From 5aacdf26e49c91fadc6f50dc2b9e19935a8f3ec4 Mon Sep 17 00:00:00 2001 From: mzxrules Date: Wed, 25 May 2022 11:43:40 -0400 Subject: [PATCH] Merge remote-tracking branch 'origin/master' into z_en_box --- .gitignore | 1 + Jenkinsfile | 6 + Makefile | 40 +- README.md | 30 +- assets/xml/code/sub_s.xml | 6 + assets/xml/interface/do_action_static.xml | 57 + assets/xml/interface/week_static.xml | 2 +- assets/xml/misc/story_static.xml | 2 +- assets/xml/objects/gameplay_dangeon_keep.xml | 48 +- assets/xml/objects/gameplay_field_keep.xml | 4 +- assets/xml/objects/gameplay_keep.xml | 146 +- assets/xml/objects/object_an1.xml | 13 +- assets/xml/objects/object_aob.xml | 110 +- assets/xml/objects/object_bb.xml | 76 +- assets/xml/objects/object_boss02.xml | 216 +- assets/xml/objects/object_boss03.xml | 30 +- assets/xml/objects/object_crow.xml | 40 +- assets/xml/objects/object_cs.xml | 4 +- assets/xml/objects/object_dekunuts.xml | 89 +- assets/xml/objects/object_dnk.xml | 93 +- assets/xml/objects/object_dog.xml | 110 +- assets/xml/objects/object_dora.xml | 27 +- assets/xml/objects/object_efc_tw.xml | 11 +- assets/xml/objects/object_fsn.xml | 164 +- assets/xml/objects/object_hariko.xml | 9 +- .../xml/objects/object_horse_link_child.xml | 4 +- assets/xml/objects/object_ice_block.xml | 35 +- assets/xml/objects/object_kbt.xml | 8 +- assets/xml/objects/object_kujiya.xml | 48 +- assets/xml/objects/object_kusa.xml | 4 +- assets/xml/objects/object_okuta.xml | 123 +- assets/xml/objects/object_open_obj.xml | 10 +- assets/xml/objects/object_raf.xml | 92 +- assets/xml/objects/object_rb.xml | 67 +- assets/xml/objects/object_shn.xml | 214 +- assets/xml/objects/object_sinkai_kabe.xml | 3 +- assets/xml/objects/object_syoten.xml | 9 +- assets/xml/objects/object_tanron4.xml | 12 +- assets/xml/objects/object_tsn.xml | 4 +- assets/xml/objects/object_utubo.xml | 87 +- assets/xml/objects/object_wallmaster.xml | 130 +- assets/xml/objects/object_wf.xml | 244 +- assets/xml/overlays/ovl_Arrow_Ice.xml | 4 +- assets/xml/overlays/ovl_Arrow_Light.xml | 13 + assets/xml/overlays/ovl_Arrow_fire.xml | 12 + assets/xml/overlays/ovl_En_Bombers.xml | 6 + assets/xml/overlays/ovl_En_Gakufu.xml | 8 + .../xml/overlays/ovl_En_Horse_Game_Check.xml | 5 + assets/xml/overlays/ovl_En_Sda.xml | 9 + assets/xml/overlays/ovl_En_Syateki_Okuta.xml | 13 + assets/xml/overlays/ovl_En_Tanron1.xml | 7 + assets/xml/overlays/ovl_Obj_Entotu.xml | 7 + assets/xml/overlays/ovl_Obj_Grass.xml | 7 + assets/xml/overlays/ovl_Obj_Smork.xml | 7 + assets/xml/overlays/ovl_Oceff_Wipe6.xml | 9 + diff_settings.py | 1 + docs/BUILDING_MACOS.md | 2 +- docs/tutorial/advanced_control_flow.md | 84 +- docs/tutorial/documenting.md | 10 +- docs/tutorial/other_functions.md | 8 +- include/functions.h | 508 +- include/ichain.h | 4 +- include/macro.inc | 36 + include/macros.h | 77 +- include/message_data_static.h | 12 + include/segment_symbols.h | 7 +- include/variables.h | 108 +- include/z64.h | 198 +- include/z64actor.h | 12 + include/z64animation.h | 125 +- include/z64audio.h | 217 +- include/z64effect.h | 1 + include/z64item.h | 8 +- include/z64light.h | 6 - include/z64math.h | 11 +- include/z64ocarina.h | 14 +- include/z64save.h | 432 +- include/z64scene.h | 3 +- include/z64schedule.h | 248 + include/z64skin.h | 106 + include/z64subs.h | 69 + include/z_en_hy_code.h | 4 +- spec | 365 +- src/boot_O2/boot_800862E0.c | 116 +- src/boot_O2_g3/idle.c | 1 + src/boot_O2_g3/idle_extra_bss.c | 3 +- src/boot_O2_g3/yaz0.c | 5 +- src/boot_O2_g3/z_std_dma.c | 10 +- src/code/audio/audio_heap.c | 1686 +++++- src/code/audio/audio_init_params.c | 2 +- src/code/audio/audio_load.c | 2320 +++++++- src/code/audio/audio_playback.c | 4 +- src/code/audio/audio_seqplayer.c | 8 +- src/code/audio/code_80192BE0.c | 6 +- src/code/audio/code_8019AF00.c | 475 +- src/code/audio/code_801A5BD0.c | 2 +- src/code/audio/code_801A7B10.c | 2 +- src/code/audioMgr.c | 2 +- src/code/code_8012EC80.c | 51 +- src/code/code_801323D0.c | 41 - src/code/flg_set.c | 204 +- src/code/graph.c | 3 +- src/code/sched.c | 1 - src/code/z_actor.c | 464 +- src/code/z_bgcheck.c | 14 +- src/code/z_camera.c | 2 +- src/code/z_common_data.c | 12 +- src/code/z_demo.c | 82 +- src/code/z_eff_blure.c | 3 +- src/code/z_effect_soft_sprite_old_init.c | 4 +- src/code/z_elf_message.c | 26 +- src/code/z_en_hy_code.c | 20 +- src/code/z_en_item00.c | 22 +- src/code/z_fireobj.c | 76 +- src/code/z_game_over.c | 8 +- src/code/z_kaleido_setup.c | 144 +- src/code/z_lib.c | 2 +- src/code/z_lifemeter.c | 51 +- src/code/z_lights.c | 9 +- src/code/z_message.c | 493 +- src/code/z_message_nes.c | 276 +- src/code/z_message_staff.c | 23 +- src/code/z_play.c | 22 +- src/code/z_quake.c | 2 +- src/code/z_rcp.c | 7 +- src/code/z_scene.c | 28 +- src/code/z_scene_proc.c | 2 +- src/code/z_schedule.c | 283 + src/code/z_skelanime.c | 23 +- src/code/z_skin.c | 272 +- src/code/z_skin_awb.c | 203 +- src/code/z_snap.c | 18 +- src/code/z_sram_NES.c | 1672 +++++- src/code/z_sub_s.c | 620 +- .../actors/ovl_Arrow_Fire/z_arrow_fire.c | 279 +- .../actors/ovl_Arrow_Fire/z_arrow_fire.h | 15 +- .../actors/ovl_Arrow_Ice/z_arrow_ice.c | 8 +- .../actors/ovl_Arrow_Light/z_arrow_light.c | 205 +- .../actors/ovl_Arrow_Light/z_arrow_light.h | 12 +- .../actors/ovl_Bg_Breakwall/z_bg_breakwall.c | 427 +- .../actors/ovl_Bg_Breakwall/z_bg_breakwall.h | 17 +- .../ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c | 698 ++- .../ovl_Bg_Dblue_Balance/z_bg_dblue_balance.h | 36 +- .../z_bg_dblue_waterfall.c | 599 +- .../z_bg_dblue_waterfall.h | 18 +- .../actors/ovl_Bg_F40_Block/z_bg_f40_block.c | 347 +- .../actors/ovl_Bg_F40_Block/z_bg_f40_block.h | 10 +- .../ovl_Bg_F40_Switch/z_bg_f40_switch.c | 167 +- .../ovl_Bg_F40_Switch/z_bg_f40_switch.h | 11 +- .../z_bg_hakugin_bombwall.c | 412 +- .../z_bg_hakugin_bombwall.h | 13 +- .../ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c | 2 + .../ovl_Bg_Ikana_Block/z_bg_ikana_block.c | 351 +- .../ovl_Bg_Ikana_Block/z_bg_ikana_block.h | 17 +- .../z_bg_ikana_rotaryroom.c | 15 +- .../ovl_Bg_Iknin_Susceil/z_bg_iknin_susceil.c | 2 +- .../actors/ovl_Bg_Iknv_Obj/z_bg_iknv_obj.c | 18 +- .../actors/ovl_Bg_Ingate/z_bg_ingate.c | 31 +- .../ovl_Bg_Kin2_Fence/z_bg_kin2_fence.c | 2 +- .../ovl_Bg_Kin2_Shelf/z_bg_kin2_shelf.c | 351 +- .../ovl_Bg_Kin2_Shelf/z_bg_kin2_shelf.h | 11 +- src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c | 2 +- .../actors/ovl_Bg_Numa_Hana/z_bg_numa_hana.c | 4 +- .../actors/ovl_Bg_Open_Spot/z_bg_open_spot.c | 51 +- .../actors/ovl_Bg_Open_Spot/z_bg_open_spot.h | 2 +- .../ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.c | 128 +- .../ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.h | 11 +- .../actors/ovl_Bg_Spdweb/z_bg_spdweb.c | 492 +- .../actors/ovl_Bg_Spdweb/z_bg_spdweb.h | 16 +- .../actors/ovl_Bg_Tobira01/z_bg_tobira01.c | 16 +- src/overlays/actors/ovl_Boss_02/z_boss_02.c | 90 +- src/overlays/actors/ovl_Boss_02/z_boss_02.h | 5 +- src/overlays/actors/ovl_Boss_03/z_boss_03.c | 2632 ++++++++- src/overlays/actors/ovl_Boss_03/z_boss_03.h | 103 +- src/overlays/actors/ovl_Boss_06/z_boss_06.c | 31 +- .../actors/ovl_Demo_Effect/z_demo_effect.c | 293 +- .../actors/ovl_Demo_Effect/z_demo_effect.h | 12 +- .../actors/ovl_Demo_Kankyo/z_demo_kankyo.c | 6 +- .../actors/ovl_Demo_Syoten/z_demo_syoten.c | 551 +- .../actors/ovl_Demo_Syoten/z_demo_syoten.h | 26 +- .../actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.c | 2 +- src/overlays/actors/ovl_Dm_An/z_dm_an.c | 339 +- src/overlays/actors/ovl_Dm_An/z_dm_an.h | 26 +- .../actors/ovl_Dm_Char01/z_dm_char01.c | 16 +- src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c | 340 +- src/overlays/actors/ovl_Dm_Gm/z_dm_gm.h | 26 +- .../actors/ovl_Dm_Ravine/z_dm_ravine.c | 2 +- src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c | 32 +- src/overlays/actors/ovl_Door_Ana/z_door_ana.c | 94 +- src/overlays/actors/ovl_Door_Ana/z_door_ana.h | 23 +- .../actors/ovl_Door_Shutter/z_door_shutter.c | 6 +- .../actors/ovl_Door_Warp1/z_door_warp1.c | 56 +- src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.c | 380 +- src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.h | 4 + src/overlays/actors/ovl_En_Ah/z_en_ah.c | 606 +- src/overlays/actors/ovl_En_Ah/z_en_ah.h | 28 +- .../ovl_En_Akindonuts/z_en_akindonuts.c | 96 +- src/overlays/actors/ovl_En_Al/z_en_al.c | 61 +- src/overlays/actors/ovl_En_Am/z_en_am.c | 13 +- src/overlays/actors/ovl_En_Am/z_en_am.h | 4 +- src/overlays/actors/ovl_En_Ani/z_en_ani.c | 2 +- .../actors/ovl_En_Aob_01/z_en_aob_01.c | 159 +- .../actors/ovl_En_Aob_01/z_en_aob_01.h | 13 +- src/overlays/actors/ovl_En_Arrow/z_en_arrow.c | 8 +- .../ovl_En_Attack_Niw/z_en_attack_niw.c | 418 +- .../ovl_En_Attack_Niw/z_en_attack_niw.h | 48 +- src/overlays/actors/ovl_En_Baba/z_en_baba.c | 99 +- .../actors/ovl_En_Baisen/z_en_baisen.c | 16 +- src/overlays/actors/ovl_En_Bb/z_en_bb.c | 728 ++- src/overlays/actors/ovl_En_Bb/z_en_bb.h | 31 +- .../actors/ovl_En_Bba_01/z_en_bba_01.c | 12 +- .../actors/ovl_En_Bbfall/z_en_bbfall.c | 778 ++- .../actors/ovl_En_Bbfall/z_en_bbfall.h | 27 +- .../actors/ovl_En_Bigokuta/z_en_bigokuta.c | 48 +- .../actors/ovl_En_Bigokuta/z_en_bigokuta.h | 8 +- src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c | 55 +- src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.h | 5 +- .../actors/ovl_En_Bigslime/z_en_bigslime.c | 73 +- .../actors/ovl_En_Bigslime/z_en_bigslime.h | 8 +- .../actors/ovl_En_Bji_01/z_en_bji_01.c | 38 +- src/overlays/actors/ovl_En_Bom/z_en_bom.c | 2 +- .../ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c | 38 +- .../ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.h | 2 +- .../actors/ovl_En_Bom_Chu/z_en_bom_chu.c | 549 +- .../actors/ovl_En_Bom_Chu/z_en_bom_chu.h | 18 +- .../actors/ovl_En_Bombers/z_en_bombers.c | 500 +- .../actors/ovl_En_Bombers/z_en_bombers.h | 40 +- .../actors/ovl_En_Bombers2/z_en_bombers2.c | 408 +- .../actors/ovl_En_Bombers2/z_en_bombers2.h | 31 +- src/overlays/actors/ovl_En_Bombf/z_en_bombf.c | 471 +- src/overlays/actors/ovl_En_Bombf/z_en_bombf.h | 16 +- .../actors/ovl_En_Bomjima/z_en_bomjima.c | 171 +- .../actors/ovl_En_Bomjimb/z_en_bomjimb.c | 70 +- src/overlays/actors/ovl_En_Box/z_en_box.c | 6 +- src/overlays/actors/ovl_En_Cha/z_en_cha.c | 10 +- .../actors/ovl_En_Cne_01/z_en_cne_01.c | 12 +- .../actors/ovl_En_Col_Man/z_en_col_man.c | 10 +- src/overlays/actors/ovl_En_Cow/z_en_cow.c | 16 +- src/overlays/actors/ovl_En_Crow/z_en_crow.c | 519 +- src/overlays/actors/ovl_En_Crow/z_en_crow.h | 16 +- src/overlays/actors/ovl_En_Dai/z_en_dai.c | 10 +- src/overlays/actors/ovl_En_Daiku/z_en_daiku.c | 17 +- .../actors/ovl_En_Daiku2/z_en_daiku2.c | 24 +- .../actors/ovl_En_Dekunuts/z_en_dekunuts.c | 105 +- .../actors/ovl_En_Dekunuts/z_en_dekunuts.h | 15 +- .../ovl_En_Demo_heishi/z_en_demo_heishi.c | 2 +- src/overlays/actors/ovl_En_Dg/z_en_dg.c | 157 +- src/overlays/actors/ovl_En_Dg/z_en_dg.h | 25 +- .../actors/ovl_En_Dinofos/z_en_dinofos.c | 83 +- .../actors/ovl_En_Dinofos/z_en_dinofos.h | 15 +- src/overlays/actors/ovl_En_Dnk/z_en_dnk.c | 62 +- src/overlays/actors/ovl_En_Dno/z_en_dno.c | 130 +- src/overlays/actors/ovl_En_Dno/z_en_dno.h | 2 +- src/overlays/actors/ovl_En_Dnp/z_en_dnp.c | 18 +- src/overlays/actors/ovl_En_Dnq/z_en_dnq.c | 16 +- src/overlays/actors/ovl_En_Dns/z_en_dns.c | 17 +- .../actors/ovl_En_Dodongo/z_en_dodongo.c | 93 +- .../actors/ovl_En_Dodongo/z_en_dodongo.h | 10 +- src/overlays/actors/ovl_En_Door/z_en_door.c | 254 +- .../actors/ovl_En_Dragon/z_en_dragon.c | 856 ++- .../actors/ovl_En_Dragon/z_en_dragon.h | 55 +- src/overlays/actors/ovl_En_Drs/z_en_drs.c | 2 +- src/overlays/actors/ovl_En_Elf/z_en_elf.c | 43 +- .../actors/ovl_En_Elfgrp/z_en_elfgrp.c | 565 +- .../actors/ovl_En_Elfgrp/z_en_elfgrp.h | 17 +- .../actors/ovl_En_Elforg/z_en_elforg.c | 10 +- src/overlays/actors/ovl_En_Fall/z_en_fall.c | 16 +- .../actors/ovl_En_Firefly/z_en_firefly.c | 65 +- .../actors/ovl_En_Firefly/z_en_firefly.h | 10 +- src/overlays/actors/ovl_En_Fish2/z_en_fish2.c | 44 +- .../actors/ovl_En_Fishing/z_en_fishing.c | 458 +- .../actors/ovl_En_Floormas/z_en_floormas.c | 146 +- .../actors/ovl_En_Floormas/z_en_floormas.h | 15 +- src/overlays/actors/ovl_En_Fsn/z_en_fsn.c | 367 +- src/overlays/actors/ovl_En_Fsn/z_en_fsn.h | 7 +- src/overlays/actors/ovl_En_Fu/z_en_fu.c | 97 +- src/overlays/actors/ovl_En_Fu/z_en_fu.h | 1 + .../actors/ovl_En_Fu_Kago/z_en_fu_kago.c | 381 +- .../actors/ovl_En_Fu_Kago/z_en_fu_kago.h | 18 +- .../actors/ovl_En_Fu_Mato/z_en_fu_mato.c | 459 +- .../actors/ovl_En_Fu_Mato/z_en_fu_mato.h | 25 +- src/overlays/actors/ovl_En_Fz/z_en_fz.c | 44 +- src/overlays/actors/ovl_En_Fz/z_en_fz.h | 6 +- .../actors/ovl_En_Gakufu/z_en_gakufu.c | 270 +- .../actors/ovl_En_Gakufu/z_en_gakufu.h | 14 +- src/overlays/actors/ovl_En_Gb2/z_en_gb2.c | 53 +- src/overlays/actors/ovl_En_Geg/z_en_geg.c | 18 +- src/overlays/actors/ovl_En_Gg/z_en_gg.c | 34 +- src/overlays/actors/ovl_En_Gg2/z_en_gg2.c | 66 +- src/overlays/actors/ovl_En_Giant/z_en_giant.c | 3 +- .../actors/ovl_En_Ginko_Man/z_en_ginko_man.c | 101 +- src/overlays/actors/ovl_En_GirlA/z_en_girla.c | 88 +- src/overlays/actors/ovl_En_GirlA/z_en_girla.h | 7 +- src/overlays/actors/ovl_En_Gk/z_en_gk.c | 72 +- src/overlays/actors/ovl_En_Gm/z_en_gm.c | 210 +- src/overlays/actors/ovl_En_Go/z_en_go.c | 65 +- .../actors/ovl_En_Goroiwa/z_en_goroiwa.c | 29 +- src/overlays/actors/ovl_En_Gs/z_en_gs.c | 46 +- .../ovl_En_Guard_Nuts/z_en_guard_nuts.c | 360 +- .../ovl_En_Guard_Nuts/z_en_guard_nuts.h | 23 +- .../actors/ovl_En_Guruguru/z_en_guruguru.c | 26 +- .../actors/ovl_En_Hanabi/z_en_hanabi.c | 323 +- .../actors/ovl_En_Hanabi/z_en_hanabi.h | 21 +- .../actors/ovl_En_Heishi/z_en_heishi.c | 8 +- src/overlays/actors/ovl_En_Hg/z_en_hg.c | 10 +- src/overlays/actors/ovl_En_Hgo/z_en_hgo.c | 12 +- .../ovl_En_Hidden_Nuts/z_en_hidden_nuts.c | 404 +- .../ovl_En_Hidden_Nuts/z_en_hidden_nuts.h | 23 +- .../actors/ovl_En_Hint_Skb/z_en_hint_skb.c | 104 +- .../actors/ovl_En_Hint_Skb/z_en_hint_skb.h | 12 +- src/overlays/actors/ovl_En_Horse/z_en_horse.c | 5046 +++++++++++++++-- src/overlays/actors/ovl_En_Horse/z_en_horse.h | 212 +- .../z_en_horse_game_check.c | 480 +- .../z_en_horse_game_check.h | 49 +- .../z_en_horse_link_child.h | 1 + src/overlays/actors/ovl_En_Hs/z_en_hs.c | 322 +- src/overlays/actors/ovl_En_Hs/z_en_hs.h | 15 +- src/overlays/actors/ovl_En_Ig/z_en_ig.c | 148 +- src/overlays/actors/ovl_En_Ig/z_en_ig.h | 4 +- src/overlays/actors/ovl_En_In/z_en_in.c | 225 +- .../actors/ovl_En_Invadepoh/z_en_invadepoh.c | 123 +- src/overlays/actors/ovl_En_Ishi/z_en_ishi.c | 2 +- src/overlays/actors/ovl_En_Ja/z_en_ja.c | 37 +- .../actors/ovl_En_Jc_Mato/z_en_jc_mato.c | 6 +- src/overlays/actors/ovl_En_Jg/z_en_jg.c | 28 +- .../actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c | 621 +- .../actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.h | 27 +- .../actors/ovl_En_Kakasi/z_en_kakasi.c | 52 +- src/overlays/actors/ovl_En_Kame/z_en_kame.c | 61 +- src/overlays/actors/ovl_En_Kame/z_en_kame.h | 10 +- .../actors/ovl_En_Kanban/z_en_kanban.c | 4 +- .../actors/ovl_En_Kanban/z_en_kanban.h | 2 +- .../actors/ovl_En_Karebaba/z_en_karebaba.c | 78 +- .../actors/ovl_En_Karebaba/z_en_karebaba.h | 10 +- src/overlays/actors/ovl_En_Kbt/z_en_kbt.c | 546 +- src/overlays/actors/ovl_En_Kbt/z_en_kbt.h | 12 +- .../actors/ovl_En_Kendo_Js/z_en_kendo_js.c | 39 +- src/overlays/actors/ovl_En_Kgy/z_en_kgy.c | 54 +- .../actors/ovl_En_Kujiya/z_en_kujiya.c | 355 +- .../actors/ovl_En_Kujiya/z_en_kujiya.h | 7 +- src/overlays/actors/ovl_En_Kusa/z_en_kusa.c | 712 ++- src/overlays/actors/ovl_En_Kusa/z_en_kusa.h | 27 +- src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c | 13 +- src/overlays/actors/ovl_En_Light/z_en_light.c | 175 +- src/overlays/actors/ovl_En_Light/z_en_light.h | 12 +- .../actors/ovl_En_Look_Nuts/z_en_look_nuts.c | 339 +- .../actors/ovl_En_Look_Nuts/z_en_look_nuts.h | 25 +- src/overlays/actors/ovl_En_Ma4/z_en_ma4.c | 54 +- .../actors/ovl_En_Ma_Yto/z_en_ma_yto.c | 118 +- .../actors/ovl_En_Ma_Yts/z_en_ma_yts.c | 36 +- src/overlays/actors/ovl_En_Mag/z_en_mag.c | 6 +- .../actors/ovl_En_Maruta/z_en_maruta.c | 635 ++- .../actors/ovl_En_Maruta/z_en_maruta.h | 15 +- .../actors/ovl_En_Minifrog/z_en_minifrog.c | 40 +- .../actors/ovl_En_Minislime/z_en_minislime.c | 8 +- src/overlays/actors/ovl_En_Mk/z_en_mk.c | 454 +- src/overlays/actors/ovl_En_Mk/z_en_mk.h | 10 +- src/overlays/actors/ovl_En_Mm/z_en_mm.c | 4 +- src/overlays/actors/ovl_En_Mm2/z_en_mm2.c | 2 +- src/overlays/actors/ovl_En_Mm3/z_en_mm3.c | 32 +- src/overlays/actors/ovl_En_Ms/z_en_ms.c | 10 +- .../actors/ovl_En_Mt_tag/z_en_mt_tag.c | 494 +- .../actors/ovl_En_Mt_tag/z_en_mt_tag.h | 11 +- src/overlays/actors/ovl_En_Muto/z_en_muto.c | 24 +- .../actors/ovl_En_Neo_Reeba/z_en_neo_reeba.c | 755 ++- .../actors/ovl_En_Neo_Reeba/z_en_neo_reeba.h | 25 +- src/overlays/actors/ovl_En_Osk/z_en_osk.c | 534 +- src/overlays/actors/ovl_En_Osk/z_en_osk.h | 13 +- src/overlays/actors/ovl_En_Osn/z_en_osn.c | 61 +- src/overlays/actors/ovl_En_Ossan/z_en_ossan.c | 350 +- src/overlays/actors/ovl_En_Ossan/z_en_ossan.h | 17 +- src/overlays/actors/ovl_En_Ot/z_en_ot.c | 123 +- src/overlays/actors/ovl_En_Ot/z_en_ot.h | 2 +- src/overlays/actors/ovl_En_Owl/z_en_owl.c | 30 +- .../actors/ovl_En_Pamera/z_en_pamera.c | 48 +- .../actors/ovl_En_Pametfrog/z_en_pametfrog.c | 71 +- .../actors/ovl_En_Pametfrog/z_en_pametfrog.h | 15 +- .../actors/ovl_En_Peehat/z_en_peehat.c | 87 +- .../actors/ovl_En_Peehat/z_en_peehat.h | 10 +- src/overlays/actors/ovl_En_Pm/z_en_pm.c | 584 +- .../ovl_En_Po_Sisters/z_en_po_sisters.c | 31 +- .../ovl_En_Po_Sisters/z_en_po_sisters.h | 6 +- src/overlays/actors/ovl_En_Poh/z_en_poh.c | 31 +- src/overlays/actors/ovl_En_Poh/z_en_poh.h | 6 +- src/overlays/actors/ovl_En_Pr/z_en_pr.c | 23 +- src/overlays/actors/ovl_En_Pr/z_en_pr.h | 6 +- src/overlays/actors/ovl_En_Pr2/z_en_pr2.c | 10 +- src/overlays/actors/ovl_En_Prz/z_en_prz.c | 2 +- .../actors/ovl_En_Racedog/z_en_racedog.c | 685 ++- .../actors/ovl_En_Racedog/z_en_racedog.h | 48 +- src/overlays/actors/ovl_En_Raf/z_en_raf.c | 917 ++- src/overlays/actors/ovl_En_Raf/z_en_raf.h | 56 +- .../actors/ovl_En_Rail_Skb/z_en_rail_skb.c | 118 +- .../actors/ovl_En_Rail_Skb/z_en_rail_skb.h | 12 +- .../actors/ovl_En_Railgibud/z_en_railgibud.c | 65 +- .../actors/ovl_En_Railgibud/z_en_railgibud.h | 8 +- src/overlays/actors/ovl_En_Rd/z_en_rd.c | 38 +- src/overlays/actors/ovl_En_Rd/z_en_rd.h | 8 +- .../actors/ovl_En_Recepgirl/z_en_recepgirl.c | 6 +- src/overlays/actors/ovl_En_Rg/z_en_rg.c | 27 +- src/overlays/actors/ovl_En_Rg/z_en_rg.h | 2 +- .../ovl_En_River_Sound/z_en_river_sound.c | 69 +- .../ovl_En_River_Sound/z_en_river_sound.h | 37 +- src/overlays/actors/ovl_En_Rr/z_en_rr.c | 62 +- src/overlays/actors/ovl_En_Rr/z_en_rr.h | 10 +- .../actors/ovl_En_Ruppecrow/z_en_ruppecrow.c | 10 +- .../actors/ovl_En_Ruppecrow/z_en_ruppecrow.h | 6 +- .../actors/ovl_En_Scopenuts/z_en_scopenuts.c | 27 +- src/overlays/actors/ovl_En_Sda/z_en_sda.c | 331 +- src/overlays/actors/ovl_En_Sda/z_en_sda.h | 2 + .../actors/ovl_En_Sellnuts/z_en_sellnuts.c | 52 +- src/overlays/actors/ovl_En_Shn/z_en_shn.c | 40 +- src/overlays/actors/ovl_En_Shn/z_en_shn.h | 4 +- src/overlays/actors/ovl_En_Skb/z_en_skb.c | 108 +- src/overlays/actors/ovl_En_Skb/z_en_skb.h | 12 +- src/overlays/actors/ovl_En_Sob1/z_en_sob1.c | 315 +- src/overlays/actors/ovl_En_Ssh/z_en_ssh.c | 10 +- src/overlays/actors/ovl_En_St/z_en_st.c | 61 +- src/overlays/actors/ovl_En_St/z_en_st.h | 4 +- src/overlays/actors/ovl_En_Sth/z_en_sth.c | 70 +- .../actors/ovl_En_Suttari/z_en_suttari.c | 379 +- .../actors/ovl_En_Suttari/z_en_suttari.h | 2 +- src/overlays/actors/ovl_En_Sw/z_en_sw.c | 64 +- src/overlays/actors/ovl_En_Sw/z_en_sw.h | 4 +- .../ovl_En_Syateki_Crow/z_en_syateki_crow.c | 25 +- .../z_en_syateki_dekunuts.c | 400 +- .../z_en_syateki_dekunuts.h | 28 +- .../ovl_En_Syateki_Man/z_en_syateki_man.c | 181 +- .../ovl_En_Syateki_Man/z_en_syateki_man.h | 10 +- .../ovl_En_Syateki_Okuta/z_en_syateki_okuta.c | 488 +- .../ovl_En_Syateki_Okuta/z_en_syateki_okuta.h | 18 +- .../ovl_En_Syateki_Wf/z_en_syateki_wf.c | 37 +- .../ovl_En_Syateki_Wf/z_en_syateki_wf.h | 7 +- src/overlays/actors/ovl_En_Tab/z_en_tab.c | 53 +- .../ovl_En_Talk_Gibud/z_en_talk_gibud.c | 63 +- .../ovl_En_Talk_Gibud/z_en_talk_gibud.h | 8 +- .../actors/ovl_En_Tanron1/z_en_tanron1.c | 389 +- .../actors/ovl_En_Tanron1/z_en_tanron1.h | 31 +- .../actors/ovl_En_Tanron3/z_en_tanron3.c | 10 +- .../actors/ovl_En_Tanron3/z_en_tanron3.h | 11 - .../actors/ovl_En_Tanron4/z_en_tanron4.c | 258 +- .../actors/ovl_En_Tanron4/z_en_tanron4.h | 19 +- .../actors/ovl_En_Tanron5/z_en_tanron5.c | 503 +- .../actors/ovl_En_Tanron5/z_en_tanron5.h | 17 +- src/overlays/actors/ovl_En_Test/z_en_test.c | 247 +- src/overlays/actors/ovl_En_Test/z_en_test.h | 20 +- src/overlays/actors/ovl_En_Test4/z_en_test4.c | 226 +- src/overlays/actors/ovl_En_Test6/z_en_test6.c | 1288 ++++- src/overlays/actors/ovl_En_Test6/z_en_test6.h | 38 +- src/overlays/actors/ovl_En_Test7/z_en_test7.c | 954 +++- src/overlays/actors/ovl_En_Test7/z_en_test7.h | 52 +- .../actors/ovl_En_Thiefbird/z_en_thiefbird.c | 93 +- .../actors/ovl_En_Thiefbird/z_en_thiefbird.h | 10 +- src/overlays/actors/ovl_En_Tite/z_en_tite.c | 91 +- src/overlays/actors/ovl_En_Tite/z_en_tite.h | 10 +- src/overlays/actors/ovl_En_Tk/z_en_tk.c | 78 +- src/overlays/actors/ovl_En_Torch/z_en_torch.c | 2 +- .../actors/ovl_En_Torch2/z_en_torch2.c | 4 +- src/overlays/actors/ovl_En_Toto/z_en_toto.c | 50 +- src/overlays/actors/ovl_En_Trt/z_en_trt.c | 261 +- src/overlays/actors/ovl_En_Trt/z_en_trt.h | 2 +- src/overlays/actors/ovl_En_Trt2/z_en_trt2.c | 58 +- src/overlays/actors/ovl_En_Tru/z_en_tru.c | 83 +- src/overlays/actors/ovl_En_Tru/z_en_tru.h | 2 + .../actors/ovl_En_Tru_Mt/z_en_tru_mt.c | 518 +- .../actors/ovl_En_Tru_Mt/z_en_tru_mt.h | 30 +- src/overlays/actors/ovl_En_Tsn/z_en_tsn.c | 611 +- src/overlays/actors/ovl_En_Tsn/z_en_tsn.h | 19 +- src/overlays/actors/ovl_En_Vm/z_en_vm.c | 501 +- src/overlays/actors/ovl_En_Vm/z_en_vm.h | 25 +- .../actors/ovl_En_Wallmas/z_en_wallmas.c | 787 ++- .../actors/ovl_En_Wallmas/z_en_wallmas.h | 46 +- .../actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c | 2 +- .../actors/ovl_En_Warp_tag/z_en_warp_tag.c | 250 +- .../actors/ovl_En_Warp_tag/z_en_warp_tag.h | 22 +- .../ovl_En_Water_Effect/z_en_water_effect.c | 2 +- .../ovl_En_Weather_Tag/z_en_weather_tag.c | 26 +- src/overlays/actors/ovl_En_Wf/z_en_wf.c | 156 +- src/overlays/actors/ovl_En_Wf/z_en_wf.h | 17 +- .../actors/ovl_En_Wood02/z_en_wood02.c | 487 +- .../actors/ovl_En_Wood02/z_en_wood02.h | 42 +- src/overlays/actors/ovl_En_Yb/z_en_yb.c | 14 +- src/overlays/actors/ovl_En_Zo/z_en_zo.c | 29 +- src/overlays/actors/ovl_En_Zo/z_en_zo.h | 2 +- src/overlays/actors/ovl_En_Zob/z_en_zob.c | 60 +- src/overlays/actors/ovl_En_Zog/z_en_zog.c | 38 +- .../actors/ovl_En_Zoraegg/z_en_zoraegg.c | 12 +- src/overlays/actors/ovl_En_Zos/z_en_zos.c | 70 +- src/overlays/actors/ovl_En_Zot/z_en_zot.c | 216 +- src/overlays/actors/ovl_En_Zov/z_en_zov.c | 26 +- src/overlays/actors/ovl_En_Zow/z_en_zow.c | 38 +- src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c | 3 +- src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.c | 399 +- src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.h | 11 +- .../actors/ovl_Obj_Armos/z_obj_armos.c | 364 +- .../actors/ovl_Obj_Armos/z_obj_armos.h | 30 +- src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c | 8 +- src/overlays/actors/ovl_Obj_Bell/z_obj_bell.c | 7 +- .../ovl_Obj_Bigicicle/z_obj_bigicicle.c | 291 +- .../ovl_Obj_Bigicicle/z_obj_bigicicle.h | 8 +- .../ovl_Obj_Blockstop/z_obj_blockstop.c | 50 +- src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c | 415 +- src/overlays/actors/ovl_Obj_Chan/z_obj_chan.h | 46 +- src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c | 4 +- .../actors/ovl_Obj_Dinner/z_obj_dinner.c | 2 +- src/overlays/actors/ovl_Obj_Dora/z_obj_dora.c | 351 +- src/overlays/actors/ovl_Obj_Dora/z_obj_dora.h | 11 +- .../actors/ovl_Obj_Driftice/z_obj_driftice.c | 436 +- .../actors/ovl_Obj_Driftice/z_obj_driftice.h | 48 +- .../actors/ovl_Obj_Entotu/z_obj_entotu.c | 148 +- .../actors/ovl_Obj_Entotu/z_obj_entotu.h | 6 +- .../ovl_Obj_Fireshield/z_obj_fireshield.c | 373 +- .../ovl_Obj_Fireshield/z_obj_fireshield.h | 20 +- .../actors/ovl_Obj_Ghaka/z_obj_ghaka.c | 15 +- .../actors/ovl_Obj_Grass/z_obj_grass.c | 495 +- .../actors/ovl_Obj_Grass/z_obj_grass.h | 36 +- .../ovl_Obj_Grass_Carry/z_obj_grass_carry.c | 333 +- .../ovl_Obj_Grass_Carry/z_obj_grass_carry.h | 8 +- .../actors/ovl_Obj_Hamishi/z_obj_hamishi.c | 261 +- .../actors/ovl_Obj_Hamishi/z_obj_hamishi.h | 13 +- .../actors/ovl_Obj_Hariko/z_obj_hariko.c | 78 +- .../actors/ovl_Obj_Hariko/z_obj_hariko.h | 5 +- .../actors/ovl_Obj_Hgdoor/z_obj_hgdoor.c | 2 +- .../ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c | 2 +- .../actors/ovl_Obj_Hunsui/z_obj_hunsui.c | 1 + .../actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.c | 2 +- .../actors/ovl_Obj_Iceblock/z_obj_iceblock.c | 136 +- .../actors/ovl_Obj_Iceblock/z_obj_iceblock.h | 14 +- .../ovl_Obj_Jgame_Light/z_obj_jgame_light.h | 2 + .../ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.c | 448 +- .../ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.h | 27 +- .../actors/ovl_Obj_Milk_Bin/z_obj_milk_bin.c | 8 +- .../ovl_Obj_Moon_Stone/z_obj_moon_stone.c | 30 +- .../actors/ovl_Obj_Mu_Pict/z_obj_mu_pict.c | 6 +- .../actors/ovl_Obj_Nozoki/z_obj_nozoki.c | 436 +- .../actors/ovl_Obj_Nozoki/z_obj_nozoki.h | 15 +- .../actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c | 2 +- .../actors/ovl_Obj_Pzlblock/z_obj_pzlblock.c | 343 +- .../actors/ovl_Obj_Pzlblock/z_obj_pzlblock.h | 19 +- .../ovl_Obj_Skateblock/z_obj_skateblock.c | 675 ++- .../ovl_Obj_Skateblock/z_obj_skateblock.h | 24 +- .../actors/ovl_Obj_Smork/z_obj_smork.c | 125 +- .../actors/ovl_Obj_Smork/z_obj_smork.h | 8 +- .../actors/ovl_Obj_Snowball/z_obj_snowball.c | 23 +- .../ovl_Obj_Snowball2/z_obj_snowball2.c | 2 +- .../ovl_Obj_Spidertent/z_obj_spidertent.c | 818 ++- .../ovl_Obj_Spidertent/z_obj_spidertent.h | 18 +- .../ovl_Obj_Spinyroll/z_obj_spinyroll.c | 676 ++- .../ovl_Obj_Spinyroll/z_obj_spinyroll.h | 48 +- .../actors/ovl_Obj_Switch/z_obj_switch.c | 1022 +++- .../actors/ovl_Obj_Switch/z_obj_switch.h | 56 +- .../ovl_Obj_Tokei_Step/z_obj_tokei_step.c | 2 +- .../actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c | 48 +- .../ovl_Obj_Vspinyroll/z_obj_vspinyroll.c | 424 +- .../ovl_Obj_Vspinyroll/z_obj_vspinyroll.h | 31 +- .../ovl_Obj_Warpstone/z_obj_warpstone.c | 6 +- .../ovl_Obj_Warpstone/z_obj_warpstone.h | 2 +- .../actors/ovl_Obj_Wturn/z_obj_wturn.c | 116 +- .../actors/ovl_Obj_Wturn/z_obj_wturn.h | 3 +- src/overlays/actors/ovl_Obj_Yado/z_obj_yado.c | 4 +- src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.c | 71 +- src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.h | 5 +- .../actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c | 1 + .../actors/ovl_Oceff_Wipe6/z_oceff_wipe6.c | 74 +- .../actors/ovl_Oceff_Wipe6/z_oceff_wipe6.h | 2 +- .../z_eff_en_ice_block.c | 72 +- .../ovl_Effect_Ss_Bubble/z_eff_ss_bubble.c | 92 +- .../ovl_Effect_Ss_Kakera/z_eff_ss_kakera.c | 183 +- .../effects/ovl_Effect_Ss_Sbn/z_eff_ss_sbn.c | 198 +- .../effects/ovl_Effect_Ss_Sbn/z_eff_ss_sbn.h | 9 +- .../ovl_Effect_Ss_Sibuki/z_eff_ss_sibuki.c | 106 +- .../ovl_Effect_Ss_Stick/z_eff_ss_stick.c | 23 +- .../ovl_Effect_Ss_Stone1/z_eff_ss_stone1.c | 67 +- .../ovl_Effect_Ss_Stone1/z_eff_ss_stone1.h | 2 +- .../gamestates/ovl_daytelop/z_daytelop.c | 24 +- .../ovl_file_choose/z_file_choose.h | 63 +- .../gamestates/ovl_opening/z_opening.c | 22 +- src/overlays/gamestates/ovl_select/z_select.c | 178 +- src/overlays/gamestates/ovl_title/z_title.c | 6 +- tools/ZAPD/.gitrepo | 4 +- tools/ZAPD/ExporterTest/CollisionExporter.cpp | 8 +- tools/ZAPD/ExporterTest/ExporterTest.vcxproj | 318 +- .../ZAPD/OtherStructs/CutsceneMM_Commands.cpp | 208 + .../ZAPD/OtherStructs/CutsceneMM_Commands.h | 140 + .../ZAPD/OtherStructs/Cutscene_Commands.cpp | 591 ++ .../ZAPD/OtherStructs/Cutscene_Commands.h | 267 + tools/ZAPD/ZAPD/ZAPD.vcxproj | 699 +-- tools/ZAPD/ZAPD/ZAPD.vcxproj.filters | 1118 ++-- tools/ZAPD/ZAPD/ZArray.cpp | 1 + tools/ZAPD/ZAPD/ZCollision.cpp | 31 +- tools/ZAPD/ZAPD/ZCollision.h | 5 +- tools/ZAPD/ZAPD/ZCollisionPoly.cpp | 76 + tools/ZAPD/ZAPD/ZCollisionPoly.h | 30 + tools/ZAPD/ZAPD/ZCutscene.cpp | 1211 +--- tools/ZAPD/ZAPD/ZCutscene.h | 426 +- tools/ZAPD/ZAPD/ZCutsceneMM.cpp | 61 - tools/ZAPD/ZAPD/ZCutsceneMM.h | 29 - tools/ZAPD/ZAPD/ZFile.cpp | 6 +- tools/ZAPD/ZAPD/ZFile.h | 6 +- tools/ZAPD/ZAPD/ZResource.cpp | 5 + tools/ZAPD/ZAPD/ZResource.h | 3 + .../ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.cpp | 98 +- tools/ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.h | 6 +- .../ZAPD/ZAPD/ZRoom/Commands/SetRoomList.cpp | 5 +- tools/ZAPD/ZAPD/ZSkeleton.cpp | 4 +- tools/ZAPD/ZAPDUtils/Utils/BitConverter.h | 5 + tools/ZAPD/ZAPDUtils/ZAPDUtils.vcxproj | 334 +- tools/ZAPDConfigs/MM/SymbolMap_MM.txt | 2 +- tools/asm-differ/.gitrepo | 4 +- tools/asm-differ/.pre-commit-config.yaml | 3 +- tools/asm-differ/README.md | 4 +- tools/asm-differ/diff.py | 196 +- tools/asm-processor/asm_processor.py | 101 +- tools/asm-processor/build.py | 56 +- tools/asm-processor/prelude.inc | 40 +- tools/disasm/disasm.py | 298 +- tools/disasm/files.txt | 5 +- tools/disasm/functions.txt | 1646 +++--- tools/disasm/mips_isa.py | 15 +- tools/disasm/variables.txt | 224 +- tools/{actorfixer.py => namefixer.py} | 345 +- tools/overlayhelpers/scheduledis.py | 264 + tools/permuter_settings.toml | 1 + tools/reloc_spec_check.sh | 112 + tools/sizes/boot_functions.csv | 18 +- tools/sizes/code_functions.csv | 446 +- undefined_syms.txt | 376 -- 627 files changed, 70449 insertions(+), 17389 deletions(-) create mode 100644 assets/xml/code/sub_s.xml create mode 100644 assets/xml/interface/do_action_static.xml create mode 100644 assets/xml/overlays/ovl_Arrow_Light.xml create mode 100644 assets/xml/overlays/ovl_Arrow_fire.xml create mode 100644 assets/xml/overlays/ovl_En_Bombers.xml create mode 100644 assets/xml/overlays/ovl_En_Gakufu.xml create mode 100644 assets/xml/overlays/ovl_En_Horse_Game_Check.xml create mode 100644 assets/xml/overlays/ovl_En_Sda.xml create mode 100644 assets/xml/overlays/ovl_En_Syateki_Okuta.xml create mode 100644 assets/xml/overlays/ovl_En_Tanron1.xml create mode 100644 assets/xml/overlays/ovl_Obj_Entotu.xml create mode 100644 assets/xml/overlays/ovl_Obj_Grass.xml create mode 100644 assets/xml/overlays/ovl_Obj_Smork.xml create mode 100644 assets/xml/overlays/ovl_Oceff_Wipe6.xml create mode 100644 include/message_data_static.h create mode 100644 include/z64schedule.h create mode 100644 include/z64skin.h create mode 100644 include/z64subs.h delete mode 100644 src/code/code_801323D0.c create mode 100644 src/code/z_schedule.c create mode 100644 tools/ZAPD/ZAPD/OtherStructs/CutsceneMM_Commands.cpp create mode 100644 tools/ZAPD/ZAPD/OtherStructs/CutsceneMM_Commands.h create mode 100644 tools/ZAPD/ZAPD/OtherStructs/Cutscene_Commands.cpp create mode 100644 tools/ZAPD/ZAPD/OtherStructs/Cutscene_Commands.h create mode 100644 tools/ZAPD/ZAPD/ZCollisionPoly.cpp create mode 100644 tools/ZAPD/ZAPD/ZCollisionPoly.h delete mode 100644 tools/ZAPD/ZAPD/ZCutsceneMM.cpp delete mode 100644 tools/ZAPD/ZAPD/ZCutsceneMM.h rename tools/{actorfixer.py => namefixer.py} (70%) create mode 100755 tools/overlayhelpers/scheduledis.py create mode 100755 tools/reloc_spec_check.sh diff --git a/.gitignore b/.gitignore index aa4a3a5c41..a2acf29c31 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ tags # Project-specific ignores *.z64 +*.sra *.bin *.elf archive/ diff --git a/Jenkinsfile b/Jenkinsfile index 50cd889087..3ebfd36147 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -14,6 +14,12 @@ pipeline { sh 'bash -c "tools/check_format.sh 2>&1 >(tee tools/check_format.txt)"' } } + stage('Check relocs') { + steps { + echo 'Checking relocs on spec...' + sh 'bash -c "tools/reloc_spec_check.sh"' + } + } stage('Copy ROM') { steps { echo 'Setting up ROM...' diff --git a/Makefile b/Makefile index c0569cbe13..ac7174e893 100644 --- a/Makefile +++ b/Makefile @@ -21,8 +21,9 @@ ifeq ($(NON_MATCHING),1) COMPARE := 0 endif +DISASM_FLAGS := --reg-names=o32 ifneq ($(FULL_DISASM), 0) - DISASM_FLAGS += --full + DISASM_FLAGS += --all endif PROJECT_DIR := $(dir $(realpath $(firstword $(MAKEFILE_LIST)))) @@ -72,6 +73,9 @@ AS := $(MIPS_BINUTILS_PREFIX)as LD := $(MIPS_BINUTILS_PREFIX)ld OBJCOPY := $(MIPS_BINUTILS_PREFIX)objcopy OBJDUMP := $(MIPS_BINUTILS_PREFIX)objdump +ASM_PROC := python3 tools/asm-processor/build.py + +ASM_PROC_FLAGS := --input-enc=utf-8 --output-enc=euc-jp IINC := -Iinclude -Isrc -Iassets -Ibuild -I. @@ -96,7 +100,10 @@ ASFLAGS := -march=vr4300 -32 -Iinclude MIPS_VERSION := -mips2 # we support Microsoft extensions such as anonymous structs, which the compiler does support but warns for their usage. Surpress the warnings with -woff. -CFLAGS += -G 0 -non_shared -Xfullwarn -Xcpluscomm $(IINC) -nostdinc -Wab,-r4300_mul -woff 624,649,838,712 +CFLAGS += -G 0 -non_shared -fullwarn -verbose -Xcpluscomm $(IINC) -nostdinc -Wab,-r4300_mul -woff 624,649,838,712,516 + +# Use relocations and abi fpr names in the dump +OBJDUMP_FLAGS := -d -r -z -Mreg-names=32 ifeq ($(shell getconf LONG_BIT), 32) # Work around memory allocation bug in QEMU @@ -177,6 +184,7 @@ build/src/libultra/flash/%.o: MIPS_VERSION := -mips1 build/src/code/audio/%.o: OPTFLAGS := -O2 build/assets/%.o: OPTFLAGS := -O1 +build/assets/%.o: ASM_PROC_FLAGS := # file flags build/src/boot_O2_g3/fault.o: CFLAGS += -trapuv @@ -193,21 +201,19 @@ build/src/libultra/libc/llcvt.o: OPTFLAGS := -O1 build/src/libultra/libc/llcvt.o: MIPS_VERSION := -mips3 -32 # cc & asm-processor -build/src/boot_O2/%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $(AS) $(ASFLAGS) -- -build/src/boot_O2_g3/%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $(AS) $(ASFLAGS) -- +build/src/boot_O2/%.o: CC := $(ASM_PROC) $(ASM_PROC_FLAGS) $(CC) -- $(AS) $(ASFLAGS) -- +build/src/boot_O2_g3/%.o: CC := $(ASM_PROC) $(ASM_PROC_FLAGS) $(CC) -- $(AS) $(ASFLAGS) -- -build/src/libultra/%.o: CC := python3 tools/asm-processor/build.py $(CC_OLD) -- $(AS) $(ASFLAGS) -- +build/src/libultra/%.o: CC := $(CC_OLD) +# Needed at least until voice is decompiled +build/src/libultra/voice/%.o: CC := $(ASM_PROC) $(ASM_PROC_FLAGS) $(CC_OLD) -- $(AS) $(ASFLAGS) -- -build/src/code/%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $(AS) $(ASFLAGS) -- -build/src/code/audio/%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $(AS) $(ASFLAGS) -- +build/src/code/%.o: CC := $(ASM_PROC) $(ASM_PROC_FLAGS) $(CC) -- $(AS) $(ASFLAGS) -- +build/src/code/audio/%.o: CC := $(ASM_PROC) $(ASM_PROC_FLAGS) $(CC) -- $(AS) $(ASFLAGS) -- -build/src/overlays/actors/%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $(AS) $(ASFLAGS) -- -build/src/overlays/effects/%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $(AS) $(ASFLAGS) -- -build/src/overlays/fbdemos/%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $(AS) $(ASFLAGS) -- -build/src/overlays/gamestates/%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $(AS) $(ASFLAGS) -- -build/src/overlays/kaleido_scope/%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $(AS) $(ASFLAGS) -- +build/src/overlays/%.o: CC := $(ASM_PROC) $(ASM_PROC_FLAGS) $(CC) -- $(AS) $(ASFLAGS) -- -build/assets/%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $(AS) $(ASFLAGS) -- +build/assets/%.o: CC := $(ASM_PROC) $(ASM_PROC_FLAGS) $(CC) -- $(AS) $(ASFLAGS) -- #### Main Targets ### @@ -302,7 +308,7 @@ build/data/%.o: data/%.s build/src/overlays/%.o: src/overlays/%.c $(CC_CHECK) $< $(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $< - @$(OBJDUMP) -d $@ > $(@:.o=.s) + @$(OBJDUMP) $(OBJDUMP_FLAGS) $@ > $(@:.o=.s) # TODO: `() || true` is currently necessary to suppress `Error 1 (ignored)` make warnings caused by `test`, but this will go away if # the following is moved to a separate rule that is only run once when all the required objects have been compiled. $(ZAPD) bovl -eh -i $@ -cfg $< --outputpath $(@D)/$(notdir $(@D))_reloc.s @@ -312,21 +318,21 @@ build/src/overlays/%.o: src/overlays/%.c build/src/%.o: src/%.c $(CC_CHECK) $< $(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $< - @$(OBJDUMP) -d $@ > $(@:.o=.s) + @$(OBJDUMP) $(OBJDUMP_FLAGS) $@ > $(@:.o=.s) $(RM_MDEBUG) build/src/libultra/libc/ll.o: src/libultra/libc/ll.c $(CC_CHECK) $< $(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $< python3 tools/set_o32abi_bit.py $@ - @$(OBJDUMP) -d $@ > $(@:.o=.s) + @$(OBJDUMP) $(OBJDUMP_FLAGS) $@ > $(@:.o=.s) $(RM_MDEBUG) build/src/libultra/libc/llcvt.o: src/libultra/libc/llcvt.c $(CC_CHECK) $< $(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $< python3 tools/set_o32abi_bit.py $@ - @$(OBJDUMP) -d $@ > $(@:.o=.s) + @$(OBJDUMP) $(OBJDUMP_FLAGS) $@ > $(@:.o=.s) $(RM_MDEBUG) # Build C files from assets diff --git a/README.md b/README.md index 845a10cc67..c3ce27e979 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ We recommend using Debian or Ubuntu 20.04 Linux distributions. ### MacOS -Preparation is covered in a [separate document](docsBUILDING_MACOS.md). +Preparation is covered in a [separate document](docs/BUILDING_MACOS.md). ### Linux (Native or under WSL / VM) @@ -74,13 +74,7 @@ sudo apt update sudo apt install make git build-essential binutils-mips-linux-gnu python3 python3-pip libpng-dev ``` -To install the Python dependencies simply run in a terminal: - -```bash -python3 -m pip install -r requirements.txt -``` - -#### 2. Fork the repository +#### 2. Clone the repository Create your own fork of the repository at `https://github.com/zeldaret/mm`. Then clone your fork where you wish to have the project, with the command: @@ -88,11 +82,27 @@ Create your own fork of the repository at `https://github.com/zeldaret/mm`. Then git clone https://github.com//mm.git ``` -#### 3. Prepare a base ROM +This will copy the GitHub repository contents into a new folder in the current directory called `mm`. Change into this directory before doing anything else: + +```bash +cd mm +``` + +#### 3. Install python dependencies + +The build process has a few python packages required that are located in `requirements.txt`. + +To install them simply run in a terminal: + +```bash +python3 -m pip install -r requirements.txt +``` + +#### 4. Prepare a base ROM Copy your ROM to inside the root of this new project directory, and rename the file of the baserom to reflect the version of ROM you are using. ex: `baserom.mm.us.rev1.z64` -#### 4. Make and Build the ROM +#### 5. Make and Build the ROM To start the extraction/build process, run the following command: diff --git a/assets/xml/code/sub_s.xml b/assets/xml/code/sub_s.xml new file mode 100644 index 0000000000..03329f0c59 --- /dev/null +++ b/assets/xml/code/sub_s.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/assets/xml/interface/do_action_static.xml b/assets/xml/interface/do_action_static.xml new file mode 100644 index 0000000000..3fdd1e404f --- /dev/null +++ b/assets/xml/interface/do_action_static.xml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/interface/week_static.xml b/assets/xml/interface/week_static.xml index 6b21b80c0b..12cc885fa9 100644 --- a/assets/xml/interface/week_static.xml +++ b/assets/xml/interface/week_static.xml @@ -1,5 +1,5 @@ - + diff --git a/assets/xml/misc/story_static.xml b/assets/xml/misc/story_static.xml index d53f3f857f..9a15d8c4f3 100644 --- a/assets/xml/misc/story_static.xml +++ b/assets/xml/misc/story_static.xml @@ -1,5 +1,5 @@ - + diff --git a/assets/xml/objects/gameplay_dangeon_keep.xml b/assets/xml/objects/gameplay_dangeon_keep.xml index 70f9d606b1..9d5a9901ad 100644 --- a/assets/xml/objects/gameplay_dangeon_keep.xml +++ b/assets/xml/objects/gameplay_dangeon_keep.xml @@ -14,20 +14,20 @@ - - + + - - + + - - - - - - - + + + + + + + @@ -59,15 +59,15 @@ - + - + - - - - - + + + + + @@ -75,15 +75,19 @@ + + - - - - + + + + + + diff --git a/assets/xml/objects/gameplay_field_keep.xml b/assets/xml/objects/gameplay_field_keep.xml index 7a299bff7b..45fa3eccde 100644 --- a/assets/xml/objects/gameplay_field_keep.xml +++ b/assets/xml/objects/gameplay_field_keep.xml @@ -40,8 +40,8 @@ - - + + diff --git a/assets/xml/objects/gameplay_keep.xml b/assets/xml/objects/gameplay_keep.xml index 265f1d5601..41b144120f 100644 --- a/assets/xml/objects/gameplay_keep.xml +++ b/assets/xml/objects/gameplay_keep.xml @@ -38,7 +38,7 @@ - + @@ -68,7 +68,7 @@ - + @@ -838,8 +838,11 @@ - - + + + + + @@ -870,9 +873,9 @@ - - - + + + @@ -903,12 +906,12 @@ - - - - - - + + + + + + @@ -1000,7 +1003,7 @@ - + @@ -1050,15 +1053,15 @@ - - - - - - - - - + + + + + + + + + @@ -1082,7 +1085,7 @@ - + @@ -1108,13 +1111,13 @@ - - + + - - + + @@ -1169,8 +1172,8 @@ - - + + @@ -1259,7 +1262,8 @@ - + + @@ -1268,7 +1272,8 @@ - + + @@ -1282,27 +1287,27 @@ - + - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - + + + + + @@ -1353,7 +1358,8 @@ - + + @@ -1384,7 +1390,8 @@ - + + @@ -1405,23 +1412,28 @@ - - - - - - - - + + + + + + + + + + + - - - - - - + + + + + + + + diff --git a/assets/xml/objects/object_an1.xml b/assets/xml/objects/object_an1.xml index 15c38af325..2c212923d7 100644 --- a/assets/xml/objects/object_an1.xml +++ b/assets/xml/objects/object_an1.xml @@ -35,15 +35,22 @@ - + - + - + + + + + + + + diff --git a/assets/xml/objects/object_aob.xml b/assets/xml/objects/object_aob.xml index 7c1e2e4ef7..3325e9b53b 100644 --- a/assets/xml/objects/object_aob.xml +++ b/assets/xml/objects/object_aob.xml @@ -1,53 +1,65 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_bb.xml b/assets/xml/objects/object_bb.xml index 4f1c39dac0..c9c6a0a908 100644 --- a/assets/xml/objects/object_bb.xml +++ b/assets/xml/objects/object_bb.xml @@ -1,37 +1,47 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_boss02.xml b/assets/xml/objects/object_boss02.xml index 0370e1ae2f..9a400554b7 100644 --- a/assets/xml/objects/object_boss02.xml +++ b/assets/xml/objects/object_boss02.xml @@ -1,99 +1,125 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_boss03.xml b/assets/xml/objects/object_boss03.xml index e483cbc896..75ce1d3c9f 100644 --- a/assets/xml/objects/object_boss03.xml +++ b/assets/xml/objects/object_boss03.xml @@ -49,23 +49,23 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + - + diff --git a/assets/xml/objects/object_crow.xml b/assets/xml/objects/object_crow.xml index 3092d91ec3..de51da580e 100644 --- a/assets/xml/objects/object_crow.xml +++ b/assets/xml/objects/object_crow.xml @@ -1,24 +1,24 @@  - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_cs.xml b/assets/xml/objects/object_cs.xml index 5ed7254937..803d2b02c2 100644 --- a/assets/xml/objects/object_cs.xml +++ b/assets/xml/objects/object_cs.xml @@ -20,7 +20,7 @@ - + @@ -62,7 +62,7 @@ - + diff --git a/assets/xml/objects/object_dekunuts.xml b/assets/xml/objects/object_dekunuts.xml index 2e9529d4c6..8a45dd04a9 100644 --- a/assets/xml/objects/object_dekunuts.xml +++ b/assets/xml/objects/object_dekunuts.xml @@ -1,42 +1,55 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_dnk.xml b/assets/xml/objects/object_dnk.xml index 359cdfd5d3..ad69c7722d 100644 --- a/assets/xml/objects/object_dnk.xml +++ b/assets/xml/objects/object_dnk.xml @@ -1,50 +1,51 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_dog.xml b/assets/xml/objects/object_dog.xml index f14a3d55e7..89eba9c96a 100644 --- a/assets/xml/objects/object_dog.xml +++ b/assets/xml/objects/object_dog.xml @@ -1,53 +1,65 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_dora.xml b/assets/xml/objects/object_dora.xml index 6a09726665..ab4b09cf7f 100644 --- a/assets/xml/objects/object_dora.xml +++ b/assets/xml/objects/object_dora.xml @@ -1,17 +1,18 @@  + - - - - - - - - - - - - - + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_efc_tw.xml b/assets/xml/objects/object_efc_tw.xml index 4d4c1029c5..3cb6468b9f 100644 --- a/assets/xml/objects/object_efc_tw.xml +++ b/assets/xml/objects/object_efc_tw.xml @@ -1,10 +1,13 @@  - + + + + - - - + + + diff --git a/assets/xml/objects/object_fsn.xml b/assets/xml/objects/object_fsn.xml index 7c3d0beb2a..f90bf4e4d0 100644 --- a/assets/xml/objects/object_fsn.xml +++ b/assets/xml/objects/object_fsn.xml @@ -1,63 +1,111 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_hariko.xml b/assets/xml/objects/object_hariko.xml index e0f139b883..5cb2d83288 100644 --- a/assets/xml/objects/object_hariko.xml +++ b/assets/xml/objects/object_hariko.xml @@ -1,8 +1,9 @@  + - - - - + + + + diff --git a/assets/xml/objects/object_horse_link_child.xml b/assets/xml/objects/object_horse_link_child.xml index 47ceff55aa..506135e0c9 100644 --- a/assets/xml/objects/object_horse_link_child.xml +++ b/assets/xml/objects/object_horse_link_child.xml @@ -10,7 +10,9 @@ - + + + diff --git a/assets/xml/objects/object_ice_block.xml b/assets/xml/objects/object_ice_block.xml index 1e14ea5b5f..ba755d100b 100644 --- a/assets/xml/objects/object_ice_block.xml +++ b/assets/xml/objects/object_ice_block.xml @@ -1,15 +1,28 @@  - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_kbt.xml b/assets/xml/objects/object_kbt.xml index ec8dbd6ea3..aad49e9460 100644 --- a/assets/xml/objects/object_kbt.xml +++ b/assets/xml/objects/object_kbt.xml @@ -42,7 +42,13 @@ - + + + + + + + diff --git a/assets/xml/objects/object_kujiya.xml b/assets/xml/objects/object_kujiya.xml index 3b17d43c08..f657e8bd8d 100644 --- a/assets/xml/objects/object_kujiya.xml +++ b/assets/xml/objects/object_kujiya.xml @@ -1,25 +1,31 @@  + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_kusa.xml b/assets/xml/objects/object_kusa.xml index 0d36569a55..36c61f3648 100644 --- a/assets/xml/objects/object_kusa.xml +++ b/assets/xml/objects/object_kusa.xml @@ -1,6 +1,6 @@  - - + + diff --git a/assets/xml/objects/object_okuta.xml b/assets/xml/objects/object_okuta.xml index e71f65a1cb..e10afa1355 100644 --- a/assets/xml/objects/object_okuta.xml +++ b/assets/xml/objects/object_okuta.xml @@ -1,59 +1,72 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_open_obj.xml b/assets/xml/objects/object_open_obj.xml index ea1664a884..74a4101bdd 100644 --- a/assets/xml/objects/object_open_obj.xml +++ b/assets/xml/objects/object_open_obj.xml @@ -4,11 +4,11 @@ - - - - - + + + + + diff --git a/assets/xml/objects/object_raf.xml b/assets/xml/objects/object_raf.xml index 26c0741ecc..e3b4d2d934 100644 --- a/assets/xml/objects/object_raf.xml +++ b/assets/xml/objects/object_raf.xml @@ -1,42 +1,58 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_rb.xml b/assets/xml/objects/object_rb.xml index a344c5327e..72b3e6cb67 100644 --- a/assets/xml/objects/object_rb.xml +++ b/assets/xml/objects/object_rb.xml @@ -1,44 +1,53 @@  + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - + + diff --git a/assets/xml/objects/object_shn.xml b/assets/xml/objects/object_shn.xml index 1b94600ab4..4a8e018675 100644 --- a/assets/xml/objects/object_shn.xml +++ b/assets/xml/objects/object_shn.xml @@ -1,97 +1,125 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_sinkai_kabe.xml b/assets/xml/objects/object_sinkai_kabe.xml index 96f8531ad0..3c23a73cef 100644 --- a/assets/xml/objects/object_sinkai_kabe.xml +++ b/assets/xml/objects/object_sinkai_kabe.xml @@ -1,5 +1,6 @@  + - + diff --git a/assets/xml/objects/object_syoten.xml b/assets/xml/objects/object_syoten.xml index 9802f7701b..2e546f471e 100644 --- a/assets/xml/objects/object_syoten.xml +++ b/assets/xml/objects/object_syoten.xml @@ -1,6 +1,7 @@  - + + @@ -12,12 +13,16 @@ - + + + + + diff --git a/assets/xml/objects/object_tanron4.xml b/assets/xml/objects/object_tanron4.xml index f1002fd229..2c988e74b3 100644 --- a/assets/xml/objects/object_tanron4.xml +++ b/assets/xml/objects/object_tanron4.xml @@ -1,14 +1,19 @@  + - - + + + + + + @@ -19,6 +24,7 @@ - + + diff --git a/assets/xml/objects/object_tsn.xml b/assets/xml/objects/object_tsn.xml index bd83a3be50..761a6e0d74 100644 --- a/assets/xml/objects/object_tsn.xml +++ b/assets/xml/objects/object_tsn.xml @@ -26,11 +26,11 @@ - + - + diff --git a/assets/xml/objects/object_utubo.xml b/assets/xml/objects/object_utubo.xml index 68cd3e1960..a1f499eb6a 100644 --- a/assets/xml/objects/object_utubo.xml +++ b/assets/xml/objects/object_utubo.xml @@ -1,42 +1,53 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_wallmaster.xml b/assets/xml/objects/object_wallmaster.xml index d6ab1aa02e..fba2bc2460 100644 --- a/assets/xml/objects/object_wallmaster.xml +++ b/assets/xml/objects/object_wallmaster.xml @@ -1,63 +1,75 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_wf.xml b/assets/xml/objects/object_wf.xml index 4775552e2c..3d9ce392db 100644 --- a/assets/xml/objects/object_wf.xml +++ b/assets/xml/objects/object_wf.xml @@ -1,110 +1,142 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/overlays/ovl_Arrow_Ice.xml b/assets/xml/overlays/ovl_Arrow_Ice.xml index 9ac5d04e07..bec512600b 100644 --- a/assets/xml/overlays/ovl_Arrow_Ice.xml +++ b/assets/xml/overlays/ovl_Arrow_Ice.xml @@ -1,8 +1,8 @@ - - + + diff --git a/assets/xml/overlays/ovl_Arrow_Light.xml b/assets/xml/overlays/ovl_Arrow_Light.xml new file mode 100644 index 0000000000..3d5ae87b84 --- /dev/null +++ b/assets/xml/overlays/ovl_Arrow_Light.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/assets/xml/overlays/ovl_Arrow_fire.xml b/assets/xml/overlays/ovl_Arrow_fire.xml new file mode 100644 index 0000000000..893f335d0d --- /dev/null +++ b/assets/xml/overlays/ovl_Arrow_fire.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/assets/xml/overlays/ovl_En_Bombers.xml b/assets/xml/overlays/ovl_En_Bombers.xml new file mode 100644 index 0000000000..c6fc64246b --- /dev/null +++ b/assets/xml/overlays/ovl_En_Bombers.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/assets/xml/overlays/ovl_En_Gakufu.xml b/assets/xml/overlays/ovl_En_Gakufu.xml new file mode 100644 index 0000000000..92b2672d4c --- /dev/null +++ b/assets/xml/overlays/ovl_En_Gakufu.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/assets/xml/overlays/ovl_En_Horse_Game_Check.xml b/assets/xml/overlays/ovl_En_Horse_Game_Check.xml new file mode 100644 index 0000000000..bcb8ea695f --- /dev/null +++ b/assets/xml/overlays/ovl_En_Horse_Game_Check.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/assets/xml/overlays/ovl_En_Sda.xml b/assets/xml/overlays/ovl_En_Sda.xml new file mode 100644 index 0000000000..7e257ee202 --- /dev/null +++ b/assets/xml/overlays/ovl_En_Sda.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/assets/xml/overlays/ovl_En_Syateki_Okuta.xml b/assets/xml/overlays/ovl_En_Syateki_Okuta.xml new file mode 100644 index 0000000000..0e5054c19f --- /dev/null +++ b/assets/xml/overlays/ovl_En_Syateki_Okuta.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/assets/xml/overlays/ovl_En_Tanron1.xml b/assets/xml/overlays/ovl_En_Tanron1.xml new file mode 100644 index 0000000000..17cf5faf50 --- /dev/null +++ b/assets/xml/overlays/ovl_En_Tanron1.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/assets/xml/overlays/ovl_Obj_Entotu.xml b/assets/xml/overlays/ovl_Obj_Entotu.xml new file mode 100644 index 0000000000..e6e6c64cf4 --- /dev/null +++ b/assets/xml/overlays/ovl_Obj_Entotu.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/assets/xml/overlays/ovl_Obj_Grass.xml b/assets/xml/overlays/ovl_Obj_Grass.xml new file mode 100644 index 0000000000..e1002b369a --- /dev/null +++ b/assets/xml/overlays/ovl_Obj_Grass.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/assets/xml/overlays/ovl_Obj_Smork.xml b/assets/xml/overlays/ovl_Obj_Smork.xml new file mode 100644 index 0000000000..745c6b6af0 --- /dev/null +++ b/assets/xml/overlays/ovl_Obj_Smork.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/assets/xml/overlays/ovl_Oceff_Wipe6.xml b/assets/xml/overlays/ovl_Oceff_Wipe6.xml new file mode 100644 index 0000000000..e64c8cc71e --- /dev/null +++ b/assets/xml/overlays/ovl_Oceff_Wipe6.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/diff_settings.py b/diff_settings.py index a6cee9dc80..4eeb4989c1 100755 --- a/diff_settings.py +++ b/diff_settings.py @@ -5,4 +5,5 @@ def apply(config, args): config['myimg'] = 'mm.us.rev1.rom_uncompressed.z64' config['mapfile'] = 'build/mm.map' config['source_directories'] = ['./src','./include'] + config['objdump_flags'] = ['-M','reg-names=32'] config['makeflags'] = ['KEEP_MDEBUG=1'] diff --git a/docs/BUILDING_MACOS.md b/docs/BUILDING_MACOS.md index 17b683442c..77f1d839e6 100644 --- a/docs/BUILDING_MACOS.md +++ b/docs/BUILDING_MACOS.md @@ -80,4 +80,4 @@ If this worked, you can now delete the temporary directory `~/binutils-tmp`. Apple's version of `make` is very out-of-date, so you should use the brew-installed `gmake` in place of `make` in this repo from now on. -You should now be able to continue from [step 2](README.md#2-clone-the-repository) of the Linux instructions. +You should now be able to continue from [step 2](../README.md#2-clone-the-repository) of the Linux instructions. diff --git a/docs/tutorial/advanced_control_flow.md b/docs/tutorial/advanced_control_flow.md index 3420fc5977..4952f7586c 100644 --- a/docs/tutorial/advanced_control_flow.md +++ b/docs/tutorial/advanced_control_flow.md @@ -81,7 +81,7 @@ void EnMs_Destroy(Actor* thisx, GlobalContext* globalCtx) { void func_80952734(EnMs* this, GlobalContext* globalCtx) { s16 temp_v1 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - if (gSaveContext.inventory.items[10] == ITEM_NONE) { + if (gSaveContext.save.inventory.items[10] == ITEM_NONE) { this->actor.textId = 0x92E; } else { this->actor.textId = 0x932; @@ -159,14 +159,14 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { temp_v0 = Message_GetState(&globalCtx->msgCtx); if (temp_v0 != 4) { if (temp_v0 != 5) { - if ((temp_v0 == 6) && (func_80147624(globalCtx) != 0)) { + if ((temp_v0 == 6) && (Message_ShouldAdvance(globalCtx) != 0)) { this->actionFunc = func_80952734; return; } // Duplicate return node #17. Try simplifying control flow for better match return; } - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx) != 0) { func_801477B4(globalCtx); Actor_PickUp((Actor *) this, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); this->actionFunc = func_809529AC; @@ -175,7 +175,7 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { // Duplicate return node #17. Try simplifying control flow for better match return; } - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx) != 0) { temp_v0_2 = globalCtx->msgCtx.choiceIndex; if (temp_v0_2 != 0) { if (temp_v0_2 != 1) { @@ -187,12 +187,12 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { return; } func_801477B4(globalCtx); - if ((s32) gSaveContext.rupees < 0xA) { + if ((s32) gSaveContext.save.playerData.rupees < 0xA) { play_sound(0x4806U); func_80151938(globalCtx, 0x935U); return; } - if ((s32) gSaveContext.inventory.ammo[gItemSlots[0xA]] >= 0x14) { + if ((s32) gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) { play_sound(0x4806U); func_80151938(globalCtx, 0x937U); return; @@ -211,7 +211,7 @@ which is long, messy, and contains some rather nasty-looking control flow, inclu temp_v0 = Message_GetState(&globalCtx->msgCtx); if (temp_v0 != 4) { if (temp_v0 != 5) { - if ((temp_v0 == 6) && (func_80147624(globalCtx) != 0)) { + if ((temp_v0 == 6) && (Message_ShouldAdvance(globalCtx) != 0)) { this->actionFunc = func_80952734; return; } @@ -248,13 +248,13 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { if (temp_v0 != 6) { goto block_17; } - if (func_80147624(globalCtx) == 0) { + if (Message_ShouldAdvance(globalCtx) == 0) { goto block_17; } this->actionFunc = func_80952734; return; block_5: - if (func_80147624(globalCtx) == 0) { + if (Message_ShouldAdvance(globalCtx) == 0) { goto block_17; } func_801477B4(globalCtx); @@ -262,7 +262,7 @@ block_5: this->actionFunc = func_809529AC; return; block_7: - if (func_80147624(globalCtx) == 0) { + if (Message_ShouldAdvance(globalCtx) == 0) { goto block_17; } temp_v0_2 = globalCtx->msgCtx.choiceIndex; @@ -275,14 +275,14 @@ block_7: goto block_16; block_11: func_801477B4(globalCtx); - if ((s32) gSaveContext.rupees >= 0xA) { + if ((s32) gSaveContext.save.playerData.rupees >= 0xA) { goto block_13; } play_sound(0x4806U); func_80151938(globalCtx, 0x935U); return; block_13: - if ((s32) gSaveContext.inventory.ammo[gItemSlots[0xA]] < 0x14) { + if ((s32) gSaveContext.save.inventory.ammo[gItemSlots[0xA]] < 0x14) { goto block_15; } play_sound(0x4806U); @@ -312,7 +312,7 @@ which in many ways looks worse: you can see why the use of gotos in code is stro The simplest sort of block label to eliminate is one that is only used once, and where the corresponding goto jumps over a simple block of code with no extra internal control flow structure. There are two obvious examples of this here, the first being ```C - if ((s32) gSaveContext.rupees >= 0xA) { + if ((s32) gSaveContext.save.playerData.rupees >= 0xA) { goto block_13; } play_sound(0x4806U); @@ -324,7 +324,7 @@ block_13: Currently, this says to jump over the code block `play_sound...` if the condition in the if is satisfied. In non-goto terms, this means that the block should be run if the condition is *not* satisfied. This also illustrates a general property of goto-only mode: you have to reverse the senses of all of the ifs. Therefore the appropriate approach is to swap the if round, put the code block inside, and remove the goto and the label: ```C - if (gSaveContext.rupees < 0xA) { + if (gSaveContext.save.playerData.rupees < 0xA) { play_sound(0x4806U); func_80151938(globalCtx, 0x935U); return; @@ -350,13 +350,13 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { if (temp_v0 != 6) { goto block_17; } - if (func_80147624(globalCtx) == 0) { + if (Message_ShouldAdvance(globalCtx) == 0) { goto block_17; } this->actionFunc = func_80952734; return; block_5: - if (func_80147624(globalCtx) == 0) { + if (Message_ShouldAdvance(globalCtx) == 0) { goto block_17; } func_801477B4(globalCtx); @@ -364,7 +364,7 @@ block_5: this->actionFunc = func_809529AC; return; block_7: - if (func_80147624(globalCtx) == 0) { + if (Message_ShouldAdvance(globalCtx) == 0) { goto block_17; } temp_v0_2 = globalCtx->msgCtx.choiceIndex; @@ -378,12 +378,12 @@ block_7: block_11: func_801477B4(globalCtx); - if (gSaveContext.rupees < 0xA) { + if (gSaveContext.save.playerData.rupees < 0xA) { play_sound(0x4806U); func_80151938(globalCtx, 0x935U); return; } - if (gSaveContext.inventory.ammo[gItemSlots[0xA]] >= 0x14) { + if (gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) { play_sound(0x4806U); func_80151938(globalCtx, 0x937U); return; @@ -420,13 +420,13 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { if (temp_v0 != 6) { return; } - if (func_80147624(globalCtx) == 0) { + if (Message_ShouldAdvance(globalCtx) == 0) { return; } this->actionFunc = func_80952734; return; block_5: - if (func_80147624(globalCtx) == 0) { + if (Message_ShouldAdvance(globalCtx) == 0) { return; } func_801477B4(globalCtx); @@ -434,7 +434,7 @@ block_5: this->actionFunc = func_809529AC; return; block_7: - if (func_80147624(globalCtx) == 0) { + if (Message_ShouldAdvance(globalCtx) == 0) { return; } temp_v0_2 = globalCtx->msgCtx.choiceIndex; @@ -448,12 +448,12 @@ block_7: block_11: func_801477B4(globalCtx); - if (gSaveContext.rupees < 0xA) { + if (gSaveContext.save.playerData.rupees < 0xA) { play_sound(0x4806U); func_80151938(globalCtx, 0x935U); return; } - if (gSaveContext.inventory.ammo[gItemSlots[0xA]] >= 0x14) { + if (gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) { play_sound(0x4806U); func_80151938(globalCtx, 0x937U); return; @@ -497,12 +497,12 @@ So let us rewrite the entire second half as a switch: case 0: func_801477B4(globalCtx); - if (gSaveContext.rupees < 0xA) { + if (gSaveContext.save.playerData.rupees < 0xA) { play_sound(0x4806U); func_80151938(globalCtx, 0x935U); return; } - if (gSaveContext.inventory.ammo[gItemSlots[0xA]] >= 0x14) { + if (gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) { play_sound(0x4806U); func_80151938(globalCtx, 0x937U); return; @@ -532,10 +532,10 @@ There's a couple of other obvious things here: case 0: func_801477B4(globalCtx); - if (gSaveContext.rupees < 0xA) { + if (gSaveContext.save.playerData.rupees < 0xA) { play_sound(0x4806U); func_80151938(globalCtx, 0x935U); - } else if (gSaveContext.inventory.ammo[gItemSlots[0xA]] >= 0x14) { + } else if (gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) { play_sound(0x4806U); func_80151938(globalCtx, 0x937U); } else { @@ -557,7 +557,7 @@ There's a couple of other obvious things here: Well, at least the bottom half looks respectable now. Again, there is no code after the switch, so the next thing up, namely ```C - if (func_80147624(globalCtx) == 0) { + if (Message_ShouldAdvance(globalCtx) == 0) { return; } ``` @@ -578,13 +578,13 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { if (temp_v0 != 6) { return; } - if (func_80147624(globalCtx) == 0) { + if (Message_ShouldAdvance(globalCtx) == 0) { return; } this->actionFunc = func_80952734; return; block_5: - if (func_80147624(globalCtx) == 0) { + if (Message_ShouldAdvance(globalCtx) == 0) { return; } func_801477B4(globalCtx); @@ -592,15 +592,15 @@ block_5: this->actionFunc = func_809529AC; return; block_7: - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx) != 0) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_801477B4(globalCtx); - if (gSaveContext.rupees < 0xA) { + if (gSaveContext.save.playerData.rupees < 0xA) { play_sound(0x4806U); func_80151938(globalCtx, 0x935U); - } else if (gSaveContext.inventory.ammo[gItemSlots[0xA]] >= 0x14) { + } else if (gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) { play_sound(0x4806U); func_80151938(globalCtx, 0x937U); } else { @@ -647,7 +647,7 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { break; case 5: - if (func_80147624(globalCtx) == 0) { + if (Message_ShouldAdvance(globalCtx) == 0) { return; } func_801477B4(globalCtx); @@ -656,15 +656,15 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { break; case 4: - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx) != 0) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_801477B4(globalCtx); - if (gSaveContext.rupees < 0xA) { + if (gSaveContext.save.playerData.rupees < 0xA) { play_sound(0x4806U); func_80151938(globalCtx, 0x935U); - } else if (gSaveContext.inventory.ammo[gItemSlots[0xA]] >= 0x14) { + } else if (gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) { play_sound(0x4806U); func_80151938(globalCtx, 0x937U); } else { @@ -700,7 +700,7 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { break; case 5: - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx) != 0) { func_801477B4(globalCtx); Actor_PickUp((Actor *) this, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); this->actionFunc = func_809529AC; @@ -708,15 +708,15 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { break; case 4: - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx) != 0) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_801477B4(globalCtx); - if (gSaveContext.rupees < 0xA) { + if (gSaveContext.save.playerData.rupees < 0xA) { play_sound(0x4806U); func_80151938(globalCtx, 0x935U); - } else if (gSaveContext.inventory.ammo[gItemSlots[0xA]] >= 0x14) { + } else if (gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) { play_sound(0x4806U); func_80151938(globalCtx, 0x937U); } else { diff --git a/docs/tutorial/documenting.md b/docs/tutorial/documenting.md index b064b3e3b2..a5e64d2a91 100644 --- a/docs/tutorial/documenting.md +++ b/docs/tutorial/documenting.md @@ -182,12 +182,12 @@ void func_80C102D4(EnRecepgirl *this, GlobalContext *globalCtx) { func_80C10148(this); return; } - - if ((temp_v0_2 == 5) && (func_80147624(globalCtx) != 0)) { + + if ((temp_v0_2 == 5) && (Message_ShouldAdvance(globalCtx) != 0)) { if (this->actor.textId == 0x2AD9) { Flags_SetSwitch(globalCtx, this->actor.params); Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00AD98, 10.0f); - if ((gSaveContext.weekEventReg[63] & 0x80)) { + if ((gSaveContext.save.weekEventReg[63] & 0x80)) { this->actor.textId = 0x2ADF; } else { this->actor.textId = 0x2ADA; @@ -500,11 +500,11 @@ void func_80C102D4(EnRecepgirl* this, GlobalContext* globalCtx) { if (temp_v0_2 == 2) { this->actor.textId = 0x2ADC; // hear directions again? func_80C10148(this); - } else if ((temp_v0_2 == 5) && (func_80147624(globalCtx) != 0)) { + } else if ((temp_v0_2 == 5) && (Message_ShouldAdvance(globalCtx) != 0)) { if (this->actor.textId == 0x2AD9) { // "Welcome..." Flags_SetSwitch(globalCtx, this->actor.params); Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00AD98, 10.0f); - if (gSaveContext.weekEventReg[63] & 0x80) { // showed Couple's Mask to meeting + if (gSaveContext.save.weekEventReg[63] & 0x80) { // showed Couple's Mask to meeting this->actor.textId = 0x2ADF; // Mayor's office is on the left (meeting ended) } else { this->actor.textId = 0x2ADA; // Mayor's office is on the left (meeting ongoing) diff --git a/docs/tutorial/other_functions.md b/docs/tutorial/other_functions.md index b0350a838e..796939dd86 100644 --- a/docs/tutorial/other_functions.md +++ b/docs/tutorial/other_functions.md @@ -288,7 +288,7 @@ void func_80C102D4(EnRecepgirl *this, GlobalContext *globalCtx) { func_80C10148(this); return; } - if (((temp_v0_2 & 0xFF) == 5) && (func_80147624(globalCtx) != 0)) { + if (((temp_v0_2 & 0xFF) == 5) && (Message_ShouldAdvance(globalCtx) != 0)) { temp_v0_3 = this->actor.textId; if (temp_v0_3 == 0x2AD9) { Flags_SetSwitch(globalCtx, (s32) this->actor.params); @@ -347,7 +347,7 @@ void func_80C102D4(EnRecepgirl *this, GlobalContext *globalCtx) { return; } - if (((temp_v0_2 & 0xFF) == 5) && (func_80147624(globalCtx) != 0)) { + if (((temp_v0_2 & 0xFF) == 5) && (Message_ShouldAdvance(globalCtx) != 0)) { if (this->actor.textId == 0x2AD9) { Flags_SetSwitch(globalCtx, this->actor.params); Animation_MorphToPlayOnce(&this->skelAnime, &D_0600AD98, 10.0f); @@ -378,7 +378,7 @@ There remains one thing we need to fix before trying to compile it, namely `*(&g /* 0x0EF8 */ u8 weekEventReg[100]; // "week_event_reg" /* 0x0F5C */ u32 mapsVisited; // "area_arrival" ``` -so it's somewhere in `weekEventReg`. `0xF37 - 0xEF8 = 0x3F = 63`, and it's a byte array, so the access is actually `gSaveContext.weekEventReg[63] & 0x80`. Now it will compile. We also don't use `!= 0` for flag comparisons: just `if (gSaveContext.weekEventReg[63] & 0x80)` will do. +so it's somewhere in `weekEventReg`. `0xF37 - 0xEF8 = 0x3F = 63`, and it's a byte array, so the access is actually `gSaveContext.save.weekEventReg[63] & 0x80`. Now it will compile. We also don't use `!= 0` for flag comparisons: just `if (gSaveContext.save.weekEventReg[63] & 0x80)` will do. Running `./diff.py -mwo3 func_80C102D4` and scrolling down, we discover that this doesn't match! @@ -397,7 +397,7 @@ somehow we skipped over `t0`. Where is this in the code? The `153` in the middle return; } - if (((temp_v0_2 & 0xFF) == 5) && (func_80147624(globalCtx) != 0)) { + if (((temp_v0_2 & 0xFF) == 5) && (Message_ShouldAdvance(globalCtx) != 0)) { ``` If you look at the conditionals and the declaration of `temp_v0_2`, you may notice something odd: `temp_v0_2` is a `u8`. Therefore the `& 0xFF` does nothing! It's surprisingly common for this to happen, be it leaving out a `& 0xFF` or adding an extraneous one. If we remove it, we get a match: diff --git a/include/functions.h b/include/functions.h index 154ee737be..c8cfcc6e4a 100644 --- a/include/functions.h +++ b/include/functions.h @@ -7,8 +7,8 @@ void bootproc(void); void Idle_ThreadEntry(void* arg); void ViConfig_UpdateVi(u32 arg0); void ViConfig_UpdateBlack(void); -s32 DmaMgr_DMARomToRam(u32 src, void* dst, size_t size); -void DmaMgr_DmaCallback0(OSPiHandle* piHandle, OSIoMesg* mb, s32 direction); +s32 DmaMgr_DmaRomToRam(u32 src, void* dst, size_t size); +s32 DmaMgr_DmaHandler(OSPiHandle* piHandle, OSIoMesg* mb, s32 direction); DmaEntry* DmaMgr_FindDmaEntry(u32 vromAddr); u32 DmaMgr_TranslateVromToRom(u32 vromAddr); s32 DmaMgr_FindDmaIndex(u32 vromAddr); @@ -153,14 +153,10 @@ void MtxConv_L2F(MtxF* m1, MatrixInternal* m2); void __assert(const char* file, u32 lineNum); // void func_800862B4(void); void* SystemArena_MallocMin1(u32 size); -void SystemArena_FreeNull(void* pvParm1); -void func_8008633C(u32 param_1, s32 param_2, s32 param_3, UNK_PTR param_4); -void func_800863AC(u32 param_1, s32 param_2, s32 param_3, UNK_PTR param_4); -// void func_8008641C(void); -// void func_800864EC(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_80086588(void); -void SystemArena_Init(u32 base, u32 size); -s32 PadSetup_Init(OSMesgQueue* mq, u8* outMask, OSContStatus* status); +void SystemArena_FreeNullCheck(void* ptr); +void SystemArena_RunInits(void); +void SystemArena_Init(void* start, size_t size); +s32 func_80086620(OSMesgQueue* param_1, PadMgr* param_2, OSContStatus* param_3); // void func_80086760(void); // void func_80086794(void); // void func_800867B4(void); @@ -576,7 +572,7 @@ void EffectSsHahen_SpawnBurst(GlobalContext* globalCtx, Vec3f* pos, f32 burstSca // void EffectSsStick_Spawn(UNK_TYPE4 uParm1, UNK_PTR puParm2, UNK_TYPE2 uParm3); // void EffectSsSibuki_Spawn(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7); void EffectSsSibuki_SpawnBurst(GlobalContext* globalCtx, Vec3f* pos); -void EffectSsStone1_Spawn(GlobalContext* globalCtx, Vec3f* arg1, s32 arg2); +void EffectSsStone1_Spawn(GlobalContext* globalCtx, Vec3f* pos, s32 reg0); // void EffectSsHitMark_Spawn(UNK_TYPE4 uParm1, UNK_TYPE4 uParm2, UNK_TYPE2 uParm3, Vec3f* pzParm4); void EffectSsHitMark_SpawnFixedScale(GlobalContext* globalCtx, s32 type, Vec3f* pos); void EffectSsHitMark_SpawnCustomScale(GlobalContext* globalCtx, s32 type, s16 scale, Vec3f* pos); @@ -598,9 +594,9 @@ void EffectSsEnFire_SpawnVec3f(GlobalContext* globalCtx, Actor* actor, Vec3f* po void EffectSsExtra_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scoreIdx); void EffectSsDeadDb_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* prim, Color_RGBA8* env, s16 scale, s16 scaleStep, s32 unk); void func_800B3030(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, s32 colorIndex); -// void EffectSsDeadDd_Spawn(UNK_TYPE4 uParm1, Vec3f* pzParm2, Vec3f* pzParm3, Vec3f* pzParm4, UNK_TYPE1* param_5, UNK_TYPE1* param_6, UNK_TYPE2 param_7, UNK_TYPE2 param_8, UNK_TYPE2 param_9, UNK_TYPE4 param_10); +void EffectSsDeadDd_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* prim, Color_RGBA8* env, s16 scale, s16 scaleStep, s16 alphaStep, s32 life); // void EffectSsDeadDs_Spawn(UNK_TYPE4 uParm1, Vec3f* pzParm2, Vec3f* pzParm3, Vec3f* pzParm4, UNK_TYPE2 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7, UNK_TYPE4 param_8); -// void func_800B31BC(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE4 param_6); +void func_800B31BC(GlobalContext* globalCtx, Vec3f* pos, s16 scale, s16 scaleStep, s16 alpha, s32 life); void EffectSsIceSmoke_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale); void EffectSsIceBlock_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale); void FlagSet_Update(GameState* gameState); @@ -772,12 +768,12 @@ s32 Actor_OtherIsTargeted(GlobalContext* globalCtx, Actor* actor); void func_800BC620(Vec3f* arg0, Vec3f* arg1, u8 alpha, GlobalContext* globalCtx); void func_800BC770(GlobalContext* globalCtx, s16 y, s16 countdown); void func_800BC7D8(GlobalContext* globalCtx, s16 y, s16 countdown, s16 speed); -void func_800BC848(Actor* actor, GlobalContext* globalCtx, s16 arg2, s16 arg3); +void func_800BC848(Actor* actor, GlobalContext* globalCtx, s16 y, s16 countdown); void Actor_DrawDoorLock(GlobalContext* globalCtx, s32 frame, s32 type); void Actor_SetColorFilter(Actor* actor, u16 colorFlag, u16 colorIntensityMax, u16 xluFlag, u16 duration); Hilite* func_800BCBF4(Vec3f* arg0, GlobalContext* globalCtx); Hilite* func_800BCC68(Vec3f* arg0, GlobalContext* globalCtx); -void func_800BCCDC(Vec3s* points, s32 pathCount, Vec3f* pos1, Vec3f* pos2, s32 parm5); +void Actor_GetClosestPosOnPath(Vec3s* points, s32 numPoints, Vec3f* srcPos, Vec3f* dstPos, s32 isPathLoop); s32 func_800BD2B4(GlobalContext* globalCtx, Actor* actor, s16* arg2, f32 arg3, u16 (*textIdCallback)(GlobalContext*, Actor*), s16 (*arg5)(GlobalContext*, Actor*)); void func_800BD888(Actor* actor, struct_800BD888_arg1* arg1, s16 arg2, s16 arg3); void func_800BD9E0(GlobalContext* globalCtx, SkelAnime* skelAnime, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, s16 alpha); @@ -799,7 +795,7 @@ void func_800BE504(Actor* actor, ColliderCylinder* collider); void func_800BE568(Actor* actor, ColliderSphere* collider); void func_800BE5CC(Actor* actor, ColliderJntSph* collider, s32 colliderIndex); s32 Actor_IsSmallChest(struct EnBox* chest); -void func_800BE680(GlobalContext* globalCtx, Actor* actor, Vec3f limbPos[], s16 arg3, f32 effectScale, f32 steamScale, f32 effectAlpha, u8 mode); +void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbPos[], s16 limbPosCount, f32 effectScale, f32 frozenSteamScale, f32 effectAlpha, u8 type); void Actor_SpawnIceEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbPos[], s32 limbPosCount, s32 effectsPerLimb, f32 scale, f32 scaleRange); void ActorOverlayTable_FaultPrint(void* arg0, void* arg1); @@ -979,7 +975,7 @@ s32 DynaPolyActor_IsInRidingMovingState(DynaPolyActor* dynaActor); s32 DynaPolyActor_IsInRidingRotatingState(DynaPolyActor* dynaActor); s32 DynaPolyActor_IsInSwitchPressedState(DynaPolyActor* dynaActor); s32 DynaPolyActor_IsInHeavySwitchPressedState(DynaPolyActor* dynaActor); -s32 DynaPolyActor_ValidateMove(GlobalContext* globalCtx, DynaPolyActor* dynaActor, s16 arg2, s16 arg3, s16 arg4); +s32 DynaPolyActor_ValidateMove(GlobalContext* globalCtx, DynaPolyActor* dynaActor, s16 startRadius, s16 endRadius, s16 startHeight); f32 Camera_fabsf(f32 f); f32 Camera_LengthVec3f(Vec3f* v); // void func_800CB270(void); @@ -1158,7 +1154,7 @@ s16 Camera_ClearFlags(Camera* camera, s16 flags); s32 func_800DFFAC(Camera* camera, Actor* doorActor, s16 bgCamDataId, f32 arg3, s16 timer1, s16 timer2, s16 timer3); // UNK_TYPE4 func_800E007C(Camera* param_1, Camera* param_2); // UNK_TYPE4 func_800E01AC(void); -// void func_800E01B8(void); +Vec3f* Camera_GetQuakeOffset(Vec3f* dst, Camera* camera); // void func_800E01DC(s32 param_1, u32 param_2, UNK_TYPE4 param_3, UNK_TYPE4 param_4, UNK_TYPE2 param_5, UNK_TYPE2 param_6); // UNK_TYPE4 func_800E0228(void); // void func_800E0238(void); @@ -1388,7 +1384,7 @@ s32 func_800E9138(GlobalContext* globalCtx, Actor* actor, Vec3s* param_3, Vec3s* s32 func_800E9250(GlobalContext* globalCtx, Actor* actor, Vec3s* param_3, Vec3s* param_4, Vec3f param_5); void SaveContext_Init(void); void GameInfo_Init(void); -// void func_800E9470(void); +// void DebugDisplay_Init(void); DebugDispObject* DebugDisplay_AddObject(f32 posX, f32 posY, f32 posZ, s16 rotX, s16 rotY, s16 rotZ, f32 scaleX, f32 scaleY, f32 scaleZ, u8 red, u8 green, u8 blue, u8 alpha, s16 type, GraphicsContext* gfxCtx); // void func_800E9C90(void); // void func_800E9CA0(s32 param_1, UNK_TYPE1 param_2, s8* param_3); @@ -1492,21 +1488,22 @@ void FireObj_Init(GlobalContext* globalCtx, FireObj* fire, FireObjInitParams* in void FireObj_Destroy(GlobalContext* globalCtx, FireObj* fire); void FireObj_SetState2(FireObj* fire, f32 dynamicSizeStep, u8 newState); void FireObj_Update(GlobalContext* globalCtx, FireObj* fire, Actor* actor); -// void func_800F3940(void); +s32 func_800F3940(GlobalContext* globalCtx); // void func_800F39B4(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); // void func_800F3A64(void); -// void func_800F3B2C(void); +void func_800F3B2C(GlobalContext* globalCtx); // void func_800F3B68(void); // void func_800F3C44(void); // void func_800F3ED4(void); void func_800F40A0(GameState* gameState, Player* player); -// void func_800F415C(void); +void func_800F415C(Actor* actor, Vec3f* arg1, s16 arg2); UNK_TYPE func_800F41E4(GlobalContext* globalCtx, ActorContext* actorCtx); void func_800F4A10(GlobalContext* globalCtx); -void func_800F4C0C(GlobalContext* globalCtx); +void KaleidoSetup_Update(GlobalContext* globalCtx); void KaleidoSetup_Init(GlobalContext* globalCtx); void KaleidoSetup_Destroy(GlobalContext* globalCtx); + void Font_LoadChar(GlobalContext* globalCtx, u16 codePointIndex, s32 offset); void Font_LoadCharNES(GlobalContext* globalCtx, u8 codePointIndex, s32 offset); void Font_LoadMessageBoxEndIcon(Font* font, u16 icon); @@ -1559,7 +1556,7 @@ void func_800FD538(Color_RGB8* param_1, Color_RGB8* param_2, f32 param_3, Vec3s* void func_800FD59C(GlobalContext* globalCtx, Color_RGB8* pzParm2, f32 fParm3); void func_800FD5E0(GlobalContext* globalCtx, Color_RGB8* pzParm2, f32 fParm3); void func_800FD654(GlobalContext* globalCtx, Color_RGB8* pzParm2, f32 fParm3); -// void func_800FD698(void); +void func_800FD698(GlobalContext* globalCtx, s16 arg1, s16 arg2, f32 arg3); // u32 get_days_elapsed(void); // void reset_days_elapsed(void); // u32 get_current_day(void); @@ -1586,9 +1583,9 @@ void func_800FE658(f32 arg0); // void func_800FE778(void); // void func_800FE788(void); // void func_800FE798(void); -// void func_800FE7A8(void); +void func_800FE7A8(Color_RGBA8* inColor, Color_RGBA8* outColor); s32 func_800FE9B4(GlobalContext* globalCtx); -// void func_800FEA50(void); +void func_800FEA50(GlobalContext* globalCtx); void func_800FEAB0(void); // void func_800FEAC0(void); void func_800FEAF4(EnvironmentContext* envCtx); @@ -1647,7 +1644,7 @@ void Actor_ProcessInitChain(Actor* actor, InitChainEntry* ichain); f32 Math_SmoothStepToF(f32* pValue, f32 target, f32 fraction, f32 step, f32 minStep); void Math_ApproachF(f32* pValue, f32 target, f32 scale, f32 maxStep); void Math_ApproachZeroF(f32* pValue, f32 scale, f32 maxStep); -s32 Math_SmoothStepToS(s16* pValue, s16 target, s16 scale, s16 step, s16 minStep); +s16 Math_SmoothStepToS(s16* pValue, s16 target, s16 scale, s16 step, s16 minStep); void Math_ApproachS(s16* pValue, s16 target, s16 scale, s16 maxStep); void Color_RGBA8_Copy(Color_RGBA8* dst, Color_RGBA8* src); void func_801000A4(u16 sfxId); @@ -1801,7 +1798,7 @@ void func_80105818(GlobalContext* globalCtx, u32 uParm2, TransitionActorEntry* p // void func_80109F78(void); s32 func_8010A000(GlobalContext* globalCtx); s32 func_8010A074(GlobalContext* globalCtx); -// void func_8010A0A4(void); +s32 func_8010A0A4(GlobalContext* globalCtx); // void func_8010A0F0(void); // void func_8010A164(void); // void func_8010A194(void); @@ -1913,13 +1910,13 @@ void Interface_ChangeAlpha(u16 param_1); // void func_80111CB4(void); // void func_801129E4(void); void func_80112AFC(GlobalContext* globalCtx); -void func_80112B40(GlobalContext* globalCtx, s32 arg1); +void func_80112B40(GlobalContext* globalCtx, u8 arg1); // void func_80112BE4(void); // void func_80112C0C(void); u32 Item_Give(GlobalContext* globalCtx, u8 param_2); // void func_801143CC(void); UNK_TYPE func_80114978(UNK_TYPE arg0); -void func_801149A0(s32 arg0, s16 arg1); +void func_801149A0(s32 itemId, s16 slotId); // void func_80114A9C(void); // void func_80114B84(void); // void func_80114CA0(void); @@ -2010,7 +2007,7 @@ s32 func_80123810(GlobalContext* globalCtx); void func_80123AA4(Player* player, s32 arg1); // void func_80123BD4(void); // void func_80123C58(void); -void Player_SetEquipmentData(GlobalContext* globalCtx, Player* this); +void Player_SetEquipmentData(GlobalContext* globalCtx, Player* this); void func_80123D50(GlobalContext* globalCtx, Player* player, UNK_TYPE arg2, UNK_TYPE arg3); void func_80123DA4(Player* player); // void func_80123DC0(void); @@ -2240,7 +2237,7 @@ void Scene_HeaderCmdPathList(GlobalContext* globalCtx, SceneCmd* cmd); void Scene_HeaderCmdTransiActorList(GlobalContext* globalCtx, SceneCmd* cmd); void Door_InitContext(GameState* gameState, DoorContext* doorCtx); void Scene_HeaderCmdEnvLightSettings(GlobalContext* globalCtx, SceneCmd* cmd); -s32 Scene_LoadAreaTextures(GlobalContext* globalCtx, s32 fileIndex); +void Scene_LoadAreaTextures(GlobalContext* globalCtx, s32 fileIndex); void Scene_HeaderCmdSkyboxSettings(GlobalContext* globalCtx, SceneCmd* cmd); void Scene_HeaderCmdSkyboxDisables(GlobalContext* globalCtx, SceneCmd* cmd); void Scene_HeaderCmdTimeSettings(GlobalContext* globalCtx, SceneCmd* cmd); @@ -2302,26 +2299,7 @@ s32 Entrance_GetSceneNum(u16 entranceIndex); s32 Entrance_GetSceneNumAbsolute(u16 entranceIndex); s32 Entrance_GetSpawnNum(u16 entranceIndex); s32 Entrance_GetTransitionFlags(u16 entranceIndex); -// void func_801323D0(void); -// void func_80132428(void); -// void func_80132494(void); -// void func_801326B8(void); -// void func_801328F0(void); -// void func_80132920(void); -// void func_80132938(void); -// void func_80132954(void); -// void func_8013296C(void); -// void func_80132A18(void); -// void func_80132A3C(void); -// void func_80132A80(void); -// void func_80132AD8(void); -// void func_80132B24(void); -// void func_80132B84(void); -// void func_80132D70(void); -// void func_80132E9C(void); -// void func_80132FDC(void); -// void func_80133000(void); -UNK_TYPE func_80133038(GlobalContext* globalCtx, UNK_TYPE* arg1, struct_80133038_arg2* arg2); +s32 Schedule_RunScript(GlobalContext* globalCtx, u8* script, ScheduleResult* result); void SkelAnime_DrawLimbLod(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor, s32 lod); void SkelAnime_DrawLod(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor, s32 lod); void SkelAnime_DrawFlexLimbLod(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDrawFlex overrideLimbDraw, PostLimbDrawFlex postLimbDraw, Actor* actor, s32 lod, Mtx** mtx); @@ -2386,7 +2364,7 @@ s32 Animation_OnFrameImpl(SkelAnime* skelAnime, f32 frame, f32 updateRate); s32 LinkAnimation_OnFrame(SkelAnime* skelAnime, f32 frame); void SkelAnime_Init(GlobalContext* globalCtx, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg, AnimationHeader* animation, Vec3s* jointTable, Vec3s* morphTable, s32 limbCount); void SkelAnime_InitFlex(GlobalContext* globalCtx, SkelAnime* skelAnime, FlexSkeletonHeader* skeletonHeaderSeg, AnimationHeader* animation, Vec3s* jointTable, Vec3s* morphTable, s32 limbCount); -void SkelAnime_InitSkin(GlobalContext* globalCtx, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg, AnimationHeader* animation); +void SkelAnime_InitSkin(GameState* gameState, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg, AnimationHeader* animationSeg); void SkelAnime_SetUpdate(SkelAnime* skelAnime); s32 SkelAnime_Update(SkelAnime* skelAnime); s32 SkelAnime_Morph(SkelAnime* skelAnime); @@ -2411,23 +2389,6 @@ void SkelAnime_UpdateTranslation(SkelAnime* skelAnime, Vec3f* pos, s16 angle); s32 Animation_OnFrame(SkelAnime* skelAnime, f32 frame); void SkelAnime_Free(SkelAnime* skelAnime, GlobalContext* globalCtx); void SkelAnime_CopyFrameTable(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src); -// void func_80137970(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_80137B34(void); -// void func_80137EBC(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_80137F58(void); -// void func_80138050(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8); -// void func_80138228(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_80138258(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); -// void func_8013828C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); -// void func_801382C4(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8); -// void func_80138300(void); -// void func_8013835C(void); -// void func_80138410(void); -// void func_80138424(void); -// void func_8013859C(void); -// void func_80138700(void); -// void func_801387D4(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE1 param_5); -// void func_801388E4(void); void SkinMatrix_Vec3fMtxFMultXYZW(MtxF* mf, Vec3f* src, Vec3f* xyzDest, f32* wDest); void SkinMatrix_Vec3fMtxFMultXYZ(MtxF* mf, Vec3f* src, Vec3f* dest); void SkinMatrix_MtxFMtxFMult(MtxF* mfB, MtxF* mfA, MtxF* dest); @@ -2452,16 +2413,17 @@ void SkinMatrix_MulXRotation(MtxF* mf, s16 a); void SkinMatrix_SetYRotation(MtxF* mf, s16 a); void SkinMatrix_MulYRotation(MtxF* mf, s16 a); void SkinMatrix_SetZRotation(MtxF* mf, s16 a); + s32 func_8013A240(GlobalContext* globalCtx); void func_8013A41C(s32 flag); void func_8013A46C(s32 flag); u32 func_8013A4C4(s32 flag); s16 func_8013A504(s16 val); s32 func_8013A530(GlobalContext* globalCtx, Actor* actor, s32 flag, Vec3f* pos, Vec3s* rot, f32 distanceMin, f32 distanceMax, s16 angleError); -struct EnDoor* SubS_FindDoor(GlobalContext* globalCtx, s32 unk_1A5); -Gfx* SubS_DrawTransformFlexLimb(GlobalContext* globalCtx, s32 idx, void** skeleton, Vec3s* jointTable, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, TransformLimbDraw transformLimbDraw, Actor* actor, Mtx** mtx, Gfx* gfx); +struct EnDoor* SubS_FindDoor(GlobalContext* globalCtx, s32 switchFlag); +Gfx* SubS_DrawTransformFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, TransformLimbDraw transformLimbDraw, Actor* actor, Mtx** mtx, Gfx* gfx); Gfx* SubS_DrawTransformFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, TransformLimbDraw transformLimbDraw, Actor* actor, Gfx* gfx); -s32 func_8013AD6C(GlobalContext* globalCtx); +s32 SubS_InCsMode(GlobalContext* globalCtx); s32 func_8013AD9C(s16 arg0, s16 arg1, Vec3f* arg2, Vec3s* arg3, s32 arg4, s32 arg5); void SubS_UpdateFlags(u16* flags, u16 setBits, u16 unsetBits); void func_8013AF00(f32* arg0, s32 arg1, s32 arg2); @@ -2470,47 +2432,48 @@ void func_8013B0C8(s32 arg0, f32 arg1, s32 arg2, f32* arg3, f32* arg4); void func_8013B350(Vec3f* arg0, f32* arg1, f32 arg2, s32 arg3, s32 arg4, Vec3s* arg5, f32* arg6); s32 func_8013B6B0(Path* path, f32* arg1, s32* arg2, s32 arg3, s32 arg4, s32* arg5, f32* arg6, Vec3f* arg7, s32 arg8); void func_8013B878(GlobalContext* globalCtx, Path* path, s32 arg2, Vec3f* arg3); -Path* func_8013BB34(GlobalContext* globalCtx, u8 arg1, s32 arg2); +Path* SubS_GetAdditionalPath(GlobalContext* globalCtx, u8 pathIndex, s32 max); Actor* SubS_FindNearestActor(Actor* actor, GlobalContext* globalCtx, u8 actorCategory, s16 actorId); s32 SubS_ChangeAnimationByInfoS(SkelAnime* skelAnime, AnimationInfoS* animations, s32 index); -s32 func_8013BD40(Actor* actor, Path* path, s32 arg2); -Path* func_8013BEDC(GlobalContext* globalCtx, u8 arg1, u8 arg2, s32* arg3); +s32 SubS_HasReachedPoint(Actor* actor, Path* path, s32 pointIndex); +Path* SubS_GetDayDependentPath(GlobalContext* globalCtx, u8 pathIndex, u8 max, s32* startPointIndex); s32 func_8013C068(Path* path, s32 arg1, Vec3f* arg2, f32 arg3, s32 arg4); s32 func_8013C624(Actor* actor, Path* path, s32* arg2, f32* arg3, s32 arg4, s32 arg5); -s32 func_8013C8B8(Path* path, s32 arg1, Vec3f* arg2); -s32 func_8013C964(Actor* actor, GlobalContext* globalCtx, f32 arg2, f32 arg3, s32 arg4, s32 arg5); -void func_8013CC2C(s32 arg0, s32 arg1, u8* arg2, s32 arg3); -void func_8013CD64(Vec3f* arg0, Vec3f* arg1, u8* arg2, f32 arg3, u8 arg4, u8* arg5, s8* arg6); -void func_8013CF04(Actor* actor, GraphicsContext** gfxCtxPtr, u8* arg2); +s32 SubS_CopyPointFromPathCheckBounds(Path* path, s32 pointIndex, Vec3f* dst); +s32 func_8013C964(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 itemId, s32 type); +void SubS_FillShadowTex(s32 startCol, s32 startRow, u8* tex, s32 size); +void SubS_GenShadowTex(Vec3f bodyPartsPos[], Vec3f* worldPos, u8* tex, f32 tween, u8 bodyPartsNum, u8 sizes[], s8 parentBodyParts[]); +void SubS_DrawShadowTex(Actor* actor, GameState* gameState, u8* tex); s16 func_8013D0E0(s16* arg0, s16 arg1, s16 arg2, f32 arg3, f32 arg4, f32 arg5); s32 func_8013D2E0(Vec3f* arg0, Vec3f* arg1, Vec3s* arg2, Vec3s* arg3, Vec3s* arg4, Vec3s* arg5, u16* arg6); s32 SubS_AngleDiffLessEqual(s16 angleA, s16 threshold, s16 angleB); -Path* func_8013D648(GlobalContext* globalCtx, s16 arg1, s16 arg2); -s32 func_8013D68C(Path* path, s32 arg1, Vec3f* arg2); -s16 func_8013D720(Vec3f* arg0, Vec3f* arg1, f32* arg2); -s32 func_8013D768(Actor* actor, Vec3f* arg1, s16 arg2); -s16 func_8013D83C(Path* path, s32 pointIdx, Vec3f* pos, f32* distSq); +Path* SubS_GetPathByIndex(GlobalContext* globalCtx, s16 pathIndex, s16 max); +s32 SubS_CopyPointFromPath(Path* path, s32 pointIndex, Vec3f* dst); +s16 SubS_GetDistSqAndOrientPoints(Vec3f* vecA, Vec3f* vecB, f32* distSq); +s32 SubS_MoveActorToPoint(Actor* actor, Vec3f* point, s16 rotStep); +s16 SubS_GetDistSqAndOrientPath(Path* path, s32 pointIdx, Vec3f* pos, f32* distSq); s8 SubS_IsObjectLoaded(s8 index, GlobalContext* globalCtx); s8 SubS_GetObjectIndex(s16 id, GlobalContext* globalCtx); Actor* SubS_FindActor(GlobalContext* globalCtx, Actor* actorListStart, u8 actorCategory, s16 actorId); s32 SubS_FillLimbRotTables(GlobalContext* globalCtx, s16* limbRotTableY, s16* limbRotTableZ, s32 numLimbs); -s32 func_8013DB90(GlobalContext* globalCtx, Vec3f* arg1, f32 arg2); -s32 func_8013DC40(Path* arg0, s32 arg1, s32 arg2, Vec3f* arg3); -void func_8013DCE0(GlobalContext* globalCtx, Vec3f* arg1, Actor* arg2, struct_8013DF3C_arg1* arg3, Path* arg4, s32 arg5, s32 arg6, s32 arg7, s32 arg8, u8 arg9); -s32 func_8013DE04(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1, struct_8013DF3C_arg1_unk_func1 arg2, struct_8013DF3C_arg1_unk_func2 arg3, struct_8013DF3C_arg1_unk_func2 arg4, struct_8013DF3C_arg1_unk_func2 arg5); -void func_8013DF3C(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1); -s32 func_8013E054(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1); -s32 func_8013E07C(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1); -s32 func_8013E0A4(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1); +s32 SubS_IsFloorAbove(GlobalContext* globalCtx, Vec3f* pos, f32 distAbove); +s32 SubS_CopyPointFromPathList(Path* paths, s32 pathIndex, s32 pointIndex, Vec3f* dst); +u8 SubS_GetPathCount(Path* paths, s32 index); +void SubS_ActorPathing_Init(GlobalContext* globalCtx, Vec3f* worldPos, Actor* actor, ActorPathing* actorPath, Path* paths, s32 pathIndex, s32 begPointIndex, s32 endPointIndex, s32 curPointIndex, u8 flags); +s32 SubS_ActorPathing_Update(GlobalContext* globalCtx, ActorPathing* actorPath, ActorPathingComputeFunc computePointInfoFunc, ActorPathingUpdateFunc updateActorInfoFunc, ActorPathingUpdateFunc moveFunc, ActorPathingUpdateFunc setNextPointFunc); +void SubS_ActorPathing_ComputePointInfo(GlobalContext* globalCtx, ActorPathing* actorPath); +s32 SubS_ActorPathing_MoveWithGravity(GlobalContext* globalCtx, ActorPathing* actorPath); +s32 SubS_ActorPathing_MoveWithoutGravityReverse(GlobalContext* globalCtx, ActorPathing* actorPath); +s32 SubS_ActorPathing_SetNextPoint(GlobalContext* globalCtx, ActorPathing* actorPath); void SubS_ChangeAnimationBySpeedInfo(SkelAnime* skelAnime, AnimationSpeedInfo* animations, s32 nextIndex, s32* curIndex); s32 SubS_StartActorCutscene(Actor* actor, s16 nextCutscene, s16 curCutscene, s32 type); s32 SubS_FillCutscenesList(Actor* actor, s16 cutscenes[], s16 numCutscenes); -void func_8013E4B0(Vec3f* arg0, Vec3f* arg1, Vec3s* arg2, Plane* plane); -s32 func_8013E5CC(Vec3f* arg0, Vec3s* arg1, Vec3f* arg2, Vec3f* arg3, Vec3f* arg4, Vec3f* arg5); +void SubS_ConstructPlane(Vec3f* point, Vec3f* unitVec, Vec3s* rot, Plane* plane); +s32 SubS_LineSegVsPlane(Vec3f* point, Vec3s* rot, Vec3f* unitVec, Vec3f* linePointA, Vec3f* linePointB, Vec3f* intersect); Actor* SubS_FindActorCustom(GlobalContext* globalCtx, Actor* actor, Actor* actorListStart, u8 actorCategory, s16 actorId, void* verifyData, VerifyActor verifyActor); -s32 func_8013E748(Actor* actor, GlobalContext* globalCtx, f32 arg2, f32 arg3, s32 arg4, Vec3s* arg5, func_8013E748_arg6 arg6); -s32 func_8013E7C0(GlobalContext* globalCtx, Actor* actor, Vec3s* arg2); -void func_8013E8F8(Actor* actor, GlobalContext* globalCtx, f32 arg2, f32 arg3, s32 arg4, s16 arg5, s16 arg6); +s32 func_8013E748(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 exchangeItemId, void* data, func_8013E748_VerifyFunc verifyFunc); +s32 SubS_ActorAndPlayerFaceEachOther(GlobalContext* globalCtx, Actor* actor, void* data); +s32 func_8013E8F8(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 exhangeItemId, s16 playerYawTol, s16 actorYawTol); s32 func_8013E950(Vec3f* arg0, Vec3f* arg1, s16 arg2, Vec3f* arg3, Vec3f* arg4, s16* arg5, s16* arg6, s16* arg7, s16* arg8, u16 arg9, u16 arg10, u16 arg11, u16 arg12); // void func_8013EC10(void); void func_8013EC44(f32 a, u8 b, u8 c, u8 d); @@ -2584,50 +2547,18 @@ s32 func_80142440(SkyboxContext* skyboxCtx, Vtx* vtx, s32 arg2, s32 arg3, s32 ar void func_80143148(SkyboxContext* skyboxCtx, s32 arg1); void func_801431E8(GameState* gameState, SkyboxContext* skyboxCtx, s16 skyType); void func_80143324(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skyType); -void func_801434E4(GameState* gameState, SkyboxContext* skyboxCtx, s16 skyType); +void func_801434E4(GameState* gameState, SkyboxContext* skyboxCtx, s16 skyType); Mtx* SkyboxDraw_UpdateMatrix(SkyboxContext* skyboxCtx, f32 x, f32 y, f32 z); void SkyboxDraw_SetColors(SkyboxContext* skyboxCtx, u8 primR, u8 primG, u8 primB, u8 envR, u8 envG, u8 envB); void SkyboxDraw_Draw(SkyboxContext* skyboxCtx, GraphicsContext* gfxCtx, s16 skyboxId, s16 blend, f32 x, f32 y, f32 z); void SkyboxDraw_Noop(SkyboxContext* skyboxCtx); -void func_80143A10(u8 owlId); -// void func_80143A54(void); -void func_80143AC4(void); -void func_80143B0C(GlobalContext* globalCtx); -void Sram_IncrementDay(void); -u32 Sram_CalcChecksum(u8* data, u32 length); -// void func_80144628(void); -// void Sram_GenerateRandomSaveFields(void); -void func_80144890(void); -void Sram_InitDebugSave(void); -void func_80144A94(SramContext* sramCtx); -// void func_80144E78(void); -// void func_8014546C(void); -// void func_80145698(void); -void func_801457CC(GameState* gameState, SramContext* param_2); -void func_80146580(s32 param_1, SramContext* param_2, s32 param_3); -// void func_80146628(void); -// void func_80146AA0(void); -// void func_80146DF8(void); -void func_80146E40(GameState* gameState, SramContext* sramCtx); -void Sram_Alloc(GameState* gameState, SramContext* sramCtx); -// void func_80146EBC(SramContext* param_1, UNK_TYPE4 param_2, UNK_TYPE4 param_3); -void func_80146EE8(GlobalContext* globalCtx); -void func_80146F5C(GlobalContext* globalCtx); -// void func_80147008(void); -void func_80147020(SramContext* param_1); -void func_80147068(SramContext* param_1); -// void func_80147138(SramContext* param_1, UNK_TYPE4 param_2, UNK_TYPE4 param_3); -void func_80147150(SramContext* param_1); -void func_80147198(SramContext* param_1); -// void func_80147314(void); -// void func_80147414(void); -// void Sram_nop8014750C(UNK_TYPE4 param_1); + // void func_80147520(void); void func_80147564(GlobalContext* globalCtx); -s32 func_80147624(GlobalContext* globalCtx); -s32 func_80147734(GlobalContext* globalCtx); +s32 Message_ShouldAdvance(GlobalContext* globalCtx); +s32 Message_ShouldAdvanceSilent(GlobalContext* globalCtx); void func_801477B4(GlobalContext* globalCtx); -// void func_80147818(GlobalContext* globalCtx, UNK_PTR puParm2, UNK_TYPE4 uParm3, UNK_TYPE4 uParm4); +void func_80147818(GlobalContext* globalCtx, UNK_PTR puParm2, UNK_TYPE4 uParm3, UNK_TYPE4 uParm4); // void func_80147F18(GlobalContext* globalCtx, UNK_PTR puParm2, UNK_TYPE4 uParm3, UNK_TYPE4 uParm4); // void func_80148558(GlobalContext* globalCtx, UNK_PTR puParm2, UNK_TYPE4 uParm3, UNK_TYPE4 uParm4); void func_80148B98(GlobalContext* globalCtx, u8 bParm2); @@ -2638,28 +2569,28 @@ void func_80148B98(GlobalContext* globalCtx, u8 bParm2); // void func_80149454(void); // void func_801496C8(void); // void func_8014995C(void); -// void func_80149C18(void); -// void func_80149EBC(void); +void func_80149C18(GlobalContext* globalCtx); +// void Message_FindMessage(void); void func_80149F74(GlobalContext* globalCtx, u32** ppuParm2); // void func_8014AAD0(void); void func_8014ADBC(GlobalContext* globalCtx, UNK_PTR puParm2); // void func_8014C70C(void); -// void func_8014CC14(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5); +void Message_LoadChar(GlobalContext* globalCtx, u16 codePointIndex, s32* offset, f32* arg3, s16 arg4); // void func_8014CCB4(void); // void func_8014CDF0(void); // void func_8014CFDC(void); -// void func_8014D304(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); +void func_8014D304(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); // void func_8014D62C(void); // void func_8014D7B4(void); -// void func_80150A84(void); +void func_80150A84(GlobalContext* globalCtx); void func_80150D08(GlobalContext* globalCtx, u32 uParm2); // void func_801514B0(void); void Message_StartTextbox(GlobalContext* globalCtx, u16 textId, Actor* Actor); void func_80151938(GlobalContext* globalCtx, u16 textId); void func_80151A68(GlobalContext* globalCtx, u16 textId); -void func_80151BB4(GlobalContext* globalCtx, u32 uParm2); +void func_80151BB4(GlobalContext* globalCtx, u8 uParm2); // void func_80151C9C(void); -// void func_80151DA4(void); +void func_80151DA4(GlobalContext* globalCtx, u16 arg2); void func_80152434(GlobalContext* globalCtx, u16 arg2); // void func_80152464(void); u8 Message_GetState(MessageContext* msgCtx); @@ -2671,23 +2602,23 @@ u8 Message_GetState(MessageContext* msgCtx); // void func_80153750(void); // void func_80153E7C(void); // void func_80153EF0(void); -// void func_801541D4(void); +void func_801541D4(GlobalContext* globalCtx, Gfx** gfxp); // void func_80156758(void); void func_8015680C(GlobalContext* globalCtx); void func_801586A4(GlobalContext* globalCtx); void Message_Init(GlobalContext* globalCtx); -void func_801588D0(GlobalContext* globalCtx, s16 param_2); -// void func_80158988(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5); -// void func_80158A24(void); -// void func_80158C04(void); -// void func_80158D98(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5); -// void func_80158FB0(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_8015926C(void); +void Message_FindMessageNES(GlobalContext* globalCtx, u16 textId); +// void Message_LoadCharNES(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5); +// void Message_LoadPluralRupeesNES(void); +// void Message_LoadLocalizedRupeesNES(void); +// void Message_LoadRupeesNES(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5); +// void Message_LoadTimeNES(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); +// void Message_LoadAreaTextNES(void); // void func_80159438(void); -// void func_8015966C(void); +void func_8015966C(GlobalContext* globalCtx, UNK_PTR puParm2, UNK_TYPE arg3); // void func_8015A144(void); -// void func_8015B198(void); -// void func_8015E750(void); +void func_8015B198(GlobalContext* globalCtx); +void Message_FindCreditsMessage(GlobalContext *globalCtx, u16 textId); void func_8015E7EC(GlobalContext* globalCtx, UNK_PTR puParm2); // void func_8015F8A8(UNK_TYPE4 ctxt); @@ -2704,10 +2635,10 @@ void ShrinkWindow_Destroy(void); void ShrinkWindow_Update(s32 framerateDivisor); void ShrinkWindow_Draw(GraphicsContext* gfxCtx); // void func_80161180(void); -void func_8016119C(Camera* camera, struct_801F4D48* arg1); +s32 func_8016119C(Camera* camera, DbCameraUnkStruct* arg1); // void func_8016122C(void); // void func_801612B8(void); -s32 func_80161998(UNK_PTR arg0, struct_801F4D48* arg1); +s32 func_80161998(u8* cmd, DbCameraUnkStruct* arg1); // s32 func_80161BAC(void); void func_80161BE0(s16 arg0); void func_80161C0C(void); @@ -2773,7 +2704,7 @@ void func_80165438(UNK_PTR param_1); // void func_80165608(void); // void func_80165630(void); void func_80165658(u32 arg0); -void func_8016566C(s32 arg0); +void func_8016566C(u32 arg0); void func_80165690(void); // void func_801656A4(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8); // void func_80165DCC(void); @@ -2795,7 +2726,7 @@ void func_80167DE4(GlobalContext* globalCtx); void Play_Draw(GlobalContext* globalCtx); void func_80168DAC(GlobalContext* globalCtx); void Play_Update(GlobalContext* globalCtx); -s32 func_801690CC(GlobalContext* globalCtx); +s32 Play_InCsMode(GlobalContext* globalCtx); f32 func_80169100(GlobalContext* globalCtx, MtxF* mtx, CollisionPoly** arg2, s32* arg3, Vec3f* feetPosPtr); // void func_801691F0(void); void* Play_LoadScene(GlobalContext* globalCtx, RomFile* entry); @@ -2937,7 +2868,7 @@ void* GameAlloc_Malloc(GameAlloc* this, size_t size); void GameAlloc_Free(GameAlloc* this, void* data); void GameAlloc_Cleanup(GameAlloc* this); void GameAlloc_Init(GameAlloc* this); -void* Graph_FaultClient(void); +void Graph_FaultClient(void); void Graph_InitTHGA(TwoHeadGfxArena* arena, Gfx* buffer, s32 size); void Graph_SetNextGfxPool(GraphicsContext* gfxCtx); GameStateOverlay* Graph_GetNextGameState(GameState* gameState); @@ -3117,7 +3048,7 @@ s32 Math3D_LineSegVsPlane(f32 nx, f32 ny, f32 nz, f32 originDist, Vec3f* linePoi void Math3D_TriSetCoords(TriNorm* tri, Vec3f* pointA, Vec3f* pointB, Vec3f* pointC); u32 Math3D_IsPointInSphere(Sphere16* sphere, Vec3f* point); s32 Math3D_PointDistToLine2D(f32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5, f32* arg6, f32* arg7, f32* arg8); // returns boolean -// void func_8017D7C0(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); +s32 func_8017D7C0(f32 x0, f32 y0, f32 x1, f32 y1, f32 x2, f32 y2, f32* lineLenSq); // void func_8017D814(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); // void func_8017D91C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); // void func_8017DA24(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); @@ -3206,12 +3137,12 @@ void func_80183070(void); // void func_801832B0(void); // void func_8018332C(void); // void func_8018340C(void); -// void func_80183430(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); -// void func_8018349C(void); -// void func_801834A8(void); +void func_80183430(SkeletonInfo* skeletonInfo, void* arg1, void* arg2, Vec3s* arg3, s16* arg4, UnkKeyframeCallback* callbacks); +void func_8018349C(UNK_PTR arg0); +void func_801834A8(SkeletonInfo* skeletonInfo, void* arg1); // void func_80183510(void); // void func_80183580(void); -// void func_801835EC(void); +void func_801835EC(UNK_PTR arg0, UNK_PTR arg1); // void func_80183658(void); // void func_801836CC(void); // void func_8018373C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9); @@ -3221,9 +3152,11 @@ void func_80183070(void); // void func_80183A3C(void); // void func_80183B08(void); // void func_80183B68(void); -// void func_80183DE0(void); +s32 func_80183DE0(SkeletonInfo* skeletonInfo); // void func_8018410C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); -// void func_8018450C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); +void func_8018450C(GlobalContext* globalCtx, SkeletonInfo* skeleton, Mtx* mtx, + OverrideKeyframeDrawScaled overrideKeyframeDraw, PostKeyframeDrawScaled postKeyframeDraw, + Actor* actor); // void func_801845A4(void); // void func_801845C8(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); // void func_80184638(void); @@ -3247,17 +3180,17 @@ void Slowly_Stop(SlowlyTask* slowly); // char* func_801857D0(void); // void func_80185864(void); u32 func_80185908(void); -// void func_80185968(void); +UNK_TYPE func_80185968(void* arg0, UNK_TYPE arg1, UNK_TYPE arg2); // void func_801859F0(void); // void func_80185A2C(void); // void func_80185B1C(void); // void func_80185BE4(void); // void func_80185C24(void); void SysFlashrom_ThreadEntry(s80185D40* param_1); -// void func_80185DDC(void); -// void func_80185EC4(void); -// void func_80185F04(void); -// void func_80185F64(void); +void func_80185DDC(u8* arg0, u32 arg1, u32 arg2); +s32 func_80185EC4(void); +s32 func_80185F04(void); +void func_80185F64(void* arg0, UNK_TYPE arg1, UNK_TYPE arg2); s32 func_80185F90(u32 param_1); u32 osFlashGetAddr(u32 pageNum); OSPiHandle* osFlashReInit(u8 latency, u8 pulse, u8 pageSize, u8 relDuration, u32 start); @@ -3316,130 +3249,53 @@ s32 osFlashReadArray(OSIoMesg* mb, s32 priority, u32 pageNum, void* dramAddr, u3 // void func_8018A808(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE4 param_6); // void func_8018ACC4(void); // void func_8018AE34(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); -// void func_8018B0F0(void); -// void func_8018B10C(void); -// void func_8018B250(void); -// void func_8018B318(void); -// void func_8018B474(void); -// void func_8018B4F8(void); -// void func_8018B520(void); -// void func_8018B578(void); -void* AudioHeap_AllocDmaMemory(AudioAllocPool* pool, u32 size); -// void func_8018B608(void); -// void func_8018B640(void); -// void func_8018B69C(void); -// void func_8018B6E8(void); -// void func_8018B740(void); -// void func_8018B768(void); -// void func_8018B77C(void); -// void func_8018B7BC(void); -// void func_8018B8FC(void); -// void func_8018B95C(void); -// void func_8018B9E0(void); -// void func_8018BA64(void); -// void func_8018BB28(void); -// void func_8018BBEC(void); -// void func_8018C380(void); -// void func_8018C3D8(void); -// void func_8018C8E8(void); -// void func_8018C93C(void); -// void func_8018C994(void); -// void func_8018CB70(void); -// void func_8018CB78(void); -// void func_8018CC3C(void); -// void func_8018CCA8(void); -// void func_8018CFAC(void); -// void func_8018D57C(void); -// void func_8018D5D4(void); -// void func_8018D658(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_8018D6C8(void); -// void func_8018D760(void); -// void func_8018DA50(void); -// void func_8018DBC4(void); -// void func_8018DCB4(void); -// void func_8018DCF8(void); -// void func_8018DD98(void); -// void func_8018DDD4(void); -// void func_8018DF24(void); -// void func_8018DFE0(void); -// void func_8018E00C(void); -// void func_8018E03C(void); -// void func_8018E2A8(void); -// void func_8018E344(void); -// void func_8018E8C8(void); -// void func_8018EB60(void); -// void func_8018EC4C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_8018EF88(void); -s32 AudioLoad_IsFontLoadComplete(s32 bankId); -// void func_8018F298(void); -// void func_8018F310(void); -// void func_8018F388(void); -// void func_8018F3B8(void); -// void func_8018F3E8(void); -// void func_8018F448(void); -// void func_8018F478(void); -// void func_8018F4D8(void); -// void func_8018F588(void); -// void func_8018F604(void); -// void func_8018F6F0(void); -// void func_8018F7C0(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_8018F7F8(void); -// void func_8018F83C(void); -// void func_8018F880(void); -// void func_8018F8C4(void); -// void func_8018F908(void); -// void func_8018F9B8(void); -// void func_8018FA60(void); -// void func_8018FAD0(void); -// void func_8018FB20(void); -// void func_8018FB78(void); -// void func_8018FCCC(void); -// void func_8018FD20(void); -// void func_8018FD40(void); -// void func_8018FE5C(void); -// void func_8018FF60(void); -// void func_80190204(void); -// void func_80190240(void); -// void func_80190294(void); -// void func_801902D8(void); -// void func_80190544(void); -// void func_80190668(void); -// void func_8019067C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8); -// void func_8019075C(void); -// void func_8019077C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_80190B08(void); -void func_80190B38(void* callback); -// void func_80190B50(void); -// void func_80190BB0(void); -// void func_80190F50(void); -// void func_80190F64(void); -// void func_80191134(void); -// void func_801911CC(void); -// void func_80191240(void); -// void func_801913C8(void); -// void func_8019144C(void); -// void func_80191460(void); -// void func_80191568(void); -// void func_80191598(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8); -// void func_8019161C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); -// void func_80191740(void); -// void func_80191864(void); -// void func_80191870(void); -// void func_801919AC(void); -// void func_80191B40(void); -// void func_80191BD0(void); -// void func_80191C40(void); -// void func_80191C54(void); -// void func_80191D94(void); -// void func_8019218C(void); -// void func_80192340(void); -// void func_80192388(void); -// void func_801924BC(void); -// void func_80192514(void); -// void func_80192990(void); -// void func_80192AE8(void); -// void func_80192B54(void); -// void func_80192BAC(void); +void AudioHeap_DiscardFont(s32 fontId); +void* AudioHeap_WritebackDCache(void* addr, size_t size); +void* AudioHeap_AllocAttemptExternal(AudioAllocPool* pool, size_t size); +void* AudioHeap_AllocDmaMemory(AudioAllocPool* pool, size_t size); +void* AudioHeap_AllocZeroed(AudioAllocPool* pool, size_t size); +void* AudioHeap_Alloc(AudioAllocPool* pool, size_t size); +void AudioHeap_AllocPoolInit(AudioAllocPool* pool, void* addr, size_t size); +void AudioHeap_PopCache(s32 tableType); +void AudioHeap_InitMainPool(size_t initPoolSize); +void* AudioHeap_AllocCached(s32 tableType, size_t size, s32 cache, s32 id); +void* AudioHeap_SearchCaches(s32 tableType, s32 cache, s32 id); +void AudioHeap_LoadFilter(s16* filter, s32 lowPassCutoff, s32 highPassCutoff); +s32 AudioHeap_ResetStep(void); +void AudioHeap_Init(void); +void* AudioHeap_SearchPermanentCache(s32 tableType, s32 id); +void* AudioHeap_AllocPermanent(s32 tableType, s32 id, size_t size); +void* AudioHeap_AllocSampleCache(size_t size, s32 sampleBankId, void* sampleAddr, s8 medium, s32 cache); +void AudioHeap_ApplySampleBankCache(s32 sampleBankId); +void AudioHeap_SetReverbData(s32 reverbIndex, u32 dataType, s32 data, s32 flags); +void AudioLoad_DecreaseSampleDmaTtls(void); +void* AudioLoad_DmaSampleData(uintptr_t devAddr, size_t size, s32 arg2, u8* dmaIndexRef, s32 medium); +void AudioLoad_InitSampleDmaBuffers(s32 numNotes); +s32 AudioLoad_IsFontLoadComplete(s32 fontId); +s32 AudioLoad_IsSeqLoadComplete(s32 seqId); +void AudioLoad_SetFontLoadStatus(s32 fontId, s32 status); +void AudioLoad_SetSeqLoadStatus(s32 seqId, s32 status); +void AudioLoad_SyncLoadSeqParts(s32 seqId, s32 arg1, s32 arg2, OSMesgQueue* arg3); +s32 AudioLoad_SyncLoadInstrument(s32 fontId, s32 instId, s32 drumId); +void AudioLoad_AsyncLoadSeq(s32 seqId, s32 arg1, s32 retData, OSMesgQueue* retQueue); +void AudioLoad_AsyncLoadSampleBank(s32 sampleBankId, s32 arg1, s32 retData, OSMesgQueue* retQueue); +void AudioLoad_AsyncLoadFont(s32 fontId, s32 arg1, s32 retData, OSMesgQueue* retQueue); +u8* AudioLoad_GetFontsForSequence(s32 seqId, u32* outNumFonts); +void AudioLoad_DiscardSeqFonts(s32 seqId); +void func_8018FA60(u32 tableType, u32 id, s32 arg2, s32 arg3); +s32 AudioLoad_SyncIniPlayer(s32 playerIdx, s32 seqId, s32 arg2); +s32 AudioLoad_SyncInitSetSeqqPlayerSkipTicks(s32 playerIdx, s32 seqId, s32 skipTicks); +void AudioLoad_ProcessLoads(s32 resetStatus); +void AudioLoad_SetDmaHandler(DmaHandler callback); +void AudioLoad_Init(void* heap, u32 heapSize); +void AudioLoad_InitSlowLoads(void); +s32 AudioLoad_SlowLoadSample(s32 fontId, s32 instId, s8* isDone); +s32 AudioLoad_SlowLoadSeq(s32 seqId, u8* ramAddr, s8* isDone); +void AudioLoad_InitAsyncLoads(void); +void AudioLoad_LoadPermanentSamples(void); +void AudioLoad_ScriptLoad(s32 tableType, s32 id, s8* isDone); +void AudioLoad_ProcessScriptLoads(void); +void AudioLoad_InitScriptLoads(void); AudioTask* func_80192BE0(void); // void func_80192C00(void); // void func_8019319C(void); @@ -3449,7 +3305,7 @@ AudioTask* func_80192BE0(void); // void func_8019380C(void); // void func_80193858(void); // void func_8019387C(void); -// void func_801938A0(void); +void Audio_QueueCmdS8(u32 opArgs, s8 data); // void func_801938D0(void); // void func_80193900(void); // void func_80193990(void); @@ -3473,8 +3329,8 @@ AudioTask* func_80192BE0(void); // void func_80194528(void); // void func_80194548(void); // void func_80194568(void); -// void func_80194668(void); -// void func_801946E4(void); +u32 Audio_NextRandom(void); +void Audio_InitMesgQueues(void); void Audio_InvalDCache(void* buf, size_t size); void Audio_WritebackDCache(void* buf, size_t size); // void func_80194790(void); @@ -3513,7 +3369,7 @@ void AudioSeq_SequenceChannelDisable(SequenceChannel* channel); // void func_80197B14(void); // void func_80197C0C(void); // void func_80197C8C(void); -// void func_80197D24(void); +void AudioSeq_SequencePlayerDisableAsFinished(SequencePlayer* seqPlayer); void AudioSeq_SequencePlayerDisable(SequencePlayer* seqPlayer); void AudioSeq_AudioListPushBack(AudioListItem* list, AudioListItem* item); void* AudioSeq_AudioListPopBack(AudioListItem* list); @@ -3535,23 +3391,23 @@ void func_80199268(s32* param_1); // void func_8019A0BC(void); // void func_8019AA3C(void); // void func_8019AAF0(void); -// void func_8019AB40(void); -// void func_8019AC10(void); +void AudioSeq_ResetSequencePlayer(SequencePlayer* seqPlayer); +void AudioSeq_InitSequencePlayerChannels(s32 playerIdx); // void func_8019ACEC(void); -// void func_8019ADBC(void); +void AudioSeq_InitSequencePlayers(void); void func_8019AE40(s32 param_1, s32 param_2, u32 param_3, s32 param_4); void func_8019AEC0(UNK_PTR param_1, UNK_PTR param_2); // void func_8019AF00(void); // void func_8019AF58(void); // void func_8019AFE8(void); // void func_8019B02C(void); -// void func_8019B074(void); +// void AudioOcarina_MapSongFromNotesToButtons(void); // void func_8019B144(void); // void func_8019B378(void); // void func_8019B38C(void); // void func_8019B3D0(void); // void func_8019B4B8(void); -void func_8019B544(u16 arg0); +void AudioOcarina_StartDefault(u32 arg0); // void func_8019B568(void); // void func_8019B5AC(void); // void func_8019B5EC(void); @@ -3563,7 +3419,7 @@ void func_8019B544(u16 arg0); // void func_8019C1D0(void); // void func_8019C268(void); // void func_8019C2E4(void); -void func_8019C300(s32 arg0); +u32 AudioOcarina_SetInstrumentId(u8 arg0); // void func_8019C398(void); // void func_8019C5A0(void); // void func_8019C8D8(void); @@ -3573,12 +3429,12 @@ void func_8019C300(s32 arg0); // void func_8019CEBC(void); // void func_8019CF6C(void); // void func_8019CF78(void); -// void func_8019CF9C(void); +OcarinaStaff* AudioOcarina_GetPlaybackStaff(void); // void func_8019CFA8(void); -// void func_8019D134(void); -// void func_8019D26C(void); -// void func_8019D488(void); -// void func_8019D4F8(void); +// void AudioOcarina_TerminaWallValidateNotes(void); +void AudioOcarina_TerminaWallGenerateNotes(void); +// void AudioOcarina_MemoryGameSetNumNotes(void); +// void AudioOcarina_MemoryGameGenerateNotes(void); // void func_8019D600(void); void func_8019D758(void); // void func_8019D864(void); @@ -3607,7 +3463,7 @@ void func_8019F230(void); // cancel sfx // void func_8019F300(void); void func_8019F420(Vec3f* pos, u16 sfxId); void func_8019F4AC(Vec3f* pos, u16 sfxId); -void func_8019F540(u8 arg0); +void func_8019F540(s8 arg0); void func_8019F570(Vec3f* pos, s8 arg1); // void func_8019F5AC(void); // void func_8019F638(void); @@ -3627,24 +3483,24 @@ void func_8019FDC8(UNK_PTR arg0, u16 sfxId, UNK_TYPE arg2); void func_8019FE74(f32* arg0, f32 arg1, s32 arg2); // void func_8019FEDC(void); // void func_8019FF38(void); -// void func_8019FF9C(void); -// void func_801A0048(void); -// void func_801A00EC(void); +void Audio_PlaySfxForRiver(Vec3f* pos, f32 freqScale); +// void Audio_PlaySfxForWaterfall(void); +// void Audio_StepFreqLerp(void); void func_801A0124(Vec3f* pos, u8 arg1); // void func_801A0184(void); // void func_801A01C4(void); void func_801A0204(s8 seqId); void func_801A0238(s32 arg0, s32 arg1); -// void func_801A026C(void); -// void func_801A0318(void); -// void func_801A046C(void); +// void Audio_SetGanonsTowerBgmVolumeLevel(void); +// void Audio_SetGanonsTowerBgmVolume(void); +// void Audio_UpdateRiverSoundVolumes(void); // void func_801A0554(void); // void func_801A05F0(void); void func_801A0654(Vec3f* arg0, u16 sfxId, s32 arg2); void func_801A0810(Vec3f* arg0, u16 sfxId, u8 arg2); // void func_801A0868(void); // void func_801A09D4(void); -// void func_801A0CB0(void); +// void Audio_SplitBgmChannels(void); // void func_801A0E44(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); // void func_801A1290(void); // void func_801A1348(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); @@ -3676,7 +3532,7 @@ void func_801A2C20(void); void func_801A2C88(u16 seqId); void func_801A2D54(u16 seqId); s32 Audio_IsSequencePlaying(u8 seqId); -void func_801A2E54(s32 param_1); +void func_801A2E54(s32 bgmId); void func_801A2ED8(void); // void func_801A2F88(void); // void func_801A3000(void); @@ -3689,14 +3545,14 @@ void func_801A31EC(u16 seqId, s8 arg1, u8 arg2); // void func_801A3590(void); u8 func_801A3950(s32 playerIndex, s32 isChannelIOSet); u8 func_801A39F8(void); -// void func_801A3A7C(void); +void func_801A3A7C(s32 arg0); // void func_801A3AC0(void); -// void func_801A3AEC(void); +void func_801A3AEC(s32 arg0); void func_801A3B48(UNK_TYPE arg0); // void func_801A3B90(void); void func_801A3CD8(s8 param_1); // void func_801A3CF4(void); -// void func_801A3D98(void); +void func_801A3D98(s8 audioSetting); // void func_801A3E38(void); // void func_801A3EC0(void); void Audio_SetCutsceneFlag(u8 flag); @@ -3704,7 +3560,7 @@ void Audio_SetCutsceneFlag(u8 flag); // void func_801A3FB4(void); // void func_801A3FFC(UNK_TYPE1 param_1); void audio_setBGM(u32 bgmID); -// void func_801A4058(void); +void func_801A4058(UNK_TYPE arg0); // void func_801A41C8(void); // void func_801A41F8(void); // void func_801A429C(void); @@ -3768,16 +3624,16 @@ void func_801A75E8(u16 sfxId); void func_801A7794(u32 param_1, u32 param_2, u32 param_3); // void func_801A7828(void); // void func_801A787C(void); -// void func_801A78E4(void); +u8 Audio_IsSfxPlaying(u32 sfxId); // void func_801A794C(void); // void func_801A7B10(void); // void func_801A7D04(void); // void func_801A7D84(void); -void Audio_QueueSeqCmd(u32 arg0); +void Audio_QueueSeqCmd(u32 cmd); // void func_801A89D0(void); s32 func_801A8A50(s32 param1); // void func_801A8ABC(void); -// void func_801A8BD0(void); +void Audio_SetVolumeScale(u8 playerIdx, u8 scaleIdx, u8 targetVol, u8 volFadeTimer); // void func_801A8D5C(void); // void func_801A8E90(void); // void func_801A9768(void); diff --git a/include/ichain.h b/include/ichain.h index f9131545c2..07bd073133 100644 --- a/include/ichain.h +++ b/include/ichain.h @@ -1,5 +1,5 @@ -#ifndef _ICHAIN_H_ -#define _ICHAIN_H_ +#ifndef ICHAIN_H +#define ICHAIN_H #include "libc/stddef.h" diff --git a/include/macro.inc b/include/macro.inc index 396a4cb687..d7a8da8755 100644 --- a/include/macro.inc +++ b/include/macro.inc @@ -37,3 +37,39 @@ .set TagHi, $29 .set ErrorEPC, $30 .set Reserved31, $31 + + +# Float register aliases (o32 ABI, odd ones are rarely used) + +.set $fv0, $f0 +.set $fv0f, $f1 +.set $fv1, $f2 +.set $fv1f, $f3 +.set $ft0, $f4 +.set $ft0f, $f5 +.set $ft1, $f6 +.set $ft1f, $f7 +.set $ft2, $f8 +.set $ft2f, $f9 +.set $ft3, $f10 +.set $ft3f, $f11 +.set $fa0, $f12 +.set $fa0f, $f13 +.set $fa1, $f14 +.set $fa1f, $f15 +.set $ft4, $f16 +.set $ft4f, $f17 +.set $ft5, $f18 +.set $ft5f, $f19 +.set $fs0, $f20 +.set $fs0f, $f21 +.set $fs1, $f22 +.set $fs1f, $f23 +.set $fs2, $f24 +.set $fs2f, $f25 +.set $fs3, $f26 +.set $fs3f, $f27 +.set $fs4, $f28 +.set $fs4f, $f29 +.set $fs5, $f30 +.set $fs5f, $f31 diff --git a/include/macros.h b/include/macros.h index d986dd78ec..5e9c062c9a 100644 --- a/include/macros.h +++ b/include/macros.h @@ -44,44 +44,68 @@ // linkAge still exists in MM, but is always set to 0 (always adult) // There are remnants of these macros from OOT, but they are essentially useless -#define LINK_IS_CHILD (gSaveContext.linkAge == 1) -#define LINK_IS_ADULT (gSaveContext.linkAge == 0) +#define LINK_IS_CHILD (gSaveContext.save.linkAge == 1) +#define LINK_IS_ADULT (gSaveContext.save.linkAge == 0) -#define CURRENT_DAY (((void)0, gSaveContext.day) % 5) +#define CURRENT_DAY (((void)0, gSaveContext.save.day) % 5) -#define TIME_TO_MINUTES(time) (s32)((time) * ((24 * 60) / 0x10000)) #define CLOCK_TIME(hr, min) (s32)(((hr) * 60 + (min)) * 0x10000 / (24 * 60)) #define CLOCK_TIME_MINUTE (CLOCK_TIME(0, 1)) -#define TIME_TO_MINUTES_F(time) ((time) * ((24.0f * 60.0f) / 0x10000)) +#define TIME_TO_MINUTES_F(time) ((time) * ((24.0f * 60.0f) / 0x10000)) // 0.021972656f #define CLOCK_TIME_F(hr, min) (((hr) * 60.0f + (min)) * (0x10000 / (24.0f * 60.0f))) -#define TIME_TO_MINUTES_ALT_F(time) ((time) / (24.0f * 60.0f / 0x10000)) +#define TIME_TO_MINUTES_ALT_F(time) ((time) / (0x10000 / (24.0f * 60.0f))) #define CLOCK_TIME_ALT_F(hr, min) (((hr) * 60.0f + (min)) / (24.0f * 60.0f / 0x10000)) #define SLOT(item) gItemSlots[item] -#define AMMO(item) gSaveContext.inventory.ammo[SLOT(item)] -#define INV_CONTENT(item) gSaveContext.inventory.items[SLOT(item)] +#define AMMO(item) gSaveContext.save.inventory.ammo[SLOT(item)] +#define INV_CONTENT(item) gSaveContext.save.inventory.items[SLOT(item)] +#define GET_INV_CONTENT(item) ((void)0, gSaveContext.save.inventory.items)[SLOT(item)] -#define ALL_EQUIP_VALUE_VOID(equip) \ - ((((void)0, gSaveContext.inventory.equipment) & gEquipMasks[equip]) >> gEquipShifts[equip]) -#define CUR_EQUIP_VALUE_VOID(equip) \ - ((((void)0, gSaveContext.equips.equipment) & gEquipMasks[equip]) >> gEquipShifts[equip]) -#define CUR_UPG_VALUE_VOID(upg) \ - ((((void)0, gSaveContext.inventory.upgrades) & gUpgradeMasks[upg]) >> gUpgradeShifts[upg]) -#define INV_CONTENT_VOID(item) ((void)0, gSaveContext.inventory.items)[SLOT(item)] +#define CUR_FORM ((gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) ? 0 : gSaveContext.save.playerForm) -#define CUR_FORM ((gSaveContext.playerForm == PLAYER_FORM_HUMAN) ? 0 : gSaveContext.playerForm) +#define GET_SAVE_EQUIPS_EQUIPMENT ((void)0, gSaveContext.save.equips.equipment) +#define GET_SAVE_INVENTORY_UPGRADES ((void)0, gSaveContext.save.inventory.upgrades) +#define GET_SAVE_INVENTORY_QUEST_ITEMS ((void)0, gSaveContext.save.inventory.questItems) -#define ALL_EQUIP_VALUE(equip) ((gSaveContext.inventory.equipment & gEquipMasks[equip]) >> gEquipShifts[equip]) -#define CUR_EQUIP_VALUE(equip) ((gSaveContext.equips.equipment & gEquipMasks[equip]) >> gEquipShifts[equip]) -#define CUR_UPG_VALUE(upg) ((gSaveContext.inventory.upgrades & gUpgradeMasks[upg]) >> gUpgradeShifts[upg]) -#define SET_EQUIP_VALUE(equip, value) (gSaveContext.equips.equipment = ((((void)0, gSaveContext.equips.equipment) & (gEquipNegMasks[equip])) | (u16)((u16)(value) << gEquipShifts[equip]))) -#define CUR_FORM_EQUIP(button) (gSaveContext.equips.buttonItems[CUR_FORM][button]) -#define CHECK_QUEST_ITEM(item) (((void)0, gSaveContext.inventory.questItems) & gBitFlags[item]) -#define REMOVE_QUEST_ITEM(item) (gSaveContext.inventory.questItems = (((void)0, gSaveContext.inventory.questItems) & (-1 - gBitFlags[item]))) -#define CHECK_DUNGEON_ITEM(item, dungeonIndex) (gSaveContext.inventory.dungeonItems[(void)0, dungeonIndex] & gBitFlags[item]) -#define DUNGEON_KEY_COUNT(dungeonIndex) (gSaveContext.inventory.dungeonKeys[(void)0, dungeonIndex]) +#define GET_CUR_EQUIP_VALUE(equip) ((GET_SAVE_EQUIPS_EQUIPMENT & gEquipMasks[equip]) >> gEquipShifts[equip]) + +#define CUR_UPG_VALUE(upg) ((gSaveContext.save.inventory.upgrades & gUpgradeMasks[upg]) >> gUpgradeShifts[upg]) +#define GET_CUR_UPG_VALUE(upg) ((GET_SAVE_INVENTORY_UPGRADES & gUpgradeMasks[upg]) >> gUpgradeShifts[upg]) + +#define SET_EQUIP_VALUE(equip, value) (gSaveContext.save.equips.equipment = ((GET_SAVE_EQUIPS_EQUIPMENT & gEquipNegMasks[equip]) | (u16)((u16)(value) << gEquipShifts[equip]))) + +#define BUTTON_ITEM_EQUIP(form, button) (gSaveContext.save.equips.buttonItems[form][button]) +#define CUR_FORM_EQUIP(button) BUTTON_ITEM_EQUIP(CUR_FORM, button) + +#define C_SLOT_EQUIP(form, button) (gSaveContext.save.equips.cButtonSlots[form][button]) +#define CHECK_QUEST_ITEM(item) (GET_SAVE_INVENTORY_QUEST_ITEMS & gBitFlags[item]) +#define REMOVE_QUEST_ITEM(item) (gSaveContext.save.inventory.questItems = (GET_SAVE_INVENTORY_QUEST_ITEMS & (-1 - gBitFlags[item]))) + +#define CHECK_DUNGEON_ITEM(item, dungeonIndex) (gSaveContext.save.inventory.dungeonItems[(void)0, dungeonIndex] & gBitFlags[item]) +#define DUNGEON_KEY_COUNT(dungeonIndex) (gSaveContext.save.inventory.dungeonKeys[(void)0, dungeonIndex]) + +#define GET_CUR_FORM_BTN_ITEM(btn) ((u8)((btn) == EQUIP_SLOT_B ? BUTTON_ITEM_EQUIP(CUR_FORM, btn) : BUTTON_ITEM_EQUIP(0, btn))) + +#define SET_CUR_FORM_BTN_ITEM(btn, item) \ + do { \ + if ((btn) == EQUIP_SLOT_B) { \ + BUTTON_ITEM_EQUIP(CUR_FORM, (btn)) = (item); \ + } else { \ + BUTTON_ITEM_EQUIP(0, (btn)) = (item); \ + } \ + } while (0) + +#define STOLEN_ITEM_NONE (0) + +#define STOLEN_ITEM_1 ((gSaveContext.save.stolenItems & 0xFF000000) >> 0x18) +#define STOLEN_ITEM_2 ((gSaveContext.save.stolenItems & 0x00FF0000) >> 0x10) + +#define SET_STOLEN_ITEM_1(itemId) \ + (gSaveContext.save.stolenItems = (gSaveContext.save.stolenItems & ~0xFF000000) | ((itemId & 0xFF) << 0x18)) +#define SET_STOLEN_ITEM_2(itemId) \ + (gSaveContext.save.stolenItems = (gSaveContext.save.stolenItems & ~0x00FF0000) | ((itemId & 0xFF) << 0x10)) #define CAPACITY(upg, value) gUpgradeCapacities[upg][value] #define CUR_CAPACITY(upg) CAPACITY(upg, CUR_UPG_VALUE(upg)) @@ -153,6 +177,7 @@ extern GraphicsContext* __gfxCtx; #define ALIGN8(val) (((val) + 7) & ~7) #define ALIGN16(val) (((val) + 0xF) & ~0xF) #define ALIGN64(val) (((val) + 0x3F) & ~0x3F) +#define ALIGN256(val) (((val) + 0xFF) & ~0xFF) #define SQ(x) ((x) * (x)) #define ABS(x) ((x) >= 0 ? (x) : -(x)) @@ -181,4 +206,4 @@ extern GraphicsContext* __gfxCtx; #define ALIGNED8 #endif -#endif // _MACROS_H_ +#endif // MACROS_H diff --git a/include/message_data_static.h b/include/message_data_static.h new file mode 100644 index 0000000000..f69e17232b --- /dev/null +++ b/include/message_data_static.h @@ -0,0 +1,12 @@ +#ifndef MESSAGE_DATA_STATIC_H +#define MESSAGE_DATA_STATIC_H + +#include "PR/ultratypes.h" + +typedef struct MessageTableEntry{ + /* 0x0 */ u16 textId; + /* 0x2 */ u8 typePos; + /* 0x4 */ const char* segment; +} MessageTableEntry; // size = 0x8; + +#endif diff --git a/include/segment_symbols.h b/include/segment_symbols.h index 3f02baa5c0..e133437cc2 100644 --- a/include/segment_symbols.h +++ b/include/segment_symbols.h @@ -1,7 +1,8 @@ -#ifndef _SEGMENT_SYMBOLS_H_ -#define _SEGMENT_SYMBOLS_H_ +#ifndef SEGMENT_SYMBOLS_H +#define SEGMENT_SYMBOLS_H -#include "z64.h" +#include "libc/stddef.h" +#include "PR/ultratypes.h" #define DECLARE_SEGMENT(name) \ extern u8 _##name##SegmentStart[]; \ diff --git a/include/variables.h b/include/variables.h index 7eafe0d2f3..4acb019a41 100644 --- a/include/variables.h +++ b/include/variables.h @@ -43,7 +43,6 @@ extern StackEntry* sStackInfoListEnd; // extern UNK_TYPE1 sGfxPrintUnkTLUT; // extern UNK_TYPE1 sGfxPrintUnkData; // extern UNK_TYPE1 sGfxPrintFontData; -// extern UNK_TYPE4 D_80097500; // extern UNK_TYPE4 D_80097524; // extern u32 sRandInt; extern OSViMode osViModeNtscHpf1; @@ -428,7 +427,6 @@ extern Color_RGBA8 actorDefaultHitColor; // extern UNK_TYPE2 D_801AEE4C; extern Gfx D_801AEF88[]; extern Gfx D_801AEFA0[]; -// extern UNK_TYPE1 D_801AEFA8; // extern UNK_TYPE1 D_801AEFB8; // extern UNK_TYPE1 D_801AEFBC; // extern UNK_TYPE1 D_801AEFC0; @@ -895,7 +893,7 @@ extern s32 graphNumGameStates; // extern UNK_TYPE2 D_801BDA7C; extern s32 D_801BDA9C; extern UNK_TYPE4 D_801BDAA0; -extern UNK_TYPE4 D_801BDAA4; +extern s32 D_801BDAA4; // extern UNK_TYPE2 D_801BDAA8; // extern UNK_TYPE2 D_801BDAAA; // extern UNK_TYPE2 D_801BDAAC; @@ -910,9 +908,7 @@ extern UNK_TYPE4 D_801BDAA4; // extern UNK_TYPE4 D_801BDACC; // extern UNK_TYPE4 D_801BDAF0; // extern UNK_TYPE4 D_801BDAF8; -// extern UNK_TYPE1 D_801BDB00; -// extern UNK_TYPE1 D_801BDB08; -// extern UNK_TYPE1 D_801BDB18; + extern u8 kanfontOrdering[92]; // extern UNK_TYPE4 D_801BDB90; // extern UNK_TYPE4 D_801BDB94; @@ -1353,12 +1349,6 @@ extern SceneTableEntry gSceneTable[]; extern UNK_PTR D_801C5C50; // extern UNK_TYPE1 D_801C5C9C; extern UNK_PTR D_801C5CB0; -extern MtxF sMtxFClear; -// extern UNK_TYPE1 D_801C5D10; -// extern UNK_TYPE1 D_801C5D20; -// extern UNK_TYPE1 D_801C5D60; -// extern UNK_TYPE1 D_801C5D80; -extern Vec3f D_801C5DB0; // extern UNK_TYPE1 D_801C5DD0; // extern UNK_TYPE1 D_801C5DE0; // extern UNK_TYPE1 D_801C5DF0; @@ -1370,36 +1360,7 @@ extern s32 D_801C5E9C[]; // D_801C5E9C extern s32 D_801C5EB0[]; // D_801C5EB0 extern s16 D_801C5EC4[]; // D_801C5EC4 extern struct_801C5F44 D_801C5F44[]; // D_801C5F44 -// extern UNK_TYPE4 D_801C5FC0; -// extern UNK_TYPE4 D_801C5FC4; -// extern UNK_TYPE4 D_801C5FC8; -// extern UNK_TYPE4 D_801C5FCC; -// extern UNK_TYPE4 D_801C5FD0; -// extern UNK_TYPE2 D_801C66D0; -// extern UNK_TYPE4 D_801C6798; -// extern UNK_TYPE1 D_801C67B0; -// extern UNK_TYPE4 D_801C67C8; -// extern UNK_TYPE4 D_801C67CC; -// extern UNK_TYPE4 D_801C67E8; -// extern UNK_TYPE4 D_801C67F0; -// extern UNK_TYPE4 D_801C67F4; -// extern UNK_TYPE1 D_801C6818; -// extern UNK_TYPE4 D_801C6838; -// extern UNK_TYPE1 D_801C6840; -// extern UNK_TYPE1 D_801C6850; -// extern UNK_TYPE1 D_801C6870; -// extern UNK_TYPE1 D_801C6890; -// extern UNK_TYPE1 D_801C6898; -// extern UNK_TYPE1 D_801C68C0; -extern Inventory gSaveDefaultInventory; -extern u16 gSaveDefaultChecksum; -// extern UNK_TYPE1 D_801C6970; -// extern UNK_TYPE1 D_801C6998; -extern Inventory D_801C69BC; -extern u16 D_801C6A44; -// extern UNK_TYPE1 D_801C6A48; -// extern UNK_TYPE1 D_801C6A50; -// extern UNK_TYPE1 D_801C6A58; + // extern UNK_TYPE1 D_801C6A70; // extern UNK_TYPE2 D_801C6A74; // extern UNK_TYPE2 D_801C6A78; @@ -1413,9 +1374,7 @@ extern u16 D_801C6A44; // extern UNK_TYPE1 D_801C6A98; // extern UNK_TYPE1 D_801C6AB8; // extern UNK_TYPE1 D_801C6B28; -// extern UNK_TYPE1 D_801C6B98; // extern UNK_TYPE1 D_801CED40; -// extern UNK_TYPE1 D_801CFB08; // extern UNK_TYPE2 D_801CFC78; // extern UNK_TYPE1 D_801CFC7A; // extern UNK_TYPE1 D_801CFC7C; @@ -1425,8 +1384,8 @@ extern u16 D_801C6A44; // extern UNK_TYPE1 D_801CFC8C; // extern UNK_TYPE1 D_801CFC8E; // extern UNK_TYPE1 D_801CFC92; -// extern UNK_TYPE1 D_801CFC98; -// extern UNK_TYPE2 D_801CFCA4; +extern u8 D_801CFC98; +extern s16 D_801CFCA4[9]; // extern UNK_TYPE2 D_801CFCAC; // extern UNK_TYPE1 D_801CFCB8; // extern UNK_TYPE2 D_801CFCD8; @@ -1518,11 +1477,11 @@ extern char D_801D039C[]; // extern UNK_TYPE1 D_801D0428; // extern UNK_TYPE1 D_801D045A; // extern UNK_TYPE1 D_801D0462; -// extern UNK_TYPE1 D_801D0468; +//extern UNK_TYPE1 D_801D0468; // extern UNK_TYPE1 D_801D0470; -extern char D_801D06F0[]; +// extern char D_801D06F0[]; // extern UNK_TYPE1 D_801D0710; -extern char D_801D0714[]; +// extern char D_801D0714[]; // extern UNK_TYPE1 D_801D07C4; // extern UNK_TYPE1 D_801D07DC; // extern UNK_TYPE1 D_801D080C; @@ -1617,21 +1576,11 @@ extern Vec3f gZeroVec3f; extern Vec3s gZeroVec3s; extern Mtx gIdentityMtx; extern MtxF gIdentityMtxF; -// extern u64* initialgspUcodeText; -// extern u64* initialgspUcodeData; // extern UNK_TYPE1 D_801D1E70; -// extern UNK_TYPE1 gLowPassFilterData; -// extern UNK_TYPE1 gHighPassFilterData; -// extern UNK_TYPE1 gBandStopFilterData; -// extern UNK_TYPE1 gBandPassFilterData; -// extern UNK_TYPE1 gSawtoothWaveSample; -// extern UNK_TYPE1 gTriangleWaveSample; -// extern UNK_TYPE1 gSineWaveSample; -// extern UNK_TYPE1 gSquareWaveSample; -// extern UNK_TYPE1 gWhiteNoiseSample; -// extern UNK_TYPE1 D_801D4790; -// extern UNK_TYPE1 gEighthPulseWaveSample; -// extern UNK_TYPE1 gQuarterPulseWaveSample; +extern s16 gLowPassFilterData[]; +extern s16 gHighPassFilterData[]; +extern s16 gBandStopFilterData[]; +extern s16 gBandPassFilterData[]; extern s16* gWaveSamples[9]; extern UNK_PTR D_801D4D98; extern UNK_PTR D_801D4DB0; @@ -1659,7 +1608,7 @@ extern f32 gDefaultPanVolume[]; // extern UNK_TYPE1 D_801D5FD4; extern UNK_PTR D_801D5FE0; // extern UNK_TYPE1 D_801D5FE4; -// extern UNK_TYPE4 D_801D5FE8; +extern s32 gAudioContextInitalized; // extern UNK_TYPE4 D_801D5FEC; // extern UNK_TYPE4 D_801D5FF0; // extern UNK_TYPE4 D_801D5FF4; @@ -1781,11 +1730,11 @@ extern UNK_PTR D_801D84F0; // extern UNK_TYPE2 D_801D853E; // extern UNK_TYPE1 D_801D8544; extern UNK_PTR D_801D889C; -extern UNK_PTR D_801D88A0; +extern u8* gScarecrowSpawnSongPtr; extern UNK_PTR D_801D88A4; // extern UNK_TYPE1 D_801D88A8; // extern UNK_TYPE1 D_801D88B8; -// extern UNK_TYPE1 D_801D8A48; +extern OcarinaSongButtons gOcarinaSongButtons[24]; // extern UNK_TYPE1 D_801D8B20; extern UNK_PTR D_801D8B24; // extern UNK_TYPE2 D_801D8B28; @@ -1840,7 +1789,7 @@ extern s8 D_801DB4B8; // extern UNK_TYPE1 D_801DB8B8; // extern UNK_TYPE1 D_801DB900; extern UNK_PTR D_801DB930; -extern AudioSpec D_801DB958[21]; +extern AudioSpec gAudioSpecs[21]; // rodata extern f32 D_801DBDF0; @@ -3019,7 +2968,7 @@ extern f32 D_801E05B4; extern f32 D_801E05B8; extern f32 D_801E05D0; extern f32 D_801E05D4; -// extern UNK_TYPE1 D_801E0BD0; +extern const u16 gAudioEnvironmentalSfx[]; // extern UNK_TYPE1 D_801E0BFC; extern f32 D_801E0CEC; extern f32 D_801E0CF0; @@ -3073,10 +3022,10 @@ extern const s16 gAudioTatumInit[]; extern const AudioContextInitSizes gAudioContextInitSizes; // extern UNK_TYPE4 D_801E1108; // extern UNK_TYPE4 D_801E110C; -// extern UNK_TYPE2 gSoundFontTable; -// extern UNK_TYPE1 gSequenceFontTable; -// extern UNK_TYPE2 gSequenceTable; -// extern UNK_TYPE1 gSampleBankTable; +extern u8 gSoundFontTable[]; +extern u8 gSequenceFontTable[]; +extern u8 gSequenceTable[]; +extern u8 gSampleBankTable[]; extern u64 aspMainDataStart[]; // bss @@ -3245,7 +3194,7 @@ extern s16 D_801F4E7A; // extern UNK_TYPE1 D_801F4F66; // extern UNK_TYPE1 D_801F4F68; // extern UNK_TYPE1 D_801F4F6A; -extern LightsBuffer sLightsBuffer; +// extern LightsBuffer sLightsBuffer; // extern UNK_TYPE1 D_801F5130; // extern UNK_TYPE1 D_801F5270; // extern UNK_TYPE1 D_801F528E; @@ -3269,7 +3218,6 @@ extern LightsBuffer sLightsBuffer; // extern UNK_TYPE1 D_801F59F0; // extern UNK_TYPE1 D_801F59F4; // extern UNK_TYPE1 D_801F59F8; -// extern UNK_TYPE1 D_801F5AC0; // extern UNK_TYPE1 D_801F69D0; // extern UNK_TYPE1 D_801F6A10; // extern UNK_TYPE1 D_801F6AD4; @@ -3297,9 +3245,9 @@ extern ShrinkWindowContext gShrinkWindowContext; extern ShrinkWindowContext* gShrinkWindowContextPtr; // extern UNK_TYPE4 D_801F6B50; // extern UNK_TYPE1 D_801F6B58; -extern FaultAddrConvClient sKaleidoAreaFaultClient; extern void (*sKaleidoScopeUpdateFunc)(GlobalContext* globalCtx); extern void (*sKaleidoScopeDrawFunc)(GlobalContext* globalCtx); +extern FaultAddrConvClient sKaleidoAreaFaultClient; // extern UNK_TYPE1 D_801F6C10; extern Input D_801F6C18; // extern UNK_TYPE1 D_801F6C30; @@ -3470,7 +3418,7 @@ extern StackEntry sys_flashromStackEntry; extern OSThread sys_flashromOSThread; extern s80185D40 D_801FD008; extern OSMesg D_801FD034; -// extern UNK_TYPE1 D_801FD120; +extern s32 D_801FD120; // extern UNK_TYPE1 D_801FD140; // extern UNK_TYPE1 D_801FD158; // extern UNK_TYPE1 D_801FD198; @@ -3597,10 +3545,10 @@ extern SoundRequest D_801FE7C0[1]; // extern UNK_TYPE1 D_80200BCE; // extern UNK_TYPE1 D_80200BD0; extern AudioContext gAudioContext; // at 0x80200C70 -// extern UNK_TYPE4 D_80208E68; -// extern UNK_TYPE4 D_80208E6C; -// extern UNK_TYPE4 D_80208E70; -// extern UNK_TYPE4 D_80208E74; +extern void (*D_80208E68)(void); +extern u32 (*D_80208E6C)(s8 value, SequenceChannel* channel); +extern s32 (*D_80208E70)(SoundFontSample*, s32, s8, s32); +extern Acmd* (*D_80208E74)(Acmd*, s32, s32); // post-code buffers extern u8 gGfxSPTaskYieldBuffer[OS_YIELD_DATA_SIZE]; diff --git a/include/z64.h b/include/z64.h index 189937fb71..e5533234aa 100644 --- a/include/z64.h +++ b/include/z64.h @@ -21,6 +21,7 @@ #include "ichain.h" #include "sequence.h" #include "sfx.h" +#include "message_data_static.h" #include "z64actor.h" #include "z64animation.h" @@ -36,8 +37,11 @@ #include "z64object.h" #include "z64ocarina.h" #include "z64player.h" -#include "z64scene.h" #include "z64save.h" +#include "z64scene.h" +#include "z64schedule.h" +#include "z64skin.h" +#include "z64subs.h" #include "z64transition.h" #include "regs.h" @@ -139,15 +143,21 @@ typedef struct { /* 0x4 */ f32 dynamicSizeStep; /* 0x8 */ u8 state; /* 0x9 */ u8 sizeGrowsCos2; - /* 0xA */ u8 unkA; + /* 0xA */ u8 colorsIndex; /* 0xB */ u8 flags; - /* 0xC */ u8 unkC; + /* 0xC */ u8 lightParamsIndex; } FireObjInitParams; // size = 0xD -typedef struct { +typedef struct FireObjColors { /* 0x0 */ Color_RGBA8 primColor; - /* 0x4 */ u8 unk4; + /* 0x4 */ u8 lod; /* 0x5 */ Color_RGB8 envColor; +} FireObjColors; // size = 0x8 + +typedef struct FireObjLightParams { + /* 0x0 */ s16 radius; + /* 0x2 */ Color_RGB8 color; + /* 0x5 */ Color_RGB8 maxColorAdj; } FireObjLightParams; // size = 0x8 #define FONT_CHAR_TEX_WIDTH 16 @@ -166,7 +176,7 @@ typedef struct { } msgBuf; /* 0x11D80 */ u8* messageStart; /* 0x11D84 */ u8* messageEnd; - /* 0x11D88 */ u8 unk_11D88; + /* 0x11D88 */ u8 unk_11D88; // current Char Buffer ? } Font; // size = 0x11D8C // Game Info aka. Static Context @@ -306,19 +316,6 @@ typedef struct { /* 0x3 */ s8 pillarboxMagnitude; } ShrinkWindowContext; // size = 0x4 -typedef struct { - /* 0x00 */ u8* readBuff; - /* 0x04 */ u32* flashReadBuff; - /* 0x08 */ char unk_08[4]; - /* 0x0C */ s16 status; - /* 0x10 */ u32 curPage; - /* 0x14 */ u32 numPages; - /* 0x18 */ OSTime unk_18; - /* 0x20 */ s16 unk_20; - /* 0x22 */ s16 unk_22; - /* 0x24 */ s16 unk_24; -} SramContext; // size = 0x28 - typedef struct { /* 0x0 */ s32 topY; /* 0x4 */ s32 bottomY; @@ -831,45 +828,91 @@ typedef struct { typedef struct { /* 0x00000 */ View view; /* 0x00168 */ Font font; - /* 0x11EF4 */ char unk_11EF4[0x10]; - /* 0x11F04 */ u16 unk11F04; + /* 0x11EF4 */ char unk_11EF4[0x4]; + /* 0x11EF8 */ UNK_PTR unk11EF8; + /* 0x11EFC */ UNK_TYPE1 unk11EFC[0x8]; + /* 0x11F04 */ u16 currentTextId; /* 0x11F06 */ UNK_TYPE1 pad11F06[0x4]; /* 0x11F0A */ u8 unk11F0A; /* 0x11F0B */ UNK_TYPE1 pad11F0B[0x5]; /* 0x11F10 */ s32 unk11F10; - /* 0x11F14 */ UNK_TYPE1 pad11F14[0xE]; + /* 0x11F14 */ UNK_TYPE1 pad11F14[0x6]; + /* 0x11F1A */ s16 unk11F1A[3]; + /* 0x11F20 */ UNK_TYPE1 pad11F20[0x2]; /* 0x11F22 */ u8 msgMode; - /* 0x11F23 */ UNK_TYPE1 pad11F23[0xFD]; + /* 0x11F23 */ UNK_TYPE1 pad11F23; + /* 0x11F24 */ union { + u8 schar[206]; + u16 wchar[103]; + } decodedBuffer; + /* 0x11FF2 */ u16 unk11FF2; + /* 0x11FF4 */ s16 unk11FF4; + /* 0x11FF6 */ s16 unk11FF6; + /* 0x11FF8 */ UNK_TYPE1 unk11FF8[0x6]; + /* 0x11FFE */ s16 unk11FFE[0x3]; + /* 0x12004 */ s16 unk12004; + /* 0x12006 */ s16 unk12006; + /* 0x12008 */ u8 unk12008[0x16]; + /* 0x1201E */ s16 unk1201E; /* 0x12020 */ u8 unk12020; /* 0x12021 */ u8 choiceIndex; /* 0x12022 */ u8 unk12022; /* 0x12023 */ u8 unk12023; - /* 0x12024 */ UNK_TYPE1 unk12024[0x6]; + /* 0x12024 */ s16 unk12024; + /* 0x12026 */ u16 unk12026; + /* 0x12028 */ u16 songPlayed; /* 0x1202A */ u16 ocarinaMode; /* 0x1202C */ u16 ocarinaAction; /* 0x1202E */ u16 unk1202E; /* 0x12030 */ s16 unk_12030; /* 0x12032 */ UNK_TYPE1 unk_12032[0x2]; - /* 0x12034 */ UNK_TYPE1 pad12034[0x10]; + /* 0x12034 */ UNK_TYPE1 pad12034[0x6]; + /* 0x1203A */ s16 unk1203A; + /* 0x1203C */ s16 unk1203C; + /* 0x1203E */ s16 pad1203E; + /* 0x12040 */ Actor* unkActor; /* 0x12044 */ s16 unk12044; - /* 0x12046 */ UNK_TYPE1 pad12046[0x2]; + /* 0x12046 */ s16 unk12046; /* 0x12048 */ u8 unk12048; // EnKakasi - /* 0x12049 */ UNK_TYPE1 pad12049[0xB]; - /* 0x12054 */ s16 unk12054; // First digit in lottery code guess - /* 0x12056 */ s16 unk12056; // Second digit lottery code guess - /* 0x12058 */ s16 unk12058; // Third digit lottery code guess - /* 0x1205A */ UNK_TYPE1 pad1205A[0x10]; + /* 0x12049 */ UNK_TYPE1 pad12049[0x1]; + /* 0x1204A */ s16 unk1204A[0x5]; + /* 0x12054 */ s16 unk12054[3]; // First, second and third digits in lottery code guess + /* 0x1205A */ UNK_TYPE1 pad1205A[0xE]; + /* 0x12068 */ s16 unk12068; /* 0x1206A */ s16 unk1206A; /* 0x1206C */ s32 unk1206C; /* 0x12070 */ s32 unk12070; /* 0x12074 */ UNK_TYPE1 pad12074[0x4]; /* 0x12078 */ s32 bankRupeesSelected; - /* 0x1207C */ s32 bankRupees; - /* 0x12080 */ UNK_TYPE1 pad12080[0x31]; + /* 0x1207C */ s32 bankRupees; + /* 0x12080 */ MessageTableEntry* messageEntryTable; + /* 0x12084 */ MessageTableEntry* messageEntryTableNes; + /* 0x12088 */ UNK_TYPE4 unk12088; + /* 0x1208C */ MessageTableEntry* messageTableStaff; + /* 0x12090 */ s16 unk12090; + /* 0x12092 */ s16 unk12092; + /* 0x12094 */ s8 unk12094; + /* 0x12095 */ UNK_TYPE1 unk12095[0x3]; + /* 0x12098 */ f32 unk12098; // Text_Scale? + /* 0x1209C */ s16 unk1209C; + /* 0x1209E */ UNK_TYPE1 unk1209E[0x2]; + /* 0x120A0 */ s32 unk120A0; + /* 0x120A4 */ UNK_TYPE1 unk120A4[0xC]; + /* 0x120B0 */ u8 unk120B0; /* 0x120B1 */ u8 unk120B1; - /* 0x120B2 */ UNK_TYPE1 pad120B2[0x22]; - /* 0x120D4 */ UNK_TYPE2 unk120D4; - /* 0x120D6 */ UNK_TYPE2 unk120D6; + /* 0x120B2 */ u8 unk120B2[0xC]; + /* 0x120BE */ s16 unk120BE; + /* 0x120C0 */ s16 unk120C0; + /* 0x120C2 */ s16 unk120C2; + /* 0x120C4 */ s32 unk120C4; + /* 0x120C8 */ s16 unk120C8; + /* 0x120CA */ s16 unk120CA; + /* 0x120CC */ s16 unk120CC; + /* 0x120CE */ s16 unk120CE; + /* 0x120D0 */ s16 unk120D0; + /* 0x120D2 */ s16 unk120D2; + /* 0x120D4 */ s16 unk120D4; + /* 0x120D6 */ s16 unk120D6; /* 0x120D8 */ UNK_TYPE1 pad120D8[0x8]; } MessageContext; // size = 0x120E0 @@ -1114,7 +1157,7 @@ typedef struct { typedef enum { /* 0 */ DISTORTION_INACTIVE, /* 1 */ DISTORTION_ACTIVE, - /* 2 */ DISTORTION_SETUP, + /* 2 */ DISTORTION_SETUP } DistortionState; typedef struct { @@ -1158,8 +1201,8 @@ typedef enum { struct FireObjLight { /* 0x00 */ LightNode* light; - /* 0x04 */ LightInfoPositional lightInfo; - /* 0x12 */ u8 unk12; + /* 0x04 */ LightInfo lightInfo; + /* 0x12 */ u8 lightParamsIndex; }; // size = 0x13 #define OS_SC_RETRACE_MSG 1 @@ -1181,7 +1224,7 @@ typedef struct { /* 0x12C */ UNK_TYPE1 pad_12C[0x4]; /* 0x130 */ OSThread thread; } AudioMgr; // size = 0x2E0 - + typedef struct { /* 0x00 */ MtxF displayMatrix; /* 0x40 */ Actor* actor; @@ -1210,7 +1253,7 @@ struct FireObj { /* 0x24 */ u8 state; // 0 - growing, 1 - shrinking, 2 - fully lit, 3 - not lit /* 0x25 */ u8 sizeGrowsCos2; /* 0x26 */ u8 unk26; - /* 0x27 */ u8 unk27; + /* 0x27 */ u8 colorsIndex; /* 0x28 */ u8 flags; // bit 0 - ?, bit 1 - ? /* 0x29 */ UNK_TYPE1 pad29[0x1]; /* 0x2A */ s16 ignitionDelay; @@ -1280,7 +1323,7 @@ struct GlobalContext { /* 0x18760 */ DoorContext doorCtx; /* 0x18768 */ void (*playerInit)(Player* player, struct GlobalContext* globalCtx, FlexSkeletonHeader* skelHeader); /* 0x1876C */ void (*playerUpdate)(Player* player, struct GlobalContext* globalCtx, Input* input); - /* 0x18770 */ void* unk_18770; //! @TODO: Determine function prototype + /* 0x18770 */ void (*unk_18770)(struct GlobalContext* globalCtx, Player* player); /* 0x18774 */ s32 (*startPlayerFishing)(struct GlobalContext* globalCtx); /* 0x18778 */ s32 (*grabPlayer)(struct GlobalContext* globalCtx, Player* player); /* 0x1877C */ s32 (*startPlayerCutscene)(struct GlobalContext* globalCtx, Player* player, s32 mode); @@ -1355,51 +1398,6 @@ typedef struct { /* 0x24 */ s16 unk_24; } struct_800BD888_arg1; // size = 0x28 -typedef struct { - /* 0x0 */ u8 unk0; - /* 0x4 */ s32 unk4; - /* 0x8 */ s32 unk8; // game script pointer? -} struct_80133038_arg2; // size = 0xC - - -typedef enum { - /* 0 */ SUBS_CUTSCENE_SET_UNK_LINK_FIELDS, - /* 1 */ SUBS_CUTSCENE_NORMAL, - /* 2 */ SUBS_CUTSCENE_SET_FLAG -} SubSCutsceneType; - -typedef s32 (*func_8013E748_arg6)(struct GlobalContext*, Actor*, Vec3s*); - -typedef s32 (*VerifyActor)(struct GlobalContext*, Actor*, Actor*, void*); - -struct struct_8013DF3C_arg1; -typedef void (*struct_8013DF3C_arg1_unk_func1)(struct GlobalContext*, struct struct_8013DF3C_arg1*); -typedef s32 (*struct_8013DF3C_arg1_unk_func2)(struct GlobalContext*, struct struct_8013DF3C_arg1*); - -typedef struct struct_8013DF3C_arg1 { - /* 0x00 */ Path* setupPathList; - /* 0x04 */ s32 pathIndex; - /* 0x08 */ Vec3s* points; - /* 0x0C */ s32 count; - /* 0x10 */ s32 unk_10; - /* 0x14 */ s32 unk_14; - /* 0x18 */ s32 unk_18; - /* 0x1C */ u8 unk_1C; - /* 0x1D */ u8 unk_1D; - /* 0x20 */ Vec3f unk_20; - /* 0x2C */ Vec3f unk_2C; - /* 0x38 */ Vec3f unk_38; - /* 0x44 */ Vec3f* unk_44; - /* 0x48 */ Actor* actor; - /* 0x4C */ f32 unk_4C; - /* 0x50 */ f32 unk_50; - /* 0x54 */ Vec3s unk_54; - /* 0x5C */ struct_8013DF3C_arg1_unk_func1 unk_5C; - /* 0x60 */ struct_8013DF3C_arg1_unk_func2 unk_60; - /* 0x64 */ struct_8013DF3C_arg1_unk_func2 unk_64; - /* 0x68 */ struct_8013DF3C_arg1_unk_func2 unk_68; -} struct_8013DF3C_arg1; // size = 0x6C - typedef struct { /* 0x00 */ u32 type; /* 0x04 */ u32 setScissor; @@ -1492,6 +1490,20 @@ enum fram_mode { FRAM_MODE_STATUS }; +typedef struct { + /* 0x00 */ UNK_TYPE1 unk_00[0x14]; + /* 0x14 */ s16 unk_14; + /* 0x16 */ s16 unk_16; + /* 0x18 */ s16 unk_18; + /* 0x1A */ UNK_TYPE1 unk_1A[0x3]; + /* 0x0C */ u8 unk_1D; + /* 0x1E */ UNK_TYPE1 unk_1E[0xC]; + /* 0x2A */ s16 unk_2A; + /* 0x1E */ UNK_TYPE1 unk_2C[0x1]; + /* 0x2D */ u8 unk_2D; + /* 0x2E */ UNK_TYPE1 unk_2E[2]; +} DbCameraUnkSubStruct; // size = 0x30 + typedef struct { /* 0x00 */ s16 unk_00; /* 0x02 */ s16 unk_02; @@ -1501,18 +1513,12 @@ typedef struct { /* 0x0A */ s16 unk_0A; /* 0x0C */ s16 unk_0C; /* 0x0E */ UNK_TYPE1 unk_0E[0x02]; - /* 0x10 */ UNK_TYPE1 unk_10[0x2C]; - /* 0x3C */ UNK_TYPE1 unk_3C[0x01]; - /* 0x3D */ u8 unk_3D; - /* 0x3E */ UNK_TYPE1 unk_3E[0x02]; - /* 0x40 */ UNK_TYPE1 unk_40[0x2C]; - /* 0x6C */ UNK_TYPE1 unk_6C[0x01]; - /* 0x6D */ u8 unk_6D; - /* 0x6E */ UNK_TYPE1 unk_6E[0x02]; + /* 0x10 */ DbCameraUnkSubStruct unk_10; + /* 0x40 */ DbCameraUnkSubStruct unk_40; /* 0x70 */ UNK_PTR unk_70; /* 0x74 */ UNK_PTR unk_74; /* 0x78 */ UNK_PTR unk_78; /* 0x7C */ Camera* camera; -} struct_801F4D48; // size = 0x80 +} DbCameraUnkStruct; // size = 0x80 #endif diff --git a/include/z64actor.h b/include/z64actor.h index 7a7556ed00..ee73ae8afc 100644 --- a/include/z64actor.h +++ b/include/z64actor.h @@ -387,6 +387,18 @@ typedef struct ActorContext { /* 0x26C */ Input unk_26C; } ActorContext; // size = 0x284 +typedef enum { + /* 00 */ ACTOR_DRAW_DMGEFF_FIRE, + /* 01 */ ACTOR_DRAW_DMGEFF_BLUE_FIRE, + /* 10 */ ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX = 10, + /* 11 */ ACTOR_DRAW_DMGEFF_FROZEN_SFX, + /* 20 */ ACTOR_DRAW_DMGEFF_LIGHT_ORBS = 20, + /* 21 */ ACTOR_DRAW_DMGEFF_BLUE_LIGHT_ORBS, + /* 30 */ ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL = 30, + /* 31 */ ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_MEDIUM, + /* 32 */ ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_LARGE +} ActorDrawDamageEffectType; + typedef enum { /* 0x000 */ ACTOR_PLAYER, /* 0x001 */ ACTOR_EN_TEST, diff --git a/include/z64animation.h b/include/z64animation.h index 10b145d38a..58ddb34df3 100644 --- a/include/z64animation.h +++ b/include/z64animation.h @@ -1,5 +1,5 @@ -#ifndef _Z64_ANIMATION_H -#define _Z64_ANIMATION_H +#ifndef Z64_ANIMATION_H +#define Z64_ANIMATION_H #include "PR/ultratypes.h" #include "PR/gbi.h" @@ -28,7 +28,7 @@ typedef enum { } AnimationModes; typedef enum { - /* -1 */ ANIMTAPER_DECEL = -1, + /* -1 */ ANIMTAPER_DECEL = -1, /* 0 */ ANIMTAPER_NONE, /* 1 */ ANIMTAPER_ACCEL } AnimationTapers; @@ -49,14 +49,6 @@ typedef struct { /* 0x08 */ Gfx* dLists[2]; // Near and far } LodLimb; // size = 0x10 -typedef struct { - /* 0x00 */ Vec3s jointPos; // Root is position in model space, children are relative to parent - /* 0x06 */ u8 child; - /* 0x07 */ u8 sibling; - /* 0x08 */ s32 unk_8; // Type of data contained in segment - /* 0x0C */ void* segment; // Segment address of data. Currently unclear what. -} SkinLimb; // size = 0x10 - // Model has limbs with only rigid meshes typedef struct { /* 0x00 */ void** segment; @@ -195,7 +187,10 @@ typedef struct SkelAnime { /* 0x24 */ Vec3s* morphTable; // Table of values used to morph between animations /* 0x28 */ f32 morphWeight; // Weight of the current animation morph as a fraction in [0,1] /* 0x2C */ f32 morphRate; // Reciprocal of the number of frames in the morph - /* 0x30 */ s32 (*update)(); // Can be Loop, Partial loop, Play once, Morph, or Tapered morph. Link only has Loop, Play once, and Morph + /* 0x30 */ union { + s32 (*normal)(struct SkelAnime*);// Can be Loop, Partial loop, Play once, Morph, or Tapered morph + s32 (*link)(struct GlobalContext*, struct SkelAnime*); // Loop, Play once, and Morph + } update; /* 0x34 */ s8 initFlags; // Flags used when initializing Link's skeleton /* 0x35 */ u8 moveFlags; // Flags used for animations that move the actor in worldspace. /* 0x36 */ s16 prevRot; // Previous rotation in worldspace. @@ -279,43 +274,6 @@ typedef s32 (*OverrideCurveLimbDraw)(struct GlobalContext* globalCtx, SkelAnimeC typedef void (*PostCurveLimbDraw)(struct GlobalContext* globalCtx, SkelAnimeCurve* skelCuve, s32 limbIndex, struct Actor* actor); -// TODO the name of this struct is imported from OoT and cannot change until the ZAPD name also changes -typedef struct { - /* 0x000 */ u16 unk_0; - /* 0x002 */ s16 unk_2; - /* 0x004 */ s16 unk_4; - /* 0x006 */ s8 unk_6; - /* 0x007 */ s8 unk_7; - /* 0x008 */ s8 unk_8; - /* 0x009 */ u8 unk_9; -} Struct_800A57C0; // size = 0xA - -// TODO the name of this struct is imported from OoT and cannot change until the ZAPD name also changes -typedef struct { - /* 0x000 */ u8 unk_0; - /* 0x002 */ s16 x; - /* 0x004 */ s16 y; - /* 0x006 */ s16 z; - /* 0x008 */ u8 unk_8; -} Struct_800A598C_2; // size = 0xA - -// TODO the name of this struct is imported from OoT and cannot change until the ZAPD name also changes -typedef struct { - /* 0x000 */ u16 unk_0; - /* 0x002 */ u16 unk_2; - /* 0x004 */ u16 unk_4; - /* 0x008 */ Struct_800A57C0* unk_8; - /* 0x00C */ Struct_800A598C_2* unk_C; -} Struct_800A598C; // size = 0x10 - -// TODO the name of this struct is imported from OoT and cannot change until the ZAPD name also changes -typedef struct { - /* 0x000 */ u16 unk_0; - /* 0x002 */ u16 unk_2; - /* 0x004 */ Struct_800A598C* unk_4; - /* 0x008 */ Gfx* unk_8; -} Struct_800A5E28; // size = 0xC - typedef struct { /* 0x00 */ AnimationHeader* animation; /* 0x04 */ f32 playSpeed; @@ -341,4 +299,73 @@ typedef struct AnimationSpeedInfo { /* 0x0C */ f32 morphFrames; } AnimationSpeedInfo; // size = 0x10 +struct SkeletonInfo; + +typedef s32 (*UnkKeyframeCallback)(struct GlobalContext* globalCtx, struct SkeletonInfo* skeletonInfo, s32* arg2, Gfx** dList, + u8* arg4, void* arg5); + +// Keyframe limb? +typedef struct { + /* 0x00 */ Gfx* dList; + /* 0x04 */ u8 unk_4; + /* 0x05 */ u8 flags; + /* 0x06 */ Vec3s root; +} Struct_801BFA14_Arg1_Field4; // size = 0xC + +// Other limb type? +typedef struct { + /* 0x00 */ Gfx* dList; + /* 0x04 */ u8 unk_4; + /* 0x05 */ u8 flags; + /* 0x06 */ u8 unk_6; // transform limb draw index +} Struct_801BFA14_Arg1_Field4_2; // size = 0x8 + +typedef struct { + /* 0x00 */ u8 limbCount; + /* 0x01 */ u8 unk_1; // non-zero in object files, number of non-null-dlist limbs? + /* 0x04 */ union { + Struct_801BFA14_Arg1_Field4* unk_4; // arrays + Struct_801BFA14_Arg1_Field4_2* unk_4_2; + }; + /* 0x08 */ s16* unk_8; + /* 0x0C */ s16* unk_C; + /* 0x0C */ char unk_10[0x2]; + /* 0x12 */ s16 unk_12; +} Struct_801BFA14_Arg1; + +typedef struct { + /* 0x00 */ u16* unk_0; + /* 0x04 */ s16* unk_4; + /* 0x08 */ s16* unk_8; + /* 0x0C */ s16* unk_C; + /* 0x0C */ char unk_10[0x2]; + /* 0x12 */ s16 unk_12; +} SkeletonInfo_1C; + +typedef struct { + /* 0x00 */ f32 unk_0; + /* 0x04 */ f32 unk_4; + /* 0x08 */ f32 unk_8; + /* 0x0C */ f32 unk_C; + /* 0x10 */ f32 unk_10; + /* 0x14 */ s32 unk_14; +} FrameControl; + +// FlexKeyframeSkeleton ? +typedef struct SkeletonInfo { + /* 0x00 */ FrameControl frameCtrl; + /* 0x18 */ Struct_801BFA14_Arg1* unk_18; // array + /* 0x1C */ SkeletonInfo_1C* unk_1C; + /* 0x20 */ UnkKeyframeCallback* unk_20; // pointer to array of functions + /* 0x24 */ f32 unk_24; // duration? current time? + /* 0x28 */ Vec3s* frameData; // array of 3 Vec3s + /* 0x2C */ s16* unk_2C; +} SkeletonInfo; + +typedef s32 (*OverrideKeyframeDrawScaled)(struct GlobalContext* globalCtx, SkeletonInfo* skeletonInfo, s32 limbIndex, Gfx** dList, + u8* flags, struct Actor* actor, Vec3f* scale, Vec3s* rot, Vec3f* pos); + +typedef void (*PostKeyframeDrawScaled)(struct GlobalContext* globalCtx, SkeletonInfo* skeleton, s32 limbIndex, Gfx** dList, + u8* flags, struct Actor* actor, Vec3f* scale, Vec3s* rot, Vec3f* pos); + #endif diff --git a/include/z64audio.h b/include/z64audio.h index db43aad488..5dd78f73ad 100644 --- a/include/z64audio.h +++ b/include/z64audio.h @@ -32,7 +32,7 @@ typedef enum { /* 1 */ AUDIO_MODE_HEADSET, /* 2 */ AUDIO_MODE_UNK, /* 3 */ AUDIO_MODE_MONO, - /* 4 */ AUDIO_MODE_SURROUND, + /* 4 */ AUDIO_MODE_SURROUND } AudioSoundMode; typedef enum { @@ -49,11 +49,10 @@ typedef enum { typedef enum { /* 0 */ MEDIUM_RAM, - /* 1 */ MEDIUM_UNK1, + /* 1 */ MEDIUM_UNK, /* 2 */ MEDIUM_CART, /* 3 */ MEDIUM_DISK_DRIVE, - /* 4 */ MEDIUM_UNK4, - /* 5 */ MEDIUM_UNK5 + /* 5 */ MEDIUM_RAM_UNLOADED = 5 } SampleMedium; typedef enum { @@ -71,6 +70,14 @@ typedef enum { /* 2 */ SAMPLE_TABLE } SampleBankTableType; +typedef enum { + /* 0 */ CACHE_LOAD_PERMANENT, + /* 1 */ CACHE_LOAD_PERSISTENT, + /* 2 */ CACHE_LOAD_TEMPORARY, + /* 3 */ CACHE_LOAD_EITHER, + /* 4 */ CACHE_LOAD_EITHER_NOSYNC +} AudioCacheLoadType; + typedef enum { /* 0 */ CACHE_TEMPORARY, /* 1 */ CACHE_PERSISTENT, @@ -78,6 +85,15 @@ typedef enum { /* 3 */ CACHE_PERMANENT } AudioCacheType; +typedef enum { + /* 0 */ LOAD_STATUS_0, + /* 1 */ LOAD_STATUS_1, + /* 2 */ LOAD_STATUS_2, // Samples/Seqplayer + /* 3 */ LOAD_STATUS_3, // Sequences + /* 4 */ LOAD_STATUS_4, // SoundFonts + /* 5 */ LOAD_STATUS_5 // Permanent +} AudioLoadStatus; + typedef s32 (*DmaHandler)(OSPiHandle* handle, OSIoMesg* mb, s32 direction); struct Note; @@ -242,9 +258,9 @@ typedef struct { } SoundFont; // size = 0x14 typedef struct { - /* 0x00 */ u8* pc; + /* 0x00 */ u8* pc; // program counter /* 0x04 */ u8* stack[4]; - /* 0x14 */ u8 remLoopIters[4]; + /* 0x14 */ u8 remLoopIters[4]; // remaining loop iterations /* 0x18 */ u8 depth; /* 0x19 */ s8 value; } SeqScriptState; // size = 0x1C @@ -399,7 +415,7 @@ typedef struct SequenceChannel { /* 0x12 */ VibratoSubStruct vibrato; /* 0x20 */ u16 delay; /* 0x22 */ u16 unk_20; - /* 0x24 */ u16 unk_22; + /* 0x24 */ u16 unk_22; // Used for indexing data /* 0x26 */ s16 instOrWave; // either 0 (none), instrument index + 1, or // 0x80..0x83 for sawtooth/triangle/sine/square waves. /* 0x28 */ s16 transposition; @@ -623,32 +639,41 @@ typedef struct { /* 0x16 */ s16 lowPassFilterCutoffRight; } ReverbSettings; // size = 0x18 +/** + * The high-level audio specifications requested when initializing or resetting the audio heap. + * Most often resets during scene transitions, but will highly depend on game play. + */ typedef struct { - /* 0x00 */ u32 frequency; + /* 0x00 */ u32 samplingFreq; // Target sampling rate in Hz /* 0x04 */ u8 unk_04; /* 0x05 */ u8 numNotes; /* 0x06 */ u8 numSequencePlayers; /* 0x07 */ u8 unk_07[0x2]; // unused, set to zero /* 0x09 */ u8 numReverbs; - /* 0x0A */ u8 unk_0A[0x2]; /* 0x0C */ ReverbSettings* reverbSettings; /* 0x10 */ u16 sampleDmaBufSize1; /* 0x12 */ u16 sampleDmaBufSize2; /* 0x14 */ u16 unk_14; - /* 0x18 */ u32 persistentSeqMem; - /* 0x1C */ u32 persistentFontMem; - /* 0x20 */ u32 persistentSampleMem; - /* 0x24 */ u32 temporarySeqMem; - /* 0x28 */ u32 temporaryFontMem; - /* 0x2C */ u32 temporarySampleMem; - /* 0x30 */ s32 persistentSampleCacheMem; - /* 0x34 */ s32 temporarySampleCacheMem; + /* 0x18 */ size_t persistentSeqCacheSize; // size of cache on audio pool to store sequences persistently + /* 0x1C */ size_t persistentFontCacheSize; // size of cache on audio pool to store soundFonts persistently + /* 0x20 */ size_t persistentSampleBankCacheSize; // size of cache on audio pool to store entire sample banks persistently + /* 0x24 */ size_t temporarySeqCacheSize; // size of cache on audio pool to store sequences temporarily + /* 0x28 */ size_t temporaryFontCacheSize; // size of cache on audio pool to store soundFonts temporarily + /* 0x2C */ size_t temporarySampleBankCacheSize; // size of cache on audio pool to store entire sample banks temporarily + /* 0x30 */ size_t persistentSampleCacheSize; // size of cache on audio pool to store individual samples persistently + /* 0x34 */ size_t temporarySampleCacheSize; // size of cache on audio pool to store individual samples temporarily } AudioSpec; // size = 0x38 +/** + * The audio buffer stores the fully processed digital audio before it is sent to the audio interface (AI), then to the + * digital-analog converter (DAC), then to play on the speakers. The audio buffer is written to by the rsp after + * processing audio commands, and the audio buffer is read by AI which sends the data to the DAC. + * This struct parameterizes that buffer. + */ typedef struct { /* 0x00 */ s16 specUnk4; - /* 0x02 */ u16 frequency; - /* 0x04 */ u16 aiFrequency; + /* 0x02 */ u16 samplingFreq; // Target sampling rate in Hz + /* 0x04 */ u16 aiSamplingFreq; // True sampling rate set to the audio interface (AI) for the audio digital-analog converter (DAC) /* 0x06 */ s16 samplesPerFrameTarget; /* 0x08 */ s16 maxAiBufferLength; /* 0x0A */ s16 minAiBufferLength; @@ -663,20 +688,29 @@ typedef struct { /* 0x24 */ f32 unk_24; } AudioBufferParameters; // size = 0x28 +/** + * Meta-data associated with a pool (contain withing the Audio Heap) + */ typedef struct { - /* 0x0 */ u8* start; - /* 0x4 */ u8* cur; - /* 0x8 */ s32 size; - /* 0xC */ s32 count; + /* 0x0 */ u8* startAddr; // start addr of the pool + /* 0x4 */ u8* curAddr; // address of the next available memory for allocation + /* 0x8 */ size_t size; // size of the pool + /* 0xC */ s32 count; // number of entries allocated to the pool } AudioAllocPool; // size = 0x10 +/** + * Audio cache entry data to store a single entry containing either a sequence, soundfont, or entire sample banks + */ typedef struct { - /* 0x0 */ u8* ptr; - /* 0x4 */ u32 size; + /* 0x0 */ u8* addr; + /* 0x4 */ size_t size; /* 0x8 */ s16 tableType; /* 0xA */ s16 id; } AudioCacheEntry; // size = 0xC +/** + * Audio cache entry data to store a single entry containing an individual sample + */ typedef struct { /* 0x00 */ s8 inUse; /* 0x01 */ s8 origMedium; @@ -684,13 +718,16 @@ typedef struct { /* 0x03 */ char unk_03[0x5]; /* 0x08 */ u8* allocatedAddr; /* 0x0C */ void* sampleAddr; - /* 0x10 */ u32 size; + /* 0x10 */ size_t size; } SampleCacheEntry; // size = 0x14 +/** + * Audio cache entry data to store individual samples + */ typedef struct { /* 0x000 */ AudioAllocPool pool; /* 0x010 */ SampleCacheEntry entries[128]; - /* 0xA10 */ s32 size; + /* 0xA10 */ s32 numEntries; } AudioSampleCache; // size = 0xA14 typedef struct { @@ -712,22 +749,21 @@ typedef struct { } AudioCache; // size = 0x110 typedef struct { - /* 0x0 */ u32 wantPersistent; - /* 0x4 */ u32 wantTemporary; -} AudioPoolSplit2; // size = 0x8 + /* 0x0 */ size_t persistentCommonPoolSize; + /* 0x4 */ size_t temporaryCommonPoolSize; +} AudioCachePoolSplit; // size = 0x8 typedef struct { - /* 0x0 */ u32 wantSeq; - /* 0x4 */ u32 wantFont; - /* 0x8 */ u32 wantSample; -} AudioPoolSplit3; // size = 0xC + /* 0x0 */ size_t seqCacheSize; + /* 0x4 */ size_t fontCacheSize; + /* 0x8 */ size_t sampleBankCacheSize; +} AudioCommonPoolSplit; // size = 0xC typedef struct { - /* 0x0 */ u32 wantSeq; - /* 0x4 */ u32 wantFont; - /* 0x8 */ u32 wantSample; - /* 0xC */ u32 wantCustom; -} AudioPoolSplit4; // size = 0x10 + /* 0x0 */ size_t miscPoolSize; + /* 0x4 */ u32 unkSizes[2]; + /* 0xC */ size_t cachePoolSize; +} AudioSessionPoolSplit; // size = 0x10 typedef struct { /* 0x00 */ u32 endAndMediumKey; @@ -763,10 +799,10 @@ typedef struct { /* 0x01 */ s8 delay; /* 0x02 */ s8 medium; /* 0x04 */ u8* ramAddr; - /* 0x08 */ u32 curDevAddr; + /* 0x08 */ uintptr_t curDevAddr; /* 0x0C */ u8* curRamAddr; - /* 0x10 */ u32 bytesRemaining; - /* 0x14 */ u32 chunkSize; + /* 0x10 */ size_t bytesRemaining; + /* 0x14 */ size_t chunkSize; /* 0x18 */ s32 unkMediumParam; /* 0x1C */ u32 retMsg; /* 0x20 */ OSMesgQueue* retQueue; @@ -780,12 +816,12 @@ typedef struct { /* 0x01 */ u8 seqOrFontId; /* 0x02 */ u16 instId; /* 0x04 */ s32 unkMediumParam; - /* 0x08 */ s32 curDevAddr; + /* 0x08 */ uintptr_t curDevAddr; /* 0x0C */ u8* curRamAddr; /* 0x10 */ u8* ramAddr; /* 0x14 */ s32 status; - /* 0x18 */ s32 bytesRemaining; - /* 0x1C */ s8* isDone; + /* 0x18 */ size_t bytesRemaining; + /* 0x1C */ s8* isDone; // TODO: rename in OoT and sync up here. This is an external status while (s32 status) is an internal status /* 0x20 */ SoundFontSample sample; /* 0x30 */ OSMesgQueue msgqueue; /* 0x48 */ OSMesg msg; @@ -793,8 +829,8 @@ typedef struct { } AudioSlowLoad; // size = 0x64 typedef struct { - /* 0x00 */ u32 romAddr; - /* 0x04 */ u32 size; + /* 0x00 */ uintptr_t romAddr; + /* 0x04 */ size_t size; /* 0x08 */ s8 medium; /* 0x09 */ s8 cachePolicy; /* 0x0A */ s16 shortData1; @@ -805,7 +841,7 @@ typedef struct { typedef struct { /* 0x00 */ s16 numEntries; /* 0x02 */ s16 unkMediumParam; - /* 0x04 */ u32 romAddr; + /* 0x04 */ uintptr_t romAddr; /* 0x08 */ char pad[0x8]; /* 0x10 */ AudioTableEntry entries[1]; // (dynamic size) } AudioTable; // size >= 0x20 @@ -819,18 +855,18 @@ typedef struct { typedef struct { /* 0x00 */ u8* ramAddr; - /* 0x04 */ u32 devAddr; + /* 0x04 */ uintptr_t devAddr; /* 0x08 */ u16 sizeUnused; /* 0x0A */ u16 size; /* 0x0C */ u8 unused; /* 0x0D */ u8 reuseIndex; // position in sSampleDmaReuseQueue1/2, if ttl == 0 - /* 0x0E */ u8 ttl; // duration after which the DMA can be discarded + /* 0x0E */ u8 ttl; // Time To Live: duration after which the DMA can be discarded } SampleDma; // size = 0x10 typedef struct { /* 0x0000 */ char unk_0000; /* 0x0001 */ s8 numSynthesisReverbs; - /* 0x0002 */ u16 unk_2; + /* 0x0002 */ u16 unk_2; // reads from audio spec unk_14, never used, always set to 0x7FFF /* 0x0004 */ u16 unk_4; /* 0x0006 */ char unk_0006[0xA]; /* 0x0010 */ s16* curLoadedBook; @@ -862,13 +898,13 @@ typedef struct { /* 0x263C */ SampleDma* sampleDmas; /* 0x2640 */ u32 sampleDmaCount; /* 0x2644 */ u32 sampleDmaListSize1; - /* 0x2648 */ s32 unused2628; + /* 0x2648 */ s32 unused2648; /* 0x264C */ u8 sampleDmaReuseQueue1[0x100]; // read pos <= write pos, wrapping mod 256 /* 0x274C */ u8 sampleDmaReuseQueue2[0x100]; - /* 0x284C */ u8 sampleDmaReuseQueue1RdPos; - /* 0x284D */ u8 sampleDmaReuseQueue2RdPos; - /* 0x284E */ u8 sampleDmaReuseQueue1WrPos; - /* 0x284F */ u8 sampleDmaReuseQueue2WrPos; + /* 0x284C */ u8 sampleDmaReuseQueue1RdPos; // Read position for dma 1 + /* 0x284D */ u8 sampleDmaReuseQueue2RdPos; // Read position for dma 2 + /* 0x284E */ u8 sampleDmaReuseQueue1WrPos; // Write position for dma 1 + /* 0x284F */ u8 sampleDmaReuseQueue2WrPos; // Write position for dma 2 /* 0x2850 */ AudioTable* sequenceTable; /* 0x2854 */ AudioTable* soundFontTable; /* 0x2858 */ AudioTable* sampleBankTable; @@ -886,52 +922,52 @@ typedef struct { /* 0x28B8 */ s32 numNotes; /* 0x2898 */ s16 tempoInternalToExternal; /* 0x28BE */ s8 soundMode; - /* 0x28C0 */ s32 totalTaskCnt; + /* 0x28C0 */ s32 totalTaskCount; // The total number of times the top-level function on the audio thread is run since the last audio reset /* 0x28C4 */ s32 curAudioFrameDmaCount; - /* 0x28C8 */ s32 rspTaskIdx; - /* 0x28CC */ s32 curAIBufIdx; - /* 0x28AC */ Acmd* abiCmdBufs[2]; + /* 0x28C8 */ s32 rspTaskIndex; + /* 0x28CC */ s32 curAiBuffferIndex; + /* 0x28AC */ Acmd* abiCmdBufs[2]; // Pointer to audio heap where the audio binary interface command lists are stored. Two lists that alternative every frame /* 0x28B4 */ Acmd* curAbiCmdBuf; - /* 0x28DC */ AudioTask* currTask; + /* 0x28DC */ AudioTask* curTask; /* 0x28C0 */ AudioTask rspTask[2]; /* 0x2980 */ f32 unk_2960; /* 0x2984*/ s32 refreshRate; - /* 0x2988 */ s16* aiBuffers[3]; - /* 0x2994 */ s16 aiBufLengths[3]; + /* 0x2988 */ s16* aiBuffers[3]; // Pointers to the audio buffer allocated on the initPool contained in the audio heap. Stores fully processed digital audio before transferring to the audio interface (AI) + /* 0x2994 */ s16 aiBufLengths[3]; // Number of bytes to transfer to the audio interface buffer /* 0x299C */ u32 audioRandom; /* 0x29A0 */ s32 audioErrorFlags; /* 0x29A4 */ volatile u32 resetTimer; /* 0x29A8 */ u32 (*unk_29A8[4])(s8 value, SequenceChannel* channel); /* 0x29B8 */ s8 unk_29B8; /* 0x29BC */ s32 unk_29BC; // sMaxAbiCmdCnt - /* 0x29C0 */ AudioAllocPool audioSessionPool; - /* 0x29D0 */ AudioAllocPool externalPool; - /* 0x29E0 */ AudioAllocPool audioInitPool; - /* 0x29F0 */ AudioAllocPool notesAndBuffersPool; + /* 0x29C0 */ AudioAllocPool audioSessionPool; // A sub-pool to main pool, contains all sub-pools and data that changes every audio reset + /* 0x29D0 */ AudioAllocPool externalPool; // pool allocated on an external device. Never used in game + /* 0x29E0 */ AudioAllocPool audioInitPool; // A sub-pool to the main pool, contains all sub-pools and data that persists every audio reset + /* 0x29F0 */ AudioAllocPool miscPool; // A sub-pool to the session pool, /* 0x2A00 */ char unk_29D0[0x20]; // probably two unused pools - /* 0x2A20 */ AudioAllocPool cachePool; - /* 0x2A30 */ AudioAllocPool persistentCommonPool; - /* 0x2A40 */ AudioAllocPool temporaryCommonPool; - /* 0x2A50 */ AudioCache seqCache; - /* 0x2B60 */ AudioCache fontCache; - /* 0x2C70 */ AudioCache sampleBankCache; - /* 0x2D80 */ AudioAllocPool permanentPool; - /* 0x2D90 */ AudioCacheEntry permanentCache[32]; - /* 0x3690 */ AudioSampleCache persistentSampleCache; - /* 0x40A4 */ AudioSampleCache temporarySampleCache; - /* 0x4338 */ AudioPoolSplit4 sessionPoolSplit; - /* 0x4348 */ AudioPoolSplit2 cachePoolSplit; - /* 0x4350 */ AudioPoolSplit3 persistentCommonPoolSplit; - /* 0x435C */ AudioPoolSplit3 temporaryCommonPoolSplit; + /* 0x2A20 */ AudioAllocPool cachePool; // The common pool for all cache entries + /* 0x2A30 */ AudioAllocPool persistentCommonPool; // A sub-pool to the cache pool, contains all caches for data stored persistently + /* 0x2A40 */ AudioAllocPool temporaryCommonPool; // A sub-pool to the cache pool, contains all caches for data stored temporarily + /* 0x2A50 */ AudioCache seqCache; // Cache to store sequences + /* 0x2B60 */ AudioCache fontCache; // Cache to store soundFonts + /* 0x2C70 */ AudioCache sampleBankCache; // Cache for loading entire sample banks + /* 0x2D80 */ AudioAllocPool permanentPool; // Pool to stores audio data that is always loaded in. Primarily used for sfxs + /* 0x2D90 */ AudioCacheEntry permanentEntries[32]; // indificual entries to the permanent pool + /* 0x3690 */ AudioSampleCache persistentSampleCache; // Stores individual samples persistently + /* 0x40A4 */ AudioSampleCache temporarySampleCache; // Stores individual samples temporarily + /* 0x4338 */ AudioSessionPoolSplit sessionPoolSplit; // splits session pool into the cache pool and misc pool + /* 0x4348 */ AudioCachePoolSplit cachePoolSplit; // splits cache pool into the persistent & temporary common pools + /* 0x4350 */ AudioCommonPoolSplit persistentCommonPoolSplit; // splits persistent common pool into caches for sequences, soundFonts, sample banks + /* 0x435C */ AudioCommonPoolSplit temporaryCommonPoolSplit; // splits temporary common pool into caches for sequences, soundFonts, sample banks /* 0x4368 */ u8 sampleFontLoadStatus[0x30]; /* 0x4398 */ u8 fontLoadStatus[0x30]; /* 0x43C8 */ u8 seqLoadStatus[0x80]; /* 0x4448 */ volatile u8 resetStatus; /* 0x4449 */ u8 audioResetSpecIdToLoad; /* 0x444C */ s32 audioResetFadeOutFramesLeft; - /* 0x4450 */ f32* unk_3520; + /* 0x4450 */ f32* unk_3520; // fadeOutVelocities for ADSR /* 0x4454 */ u8* audioHeap; - /* 0x4458 */ u32 audioHeapSize; + /* 0x4458 */ size_t audioHeapSize; /* 0x445C */ Note* notes; /* 0x4460 */ SequencePlayer seqPlayers[5]; /* 0x4B40 */ SequenceLayer sequenceLayers[80]; @@ -939,11 +975,10 @@ typedef struct { /* 0x7924 */ s32 noteSubEuOffset; /* 0x7928 */ AudioListItem layerFreeList; /* 0x7938 */ NotePool noteFreeLists; - /* 0x7978 */ u8 cmdWrPos; - /* 0x7979 */ u8 cmdRdPos; + /* 0x7978 */ u8 cmdWritePos; + /* 0x7979 */ u8 cmdReadPos; /* 0x797A */ u8 cmdQueueFinished; - /* 0x797C */ u16 unk_5BDC[4]; - /* 0x7984 */ char unk_7984[4]; + /* 0x797C */ u16 activeChannelsFlags[5]; // bitwise flag for 16 channels. Only channels with bit turned on will be processed /* 0x7988 */ OSMesgQueue* audioResetQueueP; /* 0x798C */ OSMesgQueue* taskStartQueueP; /* 0x7990 */ OSMesgQueue* cmdProcQueueP; @@ -953,7 +988,7 @@ typedef struct { /* 0x79DC */ OSMesg taskStartMsgs[1]; /* 0x79E0 */ OSMesg audioResetMesgs[1]; /* 0x79E4 */ OSMesg cmdProcMsgs[4]; - /* 0x79F4 */ AudioCmd cmdBuf[0x100]; + /* 0x79F4 */ AudioCmd cmdBuf[0x100]; // Audio commands used to transfer audio requests from the graph thread to the audio thread /* 0x81F4 */ char unk_81F4[4]; } AudioContext; // size = 0x81F8 @@ -972,9 +1007,9 @@ typedef struct { } NoteSubAttributes; // size = 0x1A typedef struct { - /* 0x0 */ u32 heapSize; - /* 0x4 */ u32 initPoolSize; - /* 0x8 */ u32 permanentPoolSize; + /* 0x0 */ size_t heapSize; // total number of bytes allocated to the audio heap. Must be <= the size of `gAudioHeap` (ideally about the same size) + /* 0x4 */ size_t mainPoolSplitSize; // The entire audio heap is split into two pools. + /* 0x8 */ size_t permanentPoolSize; } AudioContextInitSizes; // size = 0xC typedef struct { diff --git a/include/z64effect.h b/include/z64effect.h index d9211ef5e1..0b848a478f 100644 --- a/include/z64effect.h +++ b/include/z64effect.h @@ -257,6 +257,7 @@ typedef struct { /* 0x18 */ u8 unk18; // Always 1? } EffectSsOverlay; // size = 0x1C +//! TODO: Review reuse of vec/gfx/actor fields across all effects typedef struct EffectSs { /* 0x00 */ Vec3f pos; /* 0x0C */ Vec3f velocity; diff --git a/include/z64item.h b/include/z64item.h index 7d637b2915..31a0ec8fc4 100644 --- a/include/z64item.h +++ b/include/z64item.h @@ -31,7 +31,7 @@ typedef enum { /* 0x05 */ QUEST_SWORD, /* 0x06 */ QUEST_SONG_SONATA, /* 0x07 */ QUEST_SONG_LULLABY, - /* 0x08 */ QUEST_SONG_NOVA, + /* 0x08 */ QUEST_SONG_BOSSA_NOVA, /* 0x09 */ QUEST_SONG_ELEGY, /* 0x0A */ QUEST_SONG_OATH, /* 0x0B */ QUEST_SONG_SARIA, @@ -261,6 +261,7 @@ typedef enum { /* 0xA1 */ ITEM_GOLD_DUST_2, /* 0xA2 */ ITEM_HYLIAN_LOACH_2, /* 0xA3 */ ITEM_SEA_HORSE_CAUGHT, + /* 0xFD */ ITEM_UNK_FD = 0xFD, /* 0xFF */ ITEM_NONE = 0xFF } ItemID; @@ -381,7 +382,8 @@ typedef enum { /* 0x31 */ GID_POTION_RED, /* 0x32 */ GID_POTION_BLUE, /* 0x33 */ GID_SHIELD_MIRROR, - /* 0x3A */ GID_3A = 0x3A, + /* 0x39 */ GID_39 = 0x39, + /* 0x3A */ GID_3A, /* 0x3B */ GID_FAIRY, /* 0x3E */ GID_3E = 0x3E, /* 0x44 */ GID_44 = 0x44, @@ -393,7 +395,7 @@ typedef enum { /* 0x6A */ GID_6A = 0x6A, /* 0x6B */ GID_6B, /* 0x70 */ GID_70 = 0x70, - /* 0x71 */ GID_71, + /* 0x71 */ GID_71 } GetItemDrawID; // TODO: fill diff --git a/include/z64light.h b/include/z64light.h index 8e8508579e..0c90be7134 100644 --- a/include/z64light.h +++ b/include/z64light.h @@ -57,18 +57,12 @@ typedef struct Lights { /* 0x08 */ Lightsn l; } Lights; // size = 0x80 -typedef struct LightInfoPositional { - /* 0x0 */ u8 type; - /* 0x2 */ LightPoint params; -} LightInfoPositional; // size = 0xE - typedef struct LightNode { /* 0x0 */ LightInfo* info; /* 0x4 */ struct LightNode* prev; /* 0x8 */ struct LightNode* next; } LightNode; // size = 0xC -// TODO move LightsBuffer to .c file once .bss has been split #define LIGHTS_BUFFER_SIZE 32 typedef struct LightsBuffer { diff --git a/include/z64math.h b/include/z64math.h index dff6699766..78e1743ece 100644 --- a/include/z64math.h +++ b/include/z64math.h @@ -5,9 +5,14 @@ #define VEC_SET(V,X,Y,Z) V.x=X;V.y=Y;V.z=Z +typedef struct { + /* 0x00 */ s16 x; + /* 0x02 */ s16 z; +} Vec2s; // size = 0x04 + typedef struct { /* 0x00 */ f32 x; - /* 0x04 */ f32 y; + /* 0x04 */ f32 z; } Vec2f; // size = 0x08 typedef struct { @@ -44,6 +49,10 @@ typedef struct { /* 0x0C */ f32 radius; } Spheref; // size = 0x10 +/* +The plane paramaters are of form `ax + by + cz + d = 0` +where `(a,b,c)` is the plane's normal vector and d is the originDist + */ typedef struct { /* 0x00 */ Vec3f normal; /* 0x0C */ f32 originDist; diff --git a/include/z64ocarina.h b/include/z64ocarina.h index cc1662fbd7..56ab483127 100644 --- a/include/z64ocarina.h +++ b/include/z64ocarina.h @@ -39,7 +39,7 @@ typedef enum { /* 3 */ OCARINA_BTN_C_LEFT, /* 4 */ OCARINA_BTN_C_UP, /* -1 */ OCARINA_BTN_INVALID = 0xFF -} OcarinaButtonIdx; +} OcarinaButtonIndex; // Uses scientific pitch notation relative to middle C // https://en.wikipedia.org/wiki/Scientific_pitch_notation @@ -81,7 +81,7 @@ typedef enum { /* 13 */ OCARINA_INSTRUMENT_PIANO, /* 14 */ OCARINA_INSTRUMENT_BASS_GUITAR, /* 15 */ OCARINA_INSTRUMENT_BABY_SINGING, - /* 16 */ OCARINA_INSTRUMENT_AMPLIFIED_GUITAR, // Related to (gSaveContext.weekEventReg[41] & 0x20) + /* 16 */ OCARINA_INSTRUMENT_AMPLIFIED_GUITAR // Related to (gSaveContext.weekEventReg[41] & 0x20) } OcarinaInstrumentId; typedef enum { @@ -93,7 +93,7 @@ typedef enum { /** * BFlat4Flag Note: - * Flag for resolving whether (noteIdx = NOTE_BFLAT4) + * Flag for resolving whether (pitch = OCARINA_PITCH_BFLAT4) * gets mapped to either C_RIGHT and C_LEFT * * This is required as C_RIGHT and C_LEFT are the only notes @@ -103,21 +103,21 @@ typedef enum { */ typedef struct { - /* 0x0 */ u8 noteIdx; // number of semitones above middle C + /* 0x0 */ u8 pitch; // number of semitones above middle C /* 0x2 */ u16 length; // number of frames the note is sustained /* 0x4 */ u8 volume; /* 0x5 */ u8 vibrato; - /* 0x6 */ s8 bend; // frequency multiplicative offset from the pitch defined by noteIdx + /* 0x6 */ s8 bend; // frequency multiplicative offset from the pitch defined by pitch /* 0x7 */ u8 BFlat4Flag; // See note above } OcarinaNote; // size = 0x8 typedef struct { /* 0x0 */ u8 numButtons; - /* 0x1 */ u8 buttonIdx[8]; + /* 0x1 */ u8 buttonIndex[8]; } OcarinaSongButtons; // size = 0x9 typedef struct { - /* 0x0 */ u8 buttonIdx; + /* 0x0 */ u8 buttonIndex; /* 0x1 */ u8 state; // original name: "status" /* 0x2 */ u8 pos; // original name: "locate" } OcarinaStaff; // size = 0x3 diff --git a/include/z64save.h b/include/z64save.h index 31232b56c4..2595b3c275 100644 --- a/include/z64save.h +++ b/include/z64save.h @@ -1,99 +1,142 @@ -#ifndef _Z64SAVE_H_ -#define _Z64SAVE_H_ +#ifndef Z64SAVE_H +#define Z64SAVE_H #include "ultra64.h" #include "z64math.h" #include "os.h" -typedef struct { - /* 0x00 */ u8 buttonItems[4][4]; - /* 0x10 */ u8 cButtonSlots[4][4]; - /* 0x20 */ u16 equipment; -} ItemEquips; // size = 0x0A +struct GameState; +struct GlobalContext; +struct FileChooseContext; -typedef struct { - /* 0x00 */ u8 items[24]; - /* 0x18 */ u8 masks[24]; - /* 0x30 */ s8 ammo[24]; - /* 0x48 */ u32 upgrades; // some bits are wallet upgrades - /* 0x4C */ u32 questItems; - /* 0x50 */ u8 dungeonItems[10]; - /* 0x5A */ s8 dungeonKeys[10]; - /* 0x64 */ s8 strayFairies[10]; // "orange_fairy" - /* 0x6E */ char dekuPlaygroundPlayerName[3][8]; // Stores playerName (8 char) over (3 days) when getting a new high score. original name: degnuts_memory_name +// TODO: properly name DOWN, RETURN and TOP +typedef enum RespawnMode { + /* 0 */ RESTART_MODE_DOWN, // "RESTART_MODE_DOWN" + /* 1 */ RESTART_MODE_RETURN, // "RESTART_MODE_RETURN" + /* 2 */ RESTART_MODE_TOP, // "RESTART_MODE_TOP" + /* 3 */ RESPAWN_MODE_UNK_3, // Maybe related to grottos + /* 4 */ RESPAWN_MODE_GORON, // "RESTART_MODE_GORON" + /* 5 */ RESPAWN_MODE_ZORA, // "RESTART_MODE_ZORA" + /* 6 */ RESPAWN_MODE_DEKU, // "RESTART_MODE_NUTS" + /* 7 */ RESPAWN_MODE_HUMAN, // "RESTART_MODE_CHILD" + /* 8 */ RESPAWN_MODE_MAX +} RespawnMode; + +#define SAVE_BUFFER_SIZE 0x4000 + +typedef struct SramContext { + /* 0x00 */ u8* readBuff; + /* 0x04 */ u8 *saveBuf; + /* 0x08 */ char unk_08[4]; + /* 0x0C */ s16 status; + /* 0x10 */ u32 curPage; + /* 0x14 */ u32 numPages; + /* 0x18 */ OSTime unk_18; + /* 0x20 */ s16 unk_20; + /* 0x22 */ s16 unk_22; + /* 0x24 */ s16 unk_24; +} SramContext; // size = 0x28 + +typedef struct ItemEquips { + /* 0x00 */ u8 buttonItems[4][4]; // "register_item" + /* 0x10 */ u8 cButtonSlots[4][4]; // "register_item_pt" + /* 0x20 */ u16 equipment; +} ItemEquips; // size = 0x22 + +typedef struct Inventory { + /* 0x00 */ u8 items[48]; // "item_register", first 24 elements are normal items and the other 24 are masks + /* 0x30 */ s8 ammo[24]; // "item_count" + /* 0x48 */ u32 upgrades; // "non_equip_register" some bits are wallet upgrades + /* 0x4C */ u32 questItems; // "collect_register" + /* 0x50 */ u8 dungeonItems[10]; // "key_compass_map" + /* 0x5A */ s8 dungeonKeys[10]; // "key_register" + /* 0x64 */ s8 strayFairies[10]; // "orange_fairy" + /* 0x6E */ char dekuPlaygroundPlayerName[3][8]; // "degnuts_memory_name" Stores playerName (8 char) over (3 days) when getting a new high score } Inventory; // size = 0x88 -typedef struct { - /* 0x00 */ s16 scene; - /* 0x02 */ Vec3s pos; - /* 0x08 */ s16 angle; +typedef struct HorseData { + /* 0x00 */ s16 scene; // "spot_no" + /* 0x02 */ Vec3s pos; // "horse_x", "horse_y" and "horse_z" + /* 0x08 */ s16 yaw; // "horse_a" } HorseData; // size = 0x0A -typedef struct { - /* 0x0 */ Vec3f pos; - /* 0xC */ s16 yaw; - /* 0xE */ s16 playerParams; +typedef struct RespawnData { + /* 0x00 */ Vec3f pos; + /* 0x0C */ s16 yaw; + /* 0x0E */ s16 playerParams; /* 0x10 */ u16 entranceIndex; /* 0x12 */ u8 roomIndex; /* 0x13 */ s8 data; - /* 0x14 */ u32 tempSwchFlags; + /* 0x14 */ u32 tempSwitchFlags; /* 0x18 */ u32 unk_18; /* 0x1C */ u32 tempCollectFlags; } RespawnData; // size = 0x20 -typedef struct { +typedef struct PermanentSceneFlags { /* 0x00 */ u32 chest; - /* 0x04 */ u32 swch0; - /* 0x08 */ u32 swch1; + /* 0x04 */ u32 switch0; + /* 0x08 */ u32 switch1; /* 0x0C */ u32 clearedRoom; /* 0x10 */ u32 collectible; /* 0x14 */ u32 unk_14; /* 0x18 */ u32 unk_18; } PermanentSceneFlags; // size = 0x1C -typedef struct { +typedef struct CycleSceneFlags { /* 0x00 */ u32 chest; - /* 0x04 */ u32 swch0; - /* 0x08 */ u32 swch1; + /* 0x04 */ u32 switch0; + /* 0x08 */ u32 switch1; /* 0x0C */ u32 clearedRoom; /* 0x10 */ u32 collectible; } CycleSceneFlags; // size = 0x14 -typedef struct { - /* 0x0000 */ u32 entranceIndex; // "scene_no" - /* 0x0004 */ u8 equippedMask; // "player_mask" - /* 0x0005 */ u8 unk_05; // "opening_flag" +typedef struct SaveOptions { + /* 0x00 */ u16 optionId; // "option_id" + /* 0x02 */ u8 language; // "j_n" + /* 0x03 */ s8 audioSetting; // "s_sound" + /* 0x04 */ u8 languageSetting; // "language" + /* 0x05 */ u8 zTargetSetting; // "z_attention", 0: Switch; 1: Hold +} SaveOptions; // size = 0x06 + +typedef struct SavePlayerData { + /* 0x0000 */ char newf[6]; // "newf" Will always be "ZELDA3 for a valid save + /* 0x0006 */ u16 deaths; // "savect" + /* 0x0008 */ char playerName[8]; // "player_name" + /* 0x0010 */ s16 healthCapacity; // "max_life" + /* 0x0012 */ s16 health; // "now_life" + /* 0x0014 */ s8 magicLevel; // "magic_max" + /* 0x0015 */ s8 magic; // "magic_now" + /* 0x0016 */ s16 rupees; // "lupy_count" + /* 0x0018 */ u16 swordHealth; // "long_sword_hp" + /* 0x001A */ u16 tatlTimer; // "navi_timer" + /* 0x001C */ u8 magicAcquired; // "magic_mode" + /* 0x001D */ u8 doubleMagic; // "magic_ability" + /* 0x001E */ u8 doubleDefense; // "life_ability" + /* 0x001F */ u8 unk_1F; // "ocarina_round" + /* 0x0020 */ u8 unk_20; // "first_memory" + /* 0x0022 */ u16 owlActivationFlags; // "memory_warp_point" + /* 0x0024 */ u8 unk_24; // "last_warp_pt" + /* 0x0026 */ s16 savedSceneNum; // "scene_data_ID" +} SavePlayerData; // size = 0x28 + +typedef struct Save { + /* 0x0000 */ u32 entranceIndex; // "scene_no" + /* 0x0004 */ u8 equippedMask; // "player_mask" + /* 0x0005 */ u8 isFirstCycle; // "opening_flag" /* 0x0006 */ u8 unk_06; - /* 0x0007 */ u8 linkAge; // "link_age" - /* 0x0008 */ s32 cutscene; // "day_time" - /* 0x000C */ u16 time; // "zelda_time" + /* 0x0007 */ u8 linkAge; // "link_age" + /* 0x0008 */ s32 cutscene; // "day_time" + /* 0x000C */ u16 time; // "zelda_time" /* 0x000E */ u16 owlSaveLocation; - /* 0x0010 */ s32 isNight; // "asahiru_fg" - /* 0x0014 */ u32 unk_14; // "change_zelda_time" - /* 0x0018 */ s32 day; // "totalday" - /* 0x001C */ u32 daysElapsed; // "eventday" - /* 0x0020 */ u8 playerForm; // "player_character" - /* 0x0021 */ u8 snowheadCleared; // "spring_flag" - /* 0x0022 */ u8 hasTatl; // "bell_flag" + /* 0x0010 */ s32 isNight; // "asahiru_fg" + /* 0x0014 */ u32 daySpeed; // "change_zelda_time" + /* 0x0018 */ s32 day; // "totalday" + /* 0x001C */ u32 daysElapsed; // "eventday" + /* 0x0020 */ u8 playerForm; // "player_character" + /* 0x0021 */ u8 snowheadCleared; // "spring_flag" + /* 0x0022 */ u8 hasTatl; // "bell_flag" /* 0x0023 */ u8 isOwlSave; - /* 0x0024 */ char newf[6]; // Will always be "ZELDA3" for a valid save - /* 0x002B */ u16 deaths; // "savect" - /* 0x002C */ char playerName[8]; // "player_name" - /* 0x0034 */ s16 healthCapacity; // "max_life" - /* 0x0036 */ s16 health; // "now_life" - /* 0x0038 */ s8 magicLevel; // "magic_max" - /* 0x0039 */ s8 magic; // "magic_now" - /* 0x003A */ s16 rupees; // "lupy_count" - /* 0x003C */ u16 swordHealth; // "long_sword_hp" - /* 0x003E */ u16 tatlTimer; // "navi_timer" - /* 0x0040 */ u8 magicAcquired; // "magic_mode" - /* 0x0041 */ u8 doubleMagic; // "magic_ability" - /* 0x0042 */ u8 doubleDefense; // "life_ability" - /* 0x0043 */ u8 unk_43; // "ocarina_round" - /* 0x0044 */ u8 unk_44; // "first_memory" - /* 0x0046 */ u16 owlActivationFlags; // "memory_warp_point" - /* 0x0048 */ u8 unk_48; // "last_warp_pt" - /* 0x004A */ s16 savedSceneNum; // "scene_data_ID" + /* 0x0024 */ SavePlayerData playerData; /* 0x004C */ ItemEquips equips; /* 0x0070 */ Inventory inventory; /* 0x00F8 */ PermanentSceneFlags permanentSceneFlags[120]; @@ -103,144 +146,167 @@ typedef struct { /* 0x0E7C */ u32 pictoFlags1; /* 0x0E80 */ u32 unk_E80; /* 0x0E84 */ u32 unk_E84; - /* 0x0E88 */ u32 unk_E88[7]; // Invadepoh flags - /* 0x0EA4 */ u32 scenesVisible[7]; // tingle maps and clouded regions on pause map. Stores scenes bitwise for up to 224 scenes even though there are not that many scenes - /* 0x0EC0 */ u32 skullTokenCount; // upper 16 bits store Swamp skulls, lower 16 bits store Ocean skulls - /* 0x0EC4 */ u32 unk_EC4; // Gossic stone heart piece flags + /* 0x0E88 */ u32 unk_E88[7]; // Invadepoh flags + /* 0x0EA4 */ u32 scenesVisible[7]; // tingle maps and clouded regions on pause map. Stores scenes bitwise for up to 224 scenes even though there are not that many scenes + /* 0x0EC0 */ u32 skullTokenCount; // upper 16 bits store Swamp skulls, lower 16 bits store Ocean skulls + /* 0x0EC4 */ u32 unk_EC4; // Gossic stone heart piece flags /* 0x0EC8 */ u32 unk_EC8; - /* 0x0ECC */ u32 unk_ECC[2]; // Related to blue warps - /* 0x0ED4 */ u32 stolenItems; // Items stolen by Takkuri and given to Curiosity Shop Man + /* 0x0ECC */ u32 unk_ECC[2]; // Related to blue warps + /* 0x0ED4 */ u32 stolenItems; // Items stolen by Takkuri and given to Curiosity Shop Man /* 0x0ED8 */ u32 unk_DD8; /* 0x0EDC */ u32 bankRupees; /* 0x0EE0 */ u32 unk_EE0; - /* 0x0EE4 */ u32 unk_EE4; // Fishing flags + /* 0x0EE4 */ u32 unk_EE4; // Fishing flags /* 0x0EE8 */ u32 unk_EE8; /* 0x0EEC */ u32 horseBackBalloonHighScore; - /* 0x0EF0 */ u32 lotteryCodeGuess; // Lottery code chosen by player (only uses lower three hex digits) - /* 0x0EF4 */ u32 unk_EF4; // Shooting Gallery Man Flags - /* 0x0EF8 */ u8 weekEventReg[100]; // "week_event_reg" - /* 0x0F5C */ u32 mapsVisited; // "area_arrival" - /* 0x0F60 */ u32 mapsVisible; // "cloud_clear" - /* 0x0F64 */ u8 unk_F64; // "oca_rec_flag" - /* 0x0F65 */ u8 unk_F65; // "oca_rec_flag8" - /* 0x0F66 */ u8 unk_F66[128]; // "oca_rec_buff8" - /* 0x0FE6 */ s8 unk_FE6; // "aikotoba_index" - /* 0x0FE7 */ s8 unk_FE7[5]; // "aikotoba_table" - /* 0x0FEC */ s8 lotteryCodes[3][3]; // Preset lottery codes "numbers_table" - /* 0x0FF5 */ s8 spiderHouseMaskOrder[6]; // "kinsta_color_table" - /* 0x0FFB */ s8 bomberCode[5]; // "bombers_aikotoba_table" + /* 0x0EF0 */ u32 lotteryCodeGuess; // Lottery code chosen by player (only uses lower three hex digits) + /* 0x0EF4 */ u32 unk_EF4; // Shooting Gallery Man Flags + /* 0x0EF8 */ u8 weekEventReg[100]; // "week_event_reg" + /* 0x0F5C */ u32 mapsVisited; // "area_arrival" + /* 0x0F60 */ u32 mapsVisible; // "cloud_clear" + /* 0x0F64 */ u8 unk_F64; // "oca_rec_flag" has scarecrows song + /* 0x0F65 */ u8 unk_F65; // "oca_rec_flag8" scarecrows song set? + /* 0x0F66 */ u8 scarecrowsSong[128]; + /* 0x0FE6 */ s8 bombersCaughtNum; // "aikotoba_index" + /* 0x0FE7 */ s8 bombersCaughtOrder[5]; // "aikotoba_table" + /* 0x0FEC */ s8 lotteryCodes[3][3]; // "numbers_table", Preset lottery codes + /* 0x0FF5 */ s8 spiderHouseMaskOrder[6]; // "kinsta_color_table" + /* 0x0FFB */ s8 bomberCode[5]; // "bombers_aikotoba_table" /* 0x1000 */ HorseData horseData; - /* 0x100A */ u16 checksum; // "check_sum" - /* 0x100C */ u8 eventInf[8]; - /* 0x1014 */ u8 unk_1014; // "stone_set_flag" + /* 0x100A */ u16 checksum; // "check_sum" +} Save; // size = 0x100C + +typedef struct SaveContext { + /* 0x0000 */ Save save; + /* 0x100C */ u8 eventInf[8]; // "event_inf" + /* 0x1014 */ u8 unk_1014; // "stone_set_flag" /* 0x1015 */ u8 unk_1015; - /* 0x1016 */ u16 unk_1016; - /* 0x1018 */ s16 rupeeAccumulator; // "lupy_udct" - /* 0x101A */ u8 unk_101A[6]; // "bottle_status", one entry for each bottle - /* 0x1020 */ OSTime unk_1020[6]; // "bottle_ostime", one entry for each bottle - /* 0x1050 */ OSTime unk_1050[6]; // "bottle_sub", one entry for each bottle - /* 0x1080 */ OSTime unk_1080[6]; // "bottle_time", one entry for each bottle - /* 0x10B0 */ OSTime unk_10B0[6]; // "bottle_stop_time", one entry for each bottle - /* 0x10E0 */ u64 pictoPhoto[1400]; // buffer containing the pictograph photo - /* 0x3CA0 */ s32 fileNum; // "file_no" - /* 0x3CA4 */ s16 powderKegTimer; // "big_bom_timer" + /* 0x1016 */ u16 jinxTimer; + /* 0x1018 */ s16 rupeeAccumulator; // "lupy_udct" + /* 0x101A */ u8 unk_101A[6]; // "bottle_status", one entry for each bottle + /* 0x1020 */ OSTime unk_1020[6]; // "bottle_ostime", one entry for each bottle + /* 0x1050 */ OSTime unk_1050[6]; // "bottle_sub", one entry for each bottle + /* 0x1080 */ OSTime unk_1080[6]; // "bottle_time", one entry for each bottle + /* 0x10B0 */ OSTime unk_10B0[6]; // "bottle_stop_time", one entry for each bottle + /* 0x10E0 */ u64 pictoPhoto[1400]; // buffer containing the pictograph photo + /* 0x3CA0 */ s32 fileNum; // "file_no" + /* 0x3CA4 */ s16 powderKegTimer; // "big_bom_timer" /* 0x3CA6 */ u8 unk_3CA6; - /* 0x3CA7 */ u8 unk_3CA7; // "day_night_flag" - /* 0x3CA8 */ s32 gameMode; // "mode" - /* 0x3CAC */ s32 sceneSetupIndex; // "counter" - /* 0x3CB0 */ s32 respawnFlag; // "restart_flag" - /* 0x3CB4 */ RespawnData respawn[8]; // "restart_data" - /* 0x3DB4 */ f32 entranceSpeed; // "player_wipe_speedF" - /* 0x3DB8 */ u16 entranceSound; // "player_wipe_door_SE" - /* 0x3DBA */ u8 unk_3DBA; // "player_wipe_item" - /* 0x3DBB */ u8 unk_3DBB; // "next_walk" - /* 0x3DBC */ u16 dogParams; // "dog_flag" - /* 0x3DBE */ u8 textTriggerFlags; // "guide_status" - /* 0x3DBF */ u8 showTitleCard; // "name_display" - /* 0x3DC0 */ s16 unk_3DC0; // "shield_magic_timer" - /* 0x3DC2 */ u8 unk_3DC2; // "pad1" - /* 0x3DC8 */ OSTime unk_3DC8; // "get_time" - /* 0x3DD0 */ u8 unk_3DD0[7]; // "event_fg" - /* 0x3DD7 */ u8 unk_3DD7[7]; // "calc_flag" - /* 0x3DE0 */ OSTime unk_3DE0[7]; // "event_ostime" - /* 0x3E18 */ OSTime unk_3E18[7]; // "event_sub" - /* 0x3E50 */ OSTime unk_3E50[7]; // "func_time" - /* 0x3E88 */ OSTime unk_3E88[7]; // "func_end_time" - /* 0x3EC0 */ OSTime unk_3EC0[7]; // "func_stop_time" - /* 0x3EF8 */ s16 timerX[7]; // "event_xp" - /* 0x3F06 */ s16 timerY[7]; // "event_yp" - /* 0x3F14 */ s16 unk_3F14; // "character_change" - /* 0x3F16 */ u8 seqIndex; // "old_bgm" - /* 0x3F17 */ u8 nightSeqIndex; // "old_env" - /* 0x3F18 */ u8 buttonStatus[6]; // "button_item" - /* 0x3F1E */ u8 unk_3F1E; // "ck_fg" - /* 0x3F20 */ u16 unk_3F20; // "alpha_type" - /* 0x3F22 */ u16 unk_3F22; // "prev_alpha_type" - /* 0x3F24 */ u16 unk_3F24; // "alpha_count" - /* 0x3F26 */ u16 unk_3F26; // "last_time_type" - /* 0x3F28 */ s16 unk_3F28; // "magic_flag" - /* 0x3F2A */ s16 unk_3F2A; // "recovery_magic_flag" - /* 0x3F2C */ s16 unk_3F2C; // "keep_magic_flag" - /* 0x3F2E */ s16 unk_3F2E; // "magic_now_max" - /* 0x3F30 */ s16 unk_3F30; // "magic_now_now" - /* 0x3F32 */ s16 unk_3F32; // "magic_used" - /* 0x3F34 */ s16 unk_3F34; // "magic_recovery" - /* 0x3F36 */ u16 mapIndex; // "scene_ID" - /* 0x3F38 */ u16 minigameState; // "yabusame_mode" - /* 0x3F3A */ u16 minigameScore; // "yabusame_total" - /* 0x3F3C */ u16 unk_3F3C; // "yabusame_out_ct" - /* 0x3F3E */ u8 unk_3F3E; // "no_save" - /* 0x3F3F */ u8 unk_3F3F; // "flash_flag" - /* 0x3F40 */ u16 option_id; // "option_id" - /* 0x3F42 */ u8 language; // "j_n" - /* 0x3F43 */ u8 audioSetting; // "s_sound" - /* 0x3F44 */ u8 unk_3F44; // "language" - /* 0x3F45 */ u8 zTargetSetting; // 0: Switch; 1: Hold - /* 0x3F46 */ u16 unk_3F46; // "NottoriBgm" - /* 0x3F48 */ u8 unk_3F48; // "fade_go" - /* 0x3F4A */ u16 nextCutsceneIndex; // "next_daytime" - /* 0x3F4C */ u8 cutsceneTrigger; // "doukidemo" - /* 0x3F4D */ u8 unk_3F4D; // "Kenjya_no" - /* 0x3F4E */ u16 nextDayTime; // "next_zelda_time" - /* 0x3F50 */ u8 fadeDuration; // "fade_speed" - /* 0x3F51 */ u8 unk_3F51; // "wipe_speed" - /* 0x3F52 */ u16 environmentTime; // "kankyo_time" - /* 0x3F54 */ u8 dogIsLost; // "dog_event_flag" - /* 0x3F55 */ u8 nextTransition; // "next_wipe" - /* 0x3F56 */ s16 worldMapArea; // "area_type" - /* 0x3F58 */ s16 sunsSongState; // "sunmoon_flag" - /* 0x3F5A */ s16 healthAccumulator; // "life_mode" - /* 0x3F5C */ s32 unk_3F5C; // "bet_rupees" - /* 0x3F60 */ u8 unk_3F60; // "framescale_flag" - /* 0x3F64 */ f32 unk_3F64; // "framescale_scale" - /* 0x3F68 */ CycleSceneFlags cycleSceneFlags[120]; // Scene flags that are temporarily stored over the duration of a single 3-day cycle - /* 0x48C8 */ u16 unk_48C8; // "scene_id_mix" - /* 0x48CA */ u8 maskMaskBit[3]; // masks given away on the Moon - /* 0x48CD */ char unk_48CD[24]; + /* 0x3CA7 */ u8 unk_3CA7; // "day_night_flag" + /* 0x3CA8 */ s32 gameMode; // "mode" + /* 0x3CAC */ s32 sceneSetupIndex; // "counter" + /* 0x3CB0 */ s32 respawnFlag; // "restart_flag" + /* 0x3CB4 */ RespawnData respawn[RESPAWN_MODE_MAX]; // "restart_data" + /* 0x3DB4 */ f32 entranceSpeed; // "player_wipe_speedF" + /* 0x3DB8 */ u16 entranceSound; // "player_wipe_door_SE" + /* 0x3DBA */ u8 unk_3DBA; // "player_wipe_item" + /* 0x3DBB */ u8 unk_3DBB; // "next_walk" + /* 0x3DBC */ u16 dogParams; // "dog_flag" + /* 0x3DBE */ u8 textTriggerFlags; // "guide_status" + /* 0x3DBF */ u8 showTitleCard; // "name_display" + /* 0x3DC0 */ s16 unk_3DC0; // "shield_magic_timer" + /* 0x3DC2 */ u8 unk_3DC2; // "pad1" + /* 0x3DC8 */ OSTime unk_3DC8; // "get_time" + /* 0x3DD0 */ u8 unk_3DD0[7]; // "event_fg" + /* 0x3DD7 */ u8 unk_3DD7[7]; // "calc_flag" + /* 0x3DE0 */ OSTime unk_3DE0[7]; // "event_ostime" + /* 0x3E18 */ OSTime unk_3E18[7]; // "event_sub" + /* 0x3E50 */ OSTime unk_3E50[7]; // "func_time" + /* 0x3E88 */ OSTime unk_3E88[7]; // "func_end_time" + /* 0x3EC0 */ OSTime unk_3EC0[7]; // "func_stop_time" + /* 0x3EF8 */ s16 timerX[7]; // "event_xp" + /* 0x3F06 */ s16 timerY[7]; // "event_yp" + /* 0x3F14 */ s16 unk_3F14; // "character_change" + /* 0x3F16 */ u8 seqIndex; // "old_bgm" + /* 0x3F17 */ u8 nightSeqIndex; // "old_env" + /* 0x3F18 */ u8 buttonStatus[6]; // "button_item" + /* 0x3F1E */ u8 unk_3F1E; // "ck_fg" + /* 0x3F20 */ u16 unk_3F20; // "alpha_type" + /* 0x3F22 */ u16 unk_3F22; // "prev_alpha_type" + /* 0x3F24 */ u16 unk_3F24; // "alpha_count" + /* 0x3F26 */ u16 unk_3F26; // "last_time_type" + /* 0x3F28 */ s16 unk_3F28; // "magic_flag" + /* 0x3F2A */ s16 unk_3F2A; // "recovery_magic_flag" + /* 0x3F2C */ s16 unk_3F2C; // "keep_magic_flag" + /* 0x3F2E */ s16 unk_3F2E; // "magic_now_max" + /* 0x3F30 */ s16 unk_3F30; // "magic_now_now" + /* 0x3F32 */ s16 unk_3F32; // "magic_used" + /* 0x3F34 */ s16 unk_3F34; // "magic_recovery" + /* 0x3F36 */ u16 mapIndex; // "scene_ID" + /* 0x3F38 */ u16 minigameState; // "yabusame_mode" + /* 0x3F3A */ u16 minigameScore; // "yabusame_total" + /* 0x3F3C */ u16 unk_3F3C; // "yabusame_out_ct" + /* 0x3F3E */ u8 unk_3F3E; // "no_save" + /* 0x3F3F */ u8 unk_3F3F; // "flash_flag" + /* 0x3F40 */ SaveOptions options; + /* 0x3F46 */ u16 unk_3F46; // "NottoriBgm" + /* 0x3F48 */ u8 unk_3F48; // "fade_go" + /* 0x3F4A */ u16 nextCutsceneIndex; // "next_daytime" + /* 0x3F4C */ u8 cutsceneTrigger; // "doukidemo" + /* 0x3F4D */ u8 unk_3F4D; // "Kenjya_no" + /* 0x3F4E */ u16 nextDayTime; // "next_zelda_time" + /* 0x3F50 */ u8 fadeDuration; // "fade_speed" + /* 0x3F51 */ u8 fadeSpeed; // "wipe_speed" transition related + /* 0x3F52 */ u16 environmentTime; // "kankyo_time" + /* 0x3F54 */ u8 dogIsLost; // "dog_event_flag" + /* 0x3F55 */ u8 nextTransition; // "next_wipe" + /* 0x3F56 */ s16 worldMapArea; // "area_type" + /* 0x3F58 */ s16 sunsSongState; // "sunmoon_flag" + /* 0x3F5A */ s16 healthAccumulator; // "life_mode" + /* 0x3F5C */ s32 unk_3F5C; // "bet_rupees" + /* 0x3F60 */ u8 screenScaleFlag; // "framescale_flag" + /* 0x3F64 */ f32 screenScale; // "framescale_scale" + /* 0x3F68 */ CycleSceneFlags cycleSceneFlags[120]; // Scene flags that are temporarily stored over the duration of a single 3-day cycle + /* 0x48C8 */ u16 unk_48C8; // "scene_id_mix" + /* 0x48CA */ u8 maskMaskBit[27]; // "mask_mask_bit", masks given away on the Moon } SaveContext; // size = 0x48C8 -typedef enum { - /* 0x00 */ RESPAWN_MODE_VOID_OUT, - /* 0x01 */ RESPAWN_MODE_GROTTO, // Exiting a grotto - /* 0x02 */ RESPAWN_MODE_FARORES_WIND, // Unused in MM - /* 0x03 */ RESPAWN_MODE_GORON, - /* 0x04 */ RESPAWN_MODE_ZORA, - /* 0x05 */ RESPAWN_MODE_DEKU, - /* 0x06 */ RESPAWN_MODE_CHILD_LINK, - /* 0x07 */ RESPAWN_MODE_UNK_7, - /* 0x07 */ RESPAWN_MODE_UNK_8 -} RespawnMode; - -typedef enum { +typedef enum ButtonStatus { /* 0x00 */ BTN_ENABLED, /* 0xFF */ BTN_DISABLED = 0xFF } ButtonStatus; -typedef enum { +typedef enum SunsSongState { /* 0 */ SUNSSONG_INACTIVE, /* 1 */ SUNSSONG_START, // the suns ocarina effect signals that the song has finished playing /* 2 */ SUNSSONG_SPEED_TIME, // suns was played where time passes, speed up the advancement of time /* 3 */ SUNSSONG_SPECIAL // time does not advance, but signals the song was played. used for freezing redeads } SunsSongState; +void Sram_ActivateOwl(u8 owlId); +void Sram_ClearFlagsAtDawnOfTheFirstDay(void); +void Sram_SaveEndOfCycle(struct GlobalContext* globalCtx); +void Sram_IncrementDay(void); +u16 Sram_CalcChecksum(void* data, size_t count); +void Sram_InitNewSave(void); +void Sram_InitDebugSave(void); +void func_80144A94(SramContext* sramCtx); +void Sram_OpenSave(struct FileChooseContext* fileChooseCtx, SramContext* sramCtx); +void func_8014546C(SramContext* sramCtx); +void func_801457CC(struct FileChooseContext* fileChooseCtx, SramContext* sramCtx); +void func_80146580(struct FileChooseContext* fileChooseCtx, SramContext* sramCtx, s32 fileNum); +void func_80146628(struct FileChooseContext* fileChooseCtx, SramContext* sramCtx); +void Sram_InitSave(struct FileChooseContext* fileChooseCtx, SramContext* sramCtx); +void func_80146DF8(SramContext* sramCtx); +void Sram_InitSram(struct GameState* gameState, SramContext* sramCtx); +void Sram_Alloc(struct GameState* gamestate, SramContext* sramCtx); +void Sram_SaveSpecialEnterClockTown(struct GlobalContext* globalCtx); +void Sram_SaveSpecialNewDay(struct GlobalContext* globalCtx); +void func_80147008(SramContext* sramCtx, u32 curPage, u32 numPages); +void func_80147020(SramContext* sramCtx); +void func_80147068(SramContext* sramCtx); +void func_80147138(SramContext* sramCtx, s32 curPage, s32 numPages); +void func_80147150(SramContext* sramCtx); +void func_80147198(SramContext* sramCtx); + +extern s32 D_801C6798[]; +extern u8 D_801C67B0[24]; +extern s32 D_801C67C8[]; +extern s32 D_801C67E8[]; +extern s32 D_801C67F0[]; +extern s32 D_801C6818[]; +extern s32 D_801C6838[]; +extern s32 D_801C6840[]; +extern s32 D_801C6850[]; + #endif diff --git a/include/z64scene.h b/include/z64scene.h index b20313198d..5a1c39e16f 100644 --- a/include/z64scene.h +++ b/include/z64scene.h @@ -645,7 +645,8 @@ typedef enum { /* 0x6D */ SCENE_ICHIBA, /* 0x6E */ SCENE_BACKTOWN, /* 0x6F */ SCENE_CLOCKTOWER, - /* 0x70 */ SCENE_ALLEY + /* 0x70 */ SCENE_ALLEY, + /* 0x71 */ SCENE_MAX } SceneID; // SceneTableEntry draw configs diff --git a/include/z64schedule.h b/include/z64schedule.h new file mode 100644 index 0000000000..f5dfb2be87 --- /dev/null +++ b/include/z64schedule.h @@ -0,0 +1,248 @@ +#ifndef Z64SCHEDULE_H +#define Z64SCHEDULE_H + +#include "ultra64.h" + +/* + Schedule is a subsystem that acts as a way to make decisions based on the + time and scene (and a limited selection of items). It is utilized by writing + a script that is encoded into bytecode and ran, returning the result in a + struct. The returned result can be a value or a encoded time value. + + The scripts contain 2 kinds of instructions: + - Checks with branches (relative offsets, either 1-byte offsets (short, *_S), + or 2-byte offsets (long, *_L)) + - Returns + + Scripts are stored as u8[]. They are built using the macros are the bottom of + this file. The scheduledis.py script can be used to convert any scripts in + actor data into the macros. +*/ + +// Macro to convert the time format used in the save struct into the format used in Schedule +#define SCHEDULE_CONVERT_TIME(time) ((time) - 0x10000 / 360 * 90) +#define SCHEDULE_TIME_NOW SCHEDULE_CONVERT_TIME(gSaveContext.save.time) + +typedef enum { + /* 00 */ SCHEDULE_CMD_ID_CHECK_FLAG_S, // Checks if a weekEventReg flag is set and branches if so, short range branch + /* 01 */ SCHEDULE_CMD_ID_CHECK_FLAG_L, // Checks if a weekEventReg flag is set and branches if so, long range branch + /* 02 */ SCHEDULE_CMD_ID_CHECK_TIME_RANGE_S, // Checks if the current time is within the range of the two provided times and branches if so, short range branch + /* 03 */ SCHEDULE_CMD_ID_CHECK_TIME_RANGE_L, // Checks if the current time is within the range of the two provided times and branches if so, long range branch + /* 04 */ SCHEDULE_CMD_ID_RET_VAL_L, // Ends script and returns 2-byte value (Note: bugged as the return value size is only 1 byte in the struct) + /* 05 */ SCHEDULE_CMD_ID_RET_NONE, // Ends script without returning anything + /* 06 */ SCHEDULE_CMD_ID_RET_EMPTY, // Ends script and indicates return without changing existing value + /* 07 */ SCHEDULE_CMD_ID_NOP, // No-Op + /* 08 */ SCHEDULE_CMD_ID_CHECK_MISC_S, // Special check based on items or masks and branches if check passes, short range branch + /* 09 */ SCHEDULE_CMD_ID_RET_VAL_S, // Ends script and returns byte value + /* 10 */ SCHEDULE_CMD_ID_CHECK_NOT_IN_SCENE_S, // Checks if the current scene is not SceneNum and branches if so, short range branch + /* 11 */ SCHEDULE_CMD_ID_CHECK_NOT_IN_SCENE_L, // Checks if the current scene is not SceneNum and branches if so, long range branch + /* 12 */ SCHEDULE_CMD_ID_CHECK_NOT_IN_DAY_S, // Checks if the current day is not Day and branches if so, short range branch + /* 13 */ SCHEDULE_CMD_ID_CHECK_NOT_IN_DAY_L, // Checks if the current day is not Day and branches if so, long range branch + /* 14 */ SCHEDULE_CMD_ID_RET_TIME, // Returns 2 time values + /* 15 */ SCHEDULE_CMD_ID_CHECK_BEFORE_TIME_S, // Branches if the current time is less than the command time, short range branch + /* 16 */ SCHEDULE_CMD_ID_CHECK_BEFORE_TIME_L, // Branches if the current time is less than the command time, long range branch + /* 17 */ SCHEDULE_CMD_ID_BRANCH_S, // Always branch, short range branch + /* 18 */ SCHEDULE_CMD_ID_BRANCH_L, // Always branch, long range branch +} ScheduleCommandId; + +typedef enum { + /* 0 */ SCHEDULE_CHECK_MISC_ROOM_KEY, + /* 1 */ SCHEDULE_CHECK_MISC_LETTER_TO_KAFEI, + /* 2 */ SCHEDULE_CHECK_MISC_MASK_ROMANI, +} ScheduleCheckMisc; + +typedef struct { + /* 0x0 */ u8 result; + /* 0x4 */ s32 time0; + /* 0x8 */ s32 time1; + /* 0xC */ s32 hasResult; +} ScheduleResult; // size = 0x10 + +typedef struct { + /* 0x0 */ u8 cmd; +} ScheduleCmdBase; // size = 0x1 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 flagByte; + /* 0x2 */ u8 flagMask; + /* 0x3 */ s8 offset; +} ScheduleCmdCheckFlagS; // size = 0x4 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 flagByte; + /* 0x2 */ u8 flagMask; + /* 0x3 */ u8 offsetH; + /* 0x4 */ u8 offsetL; +} ScheduleCmdCheckFlagL; // size = 0x5 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 startHr; + /* 0x2 */ u8 startMin; + /* 0x3 */ u8 endHr; + /* 0x4 */ u8 endMin; + /* 0x5 */ s8 offset; +} ScheduleCmdCheckTimeRangeS; // size = 0x6 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 startHr; + /* 0x2 */ u8 startMin; + /* 0x3 */ u8 endHr; + /* 0x4 */ u8 endMin; + /* 0x5 */ u8 offsetH; + /* 0x6 */ u8 offsetL; +} ScheduleCmdCheckTimeRangeL; // size = 0x7 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 retH; + /* 0x2 */ u8 retL; +} ScheduleCmdReturnValueL; // size = 0x3 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 unk1; + /* 0x2 */ u8 unk2; + /* 0x3 */ u8 unk3; +} ScheduleCmdNop; // size = 0x4 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 which; + /* 0x2 */ s8 offset; +} ScheduleCmdCheckMiscS; // size = 0x3 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 result; +} ScheduleCmdReturnValueS; // size = 0x2 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 sceneH; + /* 0x2 */ u8 sceneL; + /* 0x3 */ s8 offset; +} ScheduleCmdCheckNotInSceneS; // size = 0x4 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 sceneH; + /* 0x2 */ u8 sceneL; + /* 0x3 */ u8 offsetH; + /* 0x4 */ u8 offsetL; +} ScheduleCmdCheckNotInSceneL; // size = 0x5 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 dayH; + /* 0x2 */ u8 dayL; + /* 0x3 */ s8 offset; +} ScheduleCmdCheckNotInDayS; // size = 0x4 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 dayH; + /* 0x2 */ u8 dayL; + /* 0x3 */ u8 offsetH; + /* 0x4 */ u8 offsetL; +} ScheduleCmdCheckNotInDayL; // size = 0x5 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 time0Hr; + /* 0x2 */ u8 time0Min; + /* 0x3 */ u8 time1Hr; + /* 0x4 */ u8 time1Min; + /* 0x5 */ u8 result; +} ScheduleCmdReturnTime; // size = 0x6 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 timeHr; + /* 0x2 */ u8 timeMin; + /* 0x3 */ s8 offset; +} ScheduleCmdCheckBeforeTimeS; // size = 0x4 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 timeHr; + /* 0x2 */ u8 timeMin; + /* 0x3 */ u8 offsetH; + /* 0x4 */ u8 offsetL; +} ScheduleCmdCheckBeforeTimeL; // size = 0x5 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ s8 offset; +} ScheduleCmdBranchS; // size = 0x2 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 offsetH; + /* 0x2 */ u8 offsetL; +} ScheduleCmdBranchL; // size = 0x3 + +#define SCHEDULE_PACK_S16(val) \ + ((val) >> 8) & 0xFF, (val) & 0xFF + +#define SCHEDULE_CMD_CHECK_FLAG_S(index, mask, offset) \ + SCHEDULE_CMD_ID_CHECK_FLAG_S, (index), (mask), (offset) + +#define SCHEDULE_CMD_CHECK_FLAG_L(index, mask, offset) \ + SCHEDULE_CMD_ID_CHECK_FLAG_L, (index), (mask), SCHEDULE_PACK_S16(offset) + +#define SCHEDULE_CMD_CHECK_TIME_RANGE_S(startHr, startMin, endHr, endMin, offset) \ + SCHEDULE_CMD_ID_CHECK_TIME_RANGE_S, (startHr), (startMin), (endHr), (endMin), (offset) + +#define SCHEDULE_CMD_CHECK_TIME_RANGE_L(startHr, startMin, endHr, endMin, offset) \ + SCHEDULE_CMD_ID_CHECK_TIME_RANGE_L, (startHr), (startMin), (endHr), (endMin), SCHEDULE_PACK_S16(offset) + +#define SCHEDULE_CMD_RET_VAL_L(result) \ + SCHEDULE_CMD_ID_RET_VAL_L, SCHEDULE_PACK_S16(result) + +#define SCHEDULE_CMD_RET_NONE() \ + SCHEDULE_CMD_ID_RET_NONE + +#define SCHEDULE_CMD_RET_EMPTY() \ + SCHEDULE_CMD_ID_RET_EMPTY, + +#define SCHEDULE_CMD_NOP(unk0, unk1, unk2) \ + SCHEDULE_CMD_ID_NOP, (unk0), (unk1), (unk2) + +#define SCHEDULE_CMD_CHECK_MISC_S(which, offset) \ + SCHEDULE_CMD_ID_CHECK_MISC_S, (which), (offset) + +#define SCHEDULE_CMD_RET_VAL_S(result) \ + SCHEDULE_CMD_ID_RET_VAL_S, (result) + +#define SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(scene, offset) \ + SCHEDULE_CMD_ID_CHECK_NOT_IN_SCENE_S, SCHEDULE_PACK_S16(scene), (offset) + +#define SCHEDULE_CMD_CHECK_NOT_IN_SCENE_L(scene, offset) \ + SCHEDULE_CMD_ID_CHECK_NOT_IN_SCENE_L, SCHEDULE_PACK_S16(scene), SCHEDULE_PACK_S16(offset) + +#define SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(day, offset) \ + SCHEDULE_CMD_ID_CHECK_NOT_IN_DAY_S, SCHEDULE_PACK_S16(day), (offset) + +#define SCHEDULE_CMD_CHECK_NOT_IN_DAY_L(day, offset) \ + SCHEDULE_CMD_ID_CHECK_NOT_IN_DAY_L, SCHEDULE_PACK_S16(day), SCHEDULE_PACK_S16(offset) + +#define SCHEDULE_CMD_RET_TIME(time0Hr, time0Min, time1Hr, time1Min, result) \ + SCHEDULE_CMD_ID_RET_TIME, (time0Hr), (time0Min), (time1Hr), (time1Min), (result) + +#define SCHEDULE_CMD_CHECK_BEFORE_TIME_S(timeHr, timeMin, offset) \ + SCHEDULE_CMD_ID_CHECK_BEFORE_TIME_S, (timeHr), (timeMin), (offset) + +#define SCHEDULE_CMD_CHECK_BEFORE_TIME_L(timeHr, timeMin, offset) \ + SCHEDULE_CMD_ID_CHECK_BEFORE_TIME_L, (timeHr), (timeMin), SCHEDULE_PACK_S16(offset) + +#define SCHEDULE_CMD_BRANCH_S(offset) \ + SCHEDULE_CMD_ID_BRANCH_S, (offset) + +#define SCHEDULE_CMD_BRANCH_L(offset) \ + SCHEDULE_CMD_ID_BRANCH_L, SCHEDULE_PACK_S16(offset) + +#endif diff --git a/include/z64skin.h b/include/z64skin.h new file mode 100644 index 0000000000..adb2f9b0fb --- /dev/null +++ b/include/z64skin.h @@ -0,0 +1,106 @@ +#ifndef Z64_SKIN_H +#define Z64_SKIN_H + +#include "z64animation.h" + +struct GraphicsContext; +struct GameState; +struct GlobalContext; + +/** + * Holds a compact version of a vertex used in the Skin system (doesn't has the x, y, z positions or the flag member) + * It is used to initialise the Vtx used by an animated limb + */ +typedef struct { + /* 0x0 */ u16 index; + /* 0x2 */ s16 s; // s and t are texture coordinates (also known as u and v) + /* 0x4 */ s16 t; + /* 0x6 */ s8 normX; + /* 0x7 */ s8 normY; + /* 0x8 */ s8 normZ; + /* 0x9 */ u8 alpha; +} SkinVertex; // size = 0xA + +/** + * Describes a position displacement and a scale to be applied to a limb at index `limbIndex` + */ +typedef struct { + /* 0x0 */ u8 limbIndex; + /* 0x2 */ s16 x; + /* 0x4 */ s16 y; + /* 0x6 */ s16 z; + /* 0x8 */ u8 scale; +} SkinTransformation; // size = 0xA + +typedef struct { + /* 0x00 */ u16 vtxCount; // number of vertices in this modif entry + /* 0x02 */ u16 transformCount; + /* 0x04 */ u16 unk_04; // index of limbTransformations + /* 0x08 */ SkinVertex* skinVertices; + /* 0x0C */ SkinTransformation* limbTransformations; +} SkinLimbModif; // size = 0x10 + +typedef struct { + /* 0x00 */ u16 totalVtxCount; // total vertex count for all modif entries + /* 0x02 */ u16 limbModifCount; // count of limbModifCount + /* 0x04 */ SkinLimbModif* limbModifications; + /* 0x08 */ Gfx* dlist; +} SkinAnimatedLimbData; // size = 0xC + +// ZAPD compatibility typedefs +// TODO: Remove when ZAPD adds support for them +typedef SkinVertex Struct_800A57C0; +typedef SkinTransformation Struct_800A598C_2; +typedef SkinAnimatedLimbData Struct_800A5E28; +typedef SkinLimbModif Struct_800A598C; + +#define SKIN_LIMB_TYPE_ANIMATED 4 +#define SKIN_LIMB_TYPE_NORMAL 11 + +typedef struct { + /* 0x00 */ Vec3s jointPos; // Root is position in model space, children are relative to parent + /* 0x06 */ u8 child; + /* 0x07 */ u8 sibling; + /* 0x08 */ s32 segmentType; // Type of data contained in segment + /* 0x0C */ void* segment; // Gfx* if segmentType is SKIN_LIMB_TYPE_NORMAL, SkinAnimatedLimbData if segmentType is SKIN_LIMB_TYPE_ANIMATED, NULL otherwise +} SkinLimb; // size = 0x10 + +typedef struct { + /* 0x0 */ u8 index; // alternates every draw cycle + /* 0x4 */ Vtx* buf[2]; // number of vertices in buffer determined by `totalVtxCount` +} SkinLimbVtx; // size = 0xC + +typedef struct { + /* 0x000 */ SkeletonHeader* skeletonHeader; + /* 0x004 */ MtxF mtx; + /* 0x044 */ s32 limbCount; + /* 0x048 */ SkinLimbVtx* vtxTable; // double buffered list of vertices for each limb + /* 0x04C */ SkelAnime skelAnime; +} Skin; // size = 0x90 + +typedef void (*SkinPostDraw)(struct Actor*, struct GlobalContext*, Skin*); +typedef s32 (*SkinOverrideLimbDraw)(struct Actor*, struct GlobalContext*, s32, Skin*); + +#define SKIN_DRAW_FLAG_CUSTOM_TRANSFORMS (1 << 0) +#define SKIN_DRAW_FLAG_CUSTOM_MATRIX (1 << 1) + + +void Skin_UpdateVertices(MtxF* mtx, SkinVertex* skinVertices, SkinLimbModif* modifEntry, Vtx* vtxBuf, Vec3f* pos); +void Skin_ApplyLimbModifications(struct GraphicsContext* gfxCtx, Skin* skin, s32 limbIndex, s32 arg3); +void Skin_DrawAnimatedLimb(struct GraphicsContext* gfxCtx, Skin* skin, s32 limbIndex, s32 arg3, s32 drawFlags); +void Skin_DrawLimb(struct GraphicsContext* gfxCtx, Skin* skin, s32 limbIndex, Gfx* dListOverride, s32 drawFlags); +void func_80138228(Actor* actor, struct GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw, s32 setTranslation); +void func_80138258(Actor* actor, struct GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw, SkinOverrideLimbDraw overrideLimbDraw, s32 setTranslation); +void func_8013828C(Actor* actor, struct GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw, SkinOverrideLimbDraw overrideLimbDraw, s32 setTranslation, s32 arg6); +void func_801382C4(Actor* actor, struct GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw, SkinOverrideLimbDraw overrideLimbDraw, s32 setTranslation, s32 arg6, s32 drawFlags); +void Skin_GetLimbPos(Skin* skin, s32 limbIndex, Vec3f* offset, Vec3f* dst); +void Skin_GetVertexPos(Skin* skin, s32 limbIndex, s32 vtxIndex, Vec3f* dst); + +void Skin_Setup(Skin* skin); +void Skin_InitAnimatedLimb(struct GameState* gameState, Skin* skin, s32 limbIndex); +void Skin_Init(struct GameState* gameState, Skin* skin, SkeletonHeader* skeletonHeader, AnimationHeader* animationHeader); +void Skin_Free(struct GameState* gameState, Skin* skin); +s32 func_801387D4(Skin* skin, SkinLimb** skeleton, MtxF* limbMatrices, u8 parentIndex, u8 limbIndex); +s32 Skin_ApplyAnimTransformations(Skin* skin, MtxF* limbMatrices, Actor* actor, s32 setTranslation); + +#endif diff --git a/include/z64subs.h b/include/z64subs.h new file mode 100644 index 0000000000..f01230fdbc --- /dev/null +++ b/include/z64subs.h @@ -0,0 +1,69 @@ +#ifndef Z64SUBS_H +#define Z64SUBS_H + +#include "z64actor.h" +#include "z64scene.h" + +#include "code/sub_s/sub_s.h" + +extern Vec3f gOneVec3f; + +typedef enum { + /* 0 */ SUBS_CUTSCENE_SET_UNK_LINK_FIELDS, + /* 1 */ SUBS_CUTSCENE_NORMAL, + /* 2 */ SUBS_CUTSCENE_SET_FLAG +} SubSCutsceneType; + +//! @TODO: rename based on func_8013E748 and func_800B8500 +typedef s32 (*func_8013E748_VerifyFunc)(struct GlobalContext*, Actor*, void*); + +typedef s32 (*VerifyActor)(struct GlobalContext*, Actor*, Actor*, void*); + +#define SUBS_SHADOW_TEX_WIDTH 64 +#define SUBS_SHADOW_TEX_HEIGHT 64 +#define SUBS_SHADOW_TEX_SIZE ((s32)sizeof(u8[SUBS_SHADOW_TEX_HEIGHT][SUBS_SHADOW_TEX_WIDTH])) + +#define ACTOR_PATHING_RETURN_TO_START (1 << 0) +#define ACTOR_PATHING_SWITCH_DIRECTION (1 << 1) +#define ACTOR_PATHING_MOVE_BACKWARDS (1 << 3) +#define ACTOR_PATHING_REACHED_POINT_PERMANENT (1 << 4) +#define ACTOR_PATHING_REACHED_END_PERMANENT (1 << 5) +#define ACTOR_PATHING_REACHED_POINT_TEMPORARY (1 << 6) +#define ACTOR_PATHING_REACHED_END_TEMPORARY (1 << 7) + +#define ACTOR_PATHING_REACHED_TEMPORARY \ + (ACTOR_PATHING_REACHED_POINT_TEMPORARY | ACTOR_PATHING_REACHED_END_TEMPORARY) +#define ACTOR_PATHING_REACHED_POINT \ + (ACTOR_PATHING_REACHED_POINT_PERMANENT | ACTOR_PATHING_REACHED_POINT_TEMPORARY) +#define ACTOR_PATHING_REACHED_END \ + (ACTOR_PATHING_REACHED_END_PERMANENT | ACTOR_PATHING_REACHED_END_TEMPORARY) + +struct ActorPathing; +typedef void (*ActorPathingComputeFunc)(struct GlobalContext*, struct ActorPathing*); +typedef s32 (*ActorPathingUpdateFunc)(struct GlobalContext*, struct ActorPathing*); + +typedef struct ActorPathing { + /* 0x00 */ Path* setupPathList; + /* 0x04 */ s32 pathIndex; + /* 0x08 */ Vec3s* points; + /* 0x0C */ s32 count; + /* 0x10 */ s32 curPointIndex; + /* 0x14 */ s32 begPointIndex; + /* 0x18 */ s32 endPointIndex; + /* 0x1C */ u8 flags; + /* 0x1D */ u8 prevFlags; + /* 0x20 */ Vec3f curPoint; + /* 0x2C */ Vec3f pointOffset; + /* 0x38 */ Vec3f prevPoint; + /* 0x44 */ Vec3f* worldPos; + /* 0x48 */ Actor* actor; + /* 0x4C */ f32 distSqToCurPointXZ; + /* 0x50 */ f32 distSqToCurPoint; + /* 0x54 */ Vec3s rotToCurPoint; + /* 0x5C */ ActorPathingComputeFunc computePointInfoFunc; + /* 0x60 */ ActorPathingUpdateFunc updateActorInfoFunc; // Return true if should setNextPoint, false if the actor should move forward + /* 0x64 */ ActorPathingUpdateFunc moveFunc; // Return true if should compute and update again + /* 0x68 */ ActorPathingUpdateFunc setNextPointFunc; // Return true if should compute and update again +} ActorPathing; // size = 0x6C + +#endif diff --git a/include/z_en_hy_code.h b/include/z_en_hy_code.h index 997a41233c..9707067608 100644 --- a/include/z_en_hy_code.h +++ b/include/z_en_hy_code.h @@ -72,8 +72,8 @@ typedef struct EnHy { } EnHy; // size = 0x3EC extern s8 gEnHyBodyParts[]; -extern s8 gEnHyBodyPartsIndex[]; -extern u8 gEnHyShadowSize[]; +extern s8 gEnHyParentBodyParts[]; +extern u8 gEnHyShadowSizes[]; s32 EnHy_ChangeAnim(SkelAnime* skelAnime, s16 animIndex); EnDoor* EnHy_FindNearestDoor(Actor* actor, GlobalContext* globalCtx); diff --git a/spec b/spec index ab47cdd85b..d95be57d9e 100644 --- a/spec +++ b/spec @@ -38,7 +38,6 @@ beginseg include "build/src/boot_O2/mtxuty-cvt.o" include "build/src/boot_O2/assert.o" include "build/src/boot_O2/boot_800862E0.o" - include "build/data/boot/boot_800862E0.data.o" include "build/src/boot_O2/padsetup.o" include "build/src/boot_O2/boot_80086760.o" include "build/asm/boot/fp.text.o" @@ -377,13 +376,15 @@ beginseg name "story_static" compress romalign 0x1000 - include "build/baserom/story_static.o" + include "build/assets/misc/story_static/story_static.o" + number 7 endseg beginseg name "do_action_static" romalign 0x1000 - include "build/baserom/do_action_static.o" + include "build/assets/interface/do_action_static/do_action_static.o" + number 9 endseg beginseg @@ -480,7 +481,6 @@ beginseg include "build/data/code/z_horse.data.o" include "build/src/code/z_jpeg.o" include "build/src/code/z_kaleido_setup.o" - include "build/data/code/z_kaleido_setup.data.o" include "build/src/code/z_kanfont.o" include "build/src/code/z_kankyo.o" include "build/data/code/z_kankyo.data.o" @@ -488,7 +488,6 @@ beginseg include "build/src/code/z_lib.o" include "build/src/code/z_lifemeter.o" include "build/src/code/z_lights.o" - include "build/data/code/z_lights.bss.o" include "build/src/code/z_malloc.o" include "build/src/code/z_map_disp.o" include "build/data/code/z_map_disp.data.o" @@ -523,16 +522,13 @@ beginseg include "build/data/code/code_801C2730.data.o" include "build/src/code/z_scene_proc.o" include "build/src/code/z_scene_table.o" - include "build/src/code/code_801323D0.o" - include "build/data/code/code_801C5C50.data.o" + include "build/src/code/z_schedule.o" include "build/src/code/z_skelanime.o" include "build/src/code/z_skin.o" - include "build/data/code/z_skin.bss.o" include "build/src/code/z_skin_awb.o" include "build/src/code/z_skin_matrix.o" include "build/src/code/z_snap.o" include "build/src/code/z_sub_s.o" - include "build/data/code/z_sub_s.data.o" include "build/data/code/code_801DE890.rodata.o" include "build/src/code/code_8013EC10.o" include "build/data/code/code_8013EC10.bss.o" @@ -545,9 +541,8 @@ beginseg include "build/src/code/z_vr_box.o" include "build/src/code/z_vr_box_draw.o" include "build/src/code/z_sram_NES.o" - include "build/data/code/z_sram_NES.data.o" - include "build/data/code/z_sram_NES.bss.o" include "build/src/code/z_message.o" + include "build/data/code/z_message.data.o" include "build/data/code/z_message.bss.o" include "build/src/code/z_message_nes.o" include "build/data/code/z_message_nes.data.o" @@ -624,8 +619,6 @@ beginseg include "build/src/code/audio/audio_heap.o" include "build/data/code/audio_heap.bss.o" include "build/src/code/audio/audio_load.o" - include "build/data/code/audio_load.data.o" - include "build/data/code/audio_load.bss.o" include "build/src/code/audio/code_80192BE0.o" include "build/data/code/code_80192BE0.data.o" include "build/src/code/audio/audio_dcache.o" @@ -741,8 +734,7 @@ beginseg name "ovl_En_Test" compress include "build/src/overlays/actors/ovl_En_Test/z_en_test.o" - include "build/data/ovl_En_Test/ovl_En_Test.data.o" - include "build/data/ovl_En_Test/ovl_En_Test.reloc.o" + include "build/src/overlays/actors/ovl_En_Test/ovl_En_Test_reloc.o" endseg beginseg @@ -764,15 +756,14 @@ beginseg name "ovl_En_Light" compress include "build/src/overlays/actors/ovl_En_Light/z_en_light.o" - include "build/data/ovl_En_Light/ovl_En_Light.data.o" - include "build/data/ovl_En_Light/ovl_En_Light.reloc.o" + include "build/src/overlays/actors/ovl_En_Light/ovl_En_Light_reloc.o" endseg beginseg name "ovl_En_Door" compress include "build/src/overlays/actors/ovl_En_Door/z_en_door.o" - include "build/data/ovl_En_Door/ovl_En_Door.reloc.o" + include "build/src/overlays/actors/ovl_En_Door/ovl_En_Door_reloc.o" endseg beginseg @@ -808,8 +799,7 @@ beginseg name "ovl_En_Wallmas" compress include "build/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.o" - include "build/data/ovl_En_Wallmas/ovl_En_Wallmas.data.o" - include "build/data/ovl_En_Wallmas/ovl_En_Wallmas.reloc.o" + include "build/src/overlays/actors/ovl_En_Wallmas/ovl_En_Wallmas_reloc.o" endseg beginseg @@ -830,8 +820,11 @@ beginseg name "ovl_En_Horse" compress include "build/src/overlays/actors/ovl_En_Horse/z_en_horse.o" - include "build/data/ovl_En_Horse/ovl_En_Horse.data.o" +#ifdef NON_MATCHING + include "build/src/overlays/actors/ovl_En_Horse/ovl_En_Horse_reloc.o" +#else include "build/data/ovl_En_Horse/ovl_En_Horse.reloc.o" +#endif endseg beginseg @@ -959,16 +952,14 @@ beginseg name "ovl_Obj_Wturn" compress include "build/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.o" - include "build/data/ovl_Obj_Wturn/ovl_Obj_Wturn.data.o" - include "build/data/ovl_Obj_Wturn/ovl_Obj_Wturn.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Wturn/ovl_Obj_Wturn_reloc.o" endseg beginseg name "ovl_En_River_Sound" compress include "build/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.o" - include "build/data/ovl_En_River_Sound/ovl_En_River_Sound.data.o" - include "build/data/ovl_En_River_Sound/ovl_En_River_Sound.reloc.o" + include "build/src/overlays/actors/ovl_En_River_Sound/ovl_En_River_Sound_reloc.o" endseg beginseg @@ -990,8 +981,7 @@ beginseg name "ovl_En_Bombf" compress include "build/src/overlays/actors/ovl_En_Bombf/z_en_bombf.o" - include "build/data/ovl_En_Bombf/ovl_En_Bombf.data.o" - include "build/data/ovl_En_Bombf/ovl_En_Bombf.reloc.o" + include "build/src/overlays/actors/ovl_En_Bombf/ovl_En_Bombf_reloc.o" endseg beginseg @@ -1028,8 +1018,7 @@ beginseg name "ovl_Bg_Breakwall" compress include "build/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.o" - include "build/data/ovl_Bg_Breakwall/ovl_Bg_Breakwall.data.o" - include "build/data/ovl_Bg_Breakwall/ovl_Bg_Breakwall.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Breakwall/ovl_Bg_Breakwall_reloc.o" endseg beginseg @@ -1068,8 +1057,7 @@ beginseg name "ovl_En_Bbfall" compress include "build/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.o" - include "build/data/ovl_En_Bbfall/ovl_En_Bbfall.data.o" - include "build/data/ovl_En_Bbfall/ovl_En_Bbfall.reloc.o" + include "build/src/overlays/actors/ovl_En_Bbfall/ovl_En_Bbfall_reloc.o" endseg beginseg @@ -1083,8 +1071,7 @@ beginseg name "ovl_En_Bb" compress include "build/src/overlays/actors/ovl_En_Bb/z_en_bb.o" - include "build/data/ovl_En_Bb/ovl_En_Bb.data.o" - include "build/data/ovl_En_Bb/ovl_En_Bb.reloc.o" + include "build/src/overlays/actors/ovl_En_Bb/ovl_En_Bb_reloc.o" endseg beginseg @@ -1098,9 +1085,7 @@ beginseg name "ovl_En_Wood02" compress include "build/src/overlays/actors/ovl_En_Wood02/z_en_wood02.o" - include "build/data/ovl_En_Wood02/ovl_En_Wood02.data.o" - include "build/data/ovl_En_Wood02/ovl_En_Wood02.bss.o" - include "build/data/ovl_En_Wood02/ovl_En_Wood02.reloc.o" + include "build/src/overlays/actors/ovl_En_Wood02/ovl_En_Wood02_reloc.o" endseg beginseg @@ -1124,16 +1109,14 @@ beginseg name "ovl_En_Vm" compress include "build/src/overlays/actors/ovl_En_Vm/z_en_vm.o" - include "build/data/ovl_En_Vm/ovl_En_Vm.data.o" - include "build/data/ovl_En_Vm/ovl_En_Vm.reloc.o" + include "build/src/overlays/actors/ovl_En_Vm/ovl_En_Vm_reloc.o" endseg beginseg name "ovl_Demo_Effect" compress include "build/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.o" - include "build/data/ovl_Demo_Effect/ovl_Demo_Effect.data.o" - include "build/data/ovl_Demo_Effect/ovl_Demo_Effect.reloc.o" + include "build/src/overlays/actors/ovl_Demo_Effect/ovl_Demo_Effect_reloc.o" endseg beginseg @@ -1288,16 +1271,14 @@ beginseg name "ovl_En_Bom_Chu" compress include "build/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.o" - include "build/data/ovl_En_Bom_Chu/ovl_En_Bom_Chu.data.o" - include "build/data/ovl_En_Bom_Chu/ovl_En_Bom_Chu.reloc.o" + include "build/src/overlays/actors/ovl_En_Bom_Chu/ovl_En_Bom_Chu_reloc.o" endseg beginseg name "ovl_En_Horse_Game_Check" compress include "build/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.o" - include "build/data/ovl_En_Horse_Game_Check/ovl_En_Horse_Game_Check.data.o" - include "build/data/ovl_En_Horse_Game_Check/ovl_En_Horse_Game_Check.reloc.o" + include "build/src/overlays/actors/ovl_En_Horse_Game_Check/ovl_En_Horse_Game_Check_reloc.o" endseg beginseg @@ -1318,11 +1299,7 @@ beginseg name "ovl_En_Fishing" compress include "build/src/overlays/actors/ovl_En_Fishing/z_en_fishing.o" -#ifdef NON_MATCHING include "build/src/overlays/actors/ovl_En_Fishing/ovl_En_Fishing_reloc.o" -#else - include "build/data/ovl_En_Fishing/ovl_En_Fishing.reloc.o" -#endif endseg beginseg @@ -1380,9 +1357,7 @@ beginseg name "ovl_Arrow_Fire" compress include "build/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.o" - include "build/data/ovl_Arrow_Fire/ovl_Arrow_Fire.data.o" - include "build/data/ovl_Arrow_Fire/ovl_Arrow_Fire.bss.o" - include "build/data/ovl_Arrow_Fire/ovl_Arrow_Fire.reloc.o" + include "build/src/overlays/actors/ovl_Arrow_Fire/ovl_Arrow_Fire_reloc.o" endseg beginseg @@ -1396,9 +1371,7 @@ beginseg name "ovl_Arrow_Light" compress include "build/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.o" - include "build/data/ovl_Arrow_Light/ovl_Arrow_Light.data.o" - include "build/data/ovl_Arrow_Light/ovl_Arrow_Light.bss.o" - include "build/data/ovl_Arrow_Light/ovl_Arrow_Light.reloc.o" + include "build/src/overlays/actors/ovl_Arrow_Light/ovl_Arrow_Light_reloc.o" endseg beginseg @@ -1479,9 +1452,7 @@ beginseg name "ovl_En_Kusa" compress include "build/src/overlays/actors/ovl_En_Kusa/z_en_kusa.o" - include "build/data/ovl_En_Kusa/ovl_En_Kusa.data.o" - include "build/data/ovl_En_Kusa/ovl_En_Kusa.bss.o" - include "build/data/ovl_En_Kusa/ovl_En_Kusa.reloc.o" + include "build/src/overlays/actors/ovl_En_Kusa/ovl_En_Kusa_reloc.o" endseg beginseg @@ -1502,9 +1473,7 @@ beginseg name "ovl_Obj_Switch" compress include "build/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.o" - include "build/data/ovl_Obj_Switch/ovl_Obj_Switch.data.o" - include "build/data/ovl_Obj_Switch/ovl_Obj_Switch.bss.o" - include "build/data/ovl_Obj_Switch/ovl_Obj_Switch.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Switch/ovl_Obj_Switch_reloc.o" endseg beginseg @@ -1576,17 +1545,14 @@ beginseg name "ovl_Obj_Blockstop" compress include "build/src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.o" - include "build/data/ovl_Obj_Blockstop/ovl_Obj_Blockstop.data.o" - include "build/data/ovl_Obj_Blockstop/ovl_Obj_Blockstop.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Blockstop/ovl_Obj_Blockstop_reloc.o" endseg beginseg name "ovl_En_Sda" compress include "build/src/overlays/actors/ovl_En_Sda/z_en_sda.o" - include "build/data/ovl_En_Sda/ovl_En_Sda.data.o" - include "build/data/ovl_En_Sda/ovl_En_Sda.bss.o" - include "build/data/ovl_En_Sda/ovl_En_Sda.reloc.o" + include "build/src/overlays/actors/ovl_En_Sda/ovl_En_Sda_reloc.o" endseg beginseg @@ -1614,8 +1580,7 @@ beginseg name "ovl_En_Hs" compress include "build/src/overlays/actors/ovl_En_Hs/z_en_hs.o" - include "build/data/ovl_En_Hs/ovl_En_Hs.data.o" - include "build/data/ovl_En_Hs/ovl_En_Hs.reloc.o" + include "build/src/overlays/actors/ovl_En_Hs/ovl_En_Hs_reloc.o" endseg beginseg @@ -1640,16 +1605,14 @@ beginseg name "ovl_En_Attack_Niw" compress include "build/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.o" - include "build/data/ovl_En_Attack_Niw/ovl_En_Attack_Niw.data.o" - include "build/data/ovl_En_Attack_Niw/ovl_En_Attack_Niw.reloc.o" + include "build/src/overlays/actors/ovl_En_Attack_Niw/ovl_En_Attack_Niw_reloc.o" endseg beginseg name "ovl_En_Mk" compress include "build/src/overlays/actors/ovl_En_Mk/z_en_mk.o" - include "build/data/ovl_En_Mk/ovl_En_Mk.data.o" - include "build/data/ovl_En_Mk/ovl_En_Mk.reloc.o" + include "build/src/overlays/actors/ovl_En_Mk/ovl_En_Mk_reloc.o" endseg beginseg @@ -1874,8 +1837,7 @@ beginseg name "ovl_Effect_Ss_Bubble" compress include "build/src/overlays/effects/ovl_Effect_Ss_Bubble/z_eff_ss_bubble.o" - include "build/data/ovl_Effect_Ss_Bubble/ovl_Effect_Ss_Bubble.data.o" - include "build/data/ovl_Effect_Ss_Bubble/ovl_Effect_Ss_Bubble.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_Bubble/ovl_Effect_Ss_Bubble_reloc.o" endseg beginseg @@ -1937,16 +1899,14 @@ beginseg name "ovl_Effect_Ss_Sibuki" compress include "build/src/overlays/effects/ovl_Effect_Ss_Sibuki/z_eff_ss_sibuki.o" - include "build/data/ovl_Effect_Ss_Sibuki/ovl_Effect_Ss_Sibuki.data.o" - include "build/data/ovl_Effect_Ss_Sibuki/ovl_Effect_Ss_Sibuki.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_Sibuki/ovl_Effect_Ss_Sibuki_reloc.o" endseg beginseg name "ovl_Effect_Ss_Stone1" compress include "build/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.o" - include "build/data/ovl_Effect_Ss_Stone1/ovl_Effect_Ss_Stone1.data.o" - include "build/data/ovl_Effect_Ss_Stone1/ovl_Effect_Ss_Stone1.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_Stone1/ovl_Effect_Ss_Stone1_reloc.o" endseg beginseg @@ -2185,8 +2145,7 @@ beginseg name "ovl_En_Crow" compress include "build/src/overlays/actors/ovl_En_Crow/z_en_crow.o" - include "build/data/ovl_En_Crow/ovl_En_Crow.data.o" - include "build/data/ovl_En_Crow/ovl_En_Crow.reloc.o" + include "build/src/overlays/actors/ovl_En_Crow/ovl_En_Crow_reloc.o" endseg beginseg @@ -2240,8 +2199,7 @@ beginseg name "ovl_Obj_Hamishi" compress include "build/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.o" - include "build/data/ovl_Obj_Hamishi/ovl_Obj_Hamishi.data.o" - include "build/data/ovl_Obj_Hamishi/ovl_Obj_Hamishi.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Hamishi/ovl_Obj_Hamishi_reloc.o" endseg beginseg @@ -2270,8 +2228,7 @@ beginseg name "ovl_Obj_Pzlblock" compress include "build/src/overlays/actors/ovl_Obj_Pzlblock/z_obj_pzlblock.o" - include "build/data/ovl_Obj_Pzlblock/ovl_Obj_Pzlblock.data.o" - include "build/data/ovl_Obj_Pzlblock/ovl_Obj_Pzlblock.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Pzlblock/ovl_Obj_Pzlblock_reloc.o" endseg beginseg @@ -2286,8 +2243,7 @@ beginseg name "ovl_Obj_Armos" compress include "build/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.o" - include "build/data/ovl_Obj_Armos/ovl_Obj_Armos.data.o" - include "build/data/ovl_Obj_Armos/ovl_Obj_Armos.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Armos/ovl_Obj_Armos_reloc.o" endseg beginseg @@ -2309,17 +2265,14 @@ beginseg name "ovl_Obj_Grass" compress include "build/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.o" - include "build/data/ovl_Obj_Grass/ovl_Obj_Grass.data.o" - include "build/data/ovl_Obj_Grass/ovl_Obj_Grass.bss.o" - include "build/data/ovl_Obj_Grass/ovl_Obj_Grass.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Grass/ovl_Obj_Grass_reloc.o" endseg beginseg name "ovl_Obj_Grass_Carry" compress include "build/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.o" - include "build/data/ovl_Obj_Grass_Carry/ovl_Obj_Grass_Carry.data.o" - include "build/data/ovl_Obj_Grass_Carry/ovl_Obj_Grass_Carry.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Grass_Carry/ovl_Obj_Grass_Carry_reloc.o" endseg beginseg @@ -2382,8 +2335,7 @@ beginseg name "ovl_En_Warp_tag" compress include "build/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.o" - include "build/data/ovl_En_Warp_tag/ovl_En_Warp_tag.data.o" - include "build/data/ovl_En_Warp_tag/ovl_En_Warp_tag.reloc.o" + include "build/src/overlays/actors/ovl_En_Warp_tag/ovl_En_Warp_tag_reloc.o" endseg beginseg @@ -2482,16 +2434,18 @@ beginseg name "ovl_Bg_Spdweb" compress include "build/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.o" - include "build/data/ovl_Bg_Spdweb/ovl_Bg_Spdweb.data.o" +#ifdef NON_MATCHING + include "build/src/overlays/actors/ovl_Bg_Spdweb/ovl_Bg_Spdweb_reloc.o" +#else include "build/data/ovl_Bg_Spdweb/ovl_Bg_Spdweb.reloc.o" +#endif endseg beginseg name "ovl_En_Mt_tag" compress include "build/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.o" - include "build/data/ovl_En_Mt_tag/ovl_En_Mt_tag.data.o" - include "build/data/ovl_En_Mt_tag/ovl_En_Mt_tag.reloc.o" + include "build/src/overlays/actors/ovl_En_Mt_tag/ovl_En_Mt_tag_reloc.o" endseg beginseg @@ -2507,20 +2461,14 @@ beginseg name "ovl_Boss_02" compress include "build/src/overlays/actors/ovl_Boss_02/z_boss_02.o" - #ifdef NON_MATCHING - include "build/src/overlays/actors/ovl_Boss_02/ovl_Boss_02_reloc.o" - #else - include "build/data/ovl_Boss_02/ovl_Boss_02.reloc.o" - #endif + include "build/src/overlays/actors/ovl_Boss_02/ovl_Boss_02_reloc.o" endseg beginseg name "ovl_Boss_03" compress include "build/src/overlays/actors/ovl_Boss_03/z_boss_03.o" - include "build/data/ovl_Boss_03/ovl_Boss_03.data.o" - include "build/data/ovl_Boss_03/ovl_Boss_03.bss.o" - include "build/data/ovl_Boss_03/ovl_Boss_03.reloc.o" + include "build/src/overlays/actors/ovl_Boss_03/ovl_Boss_03_reloc.o" endseg beginseg @@ -2596,8 +2544,7 @@ beginseg name "ovl_En_Raf" compress include "build/src/overlays/actors/ovl_En_Raf/z_en_raf.o" - include "build/data/ovl_En_Raf/ovl_En_Raf.data.o" - include "build/data/ovl_En_Raf/ovl_En_Raf.reloc.o" + include "build/src/overlays/actors/ovl_En_Raf/ovl_En_Raf_reloc.o" endseg beginseg @@ -2632,8 +2579,11 @@ beginseg name "ovl_Obj_Spinyroll" compress include "build/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.o" - include "build/data/ovl_Obj_Spinyroll/ovl_Obj_Spinyroll.data.o" +#ifdef NON_MATCHING + include "build/src/overlays/actors/ovl_Obj_Spinyroll/ovl_Obj_Spinyroll_reloc.o" +#else include "build/data/ovl_Obj_Spinyroll/ovl_Obj_Spinyroll.reloc.o" +#endif endseg beginseg @@ -2655,16 +2605,14 @@ beginseg name "ovl_Obj_Skateblock" compress include "build/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.o" - include "build/data/ovl_Obj_Skateblock/ovl_Obj_Skateblock.data.o" - include "build/data/ovl_Obj_Skateblock/ovl_Obj_Skateblock.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Skateblock/ovl_Obj_Skateblock_reloc.o" endseg beginseg name "ovl_Effect_En_Ice_Block" compress include "build/src/overlays/effects/ovl_Effect_En_Ice_Block/z_eff_en_ice_block.o" - include "build/data/ovl_Effect_En_Ice_Block/ovl_Effect_En_Ice_Block.data.o" - include "build/data/ovl_Effect_En_Ice_Block/ovl_Effect_En_Ice_Block.reloc.o" + include "build/src/overlays/effects/ovl_Effect_En_Ice_Block/ovl_Effect_En_Ice_Block_reloc.o" endseg beginseg @@ -2693,8 +2641,7 @@ beginseg name "ovl_En_Syateki_Dekunuts" compress include "build/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.o" - include "build/data/ovl_En_Syateki_Dekunuts/ovl_En_Syateki_Dekunuts.data.o" - include "build/data/ovl_En_Syateki_Dekunuts/ovl_En_Syateki_Dekunuts.reloc.o" + include "build/src/overlays/actors/ovl_En_Syateki_Dekunuts/ovl_En_Syateki_Dekunuts_reloc.o" endseg beginseg @@ -2754,8 +2701,7 @@ beginseg name "ovl_Obj_Entotu" compress include "build/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.o" - include "build/data/ovl_Obj_Entotu/ovl_Obj_Entotu.data.o" - include "build/data/ovl_Obj_Entotu/ovl_Obj_Entotu.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Entotu/ovl_Obj_Entotu_reloc.o" endseg beginseg @@ -2769,8 +2715,7 @@ beginseg name "ovl_En_Syateki_Okuta" compress include "build/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.o" - include "build/data/ovl_En_Syateki_Okuta/ovl_En_Syateki_Okuta.data.o" - include "build/data/ovl_En_Syateki_Okuta/ovl_En_Syateki_Okuta.reloc.o" + include "build/src/overlays/actors/ovl_En_Syateki_Okuta/ovl_En_Syateki_Okuta_reloc.o" endseg beginseg @@ -2801,8 +2746,7 @@ beginseg name "ovl_En_Elfgrp" compress include "build/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.o" - include "build/data/ovl_En_Elfgrp/ovl_En_Elfgrp.data.o" - include "build/data/ovl_En_Elfgrp/ovl_En_Elfgrp.reloc.o" + include "build/src/overlays/actors/ovl_En_Elfgrp/ovl_En_Elfgrp_reloc.o" endseg beginseg @@ -2824,16 +2768,18 @@ beginseg name "ovl_Obj_Vspinyroll" compress include "build/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.o" - include "build/data/ovl_Obj_Vspinyroll/ovl_Obj_Vspinyroll.data.o" +#ifdef NON_MATCHING + include "build/src/overlays/actors/ovl_Obj_Vspinyroll/ovl_Obj_Vspinyroll_reloc.o" +#else include "build/data/ovl_Obj_Vspinyroll/ovl_Obj_Vspinyroll.reloc.o" +#endif endseg beginseg name "ovl_Obj_Smork" compress include "build/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.o" - include "build/data/ovl_Obj_Smork/ovl_Obj_Smork.data.o" - include "build/data/ovl_Obj_Smork/ovl_Obj_Smork.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Smork/ovl_Obj_Smork_reloc.o" endseg beginseg @@ -2919,8 +2865,7 @@ beginseg name "ovl_Obj_Fireshield" compress include "build/src/overlays/actors/ovl_Obj_Fireshield/z_obj_fireshield.o" - include "build/data/ovl_Obj_Fireshield/ovl_Obj_Fireshield.data.o" - include "build/data/ovl_Obj_Fireshield/ovl_Obj_Fireshield.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Fireshield/ovl_Obj_Fireshield_reloc.o" endseg beginseg @@ -3060,16 +3005,18 @@ beginseg name "ovl_Obj_Driftice" compress include "build/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.o" - include "build/data/ovl_Obj_Driftice/ovl_Obj_Driftice.data.o" +#ifdef NON_MATCHING + include "build/src/overlays/actors/ovl_Obj_Driftice/ovl_Obj_Driftice_reloc.o" +#else include "build/data/ovl_Obj_Driftice/ovl_Obj_Driftice.reloc.o" +#endif endseg beginseg name "ovl_En_Look_Nuts" compress include "build/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.o" - include "build/data/ovl_En_Look_Nuts/ovl_En_Look_Nuts.data.o" - include "build/data/ovl_En_Look_Nuts/ovl_En_Look_Nuts.reloc.o" + include "build/src/overlays/actors/ovl_En_Look_Nuts/ovl_En_Look_Nuts_reloc.o" endseg beginseg @@ -3192,9 +3139,7 @@ beginseg name "ovl_En_Test6" compress include "build/src/overlays/actors/ovl_En_Test6/z_en_test6.o" - include "build/data/ovl_En_Test6/ovl_En_Test6.data.o" - include "build/data/ovl_En_Test6/ovl_En_Test6.bss.o" - include "build/data/ovl_En_Test6/ovl_En_Test6.reloc.o" + include "build/src/overlays/actors/ovl_En_Test6/ovl_En_Test6_reloc.o" endseg beginseg @@ -3339,16 +3284,18 @@ beginseg name "ovl_En_Guard_Nuts" compress include "build/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.o" - include "build/data/ovl_En_Guard_Nuts/ovl_En_Guard_Nuts.data.o" - include "build/data/ovl_En_Guard_Nuts/ovl_En_Guard_Nuts.reloc.o" + include "build/src/overlays/actors/ovl_En_Guard_Nuts/ovl_En_Guard_Nuts_reloc.o" endseg beginseg name "ovl_Bg_Hakugin_Bombwall" compress include "build/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.o" - include "build/data/ovl_Bg_Hakugin_Bombwall/ovl_Bg_Hakugin_Bombwall.data.o" +#ifdef NON_MATCHING + include "build/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/ovl_Bg_Hakugin_Bombwall_reloc.o" +#else include "build/data/ovl_Bg_Hakugin_Bombwall/ovl_Bg_Hakugin_Bombwall.reloc.o" +#endif endseg beginseg @@ -3458,8 +3405,7 @@ beginseg name "ovl_Effect_Ss_Sbn" compress include "build/src/overlays/effects/ovl_Effect_Ss_Sbn/z_eff_ss_sbn.o" - include "build/data/ovl_Effect_Ss_Sbn/ovl_Effect_Ss_Sbn.data.o" - include "build/data/ovl_Effect_Ss_Sbn/ovl_Effect_Ss_Sbn.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_Sbn/ovl_Effect_Ss_Sbn_reloc.o" endseg beginseg @@ -3490,8 +3436,7 @@ beginseg name "ovl_Bg_Open_Spot" compress include "build/src/overlays/actors/ovl_Bg_Open_Spot/z_bg_open_spot.o" - include "build/data/ovl_Bg_Open_Spot/ovl_Bg_Open_Spot.data.o" - include "build/data/ovl_Bg_Open_Spot/ovl_Bg_Open_Spot.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Open_Spot/ovl_Bg_Open_Spot_reloc.o" endseg beginseg @@ -3526,16 +3471,14 @@ beginseg name "ovl_En_Fu_Mato" compress include "build/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.o" - include "build/data/ovl_En_Fu_Mato/ovl_En_Fu_Mato.data.o" - include "build/data/ovl_En_Fu_Mato/ovl_En_Fu_Mato.reloc.o" + include "build/src/overlays/actors/ovl_En_Fu_Mato/ovl_En_Fu_Mato_reloc.o" endseg beginseg name "ovl_En_Fu_Kago" compress include "build/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.o" - include "build/data/ovl_En_Fu_Kago/ovl_En_Fu_Kago.data.o" - include "build/data/ovl_En_Fu_Kago/ovl_En_Fu_Kago.reloc.o" + include "build/src/overlays/actors/ovl_En_Fu_Kago/ovl_En_Fu_Kago_reloc.o" endseg beginseg @@ -3631,8 +3574,7 @@ beginseg name "ovl_En_Tsn" compress include "build/src/overlays/actors/ovl_En_Tsn/z_en_tsn.o" - include "build/data/ovl_En_Tsn/ovl_En_Tsn.data.o" - include "build/data/ovl_En_Tsn/ovl_En_Tsn.reloc.o" + include "build/src/overlays/actors/ovl_En_Tsn/ovl_En_Tsn_reloc.o" endseg beginseg @@ -3669,8 +3611,7 @@ beginseg name "ovl_Obj_Bigicicle" compress include "build/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.o" - include "build/data/ovl_Obj_Bigicicle/ovl_Obj_Bigicicle.data.o" - include "build/data/ovl_Obj_Bigicicle/ovl_Obj_Bigicicle.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Bigicicle/ovl_Obj_Bigicicle_reloc.o" endseg beginseg @@ -3707,9 +3648,7 @@ beginseg name "ovl_En_Test7" compress include "build/src/overlays/actors/ovl_En_Test7/z_en_test7.o" - include "build/data/ovl_En_Test7/ovl_En_Test7.data.o" - include "build/data/ovl_En_Test7/ovl_En_Test7.bss.o" - include "build/data/ovl_En_Test7/ovl_En_Test7.reloc.o" + include "build/src/overlays/actors/ovl_En_Test7/ovl_En_Test7_reloc.o" endseg beginseg @@ -3770,8 +3709,7 @@ beginseg name "ovl_En_Gakufu" compress include "build/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.o" - include "build/data/ovl_En_Gakufu/ovl_En_Gakufu.data.o" - include "build/data/ovl_En_Gakufu/ovl_En_Gakufu.reloc.o" + include "build/src/overlays/actors/ovl_En_Gakufu/ovl_En_Gakufu_reloc.o" endseg beginseg @@ -3815,11 +3753,7 @@ beginseg name "ovl_Obj_Snowball" compress include "build/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.o" -#ifdef NON_MATCHING - include "build/src/overlays/actors/ovl_Obj_Snowball/ovl_obj_Snowball_reloc.o" -#else - include "build/data/ovl_Obj_Snowball/ovl_Obj_Snowball.reloc.o" -#endif + include "build/src/overlays/actors/ovl_Obj_Snowball/ovl_Obj_Snowball_reloc.o" endseg beginseg @@ -3921,8 +3855,7 @@ beginseg name "ovl_En_Hanabi" compress include "build/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.o" - include "build/data/ovl_En_Hanabi/ovl_En_Hanabi.data.o" - include "build/data/ovl_En_Hanabi/ovl_En_Hanabi.reloc.o" + include "build/src/overlays/actors/ovl_En_Hanabi/ovl_En_Hanabi_reloc.o" endseg beginseg @@ -3988,8 +3921,11 @@ beginseg name "ovl_Obj_Spidertent" compress include "build/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.o" - include "build/data/ovl_Obj_Spidertent/ovl_Obj_Spidertent.data.o" +#ifdef NON_MATCHING + include "build/src/overlays/actors/ovl_Obj_Spidertent/ovl_Obj_Spidertent_reloc.o" +#else include "build/data/ovl_Obj_Spidertent/ovl_Obj_Spidertent.reloc.o" +#endif endseg beginseg @@ -4003,8 +3939,7 @@ beginseg name "ovl_En_Kbt" compress include "build/src/overlays/actors/ovl_En_Kbt/z_en_kbt.o" - include "build/data/ovl_En_Kbt/ovl_En_Kbt.data.o" - include "build/data/ovl_En_Kbt/ovl_En_Kbt.reloc.o" + include "build/src/overlays/actors/ovl_En_Kbt/ovl_En_Kbt_reloc.o" endseg beginseg @@ -4018,8 +3953,7 @@ beginseg name "ovl_En_Maruta" compress include "build/src/overlays/actors/ovl_En_Maruta/z_en_maruta.o" - include "build/data/ovl_En_Maruta/ovl_En_Maruta.data.o" - include "build/data/ovl_En_Maruta/ovl_En_Maruta.reloc.o" + include "build/src/overlays/actors/ovl_En_Maruta/ovl_En_Maruta_reloc.o" endseg beginseg @@ -4112,16 +4046,14 @@ beginseg name "ovl_En_Dragon" compress include "build/src/overlays/actors/ovl_En_Dragon/z_en_dragon.o" - include "build/data/ovl_En_Dragon/ovl_En_Dragon.data.o" - include "build/data/ovl_En_Dragon/ovl_En_Dragon.reloc.o" + include "build/src/overlays/actors/ovl_En_Dragon/ovl_En_Dragon_reloc.o" endseg beginseg name "ovl_Obj_Dora" compress include "build/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.o" - include "build/data/ovl_Obj_Dora/ovl_Obj_Dora.data.o" - include "build/data/ovl_Obj_Dora/ovl_Obj_Dora.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Dora/ovl_Obj_Dora_reloc.o" endseg beginseg @@ -4135,16 +4067,18 @@ beginseg name "ovl_Obj_Kendo_Kanban" compress include "build/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.o" - include "build/data/ovl_Obj_Kendo_Kanban/ovl_Obj_Kendo_Kanban.data.o" +#ifdef NON_MATCHING + include "build/src/overlays/actors/ovl_Obj_Kendo_Kanban/ovl_Obj_Kendo_Kanban_reloc.o" +#else include "build/data/ovl_Obj_Kendo_Kanban/ovl_Obj_Kendo_Kanban.reloc.o" +#endif endseg beginseg name "ovl_Obj_Hariko" compress include "build/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.o" - include "build/data/ovl_Obj_Hariko/ovl_Obj_Hariko.data.o" - include "build/data/ovl_Obj_Hariko/ovl_Obj_Hariko.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Hariko/ovl_Obj_Hariko_reloc.o" endseg beginseg @@ -4158,8 +4092,7 @@ beginseg name "ovl_Bg_Sinkai_Kabe" compress include "build/src/overlays/actors/ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.o" - include "build/data/ovl_Bg_Sinkai_Kabe/ovl_Bg_Sinkai_Kabe.data.o" - include "build/data/ovl_Bg_Sinkai_Kabe/ovl_Bg_Sinkai_Kabe.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Sinkai_Kabe/ovl_Bg_Sinkai_Kabe_reloc.o" endseg beginseg @@ -4196,8 +4129,7 @@ beginseg name "ovl_Bg_Kin2_Shelf" compress include "build/src/overlays/actors/ovl_Bg_Kin2_Shelf/z_bg_kin2_shelf.o" - include "build/data/ovl_Bg_Kin2_Shelf/ovl_Bg_Kin2_Shelf.data.o" - include "build/data/ovl_Bg_Kin2_Shelf/ovl_Bg_Kin2_Shelf.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Kin2_Shelf/ovl_Bg_Kin2_Shelf_reloc.o" endseg beginseg @@ -4218,8 +4150,7 @@ beginseg name "ovl_En_Tru_Mt" compress include "build/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.o" - include "build/data/ovl_En_Tru_Mt/ovl_En_Tru_Mt.data.o" - include "build/data/ovl_En_Tru_Mt/ovl_En_Tru_Mt.reloc.o" + include "build/src/overlays/actors/ovl_En_Tru_Mt/ovl_En_Tru_Mt_reloc.o" endseg beginseg @@ -4234,8 +4165,7 @@ beginseg name "ovl_En_Neo_Reeba" compress include "build/src/overlays/actors/ovl_En_Neo_Reeba/z_en_neo_reeba.o" - include "build/data/ovl_En_Neo_Reeba/ovl_En_Neo_Reeba.data.o" - include "build/data/ovl_En_Neo_Reeba/ovl_En_Neo_Reeba.reloc.o" + include "build/src/overlays/actors/ovl_En_Neo_Reeba/ovl_En_Neo_Reeba_reloc.o" endseg beginseg @@ -4249,8 +4179,7 @@ beginseg name "ovl_Bg_Ikana_Block" compress include "build/src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.o" - include "build/data/ovl_Bg_Ikana_Block/ovl_Bg_Ikana_Block.data.o" - include "build/data/ovl_Bg_Ikana_Block/ovl_Bg_Ikana_Block.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Ikana_Block/ovl_Bg_Ikana_Block_reloc.o" endseg beginseg @@ -4272,17 +4201,14 @@ beginseg name "ovl_Bg_Dblue_Balance" compress include "build/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.o" - include "build/data/ovl_Bg_Dblue_Balance/ovl_Bg_Dblue_Balance.data.o" - include "build/data/ovl_Bg_Dblue_Balance/ovl_Bg_Dblue_Balance.bss.o" - include "build/data/ovl_Bg_Dblue_Balance/ovl_Bg_Dblue_Balance.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Dblue_Balance/ovl_Bg_Dblue_Balance_reloc.o" endseg beginseg name "ovl_Bg_Dblue_Waterfall" compress include "build/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.o" - include "build/data/ovl_Bg_Dblue_Waterfall/ovl_Bg_Dblue_Waterfall.data.o" - include "build/data/ovl_Bg_Dblue_Waterfall/ovl_Bg_Dblue_Waterfall.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Dblue_Waterfall/ovl_Bg_Dblue_Waterfall_reloc.o" endseg beginseg @@ -4431,8 +4357,11 @@ beginseg name "ovl_Mir_Ray3" compress include "build/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.o" - include "build/data/ovl_Mir_Ray3/ovl_Mir_Ray3.data.o" +#ifdef NON_MATCHING + include "build/src/overlays/actors/ovl_Mir_Ray3/ovl_Mir_Ray3_reloc.o" +#else include "build/data/ovl_Mir_Ray3/ovl_Mir_Ray3.reloc.o" +#endif endseg beginseg @@ -4446,17 +4375,14 @@ beginseg name "ovl_Elf_Msg6" compress include "build/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.o" - include "build/data/ovl_Elf_Msg6/ovl_Elf_Msg6.data.o" - include "build/data/ovl_Elf_Msg6/ovl_Elf_Msg6.reloc.o" + include "build/src/overlays/actors/ovl_Elf_Msg6/ovl_Elf_Msg6_reloc.o" endseg beginseg name "ovl_Obj_Nozoki" compress include "build/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.o" - include "build/data/ovl_Obj_Nozoki/ovl_Obj_Nozoki.data.o" - include "build/data/ovl_Obj_Nozoki/ovl_Obj_Nozoki.bss.o" - include "build/data/ovl_Obj_Nozoki/ovl_Obj_Nozoki.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Nozoki/ovl_Obj_Nozoki_reloc.o" endseg beginseg @@ -4499,8 +4425,7 @@ beginseg name "ovl_En_Kujiya" compress include "build/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.o" - include "build/data/ovl_En_Kujiya/ovl_En_Kujiya.data.o" - include "build/data/ovl_En_Kujiya/ovl_En_Kujiya.reloc.o" + include "build/src/overlays/actors/ovl_En_Kujiya/ovl_En_Kujiya_reloc.o" endseg beginseg @@ -4521,16 +4446,14 @@ beginseg name "ovl_Obj_Yasi" compress include "build/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.o" - include "build/data/ovl_Obj_Yasi/ovl_Obj_Yasi.data.o" - include "build/data/ovl_Obj_Yasi/ovl_Obj_Yasi.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Yasi/ovl_Obj_Yasi_reloc.o" endseg beginseg name "ovl_En_Tanron1" compress include "build/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.o" - include "build/data/ovl_En_Tanron1/ovl_En_Tanron1.data.o" - include "build/data/ovl_En_Tanron1/ovl_En_Tanron1.reloc.o" + include "build/src/overlays/actors/ovl_En_Tanron1/ovl_En_Tanron1_reloc.o" endseg beginseg @@ -4551,9 +4474,7 @@ beginseg name "ovl_Obj_Chan" compress include "build/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.o" - include "build/data/ovl_Obj_Chan/ovl_Obj_Chan.data.o" - include "build/data/ovl_Obj_Chan/ovl_Obj_Chan.bss.o" - include "build/data/ovl_Obj_Chan/ovl_Obj_Chan.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Chan/ovl_Obj_Chan_reloc.o" endseg beginseg @@ -4590,17 +4511,14 @@ beginseg name "ovl_Bg_F40_Block" compress include "build/src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.o" - include "build/data/ovl_Bg_F40_Block/ovl_Bg_F40_Block.data.o" - include "build/data/ovl_Bg_F40_Block/ovl_Bg_F40_Block.reloc.o" + include "build/src/overlays/actors/ovl_Bg_F40_Block/ovl_Bg_F40_Block_reloc.o" endseg beginseg name "ovl_Bg_F40_Switch" compress include "build/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.o" - include "build/data/ovl_Bg_F40_Switch/ovl_Bg_F40_Switch.data.o" - include "build/data/ovl_Bg_F40_Switch/ovl_Bg_F40_Switch.bss.o" - include "build/data/ovl_Bg_F40_Switch/ovl_Bg_F40_Switch.reloc.o" + include "build/src/overlays/actors/ovl_Bg_F40_Switch/ovl_Bg_F40_Switch_reloc.o" endseg beginseg @@ -4639,8 +4557,7 @@ beginseg name "ovl_Oceff_Wipe6" compress include "build/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.o" - include "build/data/ovl_Oceff_Wipe6/ovl_Oceff_Wipe6.data.o" - include "build/data/ovl_Oceff_Wipe6/ovl_Oceff_Wipe6.reloc.o" + include "build/src/overlays/actors/ovl_Oceff_Wipe6/ovl_Oceff_Wipe6_reloc.o" endseg beginseg @@ -4701,8 +4618,7 @@ beginseg name "ovl_En_Ah" compress include "build/src/overlays/actors/ovl_En_Ah/z_en_ah.o" - include "build/data/ovl_En_Ah/ovl_En_Ah.data.o" - include "build/data/ovl_En_Ah/ovl_En_Ah.reloc.o" + include "build/src/overlays/actors/ovl_En_Ah/ovl_En_Ah_reloc.o" endseg beginseg @@ -4790,8 +4706,7 @@ beginseg name "ovl_En_Hidden_Nuts" compress include "build/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.o" - include "build/data/ovl_En_Hidden_Nuts/ovl_En_Hidden_Nuts.data.o" - include "build/data/ovl_En_Hidden_Nuts/ovl_En_Hidden_Nuts.reloc.o" + include "build/src/overlays/actors/ovl_En_Hidden_Nuts/ovl_En_Hidden_Nuts_reloc.o" endseg beginseg @@ -4848,16 +4763,14 @@ beginseg name "ovl_En_Tanron4" compress include "build/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.o" - include "build/data/ovl_En_Tanron4/ovl_En_Tanron4.data.o" - include "build/data/ovl_En_Tanron4/ovl_En_Tanron4.reloc.o" + include "build/src/overlays/actors/ovl_En_Tanron4/ovl_En_Tanron4_reloc.o" endseg beginseg name "ovl_En_Tanron5" compress include "build/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.o" - include "build/data/ovl_En_Tanron5/ovl_En_Tanron5.data.o" - include "build/data/ovl_En_Tanron5/ovl_En_Tanron5.reloc.o" + include "build/src/overlays/actors/ovl_En_Tanron5/ovl_En_Tanron5_reloc.o" endseg beginseg @@ -4978,8 +4891,7 @@ beginseg name "ovl_En_Osk" compress include "build/src/overlays/actors/ovl_En_Osk/z_en_osk.o" - include "build/data/ovl_En_Osk/ovl_En_Osk.data.o" - include "build/data/ovl_En_Osk/ovl_En_Osk.reloc.o" + include "build/src/overlays/actors/ovl_En_Osk/ovl_En_Osk_reloc.o" endseg beginseg @@ -5024,7 +4936,7 @@ beginseg name "ovl_En_Bomjima" compress include "build/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.o" - include "build/data/ovl_En_Bomjima/ovl_En_Bomjima.reloc.o" + include "build/src/overlays/actors/ovl_En_Bomjima/ovl_En_Bomjima_reloc.o" endseg beginseg @@ -5038,16 +4950,14 @@ beginseg name "ovl_En_Bombers" compress include "build/src/overlays/actors/ovl_En_Bombers/z_en_bombers.o" - include "build/data/ovl_En_Bombers/ovl_En_Bombers.data.o" - include "build/data/ovl_En_Bombers/ovl_En_Bombers.reloc.o" + include "build/src/overlays/actors/ovl_En_Bombers/ovl_En_Bombers_reloc.o" endseg beginseg name "ovl_En_Bombers2" compress include "build/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.o" - include "build/data/ovl_En_Bombers2/ovl_En_Bombers2.data.o" - include "build/data/ovl_En_Bombers2/ovl_En_Bombers2.reloc.o" + include "build/src/overlays/actors/ovl_En_Bombers2/ovl_En_Bombers2_reloc.o" endseg beginseg @@ -5173,8 +5083,7 @@ beginseg name "ovl_En_Jgame_Tsn" compress include "build/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.o" - include "build/data/ovl_En_Jgame_Tsn/ovl_En_Jgame_Tsn.data.o" - include "build/data/ovl_En_Jgame_Tsn/ovl_En_Jgame_Tsn.reloc.o" + include "build/src/overlays/actors/ovl_En_Jgame_Tsn/ovl_En_Jgame_Tsn_reloc.o" endseg beginseg @@ -5196,8 +5105,7 @@ beginseg name "ovl_Demo_Syoten" compress include "build/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.o" - include "build/data/ovl_Demo_Syoten/ovl_Demo_Syoten.data.o" - include "build/data/ovl_Demo_Syoten/ovl_Demo_Syoten.reloc.o" + include "build/src/overlays/actors/ovl_Demo_Syoten/ovl_Demo_Syoten_reloc.o" endseg beginseg @@ -5268,8 +5176,7 @@ beginseg name "ovl_Dm_An" compress include "build/src/overlays/actors/ovl_Dm_An/z_dm_an.o" - include "build/data/ovl_Dm_An/ovl_Dm_An.data.o" - include "build/data/ovl_Dm_An/ovl_Dm_An.reloc.o" + include "build/src/overlays/actors/ovl_Dm_An/ovl_Dm_An_reloc.o" endseg beginseg @@ -5379,8 +5286,7 @@ beginseg name "ovl_Dm_Gm" compress include "build/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.o" - include "build/data/ovl_Dm_Gm/ovl_Dm_Gm.data.o" - include "build/data/ovl_Dm_Gm/ovl_Dm_Gm.reloc.o" + include "build/src/overlays/actors/ovl_Dm_Gm/ovl_Dm_Gm_reloc.o" endseg beginseg @@ -9237,7 +9143,8 @@ endseg beginseg name "week_static" romalign 0x1000 - include "build/baserom/week_static.o" + include "build/assets/interface/week_static/week_static.o" + number 9 endseg beginseg diff --git a/src/boot_O2/boot_800862E0.c b/src/boot_O2/boot_800862E0.c index 1055dfe1b8..5774af9dac 100644 --- a/src/boot_O2/boot_800862E0.c +++ b/src/boot_O2/boot_800862E0.c @@ -1,18 +1,116 @@ #include "global.h" -#include "os_malloc.h" +#include "system_malloc.h" -#pragma GLOBAL_ASM("asm/non_matchings/boot/boot_800862E0/SystemArena_MallocMin1.s") +typedef void (*BlockFunc)(void*); +typedef void (*BlockFunc1)(void*, u32); +typedef void (*BlockFunc8)(void*, u32, u32, u32, u32, u32, u32, u32, u32); -#pragma GLOBAL_ASM("asm/non_matchings/boot/boot_800862E0/SystemArena_FreeNull.s") +typedef struct InitFunc { + uintptr_t nextOffset; + void (*func)(void); +} InitFunc; -#pragma GLOBAL_ASM("asm/non_matchings/boot/boot_800862E0/func_8008633C.s") +void* sInitFuncs = NULL; -#pragma GLOBAL_ASM("asm/non_matchings/boot/boot_800862E0/func_800863AC.s") +char sNew[] = { 0x00, 0x00, 0x00, 0x00 }; -#pragma GLOBAL_ASM("asm/non_matchings/boot/boot_800862E0/func_8008641C.s") +char D_80097508[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x80, 0x00, 0x00, + 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, +}; -#pragma GLOBAL_ASM("asm/non_matchings/boot/boot_800862E0/func_800864EC.s") +void* SystemArena_MallocMin1(size_t size) { + if (size == 0) { + size = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/boot/boot_800862E0/func_80086588.s") + return __osMalloc(&gSystemArena, size); +} -#pragma GLOBAL_ASM("asm/non_matchings/boot/boot_800862E0/SystemArena_Init.s") +void SystemArena_FreeNullCheck(void* ptr) { + if (ptr != NULL) { + __osFree(&gSystemArena, ptr); + } +} + +void SystemArena_RunBlockFunc(void* blk, size_t nBlk, size_t blkSize, BlockFunc blockFunc) { + uintptr_t pos = blk; + + for (; pos < (uintptr_t)blk + (nBlk * blkSize); pos += (blkSize & ~0)) { + blockFunc(pos); + } +} + +void SystemArena_RunBlockFunc1(void* blk, size_t nBlk, size_t blkSize, BlockFunc1 blockFunc) { + uintptr_t pos = blk; + + for (; pos < (uintptr_t)blk + (nBlk * blkSize); pos += (blkSize & ~0)) { + blockFunc(pos, 2); + } +} + +void* SystemArena_RunBlockFunc8(void* blk, size_t nBlk, size_t blkSize, BlockFunc8 blockFunc) { + if (blk == NULL) { + blk = SystemArena_MallocMin1(nBlk * blkSize); + } + + if (blk != NULL && blockFunc != NULL) { + uintptr_t pos = blk; + + for (; pos < (uintptr_t)blk + (nBlk * blkSize); pos += (blkSize & ~0)) { + blockFunc(pos, 0, 0, 0, 0, 0, 0, 0, 0); + } + } + + return blk; +} + +void SystemArena_RunBlockFunc1Reverse(void* blk, size_t nBlk, size_t blkSize, BlockFunc1 blockFunc, s32 shouldFree) { + uintptr_t pos; + uintptr_t start; + size_t maskedBlkSize; + + if (blk == NULL) { + return; + } + + if (blockFunc != NULL) { + start = blk; + maskedBlkSize = (blkSize & ~0); + pos = (uintptr_t)start + (nBlk * blkSize); + + while (pos > start) { + pos -= maskedBlkSize; + blockFunc(pos, 2); + } + } + + if (shouldFree) { + SystemArena_FreeNullCheck(blk); + } +} + +void SystemArena_RunInits(void) { + InitFunc* initFunc = (InitFunc*)&sInitFuncs; + u32 nextOffset = initFunc->nextOffset; + InitFunc* prev = NULL; + + while (nextOffset != 0) { + initFunc = (InitFunc*)((uintptr_t)initFunc + nextOffset); + + if (initFunc->func != NULL) { + (*initFunc->func)(); + } + + nextOffset = initFunc->nextOffset; + initFunc->nextOffset = (uintptr_t)prev; + prev = initFunc; + } + + sInitFuncs = prev; +} + +void SystemArena_Init(void* start, size_t size) { + SystemArena_InitArena(start, size); + SystemArena_RunInits(); +} diff --git a/src/boot_O2_g3/idle.c b/src/boot_O2_g3/idle.c index 942435fa7b..da93f13fdb 100644 --- a/src/boot_O2_g3/idle.c +++ b/src/boot_O2_g3/idle.c @@ -1,3 +1,4 @@ +#include "prevent_bss_reordering.h" #include "global.h" u8 D_80096B20 = 1; diff --git a/src/boot_O2_g3/idle_extra_bss.c b/src/boot_O2_g3/idle_extra_bss.c index 019b626405..24fc0083f2 100644 --- a/src/boot_O2_g3/idle_extra_bss.c +++ b/src/boot_O2_g3/idle_extra_bss.c @@ -1,4 +1,5 @@ -#include "global.h" +#include "PR/ultratypes.h" +#include "ultra64/vi.h" // This file is currently required to fix bss reordering in idle.c. It is not resolved by prevent_bss_reordering.h . // Hopefully it will not be permanent. diff --git a/src/boot_O2_g3/yaz0.c b/src/boot_O2_g3/yaz0.c index 5fb32b8eaa..80d819acc1 100644 --- a/src/boot_O2_g3/yaz0.c +++ b/src/boot_O2_g3/yaz0.c @@ -1,4 +1,3 @@ -#include "prevent_bss_reordering.h" #include "global.h" u8 sYaz0DataBuffer[0x400]; @@ -18,7 +17,7 @@ void* Yaz0_FirstDMA() { curSize = (u32)sYaz0CurDataEnd - (u32)sYaz0DataBuffer; dmaSize = (curSize > sYaz0CurSize) ? sYaz0CurSize : curSize; - DmaMgr_DMARomToRam(sYaz0CurRomStart, sYaz0DataBuffer, dmaSize); + DmaMgr_DmaRomToRam(sYaz0CurRomStart, sYaz0DataBuffer, dmaSize); sYaz0CurRomStart += dmaSize; sYaz0CurSize -= dmaSize; return sYaz0DataBuffer; @@ -41,7 +40,7 @@ void* Yaz0_NextDMA(void* curSrcPos) { } if (dmaSize != 0) { - DmaMgr_DMARomToRam(sYaz0CurRomStart, dst + restSize, dmaSize); + DmaMgr_DmaRomToRam(sYaz0CurRomStart, dst + restSize, dmaSize); sYaz0CurRomStart += dmaSize; sYaz0CurSize -= dmaSize; if (!sYaz0CurSize) { diff --git a/src/boot_O2_g3/z_std_dma.c b/src/boot_O2_g3/z_std_dma.c index 9edc65e52c..10d84dcb03 100644 --- a/src/boot_O2_g3/z_std_dma.c +++ b/src/boot_O2_g3/z_std_dma.c @@ -10,7 +10,7 @@ OSMesg sDmaMgrMsgs[32]; OSThread sDmaMgrThread; u8 sDmaMgrStack[0x500]; -s32 DmaMgr_DMARomToRam(uintptr_t rom, void* ram, size_t size) { +s32 DmaMgr_DmaRomToRam(uintptr_t rom, void* ram, size_t size) { OSIoMesg ioMsg; OSMesgQueue queue; OSMesg msg[1]; @@ -56,8 +56,8 @@ END: return ret; } -void DmaMgr_DmaCallback0(OSPiHandle* pihandle, OSIoMesg* mb, s32 direction) { - osEPiStartDma(pihandle, mb, direction); +s32 DmaMgr_DmaHandler(OSPiHandle* pihandle, OSIoMesg* mb, s32 direction) { + return osEPiStartDma(pihandle, mb, direction); } DmaEntry* DmaMgr_FindDmaEntry(u32 vrom) { @@ -130,7 +130,7 @@ void DmaMgr_ProcessMsg(DmaRequest* req) { if (dmaEntry->vromEnd < (vrom + size)) { Fault_AddHungupAndCrash("../z_std_dma.c", 499); } - DmaMgr_DMARomToRam((dmaEntry->romStart + vrom) - dmaEntry->vromStart, (u8*)ram, size); + DmaMgr_DmaRomToRam((dmaEntry->romStart + vrom) - dmaEntry->vromStart, (u8*)ram, size); return; } @@ -211,7 +211,7 @@ s32 DmaMgr_SendRequest0(void* vramStart, uintptr_t vromStart, size_t size) { } void DmaMgr_Start(void) { - DmaMgr_DMARomToRam(SEGMENT_ROM_START(dmadata), dmadata, SEGMENT_ROM_SIZE(dmadata)); + DmaMgr_DmaRomToRam(SEGMENT_ROM_START(dmadata), dmadata, SEGMENT_ROM_SIZE(dmadata)); { DmaEntry* iter = dmadata; diff --git a/src/code/audio/audio_heap.c b/src/code/audio/audio_heap.c index b3d83c1f98..b06f6a5776 100644 --- a/src/code/audio/audio_heap.c +++ b/src/code/audio/audio_heap.c @@ -1,111 +1,1687 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B0F0.s") +void* AudioHeap_SearchRegularCaches(s32 tableType, s32 cache, s32 id); +void AudioHeap_InitSampleCaches(size_t persistentSampleCacheSize, size_t temporarySampleCacheSize); +SampleCacheEntry* AudioHeap_AllocTemporarySampleCacheEntry(size_t size); +void AudioHeap_DiscardSampleCacheEntry(SampleCacheEntry* entry); +void AudioHeap_UnapplySampleCache(SampleCacheEntry* entry, SoundFontSample* sample); +SampleCacheEntry* AudioHeap_AllocPersistentSampleCacheEntry(size_t size); +void AudioHeap_DiscardSampleCaches(void); +void AudioHeap_DiscardSampleBank(s32 sampleBankId); +void AudioHeap_ApplySampleBankCacheInternal(s32 apply, s32 sampleBankId); +void AudioHeap_DiscardSampleBanks(void); +void AudioHeap_InitReverb(s32 reverbIndex, ReverbSettings* settings, s32 flags); -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B10C.s") +#define gTatumsPerBeat (gAudioTatumInit[1]) -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B250.s") +f32 func_8018B0F0(f32 arg0) { + return 256.0f * gAudioContext.audioBufferParameters.unkUpdatesPerFrameScaled / arg0; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B318.s") +void func_8018B10C(void) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B3FC.s") + gAudioContext.unk_3520[255] = func_8018B0F0(0.25f); + gAudioContext.unk_3520[254] = func_8018B0F0(0.33f); + gAudioContext.unk_3520[253] = func_8018B0F0(0.5f); + gAudioContext.unk_3520[252] = func_8018B0F0(0.66f); + gAudioContext.unk_3520[251] = func_8018B0F0(0.75f); -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B474.s") + for (i = 128; i < 251; i++) { + gAudioContext.unk_3520[i] = func_8018B0F0(251 - i); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B4F8.s") + for (i = 16; i < 128; i++) { + gAudioContext.unk_3520[i] = func_8018B0F0(4 * (143 - i)); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B520.s") + for (i = 1; i < 16; i++) { + gAudioContext.unk_3520[i] = func_8018B0F0(60 * (23 - i)); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B578.s") + gAudioContext.unk_3520[0] = 0.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/AudioHeap_AllocDmaMemory.s") +void AudioHeap_ResetLoadStatus(void) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B608.s") + for (i = 0; i < ARRAY_COUNT(gAudioContext.fontLoadStatus); i++) { + if (gAudioContext.fontLoadStatus[i] != LOAD_STATUS_5) { + gAudioContext.fontLoadStatus[i] = LOAD_STATUS_0; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B640.s") + for (i = 0; i < ARRAY_COUNT(gAudioContext.sampleFontLoadStatus); i++) { + if (gAudioContext.sampleFontLoadStatus[i] != LOAD_STATUS_5) { + gAudioContext.sampleFontLoadStatus[i] = LOAD_STATUS_0; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B69C.s") + for (i = 0; i < ARRAY_COUNT(gAudioContext.seqLoadStatus); i++) { + if (gAudioContext.seqLoadStatus[i] != LOAD_STATUS_5) { + gAudioContext.seqLoadStatus[i] = LOAD_STATUS_0; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B6E8.s") +void AudioHeap_DiscardFont(s32 fontId) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B740.s") + for (i = 0; i < gAudioContext.numNotes; i++) { + Note* note = &gAudioContext.notes[i]; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B768.s") + if (note->playbackState.fontId == fontId) { + if ((note->playbackState.unk_04 == 0) && (note->playbackState.priority != 0)) { + note->playbackState.parentLayer->enabled = false; + note->playbackState.parentLayer->finished = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B77C.s") + AudioPlayback_NoteDisable(note); + AudioPlayback_AudioListRemove(¬e->listItem); + AudioSeq_AudioListPushBack(&gAudioContext.noteFreeLists.disabled, ¬e->listItem); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B7AC.s") +void AudioHeap_ReleaseNotesForFont(s32 fontId) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B7BC.s") + for (i = 0; i < gAudioContext.numNotes; i++) { + Note* note = &gAudioContext.notes[i]; + NotePlaybackState* playbackState = ¬e->playbackState; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B8FC.s") + if (playbackState->fontId == fontId) { + if (playbackState->priority != 0) { + playbackState->priority = 1; + playbackState->adsr.fadeOutVel = gAudioContext.audioBufferParameters.updatesPerFrameInv; + playbackState->adsr.action.s.release = true; + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B95C.s") +void AudioHeap_DiscardSequence(s32 seqId) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B9E0.s") + for (i = 0; i < gAudioContext.audioBufferParameters.numSequencePlayers; i++) { + if (gAudioContext.seqPlayers[i].enabled && gAudioContext.seqPlayers[i].seqId == seqId) { + AudioSeq_SequencePlayerDisable(&gAudioContext.seqPlayers[i]); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018BA64.s") +/** + * Perform a writeback from the L1 data cache to the ram. + */ +void* AudioHeap_WritebackDCache(void* addr, size_t size) { + Audio_WritebackDCache(addr, size); + if (addr) {} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018BB28.s") + // KSEG0 to KSEG1 (ensures data is written straight to ram instead of the data cache) + return OS_PHYSICAL_TO_K1(OS_K0_TO_PHYSICAL(addr)); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018BBEC.s") +/** + * Attempt to allocated space on an external device. If no external device is available, + * then allocate space on the pool provided in the argument. + * Afterwards, zero all data pool the new allocated space + */ +void* AudioHeap_AllocZeroedAttemptExternal(AudioAllocPool* pool, size_t size) { + void* addr = NULL; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018C380.s") + if (gAudioContext.externalPool.startAddr != NULL) { + addr = AudioHeap_AllocZeroed(&gAudioContext.externalPool, size); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018C3D8.s") + if (addr == NULL) { + addr = AudioHeap_AllocZeroed(pool, size); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018C4E4.s") + return addr; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018C8B8.s") +/** + * Attempt to allocated space on an external device. If no external device is available, + * then allocate space on the pool provided in the argument + */ +void* AudioHeap_AllocAttemptExternal(AudioAllocPool* pool, size_t size) { + void* addr = NULL; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018C8E8.s") + if (gAudioContext.externalPool.startAddr != NULL) { + addr = AudioHeap_Alloc(&gAudioContext.externalPool, size); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018C93C.s") + if (addr == NULL) { + addr = AudioHeap_Alloc(pool, size); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018C994.s") + return addr; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018CB70.s") +void* AudioHeap_AllocDmaMemory(AudioAllocPool* pool, size_t size) { + void* addr = AudioHeap_Alloc(pool, size); -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018CB78.s") + if (addr != NULL) { + addr = AudioHeap_WritebackDCache(addr, size); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018CC3C.s") + return addr; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018CCA8.s") +void* AudioHeap_AllocDmaMemoryZeroed(AudioAllocPool* pool, size_t size) { + void* addr = AudioHeap_AllocZeroed(pool, size); -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018CFAC.s") + if (addr != NULL) { + addr = AudioHeap_WritebackDCache(addr, size); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018D57C.s") + return addr; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018D5D4.s") +/** + * Allocates space on a pool contained withing the heap and sets all the allocated space to 0 + */ +void* AudioHeap_AllocZeroed(AudioAllocPool* pool, size_t size) { + u8* addr = AudioHeap_Alloc(pool, size); + u8* ptr; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018D658.s") + if (addr != NULL) { + for (ptr = addr; ptr < pool->curAddr; ptr++) { + *ptr = 0; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018D6C8.s") + return addr; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018D760.s") +/** + * Tests the pool to see if the requested allocation would fit without actually allocating space. + * Returns NULL if there is not enough space on the pool. + * Else, return the address that would have been allocated + */ +void* AudioHeap_TestAlloc(AudioAllocPool* pool, size_t size) { + u8* oldAddr = pool->curAddr; + void* addr = AudioHeap_Alloc(pool, size); -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018DA50.s") + // remove allocation from pool + if (addr != NULL) { + pool->curAddr = oldAddr; + pool->count--; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018DBC4.s") + return addr; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018DCB4.s") +/** + * Allocates space on the pool contained withing the heap. If there is not enough space on the pool, return NULL + */ +void* AudioHeap_Alloc(AudioAllocPool* pool, size_t size) { + size_t alignedSize = ALIGN16(size); + u8* curAddr = pool->curAddr; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018DCF8.s") + if ((pool->startAddr + pool->size) >= (pool->curAddr + alignedSize)) { + pool->curAddr += alignedSize; + } else { + return NULL; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018DD98.s") + pool->count++; + return curAddr; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018DDD4.s") +/** + * Initialize a pool at the requested address with the requested size. + * Store the metadata of this pool in AudioAllocPool* pool + */ +void AudioHeap_AllocPoolInit(AudioAllocPool* pool, void* addr, size_t size) { + pool->curAddr = pool->startAddr = (u8*)ALIGN16((uintptr_t)addr); + pool->size = size - ((uintptr_t)addr & 0xF); + pool->count = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018DF24.s") +void AudioHeap_ClearPersistentCache(AudioPersistentCache* persistent) { + persistent->pool.count = 0; + persistent->numEntries = 0; + persistent->pool.curAddr = persistent->pool.startAddr; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018DFE0.s") +void AudioHeap_ClearTemporaryCache(AudioTemporaryCache* temporary) { + temporary->pool.count = 0; + temporary->pool.curAddr = temporary->pool.startAddr; + temporary->nextSide = 0; + temporary->entries[0].addr = temporary->pool.startAddr; + temporary->entries[1].addr = temporary->pool.startAddr + temporary->pool.size; + temporary->entries[0].id = -1; + temporary->entries[1].id = -1; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018E00C.s") +void AudioHeap_ResetPool(AudioAllocPool* pool) { + pool->count = 0; + pool->curAddr = pool->startAddr; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018E03C.s") +void AudioHeap_PopCache(s32 tableType) { + AudioCache* loadedCache; + AudioAllocPool* persistentHeap; + AudioPersistentCache* persistent; + void* entryAddr; + u8* loadStatus; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018E2A8.s") + switch (tableType) { + case SEQUENCE_TABLE: + loadedCache = &gAudioContext.seqCache; + loadStatus = gAudioContext.seqLoadStatus; + break; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018E344.s") + case FONT_TABLE: + loadedCache = &gAudioContext.fontCache; + loadStatus = gAudioContext.fontLoadStatus; + break; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018E8C8.s") + case SAMPLE_TABLE: + loadedCache = &gAudioContext.sampleBankCache; + loadStatus = gAudioContext.sampleFontLoadStatus; + break; + } + + persistent = &loadedCache->persistent; + persistentHeap = &persistent->pool; + + if (persistent->numEntries == 0) { + return; + } + + entryAddr = persistent->entries[persistent->numEntries - 1].addr; + persistentHeap->curAddr = entryAddr; + persistentHeap->count--; + + if (tableType == SAMPLE_TABLE) { + AudioHeap_DiscardSampleBank(persistent->entries[persistent->numEntries - 1].id); + } + if (tableType == FONT_TABLE) { + AudioHeap_DiscardFont(persistent->entries[persistent->numEntries - 1].id); + } + + loadStatus[persistent->entries[persistent->numEntries - 1].id] = LOAD_STATUS_0; + persistent->numEntries--; +} + +void AudioHeap_InitMainPool(size_t mainPoolSplitSize) { + AudioHeap_AllocPoolInit(&gAudioContext.audioInitPool, gAudioContext.audioHeap, mainPoolSplitSize); + AudioHeap_AllocPoolInit(&gAudioContext.audioSessionPool, gAudioContext.audioHeap + mainPoolSplitSize, + gAudioContext.audioHeapSize - mainPoolSplitSize); + + gAudioContext.externalPool.startAddr = NULL; +} + +void AudioHeap_InitSessionPool(AudioSessionPoolSplit* split) { + gAudioContext.audioSessionPool.curAddr = gAudioContext.audioSessionPool.startAddr; + + AudioHeap_AllocPoolInit(&gAudioContext.miscPool, + AudioHeap_Alloc(&gAudioContext.audioSessionPool, split->miscPoolSize), split->miscPoolSize); + AudioHeap_AllocPoolInit(&gAudioContext.cachePool, + AudioHeap_Alloc(&gAudioContext.audioSessionPool, split->cachePoolSize), + split->cachePoolSize); +} + +void AudioHeap_InitCachePool(AudioCachePoolSplit* split) { + gAudioContext.cachePool.curAddr = gAudioContext.cachePool.startAddr; + + AudioHeap_AllocPoolInit(&gAudioContext.persistentCommonPool, + AudioHeap_Alloc(&gAudioContext.cachePool, split->persistentCommonPoolSize), + split->persistentCommonPoolSize); + AudioHeap_AllocPoolInit(&gAudioContext.temporaryCommonPool, + AudioHeap_Alloc(&gAudioContext.cachePool, split->temporaryCommonPoolSize), + split->temporaryCommonPoolSize); +} + +void AudioHeap_InitPersistentCache(AudioCommonPoolSplit* split) { + gAudioContext.persistentCommonPool.curAddr = gAudioContext.persistentCommonPool.startAddr; + + AudioHeap_AllocPoolInit(&gAudioContext.seqCache.persistent.pool, + AudioHeap_Alloc(&gAudioContext.persistentCommonPool, split->seqCacheSize), + split->seqCacheSize); + AudioHeap_AllocPoolInit(&gAudioContext.fontCache.persistent.pool, + AudioHeap_Alloc(&gAudioContext.persistentCommonPool, split->fontCacheSize), + split->fontCacheSize); + AudioHeap_AllocPoolInit(&gAudioContext.sampleBankCache.persistent.pool, + AudioHeap_Alloc(&gAudioContext.persistentCommonPool, split->sampleBankCacheSize), + split->sampleBankCacheSize); + + AudioHeap_ClearPersistentCache(&gAudioContext.seqCache.persistent); + AudioHeap_ClearPersistentCache(&gAudioContext.fontCache.persistent); + AudioHeap_ClearPersistentCache(&gAudioContext.sampleBankCache.persistent); +} + +void AudioHeap_InitTemporaryCache(AudioCommonPoolSplit* split) { + gAudioContext.temporaryCommonPool.curAddr = gAudioContext.temporaryCommonPool.startAddr; + + AudioHeap_AllocPoolInit(&gAudioContext.seqCache.temporary.pool, + AudioHeap_Alloc(&gAudioContext.temporaryCommonPool, split->seqCacheSize), + split->seqCacheSize); + AudioHeap_AllocPoolInit(&gAudioContext.fontCache.temporary.pool, + AudioHeap_Alloc(&gAudioContext.temporaryCommonPool, split->fontCacheSize), + split->fontCacheSize); + AudioHeap_AllocPoolInit(&gAudioContext.sampleBankCache.temporary.pool, + AudioHeap_Alloc(&gAudioContext.temporaryCommonPool, split->sampleBankCacheSize), + split->sampleBankCacheSize); + + AudioHeap_ClearTemporaryCache(&gAudioContext.seqCache.temporary); + AudioHeap_ClearTemporaryCache(&gAudioContext.fontCache.temporary); + AudioHeap_ClearTemporaryCache(&gAudioContext.sampleBankCache.temporary); +} + +void* AudioHeap_AllocCached(s32 tableType, size_t size, s32 cache, s32 id) { + AudioCache* loadedCache; + AudioTemporaryCache* temporaryCache; + AudioAllocPool* temporaryPool; + void* persistentAddr; + void* temporaryAddr; + u8 loadStatusEntry0; + u8 loadStatusEntry1; + s32 i; + u8* loadStatus; + s32 side; + + switch (tableType) { + case SEQUENCE_TABLE: + loadedCache = &gAudioContext.seqCache; + loadStatus = gAudioContext.seqLoadStatus; + break; + + case FONT_TABLE: + loadedCache = &gAudioContext.fontCache; + loadStatus = gAudioContext.fontLoadStatus; + break; + + case SAMPLE_TABLE: + loadedCache = &gAudioContext.sampleBankCache; + loadStatus = gAudioContext.sampleFontLoadStatus; + break; + } + + if (cache == CACHE_TEMPORARY) { + temporaryCache = &loadedCache->temporary; + temporaryPool = &temporaryCache->pool; + + if ((s32)temporaryPool->size < (s32)size) { + return NULL; + } + + loadStatusEntry0 = + (temporaryCache->entries[0].id == -1) ? LOAD_STATUS_0 : loadStatus[temporaryCache->entries[0].id]; + loadStatusEntry1 = + (temporaryCache->entries[1].id == -1) ? LOAD_STATUS_0 : loadStatus[temporaryCache->entries[1].id]; + + if (tableType == FONT_TABLE) { + if (loadStatusEntry0 == LOAD_STATUS_4) { + for (i = 0; i < gAudioContext.numNotes; i++) { + if ((gAudioContext.notes[i].playbackState.fontId == temporaryCache->entries[0].id) && + gAudioContext.notes[i].noteSubEu.bitField0.enabled) { + break; + } + } + + if (i == gAudioContext.numNotes) { + AudioLoad_SetFontLoadStatus(temporaryCache->entries[0].id, LOAD_STATUS_3); + loadStatusEntry0 = LOAD_STATUS_3; + } + } + + if (loadStatusEntry1 == LOAD_STATUS_4) { + for (i = 0; i < gAudioContext.numNotes; i++) { + if ((gAudioContext.notes[i].playbackState.fontId == temporaryCache->entries[1].id) && + gAudioContext.notes[i].noteSubEu.bitField0.enabled) { + break; + } + } + + if (i == gAudioContext.numNotes) { + AudioLoad_SetFontLoadStatus(temporaryCache->entries[1].id, LOAD_STATUS_3); + loadStatusEntry1 = LOAD_STATUS_3; + } + } + } + + if (loadStatusEntry0 == LOAD_STATUS_0) { + temporaryCache->nextSide = 0; + } else if (loadStatusEntry1 == LOAD_STATUS_0) { + temporaryCache->nextSide = 1; + } else if ((loadStatusEntry0 == LOAD_STATUS_3) && (loadStatusEntry1 == LOAD_STATUS_3)) { + // Use the opposite side from last time. + } else if (loadStatusEntry0 == LOAD_STATUS_3) { + temporaryCache->nextSide = 0; + } else if (loadStatusEntry1 == LOAD_STATUS_3) { + temporaryCache->nextSide = 1; + } else { + // Check if there is a side which isn't in active use, if so, evict that one. + if (tableType == SEQUENCE_TABLE) { + if (loadStatusEntry0 == LOAD_STATUS_2) { + for (i = 0; i < gAudioContext.audioBufferParameters.numSequencePlayers; i++) { + if (gAudioContext.seqPlayers[i].enabled && + gAudioContext.seqPlayers[i].seqId == temporaryCache->entries[0].id) { + break; + } + } + + if (i == gAudioContext.audioBufferParameters.numSequencePlayers) { + temporaryCache->nextSide = 0; + goto done; + } + } + + if (loadStatusEntry1 == LOAD_STATUS_2) { + for (i = 0; i < gAudioContext.audioBufferParameters.numSequencePlayers; i++) { + if (gAudioContext.seqPlayers[i].enabled && + gAudioContext.seqPlayers[i].seqId == temporaryCache->entries[1].id) { + break; + } + } + + if (i == gAudioContext.audioBufferParameters.numSequencePlayers) { + temporaryCache->nextSide = 1; + goto done; + } + } + } else if (tableType == FONT_TABLE) { + if (loadStatusEntry0 == LOAD_STATUS_2) { + for (i = 0; i < gAudioContext.numNotes; i++) { + if ((gAudioContext.notes[i].playbackState.fontId == temporaryCache->entries[0].id) && + gAudioContext.notes[i].noteSubEu.bitField0.enabled) { + break; + } + } + if (i == gAudioContext.numNotes) { + temporaryCache->nextSide = 0; + goto done; + } + } + + if (loadStatusEntry1 == LOAD_STATUS_2) { + for (i = 0; i < gAudioContext.numNotes; i++) { + if ((gAudioContext.notes[i].playbackState.fontId == temporaryCache->entries[1].id) && + gAudioContext.notes[i].noteSubEu.bitField0.enabled) { + break; + } + } + if (i == gAudioContext.numNotes) { + temporaryCache->nextSide = 1; + goto done; + } + } + } + + // No such luck. Evict the side that wasn't chosen last time, except + // if it is being loaded into. + if (temporaryCache->nextSide == 0) { + if (loadStatusEntry0 == LOAD_STATUS_1) { + if (loadStatusEntry1 == LOAD_STATUS_1) { + goto fail; + } + temporaryCache->nextSide = 1; + } + } else { + if (loadStatusEntry1 == LOAD_STATUS_1) { + if (loadStatusEntry0 == LOAD_STATUS_1) { + goto fail; + } + temporaryCache->nextSide = 0; + } + } + + if (0) { + fail: + // Both sides are being loaded into. + return NULL; + } + } + done: + + side = temporaryCache->nextSide; + + if (temporaryCache->entries[side].id != -1) { + if (tableType == SAMPLE_TABLE) { + AudioHeap_DiscardSampleBank(temporaryCache->entries[side].id); + } + + loadStatus[temporaryCache->entries[side].id] = LOAD_STATUS_0; + + if (tableType == FONT_TABLE) { + AudioHeap_DiscardFont(temporaryCache->entries[side].id); + } + } + + switch (side) { + case 0: + temporaryCache->entries[0].addr = temporaryPool->startAddr; + temporaryCache->entries[0].id = id; + temporaryCache->entries[0].size = size; + temporaryPool->curAddr = temporaryPool->startAddr + size; + + if ((temporaryCache->entries[1].id != -1) && + (temporaryCache->entries[1].addr < temporaryPool->curAddr)) { + if (tableType == SAMPLE_TABLE) { + AudioHeap_DiscardSampleBank(temporaryCache->entries[1].id); + } + + loadStatus[temporaryCache->entries[1].id] = LOAD_STATUS_0; + + switch (tableType) { + case SEQUENCE_TABLE: + AudioHeap_DiscardSequence((s32)temporaryCache->entries[1].id); + break; + + case FONT_TABLE: + AudioHeap_DiscardFont((s32)temporaryCache->entries[1].id); + break; + } + + temporaryCache->entries[1].id = -1; + temporaryCache->entries[1].addr = temporaryPool->startAddr + temporaryPool->size; + } + + temporaryAddr = temporaryCache->entries[0].addr; + break; + + case 1: + temporaryCache->entries[1].addr = + (u8*)((uintptr_t)(temporaryPool->startAddr + temporaryPool->size - size) & ~0xF); + temporaryCache->entries[1].id = id; + temporaryCache->entries[1].size = size; + if ((temporaryCache->entries[0].id != -1) && + (temporaryCache->entries[1].addr < temporaryPool->curAddr)) { + if (tableType == SAMPLE_TABLE) { + AudioHeap_DiscardSampleBank(temporaryCache->entries[0].id); + } + + loadStatus[temporaryCache->entries[0].id] = LOAD_STATUS_0; + + switch (tableType) { + case SEQUENCE_TABLE: + AudioHeap_DiscardSequence(temporaryCache->entries[0].id); + break; + + case FONT_TABLE: + AudioHeap_DiscardFont(temporaryCache->entries[0].id); + break; + } + + temporaryCache->entries[0].id = -1; + temporaryPool->curAddr = temporaryPool->startAddr; + } + + temporaryAddr = temporaryCache->entries[1].addr; + break; + + default: + return NULL; + } + + temporaryCache->nextSide ^= 1; + return temporaryAddr; + } + + persistentAddr = AudioHeap_Alloc(&loadedCache->persistent.pool, size); + loadedCache->persistent.entries[loadedCache->persistent.numEntries].addr = persistentAddr; + + if (persistentAddr == NULL) { + switch (cache) { + case CACHE_EITHER: + return AudioHeap_AllocCached(tableType, size, CACHE_TEMPORARY, id); + + case CACHE_TEMPORARY: + case CACHE_PERSISTENT: + return NULL; + } + } + + loadedCache->persistent.entries[loadedCache->persistent.numEntries].id = id; + loadedCache->persistent.entries[loadedCache->persistent.numEntries].size = size; + + return loadedCache->persistent.entries[loadedCache->persistent.numEntries++].addr; +} + +void* AudioHeap_SearchCaches(s32 tableType, s32 cache, s32 id) { + void* addr; + + // Always search the permanent cache in addition to the regular ones. + addr = AudioHeap_SearchPermanentCache(tableType, id); + if (addr != NULL) { + return addr; + } + if (cache == CACHE_PERMANENT) { + return NULL; + } + return AudioHeap_SearchRegularCaches(tableType, cache, id); +} + +void* AudioHeap_SearchRegularCaches(s32 tableType, s32 cache, s32 id) { + u32 i; + AudioCache* loadedCache; + AudioTemporaryCache* temporary; + AudioPersistentCache* persistent; + + switch (tableType) { + case SEQUENCE_TABLE: + loadedCache = &gAudioContext.seqCache; + break; + + case FONT_TABLE: + loadedCache = &gAudioContext.fontCache; + break; + + case SAMPLE_TABLE: + loadedCache = &gAudioContext.sampleBankCache; + break; + } + + temporary = &loadedCache->temporary; + + if (cache == CACHE_TEMPORARY) { + if (temporary->entries[0].id == id) { + temporary->nextSide = 1; + return temporary->entries[0].addr; + } else if (temporary->entries[1].id == id) { + temporary->nextSide = 0; + return temporary->entries[1].addr; + } else { + return NULL; + } + } + + persistent = &loadedCache->persistent; + + for (i = 0; i < persistent->numEntries; i++) { + if (persistent->entries[i].id == id) { + return persistent->entries[i].addr; + } + } + + if (cache == CACHE_EITHER) { + return AudioHeap_SearchCaches(tableType, CACHE_TEMPORARY, id); + } + return NULL; +} + +void func_8018C4E4(f32 p, f32 q, u16* out) { + // With the bug below fixed, this mysterious unused function computes two recurrences + // out[0..7] = a_i, out[8..15] = b_i, where + // a_{-2} = b_{-1} = 262159 = 2^18 + 15 + // a_{-1} = b_{-2} = 0 + // a_i = q * a_{i-1} + p * a_{i-2} + // b_i = q * b_{i-1} + p * b_{i-2} + // These grow exponentially if p < -1 or p + |q| > 1. + s32 i; + f32 tmp[16]; + + tmp[0] = (f32)(q * 262159.0f); + tmp[8] = (f32)(p * 262159.0f); + tmp[1] = (f32)((q * p) * 262159.0f); + tmp[9] = (f32)(((p * p) + q) * 262159.0f); + + for (i = 2; i < 8; i++) { + //! @bug value should be stored to tmp[i] and tmp[8 + i], otherwise we read + //! garbage in later loop iterations. + out[i] = q * tmp[i - 2] + p * tmp[i - 1]; + out[8 + i] = q * tmp[6 + i] + p * tmp[7 + i]; + } + + for (i = 0; i < 16; i++) { + out[i] = tmp[i]; + } +} + +void AudioHeap_ClearFilter(s16* filter) { + s32 i; + + for (i = 0; i < 8; i++) { + filter[i] = 0; + } +} + +void AudioHeap_LoadLowPassFilter(s16* filter, s32 cutoff) { + s32 i; + s16* ptr = &gLowPassFilterData[8 * cutoff]; + + for (i = 0; i < 8; i++) { + filter[i] = ptr[i]; + } +} + +void AudioHeap_LoadHighPassFilter(s16* filter, s32 cutoff) { + s32 i; + s16* ptr = &gHighPassFilterData[8 * (cutoff - 1)]; + + for (i = 0; i < 8; i++) { + filter[i] = ptr[i]; + } +} + +void AudioHeap_LoadFilter(s16* filter, s32 lowPassCutoff, s32 highPassCutoff) { + s32 i; + s32 j; + s32 k; + s32 cutOff; + + //! @bug filter is never set if (lowPassCutoff == highPassCutoff) and does not equal 0 + if (lowPassCutoff == 0 && highPassCutoff == 0) { + // Identity filter + AudioHeap_LoadLowPassFilter(filter, 0); + } else if (highPassCutoff == 0) { + AudioHeap_LoadLowPassFilter(filter, lowPassCutoff); + } else if (lowPassCutoff == 0) { + AudioHeap_LoadHighPassFilter(filter, highPassCutoff); + } else { + k = 0; + j = 14; + + cutOff = lowPassCutoff; + if (lowPassCutoff < highPassCutoff) { + + for (i = 1; i < cutOff; i++) { + k += j; + j--; + } + + k += highPassCutoff - lowPassCutoff - 1; + for (i = 0; i < 8; i++) { + //! @bug should be gBandStopFilterData[8 * k + i]; + filter[i] = gBandStopFilterData[k + i]; + } + } else if (highPassCutoff < lowPassCutoff) { + + cutOff = highPassCutoff; + for (i = 1; i < cutOff; i++) { + k += j; + j--; + } + + k += lowPassCutoff - highPassCutoff - 1; + for (i = 0; i < 8; i++) { + //! @bug should be gBandPassFilterData[8 * k + i]; + filter[i] = gBandPassFilterData[k + i]; + } + } + } +} + +void AudioHeap_UpdateReverb(SynthesisReverb* reverb) { +} + +void AudioHeap_UpdateReverbs(void) { + s32 count; + s32 i; + s32 j; + + if (gAudioContext.audioBufferParameters.specUnk4 == 2) { + count = 2; + } else { + count = 1; + } + + for (i = 0; i < gAudioContext.numSynthesisReverbs; i++) { + for (j = 0; j < count; j++) { + AudioHeap_UpdateReverb(&gAudioContext.synthesisReverbs[i]); + } + } +} + +/** + * Clear the Audio Interface Buffers + */ +void AudioHeap_ClearAiBuffers(void) { + s32 curAiBuffferIndex = gAudioContext.curAiBuffferIndex; + s32 i; + + gAudioContext.aiBufLengths[curAiBuffferIndex] = gAudioContext.audioBufferParameters.minAiBufferLength; + + for (i = 0; i < AIBUF_LEN; i++) { + gAudioContext.aiBuffers[curAiBuffferIndex][i] = 0; + } +} + +s32 AudioHeap_ResetStep(void) { + s32 i; + s32 j; + s32 count; + + if (gAudioContext.audioBufferParameters.specUnk4 == 2) { + count = 2; + } else { + count = 1; + } + + switch (gAudioContext.resetStatus) { + case 5: + for (i = 0; i < gAudioContext.audioBufferParameters.numSequencePlayers; i++) { + AudioSeq_SequencePlayerDisableAsFinished(&gAudioContext.seqPlayers[i]); + } + gAudioContext.audioResetFadeOutFramesLeft = 2 / count; + gAudioContext.resetStatus--; + break; + + case 4: + if (gAudioContext.audioResetFadeOutFramesLeft != 0) { + gAudioContext.audioResetFadeOutFramesLeft--; + AudioHeap_UpdateReverbs(); + } else { + for (i = 0; i < gAudioContext.numNotes; i++) { + if (gAudioContext.notes[i].noteSubEu.bitField0.enabled && + gAudioContext.notes[i].playbackState.adsr.action.s.state != ADSR_STATE_DISABLED) { + gAudioContext.notes[i].playbackState.adsr.fadeOutVel = + gAudioContext.audioBufferParameters.updatesPerFrameInv; + gAudioContext.notes[i].playbackState.adsr.action.s.release = true; + } + } + gAudioContext.audioResetFadeOutFramesLeft = 8 / count; + gAudioContext.resetStatus--; + } + break; + + case 3: + if (gAudioContext.audioResetFadeOutFramesLeft != 0) { + gAudioContext.audioResetFadeOutFramesLeft--; + AudioHeap_UpdateReverbs(); + } else { + gAudioContext.audioResetFadeOutFramesLeft = 2 / count; + gAudioContext.resetStatus--; + } + break; + + case 2: + AudioHeap_ClearAiBuffers(); + if (gAudioContext.audioResetFadeOutFramesLeft != 0) { + gAudioContext.audioResetFadeOutFramesLeft--; + } else { + gAudioContext.resetStatus--; + AudioHeap_DiscardSampleCaches(); + AudioHeap_DiscardSampleBanks(); + } + break; + + case 1: + AudioHeap_Init(); + gAudioContext.resetStatus = 0; + for (i = 0; i < ARRAY_COUNT(gAudioContext.aiBufLengths); i++) { + gAudioContext.aiBufLengths[i] = gAudioContext.audioBufferParameters.maxAiBufferLength; + for (j = 0; j < AIBUF_LEN; j++) { + gAudioContext.aiBuffers[i][j] = 0; + } + } + break; + } + + if (gAudioContext.resetStatus < 3) { + return false; + } + + return true; +} + +void AudioHeap_Init(void) { + s32 pad1[4]; + s16* addr; + size_t persistentSize; + size_t temporarySize; + size_t cachePoolSize; + size_t miscPoolSize; + u32 intMask; + s32 i; + s32 j; + s32 pad2; + AudioSpec* spec = &gAudioSpecs[gAudioContext.audioResetSpecIdToLoad]; // Audio Specifications + + gAudioContext.sampleDmaCount = 0; + + // audio buffer parameters + gAudioContext.audioBufferParameters.samplingFreq = spec->samplingFreq; + gAudioContext.audioBufferParameters.aiSamplingFreq = + osAiSetFrequency(gAudioContext.audioBufferParameters.samplingFreq); + + gAudioContext.audioBufferParameters.samplesPerFrameTarget = + ALIGN16(gAudioContext.audioBufferParameters.samplingFreq / gAudioContext.refreshRate); + gAudioContext.audioBufferParameters.minAiBufferLength = + gAudioContext.audioBufferParameters.samplesPerFrameTarget - 0x10; + gAudioContext.audioBufferParameters.maxAiBufferLength = + gAudioContext.audioBufferParameters.samplesPerFrameTarget + 0x10; + gAudioContext.audioBufferParameters.updatesPerFrame = + ((gAudioContext.audioBufferParameters.samplesPerFrameTarget + 0x10) / 0xD0) + 1; + gAudioContext.audioBufferParameters.samplesPerUpdate = (gAudioContext.audioBufferParameters.samplesPerFrameTarget / + gAudioContext.audioBufferParameters.updatesPerFrame) & + ~7; + gAudioContext.audioBufferParameters.samplesPerUpdateMax = gAudioContext.audioBufferParameters.samplesPerUpdate + 8; + gAudioContext.audioBufferParameters.samplesPerUpdateMin = gAudioContext.audioBufferParameters.samplesPerUpdate - 8; + gAudioContext.audioBufferParameters.resampleRate = 32000.0f / (s32)gAudioContext.audioBufferParameters.samplingFreq; + gAudioContext.audioBufferParameters.unkUpdatesPerFrameScaled = + (1.0f / 256.0f) / gAudioContext.audioBufferParameters.updatesPerFrame; + gAudioContext.audioBufferParameters.unk_24 = gAudioContext.audioBufferParameters.updatesPerFrame * 0.25f; + gAudioContext.audioBufferParameters.updatesPerFrameInv = 1.0f / gAudioContext.audioBufferParameters.updatesPerFrame; + + // sample dma size + gAudioContext.sampleDmaBufSize1 = spec->sampleDmaBufSize1; + gAudioContext.sampleDmaBufSize2 = spec->sampleDmaBufSize2; + + gAudioContext.numNotes = spec->numNotes; + gAudioContext.audioBufferParameters.numSequencePlayers = spec->numSequencePlayers; + + if (gAudioContext.audioBufferParameters.numSequencePlayers > 5) { + gAudioContext.audioBufferParameters.numSequencePlayers = 5; + } + + gAudioContext.unk_29BC = 8; + gAudioContext.unk_2 = spec->unk_14; + gAudioContext.tempoInternalToExternal = (u32)(gAudioContext.audioBufferParameters.updatesPerFrame * 2880000.0f / + gTatumsPerBeat / gAudioContext.unk_2960); + + gAudioContext.unk_2870 = gAudioContext.refreshRate; + gAudioContext.unk_2870 *= gAudioContext.audioBufferParameters.updatesPerFrame; + gAudioContext.unk_2870 /= gAudioContext.audioBufferParameters.aiSamplingFreq; + gAudioContext.unk_2870 /= gAudioContext.tempoInternalToExternal; + + gAudioContext.audioBufferParameters.specUnk4 = spec->unk_04; + gAudioContext.audioBufferParameters.samplesPerFrameTarget *= gAudioContext.audioBufferParameters.specUnk4; + gAudioContext.audioBufferParameters.maxAiBufferLength *= gAudioContext.audioBufferParameters.specUnk4; + gAudioContext.audioBufferParameters.minAiBufferLength *= gAudioContext.audioBufferParameters.specUnk4; + gAudioContext.audioBufferParameters.updatesPerFrame *= gAudioContext.audioBufferParameters.specUnk4; + + if (gAudioContext.audioBufferParameters.specUnk4 >= 2) { + gAudioContext.audioBufferParameters.maxAiBufferLength -= 0x10; + } + + // Determine the maximum allowable number of audio command list entries for the rsp microcode + gAudioContext.maxAudioCmds = + gAudioContext.numNotes * 20 * gAudioContext.audioBufferParameters.updatesPerFrame + spec->numReverbs * 30 + 800; + + // Calculate sizes for various caches on the audio heap + persistentSize = + spec->persistentSeqCacheSize + spec->persistentFontCacheSize + spec->persistentSampleBankCacheSize + 0x10; + temporarySize = + spec->temporarySeqCacheSize + spec->temporaryFontCacheSize + spec->temporarySampleBankCacheSize + 0x10; + cachePoolSize = persistentSize + temporarySize; + miscPoolSize = gAudioContext.audioSessionPool.size - cachePoolSize - 0x100; + + if (gAudioContext.externalPool.startAddr != NULL) { + gAudioContext.externalPool.curAddr = gAudioContext.externalPool.startAddr; + } + + // Session Pool Split (split into Cache and Misc heaps) + gAudioContext.sessionPoolSplit.miscPoolSize = miscPoolSize; + gAudioContext.sessionPoolSplit.cachePoolSize = cachePoolSize; + AudioHeap_InitSessionPool(&gAudioContext.sessionPoolSplit); + + // Cache Pool Split (Split into Persistent and Temporary heaps) + gAudioContext.cachePoolSplit.persistentCommonPoolSize = persistentSize; + gAudioContext.cachePoolSplit.temporaryCommonPoolSize = temporarySize; + AudioHeap_InitCachePool(&gAudioContext.cachePoolSplit); + + // Persistent Pool Split (Split into Sequences, SoundFonts, Samples) + gAudioContext.persistentCommonPoolSplit.seqCacheSize = spec->persistentSeqCacheSize; + gAudioContext.persistentCommonPoolSplit.fontCacheSize = spec->persistentFontCacheSize; + gAudioContext.persistentCommonPoolSplit.sampleBankCacheSize = spec->persistentSampleBankCacheSize; + AudioHeap_InitPersistentCache(&gAudioContext.persistentCommonPoolSplit); + + // Temporary Pool Split (Split into Sequences, SoundFonts, Samples) + gAudioContext.temporaryCommonPoolSplit.seqCacheSize = spec->temporarySeqCacheSize; + gAudioContext.temporaryCommonPoolSplit.fontCacheSize = spec->temporaryFontCacheSize; + gAudioContext.temporaryCommonPoolSplit.sampleBankCacheSize = spec->temporarySampleBankCacheSize; + AudioHeap_InitTemporaryCache(&gAudioContext.temporaryCommonPoolSplit); + + AudioHeap_ResetLoadStatus(); + + // Initialize notes + gAudioContext.notes = AudioHeap_AllocZeroed(&gAudioContext.miscPool, gAudioContext.numNotes * sizeof(Note)); + AudioPlayback_NoteInitAll(); + AudioPlayback_InitNoteFreeList(); + gAudioContext.noteSubsEu = + AudioHeap_AllocZeroed(&gAudioContext.miscPool, gAudioContext.audioBufferParameters.updatesPerFrame * + gAudioContext.numNotes * sizeof(NoteSubEu)); + + // Initialize audio binary interface command list buffer + for (j = 0; j < ARRAY_COUNT(gAudioContext.abiCmdBufs); j++) { + gAudioContext.abiCmdBufs[j] = + AudioHeap_AllocDmaMemoryZeroed(&gAudioContext.miscPool, gAudioContext.maxAudioCmds * sizeof(u64)); + } + + // Initialize unk_3520 (fadeOutVelocities for ADSR) + gAudioContext.unk_3520 = AudioHeap_Alloc(&gAudioContext.miscPool, 0x100 * sizeof(f32)); + func_8018B10C(); + + // Initialize reverbs + for (i = 0; i < ARRAY_COUNT(gAudioContext.synthesisReverbs); i++) { + gAudioContext.synthesisReverbs[i].useReverb = 0; + } + + gAudioContext.numSynthesisReverbs = spec->numReverbs; + for (i = 0; i < gAudioContext.numSynthesisReverbs; i++) { + AudioHeap_InitReverb(i, &spec->reverbSettings[i], 1); + } + + // Initialize sequence players + AudioSeq_InitSequencePlayers(); + for (j = 0; j < gAudioContext.audioBufferParameters.numSequencePlayers; j++) { + AudioSeq_InitSequencePlayerChannels(j); + AudioSeq_ResetSequencePlayer(&gAudioContext.seqPlayers[j]); + } + + // Initialize two additional caches on the audio heap to store individual audio samples + AudioHeap_InitSampleCaches(spec->persistentSampleCacheSize, spec->temporarySampleCacheSize); + AudioLoad_InitSampleDmaBuffers(gAudioContext.numNotes); + + // Initalize Loads + gAudioContext.preloadSampleStackTop = 0; + AudioLoad_InitSlowLoads(); + AudioLoad_InitScriptLoads(); + AudioLoad_InitAsyncLoads(); + gAudioContext.unk_4 = 0x1000; + AudioLoad_LoadPermanentSamples(); + + intMask = osSetIntMask(1); + osWritebackDCacheAll(); + osSetIntMask(intMask); +} + +void* AudioHeap_SearchPermanentCache(s32 tableType, s32 id) { + s32 i; + + for (i = 0; i < gAudioContext.permanentPool.count; i++) { + if (gAudioContext.permanentEntries[i].tableType == tableType && gAudioContext.permanentEntries[i].id == id) { + return gAudioContext.permanentEntries[i].addr; + } + } + return NULL; +} + +void* AudioHeap_AllocPermanent(s32 tableType, s32 id, size_t size) { + void* addr; + s32 index = gAudioContext.permanentPool.count; + + addr = AudioHeap_Alloc(&gAudioContext.permanentPool, size); + gAudioContext.permanentEntries[index].addr = addr; + + if (addr == NULL) { + return NULL; + } + + gAudioContext.permanentEntries[index].tableType = tableType; + gAudioContext.permanentEntries[index].id = id; + gAudioContext.permanentEntries[index].size = size; + //! @bug UB: missing return. "addr" is in v0 at this point, but doing an + // explicit return uses an additional register. + // return addr; +} + +void* AudioHeap_AllocSampleCache(size_t size, s32 sampleBankId, void* sampleAddr, s8 medium, s32 cache) { + SampleCacheEntry* entry; + + if (cache == CACHE_TEMPORARY) { + entry = AudioHeap_AllocTemporarySampleCacheEntry(size); + } else { + entry = AudioHeap_AllocPersistentSampleCacheEntry(size); + } + + if (entry != NULL) { + entry->sampleBankId = sampleBankId; + entry->sampleAddr = sampleAddr; + entry->origMedium = medium; + return entry->allocatedAddr; + } + return NULL; +} + +/** + * Initializes the persistent and temporary caches used for individual samples. Will attempt to use heap space available + * on the external pool. If no external pool is provided, then default to using space on the misc heap. + */ +void AudioHeap_InitSampleCaches(size_t persistentSampleCacheSize, size_t temporarySampleCacheSize) { + void* addr; + + addr = AudioHeap_AllocAttemptExternal(&gAudioContext.miscPool, persistentSampleCacheSize); + if (addr == NULL) { + gAudioContext.persistentSampleCache.pool.size = 0; + } else { + AudioHeap_AllocPoolInit(&gAudioContext.persistentSampleCache.pool, addr, persistentSampleCacheSize); + } + + addr = AudioHeap_AllocAttemptExternal(&gAudioContext.miscPool, temporarySampleCacheSize); + if (addr == NULL) { + gAudioContext.temporarySampleCache.pool.size = 0; + } else { + AudioHeap_AllocPoolInit(&gAudioContext.temporarySampleCache.pool, addr, temporarySampleCacheSize); + } + + gAudioContext.persistentSampleCache.numEntries = 0; + gAudioContext.temporarySampleCache.numEntries = 0; +} + +SampleCacheEntry* AudioHeap_AllocTemporarySampleCacheEntry(size_t size) { + s32 pad2[2]; + void* addr; + s32 pad3[2]; + u8* allocAfter; + u8* allocBefore; + s32 pad1; + s32 index; + s32 i; + SampleCacheEntry* entry; + AudioPreloadReq* preload; + AudioSampleCache* cache; + u8* startAddr; + u8* endAddr; + + cache = &gAudioContext.temporarySampleCache; + allocBefore = cache->pool.curAddr; + addr = AudioHeap_Alloc(&cache->pool, size); + if (addr == NULL) { + // Reset the heap and try again. We still keep pointers to within the + // heap, so we have to be careful to discard existing overlapping + // allocations further down. + u8* oldAddr = cache->pool.curAddr; + + cache->pool.curAddr = cache->pool.startAddr; + addr = AudioHeap_Alloc(&cache->pool, size); + if (addr == NULL) { + cache->pool.curAddr = oldAddr; + return NULL; + } + allocBefore = cache->pool.startAddr; + } + + allocAfter = cache->pool.curAddr; + + index = -1; + for (i = 0; i < gAudioContext.preloadSampleStackTop; i++) { + preload = &gAudioContext.preloadSampleStack[i]; + if (preload->isFree == false) { + startAddr = preload->ramAddr; + endAddr = preload->ramAddr + preload->sample->size - 1; + + if ((endAddr < allocBefore) && (startAddr < allocBefore)) { + continue; + } + if ((endAddr >= allocAfter) && (startAddr >= allocAfter)) { + continue; + } + + // Overlap, skip this preload. + preload->isFree = true; + } + } + + for (i = 0; i < cache->numEntries; i++) { + if (!cache->entries[i].inUse) { + continue; + } + + startAddr = cache->entries[i].allocatedAddr; + endAddr = startAddr + cache->entries[i].size - 1; + + if ((endAddr < allocBefore) && (startAddr < allocBefore)) { + continue; + } + if ((endAddr >= allocAfter) && (startAddr >= allocAfter)) { + continue; + } + + // Overlap, discard existing entry. + AudioHeap_DiscardSampleCacheEntry(&cache->entries[i]); + cache->entries[i].inUse = false; + if (index == -1) { + index = i; + } + } + + if (index == -1) { + for (i = 0; i < cache->numEntries; i++) { + if (!cache->entries[i].inUse) { + break; + } + } + + index = i; + if (index == cache->numEntries) { + if (cache->numEntries == 128) { + return NULL; + } + cache->numEntries++; + } + } + + entry = &cache->entries[index]; + entry->inUse = 1; + entry->allocatedAddr = addr; + entry->size = size; + + return entry; +} + +void AudioHeap_UnapplySampleCacheForFont(SampleCacheEntry* entry, s32 fontId) { + Drum* drum; + Instrument* inst; + SoundFontSound* sfx; + s32 instId; + s32 drumId; + s32 sfxId; + + for (instId = 0; instId < gAudioContext.soundFonts[fontId].numInstruments; instId++) { + inst = AudioPlayback_GetInstrumentInner(fontId, instId); + if (inst != NULL) { + if (inst->normalRangeLo != 0) { + AudioHeap_UnapplySampleCache(entry, inst->lowNotesSound.sample); + } + if (inst->normalRangeHi != 0x7F) { + AudioHeap_UnapplySampleCache(entry, inst->highNotesSound.sample); + } + AudioHeap_UnapplySampleCache(entry, inst->normalNotesSound.sample); + } + } + + for (drumId = 0; drumId < gAudioContext.soundFonts[fontId].numDrums; drumId++) { + drum = AudioPlayback_GetDrum(fontId, drumId); + if (drum != NULL) { + AudioHeap_UnapplySampleCache(entry, drum->sound.sample); + } + } + + for (sfxId = 0; sfxId < gAudioContext.soundFonts[fontId].numSfx; sfxId++) { + sfx = AudioPlayback_GetSfx(fontId, sfxId); + if (sfx != NULL) { + AudioHeap_UnapplySampleCache(entry, sfx->sample); + } + } +} + +void AudioHeap_DiscardSampleCacheEntry(SampleCacheEntry* entry) { + s32 numFonts; + s32 sampleBankId1; + s32 sampleBankId2; + s32 fontId; + + numFonts = gAudioContext.soundFontTable->numEntries; + for (fontId = 0; fontId < numFonts; fontId++) { + sampleBankId1 = gAudioContext.soundFonts[fontId].sampleBankId1; + sampleBankId2 = gAudioContext.soundFonts[fontId].sampleBankId2; + if (((sampleBankId1 != 0xFF) && (entry->sampleBankId == sampleBankId1)) || + ((sampleBankId2 != 0xFF) && (entry->sampleBankId == sampleBankId2)) || entry->sampleBankId == 0 || + entry->sampleBankId == 0xFE) { + if (AudioHeap_SearchCaches(FONT_TABLE, CACHE_EITHER, fontId) != NULL) { + if (1) {} + if (AudioLoad_IsFontLoadComplete(fontId) != 0) { + AudioHeap_UnapplySampleCacheForFont(entry, fontId); + } + } + } + } +} + +void AudioHeap_UnapplySampleCache(SampleCacheEntry* entry, SoundFontSample* sample) { + if (sample != NULL) { + if (sample->sampleAddr == entry->allocatedAddr) { + sample->sampleAddr = entry->sampleAddr; + sample->medium = entry->origMedium; + } + } +} + +SampleCacheEntry* AudioHeap_AllocPersistentSampleCacheEntry(size_t size) { + AudioSampleCache* cache; + SampleCacheEntry* entry; + void* addr; + + cache = &gAudioContext.persistentSampleCache; + addr = AudioHeap_Alloc(&cache->pool, size); + if (addr == NULL) { + return NULL; + } + + if (cache->numEntries == 128) { + return NULL; + } + + entry = &cache->entries[cache->numEntries]; + entry->inUse = true; + entry->allocatedAddr = addr; + entry->size = size; + cache->numEntries++; + + return entry; +} + +void AudioHeap_DiscardSampleCacheForFont(SampleCacheEntry* entry, s32 sampleBankId1, s32 sampleBankId2, s32 fontId) { + if ((entry->sampleBankId == sampleBankId1) || (entry->sampleBankId == sampleBankId2) || + (entry->sampleBankId == 0)) { + AudioHeap_UnapplySampleCacheForFont(entry, fontId); + } +} + +void AudioHeap_DiscardSampleCaches(void) { + s32 numFonts; + s32 sampleBankId1; + s32 sampleBankId2; + s32 fontId; + s32 j; + + numFonts = gAudioContext.soundFontTable->numEntries; + for (fontId = 0; fontId < numFonts; fontId++) { + sampleBankId1 = gAudioContext.soundFonts[fontId].sampleBankId1; + sampleBankId2 = gAudioContext.soundFonts[fontId].sampleBankId2; + if ((sampleBankId1 == 0xFF) && (sampleBankId2 == 0xFF)) { + continue; + } + if (AudioHeap_SearchCaches(FONT_TABLE, CACHE_PERMANENT, fontId) == NULL || + !AudioLoad_IsFontLoadComplete(fontId)) { + continue; + } + + for (j = 0; j < gAudioContext.persistentSampleCache.numEntries; j++) { + AudioHeap_DiscardSampleCacheForFont(&gAudioContext.persistentSampleCache.entries[j], sampleBankId1, + sampleBankId2, fontId); + } + for (j = 0; j < gAudioContext.temporarySampleCache.numEntries; j++) { + AudioHeap_DiscardSampleCacheForFont(&gAudioContext.temporarySampleCache.entries[j], sampleBankId1, + sampleBankId2, fontId); + } + } +} + +typedef struct { + uintptr_t oldAddr; + uintptr_t newAddr; + size_t size; + u8 newMedium; +} StorageChange; + +void AudioHeap_ChangeStorage(StorageChange* change, SoundFontSample* sample) { + if (sample != NULL && ((sample->medium == change->newMedium) || (D_801FD120 != 1)) && + ((sample->medium == MEDIUM_RAM) || (D_801FD120 != 0))) { + uintptr_t startAddr = change->oldAddr; + uintptr_t endAddr = change->oldAddr + change->size; + + if (startAddr <= (uintptr_t)sample->sampleAddr && (uintptr_t)sample->sampleAddr < endAddr) { + sample->sampleAddr = sample->sampleAddr - startAddr + change->newAddr; + if (D_801FD120 == 0) { + sample->medium = change->newMedium; + } else { + sample->medium = MEDIUM_RAM; + } + } + } +} + +void AudioHeap_DiscardSampleBank(s32 sampleBankId) { + D_801FD120 = 0; + AudioHeap_ApplySampleBankCacheInternal(false, sampleBankId); +} + +void AudioHeap_ApplySampleBankCache(s32 sampleBankId) { + D_801FD120 = 1; + AudioHeap_ApplySampleBankCacheInternal(true, sampleBankId); +} + +void AudioHeap_ApplySampleBankCacheInternal(s32 apply, s32 sampleBankId) { + AudioTable* sampleBankTable; + AudioTableEntry* entry; + s32 numFonts; + s32 instId; + s32 drumId; + s32 sfxId; + StorageChange change; + s32 sampleBankId1; + s32 sampleBankId2; + s32 fontId; + Drum* drum; + Instrument* inst; + SoundFontSound* sfx; + uintptr_t* newAddr; + s32 pad[4]; + + sampleBankTable = gAudioContext.sampleBankTable; + numFonts = gAudioContext.soundFontTable->numEntries; + change.oldAddr = AudioHeap_SearchCaches(SAMPLE_TABLE, CACHE_EITHER, sampleBankId); + if (change.oldAddr == 0) { + return; + } + + entry = &sampleBankTable->entries[sampleBankId]; + change.size = entry->size; + change.newMedium = entry->medium; + change.newAddr = entry->romAddr; + + newAddr = &change.oldAddr; + if (apply && (apply == true)) { + uintptr_t oldAddr; + + oldAddr = change.newAddr; + + change.newAddr = *newAddr; + change.oldAddr = oldAddr; + } + + for (fontId = 0; fontId < numFonts; fontId++) { + sampleBankId1 = gAudioContext.soundFonts[fontId].sampleBankId1; + sampleBankId2 = gAudioContext.soundFonts[fontId].sampleBankId2; + if ((sampleBankId1 != 0xFF) || (sampleBankId2 != 0xFF)) { + if (!AudioLoad_IsFontLoadComplete(fontId) || + AudioHeap_SearchCaches(FONT_TABLE, CACHE_EITHER, fontId) == NULL) { + continue; + } + + if (sampleBankId1 == sampleBankId) { + } else if (sampleBankId2 == sampleBankId) { + } else { + continue; + } + + for (instId = 0; instId < gAudioContext.soundFonts[fontId].numInstruments; instId++) { + inst = AudioPlayback_GetInstrumentInner(fontId, instId); + if (inst != NULL) { + if (inst->normalRangeLo != 0) { + AudioHeap_ChangeStorage(&change, inst->lowNotesSound.sample); + } + if (inst->normalRangeHi != 0x7F) { + AudioHeap_ChangeStorage(&change, inst->highNotesSound.sample); + } + AudioHeap_ChangeStorage(&change, inst->normalNotesSound.sample); + } + } + + for (drumId = 0; drumId < gAudioContext.soundFonts[fontId].numDrums; drumId++) { + drum = AudioPlayback_GetDrum(fontId, drumId); + if (drum != NULL) { + AudioHeap_ChangeStorage(&change, drum->sound.sample); + } + } + + for (sfxId = 0; sfxId < gAudioContext.soundFonts[fontId].numSfx; sfxId++) { + sfx = AudioPlayback_GetSfx(fontId, sfxId); + if (sfx != NULL) { + AudioHeap_ChangeStorage(&change, sfx->sample); + } + } + } + } +} + +void AudioHeap_DiscardSampleBanks(void) { + AudioCache* cache; + AudioPersistentCache* persistent; + AudioTemporaryCache* temporary; + u32 i; + + cache = &gAudioContext.sampleBankCache; + temporary = &cache->temporary; + + if (temporary->entries[0].id != -1) { + AudioHeap_DiscardSampleBank(temporary->entries[0].id); + } + + if (temporary->entries[1].id != -1) { + AudioHeap_DiscardSampleBank(temporary->entries[1].id); + } + + persistent = &cache->persistent; + for (i = 0; i < persistent->numEntries; i++) { + AudioHeap_DiscardSampleBank(persistent->entries[i].id); + } +} + +void AudioHeap_SetReverbData(s32 reverbIndex, u32 dataType, s32 data, s32 flags) { + s32 windowSize; + SynthesisReverb* reverb = &gAudioContext.synthesisReverbs[reverbIndex]; + + switch (dataType) { + case 0: + AudioHeap_InitReverb(reverbIndex, (ReverbSettings*)data, 0); + break; + case 1: + if (data < 4) { + data = 4; + } + + windowSize = data * 64; + if (windowSize < 0x100) { + windowSize = 0x100; + } + + windowSize /= reverb->downsampleRate; + + if (flags == 0) { + if (reverb->unk_1E >= (data / reverb->downsampleRate)) { + if ((reverb->nextRingBufPos >= windowSize) || (reverb->unk_24 >= windowSize)) { + reverb->nextRingBufPos = 0; + reverb->unk_24 = 0; + } + } else { + break; + } + } + + reverb->windowSize = windowSize; + + if ((reverb->downsampleRate != 1) || reverb->unk_18) { + reverb->unk_0E = 0x8000 / reverb->downsampleRate; + if (reverb->unk_30 == NULL) { + reverb->unk_30 = AudioHeap_AllocZeroed(&gAudioContext.miscPool, 0x20); + reverb->unk_34 = AudioHeap_AllocZeroed(&gAudioContext.miscPool, 0x20); + reverb->unk_38 = AudioHeap_AllocZeroed(&gAudioContext.miscPool, 0x20); + reverb->unk_3C = AudioHeap_AllocZeroed(&gAudioContext.miscPool, 0x20); + if (reverb->unk_3C == NULL) { + reverb->downsampleRate = 1; + } + } + } + break; + case 2: + gAudioContext.synthesisReverbs[reverbIndex].unk_0C = data; + break; + case 3: + gAudioContext.synthesisReverbs[reverbIndex].unk_16 = data; + break; + case 4: + gAudioContext.synthesisReverbs[reverbIndex].unk_0A = data; + break; + case 5: + gAudioContext.synthesisReverbs[reverbIndex].leakRtl = data; + break; + case 6: + gAudioContext.synthesisReverbs[reverbIndex].leakLtr = data; + break; + case 7: + if (data != 0) { + if ((flags != 0) || (reverb->unk_278 == 0)) { + reverb->filterLeftState = AudioHeap_AllocDmaMemoryZeroed(&gAudioContext.miscPool, 0x40); + reverb->unk_278 = AudioHeap_AllocDmaMemory(&gAudioContext.miscPool, 0x10); + } + + reverb->filterLeft = reverb->unk_278; + if (reverb->filterLeft != 0) { + AudioHeap_LoadLowPassFilter(reverb->filterLeft, data); + } + } else { + reverb->filterLeft = 0; + + if (flags != 0) { + reverb->unk_278 = 0; + } + } + + break; + case 8: + if (data != 0) { + if ((flags != 0) || (reverb->unk_27C == 0)) { + reverb->filterRightState = AudioHeap_AllocDmaMemoryZeroed(&gAudioContext.miscPool, 0x40); + reverb->unk_27C = AudioHeap_AllocDmaMemory(&gAudioContext.miscPool, 0x10); + } + reverb->filterRight = reverb->unk_27C; + if (reverb->unk_27C != 0) { + AudioHeap_LoadLowPassFilter(reverb->unk_27C, data); + } + } else { + reverb->filterRight = 0; + if (flags != 0) { + reverb->unk_27C = 0; + } + } + break; + case 9: + reverb->unk_19 = data; + if (data == 0) { + reverb->unk_18 = false; + } else { + reverb->unk_18 = true; + } + break; + default: + break; + } +} + +void AudioHeap_InitReverb(s32 reverbIndex, ReverbSettings* settings, s32 flags) { + SynthesisReverb* reverb = &gAudioContext.synthesisReverbs[reverbIndex]; + + if (flags != 0) { + reverb->unk_1E = settings->windowSize / settings->downsampleRate; + reverb->unk_30 = 0; + } else if (reverb->unk_1E < (settings->windowSize / settings->downsampleRate)) { + return; + } + + reverb->downsampleRate = settings->downsampleRate; + reverb->unk_18 = false; + reverb->unk_19 = 0; + reverb->unk_1A = 0; + reverb->unk_1C = 0; + AudioHeap_SetReverbData(reverbIndex, 1, settings->windowSize, flags); + reverb->unk_0C = settings->unk_4; + reverb->unk_0A = settings->unk_A; + reverb->unk_14 = settings->unk_6 << 6; + reverb->unk_16 = settings->unk_8; + reverb->leakRtl = settings->leakRtl; + reverb->leakLtr = settings->leakLtr; + reverb->unk_05 = settings->unk_10; + reverb->unk_08 = settings->unk_12; + reverb->useReverb = 8; + + if (flags != 0) { + reverb->leftRingBuf = AudioHeap_AllocZeroedAttemptExternal(&gAudioContext.miscPool, reverb->windowSize * 2); + reverb->rightRingBuf = AudioHeap_AllocZeroedAttemptExternal(&gAudioContext.miscPool, reverb->windowSize * 2); + reverb->resampleFlags = 1; + reverb->nextRingBufPos = 0; + reverb->unk_24 = 0; + reverb->curFrame = 0; + reverb->framesToIgnore = 2; + } + + reverb->sound.sample = &reverb->sample; + reverb->sample.loop = &reverb->loop; + reverb->sound.tuning = 1.0f; + reverb->sample.codec = CODEC_REVERB; + reverb->sample.medium = MEDIUM_RAM; + reverb->sample.size = reverb->windowSize * 2; + reverb->sample.sampleAddr = (u8*)reverb->leftRingBuf; + reverb->loop.start = 0; + reverb->loop.count = 1; + reverb->loop.end = reverb->windowSize; + + AudioHeap_SetReverbData(reverbIndex, 7, settings->lowPassFilterCutoffLeft, flags); + AudioHeap_SetReverbData(reverbIndex, 8, settings->lowPassFilterCutoffRight, flags); +} diff --git a/src/code/audio/audio_init_params.c b/src/code/audio/audio_init_params.c index 4e6ef9dfbb..b407ef7c98 100644 --- a/src/code/audio/audio_init_params.c +++ b/src/code/audio/audio_init_params.c @@ -7,6 +7,6 @@ const s16 gAudioTatumInit[] = { const AudioContextInitSizes gAudioContextInitSizes = { 0x137F00, // heapSize - 0x1C480, // initPoolSize + 0x1C480, // mainPoolSplitSize 0x1A000, // permanentPoolSize }; diff --git a/src/code/audio/audio_load.c b/src/code/audio/audio_load.c index 497f9d47a9..8faf565ea7 100644 --- a/src/code/audio/audio_load.c +++ b/src/code/audio/audio_load.c @@ -1,161 +1,2163 @@ +/** + * @file audio_load.c + * + * Implements the transfer of audio data from the cartridge to the audio heap. + * + * The audio data in ROM consists of: + * 1) Sequences stored as a midi-based script called the music-macro language (.mus files) + * 2) SoundFonts stored as various sound-font structs bundled togther in a custom way + * that is extracted through relocs (See SoundFontData, generic .o files) + * 3) Samples consisting of raw soundbytes stored using a compressed ADPCM algorithm (.aifc files) + */ + #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018EB60.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018EC4C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/D_801E030C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018EF88.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/AudioLoad_IsFontLoadComplete.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F298.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F310.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F388.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F3B8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F3E8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F448.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F478.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F4D8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F588.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F604.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F6F0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F7C0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F7F8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F83C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F880.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F8C4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F908.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F9B8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018FA60.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018FAD0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018FB20.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018FB78.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018FCCC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018FD20.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018FD40.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018FE5C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018FF60.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80190204.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80190240.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80190294.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_801902D8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80190544.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80190668.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8019067C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80190754.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8019075C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8019077C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80190B08.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80190B38.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80190B44.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80190B50.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80190BB0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80190F50.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80190F64.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80191134.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_801911C4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_801911CC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80191240.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_801913C8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8019144C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80191460.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80191568.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80191598.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8019161C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80191740.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80191864.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80191870.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_801919AC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80191B40.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80191BD0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80191C40.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80191C54.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80191D94.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8019218C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80192340.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80192388.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_801924BC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80192514.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80192990.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80192AD0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80192AD8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80192AE0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80192AE8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80192B54.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80192BAC.s") +/** + * SoundFont Notes: + * + */ +// opaque type for unpatched sound font data (should maybe get rid of this?) +typedef void SoundFontData; + +typedef struct { + /* 0x00 */ s32 sampleBankId1; + /* 0x04 */ s32 sampleBankId2; + /* 0x08 */ uintptr_t baseAddr1; + /* 0x0C */ uintptr_t baseAddr2; + /* 0x10 */ u32 medium1; + /* 0x14 */ u32 medium2; +} AudioRelocInfo; // size = 0x18 + +void AudioLoad_DiscardFont(s32 fontId); +s32 AudioLoad_SyncInitSeqPlayerInternal(s32 playerIdx, s32 seqId, s32 arg2); +u8* AudioLoad_SyncLoadSeq(s32 seqId); +u32 AudioLoad_TrySyncLoadSampleBank(u32 sampleBankId, u32* outMedium, s32 noLoad); +SoundFontData* AudioLoad_SyncLoadFont(u32 fontId); +void* AudioLoad_SyncLoad(s32 tableType, u32 id, s32* didAllocate); +u32 AudioLoad_GetRealTableIndex(s32 tableType, u32 id); +void* AudioLoad_SearchCaches(s32 tableType, s32 id); +AudioTable* AudioLoad_GetLoadTable(s32 tableType); +void AudioLoad_SyncDma(uintptr_t devAddr, u8* addr, size_t size, s32 medium); +void AudioLoad_SyncDmaUnkMedium(uintptr_t devAddr, u8* addr, size_t size, s32 unkMediumParam); +s32 AudioLoad_Dma(OSIoMesg* mesg, u32 priority, s32 direction, uintptr_t devAddr, void* ramAddr, size_t size, + OSMesgQueue* reqQueue, s32 medium, const char* dmaFuncType); +void* AudioLoad_AsyncLoadInner(s32 tableType, s32 id, s32 nChunks, s32 retData, OSMesgQueue* retQueue); +SoundFontSample* AudioLoad_GetFontSample(s32 fontId, s32 instId); +void AudioLoad_ProcessSlowLoads(s32 resetStatus); +void AudioLoad_DmaSlowCopy(AudioSlowLoad* slowLoad, size_t size); +void AudioLoad_DmaSlowCopyUnkMedium(intptr_t devAddr, intptr_t ramAddr, size_t size, s32 arg3); +AudioAsyncLoad* AudioLoad_StartAsyncLoadUnkMedium(s32 unkMediumParam, uintptr_t devAddr, void* ramAddr, size_t size, + s32 medium, s32 nChunks, OSMesgQueue* retQueue, s32 retMsg); +AudioAsyncLoad* AudioLoad_StartAsyncLoad(uintptr_t devAddr, void* ramAddr, size_t size, s32 medium, s32 nChunks, + OSMesgQueue* retQueue, s32 retMsg); +void AudioLoad_ProcessAsyncLoads(s32 resetStatus); +void AudioLoad_ProcessAsyncLoadUnkMedium(AudioAsyncLoad* asyncLoad, s32 resetStatus); +void AudioLoad_ProcessAsyncLoad(AudioAsyncLoad* asyncLoad, s32 resetStatus); +void AudioLoad_AsyncDma(AudioAsyncLoad* asyncLoad, size_t size); +void AudioLoad_AsyncDmaRamUnloaded(AudioAsyncLoad* asyncLoad, size_t size); +void AudioLoad_AsyncDmaUnkMedium(uintptr_t devAddr, void* ramAddr, size_t size, s16 arg3); +void AudioLoad_RelocateSample(SoundFontSound* sound, SoundFontData* fontData, AudioRelocInfo* relocInfo); +void AudioLoad_RelocateFontAndPreloadSamples(s32 fontId, SoundFontData* fontData, AudioRelocInfo* relocInfo, s32 async); +s32 AudioLoad_ProcessSamplePreloads(s32 resetStatus); + +#define MK_ASYNC_MSG(retData, tableType, id, loadStatus) \ + (((retData) << 24) | ((tableType) << 16) | ((id) << 8) | (loadStatus)) + +#define ASYNC_TBLTYPE(v) ((u8)(v >> 16)) +#define ASYNC_ID(v) ((u8)(v >> 8)) +#define ASYNC_STATUS(v) ((u8)(v >> 0)) + +typedef enum { + /* 0 */ LOAD_STATUS_WAITING, + /* 1 */ LOAD_STATUS_START, + /* 2 */ LOAD_STATUS_LOADING, + /* 3 */ LOAD_STATUS_DONE +} SlowLoadStatus; + +#define OS_MESG_PRI_NORMAL 0 +#define OS_MESG_PRI_HIGH 1 + +typedef struct { + u16 numInstruments; + u16 numDrums; + u16 numSfx; +} UnloadedFonts; + +OSMesgQueue sScriptLoadQueue; +OSMesg sScriptLoadMesgBuf[0x10]; +s8* sScriptLoadDonePointers[0x10]; +s32 sAudioLoadPad1[2]; // file padding +s32 D_801FD1E0; + +DmaHandler sDmaHandler = osEPiStartDma; +void* sUnusedHandler = NULL; +s32 gAudioContextInitalized = false; + +void AudioLoad_DecreaseSampleDmaTtls(void) { + u32 i; + + for (i = 0; i < gAudioContext.sampleDmaListSize1; i++) { + SampleDma* dma = &gAudioContext.sampleDmas[i]; + + if (dma->ttl != 0) { + dma->ttl--; + if (dma->ttl == 0) { + dma->reuseIndex = gAudioContext.sampleDmaReuseQueue1WrPos; + gAudioContext.sampleDmaReuseQueue1[gAudioContext.sampleDmaReuseQueue1WrPos] = i; + gAudioContext.sampleDmaReuseQueue1WrPos++; + } + } + } + + for (i = gAudioContext.sampleDmaListSize1; i < gAudioContext.sampleDmaCount; i++) { + SampleDma* dma = &gAudioContext.sampleDmas[i]; + + if (dma->ttl != 0) { + dma->ttl--; + if (dma->ttl == 0) { + dma->reuseIndex = gAudioContext.sampleDmaReuseQueue2WrPos; + gAudioContext.sampleDmaReuseQueue2[gAudioContext.sampleDmaReuseQueue2WrPos] = i; + gAudioContext.sampleDmaReuseQueue2WrPos++; + } + } + } + + gAudioContext.unused2648 = 0; +} + +void* AudioLoad_DmaSampleData(uintptr_t devAddr, size_t size, s32 arg2, u8* dmaIndexRef, s32 medium) { + s32 pad1; + SampleDma* dma; + s32 hasDma = false; + uintptr_t dmaDevAddr; + u32 pad2; + u32 dmaIndex; + u32 transfer; + s32 bufferPos; + u32 i; + + if (arg2 != 0 || *dmaIndexRef >= gAudioContext.sampleDmaListSize1) { + for (i = gAudioContext.sampleDmaListSize1; i < gAudioContext.sampleDmaCount; i++) { + dma = &gAudioContext.sampleDmas[i]; + bufferPos = devAddr - dma->devAddr; + if (0 <= bufferPos && ((u32)bufferPos <= dma->size - size)) { + // We already have a DMA request for this memory range. + if (dma->ttl == 0 && + gAudioContext.sampleDmaReuseQueue2RdPos != gAudioContext.sampleDmaReuseQueue2WrPos) { + // Move the DMA out of the reuse queue, by swapping it with the + // read pos, and then incrementing the read pos. + if (dma->reuseIndex != gAudioContext.sampleDmaReuseQueue2RdPos) { + gAudioContext.sampleDmaReuseQueue2[dma->reuseIndex] = + gAudioContext.sampleDmaReuseQueue2[gAudioContext.sampleDmaReuseQueue2RdPos]; + gAudioContext + .sampleDmas[gAudioContext.sampleDmaReuseQueue2[gAudioContext.sampleDmaReuseQueue2RdPos]] + .reuseIndex = dma->reuseIndex; + } + gAudioContext.sampleDmaReuseQueue2RdPos++; + } + dma->ttl = 32; + *dmaIndexRef = (u8)i; + return dma->ramAddr + (devAddr - dma->devAddr); + } + } + + if (arg2 == 0) { + goto search_short_lived; + } + + if (gAudioContext.sampleDmaReuseQueue2RdPos != gAudioContext.sampleDmaReuseQueue2WrPos && arg2 != 0) { + // Allocate a DMA from reuse queue 2, unless full. + dmaIndex = gAudioContext.sampleDmaReuseQueue2[gAudioContext.sampleDmaReuseQueue2RdPos]; + gAudioContext.sampleDmaReuseQueue2RdPos++; + dma = gAudioContext.sampleDmas + dmaIndex; + hasDma = true; + } + } else { + search_short_lived: + dma = gAudioContext.sampleDmas + *dmaIndexRef; + i = 0; + again: + bufferPos = devAddr - dma->devAddr; + if (0 <= bufferPos && (u32)bufferPos <= dma->size - size) { + // We already have DMA for this memory range. + if (dma->ttl == 0) { + // Move the DMA out of the reuse queue, by swapping it with the + // read pos, and then incrementing the read pos. + if (dma->reuseIndex != gAudioContext.sampleDmaReuseQueue1RdPos) { + gAudioContext.sampleDmaReuseQueue1[dma->reuseIndex] = + gAudioContext.sampleDmaReuseQueue1[gAudioContext.sampleDmaReuseQueue1RdPos]; + gAudioContext + .sampleDmas[gAudioContext.sampleDmaReuseQueue1[gAudioContext.sampleDmaReuseQueue1RdPos]] + .reuseIndex = dma->reuseIndex; + } + gAudioContext.sampleDmaReuseQueue1RdPos++; + } + dma->ttl = 2; + return dma->ramAddr + (devAddr - dma->devAddr); + } + dma = gAudioContext.sampleDmas + i++; + if (i <= gAudioContext.sampleDmaListSize1) { + goto again; + } + } + + if (!hasDma) { + if (gAudioContext.sampleDmaReuseQueue1RdPos == gAudioContext.sampleDmaReuseQueue1WrPos) { + return NULL; + } + // Allocate a DMA from reuse queue 1. + dmaIndex = gAudioContext.sampleDmaReuseQueue1[gAudioContext.sampleDmaReuseQueue1RdPos++]; + dma = gAudioContext.sampleDmas + dmaIndex; + hasDma = true; + } + + transfer = dma->size; + dmaDevAddr = devAddr & ~0xF; + dma->ttl = 3; + dma->devAddr = dmaDevAddr; + dma->sizeUnused = transfer; + AudioLoad_Dma(&gAudioContext.currAudioFrameDmaIoMesgBuf[gAudioContext.curAudioFrameDmaCount++], OS_MESG_PRI_NORMAL, + OS_READ, dmaDevAddr, dma->ramAddr, transfer, &gAudioContext.currAudioFrameDmaQueue, medium, + "SUPERDMA"); + *dmaIndexRef = dmaIndex; + return (devAddr - dmaDevAddr) + dma->ramAddr; +} + +// This string does not appear to belong in context to any function between the previous string and the next string +const char D_801E030C[] = "TYPE %d:ID %d is not External Map.\n"; + +void AudioLoad_InitSampleDmaBuffers(s32 numNotes) { + SampleDma* dma; + s32 i; + s32 t2; + s32 j; + + gAudioContext.sampleDmaBufSize = gAudioContext.sampleDmaBufSize1; + gAudioContext.sampleDmas = + AudioHeap_Alloc(&gAudioContext.miscPool, + 4 * gAudioContext.numNotes * sizeof(SampleDma) * gAudioContext.audioBufferParameters.specUnk4); + t2 = 3 * gAudioContext.numNotes * gAudioContext.audioBufferParameters.specUnk4; + + // First 3/4 sampleDmas + for (i = 0; i < t2; i++) { + dma = &gAudioContext.sampleDmas[gAudioContext.sampleDmaCount]; + dma->ramAddr = AudioHeap_AllocAttemptExternal(&gAudioContext.miscPool, gAudioContext.sampleDmaBufSize); + if (dma->ramAddr == NULL) { + break; + } else { + AudioHeap_WritebackDCache(dma->ramAddr, gAudioContext.sampleDmaBufSize); + dma->size = gAudioContext.sampleDmaBufSize; + dma->devAddr = 0; + dma->sizeUnused = 0; + dma->unused = 0; + dma->ttl = 0; + gAudioContext.sampleDmaCount++; + } + } + + for (i = 0; (u32)i < gAudioContext.sampleDmaCount; i++) { + gAudioContext.sampleDmaReuseQueue1[i] = i; + gAudioContext.sampleDmas[i].reuseIndex = i; + } + + for (i = gAudioContext.sampleDmaCount; i < 0x100; i++) { + gAudioContext.sampleDmaReuseQueue1[i] = 0; + } + + gAudioContext.sampleDmaReuseQueue1RdPos = 0; + gAudioContext.sampleDmaReuseQueue1WrPos = gAudioContext.sampleDmaCount; + gAudioContext.sampleDmaListSize1 = gAudioContext.sampleDmaCount; + gAudioContext.sampleDmaBufSize = gAudioContext.sampleDmaBufSize2; + + for (j = 0; j < gAudioContext.numNotes; j++) { + dma = &gAudioContext.sampleDmas[gAudioContext.sampleDmaCount]; + dma->ramAddr = AudioHeap_AllocAttemptExternal(&gAudioContext.miscPool, gAudioContext.sampleDmaBufSize); + if (dma->ramAddr == NULL) { + break; + } else { + AudioHeap_WritebackDCache(dma->ramAddr, gAudioContext.sampleDmaBufSize); + dma->size = gAudioContext.sampleDmaBufSize; + dma->devAddr = 0U; + dma->sizeUnused = 0; + dma->unused = 0; + dma->ttl = 0; + gAudioContext.sampleDmaCount++; + } + } + + for (i = gAudioContext.sampleDmaListSize1; (u32)i < gAudioContext.sampleDmaCount; i++) { + gAudioContext.sampleDmaReuseQueue2[i - gAudioContext.sampleDmaListSize1] = i; + gAudioContext.sampleDmas[i].reuseIndex = i - gAudioContext.sampleDmaListSize1; + } + + for (i = gAudioContext.sampleDmaCount; i < 0x100; i++) { + gAudioContext.sampleDmaReuseQueue2[i] = gAudioContext.sampleDmaListSize1; + } + + gAudioContext.sampleDmaReuseQueue2RdPos = 0; + gAudioContext.sampleDmaReuseQueue2WrPos = gAudioContext.sampleDmaCount - gAudioContext.sampleDmaListSize1; +} + +s32 AudioLoad_IsFontLoadComplete(s32 fontId) { + if (fontId == 0xFF) { + return true; + } else if (gAudioContext.fontLoadStatus[fontId] >= LOAD_STATUS_2) { + return true; + } else if (gAudioContext.fontLoadStatus[AudioLoad_GetRealTableIndex(FONT_TABLE, fontId)] >= LOAD_STATUS_2) { + return true; + } else { + return false; + } +} + +s32 AudioLoad_IsSeqLoadComplete(s32 seqId) { + if (seqId == 0xFF) { + return true; + } else if (gAudioContext.seqLoadStatus[seqId] >= LOAD_STATUS_2) { + return true; + } else if (gAudioContext.seqLoadStatus[AudioLoad_GetRealTableIndex(SEQUENCE_TABLE, seqId)] >= LOAD_STATUS_2) { + return true; + } else { + return false; + } +} + +s32 AudioLoad_IsSampleLoadComplete(s32 sampleBankId) { + if (sampleBankId == 0xFF) { + return true; + } else if (gAudioContext.sampleFontLoadStatus[sampleBankId] >= LOAD_STATUS_2) { + return true; + } else if (gAudioContext.sampleFontLoadStatus[AudioLoad_GetRealTableIndex(SAMPLE_TABLE, sampleBankId)] >= + LOAD_STATUS_2) { + return true; + } else { + return false; + } +} + +void AudioLoad_SetFontLoadStatus(s32 fontId, s32 loadStatus) { + if ((fontId != 0xFF) && (gAudioContext.fontLoadStatus[fontId] != LOAD_STATUS_5)) { + gAudioContext.fontLoadStatus[fontId] = loadStatus; + } +} + +void AudioLoad_SetSeqLoadStatus(s32 seqId, s32 loadStatus) { + if ((seqId != 0xFF) && (gAudioContext.seqLoadStatus[seqId] != LOAD_STATUS_5)) { + gAudioContext.seqLoadStatus[seqId] = loadStatus; + } +} + +void AudioLoad_SetSampleFontLoadStatusAndApplyCaches(s32 sampleBankId, s32 loadStatus) { + if (sampleBankId != 0xFF) { + if (gAudioContext.sampleFontLoadStatus[sampleBankId] != LOAD_STATUS_5) { + gAudioContext.sampleFontLoadStatus[sampleBankId] = loadStatus; + } + + if ((gAudioContext.sampleFontLoadStatus[sampleBankId] == LOAD_STATUS_5) || + (gAudioContext.sampleFontLoadStatus[sampleBankId] == LOAD_STATUS_2)) { + AudioHeap_ApplySampleBankCache(sampleBankId); + } + } +} + +void AudioLoad_SetSampleFontLoadStatus(s32 sampleBankId, s32 loadStatus) { + if ((sampleBankId != 0xFF) && (gAudioContext.sampleFontLoadStatus[sampleBankId] != LOAD_STATUS_5)) { + gAudioContext.sampleFontLoadStatus[sampleBankId] = loadStatus; + } +} + +void AudioLoad_InitTable(AudioTable* table, uintptr_t romAddr, u16 unkMediumParam) { + s32 i; + + table->unkMediumParam = unkMediumParam; + table->romAddr = romAddr; + + for (i = 0; i < table->numEntries; i++) { + if ((table->entries[i].size != 0) && (table->entries[i].medium == MEDIUM_CART)) { + table->entries[i].romAddr += romAddr; + } + } +} + +SoundFontData* AudioLoad_SyncLoadSeqFonts(s32 seqId, u32* outDefaultFontId) { + s32 pad[2]; + s32 index; + SoundFontData* fontData; + s32 numFonts; + s32 fontId; + s32 i; + + if (seqId >= gAudioContext.numSequences) { + return NULL; + } + + fontId = 0xFF; + index = ((u16*)gAudioContext.sequenceFontTable)[seqId]; + numFonts = gAudioContext.sequenceFontTable[index++]; + + while (numFonts > 0) { + fontId = gAudioContext.sequenceFontTable[index++]; + fontData = AudioLoad_SyncLoadFont(fontId); + numFonts--; + } + + *outDefaultFontId = fontId; + return fontData; +} + +void AudioLoad_SyncLoadSeqParts(s32 seqId, s32 arg1, s32 arg2, OSMesgQueue* arg3) { + s32 pad; + u32 defaultFontId; + + if (seqId < gAudioContext.numSequences) { + if (arg1 & 2) { + AudioLoad_SyncLoadSeqFonts(seqId, &defaultFontId); + } + if (arg1 & 1) { + AudioLoad_SyncLoadSeq(seqId); + } + if (arg2 != 0) { + osSendMesg(arg3, arg2 << 0x18, OS_MESG_NOBLOCK); + } + } +} + +s32 AudioLoad_SyncLoadSample(SoundFontSample* sample, s32 fontId) { + void* sampleAddr; + + if (sample->unk_bit25 == true) { + if (sample->medium != MEDIUM_RAM) { + sampleAddr = AudioHeap_AllocSampleCache(sample->size, fontId, (void*)sample->sampleAddr, sample->medium, + CACHE_PERSISTENT); + if (sampleAddr == NULL) { + return -1; + } + + if (sample->medium == MEDIUM_UNK) { + AudioLoad_SyncDmaUnkMedium(sample->sampleAddr, sampleAddr, sample->size, + gAudioContext.sampleBankTable->unkMediumParam); + } else { + AudioLoad_SyncDma(sample->sampleAddr, sampleAddr, sample->size, sample->medium); + } + sample->medium = MEDIUM_RAM; + sample->sampleAddr = sampleAddr; + } + } +} + +s32 AudioLoad_SyncLoadInstrument(s32 fontId, s32 instId, s32 drumId) { + if (instId < 0x7F) { + Instrument* instrument = AudioPlayback_GetInstrumentInner(fontId, instId); + + if (instrument == NULL) { + return -1; + } + if (instrument->normalRangeLo != 0) { + AudioLoad_SyncLoadSample(instrument->lowNotesSound.sample, fontId); + } + AudioLoad_SyncLoadSample(instrument->normalNotesSound.sample, fontId); + if (instrument->normalRangeHi != 0x7F) { + return AudioLoad_SyncLoadSample(instrument->highNotesSound.sample, fontId); + } + // TODO: is this missing return UB? + } else if (instId == 0x7F) { + Drum* drum = AudioPlayback_GetDrum(fontId, drumId); + + if (drum == NULL) { + return -1; + } + AudioLoad_SyncLoadSample(drum->sound.sample, fontId); + return 0; + } + // TODO: is this missing return UB? +} + +void AudioLoad_AsyncLoad(s32 tableType, s32 id, s32 nChunks, s32 retData, OSMesgQueue* retQueue) { + if (AudioLoad_AsyncLoadInner(tableType, id, nChunks, retData, retQueue) == NULL) { + osSendMesg(retQueue, 0xFFFFFFFF, OS_MESG_NOBLOCK); + } +} + +void AudioLoad_AsyncLoadSeq(s32 seqId, s32 arg1, s32 retData, OSMesgQueue* retQueue) { + AudioLoad_AsyncLoad(SEQUENCE_TABLE, seqId, 0, retData, retQueue); +} + +void AudioLoad_AsyncLoadSampleBank(s32 sampleBankId, s32 arg1, s32 retData, OSMesgQueue* retQueue) { + AudioLoad_AsyncLoad(SAMPLE_TABLE, sampleBankId, 0, retData, retQueue); +} + +void AudioLoad_AsyncLoadFont(s32 fontId, s32 arg1, s32 retData, OSMesgQueue* retQueue) { + AudioLoad_AsyncLoad(FONT_TABLE, fontId, 0, retData, retQueue); +} + +u8* AudioLoad_GetFontsForSequence(s32 seqId, u32* outNumFonts) { + s32 index = ((u16*)gAudioContext.sequenceFontTable)[seqId]; + + *outNumFonts = gAudioContext.sequenceFontTable[index++]; + if (*outNumFonts == 0) { + return NULL; + } + return &gAudioContext.sequenceFontTable[index]; +} + +void AudioLoad_DiscardSeqFonts(s32 seqId) { + s32 fontId; + s32 index = ((u16*)gAudioContext.sequenceFontTable)[seqId]; + s32 numFonts = gAudioContext.sequenceFontTable[index++]; + + while (numFonts > 0) { + numFonts--; + fontId = AudioLoad_GetRealTableIndex(FONT_TABLE, gAudioContext.sequenceFontTable[index++]); + if (AudioHeap_SearchPermanentCache(FONT_TABLE, fontId) == NULL) { + AudioLoad_DiscardFont(fontId); + AudioLoad_SetFontLoadStatus(fontId, LOAD_STATUS_0); + } + } +} + +void AudioLoad_DiscardFont(s32 fontId) { + u32 i; + AudioCache* pool = &gAudioContext.fontCache; + AudioPersistentCache* persistent; + + if (fontId == pool->temporary.entries[0].id) { + pool->temporary.entries[0].id = -1; + } else if (fontId == pool->temporary.entries[1].id) { + pool->temporary.entries[1].id = -1; + } + + persistent = &pool->persistent; + for (i = 0; i < persistent->numEntries; i++) { + if (fontId == persistent->entries[i].id) { + persistent->entries[i].id = -1; + } + } + + AudioHeap_DiscardFont(fontId); +} + +void func_8018FA60(u32 tableType, u32 id, s32 type, s32 data) { + AudioTable* table = AudioLoad_GetLoadTable(tableType); + + if (table->entries[id].medium == MEDIUM_RAM_UNLOADED) { + switch (type) { + case 0: + table->entries[id].romAddr = data; + break; + case 1: + table->entries[id].size = data; + break; + default: + break; + } + } +} + +s32 AudioLoad_SyncInitSeqPlayer(s32 playerIdx, s32 seqId, s32 arg2) { + if (gAudioContext.resetTimer != 0) { + return 0; + } + + gAudioContext.seqPlayers[playerIdx].skipTicks = 0; + AudioLoad_SyncInitSeqPlayerInternal(playerIdx, seqId, arg2); + // Intentionally missing return. Returning the result of the above function + // call matches but is UB because it too is missing a return, and using the + // result of a non-void function that has failed to return a value is UB. + // The callers of this function do not use the return value, so it's fine. +} + +s32 AudioLoad_SyncInitSeqPlayerSkipTicks(s32 playerIdx, s32 seqId, s32 skipTicks) { + if (gAudioContext.resetTimer != 0) { + return 0; + } + + gAudioContext.seqPlayers[playerIdx].skipTicks = skipTicks; + AudioLoad_SyncInitSeqPlayerInternal(playerIdx, seqId, 0); + // Missing return, see above. +} + +s32 AudioLoad_SyncInitSeqPlayerInternal(s32 playerIdx, s32 seqId, s32 arg2) { + SequencePlayer* seqPlayer = &gAudioContext.seqPlayers[playerIdx]; + u8* seqData; + s32 index; + s32 numFonts; + s32 fontId; + + if (seqId >= gAudioContext.numSequences) { + return 0; + } + + AudioSeq_SequencePlayerDisable(seqPlayer); + + if (1) {} + fontId = 0xFF; + index = ((u16*)gAudioContext.sequenceFontTable)[seqId]; + numFonts = gAudioContext.sequenceFontTable[index++]; + + while (numFonts > 0) { + fontId = gAudioContext.sequenceFontTable[index++]; + AudioLoad_SyncLoadFont(fontId); + numFonts--; + } + + seqData = AudioLoad_SyncLoadSeq(seqId); + if (seqData == NULL) { + return 0; + } + + AudioSeq_ResetSequencePlayer(seqPlayer); + seqPlayer->seqId = seqId; + + if (fontId != 0xFF) { + seqPlayer->defaultFont = AudioLoad_GetRealTableIndex(FONT_TABLE, fontId); + } else { + seqPlayer->defaultFont = 0xFF; + } + + seqPlayer->seqData = seqData; + seqPlayer->enabled = true; + seqPlayer->scriptState.pc = seqData; + seqPlayer->scriptState.depth = 0; + seqPlayer->delay = 0; + seqPlayer->finished = false; + seqPlayer->playerIdx = playerIdx; + //! @bug missing return (but the return value is not used so it's not UB) +} + +u8* AudioLoad_SyncLoadSeq(s32 seqId) { + s32 pad; + s32 didAllocate; + + if (gAudioContext.seqLoadStatus[AudioLoad_GetRealTableIndex(SEQUENCE_TABLE, seqId)] == LOAD_STATUS_1) { + return NULL; + } + + return AudioLoad_SyncLoad(SEQUENCE_TABLE, seqId, &didAllocate); +} + +u32 AudioLoad_GetSampleBank(u32 sampleBankId, u32* outMedium) { + return AudioLoad_TrySyncLoadSampleBank(sampleBankId, outMedium, true); +} + +u32 AudioLoad_TrySyncLoadSampleBank(u32 sampleBankId, u32* outMedium, s32 noLoad) { + void* addr; + AudioTable* sampleBankTable; + u32 realTableId = AudioLoad_GetRealTableIndex(SAMPLE_TABLE, sampleBankId); + s8 cachePolicy; + + sampleBankTable = AudioLoad_GetLoadTable(SAMPLE_TABLE); + + addr = AudioLoad_SearchCaches(SAMPLE_TABLE, realTableId); + if (addr != NULL) { + if (gAudioContext.sampleFontLoadStatus[realTableId] != LOAD_STATUS_1) { + AudioLoad_SetSampleFontLoadStatus(realTableId, LOAD_STATUS_2); + } + + *outMedium = MEDIUM_RAM; + return addr; + } + + cachePolicy = sampleBankTable->entries[sampleBankId].cachePolicy; + + if ((cachePolicy == CACHE_LOAD_EITHER_NOSYNC) || (noLoad == true)) { + *outMedium = sampleBankTable->entries[sampleBankId].medium; + return sampleBankTable->entries[realTableId].romAddr; + } + + addr = AudioLoad_SyncLoad(SAMPLE_TABLE, sampleBankId, &noLoad); + if (addr != NULL) { + *outMedium = MEDIUM_RAM; + return addr; + } + + *outMedium = sampleBankTable->entries[sampleBankId].medium; + return sampleBankTable->entries[realTableId].romAddr; +} + +SoundFontData* AudioLoad_SyncLoadFont(u32 fontId) { + SoundFontData* fontData; + s32 sampleBankId1; + s32 sampleBankId2; + s32 didAllocate; + AudioRelocInfo relocInfo; + s32 realFontId = AudioLoad_GetRealTableIndex(FONT_TABLE, fontId); + + if (gAudioContext.fontLoadStatus[realFontId] == LOAD_STATUS_1) { + return NULL; + } + + sampleBankId1 = gAudioContext.soundFonts[realFontId].sampleBankId1; + sampleBankId2 = gAudioContext.soundFonts[realFontId].sampleBankId2; + + relocInfo.sampleBankId1 = sampleBankId1; + relocInfo.sampleBankId2 = sampleBankId2; + if (relocInfo.sampleBankId1 != 0xFF) { + relocInfo.baseAddr1 = AudioLoad_TrySyncLoadSampleBank(relocInfo.sampleBankId1, &relocInfo.medium1, false); + } else { + relocInfo.baseAddr1 = 0; + } + + if (sampleBankId2 != 0xFF) { + relocInfo.baseAddr2 = AudioLoad_TrySyncLoadSampleBank(sampleBankId2, &relocInfo.medium2, false); + } else { + relocInfo.baseAddr2 = 0; + } + + fontData = AudioLoad_SyncLoad(FONT_TABLE, fontId, &didAllocate); + if (fontData == NULL) { + return NULL; + } + if (didAllocate == true) { + AudioLoad_RelocateFontAndPreloadSamples(realFontId, fontData, &relocInfo, false); + } + + return fontData; +} + +void* AudioLoad_SyncLoad(s32 tableType, u32 id, s32* didAllocate) { + size_t size; + AudioTable* table; + s32 medium2; + u32 medium; + s32 loadStatus; + uintptr_t romAddr; + s32 cachePolicy; + void* ramAddr; + u32 realId; + s32 mediumUnk = MEDIUM_UNK; + + realId = AudioLoad_GetRealTableIndex(tableType, id); + ramAddr = AudioLoad_SearchCaches(tableType, realId); + if (ramAddr != NULL) { + *didAllocate = false; + loadStatus = LOAD_STATUS_2; + } else { + table = AudioLoad_GetLoadTable(tableType); + size = table->entries[realId].size; + size = ALIGN16(size); + medium = table->entries[id].medium; + cachePolicy = table->entries[id].cachePolicy; + romAddr = table->entries[realId].romAddr; + switch (cachePolicy) { + case CACHE_LOAD_PERMANENT: + ramAddr = AudioHeap_AllocPermanent(tableType, realId, size); + if (ramAddr == NULL) { + return ramAddr; + } + break; + + case CACHE_LOAD_PERSISTENT: + ramAddr = AudioHeap_AllocCached(tableType, size, CACHE_PERSISTENT, realId); + if (ramAddr == NULL) { + return ramAddr; + } + break; + case CACHE_LOAD_TEMPORARY: + ramAddr = AudioHeap_AllocCached(tableType, size, CACHE_TEMPORARY, realId); + if (ramAddr == NULL) { + return ramAddr; + } + break; + + case CACHE_LOAD_EITHER: + case CACHE_LOAD_EITHER_NOSYNC: + ramAddr = AudioHeap_AllocCached(tableType, size, CACHE_EITHER, realId); + if (ramAddr == NULL) { + return ramAddr; + } + break; + } + + *didAllocate = true; + + medium2 = medium; + if (medium == MEDIUM_RAM_UNLOADED) { + if (romAddr == 0) { + return NULL; + } + + if (tableType == FONT_TABLE) { + SoundFont* soundFont = &gAudioContext.soundFonts[realId]; + + soundFont->numInstruments = ((UnloadedFonts*)romAddr)->numInstruments; + soundFont->numDrums = ((UnloadedFonts*)romAddr)->numDrums; + soundFont->numSfx = ((UnloadedFonts*)romAddr)->numSfx; + romAddr += 0x10; + size -= 0x10; + } + + bcopy(romAddr, ramAddr, size); + } else if (medium2 == mediumUnk) { + AudioLoad_SyncDmaUnkMedium(romAddr, ramAddr, size, (s16)table->unkMediumParam); + } else { + AudioLoad_SyncDma(romAddr, ramAddr, size, medium); + } + + loadStatus = (cachePolicy == CACHE_LOAD_PERMANENT) ? LOAD_STATUS_5 : LOAD_STATUS_2; + } + + switch (tableType) { + case SEQUENCE_TABLE: + AudioLoad_SetSeqLoadStatus(realId, loadStatus); + break; + case FONT_TABLE: + AudioLoad_SetFontLoadStatus(realId, loadStatus); + break; + case SAMPLE_TABLE: + AudioLoad_SetSampleFontLoadStatusAndApplyCaches(realId, loadStatus); + break; + default: + break; + } + + return ramAddr; +} + +u32 AudioLoad_GetRealTableIndex(s32 tableType, u32 id) { + AudioTable* table = AudioLoad_GetLoadTable(tableType); + + if (table->entries[id].size == 0) { + id = table->entries[id].romAddr; + } + + return id; +} + +void* AudioLoad_SearchCaches(s32 tableType, s32 id) { + void* addr; + + addr = AudioHeap_SearchPermanentCache(tableType, id); + if (addr != NULL) { + return addr; + } + + addr = AudioHeap_SearchCaches(tableType, CACHE_EITHER, id); + if (addr != NULL) { + return addr; + } + + return NULL; +} + +AudioTable* AudioLoad_GetLoadTable(s32 tableType) { + AudioTable* table; + + switch (tableType) { + case SEQUENCE_TABLE: + table = gAudioContext.sequenceTable; + break; + case FONT_TABLE: + table = gAudioContext.soundFontTable; + break; + default: + table = NULL; + break; + case SAMPLE_TABLE: + table = gAudioContext.sampleBankTable; + break; + } + return table; +} + +/** + * + * SoundFontData* mem -> the address of the soundFont as stored in memory + */ +void AudioLoad_RelocateFont(s32 fontId, SoundFontData* fontData, AudioRelocInfo* relocInfo) { + uintptr_t reloc; + uintptr_t reloc2; + Instrument* inst; + Drum* drum; + SoundFontSound* sfx; + s32 i; + s32 numDrums = gAudioContext.soundFonts[fontId].numDrums; + s32 numInstruments = gAudioContext.soundFonts[fontId].numInstruments; + s32 numSfx = gAudioContext.soundFonts[fontId].numSfx; + void** ptrs = (void**)fontData; + +#define BASE_OFFSET(x) (void*)((uintptr_t)(x) + (uintptr_t)(fontData)) + + // relocate drums + reloc2 = ptrs[0]; + if (1) {} + if ((reloc2 != 0) && (numDrums != 0)) { + ptrs[0] = BASE_OFFSET(reloc2); + for (i = 0; i < numDrums; i++) { + reloc = ((Drum**)ptrs[0])[i]; + if (reloc != 0) { + reloc = BASE_OFFSET(reloc); + ((Drum**)ptrs[0])[i] = drum = reloc; + if (!drum->loaded) { + AudioLoad_RelocateSample(&drum->sound, fontData, relocInfo); + reloc = drum->envelope; + drum->envelope = BASE_OFFSET(reloc); + drum->loaded = true; + } + } + } + } + + // relocate sfxs + reloc2 = ptrs[1]; + if (1) {} + if ((reloc2 != 0) && (numSfx != 0)) { + ptrs[1] = BASE_OFFSET(reloc2); + for (i = 0; i < numSfx; i++) { + reloc = (SoundFontSound*)ptrs[1] + i; + if (reloc != 0) { + sfx = reloc; + if (sfx->sample != NULL) { + AudioLoad_RelocateSample(sfx, fontData, relocInfo); + } + } + } + } + + if (numInstruments > 0x7E) { + numInstruments = 0x7E; + } + + // relocate instruments + for (i = 2; i <= 2 + numInstruments - 1; i++) { + if (ptrs[i] != NULL) { + ptrs[i] = BASE_OFFSET(ptrs[i]); + inst = ptrs[i]; + if (!inst->loaded) { + if (inst->normalRangeLo != 0) { + AudioLoad_RelocateSample(&inst->lowNotesSound, fontData, relocInfo); + } + AudioLoad_RelocateSample(&inst->normalNotesSound, fontData, relocInfo); + if (inst->normalRangeHi != 0x7F) { + AudioLoad_RelocateSample(&inst->highNotesSound, fontData, relocInfo); + } + + reloc = inst->envelope; + inst->envelope = BASE_OFFSET(reloc); + inst->loaded = true; + } + } + } + +#undef BASE_OFFSET + + gAudioContext.soundFonts[fontId].drums = ptrs[0]; + gAudioContext.soundFonts[fontId].soundEffects = ptrs[1]; + gAudioContext.soundFonts[fontId].instruments = (Instrument**)(&ptrs[2]); +} + +void AudioLoad_SyncDma(uintptr_t devAddr, u8* ramAddr, size_t size, s32 medium) { + OSMesgQueue* msgQueue = &gAudioContext.syncDmaQueue; + OSIoMesg* ioMesg = &gAudioContext.syncDmaIoMesg; + size = ALIGN16(size); + + Audio_InvalDCache(ramAddr, size); + + while (true) { + if (size < 0x400) { + break; + } + AudioLoad_Dma(ioMesg, OS_MESG_PRI_HIGH, OS_READ, devAddr, ramAddr, 0x400, msgQueue, medium, "FastCopy"); + osRecvMesg(msgQueue, NULL, OS_MESG_BLOCK); + size -= 0x400; + devAddr += 0x400; + ramAddr += 0x400; + } + + if (size != 0) { + AudioLoad_Dma(ioMesg, OS_MESG_PRI_HIGH, OS_READ, devAddr, ramAddr, size, msgQueue, medium, "FastCopy"); + osRecvMesg(msgQueue, NULL, OS_MESG_BLOCK); + } +} + +void AudioLoad_SyncDmaUnkMedium(uintptr_t devAddr, u8* ramAddr, size_t size, s32 unkMediumParam) { +} + +s32 AudioLoad_Dma(OSIoMesg* mesg, u32 priority, s32 direction, uintptr_t devAddr, void* ramAddr, size_t size, + OSMesgQueue* reqQueue, s32 medium, const char* dmaFuncType) { + OSPiHandle* handle; + + if (gAudioContext.resetTimer > 16) { + return -1; + } + + switch (medium) { + case MEDIUM_CART: + handle = gAudioContext.cartHandle; + break; + + case MEDIUM_DISK_DRIVE: + // driveHandle is uninitialized and corresponds to stubbed-out disk drive support. + // SM64 Shindou called osDriveRomInit here. + handle = gAudioContext.driveHandle; + break; + + default: + return 0; + } + + if ((size % 0x10) != 0) { + size = ALIGN16(size); + } + + mesg->hdr.pri = priority; + mesg->hdr.retQueue = reqQueue; + mesg->dramAddr = ramAddr; + mesg->devAddr = devAddr; + mesg->size = size; + handle->transferInfo.cmdType = 2; + sDmaHandler(handle, mesg, direction); + return 0; +} + +void AudioLoad_Unused1(void) { +} + +void AudioLoad_SyncLoadSimple(u32 tableType, u32 fontId) { + s32 didAllocate; + + AudioLoad_SyncLoad(tableType, fontId, &didAllocate); +} + +void* AudioLoad_AsyncLoadInner(s32 tableType, s32 id, s32 nChunks, s32 retData, OSMesgQueue* retQueue) { + size_t size; + AudioTable* table; + void* ramAddr; + s32 medium; + s8 cachePolicy; + uintptr_t romAddr; + s32 loadStatus; + SoundFont* soundFont; + u32 realId = AudioLoad_GetRealTableIndex(tableType, id); + u32 pad; + + switch (tableType) { + case SEQUENCE_TABLE: + if (gAudioContext.seqLoadStatus[realId] == LOAD_STATUS_1) { + return NULL; + } + break; + + case FONT_TABLE: + if (gAudioContext.fontLoadStatus[realId] == LOAD_STATUS_1) { + return NULL; + } + break; + + case SAMPLE_TABLE: + if (gAudioContext.sampleFontLoadStatus[realId] == LOAD_STATUS_1) { + return NULL; + } + break; + } + + ramAddr = AudioLoad_SearchCaches(tableType, realId); + if (ramAddr != NULL) { + loadStatus = LOAD_STATUS_2; + osSendMesg(retQueue, MK_ASYNC_MSG(retData, 0, 0, LOAD_STATUS_0), OS_MESG_NOBLOCK); + } else { + table = AudioLoad_GetLoadTable(tableType); + size = table->entries[realId].size; + size = ALIGN16(size); + medium = table->entries[id].medium; + cachePolicy = table->entries[id].cachePolicy; + romAddr = table->entries[realId].romAddr; + loadStatus = LOAD_STATUS_2; + + switch (cachePolicy) { + case CACHE_LOAD_PERMANENT: + ramAddr = AudioHeap_AllocPermanent(tableType, realId, size); + if (ramAddr == NULL) { + return ramAddr; + } + loadStatus = LOAD_STATUS_5; + break; + + case CACHE_LOAD_PERSISTENT: + ramAddr = AudioHeap_AllocCached(tableType, size, CACHE_PERSISTENT, realId); + if (ramAddr == NULL) { + return ramAddr; + } + break; + + case CACHE_LOAD_TEMPORARY: + ramAddr = AudioHeap_AllocCached(tableType, size, CACHE_TEMPORARY, realId); + if (ramAddr == NULL) { + return ramAddr; + } + break; + + case CACHE_LOAD_EITHER: + case CACHE_LOAD_EITHER_NOSYNC: + ramAddr = AudioHeap_AllocCached(tableType, size, CACHE_EITHER, realId); + if (ramAddr == NULL) { + return ramAddr; + } + break; + } + + if (medium == MEDIUM_RAM_UNLOADED) { + if (romAddr == 0) { + return NULL; + } + + if (tableType == FONT_TABLE) { + soundFont = &gAudioContext.soundFonts[realId]; + + soundFont->numInstruments = ((UnloadedFonts*)romAddr)->numInstruments; + soundFont->numDrums = ((UnloadedFonts*)romAddr)->numDrums; + soundFont->numSfx = ((UnloadedFonts*)romAddr)->numSfx; + romAddr += 0x10; + size += -0x10; + } + } + + if (medium == MEDIUM_UNK) { + AudioLoad_StartAsyncLoadUnkMedium((s16)table->unkMediumParam, romAddr, ramAddr, size, medium, nChunks, + retQueue, MK_ASYNC_MSG(retData, tableType, realId, loadStatus)); + } else { + AudioLoad_StartAsyncLoad(romAddr, ramAddr, size, medium, nChunks, retQueue, + MK_ASYNC_MSG(retData, tableType, realId, loadStatus)); + } + + loadStatus = LOAD_STATUS_1; + } + + switch (tableType) { + case SEQUENCE_TABLE: + AudioLoad_SetSeqLoadStatus(realId, loadStatus); + break; + case FONT_TABLE: + AudioLoad_SetFontLoadStatus(realId, loadStatus); + break; + case SAMPLE_TABLE: + AudioLoad_SetSampleFontLoadStatusAndApplyCaches(realId, loadStatus); + break; + default: + break; + } + + return ramAddr; +} + +void AudioLoad_ProcessLoads(s32 resetStatus) { + AudioLoad_ProcessSlowLoads(resetStatus); + AudioLoad_ProcessSamplePreloads(resetStatus); + AudioLoad_ProcessAsyncLoads(resetStatus); +} + +void AudioLoad_SetDmaHandler(DmaHandler callback) { + sDmaHandler = callback; +} + +void AudioLoad_SetUnusedHandler(void* callback) { + sUnusedHandler = callback; +} + +void AudioLoad_InitSoundFontMeta(s32 fontId) { + SoundFont* font = &gAudioContext.soundFonts[fontId]; + AudioTableEntry* entry = &gAudioContext.soundFontTable->entries[fontId]; + + font->sampleBankId1 = (entry->shortData1 >> 8) & 0xFF; + font->sampleBankId2 = (entry->shortData1) & 0xFF; + font->numInstruments = (entry->shortData2 >> 8) & 0xFF; + font->numDrums = entry->shortData2 & 0xFF; + font->numSfx = entry->shortData3; +} + +void AudioLoad_Init(void* heap, size_t heapSize) { + s32 pad1[9]; + s32 numFonts; + s32 pad2[2]; + u8* audioContextPtr; + void* addr; + s32 i; + s32 j; + + D_80208E68 = NULL; + D_80208E70 = NULL; + D_80208E74 = NULL; + + for (i = 0; i < ARRAY_COUNT(gAudioContext.unk_29A8); i++) { + gAudioContext.unk_29A8[i] = NULL; + } + + gAudioContext.resetTimer = 0; + gAudioContext.unk_29B8 = false; + + // Set all of gAudioContext to 0 + audioContextPtr = (u8*)&gAudioContext; + for (j = sizeof(gAudioContext); j >= 0; j--) { + *audioContextPtr++ = 0; + } + + switch (osTvType) { + case OS_TV_PAL: + gAudioContext.unk_2960 = 20.03042f; + gAudioContext.refreshRate = 50; + break; + + case OS_TV_MPAL: + gAudioContext.unk_2960 = 16.546f; + gAudioContext.refreshRate = 60; + break; + + case OS_TV_NTSC: + default: + gAudioContext.unk_2960 = 16.713f; + gAudioContext.refreshRate = 60; + } + + Audio_InitMesgQueues(); + + for (i = 0; i < ARRAY_COUNT(gAudioContext.aiBufLengths); i++) { + gAudioContext.aiBufLengths[i] = 0xA0; + } + + gAudioContext.totalTaskCount = 0; + gAudioContext.rspTaskIndex = 0; + gAudioContext.curAiBuffferIndex = 0; + gAudioContext.soundMode = AUDIO_MODE_STEREO; + gAudioContext.curTask = NULL; + gAudioContext.rspTask[0].task.t.dataSize = 0; + gAudioContext.rspTask[1].task.t.dataSize = 0; + + osCreateMesgQueue(&gAudioContext.syncDmaQueue, &gAudioContext.syncDmaMesg, 1); + osCreateMesgQueue(&gAudioContext.currAudioFrameDmaQueue, gAudioContext.currAudioFrameDmaMesgBuf, + ARRAY_COUNT(gAudioContext.currAudioFrameDmaMesgBuf)); + osCreateMesgQueue(&gAudioContext.externalLoadQueue, gAudioContext.externalLoadMesgBuf, + ARRAY_COUNT(gAudioContext.externalLoadMesgBuf)); + osCreateMesgQueue(&gAudioContext.preloadSampleQueue, gAudioContext.preloadSampleMesgBuf, + ARRAY_COUNT(gAudioContext.preloadSampleMesgBuf)); + gAudioContext.curAudioFrameDmaCount = 0; + gAudioContext.sampleDmaCount = 0; + gAudioContext.cartHandle = osCartRomInit(); + + if (heap == NULL) { + gAudioContext.audioHeap = gAudioHeap; + gAudioContext.audioHeapSize = gAudioContextInitSizes.heapSize; + } else { + void** hp = &heap; + gAudioContext.audioHeap = *hp; + gAudioContext.audioHeapSize = heapSize; + } + + for (i = 0; i < (s32)gAudioContext.audioHeapSize / 8; i++) { + ((u64*)gAudioContext.audioHeap)[i] = 0; + } + + // Main Pool Split (split entirety of audio heap into initPool and sessionPool) + AudioHeap_InitMainPool(gAudioContextInitSizes.mainPoolSplitSize); + + // Initialize the audio interface buffer + for (i = 0; i < ARRAY_COUNT(gAudioContext.aiBuffers); i++) { + gAudioContext.aiBuffers[i] = AudioHeap_AllocZeroed(&gAudioContext.audioInitPool, AIBUF_LEN * sizeof(s16)); + } + + // Connect audio tables to their tables in memory + gAudioContext.sequenceTable = (AudioTable*)gSequenceTable; + gAudioContext.soundFontTable = (AudioTable*)gSoundFontTable; + gAudioContext.sampleBankTable = (AudioTable*)gSampleBankTable; + gAudioContext.sequenceFontTable = gSequenceFontTable; + + gAudioContext.numSequences = gAudioContext.sequenceTable->numEntries; + + gAudioContext.audioResetSpecIdToLoad = 0; + gAudioContext.resetStatus = 1; // Set reset to immediately initialize the audio heap + AudioHeap_ResetStep(); + + // Initialize audio tables + AudioLoad_InitTable(gAudioContext.sequenceTable, SEGMENT_ROM_START(Audioseq), 0); + AudioLoad_InitTable(gAudioContext.soundFontTable, SEGMENT_ROM_START(Audiobank), 0); + AudioLoad_InitTable(gAudioContext.sampleBankTable, SEGMENT_ROM_START(Audiotable), 0); + + numFonts = gAudioContext.soundFontTable->numEntries; + gAudioContext.soundFonts = AudioHeap_Alloc(&gAudioContext.audioInitPool, numFonts * sizeof(SoundFont)); + + for (i = 0; i < numFonts; i++) { + AudioLoad_InitSoundFontMeta(i); + } + + if (addr = AudioHeap_Alloc(&gAudioContext.audioInitPool, gAudioContextInitSizes.permanentPoolSize), addr == NULL) { + // cast away const from D_8014A6C4 + *((u32*)&gAudioContextInitSizes.permanentPoolSize) = 0; + } + + AudioHeap_AllocPoolInit(&gAudioContext.permanentPool, addr, gAudioContextInitSizes.permanentPoolSize); + gAudioContextInitalized = true; + osSendMesg(gAudioContext.taskStartQueueP, (void*)gAudioContext.totalTaskCount, OS_MESG_NOBLOCK); +} + +void AudioLoad_InitSlowLoads(void) { + gAudioContext.slowLoads[0].status = 0; + gAudioContext.slowLoads[1].status = 0; +} + +s32 AudioLoad_SlowLoadSample(s32 fontId, s32 instId, s8* isDone) { + SoundFontSample* sample; + AudioSlowLoad* slowLoad; + + sample = AudioLoad_GetFontSample(fontId, instId); + if (sample == NULL) { + *isDone = 0; + return -1; + } + + if (sample->medium == MEDIUM_RAM) { + *isDone = 2; + return 0; + } + + slowLoad = &gAudioContext.slowLoads[gAudioContext.slowLoadPos]; + if (slowLoad->status == LOAD_STATUS_DONE) { + slowLoad->status = LOAD_STATUS_WAITING; + } + + slowLoad->sample = *sample; + slowLoad->isDone = isDone; + slowLoad->curRamAddr = + AudioHeap_AllocSampleCache(sample->size, fontId, sample->sampleAddr, (s32)sample->medium, CACHE_TEMPORARY); + + if (slowLoad->curRamAddr == NULL) { + if (sample->medium == MEDIUM_UNK || sample->codec == CODEC_S16_INMEMORY) { + *isDone = 0; + return -1; + } else { + *isDone = 3; + return -1; + } + } + + slowLoad->status = LOAD_STATUS_START; + slowLoad->bytesRemaining = ALIGN16(sample->size); + slowLoad->ramAddr = slowLoad->curRamAddr; + slowLoad->curDevAddr = sample->sampleAddr; + slowLoad->medium = sample->medium; + slowLoad->seqOrFontId = fontId; + slowLoad->instId = instId; + + if (slowLoad->medium == MEDIUM_UNK) { + slowLoad->unkMediumParam = gAudioContext.sampleBankTable->unkMediumParam; + } + + gAudioContext.slowLoadPos ^= 1; + return 0; +} + +SoundFontSample* AudioLoad_GetFontSample(s32 fontId, s32 instId) { + SoundFontSample* sample; + + if (instId < 0x80) { + Instrument* instrument = AudioPlayback_GetInstrumentInner(fontId, instId); + + if (instrument == NULL) { + return NULL; + } + sample = instrument->normalNotesSound.sample; + } else if (instId < 0x100) { + Drum* drum = AudioPlayback_GetDrum(fontId, instId - 0x80); + + if (drum == NULL) { + return NULL; + } + sample = drum->sound.sample; + } else { + SoundFontSound* sound = AudioPlayback_GetSfx(fontId, instId - 0x100); + + if (sound == NULL) { + return NULL; + } + sample = sound->sample; + } + + return sample; +} + +void AudioLoad_Unused2(void) { +} + +void AudioLoad_FinishSlowLoad(AudioSlowLoad* slowLoad) { + SoundFontSample* sample; + + if (slowLoad->sample.sampleAddr == NULL) { + return; + } + + sample = AudioLoad_GetFontSample(slowLoad->seqOrFontId, slowLoad->instId); + if (sample == NULL) { + return; + } + + slowLoad->sample = *sample; + sample->sampleAddr = slowLoad->ramAddr; + sample->medium = MEDIUM_RAM; +} + +void AudioLoad_ProcessSlowLoads(s32 resetStatus) { + AudioSlowLoad* slowLoad; + s32 i; + + for (i = 0; i < ARRAY_COUNT(gAudioContext.slowLoads); i++) { + slowLoad = &gAudioContext.slowLoads[i]; + switch (gAudioContext.slowLoads[i].status) { + case LOAD_STATUS_LOADING: + if (slowLoad->medium != MEDIUM_UNK) { + osRecvMesg(&slowLoad->msgqueue, NULL, OS_MESG_BLOCK); + } + + if (resetStatus != 0) { + slowLoad->status = LOAD_STATUS_DONE; + continue; + } + case LOAD_STATUS_START: + slowLoad->status = LOAD_STATUS_LOADING; + if (slowLoad->bytesRemaining == 0) { + AudioLoad_FinishSlowLoad(slowLoad); + slowLoad->status = LOAD_STATUS_DONE; + *slowLoad->isDone = 1; + } else if ((s32)slowLoad->bytesRemaining < 0x400) { + if (slowLoad->medium == MEDIUM_UNK) { + size_t size = slowLoad->bytesRemaining; + + AudioLoad_DmaSlowCopyUnkMedium(slowLoad->curDevAddr, slowLoad->curRamAddr, size, + slowLoad->unkMediumParam); + } else { + AudioLoad_DmaSlowCopy(slowLoad, slowLoad->bytesRemaining); + } + slowLoad->bytesRemaining = 0; + } else { + if (slowLoad->medium == MEDIUM_UNK) { + AudioLoad_DmaSlowCopyUnkMedium(slowLoad->curDevAddr, slowLoad->curRamAddr, 0x400, + slowLoad->unkMediumParam); + } else { + AudioLoad_DmaSlowCopy(slowLoad, 0x400); + } + slowLoad->bytesRemaining -= 0x400; + slowLoad->curRamAddr += 0x400; + slowLoad->curDevAddr += 0x400; + } + break; + } + } +} + +void AudioLoad_DmaSlowCopy(AudioSlowLoad* slowLoad, size_t size) { + Audio_InvalDCache(slowLoad->curRamAddr, size); + osCreateMesgQueue(&slowLoad->msgqueue, &slowLoad->msg, 1); + AudioLoad_Dma(&slowLoad->ioMesg, OS_MESG_PRI_NORMAL, OS_READ, slowLoad->curDevAddr, slowLoad->curRamAddr, size, + &slowLoad->msgqueue, slowLoad->medium, "SLOWCOPY"); +} + +void AudioLoad_DmaSlowCopyUnkMedium(intptr_t devAddr, intptr_t ramAddr, size_t size, s32 arg3) { +} + +s32 AudioLoad_SlowLoadSeq(s32 seqId, u8* ramAddr, s8* isDone) { + AudioSlowLoad* slowLoad; + AudioTable* seqTable; + size_t size; + + if (seqId >= gAudioContext.numSequences) { + *isDone = 0; + return -1; + } + + seqId = AudioLoad_GetRealTableIndex(SEQUENCE_TABLE, seqId); + seqTable = AudioLoad_GetLoadTable(SEQUENCE_TABLE); + slowLoad = &gAudioContext.slowLoads[gAudioContext.slowLoadPos]; + if (slowLoad->status == LOAD_STATUS_DONE) { + slowLoad->status = LOAD_STATUS_WAITING; + } + + slowLoad->sample.sampleAddr = NULL; + slowLoad->isDone = isDone; + size = seqTable->entries[seqId].size; + size = ALIGN16(size); + slowLoad->curRamAddr = ramAddr; + slowLoad->status = LOAD_STATUS_START; + slowLoad->bytesRemaining = size; + slowLoad->ramAddr = ramAddr; + slowLoad->curDevAddr = seqTable->entries[seqId].romAddr; + slowLoad->medium = seqTable->entries[seqId].medium; + slowLoad->seqOrFontId = seqId; + + if (slowLoad->medium == MEDIUM_UNK) { + slowLoad->unkMediumParam = seqTable->unkMediumParam; + } + + gAudioContext.slowLoadPos ^= 1; + return 0; +} + +void AudioLoad_InitAsyncLoads(void) { + s32 i; + + for (i = 0; i < ARRAY_COUNT(gAudioContext.asyncLoads); i++) { + gAudioContext.asyncLoads[i].status = 0; + } +} + +AudioAsyncLoad* AudioLoad_StartAsyncLoadUnkMedium(s32 unkMediumParam, uintptr_t devAddr, void* ramAddr, size_t size, + s32 medium, s32 nChunks, OSMesgQueue* retQueue, s32 retMsg) { + AudioAsyncLoad* asyncLoad; + + asyncLoad = AudioLoad_StartAsyncLoad(devAddr, ramAddr, size, medium, nChunks, retQueue, retMsg); + if (asyncLoad == NULL) { + return NULL; + } + + osSendMesg(&gAudioContext.asyncLoadUnkMediumQueue, asyncLoad, OS_MESG_NOBLOCK); + asyncLoad->unkMediumParam = unkMediumParam; + return asyncLoad; +} + +AudioAsyncLoad* AudioLoad_StartAsyncLoad(uintptr_t devAddr, void* ramAddr, size_t size, s32 medium, s32 nChunks, + OSMesgQueue* retQueue, s32 retMsg) { + AudioAsyncLoad* asyncLoad; + s32 i; + + for (i = 0; i < ARRAY_COUNT(gAudioContext.asyncLoads); i++) { + if (gAudioContext.asyncLoads[i].status == 0) { + asyncLoad = &gAudioContext.asyncLoads[i]; + break; + } + } + + // no more available async loads + if (i == ARRAY_COUNT(gAudioContext.asyncLoads)) { + return NULL; + } + + asyncLoad->status = LOAD_STATUS_START; + asyncLoad->curDevAddr = devAddr; + asyncLoad->ramAddr = ramAddr; + asyncLoad->curRamAddr = ramAddr; + asyncLoad->bytesRemaining = size; + + if (nChunks == 0) { + asyncLoad->chunkSize = 0x1000; + } else if (nChunks == 1) { + asyncLoad->chunkSize = size; + } else { + asyncLoad->chunkSize = ALIGN256((s32)size / nChunks); + if (asyncLoad->chunkSize < 0x100) { + asyncLoad->chunkSize = 0x100; + } + } + + asyncLoad->retQueue = retQueue; + asyncLoad->delay = 3; + asyncLoad->medium = medium; + asyncLoad->retMsg = retMsg; + osCreateMesgQueue(&asyncLoad->msgQueue, &asyncLoad->msg, 1); + return asyncLoad; +} + +void AudioLoad_ProcessAsyncLoads(s32 resetStatus) { + AudioAsyncLoad* asyncLoad; + s32 i; + + if (gAudioContext.resetTimer == 1) { + return; + } + + if (gAudioContext.curUnkMediumLoad == NULL) { + if (resetStatus != 0) { + // Clear and ignore queue if resetting. + do { + } while (osRecvMesg(&gAudioContext.asyncLoadUnkMediumQueue, (OSMesg*)&asyncLoad, OS_MESG_NOBLOCK) != -1); + } else if (osRecvMesg(&gAudioContext.asyncLoadUnkMediumQueue, (OSMesg*)&asyncLoad, OS_MESG_NOBLOCK) == -1) { + gAudioContext.curUnkMediumLoad = NULL; + } else { + gAudioContext.curUnkMediumLoad = asyncLoad; + } + } + + if (gAudioContext.curUnkMediumLoad != NULL) { + AudioLoad_ProcessAsyncLoadUnkMedium(gAudioContext.curUnkMediumLoad, resetStatus); + } + + for (i = 0; i < ARRAY_COUNT(gAudioContext.asyncLoads); i++) { + if (gAudioContext.asyncLoads[i].status == 1) { + asyncLoad = &gAudioContext.asyncLoads[i]; + if (asyncLoad->medium != MEDIUM_UNK) { + AudioLoad_ProcessAsyncLoad(asyncLoad, resetStatus); + } + } + } +} + +void AudioLoad_ProcessAsyncLoadUnkMedium(AudioAsyncLoad* asyncLoad, s32 resetStatus) { +} + +void AudioLoad_FinishAsyncLoad(AudioAsyncLoad* asyncLoad) { + u32 retMsg = asyncLoad->retMsg; + u32 fontId; + u32 pad; + OSMesg doneMsg; + u32 sampleBankId1; + u32 sampleBankId2; + AudioRelocInfo relocInfo; + + if (1) {} + switch (ASYNC_TBLTYPE(retMsg)) { + case SEQUENCE_TABLE: + AudioLoad_SetSeqLoadStatus(ASYNC_ID(retMsg), ASYNC_STATUS(retMsg)); + break; + case SAMPLE_TABLE: + AudioLoad_SetSampleFontLoadStatusAndApplyCaches(ASYNC_ID(retMsg), ASYNC_STATUS(retMsg)); + break; + case FONT_TABLE: + fontId = ASYNC_ID(retMsg); + sampleBankId1 = gAudioContext.soundFonts[fontId].sampleBankId1; + sampleBankId2 = gAudioContext.soundFonts[fontId].sampleBankId2; + relocInfo.sampleBankId1 = sampleBankId1; + relocInfo.sampleBankId2 = sampleBankId2; + relocInfo.baseAddr1 = + sampleBankId1 != 0xFF ? AudioLoad_GetSampleBank(sampleBankId1, &relocInfo.medium1) : 0; + relocInfo.baseAddr2 = + sampleBankId2 != 0xFF ? AudioLoad_GetSampleBank(sampleBankId2, &relocInfo.medium2) : 0; + AudioLoad_SetFontLoadStatus(fontId, ASYNC_STATUS(retMsg)); + AudioLoad_RelocateFontAndPreloadSamples(fontId, asyncLoad->ramAddr, &relocInfo, true); + break; + } + + doneMsg = asyncLoad->retMsg; + if (1) {} + asyncLoad->status = LOAD_STATUS_WAITING; + osSendMesg(asyncLoad->retQueue, doneMsg, OS_MESG_NOBLOCK); +} + +void AudioLoad_ProcessAsyncLoad(AudioAsyncLoad* asyncLoad, s32 resetStatus) { + AudioTable* sampleBankTable = gAudioContext.sampleBankTable; + + if (asyncLoad->delay >= 2) { + asyncLoad->delay--; + return; + } + + if (asyncLoad->delay == 1) { + asyncLoad->delay = 0; + } else if (resetStatus != 0) { + // Await the previous DMA response synchronously, then return. + osRecvMesg(&asyncLoad->msgQueue, NULL, OS_MESG_BLOCK); + asyncLoad->status = LOAD_STATUS_WAITING; + return; + } else if (osRecvMesg(&asyncLoad->msgQueue, NULL, OS_MESG_NOBLOCK) == -1) { + // If the previous DMA step isn't done, return. + return; + } + + if (asyncLoad->bytesRemaining == 0) { + AudioLoad_FinishAsyncLoad(asyncLoad); + return; + } + + if (asyncLoad->bytesRemaining < asyncLoad->chunkSize) { + if (asyncLoad->medium == MEDIUM_UNK) { + AudioLoad_AsyncDmaUnkMedium(asyncLoad->curDevAddr, asyncLoad->curRamAddr, asyncLoad->bytesRemaining, + sampleBankTable->unkMediumParam); + } else if (asyncLoad->medium == MEDIUM_RAM_UNLOADED) { + AudioLoad_AsyncDmaRamUnloaded(asyncLoad, asyncLoad->bytesRemaining); + } else { + AudioLoad_AsyncDma(asyncLoad, asyncLoad->bytesRemaining); + } + asyncLoad->bytesRemaining = 0; + return; + } + + if (asyncLoad->medium == MEDIUM_UNK) { + AudioLoad_AsyncDmaUnkMedium(asyncLoad->curDevAddr, asyncLoad->curRamAddr, asyncLoad->chunkSize, + sampleBankTable->unkMediumParam); + } else if (asyncLoad->medium == MEDIUM_RAM_UNLOADED) { + AudioLoad_AsyncDmaRamUnloaded(asyncLoad, asyncLoad->chunkSize); + } else { + AudioLoad_AsyncDma(asyncLoad, asyncLoad->chunkSize); + } + + asyncLoad->bytesRemaining -= asyncLoad->chunkSize; + asyncLoad->curDevAddr += asyncLoad->chunkSize; + asyncLoad->curRamAddr = asyncLoad->curRamAddr + asyncLoad->chunkSize; +} + +void AudioLoad_AsyncDma(AudioAsyncLoad* asyncLoad, size_t size) { + if (size) {} + size = ALIGN16(size); + Audio_InvalDCache(asyncLoad->curRamAddr, size); + osCreateMesgQueue(&asyncLoad->msgQueue, &asyncLoad->msg, 1); + AudioLoad_Dma(&asyncLoad->ioMesg, OS_MESG_PRI_NORMAL, OS_READ, asyncLoad->curDevAddr, asyncLoad->curRamAddr, size, + &asyncLoad->msgQueue, asyncLoad->medium, "BGCOPY"); +} + +void AudioLoad_AsyncDmaRamUnloaded(AudioAsyncLoad* asyncLoad, size_t size) { + if (size) {} + size = ALIGN16(size); + Audio_InvalDCache(asyncLoad->curRamAddr, size); + osCreateMesgQueue(&asyncLoad->msgQueue, &asyncLoad->msg, 1); + bcopy(asyncLoad->curDevAddr, asyncLoad->curRamAddr, size); + osSendMesg(&asyncLoad->msgQueue, NULL, OS_MESG_NOBLOCK); +} + +void AudioLoad_AsyncDmaUnkMedium(uintptr_t devAddr, void* ramAddr, size_t size, s16 arg3) { +} + +#define RELOC(v, base) (reloc = (void*)((uintptr_t)(v) + (uintptr_t)(base))) + +void AudioLoad_RelocateSample(SoundFontSound* sound, SoundFontData* mem, AudioRelocInfo* relocInfo) { + SoundFontSample* sample; + void* reloc; + + if ((uintptr_t)sound->sample <= 0x80000000) { + sample = sound->sample = RELOC(sound->sample, mem); + if (sample->size != 0 && sample->unk_bit25 != true) { + sample->loop = RELOC(sample->loop, mem); + sample->book = RELOC(sample->book, mem); + + // Resolve the sample medium 2-bit bitfield into a real value based on relocInfo. + switch (sample->medium) { + case 0: + sample->sampleAddr = RELOC(sample->sampleAddr, relocInfo->baseAddr1); + sample->medium = relocInfo->medium1; + break; + case 1: + sample->sampleAddr = RELOC(sample->sampleAddr, relocInfo->baseAddr2); + sample->medium = relocInfo->medium2; + break; + case 2: + case 3: + // Invalid? This leaves sample->medium as MEDIUM_CART and MEDIUM_DISK_DRIVE + // respectively, and the sampleAddr unrelocated. + break; + } + + sample->unk_bit25 = true; + if (sample->unk_bit26 && (sample->medium != MEDIUM_RAM)) { + gAudioContext.usedSamples[gAudioContext.numUsedSamples++] = sample; + } + } + } +} + +#undef RELOC + +void AudioLoad_RelocateFontAndPreloadSamples(s32 fontId, SoundFontData* mem, AudioRelocInfo* relocInfo, s32 async) { + AudioPreloadReq* preload; + AudioPreloadReq* topPreload; + SoundFontSample* sample; + size_t size; + s32 nChunks; + u8* sampleRamAddr; + s32 preloadInProgress; + s32 i; + + preloadInProgress = false; + if (gAudioContext.preloadSampleStackTop != 0) { + preloadInProgress = true; + } else { + D_801FD1E0 = 0; + } + + gAudioContext.numUsedSamples = 0; + AudioLoad_RelocateFont(fontId, mem, relocInfo); + + size = 0; + for (i = 0; i < gAudioContext.numUsedSamples; i++) { + size += ALIGN16(gAudioContext.usedSamples[i]->size); + } + if (size && size) {} + + for (i = 0; i < gAudioContext.numUsedSamples; i++) { + if (gAudioContext.preloadSampleStackTop == 120) { + break; + } + + sample = gAudioContext.usedSamples[i]; + sampleRamAddr = NULL; + switch (async) { + case false: + if (sample->medium == relocInfo->medium1) { + sampleRamAddr = AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId1, + sample->sampleAddr, sample->medium, CACHE_PERSISTENT); + } else if (sample->medium == relocInfo->medium2) { + sampleRamAddr = AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId2, + sample->sampleAddr, sample->medium, CACHE_PERSISTENT); + } else if (sample->medium == MEDIUM_DISK_DRIVE) { + sampleRamAddr = AudioHeap_AllocSampleCache(sample->size, 0xFE, sample->sampleAddr, sample->medium, + CACHE_PERSISTENT); + } + break; + + case true: + if (sample->medium == relocInfo->medium1) { + sampleRamAddr = AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId1, + sample->sampleAddr, sample->medium, CACHE_TEMPORARY); + } else if (sample->medium == relocInfo->medium2) { + sampleRamAddr = AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId2, + sample->sampleAddr, sample->medium, CACHE_TEMPORARY); + } else if (sample->medium == MEDIUM_DISK_DRIVE) { + sampleRamAddr = AudioHeap_AllocSampleCache(sample->size, 0xFE, sample->sampleAddr, sample->medium, + CACHE_TEMPORARY); + } + break; + } + if (sampleRamAddr == NULL) { + continue; + } + + switch (async) { + case false: + if (sample->medium == MEDIUM_UNK) { + AudioLoad_SyncDmaUnkMedium((uintptr_t)sample->sampleAddr, sampleRamAddr, sample->size, + gAudioContext.sampleBankTable->unkMediumParam); + sample->sampleAddr = sampleRamAddr; + sample->medium = MEDIUM_RAM; + } else { + AudioLoad_SyncDma((uintptr_t)sample->sampleAddr, sampleRamAddr, sample->size, sample->medium); + sample->sampleAddr = sampleRamAddr; + sample->medium = MEDIUM_RAM; + } + if (sample->medium == MEDIUM_DISK_DRIVE) {} + break; + + case true: + preload = &gAudioContext.preloadSampleStack[gAudioContext.preloadSampleStackTop]; + preload->sample = sample; + preload->ramAddr = sampleRamAddr; + preload->encodedInfo = (gAudioContext.preloadSampleStackTop << 24) | 0xFFFFFF; + preload->isFree = false; + preload->endAndMediumKey = (uintptr_t)sample->sampleAddr + sample->size + sample->medium; + gAudioContext.preloadSampleStackTop++; + break; + } + } + gAudioContext.numUsedSamples = 0; + + if (gAudioContext.preloadSampleStackTop != 0 && !preloadInProgress) { + topPreload = &gAudioContext.preloadSampleStack[gAudioContext.preloadSampleStackTop - 1]; + sample = topPreload->sample; + nChunks = (sample->size >> 12) + 1; + AudioLoad_StartAsyncLoad((uintptr_t)sample->sampleAddr, topPreload->ramAddr, sample->size, sample->medium, + nChunks, &gAudioContext.preloadSampleQueue, topPreload->encodedInfo); + } +} + +s32 AudioLoad_ProcessSamplePreloads(s32 resetStatus) { + SoundFontSample* sample; + AudioPreloadReq* preload; + u32 preloadIndex; + u32 key; + u32 nChunks; + s32 pad; + + if (gAudioContext.preloadSampleStackTop > 0) { + if (resetStatus != 0) { + // Clear result queue and preload stack and return. + osRecvMesg(&gAudioContext.preloadSampleQueue, (OSMesg*)&preloadIndex, OS_MESG_NOBLOCK); + gAudioContext.preloadSampleStackTop = 0; + return false; + } + if (osRecvMesg(&gAudioContext.preloadSampleQueue, (OSMesg*)&preloadIndex, OS_MESG_NOBLOCK) == -1) { + // Previous preload is not done yet. + return false; + } + + preloadIndex >>= 24; + preload = &gAudioContext.preloadSampleStack[preloadIndex]; + + if (preload->isFree == false) { + sample = preload->sample; + key = (uintptr_t)sample->sampleAddr + sample->size + sample->medium; + if (key == preload->endAndMediumKey) { + // Change storage for sample to the preloaded version. + sample->sampleAddr = preload->ramAddr; + sample->medium = MEDIUM_RAM; + } + preload->isFree = true; + } + + // Pop requests with isFree = true off the stack, as far as possible, + // and dispatch the next DMA. + for (;;) { + if (gAudioContext.preloadSampleStackTop <= 0) { + break; + } + preload = &gAudioContext.preloadSampleStack[gAudioContext.preloadSampleStackTop - 1]; + if (preload->isFree == true) { + gAudioContext.preloadSampleStackTop--; + continue; + } + + sample = preload->sample; + nChunks = (sample->size >> 12) + 1; + key = (uintptr_t)sample->sampleAddr + sample->size + sample->medium; + if (key != preload->endAndMediumKey) { + preload->isFree = true; + gAudioContext.preloadSampleStackTop--; + } else { + AudioLoad_StartAsyncLoad((uintptr_t)sample->sampleAddr, preload->ramAddr, sample->size, sample->medium, + nChunks, &gAudioContext.preloadSampleQueue, preload->encodedInfo); + break; + } + } + } + return true; +} + +s32 AudioLoad_AddToSampleSet(SoundFontSample* sample, s32 numSamples, SoundFontSample** sampleSet) { + s32 i; + + for (i = 0; i < numSamples; i++) { + if (sample->sampleAddr == sampleSet[i]->sampleAddr) { + break; + } + } + + if (i == numSamples) { + sampleSet[numSamples] = sample; + numSamples++; + } + + return numSamples; +} + +s32 AudioLoad_GetSamplesForFont(s32 fontId, SoundFontSample** sampleSet) { + s32 i; + s32 numSamples = 0; + s32 numDrums = gAudioContext.soundFonts[fontId].numDrums; + s32 numInstruments = gAudioContext.soundFonts[fontId].numInstruments; + + for (i = 0; i < numDrums; i++) { + Drum* drum = AudioPlayback_GetDrum(fontId, i); + + if (1) {} + if (drum != NULL) { + numSamples = AudioLoad_AddToSampleSet(drum->sound.sample, numSamples, sampleSet); + } + } + + for (i = 0; i < numInstruments; i++) { + Instrument* instrument = AudioPlayback_GetInstrumentInner(fontId, i); + + if (instrument != NULL) { + if (instrument->normalRangeLo != 0) { + numSamples = AudioLoad_AddToSampleSet(instrument->lowNotesSound.sample, numSamples, sampleSet); + } + if (instrument->normalRangeHi != 0x7F) { + numSamples = AudioLoad_AddToSampleSet(instrument->highNotesSound.sample, numSamples, sampleSet); + } + numSamples = AudioLoad_AddToSampleSet(instrument->normalNotesSound.sample, numSamples, sampleSet); + } + } + + // Should really also process sfx, but this method is never called + return numSamples; +} + +void AudioLoad_AddUsedSample(SoundFontSound* sound) { + SoundFontSample* sample = sound->sample; + + if ((sample->size != 0) && (sample->unk_bit26) && (sample->medium != MEDIUM_RAM)) { + gAudioContext.usedSamples[gAudioContext.numUsedSamples++] = sample; + } +} + +void AudioLoad_PreloadSamplesForFont(s32 fontId, s32 async, AudioRelocInfo* relocInfo) { + s32 numDrums; + s32 numInstruments; + s32 numSfx; + Drum* drum; + Instrument* instrument; + SoundFontSound* sound; + AudioPreloadReq* preload; + AudioPreloadReq* topPreload; + u8* addr; + size_t size; + s32 i; + SoundFontSample* sample; + s32 preloadInProgress; + s32 nChunks; + + preloadInProgress = false; + if (gAudioContext.preloadSampleStackTop != 0) { + preloadInProgress = true; + } + + gAudioContext.numUsedSamples = 0; + + numDrums = gAudioContext.soundFonts[fontId].numDrums; + numInstruments = gAudioContext.soundFonts[fontId].numInstruments; + numSfx = gAudioContext.soundFonts[fontId].numSfx; + + for (i = 0; i < numInstruments; i++) { + instrument = AudioPlayback_GetInstrumentInner(fontId, i); + if (instrument != NULL) { + if (instrument->normalRangeLo != 0) { + AudioLoad_AddUsedSample(&instrument->lowNotesSound); + } + if (instrument->normalRangeHi != 0x7F) { + AudioLoad_AddUsedSample(&instrument->highNotesSound); + } + AudioLoad_AddUsedSample(&instrument->normalNotesSound); + } + } + + for (i = 0; i < numDrums; i++) { + drum = AudioPlayback_GetDrum(fontId, i); + if (drum != NULL) { + AudioLoad_AddUsedSample(&drum->sound); + } + } + + for (i = 0; i < numSfx; i++) { + sound = AudioPlayback_GetSfx(fontId, i); + if (sound != NULL) { + AudioLoad_AddUsedSample(sound); + } + } + + if (gAudioContext.numUsedSamples == 0) { + return; + } + + size = 0; + for (i = 0; i < gAudioContext.numUsedSamples; i++) { + size += ALIGN16(gAudioContext.usedSamples[i]->size); + } + if (size) {} + + for (i = 0; i < gAudioContext.numUsedSamples; i++) { + if (gAudioContext.preloadSampleStackTop == 120) { + break; + } + + sample = gAudioContext.usedSamples[i]; + if (sample->medium == MEDIUM_RAM) { + continue; + } + + switch (async) { + case false: + if (sample->medium == relocInfo->medium1) { + addr = AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId1, sample->sampleAddr, + sample->medium, CACHE_PERSISTENT); + } else if (sample->medium == relocInfo->medium2) { + addr = AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId2, sample->sampleAddr, + sample->medium, CACHE_PERSISTENT); + } + break; + + case true: + if (sample->medium == relocInfo->medium1) { + addr = AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId1, sample->sampleAddr, + sample->medium, CACHE_TEMPORARY); + } else if (sample->medium == relocInfo->medium2) { + addr = AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId2, sample->sampleAddr, + sample->medium, CACHE_TEMPORARY); + } + break; + } + if (addr == NULL) { + continue; + } + + switch (async) { + case false: + if (sample->medium == MEDIUM_UNK) { + AudioLoad_SyncDmaUnkMedium((uintptr_t)sample->sampleAddr, addr, sample->size, + gAudioContext.sampleBankTable->unkMediumParam); + sample->sampleAddr = addr; + sample->medium = MEDIUM_RAM; + } else { + AudioLoad_SyncDma((uintptr_t)sample->sampleAddr, addr, sample->size, sample->medium); + sample->sampleAddr = addr; + sample->medium = MEDIUM_RAM; + } + break; + + case true: + preload = &gAudioContext.preloadSampleStack[gAudioContext.preloadSampleStackTop]; + preload->sample = sample; + preload->ramAddr = addr; + preload->encodedInfo = (gAudioContext.preloadSampleStackTop << 24) | 0xFFFFFF; + preload->isFree = false; + preload->endAndMediumKey = (uintptr_t)sample->sampleAddr + sample->size + sample->medium; + gAudioContext.preloadSampleStackTop++; + break; + } + } + gAudioContext.numUsedSamples = 0; + + if (gAudioContext.preloadSampleStackTop != 0 && !preloadInProgress) { + topPreload = &gAudioContext.preloadSampleStack[gAudioContext.preloadSampleStackTop - 1]; + sample = topPreload->sample; + nChunks = (sample->size >> 12) + 1; + AudioLoad_StartAsyncLoad((uintptr_t)sample->sampleAddr, topPreload->ramAddr, sample->size, sample->medium, + nChunks, &gAudioContext.preloadSampleQueue, topPreload->encodedInfo); + } +} + +void AudioLoad_LoadPermanentSamples(void) { + s32 pad; + u32 fontId; + AudioTable* sampleBankTable; + s32 pad2; + s32 i; + + sampleBankTable = AudioLoad_GetLoadTable(SAMPLE_TABLE); + for (i = 0; i < gAudioContext.permanentPool.count; i++) { + AudioRelocInfo relocInfo; + + if (gAudioContext.permanentEntries[i].tableType == FONT_TABLE) { + fontId = AudioLoad_GetRealTableIndex(FONT_TABLE, gAudioContext.permanentEntries[i].id); + relocInfo.sampleBankId1 = gAudioContext.soundFonts[fontId].sampleBankId1; + relocInfo.sampleBankId2 = gAudioContext.soundFonts[fontId].sampleBankId2; + + if (relocInfo.sampleBankId1 != 0xFF) { + relocInfo.sampleBankId1 = AudioLoad_GetRealTableIndex(SAMPLE_TABLE, relocInfo.sampleBankId1); + relocInfo.medium1 = sampleBankTable->entries[relocInfo.sampleBankId1].medium; + } + + if (relocInfo.sampleBankId2 != 0xFF) { + relocInfo.sampleBankId2 = AudioLoad_GetRealTableIndex(SAMPLE_TABLE, relocInfo.sampleBankId2); + relocInfo.medium2 = sampleBankTable->entries[relocInfo.sampleBankId2].medium; + } + AudioLoad_PreloadSamplesForFont(fontId, false, &relocInfo); + } + } +} + +void AudioLoad_Unused3(void) { +} + +void AudioLoad_Unused4(void) { +} + +void AudioLoad_Unused5(void) { +} + +void AudioLoad_ScriptLoad(s32 tableType, s32 id, s8* isDone) { + static u32 sLoadIndex = 0; + + sScriptLoadDonePointers[sLoadIndex] = isDone; + AudioLoad_AsyncLoad(tableType, id, 0, sLoadIndex, &sScriptLoadQueue); + sLoadIndex++; + if (sLoadIndex == 0x10) { + sLoadIndex = 0; + } +} + +void AudioLoad_ProcessScriptLoads(void) { + u32 temp; + u32 sp20; + s8* isDone; + + if (osRecvMesg(&sScriptLoadQueue, (OSMesg*)&sp20, OS_MESG_NOBLOCK) != -1) { + temp = sp20 >> 24; + isDone = sScriptLoadDonePointers[temp]; + if (isDone != NULL) { + *isDone = false; + } + } +} + +void AudioLoad_InitScriptLoads(void) { + osCreateMesgQueue(&sScriptLoadQueue, sScriptLoadMesgBuf, ARRAY_COUNT(sScriptLoadMesgBuf)); +} diff --git a/src/code/audio/audio_playback.c b/src/code/audio/audio_playback.c index 78161943c6..6ae5696f10 100644 --- a/src/code/audio/audio_playback.c +++ b/src/code/audio/audio_playback.c @@ -982,7 +982,7 @@ void AudioPlayback_NoteInitAll(void) { note->playbackState.portamento.speed = 0; note->playbackState.stereoHeadsetEffects = false; note->playbackState.unk_84 = 0; - note->synthesisState.synthesisBuffers = AudioHeap_AllocDmaMemory(&gAudioContext.notesAndBuffersPool, 0x2E0); - note->playbackState.attributes.filterBuf = AudioHeap_AllocDmaMemory(&gAudioContext.notesAndBuffersPool, 0x10); + note->synthesisState.synthesisBuffers = AudioHeap_AllocDmaMemory(&gAudioContext.miscPool, 0x2E0); + note->playbackState.attributes.filterBuf = AudioHeap_AllocDmaMemory(&gAudioContext.miscPool, 0x10); } } diff --git a/src/code/audio/audio_seqplayer.c b/src/code/audio/audio_seqplayer.c index 56d8ac9516..e57ad19b5a 100644 --- a/src/code/audio/audio_seqplayer.c +++ b/src/code/audio/audio_seqplayer.c @@ -20,7 +20,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_80197C8C.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_80197D24.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/AudioSeq_SequencePlayerDisableAsFinished.s") #pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/AudioSeq_SequencePlayerDisable.s") @@ -64,10 +64,10 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_8019AAF0.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_8019AB40.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/AudioSeq_ResetSequencePlayer.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_8019AC10.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/AudioSeq_InitSequencePlayerChannels.s") #pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_8019ACEC.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_8019ADBC.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/AudioSeq_InitSequencePlayers.s") diff --git a/src/code/audio/code_80192BE0.c b/src/code/audio/code_80192BE0.c index d408361c73..20b4239da7 100644 --- a/src/code/audio/code_80192BE0.c +++ b/src/code/audio/code_80192BE0.c @@ -18,7 +18,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_8019387C.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_801938A0.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/Audio_QueueCmdS8.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_801938D0.s") @@ -76,6 +76,6 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80194568.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80194668.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/Audio_NextRandom.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_801946E4.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/Audio_InitMesgQueues.s") diff --git a/src/code/audio/code_8019AF00.c b/src/code/audio/code_8019AF00.c index 17404280bc..2e7cc91e17 100644 --- a/src/code/audio/code_8019AF00.c +++ b/src/code/audio/code_8019AF00.c @@ -45,7 +45,7 @@ typedef enum { /* 0xD */ SFX_CHANNEL_OCARINA, // SfxOcarinaBank /* 0xE */ SFX_CHANNEL_VOICE0, // SfxVoiceBank /* 0xF */ SFX_CHANNEL_VOICE1 -} SfxChannelIdx; // playerIdx = 2 +} SfxChannelIndex; // playerIndex = 2 // Global IO ports for sequences, 8 global ports per seqPlayer typedef enum { @@ -66,6 +66,10 @@ typedef struct { /* 0xC */ s32 remainingFrames; } FreqLerp; // size = 0x10 +s32 AudioOcarina_MemoryGameGenerateNotes(void); +s32 Audio_SetGanonsTowerBgmVolume(u8 targetVolume); +void func_801A3238(s8 playerIndex, u16 seqId, u8 fadeTimer, s8 arg3, u8 arg4); + // Sfx bss SfxSettings sSfxSettings[8]; u8 sSfxSettingsFlags; @@ -104,7 +108,7 @@ u8 sIsFinalHoursOrSoaring; u8 sObjSoundFanfareSeqId; u8 sObjSoundFanfareRequested; Vec3f sObjSoundFanfarePos; -u8 sObjSoundPlayerIdx; +u8 sObjSoundPlayerIndex; Vec3f sObjSoundPos; s16 sObjSoundFlags; f32 sObjSoundMinDist; @@ -119,7 +123,7 @@ u8 sSpatialSeqFlags; u8 D_801FD432; u8 sSpatialSubBgmFadeTimer; u8 D_801FD434; -u8 sSpatialSeqPlayerIdx; +u8 sSpatialSeqPlayerIndex; u8 sSpatialSeqFadeTimer; u16 D_801FD438; @@ -136,8 +140,8 @@ s32 sOcaInputBtnPress; u8 sOcarinaResetDelay; u8 sOcarinaResetUnused; u8 sOcarinaHasStartedSong; -u8 sFirstOcarinaSongIdx; -u8 sLastOcarinaSongIdx; +u8 sFirstOcarinaSongIndex; +u8 sLastOcarinaSongIndex; u32 sOcarinaAvailSongs; u8 sOcarinaStaffPlayingPos; u16 sMusicStaffPos[OCARINA_SONG_MAX]; @@ -984,11 +988,11 @@ u8 sIsOcarinaInputEnabled = false; s8 sOcarinaInstrumentId = OCARINA_INSTRUMENT_OFF; u8 sCurOcarinaPitch = OCARINA_PITCH_NONE; u8 sPrevOcarinaPitch = 0; -u8 sCurOcarinaButtonIdx = 0; +u8 sCurOcarinaButtonIndex = 0; u8 sMusicStaffPrevPitch = 0; f32 sCurOcarinaBendFreq = 1.0f; f32 sDefaultOcarinaVolume = 0.68503935f; -s8 sCurOcarinaBendIdx = 0; +s8 sCurOcarinaBendIndex = 0; s8 sCurOcarinaVolume = 0x57; s8 sCurOcarinaVibrato = 0; u8 sPlaybackState = 0; @@ -1014,7 +1018,7 @@ u8 sCurOcarinaSong[8] = { u8 sOcarinaSongAppendPos = 0; u8 sOcarinaSongStartingPos = 0; -u8 sButtonToNoteMap[5] = { +u8 sButtonToPitchMap[5] = { OCARINA_PITCH_D4, // OCARINA_BTN_A OCARINA_PITCH_F4, // OCARINA_BTN_C_DOWN OCARINA_PITCH_A4, // OCARINA_BTN_C_RIGHT @@ -1022,7 +1026,7 @@ u8 sButtonToNoteMap[5] = { OCARINA_PITCH_D5, // OCARINA_BTN_C_UP }; -u8 sOcaMemoryGameAppendPos = 0; +u8 sOcarinaMemoryGameAppendPos = 0; u8 sOcaMemoryGameEndPos = 0; u8 sOcaMemoryGameNumNotes[] = { 5, 6, 8 }; OcarinaNote sOcarinaSongNotes[OCARINA_SONG_MAX][20] = { @@ -1443,9 +1447,9 @@ u32 sOcarinaRecordTaskStart = 0; u8 sRecordOcarinaPitch = 0; u8 sRecordOcarinaVolume = 0; u8 sRecordOcarinaVibrato = 0; -s8 sRecordOcarinaBendIdx = 0; -u8 sRecordOcarinaButtonIdx = 0; -u8 sPlayedOcarinaSongIdxPlusOne = 0; +s8 sRecordOcarinaBendIndex = 0; +u8 sRecordOcarinaButtonIndex = 0; +u8 sPlayedOcarinaSongIndexPlusOne = 0; u8 sMusicStaffNumNotesPerTest = 0; u8 D_801D8530 = false; u32 D_801D8534 = 0; @@ -1460,7 +1464,7 @@ OcarinaNote* gScarecrowLongSongPtr = sScarecrowsLongSongNotes; u8* gScarecrowSpawnSongPtr = (u8*)&sOcarinaSongNotes[OCARINA_SONG_SCARECROW]; OcarinaNote* sTerminaWallSongPtr = sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL]; -u8 sNoteToButtonMap[16] = { +u8 sPitchToButtonMap[16] = { OCARINA_BTN_A, // OCARINA_PITCH_C4 OCARINA_BTN_A, // OCARINA_PITCH_DFLAT4 OCARINA_BTN_A, // OCARINA_PITCH_D4 @@ -1849,6 +1853,7 @@ const u16 gAudioEnvironmentalSfx[] = { NA_SE_EV_WAVE_S - SFX_FLAG, NA_SE_EV_WAVE_S - SFX_FLAG, }; +extern const u8 sIsOcarinaSongReserved[OCARINA_SONG_MAX]; /** const u8 sIsOcarinaSongReserved[OCARINA_SONG_MAX] = { true, // OCARINA_SONG_SONATA @@ -1886,7 +1891,8 @@ const u8 sIsOcarinaSongReserved[OCARINA_SONG_MAX] = { #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019B02C.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019B074.s") +void AudioOcarina_MapSongFromNotesToButtons(u8 noteSongIndex, u8 buttonSongIndex, u8 numButtons); +#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/AudioOcarina_MapSongFromNotesToButtons.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019B144.s") @@ -1898,7 +1904,7 @@ const u8 sIsOcarinaSongReserved[OCARINA_SONG_MAX] = { #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019B4B8.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019B544.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/AudioOcarina_StartDefault.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019B568.s") @@ -1924,7 +1930,7 @@ const u8 sIsOcarinaSongReserved[OCARINA_SONG_MAX] = { #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019C2E4.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019C300.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/AudioOcarina_SetInstrumentId.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019C398.s") @@ -1953,17 +1959,154 @@ const char sAudioOcarinaUnusedText7[] = "check is over!!! %d %d %d\n"; #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019CF78.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019CF9C.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/AudioOcarina_GetPlaybackStaff.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019CFA8.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019D134.s") +/** + * Tests to see if the notes from songIndex contain identical notes + * within its song to any of the reserved songIndex from 0 up to maxSongIndex + */ +s32 AudioOcarina_TerminaWallValidateNotes(u8 songIndex, u8 maxSongIndex) { + u8 curSongIndex; + u8 j; + u8 k; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019D26C.s") + // loop through all possible songs up to maxSongIndex + for (curSongIndex = 0; curSongIndex < maxSongIndex; curSongIndex++) { + // check to see if the song is reserved or not + if (sIsOcarinaSongReserved[curSongIndex]) { + // starting index to test the song + for (j = 0; j < (9 - gOcarinaSongButtons[curSongIndex].numButtons); j++) { + // loop through each note in the song + for (k = 0; (k < gOcarinaSongButtons[curSongIndex].numButtons) && ((k + j) < 8) && + (gOcarinaSongButtons[curSongIndex].buttonIndex[k] == + gOcarinaSongButtons[songIndex].buttonIndex[(k + j)]); + k++) { + continue; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019D488.s") + if (k == gOcarinaSongButtons[curSongIndex].numButtons) { + // failure: songIndex is identical to curSongIndex. + return -1; + } + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019D4F8.s") + // success: notes are accepted and used + return 0; +} + +/** + * Generates the notes displayed on the Termina Field wall of musical notes + * Song generation loop alternates between 8 random notes and a random song from Ocarina of Time (OoT). + * Will check to see that the notes are valid by ensuring no playable song is within the selected notes + * All OoT songs are valid, so the outer loop will run a maxiumum of two times. + * i.e. if random notes fails, then the next set of notes will be from a valid OoT song + */ +void AudioOcarina_TerminaWallGenerateNotes(void) { + OcarinaNote* ocarinaNote; + u8 randButtonIndex; + u8 i; + u8 j; + + do { + i = 0; + if (sOcarinaWallCounter++ % 2) { + j = 0; + + for (; i < 8; i++) { + randButtonIndex = Audio_NextRandom() % ARRAY_COUNT(sButtonToPitchMap); + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j].pitch = sButtonToPitchMap[randButtonIndex]; + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j].length = 19; + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j].volume = 80; + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j].vibrato = 0; + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j].bend = 0; + j++; + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j].pitch = OCARINA_PITCH_NONE; + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j].length = 3; + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j].volume = 0; + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j].vibrato = 0; + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j].bend = 0; + j++; + } + + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j - 2].length = 90; + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j - 1].length = 22; + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j + 1].pitch = OCARINA_PITCH_NONE; + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j + 1].length = 0; + AudioOcarina_MapSongFromNotesToButtons(OCARINA_SONG_TERMINA_WALL, OCARINA_SONG_TERMINA_WALL, 8); + } else { + j = Audio_NextRandom() % ARRAY_COUNT(sOoTOcarinaSongNotes); + ocarinaNote = sOoTOcarinaSongNotes[j]; + + for (; ocarinaNote[i].length != 0; i++) { + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][i] = ocarinaNote[i]; + } + + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][i].pitch = OCARINA_PITCH_NONE; + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][i].length = 0; + AudioOcarina_MapSongFromNotesToButtons(OCARINA_SONG_TERMINA_WALL, OCARINA_SONG_TERMINA_WALL, + sOoTOcarinaSongsNumNotes[j]); + } + } while (AudioOcarina_TerminaWallValidateNotes(OCARINA_SONG_TERMINA_WALL, OCARINA_SONG_TERMINA_WALL) != 0); +} + +/** + * Unused remnant of OoT + */ +void AudioOcarina_MemoryGameSetNumNotes(u8 minigameRound) { + u8 i; + + if (minigameRound > 2) { + minigameRound = 2; + } + + sOcarinaMemoryGameAppendPos = 0; + sOcaMemoryGameEndPos = sOcaMemoryGameNumNotes[minigameRound]; + + for (i = 0; i < 3; i++) { + AudioOcarina_MemoryGameGenerateNotes(); + } +} + +/** + * Unused remnant of OoT, Id 14 now represent Goron Lullaby Intro instead of the OoT ocarina memory game + * //! @bug calling this function in MM will overwrite Goron Lullaby Intro + */ +#define OCARINA_SONG_MEMORYGAME 14 +s32 AudioOcarina_MemoryGameGenerateNotes(void) { + u32 randButtonIndex; + u8 randPitch; + + if (sOcarinaMemoryGameAppendPos == sOcaMemoryGameEndPos) { + return true; + } + + randButtonIndex = Audio_NextRandom(); + randPitch = sButtonToPitchMap[randButtonIndex % ARRAY_COUNT(sButtonToPitchMap)]; + + if (sOcarinaSongNotes[OCARINA_SONG_MEMORYGAME][sOcarinaMemoryGameAppendPos - 1].pitch == randPitch) { + randPitch = sButtonToPitchMap[(randButtonIndex + 1) % ARRAY_COUNT(sButtonToPitchMap)]; + } + + sOcarinaSongNotes[OCARINA_SONG_MEMORYGAME][sOcarinaMemoryGameAppendPos].pitch = randPitch; + sOcarinaSongNotes[OCARINA_SONG_MEMORYGAME][sOcarinaMemoryGameAppendPos].length = 45; + sOcarinaSongNotes[OCARINA_SONG_MEMORYGAME][sOcarinaMemoryGameAppendPos].volume = 0x50; + sOcarinaSongNotes[OCARINA_SONG_MEMORYGAME][sOcarinaMemoryGameAppendPos].vibrato = 0; + sOcarinaSongNotes[OCARINA_SONG_MEMORYGAME][sOcarinaMemoryGameAppendPos].bend = 0; + + sOcarinaMemoryGameAppendPos++; + + sOcarinaSongNotes[OCARINA_SONG_MEMORYGAME][sOcarinaMemoryGameAppendPos].pitch = OCARINA_PITCH_NONE; + sOcarinaSongNotes[OCARINA_SONG_MEMORYGAME][sOcarinaMemoryGameAppendPos].length = 0; + sOcarinaSongNotes[OCARINA_SONG_MEMORYGAME][sOcarinaMemoryGameAppendPos + 1].pitch = OCARINA_PITCH_NONE; + sOcarinaSongNotes[OCARINA_SONG_MEMORYGAME][sOcarinaMemoryGameAppendPos + 1].length = 0; + if (1) {} + return false; +} +#undef OCARINA_SONG_MEMORYGAME #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019D600.s") @@ -2071,11 +2214,50 @@ const char sAudioOcarinaUnusedText7[] = "check is over!!! %d %d %d\n"; #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019FF38.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019FF9C.s") +/** + * Used for EnRiverSound + */ +void Audio_PlaySfxForRiver(Vec3f* pos, f32 freqScale) { + if (!Audio_IsSfxPlaying(NA_SE_EV_RIVER_STREAM - SFX_FLAG)) { + sRiverFreqScaleLerp.value = freqScale; + } else if (freqScale != sRiverFreqScaleLerp.value) { + sRiverFreqScaleLerp.target = freqScale; + sRiverFreqScaleLerp.remainingFrames = 40; + sRiverFreqScaleLerp.step = (sRiverFreqScaleLerp.target - sRiverFreqScaleLerp.value) / 40; + } + Audio_PlaySfxGeneral(NA_SE_EV_RIVER_STREAM - SFX_FLAG, pos, 4, &sRiverFreqScaleLerp.value, &D_801DB4B0, + &D_801DB4B8); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0048.s") +/** + * Unused remnant of OoT's EnRiverSound + * Used for Zora's River Waterfall + */ +void Audio_PlaySfxForWaterfall(Vec3f* pos, f32 freqScale) { + if (!Audio_IsSfxPlaying(NA_SE_EV_WATER_WALL_BIG - SFX_FLAG)) { + sWaterfallFreqScaleLerp.value = freqScale; + } else if (freqScale != sWaterfallFreqScaleLerp.value) { + sWaterfallFreqScaleLerp.target = freqScale; + sWaterfallFreqScaleLerp.remainingFrames = 40; + sWaterfallFreqScaleLerp.step = (sWaterfallFreqScaleLerp.target - sWaterfallFreqScaleLerp.value) / 40; + } + Audio_PlaySfxGeneral(NA_SE_EV_WATER_WALL_BIG - SFX_FLAG, pos, 4, &sWaterfallFreqScaleLerp.value, + &sWaterfallFreqScaleLerp.value, &D_801DB4B8); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A00EC.s") +/** + * Used for EnRiverSound variables + */ +void Audio_StepFreqLerp(FreqLerp* lerp) { + if (lerp->remainingFrames != 0) { + lerp->remainingFrames--; + if (lerp->remainingFrames != 0) { + lerp->value += lerp->step; + } else { + lerp->value = lerp->target; + } + } +} #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0124.s") @@ -2087,13 +2269,131 @@ const char sAudioOcarinaUnusedText7[] = "check is over!!! %d %d %d\n"; #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0238.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A026C.s") +/** + * Unused remnant from OoT's EnRiverSound + * Was designed to incrementally increase volume of NA_BGM_GANON_TOWER for each new room during the climb of Ganon's + * Tower + */ +void Audio_SetGanonsTowerBgmVolumeLevel(u8 ganonsTowerLevel) { + u8 channelIndex; + s8 pan = 0; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0318.s") + // Ganondorfs's Lair + if (ganonsTowerLevel == 0) { + pan = 0x7F; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0450.s") + for (channelIndex = 0; channelIndex < 16; channelIndex++) { + // CHAN_UPD_PAN_UNSIGNED + Audio_QueueCmdS8(((u8)(u32)channelIndex << 8) | 0x7000000, pan); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A046C.s") + // Lowest room in Ganon's Tower (Entrance Room) + if (ganonsTowerLevel == 7) { + // Adds a delay to setting the volume in the first room + sEnterGanonsTowerTimer = 2; + } else { + Audio_SetGanonsTowerBgmVolume(sGanonsTowerLevelsVol[ganonsTowerLevel % ARRAY_COUNTU(sGanonsTowerLevelsVol)]); + } +} + +/** + * Unused remnant from OoT's EnRiverSound + * If a new volume is requested for ganon's tower, update the volume and + * calculate a new low-pass filter cutoff and reverb based on the new volume + */ +s32 Audio_SetGanonsTowerBgmVolume(u8 targetVolume) { + u8 lowPassFilterCutoff; + u8 channelIndex; + u16 reverb; + + if (sGanonsTowerVol != targetVolume) { + // Sets the volume + Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 0, targetVolume, 2); + + // Sets the filter cutoff of the form (lowPassFilterCutoff << 4) | (highPassFilter & 0xF). highPassFilter is + // always set to 0 + if (targetVolume < 0x40) { + // Only the first room + lowPassFilterCutoff = 0x10; + } else { + // Higher volume leads to a higher cut-off frequency in the low-pass filtering + lowPassFilterCutoff = (((targetVolume - 0x40) >> 2) + 1) << 4; + } + + Audio_QueueSeqCmd((8 << 28) | ((u8)(SEQ_PLAYER_BGM_MAIN) << 24) | ((u8)(4) << 16) | ((u8)(15) << 8) | + (u8)(lowPassFilterCutoff)); + + // Sets the reverb + for (channelIndex = 0; channelIndex < ARRAY_COUNT(gAudioContext.seqPlayers[SEQ_PLAYER_BGM_MAIN].channels); + channelIndex++) { + if (&gAudioContext.sequenceChannelNone != + gAudioContext.seqPlayers[SEQ_PLAYER_BGM_MAIN].channels[channelIndex]) { + // soundScriptIO[5] was set to 0x40 in channels 0, 1, and 4 (BGM no longer in OoT) + if ((u8)gAudioContext.seqPlayers[SEQ_PLAYER_BGM_MAIN].channels[channelIndex]->soundScriptIO[5] != + 0xFF) { + // Higher volume leads to lower reverb + reverb = + (((u16)gAudioContext.seqPlayers[SEQ_PLAYER_BGM_MAIN].channels[channelIndex]->soundScriptIO[5] - + targetVolume) + + 0x7F); + + if (reverb > 0x7F) { + reverb = 0x7F; + } + + // CHAN_UPD_REVERB + Audio_QueueCmdS8(_SHIFTL(5, 24, 8) | _SHIFTL(SEQ_PLAYER_BGM_MAIN, 16, 8) | + _SHIFTL(channelIndex, 8, 8), + (u8)reverb); + } + } + } + + sGanonsTowerVol = targetVolume; + } + return -1; +} + +/** + * Unused remnant from OoT's EnRiverSound + * Responsible for lowering market bgm in Child Market Entrance and Child Market Back Alley + * Only lowers volume for 1 frame, so must be called every frame to maintain lower volume + */ +void Audio_LowerMainBgmVolume(u8 volume) { + sRiverSoundMainBgmVol = volume; + sRiverSoundMainBgmLower = true; +} + +/** + * Unused remnant from OoT's EnRiverSound + * Still called by Audio_Update every frame, but none of these processes get initialized + */ +void Audio_UpdateRiverSoundVolumes(void) { + // Updates Main Bgm Volume (RiverSound of type RS_LOWER_MAIN_BGM_VOLUME) + if (sRiverSoundMainBgmLower == true) { + if (sRiverSoundMainBgmCurrentVol != sRiverSoundMainBgmVol) { + // lowers the volume for 1 frame + Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 0, sRiverSoundMainBgmVol, 10); + sRiverSoundMainBgmCurrentVol = sRiverSoundMainBgmVol; + sRiverSoundMainBgmRestore = true; + } + sRiverSoundMainBgmLower = false; + } else if ((sRiverSoundMainBgmRestore == true) && !sAudioIsWindowOpen) { + // restores the volume every frame + Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 0, 0x7F, 10); + sRiverSoundMainBgmCurrentVol = 0x7F; + sRiverSoundMainBgmRestore = false; + } + + // Update Ganon's Tower Volume (RiverSound of type RS_GANON_TOWER_7) + if (sEnterGanonsTowerTimer != 0) { + sEnterGanonsTowerTimer--; + if (sEnterGanonsTowerTimer == 0) { + Audio_SetGanonsTowerBgmVolume(sGanonsTowerLevelsVol[7]); + } + } +} #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0554.s") @@ -2107,13 +2407,71 @@ const char sAudioOcarinaUnusedText7[] = "check is over!!! %d %d %d\n"; #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0868.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A09D4.s") +/** + * Unused remnant of OoT's EnRiverSound (func_800F4E30) + */ +void func_801A09D4(Vec3f* pos, f32 xzDistToPlayer) { + f32 volumeRel; + s8 pan; + u8 channelIndex; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0C70.s") + if (sRiverSoundBgmPos == NULL) { + sRiverSoundBgmPos = pos; + sRiverSoundXZDistToPlayer = xzDistToPlayer; + } else if (sRiverSoundBgmPos != pos) { + if (sRiverSoundXZDistToPlayer > xzDistToPlayer) { + sRiverSoundBgmPos = pos; + sRiverSoundXZDistToPlayer = xzDistToPlayer; + } + } else { + sRiverSoundXZDistToPlayer = xzDistToPlayer; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0C90.s") + if (sRiverSoundBgmPos->x > 100.0f) { + pan = 0x7F; + } else if (sRiverSoundBgmPos->x < -100.0f) { + pan = 0; + } else { + pan = ((sRiverSoundBgmPos->x / 100.0f) * 64.0f) + 64.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0CB0.s") + if (sRiverSoundXZDistToPlayer > 400.0f) { + volumeRel = 0.1f; + } else if (sRiverSoundXZDistToPlayer < 120.0f) { + volumeRel = 1.0f; + } else { + volumeRel = ((1.0f - ((sRiverSoundXZDistToPlayer - 120.0f) / 280.0f)) * 0.9f) + 0.1f; + } + + for (channelIndex = 0; channelIndex < 16; channelIndex++) { + if (channelIndex != 9) { + Audio_QueueSeqCmd(((u32)(6) << 28) | ((u32)(SEQ_PLAYER_BGM_MAIN) << 24) | ((u32)(2) << 16) | + ((u32)(channelIndex) << 8) | ((u8)(127.0f * volumeRel))); + Audio_QueueCmdS8(0x03000000 | ((u8)((u32)channelIndex) << 8), pan); + } + } +} + +/** + * Unused remnant of OoT's EnRiverSound + */ +void Audio_ClearSariaBgm(void) { + if (sRiverSoundBgmPos != NULL) { + sRiverSoundBgmPos = NULL; + } +} + +/** + * Unused remnant of OoT's EnRiverSound + */ +void Audio_ClearSariaBgmAtPos(Vec3f* pos) { + if (sRiverSoundBgmPos == pos) { + sRiverSoundBgmPos = NULL; + } +} + +void Audio_SplitBgmChannels(s8 volumeSplit); +#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/Audio_SplitBgmChannels.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0E44.s") @@ -2147,9 +2505,58 @@ const char sAudioOcarinaUnusedText7[] = "check is over!!! %d %d %d\n"; #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A2090.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A21FC.s") +/** + * Unused remnant of OoT's EnRiverSound + */ +void Audio_PlaySariaBgm(Vec3f* pos, u16 seqId, u16 distMax) { + f32 absY; + f32 dist; + u8 targetVolume; + f32 prevDist; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A2460.s") + if (sRiverSoundBgmTimer != 0) { + sRiverSoundBgmTimer--; + return; + } + + dist = sqrtf(SQ(pos->z) + (SQ(pos->x) + SQ(pos->y))); + + if (sRiverSoundBgmPos == NULL) { + sRiverSoundBgmPos = pos; + func_801A3238(SEQ_PLAYER_BGM_SUB, seqId, 0, 7, 2); + } else { + prevDist = sqrtf(SQ(sRiverSoundBgmPos->z) + SQ(sRiverSoundBgmPos->x)); + if (dist < prevDist) { + sRiverSoundBgmPos = pos; + } else { + dist = prevDist; + } + } + + absY = ABS_ALT(pos->y); + + if ((distMax / 15.0f) < absY) { + targetVolume = 0; + } else if (dist < distMax) { + targetVolume = (1.0f - (dist / distMax)) * 127.0f; + } else { + targetVolume = 0; + } + + if (seqId != NA_BGM_FAIRY_FOUNTAIN) { + Audio_SplitBgmChannels(targetVolume); + } + + Audio_SetVolumeScale(SEQ_PLAYER_BGM_SUB, 3, targetVolume, 0); + Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 3, 0x7F - targetVolume, 0); +} + +/** + * Unused remnant of OoT's EnRiverSound + */ +void Audio_ClearSariaBgm2(void) { + sRiverSoundBgmPos = NULL; +} #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A246C.s") diff --git a/src/code/audio/code_801A5BD0.c b/src/code/audio/code_801A5BD0.c index 7d796aa9fc..8397fd52e6 100644 --- a/src/code/audio/code_801A5BD0.c +++ b/src/code/audio/code_801A5BD0.c @@ -40,6 +40,6 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A5BD0/func_801A787C.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A5BD0/func_801A78E4.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A5BD0/Audio_IsSfxPlaying.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A5BD0/func_801A794C.s") diff --git a/src/code/audio/code_801A7B10.c b/src/code/audio/code_801A7B10.c index d2d9a71a21..6d3faaeabd 100644 --- a/src/code/audio/code_801A7B10.c +++ b/src/code/audio/code_801A7B10.c @@ -18,7 +18,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/func_801A8B2C.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/func_801A8BD0.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/Audio_SetVolumeScale.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/func_801A8D5C.s") diff --git a/src/code/audioMgr.c b/src/code/audioMgr.c index dcf5404830..ee60141373 100644 --- a/src/code/audioMgr.c +++ b/src/code/audioMgr.c @@ -79,7 +79,7 @@ void AudioMgr_ThreadEntry(void* arg) { s32 exit; func_801A4C30(); - func_80190B38(DmaMgr_DmaCallback0); + AudioLoad_SetDmaHandler(DmaMgr_DmaHandler); func_801A4D00(); osSendMesg(&audioMgr->lockMsgQ, NULL, OS_MESG_BLOCK); IrqMgr_AddClient(audioMgr->irqMgr, &irqClient, &audioMgr->interruptMsgQ); diff --git a/src/code/code_8012EC80.c b/src/code/code_8012EC80.c index c65697483d..5dee17fb5b 100644 --- a/src/code/code_8012EC80.c +++ b/src/code/code_8012EC80.c @@ -504,7 +504,7 @@ void Inventory_ChangeEquipment(s16 value) { u8 Inventory_DeleteEquipment(GlobalContext* globalCtx, s16 equipment) { Player* player = GET_PLAYER(globalCtx); - if (CUR_EQUIP_VALUE_VOID(EQUIP_SHIELD) != 0) { + if (GET_CUR_EQUIP_VALUE(EQUIP_SHIELD) != 0) { SET_EQUIP_VALUE(EQUIP_SHIELD, 0); Player_SetEquipmentData(globalCtx, player); return true; @@ -514,12 +514,12 @@ u8 Inventory_DeleteEquipment(GlobalContext* globalCtx, s16 equipment) { } void Inventory_ChangeUpgrade(s16 upgrade, u32 value) { - u32 upgrades = gSaveContext.inventory.upgrades; + u32 upgrades = gSaveContext.save.inventory.upgrades; upgrades &= gUpgradeNegMasks[upgrade]; upgrades |= value << gUpgradeShifts[upgrade]; - gSaveContext.inventory.upgrades = upgrades; + gSaveContext.save.inventory.upgrades = upgrades; } s32 Inventory_IsMapVisible(s16 sceneNum) { @@ -546,7 +546,7 @@ s32 Inventory_IsMapVisible(s16 sceneNum) { } } - if (gSaveContext.scenesVisible[index] & gBitFlags[sceneNum - (index << 5)]) { + if (gSaveContext.save.scenesVisible[index] & gBitFlags[sceneNum - (index << 5)]) { return true; } @@ -659,23 +659,23 @@ void Inventory_SetMapVisibility(s16 tingleIndex) { index = 6; } - gSaveContext.scenesVisible[index] = - gSaveContext.scenesVisible[index] | gBitFlags[(s16)(*tingleMapSceneIndices)[i] - (index << 5)]; + gSaveContext.save.scenesVisible[index] = + gSaveContext.save.scenesVisible[index] | gBitFlags[(s16)(*tingleMapSceneIndices)[i] - (index << 5)]; i++; } if ((*tingleMapSceneIndices) == sScenesPerTingleMap[0]) { - gSaveContext.mapsVisible |= 3; + gSaveContext.save.mapsVisible |= 3; } else if ((*tingleMapSceneIndices) == sScenesPerTingleMap[1]) { - gSaveContext.mapsVisible |= 0x1C; + gSaveContext.save.mapsVisible |= 0x1C; } else if ((*tingleMapSceneIndices) == sScenesPerTingleMap[2]) { - gSaveContext.mapsVisible |= 0xE0; + gSaveContext.save.mapsVisible |= 0xE0; } else if ((*tingleMapSceneIndices) == sScenesPerTingleMap[3]) { - gSaveContext.mapsVisible |= 0x100; + gSaveContext.save.mapsVisible |= 0x100; } else if ((*tingleMapSceneIndices) == sScenesPerTingleMap[4]) { - gSaveContext.mapsVisible |= 0x1E00; + gSaveContext.save.mapsVisible |= 0x1E00; } else if ((*tingleMapSceneIndices) == sScenesPerTingleMap[5]) { - gSaveContext.mapsVisible |= 0x6000; + gSaveContext.save.mapsVisible |= 0x6000; } } @@ -688,40 +688,43 @@ void Inventory_SetMapVisibility(s16 tingleIndex) { void Inventory_SaveDekuPlaygroundHighScore(s16 timerId) { s16 i; - gSaveContext.dekuPlaygroundHighScores[CURRENT_DAY - 1] = gSaveContext.unk_3DE0[timerId]; + gSaveContext.save.dekuPlaygroundHighScores[CURRENT_DAY - 1] = gSaveContext.unk_3DE0[timerId]; for (i = 0; i < 8; i++) { - gSaveContext.inventory.dekuPlaygroundPlayerName[CURRENT_DAY - 1][i] = gSaveContext.playerName[i]; + gSaveContext.save.inventory.dekuPlaygroundPlayerName[CURRENT_DAY - 1][i] = + gSaveContext.save.playerData.playerName[i]; } } void Inventory_IncrementSkullTokenCount(s16 sceneIndex) { if (sceneIndex == SCENE_KINSTA1) { // Swamp Spider House (increment high bits of skullTokenCount) - gSaveContext.skullTokenCount = ((u16)(((gSaveContext.skullTokenCount & 0xFFFF0000) >> 0x10) + 1) << 0x10) | - (gSaveContext.skullTokenCount & 0xFFFF); + gSaveContext.save.skullTokenCount = + ((u16)(((gSaveContext.save.skullTokenCount & 0xFFFF0000) >> 0x10) + 1) << 0x10) | + (gSaveContext.save.skullTokenCount & 0xFFFF); } else { // Ocean Spider House (increment low bits of skullTokenCount) - gSaveContext.skullTokenCount = - (((u16)gSaveContext.skullTokenCount + 1) & 0xFFFF) | (gSaveContext.skullTokenCount & 0xFFFF0000); + gSaveContext.save.skullTokenCount = + (((u16)gSaveContext.save.skullTokenCount + 1) & 0xFFFF) | (gSaveContext.save.skullTokenCount & 0xFFFF0000); } } s16 Inventory_GetSkullTokenCount(s16 sceneIndex) { if (sceneIndex == SCENE_KINSTA1) { // Swamp Spider House - return (gSaveContext.skullTokenCount & 0xFFFF0000) >> 0x10; + return (gSaveContext.save.skullTokenCount & 0xFFFF0000) >> 0x10; } else { // Ocean Spider House - return gSaveContext.skullTokenCount & 0xFFFF; + return gSaveContext.save.skullTokenCount & 0xFFFF; } } void Inventory_SaveLotteryCodeGuess(GlobalContext* globalCtx) { u16 lotteryCodeGuess; - lotteryCodeGuess = ((globalCtx->msgCtx.unk12054 & 0xF) << 8); // First Digit - lotteryCodeGuess |= ((globalCtx->msgCtx.unk12056 & 0xF) << 4); // Second Digit - lotteryCodeGuess |= (globalCtx->msgCtx.unk12058 & 0xF); // Third Digit - gSaveContext.lotteryCodeGuess = (gSaveContext.lotteryCodeGuess & 0xFFFF0000) | (lotteryCodeGuess & 0xFFFF); + lotteryCodeGuess = ((globalCtx->msgCtx.unk12054[0] & 0xF) << 8); // First Digit + lotteryCodeGuess |= ((globalCtx->msgCtx.unk12054[1] & 0xF) << 4); // Second Digit + lotteryCodeGuess |= (globalCtx->msgCtx.unk12054[2] & 0xF); // Third Digit + gSaveContext.save.lotteryCodeGuess = + (gSaveContext.save.lotteryCodeGuess & 0xFFFF0000) | (lotteryCodeGuess & 0xFFFF); } diff --git a/src/code/code_801323D0.c b/src/code/code_801323D0.c deleted file mode 100644 index 1457f537d7..0000000000 --- a/src/code/code_801323D0.c +++ /dev/null @@ -1,41 +0,0 @@ -#include "global.h" - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_801323D0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80132428.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80132494.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_801326B8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_801328F0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80132920.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80132938.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80132954.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_8013296C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80132A18.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80132A3C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80132A80.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80132AD8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80132B24.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80132B84.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80132D70.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80132E9C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80132FDC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80133000.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80133038.s") diff --git a/src/code/flg_set.c b/src/code/flg_set.c index 780884c852..53be7b68de 100644 --- a/src/code/flg_set.c +++ b/src/code/flg_set.c @@ -12,106 +12,106 @@ #include "global.h" static FlagSetEntry sFlagEntries[] = { - { &gSaveContext.weekEventReg[0], "week_event_reg[0]" }, - { &gSaveContext.weekEventReg[1], "week_event_reg[1]" }, - { &gSaveContext.weekEventReg[2], "week_event_reg[2]" }, - { &gSaveContext.weekEventReg[3], "week_event_reg[3]" }, - { &gSaveContext.weekEventReg[4], "week_event_reg[4]" }, - { &gSaveContext.weekEventReg[5], "week_event_reg[5]" }, - { &gSaveContext.weekEventReg[6], "week_event_reg[6]" }, - { &gSaveContext.weekEventReg[7], "week_event_reg[7]" }, - { &gSaveContext.weekEventReg[8], "week_event_reg[8]" }, - { &gSaveContext.weekEventReg[9], "week_event_reg[9]" }, - { &gSaveContext.weekEventReg[10], "week_event_reg[10]" }, - { &gSaveContext.weekEventReg[11], "week_event_reg[11]" }, - { &gSaveContext.weekEventReg[12], "week_event_reg[12]" }, - { &gSaveContext.weekEventReg[13], "week_event_reg[13]" }, - { &gSaveContext.weekEventReg[14], "week_event_reg[14]" }, - { &gSaveContext.weekEventReg[15], "week_event_reg[15]" }, - { &gSaveContext.weekEventReg[16], "week_event_reg[16]" }, - { &gSaveContext.weekEventReg[17], "week_event_reg[17]" }, - { &gSaveContext.weekEventReg[18], "week_event_reg[18]" }, - { &gSaveContext.weekEventReg[19], "week_event_reg[19]" }, - { &gSaveContext.weekEventReg[20], "week_event_reg[20]" }, - { &gSaveContext.weekEventReg[21], "week_event_reg[21]" }, - { &gSaveContext.weekEventReg[22], "week_event_reg[22]" }, - { &gSaveContext.weekEventReg[23], "week_event_reg[23]" }, - { &gSaveContext.weekEventReg[24], "week_event_reg[24]" }, - { &gSaveContext.weekEventReg[25], "week_event_reg[25]" }, - { &gSaveContext.weekEventReg[26], "week_event_reg[26]" }, - { &gSaveContext.weekEventReg[27], "week_event_reg[27]" }, - { &gSaveContext.weekEventReg[28], "week_event_reg[28]" }, - { &gSaveContext.weekEventReg[29], "week_event_reg[29]" }, - { &gSaveContext.weekEventReg[30], "week_event_reg[30]" }, - { &gSaveContext.weekEventReg[31], "week_event_reg[31]" }, - { &gSaveContext.weekEventReg[32], "week_event_reg[32]" }, - { &gSaveContext.weekEventReg[33], "week_event_reg[33]" }, - { &gSaveContext.weekEventReg[34], "week_event_reg[34]" }, - { &gSaveContext.weekEventReg[35], "week_event_reg[35]" }, - { &gSaveContext.weekEventReg[36], "week_event_reg[36]" }, - { &gSaveContext.weekEventReg[37], "week_event_reg[37]" }, - { &gSaveContext.weekEventReg[38], "week_event_reg[38]" }, - { &gSaveContext.weekEventReg[39], "week_event_reg[39]" }, - { &gSaveContext.weekEventReg[40], "week_event_reg[40]" }, - { &gSaveContext.weekEventReg[41], "week_event_reg[41]" }, - { &gSaveContext.weekEventReg[42], "week_event_reg[42]" }, - { &gSaveContext.weekEventReg[43], "week_event_reg[43]" }, - { &gSaveContext.weekEventReg[44], "week_event_reg[44]" }, - { &gSaveContext.weekEventReg[45], "week_event_reg[45]" }, - { &gSaveContext.weekEventReg[46], "week_event_reg[46]" }, - { &gSaveContext.weekEventReg[47], "week_event_reg[47]" }, - { &gSaveContext.weekEventReg[48], "week_event_reg[48]" }, - { &gSaveContext.weekEventReg[49], "week_event_reg[49]" }, - { &gSaveContext.weekEventReg[50], "week_event_reg[50]" }, - { &gSaveContext.weekEventReg[51], "week_event_reg[51]" }, - { &gSaveContext.weekEventReg[52], "week_event_reg[52]" }, - { &gSaveContext.weekEventReg[53], "week_event_reg[53]" }, - { &gSaveContext.weekEventReg[54], "week_event_reg[54]" }, - { &gSaveContext.weekEventReg[55], "week_event_reg[55]" }, - { &gSaveContext.weekEventReg[56], "week_event_reg[56]" }, - { &gSaveContext.weekEventReg[57], "week_event_reg[57]" }, - { &gSaveContext.weekEventReg[58], "week_event_reg[58]" }, - { &gSaveContext.weekEventReg[59], "week_event_reg[59]" }, - { &gSaveContext.weekEventReg[60], "week_event_reg[60]" }, - { &gSaveContext.weekEventReg[61], "week_event_reg[61]" }, - { &gSaveContext.weekEventReg[62], "week_event_reg[62]" }, - { &gSaveContext.weekEventReg[63], "week_event_reg[63]" }, - { &gSaveContext.weekEventReg[64], "week_event_reg[64]" }, - { &gSaveContext.weekEventReg[65], "week_event_reg[65]" }, - { &gSaveContext.weekEventReg[66], "week_event_reg[66]" }, - { &gSaveContext.weekEventReg[67], "week_event_reg[67]" }, - { &gSaveContext.weekEventReg[68], "week_event_reg[68]" }, - { &gSaveContext.weekEventReg[69], "week_event_reg[69]" }, - { &gSaveContext.weekEventReg[70], "week_event_reg[70]" }, - { &gSaveContext.weekEventReg[71], "week_event_reg[71]" }, - { &gSaveContext.weekEventReg[72], "week_event_reg[72]" }, - { &gSaveContext.weekEventReg[73], "week_event_reg[73]" }, - { &gSaveContext.weekEventReg[74], "week_event_reg[74]" }, - { &gSaveContext.weekEventReg[75], "week_event_reg[75]" }, - { &gSaveContext.weekEventReg[76], "week_event_reg[76]" }, - { &gSaveContext.weekEventReg[77], "week_event_reg[77]" }, - { &gSaveContext.weekEventReg[78], "week_event_reg[78]" }, - { &gSaveContext.weekEventReg[79], "week_event_reg[79]" }, - { &gSaveContext.weekEventReg[80], "week_event_reg[80]" }, - { &gSaveContext.weekEventReg[81], "week_event_reg[81]" }, - { &gSaveContext.weekEventReg[82], "week_event_reg[82]" }, - { &gSaveContext.weekEventReg[83], "week_event_reg[83]" }, - { &gSaveContext.weekEventReg[84], "week_event_reg[84]" }, - { &gSaveContext.weekEventReg[85], "week_event_reg[85]" }, - { &gSaveContext.weekEventReg[86], "week_event_reg[86]" }, - { &gSaveContext.weekEventReg[87], "week_event_reg[87]" }, - { &gSaveContext.weekEventReg[88], "week_event_reg[88]" }, - { &gSaveContext.weekEventReg[89], "week_event_reg[89]" }, - { &gSaveContext.weekEventReg[90], "week_event_reg[90]" }, - { &gSaveContext.weekEventReg[91], "week_event_reg[91]" }, - { &gSaveContext.weekEventReg[92], "week_event_reg[92]" }, - { &gSaveContext.weekEventReg[93], "week_event_reg[93]" }, - { &gSaveContext.weekEventReg[94], "week_event_reg[94]" }, - { &gSaveContext.weekEventReg[95], "week_event_reg[95]" }, - { &gSaveContext.weekEventReg[96], "week_event_reg[96]" }, - { &gSaveContext.weekEventReg[97], "week_event_reg[97]" }, - { &gSaveContext.weekEventReg[98], "week_event_reg[98]" }, - { &gSaveContext.weekEventReg[99], "week_event_reg[99]" }, + { &gSaveContext.save.weekEventReg[0], "week_event_reg[0]" }, + { &gSaveContext.save.weekEventReg[1], "week_event_reg[1]" }, + { &gSaveContext.save.weekEventReg[2], "week_event_reg[2]" }, + { &gSaveContext.save.weekEventReg[3], "week_event_reg[3]" }, + { &gSaveContext.save.weekEventReg[4], "week_event_reg[4]" }, + { &gSaveContext.save.weekEventReg[5], "week_event_reg[5]" }, + { &gSaveContext.save.weekEventReg[6], "week_event_reg[6]" }, + { &gSaveContext.save.weekEventReg[7], "week_event_reg[7]" }, + { &gSaveContext.save.weekEventReg[8], "week_event_reg[8]" }, + { &gSaveContext.save.weekEventReg[9], "week_event_reg[9]" }, + { &gSaveContext.save.weekEventReg[10], "week_event_reg[10]" }, + { &gSaveContext.save.weekEventReg[11], "week_event_reg[11]" }, + { &gSaveContext.save.weekEventReg[12], "week_event_reg[12]" }, + { &gSaveContext.save.weekEventReg[13], "week_event_reg[13]" }, + { &gSaveContext.save.weekEventReg[14], "week_event_reg[14]" }, + { &gSaveContext.save.weekEventReg[15], "week_event_reg[15]" }, + { &gSaveContext.save.weekEventReg[16], "week_event_reg[16]" }, + { &gSaveContext.save.weekEventReg[17], "week_event_reg[17]" }, + { &gSaveContext.save.weekEventReg[18], "week_event_reg[18]" }, + { &gSaveContext.save.weekEventReg[19], "week_event_reg[19]" }, + { &gSaveContext.save.weekEventReg[20], "week_event_reg[20]" }, + { &gSaveContext.save.weekEventReg[21], "week_event_reg[21]" }, + { &gSaveContext.save.weekEventReg[22], "week_event_reg[22]" }, + { &gSaveContext.save.weekEventReg[23], "week_event_reg[23]" }, + { &gSaveContext.save.weekEventReg[24], "week_event_reg[24]" }, + { &gSaveContext.save.weekEventReg[25], "week_event_reg[25]" }, + { &gSaveContext.save.weekEventReg[26], "week_event_reg[26]" }, + { &gSaveContext.save.weekEventReg[27], "week_event_reg[27]" }, + { &gSaveContext.save.weekEventReg[28], "week_event_reg[28]" }, + { &gSaveContext.save.weekEventReg[29], "week_event_reg[29]" }, + { &gSaveContext.save.weekEventReg[30], "week_event_reg[30]" }, + { &gSaveContext.save.weekEventReg[31], "week_event_reg[31]" }, + { &gSaveContext.save.weekEventReg[32], "week_event_reg[32]" }, + { &gSaveContext.save.weekEventReg[33], "week_event_reg[33]" }, + { &gSaveContext.save.weekEventReg[34], "week_event_reg[34]" }, + { &gSaveContext.save.weekEventReg[35], "week_event_reg[35]" }, + { &gSaveContext.save.weekEventReg[36], "week_event_reg[36]" }, + { &gSaveContext.save.weekEventReg[37], "week_event_reg[37]" }, + { &gSaveContext.save.weekEventReg[38], "week_event_reg[38]" }, + { &gSaveContext.save.weekEventReg[39], "week_event_reg[39]" }, + { &gSaveContext.save.weekEventReg[40], "week_event_reg[40]" }, + { &gSaveContext.save.weekEventReg[41], "week_event_reg[41]" }, + { &gSaveContext.save.weekEventReg[42], "week_event_reg[42]" }, + { &gSaveContext.save.weekEventReg[43], "week_event_reg[43]" }, + { &gSaveContext.save.weekEventReg[44], "week_event_reg[44]" }, + { &gSaveContext.save.weekEventReg[45], "week_event_reg[45]" }, + { &gSaveContext.save.weekEventReg[46], "week_event_reg[46]" }, + { &gSaveContext.save.weekEventReg[47], "week_event_reg[47]" }, + { &gSaveContext.save.weekEventReg[48], "week_event_reg[48]" }, + { &gSaveContext.save.weekEventReg[49], "week_event_reg[49]" }, + { &gSaveContext.save.weekEventReg[50], "week_event_reg[50]" }, + { &gSaveContext.save.weekEventReg[51], "week_event_reg[51]" }, + { &gSaveContext.save.weekEventReg[52], "week_event_reg[52]" }, + { &gSaveContext.save.weekEventReg[53], "week_event_reg[53]" }, + { &gSaveContext.save.weekEventReg[54], "week_event_reg[54]" }, + { &gSaveContext.save.weekEventReg[55], "week_event_reg[55]" }, + { &gSaveContext.save.weekEventReg[56], "week_event_reg[56]" }, + { &gSaveContext.save.weekEventReg[57], "week_event_reg[57]" }, + { &gSaveContext.save.weekEventReg[58], "week_event_reg[58]" }, + { &gSaveContext.save.weekEventReg[59], "week_event_reg[59]" }, + { &gSaveContext.save.weekEventReg[60], "week_event_reg[60]" }, + { &gSaveContext.save.weekEventReg[61], "week_event_reg[61]" }, + { &gSaveContext.save.weekEventReg[62], "week_event_reg[62]" }, + { &gSaveContext.save.weekEventReg[63], "week_event_reg[63]" }, + { &gSaveContext.save.weekEventReg[64], "week_event_reg[64]" }, + { &gSaveContext.save.weekEventReg[65], "week_event_reg[65]" }, + { &gSaveContext.save.weekEventReg[66], "week_event_reg[66]" }, + { &gSaveContext.save.weekEventReg[67], "week_event_reg[67]" }, + { &gSaveContext.save.weekEventReg[68], "week_event_reg[68]" }, + { &gSaveContext.save.weekEventReg[69], "week_event_reg[69]" }, + { &gSaveContext.save.weekEventReg[70], "week_event_reg[70]" }, + { &gSaveContext.save.weekEventReg[71], "week_event_reg[71]" }, + { &gSaveContext.save.weekEventReg[72], "week_event_reg[72]" }, + { &gSaveContext.save.weekEventReg[73], "week_event_reg[73]" }, + { &gSaveContext.save.weekEventReg[74], "week_event_reg[74]" }, + { &gSaveContext.save.weekEventReg[75], "week_event_reg[75]" }, + { &gSaveContext.save.weekEventReg[76], "week_event_reg[76]" }, + { &gSaveContext.save.weekEventReg[77], "week_event_reg[77]" }, + { &gSaveContext.save.weekEventReg[78], "week_event_reg[78]" }, + { &gSaveContext.save.weekEventReg[79], "week_event_reg[79]" }, + { &gSaveContext.save.weekEventReg[80], "week_event_reg[80]" }, + { &gSaveContext.save.weekEventReg[81], "week_event_reg[81]" }, + { &gSaveContext.save.weekEventReg[82], "week_event_reg[82]" }, + { &gSaveContext.save.weekEventReg[83], "week_event_reg[83]" }, + { &gSaveContext.save.weekEventReg[84], "week_event_reg[84]" }, + { &gSaveContext.save.weekEventReg[85], "week_event_reg[85]" }, + { &gSaveContext.save.weekEventReg[86], "week_event_reg[86]" }, + { &gSaveContext.save.weekEventReg[87], "week_event_reg[87]" }, + { &gSaveContext.save.weekEventReg[88], "week_event_reg[88]" }, + { &gSaveContext.save.weekEventReg[89], "week_event_reg[89]" }, + { &gSaveContext.save.weekEventReg[90], "week_event_reg[90]" }, + { &gSaveContext.save.weekEventReg[91], "week_event_reg[91]" }, + { &gSaveContext.save.weekEventReg[92], "week_event_reg[92]" }, + { &gSaveContext.save.weekEventReg[93], "week_event_reg[93]" }, + { &gSaveContext.save.weekEventReg[94], "week_event_reg[94]" }, + { &gSaveContext.save.weekEventReg[95], "week_event_reg[95]" }, + { &gSaveContext.save.weekEventReg[96], "week_event_reg[96]" }, + { &gSaveContext.save.weekEventReg[97], "week_event_reg[97]" }, + { &gSaveContext.save.weekEventReg[98], "week_event_reg[98]" }, + { &gSaveContext.save.weekEventReg[99], "week_event_reg[99]" }, { &gSaveContext.eventInf[0], "event_inf[0]" }, { &gSaveContext.eventInf[1], "event_inf[1]" }, @@ -245,8 +245,8 @@ void FlagSet_Update(GameState* gameState) { if (CHECK_BTN_ALL(input->cur.button, BTN_START)) { if (CHECK_BTN_ALL(input->press.button, BTN_B)) { s16 i; - for (i = 0; i < ARRAY_COUNT(gSaveContext.weekEventReg); i++) { - gSaveContext.weekEventReg[i] = 0; + for (i = 0; i < ARRAY_COUNT(gSaveContext.save.weekEventReg); i++) { + gSaveContext.save.weekEventReg[i] = 0; } for (i = 0; i < ARRAY_COUNT(gSaveContext.eventInf); i++) { gSaveContext.eventInf[i] = 0; diff --git a/src/code/graph.c b/src/code/graph.c index 8059d1f63a..28327c35fa 100644 --- a/src/code/graph.c +++ b/src/code/graph.c @@ -1,4 +1,3 @@ -#include "prevent_bss_reordering.h" #include "global.h" #include "system_malloc.h" #include "overlays/gamestates/ovl_daytelop/z_daytelop.h" @@ -13,7 +12,7 @@ GfxMasterList* gGfxMasterDL; CfbInfo sGraphCfbInfos[3]; OSTime sGraphTaskStartTime; -void* Graph_FaultClient(void) { +void Graph_FaultClient(void) { FaultDrawer_DrawText(30, 100, "ShowFrameBuffer PAGE 0/1"); osViSwapBuffer(SysCfb_GetFbPtr(0)); osViSetMode(D_801FBB88); diff --git a/src/code/sched.c b/src/code/sched.c index 5f9cdf236a..927a48f66b 100644 --- a/src/code/sched.c +++ b/src/code/sched.c @@ -1,4 +1,3 @@ -#include "prevent_bss_reordering.h" #include "global.h" #define RSP_DONE_MSG 667 diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 55c5bf2049..2a8591148b 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -240,7 +240,7 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* mapper, GlobalContext* globalCtx } actor->shape.unk_17 &= ~spB8; - if (!mapper->l.l) {} // POSSIBLE FAKE MATCH + if ((uintptr_t)mapper->l.l) {} // POSSIBLE FAKE MATCH } } @@ -2224,7 +2224,7 @@ void func_800B90F4(GlobalContext* globalCtx) { void func_800B9120(ActorContext* actorCtx) { s32 phi_v0 = CURRENT_DAY * 2; - if (gSaveContext.time < CLOCK_TIME(6, 0) || gSaveContext.time > CLOCK_TIME(18, 0)) { + if (gSaveContext.save.time < CLOCK_TIME(6, 0) || gSaveContext.save.time > CLOCK_TIME(18, 0)) { phi_v0++; } @@ -2236,7 +2236,7 @@ void Actor_InitContext(GlobalContext* globalCtx, ActorContext* actorCtx, ActorEn CycleSceneFlags* cycleFlags; s32 i; - gSaveContext.weekEventReg[92] |= 0x80; + gSaveContext.save.weekEventReg[92] |= 0x80; cycleFlags = &gSaveContext.cycleSceneFlags[Play_GetOriginalSceneNumber(globalCtx->sceneNum)]; bzero(actorCtx, sizeof(ActorContext)); @@ -2252,8 +2252,8 @@ void Actor_InitContext(GlobalContext* globalCtx, ActorContext* actorCtx, ActorEn } actorCtx->flags.chest = cycleFlags->chest; - actorCtx->flags.switches[0] = cycleFlags->swch0; - actorCtx->flags.switches[1] = cycleFlags->swch1; + actorCtx->flags.switches[0] = cycleFlags->switch0; + actorCtx->flags.switches[1] = cycleFlags->switch1; if (globalCtx->sceneNum == SCENE_INISIE_R) { cycleFlags = &gSaveContext.cycleSceneFlags[globalCtx->sceneNum]; } @@ -3799,13 +3799,13 @@ void func_800BC7D8(GlobalContext* globalCtx, s16 y, s16 countdown, s16 speed) { Quake_SetCountdown(idx, countdown); } -void func_800BC848(Actor* actor, GlobalContext* globalCtx, s16 arg2, s16 arg3) { - if (arg2 >= 5) { +void func_800BC848(Actor* actor, GlobalContext* globalCtx, s16 y, s16 countdown) { + if (y >= 5) { func_8013ECE0(actor->xyzDistToPlayerSq, 255, 20, 150); } else { func_8013ECE0(actor->xyzDistToPlayerSq, 180, 20, 100); } - func_800BC770(globalCtx, arg2, arg3); + func_800BC770(globalCtx, y, countdown); } typedef struct { @@ -3908,104 +3908,148 @@ Hilite* func_800BCC68(Vec3f* arg0, GlobalContext* globalCtx) { return Hilite_DrawXlu(arg0, &globalCtx->view.eye, &lightDir, globalCtx->state.gfxCtx); } -void func_800BCCDC(Vec3s* points, s32 pathCount, Vec3f* pos1, Vec3f* pos2, s32 arg4) { - s32 spB4; - s32 spB0; - s32 spA8[2] = { 0, 0 }; - s32 spA0[2] = { 0, 0 }; - Vec3f sp94; - Vec3f sp7C[2]; - Vec3f sp70; - Vec3f sp64; - f32 sp60; - f32 sp5C; - f32 sp54[2]; +/** + * Calculates the closest position `dstPos` to the input position `srcPos` along the path given by `points`/`numPoints` + * Whether the points provided forms a closed-loop path is indicated by `isPathLoop` + */ +void Actor_GetClosestPosOnPath(Vec3s* points, s32 numPoints, Vec3f* srcPos, Vec3f* dstPos, s32 isPathLoop) { + s32 pointIndex; + s32 closestPointIndex; + s32 useAdjacentLines[2] = { + false, // determines whether to use line connecting to previous point in calculations + false, // determines whether to use line connecting to next point in calculations + }; + s32 isRightSideOfAdjacentLines[2] = { + false, // determines whether srcPos is on the right side of the line from prev to curr point + false, // determines whether srcPos is on the right side of the line from curr to next point + }; + Vec3f closestPoint; + Vec3f closestPos[2]; + Vec3f closestPointNext; + Vec3f closestPointPrev; + f32 distSq; // First used as distSq to closest point, then used as distSq to closest position + f32 closestPointDistSq; + f32 loopDistSq[2]; + s32 i; - spB0 = 0; - sp5C = SQ(40000.0f); + closestPointIndex = 0; + closestPointDistSq = SQ(40000.0f); - for (spB4 = 0; spB4 < pathCount; spB4++) { - sp60 = Math3D_XZDistanceSquared(pos1->x, pos1->z, points[spB4].x, points[spB4].z); - if (sp60 < sp5C) { - sp5C = sp60; - spB0 = spB4; + // Find the point closest to srcPos + for (pointIndex = 0; pointIndex < numPoints; pointIndex++) { + distSq = Math3D_XZDistanceSquared(srcPos->x, srcPos->z, points[pointIndex].x, points[pointIndex].z); + if (distSq < closestPointDistSq) { + closestPointDistSq = distSq; + closestPointIndex = pointIndex; } } - sp94.x = (points + spB0)->x; - sp94.z = (points + spB0)->z; - pos2->y = (points + spB0)->y; - if (spB0 != 0) { - sp64.x = (points + spB0 - 1)->x; - sp64.z = (points + spB0 - 1)->z; - } else if (arg4) { - sp64.x = (points + pathCount - 1)->x; - sp64.z = (points + pathCount - 1)->z; + closestPoint.x = (points + closestPointIndex)->x; + closestPoint.z = (points + closestPointIndex)->z; + dstPos->y = (points + closestPointIndex)->y; + + // Analyze point on path immediately previous to the closest point + if (closestPointIndex != 0) { + // The point previous to the closest point + closestPointPrev.x = (points + closestPointIndex - 1)->x; + closestPointPrev.z = (points + closestPointIndex - 1)->z; + } else if (isPathLoop) { + // Closest point is the first point in the path list + // Set the previous point to loop around to the the final point on the path + closestPointPrev.x = (points + numPoints - 1)->x; + closestPointPrev.z = (points + numPoints - 1)->z; + } + if ((closestPointIndex != 0) || isPathLoop) { + // Use the adjacent line + useAdjacentLines[0] = + Math3D_PointDistToLine2D(srcPos->x, srcPos->z, closestPointPrev.x, closestPointPrev.z, closestPoint.x, + closestPoint.z, &closestPos[0].x, &closestPos[0].z, &distSq); } - if ((spB0 != 0) || arg4) { - spA8[0] = - Math3D_PointDistToLine2D(pos1->x, pos1->z, sp64.x, sp64.z, sp94.x, sp94.z, &sp7C[0].x, &sp7C[0].z, &sp60); + // Analyze point on path immediately next to the closest point + if (closestPointIndex + 1 != numPoints) { + // The point next to the closest point + closestPointNext.x = (points + closestPointIndex + 1)->x; + closestPointNext.z = (points + closestPointIndex + 1)->z; + } else if (isPathLoop) { + // Closest point is the final point in the path list + // Set the next point to loop around to the the first point on the path + closestPointNext.x = (points + 0)->x; + closestPointNext.z = (points + 0)->z; + } + if ((closestPointIndex + 1 != numPoints) || isPathLoop) { + useAdjacentLines[1] = + Math3D_PointDistToLine2D(srcPos->x, srcPos->z, closestPoint.x, closestPoint.z, closestPointNext.x, + closestPointNext.z, &closestPos[1].x, &closestPos[1].z, &distSq); } - if (spB0 + 1 != pathCount) { - sp70.x = (points + spB0 + 1)->x; - sp70.z = (points + spB0 + 1)->z; - } else if (arg4) { - sp70.x = points->x; - sp70.z = points->z; - } + /** + * For close-looped paths, they must be defined in a clockwise orientation looking from the top down. + * Therefore, `srcPos` being interior of the loop will lead to both lines of `isRightSideOfAdjacentLines` + * returning true. + */ + if (isPathLoop) { + isRightSideOfAdjacentLines[0] = ((closestPointPrev.x - srcPos->x) * (closestPoint.z - srcPos->z)) < + ((closestPointPrev.z - srcPos->z) * (closestPoint.x - srcPos->x)); - if ((spB0 + 1 != pathCount) || arg4) { - spA8[1] = - Math3D_PointDistToLine2D(pos1->x, pos1->z, sp94.x, sp94.z, sp70.x, sp70.z, &sp7C[1].x, &sp7C[1].z, &sp60); - } + isRightSideOfAdjacentLines[1] = ((closestPointNext.z - srcPos->z) * (closestPoint.x - srcPos->x)) < + ((closestPoint.z - srcPos->z) * (closestPointNext.x - srcPos->x)); - if (arg4) { - s32 phi_s0_2; - - spA0[0] = ((sp64.x - pos1->x) * (sp94.z - pos1->z)) < ((sp64.z - pos1->z) * (sp94.x - pos1->x)); - spA0[1] = ((sp70.z - pos1->z) * (sp94.x - pos1->x)) < ((sp94.z - pos1->z) * (sp70.x - pos1->x)); - - for (phi_s0_2 = 0; phi_s0_2 < ARRAY_COUNT(sp54); phi_s0_2++) { - if (spA8[phi_s0_2] != 0) { - sp54[phi_s0_2] = Math3D_XZDistanceSquared(pos1->x, pos1->z, sp7C[phi_s0_2].x, sp7C[phi_s0_2].z); + for (i = 0; i < ARRAY_COUNT(loopDistSq); i++) { + if (useAdjacentLines[i]) { + // Get distSq from srcPos to closestPos + loopDistSq[i] = Math3D_XZDistanceSquared(srcPos->x, srcPos->z, closestPos[i].x, closestPos[i].z); } else { - sp54[phi_s0_2] = SQ(40000.0f); + // The closest Pos is not contained within the line-segment + loopDistSq[i] = SQ(40000.0f); } } } - if (arg4 && (((spA0[0] != 0) && (spA0[1] != 0)) || ((spA0[0] != 0) && (spA8[0] != 0) && (sp54[0] < sp54[1])) || - ((spA0[1] != 0) && (spA8[1] != 0) && (sp54[1] < sp54[0])))) { - pos2->x = pos1->x; - pos2->z = pos1->z; - } else if ((spA8[0] != 0) && (spA8[1] != 0)) { - if ((spA0[0] == 0) && (spA0[1] == 0)) { - if (Math3D_PointDistToLine2D(pos1->x, pos1->z, sp7C[0].x, sp7C[0].z, sp7C[1].x, sp7C[1].z, &pos2->x, - &pos2->z, &sp60) == 0) { - pos2->x = (sp7C[1].x + sp7C[0].x) * 0.5f; - pos2->z = (sp7C[1].z + sp7C[0].z) * 0.5f; + // Calculate closest position along path + if (isPathLoop && ((isRightSideOfAdjacentLines[0] && isRightSideOfAdjacentLines[1]) || + (isRightSideOfAdjacentLines[0] && useAdjacentLines[0] && (loopDistSq[0] < loopDistSq[1])) || + (isRightSideOfAdjacentLines[1] && useAdjacentLines[1] && (loopDistSq[1] < loopDistSq[0])))) { + // srcPos is contained within the closed loop + dstPos->x = srcPos->x; + dstPos->z = srcPos->z; + } else if (useAdjacentLines[0] && useAdjacentLines[1]) { + // srcPos is somewhere withing the bend of the path + if (!isRightSideOfAdjacentLines[0] && !isRightSideOfAdjacentLines[1]) { + // srcPos is not inside a loop + if (!Math3D_PointDistToLine2D(srcPos->x, srcPos->z, closestPos[0].x, closestPos[0].z, closestPos[1].x, + closestPos[1].z, &dstPos->x, &dstPos->z, &distSq)) { + // The dstPos calculated in Math3D_PointDistToLine2D was not valid. + // Take the midpoint of the two closest ponits instead + dstPos->x = (closestPos[1].x + closestPos[0].x) * 0.5f; + dstPos->z = (closestPos[1].z + closestPos[0].z) * 0.5f; } - } else if (sp54[1] < sp54[0]) { - pos2->x = sp7C[1].x; - pos2->z = sp7C[1].z; + } else if (loopDistSq[1] < loopDistSq[0]) { + // Use closest position along the line in the loop connecting the closest point and the next point + dstPos->x = closestPos[1].x; + dstPos->z = closestPos[1].z; } else { - pos2->x = sp7C[0].x; - pos2->z = sp7C[0].z; + // Use closest position along the ling in the loop connecting the closest point and the prev point + dstPos->x = closestPos[0].x; + dstPos->z = closestPos[0].z; } - } else if (spA8[0] != 0) { - pos2->x = sp7C[0].x; - pos2->z = sp7C[0].z; - } else if (spA8[1] != 0) { - pos2->x = sp7C[1].x; - pos2->z = sp7C[1].z; - } else if (arg4 && ((((sp64.x - pos1->x) * (sp70.z - pos1->z)) < ((sp64.z - pos1->z) * (sp70.x - pos1->x))))) { - pos2->x = pos1->x; - pos2->z = pos1->z; + } else if (useAdjacentLines[0]) { + // Use closest position along line segment connecting the closest point and the prev point + dstPos->x = closestPos[0].x; + dstPos->z = closestPos[0].z; + } else if (useAdjacentLines[1]) { + // Use closest position along line segment connecting the closest point and the next point + dstPos->x = closestPos[1].x; + dstPos->z = closestPos[1].z; + } else if (isPathLoop && ((((closestPointPrev.x - srcPos->x) * (closestPointNext.z - srcPos->z)) < + ((closestPointPrev.z - srcPos->z) * (closestPointNext.x - srcPos->x))))) { + // Inside the line that directly connects the previous point to the next point (inside the bend of a corner) + dstPos->x = srcPos->x; + dstPos->z = srcPos->z; } else { - pos2->x = sp94.x; - pos2->z = sp94.z; + // The closest point and the closest position are the same (srcPos is near the outer region of a corner) + dstPos->x = closestPoint.x; + dstPos->z = closestPoint.z; } } @@ -4188,11 +4232,11 @@ Gfx D_801AEFA0[] = { gsSPEndDisplayList(), }; -void* func_800BD9A0(GraphicsContext* gfxCtx) { +Gfx* func_800BD9A0(GraphicsContext* gfxCtx) { Gfx* displayListHead; Gfx* displayList; - displayListHead = displayList = GRAPH_ALLOC(gfxCtx, 0x10); + displayListHead = displayList = GRAPH_ALLOC(gfxCtx, sizeof(Gfx) * 2); gDPSetRenderMode(displayListHead++, AA_EN | Z_CMP | Z_UPD | IM_RD | CLR_ON_CVG | CVG_DST_WRAP | ZMODE_XLU | FORCE_BL | @@ -4447,39 +4491,42 @@ s32 Actor_IsSmallChest(struct EnBox* chest) { return false; } -TexturePtr D_801AEFA8[] = { - gameplay_keep_Tex_091DE0, - gameplay_keep_Tex_091FE0, - gameplay_keep_Tex_0921E0, - gameplay_keep_Tex_0923E0, +TexturePtr sElectricSparkTextures[] = { + gElectricSpark1Tex, + gElectricSpark2Tex, + gElectricSpark3Tex, + gElectricSpark4Tex, }; -// Draw common damageEffects -void func_800BE680(GlobalContext* globalCtx, Actor* actor, Vec3f limbPos[], s16 arg3, f32 effectScale, f32 steamScale, - f32 effectAlpha, u8 mode) { +/** + * Draw common damage effects applied to each limb provided in limbPos + */ +void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbPos[], s16 limbPosCount, f32 effectScale, + f32 frozenSteamScale, f32 effectAlpha, u8 type) { if (effectAlpha > 0.001f) { - s32 temp_v1_3; - s16 i; - MtxF* temp_s3; + s32 twoTexScrollParam; + s16 limbIndex; + MtxF* currentMatrix; f32 alpha; - f32 sp124; - f32 sp120; - f32 sp11C; - f32 sp118; - Vec3f* limbAux = limbPos; - u32 sp110 = globalCtx->gameplayFrames; - f32 sp74; + f32 frozenScale; + f32 lightOrbsScale; + f32 electricSparksScale; + f32 steamScale; + Vec3f* limbPosStart = limbPos; + u32 gameplayFrames = globalCtx->gameplayFrames; + f32 effectAlphaScaled; - temp_s3 = Matrix_GetCurrentState(); + currentMatrix = Matrix_GetCurrentState(); + // Apply sfx along with damage effect if ((actor != NULL) && (effectAlpha > 0.05f) && (globalCtx->gameOverCtx.state == 0)) { - if (mode == 0) { + if (type == ACTOR_DRAW_DMGEFF_FIRE) { Actor_PlaySfxAtPos(actor, NA_SE_EV_BURN_OUT - SFX_FLAG); - } else if (mode == 1) { + } else if (type == ACTOR_DRAW_DMGEFF_BLUE_FIRE) { Actor_PlaySfxAtPos(actor, NA_SE_EN_COMMON_EXTINCT_LEV - SFX_FLAG); - } else if (mode == 0xB) { + } else if (type == ACTOR_DRAW_DMGEFF_FROZEN_SFX) { Actor_PlaySfxAtPos(actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); - } else if ((mode == 0x14) || (mode == 0x15)) { + } else if ((type == ACTOR_DRAW_DMGEFF_LIGHT_ORBS) || (type == ACTOR_DRAW_DMGEFF_BLUE_LIGHT_ORBS)) { Actor_PlaySfxAtPos(actor, NA_SE_EN_COMMON_DEADLIGHT - SFX_FLAG); } } @@ -4488,58 +4535,60 @@ void func_800BE680(GlobalContext* globalCtx, Actor* actor, Vec3f limbPos[], s16 func_8012C2DC(globalCtx->state.gfxCtx); - switch (mode) { - case 0xA: - case 0xB: - sp124 = ((KREG(19) * 0.01f) + 2.3f) * effectScale; - sp118 = ((KREG(28) * 0.0001f) + 0.035f) * steamScale; + switch (type) { + case ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX: + case ACTOR_DRAW_DMGEFF_FROZEN_SFX: + frozenScale = ((KREG(19) * 0.01f) + 2.3f) * effectScale; + steamScale = ((KREG(28) * 0.0001f) + 0.035f) * frozenSteamScale; func_800BCC68(limbPos, globalCtx); + // Setup to draw ice over frozen actor + gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, sp110 & 0xFF, 0x20, 0x10, 1, 0, - (sp110 * 2) & 0xFF, 0x40, 0x20)); - + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, gameplayFrames & 0xFF, 32, 16, 1, 0, + (gameplayFrames * 2) & 0xFF, 64, 32)); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 170, 255, 255, 255); + gSPDisplayList(POLY_XLU_DISP++, gFrozenIceDL); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_050648); + effectAlphaScaled = effectAlpha * 255.0f; - sp74 = effectAlpha * 255.0f; - for (i = 0; i < arg3; i++) { - alpha = i & 3; - alpha = sp74 - (30.0f * alpha); - if (sp74 < (30.0f * (i & 3))) { + // Apply and draw ice over each limb of frozen actor + for (limbIndex = 0; limbIndex < limbPosCount; limbIndex++, limbPos++) { + alpha = limbIndex & 3; + alpha = effectAlphaScaled - (30.0f * alpha); + if (effectAlphaScaled < (30.0f * (limbIndex & 3))) { alpha = 0.0f; } if (alpha > 255.0f) { alpha = 255.0f; } - gDPSetEnvColor(POLY_XLU_DISP++, KREG(20) + 0xC8, KREG(21) + 0xC8, KREG(22) + 0xFF, (u8)alpha); + gDPSetEnvColor(POLY_XLU_DISP++, KREG(20) + 200, KREG(21) + 200, KREG(22) + 255, (u8)alpha); Matrix_InsertTranslation(limbPos->x, limbPos->y, limbPos->z, MTXMODE_NEW); - Matrix_Scale(sp124, sp124, sp124, MTXMODE_APPLY); - if (i & 1) { + Matrix_Scale(frozenScale, frozenScale, frozenScale, MTXMODE_APPLY); + + if (limbIndex & 1) { Matrix_InsertYRotation_f(M_PI, MTXMODE_APPLY); } - if (i & 2) { + + if (limbIndex & 2) { Matrix_InsertZRotation_f(M_PI, MTXMODE_APPLY); } gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_0506E0); - - limbPos++; + gSPDisplayList(POLY_XLU_DISP++, gFrozenIceVtxDL); } - limbPos = limbAux; + limbPos = limbPosStart; // reset limbPos + + // Setup to draw steam over frozen actor gDPSetColorDither(POLY_XLU_DISP++, G_CD_BAYER); - gDPSetAlphaDither(POLY_XLU_DISP++, G_AD_PATTERN); - - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_051180); + gSPDisplayList(POLY_XLU_DISP++, gFrozenSteamDL); alpha = effectAlpha * 100.0f; if (alpha > 100.0f) { @@ -4548,158 +4597,165 @@ void func_800BE680(GlobalContext* globalCtx, Actor* actor, Vec3f limbPos[], s16 gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 225, 235, (u8)alpha); - for (i = 0; i < arg3; i++) { - temp_v1_3 = ((i * 3) + sp110); + // Apply and draw steam over each limb of frozen actor + for (limbIndex = 0; limbIndex < limbPosCount; limbIndex++, limbPos++) { + twoTexScrollParam = ((limbIndex * 3) + gameplayFrames); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, temp_v1_3 * 3, temp_v1_3 * -0xC, 0x20, 0x40, - 1, 0, 0, 0x20, 0x20)); + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, twoTexScrollParam * 3, + twoTexScrollParam * -12, 32, 64, 1, 0, 0, 32, 32)); Matrix_InsertTranslation(limbPos->x, limbPos->y, limbPos->z, MTXMODE_NEW); Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); - Matrix_Scale(sp118, sp118, 1.0f, MTXMODE_APPLY); + Matrix_Scale(steamScale, steamScale, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_051238); - - limbPos++; + gSPDisplayList(POLY_XLU_DISP++, gFrozenSteamVtxDL); } break; - case 0x0: - case 0x1: - if (mode == 0) { + case ACTOR_DRAW_DMGEFF_FIRE: + case ACTOR_DRAW_DMGEFF_BLUE_FIRE: + if (type == ACTOR_DRAW_DMGEFF_FIRE) { gDPSetEnvColor(POLY_XLU_DISP++, 255, 10, 0, 0); } else { gDPSetEnvColor(POLY_XLU_DISP++, 0, 255, 255, 0); - mode = 0xFF; + // Reuse type for blue primitive color + type = 255; } Matrix_SetCurrentState(&globalCtx->billboardMtxF); Matrix_Scale((effectScale * 0.005f) * 1.35f, (effectScale * 0.005f), (effectScale * 0.005f) * 1.35f, MTXMODE_APPLY); - sp74 = effectAlpha * 255.0f; + effectAlphaScaled = effectAlpha * 255.0f; - for (i = 0; i < arg3; i++) { - alpha = i & 3; - alpha = sp74 - 30.0f * alpha; - if (sp74 < 30.0f * (i & 3)) { + // Apply and draw fire on every limb + for (limbIndex = 0; limbIndex < limbPosCount; limbIndex++, limbPos++) { + alpha = limbIndex & 3; + alpha = effectAlphaScaled - 30.0f * alpha; + if (effectAlphaScaled < 30.0f * (limbIndex & 3)) { alpha = 0.0f; } if (alpha > 255.0f) { alpha = 255.0f; } - gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, mode, (u8)alpha); + // Use type for blue primitive color + // = 0 for ACTOR_DRAW_DMGEFF_FIRE + // = 255 for ACTOR_DRAW_DMGEFF_BLUE_FIRE + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, type, (u8)alpha); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, - ((i * 10 + sp110) * -0x14) & 0x1FF, 0x20, 0x80)); + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, + ((limbIndex * 10 + gameplayFrames) * -20) & 0x1FF, 32, 128)); Matrix_InsertYRotation_f(M_PI, MTXMODE_APPLY); - temp_s3->mf[3][0] = limbPos->x; - temp_s3->mf[3][1] = limbPos->y; - temp_s3->mf[3][2] = limbPos->z; + currentMatrix->mf[3][0] = limbPos->x; + currentMatrix->mf[3][1] = limbPos->y; + currentMatrix->mf[3][2] = limbPos->z; gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gGameplayKeepDrawFlameDL); - - limbPos++; } break; - case 0x14: - case 0x15: - sp120 = ((KREG(19) * 0.01f) + 4.0f) * effectScale; + case ACTOR_DRAW_DMGEFF_LIGHT_ORBS: + case ACTOR_DRAW_DMGEFF_BLUE_LIGHT_ORBS: - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023348); + // Setup to draw light orbs on actor + + lightOrbsScale = ((KREG(19) * 0.01f) + 4.0f) * effectScale; + + gSPDisplayList(POLY_XLU_DISP++, gLightOrb1DL); alpha = effectAlpha * 255.0f; if (alpha > 255.0f) { alpha = 255.0f; } - if (mode == 0x15) { - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (u8)(sREG(16) + 0xFF), (u8)(sREG(17) + 0xFF), - (u8)(sREG(18) + 0xFF), (u8)alpha); + if (type == ACTOR_DRAW_DMGEFF_BLUE_LIGHT_ORBS) { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (u8)(sREG(16) + 255), (u8)(sREG(17) + 255), + (u8)(sREG(18) + 255), (u8)alpha); - gDPSetEnvColor(POLY_XLU_DISP++, (u8)sREG(19), (u8)(sREG(20) + 0xFF), (u8)(sREG(21) + 0xFF), 0x80); + gDPSetEnvColor(POLY_XLU_DISP++, (u8)sREG(19), (u8)(sREG(20) + 255), (u8)(sREG(21) + 255), 128); } else { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 200, (u8)alpha); gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 100, 128); } - Matrix_SetCurrentState(&globalCtx->billboardMtxF); - Matrix_Scale(sp120, sp120, 1.0f, MTXMODE_APPLY); - for (i = 0; i < arg3; i++) { + Matrix_SetCurrentState(&globalCtx->billboardMtxF); + Matrix_Scale(lightOrbsScale, lightOrbsScale, 1.0f, MTXMODE_APPLY); + + // Apply and draw a light orb over each limb of frozen actor + for (limbIndex = 0; limbIndex < limbPosCount; limbIndex++, limbPos++) { Matrix_InsertZRotation_f(randPlusMinusPoint5Scaled(2 * M_PI), MTXMODE_APPLY); - temp_s3->mf[3][0] = limbPos->x; - temp_s3->mf[3][1] = limbPos->y; - temp_s3->mf[3][2] = limbPos->z; + currentMatrix->mf[3][0] = limbPos->x; + currentMatrix->mf[3][1] = limbPos->y; + currentMatrix->mf[3][2] = limbPos->z; gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023428); - - limbPos++; + gSPDisplayList(POLY_XLU_DISP++, gLightOrbVtxDL); } break; - case 0x1E: - case 0x1F: - case 0x20: - if (mode == 0x1E) { - sp11C = (KREG(19) * 0.01f + 1.0f) * effectScale; - } else if (mode == 0x1F) { - sp11C = (KREG(19) * 0.01f + 1.5f) * effectScale; + case ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL: + case ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_MEDIUM: + case ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_LARGE: + if (type == ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL) { + electricSparksScale = (KREG(19) * 0.01f + 1.0f) * effectScale; + } else if (type == ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_MEDIUM) { + electricSparksScale = (KREG(19) * 0.01f + 1.5f) * effectScale; } else { - sp11C = (KREG(19) * 0.01f + 2.0f) * effectScale; + electricSparksScale = (KREG(19) * 0.01f + 2.0f) * effectScale; } - gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(D_801AEFA8[globalCtx->gameplayFrames & 3])); + gSPSegment(POLY_XLU_DISP++, 0x08, + Lib_SegmentedToVirtual(sElectricSparkTextures[globalCtx->gameplayFrames % 4])); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023480); + gSPDisplayList(POLY_XLU_DISP++, gElectricSparkDL); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (u8)(sREG(16) + 0xFF), (u8)(sREG(17) + 0xFF), - (u8)(sREG(18) + 0x96), (u8)(sREG(19) + 0xFF)); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (u8)(sREG(16) + 255), (u8)(sREG(17) + 255), (u8)(sREG(18) + 150), + (u8)(sREG(19) + 255)); - gDPSetEnvColor(POLY_XLU_DISP++, (u8)(sREG(20) + 0xFF), (u8)(sREG(21) + 0xFF), (u8)sREG(22), - (u8)sREG(23)); + gDPSetEnvColor(POLY_XLU_DISP++, (u8)(sREG(20) + 255), (u8)(sREG(21) + 255), (u8)sREG(22), (u8)sREG(23)); Matrix_SetCurrentState(&globalCtx->billboardMtxF); - Matrix_Scale(sp11C, sp11C, sp11C, MTXMODE_APPLY); + Matrix_Scale(electricSparksScale, electricSparksScale, electricSparksScale, MTXMODE_APPLY); - for (i = 0; i < arg3; i++) { + // Every limb draws two electric sparks at random orientations + for (limbIndex = 0; limbIndex < limbPosCount; limbIndex++, limbPos++) { + // first electric spark Matrix_RotateStateAroundXAxis(Rand_ZeroFloat(2 * M_PI)); Matrix_InsertZRotation_f(Rand_ZeroFloat(2 * M_PI), MTXMODE_APPLY); - temp_s3->mf[3][0] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->x; - temp_s3->mf[3][1] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->y; - temp_s3->mf[3][2] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->z; + currentMatrix->mf[3][0] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->x; + currentMatrix->mf[3][1] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->y; + currentMatrix->mf[3][2] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->z; gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_0234F0); + gSPDisplayList(POLY_XLU_DISP++, gElectricSparkVtxDL); + // second electric spark Matrix_RotateStateAroundXAxis(Rand_ZeroFloat(2 * M_PI)); Matrix_InsertZRotation_f(Rand_ZeroFloat(2 * M_PI), MTXMODE_APPLY); - temp_s3->mf[3][0] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->x; - temp_s3->mf[3][1] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->y; - temp_s3->mf[3][2] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->z; + currentMatrix->mf[3][0] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->x; + currentMatrix->mf[3][1] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->y; + currentMatrix->mf[3][2] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->z; gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_0234F0); - - limbPos++; + gSPDisplayList(POLY_XLU_DISP++, gElectricSparkVtxDL); } + break; } diff --git a/src/code/z_bgcheck.c b/src/code/z_bgcheck.c index 3f5583f798..f0ebe59113 100644 --- a/src/code/z_bgcheck.c +++ b/src/code/z_bgcheck.c @@ -5,11 +5,11 @@ #define DYNA_RAYCAST_WALLS 2 #define DYNA_RAYCAST_CEILINGS 4 -static u32 sWallFlags[32] = { +u32 sWallFlags[32] = { 0, 1, 3, 5, 8, 16, 32, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; -static u16 sSurfaceTypeSfx[] = { +u16 sSurfaceTypeSfx[] = { /* 0x00 */ NA_SE_PL_WALK_GROUND - SFX_FLAG, /* 0x01 */ NA_SE_PL_WALK_SAND - SFX_FLAG, /* 0x02 */ NA_SE_PL_WALK_CONCRETE - SFX_FLAG, @@ -27,7 +27,7 @@ static u16 sSurfaceTypeSfx[] = { /* 0x0E */ NA_SE_PL_WALK_SNOW - SFX_FLAG }; -static u8 D_801B46C0[] = { +u8 D_801B46C0[] = { /* 0x00 */ 1, /* 0x01 */ 1, /* 0x02 */ 0, @@ -45,7 +45,7 @@ static u8 D_801B46C0[] = { /* 0x0E */ 1 }; -static s16 sSmallMemScenes[] = { +s16 sSmallMemScenes[] = { SCENE_F01, }; @@ -54,7 +54,7 @@ typedef struct { u32 memSize; } BgCheckSceneMemEntry; -static BgCheckSceneMemEntry sSceneMemList[] = { +BgCheckSceneMemEntry sSceneMemList[] = { { SCENE_00KEIKOKU, 0xC800 }, }; @@ -4440,11 +4440,13 @@ s32 WaterBox_GetSurfaceImpl(GlobalContext* globalCtx, CollisionContext* colCtx, return false; } +// boolean s32 WaterBox_GetSurface1(GlobalContext* globalCtx, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox) { - WaterBox_GetSurface1_2(globalCtx, colCtx, x, z, ySurface, outWaterBox); + return WaterBox_GetSurface1_2(globalCtx, colCtx, x, z, ySurface, outWaterBox); } +// boolean s32 WaterBox_GetSurface1_2(GlobalContext* globalCtx, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox) { s32 bgId; diff --git a/src/code/z_camera.c b/src/code/z_camera.c index 9aef846e0c..d3f1f92033 100644 --- a/src/code/z_camera.c +++ b/src/code/z_camera.c @@ -356,7 +356,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800E01AC.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800E01B8.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_GetQuakeOffset.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800E01DC.s") diff --git a/src/code/z_common_data.c b/src/code/z_common_data.c index 26fd324a73..3860cf153c 100644 --- a/src/code/z_common_data.c +++ b/src/code/z_common_data.c @@ -3,8 +3,9 @@ SaveContext gSaveContext; void SaveContext_Init(void) { - bzero(&gSaveContext, sizeof(gSaveContext)); - gSaveContext.playerForm = 0; + bzero(&gSaveContext, sizeof(SaveContext)); + + gSaveContext.save.playerForm = 0; gSaveContext.seqIndex = (u8)NA_BGM_DISABLED; gSaveContext.nightSeqIndex = 0xFF; gSaveContext.unk_3F46 = NA_BGM_GENERAL_SFX; @@ -16,7 +17,8 @@ void SaveContext_Init(void) { gSaveContext.dogIsLost = true; gSaveContext.nextTransition = 0xFF; gSaveContext.unk_3F26 = 50; - gSaveContext.language = 1; - gSaveContext.audioSetting = 0; - gSaveContext.zTargetSetting = 0; + + gSaveContext.options.language = 1; + gSaveContext.options.audioSetting = 0; + gSaveContext.options.zTargetSetting = 0; } diff --git a/src/code/z_demo.c b/src/code/z_demo.c index fb6f8687ca..c9c6253d30 100644 --- a/src/code/z_demo.c +++ b/src/code/z_demo.c @@ -21,7 +21,7 @@ u8 sCutsceneStoredPlayerForm = 0; static u16 seqId; #endif s16 sCutsceneQuakeIndex; -struct_801F4D48 sCutsceneCameraInfo; +DbCameraUnkStruct sCutsceneCameraInfo; u16 D_801F4DC8[10]; UNK_TYPE D_801F4DDC; u8 D_801F4DE0; @@ -67,7 +67,7 @@ CutsceneStateHandler sCsStateHandlers1[] = { }; void Cutscene_Update1(GlobalContext* globalCtx, CutsceneContext* csCtx) { - if (gSaveContext.cutscene < 0xFFF0) { + if (gSaveContext.save.cutscene < 0xFFF0) { sCsStateHandlers1[csCtx->state](globalCtx, csCtx); } } @@ -86,11 +86,11 @@ void Cutscene_Update2(GlobalContext* globalCtx, CutsceneContext* csCtx) { } if ((gSaveContext.cutsceneTrigger != 0) && (csCtx->state == CS_STATE_0)) { - gSaveContext.cutscene = 0xFFFD; + gSaveContext.save.cutscene = 0xFFFD; gSaveContext.cutsceneTrigger = 1; } - if (gSaveContext.cutscene >= 0xFFF0) { + if (gSaveContext.save.cutscene >= 0xFFF0) { func_800EDA84(globalCtx, csCtx); sCsStateHandlers2[csCtx->state](globalCtx, csCtx); } @@ -249,12 +249,12 @@ void Cutscene_Command_Misc(GlobalContext* globalCtx2, CutsceneContext* csCtx, Cs gSaveContext.sunsSongState = SUNSSONG_START; break; case 0x12: - if (!gSaveContext.isNight) { - time = gSaveContext.time; - gSaveContext.time = time - (u16)REG(15); + if (!gSaveContext.save.isNight) { + time = gSaveContext.save.time; + gSaveContext.save.time = time - (u16)REG(15); } else { - time = gSaveContext.time; - gSaveContext.time = time - (u16)(2 * REG(15)); + time = gSaveContext.save.time; + gSaveContext.save.time = time - (u16)(2 * REG(15)); } break; case 0x13: @@ -269,7 +269,7 @@ void Cutscene_Command_Misc(GlobalContext* globalCtx2, CutsceneContext* csCtx, Cs EnvFlags_Set(globalCtx, 4); break; case 0x16: - gSaveContext.playerForm = PLAYER_FORM_DEKU; + gSaveContext.save.playerForm = PLAYER_FORM_DEKU; break; case 0x17: player->stateFlags2 |= 0x4000000; @@ -278,9 +278,9 @@ void Cutscene_Command_Misc(GlobalContext* globalCtx2, CutsceneContext* csCtx, Cs player->stateFlags2 &= ~0x4000000; break; case 0x19: - sCutsceneStoredPlayerForm = gSaveContext.playerForm; - gSaveContext.playerForm = PLAYER_FORM_HUMAN; - gSaveContext.equippedMask = PLAYER_MASK_NONE; + sCutsceneStoredPlayerForm = gSaveContext.save.playerForm; + gSaveContext.save.playerForm = PLAYER_FORM_HUMAN; + gSaveContext.save.equippedMask = PLAYER_MASK_NONE; break; case 0x1A: func_8019F128(NA_SE_EV_EARTHQUAKE_LAST2 - SFX_FLAG); @@ -305,7 +305,7 @@ void Cutscene_Command_Misc(GlobalContext* globalCtx2, CutsceneContext* csCtx, Cs } break; case 0x1D: - gSaveContext.playerForm = sCutsceneStoredPlayerForm; + gSaveContext.save.playerForm = sCutsceneStoredPlayerForm; break; case 0x1E: D_801F4DE0 = true; @@ -315,7 +315,7 @@ void Cutscene_Command_Misc(GlobalContext* globalCtx2, CutsceneContext* csCtx, Cs break; case 0x21: if (isStartFrame) { - func_80146EE8(globalCtx); + Sram_SaveSpecialEnterClockTown(globalCtx); } break; case 0x22: @@ -328,10 +328,10 @@ void Cutscene_Command_Misc(GlobalContext* globalCtx2, CutsceneContext* csCtx, Cs D_801BB15C = csCtx->frames; if (REG(15) != 0) { - time = gSaveContext.time; - gSaveContext.time = (u16)REG(15) + time; - time = gSaveContext.time; - gSaveContext.time = (u16)gSaveContext.unk_14 + time; + time = gSaveContext.save.time; + gSaveContext.save.time = (u16)REG(15) + time; + time = gSaveContext.save.time; + gSaveContext.save.time = (u16)gSaveContext.save.daySpeed + time; } } break; @@ -348,7 +348,7 @@ void Cutscene_Command_Misc(GlobalContext* globalCtx2, CutsceneContext* csCtx, Cs case 0x26: // Seems to be used to trigger "Dawn of A New Day" - gSaveContext.day = 9; + gSaveContext.save.day = 9; { GameState* gameState = &globalCtx->state; @@ -356,11 +356,11 @@ void Cutscene_Command_Misc(GlobalContext* globalCtx2, CutsceneContext* csCtx, Cs } SET_NEXT_GAMESTATE(&globalCtx->state, Daytelop_Init, DaytelopContext); - func_80146F5C(globalCtx); + Sram_SaveSpecialNewDay(globalCtx); break; case 0x27: - gSaveContext.playerForm = PLAYER_FORM_ZORA; + gSaveContext.save.playerForm = PLAYER_FORM_ZORA; break; case 0x28: @@ -441,7 +441,7 @@ void func_800EADB0(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* u8 dayMinusOne; if (csCtx->frames == cmd->startFrame) { - dayMinusOne = (gSaveContext.day - 1); + dayMinusOne = (gSaveContext.save.day - 1); if (dayMinusOne >= 3) { dayMinusOne = 0; } @@ -556,7 +556,7 @@ void Cutscene_Command_SetTime(GlobalContext* globalCtx, CutsceneContext* csCtx, minutes = CLOCK_TIME_ALT_F(0, cmd->minute + 1); nextTime = hourAsMinutes + minutes; - gSaveContext.time = nextTime; + gSaveContext.save.time = nextTime; gSaveContext.environmentTime = nextTime; } } @@ -571,7 +571,7 @@ void Cutscene_TerminatorImpl(GlobalContext* globalCtx, CutsceneContext* csCtx, C gSaveContext.unk_3F1E = 1; } - gSaveContext.cutscene = 0; + gSaveContext.save.cutscene = 0; if (cmd->base == 1) { globalCtx->nextEntranceIndex = globalCtx->csCtx.sceneCsList[globalCtx->csCtx.currentCsIndex].nextEntranceIndex; gSaveContext.nextCutsceneIndex = 0; @@ -606,7 +606,7 @@ void Cutscene_Command_Terminator(GlobalContext* globalCtx, CutsceneContext* csCt switch (D_801F4DE2) { case 0x1F: - if (gSaveContext.weekEventReg[0x14] & 2) { + if (gSaveContext.save.weekEventReg[20] & 2) { globalCtx->nextEntranceIndex = 0x3010; globalCtx->sceneLoadFlag = 0x14; globalCtx->unk_1887F = 3; @@ -619,7 +619,7 @@ void Cutscene_Command_Terminator(GlobalContext* globalCtx, CutsceneContext* csCt break; case 0x44: - if (gSaveContext.weekEventReg[0x21] & 0x80) { + if (gSaveContext.save.weekEventReg[33] & 0x80) { globalCtx->nextEntranceIndex = 0xAE70; globalCtx->sceneLoadFlag = 0x14; globalCtx->unk_1887F = 3; @@ -632,7 +632,7 @@ void Cutscene_Command_Terminator(GlobalContext* globalCtx, CutsceneContext* csCt break; case 0x5F: - gSaveContext.weekEventReg[0x37] |= 0x80; + gSaveContext.save.weekEventReg[55] |= 0x80; globalCtx->nextEntranceIndex = 0x6A80; gSaveContext.nextCutsceneIndex = 0xFFF0; globalCtx->sceneLoadFlag = 0x14; @@ -640,7 +640,7 @@ void Cutscene_Command_Terminator(GlobalContext* globalCtx, CutsceneContext* csCt break; case 0x36: - gSaveContext.weekEventReg[0x34] |= 0x20; + gSaveContext.save.weekEventReg[52] |= 0x20; globalCtx->nextEntranceIndex = 0x2000; gSaveContext.nextCutsceneIndex = 0xFFF1; globalCtx->sceneLoadFlag = 0x14; @@ -812,7 +812,7 @@ void Cutscene_Command_GiveTatlToPlayer(GlobalContext* globalCtx, CutsceneContext if (csCtx->frames == cmd->startFrame) { if (cmd->base == 1) { - gSaveContext.hasTatl = true; + gSaveContext.save.hasTatl = true; if (player->tatlActor != NULL) { return; } @@ -1054,7 +1054,7 @@ void Cutscene_Command_Textbox(GlobalContext* globalCtx, CutsceneContext* csCtx, dialogState = Message_GetState(&globalCtx->msgCtx); if ((dialogState != 2) && (dialogState != 0) && (dialogState != 7) && (dialogState != 8)) { csCtx->frames--; - if ((dialogState == 4) && func_80147624(globalCtx)) { + if ((dialogState == 4) && Message_ShouldAdvance(globalCtx)) { if (globalCtx->msgCtx.choiceIndex == 0) { if (cmd->base == 0x33BD) { func_8019F230(); @@ -1092,7 +1092,7 @@ void Cutscene_Command_Textbox(GlobalContext* globalCtx, CutsceneContext* csCtx, } } - if (dialogState == 5 && func_80147624(globalCtx) != 0) { + if (dialogState == 5 && Message_ShouldAdvance(globalCtx)) { func_80152434(globalCtx, cmd->base); } } @@ -1417,13 +1417,14 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, } } #else +void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, u8* cutscenePtr); #pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/Cutscene_ProcessCommands.s") #endif /* End of command handling section */ void func_800ED980(GlobalContext* globalCtx, CutsceneContext* csCtx) { - if (gSaveContext.cutscene >= 0xFFF0) { + if (gSaveContext.save.cutscene >= 0xFFF0) { csCtx->frames++; Cutscene_ProcessCommands(globalCtx, csCtx, (u8*)globalCtx->csCtx.csData); } @@ -1447,7 +1448,7 @@ void func_800EDA04(GlobalContext* globalCtx, CutsceneContext* csCtx) { csCtx->actorActions[i] = NULL; } - gSaveContext.cutscene = 0; + gSaveContext.save.cutscene = 0; gSaveContext.gameMode = 0; ActorCutscene_Stop(0x7F); Audio_SetCutsceneFlag(false); @@ -1457,10 +1458,10 @@ void func_800EDA04(GlobalContext* globalCtx, CutsceneContext* csCtx) { void func_800EDA84(GlobalContext* globalCtx, CutsceneContext* csCtx) { if ((gSaveContext.cutsceneTrigger != 0) && (csCtx->state == CS_STATE_0) && !Player_InCsMode(&globalCtx->state)) { - gSaveContext.cutscene = 0xFFFD; + gSaveContext.save.cutscene = 0xFFFD; } - if ((gSaveContext.cutscene >= 0xFFF0) && (csCtx->state == CS_STATE_0)) { + if ((gSaveContext.save.cutscene >= 0xFFF0) && (csCtx->state == CS_STATE_0)) { s16 i; D_801BB124 = 0; @@ -1514,8 +1515,9 @@ void func_800EDBE0(GlobalContext* globalCtx) { ActorCutscene_Start(sp2A, NULL); gSaveContext.showTitleCard = false; } else if (!((1 << (temp_a3[temp_v0_3].unk7 % 8)) & - gSaveContext.weekEventReg[temp_a3[temp_v0_3].unk7 / 8])) { - gSaveContext.weekEventReg[(temp_a3[temp_v0_3].unk7 / 8)] |= 1 << (temp_a3[temp_v0_3].unk7 % 8); + gSaveContext.save.weekEventReg[temp_a3[temp_v0_3].unk7 / 8])) { + gSaveContext.save.weekEventReg[(temp_a3[temp_v0_3].unk7 / 8)] |= + 1 << (temp_a3[temp_v0_3].unk7 % 8); ActorCutscene_Start(sp2A, NULL); gSaveContext.showTitleCard = false; } @@ -1529,8 +1531,8 @@ void func_800EDBE0(GlobalContext* globalCtx) { if ((gSaveContext.respawnFlag == 0) || (gSaveContext.respawnFlag == -2)) { sp24 = globalCtx->loadedScene; if ((sp24->titleTextId != 0) && gSaveContext.showTitleCard) { - if ((Entrance_GetTransitionFlags(gSaveContext.sceneSetupIndex + gSaveContext.entranceIndex) & 0x4000) != - 0) { + if ((Entrance_GetTransitionFlags(gSaveContext.sceneSetupIndex + gSaveContext.save.entranceIndex) & + 0x4000) != 0) { func_80151A68(globalCtx, sp24->titleTextId); } } diff --git a/src/code/z_eff_blure.c b/src/code/z_eff_blure.c index b17799aff5..6ab70f1efa 100644 --- a/src/code/z_eff_blure.c +++ b/src/code/z_eff_blure.c @@ -309,6 +309,7 @@ void EffectBlure_GetComputedValues(EffectBlure* this, s32 index, f32 ratio, Vec3 Vec3s sp30; f32 mode4Param; EffectBlureElement* elem = &this->elements[index]; + Vec3s* unusedPtr = &sp30; // Optimized out but seems necessary to match stack usage switch (this->calcMode) { case 1: @@ -367,8 +368,6 @@ void EffectBlure_GetComputedValues(EffectBlure* this, s32 index, f32 ratio, Vec3 break; } - sp30 = sp30; // Optimized out but seems necessary to match stack usage - if (this->flags & 0x10) { color1->r = color1->g = color1->b = color1->a = 255; color2->r = color2->g = color2->b = color2->a = 255; diff --git a/src/code/z_effect_soft_sprite_old_init.c b/src/code/z_effect_soft_sprite_old_init.c index 3f868ecc36..0300144e10 100644 --- a/src/code/z_effect_soft_sprite_old_init.c +++ b/src/code/z_effect_soft_sprite_old_init.c @@ -625,11 +625,11 @@ void EffectSsSibuki_SpawnBurst(GlobalContext* globalCtx, Vec3f* pos) { // EffectSsStone1 Spawn Functions -void EffectSsStone1_Spawn(GlobalContext* globalCtx, Vec3f* pos, s32 arg2) { +void EffectSsStone1_Spawn(GlobalContext* globalCtx, Vec3f* pos, s32 reg0) { EffectSsStone1InitParams initParams; initParams.pos = *pos; - initParams.unk_C = arg2; + initParams.reg0 = reg0; EffectSs_Spawn(globalCtx, EFFECT_SS_STONE1, 128, &initParams); } diff --git a/src/code/z_elf_message.c b/src/code/z_elf_message.c index 7308b33f4e..cd2fa96b6e 100644 --- a/src/code/z_elf_message.c +++ b/src/code/z_elf_message.c @@ -7,17 +7,17 @@ u16 ElfMessage_GetFirstCycleHint(GlobalContext* globalCtx) { if (CURRENT_DAY <= 0) { return 0; } - if (gSaveContext.weekEventReg[88] & 0x20) { + if (gSaveContext.save.weekEventReg[88] & 0x20) { return 0; } - if (gSaveContext.weekEventReg[79] & 0x10) { - if (gSaveContext.weekEventReg[8] & 0x40) { + if (gSaveContext.save.weekEventReg[79] & 0x10) { + if (gSaveContext.save.weekEventReg[8] & 0x40) { return 0; } return 0x224; } - if (!(gSaveContext.weekEventReg[8] & 0x80)) { - if (gSaveContext.weekEventReg[9] & 1) { + if (!(gSaveContext.save.weekEventReg[8] & 0x80)) { + if (gSaveContext.save.weekEventReg[9] & 1) { return 0x21E; } if (globalCtx->sceneNum == SCENE_YOUSEI_IZUMI) { @@ -25,7 +25,7 @@ u16 ElfMessage_GetFirstCycleHint(GlobalContext* globalCtx) { } return 0x21D; } - if (gSaveContext.magicAcquired != true) { + if (gSaveContext.save.playerData.magicAcquired != true) { return 0x21F; } if (INV_CONTENT(ITEM_DEED_LAND) == ITEM_DEED_LAND) { @@ -35,27 +35,27 @@ u16 ElfMessage_GetFirstCycleHint(GlobalContext* globalCtx) { return 0; } if (INV_CONTENT(ITEM_MOON_TEAR) == ITEM_MOON_TEAR) { - if (gSaveContext.weekEventReg[86] & 4) { + if (gSaveContext.save.weekEventReg[86] & 4) { return 0x242; } return 0x243; } - if (gSaveContext.weekEventReg[74] & 0x20) { + if (gSaveContext.save.weekEventReg[74] & 0x20) { return 0x223; } - if (gSaveContext.weekEventReg[73] & 0x80) { + if (gSaveContext.save.weekEventReg[73] & 0x80) { return 0x222; } - if (gSaveContext.weekEventReg[73] & 0x20) { + if (gSaveContext.save.weekEventReg[73] & 0x20) { return 0x221; } - if (gSaveContext.weekEventReg[77] & 2) { - if (gSaveContext.weekEventReg[73] & 0x10) { + if (gSaveContext.save.weekEventReg[77] & 2) { + if (gSaveContext.save.weekEventReg[73] & 0x10) { return 0x240; } return 0x241; } - if ((gSaveContext.weekEventReg[86] & 2) || (gSaveContext.weekEventReg[73] & 0x40)) { + if ((gSaveContext.save.weekEventReg[86] & 2) || (gSaveContext.save.weekEventReg[73] & 0x40)) { return 0x23F; } return 0x220; diff --git a/src/code/z_en_hy_code.c b/src/code/z_en_hy_code.c index 915687125c..28c1770680 100644 --- a/src/code/z_en_hy_code.c +++ b/src/code/z_en_hy_code.c @@ -12,7 +12,7 @@ #include "objects/object_os_anime/object_os_anime.h" static AnimationInfoS sAnimations[] = { - { &object_aob_Anim_00007C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gMamamuYanUnusedIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, { &object_boj_Anim_001494, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, { &object_boj_Anim_001494, 1.0f, 0, -1, ANIMMODE_LOOP, -8 }, { &object_boj_Anim_001908, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, @@ -37,9 +37,9 @@ static AnimationInfoS sAnimations[] = { s8 gEnHyBodyParts[] = { -1, 1, 12, 13, 14, 9, 10, 11, 0, 6, 7, 8, 3, 4, 5, 2 }; -s8 gEnHyBodyPartsIndex[] = { 0, 0, 0, 0, 3, 4, 0, 6, 7, 0, 9, 10, 0, 12, 13 }; +s8 gEnHyParentBodyParts[] = { 0, 0, 0, 0, 3, 4, 0, 6, 7, 0, 9, 10, 0, 12, 13 }; -u8 gEnHyShadowSize[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +u8 gEnHyShadowSizes[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; s32 EnHy_ChangeAnim(SkelAnime* skelAnime, s16 animIndex) { s16 frameCount; @@ -152,7 +152,7 @@ s32 func_800F0CE4(EnHy* enHy, GlobalContext* globalCtx, ActorFunc draw, s16 arg3 EnDoor* door; s32 pad; - if (func_8013D68C(enHy->path, enHy->curPoint, &enHy->actor.world.pos)) { + if (SubS_CopyPointFromPath(enHy->path, enHy->curPoint, &enHy->actor.world.pos)) { door = EnHy_FindNearestDoor(&enHy->actor, globalCtx); if (door != NULL) { ret = true; @@ -174,7 +174,7 @@ s32 func_800F0DD4(EnHy* enHy, GlobalContext* globalCtx, s16 arg2, s16 arg3) { EnDoor* door; enHy->curPoint = 0; - if (func_8013D68C(enHy->path, enHy->curPoint, &enHy->actor.world.pos)) { + if (SubS_CopyPointFromPath(enHy->path, enHy->curPoint, &enHy->actor.world.pos)) { door = EnHy_FindNearestDoor(&enHy->actor, globalCtx); if (door != NULL) { ret = true; @@ -209,7 +209,8 @@ s32 EnHy_MoveForwards(EnHy* enHy, f32 speedTarget) { Math_SmoothStepToF(&enHy->actor.speedXZ, speedTarget, 0.4f, 1000.0f, 0.0f); rotStep = enHy->actor.speedXZ * 400.0f; - if (func_8013D68C(enHy->path, enHy->curPoint, &curPointPos) && func_8013D768(&enHy->actor, &curPointPos, rotStep)) { + if (SubS_CopyPointFromPath(enHy->path, enHy->curPoint, &curPointPos) && + SubS_MoveActorToPoint(&enHy->actor, &curPointPos, rotStep)) { enHy->curPoint++; if (enHy->curPoint >= enHy->path->count) { reachedEnd = true; @@ -226,7 +227,8 @@ s32 EnHy_MoveBackwards(EnHy* enHy, f32 speedTarget) { Math_SmoothStepToF(&enHy->actor.speedXZ, speedTarget, 0.4f, 1000.0f, 0.0f); rotStep = enHy->actor.speedXZ * 400.0f; - if (func_8013D68C(enHy->path, enHy->curPoint, &curPointPos) && func_8013D768(&enHy->actor, &curPointPos, rotStep)) { + if (SubS_CopyPointFromPath(enHy->path, enHy->curPoint, &curPointPos) && + SubS_MoveActorToPoint(&enHy->actor, &curPointPos, rotStep)) { enHy->curPoint--; if (enHy->curPoint < 0) { reachedEnd = true; @@ -263,12 +265,12 @@ s32 EnHy_PlayWalkingSound(EnHy* enHy, GlobalContext* globalCtx, f32 distAboveThr sfxId = SurfaceType_GetSfx(&globalCtx->colCtx, enHy->actor.floorPoly, enHy->actor.floorBgId) + SFX_FLAG; } - enHy->isLeftFootOnGround = isFootOnGround = func_8013DB90(globalCtx, &enHy->leftFootPos, distAboveThreshold); + enHy->isLeftFootOnGround = isFootOnGround = SubS_IsFloorAbove(globalCtx, &enHy->leftFootPos, distAboveThreshold); if (enHy->isLeftFootOnGround && !wasLeftFootOnGround && isFootOnGround) { Actor_PlaySfxAtPos(&enHy->actor, sfxId); } - enHy->isRightFootOnGround = isFootOnGround = func_8013DB90(globalCtx, &enHy->rightFootPos, distAboveThreshold); + enHy->isRightFootOnGround = isFootOnGround = SubS_IsFloorAbove(globalCtx, &enHy->rightFootPos, distAboveThreshold); if (enHy->isRightFootOnGround && !wasRightFootOnGround && isFootOnGround) { Actor_PlaySfxAtPos(&enHy->actor, sfxId); } diff --git a/src/code/z_en_item00.c b/src/code/z_en_item00.c index 5c8a75f982..b8fa0f4f10 100644 --- a/src/code/z_en_item00.c +++ b/src/code/z_en_item00.c @@ -822,13 +822,14 @@ s16 func_800A7650(s16 dropId) { (((dropId == ITEM00_ARROWS_10) || (dropId == ITEM00_ARROWS_30) || (dropId == ITEM00_ARROWS_40) || (dropId == ITEM00_ARROWS_50)) && (INV_CONTENT(ITEM_BOW) == ITEM_NONE)) || - (((dropId == ITEM00_MAGIC_LARGE) || (dropId == ITEM00_MAGIC_SMALL)) && (gSaveContext.magicLevel == 0))) { + (((dropId == ITEM00_MAGIC_LARGE) || (dropId == ITEM00_MAGIC_SMALL)) && + (gSaveContext.save.playerData.magicLevel == 0))) { return ITEM00_NO_DROP; } if (dropId == ITEM00_HEART) { - healthCapacity = gSaveContext.healthCapacity; - if (healthCapacity == gSaveContext.health) { + healthCapacity = gSaveContext.save.playerData.healthCapacity; + if (healthCapacity == gSaveContext.save.playerData.health) { return ITEM00_RUPEE_GREEN; } } @@ -1049,7 +1050,7 @@ void Item_DropCollectibleRandom(GlobalContext* globalCtx, Actor* fromActor, Vec3 dropQuantity = sDropTableAmounts[params + dropTableIndex]; if (dropId == ITEM00_MASK) { - switch (gSaveContext.playerForm) { + switch (gSaveContext.save.playerForm) { case PLAYER_FORM_HUMAN: dropId = ITEM00_ARROWS_10; break; @@ -1085,26 +1086,27 @@ void Item_DropCollectibleRandom(GlobalContext* globalCtx, Actor* fromActor, Vec3 } if (dropId == ITEM00_FLEXIBLE) { - if (gSaveContext.health <= 0x10) { + if (gSaveContext.save.playerData.health <= 0x10) { Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, spawnPos->x, spawnPos->y + 40.0f, spawnPos->z, 0, 0, 0, 2); SoundSource_PlaySfxAtFixedWorldPos(globalCtx, spawnPos, 40, NA_SE_EV_BUTTERFRY_TO_FAIRY); return; } - if (gSaveContext.health <= 0x30) { + if (gSaveContext.save.playerData.health <= 0x30) { params = 0x10; dropId = ITEM00_HEART; dropQuantity = 3; - } else if (gSaveContext.health <= 0x50) { + } else if (gSaveContext.save.playerData.health <= 0x50) { params = 0x10; dropId = ITEM00_HEART; dropQuantity = 1; - } else if ((gSaveContext.magicLevel != 0) && (gSaveContext.magic == 0)) { + } else if ((gSaveContext.save.playerData.magicLevel != 0) && (gSaveContext.save.playerData.magic == 0)) { params = 0xD0; dropId = ITEM00_MAGIC_LARGE; dropQuantity = 1; - } else if ((gSaveContext.magicLevel != 0) && ((gSaveContext.magicLevel >> 1) >= gSaveContext.magic)) { + } else if ((gSaveContext.save.playerData.magicLevel != 0) && + ((gSaveContext.save.playerData.magicLevel >> 1) >= gSaveContext.save.playerData.magic)) { params = 0xD0; dropId = ITEM00_MAGIC_LARGE; dropQuantity = 1; @@ -1116,7 +1118,7 @@ void Item_DropCollectibleRandom(GlobalContext* globalCtx, Actor* fromActor, Vec3 params = 0xB0; dropId = ITEM00_BOMBS_A; dropQuantity = 1; - } else if (gSaveContext.rupees < 11) { + } else if (gSaveContext.save.playerData.rupees < 11) { params = 0xA0; dropId = ITEM00_RUPEE_RED; dropQuantity = 1; diff --git a/src/code/z_fireobj.c b/src/code/z_fireobj.c index c6b6a3f9c1..379ebda1d6 100644 --- a/src/code/z_fireobj.c +++ b/src/code/z_fireobj.c @@ -29,13 +29,13 @@ ColliderCylinderInit sFireObjCollisionInit = { { 18, 67, 0, { 0, 0, 0 } }, }; -FireObjLightParams sFireObjLightParams[2] = { - { 255, 255, 0, 255, 128, 255, 0, 0 }, - { 0, 200, 128, 128, 0, 127, 127, 0 }, +FireObjColors sFireObjColors[] = { + { { 255, 255, 0, 255 }, 128, { 255, 0, 0 } }, }; -void FireObj_InitLight(GlobalContext* globalCtx, FireObjLight* light, u8* param_3, Vec3f* pos); -void FireObj_UpdateLight(GlobalContext* globalCtx, FireObjLight* light, FireObj* fire); +FireObjLightParams sFireObjLightParams[] = { + { 200, { 128, 128, 0 }, { 127, 127, 0 } }, +}; void FireObj_InitWithParams(GlobalContext* globalCtx, FireObj* fire, FireObjInitParams* init) { fire->size = init->size; @@ -43,7 +43,7 @@ void FireObj_InitWithParams(GlobalContext* globalCtx, FireObj* fire, FireObjInit fire->dynamicSizeStep = init->dynamicSizeStep; fire->state = init->state; fire->sizeGrowsCos2 = init->sizeGrowsCos2; - fire->unk27 = init->unkA; + fire->colorsIndex = init->colorsIndex; fire->flags = init->flags; fire->xScale = 0.0f; fire->yScale = 0.0f; @@ -53,7 +53,7 @@ void FireObj_InitWithParams(GlobalContext* globalCtx, FireObj* fire, FireObjInit } void FireObj_SetState(FireObj* fire, f32 dynamicSizeStep, u8 newState) { - fire->state = newState & 0xFF; + fire->state = newState; if (fire->state == FIRE_STATE_3) { fire->yScale = 0.0f; fire->xScale = 0.0f; @@ -75,11 +75,11 @@ void FireObj_StepSize(FireObj* fire) { FireObj_SetState(fire, fire->dynamicSizeStep, FIRE_STATE_2); } } else if ((fire->state == FIRE_STATE_1) && (Math_StepToF(&fire->dynamicSize, 0.0f, fire->dynamicSizeStep) != 0)) { - FireObj_SetState(fire, fire->dynamicSizeStep, 3); + FireObj_SetState(fire, fire->dynamicSizeStep, FIRE_STATE_3); } if (fire->sizeGrowsCos2 == 1) { if ((fire->state == FIRE_STATE_0) || (fire->state == FIRE_STATE_1)) { - fire->xScale = (1.0f - Math_CosS((fire->dynamicSize * fire->dynamicSize * 16384.0f))) * fire->size; + fire->xScale = (1.0f - Math_CosS(SQ(fire->dynamicSize) * 0x4000)) * fire->size; fire->yScale = fire->dynamicSize * fire->size; } else { fire->yScale = fire->dynamicSize * fire->size; @@ -96,7 +96,7 @@ void FireObj_UpdateStateTransitions(GlobalContext* globalCtx, FireObj* fire) { Player* player = GET_PLAYER(globalCtx); WaterBox* waterBox; f32 waterY; - s32 sp40 = 0; + s32 sp40 = false; u8 nextState; Vec3f dist; @@ -115,16 +115,16 @@ void FireObj_UpdateStateTransitions(GlobalContext* globalCtx, FireObj* fire) { } if ((fire->flags & 1) && (fire->state != FIRE_STATE_3) && WaterBox_GetSurface1_2(globalCtx, &globalCtx->colCtx, fire->position.x, fire->position.z, &waterY, &waterBox) && - ((fire->yScale * ((void)0, 6500.0f)) < (waterY - fire->position.y))) { // Fake but IDK what else + (waterY - fire->position.y > 6500.0f * fire->yScale)) { FireObj_SetState(fire, fire->dynamicSizeStep, FIRE_STATE_3); } if ((fire->flags & 2) && (player->itemActionParam == PLAYER_AP_STICK)) { Math_Vec3f_Diff(&player->swordInfo[0].tip, &fire->position, &dist); if (Math3D_LengthSquared(&dist) < 400.0f) { - sp40 = 1; + sp40 = true; } } - if (sp40 != 0) { + if (sp40) { if (fire->state == FIRE_STATE_3) { if (player->unk_B28 > 0) { FireObj_SetState(fire, fire->dynamicSizeStep, FIRE_STATE_0); @@ -140,7 +140,7 @@ void FireObj_UpdateStateTransitions(GlobalContext* globalCtx, FireObj* fire) { void FireObj_Draw(GlobalContext* globalCtx, FireObj* fire) { s32 pad; - FireObjLightParams* lightParams = &sFireObjLightParams[fire->unk27]; + FireObjColors* fireColors = &sFireObjColors[fire->colorsIndex]; if (fire->state != FIRE_STATE_3) { Vec3s vec; @@ -151,10 +151,10 @@ void FireObj_Draw(GlobalContext* globalCtx, FireObj* fire) { POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, (fire->unk26 * -20) & 511, 32, 128)); - gDPSetPrimColor(POLY_XLU_DISP++, 0, lightParams->unk4, lightParams->primColor.r, lightParams->primColor.g, - lightParams->primColor.b, lightParams->primColor.a); + gDPSetPrimColor(POLY_XLU_DISP++, 0, fireColors->lod, fireColors->primColor.r, fireColors->primColor.g, + fireColors->primColor.b, fireColors->primColor.a); - gDPSetEnvColor(POLY_XLU_DISP++, lightParams->envColor.r, lightParams->envColor.g, lightParams->envColor.b, 0); + gDPSetEnvColor(POLY_XLU_DISP++, fireColors->envColor.r, fireColors->envColor.g, fireColors->envColor.b, 0); vec.x = 0; vec.y = Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x8000; @@ -168,45 +168,35 @@ void FireObj_Draw(GlobalContext* globalCtx, FireObj* fire) { } } -#ifdef NON_EQUIVALENT -// Accesses data incorrectly -void FireObj_InitLight(GlobalContext* globalCtx, FireObjLight* light, u8* param_3, Vec3f* pos) { - FireObjLightParams* objectParams = &sFireObjLightParams[*param_3]; +void FireObj_InitLight(GlobalContext* globalCtx, FireObjLight* light, u8* paramsIndex, Vec3f* pos) { + FireObjLightParams* objectParams = &sFireObjLightParams[*paramsIndex]; - Lights_PointGlowSetInfo(&light->lightInfo, pos->x, pos->y, pos->z, objectParams->primColor.g, - objectParams->primColor.b, objectParams->primColor.a, objectParams->primColor.r); - light->light = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, (LightInfo*)&light->lightInfo); - light->unk12 = *param_3; + Lights_PointGlowSetInfo(&light->lightInfo, pos->x, pos->y, pos->z, objectParams->color.r, objectParams->color.g, + objectParams->color.b, objectParams->radius); + light->light = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &light->lightInfo); + light->lightParamsIndex = *paramsIndex; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fireobj/FireObj_InitLight.s") -#endif void FireObj_DestroyLight(GlobalContext* globalCtx, FireObjLight* light) { LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, light->light); } -#ifdef NON_EQUIVALENT -// Accesses data incorrectly void FireObj_UpdateLight(GlobalContext* globalCtx, FireObjLight* light, FireObj* fire) { - FireObjLightParams* lightParams = &sFireObjLightParams[light->unk12]; + FireObjLightParams* lightParams = &sFireObjLightParams[light->lightParamsIndex]; s16 radius; if (fire->state == FIRE_STATE_3) { - Lights_PointSetColorAndRadius((LightInfo*)&light->lightInfo, 0, 0, 0, -1); + Lights_PointSetColorAndRadius(&light->lightInfo, 0, 0, 0, -1); } else { radius = ((fire->yScale * 140.0f * fire->sizeInv) + 60.0f); - Lights_PointGlowSetInfo((LightInfo*)&light->lightInfo, fire->position.x, - (fire->position.y + (fire->yScale * 6500.0f)), fire->position.z, - ((s32)(Rand_ZeroOne() * lightParams->envColor.r) + lightParams->primColor.b), - ((s32)(Rand_ZeroOne() * lightParams->envColor.g) + lightParams->primColor.a), - ((s32)(Rand_ZeroOne() * lightParams->envColor.b) + lightParams->unk4), radius); + Lights_PointGlowSetInfo(&light->lightInfo, fire->position.x, (fire->position.y + (fire->yScale * 6500.0f)), + fire->position.z, + ((s32)(Rand_ZeroOne() * lightParams->maxColorAdj.r) + lightParams->color.r), + ((s32)(Rand_ZeroOne() * lightParams->maxColorAdj.g) + lightParams->color.g), + ((s32)(Rand_ZeroOne() * lightParams->maxColorAdj.b) + lightParams->color.b), radius); } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fireobj/FireObj_UpdateLight.s") -#endif void FireObj_Init(GlobalContext* globalCtx, FireObj* fire, FireObjInitParams* init, Actor* actor) { FireObj* fire2 = fire; @@ -218,7 +208,7 @@ void FireObj_Init(GlobalContext* globalCtx, FireObj* fire, FireObjInitParams* in fire2->collision.dim.radius = (fire->size * 4000.0f) + 2.5f; fire2->collision.dim.height = fire->size * 16000.0f; fire->collision.dim.yShift = fire->size * -1728.0f; - FireObj_InitLight(globalCtx, &fire->light, &init->unkC, &fire->position); + FireObj_InitLight(globalCtx, &fire->light, &init->lightParamsIndex, &fire->position); } void FireObj_Destroy(GlobalContext* globalCtx, FireObj* fire) { @@ -235,9 +225,9 @@ void FireObj_Update(GlobalContext* globalCtx, FireObj* fire, Actor* actor) { EnArrow* arrow = (EnArrow*)fire->collision.base.ac; FireObj_UpdateStateTransitions(globalCtx, fire); - if (fire->state == 3) { + if (fire->state == FIRE_STATE_3) { if ((fire->collision.base.acFlags & AC_HIT) && (fire->collision.info.acHitInfo->toucher.dmgFlags & 0x800)) { - FireObj_SetState(fire, fire->dynamicSizeStep, 0); + FireObj_SetState(fire, fire->dynamicSizeStep, FIRE_STATE_0); } } else if ((fire->collision.base.acFlags & AC_HIT) && (arrow->actor.update != NULL) && (arrow->actor.id == ACTOR_EN_ARROW)) { diff --git a/src/code/z_game_over.c b/src/code/z_game_over.c index 411cb5d003..62d55bc00a 100644 --- a/src/code/z_game_over.c +++ b/src/code/z_game_over.c @@ -44,7 +44,7 @@ void GameOver_Update(GlobalContext* globalCtx) { } gSaveContext.unk_3DC0 = 2000; - gSaveContext.tatlTimer = 0; + gSaveContext.save.playerData.tatlTimer = 0; gSaveContext.seqIndex = (u8)NA_BGM_DISABLED; gSaveContext.nightSeqIndex = 0xFF; gSaveContext.eventInf[0] = 0; @@ -72,11 +72,11 @@ void GameOver_Update(GlobalContext* globalCtx) { gSaveContext.respawnFlag = -6; } gSaveContext.nextTransition = 2; - gSaveContext.health = 48; + gSaveContext.save.playerData.health = 48; gameOverCtx->state++; if (INV_CONTENT(ITEM_MASK_DEKU) == ITEM_MASK_DEKU) { - gSaveContext.playerForm = PLAYER_FORM_HUMAN; - gSaveContext.equippedMask = PLAYER_MASK_NONE; + gSaveContext.save.playerForm = PLAYER_FORM_HUMAN; + gSaveContext.save.equippedMask = PLAYER_MASK_NONE; } func_8013EE24(); } diff --git a/src/code/z_kaleido_setup.c b/src/code/z_kaleido_setup.c index 7f4d437845..5a234ea442 100644 --- a/src/code/z_kaleido_setup.c +++ b/src/code/z_kaleido_setup.c @@ -1,9 +1,145 @@ #include "global.h" +#include "overlays/gamestates/ovl_file_choose/z_file_choose.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kaleido_setup/func_800F4A10.s") +s16 D_801BDB00[] = { PAUSE_1, PAUSE_2, PAUSE_3, PAUSE_0 }; +f32 sKaleidoSetupEyeX[] = { -64.0f, 0.0f, 64.0f, 0.0f }; +f32 sKaleidoSetupEyeZ[] = { 0.0f, -64.0f, 0.0f, 64.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kaleido_setup/func_800F4C0C.s") +void func_800F4A10(GlobalContext* globalCtx) { + PauseContext* pauseCtx = &globalCtx->pauseCtx; + s16 i; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kaleido_setup/KaleidoSetup_Init.s") + func_8013EE24(); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kaleido_setup/KaleidoSetup_Destroy.s") + pauseCtx->unk_206 = 0; + pauseCtx->unk_200 = 1; + pauseCtx->eye.x = sKaleidoSetupEyeX[pauseCtx->pageIndex]; + pauseCtx->eye.z = sKaleidoSetupEyeZ[pauseCtx->pageIndex]; + pauseCtx->pageIndex = D_801BDB00[pauseCtx->pageIndex]; + pauseCtx->unk_27E = -40; + + for (i = 0; i < ARRAY_COUNT(pauseCtx->worldMapPoints); i++) { + pauseCtx->worldMapPoints[i] = 0; + } + + if (pauseCtx->state == 1) { + for (i = 0; i < 11; i++) { + if ((gSaveContext.save.mapsVisited >> i) & 1) { + pauseCtx->worldMapPoints[i] = 1; + } + } + } else { + for (i = 9; i >= 0; i--) { + if ((gSaveContext.save.playerData.owlActivationFlags >> i) & 1) { + pauseCtx->worldMapPoints[i] = 1; + pauseCtx->unk_238[4] = i; + } + } + + if ((gSaveContext.save.playerData.owlActivationFlags >> 4) & 1) { + pauseCtx->unk_238[4] = 4; + } + } + + YREG(11) = -0x00C8; + YREG(12) = -0x3840; + YREG(13) = 0x2710; + YREG(14) = 0x2710; + YREG(15) = 0x2710; + YREG(16) = -0x00BE; + YREG(17) = -0x06D6; + YREG(18) = -0x0B90; + YREG(19) = 0x06E0; + YREG(20) = 0; + YREG(21) = -0x0622; + YREG(22) = -0x0C44; + YREG(23) = 0x0622; + YREG(24) = -0x0622; + YREG(25) = -0x005A; + YREG(26) = -0x3840; +} + +void KaleidoSetup_Update(GlobalContext* globalCtx) { + Input* input = CONTROLLER1(globalCtx); + MessageContext* msgCtx = &globalCtx->msgCtx; + Player* player = GET_PLAYER(globalCtx); + PauseContext* pauseCtx = &globalCtx->pauseCtx; + + if (CHECK_BTN_ALL(input->cur.button, BTN_R)) { + if (msgCtx && msgCtx) {} + } + + if ((pauseCtx->state == 0) && (pauseCtx->debugState == 0) && (globalCtx->gameOverCtx.state == GAMEOVER_INACTIVE)) { + if ((globalCtx->sceneLoadFlag == 0) && (globalCtx->unk_18B4A == 0)) { + if ((gSaveContext.save.cutscene < 0xFFF0) && (gSaveContext.nextCutsceneIndex < 0xFFF0)) { + if (!Play_InCsMode(globalCtx) || ((msgCtx->msgMode != 0) && (msgCtx->currentTextId == 0xFF))) { + if ((globalCtx->unk_1887C < 2) && (gSaveContext.unk_3F28 != 8) && (gSaveContext.unk_3F28 != 9)) { + if (!(gSaveContext.eventInf[1] & 0x80) && !(player->stateFlags1 & 0x20)) { + if (!(globalCtx->actorCtx.unk5 & 2) && !(globalCtx->actorCtx.unk5 & 4)) { + if ((globalCtx->actorCtx.unk268 == 0) && + CHECK_BTN_ALL(input->press.button, BTN_START)) { + gSaveContext.unk_3F26 = gSaveContext.unk_3F22; + pauseCtx->unk_2B9 = 0; + pauseCtx->state = 1; + func_800F4A10(globalCtx); + pauseCtx->mode = pauseCtx->pageIndex * 2 + 1; + func_801A3A7C(1); + } + + if (pauseCtx->state == 1) { + Game_SetFramerateDivisor(&globalCtx->state, 2); + if (ShrinkWindow_GetLetterboxTarget() != 0) { + ShrinkWindow_SetLetterboxTarget(0); + } + func_801A3AEC(1); + } + } + } + } + } + } + } + } +} + +void KaleidoSetup_Init(GlobalContext* globalCtx) { + PauseContext* pauseCtx = &globalCtx->pauseCtx; + s32 pad[2]; + + bzero(pauseCtx, sizeof(PauseContext)); + + pauseCtx->pageIndex = PAUSE_0; + + pauseCtx->unk_21C = 160.0f; + pauseCtx->unk_218 = 160.0f; + pauseCtx->unk_214 = 160.0f; + pauseCtx->unk_210 = 160.0f; + + pauseCtx->eye.x = -64.0f; + pauseCtx->unk_20C = 936.0f; + pauseCtx->unk_220 = -314.0f; + + pauseCtx->unk_238[PAUSE_1] = XREG(94) + 3; + + pauseCtx->unk_258 = 11; + pauseCtx->unk_25A = 0; + + pauseCtx->unk_25E[PAUSE_0] = 999; + pauseCtx->unk_25E[PAUSE_1] = XREG(94) + 3; + pauseCtx->unk_25E[PAUSE_2] = 999; + pauseCtx->unk_25E[PAUSE_3] = 999; + + pauseCtx->unk_268[PAUSE_0] = 0; + pauseCtx->unk_268[PAUSE_1] = XREG(94) + 3; + + pauseCtx->unk_284 = 2; + pauseCtx->unk_2A0 = -1; + pauseCtx->unk_2BA = 320; + pauseCtx->unk_2BC = 40; + pauseCtx->unk_29E = 100; + + View_Init(&pauseCtx->view, globalCtx->state.gfxCtx); +} + +void KaleidoSetup_Destroy(GlobalContext* globalCtx) { +} diff --git a/src/code/z_lib.c b/src/code/z_lib.c index d9300deda3..aaf4bc7d91 100644 --- a/src/code/z_lib.c +++ b/src/code/z_lib.c @@ -578,7 +578,7 @@ void Math_ApproachZeroF(f32* pValue, f32 scale, f32 maxStep) { *pValue = *pValue - f0; } -s32 Math_SmoothStepToS(s16* pValue, s16 target, s16 scale, s16 step, s16 minStep) { +s16 Math_SmoothStepToS(s16* pValue, s16 target, s16 scale, s16 step, s16 minStep) { s16 stepSize = 0; s16 diff = target - *pValue; diff --git a/src/code/z_lifemeter.c b/src/code/z_lifemeter.c index 386adeb13b..73ba326b56 100644 --- a/src/code/z_lifemeter.c +++ b/src/code/z_lifemeter.c @@ -1,14 +1,16 @@ +#include "prevent_bss_reordering.h" #include "global.h" #include "interface/parameter_static/parameter_static.h" +#include "prevent_bss_reordering.h" -static s16 sHeartsPrimColors[3][3] = { { 255, 70, 50 }, { 255, 190, 0 }, { 100, 100, 255 } }; -static s16 sHeartsEnvColors[3][3] = { { 50, 40, 60 }, { 255, 0, 0 }, { 0, 0, 255 } }; -static s16 sHeartsPrimFactors[3][3] = { { 0, 0, 0 }, { 0, 120, -50 }, { -155, 30, 205 } }; -static s16 sHeartsEnvFactors[3][3] = { { 0, 0, 0 }, { 205, -40, -60 }, { -50, -40, 195 } }; -static s16 sHeartsDDPrimColors[3][3] = { { 255, 255, 255 }, { 255, 190, 0 }, { 100, 100, 255 } }; -static s16 sHeartsDDEnvColors[3][3] = { { 200, 0, 0 }, { 255, 0, 0 }, { 0, 0, 255 } }; -static s16 sHeartsDDPrimFactors[3][3] = { { 0, 0, 0 }, { 0, -65, -255 }, { -155, -155, 0 } }; -static s16 sHeartsDDEnvFactors[3][3] = { { 0, 0, 0 }, { 55, 0, 0 }, { -200, 0, 255 } }; +s16 sHeartsPrimColors[3][3] = { { 255, 70, 50 }, { 255, 190, 0 }, { 100, 100, 255 } }; +s16 sHeartsEnvColors[3][3] = { { 50, 40, 60 }, { 255, 0, 0 }, { 0, 0, 255 } }; +s16 sHeartsPrimFactors[3][3] = { { 0, 0, 0 }, { 0, 120, -50 }, { -155, 30, 205 } }; +s16 sHeartsEnvFactors[3][3] = { { 0, 0, 0 }, { 205, -40, -60 }, { -50, -40, 195 } }; +s16 sHeartsDDPrimColors[3][3] = { { 255, 255, 255 }, { 255, 190, 0 }, { 100, 100, 255 } }; +s16 sHeartsDDEnvColors[3][3] = { { 200, 0, 0 }, { 255, 0, 0 }, { 0, 0, 255 } }; +s16 sHeartsDDPrimFactors[3][3] = { { 0, 0, 0 }, { 0, -65, -255 }, { -155, -155, 0 } }; +s16 sHeartsDDEnvFactors[3][3] = { { 0, 0, 0 }, { 55, 0, 0 }, { -200, 0, 255 } }; s16 sBeatingHeartsDDPrim[3]; s16 sBeatingHeartsDDEnv[3]; @@ -36,7 +38,7 @@ void LifeMeter_Init(GlobalContext* globalCtx) { interfaceCtx->unkTimer = 320; - interfaceCtx->health = gSaveContext.health; + interfaceCtx->health = gSaveContext.save.playerData.health; interfaceCtx->lifeColorChange = 0; interfaceCtx->lifeColorChangeDirection = 0; @@ -166,7 +168,7 @@ void LifeMeter_UpdateColors(GlobalContext* globalCtx) { } s32 LifeMeter_SaveInterfaceHealth(GlobalContext* globalCtx) { - gSaveContext.health = globalCtx->interfaceCtx.health; + gSaveContext.save.playerData.health = globalCtx->interfaceCtx.health; return 1; } @@ -176,8 +178,8 @@ s32 LifeMeter_IncreaseInterfaceHealth(GlobalContext* globalCtx) { interfaceCtx->unkTimer = 320; interfaceCtx->health += 0x10; - if (globalCtx->interfaceCtx.health >= gSaveContext.health) { - globalCtx->interfaceCtx.health = gSaveContext.health; + if (globalCtx->interfaceCtx.health >= gSaveContext.save.playerData.health) { + globalCtx->interfaceCtx.health = gSaveContext.save.playerData.health; return 1; } return 0; @@ -193,7 +195,7 @@ s32 LifeMeter_DecreaseInterfaceHealth(GlobalContext* globalCtx) { interfaceCtx->health -= 0x10; if (interfaceCtx->health <= 0) { interfaceCtx->health = 0; - globalCtx->damagePlayer(globalCtx, -(((void)0, gSaveContext.health) + 1)); + globalCtx->damagePlayer(globalCtx, -(((void)0, gSaveContext.save.playerData.health) + 1)); return 1; } } @@ -214,18 +216,18 @@ void LifeMeter_Draw(GlobalContext* globalCtx) { GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; Vtx* beatingHeartVtx = interfaceCtx->beatingHeartVtx; - s32 fractionHeartCount = gSaveContext.health % 0x10; - s16 healthCapacity = gSaveContext.healthCapacity / 0x10; - s16 fullHeartCount = gSaveContext.health / 0x10; + s32 fractionHeartCount = gSaveContext.save.playerData.health % 0x10; + s16 healthCapacity = gSaveContext.save.playerData.healthCapacity / 0x10; + s16 fullHeartCount = gSaveContext.save.playerData.health / 0x10; s32 pad2; f32 lifesize = interfaceCtx->lifeSizeChange * 0.1f; u32 curCombineModeSet = 0; TexturePtr temp = NULL; - s32 ddCount = gSaveContext.inventory.dungeonKeys[9] - 1; + s32 ddCount = gSaveContext.save.inventory.dungeonKeys[9] - 1; OPEN_DISPS(gfxCtx); - if ((gSaveContext.health % 0x10) == 0) { + if ((gSaveContext.save.playerData.health % 0x10) == 0) { fullHeartCount--; } offsetY = 0.0f; @@ -397,9 +399,8 @@ void LifeMeter_UpdateSizeAndBeep(GlobalContext* globalCtx) { if (interfaceCtx->lifeSizeChange <= 0) { interfaceCtx->lifeSizeChange = 0; interfaceCtx->lifeSizeChangeDirection = 0; - if (Player_InCsMode(&globalCtx->state) == 0 && (globalCtx->pauseCtx.state == 0) && - (globalCtx->pauseCtx.debugState == 0) && LifeMeter_IsCritical() && func_801690CC(globalCtx) == 0) { - // Player_InCsMode and func_801690CC : Check if in Cutscene + if (!Player_InCsMode(&globalCtx->state) && (globalCtx->pauseCtx.state == 0) && + (globalCtx->pauseCtx.debugState == 0) && LifeMeter_IsCritical() && !Play_InCsMode(globalCtx)) { play_sound(NA_SE_SY_HITPOINT_ALARM); } } @@ -415,19 +416,19 @@ void LifeMeter_UpdateSizeAndBeep(GlobalContext* globalCtx) { u32 LifeMeter_IsCritical(void) { s16 criticalThreshold; - if (gSaveContext.healthCapacity <= 80) { // healthCapacity <= 5 hearts? + if (gSaveContext.save.playerData.healthCapacity <= 80) { // healthCapacity <= 5 hearts? criticalThreshold = 16; - } else if (gSaveContext.healthCapacity <= 160) { // healthCapacity <= 10 hearts? + } else if (gSaveContext.save.playerData.healthCapacity <= 160) { // healthCapacity <= 10 hearts? criticalThreshold = 24; - } else if (gSaveContext.healthCapacity <= 240) { // healthCapacity <= 15 hearts? + } else if (gSaveContext.save.playerData.healthCapacity <= 240) { // healthCapacity <= 15 hearts? criticalThreshold = 32; } else { criticalThreshold = 44; } - if ((criticalThreshold >= gSaveContext.health) && (gSaveContext.health > 0)) { + if ((criticalThreshold >= gSaveContext.save.playerData.health) && (gSaveContext.save.playerData.health > 0)) { return true; } return false; diff --git a/src/code/z_lights.c b/src/code/z_lights.c index 615e11e690..5d47b41534 100644 --- a/src/code/z_lights.c +++ b/src/code/z_lights.c @@ -1,6 +1,8 @@ #include "global.h" #include "objects/gameplay_keep/gameplay_keep.h" +LightsBuffer sLightsBuffer; + void Lights_PointSetInfo(LightInfo* info, s16 x, s16 y, s16 z, u8 r, u8 g, u8 b, s16 radius, s32 type) { info->type = type; info->params.point.x = x; @@ -128,6 +130,7 @@ void Lights_BindPoint(Lights* lights, LightParams* params, GlobalContext* global Vec3f posF; Vec3f adjustedPos; u32 pad; + if (radiusF > 0) { posF.x = params->point.x; posF.y = params->point.y; @@ -213,7 +216,7 @@ void Lights_BindAll(Lights* lights, LightNode* listHead, Vec3f* refPos, GlobalCo } } -LightNode* Lights_FindBufSlot() { +LightNode* Lights_FindBufSlot(void) { LightNode* ret; if (sLightsBuffer.numOccupied >= LIGHTS_BUFFER_SIZE) { @@ -373,7 +376,7 @@ void Lights_GlowCheck(GlobalContext* globalCtx) { LightNode* light = globalCtx->lightCtx.listHead; while (light != NULL) { - LightPoint* params = (LightPoint*)&light->info->params; + LightPoint* params = &light->info->params.point; if (light->info->type == LIGHT_POINT_GLOW) { Vec3f pos; @@ -422,7 +425,7 @@ void Lights_DrawGlow(GlobalContext* globalCtx) { do { if (light->info->type == LIGHT_POINT_GLOW) { - params = (LightPoint*)&light->info->params; + params = &light->info->params.point; if (params->drawGlow) { f32 scale = SQ((f32)params->radius) * 2e-6f; diff --git a/src/code/z_message.c b/src/code/z_message.c index 0eceeee309..f41c713f60 100644 --- a/src/code/z_message.c +++ b/src/code/z_message.c @@ -1,14 +1,111 @@ #include "global.h" +#include "message_data_static.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80147520.s") +#if 0 -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80147564.s") +s16 D_801D02D8[15] = { + ACTOR_OCEFF_WIPE5, ACTOR_OCEFF_WIPE5, // Sonata of Awakening Effect, Sonata of Awakening Effect + ACTOR_OCEFF_WIPE5, ACTOR_OCEFF_WIPE5, // Sonata of Awakening Effect, Sonata of Awakening Effect + ACTOR_OCEFF_WIPE5, ACTOR_OCEFF_WIPE5, // Sonata of Awakening Effect, Sonata of Awakening Effect + ACTOR_OCEFF_WIPE, ACTOR_OCEFF_WIPE7, // Song of Time Effect, Song of Healing Effect + ACTOR_OCEFF_WIPE2, ACTOR_OCEFF_WIPE6, // Epona's Song Effect, Song of Soaring Effect + ACTOR_OCEFF_STORM, ACTOR_OCEFF_SPOT, // Song of Storms Effect II [?], Sun's Song Effect + ACTOR_OCEFF_WIPE, ACTOR_OCEFF_WIPE, // Song of Time Effect, Song of Time Effect + ACTOR_OCEFF_WIPE4 // Scarecrow's Song Effect +}; +s32 D_801D02F8[15] = { 0,1,2,3,4,0,1,0,0,0,0,0,1,1,0 }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80147624.s") +#endif -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80147734.s") +extern u16 D_801C6AB8[]; +extern u16 D_801C6B28[]; +extern s16 D_801D02D8[]; +extern s32 D_801D02F8[]; +extern s16 D_801F6B0C; +extern s16 D_801F6B0E; +extern s16 D_801F6B10; +extern s16 D_801F6B12; +extern s16 D_801F6B14; +extern s16 D_801F6B16; +extern s16 D_801F6B18; +extern s16 D_801F6B1A; +extern s16 D_801F6B1C; +extern s16 D_801F6B1E; +extern s16 D_801F6B20; +extern s16 D_801F6B22; +extern MessageTableEntry D_801C6B98[]; +extern MessageTableEntry D_801CFB08[]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_801477B4.s") +void func_80147520(void) { + D_801CFC98 = 0xFF; + D_801CFCA4[0] = D_801CFCA4[1] = D_801CFCA4[2] = D_801CFCA4[3] = D_801CFCA4[4] = D_801CFCA4[5] = D_801CFCA4[6] = + D_801CFCA4[7] = D_801CFCA4[8] = 0; +} + +void func_80147564(GlobalContext* globalCtx) { + MessageContext* msgCtx = &globalCtx->msgCtx; + + msgCtx->unk1204A[0] = 0xBD; + msgCtx->unk1204A[1] = 0xB8; + msgCtx->unk1204A[2] = 0xB3; + msgCtx->unk1204A[3] = 0xAE; + msgCtx->unk1204A[4] = 0xA9; + func_80147520(); + D_801F6B0C = 0x50; + D_801F6B10 = 0x96; + D_801F6B0E = 0xFF; + D_801F6B12 = 0xA; + D_801F6B16 = 0xA; + D_801F6B14 = 0xA; + D_801F6B18 = 0xFF; + D_801F6B1C = 0xFF; + D_801F6B1A = 0x32; + D_801F6B1E = 0xA; + D_801F6B22 = 0xA; + D_801F6B20 = 0xA; +} + +s32 Message_ShouldAdvance(GlobalContext* globalCtx) { + MessageContext* msgCtx = &globalCtx->msgCtx; + Input* controller = CONTROLLER1(globalCtx); + + if ((msgCtx->unk12020 == 0x10) || (msgCtx->unk12020 == 0x11)) { + if (CHECK_BTN_ALL(controller->press.button, BTN_A)) { + play_sound(NA_SE_SY_MESSAGE_PASS); + } + return CHECK_BTN_ALL(controller->press.button, BTN_A); + } else { + if (CHECK_BTN_ALL(controller->press.button, BTN_A) || CHECK_BTN_ALL(controller->press.button, BTN_B) || + CHECK_BTN_ALL(controller->press.button, BTN_CUP)) { + play_sound(NA_SE_SY_MESSAGE_PASS); + } + return CHECK_BTN_ALL(controller->press.button, BTN_A) || CHECK_BTN_ALL(controller->press.button, BTN_B) || + CHECK_BTN_ALL(controller->press.button, BTN_CUP); + } +} + +s32 Message_ShouldAdvanceSilent(GlobalContext* globalCtx) { + MessageContext* msgCtx = &globalCtx->msgCtx; + Input* controller = CONTROLLER1(globalCtx); + + if (msgCtx->unk12020 == 0x10 || msgCtx->unk12020 == 0x11) { + return CHECK_BTN_ALL(controller->press.button, BTN_A); + } else { + return CHECK_BTN_ALL(controller->press.button, BTN_A) || CHECK_BTN_ALL(controller->press.button, BTN_B) || + CHECK_BTN_ALL(controller->press.button, BTN_CUP); + } +} + +void func_801477B4(GlobalContext* globalCtx) { + MessageContext* msgCtx = &globalCtx->msgCtx; + + if (globalCtx->msgCtx.unk11F10 != 0) { + msgCtx->unk12023 = 2; + msgCtx->msgMode = 0x43; + msgCtx->unk12020 = 0; + play_sound(NA_SE_PL_WALK_GROUND - SFX_FLAG); + } +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80147818.s") @@ -16,9 +113,51 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80148558.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80148B98.s") +#ifdef NON_MATCHING +void func_80148B98(GlobalContext* globalCtx, u8 arg1) { + static s16 held = 0; + MessageContext* msgCtx = &globalCtx->msgCtx; + Input* curInput = CONTROLLER1(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80148CBC.s") + if ((curInput->rel.stick_y > 29) && held == 0) { + held = 1; + msgCtx->choiceIndex--; + if (msgCtx->choiceIndex > 128) { + msgCtx->choiceIndex = 0; + } else { + play_sound(NA_SE_SY_CURSOR); + } + return; + } else if ((curInput->rel.stick_y < -29) && held == 0) { + held = 1; + msgCtx->choiceIndex++; + if (msgCtx->choiceIndex > arg1) { + msgCtx->choiceIndex = arg1; + } else { + play_sound(NA_SE_SY_CURSOR); + } + return; + } else { + if (ABS_ALT(curInput->rel.stick_y) < 30) { + held = 0; + } + } +} +#else +#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80148B98.s") +#endif + +void func_80148CBC(GlobalContext* globalCtx, UNK_PTR puParm2, u8 arg2) { + MessageContext* msgCtx = &globalCtx->msgCtx; + + msgCtx->unk11FF4 = 0x30; + if (arg2 == 1) { + msgCtx->unk11FF6 = msgCtx->unk11FFE[1 + msgCtx->choiceIndex]; + } else { + msgCtx->unk11FF6 = msgCtx->unk11FFE[msgCtx->choiceIndex]; + } + func_80147818(globalCtx, puParm2, msgCtx->unk11FF4, msgCtx->unk11FF6); +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80148D64.s") @@ -34,7 +173,33 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80149C18.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80149EBC.s") +void Message_FindMessage(GlobalContext* globalCtx, u16 textId) { + MessageContext* msgCtx = &globalCtx->msgCtx; + Font* font = &msgCtx->font; + MessageTableEntry* msgEntry = msgCtx->messageEntryTable; + const char* segment = msgEntry->segment; + const char* foundSegment; + const char* nextSegment; + + while (msgEntry->textId != 0xFFFF) { + if (msgEntry->textId == textId) { + foundSegment = msgEntry->segment; + msgEntry++; + nextSegment = msgEntry->segment; + font->messageStart = foundSegment - segment; + font->messageEnd = nextSegment - foundSegment; + return; + } + msgEntry++; + } + + msgEntry = msgCtx->messageEntryTable; + foundSegment = msgEntry->segment; + msgEntry++; + nextSegment = msgEntry->segment; + font->messageStart = foundSegment - segment; + font->messageEnd = nextSegment - foundSegment; +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80149F74.s") @@ -44,9 +209,43 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_8014C70C.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_8014CC14.s") +void Message_LoadChar(GlobalContext* globalCtx, u16 codePointIndex, s32* offset, f32* arg3, s16 decodedBufPos) { + MessageContext* msgCtx = &globalCtx->msgCtx; + s32 temp1 = *offset; + f32 temp2 = *arg3; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_8014CCB4.s") + Font_LoadChar(globalCtx, codePointIndex, temp1); + msgCtx->decodedBuffer.wchar[decodedBufPos] = codePointIndex; + temp1 += FONT_CHAR_TEX_SIZE; + temp2 += (16.0f * msgCtx->unk12098); + *offset = temp1; + *arg3 = temp2; +} + +// Message_LoadRupees JPN ? +void func_8014CCB4(GlobalContext* globalCtx, s16* decodedBufPos, s32* offset, f32* arg3) { + MessageContext* msgCtx = &globalCtx->msgCtx; + s16 t = *decodedBufPos; + s32 k = *offset; + f32 f = *arg3; + + Font_LoadChar(globalCtx, 0x838B, k); // 0x838b = ル in JISX0213 + k += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.wchar[t] = 0x838B; + t += 1; + Font_LoadChar(globalCtx, 0x8373, k); // 0x8373 = ピ in JISX0213 + k += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.wchar[t] = 0x8373; + t += 1; + Font_LoadChar(globalCtx, 0x815C, k); // Ox815C = ― in JISX0213 + k += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.wchar[t] = 0x815C; + + f += 16.0f * msgCtx->unk12098 * 3.0f; + *decodedBufPos = t; + *offset = k; + *arg3 = f; +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_8014CDF0.s") @@ -54,7 +253,62 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_8014D304.s") +#ifdef NON_EQUIVALENT +extern u16* D_801D0188; +extern s16* D_801D0250; + +void func_8014D62C(GlobalContext* arg0, s32* arg1, f32* arg2, s16* arg3) { + f32 sp3C; + s16 temp_s0; + s16 temp_s1; + s16 temp_s1_2; + s16 temp_s6; + s32 temp_s2; + s32 temp_s2_2; + u16* temp_v0; + s16 phi_v0; + s16 phi_s0; + s16 phi_s1; + s32 phi_s2; + s16 phi_s1_2; + s32 phi_s2_2; + + temp_s1 = *arg3; + temp_s2 = *arg1; + sp3C = *arg2; + if ((func_8010A0A4(arg0) != 0) || (arg0->sceneNum == 0x4F)) { + phi_v0 = 0xA; + } else { + phi_v0 = arg0->pauseCtx.unk_238[4]; + } + temp_s6 = *(&D_801D0250 + (phi_v0 * 2)); + phi_s0 = 0; + phi_s1_2 = temp_s1; + phi_s2_2 = temp_s2; + if ((s32)temp_s6 > 0) { + phi_s1 = temp_s1; + phi_s2 = temp_s2; + do { + temp_v0 = (phi_v0 * 0x12) + &D_801D0188 + (phi_s0 * 2); + (arg0 + 0x4908 + (phi_s1 * 2))->decodedBuffer = (u16)*temp_v0; + Font_LoadChar(arg0, *temp_v0, phi_s2); + temp_s0 = phi_s0 + 1; + temp_s1_2 = phi_s1 + 1; + temp_s2_2 = phi_s2 + 0x80; + phi_s0 = temp_s0; + phi_s1 = temp_s1_2; + phi_s2 = temp_s2_2; + phi_s1_2 = temp_s1_2; + phi_s2_2 = temp_s2_2; + } while ((s32)temp_s0 < (s32)temp_s6); + } + *arg3 = phi_s1_2 - 1; + *arg1 = phi_s2_2; + *arg2 = sp3C + ((f32)(temp_s6 - 1) * (16.0f * arg0->msgCtx.unk12098)); +} +#else #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_8014D62C.s") +#endif #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_8014D7B4.s") @@ -64,46 +318,239 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_801514B0.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/Message_StartTextbox.s") +void Message_StartTextbox(GlobalContext* globalCtx, u16 textId, Actor* Actor) { + MessageContext* msgCtx = &globalCtx->msgCtx; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80151938.s") + msgCtx->ocarinaAction = 0xFFFF; + func_80150D08(globalCtx, textId); + msgCtx->unkActor = Actor; + msgCtx->msgMode = 1; + msgCtx->unk12023 = 0; + msgCtx->unk12024 = 0; + globalCtx->msgCtx.ocarinaMode = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80151A68.s") +void func_80151938(GlobalContext* globalCtx, u16 textId) { + MessageContext* msgCtx = &globalCtx->msgCtx; + InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80151BB4.s") + msgCtx->unk11F10 = 0; + func_80150D08(globalCtx, textId); + func_80150A84(globalCtx); + msgCtx->msgMode = 5; + msgCtx->unk12023 = 8; + msgCtx->unk12024 = 0; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80151C9C.s") + if (interfaceCtx->unk_222 == 0) { + if (textId != 0x1B93) { + func_8011552C(globalCtx, 0x10); + } else if (textId != 0xF8) { + func_8011552C(globalCtx, 6); + } + } + msgCtx->unk1203C = msgCtx->unk1203A; + + if (globalCtx->pauseCtx.unk_1F0 != 0) { + msgCtx->unk12004 = 0x22; + msgCtx->unk12006 = 0x15E; + func_80149C18(globalCtx); + msgCtx->unk12023 = 1; + } +} + +void func_80151A68(GlobalContext* globalCtx, u16 textId) { + MessageContext* msgCtx = &globalCtx->msgCtx; + + msgCtx->unk11F10 = 0; + func_80150D08(globalCtx, textId); + func_80150A84(globalCtx); + func_8015B198(globalCtx); + msgCtx->msgMode = 0x45; + msgCtx->unk12024 = 0; + msgCtx->unk1203C = msgCtx->unk1203A = msgCtx->unk1201E = 0; + msgCtx->unk12023 = 0x1E; + + // Day/Dawn/Night.. Messages + if ((msgCtx->currentTextId >= 0x1BB2) && (msgCtx->currentTextId < 0x1BB7)) { + XREG(74) = 0x6A; + XREG(75) = 0; + XREG(77) = 0x58; + XREG(76) = 0x44; + } else { + XREG(74) = 0x42; + XREG(75) = 0x1E; + XREG(77) = 0x3C; + XREG(76) = 0x1C; + msgCtx->unk11F1A[0] = msgCtx->unk11F1A[1] = msgCtx->unk11F1A[2] = 0; + Interface_ChangeAlpha(1); + } +} + +void func_80151BB4(GlobalContext* globalCtx, u8 arg1) { + MessageContext* msgCtx = &globalCtx->msgCtx; + u8 temp = arg1; + + if (CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { + if ((gSaveContext.save.weekEventReg[D_801C6B28[arg1] >> 8] & (u8)D_801C6B28[arg1]) == 0) { + msgCtx->unk120B2[msgCtx->unk120B1] = temp; + msgCtx->unk120B1++; + } + } else if (arg1 >= 20) { + if ((gSaveContext.save.weekEventReg[D_801C6B28[arg1] >> 8] & (u8)D_801C6B28[arg1]) == 0) { + msgCtx->unk120B2[msgCtx->unk120B1] = temp; + msgCtx->unk120B1++; + } + } +} + +u32 func_80151C9C(GlobalContext* globalCtx) { + MessageContext* msgCtx = &globalCtx->msgCtx; + u8 flag; + + while (true) { + if (msgCtx->unk120B1 == 0) { + return 0; + } + msgCtx->unk120B1--; + + if ((gSaveContext.save.weekEventReg[D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]] >> 8] & + (u8)D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]]) == 0) { + flag = gSaveContext.save.weekEventReg[D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]] >> 8]; + gSaveContext.save.weekEventReg[D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]] >> 8] = + flag | (u8)D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]]; + if ((D_801C6AB8[msgCtx->unk120B2[msgCtx->unk120B1]] != 0) && CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { + func_80151938(globalCtx, D_801C6AB8[msgCtx->unk120B2[msgCtx->unk120B1]]); + play_sound(NA_SE_SY_SCHEDULE_WRITE); + return 1; + } + } + } +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80151DA4.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80152434.s") +void func_80152434(GlobalContext* globalCtx, u16 arg2) { + globalCtx->msgCtx.unk12046 = 0; + func_80151DA4(globalCtx, arg2); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80152464.s") +void func_80152464(GlobalContext* globalCtx, u16 arg1) { + globalCtx->msgCtx.unk12046 = 1; + func_80151DA4(globalCtx, arg1); +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/Message_GetState.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_8015268C.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80152C64.s") +void func_80152C64(View* view) { + SET_FULLSCREEN_VIEWPORT(view); + func_8013FBC8(view); +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80152CAC.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80152EC0.s") +// Spawn song effect? +void func_80152EC0(GlobalContext* globalCtx) { + MessageContext* msgCtx = &globalCtx->msgCtx; + Player* player = GET_PLAYER(globalCtx); + + if (1) {} + if ((msgCtx->songPlayed < 0x17) && (msgCtx->songPlayed != 0xE) && + ((msgCtx->ocarinaAction < 0x43) || (msgCtx->ocarinaAction >= 0x47))) { + msgCtx->unk120B0 = 1; + if (msgCtx->songPlayed != 0x16) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, D_801D02D8[msgCtx->songPlayed], player->actor.world.pos.x, + player->actor.world.pos.y, player->actor.world.pos.z, 0, 0, 0, D_801D02F8[msgCtx->songPlayed]); + return; + } + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_OCEFF_WIPE4, player->actor.world.pos.x, + player->actor.world.pos.y, player->actor.world.pos.z, 0, 0, 0, 0); + } +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80152FB8.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80153750.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80153E7C.s") +void func_80153E7C(GlobalContext* globalCtx, void* arg1) { + if ((gSaveContext.options.language == 0) && (globalCtx->msgCtx.unk12090 == 0)) { + func_8014ADBC(globalCtx, arg1); + return; + } + if (globalCtx->msgCtx.unk12090 != 0) { + func_8015E7EC(globalCtx, arg1); + return; + } + func_8015966C(globalCtx, arg1, 0); +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80153EF0.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_801541D4.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80156758.s") +void func_80156758(GlobalContext* globalCtx) { + Gfx* nextDisplayList; + Gfx* polyOpa; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + + OPEN_DISPS(gfxCtx); + polyOpa = POLY_OPA_DISP; + nextDisplayList = Graph_GfxPlusOne(polyOpa); + gSPDisplayList(OVERLAY_DISP++, nextDisplayList); + + if ((globalCtx->msgCtx.currentTextId != 0x5E6) || !Play_InCsMode(globalCtx)) { + func_801541D4(globalCtx, &nextDisplayList); + } + + gSPEndDisplayList(nextDisplayList++); + Graph_BranchDlist(polyOpa, nextDisplayList); + POLY_OPA_DISP = nextDisplayList; + CLOSE_DISPS(gfxCtx); +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_8015680C.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_801586A4.s") +void func_801586A4(GlobalContext* globalCtx) { + globalCtx->msgCtx.messageEntryTableNes = D_801C6B98; + globalCtx->msgCtx.messageTableStaff = D_801CFB08; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/Message_Init.s") +void Message_Init(GlobalContext* globalCtx) { + Font* font; + MessageContext* messageCtx = &globalCtx->msgCtx; + + func_801586A4(globalCtx); + globalCtx->msgCtx.ocarinaMode = 0; + messageCtx->msgMode = 0; + messageCtx->unk11F10 = 0; + messageCtx->currentTextId = 0; + messageCtx->unk12020 = 0; + messageCtx->choiceIndex = 0; + messageCtx->ocarinaAction = messageCtx->unk11FF2 = 0; + messageCtx->unk1201E = 0xFF; + View_Init(&messageCtx->view, globalCtx->state.gfxCtx); + messageCtx->unk11EF8 = THA_AllocEndAlign16(&globalCtx->state.heap, 0x13C00); + font = &globalCtx->msgCtx.font; + Font_LoadOrderedFont(&globalCtx->msgCtx.font); + font->unk_11D88 = 0; + messageCtx->unk12090 = messageCtx->unk12092 = 0; + messageCtx->unk12094 = 0; + messageCtx->unk1209C = 0; + messageCtx->unk120A0 = 0; + messageCtx->unk12068 = 0x34; + messageCtx->unk1206A = 0x24; + messageCtx->unk120B0 = 0; + messageCtx->unk120BE = 0; + messageCtx->unk120C0 = 0; + messageCtx->unk120C2 = 0; + messageCtx->unk120C4 = 0; + messageCtx->unk120C8 = 0; + messageCtx->unk120CA = 0; + messageCtx->unk120CC = 0; + messageCtx->unk120CE = 0; + messageCtx->unk120D0 = 0; + messageCtx->unk120D2 = 0; + messageCtx->unk120D4 = 0; + messageCtx->unk120D6 = 0; +} diff --git a/src/code/z_message_nes.c b/src/code/z_message_nes.c index 4767810fb9..1de839d682 100644 --- a/src/code/z_message_nes.c +++ b/src/code/z_message_nes.c @@ -1,18 +1,280 @@ #include "global.h" +#include "message_data_static.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message_nes/func_801588D0.s") +#if 0 -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message_nes/func_80158988.s") +//fontWidth +extern f32 D_801D0470[159]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message_nes/func_80158A24.s") +//rupeesTextLocalization +u8 D_801D06F0[4][8] = { { "rupee(s)" }, //EN + { "rubin(e)" }, //DE + { "rubis" }, //FR + { "rupia(s)" } //SPA + }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message_nes/func_80158C04.s") +// rupeesTextLength +u8 D_801D0710[4] = {8,8,5,8}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message_nes/func_80158D98.s") +//TextArea +char D_801D0714[11][16] = { + "Great Bay Coast", + "Zora Cape", + "Snowhead", + "Mountain Village", + "Clock Town", + "Milk Road", + "Woodfall", + "Southern Swamp", + "Ikana Canyon", + "Stone Tower", + "Entrance" + }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message_nes/func_80158FB0.s") +//TextAreaLength +s16 D_801D07C4[11] = {15,9,8,16,10,9,8,14,12,11,8}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message_nes/func_8015926C.s") +#endif + +extern f32 D_801D0470[159]; +extern u8 D_801D06F0[4][8]; +extern u8 D_801D0710[4]; +extern u8 D_801D0714[11][16]; +extern s16 D_801D07C4[11]; + +void Message_FindMessageNES(GlobalContext* globalCtx, u16 textId) { + MessageContext* msgCtx = &globalCtx->msgCtx; + Font* font = &msgCtx->font; + MessageTableEntry* msgEntry = msgCtx->messageEntryTableNes; + const char* segment = msgEntry->segment; + const char* foundSegment; + const char* nextSegment; + + while (msgEntry->textId != 0xFFFF) { + if (msgEntry->textId == textId) { + foundSegment = msgEntry->segment; + msgEntry++; + nextSegment = msgEntry->segment; + font->messageStart = foundSegment - segment; + font->messageEnd = nextSegment - foundSegment; + return; + } + msgEntry++; + } + + msgEntry = msgCtx->messageEntryTableNes; + foundSegment = msgEntry->segment; + msgEntry++; + nextSegment = msgEntry->segment; + font->messageStart = foundSegment - segment; + font->messageEnd = nextSegment - foundSegment; +} + +void Message_LoadCharNES(GlobalContext* globalCtx, u8 codePointIndex, s32* offset, f32* arg3, s16 decodedBufPos) { + MessageContext* msgCtx = &globalCtx->msgCtx; + s32 temp1 = *offset; + f32 temp2 = *arg3; + + Font_LoadCharNES(globalCtx, codePointIndex, temp1); + msgCtx->decodedBuffer.schar[decodedBufPos] = codePointIndex; + temp1 += FONT_CHAR_TEX_SIZE; + temp2 += (16.0f * msgCtx->unk12098); + *offset = temp1; + *arg3 = temp2; +} + +void Message_LoadPluralRupeesNES(GlobalContext* globalCtx, s16* decodedBufPos, s32* offset, f32* arg3) { + MessageContext* msgCtx = &globalCtx->msgCtx; + s16 p = *decodedBufPos; + s32 o = *offset; + f32 f = *arg3; + + msgCtx->decodedBuffer.schar[p] = 0x20; + p++; + Font_LoadCharNES(globalCtx, 'R', o); + o += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[p] = 'R'; + p++; + Font_LoadCharNES(globalCtx, 'u', o); + o += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[p] = 'u'; + p++; + Font_LoadCharNES(globalCtx, 'p', o); + o += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[p] = 'p'; + p++; + Font_LoadCharNES(globalCtx, 'e', o); + o += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[p] = 'e'; + p++; + Font_LoadCharNES(globalCtx, 'e', o); + o += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[p] = 'e'; + p++; + Font_LoadCharNES(globalCtx, 's', o); + o += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[p] = 's'; + + f += 16.0f * msgCtx->unk12098 * 6.0f; + *decodedBufPos = p; + *offset = o; + *arg3 = f; +} + +void Message_LoadLocalizedRupeesNES(GlobalContext* globalCtx, s16* decodedBufPos, s32* offset, f32* arg3) { + MessageContext* msgCtx = &globalCtx->msgCtx; + s16 p = *decodedBufPos; + s32 o = *offset; + f32 f = *arg3; + u8 j; + + msgCtx->decodedBuffer.schar[p] = ' '; + p++; + + for (j = 0; j < D_801D0710[gSaveContext.options.language - 1]; j++) { + Font_LoadCharNES(globalCtx, D_801D06F0[gSaveContext.options.language - 1][j], o); + msgCtx->decodedBuffer.schar[p] = D_801D06F0[gSaveContext.options.language - 1][j]; + o += FONT_CHAR_TEX_SIZE; + p++; + } + + p--; + f += 16.0f * msgCtx->unk12098 * (D_801D0710[gSaveContext.options.language - 1] + 1); + *decodedBufPos = p; + *offset = o; + *arg3 = f; +} + +void Message_LoadRupeesNES(GlobalContext* globalCtx, s16* decodedBufPos, s32* offset, f32* arg3, s16 singular) { + MessageContext* msgCtx = &globalCtx->msgCtx; + s16 p = *decodedBufPos; + s32 o = *offset; + f32 f = *arg3; + + msgCtx->decodedBuffer.schar[p] = ' '; + p++; + Font_LoadCharNES(globalCtx, 'R', o); + o += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[p] = 'R'; + p++; + Font_LoadCharNES(globalCtx, 'u', o); + o += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[p] = 'u'; + p++; + Font_LoadCharNES(globalCtx, 'p', o); + o += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[p] = 'p'; + p++; + Font_LoadCharNES(globalCtx, 'e', o); + o += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[p] = 'e'; + p++; + Font_LoadCharNES(globalCtx, 'e', o); + o += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[p] = 'e'; + + if (singular != 1) { + p++; + Font_LoadCharNES(globalCtx, 's', o); + o += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[p] = 's'; + f += 16.0f * msgCtx->unk12098 * 6.0f; + } else { + f += 16.0f * msgCtx->unk12098 * 5.0f; + } + + *decodedBufPos = p; + *offset = o; + *arg3 = f; +} + +void Message_LoadTimeNES(GlobalContext* globalCtx, u8 arg1, s32* offset, f32* arg3, s16* decodedBufPos) { + MessageContext* msgCtx = &globalCtx->msgCtx; + s16 p = *decodedBufPos; + s32 o = *offset; + f32 f = *arg3; + u32 dayTime; + s16 digits[4]; + f32 timeInMinutes; + s32 day; + s16 i; + + if (arg1 == 0xCF) { + day = gSaveContext.save.day; + dayTime = 0x40000 - ((day % 5) << 16) - (u16)(-0x4000 + gSaveContext.save.time); + } else { + dayTime = 0x10000 - (u16)(-0x4000 + gSaveContext.save.time); + } + timeInMinutes = TIME_TO_MINUTES_F(dayTime); + + digits[0] = 0; + digits[1] = (timeInMinutes / 60.0f); + while (digits[1] >= 10) { + digits[0]++; + digits[1] -= 10; + } + + digits[2] = 0; + digits[3] = (s32)timeInMinutes % 60; + while (digits[3] >= 10) { + digits[2]++; + digits[3] -= 10; + } + + for (i = 0; i < 4; i++) { + Font_LoadCharNES(globalCtx, digits[i] + '0', o); + o += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[p] = digits[i] + '0'; + p++; + if (i == 1) { + Font_LoadCharNES(globalCtx, ':', o); + o += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[p] = ':'; + p++; + } + } + + f += 5.0f * (16.0f * msgCtx->unk12098); + *decodedBufPos = p - 1; + *offset = o; + *arg3 = f; +} + +void Message_LoadAreaTextNES(GlobalContext* globalCtx, s32* offset, f32* arg2, s16* decodedBufPos) { + MessageContext* msgCtx = &globalCtx->msgCtx; + s16 p = *decodedBufPos; + s32 o = *offset; + f32 f = *arg2; + s16 i; + u8 currentChar; + s16 currentArea; + s16 stringLimit; + + if ((func_8010A0A4(globalCtx) != 0) || (globalCtx->sceneNum == SCENE_SECOM)) { + currentArea = 10; + } else { + currentArea = globalCtx->pauseCtx.unk_238[4]; + } + stringLimit = D_801D07C4[currentArea]; + + for (i = 0; i < stringLimit; i++) { + msgCtx->decodedBuffer.schar[p] = D_801D0714[currentArea][i]; + currentChar = msgCtx->decodedBuffer.schar[p]; + if (currentChar != ' ') { + Font_LoadCharNES(globalCtx, D_801D0714[currentArea][i], o); + o += FONT_CHAR_TEX_SIZE; + } + currentChar = msgCtx->decodedBuffer.schar[p]; + p++; + f += (D_801D0470[currentChar - ' '] * msgCtx->unk12098); + } + + p--; + f += (stringLimit - 1) * (16.0f * msgCtx->unk12098); + *decodedBufPos = p; + *offset = o; + *arg2 = f; +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_message_nes/func_80159438.s") diff --git a/src/code/z_message_staff.c b/src/code/z_message_staff.c index 2dd698690f..6620f88d59 100644 --- a/src/code/z_message_staff.c +++ b/src/code/z_message_staff.c @@ -1,6 +1,27 @@ #include "global.h" +#include "message_data_static.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message_staff/func_8015E750.s") +void Message_FindCreditsMessage(GlobalContext* globalCtx, u16 textId) { + MessageContext* msgCtx = &globalCtx->msgCtx; + Font* font = &msgCtx->font; + MessageTableEntry* msgEntry = msgCtx->messageTableStaff; + const char* segment = msgEntry->segment; + const char* foundSegment; + const char* nextSegment; + + while (msgEntry->textId != 0xFFFF) { + if (msgEntry->textId == textId) { + foundSegment = msgEntry->segment; + font->charBuf[font->unk_11D88][0] = msgEntry->typePos; + msgEntry++; + nextSegment = msgEntry->segment; + font->messageStart = foundSegment - segment; + font->messageEnd = nextSegment - foundSegment; + return; + } + msgEntry++; + } +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_message_staff/func_8015E7EC.s") diff --git a/src/code/z_play.c b/src/code/z_play.c index b5c2b15c89..aa360934e3 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -58,7 +58,9 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_Update.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_801690CC.s") +s32 Play_InCsMode(GlobalContext* globalCtx) { + return (globalCtx->csCtx.state != 0) || Player_InCsMode(&globalCtx->state); +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169100.s") @@ -158,8 +160,8 @@ void Play_SaveCycleSceneFlags(GameState* gameState) { cycleSceneFlags = &gSaveContext.cycleSceneFlags[Play_GetOriginalSceneNumber(globalCtx->sceneNum)]; cycleSceneFlags->chest = globalCtx->actorCtx.flags.chest; - cycleSceneFlags->swch0 = globalCtx->actorCtx.flags.switches[0]; - cycleSceneFlags->swch1 = globalCtx->actorCtx.flags.switches[1]; + cycleSceneFlags->switch0 = globalCtx->actorCtx.flags.switches[0]; + cycleSceneFlags->switch1 = globalCtx->actorCtx.flags.switches[1]; if (globalCtx->sceneNum == SCENE_INISIE_R) { // Inverted Stone Tower Temple cycleSceneFlags = &gSaveContext.cycleSceneFlags[globalCtx->sceneNum]; @@ -178,7 +180,7 @@ void Play_SetRespawnData(GameState* gameState, s32 respawnMode, u16 entranceInde gSaveContext.respawn[respawnMode].pos = *pos; gSaveContext.respawn[respawnMode].yaw = yaw; gSaveContext.respawn[respawnMode].playerParams = playerParams; - gSaveContext.respawn[respawnMode].tempSwchFlags = globalCtx->actorCtx.flags.switches[2]; + gSaveContext.respawn[respawnMode].tempSwitchFlags = globalCtx->actorCtx.flags.switches[2]; gSaveContext.respawn[respawnMode].unk_18 = globalCtx->actorCtx.flags.collectible[1]; gSaveContext.respawn[respawnMode].tempCollectFlags = globalCtx->actorCtx.flags.collectible[2]; } @@ -188,7 +190,7 @@ void Play_SetupRespawnPoint(GameState* gameState, s32 respawnMode, s32 playerPar Player* player = GET_PLAYER(globalCtx); if (globalCtx->sceneNum != SCENE_KAKUSIANA) { // Grottos - Play_SetRespawnData(&globalCtx->state, respawnMode, (u16)((void)0, gSaveContext.entranceIndex), + Play_SetRespawnData(&globalCtx->state, respawnMode, (u16)((void)0, gSaveContext.save.entranceIndex), globalCtx->roomCtx.currRoom.num, playerParams, &player->actor.world.pos, player->actor.shape.rot.y); } @@ -207,10 +209,10 @@ void func_80169ECC(GlobalContext* globalCtx) { void func_80169EFC(GameState* gameState) { GlobalContext* globalCtx = (GlobalContext*)gameState; - gSaveContext.respawn[0].tempSwchFlags = globalCtx->actorCtx.flags.switches[2]; - gSaveContext.respawn[0].unk_18 = globalCtx->actorCtx.flags.collectible[1]; - gSaveContext.respawn[0].tempCollectFlags = globalCtx->actorCtx.flags.collectible[2]; - globalCtx->nextEntranceIndex = gSaveContext.respawn[0].entranceIndex; + gSaveContext.respawn[RESTART_MODE_DOWN].tempSwitchFlags = globalCtx->actorCtx.flags.switches[2]; + gSaveContext.respawn[RESTART_MODE_DOWN].unk_18 = globalCtx->actorCtx.flags.collectible[1]; + gSaveContext.respawn[RESTART_MODE_DOWN].tempCollectFlags = globalCtx->actorCtx.flags.collectible[2]; + globalCtx->nextEntranceIndex = gSaveContext.respawn[RESTART_MODE_DOWN].entranceIndex; gSaveContext.respawnFlag = 1; func_80169ECC(globalCtx); globalCtx->sceneLoadFlag = 0x14; @@ -222,7 +224,7 @@ void func_80169EFC(GameState* gameState) { void func_80169F78(GameState* gameState) { GlobalContext* globalCtx = (GlobalContext*)gameState; - globalCtx->nextEntranceIndex = gSaveContext.respawn[2].entranceIndex; + globalCtx->nextEntranceIndex = gSaveContext.respawn[RESTART_MODE_TOP].entranceIndex; gSaveContext.respawnFlag = -1; func_80169ECC(globalCtx); globalCtx->sceneLoadFlag = 0x14; diff --git a/src/code/z_quake.c b/src/code/z_quake.c index ee4fa3a6d6..d57dc8e54b 100644 --- a/src/code/z_quake.c +++ b/src/code/z_quake.c @@ -638,7 +638,7 @@ void Distortion_Update(void) { sDistortionContext.countdown = 2; player = GET_PLAYER(globalCtx); - if (&player->actor != NULL) { + if (player != NULL) { Actor_GetWorldPosShapeRot(&playerPosRot, &player->actor); } diff --git a/src/code/z_rcp.c b/src/code/z_rcp.c index 09e026e8fb..f4ffd43c18 100644 --- a/src/code/z_rcp.c +++ b/src/code/z_rcp.c @@ -1222,8 +1222,6 @@ Gfx* Gfx_PrimColor(GraphicsContext* gfxCtx, s32 lodfrac, s32 r, s32 g, s32 b, s3 return displayList; } -#ifdef NON_MATCHING -// Regalloc differences, minor reorderings void func_8012CF0C(GraphicsContext* gfxCtx, s32 clearFb, s32 clearZb, u8 r, u8 g, u8 b) { Gfx* masterGfx; void* zbuffer; @@ -1269,7 +1267,7 @@ void func_8012CF0C(GraphicsContext* gfxCtx, s32 clearFb, s32 clearZb, u8 r, u8 g gDPSetRenderMode(&masterGfx[3], G_RM_NOOP, G_RM_NOOP2); gDPSetFillColor(&masterGfx[4], (GPACK_RGBA5551(255, 255, 240, 0) << 16) | GPACK_RGBA5551(255, 255, 240, 0)); gSPDisplayList(&masterGfx[5], D_0E000000.clearFillRect); - gDPSetColorImage(&masterGfx[6], G_IM_FMT_RGBA, G_IM_SIZ_16b, D_801FBBCC, zbuffer); + gDPSetColorImage(&masterGfx[6], G_IM_FMT_RGBA, G_IM_SIZ_16b, D_801FBBCC, &D_0F000000); gSPEndDisplayList(&masterGfx[7]); } @@ -1328,9 +1326,6 @@ void func_8012CF0C(GraphicsContext* gfxCtx, s32 clearFb, s32 clearZb, u8 r, u8 g CLOSE_DISPS(gfxCtx); } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_rcp/func_8012CF0C.s") -#endif void func_8012D374(GraphicsContext* gfxCtx, u8 r, u8 g, u8 b) { if ((R_PAUSE_MENU_MODE < 2) && (D_801F6D10 < 2)) { diff --git a/src/code/z_scene.c b/src/code/z_scene.c index 6ef6a60913..b039907028 100644 --- a/src/code/z_scene.c +++ b/src/code/z_scene.c @@ -151,7 +151,7 @@ void Scene_HeaderCmdSpawnList(GlobalContext* globalCtx, SceneCmd* cmd) { globalCtx->linkActorEntry = (ActorEntry*)Lib_SegmentedToVirtual(cmd->spawnList.segment) + globalCtx->setupEntranceList[globalCtx->curSpawn].spawn; if ((globalCtx->linkActorEntry->params & 0x0F00) >> 8 == 0x0C || - (gSaveContext.respawnFlag == 0x02 && gSaveContext.respawn[1].playerParams == 0x0CFF)) { + (gSaveContext.respawnFlag == 0x02 && gSaveContext.respawn[RESTART_MODE_RETURN].playerParams == 0x0CFF)) { // Skull Kid Object Object_Spawn(&globalCtx->objectCtx, OBJECT_STK); return; @@ -161,7 +161,7 @@ void Scene_HeaderCmdSpawnList(GlobalContext* globalCtx, SceneCmd* cmd) { nextObject = globalCtx2->objectCtx.status[globalCtx2->objectCtx.num].segment; globalCtx->objectCtx.num = loadedCount; globalCtx->objectCtx.spawnedObjectCount = loadedCount; - playerForm = gSaveContext.playerForm; + playerForm = gSaveContext.save.playerForm; playerObjectId = gLinkFormObjectIndexes[playerForm]; gActorOverlayTable[0].initInfo->objectId = playerObjectId; Object_Spawn(&globalCtx->objectCtx, playerObjectId); @@ -341,7 +341,7 @@ void Scene_HeaderCmdEnvLightSettings(GlobalContext* globalCtx, SceneCmd* cmd) { * Loads different texture files for each region of the world. * These later are stored in segment 0x06, and used in maps. */ -s32 Scene_LoadAreaTextures(GlobalContext* globalCtx, s32 fileIndex) { +void Scene_LoadAreaTextures(GlobalContext* globalCtx, s32 fileIndex) { static RomFile sceneTextureFiles[9] = { { 0, 0 }, // Default { SEGMENT_ROM_START(scene_texture_01), SEGMENT_ROM_END(scene_texture_01) }, @@ -358,10 +358,8 @@ s32 Scene_LoadAreaTextures(GlobalContext* globalCtx, s32 fileIndex) { if (size != 0) { globalCtx->roomCtx.unk74 = THA_AllocEndAlign16(&globalCtx->state.heap, size); - return DmaMgr_SendRequest0(globalCtx->roomCtx.unk74, vromStart, size); + DmaMgr_SendRequest0(globalCtx->roomCtx.unk74, vromStart, size); } - - // UB: Undefined behaviour to not have a return statement here, but it breaks matching to add one. } // SceneTableEntry Header Command 0x11: Skybox Settings @@ -383,7 +381,7 @@ void Scene_HeaderCmdTimeSettings(GlobalContext* globalCtx, SceneCmd* cmd) { u32 dayTime; if (cmd->timeSettings.hour != 0xFF && cmd->timeSettings.min != 0xFF) { - gSaveContext.environmentTime = gSaveContext.time = + gSaveContext.environmentTime = gSaveContext.save.time = (u16)(((cmd->timeSettings.hour + (cmd->timeSettings.min / 60.0f)) * 60.0f) / 0.021972656f); } @@ -393,7 +391,7 @@ void Scene_HeaderCmdTimeSettings(GlobalContext* globalCtx, SceneCmd* cmd) { globalCtx->envCtx.timeIncrement = 0; } - if ((gSaveContext.inventory.items[SLOT_OCARINA] == ITEM_NONE) && (globalCtx->envCtx.timeIncrement != 0)) { + if ((gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) && (globalCtx->envCtx.timeIncrement != 0)) { globalCtx->envCtx.timeIncrement = 5; } @@ -401,15 +399,15 @@ void Scene_HeaderCmdTimeSettings(GlobalContext* globalCtx, SceneCmd* cmd) { REG(15) = globalCtx->envCtx.timeIncrement; } - dayTime = gSaveContext.time; + dayTime = gSaveContext.save.time; globalCtx->envCtx.unk_4 = -(Math_SinS(dayTime - 0x8000) * 120.0f) * 25.0f; - dayTime = gSaveContext.time; + dayTime = gSaveContext.save.time; globalCtx->envCtx.unk_8 = (Math_CosS(dayTime - 0x8000) * 120.0f) * 25.0f; - dayTime = gSaveContext.time; + dayTime = gSaveContext.save.time; globalCtx->envCtx.unk_C = (Math_CosS(dayTime - 0x8000) * 20.0f) * 25.0f; - if (globalCtx->envCtx.timeIncrement == 0 && gSaveContext.cutscene < 0xFFF0) { - gSaveContext.environmentTime = gSaveContext.time; + if (globalCtx->envCtx.timeIncrement == 0 && gSaveContext.save.cutscene < 0xFFF0) { + gSaveContext.environmentTime = gSaveContext.save.time; if (gSaveContext.environmentTime >= CLOCK_TIME(4, 0) && gSaveContext.environmentTime < CLOCK_TIME(6, 30)) { gSaveContext.environmentTime = CLOCK_TIME(5, 0); @@ -527,7 +525,7 @@ void Scene_HeaderCmdSetAreaVisitedFlag(GlobalContext* globalCtx, SceneCmd* cmd) } if (i < ARRAY_COUNT(gScenesPerRegion)) { - gSaveContext.mapsVisited = (gBitFlags[i] | gSaveContext.mapsVisited) | gSaveContext.mapsVisited; + gSaveContext.save.mapsVisited = (gBitFlags[i] | gSaveContext.save.mapsVisited) | gSaveContext.save.mapsVisited; } } @@ -610,5 +608,5 @@ u16 Entrance_CreateIndex(s32 sceneIndex, s32 spawnIndex, s32 sceneSetup) { * Creates an entrance index from the current entrance index with the given spawn index. */ u16 Entrance_CreateIndexFromSpawn(s32 spawnIndex) { - return Entrance_CreateIndex(gSaveContext.entranceIndex >> 9, spawnIndex, 0); + return Entrance_CreateIndex(gSaveContext.save.entranceIndex >> 9, spawnIndex, 0); } diff --git a/src/code/z_scene_proc.c b/src/code/z_scene_proc.c index f7f71a2dd7..8f369008f7 100644 --- a/src/code/z_scene_proc.c +++ b/src/code/z_scene_proc.c @@ -234,7 +234,7 @@ f32 Scene_LagrangeInterp(s32 n, f32 x[], f32 fx[], f32 xp) { s32 i; s32 j; - for (i = 0, weightsPtr = weights, xPtr1 = x, fxPtr = fx, weightsPtr = weightsPtr; i < n; i++) { + for (i = 0, xPtr1 = x, fxPtr = fx, weightsPtr = weights; i < n; i++) { for (xVal = *xPtr1, m = 1.0f, j = 0, xPtr2 = x; j < n; j++) { if (j != i) { m *= xVal - (*xPtr2); diff --git a/src/code/z_schedule.c b/src/code/z_schedule.c new file mode 100644 index 0000000000..4c57a57d4f --- /dev/null +++ b/src/code/z_schedule.c @@ -0,0 +1,283 @@ +#include "global.h" + +#define SCHEDULE_CALC_TIME(hour, minute, dest, temp) \ + (temp) = (hour)*60.0f; \ + (temp) += (minute); \ + (dest) = (temp) * (0x10000 / 60 / 24.0f); \ + (dest) = SCHEDULE_CONVERT_TIME(dest); + +s32 Schedule_CheckFlagS(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + ScheduleCmdCheckFlagS* cmd = (ScheduleCmdCheckFlagS*)*script; + u16 flag = (cmd->flagByte << 8) | cmd->flagMask; + + if (gSaveContext.save.weekEventReg[flag >> 8] & (flag & 0xFF)) { + *script += cmd->offset; + } + + return false; +} + +s32 Schedule_CheckFlagL(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + ScheduleCmdCheckFlagL* cmd = (ScheduleCmdCheckFlagL*)*script; + u16 flag = (cmd->flagByte << 8) | cmd->flagMask; + + if (gSaveContext.save.weekEventReg[flag >> 8] & (flag & 0xFF)) { + *script += (s16)((cmd->offsetH << 8) | cmd->offsetL); + } + + return false; +} + +s32 Schedule_CheckTimeRangeS(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + s32 inRange = false; + ScheduleCmdCheckTimeRangeS* cmd = (ScheduleCmdCheckTimeRangeS*)*script; + f32 f; + u16 start; + u16 end; + u16 now; + + SCHEDULE_CALC_TIME(cmd->startHr, cmd->startMin, start, f); + + SCHEDULE_CALC_TIME(cmd->endHr, cmd->endMin, end, f); + end--; + + now = SCHEDULE_TIME_NOW; + + if ((start <= now) && (now <= end)) { + inRange = true; + } + + if (inRange == true) { + *script += cmd->offset; + } + + return false; +} + +s32 Schedule_CheckTimeRangeL(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + s32 inRange = false; + ScheduleCmdCheckTimeRangeL* cmd = (ScheduleCmdCheckTimeRangeL*)*script; + f32 f; + u16 start; + u16 end; + u16 now; + + SCHEDULE_CALC_TIME(cmd->startHr, cmd->startMin, start, f); + + SCHEDULE_CALC_TIME(cmd->endHr, cmd->endMin, end, f); + end--; + + now = SCHEDULE_TIME_NOW; + + if ((start <= now) && (now <= end)) { + inRange = true; + } + + if (inRange == true) { + *script += (s16)((cmd->offsetH << 8) | cmd->offsetL); + } + + return false; +} + +s32 Schedule_ReturnValueL(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + ScheduleCmdReturnValueL* cmd = (ScheduleCmdReturnValueL*)*script; + + //! @bug result is a u8, value is truncated + result->result = (cmd->retH << 8) | cmd->retL; + result->hasResult = true; + + return true; +} + +s32 Schedule_ReturnNone(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + result->hasResult = false; + + return true; +} + +s32 Schedule_ReturnEmpty(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + result->hasResult = true; + + return true; +} + +s32 Schedule_Nop(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + return false; +} + +s32 Schedule_CheckMiscS(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + ScheduleCmdCheckMiscS* cmd = (ScheduleCmdCheckMiscS*)*script; + + if (((cmd->which == SCHEDULE_CHECK_MISC_ROOM_KEY) && (INV_CONTENT(ITEM_ROOM_KEY) == ITEM_ROOM_KEY)) || + ((cmd->which == SCHEDULE_CHECK_MISC_LETTER_TO_KAFEI) && + (INV_CONTENT(ITEM_LETTER_TO_KAFEI) == ITEM_LETTER_TO_KAFEI)) || + ((cmd->which == SCHEDULE_CHECK_MISC_MASK_ROMANI) && (Player_GetMask(globalCtx) == PLAYER_MASK_ROMANI))) { + *script += cmd->offset; + } + + return false; +} + +s32 Schedule_ReturnValueS(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + ScheduleCmdReturnValueS* cmd = (ScheduleCmdReturnValueS*)*script; + + result->result = cmd->result; + result->hasResult = true; + + return true; +} + +s32 Schedule_CheckNotInSceneS(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + ScheduleCmdCheckNotInSceneS* cmd = (ScheduleCmdCheckNotInSceneS*)*script; + s16 scene = (cmd->sceneH << 8) | cmd->sceneL; + + if (scene != globalCtx->sceneNum) { + *script += cmd->offset; + } + + return false; +} + +s32 Schedule_CheckNotInSceneL(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + ScheduleCmdCheckNotInSceneL* cmd = (ScheduleCmdCheckNotInSceneL*)*script; + s16 scene = (cmd->sceneH << 8) | cmd->sceneL; + + if (scene != globalCtx->sceneNum) { + *script = *script + (s16)((cmd->offsetH << 8) | cmd->offsetL); + } + + return false; +} + +s32 Schedule_CheckNotInDayS(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + ScheduleCmdCheckNotInDayS* cmd = (ScheduleCmdCheckNotInDayS*)*script; + s16 day = (cmd->dayH << 8) | cmd->dayL; + + if (day != (s16)gSaveContext.save.day) { + *script += cmd->offset; + } + + return false; +} + +s32 Schedule_CheckNotInDayL(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + ScheduleCmdCheckNotInDayL* cmd = (ScheduleCmdCheckNotInDayL*)*script; + s16 day = (cmd->dayH << 8) | cmd->dayL; + + if (day != (s16)gSaveContext.save.day) { + *script += (s16)((cmd->offsetH << 8) | cmd->offsetL); + } + + return false; +} + +s32 Schedule_ReturnTime(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + ScheduleCmdReturnTime* cmd = (ScheduleCmdReturnTime*)*script; + f32 f; + u16 time0; + u16 time1; + + SCHEDULE_CALC_TIME(cmd->time0Hr, cmd->time0Min, time0, f); + + SCHEDULE_CALC_TIME(cmd->time1Hr, cmd->time1Min, time1, f); + time1--; + + result->result = cmd->result; + result->time0 = time0; + result->time1 = time1; + result->hasResult = true; + + return true; +} + +s32 Schedule_CheckBeforeTimeS(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + ScheduleCmdCheckBeforeTimeS* cmd = (ScheduleCmdCheckBeforeTimeS*)*script; + f32 f; + u16 testTime; + u16 now; + + SCHEDULE_CALC_TIME(cmd->timeHr, cmd->timeMin, testTime, f); + + now = SCHEDULE_TIME_NOW; + + if (now < testTime) { + *script += cmd->offset; + } + + return false; +} + +s32 Schedule_CheckBeforeTimeL(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + ScheduleCmdCheckBeforeTimeL* cmd = (ScheduleCmdCheckBeforeTimeL*)*script; + f32 f; + u16 testTime; + u16 now; + + SCHEDULE_CALC_TIME(cmd->timeHr, cmd->timeMin, testTime, f); + + now = SCHEDULE_TIME_NOW; + + if (now < testTime) { + *script += (s16)((cmd->offsetH << 8) | cmd->offsetL); + } + + return false; +} + +s32 Schedule_BranchS(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + ScheduleCmdBranchS* cmd = (ScheduleCmdBranchS*)*script; + + *script += cmd->offset; + return false; +} + +s32 Schedule_BranchL(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + ScheduleCmdBranchL* cmd = (ScheduleCmdBranchL*)*script; + + *script += (s16)((cmd->offsetH << 8) | cmd->offsetL); + return false; +} + +static s32 (*sScheduleCmdFuncs[])(GlobalContext*, u8**, ScheduleResult*) = { + Schedule_CheckFlagS, Schedule_CheckFlagL, Schedule_CheckTimeRangeS, Schedule_CheckTimeRangeL, + Schedule_ReturnValueL, Schedule_ReturnNone, Schedule_ReturnEmpty, Schedule_Nop, + Schedule_CheckMiscS, Schedule_ReturnValueS, Schedule_CheckNotInSceneS, Schedule_CheckNotInSceneL, + Schedule_CheckNotInDayS, Schedule_CheckNotInDayL, Schedule_ReturnTime, Schedule_CheckBeforeTimeS, + Schedule_CheckBeforeTimeL, Schedule_BranchS, Schedule_BranchL, +}; + +static u8 sScheduleCmdSizes[] = { + sizeof(ScheduleCmdCheckFlagS), + sizeof(ScheduleCmdCheckFlagL), + sizeof(ScheduleCmdCheckTimeRangeS), + sizeof(ScheduleCmdCheckTimeRangeL), + sizeof(ScheduleCmdReturnValueL), + sizeof(ScheduleCmdBase), + sizeof(ScheduleCmdBase), + sizeof(ScheduleCmdNop), + sizeof(ScheduleCmdCheckMiscS), + sizeof(ScheduleCmdReturnValueS), + sizeof(ScheduleCmdCheckNotInSceneS), + sizeof(ScheduleCmdCheckNotInSceneL), + sizeof(ScheduleCmdCheckNotInDayS), + sizeof(ScheduleCmdCheckNotInDayL), + sizeof(ScheduleCmdReturnTime), + sizeof(ScheduleCmdCheckBeforeTimeS), + sizeof(ScheduleCmdCheckBeforeTimeL), + sizeof(ScheduleCmdBranchS), + sizeof(ScheduleCmdBranchL), +}; + +s32 Schedule_RunScript(GlobalContext* globalCtx, u8* script, ScheduleResult* result) { + u8 size; + s32 stop; + + do { + size = sScheduleCmdSizes[*script]; + stop = (*sScheduleCmdFuncs[*script])(globalCtx, &script, result); + script += size; + } while (!stop); + + return result->hasResult; +} diff --git a/src/code/z_skelanime.c b/src/code/z_skelanime.c index 9fc5467e07..6563eecfc9 100644 --- a/src/code/z_skelanime.c +++ b/src/code/z_skelanime.c @@ -1,4 +1,3 @@ -#include "prevent_bss_reordering.h" #include "global.h" #define ANIM_INTERP 1 @@ -1239,9 +1238,9 @@ void SkelAnime_InitLink(GlobalContext* globalCtx, SkelAnime* skelAnime, FlexSkel */ void LinkAnimation_SetUpdateFunction(SkelAnime* skelAnime) { if (skelAnime->mode <= ANIMMODE_LOOP_INTERP) { - skelAnime->update = LinkAnimation_Loop; + skelAnime->update.link = LinkAnimation_Loop; } else { - skelAnime->update = LinkAnimation_Once; + skelAnime->update.link = LinkAnimation_Once; } skelAnime->morphWeight = 0.0f; } @@ -1251,7 +1250,7 @@ void LinkAnimation_SetUpdateFunction(SkelAnime* skelAnime) { * finishes. */ s32 LinkAnimation_Update(GlobalContext* globalCtx, SkelAnime* skelAnime) { - return skelAnime->update(globalCtx, skelAnime); + return skelAnime->update.link(globalCtx, skelAnime); } /** @@ -1356,7 +1355,7 @@ void LinkAnimation_Change(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAn SkelAnime_CopyFrameTable(skelAnime, skelAnime->morphTable, skelAnime->jointTable); morphFrames = -morphFrames; } else { - skelAnime->update = LinkAnimation_Morph; + skelAnime->update.link = LinkAnimation_Morph; AnimationContext_SetLoadFrame(globalCtx, animation, (s32)startFrame, skelAnime->limbCount, skelAnime->morphTable); } @@ -1577,7 +1576,7 @@ void SkelAnime_InitFlex(GlobalContext* globalCtx, SkelAnime* skelAnime, FlexSkel /** * Initializes a skeleton with SkinLimbs to a looping animation, dynamically allocating the frame tables. */ -void SkelAnime_InitSkin(GlobalContext* globalCtx, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg, +void SkelAnime_InitSkin(GameState* gameState, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg, AnimationHeader* animation) { SkeletonHeader* skeletonHeader; @@ -1600,11 +1599,11 @@ void SkelAnime_InitSkin(GlobalContext* globalCtx, SkelAnime* skelAnime, Skeleton */ void SkelAnime_SetUpdate(SkelAnime* skelAnime) { if (skelAnime->mode <= ANIMMODE_LOOP_INTERP) { - skelAnime->update = SkelAnime_LoopFull; + skelAnime->update.normal = SkelAnime_LoopFull; } else if (skelAnime->mode <= ANIMMODE_ONCE_INTERP) { - skelAnime->update = SkelAnime_Once; + skelAnime->update.normal = SkelAnime_Once; } else { - skelAnime->update = SkelAnime_LoopPartial; + skelAnime->update.normal = SkelAnime_LoopPartial; } } @@ -1613,7 +1612,7 @@ void SkelAnime_SetUpdate(SkelAnime* skelAnime) { * finishes. */ s32 SkelAnime_Update(SkelAnime* skelAnime) { - return skelAnime->update(skelAnime); + return skelAnime->update.normal(skelAnime); } /** @@ -1775,10 +1774,10 @@ void Animation_ChangeImpl(SkelAnime* skelAnime, AnimationHeader* animation, f32 morphFrames = -morphFrames; } else { if (taper != ANIMTAPER_NONE) { - skelAnime->update = SkelAnime_MorphTaper; + skelAnime->update.normal = SkelAnime_MorphTaper; skelAnime->taper = taper; } else { - skelAnime->update = SkelAnime_Morph; + skelAnime->update.normal = SkelAnime_Morph; } SkelAnime_GetFrameData(animation, startFrame, skelAnime->limbCount, skelAnime->morphTable); } diff --git a/src/code/z_skin.c b/src/code/z_skin.c index f031b007f8..808a00da07 100644 --- a/src/code/z_skin.c +++ b/src/code/z_skin.c @@ -1,23 +1,273 @@ #include "global.h" +#include "z64skin.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin/func_80137970.s") +// 60 is an arbitrary number which specifies the max amount of limbs per skeleton this system supports +MtxF gSkinLimbMatrices[60]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin/func_80137B34.s") +static s32 sUnused; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin/func_80137EBC.s") +void Skin_UpdateVertices(MtxF* mtx, SkinVertex* skinVertices, SkinLimbModif* modifEntry, Vtx* vtxBuf, Vec3f* pos) { + SkinVertex* vertexEntry; + Vtx* vtx; + Vec3f wTemp; + Vec3f normal; + Vec3f sp44; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin/func_80137F58.s") + wTemp.x = mtx->wx; + wTemp.y = mtx->wy; + wTemp.z = mtx->wz; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin/func_80138050.s") + mtx->wx = 0.0f; + mtx->wy = 0.0f; + mtx->wz = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin/func_80138228.s") + for (vertexEntry = skinVertices; vertexEntry < &skinVertices[modifEntry->vtxCount]; vertexEntry++) { + vtx = &vtxBuf[vertexEntry->index]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin/func_80138258.s") + vtx->n.ob[0] = pos->x; + vtx->n.ob[1] = pos->y; + vtx->n.ob[2] = pos->z; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin/func_8013828C.s") + sp44.x = vertexEntry->normX; + sp44.y = vertexEntry->normY; + sp44.z = vertexEntry->normZ; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin/func_801382C4.s") + SkinMatrix_Vec3fMtxFMultXYZ(mtx, &sp44, &normal); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin/func_80138300.s") + vtx->n.n[0] = normal.x; + vtx->n.n[1] = normal.y; + vtx->n.n[2] = normal.z; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin/func_8013835C.s") + mtx->wx = wTemp.x; + mtx->wy = wTemp.y; + mtx->wz = wTemp.z; +} + +void Skin_ApplyLimbModifications(GraphicsContext* gfxCtx, Skin* skin, s32 limbIndex, s32 arg3) { + s32 modifCount; + SkinLimb** skeleton; + s32 pad; + SkinAnimatedLimbData* data; + s32 pad2[5]; + SkinLimbModif* modif; + SkinLimbVtx* vtxEntry; + s32 pad3; + s32 transformCount; + f32 scale; + SkinVertex* skinVertices; + Vec3f sp88; + Vtx* vtxBuf; + SkinTransformation* limbTransformations; + Vec3f spDC; + Vec3f spD0; + SkinTransformation* transformationEntry; + SkinLimb* limb; + SkinLimbModif* modifications; + + OPEN_DISPS(gfxCtx); + + skeleton = (SkinLimb**)Lib_SegmentedToVirtual(skin->skeletonHeader->segment); + limb = (SkinLimb*)Lib_SegmentedToVirtual(skeleton[limbIndex]); + data = Lib_SegmentedToVirtual(limb->segment); + modifications = (SkinLimbModif*)Lib_SegmentedToVirtual(data->limbModifications); + + vtxEntry = &skin->vtxTable[limbIndex]; + + vtxBuf = vtxEntry->buf[vtxEntry->index]; + modifCount = data->limbModifCount; + + for (modif = modifications; modif < &modifications[modifCount]; modif++) { + Vec3f spAC; + Vec3f spA0; + + skinVertices = (SkinVertex*)Lib_SegmentedToVirtual(modif->skinVertices); + limbTransformations = (SkinTransformation*)Lib_SegmentedToVirtual(modif->limbTransformations); + transformCount = modif->transformCount; + + if (transformCount == 1) { + spAC.x = limbTransformations[0].x; + spAC.y = limbTransformations[0].y; + spAC.z = limbTransformations[0].z; + + SkinMatrix_Vec3fMtxFMultXYZ(&gSkinLimbMatrices[limbTransformations[0].limbIndex], &spAC, &spDC); + } else if (arg3) { + transformationEntry = &limbTransformations[modif->unk_04]; + + spA0.x = transformationEntry->x; + spA0.y = transformationEntry->y; + spA0.z = transformationEntry->z; + SkinMatrix_Vec3fMtxFMultXYZ(&gSkinLimbMatrices[transformationEntry->limbIndex], &spA0, &spDC); + } else { + spDC.x = 0.0f; + spDC.y = 0.0f; + spDC.z = 0.0f; + + for (transformationEntry = limbTransformations; transformationEntry < &limbTransformations[transformCount]; + transformationEntry++) { + scale = transformationEntry->scale * 0.01f; + + sp88.x = transformationEntry->x; + sp88.y = transformationEntry->y; + sp88.z = transformationEntry->z; + + SkinMatrix_Vec3fMtxFMultXYZ(&gSkinLimbMatrices[transformationEntry->limbIndex], &sp88, &spD0); + + spDC.x += spD0.x * scale; + spDC.y += spD0.y * scale; + spDC.z += spD0.z * scale; + } + } + + Skin_UpdateVertices(&gSkinLimbMatrices[limbTransformations[modif->unk_04].limbIndex], skinVertices, modif, + vtxBuf, &spDC); + } + + gSPSegment(POLY_OPA_DISP++, 0x08, vtxEntry->buf[vtxEntry->index]); + + vtxEntry->index = (vtxEntry->index == 0); + + CLOSE_DISPS(gfxCtx); +} + +/** + * Draw a limb of type SKIN_LIMB_TYPE_ANIMATED, of the skeleton `skin` at index `limbIndex` + * The vertices of this limb are modified dynamically + */ +void Skin_DrawAnimatedLimb(GraphicsContext* gfxCtx, Skin* skin, s32 limbIndex, s32 arg3, s32 drawFlags) { + SkinLimb** skeleton; + s32 pad[3]; + SkinAnimatedLimbData* data; + + OPEN_DISPS(gfxCtx); + + skeleton = Lib_SegmentedToVirtual(skin->skeletonHeader->segment); + data = Lib_SegmentedToVirtual(((SkinLimb*)Lib_SegmentedToVirtual(skeleton[limbIndex]))->segment); + + if (!(drawFlags & SKIN_DRAW_FLAG_CUSTOM_TRANSFORMS)) { + Skin_ApplyLimbModifications(gfxCtx, skin, limbIndex, arg3); + } + + gSPDisplayList(POLY_OPA_DISP++, data->dlist); + + CLOSE_DISPS(gfxCtx); +} + +/** + * Draw a limb of type SKIN_LIMB_TYPE_NORMAL, of the skeleton `skin` at index `limbIndex` + */ +void Skin_DrawLimb(GraphicsContext* gfxCtx, Skin* skin, s32 limbIndex, Gfx* dListOverride, s32 drawFlags) { + Gfx* gfx = dListOverride; + SkinLimb** skeleton; + + OPEN_DISPS(gfxCtx); + + skeleton = Lib_SegmentedToVirtual(skin->skeletonHeader->segment); + + if (dListOverride == NULL) { + gfx = ((SkinLimb*)Lib_SegmentedToVirtual(skeleton[limbIndex]))->segment; + } + + if (gfx != NULL) { + Mtx* mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &gSkinLimbMatrices[limbIndex]); + + if (mtx != NULL) { + gSPMatrix(POLY_OPA_DISP++, mtx, G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gfx); + gSPPopMatrix(POLY_OPA_DISP++, G_MTX_MODELVIEW); + gDPPipeSync(POLY_OPA_DISP++); + } + } + + CLOSE_DISPS(gfxCtx); +} + +void Skin_DrawImpl(Actor* actor, GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw, + SkinOverrideLimbDraw overrideLimbDraw, s32 setTranslation, s32 arg6, s32 drawFlags) { + s32 i; + SkinLimb** skeleton; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + + OPEN_DISPS(gfxCtx); + + if (!(drawFlags & SKIN_DRAW_FLAG_CUSTOM_TRANSFORMS)) { + Skin_ApplyAnimTransformations(skin, gSkinLimbMatrices, actor, setTranslation); + } + + skeleton = Lib_SegmentedToVirtual(skin->skeletonHeader->segment); + + if (!(drawFlags & SKIN_DRAW_FLAG_CUSTOM_MATRIX)) { + Mtx* mtx; + + gSPMatrix(POLY_OPA_DISP++, &gIdentityMtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &skin->mtx); + if (mtx == NULL) { + goto close_disps; + } + gSPMatrix(POLY_OPA_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + } + + for (i = 0; i < skin->skeletonHeader->limbCount; i++) { + s32 shouldDraw = true; + s32 segmentType; + + if (overrideLimbDraw != NULL) { + shouldDraw = overrideLimbDraw(actor, globalCtx, i, skin); + } + + segmentType = ((SkinLimb*)Lib_SegmentedToVirtual(skeleton[i]))->segmentType; + + if (segmentType == SKIN_LIMB_TYPE_ANIMATED && shouldDraw) { + Skin_DrawAnimatedLimb(gfxCtx, skin, i, arg6, drawFlags); + } else if (segmentType == SKIN_LIMB_TYPE_NORMAL && shouldDraw) { + Skin_DrawLimb(gfxCtx, skin, i, NULL, drawFlags); + } + } + + if (postDraw != NULL) { + postDraw(actor, globalCtx, skin); + } + +close_disps:; + CLOSE_DISPS(gfxCtx); +} + +// allows specifying postDraw and setTranslation +void func_80138228(Actor* actor, GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw, s32 setTranslation) { + Skin_DrawImpl(actor, globalCtx, skin, postDraw, NULL, setTranslation, false, 0); +} + +// allows specifying OverrideLimbDraw, postDraw and setTranslation +void func_80138258(Actor* actor, GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw, + SkinOverrideLimbDraw overrideLimbDraw, s32 setTranslation) { + Skin_DrawImpl(actor, globalCtx, skin, postDraw, overrideLimbDraw, setTranslation, false, 0); +} + +// allows specifying OverrideLimbDraw, postDraw, setTranslation, and arg6 +void func_8013828C(Actor* actor, GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw, + SkinOverrideLimbDraw overrideLimbDraw, s32 setTranslation, s32 arg6) { + Skin_DrawImpl(actor, globalCtx, skin, postDraw, overrideLimbDraw, setTranslation, arg6, 0); +} + +// allows specifying all variables +void func_801382C4(Actor* actor, GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw, + SkinOverrideLimbDraw overrideLimbDraw, s32 setTranslation, s32 arg6, s32 drawFlags) { + Skin_DrawImpl(actor, globalCtx, skin, postDraw, overrideLimbDraw, setTranslation, arg6, drawFlags); +} + +void Skin_GetLimbPos(Skin* skin, s32 limbIndex, Vec3f* offset, Vec3f* dst) { + MtxF mtxf; + + SkinMatrix_MtxFMtxFMult(&skin->mtx, &gSkinLimbMatrices[limbIndex], &mtxf); + SkinMatrix_Vec3fMtxFMultXYZ(&mtxf, offset, dst); +} + +void Skin_GetVertexPos(Skin* skin, s32 limbIndex, s32 vtxIndex, Vec3f* dst) { + Vec3f pos; + Vtx* vtx = &skin->vtxTable[limbIndex].buf[skin->vtxTable[0].index][vtxIndex]; + + pos.x = vtx->n.ob[0]; + pos.y = vtx->n.ob[1]; + pos.z = vtx->n.ob[2]; + SkinMatrix_Vec3fMtxFMultXYZ(&skin->mtx, &pos, dst); +} diff --git a/src/code/z_skin_awb.c b/src/code/z_skin_awb.c index 22a1c637f4..d45b9bc250 100644 --- a/src/code/z_skin_awb.c +++ b/src/code/z_skin_awb.c @@ -1,13 +1,204 @@ #include "global.h" +#include "z64skin.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin_awb/func_80138410.s") +void Skin_Setup(Skin* skin) { + skin->skeletonHeader = NULL; + skin->limbCount = 0; + skin->vtxTable = NULL; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin_awb/func_80138424.s") +/** + * Initialises the Vtx buffers used for limb at index `limbIndex` + */ +void Skin_InitAnimatedLimb(GameState* gameState, Skin* skin, s32 limbIndex) { + s32 i; + SkinLimb** skeleton = Lib_SegmentedToVirtual(skin->skeletonHeader->segment); + SkinAnimatedLimbData* animatedLimbData = + Lib_SegmentedToVirtual(((SkinLimb*)Lib_SegmentedToVirtual(skeleton[limbIndex]))->segment); + SkinLimbModif* limbModifications = Lib_SegmentedToVirtual(animatedLimbData->limbModifications); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin_awb/func_8013859C.s") + for (i = 0; i < ARRAY_COUNT(skin->vtxTable->buf); i++) { + Vtx* vertices = skin->vtxTable[limbIndex].buf[i]; + SkinLimbModif* modifEntry; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin_awb/func_80138700.s") + for (modifEntry = limbModifications; modifEntry < &limbModifications[animatedLimbData->limbModifCount]; + modifEntry++) { + SkinVertex* skinVertices = Lib_SegmentedToVirtual(modifEntry->skinVertices); + SkinVertex* skinVtxEntry; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin_awb/func_801387D4.s") + for (skinVtxEntry = skinVertices; skinVtxEntry < &skinVertices[modifEntry->vtxCount];) { + Vtx* vtx = &vertices[skinVtxEntry->index]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin_awb/func_801388E4.s") + skinVtxEntry++; + + vtx->n.flag = 0; + vtx->n.tc[0] = skinVtxEntry[-1].s; + vtx->n.tc[1] = skinVtxEntry[-1].t; + vtx->n.a = skinVtxEntry[-1].alpha; + } + } + } +} + +/** + * Initializes a skin skeleton to looping animation, dynamically allocating the frame tables, + * and dynamically allocating and initialising the Vtx and SkinLimbVtx buffers for its animated limbs + */ +void Skin_Init(GameState* gameState, Skin* skin, SkeletonHeader* skeletonHeader, AnimationHeader* animationHeader) { + s32 limbCount; + s32 i; + SkinLimb** skeleton; + SkeletonHeader* virtSkelHeader = Lib_SegmentedToVirtual(skeletonHeader); + + skin->limbCount = virtSkelHeader->limbCount; + skin->skeletonHeader = virtSkelHeader; + limbCount = skin->skeletonHeader->limbCount; + + skeleton = Lib_SegmentedToVirtual(skin->skeletonHeader->segment); + skin->vtxTable = ZeldaArena_Malloc(limbCount * sizeof(SkinLimbVtx)); + + for (i = 0; i < limbCount; i++) { + SkinLimbVtx* vtxEntry = &skin->vtxTable[i]; + + if ((((SkinLimb*)Lib_SegmentedToVirtual(skeleton[i]))->segmentType != SKIN_LIMB_TYPE_ANIMATED) || + (((SkinLimb*)Lib_SegmentedToVirtual(skeleton[i]))->segment == NULL)) { + vtxEntry->index = 0; + + vtxEntry->buf[0] = NULL; + vtxEntry->buf[1] = NULL; + } else { + SkinAnimatedLimbData* animatedLimbData = + Lib_SegmentedToVirtual((((SkinLimb*)Lib_SegmentedToVirtual(skeleton[i]))->segment)); + + { s32 tmp; } + + vtxEntry->index = 0; + vtxEntry->buf[0] = ZeldaArena_Malloc(animatedLimbData->totalVtxCount * sizeof(Vtx)); + vtxEntry->buf[1] = ZeldaArena_Malloc(animatedLimbData->totalVtxCount * sizeof(Vtx)); + + Skin_InitAnimatedLimb(gameState, skin, i); + } + } + + SkelAnime_InitSkin(gameState, &skin->skelAnime, skeletonHeader, animationHeader); +} + +/** + * Frees the dynamically allocated Vtx and SkinLimbVtx buffers and tables + */ +void Skin_Free(GameState* gameState, Skin* skin) { + if (skin->vtxTable != NULL) { + s32 i; + + for (i = 0; i < skin->limbCount; i++) { + if (skin->vtxTable[i].buf[0] != NULL) { + ZeldaArena_Free(skin->vtxTable[i].buf[0]); + skin->vtxTable[i].buf[0] = NULL; + } + if (skin->vtxTable[i].buf[1] != NULL) { + ZeldaArena_Free(skin->vtxTable[i].buf[1]); + skin->vtxTable[i].buf[1] = NULL; + } + } + + if (skin->vtxTable != NULL) { + ZeldaArena_Free(skin->vtxTable); + } + + SkelAnime_Free(&skin->skelAnime, (GlobalContext*)gameState); + } +} + +s32 func_801387D4(Skin* skin, SkinLimb** skeleton, MtxF* limbMatrices, u8 parentIndex, u8 limbIndex) { + s32 pad; + SkinLimb* limb = Lib_SegmentedToVirtual(skeleton[limbIndex]); + MtxF* mtx; + s32 ret; + MtxF sp28; + + if (parentIndex == LIMB_DONE) { + SkinMatrix_GetClear(&mtx); + } else { + mtx = &limbMatrices[(s32)parentIndex]; + } + + SkinMatrix_MtxFMtxFMult(mtx, &limbMatrices[limbIndex], &sp28); + SkinMatrix_MtxFCopy(&sp28, &limbMatrices[limbIndex]); + + if (limb->child != LIMB_DONE) { + ret = func_801387D4(skin, skeleton, limbMatrices, limbIndex, limb->child); + if (ret) { + return ret; + } + } + + if (limb->sibling != LIMB_DONE) { + ret = func_801387D4(skin, skeleton, limbMatrices, parentIndex, limb->sibling); + if (ret) { + return ret; + } + } + + return false; +} + +/** + * Recursively applies matrix tranformations to each limb + */ +s32 Skin_ApplyAnimTransformations(Skin* skin, MtxF* limbMatrices, Actor* actor, s32 setTranslation) { + s32 i; + s32 pad; + f32 yRot; + f32 xRot; + f32 zRot; + s32 ret; + f32 yTransl; + f32 xTransl; + f32 zTransl; + SkinLimb** skeleton = Lib_SegmentedToVirtual(skin->skeletonHeader->segment); + Vec3s* jointRot = skin->skelAnime.jointTable; + + jointRot++; + xRot = jointRot->x; + yRot = jointRot->y; + zRot = jointRot->z; + + if (setTranslation) { + jointRot--; + xTransl = jointRot->x; + yTransl = jointRot->y; + zTransl = jointRot->z; + jointRot++; + + SkinMatrix_SetRotateRPYTranslate(limbMatrices, xRot, yRot, zRot, xTransl, yTransl, zTransl); + } else { + SkinMatrix_SetRotateRPYTranslate(limbMatrices, xRot, yRot, zRot, 0.0f, 0.0f, 0.0f); + } + + jointRot++; + + for (i = 1; i < skin->skeletonHeader->limbCount; i++) { + SkinLimb* limb = Lib_SegmentedToVirtual(skeleton[i]); + + xTransl = limb->jointPos.x; + yTransl = limb->jointPos.y; + zTransl = limb->jointPos.z; + xRot = jointRot->x; + yRot = jointRot->y; + zRot = jointRot->z; + jointRot++; + SkinMatrix_SetRotateRPYTranslate(&limbMatrices[i], xRot, yRot, zRot, xTransl, yTransl, zTransl); + } + + SkinMatrix_SetScaleRotateYRPTranslate( + &skin->mtx, actor->scale.x, actor->scale.y, actor->scale.z, actor->shape.rot.x, actor->shape.rot.y, + actor->shape.rot.z, actor->world.pos.x, actor->world.pos.y + (actor->shape.yOffset * actor->scale.y), + actor->world.pos.z); + + ret = func_801387D4(skin, Lib_SegmentedToVirtual(skin->skeletonHeader->segment), limbMatrices, LIMB_DONE, 0); + if (!ret) { + return ret; + } + + return false; +} diff --git a/src/code/z_snap.c b/src/code/z_snap.c index bce1f67d7b..f85f33f0a7 100644 --- a/src/code/z_snap.c +++ b/src/code/z_snap.c @@ -12,8 +12,8 @@ s32 func_8013A240(GlobalContext* globalCtx) { s32 seen; s32 count = 0; - gSaveContext.pictoFlags0 = 0; - gSaveContext.pictoFlags1 = 0; + gSaveContext.save.pictoFlags0 = 0; + gSaveContext.save.pictoFlags1 = 0; if (globalCtx->sceneNum == SCENE_20SICHITAI) { func_8013A41C(1); @@ -76,19 +76,19 @@ s32 func_8013A240(GlobalContext* globalCtx) { void func_8013A41C(s32 flag) { if (flag < 0x20) { - gSaveContext.pictoFlags0 |= (1 << flag); + gSaveContext.save.pictoFlags0 |= (1 << flag); } else { flag &= 0x1F; - gSaveContext.pictoFlags1 |= (1 << flag); + gSaveContext.save.pictoFlags1 |= (1 << flag); } } void func_8013A46C(s32 flag) { if (flag < 0x20) { - gSaveContext.pictoFlags0 &= ~(1 << flag); + gSaveContext.save.pictoFlags0 &= ~(1 << flag); } else { flag &= 0x1F; - gSaveContext.pictoFlags1 &= ~(1 << flag); + gSaveContext.save.pictoFlags1 &= ~(1 << flag); } } @@ -96,10 +96,10 @@ u32 func_8013A4C4(s32 flag) { SaveContext* saveCtx = &gSaveContext; if (flag < 0x20) { - return saveCtx->pictoFlags0 & (1 << flag); + return saveCtx->save.pictoFlags0 & (1 << flag); } else { flag &= 0x1F; - return saveCtx->pictoFlags1 & (1 << flag); + return saveCtx->save.pictoFlags1 & (1 << flag); } } @@ -135,7 +135,7 @@ s32 func_8013A530(GlobalContext* globalCtx, Actor* actor, s32 flag, Vec3f* pos, Actor_GetProjectedPos(globalCtx, pos, &screenSpace, &distance); x = (s16)(screenSpace.x * distance * 160.0f + 160.0f) - 85; y = (s16)(screenSpace.y * distance * -120.0f + 120.0f) - 67; - if ((x < 0) || (0x96 < x) || (y < 0) || (0x69 < y)) { + if ((x < 0) || (150 < x) || (y < 0) || (105 < y)) { func_8013A41C(0x3D); ret |= 0x3D; } diff --git a/src/code/z_sram_NES.c b/src/code/z_sram_NES.c index 5b5b2f5f05..90b60809ef 100644 --- a/src/code/z_sram_NES.c +++ b/src/code/z_sram_NES.c @@ -1,67 +1,1677 @@ #include "global.h" +#include "overlays/gamestates/ovl_file_choose/z_file_choose.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80143A10.s") +void func_80146EBC(SramContext* sramCtx, s32 curPage, s32 numPages); +void func_80147314(SramContext* sramCtx, s32 fileNum); +void func_80147414(SramContext* sramCtx, s32 fileNum, s32 arg2); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80143A54.s") +#define CHECK_NEWF(newf) \ + ((newf)[0] != 'Z' || (newf)[1] != 'E' || (newf)[2] != 'L' || (newf)[3] != 'D' || (newf)[4] != 'A' || \ + (newf)[5] != '3') -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80143AC4.s") +// default scene flags (?) +// indices of subarray: +// - 0: switch0 +// - 1: switch1 +// - 2: chest +// - 3: collectible +u32 D_801C5FC0[SCENE_MAX][4] = { + { 0xC00, 0, 0, 0x40000000 }, // SCENE_20SICHITAI2 + { 0, 0, 0, 0 }, // SCENE_UNSET_1 + { 0, 0, 0, 0 }, // SCENE_UNSET_2 + { 0, 0, 0, 0 }, // SCENE_UNSET_3 + { 0, 0, 0, 0 }, // SCENE_UNSET_4 + { 0, 0, 0, 0 }, // SCENE_UNSET_5 + { 0, 0, 0, 0 }, // SCENE_UNSET_6 + { 0, 0, 0, 0xC04 }, // SCENE_KAKUSIANA + { 0, 0, 0, 0 }, // SCENE_SPOT00 + { 0, 0, 0, 0 }, // SCENE_UNSET_9 + { 0, 0, 0, 0 }, // SCENE_WITCH_SHOP + { 0, 0, 0, 0x80000000 }, // SCENE_LAST_BS + { 0, 0, 0, 0x80000000 }, // SCENE_HAKASHITA + { 0, 0, 0, 0 }, // SCENE_AYASHIISHOP + { 0, 0, 0, 0 }, // SCENE_UNSET_E + { 0, 0, 0, 0 }, // SCENE_UNSET_F + { 0, 0, 0, 0 }, // SCENE_OMOYA + { 0, 0, 0, 0 }, // SCENE_BOWLING + { 0, 0, 0, 0 }, // SCENE_SONCHONOIE + { 0x100000, 0, 0, 0x40000002 }, // SCENE_IKANA + { 0, 0, 0, 0 }, // SCENE_KAIZOKU + { 0, 0, 0, 0 }, // SCENE_MILK_BAR + { 0x4000000, 0, 0, 0 }, // SCENE_INISIE_N + { 2, 0, 0, 0 }, // SCENE_TAKARAYA + { 0x4000000, 0, 0, 0 }, // SCENE_INISIE_R + { 0, 0, 0, 0 }, // SCENE_OKUJOU + { 0xF, 0, 0, 0 }, // SCENE_OPENINGDAN + { 0x70B000, 0, 0, 0 }, // SCENE_MITURIN + { 0, 0, 0, 0 }, // SCENE_13HUBUKINOMITI + { 0, 0x80000000, 0, 0x400 }, // SCENE_CASTLE + { 0, 0, 0, 0 }, // SCENE_DEKUTES + { 0, 0, 0, 0x80000000 }, // SCENE_MITURIN_BS + { 0, 0, 0, 0 }, // SCENE_SYATEKI_MIZU + { 0x1A00020, 0, 0, 0 }, // SCENE_HAKUGIN + { 0x400, 0, 0, 0 }, // SCENE_ROMANYMAE + { 0, 0, 0, 0x1000 }, // SCENE_PIRATE + { 0, 0, 0, 0 }, // SCENE_SYATEKI_MORI + { 0, 0, 0, 2 }, // SCENE_SINKAI + { 0x400, 0, 0, 0 }, // SCENE_YOUSEI_IZUMI + { 0, 0, 0, 0 }, // SCENE_KINSTA1 + { 0, 0, 0, 0x80000000 }, // SCENE_KINDAN2 + { 0, 0, 0, 0 }, // SCENE_TENMON_DAI + { 0, 0, 0, 2 }, // SCENE_LAST_DEKU + { 0, 0, 0, 0x40000000 }, // SCENE_22DEKUCITY + { 0, 0, 0, 0 }, // SCENE_KAJIYA + { 0x10, 0, 0, 0 }, // SCENE_00KEIKOKU + { 3, 0, 0, 0 }, // SCENE_POSTHOUSE + { 0, 0, 0, 0 }, // SCENE_LABO + { 0, 0, 0, 0x80000000 }, // SCENE_DANPEI2TEST + { 0, 0, 0, 0 }, // SCENE_UNSET_31 + { 0, 0, 0, 0 }, // SCENE_16GORON_HOUSE + { 0, 0, 0, 0 }, // SCENE_33ZORACITY + { 0, 0, 0, 0 }, // SCENE_8ITEMSHOP + { 0, 0, 0, 0 }, // SCENE_F01 + { 0, 0, 0, 0x80000000 }, // SCENE_INISIE_BS + { 0x100400, 0, 0, 0x22 }, // SCENE_30GYOSON + { 0x400, 0, 0, 0x80 }, // SCENE_31MISAKI + { 0, 0, 0, 0 }, // SCENE_TAKARAKUJI + { 0, 0, 0, 0 }, // SCENE_UNSET_3A + { 0x400, 0, 0, 0 }, // SCENE_TORIDE + { 0, 0, 0, 0 }, // SCENE_FISHERMAN + { 0, 0, 0, 0 }, // SCENE_GORONSHOP + { 0, 0, 0, 0 }, // SCENE_DEKU_KING + { 0, 0, 0, 2 }, // SCENE_LAST_GORON + { 0, 0, 0, 0x80000002 }, // SCENE_24KEMONOMITI + { 0, 0, 0, 0 }, // SCENE_F01_B + { 0, 0, 0, 0 }, // SCENE_F01C + { 0, 0, 0, 0 }, // SCENE_BOTI + { 0, 0, 0, 0x80000000 }, // SCENE_HAKUGIN_BS + { 0xC00, 0, 0, 0x40000000 }, // SCENE_20SICHITAI + { 0x102, 0, 0, 0x400 }, // SCENE_21MITURINMAE + { 0, 0, 0, 2 }, // SCENE_LAST_ZORA + { 0, 0, 0, 0x40000000 }, // SCENE_11GORONNOSATO2 + { 0x70, 0, 0, 0 }, // SCENE_SEA + { 0, 0, 0, 0 }, // SCENE_35TAKI + { 0, 0, 0, 0 }, // SCENE_REDEAD + { 0, 0, 0, 0x40000000 }, // SCENE_BANDROOM + { 0, 0, 0, 0x40000000 }, // SCENE_11GORONNOSATO + { 0, 0, 0, 0 }, // SCENE_GORON_HAKA + { 0, 0, 0, 0 }, // SCENE_SECOM + { 0x100000, 0, 0, 0x80000000 }, // SCENE_10YUKIYAMANOMURA + { 0, 0, 0, 0 }, // SCENE_TOUGITES + { 0, 0, 0, 0 }, // SCENE_DANPEI + { 0, 0, 0, 0 }, // SCENE_IKANAMAE + { 0, 0, 0, 0 }, // SCENE_DOUJOU + { 0, 0, 0, 0 }, // SCENE_MUSICHOUSE + { 0, 0, 0, 0 }, // SCENE_IKNINSIDE + { 0, 0, 0, 0 }, // SCENE_MAP_SHOP + { 0x400, 0, 0, 0 }, // SCENE_F40 + { 0x400, 0, 0, 0 }, // SCENE_F41 + { 0x100000, 0, 0, 0x80000000 }, // SCENE_10YUKIYAMANOMURA2 + { 0, 0, 0, 0x100 }, // SCENE_14YUKIDAMANOMITI + { 0x400, 0, 0, 0 }, // SCENE_12HAKUGINMAE + { 0, 0, 0, 0x80 }, // SCENE_17SETUGEN + { 0, 0, 0, 0x80 }, // SCENE_17SETUGEN2 + { 0, 0, 0, 0x80000000 }, // SCENE_SEA_BS + { 0, 0, 0, 0x400 }, // SCENE_RANDOM + { 0, 0, 0, 0 }, // SCENE_YADOYA + { 0, 0, 0, 0 }, // SCENE_KONPEKI_ENT + { 1, 0, 0, 0 }, // SCENE_INSIDETOWER + { 0, 0, 0, 0 }, // SCENE_26SARUNOMORI + { 0, 0, 0, 0 }, // SCENE_LOST_WOODS + { 0, 0, 0, 2 }, // SCENE_LAST_LINK + { 0, 0, 0, 0 }, // SCENE_SOUGEN + { 0, 0, 0, 0 }, // SCENE_BOMYA + { 0, 0, 0, 0 }, // SCENE_KYOJINNOMA + { 0, 0, 0, 0 }, // SCENE_KOEPONARACE + { 0, 0, 0, 0 }, // SCENE_GORONRACE + { 1, 0, 0, 0 }, // SCENE_TOWN + { 0, 0, 0, 0 }, // SCENE_ICHIBA + { 0, 0, 0, 0x400 }, // SCENE_BACKTOWN + { 0x100000, 0, 0, 0x400 }, // SCENE_CLOCKTOWER + { 0, 0, 1, 0 }, // SCENE_ALLEY +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80143B0C.s") +// Related to weekEventReg +u16 D_801C66D0[ARRAY_COUNT(gSaveContext.save.weekEventReg)] = { + 0xFFFC, 0xFFFF, 0xFFFF, 0xFFFF, 0, 0, 0, 0xC000, 0xC00, 0, 0xC0, 0, 0x300, + 0x3000, 0xC000, 0xC00, 0, 0, 0, 0, 0, 0, 0xC00C, 0xC00C, 0xC008, 3, + 0x3000, 0, 0, 0, 0xFF00, 0xC3F, 0x3F, 0, 0, 0xCFFF, 0, 0, 0xC00, + 0xC00, 0, 0xC0, 0, 0, 0, 0, 0, 0, 0, 0, 0x3C, 0x20, + 0, 0x300C, 0x3000, 0, 0xC, 0xC0, 0, 0xFF0, 0x300, 0, 0, 0xC00, 0, + 0, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xC0, 0, 0xC000, 0, 3, + 0, 0xC000, 0, 0xC0, 0x300, 0, 0, 0, 0xC000, 0xFFF0, 0, 0, 0x300, + 0, 0xC000, 0xF0, 0, 0, 0, 0, 0, 0, +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/Sram_IncrementDay.s") +// used in other files +s32 D_801C6798[] = { + 0x00000020, 0x00001470, 0x000028C0, 0x00003D10, 0x00005160, 0x000065B0, +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/Sram_CalcChecksum.s") +u8 D_801C67B0[24] = { + ITEM_NONE, ITEM_BOW, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_BOMB, ITEM_BOMBCHU, + ITEM_STICK, ITEM_NUT, ITEM_MAGIC_BEANS, ITEM_NONE, ITEM_POWDER_KEG, ITEM_PICTO_BOX, ITEM_NONE, ITEM_NONE, + ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80144628.s") +s32 D_801C67C8[] = { 0, 0x40, 0x80, 0xC0, 0x100, 0x180, 0x200, 0x280 }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/Sram_GenerateRandomSaveFields.s") +s32 D_801C67E8[] = { 0x300, 0x380 }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80144890.s") +s32 D_801C67F0[] = { 0x40, 0x40, 0x40, 0x40, 0x80, 0x80, 0x80, 0x80 }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/Sram_InitDebugSave.s") +s32 D_801C6810[] = { 1, 1 }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80144A94.s") +s32 D_801C6818[] = { 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80144E78.s") +s32 D_801C6838[] = { 1, 1 }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_8014546C.s") +s32 D_801C6840[] = { 0x100, 0x180, 0x200, 0x280 }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80145698.s") +s32 D_801C6850[] = { 0x80, 0x80, 0x80, 0x80, 0x300, 0x380, 1, 1 }; +s32 D_801C6870[] = { + sizeof(Save), + sizeof(Save), + sizeof(Save), + sizeof(Save), + offsetof(SaveContext, fileNum), + offsetof(SaveContext, fileNum), + offsetof(SaveContext, fileNum), + offsetof(SaveContext, fileNum), +}; + +u8 D_801C6890[8] = { 1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80 }; + +u16 D_801F6AF0; +u8 D_801F6AF2; + +void Sram_ActivateOwl(u8 owlId) { + gSaveContext.save.playerData.owlActivationFlags = + ((void)0, gSaveContext.save.playerData.owlActivationFlags) | (u16)gBitFlags[owlId]; + + if (gSaveContext.save.playerData.unk_20 == 0xFF) { + gSaveContext.save.playerData.unk_20 = owlId; + } +} + +void Sram_ClearHighscores(void) { + gSaveContext.save.unk_EE8 = (gSaveContext.save.unk_EE8 & 0xFFFF) | 0x130000; + gSaveContext.save.unk_EE8 = (gSaveContext.save.unk_EE8 & 0xFFFF0000) | 0xA; + gSaveContext.save.horseBackBalloonHighScore = 6000; // 60 seconds + gSaveContext.save.unk_EF4 = (gSaveContext.save.unk_EF4 & 0xFFFF0000) | 0x27; + gSaveContext.save.unk_EF4 = (gSaveContext.save.unk_EF4 & 0xFFFF) | 0xA0000; + + gSaveContext.save.dekuPlaygroundHighScores[0] = 7500; // 75 seconds + gSaveContext.save.dekuPlaygroundHighScores[1] = 7500; // 75 seconds + gSaveContext.save.dekuPlaygroundHighScores[2] = 7600; // 76 seconds +} + +/** + * Clears specific weekEventReg flags. Used by the "Dawn of the First Day" message + */ +void Sram_ClearFlagsAtDawnOfTheFirstDay(void) { + // Unconfirmed: "Link the Goron Claims His Reservation: 4:30 PM" + gSaveContext.save.weekEventReg[55] &= (u8)~2; + // Unconfirmed: "Postman fleeing town" + gSaveContext.save.weekEventReg[90] &= (u8)~1; + // Unconfirmed: "Postman is about to flee" + gSaveContext.save.weekEventReg[89] &= (u8)~0x40; + // Unconfirmed: "Postman has delivered priority mail" + gSaveContext.save.weekEventReg[89] &= (u8)~8; + // Unconfirmed: "Postman showing priority mail to Madame" + gSaveContext.save.weekEventReg[85] &= (u8)~0x80; +} + +/** + * Used by Song of Time (when clicking "Yes") and (indirectly) by the "Dawn of the New Day" cutscene + */ +void Sram_SaveEndOfCycle(GlobalContext* globalCtx) { + s16 sceneNum; + s32 j; + s32 i; + u8 temp; + u8 temp2; + + gSaveContext.save.daySpeed = 0; + gSaveContext.save.daysElapsed = 0; + gSaveContext.save.day = 0; + gSaveContext.save.time = CLOCK_TIME(6, 0) - 1; + + gSaveContext.save.playerData.deaths++; + if (gSaveContext.save.playerData.deaths > 999) { + gSaveContext.save.playerData.deaths = 999; + } + + sceneNum = Play_GetOriginalSceneNumber(globalCtx->sceneNum); + Play_SaveCycleSceneFlags(&globalCtx->state); + + globalCtx->actorCtx.flags.chest &= D_801C5FC0[sceneNum][2]; + globalCtx->actorCtx.flags.switches[0] &= D_801C5FC0[sceneNum][0]; + globalCtx->actorCtx.flags.switches[1] &= D_801C5FC0[sceneNum][1]; + globalCtx->actorCtx.flags.collectible[0] &= D_801C5FC0[sceneNum][3]; + globalCtx->actorCtx.flags.clearedRoom = 0; + + for (i = 0; i < SCENE_MAX; i++) { + gSaveContext.cycleSceneFlags[i].switch0 = ((void)0, gSaveContext.cycleSceneFlags[i].switch0) & D_801C5FC0[i][0]; + gSaveContext.cycleSceneFlags[i].switch1 = ((void)0, gSaveContext.cycleSceneFlags[i].switch1) & D_801C5FC0[i][1]; + gSaveContext.cycleSceneFlags[i].chest = ((void)0, gSaveContext.cycleSceneFlags[i].chest) & D_801C5FC0[i][2]; + gSaveContext.cycleSceneFlags[i].collectible = + ((void)0, gSaveContext.cycleSceneFlags[i].collectible) & D_801C5FC0[i][3]; + gSaveContext.cycleSceneFlags[i].clearedRoom = 0; + gSaveContext.save.permanentSceneFlags[i].unk_14 = 0; + gSaveContext.save.permanentSceneFlags[i].unk_18 = 0; + } + + for (; i < ARRAY_COUNT(gSaveContext.cycleSceneFlags); i++) { + gSaveContext.cycleSceneFlags[i].chest = 0; + gSaveContext.cycleSceneFlags[i].switch0 = 0; + gSaveContext.cycleSceneFlags[i].switch1 = 0; + gSaveContext.cycleSceneFlags[i].clearedRoom = 0; + gSaveContext.cycleSceneFlags[i].collectible = 0; + } + + for (i = 0; i < ARRAY_COUNT(gSaveContext.maskMaskBit); i++) { + gSaveContext.maskMaskBit[i] = 0; + } + + if (gSaveContext.save.weekEventReg[84] & 0x20) { + func_801149A0(ITEM_MASK_FIERCE_DEITY, SLOT(ITEM_MASK_FIERCE_DEITY)); + } + + for (i = 0; i < ARRAY_COUNT(D_801C66D0); i++) { + u16 phi_v1_3 = D_801C66D0[i]; + + for (j = 0; j < ARRAY_COUNT(D_801C6890); j++) { + if ((phi_v1_3 & 3) == 0) { + gSaveContext.save.weekEventReg[i] = + ((void)0, gSaveContext.save.weekEventReg[i]) & (0xFF ^ D_801C6890[j]); + } + phi_v1_3 >>= 2; + } + } + + for (i = 0; i < ARRAY_COUNT(gSaveContext.eventInf); i++) { + gSaveContext.eventInf[i] = 0; + } + + gSaveContext.eventInf[7] &= (u8)~1; + gSaveContext.eventInf[7] &= (u8)~2; + gSaveContext.eventInf[7] &= (u8)~4; + gSaveContext.eventInf[7] &= (u8)~8; + gSaveContext.eventInf[7] &= (u8)~0x10; + + if (gSaveContext.save.playerData.rupees != 0) { + gSaveContext.eventInf[7] |= 1; + } + + if (INV_CONTENT(ITEM_BOMB) == ITEM_BOMB) { + temp2 = INV_CONTENT(ITEM_BOMB); + if (AMMO(temp2) != 0) { + gSaveContext.eventInf[7] |= 2; + } + } + if (INV_CONTENT(ITEM_NUT) == ITEM_NUT) { + temp2 = INV_CONTENT(ITEM_NUT); + if (AMMO(temp2) != 0) { + gSaveContext.eventInf[7] |= 4; + } + } + if (INV_CONTENT(ITEM_STICK) == ITEM_STICK) { + temp2 = INV_CONTENT(ITEM_STICK); + if (AMMO(temp2) != 0) { + gSaveContext.eventInf[7] |= 8; + } + } + if (INV_CONTENT(ITEM_BOW) == ITEM_BOW) { + temp2 = INV_CONTENT(ITEM_BOW); + if (AMMO(temp2) != 0) { + gSaveContext.eventInf[7] |= 0x10; + } + } + + for (i = 0; i < ARRAY_COUNT(D_801C67B0); i++) { + if (D_801C67B0[i] != ITEM_NONE) { + if ((gSaveContext.save.inventory.items[i] != ITEM_NONE) && (i != SLOT_PICTO_BOX)) { + temp2 = gSaveContext.save.inventory.items[i]; + AMMO(temp2) = 0; + } + } + } + + for (i = SLOT_BOTTLE_1; i <= SLOT_BOTTLE_6; i++) { + // Check for all bottled items + if (gSaveContext.save.inventory.items[i] >= ITEM_POTION_RED) { + if (gSaveContext.save.inventory.items[i] <= ITEM_OBABA_DRINK) { + for (j = 1; j < 4; j++) { + if (GET_CUR_FORM_BTN_ITEM(j) == gSaveContext.save.inventory.items[i]) { + SET_CUR_FORM_BTN_ITEM(j, ITEM_BOTTLE); + func_80112B40(globalCtx, j); + } + } + gSaveContext.save.inventory.items[i] = ITEM_BOTTLE; + } + } + } + + REMOVE_QUEST_ITEM(QUEST_UNK_19); + + if (gSaveContext.save.playerData.health < 0x30) { + gSaveContext.save.playerData.health = 0x30; + } + + if (GET_CUR_EQUIP_VALUE(EQUIP_SWORD) < 3) { + SET_EQUIP_VALUE(EQUIP_SWORD, 1); + + if (CUR_FORM == 0) { + if ((STOLEN_ITEM_1 >= ITEM_SWORD_GILDED) || (STOLEN_ITEM_2 >= ITEM_SWORD_GILDED)) { + BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) = ITEM_SWORD_GILDED; + SET_EQUIP_VALUE(EQUIP_SWORD, 3); + } else { + BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) = ITEM_SWORD_KOKIRI; + } + } else { + if ((STOLEN_ITEM_1 >= ITEM_SWORD_GILDED) || (STOLEN_ITEM_2 >= ITEM_SWORD_GILDED)) { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_B) = ITEM_SWORD_GILDED; + SET_EQUIP_VALUE(EQUIP_SWORD, 3); + } else { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_B) = ITEM_SWORD_KOKIRI; + } + } + } + + if ((STOLEN_ITEM_1 == ITEM_SWORD_GREAT_FAIRY) || (STOLEN_ITEM_2 == ITEM_SWORD_GREAT_FAIRY)) { + INV_CONTENT(ITEM_SWORD_GREAT_FAIRY) = ITEM_SWORD_GREAT_FAIRY; + } + + if (STOLEN_ITEM_1 == ITEM_BOTTLE) { + temp = SLOT(ITEM_BOTTLE); + for (i = 0; i < 6; i++) { + if (gSaveContext.save.inventory.items[temp + i] == ITEM_NONE) { + gSaveContext.save.inventory.items[temp + i] = ITEM_BOTTLE; + break; + } + } + } + + if (STOLEN_ITEM_2 == ITEM_BOTTLE) { + temp = SLOT(ITEM_BOTTLE); + for (i = 0; i < 6; i++) { + if (gSaveContext.save.inventory.items[temp + i] == ITEM_NONE) { + gSaveContext.save.inventory.items[temp + i] = ITEM_BOTTLE; + break; + } + } + } + + SET_STOLEN_ITEM_1(STOLEN_ITEM_NONE); + SET_STOLEN_ITEM_2(STOLEN_ITEM_NONE); + + // ?? + func_801149A0(ITEM_OCARINA_FAIRY, SLOT_TRADE_DEED); + func_801149A0(ITEM_SLINGSHOT, SLOT_TRADE_KEY_MAMA); + func_801149A0(ITEM_LONGSHOT, SLOT_TRADE_COUPLE); + + for (j = 1; j < 4; j++) { + if (GET_CUR_FORM_BTN_ITEM(j) >= ITEM_MOON_TEAR && GET_CUR_FORM_BTN_ITEM(j) <= ITEM_PENDANT_MEMORIES) { + SET_CUR_FORM_BTN_ITEM(j, ITEM_NONE); + func_80112B40(globalCtx, j); + } + } + + gSaveContext.save.skullTokenCount &= ~0xFFFF0000; + gSaveContext.save.skullTokenCount &= ~0x0000FFFF; + gSaveContext.save.unk_EC4 = 0; + + gSaveContext.save.unk_E88[0] = 0; + gSaveContext.save.unk_E88[1] = 0; + gSaveContext.save.unk_E88[2] = 0; + gSaveContext.save.unk_E88[3] = 0; + gSaveContext.save.unk_E88[4] = 0; + gSaveContext.save.unk_E88[5] = 0; + gSaveContext.save.unk_E88[6] = 0; + + Sram_ClearHighscores(); + + for (i = 0; i < 8; i++) { + gSaveContext.save.inventory.dungeonItems[i] &= (u8)~1; + gSaveContext.save.inventory.dungeonKeys[i] = 0; + gSaveContext.save.inventory.strayFairies[i] = 0; + } + + gSaveContext.save.playerData.rupees = 0; + gSaveContext.save.unk_F65 = 0; + gSaveContext.powderKegTimer = 0; + gSaveContext.unk_1014 = 0; + gSaveContext.jinxTimer = 0; + gSaveContext.rupeeAccumulator = 0; + + func_800F3B2C(globalCtx); +} + +void Sram_IncrementDay(void) { + if (CURRENT_DAY <= 3) { + gSaveContext.save.day++; + gSaveContext.save.daysElapsed++; + } + + gSaveContext.save.bombersCaughtNum = 0; + gSaveContext.save.bombersCaughtOrder[0] = 0; + gSaveContext.save.bombersCaughtOrder[1] = 0; + gSaveContext.save.bombersCaughtOrder[2] = 0; + gSaveContext.save.bombersCaughtOrder[3] = 0; + gSaveContext.save.bombersCaughtOrder[4] = 0; + + // Unconfirmed: "Bombers Hide & Seek started on Day 1???" + gSaveContext.save.weekEventReg[73] &= (u8)~0x10; + // Unconfirmed: "Bombers Hide & Seek in Progress" + gSaveContext.save.weekEventReg[85] &= (u8)~2; +} + +u16 Sram_CalcChecksum(void* data, size_t count) { + u8* dataPtr = data; + u16 chkSum = 0; + + while (count-- > 0) { + chkSum += *dataPtr; + dataPtr++; + } + return chkSum; +} + +// Resets `Save` substruct +void Sram_ResetSave(void) { + gSaveContext.save.entranceIndex = 0x1C00; + gSaveContext.save.equippedMask = 0; + gSaveContext.save.isFirstCycle = false; + gSaveContext.save.unk_06 = 0; + gSaveContext.save.linkAge = 0; + gSaveContext.save.isNight = false; + gSaveContext.save.daySpeed = 0; + gSaveContext.save.snowheadCleared = 0; + gSaveContext.save.hasTatl = false; + gSaveContext.save.isOwlSave = false; + + // Instead of bloating all save context accesses with an extra sub-struct, the size of the would-be sub-struct + // is calculated manually + bzero(&gSaveContext.save.playerData, sizeof(Save) - offsetof(Save, playerData)); +} + +/** + * Initializes with random values the following fields: + * - lotteryCodes + * - spiderHouseMaskOrder + * - bomberCode + */ +void Sram_GenerateRandomSaveFields(void) { + s32 randBombers; + s16 sp2A; + s16 pad; + s16 i; + s16 j; + s32 k; + s16 randSpiderHouse; + + Sram_ClearHighscores(); + + gSaveContext.save.lotteryCodes[0][0] = Rand_S16Offset(0, 10); + gSaveContext.save.lotteryCodes[0][1] = Rand_S16Offset(0, 10); + gSaveContext.save.lotteryCodes[0][2] = Rand_S16Offset(0, 10); + gSaveContext.save.lotteryCodes[1][0] = Rand_S16Offset(0, 10); + gSaveContext.save.lotteryCodes[1][1] = Rand_S16Offset(0, 10); + gSaveContext.save.lotteryCodes[1][2] = Rand_S16Offset(0, 10); + gSaveContext.save.lotteryCodes[2][0] = Rand_S16Offset(0, 10); + gSaveContext.save.lotteryCodes[2][1] = Rand_S16Offset(0, 10); + gSaveContext.save.lotteryCodes[2][2] = Rand_S16Offset(0, 10); + + // Needed to match... + for (i = 0; i < 3; i++) { + for (j = 0; j < 3; j++) {} + } + + i = 0; + sp2A = Rand_S16Offset(0, 16) & 3; + k = 6; + while (i != k) { + randSpiderHouse = Rand_S16Offset(0, 16) & 3; + if (sp2A != randSpiderHouse) { + gSaveContext.save.spiderHouseMaskOrder[i] = randSpiderHouse; + i++; + sp2A = randSpiderHouse; + } + } + + do { + randBombers = Rand_S16Offset(0, 6); + } while (randBombers <= 0 || randBombers >= 6); + + gSaveContext.save.bomberCode[0] = randBombers; + + i = 1; + while (i != 5) { + k = false; + + do { + randBombers = Rand_S16Offset(0, 6); + } while (randBombers <= 0 || randBombers >= 6); + + sp2A = 0; + do { + if (randBombers == gSaveContext.save.bomberCode[sp2A]) { + k = true; + } + sp2A++; + } while (sp2A < i); + + if (k == false) { + gSaveContext.save.bomberCode[i] = randBombers; + i++; + } + } +} + +SavePlayerData sSaveDefaultPlayerData = { + { '\0', '\0', '\0', '\0', '\0', '\0' }, // newf + 0, // deaths + { 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E }, // playerName " " + 0x30, // healthCapacity + 0x30, // health + 0, // magicLevel + 0x30, // magic + 0, // rupees + 0, // swordHealth + 0, // tatlTimer + 0, // magicAcquired + 0, // doubleMagic + 0, // doubleDefense + 0, // unk_1F + 0xFF, // unk_20 + 0x0000, // owlActivationFlags + 0xFF, // unk_24 + SCENE_SPOT00, // savedSceneNum +}; + +ItemEquips sSaveDefaultItemEquips = { + { + { ITEM_SWORD_KOKIRI, ITEM_NONE, ITEM_NONE, ITEM_NONE }, + { ITEM_SWORD_KOKIRI, ITEM_NONE, ITEM_NONE, ITEM_NONE }, + { ITEM_SWORD_KOKIRI, ITEM_NONE, ITEM_NONE, ITEM_NONE }, + { ITEM_UNK_FD, ITEM_NONE, ITEM_NONE, ITEM_NONE }, + }, + { + { SLOT_OCARINA, SLOT_NONE, SLOT_NONE, SLOT_NONE }, + { SLOT_NONE, SLOT_NONE, SLOT_NONE, SLOT_NONE }, + { SLOT_NONE, SLOT_NONE, SLOT_NONE, SLOT_NONE }, + { SLOT_NONE, SLOT_NONE, SLOT_NONE, SLOT_NONE }, + }, + 0x11, +}; + +Inventory sSaveDefaultInventory = { + // items + { + ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, + ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, + ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, + ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, + ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, + }, + // ammo + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + // upgrades + 0x120000, + // questItems + 0, + // dungeonItems + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + // dungeonKeys + { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0 }, + // strayFairies + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + // dekuPlaygroundPlayerName + { + // "LINK " + { 0x15, 0x12, 0x17, 0x14, 0x3E, 0x3E, 0x3E, 0x3E }, + // "LINK " + { 0x15, 0x12, 0x17, 0x14, 0x3E, 0x3E, 0x3E, 0x3E }, + // "LINK " + { 0x15, 0x12, 0x17, 0x14, 0x3E, 0x3E, 0x3E, 0x3E }, + }, +}; + +u16 sSaveDefaultChecksum = 0; + +/** + * Initialize new save. + * This save has an empty inventory with 3 hearts, sword and shield. + */ +void Sram_InitNewSave(void) { + gSaveContext.save.playerForm = PLAYER_FORM_HUMAN; + gSaveContext.save.daysElapsed = 0; + gSaveContext.save.day = 0; + gSaveContext.save.time = CLOCK_TIME(6, 0) - 1; + Sram_ResetSave(); + + Lib_MemCpy(&gSaveContext.save.playerData, &sSaveDefaultPlayerData, sizeof(SavePlayerData)); + Lib_MemCpy(&gSaveContext.save.equips, &sSaveDefaultItemEquips, sizeof(ItemEquips)); + Lib_MemCpy(&gSaveContext.save.inventory, &sSaveDefaultInventory, sizeof(Inventory)); + Lib_MemCpy(&gSaveContext.save.checksum, &sSaveDefaultChecksum, sizeof(gSaveContext.save.checksum)); + + gSaveContext.save.horseData.scene = SCENE_F01; + gSaveContext.save.horseData.pos.x = -1420; + gSaveContext.save.horseData.pos.y = 257; + gSaveContext.save.horseData.pos.z = -1285; + gSaveContext.save.horseData.yaw = -0x7554; + + gSaveContext.nextCutsceneIndex = 0; + gSaveContext.save.playerData.magicLevel = 0; + Sram_GenerateRandomSaveFields(); +} + +SavePlayerData sSaveDebugPlayerData = { + { 'Z', 'E', 'L', 'D', 'A', '3' }, // newf + 0x0000, // deaths + { 0x15, 0x12, 0x17, 0x14, 0x3E, 0x3E, 0x3E, 0x3E }, // playerName "LINK " + 0x80, // healthCapacity + 0x80, // health + 0, // magicLevel + 0x30, // magic + 0x32, // rupees + 0x64, // swordHealth + 0, // tatlTimer + 1, // magicAcquired + 0, // doubleMagic + 0, // doubleDefense + 0, // unk_1F + 0xFF, // unk_20 + 0, // owlActivationFlags + 0xFF, // unk_24 + SCENE_SPOT00, // savedSceneNum +}; + +ItemEquips sSaveDebugItemEquips = { + { + { ITEM_SWORD_KOKIRI, ITEM_BOW, ITEM_POTION_RED, ITEM_OCARINA }, + { ITEM_SWORD_KOKIRI, ITEM_BOW, ITEM_MASK_GORON, ITEM_OCARINA }, + { ITEM_SWORD_KOKIRI, ITEM_BOW, ITEM_MASK_ZORA, ITEM_OCARINA }, + { ITEM_NUT, ITEM_NUT, ITEM_MASK_DEKU, ITEM_OCARINA }, + }, + { + { SLOT_OCARINA, SLOT_BOW, SLOT_BOTTLE_2, SLOT_OCARINA }, + { SLOT_OCARINA, SLOT_MAGIC_BEANS, SLOT_MASK_GORON, SLOT_BOMBCHU }, + { SLOT_OCARINA, SLOT_POWDER_KEG, SLOT_MASK_ZORA, SLOT_BOMBCHU }, + { SLOT_OCARINA, SLOT_BOW, SLOT_MASK_DEKU, SLOT_BOMBCHU }, + }, + 0x11, +}; + +Inventory sSaveDebugInventory = { + // items + { + ITEM_OCARINA, + ITEM_BOW, + ITEM_ARROW_FIRE, + ITEM_ARROW_ICE, + ITEM_ARROW_LIGHT, + ITEM_MOON_TEAR, + ITEM_BOMB, + ITEM_BOMBCHU, + ITEM_STICK, + ITEM_NUT, + ITEM_MAGIC_BEANS, + ITEM_ROOM_KEY, + ITEM_POWDER_KEG, + ITEM_PICTO_BOX, + ITEM_LENS, + ITEM_HOOKSHOT, + ITEM_SWORD_GREAT_FAIRY, + ITEM_LETTER_TO_KAFEI, + ITEM_BOTTLE, + ITEM_POTION_RED, + ITEM_POTION_GREEN, + ITEM_POTION_BLUE, + ITEM_NONE, + ITEM_NONE, + ITEM_MASK_POSTMAN, + ITEM_MASK_ALL_NIGHT, + ITEM_MASK_BLAST, + ITEM_MASK_STONE, + ITEM_MASK_GREAT_FAIRY, + ITEM_MASK_DEKU, + ITEM_MASK_KEATON, + ITEM_MASK_BREMEN, + ITEM_MASK_BUNNY, + ITEM_MASK_DON_GERO, + ITEM_MASK_SCENTS, + ITEM_MASK_GORON, + ITEM_MASK_ROMANI, + ITEM_MASK_CIRCUS_LEADER, + ITEM_MASK_KAFEIS_MASK, + ITEM_MASK_COUPLE, + ITEM_MASK_TRUTH, + ITEM_MASK_ZORA, + ITEM_MASK_KAMARO, + ITEM_MASK_GIBDO, + ITEM_MASK_GARO, + ITEM_MASK_CAPTAIN, + ITEM_MASK_GIANT, + ITEM_MASK_FIERCE_DEITY, + }, + // ammo + { 1, 30, 1, 1, 1, 1, 30, 30, 30, 30, 1, 1, 1, 1, 30, 1, 1, 1, 1, 1, 1, 1, 0, 0 }, + // upgrades + 0x120009, + // questItems + (1 << QUEST_SONG_SONATA) | (1 << QUEST_SONG_LULLABY) | (1 << QUEST_SONG_BOSSA_NOVA) | (1 << QUEST_SONG_ELEGY) | + (1 << QUEST_SONG_OATH) | (1 << QUEST_SONG_TIME) | (1 << QUEST_SONG_HEALING) | (1 << QUEST_SONG_EPONA) | + (1 << QUEST_SONG_SOARING) | (1 << QUEST_SONG_STORMS) | (1 << QUEST_BOMBERS_NOTEBOOK) | + (1 << QUEST_SONG_LULLABY_INTRO), + // dungeonItems + { 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 }, + // dungeonKeys + { 8, 8, 8, 8, 8, 8, 8, 8, 8, 0 }, + // strayFairies + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + // dekuPlaygroundPlayerName + { + // "LINK " + { 0x15, 0x12, 0x17, 0x14, 0x3E, 0x3E, 0x3E, 0x3E }, + // "LINK " + { 0x15, 0x12, 0x17, 0x14, 0x3E, 0x3E, 0x3E, 0x3E }, + // "LINK " + { 0x15, 0x12, 0x17, 0x14, 0x3E, 0x3E, 0x3E, 0x3E }, + }, +}; + +u16 sSaveDebugChecksum = 0; + +u8 D_801C6A48[] = { + ITEM_MASK_FIERCE_DEITY, ITEM_MASK_GORON, ITEM_MASK_ZORA, ITEM_MASK_DEKU, ITEM_MASK_FIERCE_DEITY, +}; + +u8 D_801C6A50[] = { + SLOT_MASK_FIERCE_DEITY, SLOT_MASK_GORON, SLOT_MASK_ZORA, SLOT_MASK_DEKU, SLOT_MASK_FIERCE_DEITY, +}; + +/** + * Initialize debug save. This is also used on the Title Screen + * This save has a mostly full inventory, every mask and 10 hearts. + * + * Some noteable flags that are set: + * TODO: Investigate the flags + */ +void Sram_InitDebugSave(void) { + Sram_ResetSave(); + + Lib_MemCpy(&gSaveContext.save.playerData, &sSaveDebugPlayerData, sizeof(SavePlayerData)); + Lib_MemCpy(&gSaveContext.save.equips, &sSaveDebugItemEquips, sizeof(ItemEquips)); + Lib_MemCpy(&gSaveContext.save.inventory, &sSaveDebugInventory, sizeof(Inventory)); + Lib_MemCpy(&gSaveContext.save.checksum, &sSaveDebugChecksum, sizeof(gSaveContext.save.checksum)); + + if (gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) { + BUTTON_ITEM_EQUIP(0, 2) = D_801C6A48[((void)0, gSaveContext.save.playerForm & 0xFF)]; + C_SLOT_EQUIP(0, 2) = D_801C6A50[((void)0, gSaveContext.save.playerForm & 0xFF)]; + } + + gSaveContext.save.hasTatl = true; + + gSaveContext.save.horseData.scene = SCENE_F01; + gSaveContext.save.horseData.pos.x = -1420; + gSaveContext.save.horseData.pos.y = 257; + gSaveContext.save.horseData.pos.z = -1285; + gSaveContext.save.horseData.yaw = -0x7554; + + gSaveContext.save.entranceIndex = 0x1C00; + gSaveContext.save.isFirstCycle = true; + + // + gSaveContext.save.weekEventReg[0x0F] |= 0x20; + // Unconfirmed: "Entered South Clock Town" + gSaveContext.save.weekEventReg[0x3B] |= 0x04; + // Unconfirmed: "Tatl's Second Cycle Text?" + gSaveContext.save.weekEventReg[0x1F] |= 0x04; + + gSaveContext.cycleSceneFlags[SCENE_INSIDETOWER].switch0 = 1; + gSaveContext.save.permanentSceneFlags[SCENE_INSIDETOWER].switch0 = 1; + gSaveContext.save.playerData.magicLevel = 0; + + Sram_GenerateRandomSaveFields(); +} + +// Unused +void func_80144A94(SramContext* sramCtx) { + s32 i; + s32 cutscene = gSaveContext.save.cutscene; + + bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); + + if (func_80185968(sramCtx->saveBuf, D_801C67C8[gSaveContext.fileNum * 2], D_801C67F0[gSaveContext.fileNum * 2]) != + 0) { + func_80185968(sramCtx->saveBuf, D_801C67C8[gSaveContext.fileNum * 2 + 1], + D_801C67F0[gSaveContext.fileNum * 2 + 1]); + } + Lib_MemCpy(&gSaveContext.save, sramCtx->saveBuf, sizeof(Save)); + if (CHECK_NEWF(gSaveContext.save.playerData.newf)) { + func_80185968(sramCtx->saveBuf, D_801C67C8[gSaveContext.fileNum * 2 + 1], + D_801C67F0[gSaveContext.fileNum * 2 + 1]); + Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, sizeof(Save)); + } + gSaveContext.save.cutscene = cutscene; + + for (i = 0; i < ARRAY_COUNT(gSaveContext.eventInf); i++) { + gSaveContext.eventInf[i] = 0; + } + + for (i = 0; i < ARRAY_COUNT(gSaveContext.cycleSceneFlags); i++) { + gSaveContext.cycleSceneFlags[i].chest = gSaveContext.save.permanentSceneFlags[i].chest; + gSaveContext.cycleSceneFlags[i].switch0 = gSaveContext.save.permanentSceneFlags[i].switch0; + gSaveContext.cycleSceneFlags[i].switch1 = gSaveContext.save.permanentSceneFlags[i].switch1; + gSaveContext.cycleSceneFlags[i].clearedRoom = gSaveContext.save.permanentSceneFlags[i].clearedRoom; + gSaveContext.cycleSceneFlags[i].collectible = gSaveContext.save.permanentSceneFlags[i].collectible; + } + + for (i = 0; i < ARRAY_COUNT(gSaveContext.unk_3DD0); i++) { + gSaveContext.unk_3DD0[i] = 0; + gSaveContext.unk_3DE0[i] = 0; + gSaveContext.unk_3E18[i] = 0; + gSaveContext.unk_3E50[i] = 0; + gSaveContext.unk_3E88[i] = 0; + gSaveContext.unk_3EC0[i] = 0; + } + + D_801BDAA0 = 1; + D_801BDA9C = 0; + gSaveContext.powderKegTimer = 0; + gSaveContext.unk_1014 = 0; + gSaveContext.jinxTimer = 0; +} + +u16 D_801C6A58[] = { 0x68B0, 0x6A60, 0xB230, 0x9A80, 0xD890, 0x3E40, 0x8640, 0x84A0, 0x2040, 0xAA30 }; + +#ifdef NON_MATCHING +// Small regalloc between v0/t6/t7 +void Sram_OpenSave(FileChooseContext* fileChooseCtx, SramContext* sramCtx) { + s32 i; + s32 pad; + s32 phi_t1; + s32 pad1[2]; + s32 fileNum; + + if (gSaveContext.unk_3F3F) { + bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); + + if (gSaveContext.fileNum == 0xFF) { + func_80185968(sramCtx->saveBuf, D_801C67C8[0], D_801C67F0[0]); + } else if (fileChooseCtx->unk_2446A[gSaveContext.fileNum] != 0) { + phi_t1 = gSaveContext.fileNum + 2; + phi_t1 *= 2; + + if (func_80185968(sramCtx->saveBuf, D_801C67C8[phi_t1], D_801C67F0[phi_t1]) != 0) { + func_80185968(sramCtx->saveBuf, D_801C67C8[phi_t1 + 1], D_801C67F0[phi_t1 + 1]); + } + } else { + phi_t1 = gSaveContext.fileNum; + phi_t1 *= 2; + + if (func_80185968(sramCtx->saveBuf, D_801C67C8[phi_t1], D_801C67F0[phi_t1]) != 0) { + func_80185968(sramCtx->saveBuf, D_801C67C8[phi_t1 + 1], D_801C67F0[phi_t1 + 1]); + } + } + + Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, D_801C6870[phi_t1]); + + if (CHECK_NEWF(gSaveContext.save.playerData.newf)) { + func_80185968(sramCtx->saveBuf, D_801C67C8[phi_t1 + 1], D_801C67F0[phi_t1 + 1]); + Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, D_801C6870[phi_t1]); + } + } + + gSaveContext.save.playerData.magicLevel = 0; + + if (!gSaveContext.save.isOwlSave) { + for (i = 0; i < ARRAY_COUNT(gSaveContext.eventInf); i++) { + gSaveContext.eventInf[i] = 0; + } + + for (i = 0; i < ARRAY_COUNT(gSaveContext.cycleSceneFlags); i++) { + gSaveContext.cycleSceneFlags[i].chest = gSaveContext.save.permanentSceneFlags[i].chest; + gSaveContext.cycleSceneFlags[i].switch0 = gSaveContext.save.permanentSceneFlags[i].switch0; + gSaveContext.cycleSceneFlags[i].switch1 = gSaveContext.save.permanentSceneFlags[i].switch1; + gSaveContext.cycleSceneFlags[i].clearedRoom = gSaveContext.save.permanentSceneFlags[i].clearedRoom; + gSaveContext.cycleSceneFlags[i].collectible = gSaveContext.save.permanentSceneFlags[i].collectible; + } + + for (i = 0; i < ARRAY_COUNT(gSaveContext.unk_3DD0); i++) { + gSaveContext.unk_3DD0[i] = 0; + gSaveContext.unk_3DE0[i] = 0; + gSaveContext.unk_3E18[i] = 0; + gSaveContext.unk_3E50[i] = 0; + gSaveContext.unk_3E88[i] = 0; + gSaveContext.unk_3EC0[i] = 0; + } + + if (gSaveContext.save.isFirstCycle) { + gSaveContext.save.entranceIndex = 0xD800; + gSaveContext.save.day = 0; + gSaveContext.save.time = 0x3FFF; + } else { + gSaveContext.save.entranceIndex = 0x1C00; + gSaveContext.nextCutsceneIndex = 0; + gSaveContext.save.playerForm = PLAYER_FORM_HUMAN; + } + } else { + gSaveContext.save.entranceIndex = D_801C6A58[gSaveContext.save.owlSaveLocation]; + if (D_801C6A58[gSaveContext.save.owlSaveLocation] == 0x84A0 && (gSaveContext.save.weekEventReg[20] & 2)) { + // Unconfirmed weekEventReg: "Woodfall Temple Prison Entrance raised / Water cleansed" + gSaveContext.save.entranceIndex = 0xCA0; + } else if (D_801C6A58[gSaveContext.save.owlSaveLocation] == 0x9A80 && + (gSaveContext.save.weekEventReg[33] & 0x80)) { + // Unconfirmed weekEventReg: "Mountain Village Unfrozen" + gSaveContext.save.entranceIndex = 0xAE80; + } + + for (i = 0; i < ARRAY_COUNT(gSaveContext.cycleSceneFlags); i++) { + gSaveContext.cycleSceneFlags[i].chest = gSaveContext.save.permanentSceneFlags[i].chest; + gSaveContext.cycleSceneFlags[i].switch0 = gSaveContext.save.permanentSceneFlags[i].switch0; + gSaveContext.cycleSceneFlags[i].switch1 = gSaveContext.save.permanentSceneFlags[i].switch1; + gSaveContext.cycleSceneFlags[i].clearedRoom = gSaveContext.save.permanentSceneFlags[i].clearedRoom; + gSaveContext.cycleSceneFlags[i].collectible = gSaveContext.save.permanentSceneFlags[i].collectible; + } + + if (gSaveContext.save.unk_F65) { + Lib_MemCpy(gScarecrowSpawnSongPtr, gSaveContext.save.scarecrowsSong, + sizeof(gSaveContext.save.scarecrowsSong)); + + for (i = 0; i != ARRAY_COUNT(gSaveContext.save.scarecrowsSong); i++) {} + } + + fileNum = gSaveContext.fileNum; + func_80147314(sramCtx, fileNum); + } +} +#else +#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/Sram_OpenSave.s") +#endif + +// Similar to func_80145698, but accounts for owl saves? +void func_8014546C(SramContext* sramCtx) { + s32 i; + + if (gSaveContext.save.isOwlSave) { + for (i = 0; i < ARRAY_COUNT(gSaveContext.cycleSceneFlags); i++) { + gSaveContext.save.permanentSceneFlags[i].chest = gSaveContext.cycleSceneFlags[i].chest; + gSaveContext.save.permanentSceneFlags[i].switch0 = gSaveContext.cycleSceneFlags[i].switch0; + gSaveContext.save.permanentSceneFlags[i].switch1 = gSaveContext.cycleSceneFlags[i].switch1; + gSaveContext.save.permanentSceneFlags[i].clearedRoom = gSaveContext.cycleSceneFlags[i].clearedRoom; + gSaveContext.save.permanentSceneFlags[i].collectible = gSaveContext.cycleSceneFlags[i].collectible; + } + + gSaveContext.save.checksum = 0; + gSaveContext.save.checksum = Sram_CalcChecksum(&gSaveContext, offsetof(SaveContext, fileNum)); + + Lib_MemCpy(sramCtx->saveBuf, &gSaveContext, offsetof(SaveContext, fileNum)); + } else { + for (i = 0; i < ARRAY_COUNT(gSaveContext.cycleSceneFlags); i++) { + gSaveContext.save.permanentSceneFlags[i].chest = gSaveContext.cycleSceneFlags[i].chest; + gSaveContext.save.permanentSceneFlags[i].switch0 = gSaveContext.cycleSceneFlags[i].switch0; + gSaveContext.save.permanentSceneFlags[i].switch1 = gSaveContext.cycleSceneFlags[i].switch1; + gSaveContext.save.permanentSceneFlags[i].clearedRoom = gSaveContext.cycleSceneFlags[i].clearedRoom; + gSaveContext.save.permanentSceneFlags[i].collectible = gSaveContext.cycleSceneFlags[i].collectible; + } + + gSaveContext.save.checksum = 0; + gSaveContext.save.checksum = Sram_CalcChecksum(&gSaveContext.save, sizeof(Save)); + + if (gSaveContext.unk_3F3F) { + Lib_MemCpy(sramCtx->saveBuf, &gSaveContext, sizeof(Save)); + Lib_MemCpy(&sramCtx->saveBuf[0x2000], &gSaveContext.save, sizeof(Save)); + } + } +} + +/** + * Save permanent scene flags, calculate checksum, copy save context to the save buffer + */ +void func_80145698(SramContext* sramCtx) { + s32 i; + + for (i = 0; i < ARRAY_COUNT(gSaveContext.cycleSceneFlags); i++) { + gSaveContext.save.permanentSceneFlags[i].chest = gSaveContext.cycleSceneFlags[i].chest; + gSaveContext.save.permanentSceneFlags[i].switch0 = gSaveContext.cycleSceneFlags[i].switch0; + gSaveContext.save.permanentSceneFlags[i].switch1 = gSaveContext.cycleSceneFlags[i].switch1; + gSaveContext.save.permanentSceneFlags[i].clearedRoom = gSaveContext.cycleSceneFlags[i].clearedRoom; + gSaveContext.save.permanentSceneFlags[i].collectible = gSaveContext.cycleSceneFlags[i].collectible; + } + + gSaveContext.save.checksum = 0; + gSaveContext.save.checksum = Sram_CalcChecksum(&gSaveContext.save, sizeof(Save)); + if (gSaveContext.unk_3F3F) { + Lib_MemCpy(sramCtx->saveBuf, &gSaveContext, sizeof(Save)); + Lib_MemCpy(&sramCtx->saveBuf[0x2000], &gSaveContext.save, sizeof(Save)); + } +} + +// Verifies save and use backup if corrupted? +#ifdef NON_EQUIVALENT +void func_801457CC(FileChooseContext* fileChooseCtx2, SramContext* sramCtx) { + FileChooseContext* fileChooseCtx = fileChooseCtx2; + u16 sp7A; + // u16 sp78; + u16 sp76; + // u16 sp74; + u16 sp6E; //! + // s32 sp68; + // u16 sp66; + u16 phi_s2; //! + u16 sp64; + // s32 sp60; + // s32 sp5C; + // s32 sp58; + // u32 new_var; + u16 phi_s2_3; + // s16 fakevar; + + u16 temp_s2; + u16 temp_v0_2; + u16 phi_a0; // maskCount + + if (gSaveContext.unk_3F3F) { + D_801F6AF0 = gSaveContext.save.time; + D_801F6AF2 = gSaveContext.unk_3F3F; + sp64 = 0; + + for (sp76 = 0; sp76 < 5; sp76++, sp64 += 2) { + bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); + + phi_s2 = false; + sp6E = 0; + if (func_80185968(sramCtx->saveBuf, D_801C67C8[sp64], D_801C67F0[sp64])) { + sp6E = 1; + if (func_80185968(sramCtx->saveBuf, D_801C67C8[sp64 + 1], D_801C67F0[sp64 + 1])) { + phi_s2 = true; + } + } + + if (sp76 < 2) { + fileChooseCtx->unk_24468[sp76] = 0; + if (phi_s2) { + bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); + Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, D_801C6870[sp64]); + } else { + // Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, D_801C6870[sp64]); + Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, D_801C6870[sp64]); + temp_s2 = gSaveContext.save.checksum; + gSaveContext.save.checksum = 0; + temp_v0_2 = Sram_CalcChecksum(&gSaveContext, D_801C6870[sp64]); + gSaveContext.save.checksum = temp_s2; + + if (CHECK_NEWF(gSaveContext.save.playerData.newf) || (temp_s2 != temp_v0_2)) { + sp6E = 1; + if (CHECK_NEWF2(gSaveContext.save.playerData.newf)) {} + + phi_s2 = false; + if (func_80185968(sramCtx->saveBuf, D_801C67C8[sp64 + 1], D_801C67F0[sp64 + 1])) { + phi_s2 = true; + } + + Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, D_801C6870[sp64]); + temp_s2 = gSaveContext.save.checksum; + gSaveContext.save.checksum = 0; + if (phi_s2 || CHECK_NEWF(gSaveContext.save.playerData.newf) || + (temp_s2 != Sram_CalcChecksum(&gSaveContext, D_801C6870[sp64]))) { + bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); + Lib_MemCpy(&gSaveContext.save, sramCtx->saveBuf, sizeof(Save)); + sp6E = 999; + } + } + } + + gSaveContext.save.checksum = 0; + gSaveContext.save.checksum = + Sram_CalcChecksum(&gSaveContext, D_801C6870[sp64 & 0xFFFFFFFF]); // TODO: Needed? + + for (sp7A = 0; sp7A < ARRAY_COUNT(gSaveContext.save.playerData.newf); sp7A++) { + fileChooseCtx->newf[sp76][sp7A] = gSaveContext.save.playerData.newf[sp7A]; + } + + if (!CHECK_NEWF(fileChooseCtx->newf[sp76])) { + fileChooseCtx->unk_2440C[sp76] = gSaveContext.save.playerData.deaths; + + for (sp7A = 0; sp7A < ARRAY_COUNT(gSaveContext.save.playerData.playerName); sp7A++) { + fileChooseCtx->unk_24414[sp76][sp7A] = gSaveContext.save.playerData.playerName[sp7A]; + } + + fileChooseCtx->healthCapacity[sp76] = gSaveContext.save.playerData.healthCapacity; + fileChooseCtx->health[sp76] = gSaveContext.save.playerData.health; + fileChooseCtx->unk_24454[sp76] = gSaveContext.save.inventory.dungeonKeys[9]; + fileChooseCtx->unk_24444[sp76] = gSaveContext.save.inventory.questItems; + fileChooseCtx->unk_24458[sp76] = gSaveContext.save.time; + fileChooseCtx->unk_24460[sp76] = gSaveContext.save.day; + fileChooseCtx->unk_24468[sp76] = gSaveContext.save.isOwlSave; + fileChooseCtx->rupees[sp76] = gSaveContext.save.playerData.rupees; + fileChooseCtx->unk_24474[sp76] = CUR_UPG_VALUE(4); + + for (sp7A = 0, phi_a0 = 0; sp7A < 24; sp7A++) { + if (gSaveContext.save.inventory.items[sp7A + 24] != 0xFF) { + phi_a0++; + } + } + fileChooseCtx->maskCount[sp76] = phi_a0; + fileChooseCtx->heartPieceCount[sp76] = + ((gSaveContext.save.inventory.questItems & 0xF0000000) >> 0x1C); + } + + if (sp6E == 1) { + Lib_MemCpy(&sramCtx->saveBuf[0x2000], &gSaveContext.save, sizeof(Save)); + func_80146EBC(sramCtx, D_801C67C8[sp64], D_801C6818[sp64]); + } else if (sp6E == 0) { // TODO: == 0? + temp_s2 = gSaveContext.save.checksum; + if (func_80185968(sramCtx->saveBuf, D_801C67C8[sp64 + 1], D_801C67F0[sp64 + 1])) { + phi_s2_3 = 1; + } else { + Lib_MemCpy(&gSaveContext.save, sramCtx->saveBuf, sizeof(Save)); + phi_s2_3 = gSaveContext.save.checksum; + gSaveContext.save.checksum = 0; + sp7A = Sram_CalcChecksum(&gSaveContext.save, sizeof(Save)); + } + + if (CHECK_NEWF(gSaveContext.save.playerData.newf) || (phi_s2_3 != sp7A) || (phi_s2_3 != temp_s2)) { + func_80185968(sramCtx->saveBuf, D_801C67C8[sp64], D_801C67F0[sp64]); + Lib_MemCpy(&gSaveContext.save, sramCtx->saveBuf, sizeof(Save)); + Lib_MemCpy(&sramCtx->saveBuf[0x2000], &gSaveContext.save, sizeof(Save)); + func_80146EBC(sramCtx, D_801C67C8[sp64], D_801C6818[sp64]); + } + } + } else if (sp76 < 4) { + fileChooseCtx->unk_24468[sp76] = 0; + + if (!CHECK_NEWF(fileChooseCtx->newf2[(s32)sp76])) { // TODO: Needed? + if (phi_s2) { + bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); + Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, + D_801C6870[sp64]); // TODO: Needed? + } else { + Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, D_801C6870[sp64]); + temp_s2 = gSaveContext.save.checksum; + + gSaveContext.save.checksum = 0; + temp_v0_2 = Sram_CalcChecksum(&gSaveContext, D_801C6870[sp64]); + gSaveContext.save.checksum = temp_s2; + if (CHECK_NEWF(gSaveContext.save.playerData.newf) || (temp_s2 != temp_v0_2)) { + sp6E = 1; + if ((gSaveContext.save.playerData.newf[0] == 'Z') && + (gSaveContext.save.playerData.newf[1] == 'E')) { + phi_s2 = false; + } + + if (func_80185968(sramCtx->saveBuf, D_801C67C8[sp64 + 1], D_801C67F0[sp64 + 1])) { + phi_s2 = true; + } + + Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, D_801C6870[sp64]); + temp_s2 = gSaveContext.save.checksum; + gSaveContext.save.checksum = 0; + if (phi_s2 || CHECK_NEWF(gSaveContext.save.playerData.newf) || + (temp_s2 != Sram_CalcChecksum(&gSaveContext, D_801C6870[sp64]))) { + bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); + Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, D_801C6870[sp64]); + sp6E = 999; + } + } + } + + gSaveContext.save.checksum = 0; + gSaveContext.save.checksum = + Sram_CalcChecksum(&gSaveContext, D_801C6870[sp64 & 0xFFFFFFFF]); // TODO: Needed? + + for (sp7A = 0; sp7A < ARRAY_COUNT(gSaveContext.save.playerData.newf); sp7A++) { + fileChooseCtx->newf[sp76][sp7A] = gSaveContext.save.playerData.newf[sp7A]; + } + + if (!CHECK_NEWF(fileChooseCtx->newf[sp76])) { + fileChooseCtx->unk_2440C[sp76] = gSaveContext.save.playerData.deaths; + + for (sp7A = 0; sp7A < ARRAY_COUNT(gSaveContext.save.playerData.playerName); sp7A++) { + phi_s2 += 0; // TODO: Needed? + fileChooseCtx->unk_24414[sp76][sp7A] = gSaveContext.save.playerData.playerName[sp7A]; + } + + fileChooseCtx->healthCapacity[sp76] = gSaveContext.save.playerData.healthCapacity; + fileChooseCtx->health[sp76] = gSaveContext.save.playerData.health; + fileChooseCtx->unk_24454[sp76] = gSaveContext.save.inventory.dungeonKeys[9]; + fileChooseCtx->unk_24444[sp76] = gSaveContext.save.inventory.questItems; + fileChooseCtx->unk_24458[sp76] = gSaveContext.save.time; + fileChooseCtx->unk_24460[sp76] = gSaveContext.save.day; + fileChooseCtx->unk_24468[sp76] = gSaveContext.save.isOwlSave; + fileChooseCtx->rupees[sp76] = gSaveContext.save.playerData.rupees; + fileChooseCtx->unk_24474[sp76] = CUR_UPG_VALUE(4); + + for (sp7A = 0, phi_a0 = 0; sp7A < 24; sp7A++) { + if (gSaveContext.save.inventory.items[sp7A + 24] != 0xFF) { + phi_a0++; + } + } + fileChooseCtx->maskCount[sp76] = phi_a0; + fileChooseCtx->heartPieceCount[sp76] = + ((gSaveContext.save.inventory.questItems & 0xF0000000) >> 0x1C); + } + + if (sp6E == 1) { + func_80146EBC(sramCtx, D_801C67C8[sp64], D_801C67F0[sp64]); + func_80146EBC(sramCtx, D_801C67C8[sp64 + 1], D_801C67F0[sp64 + 1]); + } else if (!sp6E) { // TODO: == 0? + temp_s2 = gSaveContext.save.checksum; + if (func_80185968(sramCtx->saveBuf, D_801C67C8[sp64 + 1], D_801C67F0[sp64 + 1])) { + phi_s2_3 = 1; + } else { + Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, D_801C6870[sp64]); + phi_s2_3 = gSaveContext.save.checksum; + gSaveContext.save.checksum = 0; + // phi_s2_3 = gSaveContext.save.checksum; + sp7A = Sram_CalcChecksum(&gSaveContext, D_801C6870[sp64]); + } + + if (CHECK_NEWF(gSaveContext.save.playerData.newf) || (phi_s2_3 != sp7A) || + (phi_s2_3 != temp_s2)) { + func_80185968(sramCtx->saveBuf, D_801C67C8[sp64], D_801C67F0[sp64]); + Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, D_801C6870[sp64]); + func_80146EBC(sramCtx, D_801C67C8[sp64], D_801C67F0[sp64]); + func_80146EBC(sramCtx, D_801C67C8[sp64 + 1], D_801C67F0[sp64 + 1]); + } + } + } else { + bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); + Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, D_801C6870[sp64]); + func_80146EBC(sramCtx, D_801C67C8[sp64], D_801C67F0[sp64]); + func_80146EBC(sramCtx, D_801C67C8[sp64 + 1], D_801C67F0[sp64 + 1]); + } + } else { + if (phi_s2) { + gSaveContext.options.optionId = 0xA51D; + gSaveContext.options.language = 1; + gSaveContext.options.audioSetting = 0; + gSaveContext.options.languageSetting = 0; + gSaveContext.options.zTargetSetting = 0; + } else { + Lib_MemCpy(&gSaveContext.options, sramCtx->saveBuf, sizeof(SaveOptions)); + if (gSaveContext.options.optionId != 0xA51D) { + gSaveContext.options.optionId = 0xA51D; + gSaveContext.options.language = 1; + gSaveContext.options.audioSetting = 0; + gSaveContext.options.languageSetting = 0; + gSaveContext.options.zTargetSetting = 0; + } + } + func_801A3D98(gSaveContext.options.audioSetting); + } + } + + gSaveContext.save.time = D_801F6AF0; + gSaveContext.unk_3F3F = D_801F6AF2; + } + + gSaveContext.options.language = 1; +} +#else #pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_801457CC.s") +#endif -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80146580.s") +void func_80146580(FileChooseContext* fileChooseCtx2, SramContext* sramCtx, s32 fileNum) { + FileChooseContext* fileChooseCtx = fileChooseCtx2; + s32 pad; + if (gSaveContext.unk_3F3F) { + if (fileChooseCtx->unk_2446A[fileNum]) { + func_80147314(sramCtx, fileNum); + fileChooseCtx->unk_2446A[fileNum] = 0; + } + bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); + Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, sizeof(Save)); + } + + gSaveContext.save.time = D_801F6AF0; + gSaveContext.unk_3F3F = D_801F6AF2; +} + +#ifdef NON_MATCHING +// v0/v1 +void func_80146628(FileChooseContext* fileChooseCtx2, SramContext* sramCtx) { + FileChooseContext* fileChooseCtx = fileChooseCtx2; + u16 i; + s16 maskCount; + + if (gSaveContext.unk_3F3F) { + if (fileChooseCtx->unk_2446A[fileChooseCtx->unk_2448E]) { + func_80147414(sramCtx, fileChooseCtx->unk_2448E, fileChooseCtx->fileNum); + fileChooseCtx->unk_24410[fileChooseCtx->fileNum] = gSaveContext.save.playerData.deaths; + + for (i = 0; i < ARRAY_COUNT(gSaveContext.save.playerData.playerName); i++) { + fileChooseCtx->unk_24424[fileChooseCtx->fileNum][i] = gSaveContext.save.playerData.playerName[i]; + } + + fileChooseCtx->unk_24438[fileChooseCtx->fileNum] = gSaveContext.save.playerData.healthCapacity; + fileChooseCtx->unk_24440[fileChooseCtx->fileNum] = gSaveContext.save.playerData.health; + fileChooseCtx->unk_24456[fileChooseCtx->fileNum] = gSaveContext.save.inventory.dungeonKeys[9]; + fileChooseCtx->unk_2444C[fileChooseCtx->fileNum] = gSaveContext.save.inventory.questItems; + fileChooseCtx->unk_2445C[fileChooseCtx->fileNum] = gSaveContext.save.time; + fileChooseCtx->unk_24464[fileChooseCtx->fileNum] = gSaveContext.save.day; + fileChooseCtx->unk_2446A[fileChooseCtx->fileNum] = gSaveContext.save.isOwlSave; + fileChooseCtx->unk_24470[fileChooseCtx->fileNum] = gSaveContext.save.playerData.rupees; + // = CUR_UPG_VALUE(UPG_WALLET); + fileChooseCtx->unk_24476[fileChooseCtx->fileNum] = + (gSaveContext.save.inventory.upgrades & gUpgradeMasks[4]) >> gUpgradeShifts[4]; + + for (i = 0, maskCount = 0; i < 24; i++) { + if (gSaveContext.save.inventory.items[i + 24] != ITEM_NONE) { + maskCount++; + } + } + + fileChooseCtx->unk_2447A[fileChooseCtx->fileNum] = maskCount; + fileChooseCtx->unk_2447E[fileChooseCtx->fileNum] = + (gSaveContext.save.inventory.questItems & 0xF0000000) >> 0x1C; + } + + // clear buffer + bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); + // read to buffer + func_80185968(sramCtx->saveBuf, D_801C67C8[fileChooseCtx->unk_2448E * 2], + D_801C67F0[fileChooseCtx->unk_2448E * 2]); + + if (1) {} + func_80185968(&sramCtx->saveBuf[0x2000], D_801C67C8[fileChooseCtx->unk_2448E * 2 + 1], + D_801C67F0[fileChooseCtx->unk_2448E * 2 + 1]); + if (1) {} + + // copy buffer to save context + Lib_MemCpy(&gSaveContext.save, sramCtx->saveBuf, sizeof(Save)); + + fileChooseCtx->unk_2440C[fileChooseCtx->fileNum] = gSaveContext.save.playerData.deaths; + + for (i = 0; i < ARRAY_COUNT(gSaveContext.save.playerData.playerName); i++) { + fileChooseCtx->unk_24414[fileChooseCtx->fileNum][i] = gSaveContext.save.playerData.playerName[i]; + } + + fileChooseCtx->healthCapacity[fileChooseCtx->fileNum] = gSaveContext.save.playerData.healthCapacity; + fileChooseCtx->health[fileChooseCtx->fileNum] = gSaveContext.save.playerData.health; + fileChooseCtx->unk_24454[fileChooseCtx->fileNum] = gSaveContext.save.inventory.dungeonKeys[9]; + fileChooseCtx->unk_24444[fileChooseCtx->fileNum] = gSaveContext.save.inventory.questItems; + fileChooseCtx->unk_24458[fileChooseCtx->fileNum] = gSaveContext.save.time; + fileChooseCtx->unk_24460[fileChooseCtx->fileNum] = gSaveContext.save.day; + fileChooseCtx->unk_24468[fileChooseCtx->fileNum] = gSaveContext.save.isOwlSave; + fileChooseCtx->rupees[fileChooseCtx->fileNum] = gSaveContext.save.playerData.rupees; + // = CUR_UPG_VALUE(UPG_WALLET); + fileChooseCtx->unk_24474[fileChooseCtx->fileNum] = + (gSaveContext.save.inventory.upgrades & gUpgradeMasks[4]) >> gUpgradeShifts[4]; + + for (i = 0, maskCount = 0; i < 24; i++) { + if (gSaveContext.save.inventory.items[i + 24] != ITEM_NONE) { + maskCount++; + } + } + + fileChooseCtx->maskCount[fileChooseCtx->fileNum] = maskCount; + fileChooseCtx->heartPieceCount[fileChooseCtx->fileNum] = + (gSaveContext.save.inventory.questItems & 0xF0000000) >> 0x1C; + } + + gSaveContext.save.time = D_801F6AF0; + gSaveContext.unk_3F3F = D_801F6AF2; +} +#else #pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80146628.s") +#endif -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80146AA0.s") +void Sram_InitSave(FileChooseContext* fileChooseCtx2, SramContext* sramCtx) { + s32 phi_v0; + u16 i; + FileChooseContext* fileChooseCtx = fileChooseCtx2; + s16 maskCount; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80146DF8.s") + if (gSaveContext.unk_3F3F) { + Sram_InitNewSave(); + if (fileChooseCtx->unk_24480 == 0) { + gSaveContext.save.cutscene = 0xFFF0; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80146E40.s") + for (phi_v0 = 0; phi_v0 < ARRAY_COUNT(gSaveContext.save.playerData.playerName); phi_v0++) { + gSaveContext.save.playerData.playerName[phi_v0] = + fileChooseCtx->unk_24414[fileChooseCtx->unk_24480][phi_v0]; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/Sram_Alloc.s") + gSaveContext.save.playerData.newf[0] = 'Z'; + gSaveContext.save.playerData.newf[1] = 'E'; + gSaveContext.save.playerData.newf[2] = 'L'; + gSaveContext.save.playerData.newf[3] = 'D'; + gSaveContext.save.playerData.newf[4] = 'A'; + gSaveContext.save.playerData.newf[5] = '3'; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80146EBC.s") + gSaveContext.save.checksum = Sram_CalcChecksum(&gSaveContext.save, sizeof(Save)); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80146EE8.s") + Lib_MemCpy(sramCtx->saveBuf, &gSaveContext.save, sizeof(Save)); + Lib_MemCpy(&sramCtx->saveBuf[0x2000], &gSaveContext.save, sizeof(Save)); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80146F5C.s") + for (i = 0; i < ARRAY_COUNT(gSaveContext.save.playerData.newf); i++) { + fileChooseCtx->newf[fileChooseCtx->unk_24480][i] = gSaveContext.save.playerData.newf[i]; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80147008.s") + fileChooseCtx->unk_2440C[fileChooseCtx->unk_24480] = gSaveContext.save.playerData.deaths; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80147020.s") + for (i = 0; i < ARRAY_COUNT(gSaveContext.save.playerData.playerName); i++) { + fileChooseCtx->unk_24414[fileChooseCtx->unk_24480][i] = gSaveContext.save.playerData.playerName[i]; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80147068.s") + fileChooseCtx->healthCapacity[fileChooseCtx->unk_24480] = gSaveContext.save.playerData.healthCapacity; + fileChooseCtx->health[fileChooseCtx->unk_24480] = gSaveContext.save.playerData.health; + fileChooseCtx->unk_24454[fileChooseCtx->unk_24480] = gSaveContext.save.inventory.dungeonKeys[9]; + fileChooseCtx->unk_24444[fileChooseCtx->unk_24480] = gSaveContext.save.inventory.questItems; + fileChooseCtx->unk_24458[fileChooseCtx->unk_24480] = gSaveContext.save.time; + fileChooseCtx->unk_24460[fileChooseCtx->unk_24480] = gSaveContext.save.day; + fileChooseCtx->unk_24468[fileChooseCtx->unk_24480] = gSaveContext.save.isOwlSave; + fileChooseCtx->rupees[fileChooseCtx->unk_24480] = gSaveContext.save.playerData.rupees; + fileChooseCtx->unk_24474[fileChooseCtx->unk_24480] = CUR_UPG_VALUE(UPG_WALLET); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80147138.s") + for (i = 0, maskCount = 0; i < 24; i++) { + if (gSaveContext.save.inventory.items[i + 24] != ITEM_NONE) { + maskCount++; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80147150.s") + fileChooseCtx->maskCount[fileChooseCtx->unk_24480] = maskCount; + fileChooseCtx->heartPieceCount[fileChooseCtx->unk_24480] = + (gSaveContext.save.inventory.questItems & 0xF0000000) >> 0x1C; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80147198.s") + gSaveContext.save.time = D_801F6AF0; + gSaveContext.unk_3F3F = D_801F6AF2; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80147314.s") +void func_80146DF8(SramContext* sramCtx) { + if (gSaveContext.unk_3F3F) { + // TODO: macros for languages + gSaveContext.options.language = 1; + Lib_MemCpy(sramCtx->saveBuf, &gSaveContext.options, sizeof(SaveOptions)); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80147414.s") +void Sram_InitSram(GameState* gameState, SramContext* sramCtx) { + if (gSaveContext.save.entranceIndex) {} // Required to match -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/Sram_nop8014750C.s") + func_801A3D98(gSaveContext.options.audioSetting); +} + +void Sram_Alloc(GameState* gamestate, SramContext* sramCtx) { + if (gSaveContext.unk_3F3F) { + sramCtx->saveBuf = THA_AllocEndAlign16(&gamestate->heap, SAVE_BUFFER_SIZE); + sramCtx->status = 0; + } +} + +/** + * Synchronous flash write + */ +void func_80146EBC(SramContext* sramCtx, s32 curPage, s32 numPages) { + sramCtx->curPage = curPage; + sramCtx->numPages = numPages; + func_80185F64(sramCtx->saveBuf, curPage, numPages); +} + +/** + * Saves the game on the very first time Player enters South Clock Town from the Clock Tower + */ +void Sram_SaveSpecialEnterClockTown(GlobalContext* globalCtx) { + s32 pad[2]; + SramContext* sramCtx = &globalCtx->sramCtx; + + gSaveContext.save.isFirstCycle = true; + gSaveContext.save.isOwlSave = false; + func_80145698(sramCtx); + func_80185F64(sramCtx->saveBuf, D_801C67C8[gSaveContext.fileNum * 2], D_801C6818[gSaveContext.fileNum * 2]); +} + +/** + * Saves when beating the game, after showing the "Dawn of the New Day" message + */ +void Sram_SaveSpecialNewDay(GlobalContext* globalCtx) { + s32 cutscene = gSaveContext.save.cutscene; + s32 day; + u16 time = gSaveContext.save.time; + + day = gSaveContext.save.day; + + // Unconfirmed: "Obtained Fierce Deity Mask?" + gSaveContext.save.weekEventReg[84] &= (u8)~0x20; + + Sram_SaveEndOfCycle(globalCtx); + func_8014546C(&globalCtx->sramCtx); + + gSaveContext.save.day = day; + gSaveContext.save.time = time; + gSaveContext.save.cutscene = cutscene; + func_80185F64(globalCtx->sramCtx.saveBuf, D_801C67C8[gSaveContext.fileNum * 2], + D_801C67F0[gSaveContext.fileNum * 2]); +} + +void func_80147008(SramContext* sramCtx, u32 curPage, u32 numPages) { + sramCtx->curPage = curPage; + sramCtx->numPages = numPages; + sramCtx->status = 1; +} + +void func_80147020(SramContext* sramCtx) { + // async flash write + func_80185DDC(sramCtx->saveBuf, sramCtx->curPage, sramCtx->numPages); + + sramCtx->unk_18 = osGetTime(); + sramCtx->status = 2; +} + +void func_80147068(SramContext* sramCtx) { + if (sramCtx->status == 2) { + if (func_80185EC4() != 0) { // if task running + if (func_80185F04() == 0) { // wait for task done + // task success + sramCtx->status = 4; + } else { + // task failure + sramCtx->status = 4; + } + } + } else if (((osGetTime() - sramCtx->unk_18) * 0x40) / 3000 / 10000 >= 200) { + sramCtx->status = 0; + } +} + +void func_80147138(SramContext* sramCtx, s32 curPage, s32 numPages) { + sramCtx->curPage = curPage; + sramCtx->numPages = numPages; + sramCtx->status = 6; +} + +void func_80147150(SramContext* sramCtx) { + func_80185DDC(sramCtx->saveBuf, sramCtx->curPage, sramCtx->numPages); + + sramCtx->unk_18 = osGetTime(); + sramCtx->status = 7; +} + +void func_80147198(SramContext* sramCtx) { + if (sramCtx->status == 7) { + if (func_80185EC4() != 0) { // Is task running + if (func_80185F04() == 0) { // Wait for task done + func_80185DDC(sramCtx->saveBuf, sramCtx->curPage + 0x80, sramCtx->numPages); + sramCtx->status = 8; + } else { + func_80185DDC(sramCtx->saveBuf, sramCtx->curPage + 0x80, sramCtx->numPages); + sramCtx->status = 8; + } + } + } else if (sramCtx->status == 8) { + if (func_80185EC4() != 0) { // Is task running + if (func_80185F04() == 0) { // Wait for task done + sramCtx->status = 4; + } else { + sramCtx->status = 4; + } + } + } else if (((osGetTime() - sramCtx->unk_18) * 0x40) / 3000 / 10000 >= 200) { + sramCtx->status = 0; + bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); + gSaveContext.save.isOwlSave = false; + gSaveContext.save.checksum = 0; + // flash read to buffer then copy to save context + func_80185968(sramCtx->saveBuf, sramCtx->curPage, sramCtx->numPages); + Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, offsetof(SaveContext, fileNum)); + } +} + +void func_80147314(SramContext* sramCtx, s32 fileNum) { + s32 pad; + + gSaveContext.save.isOwlSave = false; + + gSaveContext.save.playerData.newf[0] = '\0'; + gSaveContext.save.playerData.newf[1] = '\0'; + gSaveContext.save.playerData.newf[2] = '\0'; + gSaveContext.save.playerData.newf[3] = '\0'; + gSaveContext.save.playerData.newf[4] = '\0'; + gSaveContext.save.playerData.newf[5] = '\0'; + + gSaveContext.save.checksum = 0; + gSaveContext.save.checksum = Sram_CalcChecksum(&gSaveContext, offsetof(SaveContext, fileNum)); + + Lib_MemCpy(sramCtx->saveBuf, &gSaveContext, offsetof(SaveContext, fileNum)); + func_80146EBC(sramCtx, D_801C6840[fileNum * 2], D_801C6850[fileNum * 2]); + func_80146EBC(sramCtx, D_801C6840[fileNum * 2 + 1], D_801C6850[fileNum * 2]); + + gSaveContext.save.isOwlSave = true; + + gSaveContext.save.playerData.newf[0] = 'Z'; + gSaveContext.save.playerData.newf[1] = 'E'; + gSaveContext.save.playerData.newf[2] = 'L'; + gSaveContext.save.playerData.newf[3] = 'D'; + gSaveContext.save.playerData.newf[4] = 'A'; + gSaveContext.save.playerData.newf[5] = '3'; +} + +void func_80147414(SramContext* sramCtx, s32 fileNum, s32 arg2) { + s32 pad; + + // Clear save buffer + bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); + + // Read save file + if (func_80185968(sramCtx->saveBuf, D_801C6840[fileNum * 2], D_801C6850[fileNum * 2]) != 0) { + // If failed, read backup save file + func_80185968(sramCtx->saveBuf, D_801C6840[fileNum * 2 + 1], D_801C6850[fileNum * 2 + 1]); + } + + // Copy buffer to save context + Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, offsetof(SaveContext, fileNum)); + + func_80146EBC(sramCtx, D_801C6840[arg2 * 2], D_801C6850[arg2 * 2]); + func_80146EBC(sramCtx, D_801C6840[arg2 * 2 + 1], D_801C6850[arg2 * 2]); +} + +void Sram_nop8014750C(UNK_TYPE4 arg0) { +} diff --git a/src/code/z_sub_s.c b/src/code/z_sub_s.c index 52a5b07dac..b51de48970 100644 --- a/src/code/z_sub_s.c +++ b/src/code/z_sub_s.c @@ -6,10 +6,18 @@ #include "global.h" #include "overlays/actors/ovl_En_Door/z_en_door.h" +s16 sPathDayFlags[] = { 0x40, 0x20, 0x10, 8, 4, 2, 1, 0 }; + +#include "code/sub_s/sub_s.c" + +Vec3f gOneVec3f = { 1.0f, 1.0f, 1.0f }; + +s32 D_801C5DBC[] = { 0, 1 }; // Unused + /** - * Finds the first EnDoor instance with unk_1A4 == 5 and the specified unk_1A5. + * Finds the first EnDoor instance with unk_1A4 == 5 and the specified switchFlag. */ -EnDoor* SubS_FindDoor(GlobalContext* globalCtx, s32 unk_1A5) { +EnDoor* SubS_FindDoor(GlobalContext* globalCtx, s32 switchFlag) { Actor* actor = NULL; EnDoor* door; @@ -21,7 +29,7 @@ EnDoor* SubS_FindDoor(GlobalContext* globalCtx, s32 unk_1A5) { break; } - if ((door->unk_1A4 == 5) && (door->switchFlag == (u8)unk_1A5)) { + if ((door->unk_1A4 == 5) && (door->switchFlag == (u8)switchFlag)) { break; } @@ -150,7 +158,15 @@ Gfx* SubS_DrawTransformFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jo return gfx; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013AD6C.s") +s32 SubS_InCsMode(GlobalContext* globalCtx) { + s32 inCsMode = false; + + if (Play_InCsMode(globalCtx)) { + inCsMode = true; + } + + return inCsMode; +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013AD9C.s") @@ -170,7 +186,21 @@ void SubS_UpdateFlags(u16* flags, u16 setBits, u16 unsetBits) { #pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013B878.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013BB34.s") +Path* SubS_GetAdditionalPath(GlobalContext* globalCtx, u8 pathIndex, s32 max) { + Path* path; + s32 i = 0; + + do { + path = &globalCtx->setupPathList[pathIndex]; + if (i >= max) { + break; + } + pathIndex = path->unk1; + i++; + } while (pathIndex != 0xFF); + + return path; +} /** * Finds the nearest actor instance of a specified Id and category to an actor. @@ -228,23 +258,272 @@ s32 SubS_ChangeAnimationByInfoS(SkelAnime* skelAnime, AnimationInfoS* animations return true; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013BD40.s") +s32 SubS_HasReachedPoint(Actor* actor, Path* path, s32 pointIndex) { + Vec3s* points = Lib_SegmentedToVirtual(path->points); + s32 count = path->count; + s32 index = pointIndex; + s32 reached = false; + f32 diffX; + f32 diffZ; + f32 px; + f32 pz; + f32 d; + Vec3f point; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013BEDC.s") + Math_Vec3s_ToVec3f(&point, &points[index]); + + if (index == 0) { + diffX = points[1].x - points[0].x; + diffZ = points[1].z - points[0].z; + } else if (index == count - 1) { + diffX = points[count - 1].x - points[count - 2].x; + diffZ = points[count - 1].z - points[count - 2].z; + } else { + diffX = points[index + 1].x - points[index - 1].x; + diffZ = points[index + 1].z - points[index - 1].z; + } + + func_8017B7F8(&point, RADF_TO_BINANG(func_80086B30(diffX, diffZ)), &px, &pz, &d); + if (((px * actor->world.pos.x) + (pz * actor->world.pos.z) + d) > 0.0f) { + reached = true; + } + + return reached; +} + +Path* SubS_GetDayDependentPath(GlobalContext* globalCtx, u8 pathIndex, u8 max, s32* startPointIndex) { + Path* path = NULL; + s32 found = false; + s32 time = (((s16)TIME_TO_MINUTES_F(gSaveContext.save.time) % 60) + + ((s16)TIME_TO_MINUTES_F(gSaveContext.save.time) / 60) * 60) / + 30; + s32 day = CURRENT_DAY; + + if (pathIndex == max) { + return NULL; + } + + while (pathIndex != 0xFF) { + path = &globalCtx->setupPathList[pathIndex]; + if (sPathDayFlags[day] & path->unk2) { + found = true; + break; + } + pathIndex = path->unk1; + } + + if (found == true) { + *startPointIndex = time; + *startPointIndex = CLAMP(*startPointIndex, 0, path->count - 1); + } else { + *startPointIndex = 0; + } + + return path; +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013C068.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013C624.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013C8B8.s") +s32 SubS_CopyPointFromPathCheckBounds(Path* path, s32 pointIndex, Vec3f* dst) { + Vec3s* point; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013C964.s") + if ((path == NULL) || (pointIndex >= path->count) || (pointIndex < 0)) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013CC2C.s") + point = Lib_SegmentedToVirtual(path->points); + point = &point[pointIndex]; + dst->x = point->x; + dst->y = point->y; + dst->z = point->z; + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013CD64.s") +//! TODO: Needs docs with func_800B8500 +s32 func_8013C964(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 itemId, s32 type) { + s32 ret = false; + s16 x; + s16 y; + f32 xzDistToPlayerTemp; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013CF04.s") + Actor_GetScreenPos(globalCtx, actor, &x, &y); + + switch (type) { + case 1: + yRange = fabsf(actor->playerHeightRel) + 1.0f; + xzRange = actor->xzDistToPlayer + 1.0f; + ret = Actor_PickUp(actor, globalCtx, itemId, xzRange, yRange); + break; + case 2: + if ((fabsf(actor->playerHeightRel) <= yRange) && (actor->xzDistToPlayer <= xzRange)) { + ret = func_800B8500(actor, globalCtx, xzRange, yRange, itemId); + } + break; + case 3: + //! @bug: Both x and y conditionals are always true, || should be an && + if (((x >= 0) || (x < SCREEN_WIDTH)) && ((y >= 0) || (y < SCREEN_HEIGHT))) { + ret = func_800B8500(actor, globalCtx, xzRange, yRange, itemId); + } + break; + case 4: + yRange = fabsf(actor->playerHeightRel) + 1.0f; + xzRange = actor->xzDistToPlayer + 1.0f; + xzDistToPlayerTemp = actor->xzDistToPlayer; + actor->xzDistToPlayer = 0.0f; + actor->flags |= 0x10000; + ret = func_800B8500(actor, globalCtx, xzRange, yRange, itemId); + actor->xzDistToPlayer = xzDistToPlayerTemp; + break; + case 5: + //! @bug: Both x and y conditionals are always true, || should be an && + if (((x >= 0) || (x < SCREEN_WIDTH)) && ((y >= 0) || (y < SCREEN_HEIGHT)) && + (fabsf(actor->playerHeightRel) <= yRange) && (actor->xzDistToPlayer <= xzRange) && actor->isTargeted) { + actor->flags |= 0x10000; + ret = func_800B8500(actor, globalCtx, xzRange, yRange, itemId); + } + break; + case 6: + //! @bug: Both x and y conditionals are always true, || should be an && + if (((x >= 0) || (x < SCREEN_WIDTH)) && ((y >= 0) || (y < SCREEN_HEIGHT)) && + (fabsf(actor->playerHeightRel) <= yRange) && (actor->xzDistToPlayer <= xzRange)) { + actor->flags |= 0x10000; + ret = func_800B8500(actor, globalCtx, xzRange, yRange, itemId); + } + break; + } + return ret; +} + +const u8 sShadowMaps[4][12][12] = { + { + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0 }, + { 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0 }, + { 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0 }, + { 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0 }, + { 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + }, + { + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0 }, + { 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0 }, + { 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 }, + { 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 }, + { 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 }, + { 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0 }, + { 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + }, + { + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0 }, + { 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0 }, + { 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 }, + { 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 }, + { 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 }, + { 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 }, + { 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0 }, + { 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + }, + { + { 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0 }, + { 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 }, + { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 }, + { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 }, + { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, + { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, + { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, + { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, + { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 }, + { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 }, + { 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 }, + { 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0 }, + }, +}; + +void SubS_FillShadowTex(s32 startCol, s32 startRow, u8* tex, s32 size) { + s32 i; + s32 j; + s32 start; + + for (i = 0; i < 12; i++) { + start = ((startRow + i) * 64) + startCol - 390; + for (j = 0; j < 12; j++) { + if (sShadowMaps[size][i][j] != 0) { + if ((start + j >= 0) && (start + j < SUBS_SHADOW_TEX_SIZE)) { + tex[start + j] = 255; + } + } + } + } +} + +void SubS_GenShadowTex(Vec3f bodyPartsPos[], Vec3f* worldPos, u8* tex, f32 tween, u8 bodyPartsNum, u8 sizes[], + s8 parentBodyParts[]) { + Vec3f pos; + Vec3f startVec; + s32 i; + s32 parentBodyPart; + Vec3f* bodyPartPos; + s32 startCol; + s32 startRow; + + for (i = 0; i < bodyPartsNum; i++) { + if (parentBodyParts[i] >= 0) { + parentBodyPart = parentBodyParts[i]; + bodyPartPos = &bodyPartsPos[i]; + + pos.x = (bodyPartsPos[parentBodyPart].x - bodyPartPos->x) * tween + (bodyPartPos->x - worldPos->x); + pos.y = (bodyPartsPos[parentBodyPart].y - bodyPartPos->y) * tween + (bodyPartPos->y - worldPos->y); + pos.z = (bodyPartsPos[parentBodyPart].z - bodyPartPos->z) * tween + (bodyPartPos->z - worldPos->z); + } else { + bodyPartPos = &bodyPartsPos[i]; + + pos.x = bodyPartPos->x - worldPos->x; + pos.y = bodyPartPos->y - worldPos->y; + pos.z = bodyPartPos->z - worldPos->z; + } + + Matrix_MultiplyVector3fByState(&pos, &startVec); + startCol = 64.0f + startVec.x; + startRow = 64.0f - startVec.z; + SubS_FillShadowTex(startCol >> 1, startRow >> 1, tex, sizes[i]); + } +} + +void SubS_DrawShadowTex(Actor* actor, GameState* gameState, u8* tex) { + s32 pad; + GraphicsContext* gfxCtx = gameState->gfxCtx; + + OPEN_DISPS(gfxCtx); + + func_8012C28C(gfxCtx); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 0, 100); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0); + Matrix_InsertTranslation(actor->world.pos.x, 0.0f, actor->world.pos.z, MTXMODE_NEW); + Matrix_Scale(0.6f, 1.0f, 0.6f, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gShadowDL); + gDPLoadTextureBlock(POLY_OPA_DISP++, tex, G_IM_FMT_I, G_IM_SIZ_8b, SUBS_SHADOW_TEX_WIDTH, SUBS_SHADOW_TEX_HEIGHT, 0, + G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, 6, 6, G_TX_NOLOD, G_TX_NOLOD); + gSPDisplayList(POLY_OPA_DISP++, gShadowVtxDL); + + CLOSE_DISPS(gfxCtx); +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D0E0.s") @@ -254,15 +533,68 @@ s32 SubS_AngleDiffLessEqual(s16 angleA, s16 threshold, s16 angleB) { return (ABS_ALT(BINANG_SUB(angleB, angleA)) <= threshold) ? true : false; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D648.s") +Path* SubS_GetPathByIndex(GlobalContext* globalCtx, s16 pathIndex, s16 max) { + return (pathIndex != max) ? &globalCtx->setupPathList[pathIndex] : NULL; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D68C.s") +s32 SubS_CopyPointFromPath(Path* path, s32 pointIndex, Vec3f* dst) { + Vec3s* point; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D720.s") + if (path == NULL) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D768.s") + point = Lib_SegmentedToVirtual(path->points); + point = &point[pointIndex]; + dst->x = point->x; + dst->y = point->y; + dst->z = point->z; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D83C.s") + return true; +} + +s16 SubS_GetDistSqAndOrientPoints(Vec3f* vecA, Vec3f* vecB, f32* distSq) { + f32 diffX = vecA->x - vecB->x; + f32 diffZ = vecA->z - vecB->z; + + *distSq = SQ(diffX) + SQ(diffZ); + return Math_Atan2S(diffX, diffZ); +} + +/** + * Returns true when the actor has reached the inputed point + */ +s32 SubS_MoveActorToPoint(Actor* actor, Vec3f* point, s16 rotStep) { + Vec3f offsetBefore; + Vec3f offsetAfter; + f32 distSqBefore; + f32 distSqAfter; + + Actor_OffsetOfPointInActorCoords(actor, &offsetBefore, point); + Math_SmoothStepToS(&actor->world.rot.y, SubS_GetDistSqAndOrientPoints(point, &actor->world.pos, &distSqBefore), 4, + rotStep, 1); + actor->shape.rot.y = actor->world.rot.y; + Actor_MoveWithGravity(actor); + Actor_OffsetOfPointInActorCoords(actor, &offsetAfter, point); + SubS_GetDistSqAndOrientPoints(point, &actor->world.pos, &distSqAfter); + return ((offsetBefore.z > 0.0f) && (offsetAfter.z <= 0.0f)) ? true : false; +} + +s16 SubS_GetDistSqAndOrientPath(Path* path, s32 pointIndex, Vec3f* pos, f32* distSq) { + Vec3s* point; + f32 diffX = 0.0f; + f32 diffZ = 0.0f; + + if (path != NULL) { + point = Lib_SegmentedToVirtual(path->points); + point = &point[pointIndex]; + diffX = point->x - pos->x; + diffZ = point->z - pos->z; + } + + *distSq = SQ(diffX) + SQ(diffZ); + return Math_Atan2S(diffX, diffZ); +} s8 SubS_IsObjectLoaded(s8 index, GlobalContext* globalCtx) { return !Object_IsLoaded(&globalCtx->objectCtx, index) ? false : true; @@ -301,23 +633,166 @@ s32 SubS_FillLimbRotTables(GlobalContext* globalCtx, s16* limbRotTableY, s16* li return true; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013DB90.s") +s32 SubS_IsFloorAbove(GlobalContext* globalCtx, Vec3f* pos, f32 distAbove) { + CollisionPoly* outPoly; + Vec3f posA; + Vec3f posB; + Vec3f posResult; + s32 bgId; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013DC40.s") + posA = posB = *pos; + posB.y += distAbove; + return BgCheck_EntityLineTest1(&globalCtx->colCtx, &posA, &posB, &posResult, &outPoly, false, true, false, true, + &bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013DCCC.s") +s32 SubS_CopyPointFromPathList(Path* paths, s32 pathIndex, s32 pointIndex, Vec3f* dst) { + Path* path = &paths[pathIndex]; + Vec3s* point = &((Vec3s*)Lib_SegmentedToVirtual(path->points))[pointIndex]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013DCE0.s") + dst->x = point->x; + dst->y = point->y; + dst->z = point->z; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013DE04.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013DF3C.s") +u8 SubS_GetPathCount(Path* paths, s32 index) { + Path* path = &paths[index]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E054.s") + return path->count; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E07C.s") +void SubS_ActorPathing_Init(GlobalContext* globalCtx, Vec3f* worldPos, Actor* actor, ActorPathing* actorPath, + Path* paths, s32 pathIndex, s32 begPointIndex, s32 endPointIndex, s32 curPointIndex, + u8 flags) { + Path* path; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E0A4.s") + actorPath->setupPathList = globalCtx->setupPathList; + actorPath->pathIndex = pathIndex; + path = &paths[pathIndex]; + actorPath->points = Lib_SegmentedToVirtual(path->points); + actorPath->count = path->count; + actorPath->begPointIndex = begPointIndex; + if (endPointIndex == 0) { + actorPath->endPointIndex = actorPath->count - 1; + } else if (endPointIndex > 0) { + actorPath->endPointIndex = endPointIndex; + } else { + //! @bug: endPointIndex is negative, subtraction causes result to be past the end + actorPath->endPointIndex = (actorPath->count - endPointIndex) - 1; + } + actorPath->curPointIndex = curPointIndex; + actorPath->curPoint.x = actorPath->points[0].x; + actorPath->curPoint.y = actorPath->points[0].y; + actorPath->curPoint.z = actorPath->points[0].z; + Math_Vec3f_Copy(&actorPath->prevPoint, &actorPath->curPoint); + actorPath->worldPos = worldPos; + actorPath->actor = actor; + actorPath->flags = flags; + actorPath->prevFlags = flags; +} + +s32 SubS_ActorPathing_Update(GlobalContext* globalCtx, ActorPathing* actorPath, + ActorPathingComputeFunc computePointInfoFunc, ActorPathingUpdateFunc updateActorInfoFunc, + ActorPathingUpdateFunc moveFunc, ActorPathingUpdateFunc setNextPointFunc) { + s32 shouldSetNextPoint; + s32 reupdate; + + actorPath->computePointInfoFunc = computePointInfoFunc; + actorPath->updateActorInfoFunc = updateActorInfoFunc; + actorPath->moveFunc = moveFunc; + actorPath->setNextPointFunc = setNextPointFunc; + actorPath->flags &= ~ACTOR_PATHING_REACHED_TEMPORARY; + reupdate = false; + if (actorPath->flags & ACTOR_PATHING_MOVE_BACKWARDS) { + if (!(actorPath->prevFlags & ACTOR_PATHING_MOVE_BACKWARDS)) { + actorPath->curPointIndex--; + } + } else if (actorPath->prevFlags & ACTOR_PATHING_MOVE_BACKWARDS) { + actorPath->curPointIndex++; + } + do { + shouldSetNextPoint = false; + if (actorPath->computePointInfoFunc != NULL) { + actorPath->computePointInfoFunc(globalCtx, actorPath); + } + if (actorPath->updateActorInfoFunc != NULL) { + shouldSetNextPoint = actorPath->updateActorInfoFunc(globalCtx, actorPath); + } + if (shouldSetNextPoint) { + if (actorPath->setNextPointFunc != NULL) { + reupdate = actorPath->setNextPointFunc(globalCtx, actorPath); + } + } else if (actorPath->moveFunc != NULL) { + reupdate = actorPath->moveFunc(globalCtx, actorPath); + } + } while (reupdate); + actorPath->prevFlags = actorPath->flags; + return false; +} + +void SubS_ActorPathing_ComputePointInfo(GlobalContext* globalCtx, ActorPathing* actorPath) { + Vec3f diff; + + actorPath->curPoint.x = actorPath->points[actorPath->curPointIndex].x + actorPath->pointOffset.x; + actorPath->curPoint.y = actorPath->points[actorPath->curPointIndex].y + actorPath->pointOffset.y; + actorPath->curPoint.z = actorPath->points[actorPath->curPointIndex].z + actorPath->pointOffset.z; + diff.x = actorPath->curPoint.x - actorPath->worldPos->x; + diff.y = actorPath->curPoint.y - actorPath->worldPos->y; + diff.z = actorPath->curPoint.z - actorPath->worldPos->z; + actorPath->distSqToCurPointXZ = Math3D_XZLengthSquared(diff.x, diff.z); + actorPath->distSqToCurPoint = Math3D_LengthSquared(&diff); + actorPath->rotToCurPoint.y = Math_FAtan2F(diff.z, diff.x); + actorPath->rotToCurPoint.x = Math_FAtan2F(sqrtf(actorPath->distSqToCurPointXZ), -diff.y); + actorPath->rotToCurPoint.z = 0; +} + +s32 SubS_ActorPathing_MoveWithGravity(GlobalContext* globalCtx, ActorPathing* actorPath) { + Actor_MoveWithGravity(actorPath->actor); + return false; +} + +s32 SubS_ActorPathing_MoveWithoutGravityReverse(GlobalContext* globalCtx, ActorPathing* actorPath) { + Actor_MoveWithoutGravityReverse(actorPath->actor); + return false; +} + +s32 SubS_ActorPathing_SetNextPoint(GlobalContext* globalCtx, ActorPathing* actorPath) { + s32 reupdate = true; + + Math_Vec3f_Copy(&actorPath->prevPoint, &actorPath->curPoint); + if (!(actorPath->flags & ACTOR_PATHING_MOVE_BACKWARDS)) { + if (actorPath->curPointIndex >= actorPath->endPointIndex) { + if (actorPath->flags & ACTOR_PATHING_RETURN_TO_START) { + actorPath->curPointIndex = actorPath->begPointIndex; + } else if (actorPath->flags & ACTOR_PATHING_SWITCH_DIRECTION) { + actorPath->flags |= ACTOR_PATHING_MOVE_BACKWARDS; + } else { + reupdate = false; + } + actorPath->flags |= ACTOR_PATHING_REACHED_END; + } else { + actorPath->curPointIndex++; + } + actorPath->flags |= ACTOR_PATHING_REACHED_POINT; + } else { + if (actorPath->begPointIndex >= actorPath->curPointIndex) { + if (actorPath->flags & ACTOR_PATHING_RETURN_TO_START) { + actorPath->curPointIndex = actorPath->endPointIndex; + } else if (actorPath->flags & ACTOR_PATHING_SWITCH_DIRECTION) { + actorPath->flags &= ~ACTOR_PATHING_MOVE_BACKWARDS; + } else { + reupdate = false; + } + actorPath->flags |= ACTOR_PATHING_REACHED_END; + } else { + actorPath->curPointIndex--; + } + } + actorPath->flags |= ACTOR_PATHING_REACHED_POINT; + return reupdate; +} void SubS_ChangeAnimationBySpeedInfo(SkelAnime* skelAnime, AnimationSpeedInfo* animations, s32 nextIndex, s32* curIndex) { @@ -397,9 +872,58 @@ s32 SubS_FillCutscenesList(Actor* actor, s16 cutscenes[], s16 numCutscenes) { return i; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E4B0.s") +/** + * Computes a plane based on a point on the plane, a unit vector and two angles + * + * @param[in] point a point on the plane + * @param[in] unitVec the unit vector rotated that becomes the plane's normal + * @param[in] rot the angles to rotate with, uses just the x and y components + * @param[out] plane the computed plane + * + * Notes: + * The unit input vector is expected to already be normalized (only uses are with the z unit vector) + * + */ +void SubS_ConstructPlane(Vec3f* point, Vec3f* unitVec, Vec3s* rot, Plane* plane) { + f32 sin; + f32 cos; + f32 temp; + f32 unitVecZ; + f32 normY; + f32 unitVecYX; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E5CC.s") + sin = Math_SinS(-rot->x); + cos = Math_CosS(-rot->x); + unitVecZ = unitVec->z; + unitVecYX = unitVec->y; + + // Apply a rotation by -x about the X axis + temp = (unitVecZ * cos) - (unitVecYX * sin); + normY = (unitVecZ * sin) + (unitVecYX * cos); + + sin = Math_SinS(rot->y); + cos = Math_CosS(rot->y); + unitVecYX = unitVec->x; + plane->normal.y = normY; + + // Apply a rotation by y about the Y axis + plane->normal.z = (temp * cos) - (unitVecYX * sin); + plane->normal.x = (temp * sin) + (unitVecYX * cos); + + plane->originDist = -((point->x * plane->normal.x) + (plane->normal.y * point->y) + (plane->normal.z * point->z)); +} + +s32 SubS_LineSegVsPlane(Vec3f* point, Vec3s* rot, Vec3f* unitVec, Vec3f* linePointA, Vec3f* linePointB, + Vec3f* intersect) { + s32 lineSegVsPlane; + Plane plane; + + SubS_ConstructPlane(point, unitVec, rot, &plane); + lineSegVsPlane = Math3D_LineSegVsPlane(plane.normal.x, plane.normal.y, plane.normal.z, plane.originDist, linePointA, + linePointB, intersect, false); + + return lineSegVsPlane ? true : false; +} /** * Finds the first actor instance of a specified Id and category verified with a custom callback. @@ -423,10 +947,44 @@ Actor* SubS_FindActorCustom(GlobalContext* globalCtx, Actor* actor, Actor* actor return actorIter; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E748.s") +//! TODO: Needs docs with func_800B8500 +s32 func_8013E748(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 exchangeItemId, void* data, + func_8013E748_VerifyFunc verifyFunc) { + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E7C0.s") + if ((verifyFunc == NULL) || ((verifyFunc != NULL) && verifyFunc(globalCtx, actor, data))) { + ret = func_800B8500(actor, globalCtx, xzRange, yRange, exchangeItemId); + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E8F8.s") +s32 SubS_ActorAndPlayerFaceEachOther(GlobalContext* globalCtx, Actor* actor, void* data) { + Player* player = GET_PLAYER(globalCtx); + Vec3s* yawTols = (Vec3s*)data; + s16 playerYaw = ABS(BINANG_SUB(Actor_YawBetweenActors(&player->actor, actor), player->actor.shape.rot.y)); + s16 actorYaw = ABS(BINANG_SUB(actor->yawTowardsPlayer, actor->shape.rot.y)); + s32 areFacing = false; + s32 actorYawTol = ABS(yawTols->y); + s32 playerYawTol; + + if (actorYaw < (s16)actorYawTol) { + playerYawTol = ABS(yawTols->x); + if (playerYaw < (s16)playerYawTol) { + areFacing = true; + } + } + + return areFacing; +} + +//! TODO: Needs docs with func_800B8500 +s32 func_8013E8F8(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 exhangeItemId, s16 playerYawTol, + s16 actorYawTol) { + Vec3s yawTols; + + yawTols.x = playerYawTol; + yawTols.y = actorYawTol; + return func_8013E748(actor, globalCtx, xzRange, yRange, exhangeItemId, &yawTols, SubS_ActorAndPlayerFaceEachOther); +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E950.s") diff --git a/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c b/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c index e85e3791ad..0b9bedbb8e 100644 --- a/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c +++ b/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c @@ -5,6 +5,7 @@ */ #include "z_arrow_fire.h" +#include "overlays/actors/ovl_En_Arrow/z_en_arrow.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000) @@ -15,19 +16,10 @@ void ArrowFire_Destroy(Actor* thisx, GlobalContext* globalCtx); void ArrowFire_Update(Actor* thisx, GlobalContext* globalCtx); void ArrowFire_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80920440(ArrowFire* this, GlobalContext* globalCtx); -void func_8092058C(ArrowFire* this, GlobalContext* globalCtx); -void func_809207A0(ArrowFire* this, GlobalContext* globalCtx); +void FireArrow_ChargeAndWait(ArrowFire* this, GlobalContext* globalCtx); +void FireArrow_Fly(ArrowFire* this, GlobalContext* globalCtx); -void ArrowFire_SetupAction(ArrowFire* this, ArrowFireActionFunc actionFunc); - -#if 0 -// static ColliderQuadInit sQuadInit = { -static ColliderQuadInit D_80922230 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_PLAYER, AC_NONE, OC1_NONE, OC2_TYPE_PLAYER, COLSHAPE_QUAD, }, - { ELEMTYPE_UNK0, { 0x08000000, 0x00, 0x02 }, { 0x00000000, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_NONE, }, - { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, -}; +#include "overlays/ovl_Arrow_fire/ovl_Arrow_Fire.c" const ActorInit Arrow_Fire_InitVars = { ACTOR_ARROW_FIRE, @@ -41,29 +33,264 @@ const ActorInit Arrow_Fire_InitVars = { (ActorFunc)ArrowFire_Draw, }; -#endif +static ColliderQuadInit sQuadInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_PLAYER, + AC_NONE, + OC1_NONE, + OC2_TYPE_PLAYER, + COLSHAPE_QUAD, + }, + { + ELEMTYPE_UNK0, + { 0x08000000, 0x00, 0x02 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_NONE, + }, + { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, +}; -extern ColliderQuadInit D_80922230; +static InitChainEntry sInitChain[] = { + ICHAIN_F32(uncullZoneForward, 2000, ICHAIN_STOP), +}; -// there are uses of D_0E000000.fillRect (appearing as D_0E0002E0) in this file -extern GfxMasterList D_0E000000; +s32 sUnused; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Fire/ArrowFire_SetupAction.s") +void ArrowFire_SetupAction(ArrowFire* this, ArrowFireActionFunc actionFunc) { + this->actionFunc = actionFunc; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Fire/ArrowFire_Init.s") +void ArrowFire_Init(Actor* thisx, GlobalContext* globalCtx) { + ArrowFire* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Fire/ArrowFire_Destroy.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + this->radius = 0; + this->height = 1.0f; + ArrowFire_SetupAction(this, FireArrow_ChargeAndWait); + Actor_SetScale(&this->actor, 0.01f); + this->alpha = 160; + this->timer = 0; + this->screenFillIntensity = 0.0f; + Collider_InitAndSetQuad(globalCtx, &this->collider1, &this->actor, &sQuadInit); + Collider_InitAndSetQuad(globalCtx, &this->collider2, &this->actor, &sQuadInit); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Fire/func_80920440.s") +void ArrowFire_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ArrowFire* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Fire/FireArrow_Lerp.s") + func_80115D5C(&globalCtx->state); + Collider_DestroyQuad(globalCtx, &this->collider1); + Collider_DestroyQuad(globalCtx, &this->collider2); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Fire/func_8092058C.s") +void FireArrow_ChargeAndWait(ArrowFire* this, GlobalContext* globalCtx) { + EnArrow* arrow = (EnArrow*)this->actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Fire/func_809207A0.s") + if ((arrow == NULL) || (arrow->actor.update == NULL)) { + Actor_MarkForDeath(&this->actor); + return; + } + if (this->radius < 10) { + this->radius++; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Fire/ArrowFire_Update.s") + this->actor.world.pos = arrow->actor.world.pos; + this->actor.shape.rot = arrow->actor.shape.rot; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Fire/func_80920948.s") + func_800B9010(&this->actor, NA_SE_PL_ARROW_CHARGE_FIRE - SFX_FLAG); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Fire/ArrowFire_Draw.s") + // if arrow has no parent, player has fired the arrow + if (arrow->actor.parent == NULL) { + this->firedPos = this->actor.world.pos; + this->radius = 10; + ArrowFire_SetupAction(this, FireArrow_Fly); + this->alpha = 255; + } +} + +void FireArrow_Lerp(Vec3f* firedPos, Vec3f* pos, f32 scale) { + VEC3F_LERPIMPDST(firedPos, firedPos, pos, scale); +} + +void FireArrow_Hit(ArrowFire* this, GlobalContext* globalCtx) { + f32 offset; + f32 scale; + u16 timer; + + if (this->actor.projectedW < 50.0f) { + scale = 10.0f; + } else if (this->actor.projectedW > 950.0f) { + scale = 310.0f; + } else { + scale = this->actor.projectedW; + scale = ((scale - 50.0f) * (1.0f / 3.0f)) + 10.0f; + } + + timer = this->timer; + if (timer != 0) { + this->timer--; + if (this->timer >= 8) { + offset = (this->timer - 8) * (1.0f / 24.0f); + offset = SQ(offset); + this->radius = (((1.0f - offset) * scale) + 10.0f); + this->height = F32_LERPIMP(this->height, 2.0f, 0.1f); + if (this->timer < 16) { + this->alpha = (this->timer * 35) - 280; + } + } + } + if (this->timer >= 9) { + if (this->screenFillIntensity < 1.0f) { + this->screenFillIntensity += 0.25f; + } + } else { + if (this->screenFillIntensity > 0.0f) { + this->screenFillIntensity -= 0.125f; + } + } + if (this->timer < 8) { + this->alpha = 0; + } + if (this->timer == 0) { + this->timer = 255; + Actor_MarkForDeath(&this->actor); + return; + } + if (this->timer >= 13) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); + } +} + +void FireArrow_Fly(ArrowFire* this, GlobalContext* globalCtx) { + EnArrow* arrow = (EnArrow*)this->actor.parent; + s32 pad; + s32 pad2; + + if ((arrow == NULL) || (arrow->actor.update == NULL)) { + Actor_MarkForDeath(&this->actor); + return; + } + + this->actor.world.pos = arrow->actor.world.pos; + this->actor.shape.rot = arrow->actor.shape.rot; + + this->height = Math_Vec3f_DistXYZ(&this->firedPos, &this->actor.world.pos) * (1.0f / 24.0f); + + if (this->height < 1.0f) { + this->height = 1.0f; + } + + FireArrow_Lerp(&this->firedPos, &this->actor.world.pos, 0.05f); + if (arrow->unk_261 & 1) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_EXPLOSION_FRAME); + ArrowFire_SetupAction(this, FireArrow_Hit); + this->timer = 32; + this->alpha = 255; + return; + } + if (arrow->unk_260 < 34) { + if (this->alpha < 35) { + Actor_MarkForDeath(&this->actor); + return; + } + this->alpha -= 25; + } +} + +void ArrowFire_Update(Actor* thisx, GlobalContext* globalCtx) { + ArrowFire* this = (ArrowFire*)thisx; + + if ((globalCtx->msgCtx.msgMode == 0xE) || (globalCtx->msgCtx.msgMode == 0x12)) { + Actor_MarkForDeath(&this->actor); + return; + } + this->actionFunc(this, globalCtx); +} + +void FireArrow_SetQuadVerticies(ArrowFire* this) { + static Vec3f D_80922284 = { 100.0f, 700.0f, 0.0f }; + static Vec3f D_80922290 = { 400.0f, 27.0f, 0.0f }; + static Vec3f D_8092229C = { -100.0f, 700.0f, 0.0f }; + static Vec3f D_809222A8 = { -400, 27.0f, 0.0f }; + static Vec3f D_809222B4 = { 0.0f, 700.0f, 100.0f }; + static Vec3f D_809222C0 = { 0.0f, 27.0f, 400.0f }; + static Vec3f D_809222CC = { 0.0f, 700.0f, -100.0f }; + static Vec3f D_809222D8 = { 0.0f, 27.0f, -400.0f }; + Vec3f sp44; + Vec3f sp38; + Vec3f sp2C; + Vec3f sp20; + + Matrix_MultiplyVector3fByState(&D_80922284, &sp44); + Matrix_MultiplyVector3fByState(&D_80922290, &sp38); + Matrix_MultiplyVector3fByState(&D_8092229C, &sp2C); + Matrix_MultiplyVector3fByState(&D_809222A8, &sp20); + Collider_SetQuadVertices(&this->collider1, &sp44, &sp38, &sp2C, &sp20); + Matrix_MultiplyVector3fByState(&D_809222B4, &sp44); + Matrix_MultiplyVector3fByState(&D_809222C0, &sp38); + Matrix_MultiplyVector3fByState(&D_809222CC, &sp2C); + Matrix_MultiplyVector3fByState(&D_809222D8, &sp20); + Collider_SetQuadVertices(&this->collider2, &sp44, &sp38, &sp2C, &sp20); +} + +void ArrowFire_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnArrow* arrow; + ArrowFire* this = THIS; + u32 frames = globalCtx->state.frames; + s32 pad; + + arrow = (EnArrow*)this->actor.parent; + + if ((arrow != NULL) && (arrow->actor.update != NULL) && (this->timer < 255)) { + Actor* transform = (arrow->unk_261 & 2) ? &this->actor : &arrow->actor; + + OPEN_DISPS(globalCtx->state.gfxCtx); + Matrix_InsertTranslation(transform->world.pos.x, transform->world.pos.y, transform->world.pos.z, MTXMODE_NEW); + Matrix_RotateY(transform->shape.rot.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(transform->shape.rot.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(transform->shape.rot.z, MTXMODE_APPLY); + + Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); + if (this->screenFillIntensity > 0.0f) { + POLY_XLU_DISP = func_8012BFC4(POLY_XLU_DISP); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (s32)(this->screenFillIntensity * 40.0f) & 0xFF, 0, 0, + (s32)(150.0f * this->screenFillIntensity) & 0xFF); + + gDPSetAlphaDither(POLY_XLU_DISP++, G_AD_DISABLE); + gDPSetColorDither(POLY_XLU_DISP++, G_CD_DISABLE); + + gSPDisplayList(POLY_XLU_DISP++, D_0E000000.fillRect); + } + func_8012C2DC(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 200, 0, this->alpha); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 128); + + Matrix_InsertRotation(0x4000, 0, 0, MTXMODE_APPLY); + + if (this->timer != 0) { + Matrix_InsertTranslation(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); + } else { + Matrix_InsertTranslation(0.0f, 1500.0f, 0.0f, MTXMODE_APPLY); + } + + Matrix_Scale(this->radius * 0.2f, this->height * 4.0f, this->radius * 0.2f, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, -700.0f, 0.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + FireArrow_SetQuadVerticies(this); + gSPDisplayList(POLY_XLU_DISP++, gFireArrowMaterialDL); + gSPDisplayList(POLY_XLU_DISP++, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 255 - ((frames * 2) % 256), 0, 64, 32, 1, + 255 - (frames % 256), 511 - ((frames * 10) % 512), 64, 64)); + gSPDisplayList(POLY_XLU_DISP++, gFireArrowModelDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.h b/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.h index bf1143cd9d..5f9617c65f 100644 --- a/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.h +++ b/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.h @@ -8,12 +8,19 @@ struct ArrowFire; typedef void (*ArrowFireActionFunc)(struct ArrowFire*, GlobalContext*); typedef struct ArrowFire { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x114]; - /* 0x0258 */ ArrowFireActionFunc actionFunc; - /* 0x025C */ char unk_25C[0x8]; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderQuad collider1; + /* 0x1C4 */ ColliderQuad collider2; + /* 0x244 */ Vec3f firedPos; + /* 0x250 */ f32 height; + /* 0x254 */ f32 screenFillIntensity; + /* 0x258 */ ArrowFireActionFunc actionFunc; + /* 0x25C */ s16 radius; + /* 0x25E */ u16 timer; + /* 0x260 */ u8 alpha; } ArrowFire; // size = 0x264 + extern const ActorInit Arrow_Fire_InitVars; #endif // Z_ARROW_FIRE_H diff --git a/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c b/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c index 8f1d75ddee..8a402dfbe4 100644 --- a/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c +++ b/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c @@ -17,7 +17,6 @@ void ArrowIce_Update(Actor* thisx, GlobalContext* globalCtx); void ArrowIce_Draw(Actor* thisx, GlobalContext* globalCtx); void ArrowIce_Charge(ArrowIce* this, GlobalContext* globalCtx); -void ArrowIce_Hit(ArrowIce* this, GlobalContext* globalCtx); void ArrowIce_Fly(ArrowIce* this, GlobalContext* globalCtx); #include "overlays/ovl_Arrow_Ice/ovl_Arrow_Ice.c" @@ -94,7 +93,6 @@ void ArrowIce_LerpFiredPosition(Vec3f* firedPos, Vec3f* icePos, f32 scale) { void ArrowIce_Hit(ArrowIce* this, GlobalContext* globalCtx) { f32 scale; - f32 offset; u16 timer; if (this->actor.projectedW < 50.0f) { @@ -111,12 +109,12 @@ void ArrowIce_Hit(ArrowIce* this, GlobalContext* globalCtx) { this->timer--; if (this->timer >= 8) { - offset = ((this->timer - 8) * (1.0f / 24.0f)); + f32 offset = ((this->timer - 8) * (1.0f / 24.0f)); + offset = SQ(offset); this->radius = (((1.0f - offset) * scale) + 10.0f); - this->height += ((2.0f - this->height) * 0.1f); + this->height = F32_LERPIMP(this->height, 2.0f, 0.1f); if (this->timer < 16) { - if (1) {} this->alpha = ((this->timer * 35) - 280); } } diff --git a/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c b/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c index 7d81b05a58..ac8eb1ae92 100644 --- a/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c +++ b/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c @@ -5,6 +5,7 @@ */ #include "z_arrow_light.h" +#include "overlays/actors/ovl_En_Arrow/z_en_arrow.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000) @@ -15,13 +16,11 @@ void ArrowLight_Destroy(Actor* thisx, GlobalContext* globalCtx); void ArrowLight_Update(Actor* thisx, GlobalContext* globalCtx); void ArrowLight_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_809243AC(ArrowLight* this, GlobalContext* globalCtx); -void func_809244F8(ArrowLight* this, GlobalContext* globalCtx); -void func_809246C4(ArrowLight* this, GlobalContext* globalCtx); +void ArrowLight_Charge(ArrowLight* this, GlobalContext* globalCtx); +void ArrowLight_Fly(ArrowLight* this, GlobalContext* globalCtx); -void ArrowLight_SetupAction(ArrowLight* this, ArrowLightActionFunc actionFunc); +#include "overlays/ovl_Arrow_Light/ovl_Arrow_Light.c" -#if 0 const ActorInit Arrow_Light_InitVars = { ACTOR_ARROW_LIGHT, ACTORCAT_ITEMACTION, @@ -34,34 +33,198 @@ const ActorInit Arrow_Light_InitVars = { (ActorFunc)ArrowLight_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_809260A0[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 2000, ICHAIN_STOP), }; -#endif +static s32 sUnused; -extern InitChainEntry D_809260A0[]; +void ArrowLight_SetupAction(ArrowLight* this, ArrowLightActionFunc actionFunc) { + this->actionFunc = actionFunc; +} -// there are uses of D_0E000000.fillRect (appearing as D_0E0002E0) in this file -extern GfxMasterList D_0E000000; +void ArrowLight_Init(Actor* thisx, GlobalContext* globalCtx) { + ArrowLight* this = (ArrowLight*)thisx; + Actor_ProcessInitChain(&this->actor, sInitChain); + this->radius = 0; + this->height = 1.0f; + ArrowLight_SetupAction(this, ArrowLight_Charge); + Actor_SetScale(&this->actor, 0.01f); + this->alpha = 130; + this->timer = 0; + this->screenFillIntensity = 0.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Light/D_809260B0.s") +void ArrowLight_Destroy(Actor* thisx, GlobalContext* globalCtx) { + func_80115D5C(&globalCtx->state); + (void)"消滅"; // Unreferenced in retail, means "Disappearance" +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Light/ArrowLight_SetupAction.s") +void ArrowLight_Charge(ArrowLight* this, GlobalContext* globalCtx) { + EnArrow* arrow = (EnArrow*)this->actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Light/ArrowLight_Init.s") + if ((arrow == NULL) || (arrow->actor.update == NULL)) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Light/ArrowLight_Destroy.s") + if (this->radius < 10) { + this->radius++; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Light/func_809243AC.s") + this->actor.world.pos = arrow->actor.world.pos; + this->actor.shape.rot = arrow->actor.shape.rot; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Light/func_809244A0.s") + func_800B9010(&this->actor, NA_SE_PL_ARROW_CHARGE_LIGHT - SFX_FLAG); + if (arrow->actor.parent == NULL) { + this->firedPos = this->actor.world.pos; + this->radius = 10; + ArrowLight_SetupAction(this, ArrowLight_Fly); + this->alpha = 255; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Light/func_809244F8.s") +void ArrowLight_Lerp(Vec3f* firedPos, Vec3f* pos, f32 scale) { + VEC3F_LERPIMPDST(firedPos, firedPos, pos, scale); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Light/func_809246C4.s") +void ArrowLight_Hit(ArrowLight* this, GlobalContext* globalCtx) { + f32 scale; + u16 timer; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Light/ArrowLight_Update.s") + if (this->actor.projectedW < 50.0f) { + scale = 10.0f; + } else if (this->actor.projectedW > 950.0f) { + scale = 310.0f; + } else { + scale = this->actor.projectedW; + scale = ((scale - 50.0f) * (1.0f / 3.0f)) + 10.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Light/ArrowLight_Draw.s") + timer = this->timer; + if (timer != 0) { + this->timer--; + if (this->timer >= 8) { + f32 offset = (this->timer - 8) * (1.0f / 24.0f); + + offset = SQ(offset); + this->radius = (((1.0f - offset) * scale) + 10.0f); + this->height = F32_LERPIMP(this->height, 2.0f, 0.1f); + if (this->timer < 16) { + this->alpha = (this->timer * 35) - 280; + } + } + } + if (this->timer >= 9) { + if (this->screenFillIntensity < 1.0f) { + this->screenFillIntensity += 0.25f; + } + } else { + if (this->screenFillIntensity > 0.0f) { + this->screenFillIntensity -= 0.125f; + } + } + if (this->timer < 8) { + this->alpha = 0; + } + if (this->timer == 0) { + this->timer = 255; + Actor_MarkForDeath(&this->actor); + return; + } +} + +void ArrowLight_Fly(ArrowLight* this, GlobalContext* globalCtx) { + EnArrow* arrow = (EnArrow*)this->actor.parent; + s32 pad[2]; + + if ((arrow == NULL) || (arrow->actor.update == NULL)) { + Actor_MarkForDeath(&this->actor); + return; + } + + this->actor.world.pos = arrow->actor.world.pos; + this->actor.shape.rot = arrow->actor.shape.rot; + + this->height = Math_Vec3f_DistXYZ(&this->firedPos, &this->actor.world.pos) * (1.0f / 24.0f); + if (this->height < 1.0f) { + this->height = 1.0f; + } + + ArrowLight_Lerp(&this->firedPos, &this->actor.world.pos, 0.05f); + + if (arrow->unk_261 & 1) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_EXPLOSION_LIGHT); + ArrowLight_SetupAction(this, ArrowLight_Hit); + this->timer = 32; + this->alpha = 255; + return; + } + if (arrow->unk_260 < 34) { + if (this->alpha < 35) { + Actor_MarkForDeath(&this->actor); + return; + } + this->alpha -= 25; + } +} + +void ArrowLight_Update(Actor* thisx, GlobalContext* globalCtx) { + ArrowLight* this = THIS; + + if ((globalCtx->msgCtx.msgMode == 0xE) || (globalCtx->msgCtx.msgMode == 0x12)) { + Actor_MarkForDeath(&this->actor); + return; + } + this->actionFunc(this, globalCtx); +} + +void ArrowLight_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ArrowLight* this = (ArrowLight*)thisx; + u32 frames = globalCtx->state.frames; + EnArrow* arrow = (EnArrow*)this->actor.parent; + + if ((arrow != NULL) && (arrow->actor.update != NULL) && (this->timer < 255)) { + Actor* transform = (arrow->unk_261 & 2) ? &this->actor : &arrow->actor; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_InsertTranslation(transform->world.pos.x, transform->world.pos.y, transform->world.pos.z, MTXMODE_NEW); + Matrix_RotateY(transform->shape.rot.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(transform->shape.rot.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(transform->shape.rot.z, MTXMODE_APPLY); + Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); + if (this->screenFillIntensity > 0.0f) { + POLY_XLU_DISP = func_8012BFC4(POLY_XLU_DISP); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (s32)(this->screenFillIntensity * 30.0f) & 0xFF, + (s32)(40.0f * this->screenFillIntensity) & 0xFF, 0, + (s32)(150.0f * this->screenFillIntensity) & 0xFF); + gDPSetAlphaDither(POLY_XLU_DISP++, G_AD_DISABLE); + gDPSetColorDither(POLY_XLU_DISP++, G_CD_DISABLE); + gSPDisplayList(POLY_XLU_DISP++, D_0E000000.fillRect); + } + + func_8012C2DC(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 170, this->alpha); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 0, 128); + + Matrix_InsertRotation(0x4000, 0, 0, MTXMODE_APPLY); + if (this->timer != 0) { + Matrix_InsertTranslation(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); + } else { + Matrix_InsertTranslation(0.0f, 1500.0f, 0.0f, MTXMODE_APPLY); + } + Matrix_Scale(this->radius * 0.2f, this->height * 4.0f, this->radius * 0.2f, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, -700.0f, 0.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gLightArrowMaterialDL); + gSPDisplayList(POLY_XLU_DISP++, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 511 - ((frames * 5) % 512), 0, 4, 32, 1, + 511 - ((frames * 10) % 512), 511 - ((frames * 30) % 512), 8, 16)); + gSPDisplayList(POLY_XLU_DISP++, gLightArrowModelDL); + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.h b/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.h index ef462cfde2..7b3f3088f9 100644 --- a/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.h +++ b/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.h @@ -8,11 +8,17 @@ struct ArrowLight; typedef void (*ArrowLightActionFunc)(struct ArrowLight*, GlobalContext*); typedef struct ArrowLight { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x1C]; - /* 0x0160 */ ArrowLightActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ s16 radius; + /* 0x146 */ u16 timer; + /* 0x148 */ u8 alpha; + /* 0x14C */ Vec3f firedPos; + /* 0x158 */ f32 height; + /* 0x15C */ f32 screenFillIntensity; + /* 0x160 */ ArrowLightActionFunc actionFunc; } ArrowLight; // size = 0x164 + extern const ActorInit Arrow_Light_InitVars; #endif // Z_ARROW_LIGHT_H diff --git a/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.c b/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.c index 63a9e69dc2..b2fe546cfa 100644 --- a/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.c +++ b/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.c @@ -5,6 +5,15 @@ */ #include "z_bg_breakwall.h" +#include "objects/object_omoya_obj/object_omoya_obj.h" +#include "objects/object_yukimura_obj/object_yukimura_obj.h" +#include "objects/object_keikoku_obj/object_keikoku_obj.h" +#include "objects/object_posthouse_obj/object_posthouse_obj.h" +#include "objects/object_kumo30/object_kumo30.h" +#include "objects/object_mnk/object_mnk.h" +#include "objects/object_ikninside_obj/object_ikninside_obj.h" +#include "objects/object_kaizoku_obj/object_kaizoku_obj.h" +#include "objects/object_spot11_obj/object_spot11_obj.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -14,80 +23,418 @@ void BgBreakwall_Init(Actor* thisx, GlobalContext* globalCtx); void BgBreakwall_Update(Actor* thisx, GlobalContext* globalCtx); void BgBreakwall_SetupAction(BgBreakwall* this, BgBreakwallActionFunc actionFunc); +s32 func_808B736C(BgBreakwall* this, GlobalContext* globalCtx); +s32 func_808B7380(BgBreakwall* this, GlobalContext* globalCtx); +s32 func_808B73C4(BgBreakwall* this, GlobalContext* globalCtx); +s32 func_808B73FC(BgBreakwall* this, GlobalContext* globalCtx); +s32 func_808B7410(BgBreakwall* this, GlobalContext* globalCtx); +s32 func_808B7460(BgBreakwall* this, GlobalContext* globalCtx); +s32 func_808B74A8(BgBreakwall* this, GlobalContext* globalCtx); +s32 func_808B74D8(BgBreakwall* this, GlobalContext* globalCtx); +s32 func_808B751C(BgBreakwall* this, GlobalContext* globalCtx); +void func_808B76CC(BgBreakwall* this, GlobalContext* globalCtx); +void func_808B77D0(BgBreakwall* this, GlobalContext* globalCtx); +void func_808B77E0(BgBreakwall* this, GlobalContext* globalCtx); +void func_808B782C(BgBreakwall* this, GlobalContext* globalCtx); +void func_808B78A4(BgBreakwall* this, GlobalContext* globalCtx); +void func_808B78DC(BgBreakwall* this, GlobalContext* globalCtx); +void func_808B7914(BgBreakwall* this, GlobalContext* globalCtx); +void func_808B7A10(BgBreakwall* this, GlobalContext* globalCtx); +void func_808B7A90(Actor* thisx, GlobalContext* globalCtx); +void func_808B7B54(Actor* thisx, GlobalContext* globalCtx); +void func_808B7D34(Actor* thisx, GlobalContext* globalCtx); +void BgBreakwall_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Bg_Breakwall_InitVars = { - ACTOR_BG_BREAKWALL, - ACTORCAT_ITEMACTION, - FLAGS, - GAMEPLAY_KEEP, - sizeof(BgBreakwall), - (ActorFunc)BgBreakwall_Init, - (ActorFunc)NULL, - (ActorFunc)BgBreakwall_Update, - (ActorFunc)NULL, + ACTOR_BG_BREAKWALL, ACTORCAT_ITEMACTION, FLAGS, + GAMEPLAY_KEEP, sizeof(BgBreakwall), (ActorFunc)BgBreakwall_Init, + (ActorFunc)NULL, (ActorFunc)BgBreakwall_Update, (ActorFunc)NULL, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808B82E0[] = { +typedef struct { + /* 0x00 */ s16 unk_00; + /* 0x04 */ Gfx* unk_04; + /* 0x08 */ Gfx* unk_08; + /* 0x0C */ AnimatedMaterial* unk_0C; + /* 0x10 */ CollisionHeader* unk_10; + /* 0x14 */ BgBreakwallUnkFunc unk_14; + /* 0x18 */ BgBreakwallUnkFunc2 unk_18; + /* 0x1C */ ActorFunc unk_1C; +} BgBreakwallStruct; + +BgBreakwallStruct D_808B8140[] = { + { OBJECT_OMOYA_OBJ, object_omoya_obj_DL_0001A0, NULL, NULL, NULL, func_808B7380, func_808B77D0, NULL }, + { OBJECT_YUKIMURA_OBJ, object_yukimura_obj_DL_000F98, object_yukimura_obj_DL_000EB0, + object_yukimura_obj_Matanimheader_002090, NULL, func_808B73C4, func_808B77D0, NULL }, + { OBJECT_KEIKOKU_OBJ, object_keikoku_obj_DL_0027D8, NULL, object_keikoku_obj_Matanimheader_004290, NULL, + func_808B73FC, func_808B77D0, NULL }, + { OBJECT_KEIKOKU_OBJ, object_keikoku_obj_DL_0044A8, NULL, NULL, NULL, func_808B736C, func_808B77D0, NULL }, + { OBJECT_POSTHOUSE_OBJ, object_posthouse_obj_DL_000A50, NULL, NULL, NULL, func_808B7410, func_808B77E0, NULL }, + { OBJECT_POSTHOUSE_OBJ, object_posthouse_obj_DL_001870, NULL, NULL, &object_posthouse_obj_Colheader_002948, + func_808B7460, func_808B782C, NULL }, + { OBJECT_KUMO30, NULL, object_kumo30_DL_002A40, object_kumo30_Matanimheader_003368, NULL, func_808B74A8, + func_808B78A4, func_808B7A90 }, + { OBJECT_KUMO30, NULL, NULL, object_kumo30_Matanimheader_002890, NULL, func_808B736C, func_808B78DC, + func_808B7B54 }, + { OBJECT_MNK, object_mnk_DL_000F58, NULL, object_mnk_Matanimheader_002E28, &object_mnk_Colheader_0033E8, + func_808B74D8, func_808B7914, NULL }, + { OBJECT_IKNINSIDE_OBJ, NULL, object_ikninside_obj_DL_00AB10, object_ikninside_obj_Matanimheader_00BCC8, NULL, + func_808B751C, func_808B7A10, func_808B7D34 }, + { OBJECT_KAIZOKU_OBJ, object_kaizoku_obj_DL_00AD50, NULL, NULL, &object_kaizoku_obj_Colheader_00B868, func_808B736C, + func_808B77D0, NULL }, + { OBJECT_IKNINSIDE_OBJ, NULL, object_ikninside_obj_DL_00AEC0, object_ikninside_obj_Matanimheader_00BCB8, NULL, + func_808B751C, func_808B7A10, func_808B7D34 }, + { OBJECT_SPOT11_OBJ, object_spot11_obj_DL_0013F0, NULL, NULL, &object_spot11_obj_Colheader_001EB8, func_808B736C, + func_808B77D0, NULL }, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F(scale, 1, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 400, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 800, ICHAIN_STOP), }; -#endif +Color_RGBA8 D_808B82F0[] = { + { 255, 230, 240, 255 }, + { 255, 255, 255, 255 }, + { 255, 230, 220, 255 }, + { 80, 120, 160, 255 }, +}; -extern InitChainEntry D_808B82E0[]; +Color_RGBA8 D_808B8300[] = { + { 140, 60, 70, 255 }, + { 50, 150, 150, 255 }, + { 140, 60, 50, 255 }, + { 30, 40, 160, 255 }, +}; -extern UNK_TYPE D_06000A50; +Color_RGBA8 D_808B8310[] = { + { 210, 160, 180, 255 }, + { 120, 150, 160, 255 }, + { 210, 170, 160, 255 }, + { 70, 100, 120, 255 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/BgBreakwall_SetupAction.s") +Color_RGBA8 D_808B8320[] = { + { 255, 240, 255, 255 }, + { 255, 255, 255, 255 }, + { 255, 255, 240, 255 }, + { 150, 170, 180, 255 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B736C.s") +Color_RGBA8 D_808B8330[] = { + { 60, 20, 40, 255 }, + { 0, 50, 50, 255 }, + { 60, 30, 30, 255 }, + { 0, 20, 30, 255 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B7380.s") +Color_RGBA8 D_808B8340[] = { + { 160, 120, 140, 255 }, + { 100, 160, 150, 255 }, + { 160, 150, 120, 255 }, + { 60, 110, 110, 255 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B73C4.s") +void BgBreakwall_SetupAction(BgBreakwall* this, BgBreakwallActionFunc actionFunc) { + this->actionFunc = actionFunc; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B73FC.s") +s32 func_808B736C(BgBreakwall* this, GlobalContext* globalCtx) { + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B7410.s") +s32 func_808B7380(BgBreakwall* this, GlobalContext* globalCtx) { + if ((gSaveContext.save.day >= 2) && !(gSaveContext.save.weekEventReg[22] & 1)) { + return false; + } + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B7460.s") +s32 func_808B73C4(BgBreakwall* this, GlobalContext* globalCtx) { + return (gSaveContext.save.weekEventReg[33] & 0x80) || (gSaveContext.save.weekEventReg[21] & 1); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B74A8.s") +s32 func_808B73FC(BgBreakwall* this, GlobalContext* globalCtx) { + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B74D8.s") +s32 func_808B7410(BgBreakwall* this, GlobalContext* globalCtx) { + if (Flags_GetSwitch(globalCtx, this->switchFlag)) { + this->dyna.actor.draw = NULL; + } + Actor_SetScale(&this->dyna.actor, 0.1f); + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B751C.s") +s32 func_808B7460(BgBreakwall* this, GlobalContext* globalCtx) { + if (!Flags_GetSwitch(globalCtx, this->switchFlag)) { + this->dyna.actor.scale.x = 0.1f; + } + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/BgBreakwall_Init.s") +s32 func_808B74A8(BgBreakwall* this, GlobalContext* globalCtx) { + if (gSaveContext.save.weekEventReg[55] & 0x80) { + return false; + } + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B767C.s") +s32 func_808B74D8(BgBreakwall* this, GlobalContext* globalCtx) { + if (!(gSaveContext.save.weekEventReg[9] & 0x80) || (gSaveContext.save.weekEventReg[23] & 0x20)) { + return false; + } + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B76CC.s") +s32 func_808B751C(BgBreakwall* this, GlobalContext* globalCtx) { + Actor_SetScale(&this->dyna.actor, 0.1f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B77D0.s") + if ((BGBREAKWALL_SWITCHFLAG(&this->dyna.actor) != 0x7F) && + !Flags_GetSwitch(globalCtx, BGBREAKWALL_SWITCHFLAG(&this->dyna.actor))) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B77E0.s") + func_800FEA50(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B782C.s") + if (gSaveContext.save.isNight) { + this->unk_15E = 0; + } else { + this->unk_15E = 255; + } + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B78A4.s") +void BgBreakwall_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgBreakwall* this = THIS; + BgBreakwallStruct* sp24 = &D_808B8140[BGBREAKWALL_GET_F(&this->dyna.actor)]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B78DC.s") + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + this->unk_15C = Object_GetIndex(&globalCtx->objectCtx, sp24->unk_00); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B7914.s") + if ((this->unk_15C < 0) || !sp24->unk_14(this, globalCtx)) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B7A10.s") + BgBreakwall_SetupAction(this, func_808B76CC); + this->switchFlag = BGBREAKWALL_SWITCHFLAG(&this->dyna.actor); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/BgBreakwall_Update.s") +void BgBreakwall_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgBreakwall* this = THIS; + BgBreakwallStruct* temp_s1 = &D_808B8140[BGBREAKWALL_GET_F(&this->dyna.actor)]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B7A90.s") + if (temp_s1->unk_10 != NULL) { + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B7B54.s") +void func_808B76CC(BgBreakwall* this, GlobalContext* globalCtx) { + if (Object_IsLoaded(&globalCtx->objectCtx, this->unk_15C)) { + BgBreakwallStruct* temp_s1 = &D_808B8140[BGBREAKWALL_GET_F(&this->dyna.actor)]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B7D34.s") + this->dyna.actor.objBankIndex = this->unk_15C; + this->dyna.actor.draw = BgBreakwall_Draw; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B7FE4.s") + if (((BGBREAKWALL_GET_F(&this->dyna.actor)) != BGBREAKWALL_F_7) && + ((BGBREAKWALL_GET_F(&this->dyna.actor)) != BGBREAKWALL_F_9) && + ((BGBREAKWALL_GET_F(&this->dyna.actor)) != BGBREAKWALL_F_11)) { + this->dyna.actor.flags &= ~ACTOR_FLAG_10; + } + + Actor_SetObjectDependency(globalCtx, &this->dyna.actor); + + if (temp_s1->unk_0C != NULL) { + temp_s1->unk_0C = Lib_SegmentedToVirtual(temp_s1->unk_0C); + } + + if (temp_s1->unk_10 != NULL) { + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, temp_s1->unk_10); + } + + BgBreakwall_SetupAction(this, temp_s1->unk_18); + this->dyna.actor.destroy = BgBreakwall_Destroy; + } +} + +void func_808B77D0(BgBreakwall* this, GlobalContext* globalCtx) { +} + +void func_808B77E0(BgBreakwall* this, GlobalContext* globalCtx) { + if (!Flags_GetSwitch(globalCtx, this->switchFlag)) { + this->dyna.actor.draw = BgBreakwall_Draw; + } else { + this->dyna.actor.draw = NULL; + } +} + +void func_808B782C(BgBreakwall* this, GlobalContext* globalCtx) { + f32 phi_f0; + + if (Flags_GetSwitch(globalCtx, this->switchFlag)) { + phi_f0 = 1.0f; + } else { + phi_f0 = 0.1f; + } + Math_SmoothStepToF(&this->dyna.actor.scale.x, phi_f0, 0.2f, 0.3f, 0.06f); +} + +void func_808B78A4(BgBreakwall* this, GlobalContext* globalCtx) { + if (gSaveContext.save.weekEventReg[55] & 0x80) { + Actor_MarkForDeath(&this->dyna.actor); + } +} + +void func_808B78DC(BgBreakwall* this, GlobalContext* globalCtx) { + Actor_SetScale(&this->dyna.actor, 3.5f); + func_800B9010(&this->dyna.actor, NA_SE_EV_TORNADE - SFX_FLAG); +} + +void func_808B7914(BgBreakwall* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp30; + Vec3f sp24; + + if ((globalCtx->gameplayFrames % 8) == 0) { + sp30.x = Rand_ZeroFloat(80.0f) + (this->dyna.actor.world.pos.x - 55.0f); + sp30.y = this->dyna.actor.world.pos.y + 70.0f; + sp30.z = Rand_ZeroFloat(80.0f) + (this->dyna.actor.world.pos.z - 130.0f); + + sp24.x = 0.0f; + sp24.y = 0.5f; + sp24.z = 0.0f; + + EffectSsIceSmoke_Spawn(globalCtx, &sp30, &sp24, &gZeroVec3f, -200 - (s32)(Rand_ZeroOne() * 50.0f)); + } +} + +void func_808B7A10(BgBreakwall* this, GlobalContext* globalCtx) { + if (gSaveContext.save.isNight) { + if (this->unk_15E < 245) { + this->unk_15E += 10; + } else { + this->unk_15E = 255; + } + } else if (this->unk_15E > 10) { + this->unk_15E -= 10; + } else { + this->unk_15E = 0; + } +} + +void BgBreakwall_Update(Actor* thisx, GlobalContext* globalCtx) { + BgBreakwall* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void func_808B7A90(Actor* thisx, GlobalContext* globalCtx) { + Color_RGBA8 sp2C; + Color_RGBA8 sp28; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_800FE7A8(D_808B82F0, &sp2C); + func_800FE7A8(D_808B8300, &sp28); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, sp2C.r, sp2C.g, sp2C.b, 255); + gDPSetEnvColor(POLY_XLU_DISP++, sp28.r, sp28.g, sp28.b, 255); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_808B7B54(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + Color_RGBA8 sp50; + Color_RGBA8 sp4C; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + func_800FE7A8(D_808B8310, &sp50); + func_800FE7A8(D_808B8330, &sp4C); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, sp50.r, sp50.g, sp50.b, 255); + gDPSetEnvColor(POLY_XLU_DISP++, sp4C.r, sp4C.g, sp4C.b, 255); + gSPDisplayList(POLY_XLU_DISP++, object_posthouse_obj_DL_000A50); + + func_800FE7A8(D_808B8320, &sp50); + func_800FE7A8(D_808B8340, &sp4C); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, sp50.r, sp50.g, sp50.b, 255); + gDPSetEnvColor(POLY_XLU_DISP++, sp4C.r, sp4C.g, sp4C.b, 255); + gSPDisplayList(POLY_XLU_DISP++, object_kumo30_DL_000C98); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_808B7D34(Actor* thisx, GlobalContext* globalCtx) { + BgBreakwall* this = THIS; + s32 sp48; + s32 tempA; + s32 tempB; + s32 tempC; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + sp48 = 255 - this->unk_15E; + + tempA = (((sp48 * 245) + (this->unk_15E * 255)) & 0xFF00) >> 8; + tempB = (((sp48 * 145) + (this->unk_15E * 85)) & 0xFF00) >> 8; + tempC = (((sp48 * 135) + (this->unk_15E * 55)) & 0xFF00) >> 8; + + gSPSegment(POLY_XLU_DISP++, 0x09, Gfx_PrimColor(globalCtx->state.gfxCtx, 255, 255, tempA, tempB, tempC)); + + tempA = (((sp48 * 255) + (this->unk_15E * 150)) & 0xFF00) >> 8; + tempB = (((sp48 * 255) + (this->unk_15E * 100)) & 0xFF00) >> 8; + tempC = (((sp48 * 255) + (this->unk_15E * 75)) & 0xFF00) >> 8; + + gSPSegment(POLY_XLU_DISP++, 0x0A, Gfx_PrimColor(globalCtx->state.gfxCtx, 255, tempA, tempA, tempB, tempC)); + + tempA = (((sp48 * 185) + (this->unk_15E * 140)) & 0xFF00) >> 8; + tempB = (((sp48 * 235) + (this->unk_15E * 45)) & 0xFF00) >> 8; + + gSPSegment(POLY_XLU_DISP++, 0x0B, Gfx_PrimColor(globalCtx->state.gfxCtx, 255, 255, 255, tempA, tempB)); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void BgBreakwall_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgBreakwall* this = THIS; + BgBreakwallStruct* temp_s2 = &D_808B8140[BGBREAKWALL_GET_F(&this->dyna.actor)]; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if (temp_s2->unk_0C != NULL) { + AnimatedMat_Draw(globalCtx, temp_s2->unk_0C); + } + + if (temp_s2->unk_1C != NULL) { + temp_s2->unk_1C(&this->dyna.actor, globalCtx); + } + + if (temp_s2->unk_04 != NULL) { + func_8012C28C(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, temp_s2->unk_04); + } + + if (temp_s2->unk_08 != NULL) { + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, temp_s2->unk_08); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.h b/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.h index 279aba17bb..322929344c 100644 --- a/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.h +++ b/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.h @@ -6,10 +6,23 @@ struct BgBreakwall; typedef void (*BgBreakwallActionFunc)(struct BgBreakwall*, GlobalContext*); +typedef s32 (*BgBreakwallUnkFunc)(struct BgBreakwall*, GlobalContext*); +typedef void (*BgBreakwallUnkFunc2)(struct BgBreakwall*, GlobalContext*); + +#define BGBREAKWALL_GET_F(thisx) ((thisx)-> params & 0xF) +#define BGBREAKWALL_SWITCHFLAG(thisx) (((thisx)-> params & 0xFE00) >> 9) + +enum { + /* 7 */ BGBREAKWALL_F_7 = 7, + /* 9 */ BGBREAKWALL_F_9 = 9, + /* 11 */ BGBREAKWALL_F_11 = 11, +}; typedef struct BgBreakwall { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x1C]; + /* 0x0000 */ DynaPolyActor dyna; + /* 0x015C */ s8 unk_15C; + /* 0x015D */ u8 switchFlag; + /* 0x015E */ u8 unk_15E; /* 0x0160 */ BgBreakwallActionFunc actionFunc; } BgBreakwall; // size = 0x164 diff --git a/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c b/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c index 9f2e18d9c3..07693307b9 100644 --- a/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c +++ b/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c @@ -5,6 +5,7 @@ */ #include "z_bg_dblue_balance.h" +#include "objects/object_dblue_object/object_dblue_object.h" #define FLAGS 0x00000000 @@ -15,11 +16,19 @@ void BgDblueBalance_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgDblueBalance_Update(Actor* thisx, GlobalContext* globalCtx); void BgDblueBalance_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80B82DC4(BgDblueBalance* this); void func_80B82DE0(BgDblueBalance* this, GlobalContext* globalCtx); +void func_80B8330C(Actor* thisx, GlobalContext* globalCtx); +void func_80B83344(BgDblueBalance* this); void func_80B8335C(BgDblueBalance* this, GlobalContext* globalCtx); +void func_80B833A8(BgDblueBalance* this); void func_80B833C4(BgDblueBalance* this, GlobalContext* globalCtx); +void func_80B83518(Actor* thisx, GlobalContext* globalCtx); +void func_80B83758(Actor* thisx, GlobalContext* globalCtx); + +AnimatedMaterial* D_80B83C70; +AnimatedMaterial* D_80B83C74; -#if 0 const ActorInit Bg_Dblue_Balance_InitVars = { ACTOR_BG_DBLUE_BALANCE, ACTORCAT_BG, @@ -32,56 +41,689 @@ const ActorInit Bg_Dblue_Balance_InitVars = { (ActorFunc)BgDblueBalance_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B83A98[] = { +typedef struct { + /* 0x00 */ Gfx* unk_00; + /* 0x04 */ CollisionHeader* unk_04; + /* 0x08 */ u32 unk_08; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ f32 unk_10; + /* 0x14 */ ActorFunc unk_14; + /* 0x18 */ ActorFunc unk_18; +} BgDblueBalanceStruct2; + +BgDblueBalanceStruct2 D_80B83A20[] = { + { + object_dblue_object_DL_00B8F8, + &object_dblue_object_Colheader_00BC08, + 0x10, + 360.0f, + 300.0f, + BgDblueBalance_Update, + BgDblueBalance_Draw, + }, + { + object_dblue_object_DL_00BF48, + &object_dblue_object_Colheader_00C180, + 0x10, + 210.0f, + 190.0f, + func_80B8330C, + BgDblueBalance_Draw, + }, + { + object_dblue_object_DL_00C4B8, + &object_dblue_object_Colheader_00C700, + 0x10, + 180.0f, + 180.0f, + func_80B8330C, + BgDblueBalance_Draw, + }, + { + object_dblue_object_DL_001E68, + &object_dblue_object_Colheader_002E78, + 0x30, + 1500.0f, + 1500.0f, + func_80B83518, + func_80B83758, + }, +}; + +s8 D_80B83A90[] = { + 0, + 4, +}; +s8 D_80B83A94[] = { + 0, + 2, + 4, + 6, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#endif +void func_80B823B0(BgDblueBalance* this) { + s32 pad; + Vec3f sp28; -extern InitChainEntry D_80B83A98[]; + Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, + MTXMODE_NEW); + Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); -extern UNK_TYPE D_0600CD10; -extern UNK_TYPE D_0600CE00; -extern UNK_TYPE D_0600D110; + sp28.x = -138.28f; + sp28.y = 0.0f; + sp28.z = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B823B0.s") + if (this->unk_15C != NULL) { + Matrix_MultiplyVector3fByState(&sp28, &this->unk_15C->dyna.actor.world.pos); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B82454.s") + sp28.x = 138.28f; + if (this->unk_160 != NULL) { + Matrix_MultiplyVector3fByState(&sp28, &this->unk_160->dyna.actor.world.pos); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B8259C.s") +s32 func_80B82454(BgDblueBalance* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp58 = true; + BgDblueBalance* balance; + Vec3f sp48; + Vec3f sp3C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B8264C.s") + Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, + MTXMODE_NEW); + Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B828E4.s") + sp48.x = -138.28f; + sp48.y = 0.0f; + sp48.z = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B8296C.s") + Matrix_MultiplyVector3fByState(&sp48, &sp3C); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B82B00.s") + this->unk_15C = (BgDblueBalance*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BG_DBLUE_BALANCE, sp3C.x, + sp3C.y, sp3C.z, 0, this->dyna.actor.shape.rot.y, 0, 0x100); + if (this->unk_15C == NULL) { + sp58 = false; + } else { + balance = this->unk_15C; + balance->unk_164 = this; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/BgDblueBalance_Init.s") + sp48.x = 138.28f; + Matrix_MultiplyVector3fByState(&sp48, &sp3C); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/BgDblueBalance_Destroy.s") + this->unk_160 = (BgDblueBalance*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BG_DBLUE_BALANCE, sp3C.x, + sp3C.y, sp3C.z, 0, this->dyna.actor.shape.rot.y, 0, 0x200); + if (this->unk_160 == NULL) { + sp58 = false; + } else { + balance = this->unk_160; + balance->unk_164 = this; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B82DC4.s") + return sp58; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B82DE0.s") +void func_80B8259C(BgDblueBalance* this, GlobalContext* globalCtx) { + s32 pad; + WaterBox* sp30; + f32 sp2C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/BgDblueBalance_Update.s") + if (WaterBox_GetSurface1_2(globalCtx, &globalCtx->colCtx, this->dyna.actor.world.pos.x, + this->dyna.actor.world.pos.z, &sp2C, &sp30)) { + this->dyna.actor.depthInWater = sp2C - this->dyna.actor.world.pos.y; + this->unk_228 = sp2C; + if ((this->dyna.actor.depthInWater < 150.0f) && (this->dyna.actor.depthInWater > -150.0f)) { + this->unk_182 = true; + } else { + this->unk_182 = false; + } + } else { + this->unk_182 = false; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B8330C.s") +void func_80B8264C(BgDblueBalance* this) { + s32 pad; + s32 i; + BgDblueBalanceStruct* phi_s0; + Vec3f sp78; + f32 temp_f0; + s16 phi_s2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B83344.s") + if (this->unk_170 != 0) { + if (this->unk_183 < 8) { + this->unk_183 = 0; + } else { + this->unk_183 -= 7; + } + } else { + if (this->unk_183 > 250) { + this->unk_183 = 255; + } else { + this->unk_183 += 4; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B8335C.s") + Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, + MTXMODE_NEW); + Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B833A8.s") + for (i = 0, phi_s0 = &this->unk_188[0], phi_s2 = 0; i < ARRAY_COUNT(this->unk_188); + i++, phi_s2 += 0x2000, phi_s0++) { + phi_s0->unk_0C = this->dyna.actor.shape.rot.x + phi_s2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B833C4.s") + Matrix_StatePush(); + Matrix_InsertXRotation_s(phi_s0->unk_0C, MTXMODE_NEW); + Matrix_InsertTranslation(-545.0f, 0.0f, 270.0f, MTXMODE_APPLY); + Matrix_GetStateTranslation(&sp78); + Matrix_StatePop(); + Matrix_MultiplyVector3fByState(&sp78, &phi_s0->unk_00); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B83518.s") + temp_f0 = (sp78.z - 135.0f); + if (sp78.z > 135.0f) { + temp_f0 *= 1.8962963f; + if (temp_f0 > 255.0f) { + phi_s0->unk_0E = 0xFF; + phi_s0->unk_10 = 0.1f; + } else if (temp_f0 < 1.0f) { + phi_s0->unk_0E = 0; + phi_s0->unk_10 = 0.0f; + } else { + phi_s0->unk_0E = temp_f0; + phi_s0->unk_10 = temp_f0 * 0.000390625f; + } + } else { + phi_s0->unk_0E = 0; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/BgDblueBalance_Draw.s") +void func_80B828E4(BgDblueBalance* this, GlobalContext* globalCtx) { + if (Flags_GetSwitch(globalCtx, BGDBLUEBALANCE_GET_7F(&this->dyna.actor)) && (this->unk_17D <= 0)) { + if (this->unk_183 >= 252) { + this->unk_183 = 255; + } else { + this->unk_183 += 3; + } + } else if (this->unk_183 < 7) { + this->unk_183 = 0; + } else { + this->unk_183 -= 6; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B83758.s") +void func_80B8296C(GlobalContext* globalCtx, Vec3f* arg1, f32 arg2) { + s32 i; + Vec3f sp60; + f32 temp_f0; + f32 temp_f20 = arg2 * 2; + + for (i = 0; i < ARRAY_COUNT(D_80B83A90); i++) { + sp60.x = ((Rand_ZeroOne() - 0.5f) * temp_f20) + arg1->x; + sp60.y = arg1->y; + sp60.z = ((Rand_ZeroOne() - 0.5f) * temp_f20) + arg1->z; + EffectSsGRipple_Spawn(globalCtx, &sp60, 500, 2000, D_80B83A90[i]); + } + + for (i = 0; i < ARRAY_COUNT(D_80B83A94); i++) { + temp_f0 = Rand_ZeroOne(); + temp_f20 = 1.0f - SQ(temp_f0); + if (Rand_Next() > 0) { + temp_f20 = -temp_f20; + } + + sp60.x = (temp_f20 * arg2) + arg1->x; + sp60.y = arg1->y; + + temp_f0 = Rand_ZeroOne(); + temp_f20 = 1.0f - SQ(temp_f0); + if (Rand_Next() > 0) { + temp_f20 = -temp_f20; + } + sp60.z = (temp_f20 * arg2) + arg1->z; + + EffectSsGRipple_Spawn(globalCtx, &sp60, 400, 800, D_80B83A94[i]); + } +} + +s32 func_80B82B00(s16 arg0, s16 arg1, s16 arg2) { + if (arg0 < arg1) { + return (arg0 < arg2 && arg1 >= arg2); + } + return (arg0 < arg2 || arg1 >= arg2); +} + +void BgDblueBalance_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgDblueBalance* this = THIS; + s32 sp2C = BGDBLUEBALANCE_GET_300(&this->dyna.actor); + s32 pad2; + s32 sp24 = Flags_GetSwitch(globalCtx, BGDBLUEBALANCE_GET_7F(&this->dyna.actor)); + + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + + this->dyna.actor.flags = D_80B83A20[sp2C].unk_08; + this->dyna.actor.uncullZoneScale = D_80B83A20[sp2C].unk_0C; + this->dyna.actor.uncullZoneDownward = D_80B83A20[sp2C].unk_10; + this->dyna.actor.update = D_80B83A20[sp2C].unk_14; + this->dyna.actor.draw = D_80B83A20[sp2C].unk_18; + + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, D_80B83A20[sp2C].unk_04); + + if (sp2C == 3) { + D_80B83C70 = Lib_SegmentedToVirtual(object_dblue_object_Matanimheader_00CE00); + } else if (sp2C == 0) { + D_80B83C74 = Lib_SegmentedToVirtual(object_dblue_object_Matanimheader_00D250); + } + + if (sp2C == 0) { + if (sp24 != 0) { + this->dyna.actor.shape.rot.z = -0x1C72; + this->unk_174 = -0x1C72; + } else { + this->dyna.actor.shape.rot.z = 0x1C72; + this->unk_174 = 0x1C72; + } + func_80B82454(this, globalCtx); + func_80B8259C(this, globalCtx); + func_80B82DC4(this); + } else if (sp2C == 3) { + this->unk_16C = sp24; + this->unk_170 = sp24; + if (sp24 != 0) { + func_80B83344(this); + } else { + this->unk_178 = 0x1F4; + func_80B833A8(this); + } + } +} + +void BgDblueBalance_Destroy(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgDblueBalance* this = THIS; + s32 sp1C = BGDBLUEBALANCE_GET_300(&this->dyna.actor); + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + + if (sp1C == 0) { + if (this->unk_15C != NULL) { + this->unk_15C->unk_164 = NULL; + } + if (this->unk_160 != NULL) { + this->unk_160->unk_164 = NULL; + } + } else if (sp1C == 1) { + if (this->unk_164 != NULL) { + this->unk_164->unk_15C = NULL; + } + } else if (sp1C == 2) { + if (this->unk_164 != NULL) { + this->unk_164->unk_160 = NULL; + } + } +} + +void func_80B82DC4(BgDblueBalance* this) { + this->unk_17D = 20; + this->actionFunc = func_80B82DE0; +} + +void func_80B82DE0(BgDblueBalance* this, GlobalContext* globalCtx) { + s32 pad; + f32 sp88 = Math_CosS(this->dyna.actor.shape.rot.z * 2.2499313f); + Actor* actor = &this->dyna.actor; + s32 pad2; + s16 abs; + s32 phi_a0; + s32 phi_a1; + f32 phi_f2; + f32 temp2; + Vec3f sp60; + BgDblueBalance* sp5C; + Vec3f sp50; + s32 pad3; + Vec3f sp40; + BgDblueBalance* sp3C; + Vec3f sp30; + + if (Flags_GetSwitch(globalCtx, BGDBLUEBALANCE_GET_7F(&this->dyna.actor))) { + if (this->unk_17D > 0) { + this->unk_17D--; + } else { + this->unk_174 = -0x1C72; + this->unk_176 = (s32)(sp88 * -300.0f) - 60; + } + } else { + BgDblueBalance* balance1 = this->unk_160; + BgDblueBalance* balance2 = this->unk_15C; + + phi_a0 = 0; + phi_a1 = 1; + this->unk_17D = 20; + if (balance1 != NULL) { + if (balance1->unk_181 != 0) { + phi_a0 = 4; + } else if (balance1->unk_180 != 0) { + phi_a0 = 2; + } + } + + if (balance2 != NULL) { + if (balance2->unk_181 != 0) { + phi_a1 = 5; + } else if (balance2->unk_180 != 0) { + phi_a1 = 3; + } + } + + if (phi_a0 < phi_a1) { + this->unk_174 = 0x1C72; + this->unk_176 = (s32)(sp88 * 370.0f) + 80; + } else { + this->unk_174 = -0x1C72; + this->unk_176 = (s32)(sp88 * -160.0f) - 80; + } + } + + if (this->dyna.actor.shape.rot.z == this->unk_174) { + this->unk_178 = 0; + this->unk_17C = 0; + return; + } + + abs = this->dyna.actor.shape.rot.z - this->unk_174; + abs = ABS_ALT(abs); + + if ((this->unk_17C > 0) && (abs < 0x7D0)) { + phi_a0 = 3; + } else { + phi_a0 = 40; + this->unk_17C = 0; + } + + if (this->unk_176 >= 0) { + this->unk_178 += phi_a0; + if (this->unk_176 < this->unk_178) { + this->unk_178 = this->unk_176; + } + } else { + this->unk_178 -= phi_a0; + if (this->unk_178 < this->unk_176) { + this->unk_178 = this->unk_176; + } + } + + phi_f2 = this->unk_178; + temp2 = this->unk_17A; + if ((phi_f2 * temp2) <= 0.0f) { + func_801A7328(&this->dyna.actor.projectedPos, NA_SE_EV_SEESAW_INCLINE - SFX_FLAG); + } + + phi_f2 *= 0.0022222223f; + phi_f2 = fabsf(phi_f2); + if (phi_f2 > 1.0f) { + phi_f2 = 1.0f; + } + + func_8019FAD8(&this->dyna.actor.projectedPos, NA_SE_EV_SEESAW_INCLINE - SFX_FLAG, phi_f2 + 1.0f); + actor->shape.rot.z += this->unk_178; + + if (this->dyna.actor.shape.rot.z > 0x1C71) { + if (this->unk_17C < 2) { + actor->shape.rot.z = 0x1C71; + this->unk_178 *= -0.6f; + this->unk_17C++; + if (this->unk_182) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SEESAW_WATER_BOUND); + sp5C = this->unk_15C; + Matrix_StatePush(); + Matrix_RotateY(BINANG_SUB(this->dyna.actor.shape.rot.y, 0x4000), MTXMODE_NEW); + Matrix_GetStateTranslationAndScaledZ(45.0f, &sp60); + Matrix_StatePop(); + + sp50.x = sp5C->dyna.actor.world.pos.x + sp60.x; + sp50.y = this->unk_228; + sp50.z = sp5C->dyna.actor.world.pos.z + sp60.z; + + func_80B8296C(globalCtx, &sp50, 70.0f); + } else { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SEESAW_BOUND); + } + } else { + this->dyna.actor.shape.rot.z = 0x1C72; + this->unk_178 = 0; + } + } else if (this->dyna.actor.shape.rot.z < -0x1C71) { + if (this->unk_17C < 2) { + actor->shape.rot.z = -0x1C71; + this->unk_178 *= -0.6f; + this->unk_17C++; + if (this->unk_182) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SEESAW_WATER_BOUND); + sp3C = this->unk_160; + Matrix_StatePush(); + Matrix_RotateY(BINANG_ADD(this->dyna.actor.shape.rot.y, 0x4000), MTXMODE_NEW); + Matrix_GetStateTranslationAndScaledZ(30.0f, &sp40); + Matrix_StatePop(); + + sp30.x = sp3C->dyna.actor.world.pos.x + sp40.x; + sp30.y = this->unk_228; + sp30.z = sp3C->dyna.actor.world.pos.z + sp40.z; + + func_80B8296C(globalCtx, &sp30, 47.0f); + } else { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SEESAW_BOUND); + } + } else { + this->dyna.actor.shape.rot.z = -0x1C72; + this->unk_178 = 0; + } + } + func_80B823B0(this); +} + +void BgDblueBalance_Update(Actor* thisx, GlobalContext* globalCtx) { + BgDblueBalance* this = THIS; + + this->unk_17A = this->unk_178; + + this->actionFunc(this, globalCtx); + + func_80B828E4(this, globalCtx); +} + +void func_80B8330C(Actor* thisx, GlobalContext* globalCtx) { + BgDblueBalance* this = THIS; + + this->unk_180 = DynaPolyActor_IsInSwitchPressedState(&this->dyna); + this->unk_181 = DynaPolyActor_IsInHeavySwitchPressedState(&this->dyna); +} + +void func_80B83344(BgDblueBalance* this) { + this->unk_178 = 0; + this->actionFunc = func_80B8335C; +} + +void func_80B8335C(BgDblueBalance* this, GlobalContext* globalCtx) { + if (!Flags_GetSwitch(globalCtx, BGDBLUEBALANCE_GET_7F(&this->dyna.actor))) { + this->unk_178 = -0x14; + func_80B833A8(this); + } +} + +void func_80B833A8(BgDblueBalance* this) { + this->unk_186 = 0; + this->unk_187 = 0; + this->actionFunc = func_80B833C4; +} + +void func_80B833C4(BgDblueBalance* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp28 = false; + s16 sp26; + s16 sp24; + + if (this->unk_170 != 0) { + if ((this->unk_16C == 0) && (this->unk_17F == 0)) { + this->unk_17F = 1; + } + + if (this->unk_186 != 0) { + if (this->unk_178 >= 0x50) { + this->unk_178 -= 5; + } + } + } else { + this->unk_187 = Math_StepToS(&this->unk_178, 0x1F4, 5); + } + + sp26 = this->dyna.actor.shape.rot.x; + this->dyna.actor.shape.rot.x += this->unk_178; + sp24 = this->dyna.actor.shape.rot.x; + if (sp24) {} + + if (this->unk_170 != 0) { + if (this->unk_186 != 0) { + if (func_80B82B00(sp26, sp24, this->unk_184)) { + sp28 = true; + } + } else if (this->unk_187 != 0) { + if (func_80B82B00(sp26, sp24, 0x2097)) { + this->unk_184 = -0x8000; + this->unk_186 = 1; + } else if (func_80B82B00(sp26, sp24, -0x5F69)) { + this->unk_184 = 0; + this->unk_186 = 1; + } + } + } + + func_80B8264C(this); + + if (sp28) { + this->dyna.actor.shape.rot.x = this->unk_184; + func_80B83344(this); + } +} + +void func_80B83518(Actor* thisx, GlobalContext* globalCtx) { + BgDblueBalance* this = THIS; + + this->unk_170 = Flags_GetSwitch(globalCtx, BGDBLUEBALANCE_GET_7F(&this->dyna.actor)); + + this->actionFunc(this, globalCtx); + + if (this->unk_17F == 2) { + this->unk_17E--; + if (this->unk_17E <= 0) { + ActorCutscene_Stop(this->dyna.actor.cutscene); + this->unk_17F = 0; + } + } else if ((this->unk_17F != 0) && (this->unk_17F == 1)) { + if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + this->unk_17F = 2; + this->unk_17E = 0x50; + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } + } + this->unk_16C = this->unk_170; +} + +void BgDblueBalance_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgDblueBalance* this = THIS; + BgDblueBalanceStruct2* ptr2 = &D_80B83A20[BGDBLUEBALANCE_GET_300(&this->dyna.actor)]; + BgDblueBalance* sp38; + Gfx* gfx; + + Gfx_DrawDListOpa(globalCtx, ptr2->unk_00); + + if (!(BGDBLUEBALANCE_GET_300(&this->dyna.actor)) && (this->unk_160 != NULL)) { + AnimatedMat_Draw(globalCtx, D_80B83C74); + sp38 = this->unk_160; + Matrix_SetStateRotationAndTranslation(sp38->dyna.actor.world.pos.x, sp38->dyna.actor.world.pos.y, + sp38->dyna.actor.world.pos.z, &sp38->dyna.actor.shape.rot); + Matrix_InsertTranslation(30.0f, 15.0f, 0.0f, MTXMODE_APPLY); + Matrix_Scale(sp38->dyna.actor.scale.x, sp38->dyna.actor.scale.y, sp38->dyna.actor.scale.z, MTXMODE_APPLY); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gfx = POLY_XLU_DISP; + + gSPDisplayList(gfx++, &sSetupDL[6 * 25]); + gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetEnvColor(gfx++, 0, 0, 0, this->unk_183); + gSPDisplayList(gfx++, object_dblue_object_DL_00D110); + + POLY_XLU_DISP = gfx; + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +void func_80B83758(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgDblueBalance* this = THIS; + f32 temp_f0; + Gfx* gfx; + s32 i; + BgDblueBalanceStruct* ptr; + BgDblueBalanceStruct2* ptr2; + s32 temp; + + if (this->unk_178 != 0) { + if (this->unk_178 == 0x1F4) { + temp_f0 = 1.0f; + } else { + temp_f0 = this->unk_178 * 0.002f; + temp_f0 = CLAMP(temp_f0, 0.0f, 1.0f); + } + func_8019FB0C(&this->dyna.actor.projectedPos, NA_SE_EV_SMALL_WATER_WHEEL - SFX_FLAG, temp_f0, 0x20); + } + + if (this->dyna.actor.flags & ACTOR_FLAG_40) { + ptr2 = &D_80B83A20[BGDBLUEBALANCE_GET_300(&this->dyna.actor)]; + Gfx_DrawDListOpa(globalCtx, ptr2->unk_00); + + if (this->unk_183 != 0) { + AnimatedMat_Draw(globalCtx, D_80B83C70); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gfx = POLY_XLU_DISP; + + gSPDisplayList(gfx++, &sSetupDL[6 * 25]); + + for (i = 0, ptr = &this->unk_188[0]; i < ARRAY_COUNT(this->unk_188); i++, ptr++) { + if (ptr->unk_0E != 0) { + Matrix_InsertTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, MTXMODE_NEW); + Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(ptr->unk_0C, MTXMODE_APPLY); + Matrix_Scale(ptr->unk_10, ptr->unk_10, ptr->unk_10, MTXMODE_APPLY); + + temp = ptr->unk_0E * (f32)this->unk_183 * 0.003921569f; + gDPSetEnvColor(gfx++, 0, 0, 0, temp); + gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(gfx++, object_dblue_object_DL_00CD10); + } + } + + POLY_XLU_DISP = gfx; + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + } +} diff --git a/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.h b/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.h index 8750f40771..16eed26e32 100644 --- a/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.h +++ b/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.h @@ -7,11 +7,41 @@ struct BgDblueBalance; typedef void (*BgDblueBalanceActionFunc)(struct BgDblueBalance*, GlobalContext*); +#define BGDBLUEBALANCE_GET_7F(thisx) ((thisx)->params & 0x7F) +#define BGDBLUEBALANCE_GET_300(thisx) (((thisx)->params >> 8) & 3) + +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ s16 unk_0C; + /* 0x0E */ u8 unk_0E; + /* 0x10 */ f32 unk_10; +} BgDblueBalanceStruct; // size = 0x14 + typedef struct BgDblueBalance { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x24]; + /* 0x0000 */ DynaPolyActor dyna; + /* 0x015C */ struct BgDblueBalance* unk_15C; + /* 0x0160 */ struct BgDblueBalance* unk_160; + /* 0x0164 */ struct BgDblueBalance* unk_164; /* 0x0168 */ BgDblueBalanceActionFunc actionFunc; - /* 0x016C */ char unk_16C[0xC0]; + /* 0x016C */ s32 unk_16C; + /* 0x0170 */ s32 unk_170; + /* 0x0174 */ s16 unk_174; + /* 0x0176 */ s16 unk_176; + /* 0x0178 */ s16 unk_178; + /* 0x017A */ s16 unk_17A; + /* 0x017C */ s8 unk_17C; + /* 0x017D */ s8 unk_17D; + /* 0x017E */ s8 unk_17E; + /* 0x017F */ s8 unk_17F; + /* 0x0180 */ s8 unk_180; + /* 0x0181 */ s8 unk_181; + /* 0x0182 */ s8 unk_182; + /* 0x0183 */ u8 unk_183; + /* 0x0184 */ s16 unk_184; + /* 0x0186 */ s8 unk_186; + /* 0x0187 */ s8 unk_187; + /* 0x0188 */ BgDblueBalanceStruct unk_188[8]; + /* 0x0228 */ f32 unk_228; } BgDblueBalance; // size = 0x22C extern const ActorInit Bg_Dblue_Balance_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.c b/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.c index 0c124dc07d..cd3b8a9d6a 100644 --- a/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.c +++ b/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.c @@ -5,6 +5,7 @@ */ #include "z_bg_dblue_waterfall.h" +#include "objects/object_dblue_object/object_dblue_object.h" #define FLAGS (ACTOR_FLAG_10) @@ -15,12 +16,15 @@ void BgDblueWaterfall_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgDblueWaterfall_Update(Actor* thisx, GlobalContext* globalCtx); void BgDblueWaterfall_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80B8484C(BgDblueWaterfall* this, GlobalContext* globalCtx); void func_80B84928(BgDblueWaterfall* this, GlobalContext* globalCtx); +void func_80B84AD4(BgDblueWaterfall* this, GlobalContext* globalCtx); void func_80B84AEC(BgDblueWaterfall* this, GlobalContext* globalCtx); +void func_80B84B9C(BgDblueWaterfall* this, GlobalContext* globalCtx); void func_80B84BCC(BgDblueWaterfall* this, GlobalContext* globalCtx); +void func_80B84EF0(BgDblueWaterfall* this, GlobalContext* globalCtx); void func_80B84F20(BgDblueWaterfall* this, GlobalContext* globalCtx); -#if 0 const ActorInit Bg_Dblue_Waterfall_InitVars = { ACTOR_BG_DBLUE_WATERFALL, ACTORCAT_PROP, @@ -33,69 +37,596 @@ const ActorInit Bg_Dblue_Waterfall_InitVars = { (ActorFunc)BgDblueWaterfall_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B85370 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00CBFBB0, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00CBFBB0, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 50, 740, -740, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B853A8[] = { +Color_RGBA8 D_80B8539C = { 200, 255, 255, 255 }; +Color_RGBA8 D_80B853A0 = { 200, 200, 200, 0 }; + +s32 func_80B83C80(Vec3f* arg0, Vec3f* arg1) { + f32 temp_f0 = Math3D_LengthSquared(arg0); + f32 temp_f2; + + if (temp_f0 < 0.0000010000001f) { + return false; + } + + temp_f2 = 1.0f / sqrtf(temp_f0); + arg1->x = arg0->x * temp_f2; + arg1->y = arg0->y * temp_f2; + arg1->z = arg0->z * temp_f2; + + return true; +} + +s32 func_80B83D04(BgDblueWaterfall* this, GlobalContext* globalCtx) { + s32 phi_v1; + s32 sp18 = BGDBLUEWATERFALL_GET_100(&this->actor); + + if (Flags_GetSwitch(globalCtx, BGDBLUEWATERFALL_GET_7F(&this->actor))) { + phi_v1 = true; + } else { + phi_v1 = false; + } + return phi_v1 ^ sp18; +} + +s32 func_80B83D58(Actor* thisx, GlobalContext* globalCtx) { + BgDblueWaterfall* this = THIS; + + if (Flags_GetSwitch(globalCtx, BGDBLUEWATERFALL_GET_7F(&this->actor))) { + return false; + } + return true; +} + +void func_80B83D94(BgDblueWaterfall* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp20 = BGDBLUEWATERFALL_GET_7F(&this->actor); + s32 sp1C = BGDBLUEWATERFALL_GET_100(&this->actor); + s32 phi_v0; + + if (Flags_GetSwitch(globalCtx, sp20)) { + phi_v0 = true; + } else { + phi_v0 = false; + } + + if (phi_v0 != sp1C) { + if (phi_v0) { + Flags_UnsetSwitch(globalCtx, sp20); + } else { + Flags_SetSwitch(globalCtx, sp20); + } + } +} + +void func_80B83E1C(BgDblueWaterfall* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp20 = BGDBLUEWATERFALL_GET_7F(&this->actor); + s32 sp1C = BGDBLUEWATERFALL_GET_100(&this->actor); + s32 phi_v0; + + if (Flags_GetSwitch(globalCtx, sp20)) { + phi_v0 = true; + } else { + phi_v0 = false; + } + + if (phi_v0 == sp1C) { + if (phi_v0) { + Flags_UnsetSwitch(globalCtx, sp20); + } else { + Flags_SetSwitch(globalCtx, sp20); + } + } +} + +void func_80B83EA4(BgDblueWaterfall* this, GlobalContext* globalCtx) { + s32 i; + s32 temp_s1; + Vec3f spD4; + Vec3f spC8; + Vec3f spBC; + Vec3f spB0; + Vec3f spA4; + Vec3f sp98; + s32 phi_s3; + + if (this->collider.info.bumperFlags & BUMP_HIT) { + f32 temp_f0_2; + f32 temp_f20; + + spB0.x = this->collider.info.bumper.hitPos.x; + spB0.y = this->collider.info.bumper.hitPos.y; + spB0.z = this->collider.info.bumper.hitPos.z; + + sp98.x = spB0.x - this->actor.world.pos.x; + sp98.y = 0.0f; + sp98.z = spB0.z - this->actor.world.pos.z; + + if (!func_80B83C80(&sp98, &spA4)) { + Math_Vec3f_Copy(&spA4, &gZeroVec3f); + } + + sp98.y = 0.0f; + spBC.y = -1.4f; + + for (i = 0, phi_s3 = 0; i < 15; i++, phi_s3 += 0x1111) { + temp_s1 = (s32)(Rand_ZeroOne() * 4369.0f) + phi_s3; + temp_f0_2 = Rand_ZeroOne(); + temp_f20 = 1.0f - SQ(temp_f0_2); + + sp98.x = Math_SinS(temp_s1) * temp_f20; + sp98.z = Math_CosS(temp_s1) * temp_f20; + temp_f20 *= 5.0f; + + spD4.x = (sp98.x * temp_f20) + spB0.x; + spD4.y = ((Rand_ZeroOne() * 16.0f) - 8.0f) + spB0.y; + spD4.z = (sp98.z * temp_f20) + spB0.z; + + spC8.x = ((2.0f * Rand_ZeroOne()) - 1.0f) + ((spA4.x * 3.0f) + (sp98.x * 5.0f)); + spC8.y = (Rand_ZeroOne() * 10.0f) + 5.0f; + spC8.z = ((2.0f * Rand_ZeroOne()) - 1.0f) + ((spA4.z * 3.0f) + (sp98.z * 5.0f)); + + spBC.x = spC8.x * -0.02f; + spBC.z = spC8.z * -0.02f; + + EffectSsEnIce_Spawn(globalCtx, &spD4, (Rand_ZeroOne() * 0.3f) + 0.1f, &spC8, &spBC, &D_80B8539C, + &D_80B853A0, 30); + } + } +} + +void func_80B841A0(BgDblueWaterfall* this, GlobalContext* globalCtx) { + Vec3f sp94; + s32 i; + f32 temp_f0; + f32 temp_f20; + f32 temp_f22; + f32 temp_f24; + f32 temp_f26; + s32 temp_s3; + s32 phi_s2; + + if (this->collider.info.bumperFlags & BUMP_HIT) { + temp_f22 = this->collider.info.bumper.hitPos.x; + temp_f24 = this->collider.info.bumper.hitPos.y; + temp_f26 = this->collider.info.bumper.hitPos.z; + + for (i = 0, phi_s2 = 0; i < 10; i++, phi_s2 += 0x1999) { + temp_s3 = (s32)(Rand_ZeroOne() * 6553.0f) + phi_s2; + temp_f0 = Rand_ZeroOne(); + temp_f20 = (1.0f - SQ(temp_f0)) * 14.0f; + + sp94.x = (Math_SinS(temp_s3) * temp_f20) + temp_f22; + sp94.y = ((Rand_ZeroOne() * 20.0f) - 10.0f) + temp_f24; + sp94.z = (Math_CosS(temp_s3) * temp_f20) + temp_f26; + + EffectSsGSplash_Spawn(globalCtx, &sp94, NULL, NULL, 0, 250); + } + + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_REFLECTION_WATER); + } +} + +void func_80B84348(BgDblueWaterfall* this, GlobalContext* globalCtx, f32 arg2, f32 arg3, f32 arg4, f32 arg5, f32 arg6, + f32 arg7, s32 arg8) { + static s16 D_80B853A4 = 0; + s32 pad; + f32 spB8 = 1.0f / arg8; + s32 i; + f32 spB0 = this->actor.world.pos.y + arg3; + s32 pad2; + f32 temp_f22; + f32 temp_f24; + Vec3f sp98; + Vec3f sp8C; + Vec3f sp80; + f32 temp_f26; + f32 temp_f20; + + for (i = 0; i < arg8; i++) { + D_80B853A4 += 0x4E20; + + temp_f20 = Math_SinS(D_80B853A4); + temp_f24 = (Rand_ZeroOne() * (arg2 - arg3)) + (spB8 * i); + temp_f22 = Math_CosS(D_80B853A4); + temp_f26 = ((Rand_ZeroOne() * 0.8f) + 0.2f) * arg4; + + sp8C.x = temp_f20 * temp_f26; + sp8C.y = (Rand_ZeroOne() * 4.0f) + arg5; + sp8C.z = temp_f22 * temp_f26; + + sp80.x = sp8C.x * -0.016f; + sp80.y = sp8C.y * -0.015f; + sp80.z = sp8C.z * -0.016f; + + sp98.x = (temp_f20 * 50.0f) + this->actor.world.pos.x; + sp98.y = temp_f24 + spB0; + sp98.z = (temp_f22 * 50.0f) + this->actor.world.pos.z; + + EffectSsIceSmoke_Spawn(globalCtx, &sp98, &sp8C, &sp80, (Rand_ZeroOne() * arg7) + arg6); + } +} + +void func_80B84568(BgDblueWaterfall* this, GlobalContext* globalCtx) { + s32 pad; + CollisionPoly* sp40; + WaterBox* sp3C; + s32 sp38; + f32 sp34 = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &sp40, &sp38, &this->actor, &this->actor.world.pos); + f32 sp30; + + if (WaterBox_GetSurface1_2(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp30, + &sp3C)) { + if (sp30 < sp34) { + this->unk_198 = sp34; + } else { + this->unk_198 = sp30; + } + } else { + this->unk_198 = sp34; + } +} + +void func_80B84610(BgDblueWaterfall* this, GlobalContext* globalCtx) { + s32 pad[2]; + Vec3f sp34; + Player* player = GET_PLAYER(globalCtx); + + if (this->unk_1A7 <= 0) { + this->unk_1A7 = 16; + } else { + this->unk_1A7 -= (s8)((u32)Rand_Next() >> 0x1F); + } + + if (this->unk_1A7 >= 6) { + this->unk_1A8 += Rand_ZeroOne() * 0.1f; + if (this->unk_1A8 > 0.5f) { + this->unk_1A8 = 0.5f; + } else { + this->unk_1A8 = this->unk_1A8; + } + } else { + this->unk_1A8 -= Rand_ZeroOne() * 0.2f; + if (this->unk_1A8 > -0.5f) { + this->unk_1A8 = -0.5f; + } else { + this->unk_1A8 = this->unk_1A8; + } + } + + Matrix_StatePush(); + Matrix_RotateY(BINANG_ADD(this->actor.yawTowardsPlayer, 0x4000), MTXMODE_NEW); + Matrix_GetStateTranslationAndScaledZ(this->unk_1A8, &sp34); + Matrix_StatePop(); + + player->actor.world.pos.x += sp34.x; + player->actor.world.pos.z += sp34.z; + if (this && this && this) {} + player->unk_B80 = 8.0f; + player->unk_B84 = this->actor.yawTowardsPlayer; +} + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 1500, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 1500, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#endif +void BgDblueWaterfall_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgDblueWaterfall* this = THIS; -extern ColliderCylinderInit D_80B85370; -extern InitChainEntry D_80B853A8[]; + Actor_ProcessInitChain(&this->actor, sInitChain); + this->actor.shape.rot.z = 0; + this->actor.world.rot.z = 0; -extern UNK_TYPE D_0600B280; -extern UNK_TYPE D_0600B448; + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_UpdateCylinder(&this->actor, &this->collider); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B83C80.s") + this->unk_190 = Lib_SegmentedToVirtual(object_dblue_object_Matanimheader_00B448); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B83D04.s") + Actor_SetFocus(&this->actor, -100.0f); + func_80B84568(this, globalCtx); + func_80B8484C(this, globalCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B83D58.s") +void BgDblueWaterfall_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgDblueWaterfall* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B83D94.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B83E1C.s") +void func_80B8484C(BgDblueWaterfall* this, GlobalContext* globalCtx) { + s32 pad; + s32 temp = func_80B83D04(this, globalCtx); + s32 sp1C = this->actor.home.rot.z * 10; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B83EA4.s") + if (temp) { + this->unk_19E = 0; + this->unk_19F = 255; + this->unk_1A0 = 0; + this->collider.dim.radius = 55; + this->collider.dim.height = 150; + this->collider.dim.yShift = -150; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + } else { + this->unk_19E = 255; + this->unk_19F = 0; + this->unk_1A0 = 0; + this->collider.dim.radius = 50; + this->collider.dim.height = 740; + this->collider.dim.yShift = -740; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B841A0.s") + if ((sp1C != 0) && !func_80B83D58(&this->actor, globalCtx)) { + this->unk_19C = sp1C; + } else { + this->unk_19C = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B84348.s") + this->unk_1A3 = false; + this->actionFunc = func_80B84928; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B84568.s") +void func_80B84928(BgDblueWaterfall* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp30 = func_80B83D04(this, globalCtx); + s32 sp2C = (this->collider.base.acFlags & AC_HIT) != 0; + s32 sp28 = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B84610.s") + if (sp2C) { + this->collider.base.acFlags &= ~AC_HIT; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/BgDblueWaterfall_Init.s") + if ((sp30 == 0) && (this->collider.base.ocFlags2 & OC2_HIT_PLAYER)) { + func_80B84610(this, globalCtx); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/BgDblueWaterfall_Destroy.s") + if (this->unk_19C > 0) { + this->unk_19C--; + if (this->unk_19C == 0) { + if (sp30 != 0) { + func_80B83D94(this, globalCtx); + func_80B84EF0(this, globalCtx); + } else { + func_80B83E1C(this, globalCtx); + func_80B84B9C(this, globalCtx); + } + sp28 = true; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B8484C.s") + if (!sp28) { + if (sp2C) { + if (sp30 != 0) { + func_80B83EA4(this, globalCtx); + if (this->collider.info.acHitInfo->toucher.dmgFlags & 0x800) { + this->unk_1A4 = this->actor.cutscene; + func_80B84AD4(this, globalCtx); + } + } else { + func_80B841A0(this, globalCtx); + if (this->collider.info.acHitInfo->toucher.dmgFlags & 0x1000) { + this->unk_1A4 = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); + func_80B84AD4(this, globalCtx); + } + } + } else { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B84928.s") +void func_80B84AD4(BgDblueWaterfall* this, GlobalContext* globalCtx) { + this->actionFunc = func_80B84AEC; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B84AD4.s") +void func_80B84AEC(BgDblueWaterfall* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B84AEC.s") + if (ActorCutscene_GetCanPlayNext(this->unk_1A4)) { + sp20 = func_80B83D04(this, globalCtx); + ActorCutscene_StartAndSetUnkLinkFields(this->unk_1A4, &this->actor); + this->unk_1A3 = true; + if (sp20) { + func_80B83D94(this, globalCtx); + func_80B84EF0(this, globalCtx); + } else { + func_80B83E1C(this, globalCtx); + func_80B84B9C(this, globalCtx); + } + } else { + ActorCutscene_SetIntentToPlay(this->unk_1A4); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B84B9C.s") +void func_80B84B9C(BgDblueWaterfall* this, GlobalContext* globalCtx) { + this->unk_19C = 60; + this->unk_19E = 255; + this->unk_19F = 0; + this->unk_1A0 = 0; + this->actionFunc = func_80B84BCC; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B84BCC.s") +void func_80B84BCC(BgDblueWaterfall* this, GlobalContext* globalCtx) { + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B84EF0.s") + this->unk_19C--; + if (this->unk_19C > 0) { + s32 sp38 = this->unk_19C & 1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B84F20.s") + if (this->unk_19C > 56) { + func_80B84348(this, globalCtx, 0.0f, -5500.0f, 0.4f, -15.0f, 370.0f, 100.0f, 6); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/BgDblueWaterfall_Update.s") + if (!sp38) { + if ((this->unk_19C < 24) && (this->unk_19C > 10)) { + if (this->unk_198 > -32000.0f) { + func_80B84348(this, globalCtx, (this->unk_198 - this->actor.world.pos.y) + 50.0f, + (this->unk_198 - this->actor.world.pos.y), 7.0f, -1.0f, 280.0f, 100.0f, 3); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/BgDblueWaterfall_Draw.s") + if (this->unk_19C > 50) { + func_80B84348(this, globalCtx, 0.0f, -400.0f, 0.6f, -12.0f, 370.0f, 100.0f, 2); + } else if (this->unk_19C > 40) { + func_80B84348(this, globalCtx, 0.0f, -400.0f, 1.0f, -12.0f, 370.0f, 100.0f, 2); + } else if (this->unk_19C > 20) { + func_80B84348(this, globalCtx, 0.0f, -400.0f, 1.8f, -12.0f, 370.0f, 100.0f, 2); + } + } + + if (this->unk_19E > 6) { + this->unk_19E -= 6; + } else { + this->unk_19E = 0; + } + + if (this->unk_19C >= 55) { + if (this->unk_1A0 < 205) { + this->unk_1A0 += 50; + } else { + this->unk_1A0 = 255; + } + } else if (this->unk_19C >= 36) { + if (this->unk_1A0 >= 16) { + this->unk_1A0 -= 15; + } else { + this->unk_1A0 = 0; + } + } else { + this->unk_1A0 = 0; + } + + if (this->unk_19C < 60) { + if (this->unk_19F < 245) { + this->unk_19F += 10; + } else { + this->unk_19F = 255; + } + } + + func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); + } else { + if (this->unk_1A3) { + ActorCutscene_Stop(this->unk_1A4); + } + func_80B8484C(this, globalCtx); + } +} + +void func_80B84EF0(BgDblueWaterfall* this, GlobalContext* globalCtx) { + this->unk_19C = 60; + this->unk_19E = 0; + this->unk_19F = 255; + this->unk_1A0 = 0; + this->actionFunc = func_80B84F20; +} + +void func_80B84F20(BgDblueWaterfall* this, GlobalContext* globalCtx) { + this->unk_19C--; + + if (this->unk_19C > 0) { + if (this->unk_19C >= 58) { + func_80B84348(this, globalCtx, 100.0f, -100.0f, 4.0f, -6.0f, 370.0f, 100.0f, 0xC); + } + + if (this->unk_19C < 50) { + if (this->unk_19E < 250) { + this->unk_19E += 5; + } else { + this->unk_19E = 255; + } + } + + if (this->unk_19F >= 6) { + this->unk_19F -= 5; + } else { + this->unk_19F = 0; + } + + func_800B9010(&this->actor, NA_SE_EV_ICE_MELT_LEVEL - SFX_FLAG); + } else { + if (this->unk_1A3) { + ActorCutscene_Stop(this->unk_1A4); + } + func_80B8484C(this, globalCtx); + } +} + +void BgDblueWaterfall_Update(Actor* thisx, GlobalContext* globalCtx) { + BgDblueWaterfall* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void BgDblueWaterfall_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgDblueWaterfall* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + if (this->unk_19E > 0) { + s32 sp38 = this->unk_19E * 0.49803922f; + + AnimatedMat_Draw(globalCtx, this->unk_190); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x8A, 255, 255, 255, sp38); + gSPDisplayList(POLY_XLU_DISP++, object_dblue_object_DL_00B280); + } + + if (this->unk_19F > 0) { + if (this->unk_19F < 255) { + gSPSegment(POLY_XLU_DISP++, 0x09, D_801AEF88); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x9B, 255, 255, 255, this->unk_19F); + gSPDisplayList(POLY_XLU_DISP++, object_dblue_object_DL_003358); + } else { + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x09, D_801AEFA0); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x9B, 255, 255, 255, 255); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_dblue_object_DL_003358); + } + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0xFF, 255, 255, 255, this->unk_19F); + gSPDisplayList(POLY_XLU_DISP++, object_dblue_object_DL_003250); + } + + if (this->unk_1A0 > 0) { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0xFF, 255, 255, 255, this->unk_1A0); + gSPDisplayList(POLY_XLU_DISP++, object_dblue_object_DL_003770); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.h b/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.h index eb12538fcd..0fa908629a 100644 --- a/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.h +++ b/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.h @@ -7,11 +7,25 @@ struct BgDblueWaterfall; typedef void (*BgDblueWaterfallActionFunc)(struct BgDblueWaterfall*, GlobalContext*); +#define BGDBLUEWATERFALL_GET_7F(thisx) ((thisx)->params & 0x7F) +#define BGDBLUEWATERFALL_GET_100(thisx) (((thisx)->params >> 8) & 1) + typedef struct BgDblueWaterfall { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x50]; + /* 0x0144 */ ColliderCylinder collider; + /* 0x0190 */ AnimatedMaterial* unk_190; /* 0x0194 */ BgDblueWaterfallActionFunc actionFunc; - /* 0x0198 */ char unk_198[0x14]; + /* 0x0198 */ f32 unk_198; + /* 0x019C */ s16 unk_19C; + /* 0x019E */ u8 unk_19E; + /* 0x019F */ u8 unk_19F; + /* 0x01A0 */ u8 unk_1A0; + /* 0x01A1 */ UNK_TYPE1 unk1A1[2]; + /* 0x01A3 */ s8 unk_1A3; + /* 0x01A4 */ s16 unk_1A4; + /* 0x01A6 */ UNK_TYPE1 unk1A6[1]; + /* 0x01A7 */ s8 unk_1A7; + /* 0x01A8 */ f32 unk_1A8; } BgDblueWaterfall; // size = 0x1AC extern const ActorInit Bg_Dblue_Waterfall_InitVars; diff --git a/src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.c b/src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.c index 769118e697..1e8c369fbd 100644 --- a/src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.c +++ b/src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.c @@ -5,6 +5,7 @@ */ #include "z_bg_f40_block.h" +#include "objects/object_f40_obj/object_f40_obj.h" #define FLAGS (ACTOR_FLAG_10) @@ -15,7 +16,16 @@ void BgF40Block_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgF40Block_Update(Actor* thisx, GlobalContext* globalCtx); void BgF40Block_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80BC41AC(BgF40Block* this, GlobalContext* globalCtx); +void func_80BC4228(BgF40Block* this, GlobalContext* globalCtx); +void func_80BC4344(BgF40Block* this, GlobalContext* globalCtx); +void func_80BC4380(BgF40Block* this, GlobalContext* globalCtx); +void func_80BC43CC(BgF40Block* this, GlobalContext* globalCtx); +void func_80BC4448(BgF40Block* this, GlobalContext* globalCtx); +void func_80BC44F4(BgF40Block* this, GlobalContext* globalCtx); +void func_80BC4530(BgF40Block* this, GlobalContext* globalCtx); +void func_80BC457C(BgF40Block* this, GlobalContext* globalCtx); + const ActorInit Bg_F40_Block_InitVars = { ACTOR_BG_F40_BLOCK, ACTORCAT_BG, @@ -28,55 +38,340 @@ const ActorInit Bg_F40_Block_InitVars = { (ActorFunc)BgF40Block_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80BC4668[] = { +static Vec3f D_80BC4620[] = { + { 1.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, { 0.0f, 0.0f, 1.0f }, + { -1.0f, 0.0f, 0.0f }, { 0.0f, -1.0f, 0.0f }, { 0.0f, 0.0f, -1.0f }, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 400, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 400, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#endif +s32 func_80BC3980(BgF40Block* this, GlobalContext* globalCtx) { + Vec3s* points; -extern InitChainEntry D_80BC4668[]; + this->unk_160 = 0; + this->unk_164 = 0; -extern UNK_TYPE D_060043D0; -extern UNK_TYPE D_06004640; + if (BGF40BLOCK_GET_PATH(&this->dyna.actor) != 0x3F) { + this->path = &globalCtx->setupPathList[BGF40BLOCK_GET_PATH(&this->dyna.actor)]; + if (this->path != NULL) { + points = Lib_SegmentedToVirtual(this->path->points); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC3980.s") + this->dyna.actor.world.pos.x = points->x; + this->dyna.actor.world.pos.y = points->y; + this->dyna.actor.world.pos.z = points->z; + } + } else { + this->path = NULL; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC3A2C.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC3B00.s") +s32 func_80BC3A2C(BgF40Block* this, GlobalContext* globalCtx) { + Vec3s* points; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC3CA4.s") + this->unk_160 = this->path->count - 1; + this->unk_164 = this->path->count - 1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC3D08.s") + if (BGF40BLOCK_GET_PATH(&this->dyna.actor) != 0x3F) { + this->path = &globalCtx->setupPathList[BGF40BLOCK_GET_PATH(&this->dyna.actor)]; + if (this->path != NULL) { + points = Lib_SegmentedToVirtual(this->path->points); + points += this->unk_164; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC4038.s") + this->dyna.actor.world.pos.x = points->x; + this->dyna.actor.world.pos.y = points->y; + this->dyna.actor.world.pos.z = points->z; + } + } else { + this->path = NULL; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/BgF40Block_Init.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/BgF40Block_Destroy.s") +s32 func_80BC3B00(BgF40Block* this) { + s32 pad; + Path* path; + Vec3s* points; + Vec3f sp28; + Vec3f sp24; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC41AC.s") + if (this->path == NULL) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC4228.s") + if (this->unk_160 == this->unk_164) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC4344.s") + path = this->path; + points = Lib_SegmentedToVirtual(path->points); + points += this->unk_164; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC4380.s") + sp28.x = points->x; + sp28.y = points->y; + sp28.z = points->z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC43CC.s") + if (this->unk_168 == 6) { + sp24.x = sp28.x - this->dyna.actor.world.pos.x; + sp24.y = sp28.y - this->dyna.actor.world.pos.y; + sp24.z = sp28.z - this->dyna.actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC4448.s") + if (sp24.x > 10.0f) { + this->unk_168 = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC44F4.s") + if (sp24.y > 10.0f) { + this->unk_168 = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC4530.s") + if (sp24.z > 10.0f) { + this->unk_168 = 2; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC457C.s") + if (sp24.x < -10.0f) { + this->unk_168 = 3; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/BgF40Block_Update.s") + if (sp24.y < -10.0f) { + this->unk_168 = 4; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/BgF40Block_Draw.s") + if (sp24.z < -10.0f) { + this->unk_168 = 5; + } + } + + if (Math_Vec3f_StepTo(&this->dyna.actor.world.pos, &sp28, this->dyna.actor.speedXZ) <= 0.0f) { + this->unk_168 = 6; + this->unk_160 = this->unk_164; + return true; + } + return false; +} + +s32 func_80BC3CA4(BgF40Block* this) { + if (this->dyna.actor.cutscene == -1) { + return true; + } + + if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + return true; + } + + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + return false; +} + +s32 func_80BC3D08(BgF40Block* this, GlobalContext* globalCtx, s32 arg2) { + CollisionPoly* sp54; + Vec3f sp48; + Vec3f sp3C; + Vec3f sp30; + + if (this->unk_168 == 6) { + return false; + } + + if (arg2 != 0) { + sp48.x = + (D_80BC4620[this->unk_168].x * ((800.0f * this->dyna.actor.scale.x) - (this->dyna.actor.speedXZ * 0.5f))) + + this->dyna.actor.world.pos.x; + sp48.y = + (D_80BC4620[this->unk_168].y * ((800.0f * this->dyna.actor.scale.y) - (this->dyna.actor.speedXZ * 0.5f))) + + this->dyna.actor.world.pos.y; + sp48.z = + (D_80BC4620[this->unk_168].z * ((800.0f * this->dyna.actor.scale.z) - (this->dyna.actor.speedXZ * 0.5f))) + + this->dyna.actor.world.pos.z; + + sp3C.x = (D_80BC4620[this->unk_168].x * this->dyna.actor.speedXZ) + sp48.x; + sp3C.y = (D_80BC4620[this->unk_168].y * this->dyna.actor.speedXZ) + sp48.y; + sp3C.z = (D_80BC4620[this->unk_168].z * this->dyna.actor.speedXZ) + sp48.z; + } else { + sp3C.x = (D_80BC4620[this->unk_168].x * 800.0f * this->dyna.actor.scale.x) + this->dyna.actor.world.pos.x; + sp3C.y = (D_80BC4620[this->unk_168].y * 800.0f * this->dyna.actor.scale.y) + this->dyna.actor.world.pos.y; + sp3C.z = (D_80BC4620[this->unk_168].z * 800.0f * this->dyna.actor.scale.z) + this->dyna.actor.world.pos.z; + + sp48.x = sp3C.x - (D_80BC4620[this->unk_168].x * this->dyna.actor.speedXZ * 1.5f); + sp48.y = sp3C.y - (D_80BC4620[this->unk_168].y * this->dyna.actor.speedXZ * 1.5f); + sp48.z = sp3C.z - (D_80BC4620[this->unk_168].z * this->dyna.actor.speedXZ * 1.5f); + } + + if (BgCheck_AnyLineTest1(&globalCtx->colCtx, &sp48, &sp3C, &sp30, &sp54, true)) { + if (arg2 == 0) { + this->dyna.actor.world.pos.x -= sp3C.x - sp30.x; + this->dyna.actor.world.pos.y -= sp3C.y - sp30.y; + this->dyna.actor.world.pos.z -= sp3C.z - sp30.z; + } + return true; + } + + return false; +} + +void func_80BC4038(BgF40Block* this) { + s32 temp = this->unk_160; + + this->unk_160 = this->unk_164; + this->unk_164 = temp; + this->unk_168 = 6; +} + +void BgF40Block_Init(Actor* thisx, GlobalContext* globalCtx) { + BgF40Block* this = THIS; + + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_f40_obj_Colheader_004640); + + if (BGF40BLOCK_GET_PATH(&this->dyna.actor) != 0x3F) { + this->path = &globalCtx->setupPathList[BGF40BLOCK_GET_PATH(&this->dyna.actor)]; + } else { + this->path = NULL; + } + + if (this->path != NULL) { + if (Flags_GetSwitch(globalCtx, BGF40BLOCK_GET_SWITCHFLAG(&this->dyna.actor))) { + this->actionFunc = func_80BC4530; + this->dyna.actor.speedXZ = 40.0f; + func_80BC3A2C(this, globalCtx); + } else { + this->actionFunc = func_80BC4380; + this->dyna.actor.speedXZ = 20.0f; + func_80BC3980(this, globalCtx); + } + } else { + this->actionFunc = func_80BC457C; + } + this->unk_168 = 6; +} + +void BgF40Block_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgF40Block* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} + +void func_80BC41AC(BgF40Block* this, GlobalContext* globalCtx) { + if (func_80BC3D08(this, globalCtx, 1)) { + if (!Flags_GetSwitch(globalCtx, BGF40BLOCK_GET_SWITCHFLAG(&this->dyna.actor))) { + func_80BC4038(this); + this->actionFunc = func_80BC44F4; + } + } else { + this->actionFunc = func_80BC4344; + } +} + +void func_80BC4228(BgF40Block* this, GlobalContext* globalCtx) { + if (func_80BC3B00(this)) { + this->dyna.actor.speedXZ = 20.0f; + if (this->unk_160 < (this->path->count - 1)) { + this->unk_164 = this->unk_160 + 1; + } else { + this->actionFunc = func_80BC4530; + ActorCutscene_Stop(this->dyna.actor.cutscene); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_IKANA_BLOCK_STOP_C); + } + } + + if (func_80BC3D08(this, globalCtx, 0)) { + ActorCutscene_Stop(this->dyna.actor.cutscene); + this->actionFunc = func_80BC41AC; + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_IKANA_BLOCK_STOP_F); + return; + } + + switch (this->unk_168) { + case 0: + case 3: + func_800B9010(&this->dyna.actor, NA_SE_EV_IKANA_BLOCK_MOVE_X - SFX_FLAG); + break; + + case 1: + case 4: + func_800B9010(&this->dyna.actor, NA_SE_EV_IKANA_BLOCK_MOVE_Y - SFX_FLAG); + break; + + case 2: + case 5: + func_800B9010(&this->dyna.actor, NA_SE_EV_IKANA_BLOCK_MOVE_Z - SFX_FLAG); + break; + } +} + +void func_80BC4344(BgF40Block* this, GlobalContext* globalCtx) { + if (func_80BC3CA4(this)) { + this->actionFunc = func_80BC4228; + } +} + +void func_80BC4380(BgF40Block* this, GlobalContext* globalCtx) { + if (Flags_GetSwitch(globalCtx, BGF40BLOCK_GET_SWITCHFLAG(&this->dyna.actor))) { + this->actionFunc = func_80BC4344; + } +} + +void func_80BC43CC(BgF40Block* this, GlobalContext* globalCtx) { + if (func_80BC3D08(this, globalCtx, 1)) { + if (Flags_GetSwitch(globalCtx, BGF40BLOCK_GET_SWITCHFLAG(&this->dyna.actor))) { + func_80BC4038(this); + this->actionFunc = func_80BC4344; + } + } else { + this->actionFunc = func_80BC44F4; + } +} + +void func_80BC4448(BgF40Block* this, GlobalContext* globalCtx) { + if (func_80BC3B00(this)) { + this->dyna.actor.speedXZ = 40.0f; + if (this->unk_160 > 0) { + this->unk_164 = this->unk_160 - 1; + } else { + this->actionFunc = func_80BC4380; + ActorCutscene_Stop(this->dyna.actor.cutscene); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_IKANA_BLOCK_STOP_C); + } + } + + if (func_80BC3D08(this, globalCtx, 0)) { + ActorCutscene_Stop(this->dyna.actor.cutscene); + this->actionFunc = func_80BC43CC; + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_IKANA_BLOCK_STOP_F); + } +} + +void func_80BC44F4(BgF40Block* this, GlobalContext* globalCtx) { + if (func_80BC3CA4(this)) { + this->actionFunc = func_80BC4448; + } +} + +void func_80BC4530(BgF40Block* this, GlobalContext* globalCtx) { + if (!Flags_GetSwitch(globalCtx, BGF40BLOCK_GET_SWITCHFLAG(&this->dyna.actor))) { + this->actionFunc = func_80BC44F4; + } +} + +void func_80BC457C(BgF40Block* this, GlobalContext* globalCtx) { +} + +void BgF40Block_Update(Actor* thisx, GlobalContext* globalCtx) { + BgF40Block* this = THIS; + + this->actionFunc(this, globalCtx); + + Math_Vec3f_Copy(&this->dyna.actor.focus.pos, &this->dyna.actor.world.pos); +} + +void BgF40Block_Draw(Actor* thisx, GlobalContext* globalCtx) { + Gfx_DrawDListOpa(globalCtx, object_f40_obj_DL_0043D0); +} diff --git a/src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.h b/src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.h index 92b1d1e9e0..cf9dfb03b6 100644 --- a/src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.h +++ b/src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.h @@ -7,9 +7,15 @@ struct BgF40Block; typedef void (*BgF40BlockActionFunc)(struct BgF40Block*, GlobalContext*); +#define BGF40BLOCK_GET_PATH(thisx) (((thisx)->params & 0x1FC) >> 2) +#define BGF40BLOCK_GET_SWITCHFLAG(thisx) (((thisx)->params & 0xFE00) >> 9) + typedef struct BgF40Block { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x28]; + /* 0x0000 */ DynaPolyActor dyna; + /* 0x015C */ Path* path; + /* 0x0160 */ s32 unk_160; + /* 0x0164 */ s32 unk_164; + /* 0x0168 */ s32 unk_168; /* 0x016C */ BgF40BlockActionFunc actionFunc; } BgF40Block; // size = 0x170 diff --git a/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.c b/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.c index 8bb351a97e..5278a4b738 100644 --- a/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.c +++ b/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.c @@ -5,6 +5,7 @@ */ #include "z_bg_f40_switch.h" +#include "objects/object_f40_switch/object_f40_switch.h" #define FLAGS (ACTOR_FLAG_10) @@ -15,13 +16,13 @@ void BgF40Switch_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgF40Switch_Update(Actor* thisx, GlobalContext* globalCtx); void BgF40Switch_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80BC4B20(BgF40Switch* this, GlobalContext* globalCtx); -void func_80BC4B94(BgF40Switch* this, GlobalContext* globalCtx); -void func_80BC4BB8(BgF40Switch* this, GlobalContext* globalCtx); -void func_80BC4C68(BgF40Switch* this, GlobalContext* globalCtx); -void func_80BC4D30(BgF40Switch* this, GlobalContext* globalCtx); +void BgF40Switch_CheckAll(BgF40Switch* this, GlobalContext* globalCtx); +void BgF40Switch_Unpress(BgF40Switch* this, GlobalContext* globalCtx); +void BgF40Switch_IdlePressed(BgF40Switch* this, GlobalContext* globalCtx); +void BgF40Switch_Press(BgF40Switch* this, GlobalContext* globalCtx); +void BgF40Switch_WaitToPress(BgF40Switch* this, GlobalContext* globalCtx); +void BgF40Switch_IdleUnpressed(BgF40Switch* this, GlobalContext* globalCtx); -#if 0 const ActorInit Bg_F40_Switch_InitVars = { ACTOR_BG_F40_SWITCH, ACTORCAT_SWITCH, @@ -34,37 +35,159 @@ const ActorInit Bg_F40_Switch_InitVars = { (ActorFunc)BgF40Switch_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80BC4E04[] = { +s32 sBgF40SwitchGlobalsInitialized = false; +u32 sBgF40SwitchLastUpdateFrame; + +/* + * Updates all instances of this actor in the current room, unless it's already been called this frame. + */ +void BgF40Switch_CheckAll(BgF40Switch* this, GlobalContext* globalCtx) { + if (globalCtx->gameplayFrames != sBgF40SwitchLastUpdateFrame) { + u32 pressedSwitchFlags[4] = { 0 }; + u32 pad; + s32 switchFlag; + s32 isPressed; + Actor* actor; + BgF40Switch* actorAsSwitch; + u32 inCsMode = Player_InCsMode(&globalCtx->state); + + for (actor = globalCtx->actorCtx.actorLists[ACTORCAT_SWITCH].first; actor != NULL; actor = actor->next) { + if (actor->id == ACTOR_BG_F40_SWITCH && actor->room == this->dyna.actor.room && actor->update != NULL) { + actorAsSwitch = (BgF40Switch*)actor; + actorAsSwitch->wasPressed = actorAsSwitch->isPressed; + isPressed = DynaPolyActor_IsInSwitchPressedState(&actorAsSwitch->dyna); + if (actorAsSwitch->isPressed && actorAsSwitch->actionFunc == BgF40Switch_IdlePressed) { + // Switch is fully pressed - if there's nothing keeping it pressed, wait a short time before + // reverting to unpressed state. + if (isPressed || inCsMode) { + actorAsSwitch->switchReleaseDelay = 6; + } else { + if (actorAsSwitch->switchReleaseDelay > 0) { + actorAsSwitch->switchReleaseDelay--; + } else { + actorAsSwitch->isPressed = isPressed; + } + } + } else { + // No delay when pressing switch, or releasing from a not-fully-pressed state. + actorAsSwitch->isPressed = isPressed; + } + if (actorAsSwitch->isPressed) { + switchFlag = BGF40SWITCH_GET_SWITCHFLAG(&actorAsSwitch->dyna.actor); + if (switchFlag >= 0 && switchFlag < 0x80) { + pressedSwitchFlags[(switchFlag & ~0x1F) >> 5] |= 1 << (switchFlag & 0x1F); + if (!actorAsSwitch->wasPressed && actorAsSwitch->actionFunc == BgF40Switch_IdleUnpressed && + !Flags_GetSwitch(globalCtx, switchFlag)) { + actorAsSwitch->isInitiator = true; + } + } + } + } + } + for (actor = globalCtx->actorCtx.actorLists[ACTORCAT_SWITCH].first; actor != NULL; actor = actor->next) { + if (actor->id == ACTOR_BG_F40_SWITCH && actor->room == this->dyna.actor.room && actor->update != 0) { + switchFlag = BGF40SWITCH_GET_SWITCHFLAG(actor); + if (switchFlag >= 0 && switchFlag < 0x80 && Flags_GetSwitch(globalCtx, switchFlag) && + !(pressedSwitchFlags[(switchFlag & ~0x1F) >> 5] & (1 << (switchFlag & 0x1F)))) { + Flags_UnsetSwitch(globalCtx, switchFlag); + } + } + } + sBgF40SwitchLastUpdateFrame = globalCtx->gameplayFrames; + } +} + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 200, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 200, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 123, ICHAIN_STOP), }; -#endif +void BgF40Switch_Init(Actor* thisx, GlobalContext* globalCtx) { + BgF40Switch* this = THIS; -extern InitChainEntry D_80BC4E04[]; + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + this->dyna.actor.scale.y = 0.165f; + this->actionFunc = BgF40Switch_IdleUnpressed; + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + 1.0f; + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_f40_switch_Colheader_000118); + if (!sBgF40SwitchGlobalsInitialized) { + sBgF40SwitchLastUpdateFrame = globalCtx->gameplayFrames; + sBgF40SwitchGlobalsInitialized = true; + } +} -extern UNK_TYPE D_06000118; -extern UNK_TYPE D_06000438; +void BgF40Switch_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgF40Switch* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Switch/func_80BC47B0.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Switch/BgF40Switch_Init.s") +void BgF40Switch_Unpress(BgF40Switch* this, GlobalContext* globalCtx) { + this->dyna.actor.scale.y += 0.0495f; + if (this->dyna.actor.scale.y >= 0.165f) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_IKANA_BLOCK_SWITCH); + this->actionFunc = BgF40Switch_IdleUnpressed; + this->dyna.actor.scale.y = 0.165f; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Switch/BgF40Switch_Destroy.s") +void BgF40Switch_IdlePressed(BgF40Switch* this, GlobalContext* globalCtx) { + if (!this->isPressed) { + this->actionFunc = BgF40Switch_Unpress; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Switch/func_80BC4B20.s") +void BgF40Switch_Press(BgF40Switch* this, GlobalContext* globalCtx) { + this->dyna.actor.scale.y -= 0.0495f; + if (this->dyna.actor.scale.y <= 0.0165f) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_IKANA_BLOCK_SWITCH); + func_8013ECE0(this->dyna.actor.xyzDistToPlayerSq, 120, 20, 10); + if (this->isInitiator) { + ActorCutscene_Stop(this->dyna.actor.cutscene); + this->isInitiator = false; + } + this->actionFunc = BgF40Switch_IdlePressed; + this->dyna.actor.scale.y = 0.0165f; + this->switchReleaseDelay = 6; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Switch/func_80BC4B94.s") +void BgF40Switch_WaitToPress(BgF40Switch* this, GlobalContext* globalCtx) { + if (!this->isInitiator || this->dyna.actor.cutscene == -1) { + this->actionFunc = BgF40Switch_Press; + if (this->isInitiator) { + Flags_SetSwitch(globalCtx, BGF40SWITCH_GET_SWITCHFLAG(&this->dyna.actor)); + } + } else if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + this->actionFunc = BgF40Switch_Press; + if (this->isInitiator) { + Flags_SetSwitch(globalCtx, BGF40SWITCH_GET_SWITCHFLAG(&this->dyna.actor)); + } + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Switch/func_80BC4BB8.s") +void BgF40Switch_IdleUnpressed(BgF40Switch* this, GlobalContext* globalCtx) { + if (this->isPressed) { + this->actionFunc = BgF40Switch_WaitToPress; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Switch/func_80BC4C68.s") +void BgF40Switch_Update(Actor* thisx, GlobalContext* globalCtx) { + BgF40Switch* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Switch/func_80BC4D30.s") + BgF40Switch_CheckAll(this, globalCtx); + this->actionFunc(this, globalCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Switch/BgF40Switch_Update.s") +void BgF40Switch_Draw(Actor* thisx, GlobalContext* globalCtx) { + BgF40Switch* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Switch/BgF40Switch_Draw.s") + Gfx_DrawDListOpa(globalCtx, object_f40_switch_DL_000438); + Gfx_DrawDListOpa(globalCtx, object_f40_switch_DL_000390); +} diff --git a/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.h b/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.h index 8b4f2b679b..8d4e64603f 100644 --- a/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.h +++ b/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.h @@ -5,11 +5,18 @@ struct BgF40Switch; +#define BGF40SWITCH_GET_SWITCHFLAG(thisx) (((thisx)->params & 0xFE00) >> 9) + typedef void (*BgF40SwitchActionFunc)(struct BgF40Switch*, GlobalContext*); typedef struct BgF40Switch { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x20]; + /* 0x0000 */ DynaPolyActor dyna; + /* 0x015C */ s16 switchReleaseDelay; // frames until a pressed switch becomes released if nothing is still pressing it + /* 0x015E */ s8 isPressed; // Logical state of the switch (pressed or unpressed). Animation state may lag behind this slightly. + /* 0x015F */ s8 wasPressed; // used as temporary during update function + // true if this switch is the one that initiated a state change; false if this switch is changing as a result of another switch tied to the same flag. + // this is a temporary flag related to something currently happening, not a permanent property of the switch. + /* 0x0160 */ s8 isInitiator; /* 0x0164 */ BgF40SwitchActionFunc actionFunc; } BgF40Switch; // size = 0x168 diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.c b/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.c index 4061745f70..1f0030d28a 100644 --- a/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.c +++ b/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.c @@ -5,6 +5,7 @@ */ #include "z_bg_hakugin_bombwall.h" +#include "objects/object_hakugin_obj/object_hakugin_obj.h" #define FLAGS 0x00000000 @@ -15,7 +16,16 @@ void BgHakuginBombwall_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgHakuginBombwall_Update(Actor* thisx, GlobalContext* globalCtx); void BgHakuginBombwall_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80ABBFC0(BgHakuginBombwall* this, GlobalContext* globalCtx); +void func_80ABC2E0(BgHakuginBombwall* this, GlobalContext* globalCtx); +void func_80ABC58C(BgHakuginBombwall* this, GlobalContext* globalCtx); +void func_80ABC7FC(BgHakuginBombwall* this, GlobalContext* globalCtx); +s32 func_80ABCB5C(Actor* thisx, GlobalContext* globalCtx); +s32 func_80ABCC00(Actor* thisx, GlobalContext* globalCtx); +void func_80ABCCE4(BgHakuginBombwall* this, GlobalContext* globalCtx); +void func_80ABCD98(BgHakuginBombwall* this, GlobalContext* globalCtx); +void func_80ABCE60(BgHakuginBombwall* this, GlobalContext* globalCtx); + const ActorInit Bg_Hakugin_Bombwall_InitVars = { ACTOR_BG_HAKUGIN_BOMBWALL, ACTORCAT_BG, @@ -28,48 +38,404 @@ const ActorInit Bg_Hakugin_Bombwall_InitVars = { (ActorFunc)BgHakuginBombwall_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80ABCF80 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00000008, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000008, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 80, 80, 0, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80ABD040[] = { +Color_RGBA8 D_80ABCFAC = { 210, 210, 210, 255 }; +Color_RGBA8 D_80ABCFB0 = { 140, 140, 140, 255 }; + +Vec3f D_80ABCFB4 = { 0.0f, 0.33f, 0.0f }; + +typedef struct { + /* 0x00 */ CollisionHeader* unk_00; + /* 0x04 */ Gfx* unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ f32 unk_10; + /* 0x14 */ s16 unk_14; + /* 0x16 */ s16 unk_16; + /* 0x18 */ s32 unk_18; + /* 0x1C */ f32 unk_1C; + /* 0x20 */ BgHakuginBombwallUnkFunc unk_20; + /* 0x24 */ BgHakuginBombwallUnkFunc2 unk_24; + /* 0x28 */ BgHakuginBombwallUnkFunc2 unk_28; + /* 0x2C */ s32 unk_2C; +} BgHakuginBombwallStruct; // size = 0x30 + +BgHakuginBombwallStruct D_80ABCFC0[] = { + { + &object_hakugin_obj_Colheader_009768, + object_hakugin_obj_DL_009658, + 70.0f, + 600.0f, + 400.0f, + 80, + 80, + 0x8, + 4225.0f, + func_80ABCB5C, + func_80ABBFC0, + func_80ABC58C, + 6, + }, + { + &object_hakugin_obj_Colheader_009AF0, + object_hakugin_obj_DL_0099A8, + 10.0f, + 600.0f, + 300.0f, + 50, + 20, + 0x408, + 4225.0f, + func_80ABCC00, + func_80ABC2E0, + func_80ABC7FC, + 18, + }, +}; + +s32 D_80ABD020[] = { -73, -40, -8, 24, 57 }; + +Vec3f D_80ABD034 = { 0.0f, 3.0f, 0.0f }; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; +#ifdef NON_MATCHING +// Breaks relocs +void func_80ABBFC0(BgHakuginBombwall* this, GlobalContext* globalCtx) { + s32 temp; + Vec3f spF0; + Vec3f spE4; + Vec3f spD8; + Vec3f spCC; + s32 pad; + s16 phi_s1; + s16 phi_s0; + s32 i; + s32 j; + + Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_NEW); + + for (i = 0; i < 6; i++) { + temp = i + 1; + for (j = 0; j < ARRAY_COUNT(D_80ABD020); j++) { + spD8.x = D_80ABD020[j] + (s32)((u32)Rand_Next() >> 0x1C); + spD8.y = ((Rand_ZeroOne() - 0.5f) * 15.0f) + (temp * 26.666666f); + spD8.z = (Rand_ZeroOne() * 20.0f) - 10.0f; + + spCC.x = ((Rand_ZeroOne() - 0.5f) * 7.0f) + (spD8.x * 0.07777778f); + spCC.y = (Rand_ZeroOne() * 7.0f) - 2.0f; + spCC.z = spD8.z * 0.3f; + + Matrix_MultiplyVector3fByState(&spD8, &spF0); + Matrix_MultiplyVector3fByState(&spCC, &spE4); + + spF0.x += this->dyna.actor.world.pos.x; + spF0.y += this->dyna.actor.world.pos.y; + spF0.z += this->dyna.actor.world.pos.z; + + if ((Rand_Next() % 4) == 0) { + phi_s0 = 32; + } else { + phi_s0 = 64; + } + + if (Rand_Next() > 0) { + phi_s0 |= 1; + phi_s1 = 1; + func_800B0E48(globalCtx, &spF0, &gZeroVec3f, &D_80ABCFB4, &D_80ABCFAC, &D_80ABCFB0, + ((u32)Rand_Next() >> 0x1B) + 70, ((u32)Rand_Next() >> 0x1A) + 60); + } else { + phi_s1 = 0; + } + + EffectSsKakera_Spawn(globalCtx, &spF0, &spE4, &spF0, -550, phi_s0, 30, 0, 0, + (s32)(Rand_ZeroOne() * 22.0f) + 5, phi_s1, 0, 50, -1, OBJECT_HAKUGIN_OBJ, + object_hakugin_obj_DL_009830); + } + } +} +#else +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Bombwall/func_80ABBFC0.s") #endif -extern ColliderCylinderInit D_80ABCF80; -extern InitChainEntry D_80ABD040[]; +void func_80ABC2E0(BgHakuginBombwall* this, GlobalContext* globalCtx) { + s32 pad; + s32 i; + s16 phi_s2; + s16 phi_v0; + s16 phi_v1; + s16 phi_t0; + s16 temp_s1; + Vec3f spC8; + Vec3f spBC; + f32 temp_f20; + f32 temp_f22; + f32 temp_f24; -extern UNK_TYPE D_06009830; + for (i = 0, phi_s2 = 0; i < 25; i++, phi_s2 += 0x4E20) { + temp_f20 = (25 - i) * 2.4f; + temp_f22 = Math_SinS(phi_s2) * temp_f20; + temp_f24 = Math_CosS(phi_s2) * temp_f20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Bombwall/func_80ABBFC0.s") + spC8.x = this->dyna.actor.world.pos.x + temp_f22; + spC8.y = this->dyna.actor.world.pos.y; + spC8.z = this->dyna.actor.world.pos.z + temp_f24; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Bombwall/func_80ABC2E0.s") + spBC.x = ((Rand_ZeroOne() - 0.5f) * 10.0f) + (temp_f22 * 0.13333334f); + spBC.y = (Rand_ZeroOne() * 17.0f) + 7.0f; + spBC.z = ((Rand_ZeroOne() - 0.5f) * 10.0f) + (temp_f24 * 0.13333334f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Bombwall/func_80ABC58C.s") + temp_s1 = (Rand_Next() & 3) + (i >> 2) + 4; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Bombwall/func_80ABC7FC.s") + if ((Rand_Next() % 4) == 0) { + phi_v0 = 32; + } else { + phi_v0 = 64; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Bombwall/BgHakuginBombwall_Init.s") + if (temp_s1 >= 8) { + phi_v0 |= 1; + phi_v1 = 1; + phi_t0 = -550; + } else { + phi_v1 = 0; + phi_t0 = -400; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Bombwall/BgHakuginBombwall_Destroy.s") + EffectSsKakera_Spawn(globalCtx, &spC8, &spBC, &spC8, phi_t0, phi_v0, 30, 0, 0, temp_s1, phi_v1, 0, 50, -1, + OBJECT_HAKUGIN_OBJ, object_hakugin_obj_DL_009830); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Bombwall/func_80ABCB5C.s") + if ((i & 1) == 0) { + func_800B0E48(globalCtx, &spC8, &D_80ABD034, &D_80ABCFB4, &D_80ABCFAC, &D_80ABCFB0, + ((u32)Rand_Next() >> 0x1B) + 60, ((u32)Rand_Next() >> 0x1A) + 50); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Bombwall/func_80ABCC00.s") +void func_80ABC58C(BgHakuginBombwall* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f spD8; + Vec3f spCC; + Vec3f spC0; + Vec3f spB4; + Vec3f spA8; + Vec3f sp9C; + s32 i; + s16 phi_s1; + f32 temp_f20; + f32 temp_f22; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Bombwall/func_80ABCCE4.s") + spA8.y = 0.0f; + spB4.y = 0.3f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Bombwall/func_80ABCD98.s") + Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_NEW); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Bombwall/func_80ABCE60.s") + for (i = 0, phi_s1 = 0; i < 21; i++, phi_s1 += 0x618) { + temp_f20 = Math_SinS(phi_s1); + temp_f22 = Math_CosS(phi_s1); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Bombwall/BgHakuginBombwall_Update.s") + sp9C.x = (i - 10) * 9.0f; + sp9C.y = (Rand_ZeroOne() * 40.0f) + 15.0f; + sp9C.z = temp_f20 * 10.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Bombwall/BgHakuginBombwall_Draw.s") + spA8.x = ((Rand_ZeroOne() - 0.5f) * 7.0f) + (temp_f22 * -12.0f); + spA8.z = ((Rand_ZeroOne() - 0.5f) * 7.0f) + (temp_f20 * 16.0f); + + spB4.x = spA8.x * -0.09f; + spB4.z = spA8.z * -0.09f; + + Matrix_MultiplyVector3fByState(&sp9C, &spC0); + Matrix_MultiplyVector3fByState(&spA8, &spCC); + Matrix_MultiplyVector3fByState(&spB4, &spD8); + + spC0.x += this->dyna.actor.world.pos.x; + spC0.y += this->dyna.actor.world.pos.y; + spC0.z += this->dyna.actor.world.pos.z; + + func_800B0E48(globalCtx, &spC0, &spCC, &spD8, &D_80ABCFAC, &D_80ABCFB0, ((u32)Rand_Next() >> 0x1A) + 60, + ((u32)Rand_Next() >> 0x1B) + 60); + } +} + +void func_80ABC7FC(BgHakuginBombwall* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f spB8; + Vec3f spAC; + Vec3f spA0; + f32 temp_f20; + f32 temp_f22; + f32 temp_f24; + s16 phi_s0; + s32 i; + + spAC.y = 0.0f; + spB8.y = 0.3f; + + for (i = 0, phi_s0 = 0; i < 20; i++, phi_s0 += 0xCCC) { + temp_f20 = Math_SinS(phi_s0); + temp_f22 = Math_CosS(phi_s0); + temp_f24 = Rand_ZeroOne() * 60.0f; + + spA0.x = (temp_f22 * temp_f24) + this->dyna.actor.world.pos.x; + spA0.y = (Rand_ZeroOne() * 20.0f) + this->dyna.actor.world.pos.y; + spA0.z = (temp_f20 * temp_f24) + this->dyna.actor.world.pos.z; + + spAC.x = ((Rand_ZeroOne() - 0.5f) * 7.0f) + (temp_f20 * 15.0f); + spAC.z = ((Rand_ZeroOne() - 0.5f) * 7.0f) + (temp_f22 * 15.0f); + + spB8.x = spAC.x * -0.095f; + spB8.z = spAC.z * -0.095f; + + func_800B0E48(globalCtx, &spA0, &spAC, &spB8, &D_80ABCFAC, &D_80ABCFB0, ((u32)Rand_Next() >> 0x1A) + 60, + ((u32)Rand_Next() >> 0x1B) + 60); + } +} + +void BgHakuginBombwall_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgHakuginBombwall* this = THIS; + BgHakuginBombwallStruct* ptr = &D_80ABCFC0[BGHAKUGIN_BOMBWALL_100(&this->dyna.actor)]; + + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 0); + Collider_InitCylinder(globalCtx, &this->collider); + + if (Flags_GetSwitch(globalCtx, BGHAKUGIN_BOMBWALL_SWITCHFLAG(&this->dyna.actor))) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } + + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, ptr->unk_00); + + Collider_SetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit); + this->collider.dim.radius = ptr->unk_14; + this->collider.dim.height = ptr->unk_16; + this->collider.info.bumper.dmgFlags = ptr->unk_18; + Collider_UpdateCylinder(&this->dyna.actor, &this->collider); + + Actor_SetFocus(&this->dyna.actor, ptr->unk_08); + this->dyna.actor.uncullZoneScale = ptr->unk_0C; + this->dyna.actor.uncullZoneDownward = ptr->unk_10; + this->actionFunc = func_80ABCCE4; +} + +void BgHakuginBombwall_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgHakuginBombwall* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +s32 func_80ABCB5C(Actor* thisx, GlobalContext* globalCtx) { + BgHakuginBombwall* this = THIS; + s32 pad; + + if (this->collider.base.acFlags & AC_HIT) { + if (this->collider.base.ac != NULL) { + if (Math3D_Vec3fDistSq(&this->dyna.actor.world.pos, &this->collider.base.ac->world.pos) < + D_80ABCFC0[BGHAKUGIN_BOMBWALL_100(&this->dyna.actor)].unk_1C) { + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->dyna.actor.world.pos, 60, NA_SE_EV_WALL_BROKEN); + return true; + } + } + } + return false; +} + +s32 func_80ABCC00(Actor* thisx, GlobalContext* globalCtx) { + BgHakuginBombwall* this = THIS; + s32 pad; + + if (this->collider.base.acFlags & AC_HIT) { + if (this->collider.info.acHitInfo->toucher.dmgFlags & 8) { + if (this->collider.base.ac != NULL) { + if (Math3D_Vec3fDistSq(&this->dyna.actor.world.pos, &this->collider.base.ac->world.pos) < + D_80ABCFC0[BGHAKUGIN_BOMBWALL_100(&this->dyna.actor)].unk_1C) { + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->dyna.actor.world.pos, 50, + NA_SE_EV_WALL_BROKEN); + return true; + } + } + } else if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + label:; + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->dyna.actor.world.pos, 50, NA_SE_EV_WALL_BROKEN); + return true; + } + } + return false; +} + +void func_80ABCCE4(BgHakuginBombwall* this, GlobalContext* globalCtx) { + BgHakuginBombwallStruct* ptr = &D_80ABCFC0[BGHAKUGIN_BOMBWALL_100(&this->dyna.actor)]; + + if (ptr->unk_20(&this->dyna.actor, globalCtx)) { + this->dyna.actor.flags |= ACTOR_FLAG_10; + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + this->actionFunc = func_80ABCD98; + } else { + this->collider.base.acFlags &= ~AC_HIT; + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +void func_80ABCD98(BgHakuginBombwall* this, GlobalContext* globalCtx) { + s32 pad; + + if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + BgHakuginBombwallStruct* ptr = &D_80ABCFC0[BGHAKUGIN_BOMBWALL_100(&this->dyna.actor)]; + + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + ptr->unk_24(this, globalCtx); + this->dyna.actor.draw = NULL; + this->unk_1AC = 20; + Flags_SetSwitch(globalCtx, BGHAKUGIN_BOMBWALL_SWITCHFLAG(&this->dyna.actor)); + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + this->actionFunc = func_80ABCE60; + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } +} + +void func_80ABCE60(BgHakuginBombwall* this, GlobalContext* globalCtx) { + BgHakuginBombwallStruct* ptr = &D_80ABCFC0[BGHAKUGIN_BOMBWALL_100(&this->dyna.actor)]; + + this->unk_1AC--; + if (this->unk_1AC <= 0) { + ActorCutscene_Stop(this->dyna.actor.cutscene); + Actor_MarkForDeath(&this->dyna.actor); + } else if (this->unk_1AC == ptr->unk_2C) { + ptr->unk_28(this, globalCtx); + } +} + +void BgHakuginBombwall_Update(Actor* thisx, GlobalContext* globalCtx) { + BgHakuginBombwall* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void BgHakuginBombwall_Draw(Actor* thisx, GlobalContext* globalCtx) { + Gfx_DrawDListOpa(globalCtx, D_80ABCFC0[BGHAKUGIN_BOMBWALL_100(thisx)].unk_04); +} diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.h b/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.h index 8522fd15cd..869741214f 100644 --- a/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.h +++ b/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.h @@ -6,12 +6,17 @@ struct BgHakuginBombwall; typedef void (*BgHakuginBombwallActionFunc)(struct BgHakuginBombwall*, GlobalContext*); +typedef s32 (*BgHakuginBombwallUnkFunc)(Actor*, GlobalContext*); +typedef void (*BgHakuginBombwallUnkFunc2)(struct BgHakuginBombwall*, GlobalContext*); + +#define BGHAKUGIN_BOMBWALL_SWITCHFLAG(thisx) ((thisx)->params & 0x7F) +#define BGHAKUGIN_BOMBWALL_100(thisx) (((thisx)->params >> 8) & 1) typedef struct BgHakuginBombwall { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x64]; - /* 0x01A8 */ BgHakuginBombwallActionFunc actionFunc; - /* 0x01AC */ char unk_1AC[0x4]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ColliderCylinder collider; + /* 0x1A8 */ BgHakuginBombwallActionFunc actionFunc; + /* 0x1AC */ s32 unk_1AC; } BgHakuginBombwall; // size = 0x1B0 extern const ActorInit Bg_Hakugin_Bombwall_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c b/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c index 4306d5582d..1ad88f3f88 100644 --- a/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c +++ b/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c @@ -4,8 +4,10 @@ * Description: Snowhead Temple Central Pillar */ +#include "prevent_bss_reordering.h" #include "z_bg_hakugin_post.h" #include "objects/object_hakugin_obj/object_hakugin_obj.h" +#include "prevent_bss_reordering.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) diff --git a/src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.c b/src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.c index 9d2fd67d90..f693022785 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.c @@ -5,6 +5,7 @@ */ #include "z_bg_ikana_block.h" +#include "objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h" #define FLAGS (ACTOR_FLAG_10) @@ -14,12 +15,16 @@ void BgIkanaBlock_Init(Actor* thisx, GlobalContext* globalCtx); void BgIkanaBlock_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgIkanaBlock_Update(Actor* thisx, GlobalContext* globalCtx); +void func_80B7F00C(BgIkanaBlock* this); void func_80B7F034(BgIkanaBlock* this, GlobalContext* globalCtx); +void func_80B7F0A4(BgIkanaBlock* this); void func_80B7F0D0(BgIkanaBlock* this, GlobalContext* globalCtx); +void func_80B7F1A8(BgIkanaBlock* this); void func_80B7F290(BgIkanaBlock* this, GlobalContext* globalCtx); +void func_80B7F360(BgIkanaBlock* this); void func_80B7F398(BgIkanaBlock* this, GlobalContext* globalCtx); +void func_80B7F564(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Bg_Ikana_Block_InitVars = { ACTOR_BG_IKANA_BLOCK, ACTORCAT_BG, @@ -32,58 +37,350 @@ const ActorInit Bg_Ikana_Block_InitVars = { (ActorFunc)NULL, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B7F640[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 250, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 250, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#endif +void func_80B7EA60(BgIkanaBlock* this) { + s32 phi_v0; -extern InitChainEntry D_80B7F640[]; + this->unk_17A &= ~(0x8 | 0x4 | 0x2 | 0x1); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/func_80B7EA60.s") + if (fabsf(this->dyna.pushForce) > 0.1f) { + if (this->dyna.pushForce > 0.0f) { + phi_v0 = this->dyna.yRotation; + } else { + phi_v0 = BINANG_ROT180(this->dyna.yRotation); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/func_80B7EB30.s") + if ((phi_v0 < -0x6000) || (phi_v0 >= 0x6000)) { + this->unk_17A |= 8; + } else if (phi_v0 < -0x2000) { + this->unk_17A |= 2; + } else if (phi_v0 < 0x2000) { + this->unk_17A |= 4; + } else { + this->unk_17A |= 1; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/func_80B7EB64.s") +void func_80B7EB30(BgIkanaBlock* this) { + if (this->unk_17A & (0x8 | 0x4 | 0x2 | 0x1)) { + if (this->unk_17B < 127) { + this->unk_17B++; + } + } else { + this->unk_17B = 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/func_80B7EB7C.s") +s32 func_80B7EB64(BgIkanaBlock* this, GlobalContext* globalCtx) { + return !(this->unk_17C & 8); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/func_80B7EB94.s") +s32 func_80B7EB7C(BgIkanaBlock* this, GlobalContext* globalCtx) { + return this->unk_17B > 10; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/func_80B7ECFC.s") +s32 func_80B7EB94(BgIkanaBlock* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp70; + Vec3f sp64; + Vec3f sp58; + CollisionPoly* sp54; + s32 sp50; + s32 sp4C = false; + s16 phi_a0; + f32 phi_f12; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/func_80B7ED54.s") + if (this->dyna.pushForce > 0.0f) { + sp4C = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/func_80B7EDC4.s") + if (sp4C) { + phi_a0 = this->dyna.yRotation; + } else { + phi_a0 = BINANG_ROT180(this->dyna.yRotation); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/func_80B7EE70.s") + sp70.x = this->dyna.actor.world.pos.x; + sp70.y = this->dyna.actor.world.pos.y + this->unk_170 + 2.0f; + sp70.z = this->dyna.actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/func_80B7EEB4.s") + Matrix_RotateY(phi_a0, MTXMODE_NEW); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/BgIkanaBlock_Init.s") + if (sp4C) { + phi_f12 = 89.0f; + } else { + phi_f12 = 119.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/BgIkanaBlock_Destroy.s") + Matrix_GetStateTranslationAndScaledZ(phi_f12, &sp64); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/func_80B7F00C.s") + sp64.x += this->dyna.actor.world.pos.x; + sp64.y += this->dyna.actor.world.pos.y + this->unk_170 + 2.0f; + sp64.z += this->dyna.actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/func_80B7F034.s") + return !BgCheck_EntityLineTest3(&globalCtx->colCtx, &sp70, &sp64, &sp58, &sp54, true, false, false, true, &sp50, + &this->dyna.actor, 0.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/func_80B7F0A4.s") +s32 func_80B7ECFC(BgIkanaBlock* this, GlobalContext* globalCtx) { + return func_80B7EB64(this, globalCtx) && func_80B7EB7C(this, globalCtx) && func_80B7EB94(this, globalCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/func_80B7F0D0.s") +void func_80B7ED54(BgIkanaBlock* this) { + s32 pad; + Vec3f sp18; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/func_80B7F1A8.s") + Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_NEW); + Matrix_InsertXRotation_s(this->dyna.actor.shape.rot.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); + Matrix_GetStateTranslationAndScaledY(30.0f, &sp18); + this->unk_170 = sp18.y - 30.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/func_80B7F290.s") +s32 func_80B7EDC4(BgIkanaBlock* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp30; + s32 sp2C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/func_80B7F360.s") + sp30.x = this->dyna.actor.world.pos.x; + sp30.y = this->dyna.actor.world.pos.y + this->unk_170 + 40.0f; + sp30.z = this->dyna.actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/func_80B7F398.s") + this->dyna.actor.floorHeight = BgCheck_EntityRaycastFloor5_2( + globalCtx, &globalCtx->colCtx, &this->dyna.actor.floorPoly, &sp2C, &this->dyna.actor, &sp30); + this->dyna.actor.floorBgId = sp2C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/BgIkanaBlock_Update.s") + return ((this->dyna.actor.world.pos.y + this->unk_170) - this->dyna.actor.floorHeight) < 2.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/func_80B7F564.s") +s32 func_80B7EE70(BgIkanaBlock* this, GlobalContext* globalCtx) { + if (func_80B7EDC4(this, globalCtx)) { + this->dyna.actor.world.pos.y = this->dyna.actor.floorHeight - this->unk_170; + return true; + } + return false; +} + +s32 func_80B7EEB4(BgIkanaBlock* this, GlobalContext* globalCtx) { + func_80B7EDC4(this, globalCtx); + + if (this->dyna.actor.floorHeight > (BGCHECK_Y_MIN + 1.0f)) { + if (DynaPoly_GetActor(&globalCtx->colCtx, this->dyna.actor.floorBgId)) { + this->dyna.actor.world.pos.y = this->dyna.actor.floorHeight - this->unk_170; + return true; + } + } + return false; +} + +void BgIkanaBlock_Init(Actor* thisx, GlobalContext* globalCtx) { + BgIkanaBlock* this = THIS; + + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gameplay_dangeon_keep_Colheader_007498); + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + this->unk_15C = Lib_SegmentedToVirtual(gameplay_dangeon_keep_Matanimheader_01B370); + this->unk_174 = this->dyna.actor.shape.rot; + func_80B7ED54(this); + func_80B7F00C(this); +} + +void BgIkanaBlock_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgIkanaBlock* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} + +void func_80B7F00C(BgIkanaBlock* this) { + this->unk_17C &= ~7; + this->unk_17D = 40; + this->actionFunc = func_80B7F034; +} + +void func_80B7F034(BgIkanaBlock* this, GlobalContext* globalCtx) { + if (this->unk_17D > 0) { + this->unk_17D--; + } + + if (func_80B7EEB4(this, globalCtx)) { + func_800C6314(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + this->dyna.actor.draw = func_80B7F564; + func_80B7F0A4(this); + } +} + +void func_80B7F0A4(BgIkanaBlock* this) { + this->unk_17B = 0; + this->unk_17C &= ~7; + this->unk_17C |= 1; + this->actionFunc = func_80B7F0D0; +} + +void func_80B7F0D0(BgIkanaBlock* this, GlobalContext* globalCtx) { + s32 sp24 = 0; + s32 phi_v1; + + func_80B7EA60(this); + func_80B7EB30(this); + + if (this->unk_17C & 4) { + sp24 = 1; + } else if (func_80B7ECFC(this, globalCtx)) { + sp24 = 2; + } + + if ((sp24 != 2) && (this->unk_17A & (0x8 | 0x4 | 0x2 | 0x1))) { + Player* player = GET_PLAYER(globalCtx); + + player->stateFlags2 &= ~0x10; + this->dyna.pushForce = 0.0f; + } + + if (sp24 == 1) { + func_80B7F360(this); + } else if (sp24 == 2) { + func_80B7F1A8(this); + } +} + +void func_80B7F1A8(BgIkanaBlock* this) { + f32 temp_f0; + f32* phi_v0; + s32 phi_v0_2; + + if (this->unk_17A & (0x2 | 0x1)) { + this->unk_164 = &this->dyna.actor.world.pos.x; + phi_v0 = &this->dyna.actor.home.pos.x; + } else { + this->unk_164 = &this->dyna.actor.world.pos.z; + phi_v0 = &this->dyna.actor.home.pos.z; + } + + temp_f0 = (*this->unk_164 - *phi_v0) * 0.016666668f; + + if (temp_f0 >= 0.0f) { + temp_f0 += 0.5f; + } else { + temp_f0 -= 0.5f; + } + + if (this->unk_17A & (0x4 | 0x1)) { + phi_v0_2 = 1; + } else { + phi_v0_2 = -1; + } + + this->unk_168 = *phi_v0 + (((s32)temp_f0 + phi_v0_2) * 60.0f); + this->unk_16C = 0.0f; + this->unk_17C &= ~7; + this->unk_17C |= 2; + this->actionFunc = func_80B7F290; +} + +void func_80B7F290(BgIkanaBlock* this, GlobalContext* globalCtx) { + s32 pad; + + Math_StepToF(&this->unk_16C, 2.0f, 0.4f); + + if (Math_StepToF(this->unk_164, this->unk_168, this->unk_16C)) { + Player* player = GET_PLAYER(globalCtx); + + if (!func_80B7EB94(this, globalCtx)) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + } + + player->stateFlags2 &= ~0x10; + this->dyna.pushForce = 0.0f; + + if (func_80B7EDC4(this, globalCtx)) { + func_80B7F0A4(this); + } else { + func_80B7F360(this); + } + } else { + func_800B9010(&this->dyna.actor, NA_SE_EV_ROCK_SLIDE - SFX_FLAG); + } +} + +void func_80B7F360(BgIkanaBlock* this) { + this->unk_17C &= ~7; + this->unk_17C |= 4; + this->unk_17D = 1; + this->dyna.actor.velocity.y = 0.0f; + this->actionFunc = func_80B7F398; +} + +void func_80B7F398(BgIkanaBlock* this, GlobalContext* globalCtx) { + if (this->unk_17D > 0) { + this->unk_17D--; + return; + } + + this->dyna.actor.velocity.y -= 2.0f; + this->dyna.actor.velocity.y *= 0.95f; + + if (this->dyna.actor.velocity.y < -30.0f) { + this->dyna.actor.velocity.y = -30.0f; + } + + this->dyna.actor.world.pos.y += this->dyna.actor.velocity.y; + + if (func_80B7EE70(this, globalCtx)) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + Actor_PlaySfxAtPos( + &this->dyna.actor, + SurfaceType_GetSfx(&globalCtx->colCtx, this->dyna.actor.floorPoly, this->dyna.actor.floorBgId) + SFX_FLAG); + func_80B7F0A4(this); + } +} + +void BgIkanaBlock_Update(Actor* thisx, GlobalContext* globalCtx) { + BgIkanaBlock* this = THIS; + + if ((this->dyna.actor.shape.rot.x != this->unk_174.x) || (this->dyna.actor.shape.rot.y != this->unk_174.y) || + (this->dyna.actor.shape.rot.z != this->unk_174.z)) { + this->unk_174 = this->dyna.actor.shape.rot; + func_80B7ED54(this); + } + + this->actionFunc(this, globalCtx); + + Actor_SetFocus(&this->dyna.actor, 30.0f); + + if (this->unk_17E != 0) { + if (this->unk_17F > 0) { + this->unk_17F--; + ActorCutscene_Stop(this->dyna.actor.cutscene); + this->unk_17E = 0; + } else if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + this->unk_17F = 30; + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } + } +} + +void func_80B7F564(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgIkanaBlock* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + AnimatedMat_DrawStep(globalCtx, this->unk_15C, 0); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_OPA_DISP++, 0xFF, 0xFF, 255, 255, 255, 255); + gSPDisplayList(POLY_OPA_DISP++, gameplay_dangeon_keep_DL_0182A8); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.h b/src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.h index 112e4ad008..3ad797cbab 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.h +++ b/src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.h @@ -8,15 +8,20 @@ struct BgIkanaBlock; typedef void (*BgIkanaBlockActionFunc)(struct BgIkanaBlock*, GlobalContext*); typedef struct BgIkanaBlock { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x1C]; + /* 0x0000 */ DynaPolyActor dyna; + /* 0x015C */ AnimatedMaterial* unk_15C; /* 0x0160 */ BgIkanaBlockActionFunc actionFunc; - /* 0x0164 */ char unk_164[0xC]; + /* 0x0164 */ f32* unk_164; + /* 0x0168 */ f32 unk_168; + /* 0x016C */ f32 unk_16C; /* 0x0170 */ f32 unk_170; - /* 0x0174 */ char unk_174[0x8]; + /* 0x0174 */ Vec3s unk_174; + /* 0x017A */ u8 unk_17A; + /* 0x017B */ s8 unk_17B; /* 0x017C */ u8 unk_17C; - /* 0x017D */ char unk_17D[0x1]; - /* 0x017E */ u8 unk_17E; + /* 0x017D */ s8 unk_17D; + /* 0x017E */ s8 unk_17E; + /* 0x017F */ s8 unk_17F; } BgIkanaBlock; // size = 0x180 extern const ActorInit Bg_Ikana_Block_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.c b/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.c index a3b234392b..944ab5828d 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.c @@ -400,10 +400,10 @@ void func_80B80C88(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { Matrix_StatePush(); Matrix_InsertMatrix(&this->unk_204.unk_04, MTXMODE_APPLY); - Matrix_GetStateTranslation(&ikanaBlock->actor.world.pos); - func_80B80358(&ikanaBlock->actor.world.pos); + Matrix_GetStateTranslation(&ikanaBlock->dyna.actor.world.pos); + func_80B80358(&ikanaBlock->dyna.actor.world.pos); Matrix_CopyCurrentState(&sp3C); - func_8018219C(&sp3C, &ikanaBlock->actor.shape.rot, 0); + func_8018219C(&sp3C, &ikanaBlock->dyna.actor.shape.rot, 0); Matrix_StatePop(); } @@ -473,20 +473,21 @@ void func_80B80C88(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { s32 func_80B80F08(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { s32 pad; - BgIkanaBlock* sp40 = (BgIkanaBlock*)this->unk_204.unk_00; + BgIkanaBlock* ikanaBlock = (BgIkanaBlock*)this->unk_204.unk_00; Vec3f sp34; Vec3f sp28; s32 sp24 = false; - if (sp40 != NULL) { + if (ikanaBlock != NULL) { Matrix_StatePush(); Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); Matrix_InsertTranslation(D_80B82178.x, D_80B82178.y, D_80B82178.z, MTXMODE_APPLY); Matrix_GetStateTranslation(&sp34); - Matrix_SetStateRotationAndTranslation(sp40->actor.world.pos.x, sp40->actor.world.pos.y + sp40->unk_170, - sp40->actor.world.pos.z, &sp40->actor.shape.rot); + Matrix_SetStateRotationAndTranslation(ikanaBlock->dyna.actor.world.pos.x, + ikanaBlock->dyna.actor.world.pos.y + ikanaBlock->unk_170, + ikanaBlock->dyna.actor.world.pos.z, &ikanaBlock->dyna.actor.shape.rot); Matrix_GetStateTranslation(&sp28); Matrix_StatePop(); diff --git a/src/overlays/actors/ovl_Bg_Iknin_Susceil/z_bg_iknin_susceil.c b/src/overlays/actors/ovl_Bg_Iknin_Susceil/z_bg_iknin_susceil.c index 4a49be53c1..7e05d6977e 100644 --- a/src/overlays/actors/ovl_Bg_Iknin_Susceil/z_bg_iknin_susceil.c +++ b/src/overlays/actors/ovl_Bg_Iknin_Susceil/z_bg_iknin_susceil.c @@ -56,7 +56,7 @@ s32 func_80C0A740(BgIkninSusceil* this, GlobalContext* globalCtx) { Actor_OffsetOfPointInActorCoords(&this->dyna.actor, &offset, &player->actor.world.pos); - return (D_80C0B0E8.x < offset.z) && (offset.z < D_80C0B0E8.y) && (offset.x > -240.0f) && (offset.x < D_80C0B0E4); + return (D_80C0B0E8.x < offset.z) && (offset.z < D_80C0B0E8.z) && (offset.x > -240.0f) && (offset.x < D_80C0B0E4); } void func_80C0A804(BgIkninSusceil* this, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_Bg_Iknv_Obj/z_bg_iknv_obj.c b/src/overlays/actors/ovl_Bg_Iknv_Obj/z_bg_iknv_obj.c index 7cd39251c3..023b4b7064 100644 --- a/src/overlays/actors/ovl_Bg_Iknv_Obj/z_bg_iknv_obj.c +++ b/src/overlays/actors/ovl_Bg_Iknv_Obj/z_bg_iknv_obj.c @@ -84,7 +84,7 @@ void BgIknvObj_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit); Collider_UpdateCylinder(&this->dyna.actor, &this->collider); this->dyna.actor.colChkInfo.mass = MASS_IMMOVABLE; - gSaveContext.weekEventReg[51] &= (u8)~0x10; + gSaveContext.save.weekEventReg[51] &= (u8)~0x10; Actor_SetFocus(&this->dyna.actor, IREG(88)); break; default: @@ -98,7 +98,7 @@ void BgIknvObj_Destroy(Actor* thisx, GlobalContext* globalCtx) { if (IKNV_OBJ_TYPE(this) != IKNV_OBJ_RAISED_DOOR) { if (IKNV_OBJ_TYPE(this) == IKNV_OBJ_SAKON_DOOR) { Collider_DestroyCylinder(globalCtx, &this->collider); - gSaveContext.weekEventReg[51] &= (u8)~0x10; + gSaveContext.save.weekEventReg[51] &= (u8)~0x10; } else { return; } @@ -125,7 +125,7 @@ s32 func_80BD7CEC(BgIknvObj* this) { } void BgIknvObj_UpdateWaterwheel(BgIknvObj* this, GlobalContext* globalCtx) { - if (gSaveContext.weekEventReg[14] & 4) { + if (gSaveContext.save.weekEventReg[14] & 4) { this->dyna.actor.shape.rot.z -= 0x64; func_800B9098(&this->dyna.actor); func_800B9010(&this->dyna.actor, NA_SE_EV_WOOD_WATER_WHEEL - SFX_FLAG); @@ -156,16 +156,16 @@ s32 func_80BD7E0C(BgIknvObj* this, s16 targetRotation, GlobalContext* globalCtx) void func_80BD7ED8(BgIknvObj* this, GlobalContext* globalCtx) { if (func_80BD7E0C(this, this->dyna.actor.home.rot.y, globalCtx)) { this->actionFunc = BgIknvObj_UpdateSakonDoor; - gSaveContext.weekEventReg[51] &= (u8)~0x10; + gSaveContext.save.weekEventReg[51] &= (u8)~0x10; } CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); } void func_80BD7F4C(BgIknvObj* this, GlobalContext* globalCtx) { - if (gSaveContext.time > CLOCK_TIME(19, 30)) { + if (gSaveContext.save.time > CLOCK_TIME(19, 30)) { this->actionFunc = func_80BD7ED8; } - if ((this->dyna.actor.home.rot.x == 1) && !(gSaveContext.weekEventReg[58] & 0x80)) { + if ((this->dyna.actor.home.rot.x == 1) && !(gSaveContext.save.weekEventReg[58] & 0x80)) { ActorCutscene_Stop(this->dyna.actor.cutscene); this->dyna.actor.home.rot.x = 0; } @@ -175,7 +175,7 @@ void func_80BD7F4C(BgIknvObj* this, GlobalContext* globalCtx) { void func_80BD7FDC(BgIknvObj* this, GlobalContext* globalCtx) { if (func_80BD7E0C(this, this->dyna.actor.home.rot.y + 0x4000, globalCtx)) { this->actionFunc = func_80BD7F4C; - gSaveContext.weekEventReg[51] |= 0x10; + gSaveContext.save.weekEventReg[51] |= 0x10; this->dyna.actor.home.rot.x = 1; } } @@ -188,9 +188,9 @@ void func_80BD8040(BgIknvObj* this, GlobalContext* globalCtx) { } void BgIknvObj_UpdateSakonDoor(BgIknvObj* this, GlobalContext* globalCtx) { - if (gSaveContext.weekEventReg[58] & 0x80) { + if (gSaveContext.save.weekEventReg[58] & 0x80) { this->actionFunc = func_80BD8040; - gSaveContext.weekEventReg[89] |= 0x80; + gSaveContext.save.weekEventReg[89] |= 0x80; } CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); } diff --git a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c index c7e39eec64..11936a9d29 100644 --- a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c +++ b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c @@ -164,7 +164,7 @@ void func_80953F14(BgIngate* this, GlobalContext* globalCtx) { player->actor.focus.rot.y = player->actor.shape.rot.y; this->unk160 |= 0x10; func_80953DA8(this, globalCtx); - if (this->unk164 != 0) { + if (this->unk164 != NULL) { func_80953B40(this); } this->unk16E = -1; @@ -194,7 +194,7 @@ void func_80953F9C(BgIngate* this, GlobalContext* globalCtx) { this->dyna.actor.textId = 0x9E4; Message_StartTextbox(globalCtx, this->dyna.actor.textId, NULL); this->unk16C += 1; - gSaveContext.weekEventReg[90] |= 0x40; + gSaveContext.save.weekEventReg[90] |= 0x40; this->actionFunc = func_809543D4; } else { @@ -253,13 +253,13 @@ void func_809542A0(BgIngate* this, GlobalContext* globalCtx) { globalCtx->unk_1887F = 3; gSaveContext.nextTransition = 3; this->actionFunc = func_80953F8C; - gSaveContext.weekEventReg[90] &= (u8)~0x40; + gSaveContext.save.weekEventReg[90] &= (u8)~0x40; func_800FE498(); } void func_80954340(BgIngate* this, GlobalContext* globalCtx) { if (!DECR(this->unk16A)) { - if (this->unk164 != 0) { + if (this->unk164 != NULL) { func_800B7298(globalCtx, &this->dyna.actor, 6); this->unk164 = &globalCtx->setupPathList[this->unk164->unk1]; func_80953F14(this, globalCtx); @@ -271,7 +271,7 @@ void func_80954340(BgIngate* this, GlobalContext* globalCtx) { void func_809543D4(BgIngate* this, GlobalContext* globalCtx) { u8 talkState = Message_GetState(&globalCtx->msgCtx); - if (((talkState == 4) || (talkState == 5)) && func_80147624(globalCtx)) { + if (((talkState == 4) || (talkState == 5)) && Message_ShouldAdvance(globalCtx)) { switch (this->dyna.actor.textId) { case 0x9E4: this->dyna.actor.textId = 0x9E5; @@ -285,11 +285,11 @@ void func_809543D4(BgIngate* this, GlobalContext* globalCtx) { func_800FE498(); func_8019F208(); } else { - if (this->unk164 != 0) { + if (this->unk164 != NULL) { this->unk164 = &globalCtx->setupPathList[this->unk164->unk1]; } func_80953F14(this, globalCtx); - gSaveContext.weekEventReg[90] &= (u8)~0x40; + gSaveContext.save.weekEventReg[90] &= (u8)~0x40; func_8019F230(); } func_801477B4(globalCtx); @@ -297,10 +297,9 @@ void func_809543D4(BgIngate* this, GlobalContext* globalCtx) { case 0x9E6: if (globalCtx->msgCtx.choiceIndex == 0) { func_80953EA4(this, globalCtx); - gSaveContext.weekEventReg[90] &= (u8)~0x40; + gSaveContext.save.weekEventReg[90] &= (u8)~0x40; func_8019F208(); } else { - this = this; func_800B7298(globalCtx, &this->dyna.actor, 6); this->unk160 &= ~0x4; this->actionFunc = func_809541B8; @@ -328,12 +327,12 @@ void BgIngate_Init(Actor* thisx, GlobalContext* globalCtx2) { this->unk160 |= 0x8; this->unk160 |= 0x10; Actor_SetScale(&this->dyna.actor, 1.0f); - this->unk164 = func_8013BB34(globalCtx, BGINGATE_GET_FF(&this->dyna.actor), 0); + this->unk164 = SubS_GetAdditionalPath(globalCtx, BGINGATE_GET_FF(&this->dyna.actor), 0); this->dyna.actor.room = -1; - if (gSaveContext.weekEventReg[20] & 2) { - gSaveContext.weekEventReg[90] &= (u8)~0x40; + if (gSaveContext.save.weekEventReg[20] & 2) { + gSaveContext.save.weekEventReg[90] &= (u8)~0x40; } - if (!(gSaveContext.eventInf[3] & 0x20) && (gSaveContext.weekEventReg[90] & 0x40)) { + if (!(gSaveContext.eventInf[3] & 0x20) && (gSaveContext.save.weekEventReg[90] & 0x40)) { phi_a2 = 1; this->unk16C = 1; this->actionFunc = func_809541B8; @@ -350,8 +349,8 @@ void BgIngate_Init(Actor* thisx, GlobalContext* globalCtx2) { this->actionFunc = func_80953F8C; } } - this->unk164 = func_8013BB34(globalCtx, BGINGATE_GET_FF(&this->dyna.actor), phi_a2); - if (this->unk164 != 0) { + this->unk164 = SubS_GetAdditionalPath(globalCtx, BGINGATE_GET_FF(&this->dyna.actor), phi_a2); + if (this->unk164 != NULL) { sp38 = Lib_SegmentedToVirtual(this->unk164->points); Math_Vec3s_ToVec3f(&sp2C, &sp38[0]); Math_Vec3s_ToVec3f(&sp20, &sp38[1]); @@ -361,7 +360,7 @@ void BgIngate_Init(Actor* thisx, GlobalContext* globalCtx2) { this->dyna.actor.world.pos.y = -15.0f; this->dyna.actor.world.pos.z = sp2C.z; } - this->unk164 = func_8013BB34(globalCtx, BGINGATE_GET_FF(&this->dyna.actor), 0); + this->unk164 = SubS_GetAdditionalPath(globalCtx, BGINGATE_GET_FF(&this->dyna.actor), 0); } else { Actor_MarkForDeath(&this->dyna.actor); } diff --git a/src/overlays/actors/ovl_Bg_Kin2_Fence/z_bg_kin2_fence.c b/src/overlays/actors/ovl_Bg_Kin2_Fence/z_bg_kin2_fence.c index d169be6de0..6e27d1dc9c 100644 --- a/src/overlays/actors/ovl_Bg_Kin2_Fence/z_bg_kin2_fence.c +++ b/src/overlays/actors/ovl_Bg_Kin2_Fence/z_bg_kin2_fence.c @@ -194,7 +194,7 @@ void BgKin2Fence_HandleMaskCode(BgKin2Fence* this, GlobalContext* globalCtx) { if (this->collider.base.acFlags & AC_HIT) { hitMask = BgKin2Fence_CheckHitMask(this); if (hitMask >= 0) { - nextMask = (s8)gSaveContext.spiderHouseMaskOrder[this->masksHit]; + nextMask = (s8)gSaveContext.save.spiderHouseMaskOrder[this->masksHit]; if (hitMask == nextMask) { play_sound(NA_SE_SY_TRE_BOX_APPEAR); this->masksHit += 1; diff --git a/src/overlays/actors/ovl_Bg_Kin2_Shelf/z_bg_kin2_shelf.c b/src/overlays/actors/ovl_Bg_Kin2_Shelf/z_bg_kin2_shelf.c index cf09d0896d..dc504ecb77 100644 --- a/src/overlays/actors/ovl_Bg_Kin2_Shelf/z_bg_kin2_shelf.c +++ b/src/overlays/actors/ovl_Bg_Kin2_Shelf/z_bg_kin2_shelf.c @@ -5,6 +5,7 @@ */ #include "z_bg_kin2_shelf.h" +#include "objects/object_kin2_obj/object_kin2_obj.h" #define FLAGS 0x00000000 @@ -15,7 +16,13 @@ void BgKin2Shelf_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgKin2Shelf_Update(Actor* thisx, GlobalContext* globalCtx); void BgKin2Shelf_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80B700A8(BgKin2Shelf* this); +void func_80B700C0(BgKin2Shelf* this, GlobalContext* globalCtx); +void func_80B70214(BgKin2Shelf* this); +void func_80B70230(BgKin2Shelf* this, GlobalContext* globalCtx); +void func_80B70498(BgKin2Shelf* this); +void func_80B704B4(BgKin2Shelf* this, GlobalContext* globalCtx); + const ActorInit Bg_Kin2_Shelf_InitVars = { ACTOR_BG_KIN2_SHELF, ACTORCAT_BG, @@ -28,43 +35,345 @@ const ActorInit Bg_Kin2_Shelf_InitVars = { (ActorFunc)BgKin2Shelf_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B7077C[] = { +f32 D_80B70750[] = { 60.0f, 120.0f }; + +f32 D_80B70758[] = { 40.0f, 0.0f }; + +f32 D_80B70760[] = { 10.0f, 15.0f }; + +f32 D_80B70768[] = { 15.0f, 60.0f }; + +f32 D_80B70770[] = { 10.0f, 15.0f }; + +u8 D_80B70778[] = { 0x0F, 0x0A }; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_STOP), }; -#endif +CollisionHeader* D_80B70780[] = { &object_kin2_obj_Colheader_001328, &object_kin2_obj_Colheader_000F80 }; -extern InitChainEntry D_80B7077C[]; +Gfx* D_80B70788[] = { object_kin2_obj_DL_0010F8, object_kin2_obj_DL_000CA8 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Shelf/func_80B6FB30.s") +s32 func_80B6FB30(BgKin2Shelf* this, GlobalContext* globalCtx) { + s32 temp_v1 = BGKIN2SHELF_GET_1(&this->dyna.actor); + f32 phi_f0; + f32 spA4; + s16 spA2; + Vec3f sp94; + Vec3f sp88; + Vec3f sp7C; + Vec3f sp70; + Vec3f sp64; + Vec3f sp58; + CollisionPoly* sp54; + s32 sp50; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Shelf/func_80B6FCA4.s") + if (this->unk_164 & 2) { + spA2 = 0x4000; + } else { + spA2 = -0x4000; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Shelf/func_80B6FE08.s") + spA4 = D_80B70750[temp_v1] + ((this->dyna.pushForce < 0.0f) ? 28.0f : -2.0f) + D_80B70768[temp_v1]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Shelf/func_80B6FE48.s") + Matrix_InsertTranslation(0.0f, 10.0f, D_80B70760[temp_v1], MTXMODE_NEW); + Matrix_RotateY(spA2, MTXMODE_APPLY); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Shelf/func_80B6FEBC.s") + sp58.x = 0.0f; + sp58.y = 0.0f; + sp58.z = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Shelf/func_80B6FF28.s") + Matrix_MultiplyVector3fByState(&sp58, &sp94); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Shelf/BgKin2Shelf_Init.s") + sp58.z = spA4; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Shelf/BgKin2Shelf_Destroy.s") + Matrix_MultiplyVector3fByState(&sp58, &sp88); + Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Matrix_MultiplyVector3fByState(&sp94, &sp7C); + Matrix_MultiplyVector3fByState(&sp88, &sp70); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Shelf/func_80B700A8.s") + return BgCheck_EntityLineTest3(&globalCtx->colCtx, &sp7C, &sp70, &sp64, &sp54, true, false, false, true, &sp50, + &this->dyna.actor, 0.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Shelf/func_80B700C0.s") +s32 func_80B6FCA4(BgKin2Shelf* this, GlobalContext* globalCtx) { + s32 pad; + f32 spA0; + s16 sp9E; + Vec3f sp90; + Vec3f sp84; + Vec3f sp78; + Vec3f sp6C; + Vec3f sp60; + Vec3f sp54; + CollisionPoly* sp50; + s32 sp4C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Shelf/func_80B70214.s") + if (this->unk_164 & 1) { + sp9E = 0; + } else { + sp9E = -0x8000; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Shelf/func_80B70230.s") + spA0 = D_80B70758[0] + ((this->dyna.pushForce < 0.0f) ? 28.0f : -2.0f) + D_80B70770[0]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Shelf/func_80B70498.s") + Matrix_InsertTranslation(0.0f, 10.0f, *D_80B70760, MTXMODE_NEW); + Matrix_RotateY(sp9E, MTXMODE_APPLY); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Shelf/func_80B704B4.s") + sp54.x = 0.0f; + sp54.y = 0.0f; + sp54.z = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Shelf/BgKin2Shelf_Update.s") + Matrix_MultiplyVector3fByState(&sp54, &sp90); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Shelf/BgKin2Shelf_Draw.s") + sp54.z = spA0; + + Matrix_MultiplyVector3fByState(&sp54, &sp84); + Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Matrix_MultiplyVector3fByState(&sp90, &sp78); + Matrix_MultiplyVector3fByState(&sp84, &sp6C); + + return BgCheck_EntityLineTest3(&globalCtx->colCtx, &sp78, &sp6C, &sp60, &sp50, true, false, false, true, &sp4C, + &this->dyna.actor, 0.0f); +} + +s32 func_80B6FE08(BgKin2Shelf* this, GlobalContext* globalCtx) { + if (this->unk_164 & (0x8 | 0x2)) { + return func_80B6FB30(this, globalCtx); + } + return func_80B6FCA4(this, globalCtx); +} + +s32 func_80B6FE48(BgKin2Shelf* this, GlobalContext* globalCtx) { + s32 params = BGKIN2SHELF_GET_1(&this->dyna.actor); + u8 temp_v1 = D_80B70778[params] & this->unk_164; + + if ((this->unk_166 != 0) && (this->unk_167 != 0)) { + return false; + } + + if ((this->unk_166 == 0) && (this->unk_167 == 0)) { + return temp_v1 != 0; + } + + if (this->unk_166 != 0) { + return temp_v1 & (0x8 | 0x2); + } + + return temp_v1 & 5; +} + +s32 func_80B6FEBC(BgKin2Shelf* this, GlobalContext* globalCtx) { + if (this->unk_164 & 1) { + return this->unk_167 < 1; + } + + if (this->unk_164 & 2) { + return this->unk_166 < 1; + } + + if (this->unk_164 & 4) { + return this->unk_167 >= 0; + } + + if (this->unk_164 & 8) { + return this->unk_166 >= 0; + } + return false; +} + +s32 func_80B6FF28(BgKin2Shelf* this, GlobalContext* globalCtx) { + return (this->unk_165 > 8) && func_80B6FE48(this, globalCtx) && func_80B6FEBC(this, globalCtx) && + !func_80B6FE08(this, globalCtx); +} + +void BgKin2Shelf_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgKin2Shelf* this = THIS; + s32 sp24 = BGKIN2SHELF_GET_1(&this->dyna.actor); + + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + + if (sp24 == 0) { + this->dyna.actor.uncullZoneScale = 150.0f; + this->dyna.actor.uncullZoneDownward = 140.0f; + Actor_SetScale(&this->dyna.actor, 0.1f); + } else { + this->dyna.actor.uncullZoneScale = 250.0f; + this->dyna.actor.uncullZoneDownward = 300.0f; + Actor_SetScale(&this->dyna.actor, 1.0f); + this->dyna.actor.flags |= ACTOR_FLAG_10000000; + } + + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, D_80B70780[sp24]); + func_80B700A8(this); +} + +void BgKin2Shelf_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgKin2Shelf* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} + +void func_80B700A8(BgKin2Shelf* this) { + this->unk_165 = 0; + this->actionFunc = func_80B700C0; +} + +void func_80B700C0(BgKin2Shelf* this, GlobalContext* globalCtx) { + s16 temp_v0; + u8 phi_v0_2; + + if (fabsf(this->dyna.pushForce) > 0.1f) { + temp_v0 = this->dyna.yRotation - this->dyna.actor.shape.rot.y; + if (this->dyna.pushForce < 0.0f) { + temp_v0 = BINANG_ROT180(temp_v0); + } + + if ((temp_v0 < -0x6000) || (temp_v0 >= 0x6000)) { + phi_v0_2 = 4; + } else if (temp_v0 < -0x2000) { + phi_v0_2 = 8; + } else if (temp_v0 < 0x2000) { + phi_v0_2 = 1; + } else { + phi_v0_2 = 2; + } + + if ((phi_v0_2 == this->unk_164) || (this->unk_164 == 0)) { + this->unk_164 = phi_v0_2; + this->unk_165++; + } else { + this->unk_165 = 0; + this->unk_164 = 0; + } + + if (func_80B6FF28(this, globalCtx)) { + if (this->unk_164 & (0x8 | 0x2)) { + func_80B70214(this); + } else { + func_80B70498(this); + } + } else { + Player* player = GET_PLAYER(globalCtx); + + player->stateFlags2 &= ~0x10; + this->dyna.pushForce = 0.0f; + } + } else { + this->unk_165 = 0; + this->unk_164 = 0; + } +} + +void func_80B70214(BgKin2Shelf* this) { + this->unk_160 = 0.0f; + this->actionFunc = func_80B70230; +} + +void func_80B70230(BgKin2Shelf* this, GlobalContext* globalCtx) { + f32 phi_f20; + s32 sp40 = BGKIN2SHELF_GET_1(&this->dyna.actor); + f32 phi_f2; + s32 pad; + s16 sp36 = BINANG_ADD(this->dyna.actor.shape.rot.y, 0x4000); + + if ((BGKIN2SHELF_GET_1(&this->dyna.actor)) == 0) { + phi_f2 = (Math_SinS(this->unk_160 * 0x8000) * 0.012f) + 0.014f; + } else { + phi_f2 = (Math_SinS(this->unk_160 * 0x8000) * 0.003f) + 0.009f; + } + this->unk_160 += phi_f2; + + if (this->unk_160 >= 1.0f) { + Player* player = GET_PLAYER(globalCtx); + + this->unk_160 = 1.0f; + player->stateFlags2 &= ~0x10; + this->dyna.pushForce = 0.0f; + + if (this->unk_164 & 8) { + this->unk_166--; + } else { + this->unk_166++; + } + + phi_f20 = this->unk_166; + + this->dyna.actor.world.pos.x = ((Math_SinS(sp36) * phi_f20) * D_80B70750[sp40]) + this->dyna.actor.home.pos.x; + this->dyna.actor.world.pos.z = ((Math_CosS(sp36) * phi_f20) * D_80B70750[sp40]) + this->dyna.actor.home.pos.z; + + if (this->unk_166 != 0) { + play_sound(NA_SE_SY_TRE_BOX_APPEAR); + } + func_80B700A8(this); + } else { + if (this->unk_164 & 8) { + phi_f20 = this->unk_166 - this->unk_160; + } else { + phi_f20 = this->unk_166 + this->unk_160; + } + this->dyna.actor.world.pos.x = ((Math_SinS(sp36) * phi_f20) * D_80B70750[sp40]) + this->dyna.actor.home.pos.x; + this->dyna.actor.world.pos.z = ((Math_CosS(sp36) * phi_f20) * D_80B70750[sp40]) + this->dyna.actor.home.pos.z; + } +} + +void func_80B70498(BgKin2Shelf* this) { + this->unk_160 = 0.0f; + this->actionFunc = func_80B704B4; +} + +void func_80B704B4(BgKin2Shelf* this, GlobalContext* globalCtx) { + f32 temp_f20; + s32 sp40 = BGKIN2SHELF_GET_1(&this->dyna.actor); + f32 phi_f20; + s32 pad; + s16 sp36 = this->dyna.actor.shape.rot.y; + + this->unk_160 += (Math_SinS(this->unk_160 * 0x8000) * 0.022f) + 0.022f; + + if (this->unk_160 >= 1.0f) { + Player* player = GET_PLAYER(globalCtx); + + this->unk_160 = 1.0f; + player->stateFlags2 &= ~0x10; + this->dyna.pushForce = 0.0f; + + if (this->unk_164 & 4) { + this->unk_167--; + } else { + this->unk_167++; + } + + temp_f20 = this->unk_167; + this->dyna.actor.world.pos.x = ((Math_SinS(sp36) * temp_f20) * D_80B70758[sp40]) + this->dyna.actor.home.pos.x; + this->dyna.actor.world.pos.z = ((Math_CosS(sp36) * temp_f20) * D_80B70758[sp40]) + this->dyna.actor.home.pos.z; + + if (this->unk_167 != 0) { + play_sound(NA_SE_SY_TRE_BOX_APPEAR); + } + func_80B700A8(this); + } else { + if (this->unk_164 & 4) { + temp_f20 = this->unk_167 - this->unk_160; + } else { + temp_f20 = this->unk_167 + this->unk_160; + } + this->dyna.actor.world.pos.x = ((Math_SinS(sp36) * temp_f20) * D_80B70758[sp40]) + this->dyna.actor.home.pos.x; + this->dyna.actor.world.pos.z = ((Math_CosS(sp36) * temp_f20) * D_80B70758[sp40]) + this->dyna.actor.home.pos.z; + } +} + +void BgKin2Shelf_Update(Actor* thisx, GlobalContext* globalCtx) { + BgKin2Shelf* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void BgKin2Shelf_Draw(Actor* thisx, GlobalContext* globalCtx) { + Gfx_DrawDListOpa(globalCtx, D_80B70788[BGKIN2SHELF_GET_1(thisx)]); +} diff --git a/src/overlays/actors/ovl_Bg_Kin2_Shelf/z_bg_kin2_shelf.h b/src/overlays/actors/ovl_Bg_Kin2_Shelf/z_bg_kin2_shelf.h index d5cf40c2fd..29a295851a 100644 --- a/src/overlays/actors/ovl_Bg_Kin2_Shelf/z_bg_kin2_shelf.h +++ b/src/overlays/actors/ovl_Bg_Kin2_Shelf/z_bg_kin2_shelf.h @@ -7,11 +7,16 @@ struct BgKin2Shelf; typedef void (*BgKin2ShelfActionFunc)(struct BgKin2Shelf*, GlobalContext*); +#define BGKIN2SHELF_GET_1(thisx) ((thisx)->params & 1) + typedef struct BgKin2Shelf { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; + /* 0x0000 */ DynaPolyActor dyna; /* 0x015C */ BgKin2ShelfActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x8]; + /* 0x0160 */ f32 unk_160; + /* 0x0164 */ u8 unk_164; + /* 0x0165 */ s8 unk_165; + /* 0x0166 */ s8 unk_166; + /* 0x0167 */ s8 unk_167; } BgKin2Shelf; // size = 0x168 extern const ActorInit Bg_Kin2_Shelf_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c b/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c index 5c2a972b59..71f1d2b6a4 100644 --- a/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c +++ b/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c @@ -97,7 +97,7 @@ void BgLotus_Wait(BgLotus* this, GlobalContext* globalCtx) { EffectSsGRipple_Spawn(globalCtx, &this->dyna.actor.world.pos, 1000, 1400, 8); this->timer = 40; } - if (gSaveContext.playerForm != PLAYER_FORM_DEKU) { + if (gSaveContext.save.playerForm != PLAYER_FORM_DEKU) { this->timer = 40; this->dyna.actor.flags |= ACTOR_FLAG_10; this->actionFunc = BgLotus_Sink; diff --git a/src/overlays/actors/ovl_Bg_Numa_Hana/z_bg_numa_hana.c b/src/overlays/actors/ovl_Bg_Numa_Hana/z_bg_numa_hana.c index bf556345f1..186376d9bb 100644 --- a/src/overlays/actors/ovl_Bg_Numa_Hana/z_bg_numa_hana.c +++ b/src/overlays/actors/ovl_Bg_Numa_Hana/z_bg_numa_hana.c @@ -161,7 +161,7 @@ void BgNumaHana_Init(Actor* thisx, GlobalContext* globalCtx) { return; } - if (gSaveContext.weekEventReg[12] & 1) { + if (gSaveContext.save.weekEventReg[12] & 1) { func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); this->petalZRotation = 0x2000; @@ -219,7 +219,7 @@ void BgNumaHana_ClosedIdle(BgNumaHana* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_FLAME_IGNITION); if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); - gSaveContext.weekEventReg[12] |= 1; + gSaveContext.save.weekEventReg[12] |= 1; Flags_SetSwitch(globalCtx, BG_NUMA_HANA_SWITCH_FLAG(&this->dyna.actor)); BgNumaHana_SetupUnfoldInnerPetals(this); } else { diff --git a/src/overlays/actors/ovl_Bg_Open_Spot/z_bg_open_spot.c b/src/overlays/actors/ovl_Bg_Open_Spot/z_bg_open_spot.c index b776253e60..48d2cd4f25 100644 --- a/src/overlays/actors/ovl_Bg_Open_Spot/z_bg_open_spot.c +++ b/src/overlays/actors/ovl_Bg_Open_Spot/z_bg_open_spot.c @@ -1,10 +1,11 @@ /* * File: z_bg_open_spot.c * Overlay: ovl_Bg_Open_Spot - * Description: Star Light Rays in Intro Scene + * Description: Spotlights that shine on the Skull Kid when he turns Link + * into a Deku Scrub. */ - #include "z_bg_open_spot.h" +#include "objects/object_open_obj/object_open_obj.h" #define FLAGS (ACTOR_FLAG_10) @@ -13,8 +14,8 @@ void BgOpenSpot_Init(Actor* thisx, GlobalContext* globalCtx); void BgOpenSpot_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgOpenSpot_Update(Actor* thisx, GlobalContext* globalCtx); +void BgOpenSpot_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Bg_Open_Spot_InitVars = { ACTOR_BG_OPEN_SPOT, ACTORCAT_PROP, @@ -27,25 +28,49 @@ const ActorInit Bg_Open_Spot_InitVars = { (ActorFunc)NULL, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80ACB3B0[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 560, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 800, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#endif +void BgOpenSpot_Init(Actor* thisx, GlobalContext* globalCtx) { + BgOpenSpot* this = THIS; -extern InitChainEntry D_80ACB3B0[]; + Actor_ProcessInitChain(&this->actor, sInitChain); + this->texScrolls = Lib_SegmentedToVirtual(gSpotlightTexAnim); +} -extern UNK_TYPE D_06001A60; -extern UNK_TYPE D_06002CE0; +void BgOpenSpot_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Open_Spot/BgOpenSpot_Init.s") +void BgOpenSpot_Update(Actor* thisx, GlobalContext* globalCtx) { + BgOpenSpot* this = THIS; + u32 action; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Open_Spot/BgOpenSpot_Destroy.s") + if (Cutscene_CheckActorAction(globalCtx, 0x7D)) { + action = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 0x7D)]->action; + if (action == 1) { + this->actor.draw = NULL; + } else if (action == 2) { + this->actor.draw = BgOpenSpot_Draw; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Open_Spot/BgOpenSpot_Update.s") +void BgOpenSpot_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgOpenSpot* this = (BgOpenSpot*)thisx; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Open_Spot/func_80ACB2B0.s") + AnimatedMat_Draw(globalCtx, this->texScrolls); + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); + gDPSetColorDither(POLY_XLU_DISP++, G_CD_BAYER); + gSPDisplayList(POLY_XLU_DISP++, gSpotlightLeftDL); + gSPDisplayList(POLY_XLU_DISP++, gSpotlightRightDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Bg_Open_Spot/z_bg_open_spot.h b/src/overlays/actors/ovl_Bg_Open_Spot/z_bg_open_spot.h index cf4fa2f8da..3a2b92125c 100644 --- a/src/overlays/actors/ovl_Bg_Open_Spot/z_bg_open_spot.h +++ b/src/overlays/actors/ovl_Bg_Open_Spot/z_bg_open_spot.h @@ -7,7 +7,7 @@ struct BgOpenSpot; typedef struct BgOpenSpot { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x4]; + /* 0x144 */ AnimatedMaterial* texScrolls; } BgOpenSpot; // size = 0x148 extern const ActorInit Bg_Open_Spot_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.c b/src/overlays/actors/ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.c index 15bac4d131..e5bba655d6 100644 --- a/src/overlays/actors/ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.c +++ b/src/overlays/actors/ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.c @@ -1,10 +1,18 @@ /* * File: z_bg_sinkai_kabe.c * Overlay: ovl_Bg_Sinkai_Kabe - * Description: Large Rotating Green Rupee + * Description: Manages the Deep Pythons in Pinnacle Rock + * + * While its name describes one of its responsibilities ("Deep Sea Wall", aka the invisible + * wall blocking a Deep Python's den before you defeat it), it is also responsible for + * spawning in the Deep Pythons when the area first loads, as well as signalling to the + * Deep Python that it should extend its body. Furthermore, if the player defeats all + * eight Deep Pythons and spawns the second Seahorse, this actor is responsible for spawning + * it again if the player leaves and re-enters Pinnacle Rock. */ #include "z_bg_sinkai_kabe.h" +#include "objects/object_sinkai_kabe/object_sinkai_kabe.h" #define FLAGS (ACTOR_FLAG_10) @@ -14,7 +22,8 @@ void BgSinkaiKabe_Init(Actor* thisx, GlobalContext* globalCtx); void BgSinkaiKabe_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgSinkaiKabe_Update(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void BgSinkaiKabe_WaitForPlayer(BgSinkaiKabe* this, GlobalContext* globalCtx); + const ActorInit Bg_Sinkai_Kabe_InitVars = { ACTOR_BG_SINKAI_KABE, ACTORCAT_ITEMACTION, @@ -27,14 +36,117 @@ const ActorInit Bg_Sinkai_Kabe_InitVars = { (ActorFunc)NULL, }; -#endif +static s32 sCurrentPythonIndex = 0; -extern UNK_TYPE D_06000048; +void BgSinkaiKabe_Init(Actor* thisx, GlobalContext* globalCtx) { + BgSinkaiKabe* this = THIS; + s32 pad; + CollisionHeader* colHeader = NULL; + Vec3f pos; + s32 pad2; + s32 shouldSpawnSeahorse; + s32 cs; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Sinkai_Kabe/BgSinkaiKabe_Init.s") + DynaPolyActor_Init(&this->dyna, 0); + CollisionHeader_GetVirtual(&gPinnacleRockPythonDenCol, &colHeader); + this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); + Math_Vec3f_Copy(&pos, &this->dyna.actor.world.pos); + pos.x += Math_SinS(this->dyna.actor.world.rot.y + 0x8000) * 3000.0f; + pos.z += Math_CosS(this->dyna.actor.world.rot.y + 0x8000) * 3000.0f; + cs = this->dyna.actor.cutscene; + i = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Sinkai_Kabe/BgSinkaiKabe_Destroy.s") + // clang-format off + while (cs != -1) { this->cutscenes[i] = cs; cs = ActorCutscene_GetAdditionalCutscene(cs); i++; } + // clang-format on -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Sinkai_Kabe/func_80B6DA20.s") + this->dyna.actor.scale.x = 0.1f; + this->dyna.actor.scale.y = 0.1f; + this->dyna.actor.scale.z = 0.1f; + this->pythonIndex = sCurrentPythonIndex; + sCurrentPythonIndex++; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Sinkai_Kabe/BgSinkaiKabe_Update.s") + if (!(gSaveContext.save.weekEventReg[13] & 1)) { + this->deepPython = + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->dyna.actor, globalCtx, ACTOR_EN_DRAGON, pos.x, pos.y, pos.z, + 0, this->dyna.actor.world.rot.y, 1, this->dyna.actor.params); + + if (this->deepPython != NULL) { + EnDragon* dragon = (EnDragon*)this->deepPython; + + dragon->grabCutsceneIndex = this->cutscenes[0]; + dragon->deathCutsceneIndex = this->cutscenes[1]; + dragon->actor.cutscene = this->dyna.actor.cutscene; + Math_Vec3f_Copy(&dragon->burrowEntrancePos, &this->dyna.actor.world.pos); + dragon->pythonIndex = this->pythonIndex; + } + } else { + shouldSpawnSeahorse = false; + if (((this->dyna.actor.params == 0) && (gSaveContext.save.weekEventReg[83] & 0x10)) || + ((this->dyna.actor.params == 1) && (gSaveContext.save.weekEventReg[83] & 0x20)) || + ((this->dyna.actor.params == 2) && (gSaveContext.save.weekEventReg[83] & 0x40)) || + ((this->dyna.actor.params == 3) && (gSaveContext.save.weekEventReg[83] & 0x80)) || + ((this->dyna.actor.params == 4) && (gSaveContext.save.weekEventReg[84] & 1)) || + ((this->dyna.actor.params == 5) && (gSaveContext.save.weekEventReg[84] & 2)) || + ((this->dyna.actor.params == 6) && (gSaveContext.save.weekEventReg[84] & 4)) || + ((this->dyna.actor.params == 7) && (gSaveContext.save.weekEventReg[84] & 8))) { + shouldSpawnSeahorse = true; + } + + Math_Vec3f_Copy(&pos, &this->dyna.actor.home.pos); + pos.x += (Math_SinS(this->dyna.actor.world.rot.y + 0x8000) * 500.0f); + pos.y += -100.0f; + pos.z += (Math_CosS(this->dyna.actor.world.rot.y + 0x8000) * 500.0f); + if (shouldSpawnSeahorse) { + Actor_SpawnAsChildAndCutscene(&globalCtx->actorCtx, globalCtx, ACTOR_EN_OT, pos.x, pos.y, pos.z, 0, + this->dyna.actor.shape.rot.y, 0, 0x4000, this->dyna.actor.cutscene, + this->dyna.actor.unk20, NULL); + } + + Actor_MarkForDeath(&this->dyna.actor); + } + + this->actionFunc = BgSinkaiKabe_WaitForPlayer; +} + +void BgSinkaiKabe_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgSinkaiKabe* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} + +/** + * Extends this actor's Deep Python if the player gets close enough. + */ +void BgSinkaiKabe_WaitForPlayer(BgSinkaiKabe* this, GlobalContext* globalCtx) { + if (this->deepPython != NULL) { + if (this->deepPython->update != NULL) { + EnDragon* dragon = (EnDragon*)this->deepPython; + + if (dragon->action == DEEP_PYTHON_ACTION_IDLE) { + Player* player = GET_PLAYER(globalCtx); + + if ((this->dyna.actor.xzDistToPlayer < 500.0f) || + ((ABS_ALT(BINANG_SUB(this->dyna.actor.yawTowardsPlayer, this->dyna.actor.world.rot.y)) < 0x2000) && + (this->dyna.actor.xzDistToPlayer < 700.0f))) { + if (fabsf(this->dyna.actor.world.pos.y - player->actor.world.pos.y) < 400.0f) { + dragon->action = DEEP_PYTHON_ACTION_EXTEND; + } + } + } + } else { + this->deepPython = NULL; + } + } + + if (this->deepPython == NULL) { + Actor_MarkForDeath(&this->dyna.actor); + } +} + +void BgSinkaiKabe_Update(Actor* thisx, GlobalContext* globalCtx) { + BgSinkaiKabe* this = THIS; + + this->actionFunc(this, globalCtx); +} diff --git a/src/overlays/actors/ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.h b/src/overlays/actors/ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.h index 5fb8665299..1a29f512f0 100644 --- a/src/overlays/actors/ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.h +++ b/src/overlays/actors/ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.h @@ -2,16 +2,19 @@ #define Z_BG_SINKAI_KABE_H #include "global.h" +#include "overlays/actors/ovl_En_Dragon/z_en_dragon.h" struct BgSinkaiKabe; typedef void (*BgSinkaiKabeActionFunc)(struct BgSinkaiKabe*, GlobalContext*); typedef struct BgSinkaiKabe { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; - /* 0x015C */ BgSinkaiKabeActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x10]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ BgSinkaiKabeActionFunc actionFunc; + /* 0x160 */ Actor* deepPython; + /* 0x164 */ s16 cutscenes[2]; + /* 0x168 */ UNK_TYPE1 unk_168[0x4]; + /* 0x16C */ s32 pythonIndex; } BgSinkaiKabe; // size = 0x170 extern const ActorInit Bg_Sinkai_Kabe_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.c b/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.c index 6fccf89a01..d1847009c9 100644 --- a/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.c +++ b/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.c @@ -5,6 +5,7 @@ */ #include "z_bg_spdweb.h" +#include "objects/object_spdweb/object_spdweb.h" #define FLAGS 0x00000000 @@ -15,7 +16,14 @@ void BgSpdweb_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgSpdweb_Update(Actor* thisx, GlobalContext* globalCtx); void BgSpdweb_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_809CE068(BgSpdweb* this); +void func_809CE234(BgSpdweb* this, GlobalContext* globalCtx); +void func_809CE4C8(BgSpdweb* this, GlobalContext* globalCtx); +void func_809CE830(BgSpdweb* this, GlobalContext* globalCtx); +void func_809CEBC0(BgSpdweb* this, GlobalContext* globalCtx); +void func_809CEE74(BgSpdweb* this); +void func_809CEEAC(BgSpdweb* this, GlobalContext* globalCtx); + const ActorInit Bg_Spdweb_InitVars = { ACTOR_BG_SPDWEB, ACTORCAT_BG, @@ -28,89 +36,491 @@ const ActorInit Bg_Spdweb_InitVars = { (ActorFunc)BgSpdweb_Draw, }; -// static ColliderTrisElementInit sTrisElementsInit[2] = { -static ColliderTrisElementInit D_809CF080[2] = { +static ColliderTrisElementInit sTrisElementsInit1[2] = { { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0x00000C00, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0x00000C00, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 75.0f, -8.0f, 75.0f }, { 75.0f, -8.0f, -75.0f }, { -75.0f, -8.0f, -75.0f } } }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0x00000C00, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0x00000C00, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 75.0f, -8.0f, 75.0f }, { -75.0f, -8.0f, -75.0f }, { -75.0f, -8.0f, 75.0f } } }, }, }; -// static ColliderTrisInit sTrisInit = { -static ColliderTrisInit D_809CF0F8 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_TYPE_2, COLSHAPE_TRIS, }, - 2, D_809CF080, // sTrisElementsInit, +static ColliderTrisInit sTrisInit1 = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_2, + COLSHAPE_TRIS, + }, + 2, + sTrisElementsInit1, }; -// static ColliderTrisElementInit sTrisElementsInit[4] = { -static ColliderTrisElementInit D_809CF108[4] = { +static ColliderTrisElementInit sTrisElementsInit2[4] = { { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 70.0f, 160.0f, 15.0f }, { -70.0f, 160.0f, 15.0f }, { -70.0f, 20.0f, 15.0f } } }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 70.0f, 160.0f, 15.0f }, { -70.0f, 20.0f, 15.0f }, { 70.0f, 20.0f, 15.0f } } }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { -70.0f, 160.0f, -15.0f }, { 70.0f, 160.0f, -15.0f }, { 70.0f, 20.0f, -15.0f } } }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { -70.0f, 160.0f, -15.0f }, { 70.0f, 20.0f, -15.0f }, { -70.0f, 20.0f, -15.0f } } }, }, }; -// static ColliderTrisInit sTrisInit = { -static ColliderTrisInit D_809CF1F8 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_TYPE_2, COLSHAPE_TRIS, }, - 4, D_809CF108, // sTrisElementsInit, +static ColliderTrisInit sTrisInit2 = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_2, + COLSHAPE_TRIS, + }, + 4, + sTrisElementsInit2, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_809CF210[] = { +Color_RGBA8 D_809CF208 = { 255, 255, 150, 170 }; + +Color_RGBA8 D_809CF20C = { 255, 0, 0, 0 }; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 1500, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; +void BgSpdweb_Init(Actor* thisx, GlobalContext* globalCtx) { + BgSpdweb* this = THIS; + + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + this->unk_161 = 0; + this->switchFlag = BGSPDWEB_GET_SWITCHFLAG(&this->dyna.actor); + thisx->params &= 0xFF; + DynaPolyActor_Init(&this->dyna, 1); + + if (this->dyna.actor.params == BGSPDWEB_FF_0) { + Collider_InitAndSetTris(globalCtx, &this->collider, &this->dyna.actor, &sTrisInit1, this->colliderElements); + func_809CE068(this); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_spdweb_Colheader_002678); + this->unk_2F8 = globalCtx->colCtx.dyna.bgActors[this->dyna.bgId].colHeader->vtxList; + this->unk_164 = 0.0f; + this->actionFunc = func_809CE4C8; + } else { + Collider_InitAndSetTris(globalCtx, &this->collider, &this->dyna.actor, &sTrisInit2, this->colliderElements); + func_809CE068(this); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_spdweb_Colheader_0011C0); + this->actionFunc = func_809CEBC0; + Actor_SetFocus(&this->dyna.actor, 30.0f); + } + + this->unk_162 = 0; + + if (Flags_GetSwitch(globalCtx, this->switchFlag)) { + Actor_MarkForDeath(&this->dyna.actor); + } +} + +void BgSpdweb_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgSpdweb* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + Collider_DestroyTris(globalCtx, &this->collider); +} + +void func_809CE068(BgSpdweb* this) { + Vec3f sp64[3]; + s32 i; + s32 j; + + Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + + for (i = 0; i < this->collider.count; i++) { + for (j = 0; j < ARRAY_COUNT(sp64); j++) { + Matrix_MultiplyVector3fByState(this->collider.elements[i].dim.vtx + j, &sp64[j]); + } + Collider_SetTrisVertices(&this->collider, i, &sp64[0], &sp64[1], &sp64[2]); + } +} + +void func_809CE15C(BgSpdweb* this) { + this->unk_2F8[0].y = this->unk_2F8[3].y = this->unk_2F8[10].y = this->unk_2F8[11].y = this->unk_2F8[12].y = + this->unk_2F8[13].y = this->unk_2F8[14].y = this->unk_2F8[15].y = + (this->dyna.actor.home.pos.y - this->dyna.actor.world.pos.y) * 10.0f; +} + +void func_809CE1D0(BgSpdweb* this, GlobalContext* globalCtx) { + this->unk_162 = 30; + Flags_SetSwitch(globalCtx, this->switchFlag); + + if (this->dyna.actor.params == BGSPDWEB_FF_0) { + this->actionFunc = func_809CE234; + } else { + this->actionFunc = func_809CE830; + } +} + +void func_809CE234(BgSpdweb* this, GlobalContext* globalCtx) { + Vec3f spB4; + Vec3f spA8; + f32 temp_f20; + f32 temp_f22; + f32 temp_f24; + s16 phi_s2; + s16 temp_s0; + s32 i; + + if (this->unk_162 != 0) { + this->unk_162--; + } + + if (this->unk_162 == 0) { + ActorCutscene_Stop(this->dyna.actor.cutscene); + Actor_MarkForDeath(&this->dyna.actor); + return; + } + + if ((this->unk_162 % 3) == 0) { + phi_s2 = Rand_ZeroOne() * 10922.0f; + spB4.y = 0.0f; + spA8.y = this->dyna.actor.world.pos.y; + + for (i = 0; i < 6; i++) { + temp_s0 = (s32)randPlusMinusPoint5Scaled(10240.0f) + phi_s2; + temp_f24 = Math_SinS(temp_s0); + temp_f22 = Math_CosS(temp_s0); + + spA8.x = this->dyna.actor.world.pos.x + (120.0f * temp_f24); + spA8.z = this->dyna.actor.world.pos.z + (120.0f * temp_f22); + + temp_f20 = Math_Vec3f_DistXZ(&this->dyna.actor.home.pos, &spA8) * (1.0f / 120.0f); + if (temp_f20 < 0.7f) { + temp_f20 = 1.0f - temp_f20; + temp_f24 = Math_SinS(BINANG_ROT180(temp_s0)); + temp_f22 = Math_CosS(BINANG_ROT180(temp_s0)); + } + + spB4.x = 7.0f * temp_f24 * temp_f20; + spB4.y = 0.0f; + spB4.z = 7.0f * temp_f22 * temp_f20; + + EffectSsDeadDb_Spawn(globalCtx, &this->dyna.actor.home.pos, &spB4, &gZeroVec3f, &D_809CF208, &D_809CF20C, + 0x32, 8, 0xE); + phi_s2 += 0x2AAA; + } + + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->dyna.actor.home.pos, 11, NA_SE_EN_EXTINCT); + } +} + +void func_809CE4C8(BgSpdweb* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f sp40; + ColliderTrisElement* element; + s16 sp3A; + s32 i; + f32 temp_f12; + + sp40.x = this->dyna.actor.world.pos.x; + sp40.y = this->dyna.actor.world.pos.y - 50.0f; + sp40.z = this->dyna.actor.world.pos.z; + sp3A = player->unk_B6A; + + if (func_80123F48(globalCtx, &sp40, 70.0f, 50.0f)) { + this->dyna.actor.home.pos.x = player->swordInfo[0].tip.x; + this->dyna.actor.home.pos.z = player->swordInfo[0].tip.z; + func_809CEE74(this); + return; + } + + if (this->collider.base.acFlags & AC_HIT) { + for (i = 0; i < 2; i++) { + element = &this->collider.elements[i]; + if (element->info.bumperFlags & BUMP_HIT) { + if (this->collider.elements[i].info.acHitInfo->toucher.dmgFlags & 0x800) { + Math_Vec3s_ToVec3f(&this->dyna.actor.home.pos, &element->info.bumper.hitPos); + func_809CEE74(this); + return; + } + + if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + sp3A = 300; + break; + } + } + } + } + + if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + temp_f12 = 2.0f * sqrtf(CLAMP_MIN(sp3A, 0)); + if ((this->unk_164 < temp_f12) && (temp_f12 > 2.0f)) { + this->unk_164 = temp_f12; + this->unk_162 = 12; + if (sp3A > 50) { + player->stateFlags1 |= 0x20; + this->unk_161 = 1; + } + } else if (player->actor.speedXZ != 0.0f) { + this->unk_164 = CLAMP_MIN(this->unk_164, 2.0f); + } + } + + if (this->unk_162 != 0) { + this->unk_162--; + } + + this->dyna.actor.world.pos.y = (sin_rad(this->unk_162 * (M_PI / 6)) * this->unk_164) + this->dyna.actor.home.pos.y; + Math_ApproachZeroF(&this->unk_164, 1.0f, 0.8f); + + if (this->unk_162 == 4) { + if ((this->unk_161 != 0) || + ((DynaPolyActor_IsInRidingMovingState(&this->dyna) != 0) && (this->unk_164 > 2.0f))) { + player->actor.velocity.y = this->unk_164 * 0.7f; + player->unk_B68 = (SQ(this->unk_164) * 0.15f) + this->dyna.actor.world.pos.y; + this->unk_161 = 0; + player->stateFlags1 &= ~0x20; + } + } else if (this->unk_162 == 11) { + if (this->unk_164 > 3.0f) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WEB_VIBRATION); + } else { + func_801A75E8(NA_SE_EV_WEB_VIBRATION); + } + } + + if (this->unk_162 == 0) { + this->unk_162 = 12; + } + + func_809CE15C(this); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +#ifdef NON_MATCHING +void func_809CE830(BgSpdweb* this, GlobalContext* globalCtx) { + Vec3f spDC; + Vec3f spD0; + Vec3f spC4; + f32 spB0; + f32 spA4; + f32 sp9C; + f32 sp94; + f32 sp90; + f32 temp_f20; + f32 temp_f22; + f32 temp_f28; + f32 temp_f30; + s32 i; + s16 temp_s0; + s16 temp_s3; + + if (this->unk_162 != 0) { + this->unk_162--; + } + + if (this->unk_162 == 0) { + if (ActorCutscene_GetLength(this->dyna.actor.cutscene) == -1) { + ActorCutscene_Stop(this->dyna.actor.cutscene); + } + Actor_MarkForDeath(&this->dyna.actor); + return; + } + + if ((this->unk_162 % 3) == 0) { + temp_s3 = Rand_ZeroOne() * 0x2AAA; + spB0 = Math_CosS(this->dyna.actor.shape.rot.x); + temp_f20 = Math_SinS(this->dyna.actor.shape.rot.x); + temp_f30 = Math_CosS(this->dyna.actor.shape.rot.y); + spA4 = Math_SinS(this->dyna.actor.shape.rot.y); + if (1) {} + + spC4.x = this->dyna.actor.world.pos.x + ((90.0f * temp_f20) * spA4); + spC4.y = this->dyna.actor.world.pos.y + (90.0f * spB0); + spC4.z = this->dyna.actor.world.pos.z + ((90.0f * temp_f20) * temp_f30); + + sp94 = temp_f20 * spA4; + sp90 = temp_f20 * temp_f30; + + for (i = 0; i < 6; i++) { + temp_s0 = (s32)randPlusMinusPoint5Scaled(0x2800) + temp_s3; + temp_f20 = Math_SinS(temp_s0); + temp_f22 = Math_CosS(temp_s0); + + spD0.x = spC4.x + (90.0f * ((sp94 * temp_f22) + (temp_f30 * temp_f20))); + spD0.y = spC4.y + ((90.0f * spB0) * temp_f22); + spD0.z = spC4.z + (90.0f * ((sp90 * temp_f22) - (spA4 * temp_f20))); + + temp_f28 = Math_Vec3f_DistXYZ(&this->dyna.actor.home.pos, &spD0) * (1.0f / 90.0f); + if (temp_f28 < 0.65f) { + temp_f28 = 1.0f - temp_f28; + temp_f20 = Math_SinS(BINANG_ROT180(temp_s0)); + temp_f22 = Math_CosS(BINANG_ROT180(temp_s0)); + } + + spDC.x = (6.5f * temp_f28) * ((temp_f30 * temp_f20) + (temp_f22 * sp94)); + spDC.y = temp_f22 * ((6.5f * temp_f28) * spB0); + spDC.z = (6.5f * temp_f28) * ((temp_f22 * sp90) - (spA4 * temp_f20)); + + EffectSsDeadDb_Spawn(globalCtx, &this->dyna.actor.home.pos, &spDC, &gZeroVec3f, &D_809CF208, &D_809CF20C, + 0x3C, 8, 0xE); + temp_s3 += 0x2AAA; + } + + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->dyna.actor.home.pos, 11, NA_SE_EN_EXTINCT); + } +} +#else +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spdweb/func_809CE830.s") #endif -extern ColliderTrisElementInit D_809CF080[2]; -extern ColliderTrisInit D_809CF0F8; -extern ColliderTrisElementInit D_809CF108[4]; -extern ColliderTrisInit D_809CF1F8; -extern InitChainEntry D_809CF210[]; +void func_809CEBC0(BgSpdweb* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 sp58; + f32 temp_f10; + f32 temp_f18; + ColliderTrisElement* ptr; + s32 i; + Vec3f sp3C; + f32 sp38; + f32 sp34; + f32 sp30; + f32 sp2C; -extern UNK_TYPE D_06000060; -extern UNK_TYPE D_06002678; + if (this->collider.base.acFlags & AC_HIT) { + for (i = 0; i < ARRAY_COUNT(this->colliderElements); i++) { + ptr = &this->collider.elements[i]; + if (ptr->info.bumperFlags & BUMP_HIT) { + Math_Vec3s_ToVec3f(&this->dyna.actor.home.pos, &ptr->info.bumper.hitPos); + break; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spdweb/BgSpdweb_Init.s") + if (i == ARRAY_COUNT(this->colliderElements)) { + this->dyna.actor.home.pos.x = + ((90.0f * Math_SinS(this->dyna.actor.shape.rot.x)) * Math_SinS(this->dyna.actor.shape.rot.y)) + + this->dyna.actor.world.pos.x; + this->dyna.actor.home.pos.y = + (90.0f * Math_CosS(this->dyna.actor.shape.rot.x)) + this->dyna.actor.world.pos.y; + this->dyna.actor.home.pos.z = + ((90.0f * Math_SinS(this->dyna.actor.shape.rot.x)) * Math_CosS(this->dyna.actor.shape.rot.y)) + + this->dyna.actor.world.pos.z; + } + func_809CEE74(this); + } else if ((player->itemActionParam == 7) && (player->unk_B28 != 0)) { + Math_Vec3f_Diff(&player->swordInfo[0].tip, &this->dyna.actor.world.pos, &sp3C); + sp38 = Math_SinS(-this->dyna.actor.shape.rot.x); + sp34 = Math_CosS(-this->dyna.actor.shape.rot.x); + sp30 = Math_SinS(-this->dyna.actor.shape.rot.y); + sp2C = Math_CosS(-this->dyna.actor.shape.rot.y); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spdweb/BgSpdweb_Destroy.s") + temp_f18 = ((sp3C.x * sp38 * sp30) + (sp3C.y * sp34)) - (sp3C.z * sp38 * sp2C); + sp58 = (-sp3C.x * sp34 * sp30) + (sp3C.y * sp38) + (sp3C.z * sp34 * sp2C); + temp_f10 = (sp3C.x * sp2C) + (sp3C.z * sp30); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spdweb/func_809CE068.s") + if ((fabsf(temp_f10) < 70.0f) && (fabsf(sp58) < 10.0f) && (temp_f18 < 160.0f) && (temp_f18 > 20.0f)) { + Math_Vec3f_Copy(&this->dyna.actor.home.pos, &player->swordInfo[0].tip); + func_809CEE74(this); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spdweb/func_809CE15C.s") + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spdweb/func_809CE1D0.s") +void func_809CEE74(BgSpdweb* this) { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + this->actionFunc = func_809CEEAC; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spdweb/func_809CE234.s") +void func_809CEEAC(BgSpdweb* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + func_809CE1D0(this, globalCtx); + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spdweb/func_809CE4C8.s") +void BgSpdweb_Update(Actor* thisx, GlobalContext* globalCtx) { + BgSpdweb* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spdweb/func_809CE830.s") + this->actionFunc(this, globalCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spdweb/func_809CEBC0.s") +void BgSpdweb_Draw(Actor* thisx, GlobalContext* globalCtx) { + Gfx* gfx; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spdweb/func_809CEE74.s") + OPEN_DISPS(globalCtx->state.gfxCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spdweb/func_809CEEAC.s") + gfx = POLY_XLU_DISP; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spdweb/BgSpdweb_Update.s") + gSPDisplayList(&gfx[0], &sSetupDL[6 * 25]); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spdweb/BgSpdweb_Draw.s") + if (thisx->params == BGSPDWEB_FF_1) { + gSPMatrix(&gfx[1], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&gfx[2], object_spdweb_DL_000060); + } else { + Matrix_InsertTranslation(0.0f, (thisx->home.pos.y - thisx->world.pos.y) * 10.0f, 0.0f, MTXMODE_APPLY); + Matrix_Scale(1.0f, ((thisx->home.pos.y - thisx->world.pos.y) + 10.0f) * 0.1f, 1.0f, MTXMODE_APPLY); + + gSPMatrix(&gfx[1], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&gfx[2], object_spdweb_DL_0012F0); + } + + POLY_XLU_DISP = &gfx[3]; + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.h b/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.h index 1809d67238..9a71c278fd 100644 --- a/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.h +++ b/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.h @@ -7,11 +7,21 @@ struct BgSpdweb; typedef void (*BgSpdwebActionFunc)(struct BgSpdweb*, GlobalContext*); +#define BGSPDWEB_GET_SWITCHFLAG(thisx) (((thisx)->params >> 8) & 0x7F) + +#define BGSPDWEB_FF_0 0 +#define BGSPDWEB_FF_1 1 + typedef struct BgSpdweb { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; + /* 0x0000 */ DynaPolyActor dyna; /* 0x015C */ BgSpdwebActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x19C]; + /* 0x0160 */ u8 switchFlag; + /* 0x0161 */ u8 unk_161; + /* 0x0162 */ s16 unk_162; + /* 0x0164 */ f32 unk_164; + /* 0x0168 */ ColliderTris collider; + /* 0x0188 */ ColliderTrisElement colliderElements[4]; + /* 0x02F8 */ Vec3s* unk_2F8; } BgSpdweb; // size = 0x2FC extern const ActorInit Bg_Spdweb_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.c b/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.c index 3adec0ce4e..f9b76fd006 100644 --- a/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.c +++ b/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.c @@ -38,13 +38,13 @@ void BgTobira01_Open(BgTobira01* this, GlobalContext* globalCtx) { ActorCutscene_Stop(0x7C); } else if (ActorCutscene_GetCanPlayNext(cutsceneId)) { ActorCutscene_StartAndSetUnkLinkFields(cutsceneId, &this->dyna.actor); - gSaveContext.weekEventReg[88] |= 0x40; + gSaveContext.save.weekEventReg[88] |= 0x40; this->playCutscene = false; } else { ActorCutscene_SetIntentToPlay(cutsceneId); } - } else if (!(gSaveContext.weekEventReg[88] & 0x40) && (this->timer == 0) && (globalCtx->actorCtx.unk1F5 != 0) && - (globalCtx->actorCtx.unk1F4 == 0) && + } else if (!(gSaveContext.save.weekEventReg[88] & 0x40) && (this->timer == 0) && + (globalCtx->actorCtx.unk1F5 != 0) && (globalCtx->actorCtx.unk1F4 == 0) && (SurfaceType_GetSceneExitIndex(&globalCtx->colCtx, player->actor.floorPoly, player->actor.floorBgId) == 6)) { this->playCutscene = true; @@ -53,7 +53,7 @@ void BgTobira01_Open(BgTobira01* this, GlobalContext* globalCtx) { prevTimer = this->timer; - if (gSaveContext.weekEventReg[88] & 0x40) { + if (gSaveContext.save.weekEventReg[88] & 0x40) { this->timer++; } else { this->timer--; @@ -68,8 +68,8 @@ void BgTobira01_Open(BgTobira01* this, GlobalContext* globalCtx) { this->timer2 = 180; } - if (!(player->stateFlags1 & 0x40) && (gSaveContext.weekEventReg[88] & 0x40) && (DECR(this->timer2) == 0)) { - gSaveContext.weekEventReg[88] &= (u8)~0x40; + if (!(player->stateFlags1 & 0x40) && (gSaveContext.save.weekEventReg[88] & 0x40) && (DECR(this->timer2) == 0)) { + gSaveContext.save.weekEventReg[88] &= (u8)~0x40; } } @@ -79,9 +79,9 @@ void BgTobira01_Init(Actor* thisx, GlobalContext* globalCtx) { DynaPolyActor_Init(&this->dyna, 1); DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_spot11_obj_Colheader_0011C0); - gSaveContext.weekEventReg[88] &= (u8)~0x40; + gSaveContext.save.weekEventReg[88] &= (u8)~0x40; Actor_SetScale(&this->dyna.actor, 1.0f); - this->timer2 = gSaveContext.isNight; + this->timer2 = gSaveContext.save.isNight; this->timer = 0; this->actionFunc = BgTobira01_Open; } diff --git a/src/overlays/actors/ovl_Boss_02/z_boss_02.c b/src/overlays/actors/ovl_Boss_02/z_boss_02.c index ea65880de7..4a90612072 100644 --- a/src/overlays/actors/ovl_Boss_02/z_boss_02.c +++ b/src/overlays/actors/ovl_Boss_02/z_boss_02.c @@ -4,11 +4,12 @@ * Description: Twinmold */ +#include "prevent_bss_reordering.h" #include "z_boss_02.h" #include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" #include "overlays/actors/ovl_Item_B_Heart/z_item_b_heart.h" -#include "objects/object_boss02/object_boss02.h" #include "objects/gameplay_keep/gameplay_keep.h" +#include "prevent_bss_reordering.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -549,7 +550,7 @@ void Boss02_Init(Actor* thisx, GlobalContext* globalCtx) { s32 i; s32 pad[2]; - if ((gSaveContext.weekEventReg[52] & 0x20) && (this->actor.params == 0)) { + if ((gSaveContext.save.weekEventReg[52] & 0x20) && (this->actor.params == 0)) { D_809E0434 = (DoorWarp1*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DOOR_WARP1, 0.0f, 60.0f, 0.0f, 0, 0, 0, 1); Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_B_HEART, 0.0f, 30.0f, -150.0f, 0, 1, 0, 0); @@ -596,8 +597,8 @@ void Boss02_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.colChkInfo.mass = MASS_HEAVY; this->actor.colChkInfo.health = 20; Actor_SetScale(&this->actor, 0.01f); - SkelAnime_Init(globalCtx, &this->skelAnime, &object_boss02_Skel_009B10, &object_boss02_Anim_009C78, - this->jointTable, this->morphTable, 13); + SkelAnime_Init(globalCtx, &this->skelAnime, &gTwinmoldHeadSkel, &gTwinmoldHeadFlyAnim, this->jointTable, + this->morphTable, TWINMOLD_HEAD_LIMB_MAX); Collider_InitAndSetJntSph(globalCtx, &this->colliderSphere1, &this->actor, &sJntSphInit1, this->colliderSphere1Elements); Collider_InitAndSetJntSph(globalCtx, &this->colliderSphere2, &this->actor, &sJntSphInit2, @@ -636,7 +637,7 @@ void func_809DAA98(Boss02* this, GlobalContext* globalCtx) { void func_809DAAA8(Boss02* this, GlobalContext* globalCtx) { this->actionFunc = func_809DAB78; - Animation_MorphToLoop(&this->skelAnime, &object_boss02_Anim_009C78, 0.0f); + Animation_MorphToLoop(&this->skelAnime, &gTwinmoldHeadFlyAnim, 0.0f); if (D_809E042C->unk_1D20 != 0) { this->unk_0144 = 10; } else { @@ -1320,24 +1321,22 @@ void func_809DC78C(Actor* thisx, GlobalContext* globalCtx) { func_809DD934(this, globalCtx); } -#ifdef NON_MATCHING -// matrix stuff at the start? void Boss02_Draw(Actor* thisx, GlobalContext* globalCtx2) { static Gfx* D_809DFA9C[] = { - object_boss02_DL_00ECF0, object_boss02_DL_00EF90, object_boss02_DL_00F310, object_boss02_DL_00F690, - object_boss02_DL_00FA10, object_boss02_DL_00FD90, object_boss02_DL_010110, object_boss02_DL_010490, - object_boss02_DL_010810, object_boss02_DL_010B90, object_boss02_DL_010F10, object_boss02_DL_011290, - object_boss02_DL_011610, object_boss02_DL_011990, object_boss02_DL_011D10, object_boss02_DL_012090, - object_boss02_DL_012410, object_boss02_DL_012790, object_boss02_DL_012B10, object_boss02_DL_012E90, - object_boss02_DL_013210, object_boss02_DL_013590, + gTwinmoldBodySegment1DL, gTwinmoldBodySegment2DL, gTwinmoldBodySegment3DL, gTwinmoldBodySegment4DL, + gTwinmoldBodySegment5DL, gTwinmoldBodySegment6DL, gTwinmoldBodySegment7DL, gTwinmoldBodySegment8DL, + gTwinmoldBodySegment9DL, gTwinmoldBodySegment10DL, gTwinmoldBodySegment11DL, gTwinmoldBodySegment12DL, + gTwinmoldBodySegment13DL, gTwinmoldBodySegment14DL, gTwinmoldBodySegment15DL, gTwinmoldBodySegment16DL, + gTwinmoldBodySegment17DL, gTwinmoldBodySegment18DL, gTwinmoldBodySegment19DL, gTwinmoldBodySegment20DL, + gTwinmoldBodySegment21DL, gTwinmoldBodyTailDL, }; static Vec3f D_809DFAF4 = { -10000.0f, -100000.0f, -100000.0f }; - Boss02* this = THIS; GlobalContext* globalCtx = globalCtx2; + Boss02* this = THIS; s32 i; s32 idx; - RSPMatrix* matrix; - s32 pad; + Mtx* mtx; + Mtx* mtxIter; s32 phi_v0; f32 phi_f12; f32 spAC; @@ -1347,19 +1346,19 @@ void Boss02_Draw(Actor* thisx, GlobalContext* globalCtx2) { f32 sp9C; f32 sp98; - matrix = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(RSPMatrix) * 23); + mtxIter = mtx = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(Mtx) * 23); OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); if (this->actor.params == 0) { - gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(object_boss02_Tex_0003A0)); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(gTwinmoldRedSkinTex)); } else { - gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(object_boss02_Tex_0041A0)); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(gTwinmoldBlueSkinTex)); } - gSPSegment(POLY_OPA_DISP++, 0x0D, matrix); + gSPSegment(POLY_OPA_DISP++, 0x0D, mtx); if (D_809E0422 == 0) { sp98 = -500.0f; @@ -1396,11 +1395,11 @@ void Boss02_Draw(Actor* thisx, GlobalContext* globalCtx2) { spA4 = 0.0f; spA0 = 0.0f; - for (i = 0; i < ARRAY_COUNT(D_809DFA9C); i++) { + for (i = 0; i < ARRAY_COUNT(D_809DFA9C); i++, mtxIter++) { if (this->unk_0195 != 0) { - phi_v0 = (D_809DF5E4[i] + this->unk_014E) % ARRAY_COUNT(this->unk_01BC); + phi_v0 = (D_809DF5E4[i + 1] + this->unk_014E) % ARRAY_COUNT(this->unk_01BC); } else { - phi_v0 = (D_809DF5B4[i] + this->unk_014E) % ARRAY_COUNT(this->unk_01BC); + phi_v0 = (D_809DF5B4[i + 1] + this->unk_014E) % ARRAY_COUNT(this->unk_01BC); } if ((i == 21) && (this->unk_0144 < 20)) { @@ -1416,9 +1415,9 @@ void Boss02_Draw(Actor* thisx, GlobalContext* globalCtx2) { Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); Matrix_InsertYRotation_f(M_PI / 2, MTXMODE_APPLY); Matrix_RotateStateAroundXAxis(-(M_PI / 2)); - Matrix_GetStateAsRSPMatrix(&matrix[i]); + Matrix_ToMtx(mtxIter); - gSPMatrix(POLY_OPA_DISP++, &matrix[i], G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_OPA_DISP++, mtxIter, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); if ((this->unk_0156 & 1) && (i >= this->unk_0158) && (this->unk_015A >= i)) { POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, 255, 0, 0, 255, 0x384, 0x44B); @@ -1443,7 +1442,7 @@ void Boss02_Draw(Actor* thisx, GlobalContext* globalCtx2) { Actor* child = this->actor.child; if (child != NULL) { - Matrix_GetStateTranslationAndScaledX(500.0f, &child->world.pos); + Matrix_GetStateTranslationAndScaledX(500.0f, &this->actor.child->world.pos); } func_809DA50C(1, &this->colliderSphere2, &this->unk_147C[i + 1]); @@ -1464,18 +1463,6 @@ void Boss02_Draw(Actor* thisx, GlobalContext* globalCtx2) { func_809DA50C(21, &this->colliderSphere1, &D_809DFAF4); } } -#else -static Gfx* D_809DFA9C[] = { - object_boss02_DL_00ECF0, object_boss02_DL_00EF90, object_boss02_DL_00F310, object_boss02_DL_00F690, - object_boss02_DL_00FA10, object_boss02_DL_00FD90, object_boss02_DL_010110, object_boss02_DL_010490, - object_boss02_DL_010810, object_boss02_DL_010B90, object_boss02_DL_010F10, object_boss02_DL_011290, - object_boss02_DL_011610, object_boss02_DL_011990, object_boss02_DL_011D10, object_boss02_DL_012090, - object_boss02_DL_012410, object_boss02_DL_012790, object_boss02_DL_012B10, object_boss02_DL_012E90, - object_boss02_DL_013210, object_boss02_DL_013590, -}; -static Vec3f D_809DFAF4 = { -10000.0f, -100000.0f, -100000.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_02/Boss02_Draw.s") -#endif void func_809DD0A8(Actor* thisx, GlobalContext* globalCtx) { func_809DD2F8(globalCtx); @@ -1541,7 +1528,7 @@ void func_809DD2F8(GlobalContext* globalCtx) { for (i = 0; i < ARRAY_COUNT(D_809E0438); i++, effect++) { if (effect->unk_24 == 1) { if (!flag) { - gSPDisplayList(POLY_XLU_DISP++, object_boss02_DL_000230); + gSPDisplayList(POLY_XLU_DISP++, gTwinmoldDustMaterialDL); gDPSetEnvColor(POLY_XLU_DISP++, 185, 140, 70, 128); flag++; } @@ -1562,7 +1549,7 @@ void func_809DD2F8(GlobalContext* globalCtx) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_boss02_DL_0002E0); + gSPDisplayList(POLY_XLU_DISP++, gTwinmoldDustModelDL); } } @@ -1591,7 +1578,7 @@ void func_809DD2F8(GlobalContext* globalCtx) { for (i = 0, flag = false; i < ARRAY_COUNT(D_809E0438); i++, effect++) { if (effect->unk_24 == 4) { if (!flag) { //! @bug - dev forgot to set flag to 1, should only apply to first entry? - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023348); + gSPDisplayList(POLY_XLU_DISP++, gLightOrb1DL); gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 128); } @@ -1603,7 +1590,7 @@ void func_809DD2F8(GlobalContext* globalCtx) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023428); + gSPDisplayList(POLY_XLU_DISP++, gLightOrbVtxDL); } } @@ -1611,7 +1598,7 @@ void func_809DD2F8(GlobalContext* globalCtx) { for (i = 0, flag = false; i < ARRAY_COUNT(D_809E0438); i++, effect++) { if (effect->unk_24 == 2) { if (!flag) { - gSPDisplayList(POLY_XLU_DISP++, object_boss02_DL_000230); + gSPDisplayList(POLY_XLU_DISP++, gTwinmoldDustMaterialDL); gDPSetEnvColor(POLY_XLU_DISP++, 30, 30, 30, 128); flag++; } @@ -1627,15 +1614,13 @@ void func_809DD2F8(GlobalContext* globalCtx) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_boss02_DL_0002E0); + gSPDisplayList(POLY_XLU_DISP++, gTwinmoldDustModelDL); } } CLOSE_DISPS(globalCtx->state.gfxCtx); } -#ifdef NON_MATCHING -// Small ordering in the last loop void func_809DD934(Boss02* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s16 i; @@ -1946,9 +1931,11 @@ void func_809DD934(Boss02* this, GlobalContext* globalCtx) { } temp_a0_5 = temp_a0_5->next; } + { + f32 tmp = D_809E0422 ? 3150.0f : 0.0f; - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BG_INIBS_MOVEBG, 0, D_809E0422 ? 3150.0f : 0.0f, 0, 0, 0, 0, - D_809E0422); + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BG_INIBS_MOVEBG, 0, tmp, 0, 0, 0, 0, D_809E0422); + } temp_a0_5 = globalCtx->actorCtx.actorLists[ACTORCAT_BOSS].first; while (temp_a0_5 != NULL) { @@ -2052,9 +2039,6 @@ void func_809DD934(Boss02* this, GlobalContext* globalCtx) { ShrinkWindow_SetLetterboxTarget(27); } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_02/func_809DD934.s") -#endif void func_809DEAC4(Boss02* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); @@ -2074,7 +2058,7 @@ void func_809DEAC4(Boss02* this, GlobalContext* globalCtx) { break; case 1: - if ((gSaveContext.weekEventReg[52] & 0x20) || ((u32)(KREG(13) + 15) >= this->unk_1D1C)) { + if ((gSaveContext.save.weekEventReg[52] & 0x20) || ((u32)(KREG(13) + 15) >= this->unk_1D1C)) { break; } Cutscene_Start(globalCtx, &globalCtx->csCtx); @@ -2157,7 +2141,7 @@ void func_809DEAC4(Boss02* this, GlobalContext* globalCtx) { if (this->unk_1D1C == (u32)(KREG(92) + 125)) { TitleCard_InitBossName(&globalCtx->state, &globalCtx->actorCtx.titleCtxt, - Lib_SegmentedToVirtual(object_boss02_Tex_008650), 160, 180, 128, 40); + Lib_SegmentedToVirtual(gTwinmoldTitleCardTex), 160, 180, 128, 40); } if (this->unk_1D1C == (u32)(BREG(27) + 335)) { diff --git a/src/overlays/actors/ovl_Boss_02/z_boss_02.h b/src/overlays/actors/ovl_Boss_02/z_boss_02.h index babf40b769..6c20814fbc 100644 --- a/src/overlays/actors/ovl_Boss_02/z_boss_02.h +++ b/src/overlays/actors/ovl_Boss_02/z_boss_02.h @@ -2,6 +2,7 @@ #define Z_BOSS_02_H #include "global.h" +#include "objects/object_boss02/object_boss02.h" struct Boss02; @@ -56,8 +57,8 @@ typedef struct Boss02 { /* 0x0B1C */ Vec3f unk_0B1C[200]; /* 0x147C */ Vec3f unk_147C[23]; /* 0x1590 */ SkelAnime skelAnime; - /* 0x15D4 */ Vec3s jointTable[13]; - /* 0x1622 */ Vec3s morphTable[13]; + /* 0x15D4 */ Vec3s jointTable[TWINMOLD_HEAD_LIMB_MAX]; + /* 0x1622 */ Vec3s morphTable[TWINMOLD_HEAD_LIMB_MAX]; /* 0x1670 */ Boss02ActionFunc actionFunc; /* 0x1674 */ struct Boss02* unk_1674; // points to the other's instance /* 0x1678 */ s32 unk_1678; diff --git a/src/overlays/actors/ovl_Boss_03/z_boss_03.c b/src/overlays/actors/ovl_Boss_03/z_boss_03.c index 70a6405bcb..31e8fb0aea 100644 --- a/src/overlays/actors/ovl_Boss_03/z_boss_03.c +++ b/src/overlays/actors/ovl_Boss_03/z_boss_03.c @@ -4,12 +4,79 @@ * Description: Gyorg */ +/** + * Some notes: + * + * Global flags: + * - gSaveContext.eventInf[5] & 0x40: Enabled when Gyorg's intro cutscene has been watched + * - gSaveContext.save.weekEventReg[55] & 0x80: Checked to know if Gyorg has been defeated + * + * Seaweed: + * - Refers to the seaweed at the bottom of the stage where Player fights Gyorg + * - The default Gyorg actor will spawn 5 other Gyorg instances using the parameter GYORG_PARAM_SEAWEED to spawn them + * - Seaweed can bend when the main Gyorg instance (the actual boss) or Player are near + * + * This actor makes some heavy assumptions about the positions of the room where it is spawned + * + * Cutscenes: + * - There are 3 cutscenes: + * - IntroCutscene: The cs which is played when Player falls into the main room. It also shows Gyorg's titlecard + * - SpawnSmallFishesCutscene: The short cs which is played when Gyorg is spawning the small fishes (EnTanron3). This + * is triggered when Gyorg reaches half of its life + * - DeathCutscene: Played when Gyorg dies. Showing it splashing and becoming smaller each time until it disappears + * - This actor mainly handles the 3 cutscenes it has manually (instead of relying on existing systems for it) + * + * Main behaviour: + * - Gyorg has two types of behaviour depending on Player's state: + * - If Player is standing on the main platform, then Gyorg follows the PrepareCharge -> Charge -> JumpOverPlatform + * branch + * - Otherwise, Gyorg follows the ChasePlayer -> CatchPlayer -> ChewPlayer branch + * - The main actionFunc which decides which branch should be taken is func_809E34B8 + * - Most of the actions of those two branches are constantly checking for the WORK_TIMER_CURRENT_ACTION timer. If it + * runs out, then the behaviour resets back to func_809E34B8 + * - Either branch behaviour can be interrupted at any time by a hit from Player + * - Being hit once makes Gyorg Stunned + * - When Gyorg is Stunned, it is vulnerable to be Damaged by Player + * - When Gyorg's health drops below half, it spawns the small fishes + * + * The collision logic is handled manually + * + * This file is more or less sectioned like this: + * - SpawnEffect + * - RNG + * - Gyorg + * - Init and actionFuncs + * - Cutscenes + * - More actionFuncs and Update + * - Draw + * - Effect Update/Draw + * - Seaweed + */ + #include "z_boss_03.h" +#include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" +#include "overlays/actors/ovl_En_Water_Effect/z_en_water_effect.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_water_effect/object_water_effect.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((Boss03*)thisx) +#define WORK_TIMER_UNK0_A 0 // used in func_809E34B8 +#define WORK_TIMER_CURRENT_ACTION 0 +#define WORK_TIMER_UNK0_C 0 // used in DeathCutscene + +#define WORK_TIMER_UNK1_A 1 // used in func_809E34B8 +#define WORK_TIMER_UNK1_B 1 // used in PrepareCharge + +#define WORK_TIMER_UNK2_A 2 // used in func_809E34B8 +#define WORK_TIMER_STUNNED 2 + +// The Y position of the top of the platform +#define PLATFORM_HEIGHT 440.0f +#define WATER_HEIGHT 430.0f + void Boss03_Init(Actor* thisx, GlobalContext* globalCtx); void Boss03_Destroy(Actor* thisx, GlobalContext* globalCtx); void Boss03_Update(Actor* thisx, GlobalContext* globalCtx); @@ -17,18 +84,200 @@ void Boss03_Draw(Actor* thisx, GlobalContext* globalCtx); void func_809E344C(Boss03* this, GlobalContext* globalCtx); void func_809E34B8(Boss03* this, GlobalContext* globalCtx); -void func_809E3968(Boss03* this, GlobalContext* globalCtx); -void func_809E3D98(Boss03* this, GlobalContext* globalCtx); -void func_809E421C(Boss03* this, GlobalContext* globalCtx); -void func_809E475C(Boss03* this, GlobalContext* globalCtx); -void func_809E497C(Boss03* this, GlobalContext* globalCtx); -void func_809E4C90(Boss03* this, GlobalContext* globalCtx); -void func_809E4E80(Boss03* this, GlobalContext* globalCtx); -void func_809E5B64(Boss03* this, GlobalContext* globalCtx); -void func_809E6640(Boss03* this, GlobalContext* globalCtx); -void func_809E6BC0(Boss03* this, GlobalContext* globalCtx); +void Boss03_SetupChasePlayer(Boss03* this, GlobalContext* globalCtx); +void Boss03_ChasePlayer(Boss03* this, GlobalContext* globalCtx); +void Boss03_SetupCatchPlayer(Boss03* this, GlobalContext* globalCtx, u8 arg2); +void Boss03_CatchPlayer(Boss03* this, GlobalContext* globalCtx); +void Boss03_SetupChewPlayer(Boss03* this, GlobalContext* globalCtx); +void Boss03_ChewPlayer(Boss03* this, GlobalContext* globalCtx); +void Boss03_SetupPrepareCharge(Boss03* this, GlobalContext* globalCtx); +void Boss03_PrepareCharge(Boss03* this, GlobalContext* globalCtx); +void Boss03_SetupCharge(Boss03* this, GlobalContext* globalCtx); +void Boss03_Charge(Boss03* this, GlobalContext* globalCtx); +void Boss03_SetupJumpOverPlatform(Boss03* this, GlobalContext* globalCtx); +void Boss03_JumpOverPlatform(Boss03* this, GlobalContext* globalCtx); +void Boss03_SetupIntroCutscene(Boss03* this, GlobalContext* globalCtx); +void Boss03_IntroCutscene(Boss03* this, GlobalContext* globalCtx); +void Boss03_DeathCutscene(Boss03* this, GlobalContext* globalCtx); +void Boss03_SpawnSmallFishesCutscene(Boss03* this, GlobalContext* globalCtx); +void Boss03_Stunned(Boss03* this, GlobalContext* globalCtx); +void Boss03_Damaged(Boss03* this, GlobalContext* globalCtx); + +void Boss03_UpdateEffects(GlobalContext* globalCtx); +void Boss03_DrawEffects(GlobalContext* globalCtx); + +void Boss03_SeaweedUpdate(Actor* thisx, GlobalContext* globalCtx); +void Boss03_SeaweedDraw(Actor* thisx, GlobalContext* globalCtx); + +u8 D_809E9840; +// Timer used to start playing the boss background music if the intro cutscene was skipped (because it was already +// watched) +u8 D_809E9841; +// Used to set the timer D_809E9841 in case the intro cutscene was skipped +u8 D_809E9842; + +// Set to Gyorg's projectedPos. sGyorgProjectedPos? +Vec3f D_809E9848; + +GyorgEffect sGyorgEffects[GYORG_EFFECT_COUNT]; + +// Used by the Seaweed variant to interact with the "real" Gyorg boss +Boss03* sGyorgBossInstance; + +void Boss03_PlayUnderwaterSfx(Vec3f* projectedPos, u16 sfxId) { + func_8019F420(projectedPos, sfxId); +} + +/* Start of SpawnEffect section */ + +void Boss03_SpawnEffectWetSpot(GlobalContext* globalCtx, Vec3f* pos) { + s16 i; + GyorgEffect* eff = globalCtx->specialEffects; + + for (i = 0; i < GYORG_EFFECT_COUNT; i++) { + if ((eff->type == GYORG_EFFECT_NONE) || (eff->type == GYORG_EFFECT_BUBBLE)) { + eff->type = GYORG_EFFECT_WET_SPOT; + eff->pos = *pos; + eff->unk_34.x = 0.1f; + eff->unk_34.y = 0.4f; + eff->velocity = gZeroVec3f; + eff->accel = gZeroVec3f; + eff->alpha = 150; + eff->alphaDelta = Rand_ZeroFloat(4.0f) + 5.0f; + return; + } + + eff++; + } +} + +void Boss03_SpawnEffectDroplet(GlobalContext* globalCtx, Vec3f* pos) { + s16 i; + GyorgEffect* eff = globalCtx->specialEffects; + + for (i = 0; i < GYORG_EFFECT_COUNT; i++) { + if ((eff->type == GYORG_EFFECT_NONE) || (eff->type == GYORG_EFFECT_BUBBLE)) { + eff->type = GYORG_EFFECT_DROPLET; + eff->pos = *pos; + eff->velocity = gZeroVec3f; + eff->accel = gZeroVec3f; + eff->accel.y = -2.0f; + eff->unk_34.x = 0.1f; + eff->unk_34.y = 0.0f; + eff->unk_34.z = Rand_ZeroFloat(2 * M_PI); + eff->unk_02 = Rand_ZeroFloat(100.0f); + eff->velocity.x = randPlusMinusPoint5Scaled(25.0f); + eff->velocity.z = randPlusMinusPoint5Scaled(25.0f); + return; + } + + eff++; + } +} + +void Boss03_SpawnEffectSplash(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity) { + Vec3f accel = { 0.0f, -1.0f, 0.0f }; + f32 temp_f2; + GyorgEffect* eff = globalCtx->specialEffects; + s16 i; + + for (i = 0; i < GYORG_EFFECT_COUNT; i++) { + if ((eff->type == GYORG_EFFECT_NONE) || (eff->type == GYORG_EFFECT_BUBBLE)) { + eff->type = GYORG_EFFECT_SPLASH; + eff->pos = *pos; + eff->velocity = *velocity; + eff->accel = accel; + temp_f2 = Rand_ZeroFloat(0.02f) + 0.02f; + eff->unk_34.y = temp_f2; + eff->unk_34.x = temp_f2; + eff->unk_34.z = Rand_ZeroFloat(2 * M_PI); + eff->unk_02 = Rand_ZeroFloat(100.0f); + return; + } + + eff++; + } +} + +void Boss03_SpawnEffectBubble(GlobalContext* globalCtx, Vec3f* pos) { + s16 i; + GyorgEffect* eff = globalCtx->specialEffects; + + for (i = 0; i < GYORG_EFFECT_COUNT; i++) { + if (eff->type == GYORG_EFFECT_NONE) { + eff->type = GYORG_EFFECT_BUBBLE; + eff->pos = *pos; + eff->velocity = gZeroVec3f; + eff->accel = gZeroVec3f; + eff->accel.y = 0.2f; + eff->unk_34.x = Rand_ZeroFloat(0.3f) + 0.2f; + eff->unk_02 = 0; + return; + } + + eff++; + } +} + +/* End of SpawnEffect section */ + +void Boss03_UpdateSphereElement(s32 index, ColliderJntSph* collider, Vec3f* sphereCenter) { + ColliderJntSphElement* sphElement; + + collider->elements[index].dim.worldSphere.center.x = sphereCenter->x; + collider->elements[index].dim.worldSphere.center.y = sphereCenter->y; + collider->elements[index].dim.worldSphere.center.z = sphereCenter->z; + + sphElement = &collider->elements[index]; + sphElement->dim.worldSphere.radius = sphElement->dim.scale * sphElement->dim.modelSphere.radius; +} + +/* Start of RNG section */ + +static s32 sRandSeed0; +static s32 sRandSeed1; +static s32 sRandSeed2; + +void Boss03_SeedRand(s32 seed0, s32 seed1, s32 seed2) { + sRandSeed0 = seed0; + sRandSeed1 = seed1; + sRandSeed2 = seed2; +} + +f32 Boss03_RandZeroOne(void) { + f32 rand; + + // Wichmann-Hill algorithm + sRandSeed0 = (sRandSeed0 * 171) % 30269; + sRandSeed1 = (sRandSeed1 * 172) % 30307; + sRandSeed2 = (sRandSeed2 * 170) % 30323; + + rand = (sRandSeed0 / 30269.0f) + (sRandSeed1 / 30307.0f) + (sRandSeed2 / 30323.0f); + while (rand >= 1.0f) { + rand -= 1.0f; + } + + return fabsf(rand); +} + +/* End of RNG section */ + +// ACTOR_BG_DBLUE_MOVEBG is never spawned naturally on Gyorg's fight +Actor* Boss03_FindActorDblueMovebg(GlobalContext* globalCtx) { + Actor* actor = globalCtx->actorCtx.actorLists[ACTORCAT_BG].first; + + while (actor != NULL) { + if (actor->id == ACTOR_BG_DBLUE_MOVEBG) { + return actor; + } + actor = actor->next; + } + + return NULL; +} + +/* Start of Gyorg's Init and actionFuncs section */ -#if 0 const ActorInit Boss_03_InitVars = { ACTOR_BOSS_03, ACTORCAT_BOSS, @@ -41,157 +290,2350 @@ const ActorInit Boss_03_InitVars = { (ActorFunc)Boss03_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[2] = { -static ColliderJntSphElementInit D_809E8ECC[2] = { +// The limbs referenced here are not used. The spheres are positioned manually by Boss03_PostLimbDraw +static ColliderJntSphElementInit sHeadJntSphElementsInit[] = { { - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x00, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 0, { { 0, 0, 0 }, 70 }, 100 }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x00, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { GYORG_LIMB_NONE, { { 0, 0, 0 }, 70 }, 100 }, }, { - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x00, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 1, { { 0, 0, 0 }, 50 }, 100 }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x00, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { GYORG_LIMB_ROOT, { { 0, 0, 0 }, 50 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_809E8F14 = { - { COLTYPE_HIT3, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 2, D_809E8ECC, // sJntSphElementsInit, +static ColliderJntSphInit sHeadJntSphInit = { + { + COLTYPE_HIT3, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + ARRAY_COUNT(sHeadJntSphElementsInit), + sHeadJntSphElementsInit, }; -// static ColliderJntSphElementInit sJntSphElementsInit[5] = { -static ColliderJntSphElementInit D_809E8F24[5] = { +// The limbs referenced here are not used. The spheres are positioned manually by Boss03_PostLimbDraw +static ColliderJntSphElementInit sBodyJntSphElementsInit[] = { { - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x00, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 2, { { 0, 0, 0 }, 20 }, 100 }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x00, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { GYORG_LIMB_HEAD, { { 0, 0, 0 }, 20 }, 100 }, }, { - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x00, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 5, { { 0, 0, 0 }, 20 }, 100 }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x00, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { GYORG_LIMB_LOWER_TRUNK, { { 0, 0, 0 }, 20 }, 100 }, }, { - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x00, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 6, { { 0, 0, 0 }, 70 }, 100 }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x00, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { GYORG_LIMB_TAIL, { { 0, 0, 0 }, 70 }, 100 }, }, { - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x00, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 7, { { 0, 0, 0 }, 70 }, 100 }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x00, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { GYORG_LIMB_RIGHT_FIN_ROOT, { { 0, 0, 0 }, 70 }, 100 }, }, { - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x00, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 8, { { 0, 0, 0 }, 30 }, 100 }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x00, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { GYORG_LIMB_UPPER_RIGHT_FIN, { { 0, 0, 0 }, 30 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_809E8FD8 = { - { COLTYPE_METAL, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 5, D_809E8F24, // sJntSphElementsInit, +static ColliderJntSphInit sBodyJntSphInit = { + { + COLTYPE_METAL, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + ARRAY_COUNT(sBodyJntSphElementsInit), + sBodyJntSphElementsInit, }; -#endif +Vec3f sGyorgInitialPos = { 1216.0f, 140.0f, -1161.0f }; -extern ColliderJntSphElementInit D_809E8ECC[2]; -extern ColliderJntSphInit D_809E8F14; -extern ColliderJntSphElementInit D_809E8F24[5]; -extern ColliderJntSphInit D_809E8FD8; +// unused +Vec3f D_809E8FF4[] = { + { 261.0f, 140.0f, -1000.0f }, { -504.0f, 120.0f, -1276.0f }, { -1157.0f, 80.0f, -836.0f }, + { -1020.0f, 120.0f, 381.0f }, { -34.0f, 120.0f, 1213.0f }, { 803.0f, 80.0f, 1250.0f }, + { 1143.0f, 120.0f, 605.0f }, { 1228.0f, 140.0f, -244.0f }, { 1216.0f, 140.0f, -1161.0f }, + { 261.0f, 140.0f, -1000.0f }, { -504.0f, 120.0f, -890.0f }, { -1157.0f, 80.0f, -836.0f }, + { -1020.0f, 120.0f, 381.0f }, { -34.0f, 120.0f, 1213.0f }, { 803.0f, 80.0f, 1250.0f }, + { 1143.0f, 120.0f, 605.0f }, { 1228.0f, 140.0f, -244.0f }, { 0.0f, 0.0f, 0.0f }, + { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, + { 0.0f, 0.0f, 0.0f }, +}; -extern UNK_TYPE D_06007EB0; -extern UNK_TYPE D_06007EC8; -extern UNK_TYPE D_06009554; -extern UNK_TYPE D_060099D0; -extern UNK_TYPE D_06009C14; -extern UNK_TYPE D_06009CF8; -extern UNK_TYPE D_0600A6C8; +Color_RGBA8 sGyorgDustPrimColor = { 60, 50, 20, 255 }; +Color_RGBA8 sGyorgDustEnvColor = { 40, 30, 30, 255 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E2760.s") +/** + * Used when chasing Player and Gyorg is near the bottom + */ +void Boss03_SpawnDust(Boss03* this, GlobalContext* globalCtx) { + if (this->insideJawPos.y < 80.0f) { + u8 i; + Vec3f pos; + Vec3f velocity; + Vec3f accel; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E2788.s") + for (i = 0; i < 5; i++) { + velocity.x = randPlusMinusPoint5Scaled(10.0f); + velocity.y = Rand_ZeroFloat(2.0f) + 2.0f; + velocity.z = randPlusMinusPoint5Scaled(10.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E2880.s") + accel.y = -0.075f; + accel.z = 0.0f; + accel.x = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E299C.s") + pos.y = Rand_ZeroFloat(20.0f) + 5.0f; + pos.z = randPlusMinusPoint5Scaled(150.0f) + this->insideJawPos.z; + pos.x = randPlusMinusPoint5Scaled(150.0f) + this->insideJawPos.x; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E2AB4.s") + func_800B0EB0(globalCtx, &pos, &velocity, &accel, &sGyorgDustPrimColor, &sGyorgDustEnvColor, + Rand_ZeroFloat(200.0f) + 400.0f, 10, Rand_ZeroFloat(10.0f) + 25.0f); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E2B8C.s") +void Boss03_Init(Actor* thisx, GlobalContext* globalCtx2) { + Boss03* this = THIS; + s32 i; + GlobalContext* globalCtx = globalCtx2; + Vec3f sp70; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E2C1C.s") + if (gSaveContext.save.weekEventReg[55] & 0x80) { + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DOOR_WARP1, 0.0f, PLATFORM_HEIGHT, + 200.0f, 0, 0, 0, ENDOORWARP1_FF_1); + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_B_HEART, 0.0f, PLATFORM_HEIGHT, 0.0f, 0, 0, 0, 0); + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E2C3C.s") + if (this->actor.params == GYORG_PARAM_SEAWEED) { + this->actor.update = Boss03_SeaweedUpdate; + this->actor.draw = Boss03_SeaweedDraw; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E2D64.s") + this->unk_240 = Rand_ZeroFloat(1000.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E2DA0.s") + this->actor.scale.x = Rand_ZeroFloat(0.0075f) + 0.027f; + this->actor.scale.y = 0.02f; + this->actor.scale.z = 0.015f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/Boss03_Init.s") + // Manually set the joint table of seaweed + for (i = 0; i < 6; i++) { + this->jointTable[i].x = Math_SinS(this->unk_240 * 0x100 + i * 15000) * 3000.0f; + this->jointTable[i].y = Math_SinS(this->unk_240 * 0x180 + i * 20000) * 2000.0f; + this->jointTable[i].z = Math_SinS(this->unk_240 * 0x10 + i * 19000) * 4000.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/Boss03_Destroy.s") + this->actor.flags &= ~ACTOR_FLAG_1; + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E344C.s") + this->actor.world.pos = sGyorgInitialPos; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E34B8.s") + // Since Boss03_RandZeroOne is only used on this Init function, the resulting values end up being deterministic + Boss03_SeedRand(1, 29093, 9786); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E38EC.s") + for (i = 0; i < 5; i++) { + f32 rand; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E3968.s") + rand = Boss03_RandZeroOne(); + Matrix_InsertYRotation_f((rand * M_PI * 0.2f) + ((2.0f * M_PI / 5.0f) * i), MTXMODE_NEW); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E3D34.s") + rand = Boss03_RandZeroOne(); + Matrix_GetStateTranslationAndScaledZ((rand * 800.0f) + 400.0f, &sp70); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E3D98.s") + rand = Boss03_RandZeroOne(); + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BOSS_03, sp70.x, sp70.y, sp70.z, 0, rand * 0x10000, 0, + GYORG_PARAM_SEAWEED); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E4180.s") + sGyorgBossInstance = this; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E421C.s") + globalCtx->specialEffects = sGyorgEffects; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E4674.s") + for (i = 0; i < ARRAY_COUNT(sGyorgEffects); i++) { + sGyorgEffects[i].type = GYORG_EFFECT_NONE; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E475C.s") + this->actor.targetMode = 5; + this->actor.colChkInfo.mass = MASS_HEAVY; + this->actor.colChkInfo.health = 10; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E4910.s") + Collider_InitAndSetJntSph(globalCtx, &this->headCollider, &this->actor, &sHeadJntSphInit, + this->headColliderElements); + Collider_InitAndSetJntSph(globalCtx, &this->bodyCollider, &this->actor, &sBodyJntSphInit, + this->bodyColliderElements); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGyorgSkel, &gGyorgCrawlingAnim, this->jointTable, + this->morphTable, GYORG_LIMB_MAX); + Actor_SetScale(&this->actor, 0.2f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E497C.s") + // gSaveContext.eventInf[5] & 0x40: intro cutscene already watched + if ((KREG(64) != 0) || (gSaveContext.eventInf[5] & 0x40)) { + this->actionFunc = func_809E344C; + D_809E9842 = false; + Audio_QueueSeqCmd(NA_BGM_STOP | 0x10000); + } else { + Boss03_SetupIntroCutscene(this, globalCtx); + D_809E9842 = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E4C34.s") + this->numSpawnedSmallFish = -1; + this->waterHeight = WATER_HEIGHT; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E4C90.s") +void Boss03_Destroy(Actor* thisx, GlobalContext* globalCtx) { + Boss03* this = THIS; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E4E2C.s") +/* Start of ActionFuncs section */ -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E4E80.s") +void func_809E344C(Boss03* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E5ADC.s") + // Mid-air + if (player->actor.world.pos.y < 540.0f) { + this->actionFunc = func_809E34B8; + Animation_MorphToLoop(&this->skelAnime, &gGyorgFastSwimmingAnim, -15.0f); + this->unk_274 = 0; + this->actor.flags |= ACTOR_FLAG_1; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E5B64.s") +/** + * Swims randomly until WORK_TIMER_UNK1_A runs out + */ +void func_809E34B8(Boss03* this, GlobalContext* globalCtx) { + f32 xDiff; + f32 yDiff; + f32 zDiff; + f32 bodyYRotTarget; + s32 pad; + s16 i; + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E65F4.s") + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_WAIT_OLD - SFX_FLAG); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E6640.s") + this->unk_276 = 0x800; + this->skelAnime.playSpeed = 1.0f; + this->unk_27C = 1.0f; + this->unk_278 = 10.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E69A4.s") + SkelAnime_Update(&this->skelAnime); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E6A38.s") + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateY(this->actor.world.rot.y, MTXMODE_APPLY); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E6B70.s") + xDiff = this->unk_268.x - this->actor.world.pos.x; + yDiff = this->unk_268.y - this->actor.world.pos.y; + zDiff = this->unk_268.z - this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E6BC0.s") + Math_ApproachS(&this->actor.world.rot.x, Math_FAtan2F(sqrtf(SQ(xDiff) + SQ(zDiff)), -yDiff), 0xA, this->unk_274); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E6CB4.s") + bodyYRotTarget = + Math_SmoothStepToS(&this->actor.world.rot.y, Math_FAtan2F(zDiff, xDiff), 0xA, this->unk_274, 0) * -0.5f; + Math_ApproachS(&this->bodyYRot, bodyYRotTarget, 5, 0x100); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/Boss03_Update.s") + Math_ApproachS(&this->unk_274, this->unk_276, 1, 0x100); + Math_ApproachF(&this->actor.speedXZ, this->unk_278, 1.0f, this->unk_27C); + Math_ApproachF(&this->unk_260, __sinf(this->skelAnime.curFrame * (M_PI / 5.0f)) * 10.0f * 0.01f, 0.5f, 1.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E7920.s") + if ((this->workTimer[WORK_TIMER_UNK2_A] == 0) && (this->actor.bgCheckFlags & 8)) { + Matrix_GetStateTranslationAndScaledZ(-500.0f, &this->unk_268); + this->unk_268.y = Rand_ZeroFloat(100.0f) + 150.0f; + this->workTimer[WORK_TIMER_UNK2_A] = 60; + this->workTimer[WORK_TIMER_UNK0_A] = Rand_ZeroFloat(60.0f) + 60.0f; + this->unk_274 = 0x100; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E79C4.s") + if (this->workTimer[WORK_TIMER_UNK2_A] == 0) { + if ((sqrtf(SQ(xDiff) + SQ(zDiff)) < 100.0f) || (this->workTimer[WORK_TIMER_UNK0_A] == 0)) { + for (i = 0; i < 200; i++) { + this->unk_268.x = randPlusMinusPoint5Scaled(2500.0f); + this->unk_268.y = Rand_ZeroFloat(100.0f) + 150.0f; + this->unk_268.z = randPlusMinusPoint5Scaled(2500.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E7AA8.s") + xDiff = this->unk_268.x - this->actor.world.pos.x; + zDiff = this->unk_268.z - this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/Boss03_Draw.s") + if (sqrtf(SQ(xDiff) + SQ(zDiff)) > 300.0f) { + break; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E7D00.s") + this->unk_274 = 0x100; + this->workTimer[WORK_TIMER_UNK0_A] = Rand_ZeroFloat(60.0f) + 60.0f; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E81E4.s") + Actor_MoveWithoutGravityReverse(&this->actor); + Math_ApproachS(&this->actor.shape.rot.x, this->actor.world.rot.x, 2, this->unk_274 * 2); + Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 2, this->unk_274 * 2); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E8810.s") + if (this->workTimer[WORK_TIMER_UNK1_A] == 0) { + // Player is above water && Player is standing on ground + if ((this->waterHeight < player->actor.world.pos.y) && (player->actor.bgCheckFlags & 1)) { + Boss03_SetupPrepareCharge(this, globalCtx); + } else if ((player->transformation != PLAYER_FORM_GORON) && (player->transformation != PLAYER_FORM_DEKU)) { + if (KREG(70) == 0) { + Boss03_SetupChasePlayer(this, globalCtx); + } else if (this->numSpawnedSmallFish <= 0) { + Boss03_SetupChasePlayer(this, globalCtx); + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E8BEC.s") +void Boss03_SetupChasePlayer(Boss03* this, GlobalContext* globalCtx) { + this->actionFunc = Boss03_ChasePlayer; + Animation_MorphToLoop(&this->skelAnime, &gGyorgFastSwimmingAnim, -10.0f); + this->workTimer[WORK_TIMER_CURRENT_ACTION] = 100; + this->unk_276 = 0x1000; + this->skelAnime.playSpeed = 1.5f; + this->unk_278 = 10.0f; + this->unk_27C = 1.0f; +} + +/** + * Approach Player until near enough, then try to catch Player, unless it has since got back on the platform + */ +void Boss03_ChasePlayer(Boss03* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 xDiff; + f32 yDiff; + f32 zDiff; + f32 bodyYRotTarget; + Vec3f sp50; + s32 pad; + f32 phi_f2; + f32 sp44; + u8 sp43; + + this->unk_2BD = true; + + SkelAnime_Update(&this->skelAnime); + + xDiff = player->actor.world.pos.x - this->actor.world.pos.x; + yDiff = (player->actor.world.pos.y - this->actor.world.pos.y) + 50.0f; + zDiff = player->actor.world.pos.z - this->actor.world.pos.z; + + Math_ApproachS(&this->actor.world.rot.x, Math_FAtan2F(sqrtf(SQ(xDiff) + SQ(zDiff)), -yDiff), 0xA, this->unk_274); + bodyYRotTarget = + Math_SmoothStepToS(&this->actor.world.rot.y, Math_FAtan2F(zDiff, xDiff), 0xA, this->unk_274, 0) * -0.5f; + Math_ApproachS(&this->bodyYRot, bodyYRotTarget, 5, 0x100); + + Math_ApproachS(&this->unk_274, this->unk_276, 1, 0x100); + Math_ApproachF(&this->actor.speedXZ, this->unk_278, 1.0f, this->unk_27C); + Math_ApproachF(&this->unk_260, __sinf(this->skelAnime.curFrame * (M_PI / 5.0f)) * 10.0f * 0.01f, 0.5f, 1.0f); + Actor_MoveWithoutGravityReverse(&this->actor); + + Math_ApproachS(&this->actor.shape.rot.x, this->actor.world.rot.x, 2, this->unk_274 * 2); + Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 2, this->unk_274 * 2); + + // If either (Player is standing on ground && Player is above water) or (WORK_TIMER_CURRENT_ACTION timer runs out), + // then stop chasing + if (((player->actor.bgCheckFlags & 1) && (player->actor.shape.feetPos[0].y >= WATER_HEIGHT + 8.0f)) || + (this->workTimer[WORK_TIMER_CURRENT_ACTION] == 0)) { + if (&this->actor == player->actor.parent) { + player->unk_AE8 = 101; + player->actor.parent = NULL; + player->csMode = 0; + } + + func_809E344C(this, globalCtx); + this->workTimer[WORK_TIMER_UNK1_A] = 100; + } else { + if ((this->waterHeight - 80.0f) < player->actor.world.pos.y) { + sp43 = 1; + phi_f2 = 100.0f; + sp44 = 50.0f; + } else { + sp43 = 0; + phi_f2 = 200.0f; + sp44 = 100.0f; + } + + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + MTXMODE_NEW); + Matrix_RotateY(this->actor.world.rot.y, MTXMODE_APPLY); + Matrix_GetStateTranslationAndScaledZ(sp44, &sp50); + + xDiff = sp50.x - player->actor.world.pos.x; + zDiff = sp50.z - player->actor.world.pos.z; + + if (sqrtf(SQ(xDiff) + SQ(zDiff)) < (2.0f * phi_f2)) { + Math_ApproachS(&this->jawZRot, 0x3200, 2, 0x1800); + this->unk_278 = 25.0f; + this->unk_27C = 5.0f; + this->skelAnime.playSpeed = 2.5f; + } + + // Near enough to Player? + if (sqrtf(SQ(xDiff) + SQ(zDiff)) < phi_f2) { + Boss03_SetupCatchPlayer(this, globalCtx, sp43); + + if (sp43 != 0) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_WATER_EFFECT, player->actor.world.pos.x, + this->waterHeight, player->actor.world.pos.z, 0, 0, 0x78, ENWATEREFFECT_777); + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_SINK_OLD); + } + + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_UTSUBO_EAT); + } + } + + Boss03_SpawnDust(this, globalCtx); +} + +void Boss03_SetupCatchPlayer(Boss03* this, GlobalContext* globalCtx, u8 arg2) { + this->actionFunc = Boss03_CatchPlayer; + Animation_MorphToLoop(&this->skelAnime, &gGyorgFastSwimmingAnim, -15.0f); + this->workTimer[WORK_TIMER_CURRENT_ACTION] = 100; + this->unk_2C4 = 0.0f; + this->unk_2B8 = 0.0f; + this->unk_242 = arg2; +} + +void Boss03_CatchPlayer(Boss03* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 xDiff; + f32 yDiff; + f32 zDiff; + s32 pad; + + this->skelAnime.playSpeed = 2.0f; + this->unk_27C = 2.0f; + this->unk_276 = 0x1000; + this->unk_2BD = true; + this->unk_278 = 15.0f; + this->actor.flags &= ~ACTOR_FLAG_1; + + SkelAnime_Update(&this->skelAnime); + + xDiff = player->actor.world.pos.x - this->actor.world.pos.x; + yDiff = player->actor.world.pos.y - this->actor.world.pos.y; + zDiff = player->actor.world.pos.z - this->actor.world.pos.z; + + Math_ApproachS(&this->actor.world.rot.x, Math_FAtan2F(sqrtf(SQ(xDiff) + SQ(zDiff)), -yDiff), 0xA, this->unk_274); + Math_ApproachS(&this->bodyYRot, + Math_SmoothStepToS(&this->actor.world.rot.y, Math_FAtan2F(zDiff, xDiff), 0xA, this->unk_274, 0) * + -0.5f, + 5, 0x100); + Math_ApproachS(&this->unk_274, this->unk_276, 1, 0x100); + Math_ApproachF(&this->actor.speedXZ, this->unk_278, 1.0f, this->unk_27C); + Math_ApproachF(&this->unk_260, __sinf(this->skelAnime.curFrame * (M_PI / 5.0f)) * 10.0f * 0.01f, 0.5f, 1.0f); + Actor_MoveWithoutGravityReverse(&this->actor); + Math_ApproachS(&this->actor.shape.rot.x, this->actor.world.rot.x, 2, this->unk_274 * 2); + Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 2, this->unk_274 * 2); + + // If either (Player is standing on ground && Player is above water) or (WORK_TIMER_CURRENT_ACTION timer runs out) + // then stop trying to catch Player + if (((player->actor.bgCheckFlags & 1) && (player->actor.shape.feetPos[FOOT_LEFT].y >= WATER_HEIGHT + 8.0f)) || + (this->workTimer[WORK_TIMER_CURRENT_ACTION] == 0)) { + if (&this->actor == player->actor.parent) { + player->unk_AE8 = 101; + player->actor.parent = NULL; + player->csMode = 0; + func_80165690(); + } + + func_809E344C(this, globalCtx); + // WORK_TIMER_UNK1_A wasn't set + } else { + f32 phi_f0; + + Math_ApproachF(&player->actor.world.pos.x, this->insideJawPos.x, 1.0f, this->unk_2B8); + Math_ApproachF(&player->actor.world.pos.y, this->insideJawPos.y, 1.0f, this->unk_2B8); + Math_ApproachF(&player->actor.world.pos.z, this->insideJawPos.z, 1.0f, this->unk_2B8); + + if (this->unk_242 != 0) { + phi_f0 = 10.0f; + } else { + phi_f0 = 2.0f; + } + + Math_ApproachF(&this->unk_2B8, 100.0f, 1.0f, phi_f0); + + if (this->unk_2B8 > 30.0f) { + if ((&this->actor != player->actor.parent) && (globalCtx->grabPlayer(globalCtx, player) != 0)) { + player->actor.parent = &this->actor; + Audio_PlaySfxGeneral(NA_SE_VO_LI_DAMAGE_S, &player->actor.projectedPos, 4, &D_801DB4B0, &D_801DB4B0, + &D_801DB4B8); + Boss03_SetupChewPlayer(this, globalCtx); + } + } else { + Math_ApproachS(&this->jawZRot, 0x3200, 2, 0xC00 * phi_f0); + } + + Math_ApproachS(&player->actor.world.rot.x, 0x4000, 1, 0x400); + Math_ApproachS(&player->actor.shape.rot.x, 0x4000, 1, 0x400); + Math_ApproachS(&player->actor.world.rot.y, this->unk_2A2.y, 1, 0x400); + Math_ApproachS(&player->actor.shape.rot.y, this->unk_2A2.y, 1, 0x400); + } + + Boss03_SpawnDust(this, globalCtx); +} + +void Boss03_SetupChewPlayer(Boss03* this, GlobalContext* globalCtx) { + s16 pitchAngle; + Vec3f out; + + this->actionFunc = Boss03_ChewPlayer; + + pitchAngle = Math_FAtan2F(this->actor.world.pos.z, this->actor.world.pos.x); + Matrix_RotateY(pitchAngle, MTXMODE_NEW); + + out.x = 0.0f; + out.y = 200.0f; + out.z = 700.0f; + Matrix_MultiplyVector3fByState(&out, &this->unk_268); + + this->unk_276 = 0x800; + this->unk_242 = 0; + this->workTimer[WORK_TIMER_CURRENT_ACTION] = 100; + this->skelAnime.playSpeed = 1.0f; +} + +void Boss03_ChewPlayer(Boss03* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Input* input = CONTROLLER1(globalCtx); + f32 jawZRotTarget; + f32 xDiff; + f32 yDiff; + f32 zDiff; + + this->unk_2BD = true; + this->unk_25C = 15; + + if (this->workTimer[WORK_TIMER_CURRENT_ACTION] == 90) { + func_8016566C(0x96); + } + + SkelAnime_Update(&this->skelAnime); + + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateY(this->actor.world.rot.y, MTXMODE_APPLY); + + xDiff = this->unk_268.x - this->actor.world.pos.x; + yDiff = this->unk_268.y - this->actor.world.pos.y; + zDiff = this->unk_268.z - this->actor.world.pos.z; + + Math_ApproachS(&this->actor.world.rot.x, Math_FAtan2F(sqrtf(SQ(xDiff) + SQ(zDiff)), -yDiff), 0xA, this->unk_274); + Math_ApproachS(&this->bodyYRot, + Math_SmoothStepToS(&this->actor.world.rot.y, Math_FAtan2F(zDiff, xDiff), 0xA, this->unk_274, 0) * + -0.5f, + 5, 0x100); + Math_ApproachS(&this->unk_274, this->unk_276, 1, 0x100); + Math_ApproachF(&this->unk_260, __sinf(this->skelAnime.curFrame * (M_PI / 5.0f)) * 10.0f * 0.01f, 0.5f, 1.0f); + + switch (this->unk_242) { + case 0: + Math_ApproachF(&this->actor.speedXZ, 10.0f, 1.0f, 1.0f); + if (sqrtf(SQ(xDiff) + SQ(zDiff)) < 100.0f) { + this->unk_242 = 1; + Animation_MorphToLoop(&this->skelAnime, &gGyorgBackingUpAnim, -15.0f); + } + break; + + case 1: + Math_ApproachF(&this->actor.speedXZ, 0.0f, 1.0f, 0.5f); + Math_ApproachF(&this->actor.world.pos.y, 200.0f, 0.05f, 5.0f); + break; + } + + Actor_MoveWithoutGravityReverse(&this->actor); + + Math_ApproachS(&this->actor.shape.rot.x, this->actor.world.rot.x, 2, this->unk_274 * 2); + Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 2, this->unk_274 * 2); + + // Mashing A or B reduces the time Gyorg is chewing Player + if (CHECK_BTN_ALL(input->press.button, BTN_A) || CHECK_BTN_ALL(input->press.button, BTN_B)) { + if (this->workTimer[WORK_TIMER_CURRENT_ACTION] != 0) { + this->workTimer[WORK_TIMER_CURRENT_ACTION]--; + } + if (this->workTimer[WORK_TIMER_CURRENT_ACTION] != 0) { + this->workTimer[WORK_TIMER_CURRENT_ACTION]--; + } + } + + // Stop chewing when the timer runs out + if (this->workTimer[WORK_TIMER_CURRENT_ACTION] == 0) { + if (&this->actor == player->actor.parent) { + player->unk_AE8 = 101; + player->actor.parent = NULL; + player->csMode = 0; + func_80165690(); + func_800B8D50(globalCtx, NULL, 10.0f, this->actor.shape.rot.y, 0.0f, 0x20); + } + + func_809E344C(this, globalCtx); + this->workTimer[WORK_TIMER_UNK1_A] = Rand_ZeroFloat(100.0f) + 200.0f; + + return; + } + + player->actor.world.pos = this->insideJawPos; + + jawZRotTarget = Math_SinS(this->unk_240 * 0x2000); + Math_ApproachS(&this->jawZRot, jawZRotTarget * 2000.0f, 2, 0x3000); + + player->actor.shape.rot.x = 0x4000; + player->actor.world.rot.x = player->actor.shape.rot.x; + + player->actor.world.rot.y = player->actor.shape.rot.y = this->unk_2A2.y; + + if (this->workTimer[WORK_TIMER_CURRENT_ACTION] < 5) { + Math_ApproachS(&this->jawZRot, 0x3200, 2, 0x1800); + Math_ApproachF(&this->unk_2C4, 100.0f, 1.0f, 100.0f); + } else { + Math_ApproachF(&this->unk_2C4, -300.0f, 1.0f, 5.0f); + if ((this->unk_240 % 8) == 0) { + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_BITE_OLD); + } + } +} + +void Boss03_SetupPrepareCharge(Boss03* this, GlobalContext* globalCtx) { + this->actionFunc = Boss03_PrepareCharge; + Animation_MorphToLoop(&this->skelAnime, &gGyorgBackingUpAnim, -15.0f); + this->workTimer[WORK_TIMER_CURRENT_ACTION] = Rand_ZeroFloat(30.0f) + 80.0f; + this->workTimer[WORK_TIMER_UNK1_B] = 50; + this->unk_274 = 0; + + if (sqrtf(SQXZ(this->actor.world.pos)) > 600.0f) { + if (Rand_ZeroOne() < 0.5f) { + this->unk_242 = 1; + } else { + this->unk_242 = 0; + } + } else { + this->unk_242 = 0; + } +} + +/** + * Slowly turns back while looking at Player during WORK_TIMER_CURRENT_ACTION frames, then prepares to charge + */ +void Boss03_PrepareCharge(Boss03* this, GlobalContext* globalCtx) { + f32 posYTarget; + Player* player = GET_PLAYER(globalCtx); + + if (this->workTimer[WORK_TIMER_UNK1_B] != 0) { + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_WAIT_OLD - SFX_FLAG); + } + + // Rotate towards Player + Math_ApproachS(&this->bodyYRot, + Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 0xA, this->unk_274, 0) * + -0.7f, + 5, 0x200); + Math_ApproachS(&this->unk_274, 0x800, 1, 0x100); + Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 2, 0x1000); + Math_ApproachS(&this->actor.world.rot.x, 0, 0xA, 0x200); + Math_ApproachS(&this->actor.shape.rot.x, 0, 0xA, 0x200); + + posYTarget = this->waterHeight - 70.0f; + if (posYTarget < this->actor.world.pos.y) { + Math_ApproachF(&this->actor.world.pos.y, posYTarget, 0.05f, 5.0f); + } + + SkelAnime_Update(&this->skelAnime); + + // Player is above water && Player is standing on ground + if ((this->waterHeight < player->actor.world.pos.y) && (player->actor.bgCheckFlags & 1)) { + if (this->workTimer[WORK_TIMER_CURRENT_ACTION] == 0) { + Boss03_SetupCharge(this, globalCtx); + } + } else if (player->actor.world.pos.y <= this->waterHeight) { + func_809E344C(this, globalCtx); + this->workTimer[WORK_TIMER_UNK1_A] = 20; + } + + // Turns back slowly + Math_ApproachF(&this->actor.speedXZ, -3.0f, 1.0f, 0.5f); + Actor_MoveWithoutGravityReverse(&this->actor); +} + +void Boss03_SetupCharge(Boss03* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + this->actionFunc = Boss03_Charge; + Animation_MorphToLoop(&this->skelAnime, &gGyorgFastSwimmingAnim, -15.0f); + this->unk_268 = player->actor.world.pos; +} + +/** + * Charge against the platform, either by clashing against the platform or by preparing to jump over it + */ +void Boss03_Charge(Boss03* this, GlobalContext* globalCtx) { + f32 xDiff; + f32 yDiff; + f32 zDiff; + Player* player = GET_PLAYER(globalCtx); + s16 rotXTarget; + + this->skelAnime.playSpeed = 2.0f; + SkelAnime_Update(&this->skelAnime); + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_PREATTACK_OLD - SFX_FLAG); + + xDiff = this->unk_268.x - this->actor.world.pos.x; + yDiff = (this->unk_268.y - this->actor.world.pos.y) - 50.0f; + zDiff = this->unk_268.z - this->actor.world.pos.z; + + Math_ApproachS(&this->actor.world.rot.y, Math_FAtan2F(zDiff, xDiff), 0xA, 0x1000); + + rotXTarget = Math_FAtan2F(sqrtf(SQ(xDiff) + SQ(zDiff)), -yDiff); + Math_ApproachS(&this->actor.world.rot.x, rotXTarget, 0xA, 0x1000); + + this->actor.shape.rot = this->actor.world.rot; + + Math_ApproachF(&this->actor.speedXZ, 25.0f, 1.0f, 3.0f); + Math_ApproachF(&this->unk_260, __sinf(this->skelAnime.curFrame * (M_PI / 5.0f)) * 10.0f * 0.01f, 0.5f, 1.0f); + Actor_MoveWithoutGravityReverse(&this->actor); + + if (this->actor.speedXZ >= 20.0f) { + // Jump over platform + if (this->unk_242 == 1) { + if (sqrtf(SQXZ(this->actor.world.pos)) < 700.0f) { + Boss03_SetupJumpOverPlatform(this, globalCtx); + return; + } + } + + // Attack platform + if (this->actor.bgCheckFlags & 8) { + play_sound(NA_SE_IT_BIG_BOMB_EXPLOSION); + func_800BC848(&this->actor, globalCtx, 20, 15); + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_WATER_EFFECT, 0.0f, this->waterHeight, 0.0f, 0, 0, + 0x96, ENWATEREFFECT_780); + + // Player is above water && Player is standing on ground + if ((this->waterHeight < player->actor.world.pos.y) && (player->actor.bgCheckFlags & 1)) { + func_800B8D50(globalCtx, NULL, 7.0f, Math_FAtan2F(player->actor.world.pos.z, player->actor.world.pos.x), + 7.0f, 0); + } + + func_809E344C(this, globalCtx); + this->workTimer[WORK_TIMER_UNK1_A] = 50; + } + } +} + +void Boss03_SetupJumpOverPlatform(Boss03* this, GlobalContext* globalCtx) { + this->actionFunc = Boss03_JumpOverPlatform; + this->actor.gravity = -2.0f; + this->actor.velocity.y = 30.0f; + this->actor.speedXZ = 25.0f; + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_JUMP_OLD); +} + +void Boss03_JumpOverPlatform(Boss03* this, GlobalContext* globalCtx) { + this->bubbleEffectSpawnCount = 0; + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_JUMP_LEV_OLD - SFX_FLAG); + + this->skelAnime.playSpeed = 2.0f; + SkelAnime_Update(&this->skelAnime); + + Math_ApproachS(&this->actor.world.rot.x, this->actor.velocity.y * -300.0f, 2, 0x2000); + this->actor.shape.rot.x = this->actor.world.rot.x; + + Actor_MoveWithGravity(&this->actor); + if ((this->actor.velocity.y < 0.0f) && (this->actor.world.pos.y < this->waterHeight + 50.0f)) { + this->bubbleEffectSpawnCount = 2; + this->actor.gravity = 0.0f; + Math_ApproachZeroF(&this->actor.velocity.y, 1.0f, 1.0f); + if (this->actor.velocity.y == 0.0f) { + func_809E344C(this, globalCtx); + this->workTimer[WORK_TIMER_UNK1_A] = 50; + } + } else { + s16 i; + Vec3f sp30; + + for (i = 0; i < 3; i++) { + sp30.x = this->actor.world.pos.x + randPlusMinusPoint5Scaled(150.0f); + sp30.y = this->actor.world.pos.y; + sp30.z = this->actor.world.pos.z + randPlusMinusPoint5Scaled(150.0f); + Boss03_SpawnEffectDroplet(globalCtx, &sp30); + } + } +} + +/* End of Gyorg's Init and actionFuncs section */ + +/* Start of Gyorg's Cutscenes section */ + +void Boss03_SetupIntroCutscene(Boss03* this, GlobalContext* globalCtx) { + this->actionFunc = Boss03_IntroCutscene; + Animation_MorphToLoop(&this->skelAnime, &gGyorgFastSwimmingAnim, -10.0f); + this->skelAnime.playSpeed = 2.0f; +} + +Vec3f D_809E9104[] = { + { 770.0f, 200.0f, 720.0f }, + { 831.0f, 200.0f, -570.0f }, + { 0.0f, 450.0f, 0.0f }, +}; + +void Boss03_IntroCutscene(Boss03* this, GlobalContext* globalCtx) { + s16 i; + Vec3f effectPos; + f32 xDiff; + f32 yDiff; + f32 zDiff; + s32 pad; + f32 sp5C; + s16 sp5A; + s16 pad2; + s16 bubblesToSpawnNum = 0; + f32 phi_f2; + Player* player = GET_PLAYER(globalCtx); + + this->bubbleEffectSpawnCount = 0; + this->csTimer++; + this->unk_290 = 0; + + sp5A = 0x4BC; + + switch (this->csState) { + case 0: + if (player->actor.world.pos.y < 1350.0f) { + Cutscene_Start(globalCtx, &globalCtx->csCtx); + func_800B7298(globalCtx, &this->actor, 7); + this->csCamId = Play_CreateSubCamera(globalCtx); + Play_CameraChangeStatus(globalCtx, CAM_ID_MAIN, 1); + Play_CameraChangeStatus(globalCtx, this->csCamId, 7); + + this->actor.world.rot.y = -0x7B30; + this->prevPlayerPos.y = 1850.0f; + + this->actor.world.pos.x = 1400.0f; + this->actor.world.pos.y = 130.0f; + this->actor.world.pos.z = 1400.0f; + + player->actor.shape.rot.y = 0; + player->actor.world.pos.y = 1850.0f; + player->actor.world.rot.y = player->actor.shape.rot.y; + + this->csCamAt.y = player->actor.world.pos.y + 30.0f; + this->csState = 1; + this->csTimer = 0; + this->actor.flags &= ~ACTOR_FLAG_1; + this->unk_2D5 = true; + + this->cameraFov = KREG(14) + 60.0f; + + case 1: + player->actor.world.pos.z = 0.0f; + player->actor.world.pos.x = 0.0f; + player->actor.speedXZ = 0.0f; + + this->csCamEye.x = 100.0f; + this->csCamEye.y = 540.0f; + + this->csCamEye.z = player->actor.world.pos.z + 100.0f; + this->csCamAt.x = player->actor.world.pos.x; + + Math_ApproachF(&this->csCamAt.y, player->actor.world.pos.y + 30.0f, 0.5f, 100.0f); + this->csCamAt.z = player->actor.world.pos.z; + + if (this->csTimer > 105) { + this->csState = 2; + this->csTimer = 0; + this->unk_240 = 0; + func_8016566C(0x96); + this->cameraFov = 80.0f; + + case 2: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KONB_DEMO_MOVE_OLD - SFX_FLAG); + + xDiff = D_809E9104[this->unk_242].x - this->actor.world.pos.x; + yDiff = D_809E9104[this->unk_242].y - this->actor.world.pos.y; + zDiff = D_809E9104[this->unk_242].z - this->actor.world.pos.z; + + Math_ApproachS(&this->actor.world.rot.x, Math_FAtan2F(sqrtf(SQ(xDiff) + SQ(zDiff)), -yDiff), + 0xA, this->unk_274); + Math_ApproachS(&this->actor.world.rot.y, Math_FAtan2F(zDiff, xDiff), 0xA, this->unk_274); + Math_ApproachS(&this->unk_274, 0x200, 1, 0x10); + + if ((this->csTimer > 30) && (this->csTimer < 50)) { + bubblesToSpawnNum = 2; + } + + if ((this->csTimer == 40) || (this->csTimer == (u32)(KREG(91) + 270))) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_WATER_DEEP); + } + + if (this->csTimer > 50) { + Math_ApproachF(&this->actor.speedXZ, this->unk_278, 1.0f, 0.1f); + } + + if (this->unk_242 < 2) { + if (sqrtf(SQ(xDiff) + SQ(zDiff)) < 100.0f) { + this->unk_242++; + this->unk_274 = 0; + if (this->unk_242 >= 2) { + this->csTimer = 100; + } + } + this->unk_278 = 5.0f; + } else { + this->unk_278 = 0.0f; + bubblesToSpawnNum = 1; + if ((this->actor.speedXZ == 0.0f) && (this->csTimer > 230)) { + this->csState = 3; + this->csTimer = 0; + } + if (this->csTimer == 165) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_WATER_MID); + } + if (this->csTimer == 180) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_WATER_DEEP); + } + } + } + } + break; + + case 3: + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_PREATTACK_OLD - SFX_FLAG); + sp5A = 0x1970; + Math_ApproachF(&this->actor.speedXZ, 15.0f, 1.0f, 2.0f); + if (this->csTimer > 20) { + this->csState = 4; + this->csTimer = 0; + } + break; + + case 4: + player->actor.world.rot.y = player->actor.shape.rot.y = 0; + + if (this->csTimer == 5) { + // Rotates Player towards Gyorg + func_800B7298(globalCtx, &this->actor, 8); + } + + this->csCamEye.x = player->actor.world.pos.x + 30.0f; + this->csCamEye.y = player->actor.world.pos.y + Player_GetHeight(player) - 4.0f + BREG(17); + this->csCamEye.z = player->actor.world.pos.z - 30.0f; + + this->csCamAt.x = player->actor.world.pos.x; + this->csCamAt.y = player->actor.world.pos.y + Player_GetHeight(player) - 18.0f + 6.0f + BREG(18); + this->csCamAt.z = player->actor.world.pos.z; + + if (player->transformation == PLAYER_FORM_FIERCE_DEITY) { + this->csCamEye.y -= 60.0f; + this->csCamAt.y -= 35.0f; + } + + this->cameraFov = 60.0f; + if (this->csTimer == 16) { + this->csState = 5; + this->csTimer = 0; + this->unk_2D5 = false; + this->actor.speedXZ = -200.0f; + Actor_MoveWithoutGravityReverse(&this->actor); + this->actor.world.pos.y = this->waterHeight - 150.0f; + func_80165690(); + + case 5: + SkelAnime_Update(&this->skelAnime); + this->actor.speedXZ = 20.0f; + Actor_MoveWithoutGravityReverse(&this->actor); + player->actor.shape.rot.y = -0x1470; + player->actor.world.rot.y = player->actor.shape.rot.y; + + this->csCamEye.x = player->actor.world.pos.x + 30.0f - 90.0f + 300.0f; + this->csCamEye.y = player->actor.world.pos.y + 40.0f + 10.0f; + this->csCamEye.z = player->actor.world.pos.z - 30.0f + 160.0f + 300.0f; + + this->csCamAt.x = this->actor.world.pos.x; + this->csCamAt.y = this->actor.world.pos.y - 100.0f; + this->csCamAt.z = this->actor.world.pos.z; + + if (this->csTimer == 10) { + this->actor.velocity.y = 30.0f; + this->csState = 6; + this->csTimer = 0; + this->actor.gravity = -1.5f; + this->actor.speedXZ = 20.0f; + + Audio_QueueSeqCmd(NA_BGM_BOSS | 0x8000); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KONB_JUMP_OLD); + this->skelAnime.playSpeed = 1.0f; + } + } + break; + + case 6: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KONB_JUMP_LEV_OLD - SFX_FLAG); + + if (this->csTimer == 30) { + TitleCard_InitBossName(&globalCtx->state, &globalCtx->actorCtx.titleCtxt, + Lib_SegmentedToVirtual(gGyorgTitleCardTex), 160, 180, 128, 40); + } + + if ((this->csTimer < 24) || (this->csTimer >= 90)) { + SkelAnime_Update(&this->skelAnime); + Math_ApproachS(&this->actor.world.rot.x, this->actor.velocity.y * -300.0f, 3, 0x1000); + Actor_MoveWithGravity(&this->actor); + if ((this->actor.velocity.y <= 0.0f) && (this->actor.world.pos.y < (this->waterHeight + 50.0f))) { + this->bubbleEffectSpawnCount = 2; + this->actor.gravity = 0.0f; + Math_ApproachZeroF(&this->actor.velocity.y, 1.0f, 1.0f); + Math_ApproachZeroF(&this->actor.speedXZ, 1.0f, 0.5f); + } else { + if (1) {} + if (1) {} + if (1) {} + + for (i = 0; i < 3; i++) { + effectPos.x = randPlusMinusPoint5Scaled(150.0f) + this->actor.world.pos.x; + effectPos.y = this->actor.world.pos.y; + effectPos.z = randPlusMinusPoint5Scaled(150.0f) + this->actor.world.pos.z; + + Boss03_SpawnEffectDroplet(globalCtx, &effectPos); + } + + this->csCamTargetAt.x = this->actor.world.pos.x; + this->csCamTargetAt.y = this->actor.world.pos.y - 100.0f; + this->csCamTargetAt.z = this->actor.world.pos.z; + } + } else { + Math_ApproachF(&this->csCamEye.x, player->actor.world.pos.x + 30.0f - 90.0f + 300.0f - 90.0f, 0.05f, + 3.0f); + Math_ApproachF(&this->csCamEye.y, player->actor.world.pos.y + 40.0f + 10.0f + 90.0f, 0.05f, 3.0f); + Math_ApproachF(&this->csCamEye.z, player->actor.world.pos.z - 30.0f + 160.0f + 300.0f - 90.0f, 0.05f, + 3.0f); + Math_ApproachF(&this->unk_568, 90.0f, 0.05f, 3.0f); + } + + Math_ApproachF(&this->csCamAt.x, this->csCamTargetAt.x, 0.5f, 100.0f); + Math_ApproachF(&this->csCamAt.y, this->csCamTargetAt.y + this->unk_568, 0.5f, 100.0f); + Math_ApproachF(&this->csCamAt.z, this->csCamTargetAt.z, 0.5f, 100.0f); + + if (this->csTimer == 145) { + Camera* camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); + + camera->eye = this->csCamEye; + camera->eyeNext = this->csCamEye; + camera->at = this->csCamAt; + + func_80169AFC(globalCtx, this->csCamId, 0); + Cutscene_End(globalCtx, &globalCtx->csCtx); + func_800B7298(globalCtx, &this->actor, 6); + this->csCamId = 0; + + func_809E344C(this, globalCtx); + this->workTimer[WORK_TIMER_UNK1_A] = 50; + + gSaveContext.eventInf[5] |= 0x40; + } + break; + } + + this->actor.shape.rot = this->actor.world.rot; + + if ((this->csState == 2) || (this->csState == 3)) { + Actor_MoveWithoutGravityReverse(&this->actor); + + phi_f2 = this->actor.speedXZ * 0.02f; + phi_f2 = CLAMP_MAX(phi_f2, 0.12f); + + sp5C = Math_SinS(this->unk_240 * sp5A) * phi_f2; + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + MTXMODE_NEW); + Matrix_RotateY(this->actor.world.rot.y, MTXMODE_APPLY); + Matrix_InsertYRotation_f(sp5C, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->actor.world.rot.x, MTXMODE_APPLY); + Matrix_GetStateTranslationAndScaledZ(100.0f, &this->csCamAt); + + this->csCamEye = this->actor.world.pos; + + for (i = 0; i < bubblesToSpawnNum; i++) { + effectPos.x = randPlusMinusPoint5Scaled(100.0f) + this->csCamAt.x; + effectPos.y = (randPlusMinusPoint5Scaled(100.0f) + this->csCamAt.y) - 150.0f; + effectPos.z = randPlusMinusPoint5Scaled(100.0f) + this->csCamAt.z; + + Boss03_SpawnEffectBubble(globalCtx, &effectPos); + } + } + + if (this->csCamId != 0) { + Play_CameraSetAtEye(globalCtx, this->csCamId, &this->csCamAt, &this->csCamEye); + Play_CameraSetFov(globalCtx, this->csCamId, this->cameraFov); + } +} + +void Boss03_SetupDeathCutscene(Boss03* this, GlobalContext* globalCtx) { + this->actionFunc = Boss03_DeathCutscene; + Animation_MorphToLoop(&this->skelAnime, &gGyorgFloppingAnim, -10.0f); + this->floppingAnimLastFrame = Animation_GetLastFrame(&gGyorgFloppingAnim); + Audio_QueueSeqCmd(NA_BGM_STOP | 0x10000); + this->workTimer[WORK_TIMER_UNK0_C] = 0; + this->unk_242 = 0; + this->csState = 0; + this->actor.flags &= ~ACTOR_FLAG_1; +} + +void Boss03_DeathCutscene(Boss03* this, GlobalContext* globalCtx) { + s16 i; + Vec3f sp90; + Vec3f sp84; + Vec3f sp78; + f32 aux; + f32 aux2; + s32 pad; + f32 pad2; + f32 sp64; + Camera* camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); + Player* player; + f32 sp4C; + + aux2 = 0.0f; + player = GET_PLAYER(globalCtx); + sp64 = this->actor.scale.x * 5.0f; + + this->csTimer++; + + switch (this->csState) { + case 0: + if (ActorCutscene_GetCurrentIndex() == -1) { + Cutscene_Start(globalCtx, &globalCtx->csCtx); + func_800B7298(globalCtx, &this->actor, 1); + this->csCamId = Play_CreateSubCamera(globalCtx); + Play_CameraChangeStatus(globalCtx, CAM_ID_MAIN, 1); + Play_CameraChangeStatus(globalCtx, this->csCamId, 7); + this->unk_2BE = Math_FAtan2F(this->actor.world.pos.z, this->actor.world.pos.x); + + // Player is above water && Player is standing on ground + if ((this->waterHeight < player->actor.world.pos.y) && (player->actor.bgCheckFlags & 1)) { + player->actor.world.pos.x = 0.0f; + player->actor.world.pos.z = -200.0f; + } + + case 1: + this->csTimer = 0; + this->csState = 2; + this->csCamEye.x = camera->eye.x; + this->csCamEye.y = camera->eye.y; + this->csCamEye.z = camera->eye.z; + this->csCamAt.x = camera->at.x; + this->csCamAt.y = camera->at.y; + this->csCamAt.z = camera->at.z; + + aux = this->csCamEye.x - this->actor.world.pos.x; + this->unk_568 = Math_Acot2F(this->csCamEye.z - this->actor.world.pos.z, aux); + + this->unk_570 = 0.0f; + this->unk_56C = 0.0f; + + case 2: + sp90.x = 0.0f; + sp90.y = (50.0f * sp64) + 150.0f; + sp90.z = (400.0f * sp64) + 300.0f; + + this->csCamTargetAt.x = this->actor.world.pos.x; + this->csCamTargetAt.y = this->actor.world.pos.y; + this->csCamTargetAt.z = this->actor.world.pos.z; + + this->unk_568 += this->unk_56C; + Matrix_InsertYRotation_f(this->unk_568, MTXMODE_NEW); + Matrix_MultiplyVector3fByState(&sp90, &this->csCamTargetEye); + + this->csCamTargetEye.x += this->actor.world.pos.x; + this->csCamTargetEye.y += this->waterHeight; + this->csCamTargetEye.z += this->actor.world.pos.z; + + sp4C = 40.0f + aux2; + Math_ApproachF(&this->csCamEye.x, this->csCamTargetEye.x, 0.1f, sp4C); + Math_ApproachF(&this->csCamEye.y, this->csCamTargetEye.y, 0.1f, sp4C); + Math_ApproachF(&this->csCamEye.z, this->csCamTargetEye.z, 0.1f, sp4C); + sp4C = 70.0f + aux2; + Math_ApproachF(&this->csCamAt.x, this->csCamTargetAt.x, 0.1f, sp4C); + Math_ApproachF(&this->csCamAt.y, this->csCamTargetAt.y, 0.1f, sp4C); + Math_ApproachF(&this->csCamAt.z, this->csCamTargetAt.z, 0.1f, sp4C); + } + break; + } + + SkelAnime_Update(&this->skelAnime); + + switch (this->unk_242) { + case 0: + Math_ApproachF(&this->actor.world.pos.y, Math_SinS(this->unk_240 * 0x1000) * 80.0f + this->waterHeight, + 1.0f, 10.0f); + this->actor.shape.rot.z += 0x100; + Matrix_RotateY(this->unk_2BE, MTXMODE_NEW); + Matrix_GetStateTranslationAndScaledZ(500.0f, &sp84); + Math_ApproachF(&this->actor.world.pos.x, sp84.x, 0.1f, 5.0f); + Math_ApproachF(&this->actor.world.pos.z, sp84.z, 0.1f, 5.0f); + + if (Animation_OnFrame(&this->skelAnime, this->floppingAnimLastFrame)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KONB_DEAD_JUMP2_OLD); + } + if (Animation_OnFrame(&this->skelAnime, this->floppingAnimLastFrame * 0.5f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KONB_DEAD_JUMP_OLD); + } + + if ((this->workTimer[WORK_TIMER_UNK0_C] == 0) && ((this->waterHeight - 100.0f) < this->actor.world.pos.y)) { + this->workTimer[WORK_TIMER_UNK0_C] = Rand_ZeroFloat(15.0f) + 15.0f; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_WATER_EFFECT, this->actor.world.pos.x, + this->waterHeight, this->actor.world.pos.z, 0, 0, 0x78, ENWATEREFFECT_777); + + if (this->actionFunc == Boss03_DeathCutscene) { + if ((D_809E9840 % 2) != 0) { + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_JUMP_OLD); + } else { + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_SINK_OLD); + } + D_809E9840++; + } + + this->unk_284 = this->actor.world.pos.x; + this->unk_288 = this->waterHeight; + this->unk_28C = this->actor.world.pos.z; + + this->unk_280 = 27; + if ((fabsf(this->actor.world.pos.x - sp84.x) < 5.0f) && + (fabsf(this->actor.world.pos.z - sp84.z) < 5.0f)) { + this->unk_242 = 1; + this->actor.gravity = -2.0f; + this->actor.velocity.y = 25.0f; + this->actor.speedXZ = 10.0f; + this->actor.world.rot.y = this->unk_2BE + 0x8000; + this->unk_240 = 0; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KONB_DEAD_JUMP2_OLD); + } + } + Math_ApproachF(&this->unk_56C, 0.01f, 1.0f, 0.0005f); + break; + + case 1: + if (this->unk_240 == 0x96) { + Audio_QueueSeqCmd(NA_BGM_CLEAR_BOSS | 0x8000); + } + Math_ApproachF(&this->unk_56C, 0.01f, 1.0f, 0.0005f); + Math_ApproachF(&this->actor.scale.x, 0.01f, 0.05f, 0.001f); + Actor_SetScale(&this->actor, this->actor.scale.x); + + if (this->actor.velocity.y < 0.0f) { + if (this->actor.world.pos.y < PLATFORM_HEIGHT + (100.0f * sp64)) { + this->actor.world.pos.y = PLATFORM_HEIGHT + (100.0f * sp64); + this->actor.velocity.y = ((Rand_ZeroFloat(10.0f) + 7.5f) * sp64) + 7.5f; + this->actor.speedXZ = ((Rand_ZeroFloat(5.0f) + 2.5f) * sp64) + 2.5f; + + if (Rand_ZeroOne() < 0.5f) { + this->shapeRotTargetX = + ((s16)randPlusMinusPoint5Scaled(500.0f) + this->shapeRotTargetX) + 0x8000; + } + + if (Rand_ZeroOne() < 0.5f) { + this->shapeRotTargetZ = + ((s16)randPlusMinusPoint5Scaled(500.0f) + this->shapeRotTargetZ) + 0x8000; + } + + if (Rand_ZeroOne() < 0.5f) { + this->shapeRotTargetY = Rand_ZeroFloat(65536.0f); + } + + this->actor.world.rot.y = Math_FAtan2F(-this->actor.world.pos.z, -this->actor.world.pos.x); + + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_BOUND_OLD); + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_BOUND2_OLD); + } + } + + Math_ApproachS(&this->actor.shape.rot.y, this->shapeRotTargetY, 3, 0x500); + Math_ApproachS(&this->actor.shape.rot.x, this->shapeRotTargetX, 3, 0xA00); + Math_ApproachS(&this->actor.shape.rot.z, this->shapeRotTargetZ, 3, 0xA00); + + sp4C = 150.0f * sp64; + + for (i = 0; i < 1; i++) { + sp78.x = randPlusMinusPoint5Scaled(sp4C) + this->actor.world.pos.x; + sp78.y = this->actor.world.pos.y; + sp78.z = randPlusMinusPoint5Scaled(sp4C) + this->actor.world.pos.z; + Boss03_SpawnEffectDroplet(globalCtx, &sp78); + } + + Actor_MoveWithGravity(&this->actor); + if (this->actor.scale.x <= 0.0111f) { + this->unk_242 = 2; + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DOOR_WARP1, 0.0f, + PLATFORM_HEIGHT, 200.0f, 0, 0, 0, ENDOORWARP1_FF_1); + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_B_HEART, this->actor.focus.pos.x, + PLATFORM_HEIGHT, this->actor.focus.pos.z, 0, 0, 0, 0); + this->csTimer = 0; + Actor_SetScale(&this->actor, 0.0f); + Audio_StopSfxByPos(&this->actor.projectedPos); + } + break; + + case 2: + Math_ApproachZeroF(&this->unk_56C, 1.0f, 0.0005f); + if (this->csTimer == 60) { + camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); + camera->eye = this->csCamEye; + camera->eyeNext = this->csCamEye; + camera->at = this->csCamAt; + func_80169AFC(globalCtx, this->csCamId, 0); + this->csCamId = 0; + Cutscene_End(globalCtx, &globalCtx->csCtx); + func_800B7298(globalCtx, &this->actor, 6); + this->csState = 3; + func_80165690(); + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_INIT_OLD); + Boss03_PlayUnderwaterSfx(&D_809E9848, NA_SE_EN_KONB_INIT_OLD); + } + break; + + case 3: + this->actor.world.pos.y = 5000.0f; + break; + } + + if (this->csCamId != 0) { + Play_CameraSetAtEye(globalCtx, this->csCamId, &this->csCamAt, &this->csCamEye); + } +} + +void Boss03_SetupSpawnSmallFishesCutscene(Boss03* this, GlobalContext* globalCtx) { + this->actionFunc = Boss03_SpawnSmallFishesCutscene; + Animation_MorphToLoop(&this->skelAnime, &gGyorgBackingUpAnim, -15.0f); + this->csState = 0; + this->csTimer = 0; +} + +void Boss03_SpawnSmallFishesCutscene(Boss03* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + SkelAnime_Update(&this->skelAnime); + this->csTimer++; + switch (this->csState) { + case 0: + if (ActorCutscene_GetCurrentIndex() == -1) { + Cutscene_Start(globalCtx, &globalCtx->csCtx); + func_800B7298(globalCtx, &this->actor, 1); + this->csCamId = Play_CreateSubCamera(globalCtx); + Play_CameraChangeStatus(globalCtx, CAM_ID_MAIN, 1); + Play_CameraChangeStatus(globalCtx, this->csCamId, 7); + this->csState = 1; + this->unk_2BE = 0xBB8; + + case 1: + if (player->actor.world.pos.y < 437.0f) { + player->actor.world.pos.z = 500.0f; + player->actor.world.pos.x = 500.0f; + } + + this->actor.shape.rot.z = 0; + this->actor.world.pos.z = 1000.0f; + this->actor.world.pos.x = 1000.0f; + this->actor.world.pos.y = 200.0f; + this->actor.shape.rot.x = this->actor.shape.rot.z; + + this->actor.shape.rot.y = this->actor.world.rot.y = + Math_FAtan2F(-this->actor.world.pos.x, -this->actor.world.pos.x); + this->unk_260 = 0.0f; + + player->actor.shape.rot.y = player->actor.world.rot.y = this->actor.world.rot.y + 0x8000; + + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + MTXMODE_NEW); + Matrix_RotateY(this->actor.shape.rot.y + this->unk_2BE, MTXMODE_APPLY); + Matrix_GetStateTranslationAndScaledZ(340.0f, &this->csCamEye); + + this->csCamAt.x = this->actor.world.pos.x; + this->csCamAt.y = this->actor.world.pos.y; + this->csCamAt.z = this->actor.world.pos.z; + + Math_ApproachS(&this->unk_2BE, -4000, 10, 70); + + if (this->csTimer >= 61) { + Math_ApproachS(&this->jawZRot, 0x3200, 5, 0x500); + if ((this->csTimer >= 90) && (this->csTimer < 130)) { + if ((this->csTimer % 2) != 0) { + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_TANRON3, + this->actor.world.pos.x - 110.0f, this->actor.world.pos.y - 20.0f, + this->actor.world.pos.z - 110.0f, 0, this->actor.shape.rot.y, 0, 0); + this->numSpawnedSmallFish++; + } + if ((this->csTimer % 8) == 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KONB_MINI_APPEAR); + } + } + } + + if (this->csTimer >= 150) { + Camera* camera; + + camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); + camera->eye = this->csCamEye; + camera->eyeNext = this->csCamEye; + camera->at = this->csCamAt; + + func_80169AFC(globalCtx, this->csCamId, 0); + this->csCamId = 0; + Cutscene_End(globalCtx, &globalCtx->csCtx); + func_800B7298(globalCtx, &this->actor, 6); + + func_809E344C(this, globalCtx); + this->workTimer[WORK_TIMER_UNK1_A] = 50; + } + } + break; + } + + if (this->csCamId != 0) { + Play_CameraSetAtEye(globalCtx, this->csCamId, &this->csCamAt, &this->csCamEye); + } +} + +/* End of Gyorg's Cutscenes section */ + +/* Start of Gyorg's More actionFuncs and Update section */ + +void Boss03_SetupStunned(Boss03* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (this->actionFunc != Boss03_Stunned) { + Animation_MorphToLoop(&this->skelAnime, &gGyorgStunnedAnim, -15.0f); + this->workTimer[WORK_TIMER_STUNNED] = 200; + this->actionFunc = Boss03_Stunned; + } + + if (&this->actor == player->actor.parent) { + player->unk_AE8 = 101; + player->actor.parent = NULL; + player->csMode = 0; + func_80165690(); + } + + this->unk_240 = 0; +} + +void Boss03_Stunned(Boss03* this, GlobalContext* globalCtx) { + this->actor.hintId = 0x29; + + if (this->unk_240 >= 16) { + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_COMMON_WEAKENED - SFX_FLAG); + } + + SkelAnime_Update(&this->skelAnime); + + if ((this->waterHeight + 30.0f) < this->actor.world.pos.y) { + this->actor.gravity = -2.0f; + Actor_MoveWithGravity(&this->actor); + if (this->actor.bgCheckFlags & 2) { + play_sound(NA_SE_IT_WALL_HIT_HARD); + func_800BC848(&this->actor, globalCtx, 10, 10); + } + } else { + Math_ApproachS(&this->actor.shape.rot.z, -0x6000, 0xA, 0x900); + Math_ApproachS(&this->actor.world.rot.x, 0x800, 0xA, 0x1000); + this->actor.shape.rot.x = this->actor.world.rot.x; + + Math_ApproachF(&this->actor.world.pos.y, 100.0f, 0.05f, 5.0f); + Math_ApproachF(&this->actor.speedXZ, 0.0f, 1.0f, 1.5f); + Actor_MoveWithoutGravityReverse(&this->actor); + } + + if (this->workTimer[WORK_TIMER_STUNNED] == 0) { + func_809E344C(this, globalCtx); + // WORK_TIMER_UNK1_A wasn't set + } +} + +void Boss03_SetupDamaged(Boss03* this, GlobalContext* globalCtx) { + Animation_MorphToLoop(&this->skelAnime, &gGyorgFloppingAnim, -10.0f); + this->actionFunc = Boss03_Damaged; + this->workTimer[WORK_TIMER_CURRENT_ACTION] = 30; +} + +/** + * Invulnerability period by being damaged by Player + */ +void Boss03_Damaged(Boss03* this, GlobalContext* globalCtx) { + this->unk_25C = 15; + + SkelAnime_Update(&this->skelAnime); + + Math_ApproachS(&this->jawZRot, ((Math_SinS(this->unk_240 * 0x2000) * 3000.0f) + 0x3000), 2, 0x3000); + Math_ApproachF(&this->actor.world.pos.y, 200.0f, 0.05f, 10.0f); + + if (this->workTimer[WORK_TIMER_CURRENT_ACTION] == 0) { + if ((s8)this->actor.colChkInfo.health <= 5) { + if (!this->hasSpwanedSmallFishes) { + this->hasSpwanedSmallFishes++; + Boss03_SetupSpawnSmallFishesCutscene(this, globalCtx); + return; + } + } + + func_809E344C(this, globalCtx); + this->workTimer[WORK_TIMER_UNK1_A] = 100; + } +} + +/* End of ActionFuncs section */ + +void Boss03_UpdateCollision(Boss03* this, GlobalContext* globalCtx) { + ColliderInfo* hitbox; + u8 sp4B = true; + Player* player = GET_PLAYER(globalCtx); + s32 i; + s32 phi_v1; + u32 phi_v0; + Boss03ActionFunc stunnedActionFunc = Boss03_Stunned; + + if (((KREG(20) + (this->waterHeight - 50.0f)) < player->actor.world.pos.y) && + (player->transformation != PLAYER_FORM_FIERCE_DEITY)) { + sp4B = false; + } + + if (this->waterHeight < player->actor.world.pos.y) { + for (i = 0; i < ARRAY_COUNT(sHeadJntSphElementsInit); i++) { + if (this->headCollider.elements[i].info.toucherFlags & TOUCH_HIT) { + this->headCollider.elements[i].info.toucherFlags &= ~TOUCH_HIT; + player->unk_B84 = this->actor.shape.rot.y; + player->unk_B80 = 20.0f; + } + } + + for (i = 0; i < ARRAY_COUNT(sBodyJntSphElementsInit); i++) { + if (this->bodyCollider.elements[i].info.toucherFlags & TOUCH_HIT) { + this->bodyCollider.elements[i].info.toucherFlags &= ~TOUCH_HIT; + player->unk_B84 = this->actor.shape.rot.y; + player->unk_B80 = 20.0f; + } + } + } + + if (this->unk_25C == 0) { + if ((this->actionFunc == stunnedActionFunc) && sp4B) { + for (i = 0; i < ARRAY_COUNT(sBodyJntSphElementsInit); i++) { + if (this->bodyCollider.elements[i].info.bumperFlags & BUMP_HIT) { + hitbox = this->bodyCollider.elements[i].info.acHitInfo; + this->bodyCollider.elements[i].info.bumperFlags &= ~BUMP_HIT; + this->unk_25C = 15; + this->unk_25E = 15; + + // (DMG_SWORD_BEAM | DMG_SPIN_ATTACK | DMG_ZORA_PUNCH | DMG_ZORA_BARRIER | DMG_DEKU_LAUNCH | + // DMG_DEKU_SPIN | DMG_GORON_SPIKES | DMG_SWORD | DMG_GORON_PUNCH | DMG_DEKU_STICK) + phi_v0 = (hitbox->toucher.dmgFlags & 0x038AC302) + ? this->bodyCollider.elements[i].info.acHitInfo->toucher.damage + : 0; + + phi_v1 = phi_v0; + if (phi_v0 < 1) { + phi_v1 = 1; + } + this->actor.colChkInfo.health -= phi_v1; + + if ((s8)this->actor.colChkInfo.health <= 0) { + Boss03_PlayUnderwaterSfx(&D_809E9848, NA_SE_EN_KONB_DEAD_OLD); + Boss03_PlayUnderwaterSfx(&D_809E9848, NA_SE_EN_KONB_DEAD2_OLD); + Boss03_SetupDeathCutscene(this, globalCtx); + Enemy_StartFinishingBlow(globalCtx, &this->actor); + } else { + Boss03_SetupDamaged(this, globalCtx); + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_DAMAGE_OLD); + } + return; + } + } + } + + for (i = 0; i < ARRAY_COUNT(sHeadJntSphElementsInit); i++) { + if (this->headCollider.elements[i].info.bumperFlags & BUMP_HIT) { + hitbox = this->headCollider.elements[i].info.acHitInfo; + this->headCollider.elements[i].info.bumperFlags &= ~BUMP_HIT; + this->unk_25C = 15; + + if (this->actionFunc != stunnedActionFunc) { + Boss03_SetupStunned(this, globalCtx); + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_DAMAGE_OLD); + + if (&this->actor == player->actor.parent) { + player->unk_AE8 = 101; + player->actor.parent = NULL; + player->csMode = 0; + func_80165690(); + } + + continue; + } + + if (sp4B) { + this->unk_25E = 15; + + // (DMG_SWORD_BEAM | DMG_SPIN_ATTACK | DMG_ZORA_PUNCH | DMG_ZORA_BARRIER | DMG_DEKU_LAUNCH | + // DMG_DEKU_SPIN | DMG_GORON_SPIKES | DMG_SWORD | DMG_GORON_PUNCH | DMG_DEKU_STICK) + phi_v0 = (hitbox->toucher.dmgFlags & 0x038AC302) + ? (this->headCollider.elements[i].info.acHitInfo->toucher.damage) + : 0; + + phi_v1 = phi_v0; + if (phi_v0 < 1) { + phi_v1 = 1; + } + this->actor.colChkInfo.health -= phi_v1; + if ((s8)this->actor.colChkInfo.health <= 0) { + Boss03_PlayUnderwaterSfx(&D_809E9848, NA_SE_EN_KONB_DEAD_OLD); + Boss03_PlayUnderwaterSfx(&D_809E9848, NA_SE_EN_KONB_DEAD2_OLD); + Enemy_StartFinishingBlow(globalCtx, &this->actor); + Boss03_SetupDeathCutscene(this, globalCtx); + } else { + Boss03_SetupDamaged(this, globalCtx); + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_DAMAGE_OLD); + } + } + return; + } + } + } +} + +void Boss03_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + Boss03* this = THIS; + Actor* dblueActor; + Player* player = GET_PLAYER(globalCtx); + s32 i; + Vec3f wetSpotPos; + Vec3f bubblePos; + Vec3f dropletPos; + s16 j; + f32 yRot; + + this->actor.hintId = 0x28; + + if (!D_809E9842 && (player->actor.world.pos.y < (PLATFORM_HEIGHT + 5.0f))) { + D_809E9842 = true; + D_809E9841 = 5; + } + + if (KREG(63) == 0) { + this->unk_290 = 1; + this->unk_240++; + this->unk_2BC = 1; + + this->unk_2BD = false; + + Math_Vec3f_Copy(&D_809E9848, &this->actor.projectedPos); + + for (i = 0; i < ARRAY_COUNT(this->workTimer); i++) { + if (this->workTimer[i] != 0) { + this->workTimer[i]--; + } + } + + if (this->unk_324 != 0) { + this->unk_324--; + } + + if (this->unk_25C != 0) { + this->unk_25C--; + } + + if (this->unk_25E != 0) { + this->unk_25E--; + } + + this->actionFunc(this, globalCtx); + + if (this->actionFunc != Boss03_DeathCutscene) { + Math_ApproachS(&this->actor.shape.rot.z, 0, 0xA, 0x800); + this->actor.world.pos.y -= 100.0f; + this->actor.prevPos.y -= 100.0f; + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 50.0f, 150.0f, 100.0f, 5); + this->actor.world.pos.y += 100.0f; + this->actor.prevPos.y += 100.0f; + } + } + + if ((this->actionFunc != Boss03_DeathCutscene) && (!this->unk_2D5)) { + // Going into or out of the water + if (((this->actor.world.pos.y < this->waterHeight + 50.0f) && + (this->waterHeight + 50.0f <= this->actor.prevPos.y)) || + ((this->waterHeight - 50.0f < this->actor.world.pos.y) && + (this->actor.prevPos.y <= this->waterHeight - 50.0f))) { + if ((this->actor.velocity.y < 0.0f) && (this->actionFunc != Boss03_DeathCutscene)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KONB_SINK_OLD); + } + + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_WATER_EFFECT, this->actor.world.pos.x, + this->waterHeight, this->actor.world.pos.z, 0, 0, 0x78, ENWATEREFFECT_777); + + this->unk_280 = 27; + this->unk_284 = this->actor.world.pos.x; + this->unk_288 = this->waterHeight; + this->unk_28C = this->actor.world.pos.z; + } + } + + if (this->actionFunc != Boss03_DeathCutscene) { + if ((this->actionFunc == Boss03_Stunned) || (this->actionFunc == Boss03_Damaged)) { + this->bodyCollider.base.colType = COLTYPE_HIT3; + } else { + this->bodyCollider.base.colType = COLTYPE_METAL; + } + + Boss03_UpdateCollision(this, globalCtx); + + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->bodyCollider.base); + + if (player->transformation == PLAYER_FORM_HUMAN) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->headCollider.base); + } + + if (!this->unk_2BD) { + if (player->transformation != PLAYER_FORM_HUMAN) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->headCollider.base); + } + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->headCollider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->bodyCollider.base); + } + + if ((this->actionFunc != Boss03_Stunned) && (!this->unk_2BD)) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->headCollider.base); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->bodyCollider.base); + } + } + + dblueActor = Boss03_FindActorDblueMovebg(globalCtx); + if (dblueActor != NULL) { + dblueActor->world.pos.y = this->waterHeight; + } + + Math_ApproachZeroF(&this->unk_260, 0.1f, 0.05f); + + if (this->unk_290 != 0) { + this->unk_294 += 0.1f; + this->unk_298 += 0.12f; + this->leftFinYRot = __sinf(this->unk_294) * 1280.0f; + this->rightFinYRot = __sinf(this->unk_298) * 1280.0f; + } else { + Math_ApproachS(&this->rightFinYRot, 0, 0xA, 0x100); + Math_ApproachS(&this->leftFinYRot, 0, 0xA, 0x100); + } + + Math_ApproachS(&this->bodyYRot, 0, 0xA, 0x100); + Math_ApproachS(&this->jawZRot, 0, 0xA, 0x200); + + if ((this->unk_240 % 2) == 0) { + for (i = 0; i < this->bubbleEffectSpawnCount; i++) { + bubblePos.x = randPlusMinusPoint5Scaled(100.0f) + this->actor.world.pos.x; + bubblePos.y = randPlusMinusPoint5Scaled(100.0f) + this->actor.world.pos.y; + bubblePos.z = randPlusMinusPoint5Scaled(100.0f) + this->actor.world.pos.z; + + Boss03_SpawnEffectBubble(globalCtx, &bubblePos); + } + } + + this->bubbleEffectSpawnCount = 1; + Boss03_UpdateEffects(globalCtx); + + if (D_809E9841 != 0) { + D_809E9841--; + if (D_809E9841 == 0) { + Audio_QueueSeqCmd(NA_BGM_BOSS | 0x8000); + } + } + + if (this->actionFunc != Boss03_CatchPlayer) { + Math_ApproachS(&player->actor.world.rot.x, 0, 1, 0x80); + Math_ApproachS(&player->actor.shape.rot.x, 0, 1, 0x80); + } + + if ((this->waterHeight < player->actor.world.pos.y) && (this->prevPlayerPos.y <= this->waterHeight)) { + this->wetSpotEffectSpawnCount = 20; + } + + // Player is standing on ground && Player is above water + if ((player->actor.bgCheckFlags & 1) && (player->actor.shape.feetPos[FOOT_LEFT].y >= WATER_HEIGHT + 8.0f)) { + if (this->wetSpotEffectSpawnCount != 0) { + this->wetSpotEffectSpawnCount--; + + wetSpotPos.x = randPlusMinusPoint5Scaled(50.0f) + player->actor.world.pos.x; + wetSpotPos.y = PLATFORM_HEIGHT; + wetSpotPos.z = randPlusMinusPoint5Scaled(50.0f) + player->actor.world.pos.z; + Boss03_SpawnEffectWetSpot(globalCtx, &wetSpotPos); + } + } + + this->prevPlayerPos = player->actor.world.pos; + + if (this->waterHeight < this->actor.world.pos.y) { + func_8019F540(0); + } else { + func_8019F540(1); + } + + if (this->unk_280 != 0) { + this->unk_280--; + } + + if ((this->unk_280 == 1) || (this->unk_280 == 5) || (this->unk_280 == 9)) { + yRot = 0.0f; + + for (j = 0, i = 0; i < 20; j++) { + Matrix_InsertYRotation_f(yRot, MTXMODE_NEW); + Matrix_GetStateTranslationAndScaledZ(Rand_ZeroFloat(60.000004f) + 312.0f, &dropletPos); + dropletPos.x += this->unk_284 + randPlusMinusPoint5Scaled(40.0f); + dropletPos.y = PLATFORM_HEIGHT; + dropletPos.z += this->unk_28C + randPlusMinusPoint5Scaled(40.0f); + + if (sqrtf(SQ(dropletPos.x) + SQ(dropletPos.z)) < 355.0f) { + Boss03_SpawnEffectDroplet(globalCtx, &dropletPos); + i++; + } + + yRot += ((2.0f * M_PI) / 50.0f); + if (j >= 50) { + break; + } + } + } +} + +/* End of Gyorg's More actionFuncs and Update section */ + +/* Start of Gyorg's Draw section */ + +void Boss03_SetObject(GlobalContext* globalCtx, s16 objectId) { + s32 objectIndex = Object_GetIndex(&globalCtx->objectCtx, objectId); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[objectIndex].segment); + + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[objectIndex].segment); + gSPSegment(POLY_XLU_DISP++, 0x06, globalCtx->objectCtx.status[objectIndex].segment); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +s32 Boss03_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + Boss03* this = THIS; + + if ((limbIndex == GYORG_LIMB_UPPER_TRUNK) || (limbIndex == GYORG_LIMB_LOWER_TRUNK) || + (limbIndex == GYORG_LIMB_TAIL)) { + rot->y += this->bodyYRot; + } + if (limbIndex == GYORG_LIMB_UPPER_RIGHT_FIN) { + rot->y += this->rightFinYRot; + } + if (limbIndex == GYORG_LIMB_LOWER_RIGHT_FIN) { + rot->y += (s16)(2 * this->rightFinYRot); + } + if (limbIndex == GYORG_LIMB_UPPER_LEFT_FIN) { + rot->y -= this->leftFinYRot; + } + if (limbIndex == GYORG_LIMB_LOWER_LEFT_FIN) { + rot->y -= (s16)(2 * this->leftFinYRot); + } + if (limbIndex == GYORG_LIMB_JAW) { + rot->z += this->jawZRot; + } + + return false; +} + +/** + * Used to manually index the spheres elements of the two colliders + * Since there are two sets of ColliderJntSph, indices < 2 (ARRAY_COUNT(sHeadJntSphElementsInit)) refers to the first + * collider and indices >= 2 refers to the second one + */ +s8 sGyorgSphElementIndices[] = { + -1, // GYORG_LIMB_NONE, + -1, // GYORG_LIMB_ROOT, + 0, // GYORG_LIMB_HEAD, + -1, // GYORG_LIMB_BODY_ROOT, + 4, // GYORG_LIMB_UPPER_TRUNK, + 5, // GYORG_LIMB_LOWER_TRUNK, + 6, // GYORG_LIMB_TAIL, + -1, // GYORG_LIMB_RIGHT_FIN_ROOT, + 2, // GYORG_LIMB_UPPER_RIGHT_FIN, + -1, // GYORG_LIMB_LOWER_RIGHT_FIN, + -1, // GYORG_LIMB_LEFT_FIN_ROOT, + 3, // GYORG_LIMB_UPPER_LEFT_FIN, + -1, // GYORG_LIMB_LOWER_LEFT_FIN, + -1, // GYORG_LIMB_JAW_ROOT, + 1, // GYORG_LIMB_JAW, + -1, // GYORG_LIMB_MAX + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, +}; + +Vec3f D_809E9148 = { 600.0f, -100.0f, 0.0f }; +Vec3f D_809E9154[] = { + { 450.0f, 0.0f, 0.0f }, { 140.0f, -60.0f, 0.0f }, { 350.0f, 0.0f, 0.0f }, { 350.0f, 0.0f, 0.0f }, + { 100.0f, 0.0f, 0.0f }, { 150.0f, 0.0f, 0.0f }, { 500.0f, 0.0f, 0.0f }, +}; +Vec3f D_809E91A8 = { 100000.0f, 100000.0f, 100000.0f }; +Vec3f D_809E91B4 = { 300.0f, -100.0f, -200.0f }; + +void Boss03_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + Boss03* this = THIS; + s32 pad; + s8 sphereElementIndex; + Vec3f spherePos; + Player* player = GET_PLAYER(globalCtx); + + if (limbIndex == GYORG_LIMB_HEAD) { + Matrix_MultiplyVector3fByState(&D_809E9148, &this->actor.focus.pos); + } + + sphereElementIndex = sGyorgSphElementIndices[limbIndex]; + if (sphereElementIndex >= 0) { + Matrix_MultiplyVector3fByState(&D_809E9154[sphereElementIndex], &spherePos); + + if (sphereElementIndex < 2) { + if ((this->actionFunc == Boss03_Stunned) && (this->waterHeight < player->actor.world.pos.y)) { + Boss03_UpdateSphereElement(sphereElementIndex, &this->headCollider, &D_809E91A8); + } else { + Boss03_UpdateSphereElement(sphereElementIndex, &this->headCollider, &spherePos); + } + } else { + Boss03_UpdateSphereElement(sphereElementIndex - 2, &this->bodyCollider, &spherePos); + } + } + + if (limbIndex == GYORG_LIMB_JAW) { + MtxF mf; + + D_809E91B4.x = this->unk_2C4 + 300.0f; + Matrix_MultiplyVector3fByState(&D_809E91B4, &this->insideJawPos); + Matrix_CopyCurrentState(&mf); + func_8018219C(&mf, &this->unk_2A2, 0); + } +} + +void Boss03_Draw(Actor* thisx, GlobalContext* globalCtx) { + Boss03* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + if (!this->unk_2D5) { + if ((this->unk_25E % 2) != 0) { + POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, 255, 0, 0, 255, 900, 1099); + } + + Matrix_InsertYRotation_f(this->unk_260, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, -600.0f, 0.0f, MTXMODE_APPLY); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, Boss03_OverrideLimbDraw, Boss03_PostLimbDraw, &this->actor); + POLY_OPA_DISP = func_801660B8(globalCtx, POLY_OPA_DISP); + } + + this->unk_2BC = 0; + + Boss03_DrawEffects(globalCtx); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +/* End of Gyorg's Draw section */ + +/* Start of Effect Update/Draw section */ + +void Boss03_UpdateEffects(GlobalContext* globalCtx) { + GyorgEffect* eff = globalCtx->specialEffects; + s16 i; + Vec3f sp94; + Vec3f velocity; + + for (i = 0; i < GYORG_EFFECT_COUNT; i++, eff++) { + f32 phi_f0; + + if (eff->type == GYORG_EFFECT_NONE) { + continue; + } + + eff->unk_02++; + + eff->pos.x += eff->velocity.x; + eff->pos.y += eff->velocity.y; + eff->pos.z += eff->velocity.z; + + eff->velocity.y += eff->accel.y; + + if ((eff->unk_02 & 6) != 0) { + phi_f0 = 80.0f; + } else { + phi_f0 = 200.0f; + } + + Math_ApproachF(&eff->unk_40, phi_f0, 1.0f, 80.0f); + + if (eff->type == GYORG_EFFECT_DROPLET) { + eff->unk_34.z += 0.15f; + + Math_ApproachF(&eff->unk_34.x, 0.03f, 0.5f, 0.005f); + Math_ApproachF(&eff->unk_34.y, 0.5f, 0.5f, 0.02f); + + if (eff->pos.y <= WATER_HEIGHT) { + eff->type = GYORG_EFFECT_NONE; + eff->pos.y = WATER_HEIGHT; + EffectSsGRipple_Spawn(globalCtx, &eff->pos, 0, 80, 0); + } else if (eff->pos.y <= PLATFORM_HEIGHT) { + s16 j; + + eff->type = GYORG_EFFECT_WET_SPOT; + eff->pos.y = PLATFORM_HEIGHT; + eff->unk_34.x = 0.1f; + eff->unk_34.y = 0.6f; + eff->velocity = gZeroVec3f; + eff->accel = gZeroVec3f; + eff->alpha = 150; + eff->alphaDelta = Rand_ZeroFloat(4.0f) + 5.0f; + + for (j = 0; j < 4; j++) { + Matrix_InsertYRotation_f((2.0f * (j * M_PI)) / 6.0f, 0); + sp94.x = 0.0f; + sp94.y = Rand_ZeroFloat(4.0f) + 2.0f; + sp94.z = Rand_ZeroFloat(1.5f) + 1.5f; + Matrix_MultiplyVector3fByState(&sp94, &velocity); + Boss03_SpawnEffectSplash(globalCtx, &eff->pos, &velocity); + } + } + } else if (eff->type == GYORG_EFFECT_SPLASH) { + eff->unk_34.z += 0.15f; + + if (eff->velocity.y < -8.0f) { + eff->velocity.y = -8.0f; + } + + if ((eff->velocity.y < 0.0f) && (eff->pos.y <= PLATFORM_HEIGHT)) { + eff->type = GYORG_EFFECT_WET_SPOT; + eff->pos.y = PLATFORM_HEIGHT; + eff->unk_34.x = 0.05f; + eff->unk_34.y = 0.2f; + eff->velocity = gZeroVec3f; + eff->accel = gZeroVec3f; + eff->alpha = 150; + eff->alphaDelta = Rand_ZeroFloat(4.0f) + 5.0f; + } + } else if (eff->type == GYORG_EFFECT_WET_SPOT) { + Math_ApproachF(&eff->unk_34.x, eff->unk_34.y, 0.1f, 0.6f); + + eff->alpha -= eff->alphaDelta; + if (eff->alpha <= 0) { + eff->alpha = 0; + eff->type = GYORG_EFFECT_NONE; + } + } else if (eff->type == GYORG_EFFECT_BUBBLE) { + if (eff->velocity.y > 5.0f) { + eff->velocity.y = 5.0f; + } + if (sGyorgBossInstance->waterHeight < eff->pos.y) { + eff->type = GYORG_EFFECT_NONE; + } + } + } +} + +void Boss03_DrawEffects(GlobalContext* globalCtx) { + u8 flag = false; + s16 i; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + s32 pad; + GyorgEffect* eff = globalCtx->specialEffects; + GyorgEffect* effFirst = eff; + + OPEN_DISPS(gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C28C(gfxCtx); + + for (i = 0; i < GYORG_EFFECT_COUNT; i++, eff++) { + if (eff->type == GYORG_EFFECT_BUBBLE) { + if (!flag) { + gSPDisplayList(POLY_OPA_DISP++, gGyorgBubbleMaterialDL); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); + gDPSetEnvColor(POLY_OPA_DISP++, 150, 150, 150, 0); + + flag = true; + } + + Matrix_InsertTranslation(eff->pos.x, eff->pos.y, eff->pos.z, MTXMODE_NEW); + Matrix_Scale(eff->unk_34.x, eff->unk_34.x, 1.0f, MTXMODE_APPLY); + Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gGyorgBubbleModelDL); + } + } + + eff = effFirst; + + Boss03_SetObject(globalCtx, OBJECT_WATER_EFFECT); + + flag = false; + + for (i = 0; i < GYORG_EFFECT_COUNT; i++, eff++) { + if ((eff->type == GYORG_EFFECT_DROPLET) || (eff->type == GYORG_EFFECT_SPLASH)) { + + if (!flag) { + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0); + + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gDust1Tex)); + gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_004260); + gDPSetEnvColor(POLY_XLU_DISP++, 250, 250, 255, 0); + + flag++; + } + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (u8)eff->unk_40, (u8)((((void)0, eff->unk_40) + 55.0f)), 225, 150); + + Matrix_InsertTranslation(eff->pos.x, eff->pos.y, eff->pos.z, MTXMODE_NEW); + + if (eff->type == GYORG_EFFECT_DROPLET) { + Matrix_InsertYRotation_f(Camera_GetInputDirYaw(globalCtx->cameraPtrs[globalCtx->activeCamera]) * + (M_PI / 0x8000), + MTXMODE_APPLY); + } else { // GYORG_EFFECT_SPLASH + Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + } + + Matrix_Scale(eff->unk_34.x, eff->unk_34.y, 1.0f, MTXMODE_APPLY); + Matrix_InsertZRotation_f(eff->unk_34.z, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_0042B0); + } + } + + eff = effFirst; + + flag = false; + + for (i = 0; i < GYORG_EFFECT_COUNT; i++, eff++) { + if (eff->type == GYORG_EFFECT_WET_SPOT) { + if (!flag) { + func_8012C448(gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gDust1Tex)); + gDPSetEnvColor(POLY_XLU_DISP++, 250, 250, 255, 0); + gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_004260); + + flag++; + } + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (s16)eff->unk_40, ((void)0, ((s16)eff->unk_40) + 55), 225, + eff->alpha); + + Matrix_InsertTranslation(eff->pos.x, eff->pos.y, eff->pos.z, MTXMODE_NEW); + + Matrix_Scale(eff->unk_34.x, 1.0f, eff->unk_34.x, MTXMODE_APPLY); + Matrix_InsertYRotation_f(eff->unk_34.z, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_0042F8); + } + } + + Boss03_SetObject(globalCtx, OBJECT_BOSS03); + + CLOSE_DISPS(gfxCtx); +} + +/* End of Effect Update/Draw section */ + +/* Start of Seaweed section */ + +#define SEAWEED_FLAG_INTERACT_NONE 0 +#define SEAWEED_FLAG_INTERACT_PLAYER 1 +#define SEAWEED_FLAG_INTERACT_GYORG 2 + +void Boss03_SeaweedUpdate(Actor* thisx, GlobalContext* globalCtx) { + Boss03* this = THIS; + s16 i; + s16 pad; + s16 maxBendSpeed; + u8 flag; + Player* player = GET_PLAYER(globalCtx); + f32 distanceBetweenSeaweedAndDisturbance; + f32 disturbanceFactor; + f32 xDiff; + f32 yDiff; + f32 zDiff; + + flag = SEAWEED_FLAG_INTERACT_NONE; + this->unk_240++; + + for (i = 0; i < ARRAY_COUNT(this->seaweedSegmentPositions); i++) { + xDiff = player->actor.world.pos.x - this->seaweedSegmentPositions[i].x; + yDiff = player->actor.world.pos.y - this->seaweedSegmentPositions[i].y; + zDiff = player->actor.world.pos.z - this->seaweedSegmentPositions[i].z; + distanceBetweenSeaweedAndDisturbance = sqrtf(SQ(xDiff) + SQ(yDiff) + SQ(zDiff)); + disturbanceFactor = player->actor.speedXZ * 3.0f + 70.0f; + + // Player is standing on ground + if (player->actor.bgCheckFlags & 1) { + maxBendSpeed = 0; + } else { + maxBendSpeed = player->actor.speedXZ * 16.0f; + if (maxBendSpeed > 0x1000) { + maxBendSpeed = 0x1000; + } else if (maxBendSpeed < 0x100) { + maxBendSpeed = 0x100; + } + } + + if (distanceBetweenSeaweedAndDisturbance < disturbanceFactor) { + Math_ApproachS(&this->morphTable[i].x, (disturbanceFactor - distanceBetweenSeaweedAndDisturbance) * 200.0f, + 0xA, maxBendSpeed); + if (maxBendSpeed != 0) { + flag |= SEAWEED_FLAG_INTERACT_PLAYER; + } + } + } + + if (flag & SEAWEED_FLAG_INTERACT_PLAYER) { + Math_ApproachS(&this->actor.shape.rot.y, Math_FAtan2F(zDiff, xDiff), 0x14, 0x800); + } + + if (sGyorgBossInstance->actor.world.pos.y - 40.0f < sGyorgBossInstance->waterHeight) { + for (i = 0; i < 6; i++) { + xDiff = sGyorgBossInstance->actor.world.pos.x - this->seaweedSegmentPositions[i].x; + yDiff = sGyorgBossInstance->actor.world.pos.y - this->seaweedSegmentPositions[i].y; + zDiff = sGyorgBossInstance->actor.world.pos.z - this->seaweedSegmentPositions[i].z; + + distanceBetweenSeaweedAndDisturbance = sqrtf(SQ(xDiff) + SQ(yDiff) + SQ(zDiff)); + + if ((i == 0) && (distanceBetweenSeaweedAndDisturbance > 400.0f)) { + break; + } + + maxBendSpeed = sGyorgBossInstance->actor.speedXZ * 16.0f; + disturbanceFactor = sGyorgBossInstance->actor.speedXZ * 5.0f + 150.0f; + if (maxBendSpeed > 0x1000) { + maxBendSpeed = 0x1000; + } else if (maxBendSpeed < 0x100) { + maxBendSpeed = 0x0100; + } + + if (distanceBetweenSeaweedAndDisturbance < disturbanceFactor) { + Math_ApproachS(&this->morphTable[i].x, + (disturbanceFactor - distanceBetweenSeaweedAndDisturbance) * 200.0f, 0xA, maxBendSpeed); + if (maxBendSpeed != 0) { + flag |= SEAWEED_FLAG_INTERACT_GYORG; + } + } + } + + if (flag & SEAWEED_FLAG_INTERACT_GYORG) { + Math_ApproachS(&this->actor.shape.rot.y, Math_FAtan2F(zDiff, xDiff), 0x14, 0x800); + } + } + + if (flag == SEAWEED_FLAG_INTERACT_NONE) { + for (i = 0; i < 6; i++) { + Math_ApproachS(&this->morphTable[i].x, 0, 0x14, 0x80); + } + } +} + +Gfx* sGyorgSeaweedDLs[] = { + gGyorgSeaweedTopDL, gGyorgSeaweedPiece5DL, gGyorgSeaweedPiece4DL, + gGyorgSeaweedPiece3DL, gGyorgSeaweedPiece2DL, gGyorgSeaweedPiece1DL, +}; + +void Boss03_SeaweedDraw(Actor* thisx, GlobalContext* globalCtx) { + Boss03* this = THIS; + s16 i; + // Why 10 Mtxs? This seems to only use the first 6 elements + Mtx* mtx = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(Mtx) * 10); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x0D, mtx); + + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_InsertZRotation_s(0x4000, MTXMODE_APPLY); + // The indices looks a bit random... + Matrix_RotateY(this->jointTable[5].x * -5.0f * 0.1f, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->jointTable[3].y * -5.0f * 0.1f, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->jointTable[2].z * 6.0f * 0.1f, MTXMODE_APPLY); + + for (i = 0; i < ARRAY_COUNT(sGyorgSeaweedDLs); i++, mtx++) { + Matrix_RotateY(this->jointTable[i].x + this->morphTable[i].x, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->jointTable[i].y + this->morphTable[i].y, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->jointTable[i].z + this->morphTable[i].z, MTXMODE_APPLY); + + Matrix_ToMtx(mtx); + gSPMatrix(POLY_OPA_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_OPA_DISP++, sGyorgSeaweedDLs[i]); + + Matrix_GetStateTranslation(&this->seaweedSegmentPositions[i]); + Matrix_InsertTranslation(4000.0f, 0.0f, 0.0f, MTXMODE_APPLY); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +/* End of Seaweed section */ diff --git a/src/overlays/actors/ovl_Boss_03/z_boss_03.h b/src/overlays/actors/ovl_Boss_03/z_boss_03.h index ca8a92328a..f5af516c00 100644 --- a/src/overlays/actors/ovl_Boss_03/z_boss_03.h +++ b/src/overlays/actors/ovl_Boss_03/z_boss_03.h @@ -2,22 +2,109 @@ #define Z_BOSS_03_H #include "global.h" +#include "objects/object_boss03/object_boss03.h" struct Boss03; typedef void (*Boss03ActionFunc)(struct Boss03*, GlobalContext*); +#define GYORG_WORK_TIMER_MAX 3 + +typedef struct { + /* 0x00 */ u8 type; + /* 0x02 */ s16 unk_02; + /* 0x04 */ Vec3f pos; + /* 0x10 */ Vec3f velocity; + /* 0x1C */ Vec3f accel; + /* 0x28 */ UNK_TYPE1 unk_28[0x4]; + /* 0x2C */ s16 alpha; + /* 0x2E */ s16 alphaDelta; + /* 0x30 */ UNK_TYPE1 unk_30[0x4]; + /* 0x34 */ Vec3f unk_34; // it may not be a Vec3f + /* 0x40 */ f32 unk_40; // colorIntensity? +} GyorgEffect; // size = 0x44 + +#define GYORG_EFFECT_COUNT 150 + +typedef enum { + /* 0 */ GYORG_EFFECT_NONE, + /* 1 */ GYORG_EFFECT_BUBBLE, + /* 2 */ GYORG_EFFECT_DROPLET, + /* 3 */ GYORG_EFFECT_SPLASH, + /* 4 */ GYORG_EFFECT_WET_SPOT, +} GyorgEffectType; + typedef struct Boss03 { /* 0x0000 */ Actor actor; - /* 0x0144 */ UNK_TYPE1 unk_144[0x10E]; - /* 0x0252 */ s8 unk_252; // number of Tanron3 fish that are currently alive, maybe "numSmallFishAlive"? - /* 0x0253 */ UNK_TYPE1 unk_253[0xD1]; - /* 0x0324 */ s16 unk_324; - /* 0x0326 */ UNK_TYPE1 unk_326[0x2]; + /* 0x0144 */ UNK_TYPE1 unk_144[0x04]; + /* 0x0148 */ SkelAnime skelAnime; + /* 0x018C */ Vec3s jointTable[GYORG_LIMB_MAX]; + /* 0x01E6 */ Vec3s morphTable[GYORG_LIMB_MAX]; + /* 0x0240 */ s16 unk_240; // generic timer? used by Gyorg and seaweed + /* 0x0242 */ u8 unk_242; + /* 0x0243 */ UNK_TYPE1 unk_243[0x09]; + /* 0x024C */ s16 workTimer[GYORG_WORK_TIMER_MAX]; + /* 0x0252 */ s8 numSpawnedSmallFish; // number of Tanron3 fish that are currently alive, -1 indexed + /* 0x0253 */ u8 hasSpwanedSmallFishes; // Tanron + /* 0x0254 */ s16 bubbleEffectSpawnCount; // Amount of bubble effect which will be spawned by Update + /* 0x0258 */ f32 waterHeight; // always 430.0f + /* 0x025C */ s16 unk_25C; // Timer related to collision? + /* 0x025E */ s16 unk_25E; + /* 0x0260 */ f32 unk_260; // rotY + /* 0x0264 */ UNK_TYPE1 unk_264[0x04]; + /* 0x0268 */ Vec3f unk_268; // set to player.world.pos or random values + /* 0x0274 */ s16 unk_274; + /* 0x0276 */ s16 unk_276; + /* 0x0278 */ f32 unk_278; + /* 0x027C */ f32 unk_27C; + /* 0x0280 */ s16 unk_280; + /* 0x0284 */ f32 unk_284; // Maybe a Vec3f + /* 0x0288 */ f32 unk_288; // Set but not used + /* 0x028C */ f32 unk_28C; + /* 0x0290 */ u8 unk_290; + /* 0x0294 */ f32 unk_294; + /* 0x0298 */ f32 unk_298; + /* 0x029C */ s16 leftFinYRot; + /* 0x029E */ s16 rightFinYRot; + /* 0x02A0 */ s16 bodyYRot; + /* 0x02A2 */ Vec3s unk_2A2; + /* 0x02A8 */ s16 jawZRot; + /* 0x02AC */ Vec3f insideJawPos; // used to grab player + /* 0x02B8 */ f32 unk_2B8; + /* 0x02BC */ u8 unk_2BC; // set but not used + /* 0x02BD */ u8 unk_2BD; // playerUnderwater? + /* 0x02BE */ s16 unk_2BE; + /* 0x02C0 */ UNK_TYPE1 unk_2C0[0x04]; + /* 0x02C0 */ f32 unk_2C4; + /* 0x02C8 */ Vec3f prevPlayerPos; + /* 0x02D4 */ u8 wetSpotEffectSpawnCount; + /* 0x02D5 */ u8 unk_2D5; // flag + /* 0x02D6 */ s16 shapeRotTargetX; + /* 0x02D8 */ s16 shapeRotTargetY; + /* 0x02DA */ s16 shapeRotTargetZ; + /* 0x02DC */ Vec3f seaweedSegmentPositions[6]; + /* 0x0324 */ s16 unk_324; // timer? set by Tanron3 /* 0x0328 */ Boss03ActionFunc actionFunc; - /* 0x032C */ UNK_TYPE1 unk_32C[0x250]; + /* 0x032C */ ColliderJntSph headCollider; + /* 0x034C */ ColliderJntSphElement headColliderElements[2]; + /* 0x03CC */ ColliderJntSph bodyCollider; + /* 0x03EC */ ColliderJntSphElement bodyColliderElements[5]; + /* 0x052C */ f32 floppingAnimLastFrame; + /* 0x0530 */ u32 csTimer; + /* 0x0534 */ s16 csState; + /* 0x0536 */ s16 csCamId; + /* 0x0538 */ Vec3f csCamEye; + /* 0x0544 */ Vec3f csCamAt; + /* 0x0550 */ Vec3f csCamTargetEye; + /* 0x055C */ Vec3f csCamTargetAt; + /* 0x0568 */ f32 unk_568; + /* 0x056C */ f32 unk_56C; + /* 0x0570 */ f32 unk_570; // set but not used + /* 0x0574 */ UNK_TYPE1 unk_574[0x04]; + /* 0x0578 */ f32 cameraFov; } Boss03; // size = 0x57C - -extern const ActorInit Boss_03_InitVars; + +#define GYORG_PARAM_DEFAULT (0) +#define GYORG_PARAM_SEAWEED (0x23) #endif // Z_BOSS_03_H diff --git a/src/overlays/actors/ovl_Boss_06/z_boss_06.c b/src/overlays/actors/ovl_Boss_06/z_boss_06.c index 262bc1979d..311d07a754 100644 --- a/src/overlays/actors/ovl_Boss_06/z_boss_06.c +++ b/src/overlays/actors/ovl_Boss_06/z_boss_06.c @@ -4,6 +4,7 @@ * Description: Igos du Ikana window - curtains and ray effects */ +#include "prevent_bss_reordering.h" #include "z_boss_06.h" #include "overlays/actors/ovl_En_Knight/z_en_knight.h" #include "objects/gameplay_keep/gameplay_keep.h" @@ -499,8 +500,6 @@ void Boss06_Update(Actor* thisx, GlobalContext* globalCtx) { } } -#ifdef NON_MATCHING -// v/a flips void Boss06_Draw(Actor* thisx, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; Boss06* this = THIS; @@ -509,10 +508,11 @@ void Boss06_Draw(Actor* thisx, GlobalContext* globalCtx2) { s16 temp_s0; s16 temp_f10; Vtx* temp_v0_2; - u32 temp_v0; + u16 temp_v0; + u16 pad; u8 spD3; u8 spD2; - s32 pad; + s32 maxColor = 255; // Possible FAKE MATCH f32 sp68; OPEN_DISPS(globalCtx->state.gfxCtx); @@ -520,9 +520,9 @@ void Boss06_Draw(Actor* thisx, GlobalContext* globalCtx2) { func_8012C2DC(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); - temp_v0 = gSaveContext.time; - if (gSaveContext.time > 0x8000) { - temp_v0 = (0xFFFF - gSaveContext.time) & 0xFFFF; + temp_v0 = gSaveContext.save.time; + if (temp_v0 > CLOCK_TIME(12, 0)) { + temp_v0 = 0xFFFF - temp_v0; } sp68 = (f32)temp_v0 / 0x8000; spD3 = ((10.0f * sp68) + 105.0f) * this->unk_19C; @@ -579,10 +579,12 @@ void Boss06_Draw(Actor* thisx, GlobalContext* globalCtx2) { Matrix_InsertTranslation(0.0f, 0.0f, -1112.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x9B, 255, 255, (u8)((140.0f * sp68) + 115.0f), spD3); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 155, 255, maxColor, (u8)((140.0f * sp68) + 115.0f), spD3); gSPDisplayList(POLY_XLU_DISP++, object_knight_DL_018CF0); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0xFF, 255, 255, (u8)((100.0f * sp68) + 65.0f), spD2); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 255, 255, maxColor, (u8)((100.0f * sp68) + 65.0f), spD2); gSPDisplayList(POLY_XLU_DISP++, object_knight_DL_018DE0); + + if (1) {} } if (this->unk_144 & 1) { @@ -603,7 +605,7 @@ void Boss06_Draw(Actor* thisx, GlobalContext* globalCtx2) { func_809F2120(1, 0x71A5, 0x263A); gDPSetEnvColor(POLY_XLU_DISP++, 255, 10, 0, 0); - gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 0, 230); + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 128, 255, 255, 0, 230); for (i = 0; i < ARRAY_COUNT(D_809F4370); i++) { if ((fabsf(D_809F4370[i].x - 32.0f) < 30.0f) && (fabsf(D_809F4370[i].y - 32.0f) < 30.0f)) { @@ -621,7 +623,7 @@ void Boss06_Draw(Actor* thisx, GlobalContext* globalCtx2) { Matrix_InsertYRotation_f(M_PI, MTXMODE_APPLY); } - Matrix_Scale(-0.002f, -this->unk_1D8, 1.0f, MTXMODE_APPLY); + Matrix_Scale(-0.02f / 10.0f, -this->unk_1D8, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -642,7 +644,7 @@ void Boss06_Draw(Actor* thisx, GlobalContext* globalCtx2) { this->actor.world.pos.y + 84.0f + this->unk_1B4, (this->actor.world.pos.z - 2.0f) + spE0, MTXMODE_NEW); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023348); + gSPDisplayList(POLY_XLU_DISP++, gLightOrb1DL); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, (u8)((140.0f * sp68) + 115.0f), temp_s2); gDPSetEnvColor(POLY_XLU_DISP++, 255, 205, (u8)((100.0f * sp68) + 65.0f), 128); @@ -650,11 +652,8 @@ void Boss06_Draw(Actor* thisx, GlobalContext* globalCtx2) { Matrix_InsertZRotation_s(globalCtx->gameplayFrames * 64, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023428); + gSPDisplayList(POLY_XLU_DISP++, gLightOrbVtxDL); } CLOSE_DISPS(globalCtx->state.gfxCtx); } -#else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_06/Boss06_Draw.s") -#endif diff --git a/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c b/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c index 18be6991c1..108f128aed 100644 --- a/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c +++ b/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c @@ -5,6 +5,8 @@ */ #include "z_demo_effect.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_efc_tw/object_efc_tw.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -15,11 +17,14 @@ void DemoEffect_Destroy(Actor* thisx, GlobalContext* globalCtx); void DemoEffect_Update(Actor* thisx, GlobalContext* globalCtx); void func_808CD940(DemoEffect* this, GlobalContext* globalCtx); +void func_808CD998(DemoEffect* this, GlobalContext* globalCtx); void func_808CDBDC(DemoEffect* this, GlobalContext* globalCtx); void func_808CDCEC(DemoEffect* this, GlobalContext* globalCtx); void func_808CDD70(DemoEffect* this, GlobalContext* globalCtx); +void func_808CDDE0(DemoEffect* this, GlobalContext* globalCtx); +void func_808CDFF8(Actor* thisx, GlobalContext* globalCtx); +void func_808CE078(Actor* thisx, GlobalContext* globalCtx2); -#if 0 const ActorInit Demo_Effect_InitVars = { ACTOR_DEMO_EFFECT, ACTORCAT_BG, @@ -32,33 +37,287 @@ const ActorInit Demo_Effect_InitVars = { (ActorFunc)NULL, }; -#endif +void DemoEffect_Init(Actor* thisx, GlobalContext* globalCtx) { + static s16 D_808CE2C0[] = { + OBJECT_EFC_TW, OBJECT_EFC_TW, OBJECT_EFC_TW, OBJECT_EFC_TW, GAMEPLAY_KEEP, + GAMEPLAY_KEEP, GAMEPLAY_KEEP, GAMEPLAY_KEEP, GAMEPLAY_KEEP, + }; + s32 pad; + DemoEffect* this = THIS; + s32 sp3C = DEMOEFFECT_GET_FF(&this->actor); + s32 phi_v1; + s32 pad2; + Color_RGB8 sp24[] = { + { 200, 200, 0 }, { 255, 40, 100 }, { 50, 255, 0 }, { 0, 0, 255 }, { 255, 255, 80 }, + }; -extern UNK_TYPE D_06000050; -extern UNK_TYPE D_06000060; + if (D_808CE2C0[sp3C] == 1) { + phi_v1 = 0; + } else { + phi_v1 = Object_GetIndex(&globalCtx->objectCtx, D_808CE2C0[sp3C]); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Effect/DemoEffect_Init.s") + if (phi_v1 >= 0) { + this->unk_164 = phi_v1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Effect/DemoEffect_Destroy.s") + Actor_SetScale(&this->actor, 0.2f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Effect/func_808CD940.s") + switch (sp3C) { + case 0: + case 1: + this->actor.flags |= ACTOR_FLAG_2000000; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Effect/func_808CD998.s") + case 2: + case 3: + this->unk_174 = func_808CDFF8; + this->unk_170 = func_808CD998; + this->unk_168[0] = 0; + this->unk_168[1] = 100; + this->unk_168[2] = 255; + SkelCurve_Clear(&this->skelCurve); + this->unk_16C = 0; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Effect/func_808CDAD0.s") + case 4: + case 5: + case 6: + case 7: + case 8: + this->unk_168[0] = sp24[sp3C - 4].r; + this->unk_168[1] = sp24[sp3C - 4].g; + this->unk_168[2] = sp24[sp3C - 4].b; + Actor_SetScale(&this->actor, 0.0f); + this->unk_174 = func_808CE078; + this->unk_170 = func_808CDDE0; + this->unk_16C = 0; + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Effect/func_808CDBDC.s") + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); + this->actionFunc = func_808CD940; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Effect/func_808CDCEC.s") +u8 D_808CE2D4[] = { + 1, 1, 2, 0, 1, 1, 2, 0, 1, 2, 0, 2, 1, 0, 1, 0, 2, 0, 2, 2, 0, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Effect/func_808CDD70.s") +void DemoEffect_Destroy(Actor* thisx, GlobalContext* globalCtx) { + DemoEffect* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Effect/func_808CDDE0.s") + switch (DEMOEFFECT_GET_FF(&this->actor)) { + case 0: + case 1: + case 2: + case 3: + SkelCurve_Destroy(globalCtx, &this->skelCurve); + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Effect/DemoEffect_Update.s") +void func_808CD940(DemoEffect* this, GlobalContext* globalCtx) { + if (Object_IsLoaded(&globalCtx->objectCtx, this->unk_164)) { + this->actor.objBankIndex = this->unk_164; + this->actor.draw = this->unk_174; + this->actionFunc = this->unk_170; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Effect/func_808CDE78.s") +void func_808CD998(DemoEffect* this, GlobalContext* globalCtx) { + s32 sp34 = DEMOEFFECT_GET_FF(&this->actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Effect/func_808CDFF8.s") + if (SkelCurve_Init(globalCtx, &this->skelCurve, &object_efc_tw_Skel_0012E8, &object_efc_tw_CurveAnim_000050)) {} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Effect/func_808CE078.s") + SkelCurve_SetAnim(&this->skelCurve, &object_efc_tw_CurveAnim_000050, 1.0f, 59.0f, 1.0f, 1.7f); + SkelCurve_Update(globalCtx, &this->skelCurve); + this->actionFunc = func_808CDCEC; + + switch (sp34) { + case 0: + Actor_SetScale(&this->actor, 0.16800001f); + break; + + case 1: + Actor_SetScale(&this->actor, 0.08400001f); + break; + + case 2: + Actor_SetScale(&this->actor, 0.16800001f); + break; + + case 3: + Actor_SetScale(&this->actor, 0.28f); + break; + + default: + Actor_SetScale(&this->actor, 0.014f); + break; + } +} + +void func_808CDAD0(f32 arg0) { + s32 i; + Vtx* temp_v0 = Lib_SegmentedToVirtual(object_efc_tw_Vtx_000060); + u8 sp24[3]; + + sp24[0] = 0; + sp24[1] = (s8)(202.0f * arg0); + sp24[2] = (s8)(255.0f * arg0); + + for (i = 0; i < ARRAY_COUNT(D_808CE2D4); i++) { + if (D_808CE2D4[i] != 0) { + temp_v0[i].v.cn[3] = sp24[D_808CE2D4[i]]; + } + } +} + +void func_808CDBDC(DemoEffect* this, GlobalContext* globalCtx) { + s32 params = DEMOEFFECT_GET_FF(&this->actor); + f32 temp_f0; + f32 temp_f12; + + this->unk_16C++; + if (this->unk_16C <= 100) { + temp_f12 = (100 - this->unk_16C) * 0.01f; + temp_f0 = temp_f12 * 0.14f; + + switch (params) { + case 0: + temp_f0 *= 1.2f; + break; + + case 1: + temp_f0 *= 0.6f; + break; + + case 2: + temp_f0 *= 1.2f; + break; + + case 3: + temp_f0 *= 2.0f; + break; + } + + this->actor.scale.x = temp_f0; + this->actor.scale.z = temp_f0; + func_808CDAD0(temp_f12); + func_800B8FE8(&this->actor, NA_SE_EV_TIMETRIP_LIGHT - SFX_FLAG); + } else { + func_808CDAD0(1.0f); + Actor_MarkForDeath(&this->actor); + } +} + +void func_808CDCEC(DemoEffect* this, GlobalContext* globalCtx) { + func_800B8FE8(&this->actor, NA_SE_EV_TIMETRIP_LIGHT - SFX_FLAG); + + if (SkelCurve_Update(globalCtx, &this->skelCurve)) { + SkelCurve_SetAnim(&this->skelCurve, &object_efc_tw_CurveAnim_000050, 1.0f, 60.0f, 59.0f, 0.0f); + this->actionFunc = func_808CDBDC; + this->unk_16C = 0; + } +} + +void func_808CDD70(DemoEffect* this, GlobalContext* globalCtx) { + Actor_SetScale(&this->actor, this->actor.scale.x - 0.02f); + + this->unk_16C++; + if (this->actor.scale.x < 0.02f) { + Actor_MarkForDeath(&this->actor); + } +} + +void func_808CDDE0(DemoEffect* this, GlobalContext* globalCtx) { + Actor_SetScale(&this->actor, (this->actor.scale.x * 0.5f) + 0.2f); + + this->unk_16C++; + if (this->unk_16C >= 3) { + this->actionFunc = func_808CDD70; + } +} + +void DemoEffect_Update(Actor* thisx, GlobalContext* globalCtx) { + DemoEffect* this = THIS; + + this->actionFunc(this, globalCtx); +} + +s32 func_808CDE78(GlobalContext* globalCtx, SkelAnimeCurve* skelCuve, s32 limbIndex, Actor* thisx) { + s32 pad; + DemoEffect* this = THIS; + u32 sp4C = globalCtx->gameplayFrames; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 170, 255, 255, 255); + gDPSetEnvColor(POLY_XLU_DISP++, this->unk_168[0], this->unk_168[1], this->unk_168[2], 255); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (sp4C * 6) % 1024, 255 - ((sp4C * 16) % 256), 0x100, 0x40, + 1, (sp4C * 4) % 512, 127 - ((sp4C * 12) % 128), 0x80, 0x20)); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + if (limbIndex == 0) { + LimbTransform* transform = skelCuve->transforms; + + transform->scale.x = 0x400; + transform->scale.y = 0x400; + transform->scale.z = transform->scale.x; + } + + return true; +} + +void func_808CDFF8(Actor* thisx, GlobalContext* globalCtx) { + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + DemoEffect* this = THIS; + + OPEN_DISPS(gfxCtx); + + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 25); + + Matrix_Scale(2.0f, 2.0f, 2.0f, MTXMODE_APPLY); + SkelCurve_Draw(&this->actor, globalCtx, &this->skelCurve, func_808CDE78, NULL, 1, &this->actor); + + CLOSE_DISPS(gfxCtx); +} + +void func_808CE078(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + DemoEffect* this = THIS; + s16 sp46 = (this->unk_16C * 0x400) & 0xFFFF; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 255, 255); + gDPSetEnvColor(POLY_XLU_DISP++, this->unk_168[0], this->unk_168[1], this->unk_168[2], 255); + + Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_StatePush(); + Matrix_InsertZRotation_s(sp46, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023288); + + Matrix_StatePop(); + Matrix_InsertZRotation_s(sp46 * -1, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023288); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + D_801F4E32 = 1; + D_801F4E38.x = thisx->world.pos.x; + D_801F4E38.y = thisx->world.pos.y; + D_801F4E38.z = thisx->world.pos.z; + + D_801F4E44 = thisx->scale.x * 60.0f; + D_801F4E48 = thisx->scale.x * 50.0f; + D_801F4E4C = thisx->scale.x * 250.0f; +} diff --git a/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.h b/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.h index 1943f4387e..8216708c52 100644 --- a/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.h +++ b/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.h @@ -6,10 +6,20 @@ struct DemoEffect; typedef void (*DemoEffectActionFunc)(struct DemoEffect*, GlobalContext*); +typedef void (*DemoEffectUnkFunc)(struct DemoEffect*, GlobalContext*); +typedef void (*DemoEffectUnkFunc2)(Actor*, GlobalContext*); + +#define DEMOEFFECT_GET_FF(thisx) ((thisx)->params & 0xFF) typedef struct DemoEffect { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x34]; + /* 0x0144 */ SkelAnimeCurve skelCurve; + /* 0x0164 */ u8 unk_164; + /* 0x0165 */ UNK_TYPE1 unk_165[3]; + /* 0x0168 */ u8 unk_168[3]; + /* 0x016C */ s16 unk_16C; + /* 0x0170 */ DemoEffectUnkFunc unk_170; + /* 0x0174 */ DemoEffectUnkFunc2 unk_174; /* 0x0178 */ DemoEffectActionFunc actionFunc; } DemoEffect; // size = 0x17C diff --git a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c index 629ec5668e..b51fc64eca 100644 --- a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c +++ b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c @@ -633,7 +633,7 @@ void DemoKankyo_DrawMoonAndGiant(Actor* thisx, GlobalContext* globalCtx2) { Matrix_Scale(this->particles[i].scale * alphaScale, this->particles[i].scale * alphaScale, this->particles[i].scale * alphaScale, MTXMODE_APPLY); alphaScale = Math_Vec3f_DistXYZ(&worldPos, &globalCtx->view.eye) / 300.0f; - alphaScale = (alphaScale > 1.0f) ? 0.0f : (1.0f - alphaScale) > 1.0f ? 1.0f : 1.0f - alphaScale; + alphaScale = CLAMP(1.0f - alphaScale, 0.0f, 1.0f); if (this->actor.params == DEMO_KANKYO_TYPE_GIANTS) { this->particles[i].alpha = 255.0f * alphaScale; @@ -655,7 +655,7 @@ void DemoKankyo_DrawMoonAndGiant(Actor* thisx, GlobalContext* globalCtx2) { break; } - gSPDisplayList(POLY_XLU_DISP++, &gameplay_keep_DL_023348); + gSPDisplayList(POLY_XLU_DISP++, &gLightOrb1DL); Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); @@ -667,7 +667,7 @@ void DemoKankyo_DrawMoonAndGiant(Actor* thisx, GlobalContext* globalCtx2) { if (this->actor.params == DEMO_KANKYO_TYPE_GIANTS) { gSPDisplayList(POLY_XLU_DISP++, object_bubble_DL_001000); } else { - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023428); + gSPDisplayList(POLY_XLU_DISP++, gLightOrbVtxDL); } } } diff --git a/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.c b/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.c index a4c9b9dc38..aa25fddfdc 100644 --- a/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.c +++ b/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.c @@ -5,6 +5,7 @@ */ #include "z_demo_syoten.h" +#include "objects/object_syoten/object_syoten.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -15,7 +16,15 @@ void DemoSyoten_Destroy(Actor* thisx, GlobalContext* globalCtx); void DemoSyoten_Update(Actor* thisx, GlobalContext* globalCtx); void DemoSyoten_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80C16A64(DemoSyoten* this, GlobalContext* globalCtx); +void func_80C16A74(DemoSyoten* this, GlobalContext* globalCtx); +void func_80C16BD4(DemoSyoten* this, GlobalContext* globalCtx); +void func_80C16DD4(DemoSyoten* this, GlobalContext* globalCtx); +void func_80C16EAC(DemoSyoten* this, GlobalContext* globalCtx); +void func_80C17008(DemoSyoten* this, GlobalContext* globalCtx); +void func_80C173B4(Actor* thisx, GlobalContext* globalCtx); +void func_80C17690(Actor* thisx, GlobalContext* globalCtx); + const ActorInit Demo_Syoten_InitVars = { ACTOR_DEMO_SYOTEN, ACTORCAT_ITEMACTION, @@ -28,45 +37,539 @@ const ActorInit Demo_Syoten_InitVars = { (ActorFunc)DemoSyoten_Draw, }; -#endif +u8 D_80C177D0[] = { + 0, 1, 1, 0, 2, 2, 2, 2, 0, 0, 1, 0, 2, 2, 0, 1, 0, 2, 2, 0, 1, 0, 2, 2, 0, 1, 0, + 2, 2, 0, 1, 0, 1, 2, 2, 1, 2, 2, 0, 0, 0, 1, 1, 0, 2, 2, 2, 2, 0, 0, 1, 0, 2, 2, + 0, 1, 0, 2, 2, 0, 1, 0, 2, 2, 2, 0, 0, 2, 0, 1, 1, 0, 2, 2, 2, 0, 1, 0, 2, 2, 0, +}; -extern UNK_TYPE D_0600023C; -extern UNK_TYPE D_06001298; -extern UNK_TYPE D_060018C0; -extern UNK_TYPE D_06002880; +Color_RGBA8 D_80C17824[] = { + { 160, 100, 130, 255 }, + { 150, 120, 160, 255 }, + { 130, 90, 150, 255 }, + { 90, 70, 120, 255 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/DemoSyoten_Init.s") +Color_RGBA8 D_80C17834[] = { + { 110, 50, 80, 255 }, + { 120, 100, 130, 255 }, + { 90, 40, 100, 255 }, + { 60, 50, 100, 255 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/DemoSyoten_Destroy.s") +void DemoSyoten_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + DemoSyoten* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/func_80C16760.s") + Actor_SetScale(&this->actor, 0.3f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/func_80C16818.s") + this->actionFunc = func_80C16A64; + this->unk_3E4 = 0; + this->unk_3E6 = 0; + this->unk_3DC = NULL; + this->unk_3E0 = NULL; + this->unk_3F2 = 0; + this->unk_3D8 = 1.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/func_80C168D0.s") + switch (DEMOSYOTEN_GET_F(&this->actor)) { + case DEMOSYOTEN_F_0: + func_80183430(&this->unk_144, &object_syoten_Blob_001328, &object_syoten_Blob_00023C, this->unk_174, + this->unk_2A6, 0); + func_801835EC(&this->unk_144, &object_syoten_Blob_00023C); + this->actor.draw = NULL; + this->actionFunc = func_80C16A74; + this->actor.child = Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EFF_DUST, + this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 0, this->actor.shape.rot.y, 0, 0); + this->unk_3F0 = 0x215; + Actor_SetScale(&this->actor, 0.05f); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/func_80C16974.s") + case DEMOSYOTEN_F_1: + Actor_SetScale(&this->actor, 0.1f); + this->unk_3DC = object_syoten_DL_001370; + this->unk_3E0 = Lib_SegmentedToVirtual(&object_syoten_Matanimheader_001448); + this->unk_3E4 |= 1; + this->actionFunc = func_80C16BD4; + this->unk_3F0 = 0x215; + Actor_SetScale(&this->actor, 0.05f); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/func_80C16A64.s") + case DEMOSYOTEN_F_2: + this->unk_3DC = object_syoten_DL_001730; + this->unk_3E0 = Lib_SegmentedToVirtual(&object_syoten_Matanimheader_0018B8); + this->unk_3F0 = 0x216; + this->actionFunc = func_80C16DD4; + this->unk_3E4 |= 2; + Actor_SetScale(&this->actor, 4.0f); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/func_80C16A74.s") + case DEMOSYOTEN_F_3: + this->unk_3DC = object_syoten_DL_001DD0; + this->unk_3E0 = Lib_SegmentedToVirtual(&object_syoten_Matanimheader_002B98); + this->unk_3F0 = 0x218; + this->unk_3E4 |= 8; + this->actionFunc = func_80C16EAC; + Actor_SetScale(&this->actor, 0.5f); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/func_80C16BD4.s") + case DEMOSYOTEN_F_4: + this->unk_3DC = object_syoten_DL_002880; + this->unk_3E0 = Lib_SegmentedToVirtual(&object_syoten_Matanimheader_002B88); + this->unk_3E4 |= 2; + this->actionFunc = func_80C17008; + this->unk_3F0 = 0x217; + this->unk_3E4 |= 1; + this->unk_3E4 |= 8; + this->actor.draw = func_80C17690; + Actor_SetScale(&this->actor, 5.0f); + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/func_80C16DD4.s") +void DemoSyoten_Destroy(Actor* thisx, GlobalContext* globalCtx) { + DemoSyoten* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/func_80C16EAC.s") + if (DEMOSYOTEN_GET_F(&this->actor) == DEMOSYOTEN_F_0) { + func_8018349C(&this->unk_144); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/func_80C17008.s") +void func_80C16760(DemoSyoten* this, GlobalContext* globalCtx) { + s32 pad; + Vec3s* points; + Vec3f sp2C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/DemoSyoten_Update.s") + this->unk_3EC = 0; + if (DEMOSYOTEN_GET_7E00(&this->actor) != DEMOSYOTEN_7E00_3F) { + this->unk_3E8 = &globalCtx->setupPathList[DEMOSYOTEN_GET_7E00(&this->actor)]; + if (this->unk_3E8 != NULL) { + points = Lib_SegmentedToVirtual(this->unk_3E8->points); + Math_Vec3s_ToVec3f(&this->actor.world.pos, &points[0]); + this->unk_3EC++; + points++; + Math_Vec3s_ToVec3f(&sp2C, points); + this->actor.world.rot.y = Math_Vec3f_Yaw(&this->actor.world.pos, &sp2C); + this->actor.world.rot.x = Math_Vec3f_Pitch(&this->actor.world.pos, &sp2C); + } + } else { + this->unk_3E8 = NULL; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/func_80C170F8.s") +s32 func_80C16818(DemoSyoten* this) { + s32 pad; + Path* path = this->unk_3E8; + Vec3s* points; + Vec3f sp28; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/func_80C173B4.s") + if (path == NULL) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/func_80C17468.s") + points = Lib_SegmentedToVirtual(this->unk_3E8->points); + points += this->unk_3EC; + Math_Vec3s_ToVec3f(&sp28, points); + this->actor.world.rot.y = Math_Vec3f_Yaw(&this->actor.world.pos, &sp28); + this->actor.world.rot.x = Math_Vec3f_Pitch(&this->actor.world.pos, &sp28); + Actor_MoveWithoutGravityReverse(&this->actor); + if (Math_Vec3f_DistXYZ(&this->actor.world.pos, &sp28) < 2.0f) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/DemoSyoten_Draw.s") +void func_80C168D0(DemoSyoten* this, GlobalContext* globalCtx) { + s32 pad; + Path* path = this->unk_3E8; + Vec3s* points; + Vec3f sp30; + Vec3f sp24; + f32 sp20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/func_80C17690.s") + if (path != NULL) { + points = Lib_SegmentedToVirtual(this->unk_3E8->points); + points += this->unk_3EC; + Math_Vec3s_ToVec3f(&sp30, points); + Actor_GetProjectedPos(globalCtx, &sp30, &sp24, &sp20); + Math_Vec3f_Copy(&sp30, &this->actor.projectedPos); + sp30.z = sp30.y; + sp24.z = sp24.y; + this->actor.shape.rot.z = -Math_Vec3f_Yaw(&sp24, &sp30); + } +} + +void func_80C16974(f32 arg0) { + Vtx* vtx = Lib_SegmentedToVirtual(&object_syotenVtx_0018C0); + u8 sp20[3]; + s32 i; + + arg0 = CLAMP_MAX(arg0, 1.0f); + + sp20[0] = (s8)0.0f; + sp20[1] = (s8)(152.0f * arg0); + sp20[2] = (s8)(255.0f * arg0); + + for (i = 0; i < ARRAY_COUNT(D_80C177D0); i++, vtx++) { + vtx->v.cn[3] = sp20[D_80C177D0[i]]; + } +} + +void func_80C16A64(DemoSyoten* this, GlobalContext* globalCtx) { +} + +void func_80C16A74(DemoSyoten* this, GlobalContext* globalCtx) { + u16 temp_a0; + + func_80183DE0(&this->unk_144); + if (Cutscene_CheckActorAction(globalCtx, this->unk_3F0)) { + if ((globalCtx->csCtx.frames >= 160) && (globalCtx->csCtx.frames < 322)) { + func_800B9010(&this->actor, NA_SE_EV_IKANA_SOUL_LV - SFX_FLAG); + } else if (globalCtx->csCtx.frames == 322) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_IKANA_SOUL_TRANSFORM); + } + + temp_a0 = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->unk_3F0)]->action; + if (this->unk_3F2 != temp_a0) { + this->unk_3F2 = temp_a0; + switch (temp_a0) { + case 1: + this->actor.draw = NULL; + break; + + case 2: + this->actor.draw = func_80C173B4; + this->unk_3D8 = 1.0f; + break; + + case 3: + break; + + case 4: + this->actor.draw = NULL; + break; + } + } + + if (temp_a0 == 3) { + if (this->unk_3D8 > 0.0125f) { + this->unk_3D8 -= 0.0125f; + if (this->actor.child != NULL) { + this->actor.child->home.rot.z = 0x14; + } + } else { + this->actor.draw = NULL; + if (this->actor.child != NULL) { + this->actor.child->home.rot.z = 0; + } + } + } + } else { + this->actor.draw = NULL; + } +} + +void func_80C16BD4(DemoSyoten* this, GlobalContext* globalCtx) { + s32 pad; + u16 temp_a0; + + if (Cutscene_CheckActorAction(globalCtx, this->unk_3F0)) { + temp_a0 = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->unk_3F0)]->action; + if (this->unk_3F2 != temp_a0) { + this->unk_3F2 = temp_a0; + switch (temp_a0) { + default: + this->actor.draw = NULL; + break; + + case 1: + case 2: + this->actor.draw = NULL; + Actor_SetScale(&this->actor, 0.0f); + break; + + case 3: + this->actor.draw = DemoSyoten_Draw; + this->unk_3E4 &= ~4; + this->unk_3E4 |= 1; + this->actor.shape.rot.z = 0; + break; + + case 4: + this->actor.draw = DemoSyoten_Draw; + func_80C16760(this, globalCtx); + this->unk_3E4 |= 4; + this->unk_3E4 &= ~1; + break; + } + } + + switch (temp_a0) { + case 3: + if (this->actor.scale.x < 0.05f) { + this->actor.scale.x += 0.000625f; + } + Actor_SetScale(&this->actor, this->actor.scale.x); + break; + + case 4: + this->actor.speedXZ = + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->unk_3F0)]->urot.z * + 0.005493164f; + if (this->unk_3EC < this->unk_3E8->count) { + if (func_80C16818(this)) { + this->unk_3EC++; + } + func_80C168D0(this, globalCtx); + } + break; + } + } else { + this->actor.draw = NULL; + } +} + +void func_80C16DD4(DemoSyoten* this, GlobalContext* globalCtx) { + s32 pad; + u16 temp_a0; + + if (Cutscene_CheckActorAction(globalCtx, this->unk_3F0)) { + temp_a0 = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->unk_3F0)]->action; + if (this->unk_3F2 != temp_a0) { + this->unk_3F2 = temp_a0; + switch (temp_a0) { + case 1: + this->actor.draw = NULL; + break; + + case 2: + this->actor.draw = DemoSyoten_Draw; + this->unk_3E6 = -6; + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_DM_FLYING_GOD_DASH); + break; + } + } + + if ((temp_a0 == 2) && (this->unk_3E6 < 40)) { + this->unk_3E6++; + } + } else { + this->actor.draw = NULL; + } +} + +void func_80C16EAC(DemoSyoten* this, GlobalContext* globalCtx) { + s32 pad; + u16 temp_a0; + + if (Cutscene_CheckActorAction(globalCtx, this->unk_3F0)) { + temp_a0 = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->unk_3F0)]->action; + if (this->unk_3F2 != temp_a0) { + this->unk_3F2 = temp_a0; + switch (temp_a0) { + case 1: + this->actor.draw = NULL; + this->unk_3D8 = 0.0f; + Actor_SetScale(&this->actor, 0.5f); + break; + + case 2: + this->actor.draw = DemoSyoten_Draw; + break; + } + } + + if (temp_a0 == 2) { + if (this->actor.scale.x < 8.0f) { + this->actor.scale.x += 0.1875f; + } + + Actor_SetScale(&this->actor, this->actor.scale.x); + + if (this->unk_3D8 < 1.0f) { + this->unk_3D8 += 0.025f; + } + + if (this->unk_3D8 > 1.0f) { + this->unk_3D8 = 1.0f; + } + func_800B9010(&this->actor, NA_SE_EV_IKANA_PURIFICATION - SFX_FLAG); + } + } else { + this->actor.draw = NULL; + } + func_80C16974(this->unk_3D8); +} + +void func_80C17008(DemoSyoten* this, GlobalContext* globalCtx) { + u16 temp_a0; + + if (Cutscene_CheckActorAction(globalCtx, this->unk_3F0)) { + temp_a0 = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->unk_3F0)]->action; + if (this->unk_3F2 != temp_a0) { + this->unk_3F2 = temp_a0; + switch (temp_a0) { + case 1: + this->actor.draw = NULL; + break; + + case 2: + this->actor.draw = func_80C17690; + this->unk_3E6 = -10; + break; + } + } + + if ((temp_a0 == 2) && (this->unk_3E6 < 15)) { + this->unk_3E6++; + } + } else { + this->actor.draw = NULL; + } +} + +void DemoSyoten_Update(Actor* thisx, GlobalContext* globalCtx) { + DemoSyoten* this = THIS; + + this->actionFunc(this, globalCtx); +} + +s32 func_80C170F8(GlobalContext* globalCtx, UNK_TYPE arg1, s32 arg2, UNK_TYPE arg3, UNK_TYPE arg4, Actor* thisx) { + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + DemoSyoten* this = THIS; + + OPEN_DISPS(gfxCtx); + + switch (arg2) { + case 2: + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 240, 140, (s32)(this->unk_3D8 * 150.0f)); + break; + + case 4: + case 12: + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 240, 190, (s32)(this->unk_3D8 * 200.0f)); + break; + + case 6: + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 240, 150, (s32)(this->unk_3D8 * 150.0f)); + break; + + case 8: + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 240, 180, (s32)(this->unk_3D8 * 200.0f)); + break; + + case 10: + case 14: + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 240, 170, (s32)(this->unk_3D8 * 150.0f)); + break; + + case 16: + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 240, 160, (s32)(this->unk_3D8 * 200.0f)); + break; + } + + CLOSE_DISPS(gfxCtx); + return true; +} + +void func_80C173B4(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + DemoSyoten* this = THIS; + Mtx* matrix; + + AnimatedMat_DrawXlu(globalCtx, Lib_SegmentedToVirtual(&object_syoten_Matanimheader_001298)); + + matrix = GRAPH_ALLOC(globalCtx->state.gfxCtx, ALIGN16(sizeof(Mtx) * this->unk_144.unk_18->unk_1)); + + if (matrix != NULL) { + func_8012C2DC(globalCtx->state.gfxCtx); + Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + func_8018450C(globalCtx, &this->unk_144, matrix, (void*)func_80C170F8, 0, &this->actor); + } +} + +void func_80C17468(GlobalContext* globalCtx) { + Color_RGBA8 sp2C; + Color_RGBA8 sp28; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_800FE7A8(D_80C17824, &sp2C); + func_800FE7A8(D_80C17834, &sp28); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, sp2C.r, sp2C.g, sp2C.b, 255); + gDPSetEnvColor(POLY_XLU_DISP++, sp28.r, sp28.g, sp28.b, 255); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void DemoSyoten_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + DemoSyoten* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + if (this->unk_3E4 & 4) { + Matrix_InsertZRotation_s(-this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_Scale(1.0f, 5.0f, 1.0f, MTXMODE_APPLY); + } + + if (this->unk_3E4 & 1) { + Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + } + + if (this->unk_3E4 & 8) { + func_80C17468(globalCtx); + } + + if (this->unk_3E0 != NULL) { + if (this->unk_3E4 & 2) { + AnimatedMat_DrawStepXlu(globalCtx, this->unk_3E0, this->unk_3E6); + } else { + AnimatedMat_DrawXlu(globalCtx, this->unk_3E0); + } + } + + if (this->unk_3DC != NULL) { + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, this->unk_3DC); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80C17690(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + DemoSyoten* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + Matrix_RotateY(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), MTXMODE_APPLY); + + if (this->unk_3E4 & 8) { + func_80C17468(globalCtx); + } + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + AnimatedMat_DrawStepXlu(globalCtx, this->unk_3E0, this->unk_3E6); + + gSPDisplayList(POLY_XLU_DISP++, object_syoten_DL_002880); + + AnimatedMat_DrawStepXlu(globalCtx, this->unk_3E0, this->unk_3E6 + 5); + + gSPDisplayList(POLY_XLU_DISP++, object_syoten_DL_002A20); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.h b/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.h index 26f9902eb7..204243f47c 100644 --- a/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.h +++ b/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.h @@ -7,9 +7,33 @@ struct DemoSyoten; typedef void (*DemoSyotenActionFunc)(struct DemoSyoten*, GlobalContext*); +#define DEMOSYOTEN_GET_F(thisx) ((thisx)->params & 0xF) +#define DEMOSYOTEN_GET_7E00(thisx) (((thisx)->params & 0x7E00) >> 9) + +#define DEMOSYOTEN_7E00_3F 0x3F + +enum { + /* 0 */ DEMOSYOTEN_F_0, + /* 1 */ DEMOSYOTEN_F_1, + /* 2 */ DEMOSYOTEN_F_2, + /* 3 */ DEMOSYOTEN_F_3, + /* 4 */ DEMOSYOTEN_F_4 +}; + typedef struct DemoSyoten { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x2B0]; + /* 0x0144 */ SkeletonInfo unk_144; + /* 0x0174 */ Vec3s unk_174[51]; + /* 0x02A6 */ s16 unk_2A6[153]; + /* 0x03D8 */ f32 unk_3D8; + /* 0x03DC */ Gfx* unk_3DC; + /* 0x03E0 */ AnimatedMaterial* unk_3E0; + /* 0x03E4 */ u16 unk_3E4; + /* 0x03E6 */ s16 unk_3E6; + /* 0x03E8 */ Path* unk_3E8; + /* 0x03EC */ s32 unk_3EC; + /* 0x03F0 */ u16 unk_3F0; + /* 0x03F2 */ u16 unk_3F2; /* 0x03F4 */ DemoSyotenActionFunc actionFunc; } DemoSyoten; // size = 0x3F8 diff --git a/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.c b/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.c index 29a85569e3..579db02bf3 100644 --- a/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.c +++ b/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.c @@ -65,7 +65,7 @@ void DemoTreLgt_Init(Actor* thisx, GlobalContext* globalCtx) { this->colorAlpha2 = 255; this->status = 0; //! @bug Zora Link should also use animationType 0 - if (gSaveContext.playerForm == PLAYER_FORM_FIERCE_DEITY) { + if (gSaveContext.save.playerForm == PLAYER_FORM_FIERCE_DEITY) { this->animationType = 0; } else { this->animationType = 1; diff --git a/src/overlays/actors/ovl_Dm_An/z_dm_an.c b/src/overlays/actors/ovl_Dm_An/z_dm_an.c index e6175bfd95..2c23601f75 100644 --- a/src/overlays/actors/ovl_Dm_An/z_dm_an.c +++ b/src/overlays/actors/ovl_Dm_An/z_dm_an.c @@ -5,6 +5,8 @@ */ #include "z_dm_an.h" +#include "objects/object_an4/object_an4.h" +#include "objects/object_msmo/object_msmo.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) @@ -17,8 +19,8 @@ void DmAn_Update(Actor* thisx, GlobalContext* globalCtx); void func_80C1C958(DmAn* this, GlobalContext* globalCtx); void func_80C1CAB0(DmAn* this, GlobalContext* globalCtx); void func_80C1CC80(DmAn* this, GlobalContext* globalCtx); +void func_80C1D0B0(Actor* this, GlobalContext* globalCtx); -#if 0 const ActorInit Dm_An_InitVars = { ACTOR_DM_AN, ACTORCAT_NPC, @@ -31,37 +33,336 @@ const ActorInit Dm_An_InitVars = { (ActorFunc)NULL, }; -#endif +static AnimationInfoS sAnimations[] = { + { &object_an1_Anim_007E08, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_an1_Anim_0071E8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_an4_Anim_006CC0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_an1_Anim_013E1C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_an4_Anim_007E3C, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_an4_Anim_0088C0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_an4_Anim_0013C8, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_an4_Anim_002550, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_an4_Anim_00353C, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_an4_Anim_004498, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_an4_Anim_0060B4, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_an4_Anim_00041C, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_an4_Anim_004A78, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_an4_Anim_00506C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, +}; -extern UNK_TYPE D_06000E70; -extern UNK_TYPE D_06012618; +s32 func_80C1C410(DmAn* this, GlobalContext* globalCtx) { + s8 objectIndex = this->actor.objBankIndex; + s8 objectIndex2; + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_An/func_80C1C410.s") + if (this->unk_2C8 < 2) { + objectIndex2 = this->actor.objBankIndex; + } else { + objectIndex2 = this->unk_2AC; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_An/func_80C1C4D8.s") + if (objectIndex2 >= 0) { + gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objectIndex2].segment); + ret = SkelAnime_Update(&this->skelAnime); + gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objectIndex].segment); + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_An/func_80C1C5B4.s") +s32 func_80C1C4D8(DmAn* this, GlobalContext* globalCtx, s32 arg2) { + s8 objectIndex = this->actor.objBankIndex; + s8 objectIndex2; + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_An/func_80C1C62C.s") + if (arg2 < 2) { + objectIndex2 = this->actor.objBankIndex; + } else { + objectIndex2 = this->unk_2AC; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_An/func_80C1C83C.s") + if ((objectIndex2 >= 0) && (arg2 != this->unk_2C8)) { + gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objectIndex2].segment); + this->unk_2C8 = arg2; + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, arg2); + gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objectIndex].segment); + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_An/func_80C1C8E8.s") +void func_80C1C5B4(DmAn* this) { + if (DECR(this->unk_2BA) == 0) { + this->unk_2B8++; + if (this->unk_2B8 >= 4) { + this->unk_2BA = Rand_S16Offset(30, 30); + this->unk_2B8 = 0; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_An/func_80C1C958.s") +s32 func_80C1C62C(DmAn* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp40; + Vec3f sp34; + s16 sp32; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_An/func_80C1CAB0.s") + Math_Vec3f_Copy(&sp40, &this->unk_2B4->world.pos); + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); + sp32 = Math_Vec3f_Yaw(&sp34, &sp40); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_An/func_80C1CC80.s") + Math_ApproachS(&this->unk_2C0, (sp32 - this->unk_2C4) - this->actor.shape.rot.y, 4, 0x2AA8); + this->unk_2C0 = CLAMP(this->unk_2C0, -0x1FFE, 0x1FFE); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_An/DmAn_Init.s") + Math_ApproachS(&this->unk_2C4, (sp32 - this->unk_2C0) - this->actor.shape.rot.y, 4, 0x2AA8); + this->unk_2C4 = CLAMP(this->unk_2C4, -0x1C70, 0x1C70); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_An/DmAn_Destroy.s") + if (this->unk_2B4->id == ACTOR_PLAYER) { + sp40.y = ((Player*)this->unk_2B4)->bodyPartsPos[7].y + 3.0f; + } else { + Math_Vec3f_Copy(&sp40, &this->unk_2B4->focus.pos); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_An/DmAn_Update.s") + Math_Vec3f_Copy(&sp34, &this->actor.focus.pos); + Math_ApproachS(&this->unk_2BE, Math_Vec3f_Pitch(&sp34, &sp40) - this->unk_2C2, 4, 0x2AA8); + this->unk_2BE = CLAMP(this->unk_2BE, -0x1C70, 0x1C70); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_An/func_80C1CD80.s") + Math_ApproachS(&this->unk_2C2, Math_Vec3f_Pitch(&sp34, &sp40) - this->unk_2BE, 4, 0x2AA8); + this->unk_2C2 = CLAMP(this->unk_2C2, -0x1C70, 0x1C70); + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_An/func_80C1CEFC.s") +s32 func_80C1C83C(DmAn* this, GlobalContext* globalCtx) { + if (this->unk_2B4 != NULL) { + func_80C1C62C(this, globalCtx); + this->unk_2AE &= ~1; + this->unk_2AE |= 2; + } else if (this->unk_2AE & 2) { + this->unk_2AE &= ~2; + this->unk_2BE = 0; + this->unk_2C0 = 0; + this->unk_2C2 = 0; + this->unk_2C4 = 0; + this->unk_2BC = 20; + } else if (DECR(this->unk_2BC) == 0) { + this->unk_2AE |= 1; + } + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_An/func_80C1D0B0.s") +Actor* func_80C1C8E8(GlobalContext* globalCtx) { + Actor* tempActor; + Actor* foundActor = NULL; + + while (true) { + foundActor = SubS_FindActor(globalCtx, foundActor, ACTORCAT_NPC, ACTOR_DM_AH); + + if ((foundActor == NULL) || (foundActor->update != NULL)) { + break; + } + + tempActor = foundActor->next; + if (tempActor == NULL || NULL) { + foundActor = NULL; + break; + } + foundActor = tempActor; + } + return foundActor; +} + +void func_80C1C958(DmAn* this, GlobalContext* globalCtx) { + if ((this->unk_2AC >= 0) && SubS_IsObjectLoaded(this->unk_2AC, globalCtx) && (this->unk_2AD >= 0) && + SubS_IsObjectLoaded(this->unk_2AD, globalCtx)) { + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 14.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_an1_Skel_012618, NULL, this->jointTable, + this->morphTable, OBJECT_AN1_LIMB_MAX); + + this->unk_2C8 = -1; + func_80C1C4D8(this, globalCtx, 0); + this->actor.flags &= ~ACTOR_FLAG_1; + Actor_SetScale(&this->actor, 0.01f); + this->unk_2AE |= 1; + this->actor.draw = func_80C1D0B0; + + if ((globalCtx->sceneNum == SCENE_YADOYA) && (globalCtx->curSpawn == 4)) { + this->unk_2B4 = func_80C1C8E8(globalCtx); + func_80C1C4D8(this, globalCtx, 1); + this->actionFunc = func_80C1CC80; + } else { + this->actionFunc = func_80C1CAB0; + } + } +} + +void func_80C1CAB0(DmAn* this, GlobalContext* globalCtx) { + s32 sp28[] = { 0, 0, 12, 2, 4, 6, 8, 10, 11, 3 }; + u16 action; + s32 sp20; + + if (globalCtx->csCtx.state != 0) { + if (this->unk_2D0 == 0) { + this->unk_2B0 = 255; + this->unk_2D0 = 1; + this->unk_2D4 = 0; + this->unk_2CC = this->unk_2C8; + } + + if (Cutscene_CheckActorAction(globalCtx, 0x22D)) { + sp20 = Cutscene_GetActorActionIndex(globalCtx, 0x22D); + action = globalCtx->csCtx.actorActions[sp20]->action; + + if (this->unk_2B0 != (action & 0xFF)) { + this->unk_2B0 = action; + this->unk_2D4 = 1; + func_80C1C4D8(this, globalCtx, sp28[action]); + } + + switch (this->unk_2B0) { + case 2: + case 4: + case 5: + case 6: + case 7: + case 8: + if ((this->unk_2C8 == 12) || (this->unk_2C8 == 4) || (this->unk_2C8 == 6) || (this->unk_2C8 == 8)) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + func_80C1C4D8(this, globalCtx, this->unk_2C8 + 1); + } + } + break; + } + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, sp20); + } + } else if (this->unk_2D0 != 0) { + this->unk_2D0 = 0; + this->unk_2D4 = 0; + func_80C1C4D8(this, globalCtx, this->unk_2CC); + } +} + +void func_80C1CC80(DmAn* this, GlobalContext* globalCtx) { +} + +void DmAn_Init(Actor* thisx, GlobalContext* globalCtx) { + DmAn* this = THIS; + + this->unk_2AC = SubS_GetObjectIndex(OBJECT_AN4, globalCtx); + this->unk_2AD = SubS_GetObjectIndex(OBJECT_MSMO, globalCtx); + this->actionFunc = func_80C1C958; +} + +void DmAn_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void DmAn_Update(Actor* thisx, GlobalContext* globalCtx) { + DmAn* this = THIS; + + this->actionFunc(this, globalCtx); + + func_80C1C83C(this, globalCtx); + + if (this->actor.draw != NULL) { + func_80C1C410(this, globalCtx); + func_80C1C5B4(this); + } + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); +} + +Vec3f D_80C1D2C8 = { 450.0f, 700.0f, -760.0f }; +Vec3s D_80C1D2D4 = { 0x238C, 0, -0x3FFC }; +Vec3f D_80C1D2DC = { 1000.0f, 0.0f, 0.0f }; + +void func_80C1CD80(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + s32 pad[2]; + DmAn* this = THIS; + s8 sp2B = this->actor.objBankIndex; + s8 sp2A = this->unk_2AD; + + if ((limbIndex == OBJECT_AN1_LIMB_05) && (this->unk_2D4 != 0)) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_StatePush(); + Matrix_JointPosition(&D_80C1D2C8, &D_80C1D2D4); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[sp2A].segment); + gSPDisplayList(POLY_OPA_DISP++, gMoonMaskDL); + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[sp2B].segment); + + Matrix_StatePop(); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + + if (limbIndex == OBJECT_AN1_LIMB_09) { + Matrix_MultiplyVector3fByState(&D_80C1D2DC, &this->actor.focus.pos); + Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); + } +} + +void func_80C1CEFC(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { + DmAn* this = THIS; + s16 phi_v1; + s16 phi_v0; + + if (!(this->unk_2AE & 1)) { + if (this->unk_2AE & 2) { + phi_v0 = 1; + } else { + phi_v0 = 0; + } + phi_v1 = 1; + } else { + phi_v1 = 0; + phi_v0 = 0; + } + + if (limbIndex == OBJECT_AN1_LIMB_09) { + func_8013AD9C(this->unk_2BE + this->unk_2C2 + 0x4000, + this->unk_2C0 + this->unk_2C4 + this->actor.shape.rot.y + 0x4000, &this->unk_18C, &this->unk_1A4, + phi_v1, phi_v0); + Matrix_StatePop(); + Matrix_InsertTranslation(this->unk_18C.x, this->unk_18C.y, this->unk_18C.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateY(this->unk_1A4.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_1A4.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_1A4.z, MTXMODE_APPLY); + Matrix_StatePush(); + } else if (limbIndex == OBJECT_AN1_LIMB_02) { + func_8013AD9C(this->unk_2C2 + 0x4000, this->unk_2C4 + this->actor.shape.rot.y + 0x4000, &this->unk_194, + &this->unk_1AA, phi_v1, phi_v0); + Matrix_StatePop(); + Matrix_InsertTranslation(this->unk_194.x, this->unk_194.y, this->unk_194.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateY(this->unk_1AA.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_1AA.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_1AA.z, MTXMODE_APPLY); + Matrix_StatePush(); + } +} + +TexturePtr D_80C1D2E8[] = { + object_an1_Tex_00E6E0, + &object_an1_Tex_00F7A0, + &object_an1_Tex_0101A0, +}; + +TexturePtr D_80C1D2F4[] = { + &object_an1_Tex_00E1E0, &object_an1_Tex_00EFA0, &object_an1_Tex_00F3A0, &object_an1_Tex_00EFA0, + &object_an1_Tex_00FDA0, &object_an1_Tex_00F9A0, &object_an1_Tex_0103A0, +}; + +void func_80C1D0B0(Actor* thisx, GlobalContext* globalCtx) { + DmAn* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80C1D2F4[this->unk_2B8])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80C1D2E8[0])); + + SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, NULL, func_80C1CD80, func_80C1CEFC, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Dm_An/z_dm_an.h b/src/overlays/actors/ovl_Dm_An/z_dm_an.h index 70fcaa8521..1b2b6f354e 100644 --- a/src/overlays/actors/ovl_Dm_An/z_dm_an.h +++ b/src/overlays/actors/ovl_Dm_An/z_dm_an.h @@ -2,6 +2,7 @@ #define Z_DM_AN_H #include "global.h" +#include "objects/object_an1/object_an1.h" struct DmAn; @@ -9,9 +10,30 @@ typedef void (*DmAnActionFunc)(struct DmAn*, GlobalContext*); typedef struct DmAn { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; + /* 0x0144 */ SkelAnime skelAnime; /* 0x0188 */ DmAnActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x14C]; + /* 0x018C */ Vec3f unk_18C; + /* 0x018C */ Vec3f unk_194; + /* 0x01A4 */ Vec3s unk_1A4; + /* 0x01A4 */ Vec3s unk_1AA; + /* 0x01B0 */ Vec3s jointTable[OBJECT_AN1_LIMB_MAX]; + /* 0x022E */ Vec3s morphTable[OBJECT_AN1_LIMB_MAX]; + /* 0x02AC */ s8 unk_2AC; + /* 0x02AD */ s8 unk_2AD; + /* 0x02AE */ u16 unk_2AE; + /* 0x02B0 */ u8 unk_2B0; + /* 0x02B4 */ Actor* unk_2B4; + /* 0x02B8 */ s16 unk_2B8; + /* 0x02BA */ s16 unk_2BA; + /* 0x02BC */ s16 unk_2BC; + /* 0x02BE */ s16 unk_2BE; + /* 0x02C0 */ s16 unk_2C0; + /* 0x02C2 */ s16 unk_2C2; + /* 0x02C4 */ s16 unk_2C4; + /* 0x02C8 */ s32 unk_2C8; + /* 0x02CC */ s32 unk_2CC; + /* 0x02D0 */ s32 unk_2D0; + /* 0x02D4 */ s32 unk_2D4; } DmAn; // size = 0x2D8 extern const ActorInit Dm_An_InitVars; diff --git a/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c b/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c index 959207b8d5..b4537b1af5 100644 --- a/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c +++ b/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c @@ -66,7 +66,7 @@ void DmChar01_Init(Actor* thisx, GlobalContext* globalCtx) { switch (DMCHAR01_GET(&this->dyna.actor)) { case DMCHAR01_0: - if (gSaveContext.weekEventReg[20] & 2) { + if (gSaveContext.save.weekEventReg[20] & 2) { this->unk_34C = 2; this->actionFunc = func_80AA8F1C; break; @@ -96,7 +96,7 @@ void DmChar01_Init(Actor* thisx, GlobalContext* globalCtx) { break; case DMCHAR01_1: - if ((gSaveContext.weekEventReg[20] & 2) || (gSaveContext.sceneSetupIndex == 1)) { + if ((gSaveContext.save.weekEventReg[20] & 2) || (gSaveContext.sceneSetupIndex == 1)) { this->unk_34C = 1; this->actionFunc = func_80AA8F1C; } else { @@ -106,7 +106,7 @@ void DmChar01_Init(Actor* thisx, GlobalContext* globalCtx) { case DMCHAR01_2: this->unk_34C = 0; - if (!(gSaveContext.weekEventReg[20] & 1)) { + if (!(gSaveContext.save.weekEventReg[20] & 1)) { this->unk_34C = 1; this->dyna.actor.world.pos.y -= 400.0f; } @@ -122,7 +122,7 @@ void DmChar01_Init(Actor* thisx, GlobalContext* globalCtx) { case DMCHAR01_3: this->dyna.actor.world.rot.y += 0x8000; this->dyna.actor.shape.rot.y += 0x8000; - if (!(gSaveContext.weekEventReg[20] & 1)) { + if (!(gSaveContext.save.weekEventReg[20] & 1)) { Actor_MarkForDeath(&this->dyna.actor); return; } @@ -132,7 +132,7 @@ void DmChar01_Init(Actor* thisx, GlobalContext* globalCtx) { DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_mtoride_Colheader_00FE5C); this->unk_34D = true; - if (!(gSaveContext.weekEventReg[20] & 2)) { + if (!(gSaveContext.save.weekEventReg[20] & 2)) { this->actionFunc = func_80AA9020; this->dyna.actor.world.pos.y -= 120.0f; } else { @@ -158,7 +158,7 @@ void func_80AA8698(DmChar01* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); Player* player2 = GET_PLAYER(globalCtx); - if (gSaveContext.weekEventReg[20] & 1) { + if (gSaveContext.save.weekEventReg[20] & 1) { return; } @@ -178,7 +178,7 @@ void func_80AA8698(DmChar01* this, GlobalContext* globalCtx) { if ((player2->actor.world.pos.x > -40.0f) && (player2->actor.world.pos.x < 40.0f) && (player2->actor.world.pos.z > 1000.0f) && (player2->actor.world.pos.z < 1078.0f)) { - gSaveContext.weekEventReg[20] |= 1; + gSaveContext.save.weekEventReg[20] |= 1; this->actionFunc = func_80AA884C; } } @@ -344,7 +344,7 @@ void func_80AA9020(DmChar01* this, GlobalContext* globalCtx) { CsCmdActorAction* temp_v1 = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 135)]; if ((temp_v1->startFrame == globalCtx->csCtx.frames) && (temp_v1->action == 2)) { - gSaveContext.weekEventReg[20] |= 2; + gSaveContext.save.weekEventReg[20] |= 2; this->actionFunc = func_80AA90AC; } } diff --git a/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c b/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c index c2edb33a0e..88a99ad533 100644 --- a/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c +++ b/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c @@ -5,6 +5,8 @@ */ #include "z_dm_gm.h" +#include "objects/object_an4/object_an4.h" +#include "objects/object_msmo/object_msmo.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) @@ -17,8 +19,8 @@ void DmGm_Update(Actor* thisx, GlobalContext* globalCtx); void func_80C248A8(DmGm* this, GlobalContext* globalCtx); void func_80C24A00(DmGm* this, GlobalContext* globalCtx); void func_80C24BD0(DmGm* this, GlobalContext* globalCtx); +void func_80C25000(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Dm_Gm_InitVars = { ACTOR_DM_GM, ACTORCAT_NPC, @@ -31,37 +33,337 @@ const ActorInit Dm_Gm_InitVars = { (ActorFunc)NULL, }; -#endif +static AnimationInfoS sAnimations[] = { + { &object_an1_Anim_007E08, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_an1_Anim_0071E8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_an4_Anim_006CC0, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_an1_Anim_013E1C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_an4_Anim_007E3C, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_an4_Anim_0088C0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_an4_Anim_0013C8, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_an4_Anim_002550, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_an4_Anim_00353C, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_an4_Anim_004498, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_an4_Anim_0060B4, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_an4_Anim_00041C, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_an4_Anim_004A78, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_an4_Anim_00506C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, +}; -extern UNK_TYPE D_06000E70; -extern UNK_TYPE D_06012618; +s32 func_80C24360(DmGm* this, GlobalContext* globalCtx) { + s8 objectIndex = this->actor.objBankIndex; + s8 objectIndex2; + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/func_80C24360.s") + if (this->unk_2C8 < 2) { + objectIndex2 = this->actor.objBankIndex; + } else { + objectIndex2 = this->unk_2AC; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/func_80C24428.s") + if (objectIndex2 >= 0) { + gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objectIndex2].segment); + ret = SkelAnime_Update(&this->skelAnime); + gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objectIndex].segment); + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/func_80C24504.s") +s32 func_80C24428(DmGm* this, GlobalContext* globalCtx, s32 arg2) { + s8 objectIndex = this->actor.objBankIndex; + s8 objectIndex2; + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/func_80C2457C.s") + if (arg2 < 2) { + objectIndex2 = this->actor.objBankIndex; + } else { + objectIndex2 = this->unk_2AC; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/func_80C2478C.s") + if ((objectIndex2 >= 0) && (arg2 != this->unk_2C8)) { + gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objectIndex2].segment); + this->unk_2C8 = arg2; + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, arg2); + gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objectIndex].segment); + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/func_80C24838.s") +void func_80C24504(DmGm* this) { + if (DECR(this->unk_2BA) == 0) { + this->unk_2B8++; + if (this->unk_2B8 >= 4) { + this->unk_2BA = Rand_S16Offset(30, 30); + this->unk_2B8 = 0; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/func_80C248A8.s") +s32 func_80C2457C(DmGm* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp40; + Vec3f sp34; + s16 sp32; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/func_80C24A00.s") + Math_Vec3f_Copy(&sp40, &this->unk_2B4->world.pos); + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); + sp32 = Math_Vec3f_Yaw(&sp34, &sp40); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/func_80C24BD0.s") + Math_ApproachS(&this->unk_2C0, (sp32 - this->unk_2C4) - this->actor.shape.rot.y, 4, 0x2AA8); + this->unk_2C0 = CLAMP(this->unk_2C0, -0x1FFE, 0x1FFE); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/DmGm_Init.s") + Math_ApproachS(&this->unk_2C4, (sp32 - this->unk_2C0) - this->actor.shape.rot.y, 4, 0x2AA8); + this->unk_2C4 = CLAMP(this->unk_2C4, -0x1C70, 0x1C70); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/DmGm_Destroy.s") + if (this->unk_2B4->id == ACTOR_PLAYER) { + sp40.y = ((Player*)this->unk_2B4)->bodyPartsPos[7].y + 3.0f; + } else { + Math_Vec3f_Copy(&sp40, &this->unk_2B4->focus.pos); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/DmGm_Update.s") + Math_Vec3f_Copy(&sp34, &this->actor.focus.pos); + Math_ApproachS(&this->unk_2BE, Math_Vec3f_Pitch(&sp34, &sp40) - this->unk_2C2, 4, 0x2AA8); + this->unk_2BE = CLAMP(this->unk_2BE, -0x1C70, 0x1C70); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/func_80C24CD0.s") + Math_ApproachS(&this->unk_2C2, Math_Vec3f_Pitch(&sp34, &sp40) - this->unk_2BE, 4, 0x2AA8); + this->unk_2C2 = CLAMP(this->unk_2C2, -0x1C70, 0x1C70); + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/func_80C24E4C.s") +s32 func_80C2478C(DmGm* this, GlobalContext* globalCtx) { + if (this->unk_2B4 != NULL) { + func_80C2457C(this, globalCtx); + this->unk_2AE &= ~1; + this->unk_2AE |= 2; + } else if (this->unk_2AE & 2) { + this->unk_2AE &= ~2; + this->unk_2BE = 0; + this->unk_2C0 = 0; + this->unk_2C2 = 0; + this->unk_2C4 = 0; + this->unk_2BC = 20; + } else if (DECR(this->unk_2BC) == 0) { + this->unk_2AE |= 1; + } + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/func_80C25000.s") +Actor* func_80C24838(GlobalContext* globalCtx) { + Actor* tempActor; + Actor* foundActor = NULL; + + while (true) { + foundActor = SubS_FindActor(globalCtx, foundActor, ACTORCAT_NPC, ACTOR_DM_AH); + + if ((foundActor == NULL) || (foundActor->update != NULL)) { + break; + } + + tempActor = foundActor->next; + if (tempActor == NULL || false) { + foundActor = NULL; + break; + } + foundActor = tempActor; + } + return foundActor; +} + +void func_80C248A8(DmGm* this, GlobalContext* globalCtx) { + if ((this->unk_2AC >= 0) && SubS_IsObjectLoaded(this->unk_2AC, globalCtx) && (this->unk_2AD >= 0) && + SubS_IsObjectLoaded(this->unk_2AD, globalCtx)) { + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 14.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_an1_Skel_012618, NULL, this->jointTable, + this->morphTable, OBJECT_AN1_LIMB_MAX); + + this->unk_2C8 = -1; + func_80C24428(this, globalCtx, 0); + this->actor.flags &= ~ACTOR_FLAG_1; + Actor_SetScale(&this->actor, 0.01f); + this->unk_2AE |= 1; + this->actor.draw = func_80C25000; + + if ((globalCtx->sceneNum == SCENE_YADOYA) && (globalCtx->curSpawn == 4)) { + this->unk_2B4 = func_80C24838(globalCtx); + func_80C24428(this, globalCtx, 1); + this->actionFunc = func_80C24BD0; + } else { + this->actionFunc = func_80C24A00; + } + } +} + +void func_80C24A00(DmGm* this, GlobalContext* globalCtx) { + s32 sp28[] = { 0, 0, 12, 2, 4, 6, 8, 10, 11, 3 }; + u16 action; + s32 sp20; + + if (globalCtx->csCtx.state != 0) { + if (this->unk_2D0 == 0) { + this->unk_2B0 = 255; + this->unk_2D0 = 1; + this->unk_2D4 = 0; + this->unk_2CC = this->unk_2C8; + } + + if (Cutscene_CheckActorAction(globalCtx, 0x22D)) { + sp20 = Cutscene_GetActorActionIndex(globalCtx, 0x22D); + action = globalCtx->csCtx.actorActions[sp20]->action; + + if (this->unk_2B0 != (action & 0xFF)) { + this->unk_2B0 = action; + this->unk_2D4 = 1; + func_80C24428(this, globalCtx, sp28[action]); + } + + switch (this->unk_2B0) { + case 2: + case 4: + case 5: + case 6: + case 7: + case 8: + if ((this->unk_2C8 == 12) || (this->unk_2C8 == 4) || (this->unk_2C8 == 6) || (this->unk_2C8 == 8)) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + func_80C24428(this, globalCtx, this->unk_2C8 + 1); + } + } + break; + } + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, sp20); + } + } else if (this->unk_2D0 != 0) { + this->unk_2D0 = 0; + this->unk_2D4 = 0; + func_80C24428(this, globalCtx, this->unk_2CC); + } +} + +void func_80C24BD0(DmGm* this, GlobalContext* globalCtx) { +} + +void DmGm_Init(Actor* thisx, GlobalContext* globalCtx) { + DmGm* this = THIS; + + this->unk_2AC = SubS_GetObjectIndex(OBJECT_AN4, globalCtx); + this->unk_2AD = SubS_GetObjectIndex(OBJECT_MSMO, globalCtx); + this->actionFunc = func_80C248A8; +} + +void DmGm_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void DmGm_Update(Actor* thisx, GlobalContext* globalCtx) { + DmGm* this = THIS; + + this->actionFunc(this, globalCtx); + + func_80C2478C(this, globalCtx); + + if (this->actor.draw != NULL) { + func_80C24360(this, globalCtx); + func_80C24504(this); + } + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); +} + +Vec3f D_80C25218 = { 450.0f, 700.0f, -760.0f }; +Vec3s D_80C25224 = { 0x238C, 0, -0x3FFC }; +Vec3f D_80C2522C = { 1000.0f, 0.0f, 0.0f }; + +void DmGm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + s32 pad[2]; + DmGm* this = THIS; + s8 sp2B = this->actor.objBankIndex; + s8 sp2A = this->unk_2AD; + + if ((limbIndex == OBJECT_AN1_LIMB_05) && (this->unk_2D4 != 0)) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_StatePush(); + Matrix_JointPosition(&D_80C25218, &D_80C25224); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[sp2A].segment); + gSPDisplayList(POLY_OPA_DISP++, gMoonMaskDL); + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[sp2B].segment); + + Matrix_StatePop(); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + + if (limbIndex == OBJECT_AN1_LIMB_09) { + Matrix_MultiplyVector3fByState(&D_80C2522C, &this->actor.focus.pos); + Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); + } +} + +void DmGm_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { + DmGm* this = THIS; + s16 phi_v1; + s16 phi_v0; + + if (!(this->unk_2AE & 1)) { + if (this->unk_2AE & 2) { + phi_v0 = 1; + } else { + phi_v0 = 0; + } + phi_v1 = 1; + } else { + phi_v1 = 0; + phi_v0 = 0; + } + + if (limbIndex == OBJECT_AN1_LIMB_09) { + func_8013AD9C(this->unk_2BE + this->unk_2C2 + 0x4000, + this->unk_2C0 + this->unk_2C4 + this->actor.shape.rot.y + 0x4000, &this->unk_18C, &this->unk_1A4, + phi_v1, phi_v0); + Matrix_StatePop(); + Matrix_InsertTranslation(this->unk_18C.x, this->unk_18C.y, this->unk_18C.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateY(this->unk_1A4.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_1A4.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_1A4.z, MTXMODE_APPLY); + Matrix_StatePush(); + } else if (limbIndex == OBJECT_AN1_LIMB_02) { + func_8013AD9C(this->unk_2C2 + 0x4000, this->unk_2C4 + this->actor.shape.rot.y + 0x4000, &this->unk_194, + &this->unk_1AA, phi_v1, phi_v0); + Matrix_StatePop(); + Matrix_InsertTranslation(this->unk_194.x, this->unk_194.y, this->unk_194.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateY(this->unk_1AA.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_1AA.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_1AA.z, MTXMODE_APPLY); + Matrix_StatePush(); + } +} + +TexturePtr D_80C25238[] = { + object_an1_Tex_00E6E0, + object_an1_Tex_00F7A0, + object_an1_Tex_0101A0, +}; + +TexturePtr D_80C25244[] = { + object_an1_Tex_00E1E0, object_an1_Tex_00EFA0, object_an1_Tex_00F3A0, object_an1_Tex_00EFA0, + object_an1_Tex_00FDA0, object_an1_Tex_00F9A0, object_an1_Tex_0103A0, +}; + +void func_80C25000(Actor* thisx, GlobalContext* globalCtx) { + DmGm* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80C25244[this->unk_2B8])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80C25238[0])); + + SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, NULL, DmGm_PostLimbDraw, DmGm_TransformLimbDraw, + &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.h b/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.h index 8b416d7b7f..6f2307378b 100644 --- a/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.h +++ b/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.h @@ -2,6 +2,7 @@ #define Z_DM_GM_H #include "global.h" +#include "objects/object_an1/object_an1.h" struct DmGm; @@ -9,9 +10,30 @@ typedef void (*DmGmActionFunc)(struct DmGm*, GlobalContext*); typedef struct DmGm { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; + /* 0x0144 */ SkelAnime skelAnime; /* 0x0188 */ DmGmActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x14C]; + /* 0x018C */ Vec3f unk_18C; + /* 0x018C */ Vec3f unk_194; + /* 0x01A4 */ Vec3s unk_1A4; + /* 0x01A4 */ Vec3s unk_1AA; + /* 0x01B0 */ Vec3s jointTable[OBJECT_AN1_LIMB_MAX]; + /* 0x022E */ Vec3s morphTable[OBJECT_AN1_LIMB_MAX]; + /* 0x02AC */ s8 unk_2AC; + /* 0x02AD */ s8 unk_2AD; + /* 0x02AE */ u16 unk_2AE; + /* 0x02B0 */ u8 unk_2B0; + /* 0x02B4 */ Actor* unk_2B4; + /* 0x02B8 */ s16 unk_2B8; + /* 0x02BA */ s16 unk_2BA; + /* 0x02BC */ s16 unk_2BC; + /* 0x02BE */ s16 unk_2BE; + /* 0x02C0 */ s16 unk_2C0; + /* 0x02C2 */ s16 unk_2C2; + /* 0x02C4 */ s16 unk_2C4; + /* 0x02C8 */ s32 unk_2C8; + /* 0x02CC */ s32 unk_2CC; + /* 0x02D0 */ s32 unk_2D0; + /* 0x02D4 */ s32 unk_2D4; } DmGm; // size = 0x2D8 extern const ActorInit Dm_Gm_InitVars; diff --git a/src/overlays/actors/ovl_Dm_Ravine/z_dm_ravine.c b/src/overlays/actors/ovl_Dm_Ravine/z_dm_ravine.c index 4c39ddd544..bb8b735a40 100644 --- a/src/overlays/actors/ovl_Dm_Ravine/z_dm_ravine.c +++ b/src/overlays/actors/ovl_Dm_Ravine/z_dm_ravine.c @@ -30,7 +30,7 @@ const ActorInit Dm_Ravine_InitVars = { void DmRavine_Init(Actor* thisx, GlobalContext* globalCtx) { DmRavine* this = THIS; - u8 flag = gSaveContext.weekEventReg[0]; + u8 flag = gSaveContext.save.weekEventReg[0]; if (((flag & 0x10) | cREG(0)) != 0) { Actor_MarkForDeath(&this->actor); return; diff --git a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c index b32140c83b..08e515d262 100644 --- a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c +++ b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c @@ -841,7 +841,7 @@ void DmStk_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_InitCylinder(globalCtx, &this->collider); - if (gSaveContext.entranceIndex == 0x2C00) { + if (gSaveContext.save.entranceIndex == 0x2C00) { if (gSaveContext.sceneSetupIndex == 0) { if (gSaveContext.unk_3DD0[3] == 0) { func_8010E9F0(3, 300); @@ -849,7 +849,7 @@ void DmStk_Init(Actor* thisx, GlobalContext* globalCtx) { XREG(81) = 115; } - if (gSaveContext.inventory.items[SLOT_OCARINA] == ITEM_NONE) { + if (gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) { sCylinderInit.base.colType = COLTYPE_WOOD; this->actionFunc = func_80AA18D8; } else { @@ -938,7 +938,7 @@ void func_80AA1704(DmStk* this, GlobalContext* globalCtx) { void func_80AA1714(DmStk* this, GlobalContext* globalCtx) { Vec3f sp1C; - if (!(gSaveContext.weekEventReg[74] & 0x20)) { + if (!(gSaveContext.save.weekEventReg[74] & 0x20)) { func_80169474(globalCtx, &this->actor.world.pos, &sp1C); if (globalCtx->view.fovy < 25.0f) { if ((sp1C.x >= 70.0f) && (sp1C.x < 250.0f) && (sp1C.y >= 30.0f) && (sp1C.y < 210.0f)) { @@ -955,10 +955,10 @@ void func_80AA17F8(DmStk* this, GlobalContext* globalCtx) { s16 sp18 = ActorCutscene_GetAdditionalCutscene(sp1C); s16 cutscene; - if (gSaveContext.day < 3) { + if (gSaveContext.save.day < 3) { cutscene = sp1E; - } else if ((gSaveContext.weekEventReg[8] & 0x40) || - ((CURRENT_DAY == 3) && (gSaveContext.time < CLOCK_TIME(6, 0)))) { + } else if ((gSaveContext.save.weekEventReg[8] & 0x40) || + ((CURRENT_DAY == 3) && (gSaveContext.save.time < CLOCK_TIME(6, 0)))) { cutscene = sp18; } else { cutscene = sp1C; @@ -1171,7 +1171,7 @@ void func_80AA1D1C(DmStk* this, GlobalContext* globalCtx) { case 22: this->unk_2E0 = 29; - if (gSaveContext.inventory.items[SLOT_OCARINA] == ITEM_NONE) { + if (gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) { this->unk_32D = 3; } break; @@ -1183,7 +1183,7 @@ void func_80AA1D1C(DmStk* this, GlobalContext* globalCtx) { case 24: this->unk_2E0 = 32; - if (gSaveContext.inventory.items[SLOT_OCARINA] == ITEM_NONE) { + if (gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) { this->unk_32D = 3; } break; @@ -1194,14 +1194,14 @@ void func_80AA1D1C(DmStk* this, GlobalContext* globalCtx) { case 26: this->unk_2E0 = 34; - if (gSaveContext.inventory.items[SLOT_OCARINA] == ITEM_NONE) { + if (gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) { this->unk_32D = 3; } break; case 27: this->unk_2E0 = 36; - if (gSaveContext.inventory.items[SLOT_OCARINA] == ITEM_NONE) { + if (gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) { this->unk_32D = 3; } break; @@ -1399,7 +1399,7 @@ void func_80AA1D1C(DmStk* this, GlobalContext* globalCtx) { if (this->unk_2E4 < 0) { this->unk_2E4 = 0; this->unk_32F = 0; - gSaveContext.weekEventReg[12] |= 4; + gSaveContext.save.weekEventReg[12] |= 4; if (!(globalCtx->actorCtx.unk5 & 2)) { Actor_MarkForDeath(&this->actor); } else { @@ -1566,14 +1566,14 @@ void DmStk_Update(Actor* thisx, GlobalContext* globalCtx) { } if ((globalCtx->actorCtx.unk5 & 2) && (globalCtx->msgCtx.msgMode != 0) && - (globalCtx->msgCtx.unk11F04 == 0x5E6) && !FrameAdvance_IsEnabled(&globalCtx->state) && + (globalCtx->msgCtx.currentTextId == 0x5E6) && !FrameAdvance_IsEnabled(&globalCtx->state) && (globalCtx->sceneLoadFlag == 0) && (ActorCutscene_GetCurrentIndex() == -1) && (globalCtx->csCtx.state == 0)) { - time = gSaveContext.time; - gSaveContext.time = (u16)REG(15) + time; + time = gSaveContext.save.time; + gSaveContext.save.time = (u16)REG(15) + time; if (REG(15) != 0) { - time = gSaveContext.time; - gSaveContext.time = (u16)gSaveContext.unk_14 + time; + time = gSaveContext.save.time; + gSaveContext.save.time = (u16)gSaveContext.save.daySpeed + time; } } } diff --git a/src/overlays/actors/ovl_Door_Ana/z_door_ana.c b/src/overlays/actors/ovl_Door_Ana/z_door_ana.c index 73d9911f99..0d1daa6b5c 100644 --- a/src/overlays/actors/ovl_Door_Ana/z_door_ana.c +++ b/src/overlays/actors/ovl_Door_Ana/z_door_ana.c @@ -52,8 +52,7 @@ static ColliderCylinderInit sCylinderInit = { { 50, 10, 0, { 0, 0, 0 } }, }; -// entrances grottos can link to statically, type DOORANA_TYPE_ADJACENT uses scene exit addresses instead -static u16 entrances[] = { +static u16 sEntranceIndexes[] = { 0x1A00, 0x1400, 0x1410, 0x1420, 0x1430, 0x1440, 0x1450, 0x1460, 0x1470, 0x1480, 0x1490, 0x14A0, 0x14B0, 0x14C0, 0x14D0, }; @@ -64,11 +63,12 @@ void DoorAna_SetupAction(DoorAna* this, DoorAnaActionFunc actionFunction) { void DoorAna_Init(Actor* thisx, GlobalContext* globalCtx) { DoorAna* this = THIS; - s32 grottoType = GET_DOORANA_TYPE(this); + s32 grottoType = DOORANA_GET_TYPE(&this->actor); + this->actor.shape.rot.y = this->actor.shape.rot.z = 0; - if ((grottoType == DOORANA_TYPE_UNK) || (grottoType == DOORANA_TYPE_HIDDEN)) { - if (grottoType == DOORANA_TYPE_HIDDEN) { + if (grottoType == DOORANA_TYPE_HIDDEN_STORMS || grottoType == DOORANA_TYPE_HIDDEN_BOMB) { + if (grottoType == DOORANA_TYPE_HIDDEN_BOMB) { Collider_InitAndSetCylinder(globalCtx, &this->bombCollider, &this->actor, &sCylinderInit); } else { this->actor.flags |= ACTOR_FLAG_10; // always update @@ -86,27 +86,27 @@ void DoorAna_Init(Actor* thisx, GlobalContext* globalCtx) { void DoorAna_Destroy(Actor* thisx, GlobalContext* globalCtx) { DoorAna* this = THIS; - s32 grottoType = GET_DOORANA_TYPE(this); + s32 grottoType = DOORANA_GET_TYPE(&this->actor); - if (grottoType == DOORANA_TYPE_HIDDEN) { + if (grottoType == DOORANA_TYPE_HIDDEN_BOMB) { Collider_DestroyCylinder(globalCtx, &this->bombCollider); } } void DoorAna_WaitClosed(DoorAna* this, GlobalContext* globalCtx) { - s32 grottoIsOpen = 0; - u32 grottoType = GET_DOORANA_TYPE(this); + s32 grottoIsOpen = false; + u32 grottoType = DOORANA_GET_TYPE(&this->actor); - if (grottoType == DOORANA_TYPE_UNK) { - // in OOT decomp its marked as open with storms, but does not seem to open with storms in MM - if ((this->actor.xyzDistToPlayerSq < SQ(200.0f)) && (EnvFlags_Get(globalCtx, 5))) { - grottoIsOpen = 1; + if (grottoType == DOORANA_TYPE_HIDDEN_STORMS) { + //! @bug Implementation from OoT is not updated for MM, grotto does not open on Song of Storms + if (this->actor.xyzDistToPlayerSq < SQ(200.0f) && EnvFlags_Get(globalCtx, 5)) { + grottoIsOpen = true; this->actor.flags &= ~ACTOR_FLAG_10; // always update OFF } } else { if (this->bombCollider.base.acFlags & AC_HIT) { // bomb collision - grottoIsOpen = 1; + grottoIsOpen = true; Collider_DestroyCylinder(globalCtx, &this->bombCollider); } else { @@ -116,7 +116,7 @@ void DoorAna_WaitClosed(DoorAna* this, GlobalContext* globalCtx) { } if (grottoIsOpen) { - this->actor.params &= ~DOORANA_TYPE_BITRANGE; + DOORANA_SET_TYPE(&this->actor, DOORANA_TYPE_VISIBLE); DoorAna_SetupAction(this, DoorAna_WaitOpen); play_sound(NA_SE_SY_CORRECT_CHIME); } @@ -126,56 +126,44 @@ void DoorAna_WaitClosed(DoorAna* this, GlobalContext* globalCtx) { void DoorAna_WaitOpen(DoorAna* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - s32 dooranaType = GET_DOORANA_TYPE(this); - s8 pad[4]; - s32 entranceIndex; - f32 playerHeightRel; + s32 grottoType = DOORANA_GET_TYPE(&this->actor); - if (Math_StepToF(&this->actor.scale.x, 0.01f, 0.001f) != 0) { - if ((this->actor.targetMode != 0) && (globalCtx->sceneLoadFlag == 0) && (globalCtx->unk_18B4A == 0) && - (player->stateFlags1 & 0x80000000) && (player->unk_AE7 == 0)) { + if (Math_StepToF(&this->actor.scale.x, 0.01f, 0.001f)) { + if (this->actor.targetMode != 0 && globalCtx->sceneLoadFlag == 0 && globalCtx->unk_18B4A == 0 && + (player->stateFlags1 & 0x80000000) && player->unk_AE7 == 0) { - if (dooranaType == DOORANA_TYPE_ADJACENT) { - s32 requiredScopeTemp; + if (grottoType == DOORANA_TYPE_VISIBLE_SCENE_EXIT) { + s32 exitIndex = DOORANA_GET_EXIT_INDEX(&this->actor); - // 300 uses scene exit addresses, not static DoorAna entrance addresses, - // eg. deku playground gets address in the NCT scene exit table - - entranceIndex = GET_DOORANA_ADJACENT_ENTRANCE(this); - globalCtx->nextEntranceIndex = globalCtx->setupExitList[entranceIndex]; + globalCtx->nextEntranceIndex = globalCtx->setupExitList[exitIndex]; } else { - // unused in vanilla, the highest params bits can directly index an address - entranceIndex = GET_DOORANA_DIRECT_ENTRANCE(this); + s32 destinationIdx = DOORANA_GET_ENTRANCE(&this->actor); - Play_SetupRespawnPoint(&globalCtx->state, 3, 0x4FF); + Play_SetupRespawnPoint(&globalCtx->state, RESPAWN_MODE_UNK_3, 0x4FF); - gSaveContext.respawn[3].pos.y = this->actor.world.pos.y; - gSaveContext.respawn[3].yaw = this->actor.home.rot.y; + gSaveContext.respawn[RESPAWN_MODE_UNK_3].pos.y = this->actor.world.pos.y; + gSaveContext.respawn[RESPAWN_MODE_UNK_3].yaw = this->actor.home.rot.y; - // save the params lower byte for En_Torch to decide what item to use in the grotto chest - gSaveContext.respawn[3].data = GET_DOORANA_ITEMFLAGS(this); + // Stores item and chest flag that ACTOR_EN_TORCH uses for spawning the grotto chest + gSaveContext.respawn[RESPAWN_MODE_UNK_3].data = DOORANA_GET_ITEMFLAGS(&this->actor); - // most grottos in the game use their zrotation as their entrance index, not params - if (DOORANA_TYPE_ROTATION_ENTRANCE(entranceIndex)) { - entranceIndex = GET_DOORANA_ROTATION_ENTRANCE(this); + if (destinationIdx < 0) { + destinationIdx = DOORANA_GET_EX_ENTRANCE(&this->actor); } - globalCtx->nextEntranceIndex = entrances[entranceIndex]; + globalCtx->nextEntranceIndex = sEntranceIndexes[destinationIdx]; } DoorAna_SetupAction(this, DoorAna_GrabLink); - } else { - if ((func_801690CC(globalCtx) == 0) && ((player->stateFlags1 & 0x08800000) == 0) && - (this->actor.xzDistToPlayer <= 20.0f) && - (playerHeightRel = this->actor.playerHeightRel, (playerHeightRel >= -50.0f)) && - (playerHeightRel <= 15.0f)) { - player->stateFlags1 |= 0x80000000; - this->actor.targetMode = 1; + } else if (!Play_InCsMode(globalCtx) && !(player->stateFlags1 & 0x08800000) && + (this->actor.xzDistToPlayer <= 20.0f) && (this->actor.playerHeightRel >= -50.0f) && + (this->actor.playerHeightRel <= 15.0f)) { + player->stateFlags1 |= 0x80000000; + this->actor.targetMode = 1; - } else { - this->actor.targetMode = 0; - } + } else { + this->actor.targetMode = 0; } } @@ -194,10 +182,10 @@ void DoorAna_GrabLink(DoorAna* this, GlobalContext* globalCtx) { } } - if ((this->actor.playerHeightRel <= 0.0f) && (this->actor.xzDistToPlayer > 20.0f)) { + if (this->actor.playerHeightRel <= 0.0f && this->actor.xzDistToPlayer > 20.0f) { player = GET_PLAYER(globalCtx); - player->actor.world.pos.x = (Math_SinS(this->actor.yawTowardsPlayer) * 20.0f) + this->actor.world.pos.x; - player->actor.world.pos.z = (Math_CosS(this->actor.yawTowardsPlayer) * 20.0f) + this->actor.world.pos.z; + player->actor.world.pos.x = Math_SinS(this->actor.yawTowardsPlayer) * 20.0f + this->actor.world.pos.x; + player->actor.world.pos.z = Math_CosS(this->actor.yawTowardsPlayer) * 20.0f + this->actor.world.pos.z; } } diff --git a/src/overlays/actors/ovl_Door_Ana/z_door_ana.h b/src/overlays/actors/ovl_Door_Ana/z_door_ana.h index aec6e70be5..0cff726e96 100644 --- a/src/overlays/actors/ovl_Door_Ana/z_door_ana.h +++ b/src/overlays/actors/ovl_Door_Ana/z_door_ana.h @@ -15,18 +15,17 @@ typedef struct DoorAna { extern const ActorInit Door_Ana_InitVars; -#define DOORANA_TYPE_REGULAR 0x000 -#define DOORANA_TYPE_UNK 0x100 -#define DOORANA_TYPE_HIDDEN 0x200 -#define DOORANA_TYPE_ADJACENT 0x300 -#define DOORANA_TYPE_BITRANGE 0x300 +#define DOORANA_TYPE_BITMASK 0x300 +#define DOORANA_TYPE_VISIBLE 0x000 +#define DOORANA_TYPE_HIDDEN_STORMS 0x100 // Incomplete, leftover from OoT +#define DOORANA_TYPE_HIDDEN_BOMB 0x200 +#define DOORANA_TYPE_VISIBLE_SCENE_EXIT 0x300 // Destination dependent on scene exit list -#define GET_DOORANA_TYPE(this)(this->actor.params & 0x300) - -#define DOORANA_TYPE_ROTATION_ENTRANCE(directEntrance)(directEntrance < 0) -#define GET_DOORANA_DIRECT_ENTRANCE(this) ((((this)->actor.params >> 0xC) & 0x7) - 1) -#define GET_DOORANA_ADJACENT_ENTRANCE(this) ((this)->actor.params & 0x1F) -#define GET_DOORANA_ROTATION_ENTRANCE(this) (this->actor.home.rot.z + 1) -#define GET_DOORANA_ITEMFLAGS(this) ((this)->actor.params & 0xFF) +#define DOORANA_GET_TYPE(thisx) ((thisx)->params & DOORANA_TYPE_BITMASK) +#define DOORANA_GET_ENTRANCE(thisx) ((((thisx)->params >> 12) & 0x7) - 1) +#define DOORANA_GET_EX_ENTRANCE(thisx) ((thisx)->home.rot.z + 1) +#define DOORANA_GET_EXIT_INDEX(thisx) ((thisx)->params & 0x1F) +#define DOORANA_GET_ITEMFLAGS(thisx) ((thisx)->params & 0xFF) +#define DOORANA_SET_TYPE(thisx, t) ((thisx)->params = ((thisx)->params & ~DOORANA_TYPE_BITMASK) + (t)) #endif // Z_DOOR_ANA_H diff --git a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c index e28e05a16b..01430acc30 100644 --- a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c +++ b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c @@ -344,7 +344,7 @@ void func_808A1090(DoorShutter* this, GlobalContext* globalCtx) { if (this->unk_166 != 0) { Flags_SetSwitch(globalCtx, DOORSHUTTER_GET_7F(&this->actor)); if (this->doorType != 5) { - gSaveContext.inventory.dungeonKeys[gSaveContext.mapIndex]--; + gSaveContext.save.inventory.dungeonKeys[gSaveContext.mapIndex]--; Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHAIN_KEY_UNLOCK); } else { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHAIN_KEY_UNLOCK_B); @@ -367,7 +367,7 @@ void func_808A1090(DoorShutter* this, GlobalContext* globalCtx) { } if (this->doorType == 6) { - if (gSaveContext.healthCapacity < (DOORSHUTTER_GET_1F(&this->actor) * 0x10)) { + if (gSaveContext.save.playerData.healthCapacity < (DOORSHUTTER_GET_1F(&this->actor) * 0x10)) { player->doorType = -1; this->actor.textId = 0x14FC; } @@ -570,7 +570,7 @@ void func_808A1884(DoorShutter* this, GlobalContext* globalCtx) { if (DoorShutter_SetupDoor(this, globalCtx) && !(player->stateFlags1 & 0x800)) { DoorShutter_SetupAction(this, func_808A1C50); if (ActorCutscene_GetCurrentIndex() == 0x7D) { - s8 data = gSaveContext.respawn[0].data; + s8 data = gSaveContext.respawn[RESTART_MODE_DOWN].data; func_801226E0(globalCtx, data); player->unk_A86 = -1; diff --git a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c index 56f39772a6..dd41ac0156 100644 --- a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c +++ b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c @@ -270,7 +270,7 @@ void func_808B8E78(DoorWarp1* this, GlobalContext* globalCtx) { this->unk_1A4 = 700.0f; if (globalCtx->sceneNum == SCENE_INISIE_N) { DoorWarp1_SetupAction(this, func_808B96A0); - } else if (gSaveContext.weekEventReg[86] & 0x80) { + } else if (gSaveContext.save.weekEventReg[86] & 0x80) { this->unk_1D4 = 0; DoorWarp1_SetupAction(this, func_808B921C); } else { @@ -343,7 +343,7 @@ void func_808B921C(DoorWarp1* this, GlobalContext* globalCtx) { func_808BB8D4(this, globalCtx, 1); } - if (func_808B866C(this, globalCtx) && !func_801690CC(globalCtx)) { + if (func_808B866C(this, globalCtx) && !Play_InCsMode(globalCtx)) { func_800B7298(globalCtx, &this->dyna.actor, 7); Message_StartTextbox(globalCtx, 0xF2, &this->dyna.actor); DoorWarp1_SetupAction(this, func_808B93A0); @@ -356,7 +356,7 @@ void func_808B93A0(DoorWarp1* this, GlobalContext* globalCtx) { s32 pad; Player* player = GET_PLAYER(globalCtx); - if (Message_GetState(&globalCtx->msgCtx) == 4 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 4 && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); if (globalCtx->msgCtx.choiceIndex == 0) { func_8019F208(); @@ -443,7 +443,7 @@ void func_808B96B0(DoorWarp1* this, GlobalContext* globalCtx) { void func_808B977C(DoorWarp1* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WARP_HOLE - SFX_FLAG); - if (func_808B866C(this, globalCtx) && !func_801690CC(globalCtx)) { + if (func_808B866C(this, globalCtx) && !Play_InCsMode(globalCtx)) { Player* player = GET_PLAYER(globalCtx); Audio_PlaySfxGeneral(NA_SE_EV_LINK_WARP, &player->actor.projectedPos, 4, &D_801DB4B0, &D_801DB4B0, &D_801DB4B8); @@ -553,27 +553,28 @@ void func_808B9CE8(DoorWarp1* this, GlobalContext* globalCtx) { switch (globalCtx->sceneNum) { case SCENE_MITURIN_BS: - gSaveContext.unk_ECC[0] = - (((void)0, gSaveContext.unk_ECC[0]) & 0xFFFFFF00) | (((u8)gSaveContext.unk_ECC[1]) & 0xFF); + gSaveContext.save.unk_ECC[0] = + (((void)0, gSaveContext.save.unk_ECC[0]) & 0xFFFFFF00) | (((u8)gSaveContext.save.unk_ECC[1]) & 0xFF); break; case SCENE_HAKUGIN_BS: - gSaveContext.unk_ECC[0] = - (((void)0, gSaveContext.unk_ECC[0]) & 0xFFFF00FF) | ((((u8)gSaveContext.unk_ECC[1]) & 0xFF) << 8); + gSaveContext.save.unk_ECC[0] = (((void)0, gSaveContext.save.unk_ECC[0]) & 0xFFFF00FF) | + ((((u8)gSaveContext.save.unk_ECC[1]) & 0xFF) << 8); break; case SCENE_INISIE_BS: - gSaveContext.unk_ECC[0] = - (((void)0, gSaveContext.unk_ECC[0]) & 0xFF00FFFF) | ((((u8)gSaveContext.unk_ECC[1]) & 0xFF) << 0x10); + gSaveContext.save.unk_ECC[0] = (((void)0, gSaveContext.save.unk_ECC[0]) & 0xFF00FFFF) | + ((((u8)gSaveContext.save.unk_ECC[1]) & 0xFF) << 0x10); break; case SCENE_SEA_BS: - gSaveContext.unk_ECC[0] = - (((void)0, gSaveContext.unk_ECC[0]) & 0x00FFFFFF) | ((((u8)gSaveContext.unk_ECC[1]) & 0xFF) << 0x18); + gSaveContext.save.unk_ECC[0] = (((void)0, gSaveContext.save.unk_ECC[0]) & 0x00FFFFFF) | + ((((u8)gSaveContext.save.unk_ECC[1]) & 0xFF) << 0x18); break; } - gSaveContext.unk_ECC[1] = (gSaveContext.unk_ECC[1] & 0xFFFFFF00) | ((((u8)gSaveContext.unk_ECC[1]) + 1) & 0xFF); + gSaveContext.save.unk_ECC[1] = + (gSaveContext.save.unk_ECC[1] & 0xFFFFFF00) | ((((u8)gSaveContext.save.unk_ECC[1]) + 1) & 0xFF); Item_Give(globalCtx, func_808B849C(this, globalCtx) + (ITEM_REMAINS_ODOLWA - 1)); DoorWarp1_SetupAction(this, func_808B9E94); } @@ -594,7 +595,7 @@ void func_808B9ED8(DoorWarp1* this, GlobalContext* globalCtx) { void func_808B9F10(DoorWarp1* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WARP_HOLE - SFX_FLAG); - if ((this->unk_203 == 0) && func_808B866C(this, globalCtx) && !func_801690CC(globalCtx) && (this->unk_203 == 0)) { + if ((this->unk_203 == 0) && func_808B866C(this, globalCtx) && !Play_InCsMode(globalCtx) && (this->unk_203 == 0)) { Player* player = GET_PLAYER(globalCtx); Interface_ChangeAlpha(1); @@ -651,24 +652,24 @@ void func_808BA10C(DoorWarp1* this, GlobalContext* globalCtx) { if (this->unk_202 != 0) { if (phi_v0_2 > 0) { - gSaveContext.weekEventReg[7] |= 0x80; + gSaveContext.save.weekEventReg[7] |= 0x80; } switch (phi_v0_2) { case 0: - phi_a0 = gSaveContext.unk_ECC[0] & 0xFF; + phi_a0 = gSaveContext.save.unk_ECC[0] & 0xFF; break; case 1: - phi_a0 = (gSaveContext.unk_ECC[0] & 0xFF00) >> 8; + phi_a0 = (gSaveContext.save.unk_ECC[0] & 0xFF00) >> 8; break; case 2: - phi_a0 = (gSaveContext.unk_ECC[0] & 0xFF0000) >> 0x10; + phi_a0 = (gSaveContext.save.unk_ECC[0] & 0xFF0000) >> 0x10; break; case 3: - phi_a0 = (gSaveContext.unk_ECC[0] & 0xFF000000) >> 0x18; + phi_a0 = (gSaveContext.save.unk_ECC[0] & 0xFF000000) >> 0x18; break; default: @@ -709,8 +710,8 @@ void func_808BA10C(DoorWarp1* this, GlobalContext* globalCtx) { } else { switch (phi_v0_2) { case 0: - if (gSaveContext.weekEventReg[20] & 2) { - gSaveContext.weekEventReg[7] |= 0x80; + if (gSaveContext.save.weekEventReg[20] & 2) { + gSaveContext.save.weekEventReg[7] |= 0x80; globalCtx->nextEntranceIndex = 0x3010; globalCtx->sceneLoadFlag = 0x14; globalCtx->unk_1887F = 3; @@ -725,7 +726,7 @@ void func_808BA10C(DoorWarp1* this, GlobalContext* globalCtx) { break; case 1: - gSaveContext.weekEventReg[33] |= 0x80; + gSaveContext.save.weekEventReg[33] |= 0x80; globalCtx->nextEntranceIndex = 0xAE70; globalCtx->sceneLoadFlag = 0x14; globalCtx->unk_1887F = 3; @@ -733,14 +734,14 @@ void func_808BA10C(DoorWarp1* this, GlobalContext* globalCtx) { break; case 3: - if (gSaveContext.weekEventReg[55] & 0x80) { + if (gSaveContext.save.weekEventReg[55] & 0x80) { globalCtx->nextEntranceIndex = 0x6A90; gSaveContext.nextCutsceneIndex = 0xFFF0; globalCtx->sceneLoadFlag = 0x14; globalCtx->unk_1887F = 3; gSaveContext.nextTransition = 3; } else { - gSaveContext.weekEventReg[55] |= 0x80; + gSaveContext.save.weekEventReg[55] |= 0x80; globalCtx->nextEntranceIndex = 0x6A80; gSaveContext.nextCutsceneIndex = 0xFFF0; globalCtx->sceneLoadFlag = 0x14; @@ -750,7 +751,7 @@ void func_808BA10C(DoorWarp1* this, GlobalContext* globalCtx) { break; case 2: - gSaveContext.weekEventReg[52] |= 0x20; + gSaveContext.save.weekEventReg[52] |= 0x20; globalCtx->nextEntranceIndex = 0x20F0; gSaveContext.nextCutsceneIndex = 0xFFF2; globalCtx->sceneLoadFlag = 0x14; @@ -885,14 +886,14 @@ void func_808BAAF4(DoorWarp1* this, GlobalContext* globalCtx) { phi_f2 = 85.0f; } - if (!(gSaveContext.weekEventReg[86] & 0x80) && (fabsf(this->dyna.actor.xzDistToPlayer) < phi_f2) && + if (!(gSaveContext.save.weekEventReg[86] & 0x80) && (fabsf(this->dyna.actor.xzDistToPlayer) < phi_f2) && ((player->actor.world.pos.y - 20.0f) < this->dyna.actor.world.pos.y) && (this->dyna.actor.world.pos.y < (player->actor.world.pos.y + 20.0f))) { cutscene = this->dyna.actor.cutscene; if (ActorCutscene_GetCanPlayNext(cutscene)) { ActorCutscene_Start(cutscene, &this->dyna.actor); - gSaveContext.weekEventReg[86] |= 0x80; + gSaveContext.save.weekEventReg[86] |= 0x80; DoorWarp1_SetupAction(this, func_808BABF4); } else { ActorCutscene_SetIntentToPlay(cutscene); @@ -1092,6 +1093,7 @@ static Color_RGB8 D_808BBB50[] = { { 0, 50, 200 }, { 120, 150, 0 }, }; +void func_808BB4F4(DoorWarp1* this, GlobalContext* globalCtx2); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Warp1/func_808BB4F4.s") #endif diff --git a/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.c b/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.c index e7daab2940..68c22f2d11 100644 --- a/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.c +++ b/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.c @@ -5,6 +5,7 @@ */ #include "z_elf_msg6.h" +#include "overlays/actors/ovl_En_Elf/z_en_elf.h" #define FLAGS (ACTOR_FLAG_10) @@ -22,7 +23,6 @@ void func_80BA2048(ElfMsg6* this, GlobalContext* globalCtx); void func_80BA215C(ElfMsg6* this, GlobalContext* globalCtx); void func_80BA21C4(ElfMsg6* this, GlobalContext* globalCtx); -#if 0 const ActorInit Elf_Msg6_InitVars = { ACTOR_ELF_MSG6, ACTORCAT_ITEMACTION, @@ -35,34 +35,380 @@ const ActorInit Elf_Msg6_InitVars = { (ActorFunc)NULL, }; -#endif +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_STOP), +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg6/func_80BA15A0.s") +s32 func_80BA15A0(void) { + if (CHECK_QUEST_ITEM(QUEST_REMAINS_ODOWLA) && !(gSaveContext.save.weekEventReg[87] & 0x10)) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg6/func_80BA165C.s") + if (CHECK_QUEST_ITEM(QUEST_REMAINS_GOHT) && !(gSaveContext.save.weekEventReg[87] & 0x20)) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg6/func_80BA16F4.s") + if (CHECK_QUEST_ITEM(QUEST_REMAINS_GYORG) && !(gSaveContext.save.weekEventReg[87] & 0x40)) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg6/ElfMsg6_Init.s") + if (CHECK_QUEST_ITEM(QUEST_REMAINS_TWINMOLD) && !(gSaveContext.save.weekEventReg[87] & 0x80)) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg6/ElfMsg6_Destroy.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg6/func_80BA1C00.s") +void func_80BA165C(void) { + if (CHECK_QUEST_ITEM(QUEST_REMAINS_ODOWLA)) { + gSaveContext.save.weekEventReg[87] |= 0x10; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg6/func_80BA1C88.s") + if (CHECK_QUEST_ITEM(QUEST_REMAINS_GOHT)) { + gSaveContext.save.weekEventReg[87] |= 0x20; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg6/func_80BA1CF8.s") + if (CHECK_QUEST_ITEM(QUEST_REMAINS_GYORG)) { + gSaveContext.save.weekEventReg[87] |= 0x40; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg6/func_80BA1E30.s") + if (CHECK_QUEST_ITEM(QUEST_REMAINS_TWINMOLD)) { + gSaveContext.save.weekEventReg[87] |= 0x80; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg6/func_80BA1F80.s") +s32 func_80BA16F4(ElfMsg6* this, GlobalContext* globalCtx) { + if (!(gSaveContext.save.weekEventReg[31] & 4) && (INV_CONTENT(ITEM_MASK_DEKU) == ITEM_MASK_DEKU)) { + this->actor.textId = 0x216; + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg6/func_80BA2038.s") + if (!func_80BA15A0()) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg6/func_80BA2048.s") + if (!CHECK_QUEST_ITEM(QUEST_REMAINS_ODOWLA)) { + this->actor.textId = 0x256; + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg6/func_80BA215C.s") + if (!CHECK_QUEST_ITEM(QUEST_REMAINS_GOHT)) { + if (gSaveContext.save.weekEventReg[31] & 1) { + this->actor.textId = 0x257; + } else { + this->actor.textId = 0x231; + } + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg6/func_80BA21C4.s") + if (!CHECK_QUEST_ITEM(QUEST_REMAINS_GYORG)) { + if (gSaveContext.save.weekEventReg[31] & 2) { + this->actor.textId = 0x258; + } else { + this->actor.textId = 0x232; + } + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg6/ElfMsg6_Update.s") + if (!CHECK_QUEST_ITEM(QUEST_REMAINS_TWINMOLD)) { + if (gSaveContext.save.weekEventReg[80] & 4) { + this->actor.textId = 0x259; + } else { + this->actor.textId = 0x233; + } + return false; + } + + return true; +} + +void ElfMsg6_Init(Actor* thisx, GlobalContext* globalCtx) { + ElfMsg6* this = THIS; + + Actor_ProcessInitChain(&this->actor, sInitChain); + + if (ABS_ALT(this->actor.home.rot.x) == 0) { + this->actor.scale.z = 0.4f; + this->actor.scale.x = 0.4f; + } else { + this->actor.scale.x = this->actor.scale.z = ABS_ALT(this->actor.home.rot.x) * 0.04f; + } + + if (this->actor.home.rot.z == 0) { + this->actor.scale.y = 0.4f; + } else { + this->actor.scale.y = this->actor.home.rot.z * 0.04f; + } + + this->actor.shape.rot.x = this->actor.shape.rot.y = this->actor.shape.rot.z = 0; + + switch (ELFMSG6_GET_F(&this->actor)) { + case 0: + this->actionFunc = func_80BA1E30; + if (func_80BA16F4(this, globalCtx)) { + Actor_MarkForDeath(&this->actor); + return; + } + break; + + case 1: + this->actionFunc = func_80BA1F80; + if ((this->actor.cutscene == -1) || ((ELFMSG6_SWITCHFLAG(&this->actor) != 0x7F) && + Flags_GetSwitch(globalCtx, ELFMSG6_SWITCHFLAG(&this->actor)))) { + Actor_MarkForDeath(&this->actor); + return; + } + + switch (ELFMSG6_GET_F0(&this->actor)) { + case 0: + if (gSaveContext.save.inventory.items[ITEM_HOOKSHOT] != ITEM_HOOKSHOT) { + Actor_MarkForDeath(&this->actor); + return; + } + break; + + case 1: + if (gSaveContext.save.weekEventReg[83] & 2) { + Actor_MarkForDeath(&this->actor); + return; + } + break; + } + break; + + case 2: + if (INV_CONTENT(ITEM_OCARINA) == ITEM_OCARINA) { + Actor_MarkForDeath(&this->actor); + return; + } + + if (gSaveContext.save.weekEventReg[8] & 0x40) { + if (gSaveContext.save.weekEventReg[88] & 0x20) { + Actor_MarkForDeath(&this->actor); + return; + } + this->actor.textId = 0x25B; + } else { + if (!(gSaveContext.save.weekEventReg[74] & 0x20) || (gSaveContext.save.weekEventReg[79] & 0x10)) { + Actor_MarkForDeath(&this->actor); + return; + } + this->actor.textId = 0x224; + } + this->actionFunc = func_80BA1CF8; + break; + + case 3: + if (((ELFMSG6_SWITCHFLAG(&this->actor) != 0x7F) && + Flags_GetSwitch(globalCtx, ELFMSG6_SWITCHFLAG(&this->actor))) || + (gSaveContext.save.weekEventReg[88] & 0x10) || (gSaveContext.save.weekEventReg[91] & 1) || + (INV_CONTENT(ITEM_MASK_ZORA) == ITEM_MASK_ZORA)) { + Actor_MarkForDeath(&this->actor); + return; + } + this->actionFunc = func_80BA2048; + this->actor.textId = 0x24D; + break; + + case 4: + this->actionFunc = func_80BA215C; + this->actor.textId = 0x255; + break; + + case 5: + this->actionFunc = func_80BA21C4; + this->actor.textId = 0x25E; + break; + + case 6: + this->actionFunc = func_80BA21C4; + this->actor.textId = 0x25F; + break; + + default: + this->actionFunc = func_80BA2038; + break; + } +} + +void ElfMsg6_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +s32 func_80BA1C00(ElfMsg6* this) { + return (this->actor.xzDistToPlayer < (100.0f * this->actor.scale.x)) && + ((this->actor.playerHeightRel >= 0.0f) && (this->actor.playerHeightRel < (100.0f * this->actor.scale.y))); +} + +void func_80BA1C88(ElfMsg6* this, GlobalContext* globalCtx, s16 arg2) { + Player* player = GET_PLAYER(globalCtx); + EnElf* sp20 = (EnElf*)player->tatlActor; + + if (player->tatlActor != NULL) { + player->tatlTextId = arg2; + ActorCutscene_SetIntentToPlay(0x7C); + sp20->elfMsg = &this->actor; + if (this->actor.cutscene == -1) { + this->actor.cutscene = 0x7C; + } + } +} + +void func_80BA1CF8(ElfMsg6* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + EnElf* sp20 = (EnElf*)player->tatlActor; + + if (player->tatlActor == NULL) { + return; + } + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + switch (this->actor.textId) { + case 0x224: + gSaveContext.save.weekEventReg[79] |= 0x10; + break; + + case 0x25B: + gSaveContext.save.weekEventReg[88] |= 0x20; + break; + } + Actor_MarkForDeath(&this->actor); + return; + } + + if ((this->actor.textId == 0x224) && (gSaveContext.save.weekEventReg[8] & 0x40)) { + this->actor.textId = 0x25B; + } else if (func_80BA1C00(this) && (player->actor.speedXZ > 1.0f)) { + player->tatlTextId = -this->actor.textId; + ActorCutscene_SetIntentToPlay(0x7C); + sp20->elfMsg = &this->actor; + if (this->actor.cutscene == -1) { + this->actor.cutscene = 0x7C; + } + } +} + +void func_80BA1E30(ElfMsg6* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + EnElf* sp20 = (EnElf*)player->tatlActor; + + if (player->tatlActor == NULL) { + return; + } + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + switch (this->actor.textId) { + case 0x216: + gSaveContext.save.weekEventReg[31] |= 4; + break; + + case 0x231: + gSaveContext.save.weekEventReg[31] |= 1; + break; + + case 0x232: + gSaveContext.save.weekEventReg[31] |= 2; + break; + + case 0x233: + gSaveContext.save.weekEventReg[80] |= 4; + break; + } + func_80BA165C(); + Actor_MarkForDeath(&this->actor); + return; + } + + if (func_80BA1C00(this) && (player->actor.speedXZ > 1.0f)) { + player->tatlTextId = -this->actor.textId; + ActorCutscene_SetIntentToPlay(0x7C); + sp20->elfMsg = &this->actor; + if (this->actor.cutscene == -1) { + this->actor.cutscene = 0x7C; + } + } +} + +void func_80BA1F80(ElfMsg6* this, GlobalContext* globalCtx) { + if (((ELFMSG6_GET_F0(&this->actor)) == 1) && (gSaveContext.save.weekEventReg[83] & 2)) { + Actor_MarkForDeath(&this->actor); + return; + } + + if (func_80BA1C00(this)) { + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, NULL); + Flags_SetSwitch(globalCtx, ELFMSG6_SWITCHFLAG(&this->actor)); + Actor_MarkForDeath(&this->actor); + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } + } +} + +void func_80BA2038(ElfMsg6* this, GlobalContext* globalCtx) { +} + +void func_80BA2048(ElfMsg6* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + EnElf* sp20 = (EnElf*)GET_PLAYER(globalCtx)->tatlActor; + + sp20->unk_264 |= 0x20; + if (ELFMSG6_SWITCHFLAG(&this->actor) != 0x7F) { + Flags_SetSwitch(globalCtx, ELFMSG6_SWITCHFLAG(&this->actor)); + } + Actor_MarkForDeath(&this->actor); + return; + } + + if (((ELFMSG6_SWITCHFLAG(&this->actor) != 0x7F) && Flags_GetSwitch(globalCtx, ELFMSG6_SWITCHFLAG(&this->actor))) || + (gSaveContext.save.weekEventReg[88] & 0x10) || (gSaveContext.save.weekEventReg[91] & 1) || + (INV_CONTENT(ITEM_MASK_ZORA) == ITEM_MASK_ZORA)) { + Actor_MarkForDeath(&this->actor); + return; + } + + if (func_80BA1C00(this)) { + func_80BA1C88(this, globalCtx, 0x24D); + } +} + +void func_80BA215C(ElfMsg6* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + Actor_MarkForDeath(&this->actor); + return; + } + + if (func_80BA1C00(this)) { + func_80BA1C88(this, globalCtx, -this->actor.textId); + } +} + +void func_80BA21C4(ElfMsg6* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + EnElf* sp20 = (EnElf*)GET_PLAYER(globalCtx)->tatlActor; + + sp20->unk_264 |= 0x20; + if (ELFMSG6_SWITCHFLAG(&this->actor) != 0x7F) { + Flags_SetSwitch(globalCtx, ELFMSG6_SWITCHFLAG(&this->actor)); + } + Actor_MarkForDeath(&this->actor); + return; + } + + if (((ELFMSG6_SWITCHFLAG(&this->actor) != 0x7F) && Flags_GetSwitch(globalCtx, ELFMSG6_SWITCHFLAG(&this->actor))) || + CHECK_QUEST_ITEM(QUEST_SONG_EPONA)) { + Actor_MarkForDeath(&this->actor); + return; + } + + if (func_80BA1C00(this)) { + func_80BA1C88(this, globalCtx, this->actor.textId); + } +} + +void ElfMsg6_Update(Actor* thisx, GlobalContext* globalCtx) { + ElfMsg6* this = THIS; + + this->actionFunc(this, globalCtx); +} diff --git a/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.h b/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.h index 05713b146f..78f970de05 100644 --- a/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.h +++ b/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.h @@ -7,6 +7,10 @@ struct ElfMsg6; typedef void (*ElfMsg6ActionFunc)(struct ElfMsg6*, GlobalContext*); +#define ELFMSG6_GET_F(thisx) ((thisx)->params & 0xF) +#define ELFMSG6_GET_F0(thisx) (((thisx)->params & 0xF0) >> 4) +#define ELFMSG6_SWITCHFLAG(thisx) (((thisx)->params & 0xFE00) >> 9) + typedef struct ElfMsg6 { /* 0x0000 */ Actor actor; /* 0x0144 */ ElfMsg6ActionFunc actionFunc; diff --git a/src/overlays/actors/ovl_En_Ah/z_en_ah.c b/src/overlays/actors/ovl_En_Ah/z_en_ah.c index b7bec3f698..732b3e37b3 100644 --- a/src/overlays/actors/ovl_En_Ah/z_en_ah.c +++ b/src/overlays/actors/ovl_En_Ah/z_en_ah.c @@ -5,6 +5,7 @@ */ #include "z_en_ah.h" +#include "objects/object_ah/object_ah.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -18,7 +19,34 @@ void EnAh_Draw(Actor* thisx, GlobalContext* globalCtx); void func_80BD36B8(EnAh* this, GlobalContext* globalCtx); void func_80BD3768(EnAh* this, GlobalContext* globalCtx); -#if 0 +static u8 D_80BD3DB0[] = { + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_YADOYA, 0x21 - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(3, 0x0B - 0x08), + /* 0x08 */ SCHEDULE_CMD_RET_VAL_L(1), + /* 0x0B */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(2, 0x20 - 0x0F), + /* 0x0F */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(21, 0, 23, 0, 0x1D - 0x15), + /* 0x15 */ SCHEDULE_CMD_CHECK_FLAG_S(0x32, 0x20, 0x1C - 0x19), + /* 0x19 */ SCHEDULE_CMD_RET_VAL_L(1), + /* 0x1C */ SCHEDULE_CMD_RET_NONE(), + /* 0x1D */ SCHEDULE_CMD_RET_VAL_L(3), + /* 0x20 */ SCHEDULE_CMD_RET_NONE(), + /* 0x21 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_OMOYA, 0x37 - 0x25), + /* 0x25 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(3, 0x36 - 0x29), + /* 0x29 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(18, 0, 6, 0, 0x30 - 0x2F), + /* 0x2F */ SCHEDULE_CMD_RET_NONE(), + /* 0x30 */ SCHEDULE_CMD_RET_TIME(18, 0, 6, 0, 2), + /* 0x36 */ SCHEDULE_CMD_RET_NONE(), + /* 0x37 */ SCHEDULE_CMD_RET_NONE(), +}; + +s32 D_80BD3DE8[] = { 0x0E28FF0C, 0x10000000 }; + +s32 D_80BD3DF0[] = { 0x0E29000C, 0x10000000 }; + +s32 D_80BD3DF8[] = { 0x00330100, 0x050E28FE, 0x0C100E28, -0x03F3F000 }; + +s32 D_80BD3E08[] = { 0x0E28FD0C, 0x0F29540C, 0x10000000 }; + const ActorInit En_Ah_InitVars = { ACTOR_EN_AH, ACTORCAT_NPC, @@ -31,75 +59,575 @@ const ActorInit En_Ah_InitVars = { (ActorFunc)EnAh_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BD3E34 = { - { COLTYPE_HIT1, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT1, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 10, 68, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80BD3E60 = { 0, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -#endif +static AnimationInfoS sAnimations[] = { + { &object_ah_Anim_001860, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_ah_Anim_001860, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_ah_Anim_002280, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_ah_Anim_000968, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_ah_Anim_000DDC, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, +}; -extern ColliderCylinderInit D_80BD3E34; -extern CollisionCheckInfoInit2 D_80BD3E60; +s16 D_80BD3EBC[] = { 0, 0, 1, 0 }; -extern UNK_TYPE D_06009E70; +PosRot D_80BD3EC4 = { { 100.0f, 0.0f, 67.0f }, { 0, 0x349C, 0 } }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD2A30.s") +PosRot D_80BD3ED8 = { { 855.0f, 260.0f, 31.0f }, { 0, 0x7FF8, 0 } }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD2AE0.s") +PosRot D_80BD3EEC = { { -395.0f, 210.0f, -162.0f }, { 0, 0xBE98, 0 } }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD2B0C.s") +Vec3f D_80BD3F00 = { 1000.0f, 0.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD2BA4.s") +TexturePtr D_80BD3F0C[] = { object_ah_Tex_008D70, object_ah_Tex_009570 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD2BE8.s") +TexturePtr D_80BD3F14[] = { + object_ah_Tex_006D70, object_ah_Tex_007570, object_ah_Tex_007D70, object_ah_Tex_007570, object_ah_Tex_008570, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD2C6C.s") +s32 func_80BD2A30(EnAh* this, GlobalContext* globalCtx, u8 actorCat, s16 actorId) { + Actor* tempActor; + Actor* foundActor = NULL; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD2DA0.s") + while (true) { + foundActor = SubS_FindActor(globalCtx, foundActor, actorCat, actorId); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD2DC8.s") + if ((foundActor == NULL) || (((EnAh*)foundActor != this) && (foundActor->update != NULL))) { + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD2FD0.s") + tempActor = foundActor->next; + if (tempActor == NULL) { + foundActor = NULL; + break; + } + foundActor = tempActor; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD30C0.s") + return foundActor; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD3118.s") +void func_80BD2AE0(EnAh* this) { + this->skelAnime.playSpeed = this->unk_2DC; + SkelAnime_Update(&this->skelAnime); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD3198.s") +s32 func_80BD2B0C(EnAh* this, s32 arg1) { + s32 phi_v1 = false; + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD3294.s") + if ((arg1 == 0) || (arg1 == 1)) { + if ((this->unk_300 != 0) && (this->unk_300 != 1)) { + phi_v1 = true; + } + } else if (arg1 != this->unk_300) { + phi_v1 = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD3320.s") + if (phi_v1) { + this->unk_300 = arg1; + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, arg1); + this->unk_2DC = this->skelAnime.playSpeed; + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD3374.s") +void func_80BD2BA4(EnAh* this, GlobalContext* globalCtx) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD33FC.s") +s32 func_80BD2BE8(EnAh* this, GlobalContext* globalCtx) { + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD3484.s") + if (this->unk_2D8 & 7) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + SubS_UpdateFlags(&this->unk_2D8, 0, 7); + ret = true; + this->unk_2D8 |= 8; + this->actionFunc = func_80BD3768; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD3548.s") + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD35BC.s") +void func_80BD2C6C(EnAh* this) { + s32 phi_a3 = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD3658.s") + if (this->unk_2D8 & 0x40) { + if (DECR(this->unk_2F8) == 0) { + switch (this->unk_2F6) { + case 1: + case 2: + if ((this->unk_2FA == 4) || (this->unk_2FA == 2)) { + phi_a3 = true; + this->unk_2FA = 4; + } + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD36B8.s") + if (!phi_a3 && (this->unk_2FA == 4)) { + this->unk_2FA = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD3768.s") + if (!phi_a3) { + this->unk_2FA++; + if (this->unk_2FA >= 4) { + if (this->unk_2F6 == 0) { + this->unk_2F8 = Rand_S16Offset(30, 30); + } else { + this->unk_2F8 = 8; + } + this->unk_2FA = 0; + phi_a3 = true; + } + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/EnAh_Init.s") + if (phi_a3 == true) { + this->unk_2FC = D_80BD3EBC[this->unk_2F6]; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/EnAh_Destroy.s") +Actor* func_80BD2DA0(EnAh* this, GlobalContext* globalCtx) { + Actor* actor; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/EnAh_Update.s") + if (this->unk_1DC == 3) { + actor = this->actor.child; + } else { + actor = &GET_PLAYER(globalCtx)->actor; + } + return actor; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD3AA8.s") +void func_80BD2DC8(EnAh* this) { + s32 pad; + Vec3f sp40; + Vec3f sp34; + s16 sp32; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD3AF8.s") + Math_Vec3f_Copy(&sp40, &this->unk_1E4->world.pos); + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/EnAh_Draw.s") + sp32 = Math_Vec3f_Yaw(&sp34, &sp40); + + Math_ApproachS(&this->unk_2EE, (sp32 - this->unk_2F2) - this->actor.shape.rot.y, 4, 0x2AA8); + this->unk_2EE = CLAMP(this->unk_2EE, -0x1FFE, 0x1FFE); + + Math_ApproachS(&this->unk_2F2, (sp32 - this->unk_2EE) - this->actor.shape.rot.y, 4, 0x2AA8); + this->unk_2F2 = CLAMP(this->unk_2F2, -0x1C70, 0x1C70); + + Math_Vec3f_Copy(&sp34, &this->actor.focus.pos); + + if (this->unk_1E4->id == ACTOR_PLAYER) { + sp40.y = ((Player*)this->unk_1E4)->bodyPartsPos[7].y + 3.0f; + } else { + Math_Vec3f_Copy(&sp40, &this->unk_1E4->focus.pos); + } + + Math_ApproachS(&this->unk_2EC, Math_Vec3f_Pitch(&sp34, &sp40) - this->unk_2F0, 4, 0x2AA8); + this->unk_2EC = CLAMP(this->unk_2EC, -0x1554, 0x1554); + + Math_ApproachS(&this->unk_2F0, Math_Vec3f_Pitch(&sp34, &sp40) - this->unk_2EC, 4, 0x2AA8); + this->unk_2F0 = CLAMP(this->unk_2F0, -0xE38, 0xE38); +} + +void func_80BD2FD0(EnAh* this, GlobalContext* globalCtx) { + this->unk_1E4 = func_80BD2DA0(this, globalCtx); + + if ((this->unk_2D8 & 8) && (this->unk_1E4 != NULL)) { + if (DECR(this->unk_2F4) == 0) { + func_80BD2DC8(this); + this->unk_2F0 = 0; + this->unk_2F2 = 0; + this->unk_2D8 &= ~0x80; + this->unk_2D8 |= 0x20; + return; + } + } + + if (this->unk_2D8 & 0x20) { + this->unk_2D8 &= ~0x20; + this->unk_2EC = 0; + this->unk_2EE = 0; + this->unk_2F0 = 0; + this->unk_2F2 = 0; + this->unk_2F4 = 20; + } else if (DECR(this->unk_2F4) == 0) { + this->unk_2D8 |= 0x80; + } +} + +s32 func_80BD30C0(EnAh* this, GlobalContext* globalCtx) { + switch (this->unk_1DC) { + case 1: + func_80BD2B0C(this, 0); + break; + + case 2: + func_80BD2B0C(this, 4); + break; + } + return false; +} + +void func_80BD3118(EnAh* this, GlobalContext* globalCtx) { + if (this->unk_2FE == 0) { + func_80BD2B0C(this, 2); + this->unk_2FE++; + } else if ((this->unk_2FE == 1) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + func_80BD2B0C(this, 3); + this->unk_2FE++; + } +} + +s32 func_80BD3198(EnAh* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + u16 temp = globalCtx->msgCtx.currentTextId; + + if (player->stateFlags1 & 0x40) { + if (this->unk_2DA != temp) { + if (temp == 0x2954) { + this->unk_18C = func_80BD3118; + this->unk_2FE = 0; + } + + switch (temp) { + case 0x28FD: + this->unk_2F6 = 1; + this->unk_2F8 = 8; + break; + + case 0x2954: + this->unk_2F6 = 2; + this->unk_2F8 = 8; + break; + } + } + this->unk_2DA = temp; + this->unk_2D8 |= 0x100; + } else if (this->unk_2D8 & 0x100) { + this->unk_18C = NULL; + this->unk_2DA = 0; + this->unk_2D8 &= ~0x100; + this->unk_2F6 = 0; + this->unk_2F8 = 4; + func_80BD30C0(this, globalCtx); + } + + if (this->unk_18C != NULL) { + this->unk_18C(this, globalCtx); + } + + return false; +} + +s32* func_80BD3294(EnAh* this, GlobalContext* globalCtx) { + s32 mask = Player_GetMask(globalCtx); + + if (PLAYER_MASK_KAFEIS_MASK == mask) { + return D_80BD3E08; + } + + switch (this->unk_1DC) { + case 1: + if (gSaveContext.save.day == 2) { + return D_80BD3DF0; + } + return D_80BD3DE8; + + case 2: + return D_80BD3DF8; + } + return NULL; +} + +s32 func_80BD3320(EnAh* this, GlobalContext* globalCtx, u8 actorCat, s16 actorId) { + s32 pad; + s32 ret = false; + Actor* temp_v0 = func_80BD2A30(this, globalCtx, actorCat, actorId); + + if (temp_v0 != NULL) { + this->actor.child = temp_v0; + ret = true; + } + return ret; +} + +s32 func_80BD3374(EnAh* this, GlobalContext* globalCtx, ScheduleResult* arg2) { + s32 pad; + + Math_Vec3f_Copy(&this->actor.world.pos, &D_80BD3EC4.pos); + Math_Vec3s_Copy(&this->actor.world.rot, &D_80BD3EC4.rot); + Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); + func_80BD2B0C(this, 0); + SubS_UpdateFlags(&this->unk_2D8, 3, 7); + this->unk_2D8 |= 0x40; + return true; +} + +s32 func_80BD33FC(EnAh* this, GlobalContext* globalCtx, ScheduleResult* arg2) { + s32 pad; + + Math_Vec3f_Copy(&this->actor.world.pos, &D_80BD3ED8.pos); + Math_Vec3s_Copy(&this->actor.world.rot, &D_80BD3ED8.rot); + Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); + func_80BD2B0C(this, 4); + SubS_UpdateFlags(&this->unk_2D8, 3, 7); + this->unk_2D8 |= (0x40 | 0x10); + return true; +} + +s32 func_80BD3484(EnAh* this, GlobalContext* globalCtx, ScheduleResult* arg2) { + s32 ret = false; + + if (func_80BD3320(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_AN)) { + if (sREG(81) == 0) { + Math_Vec3f_Copy(&this->actor.world.pos, &D_80BD3EEC.pos); + Math_Vec3s_Copy(&this->actor.world.rot, &D_80BD3EEC.rot); + Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); + } + func_80BD2B0C(this, 4); + this->unk_2D8 |= (0x40 | 0x8); + this->unk_2D8 |= 0x10; + this->unk_2D8 |= 0x80; + this->actor.gravity = 0.0f; + ret = true; + } + return ret; +} + +s32 func_80BD3548(EnAh* this, GlobalContext* globalCtx, ScheduleResult* arg2) { + s32 ret; + + this->unk_2D8 = 0; + + switch (arg2->result) { + default: + ret = false; + break; + + case 1: + ret = func_80BD3374(this, globalCtx, arg2); + break; + + case 2: + ret = func_80BD33FC(this, globalCtx, arg2); + break; + + case 3: + ret = func_80BD3484(this, globalCtx, arg2); + break; + } + return ret; +} + +s32 func_80BD35BC(EnAh* this, GlobalContext* globalCtx) { + s16 temp; + s16 temp2; + + switch (this->unk_1DC) { + default: + return false; + + case 2: + temp = BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y); + temp2 = ABS_ALT(temp); + if (temp2 < 0x3800) { + SubS_UpdateFlags(&this->unk_2D8, 3, 7); + } else { + SubS_UpdateFlags(&this->unk_2D8, 0, 7); + } + return false; + } +} + +void func_80BD3658(EnAh* this, GlobalContext* globalCtx) { + if ((this->unk_1DC == 1) || (this->unk_1DC == 2) || (this->unk_1DC == 3)) { + func_80BD35BC(this, globalCtx); + } + Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 3, 0x2AA8); +} + +void func_80BD36B8(EnAh* this, GlobalContext* globalCtx) { + ScheduleResult sp18; + + if (!Schedule_RunScript(globalCtx, D_80BD3DB0, &sp18) || + ((this->unk_1DC != sp18.result) && !func_80BD3548(this, globalCtx, &sp18))) { + this->actor.shape.shadowDraw = NULL; + this->actor.flags &= ~ACTOR_FLAG_1; + sp18.result = 0; + } else { + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; + this->actor.flags |= ACTOR_FLAG_1; + } + this->unk_1DC = sp18.result; + func_80BD3658(this, globalCtx); +} + +void func_80BD3768(EnAh* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp40; + Vec3f sp34; + + if (func_8010BF58(&this->actor, globalCtx, func_80BD3294(this, globalCtx), NULL, &this->unk_1E0)) { + SubS_UpdateFlags(&this->unk_2D8, 3, 7); + this->unk_2D8 &= ~8; + this->unk_2D8 |= 0x80; + this->unk_2F4 = 20; + this->unk_1E0 = 0; + this->actionFunc = func_80BD36B8; + } else if (this->unk_1DC != 2) { + if (this->unk_1E4 != NULL) { + Math_Vec3f_Copy(&sp40, &this->unk_1E4->world.pos); + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); + Math_ApproachS(&this->actor.shape.rot.y, Math_Vec3f_Yaw(&sp34, &sp40), 4, 0x2AA8); + } + } +} + +void EnAh_Init(Actor* thisx, GlobalContext* globalCtx) { + EnAh* this = THIS; + + if (func_80BD2A30(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_AH)) { + Actor_MarkForDeath(&this->actor); + return; + } + + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_ah_Skel_009E70, NULL, this->jointTable, this->morphTable, + 17); + this->unk_300 = -1; + func_80BD2B0C(this, 0); + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); + this->actor.targetMode = 6; + Actor_SetScale(&this->actor, 0.01f); + this->unk_1DC = 0; + this->unk_2D8 = 0; + + this->actionFunc = func_80BD36B8; + this->actionFunc(this, globalCtx); +} + +void EnAh_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnAh* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +void EnAh_Update(Actor* thisx, GlobalContext* globalCtx) { + EnAh* this = THIS; + f32 radius; + f32 height; + + func_80BD2BE8(this, globalCtx); + + this->actionFunc(this, globalCtx); + + if (this->unk_1DC != 0) { + func_80BD3198(this, globalCtx); + func_80BD2AE0(this); + func_80BD2C6C(this); + func_80BD2FD0(this, globalCtx); + radius = this->collider.dim.radius + 60; + height = this->collider.dim.height + 10; + + func_8013C964(&this->actor, globalCtx, radius, height, EXCH_ITEM_NONE, this->unk_2D8 & 7); + if (!(this->unk_2D8 & 0x10)) { + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); + } + func_80BD2BA4(this, globalCtx); + } +} + +void func_80BD3AA8(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnAh* this = THIS; + + if (limbIndex == 7) { + Matrix_MultiplyVector3fByState(&D_80BD3F00, &this->actor.focus.pos); + Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); + } +} + +void func_80BD3AF8(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { + EnAh* this = THIS; + s32 phi_v1; + s32 phi_v0; + + if (!(this->unk_2D8 & 0x80)) { + if (this->unk_2D8 & 0x20) { + phi_v0 = 1; + } else { + phi_v0 = 0; + } + phi_v1 = 1; + } else { + phi_v1 = 0; + phi_v0 = 0; + } + + if (limbIndex == 7) { + func_8013AD9C(BINANG_ADD(this->unk_2EC + this->unk_2F0, 0x4000), + BINANG_ADD(this->unk_2EE + this->unk_2F2 + this->actor.shape.rot.y, 0x4000), this->unk_1E8, + this->unk_200, phi_v1, phi_v0); + Matrix_StatePop(); + Matrix_InsertTranslation(this->unk_1E8[0].x, this->unk_1E8[0].y, this->unk_1E8[0].z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateY(this->unk_200[0].y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_200[0].x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_200[0].z, MTXMODE_APPLY); + Matrix_StatePush(); + } else if (limbIndex == 2) { + func_8013AD9C(BINANG_ADD(this->unk_2F0, 0x4000), BINANG_ADD(this->unk_2F2 + this->actor.shape.rot.y, 0x4000), + &this->unk_1E8[1], &this->unk_200[1], phi_v1, phi_v0); + Matrix_StatePop(); + Matrix_InsertTranslation(this->unk_1E8[1].x, this->unk_1E8[1].y, this->unk_1E8[1].z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateY(this->unk_200[1].y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_200[1].x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_200[1].z, MTXMODE_APPLY); + Matrix_StatePush(); + } +} + +void EnAh_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnAh* this = THIS; + + if (this->unk_1DC != 0) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80BD3F14[this->unk_2FA])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80BD3F0C[this->unk_2FC])); + + SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, NULL, func_80BD3AA8, func_80BD3AF8, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_En_Ah/z_en_ah.h b/src/overlays/actors/ovl_En_Ah/z_en_ah.h index 13dd73027d..85263e04b7 100644 --- a/src/overlays/actors/ovl_En_Ah/z_en_ah.h +++ b/src/overlays/actors/ovl_En_Ah/z_en_ah.h @@ -6,12 +6,36 @@ struct EnAh; typedef void (*EnAhActionFunc)(struct EnAh*, GlobalContext*); +typedef void (*EnAhUnkFunc)(struct EnAh*, GlobalContext*); typedef struct EnAh { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; + /* 0x0144 */ SkelAnime skelAnime; /* 0x0188 */ EnAhActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x178]; + /* 0x018C */ EnAhUnkFunc unk_18C; + /* 0x0190 */ ColliderCylinder collider; + /* 0x01DC */ u8 unk_1DC; + /* 0x01E0 */ s32 unk_1E0; + /* 0x01E4 */ Actor* unk_1E4; + /* 0x01E8 */ Vec3f unk_1E8[2]; + /* 0x0200 */ Vec3s unk_200[2]; + /* 0x020C */ Vec3s jointTable[17]; + /* 0x0272 */ Vec3s morphTable[17]; + /* 0x02D8 */ u16 unk_2D8; + /* 0x02DA */ u16 unk_2DA; + /* 0x02DC */ f32 unk_2DC; + /* 0x02E0 */ UNK_TYPE1 unk2E0[0xC]; + /* 0x02EC */ s16 unk_2EC; + /* 0x02EE */ s16 unk_2EE; + /* 0x02F0 */ s16 unk_2F0; + /* 0x02F2 */ s16 unk_2F2; + /* 0x02F4 */ s16 unk_2F4; + /* 0x02F6 */ s16 unk_2F6; + /* 0x02F8 */ s16 unk_2F8; + /* 0x02FA */ s16 unk_2FA; + /* 0x02FC */ s16 unk_2FC; + /* 0x02FE */ s16 unk_2FE; + /* 0x0300 */ s32 unk_300; } EnAh; // size = 0x304 extern const ActorInit En_Ah_InitVars; diff --git a/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c b/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c index 7f540f3b64..70e98fc15f 100644 --- a/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c +++ b/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c @@ -257,17 +257,17 @@ void func_80BED090(GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (player->transformation == PLAYER_FORM_DEKU) { - gSaveContext.weekEventReg[63] |= 8; - gSaveContext.weekEventReg[63] &= (u8)~0x10; + gSaveContext.save.weekEventReg[63] |= 8; + gSaveContext.save.weekEventReg[63] &= (u8)~0x10; } else if (player->transformation == PLAYER_FORM_ZORA) { - gSaveContext.weekEventReg[63] &= (u8)~8; - gSaveContext.weekEventReg[63] |= 0x10; + gSaveContext.save.weekEventReg[63] &= (u8)~8; + gSaveContext.save.weekEventReg[63] |= 0x10; } else if (player->transformation == PLAYER_FORM_GORON) { - gSaveContext.weekEventReg[63] |= 8; - gSaveContext.weekEventReg[63] |= 0x10; + gSaveContext.save.weekEventReg[63] |= 8; + gSaveContext.save.weekEventReg[63] |= 0x10; } else if (player->transformation == PLAYER_FORM_HUMAN) { - gSaveContext.weekEventReg[63] &= (u8)~8; - gSaveContext.weekEventReg[63] &= (u8)~0x10; + gSaveContext.save.weekEventReg[63] &= (u8)~8; + gSaveContext.save.weekEventReg[63] &= (u8)~0x10; } } @@ -275,19 +275,19 @@ s32 func_80BED140(GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (player->transformation == PLAYER_FORM_DEKU) { - if ((gSaveContext.weekEventReg[63] & 8) && !(gSaveContext.weekEventReg[63] & 0x10)) { + if ((gSaveContext.save.weekEventReg[63] & 8) && !(gSaveContext.save.weekEventReg[63] & 0x10)) { return true; } } else if (player->transformation == PLAYER_FORM_ZORA) { - if (!(gSaveContext.weekEventReg[63] & 8) && (gSaveContext.weekEventReg[63] & 0x10)) { + if (!(gSaveContext.save.weekEventReg[63] & 8) && (gSaveContext.save.weekEventReg[63] & 0x10)) { return true; } } else if (player->transformation == PLAYER_FORM_GORON) { - if ((gSaveContext.weekEventReg[63] & 8) && (gSaveContext.weekEventReg[63] & 0x10)) { + if ((gSaveContext.save.weekEventReg[63] & 8) && (gSaveContext.save.weekEventReg[63] & 0x10)) { return true; } } else if (player->transformation == PLAYER_FORM_HUMAN) { - if (!(gSaveContext.weekEventReg[63] & 8) && !(gSaveContext.weekEventReg[63] & 0x10)) { + if (!(gSaveContext.save.weekEventReg[63] & 8) && !(gSaveContext.save.weekEventReg[63] & 0x10)) { return true; } } @@ -300,7 +300,7 @@ s32 func_80BED208(EnAkindonuts* this) { return 0; } - if (gSaveContext.rupees < 10) { + if (gSaveContext.save.playerData.rupees < 10) { return 1; } @@ -314,15 +314,15 @@ s32 func_80BED208(EnAkindonuts* this) { } s32 func_80BED27C(EnAkindonuts* this) { - if (CUR_UPG_VALUE_VOID(UPG_BOMB_BAG) == 3) { + if (GET_CUR_UPG_VALUE(UPG_BOMB_BAG) == 3) { return 2; } - if (CUR_UPG_VALUE_VOID(UPG_BOMB_BAG) < 2) { + if (GET_CUR_UPG_VALUE(UPG_BOMB_BAG) < 2) { return 0; } - if (gSaveContext.rupees < 200) { + if (gSaveContext.save.playerData.rupees < 200) { return 1; } @@ -336,7 +336,7 @@ s32 func_80BED2FC(EnAkindonuts* this) { return 2; } - if (gSaveContext.rupees < 40) { + if (gSaveContext.save.playerData.rupees < 40) { return 1; } @@ -350,7 +350,7 @@ s32 func_80BED35C(EnAkindonuts* this) { return 2; } - if (gSaveContext.rupees < 100) { + if (gSaveContext.save.playerData.rupees < 100) { return 1; } @@ -384,8 +384,8 @@ void func_80BED3BC(EnAkindonuts* this, GlobalContext* globalCtx) { break; case 0x15E7: - if (!(gSaveContext.weekEventReg[61] & 0x20)) { - gSaveContext.weekEventReg[61] |= 0x20; + if (!(gSaveContext.save.weekEventReg[61] & 0x20)) { + gSaveContext.save.weekEventReg[61] |= 0x20; this->unk_33C = 0x15E8; break; } @@ -446,7 +446,7 @@ void func_80BED3BC(EnAkindonuts* this, GlobalContext* globalCtx) { case 0x15E5: this->unk_33C = 0x15E6; func_80BED090(globalCtx); - gSaveContext.weekEventReg[61] |= 0x10; + gSaveContext.save.weekEventReg[61] |= 0x10; this->unk_32C |= 0x20; break; @@ -461,8 +461,8 @@ void func_80BED3BC(EnAkindonuts* this, GlobalContext* globalCtx) { void func_80BED680(EnAkindonuts* this, GlobalContext* globalCtx) { switch (this->unk_33C) { case 0: - if (func_80BED140(globalCtx) && !(gSaveContext.weekEventReg[61] & 0x40)) { - gSaveContext.weekEventReg[61] |= 0x40; + if (func_80BED140(globalCtx) && !(gSaveContext.save.weekEventReg[61] & 0x40)) { + gSaveContext.save.weekEventReg[61] |= 0x40; this->unk_33C = 0x15F0; break; } @@ -562,8 +562,8 @@ void func_80BED8A4(EnAkindonuts* this, GlobalContext* globalCtx) { break; case 0x15FE: - if (!(gSaveContext.weekEventReg[62] & 1)) { - gSaveContext.weekEventReg[62] |= 1; + if (!(gSaveContext.save.weekEventReg[62] & 1)) { + gSaveContext.save.weekEventReg[62] |= 1; this->unk_33C = 0x15FF; break; } @@ -623,7 +623,7 @@ void func_80BED8A4(EnAkindonuts* this, GlobalContext* globalCtx) { case 0x15FA: this->unk_33C = 0x15FB; - gSaveContext.weekEventReg[61] |= 0x80; + gSaveContext.save.weekEventReg[61] |= 0x80; this->unk_32C |= 0x20; break; @@ -640,8 +640,8 @@ void func_80BEDB88(EnAkindonuts* this, GlobalContext* globalCtx) { switch (this->unk_33C) { case 0: - if ((player->transformation == PLAYER_FORM_DEKU) && !(gSaveContext.weekEventReg[62] & 2)) { - gSaveContext.weekEventReg[62] |= 2; + if ((player->transformation == PLAYER_FORM_DEKU) && !(gSaveContext.save.weekEventReg[62] & 2)) { + gSaveContext.save.weekEventReg[62] |= 2; this->unk_33C = 0x15F0; break; } @@ -740,8 +740,8 @@ void func_80BEDDAC(EnAkindonuts* this, GlobalContext* globalCtx) { break; case 0x1610: - if (!(gSaveContext.weekEventReg[62] & 8)) { - gSaveContext.weekEventReg[62] |= 8; + if (!(gSaveContext.save.weekEventReg[62] & 8)) { + gSaveContext.save.weekEventReg[62] |= 8; this->unk_33C = 0x1611; break; } @@ -796,7 +796,7 @@ void func_80BEDDAC(EnAkindonuts* this, GlobalContext* globalCtx) { case 0x15FA: this->unk_33C = 0x160D; - gSaveContext.weekEventReg[62] |= 4; + gSaveContext.save.weekEventReg[62] |= 4; this->unk_32C |= 0x20; break; @@ -813,8 +813,8 @@ void func_80BEE070(EnAkindonuts* this, GlobalContext* globalCtx) { switch (this->unk_33C) { case 0: - if ((player->transformation == PLAYER_FORM_GORON) && !(gSaveContext.weekEventReg[62] & 0x10)) { - gSaveContext.weekEventReg[62] |= 0x10; + if ((player->transformation == PLAYER_FORM_GORON) && !(gSaveContext.save.weekEventReg[62] & 0x10)) { + gSaveContext.save.weekEventReg[62] |= 0x10; this->unk_33C = 0x1614; break; } @@ -900,8 +900,8 @@ void func_80BEE274(EnAkindonuts* this, GlobalContext* globalCtx) { break; case 0x1624: - if (!(gSaveContext.weekEventReg[62] & 0x40)) { - gSaveContext.weekEventReg[62] |= 0x40; + if (!(gSaveContext.save.weekEventReg[62] & 0x40)) { + gSaveContext.save.weekEventReg[62] |= 0x40; this->unk_33C = 0x1625; break; } @@ -957,7 +957,7 @@ void func_80BEE274(EnAkindonuts* this, GlobalContext* globalCtx) { case 0x1622: this->unk_33C = 0x1623; - gSaveContext.weekEventReg[62] |= 0x20; + gSaveContext.save.weekEventReg[62] |= 0x20; this->unk_32C |= 0x20; break; @@ -974,8 +974,8 @@ void func_80BEE530(EnAkindonuts* this, GlobalContext* globalCtx) { switch (this->unk_33C) { case 0: - if ((player->transformation == PLAYER_FORM_ZORA) && !(gSaveContext.weekEventReg[62] & 0x80)) { - gSaveContext.weekEventReg[62] |= 0x80; + if ((player->transformation == PLAYER_FORM_ZORA) && !(gSaveContext.save.weekEventReg[62] & 0x80)) { + gSaveContext.save.weekEventReg[62] |= 0x80; this->unk_33C = 0x162A; break; } @@ -1095,7 +1095,7 @@ void func_80BEE73C(EnAkindonuts* this, GlobalContext* globalCtx) { void func_80BEE938(EnAkindonuts* this, GlobalContext* globalCtx) { switch (ENAKINDONUTS_GET_3(&this->actor)) { case 0: - if (gSaveContext.weekEventReg[61] & 0x10) { + if (gSaveContext.save.weekEventReg[61] & 0x10) { if (ENAKINDONUTS_GET_4(&this->actor)) { this->unk_2DC = func_80BED680; } else { @@ -1109,7 +1109,7 @@ void func_80BEE938(EnAkindonuts* this, GlobalContext* globalCtx) { break; case 1: - if (gSaveContext.weekEventReg[61] & 0x80) { + if (gSaveContext.save.weekEventReg[61] & 0x80) { if (ENAKINDONUTS_GET_4(&this->actor)) { this->unk_2DC = func_80BEDB88; } else { @@ -1123,7 +1123,7 @@ void func_80BEE938(EnAkindonuts* this, GlobalContext* globalCtx) { break; case 2: - if (gSaveContext.weekEventReg[62] & 4) { + if (gSaveContext.save.weekEventReg[62] & 4) { if (ENAKINDONUTS_GET_4(&this->actor)) { this->unk_2DC = func_80BEE070; } else { @@ -1137,7 +1137,7 @@ void func_80BEE938(EnAkindonuts* this, GlobalContext* globalCtx) { break; case 3: - if (gSaveContext.weekEventReg[62] & 0x20) { + if (gSaveContext.save.weekEventReg[62] & 0x20) { if (ENAKINDONUTS_GET_4(&this->actor)) { this->unk_2DC = func_80BEE530; } else { @@ -1243,7 +1243,7 @@ void func_80BEEFA8(EnAkindonuts* this, GlobalContext* globalCtx) { u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); if (temp_v0 == 5) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (this->unk_32C & 1) { this->unk_32C &= ~0x1; globalCtx->msgCtx.msgMode = 0x43; @@ -1265,7 +1265,7 @@ void func_80BEEFA8(EnAkindonuts* this, GlobalContext* globalCtx) { } } } else if (temp_v0 == 4) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: this->unk_32C |= 0x8; @@ -1285,7 +1285,7 @@ void func_80BEEFA8(EnAkindonuts* this, GlobalContext* globalCtx) { } void func_80BEF18C(EnAkindonuts* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; this->unk_33C = 0; @@ -1310,7 +1310,7 @@ void func_80BEF20C(EnAkindonuts* this, GlobalContext* globalCtx) { SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 6); } - if ((sp27 == 5) && func_80147624(globalCtx)) { + if ((sp27 == 5) && Message_ShouldAdvance(globalCtx)) { if (this->unk_32C & 1) { this->unk_32C &= ~0x1; globalCtx->msgCtx.msgMode = 0x43; @@ -1341,7 +1341,7 @@ void func_80BEF360(EnAkindonuts* this, GlobalContext* globalCtx) { } void func_80BEF450(EnAkindonuts* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 6) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 6) && Message_ShouldAdvance(globalCtx)) { func_800B85E0(&this->actor, globalCtx, 400.0f, -1); this->actionFunc = func_80BEF4B8; } @@ -1606,7 +1606,7 @@ void EnAkindonuts_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.gravity = -1.0f; if (!ENAKINDONUTS_GET_4(&this->actor)) { - this->path = func_8013D648(globalCtx, ENAKINDONUTS_GET_FC00(&this->actor), 0x3F); + this->path = SubS_GetPathByIndex(globalCtx, ENAKINDONUTS_GET_FC00(&this->actor), 0x3F); if (this->path == NULL) { Actor_MarkForDeath(&this->actor); return; diff --git a/src/overlays/actors/ovl_En_Al/z_en_al.c b/src/overlays/actors/ovl_En_Al/z_en_al.c index 98ba1c91fc..149f82d456 100644 --- a/src/overlays/actors/ovl_En_Al/z_en_al.c +++ b/src/overlays/actors/ovl_En_Al/z_en_al.c @@ -19,10 +19,22 @@ void EnAl_Draw(Actor* thisx, GlobalContext* globalCtx); void func_80BDF5E8(EnAl* this, GlobalContext* globalCtx); void func_80BDF6C4(EnAl* this, GlobalContext* globalCtx); -s32 D_80BDFC70[] = { - 0x0C00030D, 0x02120006, 0x0001050E, 0x12000600, 0x02020800, 0x0A002F02, 0x0A000A37, - 0x23020A37, 0x0B2D0D02, 0x0B2D1400, 0x01050E0B, 0x2D140001, 0x0C000206, 0x0E0A370B, - 0x2D010E0A, 0x370B2D03, 0x0E0A000A, 0x37010400, 0x01000000, +static u8 D_80BDFC70[] = { + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(3, 0x11 - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(18, 0, 6, 0, 0x0B - 0x0A), + /* 0x0A */ SCHEDULE_CMD_RET_NONE(), + /* 0x0B */ SCHEDULE_CMD_RET_TIME(18, 0, 6, 0, 2), + /* 0x11 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(8, 0, 10, 0, 0x46 - 0x17), + /* 0x17 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 0, 10, 55, 0x40 - 0x1D), + /* 0x1D */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 55, 11, 45, 0x30 - 0x23), + /* 0x23 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(11, 45, 20, 0, 0x2A - 0x29), + /* 0x29 */ SCHEDULE_CMD_RET_NONE(), + /* 0x2A */ SCHEDULE_CMD_RET_TIME(11, 45, 20, 0, 1), + /* 0x30 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(2, 0x3A - 0x34), + /* 0x34 */ SCHEDULE_CMD_RET_TIME(10, 55, 11, 45, 1), + /* 0x3A */ SCHEDULE_CMD_RET_TIME(10, 55, 11, 45, 3), + /* 0x40 */ SCHEDULE_CMD_RET_TIME(10, 0, 10, 55, 1), + /* 0x46 */ SCHEDULE_CMD_RET_VAL_L(1), }; s32 D_80BDFCBC[] = { @@ -187,7 +199,7 @@ Actor* func_80BDE384(EnAl* this, GlobalContext* globalCtx) { switch (this->unk_35C) { case 2: - if (!(gSaveContext.weekEventReg[89] & 8) && (gSaveContext.weekEventReg[85] & 0x80)) { + if (!(gSaveContext.save.weekEventReg[89] & 8) && (gSaveContext.save.weekEventReg[85] & 0x80)) { actor = func_80BDE1A0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_PM); } else { actor = &GET_PLAYER(globalCtx)->actor; @@ -398,7 +410,7 @@ s32 func_80BDEA14(EnAl* this, GlobalContext* globalCtx) { switch (this->unk_4E6) { case 0: case 1: - if ((gSaveContext.weekEventReg[75] & 2)) { + if ((gSaveContext.save.weekEventReg[75] & 2)) { sp18 = true; } else if (func_80BDE4E0(this, &this->unk_4E6, 0)) { sp18 = true; @@ -439,7 +451,7 @@ s32* func_80BDEABC(EnAl* this, GlobalContext* globalCtx) { return D_80BDFE84; case 2: - if (!(gSaveContext.weekEventReg[89] & 8) && (gSaveContext.weekEventReg[85] & 0x80)) { + if (!(gSaveContext.save.weekEventReg[89] & 8) && (gSaveContext.save.weekEventReg[85] & 0x80)) { this->unk_4EC = func_80BDE7FC; return D_80BDFCBC; } @@ -559,7 +571,7 @@ void func_80BDEFE4(EnAl* this, GlobalContext* globalCtx) { s32 func_80BDF064(EnAl* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - u16 sp22 = globalCtx->msgCtx.unk11F04; + u16 sp22 = globalCtx->msgCtx.currentTextId; Actor* sp1C = func_80BDE1A0(this, globalCtx, 4, 0xA4); Actor* temp_v0 = func_80BDE1A0(this, globalCtx, 4, 0x234); @@ -623,7 +635,7 @@ s32 func_80BDF064(EnAl* this, GlobalContext* globalCtx) { return false; } -s32 func_80BDF244(EnAl* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BDF244(EnAl* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret = false; Actor* sp20 = func_80BDE1A0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_GM); Actor* temp_v0 = func_80BDE1A0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_TOTO); @@ -638,16 +650,16 @@ s32 func_80BDF244(EnAl* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80BDF308(EnAl* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BDF308(EnAl* this, GlobalContext* globalCtx, ScheduleResult* arg2) { SubS_UpdateFlags(&this->unk_4C2, 3, 7); - switch (arg2->unk0) { + switch (arg2->result) { case 1: func_80BDE27C(this, 0); break; case 2: - this->unk_4F0 = 0; + this->unk_4F0 = EXCH_ITEM_NONE; this->unk_4EA = 0; func_80BDE27C(this, 2); break; @@ -655,16 +667,16 @@ s32 func_80BDF308(EnAl* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return true; } -s32 func_80BDF390(EnAl* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BDF390(EnAl* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret; this->actor.flags |= ACTOR_FLAG_1; this->actor.targetMode = 0; - this->unk_4F0 = 0; + this->unk_4F0 = EXCH_ITEM_NONE; this->unk_4C2 = 0; this->unk_4D4 = 40.0f; - switch (arg2->unk0) { + switch (arg2->result) { case 3: ret = func_80BDF244(this, globalCtx, arg2); break; @@ -687,15 +699,15 @@ void func_80BDF414(EnAl* this, GlobalContext* globalCtx) { switch (this->unk_4EA) { case 0: case 1: - if (!(gSaveContext.weekEventReg[89] & 8)) { - if (gSaveContext.weekEventReg[85] & 0x80) { + if (!(gSaveContext.save.weekEventReg[89] & 8)) { + if (gSaveContext.save.weekEventReg[85] & 0x80) { func_80BDE4E0(this, &this->unk_4EA, 0); } } break; case 2: - if (gSaveContext.weekEventReg[89] & 8) { + if (gSaveContext.save.weekEventReg[89] & 8) { this->unk_4EA++; } break; @@ -734,20 +746,19 @@ void func_80BDF578(EnAl* this, GlobalContext* globalCtx) { } void func_80BDF5E8(EnAl* this, GlobalContext* globalCtx) { - u32* unk14 = &gSaveContext.unk_14; - struct_80133038_arg2 sp20; + ScheduleResult sp20; - this->unk_4E0 = REG(15) + *unk14; - if (!func_80133038(globalCtx, D_80BDFC70, &sp20) || - ((this->unk_35C != sp20.unk0) && !func_80BDF390(this, globalCtx, &sp20))) { + this->unk_4E0 = REG(15) + ((void)0, gSaveContext.save.daySpeed); + if (!Schedule_RunScript(globalCtx, D_80BDFC70, &sp20) || + ((this->unk_35C != sp20.result) && !func_80BDF390(this, globalCtx, &sp20))) { this->actor.shape.shadowDraw = NULL; this->actor.flags &= ~ACTOR_FLAG_1; - sp20.unk0 = 0; + sp20.result = 0; } else { this->actor.shape.shadowDraw = ActorShadow_DrawCircle; this->actor.flags |= ACTOR_FLAG_1; } - this->unk_35C = sp20.unk0; + this->unk_35C = sp20.result; this->unk_368 = func_80BDE384(this, globalCtx); func_80BDF578(this, globalCtx); } diff --git a/src/overlays/actors/ovl_En_Am/z_en_am.c b/src/overlays/actors/ovl_En_Am/z_en_am.c index 083bcfa417..c5b9381f6f 100644 --- a/src/overlays/actors/ovl_En_Am/z_en_am.c +++ b/src/overlays/actors/ovl_En_Am/z_en_am.c @@ -477,8 +477,8 @@ s32 EnAm_UpdateDamage(EnAm* this, GlobalContext* globalCtx) { } this->enemyCollider.base.atFlags &= ~AT_HIT; if (this->actor.colChkInfo.damageEffect == 0x4) { - this->effectScale = 0.7f; - this->effectAlpha = 4.0f; + this->drawDmgEffScale = 0.7f; + this->drawDmgEffAlpha = 4.0f; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->enemyCollider.info.bumper.hitPos.x, this->enemyCollider.info.bumper.hitPos.y, this->enemyCollider.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); @@ -521,9 +521,9 @@ void EnAm_Update(Actor* thisx, GlobalContext* globalCtx) { this->actor.flags |= ACTOR_FLAG_1000000; CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->enemyCollider.base); } - Math_StepToF(&this->effectAlpha, 0.0f, 0.05f); - this->effectScale = (this->effectAlpha + 1.0f) * 0.35f; - this->effectScale = (this->effectScale > 0.7f) ? 0.7f : this->effectScale; + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.35f; + this->drawDmgEffScale = (this->drawDmgEffScale > 0.7f) ? 0.7f : this->drawDmgEffScale; } void EnAm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { @@ -566,6 +566,7 @@ void EnAm_Draw(Actor* thisx, GlobalContext* globalCtx) { POLY_OPA_DISP = &gfx[2]; SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, EnAm_PostLimbDraw, &this->actor); - func_800BE680(globalCtx, &this->actor, this->limbPos, 13, this->effectScale, 0.0f, this->effectAlpha, 20); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, + 0.0f, this->drawDmgEffAlpha, ACTOR_DRAW_DMGEFF_LIGHT_ORBS); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Am/z_en_am.h b/src/overlays/actors/ovl_En_Am/z_en_am.h index 02ba4dd4a5..2199a832f7 100644 --- a/src/overlays/actors/ovl_En_Am/z_en_am.h +++ b/src/overlays/actors/ovl_En_Am/z_en_am.h @@ -20,8 +20,8 @@ typedef struct EnAm { /* 0x023A */ s16 unkFlag; /* 0x023C */ s16 armosYaw; // Yaw of Armos /* 0x0240 */ f32 speed; // Hopping speed of Armos - /* 0x0244 */ f32 effectAlpha; - /* 0x0248 */ f32 effectScale; + /* 0x0244 */ f32 drawDmgEffAlpha; + /* 0x0248 */ f32 drawDmgEffScale; /* 0x024C */ Vec3f limbPos[13]; /* 0x02E8 */ ColliderCylinder enemyCollider; // Collider for when Armos is Hostile /* 0x0334 */ ColliderCylinder interactCollider; // Collider for when an interactable Armos is docile diff --git a/src/overlays/actors/ovl_En_Ani/z_en_ani.c b/src/overlays/actors/ovl_En_Ani/z_en_ani.c index 00bf054619..43e9de4f0c 100644 --- a/src/overlays/actors/ovl_En_Ani/z_en_ani.c +++ b/src/overlays/actors/ovl_En_Ani/z_en_ani.c @@ -175,7 +175,7 @@ void EnAni_IdleStanding(EnAni* this, GlobalContext* globalCtx) { void EnAni_Talk(EnAni* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); - if (Message_GetState(&globalCtx->msgCtx) == 2 && globalCtx->msgCtx.unk11F04 == 0x6DE) { + if (Message_GetState(&globalCtx->msgCtx) == 2 && globalCtx->msgCtx.currentTextId == 0x6DE) { this->actionFunc = EnAni_IdleInPain; } } diff --git a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c index 26cde7e4c8..9bfd07939c 100644 --- a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c +++ b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c @@ -7,7 +7,6 @@ #include "z_en_aob_01.h" #include "overlays/actors/ovl_En_Racedog/z_en_racedog.h" #include "overlays/actors/ovl_En_Dg/z_en_dg.h" -#include "objects/object_aob/object_aob.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) @@ -46,12 +45,12 @@ const ActorInit En_Aob_01_InitVars = { }; static AnimationInfo D_809C3790[6] = { - { &object_aob_Anim_007758, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, - { &object_aob_Anim_0068B4, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, - { &object_aob_Anim_00700C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, - { &object_aob_Anim_0058EC, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, - { &object_aob_Anim_006040, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, - { &object_aob_Anim_007758, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -6.0f }, + { &gMamamuYanIdleAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gMamamuYanLaughStartAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, + { &gMamamuYanLaughLoopAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gMamamuYanSurpriseStartAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, + { &gMamamuYanSurpriseLoopAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gMamamuYanIdleAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -6.0f }, }; static ColliderCylinderInit sCylinderInit = { @@ -91,21 +90,21 @@ static EnAobStruct D_809C384C[] = { }; void func_809C10B0(EnAob01* this, s32 arg1) { - if (DECR(this->unk_3F0) == 0) { - this->unk_3EE++; - if (this->unk_3EE >= arg1) { - this->unk_3EE = 0; - this->unk_3F0 = Rand_S16Offset(30, 30); + if (DECR(this->blinkTimer) == 0) { + this->eyeIndex++; + if (this->eyeIndex >= arg1) { + this->eyeIndex = 0; + this->blinkTimer = Rand_S16Offset(30, 30); } } } void func_809C1124(void) { - u16 time = gSaveContext.time; + u16 time = gSaveContext.save.time; - gSaveContext.time = (u16)REG(15) + time; - time = gSaveContext.time; - gSaveContext.time = (u16)gSaveContext.unk_14 + time; + gSaveContext.save.time = (u16)REG(15) + time; + time = gSaveContext.save.time; + gSaveContext.save.time = (u16)gSaveContext.save.daySpeed + time; } void func_809C1158(EnAob01* this, GlobalContext* globalCtx) { @@ -114,7 +113,7 @@ void func_809C1158(EnAob01* this, GlobalContext* globalCtx) { if (temp_s0 != 0x3F) { do { - this->unk_1D8[i] = func_8013D648(globalCtx, temp_s0, 0x3F); + this->unk_1D8[i] = SubS_GetPathByIndex(globalCtx, temp_s0, 0x3F); temp_s0 = this->unk_1D8[i]->unk1; i++; } while (temp_s0 != 0xFF); @@ -219,18 +218,18 @@ void func_809C16DC(EnAob01* this, GlobalContext* globalCtx) { case 0x3548: case 0x3549: case 0x354A: - switch (gSaveContext.day) { + switch (gSaveContext.save.day) { case 1: - if (!gSaveContext.isNight) { - if (!(gSaveContext.weekEventReg[64] & 0x80)) { - gSaveContext.weekEventReg[64] |= 0x80; + if (!gSaveContext.save.isNight) { + if (!(gSaveContext.save.weekEventReg[64] & 0x80)) { + gSaveContext.save.weekEventReg[64] |= 0x80; this->unk_210 = 0x3520; } else { this->unk_210 = 0x352F; } } else { - if (!(gSaveContext.weekEventReg[65] & 1)) { - gSaveContext.weekEventReg[65] |= 1; + if (!(gSaveContext.save.weekEventReg[65] & 1)) { + gSaveContext.save.weekEventReg[65] |= 1; this->unk_210 = 0x3530; } else { this->unk_210 = 0x352F; @@ -239,16 +238,16 @@ void func_809C16DC(EnAob01* this, GlobalContext* globalCtx) { break; case 2: - if (!gSaveContext.isNight) { - if (!(gSaveContext.weekEventReg[65] & 2)) { - gSaveContext.weekEventReg[65] |= 2; + if (!gSaveContext.save.isNight) { + if (!(gSaveContext.save.weekEventReg[65] & 2)) { + gSaveContext.save.weekEventReg[65] |= 2; this->unk_210 = 0x3531; } else { this->unk_210 = 0x352F; } } else { - if (!(gSaveContext.weekEventReg[65] & 4)) { - gSaveContext.weekEventReg[65] |= 4; + if (!(gSaveContext.save.weekEventReg[65] & 4)) { + gSaveContext.save.weekEventReg[65] |= 4; this->unk_210 = 0x3532; } else { this->unk_210 = 0x352F; @@ -257,16 +256,16 @@ void func_809C16DC(EnAob01* this, GlobalContext* globalCtx) { break; case 3: - if (!gSaveContext.isNight) { - if (!(gSaveContext.weekEventReg[65] & 8)) { - gSaveContext.weekEventReg[65] |= 8; + if (!gSaveContext.save.isNight) { + if (!(gSaveContext.save.weekEventReg[65] & 8)) { + gSaveContext.save.weekEventReg[65] |= 8; this->unk_210 = 0x3533; } else { this->unk_210 = 0x352F; } } else { - if (!(gSaveContext.weekEventReg[65] & 0x10)) { - gSaveContext.weekEventReg[65] |= 0x10; + if (!(gSaveContext.save.weekEventReg[65] & 0x10)) { + gSaveContext.save.weekEventReg[65] |= 0x10; this->unk_210 = 0x3534; } else { this->unk_210 = 0x352F; @@ -307,7 +306,7 @@ void func_809C16DC(EnAob01* this, GlobalContext* globalCtx) { break; case PLAYER_FORM_HUMAN: - if (gSaveContext.rupees < 10) { + if (gSaveContext.save.playerData.rupees < 10) { this->unk_210 = 0x3524; this->unk_2D2 |= 0x10; } else { @@ -371,7 +370,7 @@ void func_809C16DC(EnAob01* this, GlobalContext* globalCtx) { break; case 0x3528: - if (gSaveContext.rupees < this->unk_434) { + if (gSaveContext.save.playerData.rupees < this->unk_434) { this->unk_210 = 0x3536; this->unk_2D2 |= 0x40; this->unk_43C = 1; @@ -416,8 +415,8 @@ void func_809C16DC(EnAob01* this, GlobalContext* globalCtx) { void func_809C1C9C(EnAob01* this, GlobalContext* globalCtx) { if (gSaveContext.rupeeAccumulator == 0) { - gSaveContext.weekEventReg[63] |= 1; - gSaveContext.weekEventReg[63] &= (u8)~2; + gSaveContext.save.weekEventReg[63] |= 1; + gSaveContext.save.weekEventReg[63] &= (u8)~2; this->unk_2D2 |= 0x20; func_800FD750(0x40); globalCtx->nextEntranceIndex = 0x7C10; @@ -433,10 +432,10 @@ void func_809C1D64(EnAob01* this, GlobalContext* globalCtx) { u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); if (temp_v0 == 4) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: - if (gSaveContext.rupees < 10) { + if (gSaveContext.save.playerData.rupees < 10) { play_sound(NA_SE_SY_ERROR); this->unk_210 = 0x3524; Message_StartTextbox(globalCtx, this->unk_210, &this->actor); @@ -457,7 +456,7 @@ void func_809C1D64(EnAob01* this, GlobalContext* globalCtx) { break; } } - } else if ((temp_v0 == 5) && func_80147624(globalCtx)) { + } else if ((temp_v0 == 5) && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; this->unk_210 = 0; @@ -561,7 +560,7 @@ void func_809C21E0(EnAob01* this, GlobalContext* globalCtx) { this->unk_2D2 &= ~8; } } else if (sp2F == 4) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { this->unk_2D2 &= ~0x40; switch (globalCtx->msgCtx.choiceIndex) { case 0: @@ -577,7 +576,7 @@ void func_809C21E0(EnAob01* this, GlobalContext* globalCtx) { } } } else if (sp2F == 5) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { this->unk_2D2 &= ~0x40; if (this->unk_2D2 & 0x10) { this->unk_2D2 &= ~0x10; @@ -588,7 +587,7 @@ void func_809C21E0(EnAob01* this, GlobalContext* globalCtx) { func_809C16DC(this, globalCtx); } } - } else if ((sp2F == 14) && func_80147624(globalCtx)) { + } else if ((sp2F == 14) && Message_ShouldAdvance(globalCtx)) { this->unk_2D2 &= ~0x40; this->unk_434 = globalCtx->msgCtx.bankRupeesSelected; func_809C16DC(this, globalCtx); @@ -599,7 +598,7 @@ s32 func_809C2504(EnAob01* this, GlobalContext* globalCtx) { Actor* npc = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; while (npc != NULL) { - if ((npc->id == ACTOR_EN_RACEDOG) && (func_800F2178(this->unk_430) == ((EnRacedog*)npc)->unk_1E8)) { + if ((npc->id == ACTOR_EN_RACEDOG) && (func_800F2178(this->unk_430) == ((EnRacedog*)npc)->currentPoint)) { ActorCutscene_Stop(this->unk_430); this->unk_3F4 = npc; this->unk_430 = ActorCutscene_GetAdditionalCutscene(this->unk_430); @@ -615,7 +614,7 @@ s32 func_809C2594(EnAob01* this, GlobalContext* globalCtx) { Actor* npc = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; while (npc != NULL) { - if ((npc->id == ACTOR_EN_RACEDOG) && (((EnRacedog*)npc)->unk_290 == ((EnRacedog*)npc)->unk_292)) { + if ((npc->id == ACTOR_EN_RACEDOG) && (((EnRacedog*)npc)->index == ((EnRacedog*)npc)->selectedDogIndex)) { this->unk_3F4 = npc; return true; } @@ -630,7 +629,7 @@ s32 func_809C25E4(EnAob01* this, GlobalContext* globalCtx) { s16 count = 0; while (npc != NULL) { - if ((npc->id == ACTOR_EN_RACEDOG) && (((EnRacedog*)npc)->unk_29C == 3)) { + if ((npc->id == ACTOR_EN_RACEDOG) && (((EnRacedog*)npc)->raceStatus == RACEDOG_RACE_STATUS_FINISHED)) { count++; } npc = npc->next; @@ -670,7 +669,6 @@ void func_809C2730(EnAob01* this, GlobalContext* globalCtx) { void func_809C2788(EnAob01* this, GlobalContext* globalCtx) { this->unk_2D2 |= 0x20; if (func_809C25E4(this, globalCtx)) { - globalCtx = globalCtx; if (func_801A8A50(0) != 0x41) { globalCtx->nextEntranceIndex = 0x7C10; gSaveContext.eventInf[0] = (gSaveContext.eventInf[0] & (u8)~7) | 3; @@ -749,7 +747,7 @@ void func_809C2A64(EnAob01* this, GlobalContext* globalCtx) { u8 sp2F = Message_GetState(&globalCtx->msgCtx); if (func_809C15BC(this)) { - if ((sp2F == 5) && func_80147624(globalCtx)) { + if ((sp2F == 5) && Message_ShouldAdvance(globalCtx)) { this->unk_434 = 0; globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; @@ -761,13 +759,13 @@ void func_809C2A64(EnAob01* this, GlobalContext* globalCtx) { this->unk_2E0 = this->unk_2F2; this->actor.parent = NULL; this->actor.shape.rot.y = this->actor.world.rot.y; - if (gSaveContext.weekEventReg[8] & 0x20) { + if (gSaveContext.save.weekEventReg[8] & 0x20) { this->actionFunc = func_809C2BE4; } else { - gSaveContext.weekEventReg[8] |= 0x20; + gSaveContext.save.weekEventReg[8] |= 0x20; this->actionFunc = func_809C2BE4; } - } else if (gSaveContext.weekEventReg[8] & 0x20) { + } else if (gSaveContext.save.weekEventReg[8] & 0x20) { Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_RED, 300.0f, 300.0f); } else { Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 300.0f, 300.0f); @@ -778,13 +776,13 @@ void func_809C2A64(EnAob01* this, GlobalContext* globalCtx) { void func_809C2BE4(EnAob01* this, GlobalContext* globalCtx) { u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); - if (((temp_v0 == 5) || (temp_v0 == 6)) && func_80147624(globalCtx)) { - if (gSaveContext.weekEventReg[63] & 2) { - gSaveContext.weekEventReg[63] &= (u8)~2; + if (((temp_v0 == 5) || (temp_v0 == 6)) && Message_ShouldAdvance(globalCtx)) { + if (gSaveContext.save.weekEventReg[63] & 2) { + gSaveContext.save.weekEventReg[63] &= (u8)~2; } - if (gSaveContext.weekEventReg[63] & 1) { - gSaveContext.weekEventReg[63] &= (u8)~1; + if (gSaveContext.save.weekEventReg[63] & 1) { + gSaveContext.save.weekEventReg[63] &= (u8)~1; } this->unk_210 = 0; @@ -819,7 +817,7 @@ void func_809C2D0C(EnAob01* this, GlobalContext* globalCtx) { } } - if ((sp2F == 5) && func_80147624(globalCtx)) { + if ((sp2F == 5) && Message_ShouldAdvance(globalCtx)) { this->unk_2D2 &= ~0x40; this->unk_2D2 &= ~0x80; if (this->unk_434 >= 150) { @@ -833,12 +831,12 @@ void func_809C2D0C(EnAob01* this, GlobalContext* globalCtx) { this->unk_434 = 0; this->actor.shape.rot.y = this->actor.world.rot.y; - if (gSaveContext.weekEventReg[63] & 2) { - gSaveContext.weekEventReg[63] &= (u8)~2; + if (gSaveContext.save.weekEventReg[63] & 2) { + gSaveContext.save.weekEventReg[63] &= (u8)~2; } - if (gSaveContext.weekEventReg[63] & 1) { - gSaveContext.weekEventReg[63] &= (u8)~1; + if (gSaveContext.save.weekEventReg[63] & 1) { + gSaveContext.save.weekEventReg[63] &= (u8)~1; } this->unk_210 = 0x354C; @@ -854,12 +852,12 @@ s32 func_809C2EC4(EnAob01* this, GlobalContext* globalCtx) { while (dog != NULL) { if (dog->id == ACTOR_EN_DG) { - this->unk_432 = ((EnDg*)dog)->unk_288; + this->unk_432 = ((EnDg*)dog)->selectedDogIndex; if (this->unk_432 == -1) { return false; } - if (this->unk_432 == ENDG_GET_3E0(dog)) { + if (this->unk_432 == ENDG_GET_INDEX(dog)) { return true; } } @@ -902,7 +900,7 @@ void func_809C2FA0(void) { } for (i = 0; i < ARRAY_COUNT(sp44); i++) { - gSaveContext.weekEventReg[42 + i] = 0; + gSaveContext.save.weekEventReg[42 + i] = 0; sp44[i] = 0; } @@ -912,8 +910,8 @@ void func_809C2FA0(void) { if (i % 2) { sp44[idx2] |= orig2 << 0x4; - idx = gSaveContext.weekEventReg[42 + idx2]; - gSaveContext.weekEventReg[42 + idx2] = idx | sp44[idx2]; + idx = gSaveContext.save.weekEventReg[42 + idx2]; + gSaveContext.save.weekEventReg[42 + idx2] = idx | sp44[idx2]; } else { sp44[idx2] |= orig2; } @@ -925,8 +923,8 @@ void EnAob01_Init(Actor* thisx, GlobalContext* globalCtx) { EnAob01* this = THIS; ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_aob_Skel_000180, NULL, this->jointTable, this->morphTable, - 16); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gMamamuYanSkel, NULL, this->jointTable, this->morphTable, + MAMAMU_YAN_LIMB_MAX); Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); this->unk_43C = 0; @@ -967,7 +965,7 @@ void EnAob01_Destroy(Actor* thisx, GlobalContext* globalCtx) { EnAob01* this = THIS; if (!(this->unk_2D2 & 0x20)) { - gSaveContext.weekEventReg[63] &= (u8)~1; + gSaveContext.save.weekEventReg[63] &= (u8)~1; } Collider_DestroyCylinder(globalCtx, &this->collider); } @@ -982,35 +980,36 @@ void EnAob01_Update(Actor* thisx, GlobalContext* globalCtx) { s32 EnAob01_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnAob01* this = THIS; - TexturePtr sp38[] = { - object_aob_Tex_000658, - object_aob_Tex_000E58, - object_aob_Tex_001658, + TexturePtr eyeTextures[] = { + gMamamuYanEyeOpenTex, + gMamamuYanEyeHalfTex, + gMamamuYanEyeClosedTex, }; - if (limbIndex == 15) { + if (limbIndex == MAMAMU_YAN_LIMB_HEAD) { OPEN_DISPS(globalCtx->state.gfxCtx); - *dList = object_aob_DL_003D18; + *dList = gMamamuYanHeadDL; - gSPSegment(POLY_OPA_DISP++, 0x0A, Lib_SegmentedToVirtual(sp38[this->unk_3EE])); + gSPSegment(POLY_OPA_DISP++, 0x0A, Lib_SegmentedToVirtual(eyeTextures[this->eyeIndex])); CLOSE_DISPS(globalCtx->state.gfxCtx); } - if (limbIndex == 15) { + if (limbIndex == MAMAMU_YAN_LIMB_HEAD) { Matrix_InsertTranslation(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); Matrix_InsertXRotation_s(this->unk_2DA.y, MTXMODE_APPLY); Matrix_InsertZRotation_s(this->unk_2DA.x * -1, MTXMODE_APPLY); Matrix_InsertTranslation(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); } - if (limbIndex == 8) { + if (limbIndex == MAMAMU_YAN_LIMB_TORSO) { Matrix_InsertXRotation_s(this->unk_2E0.y * -1, MTXMODE_APPLY); Matrix_InsertZRotation_s(this->unk_2E0.x * -1, MTXMODE_APPLY); } - if ((limbIndex == 8) || (limbIndex == 9) || (limbIndex == 12)) { + if ((limbIndex == MAMAMU_YAN_LIMB_TORSO) || (limbIndex == MAMAMU_YAN_LIMB_LEFT_UPPER_ARM) || + (limbIndex == MAMAMU_YAN_LIMB_RIGHT_UPPER_ARM)) { rot->y += (s16)Math_SinS(this->unk_2F8[limbIndex]) * 200; rot->z += (s16)Math_CosS(this->unk_318[limbIndex]) * 200; } @@ -1021,7 +1020,7 @@ void EnAob01_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, static Vec3f D_809C3968 = { 0.0f, 0.0f, 0.0f }; EnAob01* this = THIS; - if (limbIndex == 15) { + if (limbIndex == MAMAMU_YAN_LIMB_HEAD) { Matrix_MultiplyVector3fByState(&D_809C3968, &this->actor.focus.pos); } } diff --git a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.h b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.h index be7655fad0..69e15f6589 100644 --- a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.h +++ b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.h @@ -2,6 +2,7 @@ #define Z_EN_AOB_01_H #include "global.h" +#include "objects/object_aob/object_aob.h" struct EnAob01; @@ -17,8 +18,8 @@ typedef struct EnAob01 { /* 0x18C */ ColliderCylinder collider; /* 0x1D8 */ Path* unk_1D8[14]; /* 0x210 */ u16 unk_210; - /* 0x212 */ Vec3s jointTable[16]; - /* 0x272 */ Vec3s morphTable[16]; + /* 0x212 */ Vec3s jointTable[MAMAMU_YAN_LIMB_MAX]; + /* 0x272 */ Vec3s morphTable[MAMAMU_YAN_LIMB_MAX]; /* 0x2D2 */ u16 unk_2D2; /* 0x2D4 */ Vec3s unk_2D4; /* 0x2DA */ Vec3s unk_2DA; @@ -26,11 +27,11 @@ typedef struct EnAob01 { /* 0x2E6 */ Vec3s unk_2E6; /* 0x2EC */ Vec3s unk_2EC; /* 0x2F2 */ Vec3s unk_2F2; - /* 0x2F8 */ s16 unk_2F8[16]; - /* 0x318 */ s16 unk_318[16]; + /* 0x2F8 */ s16 unk_2F8[MAMAMU_YAN_LIMB_MAX]; + /* 0x318 */ s16 unk_318[MAMAMU_YAN_LIMB_MAX]; /* 0x338 */ UNK_TYPE1 unk338[0xB6]; - /* 0x3EE */ s16 unk_3EE; - /* 0x3F0 */ s16 unk_3F0; + /* 0x3EE */ s16 eyeIndex; + /* 0x3F0 */ s16 blinkTimer; /* 0x3F4 */ Actor* unk_3F4; /* 0x3F8 */ Actor* unk_3F8[14]; /* 0x430 */ s16 unk_430; diff --git a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c index d3286f5451..f1dc5c6f6a 100644 --- a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c +++ b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c @@ -357,10 +357,10 @@ void func_8088ACE0(EnArrow* this, GlobalContext* globalCtx) { if ((this->unk_262 != 0) && (this->actor.wallBgId == BG_ACTOR_MAX)) { - Math_Vec3f_Copy(&sp84.unk_00, &this->actor.world.pos); - sp84.unk_0C = this->actor.wallPoly; - sp84.unk_10 = this->bubble.unk_144; - EffectSs_Spawn(globalCtx, EFFECT_SS_SBN, 128, &sp84.unk_00); + Math_Vec3f_Copy(&sp84.pos, &this->actor.world.pos); + sp84.colPoly = this->actor.wallPoly; + sp84.scale = this->bubble.unk_144; + EffectSs_Spawn(globalCtx, EFFECT_SS_SBN, 128, &sp84); } } Actor_MarkForDeath(&this->actor); diff --git a/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.c b/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.c index 90e99b5ea6..b100f692ff 100644 --- a/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.c +++ b/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.c @@ -5,6 +5,7 @@ */ #include "z_en_attack_niw.h" +#include "overlays/actors/ovl_En_Niw/z_en_niw.h" #define FLAGS (ACTOR_FLAG_10) @@ -19,7 +20,6 @@ void func_80958634(EnAttackNiw* this, GlobalContext* globalCtx); void func_80958974(EnAttackNiw* this, GlobalContext* globalCtx); void func_80958BE4(EnAttackNiw* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Attack_Niw_InitVars = { ACTOR_EN_ATTACK_NIW, ACTORCAT_ENEMY, @@ -32,35 +32,421 @@ const ActorInit En_Attack_Niw_InitVars = { (ActorFunc)EnAttackNiw_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80959120[] = { +static InitChainEntry sInitChain[] = { ICHAIN_U8(targetMode, 1, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -2000, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 0, ICHAIN_STOP), }; -#endif +void EnAttackNiw_Init(Actor* thisx, GlobalContext* globalCtx) { + EnAttackNiw* this = THIS; -extern InitChainEntry D_80959120[]; + Actor_ProcessInitChain(&this->actor, sInitChain); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_niw_Skel_002530, &object_niw_Anim_0000E8, this->jointTable, + this->morphTable, OBJECT_NIW_LIMB_MAX); -extern UNK_TYPE D_060000E8; + if (this->actor.params < 0) { + this->actor.params = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Attack_Niw/EnAttackNiw_Init.s") + Actor_SetScale(&this->actor, 0.01f); + this->actor.gravity = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Attack_Niw/EnAttackNiw_Destroy.s") + this->unk_290.x = randPlusMinusPoint5Scaled(100.0f); + this->unk_290.y = randPlusMinusPoint5Scaled(10.0f); + this->unk_290.z = randPlusMinusPoint5Scaled(100.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Attack_Niw/func_80958228.s") + Actor_SetScale(&this->actor, 0.01f); + this->actor.flags &= ~ACTOR_FLAG_1; + this->actor.shape.rot.y = this->actor.world.rot.y = (Rand_ZeroOne() - 0.5f) * 60000.0f; + this->actionFunc = func_80958634; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Attack_Niw/func_809585B0.s") +void EnAttackNiw_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnAttackNiw* this = THIS; + EnNiw* parent = (EnNiw*)this->actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Attack_Niw/func_80958634.s") + if ((thisx->parent != NULL) && (thisx->parent->update != NULL)) { + if (parent->unk290 > 0) { + parent->unk290--; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Attack_Niw/func_80958974.s") +void func_80958228(EnAttackNiw* this, GlobalContext* globalCtx, s16 arg2) { + if (this->unk_24C == 0) { + if (arg2 == 0) { + this->unk_25C = 0.0f; + } else { + this->unk_25C = -10000.0f; + } + this->unk_286++; + this->unk_24C = 3; + if ((this->unk_286 % 2) == 0) { + this->unk_25C = 0.0f; + if (arg2 == 0) { + this->unk_24C = Rand_ZeroFloat(30.0f); + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Attack_Niw/func_80958BE4.s") + if (this->unk_250 == 0) { + this->unk_28A++; + this->unk_28A &= 1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Attack_Niw/EnAttackNiw_Update.s") + switch (arg2) { + case 0: + this->unk_264 = 0.0f; + this->unk_260 = 0.0f; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Attack_Niw/func_80958F6C.s") + case 1: + this->unk_250 = 3; + this->unk_264 = 7000.0f; + this->unk_260 = 7000.0f; + if (this->unk_28A == 0) { + this->unk_264 = 0.0f; + this->unk_260 = 0.0f; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Attack_Niw/EnAttackNiw_Draw.s") + case 2: + this->unk_250 = 2; + this->unk_264 = -10000.0f; + this->unk_260 = -10000.0f; + this->unk_278 = 25000.0f; + this->unk_270 = 25000.0f; + this->unk_27C = 6000.0f; + this->unk_274 = 6000.0f; + if (this->unk_28A == 0) { + this->unk_270 = 8000.0f; + this->unk_278 = 8000.0f; + } + break; + + case 3: + this->unk_250 = 2; + this->unk_270 = 10000.0f; + this->unk_278 = 10000.0f; + if (this->unk_28A == 0) { + this->unk_270 = 3000.0f; + this->unk_278 = 3000.0f; + } + break; + + case 4: + this->unk_24E = 5; + this->unk_24C = this->unk_24E; + break; + + case 5: + this->unk_250 = 5; + this->unk_270 = 14000.0f; + this->unk_278 = 14000.0f; + if (this->unk_28A == 0) { + this->unk_270 = 10000.0f; + this->unk_278 = 10000.0f; + } + break; + } + } + + if (this->unk_280 != this->unk_2B8) { + Math_ApproachF(&this->unk_2B8, this->unk_280, 0.5f, 4000.0f); + } + + if (this->unk_25C != this->unk_2B4) { + Math_ApproachF(&this->unk_2B4, this->unk_25C, 0.5f, 4000.0f); + } + + if (this->unk_264 != this->unk_29C) { + Math_ApproachF(&this->unk_29C, this->unk_264, 0.8f, 7000.0f); + } + + if (this->unk_278 != this->unk_2A0) { + Math_ApproachF(&this->unk_2A0, this->unk_278, 0.8f, 7000.0f); + } + + if (this->unk_27C != this->unk_2A4) { + Math_ApproachF(&this->unk_2A4, this->unk_27C, 0.8f, 7000.0f); + } + + if (this->unk_260 != this->unk_2A8) { + Math_ApproachF(&this->unk_2A8, this->unk_260, 0.8f, 7000.0f); + } + + if (this->unk_270 != this->unk_2AC) { + Math_ApproachF(&this->unk_2AC, this->unk_270, 0.8f, 7000.0f); + } + + if (this->unk_274 != this->unk_2B0) { + Math_ApproachF(&this->unk_2B0, this->unk_274, 0.8f, 7000.0f); + } +} + +s32 func_809585B0(EnAttackNiw* this, GlobalContext* globalCtx) { + s16 sp1E; + s16 sp1C; + + Actor_SetFocus(&this->actor, this->unk_2DC); + Actor_GetScreenPos(globalCtx, &this->actor, &sp1E, &sp1C); + + if ((this->actor.projectedPos.z < -20.0f) || (sp1E < 0) || (sp1E > SCREEN_WIDTH) || (sp1C < 0) || + (sp1C > SCREEN_HEIGHT)) { + return false; + } + return true; +} + +void func_80958634(EnAttackNiw* this, GlobalContext* globalCtx) { + s16 sp4E; + s16 sp4C; + Vec3f temp; + Vec3f sp34; + s32 pad; + + this->actor.speedXZ = 10.0f; + + temp.x = (this->unk_290.x + globalCtx->view.at.x) - globalCtx->view.eye.x; + temp.y = (this->unk_290.y + globalCtx->view.at.y) - globalCtx->view.eye.y; + temp.z = (this->unk_290.z + globalCtx->view.at.z) - globalCtx->view.eye.z; + + sp34.x = globalCtx->view.at.x + temp.x; + sp34.y = globalCtx->view.at.y + temp.y; + sp34.z = globalCtx->view.at.z + temp.z; + + this->unk_2CC = Math_Vec3f_Yaw(&this->actor.world.pos, &sp34); + this->unk_2C8 = Math_Vec3f_Pitch(&this->actor.world.pos, &sp34) * -1.0f; + + Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_2CC, 5, this->unk_2D4, 0); + Math_SmoothStepToS(&this->actor.world.rot.x, this->unk_2C8, 5, this->unk_2D4, 0); + Math_ApproachF(&this->unk_2D4, 5000.0f, 1.0f, 100.0f); + + Actor_SetFocus(&this->actor, this->unk_2DC); + Actor_GetScreenPos(globalCtx, &this->actor, &sp4E, &sp4C); + + if (this->actor.bgCheckFlags & 8) { + this->unk_2CC = this->actor.yawTowardsPlayer; + this->unk_2C8 = this->actor.world.rot.x - 3000.0f; + this->unk_252 = 0; + this->unk_254 = 100; + this->unk_2D4 = 0.0f; + this->unk_27C = 0.0f; + this->unk_274 = 0.0f; + this->unk_250 = this->unk_252; + this->unk_24E = this->unk_252; + this->unk_24C = this->unk_252; + this->actor.gravity = -0.2f; + this->unk_280 = 0.0f; + this->actionFunc = func_80958974; + this->unk_2D8 = 5.0f; + } else if (((this->actor.projectedPos.z > 0.0f) && (fabsf(sp34.x - this->actor.world.pos.x) < 50.0f) && + (fabsf(sp34.y - this->actor.world.pos.y) < 50.0f) && + (fabsf(sp34.z - this->actor.world.pos.z) < 50.0f)) || + (this->actor.bgCheckFlags & 1)) { + this->unk_252 = 0; + this->unk_250 = this->unk_252; + this->unk_24E = this->unk_252; + this->unk_24C = this->unk_252; + this->unk_2D4 = 0.0f; + this->unk_274 = 0.0f; + this->unk_27C = 0.0f; + this->unk_2CC = this->actor.yawTowardsPlayer; + this->unk_2C8 = this->actor.world.rot.x - 2000.0f; + this->actor.gravity = -0.2f; + this->unk_280 = 0.0f; + this->actionFunc = func_80958974; + this->unk_2D8 = 5.0f; + } else { + this->unk_24C = 10; + this->unk_25C = -10000.0f; + this->unk_280 = -3000.0f; + func_80958228(this, globalCtx, 2); + } +} + +void func_80958974(EnAttackNiw* this, GlobalContext* globalCtx) { + if (!func_809585B0(this, globalCtx)) { + Actor_MarkForDeath(&this->actor); + return; + } + + if (this->actor.bgCheckFlags & 1) { + if (this->unk_252 == 0) { + this->unk_252 = 3; + this->actor.velocity.y = 3.5f; + } + + if (this->actor.gravity != -2.0f) { + this->unk_2CC = this->actor.yawTowardsPlayer; + this->unk_25A = 50; + this->unk_254 = 100; + this->unk_270 = 14000.0f; + this->unk_278 = 14000.0f; + this->unk_274 = 0.0f; + this->unk_27C = 0.0f; + this->unk_260 = 0.0f; + this->unk_264 = 0.0f; + this->unk_2C8 = 0.0f; + this->actor.gravity = -2.0f; + } + } + + if (this->unk_254 == 50) { + this->unk_2CC = randPlusMinusPoint5Scaled(200.0f) + this->actor.yawTowardsPlayer; + } + + Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_2CC, 2, this->unk_2D4, 0); + Math_SmoothStepToS(&this->actor.world.rot.x, this->unk_2C8, 2, this->unk_2D4, 0); + Math_ApproachF(&this->unk_2D4, 10000.0f, 1.0f, 1000.0f); + Math_ApproachF(&this->actor.speedXZ, this->unk_2D8, 0.9f, 1.0f); + + if ((this->actor.gravity == -2.0f) && (this->unk_25A == 0) && + ((this->actor.bgCheckFlags & 8) || (this->unk_254 == 0))) { + this->unk_2D8 = 0.0f; + this->actor.gravity = 0.0f; + this->unk_2D4 = 0.0f; + this->unk_2C8 = this->actor.world.rot.x - 5000.0f; + this->actionFunc = func_80958BE4; + } else if (this->actor.bgCheckFlags & 1) { + func_80958228(this, globalCtx, 5); + } else { + func_80958228(this, globalCtx, 2); + } +} + +void func_80958BE4(EnAttackNiw* this, GlobalContext* globalCtx) { + if (!func_809585B0(this, globalCtx)) { + Actor_MarkForDeath(&this->actor); + return; + } + + Math_SmoothStepToS(&this->actor.world.rot.x, this->unk_2C8, 5, this->unk_2D4, 0); + Math_ApproachF(&this->unk_2D4, 5000.0f, 1.0f, 100.0f); + Math_ApproachF(&this->actor.velocity.y, 5.0f, 0.3f, 1.0f); + func_80958228(this, globalCtx, 2); +} + +void EnAttackNiw_Update(Actor* thisx, GlobalContext* globalCtx) { + EnAttackNiw* this = THIS; + s32 pad; + EnNiw* parent; + Player* player = GET_PLAYER(globalCtx); + s32 pad2; + Vec3f sp30; + + this->unk_284++; + + if (this->unk_24C != 0) { + this->unk_24C--; + } + + if (this->unk_250 != 0) { + this->unk_250--; + } + + if (this->unk_252 != 0) { + this->unk_252--; + } + + if (this->unk_256 != 0) { + this->unk_256--; + } + + if (this->unk_258 != 0) { + this->unk_258--; + } + + if (this->unk_254 != 0) { + this->unk_254--; + } + + if (this->unk_25A != 0) { + this->unk_25A--; + } + + this->actor.shape.rot = this->actor.world.rot; + this->actor.shape.shadowScale = 15.0f; + + this->actionFunc(this, globalCtx); + + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 60.0f, 0x1D); + + if (this->actionFunc == func_80958634) { + Actor_MoveWithoutGravity(&this->actor); + } else { + Actor_MoveWithGravity(&this->actor); + } + + if (this->actor.floorHeight <= -32000.0f) { + Actor_MarkForDeath(&this->actor); + } else if ((this->actor.bgCheckFlags & 0x20) && (this->actionFunc != func_80958BE4)) { + Math_Vec3f_Copy(&sp30, &this->actor.world.pos); + sp30.y += this->actor.depthInWater; + + EffectSsGSplash_Spawn(globalCtx, &sp30, NULL, NULL, 0, 400); + this->unk_2D4 = 0.0f; + this->actor.gravity = 0.0f; + this->unk_2D8 = 0.0f; + this->unk_2C8 = this->actor.world.rot.x - 5000.0f; + this->actionFunc = func_80958BE4; + } else { + f32 temp = 20.0f; + + label: + + if (this->actor.xyzDistToPlayerSq < SQ(temp)) { + parent = (EnNiw*)this->actor.parent; + if ((this->actor.parent->update != NULL) && (this->actor.parent != NULL) && (parent != NULL) && + (parent->unusedTimer25E == 0) && (player->invincibilityTimer == 0)) { + func_800B8D50(globalCtx, &this->actor, 2.0f, this->actor.world.rot.y, 0.0f, 0x10); + parent->unusedTimer25E = 70; + } + } + + if (this->unk_256 == 0) { + this->unk_256 = 30; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_A); + } + + if (this->unk_258 == 0) { + this->unk_258 = 7; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_CHICKEN_FLUTTER); + } + } +} + +s32 EnAttackNiw_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnAttackNiw* this = THIS; + + if (limbIndex == OBJECT_NIW_LIMB_0D) { + rot->y += (s16)this->unk_2B4; + } + + if (limbIndex == OBJECT_NIW_LIMB_0F) { + rot->z += (s16)this->unk_2B8; + } + + if (limbIndex == OBJECT_NIW_LIMB_0B) { + rot->x += (s16)this->unk_2B0; + rot->y += (s16)this->unk_2AC; + rot->z += (s16)this->unk_2A8; + } + + if (limbIndex == OBJECT_NIW_LIMB_07) { + rot->x += (s16)this->unk_2A4; + rot->y += (s16)this->unk_2A0; + rot->z += (s16)this->unk_29C; + } + return false; +} + +void EnAttackNiw_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnAttackNiw* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnAttackNiw_OverrideLimbDraw, NULL, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.h b/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.h index 27d5546a15..4d3243ef5c 100644 --- a/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.h +++ b/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.h @@ -2,16 +2,56 @@ #define Z_EN_ATTACK_NIW_H #include "global.h" +#include "objects/object_niw/object_niw.h" struct EnAttackNiw; typedef void (*EnAttackNiwActionFunc)(struct EnAttackNiw*, GlobalContext*); typedef struct EnAttackNiw { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x104]; - /* 0x0248 */ EnAttackNiwActionFunc actionFunc; - /* 0x024C */ char unk_24C[0x94]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[OBJECT_NIW_LIMB_MAX]; + /* 0x1E8 */ Vec3s morphTable[OBJECT_NIW_LIMB_MAX]; + /* 0x248 */ EnAttackNiwActionFunc actionFunc; + /* 0x24C */ s16 unk_24C; + /* 0x24E */ s16 unk_24E; + /* 0x250 */ s16 unk_250; + /* 0x252 */ s16 unk_252; + /* 0x254 */ s16 unk_254; + /* 0x256 */ s16 unk_256; + /* 0x258 */ s16 unk_258; + /* 0x25A */ s16 unk_25A; + /* 0x25C */ f32 unk_25C; + /* 0x260 */ f32 unk_260; + /* 0x264 */ f32 unk_264; + /* 0x268 */ UNK_TYPE1 unk268[8]; + /* 0x270 */ f32 unk_270; + /* 0x274 */ f32 unk_274; + /* 0x278 */ f32 unk_278; + /* 0x27C */ f32 unk_27C; + /* 0x280 */ f32 unk_280; + /* 0x284 */ s16 unk_284; + /* 0x286 */ s16 unk_286; + /* 0x288 */ UNK_TYPE1 unk288[2]; + /* 0x28A */ s16 unk_28A; + /* 0x28C */ UNK_TYPE1 unk28C[4]; + /* 0x290 */ Vec3f unk_290; + /* 0x29C */ f32 unk_29C; + /* 0x2A0 */ f32 unk_2A0; + /* 0x2A4 */ f32 unk_2A4; + /* 0x2A8 */ f32 unk_2A8; + /* 0x2AC */ f32 unk_2AC; + /* 0x2B0 */ f32 unk_2B0; + /* 0x2B4 */ f32 unk_2B4; + /* 0x2B8 */ f32 unk_2B8; + /* 0x2BC */ UNK_TYPE1 unk2BC[0xC]; + /* 0x2C8 */ f32 unk_2C8; + /* 0x2CC */ f32 unk_2CC; + /* 0x2D0 */ UNK_TYPE1 unk2D0[4]; + /* 0x2D4 */ f32 unk_2D4; + /* 0x2D8 */ f32 unk_2D8; + /* 0x2DC */ f32 unk_2DC; } EnAttackNiw; // size = 0x2E0 extern const ActorInit En_Attack_Niw_InitVars; diff --git a/src/overlays/actors/ovl_En_Baba/z_en_baba.c b/src/overlays/actors/ovl_En_Baba/z_en_baba.c index 25cf5e6e48..4d9c7bad39 100644 --- a/src/overlays/actors/ovl_En_Baba/z_en_baba.c +++ b/src/overlays/actors/ovl_En_Baba/z_en_baba.c @@ -107,8 +107,16 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -s32 D_80BAA488[] = { - 0x0C000119, 0x0A006E14, 0x02000000, 0x1E080F00, 0x1E030400, 0x01050E00, 0x00001E02, 0x05050000, +static u8 D_80BAA488[] = { + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(1, 0x1D - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_BACKTOWN, 0x1C - 0x08), + /* 0x08 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 0, 0, 30, 0x16 - 0x0E), + /* 0x0E */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(0, 30, 0x15 - 0x12), + /* 0x12 */ SCHEDULE_CMD_RET_VAL_L(1), + /* 0x15 */ SCHEDULE_CMD_RET_NONE(), + /* 0x16 */ SCHEDULE_CMD_RET_TIME(0, 0, 0, 30, 2), + /* 0x1C */ SCHEDULE_CMD_RET_NONE(), + /* 0x1D */ SCHEDULE_CMD_RET_NONE(), }; s32 D_80BAA4A8[] = { -1, -1, 0 }; @@ -130,12 +138,12 @@ void func_80BA886C(EnBaba* this, GlobalContext* globalCtx) { switch (this->unk_1E0) { case 0: if (this->unk_40A & 8) { - if (gSaveContext.weekEventReg[33] & 8) { + if (gSaveContext.save.weekEventReg[33] & 8) { this->unk_1E0 = 0x2A34; break; } - if (gSaveContext.weekEventReg[79] & 0x40) { + if (gSaveContext.save.weekEventReg[79] & 0x40) { this->unk_40A |= 1; this->unk_1E0 = 0x2A33; break; @@ -145,8 +153,8 @@ void func_80BA886C(EnBaba* this, GlobalContext* globalCtx) { this->unk_1E0 = 0x2A32; break; } else if (player->transformation == PLAYER_FORM_DEKU) { - if (!(gSaveContext.weekEventReg[79] & 0x20)) { - gSaveContext.weekEventReg[79] |= 0x20; + if (!(gSaveContext.save.weekEventReg[79] & 0x20)) { + gSaveContext.save.weekEventReg[79] |= 0x20; this->unk_40A |= 1; this->unk_1E0 = 0x2A37; break; @@ -155,15 +163,15 @@ void func_80BA886C(EnBaba* this, GlobalContext* globalCtx) { this->unk_1E0 = 0x2A38; } break; - } else if (!(gSaveContext.weekEventReg[33] & 8)) { - if (!(gSaveContext.weekEventReg[73] & 1)) { + } else if (!(gSaveContext.save.weekEventReg[33] & 8)) { + if (!(gSaveContext.save.weekEventReg[73] & 1)) { this->unk_1E0 = 0x660; break; } this->unk_1E0 = 0x662; break; } else { - if (!(gSaveContext.weekEventReg[73] & 2)) { + if (!(gSaveContext.save.weekEventReg[73] & 2)) { this->unk_1E0 = 0x65A; break; } @@ -185,7 +193,7 @@ void func_80BA886C(EnBaba* this, GlobalContext* globalCtx) { case 0x662: Actor_ChangeFocus(&this->actor, globalCtx, &this->unk_144->actor); this->unk_1E0 = 0x663; - gSaveContext.weekEventReg[73] |= 1; + gSaveContext.save.weekEventReg[73] |= 1; this->unk_40A |= 1; break; @@ -202,7 +210,7 @@ void func_80BA886C(EnBaba* this, GlobalContext* globalCtx) { case 0x65C: Actor_ChangeFocus(&this->actor, globalCtx, &this->unk_144->actor); this->unk_1E0 = 0x65D; - gSaveContext.weekEventReg[73] |= 2; + gSaveContext.save.weekEventReg[73] |= 2; this->unk_40A |= 1; break; @@ -266,7 +274,7 @@ s32 func_80BA8D2C(EnBaba* this, f32 arg1) { Math_SmoothStepToF(&this->actor.speedXZ, arg1, 0.4f, 1000.0f, 0.0f); sp3E = this->actor.speedXZ * 400.0f; - if (func_8013D68C(this->path, this->unk_1E8, &sp2C) && func_8013D768(&this->actor, &sp2C, sp3E)) { + if (SubS_CopyPointFromPath(this->path, this->unk_1E8, &sp2C) && SubS_MoveActorToPoint(&this->actor, &sp2C, sp3E)) { this->unk_1E8++; if (this->unk_1E8 >= this->path->count) { ret = true; @@ -305,13 +313,13 @@ void func_80BA8DF4(EnBaba* this, GlobalContext* globalCtx) { } } -s32 func_80BA8F88(EnBaba* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { - u16 sp26 = (u16)(gSaveContext.time - 0x3FFC); +s32 func_80BA8F88(EnBaba* this, GlobalContext* globalCtx, ScheduleResult* arg2) { + u16 sp26 = (u16)(gSaveContext.save.time - 0x3FFC); u16 temp; u8 sp23 = ENBABA_GET_3F00(&this->actor); - if (D_80BAA4A8[arg2->unk0] >= 0) { - this->unk_410 = func_8013BB34(globalCtx, sp23, D_80BAA4A8[arg2->unk0]); + if (D_80BAA4A8[arg2->result] >= 0) { + this->unk_410 = SubS_GetAdditionalPath(globalCtx, sp23, D_80BAA4A8[arg2->result]); } if (this->unk_410 == NULL) { @@ -321,13 +329,13 @@ s32 func_80BA8F88(EnBaba* this, GlobalContext* globalCtx, struct_80133038_arg2* if ((this->unk_434 != 0) && (this->unk_436 >= 0)) { temp = sp26; } else { - temp = arg2->unk4; + temp = arg2->time0; } - if (arg2->unk8 < temp) { - this->unk_424 = (temp - arg2->unk8) + 0xFFFF; + if (arg2->time1 < temp) { + this->unk_424 = (temp - arg2->time1) + 0xFFFF; } else { - this->unk_424 = arg2->unk8 - temp; + this->unk_424 = arg2->time1 - temp; } this->unk_430 = sp26 - temp; @@ -339,10 +347,10 @@ s32 func_80BA8F88(EnBaba* this, GlobalContext* globalCtx, struct_80133038_arg2* return true; } -s32 func_80BA9110(EnBaba* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BA9110(EnBaba* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret; - switch (arg2->unk0) { + switch (arg2->result) { default: ret = false; break; @@ -384,7 +392,7 @@ s32 func_80BA9160(EnBaba* this, GlobalContext* globalCtx) { this->actor.world.pos.x = sp58.x; this->actor.world.pos.z = sp58.z; - if (func_8013AD6C(globalCtx)) { + if (SubS_InCsMode(globalCtx)) { sp54 = this->unk_430; sp50 = this->unk_42C; sp58 = this->actor.world.pos; @@ -401,7 +409,7 @@ s32 func_80BA9160(EnBaba* this, GlobalContext* globalCtx) { this->actor.world.rot.y = Math_Vec3f_Yaw(&sp70, &sp64); } - if (func_8013AD6C(globalCtx)) { + if (SubS_InCsMode(globalCtx)) { this->unk_430 = sp54; this->unk_42C = sp50; this->unk_414 = sp58; @@ -413,7 +421,7 @@ s32 func_80BA9160(EnBaba* this, GlobalContext* globalCtx) { void func_80BA93AC(EnBaba* this, GlobalContext* globalCtx) { if (this->unk_434 != 1) { if (this->unk_434 == 2) { - gSaveContext.weekEventReg[58] |= 0x40; + gSaveContext.save.weekEventReg[58] |= 0x40; this->unk_40A |= 2; func_80BA9160(this, globalCtx); } @@ -443,10 +451,10 @@ void func_80BA9480(EnBaba* this, GlobalContext* globalCtx) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); this->actionFunc = func_80BA9758; } else if (globalCtx->sceneNum == SCENE_BACKTOWN) { - if ((ENBABA_GET_C000(&this->actor) == ENBABA_C000_0) && (gSaveContext.entranceIndex != 0xD670) && + if ((ENBABA_GET_C000(&this->actor) == ENBABA_C000_0) && (gSaveContext.save.entranceIndex != 0xD670) && ((ENBABA_GET_3F00(&this->actor)) != ENBABA_3F00_3F)) { - if ((gSaveContext.weekEventReg[58] & 0x40) || - (!(gSaveContext.time < CLOCK_TIME(0, 20)) && (gSaveContext.time < CLOCK_TIME(6, 0)))) { + if ((gSaveContext.save.weekEventReg[58] & 0x40) || + (!(gSaveContext.save.time < CLOCK_TIME(0, 20)) && (gSaveContext.save.time < CLOCK_TIME(6, 0)))) { Actor_MarkForDeath(&this->actor); return; } @@ -455,14 +463,14 @@ void func_80BA9480(EnBaba* this, GlobalContext* globalCtx) { this->unk_40C = 2; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); this->actionFunc = func_80BA9B80; - } else if ((ENBABA_GET_C000(&this->actor) == ENBABA_C000_1) && (gSaveContext.entranceIndex == 0xD670)) { - if (gSaveContext.weekEventReg[81] & 2) { + } else if ((ENBABA_GET_C000(&this->actor) == ENBABA_C000_1) && (gSaveContext.save.entranceIndex == 0xD670)) { + if (gSaveContext.save.weekEventReg[81] & 2) { Actor_MarkForDeath(&this->actor); return; } this->unk_40A |= 2; - if (gSaveContext.weekEventReg[33] & 8) { + if (gSaveContext.save.weekEventReg[33] & 8) { this->unk_40C = 0; } else { this->unk_40C = 1; @@ -514,7 +522,7 @@ void func_80BA9758(EnBaba* this, GlobalContext* globalCtx) { void func_80BA9848(EnBaba* this, GlobalContext* globalCtx) { u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); - if (((temp_v0 == 5) || (temp_v0 == 6)) && func_80147624(globalCtx)) { + if (((temp_v0 == 5) || (temp_v0 == 6)) && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; this->actionFunc = func_80BA9B80; @@ -526,7 +534,7 @@ void func_80BA98EC(EnBaba* this, GlobalContext* globalCtx) { u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); if (temp_v0 == 5) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (this->unk_40A & 1) { this->unk_40A &= ~1; globalCtx->msgCtx.msgMode = 0x43; @@ -534,12 +542,12 @@ void func_80BA98EC(EnBaba* this, GlobalContext* globalCtx) { if (this->unk_40A & 8) { if (CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { if (globalCtx->msgCtx.unk120B1 == 0) { - gSaveContext.weekEventReg[81] |= 2; + gSaveContext.save.weekEventReg[81] |= 2; func_80BA8C4C(globalCtx, 0xD670); return; } } else { - gSaveContext.weekEventReg[81] |= 2; + gSaveContext.save.weekEventReg[81] |= 2; func_80BA8C4C(globalCtx, 0xD670); } } else { @@ -556,8 +564,8 @@ void func_80BA98EC(EnBaba* this, GlobalContext* globalCtx) { } } } else if (temp_v0 == 6) { - if (func_80147624(globalCtx) && (globalCtx->msgCtx.unk120B1 == 0)) { - gSaveContext.weekEventReg[81] |= 2; + if (Message_ShouldAdvance(globalCtx) && (globalCtx->msgCtx.unk120B1 == 0)) { + gSaveContext.save.weekEventReg[81] |= 2; func_80BA8C4C(globalCtx, 0xD670); } } @@ -583,21 +591,20 @@ void func_80BA9B24(EnBaba* this, GlobalContext* globalCtx) { } void func_80BA9B80(EnBaba* this, GlobalContext* globalCtx) { - u32* unk14 = &gSaveContext.unk_14; - struct_80133038_arg2 sp20; + ScheduleResult sp20; - this->unk_436 = REG(15) + *unk14; + this->unk_436 = REG(15) + ((void)0, gSaveContext.save.daySpeed); - if (!func_80133038(globalCtx, D_80BAA488, &sp20) || - ((this->unk_434 != sp20.unk0) && !func_80BA9110(this, globalCtx, &sp20))) { + if (!Schedule_RunScript(globalCtx, D_80BAA488, &sp20) || + ((this->unk_434 != sp20.result) && !func_80BA9110(this, globalCtx, &sp20))) { this->unk_40A &= ~0x80; this->actor.flags &= ~ACTOR_FLAG_1; - sp20.unk0 = false; + sp20.result = false; } else { this->unk_40A |= 0x80; this->actor.flags |= ACTOR_FLAG_1; } - this->unk_434 = sp20.unk0; + this->unk_434 = sp20.result; func_80BA93AC(this, globalCtx); @@ -629,7 +636,7 @@ void func_80BA9CD4(EnBaba* this, GlobalContext* globalCtx) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 4); } } else { - if ((gSaveContext.weekEventReg[79] & 0x40) && (DECR(this->unk_404) == 0)) { + if ((gSaveContext.save.weekEventReg[79] & 0x40) && (DECR(this->unk_404) == 0)) { Audio_QueueSeqCmd(0x101400FF); func_80BA8C4C(globalCtx, 0xD670); } else { @@ -659,7 +666,7 @@ void EnBaba_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); - this->path = func_8013D648(globalCtx, ENBABA_GET_3F00(&this->actor), ENBABA_3F00_3F); + this->path = SubS_GetPathByIndex(globalCtx, ENBABA_GET_3F00(&this->actor), ENBABA_3F00_3F); Actor_SetScale(&this->actor, 0.01f); diff --git a/src/overlays/actors/ovl_En_Baisen/z_en_baisen.c b/src/overlays/actors/ovl_En_Baisen/z_en_baisen.c index dc7bca14ce..193c899c99 100644 --- a/src/overlays/actors/ovl_En_Baisen/z_en_baisen.c +++ b/src/overlays/actors/ovl_En_Baisen/z_en_baisen.c @@ -71,14 +71,16 @@ void EnBaisen_Init(Actor* thisx, GlobalContext* globalCtx) { this->paramCopy = this->actor.params; if (this->actor.params == 0) { this->unk290 = true; - if (!(gSaveContext.weekEventReg[63] & 0x80) && ((gSaveContext.day != 3) || !gSaveContext.isNight)) { + if (!(gSaveContext.save.weekEventReg[63] & 0x80) && + ((gSaveContext.save.day != 3) || !gSaveContext.save.isNight)) { Actor_MarkForDeath(&this->actor); } } else { this->collider.dim.radius = 30; this->collider.dim.height = 60; this->collider.dim.yShift = 0; - if ((gSaveContext.weekEventReg[63] & 0x80) || ((gSaveContext.day == 3) && (gSaveContext.isNight))) { + if ((gSaveContext.save.weekEventReg[63] & 0x80) || + ((gSaveContext.save.day == 3) && (gSaveContext.save.isNight))) { Actor_MarkForDeath(&this->actor); } } @@ -153,7 +155,7 @@ void func_80BE887C(EnBaisen* this, GlobalContext* globalCtx) { } else { if (this->paramCopy != 0) { this->textIdIndex = 0; - if (gSaveContext.weekEventReg[60] & 8) { + if (gSaveContext.save.weekEventReg[60] & 8) { this->textIdIndex = 1; } if (Player_GetMask(globalCtx) == PLAYER_MASK_COUPLE) { @@ -196,8 +198,8 @@ void func_80BE89D8(EnBaisen* this, GlobalContext* globalCtx) { EnBaisen_ChangeAnimation(this, 0); } } - if ((globalCtx->msgCtx.unk11F04 == 0x2AC6) || (globalCtx->msgCtx.unk11F04 == 0x2AC7) || - (globalCtx->msgCtx.unk11F04 == 0x2AC8)) { + if ((globalCtx->msgCtx.currentTextId == 0x2AC6) || (globalCtx->msgCtx.currentTextId == 0x2AC7) || + (globalCtx->msgCtx.currentTextId == 0x2AC8)) { this->skelAnime.playSpeed = 0.0f; this->unk29E = this->actor.yawTowardsPlayer; } @@ -220,7 +222,7 @@ void func_80BE8AAC(EnBaisen* this, GlobalContext* globalCtx) { EnBaisen_ChangeAnimation(this, 0); } } - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); this->textIdIndex++; if (this->textIdIndex < 6) { @@ -246,7 +248,7 @@ void EnBaisen_Update(Actor* thisx, GlobalContext* globalCtx) { this->unusedCounter--; } this->actor.shape.rot.y = this->actor.world.rot.y; - if ((this->paramCopy != 0) && (gSaveContext.day == 3) && gSaveContext.isNight) { + if ((this->paramCopy != 0) && (gSaveContext.save.day == 3) && gSaveContext.save.isNight) { Actor_MarkForDeath(&this->actor); return; } diff --git a/src/overlays/actors/ovl_En_Bb/z_en_bb.c b/src/overlays/actors/ovl_En_Bb/z_en_bb.c index 1ce821f66e..311c2f633b 100644 --- a/src/overlays/actors/ovl_En_Bb/z_en_bb.c +++ b/src/overlays/actors/ovl_En_Bb/z_en_bb.c @@ -5,6 +5,7 @@ */ #include "z_en_bb.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_200) @@ -15,15 +16,25 @@ void EnBb_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnBb_Update(Actor* thisx, GlobalContext* globalCtx); void EnBb_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_808C23EC(EnBb* this, GlobalContext* globalCtx); -void func_808C25E0(EnBb* this, GlobalContext* globalCtx); -void func_808C28CC(EnBb* this, GlobalContext* globalCtx); -void func_808C2B1C(EnBb* this, GlobalContext* globalCtx); -void func_808C2BD0(EnBb* this, GlobalContext* globalCtx); -void func_808C2CB4(EnBb* this, GlobalContext* globalCtx); -void func_808C2D78(EnBb* this, GlobalContext* globalCtx); +void EnBb_SetupFlyIdle(EnBb* this); +void EnBb_FlyIdle(EnBb* this, GlobalContext* globalCtx); +void EnBb_SetupAttack(EnBb* this); +void EnBb_Attack(EnBb* this, GlobalContext* globalCtx); +void EnBb_Down(EnBb* this, GlobalContext* globalCtx); +void EnBb_Dead(EnBb* this, GlobalContext* globalCtx); +void EnBb_Damage(EnBb* this, GlobalContext* globalCtx); +void EnBb_Frozen(EnBb* this, GlobalContext* globalCtx); +void EnBb_SetupWaitForRevive(EnBb* this); +void EnBb_WaitForRevive(EnBb* this, GlobalContext* globalCtx); +void EnBb_SetupRevive(EnBb* this); +void EnBb_Revive(EnBb* this, GlobalContext* globalCtx); + +typedef enum { + /* -1 */ BB_BODY_PART_DRAW_STATUS_BROKEN = -1, + /* 0 */ BB_BODY_PART_DRAW_STATUS_ALIVE, + /* 1 */ BB_BODY_PART_DRAW_STATUS_DEAD, +} EnBbBodyPartDrawStatus; -#if 0 const ActorInit En_Bb_InitVars = { ACTOR_EN_BB, ACTORCAT_ENEMY, @@ -36,118 +47,667 @@ const ActorInit En_Bb_InitVars = { (ActorFunc)EnBb_Draw, }; -// static ColliderSphereInit sSphereInit = { -static ColliderSphereInit D_808C37A0 = { - { COLTYPE_HIT3, AT_NONE | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_SPHERE, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, +static ColliderSphereInit sSphereInit = { + { + COLTYPE_HIT3, + AT_NONE | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_SPHERE, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 20 }, 100 }, }; -// static DamageTable sDamageTable = { -static DamageTable D_808C37CC = { - /* Deku Nut */ DMG_ENTRY(0, 0x1), - /* Deku Stick */ DMG_ENTRY(1, 0x0), - /* Horse trample */ DMG_ENTRY(1, 0x0), - /* Explosives */ DMG_ENTRY(1, 0x0), - /* Zora boomerang */ DMG_ENTRY(1, 0x0), - /* Normal arrow */ DMG_ENTRY(1, 0x0), - /* UNK_DMG_0x06 */ DMG_ENTRY(0, 0x0), - /* Hookshot */ DMG_ENTRY(0, 0xE), - /* Goron punch */ DMG_ENTRY(1, 0x0), - /* Sword */ DMG_ENTRY(1, 0x0), - /* Goron pound */ DMG_ENTRY(1, 0x0), - /* Fire arrow */ DMG_ENTRY(1, 0x0), - /* Ice arrow */ DMG_ENTRY(2, 0x3), - /* Light arrow */ DMG_ENTRY(2, 0x4), - /* Goron spikes */ DMG_ENTRY(1, 0x0), - /* Deku spin */ DMG_ENTRY(1, 0x0), - /* Deku bubble */ DMG_ENTRY(1, 0x0), - /* Deku launch */ DMG_ENTRY(2, 0x0), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0x1), - /* Zora barrier */ DMG_ENTRY(0, 0x5), - /* Normal shield */ DMG_ENTRY(0, 0x0), - /* Light ray */ DMG_ENTRY(0, 0x0), - /* Thrown object */ DMG_ENTRY(1, 0x0), - /* Zora punch */ DMG_ENTRY(1, 0x0), - /* Spin attack */ DMG_ENTRY(1, 0x0), - /* Sword beam */ DMG_ENTRY(0, 0x0), - /* Normal Roll */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0x0), - /* Powder Keg */ DMG_ENTRY(1, 0x0), +typedef enum { + /* 0x0 */ EN_BB_DMGEFF_NONE, + /* 0x1 */ EN_BB_DMGEFF_STUN, + /* 0x3 */ EN_BB_DMGEFF_ICE_ARROW = 0x3, + /* 0x4 */ EN_BB_DMGEFF_LIGHT_ARROW, + /* 0x5 */ EN_BB_DMGEFF_ZORA_MAGIC, + /* 0xE */ EN_BB_DMGEFF_HOOKSHOT = 0xE, +} EnBbDamageEffect; + +static DamageTable sDamageTable = { + /* Deku Nut */ DMG_ENTRY(0, EN_BB_DMGEFF_STUN), + /* Deku Stick */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), + /* Horse trample */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), + /* Explosives */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), + /* Zora boomerang */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), + /* Normal arrow */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), + /* UNK_DMG_0x06 */ DMG_ENTRY(0, EN_BB_DMGEFF_NONE), + /* Hookshot */ DMG_ENTRY(0, EN_BB_DMGEFF_HOOKSHOT), + /* Goron punch */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), + /* Sword */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), + /* Goron pound */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), + /* Fire arrow */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), + /* Ice arrow */ DMG_ENTRY(2, EN_BB_DMGEFF_ICE_ARROW), + /* Light arrow */ DMG_ENTRY(2, EN_BB_DMGEFF_LIGHT_ARROW), + /* Goron spikes */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), + /* Deku spin */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), + /* Deku bubble */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), + /* Deku launch */ DMG_ENTRY(2, EN_BB_DMGEFF_NONE), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, EN_BB_DMGEFF_STUN), + /* Zora barrier */ DMG_ENTRY(0, EN_BB_DMGEFF_ZORA_MAGIC), + /* Normal shield */ DMG_ENTRY(0, EN_BB_DMGEFF_NONE), + /* Light ray */ DMG_ENTRY(0, EN_BB_DMGEFF_NONE), + /* Thrown object */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), + /* Zora punch */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), + /* Spin attack */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), + /* Sword beam */ DMG_ENTRY(0, EN_BB_DMGEFF_NONE), + /* Normal Roll */ DMG_ENTRY(0, EN_BB_DMGEFF_NONE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, EN_BB_DMGEFF_NONE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, EN_BB_DMGEFF_NONE), + /* Unblockable */ DMG_ENTRY(0, EN_BB_DMGEFF_NONE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, EN_BB_DMGEFF_NONE), + /* Powder Keg */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), }; -// sColChkInfoInit -static CollisionCheckInfoInit D_808C37EC = { 2, 20, 40, 50 }; +static CollisionCheckInfoInit sColChkInfoInit = { 2, 20, 40, 50 }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808C37F4[] = { +static InitChainEntry sInitChain[] = { ICHAIN_S8(hintId, 28, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 10, ICHAIN_STOP), }; -#endif +/** + * This maps a given limb based on its limbIndex to its appropriate index + * in the bodyPartsPos/Velocity arrays. An index of -1 indicates that the + * limb is not part of the bodyParts arrays. + */ +static s8 sLimbIndexToBodyPartsIndex[] = { + -1, -1, -1, -1, 0, -1, -1, -1, 1, -1, -1, -1, -1, 2, -1, 3, +}; -extern ColliderSphereInit D_808C37A0; -extern DamageTable D_808C37CC; -extern CollisionCheckInfoInit D_808C37EC; -extern InitChainEntry D_808C37F4[]; +/** + * The last element of the bodyParts arrays is a duplicate of the cranium + * limb, which is then offset by a certain amount. There is no display list + * associated with this, so it is only used for effects. + */ +static Vec3f sDuplicateCraniumBodyPartOffset = { 1000.0f, -700.0f, 0.0f }; -extern UNK_TYPE D_06000184; -extern UNK_TYPE D_06000444; +void EnBb_Init(Actor* thisx, GlobalContext* globalCtx) { + EnBb* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/EnBb_Init.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + SkelAnime_Init(globalCtx, &this->skelAnime, &gBubbleSkel, &gBubbleFlyingAnim, this->jointTable, this->morphTable, + BUBBLE_LIMB_MAX); + Collider_InitAndSetSphere(globalCtx, &this->collider, &this->actor, &sSphereInit); + ActorShape_Init(&this->actor.shape, 1500.0f, ActorShadow_DrawCircle, 35.0f); + CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/EnBb_Destroy.s") + this->flameScaleY = 0.8f; + this->flameScaleX = 1.0f; + this->actor.world.pos.y += 50.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C1E94.s") + if (EN_BB_ATTACK_RANGE(&this->actor) == 0xFF) { + this->attackRange = 200.0f; + } else { + this->attackRange = EN_BB_ATTACK_RANGE(&this->actor) * 4.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C1F00.s") + EnBb_SetupFlyIdle(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C1F74.s") +void EnBb_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnBb* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C1FF4.s") + Collider_DestroySphere(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C20D4.s") +/** + * Checks to see if the Bubble is touching a wall. If it is, and if the + * Bubble is facing directly "into" the wall, then rotate it away from + * the wall. + */ +void EnBb_CheckForWall(EnBb* this) { + s16 yawDiff; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C2238.s") + if (this->actor.bgCheckFlags & 8) { + yawDiff = this->actor.shape.rot.y - this->actor.wallYaw; + if (ABS_ALT(yawDiff) > 0x4000) { + this->actor.shape.rot.y = ((this->actor.wallYaw * 2) - this->actor.shape.rot.y) - 0x8000; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C2344.s") + this->targetYRotation = this->actor.shape.rot.y; + this->actor.bgCheckFlags &= ~8; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C23EC.s") +void EnBb_Freeze(EnBb* this) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; + this->drawDmgEffScale = 0.4f; + this->drawDmgEffFrozenSteamScale = 0.6f; + this->timer = 80; + this->drawDmgEffAlpha = 1.0f; + this->actor.flags &= ~ACTOR_FLAG_200; + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C254C.s") +void EnBb_Thaw(EnBb* this, GlobalContext* globalCtx) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, this->bodyPartsPos, ARRAY_COUNT(this->bodyPartsPos), 2, 0.2f, + 0.15f); + this->actor.flags |= ACTOR_FLAG_200; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C25E0.s") +/** + * Updates certain variables that relate to flying like the Bubble's + * Y-position, bob phase, and flame scale. + */ +void EnBb_UpdateStateForFlying(EnBb* this) { + SkelAnime_Update(&this->skelAnime); + if (this->actor.floorHeight > BGCHECK_Y_MIN) { + Math_StepToF(&this->actor.world.pos.y, this->actor.floorHeight + this->flyHeightMod, 0.5f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C272C.s") + this->actor.world.pos.y += Math_CosS(this->bobPhase); + this->bobPhase += 0x826; + Math_StepToF(&this->flameScaleY, 0.8f, 0.1f); + Math_StepToF(&this->flameScaleX, 1.0f, 0.1f); + EnBb_CheckForWall(this); + Math_StepToF(&this->actor.speedXZ, this->maxSpeed, 0.5f); + Math_ApproachS(&this->actor.shape.rot.y, this->targetYRotation, 5, 0x3E8); + this->actor.world.rot.y = this->actor.shape.rot.y; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C28CC.s") +void EnBb_SetupFlyIdle(EnBb* this) { + if (this->actionFunc != EnBb_FlyIdle) { + Animation_PlayLoop(&this->skelAnime, &gBubbleFlyingAnim); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C2A00.s") + if (this->actionFunc == EnBb_Attack) { + this->attackWaitTimer = 40; + } else { + this->attackWaitTimer = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C2B1C.s") + this->timer = (s32)Rand_ZeroFloat(20.0f) + 40; + this->actor.gravity = 0.0f; + this->actor.velocity.y = 0.0f; + this->flyHeightMod = (Math_CosS(this->bobPhase) * 10.0f) + 30.0f; + this->targetYRotation = Actor_YawToPoint(&this->actor, &this->actor.home.pos); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C2B94.s") + if ((this->actor.xzDistToPlayer < (this->attackRange + 120.0f)) || + (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) < 300.0f)) { + this->targetYRotation += (s16)(Rand_Next() >> 0x11); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C2BD0.s") + this->collider.base.atFlags |= AT_ON; + this->maxSpeed = Rand_ZeroFloat(1.5f) + 1.0f; + this->actionFunc = EnBb_FlyIdle; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C2C38.s") +/** + * Makes the Bubble fly in circles around its home. + */ +void EnBb_FlyIdle(EnBb* this, GlobalContext* globalCtx) { + EnBb_UpdateStateForFlying(this); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C2CB4.s") + if (Animation_OnFrame(&this->skelAnime, 5.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_WING); + } else if ((Animation_OnFrame(&this->skelAnime, 0.0f)) && (Rand_ZeroOne() < 0.1f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_LAUGH); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C2CF0.s") + DECR(this->attackWaitTimer); + this->timer--; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C2D78.s") + if ((this->attackWaitTimer == 0) && (this->actor.xzDistToPlayer < this->attackRange) && + (Player_GetMask(globalCtx) != PLAYER_MASK_STONE)) { + EnBb_SetupAttack(this); + } else if (this->timer == 0) { + EnBb_SetupFlyIdle(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C2E34.s") +void EnBb_SetupAttack(EnBb* this) { + Animation_PlayLoop(&this->skelAnime, &gBubbleAttackAnim); + this->timer = (s32)Rand_ZeroFloat(20.0f) + 60; + this->flyHeightMod = (Math_CosS(this->bobPhase) * 10.0f) + 30.0f; + this->targetYRotation = this->actor.yawTowardsPlayer; + this->maxSpeed = Rand_ZeroFloat(1.5f) + 4.0f; + this->actionFunc = EnBb_Attack; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/EnBb_Update.s") +/** + * Makes the Bubble actively move towards the player. + */ +void EnBb_Attack(EnBb* this, GlobalContext* globalCtx) { + this->targetYRotation = this->actor.yawTowardsPlayer; + EnBb_UpdateStateForFlying(this); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C32EC.s") + if ((Animation_OnFrame(&this->skelAnime, 0.0f)) || (Animation_OnFrame(&this->skelAnime, 5.0f))) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_MOUTH); + } else if ((Animation_OnFrame(&this->skelAnime, 2.0f)) || (Animation_OnFrame(&this->skelAnime, 7.0f))) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_WING); + } else if ((Animation_OnFrame(&this->skelAnime, 0.0f)) && (Rand_ZeroOne() < 0.1f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_LAUGH); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C3324.s") + this->timer--; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/EnBb_Draw.s") + if (((this->attackRange + 120.0f) < this->actor.xzDistToPlayer) || (this->timer == 0) || + (Player_GetMask(globalCtx) == PLAYER_MASK_STONE) || + (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) > 400.0f)) { + EnBb_SetupFlyIdle(this); + } +} + +void EnBb_SetupDown(EnBb* this) { + Animation_PlayLoop(&this->skelAnime, &gBubbleFlyingAnim); + this->collider.base.atFlags |= AT_ON; + this->timer = 140; + this->collider.base.acFlags |= AC_ON; + this->actor.speedXZ = 2.0f; + this->flameScaleY = 0.0f; + this->flameScaleX = 0.0f; + this->actor.gravity = -2.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_DOWN); + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actionFunc = EnBb_Down; +} + +/** + * Makes the Bubble hop along the ground. + */ +void EnBb_Down(EnBb* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + EnBb_CheckForWall(this); + + if (this->actor.bgCheckFlags & 1) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); + if (this->timer == 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_UP); + EnBb_SetupFlyIdle(this); + return; + } + + if (this->actor.velocity.y < -14.0f) { + this->actor.velocity.y *= -0.7f; + } else { + this->actor.velocity.y = 10.0f; + } + + this->actor.bgCheckFlags &= ~1; + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 7.0f, 2, 2.0f, 0, 0, 0); + Math_ScaledStepToS(&this->actor.shape.rot.y, BINANG_ADD(this->actor.yawTowardsPlayer, 0x8000), 0xBB8); + } + + this->actor.world.rot.y = this->actor.shape.rot.y; + if (Animation_OnFrame(&this->skelAnime, 5.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_WING); + } + + if (this->timer > 0) { + this->timer--; + } +} + +void EnBb_SetupDead(EnBb* this, GlobalContext* globalCtx) { + Vec3f* bodyPartVelocity; + Vec3f posDiff; + f32 magnitude; + s32 i; + + func_800BE568(&this->actor, &this->collider); + this->timer = 15; + this->actor.shape.rot.x += 0x4E20; + this->actor.speedXZ = 0.0f; + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_BUBLE_DEAD); + Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x70); + this->actor.velocity.y = 0.0f; + this->actor.speedXZ = 0.0f; + this->bodyPartDrawStatus = BB_BODY_PART_DRAW_STATUS_DEAD; + this->actor.gravity = -1.5f; + + bodyPartVelocity = &this->bodyPartsVelocity[0]; + for (i = 0; i < ARRAY_COUNT(this->bodyPartsPos); i++, bodyPartVelocity++) { + Math_Vec3f_Diff(&this->bodyPartsPos[i], &this->actor.world.pos, &posDiff); + magnitude = Math3D_Vec3fMagnitude(&posDiff); + if (magnitude > 1.0f) { + magnitude = 2.5f / magnitude; + } + + bodyPartVelocity->x = posDiff.x * magnitude; + bodyPartVelocity->z = posDiff.z * magnitude; + bodyPartVelocity->y = Rand_ZeroFloat(3.5f) + 10.0f; + } + + this->actor.flags |= ACTOR_FLAG_10; + this->actor.flags &= ~ACTOR_FLAG_1; + this->actionFunc = EnBb_Dead; +} + +void EnBb_Dead(EnBb* this, GlobalContext* globalCtx) { + s32 i; + + this->timer--; + Math_SmoothStepToS(&this->actor.world.rot.z, 0x4000, 4, 0x1000, 0x400); + + if (this->timer == 0) { + for (i = 0; i < ARRAY_COUNT(this->bodyPartsPos); i++) { + func_800B3030(globalCtx, &this->bodyPartsPos[i], &gZeroVec3f, &gZeroVec3f, 40, 7, 2); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->bodyPartsPos[i], 11, NA_SE_EN_EXTINCT); + } + + EnBb_SetupWaitForRevive(this); + } else { + for (i = 0; i < ARRAY_COUNT(this->bodyPartsPos); i++) { + Math_Vec3f_Sum(&this->bodyPartsPos[i], &this->bodyPartsVelocity[i], &this->bodyPartsPos[i]); + this->bodyPartsVelocity[i].y += this->actor.gravity; + } + } +} + +void EnBb_SetupDamage(EnBb* this) { + this->collider.base.acFlags &= ~AC_ON; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_DAMAGE); + func_800BE568(&this->actor, &this->collider); + + if (this->actor.colChkInfo.damageEffect == EN_BB_DMGEFF_ZORA_MAGIC) { + Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_LARGE; + this->drawDmgEffAlpha = 2.0f; + this->drawDmgEffScale = 0.4f; + } else if (this->actor.colChkInfo.damageEffect == EN_BB_DMGEFF_STUN) { + Actor_SetColorFilter(&this->actor, 0, 255, 0, 20); + this->actor.speedXZ = 0.0f; + } else if (this->actor.colChkInfo.damageEffect == EN_BB_DMGEFF_HOOKSHOT) { + this->actor.speedXZ = 0.0f; + } else { + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 20); + this->actor.speedXZ = 7.0f; + } + + this->actor.gravity = -1.0f; + this->actionFunc = EnBb_Damage; +} + +void EnBb_Damage(EnBb* this, GlobalContext* globalCtx) { + Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f); + if ((this->actor.bgCheckFlags & 1) && (this->actor.speedXZ < 0.1f)) { + EnBb_SetupDown(this); + } +} + +void EnBb_SetupFrozen(EnBb* this) { + this->actor.speedXZ = 0.0f; + if (this->actor.velocity.y > 0.0f) { + this->actor.velocity.y = 0.0f; + } + + this->actor.gravity = -2.0f; + this->actionFunc = EnBb_Frozen; +} + +void EnBb_Frozen(EnBb* this, GlobalContext* globalCtx) { + DECR(this->timer); + + if (this->timer == 0) { + EnBb_Thaw(this, globalCtx); + if (this->actor.colChkInfo.health == 0) { + EnBb_SetupDead(this, globalCtx); + } else { + EnBb_SetupDown(this); + } + } +} + +void EnBb_SetupWaitForRevive(EnBb* this) { + this->actor.draw = NULL; + this->bodyPartDrawStatus = BB_BODY_PART_DRAW_STATUS_ALIVE; + this->drawDmgEffAlpha = 0.0f; + Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.home.pos); + this->actor.shape.rot.x = 0; + this->actor.world.pos.y += 50.0f; + this->timer = 200; + this->actor.speedXZ = 0.0f; + this->actor.velocity.y = 0.0f; + this->actor.gravity = 0.0f; + this->actionFunc = EnBb_WaitForRevive; +} + +void EnBb_WaitForRevive(EnBb* this, GlobalContext* globalCtx) { + this->timer--; + if (this->timer == 0) { + EnBb_SetupRevive(this); + } +} + +void EnBb_SetupRevive(EnBb* this) { + Animation_PlayLoop(&this->skelAnime, &gBubbleAttackAnim); + this->actor.draw = EnBb_Draw; + this->actor.scale.x = 0.0f; + this->actor.scale.y = 0.015f; + this->actor.scale.z = 0.0f; + this->flameScaleX = 1.0f; + this->flameScaleY = 0.8f; + this->actor.colChkInfo.health = sColChkInfoInit.health; + this->actionFunc = EnBb_Revive; +} + +void EnBb_Revive(EnBb* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + this->actor.shape.rot.y += 0x1F00; + + if (Math_StepToF(&this->actor.scale.x, 0.01f, 0.0005f)) { + this->actor.flags &= ~ACTOR_FLAG_10; + this->actor.flags |= ACTOR_FLAG_1; + this->collider.base.acFlags |= AC_ON; + this->collider.base.atFlags |= AT_ON; + this->actor.world.rot.y = this->actor.shape.rot.y; + EnBb_SetupFlyIdle(this); + } + + this->actor.scale.z = this->actor.scale.x; + this->actor.scale.y = ((0.01f - this->actor.scale.x) * 0.5f) + 0.01f; +} + +void EnBb_UpdateDamage(EnBb* this, GlobalContext* globalCtx) { + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + this->collider.base.atFlags &= ~(AT_HIT | AT_BOUNCED); + this->collider.base.atFlags &= ~AT_ON; + if ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || + !(this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { + Actor_SetDropFlag(&this->actor, &this->collider.info); + this->flameScaleY = 0.0f; + this->flameScaleX = 0.0f; + EnBb_Thaw(this, globalCtx); + + if (Actor_ApplyDamage(&this->actor) == 0) { + Enemy_StartFinishingBlow(globalCtx, &this->actor); + } + + if (this->actor.colChkInfo.damageEffect == EN_BB_DMGEFF_ICE_ARROW) { + EnBb_Freeze(this); + if (this->actor.colChkInfo.health == 0) { + this->timer = 3; + this->collider.base.acFlags &= ~AC_ON; + } + + EnBb_SetupFrozen(this); + } else if (this->actor.colChkInfo.health == 0) { + EnBb_SetupDead(this, globalCtx); + } else { + EnBb_SetupDamage(this); + } + + if (this->actor.colChkInfo.damageEffect == EN_BB_DMGEFF_LIGHT_ARROW) { + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.4f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->collider.info.bumper.hitPos.x, + this->collider.info.bumper.hitPos.y, this->collider.info.bumper.hitPos.z, 0, 0, 0, + CLEAR_TAG_SMALL_LIGHT_RAYS); + } + } + } else { + if (this->collider.base.atFlags & AT_BOUNCED) { + this->collider.base.atFlags &= ~(AT_HIT | AT_BOUNCED); + if (this->actionFunc != EnBb_Down) { + this->actor.world.rot.y = this->actor.yawTowardsPlayer + 0x8000; + this->actor.shape.rot.y = this->actor.world.rot.y; + EnBb_SetupDown(this); + } + } else if (this->collider.base.atFlags & AT_HIT) { + this->collider.base.atFlags &= ~AT_HIT; + this->actor.world.rot.y = this->actor.yawTowardsPlayer + 0x8000; + this->actor.shape.rot.y = this->actor.world.rot.y; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_BITE); + + if (this->flameScaleX > 0.0f) { + gSaveContext.jinxTimer = 1200; + } + + if (this->actionFunc == EnBb_Attack) { + EnBb_SetupFlyIdle(this); + } + } + } +} + +void EnBb_Update(Actor* thisx, GlobalContext* globalCtx) { + EnBb* this = THIS; + + EnBb_UpdateDamage(this, globalCtx); + this->actionFunc(this, globalCtx); + if ((this->actionFunc != EnBb_Dead) && (this->actionFunc != EnBb_WaitForRevive)) { + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 25.0f, 40.0f, 7); + + this->collider.dim.worldSphere.center.x = this->actor.world.pos.x; + this->collider.dim.worldSphere.center.y = this->actor.world.pos.y + 15.0f; + this->collider.dim.worldSphere.center.z = this->actor.world.pos.z; + this->collider.dim.worldSphere.radius = this->flameScaleX * 30.0f; + this->collider.dim.worldSphere.radius = CLAMP_MIN(this->collider.dim.worldSphere.radius, 20); + + Math_Vec3s_ToVec3f(&this->actor.focus.pos, &this->collider.dim.worldSphere.center); + + if (this->collider.base.atFlags & AT_ON) { + this->actor.flags |= ACTOR_FLAG_1000000; + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + if (this->collider.base.acFlags & AC_ON) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + if (this->collider.base.ocFlags1 & OC1_ON) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.2f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 0.4f); + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.4f, 0.01f)) { + func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); + } + } + } +} + +s32 EnBb_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnBb* this = THIS; + + if (this->bodyPartDrawStatus == BB_BODY_PART_DRAW_STATUS_BROKEN) { + this->limbDList = *dList; + *dList = NULL; + } + + return false; +} + +void EnBb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + s32 pad; + EnBb* this = THIS; + MtxF* currentMatrixState; + + if (this->bodyPartDrawStatus == BB_BODY_PART_DRAW_STATUS_ALIVE) { + if (sLimbIndexToBodyPartsIndex[limbIndex] != -1) { + if (sLimbIndexToBodyPartsIndex[limbIndex] == 0) { + Matrix_GetStateTranslationAndScaledX(1000.0f, &this->bodyPartsPos[0]); + } else if (sLimbIndexToBodyPartsIndex[limbIndex] == 3) { + Matrix_GetStateTranslationAndScaledX(-1000.0f, &this->bodyPartsPos[3]); + Matrix_MultiplyVector3fByState(&sDuplicateCraniumBodyPartOffset, &this->bodyPartsPos[4]); + } else { + Matrix_GetStateTranslation(&this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]]); + } + } + } else if (this->bodyPartDrawStatus > BB_BODY_PART_DRAW_STATUS_ALIVE) { + if (sLimbIndexToBodyPartsIndex[limbIndex] != -1) { + Matrix_GetStateTranslation(&this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]]); + } + + if (limbIndex == BUBBLE_LIMB_CRANIUM) { + this->bodyPartDrawStatus = BB_BODY_PART_DRAW_STATUS_BROKEN; + } + } else { + if (sLimbIndexToBodyPartsIndex[limbIndex] != -1) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + currentMatrixState = Matrix_GetCurrentState(); + currentMatrixState->mf[3][0] = this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]].x; + currentMatrixState->mf[3][1] = this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]].y; + currentMatrixState->mf[3][2] = this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]].z; + Matrix_InsertZRotation_s(thisx->world.rot.z, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, this->limbDList); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + } +} + +void EnBb_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnBb* this = THIS; + MtxF* currentMatrixState; + Gfx* gfx; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gfx = POLY_OPA_DISP; + gSPDisplayList(&gfx[0], &sSetupDL[6 * 25]); + POLY_OPA_DISP = &gfx[1]; + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnBb_OverrideLimbDraw, + EnBb_PostLimbDraw, &this->actor); + + if (this->flameScaleX > 0.0f) { + currentMatrixState = Matrix_GetCurrentState(); + func_8012C2DC(globalCtx->state.gfxCtx); + Matrix_RotateY( + ((Camera_GetCamDirYaw(globalCtx->cameraPtrs[globalCtx->activeCamera]) - this->actor.shape.rot.y) + 0x8000), + MTXMODE_APPLY); + Matrix_Scale(this->flameScaleX, this->flameScaleY, 1.0f, MTXMODE_APPLY); + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 255, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 255, 0); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, + (globalCtx->gameplayFrames * -20) & 0x1FF, 32, 128)); + currentMatrixState->mf[3][1] -= 47.0f * this->flameScaleY; + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gGameplayKeepDrawFlameDL); + } + + Actor_DrawDamageEffects(globalCtx, &this->actor, this->bodyPartsPos, ARRAY_COUNT(this->bodyPartsPos), + this->drawDmgEffScale, this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, + this->drawDmgEffType); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Bb/z_en_bb.h b/src/overlays/actors/ovl_En_Bb/z_en_bb.h index 513020bd23..7d5da25b37 100644 --- a/src/overlays/actors/ovl_En_Bb/z_en_bb.h +++ b/src/overlays/actors/ovl_En_Bb/z_en_bb.h @@ -2,16 +2,39 @@ #define Z_EN_BB_H #include "global.h" +#include "objects/object_bb/object_bb.h" + +#define EN_BB_ATTACK_RANGE(thisx) (((thisx)->params >> 8) & 0xFF) struct EnBb; typedef void (*EnBbActionFunc)(struct EnBb*, GlobalContext*); typedef struct EnBb { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x104]; - /* 0x0248 */ EnBbActionFunc actionFunc; - /* 0x024C */ char unk_24C[0x100]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[BUBBLE_LIMB_MAX]; + /* 0x1E8 */ Vec3s morphTable[BUBBLE_LIMB_MAX]; + /* 0x248 */ EnBbActionFunc actionFunc; + /* 0x24C */ s8 bodyPartDrawStatus; + /* 0x24D */ u8 drawDmgEffType; + /* 0x24E */ UNK_TYPE1 unk_24E[0x2]; + /* 0x250 */ s16 timer; + /* 0x252 */ s16 attackWaitTimer; // Cannot start attacking the player if this is non-zero + /* 0x254 */ s16 targetYRotation; + /* 0x256 */ s16 bobPhase; + /* 0x258 */ f32 maxSpeed; + /* 0x25C */ f32 flyHeightMod; + /* 0x260 */ f32 attackRange; + /* 0x264 */ f32 flameScaleX; + /* 0x268 */ f32 flameScaleY; + /* 0x26C */ f32 drawDmgEffAlpha; + /* 0x270 */ f32 drawDmgEffScale; + /* 0x274 */ f32 drawDmgEffFrozenSteamScale; + /* 0x278 */ Vec3f bodyPartsPos[5]; + /* 0x2B4 */ Vec3f bodyPartsVelocity[5]; + /* 0x2F0 */ Gfx* limbDList; + /* 0x2F4 */ ColliderSphere collider; } EnBb; // size = 0x34C extern const ActorInit En_Bb_InitVars; diff --git a/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c b/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c index 00f4be6e8e..883d4dd609 100644 --- a/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c +++ b/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c @@ -220,7 +220,7 @@ void EnBba01_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_SetCylinder(globalCtx, &this->enHy.collider, &this->enHy.actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->enHy.actor.colChkInfo, &sDamageTable, &sColChkInfoInit); this->enHy.actor.flags &= ~ACTOR_FLAG_1; - this->enHy.path = func_8013D648(globalCtx, ENBBA01_GET_PATH(&this->enHy.actor), ENBBA01_NO_PATH); + this->enHy.path = SubS_GetPathByIndex(globalCtx, ENBBA01_GET_PATH(&this->enHy.actor), ENBBA01_NO_PATH); this->enHy.waitingOnInit = true; Actor_SetScale(&this->enHy.actor, 0.01f); this->enHy.actionFunc = EnBba01_FinishInit; @@ -308,7 +308,7 @@ void EnBba01_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* t void EnBba01_Draw(Actor* thisx, GlobalContext* globalCtx) { EnBba01* this = THIS; s32 i; - u8* shadowTex = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(u8[64][64])); + u8* shadowTex = GRAPH_ALLOC(globalCtx->state.gfxCtx, SUBS_SHADOW_TEX_SIZE); u8* shadowTexIter; OPEN_DISPS(globalCtx->state.gfxCtx); @@ -322,14 +322,14 @@ void EnBba01_Draw(Actor* thisx, GlobalContext* globalCtx) { EnBba01_TransformLimbDraw, &this->enHy.actor); Matrix_InsertXRotation_s(0, MTXMODE_NEW); - for (i = 0, shadowTexIter = shadowTex; i < (s32)sizeof(u8[64][64]); i++) { + for (i = 0, shadowTexIter = shadowTex; i < SUBS_SHADOW_TEX_SIZE; i++) { *shadowTexIter++ = 0; } for (i = 0; i < 5; i++) { - func_8013CD64(this->enHy.bodyPartsPos, &this->enHy.actor.world.pos, shadowTex, i / 5.0f, - ARRAY_COUNT(this->enHy.bodyPartsPos), gEnHyShadowSize, gEnHyBodyPartsIndex); + SubS_GenShadowTex(this->enHy.bodyPartsPos, &this->enHy.actor.world.pos, shadowTex, i / 5.0f, + ARRAY_COUNT(this->enHy.bodyPartsPos), gEnHyShadowSizes, gEnHyParentBodyParts); } - func_8013CF04(&this->enHy.actor, &globalCtx->state.gfxCtx, shadowTex); + SubS_DrawShadowTex(&this->enHy.actor, &globalCtx->state, shadowTex); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.c b/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.c index 8af8e650a5..3ccd807d8c 100644 --- a/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.c +++ b/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.c @@ -5,6 +5,7 @@ */ #include "z_en_bbfall.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_200) @@ -15,16 +16,25 @@ void EnBbfall_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnBbfall_Update(Actor* thisx, GlobalContext* globalCtx); void EnBbfall_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_808BF734(EnBbfall* this, GlobalContext* globalCtx); -void func_808BF830(EnBbfall* this, GlobalContext* globalCtx); -void func_808BF8DC(EnBbfall* this, GlobalContext* globalCtx); -void func_808BFA3C(EnBbfall* this, GlobalContext* globalCtx); -void func_808BFB4C(EnBbfall* this, GlobalContext* globalCtx); -void func_808BFE58(EnBbfall* this, GlobalContext* globalCtx); -void func_808C00A0(EnBbfall* this, GlobalContext* globalCtx); -void func_808C0178(EnBbfall* this, GlobalContext* globalCtx); +void EnBbfall_SetupWaitForPlayer(EnBbfall* this); +void EnBbfall_WaitForPlayer(EnBbfall* this, GlobalContext* globalCtx); +void EnBbfall_SetupEmerge(EnBbfall* this); +void EnBbfall_Emerge(EnBbfall* this, GlobalContext* globalCtx); +void EnBbfall_SetupFly(EnBbfall* this); +void EnBbfall_Fly(EnBbfall* this, GlobalContext* globalCtx); +void EnBbfall_SetupSinkIntoLava(EnBbfall* this); +void EnBbfall_SinkIntoLava(EnBbfall* this, GlobalContext* globalCtx); +void EnBbfall_Down(EnBbfall* this, GlobalContext* globalCtx); +void EnBbfall_Dead(EnBbfall* this, GlobalContext* globalCtx); +void EnBbfall_Damage(EnBbfall* this, GlobalContext* globalCtx); +void EnBbfall_Frozen(EnBbfall* this, GlobalContext* globalCtx); + +typedef enum { + /* -1 */ BBFALL_BODY_PART_DRAW_STATUS_BROKEN = -1, + /* 0 */ BBFALL_BODY_PART_DRAW_STATUS_ALIVE, + /* 1 */ BBFALL_BODY_PART_DRAW_STATUS_DEAD, +} EnBbfallBodyPartDrawStatus; -#if 0 const ActorInit En_Bbfall_InitVars = { ACTOR_EN_BBFALL, ACTORCAT_ENEMY, @@ -37,140 +47,720 @@ const ActorInit En_Bbfall_InitVars = { (ActorFunc)EnBbfall_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[3] = { -static ColliderJntSphElementInit D_808C0D30[3] = { +static ColliderJntSphElementInit sJntSphElementsInit[3] = { { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x01, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_HARD, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x01, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_HARD, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 20 }, 100 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x01, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_HARD, BUMP_NONE, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x01, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_HARD, + BUMP_NONE, + OCELEM_NONE, + }, { 0, { { 0, 0, 0 }, 20 }, 100 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x01, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_HARD, BUMP_NONE, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x01, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_HARD, + BUMP_NONE, + OCELEM_NONE, + }, { 0, { { 0, 0, 0 }, 20 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_808C0D9C = { - { COLTYPE_HIT3, AT_NONE | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 3, D_808C0D30, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_HIT3, + AT_NONE | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + ARRAY_COUNT(sJntSphElementsInit), + sJntSphElementsInit, }; -// static DamageTable sDamageTable = { -static DamageTable D_808C0DAC = { - /* Deku Nut */ DMG_ENTRY(0, 0x1), - /* Deku Stick */ DMG_ENTRY(1, 0x0), - /* Horse trample */ DMG_ENTRY(0, 0x0), - /* Explosives */ DMG_ENTRY(1, 0x0), - /* Zora boomerang */ DMG_ENTRY(1, 0x0), - /* Normal arrow */ DMG_ENTRY(1, 0x0), - /* UNK_DMG_0x06 */ DMG_ENTRY(0, 0x0), - /* Hookshot */ DMG_ENTRY(0, 0xE), - /* Goron punch */ DMG_ENTRY(1, 0x0), - /* Sword */ DMG_ENTRY(1, 0x0), - /* Goron pound */ DMG_ENTRY(1, 0x0), - /* Fire arrow */ DMG_ENTRY(1, 0x0), - /* Ice arrow */ DMG_ENTRY(2, 0x3), - /* Light arrow */ DMG_ENTRY(2, 0x4), - /* Goron spikes */ DMG_ENTRY(1, 0x0), - /* Deku spin */ DMG_ENTRY(1, 0x0), - /* Deku bubble */ DMG_ENTRY(1, 0x0), - /* Deku launch */ DMG_ENTRY(2, 0x0), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0x1), - /* Zora barrier */ DMG_ENTRY(0, 0x5), - /* Normal shield */ DMG_ENTRY(0, 0x0), - /* Light ray */ DMG_ENTRY(0, 0x0), - /* Thrown object */ DMG_ENTRY(1, 0x0), - /* Zora punch */ DMG_ENTRY(1, 0x0), - /* Spin attack */ DMG_ENTRY(1, 0x0), - /* Sword beam */ DMG_ENTRY(0, 0x0), - /* Normal Roll */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0x0), - /* Powder Keg */ DMG_ENTRY(1, 0x0), +typedef enum { + /* 0x0 */ EN_BBFALL_DMGEFF_NONE, + /* 0x1 */ EN_BBFALL_DMGEFF_STUN, + /* 0x3 */ EN_BBFALL_DMGEFF_ICE_ARROW = 0x3, + /* 0x4 */ EN_BBFALL_DMGEFF_LIGHT_ARROW, + /* 0x5 */ EN_BBFALL_DMGEFF_ZORA_MAGIC, + /* 0xE */ EN_BBFALL_DMGEFF_HOOKSHOT = 0xE, +} EnBbfallDamageEffect; + +static DamageTable sDamageTable = { + /* Deku Nut */ DMG_ENTRY(0, EN_BBFALL_DMGEFF_STUN), + /* Deku Stick */ DMG_ENTRY(1, EN_BBFALL_DMGEFF_NONE), + /* Horse trample */ DMG_ENTRY(0, EN_BBFALL_DMGEFF_NONE), + /* Explosives */ DMG_ENTRY(1, EN_BBFALL_DMGEFF_NONE), + /* Zora boomerang */ DMG_ENTRY(1, EN_BBFALL_DMGEFF_NONE), + /* Normal arrow */ DMG_ENTRY(1, EN_BBFALL_DMGEFF_NONE), + /* UNK_DMG_0x06 */ DMG_ENTRY(0, EN_BBFALL_DMGEFF_NONE), + /* Hookshot */ DMG_ENTRY(0, EN_BBFALL_DMGEFF_HOOKSHOT), + /* Goron punch */ DMG_ENTRY(1, EN_BBFALL_DMGEFF_NONE), + /* Sword */ DMG_ENTRY(1, EN_BBFALL_DMGEFF_NONE), + /* Goron pound */ DMG_ENTRY(1, EN_BBFALL_DMGEFF_NONE), + /* Fire arrow */ DMG_ENTRY(1, EN_BBFALL_DMGEFF_NONE), + /* Ice arrow */ DMG_ENTRY(2, EN_BBFALL_DMGEFF_ICE_ARROW), + /* Light arrow */ DMG_ENTRY(2, EN_BBFALL_DMGEFF_LIGHT_ARROW), + /* Goron spikes */ DMG_ENTRY(1, EN_BBFALL_DMGEFF_NONE), + /* Deku spin */ DMG_ENTRY(1, EN_BBFALL_DMGEFF_NONE), + /* Deku bubble */ DMG_ENTRY(1, EN_BBFALL_DMGEFF_NONE), + /* Deku launch */ DMG_ENTRY(2, EN_BBFALL_DMGEFF_NONE), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, EN_BBFALL_DMGEFF_STUN), + /* Zora barrier */ DMG_ENTRY(0, EN_BBFALL_DMGEFF_ZORA_MAGIC), + /* Normal shield */ DMG_ENTRY(0, EN_BBFALL_DMGEFF_NONE), + /* Light ray */ DMG_ENTRY(0, EN_BBFALL_DMGEFF_NONE), + /* Thrown object */ DMG_ENTRY(1, EN_BBFALL_DMGEFF_NONE), + /* Zora punch */ DMG_ENTRY(1, EN_BBFALL_DMGEFF_NONE), + /* Spin attack */ DMG_ENTRY(1, EN_BBFALL_DMGEFF_NONE), + /* Sword beam */ DMG_ENTRY(0, EN_BBFALL_DMGEFF_NONE), + /* Normal Roll */ DMG_ENTRY(0, EN_BBFALL_DMGEFF_NONE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, EN_BBFALL_DMGEFF_NONE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, EN_BBFALL_DMGEFF_NONE), + /* Unblockable */ DMG_ENTRY(0, EN_BBFALL_DMGEFF_NONE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, EN_BBFALL_DMGEFF_NONE), + /* Powder Keg */ DMG_ENTRY(1, EN_BBFALL_DMGEFF_NONE), }; -// sColChkInfoInit -static CollisionCheckInfoInit D_808C0DCC = { 2, 20, 40, 50 }; +static CollisionCheckInfoInit sColChkInfoInit = { 2, 20, 40, 50 }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808C0DD4[] = { +static InitChainEntry sInitChain[] = { ICHAIN_S8(hintId, 36, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 10, ICHAIN_STOP), }; -#endif +/** + * This maps a given limb based on its limbIndex to its appropriate index + * in the bodyPartsPos/Velocity arrays. An index of -1 indicates that the + * limb is not part of the bodyParts arrays. + */ +static s8 sLimbIndexToBodyPartsIndex[] = { + -1, -1, -1, -1, 0, -1, -1, -1, 1, -1, -1, -1, -1, 2, -1, 3, +}; -extern ColliderJntSphElementInit D_808C0D30[3]; -extern ColliderJntSphInit D_808C0D9C; -extern DamageTable D_808C0DAC; -extern CollisionCheckInfoInit D_808C0DCC; -extern InitChainEntry D_808C0DD4[]; +/** + * The last element of the bodyParts arrays is a duplicate of the cranium + * limb, which is then offset by a certain amount. There is no display list + * associated with this, so it is only used for effects. + */ +static Vec3f sDuplicateCraniumBodyPartOffset = { 1000.0f, -700.0f, 0.0f }; -extern UNK_TYPE D_06000184; -extern UNK_TYPE D_06000444; +void EnBbfall_Init(Actor* thisx, GlobalContext* globalCtx) { + EnBbfall* this = THIS; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/EnBbfall_Init.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + SkelAnime_Init(globalCtx, &this->skelAnime, &gBubbleSkel, &gBubbleFlyingAnim, this->jointTable, this->morphTable, + BUBBLE_LIMB_MAX); + CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + Collider_InitAndSetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); + ActorShape_Init(&this->actor.shape, 1500.0f, ActorShadow_DrawCircle, 35.0f); + this->timer = 0; + EnBbfall_SetupWaitForPlayer(this); + Actor_SetFocus(&this->actor, 0.0f); + for (i = 0; i < ARRAY_COUNT(this->colliderElements); i++) { + this->collider.elements[i].dim.worldSphere.radius = this->collider.elements[i].dim.modelSphere.radius; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/EnBbfall_Destroy.s") +void EnBbfall_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnBbfall* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BF344.s") + Collider_DestroyJntSph(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BF3B8.s") +void EnBbfall_Freeze(EnBbfall* this) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; + this->drawDmgEffScale = 0.4f; + this->drawDmgEffFrozenSteamScale = 0.6f; + this->timer = 80; + this->drawDmgEffAlpha = 1.0f; + this->actor.flags &= ~ACTOR_FLAG_200; + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BF438.s") +void EnBbfall_Thaw(EnBbfall* this, GlobalContext* globalCtx) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, this->bodyPartsPos, ARRAY_COUNT(this->bodyPartsPos), 2, 0.2f, + 0.15f); + this->actor.flags |= ACTOR_FLAG_200; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BF4B4.s") +/** + * Returns true if the Bubble is touching a floor that it should "sink into" (i.e., if it's touching lava). + */ +s32 EnBbfall_IsTouchingLava(EnBbfall* this, GlobalContext* globalCtx) { + if (!SurfaceType_IsWallDamage(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId)) { + u32 floorType = func_800C99D4(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BF514.s") + if ((floorType == 2) || (floorType == 3) || (floorType == 9)) { + return true; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BF578.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BF5AC.s") +void EnBbfall_PlaySfx(EnBbfall* this) { + if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 5.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_MOUTH); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BF5E0.s") + func_800B9010(&this->actor, NA_SE_EN_BUBLEFALL_FIRE - SFX_FLAG); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BF734.s") +/** + * Checks to see if the Bubble is touching a wall. If it is, and if the + * Bubble is facing directly "into" the wall, then rotate it away from + * the wall. + */ +void EnBbfall_CheckForWall(EnBbfall* this) { + s16 yawDiff; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BF7A0.s") + if (this->actor.bgCheckFlags & 8) { + yawDiff = this->actor.shape.rot.y - this->actor.wallYaw; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BF830.s") + if (ABS_ALT(yawDiff) > 0x4000) { + this->actor.shape.rot.y = ((this->actor.wallYaw * 2) - this->actor.shape.rot.y) - 0x8000; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BF894.s") + this->actor.bgCheckFlags &= ~8; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BF8DC.s") +void EnBbfall_EnableColliders(EnBbfall* this) { + this->collider.elements[0].info.toucher.effect = ELEMTYPE_UNK1; // Fire + this->collider.elements[1].info.toucherFlags |= TOUCH_ON; + this->collider.elements[2].info.toucherFlags |= TOUCH_ON; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BFA18.s") +void EnBbfall_DisableColliders(EnBbfall* this) { + this->collider.elements[0].info.toucher.effect = ELEMTYPE_UNK0; // Nothing + this->collider.elements[1].info.toucherFlags &= ~TOUCH_ON; + this->collider.elements[2].info.toucherFlags &= ~TOUCH_ON; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BFA3C.s") +void EnBbfall_SetupWaitForPlayer(EnBbfall* this) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BFAB4.s") + Animation_PlayLoop(&this->skelAnime, &gBubbleAttackAnim); + this->collider.base.atFlags &= ~AT_ON; + this->collider.base.acFlags &= ~AC_ON; + this->collider.base.ocFlags1 &= ~OC1_ON; + this->flameScaleY = 0.8f; + this->flameScaleX = 1.0f; + this->flameOpacity = 255; + this->actor.colChkInfo.health = sColChkInfoInit.health; + this->actor.colorFilterTimer = 0; + this->isBgCheckCollisionEnabled = false; + this->actor.speedXZ = 0.0f; + this->actor.gravity = 0.0f; + this->actor.velocity.y = 0.0f; + Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.home.pos); + this->actor.world.pos.y -= 90.0f; + for (i = 0; i < ARRAY_COUNT(this->flamePos); i++) { + Math_Vec3f_Copy(&this->flamePos[i], &this->actor.world.pos); + this->flamePos[i].y -= 47.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BFB4C.s") + this->actor.bgCheckFlags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; + this->actionFunc = EnBbfall_WaitForPlayer; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BFCCC.s") +void EnBbfall_WaitForPlayer(EnBbfall* this, GlobalContext* globalCtx) { + if (this->timer != 0) { + this->timer--; + } else if ((Player_GetMask(globalCtx) != PLAYER_MASK_STONE) && (this->actor.xyzDistToPlayerSq <= SQ(250.0f))) { + EnBbfall_SetupEmerge(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BFE58.s") +void EnBbfall_SetupEmerge(EnBbfall* this) { + this->actor.gravity = -1.0f; + this->actor.world.rot.y = this->actor.yawTowardsPlayer; + this->actor.shape.rot.y = this->actor.yawTowardsPlayer; + this->collider.base.atFlags |= AT_ON; + this->collider.base.acFlags |= AC_ON; + this->collider.base.ocFlags1 |= OC1_ON; + this->actor.velocity.y = 17.0f; + EnBbfall_EnableColliders(this); + this->actor.flags |= ACTOR_FLAG_1; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLEFALL_APPEAR); + this->actionFunc = EnBbfall_Emerge; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BFF8C.s") +void EnBbfall_Emerge(EnBbfall* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + if (this->actor.home.pos.y < this->actor.world.pos.y) { + EnBbfall_SetupFly(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808C00A0.s") + EnBbfall_PlaySfx(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808C013C.s") +void EnBbfall_SetupFly(EnBbfall* this) { + this->flameOpacity = 255; + this->isBgCheckCollisionEnabled = true; + this->actor.bgCheckFlags &= ~1; + this->actor.speedXZ = 5.0f; + this->actor.gravity = -1.0f; + this->actionFunc = EnBbfall_Fly; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808C0178.s") +void EnBbfall_Fly(EnBbfall* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + Math_StepToF(&this->flameScaleY, 0.8f, 0.1f); + Math_StepToF(&this->flameScaleX, 1.0f, 0.1f); + EnBbfall_CheckForWall(this); + if (this->actor.bgCheckFlags & 1) { + if (EnBbfall_IsTouchingLava(this, globalCtx)) { + EnBbfall_SetupSinkIntoLava(this); + } else { + // Bounce upwards off the ground + this->actor.velocity.y *= -1.2f; + this->actor.velocity.y = CLAMP(this->actor.velocity.y, 8.0f, 12.0f); + this->actor.shape.rot.y += (s16)randPlusMinusPoint5Scaled(73728.0f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808C01E0.s") + this->actor.bgCheckFlags &= ~1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/EnBbfall_Update.s") + this->actor.world.rot.y = this->actor.shape.rot.y; + EnBbfall_PlaySfx(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808C07D4.s") +void EnBbfall_SetupSinkIntoLava(EnBbfall* this) { + this->isBgCheckCollisionEnabled = false; + this->collider.base.acFlags &= ~AC_ON; + this->actionFunc = EnBbfall_SinkIntoLava; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808C080C.s") +void EnBbfall_SinkIntoLava(EnBbfall* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + if (this->actor.world.pos.y < (this->actor.floorHeight - 90.0f)) { + this->timer = 10; + EnBbfall_SetupWaitForPlayer(this); + } else { + EnBbfall_PlaySfx(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/EnBbfall_Draw.s") +void EnBbfall_SetupDown(EnBbfall* this) { + Animation_PlayLoop(&this->skelAnime, &gBubbleFlyingAnim); + this->collider.base.atFlags |= AT_ON; + this->timer = 200; + this->flameOpacity = 0; + this->collider.base.acFlags |= AC_ON; + this->actor.speedXZ = 2.0f; + this->flameScaleY = 0.0f; + this->flameScaleX = 0.0f; + this->actor.gravity = -2.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_DOWN); + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actionFunc = EnBbfall_Down; +} + +void EnBbfall_Down(EnBbfall* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + EnBbfall_CheckForWall(this); + + if (this->actor.bgCheckFlags & 1) { + if (EnBbfall_IsTouchingLava(this, globalCtx)) { + EnBbfall_SetupSinkIntoLava(this); + return; + } + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); + if (this->timer == 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_UP); + EnBbfall_EnableColliders(this); + this->actor.velocity.y = 8.0f; + EnBbfall_SetupFly(this); + return; + } + + if (this->actor.velocity.y < -14.0f) { + this->actor.velocity.y *= -0.7f; + } else { + this->actor.velocity.y = 10.0f; + } + + this->actor.bgCheckFlags &= ~1; + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 7.0f, 2, 2.0f, 0, 0, 0); + Math_ScaledStepToS(&this->actor.shape.rot.y, BINANG_ADD(this->actor.yawTowardsPlayer, 0x8000), 0xBB8); + } + + this->actor.world.rot.y = this->actor.shape.rot.y; + if (Animation_OnFrame(&this->skelAnime, 5.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_WING); + } + + if (this->timer > 0) { + this->timer--; + } +} + +void EnBbfall_SetupDead(EnBbfall* this, GlobalContext* globalCtx) { + Vec3f* bodyPartVelocity; + Vec3f posDiff; + f32 magnitude; + s32 i; + + func_800BE5CC(&this->actor, &this->collider, 0); + this->timer = 15; + this->actor.shape.rot.x += 0x4E20; + this->actor.speedXZ = 0.0f; + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_BUBLE_DEAD); + Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x70); + this->actor.velocity.y = 0.0f; + this->actor.speedXZ = 0.0f; + this->bodyPartDrawStatus = BBFALL_BODY_PART_DRAW_STATUS_DEAD; + this->actor.gravity = -1.5f; + + bodyPartVelocity = &this->bodyPartsVelocity[0]; + for (i = 0; i < ARRAY_COUNT(this->bodyPartsPos); i++, bodyPartVelocity++) { + Math_Vec3f_Diff(&this->bodyPartsPos[i], &this->actor.world.pos, &posDiff); + magnitude = Math3D_Vec3fMagnitude(&posDiff); + if (magnitude > 1.0f) { + magnitude = 2.5f / magnitude; + } + + bodyPartVelocity->x = posDiff.x * magnitude; + bodyPartVelocity->z = posDiff.z * magnitude; + bodyPartVelocity->y = Rand_ZeroFloat(3.5f) + 10.0f; + } + + this->actionFunc = EnBbfall_Dead; +} + +void EnBbfall_Dead(EnBbfall* this, GlobalContext* globalCtx) { + s32 i; + + this->timer--; + Math_SmoothStepToS(&this->actor.world.rot.z, 0x4000, 4, 0x1000, 0x400); + + if (this->timer == 0) { + for (i = 0; i < ARRAY_COUNT(this->bodyPartsPos); i++) { + func_800B3030(globalCtx, &this->bodyPartsPos[i], &gZeroVec3f, &gZeroVec3f, 40, 7, 2); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->bodyPartsPos[i], 11, NA_SE_EN_EXTINCT); + } + + Actor_MarkForDeath(&this->actor); + } else { + for (i = 0; i < ARRAY_COUNT(this->bodyPartsPos); i++) { + Math_Vec3f_Sum(&this->bodyPartsPos[i], &this->bodyPartsVelocity[i], &this->bodyPartsPos[i]); + this->bodyPartsVelocity[i].y += this->actor.gravity; + } + } +} + +void EnBbfall_SetupDamage(EnBbfall* this) { + this->collider.base.acFlags &= ~AC_ON; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_DAMAGE); + func_800BE5CC(&this->actor, &this->collider, 0); + + if (this->actor.colChkInfo.damageEffect == EN_BBFALL_DMGEFF_ZORA_MAGIC) { + Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_LARGE; + this->drawDmgEffAlpha = 2.0f; + this->drawDmgEffScale = 0.4f; + } else if (this->actor.colChkInfo.damageEffect == EN_BBFALL_DMGEFF_STUN) { + Actor_SetColorFilter(&this->actor, 0, 255, 0, 20); + this->actor.speedXZ = 0.0f; + } else if (this->actor.colChkInfo.damageEffect == EN_BBFALL_DMGEFF_HOOKSHOT) { + this->actor.speedXZ = 0.0f; + } else { + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 20); + this->actor.speedXZ = 7.0f; + } + + this->actionFunc = EnBbfall_Damage; +} + +void EnBbfall_Damage(EnBbfall* this, GlobalContext* globalCtx) { + Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f); + if ((this->actor.bgCheckFlags & 1) && (this->actor.speedXZ < 0.1f)) { + if (EnBbfall_IsTouchingLava(this, globalCtx)) { + EnBbfall_SetupSinkIntoLava(this); + } else { + EnBbfall_SetupDown(this); + } + } +} + +void EnBbfall_SetupFrozen(EnBbfall* this) { + this->actor.speedXZ = 0.0f; + if (this->actor.velocity.y > 0.0f) { + this->actor.velocity.y = 0.0f; + } + + this->actor.gravity = -2.0f; + this->actionFunc = EnBbfall_Frozen; +} + +void EnBbfall_Frozen(EnBbfall* this, GlobalContext* globalCtx) { + DECR(this->timer); + + if (this->timer == 0) { + EnBbfall_Thaw(this, globalCtx); + if (this->actor.colChkInfo.health == 0) { + EnBbfall_SetupDead(this, globalCtx); + } else { + EnBbfall_SetupDown(this); + } + } +} + +void EnBbfall_UpdateDamage(EnBbfall* this, GlobalContext* globalCtx) { + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + this->collider.base.atFlags &= ~(AT_HIT | AT_BOUNCED); + this->collider.base.atFlags &= ~AT_ON; + if ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || + !(this->collider.elements[0].info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { + Actor_SetDropFlagJntSph(&this->actor, &this->collider); + this->flameOpacity = 0; + this->flameScaleY = 0.0f; + this->flameScaleX = 0.0f; + EnBbfall_DisableColliders(this); + EnBbfall_Thaw(this, globalCtx); + + if (Actor_ApplyDamage(&this->actor) == 0) { + Enemy_StartFinishingBlow(globalCtx, &this->actor); + } + + if (this->actor.colChkInfo.damageEffect == EN_BBFALL_DMGEFF_ICE_ARROW) { + EnBbfall_Freeze(this); + if (this->actor.colChkInfo.health == 0) { + this->timer = 3; + this->collider.base.acFlags &= ~AC_ON; + } + + EnBbfall_SetupFrozen(this); + } else if (this->actor.colChkInfo.health == 0) { + EnBbfall_SetupDead(this, globalCtx); + } else { + EnBbfall_SetupDamage(this); + } + + if (this->actor.colChkInfo.damageEffect == EN_BBFALL_DMGEFF_LIGHT_ARROW) { + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.4f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, + this->collider.elements[0].info.bumper.hitPos.x, + this->collider.elements[0].info.bumper.hitPos.y, + this->collider.elements[0].info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_SMALL_LIGHT_RAYS); + } + } + } else { + if (this->collider.base.atFlags & AT_BOUNCED) { + this->collider.base.atFlags &= ~(AT_HIT | AT_BOUNCED); + EnBbfall_DisableColliders(this); + if (this->actionFunc != EnBbfall_Down) { + this->actor.world.rot.y = this->actor.yawTowardsPlayer + 0x8000; + this->actor.shape.rot.y = this->actor.world.rot.y; + EnBbfall_SetupDown(this); + } + } + } +} + +void EnBbfall_Update(Actor* thisx, GlobalContext* globalCtx) { + EnBbfall* this = THIS; + Sphere16* sphere; + Vec3f diff; + s32 i; + f32 scale; + s32 pad[2]; + + EnBbfall_UpdateDamage(this, globalCtx); + this->actionFunc(this, globalCtx); + if (this->actionFunc != EnBbfall_Dead) { + Actor_MoveWithGravity(&this->actor); + if (this->isBgCheckCollisionEnabled) { + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 25.0f, 20.0f, 7); + } + + for (i = ARRAY_COUNT(this->flamePos) - 1; i >= 2; i--) { + Math_Vec3f_Diff(&this->flamePos[i - 2], &this->flamePos[i - 1], &diff); + Math_Vec3f_Scale(&diff, (i - 1) * 0.1f); + Math_Vec3f_Copy(&this->flamePos[i], &this->flamePos[i - 1]); + Math_Vec3f_Sum(&this->flamePos[i], &diff, &this->flamePos[i]); + } + + Math_Vec3f_Copy(&this->flamePos[1], &this->flamePos[0]); + Math_Vec3f_Copy(&this->flamePos[0], &this->actor.world.pos); + this->flamePos[0].y += 15.0f; + this->flamePos[0].y -= 47.0f * this->flameScaleY; + + for (i = 0, scale = this->flameScaleX; i < ARRAY_COUNT(this->colliderElements); i++, scale *= 0.7569f) { + sphere = &this->collider.elements[i].dim.worldSphere; + sphere->radius = 30.0f * scale; + sphere->center.x = this->flamePos[2 * i].x; + sphere->center.y = this->flamePos[2 * i].y + (47.0f * scale); + sphere->center.z = this->flamePos[2 * i].z; + } + + this->collider.elements[0].dim.worldSphere.radius = + CLAMP_MIN(this->collider.elements[0].dim.worldSphere.radius, 20); + + Math_Vec3s_ToVec3f(&this->actor.focus.pos, &this->collider.elements->dim.worldSphere.center); + + if (this->collider.base.atFlags & AT_ON) { + this->actor.flags |= ACTOR_FLAG_1000000; + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + if (this->collider.base.acFlags & AC_ON) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + if (this->collider.base.ocFlags1 & OC1_ON) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.2f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 0.4f); + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.4f, 0.01f)) { + func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); + } + } + } +} + +s32 EnBbfall_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnBbfall* this = THIS; + + if (this->bodyPartDrawStatus == BBFALL_BODY_PART_DRAW_STATUS_BROKEN) { + this->limbDList = *dList; + *dList = NULL; + } + + return false; +} + +void EnBbfall_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + s32 pad; + EnBbfall* this = THIS; + MtxF* currentMatrixState; + + if (this->bodyPartDrawStatus == BBFALL_BODY_PART_DRAW_STATUS_ALIVE) { + if (sLimbIndexToBodyPartsIndex[limbIndex] != -1) { + if (sLimbIndexToBodyPartsIndex[limbIndex] == 0) { + Matrix_GetStateTranslationAndScaledX(1000.0f, &this->bodyPartsPos[0]); + } else if (sLimbIndexToBodyPartsIndex[limbIndex] == 3) { + Matrix_GetStateTranslationAndScaledX(-1000.0f, &this->bodyPartsPos[3]); + Matrix_MultiplyVector3fByState(&sDuplicateCraniumBodyPartOffset, &this->bodyPartsPos[4]); + } else { + Matrix_GetStateTranslation(&this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]]); + } + } + } else if (this->bodyPartDrawStatus > BBFALL_BODY_PART_DRAW_STATUS_ALIVE) { + if (sLimbIndexToBodyPartsIndex[limbIndex] != -1) { + Matrix_GetStateTranslation(&this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]]); + } + + if (limbIndex == BUBBLE_LIMB_CRANIUM) { + this->bodyPartDrawStatus = BBFALL_BODY_PART_DRAW_STATUS_BROKEN; + } + } else { + if (sLimbIndexToBodyPartsIndex[limbIndex] != -1) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + currentMatrixState = Matrix_GetCurrentState(); + currentMatrixState->mf[3][0] = this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]].x; + currentMatrixState->mf[3][1] = this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]].y; + currentMatrixState->mf[3][2] = this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]].z; + Matrix_InsertZRotation_s(thisx->world.rot.z, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, this->limbDList); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + } +} + +void EnBbfall_Draw(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnBbfall* this = THIS; + MtxF* currentMatrixState; + Gfx* gfx; + s32 opacity; + Vec3f* pos; + s32 i; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gfx = POLY_OPA_DISP; + gSPDisplayList(&gfx[0], &sSetupDL[6 * 25]); + POLY_OPA_DISP = &gfx[1]; + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnBbfall_OverrideLimbDraw, + EnBbfall_PostLimbDraw, &this->actor); + + if (this->flameOpacity > 0) { + func_8012C2DC(globalCtx->state.gfxCtx); + Matrix_RotateY( + ((Camera_GetCamDirYaw(globalCtx->cameraPtrs[globalCtx->activeCamera]) - this->actor.shape.rot.y) + 0x8000), + MTXMODE_APPLY); + Matrix_Scale(this->flameScaleX, this->flameScaleY, 1.0f, MTXMODE_APPLY); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); + currentMatrixState = Matrix_GetCurrentState(); + + opacity = this->flameOpacity; + pos = &this->flamePos[0]; + + for (i = 0; i < ARRAY_COUNT(this->flamePos); i++, pos++) { + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, + ((globalCtx->gameplayFrames + (i * 10)) * (-20 + i * 2)) & 0x1FF, 32, 128)); + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 0, opacity); + currentMatrixState->mf[3][0] = pos->x; + currentMatrixState->mf[3][1] = pos->y; + currentMatrixState->mf[3][2] = pos->z; + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gGameplayKeepDrawFlameDL); + + opacity -= 35; + if (opacity < 0) { + break; + } + + Matrix_Scale(0.87f, 0.87f, 1.0f, MTXMODE_APPLY); + } + } + + Actor_DrawDamageEffects(globalCtx, &this->actor, this->bodyPartsPos, ARRAY_COUNT(this->bodyPartsPos), + this->drawDmgEffScale, this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, + this->drawDmgEffType); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.h b/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.h index 90c209b318..411c4b17f3 100644 --- a/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.h +++ b/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.h @@ -2,16 +2,35 @@ #define Z_EN_BBFALL_H #include "global.h" +#include "objects/object_bb/object_bb.h" struct EnBbfall; typedef void (*EnBbfallActionFunc)(struct EnBbfall*, GlobalContext*); typedef struct EnBbfall { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x104]; - /* 0x0248 */ EnBbfallActionFunc actionFunc; - /* 0x024C */ char unk_24C[0x218]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[BUBBLE_LIMB_MAX]; + /* 0x1E8 */ Vec3s morphTable[BUBBLE_LIMB_MAX]; + /* 0x248 */ EnBbfallActionFunc actionFunc; + /* 0x24C */ u8 flameOpacity; + /* 0x24D */ u8 isBgCheckCollisionEnabled; + /* 0x24E */ s8 bodyPartDrawStatus; + /* 0x24F */ u8 drawDmgEffType; + /* 0x250 */ s16 timer; + /* 0x254 */ f32 flameScaleY; + /* 0x258 */ f32 flameScaleX; + /* 0x25C */ f32 drawDmgEffAlpha; + /* 0x260 */ f32 drawDmgEffScale; + /* 0x264 */ f32 drawDmgEffFrozenSteamScale; + /* 0x268 */ Vec3f flamePos[6]; + /* 0x2B0 */ Vec3f bodyPartsPos[5]; + /* 0x2EC */ Vec3f bodyPartsVelocity[5]; + /* 0x328 */ Gfx* limbDList; + /* 0x32C */ UNK_TYPE1 unk_32C[0x58]; + /* 0x384 */ ColliderJntSph collider; + /* 0x3A4 */ ColliderJntSphElement colliderElements[3]; } EnBbfall; // size = 0x464 extern const ActorInit En_Bbfall_InitVars; diff --git a/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c b/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c index 019332000a..8431d67067 100644 --- a/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c +++ b/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c @@ -43,11 +43,6 @@ const ActorInit En_Bigokuta_InitVars = { (ActorFunc)EnBigokuta_Draw, }; -typedef enum { - BIGOCTO_DRAWEFFECT_ICE = 10, - BIGOCTO_DRAWEFFECT_LIGHT_ORBS = 20, -} EnBigokutaDrawEffect; - static ColliderCylinderInit sShellCylinderInit = { { COLTYPE_HARD, @@ -110,7 +105,7 @@ void EnBigokuta_Init(Actor* thisx, GlobalContext* globalCtx) { CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); this->cutscene = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); - if (gSaveContext.weekEventReg[20] & 2 || + if (gSaveContext.save.weekEventReg[20] & 2 || ((this->actor.params != 0xFF) && Flags_GetSwitch(globalCtx, this->actor.params))) { Actor_MarkForDeath(&this->actor); } else { @@ -373,8 +368,8 @@ void EnBigokuta_PlayDeathCutscene(EnBigokuta* this, GlobalContext* globalCtx) { if (this->timer != 0) { this->timer--; if (this->timer == 0) { - this->drawEffect = 0; - this->drawEffectAlpha = 0.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffAlpha = 0.0f; Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), 2, 0.5f, 0.35f); EnBigokuta_SetupDeathEffects(this); } @@ -388,7 +383,7 @@ void EnBigokuta_PlayDeathCutscene(EnBigokuta* this, GlobalContext* globalCtx) { player->stateFlags1 |= 0x20; } - if (this->drawEffect == BIGOCTO_DRAWEFFECT_ICE) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { this->timer = 3; } else { EnBigokuta_SetupDeathEffects(this); @@ -466,8 +461,8 @@ void EnBigokuta_PlayDeathEffects(EnBigokuta* this, GlobalContext* globalCtx) { } } - if (this->drawEffectAlpha > 0.0f) { - this->drawEffectAlpha = this->actor.scale.y * 30.30303f; + if (this->drawDmgEffAlpha > 0.0f) { + this->drawDmgEffAlpha = this->actor.scale.y * 30.30303f; } } } else { @@ -494,14 +489,14 @@ void EnBigokuta_CheckOneHitKill(EnBigokuta* this, GlobalContext* globalCtx) { if (this->bodyCollider.base.acFlags & AC_HIT) { if (this->bodyCollider.info.acHitInfo->toucher.dmgFlags & 0x1000) { // Ice Arrow - this->drawEffect = BIGOCTO_DRAWEFFECT_ICE; - this->drawEffectScale = 1.2f; - this->drawEffectSteamScale = 1.8000001f; - this->drawEffectAlpha = 1.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; + this->drawDmgEffScale = 1.2f; + this->drawDmgEffFrozenSteamScale = 1.8000001f; + this->drawDmgEffAlpha = 1.0f; } else if (this->bodyCollider.info.acHitInfo->toucher.dmgFlags & 0x2000) { // Light Arrow - this->drawEffect = BIGOCTO_DRAWEFFECT_LIGHT_ORBS; - this->drawEffectScale = 1.2f; - this->drawEffectAlpha = 4.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->drawDmgEffScale = 1.2f; + this->drawDmgEffAlpha = 4.0f; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->bodyCollider.info.bumper.hitPos.x, this->bodyCollider.info.bumper.hitPos.y, this->bodyCollider.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); @@ -546,12 +541,12 @@ void EnBigokuta_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_SetFocus(&this->actor, 82.5f); } - if (this->drawEffectAlpha > 0.0f) { - if (this->drawEffect != BIGOCTO_DRAWEFFECT_ICE) { - Math_StepToF(&this->drawEffectAlpha, 0.0f, 0.05f); - this->drawEffectScale = (this->drawEffectAlpha + 1.0f) * 0.6f; - this->drawEffectScale = CLAMP_MAX(this->drawEffectScale, 1.2f); - } else if (!Math_StepToF(&this->drawEffectSteamScale, 1.2f, 0.030000001f)) { + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.6f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 1.2f); + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 1.2f, 0.030000001f)) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } @@ -676,7 +671,8 @@ void EnBigokuta_Draw(Actor* thisx, GlobalContext* globalCtx) { this->skelAnime.dListCount, NULL, EnBigokuta_PostLimbDraw, &this->actor, &gfx[2]); } - func_800BE680(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawEffectScale, - this->drawEffectSteamScale, this->drawEffectAlpha, this->drawEffect); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, + this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, this->drawDmgEffType); + CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.h b/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.h index ac0cb01581..0f07c4d7f1 100644 --- a/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.h +++ b/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.h @@ -37,15 +37,15 @@ typedef struct EnBigokuta { /* 0x0144 */ EnBigokutaUnkFunc unkFunc; // possibly something to do with photographing /* 0x0148 */ SkelAnime skelAnime; /* 0x018C */ EnBigokutaActionFunc actionFunc; - /* 0x0190 */ u8 drawEffect; + /* 0x0190 */ u8 drawDmgEffType; /* 0x0192 */ s16 timer; /* 0x0194 */ s16 camId; /* 0x0196 */ s16 cutscene; /* 0x0198 */ Vec3s jointTable[BIGOKUTA_LIMB_MAX]; /* 0x0210 */ Vec3s morphTable[BIGOKUTA_LIMB_MAX]; - /* 0x0288 */ f32 drawEffectAlpha; - /* 0x028C */ f32 drawEffectScale; - /* 0x0290 */ f32 drawEffectSteamScale; // only affects DRAWEFFECT_ICE + /* 0x0288 */ f32 drawDmgEffAlpha; + /* 0x028C */ f32 drawDmgEffScale; + /* 0x0290 */ f32 drawDmgEffFrozenSteamScale; // only affects DRAWEFFECT_ICE /* 0x0294 */ Vec3f playerPos; /* 0x02A0 */ Vec3f playerHoldPos; /* 0x02AC */ Vec3f camAt; diff --git a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c index 6e2ca41863..09ed84312a 100644 --- a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c +++ b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c @@ -775,7 +775,6 @@ void EnBigpo_AdjustPoAlpha(EnBigpo* this, s32 alphaDiff) { this->actor.scale.x = newXYScale; this->actor.scale.z = newXYScale; this->actor.scale.y = (0.007f - (0.007f * lowerAlpha)) + 0.007f; - lowerAlpha = lowerAlpha; } else { Actor_SetScale(&this->actor, lowerAlpha * 0.007f); this->actor.world.pos.y = this->savedHeight + (lowerAlpha * 15.0f); @@ -1014,7 +1013,6 @@ void EnBigpo_RevealedFireIdle(EnBigpo* this, GlobalContext* globalCtx) { if (this->idleTimer == 0) { //! @bug: unreachable code this->actor.params = ENBIGPO_UNK5; - return; } } else { if (Math_StepToF(&this->actor.scale.x, 0.0f, 0.001f)) { @@ -1089,7 +1087,7 @@ void EnBigpo_UpdateColor(EnBigpo* this) { // this might be a triple ternary but it matches and is easier to read spread out bplus5 = this->mainColor.b + 5; - if (this->mainColor.b >= 211) { + if (this->mainColor.b > 210) { bminus5 = this->mainColor.b - 5; if (bminus5 < 210) { this->mainColor.b = 210; @@ -1097,7 +1095,7 @@ void EnBigpo_UpdateColor(EnBigpo* this) { this->mainColor.b = bminus5; } } else { - if (bplus5 >= 211) { + if (bplus5 > 210) { this->mainColor.b = 210; } else { this->mainColor.b = bplus5; @@ -1136,8 +1134,8 @@ s32 EnBigpo_ApplyDamage(EnBigpo* this, GlobalContext* globalCtx) { // light arrows if (this->actor.colChkInfo.damageEffect == 4) { - this->unk21C = 4.0f; - this->unk220 = 1.0f; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 1.0f; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->collider.info.bumper.hitPos.x, this->collider.info.bumper.hitPos.y, this->collider.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); @@ -1153,7 +1151,7 @@ void EnBigpo_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; ColliderCylinder* thisCollider; - if CHECK_FLAG_ALL (this->actor.flags, ACTOR_FLAG_2000) { + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_2000)) { this->hoverHeightCycleTimer = 0; this->savedHeight = this->actor.world.pos.y; } @@ -1201,15 +1199,15 @@ void EnBigpo_Update(Actor* thisx, GlobalContext* globalCtx) { CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &thisCollider->base); } - if (this->unk21C > 0.0f) { - Math_StepToF(&this->unk21C, 0.0f, 0.05f); + if (this->drawDmgEffAlpha > 0.0f) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); if (this->mainColor.a != 255) { // NOT fully visible if (this->mainColor.a * (1.0f / 255.0f) < this->mainColor.a) { - this->unk21C = this->mainColor.a * (1.0f / 255.0f); + this->drawDmgEffAlpha = this->mainColor.a * (1.0f / 255.0f); } } - this->unk220 = ((this->unk21C + 1.0f) * 0.5f); - this->unk220 = CLAMP_MAX(this->unk220, 1.0f); + this->drawDmgEffScale = ((this->drawDmgEffAlpha + 1.0f) * 0.5f); + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 1.0f); } } @@ -1265,25 +1263,20 @@ void EnBigpo_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, if (limbByte != -1) { if (limbByte < 3) { Matrix_GetStateTranslation(&this->limbPos[limbByte]); - return; - } - if (limbByte == 3) { + } else if (limbByte == 3) { Matrix_GetStateTranslationAndScaledX(3000.0f, &this->limbPos[limbByte]); - return; - } - if (limbByte == 4) { + } else if (limbByte == 4) { Matrix_GetStateTranslationAndScaledY(-2000.0f, &this->limbPos[limbByte]); - return; - } + } else { + v2ptr = &this->limbPos[limbByte + 1]; + v1ptr = D_80B65084; + Matrix_GetStateTranslationAndScaledX(-4000.0f, &this->limbPos[limbByte]); - v2ptr = &this->limbPos[limbByte + 1]; - v1ptr = D_80B65084; - Matrix_GetStateTranslationAndScaledX(-4000.0f, &this->limbPos[limbByte]); - - for (i = limbByte + 1; i < ARRAY_COUNT(this->limbPos); i++) { - Matrix_MultiplyVector3fByState(v1ptr, v2ptr); - v2ptr++; - v1ptr++; + for (i = limbByte + 1; i < ARRAY_COUNT(this->limbPos); i++) { + Matrix_MultiplyVector3fByState(v1ptr, v2ptr); + v2ptr++; + v1ptr++; + } } } CLOSE_DISPS(globalCtx->state.gfxCtx); @@ -1318,8 +1311,9 @@ void EnBigpo_DrawMainBigpo(Actor* thisx, GlobalContext* globalCtx) { } // 71.428566f might be 500/7 context unknown - func_800BE680(globalCtx, &this->actor, this->limbPos, 9, this->actor.scale.x * 71.428566f * this->unk220, 0, - this->unk21C, 0x14); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + this->actor.scale.x * 71.428566f * this->drawDmgEffScale, 0.0f, this->drawDmgEffAlpha, + ACTOR_DRAW_DMGEFF_LIGHT_ORBS); Matrix_SetCurrentState(&this->drawMtxF); EnBigpo_DrawLantern(&this->actor, globalCtx); @@ -1442,6 +1436,7 @@ void EnBigpo_DrawCircleFlames(Actor* thisx, GlobalContext* globalCtx) { for (i = 0; i < ARRAY_COUNT(this->fires); i++) { EnBigpoFireEffect* firePtr = &this->fires[i]; + Lights_PointNoGlowSetInfo(&this->fires[i].info, this->fires[i].pos.x, this->fires[i].pos.y, this->fires[i].pos.z, 170, 255, 255, fireRadius); mtfxPtr->wx = firePtr->pos.x; diff --git a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.h b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.h index 9ae87f9f39..c5d0bbe4cb 100644 --- a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.h +++ b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.h @@ -40,9 +40,8 @@ typedef struct EnBigpo { /* 0x212 */ s16 hoverHeightCycleTimer; // sin wave up and down bobbing /* 0x214 */ f32 fireRadius; // distance from center during conjunction cutscene /* 0x218 */ f32 savedHeight; // actual height while flying moves as part of bobbing - // both unk21C and unk220 are passed to func_800BE680, probably need that to know what they are - /* 0x21C */ f32 unk21C; // tied to color alpha, decremented to zero - /* 0x220 */ f32 unk220; // created from unk21C + /* 0x21C */ f32 drawDmgEffAlpha; + /* 0x220 */ f32 drawDmgEffScale; /* 0x224 */ Vec3f limbPos[9]; /* 0x290 */ Color_RGBA8 mainColor; /* 0x294 */ Color_RGBA8 lanternColor; diff --git a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c index f305684ed2..5428e701a5 100644 --- a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c +++ b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c @@ -309,7 +309,7 @@ static InitChainEntry sInitChain[] = { }; void EnBigslime_Init(Actor* thisx, GlobalContext* globalCtx2) { - // gSaveContext.weekEventReg[KEY] = VALUE + // gSaveContext.save.weekEventReg[KEY] = VALUE // KEY | VALUE static s32 isFrogReturnedFlags[] = { (32 << 8) | 0x40, // Woodfall Temple Frog Returned @@ -340,7 +340,7 @@ void EnBigslime_Init(Actor* thisx, GlobalContext* globalCtx2) { if (Flags_GetClear(globalCtx, globalCtx->roomCtx.currRoom.num)) { Actor_MarkForDeath(&this->actor); - if (!(gSaveContext.weekEventReg[isFrogReturnedFlags[this->actor.params - 1] >> 8] & + if (!(gSaveContext.save.weekEventReg[isFrogReturnedFlags[this->actor.params - 1] >> 8] & (u8)isFrogReturnedFlags[this->actor.params - 1])) { Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_MINIFROG, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, this->actor.shape.rot.y, 0, @@ -906,22 +906,22 @@ void EnBigslime_GekkoSfxInsideBigslime(EnBigslime* this, u16 sfxId) { } void EnBigslime_GekkoFreeze(EnBigslime* this) { - this->gekkoDrawEffect = GEKKO_DRAW_EFFECT_FROZEN; + this->gekkoDrawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; this->gekkoCollider.base.colType = COLTYPE_HIT3; this->gekkoCollider.info.elemType = ELEMTYPE_UNK0; this->stunTimer = 2; - this->unk_38C = 0.75f; - this->unk_390 = 1.125f; - this->unk_388 = 1.0f; + this->gekkoDrawDmgEffScale = 0.75f; + this->gekkoDrawDmgEffFrozenSteamScale = 1.125f; + this->gekkoDrawDmgEffAlpha = 1.0f; this->actor.flags &= ~ACTOR_FLAG_200; } void EnBigslime_GekkoThaw(EnBigslime* this, GlobalContext* globalCtx) { - if (this->gekkoDrawEffect == GEKKO_DRAW_EFFECT_FROZEN) { - this->gekkoDrawEffect = GEKKO_DRAW_EFFECT_THAW; + if (this->gekkoDrawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->gekkoDrawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->gekkoCollider.base.colType = COLTYPE_HIT6; this->gekkoCollider.info.elemType = ELEMTYPE_UNK1; - this->unk_388 = 0.0f; + this->gekkoDrawDmgEffAlpha = 0.0f; Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), 2, 0.3f, 0.2f); this->actor.flags |= ACTOR_FLAG_200; } @@ -1614,7 +1614,7 @@ void EnBigslime_AttackPlayerInBigslime(EnBigslime* this, GlobalContext* globalCt if (this->numGekkoMeleeAttacks == 0) { this->numGekkoPosGrabPlayer--; - if ((gSaveContext.health < 5) || (this->numGekkoPosGrabPlayer == 0)) { + if ((gSaveContext.save.playerData.health < 5) || (this->numGekkoPosGrabPlayer == 0)) { this->numGekkoPosGrabPlayer = 0; this->gekkoRot.y = this->actor.world.rot.y; this->gekkoPosOffset.x = Math_SinS(this->gekkoRot.y) * -50.0f; @@ -2176,7 +2176,7 @@ void EnBigslime_SetupDamageGekko(EnBigslime* this, s32 isNotFrozen) { } EnBigslime_GekkoSfxOutsideBigslime(this, NA_SE_EN_FROG_DAMAGE); - if CHECK_FLAG_ALL (this->actor.flags, ACTOR_FLAG_2000) { + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_2000)) { this->actor.flags &= ~ACTOR_FLAG_2000; } @@ -2211,7 +2211,7 @@ void EnBigslime_SetupStunGekko(EnBigslime* this) { void EnBigslime_StunGekko(EnBigslime* this, GlobalContext* globalCtx) { this->stunTimer--; if (this->stunTimer == 0) { - if (this->gekkoDrawEffect == GEKKO_DRAW_EFFECT_FROZEN) { + if (this->gekkoDrawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { EnBigslime_GekkoThaw(this, globalCtx); EnBigslime_SetupDamageGekko(this, false); } else { @@ -2615,7 +2615,7 @@ void EnBigslime_ApplyDamageEffectBigslime(EnBigslime* this, GlobalContext* globa void EnBigslime_ApplyDamageEffectGekko(EnBigslime* this, GlobalContext* globalCtx) { if (this->gekkoCollider.base.acFlags & AC_HIT) { this->gekkoCollider.base.acFlags &= ~AC_HIT; - if ((this->gekkoDrawEffect != GEKKO_DRAW_EFFECT_FROZEN) || + if ((this->gekkoDrawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || !(this->gekkoCollider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { EnBigslime_EndThrowMinislime(this); if (this->actor.colChkInfo.damageEffect != BIGSLIME_DMGEFF_HOOKSHOT) { @@ -2627,12 +2627,12 @@ void EnBigslime_ApplyDamageEffectGekko(EnBigslime* this, GlobalContext* globalCt EnBigslime_GekkoThaw(this, globalCtx); if ((this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_FIRE) || (this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_LIGHT)) { - this->unk_388 = 4.0f; - this->unk_38C = 0.75f; + this->gekkoDrawDmgEffAlpha = 4.0f; + this->gekkoDrawDmgEffScale = 0.75f; if (this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_FIRE) { - this->gekkoDrawEffect = GEKKO_DRAW_EFFECT_THAW; + this->gekkoDrawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; } else { - this->gekkoDrawEffect = GEKKO_DRAW_EFFECT_LIGHT_ORBS; + this->gekkoDrawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->gekkoCollider.info.bumper.hitPos.x, this->gekkoCollider.info.bumper.hitPos.y, @@ -2645,9 +2645,9 @@ void EnBigslime_ApplyDamageEffectGekko(EnBigslime* this, GlobalContext* globalCt } else if (this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_ELECTRIC_STUN) { this->stunTimer = 40; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); - this->gekkoDrawEffect = GEKKO_DRAW_EFFECT_ELECTRIC_STUN; - this->unk_38C = 0.75f; - this->unk_388 = 2.0f; + this->gekkoDrawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; + this->gekkoDrawDmgEffScale = 0.75f; + this->gekkoDrawDmgEffAlpha = 2.0f; EnBigslime_SetupStunGekko(this); } else if (this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_STUN || this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_DEKU_STUN) { @@ -2662,12 +2662,12 @@ void EnBigslime_ApplyDamageEffectGekko(EnBigslime* this, GlobalContext* globalCt EnBigslime_GekkoThaw(this, globalCtx); if ((this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_FIRE) || (this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_LIGHT)) { - this->unk_388 = 3.0f; - this->unk_38C = 0.75f; + this->gekkoDrawDmgEffAlpha = 3.0f; + this->gekkoDrawDmgEffScale = 0.75f; if (this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_FIRE) { - this->gekkoDrawEffect = GEKKO_DRAW_EFFECT_THAW; + this->gekkoDrawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; } else { - this->gekkoDrawEffect = GEKKO_DRAW_EFFECT_LIGHT_ORBS; + this->gekkoDrawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->gekkoCollider.info.bumper.hitPos.x, this->gekkoCollider.info.bumper.hitPos.y, @@ -2755,12 +2755,13 @@ void EnBigslime_UpdateEffects(EnBigslime* this) { } // update actor damage draw effects - if (this->unk_388 > 0.0f) { - if ((this->gekkoDrawEffect != GEKKO_DRAW_EFFECT_FROZEN) && (this->actionFunc != EnBigslime_PlayCutscene)) { - Math_StepToF(&this->unk_388, 0.0f, 0.05f); - this->unk_38C = 0.375f * (this->unk_388 + 1.0f); - this->unk_38C = CLAMP_MAX(this->unk_38C, 0.75f); - } else if (!Math_StepToF(&this->unk_390, 0.75f, 0.01875f)) { + if (this->gekkoDrawDmgEffAlpha > 0.0f) { + if ((this->gekkoDrawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) && + (this->actionFunc != EnBigslime_PlayCutscene)) { + Math_StepToF(&this->gekkoDrawDmgEffAlpha, 0.0f, 0.05f); + this->gekkoDrawDmgEffScale = 0.375f * (this->gekkoDrawDmgEffAlpha + 1.0f); + this->gekkoDrawDmgEffScale = CLAMP_MAX(this->gekkoDrawDmgEffScale, 0.75f); + } else if (!Math_StepToF(&this->gekkoDrawDmgEffFrozenSteamScale, 0.75f, 0.01875f)) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } @@ -3074,9 +3075,9 @@ void EnBigslime_DrawGekko(Actor* thisx, GlobalContext* globalCtx) { } else if ((this->actionFunc == EnBigslime_CutsceneDefeat) || (this->actionFunc == EnBigslime_GekkoDespawn)) { func_800AE434(globalCtx, &gekkoDamageColor, 20, 20); } else if (this->actionFunc == EnBigslime_StunGekko) { - if (this->gekkoDrawEffect == GEKKO_DRAW_EFFECT_FROZEN) { + if (this->gekkoDrawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { func_800AE434(globalCtx, &gekkoDamageColor, this->stunTimer, 80); - } else if (this->gekkoDrawEffect == GEKKO_DRAW_EFFECT_ELECTRIC_STUN) { + } else if (this->gekkoDrawDmgEffType == ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL) { func_800AE434(globalCtx, &gekkoStunColor, this->stunTimer, 40); } else { func_800AE434(globalCtx, &gekkoStunColor, this->stunTimer, 40); @@ -3109,10 +3110,10 @@ void EnBigslime_DrawGekko(Actor* thisx, GlobalContext* globalCtx) { EnBigslime_DrawShatteringEffects(this, globalCtx); - // Draw actor damage effects - func_800BE680(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), - this->gekkoScale * (999.99991f / 7.0f) * this->unk_38C, this->unk_390, this->unk_388, - this->gekkoDrawEffect); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + this->gekkoScale * (999.99991f / 7.0f) * this->gekkoDrawDmgEffScale, + this->gekkoDrawDmgEffFrozenSteamScale, this->gekkoDrawDmgEffAlpha, + this->gekkoDrawDmgEffType); } void EnBigslime_DrawShatteringEffects(EnBigslime* this, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.h b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.h index 3f57f1666e..f59a934bc5 100644 --- a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.h +++ b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.h @@ -64,7 +64,7 @@ typedef struct EnBigslime { u8 numGekkoMeleeAttacks; // The Gekko will melee-attack link at 1-3 times at each position while engulfed in bigslime }; /* 0x02B4 */ u8 shockwaveAlpha; - /* 0x02B5 */ u8 gekkoDrawEffect; + /* 0x02B5 */ u8 gekkoDrawDmgEffType; /* 0x02B6 */ s16 gekkoYaw; /* 0x02B8 */ s16 cutscene; /* 0x02BA */ union { // multi-use timer @@ -107,9 +107,9 @@ typedef struct EnBigslime { Vec3f subCamDistToFrog; // Used to zoom into frogs as Gekko despawns/Frog spawns }; /* 0x02F8 */ Vec3f limbPos[12]; - /* 0x0388 */ f32 unk_388; // used as arg to func_800BE680 - /* 0x038C */ f32 unk_38C; // used as arg to func_800BE680 - /* 0x0390 */ f32 unk_390; // used as arg to func_800BE680 + /* 0x0388 */ f32 gekkoDrawDmgEffAlpha; + /* 0x038C */ f32 gekkoDrawDmgEffScale; + /* 0x0390 */ f32 gekkoDrawDmgEffFrozenSteamScale; /* 0x0394 */ f32 gekkoScale; /* 0x0398 */ f32 vtxSurfacePerturbation[BIGSLIME_NUM_VTX]; /* 0x0620 */ f32 vtxScaleX; diff --git a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c index 8faf1cdba6..8185154465 100644 --- a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c +++ b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c @@ -122,44 +122,44 @@ void func_809CD028(EnBji01* this, GlobalContext* globalCtx) { switch (this->actor.params) { case ENBJI01_PARAMS_DEFAULT: case ENBJI01_PARAMS_FINISHED_CONVERSATION: - switch (gSaveContext.playerForm) { + switch (gSaveContext.save.playerForm) { case PLAYER_FORM_DEKU: - if (gSaveContext.weekEventReg[17] & 0x10) { - if (gSaveContext.weekEventReg[74] & 0x80) { + if (gSaveContext.save.weekEventReg[17] & 0x10) { + if (gSaveContext.save.weekEventReg[74] & 0x80) { this->textId = 0x5F4; } else { this->textId = 0x5E2; } } else { this->textId = 0x5EC; - gSaveContext.weekEventReg[17] |= 0x10; + gSaveContext.save.weekEventReg[17] |= 0x10; } break; case PLAYER_FORM_HUMAN: if (Player_GetMask(globalCtx) == PLAYER_MASK_KAFEIS_MASK) { this->textId = 0x236A; - } else if (gSaveContext.weekEventReg[74] & 0x10) { + } else if (gSaveContext.save.weekEventReg[74] & 0x10) { this->textId = 0x5F6; } else { this->textId = 0x5F5; - gSaveContext.weekEventReg[74] |= 0x10; + gSaveContext.save.weekEventReg[74] |= 0x10; } break; case PLAYER_FORM_GORON: case PLAYER_FORM_ZORA: - if (gSaveContext.weekEventReg[75] & 8) { + if (gSaveContext.save.weekEventReg[75] & 8) { this->textId = 0x5E4; } else { this->textId = 0x5DC; - gSaveContext.weekEventReg[75] |= 8; + gSaveContext.save.weekEventReg[75] |= 8; } break; } break; case ENBJI01_PARAMS_LOOKED_THROUGH_TELESCOPE: - switch (gSaveContext.playerForm) { + switch (gSaveContext.save.playerForm) { case PLAYER_FORM_DEKU: - if (gSaveContext.weekEventReg[74] & 0x80) { + if (gSaveContext.save.weekEventReg[74] & 0x80) { this->textId = 0x5F2; } else { this->textId = 0x5F1; @@ -180,9 +180,9 @@ void func_809CD028(EnBji01* this, GlobalContext* globalCtx) { this->textId = 0x5EA; break; case 3: - tempDay = gSaveContext.day; + tempDay = gSaveContext.save.day; tempTimeBeforeMoonCrash = - ((-(tempDay % 5 << 0x10) - ((u16)(gSaveContext.time - 0x4000))) + 0x40000); + ((-(tempDay % 5 << 0x10) - ((u16)(gSaveContext.save.time - 0x4000))) + 0x40000); if (tempTimeBeforeMoonCrash < CLOCK_TIME_F(1, 0)) { /* 1 hr */ this->textId = 0x5E8; } else { @@ -207,7 +207,7 @@ void EnBji01_DialogueHandler(EnBji01* this, GlobalContext* globalCtx) { } break; case 4: - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx) != 0) { this->actor.flags &= ~ACTOR_FLAG_10000; this->actor.params = ENBJI01_PARAMS_FINISHED_CONVERSATION; switch (globalCtx->msgCtx.choiceIndex) { @@ -218,7 +218,7 @@ void EnBji01_DialogueHandler(EnBji01* this, GlobalContext* globalCtx) { break; case 1: func_8019F230(); - switch (gSaveContext.playerForm) { + switch (gSaveContext.save.playerForm) { case PLAYER_FORM_DEKU: func_80151938(globalCtx, 0x5F0); break; @@ -235,9 +235,9 @@ void EnBji01_DialogueHandler(EnBji01* this, GlobalContext* globalCtx) { } break; case 5: - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx) != 0) { this->actor.flags &= ~ACTOR_FLAG_10000; - switch (globalCtx->msgCtx.unk11F04) { + switch (globalCtx->msgCtx.currentTextId) { case 0x5DE: SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_809CDC7C, 3, &this->animationIndex); func_80151938(globalCtx, 0x5DF); @@ -259,7 +259,7 @@ void EnBji01_DialogueHandler(EnBji01* this, GlobalContext* globalCtx) { case 0x5EE: case 0x5F2: case 0x5F5: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x5F0: case 0x5F6: @@ -298,7 +298,7 @@ void func_809CD634(EnBji01* this, GlobalContext* globalCtx) { func_801A5BD0(0x6F); Audio_QueueSeqCmd(0xE0000101); globalCtx->nextEntranceIndex = 0x54A0; /* Termina Field from telescope */ - gSaveContext.respawn[0].entranceIndex = globalCtx->nextEntranceIndex; + gSaveContext.respawn[RESTART_MODE_DOWN].entranceIndex = globalCtx->nextEntranceIndex; func_80169EFC(&globalCtx->state); /* Load new entrance? */ gSaveContext.respawnFlag = -2; this->actionFunc = EnBji01_DoNothing; @@ -344,7 +344,7 @@ void EnBji01_Init(Actor* thisx, GlobalContext* globalCtx) { SubS_FillCutscenesList(&this->actor, this->cutscenes, ARRAY_COUNT(this->cutscenes)); this->moonsTear = (ObjMoonStone*)SubS_FindActor(globalCtx, NULL, ACTORCAT_PROP, ACTOR_OBJ_MOON_STONE); - switch (gSaveContext.entranceIndex) { + switch (gSaveContext.save.entranceIndex) { case 0x4C00: /* Observatory from ECT */ case 0x4C10: /* Observatory from Termina Field door */ this->actor.params = ENBJI01_PARAMS_DEFAULT; diff --git a/src/overlays/actors/ovl_En_Bom/z_en_bom.c b/src/overlays/actors/ovl_En_Bom/z_en_bom.c index 57a88bcef5..eeae2b8deb 100644 --- a/src/overlays/actors/ovl_En_Bom/z_en_bom.c +++ b/src/overlays/actors/ovl_En_Bom/z_en_bom.c @@ -455,7 +455,7 @@ void EnBom_Update(Actor* thisx, GlobalContext* globalCtx) { } else { thisx->gravity = -1.2f; if (this->timer != 0) { - if (!this->isPowderKeg || (func_808715B8 == this->actionFunc) || !func_801690CC(globalCtx)) { + if (!this->isPowderKeg || (func_808715B8 == this->actionFunc) || !Play_InCsMode(globalCtx)) { this->timer--; } } diff --git a/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c b/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c index 397f230688..321468424f 100644 --- a/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c +++ b/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c @@ -50,7 +50,7 @@ const ActorInit En_Bom_Bowl_Man_InitVars = { }; static AnimationHeader* sAnimations[] = { - &object_cs_Anim_0064B8, &object_cs_Anim_00FAF4, &object_cs_Anim_0057C8, &object_cs_Anim_0053F4, + &gBomberIdleAnim, &object_cs_Anim_00FAF4, &object_cs_Anim_0057C8, &object_cs_Anim_0053F4, &object_cs_Anim_002044, &object_cs_Anim_01007C, &object_cs_Anim_00349C, &object_cs_Anim_004960, &object_cs_Anim_005128, &object_cs_Anim_004C1C, &object_cs_Anim_001A1C, &object_cs_Anim_003EE4, &object_cs_Anim_00478C, &object_cs_Anim_00433C, &object_cs_Anim_0060E8, &object_cs_Anim_001708, @@ -76,7 +76,7 @@ void EnBomBowlMan_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.colChkInfo.mass = MASS_IMMOVABLE; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 19.0f); this->actor.gravity = -3.0f; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_cs_Skel_00F82C, &object_cs_Anim_0064B8, this->jointTable, + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_cs_Skel_00F82C, &gBomberIdleAnim, this->jointTable, this->morphTable, 21); this->unk_2F6 = ENBOMBOWLMAN_GET_F0(&this->actor); this->unk_2F4 = ENBOMBOWLMAN_GET_F(&this->actor); @@ -94,10 +94,10 @@ void EnBomBowlMan_Init(Actor* thisx, GlobalContext* globalCtx) { } this->unk_29A = ENBOMBOWLMAN_GET_FF00(&this->actor); - this->path = func_8013D648(globalCtx, this->unk_29A, 0x3F); + this->path = SubS_GetPathByIndex(globalCtx, this->unk_29A, 0x3F); this->unk_2C8 = 80.0f; - if ((gSaveContext.entranceIndex == 0xD220) && (gSaveContext.weekEventReg[73] & 0x80) && + if ((gSaveContext.save.entranceIndex == 0xD220) && (gSaveContext.save.weekEventReg[73] & 0x80) && !CHECK_QUEST_ITEM(ITEM_BOTTLE)) { this->unk_2D6 = this->actor.cutscene; if (this->unk_2D6 == 0) { @@ -157,7 +157,7 @@ void func_809C4B50(EnBomBowlMan* this) { void func_809C4B6C(EnBomBowlMan* this) { if ((this->unk_29A != ENBOMBOWLMAN_FF00_MINUS1) && (this->path != NULL)) { - if (!func_8013D68C(this->path, this->unk_298, &this->unk_2A0)) { + if (!SubS_CopyPointFromPath(this->path, this->unk_298, &this->unk_2A0)) { Actor_MarkForDeath(&this->actor); } } @@ -173,9 +173,9 @@ void func_809C4BC4(EnBomBowlMan* this, GlobalContext* globalCtx) { func_809C4B50(this); func_809C493C(this, 0, 1.0f); - for (i = 0; i < ARRAY_COUNT(gSaveContext.bomberCode); i++) { + for (i = 0; i < ARRAY_COUNT(gSaveContext.save.bomberCode); i++) { Math_Vec3f_Copy(&sp7C, &this->actor.home.pos); - code = gSaveContext.bomberCode[i]; + code = gSaveContext.save.bomberCode[i]; if (code == 1) { Math_Vec3f_Copy(&this->actor.world.pos, &D_809C61A0[i]); this->unk_2D8[code] = this; @@ -203,8 +203,8 @@ void func_809C4BC4(EnBomBowlMan* this, GlobalContext* globalCtx) { func_809C493C(this, 3, 1.0f); this->unk_2D4 = this->actor.yawTowardsPlayer; this->unk_290 = this->actor.yawTowardsPlayer; - gSaveContext.weekEventReg[73] &= (u8)~0x10; - gSaveContext.weekEventReg[85] &= (u8)~2; + gSaveContext.save.weekEventReg[73] &= (u8)~0x10; + gSaveContext.save.weekEventReg[85] &= (u8)~2; this->unk_29C = 0; this->actionFunc = func_809C4DA4; } @@ -238,7 +238,7 @@ void func_809C4DA4(EnBomBowlMan* this, GlobalContext* globalCtx) { } } - if ((this->unk_2BC == 0) && (Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((this->unk_2BC == 0) && (Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { Player* player = GET_PLAYER(globalCtx); s32 pad; s32 sp28 = false; @@ -338,13 +338,13 @@ void func_809C51B4(EnBomBowlMan* this, GlobalContext* globalCtx) { globalCtx->sceneLoadFlag = 0x14; globalCtx->unk_1887F = 0x56; gSaveContext.nextTransition = 3; - gSaveContext.weekEventReg[75] &= (u8)~0x40; + gSaveContext.save.weekEventReg[75] &= (u8)~0x40; if (player->transformation == PLAYER_FORM_HUMAN) { - gSaveContext.weekEventReg[84] |= 0x80; - gSaveContext.weekEventReg[77] &= (u8)~2; + gSaveContext.save.weekEventReg[84] |= 0x80; + gSaveContext.save.weekEventReg[77] &= (u8)~2; } else { - gSaveContext.weekEventReg[73] |= 0x20; - gSaveContext.weekEventReg[85] &= (u8)~1; + gSaveContext.save.weekEventReg[73] |= 0x20; + gSaveContext.save.weekEventReg[85] &= (u8)~1; } } } @@ -402,7 +402,7 @@ void func_809C5408(EnBomBowlMan* this, GlobalContext* globalCtx) { void func_809C5524(EnBomBowlMan* this, GlobalContext* globalCtx) { this->actor.textId = 0x730; - if (!(gSaveContext.weekEventReg[85] & 2)) { + if (!(gSaveContext.save.weekEventReg[85] & 2)) { this->actor.textId = 0x72F; } func_809C493C(this, 3, 1.0f); @@ -411,7 +411,7 @@ void func_809C5524(EnBomBowlMan* this, GlobalContext* globalCtx) { } void func_809C5598(EnBomBowlMan* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); if ((this->actor.textId == 0x72F) || (this->actor.textId == 0x730)) { this->actor.textId = 0x731; @@ -484,8 +484,8 @@ void func_809C5738(EnBomBowlMan* this, GlobalContext* globalCtx) { (this->path != NULL)) { this->unk_298++; if (this->unk_298 >= this->path->count) { - gSaveContext.weekEventReg[84] |= 0x80; - gSaveContext.weekEventReg[83] &= (u8)~4; + gSaveContext.save.weekEventReg[84] |= 0x80; + gSaveContext.save.weekEventReg[83] &= (u8)~4; ActorCutscene_Stop(this->unk_2D6); Actor_MarkForDeath(&this->actor); } else { diff --git a/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.h b/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.h index 21e25b19de..6246a67564 100644 --- a/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.h +++ b/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.h @@ -43,7 +43,7 @@ typedef struct EnBomBowlMan { /* 0x02C2 */ s16 unk_2C2; /* 0x02C4 */ f32 unk_2C4; /* 0x02C8 */ f32 unk_2C8; - /* 0x02CC */ UNK_TYPE1 unk2CC[4]; + /* 0x02CC */ s16 unk_2CC[2]; /* 0x02D0 */ s16 unk_2D0; /* 0x02D2 */ s16 unk_2D2; /* 0x02D4 */ s16 unk_2D4; diff --git a/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c b/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c index 47c25941d2..fc63795dea 100644 --- a/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c +++ b/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c @@ -5,21 +5,26 @@ */ #include "z_en_bom_chu.h" +#include "overlays/actors/ovl_En_Bom/z_en_bom.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_10) #define THIS ((EnBomChu*)thisx) +#define BOMBCHU_SCALE 0.01f + void EnBomChu_Init(Actor* thisx, GlobalContext* globalCtx); void EnBomChu_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnBomChu_Update(Actor* thisx, GlobalContext* globalCtx); void EnBomChu_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_808F7868(EnBomChu* this, GlobalContext* globalCtx); -void func_808F7A84(EnBomChu* this, GlobalContext* globalCtx); -void func_808F7FA0(EnBomChu* this, GlobalContext* globalCtx); +void EnBomChu_WaitForRelease(EnBomChu* this, GlobalContext* globalCtx); +void EnBomChu_SetupMove(EnBomChu* this); +void EnBomChu_Move(EnBomChu* this, GlobalContext* globalCtx); +void EnBomChu_Explode(EnBomChu* this, GlobalContext* globalCtx); +void EnBomChu_WaitForDeath(EnBomChu* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Bom_Chu_InitVars = { ACTOR_EN_BOM_CHU, ACTORCAT_EXPLOSIVES, @@ -32,50 +37,536 @@ const ActorInit En_Bom_Chu_InitVars = { (ActorFunc)EnBomChu_Draw, }; -// static ColliderSphereInit sSphereInit = { -static ColliderSphereInit D_808F88E0 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_1 | OC1_TYPE_2, OC2_TYPE_2, COLSHAPE_SPHERE, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderSphereInit sSphereInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_1 | OC1_TYPE_2, + OC2_TYPE_2, + COLSHAPE_SPHERE, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 1, { { 0, 0, 0 }, 13 }, 100 }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808F890C[] = { +static InitChainEntry sInitChain[] = { ICHAIN_U8(targetMode, 2, ICHAIN_CONTINUE), - ICHAIN_VEC3F_DIV1000(scale, 10, ICHAIN_STOP), + ICHAIN_VEC3F_DIV1000(scale, 1000 * BOMBCHU_SCALE, ICHAIN_STOP), }; -#endif +static EffectBlureInit2 sBlureInit = { + 0, 0, 0, { 250, 0, 0, 250 }, { 200, 0, 0, 130 }, { 150, 0, 0, 100 }, { 100, 0, 0, 50 }, 16, + 0, 0, 0, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, +}; -extern ColliderSphereInit D_808F88E0; -extern InitChainEntry D_808F890C[]; +void EnBomChu_Init(Actor* thisx, GlobalContext* globalCtx) { + EnBomChu* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Chu/EnBomChu_Init.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + Collider_InitAndSetSphere(globalCtx, &this->collider, &this->actor, &sSphereInit); + this->collider.dim.worldSphere.radius = sSphereInit.dim.modelSphere.radius; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Chu/EnBomChu_Destroy.s") + Effect_Add(globalCtx, &this->blure1Index, EFFECT_BLURE2, 0, 0, &sBlureInit); + Effect_Add(globalCtx, &this->blure2Index, EFFECT_BLURE2, 0, 0, &sBlureInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Chu/func_808F75D0.s") + this->timer = 120; + this->actor.room = -1; + this->shouldTimerCountDown = true; + this->unk_174 = 0.0f; + this->actionFunc = EnBomChu_WaitForRelease; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Chu/func_808F77E4.s") +void EnBomChu_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnBomChu* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Chu/func_808F7868.s") + Effect_Destroy(globalCtx, this->blure1Index); + Effect_Destroy(globalCtx, this->blure2Index); + Collider_DestroySphere(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Chu/func_808F7944.s") +/** + * Returns true if floorPoly is valid for the Bombchu to move on, false otherwise. + */ +s32 EnBomChu_UpdateFloorPoly(EnBomChu* this, CollisionPoly* floorPoly, GlobalContext* globalCtx) { + Vec3f normal; + Vec3f vec; + f32 angle; + f32 magnitude; + f32 normDotUp; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Chu/func_808F79D4.s") + this->actor.floorPoly = floorPoly; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Chu/func_808F7A84.s") + // This NULL check means if the player releases a Bombchu with no collision + // below them, the game will not crash, unlike OoT. + if (floorPoly != NULL) { + normal.x = COLPOLY_GET_NORMAL(floorPoly->normal.x); + normal.y = COLPOLY_GET_NORMAL(floorPoly->normal.y); + normal.z = COLPOLY_GET_NORMAL(floorPoly->normal.z); + } else { + EnBomChu_Explode(this, globalCtx); + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Chu/func_808F7E74.s") + normDotUp = DOTXYZ(normal, this->axisUp); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Chu/func_808F7FA0.s") + if (fabsf(normDotUp) >= 0.999f) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Chu/func_808F7FD0.s") + angle = func_80086C48(normDotUp); + if (angle < 0.001f) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Chu/func_808F8080.s") + Math3D_CrossProduct(&this->axisUp, &normal, &vec); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Chu/func_808F818C.s") + magnitude = Math3D_Vec3fMagnitude(&vec); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Chu/EnBomChu_Update.s") + if (magnitude < 0.001f) { + EnBomChu_Explode(this, globalCtx); + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Chu/EnBomChu_Draw.s") + Math_Vec3f_Scale(&vec, 1.0f / magnitude); + Matrix_InsertRotationAroundUnitVector_f(angle, &vec, MTXMODE_NEW); + Matrix_MultiplyVector3fByState(&this->axisLeft, &vec); + Math_Vec3f_Copy(&this->axisLeft, &vec); + Math3D_CrossProduct(&this->axisLeft, &normal, &this->axisForwards); + + magnitude = Math3D_Vec3fMagnitude(&this->axisForwards); + if (magnitude < 0.001f) { + EnBomChu_Explode(this, globalCtx); + return false; + } + + Math_Vec3f_Scale(&this->axisForwards, 1.0f / magnitude); + Math_Vec3f_Copy(&this->axisUp, &normal); + return true; +} + +void EnBomChu_UpdateRotation(EnBomChu* this) { + MtxF mf; + + mf.xx = this->axisLeft.x; + mf.xy = this->axisLeft.y; + mf.xz = this->axisLeft.z; + + mf.yx = this->axisUp.x; + mf.yy = this->axisUp.y; + mf.yz = this->axisUp.z; + + mf.zx = this->axisForwards.x; + mf.zy = this->axisForwards.y; + mf.zz = this->axisForwards.z; + + func_8018219C(&mf, &this->actor.world.rot, 0); + this->actor.world.rot.x = -this->actor.world.rot.x; +} + +void EnBomChu_WaitForRelease(EnBomChu* this, GlobalContext* globalCtx) { + Player* player; + + if (this->timer == 0) { + EnBomChu_Explode(this, globalCtx); + } else if (Actor_HasNoParent(&this->actor, globalCtx)) { + player = GET_PLAYER(globalCtx); + Math_Vec3f_Copy(&this->actor.world.pos, &player->actor.world.pos); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + + this->actor.shape.rot.y = player->actor.shape.rot.y; + this->actor.flags |= ACTOR_FLAG_1; + func_800B8EF4(globalCtx, &this->actor); + + this->isMoving = true; + this->actor.speedXZ = 8.0f; + this->movingSpeed = 8.0f; + EnBomChu_SetupMove(this); + } +} + +s32 EnBomChu_IsOnCollisionPoly(GlobalContext* globalCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, + CollisionPoly** poly, s32* bgId) { + if ((BgCheck_EntityLineTest1(&globalCtx->colCtx, posA, posB, posResult, poly, true, true, true, true, bgId)) && + (!(func_800C9A4C(&globalCtx->colCtx, *poly, *bgId) & 0x30))) { + return true; + } + + return false; +} + +void EnBomChu_SetupMove(EnBomChu* this) { + func_800BE3D0(&this->actor, this->actor.shape.rot.y, &this->actor.shape.rot); + + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_InsertXRotation_s(this->actor.shape.rot.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); + + Matrix_GetStateTranslationAndScaledY(1.0f, &this->axisUp); + Matrix_GetStateTranslationAndScaledZ(1.0f, &this->axisForwards); + Matrix_GetStateTranslationAndScaledX(1.0f, &this->axisLeft); + + this->actor.world.rot.x = -this->actor.shape.rot.x; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actor.world.rot.z = this->actor.shape.rot.z; + this->actionFunc = EnBomChu_Move; +} + +void EnBomChu_Move(EnBomChu* this, GlobalContext* globalCtx) { + CollisionPoly* polySide = NULL; + CollisionPoly* polyUpDown = NULL; + s32 bgIdSide; + s32 bgIdUpDown; + s32 i; + s32 isFloorPolyValid; + f32 lineLength; + Vec3f posA; + Vec3f posB; + Vec3f posSide; + Vec3f posUpDown; + + bgIdUpDown = bgIdSide = BGCHECK_SCENE; + isFloorPolyValid = false; + + this->actor.speedXZ = this->movingSpeed; + lineLength = 2.0f * this->movingSpeed; + + if ((this->timer == 0) || (this->collider.base.acFlags & AC_HIT) || (this->collider.base.ocFlags1 & OC1_HIT)) { + EnBomChu_Explode(this, globalCtx); + return; + } + + posA.x = this->actor.world.pos.x + (this->axisUp.x * 2.0f); + posA.y = this->actor.world.pos.y + (this->axisUp.y * 2.0f); + posA.z = this->actor.world.pos.z + (this->axisUp.z * 2.0f); + + posB.x = this->actor.world.pos.x - (this->axisUp.x * 4.0f); + posB.y = this->actor.world.pos.y - (this->axisUp.y * 4.0f); + posB.z = this->actor.world.pos.z - (this->axisUp.z * 4.0f); + + if (EnBomChu_IsOnCollisionPoly(globalCtx, &posA, &posB, &posUpDown, &polyUpDown, &bgIdUpDown)) { + // forwards + posB.x = (this->axisForwards.x * lineLength) + posA.x; + posB.y = (this->axisForwards.y * lineLength) + posA.y; + posB.z = (this->axisForwards.z * lineLength) + posA.z; + + if (EnBomChu_IsOnCollisionPoly(globalCtx, &posA, &posB, &posSide, &polySide, &bgIdSide)) { + isFloorPolyValid = EnBomChu_UpdateFloorPoly(this, polySide, globalCtx); + Math_Vec3f_Copy(&this->actor.world.pos, &posSide); + this->actor.floorBgId = bgIdSide; + this->actor.speedXZ = 0.0f; + } else { + if (this->actor.floorPoly != polyUpDown) { + isFloorPolyValid = EnBomChu_UpdateFloorPoly(this, polyUpDown, globalCtx); + } + + Math_Vec3f_Copy(&this->actor.world.pos, &posUpDown); + this->actor.floorBgId = bgIdUpDown; + } + } else { + this->actor.speedXZ = 0.0f; + lineLength *= 3.0f; + Math_Vec3f_Copy(&posA, &posB); + + for (i = 0; i < 3; i++) { + if (i == 0) { + // backwards + posB.x = posA.x - (this->axisForwards.x * lineLength); + posB.y = posA.y - (this->axisForwards.y * lineLength); + posB.z = posA.z - (this->axisForwards.z * lineLength); + } else if (i == 1) { + // left + posB.x = posA.x + (this->axisLeft.x * lineLength); + posB.y = posA.y + (this->axisLeft.y * lineLength); + posB.z = posA.z + (this->axisLeft.z * lineLength); + } else { + // right + posB.x = posA.x - (this->axisLeft.x * lineLength); + posB.y = posA.y - (this->axisLeft.y * lineLength); + posB.z = posA.z - (this->axisLeft.z * lineLength); + } + + if (EnBomChu_IsOnCollisionPoly(globalCtx, &posA, &posB, &posSide, &polySide, &bgIdSide)) { + isFloorPolyValid = EnBomChu_UpdateFloorPoly(this, polySide, globalCtx); + Math_Vec3f_Copy(&this->actor.world.pos, &posSide); + this->actor.floorBgId = bgIdSide; + break; + } + } + + if (i == 3) { + // no collision nearby + EnBomChu_Explode(this, globalCtx); + } + } + + if (isFloorPolyValid) { + EnBomChu_UpdateRotation(this); + this->actor.shape.rot.x = -this->actor.world.rot.x; + this->actor.shape.rot.y = this->actor.world.rot.y; + this->actor.shape.rot.z = this->actor.world.rot.z; + } + + if (this->isMoving) { + func_800B8F98(&this->actor, NA_SE_IT_BOMBCHU_MOVE - SFX_FLAG); + } + + if (this->actor.speedXZ != 0.0f) { + this->movingSpeed = this->actor.speedXZ; + } +} + +void EnBomChu_Explode(EnBomChu* this, GlobalContext* globalCtx) { + EnBom* bomb; + s32 i; + + bomb = (EnBom*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0); + + this->shouldTimerCountDown = true; + this->isMoving = false; + + if (bomb != NULL) { + bomb->timer = 0; + } + + this->timer = 1; + this->actor.speedXZ = 0.0f; + + if (this->actor.depthInWater > 0.0f) { + for (i = 0; i < 40; i++) { + EffectSsBubble_Spawn(globalCtx, &this->actor.world.pos, 1.0f, 5.0f, 30.0f, 0.25f); + } + } + + this->actor.draw = NULL; + this->actionFunc = EnBomChu_WaitForDeath; +} + +void EnBomChu_WaitForDeath(EnBomChu* this, GlobalContext* globalCtx) { + if (this->timer == 0) { + Actor_MarkForDeath(&this->actor); + } +} + +/** + * Transform coordinates from actor coordinate space to world space, according to current orientation. + * `offset` is expected to already be at world scale. + */ +void EnBomChu_ActorCoordsToWorld(EnBomChu* this, Vec3f* offset, Vec3f* pos) { + f32 x = offset->x + this->visualJitter; + + pos->x = this->actor.world.pos.x + (this->axisLeft.x * x) + (this->axisUp.x * offset->y) + + (this->axisForwards.x * offset->z); + pos->y = this->actor.world.pos.y + (this->axisLeft.y * x) + (this->axisUp.y * offset->y) + + (this->axisForwards.y * offset->z); + pos->z = this->actor.world.pos.z + (this->axisLeft.z * x) + (this->axisUp.z * offset->y) + + (this->axisForwards.z * offset->z); +} + +void EnBomChu_SpawnRipplesAndSplashes(EnBomChu* this, GlobalContext* globalCtx, f32 y, s32 spawnExtraRipples) { + s32 pad; + Vec3f pos; + + pos.x = this->actor.world.pos.x; + pos.y = y; + pos.z = this->actor.world.pos.z; + + EffectSsGRipple_Spawn(globalCtx, &pos, 70, 500, 0); + + if (spawnExtraRipples) { + EffectSsGRipple_Spawn(globalCtx, &pos, 70, 500, 4); + EffectSsGRipple_Spawn(globalCtx, &pos, 70, 500, 8); + } else { + pos.x -= this->axisForwards.x * 10.0f; + pos.z -= this->axisForwards.z * 10.0f; + } + + pos.y += 5.0f; + EffectSsGSplash_Spawn(globalCtx, &pos, NULL, NULL, 1, 450); +} + +void EnBomChu_HandleNonSceneCollision(EnBomChu* this, GlobalContext* globalCtx) { + Vec3f originalWorldPos; + Vec3f posA; + Vec3f posB; + Vec3f originalAxisUp; + s16 yaw; + f32 sin; + f32 cos; + f32 tempX; + CollisionPoly* poly = NULL; + s32 bgId = BGCHECK_SCENE; + s32 isFloorPolyValid; + + Math_Vec3f_Copy(&originalWorldPos, &this->actor.world.pos); + Math_Vec3f_Copy(&originalAxisUp, &this->axisUp); + yaw = this->actor.shape.rot.y; + BgCheck2_UpdateActorAttachedToMesh(&globalCtx->colCtx, this->actor.floorBgId, &this->actor); + + if (yaw != this->actor.shape.rot.y) { + yaw = this->actor.shape.rot.y - yaw; + + sin = Math_SinS(yaw); + cos = Math_CosS(yaw); + + tempX = this->axisForwards.x; + this->axisForwards.x = (sin * this->axisForwards.z) + (cos * tempX); + this->axisForwards.z = (cos * this->axisForwards.z) - (sin * tempX); + + tempX = this->axisUp.x; + this->axisUp.x = (sin * this->axisUp.z) + (cos * tempX); + this->axisUp.z = (cos * this->axisUp.z) - (sin * tempX); + + tempX = this->axisLeft.x; + this->axisLeft.x = (sin * this->axisLeft.z) + (cos * tempX); + this->axisLeft.z = (cos * this->axisLeft.z) - (sin * tempX); + } + + posA.x = originalWorldPos.x + (2.0f * originalAxisUp.x); + posA.y = originalWorldPos.y + (2.0f * originalAxisUp.y); + posA.z = originalWorldPos.z + (2.0f * originalAxisUp.z); + + posB.x = this->actor.world.pos.x + (2.0f * this->axisUp.x); + posB.y = this->actor.world.pos.y + (2.0f * this->axisUp.y); + posB.z = this->actor.world.pos.z + (2.0f * this->axisUp.z); + + if (EnBomChu_IsOnCollisionPoly(globalCtx, &posA, &posB, &originalWorldPos, &poly, &bgId)) { + isFloorPolyValid = EnBomChu_UpdateFloorPoly(this, poly, globalCtx); + Math_Vec3f_Copy(&this->actor.world.pos, &originalWorldPos); + this->actor.floorBgId = bgId; + this->actor.speedXZ = 0.0f; + + if (isFloorPolyValid) { + EnBomChu_UpdateRotation(this); + this->actor.shape.rot.x = -this->actor.world.rot.x; + this->actor.shape.rot.y = this->actor.world.rot.y; + this->actor.shape.rot.z = this->actor.world.rot.z; + } + } +} + +void EnBomChu_Update(Actor* thisx, GlobalContext* globalCtx) { + static Vec3f sBlureP1Offset = { 0.0f, 7.0f, -6.0f }; + static Vec3f sBlureP2LeftOffset = { 12.0f, 0.0f, -5.0f }; + static Vec3f sBlureP2RightOffset = { -12.0f, 0.0f, -5.0f }; + s32 pad; + EnBomChu* this = THIS; + Vec3f blureP1; + Vec3f blureP2; + WaterBox* waterBox; + f32 waterY; + + if (this->actor.floorBgId != BGCHECK_SCENE) { + EnBomChu_HandleNonSceneCollision(this, globalCtx); + } + + if (this->shouldTimerCountDown) { + this->timer--; + } + + this->actionFunc(this, globalCtx); + + if ((this->actionFunc != EnBomChu_WaitForDeath) && + (SurfaceType_IsWallDamage(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId))) { + EnBomChu_Explode(this, globalCtx); + return; + } + + Actor_MoveWithoutGravity(&this->actor); + + this->collider.dim.worldSphere.center.x = this->actor.world.pos.x; + this->collider.dim.worldSphere.center.y = this->actor.world.pos.y; + this->collider.dim.worldSphere.center.z = this->actor.world.pos.z; + + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + if (this->actionFunc != EnBomChu_WaitForRelease) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + this->actor.focus.pos.x = this->actor.world.pos.x + (20.0f * this->axisUp.x); + this->actor.focus.pos.y = this->actor.world.pos.y + (20.0f * this->axisUp.y); + this->actor.focus.pos.z = this->actor.world.pos.z + (20.0f * this->axisUp.z); + + if (this->isMoving) { + this->visualJitter = + (5.0f + (Rand_ZeroOne() * 3.0f)) * Math_SinS((((s32)(Rand_ZeroOne() * 512.0f) + 0x3000) * this->timer)); + EnBomChu_ActorCoordsToWorld(this, &sBlureP1Offset, &blureP1); + + EnBomChu_ActorCoordsToWorld(this, &sBlureP2LeftOffset, &blureP2); + EffectBlure_AddVertex(Effect_GetByIndex(this->blure1Index), &blureP1, &blureP2); + + EnBomChu_ActorCoordsToWorld(this, &sBlureP2RightOffset, &blureP2); + EffectBlure_AddVertex(Effect_GetByIndex(this->blure2Index), &blureP1, &blureP2); + + waterY = this->actor.world.pos.y; + + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &waterY, &waterBox)) { + this->actor.depthInWater = waterY - this->actor.world.pos.y; + + if (this->actor.depthInWater < 0.0f) { + if (this->actor.bgCheckFlags & 0x20) { + EnBomChu_SpawnRipplesAndSplashes(this, globalCtx, waterY, true); + } + + this->actor.bgCheckFlags &= ~0x20; + return; + } + + if (!(this->actor.bgCheckFlags & 0x20) && (this->timer != 120)) { + EnBomChu_SpawnRipplesAndSplashes(this, globalCtx, waterY, true); + } else { + EffectSsBubble_Spawn(globalCtx, &this->actor.world.pos, 0.0f, 3.0f, 15.0f, 0.25f); + } + + this->actor.bgCheckFlags |= 0x20; + } else { + this->actor.bgCheckFlags &= ~0x20; + this->actor.depthInWater = BGCHECK_Y_MIN; + } + } +} + +void EnBomChu_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnBomChu* this = THIS; + f32 colorIntensity; + s32 blinkHalfPeriod; + s32 blinkTime; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + func_800B8050(&this->actor, globalCtx, 0); + + if (this->timer >= 40) { + blinkTime = this->timer % 20; + blinkHalfPeriod = 10; + } else if (this->timer >= 10) { + blinkTime = this->timer % 10; + blinkHalfPeriod = 5; + } else { + blinkTime = this->timer & 1; + blinkHalfPeriod = 1; + } + + if (blinkTime > blinkHalfPeriod) { + blinkTime = 2 * blinkHalfPeriod - blinkTime; + } + + colorIntensity = blinkTime / (f32)blinkHalfPeriod; + gDPSetEnvColor(POLY_OPA_DISP++, (s32)(colorIntensity * 209.0f) + 9, (s32)(colorIntensity * 34.0f) + 9, + (s32)(colorIntensity * -35.0f) + 35, 255); + Matrix_InsertTranslation(this->visualJitter * (1.0f / BOMBCHU_SCALE), 0.0f, 0.0f, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gBombchuDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.h b/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.h index 910ad51745..30a3dab9ae 100644 --- a/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.h +++ b/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.h @@ -8,9 +8,21 @@ struct EnBomChu; typedef void (*EnBomChuActionFunc)(struct EnBomChu*, GlobalContext*); typedef struct EnBomChu { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnBomChuActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x98]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnBomChuActionFunc actionFunc; + /* 0x148 */ u8 shouldTimerCountDown; // the actor always sets this to true + /* 0x149 */ u8 isMoving; + /* 0x14A */ s16 timer; + /* 0x14C */ Vec3f axisForwards; + /* 0x158 */ Vec3f axisUp; + /* 0x164 */ Vec3f axisLeft; + /* 0x170 */ f32 visualJitter; + /* 0x174 */ f32 unk_174; // set but never used + /* 0x178 */ UNK_TYPE1 unk_178[0x4]; + /* 0x17C */ f32 movingSpeed; + /* 0x180 */ s32 blure1Index; + /* 0x184 */ s32 blure2Index; + /* 0x188 */ ColliderSphere collider; } EnBomChu; // size = 0x1E0 extern const ActorInit En_Bom_Chu_InitVars; diff --git a/src/overlays/actors/ovl_En_Bombers/z_en_bombers.c b/src/overlays/actors/ovl_En_Bombers/z_en_bombers.c index c20759cb6c..a76c901eb0 100644 --- a/src/overlays/actors/ovl_En_Bombers/z_en_bombers.c +++ b/src/overlays/actors/ovl_En_Bombers/z_en_bombers.c @@ -5,6 +5,8 @@ */ #include "z_en_bombers.h" +#include "overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.h" +#include "objects/object_cs/object_cs.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) @@ -15,12 +17,14 @@ void EnBombers_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnBombers_Update(Actor* thisx, GlobalContext* globalCtx); void EnBombers_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80C03ACC(EnBombers* this); void func_80C03AF4(EnBombers* this, GlobalContext* globalCtx); +void func_80C03F64(EnBombers* this); void func_80C03FAC(EnBombers* this, GlobalContext* globalCtx); +void func_80C042F8(EnBombers* this); void func_80C04354(EnBombers* this, GlobalContext* globalCtx); void func_80C043C8(EnBombers* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Bombers_InitVars = { ACTOR_EN_BOMBERS, ACTORCAT_NPC, @@ -33,45 +37,495 @@ const ActorInit En_Bombers_InitVars = { (ActorFunc)EnBombers_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80C04770 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 10, 30, 0, { 0, 0, 0 } }, }; -#endif +AnimationHeader* D_80C0479C[] = { + &gBomberIdleAnim, &object_cs_Anim_0053F4, &object_cs_Anim_01007C, &object_cs_Anim_00349C, + &object_cs_Anim_004960, &object_cs_Anim_005128, &object_cs_Anim_004C1C, &object_cs_Anim_001A1C, + &object_cs_Anim_003EE4, &object_cs_Anim_00478C, &object_cs_Anim_00433C, &object_cs_Anim_0060E8, + &object_cs_Anim_001708, &object_cs_Anim_005DC4, &object_cs_Anim_0026B0, &object_cs_Anim_0036B0, + &object_cs_Anim_0031C4, +}; -extern ColliderCylinderInit D_80C04770; +u8 D_80C047E0[] = { + ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_LOOP, + ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, + ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, +}; -extern UNK_TYPE D_060064B8; +#include "overlays/ovl_En_Bombers/ovl_En_Bombers.c" -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers/EnBombers_Init.s") +Gfx* D_80C04818[] = { + ovl_En_Bombers_DL_12C8, ovl_En_Bombers_DL_12D8, ovl_En_Bombers_DL_12D8, + ovl_En_Bombers_DL_12D8, ovl_En_Bombers_DL_12D8, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers/EnBombers_Destroy.s") +TexturePtr D_80C0482C[] = { + object_cs_Tex_00C520, + object_cs_Tex_00CD20, + object_cs_Tex_00D520, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers/func_80C03824.s") +TexturePtr D_80C04838[] = { + object_cs_Tex_00E620, object_cs_Tex_00EA20, object_cs_Tex_00EE20, object_cs_Tex_00DD20, object_cs_Tex_00F220, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers/func_80C038B4.s") +void EnBombers_Init(Actor* thisx, GlobalContext* globalCtx) { + EnBombers* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers/func_80C039A8.s") + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 19.0f); + this->actor.gravity = -1.0f; + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_cs_Skel_00F82C, &gBomberIdleAnim, this->jointTable, + this->morphtable, 21); + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + this->actor.targetMode = 0; + Actor_SetScale(&this->actor, 0.01f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers/func_80C03ACC.s") + this->unk_2BC = ENBOMBERS_GET_F0(&this->actor); + this->unk_2BE = ENBOMBERS_GET_F(&this->actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers/func_80C03AF4.s") + if (this->unk_2BC == ENBOMBERS_F0_0) { + if ((gSaveContext.save.weekEventReg[73] & 0x10) || (gSaveContext.save.weekEventReg[85] & 2)) { + Actor_MarkForDeath(&this->actor); + } else { + this->unk_2BE++; + func_80C03ACC(this); + } + } else if (((gSaveContext.save.weekEventReg[73] & 0x10) || (gSaveContext.save.weekEventReg[85] & 2)) && + (((this->unk_2BE == ENBOMBERS_F_0) && (gSaveContext.save.weekEventReg[76] & 1)) || + ((this->unk_2BE == ENBOMBERS_F_1) && (gSaveContext.save.weekEventReg[76] & 2)) || + ((this->unk_2BE == ENBOMBERS_F_2) && (gSaveContext.save.weekEventReg[76] & 4)) || + ((this->unk_2BE == ENBOMBERS_F_3) && (gSaveContext.save.weekEventReg[76] & 8)) || + ((this->unk_2BE == ENBOMBERS_F_4) && (gSaveContext.save.weekEventReg[76] & 0x10)))) { + if (gSaveContext.save.weekEventReg[75] & 0x40) { + if (this->unk_2BE == ENBOMBERS_F_0) { + EnBomBowlMan* bomBowlMan = (EnBomBowlMan*)Actor_Spawn( + &globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM_BOWL_MAN, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, this->actor.world.rot.y, 0, 0); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers/func_80C03F64.s") + if (bomBowlMan != NULL) { + s32 cs = this->actor.cutscene; + s32 i = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers/func_80C03FAC.s") + // clang-format off + while (cs != -1) { bomBowlMan->unk_2CC[i] = cs; cs = ActorCutscene_GetAdditionalCutscene(cs); i++; } + // clang-format on -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers/func_80C042F8.s") + gSaveContext.save.weekEventReg[76] &= (u8)~1; + gSaveContext.save.weekEventReg[76] &= (u8)~2; + gSaveContext.save.weekEventReg[76] &= (u8)~4; + gSaveContext.save.weekEventReg[76] &= (u8)~8; + gSaveContext.save.weekEventReg[76] &= (u8)~0x10; + } + } + Actor_MarkForDeath(&this->actor); + } else { + func_80C042F8(this); + } + } else { + Actor_MarkForDeath(&this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers/func_80C04354.s") +void EnBombers_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnBombers* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers/func_80C043C8.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers/EnBombers_Update.s") +void func_80C03824(EnBombers* this, s32 arg1, f32 arg2) { + this->unk_2C4 = arg1; + this->unk_2B0 = Animation_GetLastFrame(D_80C0479C[arg1]); + Animation_Change(&this->skelAnime, D_80C0479C[this->unk_2C4], arg2, 0.0f, this->unk_2B0, D_80C047E0[this->unk_2C4], + -10.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers/func_80C045B4.s") +void func_80C038B4(EnBombers* this) { + if ((this->unk_2C4 == 2) && + (Animation_OnFrame(&this->skelAnime, 9.0f) || Animation_OnFrame(&this->skelAnime, 10.0f) || + Animation_OnFrame(&this->skelAnime, 17.0f) || Animation_OnFrame(&this->skelAnime, 18.0f))) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMBERS_WALK); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers/EnBombers_Draw.s") + if ((this->unk_2C4 == 15) && + (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 2.0f) || + Animation_OnFrame(&this->skelAnime, 4.0f) || Animation_OnFrame(&this->skelAnime, 6.0f))) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMBERS_WALK); + } +} + +void func_80C039A8(EnBombers* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + this->unk_2A6 = 5; + + switch (player->transformation) { + case PLAYER_FORM_HUMAN: + this->actor.textId = 0x73D; + if (gSaveContext.save.weekEventReg[84] & 0x80) { + this->actor.textId = 0x74B; + } + break; + + case PLAYER_FORM_GORON: + this->actor.textId = 0x73E; + break; + + case PLAYER_FORM_ZORA: + this->actor.textId = 0x73F; + break; + + case PLAYER_FORM_DEKU: + if (gSaveContext.save.weekEventReg[73] & 0x20) { + this->actor.textId = 0x75A; + } else if (gSaveContext.save.weekEventReg[73] & 0x40) { + this->actor.textId = 0x749; + if (((this->unk_2BE == ENBOMBERS_F_1) && (gSaveContext.save.weekEventReg[74] & 1)) || + ((this->unk_2BE == ENBOMBERS_F_2) && (gSaveContext.save.weekEventReg[74] & 2)) || + ((this->unk_2BE == ENBOMBERS_F_3) && (gSaveContext.save.weekEventReg[74] & 4)) || + ((this->unk_2BE == ENBOMBERS_F_4) && (gSaveContext.save.weekEventReg[74] & 8))) { + this->actor.textId = 0x74A; + } + } else { + this->actor.textId = 0x744; + } + break; + } +} + +void func_80C03ACC(EnBombers* this) { + this->collider.dim.radius = 10; + this->collider.dim.height = 30; + this->unk_2C0 = 0; + this->actionFunc = func_80C03AF4; +} + +void func_80C03AF4(EnBombers* this, GlobalContext* globalCtx) { + CollisionPoly* colPoly; + f32 curFrame = this->skelAnime.curFrame; + Vec3f sp6C; + Vec3f sp60; + Vec3f sp54; + f32 x; + f32 z; + s32 sp48; + s16 abs; + + switch (this->unk_2A0) { + case 0: + if (this->unk_2A8 == 0) { + Math_Vec3f_Copy(&sp60, &this->actor.home.pos); + + sp60.x += randPlusMinusPoint5Scaled(150.0f); + sp60.z += randPlusMinusPoint5Scaled(150.0f); + + abs = ABS_ALT(BINANG_SUB(this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &sp60))); + if ((abs < 0x4000) && !BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &sp60, &sp6C, + &colPoly, true, false, false, true, &sp48)) { + func_80C03824(this, 2, 1.0f); + Math_Vec3f_Copy(&this->unk_294, &sp60); + this->unk_2AA = Rand_S16Offset(30, 50); + this->unk_2A0++; + } + } + break; + + case 1: + if (curFrame >= 0.0f) { + this->unk_2A4 = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_294); + Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_2A4, 0xA, 0x7D0, 0x14); + } + + if ((s16)ABS_ALT(BINANG_SUB(this->actor.world.rot.y, this->unk_2A4)) < 0x100) { + Math_Vec3f_Copy(&sp54, &this->actor.world.pos); + sp54.x += Math_SinS(this->actor.world.rot.y) * 60.0f; + sp54.z += Math_CosS(this->actor.world.rot.y) * 60.0f; + + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &sp54, &sp6C, &colPoly, true, + false, false, true, &sp48)) { + this->unk_2A8 = 0; + if (Rand_ZeroOne() < 0.5f) { + func_80C03824(this, 16, 1.0f); + } else { + func_80C03824(this, 0, 1.0f); + } + this->unk_2A0 = 0; + this->unk_2B4 = 0.0f; + break; + } + } + + x = this->unk_294.x - this->actor.world.pos.x; + z = this->unk_294.z - this->actor.world.pos.z; + + if ((this->unk_2AA == 0) || (sqrtf(SQ(x) + SQ(z)) < 4.0f)) { + this->unk_2A8 = Rand_S16Offset(20, 20); + if (!(this->unk_2A8 & 1)) { + func_80C03824(this, 16, 1.0f); + } else { + func_80C03824(this, 0, 1.0f); + } + this->unk_2A0 = 0; + this->unk_2B4 = 0.0f; + } else if (curFrame >= 0.0f) { + Math_ApproachF(&this->actor.world.pos.x, this->unk_294.x, 0.3f, this->unk_2B4); + Math_ApproachF(&this->actor.world.pos.z, this->unk_294.z, 0.3f, this->unk_2B4); + Math_ApproachF(&this->unk_2B4, 1.0f, 0.3f, 0.5f); + } + break; + } + + if (!Text_GetFaceReaction(globalCtx, 0x12)) { + func_80C039A8(this, globalCtx); + } else { + this->unk_2A6 = 5; + this->actor.textId = Text_GetFaceReaction(globalCtx, 0x12); + } + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->unk_2A4 = this->actor.yawTowardsPlayer; + this->collider.dim.radius = 20; + this->collider.dim.height = 60; + func_80C03F64(this); + } else { + func_800B8614(&this->actor, globalCtx, 70.0f); + } +} + +void func_80C03F64(EnBombers* this) { + this->unk_2A4 = this->actor.yawTowardsPlayer; + func_80C03824(this, 1, 1.0f); + this->unk_2C0 = 1; + this->actionFunc = func_80C03FAC; +} + +void func_80C03FAC(EnBombers* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 sp2A; + + Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_2A4, 1, 0x1388, 0); + + switch (player->transformation) { + case PLAYER_FORM_HUMAN: + this->unk_28E = -0xFA0; + break; + + case PLAYER_FORM_GORON: + case PLAYER_FORM_ZORA: + this->unk_28E = -0x1770; + break; + } + + if ((this->unk_2A6 == Message_GetState(&globalCtx->msgCtx)) && Message_ShouldAdvance(globalCtx)) { + sp2A = 0; + func_801477B4(globalCtx); + this->unk_2A6 = 5; + + if ((this->actor.textId == 0x73D) || (this->actor.textId == 0x73E) || (this->actor.textId == 0x73F)) { + this->actor.textId = 0x740; + this->unk_2A6 = 4; + sp2A = 1; + } else if (this->actor.textId == 0x740) { + if (globalCtx->msgCtx.choiceIndex == 0) { + func_8019F208(); + this->actor.textId = 0x742; + sp2A = 1; + } else { + func_8019F230(); + this->actor.textId = 0x741; + sp2A = 1; + } + } else if (this->actor.textId == 0x742) { + this->actor.textId = 0x737; + sp2A = 1; + } else if (this->actor.textId == 0x737) { + this->actor.textId = 0x743; + sp2A = 1; + } else if (this->actor.textId == 0x74B) { + this->actor.textId = 0x74C; + this->unk_2A6 = 4; + sp2A = 1; + } else if (this->actor.textId == 0x74C) { + if (globalCtx->msgCtx.choiceIndex == 1) { + func_8019F230(); + this->actor.textId = 0x737; + sp2A = 1; + } else { + func_8019F208(); + this->actor.textId = 0x74D; + func_80C03824(this, 14, 1.0f); + sp2A = 1; + } + } else if (this->actor.textId == 0x744) { + s32 day = gSaveContext.save.day - 1; + + if (day == 2) { + this->actor.textId = 0x746; + sp2A = 1; + } else { + this->actor.textId = 0x745; + sp2A = 1; + } + } else if ((this->actor.textId == 0x745) || (this->actor.textId == 0x746)) { + this->actor.textId = 0x747; + sp2A = 1; + } else if (this->actor.textId == 0x747) { + this->actor.textId = 0x748; + sp2A = 1; + } else if (this->actor.textId == 0x748) { + switch (this->unk_2BE) { + case ENBOMBERS_F_1: + gSaveContext.save.weekEventReg[74] |= 1; + break; + + case ENBOMBERS_F_2: + gSaveContext.save.weekEventReg[74] |= 2; + break; + + case ENBOMBERS_F_3: + gSaveContext.save.weekEventReg[74] |= 4; + break; + + case ENBOMBERS_F_4: + gSaveContext.save.weekEventReg[74] |= 8; + break; + } + gSaveContext.save.weekEventReg[73] |= 0x40; + } + + switch (sp2A) { + case 0: + this->unk_28E = 0; + func_80C03ACC(this); + break; + + case 1: + func_80151938(globalCtx, this->actor.textId); + break; + } + } +} + +void func_80C042F8(EnBombers* this) { + if (this->unk_2C4 != 6) { + func_80C03824(this, 6, 1.0f); + } + this->actor.textId = 0x72D; + this->unk_28E = 0x1F40; + this->unk_2C0 = 2; + this->actionFunc = func_80C04354; +} + +void func_80C04354(EnBombers* this, GlobalContext* globalCtx) { + Math_SmoothStepToS(&this->unk_288, this->unk_28E, 1, 0x3E8, 0); + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->unk_28E = 0; + this->actionFunc = func_80C043C8; + } else { + func_800B8614(&this->actor, globalCtx, 70.0f); + } +} + +void func_80C043C8(EnBombers* this, GlobalContext* globalCtx) { + Math_SmoothStepToS(&this->unk_288, this->unk_28E, 1, 0x3E8, 0); + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + func_801477B4(globalCtx); + func_80C042F8(this); + } +} + +void EnBombers_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnBombers* this = THIS; + + if (this->unk_2AA != 0) { + this->unk_2AA--; + } + + if (this->unk_2A8 != 0) { + this->unk_2A8--; + } + + if (this->unk_2AC != 0) { + this->unk_2AC--; + } + + SkelAnime_Update(&this->skelAnime); + this->actor.shape.rot.y = this->actor.world.rot.y; + func_80C038B4(this); + Actor_SetFocus(&this->actor, 20.0f); + this->actionFunc(this, globalCtx); + Actor_MoveWithGravity(&this->actor); + Math_SmoothStepToS(&this->unk_28A, this->unk_290, 1, 0x1388, 0); + Math_SmoothStepToS(&this->unk_288, this->unk_28E, 1, 0x1388, 0); + + if (this->unk_2BA == 0) { + this->unk_2B8++; + if (this->unk_2B8 >= 3) { + this->unk_2B8 = 0; + this->unk_2BA = (s16)Rand_ZeroFloat(60.0f) + 20; + } + } + + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); + this->actor.uncullZoneForward = 500.0f; + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +s32 EnBombers_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnBombers* this = THIS; + + if (limbIndex == OBJECT_CS_LIMB_0F) { + *dList = NULL; + } + + if (limbIndex == OBJECT_CS_LIMB_11) { + rot->x += this->unk_28A; + rot->z += this->unk_288; + } + + if (limbIndex == OBJECT_CS_LIMB_13) { + *dList = NULL; + } + + return false; +} + +void EnBombers_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnBombers* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80C0482C[this->unk_2B8])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80C04838[this->unk_2BE])); + gSPSegment(POLY_OPA_DISP++, 0x0A, Lib_SegmentedToVirtual(D_80C04818[this->unk_2BE])); + + Scene_SetRenderModeXlu(globalCtx, 0, 1); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnBombers_OverrideLimbDraw, NULL, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Bombers/z_en_bombers.h b/src/overlays/actors/ovl_En_Bombers/z_en_bombers.h index 630c26e658..c51150df85 100644 --- a/src/overlays/actors/ovl_En_Bombers/z_en_bombers.h +++ b/src/overlays/actors/ovl_En_Bombers/z_en_bombers.h @@ -7,11 +7,47 @@ struct EnBombers; typedef void (*EnBombersActionFunc)(struct EnBombers*, GlobalContext*); +#define ENBOMBERS_GET_F(thisx) ((thisx)->params & 0xF) +#define ENBOMBERS_GET_F0(thisx) (((thisx)->params >> 4) & 0xF) + +enum { + /* 0 */ ENBOMBERS_F_0, + /* 1 */ ENBOMBERS_F_1, + /* 2 */ ENBOMBERS_F_2, + /* 3 */ ENBOMBERS_F_3, + /* 4 */ ENBOMBERS_F_4, +}; + +#define ENBOMBERS_F0_0 0 + typedef struct EnBombers { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x140]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[21]; + /* 0x0206 */ Vec3s morphtable[21]; /* 0x0284 */ EnBombersActionFunc actionFunc; - /* 0x0288 */ char unk_288[0x8C]; + /* 0x0288 */ s16 unk_288; + /* 0x028A */ s16 unk_28A; + /* 0x028C */ UNK_TYPE1 unk28C[2]; + /* 0x028E */ s16 unk_28E; + /* 0x0290 */ s16 unk_290; + /* 0x0294 */ Vec3f unk_294; + /* 0x02A0 */ s16 unk_2A0; + /* 0x02A2 */ UNK_TYPE1 unk2A2[2]; + /* 0x02A4 */ s16 unk_2A4; + /* 0x02A6 */ s16 unk_2A6; + /* 0x02A8 */ s16 unk_2A8; + /* 0x02AA */ s16 unk_2AA; + /* 0x02AC */ s16 unk_2AC; + /* 0x02B0 */ f32 unk_2B0; + /* 0x02B4 */ f32 unk_2B4; + /* 0x02B8 */ s16 unk_2B8; + /* 0x02BA */ s16 unk_2BA; + /* 0x02BC */ s16 unk_2BC; + /* 0x02BE */ s16 unk_2BE; + /* 0x02C0 */ s16 unk_2C0; + /* 0x02C4 */ s32 unk_2C4; + /* 0x02C8 */ ColliderCylinder collider; } EnBombers; // size = 0x314 extern const ActorInit En_Bombers_InitVars; diff --git a/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.c b/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.c index bcd76ab9d3..8b2fa6d906 100644 --- a/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.c +++ b/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.c @@ -18,8 +18,11 @@ void EnBombers2_Draw(Actor* thisx, GlobalContext* globalCtx); void func_80C04BA0(EnBombers2* this, GlobalContext* globalCtx); void func_80C04D8C(EnBombers2* this, GlobalContext* globalCtx); void func_80C0520C(EnBombers2* this, GlobalContext* globalCtx); +void func_80C04B40(EnBombers2* this); +void EnBombers2_ChangeAnim(EnBombers2* this, s32 animIndex, f32 playSpeed); +void func_80C04D00(EnBombers2* this); +void func_80C050B8(EnBombers2* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Bombers2_InitVars = { ACTOR_EN_BOMBERS2, ACTORCAT_NPC, @@ -32,39 +35,404 @@ const ActorInit En_Bombers2_InitVars = { (ActorFunc)EnBombers2_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80C058B0 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static u16 sTextIds[] = { + 0x0727, 0x0728, 0x0726, 0x0729, 0x072B, 0x0725, 0x072A, 0x073C, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 35, 30, 0, { 0, 0, 0 } }, }; -#endif +static AnimationHeader* sAnimations[] = { + &gBomberIdleAnim, &object_cs_Anim_0053F4, &object_cs_Anim_01007C, &object_cs_Anim_00349C, + &object_cs_Anim_0060E8, &object_cs_Anim_005DC4, &object_cs_Anim_0026B0, +}; -extern ColliderCylinderInit D_80C058B0; +static u8 sAnimModes[] = { + ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, + ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, +}; -extern UNK_TYPE D_060064B8; +static Gfx sSetPrimColorDL[] = { + gsDPSetPrimColor(0, 0xFF, 198, 140, 0, 255), + gsSPEndDisplayList(), +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers2/EnBombers2_Init.s") +static Gfx* sSetPrimColorDlPtr = sSetPrimColorDL; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers2/EnBombers2_Destroy.s") +static TexturePtr sEyeTextures[] = { + object_cs_Tex_00C520, + object_cs_Tex_00CD20, + object_cs_Tex_00D520, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers2/func_80C04AAC.s") +static TexturePtr D_80C05920 = object_cs_Tex_00E220; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers2/func_80C04B40.s") +void EnBombers2_Init(Actor* thisx, GlobalContext* globalCtx) { + f32 cos; + EnBombers2* this = (EnBombers2*)thisx; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers2/func_80C04BA0.s") + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 19.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_cs_Skel_00F82C, &gBomberIdleAnim, this->morphTable, + this->jointTable, OBJECT_CS_LIMB_MAX); + this->actor.targetMode = 6; + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + if ((gSaveContext.save.weekEventReg[73] & 0x80) || (gSaveContext.save.entranceIndex == 0xD220)) { + this->actor.world.pos.x += Math_SinS(this->actor.home.rot.y + 0xC100) * 50.0f; + cos = Math_CosS(this->actor.home.rot.y + 0xC100) * 50.0f; + this->unk_2AC = 1; + this->actor.world.pos.z += cos; + } + this->cutscene = this->actor.cutscene; + if (this->cutscene == 0) { + Actor_MarkForDeath(&this->actor); + } + func_80C04B40(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers2/func_80C04D00.s") +void EnBombers2_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnBombers2* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers2/func_80C04D8C.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers2/func_80C050B8.s") +void EnBombers2_ChangeAnim(EnBombers2* this, s32 animIndex, f32 playSpeed) { + f32 lastFrame; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers2/func_80C0520C.s") + this->animIndex = animIndex; + lastFrame = Animation_GetLastFrame(sAnimations[this->animIndex]); + this->lastAnimFrame = lastFrame; + Animation_Change(&this->skelAnime, sAnimations[this->animIndex], playSpeed, 0.0f, lastFrame, + sAnimModes[this->animIndex], -10.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers2/EnBombers2_Update.s") +void func_80C04B40(EnBombers2* this) { + if (this->unk_2AC == 0) { + EnBombers2_ChangeAnim(this, 4, 1.0f); + } else { + EnBombers2_ChangeAnim(this, 0, 1.0f); + } + this->unk_2C0 = 0; + this->actionFunc = func_80C04BA0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers2/func_80C056D4.s") +void func_80C04BA0(EnBombers2* this, GlobalContext* globalCtx) { + s32 yawDiffAbs; + s16 yawDiff; + Player* player; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers2/EnBombers2_Draw.s") + yawDiff = this->actor.yawTowardsPlayer - this->actor.world.rot.y; + yawDiffAbs = ABS_ALT(yawDiff); + player = GET_PLAYER(globalCtx); + + switch (player->transformation) { + case PLAYER_FORM_GORON: + case PLAYER_FORM_ZORA: + this->textIdIndex = 1; + this->unk_2CE = 5; + break; + case PLAYER_FORM_DEKU: + case PLAYER_FORM_HUMAN: + this->textIdIndex = 2; + this->unk_2CE = 5; + break; + } + if (this->unk_2AC != 0) { + this->textIdIndex = 7; + } + this->actor.textId = sTextIds[this->textIdIndex]; + + if (Text_GetFaceReaction(globalCtx, 0x15) != 0) { + this->actor.textId = Text_GetFaceReaction(globalCtx, 0x15); + } + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->unk_2B6 = this->actor.world.rot.y; + gSaveContext.save.weekEventReg[86] |= 2; + func_80C04D00(this); + return; + } + if (yawDiffAbs < 0x3BB5) { + func_800B8614(&this->actor, globalCtx, 70.0f); + } +} + +void func_80C04D00(EnBombers2* this) { + if ((this->textIdIndex == 0) || (this->textIdIndex == 1)) { + EnBombers2_ChangeAnim(this, 5, 1.0f); + } else { + EnBombers2_ChangeAnim(this, 1, 1.0f); + } + + this->unk_2A8 = 0; + if (this->unk_2AC != 0) { + EnBombers2_ChangeAnim(this, 6, 1.0f); + } + this->unk_2C0 = 1; + this->actionFunc = func_80C04D8C; +} + +void func_80C04D8C(EnBombers2* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 temp = this->skelAnime.curFrame; + + if ((this->unk_2AC == 0) && (this->lastAnimFrame <= temp)) { + if (!(this->unk_2A8 & 1)) { + EnBombers2_ChangeAnim(this, 1, 1.0f); + } else { + EnBombers2_ChangeAnim(this, 5, 1.0f); + } + this->unk_2A8++; + this->unk_2A8 &= 1; + } + switch (player->transformation) { + case PLAYER_FORM_HUMAN: + this->unk_28E = -0xFA0; + break; + case PLAYER_FORM_GORON: + case PLAYER_FORM_ZORA: + this->unk_28E = -0x1770; + break; + default: + break; + } + if ((this->unk_2CE == Message_GetState(&globalCtx->msgCtx)) && Message_ShouldAdvance(globalCtx)) { + if (this->unk_2CE == 0xF) { + s32 i; + s32 correctDigits; + + for (i = 0; i < ARRAY_COUNT(this->correctDigitSlots); i++) { + if (!(this->correctDigitSlots[i]) && + (globalCtx->msgCtx.unk12054[i] == gSaveContext.save.bomberCode[i])) { + this->correctDigitSlots[i] = true; + } + } + for (i = 0, correctDigits = 0; i < ARRAY_COUNT(this->correctDigitSlots); i++) { + if (this->correctDigitSlots[i]) { + correctDigits++; + } + } + + if (correctDigits >= 5) { + this->textIdIndex = 6; + this->actor.textId = sTextIds[this->textIdIndex]; + func_80151938(globalCtx, this->actor.textId); + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_PIECE_OF_HEART); + this->unk_2CE = 5; + return; + } + } + if (Text_GetFaceReaction(globalCtx, 0x15) != 0) { + this->unk_28E = 0; + func_801477B4(globalCtx); + func_80C04B40(this); + } else { + s32 j; + + switch (this->textIdIndex) { + case 0: + case 1: + case 5: + case 7: + this->unk_28E = 0; + func_801477B4(globalCtx); + func_80C04B40(this); + break; + case 2: + this->textIdIndex = 3; + this->actor.textId = sTextIds[this->textIdIndex]; + func_80151938(globalCtx, this->actor.textId); + this->unk_2CE = 0xF; + break; + case 3: + for (j = 0; j < ARRAY_COUNT(this->correctDigitSlots); j++) { + this->correctDigitSlots[j] = false; + } + this->textIdIndex = 4; + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_ERROR); + this->actor.textId = sTextIds[this->textIdIndex]; + func_80151938(globalCtx, this->actor.textId); + this->unk_2CE = 5; + break; + case 4: + this->textIdIndex = 5; + this->actor.textId = sTextIds[this->textIdIndex]; + func_80151938(globalCtx, this->actor.textId); + this->unk_2CE = 5; + break; + case 6: + globalCtx->msgCtx.unk11F10 = 0; + func_80C050B8(this, globalCtx); + break; + } + } + } +} + +void func_80C050B8(EnBombers2* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 homeYawToPlayer; + + EnBombers2_ChangeAnim(this, 2, 1.0f); + this->unk_2A8 = 0; + homeYawToPlayer = Math_Vec3f_Yaw(&this->actor.home.pos, &player->actor.world.pos); + Math_Vec3f_Copy(&this->unk_29C, &this->actor.world.pos); + if (this->actor.home.rot.y < homeYawToPlayer) { + this->unk_29C.x += Math_SinS(this->actor.home.rot.y + 0xC100) * 50.0f; + this->unk_29C.z += Math_CosS(this->actor.home.rot.y + 0xC100) * 50.0f; + } else { + this->unk_29C.x += Math_SinS(this->actor.home.rot.y + 0x3F00) * 50.0f; + this->unk_29C.z += Math_CosS(this->actor.home.rot.y + 0x3F00) * 50.0f; + } + this->unk_2B6 = Math_Vec3f_Yaw(&this->actor.home.pos, &this->unk_29C); + this->unk_2C0 = 2; + this->actionFunc = func_80C0520C; +} + +void func_80C0520C(EnBombers2* this, GlobalContext* globalCtx) { + if (this->unk_2A8 == 0) { + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->cutscene); + } else if (ActorCutscene_GetCanPlayNext(this->cutscene) == 0) { + ActorCutscene_SetIntentToPlay(this->cutscene); + } else { + ActorCutscene_StartAndSetUnkLinkFields(this->cutscene, &this->actor); + this->unk_2A8 = 1; + } + } else { + Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_2B6, 1, 0xBB8, 0); + if ((fabsf(this->unk_29C.x - this->actor.world.pos.x) < 3.0f) && + (fabsf(this->unk_29C.z - this->actor.world.pos.z) < 3.0f)) { + this->unk_2B6 = this->actor.yawTowardsPlayer; + this->actor.speedXZ = 0.0f; + if (fabsf(this->actor.world.rot.y - this->actor.yawTowardsPlayer) < 100.0f) { + func_801477B4(globalCtx); + this->unk_2CE = 5; + this->textIdIndex = 7; + EnBombers2_ChangeAnim(this, 6, 1.0f); + this->unk_2A8 = 0; + this->unk_2C0 = 1; + gSaveContext.save.weekEventReg[73] |= 0x80; + ActorCutscene_Stop(this->cutscene); + this->unk_2AC = 1; + this->actor.textId = sTextIds[this->textIdIndex]; + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); + this->actionFunc = func_80C04D8C; + } + } else { + Math_ApproachF(&this->actor.world.pos.x, this->unk_29C.x, 0.3f, 1.0f); + Math_ApproachF(&this->actor.world.pos.z, this->unk_29C.z, 0.3f, 1.0f); + } + } +} + +void EnBombers2_Update(Actor* thisx, GlobalContext* globalCtx) { + EnBombers2* this = (EnBombers2*)thisx; + f32 temp_f4; + Vec3f sp34; + s32 yawDiffAbs; + + SkelAnime_Update(&this->skelAnime); + if (this->unk_2B2 != 0) { + this->unk_2B2--; + } + if ((this->animIndex == 2) && + (Animation_OnFrame(&this->skelAnime, 9.0f) || Animation_OnFrame(&this->skelAnime, 10.0f) || + Animation_OnFrame(&this->skelAnime, 17.0f) || Animation_OnFrame(&this->skelAnime, 18.0f))) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMBERS_WALK); + } + this->actor.shape.rot.y = this->actor.world.rot.y; + if (this->unk_2C0 != 2) { + + yawDiffAbs = ABS_ALT((s16)(this->actor.yawTowardsPlayer - this->actor.world.rot.y)); + this->unk_290 = 0; + if (yawDiffAbs < 0x3A98) { + this->unk_290 = this->actor.yawTowardsPlayer - this->actor.world.rot.y; + if (this->unk_290 >= 0x2711) { + this->unk_290 = 0x2710; + } else if (this->unk_290 < -0x2710) { + this->unk_290 = -0x2710; + } + } + } + Actor_SetFocus(&this->actor, 20.0f); + Actor_SetScale(&this->actor, 0.008f); + this->actionFunc(this, globalCtx); + Actor_MoveWithGravity(&this->actor); + Math_SmoothStepToS(&this->unk_28A, this->unk_290, 1, 0xBB8, 0); + Math_SmoothStepToS(&this->unk_288, this->unk_28E, 1, 0xBB8, 0); + if (this->unk_2BE == 0) { + this->eyeIndex += 1; + if (this->eyeIndex >= 3) { + this->eyeIndex = 0; + this->unk_2BE = (s16)Rand_ZeroFloat(60.0f) + 0x14; + } + } + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); + if (this->unk_2AC == 0) { + this->actor.world.pos.x = (Math_SinS((this->actor.world.rot.y + 0x8000)) * 26.0f) + sp34.x; + temp_f4 = Math_CosS(this->actor.world.rot.y + 0x8000) * 26.0f; + this->actor.world.pos.z = temp_f4 + sp34.z; + this->collider.dim.radius = 0x23; + this->collider.dim.height = 0x1E; + } else { + this->collider.dim.radius = 0xA; + this->collider.dim.height = 0x19; + } + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + if (this->unk_2AC == 0) { + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); + } + Math_Vec3f_Copy(&this->actor.world.pos, &sp34); +} + +s32 func_80C056D4(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnBombers2* this = THIS; + + if (limbIndex == OBJECT_CS_LIMB_08) { + rot->x += this->unk_296; + } + if (limbIndex == OBJECT_CS_LIMB_11) { + rot->x += this->unk_28A; + rot->z += this->unk_288; + } + if ((limbIndex == OBJECT_CS_LIMB_0F) || (limbIndex == OBJECT_CS_LIMB_13) || (limbIndex == OBJECT_CS_LIMB_14)) { + *dList = NULL; + } + return false; +} + +void EnBombers2_Draw(Actor* thisx, GlobalContext* globalCtx) { + + EnBombers2* this = THIS; + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeIndex])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80C05920)); + gSPSegment(POLY_OPA_DISP++, 0x0A, Lib_SegmentedToVirtual(sSetPrimColorDlPtr)); + Scene_SetRenderModeXlu(globalCtx, 0, 1); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + func_80C056D4, NULL, &this->actor); + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.h b/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.h index 25c5fd773a..ed10a84db9 100644 --- a/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.h +++ b/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.h @@ -3,15 +3,42 @@ #include "global.h" +#include "objects/object_cs/object_cs.h" + struct EnBombers2; typedef void (*EnBombers2ActionFunc)(struct EnBombers2*, GlobalContext*); typedef struct EnBombers2 { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x140]; + /* 0x014C */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s morphTable[OBJECT_CS_LIMB_MAX]; + /* 0x0206 */ Vec3s jointTable[OBJECT_CS_LIMB_MAX]; /* 0x0284 */ EnBombers2ActionFunc actionFunc; - /* 0x0288 */ char unk_288[0x94]; + /* 0x0288 */ s16 unk_288; + /* 0x028A */ s16 unk_28A; + /* 0x028C */ UNK_TYPE1 pad_28C[2]; + /* 0x028E */ s16 unk_28E; + /* 0x0290 */ s16 unk_290; + /* 0x0292 */ UNK_TYPE1 pad_292[4]; + /* 0x0296 */ s16 unk_296; + /* 0x0298 */ UNK_TYPE1 pad_298[4]; + /* 0x029C */ Vec3f unk_29C; + /* 0x02A8 */ s32 unk_2A8; + /* 0x02AC */ u8 unk_2AC; + /* 0x02AE */ s16 animIndex; + /* 0x02B0 */ s16 cutscene; + /* 0x02B2 */ s16 unk_2B2; + /* 0x02B4 */ s16 unk_2B4; + /* 0x02B6 */ s16 unk_2B6; + /* 0x02B8 */ f32 lastAnimFrame; + /* 0x02BC */ s16 eyeIndex; + /* 0x02BE */ s16 unk_2BE; + /* 0x02C0 */ s16 unk_2C0; + /* 0x02C2 */ s16 textIdIndex; + /* 0x02C4 */ s16 correctDigitSlots[5]; + /* 0x02CE */ s16 unk_2CE; + /* 0x02D0 */ ColliderCylinder collider; } EnBombers2; // size = 0x31C extern const ActorInit En_Bombers2_InitVars; diff --git a/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c b/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c index 4362997e66..fef26002bc 100644 --- a/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c +++ b/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c @@ -5,6 +5,7 @@ */ #include "z_en_bombf.h" +#include "objects/object_bombf/object_bombf.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_10) @@ -15,13 +16,13 @@ void EnBombf_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnBombf_Update(Actor* thisx, GlobalContext* globalCtx); void EnBombf_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnBombf_SetupAction(EnBombf* this, EnBombfActionFunc actionFunc); +void func_808AEAB8(EnBombf* this, s16 arg1); +void func_808AEAE0(EnBombf* this, GlobalContext* globalCtx); void func_808AEE3C(EnBombf* this, GlobalContext* globalCtx); void func_808AEF68(EnBombf* this, GlobalContext* globalCtx); void func_808AEFD4(EnBombf* this, GlobalContext* globalCtx); -void EnBombf_SetupAction(EnBombf* this, EnBombfActionFunc actionFunc); - -#if 0 const ActorInit En_Bombf_InitVars = { ACTOR_EN_BOMBF, ACTORCAT_PROP, @@ -34,53 +35,463 @@ const ActorInit En_Bombf_InitVars = { (ActorFunc)EnBombf_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_808AFB20 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER | AC_TYPE_OTHER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK2, { 0x00000000, 0x00, 0x00 }, { 0x00013A28, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER | AC_TYPE_OTHER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK2, + { 0x00000000, 0x00, 0x00 }, + { 0x00013A28, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 9, 18, 10, { 0, 0, 0 } }, }; -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_808AFB4C[1] = { +static ColliderJntSphElementInit sJntSphElementsInit[1] = { { - { ELEMTYPE_UNK0, { 0x00000008, 0x00, 0x08 }, { 0x00000000, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NONE, BUMP_NONE, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0x00000008, 0x00, 0x08 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NONE, + BUMP_NONE, + OCELEM_NONE, + }, { 0, { { 0, 0, 0 }, 0 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_808AFB70 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_ALL, AC_NONE, OC1_NONE, OC2_NONE, COLSHAPE_JNTSPH, }, - 1, D_808AFB4C, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ALL, + AC_NONE, + OC1_NONE, + OC2_NONE, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, }; -#endif +void EnBombf_SetupAction(EnBombf* this, EnBombfActionFunc actionFunc) { + this->actionFunc = actionFunc; +} -extern ColliderCylinderInit D_808AFB20; -extern ColliderJntSphElementInit D_808AFB4C[1]; -extern ColliderJntSphInit D_808AFB70; +void EnBombf_Init(Actor* thisx, GlobalContext* globalCtx2) { + f32 yOffset = 0.0f; + GlobalContext* globalCtx = globalCtx2; + EnBombf* this = THIS; -extern UNK_TYPE D_06000340; + Actor_SetScale(thisx, 0.01f); + this->unk_1F8 = 1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombf/EnBombf_SetupAction.s") + Collider_InitCylinder(globalCtx, &this->colliderCylinder); + Collider_InitJntSph(globalCtx, &this->colliderJntSph); + Collider_SetCylinder(globalCtx, &this->colliderCylinder, thisx, &sCylinderInit); + Collider_SetJntSph(globalCtx, &this->colliderJntSph, thisx, &sJntSphInit, this->colliderJntSphElements); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombf/EnBombf_Init.s") + if (ENBOMBF_GET(thisx) == ENBOMBF_0) { + yOffset = 1000.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombf/EnBombf_Destroy.s") + ActorShape_Init(&thisx->shape, yOffset, ActorShadow_DrawCircle, 12.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombf/func_808AEAB8.s") + thisx->focus.pos = thisx->world.pos; + thisx->colChkInfo.cylRadius = 10; + thisx->colChkInfo.cylHeight = 10; + thisx->targetMode = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombf/func_808AEAE0.s") + if (ENBOMBF_GET(thisx) == ENBOMBF_0) { + this->timer = 140; + this->unk_1FE = 15; + thisx->gravity = -1.5f; + func_800BC154(globalCtx, &globalCtx->actorCtx, thisx, 3); + thisx->colChkInfo.mass = 200; + thisx->flags &= ~ACTOR_FLAG_1; + EnBombf_SetupAction(this, func_808AEE3C); + } else { + thisx->colChkInfo.mass = MASS_IMMOVABLE; + this->unk_1FC = 1; + this->unk_204 = 1.0f; + func_808AEAB8(this, ENBOMBF_GET(thisx)); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombf/func_808AEE3C.s") + thisx->uncullZoneScale += 31000.0f; + thisx->uncullZoneForward += 31000.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombf/func_808AEF68.s") +void EnBombf_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnBombf* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombf/func_808AEFD4.s") + Collider_DestroyCylinder(globalCtx, &this->colliderCylinder); + Collider_DestroyJntSph(globalCtx, &this->colliderJntSph); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombf/EnBombf_Update.s") +void func_808AEAB8(EnBombf* this, s16 arg1) { + EnBombf_SetupAction(this, func_808AEAE0); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombf/func_808AF86C.s") +void func_808AEAE0(EnBombf* this, GlobalContext* globalCtx) { + s32 pad; + s32 pad2; + EnBombf* bombf; + Player* player = GET_PLAYER(globalCtx); + s32 pad3; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombf/EnBombf_Draw.s") + if (this->unk_204 >= 1.0f) { + if (Actor_HasParent(&this->actor, globalCtx)) { + bombf = (EnBombf*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOMBF, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, ENBOMBF_0); + if (bombf != NULL) { + func_800B8C20(&this->actor, &bombf->actor, globalCtx); + this->timer = 180; + this->unk_204 = 0.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_PULL_UP_ROCK); + this->actor.flags &= ~ACTOR_FLAG_1; + } else { + player->actor.child = NULL; + player->heldActor = NULL; + player->interactRangeActor = NULL; + this->actor.parent = NULL; + player->stateFlags1 &= ~0x800; + } + } else if ((this->colliderCylinder.base.acFlags & AC_HIT) && + ((this->colliderCylinder.info.acHitInfo->toucher.dmgFlags & 0x13828) || + ((this->colliderCylinder.info.acHitInfo->toucher.dmgFlags & 0x200) && + (player->transformation == PLAYER_FORM_GORON) && (player->actor.speedXZ > 15.0f)))) { + this->colliderCylinder.base.acFlags &= ~AC_HIT; + if (this->colliderCylinder.base.ac->category != ACTORCAT_BOSS) { + bombf = (EnBombf*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOMBF, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, ENBOMBF_0); + if (bombf != NULL) { + bombf->unk_1F8 = 1; + bombf->timer = 0; + this->timer = 180; + this->actor.flags &= ~ACTOR_FLAG_1; + this->unk_204 = 0.0f; + } + } + } else { + if (func_80123F48(globalCtx, &this->actor.world.pos, 30.0f, 50.0f)) { + bombf = (EnBombf*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOMBF, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, ENBOMBF_0); + if (bombf != NULL) { + bombf->timer = 100; + this->timer = 180; + this->actor.flags &= ~ACTOR_FLAG_1; + this->unk_204 = 0.0f; + } + } else { + if (!Actor_HasParent(&this->actor, globalCtx)) { + Actor_LiftActor(&this->actor, globalCtx); + return; + } + player->actor.child = NULL; + player->heldActor = NULL; + player->interactRangeActor = NULL; + this->actor.parent = NULL; + player->stateFlags1 &= ~0x800; + this->actor.world.pos = this->actor.home.pos; + } + } + } else { + if (this->timer == 0) { + this->unk_204 += 0.05f; + if (this->unk_204 >= 1.0f) { + this->actor.flags |= ACTOR_FLAG_1; + } + } + + if (Actor_HasParent(&this->actor, globalCtx)) { + player->actor.child = NULL; + player->heldActor = NULL; + player->interactRangeActor = NULL; + this->actor.parent = NULL; + player->stateFlags1 &= ~0x800; + this->actor.world.pos = this->actor.home.pos; + } + } +} + +void func_808AEE3C(EnBombf* this, GlobalContext* globalCtx) { + if (Actor_HasParent(&this->actor, globalCtx)) { + this->unk_204 = 0.0f; + EnBombf_SetupAction(this, func_808AEF68); + this->actor.room = -1; + return; + } + + this->unk_204 = 1.0f; + if (!(this->actor.bgCheckFlags & 1)) { + Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 0.025f, 0.0f); + return; + } + + Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 1.5f, 0.0f); + if (this->actor.bgCheckFlags & 2) { + func_800B8EF4(globalCtx, &this->actor); + if (this->actor.velocity.y < -6.0f) { + this->actor.velocity.y *= -0.3f; + this->actor.bgCheckFlags &= ~1; + } + } else if (this->timer >= 4) { + Actor_LiftActor(&this->actor, globalCtx); + } +} + +void func_808AEF68(EnBombf* this, GlobalContext* globalCtx) { + if (Actor_HasNoParent(&this->actor, globalCtx)) { + EnBombf_SetupAction(this, func_808AEE3C); + this->actor.bgCheckFlags &= ~1; + func_808AEE3C(this, globalCtx); + } else { + this->actor.velocity.y = 0.0f; + } +} + +void func_808AEFD4(EnBombf* this, GlobalContext* globalCtx) { + if (this->colliderJntSph.elements->dim.modelSphere.radius == 0) { + this->actor.flags |= ACTOR_FLAG_20; + func_8013ECE0(this->actor.xzDistToPlayer, 255, 20, 150); + } + + this->colliderJntSph.elements->dim.modelSphere.radius = 100; + this->colliderJntSph.elements->dim.worldSphere.radius = 100; + + if (ENBOMBF_GET(&this->actor) == ENBOMBF_1) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderJntSph.base); + } + + if (globalCtx->envCtx.lightSettings.diffuseColor1[0] != 0) { + globalCtx->envCtx.lightSettings.diffuseColor1[0] -= 25; + } + + if (globalCtx->envCtx.lightSettings.diffuseColor1[1] != 0) { + globalCtx->envCtx.lightSettings.diffuseColor1[1] -= 25; + } + + if (globalCtx->envCtx.lightSettings.diffuseColor1[2] != 0) { + globalCtx->envCtx.lightSettings.diffuseColor1[2] -= 25; + } + + if (globalCtx->envCtx.lightSettings.ambientColor[0] != 0) { + globalCtx->envCtx.lightSettings.ambientColor[0] -= 25; + } + + if (globalCtx->envCtx.lightSettings.ambientColor[1] != 0) { + globalCtx->envCtx.lightSettings.ambientColor[1] -= 25; + } + + if (globalCtx->envCtx.lightSettings.ambientColor[2] != 0) { + globalCtx->envCtx.lightSettings.ambientColor[2] -= 25; + } + + if (this->timer == 0) { + Player* player = GET_PLAYER(globalCtx); + + if ((player->stateFlags1 & 0x800) && (&this->actor == player->heldActor)) { + player->actor.child = NULL; + player->heldActor = NULL; + player->interactRangeActor = NULL; + player->stateFlags1 &= ~0x800; + } + Actor_MarkForDeath(&this->actor); + } +} + +void EnBombf_Update(Actor* thisx, GlobalContext* globalCtx) { + Vec3f sp8C = { 0.0f, 0.0f, 0.0f }; + Vec3f sp80 = { 0.0f, 0.1f, 0.0f }; + Vec3f sp74 = { 0.0f, 0.0f, 0.0f }; + Vec3f sp68; + Vec3f sp5C = { 0.0f, 0.6f, 0.0f }; + Color_RGBA8 sp58 = { 255, 255, 255, 255 }; + EnBombf* this = THIS; + s32 pad; + + if ((this->unk_1F8 != 0) && (this->timer != 0)) { + this->timer--; + } + + if ((this->unk_1FC == 0) && !Actor_HasParent(&this->actor, globalCtx) && + ((this->actor.xzDistToPlayer >= 20.0f) || (fabsf(this->actor.playerHeightRel) >= 80.0f))) { + this->unk_1FC = 1; + } + + this->actionFunc(this, globalCtx); + + if (ENBOMBF_GET(&this->actor) == ENBOMBF_0) { + Actor_MoveWithGravity(&this->actor); + } + + if (this->actor.gravity != 0.0f) { + DREG(6) = 1; + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 5.0f, 10.0f, 0.0f, 0x1F); + DREG(6) = 0; + } + + if (ENBOMBF_GET(&this->actor) == ENBOMBF_0) { + if ((this->actor.velocity.y > 0.0f) && (this->actor.bgCheckFlags & 0x10)) { + this->actor.velocity.y = -this->actor.velocity.y; + } + + if ((this->actor.speedXZ != 0.0f) && (this->actor.bgCheckFlags & 8)) { + s16 yDiff = BINANG_SUB(this->actor.wallYaw, this->actor.world.rot.y); + + if (ABS_ALT(yDiff) > 0x4000) { + this->actor.world.rot.y = + BINANG_SUB(this->actor.wallYaw - this->actor.world.rot.y + this->actor.wallYaw, 0x8000); + } + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMB_BOUND); + Actor_MoveWithGravity(&this->actor); + DREG(6) = 1; + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 5.0f, 10.0f, 0.0f, 0x1F); + DREG(6) = 0; + this->actor.speedXZ *= 0.7f; + this->actor.bgCheckFlags &= ~8; + } + + if ((this->colliderCylinder.base.acFlags & AC_HIT) || + ((this->colliderCylinder.base.ocFlags1 & OC1_HIT) && (this->colliderCylinder.base.oc->category == 5))) { + this->unk_1F8 = 1; + this->timer = 0; + } else if ((this->timer > 100) && func_80123F48(globalCtx, &this->actor.world.pos, 30.0f, 50.0f)) { + this->timer = 100; + } + + if (this->unk_1F8 != 0) { + sp5C.y = 0.2f; + sp68 = this->actor.world.pos; + sp68.y += 25.0f; + + if (this->timer < 127) { + if ((globalCtx->gameplayFrames % 2) == 0) { + EffectSsGSpk_SpawnFuse(globalCtx, &this->actor, &sp68, &sp8C, &sp74); + } + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_BOMB_IGNIT - SFX_FLAG); + sp68.y += 3.0f; + func_800B0DE0(globalCtx, &sp68, &sp8C, &sp5C, &sp58, &sp58, 0x32, 5); + } + + if ((this->timer == 3) || (this->timer == 30) || (this->timer == 50) || (this->timer == 70)) { + this->unk_1FE = this->unk_1FE >> 1; + } + + if ((this->timer < 100) && (this->timer & (this->unk_1FE + 1))) { + Math_SmoothStepToF(&this->unk_200, 150.0f, 1.0f, 150.0f / this->unk_1FE, 0.0f); + } else { + Math_SmoothStepToF(&this->unk_200, 0.0f, 1.0f, 150.0f / this->unk_1FE, 0.0f); + } + + if (this->timer < 3) { + Actor_SetScale(&this->actor, this->actor.scale.x + 0.002f); + } + + if (this->timer == 0) { + sp68 = this->actor.world.pos; + sp68.y += 10.0f; + + if (Actor_HasParent(&this->actor, globalCtx)) { + sp68.y += 30.0f; + } + + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, sp68.x, sp68.y, sp68.z, 0, 0, 0, + CLEAR_TAG_SMALL_EXPLOSION); + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_BOMB_EXPLOSION); + + globalCtx->envCtx.lightSettings.diffuseColor1[0] = globalCtx->envCtx.lightSettings.diffuseColor1[1] = + globalCtx->envCtx.lightSettings.diffuseColor1[2] = 250; + globalCtx->envCtx.lightSettings.ambientColor[0] = globalCtx->envCtx.lightSettings.ambientColor[1] = + globalCtx->envCtx.lightSettings.ambientColor[2] = 250; + + func_800DFD04(&globalCtx->mainCamera, 2, 11, 8); + + this->actor.params = ENBOMBF_1; + this->timer = 10; + this->actor.flags |= ACTOR_FLAG_20; + + EnBombf_SetupAction(this, func_808AEFD4); + } + } + } + + this->actor.focus.pos = this->actor.world.pos; + this->actor.focus.pos.y += 10.0f; + + if (ENBOMBF_GET(&this->actor) <= ENBOMBF_0) { + Collider_UpdateCylinder(&this->actor, &this->colliderCylinder); + if ((this->unk_204 >= 1.0f) && (this->unk_1FC != 0)) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); + } + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); + } + + if ((this->actor.scale.x >= 0.01f) && (ENBOMBF_GET(&this->actor) != ENBOMBF_1)) { + if (this->actor.depthInWater >= 20.0f) { + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 30, NA_SE_IT_BOMB_UNEXPLOSION); + Actor_MarkForDeath(&this->actor); + } else if (this->actor.bgCheckFlags & 0x40) { + this->actor.bgCheckFlags &= ~0x40; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMB_DROP_WATER); + } + } +} + +Gfx* func_808AF86C(GraphicsContext* gfxCtx, GlobalContext* globalCtx) { + Gfx* head = GRAPH_ALLOC(gfxCtx, sizeof(Gfx) * 6); + Gfx* gfx = head; + + Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + + gSPMatrix(gfx++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPEndDisplayList(gfx++); + + return head; +} + +void EnBombf_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnBombf* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if (ENBOMBF_GET(&this->actor) <= ENBOMBF_0) { + func_8012C28C(globalCtx->state.gfxCtx); + + if (ENBOMBF_GET(&this->actor) != ENBOMBF_0) { + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_bombf_DL_000340); + gSPDisplayList(POLY_OPA_DISP++, object_bombf_DL_000530); + + Matrix_InsertTranslation(0.0f, 1000.0f, 0.0f, MTXMODE_APPLY); + Matrix_Scale(this->unk_204, this->unk_204, this->unk_204, MTXMODE_APPLY); + } + + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 200, 255, 200, 255); + gDPPipeSync(POLY_OPA_DISP++); + gDPSetEnvColor(POLY_OPA_DISP++, (s8)this->unk_200, 20, 10, 0); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + { + Gfx* gfx = func_808AF86C(globalCtx->state.gfxCtx, globalCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(gfx)); + } + + gSPDisplayList(POLY_OPA_DISP++, object_bombf_DL_000408); + } else { + Collider_UpdateSpheres(0, &this->colliderJntSph); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Bombf/z_en_bombf.h b/src/overlays/actors/ovl_En_Bombf/z_en_bombf.h index 723d254cb4..b72edce8c5 100644 --- a/src/overlays/actors/ovl_En_Bombf/z_en_bombf.h +++ b/src/overlays/actors/ovl_En_Bombf/z_en_bombf.h @@ -7,13 +7,23 @@ struct EnBombf; typedef void (*EnBombfActionFunc)(struct EnBombf*, GlobalContext*); +#define ENBOMBF_GET(thisx) ((thisx)->params) + +#define ENBOMBF_0 0 +#define ENBOMBF_1 1 + typedef struct EnBombf { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xAC]; + /* 0x0144 */ ColliderCylinder colliderCylinder; + /* 0x0190 */ ColliderJntSph colliderJntSph; + /* 0x01B0 */ ColliderJntSphElement colliderJntSphElements[1]; /* 0x01F0 */ s16 timer; - /* 0x01F2 */ char unk_1F2[0x2]; /* 0x01F4 */ EnBombfActionFunc actionFunc; - /* 0x01F8 */ char unk_1F8[0x10]; + /* 0x01F8 */ s32 unk_1F8; + /* 0x01FC */ u8 unk_1FC; + /* 0x01FE */ s16 unk_1FE; + /* 0x0200 */ f32 unk_200; + /* 0x0204 */ f32 unk_204; } EnBombf; // size = 0x208 extern const ActorInit En_Bombf_InitVars; diff --git a/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c b/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c index 33b7e30581..300679a4e5 100644 --- a/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c +++ b/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c @@ -74,44 +74,36 @@ static ColliderCylinderInit sCylinderInit = { { 10, 30, 0, { 0, 0, 0 } }, }; -static u16 D_80C00A44[] = { - 0x0719, - 0x071A, - 0x071B, - 0x0708, +u16 D_80C00A44[] = { 0x719, 0x71A, 0x71B, 0x708 }; + +u16 D_80C00A4C[] = { 0x739, 0x73A, 0x73B, 0x000 }; + +u16 D_80C00A54[] = { + 0x739, 0x73A, 0x73B, 0x714, 0x709, 0x70A, 0x70B, 0x70C, 0x70D, 0x70E, 0x70F, 0x712, 0x713, }; -static u16 D_80C00A4C[] = { - 0x0739, - 0x073A, - 0x073B, - 0x0000, +u16 D_80C00A70[] = { + 0x739, 0x73A, 0x73B, 0x759, 0x753, 0x754, 0x755, 0x756, 0x70D, 0x757, 0x758, 0x712, 0x713, }; -static u16 D_80C00A54[] = { 0x0739, 0x073A, 0x073B, 0x0714, 0x0709, 0x070A, 0x070B, - 0x070C, 0x070D, 0x070E, 0x070F, 0x0712, 0x0713 }; - -static u16 D_80C00A70[] = { 0x0739, 0x073A, 0x073B, 0x0759, 0x0753, 0x0754, 0x0755, - 0x0756, 0x070D, 0x0757, 0x0758, 0x0712, 0x0713 }; - -static u16 D_80C00A8C[] = { - 0x0736, - 0x0737, - 0x0738, - 0x074E, -}; +u16 D_80C00A8C[] = { 0x736, 0x737, 0x738, 0x74E }; static AnimationHeader* sAnimations[] = { - &object_cs_Anim_0064B8, &object_cs_Anim_00FAF4, &object_cs_Anim_0057C8, &object_cs_Anim_0053F4, + &gBomberIdleAnim, &object_cs_Anim_00FAF4, &object_cs_Anim_0057C8, &object_cs_Anim_0053F4, &object_cs_Anim_002044, &object_cs_Anim_01007C, &object_cs_Anim_00349C, &object_cs_Anim_004960, &object_cs_Anim_005128, &object_cs_Anim_004C1C, &object_cs_Anim_001A1C, &object_cs_Anim_003EE4, &object_cs_Anim_00478C, &object_cs_Anim_00433C, &object_cs_Anim_0060E8, &object_cs_Anim_001708, &object_cs_Anim_005DC4, &object_cs_Anim_0026B0, &object_cs_Anim_0036B0, &object_cs_Anim_0031C4, }; -static u8 D_80C00AE4[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, - 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, +u8 D_80C00AE4[] = { + ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, + ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_LOOP, + ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_LOOP, +}; + +s16 D_80C00AF8[] = { + 0x4000, 60, 0x4000, 30, 0xC000, 30, 0xC000, 60, }; void EnBomjima_Init(Actor* thisx, GlobalContext* globalCtx) { @@ -122,10 +114,10 @@ void EnBomjima_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.colChkInfo.mass = MASS_IMMOVABLE; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 19.0f); this->actor.gravity = -3.0f; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_cs_Skel_00F82C, &object_cs_Anim_0064B8, this->jointTable, - this->morphTable, 21); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_cs_Skel_00F82C, &gBomberIdleAnim, this->jointTable, + this->morphTable, OBJECT_CS_LIMB_MAX); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - gSaveContext.weekEventReg[83] &= (u8)~4; + gSaveContext.save.weekEventReg[83] &= (u8)~4; this->actor.targetMode = 0; this->unk_2E6 = ENBOMJIMA_GET_F0(&this->actor); this->unk_2E4 = ENBOMJIMA_GET_F(&this->actor); @@ -147,8 +139,8 @@ void EnBomjima_Init(Actor* thisx, GlobalContext* globalCtx) { func_80BFFCFC(this); } - if ((gSaveContext.weekEventReg[75] & 0x40) || (gSaveContext.weekEventReg[73] & 0x10) || - (gSaveContext.weekEventReg[85] & 2)) { + if ((gSaveContext.save.weekEventReg[75] & 0x40) || (gSaveContext.save.weekEventReg[73] & 0x10) || + (gSaveContext.save.weekEventReg[85] & 2)) { Actor_MarkForDeath(&this->actor); } } @@ -174,12 +166,12 @@ void func_80BFE32C(EnBomjima* this, GlobalContext* globalCtx, s32 arg2) { case 0: if (player->transformation == PLAYER_FORM_DEKU) { this->actor.textId = 0x759; - if (!(gSaveContext.weekEventReg[73] & 0x20)) { + if (!(gSaveContext.save.weekEventReg[73] & 0x20)) { this->actor.textId = 0x708; } } else if (player->transformation == PLAYER_FORM_HUMAN) { this->actor.textId = 0x75A; - if (!(gSaveContext.weekEventReg[84] & 0x80)) { + if (!(gSaveContext.save.weekEventReg[84] & 0x80)) { this->actor.textId = 0x719; } } else if ((this->unk_2C8 == 1) || (this->unk_2C8 == 2)) { @@ -358,18 +350,18 @@ void func_80BFEB64(EnBomjima* this, GlobalContext* globalCtx) { func_80BFE32C(this, globalCtx, 0); if (player->transformation == PLAYER_FORM_DEKU) { - if (gSaveContext.weekEventReg[73] & 0x20) { + if (gSaveContext.save.weekEventReg[73] & 0x20) { this->unk_2C8 = 3; func_80BFE32C(this, globalCtx, 3); - } else if (gSaveContext.weekEventReg[77] & 2) { + } else if (gSaveContext.save.weekEventReg[77] & 2) { this->unk_2C8 = 11; func_80BFE32C(this, globalCtx, 2); } } else if (player->transformation == PLAYER_FORM_HUMAN) { - if (gSaveContext.weekEventReg[84] & 0x80) { + if (gSaveContext.save.weekEventReg[84] & 0x80) { this->unk_2C8 = 0; func_80BFE32C(this, globalCtx, 3); - } else if (gSaveContext.weekEventReg[85] & 1) { + } else if (gSaveContext.save.weekEventReg[85] & 1) { this->unk_2C8 = 11; func_80BFE32C(this, globalCtx, 2); } @@ -468,7 +460,7 @@ void func_80BFF03C(EnBomjima* this, GlobalContext* globalCtx) { ActorCutscene_SetIntentToPlay(this->unk_2D4[0]); } else { player->stateFlags1 &= ~0x20; - gSaveContext.weekEventReg[83] &= (u8)~4; + gSaveContext.save.weekEventReg[83] &= (u8)~4; this->actor.world.rot.y = Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)); this->unk_2DC = Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)); ActorCutscene_StartAndSetUnkLinkFields(this->unk_2D4[0], &this->actor); @@ -514,11 +506,11 @@ void func_80BFF174(EnBomjima* this, GlobalContext* globalCtx) { } if (player->transformation == PLAYER_FORM_DEKU) { - if (gSaveContext.weekEventReg[73] & 0x20) { + if (gSaveContext.save.weekEventReg[73] & 0x20) { this->unk_2C8 = 3; func_80BFE32C(this, globalCtx, 3); } else { - if (!(gSaveContext.weekEventReg[77] & 2)) { + if (!(gSaveContext.save.weekEventReg[77] & 2)) { if (this->unk_2E8 == 0) { this->unk_2C8 = 4; } else { @@ -530,11 +522,11 @@ void func_80BFF174(EnBomjima* this, GlobalContext* globalCtx) { func_80BFE32C(this, globalCtx, 2); } } else if (player->transformation == PLAYER_FORM_HUMAN) { - if (gSaveContext.weekEventReg[84] & 0x80) { + if (gSaveContext.save.weekEventReg[84] & 0x80) { this->unk_2C8 = 0; func_80BFE32C(this, globalCtx, 3); } else { - if (!(gSaveContext.weekEventReg[85] & 1)) { + if (!(gSaveContext.save.weekEventReg[85] & 1)) { if (this->unk_2EA == 0) { this->unk_2C8 = 4; } else { @@ -574,7 +566,7 @@ void func_80BFF430(EnBomjima* this, GlobalContext* globalCtx) { bombal->unk_150 = 0.0f; bombal->unk_14C = this->unk_2F4; Actor_ChangeFocus(&this->actor, globalCtx, &bombal->actor); - gSaveContext.weekEventReg[83] &= (u8)~4; + gSaveContext.save.weekEventReg[83] &= (u8)~4; func_80BFE65C(this); func_801477B4(globalCtx); this->actionFunc = func_80BFEA94; @@ -589,7 +581,7 @@ void func_80BFF4F4(EnBomjima* this) { } void func_80BFF52C(EnBomjima* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 4) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 4) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); if (globalCtx->msgCtx.choiceIndex == 0) { Player* player = GET_PLAYER(globalCtx); @@ -632,7 +624,7 @@ void func_80BFF6CC(EnBomjima* this, GlobalContext* globalCtx) { f32 curFrame = this->skelAnime.curFrame; if (this->unk_2CC <= curFrame) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); func_80BFE494(this, 1, 1.0f); this->actionFunc = func_80BFF754; @@ -640,21 +632,7 @@ void func_80BFF6CC(EnBomjima* this, GlobalContext* globalCtx) { } } -#ifdef NON_EQUIVALENT -// Data indexing is wrong - -typedef struct { - /* 0x00 */ s16 unk_00; - /* 0x02 */ s16 unk_02; -} EnBombjimaStruct; - void func_80BFF754(EnBomjima* this, GlobalContext* globalCtx) { - static EnBombjimaStruct D_80C00AF8[] = { - { 0x4000, 0x003C }, - { 0x4000, 0x001E }, - { 0xC000, 0x001E }, - { 0xC000, 0x003C }, - }; Player* player = GET_PLAYER(globalCtx); Vec3f spA0; EnBombal* temp_s3; @@ -688,13 +666,12 @@ void func_80BFF754(EnBomjima* this, GlobalContext* globalCtx) { temp_s3 = (EnBombal*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_BOMJIMA, spA0.x, spA0.y, spA0.z, 0, 0, 0, i + 32); if (temp_s3 != NULL) { - s32 idx1 = (i * 2) - 1; - s32 idx2 = i * 2; + s32 index = (i * 2) - 2; Math_Vec3f_Copy(&spA0, &this->actor.world.pos); - spA0.x += Math_SinS(D_80C00AF8[idx1 - 1].unk_00 + this->actor.world.rot.y) * D_80C00AF8[idx2].unk_02; - spA0.z += Math_CosS(D_80C00AF8[idx2].unk_00 + this->actor.world.rot.y) * D_80C00AF8[idx2].unk_02; + spA0.x += Math_SinS(D_80C00AF8[(i * 2) - 2] + this->actor.world.rot.y) * D_80C00AF8[index + 1]; + spA0.z += Math_CosS(D_80C00AF8[index] + this->actor.world.rot.y) * D_80C00AF8[index + 1]; Math_Vec3f_Copy(&temp_s3->unk_2A4, &spA0); } @@ -704,15 +681,6 @@ void func_80BFF754(EnBomjima* this, GlobalContext* globalCtx) { ActorCutscene_StartAndSetUnkLinkFields(this->unk_2D4[1], &this->actor); this->actionFunc = func_80BFF9B0; } -#else -static s16 D_80C00AF8[][2] = { - { 0x4000, 0x003C }, - { 0x4000, 0x001E }, - { 0xC000, 0x001E }, - { 0xC000, 0x003C }, -}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80BFF754.s") -#endif void func_80BFF9B0(EnBomjima* this, GlobalContext* globalCtx) { if (D_80C009F0 >= 4) { @@ -721,31 +689,31 @@ void func_80BFF9B0(EnBomjima* this, GlobalContext* globalCtx) { D_80C009F0 = 0; this->unk_2C8 = 9; if (player->transformation == PLAYER_FORM_DEKU) { - gSaveContext.weekEventReg[73] |= 0x10; - gSaveContext.weekEventReg[77] |= 2; + gSaveContext.save.weekEventReg[73] |= 0x10; + gSaveContext.save.weekEventReg[77] |= 2; } else { - gSaveContext.weekEventReg[85] |= 2; - gSaveContext.weekEventReg[85] |= 1; + gSaveContext.save.weekEventReg[85] |= 2; + gSaveContext.save.weekEventReg[85] |= 1; } - gSaveContext.weekEventReg[11] &= (u8)~1; - gSaveContext.weekEventReg[11] &= (u8)~2; - gSaveContext.weekEventReg[11] &= (u8)~4; - gSaveContext.weekEventReg[11] &= (u8)~8; - gSaveContext.weekEventReg[11] &= (u8)~0x10; + gSaveContext.save.weekEventReg[11] &= (u8)~1; + gSaveContext.save.weekEventReg[11] &= (u8)~2; + gSaveContext.save.weekEventReg[11] &= (u8)~4; + gSaveContext.save.weekEventReg[11] &= (u8)~8; + gSaveContext.save.weekEventReg[11] &= (u8)~0x10; - gSaveContext.weekEventReg[76] &= (u8)~1; - gSaveContext.weekEventReg[76] &= (u8)~2; - gSaveContext.weekEventReg[76] &= (u8)~4; - gSaveContext.weekEventReg[76] &= (u8)~8; - gSaveContext.weekEventReg[76] &= (u8)~0x10; + gSaveContext.save.weekEventReg[76] &= (u8)~1; + gSaveContext.save.weekEventReg[76] &= (u8)~2; + gSaveContext.save.weekEventReg[76] &= (u8)~4; + gSaveContext.save.weekEventReg[76] &= (u8)~8; + gSaveContext.save.weekEventReg[76] &= (u8)~0x10; - gSaveContext.unk_FE6 = 0; - gSaveContext.unk_FE7[0] = 0; - gSaveContext.unk_FE7[1] = 0; - gSaveContext.unk_FE7[2] = 0; - gSaveContext.unk_FE7[3] = 0; - gSaveContext.unk_FE7[4] = 0; + gSaveContext.save.bombersCaughtNum = 0; + gSaveContext.save.bombersCaughtOrder[0] = 0; + gSaveContext.save.bombersCaughtOrder[1] = 0; + gSaveContext.save.bombersCaughtOrder[2] = 0; + gSaveContext.save.bombersCaughtOrder[3] = 0; + gSaveContext.save.bombersCaughtOrder[4] = 0; func_80BFE494(this, 3, 1.0f); this->unk_2C8 = 9; @@ -761,7 +729,7 @@ void func_80BFF9B0(EnBomjima* this, GlobalContext* globalCtx) { } void func_80BFFB40(EnBomjima* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); func_80BFE494(this, 15, 1.0f); D_80C009F0 = 100; @@ -937,15 +905,18 @@ void func_80C00284(EnBomjima* this, GlobalContext* globalCtx) { this->unk_2BC &= 1; } - if ((player->transformation != PLAYER_FORM_GORON) && (player->transformation != PLAYER_FORM_ZORA)) { - if (player->transformation == PLAYER_FORM_HUMAN) { - this->unk_28E = -4000; - } - } else { - this->unk_28E = -6000; + switch (player->transformation) { + case PLAYER_FORM_HUMAN: + this->unk_28E = -0xFA0; + break; + + case PLAYER_FORM_GORON: + case PLAYER_FORM_ZORA: + this->unk_28E = -0x1770; + break; } - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { this->collider.dim.radius = 10; this->collider.dim.height = 30; if ((this->unk_2A0 == 4) || (this->unk_2CA == 1) || ((this->unk_2CA == 3) && (this->unk_2C8 >= 2))) { diff --git a/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c b/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c index 2989bbd02e..c18a942095 100644 --- a/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c +++ b/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c @@ -78,8 +78,8 @@ void EnBomjimb_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.colChkInfo.mass = MASS_IMMOVABLE; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 19.0f); this->actor.gravity = -2.0f; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_cs_Skel_00F82C, &object_cs_Anim_0064B8, this->jointTable, - this->morphTable, 21); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_cs_Skel_00F82C, &gBomberIdleAnim, this->jointTable, + this->morphTable, OBJECT_CS_LIMB_MAX); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); this->actor.targetMode = 6; Actor_SetScale(&this->actor, 0.01f); @@ -99,38 +99,38 @@ void EnBomjimb_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_2C6 = ENBOMJIMB_F0_0; } - if ((gSaveContext.weekEventReg[73] & 0x10) || (gSaveContext.weekEventReg[85] & 2)) { + if ((gSaveContext.save.weekEventReg[73] & 0x10) || (gSaveContext.save.weekEventReg[85] & 2)) { switch (this->unk_2C8) { case ENBOMJIMB_F_0: - if (gSaveContext.weekEventReg[11] & 1) { + if (gSaveContext.save.weekEventReg[11] & 1) { Actor_MarkForDeath(&this->actor); return; } break; case ENBOMJIMB_F_1: - if (gSaveContext.weekEventReg[11] & 2) { + if (gSaveContext.save.weekEventReg[11] & 2) { Actor_MarkForDeath(&this->actor); return; } break; case ENBOMJIMB_F_2: - if (gSaveContext.weekEventReg[11] & 4) { + if (gSaveContext.save.weekEventReg[11] & 4) { Actor_MarkForDeath(&this->actor); return; } break; case ENBOMJIMB_F_3: - if (gSaveContext.weekEventReg[11] & 8) { + if (gSaveContext.save.weekEventReg[11] & 8) { Actor_MarkForDeath(&this->actor); return; } break; case ENBOMJIMB_F_4: - if (gSaveContext.weekEventReg[11] & 0x10) { + if (gSaveContext.save.weekEventReg[11] & 0x10) { Actor_MarkForDeath(&this->actor); return; } @@ -138,8 +138,8 @@ void EnBomjimb_Init(Actor* thisx, GlobalContext* globalCtx) { } } - if ((!(gSaveContext.weekEventReg[73] & 0x10) && !(gSaveContext.weekEventReg[85] & 2)) || - (gSaveContext.weekEventReg[75] & 0x40)) { + if ((!(gSaveContext.save.weekEventReg[73] & 0x10) && !(gSaveContext.save.weekEventReg[85] & 2)) || + (gSaveContext.save.weekEventReg[75] & 0x40)) { Actor_MarkForDeath(&this->actor); return; } @@ -160,7 +160,7 @@ void EnBomjimb_Destroy(Actor* thisx, GlobalContext* globalCtx) { void func_80C0113C(EnBomjimb* this, s32 arg1, f32 arg2) { static AnimationHeader* sAnimations[] = { - &object_cs_Anim_0064B8, &object_cs_Anim_00FAF4, &object_cs_Anim_0057C8, &object_cs_Anim_0053F4, + &gBomberIdleAnim, &object_cs_Anim_00FAF4, &object_cs_Anim_0057C8, &object_cs_Anim_0053F4, &object_cs_Anim_002044, &object_cs_Anim_01007C, &object_cs_Anim_00349C, &object_cs_Anim_004960, &object_cs_Anim_005128, &object_cs_Anim_004C1C, &object_cs_Anim_002930, &object_cs_Anim_001A1C, &object_cs_Anim_003EE4, &object_cs_Anim_00478C, &object_cs_Anim_00433C, &object_cs_Anim_0060E8, @@ -209,7 +209,7 @@ void func_80C012E0(EnBomjimb* this) { s32 func_80C012FC(EnBomjimb* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (!func_801690CC(globalCtx) && (this->actor.xzDistToPlayer < 40.0f) && + if (!Play_InCsMode(globalCtx) && (this->actor.xzDistToPlayer < 40.0f) && (fabsf(player->actor.world.pos.y - this->actor.world.pos.y) < 50.0f) && (globalCtx->msgCtx.unk11F10 == 0)) { this->actor.speedXZ = 0.0f; func_80C02740(this, globalCtx); @@ -671,8 +671,8 @@ void func_80C02740(EnBomjimb* this, GlobalContext* globalCtx) { return; } - if (((player->transformation == PLAYER_FORM_DEKU) && !(gSaveContext.weekEventReg[73] & 0x10)) || - ((player->transformation == PLAYER_FORM_HUMAN) && !(gSaveContext.weekEventReg[85] & 2))) { + if (((player->transformation == PLAYER_FORM_DEKU) && !(gSaveContext.save.weekEventReg[73] & 0x10)) || + ((player->transformation == PLAYER_FORM_HUMAN) && !(gSaveContext.save.weekEventReg[85] & 2))) { func_80C0113C(this, 17, 1.0f); Message_StartTextbox(globalCtx, 0x72E, &this->actor); player->stateFlags1 |= 0x10000000; @@ -683,13 +683,13 @@ void func_80C02740(EnBomjimb* this, GlobalContext* globalCtx) { return; } - idx = gSaveContext.unk_FE6; + idx = gSaveContext.save.bombersCaughtNum; Message_StartTextbox(globalCtx, D_80C03230[idx], &this->actor); - idx = gSaveContext.unk_FE6; - gSaveContext.unk_FE7[idx] = this->unk_2C8 + 1; - gSaveContext.unk_FE6++; + idx = gSaveContext.save.bombersCaughtNum; + gSaveContext.save.bombersCaughtOrder[idx] = this->unk_2C8 + 1; + gSaveContext.save.bombersCaughtNum++; - if (gSaveContext.unk_FE6 > 4) { + if (gSaveContext.save.bombersCaughtNum > 4) { func_801A3098(0x922); } else { Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_PIECE_OF_HEART); @@ -697,32 +697,32 @@ void func_80C02740(EnBomjimb* this, GlobalContext* globalCtx) { switch (this->unk_2C8) { case ENBOMJIMB_F_0: - gSaveContext.weekEventReg[76] |= 1; - gSaveContext.weekEventReg[11] |= 1; + gSaveContext.save.weekEventReg[76] |= 1; + gSaveContext.save.weekEventReg[11] |= 1; break; case ENBOMJIMB_F_1: - gSaveContext.weekEventReg[76] |= 2; - gSaveContext.weekEventReg[11] |= 2; + gSaveContext.save.weekEventReg[76] |= 2; + gSaveContext.save.weekEventReg[11] |= 2; break; case ENBOMJIMB_F_2: - gSaveContext.weekEventReg[76] |= 4; - gSaveContext.weekEventReg[11] |= 4; + gSaveContext.save.weekEventReg[76] |= 4; + gSaveContext.save.weekEventReg[11] |= 4; break; case ENBOMJIMB_F_3: - gSaveContext.weekEventReg[76] |= 8; - gSaveContext.weekEventReg[11] |= 8; + gSaveContext.save.weekEventReg[76] |= 8; + gSaveContext.save.weekEventReg[11] |= 8; break; case ENBOMJIMB_F_4: - gSaveContext.weekEventReg[76] |= 0x10; - gSaveContext.weekEventReg[11] |= 0x10; + gSaveContext.save.weekEventReg[76] |= 0x10; + gSaveContext.save.weekEventReg[11] |= 0x10; break; } - if (!func_801690CC(globalCtx)) { + if (!Play_InCsMode(globalCtx)) { Player* player = GET_PLAYER(globalCtx); player->stateFlags1 |= 0x10000000; @@ -758,9 +758,9 @@ void func_80C02A14(EnBomjimb* this, GlobalContext* globalCtx) { player->actor.freezeTimer = 3; } - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); - if ((this->unk_2CA == 8) && (gSaveContext.unk_FE6 >= 5)) { + if ((this->unk_2CA == 8) && (gSaveContext.save.bombersCaughtNum >= 5)) { func_80C02CA4(this, globalCtx); } else { if (this->unk_2CA == 8) { @@ -777,7 +777,7 @@ void func_80C02BCC(EnBomjimb* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1, 5000, 0); if (this->unk_2C0 == 0) { player->actor.freezeTimer = 3; - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); this->unk_2C0 = 1; player->stateFlags1 &= ~0x10000000; @@ -800,8 +800,8 @@ void func_80C02CA4(EnBomjimb* this, GlobalContext* globalCtx) { globalCtx->unk_1887F = 0x56; gSaveContext.nextTransition = 3; } - gSaveContext.weekEventReg[75] |= 0x40; - gSaveContext.weekEventReg[83] |= 4; + gSaveContext.save.weekEventReg[75] |= 0x40; + gSaveContext.save.weekEventReg[83] |= 4; this->actionFunc = func_80C02DAC; } diff --git a/src/overlays/actors/ovl_En_Box/z_en_box.c b/src/overlays/actors/ovl_En_Box/z_en_box.c index f92b121ef2..a4a50dad29 100644 --- a/src/overlays/actors/ovl_En_Box/z_en_box.c +++ b/src/overlays/actors/ovl_En_Box/z_en_box.c @@ -470,7 +470,7 @@ void EnBox_WaitOpen(EnBox* this, GlobalContext* globalCtx) { u8 playerForm; playbackSpeedTable = sPlaybackSpeed; - playerForm = gSaveContext.playerForm; + playerForm = gSaveContext.save.playerForm; animHeader = sBigChestAnimations[playerForm]; playbackSpeed = playbackSpeedTable.data[playerForm]; } @@ -549,9 +549,9 @@ void EnBox_Open(EnBox* this, GlobalContext* globalCtx) { s32 bgId; u16 sfxId = 0; - if (Animation_OnFrame(&this->skelAnime, gSaveContext.playerForm == PLAYER_FORM_DEKU ? 14.0f : 30.0f)) { + if (Animation_OnFrame(&this->skelAnime, gSaveContext.save.playerForm == PLAYER_FORM_DEKU ? 14.0f : 30.0f)) { sfxId = NA_SE_EV_TBOX_UNLOCK; - } else if (Animation_OnFrame(&this->skelAnime, gSaveContext.playerForm == PLAYER_FORM_DEKU ? 15.0f : 90.0f)) { + } else if (Animation_OnFrame(&this->skelAnime, gSaveContext.save.playerForm == PLAYER_FORM_DEKU ? 15.0f : 90.0f)) { sfxId = NA_SE_EV_TBOX_OPEN; } if (sfxId != 0) { diff --git a/src/overlays/actors/ovl_En_Cha/z_en_cha.c b/src/overlays/actors/ovl_En_Cha/z_en_cha.c index 129045a6c7..0f340da3af 100644 --- a/src/overlays/actors/ovl_En_Cha/z_en_cha.c +++ b/src/overlays/actors/ovl_En_Cha/z_en_cha.c @@ -61,7 +61,7 @@ void EnCha_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.home.rot.z = 0; this->actionFunc = EnCha_Idle; this->actor.home.rot.x = this->actor.home.rot.z; - gSaveContext.weekEventReg[60] &= (u8)~4; + gSaveContext.save.weekEventReg[60] &= (u8)~4; } void EnCha_Destroy(Actor* thisx, GlobalContext* globalCtx) { @@ -83,16 +83,16 @@ void EnCha_Ring(EnCha* this, GlobalContext* globalCtx) { } void EnCha_Idle(EnCha* this, GlobalContext* globalCtx) { - if (gSaveContext.weekEventReg[60] & 4) { + if (gSaveContext.save.weekEventReg[60] & 4) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DOOR_BELL); - gSaveContext.weekEventReg[60] &= (u8)~4; + gSaveContext.save.weekEventReg[60] &= (u8)~4; this->actor.home.rot.z = 0x7D0; } if (this->collider.base.acFlags & AC_HIT) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DOOR_BELL); this->actor.home.rot.z = 0x7D0; - if (!(gSaveContext.weekEventReg[51] & 4)) { - gSaveContext.weekEventReg[51] |= 4; + if (!(gSaveContext.save.weekEventReg[51] & 4)) { + gSaveContext.save.weekEventReg[51] |= 4; this->actionFunc = EnCha_Ring; } } diff --git a/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c b/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c index 3d8623e7a0..53198c5941 100644 --- a/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c +++ b/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c @@ -210,7 +210,7 @@ void EnCne01_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_SetCylinder(globalCtx, &this->enHy.collider, &this->enHy.actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->enHy.actor.colChkInfo, &sDamageTable, &sColChkInfoInit); this->enHy.actor.flags &= ~ACTOR_FLAG_1; - this->enHy.path = func_8013D648(globalCtx, ENCNE01_GET_PATH(&this->enHy.actor), ENCNE01_NO_PATH); + this->enHy.path = SubS_GetPathByIndex(globalCtx, ENCNE01_GET_PATH(&this->enHy.actor), ENCNE01_NO_PATH); this->enHy.waitingOnInit = true; Actor_SetScale(&this->enHy.actor, 0.01f); this->enHy.actionFunc = EnCne01_FinishInit; @@ -299,7 +299,7 @@ void EnCne01_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* t void EnCne01_Draw(Actor* thisx, GlobalContext* globalCtx) { EnCne01* this = THIS; s32 i; - u8* shadowTex = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(u8[64][64])); + u8* shadowTex = GRAPH_ALLOC(globalCtx->state.gfxCtx, SUBS_SHADOW_TEX_SIZE); u8* shadowTexIter; OPEN_DISPS(globalCtx->state.gfxCtx); @@ -314,14 +314,14 @@ void EnCne01_Draw(Actor* thisx, GlobalContext* globalCtx) { EnCne01_TransformLimbDraw, &this->enHy.actor); Matrix_InsertXRotation_s(0, MTXMODE_NEW); - for (i = 0, shadowTexIter = shadowTex; i < (s32)sizeof(u8[64][64]); i++) { + for (i = 0, shadowTexIter = shadowTex; i < SUBS_SHADOW_TEX_SIZE; i++) { *shadowTexIter++ = 0; } for (i = 0; i < 5; i++) { - func_8013CD64(this->enHy.bodyPartsPos, &this->enHy.actor.world.pos, shadowTex, i / 5.0f, - ARRAY_COUNT(this->enHy.bodyPartsPos), gEnHyShadowSize, gEnHyBodyPartsIndex); + SubS_GenShadowTex(this->enHy.bodyPartsPos, &this->enHy.actor.world.pos, shadowTex, i / 5.0f, + ARRAY_COUNT(this->enHy.bodyPartsPos), gEnHyShadowSizes, gEnHyParentBodyParts); } - func_8013CF04(&this->enHy.actor, &globalCtx->state.gfxCtx, shadowTex); + SubS_DrawShadowTex(&this->enHy.actor, &globalCtx->state, shadowTex); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Col_Man/z_en_col_man.c b/src/overlays/actors/ovl_En_Col_Man/z_en_col_man.c index 5b5cf51333..6817c1830f 100644 --- a/src/overlays/actors/ovl_En_Col_Man/z_en_col_man.c +++ b/src/overlays/actors/ovl_En_Col_Man/z_en_col_man.c @@ -94,7 +94,7 @@ void EnColMan_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void func_80AFDD60(EnColMan* this) { - if (!(gSaveContext.weekEventReg[56] & 2)) { + if (!(gSaveContext.save.weekEventReg[56] & 2)) { this->actor.draw = func_80AFE414; this->actor.shape.yOffset = 700.0f; if (this->actor.params == EN_COL_MAN_HEART_PIECE) { @@ -123,14 +123,14 @@ void func_80AFDE00(EnColMan* this, GlobalContext* globalCtx) { this->actor.speedXZ = 0.0f; } } - if (!(gSaveContext.weekEventReg[56] & 2)) { + if (!(gSaveContext.save.weekEventReg[56] & 2)) { this->actor.shape.rot.y += 0x3E8; } if (Actor_HasParent(&this->actor, globalCtx)) { this->actor.parent = NULL; this->actor.draw = NULL; this->actionFunc = EnColMan_SetHeartPieceCollectedAndKill; - } else if (!(gSaveContext.weekEventReg[56] & 2)) { + } else if (!(gSaveContext.save.weekEventReg[56] & 2)) { Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 40.0f, 40.0f); } else { Actor_PickUp(&this->actor, globalCtx, GI_RECOVERY_HEART, 40.0f, 40.0f); @@ -138,8 +138,8 @@ void func_80AFDE00(EnColMan* this, GlobalContext* globalCtx) { } void EnColMan_SetHeartPieceCollectedAndKill(EnColMan* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx)) { - gSaveContext.weekEventReg[56] |= 2; + if (Message_GetState(&globalCtx->msgCtx) == 6 && Message_ShouldAdvance(globalCtx)) { + gSaveContext.save.weekEventReg[56] |= 2; Actor_MarkForDeath(&this->actor); } } diff --git a/src/overlays/actors/ovl_En_Cow/z_en_cow.c b/src/overlays/actors/ovl_En_Cow/z_en_cow.c index 73569c34b6..772d054abb 100644 --- a/src/overlays/actors/ovl_En_Cow/z_en_cow.c +++ b/src/overlays/actors/ovl_En_Cow/z_en_cow.c @@ -116,7 +116,7 @@ void EnCow_Init(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc = EnCow_Idle; - if (!(gSaveContext.weekEventReg[22] & 1) && (CURRENT_DAY != 1) && + if (!(gSaveContext.save.weekEventReg[22] & 1) && (CURRENT_DAY != 1) && (EN_COW_TYPE(thisx) == EN_COW_TYPE_ABDUCTED)) { Actor_MarkForDeath(&this->actor); return; @@ -153,7 +153,7 @@ void EnCow_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, 0.01f); this->flags = 0; - gSaveContext.weekEventReg[87] &= (u8)~1; + gSaveContext.save.weekEventReg[87] &= (u8)~1; } void EnCow_Destroy(Actor* thisx, GlobalContext* globalCtx) { @@ -200,7 +200,7 @@ void EnCow_UpdateAnimation(EnCow* this, GlobalContext* globalCtx) { } void EnCow_TalkEnd(EnCow* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { this->actor.flags &= ~ACTOR_FLAG_10000; func_801477B4(globalCtx); this->actionFunc = EnCow_Idle; @@ -224,7 +224,7 @@ void EnCow_GiveMilkWait(EnCow* this, GlobalContext* globalCtx) { } void EnCow_GiveMilk(EnCow* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { this->actor.flags &= ~ACTOR_FLAG_10000; func_801477B4(globalCtx); this->actionFunc = EnCow_GiveMilkWait; @@ -233,7 +233,7 @@ void EnCow_GiveMilk(EnCow* this, GlobalContext* globalCtx) { } void EnCow_CheckForEmptyBottle(EnCow* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { if (Interface_HasEmptyBottle()) { func_80151938(globalCtx, 0x32C9); // Text to give milk. this->actionFunc = EnCow_GiveMilk; @@ -289,8 +289,8 @@ void EnCow_Idle(EnCow* this, GlobalContext* globalCtx) { if (this->actor.xzDistToPlayer < 150.0f && ABS_ALT((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)) < 25000) { if (func_801A5100() == 4) { - if (!(gSaveContext.weekEventReg[87] & 1)) { - gSaveContext.weekEventReg[87] |= 1; + if (!(gSaveContext.save.weekEventReg[87] & 1)) { + gSaveContext.save.weekEventReg[87] |= 1; if (Interface_HasEmptyBottle()) { this->actor.textId = 0x32C9; // Text to give milk. } else { @@ -301,7 +301,7 @@ void EnCow_Idle(EnCow* this, GlobalContext* globalCtx) { this->actionFunc = EnCow_Talk; } } else { - gSaveContext.weekEventReg[87] &= (u8)~1; + gSaveContext.save.weekEventReg[87] &= (u8)~1; } } diff --git a/src/overlays/actors/ovl_En_Crow/z_en_crow.c b/src/overlays/actors/ovl_En_Crow/z_en_crow.c index 8293ddd941..bf77b1897b 100644 --- a/src/overlays/actors/ovl_En_Crow/z_en_crow.c +++ b/src/overlays/actors/ovl_En_Crow/z_en_crow.c @@ -15,14 +15,18 @@ void EnCrow_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnCrow_Update(Actor* thisx, GlobalContext* globalCtx); void EnCrow_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_8099AC8C(EnCrow* this, GlobalContext* globalCtx); -void func_8099B0CC(EnCrow* this, GlobalContext* globalCtx); -void func_8099B584(EnCrow* this, GlobalContext* globalCtx); -void func_8099B6C4(EnCrow* this, GlobalContext* globalCtx); -void func_8099B838(EnCrow* this, GlobalContext* globalCtx); -void func_8099B9E8(EnCrow* this, GlobalContext* globalCtx); +void EnCrow_SetupFlyIdle(EnCrow* this); +void EnCrow_FlyIdle(EnCrow* this, GlobalContext* globalCtx); +void EnCrow_SetupDiveAttack(EnCrow* this); +void EnCrow_DiveAttack(EnCrow* this, GlobalContext* globalCtx); +void EnCrow_CheckIfFrozen(EnCrow* this, GlobalContext* globalCtx); +void EnCrow_Damaged(EnCrow* this, GlobalContext* globalCtx); +void EnCrow_SetupDie(EnCrow* this); +void EnCrow_Die(EnCrow* this, GlobalContext* globalCtx); +void EnCrow_SetupRespawn(EnCrow* this); +void EnCrow_TurnAway(EnCrow* this, GlobalContext* globalCtx); +void EnCrow_Respawn(EnCrow* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Crow_InitVars = { ACTOR_EN_CROW, ACTORCAT_ENEMY, @@ -35,25 +39,36 @@ const ActorInit En_Crow_InitVars = { (ActorFunc)EnCrow_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_8099C070[1] = { +static ColliderJntSphElementInit sJntSphElementsInit[1] = { { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_HARD, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_HARD, + BUMP_ON, + OCELEM_ON, + }, { 1, { { 0, 0, 0 }, 20 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_8099C094 = { - { COLTYPE_HIT3, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, D_8099C070, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_HIT3, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, }; -// sColChkInfoInit -static CollisionCheckInfoInit D_8099C0A4 = { 1, 15, 30, 30 }; +static CollisionCheckInfoInit sColChkInfoInit = { 1, 15, 30, 30 }; -// static DamageTable sDamageTable = { -static DamageTable D_8099C0AC = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x1), /* Deku Stick */ DMG_ENTRY(1, 0x0), /* Horse trample */ DMG_ENTRY(1, 0x0), @@ -88,60 +103,470 @@ static DamageTable D_8099C0AC = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_8099C0D0[] = { +static s32 D_8099C0CC = 0; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 3000, ICHAIN_CONTINUE), ICHAIN_S8(hintId, 88, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -500, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_STOP), }; -#endif +void EnCrow_Init(Actor* thisx, GlobalContext* globalCtx) { + EnCrow* this = THIS; -extern ColliderJntSphElementInit D_8099C070[1]; -extern ColliderJntSphInit D_8099C094; -extern CollisionCheckInfoInit D_8099C0A4; -extern DamageTable D_8099C0AC; -extern InitChainEntry D_8099C0D0[]; + Actor_ProcessInitChain(&this->actor, sInitChain); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGuaySkel, &gGuayFlyAnim, this->jointTable, this->morphTable, + OBJECT_CROW_LIMB_MAX); + Collider_InitAndSetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderItems); + this->collider.elements->dim.worldSphere.radius = sJntSphInit.elements[0].dim.modelSphere.radius; + CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + ActorShape_Init(&this->actor.shape, 2000.0f, ActorShadow_DrawCircle, 20.0f); + D_8099C0CC = 0; + if (this->actor.parent != NULL) { + this->actor.flags &= ~ACTOR_FLAG_1; + } + EnCrow_SetupFlyIdle(this); +} -extern UNK_TYPE D_060000F0; +void EnCrow_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnCrow* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/EnCrow_Init.s") + Collider_DestroyJntSph(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/EnCrow_Destroy.s") +void EnCrow_SetupFlyIdle(EnCrow* this) { + this->timer = 100; + this->collider.base.acFlags |= AC_ON; + this->actionFunc = EnCrow_FlyIdle; + this->skelAnime.playSpeed = 1.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099AC58.s") +void EnCrow_FlyIdle(EnCrow* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 dist; + s32 onInitialAnimFrame; + s16 yaw; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099AC8C.s") + SkelAnime_Update(&this->skelAnime); + onInitialAnimFrame = Animation_OnFrame(&this->skelAnime, 0.0f); + this->actor.speedXZ = (Rand_ZeroOne() * 1.5f) + 3.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099B098.s") + if ((this->actor.parent != NULL) && (this->actor.parent->home.rot.z == 0)) { + this->actor.home.pos.x = this->actor.parent->world.pos.x; + this->actor.home.pos.z = this->actor.parent->world.pos.z; + dist = Actor_XZDistanceToPoint(&this->actor, &this->actor.parent->world.pos); + } else { + dist = 450.0f; + this->actor.flags |= ACTOR_FLAG_1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099B0CC.s") + if (this->actor.bgCheckFlags & 8) { + this->aimRotY = this->actor.wallYaw; + } else if (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) > 300.0f) { + this->aimRotY = Actor_YawToPoint(&this->actor, &this->actor.home.pos); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099B318.s") + if ((Math_SmoothStepToS(&this->actor.shape.rot.y, this->aimRotY, 5, 0x300, 0x10) == 0) && onInitialAnimFrame && + (Rand_ZeroOne() < 0.1f)) { -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099B384.s") + yaw = (Actor_YawToPoint(&this->actor, &this->actor.home.pos) - this->actor.shape.rot.y); + if (yaw > 0) { + this->aimRotY += Rand_S16Offset(0x1000, 0x1000); + } else { + this->aimRotY -= Rand_S16Offset(0x1000, 0x1000); + } + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KAICHO_CRY); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099B584.s") + if ((this->actor.depthInWater > -40.0f) || (this->actor.bgCheckFlags & 1)) { + this->aimRotX = -0x1000; + } else if (this->actor.world.pos.y < (this->actor.home.pos.y - 50.0f)) { + this->aimRotX = -Rand_S16Offset(0x800, 0x800); + } else if (this->actor.world.pos.y > (this->actor.home.pos.y + 50.0f)) { + this->aimRotX = Rand_S16Offset(0x800, 0x800); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099B6AC.s") + if ((Math_SmoothStepToS(&this->actor.shape.rot.x, this->aimRotX, 0xA, 0x100, 8) == 0) && onInitialAnimFrame && + (Rand_ZeroOne() < 0.1f)) { + if (this->actor.home.pos.y < this->actor.world.pos.y) { + this->aimRotX -= Rand_S16Offset(0x400, 0x400); + } else { + this->aimRotX += Rand_S16Offset(0x400, 0x400); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099B6C4.s") + this->aimRotX = CLAMP(this->aimRotX, -0x1000, 0x1000); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099B778.s") + if (this->actor.bgCheckFlags & 1) { + Math_ScaledStepToS(&this->actor.shape.rot.x, -0x100, 0x400); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099B838.s") + if (this->timer != 0) { + this->timer--; + } + if ((this->timer == 0) && + (((this->actor.xzDistToPlayer < 300.0f) && !(player->stateFlags1 & 0x800000)) || (dist < 300.0f)) && + (this->actor.depthInWater < -40.0f) && (Player_GetMask(globalCtx) != PLAYER_MASK_STONE)) { + if (dist < this->actor.xzDistToPlayer) { + this->actor.child = this->actor.parent; + } else { + this->actor.child = &player->actor; + } + EnCrow_SetupDiveAttack(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099B8EC.s") +void EnCrow_SetupDiveAttack(EnCrow* this) { + this->timer = 300; + this->actionFunc = EnCrow_DiveAttack; + this->actor.speedXZ = 4.0f; + this->skelAnime.playSpeed = 2.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099B9E8.s") +void EnCrow_DiveAttack(EnCrow* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 isFacingActor; + Vec3f pos; + s16 pitch; + s16 pitchTarget; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099BAB4.s") + SkelAnime_Update(&this->skelAnime); + if (this->timer != 0) { + this->timer--; + } + isFacingActor = Actor_ActorAIsFacingActorB(&this->actor, this->actor.child, 0x2800); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/EnCrow_Update.s") + if (isFacingActor) { + if (&player->actor == this->actor.child) { + pos.y = this->actor.child->world.pos.y + 20.0f; + } else { + pos.y = this->actor.child->world.pos.y + 40.0f; + } + pos.x = this->actor.child->world.pos.x; + pos.z = this->actor.child->world.pos.z; + pitch = Actor_PitchToPoint(&this->actor, &pos); + pitchTarget = CLAMP(pitch, -0x3000, 0x3000); + Math_SmoothStepToS(&this->actor.shape.rot.x, pitchTarget, 2, 0x400, 64); + } else { + Math_SmoothStepToS(&this->actor.shape.rot.x, -0x800, 2, 0x100, 16); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099BE48.s") + if (isFacingActor || (Actor_XZDistanceBetweenActors(&this->actor, this->actor.child) > 80.0f)) { + Math_SmoothStepToS(&this->actor.shape.rot.y, Actor_YawBetweenActors(&this->actor, this->actor.child), 4, 0xC00, + 0xC0); + } + if (((this->timer == 0) || ((&player->actor != this->actor.child) && (this->actor.child->home.rot.z != 0)) || + ((&player->actor == this->actor.child) && + ((Player_GetMask(globalCtx) == PLAYER_MASK_STONE) || (player->stateFlags1 & 0x800000))) || + ((this->collider.base.atFlags & AT_HIT) || (this->actor.bgCheckFlags & 9))) || + (this->actor.depthInWater > -40.0f)) { -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099BF20.s") + if (this->collider.base.atFlags & AT_HIT) { + this->collider.base.atFlags &= ~AT_HIT; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KAICHO_ATTACK); + } + EnCrow_SetupFlyIdle(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/EnCrow_Draw.s") +void EnCrow_CheckIfFrozen(EnCrow* this, GlobalContext* globalCtx) { + if (this->deathMode == 10) { + this->deathMode = 0; + this->effectAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, this->bodyPartsPos, 4, 2, 0.2f, 0.2f); + } +} + +void EnCrow_SetupDamaged(EnCrow* this, GlobalContext* globalCtx) { + f32 scale; + + this->actor.speedXZ *= Math_CosS(this->actor.world.rot.x); + this->actor.velocity.y = 0.0f; + Animation_Change(&this->skelAnime, &gGuayFlyAnim, 0.4f, 0.0f, 0.0f, ANIMMODE_LOOP_INTERP, -3.0f); + this->actor.shape.yOffset = 0.0f; + this->actor.targetArrowOffset = 0.0f; + this->actor.bgCheckFlags &= ~1; + scale = (this->actor.scale.x * 100.0f); + this->actor.world.pos.y += 20.0f * scale; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KAICHO_DEAD); + + if (this->actor.colChkInfo.damageEffect == 3) { + this->deathMode = 10; // Ice arrows + this->effectAlpha = 1.0f; + this->effectScale = 0.75f; + this->steamScale = 0.5f; + } else if (this->actor.colChkInfo.damageEffect == 4) { + this->deathMode = 20; // Light Arrows + this->effectAlpha = 4.0f; + this->steamScale = 0.5f; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->collider.elements->info.bumper.hitPos.x, + this->collider.elements->info.bumper.hitPos.y, this->collider.elements->info.bumper.hitPos.z, 0, 0, + 0, CLEAR_TAG_SMALL_LIGHT_RAYS); + } else if (this->actor.colChkInfo.damageEffect == 2) { + this->deathMode = 0; // Fire arrows + this->effectAlpha = 4.0f; + this->steamScale = 0.5f; + } + + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 40); + if (this->actor.flags & ACTOR_FLAG_8000) { + this->actor.speedXZ = 0.0f; + } + + this->collider.base.acFlags &= ~AC_ON; + this->actor.flags |= ACTOR_FLAG_10; + + this->actionFunc = EnCrow_Damaged; +} + +void EnCrow_Damaged(EnCrow* this, GlobalContext* globalCtx) { + Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); + this->actor.colorFilterTimer = 40; + + if (!(this->actor.flags & ACTOR_FLAG_8000)) { + if (this->deathMode != 10) { + Math_ScaledStepToS(&this->actor.shape.rot.x, 0x4000, 0x200); + this->actor.shape.rot.z += 0x1780; + } + if ((this->actor.bgCheckFlags & 1) || (this->actor.floorHeight == BGCHECK_Y_MIN)) { + EnCrow_CheckIfFrozen(this, globalCtx); + func_800B3030(globalCtx, &this->actor.world.pos, &gZeroVec3f, &gZeroVec3f, this->actor.scale.x * 10000.0f, + 0, 0); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 11, NA_SE_EN_EXTINCT); + + if (this->actor.parent != NULL) { + Actor_MarkForDeath(&this->actor); + return; + } + EnCrow_SetupDie(this); + } + } +} + +void EnCrow_SetupDie(EnCrow* this) { + this->actor.colorFilterTimer = 0; + this->actionFunc = EnCrow_Die; +} + +void EnCrow_Die(EnCrow* this, GlobalContext* globalCtx) { + f32 stepScale; + + if (this->actor.params != 0) { + stepScale = 0.006f; + } else { + stepScale = 0.002f; + } + if (Math_StepToF(&this->actor.scale.x, 0.0f, stepScale) != 0) { + if (this->actor.params == 0) { + D_8099C0CC++; + Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x80); + } else { + Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x90); + } + EnCrow_SetupRespawn(this); + } + this->actor.scale.z = this->actor.scale.y = this->actor.scale.x; +} + +void EnCrow_SetupTurnAway(EnCrow* this) { + this->timer = 100; + this->aimRotX = -0x1000; + this->actor.speedXZ = 3.5f; + this->aimRotY = this->actor.yawTowardsPlayer + 0x8000; + this->skelAnime.playSpeed = 2.0f; + if (this->actor.colChkInfo.damageEffect == 1) { + Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + } else { + Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + } + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + this->actionFunc = EnCrow_TurnAway; +} + +void EnCrow_TurnAway(EnCrow* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + + if (this->actor.bgCheckFlags & 8) { + this->aimRotY = this->actor.wallYaw; + } else { + this->aimRotY = this->actor.yawTowardsPlayer + 0x8000; + } + + Math_SmoothStepToS(&this->actor.shape.rot.y, this->aimRotY, 3, 0xC00, 0xC0); + Math_SmoothStepToS(&this->actor.shape.rot.x, this->aimRotX, 5, 0x100, 0x10); + + if (this->timer != 0) { + this->timer--; + } + + if (this->timer == 0) { + EnCrow_SetupFlyIdle(this); + } +} + +void EnCrow_SetupRespawn(EnCrow* this) { + if (D_8099C0CC == 10) { + this->actor.params = 1; + D_8099C0CC = 0; + this->collider.elements->dim.worldSphere.radius = sJntSphInit.elements->dim.modelSphere.radius * 0.03f * 100.0f; + } else { + this->actor.params = 0; + this->collider.elements->dim.worldSphere.radius = sJntSphInit.elements->dim.modelSphere.radius; + } + Animation_PlayLoop(&this->skelAnime, &gGuayFlyAnim); + Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.home.pos); + this->actor.shape.rot.x = 0; + this->actor.shape.rot.z = 0; + this->timer = 300; + this->actor.draw = NULL; + this->actor.shape.yOffset = 2000.0f; + this->actor.targetArrowOffset = 2000.0; + this->effectAlpha = 0.0f; + this->actionFunc = EnCrow_Respawn; +} + +void EnCrow_Respawn(EnCrow* this, GlobalContext* globalCtx) { + f32 target; + + if (this->timer != 0) { + this->timer--; + } + if (this->timer == 0) { + SkelAnime_Update(&this->skelAnime); + this->actor.draw = EnCrow_Draw; + if (this->actor.params != 0) { + target = 0.03f; + } else { + target = 0.01f; + } + if (Math_StepToF(&this->actor.scale.x, target, target * 0.1f)) { + this->actor.flags |= ACTOR_FLAG_1; + this->actor.flags &= ~ACTOR_FLAG_10; + this->actor.colChkInfo.health = 1; + EnCrow_SetupFlyIdle(this); + } + this->actor.scale.z = this->actor.scale.y = this->actor.scale.x; + } +} + +void EnCrow_UpdateDamage(EnCrow* this, GlobalContext* globalCtx) { + + if (this->collider.base.acFlags & AT_HIT) { + this->collider.base.acFlags &= ~AT_HIT; + Actor_SetDropFlag(&this->actor, &this->collider.elements->info); + + if (this->actor.colChkInfo.damageEffect == 1) { + EnCrow_SetupTurnAway(this); + + } else if (this->actor.colChkInfo.damageEffect == 5) { + this->deathMode = 31; // Stunned via deku nuts or zora barrier + this->effectAlpha = 2.0f; + this->steamScale = 0.5f; + EnCrow_SetupTurnAway(this); + + } else { + this->actor.colChkInfo.health = 0; + this->actor.flags &= ~ACTOR_FLAG_1; + Enemy_StartFinishingBlow(globalCtx, &this->actor); + EnCrow_SetupDamaged(this, globalCtx); + } + } +} + +void EnCrow_Update(Actor* thisx, GlobalContext* globalCtx) { + f32 pad; + EnCrow* this = (EnCrow*)thisx; + f32 height; + f32 scale; + + EnCrow_UpdateDamage(this, globalCtx); + this->actionFunc(this, globalCtx); + scale = this->actor.scale.x * 100.0f; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actor.world.rot.x = -this->actor.shape.rot.x; + + if (this->actionFunc != EnCrow_Respawn) { + if (this->actor.colChkInfo.health != 0) { + height = 20.0f * scale; + Actor_MoveWithoutGravity(&this->actor); + } else { + height = 0.0f; + Actor_MoveWithGravity(&this->actor); + } + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 12.0f * scale, 25.0f * scale, 50.0f * scale, 7); + } else { + height = 0.0f; + } + + this->collider.elements[0].dim.worldSphere.center.x = this->actor.world.pos.x; + this->collider.elements[0].dim.worldSphere.center.y = this->actor.world.pos.y + height; + this->collider.elements[0].dim.worldSphere.center.z = this->actor.world.pos.z; + + if (this->actionFunc == EnCrow_DiveAttack) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + if (this->collider.base.acFlags & AC_ON) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + if (this->actionFunc != EnCrow_Respawn) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + Actor_SetFocus(&this->actor, height); + + if ((this->actor.colChkInfo.health != 0) && (Animation_OnFrame(&this->skelAnime, 3.0f))) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KAICHO_FLUTTER); + } + if (this->effectAlpha > 0.0f) { + if (this->deathMode != 10) { + Math_StepToF(&this->effectAlpha, 0.0f, 0.05f); + this->steamScale = (this->effectAlpha + 1.0f) * 0.25f; + if (this->steamScale > 0.5f) { + this->steamScale = 0.5f; + } else { + this->steamScale = this->steamScale; + } + } else if (Math_StepToF(&this->effectScale, 0.5f, 0.0125f) == 0) { + func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); + } + } +} + +s32 EnCrow_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnCrow* this = (EnCrow*)thisx; + + if (this->actor.colChkInfo.health != 0) { + if (limbIndex == OBJECT_CROW_LIMB_UPPER_TAIL) { + rot->y += (s16)(0xC00 * sin_rad(this->skelAnime.curFrame * (M_PI / 4))); + } else if (limbIndex == OBJECT_CROW_LIMB_TAIL) { + rot->y += (s16)(0x1400 * sin_rad((this->skelAnime.curFrame + 2.5f) * (M_PI / 4))); + } + } + return false; +} + +void EnCrow_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnCrow* this = (EnCrow*)thisx; + + if (limbIndex == OBJECT_CROW_LIMB_BODY) { + Matrix_GetStateTranslationAndScaledX(2500.0f, this->bodyPartsPos); + return; + } + if ((limbIndex == OBJECT_CROW_LIMB_RIGHT_WING_TIP) || (limbIndex == OBJECT_CROW_LIMB_LEFT_WING_TIP) || + (limbIndex == OBJECT_CROW_LIMB_TAIL)) { + Matrix_GetStateTranslation(&this->bodyPartsPos[(limbIndex >> 1) - 1]); + } +} + +void EnCrow_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnCrow* this = (EnCrow*)thisx; + + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnCrow_OverrideLimbDraw, EnCrow_PostLimbDraw, &this->actor); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->bodyPartsPos, ARRAY_COUNT(this->bodyPartsPos), + this->actor.scale.x * 100.0f * this->steamScale, this->effectScale, this->effectAlpha, + this->deathMode); +} diff --git a/src/overlays/actors/ovl_En_Crow/z_en_crow.h b/src/overlays/actors/ovl_En_Crow/z_en_crow.h index e1d7631429..9076a198ca 100644 --- a/src/overlays/actors/ovl_En_Crow/z_en_crow.h +++ b/src/overlays/actors/ovl_En_Crow/z_en_crow.h @@ -2,6 +2,7 @@ #define Z_EN_CROW_H #include "global.h" +#include "objects/object_crow/object_crow.h" struct EnCrow; @@ -9,9 +10,20 @@ typedef void (*EnCrowActionFunc)(struct EnCrow*, GlobalContext*); typedef struct EnCrow { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; + /* 0x0144 */ SkelAnime skelAnime; /* 0x0188 */ EnCrowActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x110]; + /* 0x18C */ u8 deathMode; + /* 0x18E */ s16 timer; + /* 0x190 */ s16 aimRotX; + /* 0x192 */ s16 aimRotY; + /* 0x194 */ Vec3s jointTable[OBJECT_CROW_LIMB_MAX]; + /* 0x1CA */ Vec3s morphTable[OBJECT_CROW_LIMB_MAX]; + /* 0x200 */ ColliderJntSph collider; + /* 0x220 */ ColliderJntSphElement colliderItems[1]; + /* 0x260 */ Vec3f bodyPartsPos[4]; + /* 0x290 */ f32 effectAlpha; + /* 0x294 */ f32 steamScale; + /* 0x298 */ f32 effectScale; } EnCrow; // size = 0x29C extern const ActorInit En_Crow_InitVars; diff --git a/src/overlays/actors/ovl_En_Dai/z_en_dai.c b/src/overlays/actors/ovl_En_Dai/z_en_dai.c index 3b96d1b4d6..f8118e199b 100644 --- a/src/overlays/actors/ovl_En_Dai/z_en_dai.c +++ b/src/overlays/actors/ovl_En_Dai/z_en_dai.c @@ -179,7 +179,7 @@ s32 func_80B3E69C(EnDai* this, GlobalContext* globalCtx) { s32 ret = false; if ((globalCtx->csCtx.state != 0) && (globalCtx->sceneNum == SCENE_12HAKUGINMAE) && - (globalCtx->csCtx.currentCsIndex == 0) && !(gSaveContext.weekEventReg[30] & 1)) { + (globalCtx->csCtx.currentCsIndex == 0) && !(gSaveContext.save.weekEventReg[30] & 1)) { if (!(this->unk_1CE & 0x10)) { Flags_SetSwitch(globalCtx, 20); this->unk_1CE |= (0x80 | 0x10); @@ -194,7 +194,7 @@ s32 func_80B3E69C(EnDai* this, GlobalContext* globalCtx) { } else if (this->unk_1CE & 0x10) { this->unk_1CE &= ~0x10; this->unk_1CE |= 0x200; - gSaveContext.weekEventReg[30] |= 1; + gSaveContext.save.weekEventReg[30] |= 1; this->actionFunc = func_80B3F00C; } @@ -525,7 +525,7 @@ void EnDai_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_1CE = 0; this->unk_1D6 = 0; - if (gSaveContext.weekEventReg[33] & 0x80) { + if (gSaveContext.save.weekEventReg[33] & 0x80) { SubS_UpdateFlags(&this->unk_1CE, 3, 7); this->unk_1CE |= 0x80; this->unk_1CD = 0xFF; @@ -533,7 +533,7 @@ void EnDai_Init(Actor* thisx, GlobalContext* globalCtx) { return; } - if (gSaveContext.weekEventReg[30] & 1) { + if (gSaveContext.save.weekEventReg[30] & 1) { Actor_MarkForDeath(&this->actor); return; } @@ -564,7 +564,7 @@ void EnDai_Update(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); func_80B3E834(this); if (!(this->unk_1CE & 0x200)) { - func_8013C964(&this->actor, globalCtx, 0.0f, 0.0f, 0, this->unk_1CE & 7); + func_8013C964(&this->actor, globalCtx, 0.0f, 0.0f, EXCH_ITEM_NONE, this->unk_1CE & 7); } func_80B3E460(this); } diff --git a/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c b/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c index 011c0ebbd3..3d76b73919 100644 --- a/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c +++ b/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c @@ -67,7 +67,7 @@ void EnDaiku_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_278 = ENDAIKU_GET_FF(&this->actor); if (this->unk_278 == ENDAIKU_PARAMS_FF_3) { this->unk_288 = ENDAIKU_GET_FF00(&this->actor); - this->unk_258 = func_8013D648(globalCtx, this->unk_288, 0x3F); + this->unk_258 = SubS_GetPathByIndex(globalCtx, this->unk_288, 0x3F); } else if (this->unk_278 == ENDAIKU_PARAMS_FF_2) { this->unk_264 = -2000; } @@ -77,10 +77,11 @@ void EnDaiku_Init(Actor* thisx, GlobalContext* globalCtx) { this->collider.dim.height = 60; this->collider.dim.yShift = 0; this->actor.flags |= ACTOR_FLAG_8000000; - if ((gSaveContext.weekEventReg[63] & 0x80) || ((gSaveContext.day == 3) && gSaveContext.isNight)) { + if ((gSaveContext.save.weekEventReg[63] & 0x80) || + ((gSaveContext.save.day == 3) && gSaveContext.save.isNight)) { Actor_MarkForDeath(&this->actor); } - } else if ((gSaveContext.day == 3) && gSaveContext.isNight) { + } else if ((gSaveContext.save.day == 3) && gSaveContext.save.isNight) { Actor_MarkForDeath(&this->actor); } @@ -133,14 +134,14 @@ void func_8094373C(EnDaiku* this, s32 arg1) { void func_809437C8(EnDaiku* this) { if ((this->unk_288 != -1) && (this->unk_258 != 0)) { - if (!func_8013D68C(this->unk_258, this->unk_25C, &this->unk_26C)) { + if (!SubS_CopyPointFromPath(this->unk_258, this->unk_25C, &this->unk_26C)) { Actor_MarkForDeath(&this->actor); } } } void func_80943820(EnDaiku* this) { - s32 day = gSaveContext.day - 1; + s32 day = gSaveContext.save.day - 1; switch (this->unk_278) { case 0: @@ -167,7 +168,7 @@ void func_80943820(EnDaiku* this) { void func_809438F8(EnDaiku* this, GlobalContext* globalCtx) { f32 currentFrame = this->skelAnime.curFrame; s32 pad; - s32 day = gSaveContext.day - 1; + s32 day = gSaveContext.save.day - 1; s32 pad2; if (Player_GetMask(globalCtx) == PLAYER_MASK_KAFEIS_MASK) { @@ -241,7 +242,7 @@ void func_80943BDC(EnDaiku* this, GlobalContext* globalCtx) { } } - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); func_80943820(this); } @@ -255,7 +256,7 @@ void EnDaiku_Update(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); } - if ((this->unk_278 == ENDAIKU_PARAMS_FF_0) && (gSaveContext.day == 3) && (gSaveContext.isNight)) { + if ((this->unk_278 == ENDAIKU_PARAMS_FF_0) && (gSaveContext.save.day == 3) && (gSaveContext.save.isNight)) { Actor_MarkForDeath(&this->actor); return; } diff --git a/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c b/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c index 434e1c79fd..64a8c3d9b3 100644 --- a/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c +++ b/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c @@ -70,7 +70,7 @@ static ColliderCylinderInit sCylinderInit = { void func_80BE61D0(EnDaiku2* this) { if ((this->unk_27A != -1) && (this->unk_258 != 0)) { - if (func_8013D68C(this->unk_258, this->unk_25C, &this->unk_268) == 0) { + if (!SubS_CopyPointFromPath(this->unk_258, this->unk_25C, &this->unk_268)) { Actor_MarkForDeath(&this->actor); } } @@ -78,7 +78,7 @@ void func_80BE61D0(EnDaiku2* this) { void EnDaiku2_Init(Actor* thisx, GlobalContext* globalCtx) { EnDaiku2* this = THIS; - s32 day = gSaveContext.day; + s32 day = gSaveContext.save.day; this->actor.colChkInfo.mass = MASS_IMMOVABLE; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 40.0f); @@ -88,7 +88,7 @@ void EnDaiku2_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); this->unk_278 = ENDAIKU2_GET_7F(&this->actor); this->unk_27A = ENDAIKU2_GET_1F80(&this->actor); - this->unk_258 = func_8013D648(globalCtx, this->unk_27A, 0x3F); + this->unk_258 = SubS_GetPathByIndex(globalCtx, this->unk_27A, 0x3F); this->unk_280 = ENDAIKU2_GET_8000(&this->actor); Actor_SetScale(&this->actor, 0.01f); if (!this->unk_280) { @@ -163,10 +163,10 @@ s32 func_80BE64C0(EnDaiku2* this, GlobalContext* globalCtx) { } void func_80BE65B4(EnDaiku2* this, GlobalContext* globalCtx) { - switch (gSaveContext.day - 1) { + switch (gSaveContext.save.day - 1) { case 0: this->unk_28A = 0; - if (gSaveContext.weekEventReg[64] & 2) { + if (gSaveContext.save.weekEventReg[64] & 2) { this->unk_28A = 6; } func_80BE6408(this, 8); @@ -174,7 +174,7 @@ void func_80BE65B4(EnDaiku2* this, GlobalContext* globalCtx) { case 1: this->unk_28A = 2; - if (gSaveContext.weekEventReg[64] & 4) { + if (gSaveContext.save.weekEventReg[64] & 4) { this->unk_28A = 7; } func_80BE6408(this, 8); @@ -201,7 +201,7 @@ void func_80BE65B4(EnDaiku2* this, GlobalContext* globalCtx) { void func_80BE66E4(EnDaiku2* this, GlobalContext* globalCtx) { f32 sp9C = this->skelAnime.curFrame; - s32 sp98 = gSaveContext.day - 1; + s32 sp98 = gSaveContext.save.day - 1; s32 i; Vec3f sp88; Vec3f sp7C; @@ -279,7 +279,7 @@ void func_80BE66E4(EnDaiku2* this, GlobalContext* globalCtx) { } void func_80BE6B40(EnDaiku2* this, GlobalContext* globalCtx) { - s32 day = gSaveContext.day; + s32 day = gSaveContext.save.day; this->unk_288 = 1; if ((day != 3) && Flags_GetSwitch(globalCtx, this->unk_278)) { @@ -292,8 +292,8 @@ void func_80BE6B40(EnDaiku2* this, GlobalContext* globalCtx) { void func_80BE6BC0(EnDaiku2* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1, 0xBB8, 0x0); - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - s32 day = gSaveContext.day - 1; + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + s32 day = gSaveContext.save.day - 1; func_801477B4(globalCtx); @@ -307,11 +307,11 @@ void func_80BE6BC0(EnDaiku2* this, GlobalContext* globalCtx) { } else { switch (day) { case 0: - gSaveContext.weekEventReg[64] |= 2; + gSaveContext.save.weekEventReg[64] |= 2; break; case 1: - gSaveContext.weekEventReg[64] |= 4; + gSaveContext.save.weekEventReg[64] |= 4; break; } func_80BE65B4(this, globalCtx); diff --git a/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c b/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c index 9a6b678fc3..da9f37237f 100644 --- a/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c +++ b/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c @@ -6,7 +6,6 @@ #include "z_en_dekunuts.h" #include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" -#include "objects/object_dekunuts/object_dekunuts.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) @@ -119,8 +118,8 @@ void EnDekunuts_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->actor, sInitChain); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 35.0f); - SkelAnime_Init(globalCtx, &this->skelAnime, &object_dekunuts_Skel_002468, &object_dekunuts_Anim_00326C, - this->jointTable, this->morphTable, 10); + SkelAnime_Init(globalCtx, &this->skelAnime, &gDekuScrubSkel, &gDekuScrubIdleAnim, this->jointTable, + this->morphTable, DEKU_SCRUB_LIMB_MAX); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); this->unk_194 = ENDEKUNUTS_GET_FF00(&this->actor); @@ -147,26 +146,26 @@ void EnDekunuts_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void func_808BD348(EnDekunuts* this) { - this->unk_18E = 10; - this->unk_214 = 0.55f; - this->unk_218 = 0.82500005f; - this->unk_210 = 1.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffFrozenSteamScale = 0.82500005f; + this->drawDmgEffAlpha = 1.0f; this->collider.base.colType = COLTYPE_HIT3; this->unk_190 = 80; Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); } void func_808BD3B4(EnDekunuts* this, GlobalContext* globalCtx) { - if (this->unk_18E == 10) { - this->unk_18E = 0; + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->collider.base.colType = COLTYPE_HIT6; - this->unk_210 = 0.0f; - Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_21C, 8, 2, 0.2f, 0.2f); + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, 8, 2, 0.2f, 0.2f); } } void func_808BD428(EnDekunuts* this) { - Animation_PlayOnceSetSpeed(&this->skelAnime, &object_dekunuts_Anim_003180, 0.0f); + Animation_PlayOnceSetSpeed(&this->skelAnime, &gDekuScrubUpAnim, 0.0f); this->unk_190 = Rand_S16Offset(100, 50); this->collider.dim.height = 5; Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.home.pos); @@ -221,7 +220,7 @@ void func_808BD49C(EnDekunuts* this, GlobalContext* globalCtx) { } void func_808BD78C(EnDekunuts* this) { - Animation_PlayLoop(&this->skelAnime, &object_dekunuts_Anim_002FA4); + Animation_PlayLoop(&this->skelAnime, &gDekuScrubLookAroundAnim); this->unk_190 = 2; this->actionFunc = func_808BD7D4; } @@ -241,7 +240,7 @@ void func_808BD7D4(EnDekunuts* this, GlobalContext* globalCtx) { } void func_808BD870(EnDekunuts* this) { - Animation_MorphToLoop(&this->skelAnime, &object_dekunuts_Anim_00326C, -3.0f); + Animation_MorphToLoop(&this->skelAnime, &gDekuScrubIdleAnim, -3.0f); if (this->actionFunc == func_808BDA4C) { this->unk_190 = 4098; } else { @@ -280,7 +279,7 @@ void func_808BD8D8(EnDekunuts* this, GlobalContext* globalCtx) { } void func_808BDA08(EnDekunuts* this) { - Animation_PlayOnce(&this->skelAnime, &object_dekunuts_Anim_000168); + Animation_PlayOnce(&this->skelAnime, &gDekuScrubSpitAnim); this->unk_190 = this->unk_194; this->actionFunc = func_808BDA4C; } @@ -324,7 +323,7 @@ void func_808BDA4C(EnDekunuts* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_THROW); } } else if ((this->unk_190 >= 2) && Animation_OnFrame(&this->skelAnime, 12.0f)) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_dekunuts_Anim_000168, -3.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &gDekuScrubSpitAnim, -3.0f); if (this->unk_190 != 0) { this->unk_190--; } @@ -332,14 +331,14 @@ void func_808BDA4C(EnDekunuts* this, GlobalContext* globalCtx) { } void func_808BDC9C(EnDekunuts* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_dekunuts_Anim_002A5C, -5.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &gDekuScrubBurrowAnim, -5.0f); this->unk_190 = 0; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); this->actionFunc = func_808BDD54; } void func_808BDCF0(EnDekunuts* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_dekunuts_Anim_002A5C, -5.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &gDekuScrubBurrowAnim, -5.0f); this->collider.base.acFlags &= ~AC_ON; this->unk_190 = 80; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); @@ -367,7 +366,7 @@ void func_808BDD54(EnDekunuts* this, GlobalContext* globalCtx) { } void func_808BDE7C(EnDekunuts* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_dekunuts_Anim_002DD4, -3.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &gDekuScrubUnburrowAnim, -3.0f); this->collider.dim.height = 37; this->actor.colChkInfo.mass = 50; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DAMAGE); @@ -387,7 +386,7 @@ void func_808BDEF8(EnDekunuts* this, GlobalContext* globalCtx) { } void func_808BDF60(EnDekunuts* this) { - Animation_PlayLoop(&this->skelAnime, &object_dekunuts_Anim_003780); + Animation_PlayLoop(&this->skelAnime, &gDekuScrubRunAnim); this->unk_190 = 2; this->unk_18C = 0; this->collider.base.acFlags |= AC_ON; @@ -444,7 +443,7 @@ void func_808BDFB8(EnDekunuts* this, GlobalContext* globalCtx) { } void func_808BE1CC(EnDekunuts* this) { - Animation_PlayLoop(&this->skelAnime, &object_dekunuts_Anim_0033E4); + Animation_PlayLoop(&this->skelAnime, &gDekuScrubPantingAnim); this->unk_190 = 3; this->actor.speedXZ = 0.0f; if (this->unk_18D != 0) { @@ -467,7 +466,7 @@ void func_808BE22C(EnDekunuts* this, GlobalContext* globalCtx) { } void func_808BE294(EnDekunuts* this, s32 arg1) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_dekunuts_Anim_00259C, -3.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &gDekuScrubDamageAnim, -3.0f); if (this->actor.params == ENDEKUNUTS_GET_FF00_0) { this->actor.speedXZ = 10.0f; if (arg1 != 0) { @@ -480,7 +479,7 @@ void func_808BE294(EnDekunuts* this, s32 arg1) { this->actionFunc = func_808BE358; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DAMAGE); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_CUTBODY); - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, Animation_GetLastFrame(&object_dekunuts_Anim_00259C)); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, Animation_GetLastFrame(&gDekuScrubDamageAnim)); } void func_808BE358(EnDekunuts* this, GlobalContext* globalCtx) { @@ -519,7 +518,7 @@ void func_808BE3FC(EnDekunuts* this, GlobalContext* globalCtx) { } void func_808BE484(EnDekunuts* this) { - Animation_PlayOnce(&this->skelAnime, &object_dekunuts_Anim_002BD4); + Animation_PlayOnce(&this->skelAnime, &gDekuScrubDieAnim); this->actionFunc = func_808BE4D4; this->actor.speedXZ = 0.0f; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DEAD); @@ -543,13 +542,13 @@ void func_808BE4D4(EnDekunuts* this, GlobalContext* globalCtx) { Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_OBJ_ETCETERA, this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, 0, this->actor.home.rot.y, 0, 0x80); EffectSsHahen_SpawnBurst(globalCtx, &this->actor.home.pos, 6.0f, 0, 6, 2, 15, 64, 10, - object_dekunuts_DL_001F50); + gDekuScrubFlowerFragmentDL); Actor_MarkForDeath(&this->actor); } } void func_808BE680(EnDekunuts* this) { - Animation_MorphToLoop(&this->skelAnime, &object_dekunuts_Anim_00326C, -3.0f); + Animation_MorphToLoop(&this->skelAnime, &gDekuScrubIdleAnim, -3.0f); this->actionFunc = func_808BE6C4; } @@ -568,7 +567,8 @@ void func_808BE73C(EnDekunuts* this, GlobalContext* globalCtx) { if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; Actor_SetDropFlag(&this->actor, &this->collider.info); - if ((this->unk_18E != 10) || !(this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { + if ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || + !(this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { func_808BD3B4(this, globalCtx); if ((this->actor.colChkInfo.mass == 50) || (this->actor.params != ENDEKUNUTS_GET_FF00_0)) { if ((this->actor.params != ENDEKUNUTS_GET_FF00_1) && !Actor_ApplyDamage(&this->actor)) { @@ -599,20 +599,20 @@ void func_808BE73C(EnDekunuts* this, GlobalContext* globalCtx) { } if (this->actor.colChkInfo.damageEffect == 2) { - this->unk_210 = 4.0f; - this->unk_214 = 0.55f; - this->unk_18E = 0; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; } else if (this->actor.colChkInfo.damageEffect == 4) { - this->unk_210 = 4.0f; - this->unk_214 = 0.55f; - this->unk_18E = 20; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->collider.info.bumper.hitPos.x, this->collider.info.bumper.hitPos.y, this->collider.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_SMALL_LIGHT_RAYS); } else if (this->actor.colChkInfo.damageEffect == 5) { - this->unk_18E = 32; - this->unk_210 = 4.0f; - this->unk_214 = 0.55f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_LARGE; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.55f; } func_808BE294(this, 1); @@ -649,12 +649,13 @@ void EnDekunuts_Update(Actor* thisx, GlobalContext* globalCtx) { } CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - if (this->unk_210 > 0.0f) { - if (this->unk_18E != 10) { - Math_StepToF(&this->unk_210, 0.0f, 0.05f); - this->unk_214 = (this->unk_210 + 1.0f) * 0.275f; - this->unk_214 = CLAMP_MAX(this->unk_214, 0.55f); - } else if ((this->unk_18E == 10) && !Math_StepToF(&this->unk_218, 0.55f, (33.0f / 1600.0f))) { + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.275f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 0.55f); + } else if ((this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) && + !Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.55f, (33.0f / 1600.0f))) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } @@ -667,7 +668,7 @@ s32 EnDekunuts_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** d f32 currentFrame; if (this->actionFunc == func_808BDA4C) { - if (limbIndex == 5) { + if (limbIndex == DEKU_SCRUB_LIMB_SNOUT) { currentFrame = this->skelAnime.curFrame; if (currentFrame <= 6.0f) { arg2 = 1.0f - (currentFrame * 0.0833f); @@ -686,7 +687,7 @@ s32 EnDekunuts_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** d return 0; } Matrix_Scale(arg1, arg2, arg3, MTXMODE_APPLY); - } else if ((limbIndex == 2) && (this->actor.params == ENDEKUNUTS_GET_FF00_2)) { + } else if ((limbIndex == DEKU_SCRUB_LIMB_HEAD) && (this->actor.params == ENDEKUNUTS_GET_FF00_2)) { rot->z = this->actor.world.rot.x; } } @@ -709,19 +710,19 @@ void EnDekunuts_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis if (value != -1) { if (value < 3) { - Matrix_GetStateTranslationAndScaledX(1000.0f, &this->unk_21C[value]); + Matrix_GetStateTranslationAndScaledX(1000.0f, &this->limbPos[value]); } else { - Matrix_GetStateTranslation(&this->unk_21C[value]); + Matrix_GetStateTranslation(&this->limbPos[value]); ptr1 = &D_808BEFA4[0]; - ptr2 = &this->unk_21C[value + 1]; - for (i = value + 1; i < ARRAY_COUNT(this->unk_21C); i++) { + ptr2 = &this->limbPos[value + 1]; + for (i = value + 1; i < ARRAY_COUNT(this->limbPos); i++) { Matrix_MultiplyVector3fByState(ptr1, ptr2); ptr1++, ptr2++; } } } - if (limbIndex == 2) { + if (limbIndex == DEKU_SCRUB_LIMB_HEAD) { Matrix_GetStateTranslation(&this->actor.focus.pos); } } @@ -737,7 +738,7 @@ void EnDekunuts_Draw(Actor* thisx, GlobalContext* globalCtx) { if (this->actor.colorFilterTimer != 0) { func_800AE5A0(globalCtx); } - Gfx_DrawDListOpa(globalCtx, object_dekunuts_DL_001E50); - func_800BE680(globalCtx, &this->actor, this->unk_21C, 8, this->unk_214, this->unk_218, this->unk_210, - this->unk_18E); + Gfx_DrawDListOpa(globalCtx, gDekuScrubFlowerDL); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, + this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, this->drawDmgEffType); } diff --git a/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.h b/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.h index aa0b3e1bff..39d0dd9544 100644 --- a/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.h +++ b/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.h @@ -2,6 +2,7 @@ #define Z_EN_DEKUNUTS_H #include "global.h" +#include "objects/object_dekunuts/object_dekunuts.h" struct EnDekunuts; @@ -22,16 +23,16 @@ typedef struct EnDekunuts { /* 0x188 */ EnDekunutsActionFunc actionFunc; /* 0x18C */ u8 unk_18C; /* 0x18D */ u8 unk_18D; - /* 0x18E */ u8 unk_18E; + /* 0x18E */ u8 drawDmgEffType; /* 0x190 */ s16 unk_190; /* 0x192 */ s16 unk_192; /* 0x194 */ s16 unk_194; - /* 0x196 */ Vec3s jointTable[10]; - /* 0x1D2 */ Vec3s morphTable[10]; - /* 0x210 */ f32 unk_210; - /* 0x214 */ f32 unk_214; - /* 0x218 */ f32 unk_218; - /* 0x21C */ Vec3f unk_21C[8]; + /* 0x196 */ Vec3s jointTable[DEKU_SCRUB_LIMB_MAX]; + /* 0x1D2 */ Vec3s morphTable[DEKU_SCRUB_LIMB_MAX]; + /* 0x210 */ f32 drawDmgEffAlpha; + /* 0x214 */ f32 drawDmgEffScale; + /* 0x218 */ f32 drawDmgEffFrozenSteamScale; + /* 0x21C */ Vec3f limbPos[8]; /* 0x27C */ ColliderCylinder collider; } EnDekunuts; // size = 0x2C8 diff --git a/src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.c b/src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.c index 65aad6461c..76934448ad 100644 --- a/src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.c +++ b/src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.c @@ -144,7 +144,7 @@ void EnDemoheishi_SetupTalk(EnDemoheishi* this) { } void EnDemoheishi_Talk(EnDemoheishi* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); EnDemoheishi_SetupIdle(this); } diff --git a/src/overlays/actors/ovl_En_Dg/z_en_dg.c b/src/overlays/actors/ovl_En_Dg/z_en_dg.c index 0648ca4ad0..23bd7e183b 100644 --- a/src/overlays/actors/ovl_En_Dg/z_en_dg.c +++ b/src/overlays/actors/ovl_En_Dg/z_en_dg.c @@ -5,7 +5,6 @@ */ #include "z_en_dg.h" -#include "objects/object_dog/object_dog.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_800000) @@ -58,19 +57,32 @@ typedef struct { static D_8098C2A4_s D_8098C2A4 = { 0x0063, 0x0000 }; +/** + * Stores the state for the dogs milling about at the Doggy Racetrack. + */ typedef struct { - s16 unk_00; - s16 unk_02; - s16 unk_04; -} D_8098C2A8_s; + s16 color; // The dog's color, which is used as an index into sBaseSpeeds + s16 index; // The dog's index within sDogInfo + s16 textId; // The ID of the text to display when the dog is picked up +} RacetrackDogInfo; -static D_8098C2A8_s D_8098C2A8[] = { - { 3, 0, 0x3539 }, { 1, 1, 0x353A }, { 5, 2, 0x353B }, { 2, 3, 0x353C }, { 4, 4, 0x3538 }, - { 2, 5, 0x353E }, { 3, 6, 0x353F }, { 1, 7, 0x3540 }, { 1, 8, 0x3541 }, { 6, 9, 0x3542 }, - { 2, 10, 0x3543 }, { 3, 11, 0x3544 }, { 1, 12, 0x3545 }, { 4, 13, 0x3546 }, +/** + * A table of RacetrackDogInfo for every dog at the Doggy Racetrack. Note that the textId values + * in this table are updated by functions within this actor. + */ +static RacetrackDogInfo sRacetrackDogInfo[] = { + { DOG_COLOR_BEIGE, 0, 0x3539 }, { DOG_COLOR_WHITE, 1, 0x353A }, { DOG_COLOR_BLUE, 2, 0x353B }, + { DOG_COLOR_GRAY, 3, 0x353C }, { DOG_COLOR_BROWN, 4, 0x3538 }, { DOG_COLOR_GRAY, 5, 0x353E }, + { DOG_COLOR_BEIGE, 6, 0x353F }, { DOG_COLOR_WHITE, 7, 0x3540 }, { DOG_COLOR_WHITE, 8, 0x3541 }, + { DOG_COLOR_GOLD, 9, 0x3542 }, { DOG_COLOR_GRAY, 10, 0x3543 }, { DOG_COLOR_BEIGE, 11, 0x3544 }, + { DOG_COLOR_WHITE, 12, 0x3545 }, { DOG_COLOR_BROWN, 13, 0x3546 }, }; -static D_8098C2A8_s D_8098C2FC = { 0, -1, 0x353E }; +/** + * Stores the RacetrackDogInfo for the dog that is selected by the player. These values are just + * placeholders, and the actual value gets grabbed from sRacetrackDogInfo in func_80989E18. + */ +static RacetrackDogInfo sSelectedRacetrackDogInfo = { DOG_COLOR_DEFAULT, -1, 0x353E }; static ColliderCylinderInit sCylinderInit = { { @@ -130,22 +142,14 @@ static DamageTable sDamageTable = { }; static AnimationInfoS sAnimations[] = { - { &object_dog_Anim_0021C8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_dog_Anim_0021C8, 1.0f, 0, -1, ANIMMODE_LOOP, -6 }, - { &object_dog_Anim_001BD8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_dog_Anim_000998, 1.0f, 0, -1, ANIMMODE_LOOP, -6 }, - { &object_dog_Anim_001FB0, 1.0f, 0, -1, ANIMMODE_ONCE, -6 }, - { &object_dog_Anim_001FB0, 1.0f, 0, -1, ANIMMODE_LOOP_PARTIAL, -6 }, - { &object_dog_Anim_001048, 1.0f, 0, -1, ANIMMODE_ONCE, -6 }, - { &object_dog_Anim_001348, 1.0f, 0, -1, ANIMMODE_LOOP, -6 }, - { &object_dog_Anim_001048, 1.0f, 0, 27, ANIMMODE_ONCE, -6 }, - { &object_dog_Anim_001048, 1.0f, 28, -1, ANIMMODE_ONCE, -6 }, - { &object_dog_Anim_001048, 1.0f, 54, 54, ANIMMODE_ONCE, -6 }, - { &object_dog_Anim_0021C8, -1.5f, -1, 0, ANIMMODE_LOOP, -6 }, - { &object_dog_Anim_001560, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_dog_Anim_001A84, 1.2f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_dog_Anim_0017C0, 1.2f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_dog_Anim_0021C8, 0.5f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gDogWalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, { &gDogWalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -6 }, + { &gDogRunAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, { &gDogBarkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -6 }, + { &gDogSitAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -6 }, { &gDogSitAnim, 1.0f, 0, -1, ANIMMODE_LOOP_PARTIAL, -6 }, + { &gDogLyingDownAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -6 }, { &gDogLyingDownLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -6 }, + { &gDogLyingDownAnim, 1.0f, 0, 27, ANIMMODE_ONCE, -6 }, { &gDogLyingDownAnim, 1.0f, 28, -1, ANIMMODE_ONCE, -6 }, + { &gDogLyingDownAnim, 1.0f, 54, 54, ANIMMODE_ONCE, -6 }, { &gDogWalkAnim, -1.5f, -1, 0, ANIMMODE_LOOP, -6 }, + { &gDogJumpAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, { &gDogLongJumpAnim, 1.2f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gDogJump2Anim, 1.2f, 0, -1, ANIMMODE_ONCE, 0 }, { &gDogWalkAnim, 0.5f, 0, -1, ANIMMODE_LOOP, 0 }, }; static InitChainEntry sInitChain[] = { @@ -221,7 +225,7 @@ s32 func_80989418(EnDg* this, Path* arg1, s32 arg2) { if (idx == 0) { phi_f12 = sp5C[1].x - sp5C[0].x; phi_f14 = sp5C[1].z - sp5C[0].z; - } else if ((idx + 1) == ((void)0, count)) { + } else if (idx == count - 1) { phi_f12 = sp5C[count - 1].x - sp5C[count - 2].x; phi_f14 = sp5C[count - 1].z - sp5C[count - 2].z; } else { @@ -229,7 +233,7 @@ s32 func_80989418(EnDg* this, Path* arg1, s32 arg2) { phi_f14 = sp5C[idx + 1].z - sp5C[idx - 1].z; } - func_8017B7F8(&sp30, func_80086B30(phi_f12, phi_f14) * 10430.378f, &sp44, &sp40, &sp3C); + func_8017B7F8(&sp30, RADF_TO_BINANG(func_80086B30(phi_f12, phi_f14)), &sp44, &sp40, &sp3C); if (((this->actor.world.pos.x * sp44) + (sp40 * this->actor.world.pos.z) + sp3C) > 0.0f) { sp50 = true; } @@ -261,29 +265,29 @@ void func_80989674(EnDg* this, GlobalContext* globalCtx) { s16 phi_a1; f32 sp30; - if (this->unk_1DC != NULL) { - phi_a1 = func_809895B4(this->unk_1DC, this->unk_1E0, &this->actor.world.pos, &sp30); + if (this->path != NULL) { + phi_a1 = func_809895B4(this->path, this->unk_1E0, &this->actor.world.pos, &sp30); if (this->actor.bgCheckFlags & 8) { phi_a1 = this->actor.wallYaw; } Math_SmoothStepToS(&this->actor.world.rot.y, phi_a1, 4, 0x3E8, 1); this->actor.shape.rot.y = this->actor.world.rot.y; - if (func_80989418(this, this->unk_1DC, this->unk_1E0)) { - if (this->unk_1E0 >= (this->unk_1DC->count - 1)) { + if (func_80989418(this, this->path, this->unk_1E0)) { + if (this->unk_1E0 >= (this->path->count - 1)) { this->unk_1E0 = 0; } else { this->unk_1E0++; } } - if ((this->unk_286 == 21) || ((this->unk_286 == 20) && (globalCtx->sceneNum == SCENE_OMOYA))) { + if ((this->index == 21) || ((this->index == 20) && (globalCtx->sceneNum == SCENE_OMOYA))) { Math_ApproachF(&this->actor.speedXZ, 1.0f, 0.2f, 1.0f); - } else if (this->unk_286 == 20) { + } else if (this->index == 20) { Math_ApproachF(&this->actor.speedXZ, 3.5f, 0.2f, 1.0f); } else if (globalCtx->sceneNum == SCENE_CLOCKTOWER) { Math_ApproachF(&this->actor.speedXZ, 3.5f, 0.2f, 1.0f); - } else if (D_8098C2A8[this->unk_286].unk_04 & 0x11) { + } else if (sRacetrackDogInfo[this->index].textId & 0x11) { Math_ApproachF(&this->actor.speedXZ, 1.0f, 0.2f, 1.0f); } else { Math_ApproachF(&this->actor.speedXZ, 3.5f, 0.2f, 1.0f); @@ -298,7 +302,7 @@ void func_80989864(EnDg* this, GlobalContext* globalCtx) { s16 mod = (this->actor.speedXZ > 6.0f) ? 2 : 3; Vec3f sp38; - if (((this->unk_286 + frame) % mod) == 0) { + if (((this->index + frame) % mod) == 0) { sp38.x = randPlusMinusPoint5Scaled(15.0f) + this->actor.world.pos.x; sp38.y = this->actor.world.pos.y; sp38.z = randPlusMinusPoint5Scaled(15.0f) + this->actor.world.pos.z; @@ -338,13 +342,13 @@ void func_80989A9C(EnDg* this, f32 arg1) { void func_80989ADC(EnDg* this, GlobalContext* globalCtx) { if (!(this->actor.bgCheckFlags & 0x20)) { - if ((this->unk_286 == 21) || ((this->unk_286 == 20) && (globalCtx->sceneNum == SCENE_OMOYA))) { + if ((this->index == 21) || ((this->index == 20) && (globalCtx->sceneNum == SCENE_OMOYA))) { func_80989140(&this->skelAnime, sAnimations, 1); - } else if (this->unk_286 == 20) { + } else if (this->index == 20) { func_80989140(&this->skelAnime, sAnimations, 2); } else if (globalCtx->sceneNum == SCENE_CLOCKTOWER) { func_80989140(&this->skelAnime, sAnimations, 2); - } else if (D_8098C2A8[this->unk_286].unk_04 & 0x11) { + } else if (sRacetrackDogInfo[this->index].textId & 0x11) { func_80989140(&this->skelAnime, sAnimations, 1); } else { func_80989140(&this->skelAnime, sAnimations, 2); @@ -354,37 +358,37 @@ void func_80989ADC(EnDg* this, GlobalContext* globalCtx) { } void func_80989BF8(EnDg* this) { - if (this->unk_286 < 14) { - if (this->unk_286 % 2) { - D_8098C2A8[this->unk_286].unk_04 = - 0x3538 + ((gSaveContext.weekEventReg[42 + (this->unk_286 / 2)] & (0x10 | 0x20 | 0x40 | 0x80)) >> 4); + if (this->index < 14) { + if (this->index % 2) { + sRacetrackDogInfo[this->index].textId = + 0x3538 + ((gSaveContext.save.weekEventReg[42 + (this->index / 2)] & (0x10 | 0x20 | 0x40 | 0x80)) >> 4); } else { - D_8098C2A8[this->unk_286].unk_04 = - 0x3538 + (gSaveContext.weekEventReg[42 + (this->unk_286 / 2)] & (1 | 2 | 4 | 8)); + sRacetrackDogInfo[this->index].textId = + 0x3538 + (gSaveContext.save.weekEventReg[42 + (this->index / 2)] & (1 | 2 | 4 | 8)); } } else { Actor_MarkForDeath(&this->actor); } - if ((D_8098C2A8[this->unk_286].unk_04 >= 0x3547) || (D_8098C2A8[this->unk_286].unk_04 < 0x3538)) { - D_8098C2A8[this->unk_286].unk_04 = 0x353E; + if ((sRacetrackDogInfo[this->index].textId >= 0x3547) || (sRacetrackDogInfo[this->index].textId < 0x3538)) { + sRacetrackDogInfo[this->index].textId = 0x353E; } - if (D_8098C2A8[this->unk_286].unk_04 == 0x353D) { - D_8098C2A8[this->unk_286].unk_04 = 0x3538; + if (sRacetrackDogInfo[this->index].textId == 0x353D) { + sRacetrackDogInfo[this->index].textId = 0x3538; } } void func_80989D38(EnDg* this, GlobalContext* globalCtx) { - if (this->unk_286 == 21) { + if (this->index == 21) { if (CURRENT_DAY == 1) { Message_StartTextbox(globalCtx, 0x91C, NULL); } else { Message_StartTextbox(globalCtx, 0x91E, NULL); } - } else if ((this->unk_286 >= 0) && (this->unk_286 < 14)) { - Message_StartTextbox(globalCtx, D_8098C2A8[this->unk_286].unk_04, NULL); - } else if (this->unk_286 == 20) { + } else if ((this->index >= 0) && (this->index < 14)) { + Message_StartTextbox(globalCtx, sRacetrackDogInfo[this->index].textId, NULL); + } else if (this->index == 20) { Message_StartTextbox(globalCtx, 0x353D, NULL); } else { Message_StartTextbox(globalCtx, 0x627, NULL); @@ -392,7 +396,7 @@ void func_80989D38(EnDg* this, GlobalContext* globalCtx) { } void func_80989E18(EnDg* this, GlobalContext* globalCtx) { - D_8098C2A8_s* temp; + RacetrackDogInfo* temp; if ((D_8098C2A0 != 0) && !(this->unk_280 & 1)) { this->actor.flags |= ACTOR_FLAG_8000000; @@ -405,7 +409,7 @@ void func_80989E18(EnDg* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SMALL_DOG_BARK); this->unk_290 = 1; - D_8098C2FC = D_8098C2A8[this->unk_286]; + sSelectedRacetrackDogInfo = sRacetrackDogInfo[this->index]; if (D_8098C2A0 == 0) { this->actor.flags |= ACTOR_FLAG_8000000; D_8098C2A0 = 1; @@ -435,13 +439,13 @@ s32 func_80989FC8(GlobalContext* globalCtx) { while (enemy != NULL) { if (enemy->actor.id == ACTOR_EN_DG) { if (enemy->actor.isTargeted) { - D_8098C2A4.unk_00 = enemy->unk_286; + D_8098C2A4.unk_00 = enemy->index; return true; } dist = enemy->actor.xzDistToPlayer; if (dist < minDist) { - D_8098C2A4.unk_00 = enemy->unk_286; + D_8098C2A4.unk_00 = enemy->index; minDist = dist; } } @@ -463,7 +467,7 @@ void func_8098A064(EnDg* this, GlobalContext* globalCtx) { func_80989FC8(globalCtx); } - if (this->unk_286 == D_8098C2A4.unk_00) { + if (this->index == D_8098C2A4.unk_00) { if (!(this->unk_280 & 0x20)) { this->unk_280 |= 0x20; func_80989140(&this->skelAnime, sAnimations, 1); @@ -475,7 +479,7 @@ void func_8098A064(EnDg* this, GlobalContext* globalCtx) { } } } - } else if (this->unk_286 == D_8098C2A4.unk_00) { + } else if (this->index == D_8098C2A4.unk_00) { this->unk_280 &= ~0x20; D_8098C2A4.unk_00 = 99; func_80989ADC(this, globalCtx); @@ -1061,8 +1065,8 @@ void func_8098BA64(EnDg* this, GlobalContext* globalCtx) { D_8098C2A0 = 0; this->unk_280 &= ~1; } - this->unk_288 = -1; - D_8098C2FC.unk_02 = this->unk_288; + this->selectedDogIndex = -1; + sSelectedRacetrackDogInfo.index = this->selectedDogIndex; this->unk_28A = 100; Actor_MoveWithGravity(&this->actor); this->unk_280 |= 0x10; @@ -1117,13 +1121,12 @@ void EnDg_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_dog_Skel_0080F0, NULL, this->jointTable, this->morphTable, - 13); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gDogSkel, NULL, this->jointTable, this->morphTable, DOG_LIMB_MAX); Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); Actor_ProcessInitChain(&this->actor, sInitChain); - this->unk_1DC = func_8013D648(globalCtx, ENDG_GET_FC00(&this->actor), 0x3F); + this->path = SubS_GetPathByIndex(globalCtx, ENDG_GET_PATH(&this->actor), 0x3F); Actor_SetScale(&this->actor, 0.0075f); this->actor.targetMode = 1; this->actor.gravity = -3.0f; @@ -1131,7 +1134,7 @@ void EnDg_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_280 = 0; this->unk_28E = 20; this->unk_284 = 10; - this->unk_286 = ENDG_GET_3E0(&this->actor); + this->index = ENDG_GET_INDEX(&this->actor); this->unk_28C = 0; this->unk_290 = 0; if (globalCtx->sceneNum == SCENE_F01_B) { @@ -1153,7 +1156,7 @@ void EnDg_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; Vec3f sp28 = { 0.0f, 0.0f, 0.0f }; - this->unk_288 = D_8098C2FC.unk_02; + this->selectedDogIndex = sSelectedRacetrackDogInfo.index; if (!(player->stateFlags1 & 0x20) || (globalCtx->sceneNum != SCENE_CLOCKTOWER)) { if (func_8098A1B4(this, globalCtx)) { func_8098A234(this, globalCtx); @@ -1184,7 +1187,7 @@ void EnDg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec EnDg* this = THIS; Vec3f sp20 = { 0.0f, 20.0f, 0.0f }; - if (limbIndex == 5) { + if (limbIndex == DOG_LIMB_HEAD) { if (this->actionFunc == func_8098BBEC) { sp20.x = 5000.0f; Matrix_MultiplyVector3fByState(&sp20, &this->actor.focus.pos); @@ -1203,25 +1206,31 @@ void EnDg_Draw(Actor* thisx, GlobalContext* globalCtx) { gDPPipeSync(POLY_OPA_DISP++); - switch (D_8098C2A8[this->unk_286].unk_00) { - case 3: + switch (sRacetrackDogInfo[this->index].color) { + case DOG_COLOR_BEIGE: gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 200, 0); break; - case 1: + + case DOG_COLOR_WHITE: gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 0); break; - case 5: + + case DOG_COLOR_BLUE: gDPSetEnvColor(POLY_OPA_DISP++, 79, 79, 143, 0); break; - case 6: + + case DOG_COLOR_GOLD: gDPSetEnvColor(POLY_OPA_DISP++, 255, 207, 47, 0); break; - case 4: + + case DOG_COLOR_BROWN: gDPSetEnvColor(POLY_OPA_DISP++, 143, 79, 47, 0); break; - case 2: + + case DOG_COLOR_GRAY: gDPSetEnvColor(POLY_OPA_DISP++, 143, 143, 143, 0); break; + default: gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 200, 0); break; diff --git a/src/overlays/actors/ovl_En_Dg/z_en_dg.h b/src/overlays/actors/ovl_En_Dg/z_en_dg.h index cfb474b189..ca85d4a4da 100644 --- a/src/overlays/actors/ovl_En_Dg/z_en_dg.h +++ b/src/overlays/actors/ovl_En_Dg/z_en_dg.h @@ -2,13 +2,24 @@ #define Z_EN_DG_H #include "global.h" +#include "objects/object_dog/object_dog.h" + +typedef enum { + /* 0 */ DOG_COLOR_DEFAULT, // ends up just being treated as beige + /* 1 */ DOG_COLOR_WHITE, + /* 2 */ DOG_COLOR_GRAY, + /* 3 */ DOG_COLOR_BEIGE, + /* 4 */ DOG_COLOR_BROWN, + /* 5 */ DOG_COLOR_BLUE, + /* 6 */ DOG_COLOR_GOLD, +} DogColors; struct EnDg; typedef void (*EnDgActionFunc)(struct EnDg*, GlobalContext*); -#define ENDG_GET_FC00(thisx) (((thisx)->params & 0xFC00) >> 0xA) -#define ENDG_GET_3E0(thisx) (((thisx)->params & 0x3E0) >> 5) +#define ENDG_GET_INDEX(thisx) (((thisx)->params & 0x3E0) >> 5) +#define ENDG_GET_PATH(thisx) (((thisx)->params & 0xFC00) >> 0xA) typedef struct EnDg { /* 0x000 */ Actor actor; @@ -16,15 +27,15 @@ typedef struct EnDg { /* 0x148 */ UNK_TYPE1 unk_148[0x4]; /* 0x14C */ SkelAnime skelAnime; /* 0x190 */ ColliderCylinder collider; - /* 0x1DC */ Path* unk_1DC; + /* 0x1DC */ Path* path; /* 0x1E0 */ s32 unk_1E0; - /* 0x1E4 */ Vec3s jointTable[13]; - /* 0x232 */ Vec3s morphTable[13]; + /* 0x1E4 */ Vec3s jointTable[DOG_LIMB_MAX]; + /* 0x232 */ Vec3s morphTable[DOG_LIMB_MAX]; /* 0x280 */ u16 unk_280; /* 0x282 */ s16 unk_282; /* 0x284 */ s16 unk_284; - /* 0x286 */ s16 unk_286; - /* 0x288 */ s16 unk_288; + /* 0x286 */ s16 index; + /* 0x288 */ s16 selectedDogIndex; /* 0x28A */ s16 unk_28A; /* 0x28C */ s16 unk_28C; /* 0x28E */ s16 unk_28E; diff --git a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c index 03afec1fb3..e06e2e7768 100644 --- a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c +++ b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c @@ -376,22 +376,22 @@ void func_8089ABF4(EnDinofos* this, GlobalContext* globalCtx) { } void func_8089AC70(EnDinofos* this) { - this->unk_28A = 10; - this->unk_2B4 = 0.55f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; + this->drawDmgEffScale = 0.55f; this->colliderJntSph.base.colType = COLTYPE_HIT3; - this->unk_2B8 = 0.82500005f; - this->unk_2B0 = 1.0f; + this->drawDmgEffFrozenSteamScale = 0.82500005f; + this->drawDmgEffAlpha = 1.0f; this->unk_290 = 80; this->actor.flags &= ~ACTOR_FLAG_400; Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); } void func_8089ACEC(EnDinofos* this, GlobalContext* globalCtx) { - if (this->unk_28A == 10) { - this->unk_28A = 0; + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->colliderJntSph.base.colType = COLTYPE_HIT0; - this->unk_2B0 = 0.0f; - Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_2D4, 12, 2, 0.3f, 0.2f); + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, 12, 2, 0.3f, 0.2f); this->actor.flags |= ACTOR_FLAG_400; } } @@ -450,7 +450,7 @@ s32 func_8089AE00(EnDinofos* this, GlobalContext* globalCtx) { return true; } - if ((gSaveContext.playerForm == PLAYER_FORM_GORON) && (player->actor.velocity.y < -5.0f) && + if ((gSaveContext.save.playerForm == PLAYER_FORM_GORON) && (player->actor.velocity.y < -5.0f) && (player->unk_AE7 == 1) && (this->unk_28B == 0)) { this->unk_28B = 1; for (i = 0; i < ARRAY_COUNT(this->colliderJntSphElement) - 3; i++) { @@ -1048,9 +1048,9 @@ void func_8089CB10(EnDinofos* this, GlobalContext* globalCtx) { for (i = 6; i < ARRAY_COUNT(this->colliderJntSphElement); i++) { worldSphere = &this->colliderJntSph.elements[i].dim.worldSphere; - worldSphere->center.x = this->unk_34C.x; - worldSphere->center.y = this->unk_34C.y; - worldSphere->center.z = this->unk_34C.z; + worldSphere->center.x = this->limbPos[10].x; + worldSphere->center.y = this->limbPos[10].y; + worldSphere->center.z = this->limbPos[10].z; } if (globalCtx->sceneNum == SCENE_MITURIN) { @@ -1086,7 +1086,7 @@ void func_8089CBEC(EnDinofos* this, GlobalContext* globalCtx) { sp7C.y = randPlusMinusPoint5Scaled(0.6f) + 1.4f; sp7C.z = 0.9f * temp_f22; func_800B9010(&this->actor, NA_SE_EN_DODO_J_FIRE - SFX_FLAG); - EffectSsDFire_Spawn(globalCtx, &this->unk_34C, &sp88, &sp7C, 30, 22, 255 - (temp_s0 * 20), 20, 3, 8); + EffectSsDFire_Spawn(globalCtx, &this->limbPos[10], &sp88, &sp7C, 30, 22, 255 - (temp_s0 * 20), 20, 3, 8); for (end = 6, i = 3; i > 0; i--) { if (this->unk_290 < (20 + -(i * 2))) { @@ -1099,9 +1099,9 @@ void func_8089CBEC(EnDinofos* this, GlobalContext* globalCtx) { dim = &this->colliderJntSph.elements[i].dim; temp_s3 = (s32)(cos_rad((this->unk_290 + ((i - 5) << 1)) * (M_PI / 20)) * 0x2C00) + this->actor.shape.rot.y; - dim->worldSphere.center.x = (s32)(Math_SinS(temp_s3) * dim->modelSphere.center.z) + (s32)this->unk_34C.x; - dim->worldSphere.center.y = (s32)this->unk_34C.y + (s32)dim->modelSphere.center.y; - dim->worldSphere.center.z = (s32)(Math_CosS(temp_s3) * dim->modelSphere.center.z) + (s32)this->unk_34C.z; + dim->worldSphere.center.x = (s32)this->limbPos[10].x + (s32)(Math_SinS(temp_s3) * dim->modelSphere.center.z); + dim->worldSphere.center.y = (s32)this->limbPos[10].y + (s32)dim->modelSphere.center.y; + dim->worldSphere.center.z = (s32)this->limbPos[10].z + (s32)(Math_CosS(temp_s3) * dim->modelSphere.center.z); } if (this->unk_290 != 0) { @@ -1151,8 +1151,8 @@ void func_8089D018(EnDinofos* this, GlobalContext* globalCtx) { this->unk_288 = temp_v0; } - if (this->unk_2B0 > 0.0f) { - this->unk_2B0 = this->unk_288 * (1.0f / 255.0f); + if (this->drawDmgEffAlpha > 0.0f) { + this->drawDmgEffAlpha = this->unk_288 * (1.0f / 255.0f); } this->actor.shape.shadowAlpha = this->unk_288; @@ -1234,7 +1234,7 @@ void func_8089D42C(EnDinofos* this, GlobalContext* globalCtx) { Math_ScaledStepToS(&this->unk_28E, cos_rad(M_PI) * 0x2C00, 0x233); } else if (this->actionFunc == func_8089CBEC) { this->unk_28E = cos_rad(this->unk_290 * (M_PI / 20)) * 0x2C00; - } else if (!func_801690CC(globalCtx)) { + } else if (!Play_InCsMode(globalCtx)) { temp_v0_2 = this->unk_28E + this->actor.shape.rot.y; temp_v0_2 = BINANG_SUB(this->actor.yawTowardsPlayer, temp_v0_2); temp_v0_2 = CLAMP(temp_v0_2, -0x300, 0x300); @@ -1260,7 +1260,8 @@ s32 func_8089D60C(EnDinofos* this, GlobalContext* globalCtx) { return false; } - if ((this->unk_28A == 10) && (this->colliderJntSph.elements[i].info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { + if ((this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) && + (this->colliderJntSph.elements[i].info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { return false; } @@ -1311,22 +1312,22 @@ s32 func_8089D60C(EnDinofos* this, GlobalContext* globalCtx) { if (this->actor.colChkInfo.damageEffect == 5) { this->unk_290 = 40; Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); - this->unk_2B4 = 0.55f; - this->unk_2B0 = 2.0f; - this->unk_28A = 31; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffAlpha = 2.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_MEDIUM; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); func_8089C784(this); return true; } if (this->actor.colChkInfo.damageEffect == 2) { - this->unk_2B0 = 4.0f; - this->unk_2B4 = 0.55f; - this->unk_28A = 0; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; } else if (this->actor.colChkInfo.damageEffect == 4) { - this->unk_2B0 = 4.0f; - this->unk_2B4 = 0.55f; - this->unk_28A = 20; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->colliderJntSph.elements[i].info.bumper.hitPos.x, this->colliderJntSph.elements[i].info.bumper.hitPos.y, @@ -1359,7 +1360,7 @@ void EnDinofos_Update(Actor* thisx, GlobalContext* globalCtx2) { if (this->actionFunc != func_8089C7B8) { if ((this->actor.depthInWater > 0.0f) && (this->actor.depthInWater < 10.0f)) { if (!((globalCtx->gameplayFrames % 4) & 1)) { - Math_Vec3f_Copy(&sp30, &this->unk_2D4[1 + (globalCtx->gameplayFrames % 4)]); + Math_Vec3f_Copy(&sp30, &this->limbPos[1 + (globalCtx->gameplayFrames % 4)]); sp30.y = this->actor.world.pos.y + this->actor.depthInWater; EffectSsGRipple_Spawn(globalCtx, &sp30, 100, 320, 0); } @@ -1373,7 +1374,7 @@ void EnDinofos_Update(Actor* thisx, GlobalContext* globalCtx2) { Math_ScaledStepToS(&this->unk_28E, 0, 2000); } - Math_Vec3f_Copy(&this->actor.focus.pos, &this->unk_304); + Math_Vec3f_Copy(&this->actor.focus.pos, &this->limbPos[4]); this->actor.focus.rot.y = this->actor.shape.rot.y + this->unk_28E; if (this->colliderJntSph.base.acFlags & AC_ON) { CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderJntSph.base); @@ -1388,12 +1389,12 @@ void EnDinofos_Update(Actor* thisx, GlobalContext* globalCtx2) { CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderQuad.base); } - if (this->unk_2B0 > 0.0f) { - if (this->unk_28A != 10) { - Math_StepToF(&this->unk_2B0, 0.0f, 0.05f); - this->unk_2B4 = (this->unk_2B0 + 1.0f) * (11.0f / 40.0f); - this->unk_2B4 = CLAMP_MAX(this->unk_2B4, 0.55f); - } else if (!Math_StepToF(&this->unk_2B8, 0.55f, 0.01375f)) { + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * (11.0f / 40.0f); + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 0.55f); + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.55f, 0.01375f)) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } @@ -1428,7 +1429,7 @@ void func_8089DC84(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* Collider_UpdateSpheres(limbIndex, &this->colliderJntSph); if (D_8089E3B0[limbIndex] != -1) { - Matrix_GetStateTranslation(&this->unk_2D4[D_8089E3B0[limbIndex]]); + Matrix_GetStateTranslation(&this->limbPos[D_8089E3B0[limbIndex]]); } if ((limbIndex == 14) && (this->unk_292 != this->unk_290) && @@ -1460,7 +1461,7 @@ void func_8089DC84(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* sp4C.x -= sp48->mf[3][0]; sp4C.y -= sp48->mf[3][1]; sp4C.z -= sp48->mf[3][2]; - EffectSsDFire_Spawn(globalCtx, &this->unk_34C, &sp4C, &gZeroVec3f, 30, 22, 255 - (sp58 * 20), 20, 3, 8); + EffectSsDFire_Spawn(globalCtx, &this->limbPos[10], &sp4C, &gZeroVec3f, 30, 22, 255 - (sp58 * 20), 20, 3, 8); this->unk_292 = this->unk_290; } } @@ -1495,8 +1496,8 @@ void EnDinofos_Draw(Actor* thisx, GlobalContext* globalCtx) { this->skelAnime.dListCount, func_8089DC4C, func_8089DC84, &this->actor, POLY_XLU_DISP); } - func_800BE680(globalCtx, &this->actor, this->unk_2D4, 12, this->unk_2B4, this->unk_2B8, this->unk_2B0, - this->unk_28A); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, + this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, this->drawDmgEffType); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.h b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.h index 961780b942..f5c7431f0a 100644 --- a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.h +++ b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.h @@ -15,7 +15,7 @@ typedef struct EnDinofos { /* 0x284 */ EnDinofosActionFunc actionFunc; /* 0x288 */ u8 unk_288; /* 0x289 */ u8 unk_289; - /* 0x28A */ u8 unk_28A; + /* 0x28A */ u8 drawDmgEffType; /* 0x28B */ u8 unk_28B; /* 0x28C */ s16 unk_28C; /* 0x28E */ s16 unk_28E; @@ -28,20 +28,15 @@ typedef struct EnDinofos { /* 0x2A4 */ f32 unk_2A4; /* 0x2A8 */ f32 unk_2A8; /* 0x2AC */ f32 unk_2AC; - /* 0x2B0 */ f32 unk_2B0; - /* 0x2B4 */ f32 unk_2B4; - /* 0x2B8 */ f32 unk_2B8; + /* 0x2B0 */ f32 drawDmgEffAlpha; + /* 0x2B4 */ f32 drawDmgEffScale; + /* 0x2B8 */ f32 drawDmgEffFrozenSteamScale; /* 0x2BC */ Vec3f unk_2BC; /* 0x2C8 */ Vec3f unk_2C8; - /* 0x2D4 */ Vec3f unk_2D4[4]; - /* 0x304 */ Vec3f unk_304; - /* 0x310 */ UNK_TYPE1 unk_310[0x3C]; - /* 0x34C */ Vec3f unk_34C; - /* 0x358 */ UNK_TYPE1 unk_358[0xC]; + /* 0x2D4 */ Vec3f limbPos[12]; /* 0x364 */ ColliderJntSph colliderJntSph; /* 0x384 */ ColliderJntSphElement colliderJntSphElement[9]; /* 0x5C4 */ ColliderQuad colliderQuad; - } EnDinofos; // size = 0x644 extern const ActorInit En_Dinofos_InitVars; diff --git a/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c b/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c index d04ed3ee1f..99c5d23d9a 100644 --- a/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c +++ b/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c @@ -94,16 +94,16 @@ static DamageTable sDamageTable = { }; static AnimationInfoS sAnimations[] = { - { &object_dnk_Anim_000B70, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_dnk_Anim_000B70, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_dnk_Anim_002A08, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_dnk_Anim_00031C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_dnk_Anim_000430, 1.0f, -1, -1, ANIMMODE_ONCE, 0 }, - { &object_dnk_Anim_000430, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_dnk_Anim_000894, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_dnk_Anim_002B6C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_dnk_Anim_002B6C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_dnk_Anim_0006CC, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gDekuPalaceGuardStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gDekuPalaceGuardStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gDekuPalaceGuardWaitAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gDekuPalaceGuardAttackAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gDekuPalaceGuardDigAnim, 1.0f, -1, -1, ANIMMODE_ONCE, 0 }, + { &gDekuPalaceGuardDigAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gDekuPalaceGuardJumpAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gDekuPalaceGuardWalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gDekuPalaceGuardWalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gDekuPalaceGuardHappyAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, { &object_hintnuts_Anim_000168, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, { &object_hintnuts_Anim_0024CC, 1.0f, -1, -1, ANIMMODE_ONCE, 0 }, { &object_hintnuts_Anim_0024CC, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, @@ -116,20 +116,20 @@ static AnimationInfoS sAnimations[] = { { &object_hintnuts_Anim_003128, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, { &object_hintnuts_Anim_0029BC, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, { &object_hintnuts_Anim_002E84, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_dekunuts_Anim_000168, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_dekunuts_Anim_00259C, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_dekunuts_Anim_002A5C, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_dekunuts_Anim_002A5C, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_dekunuts_Anim_002BD4, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_dekunuts_Anim_002DD4, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_dekunuts_Anim_002FA4, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_dekunuts_Anim_003180, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_dekunuts_Anim_00326C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_dekunuts_Anim_00326C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_dekunuts_Anim_0033E4, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_dekunuts_Anim_003780, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_dekunuts_Anim_003780, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_dekunuts_Anim_002950, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gDekuScrubSpitAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gDekuScrubDamageAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gDekuScrubBurrowAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gDekuScrubBurrowAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gDekuScrubDieAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gDekuScrubUnburrowAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gDekuScrubLookAroundAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gDekuScrubUpAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gDekuScrubIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gDekuScrubIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gDekuScrubPantingAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gDekuScrubRunAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gDekuScrubRunAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gDekuScrubStandingIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, }; s32 func_80A514F0(SkelAnime* skelAnime, s16 animIndex) { @@ -178,8 +178,8 @@ void func_80A51648(EnDnk* this, GlobalContext* globalCtx) { switch (ENDNK_GET_3(&this->actor)) { case ENDNK_GET_3_0: - SkelAnime_Init(globalCtx, &this->skelAnime, &object_dnk_Skel_002848, NULL, this->jointTable, - this->morphTable, 11); + SkelAnime_Init(globalCtx, &this->skelAnime, &gDekuPalaceGuardSkel, NULL, this->jointTable, + this->morphTable, DEKU_PALACE_GUARD_LIMB_MAX); func_80A514F0(&this->skelAnime, 7); break; @@ -190,8 +190,8 @@ void func_80A51648(EnDnk* this, GlobalContext* globalCtx) { break; case ENDNK_GET_3_2: - SkelAnime_Init(globalCtx, &this->skelAnime, &object_dekunuts_Skel_002468, NULL, this->jointTable, - this->morphTable, 10); + SkelAnime_Init(globalCtx, &this->skelAnime, &gDekuScrubSkel, NULL, this->jointTable, this->morphTable, + DEKU_SCRUB_LIMB_MAX); func_80A514F0(&this->skelAnime, 35); break; } @@ -326,9 +326,9 @@ void func_80A51AA4(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* void func_80A51CB8(EnDnk* this, GlobalContext* globalCtx) { static TexturePtr D_80A5245C[] = { - object_dnk_Tex_001680, - object_dnk_Tex_001700, - object_dnk_Tex_001780, + gDekuPalaceGuardEyeOpenTex, + gDekuPalaceGuardEyeHalfTex, + gDekuPalaceGuardEyeClosedTex, }; s32 pad; diff --git a/src/overlays/actors/ovl_En_Dno/z_en_dno.c b/src/overlays/actors/ovl_En_Dno/z_en_dno.c index d51ec8a4d8..e774c8965b 100644 --- a/src/overlays/actors/ovl_En_Dno/z_en_dno.c +++ b/src/overlays/actors/ovl_En_Dno/z_en_dno.c @@ -149,8 +149,8 @@ void func_80A715DC(EnDno* this, GlobalContext* globalCtx) { crace = (BgCraceMovebg*)SubS_FindActor(globalCtx, &crace->actor, ACTORCAT_BG, ACTOR_BG_CRACE_MOVEBG); if (crace != NULL) { if (ENDNO_GET_F(&crace->actor) == ENDNO_GET_F_0 && !(crace->unk_170 & 1)) { - if (func_8013E5CC(&crace->actor.home.pos, &crace->actor.home.rot, &D_80A73B2C, &this->actor.prevPos, - &this->actor.world.pos, &sp88)) { + if (SubS_LineSegVsPlane(&crace->actor.home.pos, &crace->actor.home.rot, &D_80A73B2C, + &this->actor.prevPos, &this->actor.world.pos, &sp88)) { Math_Vec3f_Diff(&this->actor.world.pos, &crace->actor.home.pos, &sp7C); Matrix_RotateY(-crace->actor.home.rot.y, MTXMODE_NEW); Matrix_MultiplyVector3fByState(&sp7C, &sp70); @@ -211,7 +211,7 @@ void EnDno_Init(Actor* thisx, GlobalContext* globalCtx) { switch (ENDNO_GET_C000(thisx)) { case ENDNO_GET_C000_0: func_80A71788(this, globalCtx); - if (!(gSaveContext.weekEventReg[23] & 0x20) || (gSaveContext.weekEventReg[93] & 2)) { + if (!(gSaveContext.save.weekEventReg[23] & 0x20) || (gSaveContext.save.weekEventReg[93] & 2)) { Actor_MarkForDeath(thisx); } else { SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 14, &this->unk_32C); @@ -225,7 +225,7 @@ void EnDno_Init(Actor* thisx, GlobalContext* globalCtx) { break; case ENDNO_GET_C000_1: - if (gSaveContext.weekEventReg[23] & 0x20) { + if (gSaveContext.save.weekEventReg[23] & 0x20) { Actor_MarkForDeath(thisx); } else { SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 13, &this->unk_32C); @@ -267,7 +267,7 @@ void func_80A71B68(EnDno* this, GlobalContext* globalCtx) { this->unk_452 = 0; this->actor.textId = 0; if (CHECK_QUEST_ITEM(QUEST_SONG_SONATA)) { - if (gSaveContext.weekEventReg[27] & 1) { + if (gSaveContext.save.weekEventReg[27] & 1) { if (!(this->unk_3B0 & 0x20)) { SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 6, &this->unk_32C); this->actor.shape.rot.y = Actor_YawBetweenActors(&this->actor, this->unk_460); @@ -331,17 +331,17 @@ void func_80A71C3C(EnDno* this, GlobalContext* globalCtx) { void func_80A71E54(EnDno* this, GlobalContext* globalCtx) { if (CHECK_QUEST_ITEM(QUEST_SONG_SONATA)) { - if (gSaveContext.weekEventReg[27] & 1) { + if (gSaveContext.save.weekEventReg[27] & 1) { this->textId = 0x811; } else { this->textId = 0x80F; - gSaveContext.weekEventReg[27] |= 1; + gSaveContext.save.weekEventReg[27] |= 1; } - } else if (gSaveContext.weekEventReg[26] & 0x80) { + } else if (gSaveContext.save.weekEventReg[26] & 0x80) { this->textId = 0x80B; } else { this->textId = 0x80C; - gSaveContext.weekEventReg[26] |= 0x80; + gSaveContext.save.weekEventReg[26] |= 0x80; } if (this->textId != 0x811) { @@ -381,7 +381,7 @@ void func_80A71F18(EnDno* this, GlobalContext* globalCtx) { break; case 3: - if (globalCtx->msgCtx.unk11F04 == 0x80B) { + if (globalCtx->msgCtx.currentTextId == 0x80B) { switch (this->unk_32C) { case 16: if (this->skelAnime.curFrame == this->skelAnime.endFrame) { @@ -405,7 +405,7 @@ void func_80A71F18(EnDno* this, GlobalContext* globalCtx) { case 4: case 5: case 6: - switch (globalCtx->msgCtx.unk11F04) { + switch (globalCtx->msgCtx.currentTextId) { case 0x80B: switch (this->unk_32C) { case 16: @@ -415,7 +415,7 @@ void func_80A71F18(EnDno* this, GlobalContext* globalCtx) { break; case 9: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 10, &this->unk_32C); globalCtx->msgCtx.msgMode = 0x44; } @@ -432,13 +432,13 @@ void func_80A71F18(EnDno* this, GlobalContext* globalCtx) { break; case 0x80C: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { func_80151938(globalCtx, 0x80D); } break; case 0x80D: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { func_80151938(globalCtx, 0x80E); } break; @@ -450,20 +450,20 @@ void func_80A71F18(EnDno* this, GlobalContext* globalCtx) { if (this->skelAnime.curFrame == this->skelAnime.endFrame) { SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 13, &this->unk_32C); } - } else if ((this->unk_32C == 13) && func_80147624(globalCtx)) { + } else if ((this->unk_32C == 13) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); func_80A71B68(this, globalCtx); } break; case 0x80F: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { func_80151938(globalCtx, 0x810); } break; case 0x810: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { this->unk_3B0 |= 0x20; func_801477B4(globalCtx); func_80A71B68(this, globalCtx); @@ -484,7 +484,7 @@ void func_80A71F18(EnDno* this, GlobalContext* globalCtx) { break; case 0x811: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); func_80A71B68(this, globalCtx); } @@ -558,7 +558,7 @@ void func_80A725F8(EnDno* this, GlobalContext* globalCtx) { case 2: if (Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x2D8)) { - gSaveContext.weekEventReg[93] |= 2; + gSaveContext.save.weekEventReg[93] |= 2; Message_StartTextbox(globalCtx, 0x802, &this->actor); } break; @@ -572,7 +572,7 @@ void func_80A725F8(EnDno* this, GlobalContext* globalCtx) { case 1: case 2: case 3: - if (((globalCtx->msgCtx.unk11F04 == 0x800) || (globalCtx->msgCtx.unk11F04 == 0x801)) && + if (((globalCtx->msgCtx.currentTextId == 0x800) || (globalCtx->msgCtx.currentTextId == 0x801)) && (this->unk_32C == 8)) { Math_SmoothStepToF(&this->unk_454, 1.0f, 1.0f, 0.1f, 0.01f); if (this->skelAnime.curFrame <= 23.0f) { @@ -596,10 +596,10 @@ void func_80A725F8(EnDno* this, GlobalContext* globalCtx) { case 4: case 5: case 6: - switch (globalCtx->msgCtx.unk11F04) { + switch (globalCtx->msgCtx.currentTextId) { case 0x800: case 0x801: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x44; this->unk_452 = 1; this->unk_454 = 0.0f; @@ -608,7 +608,7 @@ void func_80A725F8(EnDno* this, GlobalContext* globalCtx) { break; case 0x802: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (INV_CONTENT(ITEM_MASK_SCENTS) == ITEM_MASK_SCENTS) { this->unk_458 = GI_RUPEE_RED; } else { @@ -621,14 +621,14 @@ void func_80A725F8(EnDno* this, GlobalContext* globalCtx) { break; case 0x803: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { func_80A72AE4(this, globalCtx); } break; case 0x804: if (this->unk_32C == 14) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 5, &this->unk_32C); if (!(this->unk_3B0 & 0x40)) { func_80A72CF8(this, globalCtx); @@ -642,7 +642,7 @@ void func_80A725F8(EnDno* this, GlobalContext* globalCtx) { break; case 0x806: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { func_80151938(globalCtx, 0x800); } break; @@ -687,12 +687,12 @@ void func_80A72C04(EnDno* this, GlobalContext* globalCtx) { this->actor.flags |= ACTOR_FLAG_8000000; this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); Math_Vec3f_Copy(&this->unk_334, &this->actor.world.pos); - func_8013DCE0(globalCtx, &this->unk_334, &this->actor, &this->unk_340, globalCtx->setupPathList, - ENDNO_GET_7F(&this->actor), 1, 0, 1, 0); - func_8013DF3C(globalCtx, &this->unk_340); + SubS_ActorPathing_Init(globalCtx, &this->unk_334, &this->actor, &this->actorPath, globalCtx->setupPathList, + ENDNO_GET_7F(&this->actor), 1, 0, 1, 0); + SubS_ActorPathing_ComputePointInfo(globalCtx, &this->actorPath); - this->actor.world.rot.y = this->unk_340.unk_54.y; - this->actor.world.rot.x = this->unk_340.unk_54.x; + this->actor.world.rot.y = this->actorPath.rotToCurPoint.y; + this->actor.world.rot.x = this->actorPath.rotToCurPoint.x; Flags_SetSwitch(globalCtx, ENDNO_GET_3F80(&this->actor)); this->actionFunc = func_80A730A0; @@ -704,8 +704,8 @@ void func_80A72CF8(EnDno* this, GlobalContext* globalCtx) { this->actor.floorHeight, this->actor.world.pos.z, 0, 0, 0, 0x201); } -s32 func_80A72D8C(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1) { - Actor* actor = arg1->actor; +s32 EnDno_ActorPathing_UpdateActorInfo(GlobalContext* globalCtx, ActorPathing* actorPath) { + Actor* thisx = actorPath->actor; s32 pad; s32 ret = false; f32 sp38; @@ -713,52 +713,52 @@ s32 func_80A72D8C(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1) { s32 temp_v0_2; s32 sp2C; - actor->gravity = 0.0f; - temp_v0 = actor->yawTowardsPlayer - actor->world.rot.y; + thisx->gravity = 0.0f; + temp_v0 = thisx->yawTowardsPlayer - thisx->world.rot.y; if ((temp_v0 <= 0x4000) && (temp_v0 >= -0x4000)) { - Math_SmoothStepToF(&actor->speedXZ, 15.0f, 0.8f, 1.0f, 0.01f); + Math_SmoothStepToF(&thisx->speedXZ, 15.0f, 0.8f, 1.0f, 0.01f); } else { - if (actor->xzDistToPlayer <= 80.0f) { - Math_SmoothStepToF(&actor->speedXZ, 8.0f, 0.5f, 0.5f, 0.01f); - } else if (actor->xzDistToPlayer <= 360.0f) { - Math_SmoothStepToF(&actor->speedXZ, 7.0f, 0.5f, 0.5f, 0.01f); + if (thisx->xzDistToPlayer <= 80.0f) { + Math_SmoothStepToF(&thisx->speedXZ, 8.0f, 0.5f, 0.5f, 0.01f); + } else if (thisx->xzDistToPlayer <= 360.0f) { + Math_SmoothStepToF(&thisx->speedXZ, 7.0f, 0.5f, 0.5f, 0.01f); } else { - Math_SmoothStepToF(&actor->speedXZ, 3.5f, 0.5f, 0.5f, 0.01f); + Math_SmoothStepToF(&thisx->speedXZ, 3.5f, 0.5f, 0.5f, 0.01f); } } - if (arg1->unk_50 < SQ(actor->speedXZ)) { + if (actorPath->distSqToCurPoint < SQ(thisx->speedXZ)) { ret = true; } else { - sp38 = actor->speedXZ / sqrtf(arg1->unk_4C); - sp2C = ABS(arg1->unk_54.x - actor->world.rot.x); + sp38 = thisx->speedXZ / sqrtf(actorPath->distSqToCurPointXZ); + sp2C = ABS(actorPath->rotToCurPoint.x - thisx->world.rot.x); temp_v0_2 = sp2C; temp_v0_2 *= sp38; temp_v0_2 += 0x71C; - sp2C = ABS(arg1->unk_54.y - actor->world.rot.y); + sp2C = ABS(actorPath->rotToCurPoint.y - thisx->world.rot.y); - Math_ScaledStepToS(&actor->world.rot.x, arg1->unk_54.x, temp_v0_2); - Math_ScaledStepToS(&actor->world.rot.y, arg1->unk_54.y, (s32)(sp2C * sp38) + 0x71C); + Math_ScaledStepToS(&thisx->world.rot.x, actorPath->rotToCurPoint.x, temp_v0_2); + Math_ScaledStepToS(&thisx->world.rot.y, actorPath->rotToCurPoint.y, (s32)(sp2C * sp38) + 0x71C); } return ret; } -s32 func_80A72FAC(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1) { - Actor* actor = arg1->actor; - EnDno* dno = (EnDno*)actor; - f32 sp24 = Math_CosS(-actor->world.rot.x) * actor->speedXZ; +s32 EnDno_ActorPathing_Move(GlobalContext* globalCtx, ActorPathing* actorPath) { + Actor* thisx = actorPath->actor; + EnDno* this = (EnDno*)thisx; + f32 sp24 = Math_CosS(-thisx->world.rot.x) * thisx->speedXZ; f32 sp20 = gFramerateDivisorHalf; - actor->velocity.x = Math_SinS(actor->world.rot.y) * sp24; - actor->velocity.y = Math_SinS(-actor->world.rot.x) * actor->speedXZ; - actor->velocity.z = Math_CosS(actor->world.rot.y) * sp24; + thisx->velocity.x = Math_SinS(thisx->world.rot.y) * sp24; + thisx->velocity.y = Math_SinS(-thisx->world.rot.x) * thisx->speedXZ; + thisx->velocity.z = Math_CosS(thisx->world.rot.y) * sp24; - dno->unk_334.x += (dno->actor.velocity.x * sp20) + dno->actor.colChkInfo.displacement.x; - dno->unk_334.y += (dno->actor.velocity.y * sp20) + dno->actor.colChkInfo.displacement.y; - dno->unk_334.z += (dno->actor.velocity.z * sp20) + dno->actor.colChkInfo.displacement.z; + this->unk_334.x += (this->actor.velocity.x * sp20) + this->actor.colChkInfo.displacement.x; + this->unk_334.y += (this->actor.velocity.y * sp20) + this->actor.colChkInfo.displacement.y; + this->unk_334.z += (this->actor.velocity.z * sp20) + this->actor.colChkInfo.displacement.z; - return 0; + return false; } void func_80A730A0(EnDno* this, GlobalContext* globalCtx) { @@ -786,11 +786,13 @@ void func_80A730A0(EnDno* this, GlobalContext* globalCtx) { } } - func_8013DE04(globalCtx, &this->unk_340, func_8013DF3C, func_80A72D8C, func_80A72FAC, func_8013E0A4); + SubS_ActorPathing_Update(globalCtx, &this->actorPath, SubS_ActorPathing_ComputePointInfo, + EnDno_ActorPathing_UpdateActorInfo, EnDno_ActorPathing_Move, + SubS_ActorPathing_SetNextPoint); this->unk_45C += 6553; - this->unk_340.unk_2C.x = 0.0f; - this->unk_340.unk_2C.y = 0.0f; - this->unk_340.unk_2C.z = 0.0f; + this->actorPath.pointOffset.x = 0.0f; + this->actorPath.pointOffset.y = 0.0f; + this->actorPath.pointOffset.z = 0.0f; Math_Vec3f_Copy(&this->actor.world.pos, &this->unk_334); temp_f10 = (4.0f + Math_SinS(this->unk_3AE)) * Math_SinS(this->unk_3AC); this->actor.world.pos.y += temp_f10; @@ -799,8 +801,8 @@ void func_80A730A0(EnDno* this, GlobalContext* globalCtx) { this->actor.shape.rot.y = this->actor.yawTowardsPlayer; func_80A715DC(this, globalCtx); func_800B9010(&this->actor, NA_SE_EV_BUTLER_FRY - SFX_FLAG); - if (this->unk_340.unk_1C & 0x20) { - Math_Vec3f_Copy(&this->actor.world.pos, &this->unk_340.unk_20); + if (this->actorPath.flags & ACTOR_PATHING_REACHED_END_PERMANENT) { + Math_Vec3f_Copy(&this->actor.world.pos, &this->actorPath.curPoint); this->actor.speedXZ = 0.0f; this->actor.velocity.x = 0.0f; this->actor.velocity.y = 0.0f; diff --git a/src/overlays/actors/ovl_En_Dno/z_en_dno.h b/src/overlays/actors/ovl_En_Dno/z_en_dno.h index 350e0c0049..dcffee6c9d 100644 --- a/src/overlays/actors/ovl_En_Dno/z_en_dno.h +++ b/src/overlays/actors/ovl_En_Dno/z_en_dno.h @@ -34,7 +34,7 @@ typedef struct EnDno { /* 0x32C */ s32 unk_32C; /* 0x330 */ UNK_TYPE1 unk_330[0x4]; /* 0x334 */ Vec3f unk_334; - /* 0x340 */ struct_8013DF3C_arg1 unk_340; + /* 0x340 */ ActorPathing actorPath; /* 0x3AC */ s16 unk_3AC; /* 0x3AE */ s16 unk_3AE; /* 0x3B0 */ u16 unk_3B0; diff --git a/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c b/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c index d7274837cb..3e9bd9f6ef 100644 --- a/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c +++ b/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c @@ -206,7 +206,7 @@ s32 func_80B3CF60(EnDnp* this, GlobalContext* globalCtx) { this->unk_322 |= 8; this->actionFunc = func_80B3D3F8; ret = true; - } else if (!(gSaveContext.weekEventReg[23] & 0x20) && Actor_HasParent(&this->actor, globalCtx)) { + } else if (!(gSaveContext.save.weekEventReg[23] & 0x20) && Actor_HasParent(&this->actor, globalCtx)) { SubS_UpdateFlags(&this->unk_322, 0, 7); this->unk_322 &= ~0x500; this->actor.parent = NULL; @@ -247,10 +247,10 @@ void func_80B3D11C(EnDnp* this, GlobalContext* globalCtx) { s32 temp_v0; s32 val; - if (!(gSaveContext.weekEventReg[29] & 0x40) && (globalCtx->sceneNum == SCENE_MITURIN) && + if (!(gSaveContext.save.weekEventReg[29] & 0x40) && (globalCtx->sceneNum == SCENE_MITURIN) && (globalCtx->csCtx.currentCsIndex == 0)) { this->unk_322 |= 0x20; - gSaveContext.weekEventReg[29] |= 0x40; + gSaveContext.save.weekEventReg[29] |= 0x40; } if (Cutscene_CheckActorAction(globalCtx, 101)) { @@ -337,7 +337,7 @@ void func_80B3D47C(EnDnp* this, GlobalContext* globalCtx) { void func_80B3D558(EnDnp* this, GlobalContext* globalCtx) { if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); - gSaveContext.weekEventReg[23] |= 0x20; + gSaveContext.save.weekEventReg[23] |= 0x20; } else { ActorCutscene_SetIntentToPlay(this->actor.cutscene); } @@ -366,12 +366,12 @@ void EnDnp_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.cutscene = 0x10; this->actionFunc = func_80B3D47C; } else if (((ENDNP_GET_7(&this->actor) == ENDNP_GET_7_0) && !Interface_HasItemInBottle(ITEM_DEKU_PRINCESS) && - !(gSaveContext.weekEventReg[23] & 0x20)) || - ((ENDNP_GET_7(&this->actor) == ENDNP_GET_7_2) && (gSaveContext.weekEventReg[23] & 0x20))) { + !(gSaveContext.save.weekEventReg[23] & 0x20)) || + ((ENDNP_GET_7(&this->actor) == ENDNP_GET_7_2) && (gSaveContext.save.weekEventReg[23] & 0x20))) { Actor_SetScale(&this->actor, 0.0085f); SubS_UpdateFlags(&this->unk_322, 3, 7); this->unk_322 |= 0x400; - if ((globalCtx->sceneNum == SCENE_MITURIN) && (gSaveContext.weekEventReg[29] & 0x40)) { + if ((globalCtx->sceneNum == SCENE_MITURIN) && (gSaveContext.save.weekEventReg[29] & 0x40)) { this->unk_322 |= 0x20; func_80B3CC38(this, 1); } @@ -407,10 +407,10 @@ void EnDnp_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); sp2C = this->collider.dim.radius + 50; sp28 = this->collider.dim.height + 30; - if ((this->unk_322 & 0x400) && !(gSaveContext.weekEventReg[23] & 0x20)) { + if ((this->unk_322 & 0x400) && !(gSaveContext.save.weekEventReg[23] & 0x20)) { Actor_PickUp(&this->actor, globalCtx, GI_MAX, sp2C, sp28); } - func_8013C964(&this->actor, globalCtx, sp2C, sp28, 0, this->unk_322 & 7); + func_8013C964(&this->actor, globalCtx, sp2C, sp28, EXCH_ITEM_NONE, this->unk_322 & 7); Actor_SetFocus(&this->actor, 30.0f); func_80B3CC80(this, globalCtx); } diff --git a/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c b/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c index f25abc6a4f..ae7f918f13 100644 --- a/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c +++ b/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c @@ -254,7 +254,7 @@ s32 func_80A52A78(EnDnq* this, GlobalContext* globalCtx) { s32 func_80A52B68(EnDnq* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - u16 temp = globalCtx->msgCtx.unk11F04; + u16 temp = globalCtx->msgCtx.currentTextId; if ((player->stateFlags1 & 0x40) && (player->targetActor == &this->actor)) { switch (temp) { @@ -306,7 +306,7 @@ void func_80A52C6C(EnDnq* this, GlobalContext* globalCtx) { } s32* func_80A52CF8(EnDnq* this, GlobalContext* globalCtx) { - if (gSaveContext.weekEventReg[23] & 0x20) { + if (gSaveContext.save.weekEventReg[23] & 0x20) { return &D_80A53400[14]; } @@ -340,11 +340,11 @@ void func_80A52DC8(EnDnq* this, GlobalContext* globalCtx) { SubS_UpdateFlags(&this->unk_37C, 0, 7); } - if (!(gSaveContext.weekEventReg[23] & 0x20)) { + if (!(gSaveContext.save.weekEventReg[23] & 0x20)) { this->unk_390 = 70.0f; - if (Interface_HasItemInBottle(ITEM_DEKU_PRINCESS) && !func_801690CC(globalCtx) && + if (Interface_HasItemInBottle(ITEM_DEKU_PRINCESS) && !Play_InCsMode(globalCtx) && (Message_GetState(&globalCtx->msgCtx) == 0) && (ActorCutscene_GetCurrentIndex() == -1)) { - if ((DECR(this->unk_384) == 0) && (gSaveContext.weekEventReg[29] & 0x40)) { + if ((DECR(this->unk_384) == 0) && (gSaveContext.save.weekEventReg[29] & 0x40)) { Message_StartTextbox(globalCtx, 0x969, NULL); this->unk_384 = 200; } @@ -358,7 +358,7 @@ void func_80A52DC8(EnDnq* this, GlobalContext* globalCtx) { this->actor.xzDistToPlayer = this->unk_394; - if (gSaveContext.weekEventReg[83] & 8) { + if (gSaveContext.save.weekEventReg[83] & 8) { func_80A52A78(this, globalCtx); } else if (this->unk_3A4 == 0) { Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 3, 0x2AA8); @@ -427,7 +427,7 @@ void EnDnq_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_386 = 0; this->unk_37C = 0; SubS_UpdateFlags(&this->unk_37C, 3, 7); - if (gSaveContext.weekEventReg[9] & 0x80) { + if (gSaveContext.save.weekEventReg[9] & 0x80) { this->unk_3A4 = 1; } else { this->unk_3A4 = 0; @@ -455,7 +455,7 @@ void EnDnq_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); this->unk_394 = this->actor.xzDistToPlayer; func_80A52C6C(this, globalCtx); - func_8013C964(&this->actor, globalCtx, this->unk_390, fabsf(this->actor.playerHeightRel) + 1.0f, 0, + func_8013C964(&this->actor, globalCtx, this->unk_390, fabsf(this->actor.playerHeightRel) + 1.0f, EXCH_ITEM_NONE, this->unk_37C & 7); this->actor.xzDistToPlayer = this->unk_394; Actor_SetFocus(&this->actor, 46.0f); diff --git a/src/overlays/actors/ovl_En_Dns/z_en_dns.c b/src/overlays/actors/ovl_En_Dns/z_en_dns.c index b9f1605f9d..6b7943504b 100644 --- a/src/overlays/actors/ovl_En_Dns/z_en_dns.c +++ b/src/overlays/actors/ovl_En_Dns/z_en_dns.c @@ -182,7 +182,7 @@ void func_8092C934(EnDns* this) { s32* func_8092C9BC(EnDns* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (!(gSaveContext.weekEventReg[23] & 0x20)) { + if (!(gSaveContext.save.weekEventReg[23] & 0x20)) { if (player->transformation != PLAYER_FORM_DEKU) { return &D_8092DCB0[16]; } else if (this->unk_2FC != 0) { @@ -274,7 +274,7 @@ s32 func_8092CC68(GlobalContext* globalCtx) { s32 ret = false; s16 bgId; - if (!func_801690CC(globalCtx) && (player->actor.bgCheckFlags & 1) && (player->transformation != PLAYER_FORM_DEKU)) { + if (!Play_InCsMode(globalCtx) && (player->actor.bgCheckFlags & 1) && (player->transformation != PLAYER_FORM_DEKU)) { bgId = player->actor.floorBgId; if (SurfaceType_GetSceneExitIndex(&globalCtx->colCtx, player->actor.floorPoly, bgId) != 4) { ret = true; @@ -361,14 +361,14 @@ s32 func_8092D068(EnDns* this) { s32 ret = false; if (ENDNS_GET_8000(&this->actor)) { - if (gSaveContext.weekEventReg[23] & 0x20) { + if (gSaveContext.save.weekEventReg[23] & 0x20) { ret = true; } } else if (ENDNS_GET_4000(&this->actor)) { - if ((gSaveContext.weekEventReg[9] & 0x80) && !(gSaveContext.weekEventReg[23] & 0x20)) { + if ((gSaveContext.save.weekEventReg[9] & 0x80) && !(gSaveContext.save.weekEventReg[23] & 0x20)) { ret = true; } - } else if (!(gSaveContext.weekEventReg[9] & 0x80) && !(gSaveContext.weekEventReg[23] & 0x20)) { + } else if (!(gSaveContext.save.weekEventReg[9] & 0x80) && !(gSaveContext.save.weekEventReg[23] & 0x20)) { ret = true; } @@ -399,7 +399,8 @@ void func_8092D1B8(EnDns* this, GlobalContext* globalCtx) { } if (!ENDNS_GET_4000(&this->actor) || (this->unk_2D2 != 0)) { - if (!(gSaveContext.weekEventReg[23] & 0x20) && !(gSaveContext.eventInf[1] & 0x20) && func_8092CC68(globalCtx)) { + if (!(gSaveContext.save.weekEventReg[23] & 0x20) && !(gSaveContext.eventInf[1] & 0x20) && + func_8092CC68(globalCtx)) { player->stateFlags1 |= 0x20; this->unk_2C6 |= 0x100; SubS_UpdateFlags(&this->unk_2C6, 4, 7); @@ -524,7 +525,7 @@ void EnDns_Init(Actor* thisx, GlobalContext* globalCtx) { SubS_UpdateFlags(&this->unk_2C6, 3, 7); this->unk_2C6 |= (0x40 | 0x10); this->unk_2C6 |= 0x200; - if (gSaveContext.weekEventReg[9] & 0x80) { + if (gSaveContext.save.weekEventReg[9] & 0x80) { this->unk_2FC = 1; } else { this->unk_2FC = 0; @@ -553,7 +554,7 @@ void EnDns_Update(Actor* thisx, GlobalContext* globalCtx) { func_8092C934(this); func_8092C86C(this, globalCtx); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); - func_8013C964(&this->actor, globalCtx, 80.0f, 40.0f, 0, this->unk_2C6 & 7); + func_8013C964(&this->actor, globalCtx, 80.0f, 40.0f, EXCH_ITEM_NONE, this->unk_2C6 & 7); Actor_SetFocus(&this->actor, 34.0f); func_8092C6FC(this, globalCtx); func_8092C5C0(this); diff --git a/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c b/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c index 8432b632ab..a630a0dcba 100644 --- a/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c +++ b/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c @@ -293,7 +293,7 @@ void EnDodongo_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_330.r = 255; this->unk_330.g = 10; this->unk_330.a = 200; - Math_Vec3f_Copy(&this->unk_314, &D_801C5DB0); + Math_Vec3f_Copy(&this->unk_314, &gOneVec3f); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 48.0f); SkelAnime_Init(globalCtx, &this->skelAnime, &object_dodongo_Skel_008318, &object_dodongo_Anim_004C20, this->jointTable, this->morphTable, 31); @@ -399,13 +399,13 @@ void func_80876B08(EnDodongo* this, GlobalContext* globalCtx) { void func_80876BD0(EnDodongo* this, GlobalContext* globalCtx, s32 arg2) { if (this->actor.colChkInfo.damageEffect == 2) { - this->unk_300 = 0; - this->unk_340 = 0.75f; - this->unk_33C = 4.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffAlpha = 4.0f; } else if (this->actor.colChkInfo.damageEffect == 4) { - this->unk_300 = 20; - this->unk_340 = 0.75f; - this->unk_33C = 4.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffAlpha = 4.0f; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->collider1.elements[arg2].info.bumper.hitPos.x, this->collider1.elements[arg2].info.bumper.hitPos.y, @@ -414,24 +414,24 @@ void func_80876BD0(EnDodongo* this, GlobalContext* globalCtx, s32 arg2) { } void func_80876CAC(EnDodongo* this) { - this->unk_300 = 10; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; this->collider1.base.colType = COLTYPE_HIT3; - this->unk_340 = 0.75f; - this->unk_344 = 1.125f; - this->unk_33C = 1.0f; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffFrozenSteamScale = 1.125f; + this->drawDmgEffAlpha = 1.0f; this->timer = 80; this->actor.flags &= ~ACTOR_FLAG_400; Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 80); } void func_80876D28(EnDodongo* this, GlobalContext* globalCtx) { - if (this->unk_300 == 10) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { this->timer = 0; this->actor.colorFilterTimer = 0; - this->unk_300 = 0; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->collider1.base.colType = COLTYPE_HIT0; - this->unk_33C = 0.0f; - Actor_SpawnIceEffects(globalCtx, &this->actor, &this->unk_348[0], 9, 2, this->unk_334 * 0.3f, + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, &this->limbPos[0], 9, 2, this->unk_334 * 0.3f, this->unk_334 * 0.2f); this->actor.flags |= ACTOR_FLAG_400; } @@ -448,7 +448,7 @@ void func_80876DC4(EnDodongo* this, GlobalContext* globalCtx) { f32 temp_f22; f32 temp_f20; - Math_Vec3f_Copy(&sp68, &this->unk_348[0]); + Math_Vec3f_Copy(&sp68, &this->limbPos[0]); sp66 = (Rand_Next() >> 0x12) + this->actor.shape.rot.y; temp_f20 = Math_CosS(sp66); temp_f22 = Math_SinS(sp66); @@ -496,8 +496,8 @@ void func_80876DC4(EnDodongo* this, GlobalContext* globalCtx) { sp74.z = (Rand_ZeroFloat(0.1f) + 0.15f) * -temp_f22 * this->unk_334; func_800B0EB0(globalCtx, &sp68, &sp80, &sp74, &this->unk_32C, &this->unk_330, sp64, sp62, 0x14); - sp68.x = this->unk_348[0].x + (temp_f20 * 6.0f * this->unk_334); - sp68.z = this->unk_348[0].z - (temp_f22 * 6.0f * this->unk_334); + sp68.x = this->limbPos[0].x + (temp_f20 * 6.0f * this->unk_334); + sp68.z = this->limbPos[0].z - (temp_f22 * 6.0f * this->unk_334); sp80.x *= -1.0f; sp80.z = sp80.z * -1.0f; sp74.x = (Rand_ZeroFloat(0.1f) + 0.15f) * -temp_f20 * this->unk_334; @@ -622,9 +622,9 @@ void func_808777A8(EnDodongo* this) { for (i = 0; i < ARRAY_COUNT(this->collider3Elements); i++) { sph = &this->collider3.elements[i].dim.worldSphere; - sph->center.x = this->unk_348[0].x; - sph->center.y = this->unk_348[0].y; - sph->center.z = this->unk_348[0].z; + sph->center.x = this->limbPos[0].x; + sph->center.y = this->limbPos[0].y; + sph->center.z = this->limbPos[0].z; sph->radius = 0; } @@ -658,10 +658,10 @@ void func_8087784C(EnDodongo* this, GlobalContext* globalCtx) { temp_f12 = Math_CosS(this->actor.shape.rot.y) * this->unk_334; for (i = 0; i < end; i++, element++) { - element->dim.worldSphere.center.x = this->unk_348[0].x + (element->dim.modelSphere.center.z * temp_f2); + element->dim.worldSphere.center.x = this->limbPos[0].x + (element->dim.modelSphere.center.z * temp_f2); element->dim.worldSphere.center.y = - this->unk_348[0].y + (element->dim.modelSphere.center.y * this->unk_334); - element->dim.worldSphere.center.z = this->unk_348[0].z + (element->dim.modelSphere.center.z * temp_f12); + this->limbPos[0].y + (element->dim.modelSphere.center.y * this->unk_334); + element->dim.worldSphere.center.z = this->limbPos[0].z + (element->dim.modelSphere.center.z * temp_f12); element->dim.worldSphere.radius = element->dim.modelSphere.radius; } @@ -669,7 +669,7 @@ void func_8087784C(EnDodongo* this, GlobalContext* globalCtx) { D_80879348.x = 2.5f * temp_f2; D_80879348.y = this->unk_334 * 1.4f; D_80879348.z = 2.5f * temp_f12; - EffectSsDFire_Spawn(globalCtx, &this->unk_348[0], &D_80879354, &D_80879348, this->unk_334 * 100.0f, + EffectSsDFire_Spawn(globalCtx, &this->limbPos[0], &D_80879354, &D_80879348, this->unk_334 * 100.0f, this->unk_334 * 35.0f, 0xFF - (frame * 10), 5, 0, 8); } else if ((this->skelAnime.curFrame >= 2.0f) && (this->skelAnime.curFrame <= 20.0f)) { func_800B9010(&this->actor, NA_SE_EN_DODO_J_BREATH - SFX_FLAG); @@ -772,13 +772,13 @@ void func_80877E60(EnDodongo* this, GlobalContext* globalCtx) { } else { sp5E = this->unk_334 * 50.0f; sp5C = this->unk_334 * 5.0f; - Math_Vec3f_Copy(&sp64, &this->unk_348[0]); + Math_Vec3f_Copy(&sp64, &this->limbPos[0]); func_800B0DE0(globalCtx, &sp64, &gZeroVec3f, &D_80879360, &D_8087936C, &D_8087936C, sp5E, sp5C); sp64.x -= Math_CosS(this->actor.shape.rot.y) * 6.0f * this->unk_334; sp64.z += Math_SinS(this->actor.shape.rot.y) * 6.0f * this->unk_334; func_800B0DE0(globalCtx, &sp64, &gZeroVec3f, &D_80879360, &D_8087936C, &D_8087936C, sp5E, sp5C); - sp64.x = (2.0f * this->unk_348[0].x) - sp64.x; - sp64.z = (2.0f * this->unk_348[0].z) - sp64.z; + sp64.x = (2.0f * this->limbPos[0].x) - sp64.x; + sp64.z = (2.0f * this->limbPos[0].z) - sp64.z; func_800B0DE0(globalCtx, &sp64, &gZeroVec3f, &D_80879360, &D_8087936C, &D_8087936C, sp5E, sp5C); } } @@ -953,7 +953,8 @@ void EnDodongo_UpdateDamage(EnDodongo* this, GlobalContext* globalCtx) { } if ((i != ARRAY_COUNT(this->collider2Elements)) && - ((this->unk_300 != 10) || !(this->collider2.elements[i].info.acHitInfo->toucher.dmgFlags & 0xDB0B3))) { + ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || + !(this->collider2.elements[i].info.acHitInfo->toucher.dmgFlags & 0xDB0B3))) { func_80876D28(this, globalCtx); Math_Vec3s_ToVec3f(&sp3C, &this->collider2.elements[i].info.bumper.hitPos); if (this->actor.colChkInfo.damageEffect == 0xF) { @@ -976,7 +977,8 @@ void EnDodongo_UpdateDamage(EnDodongo* this, GlobalContext* globalCtx) { } if ((i != ARRAY_COUNT(this->collider1Elements)) && - ((this->unk_300 != 10) || !(this->collider1.elements[i].info.acHitInfo->toucher.dmgFlags & 0xDB0B3))) { + ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || + !(this->collider1.elements[i].info.acHitInfo->toucher.dmgFlags & 0xDB0B3))) { func_80876D28(this, globalCtx); if (this->actor.colChkInfo.damageEffect != 0xF) { if (!Actor_ApplyDamage(&this->actor)) { @@ -1000,9 +1002,9 @@ void EnDodongo_UpdateDamage(EnDodongo* this, GlobalContext* globalCtx) { this->timer = 40; Actor_SetColorFilter(&this->actor, 0, 0xFF, 0, 40); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); - this->unk_300 = 30; - this->unk_340 = 0.75f; - this->unk_33C = 2.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffAlpha = 2.0f; func_80878594(this); } else if (this->actor.colChkInfo.damageEffect == 3) { func_80876CAC(this); @@ -1043,12 +1045,12 @@ void EnDodongo_Update(Actor* thisx, GlobalContext* globalCtx2) { CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider3.base); } - if (this->unk_33C > 0.0f) { - if (this->unk_300 != 10) { - Math_StepToF(&this->unk_33C, 0.0f, 0.05f); - this->unk_340 = (this->unk_33C + 1.0f) * 0.375f; - this->unk_340 = (this->unk_340 > 0.75f) ? 0.75f : this->unk_340; - } else if (!Math_StepToF(&this->unk_344, 0.75f, 0.01875f)) { + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.375f; + this->drawDmgEffScale = (this->drawDmgEffScale > 0.75f) ? 0.75f : this->drawDmgEffScale; + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.75f, 0.01875f)) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } @@ -1079,20 +1081,20 @@ void EnDodongo_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList Collider_UpdateSpheres(limbIndex, &this->collider1); Collider_UpdateSpheres(limbIndex, &this->collider2); if (D_80879388[limbIndex] != -1) { - Matrix_GetStateTranslation(&this->unk_348[D_80879388[limbIndex]]); + Matrix_GetStateTranslation(&this->limbPos[D_80879388[limbIndex]]); } if (limbIndex == 7) { Matrix_MultiplyVector3fByState(&D_80879370, &this->unk_308); - Matrix_MultiplyVector3fByState(&D_8087937C, &this->unk_348[0]); + Matrix_MultiplyVector3fByState(&D_8087937C, &this->limbPos[0]); Matrix_GetStateTranslation(&this->actor.focus.pos); - Matrix_GetStateTranslationAndScaledY(-200.0f, &this->unk_348[1]); + Matrix_GetStateTranslationAndScaledY(-200.0f, &this->limbPos[1]); } else if (limbIndex == 13) { Matrix_GetStateTranslationAndScaledX(1600.0f, &this->unk_320); } if ((limbIndex == 30) && (this->actionFunc == func_80878424) && (this->timer != this->unk_304)) { - EffectBlure_AddVertex(Effect_GetByIndex(this->unk_338), &this->unk_320, &this->unk_348[4]); + EffectBlure_AddVertex(Effect_GetByIndex(this->unk_338), &this->unk_320, &this->limbPos[4]); this->unk_304 = this->timer; } } @@ -1103,6 +1105,7 @@ void EnDodongo_Draw(Actor* thisx, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnDodongo_OverrideLimbDraw, EnDodongo_PostLimbDraw, &this->actor); - func_800BE680(globalCtx, &this->actor, this->unk_348, ARRAY_COUNT(this->unk_348), this->unk_340 * this->unk_334, - this->unk_344 * this->unk_334, this->unk_33C, this->unk_300); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + this->drawDmgEffScale * this->unk_334, this->drawDmgEffFrozenSteamScale * this->unk_334, + this->drawDmgEffAlpha, this->drawDmgEffType); } diff --git a/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.h b/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.h index 4a7fe8e9d8..30562404f2 100644 --- a/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.h +++ b/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.h @@ -13,7 +13,7 @@ typedef struct EnDodongo { /* 0x188 */ Vec3s jointTable[31]; /* 0x242 */ Vec3s morphTable[31]; /* 0x2FC */ EnDodongoActionFunc actionFunc; - /* 0x300 */ u8 unk_300; + /* 0x300 */ u8 drawDmgEffType; /* 0x302 */ s16 timer; /* 0x304 */ s16 unk_304; /* 0x306 */ s16 unk_306; @@ -24,10 +24,10 @@ typedef struct EnDodongo { /* 0x330 */ Color_RGBA8 unk_330; /* 0x334 */ f32 unk_334; /* 0x338 */ s32 unk_338; - /* 0x33C */ f32 unk_33C; - /* 0x340 */ f32 unk_340; - /* 0x344 */ f32 unk_344; - /* 0x348 */ Vec3f unk_348[9]; + /* 0x33C */ f32 drawDmgEffAlpha; + /* 0x340 */ f32 drawDmgEffScale; + /* 0x344 */ f32 drawDmgEffFrozenSteamScale; + /* 0x348 */ Vec3f limbPos[9]; /* 0x3B4 */ ColliderJntSph collider1; /* 0x3D4 */ ColliderJntSphElement collider1Elements[10]; /* 0x654 */ ColliderJntSph collider2; diff --git a/src/overlays/actors/ovl_En_Door/z_en_door.c b/src/overlays/actors/ovl_En_Door/z_en_door.c index e5733c2b16..fe65bb30d8 100644 --- a/src/overlays/actors/ovl_En_Door/z_en_door.c +++ b/src/overlays/actors/ovl_En_Door/z_en_door.c @@ -38,104 +38,243 @@ void func_808670F0(EnDoor*, GlobalContext*); void func_80866A5C(EnDoor*, GlobalContext*); u8 D_808675D0[] = { - 0x0C, 0x00, 0x03, 0x0E, 0x02, 0x06, 0x00, 0x17, 0x00, 0x08, - 0x02, 0x00, 0x00, 0x06, 0x00, 0x02, 0x09, 0x07, 0x05, 0x00, + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(3, 0x12 - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(6, 0, 23, 0, 0x12 - 0x0A), + /* 0x0A */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 0, 6, 0, 0x12 - 0x10), + /* 0x10 */ SCHEDULE_CMD_RET_VAL_S(7), + /* 0x12 */ SCHEDULE_CMD_RET_NONE(), }; u8 D_808675E4[] = { - 0x0F, 0x09, 0x00, 0x47, 0x0F, 0x0C, 0x00, 0x15, 0x0C, 0x00, 0x01, 0x13, 0x11, 0x00, 0x0F, 0x0D, - 0x00, 0x0A, 0x0F, 0x0F, 0x00, 0x07, 0x0F, 0x00, 0x00, 0x02, 0x09, 0x09, 0x05, 0x09, 0x08, 0x0C, - 0x00, 0x02, 0x19, 0x00, 0x1C, 0x08, 0x07, 0x0F, 0x0D, 0x00, 0x02, 0x09, 0x09, 0x05, 0x0F, 0x0D, - 0x00, 0xEA, 0x0F, 0x11, 0x00, 0xE7, 0x0F, 0x00, 0x00, 0xE2, 0x09, 0x09, 0x0F, 0x0D, 0x00, 0xDC, - 0x0F, 0x0D, 0x00, 0xD9, 0x0F, 0x12, 0x00, 0x01, 0x05, 0x09, 0x09, 0x09, 0x09, 0x00, 0x00, 0x00, + /* 0x00 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(9, 0, 0x4B - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(12, 0, 0x1D - 0x08), + /* 0x08 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(1, 0x1F - 0x0C), + /* 0x0C */ SCHEDULE_CMD_BRANCH_S(0x0), + /* 0x0E */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(13, 0, 0x1C - 0x12), + /* 0x12 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(15, 0, 0x1D - 0x16), + /* 0x16 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(0, 0, 0x1C - 0x1A), + /* 0x1A */ SCHEDULE_CMD_RET_VAL_S(9), + /* 0x1C */ SCHEDULE_CMD_RET_NONE(), + /* 0x1D */ SCHEDULE_CMD_RET_VAL_S(8), + /* 0x1F */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(2, 0x3C - 0x23), + /* 0x23 */ SCHEDULE_CMD_CHECK_FLAG_S(0x1C, 0x08, 0x2E - 0x27), + /* 0x27 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(13, 0, 0x2D - 0x2B), + /* 0x2B */ SCHEDULE_CMD_RET_VAL_S(9), + /* 0x2D */ SCHEDULE_CMD_RET_NONE(), + /* 0x2E */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(13, 0, 0x1C - 0x32), + /* 0x32 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(17, 0, 0x1D - 0x36), + /* 0x36 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(0, 0, 0x1C - 0x3A), + /* 0x3A */ SCHEDULE_CMD_RET_VAL_S(9), + /* 0x3C */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(13, 0, 0x1C - 0x40), + /* 0x40 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(13, 0, 0x1D - 0x44), + /* 0x44 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(18, 0, 0x49 - 0x48), + /* 0x48 */ SCHEDULE_CMD_RET_NONE(), + /* 0x49 */ SCHEDULE_CMD_RET_VAL_S(9), + /* 0x4B */ SCHEDULE_CMD_RET_VAL_S(9), }; u8 D_80867634[] = { - 0x02, 0x06, 0x00, 0x17, 0x00, 0x02, 0x09, 0x1C, 0x05, 0x00, 0x00, 0x00, + /* 0x0 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(6, 0, 23, 0, 0x8 - 0x6), + /* 0x6 */ SCHEDULE_CMD_RET_VAL_S(28), + /* 0x8 */ SCHEDULE_CMD_RET_NONE(), }; u8 D_80867640[] = { - 0x02, 0x15, 0x00, 0x16, 0x00, 0x01, 0x05, 0x09, 0x0B, 0x00, 0x00, 0x00, + /* 0x0 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(21, 0, 22, 0, 0x7 - 0x6), + /* 0x6 */ SCHEDULE_CMD_RET_NONE(), + /* 0x7 */ SCHEDULE_CMD_RET_VAL_S(11), }; + u8 D_8086764C[] = { - 0x02, 0x16, 0x00, 0x05, 0x00, 0x02, 0x09, 0x0A, 0x05, 0x00, 0x00, 0x00, + /* 0x0 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(22, 0, 5, 0, 0x8 - 0x6), + /* 0x6 */ SCHEDULE_CMD_RET_VAL_S(10), + /* 0x8 */ SCHEDULE_CMD_RET_NONE(), }; + u8 D_80867658[] = { - 0x0C, 0x00, 0x02, 0x0F, 0x00, 0x1C, 0x08, 0x02, 0x09, 0x0C, 0x02, 0x0F, 0x0A, 0x16, 0x00, - 0x02, 0x09, 0x0C, 0x05, 0x0C, 0x00, 0x03, 0x11, 0x0F, 0x0D, 0x00, 0x0D, 0x00, 0x33, 0x08, - 0x02, 0x09, 0x0C, 0x0F, 0x16, 0x00, 0x02, 0x09, 0x0C, 0x05, 0x09, 0x0C, 0x00, 0x00, + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(2, 0x13 - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_FLAG_S(0x1C, 0x08, 0x0A - 0x08), + /* 0x08 */ SCHEDULE_CMD_RET_VAL_S(12), + /* 0x0A */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(15, 10, 22, 0, 0x12 - 0x10), + /* 0x10 */ SCHEDULE_CMD_RET_VAL_S(12), + /* 0x12 */ SCHEDULE_CMD_RET_NONE(), + /* 0x13 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(3, 0x28 - 0x17), + /* 0x17 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(13, 0, 0x28 - 0x1B), + /* 0x1B */ SCHEDULE_CMD_CHECK_FLAG_S(0x33, 0x08, 0x21 - 0x1F), + /* 0x1F */ SCHEDULE_CMD_RET_VAL_S(12), + /* 0x21 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(22, 0, 0x27 - 0x25), + /* 0x25 */ SCHEDULE_CMD_RET_VAL_S(12), + /* 0x27 */ SCHEDULE_CMD_RET_NONE(), + /* 0x28 */ SCHEDULE_CMD_RET_VAL_S(12), }; -u8 D_80867684[] = { 0x05, 0x00, 0x00, 0x00 }; +u8 D_80867684[] = { + /* 0x0 */ SCHEDULE_CMD_RET_NONE(), +}; -u8 D_80867688[] = { 0x0F, 0x16, 0x00, 0x02, 0x09, 0x0F, 0x05, 0x00 }; +u8 D_80867688[] = { + /* 0x0 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(22, 0, 0x6 - 0x4), + /* 0x4 */ SCHEDULE_CMD_RET_VAL_S(15), + /* 0x6 */ SCHEDULE_CMD_RET_NONE(), +}; -u8 D_80867690[] = { 0x0F, 0x16, 0x00, 0x02, 0x09, 0x10, 0x05, 0x00 }; +u8 D_80867690[] = { + /* 0x0 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(22, 0, 0x6 - 0x4), + /* 0x4 */ SCHEDULE_CMD_RET_VAL_S(16), + /* 0x6 */ SCHEDULE_CMD_RET_NONE(), +}; -u8 D_80867698[] = { 0x0F, 0x16, 0x00, 0x02, 0x09, 0x11, 0x05, 0x00 }; +u8 D_80867698[] = { + /* 0x0 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(22, 0, 0x6 - 0x4), + /* 0x4 */ SCHEDULE_CMD_RET_VAL_S(17), + /* 0x6 */ SCHEDULE_CMD_RET_NONE(), +}; u8 D_808676A0[] = { - 0x02, 0x0A, 0x00, 0x15, 0x00, 0x0F, 0x02, 0x16, 0x00, 0x05, 0x00, 0x02, - 0x09, 0x12, 0x08, 0x02, 0x02, 0x09, 0x22, 0x09, 0x21, 0x05, 0x00, 0x00, + /* 0x00 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 0, 21, 0, 0x15 - 0x06), + /* 0x06 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(22, 0, 5, 0, 0x0E - 0x0C), + /* 0x0C */ SCHEDULE_CMD_RET_VAL_S(18), + /* 0x0E */ SCHEDULE_CMD_CHECK_MISC_S(SCHEDULE_CHECK_MISC_MASK_ROMANI, 0x13 - 0x11), + /* 0x11 */ SCHEDULE_CMD_RET_VAL_S(34), + /* 0x13 */ SCHEDULE_CMD_RET_VAL_S(33), + /* 0x15 */ SCHEDULE_CMD_RET_NONE(), }; u8 D_808676B8[] = { - 0x08, 0x00, 0x14, 0x0C, 0x00, 0x03, 0x07, 0x0F, 0x08, 0x00, 0x01, 0x05, - 0x09, 0x13, 0x02, 0x08, 0x00, 0x14, 0x1E, 0x02, 0x09, 0x13, 0x05, 0x05, + /* 0x00 */ SCHEDULE_CMD_CHECK_MISC_S(SCHEDULE_CHECK_MISC_ROOM_KEY, 0x17 - 0x03), + /* 0x03 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(3, 0x0E - 0x07), + /* 0x07 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(8, 0, 0x0C - 0x0B), + /* 0x0B */ SCHEDULE_CMD_RET_NONE(), + /* 0x0C */ SCHEDULE_CMD_RET_VAL_S(19), + /* 0x0E */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(8, 0, 20, 30, 0x16 - 0x14), + /* 0x14 */ SCHEDULE_CMD_RET_VAL_S(19), + /* 0x16 */ SCHEDULE_CMD_RET_NONE(), + /* 0x17 */ SCHEDULE_CMD_RET_NONE(), }; -u8 D_808676D0[] = { 0x05, 0x00, 0x00, 0x00 }; +u8 D_808676D0[] = { + /* 0x0 */ SCHEDULE_CMD_RET_NONE(), +}; -u8 D_808676D4[] = { 0x05, 0x00, 0x00, 0x00 }; +u8 D_808676D4[] = { + /* 0x0 */ SCHEDULE_CMD_RET_NONE(), +}; -u8 D_808676D8[] = { 0x0C, 0x00, 0x03, 0x05, 0x0F, 0x12, 0x00, 0x01, 0x05, 0x09, 0x14, 0x00 }; +u8 D_808676D8[] = { + /* 0x0 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(3, 0x9 - 0x4), + /* 0x4 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(18, 0, 0x9 - 0x8), + /* 0x8 */ SCHEDULE_CMD_RET_NONE(), + /* 0x9 */ SCHEDULE_CMD_RET_VAL_S(20), +}; -u8 D_808676E4[] = { 0x08, 0x00, 0x02, 0x09, 0x16, 0x05, 0x00, 0x00 }; +u8 D_808676E4[] = { + /* 0x0 */ SCHEDULE_CMD_CHECK_MISC_S(SCHEDULE_CHECK_MISC_ROOM_KEY, 0x5 - 0x3), + /* 0x3 */ SCHEDULE_CMD_RET_VAL_S(22), + /* 0x5 */ SCHEDULE_CMD_RET_NONE(), +}; -u8 D_808676EC[] = { 0x05, 0x00, 0x00, 0x00 }; +u8 D_808676EC[] = { + /* 0x0 */ SCHEDULE_CMD_RET_NONE(), +}; u8 D_808676F0[] = { - 0x0C, 0x00, 0x03, 0x05, 0x0F, 0x0A, 0x00, 0x07, 0x05, 0x02, - 0x0A, 0x00, 0x14, 0x00, 0xF9, 0x09, 0x15, 0x00, 0x00, 0x00, + /* 0x0 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(3, 0x9 - 0x4), + /* 0x4 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(10, 0, 0xF - 0x8), + /* 0x8 */ SCHEDULE_CMD_RET_NONE(), + /* 0x9 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 0, 20, 0, 0x8 - 0xF), + /* 0xF */ SCHEDULE_CMD_RET_VAL_S(21), }; -u8 D_80867704[] = { 0x05, 0x00, 0x00, 0x00 }; -u8 D_80867708[] = { 0x05, 0x00, 0x00, 0x00 }; -u8 D_8086770C[] = { 0x05, 0x00, 0x00, 0x00 }; -u8 D_80867710[] = { 0x05, 0x00, 0x00, 0x00 }; +u8 D_80867704[] = { + /* 0x0 */ SCHEDULE_CMD_RET_NONE(), +}; -u8 D_80867714[] = { 0x0F, 0x14, 0x00, 0x02, 0x09, 0x17, 0x05, 0x00 }; +u8 D_80867708[] = { + /* 0x0 */ SCHEDULE_CMD_RET_NONE(), +}; + +u8 D_8086770C[] = { + /* 0x0 */ SCHEDULE_CMD_RET_NONE(), +}; + +u8 D_80867710[] = { + /* 0x0 */ SCHEDULE_CMD_RET_NONE(), +}; + +u8 D_80867714[] = { + /* 0x0 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(20, 0, 0x6 - 0x4), + /* 0x4 */ SCHEDULE_CMD_RET_VAL_S(23), + /* 0x6 */ SCHEDULE_CMD_RET_NONE(), +}; u8 D_8086771C[] = { - 0x0C, 0x00, 0x01, 0x07, 0x0F, 0x02, 0x1E, 0x02, 0x09, 0x18, 0x05, 0x0C, - 0x00, 0x03, 0xFB, 0x0F, 0x14, 0x00, 0xF7, 0x09, 0x0C, 0x00, 0x00, 0x00, + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(1, 0x0B - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(2, 30, 0x0A - 0x08), + /* 0x08 */ SCHEDULE_CMD_RET_VAL_S(24), + /* 0x0A */ SCHEDULE_CMD_RET_NONE(), + /* 0x0B */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(3, 0x0A - 0x0F), + /* 0x0F */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(20, 0, 0x0A - 0x13), + /* 0x13 */ SCHEDULE_CMD_RET_VAL_S(12), }; -u8 D_80867734[] = { 0x0F, 0x14, 0x00, 0x02, 0x09, 0x19, 0x05, 0x00 }; +u8 D_80867734[] = { + /* 0x0 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(20, 0, 0x6 - 0x4), + /* 0x4 */ SCHEDULE_CMD_RET_VAL_S(25), + /* 0x6 */ SCHEDULE_CMD_RET_NONE(), +}; -u8 D_8086773C[] = { 0x0F, 0x14, 0x00, 0x02, 0x09, 0x1A, 0x05, 0x00 }; +u8 D_8086773C[] = { + /* 0x0 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(20, 0, 0x6 - 0x4), + /* 0x4 */ SCHEDULE_CMD_RET_VAL_S(26), + /* 0x6 */ SCHEDULE_CMD_RET_NONE(), +}; u8 D_80867744[] = { - 0x0C, 0x00, 0x02, 0x04, 0x00, 0x63, 0x80, 0x06, 0x0F, 0x14, 0x00, 0x08, - 0x09, 0x1B, 0x0F, 0x12, 0x00, 0x02, 0x09, 0x1B, 0x05, 0x00, 0x00, 0x00, + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(2, 0x08 - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_FLAG_S(0x63, 0x80, 0x0E - 0x08), + /* 0x08 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(20, 0, 0x14 - 0x0C), + /* 0x0C */ SCHEDULE_CMD_RET_VAL_S(27), + /* 0x0E */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(18, 0, 0x14 - 0x12), + /* 0x12 */ SCHEDULE_CMD_RET_VAL_S(27), + /* 0x14 */ SCHEDULE_CMD_RET_NONE(), }; u8 D_8086775C[] = { - 0x00, 0x34, 0x20, 0x17, 0x00, 0x4B, 0x20, 0x13, 0x00, 0x0E, 0x04, 0x02, 0x09, 0x1D, - 0x00, 0x3B, 0x01, 0x08, 0x00, 0x3D, 0x02, 0x02, 0x09, 0x1E, 0x09, 0x1F, 0x05, 0x05, + /* 0x00 */ SCHEDULE_CMD_CHECK_FLAG_S(0x34, 0x20, 0x1B - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_FLAG_S(0x4B, 0x20, 0x1B - 0x08), + /* 0x08 */ SCHEDULE_CMD_CHECK_FLAG_S(0x0E, 0x04, 0x0E - 0x0C), + /* 0x0C */ SCHEDULE_CMD_RET_VAL_S(29), + /* 0x0E */ SCHEDULE_CMD_CHECK_FLAG_S(0x3B, 0x01, 0x1A - 0x12), + /* 0x12 */ SCHEDULE_CMD_CHECK_FLAG_S(0x3D, 0x02, 0x18 - 0x16), + /* 0x16 */ SCHEDULE_CMD_RET_VAL_S(30), + /* 0x18 */ SCHEDULE_CMD_RET_VAL_S(31), + /* 0x1A */ SCHEDULE_CMD_RET_NONE(), + /* 0x1B */ SCHEDULE_CMD_RET_NONE(), }; -u8 D_80867778[] = { 0x09, 0x20, 0x00, 0x00 }; -u8 D_8086777C[] = { 0x05, 0x00, 0x00, 0x00 }; -u8 D_80867780[] = { 0x05, 0x00, 0x00, 0x00 }; -u8 D_80867784[] = { 0x0F, 0x16, 0x00, 0x02, 0x09, 0x23, 0x05, 0x00 }; +u8 D_80867778[] = { + /* 0x0 */ SCHEDULE_CMD_RET_VAL_S(32), +}; -// void* seems to keep the compiler happy. -void* D_8086778C[] = { - &D_808675D0, &D_808675E4, &D_80867634, &D_80867640, &D_8086764C, &D_80867658, &D_80867684, &D_80867688, - &D_80867690, &D_80867698, &D_808676A0, &D_808676B8, &D_808676D0, &D_808676D4, &D_808676D8, &D_808676E4, - &D_808676EC, &D_808676F0, &D_80867704, &D_80867708, &D_8086770C, &D_80867710, &D_80867714, &D_8086771C, - &D_80867734, &D_8086773C, &D_80867744, &D_8086775C, &D_80867778, &D_8086777C, &D_80867780, &D_80867784, +u8 D_8086777C[] = { + /* 0x0 */ SCHEDULE_CMD_RET_NONE(), +}; + +u8 D_80867780[] = { + /* 0x0 */ SCHEDULE_CMD_RET_NONE(), +}; + +u8 D_80867784[] = { + /* 0x0 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(22, 0, 0x6 - 0x4), + /* 0x4 */ SCHEDULE_CMD_RET_VAL_S(35), + /* 0x6 */ SCHEDULE_CMD_RET_NONE(), +}; + +u8* D_8086778C[] = { + D_808675D0, D_808675E4, D_80867634, D_80867640, D_8086764C, D_80867658, D_80867684, D_80867688, + D_80867690, D_80867698, D_808676A0, D_808676B8, D_808676D0, D_808676D4, D_808676D8, D_808676E4, + D_808676EC, D_808676F0, D_80867704, D_80867708, D_8086770C, D_80867710, D_80867714, D_8086771C, + D_80867734, D_8086773C, D_80867744, D_8086775C, D_80867778, D_8086777C, D_80867780, D_80867784, }; const ActorInit En_Door_InitVars = { @@ -336,7 +475,6 @@ void func_80866B20(EnDoor* this, GlobalContext* globalCtx) { s32 temp_a1_2; s32 temp_t0; u8 temp_a1; - s32 pad; if (Actor_ProcessTalkRequest(&this->dyna.actor, &globalCtx->state) && (this->dyna.actor.textId == 0x1821)) { D_80867BC0[0] = 1; @@ -346,7 +484,7 @@ void func_80866B20(EnDoor* this, GlobalContext* globalCtx) { Animation_PlayOnceSetSpeed(&this->skelAnime, sAnimations[this->animIndex], (player->stateFlags1 & 0x8000000) ? 0.75f : 1.5f); if (this->unk_1A6 != 0) { - gSaveContext.inventory.dungeonKeys[gSaveContext.mapIndex]--; + gSaveContext.save.inventory.dungeonKeys[gSaveContext.mapIndex]--; Flags_SetSwitch(globalCtx, this->switchFlag); Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_CHAIN_KEY_UNLOCK); } @@ -366,7 +504,7 @@ void func_80866B20(EnDoor* this, GlobalContext* globalCtx) { player->doorDirection = playerPosRelToDoor.z >= 0.0f ? 1.0f : -1.0f; player->doorActor = &this->dyna.actor; if (this->unk_1A6 != 0) { - if (gSaveContext.inventory.dungeonKeys[((void)0, gSaveContext.mapIndex)] <= 0) { + if (gSaveContext.save.inventory.dungeonKeys[((void)0, gSaveContext.mapIndex)] <= 0) { player->doorType = -1; this->dyna.actor.textId = 0x1802; } else { @@ -396,10 +534,10 @@ void func_80866B20(EnDoor* this, GlobalContext* globalCtx) { this->dyna.actor.textId = baseTextId + textIdOffset; } } else if ((this->unk_1A4 == 5) && (playerPosRelToDoor.z > 0.0f)) { - struct_80133038_arg2 sp30; + ScheduleResult sp30; - if (func_80133038(globalCtx, D_8086778C[this->switchFlag], &sp30) != 0) { - this->dyna.actor.textId = sp30.unk0 + 0x1800; + if (Schedule_RunScript(globalCtx, D_8086778C[this->switchFlag], &sp30) != 0) { + this->dyna.actor.textId = sp30.result + 0x1800; player->doorType = ((this->dyna.actor.textId == 0x1821) && (D_80867BC0[0] != 0)) ? 5 : -1; } @@ -514,7 +652,7 @@ s32 EnDoor_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList *dList = dl[dlIndex]; } } - return 0; + return false; } void EnDoor_Draw(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_En_Dragon/z_en_dragon.c b/src/overlays/actors/ovl_En_Dragon/z_en_dragon.c index 604be5441f..efd901eb38 100644 --- a/src/overlays/actors/ovl_En_Dragon/z_en_dragon.c +++ b/src/overlays/actors/ovl_En_Dragon/z_en_dragon.c @@ -15,16 +15,41 @@ void EnDragon_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnDragon_Update(Actor* thisx, GlobalContext* globalCtx); void EnDragon_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80B5ED90(EnDragon* this, GlobalContext* globalCtx); -void func_80B5EE3C(EnDragon* this, GlobalContext* globalCtx); -void func_80B5EFD0(EnDragon* this, GlobalContext* globalCtx); -void func_80B5F418(EnDragon* this, GlobalContext* globalCtx); -void func_80B5F508(EnDragon* this, GlobalContext* globalCtx); -void func_80B5F8D8(EnDragon* this, GlobalContext* globalCtx); -void func_80B5FCC0(EnDragon* this, GlobalContext* globalCtx); -void func_80B5FD68(EnDragon* this, GlobalContext* globalCtx); +void EnDragon_SetupRetreatOrIdle(EnDragon* this); +void EnDragon_RetreatOrIdle(EnDragon* this, GlobalContext* globalCtx); +void EnDragon_SetupExtend(EnDragon* this); +void EnDragon_Extend(EnDragon* this, GlobalContext* globalCtx); +void EnDragon_Grab(EnDragon* this, GlobalContext* globalCtx); +void EnDragon_SetupAttack(EnDragon* this); +void EnDragon_Attack(EnDragon* this, GlobalContext* globalCtx); +void EnDragon_Dead(EnDragon* this, GlobalContext* globalCtx); + +typedef enum { + /* 0 */ DEEP_PYTHON_ANIMATION_SMALL_SIDE_SWAY, + /* 1 */ DEEP_PYTHON_ANIMATION_LARGE_SIDE_SWAY, + /* 2 */ DEEP_PYTHON_ANIMATION_VERTICAL_SWAY, + /* 3 */ DEEP_PYTHON_ANIMATION_IDLE +} DeepPythonAnimationIndex; + +typedef enum { + /* 0 */ DEEP_PYTHON_EXTEND_STATE_NOT_FULLY_EXTENDED, + /* 1 */ DEEP_PYTHON_EXTEND_STATE_FULLY_EXTENDED, + /* 2 */ DEEP_PYTHON_EXTEND_STATE_REPEAT_LARGE_SWAY, + /* 3 */ DEEP_PYTHON_EXTEND_STATE_REPEAT_SMALL_SWAY, +} DeepPythonExtendState; + +typedef enum { + /* 0 */ DEEP_PYTHON_GRAB_STATE_START, + /* 1 */ DEEP_PYTHON_GRAB_STATE_GRABBED, +} DeepPythonGrabState; + +typedef enum { + /* 0 */ DEEP_PYTHON_ATTACK_STATE_START, + /* 1 */ DEEP_PYTHON_ATTACK_STATE_RELEASED, +} DeepPythonAttackState; + +static s32 sNumPythonsDead = 0; -#if 0 const ActorInit En_Dragon_InitVars = { ACTOR_EN_DRAGON, ACTORCAT_ENEMY, @@ -37,130 +62,779 @@ const ActorInit En_Dragon_InitVars = { (ActorFunc)EnDragon_Draw, }; -// static DamageTable sDamageTable = { -static DamageTable D_80B605F4 = { - /* Deku Nut */ DMG_ENTRY(0, 0x0), - /* Deku Stick */ DMG_ENTRY(0, 0x0), - /* Horse trample */ DMG_ENTRY(0, 0x0), - /* Explosives */ DMG_ENTRY(1, 0xF), - /* Zora boomerang */ DMG_ENTRY(1, 0xF), - /* Normal arrow */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x06 */ DMG_ENTRY(0, 0x0), - /* Hookshot */ DMG_ENTRY(0, 0x0), - /* Goron punch */ DMG_ENTRY(0, 0x0), - /* Sword */ DMG_ENTRY(0, 0x0), - /* Goron pound */ DMG_ENTRY(0, 0x0), - /* Fire arrow */ DMG_ENTRY(0, 0x0), - /* Ice arrow */ DMG_ENTRY(0, 0x0), - /* Light arrow */ DMG_ENTRY(0, 0x0), - /* Goron spikes */ DMG_ENTRY(0, 0x0), - /* Deku spin */ DMG_ENTRY(0, 0x0), - /* Deku bubble */ DMG_ENTRY(0, 0x0), - /* Deku launch */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0x0), - /* Zora barrier */ DMG_ENTRY(1, 0xF), - /* Normal shield */ DMG_ENTRY(0, 0x0), - /* Light ray */ DMG_ENTRY(0, 0x0), - /* Thrown object */ DMG_ENTRY(0, 0x0), - /* Zora punch */ DMG_ENTRY(1, 0xF), - /* Spin attack */ DMG_ENTRY(0, 0x0), - /* Sword beam */ DMG_ENTRY(0, 0x0), - /* Normal Roll */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0x0), - /* Powder Keg */ DMG_ENTRY(1, 0xF), +typedef enum { + /* 0x0 */ DEEP_PYTHON_DMGEFF_NONE, + /* 0xF */ DEEP_PYTHON_DMGEFF_DAMAGE = 0xF +} DeepPythonDamageEffect; + +static DamageTable sDamageTable = { + /* Deku Nut */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Deku Stick */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Horse trample */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Explosives */ DMG_ENTRY(1, DEEP_PYTHON_DMGEFF_DAMAGE), + /* Zora boomerang */ DMG_ENTRY(1, DEEP_PYTHON_DMGEFF_DAMAGE), + /* Normal arrow */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* UNK_DMG_0x06 */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Hookshot */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Goron punch */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Sword */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Goron pound */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Fire arrow */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Ice arrow */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Light arrow */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Goron spikes */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Deku spin */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Deku bubble */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Deku launch */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Zora barrier */ DMG_ENTRY(1, DEEP_PYTHON_DMGEFF_DAMAGE), + /* Normal shield */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Light ray */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Thrown object */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Zora punch */ DMG_ENTRY(1, DEEP_PYTHON_DMGEFF_DAMAGE), + /* Spin attack */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Sword beam */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Normal Roll */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Unblockable */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Powder Keg */ DMG_ENTRY(1, DEEP_PYTHON_DMGEFF_DAMAGE), }; -// static ColliderJntSphElementInit sJntSphElementsInit[8] = { -static ColliderJntSphElementInit D_80B60614[8] = { +static ColliderJntSphElementInit sJntSphElementsInit[8] = { { - { ELEMTYPE_UNK1, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 13, { { 0, 0, 0 }, 0 }, 1 }, + { + ELEMTYPE_UNK1, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { DEEP_PYTHON_LIMB_HEAD, { { 0, 0, 0 }, 0 }, 1 }, }, { - { ELEMTYPE_UNK1, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 12, { { 0, 0, 0 }, 0 }, 1 }, + { + ELEMTYPE_UNK1, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { DEEP_PYTHON_LIMB_COLLAR, { { 0, 0, 0 }, 0 }, 1 }, }, { - { ELEMTYPE_UNK1, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 12, { { 0, 0, 0 }, 0 }, 1 }, + { + ELEMTYPE_UNK1, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { DEEP_PYTHON_LIMB_COLLAR, { { 0, 0, 0 }, 0 }, 1 }, }, { - { ELEMTYPE_UNK1, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 10, { { 0, 0, 0 }, 0 }, 1 }, + { + ELEMTYPE_UNK1, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { DEEP_PYTHON_LIMB_BODY_SEGMENT_1, { { 0, 0, 0 }, 0 }, 1 }, }, { - { ELEMTYPE_UNK1, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 10, { { 0, 0, 0 }, 0 }, 1 }, + { + ELEMTYPE_UNK1, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { DEEP_PYTHON_LIMB_BODY_SEGMENT_1, { { 0, 0, 0 }, 0 }, 1 }, }, { - { ELEMTYPE_UNK1, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 9, { { 0, 0, 0 }, 0 }, 1 }, + { + ELEMTYPE_UNK1, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { DEEP_PYTHON_LIMB_BODY_SEGMENT_2, { { 0, 0, 0 }, 0 }, 1 }, }, { - { ELEMTYPE_UNK1, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 9, { { 0, 0, 0 }, 0 }, 1 }, + { + ELEMTYPE_UNK1, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { DEEP_PYTHON_LIMB_BODY_SEGMENT_2, { { 0, 0, 0 }, 0 }, 1 }, }, { - { ELEMTYPE_UNK1, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 9, { { 0, 0, 0 }, 0 }, 1 }, + { + ELEMTYPE_UNK1, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { DEEP_PYTHON_LIMB_BODY_SEGMENT_2, { { 0, 0, 0 }, 0 }, 1 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_80B60734 = { - { COLTYPE_HIT6, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 8, D_80B60614, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_HIT6, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + ARRAY_COUNT(sJntSphElementsInit), + sJntSphElementsInit, }; -#endif +void EnDragon_Init(Actor* thisx, GlobalContext* globalCtx) { + EnDragon* this = THIS; -extern DamageTable D_80B605F4; -extern ColliderJntSphElementInit D_80B60614[8]; -extern ColliderJntSphInit D_80B60734; + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gDeepPythonSkel, &gDeepPythonSmallSideSwayAnim, this->jointTable, + this->morphTable, DEEP_PYTHON_LIMB_MAX); -extern UNK_TYPE D_060048B8; + this->actor.colChkInfo.health = 4; + this->actor.colChkInfo.damageTable = &sDamageTable; + this->actor.targetMode = 0xA; + Collider_InitAndSetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/EnDragon_Init.s") + this->collider.elements[0].dim.scale = this->collider.elements[1].dim.scale = this->collider.elements[2].dim.scale = + this->collider.elements[3].dim.scale = this->collider.elements[4].dim.scale = + this->collider.elements[5].dim.scale = this->collider.elements[6].dim.scale = + this->collider.elements[7].dim.scale = 1.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/EnDragon_Destroy.s") + this->collider.elements[0].dim.modelSphere.radius = 150; + this->collider.elements[0].dim.modelSphere.center.x = 420; + this->collider.elements[1].dim.modelSphere.radius = 160; + this->collider.elements[1].dim.modelSphere.center.x = 630; + this->collider.elements[2].dim.modelSphere.radius = 130; + this->collider.elements[2].dim.modelSphere.center.x = 630; + this->collider.elements[3].dim.modelSphere.radius = 170; + this->collider.elements[3].dim.modelSphere.center.x = 920; + this->collider.elements[4].dim.modelSphere.radius = 150; + this->collider.elements[4].dim.modelSphere.center.x = 530; + this->collider.elements[5].dim.modelSphere.radius = 140; + this->collider.elements[5].dim.modelSphere.center.x = 730; + this->collider.elements[6].dim.modelSphere.radius = 120; + this->collider.elements[6].dim.modelSphere.center.x = 430; + this->collider.elements[7].dim.modelSphere.radius = 110; + this->collider.elements[7].dim.modelSphere.center.x = 160; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B5EAA0.s") + this->pythonIndex = EN_DRAGON_GET_PYTHON_INDEX(&this->actor); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->action = DEEP_PYTHON_ACTION_IDLE; + this->actor.hintId = 0xE; + this->scale = 0.5f; + this->actor.flags &= ~ACTOR_FLAG_8000000; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B5EB40.s") + EnDragon_SetupRetreatOrIdle(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B5ED90.s") +void EnDragon_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnDragon* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B5EDF0.s") + Collider_DestroyJntSph(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B5EE3C.s") +static AnimationHeader* sAnimations[] = { + &gDeepPythonSmallSideSwayAnim, + &gDeepPythonLargeSideSwayAnim, + &gDeepPythonVerticalSwayAnim, + &gDeepPythonSmallSideSwayAnim, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B5EF88.s") +static u8 sAnimationModes[] = { ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_ONCE }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B5EFD0.s") +void EnDragon_ChangeAnimation(EnDragon* this, s32 animationIndex) { + f32 startFrame; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B5F3A4.s") + this->animationIndex = animationIndex; + this->endFrame = Animation_GetLastFrame(sAnimations[animationIndex]); + startFrame = 0.0f; + if (this->animationIndex == DEEP_PYTHON_ANIMATION_IDLE) { + startFrame = this->endFrame; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B5F418.s") + Animation_Change(&this->skelAnime, sAnimations[animationIndex], 1.0f, startFrame, this->endFrame, + sAnimationModes[this->animationIndex], -4.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B5F508.s") +static Color_RGBA8 sBubblePrimColors[] = { + { 255, 255, 255, 255 }, + { 150, 255, 255, 255 }, + { 100, 255, 255, 255 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B5F888.s") +static Color_RGBA8 sBubbleEnvColors[] = { + { 150, 150, 150, 0 }, + { 0, 100, 0, 255 }, + { 0, 0, 255, 255 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B5F8D8.s") +void EnDragon_SpawnBubbles(EnDragon* this, GlobalContext* globalCtx, Vec3f basePos) { + static Vec3f sBubbleVelocity = { 0.0f, 0.0f, 0.0f }; + static Vec3f sBubbleAccel = { 0.0f, 0.1f, 0.0f }; + s32 bubbleCount; + s16 colorIndex; + s16 scale; + Vec3f bubblePos; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B5FCC0.s") + bubbleCount = (s32)randPlusMinusPoint5Scaled(5.0f) + 10; + colorIndex = 0; + if (this->action == DEEP_PYTHON_ACTION_DEAD) { + colorIndex = 1; + bubbleCount = (s32)randPlusMinusPoint5Scaled(5.0f) + 10; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B5FD68.s") + for (i = 0; i < bubbleCount; i++) { + Math_Vec3f_Copy(&bubblePos, &basePos); + sBubbleVelocity.x = Rand_ZeroFloat(1.0f) * 23.0f; + sBubbleVelocity.y = Rand_ZeroFloat(1.0f) * 10.0f; + sBubbleVelocity.z = Rand_ZeroFloat(1.0f) * 23.0f; + bubblePos.x += randPlusMinusPoint5Scaled(i * 30.0f); + bubblePos.y += randPlusMinusPoint5Scaled(5.0f); + bubblePos.z += randPlusMinusPoint5Scaled(i * 30.0f); + sBubbleAccel.y = Rand_ZeroFloat(1.0f) * 20.0f * 3.0f; + scale = Rand_S16Offset(380, 240); + EffectSsDtBubble_SpawnCustomColor(globalCtx, &bubblePos, &sBubbleVelocity, &sBubbleAccel, + &sBubblePrimColors[colorIndex], &sBubbleEnvColors[colorIndex], scale, 30, 0); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B60138.s") +void EnDragon_RetreatOnceTimerEnds(EnDragon* this, GlobalContext* globalCtx) { + if (this->timer == 0) { + func_800B8D50(globalCtx, &this->actor, 10.0f, this->actor.world.rot.y, 10.0f, 8); + EnDragon_SetupRetreatOrIdle(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/EnDragon_Update.s") +void EnDragon_SetupRetreatOrIdle(EnDragon* this) { + EnDragon_ChangeAnimation(this, DEEP_PYTHON_ANIMATION_IDLE); + this->state = 0; + this->unk_2CC = 0; + this->hasGrabbedPlayer = false; + this->grabTimer = 0; + this->timer = 30; + this->actionFunc = EnDragon_RetreatOrIdle; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B6043C.s") +void EnDragon_RetreatOrIdle(EnDragon* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + if (this->action == DEEP_PYTHON_ACTION_EXTEND) { + EnDragon_SetupExtend(this); + } else if ((this->timer != 0) && (fabsf(this->actor.world.pos.x - this->actor.home.pos.x) > 101.0f) && + (fabsf(this->actor.world.pos.z - this->actor.home.pos.z) > 101.0f)) { + this->actor.speedXZ = -100.0f; + } else { + this->actor.speedXZ = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B60494.s") + if ((fabsf(this->actor.world.pos.x - this->actor.home.pos.x) > 4.0f) && + (fabsf(this->actor.world.pos.z - this->actor.home.pos.z) > 4.0f)) { + Math_ApproachF(&this->actor.world.pos.x, this->actor.home.pos.x, 0.3f, 200.0f); + Math_ApproachF(&this->actor.world.pos.z, this->actor.home.pos.z, 0.3f, 200.0f); + } else if (this->action != DEEP_PYTHON_ACTION_IDLE) { + this->action = DEEP_PYTHON_ACTION_IDLE; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/EnDragon_Draw.s") +void EnDragon_SetupExtend(EnDragon* this) { + this->state = 0; + this->behindJawRetreatTimer = this->state; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_UTSUBO_APPEAR_TRG); + this->retreatTimer = 250; + this->actionFunc = EnDragon_Extend; +} + +void EnDragon_Extend(EnDragon* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 currentFrame = this->skelAnime.curFrame; + s16 yaw; + + EnDragon_SpawnBubbles(this, globalCtx, this->jawPos); + + if (this->action >= DEEP_PYTHON_ACTION_DAMAGE) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_UTSUBO_BACK); + EnDragon_SetupRetreatOrIdle(this); + } else if (this->retreatTimer == 0) { + this->action = DEEP_PYTHON_ACTION_RETREAT; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_UTSUBO_BACK); + EnDragon_SetupRetreatOrIdle(this); + } else if (this->state == DEEP_PYTHON_EXTEND_STATE_NOT_FULLY_EXTENDED) { + Vec3f extendedPos; + + Math_Vec3f_Copy(&extendedPos, &this->burrowEntrancePos); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_UTSUBO_APPEAR - SFX_FLAG); + extendedPos.x += Math_SinS(this->actor.world.rot.y) * -530.0f; + extendedPos.z += Math_CosS(this->actor.world.rot.y) * -530.0f; + this->actor.speedXZ = 40.0f; + Math_SmoothStepToS(&this->jawZRotation, 0xFA0, 5, 0xBB8, 0x14); + + if ((fabsf(this->actor.world.pos.x - extendedPos.x) < 51.0f) && + (fabsf(this->actor.world.pos.z - extendedPos.z) < 51.0f)) { + this->actor.speedXZ = 0.0f; + Math_ApproachF(&this->actor.world.pos.x, extendedPos.x, 0.3f, 50.0f); + Math_ApproachF(&this->actor.world.pos.z, extendedPos.z, 0.3f, 50.0f); + if ((fabsf(this->actor.world.pos.x - extendedPos.x) < 4.0f) && + (fabsf(this->actor.world.pos.z - extendedPos.z) < 4.0f)) { + if (this->animationIndex != DEEP_PYTHON_ANIMATION_LARGE_SIDE_SWAY) { + EnDragon_ChangeAnimation(this, DEEP_PYTHON_ANIMATION_LARGE_SIDE_SWAY); + } + + this->state = DEEP_PYTHON_EXTEND_STATE_FULLY_EXTENDED; + } + } + } else { + Math_SmoothStepToS(&this->jawZRotation, 0, 5, 0xBB8, 0x14); + SkelAnime_Update(&this->skelAnime); + if (this->state == DEEP_PYTHON_EXTEND_STATE_FULLY_EXTENDED) { + if (currentFrame < this->endFrame) { + return; + } + + this->state = DEEP_PYTHON_EXTEND_STATE_REPEAT_LARGE_SWAY; + } + + yaw = ABS_ALT(BINANG_SUB(Math_Vec3f_Yaw(&this->jawPos, &player->actor.world.pos), this->actor.shape.rot.y)); + if (yaw < 0x5000) { + // Player is in front of the jaw + if ((this->endFrame <= currentFrame) && (this->largeSwayWaitTimer == 0)) { + if (this->animationIndex != DEEP_PYTHON_ANIMATION_LARGE_SIDE_SWAY) { + EnDragon_ChangeAnimation(this, DEEP_PYTHON_ANIMATION_LARGE_SIDE_SWAY); + } + + this->state = DEEP_PYTHON_EXTEND_STATE_REPEAT_LARGE_SWAY; + } + + this->behindJawRetreatTimer = 0; + } else { + // Player is in behind the jaw + if (this->state == DEEP_PYTHON_EXTEND_STATE_REPEAT_LARGE_SWAY) { + EnDragon_ChangeAnimation(this, DEEP_PYTHON_ANIMATION_SMALL_SIDE_SWAY); + this->largeSwayWaitTimer = Rand_ZeroFloat(20.0f) + this->endFrame; + this->state = DEEP_PYTHON_EXTEND_STATE_REPEAT_SMALL_SWAY; + } + + this->behindJawRetreatTimer++; + if (this->behindJawRetreatTimer > 60) { + this->action = DEEP_PYTHON_ACTION_RETREAT; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_UTSUBO_BACK); + EnDragon_SetupRetreatOrIdle(this); + } + } + } +} + +void EnDragon_CameraSetAtEye(EnDragon* this, GlobalContext* globalCtx, Vec3f eye, Vec3f at) { + this->cameraId = ActorCutscene_GetCurrentCamera(this->actor.cutscene); + Math_Vec3f_Copy(&this->cameraEye, &eye); + Math_Vec3f_Copy(&this->cameraAt, &at); + Play_CameraSetAtEye(globalCtx, this->cameraId, &this->cameraAt, &this->cameraEye); +} + +void EnDragon_SetupGrab(EnDragon* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f extendedPos; + s16 yaw; + + if (!ActorCutscene_GetCanPlayNext(this->grabCutsceneIndex)) { + ActorCutscene_SetIntentToPlay(this->grabCutsceneIndex); + } else { + ActorCutscene_StartAndSetUnkLinkFields(this->grabCutsceneIndex, &this->actor); + Math_Vec3f_Copy(&extendedPos, &this->burrowEntrancePos); + extendedPos.x += Math_SinS(this->actor.world.rot.y) * -530.0f; + extendedPos.z += Math_CosS(this->actor.world.rot.y) * -530.0f; + Math_Vec3f_Copy(&this->actor.world.pos, &extendedPos); + yaw = Math_Vec3f_Yaw(&player->actor.world.pos, &this->jawPos); + player->actor.shape.rot.y = yaw; + player->actor.world.rot.y = yaw; + this->state = DEEP_PYTHON_GRAB_STATE_START; + this->grabTimer = 0; + this->hasGrabbedPlayer = false; + EnDragon_ChangeAnimation(this, DEEP_PYTHON_ANIMATION_IDLE); + this->actionFunc = EnDragon_Grab; + } +} + +static Vec3f sCameraEyePerPython[] = { + { 1600.0f, 0.0f, 1400.0f }, { 1400.0f, 0.0f, 400.0f }, { 1800.0f, 0.0f, 1400.f }, { 1100.0f, -200.0f, 1500.0f }, + { 2000.0f, 0.0f, 1500.0f }, { 1900.0f, 0.0f, 1800.0f }, { 1700.0f, 0.0f, 1100.0f }, { 1700.0f, 0.0f, 1100.0f }, +}; + +static Vec3f sCameraAtPerPython[] = { + { 300.0f, -100.0f, 1300.0f }, { 1500.0f, 0.0f, 2400.0f }, { 300.0f, -100.0f, 1300.0f }, { 1900.0f, 500.0f, 600.0f }, + { -1000.0f, 0.0f, 1000.0f }, { 1200.0f, 0.0f, 1500.0f }, { 1100.0f, 0.0f, 2000.0f }, { 1100.0f, 0.0f, 2000.0f }, +}; + +static s16 sZRotPerPython[] = { 0x07D0, 0x07D0, 0x07D0, 0x07D0, 0x07D0, 0x0BB8, 0x0000, 0x0000 }; + +static s32 sMaxGrabTimerPerPython[] = { 5, 5, 5, 4, 5, 8, 5, 5 }; + +void EnDragon_Grab(EnDragon* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f sp50; // used as both the extended position and the camera eye + Vec3f at; + + this->cameraId = ActorCutscene_GetCurrentCamera(this->actor.cutscene); + SkelAnime_Update(&this->skelAnime); + + if (this->grabTimer == 0) { + if (!this->hasGrabbedPlayer) { + Math_Vec3f_Copy(&player->actor.world.pos, &this->playerGrabPosition); + Math_Vec3f_Copy(&this->playerGrabPositionTemp, &this->playerGrabPosition); + this->hasGrabbedPlayer = true; + } else { + Math_Vec3f_Copy(&player->actor.world.pos, &this->playerGrabPositionTemp); + } + + Math_Vec3f_Copy(&sp50, &this->burrowEntrancePos); + sp50.x += Math_SinS(this->actor.world.rot.y) * -930.0f; + sp50.z += Math_CosS(this->actor.world.rot.y) * -930.0f; + Math_Vec3f_Copy(&this->actor.world.pos, &sp50); + this->jawZRotation = 0x1450; + this->actor.speedXZ = 60.0f; + } + + this->grabTimer++; + Math_SmoothStepToS(&this->actor.shape.rot.z, sZRotPerPython[this->pythonIndex], 0xA, 0x1F4, 0x14); + EnDragon_SpawnBubbles(this, globalCtx, this->jawPos); + + Math_Vec3f_Copy(&sp50, &this->burrowEntrancePos); + sp50.x += Math_SinS(this->actor.world.rot.y) * sCameraEyePerPython[this->pythonIndex].x; + sp50.y += sCameraEyePerPython[this->pythonIndex].y; + sp50.z += Math_CosS(this->actor.world.rot.y) * sCameraEyePerPython[this->pythonIndex].z; + + Math_Vec3f_Copy(&at, &this->actor.world.pos); + at.x += Math_SinS(this->actor.world.rot.y) * sCameraAtPerPython[this->pythonIndex].x; + at.y += sCameraAtPerPython[this->pythonIndex].y; + at.z += Math_CosS(this->actor.world.rot.y) * sCameraAtPerPython[this->pythonIndex].z; + + EnDragon_CameraSetAtEye(this, globalCtx, sp50, at); + + if (this->grabTimer > sMaxGrabTimerPerPython[this->pythonIndex]) { + if (this->state == DEEP_PYTHON_GRAB_STATE_START) { + func_800B7298(globalCtx, &this->actor, 6); + this->state = DEEP_PYTHON_GRAB_STATE_GRABBED; + } + + globalCtx->unk_18770(globalCtx, player); + player->actor.parent = &this->actor; + player->unk_AE8 = 50; + this->action = DEEP_PYTHON_ACTION_GRAB; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_UTSUBO_EAT); + EnDragon_SetupAttack(this); + } +} + +void EnDragon_SetupAttack(EnDragon* this) { + if (this->animationIndex != DEEP_PYTHON_ANIMATION_LARGE_SIDE_SWAY) { + EnDragon_ChangeAnimation(this, DEEP_PYTHON_ANIMATION_LARGE_SIDE_SWAY); + } + + this->behindJawRetreatTimer = 0; + this->grabTimer = 0; + this->state = DEEP_PYTHON_ATTACK_STATE_START; + this->actionFunc = EnDragon_Attack; +} + +void EnDragon_Attack(EnDragon* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 currentFrame = this->skelAnime.curFrame; + Vec3f sp4C; // used as both the extended position and the camera eye + Vec3f at; + + SkelAnime_Update(&this->skelAnime); + Math_SmoothStepToS(&this->actor.shape.rot.z, 0, 0xA, 0x1388, 0); + if ((globalCtx->gameplayFrames % 16) == 0) { + globalCtx->damagePlayer(globalCtx, -2); + + //! @bug: This function should only pass Player*: it uses *(this + 0x153), which is meant to be + //! player->currentMask, but in this case is garbage in the skelAnime + func_800B8E58((Player*)this, player->ageProperties->unk_92 + NA_SE_VO_LI_DAMAGE_S); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_UTSUBO_BITE); + CollisionCheck_GreenBlood(globalCtx, NULL, &player->actor.world.pos); + } + + Math_Vec3f_Copy(&sp4C, &this->actor.world.pos); + sp4C.x += Math_SinS(this->actor.world.rot.y) * 3000.0f; + sp4C.y += 600.0f; + sp4C.z += Math_CosS(this->actor.world.rot.y) * 3000.0f; + + Math_Vec3f_Copy(&at, &this->actor.world.pos); + at.x += Math_SinS(this->actor.world.rot.y) * 1200.0f; + at.y += -100.0f; + at.z += Math_CosS(this->actor.world.rot.y) * 1200.0f; + + EnDragon_CameraSetAtEye(this, globalCtx, sp4C, at); + + player->actor.world.rot.y = player->actor.shape.rot.y = this->actor.world.rot.y; + player->actor.world.rot.x = player->actor.shape.rot.x = this->actor.world.rot.x; + player->actor.world.rot.z = player->actor.shape.rot.z = this->actor.world.rot.z - 0x36B0; + Math_Vec3f_Copy(&player->actor.world.pos, &this->playerGrabPosition); + this->jawZRotation = 0xC8; + + Math_Vec3f_Copy(&sp4C, &this->burrowEntrancePos); + sp4C.x += Math_SinS(this->actor.world.rot.y) * -530.0f; + sp4C.z += Math_CosS(this->actor.world.rot.y) * -530.0f; + Math_ApproachF(&this->actor.world.pos.x, sp4C.x, 0.3f, 200.0f); + Math_ApproachF(&this->actor.world.pos.y, sp4C.y, 0.3f, 200.0f); + Math_ApproachF(&this->actor.world.pos.z, sp4C.z, 0.3f, 200.0f); + + if ((this->state <= DEEP_PYTHON_ATTACK_STATE_START) && (this->endFrame <= currentFrame)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_UTSUBO_BITE); + if (this->animationIndex != DEEP_PYTHON_ANIMATION_LARGE_SIDE_SWAY) { + EnDragon_ChangeAnimation(this, DEEP_PYTHON_ANIMATION_LARGE_SIDE_SWAY); + } + + this->state++; + } + + if (((this->state != DEEP_PYTHON_ATTACK_STATE_START) && (this->endFrame <= currentFrame)) || + (!(player->stateFlags2 & 0x80)) || ((this->collider.elements[0].info.bumperFlags & BUMP_HIT)) || + (this->collider.elements[1].info.bumperFlags & BUMP_HIT) || + (this->collider.elements[2].info.bumperFlags & BUMP_HIT)) { + player->actor.parent = NULL; + this->grabWaitTimer = 30; + ActorCutscene_Stop(this->grabCutsceneIndex); + if (player->stateFlags2 & 0x80) { + player->unk_AE8 = 100; + } + + this->actor.flags &= ~ACTOR_FLAG_100000; + + if ((this->state != DEEP_PYTHON_ATTACK_STATE_START) && (this->endFrame <= currentFrame)) { + this->timer = 3; + this->actionFunc = EnDragon_RetreatOnceTimerEnds; + } else { + EnDragon_SetupRetreatOrIdle(this); + } + } +} + +void EnDragon_SetupDead(EnDragon* this, GlobalContext* globalCtx) { + if (!ActorCutscene_GetCanPlayNext(this->deathCutsceneIndex)) { + ActorCutscene_SetIntentToPlay(this->deathCutsceneIndex); + } else { + ActorCutscene_StartAndSetUnkLinkFields(this->deathCutsceneIndex, &this->actor); + this->endFrame = Animation_GetLastFrame(&gDeepPythonSmallSideSwayAnim); + Animation_Change(&this->skelAnime, &gDeepPythonSmallSideSwayAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f); + this->timer = 20; + this->actionFunc = EnDragon_Dead; + } +} + +void EnDragon_Dead(EnDragon* this, GlobalContext* globalCtx) { + Vec3f seahorsePos; + + SkelAnime_Update(&this->skelAnime); + this->actor.shape.rot.z += 0x1000; + this->jawZRotation = 0xFA0; + EnDragon_SpawnBubbles(this, globalCtx, this->jawPos); + + if ((this->timer != 0) && (fabsf(this->actor.world.pos.x - this->actor.home.pos.x) > 121.0f) && + (fabsf(this->actor.world.pos.z - this->actor.home.pos.z) > 121.0f)) { + this->actor.speedXZ = -120.0f; + if (((this->pythonIndex & 1) == 0) && (Rand_ZeroOne() < 0.5f)) { + //! @bug: !globalCtx->gameplayFrames is 0 essentially all the time, so this code never runs. + if (((!globalCtx->gameplayFrames) & 0x1F)) { + Item_DropCollectibleRandom(globalCtx, NULL, &this->jawPos, 0x90); + } + } + + this->action = DEEP_PYTHON_ACTION_DEAD; + return; + } + + this->actor.speedXZ = 0.0f; + if ((fabsf(this->actor.world.pos.x - this->actor.home.pos.x) > 20.0f) && + (fabsf(this->actor.world.pos.z - this->actor.home.pos.z) > 20.0f)) { + Math_ApproachF(&this->actor.world.pos.x, this->actor.home.pos.x, 0.3f, 300.0f); + Math_ApproachF(&this->actor.world.pos.z, this->actor.home.pos.z, 0.3f, 300.0f); + return; + } + + sNumPythonsDead++; + if (sNumPythonsDead >= (BREG(39) + 8)) { + Math_Vec3f_Copy(&seahorsePos, &this->actor.parent->world.pos); + seahorsePos.x += (Math_SinS((this->actor.parent->world.rot.y + 0x8000)) * (500.0f + BREG(38))); + seahorsePos.y += -100.0f + BREG(33); + seahorsePos.z += (Math_CosS((this->actor.parent->world.rot.y + 0x8000)) * (500.0f + BREG(38))); + if (Actor_SpawnAsChildAndCutscene(&globalCtx->actorCtx, globalCtx, ACTOR_EN_OT, seahorsePos.x, seahorsePos.y, + seahorsePos.z, 0, this->actor.shape.rot.y, 0, 0x4000, this->actor.cutscene, + this->actor.unk20, NULL)) { + gSaveContext.save.weekEventReg[13] |= 1; + switch (this->pythonIndex) { + case 0: + gSaveContext.save.weekEventReg[83] |= 0x10; + break; + + case 1: + gSaveContext.save.weekEventReg[83] |= 0x20; + break; + + case 2: + gSaveContext.save.weekEventReg[83] |= 0x40; + break; + + case 3: + gSaveContext.save.weekEventReg[83] |= 0x80; + break; + case 4: + gSaveContext.save.weekEventReg[84] |= 1; + break; + + case 5: + gSaveContext.save.weekEventReg[84] |= 2; + break; + + case 6: + gSaveContext.save.weekEventReg[84] |= 4; + break; + + case 7: + gSaveContext.save.weekEventReg[84] |= 8; + break; + } + } + } + + Actor_MarkForDeath(&this->actor); +} + +void EnDragon_UpdateDamage(EnDragon* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + u32 sp30; + + if ((this->action == DEEP_PYTHON_ACTION_EXTEND)) { + if ((this->collider.elements[2].info.bumperFlags & BUMP_HIT) || + (this->collider.elements[3].info.bumperFlags & BUMP_HIT) || + (this->collider.elements[4].info.bumperFlags & BUMP_HIT) || + (this->collider.elements[5].info.bumperFlags & BUMP_HIT) || + (this->collider.elements[6].info.bumperFlags & BUMP_HIT) || + (this->collider.elements[7].info.bumperFlags & BUMP_HIT)) { + Actor_ApplyDamage(&this->actor); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 25); + if (this->actor.colChkInfo.health > 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_UTSUBO_DAMAGE); + this->action = DEEP_PYTHON_ACTION_DAMAGE; + } else { + Enemy_StartFinishingBlow(globalCtx, &this->actor); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_UTSUBO_DEAD); + this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags &= ~ACTOR_FLAG_1; + this->actor.flags |= ACTOR_FLAG_100000; + this->action = DEEP_PYTHON_ACTION_SETUP_DEAD; + this->actionFunc = EnDragon_SetupDead; + } + } + } + + if ((this->action == DEEP_PYTHON_ACTION_EXTEND) && (this->grabWaitTimer == 0) && + (player->invincibilityTimer == 0) && (this->collider.elements[0].info.ocElemFlags & OCELEM_HIT) && + (!(func_800B64FC(globalCtx, 1000.0f, &this->actor.world.pos, &sp30) >= 0.0f) || (sp30 != 1))) { + this->actor.speedXZ = 0.0f; + this->action = DEEP_PYTHON_ACTION_GRAB; + this->actor.flags |= ACTOR_FLAG_100000; + this->actionFunc = EnDragon_SetupGrab; + } +} + +void EnDragon_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnDragon* this = THIS; + + if (this->retreatTimer != 0) { + this->retreatTimer--; + } + + if (this->timer != 0) { + this->timer--; + } + + if (this->largeSwayWaitTimer != 0) { + this->largeSwayWaitTimer--; + } + + if (this->grabWaitTimer != 0) { + this->grabWaitTimer--; + } + + EnDragon_UpdateDamage(this, globalCtx); + this->actor.shape.rot.y = this->actor.world.rot.y; + Math_Vec3f_Copy(&this->actor.focus.pos, &this->focusPos); + Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); + Actor_SetScale(&this->actor, this->scale); + + this->actionFunc(this, globalCtx); + Actor_MoveWithGravity(&this->actor); + + if (this->action != DEEP_PYTHON_ACTION_GRAB) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + if (this->action < DEEP_PYTHON_ACTION_DAMAGE) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +s32 EnDragon_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnDragon* this = THIS; + + if (limbIndex == DEEP_PYTHON_LIMB_JAW) { + rot->x += this->jawXRotation; + rot->y += this->jawYRotation; + rot->z += this->jawZRotation; + } + + return false; +} + +void EnDragon_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnDragon* this = THIS; + Vec3f playerGrabOffsetFromJawPos = { 350.0f, -120.0f, -60.0f }; + + if (limbIndex == DEEP_PYTHON_LIMB_JAW) { + Matrix_MultiplyVector3fByState(&gZeroVec3f, &this->jawPos); + playerGrabOffsetFromJawPos.x = 350.0f; + playerGrabOffsetFromJawPos.y = -120.0f; + playerGrabOffsetFromJawPos.z = -60.0f; + Matrix_MultiplyVector3fByState(&playerGrabOffsetFromJawPos, &this->playerGrabPosition); + } + + if (limbIndex == DEEP_PYTHON_LIMB_HEAD_AND_COLLAR_ROOT) { + Matrix_MultiplyVector3fByState(&gZeroVec3f, &this->focusPos); + } + + Collider_UpdateSpheres(limbIndex, &this->collider); +} + +void EnDragon_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnDragon* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnDragon_OverrideLimbDraw, EnDragon_PostLimbDraw, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Dragon/z_en_dragon.h b/src/overlays/actors/ovl_En_Dragon/z_en_dragon.h index f228748046..5fe44083b4 100644 --- a/src/overlays/actors/ovl_En_Dragon/z_en_dragon.h +++ b/src/overlays/actors/ovl_En_Dragon/z_en_dragon.h @@ -2,16 +2,63 @@ #define Z_EN_DRAGON_H #include "global.h" +#include "objects/object_utubo/object_utubo.h" + +#define EN_DRAGON_GET_PYTHON_INDEX(thisx) (((thisx)->params >> 7) & 0x1F) + +typedef enum { + /* 0 */ DEEP_PYTHON_ACTION_IDLE, + /* 1 */ DEEP_PYTHON_ACTION_EXTEND, + /* 2 */ DEEP_PYTHON_ACTION_GRAB, + /* 3 */ DEEP_PYTHON_ACTION_DAMAGE, + /* 4 */ DEEP_PYTHON_ACTION_RETREAT, + /* 5 */ DEEP_PYTHON_ACTION_SETUP_DEAD, + /* 6 */ DEEP_PYTHON_ACTION_DEAD, +} DeepPythonAction; struct EnDragon; typedef void (*EnDragonActionFunc)(struct EnDragon*, GlobalContext*); typedef struct EnDragon { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x104]; - /* 0x0248 */ EnDragonActionFunc actionFunc; - /* 0x024C */ char unk_24C[0x2B0]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[DEEP_PYTHON_LIMB_MAX]; + /* 0x1E8 */ Vec3s morphTable[DEEP_PYTHON_LIMB_MAX]; + /* 0x248 */ EnDragonActionFunc actionFunc; + /* 0x24C */ s32 animationIndex; + /* 0x250 */ s32 pythonIndex; + /* 0x254 */ Vec3f jawPos; + /* 0x260 */ Vec3f burrowEntrancePos; // Vertically and horizontally centered on the burrow opening. Set by Bg_Sinkai_Kabe + /* 0x26C */ Vec3f playerGrabPosition; + /* 0x278 */ Vec3f cameraEye; + /* 0x278 */ Vec3f cameraAt; + /* 0x290 */ Vec3f playerGrabPositionTemp; + /* 0x29C */ Vec3f focusPos; + /* 0x2A8 */ s16 jawZRotation; + /* 0x2AA */ s16 jawYRotation; // Never initialized by the actor + /* 0x2AC */ s16 jawXRotation; // Never initialized by the actor + /* 0x2AE */ s16 retreatTimer; // If the Deep Python is extended and this timer reaches 0, it is forced to retreat back to its burrow + /* 0x2B0 */ s16 behindJawRetreatTimer; // If the player is behind the jaw, then this will count up. When it reaches 60, the Deep Python will retreat + /* 0x2B2 */ s16 largeSwayWaitTimer; // If the player is in front of the jaw, it won't play or replay the large sway animation unless this is zero. + /* 0x2B4 */ s16 timer; + /* 0x2B6 */ s16 grabWaitTimer; // Cannot grab the player if this is non-zero + /* 0x2B8 */ s16 hasGrabbedPlayer; + /* 0x2BA */ s16 action; + /* 0x2BC */ UNK_TYPE1 unk_2BC[0x2]; + /* 0x2BE */ s16 state; + /* 0x2C0 */ s16 grabCutsceneIndex; + /* 0x2C2 */ s16 deathCutsceneIndex; + /* 0x2C4 */ UNK_TYPE1 unk_2C4[0x4]; + /* 0x2C8 */ s16 cameraId; + /* 0x2CA */ s16 grabTimer; // Counts up from the time a grab starts until the time the actor begins attacking + /* 0x2CC */ s16 unk_2CC; // Initialized, but never used + /* 0x2CE */ UNK_TYPE1 unk_2CE[0x2]; + /* 0x2D0 */ f32 endFrame; + /* 0x2D4 */ f32 scale; + /* 0x2D8 */ UNK_TYPE1 unk_2D8[0x4]; + /* 0x2DC */ ColliderJntSph collider; + /* 0x2FC */ ColliderJntSphElement colliderElements[8]; } EnDragon; // size = 0x4FC extern const ActorInit En_Dragon_InitVars; diff --git a/src/overlays/actors/ovl_En_Drs/z_en_drs.c b/src/overlays/actors/ovl_En_Drs/z_en_drs.c index 8643dfa91a..74f4f19cc9 100644 --- a/src/overlays/actors/ovl_En_Drs/z_en_drs.c +++ b/src/overlays/actors/ovl_En_Drs/z_en_drs.c @@ -108,7 +108,7 @@ void EnDrs_PostLimbDraw(GlobalContext* globalCtx2, s32 limbIndex, Gfx** dList, V // Anju removes the Moon Mask at the start of the Couple's Mask cutscene // after that it will no longer be rendered. - if (!(gSaveContext.weekEventReg[87] & 2) && (limbIndex == WEDDING_DRESS_MANNEQUIN_LIMB_MASK)) { + if (!(gSaveContext.save.weekEventReg[87] & 2) && (limbIndex == WEDDING_DRESS_MANNEQUIN_LIMB_MASK)) { OPEN_DISPS(globalCtx->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[temp].segment); gSPDisplayList(POLY_OPA_DISP++, &gMoonMaskDL); diff --git a/src/overlays/actors/ovl_En_Elf/z_en_elf.c b/src/overlays/actors/ovl_En_Elf/z_en_elf.c index 134a7080ef..62d455147f 100644 --- a/src/overlays/actors/ovl_En_Elf/z_en_elf.c +++ b/src/overlays/actors/ovl_En_Elf/z_en_elf.c @@ -355,15 +355,15 @@ void EnElf_Init(Actor* thisx, GlobalContext* globalCtx2) { this->elfMsg = NULL; this->unk_234 = NULL; this->unk_269 = 20; - if ((gSaveContext.tatlTimer >= 25800) || (gSaveContext.tatlTimer < 3000)) { - gSaveContext.tatlTimer = 0; + if ((gSaveContext.save.playerData.tatlTimer >= 25800) || (gSaveContext.save.playerData.tatlTimer < 3000)) { + gSaveContext.save.playerData.tatlTimer = 0; } this->unk_266 = ElfMessage_GetFirstCycleHint(globalCtx); break; case 1: colorConfig = -1; - gSaveContext.unk_1016 = 0; + gSaveContext.jinxTimer = 0; EnElf_SetupAction(this, func_8088E0F0); this->unk_254 = Math_Vec3f_DistXZ(&thisx->world.pos, &player->actor.world.pos); this->unk_248 = player->actor.shape.rot.y; @@ -675,9 +675,10 @@ void func_8088DD34(EnElf* this, GlobalContext* globalCtx) { !func_8088C804(&this->actor.world.pos, &refActor->actor.world.pos, 10.0f)) { func_80115908(globalCtx, 0x80); if (this->fairyFlags & 0x200) { - Parameter_AddMagic(globalCtx, ((void)0, gSaveContext.unk_3F30) + (gSaveContext.doubleMagic * 0x30) + 0x30); + Parameter_AddMagic(globalCtx, ((void)0, gSaveContext.unk_3F30) + + (gSaveContext.save.playerData.doubleMagic * 0x30) + 0x30); } - gSaveContext.unk_1016 = 0; + gSaveContext.jinxTimer = 0; this->unk_254 = 50.0f; this->unk_248 = refActor->actor.shape.rot.y; this->unk_24C = -0x1000; @@ -1360,8 +1361,8 @@ void func_8088FE64(Actor* thisx, GlobalContext* globalCtx2) { switch (Message_GetState(&globalCtx->msgCtx)) { case 4: - if (func_80147624(globalCtx)) { - if (globalCtx->msgCtx.unk11F04 == 0x202) { + if (Message_ShouldAdvance(globalCtx)) { + if (globalCtx->msgCtx.currentTextId == 0x202) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_8019F230(); @@ -1375,19 +1376,19 @@ void func_8088FE64(Actor* thisx, GlobalContext* globalCtx2) { switch (globalCtx->msgCtx.choiceIndex) { case 0: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 - 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId - 1); break; case 1: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; } } break; case 5: - if (func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 576: func_80151938(globalCtx, 0x245); break; @@ -1414,10 +1415,10 @@ void func_8088FE64(Actor* thisx, GlobalContext* globalCtx2) { break; case 3: - if (!gSaveContext.isNight) { + if (!gSaveContext.save.isNight) { func_80151938(globalCtx, 0x248); - } else if ((gSaveContext.time < CLOCK_TIME(6, 0)) && - (gSaveContext.weekEventReg[74] & 0x20)) { + } else if ((gSaveContext.save.time < CLOCK_TIME(6, 0)) && + (gSaveContext.save.weekEventReg[74] & 0x20)) { func_80151938(globalCtx, 0x225); } else { func_80151938(globalCtx, 0x249); @@ -1454,11 +1455,11 @@ void func_8089010C(Actor* thisx, GlobalContext* globalCtx) { if (temp_v0 != this->unk_266) { this->unk_266 = temp_v0; - gSaveContext.tatlTimer = 0; + gSaveContext.save.playerData.tatlTimer = 0; } if ((player->tatlTextId == 0) && (player->unk_730 == NULL)) { - if ((gSaveContext.tatlTimer >= 600) && (gSaveContext.tatlTimer <= 3000)) { + if ((gSaveContext.save.playerData.tatlTimer >= 600) && (gSaveContext.save.playerData.tatlTimer <= 3000)) { player->tatlTextId = ElfMessage_GetFirstCycleHint(globalCtx); } } @@ -1473,7 +1474,7 @@ void func_8089010C(Actor* thisx, GlobalContext* globalCtx) { if (thisx->textId == ElfMessage_GetFirstCycleHint(globalCtx)) { this->fairyFlags |= 0x80; - gSaveContext.tatlTimer = 3001; + gSaveContext.save.playerData.tatlTimer = 3001; } this->fairyFlags |= 0x10; @@ -1503,11 +1504,11 @@ void func_8089010C(Actor* thisx, GlobalContext* globalCtx) { } else { this->actionFunc(this, globalCtx); - if (!func_801690CC(globalCtx)) { - if (gSaveContext.tatlTimer < 25800) { - gSaveContext.tatlTimer++; + if (!Play_InCsMode(globalCtx)) { + if (gSaveContext.save.playerData.tatlTimer < 25800) { + gSaveContext.save.playerData.tatlTimer++; } else if (!(this->fairyFlags & 0x80)) { - gSaveContext.tatlTimer = 0; + gSaveContext.save.playerData.tatlTimer = 0; } } } diff --git a/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.c b/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.c index 9ff716318b..3acd2adf5d 100644 --- a/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.c +++ b/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.c @@ -5,6 +5,7 @@ */ #include "z_en_elfgrp.h" +#include "overlays/actors/ovl_En_Elforg/z_en_elforg.h" #define FLAGS (ACTOR_FLAG_10) @@ -14,7 +15,24 @@ void EnElfgrp_Init(Actor* thisx, GlobalContext* globalCtx); void EnElfgrp_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnElfgrp_Update(Actor* thisx, GlobalContext* globalCtx); -#if 0 +s32 func_80A39BD0(GlobalContext* globalCtx, s32 arg2); +s32 func_80A39C1C(GlobalContext* globalCtx, s32 arg1); +void func_80A39DC8(EnElfgrp* this, GlobalContext* globalCtx, s32 arg2, s32 arg3); +void func_80A3A0AC(EnElfgrp* this, GlobalContext* globalCtx); +void func_80A3A0F4(EnElfgrp* this, GlobalContext* globalCtx); +void func_80A3A210(EnElfgrp* this, GlobalContext* globalCtx); +void func_80A3A274(EnElfgrp* this, GlobalContext* globalCtx); +void func_80A3A398(EnElfgrp* this, GlobalContext* globalCtx); +void func_80A3A484(EnElfgrp* this, GlobalContext* globalCtx); +void func_80A3A4AC(EnElfgrp* this, GlobalContext* globalCtx); +void func_80A3A520(EnElfgrp* this, GlobalContext* globalCtx); +void func_80A3A600(EnElfgrp* this, GlobalContext* globalCtx); +void func_80A3A610(EnElfgrp* this, GlobalContext* globalCtx); +void func_80A3A6F4(EnElfgrp* this, GlobalContext* globalCtx); +void func_80A3A77C(EnElfgrp* this, GlobalContext* globalCtx); +void func_80A3A7FC(EnElfgrp* this, GlobalContext* globalCtx); +void func_80A3A8F8(EnElfgrp* this, GlobalContext* globalCtx); + const ActorInit En_Elfgrp_InitVars = { ACTOR_EN_ELFGRP, ACTORCAT_PROP, @@ -27,54 +45,547 @@ const ActorInit En_Elfgrp_InitVars = { (ActorFunc)NULL, }; -#endif +void func_80A396B0(EnElfgrp* this, s32 arg1) { + while (arg1 > 0) { + if (this->actor.cutscene == -1) { + break; + } + this->actor.cutscene = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A396B0.s") + arg1--; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/EnElfgrp_Init.s") +void EnElfgrp_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnElfgrp* this = THIS; + s32 sp24; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/EnElfgrp_Destroy.s") + this->unk_147 = ENELFGRP_GET(&this->actor); + this->unk_148 = 0; + this->unk_14A = 0; + this->actor.focus.pos.y += 40.0f; + this->actor.flags &= ~ACTOR_FLAG_1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A39BD0.s") + switch (this->unk_147) { + case ENELFGRP_1: + case ENELFGRP_2: + case ENELFGRP_3: + case ENELFGRP_4: + this->unk_148 = this->unk_147 - 1; + sp24 = func_80A39C1C(globalCtx, this->unk_147); + this->unk_146 = 1 << this->unk_147; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A39C1C.s") + if (sp24 < 25) { + func_80A39DC8(this, globalCtx, sp24, 0); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A39CD4.s") + if (sp24 >= 25) { + this->actionFunc = func_80A3A520; + func_80A396B0(this, 2); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A39DC8.s") + if ((func_80A39BD0(globalCtx, this->unk_147) + sp24) >= 25) { + this->actionFunc = func_80A3A398; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A39F50.s") + switch (this->unk_147) { + case ENELFGRP_1: + if (gSaveContext.save.weekEventReg[23] & 2) { + func_80A396B0(this, 1); + } else { + this->unk_14A |= 4; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A39FBC.s") + case ENELFGRP_2: + if (gSaveContext.save.playerData.doubleMagic == true) { + func_80A396B0(this, 1); + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A3A044.s") + case ENELFGRP_3: + if (gSaveContext.save.playerData.doubleDefense) { + func_80A396B0(this, 1); + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A3A0AC.s") + case ENELFGRP_4: + if (INV_CONTENT(ITEM_SWORD_GREAT_FAIRY) == ITEM_SWORD_GREAT_FAIRY) { + func_80A396B0(this, 1); + } else { + this->unk_14A |= 0x10; + } + break; + } + } else if (func_80A39BD0(globalCtx, this->unk_147)) { + this->actionFunc = func_80A3A7FC; + this->actor.textId = (this->unk_147 * 3) + 0x581; + } else { + this->actionFunc = func_80A3A8F8; + if ((gSaveContext.save.weekEventReg[9] & this->unk_146)) { + this->actor.textId = (this->unk_147 * 3) + 0x580; + } else { + this->actor.textId = (this->unk_147 * 3) + 0x57F; + } + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A3A0F4.s") + default: + sp24 = func_80A39C1C(globalCtx, 0); + this->unk_146 = ENELFGRP_1; + if (sp24 >= 25) { + this->actionFunc = func_80A3A520; + if ((this->actor.home.rot.z != 0) && Flags_GetSwitch(globalCtx, this->actor.home.rot.z)) { + this->actionFunc = func_80A3A600; + } else if (INV_CONTENT(ITEM_MASK_GREAT_FAIRY) == ITEM_MASK_GREAT_FAIRY) { + func_80A396B0(this, 4); + } else if (INV_CONTENT(ITEM_MASK_DEKU) != ITEM_MASK_DEKU) { + func_80A396B0(this, 5); + } else { + this->unk_14A |= 2; + func_80A396B0(this, 6); + } + } else if ((gSaveContext.save.weekEventReg[8] & 0x80)) { + func_80A39DC8(this, globalCtx, 24, 0); + this->actionFunc = func_80A3A398; + if (INV_CONTENT(ITEM_MASK_DEKU) == ITEM_MASK_DEKU) { + if (INV_CONTENT(ITEM_MASK_GREAT_FAIRY) == ITEM_MASK_GREAT_FAIRY) { + func_80A396B0(this, 2); + } else { + func_80A396B0(this, 3); + this->unk_14A |= 2; + } + } else if (gSaveContext.save.playerData.magicAcquired == true) { + func_80A396B0(this, 1); + } + } else { + func_80A39DC8(this, globalCtx, 24, 0); + this->actionFunc = func_80A3A8F8; + if ((gSaveContext.save.weekEventReg[9] & this->unk_146)) { + this->actor.textId = 0x580; + } else { + this->actor.textId = 0x578; + } + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); + } + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A3A210.s") +void EnElfgrp_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A3A274.s") +s32 func_80A39BD0(GlobalContext* globalCtx, s32 arg2) { + s8 sp1F; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A3A398.s") + if ((arg2 < 1) || (arg2 >= 5)) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A3A484.s") + sp1F = gSaveContext.save.inventory.strayFairies[arg2 - 1]; + return (sp1F - func_80A39C1C(globalCtx, arg2)) + 10; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A3A4AC.s") +s32 func_80A39C1C(GlobalContext* globalCtx, s32 arg1) { + // the permanentSceneFlags access here is in the form + // struct { + // u32 clockTown : 1; + // u32 fountains[4] : 5; + // } FairyFountains; + // where arg1 is: + // 0: clocktown + // 1: woodfall, + // 2: snowhead, + // 3: great bay, + // 4: stone tower + // clocktown is handled separately, and then the fountains are looked up as array indexing -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A3A520.s") + s32 temp_v1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A3A600.s") + if ((arg1 < 0) || (arg1 >= 5)) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A3A610.s") + if (arg1 == 0) { + if (gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 & 1) { + return 25; + } + return 24; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A3A6F4.s") + temp_v1 = (gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 >> (((arg1 - 1) * 5) + 1)) & 0x1F; + if (temp_v1 < 10) { + temp_v1 = 10; + } else if (temp_v1 > 25) { + temp_v1 = 25; + } + return temp_v1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A3A77C.s") +void func_80A39CD4(GlobalContext* globalCtx, s32 arg1, s32 arg2) { + if ((arg1 < 0) || (arg1 > 4) || (arg2 < 10) || (arg2 > 25)) { + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A3A7FC.s") + if (arg1 == 0) { + if (arg2 == 25) { + gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 |= 1; + } else { + gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 &= ~1; + } + } else { + gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 &= ~(0x1F << ((arg1 * 5) - 4)); + gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 |= arg2 << ((arg1 * 5) - 4); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A3A8F8.s") +void func_80A39DC8(EnElfgrp* this, GlobalContext* globalCtx, s32 arg2, s32 arg3) { + s32 pad; + s32 i; + Actor* elforg; + s32 temp; + Vec3f sp6C; + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/EnElfgrp_Update.s") + if (arg3 == 0) { + this->unk_14A |= 8; + } + + if (arg3 == 0) { + sp6C = this->actor.world.pos; + sp6C.y += 20.0f; + temp = ((this->unk_147 & 7) << 6) | STRAY_FAIRY_TYPE_FAIRY_FOUNTAIN; + } else { + sp6C = player->actor.world.pos; + sp6C.y += 20.0f; + temp = ((this->unk_147 & 7) << 6) | STRAY_FAIRY_TYPE_TURN_IN_TO_FAIRY_FOUNTAIN; + } + + for (i = 0; i < arg2; i++) { + elforg = + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELFORG, randPlusMinusPoint5Scaled(20.0f) + sp6C.x, + sp6C.y, randPlusMinusPoint5Scaled(20.0f) + sp6C.z, 0, 0, 0, temp); + if (elforg == NULL) { + continue; + } + elforg->home.pos.x = this->actor.home.pos.x; + elforg->home.pos.y = this->actor.home.pos.y + 20.0f; + elforg->home.pos.z = this->actor.home.pos.z; + } +} + +s32 func_80A39F50(GlobalContext* globalCtx) { + Actor* itemAction = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; + EnElforg* elfOrg; + + while (itemAction != NULL) { + if ((itemAction->id != ACTOR_EN_ELFORG) || + ((STRAY_FAIRY_TYPE(itemAction) != STRAY_FAIRY_TYPE_FAIRY_FOUNTAIN) && + (STRAY_FAIRY_TYPE(itemAction) != STRAY_FAIRY_TYPE_TURN_IN_TO_FAIRY_FOUNTAIN))) { + itemAction = itemAction->next; + continue; + } + + elfOrg = (EnElforg*)itemAction; + if (!(elfOrg->flags & STRAY_FAIRY_FLAG_MOVES_QUICKLY_TO_HOME)) { + elfOrg->flags |= STRAY_FAIRY_FLAG_MOVES_QUICKLY_TO_HOME; + } + itemAction = itemAction->next; + } + + return 0; +} + +s32 func_80A39FBC(GlobalContext* globalCtx) { + Actor* itemAction = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; + EnElforg* elfOrg; + s32 phi_v1 = 30; + + while (itemAction != NULL) { + if ((itemAction->id != ACTOR_EN_ELFORG) || + ((STRAY_FAIRY_TYPE(itemAction) != STRAY_FAIRY_TYPE_FAIRY_FOUNTAIN) && + (STRAY_FAIRY_TYPE(itemAction) != STRAY_FAIRY_TYPE_TURN_IN_TO_FAIRY_FOUNTAIN))) { + itemAction = itemAction->next; + continue; + } + + elfOrg = (EnElforg*)itemAction; + if (!(elfOrg->flags & STRAY_FAIRY_FLAG_CIRCLES_QUICKLY_IN_FOUNTAIN)) { + elfOrg->flags |= STRAY_FAIRY_FLAG_CIRCLES_QUICKLY_IN_FOUNTAIN; + if (phi_v1 >= 100) { + return phi_v1; + } + elfOrg->secondaryTimer = phi_v1; + phi_v1 += 5; + } + + itemAction = itemAction->next; + } + + return phi_v1; +} + +void func_80A3A044(GlobalContext* globalCtx) { + Actor* itemAction = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; + EnElforg* elfOrg; + + while (itemAction != NULL) { + if ((itemAction->id != ACTOR_EN_ELFORG) || + ((STRAY_FAIRY_TYPE(itemAction) != STRAY_FAIRY_TYPE_FAIRY_FOUNTAIN) && + (STRAY_FAIRY_TYPE(itemAction) != STRAY_FAIRY_TYPE_TURN_IN_TO_FAIRY_FOUNTAIN))) { + itemAction = itemAction->next; + continue; + } + + elfOrg = (EnElforg*)itemAction; + elfOrg->actor.home.rot.x = 0x14; + elfOrg->flags |= STRAY_FAIRY_FLAG_SPARKLES_AND_SHRINKS; + + itemAction = itemAction->next; + } +} + +void func_80A3A0AC(EnElfgrp* this, GlobalContext* globalCtx) { + if (!Cutscene_CheckActorAction(globalCtx, 0x64)) { + this->actionFunc = func_80A3A600; + ActorCutscene_Stop(this->actor.cutscene); + } +} + +void func_80A3A0F4(EnElfgrp* this, GlobalContext* globalCtx) { + if (this->unk_144 == 10) { + play_sound(NA_SE_SY_WHITE_OUT_T); + if (ENELFGRP_GET(&this->actor) < ENELFGRP_4) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DEMO_EFFECT, this->actor.world.pos.x, + this->actor.world.pos.y + 30.0f, this->actor.world.pos.z, 0, 0, 0, + ENELFGRP_GET(&this->actor) + ENELFGRP_4); + } else { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DEMO_EFFECT, this->actor.world.pos.x, + this->actor.world.pos.y + 30.0f, this->actor.world.pos.z, 0, 0, 0, 4); + } + } + + if ((this->unk_144 > 10) && (this->unk_14A & 1)) { + func_800B9010(&this->actor, NA_SE_EV_FAIRY_GROUP_FRY - SFX_FLAG); + } + + if (this->unk_144 == 0) { + this->actionFunc = func_80A3A0AC; + } +} + +void func_80A3A210(EnElfgrp* this, GlobalContext* globalCtx) { + if (this->unk_144 == 0) { + this->actionFunc = func_80A3A0F4; + func_80A3A044(globalCtx); + this->unk_144 = 30; + } + + if (this->unk_14A & 1) { + func_800B9010(&this->actor, NA_SE_EV_FAIRY_GROUP_FRY - SFX_FLAG); + } +} + +void func_80A3A274(EnElfgrp* this, GlobalContext* globalCtx) { + if (Cutscene_CheckActorAction(globalCtx, 0x64)) { + if (this->unk_14A & 1) { + func_800B9010(&this->actor, NA_SE_PL_CHIBI_FAIRY_HEAL - SFX_FLAG); + } + + switch (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 0x64)]->action) { + case 2: + if (!(this->unk_14A & 1)) { + if (this->unk_147 == ENELFGRP_0) { + func_80A39DC8(this, globalCtx, 1, 1); + } else { + func_80A39DC8(this, globalCtx, func_80A39BD0(globalCtx, this->unk_147), 1); + } + this->unk_14A |= 1; + func_80A39CD4(globalCtx, this->unk_147, 25); + } + break; + + case 3: + func_80A39F50(globalCtx); + this->actionFunc = func_80A3A210; + this->unk_144 = 90; + break; + } + } +} + +void func_80A3A398(EnElfgrp* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + this->actionFunc = func_80A3A274; + Flags_UnsetSwitch(globalCtx, ENELFGRP_GET_FE00(&this->actor)); + if (this->unk_14A & 2) { + Item_Give(globalCtx, ITEM_MASK_GREAT_FAIRY); + } + + if ((this->unk_14A & 4) != 0) { + gSaveContext.save.weekEventReg[23] |= 2; + } + + if (this->unk_14A & 0x10) { + Item_Give(globalCtx, ITEM_SWORD_GREAT_FAIRY); + } + this->unk_14A &= ~8; + } else if (this->actor.xzDistToPlayer < 350.0f) { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } +} + +void func_80A3A484(EnElfgrp* this, GlobalContext* globalCtx) { + if (this->unk_144 == 0) { + this->actionFunc = func_80A3A0F4; + this->unk_144 = 30; + } +} + +void func_80A3A4AC(EnElfgrp* this, GlobalContext* globalCtx) { + if (Cutscene_CheckActorAction(globalCtx, 0x64)) { + s32 temp = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 0x64)]->action; + if (temp == 3) { + this->actionFunc = func_80A3A484; + this->unk_144 = 90; + } + } +} + +void func_80A3A520(EnElfgrp* this, GlobalContext* globalCtx) { + if (Cutscene_CheckActorAction(globalCtx, 0x67)) { + this->actionFunc = func_80A3A600; + } else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + this->actionFunc = func_80A3A4AC; + Flags_SetSwitch(globalCtx, ENELFGRP_GET_FE00(&this->actor)); + + if (this->unk_14A & 2) { + Item_Give(globalCtx, ITEM_MASK_GREAT_FAIRY); + } + + if (this->actor.home.rot.z != 0) { + Flags_SetSwitch(globalCtx, this->actor.home.rot.z); + } + } else if (this->actor.xzDistToPlayer < 350.0f) { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } +} + +void func_80A3A600(EnElfgrp* this, GlobalContext* globalCtx) { +} + +void func_80A3A610(EnElfgrp* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (this->unk_144 == 60) { + Parameter_AddMagic(globalCtx, + ((void)0, gSaveContext.unk_3F30) + (gSaveContext.save.playerData.doubleMagic * 0x30) + 0x30); + gSaveContext.healthAccumulator = 320; + } + + if (this->unk_144 > 0) { + player->actor.freezeTimer = 100; + player->stateFlags1 |= 0x20000000; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIRY_GROUP_HEAL - SFX_FLAG); + } else { + player->actor.freezeTimer = 0; + player->stateFlags1 &= ~0x20000000; + this->actionFunc = func_80A3A600; + this->unk_14A |= 8; + } +} + +void func_80A3A6F4(EnElfgrp* this, GlobalContext* globalCtx) { + s32 pad; + Player* player = GET_PLAYER(globalCtx); + + if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { + player->actor.freezeTimer = 100; + player->stateFlags1 |= 0x20000000; + this->unk_144 = func_80A39FBC(globalCtx); + this->actionFunc = func_80A3A610; + this->unk_14A &= ~8; + } +} + +void func_80A3A77C(EnElfgrp* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + player->actor.freezeTimer = 100; + player->stateFlags1 |= 0x20000000; + if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { + this->unk_144 = func_80A39FBC(globalCtx); + this->actionFunc = func_80A3A610; + this->unk_14A &= ~8; + } +} + +void func_80A3A7FC(EnElfgrp* this, GlobalContext* globalCtx) { + s32 temp_s0; + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + gSaveContext.save.weekEventReg[9] |= this->unk_146; + this->actionFunc = func_80A3A6F4; + temp_s0 = func_80A39BD0(globalCtx, this->unk_147); + func_80A39DC8(this, globalCtx, temp_s0, 1); + temp_s0 += func_80A39C1C(globalCtx, this->unk_147); + if (temp_s0 > 25) { + temp_s0 = 25; + } + func_80A39CD4(globalCtx, this->unk_147, temp_s0); + } else if (this->actor.xzDistToPlayer < 280.0f) { + this->actor.flags |= ACTOR_FLAG_10000; + func_800B8614(&this->actor, globalCtx, 300.0f); + } +} + +void func_80A3A8F8(EnElfgrp* this, GlobalContext* globalCtx) { + s32 pad; + Player* player = GET_PLAYER(globalCtx); + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + gSaveContext.save.weekEventReg[9] |= this->unk_146; + this->actionFunc = func_80A3A6F4; + return; + } + + if (this->unk_147 != ENELFGRP_0) { + if (func_80A39BD0(globalCtx, this->unk_147) > 0) { + this->actionFunc = func_80A3A7FC; + return; + } + } + + if (this->actor.xzDistToPlayer < 30.0f) { + if (gSaveContext.save.playerForm == PLAYER_FORM_DEKU) { + this->actor.flags &= ~ACTOR_FLAG_10000; + player->actor.freezeTimer = 100; + player->stateFlags1 |= 0x20000000; + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); + this->actionFunc = func_80A3A77C; + gSaveContext.save.weekEventReg[9] |= this->unk_146; + } else { + this->actor.flags |= ACTOR_FLAG_10000; + func_800B8614(&this->actor, globalCtx, 100.0f); + } + } else { + this->actor.flags &= ~ACTOR_FLAG_10000; + } +} + +void EnElfgrp_Update(Actor* thisx, GlobalContext* globalCtx) { + EnElfgrp* this = THIS; + + this->actionFunc(this, globalCtx); + + if (this->unk_14A & 8) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIRY_GROUP_FRY - SFX_FLAG); + } + + if (this->unk_144 != 0) { + this->unk_144--; + } +} diff --git a/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.h b/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.h index 7ecb7d71d4..375dad55bb 100644 --- a/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.h +++ b/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.h @@ -7,9 +7,24 @@ struct EnElfgrp; typedef void (*EnElfgrpActionFunc)(struct EnElfgrp*, GlobalContext*); +#define ENELFGRP_GET(thisx) ((thisx)->params & 0xF) +#define ENELFGRP_GET_FE00(thisx) (((thisx)->params & 0xFE00) >> 9) + +enum { + /* 0 */ ENELFGRP_0, + /* 2 */ ENELFGRP_1, + /* 2 */ ENELFGRP_2, + /* 3 */ ENELFGRP_3, + /* 4 */ ENELFGRP_4, +}; + typedef struct EnElfgrp { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x8]; + /* 0x0144 */ s16 unk_144; + /* 0x0146 */ u8 unk_146; + /* 0x0147 */ u8 unk_147; + /* 0x0148 */ s8 unk_148; + /* 0x014A */ u16 unk_14A; /* 0x014C */ EnElfgrpActionFunc actionFunc; } EnElfgrp; // size = 0x150 diff --git a/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c b/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c index 3c263c0182..36ad91c0fb 100644 --- a/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c +++ b/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c @@ -81,7 +81,7 @@ void EnElforg_Init(Actor* thisx, GlobalContext* globalCtx) { switch (STRAY_FAIRY_TYPE(&this->actor)) { case STRAY_FAIRY_TYPE_CLOCK_TOWN: - if (gSaveContext.weekEventReg[8] & 0x80) { + if (gSaveContext.save.weekEventReg[8] & 0x80) { Actor_MarkForDeath(&this->actor); return; } @@ -364,7 +364,7 @@ void EnElforg_CirclePlayer(EnElforg* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); f32 distanceFromPlayer; - if (gSaveContext.playerForm == PLAYER_FORM_GORON) { + if (gSaveContext.save.playerForm == PLAYER_FORM_GORON) { distanceFromPlayer = 40.0f; } else { distanceFromPlayer = 20.0f; @@ -407,7 +407,7 @@ void EnElforg_ClockTownFairyCollected(EnElforg* this, GlobalContext* globalCtx) player->actor.freezeTimer = 0; player->stateFlags1 &= ~0x20000000; Actor_MarkForDeath(&this->actor); - gSaveContext.weekEventReg[8] |= 0x80; + gSaveContext.save.weekEventReg[8] |= 0x80; ActorCutscene_Stop(0x7C); } else { func_800B9010(&this->actor, NA_SE_PL_CHIBI_FAIRY_HEAL - SFX_FLAG); @@ -463,9 +463,9 @@ void EnElforg_FreeFloating(EnElforg* this, GlobalContext* globalCtx) { } if (func_8010A074(globalCtx)) { - gSaveContext.inventory.strayFairies[gSaveContext.unk_48C8]++; + gSaveContext.save.inventory.strayFairies[gSaveContext.unk_48C8]++; Message_StartTextbox(globalCtx, 0x11, NULL); - if (gSaveContext.inventory.strayFairies[(void)0, gSaveContext.unk_48C8] >= 15) { + if (gSaveContext.save.inventory.strayFairies[(void)0, gSaveContext.unk_48C8] >= 15) { func_801A3098(NA_BGM_GET_ITEM | 0x900); } } diff --git a/src/overlays/actors/ovl_En_Fall/z_en_fall.c b/src/overlays/actors/ovl_En_Fall/z_en_fall.c index 8c7f291ce5..dabd62e0fa 100644 --- a/src/overlays/actors/ovl_En_Fall/z_en_fall.c +++ b/src/overlays/actors/ovl_En_Fall/z_en_fall.c @@ -77,7 +77,7 @@ const ActorInit En_Fall_InitVars = { * it also moves the moon closer to the ground depending on the current time. */ void EnFall_Moon_AdjustScaleAndPosition(EnFall* this, GlobalContext* globalCtx) { - u16 currentTime = gSaveContext.time; + u16 currentTime = gSaveContext.save.time; u16 dayStartTime = this->dayStartTime; f32 finalDayRelativeHeight; @@ -218,7 +218,7 @@ void EnFall_Setup(EnFall* this, GlobalContext* globalCtx) { this->actor.draw = EnFall_Moon_Draw; this->actionFunc = EnFall_StoppedClosedMouthMoon_PerformCutsceneActions; Actor_SetScale(&this->actor, this->scale * 3.0f); - if (!(gSaveContext.weekEventReg[25] & 2)) { + if (!(gSaveContext.save.weekEventReg[25] & 2)) { Actor_MarkForDeath(&this->actor); } break; @@ -227,7 +227,7 @@ void EnFall_Setup(EnFall* this, GlobalContext* globalCtx) { this->actionFunc = EnFall_ClockTowerOrTitleScreenMoon_PerformCutsceneActions; Actor_SetScale(&this->actor, this->scale * 3.0f); this->actor.draw = EnFall_Moon_Draw; - if (gSaveContext.weekEventReg[25] & 2) { + if (gSaveContext.save.weekEventReg[25] & 2) { Actor_MarkForDeath(&this->actor); } break; @@ -325,7 +325,7 @@ void EnFall_CrashingMoon_HandleGiantsCutscene(EnFall* this, GlobalContext* globa case 2: if (CHECK_QUEST_ITEM(QUEST_REMAINS_ODOWLA) && CHECK_QUEST_ITEM(QUEST_REMAINS_GOHT) && CHECK_QUEST_ITEM(QUEST_REMAINS_GYORG) && CHECK_QUEST_ITEM(QUEST_REMAINS_TWINMOLD)) { - if (gSaveContext.weekEventReg[93] & 4) { + if (gSaveContext.save.weekEventReg[93] & 4) { if (ActorCutscene_GetCanPlayNext(0xC)) { ActorCutscene_Start(0xC, &this->actor); sGiantsCutsceneState++; @@ -334,7 +334,7 @@ void EnFall_CrashingMoon_HandleGiantsCutscene(EnFall* this, GlobalContext* globa } } else if (ActorCutscene_GetCanPlayNext(0xB)) { ActorCutscene_Start(0xB, &this->actor); - gSaveContext.weekEventReg[93] |= 4; + gSaveContext.save.weekEventReg[93] |= 4; sGiantsCutsceneState++; } else { ActorCutscene_SetIntentToPlay(0xB); @@ -481,7 +481,7 @@ void EnFall_Moon_PerformDefaultActions(EnFall* this, GlobalContext* globalCtx) { currentDay = CURRENT_DAY; if ((u16)this->currentDay != (u32)currentDay) { this->currentDay = currentDay; - this->dayStartTime = gSaveContext.time; + this->dayStartTime = gSaveContext.save.time; } EnFall_Moon_AdjustScaleAndPosition(this, globalCtx); } @@ -518,8 +518,8 @@ void EnFall_MoonsTear_Fall(EnFall* this, GlobalContext* globalCtx) { if (this->actor.draw != NULL) { if (Math_Vec3f_StepTo(&this->actor.world.pos, &this->actor.home.pos, this->actor.speedXZ) <= 0.0f) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_GORON_BOUND_1); - gSaveContext.weekEventReg[74] |= 0x80; - gSaveContext.weekEventReg[74] |= 0x20; + gSaveContext.save.weekEventReg[74] |= 0x80; + gSaveContext.save.weekEventReg[74] |= 0x20; Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_TEST, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, -2); Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->actor.world.pos.x, diff --git a/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c b/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c index 664c7ce37e..711b4ca6e5 100644 --- a/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c +++ b/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c @@ -168,10 +168,10 @@ void EnFirefly_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void EnFirefly_SpawnIceEffects(EnFirefly* this, GlobalContext* globalCtx) { - if (this->unk_18F == 0xA) { - this->unk_18F = 0; - this->unk_2E8.x = 0.0f; - Actor_SpawnIceEffects(globalCtx, &this->actor, &this->unk_2F8, 3, 2, 0.2f, 0.2f); + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, &this->limbPos[0], 3, 2, 0.2f, 0.2f); } } @@ -340,24 +340,24 @@ void EnFirefly_SetupFall(EnFirefly* this, GlobalContext* globalCtx) { } if (this->actor.colChkInfo.damageEffect == 3) { - this->unk_18F = 0xA; - this->unk_2E8.x = 1.0f; - this->unk_2E8.y = 0.55f; - this->unk_2E8.z = 0.82500005f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffFrozenSteamScale = 0.82500005f; } else if (this->actor.colChkInfo.damageEffect == 4) { - this->unk_18F = 0x14; - this->unk_2E8.x = 4.0f; - this->unk_2E8.y = 0.55f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.55f; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->collider.info.bumper.hitPos.x, this->collider.info.bumper.hitPos.y, this->collider.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_SMALL_LIGHT_RAYS); } else if (this->actor.colChkInfo.damageEffect == 2) { - this->unk_18F = 0; - this->unk_2E8.x = 4.0f; - this->unk_2E8.y = 0.55f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.55f; } - if (this->unk_2E8.x > 0.0f) { + if (this->drawDmgEffAlpha > 0.0f) { this->auraType = KEESE_AURA_NONE; } @@ -374,7 +374,7 @@ void EnFirefly_Fall(EnFirefly* this, GlobalContext* globalCtx) { Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); if (!(this->actor.flags & ACTOR_FLAG_8000)) { - if (this->unk_18F != 0xA) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { Math_ScaledStepToS(&this->actor.shape.rot.x, 0x6800, 0x200); this->actor.shape.rot.y -= 0x300; } @@ -566,8 +566,8 @@ void EnFirefly_Stunned(EnFirefly* this, GlobalContext* globalCtx) { } else { this->actor.colorFilterTimer = 40; - if (this->unk_2E8.x > 0.0f) { - this->unk_2E8.x = 2.0f; + if (this->drawDmgEffAlpha > 0.0f) { + this->drawDmgEffAlpha = 2.0f; } } } @@ -638,9 +638,9 @@ void EnFirefly_UpdateDamage(EnFirefly* this, GlobalContext* globalCtx) { EnFirefly_SetupStunned(this); } else if (this->actor.colChkInfo.damageEffect == 5) { this->timer = 40; - this->unk_18F = 0x1F; - this->unk_2E8.x = 2.0f; - this->unk_2E8.y = 0.55f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_MEDIUM; + this->drawDmgEffAlpha = 2.0f; + this->drawDmgEffScale = 0.55f; EnFirefly_SetupStunned(this); } else { Enemy_StartFinishingBlow(globalCtx, &this->actor); @@ -710,12 +710,12 @@ void EnFirefly_Update(Actor* thisx, GlobalContext* globalCtx2) { CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - if (this->unk_2E8.x > 0.0f) { - if (this->unk_18F != 0xA) { - Math_StepToF(&this->unk_2E8.x, 0.0f, 0.05f); - this->unk_2E8.y = (this->unk_2E8.x + 1.0f) * 0.275f; - this->unk_2E8.y = CLAMP_MAX(this->unk_2E8.y, 0.55f); - } else if (!Math_StepToF(&this->unk_2E8.z, 0.55f, 0.01375f)) { + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.275f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 0.55f); + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.55f, 0.01375f)) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } @@ -793,11 +793,11 @@ void EnFirefly_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList } if (limbIndex == 15) { - Matrix_GetStateTranslation(&this->unk_2F8); + Matrix_GetStateTranslation(&this->limbPos[0]); } else if (limbIndex == 21) { - Matrix_GetStateTranslation(&this->unk_304); + Matrix_GetStateTranslation(&this->limbPos[1]); } else if (limbIndex == 10) { - Matrix_GetStateTranslation(&this->unk_310); + Matrix_GetStateTranslation(&this->limbPos[2]); } } @@ -830,8 +830,9 @@ void EnFirefly_Draw(Actor* thisx, GlobalContext* globalCtx) { POLY_OPA_DISP = gfx; } - func_800BE680(globalCtx, NULL, &this->unk_2F8, 3, this->unk_2E8.y * this->actor.scale.y * 200.0f, this->unk_2E8.z, - this->unk_2E8.x, this->unk_18F); + Actor_DrawDamageEffects(globalCtx, NULL, this->limbPos, ARRAY_COUNT(this->limbPos), + this->drawDmgEffScale * this->actor.scale.y * 200.0f, this->drawDmgEffFrozenSteamScale, + this->drawDmgEffAlpha, this->drawDmgEffType); this->unk_2F4 = globalCtx->gameplayFrames; CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Firefly/z_en_firefly.h b/src/overlays/actors/ovl_En_Firefly/z_en_firefly.h index e4439ec36b..c8e24aa4f0 100644 --- a/src/overlays/actors/ovl_En_Firefly/z_en_firefly.h +++ b/src/overlays/actors/ovl_En_Firefly/z_en_firefly.h @@ -24,17 +24,17 @@ typedef struct EnFirefly { /* 0x18C */ u8 auraType; /* 0x18D */ u8 currentType; /* 0x18E */ u8 isInvisible; - /* 0x18F */ u8 unk_18F; + /* 0x18F */ u8 drawDmgEffType; /* 0x190 */ s16 timer; /* 0x192 */ s16 targetPitch; /* 0x194 */ Vec3s jointTable[28]; /* 0x23C */ Vec3s morphTable[28]; /* 0x2E4 */ f32 maxAltitude; - /* 0x2E8 */ Vec3f unk_2E8; + /* 0x2E8 */ f32 drawDmgEffAlpha; + /* 0x2E8 */ f32 drawDmgEffScale; + /* 0x2E8 */ f32 drawDmgEffFrozenSteamScale; /* 0x2F4 */ u32 unk_2F4; - /* 0x2F8 */ Vec3f unk_2F8; - /* 0x304 */ Vec3f unk_304; - /* 0x310 */ Vec3f unk_310; + /* 0x2F8 */ Vec3f limbPos[3]; /* 0x31C */ ColliderSphere collider; } EnFirefly; // size = 0x374 diff --git a/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c b/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c index 21b42c4a4a..f86cda7d85 100644 --- a/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c +++ b/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c @@ -161,27 +161,27 @@ void EnFish2_Init(Actor* thisx, GlobalContext* globalCtx) { this->jointTable, this->morphTable, 24); this->actor.colChkInfo.mass = MASS_IMMOVABLE; if (this->unk_344 == 0) { - if (gSaveContext.weekEventReg[81] & 0x10) { + if (gSaveContext.save.weekEventReg[81] & 0x10) { this->unk_2C0 = 1; } - if (gSaveContext.weekEventReg[81] & 0x20) { + if (gSaveContext.save.weekEventReg[81] & 0x20) { this->unk_2C0 = 2; } - if (gSaveContext.weekEventReg[81] & 0x40) { + if (gSaveContext.save.weekEventReg[81] & 0x40) { this->unk_2C0 = 3; } } else { - if (gSaveContext.weekEventReg[81] & 0x80) { + if (gSaveContext.save.weekEventReg[81] & 0x80) { this->unk_2C0 = 1; } - if (gSaveContext.weekEventReg[82] & 1) { + if (gSaveContext.save.weekEventReg[82] & 1) { this->unk_2C0 = 2; } - if (gSaveContext.weekEventReg[82] & 2) { + if (gSaveContext.save.weekEventReg[82] & 2) { this->unk_2C0 = 3; } } @@ -434,7 +434,7 @@ void func_80B29128(EnFish2* this) { } void func_80B2913C(EnFish2* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); func_80B28B5C(this); } @@ -619,18 +619,18 @@ void func_80B297FC(EnFish2* this, GlobalContext* globalCtx) { this->unk_2C0++; if (this->unk_344 == 0) { if (this->unk_2C0 == 1) { - gSaveContext.weekEventReg[81] |= 0x10; + gSaveContext.save.weekEventReg[81] |= 0x10; } else if (this->unk_2C0 == 2) { - gSaveContext.weekEventReg[81] |= 0x20; + gSaveContext.save.weekEventReg[81] |= 0x20; } else if (this->unk_2C0 == 3) { - gSaveContext.weekEventReg[81] |= 0x40; + gSaveContext.save.weekEventReg[81] |= 0x40; } } else if (this->unk_2C0 == 1) { - gSaveContext.weekEventReg[81] |= 0x80; + gSaveContext.save.weekEventReg[81] |= 0x80; } else if (this->unk_2C0 == 2) { - gSaveContext.weekEventReg[82] |= 1; + gSaveContext.save.weekEventReg[82] |= 1; } else if (this->unk_2C0 == 3) { - gSaveContext.weekEventReg[82] |= 2; + gSaveContext.save.weekEventReg[82] |= 2; } if (this->unk_2B0 != 0) { @@ -890,12 +890,12 @@ void func_80B2A498(EnFish2* this, GlobalContext* globalCtx) { temp_v0->speedXZ = 4.0f; temp_v0->velocity.y = 15.0f; Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_PIECE_OF_HEART); - gSaveContext.weekEventReg[81] &= (u8)~0x10; - gSaveContext.weekEventReg[81] &= (u8)~0x20; - gSaveContext.weekEventReg[81] &= (u8)~0x40; - gSaveContext.weekEventReg[81] &= (u8)~0x80; - gSaveContext.weekEventReg[82] &= (u8)~1; - gSaveContext.weekEventReg[82] &= (u8)~2; + gSaveContext.save.weekEventReg[81] &= (u8)~0x10; + gSaveContext.save.weekEventReg[81] &= (u8)~0x20; + gSaveContext.save.weekEventReg[81] &= (u8)~0x40; + gSaveContext.save.weekEventReg[81] &= (u8)~0x80; + gSaveContext.save.weekEventReg[82] &= (u8)~1; + gSaveContext.save.weekEventReg[82] &= (u8)~2; } } @@ -1094,9 +1094,9 @@ void func_80B2ADB0(EnFish2* this, Vec3f* vec, s16 arg2) { TexturePtr phi_v0; if (Rand_ZeroOne() < 0.5f) { - phi_v0 = gameplay_keep_Tex_091CE0; + phi_v0 = gEffBubble2Tex; } else { - phi_v0 = gameplay_keep_Tex_091BE0; + phi_v0 = gEffBubble1Tex; } ptr->unk_20 = VIRTUAL_TO_PHYSICAL(SEGMENTED_TO_VIRTUAL(phi_v0)); @@ -1168,7 +1168,7 @@ void func_80B2B180(EnFish2* this, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); gDPSetEnvColor(POLY_OPA_DISP++, 150, 150, 150, 0); gSPSegment(POLY_OPA_DISP++, 0x08, ptr->unk_20); - gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_0301B0); + gSPDisplayList(POLY_OPA_DISP++, gEffBubbleDL); } } diff --git a/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c b/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c index 14e364d56f..eccee0fe9f 100644 --- a/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c +++ b/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c @@ -4,6 +4,7 @@ * Description: Fishing Pond Elements (Owner, Fish, Props, Effects...) */ +#include "prevent_bss_reordering.h" #include "z_en_fishing.h" #include "objects/object_fish/object_fish.h" #include "overlays/actors/ovl_En_Kanban/z_en_kanban.h" @@ -118,86 +119,86 @@ typedef struct { #define LINE_SEG_COUNT 200 #define SINKING_LURE_SEG_COUNT 20 -static f32 D_809101B0; -static f32 D_809101B4; -static s16 D_809101B8; -static f32 D_809101BC; -static f32 D_809101C0; -static f32 D_809101C4; -static f32 D_809101C8; -static s16 D_809101CC; -static f32 D_809101D0; -static Vec3f sRodTipPos; -static Vec3f sReelLinePos[LINE_SEG_COUNT]; -static Vec3f sReelLineRot[LINE_SEG_COUNT]; -static Vec3f sReelLineUnk[LINE_SEG_COUNT]; -static Vec3f sLureHookRefPos[2]; -static f32 sLureHookRotY[2]; -static u8 D_80911E28; -static Vec3f sSinkingLurePos[SINKING_LURE_SEG_COUNT]; -static s16 D_80911F20; -static f32 sProjectedW; -static Vec3f sCameraEye; -static Vec3f sCameraAt; -static s16 sCameraId; -static f32 D_80911F48; -static f32 D_80911F4C; -static f32 D_80911F50; -static Vec3f sSinkingLureBasePos; -static f32 D_80911F64; -static s32 sRandSeed0; -static s32 sRandSeed1; -static s32 sRandSeed2; -static FishingProp sPondProps[POND_PROP_COUNT]; -static FishingGroupFish sGroupFishes[GROUP_FISH_COUNT]; -static f32 sFishGroupAngle1; -static f32 sFishGroupAngle2; -static f32 sFishGroupAngle3; -static FishingEffect sFishingEffects[EFFECT_COUNT]; -static Vec3f sStreamSoundProjectedPos; -static EnFishing* sFishingMain; -static u8 D_809171C8; -static u8 sLinkAge; -static u8 D_809171CA; -static u8 D_809171CB; -static f32 D_809171CC; -static u8 D_809171D0; -static u8 D_809171D1; -static u8 D_809171D2; -static s16 D_809171D4; -static u8 D_809171D6; -static u16 D_809171D8; -static u16 D_809171DA; -static s8 D_809171DC; -static Vec3f sOwnerHeadPos; -static Vec3s sEffOwnerHatRot; -static u8 D_809171F2; -static s16 D_809171F4; -static s16 D_809171F6; -static EnFishing* sFishingHookedFish; -static s16 D_809171FC; -static s16 D_809171FE; -static s16 D_80917200; -static s16 D_80917202; -static s16 D_80917204; -static u8 D_80917206; -static Vec3f sLurePos; -static Vec3f D_80917218; -static Vec3f sLureRot; -static Vec3f D_80917238; -static Vec3f D_80917248; -static f32 D_80917254; -static f32 D_80917258; -static f32 D_8091725C; -static f32 D_80917260; -static s8 D_80917264; -static s16 D_80917266; -static u8 D_80917268; -static f32 D_8091726C; -static u8 D_80917270; -static s16 D_80917272; -static u8 D_80917274; -static Vec3f D_80917278; +f32 D_809101B0; +f32 D_809101B4; +s16 D_809101B8; +f32 D_809101BC; +f32 D_809101C0; +f32 D_809101C4; +f32 D_809101C8; +s16 D_809101CC; +f32 D_809101D0; +Vec3f sRodTipPos; +Vec3f sReelLinePos[LINE_SEG_COUNT]; +Vec3f sReelLineRot[LINE_SEG_COUNT]; +Vec3f sReelLineUnk[LINE_SEG_COUNT]; +Vec3f sLureHookRefPos[2]; +f32 sLureHookRotY[2]; +u8 D_80911E28; +Vec3f sSinkingLurePos[SINKING_LURE_SEG_COUNT]; +s16 D_80911F20; +f32 sProjectedW; +Vec3f sCameraEye; +Vec3f sCameraAt; +s16 sCameraId; +f32 D_80911F48; +f32 D_80911F4C; +f32 D_80911F50; +Vec3f sSinkingLureBasePos; +f32 D_80911F64; +s32 sRandSeed0; +s32 sRandSeed1; +s32 sRandSeed2; +FishingProp sPondProps[POND_PROP_COUNT]; +FishingGroupFish sGroupFishes[GROUP_FISH_COUNT]; +f32 sFishGroupAngle1; +f32 sFishGroupAngle2; +f32 sFishGroupAngle3; +FishingEffect sFishingEffects[EFFECT_COUNT]; +Vec3f sStreamSoundProjectedPos; +EnFishing* sFishingMain; +u8 D_809171C8; +u8 sLinkAge; +u8 D_809171CA; +u8 D_809171CB; +f32 D_809171CC; +u8 D_809171D0; +u8 D_809171D1; +u8 D_809171D2; +s16 D_809171D4; +u8 D_809171D6; +u16 D_809171D8; +u16 D_809171DA; +s8 D_809171DC; +Vec3f sOwnerHeadPos; +Vec3s sEffOwnerHatRot; +u8 D_809171F2; +s16 D_809171F4; +s16 D_809171F6; +EnFishing* sFishingHookedFish; +s16 D_809171FC; +s16 D_809171FE; +s16 D_80917200; +s16 D_80917202; +s16 D_80917204; +u8 D_80917206; +Vec3f sLurePos; +Vec3f D_80917218; +Vec3f sLureRot; +Vec3f D_80917238; +Vec3f D_80917248; +f32 D_80917254; +f32 D_80917258; +f32 D_8091725C; +f32 D_80917260; +s8 D_80917264; +s16 D_80917266; +u8 D_80917268; +f32 D_8091726C; +u8 D_80917270; +s16 D_80917272; +u8 D_80917274; +Vec3f D_80917278; const ActorInit En_Fishing_InitVars = { ACTOR_EN_FISHING, @@ -211,38 +212,38 @@ const ActorInit En_Fishing_InitVars = { (ActorFunc)EnFishing_DrawFish, }; -static f32 D_8090CCD0 = 0.0f; -static u8 D_8090CCD4 = 0; -static f32 D_8090CCD8 = 0.0f; -static Vec3f D_8090CCDC = { 0.0f, 0.0f, 0.0f }; -static f32 D_8090CCE8 = 0.0f; -static u8 sSinkingLureLocation = 0; -static f32 D_8090CCF0 = 0.0f; -static u8 D_8090CCF4 = true; -static u16 D_8090CCF8 = 0; -static u8 D_8090CCFC = 0; -static s32 D_8090CD00 = 0; -static s16 D_8090CD04 = 0; -static u8 D_8090CD08 = 0; -static u8 D_8090CD0C = 0; -static u8 D_8090CD10 = 0; -static s16 D_8090CD14 = 0; -static Vec3f sFishMouthOffset = { 500.0f, 500.0f, 0.0f }; -static u8 D_8090CD24 = 0; -static f32 D_8090CD28 = 0; -static f32 D_8090CD2C = 0; -static f32 D_8090CD30 = 0.0f; -static f32 D_8090CD34 = 0.0f; -static f32 D_8090CD38 = 0.0f; -static f32 D_8090CD3C = 0.0f; -static f32 D_8090CD40 = 0.0f; -static s16 D_8090CD44 = 0; -static s16 D_8090CD48 = 0; -static u8 D_8090CD4C = 0; -static u8 D_8090CD50 = 0; -static u8 D_8090CD54 = 0; +f32 D_8090CCD0 = 0.0f; +u8 D_8090CCD4 = 0; +f32 D_8090CCD8 = 0.0f; +Vec3f D_8090CCDC = { 0.0f, 0.0f, 0.0f }; +f32 D_8090CCE8 = 0.0f; +u8 sSinkingLureLocation = 0; +f32 D_8090CCF0 = 0.0f; +u8 D_8090CCF4 = true; +u16 D_8090CCF8 = 0; +u8 D_8090CCFC = 0; +s32 D_8090CD00 = 0; +s16 D_8090CD04 = 0; +u8 D_8090CD08 = 0; +u8 D_8090CD0C = 0; +u8 D_8090CD10 = 0; +s16 D_8090CD14 = 0; +Vec3f sFishMouthOffset = { 500.0f, 500.0f, 0.0f }; +u8 D_8090CD24 = 0; +f32 D_8090CD28 = 0; +f32 D_8090CD2C = 0; +f32 D_8090CD30 = 0.0f; +f32 D_8090CD34 = 0.0f; +f32 D_8090CD38 = 0.0f; +f32 D_8090CD3C = 0.0f; +f32 D_8090CD40 = 0.0f; +s16 D_8090CD44 = 0; +s16 D_8090CD48 = 0; +u8 D_8090CD4C = 0; +u8 D_8090CD50 = 0; +u8 D_8090CD54 = 0; -static ColliderJntSphElementInit sJntSphElementsInit[12] = { +static ColliderJntSphElementInit sJntSphElementsInit[] = { { { ELEMTYPE_UNK0, @@ -386,13 +387,13 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 12, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; -static u8 D_8090CF18 = 0; +u8 D_8090CF18 = 0; static Vec3f sZeroVec = { 0.0f, 0.0f, 0.0f }; -static Vec3f D_8090CF28 = { 0.0f, 0.0f, 2000.0f }; // Unused +Vec3f D_8090CF28 = { 0.0f, 0.0f, 2000.0f }; // Unused void EnFishing_SetColliderElement(s32 index, ColliderJntSph* collider, Vec3f* pos, f32 scale) { collider->elements[index].dim.worldSphere.center.x = pos->x; @@ -579,7 +580,7 @@ void EnFishing_SpawnRainDrop(FishingEffect* effect, Vec3f* pos, Vec3f* rot) { } } -static FishingPropInit sPondPropInits[POND_PROP_COUNT + 1] = { +FishingPropInit sPondPropInits[POND_PROP_COUNT + 1] = { { FS_PROP_ROCK, { 529, -53, -498 } }, { FS_PROP_ROCK, { 461, -66, -480 } }, { FS_PROP_ROCK, { 398, -73, -474 } }, @@ -779,7 +780,7 @@ void EnFishing_InitPondProps(EnFishing* this, GlobalContext* globalCtx) { } } -static FishingFishInit sFishInits[] = { +FishingFishInit sFishInits[] = { { 0, { 666, -45, 354 }, 38, 0.1f }, { 0, { 681, -45, 240 }, 36, 0.1f }, { 0, { 670, -45, 90 }, 41, 0.05f }, { 0, { 615, -45, -450 }, 35, 0.2f }, { 0, { 500, -45, -420 }, 39, 0.1f }, { 0, { 420, -45, -550 }, 44, 0.05f }, { 0, { -264, -45, -640 }, 40, 0.1f }, { 0, { -470, -45, -540 }, 34, 0.2f }, { 0, { -557, -45, -430 }, 54, 0.01f }, @@ -801,7 +802,7 @@ void EnFishing_Init(Actor* thisx, GlobalContext* globalCtx2) { Actor_ProcessInitChain(thisx, sInitChain); ActorShape_Init(&thisx->shape, 0.0f, NULL, 0.0f); - sLinkAge = gSaveContext.linkAge; + sLinkAge = gSaveContext.save.linkAge; if (thisx->params < 100) { s16 i; @@ -833,7 +834,7 @@ void EnFishing_Init(Actor* thisx, GlobalContext* globalCtx2) { if (sLinkAge != 1) { // HIGH_SCORE(HS_FISHING) from OoT - if (gSaveContext.unk_EE4 & 0x1000) { + if (gSaveContext.save.unk_EE4 & 0x1000) { D_8090CD08 = 0; } else { D_8090CD08 = 1; @@ -851,18 +852,18 @@ void EnFishing_Init(Actor* thisx, GlobalContext* globalCtx2) { Audio_QueueSeqCmd(0x100100FF); if (sLinkAge == 1) { - if (gSaveContext.unk_EE4 & 0x7F) { - D_809171CC = gSaveContext.unk_EE4 & 0x7F; + if (gSaveContext.save.unk_EE4 & 0x7F) { + D_809171CC = gSaveContext.save.unk_EE4 & 0x7F; } else { D_809171CC = 40.0f; } - } else if (gSaveContext.unk_EE4 & 0x7F000000) { - D_809171CC = (gSaveContext.unk_EE4 & 0x7F000000) >> 0x18; + } else if (gSaveContext.save.unk_EE4 & 0x7F000000) { + D_809171CC = (gSaveContext.save.unk_EE4 & 0x7F000000) >> 0x18; } else { D_809171CC = 45.0f; } - D_809171D1 = (gSaveContext.unk_EE4 & 0xFF0000) >> 0x10; + D_809171D1 = (gSaveContext.save.unk_EE4 & 0xFF0000) >> 0x10; if ((D_809171D1 & 7) == 7) { globalCtx->roomCtx.unk7A[0] = 90; D_809171CA = 1; @@ -1127,7 +1128,7 @@ void EnFishing_UpdateEffects(FishingEffect* effect, GlobalContext* globalCtx) { } if ((effect->unk_2C >= 100) && (Message_GetState(&globalCtx->msgCtx) == 5)) { - if (func_80147624(globalCtx) || Message_GetState(&globalCtx->msgCtx) == 0) { + if (Message_ShouldAdvance(globalCtx) || Message_GetState(&globalCtx->msgCtx) == 0) { func_801477B4(globalCtx); func_801159EC(-50); effect->unk_2C = -1; @@ -1699,7 +1700,7 @@ void EnFishing_UpdateSinkingLure(GlobalContext* globalCtx) { } } -static f32 sSinkingLureSizes[] = { +f32 sSinkingLureSizes[] = { 1.0f, 1.5f, 1.8f, 2.0f, 1.8f, 1.6f, 1.4f, 1.2f, 1.0f, 1.0f, 0.9f, 0.85f, 0.8f, 0.7f, 0.8f, 1.0f, 1.2f, 1.1f, 1.0f, 0.8f, }; @@ -1904,18 +1905,18 @@ void EnFishing_DrawLureAndLine(GlobalContext* globalCtx, Vec3f* linePos, Vec3f* CLOSE_DISPS(globalCtx->state.gfxCtx); } -static f32 sRodScales[22] = { +f32 sRodScales[22] = { 1.0f, 1.0f, 1.0f, 0.9625f, 0.925f, 0.8875f, 0.85f, 0.8125f, 0.775f, 0.73749995f, 0.7f, 0.6625f, 0.625f, 0.5875f, 0.54999995f, 0.5125f, 0.47499996f, 0.4375f, 0.39999998f, 0.36249995f, 0.325f, 0.28749996f, }; -static f32 sRodBendRatios[22] = { +f32 sRodBendRatios[22] = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.06f, 0.12f, 0.18f, 0.24f, 0.30f, 0.36f, 0.42f, 0.48f, 0.54f, 0.60f, 0.60f, 0.5142f, 0.4285f, 0.3428f, 0.2571f, 0.1714f, 0.0857f, }; -static Vec3f sRodTipOffset = { 0.0f, 0.0f, 0.0f }; +Vec3f sRodTipOffset = { 0.0f, 0.0f, 0.0f }; void EnFishing_DrawRod(GlobalContext* globalCtx) { s16 i; @@ -2056,34 +2057,25 @@ void EnFishing_DrawRod(GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx); } -static Vec3f D_8090D614 = { 0.0f, 0.0f, 0.0f }; +Vec3f D_8090D614 = { 0.0f, 0.0f, 0.0f }; -#ifdef NON_MATCHING -// Stack memes, the pad on line ~2410 makes stack too big, but needed for ordering void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { f32 spE4; f32 spE0; - s16 phi_v0; + s16 i; s16 spDC; f32 spD8; f32 spD4; f32 spD0; f32 phi_f16; f32 spC8; - s16 i; + f32 phi_f0; Player* player = GET_PLAYER(globalCtx); Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; Vec3f spA8; Vec3f sp9C; Vec3f sp90; Input* input = CONTROLLER1(globalCtx); - // Vec3f sp80; - - f32 phi_f0; - // f32 sp70; - // Vec3f sp64; - // Vec3f sp58; - // s32 pad; D_809171FE++; @@ -2240,8 +2232,6 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { spC8 = SQ(sLurePos.x) + SQ(sLurePos.z); if (spC8 > SQ(920.0f)) { - f32 temp; - if ((sLurePos.y > 160.0f) || (sLurePos.x < 80.0f) || (sLurePos.x > 180.0f) || (sLurePos.z > 1350.0f) || (sLurePos.z < 1100.0f) || (sLurePos.y < 45.0f)) { Vec3f sp80 = this->actor.world.pos; @@ -2266,10 +2256,9 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { } } - temp = ((sqrtf(spC8) - 920.0f) * 0.11f) + WATER_SURFACE_Y(globalCtx); - // spE4 = ((sqrtf(spC8) - 920.0f) * 0.11f) + WATER_SURFACE_Y(globalCtx); - if (sLurePos.y <= temp) { - sLurePos.y = temp; + spE0 = ((sqrtf(spC8) - 920.0f) * 0.11f) + WATER_SURFACE_Y(globalCtx); + if (sLurePos.y <= spE0) { + sLurePos.y = spE0; D_80917238.x = D_80917238.y = D_80917238.z = 0.0f; D_8090CD14 = 3; D_809101D0 = 0.0; @@ -2281,7 +2270,6 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { } else { f32 sp7C = WATER_SURFACE_Y(globalCtx); f32 sp78; - // spE4 = WATER_SURFACE_Y(globalCtx); if (sLurePos.y <= sp7C) { D_8090CD14 = 2; @@ -2356,7 +2344,10 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { break; case 3: { + f32 pad; f32 sp70; + Vec3f sp64; + Vec3f sp58; D_80911F20 = 0; @@ -2432,7 +2423,7 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { sLurePos.y += D_80917278.y; } } else if (CHECK_BTN_ALL(input->cur.button, BTN_A)) { - s32 pad; + s8 requiredScopeTemp; spDC = 0x500; D_809101B0 = sReelLineRot[LINE_SEG_COUNT - 2].y + M_PI; @@ -2483,7 +2474,7 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { Matrix_InsertYRotation_f(sLureRot.y, MTXMODE_NEW); if (D_80917206 == 2) { - Vec3f sp64; + s8 requiredScopeTemp; Matrix_MultiplyVector3fByState(&sp90, &sp64); D_80917278.x = sp64.x; @@ -2506,7 +2497,9 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { } } else if (sReelLinePos[LINE_SEG_COUNT - 1].y < (WATER_SURFACE_Y(globalCtx) + phi_f0)) { if (D_80917206 == 2) { - Vec3f sp58 = this->actor.world.pos; + s8 requiredScopeTemp; + + sp58 = this->actor.world.pos; this->actor.prevPos = this->actor.world.pos = sLurePos; Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 15.0f, 30.0f, 30.0f, 0x44); this->actor.world.pos = sp58; @@ -2579,7 +2572,8 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { if ((sLurePos.y <= (WATER_SURFACE_Y(globalCtx) + 4.0f)) && (sLurePos.y >= (WATER_SURFACE_Y(globalCtx) - 4.0f))) { - phi_v0 = 63; + s8 phi_v0 = 63; + if (CHECK_BTN_ALL(input->cur.button, BTN_A) || (D_809101B4 > 1.0f)) { phi_v0 = 1; } @@ -2590,8 +2584,7 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { EnFishing_SpawnRipple(NULL, globalCtx->specialEffects, &spA8, 30.0f, 300.0f, 150, 90); } } - break; - } + } break; // must be outside of the block case 4: if (this->unk_14F != 0) { @@ -2626,10 +2619,6 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { break; } } -#else -static Vec3f D_8090D620 = { 0.0f, 0.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/EnFishing_UpdateLure.s") -#endif s32 func_809033F0(EnFishing* this, GlobalContext* globalCtx, u8 ignorePosCheck) { s16 i; @@ -2812,8 +2801,8 @@ void func_80903C60(EnFishing* this, u8 arg1) { void EnFishing_HandleAquariumDialog(EnFishing* this, GlobalContext* globalCtx) { if (sLinkAge == 1) { - if (gSaveContext.unk_EE4 & 0x7F) { - if (gSaveContext.unk_EE4 & 0x80) { + if (gSaveContext.save.unk_EE4 & 0x7F) { + if (gSaveContext.save.unk_EE4 & 0x80) { this->actor.textId = 0x40B1; } else { this->actor.textId = 0x4089; @@ -2821,8 +2810,8 @@ void EnFishing_HandleAquariumDialog(EnFishing* this, GlobalContext* globalCtx) { } else { this->actor.textId = 0x40AE; } - } else if (gSaveContext.unk_EE4 & 0x7F000000) { - if (gSaveContext.unk_EE4 & 0x80000000) { + } else if (gSaveContext.save.unk_EE4 & 0x7F000000) { + if (gSaveContext.save.unk_EE4 & 0x80000000) { this->actor.textId = 0x40B1; } else { this->actor.textId = 0x4089; @@ -2851,8 +2840,6 @@ void EnFishing_HandleAquariumDialog(EnFishing* this, GlobalContext* globalCtx) { } } -#ifdef NON_MATCHING -// D_80917266 in case 5 around the large branching void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { s16 i; s16 sp134 = 10; @@ -2868,7 +2855,7 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { s16 spFE; s16 spFC; s16 spFA; - s16 phi_v0; + s16 spF8; s16 spF6; s16 spF4; s16 spF2; @@ -2883,11 +2870,9 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { f32 phi_f2; Vec3f spC4; Vec3f spB8; - u8 phi_v0_2; f32 temp_f0; f32 temp; - s32 pad; - f32 spA4; + f32 temp2; this->actor.uncullZoneForward = 700.0f; this->actor.uncullZoneScale = 50.0f; @@ -3080,11 +3065,11 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { } if (Message_GetState(&globalCtx->msgCtx) == 0) { - if ((gSaveContext.time >= 0xC000) && (gSaveContext.time <= 0xC01B)) { + if ((gSaveContext.save.time >= CLOCK_TIME(18, 0)) && (gSaveContext.save.time <= 0xC01B)) { this->unk_150 = 7; this->unk_172[3] = Rand_ZeroFloat(150.0f) + 200.0f; } - if ((gSaveContext.time >= 0x3AAA) && (gSaveContext.time <= 0x3AC5)) { + if ((gSaveContext.save.time >= CLOCK_TIME(5, 30)) && (gSaveContext.save.time <= 0x3AC5)) { this->unk_150 = 7; this->unk_172[3] = Rand_ZeroFloat(150.0f) + 200.0f; } @@ -3328,9 +3313,9 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { multiplier = 1.0f; } - if ((gSaveContext.time >= 0xB555) && (gSaveContext.time <= 0xCAAA)) { + if ((gSaveContext.save.time >= 0xB555) && (gSaveContext.save.time <= 0xCAAA)) { multiplier *= 1.75f; - } else if ((gSaveContext.time >= 0x3555) && (gSaveContext.time <= 0x4AAA)) { + } else if ((gSaveContext.save.time >= 0x3555) && (gSaveContext.save.time <= 0x4AAA)) { multiplier *= 1.5f; } else if (D_809171CA != 0) { multiplier *= 1.5f; @@ -3435,6 +3420,8 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { this->unk_188 = 1.0f; this->unk_18C = 2000.0f; } else if (sp124 < 10.0f) { + s16 phi_v0; + if (func_809033F0(this, globalCtx, false)) { func_80903C60(this, 0); } @@ -3565,15 +3552,15 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { D_809171F6 = 0; if (this->unk_148 == 1) { - spA4 = (this->unk_1A4 * 3.0f) + 120.0f; + temp2 = (this->unk_1A4 * 3.0f) + 120.0f; } else { - spA4 = (2.0f * this->unk_1A4) + 120.0f; + temp2 = (2.0f * this->unk_1A4) + 120.0f; } - if (spA4 > 255.0f) { - spA4 = 255.0f; + if (temp2 > 255.0f) { + temp2 = 255.0f; } - func_8013EC44(0.0f, spA4, 120, 5); + func_8013EC44(0.0f, temp2, 120, 5); D_809171F4 = 40; D_80911E28 = 10; play_sound(NA_SE_IT_FISHING_HIT); @@ -3581,6 +3568,9 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { } if (this->actor.world.pos.y < WATER_SURFACE_Y(globalCtx)) { + u8 phi_v0_2; + f32 spA4; + if (this->unk_172[1] > 30) { phi_v0_2 = 7; } else { @@ -3762,8 +3752,8 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { if ((D_80917272 == 0) && (D_80917274 == 0)) { // Assignment of OoT's D_80B7E086 here removed in MM - if (((sLinkAge == 1) && (gSaveContext.unk_EE4 & 0x400)) || - ((sLinkAge != 1) && (gSaveContext.unk_EE4 & 0x800))) { + if (((sLinkAge == 1) && (gSaveContext.save.unk_EE4 & 0x400)) || + ((sLinkAge != 1) && (gSaveContext.save.unk_EE4 & 0x800))) { // Assignment of OoT's D_80B7A67C here removed in MM, this is now an empty branch } } else { @@ -3876,7 +3866,7 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { switch (this->unk_1CD) { case 0: if ((Message_GetState(&globalCtx->msgCtx) == 4) || Message_GetState(&globalCtx->msgCtx) == 0) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); if (globalCtx->msgCtx.choiceIndex == 0) { if (D_8090CCF0 == 0.0f) { @@ -3907,7 +3897,7 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { break; case 1: if ((Message_GetState(&globalCtx->msgCtx) == 4) || Message_GetState(&globalCtx->msgCtx) == 0) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); if (globalCtx->msgCtx.choiceIndex != 0) { f32 temp1 = D_8090CCF0; @@ -4181,9 +4171,6 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { } } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/EnFishing_UpdateFish.s") -#endif s32 EnFishing_FishOverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { @@ -4698,14 +4685,14 @@ void EnFishing_DrawGroupFishes(GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx); } -static u16 D_8090D638[] = { 0x4096, 0x408D, 0x408E, 0x408F, 0x4094, 0x4095 }; +u16 D_8090D638[] = { 0x4096, 0x408D, 0x408E, 0x408F, 0x4094, 0x4095 }; void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { switch (this->unk_154) { case 0: if (D_809171FC == 0) { if (sLinkAge != 1) { - if ((gSaveContext.unk_EE4 & 0x100) && !(gSaveContext.unk_EE4 & 0x200)) { + if ((gSaveContext.save.unk_EE4 & 0x100) && !(gSaveContext.save.unk_EE4 & 0x200)) { this->actor.textId = 0x4093; } else { this->actor.textId = 0x407B; @@ -4723,9 +4710,9 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { if (D_809171FC == 0) { this->unk_154 = 1; if (sLinkAge != 1) { - gSaveContext.unk_EE4 |= 0x200; + gSaveContext.save.unk_EE4 |= 0x200; } else { - gSaveContext.unk_EE4 |= 0x100; + gSaveContext.save.unk_EE4 |= 0x100; } } else { this->unk_154 = 10; @@ -4736,12 +4723,12 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { break; case 1: - if ((Message_GetState(&globalCtx->msgCtx) == 4) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 4) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); switch (globalCtx->msgCtx.choiceIndex) { case 0: - if (gSaveContext.rupees >= 20) { + if (gSaveContext.save.playerData.rupees >= 20) { func_801159EC(-20); if (func_8013EE04() == 0) { this->actor.textId = 0x407C; @@ -4764,7 +4751,7 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { break; case 2: - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); func_80151938(globalCtx, 0x407F); this->unk_154 = 4; @@ -4772,7 +4759,7 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { break; case 3: - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); this->unk_154 = 0; } @@ -4782,7 +4769,7 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { break; case 4: - if ((Message_GetState(&globalCtx->msgCtx) == 4) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 4) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); switch (globalCtx->msgCtx.choiceIndex) { @@ -4799,7 +4786,7 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { break; case 5: - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); globalCtx->interfaceCtx.unk_27E = 1; @@ -4808,15 +4795,15 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { D_8090CD04 = 20; this->unk_154 = 0; - if ((gSaveContext.unk_EE4 & 0xFF0000) < 0xFF0000) { - gSaveContext.unk_EE4 += 0x10000; + if ((gSaveContext.save.unk_EE4 & 0xFF0000) < 0xFF0000) { + gSaveContext.save.unk_EE4 += 0x10000; } } break; case 10: if (D_8090CD0C != 0) { - if ((Message_GetState(&globalCtx->msgCtx) == 4) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 4) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); switch (globalCtx->msgCtx.choiceIndex) { @@ -4832,7 +4819,7 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { } } } else { - if ((Message_GetState(&globalCtx->msgCtx) == 4) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 4) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); switch (globalCtx->msgCtx.choiceIndex) { @@ -4905,7 +4892,7 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { case 11: if (((Message_GetState(&globalCtx->msgCtx) == 5) || Message_GetState(&globalCtx->msgCtx) == 0) && - func_80147624(globalCtx)) { + Message_ShouldAdvance(globalCtx)) { s32 getItemId; func_801477B4(globalCtx); @@ -4917,30 +4904,29 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { if (sLinkAge == 1) { f32 temp; - gSaveContext.unk_EE4 &= 0xFFFFFF00; - gSaveContext.unk_EE4 |= ((s16)D_809171CC & 0x7F); - - temp = (gSaveContext.unk_EE4 & 0x7F000000) >> 0x18; + gSaveContext.save.unk_EE4 &= 0xFFFFFF00; + gSaveContext.save.unk_EE4 |= ((s16)D_809171CC & 0x7F); + temp = (gSaveContext.save.unk_EE4 & 0x7F000000) >> 0x18; if (temp < D_809171CC) { - gSaveContext.unk_EE4 &= 0xFFFFFF; - gSaveContext.unk_EE4 |= ((s16)D_809171CC & 0x7F) << 0x18; + gSaveContext.save.unk_EE4 &= 0xFFFFFF; + gSaveContext.save.unk_EE4 |= ((s16)D_809171CC & 0x7F) << 0x18; if (D_809171D2 == 2) { - gSaveContext.unk_EE4 |= 0x80000000; + gSaveContext.save.unk_EE4 |= 0x80000000; } } if (D_809171D2 == 2) { - gSaveContext.unk_EE4 |= 0x80; + gSaveContext.save.unk_EE4 |= 0x80; this->unk_154 = 0; break; } } else { - gSaveContext.unk_EE4 &= 0xFFFFFF; - gSaveContext.unk_EE4 |= ((s16)D_809171CC & 0x7F) << 0x18; + gSaveContext.save.unk_EE4 &= 0xFFFFFF; + gSaveContext.save.unk_EE4 |= ((s16)D_809171CC & 0x7F) << 0x18; if (D_809171D2 == 2) { - gSaveContext.unk_EE4 |= 0x80000000; + gSaveContext.save.unk_EE4 |= 0x80000000; this->unk_154 = 0; break; } @@ -4957,14 +4943,14 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { } if (sLinkAge == 1) { - if ((D_809171CC >= 50.0f) && !(gSaveContext.unk_EE4 & 0x400)) { - gSaveContext.unk_EE4 |= 0x400; + if ((D_809171CC >= 50.0f) && !(gSaveContext.save.unk_EE4 & 0x400)) { + gSaveContext.save.unk_EE4 |= 0x400; getItemId = GI_HEART_PIECE; sSinkingLureLocation = Rand_ZeroFloat(3.999f) + 1.0f; } } else { - if ((D_809171CC >= 60.0f) && !(gSaveContext.unk_EE4 & 0x800)) { - gSaveContext.unk_EE4 |= 0x800; + if ((D_809171CC >= 60.0f) && !(gSaveContext.save.unk_EE4 & 0x800)) { + gSaveContext.save.unk_EE4 |= 0x800; getItemId = GI_SCALE_GOLD; sSinkingLureLocation = Rand_ZeroFloat(3.999f) + 1.0f; } @@ -4981,14 +4967,14 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { break; case 20: - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); this->unk_154 = 0; } break; case 21: - if ((Message_GetState(&globalCtx->msgCtx) == 4) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 4) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); switch (globalCtx->msgCtx.choiceIndex) { @@ -5030,7 +5016,7 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { case 24: D_8090CCF4 = false; - if ((Message_GetState(&globalCtx->msgCtx) == 6) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 6) && Message_ShouldAdvance(globalCtx)) { if (D_809171D0 == 0) { this->unk_154 = 0; } else { @@ -5042,19 +5028,17 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { } } -static s16 D_8090D644[] = { 0, 1, 2, 2, 1 }; +s16 D_8090D644[] = { 0, 1, 2, 2, 1 }; -static Vec3f sStreamSoundPos = { 670.0f, 0.0f, -600.0f }; +Vec3f sStreamSoundPos = { 670.0f, 0.0f, -600.0f }; -static Vec3s sSinkingLureLocationPos[] = { +Vec3s sSinkingLureLocationPos[] = { { -364, -30, -269 }, { 1129, 3, -855 }, { -480, 0, -1055 }, { 553, -48, -508 }, }; -#ifdef NON_MATCHING -// Register flip around target near the end of the function void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; EnFishing* this = THIS; @@ -5066,10 +5050,9 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { f32 target; f32 camAtFraction; f32 lureDistXZ; - s32 pad; + Camera* camera; Player* player = GET_PLAYER(globalCtx); Input* input = CONTROLLER1(globalCtx); - Camera* camera; playerShadowAlpha = player->actor.shape.shadowAlpha; @@ -5130,9 +5113,9 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { } if (D_8090CD08 == 0) { - gSaveContext.unk_EE4 |= 0x1000; + gSaveContext.save.unk_EE4 |= 0x1000; } else if (D_8090CD08 == 1) { - gSaveContext.unk_EE4 &= ~0x1000; + gSaveContext.save.unk_EE4 &= ~0x1000; } if (D_8090CCFC != 0) { @@ -5334,7 +5317,7 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { player->actor.speedXZ = 0.0f; if (Message_GetState(&globalCtx->msgCtx) == 0) { - camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); + Camera* camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); camera->eye = sCameraEye; camera->eyeNext = sCameraEye; @@ -5370,7 +5353,7 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { // fallthrough case 21: - if ((D_8090CD50 == 0) && func_80147624(globalCtx)) { + if ((D_8090CD50 == 0) && Message_ShouldAdvance(globalCtx)) { D_8090CD4C = 22; D_8090CD50 = 40; // func_800B7298 call removed in MM @@ -5427,7 +5410,7 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { if (D_8090CD50 == 0) { if ((Message_GetState(&globalCtx->msgCtx) == 4) || Message_GetState(&globalCtx->msgCtx) == 0) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { Camera* camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); func_801477B4(globalCtx); @@ -5533,7 +5516,8 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { Math_ApproachF(&D_8090CCD0, D_8090CCD4, 1.0f, 0.05f); if (D_8090CCD0 > 0.0f) { - target = (D_8090CCD0 * 0.03f) + 0.8f; + f32 target = (D_8090CCD0 * 0.03f) + 0.8f; + if (target > 1.2f) { target = 1.2f; } @@ -5561,9 +5545,8 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { if ((u8)D_8090CCD0 > 0) { s32 pad; - Camera* camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); s16 i; - s32 pad1; + Camera* camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); Vec3f pos; Vec3f rot; Vec3f projectedPos; @@ -5595,15 +5578,12 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { Audio_PlaySfxAtPos(&sStreamSoundProjectedPos, NA_SE_EV_WATER_WALL - SFX_FLAG); - if (gSaveContext.language == 0) { // Added in MM + if (gSaveContext.options.language == 0) { // Added in MM gSaveContext.minigameScore = D_8090CCF8; } else { gSaveContext.minigameScore = (SQ((f32)D_8090CCF8) * 0.0036f) + 0.5f; } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/EnFishing_UpdateOwner.s") -#endif s32 EnFishing_OwnerOverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { @@ -5632,10 +5612,10 @@ void EnFishing_OwnerPostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** } } -static UNK_TYPE sFishingOwnerEyeTexs[] = { - &gFishingOwnerEyeOpenTex, - &gFishingOwnerEyeHalfTex, - &gFishingOwnerEyeClosedTex, +TexturePtr sFishingOwnerEyeTexs[] = { + gFishingOwnerEyeOpenTex, + gFishingOwnerEyeHalfTex, + gFishingOwnerEyeClosedTex, }; void EnFishing_DrawOwner(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c index 3ce216f7fc..de7d340249 100644 --- a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c +++ b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c @@ -5,7 +5,6 @@ */ #include "z_en_floormas.h" -#include "objects/object_wallmaster/object_wallmaster.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_400) @@ -154,8 +153,8 @@ void EnFloormas_Init(Actor* thisx, GlobalContext* globalCtx2) { Actor_ProcessInitChain(&this->actor, sInitChain); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 50.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_wallmaster_Skel_008FB0, &object_wallmaster_Anim_009DB0, - this->jointTable, this->morphTable, 25); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gWallmasterSkel, &gWallmasterIdleAnim, this->jointTable, + this->morphTable, WALLMASTER_LIMB_MAX); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); @@ -233,10 +232,10 @@ void func_808D0930(EnFloormas* this, GlobalContext* globalCtx) { } void func_808D09CC(EnFloormas* this) { - this->unk_18C = 10; - this->unk_2C8 = 0.55f; - this->unk_2CC = 0.82500005f; - this->unk_2C4 = 1.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffFrozenSteamScale = 0.82500005f; + this->drawDmgEffAlpha = 1.0f; this->collider.base.colType = COLTYPE_HIT3; this->unk_18E = 80; this->actor.flags &= ~(ACTOR_FLAG_200 | ACTOR_FLAG_400); @@ -244,11 +243,11 @@ void func_808D09CC(EnFloormas* this) { } void func_808D0A48(EnFloormas* this, GlobalContext* globalCtx) { - if (this->unk_18C == 10) { - this->unk_18C = 0; + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->collider.base.colType = COLTYPE_HIT0; - this->unk_2C4 = 0.0f; - Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_2D0, ARRAY_COUNT(this->unk_2D0), 2, + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), 2, this->actor.scale.x * 30.000002f, this->actor.scale.x * 20.0f); if (this->actor.scale.x > 0.009f) { this->actor.flags |= ACTOR_FLAG_400; @@ -259,7 +258,7 @@ void func_808D0A48(EnFloormas* this, GlobalContext* globalCtx) { } void func_808D0B08(EnFloormas* this) { - Animation_PlayOnce(&this->skelAnime, &object_wallmaster_Anim_009DB0); + Animation_PlayOnce(&this->skelAnime, &gWallmasterIdleAnim); this->actor.speedXZ = 0.0f; this->actionFunc = func_808D0B50; } @@ -278,7 +277,7 @@ void func_808D0B50(EnFloormas* this, GlobalContext* globalCtx) { } void func_808D0C14(EnFloormas* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_wallmaster_Anim_00A054, -3.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &gWallmasterStandUpAnim, -3.0f); this->actionFunc = func_808D0C58; } @@ -296,7 +295,7 @@ void func_808D0C58(EnFloormas* this, GlobalContext* globalCtx) { void func_808D0CE4(EnFloormas* this) { if (this->actionFunc != func_808D0F80) { - Animation_PlayLoopSetSpeed(&this->skelAnime, &object_wallmaster_Anim_0041F4, 1.5f); + Animation_PlayLoopSetSpeed(&this->skelAnime, &gWallmasterWalkAnim, 1.5f); } else { this->skelAnime.playSpeed = 1.5f; } @@ -334,7 +333,7 @@ void func_808D0D70(EnFloormas* this, GlobalContext* globalCtx) { } void func_808D0ECC(EnFloormas* this) { - Animation_PlayOnce(&this->skelAnime, &object_wallmaster_Anim_009244); + Animation_PlayOnce(&this->skelAnime, &gWallmasterStopWalkAnim); this->actor.speedXZ = 0.0f; this->actionFunc = func_808D0F14; } @@ -373,10 +372,10 @@ void func_808D108C(EnFloormas* this) { this->actor.speedXZ = 0.0f; if (sp36 > 0) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_wallmaster_Anim_002158, -3.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &gFloormasterTurnAnim, -3.0f); } else { - Animation_Change(&this->skelAnime, &object_wallmaster_Anim_002158, -1.0f, - Animation_GetLastFrame(&object_wallmaster_Anim_002158.common), 0.0f, 2, -3.0f); + Animation_Change(&this->skelAnime, &gFloormasterTurnAnim, -1.0f, Animation_GetLastFrame(&gFloormasterTurnAnim), + 0.0f, ANIMMODE_ONCE, -3.0f); } if (this->actor.scale.x > 0.009f) { @@ -418,8 +417,8 @@ void func_808D11BC(EnFloormas* this, GlobalContext* globalCtx) { } void func_808D1380(EnFloormas* this, GlobalContext* globalCtx) { - Animation_Change(&this->skelAnime, &object_wallmaster_Anim_009520, 3.0f, 0.0f, - Animation_GetLastFrame(&object_wallmaster_Anim_009520.common), 2, -3.0f); + Animation_Change(&this->skelAnime, &gWallmasterHoverAnim, 3.0f, 0.0f, Animation_GetLastFrame(&gWallmasterHoverAnim), + ANIMMODE_ONCE, -3.0f); this->actor.speedXZ = 0.0f; this->actor.gravity = 0.0f; func_808D08D0(this); @@ -492,7 +491,7 @@ void func_808D1650(EnFloormas* this, GlobalContext* globalCtx) { } void func_808D1740(EnFloormas* this) { - Animation_Change(&this->skelAnime, &object_wallmaster_Anim_0019CC, 1.0f, 41.0f, 42.0f, 2, 5.0f); + Animation_Change(&this->skelAnime, &gWallmasterJumpAnim, 1.0f, 41.0f, 42.0f, ANIMMODE_ONCE, 5.0f); if ((this->actor.speedXZ < 0.0f) || (this->actionFunc != func_808D1650)) { this->unk_18E = 30; } else { @@ -538,7 +537,7 @@ void func_808D17EC(EnFloormas* this, GlobalContext* globalCtx) { if ((this->unk_18E == 0) && (sp24 != 0)) { if (this->skelAnime.endFrame < 45.0f) { - this->skelAnime.endFrame = Animation_GetLastFrame(&object_wallmaster_Anim_0019CC.common); + this->skelAnime.endFrame = Animation_GetLastFrame(&gWallmasterJumpAnim); } else if (this->actor.params == ENFLOORMAS_GET_7FFF_40) { func_808D2700(this); } else { @@ -556,10 +555,10 @@ void func_808D19D4(EnFloormas* this) { Actor* parent; this->actor.colorFilterTimer = 0; - this->unk_2C4 = 0.0f; + this->drawDmgEffAlpha = 0.0f; Actor_SetScale(&this->actor, 0.004f); this->actor.flags |= ACTOR_FLAG_10; - if CHECK_FLAG_ALL (this->actor.flags, ACTOR_FLAG_80) { + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80)) { this->actor.draw = func_808D3754; } else { this->actor.draw = EnFloormas_Draw; @@ -569,8 +568,8 @@ void func_808D19D4(EnFloormas* this) { this->actor.shape.rot.y = parent->shape.rot.y + 0x5555; this->actor.world.pos = parent->world.pos; this->actor.params = ENFLOORMAS_GET_7FFF_10; - Animation_Change(&this->skelAnime, &object_wallmaster_Anim_0019CC, 1.0f, 41.0f, - Animation_GetLastFrame(&object_wallmaster_Anim_0019CC.common), 2, 0.0f); + Animation_Change(&this->skelAnime, &gWallmasterJumpAnim, 1.0f, 41.0f, Animation_GetLastFrame(&gWallmasterJumpAnim), + ANIMMODE_ONCE, 0.0f); this->collider.dim.radius = sCylinderInit.dim.radius * 0.6f; this->collider.dim.height = sCylinderInit.dim.height * 0.6f; this->actor.flags &= ~ACTOR_FLAG_400; @@ -596,7 +595,7 @@ void func_808D1B44(EnFloormas* this, GlobalContext* globalCtx) { } void func_808D1BCC(EnFloormas* this) { - Animation_PlayLoopSetSpeed(&this->skelAnime, &object_wallmaster_Anim_0041F4, 4.5f); + Animation_PlayLoopSetSpeed(&this->skelAnime, &gWallmasterWalkAnim, 4.5f); this->actor.speedXZ = 5.0f; this->actionFunc = func_808D1C1C; } @@ -623,7 +622,7 @@ void func_808D1C1C(EnFloormas* this, GlobalContext* globalCtx) { void func_808D1D0C(EnFloormas* this) { if (this->actionFunc != func_808D1C1C) { - Animation_PlayLoopSetSpeed(&this->skelAnime, &object_wallmaster_Anim_0041F4, 4.5f); + Animation_PlayLoopSetSpeed(&this->skelAnime, &gWallmasterWalkAnim, 4.5f); } this->actor.speedXZ = 5.0f; this->actionFunc = func_808D1D6C; @@ -686,7 +685,7 @@ void func_808D1F7C(EnFloormas* this, GlobalContext* globalCtx) { } void func_808D1FD4(EnFloormas* this) { - Animation_Change(&this->skelAnime, &object_wallmaster_Anim_0019CC, 2.0f, 0.0f, 41.0f, 2, 0.0f); + Animation_Change(&this->skelAnime, &gWallmasterJumpAnim, 2.0f, 0.0f, 41.0f, ANIMMODE_ONCE, 0.0f); this->actor.speedXZ = 0.0f; this->actionFunc = func_808D2040; } @@ -716,12 +715,12 @@ void func_808D217C(EnFloormas* this, Player* player) { Vec3f* ptr; u8 playerForm; - Animation_Change(&this->skelAnime, &object_wallmaster_Anim_0019CC, 1.0f, 36.0f, 45.0f, 2, -3.0f); + Animation_Change(&this->skelAnime, &gWallmasterJumpAnim, 1.0f, 36.0f, 45.0f, ANIMMODE_ONCE, -3.0f); this->actor.flags &= ~ACTOR_FLAG_1; this->actor.speedXZ = 0.0f; this->actor.velocity.y = 0.0f; func_808D08D0(this); - playerForm = gSaveContext.playerForm; + playerForm = gSaveContext.save.playerForm; ptr = &D_808D3900[playerForm]; this->actor.home.pos.x = ptr->z * Math_SinS(this->actor.shape.rot.y); this->actor.home.pos.y = CLAMP(-this->actor.playerHeightRel, ptr->x, ptr->y); @@ -772,7 +771,7 @@ void func_808D22C8(EnFloormas* this, GlobalContext* globalCtx) { } void func_808D2484(EnFloormas* this) { - Animation_Change(&this->skelAnime, &object_wallmaster_Anim_0019CC, 2.0f, 0.0f, 41.0f, 2, 0.0f); + Animation_Change(&this->skelAnime, &gWallmasterJumpAnim, 2.0f, 0.0f, 41.0f, ANIMMODE_ONCE, 0.0f); this->actor.speedXZ = 0.0f; this->actionFunc = func_808D24F0; } @@ -816,7 +815,7 @@ void func_808D24F0(EnFloormas* this, GlobalContext* globalCtx) { } void func_808D2700(EnFloormas* this) { - Animation_PlayOnce(&this->skelAnime, &object_wallmaster_Anim_009DB0); + Animation_PlayOnce(&this->skelAnime, &gWallmasterIdleAnim); this->unk_18E = 0; this->unk_194 = 1500; this->actor.params = ENFLOORMAS_GET_7FFF_40; @@ -881,10 +880,10 @@ void func_808D2764(EnFloormas* this, GlobalContext* globalCtx) { this->actor.colChkInfo.health = sColChkInfoInit.health; func_808D0C14(this); } else if (this->unk_18E == 0) { - Animation_PlayOnce(&this->skelAnime, &object_wallmaster_Anim_0039B0); + Animation_PlayOnce(&this->skelAnime, &gFloormasterTapFingerAnim); this->unk_18E = 1; } else { - Animation_PlayOnce(&this->skelAnime, &object_wallmaster_Anim_009DB0); + Animation_PlayOnce(&this->skelAnime, &gWallmasterIdleAnim); this->unk_18E = 0; } } @@ -896,7 +895,7 @@ void func_808D2A20(EnFloormas* this) { EnFloormas* parent = (EnFloormas*)this->actor.parent; EnFloormas* child = (EnFloormas*)this->actor.child; - this->unk_2C4 = 0.0f; + this->drawDmgEffAlpha = 0.0f; if ((parent->actionFunc == func_808D2AA8) && (child->actionFunc == func_808D2AA8)) { func_808D2AB8(parent); @@ -924,7 +923,7 @@ void func_808D2AF4(EnFloormas* this, GlobalContext* globalCtx) { } void func_808D2B18(EnFloormas* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_wallmaster_Anim_000590, -3.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &gWallmasterDamageAnim, -3.0f); func_800BE504(&this->actor, &this->collider); Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 20); this->actor.speedXZ = 5.0f; @@ -967,7 +966,7 @@ void func_808D2C08(EnFloormas* this, GlobalContext* globalCtx) { } void func_808D2CDC(EnFloormas* this) { - Animation_PlayOnce(&this->skelAnime, &object_wallmaster_Anim_000EA4); + Animation_PlayOnce(&this->skelAnime, &gWallmasterRecoverFromDamageAnim); this->actor.speedXZ = 0.0f; this->actor.velocity.y = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; @@ -1009,16 +1008,17 @@ void func_808D2E34(EnFloormas* this, GlobalContext* globalCtx) { if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; Actor_SetDropFlag(&this->actor, &this->collider.info); - if ((this->unk_18C != 10) || !(this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { + if ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || + !(this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { if (this->actor.colChkInfo.damageEffect == 0xE) { func_808D0908(this); this->actor.colorFilterTimer = 0; this->actor.colChkInfo.damage = 4; this->unk_192 = -1600; this->actor.gravity = -1.0f; - this->unk_2C4 = 4.0f; - this->unk_2C8 = 0.55f; - this->unk_18C = 20; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; } if (this->collider.base.colType != COLTYPE_HARD) { @@ -1053,19 +1053,19 @@ void func_808D2E34(EnFloormas* this, GlobalContext* globalCtx) { this->unk_18E = 40; Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); - this->unk_2C8 = 0.55f; - this->unk_2C4 = 2.0f; - this->unk_18C = 31; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffAlpha = 2.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_MEDIUM; func_808D2D6C(this); } else { if (this->actor.colChkInfo.damageEffect == 2) { - this->unk_2C4 = 4.0f; - this->unk_2C8 = 0.55f; - this->unk_18C = 0; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; } else if (this->actor.colChkInfo.damageEffect == 4) { - this->unk_2C4 = 4.0f; - this->unk_2C8 = 0.55f; - this->unk_18C = 20; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->collider.info.bumper.hitPos.x, this->collider.info.bumper.hitPos.y, this->collider.info.bumper.hitPos.z, 0, 0, 0, @@ -1133,12 +1133,12 @@ void EnFloormas_Update(Actor* thisx, GlobalContext* globalCtx) { } } - if (this->unk_2C4 > 0.0f) { - if (this->unk_18C != 10) { - Math_StepToF(&this->unk_2C4, 0.0f, 0.05f); - this->unk_2C8 = (this->unk_2C4 + 1.0f) * 0.275f; - this->unk_2C8 = CLAMP_MAX(this->unk_2C8, 0.55f); - } else if (!Math_StepToF(&this->unk_2CC, 0.55f, 0.01375f)) { + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.275f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 0.55f); + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.55f, 0.01375f)) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } @@ -1150,9 +1150,10 @@ s32 EnFloormas_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** d Actor* thisx, Gfx** gfx) { EnFloormas* this = THIS; - if (limbIndex == 1) { + if (limbIndex == WALLMASTER_LIMB_ROOT) { pos->z += this->unk_192; } + return false; } @@ -1161,16 +1162,13 @@ void EnFloormas_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis EnFloormas* this = THIS; if (D_808D393C[limbIndex] != -1) { - Matrix_GetStateTranslation(&this->unk_2D0[D_808D393C[limbIndex]]); + Matrix_GetStateTranslation(&this->limbPos[D_808D393C[limbIndex]]); } - if (limbIndex == 19) { - Matrix_GetStateTranslationAndScaledX(1000.0f, &this->unk_2D0[9]); - Matrix_GetStateTranslationAndScaledX(-1000.0f, &this->unk_2D0[10]); - return; - } - - if (limbIndex == 2) { + if (limbIndex == WALLMASTER_LIMB_WRIST) { + Matrix_GetStateTranslationAndScaledX(1000.0f, &this->limbPos[9]); + Matrix_GetStateTranslationAndScaledX(-1000.0f, &this->limbPos[10]); + } else if (limbIndex == WALLMASTER_LIMB_HAND) { Matrix_StatePush(); Matrix_InsertTranslation(1600.0f, -700.0f, -1700.0f, MTXMODE_APPLY); Matrix_InsertYRotation_f(M_PI / 3, MTXMODE_APPLY); @@ -1178,7 +1176,7 @@ void EnFloormas_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis Matrix_Scale(2.0f, 2.0f, 2.0f, MTXMODE_APPLY); gSPMatrix((*gfx)++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList((*gfx)++, object_wallmaster_DL_008688); + gSPDisplayList((*gfx)++, gWallmasterLittleFingerDL); Matrix_StatePop(); } @@ -1203,9 +1201,10 @@ void EnFloormas_Draw(Actor* thisx, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx); - func_800BE680(globalCtx, &this->actor, this->unk_2D0, ARRAY_COUNT(this->unk_2D0), - 100.0f * (this->unk_2C8 * this->actor.scale.x), 100.0f * (this->unk_2CC * this->actor.scale.x), - this->unk_2C4, this->unk_18C); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + 100.0f * (this->drawDmgEffScale * this->actor.scale.x), + 100.0f * (this->drawDmgEffFrozenSteamScale * this->actor.scale.x), this->drawDmgEffAlpha, + this->drawDmgEffType); } void func_808D3754(Actor* thisx, GlobalContext* globalCtx) { @@ -1227,7 +1226,8 @@ void func_808D3754(Actor* thisx, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx); - func_800BE680(globalCtx, &this->actor, this->unk_2D0, ARRAY_COUNT(this->unk_2D0), - this->unk_2C8 * this->actor.scale.x * 100.0f, this->unk_2CC * this->actor.scale.x * 100.0f, - this->unk_2C4, this->unk_18C); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + this->drawDmgEffScale * this->actor.scale.x * 100.0f, + this->drawDmgEffFrozenSteamScale * this->actor.scale.x * 100.0f, this->drawDmgEffAlpha, + this->drawDmgEffType); } diff --git a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.h b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.h index ebfa17777f..5c33ba8863 100644 --- a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.h +++ b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.h @@ -2,6 +2,7 @@ #define Z_EN_FLOORMAS_H #include "global.h" +#include "objects/object_wallmaster/object_wallmaster.h" struct EnFloormas; @@ -21,17 +22,17 @@ typedef struct EnFloormas { /* 0x0000 */ Actor actor; /* 0x0144 */ SkelAnime skelAnime; /* 0x0188 */ EnFloormasActionFunc actionFunc; - /* 0x018C */ u8 unk_18C; + /* 0x018C */ u8 drawDmgEffType; /* 0x018E */ s16 unk_18E; /* 0x0190 */ s16 unk_190; /* 0x0192 */ s16 unk_192; /* 0x0194 */ s16 unk_194; - /* 0x0196 */ Vec3s jointTable[25]; - /* 0x022C */ Vec3s morphTable[25]; - /* 0x02C4 */ f32 unk_2C4; - /* 0x02C8 */ f32 unk_2C8; - /* 0x02CC */ f32 unk_2CC; - /* 0x02D0 */ Vec3f unk_2D0[11]; + /* 0x0196 */ Vec3s jointTable[WALLMASTER_LIMB_MAX]; + /* 0x022C */ Vec3s morphTable[WALLMASTER_LIMB_MAX]; + /* 0x02C4 */ f32 drawDmgEffAlpha; + /* 0x02C8 */ f32 drawDmgEffScale; + /* 0x02CC */ f32 drawDmgEffFrozenSteamScale; + /* 0x02D0 */ Vec3f limbPos[11]; /* 0x0354 */ ColliderCylinder collider; } EnFloormas; // size = 0x3A0 diff --git a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c index 31a7046cbb..a69730bed0 100644 --- a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c +++ b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c @@ -5,7 +5,6 @@ */ #include "z_en_fsn.h" -#include "objects/object_fsn/object_fsn.h" #include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) @@ -47,6 +46,29 @@ void EnFsn_SelectItem(EnFsn* this, GlobalContext* globalCtx); void EnFsn_LookToShopkeeperFromShelf(EnFsn* this, GlobalContext* globalCtx); void EnFsn_PlayerCannotBuy(EnFsn* this, GlobalContext* globalCtx); +typedef enum { + /* 0 */ ENFSN_CUTSCENESTATE_STOPPED, + /* 1 */ ENFSN_CUTSCENESTATE_WAITING, + /* 2 */ ENFSN_CUTSCENESTATE_PLAYING +} EnFsnCutsceneState; + +typedef enum { + /* 00 */ FSN_ANIMATION_IDLE, + /* 01 */ FSN_ANIMATION_SCRATCH_BACK, + /* 02 */ FSN_ANIMATION_TURN_AROUND_FORWARD, + /* 03 */ FSN_ANIMATION_TURN_AROUND_REVERSE, + /* 04 */ FSN_ANIMATION_HANDS_ON_COUNTER_START, + /* 05 */ FSN_ANIMATION_HANDS_ON_COUNTER_LOOP, + /* 06 */ FSN_ANIMATION_HAND_ON_FACE_START, + /* 07 */ FSN_ANIMATION_HAND_ON_FACE_LOOP, + /* 08 */ FSN_ANIMATION_LEAN_FORWARD_START, + /* 09 */ FSN_ANIMATION_LEAN_FORWARD_LOOP, + /* 10 */ FSN_ANIMATION_SLAM_COUNTER_START, + /* 11 */ FSN_ANIMATION_SLAM_COUNTER_LOOP, + /* 12 */ FSN_ANIMATION_MAKE_OFFER, + /* 13 */ FSN_ANIMATION_MAX +} FsnAnimation; + const ActorInit En_Fsn_InitVars = { ACTOR_EN_FSN, ACTORCAT_NPC, @@ -60,19 +82,19 @@ const ActorInit En_Fsn_InitVars = { }; static AnimationInfoS sAnimations[] = { - { &object_fsn_Anim_012C34, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_fsn_Anim_0131FC, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_fsn_Anim_00C58C, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_fsn_Anim_00C58C, -1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_fsn_Anim_00E3EC, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_fsn_Anim_00F00C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_fsn_Anim_00CB3C, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_fsn_Anim_00D354, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_fsn_Anim_0138B0, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_fsn_Anim_01430C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_fsn_Anim_00B9D8, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_fsn_Anim_00C26C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_fsn_Anim_00DE34, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gFsnIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gFsnScratchBackAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gFsnTurnAroundAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gFsnTurnAroundAnim, -1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gFsnHandsOnCounterStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gFsnHandsOnCounterLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gFsnHandOnFaceStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gFsnHandOnFaceLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gFsnLeanForwardStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gFsnLeanForwardLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gFsnSlamCounterStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gFsnSlamCounterLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gFsnMakeOfferAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, }; static ColliderCylinderInit sCylinderInit = { @@ -131,7 +153,7 @@ u16 EnFsn_GetWelcome(GlobalContext* globalCtx) { void EnFsn_HandleConversationBackroom(EnFsn* this, GlobalContext* globalCtx) { switch (this->textId) { case 0: - if (!(gSaveContext.weekEventReg[80] & 0x10)) { + if (!(gSaveContext.save.weekEventReg[80] & 0x10)) { this->textId = 0x29E0; break; } else { @@ -144,7 +166,7 @@ void EnFsn_HandleConversationBackroom(EnFsn* this, GlobalContext* globalCtx) { this->flags |= ENFSN_GIVE_ITEM; this->flags |= ENFSN_GAVE_LETTER_TO_MAMA; this->getItemId = GI_LETTER_TO_MAMA; - gSaveContext.weekEventReg[80] |= 0x10; + gSaveContext.save.weekEventReg[80] |= 0x10; this->textId = 0x29F1; break; } else { @@ -164,7 +186,7 @@ void EnFsn_HandleConversationBackroom(EnFsn* this, GlobalContext* globalCtx) { this->flags |= ENFSN_GIVE_ITEM; this->flags |= ENFSN_GAVE_LETTER_TO_MAMA; this->getItemId = GI_LETTER_TO_MAMA; - gSaveContext.weekEventReg[80] |= 0x10; + gSaveContext.save.weekEventReg[80] |= 0x10; this->textId = 0x29F1; break; case 0x29F1: @@ -187,7 +209,8 @@ void EnFsn_HandleConversationBackroom(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_HandleSetupResumeInteraction(EnFsn* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx) && this->cutsceneState == 0) { + if (Message_GetState(&globalCtx->msgCtx) == 6 && Message_ShouldAdvance(globalCtx) && + this->cutsceneState == ENFSN_CUTSCENESTATE_STOPPED) { Actor_ProcessTalkRequest(&this->actor, &globalCtx->state); func_800B85E0(&this->actor, globalCtx, 400.0f, EXCH_ITEM_MINUS1); if (ENFSN_IS_SHOP(&this->actor)) { @@ -205,19 +228,19 @@ void EnFsn_UpdateCollider(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_HandleLookToShopkeeperBuyingCutscene(EnFsn* this) { - if (this->cutsceneState == 2 && this->lookToShopkeeperBuyingCutscene != this->cutscene && - this->actor.textId == 0x29CE) { + if ((this->cutsceneState == ENFSN_CUTSCENESTATE_PLAYING) && + (this->lookToShopkeeperBuyingCutscene != this->cutscene) && (this->actor.textId == 0x29CE)) { ActorCutscene_Stop(this->cutscene); if (ActorCutscene_GetCurrentIndex() == 0x7C) { ActorCutscene_Stop(0x7C); } this->cutscene = this->lookToShopkeeperBuyingCutscene; ActorCutscene_SetIntentToPlay(this->cutscene); - this->cutsceneState = 1; - } else if (this->cutsceneState == 1) { + this->cutsceneState = ENFSN_CUTSCENESTATE_WAITING; + } else if (this->cutsceneState == ENFSN_CUTSCENESTATE_WAITING) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { ActorCutscene_Start(this->cutscene, &this->actor); - this->cutsceneState = 2; + this->cutsceneState = ENFSN_CUTSCENESTATE_PLAYING; } else { ActorCutscene_SetIntentToPlay(this->cutscene); } @@ -278,8 +301,8 @@ void EnFsn_CursorLeftRight(EnFsn* this) { } s16 EnFsn_GetThirdDayItemId(void) { - if (!(gSaveContext.weekEventReg[33] & 4) && CURRENT_DAY == 3) { - if (!(gSaveContext.weekEventReg[33] & 8) && !(gSaveContext.weekEventReg[79] & 0x40)) { + if (!(gSaveContext.save.weekEventReg[33] & 4) && CURRENT_DAY == 3) { + if (!(gSaveContext.save.weekEventReg[33] & 8) && !(gSaveContext.save.weekEventReg[79] & 0x40)) { return SI_BOMB_BAG_30_1; } return SI_MASK_ALL_NIGHT; @@ -305,22 +328,23 @@ s16 EnFsn_GetStolenItemId(u32 stolenItem) { s32 EnFsn_HasItemsToSell(void) { if (CURRENT_DAY != 3) { - if (((gSaveContext.stolenItems & 0xFF000000) >> 0x18) || ((gSaveContext.stolenItems & 0xFF0000) >> 0x10)) { - return true; - } - return false; - } else { - if (((gSaveContext.stolenItems & 0xFF000000) >> 0x18) || ((gSaveContext.stolenItems & 0xFF0000) >> 0x10) || - !(gSaveContext.weekEventReg[33] & 4)) { + if ((STOLEN_ITEM_1 != STOLEN_ITEM_NONE) || (STOLEN_ITEM_2 != STOLEN_ITEM_NONE)) { return true; } return false; } + + if ((STOLEN_ITEM_1 != STOLEN_ITEM_NONE) || (STOLEN_ITEM_2 != STOLEN_ITEM_NONE) || + !(gSaveContext.save.weekEventReg[33] & 4)) { + return true; + } + + return false; } void EnFsn_GetShopItemIds(EnFsn* this) { - u32 stolenItem1 = (gSaveContext.stolenItems & 0xFF000000) >> 0x18; - u32 stolenItem2 = (gSaveContext.stolenItems & 0xFF0000) >> 0x10; + u32 stolenItem1 = STOLEN_ITEM_1; + u32 stolenItem2 = STOLEN_ITEM_2; s16 itemId; this->stolenItem1 = this->stolenItem2 = 0; @@ -362,9 +386,9 @@ void EnFsn_SpawnShopItems(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_EndInteraction(EnFsn* this, GlobalContext* globalCtx) { - if (this->cutsceneState == 2) { + if (this->cutsceneState == ENFSN_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); - this->cutsceneState = 0; + this->cutsceneState = ENFSN_CUTSCENESTATE_STOPPED; } Actor_ProcessTalkRequest(&this->actor, &globalCtx->state); globalCtx->msgCtx.msgMode = 0x43; @@ -400,14 +424,14 @@ s32 EnFsn_TestCancelOption(EnFsn* this, GlobalContext* globalCtx, Input* input) } void EnFsn_UpdateCursorPos(EnFsn* this, GlobalContext* globalCtx) { - s16 sp2E; - s16 sp2C; + s16 x; + s16 y; f32 xOffset = 0.0f; f32 yOffset = 17.0f; - Actor_GetScreenPos(globalCtx, &this->items[this->cursorIdx]->actor, &sp2E, &sp2C); - this->cursorPos.x = sp2E + xOffset; - this->cursorPos.y = sp2C + yOffset; + Actor_GetScreenPos(globalCtx, &this->items[this->cursorIdx]->actor, &x, &y); + this->cursorPos.x = x + xOffset; + this->cursorPos.y = y + yOffset; this->cursorPos.z = 1.2f; } @@ -417,9 +441,9 @@ s32 EnFsn_FacingShopkeeperDialogResult(EnFsn* this, GlobalContext* globalCtx) { func_8019F208(); if (CURRENT_DAY != 3) { this->actor.textId = 0x29FB; - } else if (gSaveContext.weekEventReg[33] & 4) { + } else if (gSaveContext.save.weekEventReg[33] & 4) { this->actor.textId = 0x29FF; - } else if (!(gSaveContext.weekEventReg[33] & 8) && !(gSaveContext.weekEventReg[79] & 0x40)) { + } else if (!(gSaveContext.save.weekEventReg[33] & 8) && !(gSaveContext.save.weekEventReg[79] & 0x40)) { this->actor.textId = 0x29D7; } else { this->actor.textId = 0x29D8; @@ -579,8 +603,7 @@ void EnFsn_UpdateCursorAnim(EnFsn* this) { void EnFsn_UpdateStickDirectionPromptAnim(EnFsn* this) { f32 arrowAnimTween = this->arrowAnimTween; f32 stickAnimTween = this->stickAnimTween; - s32 maxColor = 255; - f32 tmp; + s32 maxColor = 255; // POSSIBLY FAKE if (this->arrowAnimState == 0) { arrowAnimTween += 0.05f; @@ -607,54 +630,51 @@ void EnFsn_UpdateStickDirectionPromptAnim(EnFsn* this) { stickAnimTween = 0.0f; this->stickAnimState = 0; } - - tmp = 155.0f * arrowAnimTween; - this->stickAnimTween = stickAnimTween; this->stickLeftPrompt.arrowColor.r = COL_CHAN_MIX(255, 155.0f, arrowAnimTween); this->stickLeftPrompt.arrowColor.g = COL_CHAN_MIX(maxColor, 155.0f, arrowAnimTween); - this->stickLeftPrompt.arrowColor.b = COL_CHAN_MIX(0, -100, arrowAnimTween); + this->stickLeftPrompt.arrowColor.b = COL_CHAN_MIX(0, -100.0f, arrowAnimTween); this->stickLeftPrompt.arrowColor.a = COL_CHAN_MIX(200, 50.0f, arrowAnimTween); - this->stickRightPrompt.arrowColor.r = (maxColor - ((s32)tmp)) & 0xFF; - this->stickRightPrompt.arrowColor.g = (255 - ((s32)tmp)) & 0xFF; + this->stickRightPrompt.arrowTexX = 290.0f; + + this->stickRightPrompt.arrowColor.r = COL_CHAN_MIX(maxColor, 155.0f, arrowAnimTween); + this->stickRightPrompt.arrowColor.g = COL_CHAN_MIX(255, 155.0f, arrowAnimTween); this->stickRightPrompt.arrowColor.b = COL_CHAN_MIX(0, -100.0f, arrowAnimTween); this->stickRightPrompt.arrowColor.a = COL_CHAN_MIX(200, 50.0f, arrowAnimTween); - this->stickRightPrompt.arrowTexX = 290.0f; this->stickLeftPrompt.arrowTexX = 33.0f; this->stickRightPrompt.stickTexX = 274.0f; this->stickRightPrompt.stickTexX += 8.0f * stickAnimTween; + this->stickLeftPrompt.stickTexX = 49.0f; this->stickLeftPrompt.stickTexX -= 8.0f * stickAnimTween; - this->stickLeftPrompt.arrowTexY = this->stickRightPrompt.arrowTexY = 91.0f; - this->stickLeftPrompt.stickTexY = this->stickRightPrompt.stickTexY = 95.0f; + this->stickRightPrompt.arrowTexY = 91.0f; + this->stickLeftPrompt.arrowTexY = 91.0f; + + this->stickRightPrompt.stickTexY = 95.0f; + this->stickLeftPrompt.stickTexY = 95.0f; } void EnFsn_InitShop(EnFsn* this, GlobalContext* globalCtx) { - EnFsn* this2; - s32 maxColor = 255; - if (EnFsn_HasItemsToSell()) { EnFsn_SpawnShopItems(this, globalCtx); - this2 = this; - this2->cursorPos.x = 100.0f; - this2->cursorPos.y = 100.0f; - this2->stickAccumY = 0; - this2->stickAccumX = 0; + this->cursorPos.y = this->cursorPos.x = 100.0f; + this->stickAccumY = 0; + this->stickAccumX = 0; this->cursorPos.z = 1.2f; this->cursorColor.r = 0; this->cursorColor.g = 80; - this->cursorColor.b = maxColor; - this->cursorColor.a = maxColor; + this->cursorColor.b = 255; + this->cursorColor.a = 255; + this->cursorAnimTween = 0.0f; this->cursorAnimState = 0; this->drawCursor = 0; - this->cursorAnimTween = 0.0f; this->stickLeftPrompt.stickColor.r = 200; this->stickLeftPrompt.stickColor.g = 200; @@ -662,8 +682,8 @@ void EnFsn_InitShop(EnFsn* this, GlobalContext* globalCtx) { this->stickLeftPrompt.stickColor.a = 180; this->stickLeftPrompt.stickTexX = 49.0f; this->stickLeftPrompt.stickTexY = 95.0f; - this->stickLeftPrompt.arrowColor.r = maxColor; - this->stickLeftPrompt.arrowColor.g = maxColor; + this->stickLeftPrompt.arrowColor.r = 255; + this->stickLeftPrompt.arrowColor.g = 255; this->stickLeftPrompt.arrowColor.b = 0; this->stickLeftPrompt.arrowColor.a = 200; this->stickLeftPrompt.arrowTexX = 33.0f; @@ -677,7 +697,7 @@ void EnFsn_InitShop(EnFsn* this, GlobalContext* globalCtx) { this->stickRightPrompt.stickColor.a = 180; this->stickRightPrompt.stickTexX = 274.0f; this->stickRightPrompt.stickTexY = 95.0f; - this->stickRightPrompt.arrowColor.r = maxColor; + this->stickRightPrompt.arrowColor.r = 255; this->stickRightPrompt.arrowColor.g = 0; this->stickRightPrompt.arrowColor.b = 0; this->stickRightPrompt.arrowColor.a = 200; @@ -691,21 +711,21 @@ void EnFsn_InitShop(EnFsn* this, GlobalContext* globalCtx) { this->stickAnimTween = this->arrowAnimTween = 0.0f; } this->blinkTimer = 20; - this->animationIdx = 4; + this->animationIndex = FSN_ANIMATION_HANDS_ON_COUNTER_START; this->eyeTextureIdx = 0; - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIdx); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); this->actionFunc = EnFsn_Idle; } void EnFsn_Idle(EnFsn* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (this->animationIdx == 4) { + if (this->animationIndex == FSN_ANIMATION_HANDS_ON_COUNTER_START) { s16 curFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIdx].animation); + s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); if (curFrame == frameCount) { - this->animationIdx = 5; - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIdx); + this->animationIndex = FSN_ANIMATION_HANDS_ON_COUNTER_LOOP; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); } return; } @@ -716,13 +736,13 @@ void EnFsn_Idle(EnFsn* this, GlobalContext* globalCtx) { } if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - if (this->cutsceneState == 0) { + if (this->cutsceneState == ENFSN_CUTSCENESTATE_STOPPED) { if (ActorCutscene_GetCurrentIndex() == 0x7C) { ActorCutscene_Stop(0x7C); } this->cutscene = this->lookToShopkeeperCutscene; ActorCutscene_SetIntentToPlay(this->cutscene); - this->cutsceneState = 1; + this->cutsceneState = ENFSN_CUTSCENESTATE_WAITING; } this->actor.textId = EnFsn_GetWelcome(globalCtx); Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); @@ -738,29 +758,29 @@ void EnFsn_Idle(EnFsn* this, GlobalContext* globalCtx) { void EnFsn_Haggle(EnFsn* this, GlobalContext* globalCtx) { s16 curFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIdx].animation); + s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); if (this->flags & ENFSN_ANGRY) { this->flags &= ~ENFSN_ANGRY; - this->animationIdx = 11; - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIdx); + this->animationIndex = FSN_ANIMATION_SLAM_COUNTER_LOOP; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); } else { - if (this->animationIdx == 11 && Animation_OnFrame(&this->skelAnime, 18.0f)) { + if (this->animationIndex == FSN_ANIMATION_SLAM_COUNTER_LOOP && Animation_OnFrame(&this->skelAnime, 18.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HANKO); } if (this->flags & ENFSN_CALM_DOWN) { this->flags &= ~ENFSN_CALM_DOWN; - this->animationIdx = 5; - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIdx); + this->animationIndex = FSN_ANIMATION_HANDS_ON_COUNTER_LOOP; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); } else if (this->flags & ENFSN_OFFER_FINAL_PRICE) { this->flags &= ~ENFSN_OFFER_FINAL_PRICE; - this->animationIdx = 12; - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIdx); + this->animationIndex = FSN_ANIMATION_MAKE_OFFER; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); } else { - if (this->animationIdx == 12) { + if (this->animationIndex == FSN_ANIMATION_MAKE_OFFER) { if (curFrame == frameCount) { - this->animationIdx = 5; - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIdx); + this->animationIndex = FSN_ANIMATION_HANDS_ON_COUNTER_LOOP; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); } else { if (Animation_OnFrame(&this->skelAnime, 28.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HANKO); @@ -776,10 +796,10 @@ void EnFsn_Haggle(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_BeginInteraction(EnFsn* this, GlobalContext* globalCtx) { - if (this->cutsceneState == 1) { + if (this->cutsceneState == ENFSN_CUTSCENESTATE_WAITING) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); - this->cutsceneState = 2; + this->cutsceneState = ENFSN_CUTSCENESTATE_PLAYING; if (Player_GetMask(globalCtx) == PLAYER_MASK_NONE) { func_8011552C(globalCtx, 16); if (EnFsn_HasItemsToSell()) { @@ -802,7 +822,7 @@ void EnFsn_StartBuying(EnFsn* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); EnFsn_HandleLookToShopkeeperBuyingCutscene(this); - if (talkState == 5 && func_80147624(globalCtx)) { + if (talkState == 5 && Message_ShouldAdvance(globalCtx)) { switch (this->actor.textId) { case 0x29CC: this->actor.textId = 0x29CD; @@ -830,7 +850,7 @@ void EnFsn_AskBuyOrSell(EnFsn* this, GlobalContext* globalCtx) { u8 talkState = Message_GetState(&globalCtx->msgCtx); if (talkState == 5) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->actor.textId) { case 0x29CC: if (CURRENT_DAY != 3) { @@ -841,9 +861,10 @@ void EnFsn_AskBuyOrSell(EnFsn* this, GlobalContext* globalCtx) { Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); break; case 0x29D2: - if (gSaveContext.weekEventReg[33] & 4) { + if (gSaveContext.save.weekEventReg[33] & 4) { this->actor.textId = 0x2A01; - } else if (!(gSaveContext.weekEventReg[33] & 8) && !(gSaveContext.weekEventReg[79] & 0x40)) { + } else if (!(gSaveContext.save.weekEventReg[33] & 8) && + !(gSaveContext.save.weekEventReg[79] & 0x40)) { this->actor.textId = 0x29D3; } else { this->actor.textId = 0x29D4; @@ -861,14 +882,13 @@ void EnFsn_AskBuyOrSell(EnFsn* this, GlobalContext* globalCtx) { } } else if (talkState == 4) { func_8011552C(globalCtx, 6); - if (!EnFsn_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx)) && func_80147624(globalCtx)) { - u32 trueTmp = true; + if (!EnFsn_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx)) && Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_8019F208(); - this->isSelling = trueTmp; + this->isSelling = true; this->stickLeftPrompt.isEnabled = false; - this->stickRightPrompt.isEnabled = trueTmp; + this->stickRightPrompt.isEnabled = true; this->actor.textId = 0x29D6; Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); this->actionFunc = EnFsn_FaceShopkeeperSelling; @@ -905,7 +925,7 @@ void EnFsn_DeterminePrice(EnFsn* this, GlobalContext* globalCtx) { if (player->heldItemButton == 0) { buttonItem = CUR_FORM_EQUIP(player->heldItemButton); } else { - buttonItem = gSaveContext.equips.buttonItems[0][player->heldItemButton]; + buttonItem = gSaveContext.save.equips.buttonItems[0][player->heldItemButton]; } this->price = (buttonItem < ITEM_MOON_TEAR) ? gItemPrices[buttonItem] : 0; if (this->price > 0) { @@ -935,15 +955,15 @@ void EnFsn_MakeOffer(EnFsn* this, GlobalContext* globalCtx) { u8 talkState = Message_GetState(&globalCtx->msgCtx); Player* player = GET_PLAYER(globalCtx); - if (talkState == 4 && func_80147624(globalCtx)) { + if (talkState == 4 && Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_8019F208(); globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; - if (this->cutsceneState == 2) { + if (this->cutsceneState == ENFSN_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); - this->cutsceneState = 0; + this->cutsceneState = ENFSN_CUTSCENESTATE_STOPPED; } switch (this->price) { case 5: @@ -975,7 +995,7 @@ void EnFsn_MakeOffer(EnFsn* this, GlobalContext* globalCtx) { void EnFsn_GiveItem(EnFsn* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { - if (this->isSelling == true && this->items[this->cursorIdx]->getItemId == GI_MASK_ALL_NIGHT) { + if ((this->isSelling == true) && (this->items[this->cursorIdx]->getItemId == GI_MASK_ALL_NIGHT)) { func_80151BB4(globalCtx, 45); func_80151BB4(globalCtx, 3); } @@ -1027,10 +1047,10 @@ void EnFsn_ResumeInteraction(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_ResumeShoppingInteraction(EnFsn* this, GlobalContext* globalCtx) { - if (this->cutsceneState == 0) { + if (this->cutsceneState == ENFSN_CUTSCENESTATE_STOPPED) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); - this->cutsceneState = 2; + this->cutsceneState = ENFSN_CUTSCENESTATE_PLAYING; if (!this->isSelling) { this->actionFunc = EnFsn_AskCanBuyMore; } else if (this->actor.textId != 0x29D6) { @@ -1052,18 +1072,18 @@ void EnFsn_ResumeShoppingInteraction(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_LookToShelf(EnFsn* this, GlobalContext* globalCtx) { - if (this->cutsceneState == 2) { + if (this->cutsceneState == ENFSN_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); if (ActorCutscene_GetCurrentIndex() == 0x7C) { ActorCutscene_Stop(0x7C); } this->cutscene = this->lookToShelfCutscene; ActorCutscene_SetIntentToPlay(this->cutscene); - this->cutsceneState = 1; - } else if (this->cutsceneState == 1) { + this->cutsceneState = ENFSN_CUTSCENESTATE_WAITING; + } else if (this->cutsceneState == ENFSN_CUTSCENESTATE_WAITING) { if (ActorCutscene_GetCanPlayNext(this->cutscene) != 0) { ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); - this->cutsceneState = 2; + this->cutsceneState = ENFSN_CUTSCENESTATE_PLAYING; EnFsn_UpdateCursorPos(this, globalCtx); this->actionFunc = EnFsn_BrowseShelf; func_80151938(globalCtx, this->items[this->cursorIdx]->actor.textId); @@ -1100,18 +1120,18 @@ void EnFsn_BrowseShelf(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_LookToShopkeeperFromShelf(EnFsn* this, GlobalContext* globalCtx) { - if (this->cutsceneState == 2) { + if (this->cutsceneState == ENFSN_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); if (ActorCutscene_GetCurrentIndex() == 0x7C) { ActorCutscene_Stop(0x7C); } this->cutscene = this->lookToShopkeeperFromShelfCutscene; ActorCutscene_SetIntentToPlay(this->cutscene); - this->cutsceneState = 1; - } else if (this->cutsceneState == 1) { + this->cutsceneState = ENFSN_CUTSCENESTATE_WAITING; + } else if (this->cutsceneState == ENFSN_CUTSCENESTATE_WAITING) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); - this->cutsceneState = 2; + this->cutsceneState = ENFSN_CUTSCENESTATE_PLAYING; this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = true; this->actor.textId = 0x29D6; @@ -1129,11 +1149,11 @@ void EnFsn_HandleCanPlayerBuyItem(EnFsn* this, GlobalContext* globalCtx) { switch (item->canBuyFunc(globalCtx, item)) { case CANBUY_RESULT_SUCCESS_2: func_8019F208(); - gSaveContext.weekEventReg[33] |= 4; + gSaveContext.save.weekEventReg[33] |= 4; case CANBUY_RESULT_SUCCESS_1: - if (this->cutsceneState == 2) { + if (this->cutsceneState == ENFSN_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); - this->cutsceneState = 0; + this->cutsceneState = ENFSN_CUTSCENESTATE_STOPPED; } func_8019F208(); item = this->items[this->cursorIdx]; @@ -1147,9 +1167,9 @@ void EnFsn_HandleCanPlayerBuyItem(EnFsn* this, GlobalContext* globalCtx) { item = this->items[this->cursorIdx]; item->boughtFunc(globalCtx, item); if (this->stolenItem1 == this->cursorIdx) { - gSaveContext.stolenItems &= ~0xFF000000; + SET_STOLEN_ITEM_1(STOLEN_ITEM_NONE); } else if (this->stolenItem2 == this->cursorIdx) { - gSaveContext.stolenItems &= ~0xFF0000; + SET_STOLEN_ITEM_2(STOLEN_ITEM_NONE); } this->numSellingItems--; this->itemIds[this->cursorIdx] = -1; @@ -1171,7 +1191,7 @@ void EnFsn_HandleCanPlayerBuyItem(EnFsn* this, GlobalContext* globalCtx) { void EnFsn_SetupEndInteraction(EnFsn* this, GlobalContext* globalCtx) { u8 talkState = Message_GetState(&globalCtx->msgCtx); - if ((talkState == 5 || talkState == 6) && func_80147624(globalCtx)) { + if ((talkState == 5 || talkState == 6) && Message_ShouldAdvance(globalCtx)) { if (CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { if (globalCtx->msgCtx.unk120B1 == 0) { EnFsn_EndInteraction(this, globalCtx); @@ -1190,7 +1210,7 @@ void EnFsn_SelectItem(EnFsn* this, GlobalContext* globalCtx) { if (EnFsn_TakeItemOffShelf(this) && talkState == 4) { func_8011552C(globalCtx, 6); - if (!EnFsn_TestCancelOption(this, globalCtx, CONTROLLER1(globalCtx)) && func_80147624(globalCtx)) { + if (!EnFsn_TestCancelOption(this, globalCtx, CONTROLLER1(globalCtx)) && Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: EnFsn_HandleCanPlayerBuyItem(this, globalCtx); @@ -1205,7 +1225,7 @@ void EnFsn_SelectItem(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_PlayerCannotBuy(EnFsn* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { this->actionFunc = this->tmpActionFunc; func_80151938(globalCtx, this->items[this->cursorIdx]->actor.textId); } @@ -1214,10 +1234,10 @@ void EnFsn_PlayerCannotBuy(EnFsn* this, GlobalContext* globalCtx) { void EnFsn_AskCanBuyMore(EnFsn* this, GlobalContext* globalCtx) { u8 talkState = Message_GetState(&globalCtx->msgCtx); - if (this->cutsceneState == 0) { + if (this->cutsceneState == ENFSN_CUTSCENESTATE_STOPPED) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); - this->cutsceneState = 2; + this->cutsceneState = ENFSN_CUTSCENESTATE_PLAYING; } else { if (ActorCutscene_GetCurrentIndex() == 0x7C) { ActorCutscene_Stop(0x7C); @@ -1227,7 +1247,7 @@ void EnFsn_AskCanBuyMore(EnFsn* this, GlobalContext* globalCtx) { } } if (talkState == 4) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_8019F208(); @@ -1243,7 +1263,7 @@ void EnFsn_AskCanBuyMore(EnFsn* this, GlobalContext* globalCtx) { break; } } - } else if ((talkState == 5 || talkState == 6) && func_80147624(globalCtx)) { + } else if ((talkState == 5 || talkState == 6) && Message_ShouldAdvance(globalCtx)) { if (CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { if (globalCtx->msgCtx.unk120B1 == 0) { EnFsn_EndInteraction(this, globalCtx); @@ -1260,10 +1280,10 @@ void EnFsn_AskCanBuyMore(EnFsn* this, GlobalContext* globalCtx) { void EnFsn_AskCanBuyAterRunningOutOfItems(EnFsn* this, GlobalContext* globalCtx) { u8 talkState = Message_GetState(&globalCtx->msgCtx); - if (this->cutsceneState == 0) { + if (this->cutsceneState == ENFSN_CUTSCENESTATE_STOPPED) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); - this->cutsceneState = 2; + this->cutsceneState = ENFSN_CUTSCENESTATE_PLAYING; } else { if (ActorCutscene_GetCurrentIndex() == 0x7C) { ActorCutscene_Stop(0x7C); @@ -1273,7 +1293,7 @@ void EnFsn_AskCanBuyAterRunningOutOfItems(EnFsn* this, GlobalContext* globalCtx) } } if (talkState == 4) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_8019F208(); @@ -1290,7 +1310,7 @@ void EnFsn_AskCanBuyAterRunningOutOfItems(EnFsn* this, GlobalContext* globalCtx) break; } } - } else if ((talkState == 5 || talkState == 6) && func_80147624(globalCtx)) { + } else if ((talkState == 5 || talkState == 6) && Message_ShouldAdvance(globalCtx)) { if (CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { if (globalCtx->msgCtx.unk120B1 == 0) { EnFsn_EndInteraction(this, globalCtx); @@ -1311,7 +1331,7 @@ void EnFsn_FaceShopkeeperSelling(EnFsn* this, GlobalContext* globalCtx) { if (talkState == 4) { func_8011552C(globalCtx, 6); if (!EnFsn_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx)) && - (!func_80147624(globalCtx) || !EnFsn_FacingShopkeeperDialogResult(this, globalCtx)) && + (!Message_ShouldAdvance(globalCtx) || !EnFsn_FacingShopkeeperDialogResult(this, globalCtx)) && this->stickAccumX > 0) { cursorIdx = EnFsn_SetCursorIndexFromNeutral(this); if (cursorIdx != CURSOR_INVALID) { @@ -1322,7 +1342,7 @@ void EnFsn_FaceShopkeeperSelling(EnFsn* this, GlobalContext* globalCtx) { play_sound(NA_SE_SY_CURSOR); } } - } else if (talkState == 5 && func_80147624(globalCtx)) { + } else if (talkState == 5 && Message_ShouldAdvance(globalCtx)) { this->actor.textId = 0x29D6; Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); if (globalCtx) {} @@ -1330,7 +1350,7 @@ void EnFsn_FaceShopkeeperSelling(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_SetupEndInteractionImmediately(EnFsn* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { EnFsn_EndInteraction(this, globalCtx); } } @@ -1346,7 +1366,7 @@ void EnFsn_IdleBackroom(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_ConverseBackroom(EnFsn* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { if (this->flags & ENFSN_END_CONVERSATION) { this->flags &= ~ENFSN_END_CONVERSATION; globalCtx->msgCtx.msgMode = 0x43; @@ -1386,19 +1406,19 @@ void EnFsn_Blink(EnFsn* this) { } void EnFsn_Init(Actor* thisx, GlobalContext* globalCtx) { - EnFsn* this = THIS; s32 pad; + EnFsn* this = THIS; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_fsn_Skel_013320, &object_fsn_Anim_012C34, this->jointTable, - this->morphTable, 19); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gFsnSkel, &gFsnIdleAnim, this->jointTable, this->morphTable, + FSN_LIMB_MAX + 1); if (ENFSN_IS_SHOP(&this->actor)) { this->actor.shape.rot.y = BINANG_ROT180(this->actor.shape.rot.y); this->actor.flags &= ~ACTOR_FLAG_1; EnFsn_GetCutscenes(this); EnFsn_InitShop(this, globalCtx); } else { - if ((gSaveContext.weekEventReg[33] & 8) || (gSaveContext.weekEventReg[79] & 0x40)) { + if ((gSaveContext.save.weekEventReg[33] & 8) || (gSaveContext.save.weekEventReg[79] & 0x40)) { Actor_MarkForDeath(&this->actor); return; } @@ -1408,8 +1428,8 @@ void EnFsn_Init(Actor* thisx, GlobalContext* globalCtx) { this->eyeTextureIdx = 0; this->actor.flags |= ACTOR_FLAG_1; this->actor.targetMode = 0; - this->animationIdx = 0; - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIdx); + this->animationIndex = FSN_ANIMATION_IDLE; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); this->actionFunc = EnFsn_IdleBackroom; } } @@ -1441,7 +1461,10 @@ void EnFsn_Update(Actor* thisx, GlobalContext* globalCtx) { } void EnFsn_DrawCursor(EnFsn* this, GlobalContext* globalCtx, f32 x, f32 y, f32 z, u8 drawCursor) { - s32 ulx, uly, lrx, lry; + s32 ulx; + s32 uly; + s32 lrx; + s32 lry; f32 w; s32 dsdx; s32 pad; @@ -1451,8 +1474,8 @@ void EnFsn_DrawCursor(EnFsn* this, GlobalContext* globalCtx, f32 x, f32 y, f32 z func_8012C654(globalCtx->state.gfxCtx); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, this->cursorColor.r, this->cursorColor.g, this->cursorColor.b, this->cursorColor.a); - gDPLoadTextureBlock_4b(OVERLAY_DISP++, gameplay_keep_Tex_01F740, G_IM_FMT_IA, 16, 16, 0, - G_TX_MIRROR | G_TX_WRAP, G_TX_MIRROR | G_TX_WRAP, 4, 4, G_TX_NOLOD, G_TX_NOLOD); + gDPLoadTextureBlock_4b(OVERLAY_DISP++, gSelectionCursorTex, G_IM_FMT_IA, 16, 16, 0, G_TX_MIRROR | G_TX_WRAP, + G_TX_MIRROR | G_TX_WRAP, 4, 4, G_TX_NOLOD, G_TX_NOLOD); w = 16.0f * z; ulx = (x - w) * 4.0f; uly = (y - w + -12.0f) * 4.0f; @@ -1467,9 +1490,14 @@ void EnFsn_DrawCursor(EnFsn* this, GlobalContext* globalCtx, f32 x, f32 y, f32 z void EnFsn_DrawTextRec(GlobalContext* globalCtx, s32 r, s32 g, s32 b, s32 a, f32 x, f32 y, f32 z, s32 s, s32 t, f32 dx, f32 dy) { f32 unk; - s32 ulx, uly, lrx, lry; - f32 w, h; - s32 dsdx, dtdy; + s32 ulx; + s32 uly; + s32 lrx; + s32 lry; + f32 w; + f32 h; + s32 dsdx; + s32 dtdy; OPEN_DISPS(globalCtx->state.gfxCtx); gDPPipeSync(OVERLAY_DISP++); @@ -1499,15 +1527,9 @@ void EnFsn_DrawStickDirectionPrompts(EnFsn* this, GlobalContext* globalCtx) { if (drawStickRightPrompt || drawStickLeftPrompt) { func_8012C654(globalCtx->state.gfxCtx); gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); - gDPSetTextureImage(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 1, gameplay_keep_Tex_01F8C0); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 0, 0x0000, G_TX_LOADTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPLoadSync(OVERLAY_DISP++); - gDPLoadBlock(OVERLAY_DISP++, G_TX_LOADTILE, 0, 0, 191, 1024); - gDPPipeSync(OVERLAY_DISP++); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_8b, 2, 0x0000, G_TX_RENDERTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPSetTileSize(OVERLAY_DISP++, G_TX_RENDERTILE, 0, 0, 15 * 4, 23 * 4); + gDPLoadTextureBlock(OVERLAY_DISP++, gArrowCursorTex, G_IM_FMT_IA, G_IM_SIZ_8b, 16, 24, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); if (drawStickRightPrompt) { EnFsn_DrawTextRec(globalCtx, this->stickLeftPrompt.arrowColor.r, this->stickLeftPrompt.arrowColor.g, this->stickLeftPrompt.arrowColor.b, this->stickLeftPrompt.arrowColor.a, @@ -1520,15 +1542,9 @@ void EnFsn_DrawStickDirectionPrompts(EnFsn* this, GlobalContext* globalCtx) { this->stickRightPrompt.arrowTexX, this->stickRightPrompt.arrowTexY, this->stickRightPrompt.texZ, 0, 0, 1.0f, 1.0f); } - gDPSetTextureImage(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 1, gameplay_keep_Tex_01F7C0); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 0, 0x0000, G_TX_LOADTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPLoadSync(OVERLAY_DISP++); - gDPLoadBlock(OVERLAY_DISP++, G_TX_LOADTILE, 0, 0, 127, 1024); - gDPPipeSync(OVERLAY_DISP++); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_8b, 2, 0x0000, G_TX_RENDERTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPSetTileSize(OVERLAY_DISP++, G_TX_RENDERTILE, 0, 0, 15 * 4, 15 * 4); + gDPLoadTextureBlock(OVERLAY_DISP++, gControlStickTex, G_IM_FMT_IA, G_IM_SIZ_8b, 16, 16, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); if (drawStickRightPrompt) { EnFsn_DrawTextRec(globalCtx, this->stickLeftPrompt.stickColor.r, this->stickLeftPrompt.stickColor.g, this->stickLeftPrompt.stickColor.b, this->stickLeftPrompt.stickColor.a, @@ -1547,21 +1563,20 @@ void EnFsn_DrawStickDirectionPrompts(EnFsn* this, GlobalContext* globalCtx) { s32 EnFsn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnFsn* this = THIS; - s16 tmp; s32 limbRotTableIdx; - if (limbIndex == 16) { + if (limbIndex == FSN_LIMB_HEAD) { Matrix_InsertXRotation_s(this->headRot.y, MTXMODE_APPLY); } if (ENFSN_IS_BACKROOM(&this->actor)) { switch (limbIndex) { - case 8: + case FSN_LIMB_TORSO: limbRotTableIdx = 0; break; - case 11: + case FSN_LIMB_LEFT_HAND: limbRotTableIdx = 1; break; - case 16: + case FSN_LIMB_HEAD: limbRotTableIdx = 2; break; default: @@ -1569,13 +1584,11 @@ s32 EnFsn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, break; } if (limbRotTableIdx < 9) { - tmp = (s32)(Math_SinS(this->limbRotYTable[limbRotTableIdx]) * 200.0f); - rot->y += tmp; - tmp = (s32)(Math_CosS(this->limbRotZTable[limbRotTableIdx]) * 200.0f); - rot->z += tmp; + rot->y += (s16)(Math_SinS(this->limbRotYTable[limbRotTableIdx]) * 200.0f); + rot->z += (s16)(Math_CosS(this->limbRotZTable[limbRotTableIdx]) * 200.0f); } } - if (limbIndex == 17) { + if (limbIndex == FSN_LIMB_TOUPEE) { *dList = NULL; } return false; @@ -1584,22 +1597,22 @@ s32 EnFsn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, void EnFsn_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnFsn* this = THIS; - if (limbIndex == 16) { + if (limbIndex == FSN_LIMB_HEAD) { this->actor.focus.pos.x = this->actor.world.pos.x; this->actor.focus.pos.y = this->actor.world.pos.y + 60.0f; this->actor.focus.pos.z = this->actor.world.pos.z; OPEN_DISPS(globalCtx->state.gfxCtx); - gSPDisplayList(POLY_OPA_DISP++, object_fsn_DL_00F180); - gSPDisplayList(POLY_OPA_DISP++, object_fsn_DL_00F218); + gSPDisplayList(POLY_OPA_DISP++, gFsnGlassesFrameDL); + gSPDisplayList(POLY_OPA_DISP++, gFsnGlassesLensesDL); CLOSE_DISPS(globalCtx->state.gfxCtx); } } void EnFsn_Draw(Actor* thisx, GlobalContext* globalCtx) { - static TexturePtr sEyeTextures[] = { object_fsn_Tex_005BC0, object_fsn_Tex_006D40, object_fsn_Tex_007140 }; - EnFsn* this = THIS; + static TexturePtr sEyeTextures[] = { gFsnEyeOpenTex, gFsnEyeHalfTex, gFsnEyeClosedTex }; s32 pad; + EnFsn* this = THIS; s16 i; OPEN_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.h b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.h index 139e145daf..5fabf59ade 100644 --- a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.h +++ b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.h @@ -3,6 +3,7 @@ #include "global.h" #include "overlays/actors/ovl_En_GirlA/z_en_girla.h" +#include "objects/object_fsn/object_fsn.h" #define ENFSN_IS_BACKROOM(thisx) ((thisx)->params & 1) #define ENFSN_IS_SHOP(thisx) (!((thisx)->params & 1)) @@ -27,8 +28,8 @@ typedef struct EnFsn { /* 0x24E */ s16 limbRotZTable[19]; /* 0x274 */ Vec3s headRot; /* 0x27A */ Vec3s unk27A; // Set but never used - /* 0x280 */ Vec3s jointTable[19]; - /* 0x2F2 */ Vec3s morphTable[19]; + /* 0x280 */ Vec3s jointTable[FSN_LIMB_MAX + 1]; + /* 0x2F2 */ Vec3s morphTable[FSN_LIMB_MAX + 1]; /* 0x364 */ s16 eyeTextureIdx; /* 0x366 */ s16 blinkTimer; /* 0x368 */ s16 cutsceneState; @@ -63,7 +64,7 @@ typedef struct EnFsn { /* 0x444 */ u8 arrowAnimState; /* 0x445 */ u8 stickAnimState; /* 0x448 */ f32 shopItemSelectedTween; - /* 0x44C */ s16 animationIdx; + /* 0x44C */ s16 animationIndex; /* 0x44E */ u16 flags; } EnFsn; // size = 0x450 diff --git a/src/overlays/actors/ovl_En_Fu/z_en_fu.c b/src/overlays/actors/ovl_En_Fu/z_en_fu.c index aac2475467..b67a3080e3 100644 --- a/src/overlays/actors/ovl_En_Fu/z_en_fu.c +++ b/src/overlays/actors/ovl_En_Fu/z_en_fu.c @@ -4,12 +4,11 @@ * Description: Honey & Darling */ +#include "z_en_fu.h" #include "overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.h" #include "overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.h" -#include "overlays/actors/ovl_Bg_Fu_Mizu/z_bg_fu_mizu.h" #include "overlays/actors/ovl_Bg_Fu_Kaiten/z_bg_fu_kaiten.h" #include "overlays/actors/ovl_En_Bom/z_en_bom.h" -#include "z_en_fu.h" #include "objects/object_mu/object_mu.h" #include "objects/gameplay_keep/gameplay_keep.h" @@ -112,7 +111,7 @@ void func_809616E0(EnFu* this, GlobalContext* globalCtx) { s16 spA0 = false; Vec3f sp94; - if ((gSaveContext.playerForm == PLAYER_FORM_DEKU) && (CURRENT_DAY == 3)) { + if ((gSaveContext.save.playerForm == PLAYER_FORM_DEKU) && (CURRENT_DAY == 3)) { spA0 = true; } this->unk_54C = 0; @@ -230,8 +229,8 @@ void EnFu_Init(Actor* thisx, GlobalContext* globalCtx) { void EnFu_Destroy(Actor* thisx, GlobalContext* globalCtx) { EnFu* this = THIS; - gSaveContext.weekEventReg[63] &= (u8)~1; - gSaveContext.weekEventReg[8] &= (u8)~1; + gSaveContext.save.weekEventReg[63] &= (u8)~1; + gSaveContext.save.weekEventReg[8] &= (u8)~1; Collider_DestroyCylinder(globalCtx, &this->collider); } @@ -386,12 +385,12 @@ void func_80962340(EnFu* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { if (this->unk_54A == 2) { if (this->unk_552 == 0x287D) { - if (gSaveContext.playerForm == PLAYER_FORM_DEKU) { + if (gSaveContext.save.playerForm == PLAYER_FORM_DEKU) { Message_StartTextbox(globalCtx, 0x287E, &this->actor); this->unk_552 = 0x287E; - } else if ((CURRENT_DAY == 3) && (gSaveContext.weekEventReg[22] & 0x10) && - (gSaveContext.weekEventReg[22] & 0x20)) { - if ((gSaveContext.weekEventReg[22] & 0x40)) { + } else if ((CURRENT_DAY == 3) && (gSaveContext.save.weekEventReg[22] & 0x10) && + (gSaveContext.save.weekEventReg[22] & 0x20)) { + if ((gSaveContext.save.weekEventReg[22] & 0x40)) { Message_StartTextbox(globalCtx, 0x2883, &this->actor); this->unk_552 = 0x2883; } else { @@ -426,10 +425,10 @@ void func_80962340(EnFu* this, GlobalContext* globalCtx) { } void func_80962588(EnFu* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx) && (this->unk_552 == 0x2871)) { + if (Message_ShouldAdvance(globalCtx) && (this->unk_552 == 0x2871)) { if (1) {} if (globalCtx->msgCtx.choiceIndex == 0) { - if (gSaveContext.rupees >= 10) { + if (gSaveContext.save.playerData.rupees >= 10) { func_8019F208(); func_801159EC(-10); func_80963DE4(this, globalCtx); @@ -449,7 +448,7 @@ void func_80962588(EnFu* this, GlobalContext* globalCtx) { void func_80962660(EnFu* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->unk_552) { case 0x283C: func_80963F44(this, globalCtx); @@ -532,8 +531,8 @@ void func_80962660(EnFu* this, GlobalContext* globalCtx) { break; case 0x287D: - gSaveContext.weekEventReg[63] |= 1; - gSaveContext.weekEventReg[63] &= (u8)~2; + gSaveContext.save.weekEventReg[63] |= 1; + gSaveContext.save.weekEventReg[63] &= (u8)~2; func_801477B4(globalCtx); player->stateFlags1 |= 0x20; this->unk_53C = 0; @@ -596,7 +595,7 @@ void func_809628D0(EnFu* this, GlobalContext* globalCtx) { break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { this->unk_54A = 1; switch (this->unk_552) { case 0x287F: @@ -605,8 +604,8 @@ void func_809628D0(EnFu* this, GlobalContext* globalCtx) { case 0x2884: case 0x2887: case 0x288A: - gSaveContext.weekEventReg[63] &= (u8)~1; - gSaveContext.weekEventReg[63] &= (u8)~2; + gSaveContext.save.weekEventReg[63] &= (u8)~1; + gSaveContext.save.weekEventReg[63] &= (u8)~2; func_809622FC(this); break; @@ -652,10 +651,10 @@ void func_80962A10(EnFu* this, GlobalContext* globalCtx) { this->unk_546 = 1; } - if ((gSaveContext.playerForm == PLAYER_FORM_DEKU) && gSaveContext.magicAcquired) { + if ((gSaveContext.save.playerForm == PLAYER_FORM_DEKU) && gSaveContext.save.playerData.magicAcquired) { s16 temp = gSaveContext.unk_3F30; - Parameter_AddMagic(globalCtx, temp + (gSaveContext.doubleMagic * 48) + 48); + Parameter_AddMagic(globalCtx, temp + (gSaveContext.save.playerData.doubleMagic * 48) + 48); } func_80962F10(this); @@ -739,7 +738,7 @@ void func_80962EBC(EnFu* this, GlobalContext* globalCtx) { void func_80962F10(EnFu* this) { this->unk_548 = 0; this->actor.flags &= ~ACTOR_FLAG_1; - gSaveContext.weekEventReg[8] |= 1; + gSaveContext.save.weekEventReg[8] |= 1; this->actionFunc = func_80962F4C; } @@ -749,7 +748,7 @@ void func_80962F4C(EnFu* this, GlobalContext* globalCtx) { switch (this->unk_542) { case 0: - if (gSaveContext.playerForm == PLAYER_FORM_HUMAN) { + if (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { player->stateFlags3 |= 0x400; } break; @@ -822,11 +821,11 @@ void func_8096326C(EnFu* this, GlobalContext* globalCtx) { } void func_809632D0(EnFu* this) { - if (gSaveContext.playerForm == PLAYER_FORM_DEKU) { + if (gSaveContext.save.playerForm == PLAYER_FORM_DEKU) { Interface_ChangeAlpha(50); } - gSaveContext.weekEventReg[8] &= (u8)~1; + gSaveContext.save.weekEventReg[8] &= (u8)~1; if (this->unk_2D4 != NULL) { BgFuMizu* mizu = this->unk_2D4; @@ -842,7 +841,7 @@ void func_80963350(EnFu* this, GlobalContext* globalCtx) { static s32 D_80964C24 = 0; BgFuKaiten* fuKaiten = (BgFuKaiten*)this->actor.child; - if ((this->unk_54A == 0) && (((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) || + if ((this->unk_54A == 0) && (((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) || ((Message_GetState(&globalCtx->msgCtx) == 2) && (globalCtx->msgCtx.unk12023 == 1)))) { func_801477B4(globalCtx); this->unk_54A = 2; @@ -879,7 +878,7 @@ void func_80963560(EnFu* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { this->actor.parent = NULL; func_80963610(this); - } else if ((this->unk_552 == 0x2880) && !(gSaveContext.weekEventReg[22] & 0x80)) { + } else if ((this->unk_552 == 0x2880) && !(gSaveContext.save.weekEventReg[22] & 0x80)) { Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 500.0f, 100.0f); } else { Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_PURPLE, 500.0f, 100.0f); @@ -896,13 +895,13 @@ void func_80963630(EnFu* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - if ((gSaveContext.weekEventReg[22] & 0x10) && (gSaveContext.weekEventReg[22] & 0x20) && (CURRENT_DAY == 3) && - (gSaveContext.playerForm == PLAYER_FORM_HUMAN)) { - if (gSaveContext.weekEventReg[22] & 0x40) { + if ((gSaveContext.save.weekEventReg[22] & 0x10) && (gSaveContext.save.weekEventReg[22] & 0x20) && + (CURRENT_DAY == 3) && (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN)) { + if (gSaveContext.save.weekEventReg[22] & 0x40) { Message_StartTextbox(globalCtx, 0x2884, &this->actor); this->unk_552 = 0x2884; - } else if (!(gSaveContext.weekEventReg[22] & 0x80)) { - gSaveContext.weekEventReg[22] |= 0x80; + } else if (!(gSaveContext.save.weekEventReg[22] & 0x80)) { + gSaveContext.save.weekEventReg[22] |= 0x80; Message_StartTextbox(globalCtx, 0x2882, &this->actor); this->unk_552 = 0x2882; } else { @@ -918,18 +917,18 @@ void func_80963630(EnFu* this, GlobalContext* globalCtx) { this->actor.child->freezeTimer = 0; func_809628BC(this); - if (gSaveContext.playerForm == PLAYER_FORM_HUMAN) { + if (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { switch (CURRENT_DAY) { case 1: - gSaveContext.weekEventReg[22] |= 0x10; + gSaveContext.save.weekEventReg[22] |= 0x10; break; case 2: - gSaveContext.weekEventReg[22] |= 0x20; + gSaveContext.save.weekEventReg[22] |= 0x20; break; case 3: - gSaveContext.weekEventReg[22] |= 0x40; + gSaveContext.save.weekEventReg[22] |= 0x40; break; } } @@ -1016,11 +1015,11 @@ s32 func_809638F8(GlobalContext* globalCtx) { void func_809639D0(EnFu* this, GlobalContext* globalCtx) { switch (CURRENT_DAY) { case 1: - if (gSaveContext.playerForm == PLAYER_FORM_HUMAN) { + if (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { if (CUR_UPG_VALUE(UPG_BOMB_BAG) == 0) { Message_StartTextbox(globalCtx, 0x2853, &this->actor); this->unk_552 = 0x2853; - } else if (gSaveContext.weekEventReg[22] & 0x10) { + } else if (gSaveContext.save.weekEventReg[22] & 0x10) { Message_StartTextbox(globalCtx, 0x284D, &this->actor); this->unk_552 = 0x284D; } else if (this->unk_53E == 1) { @@ -1038,13 +1037,13 @@ void func_809639D0(EnFu* this, GlobalContext* globalCtx) { break; case 2: - if (gSaveContext.playerForm != PLAYER_FORM_HUMAN) { + if (gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) { Message_StartTextbox(globalCtx, 0x286F, &this->actor); this->unk_552 = 0x286F; } else if (CUR_UPG_VALUE(UPG_BOMB_BAG) == 0) { Message_StartTextbox(globalCtx, 0x2853, &this->actor); this->unk_552 = 0x2853; - } else if (!(gSaveContext.weekEventReg[22] & 0x10)) { + } else if (!(gSaveContext.save.weekEventReg[22] & 0x10)) { if (this->unk_53E == 1) { Message_StartTextbox(globalCtx, 0x285B, &this->actor); this->unk_552 = 0x285B; @@ -1053,7 +1052,7 @@ void func_809639D0(EnFu* this, GlobalContext* globalCtx) { Message_StartTextbox(globalCtx, 0x285D, &this->actor); this->unk_552 = 0x285D; } - } else if (gSaveContext.weekEventReg[22] & 0x20) { + } else if (gSaveContext.save.weekEventReg[22] & 0x20) { Message_StartTextbox(globalCtx, 0x2855, &this->actor); this->unk_552 = 0x2855; } else if (this->unk_53E == 1) { @@ -1067,8 +1066,8 @@ void func_809639D0(EnFu* this, GlobalContext* globalCtx) { break; case 3: - if (gSaveContext.playerForm != PLAYER_FORM_HUMAN) { - if (gSaveContext.playerForm == PLAYER_FORM_DEKU) { + if (gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) { + if (gSaveContext.save.playerForm == PLAYER_FORM_DEKU) { func_80963EAC(this, globalCtx); } else { Message_StartTextbox(globalCtx, 0x2841, &this->actor); @@ -1077,15 +1076,15 @@ void func_809639D0(EnFu* this, GlobalContext* globalCtx) { } else if (CUR_UPG_VALUE(UPG_QUIVER) == 0) { Message_StartTextbox(globalCtx, 0x284B, &this->actor); this->unk_552 = 0x284B; - } else if (gSaveContext.weekEventReg[22] & 0x40) { - if ((gSaveContext.weekEventReg[22] & 0x10) && (gSaveContext.weekEventReg[22] & 0x20)) { + } else if (gSaveContext.save.weekEventReg[22] & 0x40) { + if ((gSaveContext.save.weekEventReg[22] & 0x10) && (gSaveContext.save.weekEventReg[22] & 0x20)) { Message_StartTextbox(globalCtx, 0x285F, &this->actor); this->unk_552 = 0x285F; } else { Message_StartTextbox(globalCtx, 0x2861, &this->actor); this->unk_552 = 0x2861; } - } else if ((gSaveContext.weekEventReg[22] & 0x10) && (gSaveContext.weekEventReg[22] & 0x20)) { + } else if ((gSaveContext.save.weekEventReg[22] & 0x10) && (gSaveContext.save.weekEventReg[22] & 0x20)) { if (this->unk_53E == 1) { Message_StartTextbox(globalCtx, 0x2863, &this->actor); this->unk_552 = 0x2863; @@ -1094,7 +1093,7 @@ void func_809639D0(EnFu* this, GlobalContext* globalCtx) { Message_StartTextbox(globalCtx, 0x2865, &this->actor); this->unk_552 = 0x2865; } - } else if ((gSaveContext.weekEventReg[22] & 0x10) || (gSaveContext.weekEventReg[22] & 0x20)) { + } else if ((gSaveContext.save.weekEventReg[22] & 0x10) || (gSaveContext.save.weekEventReg[22] & 0x20)) { if (this->unk_53E == 1) { Message_StartTextbox(globalCtx, 0x2867, &this->actor); this->unk_552 = 0x2867; @@ -1118,7 +1117,7 @@ void func_809639D0(EnFu* this, GlobalContext* globalCtx) { void func_80963DE4(EnFu* this, GlobalContext* globalCtx) { switch (this->unk_542) { case 0: - if (gSaveContext.playerForm != PLAYER_FORM_HUMAN) { + if (gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) { Message_StartTextbox(globalCtx, 0x2875, &this->actor); this->unk_552 = 0x2875; } else { @@ -1140,7 +1139,7 @@ void func_80963DE4(EnFu* this, GlobalContext* globalCtx) { } void func_80963EAC(EnFu* this, GlobalContext* globalCtx) { - if (gSaveContext.magicAcquired) { + if (gSaveContext.save.playerData.magicAcquired) { if (this->unk_540 == 1) { Message_StartTextbox(globalCtx, 0x2847, &this->actor); this->unk_552 = 0x2847; @@ -1210,7 +1209,7 @@ void func_8096413C(EnFu* this, GlobalContext* globalCtx) { } void func_80964190(EnFu* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->unk_552) { case 0x2842: case 0x2844: @@ -1262,7 +1261,7 @@ void func_80964190(EnFu* this, GlobalContext* globalCtx) { } void func_8096426C(EnFu* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->unk_552) { case 0x2840: case 0x2841: diff --git a/src/overlays/actors/ovl_En_Fu/z_en_fu.h b/src/overlays/actors/ovl_En_Fu/z_en_fu.h index b16ea46201..6af75768f8 100644 --- a/src/overlays/actors/ovl_En_Fu/z_en_fu.h +++ b/src/overlays/actors/ovl_En_Fu/z_en_fu.h @@ -2,6 +2,7 @@ #define Z_EN_FU_H #include "global.h" +#include "overlays/actors/ovl_Bg_Fu_Mizu/z_bg_fu_mizu.h" struct EnFu; diff --git a/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.c b/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.c index 3cc50bbec7..ad92b34d67 100644 --- a/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.c +++ b/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.c @@ -5,6 +5,9 @@ */ #include "z_en_fu_kago.h" +#include "overlays/actors/ovl_En_Bom/z_en_bom.h" +#include "overlays/actors/ovl_En_Fu/z_en_fu.h" +#include "objects/object_fu_mato/object_fu_mato.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -15,7 +18,15 @@ void EnFuKago_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnFuKago_Update(Actor* thisx, GlobalContext* globalCtx); void EnFuKago_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80ACF994(EnFuKago* this); +void func_80ACF9A8(EnFuKago* this, GlobalContext* globalCtx); +void func_80ACF9DC(EnFuKago* this); +void func_80ACF9FC(EnFuKago* this, GlobalContext* globalCtx); +void func_80ACFA78(EnFuKago* this, GlobalContext* globalCtx); +void func_80AD0028(EnFuKago* this, GlobalContext* globalCtx); +void func_80AD0274(EnFuKago* this); +void func_80AD0288(EnFuKago* this, GlobalContext* globalCtx); + const ActorInit En_Fu_Kago_InitVars = { ACTOR_EN_FU_KAGO, ACTORCAT_BG, @@ -28,46 +39,368 @@ const ActorInit En_Fu_Kago_InitVars = { (ActorFunc)EnFuKago_Draw, }; -// static ColliderSphereInit sSphereInit = { -static ColliderSphereInit D_80AD05F0 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_NO_PUSH | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_SPHERE, }, - { ELEMTYPE_UNK4, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderSphereInit sSphereInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_NO_PUSH | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_SPHERE, + }, + { + ELEMTYPE_UNK4, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 200 }, 100 }, }; -#endif +Gfx* D_80AD061C[] = { + object_fu_mato_DL_0006A0, object_fu_mato_DL_000740, object_fu_mato_DL_0007E0, + object_fu_mato_DL_000880, object_fu_mato_DL_000920, object_fu_mato_DL_0009C0, +}; -extern ColliderSphereInit D_80AD05F0; +Vec3f D_80AD0634[] = { + { -1.0f, 0.5f, 1.73f }, { 1.0f, 0.5f, 1.73f }, { 2.0f, 0.5f, 0.0f }, + { 1.0f, 0.5f, -1.73f }, { -1.0f, 0.5f, -1.73f }, { -2.0f, 0.5f, 0.0f }, +}; -extern UNK_TYPE D_060006A0; -extern UNK_TYPE D_060015C0; +Vec3f D_80AD067C[] = { + { -0.5f, 0.5f, 0.87f }, { 0.5f, 0.5f, 0.87f }, { 1.0f, 0.5f, 0.0f }, + { 0.5f, 0.5f, -0.87f }, { -0.5f, 0.5f, -0.87f }, { -1.0f, 0.5f, 0.0f }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Kago/EnFuKago_Init.s") +Vec3f D_80AD06C4[] = { + { -13.7f, 9.0f, 15.5f }, { 13.7f, 9.0f, 15.5f }, { 13.7f, 9.0f, 0.0f }, + { 13.7f, 9.0f, -15.5f }, { -13.7f, 9.0f, -15.5f }, { -13.7f, 9.0f, 0.0f }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Kago/EnFuKago_Destroy.s") +void EnFuKago_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnFuKago* this = THIS; + CollisionHeader* sp34 = NULL; + Actor* npc = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Kago/func_80ACF8B8.s") + DynaPolyActor_Init(&this->dyna, 1); + CollisionHeader_GetVirtual(&object_fu_mato_Colheader_0015C0, &sp34); + this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, sp34); + Actor_SetScale(&this->dyna.actor, 0.1f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Kago/func_80ACF994.s") + while (npc != NULL) { + if (npc->id == ACTOR_EN_FU) { + this->dyna.actor.parent = npc; + break; + } + npc = npc->next; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Kago/func_80ACF9A8.s") + if (npc == NULL) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Kago/func_80ACF9DC.s") + Collider_InitSphere(globalCtx, &this->collider); + Collider_SetSphere(globalCtx, &this->collider, &this->dyna.actor, &sSphereInit); + this->collider.dim.worldSphere.radius = 10; + this->unk_33A = 0; + this->unk_33C = 0; + this->dyna.actor.colChkInfo.health = 1; + func_80ACF994(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Kago/func_80ACF9FC.s") +void EnFuKago_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnFuKago* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Kago/func_80ACFA78.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Kago/func_80ACFDAC.s") +s32 func_80ACF8B8(EnFuKago* this, GlobalContext* globalCtx) { + this->collider.dim.worldSphere.center.x = this->dyna.actor.world.pos.x; + this->collider.dim.worldSphere.center.y = this->dyna.actor.world.pos.y + 10.0f; + this->collider.dim.worldSphere.center.z = this->dyna.actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Kago/func_80AD0028.s") + if (this->collider.base.ocFlags1 & OC1_HIT) { + this->collider.base.ocFlags1 &= ~OC1_HIT; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Kago/func_80AD0274.s") + if (this->collider.base.oc->id == ACTOR_EN_BOM) { + this->dyna.actor.child = this->collider.base.oc; + } else if (this->collider.base.oc->id == ACTOR_PLAYER) { + func_80ACFA78(this, globalCtx); + return false; + } else { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Kago/func_80AD0288.s") + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_SY_TRE_BOX_APPEAR); + return true; + } else { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Kago/EnFuKago_Update.s") +void func_80ACF994(EnFuKago* this) { + this->actionFunc = func_80ACF9A8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Kago/func_80AD0340.s") +void func_80ACF9A8(EnFuKago* this, GlobalContext* globalCtx) { + if (func_80ACF8B8(this, globalCtx)) { + func_80ACF9DC(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Kago/EnFuKago_Draw.s") +void func_80ACF9DC(EnFuKago* this) { + EnBom* bom = (EnBom*)this->dyna.actor.child; + + bom->timer = 20; + this->actionFunc = func_80ACF9FC; +} + +void func_80ACF9FC(EnFuKago* this, GlobalContext* globalCtx) { + EnBom* bom = (EnBom*)this->dyna.actor.child; + EnFu* fu = (EnFu*)this->dyna.actor.parent; + + if (this->dyna.actor.child->update == NULL) { + this->dyna.actor.child = NULL; + func_80ACF994(this); + } else if (bom->timer == 1) { + fu->unk_548++; + func_80ACFA78(this, globalCtx); + } else { + this->dyna.actor.child->world.pos.x = this->dyna.actor.world.pos.x; + this->dyna.actor.child->world.pos.z = this->dyna.actor.world.pos.z; + } +} + +void func_80ACFA78(EnFuKago* this, GlobalContext* globalCtx) { + s32 i; + Vec3f sp98; + Vec3s sp90; + Vec3s sp88 = { 0, 0, 0 }; + EnFuKagoStruct* ptr; + s16 y; + + this->dyna.actor.colChkInfo.health = 0; + sp98 = this->dyna.actor.world.pos; + sp90 = this->dyna.actor.shape.rot; + + ptr = &this->unk_1B8[0]; + y = sp90.y; + + for (i = 0; i < ARRAY_COUNT(this->unk_1B8); i++) { + ptr->unk_00 = sp98; + ptr->unk_30 = sp88; + + ptr->unk_0C.x = (Math_CosS(y) * D_80AD0634[i].x) + (Math_SinS(y) * D_80AD0634[i].z); + ptr->unk_0C.y = D_80AD0634[i].y + Rand_Centered(); + ptr->unk_0C.z = (Math_CosS(y) * D_80AD0634[i].z) - (Math_SinS(y) * D_80AD0634[i].x); + + ptr->unk_18.x = (Math_CosS(y) * D_80AD067C[i].x) + (Math_SinS(y) * D_80AD067C[i].z); + ptr->unk_18.y = D_80AD067C[i].y; + ptr->unk_18.z = (Math_CosS(y) * D_80AD067C[i].z) - (Math_SinS(y) * D_80AD067C[i].x); + + ptr->unk_36.x = (s16)Rand_Next() >> 5; + ptr->unk_36.y = 0; + ptr->unk_36.z = (s16)Rand_Next() >> 5; + + ptr->unk_24.x = D_80AD06C4[i].x; + ptr->unk_24.y = D_80AD06C4[i].y; + ptr->unk_24.z = D_80AD06C4[i].z; + + ptr->unk_3C = 0; + + ptr->unk_00.x += 18.0f * ptr->unk_0C.x; + ptr->unk_00.y += 18.0f * ptr->unk_0C.y; + ptr->unk_00.z += 18.0f * ptr->unk_0C.z; + + ptr++; + } + + this->dyna.actor.freezeTimer = 2; + EffectSsHahen_SpawnBurst(globalCtx, &this->dyna.actor.world.pos, 17.0f, 0, 15, 13, 20, -1, 10, NULL); + + this->unk_338 = 60; + this->unk_33A = 1; + + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WOODBOX_BREAK); + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + this->actionFunc = func_80AD0028; +} + +Vec3f D_80AD0714 = { 0.0f, 0.0f, 0.0f }; + +void func_80ACFDAC(EnFuKago* this, GlobalContext* globalCtx, EnFuKagoStruct* arg2) { + Vec3f sp34; + f32 temp_f0; + + if (arg2->unk_3C == 0) { + if (arg2->unk_00.y < 15.0f) { + sp34 = arg2->unk_00; + sp34.y = 30.0f; + EffectSsGSplash_Spawn(globalCtx, &sp34, NULL, NULL, 0, 800); + EffectSsGRipple_Spawn(globalCtx, &sp34, 250, 650, 0); + arg2->unk_3C = 1; + } + + Math_SmoothStepToF(&arg2->unk_18.x, 0.0f, 0.1f, 0.1f, 0.1f); + Math_SmoothStepToF(&arg2->unk_18.y, -1.0f, 0.1f, 0.1f, 0.1f); + Math_SmoothStepToF(&arg2->unk_18.z, 0.0f, 0.1f, 0.1f, 0.1f); + return; + } + + temp_f0 = Math_Vec3f_DistXZ(&arg2->unk_00, &D_80AD0714); + + arg2->unk_18.y = ((15.0f - arg2->unk_00.y) * 0.1f) - (0.2f * arg2->unk_0C.y); + arg2->unk_18.x = arg2->unk_0C.x * -0.1f; + arg2->unk_18.z = arg2->unk_0C.z * -0.1f; + + if (temp_f0 < 190.0f) { + arg2->unk_00.x *= 190.0f / temp_f0; + arg2->unk_00.z *= 190.0f / temp_f0; + } + + if (ABS_ALT(arg2->unk_36.x) > 100) { + Math_SmoothStepToS(&arg2->unk_36.x, 0, 0xA, 0x64, 0xA); + } + + if (ABS_ALT(arg2->unk_36.z) > 100) { + Math_SmoothStepToS(&arg2->unk_36.z, 0, 0xA, 0x64, 0xA); + } + + if ((globalCtx->gameplayFrames % 8) == 0) { + sp34 = arg2->unk_00; + sp34.y = 30.0f; + EffectSsGRipple_Spawn(globalCtx, &sp34, 250, 650, 0); + } +} + +void func_80AD0028(EnFuKago* this, GlobalContext* globalCtx) { + EnFuKagoStruct* ptr = this->unk_1B8; + s32 i; + + for (i = 0; i < ARRAY_COUNT(this->unk_1B8); i++) { + func_80ACFDAC(this, globalCtx, ptr); + + ptr->unk_0C.x += ptr->unk_18.x; + ptr->unk_0C.y += ptr->unk_18.y; + ptr->unk_0C.z += ptr->unk_18.z; + + ptr->unk_00.x += ptr->unk_0C.x; + ptr->unk_00.y += ptr->unk_0C.y; + ptr->unk_00.z += ptr->unk_0C.z; + + ptr->unk_30.x += ptr->unk_36.x; + ptr->unk_30.y += ptr->unk_36.y; + ptr->unk_30.z += ptr->unk_36.z; + + ptr++; + } + + if (this->unk_338 == 59) { + this->unk_1B8[3].unk_0C.x *= -1.0f; + this->unk_1B8[3].unk_0C.z *= -1.0f; + + this->unk_1B8[4].unk_0C.x *= -1.0f; + this->unk_1B8[4].unk_0C.z *= -1.0f; + } else if (this->unk_338 == 58) { + Vec3f sp34 = this->unk_1B8[5].unk_0C; + + this->unk_1B8[5].unk_0C.x = sp34.z; + this->unk_1B8[5].unk_0C.z = -sp34.x; + + sp34 = this->unk_1B8[2].unk_0C; + this->unk_1B8[2].unk_0C.x = -sp34.z; + this->unk_1B8[2].unk_0C.z = sp34.x; + + this->unk_1B8[5].unk_36.x *= -1; + this->unk_1B8[5].unk_36.y *= -1; + this->unk_1B8[5].unk_36.z *= -1; + + this->unk_1B8[2].unk_36.x *= -1; + this->unk_1B8[2].unk_36.y *= -1; + this->unk_1B8[2].unk_36.z *= -1; + } else if (this->unk_338 == 0) { + func_80AD0274(this); + } + this->unk_338--; +} + +void func_80AD0274(EnFuKago* this) { + this->actionFunc = func_80AD0288; +} + +void func_80AD0288(EnFuKago* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f* scale = &this->dyna.actor.scale; + + Math_SmoothStepToF(&scale->x, 0.0f, 0.1f, 0.005f, 0.005f); + scale->z = scale->x; + scale->y = scale->x; + if (scale->x == 0.0f) { + Actor_MarkForDeath(&this->dyna.actor); + } +} + +void EnFuKago_Update(Actor* thisx, GlobalContext* globalCtx) { + EnFuKago* this = THIS; + + this->actionFunc(this, globalCtx); + + if (this->unk_33C == 1) { + func_80AD0274(this); + } +} + +void func_80AD0340(EnFuKago* this, GlobalContext* globalCtx) { + s32 pad[2]; + EnFuKagoStruct* ptr = &this->unk_1B8[0]; + s32 i; + Vec3f* scale = &this->dyna.actor.scale; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + for (i = 0; i < ARRAY_COUNT(D_80AD061C); i++, ptr++) { + Matrix_StatePush(); + Matrix_SetStateRotationAndTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, &this->dyna.actor.shape.rot); + Matrix_InsertTranslation(ptr->unk_24.x, ptr->unk_24.y, ptr->unk_24.z, MTXMODE_APPLY); + Matrix_InsertRotation(ptr->unk_30.x, ptr->unk_30.y, ptr->unk_30.z, MTXMODE_APPLY); + Matrix_InsertTranslation(-ptr->unk_24.x, -ptr->unk_24.y, -ptr->unk_24.z, MTXMODE_APPLY); + Matrix_Scale(scale->x, scale->y, scale->z, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, D_80AD061C[i]); + + Matrix_StatePop(); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void EnFuKago_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnFuKago* this = THIS; + + if (this->unk_33A == 0) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_fu_mato_DL_0006A0); + gSPDisplayList(POLY_OPA_DISP++, object_fu_mato_DL_000740); + gSPDisplayList(POLY_OPA_DISP++, object_fu_mato_DL_0007E0); + gSPDisplayList(POLY_OPA_DISP++, object_fu_mato_DL_000880); + gSPDisplayList(POLY_OPA_DISP++, object_fu_mato_DL_000920); + gSPDisplayList(POLY_OPA_DISP++, object_fu_mato_DL_0009C0); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } else { + func_80AD0340(this, globalCtx); + } +} diff --git a/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.h b/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.h index db37f2f2d8..19022093e2 100644 --- a/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.h +++ b/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.h @@ -7,11 +7,23 @@ struct EnFuKago; typedef void (*EnFuKagoActionFunc)(struct EnFuKago*, GlobalContext*); +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ Vec3f unk_0C; + /* 0x18 */ Vec3f unk_18; + /* 0x24 */ Vec3f unk_24; + /* 0x30 */ Vec3s unk_30; + /* 0x36 */ Vec3s unk_36; + /* 0x3C */ s16 unk_3C; +} EnFuKagoStruct; // size = 0x40 + typedef struct EnFuKago { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; + /* 0x0000 */ DynaPolyActor dyna; /* 0x015C */ EnFuKagoActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x1DC]; + /* 0x0160 */ ColliderSphere collider; + /* 0x01B8 */ EnFuKagoStruct unk_1B8[6]; + /* 0x0338 */ s16 unk_338; + /* 0x033A */ s16 unk_33A; /* 0x033C */ s16 unk_33C; } EnFuKago; // size = 0x340 diff --git a/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.c b/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.c index fb4fc2a450..ec02097298 100644 --- a/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.c +++ b/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.c @@ -5,6 +5,8 @@ */ #include "z_en_fu_mato.h" +#include "overlays/actors/ovl_En_Fu/z_en_fu.h" +#include "objects/object_fu_mato/object_fu_mato.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -15,7 +17,15 @@ void EnFuMato_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnFuMato_Update(Actor* thisx, GlobalContext* globalCtx); void EnFuMato_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80ACE4B4(EnFuMato* this); +void func_80ACE4C8(EnFuMato* this, GlobalContext* globalCtx); +void func_80ACE508(EnFuMato* this); +void func_80ACE51C(EnFuMato* this, GlobalContext* globalCtx); +void func_80ACE718(EnFuMato* this, GlobalContext* globalCtx); +void func_80ACECFC(EnFuMato* this, GlobalContext* globalCtx); +void func_80ACEFC4(EnFuMato* this); +void func_80ACEFD8(EnFuMato* this, GlobalContext* globalCtx); + const ActorInit En_Fu_Mato_InitVars = { ACTOR_EN_FU_MATO, ACTORCAT_BG, @@ -28,52 +38,447 @@ const ActorInit En_Fu_Mato_InitVars = { (ActorFunc)EnFuMato_Draw, }; -// static ColliderSphereInit sSphereInit = { -static ColliderSphereInit D_80ACF610 = { - { COLTYPE_HIT3, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_SPHERE, }, - { ELEMTYPE_UNK4, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderSphereInit sSphereInit = { + { + COLTYPE_HIT3, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_SPHERE, + }, + { + ELEMTYPE_UNK4, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 200 }, 100 }, }; -#endif +Gfx* D_80ACF63C[] = { + object_fu_mato_DL_001C80, object_fu_mato_DL_001D68, object_fu_mato_DL_001E50, + object_fu_mato_DL_001F38, object_fu_mato_DL_002020, object_fu_mato_DL_002108, +}; -extern ColliderSphereInit D_80ACF610; +Vec2f D_80ACF654[] = { + { -1.0f, -1.73f }, { 1.0f, -1.73f }, { 2.0f, 0.0f }, { 1.0f, 1.73f }, { -1.0f, 1.73f }, { -2.0f, 0.0f }, +}; -extern UNK_TYPE D_060023D4; -extern UNK_TYPE D_06002720; +void EnFuMato_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnFuMato* this = THIS; + CollisionHeader* sp2C = NULL; + Actor* actor = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; + EnFu* fu; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/EnFuMato_Init.s") + DynaPolyActor_Init(&this->dyna, 3); + CollisionHeader_GetVirtual(&object_fu_mato_Colheader_0023D4, &sp2C); + this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, sp2C); + Actor_SetScale(&this->dyna.actor, 0.1f); + Collider_InitSphere(globalCtx, &this->collider); + Collider_SetSphere(globalCtx, &this->collider, &this->dyna.actor, &sSphereInit); + this->collider.dim.worldSphere.radius = 20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/EnFuMato_Destroy.s") + while (actor != NULL) { + if (actor->id == ACTOR_EN_FU) { + this->dyna.actor.parent = actor; + break; + } + actor = actor->next; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/func_80ACE4B4.s") + if (actor == NULL) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/func_80ACE4C8.s") + fu = (EnFu*)this->dyna.actor.parent; + if (fu->unk_542 == 2) { + this->collider.info.elemType = ELEMTYPE_UNK0; + this->collider.dim.worldSphere.radius = 30; + } else { + this->collider.dim.worldSphere.radius = 17; + this->unk_2F8 = fu->unk_538; + this->unk_2F4 = fu->unk_520; + this->unk_2F0 = ENFUMATO_GET(&this->dyna.actor); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/func_80ACE508.s") + this->unk_302 = 0; + this->unk_304 = 0; + func_80ACE4B4(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/func_80ACE51C.s") +void EnFuMato_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnFuMato* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/func_80ACE680.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + Collider_DestroySphere(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/func_80ACE718.s") +void func_80ACE4B4(EnFuMato* this) { + this->actionFunc = func_80ACE4C8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/func_80ACE850.s") +void func_80ACE4C8(EnFuMato* this, GlobalContext* globalCtx) { + EnFu* fu = (EnFu*)this->dyna.actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/func_80ACEB2C.s") + if ((fu->unk_54A == 0) && (fu->unk_542 == 0)) { + func_80ACE508(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/func_80ACECFC.s") +void func_80ACE508(EnFuMato* this) { + this->actionFunc = func_80ACE51C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/func_80ACEFC4.s") +void func_80ACE51C(EnFuMato* this, GlobalContext* globalCtx) { + EnFu* fu = (EnFu*)this->dyna.actor.parent; + Vec3f sp30; + f32 sp2C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/func_80ACEFD8.s") + sp30.x = this->unk_2F8[this->unk_2F0].x; + sp30.y = this->unk_2F8[this->unk_2F0].y; + sp30.z = this->unk_2F8[this->unk_2F0].z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/func_80ACF04C.s") + sp2C = Math_Vec3f_DistXZ(&this->dyna.actor.world.pos, &sp30); + this->dyna.actor.world.rot.y = Math_Vec3f_Yaw(&this->dyna.actor.world.pos, &sp30); + this->dyna.actor.world.rot.x = Math_Vec3f_Pitch(&this->dyna.actor.world.pos, &sp30); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/EnFuMato_Update.s") + if (sp2C < 10.0f) { + if (this->unk_2F0 < (this->unk_2F4 - 1)) { + this->unk_2F0++; + } else { + this->unk_2F0 = 0; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/func_80ACF1F4.s") + this->dyna.actor.speedXZ = 2.0f; + this->dyna.actor.shape.rot.y = Math_Vec3f_Yaw(&this->dyna.actor.world.pos, &this->dyna.actor.parent->world.pos); + Actor_MoveWithGravity(&this->dyna.actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/func_80ACF3F4.s") + if (fu->unk_54A != 0) { + func_80ACE4B4(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/EnFuMato_Draw.s") +void func_80ACE680(EnFuMato* this) { + this->dyna.actor.gravity = -0.5f; + this->dyna.actor.velocity.y = 1.0f; + this->dyna.actor.velocity.x = 2.0f * Rand_Centered(); + this->dyna.actor.velocity.z = 2.0f * Rand_Centered(); + this->unk_2FC.x = Rand_Next() & 0xFFF; + this->unk_2FC.y = Rand_Next() & 0xFFF; + this->unk_2FC.z = Rand_Next() & 0xFFF; + this->unk_302 = 3; + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WOODPLATE_BOUND); + this->actionFunc = func_80ACE718; +} + +void func_80ACE718(EnFuMato* this, GlobalContext* globalCtx) { + this->dyna.actor.shape.rot.x += this->unk_2FC.x; + this->dyna.actor.shape.rot.y += this->unk_2FC.y; + this->dyna.actor.shape.rot.z += this->unk_2FC.z; + this->dyna.actor.velocity.y += this->dyna.actor.gravity; + + Actor_UpdatePos(&this->dyna.actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 15.0f, 30.0f, 60.0f, 5); + + if ((this->dyna.actor.bgCheckFlags & 1) || (this->dyna.actor.world.pos.y < -500.0f)) { + Vec3f sp3C = { 0.0f, 0.0f, 0.0f }; + Vec3f sp30 = { 0.0f, 2.0f, 0.0f }; + + func_800B3030(globalCtx, &this->dyna.actor.world.pos, &sp3C, &sp30, 20, 40, 2); + Actor_MarkForDeath(&this->dyna.actor); + } +} + +void func_80ACE850(EnFuMato* this, GlobalContext* globalCtx) { + EnFuMatoStruct* ptr = this->unk_1B8; + s16 temp_s4 = this->dyna.actor.shape.rot.y; + s32 phi_s2; + s32 i; + + this->unk_308 = (u32)Rand_Next() % ARRAY_COUNT(this->unk_1B8); + this->unk_302 = 1; + this->dyna.actor.gravity = -1.0f; + this->dyna.actor.velocity.y = Rand_ZeroOne(); + + phi_s2 = this->unk_308; + + for (i = 0; i < 2; i++) { + ptr->unk_00 = this->dyna.actor.world.pos; + + ptr->unk_0C.x = Math_CosS(temp_s4) * D_80ACF654[phi_s2].x; + ptr->unk_0C.y = D_80ACF654[phi_s2].z; + ptr->unk_0C.z = -Math_SinS(temp_s4) * D_80ACF654[phi_s2].x; + + ptr->unk_0C.x += Rand_Centered(); + ptr->unk_0C.y += Rand_ZeroOne() * 0.5f; + ptr->unk_0C.z += Rand_Centered(); + + ptr->unk_18.x = 0.0f; + ptr->unk_18.y = -1.0f; + ptr->unk_18.z = 0.0f; + + ptr->unk_00.x += 9.0f * ptr->unk_0C.x; + ptr->unk_00.y += 9.0f * ptr->unk_0C.y; + ptr->unk_00.z += 9.0f * ptr->unk_0C.z; + + ptr->unk_24 = this->dyna.actor.shape.rot; + + ptr->unk_2A.x = (s16)Rand_Next() >> 6; + ptr->unk_2A.y = (s16)Rand_Next() >> 6; + ptr->unk_2A.z = (s16)Rand_Next() >> 6; + ptr->unk_30 = 1; + + phi_s2 = (phi_s2 + 3) % ARRAY_COUNT(this->unk_1B8); + ptr++; + } + + this->dyna.actor.freezeTimer = 2; + EffectSsHahen_SpawnBurst(globalCtx, &this->dyna.actor.world.pos, 13.0f, 0, 7, 8, 20, -1, 10, NULL); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WOODPLATE_BROKEN); + this->actionFunc = func_80ACECFC; +} + +void func_80ACEB2C(EnFuMato* this) { + EnFuMatoStruct sp18[2]; + s32 phi_v0 = this->unk_308; + s32 i; + s32 phi_v1; + s32 phi_a1; + + sp18[0] = this->unk_1B8[0]; + sp18[1] = this->unk_1B8[1]; + + for (i = 0; i < ARRAY_COUNT(sp18); i++) { + if (phi_v0 == 0) { + phi_v1 = 5; + } else { + phi_v1 = phi_v0 - 1; + } + + if (phi_v0 == 5) { + phi_a1 = 0; + } else { + phi_a1 = phi_v0 + 1; + } + + this->unk_1B8[phi_v0] = sp18[i]; + this->unk_1B8[phi_v1] = sp18[i]; + this->unk_1B8[phi_a1] = sp18[i]; + + phi_v0 = (phi_v0 + 3) % ARRAY_COUNT(this->unk_1B8); + } + + this->unk_302 = 2; + this->actionFunc = func_80ACECFC; +} + +void func_80ACECFC(EnFuMato* this, GlobalContext* globalCtx) { + EnFuMatoStruct* ptr = this->unk_1B8; + s32 phi_s3; + s32 i; + + this->dyna.actor.velocity.y += this->dyna.actor.gravity; + Actor_UpdatePos(&this->dyna.actor); + + if (this->dyna.actor.world.pos.y < -500.0f) { + this->dyna.actor.world.pos.y = -500.0f; + } + + if (this->unk_302 == 1) { + phi_s3 = 2; + } else { + phi_s3 = ARRAY_COUNT(this->unk_1B8); + } + + for (i = 0; i < phi_s3; i++, ptr++) { + ptr->unk_00.x += ptr->unk_0C.x; + ptr->unk_00.y += ptr->unk_0C.y; + ptr->unk_00.z += ptr->unk_0C.z; + + ptr->unk_0C.x += ptr->unk_18.x; + ptr->unk_0C.y += ptr->unk_18.y; + ptr->unk_0C.z += ptr->unk_18.z; + + ptr->unk_24.x += ptr->unk_2A.x; + ptr->unk_24.y += ptr->unk_2A.y; + ptr->unk_24.z += ptr->unk_2A.z; + + if ((this->unk_302 == 2) && (ptr->unk_30 == 1) && (ptr->unk_00.y < (this->dyna.actor.floorHeight + 10.0f))) { + if (ptr->unk_0C.y < 0.0f) { + ptr->unk_0C.y = -ptr->unk_0C.y; + } else { + ptr->unk_0C.y = ptr->unk_0C.y; + } + ptr->unk_0C.y *= 0.5f; + ptr->unk_0C.x *= (Rand_Centered() * 1.5f) + 2.0f; + ptr->unk_0C.z *= (Rand_Centered() * 1.5f) + 2.0f; + + ptr->unk_2A.x = (s16)Rand_Next() >> 5; + ptr->unk_2A.y = (s16)Rand_Next() >> 5; + ptr->unk_2A.z = (s16)Rand_Next() >> 5; + + ptr->unk_30 = 0; + } + } + + if (this->unk_302 == 1) { + Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 15.0f, 30.0f, 60.0f, 5); + if (this->dyna.actor.bgCheckFlags & 1) { + func_80ACEB2C(this); + } + } + + if (this->unk_304 < 60) { + this->unk_304++; + } else { + func_80ACEFC4(this); + } +} + +void func_80ACEFC4(EnFuMato* this) { + this->actionFunc = func_80ACEFD8; +} + +void func_80ACEFD8(EnFuMato* this, GlobalContext* globalCtx) { + Vec3f* scale = &this->dyna.actor.scale; + + Math_SmoothStepToF(&scale->x, 0.0f, 0.1f, 0.005f, 0.005f); + scale->y = scale->z = scale->x; + if (scale->x == 0.0f) { + Actor_MarkForDeath(&this->dyna.actor); + } +} + +s32 func_80ACF04C(EnFuMato* this, GlobalContext* globalCtx) { + EnFu* fu = (EnFu*)this->dyna.actor.parent; + + this->collider.dim.worldSphere.center.x = this->dyna.actor.world.pos.x; + this->collider.dim.worldSphere.center.y = this->dyna.actor.world.pos.y; + this->collider.dim.worldSphere.center.z = this->dyna.actor.world.pos.z; + + if ((this->unk_302 == 0) && (((fu->unk_542 == 0) && (this->collider.base.acFlags & AC_HIT)) || + ((fu->unk_542 == 2) && (this->collider.base.ocFlags1 & OC1_HIT)))) { + this->collider.base.acFlags &= ~AC_HIT; + this->collider.base.ocFlags1 &= ~OC1_HIT; + + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_SY_TRE_BOX_APPEAR); + + fu->unk_548++; + if ((fu->unk_542 == 2) || (gSaveContext.save.playerForm == PLAYER_FORM_DEKU)) { + fu->unk_546 = 1; + func_80ACE680(this); + } else { + func_80ACE850(this, globalCtx); + } + return true; + } + + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + return false; +} + +void EnFuMato_Update(Actor* thisx, GlobalContext* globalCtx) { + EnFuMato* this = THIS; + + this->actionFunc(this, globalCtx); + + func_80ACF04C(this, globalCtx); + + if (this->unk_30A == 1) { + func_80ACEFC4(this); + } +} + +void func_80ACF1F4(EnFuMato* this, GlobalContext* globalCtx) { + EnFuMatoStruct* ptr = this->unk_1B8; + s32 temp_s4 = this->unk_308; + s32 i; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + for (i = 0; i < 2; i++) { + Matrix_StatePush(); + Matrix_SetStateRotationAndTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, &ptr->unk_24); + Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, D_80ACF63C[temp_s4]); + + switch (temp_s4) { + case 0: + gSPDisplayList(POLY_OPA_DISP++, D_80ACF63C[5]); + gSPDisplayList(POLY_OPA_DISP++, D_80ACF63C[temp_s4 + 1]); + break; + + case 5: + gSPDisplayList(POLY_OPA_DISP++, D_80ACF63C[temp_s4 - 1]); + gSPDisplayList(POLY_OPA_DISP++, D_80ACF63C[0]); + break; + + default: + gSPDisplayList(POLY_OPA_DISP++, D_80ACF63C[temp_s4 - 1]); + gSPDisplayList(POLY_OPA_DISP++, D_80ACF63C[temp_s4 + 1]); + break; + } + + Matrix_StatePop(); + + temp_s4 = (temp_s4 + 3) % ARRAY_COUNT(this->unk_1B8); + ptr++; + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80ACF3F4(EnFuMato* this, GlobalContext* globalCtx) { + EnFuMatoStruct* ptr = this->unk_1B8; + Vec3f* scale = &this->dyna.actor.scale; + s32 i; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + for (i = 0; i < ARRAY_COUNT(D_80ACF63C); i++, ptr++) { + Matrix_StatePush(); + Matrix_SetStateRotationAndTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, &ptr->unk_24); + Matrix_Scale(scale->x, scale->y, scale->z, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, D_80ACF63C[i]); + + Matrix_StatePop(); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void EnFuMato_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnFuMato* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + if ((this->unk_302 == 0) || (this->unk_302 == 3)) { + gSPDisplayList(POLY_OPA_DISP++, object_fu_mato_DL_002720); + } else if (this->unk_302 == 1) { + func_80ACF1F4(this, globalCtx); + } else { + func_80ACF3F4(this, globalCtx); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.h b/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.h index 51dbf177fc..5666b71fcb 100644 --- a/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.h +++ b/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.h @@ -7,11 +7,30 @@ struct EnFuMato; typedef void (*EnFuMatoActionFunc)(struct EnFuMato*, GlobalContext*); +#define ENFUMATO_GET(thisx) ((thisx)->params) + +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ Vec3f unk_0C; + /* 0x18 */ Vec3f unk_18; + /* 0x24 */ Vec3s unk_24; + /* 0x2A */ Vec3s unk_2A; + /* 0x30 */ s16 unk_30; +} EnFuMatoStruct; // size = 0x34 + typedef struct EnFuMato { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; + /* 0x0000 */ DynaPolyActor dyna; /* 0x015C */ EnFuMatoActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x1AA]; + /* 0x0160 */ ColliderSphere collider; + /* 0x01B8 */ EnFuMatoStruct unk_1B8[6]; + /* 0x02F0 */ s32 unk_2F0; + /* 0x02F4 */ s32 unk_2F4; + /* 0x02F8 */ Vec3s* unk_2F8; + /* 0x02FC */ Vec3s unk_2FC; + /* 0x0302 */ s16 unk_302; + /* 0x0304 */ s16 unk_304; + /* 0x0306 */ UNK_TYPE1 unk306[2]; + /* 0x0308 */ s16 unk_308; /* 0x030A */ s16 unk_30A; } EnFuMato; // size = 0x30C diff --git a/src/overlays/actors/ovl_En_Fz/z_en_fz.c b/src/overlays/actors/ovl_En_Fz/z_en_fz.c index ea225846ab..067e8c50d2 100644 --- a/src/overlays/actors/ovl_En_Fz/z_en_fz.c +++ b/src/overlays/actors/ovl_En_Fz/z_en_fz.c @@ -227,9 +227,9 @@ void EnFz_Init(Actor* thisx, GlobalContext* globalCtx) { } } - this->unk_BA4 = 0; - this->unk_BA0 = 0.0f; - this->unk_B9C = 0.0f; + this->drawDmgEffTimer = 0; + this->drawDmgEffScale = 0.0f; + this->drawDmgEffAlpha = 0.0f; func_80932784(this, globalCtx); } @@ -416,8 +416,8 @@ void func_80932C98(EnFz* this, GlobalContext* globalCtx) { this->collider1.base.acFlags &= ~AC_HIT; switch (this->actor.colChkInfo.damageEffect) { case 4: - this->unk_BA4 = 0x28; - this->unk_B9C = 1.0f; + this->drawDmgEffTimer = 40; + this->drawDmgEffAlpha = 1.0f; case 15: Actor_ApplyDamage(&this->actor); @@ -773,16 +773,16 @@ void func_80933B38(EnFz* this, GlobalContext* globalCtx) { } void func_80933B48(EnFz* this, GlobalContext* globalCtx) { - if (this->unk_BA4 != 0) { - if (this->unk_BA4 > 0) { - this->unk_BA4--; + if (this->drawDmgEffTimer != 0) { + if (this->drawDmgEffTimer > 0) { + this->drawDmgEffTimer--; } - if (this->unk_BA4 < 20) { - Math_SmoothStepToF(&this->unk_BA0, 0.0f, 0.5f, 0.03f, 0.0f); - this->unk_B9C = this->unk_BA4 * 0.05f; + if (this->drawDmgEffTimer < 20) { + Math_SmoothStepToF(&this->drawDmgEffScale, 0.0f, 0.5f, 0.03f, 0.0f); + this->drawDmgEffAlpha = this->drawDmgEffTimer * 0.05f; } else { - Math_SmoothStepToF(&this->unk_BA0, 0.5f, 0.1f, 0.02f, 0.0f); + Math_SmoothStepToF(&this->drawDmgEffScale, 0.5f, 0.1f, 0.02f, 0.0f); } } } @@ -862,17 +862,17 @@ void EnFz_Draw(Actor* thisx, GlobalContext* globalCtx) { func_80934464(this, globalCtx); - if (this->unk_BA4 > 0) { + if (this->drawDmgEffTimer > 0) { s32 pad2[6]; - Vec3f sp58; - Vec3f sp4C; + Vec3f limbPos[2]; s32 pad3; - sp4C = this->actor.world.pos; - sp58 = this->actor.world.pos; - sp4C.y += 20.0f; - sp58.y += 40.0f; - func_800BE680(globalCtx, NULL, &sp4C, 2, this->unk_BA0 * 4.0f, 0.5f, this->unk_B9C, 20); + limbPos[0] = this->actor.world.pos; + limbPos[1] = this->actor.world.pos; + limbPos[0].y += 20.0f; + limbPos[1].y += 40.0f; + Actor_DrawDamageEffects(globalCtx, NULL, limbPos, ARRAY_COUNT(limbPos), this->drawDmgEffScale * 4.0f, 0.5f, + this->drawDmgEffAlpha, ACTOR_DRAW_DMGEFF_LIGHT_ORBS); } CLOSE_DISPS(globalCtx->state.gfxCtx); @@ -1004,7 +1004,7 @@ void func_80934464(EnFz* this, GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); if (flag == 0) { - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_051180); + gSPDisplayList(POLY_XLU_DISP++, gFrozenSteamDL); flag++; } @@ -1018,7 +1018,7 @@ void func_80934464(EnFz* this, GlobalContext* globalCtx) { Matrix_Scale(ptr->unk_30, ptr->unk_30, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_051238); + gSPDisplayList(POLY_XLU_DISP++, gFrozenSteamVtxDL); } } diff --git a/src/overlays/actors/ovl_En_Fz/z_en_fz.h b/src/overlays/actors/ovl_En_Fz/z_en_fz.h index 5e76eadf9f..19f462d0ab 100644 --- a/src/overlays/actors/ovl_En_Fz/z_en_fz.h +++ b/src/overlays/actors/ovl_En_Fz/z_en_fz.h @@ -43,9 +43,9 @@ typedef struct EnFz { /* 0x22C */ Vec3f unk_22C; /* 0x238 */ f32 unk_238; /* 0x23C */ EnFzStruct unk_23C[40]; - /* 0xB9C */ f32 unk_B9C; - /* 0xBA0 */ f32 unk_BA0; - /* 0xBA4 */ s16 unk_BA4; + /* 0xB9C */ f32 drawDmgEffAlpha; + /* 0xBA0 */ f32 drawDmgEffScale; + /* 0xBA4 */ s16 drawDmgEffTimer; /* 0xBA8 */ f32 unk_BA8; /* 0xBAC */ f32 unk_BAC; /* 0xBB0 */ f32 unk_BB0; diff --git a/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.c b/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.c index 024c857ea5..1d9175b494 100644 --- a/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.c +++ b/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.c @@ -5,6 +5,7 @@ */ #include "z_en_gakufu.h" +#include "interface/parameter_static/parameter_static.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000) @@ -15,13 +16,15 @@ void EnGakufu_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnGakufu_Update(Actor* thisx, GlobalContext* globalCtx); void EnGakufu_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80AFCB94(EnGakufu* this, GlobalContext* globalCtx); -void func_80AFCBD4(EnGakufu* this, GlobalContext* globalCtx); -void func_80AFCC14(EnGakufu* this, GlobalContext* globalCtx); -void func_80AFCD44(EnGakufu* this, GlobalContext* globalCtx); -void func_80AFCDC8(EnGakufu* this, GlobalContext* globalCtx); +void EnGakufu_ProcessNotes(EnGakufu* this); +s32 EnGakufu_IsPlayerInRange(EnGakufu* this, GlobalContext* globalCtx); +void EnGakufu_DisplayOnTimer(EnGakufu* this, GlobalContext* globalCtx); +void EnGakufu_WaitForTimer(EnGakufu* this, GlobalContext* globalCtx); +void EnGakufu_DoNothing(EnGakufu* this, GlobalContext* globalCtx); +void EnGakufu_GiveReward(EnGakufu* this, GlobalContext* globalCtx); +void EnGakufu_PlayRewardCutscene(EnGakufu* this, GlobalContext* globalCtx); +void EnGakufu_WaitForSong(EnGakufu* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Gakufu_InitVars = { ACTOR_EN_GAKUFU, ACTORCAT_ITEMACTION, @@ -34,28 +37,257 @@ const ActorInit En_Gakufu_InitVars = { (ActorFunc)EnGakufu_Draw, }; -#endif +Vec3f sRewardDropsSpawnTerminaFieldPos = { + -710.0f, + -123.0f, + -3528.0f, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gakufu/func_80AFC960.s") +/** + * Determines which set of `sRewardDrops` to collect when successfully playing the notes on the wall. + * Rewards come in batches of three, and the reward you get depends on the time of day. + */ +u8 sRewardDropsIndex[] = { + 3, // CLOCK_TIME(0, 0) to CLOCKTIME(1, 0) + 12, // CLOCK_TIME(1, 0) to CLOCKTIME(2, 0) + 6, // CLOCK_TIME(2, 0) to CLOCKTIME(3, 0) + 12, // CLOCK_TIME(3, 0) to CLOCKTIME(4, 0) + 9, // CLOCK_TIME(4, 0) to CLOCKTIME(5, 0) + 12, // CLOCK_TIME(5, 0) to CLOCKTIME(6, 0) + 0, // CLOCK_TIME(6, 0) to CLOCKTIME(7, 0) + 12, // CLOCK_TIME(7, 0) to CLOCKTIME(8, 0) + 3, // CLOCK_TIME(8, 0) to CLOCKTIME(9, 0) + 12, // CLOCK_TIME(9, 0) to CLOCKTIME(10, 0) + 6, // CLOCK_TIME(10, 0) to CLOCKTIME(11, 0) + 12, // CLOCK_TIME(11, 0) to CLOCKTIME(12, 0) + 3, // CLOCK_TIME(12, 0) to CLOCKTIME(13, 0) + 12, // CLOCK_TIME(13, 0) to CLOCKTIME(14, 0) + 6, // CLOCK_TIME(14, 0) to CLOCKTIME(15, 0) + 12, // CLOCK_TIME(15, 0) to CLOCKTIME(16, 0) + 3, // CLOCK_TIME(16, 0) to CLOCKTIME(17, 0) + 12, // CLOCK_TIME(17, 0) to CLOCKTIME(18, 0) + 6, // CLOCK_TIME(18, 0) to CLOCKTIME(19, 0) + 12, // CLOCK_TIME(19, 0) to CLOCKTIME(20, 0) + 9, // CLOCK_TIME(20, 0) to CLOCKTIME(21, 0) + 12, // CLOCK_TIME(21, 0) to CLOCKTIME(22, 0) + 6, // CLOCK_TIME(22, 0) to CLOCKTIME(23, 0) + 12, // CLOCK_TIME(23, 0) to CLOCKTIME(0, 0) +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gakufu/EnGakufu_Init.s") +/** + * The set of rewards when the song notes on the wall are played. + * Should be thought of as a 2D array: sRewardDrops[5][3] + * i.e. there are 5 sets of possible rewards. And each set gives out three rewards + */ +u8 sRewardDrops[] = { + ITEM00_RUPEE_RED, ITEM00_RUPEE_RED, ITEM00_RUPEE_RED, // Set 1 (index 0) + ITEM00_RUPEE_RED, ITEM00_RUPEE_GREEN, ITEM00_RUPEE_GREEN, // Set 2 (index 3) + ITEM00_RUPEE_BLUE, ITEM00_RUPEE_BLUE, ITEM00_RUPEE_BLUE, // Set 3 (index 6) + ITEM00_RUPEE_RED, ITEM00_RUPEE_BLUE, ITEM00_RUPEE_BLUE, // Set 4 (index 9) + ITEM00_RUPEE_GREEN, ITEM00_RUPEE_GREEN, ITEM00_RUPEE_GREEN, // Set 5 (index 12) +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gakufu/EnGakufu_Destroy.s") +// y-offsets of ocarina buttons drawn on wall +f32 sOcarinaBtnWallYOffsets[] = { + -4.0f, -2.0f, 0.0f, 1.0f, 3.0f, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gakufu/func_80AFCB94.s") +TexturePtr sOcarinaBtnWallTextures[] = { + gOcarinaATex, gOcarinaCDownTex, gOcarinaCRightTex, gOcarinaCLeftTex, gOcarinaCUpTex, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gakufu/func_80AFCBD4.s") +#include "overlays/ovl_En_Gakufu/ovl_En_Gakufu.c" -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gakufu/func_80AFCC14.s") +void EnGakufu_ProcessNotes(EnGakufu* this) { + OcarinaStaff* playbackStaff; + OcarinaSongButtons* ocarinaSongButtons; + s32 songNumButtons; + s32 i; + s32 songIndex; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gakufu/func_80AFCC24.s") + AudioOcarina_TerminaWallGenerateNotes(); + AudioOcarina_SetInstrumentId(OCARINA_INSTRUMENT_DEFAULT); + AudioOcarina_StartDefault((1 << this->songIndex) | 0x80000000); + playbackStaff = AudioOcarina_GetPlaybackStaff(); + playbackStaff->pos = 0; + playbackStaff->state = 0xFF; + AudioOcarina_SetInstrumentId(OCARINA_INSTRUMENT_OFF); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gakufu/func_80AFCC58.s") + songIndex = this->songIndex; + ocarinaSongButtons = &gOcarinaSongButtons[songIndex]; + songNumButtons = gOcarinaSongButtons[this->songIndex].numButtons; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gakufu/func_80AFCD44.s") + for (i = 0; i < songNumButtons; i++) { + this->buttonIndex[i] = ocarinaSongButtons->buttonIndex[i]; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gakufu/func_80AFCDC8.s") + for (; i < ARRAY_COUNT(this->buttonIndex); i++) { + this->buttonIndex[i] = OCARINA_BTN_INVALID; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gakufu/EnGakufu_Update.s") +void EnGakufu_Init(Actor* thisx, GlobalContext* globalCtx) { + EnGakufu* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gakufu/EnGakufu_Draw.s") + this->songIndex = OCARINA_SONG_TERMINA_WALL; + EnGakufu_ProcessNotes(this); + Actor_SetScale(&this->actor, 1.0f); + + if (GAKUFU_GET_TYPE(&this->actor) == GAKUFU_MILK_BAR) { + this->actor.draw = NULL; + this->actionFunc = EnGakufu_WaitForTimer; + return; + } + + this->actor.flags &= ~ACTOR_FLAG_2000000; + + if (EnGakufu_IsPlayerInRange(this, globalCtx)) { + gSaveContext.eventInf[3] |= 2; + } else { + gSaveContext.eventInf[3] &= (u8)~2; + } + + this->actionFunc = EnGakufu_WaitForSong; + gSaveContext.eventInf[3] &= (u8)~4; +} + +void EnGakufu_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnGakufu* this = THIS; + + if (GAKUFU_GET_TYPE(&this->actor) != GAKUFU_MILK_BAR) { + gSaveContext.eventInf[3] &= (u8)~2; + } +} + +/** + * Special behaviour for the Milk Bar: + * this->actor.home.rot.x acts as a timer. Draws the notes on the back of the stage + * until the timer runs out + */ +void EnGakufu_DisplayOnTimer(EnGakufu* this, GlobalContext* globalCtx) { + if (this->actor.home.rot.x > 0) { + this->actor.draw = EnGakufu_Draw; + this->actor.home.rot.x--; + } else { + this->actor.draw = NULL; + this->actor.home.rot.x = 0; + this->actionFunc = EnGakufu_WaitForTimer; + } +} + +/** + * Special behaviour for the Milk Bar: + * this->actor.home.rot.x acts as a timer. Waits for this timer to be set, + * then rerolls the notes and start displaying the notes + */ +void EnGakufu_WaitForTimer(EnGakufu* this, GlobalContext* globalCtx) { + if (this->actor.home.rot.x > 0) { + EnGakufu_ProcessNotes(this); + this->actionFunc = EnGakufu_DisplayOnTimer; + } +} + +void EnGakufu_DoNothing(EnGakufu* this, GlobalContext* globalCtx) { +} + +s32 EnGakufu_IsPlayerInRange(EnGakufu* this, GlobalContext* globalCtx) { + if (this->actor.xzDistToPlayer < 600.0f) { + return true; + } else { + return false; + } +} + +/** + * Reward the player with three item drops depending on the time of day + */ +void EnGakufu_GiveReward(EnGakufu* this, GlobalContext* globalCtx) { + s32 hour; + s32 i; + + play_sound(NA_SE_SY_CORRECT_CHIME); + + hour = gSaveContext.save.time * (24.0f / 0x10000); + for (i = 0; i < 3; i++) { + Item_DropCollectible(globalCtx, &sRewardDropsSpawnTerminaFieldPos, sRewardDrops[i + sRewardDropsIndex[hour]]); + } + + this->actionFunc = EnGakufu_DoNothing; +} + +void EnGakufu_PlayRewardCutscene(EnGakufu* this, GlobalContext* globalCtx) { + if (this->actor.cutscene == -1) { + EnGakufu_GiveReward(this, globalCtx); + } else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + EnGakufu_GiveReward(this, globalCtx); + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } +} + +/** + * Waits for the notes on the wall to be played and updates the corresponding flags + * (gSaveContext.eventInf[3] & 2) is checking if Player is within range of the wall + * (gSaveContext.eventInf[3] & 4) is checking if Player has played the notes of the wall + */ +void EnGakufu_WaitForSong(EnGakufu* this, GlobalContext* globalCtx) { + if (gSaveContext.eventInf[3] & 2) { + if (gSaveContext.eventInf[3] & 4) { + gSaveContext.eventInf[3] &= (u8)~2; + gSaveContext.eventInf[3] &= (u8)~4; + + this->actionFunc = EnGakufu_PlayRewardCutscene; + EnGakufu_PlayRewardCutscene(this, globalCtx); + this->actor.draw = NULL; + } else if (!EnGakufu_IsPlayerInRange(this, globalCtx)) { + gSaveContext.eventInf[3] &= (u8)~2; + } + } else if (EnGakufu_IsPlayerInRange(this, globalCtx)) { + gSaveContext.eventInf[3] |= 2; + } +} + +void EnGakufu_Update(Actor* thisx, GlobalContext* globalCtx) { + EnGakufu* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void EnGakufu_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 i; + s32 pad; + EnGakufu* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gDPPipeSync(POLY_XLU_DISP++); + gSPSegment(POLY_XLU_DISP++, 0x02, globalCtx->interfaceCtx.parameterSegment); + + for (i = 0; (i < ARRAY_COUNT(this->buttonIndex)) && (this->buttonIndex[i] != OCARINA_BTN_INVALID); i++) { + Matrix_StatePush(); + Matrix_InsertTranslation(30 * i - 105, sOcarinaBtnWallYOffsets[this->buttonIndex[i]] * 7.5f, 1.0f, + MTXMODE_APPLY); + Matrix_Scale(0.6f, 0.6f, 0.6f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetTextureLUT(POLY_XLU_DISP++, G_TT_NONE); + gDPLoadTextureBlock(POLY_XLU_DISP++, sOcarinaBtnWallTextures[this->buttonIndex[i]], G_IM_FMT_IA, G_IM_SIZ_8b, + 16, 16, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, 4, 4, G_TX_NOLOD, + G_TX_NOLOD); + + if (this->buttonIndex[i] == OCARINA_BTN_A) { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 80, 150, 255, 200); + } else { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 50, 200); + } + + gSPDisplayList(POLY_XLU_DISP++, gGakufuButtonIndexDL); + + Matrix_StatePop(); + } + + gSPSegment(POLY_XLU_DISP++, 0x02, globalCtx->sceneSegment); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.h b/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.h index b4bf8643c7..9ba96a7246 100644 --- a/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.h +++ b/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.h @@ -7,10 +7,18 @@ struct EnGakufu; typedef void (*EnGakufuActionFunc)(struct EnGakufu*, GlobalContext*); +#define GAKUFU_GET_TYPE(thisx) ((thisx)->params & 0xF) + +typedef enum { + /* 0x00 */ GAKUFU_TERMINA_FIELD, + /* 0x01 */ GAKUFU_MILK_BAR +} GakufuType; + typedef struct EnGakufu { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xC]; - /* 0x0150 */ EnGakufuActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ s32 songIndex; + /* 0x148 */ u8 buttonIndex[8]; + /* 0x150 */ EnGakufuActionFunc actionFunc; } EnGakufu; // size = 0x154 extern const ActorInit En_Gakufu_InitVars; diff --git a/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c b/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c index 4427bd3b19..947afd914e 100644 --- a/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c +++ b/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c @@ -120,8 +120,8 @@ s32 func_80B0F660(EnGb2* this, GlobalContext* globalCtx) { } void func_80B0F6DC(EnGb2* this) { - if (!(gSaveContext.weekEventReg[54] & 0x20)) { - gSaveContext.weekEventReg[54] |= 0x20; + if (!(gSaveContext.save.weekEventReg[54] & 0x20)) { + gSaveContext.save.weekEventReg[54] |= 0x20; this->unk_26E = 0x14D0; } else { this->unk_26E = 0x14D1; @@ -163,7 +163,7 @@ u16 func_80B0F7FC(EnGb2* this) { return 0x14E4; } - if (gSaveContext.health > 48) { + if (gSaveContext.save.playerData.health > 48) { return 0x14D2; } @@ -171,7 +171,7 @@ u16 func_80B0F7FC(EnGb2* this) { return 0x14D3; case 0x14E4: - if (gSaveContext.health > 48) { + if (gSaveContext.save.playerData.health > 48) { return 0x14D2; } @@ -208,7 +208,7 @@ u16 func_80B0F8F8(EnGb2* this) { case 0x14DE: this->unk_26C |= 2; - gSaveContext.weekEventReg[54] |= 0x80; + gSaveContext.save.weekEventReg[54] |= 0x80; return 0x14DF; case 0x14E1: @@ -226,7 +226,7 @@ u16 func_80B0F97C(EnGb2* this) { return 0x14F7; case 0x14F7: - gSaveContext.weekEventReg[76] |= 0x80; + gSaveContext.save.weekEventReg[76] |= 0x80; this->unk_26C |= 2; return 0x14F8; @@ -259,7 +259,7 @@ s32 func_80B0FA48(EnGb2* this, GlobalContext* globalCtx) { return false; case PLAYER_MASK_CAPTAIN: - if (!(gSaveContext.weekEventReg[80] & 0x40)) { + if (!(gSaveContext.save.weekEventReg[80] & 0x40)) { this->unk_26E = 0x14EB; return false; } @@ -267,7 +267,7 @@ s32 func_80B0FA48(EnGb2* this, GlobalContext* globalCtx) { return true; } - if (!(gSaveContext.weekEventReg[80] & 0x20)) { + if (!(gSaveContext.save.weekEventReg[80] & 0x20)) { this->unk_26E = 0x14EF; return false; } else { @@ -389,7 +389,7 @@ void func_80B0FFA8(EnGb2* this, GlobalContext* globalCtx) { u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); if (temp_v0 == 5) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (this->unk_26C & 2) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; @@ -403,11 +403,11 @@ void func_80B0FFA8(EnGb2* this, GlobalContext* globalCtx) { Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); } } - } else if ((temp_v0 == 4) && func_80147624(globalCtx)) { + } else if ((temp_v0 == 4) && Message_ShouldAdvance(globalCtx)) { if (this->unk_26E == 0x14D5) { switch (globalCtx->msgCtx.choiceIndex) { case 0: - if (gSaveContext.rupees < this->unk_288) { + if (gSaveContext.save.playerData.rupees < this->unk_288) { play_sound(NA_SE_SY_ERROR); this->unk_26E = 0x14D7; this->unk_26C |= 2; @@ -505,7 +505,7 @@ void func_80B10344(EnGb2* this, GlobalContext* globalCtx) { } } - if (gSaveContext.health < 49) { + if (gSaveContext.save.playerData.health < 49) { gSaveContext.unk_3DD0[1] = 5; gSaveContext.eventInf[4] |= 0x40; gSaveContext.eventInf[4] |= 0x20; @@ -551,7 +551,7 @@ void func_80B10634(EnGb2* this, GlobalContext* globalCtx) { u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); if (temp_v0 == 5) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (this->unk_26C & 2) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; @@ -572,10 +572,10 @@ void func_80B10634(EnGb2* this, GlobalContext* globalCtx) { Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); } } - } else if ((temp_v0 == 4) && func_80147624(globalCtx)) { + } else if ((temp_v0 == 4) && Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: - if (gSaveContext.rupees < this->unk_288) { + if (gSaveContext.save.playerData.rupees < this->unk_288) { play_sound(NA_SE_SY_ERROR); this->unk_26E = 0x14D7; this->unk_26C |= 2; @@ -617,7 +617,7 @@ void func_80B10868(EnGb2* this, GlobalContext* globalCtx) { void func_80B10924(EnGb2* this, GlobalContext* globalCtx) { s32 sp24; - if (gSaveContext.weekEventReg[54] & 0x40) { + if (gSaveContext.save.weekEventReg[54] & 0x40) { sp24 = 5; } else { sp24 = 12; @@ -626,7 +626,7 @@ void func_80B10924(EnGb2* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { this->actor.parent = NULL; if (sp24 == 12) { - gSaveContext.weekEventReg[54] |= 0x40; + gSaveContext.save.weekEventReg[54] |= 0x40; } else { func_801159EC(50); } @@ -706,9 +706,9 @@ void func_80B10B5C(EnGb2* this, GlobalContext* globalCtx) { this->actor.flags &= ~ACTOR_FLAG_10000; Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); if (this->unk_26E == 0x14EB) { - gSaveContext.weekEventReg[80] |= 0x40; + gSaveContext.save.weekEventReg[80] |= 0x40; } else if (this->unk_26E == 0x14EF) { - gSaveContext.weekEventReg[80] |= 0x20; + gSaveContext.save.weekEventReg[80] |= 0x20; } this->unk_26C &= ~0x20; this->unk_290 = 0; @@ -746,7 +746,7 @@ void func_80B10DAC(EnGb2* this, GlobalContext* globalCtx) { } void func_80B10E98(EnGb2* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { if (this->unk_26C & 2) { this->unk_26C &= ~2; globalCtx->msgCtx.msgMode = 0x43; @@ -790,7 +790,7 @@ void func_80B11048(EnGb2* this, GlobalContext* globalCtx) { } void func_80B110F8(EnGb2* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { if (this->unk_26C & 2) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; @@ -885,13 +885,13 @@ void EnGb2_Init(Actor* thisx, GlobalContext* globalCtx) { switch (ENGB2_GET_7(&this->actor)) { case ENGB2_7_0: - if (gSaveContext.weekEventReg[54] & 0x80) { + if (gSaveContext.save.weekEventReg[54] & 0x80) { Actor_MarkForDeath(&this->actor); - } else if (gSaveContext.weekEventReg[52] & 0x20) { + } else if (gSaveContext.save.weekEventReg[52] & 0x20) { Actor_MarkForDeath(&this->actor); } - if (gSaveContext.entranceIndex == 0x9C10) { + if (gSaveContext.save.entranceIndex == 0x9C10) { func_800FE484(); this->actionFunc = func_80B10240; break; @@ -910,7 +910,7 @@ void EnGb2_Init(Actor* thisx, GlobalContext* globalCtx) { break; case ENGB2_7_1: - if ((globalCtx->curSpawn == 1) || (gSaveContext.weekEventReg[80] & 0x80)) { + if ((globalCtx->curSpawn == 1) || (gSaveContext.save.weekEventReg[80] & 0x80)) { Actor_MarkForDeath(&this->actor); return; } @@ -940,7 +940,7 @@ void EnGb2_Init(Actor* thisx, GlobalContext* globalCtx) { return; } - if (gSaveContext.weekEventReg[76] & 0x80) { + if (gSaveContext.save.weekEventReg[76] & 0x80) { this->actor.draw = NULL; this->unk_26C |= 0x100; this->actor.flags &= ~ACTOR_FLAG_1; @@ -982,7 +982,6 @@ s32 EnGb2_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, EnGb2* this = THIS; if (limbIndex == 7) { - limbIndex = limbIndex; Matrix_RotateY(this->unk_270.y, MTXMODE_APPLY); } diff --git a/src/overlays/actors/ovl_En_Geg/z_en_geg.c b/src/overlays/actors/ovl_En_Geg/z_en_geg.c index 60c5ebdb68..d022058dd8 100644 --- a/src/overlays/actors/ovl_En_Geg/z_en_geg.c +++ b/src/overlays/actors/ovl_En_Geg/z_en_geg.c @@ -452,7 +452,7 @@ void func_80BB221C(EnGeg* this, GlobalContext* globalCtx) { } } else { this->unk_230 &= ~4; - if (gSaveContext.weekEventReg[35] & 0x40) { + if (gSaveContext.save.weekEventReg[35] & 0x40) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) && (this->unk_230 & 8)) { this->unk_496 = 0xD62; Message_StartTextbox(globalCtx, this->unk_496, &this->actor); @@ -463,7 +463,7 @@ void func_80BB221C(EnGeg* this, GlobalContext* globalCtx) { this->unk_230 |= 8; } } else if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) && (this->unk_230 & 8)) { - gSaveContext.weekEventReg[35] |= 0x40; + gSaveContext.save.weekEventReg[35] |= 0x40; this->unk_496 = 0xD5E; this->unk_49A = this->unk_49C[0]; Message_StartTextbox(globalCtx, this->unk_496, &this->actor); @@ -542,7 +542,7 @@ void func_80BB2520(EnGeg* this, GlobalContext* globalCtx) { } void func_80BB26EC(EnGeg* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { switch (this->unk_496) { case 0xD5E: this->unk_49A = this->unk_49C[1]; @@ -564,7 +564,7 @@ void func_80BB26EC(EnGeg* this, GlobalContext* globalCtx) { } void func_80BB27D4(EnGeg* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { switch (this->unk_496) { case 0xD63: globalCtx->msgCtx.msgMode = 0x43; @@ -615,7 +615,7 @@ void func_80BB2944(EnGeg* this, GlobalContext* globalCtx) { this->unk_4AC = 6; func_80BB2020(this, globalCtx); } - } else if ((sp27 == 5) && func_80147624(globalCtx)) { + } else if ((sp27 == 5) && Message_ShouldAdvance(globalCtx)) { if (this->unk_496 == 0xD67) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; @@ -629,7 +629,7 @@ void func_80BB2944(EnGeg* this, GlobalContext* globalCtx) { } void func_80BB2A54(EnGeg* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { if (this->unk_496 == 0xD65) { ActorCutscene_Stop(this->unk_498); this->unk_230 &= ~0x10; @@ -655,7 +655,7 @@ void func_80BB2B1C(EnGeg* this, GlobalContext* globalCtx) { if (ActorCutscene_GetCurrentIndex() != this->unk_49C[4]) { if (ActorCutscene_GetCanPlayNext(this->unk_498)) { - gSaveContext.weekEventReg[37] |= 8; + gSaveContext.save.weekEventReg[37] |= 8; if (this->actor.child != NULL) { Actor_MarkForDeath(this->actor.child); } @@ -797,7 +797,7 @@ void func_80BB31B8(EnGeg* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { this->actor.parent = NULL; - gSaveContext.weekEventReg[61] |= 1; + gSaveContext.save.weekEventReg[61] |= 1; if (getItemId == GI_MASK_DON_GERO) { this->unk_230 |= 0x40; } @@ -860,7 +860,7 @@ void EnGeg_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad2; s32 sp34[] = { 0x3E, 0xF64 }; - if (gSaveContext.weekEventReg[61] & 1) { + if (gSaveContext.save.weekEventReg[61] & 1) { Actor_MarkForDeath(&this->actor); return; } diff --git a/src/overlays/actors/ovl_En_Gg/z_en_gg.c b/src/overlays/actors/ovl_En_Gg/z_en_gg.c index c9b6435f5c..3d80cc8474 100644 --- a/src/overlays/actors/ovl_En_Gg/z_en_gg.c +++ b/src/overlays/actors/ovl_En_Gg/z_en_gg.c @@ -129,7 +129,7 @@ s32 func_80B34FB4(EnGg* this, GlobalContext* globalCtx) { pitch = Math_Vec3f_Pitch(&sp34, &sp40); if ((this->actor.xzDistToPlayer < 250.0f) && (this->actor.xzDistToPlayer > 50.0f) && - (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80) || (gSaveContext.weekEventReg[19] & 0x80))) { + (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80) || (gSaveContext.save.weekEventReg[19] & 0x80))) { Math_SmoothStepToS(&this->unk_2E8, pitch, 4, 0x2AA8, 1); } else { Math_SmoothStepToS(&this->unk_2E8, 0, 4, 0x2AA8, 1); @@ -212,7 +212,7 @@ void func_80B352A4(EnGg* this, GlobalContext* globalCtx) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); break; } - gSaveContext.weekEventReg[19] |= 0x80; + gSaveContext.save.weekEventReg[19] |= 0x80; this->actionFunc = func_80B3556C; } else if ((this->unk_2E6 == 0) && ((this->actor.textId == 0xCED) || (this->actor.textId == 0xCEE))) { if (sp26 < (lastFrame - 1)) { @@ -225,21 +225,21 @@ void func_80B352A4(EnGg* this, GlobalContext* globalCtx) { } void func_80B35450(EnGg* this, GlobalContext* globalCtx) { - if ((gSaveContext.weekEventReg[91] & 0x10) && (globalCtx->csCtx.state == 0)) { + if ((gSaveContext.save.weekEventReg[91] & 0x10) && (globalCtx->csCtx.state == 0)) { func_80B359DC(this, globalCtx); } if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - if CHECK_FLAG_ALL (this->actor.flags, ACTOR_FLAG_80) { + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80)) { func_800B90F4(globalCtx); } this->unk_308 = 1; this->actionFunc = func_80B352A4; } else if ((this->actor.xzDistToPlayer < 200.0f) && (this->actor.xzDistToPlayer > 50.0f)) { - if (gSaveContext.weekEventReg[19] & 0x80) { + if (gSaveContext.save.weekEventReg[19] & 0x80) { func_800B863C(&this->actor, globalCtx); this->actor.textId = 0xCEE; - } else if CHECK_FLAG_ALL (this->actor.flags, ACTOR_FLAG_80) { + } else if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80)) { func_800B863C(&this->actor, globalCtx); this->actor.textId = 0xCE5; } @@ -247,7 +247,7 @@ void func_80B35450(EnGg* this, GlobalContext* globalCtx) { } void func_80B3556C(EnGg* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { if (this->unk_2E6 == 4) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; @@ -400,8 +400,8 @@ void func_80B359DC(EnGg* this, GlobalContext* globalCtx) { if ((player->transformation == PLAYER_FORM_HUMAN) && (globalCtx->msgCtx.ocarinaMode == 3) && (globalCtx->msgCtx.unk1202E == 7)) { - if (!(gSaveContext.weekEventReg[19] & 0x80)) { - gSaveContext.weekEventReg[19] |= 0x80; + if (!(gSaveContext.save.weekEventReg[19] & 0x80)) { + gSaveContext.save.weekEventReg[19] |= 0x80; } this->unk_307 = true; } @@ -661,9 +661,9 @@ void EnGg_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); - gSaveContext.weekEventReg[20] &= (u8)~4; - gSaveContext.weekEventReg[20] &= (u8)~8; - gSaveContext.weekEventReg[20] &= (u8)~0x10; + gSaveContext.save.weekEventReg[20] &= (u8)~4; + gSaveContext.save.weekEventReg[20] &= (u8)~8; + gSaveContext.save.weekEventReg[20] &= (u8)~0x10; this->actor.flags &= ~ACTOR_FLAG_80; this->unk_310 = this->actor.home.pos.y; this->unk_2DC = this->actor.cutscene; @@ -691,7 +691,7 @@ void EnGg_Update(Actor* thisx, GlobalContext* globalCtx) { this->actor.flags &= ~ACTOR_FLAG_1; } - if (gSaveContext.weekEventReg[19] & 0x80) { + if (gSaveContext.save.weekEventReg[19] & 0x80) { if (globalCtx->csCtx.state == 0) { this->actor.flags |= ACTOR_FLAG_1; } else { @@ -709,10 +709,10 @@ void EnGg_Update(Actor* thisx, GlobalContext* globalCtx) { func_80B35968(this, globalCtx); } - if (!(gSaveContext.weekEventReg[91] & 0x10) && - ((gSaveContext.weekEventReg[19] & 0x80) || CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80) || + if (!(gSaveContext.save.weekEventReg[91] & 0x10) && + ((gSaveContext.save.weekEventReg[19] & 0x80) || CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80) || (this->unk_308 == 1))) { - gSaveContext.weekEventReg[91] |= 0x10; + gSaveContext.save.weekEventReg[91] |= 0x10; } this->actionFunc(this, globalCtx); @@ -790,7 +790,7 @@ void EnGg_Draw(Actor* thisx, GlobalContext* globalCtx) { this->unk_344.unk_38(&this->unk_344, globalCtx); } - if (gSaveContext.weekEventReg[19] & 0x80) { + if (gSaveContext.save.weekEventReg[19] & 0x80) { func_8012C28C(globalCtx->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80B36DFC[this->unk_2E2])); diff --git a/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c b/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c index 252853a249..ebe127fcff 100644 --- a/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c +++ b/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c @@ -172,7 +172,7 @@ void func_80B3B05C(EnGg2* this, GlobalContext* globalCtx) { } void func_80B3B0A0(EnGg2* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; this->unk_2F0 = 0; @@ -214,17 +214,17 @@ void func_80B3B294(EnGg2* this, GlobalContext* globalCtx) { if (this->unk_2F1 == 0) { if (globalCtx->sceneNum == SCENE_11GORONNOSATO) { - gSaveContext.weekEventReg[20] |= 4; - gSaveContext.weekEventReg[20] &= (u8)~8; - gSaveContext.weekEventReg[20] &= (u8)~0x10; + gSaveContext.save.weekEventReg[20] |= 4; + gSaveContext.save.weekEventReg[20] &= (u8)~8; + gSaveContext.save.weekEventReg[20] &= (u8)~0x10; } else if (globalCtx->sceneNum == SCENE_17SETUGEN) { - gSaveContext.weekEventReg[20] &= (u8)~4; - gSaveContext.weekEventReg[20] |= 8; - gSaveContext.weekEventReg[20] &= (u8)~0x10; + gSaveContext.save.weekEventReg[20] &= (u8)~4; + gSaveContext.save.weekEventReg[20] |= 8; + gSaveContext.save.weekEventReg[20] &= (u8)~0x10; } else if (globalCtx->sceneNum == SCENE_10YUKIYAMANOMURA) { - gSaveContext.weekEventReg[20] &= (u8)~4; - gSaveContext.weekEventReg[20] &= (u8)~8; - gSaveContext.weekEventReg[20] |= 0x10; + gSaveContext.save.weekEventReg[20] &= (u8)~4; + gSaveContext.save.weekEventReg[20] &= (u8)~8; + gSaveContext.save.weekEventReg[20] |= 0x10; } if (this->unk_1D8 != NULL) { @@ -240,17 +240,17 @@ void func_80B3B294(EnGg2* this, GlobalContext* globalCtx) { } else { this->unk_2F1 = 1; if (globalCtx->sceneNum == SCENE_11GORONNOSATO) { - gSaveContext.weekEventReg[20] |= 4; - gSaveContext.weekEventReg[20] &= (u8)~8; - gSaveContext.weekEventReg[20] &= (u8)~0x10; + gSaveContext.save.weekEventReg[20] |= 4; + gSaveContext.save.weekEventReg[20] &= (u8)~8; + gSaveContext.save.weekEventReg[20] &= (u8)~0x10; } else if (globalCtx->sceneNum == SCENE_17SETUGEN) { - gSaveContext.weekEventReg[20] &= (u8)~4; - gSaveContext.weekEventReg[20] |= 8; - gSaveContext.weekEventReg[20] &= (u8)~0x10; + gSaveContext.save.weekEventReg[20] &= (u8)~4; + gSaveContext.save.weekEventReg[20] |= 8; + gSaveContext.save.weekEventReg[20] &= (u8)~0x10; } else if (globalCtx->sceneNum == SCENE_10YUKIYAMANOMURA) { - gSaveContext.weekEventReg[20] &= (u8)~4; - gSaveContext.weekEventReg[20] &= (u8)~8; - gSaveContext.weekEventReg[20] |= 0x10; + gSaveContext.save.weekEventReg[20] &= (u8)~4; + gSaveContext.save.weekEventReg[20] &= (u8)~8; + gSaveContext.save.weekEventReg[20] |= 0x10; } } } @@ -360,7 +360,7 @@ void EnGg2_Init(Actor* thisx, GlobalContext* globalCtx2) { return; } - if (gSaveContext.weekEventReg[91] & 0x10) { + if (gSaveContext.save.weekEventReg[91] & 0x10) { Actor_MarkForDeath(&this->actor); return; } @@ -369,7 +369,7 @@ void EnGg2_Init(Actor* thisx, GlobalContext* globalCtx2) { this->actor.bgCheckFlags |= 0x400; SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_gg_Skel_00F6C0, &object_gg_Anim_00F578, this->jointTable, this->morphTable, 20); - this->unk_1D8 = func_8013D648(globalCtx, ENGG2_GET_FC00(&this->actor), 0x3F); + this->unk_1D8 = SubS_GetPathByIndex(globalCtx, ENGG2_GET_FC00(&this->actor), 0x3F); this->actor.flags &= ~ACTOR_FLAG_80; this->unk_2F0 = 0; this->unk_2F1 = 0; @@ -381,16 +381,16 @@ void EnGg2_Init(Actor* thisx, GlobalContext* globalCtx2) { this->unk_2EA = 0; if (globalCtx->sceneNum == SCENE_11GORONNOSATO) { - gSaveContext.weekEventReg[20] &= (u8)~4; - gSaveContext.weekEventReg[20] &= (u8)~8; - gSaveContext.weekEventReg[20] &= (u8)~0x10; + gSaveContext.save.weekEventReg[20] &= (u8)~4; + gSaveContext.save.weekEventReg[20] &= (u8)~8; + gSaveContext.save.weekEventReg[20] &= (u8)~0x10; this->unk_2EE = 0; Actor_ChangeAnimationByInfo(&this->skelAnime, D_80B3BF00, 0); this->actionFunc = func_80B3AFB0; } else if (globalCtx->sceneNum == SCENE_17SETUGEN) { - if ((gSaveContext.weekEventReg[20] & 4) && !(gSaveContext.weekEventReg[20] & 8) && - !(gSaveContext.weekEventReg[20] & 0x10)) { - gSaveContext.weekEventReg[20] &= (u8)~4; + if ((gSaveContext.save.weekEventReg[20] & 4) && !(gSaveContext.save.weekEventReg[20] & 8) && + !(gSaveContext.save.weekEventReg[20] & 0x10)) { + gSaveContext.save.weekEventReg[20] &= (u8)~4; this->unk_2EE = 8; Actor_ChangeAnimationByInfo(&this->skelAnime, D_80B3BF00, 0); this->actionFunc = func_80B3B05C; @@ -398,9 +398,9 @@ void EnGg2_Init(Actor* thisx, GlobalContext* globalCtx2) { Actor_MarkForDeath(&this->actor); } } else if (globalCtx->sceneNum == SCENE_10YUKIYAMANOMURA) { - if (!(gSaveContext.weekEventReg[20] & 4) && (gSaveContext.weekEventReg[20] & 8) && - !(gSaveContext.weekEventReg[20] & 0x10)) { - gSaveContext.weekEventReg[20] &= (u8)~8; + if (!(gSaveContext.save.weekEventReg[20] & 4) && (gSaveContext.save.weekEventReg[20] & 8) && + !(gSaveContext.save.weekEventReg[20] & 0x10)) { + gSaveContext.save.weekEventReg[20] &= (u8)~8; this->unk_2EE = 8; Actor_ChangeAnimationByInfo(&this->skelAnime, D_80B3BF00, 0); this->actionFunc = func_80B3B05C; @@ -408,9 +408,9 @@ void EnGg2_Init(Actor* thisx, GlobalContext* globalCtx2) { Actor_MarkForDeath(&this->actor); } } else { - gSaveContext.weekEventReg[20] &= (u8)~4; - gSaveContext.weekEventReg[20] &= (u8)~8; - gSaveContext.weekEventReg[20] &= (u8)~0x10; + gSaveContext.save.weekEventReg[20] &= (u8)~4; + gSaveContext.save.weekEventReg[20] &= (u8)~8; + gSaveContext.save.weekEventReg[20] &= (u8)~0x10; Actor_MarkForDeath(&this->actor); } } diff --git a/src/overlays/actors/ovl_En_Giant/z_en_giant.c b/src/overlays/actors/ovl_En_Giant/z_en_giant.c index c509db2b8c..90d945e2a0 100644 --- a/src/overlays/actors/ovl_En_Giant/z_en_giant.c +++ b/src/overlays/actors/ovl_En_Giant/z_en_giant.c @@ -183,10 +183,11 @@ void EnGiant_Init(Actor* thisx, GlobalContext* globalCtx) { } if (GIANT_TYPE_IS_CLOCK_TOWER_SUCCESS(type)) { - if (!(gSaveContext.weekEventReg[25] & 2)) { + if (!(gSaveContext.save.weekEventReg[25] & 2)) { Actor_MarkForDeath(&this->actor); return; } + this->actorActionCommand = 0x1C5; Actor_SetScale(&this->actor, 0.32f); this->actionFunc = EnGiant_PerformClockTowerSuccessActions; diff --git a/src/overlays/actors/ovl_En_Ginko_Man/z_en_ginko_man.c b/src/overlays/actors/ovl_En_Ginko_Man/z_en_ginko_man.c index fe480fb14f..34b0e36b48 100644 --- a/src/overlays/actors/ovl_En_Ginko_Man/z_en_ginko_man.c +++ b/src/overlays/actors/ovl_En_Ginko_Man/z_en_ginko_man.c @@ -81,13 +81,13 @@ void EnGinkoMan_Idle(EnGinkoMan* this, GlobalContext* globalCtx) { EnGinkoMan_SwitchAnimation(this, globalCtx); if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - if ((gSaveContext.bankRupees & 0xFFFF) == 0) { + if ((gSaveContext.save.bankRupees & 0xFFFF) == 0) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_FLOORSMACKING); Message_StartTextbox(globalCtx, 0x44C, &this->actor); this->curTextId = 0x44C; // would you like to make an account } else { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); - if ((CURRENT_DAY == 3) && (gSaveContext.isNight == 1)) { + if ((CURRENT_DAY == 3) && (gSaveContext.save.isNight == true)) { Message_StartTextbox(globalCtx, 0x467, &this->actor); this->curTextId = 0x467; // "What's this? You need somethin' on a day like this? } else { @@ -103,14 +103,14 @@ void EnGinkoMan_Idle(EnGinkoMan* this, GlobalContext* globalCtx) { // action func: non-input dialogue void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { - if (!func_80147624(globalCtx)) { + if (!Message_ShouldAdvance(globalCtx)) { return; } switch (this->curTextId) { case 0x44C: // "Hey there, little guy! Won't you deposit some Rupees? (first dialogue) Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); - if (gSaveContext.weekEventReg[10] & 8) { + if (gSaveContext.save.weekEventReg[10] & 8) { Message_StartTextbox(globalCtx, 0x44E, &this->actor); this->curTextId = 0x44E; //" ...So, what'll it be? Deposit Rupees Don't deposit Rupees" } else { @@ -145,7 +145,7 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_FLOORSMACKING); } - globalCtx->msgCtx.bankRupees = gSaveContext.bankRupees & 0xFFFF; + globalCtx->msgCtx.bankRupees = gSaveContext.save.bankRupees & 0xFFFF; Message_StartTextbox(globalCtx, 0x45A, &this->actor); this->curTextId = 0x45A; // "All right, little guy, now I've got a total of [rupees] from you!" } @@ -156,22 +156,22 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { this->curTextId = 0x44E; //" ...So, what'll it be? Deposit Rupees Don't deposit Rupees" break; case 0x45A: // "All right, little guy, now I've got a total of [rupees] from you!" - if (((gSaveContext.bankRupees & 0xFFFF) >= 200) && (this->previousBankValue < 200) && - !(gSaveContext.weekEventReg[59] & 0x40)) { - gSaveContext.weekEventReg[59] |= 0x40; + if (((gSaveContext.save.bankRupees & 0xFFFF) >= 200) && (this->previousBankValue < 200) && + !(gSaveContext.save.weekEventReg[59] & 0x40)) { + gSaveContext.save.weekEventReg[59] |= 0x40; Message_StartTextbox(globalCtx, 0x45B, &this->actor); this->curTextId = 0x45B; // "What's this? You've already saved up 200 Rupees!?! - } else if (((gSaveContext.bankRupees & 0xFFFF) >= 1000) && ((this->previousBankValue) < 1000) && - !(gSaveContext.weekEventReg[59] & 0x80)) { - gSaveContext.weekEventReg[59] |= 0x80; + } else if (((gSaveContext.save.bankRupees & 0xFFFF) >= 1000) && ((this->previousBankValue) < 1000) && + !(gSaveContext.save.weekEventReg[59] & 0x80)) { + gSaveContext.save.weekEventReg[59] |= 0x80; Message_StartTextbox(globalCtx, 0x45C, &this->actor); this->curTextId = 0x45C; // "What's this? You've already saved up 1000 Rupees!?! - } else if ((gSaveContext.bankRupees & 0xFFFF) >= 5000) { - if ((this->previousBankValue < 5000) && !(gSaveContext.weekEventReg[60] & 1)) { - gSaveContext.weekEventReg[60] |= 1; + } else if ((gSaveContext.save.bankRupees & 0xFFFF) >= 5000) { + if ((this->previousBankValue < 5000) && !(gSaveContext.save.weekEventReg[60] & 1)) { + gSaveContext.save.weekEventReg[60] |= 1; Message_StartTextbox(globalCtx, 0x45D, &this->actor); this->curTextId = 0x45D; // "What's this? You've already saved up 5000 Rupees?! - } else if (this->previousBankValue < (s16)(gSaveContext.bankRupees & 0xFFFF)) { + } else if (this->previousBankValue < (s16)(gSaveContext.save.bankRupees & 0xFFFF)) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); Message_StartTextbox(globalCtx, 0x45E, &this->actor); this->curTextId = @@ -213,7 +213,7 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { break; case 0x465: // "There! Now I'll know you when I see you!" Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_FLOORSMACKING); - globalCtx->msgCtx.bankRupees = gSaveContext.bankRupees & 0xFFFF; + globalCtx->msgCtx.bankRupees = gSaveContext.save.bankRupees & 0xFFFF; Message_StartTextbox(globalCtx, 0x45A, &this->actor); this->curTextId = 0x45A; // "All right, little guy, now I've got a total of [rupees] from you!" break; @@ -229,10 +229,10 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { case 0x46C: // "Ah, yes...[Link], right? If I remember, you're the little guy who deposited [rupees]." case 0x47E: // "Your deposits total [rupees]." if (this->choiceDepositWithdrawl == GINKOMAN_CHOICE_DEPOSIT) { - if ((u32)(gSaveContext.bankRupees & 0xFFFF) >= 5000) { + if ((u32)(gSaveContext.save.bankRupees & 0xFFFF) >= 5000) { Message_StartTextbox(globalCtx, 0x45F, &this->actor); this->curTextId = 0x45F; // "Excuuuse me! But I can't take anymore deposits! - } else if (gSaveContext.rupees == 0) { + } else if (gSaveContext.save.playerData.rupees == 0) { Message_StartTextbox(globalCtx, 0x458, &this->actor); this->curTextId = 0x458; // "Hmm...You play mean jokes, little guy! You haven't even got a single Rupee! @@ -240,7 +240,7 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { Message_StartTextbox(globalCtx, 0x479, &this->actor); this->curTextId = 0x479; // "Well, are you gonna make a deposit?" } - } else if ((CURRENT_DAY == 3) && (gSaveContext.isNight == 1)) { + } else if ((CURRENT_DAY == 3) && (gSaveContext.save.isNight == true)) { Message_StartTextbox(globalCtx, 0x46D, &this->actor); // "Look, little guy, if it's 'cause of the bad rumors going around, forget it! They're just rumors!" this->curTextId = 0x46D; @@ -261,7 +261,7 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { this->curTextId = 0x46B; // So... break; case 0x470: // "Is that so? Come back and deposit some after saving up a bunch!" - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); this->isStampChecked = false; EnGinkoMan_SetupIdle(this); // change to waiting for approach @@ -280,12 +280,12 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { case 0x473: // Use it wisely... case 0x474: // "Aw, you're taking out all that? If you spend it like that, it'll all be gone before you know // it!" - if ((gSaveContext.bankRupees & 0xFFFF) == 0) { + if ((gSaveContext.save.bankRupees & 0xFFFF) == 0) { Message_StartTextbox(globalCtx, 0x478, &this->actor); // "Look, little guy, all the Rupees you deposited are gone, so you can't use that stamp anymore." this->curTextId = 0x478; } else { - globalCtx->msgCtx.bankRupees = gSaveContext.bankRupees & 0xFFFF; + globalCtx->msgCtx.bankRupees = gSaveContext.save.bankRupees & 0xFFFF; Message_StartTextbox(globalCtx, 0x45A, &this->actor); this->curTextId = 0x45A; // "All right, little guy, now I've got a total of [rupees] from you!" } @@ -304,19 +304,19 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { // actionfunc: wait for player dialogue input void EnGinkoMan_WaitForDialogueInput(EnGinkoMan* this, GlobalContext* globalCtx) { - if (!func_80147624(globalCtx)) { + if (!Message_ShouldAdvance(globalCtx)) { return; } switch (this->curTextId) { case 0x44E: // "...So, what'll it be? if (globalCtx->msgCtx.choiceIndex == GINKOMAN_CHOICE_YES) { - if ((gSaveContext.bankRupees & 0xFFFF) >= 5000) { + if ((gSaveContext.save.bankRupees & 0xFFFF) >= 5000) { play_sound(NA_SE_SY_ERROR); Message_StartTextbox(globalCtx, 0x45F, &this->actor); this->curTextId = 0x45F; // bank full, cannot accept more } else { - if (gSaveContext.rupees > 0) { + if (gSaveContext.save.playerData.rupees > 0) { func_8019F208(); Message_StartTextbox(globalCtx, 0x44F, &this->actor); this->curTextId = 0x44F; // "All right! so..." @@ -334,7 +334,7 @@ void EnGinkoMan_WaitForDialogueInput(EnGinkoMan* this, GlobalContext* globalCtx) break; case 0x452: // Really? are you really depositing rupees? if (globalCtx->msgCtx.choiceIndex == GINKOMAN_CHOICE_YES) { - if (gSaveContext.rupees < globalCtx->msgCtx.bankRupeesSelected) { + if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.bankRupeesSelected) { play_sound(NA_SE_SY_ERROR); Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); Message_StartTextbox(globalCtx, 0x459, &this->actor); @@ -353,20 +353,20 @@ void EnGinkoMan_WaitForDialogueInput(EnGinkoMan* this, GlobalContext* globalCtx) this->curTextId = 0x453; // That's it? That aint nothing at all } - if ((gSaveContext.bankRupees & 0xFFFF) == 0) { + if ((gSaveContext.save.bankRupees & 0xFFFF) == 0) { this->isNewAccount = true; } func_801159EC((s16)-globalCtx->msgCtx.bankRupeesSelected); - this->previousBankValue = gSaveContext.bankRupees & 0xFFFF; - gSaveContext.bankRupees = - ((gSaveContext.bankRupees & 0xFFFF) + globalCtx->msgCtx.bankRupeesSelected) | - (gSaveContext.bankRupees & 0xFFFF0000); + this->previousBankValue = gSaveContext.save.bankRupees & 0xFFFF; + gSaveContext.save.bankRupees = + ((gSaveContext.save.bankRupees & 0xFFFF) + globalCtx->msgCtx.bankRupeesSelected) | + (gSaveContext.save.bankRupees & 0xFFFF0000); } } else { // GINKOMAN_CHOICE_NO func_8019F230(); Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); - if ((gSaveContext.bankRupees & 0xFFFF) == 0) { + if ((gSaveContext.save.bankRupees & 0xFFFF) == 0) { Message_StartTextbox(globalCtx, 0x456, &this->actor); this->curTextId = 0x456; // Is that so? think about it } else { @@ -395,13 +395,14 @@ void EnGinkoMan_WaitForDialogueInput(EnGinkoMan* this, GlobalContext* globalCtx) break; case 0x471: // Are you really withdrawling [selected rupees]? if (globalCtx->msgCtx.choiceIndex == GINKOMAN_CHOICE_YES) { - if ((s32)((gSaveContext.bankRupees & 0xFFFF)) < + if ((s32)((gSaveContext.save.bankRupees & 0xFFFF)) < ((s32)(globalCtx->msgCtx.bankRupeesSelected + this->serviceFee))) { play_sound(NA_SE_SY_ERROR); Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_FLOORSMACKING); Message_StartTextbox(globalCtx, 0x476, &this->actor); this->curTextId = 0x476; // you dont have enough deposited to withdrawl - } else if (CUR_CAPACITY(UPG_WALLET) < (globalCtx->msgCtx.bankRupeesSelected + gSaveContext.rupees)) { + } else if (CUR_CAPACITY(UPG_WALLET) < + (globalCtx->msgCtx.bankRupeesSelected + gSaveContext.save.playerData.rupees)) { // check if wallet is big enough play_sound(NA_SE_SY_ERROR); Message_StartTextbox(globalCtx, 0x475, &this->actor); @@ -419,11 +420,11 @@ void EnGinkoMan_WaitForDialogueInput(EnGinkoMan* this, GlobalContext* globalCtx) this->curTextId = 0x472; // It's a waste to take out such a tiny bit } - this->previousBankValue = (s16)(gSaveContext.bankRupees & 0xFFFF); - gSaveContext.bankRupees = - (((gSaveContext.bankRupees & 0xFFFF) - globalCtx->msgCtx.bankRupeesSelected) - + this->previousBankValue = (s16)(gSaveContext.save.bankRupees & 0xFFFF); + gSaveContext.save.bankRupees = + (((gSaveContext.save.bankRupees & 0xFFFF) - globalCtx->msgCtx.bankRupeesSelected) - this->serviceFee) | - (gSaveContext.bankRupees & 0xFFFF0000); + (gSaveContext.save.bankRupees & 0xFFFF0000); func_801159EC(globalCtx->msgCtx.bankRupeesSelected); } } else { @@ -436,7 +437,7 @@ void EnGinkoMan_WaitForDialogueInput(EnGinkoMan* this, GlobalContext* globalCtx) } void EnGinkoMan_WaitForRupeeCount(EnGinkoMan* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->curTextId) { case 0x450: // "How much? How much?" [rupee prompt] Set the amount with [Control Stick] and if (globalCtx->msgCtx.bankRupeesSelected == 0) { @@ -452,7 +453,7 @@ void EnGinkoMan_WaitForRupeeCount(EnGinkoMan* this, GlobalContext* globalCtx) { if (globalCtx->msgCtx.bankRupeesSelected == 0) { Message_StartTextbox(globalCtx, 0x46F, &this->actor); this->curTextId = 0x46F; // "Zero Rupees?!? That's a cruel joke!" - } else if (gSaveContext.isNight == 1) { + } else if (gSaveContext.save.isNight == true) { Message_StartTextbox(globalCtx, 0x477, &this->actor); this->curTextId = 0x477; // "...You know, at this time of day there's a 4 Rupee service charge... } else { @@ -481,7 +482,7 @@ void EnGinkoMan_Dialogue(EnGinkoMan* this, GlobalContext* globalCtx) { EnGinkoMan_DepositDialogue(this, globalCtx); break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { this->isStampChecked = false; EnGinkoMan_SetupIdle(this); } @@ -510,14 +511,14 @@ void EnGinkoMan_BankAward(EnGinkoMan* this, GlobalContext* globalCtx) { this->actor.parent = NULL; EnGinkoMan_SetupBankAward2(this); } else if (this->curTextId == 0x45B) { // "Whats this, you already saved up 200?" - if (!(gSaveContext.weekEventReg[10] & 8)) { + if (!(gSaveContext.save.weekEventReg[10] & 8)) { Actor_PickUp(&this->actor, globalCtx, GI_WALLET_ADULT + CUR_UPG_VALUE(UPG_WALLET), 500.0f, 100.0f); } else { Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_BLUE, 500.0f, 100.0f); } } else if (this->curTextId == 0x45C) { // "Whats this, you already saved up 5000?" Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_BLUE, 500.0f, 100.0f); - } else if (!(gSaveContext.weekEventReg[59] & 8)) { + } else if (!(gSaveContext.save.weekEventReg[59] & 8)) { Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 500.0f, 100.0f); } else { Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_BLUE, 500.0f, 100.0f); @@ -532,10 +533,10 @@ void EnGinkoMan_SetupBankAward2(EnGinkoMan* this) { // separate function to handle bank rewards... called while the player is receiving the award void EnGinkoMan_BankAward2(EnGinkoMan* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - if (!(gSaveContext.weekEventReg[10] & 8) && (this->curTextId == 0x45B)) { + if (!(gSaveContext.save.weekEventReg[10] & 8) && (this->curTextId == 0x45B)) { // "What's this? You've already saved up 200 Rupees!?! Well, little guy, here's your special gift. Take // it!" - gSaveContext.weekEventReg[10] |= 8; + gSaveContext.save.weekEventReg[10] |= 8; Message_StartTextbox(globalCtx, 0x47A, &this->actor); this->curTextId = 0x47A; // Message after receiving reward for depositing 200 rupees. } else { @@ -546,9 +547,9 @@ void EnGinkoMan_BankAward2(EnGinkoMan* this, GlobalContext* globalCtx) { EnGinkoMan_SetupDialogue(this); } else if (this->curTextId == 0x45D) { // saved up 5000 rupees for HP - if ((Message_GetState(&globalCtx->msgCtx) == 6) && func_80147624(globalCtx)) { - if (!(gSaveContext.weekEventReg[59] & 8)) { - gSaveContext.weekEventReg[59] |= 8; + if ((Message_GetState(&globalCtx->msgCtx) == 6) && Message_ShouldAdvance(globalCtx)) { + if (!(gSaveContext.save.weekEventReg[59] & 8)) { + gSaveContext.save.weekEventReg[59] |= 8; } EnGinkoMan_SetupIdle(this); } @@ -577,8 +578,8 @@ void EnGinkoMan_Stamp(EnGinkoMan* this, GlobalContext* globalCtx) { break; case 0x469: // "Excuse me, but let me take a look at you..." Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); - globalCtx->msgCtx.bankRupees = (gSaveContext.bankRupees & 0xFFFF); - if ((CURRENT_DAY == 3) && (gSaveContext.isNight == 1)) { + globalCtx->msgCtx.bankRupees = (gSaveContext.save.bankRupees & 0xFFFF); + if ((CURRENT_DAY == 3) && (gSaveContext.save.isNight == true)) { Message_StartTextbox(globalCtx, 0x46C, &this->actor); this->curTextId = 0x46C; // "Ah, yes...[Link], right? } else { diff --git a/src/overlays/actors/ovl_En_GirlA/z_en_girla.c b/src/overlays/actors/ovl_En_GirlA/z_en_girla.c index 2142ca5f02..26cdc2df70 100644 --- a/src/overlays/actors/ovl_En_GirlA/z_en_girla.c +++ b/src/overlays/actors/ovl_En_GirlA/z_en_girla.c @@ -159,8 +159,8 @@ void EnGirlA_SetupAction(EnGirlA* this, EnGirlAActionFunc action) { void EnGirlA_InitObjIndex(EnGirlA* this, GlobalContext* globalCtx) { s16 params = this->actor.params; - //! @bug: Condition is impossible - if (params >= 43 && params < 0) { + //! @bug: Condition is impossible, && should be an || + if (params >= SI_MAX && params < SI_POTION_RED_1) { Actor_MarkForDeath(&this->actor); return; } @@ -188,7 +188,7 @@ s32 EnGirlA_CanBuyPotionRed(GlobalContext* globalCtx, EnGirlA* this) { if (!Interface_HasEmptyBottle()) { return CANBUY_RESULT_NEED_EMPTY_BOTTLE; } - if (gSaveContext.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_2; @@ -198,46 +198,46 @@ s32 EnGirlA_CanBuyPotionGreen(GlobalContext* globalCtx, EnGirlA* this) { if (!Interface_HasEmptyBottle()) { return CANBUY_RESULT_NEED_EMPTY_BOTTLE; } - if (gSaveContext.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_2; } s32 EnGirlA_CanBuyPotionBlue(GlobalContext* globalCtx, EnGirlA* this) { - if (!(gSaveContext.weekEventReg[53] & 8)) { + if (!(gSaveContext.save.weekEventReg[53] & 8)) { return CANBUY_RESULT_CANNOT_GET_NOW; } if (!Interface_HasEmptyBottle()) { return CANBUY_RESULT_NEED_EMPTY_BOTTLE; } - if (!(gSaveContext.weekEventReg[53] & 0x10)) { + if (!(gSaveContext.save.weekEventReg[53] & 0x10)) { return CANBUY_RESULT_SUCCESS_2; } - if (gSaveContext.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_2; } s32 EnGirlA_CanBuyArrows(GlobalContext* globalCtx, EnGirlA* this) { - if (CUR_UPG_VALUE_VOID(UPG_QUIVER) == 0) { + if (GET_CUR_UPG_VALUE(UPG_QUIVER) == 0) { return CANBUY_RESULT_CANNOT_GET_NOW_2; } if (AMMO(ITEM_BOW) >= CUR_CAPACITY(UPG_QUIVER)) { return CANBUY_RESULT_NO_ROOM_2; } - if (gSaveContext.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_2; } s32 EnGirlA_CanBuyNuts(GlobalContext* globalCtx, EnGirlA* this) { - if (CUR_CAPACITY(UPG_NUTS) != 0 && AMMO(ITEM_NUT) >= CUR_CAPACITY(UPG_NUTS)) { + if (CUR_CAPACITY(UPG_NUTS) != 0 && CUR_CAPACITY(UPG_NUTS) <= AMMO(ITEM_NUT)) { return CANBUY_RESULT_NO_ROOM; } - if (gSaveContext.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } if (func_80114978(ITEM_NUT) == ITEM_NONE) { @@ -247,10 +247,10 @@ s32 EnGirlA_CanBuyNuts(GlobalContext* globalCtx, EnGirlA* this) { } s32 EnGirlA_CanBuyShieldHero(GlobalContext* globalCtx, EnGirlA* this) { - if (CUR_EQUIP_VALUE_VOID(EQUIP_SHIELD) != 0) { + if (GET_CUR_EQUIP_VALUE(EQUIP_SHIELD) != 0) { return CANBUY_RESULT_NO_ROOM; } - if (gSaveContext.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_1; @@ -260,7 +260,7 @@ s32 EnGirlA_CanBuyStick(GlobalContext* globalCtx, EnGirlA* this) { if (CUR_CAPACITY(UPG_STICKS) != 0 && AMMO(ITEM_STICK) >= CUR_CAPACITY(UPG_STICKS)) { return CANBUY_RESULT_NO_ROOM; } - if (gSaveContext.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } if (func_80114978(ITEM_STICK) == ITEM_NONE) { @@ -270,56 +270,56 @@ s32 EnGirlA_CanBuyStick(GlobalContext* globalCtx, EnGirlA* this) { } s32 EnGirlA_CanBuyMaskAllNight(GlobalContext* globalCtx, EnGirlA* this) { - if (gSaveContext.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_2; } s32 EnGirlA_CanBuyBombBagCuriosityShop(GlobalContext* globalCtx, EnGirlA* this) { - if (CUR_UPG_VALUE_VOID(UPG_BOMB_BAG) >= 2) { + if (GET_CUR_UPG_VALUE(UPG_BOMB_BAG) >= 2) { return CANBUY_RESULT_CANNOT_GET_NOW; } - if (gSaveContext.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_2; } s32 EnGirlA_CanBuyBombBag20BombShop(GlobalContext* globalCtx, EnGirlA* this) { - if (CUR_UPG_VALUE_VOID(UPG_BOMB_BAG) == 1) { + if (GET_CUR_UPG_VALUE(UPG_BOMB_BAG) == 1) { return CANBUY_RESULT_ALREADY_HAVE; } - if (CUR_UPG_VALUE_VOID(UPG_BOMB_BAG) >= 2) { + if (GET_CUR_UPG_VALUE(UPG_BOMB_BAG) >= 2) { return CANBUY_RESULT_HAVE_BETTER; } - if (gSaveContext.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_1; } s32 EnGirlA_CanBuyBombBag30BombShop(GlobalContext* globalCtx, EnGirlA* this) { - if (CUR_UPG_VALUE_VOID(UPG_BOMB_BAG) == 2) { + if (GET_CUR_UPG_VALUE(UPG_BOMB_BAG) == 2) { return CANBUY_RESULT_ALREADY_HAVE; } - if (CUR_UPG_VALUE_VOID(UPG_BOMB_BAG) == 3) { + if (GET_CUR_UPG_VALUE(UPG_BOMB_BAG) == 3) { return CANBUY_RESULT_HAVE_BETTER; } - if (gSaveContext.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_1; } s32 EnGirlA_CanBuyBombchus(GlobalContext* globalCtx, EnGirlA* this) { - if (CUR_UPG_VALUE_VOID(UPG_BOMB_BAG) == 0) { + if (GET_CUR_UPG_VALUE(UPG_BOMB_BAG) == 0) { return CANBUY_RESULT_CANNOT_GET_NOW; } if (AMMO(ITEM_BOMBCHU) >= CUR_CAPACITY(UPG_BOMB_BAG)) { return CANBUY_RESULT_NO_ROOM; } - if (gSaveContext.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } if (func_80114978(ITEM_BOMBCHU) == ITEM_NONE) { @@ -329,37 +329,37 @@ s32 EnGirlA_CanBuyBombchus(GlobalContext* globalCtx, EnGirlA* this) { } s32 EnGirlA_CanBuyBombs(GlobalContext* globalCtx, EnGirlA* this) { - if (CUR_UPG_VALUE_VOID(UPG_BOMB_BAG) == 0) { + if (GET_CUR_UPG_VALUE(UPG_BOMB_BAG) == 0) { return CANBUY_RESULT_CANNOT_GET_NOW; } if (AMMO(ITEM_BOMB) >= CUR_CAPACITY(UPG_BOMB_BAG)) { return CANBUY_RESULT_NO_ROOM; } - if (gSaveContext.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_2; } s32 EnGirlA_CanBuyBottleStolen(GlobalContext* globalCtx, EnGirlA* this) { - if (gSaveContext.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_1; } s32 EnGirlA_CanBuySword(GlobalContext* globalCtx, EnGirlA* this) { - if (gSaveContext.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_1; } s32 EnGirlA_CanBuyShieldMirror(GlobalContext* globalCtx, EnGirlA* this) { - if (CUR_EQUIP_VALUE_VOID(EQUIP_SHIELD) != 0) { + if (GET_CUR_EQUIP_VALUE(EQUIP_SHIELD) != 0) { return CANBUY_RESULT_NO_ROOM; } - if (gSaveContext.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_1; @@ -369,7 +369,7 @@ s32 EnGirlA_CanBuyFairy(GlobalContext* globalCtx, EnGirlA* this) { if (!Interface_HasEmptyBottle()) { return CANBUY_RESULT_NEED_EMPTY_BOTTLE; } - if (gSaveContext.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_2; @@ -377,24 +377,24 @@ s32 EnGirlA_CanBuyFairy(GlobalContext* globalCtx, EnGirlA* this) { void EnGirlA_BuyBottleItem(GlobalContext* globalCtx, EnGirlA* this) { switch (this->actor.params) { - case 0: - case 10: - case 18: - case 29: - case 32: - case 35: + case SI_POTION_RED_1: + case SI_POTION_RED_2: + case SI_POTION_RED_3: + case SI_POTION_RED_4: + case SI_POTION_RED_5: + case SI_POTION_RED_6: Item_Give(globalCtx, ITEM_POTION_RED); break; - case 1: - case 5: - case 14: + case SI_POTION_GREEN_1: + case SI_POTION_GREEN_2: + case SI_POTION_GREEN_3: Item_Give(globalCtx, ITEM_POTION_GREEN); break; - case 2: + case SI_POTION_BLUE: Item_Give(globalCtx, ITEM_POTION_BLUE); break; - case 3: - case 11: + case SI_FAIRY_1: + case SI_FAIRY_2: Item_Give(globalCtx, ITEM_FAIRY); break; } diff --git a/src/overlays/actors/ovl_En_GirlA/z_en_girla.h b/src/overlays/actors/ovl_En_GirlA/z_en_girla.h index fa2711501b..a3d8e02061 100644 --- a/src/overlays/actors/ovl_En_GirlA/z_en_girla.h +++ b/src/overlays/actors/ovl_En_GirlA/z_en_girla.h @@ -25,7 +25,7 @@ typedef struct ShopItemEntry { typedef struct EnGirlA { /* 0x000 */ Actor actor; - /* 0x144 */ char unk144[0x44]; + /* 0x144 */ UNK_TYPE1 unk144[0x44]; /* 0x188 */ EnGirlAActionFunc actionFunc; /* 0x18C */ s8 objIndex; /* 0x190 */ EnGirlAActionFunc mainActionFunc; @@ -103,7 +103,8 @@ typedef enum { /* 39 */ SI_SWORD_RAZOR, /* 40 */ SI_SWORD_GILDED, /* 41 */ SI_SHIELD_HERO_4, - /* 42 */ SI_SHIELD_MIRROR + /* 42 */ SI_SHIELD_MIRROR, + /* 43 */ SI_MAX } EnGirlAShopItemId; extern const ActorInit En_GirlA_InitVars; @@ -122,7 +123,7 @@ typedef struct { /* 0x28 */ f32 arrowTexX; /* 0x2C */ f32 arrowTexY; /* 0x30 */ f32 texZ; // Used for both stickTexZ and arrowTexZ - /* 0x34 */ s32 isEnabled; + /* 0x34 */ u32 isEnabled; } StickDirectionPrompt; // size = 0x38 typedef struct ShopItem { diff --git a/src/overlays/actors/ovl_En_Gk/z_en_gk.c b/src/overlays/actors/ovl_En_Gk/z_en_gk.c index 4f2d774980..059f18c9c2 100644 --- a/src/overlays/actors/ovl_En_Gk/z_en_gk.c +++ b/src/overlays/actors/ovl_En_Gk/z_en_gk.c @@ -120,7 +120,7 @@ u16 func_80B50410(EnGk* this, GlobalContext* globalCtx) { if (globalCtx->sceneNum == SCENE_17SETUGEN2) { if (player->transformation == PLAYER_FORM_GORON) { - if (!(gSaveContext.weekEventReg[40] & 0x80)) { + if (!(gSaveContext.save.weekEventReg[40] & 0x80)) { switch (this->unk_31C) { case 0xE7A: return 0xE7B; @@ -133,7 +133,7 @@ u16 func_80B50410(EnGk* this, GlobalContext* globalCtx) { case 0xE7E: return 0xE7F; case 0xE7F: - gSaveContext.weekEventReg[40] |= 0x80; + gSaveContext.save.weekEventReg[40] |= 0x80; this->unk_1E4 |= 1; return 0xE80; default: @@ -143,7 +143,7 @@ u16 func_80B50410(EnGk* this, GlobalContext* globalCtx) { this->unk_1E4 |= 1; return 0xE81; } - } else if (!(gSaveContext.weekEventReg[41] & 1)) { + } else if (!(gSaveContext.save.weekEventReg[41] & 1)) { switch (this->unk_31C) { case 0xE82: return 0xE83; @@ -154,7 +154,7 @@ u16 func_80B50410(EnGk* this, GlobalContext* globalCtx) { case 0xE7E: return 0xE7F; case 0xE7F: - gSaveContext.weekEventReg[41] |= 1; + gSaveContext.save.weekEventReg[41] |= 1; this->unk_1E4 |= 1; return 0xE80; default: @@ -166,12 +166,12 @@ u16 func_80B50410(EnGk* this, GlobalContext* globalCtx) { } } else if (globalCtx->sceneNum == SCENE_GORONRACE) { if (player->transformation == PLAYER_FORM_GORON) { - if (!(gSaveContext.weekEventReg[41] & 4)) { + if (!(gSaveContext.save.weekEventReg[41] & 4)) { if (this->unk_31C == 0xE88) { - if (!(gSaveContext.weekEventReg[41] & 8) || Interface_HasEmptyBottle()) { + if (!(gSaveContext.save.weekEventReg[41] & 8) || Interface_HasEmptyBottle()) { return 0xE89; } - gSaveContext.weekEventReg[41] |= 4; + gSaveContext.save.weekEventReg[41] |= 4; this->unk_1E4 |= 1; return 0xE94; } @@ -179,10 +179,10 @@ u16 func_80B50410(EnGk* this, GlobalContext* globalCtx) { } if ((this->unk_31C == 0xE8D) || (this->unk_31C == 0xE98)) { - if (!(gSaveContext.weekEventReg[41] & 8) || Interface_HasEmptyBottle()) { + if (!(gSaveContext.save.weekEventReg[41] & 8) || Interface_HasEmptyBottle()) { return 0xE89; } - gSaveContext.weekEventReg[41] |= 4; + gSaveContext.save.weekEventReg[41] |= 4; this->unk_1E4 |= 1; return 0xE94; } @@ -193,12 +193,12 @@ u16 func_80B50410(EnGk* this, GlobalContext* globalCtx) { return 0xE98; } - if (!(gSaveContext.weekEventReg[41] & 2)) { + if (!(gSaveContext.save.weekEventReg[41] & 2)) { switch (this->unk_31C) { case 0xE85: return 0xE86; case 0xE86: - gSaveContext.weekEventReg[41] |= 2; + gSaveContext.save.weekEventReg[41] |= 2; this->unk_1E4 |= 1; return 0xE87; default: @@ -216,7 +216,7 @@ u16 func_80B50410(EnGk* this, GlobalContext* globalCtx) { u16 func_80B50710(EnGk* this) { switch (this->unk_31C) { case 0xE8E: - gSaveContext.weekEventReg[41] |= 4; + gSaveContext.save.weekEventReg[41] |= 4; this->unk_1E4 &= ~0x10; this->unk_1E4 |= 1; return 0xE8F; @@ -225,7 +225,7 @@ u16 func_80B50710(EnGk* this) { return 0xE8B; case 0xE8B: - gSaveContext.weekEventReg[41] |= 4; + gSaveContext.save.weekEventReg[41] |= 4; this->unk_1E4 |= 0x10; this->unk_1E4 |= 1; return 0xE8C; @@ -633,7 +633,7 @@ void func_80B51760(EnGk* this, GlobalContext* globalCtx) { } } else { if (Flags_GetSwitch(globalCtx, ENGK_GET_3F00(&this->actor))) { - gSaveContext.weekEventReg[40] |= 0x40; + gSaveContext.save.weekEventReg[40] |= 0x40; this->actionFunc = func_80B51D9C; return; } @@ -648,7 +648,7 @@ void func_80B51760(EnGk* this, GlobalContext* globalCtx) { this->unk_1E4 |= 2; } } else if (((this->actor.xzDistToPlayer < 100.0f) || this->actor.isTargeted) && - (gSaveContext.entranceIndex != 0xD010)) { + (gSaveContext.save.entranceIndex != 0xD010)) { func_800B863C(&this->actor, globalCtx); } @@ -662,7 +662,7 @@ void func_80B51760(EnGk* this, GlobalContext* globalCtx) { void func_80B51970(EnGk* this, GlobalContext* globalCtx) { u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); - if (((temp_v0 == 6) || (temp_v0 == 5)) && func_80147624(globalCtx)) { + if (((temp_v0 == 6) || (temp_v0 == 5)) && Message_ShouldAdvance(globalCtx)) { if ((this->unk_31C == 0xE84) || (this->unk_31C == 0xE99)) { ActorCutscene_Stop(this->unk_318); this->unk_318 = ActorCutscene_GetAdditionalCutscene(this->unk_318); @@ -713,7 +713,7 @@ void func_80B51B40(EnGk* this, GlobalContext* globalCtx) { u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); if (temp_v0 == 6) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (this->unk_1E4 & 1) { this->unk_1E4 &= ~1; this->unk_1E4 &= ~4; @@ -727,8 +727,8 @@ void func_80B51B40(EnGk* this, GlobalContext* globalCtx) { globalCtx->sceneLoadFlag = 0x14; globalCtx->unk_1887F = 3; gSaveContext.nextTransition = 3; - Parameter_AddMagic(globalCtx, - ((void)0, gSaveContext.unk_3F30) + (gSaveContext.doubleMagic * 0x30) + 0x30); + Parameter_AddMagic(globalCtx, ((void)0, gSaveContext.unk_3F30) + + (gSaveContext.save.playerData.doubleMagic * 0x30) + 0x30); } else { this->actionFunc = func_80B51760; } @@ -741,7 +741,7 @@ void func_80B51B40(EnGk* this, GlobalContext* globalCtx) { this->unk_1E4 |= 2; } } - } else if ((temp_v0 == 4) && (func_80147624(globalCtx) != 0)) { + } else if ((temp_v0 == 4) && (Message_ShouldAdvance(globalCtx) != 0)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_8019F208(); @@ -833,7 +833,7 @@ void func_80B51EA4(EnGk* this, GlobalContext* globalCtx) { } void func_80B51FD0(EnGk* this, GlobalContext* globalCtx) { - if (!(gSaveContext.weekEventReg[22] & 4)) { + if (!(gSaveContext.save.weekEventReg[22] & 4)) { if (this->unk_1E4 & 2) { func_801A4748(&this->actor.projectedPos, NA_SE_EN_GOLON_KID_CRY - SFX_FLAG); } else { @@ -851,7 +851,7 @@ void func_80B5202C(EnGk* this, GlobalContext* globalCtx) { if (!func_80B50854(this, globalCtx)) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - gSaveContext.weekEventReg[24] |= 0x80; + gSaveContext.save.weekEventReg[24] |= 0x80; this->actionFunc = func_80B51698; } else if ((this->actor.xzDistToPlayer < 100.0f) || this->actor.isTargeted) { func_800B863C(&this->actor, globalCtx); @@ -874,7 +874,7 @@ void func_80B5202C(EnGk* this, GlobalContext* globalCtx) { } void func_80B5216C(EnGk* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; this->actionFunc = func_80B51698; @@ -900,7 +900,7 @@ void func_80B5227C(EnGk* this, GlobalContext* globalCtx) { func_800B14D4(globalCtx, 20.0f, &this->actor.home.pos); this->unk_350 = 60; if (!(this->unk_1E4 & 0x80)) { - gSaveContext.weekEventReg[22] |= 4; + gSaveContext.save.weekEventReg[22] |= 4; } Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_SIT_IMT); this->unk_350 = 0x4000; @@ -929,7 +929,7 @@ void func_80B52340(EnGk* this, GlobalContext* globalCtx) { } void func_80B52430(EnGk* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 6) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 6) && Message_ShouldAdvance(globalCtx)) { switch (this->unk_31C) { case 0xE93: this->unk_31C = 0xE89; @@ -960,7 +960,7 @@ void func_80B52430(EnGk* this, GlobalContext* globalCtx) { void func_80B5253C(EnGk* this, GlobalContext* globalCtx) { s32 sp24; - if (gSaveContext.weekEventReg[41] & 8) { + if (gSaveContext.save.weekEventReg[41] & 8) { sp24 = 0x93; } else { sp24 = 0x6A; @@ -969,7 +969,7 @@ void func_80B5253C(EnGk* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { this->actor.parent = NULL; if (sp24 == 0x6A) { - gSaveContext.weekEventReg[41] |= 8; + gSaveContext.save.weekEventReg[41] |= 8; } this->actionFunc = func_80B525E0; } else { @@ -990,7 +990,7 @@ void func_80B525E0(EnGk* this, GlobalContext* globalCtx) { void func_80B52654(EnGk* this, GlobalContext* globalCtx) { this->unk_350 += 0x400; if ((this->unk_1E4 & 0x80) && (globalCtx->csCtx.frames == 250)) { - gSaveContext.weekEventReg[22] |= 4; + gSaveContext.save.weekEventReg[22] |= 4; } this->unk_354 = Math_SinS(this->unk_350) * 0.006f * 0.06f; @@ -1028,14 +1028,14 @@ void EnGk_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_MarkForDeath(&this->actor); } else { this->unk_318 = this->actor.cutscene; - this->path = func_8013D648(globalCtx, ENGK_GET_F0(&this->actor), 15); + this->path = SubS_GetPathByIndex(globalCtx, ENGK_GET_F0(&this->actor), 15); this->actionFunc = func_80B51760; } } else if (globalCtx->sceneNum == SCENE_GORONRACE) { - if (gSaveContext.weekEventReg[33] & 0x80) { - if (gSaveContext.entranceIndex == 0xD010) { + if (gSaveContext.save.weekEventReg[33] & 0x80) { + if (gSaveContext.save.entranceIndex == 0xD010) { this->actionFunc = func_80B51760; - } else if (gSaveContext.entranceIndex == 0xD020) { + } else if (gSaveContext.save.entranceIndex == 0xD020) { this->actionFunc = func_80B52340; } else { this->actionFunc = func_80B51760; @@ -1047,7 +1047,7 @@ void EnGk_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_MarkForDeath(&this->actor); } } else if (ENGK_GET_F(&this->actor) == ENGK_F_2) { - if (!(gSaveContext.weekEventReg[22] & 4)) { + if (!(gSaveContext.save.weekEventReg[22] & 4)) { this->actionFunc = func_80B51FD0; this->actor.draw = NULL; this->actor.flags |= ACTOR_FLAG_10; @@ -1055,7 +1055,7 @@ void EnGk_Init(Actor* thisx, GlobalContext* globalCtx) { } else { Actor_MarkForDeath(&this->actor); } - } else if (!(gSaveContext.weekEventReg[22] & 4)) { + } else if (!(gSaveContext.save.weekEventReg[22] & 4)) { this->unk_2E4 = 0; this->unk_318 = this->actor.cutscene; this->actor.flags |= ACTOR_FLAG_10; @@ -1079,7 +1079,7 @@ void EnGk_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); if ((ENGK_GET_F(&this->actor) == ENGK_F_1) || - ((ENGK_GET_F(&this->actor) == ENGK_F_0) && !(gSaveContext.weekEventReg[22] & 4))) { + ((ENGK_GET_F(&this->actor) == ENGK_F_0) && !(gSaveContext.save.weekEventReg[22] & 4))) { func_80B507A0(this, globalCtx); SkelAnime_Update(&this->skelAnime); func_800E9250(globalCtx, &this->actor, &this->unk_1D8, &this->unk_1DE, this->actor.focus.pos); @@ -1238,7 +1238,7 @@ void EnGk_Draw(Actor* thisx, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); - if ((ENGK_GET_F(&this->actor) == ENGK_F_0) && (gSaveContext.weekEventReg[22] & 4)) { + if ((ENGK_GET_F(&this->actor) == ENGK_F_0) && (gSaveContext.save.weekEventReg[22] & 4)) { Matrix_InsertXRotation_s(-0x4000, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_En_Gm/z_en_gm.c b/src/overlays/actors/ovl_En_Gm/z_en_gm.c index 094de1c620..e598fe78f6 100644 --- a/src/overlays/actors/ovl_En_Gm/z_en_gm.c +++ b/src/overlays/actors/ovl_En_Gm/z_en_gm.c @@ -20,21 +20,102 @@ void EnGm_Draw(Actor* thisx, GlobalContext* globalCtx); void func_80950CDC(EnGm* this, GlobalContext* globalCtx); void func_80950DB8(EnGm* this, GlobalContext* globalCtx); -static u32 D_80951820[] = { - 0x0D000101, 0x360A0061, 0x25020600, 0x09001902, 0x0900090A, 0x0D02090A, 0x090F0105, 0x0E090A09, 0x0F0F0E09, - 0x00090A18, 0x0E060009, 0x00060A00, 0x6C490209, 0x0A090F3D, 0x02090F0A, 0x0031020A, 0x000A0525, 0x020C0F0C, - 0x1419020C, 0x140C320D, 0x020C320C, 0x3701050E, 0x0C320C37, 0x0C0E0C14, 0x0C32160E, 0x0C0F0C14, 0x0B0E0A00, - 0x0A050A0E, 0x090F0A00, 0x150E090A, 0x090F090B, 0x00120085, 0x020A000A, 0x0579020A, 0x050A0A6D, 0x020A0A0A, - 0x1E61020A, 0x1E0A2855, 0x020A280A, 0x2D49020A, 0x2D0A373D, 0x020A370B, 0x2D31020B, 0x2D0B3725, 0x020B370C, - 0x0019020C, 0x000C0F0D, 0x020C0F0C, 0x1401050E, 0x0C0F0C14, 0x110E0C00, 0x0C0F1D0E, 0x0B370C00, 0x130E0B2D, - 0x0B371C0E, 0x0A370B2D, 0x020E0A2D, 0x0A371B0E, 0x0A280A2D, 0x120E0A1E, 0x0A281A0E, 0x0A0A0A1E, 0x010E0A05, - 0x0A0A190E, 0x0A000A05, 0x100A0015, 0x31020C37, 0x0D002502, 0x0D000D19, 0x19020D19, 0x15050D02, 0x15370505, - 0x01050E15, 0x37050505, 0x0E0D1915, 0x05030E0D, 0x000D191E, 0x0E0C370D, 0x0014050D, 0x000200AB, 0x01320100, - 0x880A0061, 0x31020600, 0x12002502, 0x12001500, 0x19021500, 0x150A0D02, 0x150A150F, 0x01050E15, 0x0A150F0F, - 0x0E150015, 0x0A180E12, 0x00150006, 0x0E060012, 0x00070A00, 0x6C250215, 0x0A150F19, 0x02150F15, 0x190D0215, - 0x19151E01, 0x050E1519, 0x151E0E0E, 0x150F1519, 0x170E150A, 0x150F0D0A, 0x00152502, 0x151E152D, 0x1902152D, - 0x160A0D02, 0x160A0600, 0x01050E16, 0x0A060005, 0x0E152D16, 0x0A1E0E15, 0x1E152D14, 0x050A0061, 0x19020600, - 0x12000D02, 0x12000600, 0x01050E00, 0x00000008, 0x0E060012, 0x00070505, +static u8 D_80951820[] = { + /* 0x000 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_L(1, 0x13B - 0x005), + /* 0x005 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_YADOYA, 0x02E - 0x009), + /* 0x009 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(6, 0, 9, 0, 0x028 - 0x00F), + /* 0x00F */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(9, 0, 9, 10, 0x022 - 0x015), + /* 0x015 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(9, 10, 9, 15, 0x01C - 0x01B), + /* 0x01B */ SCHEDULE_CMD_RET_NONE(), + /* 0x01C */ SCHEDULE_CMD_RET_TIME(9, 10, 9, 15, 15), + /* 0x022 */ SCHEDULE_CMD_RET_TIME(9, 0, 9, 10, 24), + /* 0x028 */ SCHEDULE_CMD_RET_TIME(6, 0, 9, 0, 6), + /* 0x02E */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_TOWN, 0x07B - 0x032), + /* 0x032 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(9, 10, 9, 15, 0x075 - 0x038), + /* 0x038 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(9, 15, 10, 0, 0x06F - 0x03E), + /* 0x03E */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 0, 10, 5, 0x069 - 0x044), + /* 0x044 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(12, 15, 12, 20, 0x063 - 0x04A), + /* 0x04A */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(12, 20, 12, 50, 0x05D - 0x050), + /* 0x050 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(12, 50, 12, 55, 0x057 - 0x056), + /* 0x056 */ SCHEDULE_CMD_RET_NONE(), + /* 0x057 */ SCHEDULE_CMD_RET_TIME(12, 50, 12, 55, 12), + /* 0x05D */ SCHEDULE_CMD_RET_TIME(12, 20, 12, 50, 22), + /* 0x063 */ SCHEDULE_CMD_RET_TIME(12, 15, 12, 20, 11), + /* 0x069 */ SCHEDULE_CMD_RET_TIME(10, 0, 10, 5, 10), + /* 0x06F */ SCHEDULE_CMD_RET_TIME(9, 15, 10, 0, 21), + /* 0x075 */ SCHEDULE_CMD_RET_TIME(9, 10, 9, 15, 9), + /* 0x07B */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_L(SCENE_SONCHONOIE, 0x105 - 0x080), + /* 0x080 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 0, 10, 5, 0x0FF - 0x086), + /* 0x086 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 5, 10, 10, 0x0F9 - 0x08C), + /* 0x08C */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 10, 10, 30, 0x0F3 - 0x092), + /* 0x092 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 30, 10, 40, 0x0ED - 0x098), + /* 0x098 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 40, 10, 45, 0x0E7 - 0x09E), + /* 0x09E */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 45, 10, 55, 0x0E1 - 0x0A4), + /* 0x0A4 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 55, 11, 45, 0x0DB - 0x0AA), + /* 0x0AA */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(11, 45, 11, 55, 0x0D5 - 0x0B0), + /* 0x0B0 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(11, 55, 12, 0, 0x0CF - 0x0B6), + /* 0x0B6 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(12, 0, 12, 15, 0x0C9 - 0x0BC), + /* 0x0BC */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(12, 15, 12, 20, 0x0C3 - 0x0C2), + /* 0x0C2 */ SCHEDULE_CMD_RET_NONE(), + /* 0x0C3 */ SCHEDULE_CMD_RET_TIME(12, 15, 12, 20, 17), + /* 0x0C9 */ SCHEDULE_CMD_RET_TIME(12, 0, 12, 15, 29), + /* 0x0CF */ SCHEDULE_CMD_RET_TIME(11, 55, 12, 0, 19), + /* 0x0D5 */ SCHEDULE_CMD_RET_TIME(11, 45, 11, 55, 28), + /* 0x0DB */ SCHEDULE_CMD_RET_TIME(10, 55, 11, 45, 2), + /* 0x0E1 */ SCHEDULE_CMD_RET_TIME(10, 45, 10, 55, 27), + /* 0x0E7 */ SCHEDULE_CMD_RET_TIME(10, 40, 10, 45, 18), + /* 0x0ED */ SCHEDULE_CMD_RET_TIME(10, 30, 10, 40, 26), + /* 0x0F3 */ SCHEDULE_CMD_RET_TIME(10, 10, 10, 30, 1), + /* 0x0F9 */ SCHEDULE_CMD_RET_TIME(10, 5, 10, 10, 25), + /* 0x0FF */ SCHEDULE_CMD_RET_TIME(10, 0, 10, 5, 16), + /* 0x105 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_MILK_BAR, 0x13A - 0x109), + /* 0x109 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(12, 55, 13, 0, 0x134 - 0x10F), + /* 0x10F */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 0, 13, 25, 0x12E - 0x115), + /* 0x115 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 25, 21, 5, 0x128 - 0x11B), + /* 0x11B */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(21, 55, 5, 5, 0x122 - 0x121), + /* 0x121 */ SCHEDULE_CMD_RET_NONE(), + /* 0x122 */ SCHEDULE_CMD_RET_TIME(21, 55, 5, 5, 5), + /* 0x128 */ SCHEDULE_CMD_RET_TIME(13, 25, 21, 5, 3), + /* 0x12E */ SCHEDULE_CMD_RET_TIME(13, 0, 13, 25, 30), + /* 0x134 */ SCHEDULE_CMD_RET_TIME(12, 55, 13, 0, 20), + /* 0x13A */ SCHEDULE_CMD_RET_NONE(), + /* 0x13B */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_L(2, 0x1EB - 0x140), + /* 0x140 */ SCHEDULE_CMD_CHECK_FLAG_L(0x32, 0x01, 0x1CD - 0x145), + /* 0x145 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_YADOYA, 0x17A - 0x149), + /* 0x149 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(6, 0, 18, 0, 0x174 - 0x14F), + /* 0x14F */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(18, 0, 21, 0, 0x16E - 0x155), + /* 0x155 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(21, 0, 21, 10, 0x168 - 0x15B), + /* 0x15B */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(21, 10, 21, 15, 0x162 - 0x161), + /* 0x161 */ SCHEDULE_CMD_RET_NONE(), + /* 0x162 */ SCHEDULE_CMD_RET_TIME(21, 10, 21, 15, 15), + /* 0x168 */ SCHEDULE_CMD_RET_TIME(21, 0, 21, 10, 24), + /* 0x16E */ SCHEDULE_CMD_RET_TIME(18, 0, 21, 0, 6), + /* 0x174 */ SCHEDULE_CMD_RET_TIME(6, 0, 18, 0, 7), + /* 0x17A */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_TOWN, 0x1A3 - 0x17E), + /* 0x17E */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(21, 10, 21, 15, 0x19D - 0x184), + /* 0x184 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(21, 15, 21, 25, 0x197 - 0x18A), + /* 0x18A */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(21, 25, 21, 30, 0x191 - 0x190), + /* 0x190 */ SCHEDULE_CMD_RET_NONE(), + /* 0x191 */ SCHEDULE_CMD_RET_TIME(21, 25, 21, 30, 14), + /* 0x197 */ SCHEDULE_CMD_RET_TIME(21, 15, 21, 25, 23), + /* 0x19D */ SCHEDULE_CMD_RET_TIME(21, 10, 21, 15, 13), + /* 0x1A3 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_MILK_BAR, 0x1CC - 0x1A7), + /* 0x1A7 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(21, 30, 21, 45, 0x1C6 - 0x1AD), + /* 0x1AD */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(21, 45, 22, 10, 0x1C0 - 0x1B3), + /* 0x1B3 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(22, 10, 6, 0, 0x1BA - 0x1B9), + /* 0x1B9 */ SCHEDULE_CMD_RET_NONE(), + /* 0x1BA */ SCHEDULE_CMD_RET_TIME(22, 10, 6, 0, 5), + /* 0x1C0 */ SCHEDULE_CMD_RET_TIME(21, 45, 22, 10, 30), + /* 0x1C6 */ SCHEDULE_CMD_RET_TIME(21, 30, 21, 45, 20), + /* 0x1CC */ SCHEDULE_CMD_RET_NONE(), + /* 0x1CD */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_YADOYA, 0x1EA - 0x1D1), + /* 0x1D1 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(6, 0, 18, 0, 0x1E4 - 0x1D7), + /* 0x1D7 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(18, 0, 6, 0, 0x1DE - 0x1DD), + /* 0x1DD */ SCHEDULE_CMD_RET_NONE(), + /* 0x1DE */ SCHEDULE_CMD_RET_TIME(0, 0, 0, 0, 8), + /* 0x1E4 */ SCHEDULE_CMD_RET_TIME(6, 0, 18, 0, 7), + /* 0x1EA */ SCHEDULE_CMD_RET_NONE(), + /* 0x1EB */ SCHEDULE_CMD_RET_NONE(), }; static s32 D_80951A0C[] = { @@ -382,7 +463,7 @@ s32 func_8094E52C(EnGm* this, GlobalContext* globalCtx) { } case 2: - if (!(gSaveContext.weekEventReg[86] & 0x40) && (this->unk_3E0 == 2)) { + if (!(gSaveContext.save.weekEventReg[86] & 0x40) && (this->unk_3E0 == 2)) { ActorCutscene_Stop(sp2A); } else { Camera_SetTargetActor(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), &this->actor); @@ -552,8 +633,8 @@ s32 func_8094EB1C(EnGm* this, GlobalContext* globalCtx) { switch (this->unk_3E0) { case 0: - if ((gSaveContext.weekEventReg[50] & 1) || (gSaveContext.weekEventReg[51] & 0x80) || - (gSaveContext.weekEventReg[75] & 2)) { + if ((gSaveContext.save.weekEventReg[50] & 1) || (gSaveContext.save.weekEventReg[51] & 0x80) || + (gSaveContext.save.weekEventReg[75] & 2)) { ret = true; break; } @@ -659,14 +740,14 @@ s32 func_8094EE84(EnGm* this, GlobalContext* globalCtx) { this->actor.child = this->unk_268; this->unk_264 = func_8094EDBC(this, globalCtx); - if ((this->unk_258 == 5) && !(gSaveContext.weekEventReg[50] & 1) && - !(gSaveContext.weekEventReg[51] & 0x80) && !(gSaveContext.weekEventReg[75] & 2)) { + if ((this->unk_258 == 5) && !(gSaveContext.save.weekEventReg[50] & 1) && + !(gSaveContext.save.weekEventReg[51] & 0x80) && !(gSaveContext.save.weekEventReg[75] & 2)) { this->unk_3A4 |= 0x20; } else if ((this->unk_258 != 1) && (this->unk_258 != 5) && (this->unk_258 != 7)) { this->unk_3A4 |= 0x20; } - if ((this->unk_258 == 3) && (gSaveContext.weekEventReg[75] & 1)) { + if ((this->unk_258 == 3) && (gSaveContext.save.weekEventReg[75] & 1)) { this->unk_3A4 &= ~0x20; } @@ -778,7 +859,7 @@ void func_8094F2E8(EnGm* this) { void func_8094F3D0(EnGm* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 sp28 = Message_GetState(&globalCtx->msgCtx); - s32 var = globalCtx->msgCtx.unk11F04; + s32 var = globalCtx->msgCtx.currentTextId; if ((&this->actor == player->targetActor) && ((var < 0xFF) || (var > 0x200)) && (sp28 == 3) && (this->unk_3F0 == 3)) { @@ -807,7 +888,7 @@ s32 func_8094F4EC(EnGm* this, GlobalContext* globalCtx) { s32 func_8094F53C(EnGm* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - u16 sp32 = globalCtx->msgCtx.unk11F04; + u16 sp32 = globalCtx->msgCtx.currentTextId; Actor* al = func_8094DEE0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_AL); Actor* toto = func_8094DEE0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_TOTO); @@ -889,7 +970,7 @@ s32 func_8094F53C(EnGm* this, GlobalContext* globalCtx) { return false; } -s32 func_8094F7D0(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2, u8 arg3, s16 arg4) { +s32 func_8094F7D0(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2, u8 arg3, s16 arg4) { u8 sp4F = ENGM_GET_FF(&this->actor); Vec3s* sp48; Vec3f sp3C; @@ -901,8 +982,8 @@ s32 func_8094F7D0(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_234 = NULL; actor = func_8094DEE0(this, globalCtx, arg3, arg4); - if (D_80951A0C[arg2->unk0] >= 0) { - this->unk_234 = func_8013BB34(globalCtx, sp4F, D_80951A0C[arg2->unk0]); + if (D_80951A0C[arg2->result] >= 0) { + this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80951A0C[arg2->result]); } if ((actor != NULL) && (actor->update != NULL)) { @@ -919,8 +1000,8 @@ s32 func_8094F7D0(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_8094F904(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { - u16 sp56 = gSaveContext.time - 0x3FFC; +s32 func_8094F904(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { + u16 sp56 = SCHEDULE_TIME_NOW; u8 sp55 = ENGM_GET_FF(&this->actor); EnDoor* door; Vec3s* sp4C; @@ -930,10 +1011,10 @@ s32 func_8094F904(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar s32 ret = false; this->unk_234 = NULL; - door = func_8094DF90(globalCtx, arg2->unk0); + door = func_8094DF90(globalCtx, arg2->result); - if (D_80951A0C[arg2->unk0] >= 0) { - this->unk_234 = func_8013BB34(globalCtx, sp55, D_80951A0C[arg2->unk0]); + if (D_80951A0C[arg2->result] >= 0) { + this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp55, D_80951A0C[arg2->result]); } if ((door != NULL) && (door->dyna.actor.update != NULL)) { @@ -952,8 +1033,8 @@ s32 func_8094F904(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_261 = 75; } - this->unk_3B8 = arg2->unk8 - arg2->unk4; - this->unk_3BA = sp56 - arg2->unk4; + this->unk_3B8 = arg2->time1 - arg2->time0; + this->unk_3BA = sp56 - arg2->time0; this->actor.flags &= ~ACTOR_FLAG_1; this->unk_3A4 |= 0x100; this->unk_3A4 |= 0x200; @@ -965,16 +1046,16 @@ s32 func_8094F904(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_8094FAC4(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { - u16 sp2E = gSaveContext.time - 0x3FFC; +s32 func_8094FAC4(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { + u16 sp2E = SCHEDULE_TIME_NOW; u16 phi_v1; u8 sp2B = ENGM_GET_FF(&this->actor); s32 pad; s32 ret = false; this->unk_234 = NULL; - if (D_80951A0C[arg2->unk0] >= 0) { - this->unk_234 = func_8013BB34(globalCtx, sp2B, D_80951A0C[arg2->unk0]); + if (D_80951A0C[arg2->result] >= 0) { + this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp2B, D_80951A0C[arg2->result]); } if ((this->unk_234 != NULL) && (this->unk_234->count < 3)) { @@ -985,13 +1066,13 @@ s32 func_8094FAC4(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar if ((this->unk_258 < 9) && (this->unk_258 != 0) && (this->unk_3C4 >= 0)) { phi_v1 = sp2E; } else { - phi_v1 = arg2->unk4; + phi_v1 = arg2->time0; } - if (arg2->unk8 < phi_v1) { - this->unk_248 = (phi_v1 - arg2->unk8) + 0xFFFF; + if (arg2->time1 < phi_v1) { + this->unk_248 = (phi_v1 - arg2->time1) + 0xFFFF; } else { - this->unk_248 = arg2->unk8 - phi_v1; + this->unk_248 = arg2->time1 - phi_v1; } this->unk_254 = sp2E - phi_v1; @@ -1010,7 +1091,7 @@ s32 func_8094FAC4(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_8094FCC4(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_8094FCC4(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { static Vec3f D_80951D90 = { 64.0f, 0.0f, -122.0f }; s32 ret = false; @@ -1030,7 +1111,7 @@ s32 func_8094FCC4(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_8094FD88(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_8094FD88(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret = false; if (func_8094F7D0(this, globalCtx, arg2, ACTORCAT_NPC, ACTOR_EN_RECEPGIRL)) { @@ -1043,7 +1124,7 @@ s32 func_8094FD88(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_8094FE10(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_8094FE10(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret = false; Actor* al; @@ -1052,7 +1133,7 @@ s32 func_8094FE10(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar func_8094E054(this, globalCtx, 11); SubS_UpdateFlags(&this->unk_3A4, 3, 7); this->unk_268 = al; - if (!(gSaveContext.weekEventReg[86] & 0x20)) { + if (!(gSaveContext.save.weekEventReg[86] & 0x20)) { this->unk_3C8 = 2; this->unk_3CA = 2; this->unk_3CC = 8; @@ -1064,7 +1145,7 @@ s32 func_8094FE10(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_8094FF04(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_8094FF04(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { static Vec3f D_80951D9C = { 64.0f, 0.0f, -122.0f }; u8 sp4F = ENGM_GET_FF(&this->actor); Vec3s* sp48; @@ -1075,8 +1156,8 @@ s32 func_8094FF04(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_234 = NULL; - if (D_80951A0C[arg2->unk0] >= 0) { - this->unk_234 = func_8013BB34(globalCtx, sp4F, D_80951A0C[arg2->unk0]); + if (D_80951A0C[arg2->result] >= 0) { + this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80951A0C[arg2->result]); } if (this->unk_234 != NULL) { @@ -1106,7 +1187,7 @@ s32 func_8094FF04(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80950088(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80950088(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { static Vec3f D_80951DA8 = { 278.0f, 0.0f, 223.0f }; static Vec3s D_80951DB4 = { 0x0000, 0xC000, 0x0000 }; s32 pad; @@ -1121,7 +1202,7 @@ s32 func_80950088(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return true; } -s32 func_80950120(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80950120(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { static Vec3f D_80951DBC = { -525.0f, 214.0f, 515.0f }; static Vec3s D_80951DC8 = { 0x0000, 0x38E0, 0x0000 }; s32 pad; @@ -1136,7 +1217,7 @@ s32 func_80950120(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return true; } -s32 func_809501B8(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_809501B8(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { static Vec3f D_80951DD0 = { -334.0f, 225.0f, 903.0f }; static Vec3s D_80951DDC = { 0x0000, 0x7FFF, 0x0000 }; s32 pad; @@ -1157,7 +1238,7 @@ s32 func_809501B8(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return true; } -s32 func_80950280(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80950280(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 phi_v1; this->actor.flags |= ACTOR_FLAG_1; @@ -1168,7 +1249,7 @@ s32 func_80950280(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_3CC = 8; this->unk_3B4 = 40.0f; - switch (arg2->unk0) { + switch (arg2->result) { case 1: phi_v1 = func_8094FD88(this, globalCtx, arg2); break; @@ -1267,7 +1348,7 @@ s32 func_80950490(EnGm* this, GlobalContext* globalCtx) { }; s32 pad; - if ((gSaveContext.weekEventReg[50] & 1) || (gSaveContext.weekEventReg[51] & 0x80)) { + if ((gSaveContext.save.weekEventReg[50] & 1) || (gSaveContext.save.weekEventReg[51] & 0x80)) { if (this->unk_400 == 0) { this->unk_3C8 = 1; this->unk_3CA = 1; @@ -1363,7 +1444,7 @@ s32 func_80950804(EnGm* this, GlobalContext* globalCtx) { f32 temp_f0; door = func_8094DF90(globalCtx, this->unk_258); - if (!func_8013AD6C(globalCtx) && (this->unk_3C4 != 0)) { + if (!SubS_InCsMode(globalCtx) && (this->unk_3C4 != 0)) { if ((door != NULL) && (door->dyna.actor.update != NULL)) { if ((this->unk_3BA / (f32)this->unk_3B8) <= 0.9f) { door->unk_1A7 = this->unk_261; @@ -1412,7 +1493,7 @@ s32 func_8095097C(EnGm* this, GlobalContext* globalCtx) { this->actor.world.pos.x = sp58.x; this->actor.world.pos.z = sp58.z; - if (func_8013AD6C(globalCtx)) { + if (SubS_InCsMode(globalCtx)) { sp54 = this->unk_254; sp50 = this->unk_250; sp58 = this->actor.world.pos; @@ -1429,7 +1510,7 @@ s32 func_8095097C(EnGm* this, GlobalContext* globalCtx) { this->actor.world.rot.y = Math_Vec3f_Yaw(&sp70, &sp64); } - if (func_8013AD6C(globalCtx)) { + if (SubS_InCsMode(globalCtx)) { this->unk_254 = sp54; this->unk_250 = sp50; this->unk_238 = sp58; @@ -1493,21 +1574,20 @@ void func_80950C24(EnGm* this, GlobalContext* globalCtx) { } void func_80950CDC(EnGm* this, GlobalContext* globalCtx) { - u32* unk_14 = &gSaveContext.unk_14; - struct_80133038_arg2 sp20; + ScheduleResult sp20; - this->unk_3C4 = REG(15) + *unk_14; + this->unk_3C4 = REG(15) + ((void)0, gSaveContext.save.daySpeed); - if (!func_80133038(globalCtx, (void*)&D_80951820, &sp20) || - ((this->unk_258 != sp20.unk0) && !func_80950280(this, globalCtx, &sp20))) { + if (!Schedule_RunScript(globalCtx, D_80951820, &sp20) || + ((this->unk_258 != sp20.result) && !func_80950280(this, globalCtx, &sp20))) { this->actor.shape.shadowDraw = NULL; this->actor.flags &= ~ACTOR_FLAG_1; - sp20.unk0 = 0; + sp20.result = 0; } else { this->actor.shape.shadowDraw = ActorShadow_DrawCircle; this->actor.flags |= ACTOR_FLAG_1; } - this->unk_258 = sp20.unk0; + this->unk_258 = sp20.result; this->unk_268 = func_8094F074(this, globalCtx); func_80950C24(this, globalCtx); } @@ -1626,7 +1706,7 @@ void EnGm_Update(Actor* thisx, GlobalContext* globalCtx) { func_8094DFF8(this, globalCtx); func_8094E2D0(this); func_8094F2E8(this); - func_8013C964(&this->actor, globalCtx, this->unk_3B4, 30.0f, 0, this->unk_3A4 & 7); + func_8013C964(&this->actor, globalCtx, this->unk_3B4, 30.0f, EXCH_ITEM_NONE, this->unk_3A4 & 7); if ((this->unk_258 != 3) && (this->unk_258 != 5) && (this->unk_258 != 8)) { Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); diff --git a/src/overlays/actors/ovl_En_Go/z_en_go.c b/src/overlays/actors/ovl_En_Go/z_en_go.c index 00355cb457..c05de7ab88 100644 --- a/src/overlays/actors/ovl_En_Go/z_en_go.c +++ b/src/overlays/actors/ovl_En_Go/z_en_go.c @@ -213,7 +213,7 @@ static AnimationInfoS sAnimations[] = { { &object_hakugin_demo_Anim_003378, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, }; -EnGoStruct* func_80A10FD0(EnGoStruct ptr[], Vec3f arg1, Vec3f arg2, Vec3f arg3, f32 arg4, f32 arg5, s32 arg6) { +EnGoStruct* func_80A10FD0(EnGoStruct* ptr, Vec3f arg1, Vec3f arg2, Vec3f arg3, f32 arg4, f32 arg5, s32 arg6) { s32 i; for (i = 16; i < 32; i++, ptr++) { @@ -233,7 +233,7 @@ EnGoStruct* func_80A10FD0(EnGoStruct ptr[], Vec3f arg1, Vec3f arg2, Vec3f arg3, return ptr; } -void func_80A11144(EnGoStruct ptr[], GlobalContext* globalCtx) { +void func_80A11144(EnGoStruct* ptr, GlobalContext* globalCtx) { s32 pad; s32 i; s32 flag = false; @@ -279,7 +279,7 @@ void func_80A11144(EnGoStruct ptr[], GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx); } -void func_80A1143C(EnGoStruct ptr[], Vec3f arg1, Vec3f arg2, Vec3f arg3, f32 arg4, f32 arg5, s32 arg6, s32 arg7) { +void func_80A1143C(EnGoStruct* ptr, Vec3f arg1, Vec3f arg2, Vec3f arg3, f32 arg4, f32 arg5, s32 arg6, s32 arg7) { s32 i; for (i = 16; i < 32; i++, ptr++) { @@ -299,7 +299,7 @@ void func_80A1143C(EnGoStruct ptr[], Vec3f arg1, Vec3f arg2, Vec3f arg3, f32 arg } } -void func_80A115B4(EnGoStruct ptr[], GlobalContext* globalCtx) { +void func_80A115B4(EnGoStruct* ptr, GlobalContext* globalCtx) { static TexturePtr D_80A16644[] = { gDust8Tex, gDust7Tex, gDust6Tex, gDust5Tex, gDust4Tex, gDust3Tex, gDust2Tex, gDust1Tex, }; @@ -355,7 +355,7 @@ void func_80A115B4(EnGoStruct ptr[], GlobalContext* globalCtx) { } #ifdef NON_MATCHING -void func_80A118F8(EnGoStruct ptr[32], Vec3f arg1) { +void func_80A118F8(EnGoStruct* ptr, Vec3f arg1) { static u8 D_80A1667C[] = { 3, 1, 1, 2, 3, 1, 1, 2, 3, 1, 1, 2, 3, 1, 1, 2, }; @@ -400,10 +400,11 @@ void func_80A118F8(EnGoStruct ptr[32], Vec3f arg1) { static u8 D_80A1667C[] = { 3, 1, 1, 2, 3, 1, 1, 2, 3, 1, 1, 2, 3, 1, 1, 2, }; +void func_80A118F8(EnGoStruct* ptr, Vec3f arg1); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A118F8.s") #endif -void func_80A11BF8(EnGoStruct ptr[], f32 arg1) { +void func_80A11BF8(EnGoStruct* ptr, f32 arg1) { f32 test; f32 test2; f32 x; @@ -449,7 +450,7 @@ void func_80A11BF8(EnGoStruct ptr[], f32 arg1) { } #ifdef NON_MATCHING -void func_80A11EC0(EnGoStruct ptr[], GlobalContext* globalCtx, Gfx arg2[], Gfx arg3[], u8 arg4) { +void func_80A11EC0(EnGoStruct* ptr, GlobalContext* globalCtx, Gfx* arg2, Gfx* arg3, u8 arg4) { s32 i; u8 flag = false; @@ -484,6 +485,7 @@ void func_80A11EC0(EnGoStruct ptr[], GlobalContext* globalCtx, Gfx arg2[], Gfx a CLOSE_DISPS(globalCtx->state.gfxCtx); } #else +void func_80A11EC0(EnGoStruct* ptr, GlobalContext* globalCtx, Gfx* arg2, Gfx* arg3, u8 arg4); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A11EC0.s") #endif @@ -536,7 +538,7 @@ s32 func_80A1222C(EnGo* this, GlobalContext* globalCtx) { if (((player->transformation == PLAYER_FORM_GORON) && (globalCtx->msgCtx.ocarinaMode == 3) && (globalCtx->msgCtx.unk1202E == 1) && (this->unk_3EC == 0) && (this->actor.xzDistToPlayer < 400.0f)) || - (!(gSaveContext.weekEventReg[22] & 4) && (globalCtx->sceneNum == SCENE_16GORON_HOUSE) && + (!(gSaveContext.save.weekEventReg[22] & 4) && (globalCtx->sceneNum == SCENE_16GORON_HOUSE) && (gSaveContext.sceneSetupIndex == 0) && (this->unk_3EC == 0) && (globalCtx->csCtx.currentCsIndex == 1))) { ret = true; } @@ -821,7 +823,7 @@ void func_80A12DF4(EnGo* this, GlobalContext* globalCtx) { } s32 func_80A12E80(EnGo* this, GlobalContext* globalCtx) { - u16 temp = globalCtx->msgCtx.unk11F04; + u16 temp = globalCtx->msgCtx.currentTextId; Player* player = GET_PLAYER(globalCtx); if (ENGO_GET_F(&this->actor) != ENGO_F_4) { @@ -943,7 +945,7 @@ void func_80A132C8(EnGo* this, GlobalContext* globalCtx) { if ((fabsf(this->actor.playerHeightRel) > 20.0f) || (this->actor.xzDistToPlayer > 300.0f)) { SubS_UpdateFlags(&this->unk_390, 3, 7); } else if ((player->transformation != PLAYER_FORM_GORON) || (ABS_ALT(temp_v1) >= 0x1C70) || - (gSaveContext.weekEventReg[21] & 4) || (gSaveContext.weekEventReg[21] & 8)) { + (gSaveContext.save.weekEventReg[21] & 4) || (gSaveContext.save.weekEventReg[21] & 8)) { SubS_UpdateFlags(&this->unk_390, 3, 7); } else { SubS_UpdateFlags(&this->unk_390, 4, 7); @@ -951,7 +953,7 @@ void func_80A132C8(EnGo* this, GlobalContext* globalCtx) { } void func_80A133A8(EnGo* this, GlobalContext* globalCtx) { - if (gSaveContext.weekEventReg[21] & 8) { + if (gSaveContext.save.weekEventReg[21] & 8) { SubS_UpdateFlags(&this->unk_390, 3, 7); } else { SubS_UpdateFlags(&this->unk_390, 4, 7); @@ -986,7 +988,7 @@ Actor* func_80A13400(EnGo* this, GlobalContext* globalCtx) { } void func_80A134B0(EnGo* this, GlobalContext* globalCtx, s32 arg2) { - if ((gSaveContext.weekEventReg[18] & 0x80) || (globalCtx->actorCtx.unk5 & 1) || arg2) { + if ((gSaveContext.save.weekEventReg[18] & 0x80) || (globalCtx->actorCtx.unk5 & 1) || arg2) { this->colliderSphere.dim.modelSphere.radius = 300; } else { this->colliderSphere.dim.modelSphere.radius = 380; @@ -1177,7 +1179,7 @@ s32 func_80A13B1C(EnGo* this, GlobalContext* globalCtx) { func_80A13728(this, globalCtx); this->unk_3C4++; this->unk_3C2 = 0; - gSaveContext.weekEventReg[88] |= 0x40; + gSaveContext.save.weekEventReg[88] |= 0x40; } break; @@ -1197,19 +1199,19 @@ s32 func_80A13B1C(EnGo* this, GlobalContext* globalCtx) { if (this->unk_3C0 >= 65) { switch (player->transformation) { case 4: - gSaveContext.weekEventReg[88] |= 0x80; + gSaveContext.save.weekEventReg[88] |= 0x80; break; case 1: - gSaveContext.weekEventReg[89] |= 4; + gSaveContext.save.weekEventReg[89] |= 4; break; case 2: - gSaveContext.weekEventReg[89] |= 2; + gSaveContext.save.weekEventReg[89] |= 2; break; case 3: - gSaveContext.weekEventReg[89] |= 1; + gSaveContext.save.weekEventReg[89] |= 1; break; } ret = true; @@ -1332,7 +1334,7 @@ void func_80A1428C(EnGo* this, GlobalContext* globalCtx) { Math_Vec3f_Copy(&sp30, &this->actor.world.pos); if (this->unk_284 != NULL) { this->actor.flags &= ~ACTOR_FLAG_2000000; - func_8013C8B8(this->unk_284, 0, &sp24); + SubS_CopyPointFromPathCheckBounds(this->unk_284, 0, &sp24); temp = Math_Vec3f_Yaw(&sp30, &sp24); this->actor.shape.rot.y = temp; this->actor.world.rot.y = temp; @@ -1373,8 +1375,8 @@ void func_80A143A8(EnGo* this, GlobalContext* globalCtx) { } void func_80A14430(EnGo* this, GlobalContext* globalCtx) { - if (((gSaveContext.entranceIndex == 0xD000) || (gSaveContext.entranceIndex == 0xD020)) && - (gSaveContext.weekEventReg[33] & 0x80)) { + if (((gSaveContext.save.entranceIndex == 0xD000) || (gSaveContext.save.entranceIndex == 0xD020)) && + (gSaveContext.save.weekEventReg[33] & 0x80)) { func_80A14018(this, globalCtx); this->actionFunc = func_80A149B0; } else { @@ -1383,7 +1385,7 @@ void func_80A14430(EnGo* this, GlobalContext* globalCtx) { } void func_80A1449C(EnGo* this, GlobalContext* globalCtx) { - if ((gSaveContext.entranceIndex == 0xD010) || (gSaveContext.entranceIndex == 0x1C00)) { + if ((gSaveContext.save.entranceIndex == 0xD010) || (gSaveContext.save.entranceIndex == 0x1C00)) { func_80A14104(this, globalCtx); this->actionFunc = func_80A149B0; } else { @@ -1392,8 +1394,8 @@ void func_80A1449C(EnGo* this, GlobalContext* globalCtx) { } void func_80A144F4(EnGo* this, GlobalContext* globalCtx) { - if (gSaveContext.day >= 2) { - this->unk_284 = func_8013BEDC(globalCtx, ENGO_GET_7F80(&this->actor), 0xFF, &this->unk_3E4); + if (gSaveContext.save.day >= 2) { + this->unk_284 = SubS_GetDayDependentPath(globalCtx, ENGO_GET_7F80(&this->actor), 0xFF, &this->unk_3E4); if (this->unk_284 != NULL) { this->unk_3E4 = 1; } @@ -1411,7 +1413,7 @@ void func_80A145AC(EnGo* this, GlobalContext* globalCtx) { if ((ENGO_GET_70(&this->actor) == ENGO_70_1) && (((globalCtx->sceneNum == SCENE_10YUKIYAMANOMURA2) && (gSaveContext.sceneSetupIndex == 1) && (globalCtx->csCtx.currentCsIndex == 0)) || - !(gSaveContext.weekEventReg[21] & 8))) { + !(gSaveContext.save.weekEventReg[21] & 8))) { this->actor.child = func_80A13400(this, globalCtx); this->actor.child->child = &this->actor; func_80A141D4(this, globalCtx); @@ -1423,7 +1425,7 @@ void func_80A145AC(EnGo* this, GlobalContext* globalCtx) { } void func_80A14668(EnGo* this, GlobalContext* globalCtx) { - if (!(gSaveContext.weekEventReg[22] & 4)) { + if (!(gSaveContext.save.weekEventReg[22] & 4)) { func_80A14324(this, globalCtx); this->actionFunc = func_80A149B0; } else { @@ -1511,7 +1513,7 @@ void func_80A14798(EnGo* this, GlobalContext* globalCtx) { void func_80A149B0(EnGo* this, GlobalContext* globalCtx) { s16 sp26 = this->actor.world.rot.y; - if ((ENGO_GET_F(&this->actor) == ENGO_F_2) && (gSaveContext.entranceIndex == 0xD010)) { + if ((ENGO_GET_F(&this->actor) == ENGO_F_2) && (gSaveContext.save.entranceIndex == 0xD010)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_GORON_CHEER - SFX_FLAG); } else if (ENGO_GET_F(&this->actor) != ENGO_F_8) { if (func_80A1222C(this, globalCtx)) { @@ -1568,7 +1570,7 @@ void func_80A14B30(EnGo* this, GlobalContext* globalCtx) { this->unk_390 &= ~0x200; this->unk_390 |= 0x8000; this->actor.shape.yOffset = 0.0f; - } else if ((this->unk_3EC != 0) && (gSaveContext.weekEventReg[22] & 4)) { + } else if ((this->unk_3EC != 0) && (gSaveContext.save.weekEventReg[22] & 4)) { this->actor.scale.x = this->unk_3A4 - (Math_SinS(this->unk_3AE) * 0.001f); this->actor.scale.y = (Math_SinS(this->unk_3AE) * 0.001f) + this->unk_3A4; this->actor.scale.z = (Math_SinS(this->unk_3AE) * 0.001f) + this->unk_3A4; @@ -1771,7 +1773,7 @@ void func_80A153FC(EnGo* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_COLD); - if (gSaveContext.day == 3) { + if (gSaveContext.save.day == 3) { func_80A141D4(this, globalCtx); this->actionFunc = func_80A14E14; } else { @@ -1785,7 +1787,7 @@ void func_80A153FC(EnGo* this, GlobalContext* globalCtx) { } sp5C = Lib_SegmentedToVirtual(this->unk_284->points); - if (func_8013BD40(&this->actor, this->unk_284, this->unk_3E4)) { + if (SubS_HasReachedPoint(&this->actor, this->unk_284, this->unk_3E4)) { if (this->unk_3E4 >= (this->unk_284->count - 1)) { this->unk_3E4 = 0; } else { @@ -1926,10 +1928,10 @@ void EnGo_Update(Actor* thisx, GlobalContext* globalCtx) { } else { phi_f0 = this->colliderCylinder.dim.radius + 40; } - func_8013C964(&this->actor, globalCtx, phi_f0, 20.0f, 0, this->unk_390 & 7); + func_8013C964(&this->actor, globalCtx, phi_f0, 20.0f, EXCH_ITEM_NONE, this->unk_390 & 7); } else if ((this->unk_390 & 0x200) && (this->unk_3EC != 0)) { phi_f0 = this->colliderCylinder.dim.radius + 40; - func_8013C964(&this->actor, globalCtx, phi_f0, 20.0f, 0, this->unk_390 & 7); + func_8013C964(&this->actor, globalCtx, phi_f0, 20.0f, EXCH_ITEM_NONE, this->unk_390 & 7); } if ((ENGO_GET_F(&this->actor) != ENGO_F_8) && (ENGO_GET_F(&this->actor) != ENGO_F_2) && @@ -1976,7 +1978,6 @@ s32 EnGo_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, s32 idx; if ((ENGO_GET_F(&this->actor) == ENGO_F_8) && (limbIndex == 10)) { - limbIndex = limbIndex; Matrix_GetStateTranslation(&sp30); sp30.y = this->actor.world.pos.y; Math_Vec3f_ToVec3s(&this->colliderSphere.dim.worldSphere.center, &sp30); diff --git a/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c b/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c index 610d85b8b8..dd8d95c23a 100644 --- a/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c +++ b/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c @@ -528,10 +528,9 @@ s32 func_8093F6F8(EnGoroiwa* this, GlobalContext* globalCtx) { return false; } -#ifdef NON_MATCHING -// Stack void func_8093FAA4(EnGoroiwa* this, GlobalContext* globalCtx) { f32 temp; + f32 tmp2; f32 sp7C; Vec3f sp70; Vec3f sp64; @@ -541,7 +540,8 @@ void func_8093FAA4(EnGoroiwa* this, GlobalContext* globalCtx) { sp7C = this->unk_1C0; } else { temp = Math3D_Distance(&this->actor.world.pos, &this->actor.prevPos); - this->unk_1C0 = temp / this->unk_1DC; + tmp2 = temp / this->unk_1DC; + this->unk_1C0 = tmp2; sp7C = this->unk_1C0; } @@ -567,9 +567,6 @@ void func_8093FAA4(EnGoroiwa* this, GlobalContext* globalCtx) { Matrix_CopyCurrentState(&sp24); func_8018219C(&sp24, &this->actor.shape.rot, MTXMODE_NEW); } -#else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/func_8093FAA4.s") -#endif void func_8093FC00(EnGoroiwa* this) { s32 params = ENGOROIWA_GET_300(&this->actor); @@ -724,8 +721,8 @@ void func_80940090(EnGoroiwa* this, GlobalContext* globalCtx) { Math_Vec3f_Sum(&sp100, &sp10C, &sp100); EffectSsKakera_Spawn(globalCtx, &sp100, &spF4, &sp100, phi_s2, phi_s0, 30, 0, 0, - ((Rand_ZeroOne() * 150.0f) + 300.0f) * this->actor.scale.x, phi_s3, 0, 0x32, -1, 0xEF, - phi_s1); + ((Rand_ZeroOne() * 150.0f) + 300.0f) * this->actor.scale.x, phi_s3, 0, 0x32, -1, + OBJECT_GOROIWA, phi_s1); if (this->unk_1E6 == 0) { sp100.x += ((Rand_ZeroOne() * 1200.0f) - 600.0f) * this->actor.scale.x; sp100.y += ((Rand_ZeroOne() * 1400.0f) - 600.0f) * this->actor.scale.y; @@ -807,7 +804,7 @@ void func_80940588(GlobalContext* globalCtx, Vec3f* arg1, Gfx* arg2[], Color_RGB } EffectSsKakera_Spawn(globalCtx, &sp100, &spF4, &sp100, phi_fp, phi_s0, 30, 0, 0, - ((Rand_ZeroOne() * 100.0f) + 170.0f) * arg5, spC8, 0, 0x36, -1, 0xEF, phi_s7); + ((Rand_ZeroOne() * 100.0f) + 170.0f) * arg5, spC8, 0, 0x36, -1, OBJECT_GOROIWA, phi_s7); for (j = 0; j < 2; j++) { spE8.x = (((Rand_ZeroOne() * 1000.0f) - 500.0f) * arg5) + sp100.x; @@ -882,7 +879,7 @@ void func_80940A1C(GlobalContext* globalCtx, Vec3f* arg1, Gfx** arg2, Color_RGBA } EffectSsKakera_Spawn(globalCtx, &spE8, &spDC, &spE8, phi_s2, phi_s0, 30, 0, 0, - ((Rand_ZeroOne() * 150.0f) + 250.0f) * arg5, phi_s3, 0, 0x36, -1, 0xEF, phi_s1); + ((Rand_ZeroOne() * 150.0f) + 250.0f) * arg5, phi_s3, 0, 0x36, -1, OBJECT_GOROIWA, phi_s1); spE8.x += ((Rand_ZeroOne() * 800.0f) - 400.0f) * arg5; spE8.y += ((Rand_ZeroOne() * 800.0f) - 250.0f) * arg5; @@ -1431,8 +1428,6 @@ void func_80942604(EnGoroiwa* this, GlobalContext* globalCtx) { } } -#ifdef NON_MATCHING -// stack for params and colCtx void EnGoroiwa_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnGoroiwa* this = THIS; @@ -1442,6 +1437,8 @@ void EnGoroiwa_Update(Actor* thisx, GlobalContext* globalCtx) { Vec3f sp50; f32 sp4C; s32 sp48 = true; + u32 temp_v0_2; + CollisionPoly* tmp; if (!(player->stateFlags1 & (0x30000000 | 0x80 | 0x40))) { if (this->unk_1CC > 0) { @@ -1459,8 +1456,9 @@ void EnGoroiwa_Update(Actor* thisx, GlobalContext* globalCtx) { sp5C = true; if (this->actor.flags & ACTOR_FLAG_40) { - if (this->actor.floorPoly != NULL) { - u32 temp_v0_2 = func_800C99D4(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId); + tmp = this->actor.floorPoly; + if (tmp != NULL) { + temp_v0_2 = func_800C99D4(&globalCtx->colCtx, tmp, this->actor.floorBgId); if ((temp_v0_2 == 14) || (temp_v0_2 == 15)) { if (!(this->unk_1E5 & 0x40)) { @@ -1549,9 +1547,6 @@ void EnGoroiwa_Update(Actor* thisx, GlobalContext* globalCtx) { } } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/EnGoroiwa_Update.s") -#endif void func_80942B1C(EnGoroiwa* this, GlobalContext* globalCtx) { s32 pad; diff --git a/src/overlays/actors/ovl_En_Gs/z_en_gs.c b/src/overlays/actors/ovl_En_Gs/z_en_gs.c index 7dc4e69682..37f56469db 100644 --- a/src/overlays/actors/ovl_En_Gs/z_en_gs.c +++ b/src/overlays/actors/ovl_En_Gs/z_en_gs.c @@ -112,7 +112,7 @@ s8 func_80997A90(s16 arg0, s16 arg1) { if ((arg0 == 0) || ((arg0 != 1) && (arg0 != 2) && (arg0 == 3))) { phi_v1 = 0; } else { - phi_v1 = (gSaveContext.unk_EC4 >> (arg1 * 3)) & 7; + phi_v1 = (gSaveContext.save.unk_EC4 >> (arg1 * 3)) & 7; } return phi_v1; } @@ -154,8 +154,8 @@ void EnGs_Init(Actor* thisx, GlobalContext* globalCtx) { func_80997AFC(this->unk_194, &this->unk_1FA); this->unk_1F4 = this->unk_1FA; - Math_Vec3f_Copy(&this->unk_1B0[0], &D_801C5DB0); - Math_Vec3f_Copy(&this->unk_1B0[1], &D_801C5DB0); + Math_Vec3f_Copy(&this->unk_1B0[0], &gOneVec3f); + Math_Vec3f_Copy(&this->unk_1B0[1], &gOneVec3f); SubS_FillCutscenesList(&this->actor, this->unk_212, ARRAY_COUNT(this->unk_212)); func_801A5080(0); if (this->actor.params == ENGS_1) { @@ -183,8 +183,8 @@ void func_80997D38(EnGs* this, GlobalContext* globalCtx) { if (Message_GetState(&globalCtx->msgCtx) == 0) { if (this->actor.xzDistToPlayer <= D_8099A408[this->actor.params]) { - func_8013E8F8(&this->actor, globalCtx, D_8099A408[this->actor.params], D_8099A408[this->actor.params], 0, - 0x2000, 0x2000); + func_8013E8F8(&this->actor, globalCtx, D_8099A408[this->actor.params], D_8099A408[this->actor.params], + EXCH_ITEM_NONE, 0x2000, 0x2000); } } @@ -217,8 +217,8 @@ void func_80997E4C(EnGs* this, GlobalContext* globalCtx) { case 4: case 5: case 6: - if (func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x20D0: func_80997D14(this, globalCtx); break; @@ -296,7 +296,7 @@ void func_8099807C(EnGs* this, GlobalContext* globalCtx) { break; case 0: - if ((this->actor.params == ENGS_1) && (gSaveContext.playerForm == PLAYER_FORM_DEKU)) { + if ((this->actor.params == ENGS_1) && (gSaveContext.save.playerForm == PLAYER_FORM_DEKU)) { this->unk_194 = 1; this->unk_19C = 5; this->unk_19A |= 1; @@ -306,7 +306,7 @@ void func_8099807C(EnGs* this, GlobalContext* globalCtx) { break; case 2: - if ((this->actor.params == ENGS_1) && (gSaveContext.playerForm == PLAYER_FORM_ZORA)) { + if ((this->actor.params == ENGS_1) && (gSaveContext.save.playerForm == PLAYER_FORM_ZORA)) { this->unk_194 = 3; this->unk_19C = 5; this->unk_19A |= 1; @@ -316,7 +316,7 @@ void func_8099807C(EnGs* this, GlobalContext* globalCtx) { break; case 1: - if ((this->actor.params == ENGS_1) && (gSaveContext.playerForm == PLAYER_FORM_GORON)) { + if ((this->actor.params == ENGS_1) && (gSaveContext.save.playerForm == PLAYER_FORM_GORON)) { this->unk_194 = 2; this->unk_19C = 5; this->unk_19A |= 1; @@ -388,8 +388,8 @@ void func_809985B8(EnGs* this, GlobalContext* globalCtx) { Math_Vec3f_Sum(&player->actor.world.pos, &sp38, &player->actor.world.pos); Math_Vec3f_Copy(&player->actor.prevPos, &player->actor.world.pos); this->unk_200 = 0.0f; - gSaveContext.unk_EC4 = - ((u32)gSaveContext.unk_EC4 & ~(7 << (this->unk_198 * 3))) | ((this->unk_194 & 7) << (this->unk_198 * 3)); + gSaveContext.save.unk_EC4 = ((u32)gSaveContext.save.unk_EC4 & ~(7 << (this->unk_198 * 3))) | + ((this->unk_194 & 7) << (this->unk_198 * 3)); gossipStone = NULL; do { @@ -450,7 +450,7 @@ void func_8099874C(EnGs* this, GlobalContext* globalCtx) { phi_v0 = 1; for (i = 0; i < 4; i++) { - if (((gSaveContext.unk_EC4 >> (i * 3)) & 7) != (u32)this->unk_194) { + if (((gSaveContext.save.unk_EC4 >> (i * 3)) & 7) != (u32)this->unk_194) { phi_v0 = 0; } } @@ -459,29 +459,29 @@ void func_8099874C(EnGs* this, GlobalContext* globalCtx) { this->unk_20C = -1; switch (this->unk_194) { case 1: - if (!(gSaveContext.weekEventReg[77] & 8)) { + if (!(gSaveContext.save.weekEventReg[77] & 8)) { this->unk_20C = 6; - gSaveContext.weekEventReg[77] |= 8; + gSaveContext.save.weekEventReg[77] |= 8; } break; case 3: - if (!(gSaveContext.weekEventReg[77] & 0x10)) { + if (!(gSaveContext.save.weekEventReg[77] & 0x10)) { this->unk_20C = 6; - gSaveContext.weekEventReg[77] |= 0x10; + gSaveContext.save.weekEventReg[77] |= 0x10; } break; case 2: - if (!(gSaveContext.weekEventReg[77] & 0x20)) { + if (!(gSaveContext.save.weekEventReg[77] & 0x20)) { this->unk_20C = 6; - gSaveContext.weekEventReg[77] |= 0x20; + gSaveContext.save.weekEventReg[77] |= 0x20; } break; } - if (!(gSaveContext.weekEventReg[90] & 0x10)) { - gSaveContext.weekEventReg[90] |= 0x10; + if (!(gSaveContext.save.weekEventReg[90] & 0x10)) { + gSaveContext.save.weekEventReg[90] |= 0x10; this->unk_20C = 12; } @@ -533,8 +533,8 @@ s32 func_80998A48(EnGs* this, GlobalContext* globalCtx) { } else if (this->unk_19D == 1) { if (func_80998334(this, globalCtx, &this->unk_1DC, &this->unk_1E0, &this->unk_1D4, 0.8f, 0.007f, 0.001f, 7, 0) == 0.0f) { - if ((this->actor.params != ENGS_0) && !func_801690CC(globalCtx) && - Message_GetState(&globalCtx->msgCtx) == 0) { + if ((this->actor.params != ENGS_0) && !Play_InCsMode(globalCtx) && + (Message_GetState(&globalCtx->msgCtx) == 0)) { this->unk_216 = 0; Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIVE_LUPY_COUNT); Message_StartTextbox(globalCtx, 0x20D2, NULL); diff --git a/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.c b/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.c index eefabdb3bb..3a8cfdcd9f 100644 --- a/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.c +++ b/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.c @@ -15,7 +15,15 @@ void EnGuardNuts_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnGuardNuts_Update(Actor* thisx, GlobalContext* globalCtx); void EnGuardNuts_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void EnGuardNuts_ChangeAnim(EnGuardNuts* this, s32 index); +void EnGuardNuts_SetupWait(EnGuardNuts* this); +void EnGuardNuts_Wait(EnGuardNuts* this, GlobalContext* globalCtx); +void func_80ABB540(EnGuardNuts* this); +void func_80ABB590(EnGuardNuts* this, GlobalContext* globalCtx); +void EnGuardNuts_Burrow(EnGuardNuts* this, GlobalContext* globalCtx); +void EnGuardNuts_SetupUnburrow(EnGuardNuts* this, GlobalContext* globalCtx); +void EnGuardNuts_Unburrow(EnGuardNuts* this, GlobalContext* globalCtx); + const ActorInit En_Guard_Nuts_InitVars = { ACTOR_EN_GUARD_NUTS, ACTORCAT_NPC, @@ -28,42 +36,350 @@ const ActorInit En_Guard_Nuts_InitVars = { (ActorFunc)EnGuardNuts_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80ABBDF0 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON | OCELEM_UNK3, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON | OCELEM_UNK3, + }, { 50, 50, 0, { 0, 0, 0 } }, }; -#endif +s32 sGuardCount = 0; -extern ColliderCylinderInit D_80ABBDF0; +s32 D_80ABBE20 = 0; -extern UNK_TYPE D_06002700; -extern UNK_TYPE D_06002A08; +static u16 sTextIDs[] = { 0x0824, 0x0825, 0x0826, 0x082D, 0x0827, 0x0828, 0x0829, 0x082A, 0x082B, 0x082C }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Guard_Nuts/EnGuardNuts_Init.s") +s16 D_80ABBE38[] = { 0x0000, 0x0000, 0x0002, 0x0001, 0x0000, 0x0000, 0x0002, 0x0000, 0x0000, 0x0002 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Guard_Nuts/EnGuardNuts_Destroy.s") +static AnimationHeader* sAnimations[] = { + &gDekuPalaceGuardWaitAnim, + &gDekuPalaceGuardWalkAnim, + &gDekuPalaceGuardDigAnim, + &gDekuPalaceGuardWalkAnim, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Guard_Nuts/func_80ABB210.s") +static u8 sAnimModes[] = { ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_ONCE }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Guard_Nuts/func_80ABB29C.s") +static TexturePtr sEyeTextures[] = { + gDekuPalaceGuardEyeOpenTex, + gDekuPalaceGuardEyeHalfTex, + gDekuPalaceGuardEyeClosedTex, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Guard_Nuts/func_80ABB2D4.s") +typedef enum { + /* 0 */ WAIT_HEAD_TILT_ANIM, + /* 1 */ WALK_ANIM, + /* 2 */ DIG_ANIM, + /* 3 */ WALK_ANIM_2, +} EnGuardNutsAnim; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Guard_Nuts/func_80ABB540.s") +typedef enum { + /* 0 */ GUARD_NUTS_WAIT_STATE, + /* 1 */ GUARD_NUTS_TALKING_STATE, + /* 3 */ GUARD_NUTS_BURROWED_STATE = 3, + /* 4 */ GUARD_NUTS_UNK_STATE +} EnGuardNutsState; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Guard_Nuts/func_80ABB590.s") +void EnGuardNuts_Init(Actor* thisx, GlobalContext* globalCtx) { + EnGuardNuts* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Guard_Nuts/func_80ABB854.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); + SkelAnime_Init(globalCtx, &this->skelAnime, &gDekuPalaceGuardSkel, &gDekuPalaceGuardWaitAnim, this->jointTable, + this->morphTable, DEKU_PALACE_GUARD_LIMB_MAX); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->actor.targetMode = 1; + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Actor_SetScale(&this->actor, 0.015f); + Math_Vec3f_Copy(&this->guardPos, &this->actor.world.pos); + this->guardNumber = sGuardCount; + sGuardCount++; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Guard_Nuts/func_80ABB91C.s") + // If you have returned deku princess guards will init burrowed. + if (!(gSaveContext.save.weekEventReg[23] & 0x20)) { + EnGuardNuts_SetupWait(this); + } else { + EnGuardNuts_Burrow(this, globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Guard_Nuts/func_80ABB990.s") +void EnGuardNuts_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnGuardNuts* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Guard_Nuts/EnGuardNuts_Update.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Guard_Nuts/func_80ABBC60.s") +/** + * @brief Changes the animation to the provided index. Updates animIndex and animFrameCount for the animation. + * + * @param this + * @param index the index of sAnimations to change to + */ +void EnGuardNuts_ChangeAnim(EnGuardNuts* this, s32 index) { + this->animIndex = index; + this->animFrameCount = Animation_GetLastFrame(sAnimations[this->animIndex]); + Animation_Change(&this->skelAnime, sAnimations[this->animIndex], 1.0f, 0.0f, this->animFrameCount, + sAnimModes[this->animIndex], -2.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Guard_Nuts/EnGuardNuts_Draw.s") +void EnGuardNuts_SetupWait(EnGuardNuts* this) { + EnGuardNuts_ChangeAnim(this, WAIT_HEAD_TILT_ANIM); + this->state = GUARD_NUTS_WAIT_STATE; + this->actionFunc = EnGuardNuts_Wait; +} + +void EnGuardNuts_Wait(EnGuardNuts* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 phi_a1; + s16 yawDiff; + + SkelAnime_Update(&this->skelAnime); + yawDiff = ABS_ALT(BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.home.rot.y)); + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + func_80ABB540(this); + return; + } + if (yawDiff > 0x6000) { + D_80ABBE20 = 2; + } + if (player->transformation == PLAYER_FORM_DEKU) { + // this is the palace of... + this->guardTextIndex = 0; + if ((gSaveContext.save.weekEventReg[17] & 4) && (!this->hasCompletedConversation)) { + // I told you not to enter!! + this->guardTextIndex = 7; + } else if (gSaveContext.save.weekEventReg[12] & 0x40) { + // come to see the monkey again? + this->guardTextIndex = 4; + } + } else { + // No place for an outsider + this->guardTextIndex = 3; + } + this->actor.textId = sTextIDs[this->guardTextIndex]; + phi_a1 = this->actor.world.rot.y; + if (D_80ABBE20 == 2) { + EnGuardNuts_Burrow(this, globalCtx); + return; + } + if (D_80ABBE20 == 1) { + if (this->animIndex != WALK_ANIM) { + EnGuardNuts_ChangeAnim(this, WALK_ANIM); + } + phi_a1 = (this->actor.home.rot.y + 0x8000); + } + if (fabsf((f32)(this->actor.shape.rot.y - phi_a1)) < 100.0f) { + this->actor.shape.rot.y = phi_a1; + if ((D_80ABBE20 == 1) && (this->animIndex != WALK_ANIM_2)) { + EnGuardNuts_ChangeAnim(this, WALK_ANIM_2); + } + } else { + Math_SmoothStepToS(&this->actor.shape.rot.y, phi_a1, 1, 0xBB8, 0); + } + if (this->targetHeadPos.x == 0) { + if (fabsf((f32)this->actor.world.rot.y - (f32)this->actor.yawTowardsPlayer) < 10000.0f) { + this->targetHeadPos.y = this->actor.world.rot.y - this->actor.yawTowardsPlayer; + this->targetHeadPos.y = -this->targetHeadPos.y; + } + } + func_800B8614(&this->actor, globalCtx, 70.0f); +} + +void func_80ABB540(EnGuardNuts* this) { + EnGuardNuts_ChangeAnim(this, WALK_ANIM); + this->targetHeadPos.x = this->targetHeadPos.y = 0; + this->timer = 16; + this->state = GUARD_NUTS_TALKING_STATE; + this->actionFunc = func_80ABB590; +} + +void func_80ABB590(EnGuardNuts* this, GlobalContext* globalCtx) { + s16 yaw = this->actor.yawTowardsPlayer; + f32 curFrame; + + if (D_80ABBE20 == 1) { + yaw = (this->actor.home.rot.y + 0x8000); + } + if (fabsf((this->actor.shape.rot.y - yaw)) < 100.0f) { + this->actor.shape.rot.y = yaw; + curFrame = this->skelAnime.curFrame; + if ((curFrame < this->animFrameCount) || (this->guardTextIndex >= 7)) { + SkelAnime_Update(&this->skelAnime); + } + } else { + SkelAnime_Update(&this->skelAnime); + Math_SmoothStepToS(&this->actor.shape.rot.y, yaw, 1, 0xBB8, 0); + } + if (Message_GetState(&globalCtx->msgCtx) == 5) { + this->targetHeadPos.y = 0; + this->targetHeadPos.x = 0; + if ((this->guardTextIndex == 3) && (this->animIndex == WAIT_HEAD_TILT_ANIM)) { + EnGuardNuts_ChangeAnim(this, WAIT_HEAD_TILT_ANIM); + } + if (Message_ShouldAdvance(globalCtx) != 0) { + if (D_80ABBE38[this->guardTextIndex] != 1) { + if (D_80ABBE38[this->guardTextIndex] == 2) { + func_801477B4(globalCtx); + D_80ABBE20 = 2; + gSaveContext.save.weekEventReg[12] |= 0x40; + EnGuardNuts_Burrow(this, globalCtx); + } else { + this->guardTextIndex++; + Message_StartTextbox(globalCtx, sTextIDs[this->guardTextIndex], &this->actor); + if (D_80ABBE38[this->guardTextIndex] == 2) { + D_80ABBE20 = 1; + } + this->timer = 16; + } + } else if (this->guardTextIndex != 3) { + this->targetHeadPos.x = 0; + this->targetHeadPos.y = this->targetHeadPos.x; + func_801477B4(globalCtx); + this->state = GUARD_NUTS_UNK_STATE; + this->actionFunc = EnGuardNuts_Unburrow; + } else { + func_801477B4(globalCtx); + EnGuardNuts_SetupWait(this); + } + } + } else if ((Message_GetState(&globalCtx->msgCtx) >= 3) && (D_80ABBE20 == 0)) { + if ((this->guardTextIndex == 0) || (this->guardTextIndex == 3) || (this->guardTextIndex >= 7)) { + if (this->timer == 0) { + this->timer = 2; + this->targetHeadPos.y ^= 0x2000; + } + } else if (this->timer == 0) { + this->timer = 2; + this->targetHeadPos.x ^= 0x2000; + } + } +} + +void EnGuardNuts_Burrow(EnGuardNuts* this, GlobalContext* globalCtx) { + Vec3f digPos; + + EnGuardNuts_ChangeAnim(this, DIG_ANIM); + Math_Vec3f_Copy(&digPos, &this->actor.world.pos); + digPos.y = this->actor.floorHeight; + EffectSsHahen_SpawnBurst(globalCtx, &digPos, 4.0f, 0, 10, 3, 15, -1, 10, NULL); + this->targetHeadPos.y = 0; + this->actor.flags |= ACTOR_FLAG_8000000; + this->targetHeadPos.x = this->targetHeadPos.y; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); + this->actionFunc = EnGuardNuts_SetupUnburrow; +} + +void EnGuardNuts_SetupUnburrow(EnGuardNuts* this, GlobalContext* globalCtx) { + f32 curFrame = this->skelAnime.curFrame; + + SkelAnime_Update(&this->skelAnime); + if (this->animFrameCount <= curFrame) { + this->state = GUARD_NUTS_BURROWED_STATE; + this->actionFunc = EnGuardNuts_Unburrow; + this->actor.world.rot.y = this->actor.home.rot.y; + this->actor.shape.rot.y = this->actor.home.rot.y; + } +} + +void EnGuardNuts_Unburrow(EnGuardNuts* this, GlobalContext* globalCtx) { + s16 yawDiff; + Vec3f digPos; + + // If you have returned Deku Princess, guards will not unburrow + if (!(gSaveContext.save.weekEventReg[23] & 0x20)) { + yawDiff = ABS_ALT(BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.home.rot.y)); + if ((yawDiff < 0x4000) && ((D_80ABBE20 == 0) || (this->actor.xzDistToPlayer > 150.0f))) { + Math_Vec3f_Copy(&digPos, &this->actor.world.pos); + digPos.y = this->actor.floorHeight; + EffectSsHahen_SpawnBurst(globalCtx, &digPos, 4.0f, 0, 10, 3, 15, -1, 10, NULL); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); + D_80ABBE20 = 0; + if (this->guardTextIndex == 9) { + this->hasCompletedConversation = true; + } + this->actor.flags &= ~ACTOR_FLAG_8000000; + EnGuardNuts_SetupWait(this); + } + } +} + +void EnGuardNuts_Update(Actor* thisx, GlobalContext* globalCtx) { + EnGuardNuts* this = THIS; + s32 pad; + + if (this->blinkTimer == 0) { + if (++(this->eyeState) >= 3) { + this->eyeState = 0; + this->blinkTimer = (s16)Rand_ZeroFloat(60.0f) + 20; + } + } + if ((this->animIndex == WALK_ANIM) && + ((Animation_OnFrame(&this->skelAnime, 1.0f)) || (Animation_OnFrame(&this->skelAnime, 5.0f)))) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_WALK); + } + + this->actionFunc(this, globalCtx); + Actor_SetFocus(&this->actor, 40.0f); + Math_SmoothStepToS(&this->headRot.x, this->targetHeadPos.x, 1, 0xBB8, 0); + Math_SmoothStepToS(&this->headRot.y, this->targetHeadPos.y, 1, 0xBB8, 0); + + if (this->blinkTimer != 0) { + this->blinkTimer--; + } + if (this->timer != 0) { + this->timer--; + } + + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 60.0f, 0x1D); + if ((this->state != GUARD_NUTS_BURROWED_STATE) && (this->state != GUARD_NUTS_UNK_STATE)) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +s32 EnGuardNuts_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnGuardNuts* this = THIS; + + if (limbIndex == DEKU_PALACE_GUARD_LIMB_HEAD) { + rot->x += this->headRot.x; + rot->y += this->headRot.y; + rot->z += this->headRot.z; + } + return false; +} + +void EnGuardNuts_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnGuardNuts* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeState])); + + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnGuardNuts_OverrideLimbDraw, + NULL, &this->actor); + Matrix_InsertTranslation(this->guardPos.x, this->actor.floorHeight, this->guardPos.z, MTXMODE_NEW); + Matrix_Scale(0.015f, 0.015f, 0.015f, 1); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_OPA_DISP++, gDekuPalaceGuardFlower); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.h b/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.h index 13acc2237c..4a42e4e5a0 100644 --- a/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.h +++ b/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.h @@ -2,16 +2,31 @@ #define Z_EN_GUARD_NUTS_H #include "global.h" +#include "objects/object_dnk/object_dnk.h" struct EnGuardNuts; typedef void (*EnGuardNutsActionFunc)(struct EnGuardNuts*, GlobalContext*); typedef struct EnGuardNuts { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xC8]; - /* 0x020C */ EnGuardNutsActionFunc actionFunc; - /* 0x0210 */ char unk_210[0x80]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[DEKU_PALACE_GUARD_LIMB_MAX]; + /* 0x1CA */ Vec3s morphTable[DEKU_PALACE_GUARD_LIMB_MAX]; + /* 0x20C */ EnGuardNutsActionFunc actionFunc; + /* 0x210 */ s16 eyeState; + /* 0x212 */ s16 blinkTimer; + /* 0x214 */ s16 timer; + /* 0x218 */ s32 animIndex; + /* 0x21C */ s16 state; + /* 0x21E */ s16 guardNumber; // Unused - Number used to identify guard + /* 0x220 */ s32 guardTextIndex; + /* 0x224 */ u8 hasCompletedConversation; // Flag set when player has gone through all text. + /* 0x228 */ Vec3f guardPos; + /* 0x234 */ Vec3s headRot; + /* 0x23A */ Vec3s targetHeadPos; + /* 0x240 */ f32 animFrameCount; + /* 0x244 */ ColliderCylinder collider; } EnGuardNuts; // size = 0x290 extern const ActorInit En_Guard_Nuts_InitVars; diff --git a/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c b/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c index f3ba53251b..8844062b80 100644 --- a/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c +++ b/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c @@ -79,7 +79,7 @@ void EnGuruguru_Init(Actor* thisx, GlobalContext* globalCtx) { if (this->actor.params != 2) { Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); } - if (!gSaveContext.isNight) { + if (!gSaveContext.save.isNight) { if (this->actor.params == 0) { func_80BC6E10(this); } else if (this->actor.params == 2) { @@ -119,10 +119,10 @@ void func_80BC6E10(EnGuruguru* this) { this->textIdIndex = 0; this->unk270 = 0; if (this->actor.params == 0) { - if (gSaveContext.weekEventReg[38] & 0x10) { + if (gSaveContext.save.weekEventReg[38] & 0x10) { this->textIdIndex = 1; } - } else if (gSaveContext.weekEventReg[38] & 0x40) { + } else if (gSaveContext.save.weekEventReg[38] & 0x40) { this->textIdIndex = 2; } else { this->textIdIndex = 3; @@ -131,8 +131,8 @@ void func_80BC6E10(EnGuruguru* this) { this->headZRotTarget = 0; this->unk268 = 1; this->actor.textId = textIDs[this->textIdIndex]; - if ((this->textIdIndex == 0 || this->textIdIndex == 1) && (gSaveContext.weekEventReg[77] & 4)) { - if (!(gSaveContext.weekEventReg[88] & 4)) { + if ((this->textIdIndex == 0 || this->textIdIndex == 1) && (gSaveContext.save.weekEventReg[77] & 4)) { + if (!(gSaveContext.save.weekEventReg[88] & 4)) { this->actor.textId = 0x295F; } else { this->actor.textId = 0x2960; @@ -153,7 +153,7 @@ void func_80BC6F14(EnGuruguru* this, GlobalContext* globalCtx) { this->textIdIndex = 3; if (player->transformation == PLAYER_FORM_DEKU) { this->textIdIndex = 13; - if (gSaveContext.weekEventReg[79] & 4) { + if (gSaveContext.save.weekEventReg[79] & 4) { this->textIdIndex = 14; } } @@ -207,21 +207,21 @@ void func_80BC7068(EnGuruguru* this, GlobalContext* globalCtx) { } } } - if ((Message_GetState(&globalCtx->msgCtx) == 5) && (func_80147624(globalCtx))) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && (Message_ShouldAdvance(globalCtx))) { func_801477B4(globalCtx); this->headZRotTarget = 0; if ((this->textIdIndex == 13) || (this->textIdIndex == 14)) { func_80151BB4(globalCtx, 0x13); - gSaveContext.weekEventReg[79] |= 4; + gSaveContext.save.weekEventReg[79] |= 4; func_80BC6E10(this); return; } if (this->actor.params == 0) { if (this->actor.textId == 0x295F) { - gSaveContext.weekEventReg[88] |= 4; + gSaveContext.save.weekEventReg[88] |= 4; } if (this->actor.textId == 0x292A) { - gSaveContext.weekEventReg[38] |= 0x10; + gSaveContext.save.weekEventReg[38] |= 0x10; } func_80151BB4(globalCtx, 0x13); func_80BC6E10(this); @@ -232,7 +232,7 @@ void func_80BC7068(EnGuruguru* this, GlobalContext* globalCtx) { return; } if (this->textIdIndex == 12) { - gSaveContext.weekEventReg[38] |= 0x40; + gSaveContext.save.weekEventReg[38] |= 0x40; func_801A3B48(0); func_80151BB4(globalCtx, 0x36); func_80151BB4(globalCtx, 0x13); @@ -297,7 +297,7 @@ void func_80BC7440(EnGuruguru* this, GlobalContext* globalCtx) { func_801A3B48(1); func_800B8500(&this->actor, globalCtx, 400.0f, 400.0f, EXCH_ITEM_MINUS1); this->unk268 = 0; - gSaveContext.weekEventReg[38] |= 0x40; + gSaveContext.save.weekEventReg[38] |= 0x40; this->actionFunc = func_80BC7520; } else { Actor_PickUp(&this->actor, globalCtx, GI_MASK_BREMEN, 300.0f, 300.0f); @@ -319,7 +319,7 @@ void EnGuruguru_Update(Actor* thisx, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s16 yawTemp; - if (!gSaveContext.isNight) { + if (!gSaveContext.save.isNight) { if (this->actor.params == 1) { Actor_MarkForDeath(&this->actor); return; diff --git a/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c b/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c index 2b15971bf0..d7ec6103f4 100644 --- a/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c +++ b/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c @@ -5,6 +5,7 @@ */ #include "z_en_hanabi.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -18,8 +19,8 @@ void func_80B23894(EnHanabi* this, GlobalContext* globalCtx); void func_80B238D4(EnHanabi* this, GlobalContext* globalCtx); void func_80B23910(EnHanabi* this, GlobalContext* globalCtx); void func_80B23934(EnHanabi* this, GlobalContext* globalCtx); +void EnHanabi_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit En_Hanabi_InitVars = { ACTOR_EN_HANABI, ACTORCAT_ITEMACTION, @@ -32,38 +33,322 @@ const ActorInit En_Hanabi_InitVars = { (ActorFunc)NULL, }; -#endif +Vec3s D_80B23AA0[] = { + { 85, 14, 49 }, { 70, -70, 0 }, { 85, 14, -49 }, { 90, -32, 28 }, { 90, -32, -28 }, { 98, 16, 0 }, + { 70, 70, 0 }, { 84, 45, 26 }, { 84, 45, -26 }, { 50, -50, 70 }, { 73, -19, 64 }, { 65, -65, 38 }, + { 50, -50, -70 }, { 65, -65, -38 }, { 73, -19, -64 }, { 0, 0, -100 }, { 14, 85, -49 }, { 49, 8, -86 }, + { 8, 49, -86 }, { 57, 57, -57 }, { 45, 84, -26 }, { 27, -27, -92 }, { -50, 50, -70 }, { -27, 27, -92 }, + { -19, 73, -64 }, { -70, 70, 0 }, { 14, 85, 49 }, { -32, 90, -28 }, { -32, 90, 28 }, { 16, 98, 0 }, + { 45, 84, 26 }, { -65, 65, -38 }, { -50, 50, 70 }, { -65, 65, 38 }, { -19, 73, 64 }, { 0, 0, 100 }, + { 8, 49, 86 }, { 49, 8, 86 }, { 57, 57, 57 }, { -27, 27, 92 }, { 27, -27, 92 }, { -14, -85, -49 }, + { -14, -85, 49 }, { 32, -90, -28 }, { 32, -90, 28 }, { -16, -98, 0 }, { -70, -70, 0 }, { -45, -84, -26 }, + { -45, -84, 26 }, { 19, -73, -64 }, { 19, -73, 64 }, { -85, -14, -49 }, { -49, -8, -86 }, { -8, -49, -86 }, + { -57, -57, -57 }, { -84, -45, -26 }, { -73, 19, -64 }, { -85, -14, 49 }, { -90, 32, 28 }, { -90, 32, -28 }, + { -98, -16, 0 }, { -84, -45, 26 }, { -73, 19, 64 }, { -8, -49, 86 }, { -49, -8, 86 }, { -57, -57, 57 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/func_80B22C00.s") +u8 D_80B23C2C[] = { + 255, 255, 200, 255, 200, 255, 200, 255, 255, 255, 200, 200, 200, 255, 200, 200, 200, 255, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/func_80B22C2C.s") +u8 D_80B23C40[] = { + 200, 200, 0, 200, 0, 200, 0, 200, 200, 200, 0, 0, 0, 200, 0, 0, 200, 200, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/func_80B22C80.s") +void func_80B22C00(EnHanabiStruct* arg0) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/func_80B22E0C.s") + for (i = 0; i < 400; i++, arg0++) { + arg0->unk_00 = 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/func_80B22F34.s") +void func_80B22C2C(EnHanabiStruct* arg0, s32 arg1) { + arg0->unk_01 = (s32)Rand_ZeroFloat(20.0f) + 60; + arg0->unk_02 = arg1; + arg0->unk_14.x = 0.7f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/func_80B22FA8.s") +s32 func_80B22C80(Vec3f* arg0, EnHanabiStruct* arg1, f32 arg2) { + Vec3s* phi_s1 = &D_80B23AA0[0]; + f32 temp_f22 = (Rand_ZeroFloat(0.2f) + 0.6f) * arg2; + s32 temp_s6 = (s32)Rand_ZeroFloat(6.0f) * 3; + s32 i; + s32 j; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/EnHanabi_Init.s") + for (i = 0, j = 0; j < ARRAY_COUNT(D_80B23AA0) && i < 400; i++, arg1++) { + if (arg1->unk_00 <= 0) { + arg1->unk_00 = 1; + Math_Vec3f_Copy(&arg1->unk_08, arg0); + arg1->unk_20.x = phi_s1->x * temp_f22; + arg1->unk_20.y = (phi_s1->y * temp_f22) + 50.0f; + arg1->unk_20.z = phi_s1->z * temp_f22; + arg1->unk_04 = 1.5f * arg2; + func_80B22C2C(arg1, temp_s6); + phi_s1++; + j++; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/EnHanabi_Destroy.s") + return temp_s6; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/func_80B234C8.s") +void func_80B22E0C(EnHanabiStruct* arg0) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/func_80B235CC.s") + for (i = 0; i < 400; i++, arg0++) { + if (arg0->unk_00 == 1) { + arg0->unk_08.x += arg0->unk_20.x; + arg0->unk_08.y += arg0->unk_20.y; + arg0->unk_08.z += arg0->unk_20.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/func_80B236C8.s") + arg0->unk_20.x *= arg0->unk_14.x; + arg0->unk_20.z *= arg0->unk_14.x; + arg0->unk_20.y *= arg0->unk_14.x; + arg0->unk_20.y -= 1.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/func_80B23894.s") + arg0->unk_20.x += randPlusMinusPoint5Scaled(0.8f); + arg0->unk_20.y += randPlusMinusPoint5Scaled(0.8f); + arg0->unk_20.z += randPlusMinusPoint5Scaled(0.8f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/func_80B238D4.s") + if (arg0->unk_01 > 0) { + arg0->unk_01--; + } else { + arg0->unk_00 = 0; + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/func_80B23910.s") +s32 func_80B22F34(EnHanabiStruct* arg0) { + s32 count = 0; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/func_80B23934.s") + for (i = 0; i < 400; i++, arg0++) { + if (arg0->unk_00 == 1) { + count++; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/EnHanabi_Update.s") + return count; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/func_80B23A38.s") +void func_80B22FA8(EnHanabiStruct* arg0, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + s32 i; + u8 sp53; + + OPEN_DISPS(gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 20); + + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gSun1Tex)); + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_07AB10); + + sp53 = 0xFF; + if (sp53) {} + + for (i = 0; i < 400; i++, arg0++) { + if (arg0->unk_00 == 1) { + Matrix_InsertTranslation(arg0->unk_08.x, arg0->unk_08.y, arg0->unk_08.z, MTXMODE_NEW); + Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + if (arg0->unk_01 < 40) { + Matrix_Scale(arg0->unk_04 * 0.025f * arg0->unk_01, arg0->unk_04 * 0.025f * arg0->unk_01, 1.0f, + MTXMODE_APPLY); + } else { + Matrix_Scale(arg0->unk_04, arg0->unk_04, 1.0f, MTXMODE_APPLY); + } + Matrix_InsertZRotation_s(globalCtx->gameplayFrames * 4864, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + if (sp53 != arg0->unk_02) { + gDPPipeSync(POLY_XLU_DISP++); + gDPSetEnvColor(POLY_XLU_DISP++, D_80B23C40[arg0->unk_02], D_80B23C40[arg0->unk_02 + 1], + D_80B23C40[arg0->unk_02 + 2], 255); + + sp53 = arg0->unk_02; + } + + if (arg0->unk_01 < 6) { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, D_80B23C2C[arg0->unk_02], D_80B23C2C[arg0->unk_02 + 1], + D_80B23C2C[arg0->unk_02 + 2], arg0->unk_01 * 50); + } else { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, D_80B23C2C[arg0->unk_02], D_80B23C2C[arg0->unk_02 + 1], + D_80B23C2C[arg0->unk_02 + 2], 255); + } + + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_07AB58); + } + } + + CLOSE_DISPS(gfxCtx); +} + +void EnHanabi_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnHanabi* this = THIS; + s32 i; + + if (1) {} + + Actor_SetScale(thisx, 1.0f); + this->actionFunc = func_80B23910; + this->unk_144 = 0; + func_80B22C00(this->unk_148); + + for (i = 0; i < ARRAY_COUNT(this->unk_4608); i++) { + Lights_PointNoGlowSetInfo(&this->unk_4608[i], thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, 255, + 255, 255, -1); + this->unk_4634[i] = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->unk_4608[i]); + } + + if (ENHANABI_GET_1F(thisx) == ENHANABI_1F_1) { + this->actionFunc = func_80B23934; + this->actor.home.rot.x = 0x384; + } +} + +void EnHanabi_Destroy(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnHanabi* this = THIS; + s32 i; + + for (i = 0; i < ARRAY_COUNT(this->unk_4634); i++) { + LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->unk_4634[i]); + } +} + +void func_80B234C8(EnHanabi* this) { + s16 phi_v1; + s32 i; + + for (i = 0; i < ARRAY_COUNT(this->unk_4640); i++) { + if (this->unk_4640[i] > 0) { + this->unk_4640[i]--; + if (this->unk_4640[i] == 0) { + phi_v1 = -1; + } else { + if (this->unk_4640[i] >= 0xA) { + phi_v1 = 0x3E8; + } else { + phi_v1 = this->unk_4640[i] * 0x64; + } + + if (this->actor.home.rot.x >= 0x259) { + phi_v1 *= 2; + } + } + + Lights_PointSetColorAndRadius(&this->unk_4608[i], D_80B23C2C[this->unk_4648[i]], + D_80B23C2C[this->unk_4648[i] + 1], D_80B23C2C[this->unk_4648[i] + 2], phi_v1); + } + } +} + +void func_80B235CC(EnHanabi* this, Vec3f* arg1, s32 arg2) { + s32 i; + + for (i = 0; i < ARRAY_COUNT(this->unk_4640); i++) { + if (this->unk_4640[i] == 0) { + this->unk_4648[i] = arg2; + Lights_PointNoGlowSetInfo(&this->unk_4608[i], arg1->x, arg1->y, arg1->z, D_80B23C2C[arg2], + D_80B23C2C[arg2 + 1], D_80B23C2C[arg2 + 2], 0x3E8); + this->unk_4640[i] = 20; + break; + } + } +} + +void func_80B236C8(EnHanabi* this, GlobalContext* globalCtx) { + Vec3f sp34; + f32 sp30; + s32 pad; + s32 sp28; + + this->actor.draw = EnHanabi_Draw; + func_80B234C8(this); + if (this->actor.home.rot.x != 0) { + if (this->unk_144 > 0) { + this->unk_144--; + return; + } + + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); + + if (this->actor.home.rot.x != 0) { + sp30 = Rand_ZeroFloat(200.0f) + this->actor.home.rot.x; + } else { + sp30 = Rand_ZeroFloat(200.0f) + 300.0f; + } + + sp34.x += sp30 * Math_SinS(this->actor.home.rot.y); + sp34.y += randPlusMinusPoint5Scaled(300.0f); + sp34.z += sp30 * Math_CosS(this->actor.home.rot.y); + + if (this->actor.home.rot.x >= 0x259) { + sp28 = func_80B22C80(&sp34, this->unk_148, 2.0f); + } else { + sp28 = func_80B22C80(&sp34, this->unk_148, 1.0f); + } + + this->actor.home.rot.y += (s16)((Rand_ZeroFloat(40.0f) + 80.0f) * 256.0f); + this->unk_144 = (s32)Rand_ZeroFloat(5.0f) + 20; + Actor_PlaySfxAtPos(&this->actor, NA_SE_OC_FIREWORKS); + func_80B235CC(this, &sp34, sp28); + } +} + +void func_80B23894(EnHanabi* this, GlobalContext* globalCtx) { + func_80B236C8(this, globalCtx); + if (func_80B22F34(this->unk_148) == 0) { + Actor_MarkForDeath(&this->actor); + } +} + +void func_80B238D4(EnHanabi* this, GlobalContext* globalCtx) { + func_80B236C8(this, globalCtx); + if (this->actor.home.rot.x == 0) { + this->actionFunc = func_80B23894; + } +} + +void func_80B23910(EnHanabi* this, GlobalContext* globalCtx) { + if (this->actor.home.rot.x != 0) { + this->actionFunc = func_80B238D4; + } +} + +void func_80B23934(EnHanabi* this, GlobalContext* globalCtx) { + if ((gSaveContext.save.entranceIndex == 0x5410) && (gSaveContext.sceneSetupIndex == 7)) { + if (globalCtx->csCtx.frames > 1650) { + func_80B236C8(this, globalCtx); + func_800B8FE8(&this->actor, NA_SE_EV_FIREWORKS_LAUNCH - SFX_FLAG); + } + } + + if ((globalCtx->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 7) && + (globalCtx->csCtx.currentCsIndex == 0) && (globalCtx->csCtx.frames == 610)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_KYOJIN_GROAN); + } +} + +void EnHanabi_Update(Actor* thisx, GlobalContext* globalCtx) { + EnHanabi* this = THIS; + + this->actionFunc(this, globalCtx); + + func_80B22E0C(this->unk_148); +} + +void EnHanabi_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnHanabi* this = THIS; + + Matrix_StatePush(); + func_80B22FA8(this->unk_148, globalCtx); + Matrix_StatePop(); +} diff --git a/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.h b/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.h index 78f198ed40..ed4963daf2 100644 --- a/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.h +++ b/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.h @@ -7,9 +7,28 @@ struct EnHanabi; typedef void (*EnHanabiActionFunc)(struct EnHanabi*, GlobalContext*); +#define ENHANABI_GET_1F(thisx) ((thisx)->params & 0x1F) + +#define ENHANABI_1F_1 1 + +typedef struct { + /* 0x00 */ u8 unk_00; + /* 0x01 */ u8 unk_01; + /* 0x02 */ u8 unk_02; + /* 0x04 */ f32 unk_04; + /* 0x08 */ Vec3f unk_08; + /* 0x14 */ Vec3f unk_14; + /* 0x20 */ Vec3f unk_20; +} EnHanabiStruct; // size = 0x2C + typedef struct EnHanabi { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x4510]; + /* 0x0144 */ s16 unk_144; + /* 0x0148 */ EnHanabiStruct unk_148[400]; + /* 0x4608 */ LightInfo unk_4608[3]; + /* 0x4634 */ LightNode* unk_4634[3]; + /* 0x4640 */ s16 unk_4640[3]; + /* 0x4648 */ s32 unk_4648[3]; /* 0x4654 */ EnHanabiActionFunc actionFunc; } EnHanabi; // size = 0x4658 diff --git a/src/overlays/actors/ovl_En_Heishi/z_en_heishi.c b/src/overlays/actors/ovl_En_Heishi/z_en_heishi.c index 14bbf6a995..bb2fb002b7 100644 --- a/src/overlays/actors/ovl_En_Heishi/z_en_heishi.c +++ b/src/overlays/actors/ovl_En_Heishi/z_en_heishi.c @@ -73,14 +73,16 @@ void EnHeishi_Init(Actor* thisx, GlobalContext* globalCtx) { if (this->paramsCopy == 0) { this->shouldSetHeadRotation = 1; - if (!(gSaveContext.weekEventReg[63] & 0x80) && !((gSaveContext.day == 3) && gSaveContext.isNight)) { + if (!(gSaveContext.save.weekEventReg[63] & 0x80) && + !((gSaveContext.save.day == 3) && gSaveContext.save.isNight)) { Actor_MarkForDeath(&this->actor); } } else { this->colliderCylinder.dim.radius = 30; this->colliderCylinder.dim.height = 60; this->colliderCylinder.dim.yShift = 0; - if ((gSaveContext.weekEventReg[63] & 0x80) || ((gSaveContext.day == 3) && gSaveContext.isNight)) { + if ((gSaveContext.save.weekEventReg[63] & 0x80) || + ((gSaveContext.save.day == 3) && gSaveContext.save.isNight)) { Actor_MarkForDeath(&this->actor); } } @@ -150,7 +152,7 @@ void EnHeishi_Update(Actor* thisx, GlobalContext* globalCtx) { } this->actor.shape.rot.y = this->actor.world.rot.y; - if ((this->paramsCopy != 0) && (gSaveContext.day == 3) && gSaveContext.isNight) { + if ((this->paramsCopy != 0) && (gSaveContext.save.day == 3) && gSaveContext.save.isNight) { Actor_MarkForDeath(&this->actor); } else { this->actionFunc(this, globalCtx); diff --git a/src/overlays/actors/ovl_En_Hg/z_en_hg.c b/src/overlays/actors/ovl_En_Hg/z_en_hg.c index 2af301e139..0bbef0b9e3 100644 --- a/src/overlays/actors/ovl_En_Hg/z_en_hg.c +++ b/src/overlays/actors/ovl_En_Hg/z_en_hg.c @@ -126,7 +126,7 @@ void EnHg_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit2); - if ((gSaveContext.weekEventReg[75] & 0x20) || (gSaveContext.weekEventReg[52] & 0x20)) { + if ((gSaveContext.save.weekEventReg[75] & 0x20) || (gSaveContext.save.weekEventReg[52] & 0x20)) { Actor_MarkForDeath(&this->actor); } this->actor.targetMode = 1; @@ -304,7 +304,7 @@ void func_80BCF95C(EnHg* this, GlobalContext* globalCtx) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); break; case 6: - gSaveContext.weekEventReg[75] |= 0x20; + gSaveContext.save.weekEventReg[75] |= 0x20; Actor_MarkForDeath(&this->actor); break; } @@ -358,7 +358,7 @@ void func_80BCFC0C(EnHg* this, GlobalContext* globalCtx) { D_80BD00C8 = false; } if (globalCtx->msgCtx.ocarinaMode == 3) { - if (globalCtx->msgCtx.unk1202E == 7 && gSaveContext.playerForm == PLAYER_FORM_HUMAN) { + if (globalCtx->msgCtx.unk1202E == 7 && gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { if (INV_CONTENT(ITEM_MASK_GIBDO) == ITEM_MASK_GIBDO) { this->unk218 = 3; } else { @@ -369,8 +369,8 @@ void func_80BCFC0C(EnHg* this, GlobalContext* globalCtx) { } else { if (this->actor.xzDistToPlayer < 60.0f && fabsf(this->actor.playerHeightRel) < 40.0f) { if ((this->actionFunc != func_80BCF8A0) && (this->actionFunc != func_80BCF95C)) { - if (!(gSaveContext.weekEventReg[61] & 2)) { - gSaveContext.weekEventReg[61] |= 2; + if (!(gSaveContext.save.weekEventReg[61] & 2)) { + gSaveContext.save.weekEventReg[61] |= 2; this->unk218 = 0; } else { this->unk218 = 2; diff --git a/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c b/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c index d089de0da8..2aa2178463 100644 --- a/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c +++ b/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c @@ -94,7 +94,7 @@ void EnHgo_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_314 = 0; this->unk_310 = 0; this->unk_312 = 0; - if ((gSaveContext.weekEventReg[75] & 0x20) || (gSaveContext.weekEventReg[52] & 0x20)) { + if ((gSaveContext.save.weekEventReg[75] & 0x20) || (gSaveContext.save.weekEventReg[52] & 0x20)) { func_80BD049C(this); } else { thisx->draw = NULL; @@ -144,7 +144,7 @@ void func_80BD04E0(EnHgo* this, GlobalContext* globalCtx) { Message_StartTextbox(globalCtx, 0x15A7, &this->actor); this->unk_314 = 0x15A7; // can I research that mask } - } else if (gSaveContext.playerForm == PLAYER_FORM_HUMAN) { + } else if (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { if (!(this->unk_310 & 1)) { this->unk_310 |= 1; Message_StartTextbox(globalCtx, 0x158F, &this->actor); @@ -185,7 +185,7 @@ void EnHgo_DefaultDialogueHandler(EnHgo* this, GlobalContext* globalCtx) { func_80BD06FC(this, globalCtx); break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { func_80BD049C(this); } } @@ -194,14 +194,14 @@ void EnHgo_DefaultDialogueHandler(EnHgo* this, GlobalContext* globalCtx) { } void func_80BD06FC(EnHgo* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->unk_314) { case 0x158F: Message_StartTextbox(globalCtx, 0x1590, &this->actor); this->unk_314 = 0x1590; break; case 0x1590: - if (gSaveContext.weekEventReg[14] & 4) { + if (gSaveContext.save.weekEventReg[14] & 4) { Message_StartTextbox(globalCtx, 0x1591, &this->actor); this->unk_314 = 0x1591; break; @@ -303,7 +303,7 @@ s32 func_80BD0898(EnHgo* this, GlobalContext* globalCtx) { Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); return true; } - if ((globalCtx->csCtx.state == 0) && (((gSaveContext.weekEventReg[75]) & 0x20)) && + if ((globalCtx->csCtx.state == 0) && (((gSaveContext.save.weekEventReg[75]) & 0x20)) && (this->actionFunc == func_80BD0410)) { this->actor.shape.rot.y = this->actor.world.rot.y; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ELF_MSG2, this->actor.focus.pos.x, this->actor.focus.pos.y, diff --git a/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.c b/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.c index c19e596ace..e1432c10a3 100644 --- a/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.c +++ b/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.c @@ -5,6 +5,7 @@ */ #include "z_en_hidden_nuts.h" +#include "objects/object_hintnuts/object_hintnuts.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_2000000) @@ -15,15 +16,20 @@ void EnHiddenNuts_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnHiddenNuts_Update(Actor* thisx, GlobalContext* globalCtx); void EnHiddenNuts_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80BDB268(EnHiddenNuts* this); void func_80BDB2B8(EnHiddenNuts* this, GlobalContext* globalCtx); +void func_80BDB580(EnHiddenNuts* this); void func_80BDB59C(EnHiddenNuts* this, GlobalContext* globalCtx); +void func_80BDB788(EnHiddenNuts* this); void func_80BDB7E8(EnHiddenNuts* this, GlobalContext* globalCtx); void func_80BDB8F4(EnHiddenNuts* this, GlobalContext* globalCtx); +void func_80BDB930(EnHiddenNuts* this); void func_80BDB978(EnHiddenNuts* this, GlobalContext* globalCtx); +void func_80BDBA28(EnHiddenNuts* this, GlobalContext* globalCtx); void func_80BDBB48(EnHiddenNuts* this, GlobalContext* globalCtx); +void func_80BDBE70(EnHiddenNuts* this, GlobalContext* globalCtx); void func_80BDBED4(EnHiddenNuts* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Hidden_Nuts_InitVars = { ACTOR_EN_HIDDEN_NUTS, ACTORCAT_PROP, @@ -36,51 +42,397 @@ const ActorInit En_Hidden_Nuts_InitVars = { (ActorFunc)EnHiddenNuts_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BDC0D0 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 30, 20, 0, { 0, 0, 0 } }, }; -#endif +static AnimationHeader* D_80BDC0FC[] = { + &object_hintnuts_Anim_000168, &object_hintnuts_Anim_0024CC, &object_hintnuts_Anim_0026C4, + &object_hintnuts_Anim_002894, &object_hintnuts_Anim_002B90, &object_hintnuts_Anim_002F7C, + &object_hintnuts_Anim_003128, &object_hintnuts_Anim_0029BC, &object_hintnuts_Anim_0024CC, +}; -extern ColliderCylinderInit D_80BDC0D0; +u8 D_80BDC120[] = { + ANIMMODE_ONCE, ANIMMODE_ONCE, ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_ONCE, + ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_ONCE, ANIMMODE_LOOP, +}; -extern UNK_TYPE D_060024CC; +void EnHiddenNuts_Init(Actor* thisx, GlobalContext* globalCtx) { + EnHiddenNuts* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/EnHiddenNuts_Init.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); + SkelAnime_Init(globalCtx, &this->skelAnime, &object_hintnuts_Skel_0023B8.sh, &object_hintnuts_Anim_0024CC, + this->jointTable, this->morphTable, 10); + Actor_SetScale(&this->actor, 0.01f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/EnHiddenNuts_Destroy.s") + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->actor.targetMode = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/func_80BDB1B4.s") + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/func_80BDB268.s") + this->unk_21E = ENHIDDENNUTS_GET_F80(&this->actor); + this->switchFlag = ENHIDDENNUTS_GET_SWITCHFLAG(&this->actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/func_80BDB2B8.s") + if (this->switchFlag == 0x7F) { + this->switchFlag = -1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/func_80BDB580.s") + if ((this->switchFlag >= 0) && Flags_GetSwitch(globalCtx, this->switchFlag)) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/func_80BDB59C.s") + if (this->unk_21E == 0x1F) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/func_80BDB788.s") + this->path = SubS_GetPathByIndex(globalCtx, this->unk_21E, 0x3F); + this->unk_226 = this->actor.cutscene; + func_801A5080(2); + func_80BDB268(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/func_80BDB7E8.s") +void EnHiddenNuts_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnHiddenNuts* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/func_80BDB8F4.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/func_80BDB930.s") +void func_80BDB1B4(EnHiddenNuts* this, s32 arg1) { + f32 sp34; + f32 sp30; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/func_80BDB978.s") + this->unk_220 = arg1; + sp34 = 0.0f; + sp30 = -4.0f; + this->unk_22C = Animation_GetLastFrame(D_80BDC0FC[arg1]); + if (this->unk_220 == 1) { + sp34 = this->unk_22C; + sp30 = 0.0f; + } + Animation_Change(&this->skelAnime, D_80BDC0FC[this->unk_220], 1.0f, sp34, this->unk_22C, D_80BDC120[this->unk_220], + sp30); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/func_80BDBA28.s") +void func_80BDB268(EnHiddenNuts* this) { + this->actor.textId = 0x234; + this->unk_228 = 1600.0f; + this->actor.shape.yOffset = 1600.0f; + func_80BDB1B4(this, 1); + this->unk_21A = 0; + this->actionFunc = func_80BDB2B8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/func_80BDBB48.s") +void func_80BDB2B8(EnHiddenNuts* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/func_80BDBE70.s") + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NEMURI_SLEEP - SFX_FLAG); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/func_80BDBED4.s") + if (player->stateFlags2 & 0x8000000) { + if (this->unk_20A == 0) { + play_sound(NA_SE_SY_TRE_BOX_APPEAR); + this->unk_20A = 1; + } + } else { + this->unk_20A = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/EnHiddenNuts_Update.s") + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) != 0) { + func_80BDB580(this); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/EnHiddenNuts_Draw.s") + if (this->unk_218 == 0) { + Vec3f sp94 = { 0.0f, 0.0f, 0.0f }; + Vec3f sp88 = { 0.0f, 0.0f, 0.0f }; + Color_RGBA8 sp84 = { 255, 255, 255, 255 }; + Color_RGBA8 sp80 = { 150, 150, 150, 0 }; + Vec3f sp74; + + for (i = 0; i < 3; i++) { + sp94.y = Rand_ZeroFloat(1.0f) + 1.0f; + + Math_Vec3f_Copy(&sp74, &this->actor.world.pos); + + sp74.x += randPlusMinusPoint5Scaled(15.0f); + sp74.z += randPlusMinusPoint5Scaled(15.0f); + + EffectSsDtBubble_SpawnCustomColor(globalCtx, &sp74, &sp94, &sp88, &sp84, &sp80, Rand_S16Offset(120, 90), 30, + 1); + } + this->unk_218 = 30; + } + + if (!(this->actor.xzDistToPlayer > 120.0f)) { + if ((globalCtx->msgCtx.ocarinaMode == 3) && (globalCtx->msgCtx.unk1202E == 0)) { + globalCtx->msgCtx.ocarinaMode = 4; + func_80BDB788(this); + } else if (func_801A5100() == 2) { + func_80BDB788(this); + } else { + func_800B8614(&this->actor, globalCtx, BREG(13) + 100.0f); + } + } +} + +void func_80BDB580(EnHiddenNuts* this) { + this->unk_21A = 1; + this->actionFunc = func_80BDB59C; +} + +void func_80BDB59C(EnHiddenNuts* this, GlobalContext* globalCtx) { + s32 i; + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NEMURI_SLEEP - SFX_FLAG); + + if (this->unk_218 == 0) { + Vec3f sp98 = { 0.0f, 0.0f, 0.0f }; + Vec3f sp8C = { 0.0f, 0.0f, 0.0f }; + Color_RGBA8 sp88 = { 255, 255, 255, 255 }; + Color_RGBA8 sp84 = { 150, 150, 150, 0 }; + Vec3f sp78; + + for (i = 0; i < 3; i++) { + sp98.y = Rand_ZeroFloat(1.0f) + 1.0f; + + Math_Vec3f_Copy(&sp78, &this->actor.world.pos); + + sp78.x += randPlusMinusPoint5Scaled(15.0f); + sp78.z += randPlusMinusPoint5Scaled(15.0f); + + EffectSsDtBubble_SpawnCustomColor(globalCtx, &sp78, &sp98, &sp8C, &sp88, &sp84, Rand_S16Offset(120, 90), 30, + 1); + } + this->unk_218 = 30; + } + + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + func_801477B4(globalCtx); + func_80BDB268(this); + } +} + +void func_80BDB788(EnHiddenNuts* this) { + this->actor.flags |= ACTOR_FLAG_10; + this->actor.flags |= ACTOR_FLAG_8000000; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DEAD); + this->unk_21A = 2; + this->actionFunc = func_80BDB7E8; +} + +void func_80BDB7E8(EnHiddenNuts* this, GlobalContext* globalCtx) { + Vec3f sp3C; + + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->unk_226); + return; + } + + if (!ActorCutscene_GetCanPlayNext(this->unk_226)) { + ActorCutscene_SetIntentToPlay(this->unk_226); + return; + } + + ActorCutscene_StartAndSetUnkLinkFields(this->unk_226, &this->actor); + this->unk_228 = -1200.0f; + + Math_Vec3f_Copy(&sp3C, &this->actor.world.pos); + sp3C.y = this->actor.floorHeight + 30.0f; + + EffectSsHahen_SpawnBurst(globalCtx, &sp3C, 4.0f, 0, 10, 3, 15, -1, 10, NULL); + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); + func_80BDB1B4(this, 7); + this->actionFunc = func_80BDB8F4; +} + +void func_80BDB8F4(EnHiddenNuts* this, GlobalContext* globalCtx) { + f32 curFrame = this->skelAnime.curFrame; + + if (this->unk_22C <= curFrame) { + func_80BDB930(this); + } +} + +void func_80BDB930(EnHiddenNuts* this) { + func_80BDB1B4(this, 3); + this->unk_21A = 3; + this->unk_228 = 500.0f; + this->actionFunc = func_80BDB978; +} + +void func_80BDB978(EnHiddenNuts* this, GlobalContext* globalCtx) { + f32 curFrame = this->skelAnime.curFrame; + + if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 8.0f) || + Animation_OnFrame(&this->skelAnime, 18.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUT_FAINT); + } + + if (this->unk_22C <= curFrame) { + this->unk_224++; + if (this->unk_224 >= 2) { + func_80BDBA28(this, globalCtx); + } + } +} + +void func_80BDBA28(EnHiddenNuts* this, GlobalContext* globalCtx) { + Vec3f sp44; + + func_80BDB1B4(this, 2); + this->unk_228 = 0.0f; + + Math_Vec3f_Copy(&sp44, &this->actor.world.pos); + sp44.y = this->actor.floorHeight + 30.0f; + + EffectSsHahen_SpawnBurst(globalCtx, &sp44, 4.0f, 0, 10, 3, 15, -1, 10, NULL); + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); + this->unk_208 = 1; + + if ((this->path != NULL) && !SubS_CopyPointFromPath(this->path, this->unk_208, &this->unk_20C)) { + Actor_MarkForDeath(&this->actor); + } + + this->actor.speedXZ = 2.0f; + this->actor.gravity = -2.0f; + this->actor.velocity.y = 4.0f; + this->actor.world.rot.y = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_20C); + this->unk_21A = 4; + this->actionFunc = func_80BDBB48; +} + +void func_80BDBB48(EnHiddenNuts* this, GlobalContext* globalCtx) { + s32 pad[3]; + f32 sp58 = this->skelAnime.curFrame; + WaterBox* sp54; + f32 sp50; + s16 sp4E = 0; + Vec3f sp40; + + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp50, + &sp54) && + (this->actor.world.pos.y < sp50)) { + this->actor.velocity.y = 0.0f; + Math_Vec3f_Copy(&sp40, &this->actor.world.pos); + sp40.y = sp50; + this->actor.gravity = 0.0f; + + if ((globalCtx->gameplayFrames % 8) == 0) { + EffectSsGRipple_Spawn(globalCtx, &sp40, 650, 3150, 0); + } + + if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 5.0f) || + Animation_OnFrame(&this->skelAnime, 10.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WALK_WATER); + sp4E = 1; + } + } + + if ((sp4E != 0) && (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 5.0f) || + Animation_OnFrame(&this->skelAnime, 10.0f))) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_WALK); + } + + Math_SmoothStepToS(&this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_20C), 1, 0x1388, 0); + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 1, 0x3E8, 0); + + if (this->unk_220 == 2) { + if (this->unk_22C <= sp58) { + this->actor.speedXZ = 0.0f; + this->actor.velocity.y = 0.0f; + func_80BDB1B4(this, 6); + } + } else { + Math_ApproachF(&this->actor.world.pos.x, this->unk_20C.x, 0.5f, + fabsf(Math_SinS(this->actor.world.rot.y) * (BREG(33) + 8.0f))); + Math_ApproachF(&this->actor.world.pos.z, this->unk_20C.z, 0.5f, + fabsf(Math_CosS(this->actor.world.rot.y) * (BREG(33) + 8.0f))); + + if ((sqrtf(SQ(this->actor.world.pos.x - this->unk_20C.x) + SQ(this->actor.world.pos.z - this->unk_20C.z)) < + 4.0f) && + (this->path != NULL)) { + this->unk_208++; + if (this->unk_208 >= this->path->count) { + func_80BDBE70(this, globalCtx); + } else if ((this->path != NULL) && !SubS_CopyPointFromPath(this->path, this->unk_208, &this->unk_20C)) { + Actor_MarkForDeath(&this->actor); + } + } + } +} + +void func_80BDBE70(EnHiddenNuts* this, GlobalContext* globalCtx) { + if (this->switchFlag >= 0) { + Flags_SetSwitch(globalCtx, this->switchFlag); + } + func_80BDB1B4(this, 8); + this->unk_21A = 5; + this->actionFunc = func_80BDBED4; +} + +void func_80BDBED4(EnHiddenNuts* this, GlobalContext* globalCtx) { + f32 curFrame = this->skelAnime.curFrame; + Vec3f sp38; + + if (this->unk_22C <= curFrame) { + Math_Vec3f_Copy(&sp38, &this->actor.world.pos); + sp38.y = this->actor.floorHeight; + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); + EffectSsHahen_SpawnBurst(globalCtx, &sp38, 4.0f, 0, 10, 3, 15, -1, 10, NULL); + Actor_MarkForDeath(&this->actor); + } +} + +void EnHiddenNuts_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnHiddenNuts* this = THIS; + + if (this->unk_218 != 0) { + this->unk_218--; + } + + Actor_SetFocus(&this->actor, 20.0f); + SkelAnime_Update(&this->skelAnime); + + this->actionFunc(this, globalCtx); + + Math_ApproachF(&this->actor.shape.yOffset, this->unk_228, 0.5f, 200.0f); + + if (this->unk_21A >= 4) { + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 40.0f, 0x1D); + } + + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +void EnHiddenNuts_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnHiddenNuts* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.h b/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.h index 08dc574fea..baff911b68 100644 --- a/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.h +++ b/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.h @@ -7,11 +7,30 @@ struct EnHiddenNuts; typedef void (*EnHiddenNutsActionFunc)(struct EnHiddenNuts*, GlobalContext*); +#define ENHIDDENNUTS_GET_SWITCHFLAG(thisx) ((thisx)->params & 0x7F) +#define ENHIDDENNUTS_GET_F80(thisx) (((thisx)->params >> 7) & 0x1F) + typedef struct EnHiddenNuts { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xBC]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[10]; + /* 0x01C4 */ Vec3s morphTable[10]; /* 0x0200 */ EnHiddenNutsActionFunc actionFunc; - /* 0x0204 */ char unk_204[0x7C]; + /* 0x0204 */ Path* path; + /* 0x0208 */ s16 unk_208; + /* 0x020A */ u8 unk_20A; + /* 0x020C */ Vec3f unk_20C; + /* 0x0218 */ s16 unk_218; + /* 0x021A */ s16 unk_21A; + /* 0x021C */ s16 switchFlag; + /* 0x021E */ s16 unk_21E; + /* 0x0220 */ s32 unk_220; + /* 0x0224 */ s16 unk_224; + /* 0x0226 */ s16 unk_226; + /* 0x0228 */ f32 unk_228; + /* 0x022C */ f32 unk_22C; + /* 0x0230 */ UNK_TYPE1 unk230[4]; + /* 0x0234 */ ColliderCylinder collider; } EnHiddenNuts; // size = 0x280 extern const ActorInit En_Hidden_Nuts_InitVars; diff --git a/src/overlays/actors/ovl_En_Hint_Skb/z_en_hint_skb.c b/src/overlays/actors/ovl_En_Hint_Skb/z_en_hint_skb.c index fa5b8e1904..51a408e6e5 100644 --- a/src/overlays/actors/ovl_En_Hint_Skb/z_en_hint_skb.c +++ b/src/overlays/actors/ovl_En_Hint_Skb/z_en_hint_skb.c @@ -162,7 +162,7 @@ void EnHintSkb_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_3DE = 0; this->unk_3E0 = 0; this->unk_3DC = 0; - this->unk_3E9 = 0; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; func_80C1FE0C(this); } @@ -340,10 +340,10 @@ void func_80C20540(EnHintSkb* this) { } void func_80C20590(EnHintSkb* this, GlobalContext* globalCtx) { - if (this->unk_3E2 == 0) { - this->unk_3E2 = 0; - this->unk_2D8 = 0.0f; - this->unk_2D4 = 0.0f; + if (this->drawDmgEffTimer == 0) { + this->drawDmgEffTimer = 0; + this->drawDmgEffScale = 0.0f; + this->drawDmgEffAlpha = 0.0f; if (this->actor.colChkInfo.health != 0) { Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); @@ -354,7 +354,7 @@ void func_80C20590(EnHintSkb* this, GlobalContext* globalCtx) { SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_STALKID_DEAD); func_80C20484(this); } - } else if (this->unk_3E2 == 1) { + } else if (this->drawDmgEffTimer == 1) { func_80C21468(this, globalCtx); } } @@ -367,10 +367,10 @@ void func_80C2066C(EnHintSkb* this) { } void func_80C2069C(EnHintSkb* this, GlobalContext* globalCtx) { - if (this->unk_3E2 == 0) { - this->unk_3E2 = 0; - this->unk_2D8 = 0.0f; - this->unk_2D4 = 0.0f; + if (this->drawDmgEffTimer == 0) { + this->drawDmgEffTimer = 0; + this->drawDmgEffScale = 0.0f; + this->drawDmgEffAlpha = 0.0f; if (this->actor.colChkInfo.health != 0) { Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); @@ -438,7 +438,7 @@ void func_80C208D0(EnHintSkb* this, GlobalContext* globalCtx) { break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { func_80C2075C(this); } break; @@ -516,7 +516,7 @@ void func_80C20A74(EnHintSkb* this, GlobalContext* globalCtx) { } void func_80C20B88(EnHintSkb* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (globalCtx->msgCtx.choiceIndex == 0) { func_8019F208(); this->unk_3E8 |= 0x10; @@ -531,7 +531,7 @@ void func_80C20B88(EnHintSkb* this, GlobalContext* globalCtx) { } void func_80C20C24(EnHintSkb* this, GlobalContext* globalCtx) { - if (!func_80147624(globalCtx)) { + if (!Message_ShouldAdvance(globalCtx)) { return; } @@ -636,10 +636,10 @@ void func_80C20E90(EnHintSkb* this, GlobalContext* globalCtx) { case 9: case 10: case 11: - if (this->unk_3E2 >= 2) { + if (this->drawDmgEffTimer > 1) { func_80C21468(this, globalCtx); } - this->unk_3E2 = 0; + this->drawDmgEffTimer = 0; break; } } @@ -655,10 +655,10 @@ void func_80C20E90(EnHintSkb* this, GlobalContext* globalCtx) { switch (this->actor.colChkInfo.damageEffect) { case 11: - this->unk_3E9 = 30; - this->unk_3E2 = 40; - this->unk_2D4 = 1.0f; - this->unk_2D8 = 0.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; + this->drawDmgEffTimer = 40; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffScale = 0.0f; Actor_SetColorFilter(&this->actor, 0, 120, 0, 40); func_80C2011C(this); break; @@ -669,10 +669,10 @@ void func_80C20E90(EnHintSkb* this, GlobalContext* globalCtx) { break; case 2: - this->unk_3E2 = 80; - this->unk_3E9 = 0; - this->unk_2D4 = 1.0f; - this->unk_2D8 = 0.0f; + this->drawDmgEffTimer = 80; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffScale = 0.0f; Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); this->unk_3E8 |= 1; @@ -681,21 +681,21 @@ void func_80C20E90(EnHintSkb* this, GlobalContext* globalCtx) { case 3: if (this->actor.colChkInfo.health != 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); - this->unk_3E2 = 80; + this->drawDmgEffTimer = 80; } else { - this->unk_3E2 = 3; + this->drawDmgEffTimer = 3; } - this->unk_3E9 = 11; - this->unk_2D4 = 1.0f; - this->unk_2D8 = 0.5f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_SFX; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffScale = 0.5f; Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); func_80C20540(this); break; case 4: - this->unk_3E2 = 40; - this->unk_3E9 = 20; - this->unk_2D4 = 1.0f; - this->unk_2D8 = 0.5f; + this->drawDmgEffTimer = 40; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffScale = 0.5f; Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); @@ -747,20 +747,20 @@ void func_80C21250(EnHintSkb* this, GlobalContext* globalCtx) { } void func_80C21320(EnHintSkb* this, GlobalContext* globalCtx) { - if (this->unk_3E2 > 0) { - this->unk_3E2--; + if (this->drawDmgEffTimer > 0) { + this->drawDmgEffTimer--; } if (this->actionFunc != func_80C20590) { - if (this->unk_3E2 < 20) { + if (this->drawDmgEffTimer < 20) { if (this->actionFunc == func_80C2069C) { - Math_SmoothStepToF(&this->unk_2D8, 0.0f, 0.5f, 0.03f, 0.0f); + Math_SmoothStepToF(&this->drawDmgEffScale, 0.0f, 0.5f, 0.03f, 0.0f); } else { - Math_SmoothStepToF(&this->unk_2D8, 0.0f, 0.5f, 0.01f, 0.0f); + Math_SmoothStepToF(&this->drawDmgEffScale, 0.0f, 0.5f, 0.01f, 0.0f); } - this->unk_2D4 = this->unk_3E2 * 0.05f; + this->drawDmgEffAlpha = this->drawDmgEffTimer * 0.05f; } else { - Math_SmoothStepToF(&this->unk_2D8, 0.5f, 0.1f, 0.02f, 0.0f); + Math_SmoothStepToF(&this->drawDmgEffScale, 0.5f, 0.1f, 0.02f, 0.0f); } } } @@ -782,21 +782,21 @@ void func_80C21468(EnHintSkb* this, GlobalContext* globalCtx) { s32 i; if (this->unk_3E8 & 2) { - phi_s4 = ARRAY_COUNT(this->unk_22C) - 1; + phi_s4 = ARRAY_COUNT(this->limbPos) - 1; } else { - phi_s4 = ARRAY_COUNT(this->unk_22C); + phi_s4 = ARRAY_COUNT(this->limbPos); } SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 30, NA_SE_EV_ICE_BROKEN); for (i = 0; i < phi_s4; i++) { - temp_s1 = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_22C[i]); + temp_s1 = Math_Vec3f_Yaw(&this->actor.world.pos, &this->limbPos[i]); sp84.x = Math_SinS(temp_s1) * 3.0f; sp84.z = Math_CosS(temp_s1) * 3.0f; sp84.y = (Rand_ZeroOne() * 4.0f) + 4.0f; - EffectSsEnIce_Spawn(globalCtx, &this->unk_22C[i], 0.6f, &sp84, &D_80C21E4C, &D_80C21E44, &D_80C21E48, 30); + EffectSsEnIce_Spawn(globalCtx, &this->limbPos[i], 0.6f, &sp84, &D_80C21E4C, &D_80C21E44, &D_80C21E48, 30); } } @@ -879,15 +879,15 @@ void EnHintSkb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList Actor_SpawnBodyParts(&this->actor, globalCtx, 1, dList); } - if (this->unk_3E2 != 0) { + if (this->drawDmgEffTimer != 0) { if ((limbIndex == 2) || (limbIndex == 4) || (limbIndex == 5) || (limbIndex == 6) || (limbIndex == 7) || (limbIndex == 8) || (limbIndex == 9) || (limbIndex == 13) || (limbIndex == 14) || (limbIndex == 15) || (limbIndex == 16) || (limbIndex == 17) || (limbIndex == 18)) { - Matrix_GetStateTranslation(&this->unk_22C[this->unk_2DC]); - this->unk_2DC++; + Matrix_GetStateTranslation(&this->limbPos[this->limbCount]); + this->limbCount++; } else if ((limbIndex == 11) && !(this->unk_3E8 & 2)) { - Matrix_MultiplyVector3fByState(&D_80C21E70, &this->unk_22C[this->unk_2DC]); - this->unk_2DC++; + Matrix_MultiplyVector3fByState(&D_80C21E70, &this->limbPos[this->limbCount]); + this->limbCount++; } } } @@ -896,13 +896,13 @@ void EnHintSkb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList void EnHintSkb_Draw(Actor* thisx, GlobalContext* globalCtx) { EnHintSkb* this = THIS; - this->unk_2DC = 0; + this->limbCount = 0; func_8012C28C(globalCtx->state.gfxCtx); SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnHintSkb_OverrideLimbDraw, EnHintSkb_PostLimbDraw, &this->actor); - if (this->unk_3E2 > 0) { - func_800BE680(globalCtx, &this->actor, this->unk_22C, this->unk_2DC, this->unk_2D8, 0.5f, this->unk_2D4, - this->unk_3E9); + if (this->drawDmgEffTimer > 0) { + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, this->limbCount, this->drawDmgEffScale, 0.5f, + this->drawDmgEffAlpha, this->drawDmgEffType); } if (this->unk_3E8 & 4) { diff --git a/src/overlays/actors/ovl_En_Hint_Skb/z_en_hint_skb.h b/src/overlays/actors/ovl_En_Hint_Skb/z_en_hint_skb.h index e399638b7d..b67e563528 100644 --- a/src/overlays/actors/ovl_En_Hint_Skb/z_en_hint_skb.h +++ b/src/overlays/actors/ovl_En_Hint_Skb/z_en_hint_skb.h @@ -15,21 +15,21 @@ typedef struct EnHintSkb { /* 0x0164 */ ColliderJntSphElement colliderElement[2]; /* 0x01E4 */ SkelAnime skelAnime; /* 0x0228 */ EnHintSkbActionFunc actionFunc; - /* 0x022C */ Vec3f unk_22C[14]; - /* 0x02D4 */ f32 unk_2D4; - /* 0x02D8 */ f32 unk_2D8; - /* 0x02DC */ s32 unk_2DC; + /* 0x022C */ Vec3f limbPos[14]; + /* 0x02D4 */ f32 drawDmgEffAlpha; + /* 0x02D8 */ f32 drawDmgEffScale; + /* 0x02DC */ s32 limbCount; /* 0x02E0 */ Vec3s jointTable[20]; /* 0x0358 */ Vec3s morphtable[20]; /* 0x03D0 */ UNK_TYPE1 unk3D0[0xC]; /* 0x03DC */ s16 unk_3DC; /* 0x03DE */ s16 unk_3DE; /* 0x03E0 */ s16 unk_3E0; - /* 0x03E2 */ s16 unk_3E2; + /* 0x03E2 */ s16 drawDmgEffTimer; /* 0x03E4 */ s16 unk_3E4; /* 0x03E6 */ u16 unk_3E6; /* 0x03E8 */ u8 unk_3E8; - /* 0x03E9 */ u8 unk_3E9; + /* 0x03E9 */ u8 drawDmgEffType; } EnHintSkb; // size = 0x3EC extern const ActorInit En_Hint_Skb_InitVars; diff --git a/src/overlays/actors/ovl_En_Horse/z_en_horse.c b/src/overlays/actors/ovl_En_Horse/z_en_horse.c index ad9089df6c..d71ac41afa 100644 --- a/src/overlays/actors/ovl_En_Horse/z_en_horse.c +++ b/src/overlays/actors/ovl_En_Horse/z_en_horse.c @@ -5,6 +5,7 @@ */ #include "z_en_horse.h" +#include "objects/object_horse_link_child/object_horse_link_child.h" #define FLAGS (ACTOR_FLAG_10) @@ -15,7 +16,116 @@ void EnHorse_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnHorse_Update(Actor* thisx, GlobalContext* globalCtx); void EnHorse_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_8087D540(Actor* thisx, GlobalContext* globalCtx); +void EnHorse_StartMountedIdleResetAnim(EnHorse* this); +void EnHorse_StartMountedIdle(EnHorse* this); +void EnHorse_MountedIdle(EnHorse* this, GlobalContext* globalCtx); +void EnHorse_MountedIdleAnim(EnHorse* this); +void EnHorse_MountedIdleWhinney(EnHorse* this); +void EnHorse_StartTurning(EnHorse* this); +void EnHorse_StartWalkingFromIdle(EnHorse* this); +void EnHorse_StartWalkingInterruptable(EnHorse* this); +void EnHorse_StartWalking(EnHorse* this); +void EnHorse_StartTrotting(EnHorse* this); +void EnHorse_StartGallopingInterruptable(EnHorse* this); +void EnHorse_StartGalloping(EnHorse* this); +void EnHorse_StartBraking(EnHorse* this, GlobalContext* globalCtx); +void EnHorse_StartReversingInterruptable(EnHorse* this); +void EnHorse_StartReversing(EnHorse* this); +void EnHorse_StartLowJump(EnHorse* this, GlobalContext* globalCtx); +void EnHorse_StartHighJump(EnHorse* this, GlobalContext* globalCtx); +void EnHorse_InitInactive(EnHorse* this); +void EnHorse_ChangeIdleAnimation(EnHorse* this, s32 anim, f32 morphFrames); +void EnHorse_ResetIdleAnimation(EnHorse* this); +void EnHorse_StartIdleRidable(EnHorse* this); +void EnHorse_StartMovingAnimation(EnHorse* this, s32 anim, f32 morphFrames, f32 startFrames); +void EnHorse_SetFollowAnimation(EnHorse* this, GlobalContext* globalCtx); +void EnHorse_InitIngoHorse(EnHorse* this); +void EnHorse_UpdateIngoHorseAnim(EnHorse* this); +void func_80881290(EnHorse* this, GlobalContext* globalCtx); +void func_8088159C(EnHorse* this, GlobalContext* globalCtx); +void func_80881634(EnHorse* this); +void func_8088168C(EnHorse* this); +void EnHorse_CsMoveInit(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void EnHorse_CsMoveToPoint(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void EnHorse_CsPlayHighJumpAnim(EnHorse* this, GlobalContext* globalCtx); +void EnHorse_CsJumpInit(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void EnHorse_CsJump(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void EnHorse_CsRearingInit(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void EnHorse_CsRearing(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void EnHorse_WarpMoveInit(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void EnHorse_CsWarpMoveToPoint(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void EnHorse_CsWarpRearingInit(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void EnHorse_CsWarpRearing(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void EnHorse_InitCutscene(EnHorse* this, GlobalContext* globalCtx); +void EnHorse_InitHorsebackArchery(EnHorse* this); +void EnHorse_UpdateHbaAnim(EnHorse* this); +void func_80883BEC(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_80883CB0(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_80883D64(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_80883DE0(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_80883E10(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_80883EA0(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_80883F18(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_80883F98(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_80884010(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_808840C4(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_80884194(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_8088424C(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_80884314(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_808843B4(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_80884444(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_808844E0(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_80884564(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_80884604(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_808846B4(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_808846DC(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_808846F0(EnHorse* this, GlobalContext* globalCtx); +void func_80884994(EnHorse* this); +void func_80884D04(EnHorse* this, GlobalContext* globalCtx); +void EnHorse_StickDirection(Vec2f* curStick, f32* stickMag, s16* angle); +s32 EnHorse_GetMountSide(EnHorse* this, GlobalContext* globalCtx); + +typedef struct { + s32 csAction; + s32 csFuncIdx; +} CsActionEntry; + +typedef struct { + s16 x; + s16 y; + s16 z; + s16 speed; + s16 angle; +} RaceWaypoint; + +typedef struct { + s32 numWaypoints; + RaceWaypoint* waypoints; +} RaceInfo; + +static AnimationHeader* sEponaAnimHeaders[] = { + &object_horse_link_child_Anim_006D44, &object_horse_link_child_Anim_007468, &object_horse_link_child_Anim_005F64, + &object_horse_link_child_Anim_004DE8, &object_horse_link_child_Anim_007D50, &object_horse_link_child_Anim_0043AC, + &object_horse_link_child_Anim_002F98, &object_horse_link_child_Anim_0035B0, &object_horse_link_child_Anim_003D38, +}; + +static AnimationHeader* sHniAnimHeaders[] = { + &object_ha_Anim_00C850, &object_ha_Anim_00CE70, &object_ha_Anim_00B9C8, + &object_ha_Anim_00B00C, &object_ha_Anim_00D648, &object_ha_Anim_00A650, + &object_ha_Anim_009208, &object_ha_Anim_009858, &object_ha_Anim_00A05C, +}; + +static AnimationHeader** sAnimationHeaders[] = { + NULL, NULL, sEponaAnimHeaders, sHniAnimHeaders, sHniAnimHeaders, +}; + +static f32 sPlaybackSpeeds[] = { 2.0f / 3.0f, 2.0f / 3.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 2.0f / 3.0f, 2.0f / 3.0f }; + +static SkeletonHeader* sSkeletonHeaders[] = { + NULL, NULL, &object_horse_link_child_Skel_00A480, NULL, NULL, +}; + const ActorInit En_Horse_InitVars = { ACTOR_EN_HORSE, ACTORCAT_BG, @@ -28,370 +138,4616 @@ const ActorInit En_Horse_InitVars = { (ActorFunc)EnHorse_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80888F74 = { - { COLTYPE_NONE, AT_NONE | AT_TYPE_PLAYER, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1 | OC2_UNK1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000004, 0x00, 0x02 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NONE, BUMP_NONE, OCELEM_ON, }, - { 20, 70, 0, { 0, 0, 0 } }, -}; - -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80888FA0 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1 | OC2_UNK1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, - { 20, 70, 0, { 0, 0, 0 } }, -}; - -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_80888FCC[1] = { +static ColliderCylinderInit sCylinderInit1 = { { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00013820, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_NO_AT_INFO | BUMP_NO_DAMAGE | BUMP_NO_SWORD_SFX | BUMP_NO_HITMARK, OCELEM_ON, }, + COLTYPE_NONE, + AT_NONE | AT_TYPE_PLAYER, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1 | OC2_UNK1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000004, 0x00, 0x02 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NONE, + BUMP_NONE, + OCELEM_ON, + }, + { 20, 70, 0, { 0, 0, 0 } }, +}; + +static ColliderCylinderInit sCylinderInit2 = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1 | OC2_UNK1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, + { 20, 70, 0, { 0, 0, 0 } }, +}; + +static ColliderJntSphElementInit sJntSphElementsInit[] = { + { + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00013820, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_NO_AT_INFO | BUMP_NO_DAMAGE | BUMP_NO_SWORD_SFX | BUMP_NO_HITMARK, + OCELEM_ON, + }, { 13, { { 0, 0, 0 }, 20 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_80888FF0 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1 | OC2_UNK1, COLSHAPE_JNTSPH, }, - 1, D_80888FCC, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1 | OC2_UNK1, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, }; -// sColChkInfoInit -static CollisionCheckInfoInit D_80889000 = { 10, 35, 100, MASS_HEAVY }; +static CollisionCheckInfoInit sColChkInfoInit = { 10, 35, 100, MASS_HEAVY }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80889010[] = { +static s32 sAnimSoundFrames[] = { + 0, + 16, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneScale, 1200, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 300, ICHAIN_STOP), }; +static u8 sResetNoInput[] = { + false, false, false, false, false, false, true, true, true, true, true, true, + true, true, true, false, false, false, false, false, false, false, false, false, +}; + +static s32 sIdleAnimIds[] = { + 1, 3, 0, 3, 1, 0, +}; + +static s16 sIngoAnimations[] = { 7, 6, 2, 2, 1, 1, 0, 0, 0, 0 }; + +static EnHorseCsFunc sCutsceneInitFuncs[] = { + NULL, + EnHorse_CsMoveInit, + EnHorse_CsJumpInit, + EnHorse_CsRearingInit, + EnHorse_WarpMoveInit, + EnHorse_CsWarpRearingInit, +}; + +static EnHorseCsFunc sCutsceneActionFuncs[] = { + NULL, EnHorse_CsMoveToPoint, EnHorse_CsJump, EnHorse_CsRearing, EnHorse_CsWarpMoveToPoint, EnHorse_CsWarpRearing, +}; + +static CsActionEntry sCsActionTable[] = { + { 36, 1 }, { 37, 2 }, { 38, 3 }, { 64, 4 }, { 65, 5 }, +}; + +static RaceWaypoint sHbaWaypoints[] = { + { 3600, 1413, -5055, 11, 0x8001 }, { 3360, 1413, -5220, 5, 0xC000 }, { 3100, 1413, -4900, 5, 0x0000 }, + { 3600, 1413, -4100, 11, 0x0000 }, { 3600, 1413, 360, 11, 0x0000 }, +}; + +static RaceInfo sHbaInfo = { 5, sHbaWaypoints }; + +static EnHorseCsFunc D_808890F0[] = { + NULL, func_80883BEC, func_80883D64, func_80883E10, func_80883F18, func_80884010, + func_80884194, func_80884314, func_80884444, func_80884564, func_808846B4, +}; + +static EnHorseCsFunc D_8088911C[] = { + NULL, func_80883CB0, func_80883DE0, func_80883EA0, func_80883F98, func_808840C4, + func_8088424C, func_808843B4, func_808844E0, func_80884604, func_808846DC, +}; + +void EnHorse_RaceWaypointPos(RaceWaypoint* waypoints, s32 idx, Vec3f* pos) { + pos->x = waypoints[idx].x; + pos->y = waypoints[idx].y; + pos->z = waypoints[idx].z; +} + +void EnHorse_RotateToPoint(EnHorse* this, GlobalContext* globalCtx, Vec3f* pos, s16 turnAmount) { + func_800F415C(&this->actor, pos, turnAmount); +} + +void func_8087B7C0(EnHorse* this, GlobalContext* globalCtx, Path* path) { + s32 spA4; + Vec3s* spA0; + f32 phi_f12; + f32 phi_f14; + Vec3f sp8C; + Vec3f sp80; + f32 sp7C; + f32 sp78; + f32 sp74; + f32 sp70; + s32 i; + s32 sp68; + f32 sp64; + s32 sp60; + f32 temp_f0; + Vec3f sp50; + + spA4 = path->count; + spA0 = Lib_SegmentedToVirtual(path->points); + Math_Vec3s_ToVec3f(&sp8C, &spA0[this->curRaceWaypoint]); + + if (this->curRaceWaypoint == 0) { + phi_f12 = spA0[1].x - spA0[0].x; + phi_f14 = spA0[1].z - spA0[0].z; + } else if ((this->curRaceWaypoint + 1) == path->count) { + phi_f12 = spA0[path->count - 1].x - spA0[path->count - 2].x; + phi_f14 = spA0[path->count - 1].z - spA0[path->count - 2].z; + } else { + phi_f12 = spA0[this->curRaceWaypoint + 1].x - spA0[this->curRaceWaypoint - 1].x; + phi_f14 = spA0[this->curRaceWaypoint + 1].z - spA0[this->curRaceWaypoint - 1].z; + } + + func_8017B7F8(&sp8C, Math_Atan2S(phi_f12, phi_f14), &sp7C, &sp78, &sp74); + + if (((this->actor.world.pos.x * sp7C) + (sp78 * this->actor.world.pos.z) + sp74) > 0.0f) { + this->curRaceWaypoint++; + if (this->curRaceWaypoint >= spA4) { + this->curRaceWaypoint = spA4 - 1; + } + Math_Vec3s_ToVec3f(&sp8C, &spA0[this->curRaceWaypoint]); + } + + if (this->curRaceWaypoint == 0) { + Math_Vec3s_ToVec3f(&sp80, &spA0[1]); + } else { + Math_Vec3s_ToVec3f(&sp80, &spA0[this->curRaceWaypoint - 1]); + } + + func_8017D7C0(this->actor.world.pos.x, this->actor.world.pos.z, sp80.x, sp80.z, sp8C.x, sp8C.z, &sp70); + + if ((this->actor.bgCheckFlags & 8) || (this->unk_1EC & 4)) { + EnHorse_RotateToPoint(this, globalCtx, &sp8C, 0xC80); + if (this->unk_1EC & 4) { + this->unk_1EC &= ~4; + } + } else { + EnHorse_RotateToPoint(this, globalCtx, &sp8C, 0x320); + if (sp70 < SQ(100.0f)) { + if ((this->actor.xzDistToPlayer < 100.0f) || + (this->colliderJntSph.elements[0].info.ocElemFlags & OCELEM_HIT)) { + s32 pad; + + if (Math_SinS(this->actor.yawTowardsPlayer - this->actor.world.rot.y) > 0.0f) { + this->actor.world.rot.y -= 0x1E0; + } else { + this->actor.world.rot.y += 0x1E0; + } + } else if (this->actor.xzDistToPlayer < 300.0f) { + if (Math_SinS(this->actor.yawTowardsPlayer - this->actor.world.rot.y) > 0.0f) { + this->actor.world.rot.y += 0x1E0; + } else { + this->actor.world.rot.y -= 0x1E0; + } + } + this->actor.shape.rot.y = this->actor.world.rot.y; + } + } + + sp68 = this->curRaceWaypoint - 3; + if (sp68 < 0) { + sp68 = 0; + } + + sp64 = 1.0e+38; + sp60 = sp68 + 5; + if (path->count < sp60) { + sp60 = path->count; + } + + for (i = sp68; i < sp60; i++) { + Math_Vec3s_ToVec3f(&sp50, &spA0[i]); + temp_f0 = Math3D_Distance(&this->actor.world.pos, &sp50); + if (temp_f0 < sp64) { + sp64 = temp_f0; + sp68 = i; + } + } + + this->unk_398 = spA0[this->curRaceWaypoint].y * 0.01f; + if ((this->unk_1EC & 0x100) && !(this->stateFlags & ENHORSE_JUMPING) && + ((this->colliderCylinder1.base.acFlags & AC_HIT) || (this->colliderCylinder2.base.acFlags & AC_HIT) || + (this->unk_58C > 0))) { + if (this->unk_58C == 0) { + this->unk_590 = 0x1F4; + this->unk_58C = 0x2B; + } + this->unk_58C--; + if (this->actor.speedXZ > 5.0f) { + this->actor.speedXZ -= 0.5f; + } + } else if (this->unk_590 > 0) { + if (this->unk_590 == 0x1F4) { + if (this->rider != NULL) { + Actor_PlaySfxAtPos(&this->rider->actor, NA_SE_VO_IN_CRY_0); + } + } + this->unk_590--; + if (this->actor.speedXZ < this->unk_398) { + this->actor.speedXZ += 1.0f; + } else { + this->actor.speedXZ -= 0.5f; + } + } else if (this->actor.params == ENHORSE_5) { + s16 sp4A; + + if (sp68 >= this->curRaceWaypoint) { + if (this->actor.speedXZ < this->unk_398) { + this->actor.speedXZ += 0.5f; + } else { + this->actor.speedXZ -= 0.5f; + } + this->unk_394 |= 1; + return; + } + + sp4A = Actor_YawBetweenActors(&this->actor, &GET_PLAYER(globalCtx)->actor) - this->actor.world.rot.y; + + if ((fabsf(Math_SinS(sp4A)) < 0.9f) && (Math_CosS(sp4A) > 0.0f)) { + if (this->actor.speedXZ < this->unk_398) { + this->actor.speedXZ += 0.5f; + } else { + this->actor.speedXZ -= 0.25f; + } + this->unk_394 |= 1; + } else { + if (this->actor.speedXZ < 13.0f) { + this->actor.speedXZ += 0.4f; + } else { + this->actor.speedXZ -= 0.2f; + } + this->unk_394 &= ~1; + } + } else if (sp68 >= this->curRaceWaypoint) { + if (this->actor.speedXZ < this->unk_398) { + this->actor.speedXZ += 0.5f; + } else { + this->actor.speedXZ -= 0.5f; + } + this->unk_394 |= 1; + } else if ((sp68 + 1) == this->curRaceWaypoint) { + s16 sp48 = Actor_YawBetweenActors(&this->actor, &GET_PLAYER(globalCtx)->actor) - this->actor.world.rot.y; + + if ((fabsf(Math_SinS(sp48)) < 0.9f) && (Math_CosS(sp48) > 0.0f)) { + if (this->actor.speedXZ < this->unk_398) { + this->actor.speedXZ += 0.5f; + } else { + this->actor.speedXZ -= 0.25f; + } + this->unk_394 |= 1; + } else { + if (this->actor.speedXZ < 12.0f) { + this->actor.speedXZ += 0.4f; + } else { + this->actor.speedXZ -= 0.2f; + } + this->unk_394 &= ~1; + } + } else { + if (this->actor.speedXZ < 13.0f) { + this->actor.speedXZ += 0.4f; + } else { + this->actor.speedXZ -= 0.2f; + } + this->unk_394 &= ~1; + } +} + +void EnHorse_PlayWalkingSound(EnHorse* this) { + if (sAnimSoundFrames[this->soundTimer] < this->curFrame) { + if ((this->soundTimer == 0) && (sAnimSoundFrames[1] < this->curFrame)) { + return; + } + + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_WALK); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_WALK); + } + + this->soundTimer++; + if (this->soundTimer > 1) { + this->soundTimer = 0; + } + } +} + +void func_8087C178(EnHorse* this) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_RUN); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_RUN); + } +} + +void func_8087C1C0(EnHorse* this) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_RUN); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_RUN); + } +} + +f32 EnHorse_SlopeSpeedMultiplier(EnHorse* this, GlobalContext* globalCtx) { + f32 multiplier = 1.0f; + + if ((Math_CosS(this->actor.shape.rot.x) < 0.939262f) && (Math_SinS(this->actor.shape.rot.x) < 0.0f)) { + multiplier = 0.7f; + } + return multiplier; +} + +void func_8087C288(GlobalContext* globalCtx, Vec3f* arg1, Vec3f* arg2, f32* arg3) { + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, arg1, arg2, arg3); +} + +s32 func_8087C2B8(GlobalContext* globalCtx, EnHorse* this, Vec3f* arg2, f32 arg3) { + f32 phi_f14; + + if ((arg2->z > 0.0f) && (arg2->z < (this->actor.uncullZoneForward + this->actor.uncullZoneScale))) { + if (arg3 < 1.0f) { + phi_f14 = 1.0f; + } else { + phi_f14 = 1.0f / arg3; + } + + if (((fabsf(arg2->x) * phi_f14) < 1.0f) && (((arg2->y + this->actor.uncullZoneDownward) * phi_f14) > -1.0f) && + (((arg2->y - this->actor.uncullZoneScale) * phi_f14) < 1.0f)) { + return true; + } + } + return false; +} + +s32 func_8087C38C(GlobalContext* globalCtx, EnHorse* this, Vec3f* arg2) { + Vec3f sp24; + f32 sp20; + f32 eyeDist; + + func_8087C288(globalCtx, arg2, &sp24, &sp20); + + if (fabsf(sp20) < 0.008f) { + return false; + } + + eyeDist = Math3D_Distance(arg2, &globalCtx->view.eye); + + return func_8087C2B8(globalCtx, this, &sp24, sp20) || (eyeDist < 100.0f); +} + +void EnHorse_IdleAnimSounds(EnHorse* this, GlobalContext* globalCtx) { + if ((this->animationIdx == ENHORSE_ANIM_IDLE) && + (((this->curFrame > 35.0f) && (this->type == HORSE_EPONA)) || + ((this->curFrame > 28.0f) && (this->type == HORSE_HNI)) || + ((this->curFrame > 25.0f) && (this->type == HORSE_2))) && + !(this->stateFlags & ENHORSE_SANDDUST_SOUND)) { + this->stateFlags |= ENHORSE_SANDDUST_SOUND; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_SANDDUST); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_SANDDUST); + } + } else if ((this->animationIdx == 3) && (this->curFrame > 25.0f) && !(this->stateFlags & ENHORSE_LAND2_SOUND)) { + this->stateFlags |= ENHORSE_LAND2_SOUND; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_LAND2); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_LAND2); + } + } +} + +s32 EnHorse_Spawn(EnHorse* this, GlobalContext* globalCtx) { + s32 i; + f32 dist; + Path* path; + s32 spawn = false; + f32 minDist = 1.0e+38; + Player* player = GET_PLAYER(globalCtx); + Vec3f spawnPos; + s32 pathIdx = func_800F3940(globalCtx); + s32 pathCount; + Vec3s* pathPoints; + + if (pathIdx == -1) { + return false; + } + + path = &globalCtx->setupPathList[pathIdx]; + pathCount = path->count; + pathPoints = Lib_SegmentedToVirtual(path->points); + + for (i = 0; i < pathCount; i++) { + spawnPos.x = pathPoints[i].x; + spawnPos.y = pathPoints[i].y; + spawnPos.z = pathPoints[i].z; + dist = Math3D_Distance(&player->actor.world.pos, &spawnPos); + + if ((minDist < dist) || func_8087C38C(globalCtx, this, &spawnPos)) { + continue; + } + + minDist = dist; + this->actor.world.pos.x = spawnPos.x; + this->actor.world.pos.y = spawnPos.y; + this->actor.world.pos.z = spawnPos.z; + this->actor.prevPos = this->actor.world.pos; + this->actor.world.rot.y = 0; + this->actor.shape.rot.y = Actor_YawBetweenActors(&this->actor, &GET_PLAYER(globalCtx)->actor); + spawn = true; + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &this->actor.world.pos, &this->actor.projectedPos, + &this->actor.projectedW); + } + + if (spawn == true) { + return true; + } + + for (i = 0; i < pathCount; i++) { + spawnPos.x = pathPoints[i].x; + spawnPos.y = pathPoints[i].y; + spawnPos.z = pathPoints[i].z; + dist = Math3D_Distance(&player->actor.world.pos, &spawnPos); + + if (minDist < dist) { + continue; + } + + minDist = dist; + this->actor.world.pos.x = spawnPos.x; + this->actor.world.pos.y = spawnPos.y; + this->actor.world.pos.z = spawnPos.z; + this->actor.prevPos = this->actor.world.pos; + this->actor.world.rot.y = 0; + this->actor.shape.rot.y = Actor_YawBetweenActors(&this->actor, &GET_PLAYER(globalCtx)->actor); + spawn = true; + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &this->actor.world.pos, &this->actor.projectedPos, + &this->actor.projectedW); + } + + return spawn; +} + +void EnHorse_ResetCutscene(EnHorse* this, GlobalContext* globalCtx) { + this->cutsceneAction = -1; + this->cutsceneFlags = 0; +} + +void EnHorse_ResetRace(EnHorse* this, GlobalContext* globalCtx) { + this->inRace = false; +} + +s32 EnHorse_PlayerCanMove(EnHorse* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if ((player->stateFlags1 & 1) || (func_800B7128(GET_PLAYER(globalCtx)) == true) || + (player->stateFlags1 & 0x100000) || + (((this->stateFlags & ENHORSE_FLAG_19) || (this->stateFlags & ENHORSE_FLAG_29)) && !this->inRace) || + (this->action == 19) || (player->actor.flags & ACTOR_FLAG_100) || (globalCtx->csCtx.state != 0) || + (ActorCutscene_GetCurrentIndex() != -1) || (player->stateFlags1 & 0x20) || (player->csMode != 0)) { + return false; + } + return true; +} + +void EnHorse_ResetHorsebackArchery(EnHorse* this, GlobalContext* globalCtx) { + this->unk_39C = 0; + this->hbaStarted = 0; + this->hbaFlags = 0; +} + +void EnHorse_ClearDustFlags(u16* dustFlags) { + *dustFlags = 0; +} + +void func_8087C9F8(EnHorse* this) { +} + +void func_8087CA04(EnHorse* this, GlobalContext* globalCtx) { +} + +#ifdef NON_MATCHING +void EnHorse_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnHorse* this = THIS; + + Actor_ProcessInitChain(&this->actor, sInitChain); + EnHorse_ClearDustFlags(&this->dustFlags); + D_801BDAA4 = 0; + Skin_Setup(&this->skin); + this->riderPos = this->actor.world.pos; + this->unk_52C = 0; + this->noInputTimer = 0; + this->riderPos.y += 70.0f; + this->noInputTimerMax = 0; + this->unk_1EC = 0; + this->unk_58C = 0; + this->unk_590 = 0; + this->unk_3E8 = 0.0f; + this->unk_528 = 100.0f; + + if (ENHORSE_GET_8000(&this->actor)) { + this->type = HORSE_4; + this->unk_528 = 80.0f; + this->boostSpeed = 12; + if ((this->bankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_HA)) < 0) { + Actor_MarkForDeath(&this->actor); + return; + } + this->unk_1EC |= 1; + this->actor.update = func_8087D540; + } else if (ENHORSE_GET_4000(&this->actor)) { + this->type = HORSE_2; + this->unk_528 = 64.8f; + this->boostSpeed = 15; + if ((this->bankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_HORSE_LINK_CHILD)) < 0) { + this->actor.objBankIndex = Object_Spawn(&globalCtx->objectCtx, OBJECT_HORSE_LINK_CHILD); + Actor_SetObjectDependency(globalCtx, &this->actor); + Skin_Init(&globalCtx->state, &this->skin, sSkeletonHeaders[this->type], sAnimationHeaders[this->type][0]); + Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx]); + this->unk_1EC |= 0x200; + } else { + this->actor.update = func_8087D540; + } + } else if (ENHORSE_GET_2000(&this->actor)) { + this->type = HORSE_3; + this->boostSpeed = 12; + if ((this->bankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_HA)) < 0) { + Actor_MarkForDeath(&this->actor); + return; + } + this->unk_1EC |= 1; + this->actor.update = func_8087D540; + } else { + this->type = HORSE_EPONA; + this->boostSpeed = 15; + Actor_MarkForDeath(&this->actor); + } + + this->actor.params &= ~0xE000; + if (this->actor.params == 0x1FFF) { + this->actor.params = ENHORSE_1; + } + + if (this->actor.params == ENHORSE_3) { + this->stateFlags = ENHORSE_FLAG_19 | ENHORSE_CANT_JUMP | ENHORSE_UNRIDEABLE; + } else if (this->actor.params == ENHORSE_8) { + this->stateFlags = ENHORSE_FLAG_19 | ENHORSE_CANT_JUMP; + if (CHECK_QUEST_ITEM(14)) { + this->stateFlags &= ~ENHORSE_CANT_JUMP; + this->stateFlags |= ENHORSE_FLAG_26; + } + } else if (this->actor.params == ENHORSE_13) { + this->stateFlags = ENHORSE_FLAG_29; + this->unk_1EC |= 0x10; + } else if (this->actor.params == ENHORSE_4) { + this->stateFlags = ENHORSE_FLAG_29 | ENHORSE_CANT_JUMP; + this->actor.flags |= ACTOR_FLAG_80000000; + } else if (this->actor.params == ENHORSE_5) { + this->stateFlags = ENHORSE_FLAG_29 | ENHORSE_CANT_JUMP; + this->actor.flags |= ACTOR_FLAG_80000000; + } else if (this->actor.params == ENHORSE_15) { + this->stateFlags = ENHORSE_UNRIDEABLE | ENHORSE_FLAG_7; + } else if (this->actor.params == ENHORSE_17) { + this->stateFlags = 0; + this->unk_1EC |= 8; + } else if (this->actor.params == ENHORSE_18) { + this->stateFlags = ENHORSE_FLAG_29 | ENHORSE_CANT_JUMP; + this->actor.flags |= ACTOR_FLAG_80000000; + } else if (this->actor.params == ENHORSE_1) { + this->stateFlags = ENHORSE_FLAG_7; + } else if ((this->actor.params == ENHORSE_19) || (this->actor.params == ENHORSE_20)) { + this->stateFlags = ENHORSE_CANT_JUMP | ENHORSE_UNRIDEABLE; + } else { + this->stateFlags = 0; + } + + if (((globalCtx->sceneNum == SCENE_KOEPONARACE) && ((gSaveContext.save.weekEventReg[92] & (1 | 2 | 4)) == 1)) || + ((gSaveContext.save.entranceIndex == 0x6400) && Cutscene_GetSceneSetupIndex(globalCtx))) { + this->stateFlags |= ENHORSE_FLAG_25; + } + + this->actor.gravity = -3.5f; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawHorse, 20.0f); + this->action = ENHORSE_ACT_IDLE; + this->actor.speedXZ = 0.0f; + + if (this->type == HORSE_2) { + sJntSphInit.elements[0].dim.limb = 13; + } else if ((this->type == HORSE_3) || (this->type == HORSE_4)) { + sJntSphInit.elements[0].dim.limb = 10; + } + + Collider_InitCylinder(globalCtx, &this->colliderCylinder1); + Collider_SetCylinder(globalCtx, &this->colliderCylinder1, &this->actor, &sCylinderInit1); + Collider_InitCylinder(globalCtx, &this->colliderCylinder2); + Collider_SetCylinder(globalCtx, &this->colliderCylinder2, &this->actor, &sCylinderInit2); + Collider_InitJntSph(globalCtx, &this->colliderJntSph); + Collider_SetJntSph(globalCtx, &this->colliderJntSph, &this->actor, &sJntSphInit, this->colliderJntSphElements); + + if (this->type == HORSE_2) { + this->colliderCylinder1.dim.radius = this->colliderCylinder1.dim.radius * 0.8f; + this->colliderCylinder2.dim.radius = this->colliderCylinder2.dim.radius * 0.8f; + this->colliderJntSph.elements[0].dim.modelSphere.radius *= 0.6f; + } else if (this->type == HORSE_4) { + this->colliderCylinder1.dim.radius = 50; + } + + CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); + + if (this->type == HORSE_2) { + Actor_SetScale(&this->actor, 0.00648f); + } else if (this->type == HORSE_4) { + Actor_SetScale(&this->actor, 0.008f); + } else { + Actor_SetScale(&this->actor, 0.01f); + } + + this->actor.focus.pos = this->actor.world.pos; + this->playerControlled = false; + this->actor.focus.pos.y += 70.0f; + + if (!(this->unk_1EC & 1) && !(this->unk_1EC & 0x200) && (this->actor.update == EnHorse_Update)) { + Skin_Init(&globalCtx->state, &this->skin, sSkeletonHeaders[this->type], sAnimationHeaders[this->type][0]); + } + + this->animationIdx = 0; + this->numBoosts = 6; + this->boostRegenTime = 0; + this->postDrawFunc = NULL; + this->blinkTimer = 0; + + EnHorse_ResetCutscene(this, globalCtx); + EnHorse_ResetRace(this, globalCtx); + EnHorse_ResetHorsebackArchery(this, globalCtx); + + if (this->actor.params == ENHORSE_2) { + this->unk_53C = 0; + EnHorse_InitInactive(this); + } else if (this->actor.params == ENHORSE_3) { + EnHorse_InitIngoHorse(this); + this->rider = (EnIn*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_IN, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, this->actor.shape.rot.x, + this->actor.shape.rot.y, 1, 1); + this->unk_398 = 14.34f; + } else if (this->actor.params == ENHORSE_4) { + func_80881634(this); + this->unk_398 = 14.34f; + this->rider = (EnIn*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_IN, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, this->actor.shape.rot.x, + this->actor.shape.rot.y, 1, 1); + this->unk_1EC |= 0x100; + } else if (this->actor.params == ENHORSE_5) { + func_80881634(this); + this->unk_398 = 14.525f; + this->rider = (EnIn*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_IN, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, this->actor.shape.rot.x, + this->actor.shape.rot.y, 1, 2); + this->unk_1EC |= 0x100; + } else if (this->actor.params == ENHORSE_9) { + EnHorse_InitCutscene(this, globalCtx); + } else if (this->actor.params == ENHORSE_10) { + EnHorse_InitHorsebackArchery(this); + func_80112AFC(globalCtx); + } else if (this->actor.params == ENHORSE_14) { + func_808846F0(this, globalCtx); + if ((globalCtx->sceneNum == SCENE_LOST_WOODS) && !Cutscene_IsPlaying(globalCtx)) { + Actor_MarkForDeath(&this->actor); + } + } else if (this->actor.params == ENHORSE_16) { + func_8087C9F8(this); + } else if (this->actor.params == ENHORSE_15) { + EnHorse_ResetIdleAnimation(this); + } else if (this->actor.params == ENHORSE_18) { + func_80884994(this); + } else if (this->actor.params == ENHORSE_19) { + EnIn* in; + + func_80884D04(this, globalCtx); + in = (EnIn*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_IN, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, this->actor.shape.rot.x, + this->actor.shape.rot.y, 1, 1); + this->rider = in; + in->unk4AC |= (0x20 | 0x4); + } else if (this->actor.params == ENHORSE_20) { + EnIn* in; + + func_80884D04(this, globalCtx); + in = (EnIn*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_IN, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, this->actor.shape.rot.x, + this->actor.shape.rot.y, 1, 1); + this->rider = in; + in->unk4AC |= (0x20 | 0x8 | 0x4); + } else { + EnHorse_StartIdleRidable(this); + } + + this->actor.shape.rot.z = 0; + this->actor.world.rot.z = this->actor.shape.rot.z; + this->actor.home.rot.z = this->actor.shape.rot.z; + this->unk_3EC = this->actor.world.rot.y; + this->unk_538 = 0; + + if (this->unk_1EC & 0x100) { + this->colliderCylinder1.base.colType = COLTYPE_HIT3; + this->colliderCylinder1.base.acFlags |= (AC_TYPE_PLAYER | AC_ON); + this->colliderCylinder1.info.bumperFlags |= BUMP_ON; + this->colliderCylinder1.info.bumper.dmgFlags = 0x10000 | 0x2000 | 0x1000 | 0x800 | 0x20; + this->colliderCylinder2.base.colType = COLTYPE_HIT3; + this->colliderCylinder2.base.acFlags |= (AC_TYPE_PLAYER | AC_ON); + this->colliderCylinder2.info.bumperFlags |= BUMP_ON; + this->colliderCylinder2.info.bumper.dmgFlags = 0x10000 | 0x2000 | 0x1000 | 0x800 | 0x20; + } +} +#else +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/EnHorse_Init.s") #endif -extern ColliderCylinderInit D_80888F74; -extern ColliderCylinderInit D_80888FA0; -extern ColliderJntSphElementInit D_80888FCC[1]; -extern ColliderJntSphInit D_80888FF0; -extern CollisionCheckInfoInit D_80889000; -extern InitChainEntry D_80889010[]; - -extern UNK_TYPE D_06008C68; -extern UNK_TYPE D_0600A8DC; -extern UNK_TYPE D_0600AD08; -extern UNK_TYPE D_0600B3E0; -extern UNK_TYPE D_0600BDE0; -extern UNK_TYPE D_0600D178; -extern UNK_TYPE D_0600D4E8; - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087B730.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087B784.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087B7C0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087C0AC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087C178.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087C1C0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087C208.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087C288.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087C2B8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087C38C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087C43C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087C590.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087C8B8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087C8D0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087C8E0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087C9D4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087C9EC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087C9F8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087CA04.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/EnHorse_Init.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087D540.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/EnHorse_Destroy.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087D70C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087D75C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087D814.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087D988.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087DDEC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087DE28.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087DF64.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087E080.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087E0A4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087E18C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087E2A8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087E350.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087E564.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087E5B4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087E5D8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087E684.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087E6D8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087E92C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087E9D0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087EA1C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087EB54.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087EB78.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087EC20.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087EC78.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087ED10.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087EEC4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087F078.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087F1FC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087F39C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087F590.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087F5B4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087F658.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087F9A0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087F9C4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087FB08.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087FB14.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087FD94.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087FDB8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087FF08.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087FF14.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808801A8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808801F8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808802D0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808804A4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808804CC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80880500.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80880534.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808806DC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80880844.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80880978.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80880D50.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80880DA8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80880E00.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80881128.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8088126C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80881290.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80881398.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8088159C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80881634.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8088168C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808819D8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80881BDC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80881C54.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80881DA4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80881DC8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80881F10.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80881F48.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808821C8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808822CC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8088247C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80882564.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808826B4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80882820.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808829D0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808829F4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80882A44.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80882B9C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80882D8C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80882DC0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80883104.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80883308.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80883B70.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80883BEC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80883CB0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80883D64.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80883DE0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80883E10.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80883EA0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80883F18.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80883F98.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80884010.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808840C4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80884194.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8088424C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80884314.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808843B4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80884444.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808844E0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80884564.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80884604.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808846B4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808846DC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808846F0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80884718.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80884868.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808848C8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80884994.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80884A40.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80884D04.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80884E0C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80885060.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808850DC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80885220.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808853E0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8088598C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80885A80.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80885AF4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80885B4C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80885C90.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80885DA4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80886C00.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80886DC4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80886FA8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808870A4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808871A0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80887270.s") - +void func_8087D540(Actor* thisx, GlobalContext* globalCtx) { + EnHorse* this = THIS; + + if (Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)) { + this->actor.objBankIndex = this->bankIndex; + Actor_SetObjectDependency(globalCtx, &this->actor); + this->actor.update = EnHorse_Update; + if (this->unk_1EC & 1) { + if (this->type == HORSE_3) { + SkelAnime_InitFlex(globalCtx, &this->skin.skelAnime, &object_ha_Skel_008C68, NULL, this->jointTable, + this->morphTable, OBJECT_HA_1_LIMB_MAX); + } else { + SkelAnime_InitFlex(globalCtx, &this->skin.skelAnime, &object_ha_Skel_0150D8, NULL, this->jointTable, + this->morphTable, OBJECT_HA_2_LIMB_MAX); + } + } else { + Skin_Init(&globalCtx->state, &this->skin, sSkeletonHeaders[this->type], sAnimationHeaders[this->type][0]); + } + Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx]); + } +} + +void EnHorse_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnHorse* this = THIS; + + if (this->stateFlags & ENHORSE_DRAW) { + Audio_StopSfxByPos(&this->unk_218); + } + Skin_Free(&globalCtx->state, &this->skin); + Collider_DestroyCylinder(globalCtx, &this->colliderCylinder1); + Collider_DestroyCylinder(globalCtx, &this->colliderCylinder2); + Collider_DestroyJntSph(globalCtx, &this->colliderJntSph); +} + +void EnHorse_RotateToPlayer(EnHorse* this, GlobalContext* globalCtx) { + EnHorse_RotateToPoint(this, globalCtx, &GET_PLAYER(globalCtx)->actor.world.pos, 0x320); + if (this->stateFlags & ENHORSE_OBSTACLE) { + this->actor.world.rot.y += 1600; + } + this->actor.shape.rot.y = this->actor.world.rot.y; +} + +void EnHorse_Freeze(EnHorse* this, GlobalContext* globalCtx) { + if ((this->action != ENHORSE_ACT_HBA) && (this->action != ENHORSE_ACT_21) && + (this->action != ENHORSE_ACT_FLEE_PLAYER)) { + if (sResetNoInput[this->actor.params] && (this->actor.params != ENHORSE_6)) { + Player* player = GET_PLAYER(globalCtx); + + this->noInputTimerMax = 0; + this->noInputTimer = 0; + player->actor.world.pos = this->actor.world.pos; + player->actor.world.pos.y += 70.0f; + } + this->prevAction = this->action; + this->action = ENHORSE_ACT_FROZEN; + this->colliderCylinder1.base.ocFlags1 &= ~OC1_ON; + this->colliderCylinder2.base.ocFlags1 &= ~OC1_ON; + this->colliderJntSph.base.ocFlags1 &= ~OC1_ON; + this->animationIdx = ENHORSE_ANIM_IDLE; + } +} + +void EnHorse_Frozen(EnHorse* this, GlobalContext* globalCtx) { + this->actor.speedXZ = 0.0f; + this->noInputTimer--; + if (this->noInputTimer < 0) { + this->colliderCylinder1.base.ocFlags1 |= OC1_ON; + this->colliderCylinder2.base.ocFlags1 |= OC1_ON; + this->colliderJntSph.base.ocFlags1 |= OC1_ON; + if (this->playerControlled == true) { + this->stateFlags &= ~ENHORSE_FLAG_7; + if (this->actor.params == ENHORSE_6) { + EnHorse_StartMountedIdleResetAnim(this); + } else if (this->actor.params == ENHORSE_11) { + this->actor.params = ENHORSE_7; + if (globalCtx->csCtx.state != 0) { + EnHorse_StartMountedIdle(this); + } else { + this->actor.speedXZ = 8.0f; + EnHorse_StartGalloping(this); + } + } else if (this->prevAction == ENHORSE_ACT_IDLE) { + EnHorse_StartMountedIdle(this); + } else { + EnHorse_StartMountedIdleResetAnim(this); + } + + if (this->actor.params != ENHORSE_0) { + this->actor.params = ENHORSE_0; + } + } else if (this->prevAction == ENHORSE_ACT_MOUNTED_TURN) { + EnHorse_ChangeIdleAnimation(this, 0, 0.0f); + } else if (this->prevAction == ENHORSE_ACT_MOUNTED_WALK) { + EnHorse_ChangeIdleAnimation(this, 0, 0.0f); + } else { + EnHorse_ChangeIdleAnimation(this, 0, 0.0f); + } + } +} + +void EnHorse_UpdateSpeed(EnHorse* this, GlobalContext* globalCtx, f32 brakeDecel, f32 brakeAngle, f32 minStickMag, + f32 decel, f32 baseSpeed, s16 turnSpeed) { + f32 phi_f0; + f32 stickMag; + s16 stickAngle; + s16 turn; + f32 temp_f12; + + if (!EnHorse_PlayerCanMove(this, globalCtx)) { + if (this->actor.speedXZ > 8.0f) { + this->actor.speedXZ -= decel; + } else if (this->actor.speedXZ < 0.0f) { + this->actor.speedXZ = 0.0f; + } + return; + } + + baseSpeed *= EnHorse_SlopeSpeedMultiplier(this, globalCtx); + EnHorse_StickDirection(&this->curStick, &stickMag, &stickAngle); + + if (Math_CosS(stickAngle) <= brakeAngle) { + this->actor.speedXZ -= brakeDecel; + this->actor.speedXZ = CLAMP_MIN(this->actor.speedXZ, 0.0f); + return; + } + + if (stickMag < minStickMag) { + this->stateFlags &= ~ENHORSE_BOOST; + this->stateFlags &= ~ENHORSE_BOOST_DECEL; + this->actor.speedXZ -= decel; + if (this->actor.speedXZ < 0.0f) { + this->actor.speedXZ = 0.0f; + } + return; + } + + if (this->stateFlags & ENHORSE_BOOST) { + if ((16 - this->boostTimer) > 0) { + this->actor.speedXZ = + (((EnHorse_SlopeSpeedMultiplier(this, globalCtx) * this->boostSpeed) - this->actor.speedXZ) / + (16.0f - this->boostTimer)) + + this->actor.speedXZ; + } else { + this->actor.speedXZ = EnHorse_SlopeSpeedMultiplier(this, globalCtx) * this->boostSpeed; + } + + if ((EnHorse_SlopeSpeedMultiplier(this, globalCtx) * this->boostSpeed) <= this->actor.speedXZ) { + this->stateFlags &= ~ENHORSE_BOOST; + this->stateFlags |= ENHORSE_BOOST_DECEL; + } + } else if (this->stateFlags & ENHORSE_BOOST_DECEL) { + if (this->actor.speedXZ > baseSpeed) { + this->actor.speedXZ -= 0.06f; + } else if (this->actor.speedXZ < baseSpeed) { + this->actor.speedXZ = baseSpeed; + this->stateFlags &= ~ENHORSE_BOOST_DECEL; + } + } else { + if (this->actor.speedXZ <= (baseSpeed * (1.0f / 54.0f) * stickMag)) { + phi_f0 = 1.0f; + } else { + phi_f0 = -1.0f; + } + + this->actor.speedXZ += phi_f0 * 50.0f * 0.01f; + + if (this->actor.speedXZ > baseSpeed) { + this->actor.speedXZ -= decel; + if (this->actor.speedXZ < baseSpeed) { + this->actor.speedXZ = baseSpeed; + } + } + } + + temp_f12 = stickAngle * (1 / 32236.f); + turn = stickAngle * temp_f12 * temp_f12 * (2.2f - (this->actor.speedXZ * (1.0f / this->boostSpeed))); + turn = CLAMP(turn, -turnSpeed * (2.2f - (1.7f * this->actor.speedXZ * (1.0f / this->boostSpeed))), + turnSpeed * (2.2f - (1.7f * this->actor.speedXZ * (1.0f / this->boostSpeed)))); + this->actor.world.rot.y += turn; + this->actor.shape.rot.y = this->actor.world.rot.y; +} + +void EnHorse_StartMountedIdleResetAnim(EnHorse* this) { + this->skin.skelAnime.curFrame = 0.0f; + EnHorse_StartMountedIdle(this); + this->stateFlags &= ~ENHORSE_SANDDUST_SOUND; +} + +void EnHorse_StartMountedIdle(EnHorse* this) { + f32 curFrame; + + this->action = ENHORSE_ACT_MOUNTED_TURN; + this->animationIdx = ENHORSE_ANIM_IDLE; + + if (((this->curFrame > 35.0f) && (this->type == HORSE_EPONA)) || + ((this->curFrame > 28.0f) && (this->type == HORSE_HNI))) { + if (!(this->stateFlags & ENHORSE_SANDDUST_SOUND)) { + this->stateFlags |= ENHORSE_SANDDUST_SOUND; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_SANDDUST); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_SANDDUST); + } + } + } + curFrame = this->skin.skelAnime.curFrame; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, curFrame, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); +} + +void EnHorse_MountedIdle(EnHorse* this, GlobalContext* globalCtx) { + f32 mag; + s16 angle = 0; + + this->actor.speedXZ = 0.0f; + EnHorse_StickDirection(&this->curStick, &mag, &angle); + if (mag > 10.0f) { + if (EnHorse_PlayerCanMove(this, globalCtx) == true) { + if (Math_CosS(angle) <= -0.5f) { + EnHorse_StartReversingInterruptable(this); + } else if (Math_CosS(angle) <= 0.7071f) { + EnHorse_StartTurning(this); + } else { + EnHorse_StartWalkingFromIdle(this); + } + } else if (this->unk_3EC != this->actor.world.rot.y) { + EnHorse_StartTurning(this); + } + } + + if (SkelAnime_Update(&this->skin.skelAnime)) { + EnHorse_MountedIdleAnim(this); + } +} + +void EnHorse_MountedIdleAnim(EnHorse* this) { + this->skin.skelAnime.curFrame = 0.0f; + EnHorse_MountedIdleWhinney(this); +} + +void EnHorse_MountedIdleWhinney(EnHorse* this) { + f32 curFrame; + + this->action = ENHORSE_ACT_MOUNTED_WALK; + this->animationIdx = ENHORSE_ANIM_WHINNEY; + curFrame = this->skin.skelAnime.curFrame; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, curFrame, + Animation_GetLastFrame(sAnimationHeaders[this->type][1]), ANIMMODE_ONCE, -3.0f); + if (this->stateFlags & ENHORSE_DRAW) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_GROAN); + } else { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_GROAN); + } + } +} + +void EnHorse_MountedIdleWhinneying(EnHorse* this, GlobalContext* globalCtx) { + f32 stickMag; + s16 stickAngle = 0; + + this->actor.speedXZ = 0.0f; + EnHorse_StickDirection(&this->curStick, &stickMag, &stickAngle); + if (stickMag > 10.0f) { + if (EnHorse_PlayerCanMove(this, globalCtx) == true) { + if (Math_CosS(stickAngle) <= -0.5f) { + EnHorse_StartReversingInterruptable(this); + } else if (Math_CosS(stickAngle) <= 0.7071f) { + EnHorse_StartTurning(this); + } else { + EnHorse_StartWalkingFromIdle(this); + } + } else if (this->unk_3EC != this->actor.world.rot.y) { + EnHorse_StartTurning(this); + } + } + + if (SkelAnime_Update(&this->skin.skelAnime)) { + EnHorse_StartMountedIdleResetAnim(this); + } +} + +void EnHorse_StartTurning(EnHorse* this) { + this->action = ENHORSE_ACT_MOUNTED_TROT; + this->soundTimer = 0; + this->animationIdx = ENHORSE_ANIM_WALK; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][4]), ANIMMODE_ONCE, -3.0f); +} + +void EnHorse_MountedTurn(EnHorse* this, GlobalContext* globalCtx) { + f32 stickMag; + s16 clampedYaw; + s16 stickAngle; + + this->actor.speedXZ = 0.0f; + EnHorse_PlayWalkingSound(this); + if (EnHorse_PlayerCanMove(this, globalCtx) == true) { + EnHorse_StickDirection(&this->curStick, &stickMag, &stickAngle); + if (stickMag > 10.0f) { + if (!EnHorse_PlayerCanMove(this, globalCtx)) { + EnHorse_StartMountedIdleResetAnim(this); + } else if (Math_CosS(stickAngle) <= -0.5f) { + EnHorse_StartReversingInterruptable(this); + } else if (Math_CosS(stickAngle) <= 0.7071f) { + clampedYaw = CLAMP(stickAngle, -1600.0f, 1600.0f); + this->actor.world.rot.y += clampedYaw; + this->actor.shape.rot.y = this->actor.world.rot.y; + } else { + EnHorse_StartWalkingInterruptable(this); + } + } + } + + if (SkelAnime_Update(&this->skin.skelAnime)) { + if (EnHorse_PlayerCanMove(this, globalCtx) == true) { + if (Math_CosS(stickAngle) <= 0.7071f) { + EnHorse_StartTurning(this); + } else { + EnHorse_StartMountedIdleResetAnim(this); + } + } else if (this->unk_3EC != this->actor.world.rot.y) { + EnHorse_StartTurning(this); + } else { + EnHorse_StartMountedIdleResetAnim(this); + } + } +} + +void EnHorse_StartWalkingFromIdle(EnHorse* this) { + EnHorse_StartWalkingInterruptable(this); + if (!(this->stateFlags & ENHORSE_FLAG_8) && !(this->stateFlags & ENHORSE_FLAG_9)) { + this->stateFlags |= ENHORSE_FLAG_9; + this->waitTimer = 8; + } else { + this->waitTimer = 0; + } +} + +void EnHorse_StartWalkingInterruptable(EnHorse* this) { + this->noInputTimer = 0; + this->noInputTimerMax = 0; + EnHorse_StartWalking(this); +} + +void EnHorse_StartWalking(EnHorse* this) { + this->action = ENHORSE_ACT_MOUNTED_GALLOP; + this->soundTimer = 0; + this->animationIdx = ENHORSE_ANIM_WALK; + this->waitTimer = 0; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][4]), ANIMMODE_ONCE, -3.0f); +} + +void EnHorse_MountedWalkingReset(EnHorse* this) { + this->action = ENHORSE_ACT_MOUNTED_GALLOP; + this->soundTimer = 0; + this->animationIdx = ENHORSE_ANIM_WALK; + this->waitTimer = 0; + Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx]); +} + +void EnHorse_MountedWalk(EnHorse* this, GlobalContext* globalCtx) { + f32 stickMag; + s16 stickAngle; + + EnHorse_PlayWalkingSound(this); + EnHorse_StickDirection(&this->curStick, &stickMag, &stickAngle); + + if ((this->noInputTimerMax == 0) || + ((this->noInputTimer > 0) && (this->noInputTimer < (this->noInputTimerMax - 20)))) { + EnHorse_UpdateSpeed(this, globalCtx, 0.3f, -0.5f, 10.0f, 0.06f, 3.0f, 0x320); + } else { + this->actor.speedXZ = 3.0f; + } + + if (this->actor.speedXZ == 0.0f) { + this->stateFlags &= ~ENHORSE_FLAG_9; + EnHorse_StartMountedIdleResetAnim(this); + this->noInputTimer = 0; + this->noInputTimerMax = 0; + } else if (this->actor.speedXZ > 3.0f) { + this->stateFlags &= ~ENHORSE_FLAG_9; + EnHorse_StartTrotting(this); + this->noInputTimer = 0; + this->noInputTimerMax = 0; + } + + if (this->noInputTimer > 0) { + this->noInputTimer--; + if (this->noInputTimer <= 0) { + this->noInputTimerMax = 0; + } + } + + if (this->waitTimer <= 0) { + this->stateFlags &= ~ENHORSE_FLAG_9; + this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.75f; + if ((SkelAnime_Update(&this->skin.skelAnime) || (this->actor.speedXZ == 0.0f)) && (this->noInputTimer <= 0)) { + if (this->actor.speedXZ > 3.0f) { + EnHorse_StartTrotting(this); + this->noInputTimer = 0; + this->noInputTimerMax = 0; + } else if ((stickMag < 10.0f) || (Math_CosS(stickAngle) <= -0.5f)) { + EnHorse_StartMountedIdleResetAnim(this); + this->noInputTimer = 0; + this->noInputTimerMax = 0; + } else { + EnHorse_MountedWalkingReset(this); + } + } + } else { + this->waitTimer--; + this->actor.speedXZ = 0.0f; + } +} + +void EnHorse_StartTrotting(EnHorse* this) { + this->action = ENHORSE_ACT_MOUNTED_REARING; + this->animationIdx = ENHORSE_ANIM_TROT; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); +} + +void EnHorse_MountedTrotReset(EnHorse* this) { + this->action = ENHORSE_ACT_MOUNTED_REARING; + this->animationIdx = ENHORSE_ANIM_TROT; + Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx]); +} + +void EnHorse_MountedTrot(EnHorse* this, GlobalContext* globalCtx) { + f32 stickMag; + s16 stickAngle; + + EnHorse_UpdateSpeed(this, globalCtx, 0.3f, -0.5f, 10.0f, 0.06f, 6.0f, 800); + EnHorse_StickDirection(&this->curStick, &stickMag, &stickAngle); + if (this->actor.speedXZ < 3.0f) { + EnHorse_StartWalkingInterruptable(this); + } + + this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.375f; + + if (SkelAnime_Update(&this->skin.skelAnime)) { + func_8087C178(this); + func_8013ECE0(0.0f, 60, 8, 255); + if (this->actor.speedXZ >= 6.0f) { + EnHorse_StartGallopingInterruptable(this); + } else if (this->actor.speedXZ < 3.0f) { + EnHorse_StartWalkingInterruptable(this); + } else { + EnHorse_MountedTrotReset(this); + } + } +} + +void EnHorse_StartGallopingInterruptable(EnHorse* this) { + this->noInputTimer = 0; + this->noInputTimerMax = 0; + EnHorse_StartGalloping(this); +} + +void EnHorse_StartGalloping(EnHorse* this) { + this->action = ENHORSE_ACT_STOPPING; + this->animationIdx = ENHORSE_ANIM_GALLOP; + this->unk_230 = 0; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); +} + +void EnHorse_MountedGallopReset(EnHorse* this) { + this->noInputTimer = 0; + this->noInputTimerMax = 0; + this->action = ENHORSE_ACT_STOPPING; + this->animationIdx = ENHORSE_ANIM_GALLOP; + this->unk_230 = 0; + Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx]); +} + +void EnHorse_JumpLanding(EnHorse* this, GlobalContext* globalCtx) { + Vec3s* jointTable; + f32 y; + + this->action = ENHORSE_ACT_STOPPING; + this->animationIdx = ENHORSE_ANIM_GALLOP; + Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx]); + jointTable = this->skin.skelAnime.jointTable; + y = jointTable->y; + this->riderPos.y += y * 0.01f * this->unk_528 * 0.01f; + this->postDrawFunc = NULL; +} + +void EnHorse_MountedGallop(EnHorse* this, GlobalContext* globalCtx) { + f32 stickMag; + s16 stickAngle; + + EnHorse_StickDirection(&this->curStick, &stickMag, &stickAngle); + + if (this->noInputTimer <= 0) { + EnHorse_UpdateSpeed(this, globalCtx, 0.3f, -0.5f, 10.0f, 0.06f, 8.0f, 800); + } else if (this->noInputTimer > 0) { + this->noInputTimer--; + this->actor.speedXZ = 8.0f; + } + + if (this->actor.speedXZ < 6.0f) { + EnHorse_StartTrotting(this); + } + + this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.3f; + + if (SkelAnime_Update(&this->skin.skelAnime)) { + func_8087C1C0(this); + func_8013ECE0(0.0f, 120, 8, 255); + if (EnHorse_PlayerCanMove(this, globalCtx) == true) { + if ((stickMag >= 10.0f) && (Math_CosS(stickAngle) <= -0.5f)) { + EnHorse_StartBraking(this, globalCtx); + } else if (this->actor.speedXZ < 6.0f) { + EnHorse_StartTrotting(this); + } else { + EnHorse_MountedGallopReset(this); + } + } else { + EnHorse_MountedGallopReset(this); + } + } +} + +void EnHorse_StartRearing(EnHorse* this) { + this->action = ENHORSE_ACT_REVERSE; + this->animationIdx = ENHORSE_ANIM_REARING; + + if (sAnimationHeaders[this->type][this->animationIdx] == NULL) { + if (Rand_ZeroOne() > 0.5f) { + if (this->stateFlags & ENHORSE_DRAW) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_NEIGH); + } else { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_NEIGH); + } + } + func_8013ECE0(0.0f, 180, 20, 100); + this->stateFlags &= ~ENHORSE_STOPPING_NEIGH_SOUND; + } + EnHorse_StartMountedIdleResetAnim(this); + } + + this->stateFlags &= ~ENHORSE_LAND2_SOUND; + if (this->stateFlags & ENHORSE_DRAW) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_NEIGH); + } else { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_NEIGH); + } + } + + func_8013ECE0(0.0f, 180, 20, 100); + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); +} + +void EnHorse_MountedRearing(EnHorse* this, GlobalContext* globalCtx) { + f32 stickMag; + s16 stickAngle; + + this->actor.speedXZ = 0.0f; + if (this->curFrame > 25.0f) { + if (!(this->stateFlags & ENHORSE_LAND2_SOUND)) { + this->stateFlags |= ENHORSE_LAND2_SOUND; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_LAND2); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_LAND2); + } + func_8013ECE0(0.0f, 180, 20, 100); + } + } + + EnHorse_StickDirection(&this->curStick, &stickMag, &stickAngle); + + if (SkelAnime_Update(&this->skin.skelAnime)) { + if (EnHorse_PlayerCanMove(this, globalCtx) == true) { + if (this->stateFlags & ENHORSE_FORCE_REVERSING) { + this->noInputTimer = 100; + this->noInputTimerMax = 100; + this->stateFlags &= ~ENHORSE_FORCE_REVERSING; + EnHorse_StartReversing(this); + } else if (this->stateFlags & ENHORSE_FORCE_WALKING) { + this->noInputTimer = 100; + this->noInputTimerMax = 100; + this->stateFlags &= ~ENHORSE_FORCE_WALKING; + EnHorse_StartWalking(this); + } else if (Math_CosS(stickAngle) <= -0.5f) { + EnHorse_StartReversingInterruptable(this); + } else { + EnHorse_StartMountedIdleResetAnim(this); + } + } else { + EnHorse_StartMountedIdleResetAnim(this); + } + } +} + +void EnHorse_StartBraking(EnHorse* this, GlobalContext* globalCtx) { + this->action = ENHORSE_ACT_LOW_JUMP; + this->animationIdx = ENHORSE_ANIM_STOPPING; + if (sAnimationHeaders[this->type][this->animationIdx] == NULL) { + if (Rand_ZeroOne() > 0.5f) { + if (this->stateFlags & ENHORSE_DRAW) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_NEIGH); + } else { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_NEIGH); + } + } + func_8013ECE0(0.0f, 180, 20, 100); + this->stateFlags &= ~ENHORSE_STOPPING_NEIGH_SOUND; + } + EnHorse_StartMountedIdleResetAnim(this); + } + + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_SLIP); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_SLIP); + } + + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.5f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); + this->stateFlags |= ENHORSE_STOPPING_NEIGH_SOUND; + this->stateFlags &= ~ENHORSE_BOOST; +} + +void EnHorse_Stopping(EnHorse* this, GlobalContext* globalCtx) { + if (this->actor.speedXZ > 0.0f) { + this->actor.speedXZ -= 0.6f; + if (this->actor.speedXZ < 0.0f) { + this->actor.speedXZ = 0.0f; + } + } + + if ((this->stateFlags & ENHORSE_STOPPING_NEIGH_SOUND) && (this->skin.skelAnime.curFrame > 29.0f)) { + this->actor.speedXZ = 0.0f; + if ((Rand_ZeroOne() > 0.5f) && + ((gSaveContext.save.entranceIndex != 0x6400) || !Cutscene_GetSceneSetupIndex(globalCtx))) { + if (this->stateFlags & ENHORSE_DRAW) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_NEIGH); + } else { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_NEIGH); + } + } + func_8013ECE0(0.0f, 180, 20, 100); + this->stateFlags &= ~ENHORSE_STOPPING_NEIGH_SOUND; + } else { + EnHorse_StartMountedIdleResetAnim(this); + } + } + + if (this->skin.skelAnime.curFrame > 29.0f) { + this->actor.speedXZ = 0.0f; + } else if ((this->actor.speedXZ > 3.0f) && (this->stateFlags & ENHORSE_FORCE_REVERSING)) { + this->actor.speedXZ = 3.0f; + } + + if (SkelAnime_Update(&this->skin.skelAnime)) { + if (this->stateFlags & ENHORSE_FORCE_REVERSING) { + this->noInputTimer = 100; + this->noInputTimerMax = 100; + EnHorse_StartReversing(this); + this->stateFlags &= ~ENHORSE_FORCE_REVERSING; + } else { + EnHorse_StartMountedIdleResetAnim(this); + } + } +} + +void EnHorse_StartReversingInterruptable(EnHorse* this) { + this->noInputTimer = 0; + this->noInputTimerMax = 0; + EnHorse_StartReversing(this); +} + +void EnHorse_StartReversing(EnHorse* this) { + this->action = ENHORSE_ACT_HIGH_JUMP; + this->animationIdx = ENHORSE_ANIM_WALK; + this->soundTimer = 0; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_LOOP, -3.0f); +} + +void EnHorse_Reverse(EnHorse* this, GlobalContext* globalCtx) { + f32 stickMag; + s16 stickAngle; + s16 turnAmount; + Player* player = GET_PLAYER(globalCtx); + + EnHorse_PlayWalkingSound(this); + EnHorse_StickDirection(&this->curStick, &stickMag, &stickAngle); + if (EnHorse_PlayerCanMove(this, globalCtx) == true) { + if ((this->noInputTimerMax == 0) || + ((this->noInputTimer > 0) && (this->noInputTimer < (this->noInputTimerMax - 20)))) { + if ((stickMag < 10.0f) && (this->noInputTimer <= 0)) { + EnHorse_StartMountedIdleResetAnim(this); + this->actor.speedXZ = 0.0f; + return; + } else if (stickMag < 10.0f) { + stickAngle = -0x7FFF; + } else if (Math_CosS(stickAngle) > -0.5f) { + this->noInputTimerMax = 0; + EnHorse_StartMountedIdleResetAnim(this); + this->actor.speedXZ = 0.0f; + return; + } + } else if (stickMag < 10.0f) { + stickAngle = -0x7FFF; + } + } else if ((player->actor.flags & ACTOR_FLAG_100) || (globalCtx->csCtx.state != 0) || + (ActorCutscene_GetCurrentIndex() != -1) || (player->stateFlags1 & 0x20)) { + EnHorse_StartMountedIdleResetAnim(this); + this->actor.speedXZ = 0.0f; + return; + } else { + stickAngle = -0x7FFF; + } + + this->actor.speedXZ = -2.0f; + turnAmount = -0x8000 - stickAngle; + turnAmount = CLAMP(turnAmount, -2400.0f, 2400.0f); + this->actor.world.rot.y += turnAmount; + this->actor.shape.rot.y = this->actor.world.rot.y; + + if (this->noInputTimer > 0) { + this->noInputTimer--; + if (this->noInputTimer <= 0) { + this->noInputTimerMax = 0; + } + } + + this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.5f * 1.5f; + + if (SkelAnime_Update(&this->skin.skelAnime) && (this->noInputTimer <= 0) && + (EnHorse_PlayerCanMove(this, globalCtx) == true)) { + if ((stickMag > 10.0f) && (Math_CosS(stickAngle) <= -0.5f)) { + this->noInputTimerMax = 0; + EnHorse_StartReversingInterruptable(this); + } else if (stickMag < 10.0f) { + this->noInputTimerMax = 0; + EnHorse_StartMountedIdleResetAnim(this); + } else { + EnHorse_StartReversing(this); + } + } +} + +void EnHorse_LowJumpInit(EnHorse* this, GlobalContext* globalCtx) { + this->skin.skelAnime.curFrame = 0.0f; + EnHorse_StartLowJump(this, globalCtx); +} + +void EnHorse_StartLowJump(EnHorse* this, GlobalContext* globalCtx) { + f32 curFrame; + Vec3s* jointTable; + f32 y; + + this->action = ENHORSE_ACT_BRIDGE_JUMP; + this->animationIdx = ENHORSE_ANIM_LOW_JUMP; + curFrame = this->skin.skelAnime.curFrame; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.5f, curFrame, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); + this->postDrawFunc = NULL; + this->jumpStartY = this->actor.world.pos.y; + this->actor.gravity = 0.0f; + this->actor.velocity.y = 0.0f; + + jointTable = this->skin.skelAnime.jointTable; + y = jointTable->y; + this->riderPos.y -= ((y * 0.01f) * this->unk_528) * 0.01f; + + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_JUMP); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_JUMP); + } + func_8013ECE0(0.0f, 170, 10, 10); +} + +void EnHorse_Stub1(EnHorse* this) { +} + +void EnHorse_LowJump(EnHorse* this, GlobalContext* globalCtx) { + Vec3f pad; + f32 temp_f0; + f32 curFrame; + Vec3s* jointTable; + + this->stateFlags |= ENHORSE_JUMPING; + + if (this->actor.speedXZ < 12.0f) { + this->actor.speedXZ = 12.0f; + } + + if (this->actor.floorHeight != BGCHECK_Y_MIN) { + CollisionPoly* colPoly; + s32 floorBgId; + Vec3f pos = this->actor.world.pos; + + pos.y = this->actor.floorHeight - 5.0f; + temp_f0 = + BgCheck_EntityRaycastFloor5_2(globalCtx, &globalCtx->colCtx, &colPoly, &floorBgId, &this->actor, &pos); + if ((this->actor.floorHeight - 120.0f) < temp_f0) { + this->actor.floorHeight = temp_f0; + this->actor.floorPoly = colPoly; + this->actor.floorBgId = floorBgId; + } + } + + curFrame = this->skin.skelAnime.curFrame; + + if (curFrame > 17.0f) { + this->actor.gravity = -3.5f; + if (this->actor.velocity.y == 0.0f) { + this->actor.velocity.y = -6.0f; + } + if (this->actor.world.pos.y < (this->actor.floorHeight + 90.0f)) { + this->skin.skelAnime.playSpeed = 1.5f; + } else { + this->skin.skelAnime.playSpeed = 0.0f; + } + } else { + jointTable = this->skin.skelAnime.jointTable; + temp_f0 = jointTable->y; + + this->actor.world.pos.y = this->jumpStartY + (temp_f0 * 0.01f * this->unk_528 * 0.01f); + } + + if (SkelAnime_Update(&this->skin.skelAnime) || + ((curFrame > 17.0f) && + (this->actor.world.pos.y < ((this->actor.floorHeight - this->actor.velocity.y) + 80.0f)))) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_LAND); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_LAND); + } + func_8013ECE0(0.0f, 255, 10, 80); + this->stateFlags &= ~ENHORSE_JUMPING; + this->actor.gravity = -3.5f; + this->actor.world.pos.y = this->actor.floorHeight; + EnHorse_JumpLanding(this, globalCtx); + } +} + +void EnHorse_HighJumpInit(EnHorse* this, GlobalContext* globalCtx) { + this->skin.skelAnime.curFrame = 0.0f; + EnHorse_StartHighJump(this, globalCtx); +} + +void EnHorse_StartHighJump(EnHorse* this, GlobalContext* globalCtx) { + f32 curFrame; + Vec3s* jointTable; + f32 y; + + this->action = ENHORSE_ACT_CS_UPDATE; + this->animationIdx = ENHORSE_ANIM_HIGH_JUMP; + curFrame = this->skin.skelAnime.curFrame; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.5f, curFrame, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); + + this->postDrawFunc = NULL; + this->jumpStartY = this->actor.world.pos.y; + this->actor.gravity = 0.0f; + this->actor.velocity.y = 0.0f; + + jointTable = this->skin.skelAnime.jointTable; + y = jointTable->y; + this->riderPos.y -= ((y * 0.01f) * this->unk_528) * 0.01f; + + this->stateFlags |= ENHORSE_CALC_RIDER_POS; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_JUMP); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_JUMP); + } + func_8013ECE0(0.0f, 170, 10, 10); +} + +void EnHorse_Stub2(EnHorse* this) { +} + +void EnHorse_HighJump(EnHorse* this, GlobalContext* globalCtx) { + Vec3f pad; + f32 temp_f0; + f32 curFrame; + Vec3s* jointTable; + + this->stateFlags |= ENHORSE_JUMPING; + + if (this->actor.speedXZ < 13.0f) { + this->actor.speedXZ = 13.0f; + } + + if (this->actor.floorHeight != BGCHECK_Y_MIN) { + CollisionPoly* colPoly; + s32 floorBgId; + Vec3f pos = this->actor.world.pos; + + pos.y = this->actor.floorHeight - 5.0f; + temp_f0 = + BgCheck_EntityRaycastFloor5_2(globalCtx, &globalCtx->colCtx, &colPoly, &floorBgId, &this->actor, &pos); + if ((this->actor.floorHeight - 120.0f) < temp_f0) { + this->actor.floorHeight = temp_f0; + this->actor.floorPoly = colPoly; + this->actor.floorBgId = floorBgId; + } + } + + curFrame = this->skin.skelAnime.curFrame; + + if (curFrame > 23.0f) { + this->actor.gravity = -3.5f; + if (this->actor.velocity.y == 0.0f) { + this->actor.velocity.y = -10.5f; + } + if (this->actor.world.pos.y < (this->actor.floorHeight + 90.0f)) { + this->skin.skelAnime.playSpeed = 1.5f; + } else { + this->skin.skelAnime.playSpeed = 0.0f; + } + } else { + jointTable = this->skin.skelAnime.jointTable; + temp_f0 = jointTable->y; + this->actor.world.pos.y = this->jumpStartY + (temp_f0 * 0.01f * this->unk_528 * 0.01f); + } + + if (SkelAnime_Update(&this->skin.skelAnime) || + ((curFrame > 23.0f) && + (this->actor.world.pos.y < ((this->actor.floorHeight - this->actor.velocity.y) + 80.0f)))) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_LAND); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_LAND); + } + func_8013ECE0(0.0f, 255, 10, 80); + this->stateFlags &= ~ENHORSE_JUMPING; + this->actor.gravity = -3.5f; + this->actor.world.pos.y = this->actor.floorHeight; + func_800B1598(globalCtx, 25.0f, &this->actor.world.pos); + EnHorse_JumpLanding(this, globalCtx); + } +} + +void EnHorse_InitInactive(EnHorse* this) { + this->colliderCylinder1.base.ocFlags1 &= ~OC1_ON; + this->colliderCylinder2.base.ocFlags1 &= ~OC1_ON; + this->colliderJntSph.base.ocFlags1 &= ~OC1_ON; + this->action = ENHORSE_ACT_INACTIVE; + this->animationIdx = ENHORSE_ANIM_WALK; + this->stateFlags |= ENHORSE_INACTIVE; + this->followTimer = 0; +} + +void EnHorse_Inactive(EnHorse* this, GlobalContext* globalCtx) { + if ((D_801BDAA4 != 0) && (this->type == HORSE_2)) { + D_801BDAA4 = 0; + if (EnHorse_Spawn(this, globalCtx)) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_NEIGH); + } + this->stateFlags &= ~ENHORSE_INACTIVE; + } + } + + if (!(this->stateFlags & ENHORSE_INACTIVE)) { + this->followTimer = 0; + EnHorse_SetFollowAnimation(this, globalCtx); + this->actor.params = ENHORSE_0; + this->colliderCylinder1.base.ocFlags1 |= OC1_ON; + this->colliderCylinder2.base.ocFlags1 |= OC1_ON; + this->colliderJntSph.base.ocFlags1 |= OC1_ON; + } +} + +void EnHorse_PlayIdleAnimation(EnHorse* this, s32 anim, f32 morphFrames, f32 startFrames) { + this->action = ENHORSE_ACT_IDLE; + this->actor.speedXZ = 0.0f; + + if ((anim != ENHORSE_ANIM_IDLE) && (anim != ENHORSE_ANIM_WHINNEY) && (anim != ENHORSE_ANIM_REARING)) { + anim = ENHORSE_ANIM_IDLE; + } + + if (sAnimationHeaders[this->type][anim] == NULL) { + anim = ENHORSE_ANIM_IDLE; + } + + if (anim != this->animationIdx) { + this->animationIdx = anim; + if (anim == ENHORSE_ANIM_IDLE) { + this->stateFlags &= ~ENHORSE_SANDDUST_SOUND; + } else { + if (this->animationIdx == ENHORSE_ANIM_WHINNEY) { + if (this->stateFlags & ENHORSE_DRAW) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_GROAN); + } else { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_GROAN); + } + } + } else if (this->animationIdx == ENHORSE_ANIM_REARING) { + if (this->stateFlags & ENHORSE_DRAW) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_NEIGH); + } else { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_NEIGH); + } + } + this->stateFlags &= ~ENHORSE_LAND2_SOUND; + } + } + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, startFrames, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + morphFrames); + } +} + +void EnHorse_ChangeIdleAnimation(EnHorse* this, s32 anim, f32 morphFrames) { + EnHorse_PlayIdleAnimation(this, anim, morphFrames, this->curFrame); +} + +void EnHorse_ResetIdleAnimation(EnHorse* this) { + this->animationIdx = ENHORSE_ANIM_WALK; + EnHorse_PlayIdleAnimation(this, this->animationIdx, 0.0f, 0.0f); +} + +void EnHorse_StartIdleRidable(EnHorse* this) { + EnHorse_ResetIdleAnimation(this); + this->stateFlags &= ~ENHORSE_UNRIDEABLE; +} + +void EnHorse_Idle(EnHorse* this, GlobalContext* globalCtx) { + this->actor.speedXZ = 0.0f; + EnHorse_IdleAnimSounds(this, globalCtx); + + if ((D_801BDAA4 != 0) && (this->type == HORSE_2)) { + D_801BDAA4 = 0; + if (!func_8087C38C(globalCtx, this, &this->actor.world.pos)) { + if (EnHorse_Spawn(this, globalCtx)) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_NEIGH); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_NEIGH); + } + this->followTimer = 0; + EnHorse_SetFollowAnimation(this, globalCtx); + } + } else { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_NEIGH); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_NEIGH); + } + this->followTimer = 0; + EnHorse_StartMovingAnimation(this, 6, -3.0f, 0.0f); + } + } + + if (SkelAnime_Update(&this->skin.skelAnime)) { + s32 idleAnimIdx = 0; + + if (this->animationIdx != 0) { + if (this->animationIdx == 1) { + idleAnimIdx = 1; + } else if (this->animationIdx == 3) { + idleAnimIdx = 2; + } + } + // Play one of the two other idle animations + EnHorse_PlayIdleAnimation(this, sIdleAnimIds[((Rand_ZeroOne() > 0.5f) ? 0 : 1) + idleAnimIdx * 2], 0.0f, 0.0f); + } +} + +void EnHorse_StartMovingAnimation(EnHorse* this, s32 anim, f32 morphFrames, f32 startFrames) { + this->action = ENHORSE_ACT_FOLLOW_PLAYER; + this->stateFlags &= ~ENHORSE_TURNING_TO_PLAYER; + + if ((anim != ENHORSE_ANIM_TROT) && (anim != ENHORSE_ANIM_GALLOP) && (anim != ENHORSE_ANIM_WALK)) { + anim = ENHORSE_ANIM_WALK; + } + + if (anim != this->animationIdx) { + this->animationIdx = anim; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, startFrames, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + morphFrames); + } else { + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, startFrames, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + 0.0f); + } +} + +void EnHorse_SetFollowAnimation(EnHorse* this, GlobalContext* globalCtx) { + s32 anim = ENHORSE_ANIM_WALK; + f32 distToPlayer = Actor_XZDistanceBetweenActors(&this->actor, &GET_PLAYER(globalCtx)->actor); + + if (distToPlayer > 400.0f) { + anim = ENHORSE_ANIM_GALLOP; + } else if (!(distToPlayer <= 300.0f) && (distToPlayer <= 400.0f)) { + anim = ENHORSE_ANIM_TROT; + } + + if (this->animationIdx == ENHORSE_ANIM_GALLOP) { + if (distToPlayer > 400.0f) { + anim = ENHORSE_ANIM_GALLOP; + } else { + anim = ENHORSE_ANIM_TROT; + } + } else if (this->animationIdx == ENHORSE_ANIM_TROT) { + if (distToPlayer > 400.0f) { + anim = ENHORSE_ANIM_GALLOP; + } else if (distToPlayer < 300.0f) { + anim = ENHORSE_ANIM_WALK; + } else { + anim = ENHORSE_ANIM_TROT; + } + } else if (this->animationIdx == ENHORSE_ANIM_WALK) { + if (distToPlayer > 300.0f) { + anim = ENHORSE_ANIM_TROT; + } else { + anim = ENHORSE_ANIM_WALK; + } + } + + EnHorse_StartMovingAnimation(this, anim, -3.0f, 0.0f); +} + +void EnHorse_FollowPlayer(EnHorse* this, GlobalContext* globalCtx) { + f32 distToPlayer; + + D_801BDAA4 = 0; + distToPlayer = Actor_XZDistanceBetweenActors(&this->actor, &GET_PLAYER(globalCtx)->actor); + + if (((this->playerDir == PLAYER_DIR_BACK_R) || (this->playerDir == PLAYER_DIR_BACK_L)) && (distToPlayer > 300.0f) && + !(this->stateFlags & ENHORSE_TURNING_TO_PLAYER)) { + f32 angleDiff; + + this->animationIdx = ENHORSE_ANIM_REARING; + this->stateFlags |= ENHORSE_TURNING_TO_PLAYER; + this->angleToPlayer = Actor_YawBetweenActors(&this->actor, &GET_PLAYER(globalCtx)->actor); + + angleDiff = (f32)this->angleToPlayer - this->actor.world.rot.y; + if (angleDiff > 0x7FFF) { + angleDiff -= 0x7FFF; + } else if (angleDiff < -0x7FFF) { + angleDiff += 0x7FFF; + } + + this->followPlayerTurnSpeed = + angleDiff / Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]); + + Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx]); + this->skin.skelAnime.playSpeed = 1.0f; + this->stateFlags &= ~ENHORSE_LAND2_SOUND; + } else if (this->stateFlags & ENHORSE_TURNING_TO_PLAYER) { + this->actor.world.rot.y += this->followPlayerTurnSpeed; + this->actor.shape.rot.y = this->actor.world.rot.y; + if ((this->curFrame > 25.0f) && !(this->stateFlags & ENHORSE_LAND2_SOUND)) { + this->stateFlags |= ENHORSE_LAND2_SOUND; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_LAND2); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_LAND2); + } + } + } else { + EnHorse_RotateToPlayer(this, globalCtx); + } + + if (this->animationIdx == ENHORSE_ANIM_GALLOP) { + this->actor.speedXZ = 8.0f; + this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.3f; + } else { + if (this->animationIdx == ENHORSE_ANIM_TROT) { + this->actor.speedXZ = 6.0f; + this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.375f; + } else if (this->animationIdx == ENHORSE_ANIM_WALK) { + this->actor.speedXZ = 3.0f; + EnHorse_PlayWalkingSound(this); + this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.75f; + } else { + this->actor.speedXZ = 0.0f; + this->skin.skelAnime.playSpeed = 1.0f; + } + } + + if (!(this->stateFlags & ENHORSE_TURNING_TO_PLAYER)) { + this->followTimer++; + if (this->followTimer > 300) { + EnHorse_StartIdleRidable(this); + if (this->stateFlags & ENHORSE_DRAW) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_NEIGH); + } else { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_NEIGH); + } + } + } + } + + if (SkelAnime_Update(&this->skin.skelAnime)) { + if (this->animationIdx == ENHORSE_ANIM_GALLOP) { + func_8087C1C0(this); + } else if (this->animationIdx == ENHORSE_ANIM_TROT) { + func_8087C178(this); + } + + this->stateFlags &= ~ENHORSE_TURNING_TO_PLAYER; + + if (distToPlayer < 100.0f) { + EnHorse_StartIdleRidable(this); + } else { + EnHorse_SetFollowAnimation(this, globalCtx); + } + } +} + +void EnHorse_InitIngoHorse(EnHorse* this) { + this->curRaceWaypoint = 0; + this->soundTimer = 0; + this->actor.speedXZ = 0.0f; + EnHorse_UpdateIngoHorseAnim(this); + if (this->stateFlags & ENHORSE_DRAW) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_IT_INGO_HORSE_NEIGH); + } +} + +void EnHorse_SetIngoAnimation(s32 anim, f32 curFrame, s32 arg2, s16* animIdxOut) { + *animIdxOut = sIngoAnimations[anim]; + if (arg2 == 1) { + if (anim == 5) { + *animIdxOut = 4; + } else if (anim == 6) { + *animIdxOut = 3; + } + } +} + +void EnHorse_UpdateIngoHorseAnim(EnHorse* this) { + s32 animChanged = false; + f32 animSpeed; + + this->action = ENHORSE_ACT_INGO_RACE; + this->stateFlags &= ~ENHORSE_SANDDUST_SOUND; + + if (this->actor.speedXZ == 0.0f) { + if (this->animationIdx != ENHORSE_ANIM_IDLE) { + animChanged = true; + } + this->animationIdx = ENHORSE_ANIM_IDLE; + } else if (this->actor.speedXZ <= 3.0f) { + if (this->animationIdx != ENHORSE_ANIM_WALK) { + animChanged = true; + } + this->animationIdx = ENHORSE_ANIM_WALK; + } else if (this->actor.speedXZ <= 6.0f) { + if (this->animationIdx != ENHORSE_ANIM_TROT) { + animChanged = true; + } + this->animationIdx = ENHORSE_ANIM_TROT; + } else { + if (this->animationIdx != ENHORSE_ANIM_GALLOP) { + animChanged = true; + } + this->animationIdx = ENHORSE_ANIM_GALLOP; + } + + if (this->animationIdx == ENHORSE_ANIM_WALK) { + animSpeed = this->actor.speedXZ * 0.5f; + } else if (this->animationIdx == ENHORSE_ANIM_TROT) { + animSpeed = this->actor.speedXZ * 0.25f; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_RUN); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_RUN); + } + } else if (this->animationIdx == ENHORSE_ANIM_GALLOP) { + animSpeed = this->actor.speedXZ * 0.2f; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_RUN); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_RUN); + } + } else { + animSpeed = 1.0f; + } + + if (animChanged == true) { + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], + sPlaybackSpeeds[this->animationIdx] * animSpeed * 1.5f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + -3.0f); + } else { + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], + sPlaybackSpeeds[this->animationIdx] * animSpeed * 1.5f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + 0.0f); + } +} + +void EnHorse_UpdateIngoRace(EnHorse* this, GlobalContext* globalCtx) { + f32 playSpeed; + + if ((this->animationIdx == ENHORSE_ANIM_IDLE) || (this->animationIdx == ENHORSE_ANIM_WHINNEY)) { + EnHorse_IdleAnimSounds(this, globalCtx); + } else if (this->animationIdx == ENHORSE_ANIM_WALK) { + EnHorse_PlayWalkingSound(this); + } + + if (!this->inRace) { + this->actor.speedXZ = 0.0f; + this->rider->actor.speedXZ = 0.0f; + if (this->animationIdx != ENHORSE_ANIM_IDLE) { + EnHorse_UpdateIngoHorseAnim(this); + } + } + + if (this->animationIdx == ENHORSE_ANIM_WALK) { + playSpeed = this->actor.speedXZ * 0.5f; + } else if (this->animationIdx == 5) { + playSpeed = this->actor.speedXZ * 0.25f; + } else if (this->animationIdx == 6) { + playSpeed = this->actor.speedXZ * 0.2f; + } else { + playSpeed = 1.0f; + } + this->skin.skelAnime.playSpeed = playSpeed; + + if (SkelAnime_Update(&this->skin.skelAnime) || + ((this->animationIdx == ENHORSE_ANIM_IDLE) && (this->actor.speedXZ != 0.0f))) { + EnHorse_UpdateIngoHorseAnim(this); + } +} + +void func_8088126C(EnHorse* this, GlobalContext* globalCtx) { + this->skin.skelAnime.curFrame = 0.0f; + func_80881290(this, globalCtx); +} + +void func_80881290(EnHorse* this, GlobalContext* globalCtx) { + f32 curFrame; + + this->action = ENHORSE_ACT_MOUNTED_IDLE_WHINNEYING; + this->animationIdx = ENHORSE_ANIM_HIGH_JUMP; + curFrame = this->skin.skelAnime.curFrame; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.5f, curFrame, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); + this->postDrawFunc = NULL; + this->actor.gravity = 0.0f; + this->actor.velocity.y = 0.0f; + this->jumpStartY = this->actor.world.pos.y; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_JUMP); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_JUMP); + } + func_8013ECE0(0.0f, 170, 10, 10); +} + +void func_80881398(EnHorse* this, GlobalContext* globalCtx) { + Vec3s* jointTable; + f32 y; + s32 animeUpdated; + f32 curFrame; + + this->stateFlags |= ENHORSE_JUMPING; + if (this->actor.speedXZ < 14.0f) { + this->actor.speedXZ = 14.0f; + } + + animeUpdated = SkelAnime_Update(&this->skin.skelAnime); + curFrame = this->skin.skelAnime.curFrame; + + if (curFrame > 23.0f) { + this->actor.gravity = -3.5f; + if (this->actor.velocity.y == 0.0f) { + this->actor.velocity.y = -10.5f; + } + if (this->actor.world.pos.y < (this->actor.floorHeight + 90.0f)) { + this->skin.skelAnime.playSpeed = 1.5f; + } else { + this->skin.skelAnime.playSpeed = 0.0f; + } + } else { + jointTable = this->skin.skelAnime.jointTable; + y = jointTable->y; + this->actor.world.pos.y = this->jumpStartY + (y * 0.01f * this->unk_528 * 0.01f); + } + + if (animeUpdated || ((curFrame > 17.0f) && + (this->actor.world.pos.y < ((this->actor.floorHeight - this->actor.velocity.y) + 80.0f)))) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_LAND); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_LAND); + } + func_8013ECE0(0.0f, 255, 10, 80); + this->stateFlags &= ~ENHORSE_JUMPING; + this->stateFlags &= ~ENHORSE_FLAG_30; + this->actor.gravity = -3.5f; + this->actor.world.pos.y = this->actor.floorHeight; + func_800B1598(globalCtx, 25.0f, &this->actor.world.pos); + func_8088159C(this, globalCtx); + } +} + +void func_8088159C(EnHorse* this, GlobalContext* globalCtx) { + Vec3s* jointTable; + f32 y; + + this->action = ENHORSE_ACT_MOUNTED_IDLE; + this->animationIdx = ENHORSE_ANIM_GALLOP; + Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx]); + jointTable = this->skin.skelAnime.jointTable; + y = jointTable->y; + this->riderPos.y += y * 0.01f * this->unk_528 * 0.01f; + this->postDrawFunc = NULL; +} + +void func_80881634(EnHorse* this) { + this->curRaceWaypoint = 0; + this->soundTimer = 0; + this->actor.speedXZ = 0.0f; + func_8088168C(this); + if (this->stateFlags & ENHORSE_DRAW) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_IT_INGO_HORSE_NEIGH); + } +} + +void func_8088168C(EnHorse* this) { + s32 animChanged = false; + f32 animSpeed; + f32 finalAnimSpeed; + + this->action = ENHORSE_ACT_MOUNTED_IDLE; + this->stateFlags &= ~ENHORSE_SANDDUST_SOUND; + + if (this->actor.speedXZ == 0.0f) { + if (this->animationIdx != ENHORSE_ANIM_IDLE) { + animChanged = true; + } + this->animationIdx = ENHORSE_ANIM_IDLE; + } else if (this->actor.speedXZ <= 3.0f) { + if (this->animationIdx != ENHORSE_ANIM_WALK) { + animChanged = true; + } + this->animationIdx = ENHORSE_ANIM_WALK; + } else if (this->actor.speedXZ <= 6.0f) { + if (this->animationIdx != ENHORSE_ANIM_TROT) { + animChanged = true; + } + this->animationIdx = ENHORSE_ANIM_TROT; + } else { + if (this->animationIdx != ENHORSE_ANIM_GALLOP) { + animChanged = true; + } + this->animationIdx = ENHORSE_ANIM_GALLOP; + } + + if (this->animationIdx == ENHORSE_ANIM_WALK) { + animSpeed = this->actor.speedXZ * 0.5f; + } else if (this->animationIdx == ENHORSE_ANIM_TROT) { + animSpeed = this->actor.speedXZ * 0.25f; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_RUN); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_RUN); + } + } else if (this->animationIdx == ENHORSE_ANIM_GALLOP) { + animSpeed = this->actor.speedXZ * 0.2f; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_RUN); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_RUN); + } + } else { + animSpeed = 1.0f; + } + + finalAnimSpeed = sPlaybackSpeeds[this->animationIdx] * animSpeed * 1.5f; + if (finalAnimSpeed < 1.0f) { + finalAnimSpeed = 1.0f; + } + + if (animChanged == true) { + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], finalAnimSpeed, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + -3.0f); + } else { + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], finalAnimSpeed, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + 0.0f); + } +} + +void func_808819D8(EnHorse* this, GlobalContext* globalCtx) { + Path* path; + f32 animSpeed; + + if ((this->animationIdx == ENHORSE_ANIM_IDLE) || (this->animationIdx == ENHORSE_ANIM_WHINNEY)) { + EnHorse_IdleAnimSounds(this, globalCtx); + } else if (this->animationIdx == ENHORSE_ANIM_WALK) { + EnHorse_PlayWalkingSound(this); + } + + if (!this->inRace) { + this->actor.speedXZ = 0.0f; + this->rider->actor.speedXZ = 0.0f; + if (this->animationIdx != ENHORSE_ANIM_IDLE) { + EnHorse_UpdateIngoHorseAnim(this); + } + } + + if (this->actor.params == ENHORSE_4) { + path = &globalCtx->setupPathList[0]; + func_8087B7C0(this, globalCtx, path); + } else if (this->actor.params == ENHORSE_5) { + path = &globalCtx->setupPathList[1]; + func_8087B7C0(this, globalCtx, path); + } + + if (!this->inRace) { + this->actor.speedXZ = 0.0f; + if (this->animationIdx != ENHORSE_ANIM_IDLE) { + func_8088168C(this); + } + } + + if (this->animationIdx == ENHORSE_ANIM_WALK) { + animSpeed = this->actor.speedXZ * 0.5f; + } else if (this->animationIdx == ENHORSE_ANIM_TROT) { + animSpeed = this->actor.speedXZ * 0.25f; + } else if (this->animationIdx == ENHORSE_ANIM_GALLOP) { + animSpeed = this->actor.speedXZ * 0.2f; + } else { + animSpeed = 1.0f; + } + this->skin.skelAnime.playSpeed = animSpeed; + + if (SkelAnime_Update(&this->skin.skelAnime) || + ((this->animationIdx == ENHORSE_ANIM_IDLE) && (this->actor.speedXZ != 0.0f))) { + func_8088168C(this); + } + + if ((gSaveContext.save.weekEventReg[92] & (1 | 2 | 4)) == 3) { + this->rider->unk488 = 7; + } else { + EnHorse_SetIngoAnimation(this->animationIdx, this->skin.skelAnime.curFrame, this->unk_394 & 1, + &this->rider->unk488); + } +} + +void EnHorse_CsMoveInit(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + this->animationIdx = ENHORSE_ANIM_GALLOP; + this->cutsceneAction = 1; + Animation_PlayOnceSetSpeed(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], + this->actor.speedXZ * 0.2f * 1.5f); +} + +void EnHorse_CsMoveToPoint(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + Vec3f endPos; + s32 pad; + + endPos.x = action->endPos.x; + endPos.y = action->endPos.y; + endPos.z = action->endPos.z; + + if (Math3D_Distance(&endPos, &this->actor.world.pos) > 8.0f) { + EnHorse_RotateToPoint(this, globalCtx, &endPos, 0x320); + this->actor.speedXZ = 8.0f; + this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.3f; + } else { + this->actor.world.pos = endPos; + this->actor.speedXZ = 0.0f; + } + + if (SkelAnime_Update(&this->skin.skelAnime)) { + func_8087C1C0(this); + func_8013ECE0(0.0f, 120, 8, 255); + Animation_PlayOnceSetSpeed(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], + this->actor.speedXZ * 0.3f); + } +} + +void EnHorse_CsSetAnimHighJump(EnHorse* this, GlobalContext* globalCtx) { + this->skin.skelAnime.curFrame = 0.0f; + EnHorse_CsPlayHighJumpAnim(this, globalCtx); +} + +void EnHorse_CsPlayHighJumpAnim(EnHorse* this, GlobalContext* globalCtx) { + f32 curFrame; + f32 y; + Vec3s* jointTable; + + this->animationIdx = ENHORSE_ANIM_HIGH_JUMP; + curFrame = this->skin.skelAnime.curFrame; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.5f, curFrame, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); + this->postDrawFunc = NULL; + this->jumpStartY = this->actor.world.pos.y; + this->actor.gravity = 0.0f; + this->actor.velocity.y = 0.0f; + + jointTable = this->skin.skelAnime.jointTable; + y = jointTable->y; + this->riderPos.y -= y * 0.01f * this->unk_528 * 0.01f; + + this->stateFlags |= ENHORSE_ANIM_HIGH_JUMP; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_JUMP); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_JUMP); + } + func_8013ECE0(0.0f, 170, 10, 10); +} + +void EnHorse_CsJumpInit(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + EnHorse_CsSetAnimHighJump(this, globalCtx); + this->cutsceneAction = 2; + this->cutsceneFlags &= ~1; +} + +void EnHorse_CsJump(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + f32 curFrame; + f32 y; + Vec3s* jointTable; + s32 pad[2]; + + if (this->cutsceneFlags & 1) { + EnHorse_CsMoveToPoint(this, globalCtx, action); + return; + } + + curFrame = this->skin.skelAnime.curFrame; + this->actor.speedXZ = 13.0f; + this->stateFlags |= ENHORSE_JUMPING; + + if (curFrame > 19.0f) { + this->actor.gravity = -3.5f; + if (this->actor.velocity.y == 0.0f) { + this->actor.velocity.y = -10.5f; + } + if (this->actor.world.pos.y < (this->actor.floorHeight + 90.0f)) { + this->skin.skelAnime.playSpeed = 1.5f; + } else { + this->skin.skelAnime.playSpeed = 0.0f; + } + } else { + jointTable = this->skin.skelAnime.jointTable; + y = jointTable->y; + + this->actor.world.pos.y = this->jumpStartY + (y * 0.01f * this->unk_528 * 0.01f); + } + + if (SkelAnime_Update(&this->skin.skelAnime) || + ((curFrame > 19.0f) && + (this->actor.world.pos.y < ((this->actor.floorHeight - this->actor.velocity.y) + 80.0f)))) { + this->cutsceneFlags |= 1; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_LAND); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_LAND); + } + func_8013ECE0(0.0f, 255, 10, 80); + this->stateFlags &= ~ENHORSE_JUMPING; + this->actor.gravity = -3.5f; + this->actor.velocity.y = 0.0f; + this->actor.world.pos.y = this->actor.floorHeight; + func_800B1598(globalCtx, 25.0f, &this->actor.world.pos); + this->animationIdx = ENHORSE_ANIM_GALLOP; + Animation_PlayOnceSetSpeed(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], + sPlaybackSpeeds[6]); + + jointTable = this->skin.skelAnime.jointTable; + y = jointTable->y; + this->riderPos.y += y * 0.01f * this->unk_528 * 0.01f; + + this->postDrawFunc = NULL; + } +} + +void EnHorse_CsRearingInit(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + this->animationIdx = ENHORSE_ANIM_REARING; + this->cutsceneAction = 3; + this->cutsceneFlags &= ~4; + this->stateFlags &= ~ENHORSE_LAND2_SOUND; + if (this->stateFlags & ENHORSE_DRAW) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_NEIGH); + } else { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_NEIGH); + } + } + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); +} + +void EnHorse_CsRearing(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + this->actor.speedXZ = 0.0f; + if (this->curFrame > 25.0f) { + if (!(this->stateFlags & ENHORSE_LAND2_SOUND)) { + this->stateFlags |= ENHORSE_LAND2_SOUND; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_LAND2); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_LAND2); + } + } + } + + if (SkelAnime_Update(&this->skin.skelAnime)) { + this->animationIdx = ENHORSE_ANIM_IDLE; + if (!(this->cutsceneFlags & 4)) { + this->cutsceneFlags |= 4; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + -3.0f); + } else { + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_LOOP, + 0.0f); + } + } +} + +void EnHorse_WarpMoveInit(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + this->actor.world.pos.x = action->startPos.x; + this->actor.world.pos.y = action->startPos.y; + this->actor.world.pos.z = action->startPos.z; + this->actor.prevPos = this->actor.world.pos; + + this->actor.world.rot.y = action->urot.y; + this->actor.shape.rot = this->actor.world.rot; + + this->animationIdx = ENHORSE_ANIM_GALLOP; + this->cutsceneAction = 4; + Animation_PlayOnceSetSpeed(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], + this->actor.speedXZ * 0.3f); +} + +void EnHorse_CsWarpMoveToPoint(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + Vec3f endPos; + s32 pad; + + endPos.x = action->endPos.x; + endPos.y = action->endPos.y; + endPos.z = action->endPos.z; + + if (Math3D_Distance(&endPos, &this->actor.world.pos) > 8.0f) { + EnHorse_RotateToPoint(this, globalCtx, &endPos, 0x320); + this->actor.speedXZ = 8.0f; + this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.3f; + } else { + this->actor.world.pos = endPos; + this->actor.speedXZ = 0.0f; + } + + if (SkelAnime_Update(&this->skin.skelAnime)) { + func_8087C1C0(this); + func_8013ECE0(0.0f, 120, 8, 255); + Animation_PlayOnceSetSpeed(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], + this->actor.speedXZ * 0.3f); + } +} + +void EnHorse_CsWarpRearingInit(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + this->actor.world.pos.x = action->startPos.x; + this->actor.world.pos.y = action->startPos.y; + this->actor.world.pos.z = action->startPos.z; + this->actor.prevPos = this->actor.world.pos; + + this->actor.world.rot.y = action->urot.y; + this->actor.shape.rot = this->actor.world.rot; + + this->animationIdx = ENHORSE_ANIM_REARING; + this->cutsceneAction = 5; + this->cutsceneFlags &= ~4; + this->stateFlags &= ~ENHORSE_LAND2_SOUND; + + if (this->stateFlags & ENHORSE_DRAW) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_NEIGH); + } else { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_NEIGH); + } + } + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); +} + +void EnHorse_CsWarpRearing(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + this->actor.speedXZ = 0.0f; + if (this->curFrame > 25.0f) { + if (!(this->stateFlags & ENHORSE_LAND2_SOUND)) { + this->stateFlags |= ENHORSE_LAND2_SOUND; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_LAND2); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_LAND2); + } + } + } + + if (SkelAnime_Update(&this->skin.skelAnime)) { + this->animationIdx = ENHORSE_ANIM_IDLE; + if (!(this->cutsceneFlags & 4)) { + this->cutsceneFlags |= 4; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + -3.0f); + } else { + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_LOOP, + 0.0f); + } + } +} + +void EnHorse_InitCutscene(EnHorse* this, GlobalContext* globalCtx) { + this->playerControlled = false; + this->action = ENHORSE_ACT_HBA; + this->cutsceneAction = 0; + this->actor.speedXZ = 0.0f; +} + +s32 EnHorse_GetCutsceneFunctionIndex(s32 csAction) { + s32 numActions = ARRAY_COUNT(sCsActionTable); // prevents unrolling + s32 i; + + for (i = 0; i < numActions; i++) { + if (csAction == sCsActionTable[i].csAction) { + return sCsActionTable[i].csFuncIdx; + } + + if (csAction < sCsActionTable[i].csAction) { + return 0; + } + } + return 0; +} + +void EnHorse_CutsceneUpdate(EnHorse* this, GlobalContext* globalCtx) { + s32 csFunctionIdx; + CsCmdActorAction* playerAction = globalCtx->csCtx.playerAction; + + if (globalCtx->csCtx.state == 3) { + this->playerControlled = true; + this->actor.params = ENHORSE_12; + this->action = ENHORSE_ACT_IDLE; + EnHorse_Freeze(this, globalCtx); + return; + } + + if (playerAction != NULL) { + csFunctionIdx = EnHorse_GetCutsceneFunctionIndex(playerAction->action); + if (csFunctionIdx != 0) { + if (csFunctionIdx != this->cutsceneAction) { + if (this->cutsceneAction == 0) { + this->actor.world.pos.x = playerAction->startPos.x; + this->actor.world.pos.y = playerAction->startPos.y; + this->actor.world.pos.z = playerAction->startPos.z; + + this->actor.world.rot.y = playerAction->urot.y; + this->actor.shape.rot = this->actor.world.rot; + this->actor.prevPos = this->actor.world.pos; + } + this->cutsceneAction = csFunctionIdx; + sCutsceneInitFuncs[csFunctionIdx](this, globalCtx, playerAction); + } + sCutsceneActionFuncs[this->cutsceneAction](this, globalCtx, playerAction); + } + } +} + +s32 EnHorse_UpdateHbaRaceInfo(EnHorse* this, GlobalContext* globalCtx, RaceInfo* raceInfo) { + Vec3f pos; + f32 px; + f32 pz; + f32 d; + + EnHorse_RaceWaypointPos(raceInfo->waypoints, this->curRaceWaypoint, &pos); + func_8017B7F8(&pos, raceInfo->waypoints[this->curRaceWaypoint].angle, &px, &pz, &d); + + if ((this->curRaceWaypoint >= (raceInfo->numWaypoints - 1)) && + (Math3D_Distance(&pos, &this->actor.world.pos) < DREG(8))) { + this->hbaFlags |= 2; + } + + if (((this->actor.world.pos.x * px) + (pz * this->actor.world.pos.z) + d) > 0.0f) { + this->curRaceWaypoint++; + if (this->curRaceWaypoint >= raceInfo->numWaypoints) { + this->hbaFlags |= 1; + return true; + } + } + + if (!(this->hbaFlags & 1)) { + EnHorse_RotateToPoint(this, globalCtx, &pos, 0x640); + } + + this->actor.shape.rot.y = this->actor.world.rot.y; + if ((this->actor.speedXZ < raceInfo->waypoints[this->curRaceWaypoint].speed) && !(this->hbaFlags & 1)) { + this->actor.speedXZ += 0.4f; + } else { + this->actor.speedXZ -= 0.4f; + if (this->actor.speedXZ < 0.0f) { + this->actor.speedXZ = 0.0f; + } + } + return false; +} + +void EnHorse_InitHorsebackArchery(EnHorse* this) { + this->hbaStarted = 0; + this->soundTimer = 0; + this->curRaceWaypoint = 0; + this->hbaTimer = 0; + this->actor.speedXZ = 0.0f; + EnHorse_UpdateHbaAnim(this); +} + +void EnHorse_UpdateHbaAnim(EnHorse* this) { + s32 animChanged = false; + f32 animSpeed; + + this->action = ENHORSE_ACT_FLEE_PLAYER; + if (this->actor.speedXZ == 0.0f) { + if (this->animationIdx != ENHORSE_ANIM_IDLE) { + animChanged = true; + } + this->animationIdx = ENHORSE_ANIM_IDLE; + } else if (this->actor.speedXZ <= 3.0f) { + if (this->animationIdx != ENHORSE_ANIM_WALK) { + animChanged = true; + } + this->animationIdx = ENHORSE_ANIM_WALK; + } else if (this->actor.speedXZ <= 6.0f) { + if (this->animationIdx != ENHORSE_ANIM_TROT) { + animChanged = true; + } + this->animationIdx = ENHORSE_ANIM_TROT; + } else { + if (this->animationIdx != ENHORSE_ANIM_GALLOP) { + animChanged = true; + } + this->animationIdx = ENHORSE_ANIM_GALLOP; + } + + if (this->animationIdx == ENHORSE_ANIM_WALK) { + animSpeed = this->actor.speedXZ * 0.5f; + } else if (this->animationIdx == ENHORSE_ANIM_TROT) { + animSpeed = this->actor.speedXZ * 0.25f; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_RUN); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_RUN); + } + func_8013ECE0(0.0f, 60, 8, 255); + } else if (this->animationIdx == ENHORSE_ANIM_GALLOP) { + animSpeed = this->actor.speedXZ * 0.2f; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_RUN); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_RUN); + } + func_8013ECE0(0.0f, 120, 8, 255); + } else { + animSpeed = 1.0f; + } + + if (animChanged == true) { + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], + sPlaybackSpeeds[this->animationIdx] * animSpeed * 1.5f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + -3.0f); + } else { + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], + sPlaybackSpeeds[this->animationIdx] * animSpeed * 1.5f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + 0.0f); + } +} + +void EnHorse_UpdateHorsebackArchery(EnHorse* this, GlobalContext* globalCtx) { + f32 playSpeed; + s32 sp28; + + if (this->animationIdx == ENHORSE_ANIM_WALK) { + EnHorse_PlayWalkingSound(this); + } + + if (globalCtx->interfaceCtx.hbaAmmo == 0) { + this->hbaTimer++; + } + + sp28 = Audio_IsSequencePlaying(0x41); + EnHorse_UpdateHbaRaceInfo(this, globalCtx, &sHbaInfo); + + if (((this->hbaFlags & 1) || (this->hbaTimer > 45)) && (sp28 != 1) && (gSaveContext.minigameState != 3)) { + gSaveContext.save.cutscene = 0; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 0x40; + } + + if (globalCtx->interfaceCtx.hbaAmmo) {} + + if (((globalCtx->interfaceCtx.hbaAmmo == 0) || (this->hbaFlags & 2)) && (this->hbaFlags & 4)) { + this->hbaFlags &= ~4; + Audio_QueueSeqCmd(0x8041); + } + + if (this->hbaStarted == 0) { + this->actor.speedXZ = 0.0f; + if (this->animationIdx != ENHORSE_ANIM_IDLE) { + EnHorse_UpdateHbaAnim(this); + } + } + + if (this->animationIdx == ENHORSE_ANIM_WALK) { + playSpeed = this->actor.speedXZ * 0.5f; + } else if (this->animationIdx == ENHORSE_ANIM_TROT) { + playSpeed = this->actor.speedXZ * 0.25f; + } else if (this->animationIdx == ENHORSE_ANIM_GALLOP) { + playSpeed = this->actor.speedXZ * 0.2f; + } else { + playSpeed = 1.0f; + } + this->skin.skelAnime.playSpeed = playSpeed; + + if (SkelAnime_Update(&this->skin.skelAnime) || + ((this->animationIdx == ENHORSE_ANIM_IDLE) && (this->actor.speedXZ != 0.0f))) { + EnHorse_UpdateHbaAnim(this); + } +} + +#ifdef NON_MATCHING +void EnHorse_FleePlayer(EnHorse* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 distToHome; + f32 playerDistToHome; + f32 distToPlayer; + s32 nextAnim; + s32 animFinished; + s16 yaw; + + if ((D_801BDAA4 != 0) || (this->type == HORSE_HNI)) { + EnHorse_StartIdleRidable(this); + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_NEIGH); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_NEIGH); + } + } + + distToHome = Math3D_Distance(&this->actor.home.pos, &this->actor.world.pos); + playerDistToHome = Math3D_Distance(&player->actor.world.pos, &this->actor.home.pos); + distToPlayer = Math3D_Distance(&player->actor.world.pos, &this->actor.world.pos); + + if (playerDistToHome > 300.0f) { + if (distToHome > 150.0f) { + this->actor.speedXZ += 0.4f; + if (this->actor.speedXZ > 8.0f) { + this->actor.speedXZ = 8.0f; + } + } else { + this->actor.speedXZ -= 0.5f; + if (this->actor.speedXZ < 0.0f) { + this->actor.speedXZ = 0.0f; + } + } + } else if (distToPlayer < 300.0f) { + this->actor.speedXZ += 0.4f; + if (this->actor.speedXZ > 8.0f) { + this->actor.speedXZ = 8.0f; + } + } else { + this->actor.speedXZ -= 0.5f; + if (this->actor.speedXZ < 0.0f) { + this->actor.speedXZ = 0.0f; + } + } + + if (this->actor.speedXZ >= 6.0f) { + this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.3f; + nextAnim = ENHORSE_ANIM_GALLOP; + } else if (this->actor.speedXZ >= 3.0f) { + this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.375f; + nextAnim = ENHORSE_ANIM_TROT; + } else if (this->actor.speedXZ > 0.1f) { + this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.75f; + nextAnim = ENHORSE_ANIM_WALK; + EnHorse_PlayWalkingSound(this); + } else { + if (Rand_ZeroOne() > 0.5f) { + nextAnim = ENHORSE_ANIM_WHINNEY; + } else { + nextAnim = ENHORSE_ANIM_IDLE; + } + EnHorse_IdleAnimSounds(this, globalCtx); + this->skin.skelAnime.playSpeed = 1.0f; + } + + if ((nextAnim == ENHORSE_ANIM_GALLOP) || (nextAnim == ENHORSE_ANIM_TROT) || (nextAnim == ENHORSE_ANIM_WALK)) { + if (playerDistToHome < 300.0f) { + yaw = player->actor.shape.rot.y; + yaw += ((Actor_YawBetweenActors(&this->actor, &player->actor) > 0) ? 1 : -1) * 0x3FFF; + } else { + yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.home.pos) - this->actor.world.rot.y; + } + + if (yaw > 800.0f) { + this->actor.world.rot.y += 0x320; + } else if (yaw < -800.0f) { + this->actor.world.rot.y += -0x320; + } else { + this->actor.world.rot.y += yaw; + } + this->actor.shape.rot.y = this->actor.world.rot.y; + } + + animFinished = SkelAnime_Update(&this->skin.skelAnime); + + if (((this->animationIdx == ENHORSE_ANIM_IDLE) || (this->animationIdx == ENHORSE_ANIM_WHINNEY)) && + ((nextAnim == ENHORSE_ANIM_GALLOP) || (nextAnim == ENHORSE_ANIM_TROT) || (nextAnim == ENHORSE_ANIM_WALK))) { + this->animationIdx = nextAnim; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][nextAnim]), ANIMMODE_ONCE, -3.0f); + if (this->animationIdx == ENHORSE_ANIM_GALLOP) { + func_8087C1C0(this); + } else if (this->animationIdx == ENHORSE_ANIM_TROT) { + func_8087C178(this); + } + } else if (animFinished) { + if (nextAnim == ENHORSE_ANIM_GALLOP) { + func_8087C1C0(this); + } else if (nextAnim == ENHORSE_ANIM_TROT) { + func_8087C178(this); + } + + if ((this->animationIdx == ENHORSE_ANIM_IDLE) || (this->animationIdx == ENHORSE_ANIM_WHINNEY)) { + if (nextAnim != this->animationIdx) { + this->animationIdx = nextAnim; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), + ANIMMODE_ONCE, -3.0f); + } else { + if (Rand_ZeroOne() > 0.5f) { + this->animationIdx = ENHORSE_ANIM_IDLE; + this->stateFlags &= ~ENHORSE_SANDDUST_SOUND; + } else { + this->animationIdx = ENHORSE_ANIM_WHINNEY; + if (this->stateFlags & ENHORSE_DRAW) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_GROAN); + } else { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_GROAN); + } + } + } + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), + ANIMMODE_ONCE, -3.0f); + } + } else if (nextAnim != this->animationIdx) { + this->animationIdx = nextAnim; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + -3.0f); + } else { + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + 0.0f); + } + } else if ((this->animationIdx == ENHORSE_ANIM_WALK) && + ((nextAnim == ENHORSE_ANIM_IDLE) || (nextAnim == ENHORSE_ANIM_WHINNEY))) { + this->animationIdx = nextAnim; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + -3.0f); + } +} +#else +void EnHorse_FleePlayer(EnHorse* this, GlobalContext* globalCtx); +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/EnHorse_FleePlayer.s") +#endif + +void func_80883B70(EnHorse* this, CsCmdActorAction* action) { + this->actor.world.pos.x = action->startPos.x; + this->actor.world.pos.y = action->startPos.y; + this->actor.world.pos.z = action->startPos.z; + + this->actor.world.rot.y = action->urot.y; + this->actor.shape.rot = this->actor.world.rot; + + this->actor.prevPos = this->actor.world.pos; +} + +void func_80883BEC(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + func_80883B70(this, action); + this->animationIdx = ENHORSE_ANIM_IDLE; + this->unk_3E0 = 1; + this->stateFlags &= ~ENHORSE_SANDDUST_SOUND; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, 0.0f); + this->stateFlags |= ENHORSE_SANDDUST_SOUND; +} + +void func_80883CB0(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + EnHorse_IdleAnimSounds(this, globalCtx); + if (SkelAnime_Update(&this->skin.skelAnime)) { + this->animationIdx = ENHORSE_ANIM_IDLE; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + 0.0f); + } +} + +void func_80883D64(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + func_80883B70(this, action); + this->unk_3E0 = 2; + Animation_Change(&this->skin.skelAnime, &object_horse_link_child_Anim_00A8DC, 0.0f, 0.0f, + Animation_GetLastFrame(&object_horse_link_child_Anim_00A8DC), ANIMMODE_ONCE, 0.0f); +} + +void func_80883DE0(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + SkelAnime_Update(&this->skin.skelAnime); +} + +void func_80883E10(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + func_80883B70(this, action); + this->unk_3E0 = 3; + Animation_Change(&this->skin.skelAnime, &object_horse_link_child_Anim_00A8DC, 1.0f, 0.0f, + Animation_GetLastFrame(&object_horse_link_child_Anim_00A8DC), ANIMMODE_ONCE, -3.0f); + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_NEIGH); +} + +void func_80883EA0(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + if (SkelAnime_Update(&this->skin.skelAnime)) { + Animation_Change(&this->skin.skelAnime, &object_horse_link_child_Anim_00B3E0, 1.0f, 11.0f, + Animation_GetLastFrame(&object_horse_link_child_Anim_00B3E0), ANIMMODE_ONCE, 0.0f); + } +} + +void func_80883F18(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + func_80883B70(this, action); + this->unk_3E0 = 4; + Animation_Change(&this->skin.skelAnime, &object_horse_link_child_Anim_00AD08, 1.0f, 0.0f, + Animation_GetLastFrame(&object_horse_link_child_Anim_00AD08), ANIMMODE_ONCE, -3.0f); +} + +void func_80883F98(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + if (Animation_OnFrame(&this->skin.skelAnime, Animation_GetLastFrame(&object_horse_link_child_Anim_00AD08) - 1.0f)) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_LAND2); + } + SkelAnime_Update(&this->skin.skelAnime); +} + +void func_80884010(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + func_80883B70(this, action); + this->unk_3E0 = 5; + this->animationIdx = ENHORSE_ANIM_WALK; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); +} + +void func_808840C4(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + EnHorse_PlayWalkingSound(this); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, this->unk_530); + if (SkelAnime_Update(&this->skin.skelAnime)) { + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + 0.0f); + } +} + +void func_80884194(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + func_80883B70(this, action); + this->unk_3E0 = 6; + this->animationIdx = ENHORSE_ANIM_GALLOP; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); + func_8087C1C0(this); +} + +void func_8088424C(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, this->unk_530); + if (SkelAnime_Update(&this->skin.skelAnime)) { + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + 0.0f); + func_8087C1C0(this); + } +} + +void func_80884314(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 20.0f); + func_80883B70(this, action); + this->unk_3E0 = 7; + Animation_Change(&this->skin.skelAnime, &object_horse_link_child_Anim_00D178, 1.0f, 0.0f, + Animation_GetLastFrame(&object_horse_link_child_Anim_00D178), ANIMMODE_ONCE, 0.0f); + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_NEIGH); +} + +void func_808843B4(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + SkelAnime_Update(&this->skin.skelAnime); + if (this->curFrame > 42.0f) { + if (((s32)this->curFrame % 11) == 0) { + func_8087C1C0(this); + } + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, this->unk_530); + } +} + +void func_80884444(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 20.0f); + func_80883B70(this, action); + this->cutsceneAction = 8; + Animation_Change(&this->skin.skelAnime, &object_horse_link_child_Anim_00D4E8, 1.0f, 0.0f, + Animation_GetLastFrame(&object_horse_link_child_Anim_00D4E8), ANIMMODE_ONCE, 0.0f); + func_8087C1C0(this); +} + +void func_808844E0(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, this->unk_530); + if (SkelAnime_Update(&this->skin.skelAnime)) { + Animation_Change(&this->skin.skelAnime, &object_horse_link_child_Anim_00D4E8, 1.0f, 0.0f, + Animation_GetLastFrame(&object_horse_link_child_Anim_00D4E8), ANIMMODE_ONCE, 0.0f); + func_8087C1C0(this); + } +} + +void func_80884564(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 20.0f); + func_80883B70(this, action); + this->cutsceneAction = 8; + Animation_Change(&this->skin.skelAnime, &object_horse_link_child_Anim_00BDE0, 1.0f, 0.0f, + Animation_GetLastFrame(&object_horse_link_child_Anim_00BDE0), ANIMMODE_ONCE, -3.0f); + func_8087C1C0(this); +} + +void func_80884604(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, this->unk_530); + if (SkelAnime_Update(&this->skin.skelAnime)) { + Animation_Change(&this->skin.skelAnime, &object_horse_link_child_Anim_00BDE0, 1.0f, 0.0f, + Animation_GetLastFrame(&object_horse_link_child_Anim_00BDE0), ANIMMODE_ONCE, 0.0f); + } + + if (((s32)this->curFrame % 11) == 0) { + func_8087C1C0(this); + } +} + +void func_808846B4(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + Actor_MarkForDeath(&this->actor); +} + +void func_808846DC(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { +} + +void func_808846F0(EnHorse* this, GlobalContext* globalCtx) { + this->playerControlled = false; + this->action = ENHORSE_ACT_21; + this->unk_3E0 = -1; + this->actor.speedXZ = 0.0f; +} + +void func_80884718(EnHorse* this, GlobalContext* globalCtx) { + CsCmdActorAction* action; + + if (Cutscene_CheckActorAction(globalCtx, 0x70)) { + this->unk_530 = Cutscene_GetActorActionIndex(globalCtx, 0x70); + action = globalCtx->csCtx.actorActions[this->unk_530]; + + this->unk_1EC |= 0x20; + if (this->unk_3E0 != action->action) { + if (this->unk_3E0 == -1) { + this->actor.world.pos.x = action->startPos.x; + this->actor.world.pos.y = action->startPos.y; + this->actor.world.pos.z = action->startPos.z; + + this->actor.world.rot.y = action->urot.y; + this->actor.shape.rot = this->actor.world.rot; + + this->actor.prevPos = this->actor.world.pos; + } + + this->unk_3E0 = action->action; + if (D_808890F0[this->unk_3E0] != NULL) { + D_808890F0[this->unk_3E0](this, globalCtx, action); + } + } + + if (D_8088911C[this->unk_3E0] != NULL) { + D_8088911C[this->unk_3E0](this, globalCtx, action); + } + } +} + +void func_80884868(EnHorse* this) { + this->action = ENHORSE_ACT_23; + this->animationIdx = ENHORSE_ANIM_WALK; + Animation_PlayLoop(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx]); + this->stateFlags |= ENHORSE_UNRIDEABLE; +} + +void func_808848C8(EnHorse* this, GlobalContext* globalCtx) { + Vec3f sp24 = { -1916.0f, -106.0f, -523.0f }; + + EnHorse_PlayWalkingSound(this); + this->actor.speedXZ = 4.0f; + func_800F415C(&this->actor, &sp24, 2000); + this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.75f; + SkelAnime_Update(&this->skin.skelAnime); + if (Math3D_Distance(&sp24, &this->actor.world.pos) < 30.0f) { + this->stateFlags &= ~ENHORSE_UNRIDEABLE; + EnHorse_StartIdleRidable(this); + } +} + +void func_80884994(EnHorse* this) { + this->unk_534 = -1; + this->animationIdx = ENHORSE_ANIM_TROT; + this->action = ENHORSE_ACT_24; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 2.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); +} + +void func_80884A40(EnHorse* this, GlobalContext* globalCtx) { + s32 sp44[] = { 5, 6, 0 }; + s32 sp40; + s32 temp_v0; + + if (this->animationIdx == ENHORSE_ANIM_WHINNEY) { + temp_v0 = 0; + } else { + temp_v0 = this->animationIdx; + } + + sp40 = sp44[this->unk_538] != temp_v0; + + if (SkelAnime_Update(&this->skin.skelAnime) || sp40) { + this->animationIdx = sp44[this->unk_538]; + if ((this->animationIdx == ENHORSE_ANIM_IDLE) && (Rand_ZeroOne() < 0.5f)) { + this->animationIdx = ENHORSE_ANIM_WHINNEY; + } + + if (sp40) { + if (this->animationIdx == ENHORSE_ANIM_IDLE) { + Animation_MorphToPlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], + -3.0f); + } else { + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 2.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), + ANIMMODE_ONCE, -3.0f); + } + } else if (this->animationIdx == ENHORSE_ANIM_IDLE) { + Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx]); + } else { + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 2.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + 0.0f); + } + + if ((this->unk_538 == 0) || (this->unk_538 == 1)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HORSE_RUN); + } else if (this->unk_538 == 2) { + if (this->animationIdx == ENHORSE_ANIM_IDLE) { + EnHorse_IdleAnimSounds(this, globalCtx); + } else if (this->animationIdx == ENHORSE_ANIM_WHINNEY) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HORSE_GROAN); + } + } + } +} + +void func_80884D04(EnHorse* this, GlobalContext* globalCtx) { + f32 playSpeed; + + this->actor.speedXZ = 10.0f; + this->action = ENHORSE_ACT_25; + this->unk_540 = this->actor.world.pos; + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_INGO_HORSE_NEIGH); + this->animationIdx = ENHORSE_ANIM_GALLOP; + playSpeed = this->actor.speedXZ * 0.2f; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], + sPlaybackSpeeds[this->animationIdx] * playSpeed * 2.5f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, 0.0f); +} + +void func_80884E0C(EnHorse* this, GlobalContext* globalCtx) { + f32 playSpeed = (this->unk_56C * 0.2f * 0.5f) + 1.0f; + Vec3f pos; + CollisionPoly* sp3C; + + this->skin.skelAnime.playSpeed = playSpeed; + + if (SkelAnime_Update(&this->skin.skelAnime)) { + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], + sPlaybackSpeeds[this->animationIdx] * playSpeed * 2.5f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + 0.0f); + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_RUN); + } + + this->unk_57C = this->actor.world.pos; + this->actor.world.pos.x = this->unk_570.x; + this->actor.world.pos.z = this->unk_570.z; + + this->unk_56C = Math3D_Distance(&this->actor.world.pos, &this->actor.prevPos); + if (((this->unk_550 == 5) || (this->unk_550 == 7)) && (Player_GetMask(globalCtx) != PLAYER_MASK_CIRCUS_LEADER)) { + this->rider->unk488 = 7; + } else { + EnHorse_SetIngoAnimation(this->animationIdx, this->skin.skelAnime.curFrame, this->unk_394 & 1, + &this->rider->unk488); + } + + pos = this->actor.world.pos; + pos.y += 10.0f; + + if (BgCheck_EntityRaycastFloor1(&globalCtx->colCtx, &sp3C, &pos) != BGCHECK_Y_MIN) { + this->actor.velocity.y += this->actor.gravity; + if (this->actor.velocity.y < this->actor.terminalVelocity) { + this->actor.velocity.y = this->actor.terminalVelocity; + } + this->actor.world.pos.y += this->actor.velocity.y * 0.5f; + } else { + this->actor.world.pos.y = this->unk_570.y; + } +} + +void EnHorse_Vec3fOffset(Vec3f* src, s16 yaw, f32 dist, f32 height, Vec3f* dst) { + dst->x = (Math_SinS(yaw) * dist) + src->x; + dst->y = src->y + height; + dst->z = (Math_CosS(yaw) * dist) + src->z; +} + +s32 EnHorse_CalcFloorHeight(EnHorse* this, GlobalContext* globalCtx, Vec3f* pos, CollisionPoly** polyFloor, + f32* floorHeight, s32* bgId) { + f32 waterY; + WaterBox* waterbox; + + *polyFloor = NULL; + *floorHeight = BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, polyFloor, bgId, pos); + if (*floorHeight == BGCHECK_Y_MIN) { + return 1; // No floor + } + + if ((WaterBox_GetSurface1_2(globalCtx, &globalCtx->colCtx, pos->x, pos->z, &waterY, &waterbox) == 1) && + (*floorHeight < waterY)) { + return 2; // Water + } + + if ((COLPOLY_GET_NORMAL((*polyFloor)->normal.y) < 0.81915206f) || + SurfaceType_IsHorseBlocked(&globalCtx->colCtx, *polyFloor, *bgId) || + (func_800C99D4(&globalCtx->colCtx, *polyFloor, *bgId) == 7)) { + return 3; // Horse blocked surface + } + + return 0; +} + +/** + * obstacleType: + * 1: Water in front + * 2: Water behind? + * 3: ? + * 4: Obstructed in front + * 5: Obstructed behind + */ +void EnHorse_ObstructMovement(EnHorse* this, GlobalContext* globalCtx, s32 obstacleType, s32 galloping) { + if (this->action != ENHORSE_ACT_HBA) { + if ((this->action == ENHORSE_ACT_MOUNTED_IDLE) || (this->action == ENHORSE_ACT_MOUNTED_IDLE_WHINNEYING)) { + this->actor.world.pos = this->actor.prevPos; + this->actor.world.rot.y -= 0x640; + this->actor.speedXZ = 0.0f; + this->actor.shape.rot.y = this->actor.world.rot.y; + this->unk_1EC |= 4; + } else if (this->action == ENHORSE_ACT_25) { + this->unk_1EC |= 0x80; + this->actor.world.pos = this->actor.prevPos; + this->actor.speedXZ = 0.0f; + } else if ((globalCtx->sceneNum != SCENE_KOEPONARACE) || (this->unk_1EC & 2)) { + this->unk_1EC &= ~2; + this->actor.world.pos = this->lastPos; + this->stateFlags |= ENHORSE_OBSTACLE; + if (this->playerControlled == 0) { + if (this->animationIdx != 3) {} + } else if (this->action != ENHORSE_ACT_REVERSE) { + if (this->stateFlags & ENHORSE_JUMPING) { + this->stateFlags &= ~ENHORSE_JUMPING; + this->actor.gravity = -3.5f; + this->actor.world.pos.y = this->actor.floorHeight; + } + + if ((obstacleType == 1) || (obstacleType == 4)) { + this->stateFlags |= ENHORSE_FORCE_REVERSING; + } else if ((obstacleType == 2) || (obstacleType == 5)) { + this->stateFlags |= ENHORSE_FORCE_WALKING; + } + + if (galloping == true) { + EnHorse_StartRearing(this); + } + } + } + } +} + +void EnHorse_CheckFloors(EnHorse* this, GlobalContext* globalCtx) { + s32 pad; + CollisionPoly* frontFloor; + CollisionPoly* backFloor; + s32 bgId; + s16 floorSlope; + Vec3f frontPos; + Vec3f backPos; + Vec3f pos; + f32 nx; + f32 ny; + f32 nz; + s32 galloping = this->actor.speedXZ > 8.0f; + s32 status; + f32 waterHeight; + WaterBox* waterbox; + f32 dist; + + if ((WaterBox_GetSurface1_2(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &waterHeight, &waterbox) == true) && + (this->actor.floorHeight < waterHeight)) { + EnHorse_ObstructMovement(this, globalCtx, 1, galloping); + return; + } + + if (this->type != HORSE_2) { + EnHorse_Vec3fOffset(&this->actor.world.pos, this->actor.shape.rot.y, 30.0f, 55.0f, &frontPos); + } else { + EnHorse_Vec3fOffset(&this->actor.world.pos, this->actor.shape.rot.y, 15.0f, 30.0f, &frontPos); + } + + status = EnHorse_CalcFloorHeight(this, globalCtx, &frontPos, &frontFloor, &this->yFront, &this->unk_24C); + if (status == 1) { + this->actor.shape.rot.x = 0; + EnHorse_ObstructMovement(this, globalCtx, 4, galloping); + return; + } + + if (status == 3) { + this->unk_1EC |= 2; + EnHorse_ObstructMovement(this, globalCtx, 4, galloping); + return; + } + + if (this->type != HORSE_2) { + EnHorse_Vec3fOffset(&this->actor.world.pos, this->actor.shape.rot.y, -30.0f, 55.0f, &backPos); + } else { + EnHorse_Vec3fOffset(&this->actor.world.pos, this->actor.shape.rot.y, -15.0f, 30.0f, &backPos); + } + + status = EnHorse_CalcFloorHeight(this, globalCtx, &backPos, &backFloor, &this->yBack, &bgId); + if (status == 1) { + this->actor.shape.rot.x = 0; + EnHorse_ObstructMovement(this, globalCtx, 5, galloping); + return; + } + + if (status == 3) { + this->unk_1EC |= 2; + EnHorse_ObstructMovement(this, globalCtx, 5, galloping); + return; + } + + floorSlope = Math_Atan2S(this->yBack - this->yFront, 60.0f); + if (this->actor.floorPoly != NULL) { + nx = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.x); + ny = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.y); + nz = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.z); + + pos = frontPos; + pos.y = this->yFront; + + dist = Math3D_DistPlaneToPos(nx, ny, nz, this->actor.floorPoly->dist, &pos); + if ((frontFloor != this->actor.floorPoly) && (this->actor.speedXZ >= 0.0f) && + ((!(this->stateFlags & ENHORSE_JUMPING) && (dist < -40.0f)) || + ((this->stateFlags & ENHORSE_JUMPING) && (dist < -200.0f)))) { + EnHorse_ObstructMovement(this, globalCtx, 4, galloping); + return; + } + + pos = backPos; + pos.y = this->yBack; + + dist = Math3D_DistPlaneToPos(nx, ny, nz, this->actor.floorPoly->dist, &pos); + if ((backFloor != this->actor.floorPoly) && (this->actor.speedXZ <= 0.0f) && + ((!(this->stateFlags & ENHORSE_JUMPING) && (dist < -40.0f)) || + ((this->stateFlags & ENHORSE_JUMPING) && (dist < -200.0f)))) { + EnHorse_ObstructMovement(this, globalCtx, 5, galloping); + return; + } + + if ((ny < 0.81915206f) || + SurfaceType_IsHorseBlocked(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId) || + (func_800C99D4(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId) == 7)) { + if (this->actor.speedXZ >= 0.0f) { + EnHorse_ObstructMovement(this, globalCtx, 4, galloping); + } else { + EnHorse_ObstructMovement(this, globalCtx, 5, galloping); + } + } else if (this->stateFlags & 4) { + this->actor.shape.rot.x = 0; + } else if ((this->actor.floorHeight + 4.0f) < this->actor.world.pos.y) { + this->actor.shape.rot.x = 0; + } else if (!(fabsf(floorSlope) > 0x1FFF)) { + this->actor.shape.rot.x = floorSlope; + this->actor.shape.yOffset = + ((this->yFront + (((this->yBack - this->yFront) * 20.0f) / 45.0f)) - this->actor.floorHeight) + + this->unk_3E8; + } + } +} + +void EnHorse_MountDismount(EnHorse* this, GlobalContext* globalCtx) { + s32 mountSide = EnHorse_GetMountSide(this, globalCtx); + + if ((mountSide != 0) && !(this->stateFlags & ENHORSE_UNRIDEABLE)) { + Actor_SetRideActor(globalCtx, &this->actor, mountSide); + } + + if ((this->playerControlled == false) && (Actor_HasRider(globalCtx, &this->actor) == true)) { + this->noInputTimer = 26; + this->noInputTimerMax = 26; + this->playerControlled = true; + EnHorse_Freeze(this, globalCtx); + } else if ((this->playerControlled == true) && (Actor_HasNoRider(globalCtx, &this->actor) == true)) { + this->noInputTimer = 35; + this->noInputTimerMax = 35; + this->stateFlags &= ~ENHORSE_UNRIDEABLE; + this->playerControlled = false; + EnHorse_Freeze(this, globalCtx); + } +} + +void EnHorse_StickDirection(Vec2f* curStick, f32* stickMag, s16* angle) { + *stickMag = sqrtf(SQ(curStick->x) + SQ(curStick->z)); + *stickMag = CLAMP_MAX(*stickMag, 60.0f); + *angle = Math_Atan2S(-curStick->x, curStick->z); +} + +void EnHorse_UpdateStick(EnHorse* this, GlobalContext* globalCtx) { + Input* input = &globalCtx->state.input[this->unk_52C]; + + this->lastStick = this->curStick; + this->curStick.x = input->rel.stick_x; + this->curStick.z = input->rel.stick_y; +} + +void EnHorse_ResolveCollision(EnHorse* this, GlobalContext* globalCtx, CollisionPoly* colPoly) { + f32 dist; + f32 nx; + f32 ny; + f32 nz; + f32 offset; + + nx = COLPOLY_GET_NORMAL(colPoly->normal.x); + ny = COLPOLY_GET_NORMAL(colPoly->normal.y); + nz = COLPOLY_GET_NORMAL(colPoly->normal.z); + + if (!(Math_CosS(BINANG_ROT180(this->actor.world.rot.y - Math_Atan2S(colPoly->normal.x, colPoly->normal.z))) < + 0.7071f)) { // cos(45 degrees) + dist = Math3D_DistPlaneToPos(nx, ny, nz, colPoly->dist, &this->actor.world.pos); + offset = (1.0f / sqrtf(SQ(nx) + SQ(nz))); + offset = (30.0f - dist) * offset; + this->actor.world.pos.x += offset * nx; + this->actor.world.pos.z += offset * nz; + } +} + +void EnHorse_BgCheckSlowMoving(EnHorse* this, GlobalContext* globalCtx) { + f32 yOffset = 40.0f; + Vec3f start; + Vec3f end; + Vec3f intersect; + CollisionPoly* colPoly; + s32 bgId; + + Math_Vec3f_Copy(&start, &this->actor.world.pos); + start.y += yOffset; + + Math_Vec3f_Copy(&end, &start); + end.x += 30.0f * Math_SinS(this->actor.world.rot.y); + end.y += 30.0f * Math_SinS(-this->actor.shape.rot.x); + end.z += 30.0f * Math_CosS(this->actor.world.rot.y); + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &start, &end, &intersect, &colPoly, true, false, false, true, + &bgId)) { + EnHorse_ResolveCollision(this, globalCtx, colPoly); + } +} + +void EnHorse_UpdateBgCheckInfo(EnHorse* this, GlobalContext* globalCtx) { + s32 pad2[2]; + Vec3f startPos; + Vec3f endPos; + Vec3f obstaclePos; + f32 temp_f0; + f32 intersectDist; + CollisionPoly* wall = NULL; + CollisionPoly* obstacleFloor = NULL; + s32 bgId; + f32 obstacleHeight; + f32 behindObstacleHeight; + DynaPolyActor* horseJump; + s32 movingFast; + s16 sp7E = 0; + DynaPolyActor* horseGameCheck = NULL; + s32 pad6; + s32 pad; + Vec3f intersect; + Vec3f obstacleTop; + s32 pad5; + s32 pad4; + + if ((this->actor.params != ENHORSE_4) && (this->actor.params != ENHORSE_5) && (this->actor.params != ENHORSE_19) && + (this->actor.params != ENHORSE_20) && (this->actor.params != ENHORSE_18)) { + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 40.0f, 35.0f, 100.0f, 0x1D); + } else { + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 40.0f, 35.0f, 100.0f, 0x1C); + } + + if ((this->actor.bgCheckFlags & 8) && (Math_CosS(this->actor.wallYaw - this->actor.world.rot.y) < -0.3f)) { + if (this->actor.speedXZ > 4.0f) { + this->actor.speedXZ -= 1.0f; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_SANDDUST); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_SANDDUST); + } + } + } + + horseJump = DynaPoly_GetActor(&globalCtx->colCtx, this->actor.floorBgId); + + if (!(this->stateFlags & ENHORSE_JUMPING)) { + if ((horseJump != NULL) && (horseJump->actor.id == ACTOR_EN_HORSE_GAME_CHECK) && + ((horseJump->actor.params & 0xFF) == 5)) { + this->stateFlags |= ENHORSE_FLAG_28; + this->unk_3E8 += ((-10.0f / this->actor.scale.y) - this->unk_3E8) * 0.5f; + if (this->actor.speedXZ > 2.0f) { + this->actor.speedXZ -= 1.0f; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_SANDDUST); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_SANDDUST); + } + } + } else { + this->stateFlags &= ~ENHORSE_FLAG_28; + this->unk_3E8 *= 0.5f; + } + } + + if ((this->stateFlags & ENHORSE_JUMPING) || (this->stateFlags & ENHORSE_FLAG_28) || (this->actor.speedXZ < 0.0f) || + (this->action == ENHORSE_ACT_LOW_JUMP) || (this->action == ENHORSE_ACT_REVERSE)) { + return; + } + + if (this->actor.speedXZ > 8.0f) { + if (this->actor.speedXZ < 12.8f) { + intersectDist = 160.0f; + movingFast = false; + } else { + intersectDist = 230.0f; + movingFast = true; + } + } else { + EnHorse_BgCheckSlowMoving(this, globalCtx); + return; + } + + startPos = this->actor.world.pos; + startPos.y += 19.0f; + + endPos = startPos; + endPos.x += intersectDist * Math_SinS(this->actor.world.rot.y); + endPos.y += intersectDist * Math_SinS(-this->actor.shape.rot.x); + endPos.z += intersectDist * Math_CosS(this->actor.world.rot.y); + + intersect = endPos; + wall = NULL; + + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &startPos, &endPos, &intersect, &wall, true, false, false, true, + &bgId) == true) { + intersectDist = sqrtf(Math3D_Vec3fDistSq(&startPos, &intersect)); + this->stateFlags |= ENHORSE_OBSTACLE; + } + + if (wall != NULL) { + if (intersectDist < 30.0f) { + EnHorse_ResolveCollision(this, globalCtx, wall); + } + + sp7E = BINANG_ROT180(this->actor.world.rot.y - Math_Atan2S(wall->normal.x, wall->normal.z)); + + if ((Math_CosS(sp7E) < 0.5f) || SurfaceType_IsHorseBlocked(&globalCtx->colCtx, wall, bgId)) { + return; + } + + if (((movingFast == false) && (intersectDist < 80.0f)) || ((movingFast == true) && (intersectDist < 150.0f))) { + if ((globalCtx->sceneNum != SCENE_KOEPONARACE) && (Math_CosS(sp7E) < 0.9f) && + (this->playerControlled == true)) { + if (movingFast == false) { + this->stateFlags |= ENHORSE_FORCE_REVERSING; + } else if (movingFast == true) { + this->stateFlags |= ENHORSE_FORCE_REVERSING; + EnHorse_StartBraking(this, globalCtx); + } + } + return; + } + + horseJump = DynaPoly_GetActor(&globalCtx->colCtx, bgId); + if ((this->stateFlags & ENHORSE_FLAG_26) && + (((horseJump != NULL) && (horseJump->actor.id != ACTOR_BG_UMAJUMP)) || (horseJump == NULL))) { + if (this->playerControlled == true) { + if (movingFast == false) { + this->stateFlags |= ENHORSE_FORCE_REVERSING; + } else if (movingFast == true) { + this->stateFlags |= ENHORSE_FORCE_REVERSING; + EnHorse_StartBraking(this, globalCtx); + } + } + return; + } + } + + intersectDist += 5.0f; + obstaclePos = startPos; + + obstaclePos.x += intersectDist * Math_SinS(this->actor.world.rot.y); + obstaclePos.y = this->actor.world.pos.y + 120.0f; + obstaclePos.z += intersectDist * Math_CosS(this->actor.world.rot.y); + + obstacleTop = obstaclePos; + obstacleTop.y = BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, &obstacleFloor, &bgId, &obstaclePos); + + if (obstacleTop.y == BGCHECK_Y_MIN) { + return; + } + + obstacleHeight = obstacleTop.y - this->actor.world.pos.y; + + if ((this->actor.floorPoly == NULL) || (obstacleFloor == NULL)) { + return; + } + + if ((Math3D_DistPlaneToPos(COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.x), + COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.y), + COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.z), this->actor.floorPoly->dist, + &obstacleTop) < -40.0f) && + (Math3D_DistPlaneToPos(COLPOLY_GET_NORMAL(obstacleFloor->normal.x), COLPOLY_GET_NORMAL(obstacleFloor->normal.y), + COLPOLY_GET_NORMAL(obstacleFloor->normal.z), obstacleFloor->dist, + &this->actor.world.pos) > 40.0f)) { + if ((movingFast == true) && (this->playerControlled == true) && (this->action != ENHORSE_ACT_LOW_JUMP) && + (globalCtx->sceneNum != SCENE_KOEPONARACE)) { + this->stateFlags |= ENHORSE_FORCE_REVERSING; + EnHorse_StartBraking(this, globalCtx); + } + this->stateFlags |= ENHORSE_OBSTACLE; + return; + } + + temp_f0 = COLPOLY_GET_NORMAL(obstacleFloor->normal.y); + if ((temp_f0 < 0.81915206f) || SurfaceType_IsHorseBlocked(&globalCtx->colCtx, obstacleFloor, bgId) || + (func_800C99D4(&globalCtx->colCtx, obstacleFloor, bgId) == 7)) { + if ((Math_CosS(sp7E) < 0.9f) && (movingFast == true) && (this->playerControlled == true) && + (this->action != ENHORSE_ACT_LOW_JUMP) && (globalCtx->sceneNum != SCENE_KOEPONARACE)) { + this->stateFlags |= ENHORSE_FORCE_REVERSING; + EnHorse_StartBraking(this, globalCtx); + } + return; + } + + if (wall == NULL) { + horseGameCheck = DynaPoly_GetActor(&globalCtx->colCtx, bgId); + if ((horseGameCheck == NULL) || (horseGameCheck->actor.id != ACTOR_EN_HORSE_GAME_CHECK) || + ((horseGameCheck->actor.params & 0xFF) != 5)) { + return; + } + } + + if (((obstacleTop.y < intersect.y) && + ((horseGameCheck == NULL) || (horseGameCheck->actor.id != ACTOR_EN_HORSE_GAME_CHECK) || + ((horseGameCheck->actor.params & 0xFF) != 5))) || + ((this->stateFlags & ENHORSE_CANT_JUMP) && (this->action != ENHORSE_ACT_MOUNTED_IDLE))) { + return; + } + + if ((this->action == ENHORSE_ACT_MOUNTED_IDLE) && !(this->stateFlags & ENHORSE_FLAG_30)) { + horseGameCheck = DynaPoly_GetActor(&globalCtx->colCtx, bgId); + if ((horseGameCheck != NULL) && (horseGameCheck->actor.id == ACTOR_EN_HORSE_GAME_CHECK) && + ((horseGameCheck->actor.params & 0xFF) == 5)) { + this->stateFlags |= ENHORSE_FLAG_30; + this->postDrawFunc = func_8088126C; + } + } + + if (this->playerControlled == false) { + return; + } + + obstaclePos = startPos; + obstaclePos.y = this->actor.world.pos.y + 120.0f; + + if (movingFast == false) { + obstaclePos.x += 276.0f * Math_SinS(this->actor.world.rot.y); + obstaclePos.z += 276.0f * Math_CosS(this->actor.world.rot.y); + } else { + obstaclePos.x += 390.0f * Math_SinS(this->actor.world.rot.y); + obstaclePos.z += 390.0f * Math_CosS(this->actor.world.rot.y); + } + + obstacleTop = obstaclePos; + obstacleTop.y = BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, &obstacleFloor, &bgId, &obstaclePos); + + if (obstacleTop.y == BGCHECK_Y_MIN) { + return; + } + + behindObstacleHeight = obstacleTop.y - this->actor.world.pos.y; + + if (obstacleFloor == NULL) { + return; + } + + temp_f0 = COLPOLY_GET_NORMAL(obstacleFloor->normal.y); + if ((temp_f0 < 0.81915206f) || SurfaceType_IsHorseBlocked(&globalCtx->colCtx, obstacleFloor, bgId) || + (func_800C99D4(&globalCtx->colCtx, obstacleFloor, bgId) == 7)) { + if ((movingFast == true) && (this->playerControlled == true) && (this->action != ENHORSE_ACT_LOW_JUMP) && + (globalCtx->sceneNum != SCENE_KOEPONARACE)) { + this->stateFlags |= ENHORSE_FORCE_REVERSING; + EnHorse_StartBraking(this, globalCtx); + } + } else if (behindObstacleHeight < -70.0f) { + if ((movingFast == true) && (this->playerControlled == true) && (this->action != ENHORSE_ACT_LOW_JUMP) && + (globalCtx->sceneNum != SCENE_KOEPONARACE)) { + this->stateFlags |= ENHORSE_FORCE_REVERSING; + EnHorse_StartBraking(this, globalCtx); + } + } else { + temp_f0 = (this->actor.scale.y * 100.0f); + + if ((horseGameCheck == NULL) || (horseGameCheck->actor.id != ACTOR_EN_HORSE_GAME_CHECK) || + ((horseGameCheck->actor.params & 0xFF) != 5)) { + if ((movingFast == false) && ((19.0f * temp_f0) < obstacleHeight) && + (obstacleHeight <= (40.0f * temp_f0))) { + EnHorse_Stub1(this); + this->postDrawFunc = EnHorse_LowJumpInit; + } else if ((movingFast == true) && + (((this->actor.speedXZ < 13.8f) && ((19.0f * temp_f0) < obstacleHeight) && + (obstacleHeight <= (72.0f * temp_f0))) || + ((this->actor.speedXZ > 13.8f) && (obstacleHeight <= (112.0f * temp_f0))))) { + EnHorse_Stub2(this); + this->postDrawFunc = EnHorse_HighJumpInit; + } + } else if (movingFast == false) { + EnHorse_Stub1(this); + this->postDrawFunc = EnHorse_LowJumpInit; + } else if (movingFast == true) { + EnHorse_Stub2(this); + this->postDrawFunc = EnHorse_HighJumpInit; + } + } +} + +void func_80886C00(EnHorse* this, GlobalContext* globalCtx) { + Input* input = &globalCtx->state.input[this->unk_52C]; + + if (((this->action == ENHORSE_ACT_MOUNTED_GALLOP) || (this->action == ENHORSE_ACT_MOUNTED_REARING) || + (this->action == ENHORSE_ACT_STOPPING)) && + (CHECK_BTN_ALL(input->press.button, BTN_A) || (func_801A5100() == 5)) && + (globalCtx->interfaceCtx.unk_212 == 8) && !(this->stateFlags & ENHORSE_BOOST) && + !(this->stateFlags & ENHORSE_FLAG_8) && !(this->stateFlags & ENHORSE_FLAG_9)) { + if (this->numBoosts > 0) { + func_8013ECE0(0.0f, 180, 20, 100); + this->stateFlags |= ENHORSE_BOOST; + this->stateFlags |= ENHORSE_FIRST_BOOST_REGEN; + this->stateFlags |= ENHORSE_FLAG_8; + this->numBoosts--; + this->boostTimer = 0; + if (this->numBoosts == 0) { + this->boostRegenTime = 140; + } else if (this->type == HORSE_EPONA) { + if (this->stateFlags & ENHORSE_FIRST_BOOST_REGEN) { + this->boostRegenTime = 60; + this->stateFlags &= ~ENHORSE_FIRST_BOOST_REGEN; + } else { + this->boostRegenTime = 8; + } + } else { + this->boostRegenTime = 70; + } + } else if ((this->stateFlags & ENHORSE_DRAW) && (Rand_ZeroOne() < 0.1f)) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_NEIGH); + } else { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_NEIGH); + } + } + } +} + +void EnHorse_RegenBoost(EnHorse* this, GlobalContext* globalCtx) { + s32 playSfx; + + if ((this->numBoosts < 6) && (this->numBoosts > 0)) { + this->boostRegenTime--; + this->boostTimer++; + if (this->boostRegenTime <= 0) { + this->numBoosts++; + if (((this->action == ENHORSE_ACT_MOUNTED_TURN) || (this->action == ENHORSE_ACT_FROZEN) || + (this->action == ENHORSE_ACT_MOUNTED_WALK)) && + !(this->stateFlags & ENHORSE_FLAG_19) && !(this->stateFlags & ENHORSE_FLAG_25)) { + playSfx = true; + } else { + playSfx = false; + } + + if (!playSfx) { + play_sound(NA_SE_SY_CARROT_RECOVER); + } + + if (this->numBoosts < 6) { + this->boostRegenTime = 11; + } + } + } else if (this->numBoosts == 0) { + this->boostRegenTime--; + this->boostTimer++; + if (this->boostRegenTime <= 0) { + this->boostRegenTime = 0; + this->numBoosts = 6; + if (((this->action == ENHORSE_ACT_MOUNTED_TURN) || (this->action == ENHORSE_ACT_FROZEN) || + (this->action == ENHORSE_ACT_MOUNTED_WALK)) && + !(this->stateFlags & ENHORSE_FLAG_19) && !(this->stateFlags & ENHORSE_FLAG_25)) { + playSfx = true; + } else { + playSfx = false; + } + + if (!playSfx) { + play_sound(NA_SE_SY_CARROT_RECOVER); + } + } + } + + if (this->boostTimer == 8) { + if ((Rand_ZeroOne() < 0.25f) && (this->stateFlags & ENHORSE_DRAW)) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_NEIGH); + } else { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_NEIGH); + } + } + } + + globalCtx->interfaceCtx.numHorseBoosts = this->numBoosts; +} + +void EnHorse_UpdatePlayerDir(EnHorse* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 angle = Actor_YawBetweenActors(&this->actor, &player->actor) - this->actor.world.rot.y; + f32 s = Math_SinS(angle); + f32 c = Math_CosS(angle); + + if (s > 0.8660254f) { // sin(60 degrees) + this->playerDir = PLAYER_DIR_SIDE_L; + } else if (s < -0.8660254f) { // -sin(60 degrees) + this->playerDir = PLAYER_DIR_SIDE_R; + } else if (c > 0.0f) { + if (s > 0.0f) { + this->playerDir = PLAYER_DIR_FRONT_L; + } else { + this->playerDir = PLAYER_DIR_FRONT_R; + } + } else if (s > 0.0f) { + this->playerDir = PLAYER_DIR_BACK_L; + } else { + this->playerDir = PLAYER_DIR_BACK_R; + } +} + +void EnHorse_TiltBody(EnHorse* this, GlobalContext* globalCtx) { + f32 speed; + f32 rollDiff; + s32 targetRoll; + s16 turnVel; + + speed = this->actor.speedXZ / this->boostSpeed; + turnVel = this->actor.shape.rot.y - this->lastYaw; + targetRoll = -((s16)((2730.0f * speed) * (turnVel / 960.00006f))); + rollDiff = targetRoll - this->actor.world.rot.z; + + if (fabsf(targetRoll) < 100.0f) { + this->actor.world.rot.z = 0; + } else if (fabsf(rollDiff) < 100.0f) { + this->actor.world.rot.z = targetRoll; + } else if (rollDiff > 0.0f) { + this->actor.world.rot.z += 0x64; + } else { + this->actor.world.rot.z -= 0x64; + } + + this->actor.shape.rot.z = this->actor.world.rot.z; +} + +s32 EnHorse_UpdateConveyors(EnHorse* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 conveyorDir; + + if ((this->actor.floorPoly == NULL) || (&this->actor != player->rideActor) || + !SurfaceType_GetConveyorSpeed(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId)) { + return false; + } + + conveyorDir = SurfaceType_GetConveyorDirection(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId); + conveyorDir = (conveyorDir * 0x400) - this->actor.world.rot.y; + if (conveyorDir > 0x640) { + this->actor.world.rot.y += 0x640; + } else if (conveyorDir < -0x640) { + this->actor.world.rot.y -= 0x640; + } else { + this->actor.world.rot.y += conveyorDir; + } + this->actor.shape.rot.y = this->actor.world.rot.y; + return true; +} + +s32 EnHorse_RandInt(f32 arg0) { + return Rand_ZeroOne() * arg0; +} + +#ifdef NON_MATCHING +void EnHorse_Update(Actor* thisx, GlobalContext* globalCtx) { + static EnHorseActionFunc sActionFuncs[] = { + EnHorse_Frozen, + EnHorse_Inactive, + EnHorse_Idle, + EnHorse_FollowPlayer, + EnHorse_UpdateIngoRace, + func_808819D8, + func_80881398, + EnHorse_MountedIdle, + EnHorse_MountedIdleWhinneying, + EnHorse_MountedTurn, + EnHorse_MountedWalk, + EnHorse_MountedTrot, + EnHorse_MountedGallop, + EnHorse_MountedRearing, + EnHorse_Stopping, + EnHorse_Reverse, + EnHorse_LowJump, + EnHorse_HighJump, + EnHorse_CutsceneUpdate, + EnHorse_UpdateHorsebackArchery, + EnHorse_FleePlayer, + func_80884718, + func_8087CA04, + func_808848C8, + func_80884A40, + func_80884E0C, + }; + s32 pad; + EnHorse* this = THIS; + Vec3f dustAcc = { 0.0f, 0.0f, 0.0f }; + Vec3f dustVel = { 0.0f, 1.0f, 0.0f }; + Player* player = GET_PLAYER(globalCtx); + + if (this->type == HORSE_2) { + Actor_SetScale(&this->actor, 0.00648f); + } else if (this->type == HORSE_4) { + Actor_SetScale(&this->actor, 0.008f); + } else { + Actor_SetScale(&this->actor, 0.01f); + } + + this->lastYaw = this->actor.shape.rot.y; + EnHorse_UpdateStick(this, globalCtx); + EnHorse_UpdatePlayerDir(this, globalCtx); + + if (!(this->stateFlags & ENHORSE_INACTIVE)) { + EnHorse_MountDismount(this, globalCtx); + } + + if (this->stateFlags & ENHORSE_FLAG_19) { + if ((this->stateFlags & ENHORSE_FLAG_20) && (this->inRace == true)) { + this->stateFlags &= ~ENHORSE_FLAG_20; + EnHorse_StartRearing(this); + } else if (!(this->stateFlags & ENHORSE_FLAG_20) && (this->stateFlags & ENHORSE_FLAG_21) && + (this->action != ENHORSE_ACT_REVERSE) && (this->inRace == true)) { + this->stateFlags &= ~ENHORSE_FLAG_21; + EnHorse_StartRearing(this); + } + } + + sActionFuncs[this->action](this, globalCtx); + + this->stateFlags &= ~ENHORSE_OBSTACLE; + this->unk_3EC = this->actor.world.rot.y; + if ((this->animationIdx == ENHORSE_ANIM_STOPPING) || (this->animationIdx == ENHORSE_ANIM_REARING)) { + this->skin.skelAnime.jointTable[0].y += 0x154; + } + + this->curFrame = this->skin.skelAnime.curFrame; + this->lastPos = this->actor.world.pos; + + if (!(this->stateFlags & ENHORSE_INACTIVE)) { + if ((this->action == ENHORSE_ACT_STOPPING) || (this->action == ENHORSE_ACT_MOUNTED_REARING) || + (this->action == ENHORSE_ACT_MOUNTED_GALLOP)) { + func_80886C00(this, globalCtx); + } + + if (this->playerControlled == true) { + EnHorse_RegenBoost(this, globalCtx); + } + + if (ActorCutscene_GetCurrentIndex() != -1) { + this->actor.speedXZ = 0.0f; + } + + if (this->action != ENHORSE_ACT_25) { + Actor_MoveWithGravity(&this->actor); + } + + if (this->rider != NULL) { + if ((this->action == ENHORSE_ACT_INGO_RACE) || (this->action == ENHORSE_ACT_MOUNTED_IDLE) || + (this->action == ENHORSE_ACT_25)) { + this->rider->actor.world.pos.x = this->actor.world.pos.x; + this->rider->actor.world.pos.y = this->actor.world.pos.y + 10.0f; + this->rider->actor.world.pos.z = this->actor.world.pos.z; + this->rider->actor.shape.rot.x = this->actor.shape.rot.x; + this->rider->actor.shape.rot.y = this->actor.shape.rot.y; + } else if (this->action == ENHORSE_ACT_MOUNTED_IDLE_WHINNEYING) { + EnIn* in = this->rider; + s16 jnt = in->jointTable[0].y; + + in->actor.world.pos.x = this->riderPos.x; + in->actor.world.pos.y = this->riderPos.y - (jnt * 0.01f * this->unk_528 * 0.01f); + in->actor.world.pos.z = this->riderPos.z; + in->actor.shape.rot.x = this->actor.shape.rot.x; + in->actor.shape.rot.y = this->actor.shape.rot.y; + } + } + + if (this->colliderJntSph.elements->info.ocElemFlags & OCELEM_HIT) { + if (this->actor.speedXZ > 10.0f) { + this->actor.speedXZ -= 1.0f; + } + } + + if ((this->colliderJntSph.base.acFlags & AC_HIT) && (this->stateFlags & ENHORSE_DRAW)) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_NEIGH); + } else { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_NEIGH); + } + } + + if ((this->action != ENHORSE_ACT_INGO_RACE) && (this->action != ENHORSE_ACT_MOUNTED_IDLE) && + (this->action != ENHORSE_ACT_MOUNTED_IDLE_WHINNEYING)) { + EnHorse_TiltBody(this, globalCtx); + } + + if ((this->playerControlled == false) && (this->unk_1EC & 8)) { + if ((this->colliderJntSph.elements->info.ocElemFlags & OCELEM_HIT) && + (this->colliderJntSph.base.oc->id == ACTOR_EN_IN)) { + func_80884868(this); + } + + if ((this->colliderCylinder1.base.ocFlags1 & OC1_HIT) && + (this->colliderCylinder1.base.oc->id == ACTOR_EN_IN)) { + func_80884868(this); + } + + if ((this->colliderCylinder2.base.ocFlags1 & OC1_HIT) && + (this->colliderCylinder2.base.oc->id == ACTOR_EN_IN)) { + func_80884868(this); + } + } + + Collider_UpdateCylinder(&this->actor, &this->colliderCylinder1); + Collider_UpdateCylinder(&this->actor, &this->colliderCylinder2); + + if (this->type == HORSE_2) { + this->colliderCylinder1.dim.pos.x = + (s16)(Math_SinS(this->actor.shape.rot.y) * 11.0f) + this->colliderCylinder1.dim.pos.x; + this->colliderCylinder1.dim.pos.z = + (s16)(Math_CosS(this->actor.shape.rot.y) * 11.0f) + this->colliderCylinder1.dim.pos.z; + this->colliderCylinder2.dim.pos.x = + (s16)(Math_SinS(this->actor.shape.rot.y) * -18.0f) + this->colliderCylinder2.dim.pos.x; + this->colliderCylinder2.dim.pos.z = + (s16)(Math_CosS(this->actor.shape.rot.y) * -18.0f) + this->colliderCylinder2.dim.pos.z; + } else { + this->colliderCylinder1.dim.pos.x = + (s16)(Math_SinS(this->actor.shape.rot.y) * 6.6000004f) + this->colliderCylinder1.dim.pos.x; + this->colliderCylinder1.dim.pos.z = + (s16)(Math_CosS(this->actor.shape.rot.y) * 6.6000004f) + this->colliderCylinder1.dim.pos.z; + this->colliderCylinder2.dim.pos.x = + (s16)(Math_SinS(this->actor.shape.rot.y) * -10.8f) + this->colliderCylinder2.dim.pos.x; + this->colliderCylinder2.dim.pos.z = + (s16)(Math_CosS(this->actor.shape.rot.y) * -10.8f) + this->colliderCylinder2.dim.pos.z; + } + + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder1.base); + if (!(this->stateFlags & ENHORSE_JUMPING) && !(this->unk_1EC & 0x20)) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder1.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder2.base); + } else { + this->unk_1EC &= ~0x20; + } + + if (this->unk_1EC & 0x100) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder1.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder2.base); + } + + if ((player->stateFlags1 & ENHORSE_BOOST) && (player->rideActor != NULL)) { + EnHorse_UpdateConveyors(this, globalCtx); + } + + EnHorse_UpdateBgCheckInfo(this, globalCtx); + EnHorse_CheckFloors(this, globalCtx); + if (this->actor.world.pos.y < this->yFront) { + if (this->actor.world.pos.y < this->yBack) { + if (this->yBack < this->yFront) { + this->actor.world.pos.y = this->yBack; + } else { + this->actor.world.pos.y = this->yFront; + } + } + } + + this->actor.focus.pos = this->actor.world.pos; + this->actor.focus.pos.y += 70.0f; + + if ((Rand_ZeroOne() < 0.025f) && (this->blinkTimer == 0)) { + this->blinkTimer++; + } else if (this->blinkTimer > 0) { + this->blinkTimer++; + if (this->blinkTimer > 3) { + this->blinkTimer = 0; + } + } + + if ((this->actor.speedXZ == 0.0f) && !(this->stateFlags & ENHORSE_FLAG_19)) { + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + } else { + this->actor.colChkInfo.mass = MASS_HEAVY; + } + + if (this->actor.speedXZ >= 5.0f) { + this->colliderCylinder1.base.atFlags |= AT_ON; + } else { + this->colliderCylinder1.base.atFlags &= ~AT_ON; + } + + if (this->dustFlags & 1) { + this->dustFlags &= ~1; + func_800B12F0(globalCtx, &this->frontRightHoof, &dustVel, &dustAcc, EnHorse_RandInt(100.0f) + 200, + EnHorse_RandInt(10.0f) + 30, EnHorse_RandInt(20.0f) + 30); + } else if (this->dustFlags & 2) { + this->dustFlags &= ~2; + func_800B12F0(globalCtx, &this->frontLeftHoof, &dustVel, &dustAcc, EnHorse_RandInt(100.0f) + 200, + EnHorse_RandInt(10.0f) + 30, EnHorse_RandInt(20.0f) + 30); + } else if (this->dustFlags & 4) { + this->dustFlags &= ~4; + func_800B12F0(globalCtx, &this->backRightHoof, &dustVel, &dustAcc, EnHorse_RandInt(100.0f) + 200, + EnHorse_RandInt(10.0f) + 30, EnHorse_RandInt(20.0f) + 30); + } else if (this->dustFlags & 8) { + this->dustFlags &= ~8; + func_800B12F0(globalCtx, &this->backLeftHoof, &dustVel, &dustAcc, EnHorse_RandInt(100.0f) + 200, + EnHorse_RandInt(10.0f) + 30, EnHorse_RandInt(20.0f) + 30); + } + this->stateFlags &= ~ENHORSE_DRAW; + } +} +#else +EnHorseActionFunc sActionFuncs[] = { + EnHorse_Frozen, + EnHorse_Inactive, + EnHorse_Idle, + EnHorse_FollowPlayer, + EnHorse_UpdateIngoRace, + func_808819D8, + func_80881398, + EnHorse_MountedIdle, + EnHorse_MountedIdleWhinneying, + EnHorse_MountedTurn, + EnHorse_MountedWalk, + EnHorse_MountedTrot, + EnHorse_MountedGallop, + EnHorse_MountedRearing, + EnHorse_Stopping, + EnHorse_Reverse, + EnHorse_LowJump, + EnHorse_HighJump, + EnHorse_CutsceneUpdate, + EnHorse_UpdateHorsebackArchery, + EnHorse_FleePlayer, + func_80884718, + func_8087CA04, + func_808848C8, + func_80884A40, + func_80884E0C, +}; +Vec3f D_808891C8 = { 0.0f, 0.0f, 0.0f }; +Vec3f D_808891D4 = { 0.0f, 1.0f, 0.0f }; #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/EnHorse_Update.s") +#endif -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80887D20.s") +s32 EnHorse_PlayerDirToMountSide(EnHorse* this, GlobalContext* globalCtx, Player* player) { + if (this->playerDir == PLAYER_DIR_SIDE_L) { + return -1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80887D60.s") + if (this->playerDir == PLAYER_DIR_SIDE_R) { + return 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80887E64.s") + return 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80887EBC.s") +s32 EnHorse_MountSideCheck(EnHorse* this, GlobalContext* globalCtx, Player* player) { + s32 mountSide; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80887F58.s") + if (Actor_XZDistanceBetweenActors(&this->actor, &player->actor) > 75.0f) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80888C48.s") + if (fabsf(this->actor.world.pos.y - player->actor.world.pos.y) > 30.0f) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80888D18.s") + if (Math_CosS(Actor_YawBetweenActors(&player->actor, &this->actor) - player->actor.world.rot.y) < + 0.17364818f) { // cos(80 degrees) + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/EnHorse_Draw.s") + mountSide = EnHorse_PlayerDirToMountSide(this, globalCtx, player); + if (mountSide == -1) { + return -1; + } + + if (mountSide == 1) { + return 1; + } + + return 0; +} + +s32 EnHorse_GetMountSide(EnHorse* this, GlobalContext* globalCtx) { + if (this->action != ENHORSE_ACT_IDLE) { + return 0; + } + + if ((this->animationIdx != ENHORSE_ANIM_IDLE) && (this->animationIdx != ENHORSE_ANIM_WHINNEY)) { + return 0; + } + + return EnHorse_MountSideCheck(this, globalCtx, GET_PLAYER(globalCtx)); +} + +void EnHorse_RandomOffset(Vec3f* src, f32 dist, Vec3f* dst) { + dst->x = ((Rand_ZeroOne() * (2.0f * dist)) + src->x) - dist; + dst->y = ((Rand_ZeroOne() * (2.0f * dist)) + src->y) - dist; + dst->z = ((Rand_ZeroOne() * (2.0f * dist)) + src->z) - dist; +} + +void EnHorse_PostDraw(Actor* thisx, GlobalContext* globalCtx, Skin* skin) { + s32 pad; + EnHorse* this = THIS; + Vec3f sp7C = { 0.0f, 0.0f, 0.0f }; + Vec3f hoofOffset = { 5.0f, -4.0f, 5.0f }; + Vec3f sp64; + f32 curFrame = this->skin.skelAnime.curFrame; + Vec3f center; + Vec3f newCenter; + s32 i; + Vec3f sp38; + f32 sp34; + + if (!(this->stateFlags & ENHORSE_CALC_RIDER_POS)) { + if (this->type == HORSE_2) { + Skin_GetVertexPos(skin, 5, 120, &this->riderPos); + this->riderPos.y += 13.0f; + } else { + Vec3f riderOffset = { 600.0f, -1670.0f, 0.0f }; + + Skin_GetLimbPos(skin, 30, &riderOffset, &this->riderPos); + } + this->riderPos.x -= this->actor.world.pos.x; + this->riderPos.y -= this->actor.world.pos.y; + this->riderPos.z -= this->actor.world.pos.z; + } else { + this->stateFlags &= ~ENHORSE_CALC_RIDER_POS; + } + + if (this->type == HORSE_2) { + Skin_GetLimbPos(skin, 13, &sp7C, &sp38); + } else { + Skin_GetLimbPos(skin, 13, &sp7C, &sp38); + } + + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &sp38, &this->unk_218, &sp34); + + if ((this->animationIdx == ENHORSE_ANIM_IDLE) && (this->action != ENHORSE_ACT_FROZEN) && + (((curFrame > 40.0f) && (curFrame < 45.0f) && (this->type == 0)) || + ((curFrame > 28.0f) && (curFrame < 33.0f) && (this->type == 1)))) { + if (Rand_ZeroOne() < 0.02f) { + this->dustFlags |= 1; + Skin_GetLimbPos(skin, 28, &hoofOffset, &this->frontRightHoof); + this->frontRightHoof.y -= 5.0f; + } + } else { + if (this->action == ENHORSE_ACT_LOW_JUMP) { + if (((curFrame > 10.0f) && (curFrame < 13.0f)) || ((curFrame > 25.0f) && (curFrame < 33.0f))) { + if (Rand_ZeroOne() < 0.02f) { + this->dustFlags |= 2; + if (this->type == HORSE_2) { + Skin_GetLimbPos(skin, 20, &hoofOffset, &sp64); + } else { + Skin_GetLimbPos(skin, 20, &hoofOffset, &sp64); + } + EnHorse_RandomOffset(&sp64, 10.0f, &this->frontLeftHoof); + } + + if (Rand_ZeroOne() < 0.02f) { + this->dustFlags |= 1; + if (this->type == HORSE_2) { + Skin_GetLimbPos(skin, 28, &hoofOffset, &sp64); + } else { + Skin_GetLimbPos(skin, 28, &hoofOffset, &sp64); + } + EnHorse_RandomOffset(&sp64, 10.0f, &this->frontRightHoof); + } + } + + if (((curFrame > 6.0f) && (curFrame < 10.0f)) || ((curFrame > 23.0f) && (curFrame < 29.0f))) { + if (Rand_ZeroOne() < 0.02f) { + this->dustFlags |= 8; + if (this->type == HORSE_2) { + Skin_GetLimbPos(skin, 36, &hoofOffset, &sp64); + } else { + Skin_GetLimbPos(skin, 37, &hoofOffset, &sp64); + } + EnHorse_RandomOffset(&sp64, 10.0f, &this->backLeftHoof); + } + } + + if ((((curFrame > 7.0f) && (curFrame < 14.0f)) || ((curFrame > 26.0f) && (curFrame < 30.0f))) && + (Rand_ZeroOne() < 0.02f)) { + this->dustFlags |= 4; + if (this->type == HORSE_2) { + Skin_GetLimbPos(skin, 44, &hoofOffset, &sp64); + } else { + Skin_GetLimbPos(skin, 45, &hoofOffset, &sp64); + } + EnHorse_RandomOffset(&sp64, 10.0f, &this->backRightHoof); + } + } else if (this->animationIdx == ENHORSE_ANIM_GALLOP) { + if ((curFrame > 14.0f) && (curFrame < 16.0f) && (Rand_ZeroOne() < 0.02f)) { + this->dustFlags |= 1; + if (this->type == HORSE_2) { + Skin_GetLimbPos(skin, 28, &hoofOffset, &sp64); + } else { + Skin_GetLimbPos(skin, 28, &hoofOffset, &sp64); + } + EnHorse_RandomOffset(&sp64, 5.0f, &this->frontRightHoof); + } else if ((curFrame > 8.0f) && (curFrame < 10.0f) && (Rand_ZeroOne() < 0.02f)) { + this->dustFlags |= 2; + if (this->type == HORSE_2) { + Skin_GetLimbPos(skin, 20, &hoofOffset, &sp64); + } else { + Skin_GetLimbPos(skin, 20, &hoofOffset, &sp64); + } + EnHorse_RandomOffset(&sp64, 10.0f, &this->frontLeftHoof); + } else if ((curFrame > 1.0f) && (curFrame < 3.0f) && (Rand_ZeroOne() < 0.02f)) { + this->dustFlags |= 4; + if (this->type == HORSE_2) { + Skin_GetLimbPos(skin, 44, &hoofOffset, &sp64); + } else { + Skin_GetLimbPos(skin, 45, &hoofOffset, &sp64); + } + EnHorse_RandomOffset(&sp64, 10.0f, &this->backRightHoof); + } else if ((curFrame > 26.0f) && (curFrame < 28.0f) && (Rand_ZeroOne() < 0.02f)) { + this->dustFlags |= 8; + if (this->type == HORSE_2) { + Skin_GetLimbPos(skin, 36, &hoofOffset, &sp64); + } else { + Skin_GetLimbPos(skin, 37, &hoofOffset, &sp64); + } + EnHorse_RandomOffset(&sp64, 10.0f, &this->backLeftHoof); + } + } else if ((this->action == ENHORSE_ACT_BRIDGE_JUMP) && (curFrame > 6.0f) && + (Rand_ZeroOne() < (1.0f - ((curFrame - 6.0f) * (1.0f / 17.0f))))) { + if (Rand_ZeroOne() < 0.05f) { + this->dustFlags |= 8; + if (this->type == HORSE_2) { + Skin_GetLimbPos(skin, 36, &hoofOffset, &sp64); + } else { + Skin_GetLimbPos(skin, 37, &hoofOffset, &sp64); + } + EnHorse_RandomOffset(&sp64, 10.0f, &this->backLeftHoof); + } + if (Rand_ZeroOne() < 0.02f) { + this->dustFlags |= 4; + if (this->type == HORSE_2) { + Skin_GetLimbPos(skin, 44, &hoofOffset, &sp64); + } else { + Skin_GetLimbPos(skin, 45, &hoofOffset, &sp64); + } + EnHorse_RandomOffset(&sp64, 10.0f, &this->backRightHoof); + } + } else if ((this->action == ENHORSE_ACT_CS_UPDATE) && (curFrame > 5.0f)) { + if (Rand_ZeroOne() < (1.0f - ((curFrame - 5.0f) * 0.04f))) { + if (Rand_ZeroOne() < 0.05f) { + this->dustFlags |= 8; + if (this->type == HORSE_2) { + Skin_GetLimbPos(skin, 36, &hoofOffset, &sp64); + } else { + Skin_GetLimbPos(skin, 37, &hoofOffset, &sp64); + } + EnHorse_RandomOffset(&sp64, 10.0f, &this->backLeftHoof); + } + + if (Rand_ZeroOne() < 0.02f) { + this->dustFlags |= 4; + if (this->type == HORSE_2) { + Skin_GetLimbPos(skin, 44, &hoofOffset, &sp64); + } else { + Skin_GetLimbPos(skin, 45, &hoofOffset, &sp64); + } + EnHorse_RandomOffset(&sp64, 10.0f, &this->backRightHoof); + } + } + } + } + + for (i = 0; i < this->colliderJntSph.count; i++) { + center.x = this->colliderJntSph.elements[i].dim.modelSphere.center.x; + center.y = this->colliderJntSph.elements[i].dim.modelSphere.center.y; + center.z = this->colliderJntSph.elements[i].dim.modelSphere.center.z; + + Skin_GetLimbPos(skin, this->colliderJntSph.elements[i].dim.limb, ¢er, &newCenter); + + this->colliderJntSph.elements[i].dim.worldSphere.center.x = newCenter.x; + this->colliderJntSph.elements[i].dim.worldSphere.center.y = newCenter.y; + this->colliderJntSph.elements[i].dim.worldSphere.center.z = newCenter.z; + + this->colliderJntSph.elements[i].dim.worldSphere.radius = + this->colliderJntSph.elements[i].dim.modelSphere.radius * this->colliderJntSph.elements[i].dim.scale; + } + + //! @bug Setting colliders in a draw function allows for duplicate entries to be added to their respective lists + //! under certain conditions, like when pausing and unpausing the game. + //! Actors will draw for a couple of frames between the pauses, but some important logic updates will not occur. + //! In the case of OC, this can cause unwanted effects such as a very large amount of displacement being applied to + //! a colliding actor. + if (!(this->stateFlags & ENHORSE_JUMPING)) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderJntSph.base); + } +} + +s32 EnHorse_OverrideLimbDraw(Actor* thisx, GlobalContext* globalCtx, s32 limbIndex, Skin* skin) { + static TexturePtr D_80889204[] = { + object_horse_link_child_Tex_001D28, + object_horse_link_child_Tex_001928, + object_horse_link_child_Tex_001B28, + }; + static u8 D_80889210[] = { 0, 1, 2, 1 }; + EnHorse* this = THIS; + s32 drawOriginalLimb = true; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if ((limbIndex != 13) || (this->type != HORSE_EPONA)) { + if ((limbIndex == 13) && (this->type == HORSE_2)) { + u8 idx = D_80889210[this->blinkTimer]; + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80889204[idx])); + } else if ((this->type == HORSE_HNI) && (this->stateFlags & ENHORSE_FLAG_18) && (limbIndex == 30)) { + drawOriginalLimb = false; + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + return drawOriginalLimb; +} + +s32 func_80888D18(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + Vec3f sp1C = { -98.0f, -1454.0f, 0.0f }; + EnHorse* this = THIS; + + if (limbIndex == 3) { + Matrix_MultiplyVector3fByState(&sp1C, &this->riderPos); + } + return false; +} + +void EnHorse_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnHorse* this = THIS; + + if (!(this->stateFlags & ENHORSE_INACTIVE) && (this->actor.update != func_8087D540)) { + func_8012C28C(globalCtx->state.gfxCtx); + this->stateFlags |= ENHORSE_DRAW; + if (!(this->unk_1EC & 1)) { + if (this->stateFlags & ENHORSE_JUMPING) { + func_80138258(&this->actor, globalCtx, &this->skin, EnHorse_PostDraw, EnHorse_OverrideLimbDraw, false); + } else { + func_80138258(&this->actor, globalCtx, &this->skin, EnHorse_PostDraw, EnHorse_OverrideLimbDraw, true); + } + } else { + if (this->stateFlags & ENHORSE_JUMPING) { + this->skin.skelAnime.jointTable->x = 0; + this->skin.skelAnime.jointTable->y = 0; + this->skin.skelAnime.jointTable->z = 0; + } + SkelAnime_DrawFlexOpa(globalCtx, this->skin.skelAnime.skeleton, this->skin.skelAnime.jointTable, + this->skin.skelAnime.dListCount, func_80888D18, NULL, &this->actor); + } + + if (this->postDrawFunc != NULL) { + this->postDrawFunc(this, globalCtx); + } + } +} diff --git a/src/overlays/actors/ovl_En_Horse/z_en_horse.h b/src/overlays/actors/ovl_En_Horse/z_en_horse.h index 787fd8b579..2dc5e44f51 100644 --- a/src/overlays/actors/ovl_En_Horse/z_en_horse.h +++ b/src/overlays/actors/ovl_En_Horse/z_en_horse.h @@ -2,16 +2,218 @@ #define Z_EN_HORSE_H #include "global.h" +#include "z64skin.h" +#include "overlays/actors/ovl_En_In/z_en_in.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_ha/object_ha.h" struct EnHorse; +typedef void (*EnHorseActionFunc)(struct EnHorse*, GlobalContext*); +typedef void (*EnHorsePostdrawFunc)(struct EnHorse*, GlobalContext*); +typedef void (*EnHorseCsFunc)(struct EnHorse*, GlobalContext*, CsCmdActorAction*); + +#define ENHORSE_BOOST (1 << 0) /* 0x1 */ +#define ENHORSE_BOOST_DECEL (1 << 1) /* 0x2 */ +#define ENHORSE_JUMPING (1 << 2) /* 0x4 */ +#define ENHORSE_CALC_RIDER_POS (1 << 3) /* 0x8 */ +#define ENHORSE_FORCE_REVERSING (1 << 4) /* 0x10 */ +#define ENHORSE_FORCE_WALKING (1 << 5) /* 0x20 */ +#define ENHORSE_FLAG_6 (1 << 6) /* 0x40 */ +#define ENHORSE_FLAG_7 (1 << 7) /* 0x80 */ +#define ENHORSE_FLAG_8 (1 << 8) /* 0x100 */ +#define ENHORSE_FLAG_9 (1 << 9) /* 0x200 */ +#define ENHORSE_STOPPING_NEIGH_SOUND (1 << 10) /* 0x400 */ +#define ENHORSE_LAND2_SOUND (1 << 11) /* 0x800 */ +#define ENHORSE_SANDDUST_SOUND (1 << 12) /* 0x1000 */ +#define ENHORSE_INACTIVE (1 << 13) /* 0x2000 */ +#define ENHORSE_OBSTACLE (1 << 14) /* 0x4000 */ +#define ENHORSE_TURNING_TO_PLAYER (1 << 15) /* 0x8000 */ +#define ENHORSE_UNRIDEABLE (1 << 16) /* 0x10000 */ +#define ENHORSE_CANT_JUMP (1 << 17) /* 0x20000 */ +#define ENHORSE_FLAG_18 (1 << 18) /* 0x40000 */ +#define ENHORSE_FLAG_19 (1 << 19) /* 0x80000 */ +#define ENHORSE_FLAG_20 (1 << 20) /* 0x100000 */ +#define ENHORSE_FLAG_21 (1 << 21) /* 0x200000 */ +#define ENHORSE_FIRST_BOOST_REGEN (1 << 22) /* 0x400000 */ +#define ENHORSE_INGO_WON (1 << 23) /* 0x800000 */ +#define ENHORSE_FLAG_24 (1 << 24) /* 0x1000000 */ +#define ENHORSE_FLAG_25 (1 << 25) /* 0x2000000 */ +#define ENHORSE_FLAG_26 (1 << 26) /* 0x4000000 */ +#define ENHORSE_DRAW (1 << 27) /* 0x8000000 */ +#define ENHORSE_FLAG_28 (1 << 28) /* 0x10000000 */ +#define ENHORSE_FLAG_29 (1 << 29) /* 0x20000000 */ +#define ENHORSE_FLAG_30 (1 << 30) /* 0x40000000 */ +#define ENHORSE_FLAG_31 (1 << 31) /* 0x80000000 */ + +typedef enum { + /* 0 */ ENHORSE_ACT_FROZEN, + /* 1 */ ENHORSE_ACT_INACTIVE, + /* 2 */ ENHORSE_ACT_IDLE, + /* 3 */ ENHORSE_ACT_FOLLOW_PLAYER, + /* 4 */ ENHORSE_ACT_INGO_RACE, + /* 5 */ ENHORSE_ACT_MOUNTED_IDLE, + /* 6 */ ENHORSE_ACT_MOUNTED_IDLE_WHINNEYING, + /* 7 */ ENHORSE_ACT_MOUNTED_TURN, + /* 8 */ ENHORSE_ACT_MOUNTED_WALK, + /* 9 */ ENHORSE_ACT_MOUNTED_TROT, + /* 10 */ ENHORSE_ACT_MOUNTED_GALLOP, + /* 11 */ ENHORSE_ACT_MOUNTED_REARING, + /* 12 */ ENHORSE_ACT_STOPPING, + /* 13 */ ENHORSE_ACT_REVERSE, + /* 14 */ ENHORSE_ACT_LOW_JUMP, + /* 15 */ ENHORSE_ACT_HIGH_JUMP, + /* 16 */ ENHORSE_ACT_BRIDGE_JUMP, + /* 17 */ ENHORSE_ACT_CS_UPDATE, + /* 18 */ ENHORSE_ACT_HBA, + /* 19 */ ENHORSE_ACT_FLEE_PLAYER, + /* 20 */ ENHORSE_ACT_20, + /* 21 */ ENHORSE_ACT_21, + /* 22 */ ENHORSE_ACT_22, + /* 23 */ ENHORSE_ACT_23, + /* 24 */ ENHORSE_ACT_24, + /* 25 */ ENHORSE_ACT_25, +} EnHorseAction; + +typedef enum { + /* 0 */ PLAYER_DIR_FRONT_R, + /* 1 */ PLAYER_DIR_FRONT_L, + /* 2 */ PLAYER_DIR_BACK_R, + /* 3 */ PLAYER_DIR_BACK_L, + /* 4 */ PLAYER_DIR_SIDE_R, + /* 5 */ PLAYER_DIR_SIDE_L +} EnHorsePlayerDir; + +typedef enum { + /* 0 */ ENHORSE_ANIM_IDLE, + /* 1 */ ENHORSE_ANIM_WHINNEY, + /* 2 */ ENHORSE_ANIM_STOPPING, + /* 3 */ ENHORSE_ANIM_REARING, + /* 4 */ ENHORSE_ANIM_WALK, + /* 5 */ ENHORSE_ANIM_TROT, + /* 6 */ ENHORSE_ANIM_GALLOP, + /* 7 */ ENHORSE_ANIM_LOW_JUMP, + /* 8 */ ENHORSE_ANIM_HIGH_JUMP +} EnHorseAnimationIndex; + +typedef enum { + /* 0 */ HORSE_EPONA, + /* 1 */ HORSE_HNI, + /* 2 */ HORSE_2, + /* 3 */ HORSE_3, + /* 4 */ HORSE_4 +} HorseType; + +#define ENHORSE_GET_2000(thisx) ((thisx)->params & 0x2000) +#define ENHORSE_GET_4000(thisx) ((thisx)->params & 0x4000) +#define ENHORSE_GET_8000(thisx) ((thisx)->params & 0x8000) + +enum { + /* 0 */ ENHORSE_0, + /* 1 */ ENHORSE_1, + /* 2 */ ENHORSE_2, + /* 3 */ ENHORSE_3, + /* 4 */ ENHORSE_4, + /* 5 */ ENHORSE_5, + /* 6 */ ENHORSE_6, + /* 7 */ ENHORSE_7, + /* 8 */ ENHORSE_8, + /* 9 */ ENHORSE_9, + /* 10 */ ENHORSE_10, + /* 11 */ ENHORSE_11, + /* 12 */ ENHORSE_12, + /* 13 */ ENHORSE_13, + /* 14 */ ENHORSE_14, + /* 15 */ ENHORSE_15, + /* 16 */ ENHORSE_16, + /* 17 */ ENHORSE_17, + /* 18 */ ENHORSE_18, + /* 19 */ ENHORSE_19, + /* 20 */ ENHORSE_20, +}; + typedef struct EnHorse { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0xC]; - /* 0x150 */ s32 unk_150; - /* 0x154 */ char unk_154[0x98]; - /* 0x1EC */ UNK_TYPE4 unk_1EC; - /* 0x1F0 */ char unk_1F0[0x3A4]; + /* 0x144 */ s32 action; + /* 0x148 */ s32 noInputTimer; + /* 0x14C */ s32 noInputTimerMax; + /* 0x150 */ s32 type; + /* 0x154 */ s8 bankIndex; + /* 0x158 */ Skin skin; + /* 0x1E8 */ s32 stateFlags; + /* 0x1EC */ s32 unk_1EC; + /* 0x1F0 */ Vec3f lastPos; + /* 0x1FC */ s16 lastYaw; + /* 0x200 */ s32 curRaceWaypoint; + /* 0x204 */ s32 boostSpeed; + /* 0x208 */ s32 playerControlled; + /* 0x20C */ s32 animationIdx; + /* 0x210 */ f32 curFrame; + /* 0x214 */ s32 soundTimer; + /* 0x218 */ Vec3f unk_218; + /* 0x224 */ UNK_TYPE1 unk224[0xC]; + /* 0x230 */ s32 unk_230; + /* 0x234 */ u8 numBoosts; + /* 0x238 */ s32 boostRegenTime; + /* 0x23C */ s32 boostTimer; + /* 0x240 */ EnHorsePostdrawFunc postDrawFunc; + /* 0x244 */ f32 yFront; + /* 0x248 */ f32 yBack; + /* 0x24C */ s32 unk_24C; + /* 0x250 */ s16 followTimer; + /* 0x254 */ s32 prevAction; + /* 0x258 */ Vec3f riderPos; + /* 0x264 */ Vec2f curStick; + /* 0x26C */ Vec2f lastStick; + /* 0x274 */ f32 jumpStartY; + /* 0x278 */ ColliderCylinder colliderCylinder1; + /* 0x2C4 */ ColliderCylinder colliderCylinder2; + /* 0x310 */ ColliderJntSph colliderJntSph; + /* 0x330 */ ColliderJntSphElement colliderJntSphElements[1]; + /* 0x370 */ s32 playerDir; + /* 0x374 */ UNK_TYPE1 unk374[0x2]; + /* 0x376 */ s16 angleToPlayer; + /* 0x378 */ s16 followPlayerTurnSpeed; + /* 0x37A */ u8 blinkTimer; + /* 0x37C */ s16 waitTimer; + /* 0x380 */ s32 cutsceneAction; + /* 0x384 */ u16 cutsceneFlags; + /* 0x388 */ s32 inRace; + /* 0x38C */ struct EnIn* rider; + /* 0x390 */ UNK_TYPE1 unk390[0x4]; + /* 0x394 */ u16 unk_394; + /* 0x398 */ f32 unk_398; + /* 0x39C */ s32 unk_39C; + /* 0x3A0 */ s32 hbaStarted; + /* 0x3A4 */ s32 hbaFlags; + /* 0x3A8 */ s32 hbaTimer; + /* 0x3AC */ u16 dustFlags; + /* 0x3B0 */ Vec3f frontRightHoof; + /* 0x3BC */ Vec3f frontLeftHoof; + /* 0x3C8 */ Vec3f backRightHoof; + /* 0x3D4 */ Vec3f backLeftHoof; + /* 0x3E0 */ s32 unk_3E0; + /* 0x3E4 */ UNK_TYPE1 unk3E4[0x4]; + /* 0x3E8 */ f32 unk_3E8; + /* 0x3EC */ s16 unk_3EC; + /* 0x3EE */ Vec3s jointTable[OBJECT_HA_1_LIMB_MAX]; + /* 0x48A */ Vec3s morphTable[OBJECT_HA_1_LIMB_MAX]; + /* 0x528 */ f32 unk_528; + /* 0x52C */ s32 unk_52C; + /* 0x530 */ s32 unk_530; + /* 0x534 */ s32 unk_534; + /* 0x538 */ s32 unk_538; + /* 0x53C */ s32 unk_53C; + /* 0x540 */ Vec3f unk_540; + /* 0x54C */ UNK_TYPE1 unk54C[0x4]; + /* 0x550 */ s32 unk_550; + /* 0x554 */ UNK_TYPE1 unk554[0x18]; + /* 0x56C */ f32 unk_56C; + /* 0x570 */ Vec3f unk_570; + /* 0x57C */ Vec3f unk_57C; + /* 0x588 */ UNK_TYPE1 unk588[0x4]; + /* 0x58C */ s32 unk_58C; + /* 0x590 */ s32 unk_590; } EnHorse; // size = 0x594 extern const ActorInit En_Horse_InitVars; diff --git a/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c b/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c index ff3465a0ae..7b9fa684e0 100644 --- a/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c +++ b/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c @@ -5,6 +5,7 @@ */ #include "z_en_horse_game_check.h" +#include "objects/object_horse_game_check/object_horse_game_check.h" #define FLAGS (ACTOR_FLAG_10) @@ -15,7 +16,25 @@ void EnHorseGameCheck_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnHorseGameCheck_Update(Actor* thisx, GlobalContext* globalCtx); void EnHorseGameCheck_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +s32 func_808F8AA0(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F8C24(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F8C5C(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F8C70(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F8CCC(EnHorseGameCheck* this, GlobalContext* globalCtx2); +s32 func_808F8E94(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F8FAC(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F96E4(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F9830(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F9868(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F987C(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F990C(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F9944(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F9958(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F999C(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F99B0(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F99C4(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F99D8(EnHorseGameCheck* this, GlobalContext* globalCtx); + const ActorInit En_Horse_Game_Check_InitVars = { ACTOR_EN_HORSE_GAME_CHECK, ACTORCAT_BG, @@ -28,63 +47,454 @@ const ActorInit En_Horse_Game_Check_InitVars = { (ActorFunc)EnHorseGameCheck_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808F9BDC[] = { +#include "overlays/ovl_En_Horse_Game_Check/ovl_En_Horse_Game_Check.c" + +s32 func_808F8AA0(EnHorseGameCheck* this, GlobalContext* globalCtx) { + s32 pad[3]; + CollisionHeader* sp78 = NULL; + MtxF sp38; + + this->dyna.actor.scale.x = this->dyna.actor.scale.y = this->dyna.actor.scale.z = this->unk_160 * 0.001f; + this->dyna.actor.flags |= ACTOR_FLAG_400000; + + DynaPolyActor_Init(&this->dyna, 0); + + if (GET_RACE_FLAGS != RACE_FLAG_START) { + Actor_MarkForDeath(&this->dyna.actor); + return false; + } + + CollisionHeader_GetVirtual(&object_horse_game_check_Colheader_003918, &sp78); + + this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, sp78); + this->unk_15C = ENHORSEGAMECHECK_FF_5; + this->dyna.actor.floorPoly = NULL; + this->dyna.actor.world.pos.y += 100.0f; + + this->dyna.actor.floorHeight = BgCheck_EntityRaycastFloor2( + globalCtx, &globalCtx->colCtx, &this->dyna.actor.floorPoly, &this->dyna.actor.world.pos); + this->dyna.actor.world.pos.y = this->dyna.actor.floorHeight + 3.0f; + func_800C0094(this->dyna.actor.floorPoly, this->dyna.actor.world.pos.x, this->dyna.actor.floorHeight, + this->dyna.actor.world.pos.z, &sp38); + + Matrix_SetCurrentState(&sp38); + Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Scale(this->dyna.actor.scale.x, this->dyna.actor.scale.y, this->dyna.actor.scale.y, MTXMODE_APPLY); + Matrix_CopyCurrentState(&sp38); + + func_8018219C(&sp38, &this->dyna.actor.shape.rot, 1); + this->dyna.actor.world.rot = this->dyna.actor.shape.rot; + return true; +} + +s32 func_808F8C24(EnHorseGameCheck* this, GlobalContext* globalCtx) { + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + return true; +} + +s32 func_808F8C5C(EnHorseGameCheck* this, GlobalContext* globalCtx) { + return true; +} + +s32 func_808F8C70(EnHorseGameCheck* this, GlobalContext* globalCtx) { + if (Matrix_NewMtx(globalCtx->state.gfxCtx) == NULL) { + return true; + } else { + Gfx_DrawDListXlu(globalCtx, object_horse_game_check_DL_003030); + Gfx_DrawDListOpa(globalCtx, object_horse_game_check_DL_0030C0); + } + return true; +} + +s32 func_808F8CCC(EnHorseGameCheck* this, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + s32 pad; + Vec3f sp4C = { -1262.0f, 15.0f, 780.0f }; + Vec3f sp40 = { -1262.0f, -26.0f, 470.0f }; + + this->unk_164 = 0; + this->unk_168 = 0; + this->unk_174 = 0; + + if (GET_RACE_FLAGS != RACE_FLAG_START) { + Actor_MarkForDeath(&this->dyna.actor); + return false; + } + + func_8010E9F0(4, 0); + globalCtx->interfaceCtx.unk_280 = 1; + + this->horse1 = (EnHorse*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_HORSE, -1149.0f, -106.0f, 470.0f, 0, + 0x7FFF, 0, 0x2004); + if (this->horse1 == NULL) { + __assert("../z_en_horse_game_check.c", 1517); + } + + this->horse2 = (EnHorse*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_HORSE, -1376.0f, -106.0f, 470.0f, 0, + 0x7FFF, 0, 0x2005); + if (this->horse2 == NULL) { + __assert("../z_en_horse_game_check.c", 1526); + } + + this->unk_17C = -1; + func_800DFAC8(globalCtx->cameraPtrs[CAM_ID_MAIN], 10); + Play_CameraSetAtEye(globalCtx, 0, &sp40, &sp4C); + Play_CameraSetFov(globalCtx, 0, 45.0f); + func_800FE484(); + return false; +} + +s32 func_808F8E94(EnHorseGameCheck* this, GlobalContext* globalCtx) { + gSaveContext.unk_3DD0[4] = 0; + return true; +} + +s32 func_808F8EB0(EnHorseGameCheck* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (globalCtx->nextEntranceIndex == 0xCE20) { + return false; + } + + if (GET_RACE_FLAGS == RACE_FLAG_3) { + globalCtx->unk_1887F = 0x40; + gSaveContext.nextTransition = 2; + } else if (GET_RACE_FLAGS == RACE_FLAG_2) { + globalCtx->unk_1887F = 0x50; + gSaveContext.nextTransition = 3; + } else if (GET_RACE_FLAGS == RACE_FLAG_4) { + SET_RACE_FLAGS(RACE_FLAG_3); + globalCtx->unk_1887F = 2; + gSaveContext.nextTransition = 2; + } + + D_801BDA9C = 0; + if (player->stateFlags1 & 0x800000) { + D_801BDAA0 = 1; + } + globalCtx->nextEntranceIndex = 0xCE20; + globalCtx->sceneLoadFlag = 0x14; + return false; +} + +f32 D_808F9BAC[] = { + -1825.0f, + -237.0f, + -2867.0f, + -1987.0f, +}; + +f32 D_808F9BBC[] = { + 1564.0f, + 3395.0f, + -1665.0f, + -200.0f, +}; + +f32 D_808F9BCC[] = { + -22.0f, + 2005.0f, + 3869.0f, + 5368.0f, +}; + +s32 func_808F8FAC(EnHorseGameCheck* this, GlobalContext* globalCtx) { + s32 pad[2]; + Player* player = GET_PLAYER(globalCtx); + s32 pad2; + EnHorse* horse = (EnHorse*)player->rideActor; + s32 pad3[2]; + EnHorseGameCheck* horseGameCheck; + + if (horse == NULL) { + return true; + } + + if ((this->unk_168 > 50) && !(this->unk_164 & 2)) { + this->unk_164 |= 2; + } else if ((globalCtx->interfaceCtx.unk_280 >= 8) && !(this->unk_164 & 1)) { + this->unk_164 |= 1; + horse->inRace = true; + } else if ((globalCtx->interfaceCtx.unk_280 >= 8) && !(this->unk_164 & 8)) { + EnHorse* horse = this->horse1; + + horse->inRace = true; + horse = this->horse2; + horse->inRace = true; + + this->unk_164 |= 8; + this->unk_17C = this->unk_168; + } + + if ((this->unk_17C != -1) && ((this->unk_168 - this->unk_17C) > 10)) { + this->unk_17C = -1; + func_800DFAC8(globalCtx->cameraPtrs[CAM_ID_MAIN], 4); + } + + this->unk_168++; + if ((this->unk_164 & 0x4000) && (this->unk_164 & 0x200000)) { + if (!(this->unk_164 & 0x10)) { + this->unk_164 |= 0x10; + } + } + + if ((this->unk_164 & 0x800) || (this->unk_164 & 0x40000) || (this->unk_164 & 0x02000000)) { + if (this->unk_174 > 0) { + this->unk_174--; + } else { + func_808F8EB0(this, globalCtx); + } + return true; + } + + if (gSaveContext.unk_3DE0[4] >= 0x4650) { + Audio_QueueSeqCmd(0x8041); + play_sound(NA_SE_SY_START_SHOT); + this->unk_164 |= 0x40000; + gSaveContext.unk_3DD0[4] = 6; + SET_RACE_FLAGS(RACE_FLAG_4) + this->unk_174 = 60; + } + + if (!(this->unk_164 & 0x1000)) { + if (Math3D_XZBoundCheck(D_808F9BAC[0], D_808F9BAC[1], D_808F9BAC[2], D_808F9BAC[3], + this->horse1->actor.world.pos.x, this->horse1->actor.world.pos.z)) { + this->unk_164 |= 0x1000; + } + } + + if (!(this->unk_164 & 0x2000) && (this->unk_164 & 0x1000)) { + if (Math3D_XZBoundCheck(D_808F9BBC[0], D_808F9BBC[1], D_808F9BBC[2], D_808F9BBC[3], + this->horse1->actor.world.pos.x, this->horse1->actor.world.pos.z)) { + this->unk_164 |= 0x2000; + } + } + + if (!(this->unk_164 & 0x4000) && (this->unk_164 & 0x2000)) { + if (Math3D_XZBoundCheck(D_808F9BCC[0], D_808F9BCC[1], D_808F9BCC[2], D_808F9BCC[3], + this->horse1->actor.world.pos.x, this->horse1->actor.world.pos.z)) { + this->unk_164 |= 0x4000; + } + } + + horseGameCheck = (EnHorseGameCheck*)DynaPoly_GetActor(&globalCtx->colCtx, this->horse1->unk_24C); + if ((this->unk_164 & 0x4000) && (horseGameCheck != NULL) && + (horseGameCheck->dyna.actor.id == ACTOR_EN_HORSE_GAME_CHECK) && + (horseGameCheck->unk_15C == ENHORSEGAMECHECK_FF_7) && !(this->unk_164 & 0x40000)) { + Audio_QueueSeqCmd(0x8041); + play_sound(NA_SE_SY_START_SHOT); + this->unk_164 |= 0x40000; + gSaveContext.unk_3DD0[4] = 6; + SET_RACE_FLAGS(RACE_FLAG_3) + this->unk_174 = 60; + } + + if (!(this->unk_164 & 0x80000)) { + if (Math3D_XZBoundCheck(D_808F9BAC[0], D_808F9BAC[1], D_808F9BAC[2], D_808F9BAC[3], + this->horse2->actor.world.pos.x, this->horse2->actor.world.pos.z)) { + this->unk_164 |= 0x80000; + } + } + + if (!(this->unk_164 & 0x100000) && (this->unk_164 & 0x80000)) { + if (Math3D_XZBoundCheck(D_808F9BBC[0], D_808F9BBC[1], D_808F9BBC[2], D_808F9BBC[3], + this->horse2->actor.world.pos.x, this->horse2->actor.world.pos.z)) { + this->unk_164 |= 0x100000; + } + } + + if (!(this->unk_164 & 0x200000) && (this->unk_164 & 0x100000)) { + if (Math3D_XZBoundCheck(D_808F9BCC[0], D_808F9BCC[1], D_808F9BCC[2], D_808F9BCC[3], + this->horse2->actor.world.pos.x, this->horse2->actor.world.pos.z)) { + this->unk_164 |= 0x200000; + } + } + + horseGameCheck = (EnHorseGameCheck*)DynaPoly_GetActor(&globalCtx->colCtx, this->horse2->unk_24C); + if ((this->unk_164 & 0x200000) && (horseGameCheck != NULL) && + (horseGameCheck->dyna.actor.id == ACTOR_EN_HORSE_GAME_CHECK) && + (horseGameCheck->unk_15C == ENHORSEGAMECHECK_FF_7) && !(this->unk_164 & 0x02000000)) { + Audio_QueueSeqCmd(0x8041); + play_sound(NA_SE_SY_START_SHOT); + this->unk_164 |= 0x02000000; + gSaveContext.unk_3DD0[4] = 6; + SET_RACE_FLAGS(RACE_FLAG_3) + this->unk_174 = 60; + } + + if (!(this->unk_164 & 0x20) && Math3D_XZBoundCheck(D_808F9BAC[0], D_808F9BAC[1], D_808F9BAC[2], D_808F9BAC[3], + horse->actor.world.pos.x, horse->actor.world.pos.z)) { + this->unk_164 |= 0x20; + } + + if (!(this->unk_164 & 0x40) && (this->unk_164 & 0x20) && + Math3D_XZBoundCheck(D_808F9BBC[0], D_808F9BBC[1], D_808F9BBC[2], D_808F9BBC[3], horse->actor.world.pos.x, + horse->actor.world.pos.z)) { + this->unk_164 |= 0x40; + } + + if (!(this->unk_164 & 0x80) && (this->unk_164 & 0x40) && + Math3D_XZBoundCheck(D_808F9BCC[0], D_808F9BCC[1], D_808F9BCC[2], D_808F9BCC[3], horse->actor.world.pos.x, + horse->actor.world.pos.z)) { + this->unk_164 |= 0x80; + } + + horseGameCheck = (EnHorseGameCheck*)DynaPoly_GetActor(&globalCtx->colCtx, horse->unk_24C); + if ((this->unk_164 & 0x80) && (horseGameCheck != NULL) && + (horseGameCheck->dyna.actor.id == ACTOR_EN_HORSE_GAME_CHECK) && + (horseGameCheck->unk_15C == ENHORSEGAMECHECK_FF_7) && !(this->unk_164 & 0x800)) { + Audio_QueueSeqCmd(0x8041); + play_sound(NA_SE_SY_START_SHOT); + this->unk_164 |= 0x800; + gSaveContext.unk_3DD0[4] = 6; + SET_RACE_FLAGS(RACE_FLAG_2) + this->unk_174 = 60; + } + return true; +} + +s32 func_808F96E4(EnHorseGameCheck* this, GlobalContext* globalCtx) { + s32 pad[3]; + CollisionHeader* sp78 = NULL; + MtxF sp38; + + this->dyna.actor.scale.x = this->dyna.actor.scale.y = this->dyna.actor.scale.z = this->unk_160 * 0.01f; + DynaPolyActor_Init(&this->dyna, 0); + CollisionHeader_GetVirtual(&ovl_En_Horse_Game_Check_Colheader_0010C8, &sp78); + + this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, sp78); + this->unk_15C = ENHORSEGAMECHECK_FF_7; + this->dyna.actor.floorPoly = NULL; + this->dyna.actor.world.pos.y += 100.0f; + + this->dyna.actor.floorHeight = BgCheck_EntityRaycastFloor2( + globalCtx, &globalCtx->colCtx, &this->dyna.actor.floorPoly, &this->dyna.actor.world.pos); + this->dyna.actor.world.pos.y = this->dyna.actor.floorHeight + 1.0f; + func_800C0094(this->dyna.actor.floorPoly, this->dyna.actor.world.pos.x, this->dyna.actor.floorHeight, + this->dyna.actor.world.pos.z, &sp38); + + Matrix_SetCurrentState(&sp38); + Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Scale(this->dyna.actor.scale.x, this->dyna.actor.scale.y, this->dyna.actor.scale.y, MTXMODE_APPLY); + Matrix_CopyCurrentState(&sp38); + + func_8018219C(&sp38, &this->dyna.actor.shape.rot, 1); + this->dyna.actor.world.rot = this->dyna.actor.shape.rot; + return true; +} + +s32 func_808F9830(EnHorseGameCheck* this, GlobalContext* globalCtx) { + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + return true; +} + +s32 func_808F9868(EnHorseGameCheck* this, GlobalContext* globalCtx) { + return true; +} + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneScale, 2400, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 300, ICHAIN_STOP), }; -#endif +s32 func_808F987C(EnHorseGameCheck* this, GlobalContext* globalCtx) { + s32 pad[3]; + CollisionHeader* sp28 = NULL; + s32 pad2; -extern InitChainEntry D_808F9BDC[]; + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + this->dyna.actor.scale.z = 1.0f; + this->dyna.actor.scale.y = 1.0f; + this->dyna.actor.scale.x = 1.0f; + DynaPolyActor_Init(&this->dyna, 0); + CollisionHeader_GetVirtual(&object_horse_game_check_Colheader_002FB8, &sp28); + this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, sp28); + this->unk_15C = ENHORSEGAMECHECK_FF_8; + return true; +} -extern UNK_TYPE D_060014B0; -extern UNK_TYPE D_06002FB8; -extern UNK_TYPE D_06003030; -extern UNK_TYPE D_06003918; +s32 func_808F990C(EnHorseGameCheck* this, GlobalContext* globalCtx) { + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F8AA0.s") +s32 func_808F9944(EnHorseGameCheck* this, GlobalContext* globalCtx) { + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F8C24.s") +s32 func_808F9958(EnHorseGameCheck* this, GlobalContext* globalCtx) { + Gfx_DrawDListOpa(globalCtx, object_horse_game_check_DL_0014B0); + Gfx_DrawDListOpa(globalCtx, object_horse_game_check_DL_0013A0); + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F8C5C.s") +s32 func_808F999C(EnHorseGameCheck* this, GlobalContext* globalCtx) { + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F8C70.s") +s32 func_808F99B0(EnHorseGameCheck* this, GlobalContext* globalCtx) { + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F8CCC.s") +s32 func_808F99C4(EnHorseGameCheck* this, GlobalContext* globalCtx) { + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F8E94.s") +s32 func_808F99D8(EnHorseGameCheck* this, GlobalContext* globalCtx) { + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F8EB0.s") +EnHorseGameCheckUnkFunc D_808F9BE4[] = { + NULL, NULL, NULL, NULL, NULL, func_808F8AA0, func_808F8CCC, func_808F96E4, func_808F987C, func_808F999C, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F8FAC.s") +EnHorseGameCheckUnkFunc D_808F9C0C[] = { + NULL, NULL, NULL, NULL, NULL, func_808F8C24, func_808F8E94, func_808F9830, func_808F990C, func_808F99B0, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F96E4.s") +EnHorseGameCheckUnkFunc D_808F9C34[] = { + NULL, NULL, NULL, NULL, NULL, func_808F8C5C, func_808F8FAC, func_808F9868, func_808F9944, func_808F99C4, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F9830.s") +EnHorseGameCheckUnkFunc D_808F9C5C[] = { + NULL, NULL, NULL, NULL, NULL, func_808F8C70, NULL, NULL, func_808F9958, func_808F99D8, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F9868.s") +void EnHorseGameCheck_Init(Actor* thisx, GlobalContext* globalCtx) { + EnHorseGameCheck* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F987C.s") + this->unk_15C = ENHORSEGAMECHECK_GET_FF(&this->dyna.actor); + this->unk_160 = ENHORSEGAMECHECK_GET_FF00(&this->dyna.actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F990C.s") + if (this->unk_15C >= ENHORSEGAMECHECK_FF_MAX) { + this->unk_15C = ENHORSEGAMECHECK_FF_0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F9944.s") + if (D_808F9BE4[this->unk_15C] != NULL) { + D_808F9BE4[this->unk_15C](this, globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F9958.s") +void EnHorseGameCheck_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnHorseGameCheck* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F999C.s") + if (D_808F9C0C[this->unk_15C] != NULL) { + D_808F9C0C[this->unk_15C](this, globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F99B0.s") +void EnHorseGameCheck_Update(Actor* thisx, GlobalContext* globalCtx) { + EnHorseGameCheck* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F99C4.s") + if (D_808F9C34[this->unk_15C] != NULL) { + D_808F9C34[this->unk_15C](this, globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F99D8.s") +void EnHorseGameCheck_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnHorseGameCheck* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/EnHorseGameCheck_Init.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/EnHorseGameCheck_Destroy.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/EnHorseGameCheck_Update.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/EnHorseGameCheck_Draw.s") + if (D_808F9C5C[this->unk_15C] != NULL) { + D_808F9C5C[this->unk_15C](this, globalCtx); + } +} diff --git a/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.h b/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.h index 4c04619826..1e4bf4f5a8 100644 --- a/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.h +++ b/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.h @@ -2,12 +2,57 @@ #define Z_EN_HORSE_GAME_CHECK_H #include "global.h" +#include "overlays/actors/ovl_En_Horse/z_en_horse.h" struct EnHorseGameCheck; +typedef s32 (*EnHorseGameCheckUnkFunc)(struct EnHorseGameCheck*, GlobalContext*); + +#define ENHORSEGAMECHECK_GET_FF(thisx) ((thisx)->params & 0xFF) +#define ENHORSEGAMECHECK_GET_FF00(thisx) (((thisx)->params & 0xFF00) >> 8) + +enum { + /* 0 */ ENHORSEGAMECHECK_FF_0, + /* 1 */ ENHORSEGAMECHECK_FF_1, + /* 2 */ ENHORSEGAMECHECK_FF_2, + /* 3 */ ENHORSEGAMECHECK_FF_3, + /* 4 */ ENHORSEGAMECHECK_FF_4, + /* 5 */ ENHORSEGAMECHECK_FF_5, + /* 6 */ ENHORSEGAMECHECK_FF_6, + /* 7 */ ENHORSEGAMECHECK_FF_7, + /* 8 */ ENHORSEGAMECHECK_FF_8, + /* 9 */ ENHORSEGAMECHECK_FF_9, + /* 10 */ ENHORSEGAMECHECK_FF_MAX, +}; + +#define RACE_FLAG_END 0 +#define RACE_FLAG_START 1 +#define RACE_FLAG_2 2 +#define RACE_FLAG_3 3 +#define RACE_FLAG_4 4 +#define RACE_FLAGS 7 + +#define GET_RACE_FLAGS (gSaveContext.save.weekEventReg[92] & RACE_FLAGS) + +#define SET_RACE_FLAGS(flag) \ + { \ + gSaveContext.save.weekEventReg[92] &= (u8)~RACE_FLAGS; \ + gSaveContext.save.weekEventReg[92] = \ + gSaveContext.save.weekEventReg[92] | (u8)((gSaveContext.save.weekEventReg[92] & ~RACE_FLAGS) | (flag)); \ + } + typedef struct EnHorseGameCheck { - /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x74]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ s32 unk_15C; + /* 0x160 */ s32 unk_160; + /* 0x164 */ s32 unk_164; + /* 0x168 */ s32 unk_168; + /* 0x16C */ EnHorse* horse1; + /* 0x170 */ EnHorse* horse2; + /* 0x174 */ s32 unk_174; + /* 0x178 */ UNK_TYPE1 pad178[0x4]; + /* 0x17C */ s32 unk_17C; + /* 0x180 */ UNK_TYPE1 pad180[0x38]; } EnHorseGameCheck; // size = 0x1B8 extern const ActorInit En_Horse_Game_Check_InitVars; diff --git a/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.h b/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.h index 16ac6a6160..ecc816c52b 100644 --- a/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.h +++ b/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.h @@ -2,6 +2,7 @@ #define Z_EN_HORSE_LINK_CHILD_H #include "global.h" +#include "z64skin.h" struct EnHorseLinkChild; diff --git a/src/overlays/actors/ovl_En_Hs/z_en_hs.c b/src/overlays/actors/ovl_En_Hs/z_en_hs.c index 70c021d0e3..e15e3adb3c 100644 --- a/src/overlays/actors/ovl_En_Hs/z_en_hs.c +++ b/src/overlays/actors/ovl_En_Hs/z_en_hs.c @@ -23,7 +23,6 @@ void func_809532D0(EnHs* this, GlobalContext* globalCtx); void func_80953354(EnHs* this, GlobalContext* globalCtx); void func_8095345C(EnHs* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Hs_InitVars = { ACTOR_EN_HS, ACTORCAT_NPC, @@ -36,51 +35,322 @@ const ActorInit En_Hs_InitVars = { (ActorFunc)EnHs_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80953910 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_ENEMY, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_ENEMY, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 40, 40, 0, { 0, 0, 0 } }, }; -#endif +Vec3f D_8095393C = { 300.0f, 1000.0f, 0.0f }; -extern ColliderCylinderInit D_80953910; +void func_80952C50(EnHs* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 i; -extern UNK_TYPE D_060005C0; + for (i = 0; i < ARRAY_COUNT(this->unk_2A4); i++) { + Math_Vec3f_Copy(&this->unk_2A4[i], &player->actor.world.pos); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/func_80952C50.s") + this->actor.home.rot.x = 0; + this->actor.home.rot.z = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/EnHs_Init.s") +void EnHs_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnHs* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/EnHs_Destroy.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_hs_Skel_006260, &object_hs_Anim_0005C0, this->jointTable, + this->morphTable, OBJECT_HS_LIMB_MAX); + Animation_PlayLoop(&this->skelAnime, &object_hs_Anim_0005C0); + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + Actor_SetScale(&this->actor, 0.01f); + this->actionFunc = func_8095345C; + if (globalCtx->curSpawn == 1) { + this->actor.flags |= ACTOR_FLAG_10000; + } + this->unk_2A0 = 0; + this->actor.targetMode = 6; + func_80952C50(this, globalCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/func_80952DFC.s") +void EnHs_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnHs* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/func_80952E50.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/func_80952F00.s") +void func_80952DFC(GlobalContext* globalCtx) { + if (INV_CONTENT(ITEM_MASK_BUNNY) == ITEM_MASK_BUNNY) { + func_80151BB4(globalCtx, 0x2E); + } + func_80151BB4(globalCtx, 0x10); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/func_80952FE0.s") +void func_80952E50(Vec3f* dst, Vec3f src, f32 arg2) { + Vec3f sp1C; + f32 temp_f0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/func_80953098.s") + Math_Vec3f_Diff(&src, dst, &sp1C); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/func_80953180.s") + temp_f0 = SQ(sp1C.x) + SQ(sp1C.z); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/func_809532C0.s") + if (SQ(arg2) > temp_f0) { + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/func_809532D0.s") + temp_f0 = sqrtf(temp_f0); + sp1C.x *= (temp_f0 - arg2) / temp_f0; + sp1C.z *= (temp_f0 - arg2) / temp_f0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/func_80953354.s") + dst->x += sp1C.x; + dst->z += sp1C.z; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/func_809533A0.s") +void func_80952F00(EnHs* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 i; + f32 phi_f20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/func_8095345C.s") + if (this->actor.home.rot.z >= 20) { + phi_f20 = 15.0f; + } else { + phi_f20 = 10.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/EnHs_Update.s") + func_80952E50(&this->unk_2A4[0], player->actor.world.pos, phi_f20); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/func_8095376C.s") + for (i = 1; i < ARRAY_COUNT(this->unk_2A4); i++) { + func_80952E50(&this->unk_2A4[i], this->unk_2A4[i - 1], phi_f20); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/func_80953848.s") +void func_80952FE0(EnHs* this, GlobalContext* globalCtx) { + if (this->unk_2A2 < 40) { + Math_SmoothStepToS(&this->unk_294.y, 0x1F40, 6, 0x1838, 0x64); + } else if (this->unk_2A2 < 80) { + Math_SmoothStepToS(&this->unk_294.y, -0x1F40, 6, 0x1838, 0x64); + } else { + this->actionFunc = func_80953180; + this->unk_2A0 &= ~4; + func_80151938(globalCtx, 0x33F6); + func_80952DFC(globalCtx); + } + this->unk_2A2++; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/EnHs_Draw.s") +void func_80953098(EnHs* this, GlobalContext* globalCtx) { + if (Actor_HasParent(&this->actor, globalCtx)) { + this->actor.parent = NULL; + this->actionFunc = func_8095345C; + this->actor.flags |= ACTOR_FLAG_10000; + this->unk_2A0 |= 0x10; + func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + } else { + this->unk_2A0 |= 8; + if (INV_CONTENT(ITEM_MASK_BUNNY) == ITEM_MASK_BUNNY) { + Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_RED, 10000.0f, 50.0f); + } else { + Actor_PickUp(&this->actor, globalCtx, GI_MASK_BUNNY, 10000.0f, 50.0f); + } + } +} + +void func_80953180(EnHs* this, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { + case 0x33F4: + case 0x33F6: + func_801477B4(globalCtx); + this->actionFunc = func_8095345C; + break; + + case 0x33F7: + this->actor.flags &= ~ACTOR_FLAG_10000; + func_801477B4(globalCtx); + this->actionFunc = func_80953098; + func_80953098(this, globalCtx); + break; + + case 0x33F9: + this->actor.flags &= ~ACTOR_FLAG_10000; + func_801477B4(globalCtx); + this->actionFunc = func_8095345C; + break; + + case 0x33F5: + globalCtx->msgCtx.unk11F10 = 0; + this->actionFunc = func_80952FE0; + this->unk_2A2 = 0; + this->unk_294.z = 0; + this->unk_2A0 |= 4; + break; + + default: + func_801477B4(globalCtx); + this->actionFunc = func_8095345C; + break; + } + } +} + +void func_809532C0(EnHs* this, GlobalContext* globalCtx) { +} + +void func_809532D0(EnHs* this, GlobalContext* globalCtx) { + if (DECR(this->unk_2A2) == 0) { + globalCtx->nextEntranceIndex = globalCtx->setupExitList[ENHS_GET_F(&this->actor)]; + globalCtx->sceneLoadFlag = 0x14; + gSaveContext.save.weekEventReg[25] |= 8; + this->actionFunc = func_809532C0; + } +} + +void func_80953354(EnHs* this, GlobalContext* globalCtx) { + if (!Play_InCsMode(globalCtx)) { + func_800B7298(globalCtx, &this->actor, 7); + this->actionFunc = func_809532D0; + } +} + +void func_809533A0(EnHs* this, GlobalContext* globalCtx) { + u16 sp1E; + + if ((globalCtx->curSpawn == 1) && !(this->unk_2A0 & 0x20)) { + sp1E = 0x33F7; + this->unk_2A0 |= 0x20; + } else if (this->unk_2A0 & 0x10) { + sp1E = 0x33F9; + this->unk_2A0 &= ~0x10; + } else if (gSaveContext.save.weekEventReg[25] & 8) { + sp1E = 0x33F4; + } else { + sp1E = 0x33F5; + } + + Message_StartTextbox(globalCtx, sp1E, &this->actor); + + if (sp1E == 0x33F4) { + func_80952DFC(globalCtx); + } +} + +void func_8095345C(EnHs* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = func_80953180; + func_809533A0(this, globalCtx); + if (this->unk_2A0 & 8) { + func_80952DFC(globalCtx); + this->unk_2A0 &= ~8; + } + } else if (this->actor.home.rot.x >= 20) { + this->actionFunc = func_80953354; + this->unk_2A2 = 40; + } else if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_10000)) { + func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + this->unk_2A0 |= 1; + } else if ((this->actor.xzDistToPlayer < 120.0f) && Player_IsFacingActor(&this->actor, 0x2000, globalCtx)) { + func_800B8614(&this->actor, globalCtx, 130.0f); + this->unk_2A0 |= 1; + } else { + this->unk_2A0 &= ~1; + } +} + +void EnHs_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnHs* this = THIS; + + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + + if (SkelAnime_Update(&this->skelAnime)) { + this->skelAnime.curFrame = 0.0f; + } + + this->actionFunc(this, globalCtx); + + func_80952F00(this, globalCtx); + + if (this->unk_2A0 & 4) { + Math_SmoothStepToS(&this->unk_294.x, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->unk_29A.x, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->unk_29A.y, 0, 6, 0x1838, 0x64); + } else if (this->unk_2A0 & 1) { + func_800E9250(globalCtx, &this->actor, &this->unk_294, &this->unk_29A, this->actor.focus.pos); + } else { + Math_SmoothStepToS(&this->unk_294.x, 0x3200, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->unk_294.y, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->unk_29A.x, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->unk_29A.y, 0, 6, 0x1838, 0x64); + } +} + +s32 EnHs_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnHs* this = THIS; + + switch (limbIndex) { + case OBJECT_HS_LIMB_09: + rot->x += this->unk_294.y; + rot->z += this->unk_294.x; + break; + + case OBJECT_HS_LIMB_0A: + rot->x += this->unk_294.y; + rot->z += this->unk_294.x; + break; + + case OBJECT_HS_LIMB_0B: + *dList = NULL; + return false; + + case OBJECT_HS_LIMB_0C: + if (this->actor.params == ENHS_1) { + *dList = NULL; + return false; + } + break; + + case OBJECT_HS_LIMB_0D: + if (this->actor.params == ENHS_1) { + *dList = NULL; + return false; + } + break; + } + return false; +} + +void EnHs_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnHs* this = THIS; + + if (limbIndex == OBJECT_HS_LIMB_09) { + Matrix_MultiplyVector3fByState(&D_8095393C, &this->actor.focus.pos); + } +} + +void EnHs_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnHs* this = THIS; + + func_8012C5B0(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnHs_OverrideLimbDraw, EnHs_PostLimbDraw, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Hs/z_en_hs.h b/src/overlays/actors/ovl_En_Hs/z_en_hs.h index b9442c03d5..0a50ee3607 100644 --- a/src/overlays/actors/ovl_En_Hs/z_en_hs.h +++ b/src/overlays/actors/ovl_En_Hs/z_en_hs.h @@ -2,14 +2,27 @@ #define Z_EN_HS_H #include "global.h" +#include "objects/object_hs/object_hs.h" struct EnHs; typedef void (*EnHsActionFunc)(struct EnHs*, GlobalContext*); +#define ENHS_GET_F(thisx) ((thisx)->params & 0xF) + +#define ENHS_1 1 + typedef struct EnHs { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x250]; + /* 0x0144 */ ColliderCylinder collider; + /* 0x0190 */ SkelAnime skelAnime; + /* 0x01D4 */ Vec3s jointTable[OBJECT_HS_LIMB_MAX]; + /* 0x0234 */ Vec3s morphTable[OBJECT_HS_LIMB_MAX]; + /* 0x0294 */ Vec3s unk_294; + /* 0x029A */ Vec3s unk_29A; + /* 0x02A0 */ u16 unk_2A0; + /* 0x02A2 */ s16 unk_2A2; + /* 0x02A4 */ Vec3f unk_2A4[20]; /* 0x0394 */ EnHsActionFunc actionFunc; } EnHs; // size = 0x398 diff --git a/src/overlays/actors/ovl_En_Ig/z_en_ig.c b/src/overlays/actors/ovl_En_Ig/z_en_ig.c index c43f065dcb..bbb706326b 100644 --- a/src/overlays/actors/ovl_En_Ig/z_en_ig.c +++ b/src/overlays/actors/ovl_En_Ig/z_en_ig.c @@ -20,13 +20,44 @@ void EnIg_Draw(Actor* thisx, GlobalContext* globalCtx); void func_80BF2AF8(EnIg* this, GlobalContext* globalCtx); void func_80BF2BD4(EnIg* this, GlobalContext* globalCtx); -static s32 D_80BF3260[] = { - 0x0D000100, 0xB10A006C, 0x4E020F19, 0x0F2D4202, 0x0F2D0F32, 0x36004B10, 0x1050210, 0x32103725, - 0x02103711, 0x0F190211, 0x0F12000D, 0x02120006, 0x0001050E, 0x12000600, 0x040E110F, 0x0600020E, - 0x1037110F, 0x0B0E1032, 0x1037060E, 0x0F2D0F32, 0x050E0F19, 0x0F2D0A0A, 0x00615A02, 0x0F2D0F32, - 0x4E020F32, 0x100A4202, 0x100A101E, 0x36004B10, 0x1902101E, 0x10320D02, 0x10321037, 0x01050E10, - 0x32103708, 0x0E101E10, 0x320D0210, 0x1E10320D, 0x02103210, 0x3701050E, 0x10321037, 0x090E101E, - 0x10320E0E, 0x100A101E, 0x030E0F32, 0x100A0C0E, 0x0F2D0F32, 0x07050500, +static u8 D_80BF3260[] = { + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_L(1, 0xB6 - 0x05), + /* 0x05 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_TOWN, 0x57 - 0x09), + /* 0x09 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(15, 25, 15, 45, 0x51 - 0x0F), + /* 0x0F */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(15, 45, 15, 50, 0x4B - 0x15), + /* 0x15 */ SCHEDULE_CMD_CHECK_FLAG_S(0x4B, 0x10, 0x1A - 0x19), + /* 0x19 */ SCHEDULE_CMD_RET_NONE(), + /* 0x1A */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(16, 50, 16, 55, 0x45 - 0x20), + /* 0x20 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(16, 55, 17, 15, 0x3F - 0x26), + /* 0x26 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(17, 15, 18, 0, 0x39 - 0x2C), + /* 0x2C */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(18, 0, 6, 0, 0x33 - 0x32), + /* 0x32 */ SCHEDULE_CMD_RET_NONE(), + /* 0x33 */ SCHEDULE_CMD_RET_TIME(18, 0, 6, 0, 4), + /* 0x39 */ SCHEDULE_CMD_RET_TIME(17, 15, 6, 0, 2), + /* 0x3F */ SCHEDULE_CMD_RET_TIME(16, 55, 17, 15, 11), + /* 0x45 */ SCHEDULE_CMD_RET_TIME(16, 50, 16, 55, 6), + /* 0x4B */ SCHEDULE_CMD_RET_TIME(15, 45, 15, 50, 5), + /* 0x51 */ SCHEDULE_CMD_RET_TIME(15, 25, 15, 45, 10), + /* 0x57 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_YADOYA, 0xB5 - 0x5B), + /* 0x5B */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(15, 45, 15, 50, 0xAF - 0x61), + /* 0x61 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(15, 50, 16, 10, 0xA9 - 0x67), + /* 0x67 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(16, 10, 16, 30, 0xA3 - 0x6D), + /* 0x6D */ SCHEDULE_CMD_CHECK_FLAG_S(0x4B, 0x10, 0x8A - 0x71), + /* 0x71 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(16, 30, 16, 50, 0x84 - 0x77), + /* 0x77 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(16, 50, 16, 55, 0x7E - 0x7D), + /* 0x7D */ SCHEDULE_CMD_RET_NONE(), + /* 0x7E */ SCHEDULE_CMD_RET_TIME(16, 50, 16, 55, 8), + /* 0x84 */ SCHEDULE_CMD_RET_TIME(16, 30, 16, 50, 13), + /* 0x8A */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(16, 30, 16, 50, 0x9D - 0x90), + /* 0x90 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(16, 50, 16, 55, 0x97 - 0x96), + /* 0x96 */ SCHEDULE_CMD_RET_NONE(), + /* 0x97 */ SCHEDULE_CMD_RET_TIME(16, 50, 16, 55, 9), + /* 0x9D */ SCHEDULE_CMD_RET_TIME(16, 30, 16, 50, 14), + /* 0xA3 */ SCHEDULE_CMD_RET_TIME(16, 10, 16, 30, 3), + /* 0xA9 */ SCHEDULE_CMD_RET_TIME(15, 50, 16, 10, 12), + /* 0xAF */ SCHEDULE_CMD_RET_TIME(15, 45, 15, 50, 7), + /* 0xB5 */ SCHEDULE_CMD_RET_NONE(), + /* 0xB6 */ SCHEDULE_CMD_RET_NONE(), }; static s32 D_80BF3318[] = { -1, -1, 3, 1, 3, 1, 2, 0, 3, 5, 0, 3, 1, 2, 4 }; @@ -233,7 +264,7 @@ void func_80BF13E4(EnIg* this) { Actor* func_80BF146C(EnIg* this, GlobalContext* globalCtx) { Actor* retActor; - if (this->unk_298.unk0 == 3) { + if (this->scheduleResult == 3) { retActor = func_80BF1150(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_AN); } else { retActor = &GET_PLAYER(globalCtx)->actor; @@ -341,7 +372,7 @@ s32 func_80BF17BC(EnIg* this, GlobalContext* globalCtx) { case 1: case 3: - if (!(gSaveContext.weekEventReg[75] & 0x10) && (this->unk_3F6 == 3)) { + if (!(gSaveContext.save.weekEventReg[75] & 0x10) && (this->unk_3F6 == 3)) { ActorCutscene_Stop(sp2A); this->unk_3F6 = 5; } else { @@ -361,7 +392,7 @@ s32 func_80BF17BC(EnIg* this, GlobalContext* globalCtx) { } s32* func_80BF1920(EnIg* this, GlobalContext* globalCtx) { - switch (this->unk_298.unk0) { + switch (this->scheduleResult) { case 3: this->unk_3F8 = func_80BF17BC; return D_80BF335C; @@ -395,8 +426,8 @@ s32 func_80BF19A0(EnIg* this, GlobalContext* globalCtx) { this->unk_3F6 = 0; this->unk_3F8 = NULL; this->actor.child = this->unk_2A8; - this->unk_298.unk4 = func_80BF1920(this, globalCtx); - if ((this->unk_298.unk0 != 2) && (this->unk_298.unk0 != 3) && (this->unk_298.unk0 != 4)) { + this->unk_29C = func_80BF1920(this, globalCtx); + if ((this->scheduleResult != 2) && (this->scheduleResult != 3) && (this->scheduleResult != 4)) { this->unk_3D0 |= 0x20; } this->actionFunc = func_80BF2BD4; @@ -417,7 +448,7 @@ void func_80BF1A60(EnIg* this, GlobalContext* globalCtx) { } s32 func_80BF1AE0(EnIg* this, GlobalContext* globalCtx) { - switch (this->unk_298.unk0) { + switch (this->scheduleResult) { case 3: func_80BF1284(this, 0); break; @@ -435,7 +466,7 @@ s32 func_80BF1AE0(EnIg* this, GlobalContext* globalCtx) { s32 func_80BF1B40(EnIg* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - u16 temp = globalCtx->msgCtx.unk11F04; + u16 temp = globalCtx->msgCtx.currentTextId; s32 pad; if (player->stateFlags1 & 0xC40) { @@ -465,7 +496,7 @@ s32 func_80BF1B40(EnIg* this, GlobalContext* globalCtx) { return false; } -s32 func_80BF1C44(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2, s32 arg3, s32 arg4) { +s32 func_80BF1C44(EnIg* this, GlobalContext* globalCtx, ScheduleResult* arg2, s32 arg3, s32 arg4) { u8 sp4F = ENIG_GET_FF(&this->actor); Vec3s* sp48; Vec3f sp3C; @@ -477,8 +508,8 @@ s32 func_80BF1C44(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar sp2C = func_80BF1150(this, globalCtx, arg3, arg4); this->unk_274 = NULL; - if (D_80BF3318[arg2->unk0] >= 0) { - this->unk_274 = func_8013BB34(globalCtx, sp4F, D_80BF3318[arg2->unk0]); + if (D_80BF3318[arg2->result] >= 0) { + this->unk_274 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80BF3318[arg2->result]); } if ((sp2C != NULL) && (sp2C->update != NULL)) { @@ -495,7 +526,7 @@ s32 func_80BF1C44(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return sp24; } -s32 func_80BF1D78(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BF1D78(EnIg* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 sp2C = 0; if (func_80BF1C44(this, globalCtx, arg2, ACTORCAT_NPC, ACTOR_EN_AN)) { @@ -508,8 +539,8 @@ s32 func_80BF1D78(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return sp2C; } -s32 func_80BF1DF4(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { - u16 sp56 = gSaveContext.time - 0x3FFC; +s32 func_80BF1DF4(EnIg* this, GlobalContext* globalCtx, ScheduleResult* arg2) { + u16 sp56 = SCHEDULE_TIME_NOW; u8 sp55 = ENIG_GET_FF(&this->actor); EnDoor* door; Vec3s* sp4C; @@ -519,10 +550,10 @@ s32 func_80BF1DF4(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar s32 ret = false; this->unk_274 = NULL; - door = func_80BF1200(globalCtx, arg2->unk0); + door = func_80BF1200(globalCtx, arg2->result); - if (D_80BF3318[arg2->unk0] >= 0) { - this->unk_274 = func_8013BB34(globalCtx, sp55, D_80BF3318[arg2->unk0]); + if (D_80BF3318[arg2->result] >= 0) { + this->unk_274 = SubS_GetAdditionalPath(globalCtx, sp55, D_80BF3318[arg2->result]); } if ((door != NULL) && (door->dyna.actor.update != NULL)) { @@ -541,8 +572,8 @@ s32 func_80BF1DF4(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_2A4 = 75; } - this->unk_3E0 = arg2->unk8 - arg2->unk4; - this->unk_3E2 = sp56 - arg2->unk4; + this->unk_3E0 = arg2->time1 - arg2->time0; + this->unk_3E2 = sp56 - arg2->time0; this->actor.flags &= ~ACTOR_FLAG_1; this->unk_3D0 |= 0x100; func_80BF1284(this, 3); @@ -553,8 +584,8 @@ s32 func_80BF1DF4(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80BF1FA8(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { - u16 sp2E = gSaveContext.time - 0x3FFC; +s32 func_80BF1FA8(EnIg* this, GlobalContext* globalCtx, ScheduleResult* arg2) { + u16 sp2E = SCHEDULE_TIME_NOW; u16 phi_v1; u8 sp2B = ENIG_GET_FF(&this->actor); s32 temp_t8; @@ -562,8 +593,8 @@ s32 func_80BF1FA8(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_274 = NULL; - if (D_80BF3318[arg2->unk0] >= 0) { - this->unk_274 = func_8013BB34(globalCtx, sp2B, D_80BF3318[arg2->unk0]); + if (D_80BF3318[arg2->result] >= 0) { + this->unk_274 = SubS_GetAdditionalPath(globalCtx, sp2B, D_80BF3318[arg2->result]); } if ((this->unk_274 != NULL) && (this->unk_274->count < 3)) { @@ -571,17 +602,17 @@ s32 func_80BF1FA8(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar } if (this->unk_274 != NULL) { - temp_t8 = this->unk_298.unk0; + temp_t8 = this->scheduleResult; if ((temp_t8 < 10) && (temp_t8 != 0) && (this->unk_3EC >= 0)) { phi_v1 = sp2E; } else { - phi_v1 = arg2->unk4; + phi_v1 = arg2->time0; } - if (arg2->unk8 < phi_v1) { - this->unk_288 = (phi_v1 - arg2->unk8) + 0xFFFF; + if (arg2->time1 < phi_v1) { + this->unk_288 = (phi_v1 - arg2->time1) + 0xFFFF; } else { - this->unk_288 = arg2->unk8 - phi_v1; + this->unk_288 = arg2->time1 - phi_v1; } this->unk_294 = sp2E - phi_v1; @@ -602,7 +633,7 @@ s32 func_80BF1FA8(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80BF219C(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BF219C(EnIg* this, GlobalContext* globalCtx, ScheduleResult* arg2) { u8 sp4F = ENIG_GET_FF(&this->actor); Vec3f sp40; Vec3f sp34; @@ -612,8 +643,8 @@ s32 func_80BF219C(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_274 = NULL; - if (D_80BF3318[arg2->unk0] >= 0) { - this->unk_274 = func_8013BB34(globalCtx, sp4F, D_80BF3318[arg2->unk0]); + if (D_80BF3318[arg2->result] >= 0) { + this->unk_274 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80BF3318[arg2->result]); } if ((this->unk_274 != 0) && (this->unk_274->count >= 2)) { @@ -625,7 +656,7 @@ s32 func_80BF219C(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar Math_Vec3f_Copy(&this->actor.world.pos, &sp40); Math_Vec3f_Copy(&this->actor.prevPos, &sp40); - switch (arg2->unk0) { + switch (arg2->result) { case 2: this->actor.home.rot.y = this->actor.world.rot.y; this->actor.home.rot.y += 0x8000; @@ -647,14 +678,14 @@ s32 func_80BF219C(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80BF2368(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BF2368(EnIg* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret = false; this->actor.targetMode = 0; this->unk_3D0 = 0; this->actor.flags |= ACTOR_FLAG_1; - switch (arg2->unk0) { + switch (arg2->result) { case 5: case 6: case 7: @@ -697,12 +728,12 @@ s32 func_80BF2400(EnIg* this, GlobalContext* globalCtx) { } s32 func_80BF2470(EnIg* this, GlobalContext* globalCtx) { - EnDoor* door = func_80BF1200(globalCtx, this->unk_298.unk0); + EnDoor* door = func_80BF1200(globalCtx, this->scheduleResult); Vec3f sp38; f32 temp; s32 pad; - if (!func_8013AD6C(globalCtx) && (this->unk_3EC != 0)) { + if (!SubS_InCsMode(globalCtx) && (this->unk_3EC != 0)) { if ((door != NULL) && (door->dyna.actor.update != NULL)) { if (((f32)this->unk_3E2 / this->unk_3E0) <= 0.9f) { door->unk_1A7 = this->unk_2A4; @@ -748,7 +779,7 @@ s32 func_80BF25E8(EnIg* this, GlobalContext* globalCtx) { this->actor.world.pos.x = sp58.x; this->actor.world.pos.z = sp58.z; - if (func_8013AD6C(globalCtx)) { + if (SubS_InCsMode(globalCtx)) { sp54 = this->unk_294; sp50 = this->unk_290; sp58 = this->actor.world.pos; @@ -765,7 +796,7 @@ s32 func_80BF25E8(EnIg* this, GlobalContext* globalCtx) { this->actor.world.rot.y = Math_Vec3f_Yaw(&sp70, &sp64); } - if (func_8013AD6C(globalCtx)) { + if (SubS_InCsMode(globalCtx)) { this->unk_294 = sp54; this->unk_290 = sp50; this->unk_278 = sp58; @@ -807,7 +838,7 @@ s32 func_80BF293C(EnIg* this, GlobalContext* globalCtx) { } void func_80BF2A50(EnIg* this, GlobalContext* globalCtx) { - switch (this->unk_298.unk0) { + switch (this->scheduleResult) { case 10: case 11: case 12: @@ -840,22 +871,21 @@ void func_80BF2A50(EnIg* this, GlobalContext* globalCtx) { } void func_80BF2AF8(EnIg* this, GlobalContext* globalCtx) { - u32* unk_14 = &gSaveContext.unk_14; - struct_80133038_arg2 sp20; + ScheduleResult sp20; - this->unk_3EC = REG(15) + *unk_14; + this->unk_3EC = REG(15) + ((void)0, gSaveContext.save.daySpeed); - if (!func_80133038(globalCtx, D_80BF3260, &sp20) || - ((this->unk_298.unk0 != sp20.unk0) && !func_80BF2368(this, globalCtx, &sp20))) { + if (!Schedule_RunScript(globalCtx, D_80BF3260, &sp20) || + ((this->scheduleResult != sp20.result) && !func_80BF2368(this, globalCtx, &sp20))) { this->actor.shape.shadowDraw = NULL; this->actor.flags &= ~ACTOR_FLAG_1; - sp20.unk0 = 0; + sp20.result = 0; } else { this->actor.shape.shadowDraw = ActorShadow_DrawCircle; this->actor.flags |= ACTOR_FLAG_1; } this->unk_2A8 = func_80BF146C(this, globalCtx); - this->unk_298.unk0 = sp20.unk0; + this->scheduleResult = sp20.result; func_80BF2A50(this, globalCtx); } @@ -864,14 +894,14 @@ void func_80BF2BD4(EnIg* this, GlobalContext* globalCtx) { Vec3f sp38; Vec3f sp2C; - if (func_8010BF58(&this->actor, globalCtx, this->unk_298.unk4, this->unk_3F8, &this->unk_298.unk8)) { + if (func_8010BF58(&this->actor, globalCtx, this->unk_29C, this->unk_3F8, &this->unk_2A0)) { SubS_UpdateFlags(&this->unk_3D0, 3, 7); this->unk_3D0 &= ~0x20; this->unk_3D0 |= 0x200; this->unk_3EE = 20; - this->unk_298.unk8 = 0; + this->unk_2A0 = 0; this->actionFunc = func_80BF2AF8; - } else if (((this->unk_298.unk0 != 2) && (this->unk_298.unk0 != 4)) && + } else if (((this->scheduleResult != 2) && (this->scheduleResult != 4)) && ((this->unk_2A8 != NULL) && (this->unk_2A8->update != NULL))) { Math_Vec3f_Copy(&sp38, &this->unk_2A8->world.pos); Math_Vec3f_Copy(&sp2C, &this->actor.world.pos); @@ -892,7 +922,7 @@ void EnIg_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_InitAndSetSphere(globalCtx, &this->collider2, &this->actor, &sSphereInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); Actor_SetScale(&this->actor, 0.01f); - this->unk_298.unk0 = 0; + this->scheduleResult = 0; this->actor.gravity = 0.0f; this->actionFunc = func_80BF2AF8; this->actionFunc(this, globalCtx); @@ -914,11 +944,11 @@ void EnIg_Update(Actor* thisx, GlobalContext* globalCtx) { func_80BF1B40(this, globalCtx); - if (this->unk_298.unk0 != 0) { + if (this->scheduleResult != 0) { func_80BF1258(this); func_80BF13E4(this); func_80BF15EC(this); - func_8013C964(&this->actor, globalCtx, 60.0f, 30.0f, 0, this->unk_3D0 & 7); + func_8013C964(&this->actor, globalCtx, 60.0f, 30.0f, EXCH_ITEM_NONE, this->unk_3D0 & 7); Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); func_80BF1354(this, globalCtx); @@ -1003,7 +1033,7 @@ void EnIg_Draw(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnIg* this = THIS; - if (this->unk_298.unk0 != 0) { + if (this->scheduleResult != 0) { func_8012C28C(globalCtx->state.gfxCtx); OPEN_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Ig/z_en_ig.h b/src/overlays/actors/ovl_En_Ig/z_en_ig.h index 200c751b12..21abb08ac8 100644 --- a/src/overlays/actors/ovl_En_Ig/z_en_ig.h +++ b/src/overlays/actors/ovl_En_Ig/z_en_ig.h @@ -26,7 +26,9 @@ typedef struct EnIg { /* 0x028C */ s32 unk_28C; /* 0x0290 */ s32 unk_290; /* 0x0294 */ s32 unk_294; - /* 0x0298 */ struct_80133038_arg2 unk_298; + /* 0x0298 */ u8 scheduleResult; + /* 0x029C */ s32* unk_29C; + /* 0x02A0 */ s32 unk_2A0; /* 0x02A4 */ s8 unk_2A4; /* 0x02A8 */ Actor* unk_2A8; /* 0x02AC */ UNK_TYPE1 unk2AC[0x4]; diff --git a/src/overlays/actors/ovl_En_In/z_en_in.c b/src/overlays/actors/ovl_En_In/z_en_in.c index 5a1ec5a182..758543f452 100644 --- a/src/overlays/actors/ovl_En_In/z_en_in.c +++ b/src/overlays/actors/ovl_En_In/z_en_in.c @@ -6,25 +6,12 @@ #include "z_en_in.h" #include "objects/object_in/object_in.h" +#include "overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnIn*)thisx) -#define SET_FLAGS_FINISH_RACE \ - { \ - gSaveContext.weekEventReg[92] &= (u8) ~(1 | 2 | 4); \ - gSaveContext.weekEventReg[92] = \ - gSaveContext.weekEventReg[92] | (u8)(gSaveContext.weekEventReg[92] & ~(1 | 2 | 4)); \ - } - -#define SET_FLAGS_START_RACE \ - { \ - gSaveContext.weekEventReg[92] &= (u8) ~(1 | 2 | 4); \ - gSaveContext.weekEventReg[92] = \ - gSaveContext.weekEventReg[92] | (u8)((gSaveContext.weekEventReg[92] & ~(1 | 2 | 4)) | 1); \ - } - void EnIn_Init(Actor* thisx, GlobalContext* globalCtx); void EnIn_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnIn_Update(Actor* thisx, GlobalContext* globalCtx); @@ -178,11 +165,11 @@ s32 func_808F3178(EnIn* this, GlobalContext* globalCtx) { u8 prevUnk261 = this->unk261; u8 tmp; - this->unk260 = tmp = func_8013DB90(globalCtx, &this->unk248, -6.0f); + this->unk260 = tmp = SubS_IsFloorAbove(globalCtx, &this->unk248, -6.0f); if (this->unk260 != 0 && prevUnk260 == 0 && tmp) { Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_WALK_CONCRETE); } - this->unk261 = tmp = func_8013DB90(globalCtx, &this->unk254, -6.0f); + this->unk261 = tmp = SubS_IsFloorAbove(globalCtx, &this->unk254, -6.0f); if (this->unk261 != 0 && prevUnk261 == 0 && tmp) { Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_WALK_CONCRETE); } @@ -231,12 +218,11 @@ s32 func_808F3334(EnIn* this, GlobalContext* globalCtx) { } s32 func_808F33B8(void) { - s32 ret; + s32 ret = (((gSaveContext.save.day == 1) && + ((gSaveContext.save.time >= CLOCK_TIME(5, 30)) && (gSaveContext.save.time <= CLOCK_TIME(6, 0)))) || + (gSaveContext.save.day >= 2)) && + !(gSaveContext.save.weekEventReg[22] & 1); - if (((ret = gSaveContext.day == 1) && (ret = gSaveContext.time >= 0x3AAA) && (ret = gSaveContext.time <= 0x4000)) || - (ret = gSaveContext.day >= 2)) { - ret = (gSaveContext.weekEventReg[22] & 1) == 0; - } return ret; } @@ -300,7 +286,7 @@ void func_808F3690(EnIn* this, GlobalContext* globalCtx) { Math_SmoothStepToF(&this->actor.speedXZ, 1.0f, 0.4f, 1000.0f, 0.0f); sp36 = this->actor.speedXZ * 400.0f; - if (func_8013D68C(this->path, this->unk244, &sp28) && func_8013D768(&this->actor, &sp28, sp36)) { + if (SubS_CopyPointFromPath(this->path, this->unk244, &sp28) && SubS_MoveActorToPoint(&this->actor, &sp28, sp36)) { this->unk244++; if (this->unk244 >= this->path->count) { this->unk244 = 0; @@ -309,9 +295,10 @@ void func_808F3690(EnIn* this, GlobalContext* globalCtx) { } void func_808F374C(EnIn* this, GlobalContext* globalCtx) { - AnimationHeader* animations[] = { &object_in_Anim_015E38, &object_in_Anim_016A60, &object_in_Anim_0177AC, - &object_in_Anim_016484, &object_in_Anim_0170DC, &object_in_Anim_018240, - &object_in_Anim_0187C8, &object_in_Anim_0198A8 }; + AnimationHeader* sAnimations[] = { + &object_in_Anim_015E38, &object_in_Anim_016A60, &object_in_Anim_0177AC, &object_in_Anim_016484, + &object_in_Anim_0170DC, &object_in_Anim_018240, &object_in_Anim_0187C8, &object_in_Anim_0198A8, + }; if (this->skelAnime.animation == &object_in_Anim_016484 || this->skelAnime.animation == &object_in_Anim_0170DC) { if (Animation_OnFrame(&this->skelAnime, 8.0f)) { @@ -326,9 +313,10 @@ void func_808F374C(EnIn* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_IN_CRY_0); } if (SkelAnime_Update(&this->skelAnime)) { - this->unk486 = this->unk488 %= 8; - Animation_Change(&this->skelAnime, animations[this->unk488], 1.0f, 0.0f, - Animation_GetLastFrame(animations[this->unk488]), 2, -10.0f); + this->unk488 %= ARRAY_COUNT(sAnimations); + this->unk486 = this->unk488; + Animation_Change(&this->skelAnime, sAnimations[this->unk488], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimations[this->unk488]), 2, -10.0f); } } @@ -345,7 +333,7 @@ void func_808F38F8(EnIn* this, GlobalContext* globalCtx) { } void func_808F395C(EnIn* this, GlobalContext* globalCtx) { - if (this->unk4B0 == 0) { + if (this->unk4B0 == RACE_FLAG_END) { this->actionFunc = func_808F5A94; } if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { @@ -360,31 +348,31 @@ void func_808F395C(EnIn* this, GlobalContext* globalCtx) { void func_808F39DC(EnIn* this, GlobalContext* globalCtx) { u16 textId = 0; - if (gSaveContext.day != 3) { - switch (gSaveContext.weekEventReg[92] & (1 | 2 | 4)) { - case 2: + if (gSaveContext.save.day != 3) { + switch (GET_RACE_FLAGS) { + case RACE_FLAG_2: textId = 0x347A; break; - case 3: + case RACE_FLAG_3: textId = 0x3476; break; } - SET_FLAGS_FINISH_RACE; + SET_RACE_FLAGS(RACE_FLAG_END); } else { - switch (gSaveContext.weekEventReg[92] & (1 | 2 | 4)) { - case 2: + switch (GET_RACE_FLAGS) { + case RACE_FLAG_2: textId = 0x349D; break; - case 3: + case RACE_FLAG_3: textId = 0x3499; break; } - SET_FLAGS_FINISH_RACE; + SET_RACE_FLAGS(RACE_FLAG_END); } this->actor.flags |= ACTOR_FLAG_10000; this->actor.textId = textId; this->actionFunc = func_808F395C; - if (this->unk4B0 == 2) { + if (this->unk4B0 == RACE_FLAG_2) { Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_IN_LOST); } else { Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_IN_JOY0); @@ -408,7 +396,7 @@ void func_808F3B40(EnIn* this, GlobalContext* globalCtx) { this->actor.parent = NULL; this->actor.flags |= ACTOR_FLAG_10000; this->actionFunc = func_808F3AD4; - textId = gSaveContext.day != 3 ? 0x3481 : 0x34A4; + textId = gSaveContext.save.day != 3 ? 0x3481 : 0x34A4; this->actor.textId = textId; } else { Actor_PickUp(&this->actor, globalCtx, GI_MILK, 500.0f, 100.0f); @@ -432,7 +420,7 @@ void func_808F3C40(EnIn* this, GlobalContext* globalCtx) { this->actor.parent = NULL; this->actor.flags |= ACTOR_FLAG_10000; this->actionFunc = func_808F3BD4; - textId = gSaveContext.day != 3 ? 0x346A : 0x3492; + textId = gSaveContext.save.day != 3 ? 0x346A : 0x3492; this->actor.textId = textId; } else { Actor_PickUp(&this->actor, globalCtx, GI_MILK, 500.0f, 100.0f); @@ -455,7 +443,7 @@ void func_808F3D40(EnIn* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { this->actor.parent = NULL; this->actionFunc = func_808F3CD4; - textId = gSaveContext.day != 3 ? 0x347D : 0x34A0; + textId = gSaveContext.save.day != 3 ? 0x347D : 0x34A0; this->actor.textId = textId; this->actor.flags |= ACTOR_FLAG_10000; } else { @@ -469,7 +457,7 @@ u16 func_808F3DD4(GlobalContext* globalCtx, EnIn* this, u32 arg2) { if (Player_GetMask(globalCtx) == PLAYER_MASK_CIRCUS_LEADER) { s32 requiredScopeTemp; - if (!(gSaveContext.weekEventReg[63] & 0x40)) { + if (!(gSaveContext.save.weekEventReg[63] & 0x40)) { return 0x34A9; } else if (this->unk4AC & 8) { return 0x34B1; @@ -479,41 +467,43 @@ u16 func_808F3DD4(GlobalContext* globalCtx, EnIn* this, u32 arg2) { } else { switch (arg2) { case 0: - if ((gSaveContext.playerForm == PLAYER_FORM_ZORA) || (gSaveContext.playerForm == PLAYER_FORM_GORON)) { + if ((gSaveContext.save.playerForm == PLAYER_FORM_ZORA) || + (gSaveContext.save.playerForm == PLAYER_FORM_GORON)) { textId = 0x345C; - } else if (gSaveContext.playerForm == PLAYER_FORM_DEKU) { + } else if (gSaveContext.save.playerForm == PLAYER_FORM_DEKU) { textId = 0x3460; - } else if (!(gSaveContext.weekEventReg[15] & 8)) { + } else if (!(gSaveContext.save.weekEventReg[15] & 8)) { textId = 0x3458; } else { textId = 0x345B; } break; case 1: - if (!(gSaveContext.weekEventReg[15] & 0x10)) { + if (!(gSaveContext.save.weekEventReg[15] & 0x10)) { textId = 0x3463; } else { textId = 0x346B; } break; case 3: - if (gSaveContext.playerForm == PLAYER_FORM_DEKU) { + if (gSaveContext.save.playerForm == PLAYER_FORM_DEKU) { textId = 0x3485; - } else if (gSaveContext.playerForm == PLAYER_FORM_ZORA || - gSaveContext.playerForm == PLAYER_FORM_GORON) { + } else if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA || + gSaveContext.save.playerForm == PLAYER_FORM_GORON) { textId = 0x3484; - } else if (!(gSaveContext.weekEventReg[56] & 4)) { + } else if (!(gSaveContext.save.weekEventReg[56] & 4)) { textId = 0x346D; } else { textId = 0x3482; } break; case 4: - if (gSaveContext.playerForm == PLAYER_FORM_ZORA || gSaveContext.playerForm == PLAYER_FORM_GORON) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA || + gSaveContext.save.playerForm == PLAYER_FORM_GORON) { textId = 0x348A; - } else if (gSaveContext.playerForm == PLAYER_FORM_DEKU) { + } else if (gSaveContext.save.playerForm == PLAYER_FORM_DEKU) { textId = 0x348B; - } else if (!(gSaveContext.weekEventReg[16] & 1)) { + } else if (!(gSaveContext.save.weekEventReg[16] & 1)) { textId = 0x3486; } else { textId = 0x3489; @@ -522,19 +512,19 @@ u16 func_808F3DD4(GlobalContext* globalCtx, EnIn* this, u32 arg2) { case 5: if (func_808F33B8()) { textId = 0x34B3; - } else if (!(gSaveContext.weekEventReg[16] & 2)) { + } else if (!(gSaveContext.save.weekEventReg[16] & 2)) { textId = 0x348E; } else { textId = 0x3493; } break; case 7: - if (gSaveContext.playerForm == PLAYER_FORM_DEKU) { + if (gSaveContext.save.playerForm == PLAYER_FORM_DEKU) { textId = 0x34A8; - } else if (gSaveContext.playerForm == PLAYER_FORM_ZORA || - gSaveContext.playerForm == PLAYER_FORM_GORON) { + } else if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA || + gSaveContext.save.playerForm == PLAYER_FORM_GORON) { textId = 0x34A7; - } else if (!(gSaveContext.weekEventReg[16] & 4)) { + } else if (!(gSaveContext.save.weekEventReg[16] & 4)) { textId = 0x3495; } else { textId = 0x34A5; @@ -585,9 +575,9 @@ s32 func_808F4150(GlobalContext* globalCtx, EnIn* this, s32 arg2, MessageContext if (msgCtx->choiceIndex == 0) { func_8019F208(); - if (gSaveContext.rupees >= globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees >= globalCtx->msgCtx.unk1206C) { func_801159EC(-globalCtx->msgCtx.unk1206C); - if (!(gSaveContext.weekEventReg[57] & 1)) { + if (!(gSaveContext.save.weekEventReg[57] & 1)) { func_808F4108(this, globalCtx, 0x3474); } else if (this->unk4AC & 8) { func_808F4108(this, globalCtx, 0x3475); @@ -611,9 +601,9 @@ s32 func_808F4270(GlobalContext* globalCtx, EnIn* this, s32 arg2, MessageContext if (msgCtx->choiceIndex == 0) { func_8019F208(); - if (gSaveContext.rupees >= fee) { + if (gSaveContext.save.playerData.rupees >= fee) { func_801159EC(-fee); - if (!(gSaveContext.weekEventReg[57] & 1)) { + if (!(gSaveContext.save.weekEventReg[57] & 1)) { if (arg4 != 0) { func_800E8EA0(globalCtx, &this->actor, 0x3474); } else { @@ -644,7 +634,7 @@ s32 func_808F4270(GlobalContext* globalCtx, EnIn* this, s32 arg2, MessageContext s32 func_808F43E0(EnIn* this) { this->unk48C = 0; this->actor.textId = 0; - SET_FLAGS_FINISH_RACE; + SET_RACE_FLAGS(RACE_FLAG_END); return 0; } @@ -661,7 +651,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { break; case 0x34A9: func_808F4108(this, globalCtx, 0x34AA); - gSaveContext.weekEventReg[63] |= 0x40; + gSaveContext.save.weekEventReg[63] |= 0x40; ret = false; break; case 0x34AA: @@ -692,7 +682,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { case 0: switch (textId) { case 0x3458: - gSaveContext.weekEventReg[15] |= 8; + gSaveContext.save.weekEventReg[15] |= 8; func_800E8EA0(globalCtx, &this->actor, 0x3459); ret = false; break; @@ -741,7 +731,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { case 1: switch (textId) { case 0x3463: - gSaveContext.weekEventReg[15] |= 0x10; + gSaveContext.save.weekEventReg[15] |= 0x10; func_800E8EA0(globalCtx, &this->actor, 0x3464); ret = false; break; @@ -756,7 +746,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { case 0x3466: if (msgCtx->choiceIndex == 0) { func_8019F208(); - if (gSaveContext.rupees >= globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees >= globalCtx->msgCtx.unk1206C) { if (Interface_HasEmptyBottle()) { this->actionFunc = func_808F3C40; Actor_PickUp(&this->actor, globalCtx, GI_MILK, 500.0f, 100.0f); @@ -817,21 +807,21 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { break; case 0x3472: func_808F43E0(this); - gSaveContext.weekEventReg[56] &= (u8)~8; + gSaveContext.save.weekEventReg[56] &= (u8)~8; func_80151BB4(globalCtx, 0x11); ret = true; break; case 0x3473: - gSaveContext.weekEventReg[56] &= (u8)~8; + gSaveContext.save.weekEventReg[56] &= (u8)~8; func_80151BB4(globalCtx, 0x11); break; case 0x3475: - SET_FLAGS_START_RACE; + SET_RACE_FLAGS(RACE_FLAG_START); func_800FD750(NA_BGM_HORSE); globalCtx->nextEntranceIndex = 0xCE50; globalCtx->unk_1887F = 5; globalCtx->sceneLoadFlag = 0x14; - gSaveContext.weekEventReg[57] |= 1; + gSaveContext.save.weekEventReg[57] |= 1; break; case 0x3478: if (msgCtx->choiceIndex == 0) { @@ -839,14 +829,14 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { ret = false; } else { func_8019F230(); - gSaveContext.weekEventReg[56] &= (u8)~8; + gSaveContext.save.weekEventReg[56] &= (u8)~8; func_808F4108(this, globalCtx, 0x3479); ret = false; } break; case 0x347B: func_808F4108(this, globalCtx, 0x347C); - gSaveContext.weekEventReg[56] &= (u8)~8; + gSaveContext.save.weekEventReg[56] &= (u8)~8; ret = false; break; } @@ -855,8 +845,8 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { switch (textId) { case 0x346D: func_808F4108(this, globalCtx, 0x346E); - gSaveContext.weekEventReg[56] |= 4; - gSaveContext.weekEventReg[56] |= 8; + gSaveContext.save.weekEventReg[56] |= 4; + gSaveContext.save.weekEventReg[56] |= 8; ret = false; break; case 0x346F: @@ -865,7 +855,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { break; case 0x3482: func_808F4108(this, globalCtx, 0x3483); - gSaveContext.weekEventReg[56] |= 8; + gSaveContext.save.weekEventReg[56] |= 8; ret = false; break; case 0x3484: @@ -885,7 +875,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { ret = false; break; case 0x3477: - gSaveContext.weekEventReg[56] |= 8; + gSaveContext.save.weekEventReg[56] |= 8; func_808F4108(this, globalCtx, 0x3478); ret = false; break; @@ -896,7 +886,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { func_800E8EA0(globalCtx, &this->actor, 0x347E); ret = false; } else { - gSaveContext.weekEventReg[56] |= 8; + gSaveContext.save.weekEventReg[56] |= 8; func_808F4108(this, globalCtx, 0x347B); ret = false; } @@ -952,7 +942,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { switch (textId) { case 0x3486: func_800E8EA0(globalCtx, &this->actor, 0x3487); - gSaveContext.weekEventReg[16] |= 1; + gSaveContext.save.weekEventReg[16] |= 1; ret = false; break; case 0x3487: @@ -993,7 +983,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { case 0x348E: case 0x34B3: func_800E8EA0(globalCtx, &this->actor, 0x348F); - gSaveContext.weekEventReg[16] |= 2; + gSaveContext.save.weekEventReg[16] |= 2; ret = false; break; case 0x3493: @@ -1008,7 +998,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { case 0x3490: if (msgCtx->choiceIndex == 0) { func_8019F208(); - if (gSaveContext.rupees >= globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees >= globalCtx->msgCtx.unk1206C) { if (Interface_HasEmptyBottle()) { this->actionFunc = func_808F3C40; Actor_PickUp(&this->actor, globalCtx, GI_MILK, 500.0f, 100.0f); @@ -1045,8 +1035,8 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { break; case 0x3495: func_808F4108(this, globalCtx, 0x3496); - gSaveContext.weekEventReg[16] |= 4; - gSaveContext.weekEventReg[56] |= 8; + gSaveContext.save.weekEventReg[16] |= 4; + gSaveContext.save.weekEventReg[56] |= 8; ret = false; break; case 0x3497: @@ -1061,11 +1051,11 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { break; case 0x34A5: func_808F4108(this, globalCtx, 0x34A6); - gSaveContext.weekEventReg[56] |= 8; + gSaveContext.save.weekEventReg[56] |= 8; ret = false; break; case 0x3473: - gSaveContext.weekEventReg[56] &= (u8)~8; + gSaveContext.save.weekEventReg[56] &= (u8)~8; func_80151BB4(globalCtx, 0x11); break; case 0x3474: @@ -1073,12 +1063,12 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { ret = false; break; case 0x3475: - SET_FLAGS_START_RACE; + SET_RACE_FLAGS(RACE_FLAG_START); func_800FD750(NA_BGM_HORSE); globalCtx->nextEntranceIndex = 0xCE50; globalCtx->unk_1887F = 5; globalCtx->sceneLoadFlag = 0x14; - gSaveContext.weekEventReg[57] |= 1; + gSaveContext.save.weekEventReg[57] |= 1; break; case 0x349D: func_808F30B0(&this->skelAnime, 1); @@ -1087,7 +1077,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { func_800E8EA0(globalCtx, &this->actor, 0x34A1); ret = false; } else { - gSaveContext.weekEventReg[56] |= 8; + gSaveContext.save.weekEventReg[56] |= 8; func_808F4108(this, globalCtx, 0x349E); ret = false; } @@ -1170,13 +1160,13 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { break; case 0x3472: func_808F43E0(this); - gSaveContext.weekEventReg[56] &= (u8)~8; + gSaveContext.save.weekEventReg[56] &= (u8)~8; func_80151BB4(globalCtx, 0x11); ret = true; break; case 0x349E: func_808F4108(this, globalCtx, 0x349F); - gSaveContext.weekEventReg[56] &= (u8)~8; + gSaveContext.save.weekEventReg[56] &= (u8)~8; ret = false; break; } @@ -1196,7 +1186,7 @@ s32 func_808F5674(GlobalContext* globalCtx, EnIn* this, s32 arg2) { break; case 4: case 5: - if (func_80147624(globalCtx) && func_808F4414(globalCtx, this, arg2)) { + if (Message_ShouldAdvance(globalCtx) && func_808F4414(globalCtx, this, arg2)) { func_801477B4(globalCtx); ret = true; } @@ -1287,7 +1277,7 @@ s32 func_808F5994(EnIn* this, GlobalContext* globalCtx, Vec3f* arg2, s16 arg3) { } void func_808F5A34(EnIn* this, GlobalContext* globalCtx) { - if (gSaveContext.day != 3) { + if (gSaveContext.save.day != 3) { func_808F5728(globalCtx, this, 3, &this->unk48C); } else { func_808F5728(globalCtx, this, 7, &this->unk48C); @@ -1296,13 +1286,13 @@ void func_808F5A34(EnIn* this, GlobalContext* globalCtx) { void func_808F5A94(EnIn* this, GlobalContext* globalCtx) { if (func_800F41E4(globalCtx, &globalCtx->actorCtx)) { - if (gSaveContext.day == 3) { + if (gSaveContext.save.day == 3) { func_808F5728(globalCtx, this, 7, &this->unk48C); } else { func_808F5728(globalCtx, this, 3, &this->unk48C); } } else { - if (gSaveContext.day == 3) { + if (gSaveContext.save.day == 3) { func_808F5728(globalCtx, this, 5, &this->unk48C); } else { func_808F5728(globalCtx, this, 1, &this->unk48C); @@ -1312,17 +1302,17 @@ void func_808F5A94(EnIn* this, GlobalContext* globalCtx) { void func_808F5B58(EnIn* this, GlobalContext* globalCtx) { if (func_800F41E4(globalCtx, &globalCtx->actorCtx)) { - if ((Player_GetMask(globalCtx) == PLAYER_MASK_CIRCUS_LEADER && gSaveContext.weekEventReg[63] & 0x40) || - gSaveContext.weekEventReg[56] & 8) { - if (gSaveContext.day == 3) { + if ((Player_GetMask(globalCtx) == PLAYER_MASK_CIRCUS_LEADER && gSaveContext.save.weekEventReg[63] & 0x40) || + gSaveContext.save.weekEventReg[56] & 8) { + if (gSaveContext.save.day == 3) { func_808F5728(globalCtx, this, 6, &this->unk48C); } else { func_808F5728(globalCtx, this, 2, &this->unk48C); } } } else if (Player_GetMask(globalCtx) != PLAYER_MASK_CIRCUS_LEADER || - (Player_GetMask(globalCtx) == PLAYER_MASK_CIRCUS_LEADER && gSaveContext.weekEventReg[63] & 0x40)) { - if (gSaveContext.day == 3) { + (Player_GetMask(globalCtx) == PLAYER_MASK_CIRCUS_LEADER && gSaveContext.save.weekEventReg[63] & 0x40)) { + if (gSaveContext.save.day == 3) { func_808F5728(globalCtx, this, 4, &this->unk48C); } else { func_808F5728(globalCtx, this, 0, &this->unk48C); @@ -1331,19 +1321,19 @@ void func_808F5B58(EnIn* this, GlobalContext* globalCtx) { } void func_808F5C98(EnIn* this, GlobalContext* globalCtx) { - if (this->unk4B0 == 0) { + if (this->unk4B0 == RACE_FLAG_END) { this->actionFunc = func_808F5B58; } - if ((Player_GetMask(globalCtx) == PLAYER_MASK_CIRCUS_LEADER && gSaveContext.weekEventReg[63] & 0x40) || - gSaveContext.weekEventReg[56] & 8) { - if (gSaveContext.day != 3) { + if ((Player_GetMask(globalCtx) == PLAYER_MASK_CIRCUS_LEADER && gSaveContext.save.weekEventReg[63] & 0x40) || + gSaveContext.save.weekEventReg[56] & 8) { + if (gSaveContext.save.day != 3) { func_808F5728(globalCtx, this, 2, &this->unk48C); } else { func_808F5728(globalCtx, this, 6, &this->unk48C); } } if (this->unk4A8 == 2) { - if (this->unk4B0 == 2) { + if (this->unk4B0 == RACE_FLAG_2) { Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_IN_LOST); } else { Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_IN_JOY0); @@ -1376,8 +1366,8 @@ void EnIn_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk48C = 0; this->unk4AC = 0; type = ENIN_GET_TYPE(thisx); - this->unk4B0 = gSaveContext.weekEventReg[92] & (1 | 2 | 4); - if (type == ENIN_HORSE_RIDER_BLUE_SHIRT || type == 4) { + this->unk4B0 = GET_RACE_FLAGS; + if (type == ENIN_HORSE_RIDER_BLUE_SHIRT || type == ENIN_BLUE_SHIRT) { this->unk4AC |= 8; } if (type == ENIN_HORSE_RIDER_YELLOW_SHIRT || type == ENIN_HORSE_RIDER_BLUE_SHIRT) { @@ -1394,23 +1384,22 @@ void EnIn_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_SetJntSph(globalCtx, &this->colliderJntSph, &this->actor, &sJntSphInit, &this->colliderJntSphElement); Actor_SetScale(&this->actor, 0.01f); this->actor.gravity = -4.0f; - this->path = func_8013D648(globalCtx, ENIN_GET_PATH(&this->actor), 0x3F); + this->path = SubS_GetPathByIndex(globalCtx, ENIN_GET_PATH(&this->actor), 0x3F); this->unk23D = 0; if (type == ENIN_YELLOW_SHIRT || type == ENIN_BLUE_SHIRT) { - if ((gSaveContext.weekEventReg[92] & (1 | 2 | 4)) == 2 || - (gSaveContext.weekEventReg[92] & (1 | 2 | 4)) == 3) { - gSaveContext.weekEventReg[56] &= (u8)~8; + if (GET_RACE_FLAGS == RACE_FLAG_2 || GET_RACE_FLAGS == RACE_FLAG_3) { + gSaveContext.save.weekEventReg[56] &= (u8)~8; this->unk4A8 = 0; this->unk4AC |= 2; func_808F35AC(this, globalCtx); this->unk23C = 0; D_801BDAA0 = 0; - if ((gSaveContext.weekEventReg[92] & (1 | 2 | 4)) == 2) { + if (GET_RACE_FLAGS == RACE_FLAG_2) { func_808F30B0(&this->skelAnime, 6); } else { func_808F30B0(&this->skelAnime, 4); } - if ((gSaveContext.weekEventReg[92] & (1 | 2 | 4)) == 2) { + if (GET_RACE_FLAGS == RACE_FLAG_2) { this->skelAnime.curFrame = ((Rand_ZeroOne() * 0.6f) + 0.2f) * this->skelAnime.endFrame; } if (this->unk4AC & 8) { @@ -1419,8 +1408,8 @@ void EnIn_Init(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc = func_808F5C98; } } else { - if ((gSaveContext.weekEventReg[92] & (1 | 2 | 4)) != 1) { - gSaveContext.weekEventReg[56] &= (u8)~8; + if (GET_RACE_FLAGS != RACE_FLAG_START) { + gSaveContext.save.weekEventReg[56] &= (u8)~8; this->unk23C = 0; this->unk4AC |= 2; if (type == ENIN_BLUE_SHIRT) { @@ -1428,7 +1417,7 @@ void EnIn_Init(Actor* thisx, GlobalContext* globalCtx) { func_808F30B0(&this->skelAnime, 0); this->actionFunc = func_808F5A94; } else { - if (gSaveContext.weekEventReg[52] & 1) { + if (gSaveContext.save.weekEventReg[52] & 1) { Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_KANBAN, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, this->actor.shape.rot.x, this->actor.shape.rot.y, this->actor.shape.rot.z, 0xF); @@ -1439,7 +1428,7 @@ void EnIn_Init(Actor* thisx, GlobalContext* globalCtx) { } } } else { - if (gSaveContext.weekEventReg[52] & 1) { + if (gSaveContext.save.weekEventReg[52] & 1) { Actor_MarkForDeath(&this->actor); } else { func_808F30B0(&this->skelAnime, 7); @@ -1492,7 +1481,7 @@ void func_808F6334(EnIn* this, GlobalContext* globalCtx) { Matrix_InsertTranslation(this->unk4C4, 0.0f, 0.0f, MTXMODE_APPLY); if (&this->actor == player->targetActor && - !(globalCtx->msgCtx.unk11F04 >= 0xFF && globalCtx->msgCtx.unk11F04 <= 0x200) && newUnk4C8 == 3 && + !(globalCtx->msgCtx.currentTextId >= 0xFF && globalCtx->msgCtx.currentTextId <= 0x200) && newUnk4C8 == 3 && this->unk4C8 == 3) { if (!(globalCtx->state.frames & 1)) { this->unk4C0 = this->unk4C0 != 0.0f ? 0.0f : 1.0f; diff --git a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c index 667f66a51f..80a5c76516 100644 --- a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c +++ b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c @@ -3,6 +3,8 @@ * Overlay: ovl_En_Invadepoh * Description: Ranch nighttime actors */ + +#include "prevent_bss_reordering.h" #include "z_en_invadepoh.h" #include "overlays/actors/ovl_En_Door/z_en_door.h" #include "objects/gameplay_keep/gameplay_keep.h" @@ -628,9 +630,10 @@ void func_80B439B0(s32 arg0, s32 arg1) { } if (!(arg0 & 1)) { - gSaveContext.unk_E88[arg0 >> 1] = (gSaveContext.unk_E88[arg0 >> 1] & 0xFFFF0000) | (arg1 & 0xFFFF); + gSaveContext.save.unk_E88[arg0 >> 1] = (gSaveContext.save.unk_E88[arg0 >> 1] & 0xFFFF0000) | (arg1 & 0xFFFF); } else { - gSaveContext.unk_E88[arg0 >> 1] = (gSaveContext.unk_E88[arg0 >> 1] & 0xFFFF) | ((arg1 & 0xFFFF) << 0x10); + gSaveContext.save.unk_E88[arg0 >> 1] = + (gSaveContext.save.unk_E88[arg0 >> 1] & 0xFFFF) | ((arg1 & 0xFFFF) << 0x10); } } @@ -638,19 +641,19 @@ s32 func_80B43A24(s32 arg0) { u32 phi_v1; if ((arg0 & 1) == 0) { - phi_v1 = gSaveContext.unk_E88[arg0 >> 1] & 0xFFFF; + phi_v1 = gSaveContext.save.unk_E88[arg0 >> 1] & 0xFFFF; } else { - phi_v1 = (gSaveContext.unk_E88[arg0 >> 1] & 0xFFFF0000) >> 0x10; + phi_v1 = (gSaveContext.save.unk_E88[arg0 >> 1] & 0xFFFF0000) >> 0x10; } return phi_v1 + 0x1AAA; } void func_80B43A74(s32 arg0) { - gSaveContext.unk_E88[4] = (gSaveContext.unk_E88[4] & ~0xFF) | (arg0 & 0xFF); + gSaveContext.save.unk_E88[4] = (gSaveContext.save.unk_E88[4] & ~0xFF) | (arg0 & 0xFF); } s32 func_80B43A9C(void) { - return (gSaveContext.unk_E88[4] >> 0) & 0xFF; + return (gSaveContext.save.unk_E88[4] >> 0) & 0xFF; } s32 func_80B43AB0(void) { @@ -664,7 +667,7 @@ s32 func_80B43AB0(void) { } void func_80B43AF0(s32 arg0) { - s32 currentTime = gSaveContext.time; + s32 currentTime = gSaveContext.save.time; if (((CURRENT_DAY == 1) && (currentTime >= CLOCK_TIME(2, 30))) && (currentTime < CLOCK_TIME(5, 15))) { s32 adjustment = (0xC - func_80B43A9C()) * 25.0f; @@ -872,7 +875,7 @@ s32 func_80B44234(EnInvadepoh* this, Vec3f* vec) { void func_80B442E4(EnInvadepoh* this) { s32 pad; - s32 sp18 = gSaveContext.time; + s32 sp18 = gSaveContext.save.time; s32 temp_v1_2 = sp18 - func_80B43A24(this->actor.params & 7); if (D_80B4E940 == 1) { @@ -945,7 +948,7 @@ void func_80B44540(EnInvadepoh* this, GlobalContext* globalCtx) { } void func_80B44570(EnInvadepoh* this) { - s32 currentTime = gSaveContext.time; + s32 currentTime = gSaveContext.save.time; if ((currentTime < CLOCK_TIME(2, 0)) || (currentTime >= CLOCK_TIME(6, 0))) { this->clockTime = 0.0f; @@ -989,7 +992,7 @@ void func_80B446D0(EnInvadepoh* this, GlobalContext* globalCtx) { } void func_80B44700(EnInvadepoh* this) { - s32 currentTime = gSaveContext.time; + s32 currentTime = gSaveContext.save.time; s32 new_var4 = 0xFFFF2AAB; if ((currentTime < CLOCK_TIME(20, 0)) && (currentTime >= CLOCK_TIME(6, 0))) { @@ -1262,7 +1265,7 @@ void func_80B451A0(EnInvadepoh* this, GlobalContext* globalCtx) { if (CURRENT_DAY <= 0) { D_80B4E940 = 1; } else if (CURRENT_DAY == 1) { - currentTime = gSaveContext.time; + currentTime = gSaveContext.save.time; if ((currentTime < CLOCK_TIME(2, 30)) || (currentTime >= CLOCK_TIME(6, 0))) { D_80B4E940 = 1; } else if (currentTime < CLOCK_TIME(5, 15)) { @@ -1283,7 +1286,7 @@ void func_80B451A0(EnInvadepoh* this, GlobalContext* globalCtx) { } if (D_80B4E940 == 0) { - if (gSaveContext.weekEventReg[22] & 1) { + if (gSaveContext.save.weekEventReg[22] & 1) { D_80B4E940 = 3; } else { D_80B4E940 = 4; @@ -1648,7 +1651,7 @@ void func_80B4627C(EnInvadepoh* this, GlobalContext* globalCtx) { if (D_80B4E940 == 1) { func_80B46DA8(this); } else if (D_80B4E940 == 2) { - if (gSaveContext.time < CLOCK_TIME(2, 31)) { + if (gSaveContext.save.time < CLOCK_TIME(2, 31)) { func_80B46DA8(this); } else { func_80B454BC(this, globalCtx); @@ -1657,10 +1660,10 @@ void func_80B4627C(EnInvadepoh* this, GlobalContext* globalCtx) { func_80B46F88(this); } } else if (D_80B4E940 == 3) { - if (gSaveContext.entranceIndex == 0x6460) { + if (gSaveContext.save.entranceIndex == 0x6460) { func_80B471C0(this); - } else if (gSaveContext.entranceIndex == 0x6470) { + } else if (gSaveContext.save.entranceIndex == 0x6470) { func_80B47248(this); } else { func_80B47248(this); @@ -1747,23 +1750,23 @@ void EnInvadepoh_InitRomani(EnInvadepoh* this, GlobalContext* globalCtx) { Actor_MarkForDeath(&this->actor); } if (temp == 5) { - if (gSaveContext.weekEventReg[22] & 1) { + if (gSaveContext.save.weekEventReg[22] & 1) { Actor_MarkForDeath(&this->actor); return; } } else if (temp == 7) { - if (gSaveContext.time < CLOCK_TIME(6, 0) && gSaveContext.time >= CLOCK_TIME(2, 15)) { + if (gSaveContext.save.time < CLOCK_TIME(6, 0) && gSaveContext.save.time >= CLOCK_TIME(2, 15)) { Actor_MarkForDeath(&this->actor); return; } } else if (temp != 8) { if (temp == 9) { - if (gSaveContext.entranceIndex != 0x6460) { + if (gSaveContext.save.entranceIndex != 0x6460) { Actor_MarkForDeath(&this->actor); return; } } else if (temp == 0xC) { - if (!(gSaveContext.weekEventReg[22] & 1)) { + if (!(gSaveContext.save.weekEventReg[22] & 1)) { Actor_MarkForDeath(&this->actor); } D_80B503F4 = this; @@ -1776,7 +1779,7 @@ void func_80B468B4(EnInvadepoh* this, GlobalContext* globalCtx) { this->actor.update = func_80B49B1C; this->actor.draw = func_80B4E3F0; func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_NPC); - if (D_80B4E940 == 1 || gSaveContext.time < CLOCK_TIME(2, 31)) { + if (D_80B4E940 == 1 || gSaveContext.save.time < CLOCK_TIME(2, 31)) { this->actor.world.pos.x += D_80B4E934.x; this->actor.world.pos.y += D_80B4E934.y + 3000.0f; this->actor.world.pos.z += D_80B4E934.z; @@ -1818,7 +1821,7 @@ void EnInvadepoh_InitCremia(EnInvadepoh* this, GlobalContext* globalCtx) { if (this->bankIndex < 0) { Actor_MarkForDeath(&this->actor); } - if (!(gSaveContext.weekEventReg[22] & 1)) { + if (!(gSaveContext.save.weekEventReg[22] & 1)) { Actor_MarkForDeath(&this->actor); } D_80B503F8 = this; @@ -1899,7 +1902,7 @@ void func_80B46DA8(EnInvadepoh* this) { } void func_80B46DC8(EnInvadepoh* this, GlobalContext* globalCtx) { - if ((gSaveContext.time < CLOCK_TIME(6, 0)) && (gSaveContext.time >= CLOCK_TIME(2, 30))) { + if ((gSaveContext.save.time < CLOCK_TIME(6, 0)) && (gSaveContext.save.time >= CLOCK_TIME(2, 30))) { func_80B454BC(this, globalCtx); func_80B452EC(this, globalCtx); func_80B46E20(this); @@ -1954,8 +1957,8 @@ void func_80B46F88(EnInvadepoh* this) { void func_80B46FA8(EnInvadepoh* this, GlobalContext* globalCtx) { s32 i; - if ((gSaveContext.time < CLOCK_TIME(6, 0)) && (gSaveContext.time >= CLOCK_TIME(5, 15))) { - gSaveContext.weekEventReg[22] |= 1; + if ((gSaveContext.save.time < CLOCK_TIME(6, 0)) && (gSaveContext.save.time >= CLOCK_TIME(5, 15))) { + gSaveContext.save.weekEventReg[22] |= 1; func_80B47064(this); } else { func_80B457A0(this); @@ -2040,7 +2043,7 @@ void func_80B47298(EnInvadepoh* this, GlobalContext* globalCtx) { globalCtx->sceneLoadFlag = 0x14; globalCtx->unk_1887F = 0x48; gSaveContext.nextTransition = 0x48; - gSaveContext.weekEventReg[89] |= 0x10; + gSaveContext.save.weekEventReg[89] |= 0x10; func_80B47304(this); } @@ -2289,7 +2292,7 @@ void func_80B47BAC(Actor* thisx, GlobalContext* globalCtx) { func_80B447C0(this, globalCtx); func_80B43F0C(this); func_80B4516C(this); - if (D_80B4E940 == 1 || gSaveContext.time < CLOCK_TIME(2, 31)) { + if (D_80B4E940 == 1 || gSaveContext.save.time < CLOCK_TIME(2, 31)) { func_80B47380(this); } else if (D_80B4E940 == 2) { if (this->clockTime >= 0.0001f) { @@ -3061,7 +3064,7 @@ void func_80B49DFC(EnInvadepoh* this, GlobalContext* globalCtx) { substruct->unk26.y = CLAMP(temp_v1, -0x1F40, 0x1F40); if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { if (this->actor.textId == 0x332D) { - gSaveContext.weekEventReg[54] |= 0x10; + gSaveContext.save.weekEventReg[54] |= 0x10; this->actor.textId = 0x332E; } func_80B49BD0(this); @@ -3074,7 +3077,7 @@ void func_80B49F88(Actor* thisx, GlobalContext* globalCtx) { s32 sp38; if (Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)) { - sp38 = gSaveContext.time; + sp38 = gSaveContext.save.time; this->actor.objBankIndex = this->bankIndex; Actor_SetObjectDependency(globalCtx, &this->actor); func_80B44F58(); @@ -3086,8 +3089,8 @@ void func_80B49F88(Actor* thisx, GlobalContext* globalCtx) { func_80B44C24(this, globalCtx); func_80B43F0C(this); func_80B4516C(this); - if (0x20 & gSaveContext.weekEventReg[21]) { - if (gSaveContext.weekEventReg[54] & 0x10) { + if (0x20 & gSaveContext.save.weekEventReg[21]) { + if (gSaveContext.save.weekEventReg[54] & 0x10) { this->actor.textId = 0x332E; } else { this->actor.textId = 0x332D; @@ -3113,7 +3116,7 @@ void func_80B49F88(Actor* thisx, GlobalContext* globalCtx) { void func_80B4A168(Actor* thisx, GlobalContext* globalCtx) { EnInvadepoh* this = THIS; - if ((gSaveContext.time < CLOCK_TIME(6, 0)) && (gSaveContext.time >= CLOCK_TIME(2, 0))) { + if ((gSaveContext.save.time < CLOCK_TIME(6, 0)) && (gSaveContext.save.time >= CLOCK_TIME(2, 0))) { this->actor.update = func_80B4A1B8; this->actor.draw = func_80B4E324; func_80B49BD0(this); @@ -3288,7 +3291,7 @@ void func_80B4A81C(EnInvadepoh* this, GlobalContext* globalCtx) { if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { if (this->actor.textId == 0x332D) { - gSaveContext.weekEventReg[54] |= 0x10; + gSaveContext.save.weekEventReg[54] |= 0x10; this->actor.textId = 0x332E; } if (this->pathIndex == this->endPoint) { @@ -3305,7 +3308,7 @@ void func_80B4A9C8(Actor* thisx, GlobalContext* globalCtx) { s32 sp38; if (Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)) { - sp38 = gSaveContext.time; + sp38 = gSaveContext.save.time; this->actor.objBankIndex = this->bankIndex; Actor_SetObjectDependency(globalCtx, &this->actor); func_80B44F58(); @@ -3327,8 +3330,8 @@ void func_80B4A9C8(Actor* thisx, GlobalContext* globalCtx) { func_80B43F0C(this); func_800B4AEC(globalCtx, &this->actor, 50.0f); func_80B4516C(this); - if (gSaveContext.weekEventReg[21] & 0x20) { - if (gSaveContext.weekEventReg[54] & 0x10) { + if (gSaveContext.save.weekEventReg[21] & 0x20) { + if (gSaveContext.save.weekEventReg[54] & 0x10) { this->actor.textId = 0x332E; } else { this->actor.textId = 0x332D; @@ -3342,7 +3345,7 @@ void func_80B4A9C8(Actor* thisx, GlobalContext* globalCtx) { void func_80B4AB8C(Actor* thisx, GlobalContext* globalCtx) { EnInvadepoh* this = THIS; - if ((gSaveContext.time < CLOCK_TIME(6, 0)) && (gSaveContext.time >= CLOCK_TIME(2, 15))) { + if ((gSaveContext.save.time < CLOCK_TIME(6, 0)) && (gSaveContext.save.time >= CLOCK_TIME(2, 15))) { this->actor.update = func_80B4ABDC; this->actor.draw = func_80B4E324; func_80B4A614(this); @@ -3376,7 +3379,7 @@ void func_80B4ACDC(EnInvadepoh* this) { } void func_80B4ACF0(EnInvadepoh* this, GlobalContext* globalCtx) { - if (gSaveContext.weekEventReg[22] & 1) { + if (gSaveContext.save.weekEventReg[22] & 1) { this->actor.draw = func_80B4E324; this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); func_80B4AD3C(this); @@ -3402,9 +3405,9 @@ void func_80B4ADB8(EnInvadepoh* this) { } void func_80B4ADCC(EnInvadepoh* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { if (this->textId == 0x3331) { - if (gSaveContext.weekEventReg[22] & 2) { + if (gSaveContext.save.weekEventReg[22] & 2) { EnInvadepoh_SetTextID(this, globalCtx, 0x3334); func_80151BB4(globalCtx, 0x1D); func_80151BB4(globalCtx, 5); @@ -3436,7 +3439,7 @@ void func_80B4AEDC(EnInvadepoh* this, GlobalContext* globalCtx) { } if (Actor_HasParent(&this->actor, globalCtx)) { this->actor.parent = NULL; - gSaveContext.weekEventReg[22] |= 2; + gSaveContext.save.weekEventReg[22] |= 2; func_80B4AF80(this); } else { Actor_PickUp(&this->actor, globalCtx, GI_MILK_BOTTLE, 2000.0f, 2000.0f); @@ -3533,7 +3536,7 @@ void func_80B4B3DC(EnInvadepoh* this) { } void func_80B4B430(EnInvadepoh* this) { - Animation_MorphToLoop(&this->skelAnime, &object_dog_Anim_0021C8, -6.0f); + Animation_MorphToLoop(&this->skelAnime, &gDogWalkAnim, -6.0f); this->actionTimer = Rand_S16Offset(50, 80); this->actionFunc = func_80B4B484; } @@ -3556,7 +3559,7 @@ void func_80B4B484(EnInvadepoh* this, GlobalContext* globalCtx) { } void func_80B4B510(EnInvadepoh* this) { - Animation_MorphToLoop(&this->skelAnime, &object_dog_Anim_001BD8, -6.0f); + Animation_MorphToLoop(&this->skelAnime, &gDogRunAnim, -6.0f); this->actionTimer = Rand_S16Offset(50, 200); this->actionFunc = func_80B4B564; } @@ -3600,7 +3603,7 @@ void func_80B4B564(EnInvadepoh* this, GlobalContext* globalCtx) { } void func_80B4B724(EnInvadepoh* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_dog_Anim_000998, -6.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &gDogBarkAnim, -6.0f); this->actionFunc = func_80B4B768; } @@ -3620,7 +3623,7 @@ void func_80B4B768(EnInvadepoh* this, GlobalContext* globalCtx) { } void func_80B4B820(EnInvadepoh* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_dog_Anim_001560, -6.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &gDogJumpAnim, -6.0f); this->actionFunc = func_80B4B864; } @@ -3639,8 +3642,8 @@ void func_80B4B8BC(Actor* thisx, GlobalContext* globalCtx) { if (Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)) { this->actor.objBankIndex = this->bankIndex; Actor_SetObjectDependency(globalCtx, &this->actor); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_dog_Skel_0080F0, &object_dog_Anim_0021C8, - this->jointTable, this->morphTable, 13); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gDogSkel, &gDogWalkAnim, this->jointTable, this->morphTable, + DOG_LIMB_MAX); func_80B45C04(&this->behaviorInfo, 0, 0, 0, 0, &gZeroVec3s, 3000, 0.1f, 0.0f, 0.0f); func_80B44664(this, globalCtx); EnInvadepoh_SetPathPointToWorldPos(this, 0); @@ -3791,7 +3794,7 @@ void func_80B4BC4C(EnInvadepoh* this, GlobalContext* globalCtx) { (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 12.0f))) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_ROMANI_WALK); } - if (gSaveContext.time > CLOCK_TIME(20, 15)) { + if (gSaveContext.save.time > CLOCK_TIME(20, 15)) { Actor_MarkForDeath(&this->actor); } else if ((temp_t6 != NULL) && (temp_t6->actionFunc == func_80B4CB0C)) { func_80B4C1BC(this); @@ -3868,7 +3871,7 @@ void func_80B4C3A0(Actor* thisx, GlobalContext* globalCtx) { if (Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)) { s32 pad[2]; - s32 currentTime = gSaveContext.time; + s32 currentTime = gSaveContext.save.time; this->actor.objBankIndex = this->bankIndex; Actor_SetObjectDependency(globalCtx, &this->actor); @@ -3904,7 +3907,7 @@ void func_80B4C3A0(Actor* thisx, GlobalContext* globalCtx) { void func_80B4C568(Actor* thisx, GlobalContext* globalCtx) { EnInvadepoh* this = THIS; - if ((gSaveContext.time >= 0xD573) && (gSaveContext.time < CLOCK_TIME(20, 15))) { + if ((gSaveContext.save.time >= 0xD573) && (gSaveContext.save.time < CLOCK_TIME(20, 15))) { this->actor.update = func_80B4C5C0; this->actor.draw = func_80B4E7BC; func_80B4BBE0(this); @@ -3955,21 +3958,14 @@ void func_80B4C730(EnInvadepoh* this, GlobalContext* globalCtx) { Vec3f sp4C; Vec3f sp40; s16 diff; - s8 temp_v1; + s16 pad; s16 sp3A; - s8 temp_v0; + s16 pad2; func_80B44700(this); func_80B44EFC(this, globalCtx); func_80B43E6C(this, 6, 2000, 100); - if (1) {} - temp_v1 = this->pathIndex; - temp_v0 = this->endPoint; - phi_a2 = temp_v0 - 1; - if (temp_v1 < temp_v0) { - phi_a2 = temp_v1; - } else if (temp_v1_3) { - } + phi_a2 = ((this->pathIndex < this->endPoint) ? this->pathIndex : this->endPoint - 1); Math_Vec3s_ToVec3f(&sp4C, &this->pathPoints[phi_a2]); Math_Vec3s_ToVec3f(&sp40, &this->pathPoints[phi_a2 + 1]); @@ -4089,7 +4085,7 @@ void func_80B4CE54(Actor* thisx, GlobalContext* globalCtx) { s32 sp38; if (Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)) { - sp38 = gSaveContext.time; + sp38 = gSaveContext.save.time; this->actor.objBankIndex = this->bankIndex; Actor_SetObjectDependency(globalCtx, &this->actor); @@ -4120,7 +4116,7 @@ void func_80B4CE54(Actor* thisx, GlobalContext* globalCtx) { void func_80B4CFFC(Actor* thisx, GlobalContext* globalCtx) { EnInvadepoh* this = THIS; - if ((gSaveContext.time >= CLOCK_TIME(20, 0)) && (gSaveContext.time < 0xD7E1)) { + if ((gSaveContext.save.time >= CLOCK_TIME(20, 0)) && (gSaveContext.save.time < 0xD7E1)) { this->actor.update = func_80B4D054; this->actor.draw = func_80B4E324; func_80B4C6C8(this); @@ -4552,7 +4548,8 @@ void func_80B4E3F0(Actor* thisx, GlobalContext* globalCtx) { } s32 func_80B4E5B0(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { - if ((limbIndex == 5) || (limbIndex == 6) || (limbIndex == 7)) { + if ((limbIndex == DOG_LIMB_HEAD) || (limbIndex == DOG_LIMB_RIGHT_FACE_HAIR) || + (limbIndex == DOG_LIMB_LEFT_FACE_HAIR)) { EnInvadepoh* this = THIS; rot->x += this->behaviorInfo.unk20.x; @@ -4566,7 +4563,7 @@ s32 func_80B4E5B0(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* p void func_80B4E61C(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnInvadepoh* this = THIS; - if (limbIndex == 5) { + if (limbIndex == DOG_LIMB_HEAD) { Matrix_GetStateTranslationAndScaledY(20.0f, &this->actor.focus.pos); } } diff --git a/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c b/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c index 99d19a1cf7..ac42d0c7aa 100644 --- a/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c +++ b/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c @@ -255,7 +255,7 @@ void func_8095DABC(Actor* thisx, GlobalContext* globalCtx) { } EffectSsKakera_Spawn(globalCtx, &spCC, &spD8, &this->actor.world.pos, phi_v1, phi_v0, 30, 5, 0, D_8095F758[i], - 5, 2, 70, 0, 2, gameplay_field_keep_DL_006420); + 5, 2, 70, 0, GAMEPLAY_FIELD_KEEP, gameplay_field_keep_DL_006420); } } diff --git a/src/overlays/actors/ovl_En_Ja/z_en_ja.c b/src/overlays/actors/ovl_En_Ja/z_en_ja.c index b31436bb46..b02b6f4ee8 100644 --- a/src/overlays/actors/ovl_En_Ja/z_en_ja.c +++ b/src/overlays/actors/ovl_En_Ja/z_en_ja.c @@ -22,8 +22,16 @@ void func_80BC2EA4(EnJa* this); void func_80BC32D8(EnJa* this, GlobalContext* globalCtx); void func_80BC3594(EnJa* this, GlobalContext* globalCtx); -s32 D_80BC35F0[] = { - 0x0C000301, 0x05020600, 0x1200080A, 0x00610304, 0x0002050A, 0x006C0304, 0x00010500, +static u8 D_80BC35F0[] = { + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(3, 0x05 - 0x04), + /* 0x04 */ SCHEDULE_CMD_RET_NONE(), + /* 0x05 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(6, 0, 18, 0, 0x13 - 0x0B), + /* 0x0B */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_YADOYA, 0x12 - 0x0F), + /* 0x0F */ SCHEDULE_CMD_RET_VAL_L(2), + /* 0x12 */ SCHEDULE_CMD_RET_NONE(), + /* 0x13 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_TOWN, 0x1A - 0x17), + /* 0x17 */ SCHEDULE_CMD_RET_VAL_L(1), + /* 0x1A */ SCHEDULE_CMD_RET_NONE(), }; s32 D_80BC360C[] = { @@ -211,7 +219,7 @@ void func_80BC1E40(EnJa* this, GlobalContext* globalCtx) { s32 sp20 = Message_GetState(&globalCtx->msgCtx); f32 phi_f0; - if (((globalCtx->msgCtx.unk11F04 < 0xFF) || (globalCtx->msgCtx.unk11F04 > 0x200)) && (sp20 == 3) && + if (((globalCtx->msgCtx.currentTextId < 0xFF) || (globalCtx->msgCtx.currentTextId > 0x200)) && (sp20 == 3) && (this->unk_374 == 3) && (&this->actor == player->targetActor)) { if ((globalCtx->state.frames % 2) == 0) { if (this->unk_348 != 0.0f) { @@ -231,7 +239,7 @@ void func_80BC1E40(EnJa* this, GlobalContext* globalCtx) { this->unk_374 = sp20; } -s32 func_80BC1FC8(EnJa* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BC1FC8(EnJa* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret = false; if (func_80BC1AE0(this, globalCtx)) { @@ -244,7 +252,7 @@ s32 func_80BC1FC8(EnJa* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80BC203C(EnJa* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BC203C(EnJa* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret = false; if (func_80BC1AE0(this, globalCtx)) { @@ -261,12 +269,12 @@ s32 func_80BC203C(EnJa* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80BC20D0(EnJa* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BC20D0(EnJa* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret = false; this->unk_340 = 0; - switch (arg2->unk0) { + switch (arg2->result) { case 1: ret = func_80BC1FC8(this, globalCtx, arg2); if (ret == 1) {} @@ -291,20 +299,19 @@ void func_80BC2150(EnJa* this, GlobalContext* globalCtx) { } void func_80BC21A8(EnJa* this, GlobalContext* globalCtx) { - u32* unk_14 = &gSaveContext.unk_14; - struct_80133038_arg2 sp18; + ScheduleResult sp18; - this->unk_35C = REG(15) + *unk_14; - if (!func_80133038(globalCtx, D_80BC35F0, &sp18) || - ((this->unk_1D8.unk_00 != sp18.unk0) && !func_80BC20D0(this, globalCtx, &sp18))) { + this->unk_35C = REG(15) + ((void)0, gSaveContext.save.daySpeed); + if (!Schedule_RunScript(globalCtx, D_80BC35F0, &sp18) || + ((this->unk_1D8.unk_00 != sp18.result) && !func_80BC20D0(this, globalCtx, &sp18))) { this->actor.shape.shadowDraw = NULL; this->actor.flags &= ~ACTOR_FLAG_1; - sp18.unk0 = 0; + sp18.result = 0; } else { this->actor.shape.shadowDraw = ActorShadow_DrawCircle; this->actor.flags |= ACTOR_FLAG_1; } - this->unk_1D8.unk_00 = sp18.unk0; + this->unk_1D8.unk_00 = sp18.result; func_80BC2150(this, globalCtx); } @@ -379,7 +386,7 @@ void EnJa_Update(Actor* thisx, GlobalContext* globalCtx) { radius = this->collider.dim.radius + 30; height = this->collider.dim.height + 10; - func_8013C964(&this->actor, globalCtx, radius, height, 0, this->unk_340 & 7); + func_8013C964(&this->actor, globalCtx, radius, height, EXCH_ITEM_NONE, this->unk_340 & 7); if (this->unk_1D8.unk_00 != 2) { Actor_MoveWithGravity(&this->actor); diff --git a/src/overlays/actors/ovl_En_Jc_Mato/z_en_jc_mato.c b/src/overlays/actors/ovl_En_Jc_Mato/z_en_jc_mato.c index 8051f71f4c..4e50ceba60 100644 --- a/src/overlays/actors/ovl_En_Jc_Mato/z_en_jc_mato.c +++ b/src/overlays/actors/ovl_En_Jc_Mato/z_en_jc_mato.c @@ -95,7 +95,7 @@ s32 EnJcMato_CheckForHit(EnJcMato* this, GlobalContext* globalCtx) { this->collider.base.acFlags &= ~AC_HIT; Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); globalCtx->interfaceCtx.unk_25C = 1; - this->hitFlag = 1; + this->hitFlag = true; return 1; } else { CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); @@ -111,7 +111,7 @@ void EnJcMato_SetupIdle(EnJcMato* this) { void EnJcMato_Idle(EnJcMato* this, GlobalContext* globalCtx) { s16 shouldDespawn; - if (this->hitFlag != 0) { + if (this->hitFlag) { if (this->despawnTimer == 0) { shouldDespawn = 0; } else { @@ -133,7 +133,7 @@ void EnJcMato_Init(Actor* thisx, GlobalContext* globalCtx) { this->collider.dim.worldSphere.radius = 0xF; this->actor.colChkInfo.damageTable = &sDamageTable; Actor_SetScale(&this->actor, 0.008f); - this->hitFlag = 0; + this->hitFlag = false; this->despawnTimer = 25; EnJcMato_SetupIdle(this); } diff --git a/src/overlays/actors/ovl_En_Jg/z_en_jg.c b/src/overlays/actors/ovl_En_Jg/z_en_jg.c index 7797f2ad40..9412e55948 100644 --- a/src/overlays/actors/ovl_En_Jg/z_en_jg.c +++ b/src/overlays/actors/ovl_En_Jg/z_en_jg.c @@ -358,7 +358,7 @@ void EnJg_GoronShrineIdle(EnJg* this, GlobalContext* globalCtx) { } void EnJg_GoronShrineTalk(EnJg* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && (func_80147624(globalCtx))) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && (Message_ShouldAdvance(globalCtx))) { if ((this->textId == 0xDCC) || (this->textId == 0xDDD) || (this->textId == 0xDE0)) { // There is nothing more to say after these lines, so end the current conversation. globalCtx->msgCtx.msgMode = 0x43; @@ -425,7 +425,7 @@ void EnJg_AlternateTalkOrWalkInPlace(EnJg* this, GlobalContext* globalCtx) { SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); } } else if (this->animationIndex == EN_JG_ANIMATION_SURPRISE_LOOP) { - if ((messageState == 5) && (func_80147624(globalCtx))) { + if ((messageState == 5) && (Message_ShouldAdvance(globalCtx))) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; this->flags &= ~FLAG_LOOKING_AT_PLAYER; @@ -480,7 +480,7 @@ void EnJg_Talk(EnJg* this, GlobalContext* globalCtx) { SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); } - if ((messageState == 5) && (func_80147624(globalCtx))) { + if ((messageState == 5) && (Message_ShouldAdvance(globalCtx))) { temp = this->textId; if ((temp == 0xDB4) || (temp == 0xDB5) || (temp == 0xDC4) || (temp == 0xDC6)) { // There is nothing more to say after these lines, so end the current conversation. @@ -493,14 +493,14 @@ void EnJg_Talk(EnJg* this, GlobalContext* globalCtx) { temp = this->textId; if ((temp == 0xDBB) || (temp == 0xDBC)) { - if (!(gSaveContext.weekEventReg[24] & 0x80)) { + if (!(gSaveContext.save.weekEventReg[24] & 0x80)) { // The player hasn't talked to the Goron Child at least once, so they can't learn // the Lullaby Intro. End the current conversation with the player. globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; this->flags &= ~FLAG_LOOKING_AT_PLAYER; this->actionFunc = EnJg_SetupWalk; - } else if (((gSaveContext.weekEventReg[24] & 0x40)) || + } else if (((gSaveContext.save.weekEventReg[24] & 0x40)) || (CHECK_QUEST_ITEM(QUEST_SONG_LULLABY) || CHECK_QUEST_ITEM(QUEST_SONG_LULLABY_INTRO))) { // The player already has the Lullaby or Lullaby Intro, so say "I'm counting on you" this->textId = EnJg_GetNextTextId(this); @@ -600,7 +600,7 @@ void EnJg_FrozenIdle(EnJg* this, GlobalContext* globalCtx) { } void EnJg_EndFrozenInteraction(EnJg* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx) != 0) { + if (Message_GetState(&globalCtx->msgCtx) == 6 && Message_ShouldAdvance(globalCtx) != 0) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; this->actionFunc = EnJg_FrozenIdle; @@ -700,7 +700,7 @@ void EnJg_LullabyIntroCutsceneAction(EnJg* this, GlobalContext* globalCtx) { } else { this->csAction = 99; this->freezeTimer = 1000; - gSaveContext.weekEventReg[24] |= 0x40; + gSaveContext.save.weekEventReg[24] |= 0x40; this->actionFunc = EnJg_Idle; } } @@ -830,7 +830,7 @@ s32 EnJg_GetNextTextId(EnJg* this) { return 0xDDC; // Everyone would accept you case 0xDDC: // Everyone would accept you - gSaveContext.weekEventReg[77] |= 0x80; + gSaveContext.save.weekEventReg[77] |= 0x80; return 0xDDD; // Think it over slowly default: @@ -848,7 +848,7 @@ s32 EnJg_GetStartingConversationTextId(EnJg* this, GlobalContext* globalCtx) { if (!EN_JG_IS_IN_GORON_SHRINE(&this->actor)) { if (player->transformation == PLAYER_FORM_GORON) { - if ((gSaveContext.weekEventReg[24] & 0x10) || CHECK_QUEST_ITEM(QUEST_SONG_LULLABY) || + if ((gSaveContext.save.weekEventReg[24] & 0x10) || CHECK_QUEST_ITEM(QUEST_SONG_LULLABY) || CHECK_QUEST_ITEM(QUEST_SONG_LULLABY_INTRO)) { // The player has already talked as a Goron at least once. return 0xDBC; // Following me won't do you any good @@ -858,7 +858,7 @@ s32 EnJg_GetStartingConversationTextId(EnJg* this, GlobalContext* globalCtx) { return 0xDB6; // "Hunh???" } - if (gSaveContext.weekEventReg[24] & 0x20) { + if (gSaveContext.save.weekEventReg[24] & 0x20) { // The player has already talked as a non-Goron at least once. return 0xDB5; // This is our problem (repeat) } @@ -868,7 +868,7 @@ s32 EnJg_GetStartingConversationTextId(EnJg* this, GlobalContext* globalCtx) { } if (player->transformation == PLAYER_FORM_GORON) { - if (gSaveContext.weekEventReg[77] & 0x80) { + if (gSaveContext.save.weekEventReg[77] & 0x80) { // The player has heard the Goron Shrine cheer as a Goron at least once. return 0xDDE; // Come back after entering the race } @@ -908,9 +908,9 @@ void EnJg_CheckIfTalkingToPlayerAndHandleFreezeTimer(EnJg* this, GlobalContext* if (this->textId == 0xDAC) { this->action = EN_JG_ACTION_FIRST_THAW; } else if (this->textId == 0xDAE) { - gSaveContext.weekEventReg[24] |= 0x20; + gSaveContext.save.weekEventReg[24] |= 0x20; } else if (this->textId == 0xDB6) { - gSaveContext.weekEventReg[24] |= 0x10; + gSaveContext.save.weekEventReg[24] |= 0x10; } Message_StartTextbox(globalCtx, this->textId, &this->actor); @@ -957,7 +957,7 @@ void EnJg_Init(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc = EnJg_LullabyIntroCutsceneAction; } else { // This is the elder that appears in Mountain Village or the Path to Goron Village in winter. - this->path = func_8013D648(globalCtx, EN_JG_GET_PATH(thisx), 0x3F); + this->path = SubS_GetPathByIndex(globalCtx, EN_JG_GET_PATH(thisx), 0x3F); this->animationIndex = EN_JG_ANIMATION_SURPRISE_START; this->action = EN_JG_ACTION_SPAWNING; this->freezeTimer = 1000; diff --git a/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c b/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c index 8218d7c632..104e2bc3c7 100644 --- a/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c +++ b/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c @@ -5,6 +5,7 @@ */ #include "z_en_jgame_tsn.h" +#include "overlays/actors/ovl_Obj_Jgame_Light/z_obj_jgame_light.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_2000000) @@ -15,7 +16,26 @@ void EnJgameTsn_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnJgameTsn_Update(Actor* thisx, GlobalContext* globalCtx); void EnJgameTsn_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80C13A2C(EnJgameTsn* this, GlobalContext* globalCtx); +void func_80C13B74(EnJgameTsn* this); +void func_80C13BB8(EnJgameTsn* this, GlobalContext* globalCtx); +void func_80C13E6C(EnJgameTsn* this); +void func_80C13E90(EnJgameTsn* this, GlobalContext* globalCtx); +void func_80C13F9C(EnJgameTsn* this, GlobalContext* globalCtx); +void func_80C14030(EnJgameTsn* this); +void func_80C14044(EnJgameTsn* this, GlobalContext* globalCtx); +void func_80C1418C(EnJgameTsn* this, GlobalContext* globalCtx); +void func_80C141DC(EnJgameTsn* this); +void func_80C14230(EnJgameTsn* this, GlobalContext* globalCtx); +void func_80C144F8(EnJgameTsn* this, GlobalContext* globalCtx); +void func_80C14554(EnJgameTsn* this, GlobalContext* globalCtx); +void func_80C145FC(EnJgameTsn* this); +void func_80C14610(EnJgameTsn* this, GlobalContext* globalCtx); +void func_80C14684(EnJgameTsn* this, GlobalContext* globalCtx); +void func_80C147B4(EnJgameTsn* this, GlobalContext* globalCtx); +s32 func_80C149B0(GlobalContext* globalCtx, EnJgameTsnStruct* arg1); +s32 func_80C14BCC(EnJgameTsn* this, GlobalContext* globalCtx); + const ActorInit En_Jgame_Tsn_InitVars = { ACTOR_EN_JGAME_TSN, ACTORCAT_NPC, @@ -28,81 +48,600 @@ const ActorInit En_Jgame_Tsn_InitVars = { (ActorFunc)EnJgameTsn_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80C15078 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_ENEMY, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static AnimationInfo sAnimations[] = { + { &object_tsn_Anim_0092FC, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -6.0f }, + { &object_tsn_Anim_000964, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -6.0f }, + { &object_tsn_Anim_001198, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -6.0f }, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_ENEMY, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 30, 40, 0, { 0, 0, 0 } }, }; -#endif +TexturePtr D_80C150A4[] = { + object_tsn_Tex_0073B8, + object_tsn_Tex_0085B8, +}; -extern ColliderCylinderInit D_80C15078; +void EnJgameTsn_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnJgameTsn* this = THIS; -extern UNK_TYPE D_060092FC; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_tsn_Skel_008AB8, &object_tsn_Anim_0092FC, this->jointTable, + this->morphTable, OBJECT_TSN_LIMB_MAX); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/EnJgameTsn_Init.s") + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C13A2C.s") + this->actor.targetMode = 6; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->actor.velocity.y = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/EnJgameTsn_Destroy.s") + if (gSaveContext.save.entranceIndex == 0x68D0) { + this->actor.flags |= ACTOR_FLAG_10000; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C13B74.s") + this->unk_2F8 = 0; + this->unk_2FA = 0; + this->unk_21C = 0; + this->unk_2FE = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C13BB8.s") + func_80C13A2C(this, globalCtx); + func_80C13B74(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C13E6C.s") +void func_80C13A2C(EnJgameTsn* this, GlobalContext* globalCtx) { + Path* path = &globalCtx->setupPathList[ENJGAMETSN_GET_FF(&this->actor)]; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C13E90.s") + if (path == NULL) { + Actor_MarkForDeath(&this->actor); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C13F88.s") + for (i = 0; i < ARRAY_COUNT(this->unk_1D8); i++) { + this->unk_1D8[i].points = Lib_SegmentedToVirtual(path->points); + this->unk_1D8[i].count = path->count; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C13F9C.s") + path = &globalCtx->setupPathList[path->unk1]; + if (path == NULL) { + Actor_MarkForDeath(&this->actor); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C14030.s") + this->unk_1F8.points = Lib_SegmentedToVirtual(path->points); + this->unk_1F8.count = path->count; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C14044.s") + path = &globalCtx->setupPathList[path->unk1]; + if (path == NULL) { + Actor_MarkForDeath(&this->actor); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C1410C.s") + this->unk_200.points = Lib_SegmentedToVirtual(path->points); + this->unk_200.count = path->count; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C1418C.s") +void EnJgameTsn_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnJgameTsn* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C141DC.s") + Collider_DestroyCylinder(globalCtx, &this->collider); + gSaveContext.save.weekEventReg[90] &= (u8)~0x20; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C14230.s") +void func_80C13B74(EnJgameTsn* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + this->actionFunc = func_80C13BB8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C144E4.s") +void func_80C13BB8(EnJgameTsn* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C144F8.s") + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (this->actor.flags & ACTOR_FLAG_10000) { + this->actor.flags &= ~ACTOR_FLAG_10000; + if (gSaveContext.unk_3DE0[4] > 0) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + Message_StartTextbox(globalCtx, 0x10A2, &this->actor); + this->unk_300 = 0x10A2; + } else if (gSaveContext.minigameScore < 20) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + Message_StartTextbox(globalCtx, 0x10A2, &this->actor); + this->unk_300 = 0x10A2; + } else { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + Message_StartTextbox(globalCtx, 0x10A3, &this->actor); + this->unk_300 = 0x10A3; + } + } else if (((gSaveContext.save.time > CLOCK_TIME(4, 0)) && (gSaveContext.save.time < CLOCK_TIME(7, 0))) || + ((gSaveContext.save.time > CLOCK_TIME(16, 0)) && (gSaveContext.save.time < CLOCK_TIME(19, 0)))) { + Message_StartTextbox(globalCtx, 0x1094, &this->actor); + this->unk_300 = 0x1094; + } else if (this->unk_2F8 == 0) { + this->unk_2F8 = 1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + Message_StartTextbox(globalCtx, 0x1095, &this->actor); + this->unk_300 = 0x1095; + } else { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + Message_StartTextbox(globalCtx, 0x1096, &this->actor); + this->unk_300 = 0x1096; + } + func_80C14030(this); + } else if (this->actor.flags & ACTOR_FLAG_10000) { + func_800B8614(&this->actor, globalCtx, 200.0f); + } else { + func_800B8614(&this->actor, globalCtx, 80.0f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C14540.s") + if ((player->actor.bgCheckFlags & 1) && !(player->stateFlags1 & 0x2000) && (this->unk_2FE == 0) && + (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) && func_80C149B0(globalCtx, &this->unk_1F8)) { + this->unk_2FE = 1; + func_80C13E6C(this); + } else if (!(player->actor.bgCheckFlags & 1)) { + this->unk_2FE = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C14554.s") + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 5, 0x71C, 0xB6); + this->actor.world.rot.y = this->actor.shape.rot.y; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C145FC.s") +void func_80C13E6C(EnJgameTsn* this) { + this->actor.flags |= ACTOR_FLAG_10000; + this->actionFunc = func_80C13E90; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C14610.s") +void func_80C13E90(EnJgameTsn* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actor.flags &= ~ACTOR_FLAG_10000; + if (((gSaveContext.save.time > CLOCK_TIME(4, 0)) && (gSaveContext.save.time < CLOCK_TIME(7, 0))) || + ((gSaveContext.save.time > CLOCK_TIME(16, 0)) && (gSaveContext.save.time < CLOCK_TIME(19, 0)))) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + Message_StartTextbox(globalCtx, 0x1094, &this->actor); + this->unk_300 = 0x1094; + } else { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + Message_StartTextbox(globalCtx, 0x1098, &this->actor); + this->unk_300 = 0x1098; + } + func_80C14030(this); + } else { + func_800B8614(&this->actor, globalCtx, 1000.0f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C14684.s") +void func_80C13F88(EnJgameTsn* this) { + this->actionFunc = func_80C13F9C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C1476C.s") +void func_80C13F9C(EnJgameTsn* this, GlobalContext* globalCtx) { + if (this->actor.cutscene != -1) { + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + func_80C14030(this); + } else { + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + } + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } + } else { + func_80C14030(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C147B4.s") +void func_80C14030(EnJgameTsn* this) { + this->actionFunc = func_80C14044; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C14960.s") +void func_80C14044(EnJgameTsn* this, GlobalContext* globalCtx) { + switch (Message_GetState(&globalCtx->msgCtx)) { + case 0: + case 1: + case 2: + case 3: + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C149B0.s") + case 4: + func_80C14684(this, globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C14BCC.s") + case 5: + func_80C147B4(this, globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C14D14.s") + case 6: + if (Message_ShouldAdvance(globalCtx)) { + if (ActorCutscene_GetCurrentIndex() == this->actor.cutscene) { + ActorCutscene_Stop(this->actor.cutscene); + } + func_80C13B74(this); + } + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C14D58.s") + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 0x71C, 0xB6); + this->actor.world.rot.y = this->actor.shape.rot.y; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/EnJgameTsn_Update.s") +void func_80C1410C(EnJgameTsn* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C14E64.s") + player->stateFlags1 |= 0x20; + func_801A2BB8(0x25); + globalCtx->interfaceCtx.unk_280 = 1; + func_80112AFC(globalCtx); + gSaveContext.save.weekEventReg[90] |= 0x20; + func_8010E9F0(4, 0x78); + this->actionFunc = func_80C1418C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C14EE4.s") +void func_80C1418C(EnJgameTsn* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/EnJgameTsn_Draw.s") + if (globalCtx->interfaceCtx.unk_280 == 8) { + func_80C141DC(this); + player->stateFlags1 &= ~0x20; + } +} + +void func_80C141DC(EnJgameTsn* this) { + this->unk_218 = Rand_Next() & 3; + this->unk_2FC = 0; + *this->unk_208[this->unk_218] |= 1; + this->actionFunc = func_80C14230; +} + +void func_80C14230(EnJgameTsn* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 i; + s32 rand; + + if ((this->unk_2FC > 100) || func_80C14BCC(this, globalCtx)) { + rand = (u32)Rand_Next() % 3; + + this->unk_2FC = 0; + if (rand < this->unk_218) { + this->unk_218 = rand; + } else { + this->unk_218 = rand + 1; + } + + for (i = 0; i < ARRAY_COUNT(this->unk_208); i++) { + if (i == this->unk_218) { + *this->unk_208[i] |= 1; + *this->unk_208[i] &= ~8; + } else { + *this->unk_208[i] |= 8; + } + } + } + + this->unk_2FC++; + + if ((player->actor.bgCheckFlags & 2) && func_80C149B0(globalCtx, &this->unk_200)) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + Message_StartTextbox(globalCtx, 0x109F, &this->actor); + this->unk_300 = 0x109F; + player->stateFlags1 |= 0x20; + *this->unk_208[this->unk_218] &= ~1; + func_801A2C20(); + func_80C14030(this); + } else if ((player->actor.bgCheckFlags & 0x40) || (player->actor.bgCheckFlags & 0x20)) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + Message_StartTextbox(globalCtx, 0x10A0, &this->actor); + this->unk_300 = 0x10A0; + player->stateFlags1 |= 0x20; + *this->unk_208[this->unk_218] &= ~1; + func_801A2C20(); + func_80C14030(this); + } + + if (gSaveContext.unk_3DE0[4] == 0) { + Message_StartTextbox(globalCtx, 0x10A1, &this->actor); + this->unk_300 = 0x10A1; + player->stateFlags1 |= 0x20; + *this->unk_208[this->unk_218] &= ~1; + func_801A2C20(); + func_80C14030(this); + } +} + +void func_80C144E4(EnJgameTsn* this) { + this->actionFunc = func_80C144F8; +} + +void func_80C144F8(EnJgameTsn* this, GlobalContext* globalCtx) { + globalCtx->nextEntranceIndex = 0x68D0; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 0x50; + gSaveContext.nextTransition = 3; +} + +void func_80C14540(EnJgameTsn* this) { + this->actionFunc = func_80C14554; +} + +void func_80C14554(EnJgameTsn* this, GlobalContext* globalCtx) { + if (Actor_HasParent(&this->actor, globalCtx)) { + if (!(gSaveContext.save.weekEventReg[82] & 0x10)) { + gSaveContext.save.weekEventReg[82] |= 0x10; + } + func_80C145FC(this); + } else if (gSaveContext.save.weekEventReg[82] & 0x10) { + Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_PURPLE, 500.0f, 100.0f); + } else { + Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 500.0f, 100.0f); + } +} + +void func_80C145FC(EnJgameTsn* this) { + this->actionFunc = func_80C14610; +} + +void func_80C14610(EnJgameTsn* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + Message_StartTextbox(globalCtx, 0x10A4, &this->actor); + this->unk_300 = 0x10A4; + func_80C14030(this); + } else { + func_800B85E0(&this->actor, globalCtx, 200.0f, -1); + } +} + +void func_80C14684(EnJgameTsn* this, GlobalContext* globalCtx) { + if (Message_ShouldAdvance(globalCtx)) { + if (globalCtx->msgCtx.choiceIndex == 0) { + if (gSaveContext.save.playerData.rupees >= 20) { + Message_StartTextbox(globalCtx, 0x109E, &this->actor); + this->unk_300 = 0x109E; + func_801159EC(-20); + } else { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + Message_StartTextbox(globalCtx, 0x109D, &this->actor); + this->unk_300 = 0x109D; + } + } else { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + Message_StartTextbox(globalCtx, 0x109C, &this->actor); + this->unk_300 = 0x109C; + } + } +} + +void func_80C1476C(EnJgameTsn* this, GlobalContext* globalCtx) { + Actor* prop = globalCtx->actorCtx.actorLists[ACTORCAT_PROP].first; + + while (prop != NULL) { + if (prop->id == ACTOR_OBJ_JGAME_LIGHT) { + this->unk_208[OBJJGAMELIGHT_GET_7F(prop)] = &prop->colChkInfo.health; + } + prop = prop->next; + } +} + +void func_80C147B4(EnJgameTsn* this, GlobalContext* globalCtx) { + if (Message_ShouldAdvance(globalCtx)) { + switch (this->unk_300) { + case 0x1095: + Message_StartTextbox(globalCtx, 0x1096, &this->actor); + this->unk_300 = 0x1096; + break; + + case 0x1096: + Message_StartTextbox(globalCtx, 0x1097, &this->actor); + this->unk_300 = 0x1097; + break; + + case 0x1098: + Message_StartTextbox(globalCtx, 0x1099, &this->actor); + this->unk_300 = 0x1099; + func_80C13F88(this); + break; + + case 0x1099: + Message_StartTextbox(globalCtx, 0x109A, &this->actor); + this->unk_300 = 0x109A; + break; + + case 0x109A: + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + Message_StartTextbox(globalCtx, 0x109B, &this->actor); + this->unk_300 = 0x109B; + break; + + case 0x109E: + if (ActorCutscene_GetCurrentIndex() == this->actor.cutscene) { + ActorCutscene_Stop(this->actor.cutscene); + } + func_801477B4(globalCtx); + func_80C1476C(this, globalCtx); + func_80C1410C(this, globalCtx); + break; + + case 0x109F: + case 0x10A0: + case 0x10A1: + func_801477B4(globalCtx); + gSaveContext.minigameState = 3; + gSaveContext.unk_3DD0[4] = 5; + gSaveContext.save.weekEventReg[90] &= (u8)~0x20; + func_80C144E4(this); + break; + + case 0x10A3: + func_801477B4(globalCtx); + func_80C14540(this); + func_80C14554(this, globalCtx); + break; + } + } +} + +s32 func_80C14960(Vec2f arg0, Vec2f arg1) { + s32 phi_v1; + + if ((arg1.x * arg0.z) < (arg0.x * arg1.z)) { + phi_v1 = 1; + } else { + phi_v1 = -1; + } + return phi_v1; +} + +s32 func_80C149B0(GlobalContext* globalCtx, EnJgameTsnStruct* arg1) { + s32 i = 1; + s32 temp_s3; + Player* player = GET_PLAYER(globalCtx); + Vec2f sp64; + Vec2f sp5C; + s32 sp58 = true; + s32 pad; + s32 sp50 = 0; + f32 temp_f20 = player->actor.world.pos.z; + f32 temp_f22 = player->actor.world.pos.x; + + sp64.x = arg1->points[0].z - temp_f20; + sp64.z = arg1->points[0].x - temp_f22; + sp5C.x = arg1->points[1].z - temp_f20; + sp5C.z = arg1->points[1].x - temp_f22; + temp_s3 = func_80C14960(sp64, sp5C); + + while (i != 0) { + sp50++; + if (i < (arg1->count - 1)) { + i++; + } else { + i = 0; + } + + sp64.x = arg1->points[sp50].z - temp_f20; + sp64.z = arg1->points[sp50].x - temp_f22; + sp5C.x = arg1->points[i].z - temp_f20; + sp5C.z = arg1->points[i].x - temp_f22; + + if (func_80C14960(sp64, sp5C) != temp_s3) { + sp58 = false; + break; + } + } + + return sp58; +} + +s32 func_80C14BCC(EnJgameTsn* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 i; + s32 phi_s3 = -1; + + if (player->actor.bgCheckFlags & 2) { + for (i = 0; i < ARRAY_COUNT(this->unk_1D8); i++) { + if (func_80C149B0(globalCtx, &this->unk_1D8[i])) { + phi_s3 = i; + } + } + + if (phi_s3 == -1) { + return false; + } + + if (phi_s3 == this->unk_218) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); + *this->unk_208[phi_s3] |= 2; + globalCtx->interfaceCtx.unk_25C = 1; + return true; + } + + if (*this->unk_208[phi_s3] & 1) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); + *this->unk_208[phi_s3] |= 2; + globalCtx->interfaceCtx.unk_25C = 1; + } else { + *this->unk_208[phi_s3] |= 4; + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_ERROR); + } + } + + return false; +} + +void func_80C14D14(EnJgameTsn* this, GlobalContext* globalCtx) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +void func_80C14D58(EnJgameTsn* this, GlobalContext* globalCtx) { + func_800E9250(globalCtx, &this->actor, &this->unk_2EC, &this->unk_2F2, this->actor.focus.pos); + + if (DECR(this->unk_2FA) == 0) { + this->unk_2FA = Rand_S16Offset(60, 60); + } + + if ((this->unk_2FA == 1) || (this->unk_2FA == 3)) { + this->unk_21C = 1; + } else { + this->unk_21C = 0; + } +} + +void EnJgameTsn_Update(Actor* thisx, GlobalContext* globalCtx) { + EnJgameTsn* this = THIS; + + this->actionFunc(this, globalCtx); + + SkelAnime_Update(&this->skelAnime); + func_80C14D14(this, globalCtx); + func_80C14D58(this, globalCtx); +} + +s32 EnJgamesTsn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnJgameTsn* this = THIS; + s16 temp_v0 = this->unk_2EC.x >> 1; + + if (limbIndex == OBJECT_TSN_LIMB_0F) { + rot->x += this->unk_2EC.y; + rot->z += temp_v0; + } else if (limbIndex == OBJECT_TSN_LIMB_08) { + rot->x += this->unk_2F2.y; + rot->z += temp_v0; + } + return false; +} + +void EnJgamesTsn_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + if (limbIndex == OBJECT_TSN_LIMB_0F) { + Matrix_GetStateTranslation(&thisx->focus.pos); + } +} + +void EnJgameTsn_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnJgameTsn* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C5B0(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80C150A4[this->unk_21C])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80C150A4[this->unk_21C])); + + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnJgamesTsn_OverrideLimbDraw, EnJgamesTsn_PostLimbDraw, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.h b/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.h index c7e53da1a9..08d07376df 100644 --- a/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.h +++ b/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.h @@ -2,16 +2,39 @@ #define Z_EN_JGAME_TSN_H #include "global.h" +#include "objects/object_tsn/object_tsn.h" struct EnJgameTsn; typedef void (*EnJgameTsnActionFunc)(struct EnJgameTsn*, GlobalContext*); +#define ENJGAMETSN_GET_FF(thisx) ((thisx)->params & 0xFF) + +typedef struct { + /* 0x00 */ Vec3s* points; + /* 0x04 */ s32 count; +} EnJgameTsnStruct; // size = 0x8 + typedef struct EnJgameTsn { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x90]; + /* 0x0144 */ ColliderCylinder collider; + /* 0x0190 */ SkelAnime skelAnime; /* 0x01D4 */ EnJgameTsnActionFunc actionFunc; - /* 0x01D8 */ char unk_1D8[0x12C]; + /* 0x01D8 */ EnJgameTsnStruct unk_1D8[4]; + /* 0x01F8 */ EnJgameTsnStruct unk_1F8; + /* 0x0200 */ EnJgameTsnStruct unk_200; + /* 0x0208 */ u8* unk_208[4]; + /* 0x0218 */ s32 unk_218; + /* 0x021C */ s32 unk_21C; + /* 0x0220 */ Vec3s jointTable[OBJECT_TSN_LIMB_MAX]; + /* 0x0286 */ Vec3s morphTable[OBJECT_TSN_LIMB_MAX]; + /* 0x02EC */ Vec3s unk_2EC; + /* 0x02F2 */ Vec3s unk_2F2; + /* 0x02F8 */ s16 unk_2F8; + /* 0x02FA */ s16 unk_2FA; + /* 0x02FC */ s16 unk_2FC; + /* 0x02FE */ s16 unk_2FE; + /* 0x0300 */ u16 unk_300; } EnJgameTsn; // size = 0x304 extern const ActorInit En_Jgame_Tsn_InitVars; diff --git a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c index d7e113cb31..c3194461d9 100644 --- a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c +++ b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c @@ -176,14 +176,14 @@ void EnKakasi_Init(Actor* thisx, GlobalContext* globalCtx) { } if (this->aboveGroundStatus) { - if (gSaveContext.weekEventReg[79] & 8) { + if (gSaveContext.save.weekEventReg[79] & 8) { this->aboveGroundStatus = ENKAKASI_ABOVE_GROUND_TYPE; this->songSummonDist = 80.0f; EnKakasi_SetupIdleUnderground(this); } else { Actor_SetFocus(&this->actor, 60.0f); this->unkFunc = EnKakasi_8096F88C; - if (gSaveContext.weekEventReg[83] & 1) { + if (gSaveContext.save.weekEventReg[83] & 1) { EnKakasi_InitTimeSkipDialogue(this); } else { EnKakasi_SetupIdleStanding(this); @@ -302,13 +302,13 @@ void EnKakasi_TimeSkipDialogue(EnKakasi* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (gSaveContext.respawnFlag != -4 && gSaveContext.respawnFlag != -8) { - if (gSaveContext.time != CLOCK_TIME(6, 0) && gSaveContext.time != CLOCK_TIME(18, 0) && + if (gSaveContext.save.time != CLOCK_TIME(6, 0) && gSaveContext.save.time != CLOCK_TIME(18, 0) && !(gSaveContext.eventInf[1] & 0x80)) { if (this->actor.textId == 0) { // dialogue after skipped time 'did you feel that? went by in an instant' this->actor.textId = 0x1653; - gSaveContext.weekEventReg[83] &= (u8)~1; + gSaveContext.save.weekEventReg[83] &= (u8)~1; this->unkMsgState1AC = 5; player->stateFlags1 |= 0x20; this->actor.flags |= ACTOR_FLAG_10000; @@ -332,7 +332,7 @@ void EnKakasi_SetupIdleStanding(EnKakasi* this) { } void EnKakasi_IdleStanding(EnKakasi* this, GlobalContext* globalCtx) { - u32 saveContextDay = gSaveContext.day; + u32 saveContextDay = gSaveContext.save.day; s16 x; s16 y; @@ -361,7 +361,7 @@ void EnKakasi_IdleStanding(EnKakasi* this, GlobalContext* globalCtx) { EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); this->skelanime.playSpeed = 2.0f; } - } else if (saveContextDay == 3 && gSaveContext.isNight) { + } else if (saveContextDay == 3 && gSaveContext.save.isNight) { this->skelanime.playSpeed = 1.0f; if (this->animIndex != ENKAKASI_ANIM_SIDEWAYS_SHAKING) { EnKakasi_SetAnimation(this, 1); @@ -388,7 +388,7 @@ void EnKakasi_SetupDialogue(EnKakasi* this) { } void EnKakasi_RegularDialogue(EnKakasi* this, GlobalContext* globalCtx) { - u32 saveContextDay = gSaveContext.day; + u32 saveContextDay = gSaveContext.save.day; f32 currentAnimeFrame = this->skelanime.curFrame; Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 2000, 0); @@ -415,7 +415,7 @@ void EnKakasi_RegularDialogue(EnKakasi* this, GlobalContext* globalCtx) { this->unkState1A8 = 0; } - if (this->unkMsgState1AC == Message_GetState(&globalCtx->msgCtx) && func_80147624(globalCtx) != 0) { + if (this->unkMsgState1AC == Message_GetState(&globalCtx->msgCtx) && Message_ShouldAdvance(globalCtx) != 0) { func_801477B4(globalCtx); if (this->unkMsgState1AC == 5) { // bad song input @@ -425,16 +425,16 @@ void EnKakasi_RegularDialogue(EnKakasi* this, GlobalContext* globalCtx) { // after timeskip if (this->actor.textId == 0x1653) { - u32 saveContextDay2 = gSaveContext.day; + u32 saveContextDay2 = gSaveContext.save.day; if (this->animIndex != ENKAKASI_ANIM_SIDEWAYS_SHAKING) { EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); } - if (saveContextDay2 == 3 && gSaveContext.isNight) { + if (saveContextDay2 == 3 && gSaveContext.save.isNight) { // text: dangerous outside this->actor.textId = 0x164F; - } else if (gSaveContext.isNight) { + } else if (gSaveContext.save.isNight) { // text: would you like to skip time? this->actor.textId = 0x164E; } else { @@ -475,7 +475,7 @@ void EnKakasi_RegularDialogue(EnKakasi* this, GlobalContext* globalCtx) { if (this->animIndex != ENKAKASI_ANIM_SIDEWAYS_SHAKING) { EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); } - if (gSaveContext.isNight) { + if (gSaveContext.save.isNight) { this->actor.textId = 0x164E; } else { this->actor.textId = 0x1645; @@ -519,7 +519,7 @@ void EnKakasi_RegularDialogue(EnKakasi* this, GlobalContext* globalCtx) { this->actor.textId = 0x1658; } else if (this->actor.textId == 0x165C) { this->actor.textId = 0x165E; - } else if (saveContextDay == 3 && gSaveContext.isNight) { + } else if (saveContextDay == 3 && gSaveContext.save.isNight) { this->actor.textId = 0x164F; } else { this->actor.textId = 0x1652; @@ -560,7 +560,7 @@ void EnKakasi_SetupSongTeach(EnKakasi* this, GlobalContext* globalCtx) { * before actually teaching */ void EnKakasi_OcarinaRemark(EnKakasi* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx) != 0) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx) != 0) { func_80152434(globalCtx, 0x35); this->unkState1A8 = 0; if (ActorCutscene_GetCurrentIndex() == 0x7C) { @@ -735,7 +735,7 @@ void EnKakasi_PostSongLearnDialogue(EnKakasi* this, GlobalContext* globalCtx) { func_8096FAAC(this, globalCtx); if (this->unkState1A8 != 0 && Message_GetState(&globalCtx->msgCtx) == this->unkMsgState1AC && - func_80147624(globalCtx) != 0) { + Message_ShouldAdvance(globalCtx) != 0) { func_801477B4(globalCtx); @@ -788,7 +788,7 @@ void EnKakasi_PostSongLearnDialogue(EnKakasi* this, GlobalContext* globalCtx) { * talking before dancing the night away, and cutscene setup */ void EnKakasi_DancingRemark(EnKakasi* this, GlobalContext* globalCtx) { - u32 currentDay = gSaveContext.day; + u32 currentDay = gSaveContext.save.day; this->unkState196 = 3; if (ActorCutscene_GetCurrentIndex() == 0x7C) { @@ -799,7 +799,7 @@ void EnKakasi_DancingRemark(EnKakasi* this, GlobalContext* globalCtx) { } else { ActorCutscene_StartAndSetUnkLinkFields(this->actorCutscenes[0], &this->actor); this->cutsceneCamId = ActorCutscene_GetCurrentCamera(this->actor.cutscene); - if (currentDay == 3 && gSaveContext.isNight) { + if (currentDay == 3 && gSaveContext.save.isNight) { EnKakasi_SetupDigAway(this); } else { func_801A2BB8(NA_BGM_SARIAS_SONG); @@ -931,20 +931,20 @@ void EnKakasi_DancingNightAway(EnKakasi* this, GlobalContext* globalCtx) { if (this->unk204 == 0) { player = GET_PLAYER(globalCtx); - Play_SetRespawnData(&globalCtx->state, 0, Entrance_CreateIndexFromSpawn(0), player->unk_3CE, 0xBFF, - &player->unk_3C0, player->unk_3CC); + Play_SetRespawnData(&globalCtx->state, RESTART_MODE_DOWN, Entrance_CreateIndexFromSpawn(0), + player->unk_3CE, 0xBFF, &player->unk_3C0, player->unk_3CC); func_80169EFC(&globalCtx->state); if (0) {} - if (gSaveContext.time > CLOCK_TIME(18, 0) || gSaveContext.time < CLOCK_TIME(6, 0)) { - gSaveContext.time = CLOCK_TIME(6, 0); + if (gSaveContext.save.time > CLOCK_TIME(18, 0) || gSaveContext.save.time < CLOCK_TIME(6, 0)) { + gSaveContext.save.time = CLOCK_TIME(6, 0); gSaveContext.respawnFlag = -4; gSaveContext.eventInf[2] |= 0x80; } else { - gSaveContext.time = CLOCK_TIME(18, 0); + gSaveContext.save.time = CLOCK_TIME(18, 0); gSaveContext.respawnFlag = -8; } - gSaveContext.weekEventReg[83] |= 1; + gSaveContext.save.weekEventReg[83] |= 1; this->unk190 = 0; this->actionFunc = EnKakasi_DoNothing; } @@ -1013,7 +1013,7 @@ void EnKakasi_DiggingAway(EnKakasi* this, GlobalContext* globalCtx) { Math_ApproachF(&this->actor.shape.yOffset, -6000.0f, 0.5f, 200.0f); if (fabsf(this->actor.shape.yOffset + 6000.0f) < 10.0f) { - gSaveContext.weekEventReg[79] |= 8; + gSaveContext.save.weekEventReg[79] |= 8; func_800B7298(globalCtx, &this->actor, 6); ActorCutscene_Stop(this->actorCutscenes[0]); this->aboveGroundStatus = ENKAKASI_ABOVE_GROUND_TYPE; @@ -1031,7 +1031,7 @@ void EnKakasi_SetupIdleUnderground(EnKakasi* this) { } void EnKakasi_IdleUnderground(EnKakasi* this, GlobalContext* globalCtx) { - if ((gSaveContext.weekEventReg[79] & 8) && this->actor.xzDistToPlayer < this->songSummonDist && + if ((gSaveContext.save.weekEventReg[79] & 8) && this->actor.xzDistToPlayer < this->songSummonDist && (BREG(1) != 0 || globalCtx->msgCtx.ocarinaMode == 0xD)) { this->actor.flags &= ~ACTOR_FLAG_8000000; globalCtx->msgCtx.ocarinaMode = 4; @@ -1101,7 +1101,7 @@ void EnKakasi_IdleRisen(EnKakasi* this, GlobalContext* globalCtx) { void EnKakasi_RisenDialogue(EnKakasi* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 1000, 0); - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx) != 0) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx) != 0) { func_801477B4(globalCtx); EnKakasi_SetupIdleRisen(this); } diff --git a/src/overlays/actors/ovl_En_Kame/z_en_kame.c b/src/overlays/actors/ovl_En_Kame/z_en_kame.c index 1ec39194de..e457ec2191 100644 --- a/src/overlays/actors/ovl_En_Kame/z_en_kame.c +++ b/src/overlays/actors/ovl_En_Kame/z_en_kame.c @@ -163,10 +163,10 @@ void func_80AD6F34(EnKame* this) { } void func_80AD6F9C(EnKame* this) { - this->unk_29D = 10; - this->unk_2B4 = 0.6f; - this->unk_2B8 = 0.90000004f; - this->unk_2B0 = 1.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; + this->drawDmgEffScale = 0.6f; + this->drawDmgEffFrozenSteamScale = 0.90000004f; + this->drawDmgEffAlpha = 1.0f; this->collider.base.colType = COLTYPE_HIT3; this->unk_2A2 = 80; this->actor.flags &= ~ACTOR_FLAG_400; @@ -174,11 +174,11 @@ void func_80AD6F9C(EnKame* this) { } void func_80AD7018(EnKame* this, GlobalContext* globalCtx) { - if (this->unk_29D == 10) { - this->unk_29D = 0; + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->collider.base.colType = COLTYPE_HIT6; - this->unk_2B0 = 0.0f; - Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_2C8, 10, 2, 0.3f, 0.2f); + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, 10, 2, 0.3f, 0.2f); this->actor.flags |= ACTOR_FLAG_400; } } @@ -617,7 +617,8 @@ void func_80AD84C0(EnKame* this, GlobalContext* globalCtx) { this->collider.base.acFlags &= ~AC_HIT; Actor_SetDropFlag(&this->actor, &this->collider.info); - if ((this->unk_29D == 10) && (this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { + if ((this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) && + (this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { return; } @@ -644,9 +645,9 @@ void func_80AD84C0(EnKame* this, GlobalContext* globalCtx) { this->unk_2A2 = 40; Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); - this->unk_2B4 = 0.6f; - this->unk_2B0 = 2.0f; - this->unk_29D = 30; + this->drawDmgEffScale = 0.6f; + this->drawDmgEffAlpha = 2.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; func_80AD7FA4(this); } else if (this->actor.colChkInfo.damageEffect == 1) { this->unk_2A2 = 40; @@ -662,13 +663,13 @@ void func_80AD84C0(EnKame* this, GlobalContext* globalCtx) { func_80AD7FA4(this); } else { if (this->actor.colChkInfo.damageEffect == 2) { - this->unk_2B4 = 0.6f; - this->unk_2B0 = 4.0f; - this->unk_29D = 0; + this->drawDmgEffScale = 0.6f; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; } else if (this->actor.colChkInfo.damageEffect == 4) { - this->unk_2B4 = 0.6f; - this->unk_2B0 = 4.0f; - this->unk_29D = 20; + this->drawDmgEffScale = 0.6f; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->collider.info.bumper.hitPos.x, this->collider.info.bumper.hitPos.y, this->collider.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); @@ -732,16 +733,16 @@ void EnKame_Update(Actor* thisx, GlobalContext* globalCtx) { CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - if (this->unk_2B0 > 0.0f) { - if (this->unk_29D != 10) { - Math_StepToF(&this->unk_2B0, 0.0f, 0.05f); - this->unk_2B4 = (this->unk_2B0 + 1.0f) * 0.3f; - if (this->unk_2B4 > 0.6f) { - this->unk_2B4 = 0.6f; + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.3f; + if (this->drawDmgEffScale > 0.6f) { + this->drawDmgEffScale = 0.6f; } else { - this->unk_2B4 = this->unk_2B4; + this->drawDmgEffScale = this->drawDmgEffScale; } - } else if (!Math_StepToF(&this->unk_2B8, 0.6f, 0.015000001f)) { + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.6f, 0.015000001f)) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } @@ -769,7 +770,7 @@ void func_80AD8AF8(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* EnKame* this = THIS; if (D_80AD8EA4[limbIndex] != -1) { - Matrix_GetStateTranslation(&this->unk_2C8[D_80AD8EA4[limbIndex]]); + Matrix_GetStateTranslation(&this->limbPos[D_80AD8EA4[limbIndex]]); } if (limbIndex == 1) { @@ -782,7 +783,7 @@ void func_80AD8AF8(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* } ptr2 = D_80AD8E68; - ptr = &this->unk_2C8[5]; + ptr = &this->limbPos[5]; for (i = 0; i < ARRAY_COUNT(D_80AD8E68); i++) { Matrix_MultiplyVector3fByState(ptr2, ptr); ptr2++; @@ -807,8 +808,8 @@ void EnKame_Draw(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime1.skeleton, this->skelAnime1.jointTable, this->skelAnime1.dListCount, func_80AD8A48, func_80AD8AF8, &this->actor); - func_800BE680(globalCtx, &this->actor, this->unk_2C8, 10, this->unk_2B4, this->unk_2B8, this->unk_2B0, - this->unk_29D); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, + this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, this->drawDmgEffType); if (this->actor.shape.shadowDraw == NULL) { ActorShadow_DrawCircle(&this->actor, NULL, globalCtx); diff --git a/src/overlays/actors/ovl_En_Kame/z_en_kame.h b/src/overlays/actors/ovl_En_Kame/z_en_kame.h index 115bf137fd..d47e96d541 100644 --- a/src/overlays/actors/ovl_En_Kame/z_en_kame.h +++ b/src/overlays/actors/ovl_En_Kame/z_en_kame.h @@ -17,7 +17,7 @@ typedef struct EnKame { /* 0x0280 */ Vec3s morphTable2[4]; /* 0x0298 */ EnKameActionFunc actionFunc; /* 0x029C */ u8 unk_29C; - /* 0x029D */ u8 unk_29D; + /* 0x029D */ u8 drawDmgEffType; /* 0x029E */ s16 unk_29E; /* 0x02A0 */ s16 unk_2A0; /* 0x02A2 */ s16 unk_2A2; @@ -25,11 +25,11 @@ typedef struct EnKame { /* 0x02A6 */ s16 unk_2A6; /* 0x02A8 */ f32 unk_2A8; /* 0x02AC */ f32 unk_2AC; - /* 0x02B0 */ f32 unk_2B0; - /* 0x02B4 */ f32 unk_2B4; - /* 0x02B8 */ f32 unk_2B8; + /* 0x02B0 */ f32 drawDmgEffAlpha; + /* 0x02B4 */ f32 drawDmgEffScale; + /* 0x02B8 */ f32 drawDmgEffFrozenSteamScale; /* 0x02BC */ Vec3f unk_2BC; - /* 0x02C8 */ Vec3f unk_2C8[10]; + /* 0x02C8 */ Vec3f limbPos[10]; /* 0x0340 */ ColliderCylinder collider; } EnKame; // size = 0x38C diff --git a/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c b/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c index e3edc73116..33474cda5d 100644 --- a/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c +++ b/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c @@ -991,11 +991,11 @@ void EnKanban_Draw(Actor* thisx, GlobalContext* globalCtx) { if ((this->actor.projectedPos.z <= 400.0f) && (this->actor.projectedPos.z > 0.0f) && (this->actor.floorHeight > -3000.0f) && ((this->bounceX != 0) || (this->bounceZ != 0))) { - u16 dayTime = gSaveContext.time; + u16 dayTime = gSaveContext.save.time; f32 shadowAlpha; if (dayTime >= CLOCK_TIME(12, 0)) { - dayTime = (0xFFFF - dayTime) & 0xFFFF; + dayTime = 0xFFFF - dayTime; } shadowAlpha = (dayTime * 0.00275f) + 10.0f; diff --git a/src/overlays/actors/ovl_En_Kanban/z_en_kanban.h b/src/overlays/actors/ovl_En_Kanban/z_en_kanban.h index b667bd9e8c..201364bc02 100644 --- a/src/overlays/actors/ovl_En_Kanban/z_en_kanban.h +++ b/src/overlays/actors/ovl_En_Kanban/z_en_kanban.h @@ -66,7 +66,7 @@ typedef enum { typedef struct EnKanban { /* 0x000 */ Actor actor; - /* 0x144 */ UNK_TYPE1 unk144[4]; // actionFunc? + /* 0x144 */ UNK_TYPE1 unk_144[4]; // actionFunc? /* 0x148 */ u8 frameCount; /* 0x14A */ s16 airTimer; /* 0x14C */ u8 actionState; diff --git a/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.c b/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.c index f6b1f7b402..7a59e702cc 100644 --- a/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.c +++ b/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.c @@ -175,39 +175,39 @@ void EnKarebaba_Destroy(Actor* thisx, GlobalContext* globalCtx) { void func_808F1374(EnKarebaba* this, GlobalContext* globalCtx) { s32 phi_a3; - if (this->unk_1EC == 10) { - this->unk_1EC = 0; - this->unk_1F0 = 0.0f; + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffAlpha = 0.0f; if (this->actor.params == ENKAREBABA_2) { phi_a3 = 1; } else { phi_a3 = 4; } - Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_1FC, phi_a3, 4, 0.3f, 0.2f); + Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, phi_a3, 4, 0.3f, 0.2f); } } void func_808F13FC(EnKarebaba* this, GlobalContext* globalCtx) { if (this->actor.colChkInfo.damageEffect == 2) { - this->unk_1EC = 0; - this->unk_1F4 = 0.75f; - this->unk_1F0 = 3.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffAlpha = 3.0f; } else if (this->actor.colChkInfo.damageEffect == 4) { - this->unk_1F4 = 0.75f; - this->unk_1EC = 20; - this->unk_1F0 = 3.0f; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->drawDmgEffAlpha = 3.0f; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->collider2.info.bumper.hitPos.x, this->collider2.info.bumper.hitPos.y, this->collider2.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_SMALL_LIGHT_RAYS); } else if (this->actor.colChkInfo.damageEffect == 3) { - this->unk_1EC = 10; - this->unk_1F4 = 0.75f; - this->unk_1F0 = 1.0f; - this->unk_1F8 = 1.125f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffFrozenSteamScale = 1.125f; } else if (this->actor.colChkInfo.damageEffect == 5) { - this->unk_1EC = 31; - this->unk_1F4 = 0.75f; - this->unk_1F0 = 3.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_MEDIUM; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffAlpha = 3.0f; } } @@ -371,7 +371,7 @@ void func_808F1A58(EnKarebaba* this, GlobalContext* globalCtx) { } void func_808F1BF8(EnKarebaba* this) { - if (this->unk_1EC != 10) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { this->unk_1EE = 0; this->actor.gravity = -0.8f; this->actor.velocity.y = 4.0f; @@ -393,7 +393,7 @@ void func_808F1C84(EnKarebaba* this, GlobalContext* globalCtx) { f32 temp_f22; f32 temp_f24; - if (this->unk_1EC == 10) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { this->unk_1EE--; if (this->unk_1EE == 0) { this->actor.gravity = -0.8f; @@ -446,14 +446,14 @@ void func_808F1FAC(EnKarebaba* this) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEKU_JR_DEAD); this->actor.flags |= (ACTOR_FLAG_10 | ACTOR_FLAG_20); this->actor.flags &= ~ACTOR_FLAG_1; - if (this->unk_1EC == 10) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { this->unk_1EE = 3; } this->actionFunc = func_808F200C; } void func_808F200C(EnKarebaba* this, GlobalContext* globalCtx) { - if (this->unk_1EC == 10) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { this->unk_1EE--; if (this->unk_1EE == 0) { func_808F1374(this, globalCtx); @@ -481,7 +481,7 @@ void func_808F20FC(EnKarebaba* this, GlobalContext* globalCtx) { func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, 8); this->unk_1EE = 200; this->actor.flags &= ~ACTOR_FLAG_20; - this->unk_1F0 = 0.0f; + this->drawDmgEffAlpha = 0.0f; this->actionFunc = func_808F21A4; } @@ -530,7 +530,7 @@ void func_808F238C(EnKarebaba* this) { this->unk_1EE = 200; this->actor.parent = NULL; this->actor.shape.shadowScale = 0.0f; - this->unk_1F0 = 0.0f; + this->drawDmgEffAlpha = 0.0f; Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.home.pos); this->actionFunc = func_808F254C; } @@ -580,16 +580,16 @@ void EnKarebaba_Update(Actor* thisx, GlobalContext* globalCtx2) { this->actionFunc(this, globalCtx); - if (this->unk_1F0 > 0.0f) { - if (this->unk_1EC != 10) { - Math_StepToF(&this->unk_1F0, 0.0f, 0.05f); - this->unk_1F4 = (this->unk_1F0 + 1.0f) * 0.375f; - if (this->unk_1F4 > 0.75f) { - this->unk_1F4 = 0.75f; + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.375f; + if (this->drawDmgEffScale > 0.75f) { + this->drawDmgEffScale = 0.75f; } else { - this->unk_1F4 = this->unk_1F4; + this->drawDmgEffScale = this->drawDmgEffScale; } - } else if (!Math_StepToF(&this->unk_1F8, 0.75f, 0.01875f)) { + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.75f, 0.01875f)) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } @@ -646,13 +646,13 @@ void EnKarebaba_Draw(Actor* thisx, GlobalContext* globalCtx) { EnKarebaba* this = THIS; s32 i; s32 sp94; - s16 phi_a3; + s16 limbCount; f32 sp8C = 0.01f; OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); - Math_Vec3f_Copy(this->unk_1FC, &this->actor.world.pos); + Math_Vec3f_Copy(this->limbPos, &this->actor.world.pos); if (this->actionFunc == func_808F21A4) { if ((this->unk_1EE > 40) || (this->unk_1EE & 1)) { @@ -691,7 +691,7 @@ void EnKarebaba_Draw(Actor* thisx, GlobalContext* globalCtx) { G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, D_808F2E2C[i]); - Matrix_GetStateTranslation(&this->unk_1FC[1 + i]); + Matrix_GetStateTranslation(&this->limbPos[1 + i]); if ((i == 0) && (this->actionFunc == func_808F1C84)) { Matrix_GetStateTranslation(&this->actor.focus.pos); } @@ -719,19 +719,19 @@ void EnKarebaba_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_dekubaba_DL_001828); - Matrix_GetStateTranslation(&this->unk_1FC[3]); + Matrix_GetStateTranslation(&this->limbPos[3]); } func_800AE5A0(globalCtx); if (this->actor.params == ENKAREBABA_2) { - phi_a3 = 1; + limbCount = 1; } else { - phi_a3 = 4; + limbCount = ARRAY_COUNT(this->limbPos); } - func_800BE680(globalCtx, &this->actor, this->unk_1FC, phi_a3, this->unk_1F4, this->unk_1F8, this->unk_1F0, - this->unk_1EC); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, limbCount, this->drawDmgEffScale, + this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, this->drawDmgEffType); if (this->unk_22C != 0) { func_808F280C(this, globalCtx); diff --git a/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.h b/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.h index 9fd021e5fb..e91e151ae4 100644 --- a/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.h +++ b/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.h @@ -19,12 +19,12 @@ typedef struct EnKarebaba { /* 0x0188 */ EnKarebabaActionFunc actionFunc; /* 0x018C */ Vec3s jointTable[8]; /* 0x01BC */ Vec3s morphTable[8]; - /* 0x01EC */ u8 unk_1EC; + /* 0x01EC */ u8 drawDmgEffType; /* 0x01EE */ s16 unk_1EE; - /* 0x01F0 */ f32 unk_1F0; - /* 0x01F4 */ f32 unk_1F4; - /* 0x01F8 */ f32 unk_1F8; - /* 0x01FC */ Vec3f unk_1FC[4]; + /* 0x01F0 */ f32 drawDmgEffAlpha; + /* 0x01F4 */ f32 drawDmgEffScale; + /* 0x01F8 */ f32 drawDmgEffFrozenSteamScale; + /* 0x01FC */ Vec3f limbPos[4]; /* 0x022C */ CollisionPoly* unk_22C; /* 0x0230 */ ColliderCylinder collider1; /* 0x027C */ ColliderCylinder collider2; diff --git a/src/overlays/actors/ovl_En_Kbt/z_en_kbt.c b/src/overlays/actors/ovl_En_Kbt/z_en_kbt.c index deedb3e787..9a42980db3 100644 --- a/src/overlays/actors/ovl_En_Kbt/z_en_kbt.c +++ b/src/overlays/actors/ovl_En_Kbt/z_en_kbt.c @@ -15,10 +15,13 @@ void EnKbt_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnKbt_Update(Actor* thisx, GlobalContext* globalCtx); void EnKbt_Draw(Actor* thisx, GlobalContext* globalCtx); +s32 func_80B33E64(GlobalContext* globalCtx); +s32 func_80B33E8C(GlobalContext* globalCtx); +void func_80B33EF0(EnKbt* this, s16 arg1); +Actor* func_80B3403C(GlobalContext* globalCtx); void func_80B34314(EnKbt* this, GlobalContext* globalCtx); void func_80B34598(EnKbt* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Kbt_InitVars = { ACTOR_EN_KBT, ACTORCAT_NPC, @@ -31,36 +34,543 @@ const ActorInit En_Kbt_InitVars = { (ActorFunc)EnKbt_Draw, }; -#endif +void EnKbt_Init(Actor* thisx, GlobalContext* globalCtx) { + EnKbt* this = THIS; -extern UNK_TYPE D_06004274; + Actor_SetScale(&this->actor, 0.01f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_kbt_Skel_00DEE8, &object_kbt_Anim_004274, this->jointTable, + this->morphTable, OBJECT_KBT_LIMB_MAX); + this->unk_27C = 0; + this->actor.home.rot.z = 0; + this->unk_27E = 4; + this->unk_27F = 0; + this->unk_280 = 13; + this->unk_282 = 13; + this->unk_278 = func_80B3403C(globalCtx); + this->unk_284 = 0; + this->actor.textId = 0; + if (func_80B33E64(globalCtx)) { + func_80B33EF0(this, 6); + this->unk_282 = 11; + if (func_80B33E8C(globalCtx)) { + this->actor.textId = 0xC50; + } else { + this->actor.textId = 0xC4E; + this->unk_27C |= 1; + } + this->actionFunc = func_80B34314; + } else { + func_80B33EF0(this, 0); + this->unk_282 = 0; + this->actionFunc = func_80B34598; + } + this->actor.flags &= ~ACTOR_FLAG_1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kbt/EnKbt_Init.s") +void EnKbt_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kbt/EnKbt_Destroy.s") +s32 func_80B33E64(GlobalContext* globalCtx) { + return gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 & 1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kbt/func_80B33E64.s") +s32 func_80B33E8C(GlobalContext* globalCtx) { + if ((CURRENT_DAY == 3) || + ((CURRENT_DAY == 2) && (gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 & 2))) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kbt/func_80B33E8C.s") +void func_80B33EF0(EnKbt* this, s16 arg1) { + static AnimationHeader* sAnimations[] = { + &object_kbt_Anim_000670, &object_kbt_Anim_001674, &object_kbt_Anim_002084, &object_kbt_Anim_000FE8, + &object_kbt_Anim_001940, &object_kbt_Anim_00E7BC, &object_kbt_Anim_00F0C8, &object_kbt_Anim_002710, + &object_kbt_Anim_002DE0, &object_kbt_Anim_003414, &object_kbt_Anim_003D24, &object_kbt_Anim_001BF4, + &object_kbt_Anim_002084, + }; + u8 sp38[] = { + ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_LOOP, + ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_ONCE, + }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kbt/func_80B33EF0.s") + if (arg1 != this->unk_280) { + if (arg1 >= 12) { + Animation_Change(&this->skelAnime, sAnimations[arg1], -1.0f, + Animation_GetLastFrame(sAnimations[arg1]) - 1.0f, 0.0f, sp38[arg1], -5.0f); + } else { + Animation_Change(&this->skelAnime, sAnimations[arg1], 1.0f, 0.0f, Animation_GetLastFrame(sAnimations[arg1]), + sp38[arg1], -5.0f); + } + this->unk_280 = arg1; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kbt/func_80B3403C.s") +Actor* func_80B3403C(GlobalContext* globalCtx) { + Actor* npc = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kbt/func_80B34078.s") + while (npc != NULL) { + if (npc->id == ACTOR_EN_KGY) { + return npc; + } + npc = npc->next; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kbt/func_80B3415C.s") + return NULL; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kbt/func_80B34314.s") +void func_80B34078(EnKbt* this) { + if (SkelAnime_Update(&this->skelAnime)) { + if (this->unk_284 > 0) { + this->unk_284--; + } else { + switch (this->unk_280) { + case 2: + switch (this->unk_282) { + case 0: + func_80B33EF0(this, 12); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kbt/func_80B34574.s") + case 5: + this->actor.home.rot.z = 0; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kbt/func_80B34598.s") + default: + func_80B33EF0(this, 5); + break; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kbt/EnKbt_Update.s") + case 12: + func_80B33EF0(this, 0); + this->actor.home.rot.z = 0; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kbt/func_80B349C8.s") + case 4: + func_80B33EF0(this, 1); + this->unk_27E = 2; + this->actor.home.rot.z = 0; + break; + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kbt/func_80B34A00.s") +void func_80B3415C(EnKbt* this) { + if (this->unk_27C & 2) { + if (this->unk_284 > 0) { + this->unk_284--; + } else { + this->unk_27F = 0; + this->unk_282 = 3; + this->unk_27C &= ~2; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kbt/EnKbt_Draw.s") + switch (this->unk_282) { + case 0: + if ((this->unk_280 != 2) && (this->unk_280 != 12)) { + func_80B33EF0(this, 0); + } + break; + + case 1: + func_80B33EF0(this, 2); + this->unk_282 = 0; + break; + + case 2: + if (this->unk_280 != 12) { + func_80B33EF0(this, 3); + } + break; + + case 3: + if (this->unk_280 != 1) { + func_80B33EF0(this, 4); + } + break; + + case 10: + func_80B33EF0(this, 11); + break; + + case 4: + func_80B33EF0(this, 2); + this->unk_282 = 6; + break; + + case 6: + if (this->unk_280 != 2) { + func_80B33EF0(this, 5); + } + break; + + case 11: + func_80B33EF0(this, 6); + break; + + case 7: + if (this->unk_280 != 2) { + func_80B33EF0(this, 7); + } + break; + + case 8: + if (this->unk_280 != 2) { + func_80B33EF0(this, 8); + } + break; + + case 9: + if (this->unk_280 != 2) { + func_80B33EF0(this, 9); + } + break; + + case 12: + func_80B33EF0(this, 10); + break; + } +} + +void func_80B34314(EnKbt* this, GlobalContext* globalCtx) { + s32 playerForm; + + func_80B34078(this); + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = func_80B34598; + Actor_ChangeFocus(&this->actor, globalCtx, this->unk_278); + this->unk_278->textId = this->actor.textId; + this->unk_27C &= ~4; + if (this->actor.textId == 0xC4E) { + this->unk_27C |= 0x10; + } + } else if (this->actor.xzDistToPlayer < 250.0f) { + if ((this->unk_278 != NULL) && (this->unk_278->xzDistToPlayer < 250.0f)) { + if (this->unk_27C & 4) { + playerForm = gSaveContext.save.playerForm; + if (((playerForm ^ 0) != PLAYER_FORM_HUMAN) || ((CUR_FORM_EQUIP(EQUIP_SLOT_B) != ITEM_SWORD_KOKIRI) && + (CUR_FORM_EQUIP(EQUIP_SLOT_B) != ITEM_SWORD_RAZOR) && + (CUR_FORM_EQUIP(EQUIP_SLOT_B) != ITEM_SWORD_GILDED))) { + this->actor.textId = 0xC38; + } else if (CURRENT_DAY == 3) { + this->actor.textId = 0xC39; + } else if (this->unk_27C & 8) { + this->actor.textId = 0xC3E; + } else { + this->actor.textId = 0xC3A; + } + } + + if (this->actor.textId != 0xC37) { + if (((this->actor.textId == 0xC4E) || (this->actor.textId == 0xC4F) || (this->actor.textId == 0xC50)) && + (gSaveContext.save.playerForm != PLAYER_FORM_HUMAN)) { + this->actor.textId = 0xC37; + } + } else if (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { + if (func_80B33E8C(globalCtx)) { + this->actor.textId = 0xC50; + } else { + this->actor.textId = 0xC4E; + } + } + func_800B8614(&this->actor, globalCtx, 260.0f); + } + } + func_80B3415C(this); +} + +void func_80B34574(EnKbt* this) { + this->unk_27E = 0; + this->unk_27F = 0; + this->unk_282 = 6; + this->actionFunc = func_80B34314; +} + +void func_80B34598(EnKbt* this, GlobalContext* globalCtx) { + func_80B34078(this); + + switch (this->actor.textId) { + case 0x1: + this->unk_27E = 4; + this->unk_27F = 0; + this->unk_282 = 0; + break; + + case 0x2: + func_80B34574(this); + this->actor.textId = 0xC3E; + this->unk_27C |= 0x4; + this->unk_27C |= 0x8; + return; + + case 0x3: + func_80B34574(this); + this->actor.textId = 0xC58; + return; + + case 0x4: + func_80B34574(this); + this->actor.textId = 0xC4B; + return; + + case 0x5: + this->unk_27E = 4; + this->unk_27F = 0; + this->unk_282 = 0; + func_80B33EF0(this, 12); + break; + + case 0x6: + func_80B34574(this); + this->actor.textId = 0xC3A; + this->unk_27C |= 4; + return; + + case 0x7: + this->unk_27E = 4; + this->unk_27F = 0; + this->unk_282 = 11; + if (func_80B33E8C(globalCtx)) { + this->actor.textId = 0xC50; + } else if (this->unk_27C & 0x10) { + this->actor.textId = 0xC4F; + } else { + this->actor.textId = 0xC4E; + } + this->actionFunc = func_80B34314; + return; + + case 0x8: + func_80B34574(this); + this->actor.textId = 0xC56; + return; + + case 0xC1E: + this->unk_27E = 2; + this->unk_27F = 1; + break; + + case 0xC1F: + case 0xC2E: + this->unk_27E = 2; + this->unk_27F = 1; + this->unk_282 = 1; + this->unk_284 = 20; + break; + + case 0xC20: + case 0xC23: + case 0xC2F: + this->unk_27E = 0; + this->unk_282 = 2; + break; + + case 0xC21: + case 0xC29: + this->unk_284 = 10; + this->unk_27C |= 2; + break; + + case 0xC22: + case 0xC2A: + this->unk_27F = 1; + break; + + case 0xC2C: + this->unk_27E = 0; + this->unk_27F = 0; + this->unk_282 = 2; + break; + + case 0xC31: + this->unk_27E = 2; + this->unk_27F = 1; + this->unk_282 = 4; + break; + + case 0xC32: + this->unk_27E = 1; + this->unk_282 = 7; + break; + + case 0xC34: + this->unk_27E = 0; + this->unk_282 = 8; + break; + + case 0xC35: + this->unk_27E = 4; + this->unk_27F = 0; + func_80B33EF0(this, 2); + this->unk_282 = 5; + break; + + case 0xC36: + this->unk_27E = 1; + this->unk_27F = 1; + func_80B33EF0(this, 7); + this->unk_282 = 7; + break; + + case 0xC37: + func_80B33EF0(this, 10); + this->unk_27E = 0; + this->unk_27F = 1; + break; + + case 0xC38: + case 0xC39: + func_80B33EF0(this, 7); + this->unk_27E = 0; + this->unk_27F = 1; + break; + + case 0xC3A: + case 0xC4D: + case 0xC58: + this->unk_27E = 0; + this->unk_27F = 1; + this->unk_282 = 8; + break; + + case 0xC3C: + case 0xC57: + this->unk_27E = 1; + this->unk_282 = 7; + break; + + case 0xC3D: + this->unk_27E = 0; + break; + + case 0xC3E: + this->unk_27F = 1; + this->unk_282 = 8; + break; + + case 0xC3F: + case 0xC47: + case 0xC4C: + this->unk_27E = 1; + this->unk_27F = 1; + this->unk_282 = 7; + break; + + case 0xC40: + this->unk_27E = 3; + this->unk_282 = 6; + break; + + case 0xC45: + case 0xC4B: + case 0xC56: + this->unk_27E = 0; + this->unk_27F = 1; + this->unk_282 = 7; + break; + + case 0xC46: + this->unk_27E = 1; + this->unk_27F = 1; + this->unk_282 = 9; + break; + + case 0xC48: + this->unk_27E = 2; + this->unk_27F = 0; + this->unk_282 = 10; + break; + + case 0xC49: + this->unk_27F = 1; + break; + + case 0xC4A: + this->unk_27E = 0; + this->unk_282 = 7; + break; + + case 0xC4E: + this->unk_27E = 1; + this->unk_27F = 1; + this->unk_282 = 12; + break; + + case 0xC4F: + this->unk_27E = 2; + this->unk_27F = 1; + this->unk_282 = 12; + break; + + case 0xC50: + this->unk_27E = 0; + this->unk_27F = 1; + this->unk_282 = 12; + break; + } + + this->actor.textId = 0; + func_80B3415C(this); +} + +void EnKbt_Update(Actor* thisx, GlobalContext* globalCtx) { + EnKbt* this = THIS; + + this->actionFunc(this, globalCtx); +} + +s32 EnKbt_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnKbt* this = THIS; + + if (!(this->unk_27C & 1) && (limbIndex == OBJECT_KBT_LIMB_0E)) { + *dList = NULL; + } + return false; +} + +Vec3f D_80B34B84 = { 500.0f, 500.0f, 0.0f }; + +void EnKbt_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnKbt* this = THIS; + + if (limbIndex == OBJECT_KBT_LIMB_09) { + Matrix_MultiplyVector3fByState(&D_80B34B84, &this->actor.focus.pos); + } +} + +TexturePtr D_80B34B90[] = { + object_kbt_Tex_00A5B8, + object_kbt_Tex_00ADB8, +}; + +TexturePtr D_80B34B98[] = { + object_kbt_Tex_00B5B8, object_kbt_Tex_00BDB8, object_kbt_Tex_00C5B8, object_kbt_Tex_00CDB8, object_kbt_Tex_00D5B8, +}; + +void EnKbt_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnKbt* this = THIS; + Gfx* gfx; + TexturePtr tex; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gfx = POLY_OPA_DISP; + + tex = Lib_SegmentedToVirtual(D_80B34B98[this->unk_27E]); + gSPSegment(&gfx[0], 0x08, tex); + + tex = Lib_SegmentedToVirtual(D_80B34B90[this->unk_27F]); + gSPSegment(&gfx[1], 0x09, tex); + + POLY_OPA_DISP = &gfx[2]; + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnKbt_OverrideLimbDraw, EnKbt_PostLimbDraw, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Kbt/z_en_kbt.h b/src/overlays/actors/ovl_En_Kbt/z_en_kbt.h index 9d68dce1d5..7556e3f5c8 100644 --- a/src/overlays/actors/ovl_En_Kbt/z_en_kbt.h +++ b/src/overlays/actors/ovl_En_Kbt/z_en_kbt.h @@ -2,6 +2,7 @@ #define Z_EN_KBT_H #include "global.h" +#include "objects/object_kbt/object_kbt.h" struct EnKbt; @@ -9,7 +10,16 @@ typedef void (*EnKbtActionFunc)(struct EnKbt*, GlobalContext*); typedef struct EnKbt { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x144]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[OBJECT_KBT_LIMB_MAX]; + /* 0x0200 */ Vec3s morphTable[OBJECT_KBT_LIMB_MAX]; + /* 0x0278 */ Actor* unk_278; + /* 0x027C */ u16 unk_27C; + /* 0x027E */ u8 unk_27E; + /* 0x027F */ u8 unk_27F; + /* 0x0280 */ s16 unk_280; + /* 0x0282 */ s16 unk_282; + /* 0x0284 */ s16 unk_284; /* 0x0288 */ EnKbtActionFunc actionFunc; } EnKbt; // size = 0x28C diff --git a/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.c b/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.c index eee97c5f7a..92053374a1 100644 --- a/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.c +++ b/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.c @@ -109,7 +109,8 @@ void EnKendoJs_Init(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_js_Skel_006990, &object_js_Anim_000F4C, this->jointTable, this->morphTable, 13); - if ((CURRENT_DAY == 3) && !((gSaveContext.time <= CLOCK_TIME(23, 0)) && (gSaveContext.time >= CLOCK_TIME(6, 0)))) { + if ((CURRENT_DAY == 3) && + !((gSaveContext.save.time <= CLOCK_TIME(23, 0)) && (gSaveContext.save.time >= CLOCK_TIME(6, 0)))) { if (ENKENDOJS_GET_FF(&this->actor) != ENKENDOJS_FF_1) { Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_KANBAN, this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z - 10.0f, this->actor.home.rot.x, @@ -145,7 +146,7 @@ void EnKendoJs_Destroy(Actor* thisx, GlobalContext* globalCtx) { EnKendoJs* this = THIS; Collider_DestroyCylinder(globalCtx, &this->collider); - gSaveContext.weekEventReg[82] &= (u8)~8; + gSaveContext.save.weekEventReg[82] &= (u8)~8; } void func_80B26538(EnKendoJs* this) { @@ -166,8 +167,8 @@ void func_80B2654C(EnKendoJs* this, GlobalContext* globalCtx) { if (ENKENDOJS_GET_FF(&this->actor) == ENKENDOJS_FF_1) { Message_StartTextbox(globalCtx, 0x273C, &this->actor); this->unk_288 = 0x273C; - } else if (gSaveContext.playerForm != PLAYER_FORM_HUMAN) { - switch (gSaveContext.playerForm) { + } else if (gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) { + switch (gSaveContext.save.playerForm) { case PLAYER_FORM_DEKU: phi_v0 = 0; break; @@ -212,15 +213,15 @@ void func_80B2654C(EnKendoJs* this, GlobalContext* globalCtx) { } void func_80B26758(EnKendoJs* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx) && (this->unk_288 == 0x2716)) { + if (Message_ShouldAdvance(globalCtx) && (this->unk_288 == 0x2716)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: - if (CUR_EQUIP_VALUE_VOID(EQUIP_SWORD) == EQUIP_SWORD) { + if (GET_CUR_EQUIP_VALUE(EQUIP_SWORD) == EQUIP_SWORD) { play_sound(NA_SE_SY_ERROR); Message_StartTextbox(globalCtx, 0x272C, &this->actor); this->unk_288 = 0x272C; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); - } else if (gSaveContext.rupees < globalCtx->msgCtx.unk1206C) { + } else if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { play_sound(NA_SE_SY_ERROR); Message_StartTextbox(globalCtx, 0x2718, &this->actor); this->unk_288 = 0x2718; @@ -233,12 +234,12 @@ void func_80B26758(EnKendoJs* this, GlobalContext* globalCtx) { break; case 1: - if (CUR_EQUIP_VALUE_VOID(EQUIP_SWORD) == EQUIP_SWORD) { + if (GET_CUR_EQUIP_VALUE(EQUIP_SWORD) == EQUIP_SWORD) { play_sound(NA_SE_SY_ERROR); Message_StartTextbox(globalCtx, 0x272C, &this->actor); this->unk_288 = 0x272C; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); - } else if (gSaveContext.rupees < globalCtx->msgCtx.unk12070) { + } else if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk12070) { play_sound(NA_SE_SY_ERROR); Message_StartTextbox(globalCtx, 0x2718, &this->actor); this->unk_288 = 0x2718; @@ -261,7 +262,7 @@ void func_80B26758(EnKendoJs* this, GlobalContext* globalCtx) { void func_80B269A4(EnKendoJs* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (!func_80147624(globalCtx)) { + if (!Message_ShouldAdvance(globalCtx)) { return; } @@ -325,7 +326,7 @@ void func_80B26AFC(EnKendoJs* this, GlobalContext* globalCtx) { break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (this->unk_288 == 0x272C) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); } @@ -492,7 +493,7 @@ void func_80B27030(EnKendoJs* this, GlobalContext* globalCtx) { } void func_80B2714C(EnKendoJs* this) { - gSaveContext.weekEventReg[82] |= 8; + gSaveContext.save.weekEventReg[82] |= 8; this->unk_28C = 1; this->unk_290 = 0; this->unk_284 = 0; @@ -503,7 +504,7 @@ void func_80B2714C(EnKendoJs* this) { void func_80B27188(EnKendoJs* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { if (this->unk_288 == 0x2729) { func_80B26F14(this, globalCtx); } else if (!func_80B26F6C(this, globalCtx)) { @@ -553,14 +554,14 @@ void func_80B27188(EnKendoJs* this, GlobalContext* globalCtx) { } if (this->unk_284 == 7) { - gSaveContext.weekEventReg[82] &= (u8)~8; + gSaveContext.save.weekEventReg[82] &= (u8)~8; func_80B26AE8(this); } } } void func_80B273D0(EnKendoJs* this) { - gSaveContext.weekEventReg[82] |= 8; + gSaveContext.save.weekEventReg[82] |= 8; this->unk_290 = 120; this->unk_284 = 0; this->unk_286 = 1; @@ -593,7 +594,7 @@ void func_80B274BC(EnKendoJs* this, GlobalContext* globalCtx) { this->unk_288 = 0x272E; } player->stateFlags1 |= 0x20; - gSaveContext.weekEventReg[82] &= (u8)~8; + gSaveContext.save.weekEventReg[82] &= (u8)~8; func_80B26AE8(this); return; } @@ -635,7 +636,7 @@ void func_80B276D8(EnKendoJs* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { this->actor.parent = NULL; func_80B27760(this); - } else if (!(gSaveContext.weekEventReg[63] & 0x20)) { + } else if (!(gSaveContext.save.weekEventReg[63] & 0x20)) { Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 800.0f, 100.0f); } else { Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_RED, 800.0f, 100.0f); @@ -650,8 +651,8 @@ void func_80B27774(EnKendoJs* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - if (!(gSaveContext.weekEventReg[63] & 0x20)) { - gSaveContext.weekEventReg[63] |= 0x20; + if (!(gSaveContext.save.weekEventReg[63] & 0x20)) { + gSaveContext.save.weekEventReg[63] |= 0x20; Message_StartTextbox(globalCtx, 0x272F, &this->actor); this->unk_288 = 0x272F; } else { diff --git a/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c b/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c index 0099ff9671..176a556e57 100644 --- a/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c +++ b/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c @@ -60,10 +60,10 @@ void EnKgy_Init(Actor* thisx, GlobalContext* globalCtx) { this->zubora = EnKgy_FindZubora(globalCtx); this->iceBlock = EnKgy_FindIceBlock(globalCtx); Flags_UnsetSwitch(globalCtx, ENKGY_GET_FE00(&this->actor) + 1); - if (Flags_GetSwitch(globalCtx, ENKGY_GET_FE00(&this->actor)) || (gSaveContext.weekEventReg[33] & 0x80)) { + if (Flags_GetSwitch(globalCtx, ENKGY_GET_FE00(&this->actor)) || (gSaveContext.save.weekEventReg[33] & 0x80)) { Flags_SetSwitch(globalCtx, ENKGY_GET_FE00(&this->actor) + 1); globalCtx->envCtx.lightSettingOverride = 1; - gSaveContext.weekEventReg[21] |= 1; + gSaveContext.save.weekEventReg[21] |= 1; if (!func_80B40D64(globalCtx)) { EnKgy_ChangeAnim(this, 4, 0, 0); this->actionFunc = func_80B425A0; @@ -80,7 +80,7 @@ void EnKgy_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.textId = 0xC50; } } else { - if (gSaveContext.weekEventReg[20] & 0x80) { + if (gSaveContext.save.weekEventReg[20] & 0x80) { EnKgy_ChangeAnim(this, 4, 0, 0); } else { EnKgy_ChangeAnim(this, 0, 0, 0); @@ -153,33 +153,33 @@ ObjIcePoly* EnKgy_FindIceBlock(GlobalContext* globalCtx) { } void func_80B40C74(GlobalContext* globalCtx) { - gSaveContext.permanentSceneFlags[globalCtx->sceneNum].unk_14 |= 1; + gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 |= 1; if (CURRENT_DAY == 1) { - gSaveContext.permanentSceneFlags[globalCtx->sceneNum].unk_14 |= 2; + gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 |= 2; } else { - gSaveContext.permanentSceneFlags[globalCtx->sceneNum].unk_14 &= ~2; + gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 &= ~2; } } void func_80B40D00(GlobalContext* globalCtx) { - gSaveContext.permanentSceneFlags[globalCtx->sceneNum].unk_14 |= 4; + gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 |= 4; } void func_80B40D30(GlobalContext* globalCtx) { - gSaveContext.permanentSceneFlags[globalCtx->sceneNum].unk_14 &= ~7; + gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 &= ~7; } s32 func_80B40D64(GlobalContext* globalCtx) { - return gSaveContext.permanentSceneFlags[globalCtx->sceneNum].unk_14 & 1; + return gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 & 1; } s32 func_80B40D8C(GlobalContext* globalCtx) { - return gSaveContext.permanentSceneFlags[globalCtx->sceneNum].unk_14 & 4; + return gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 & 4; } s32 func_80B40DB4(GlobalContext* globalCtx) { if ((CURRENT_DAY == 3) || - ((CURRENT_DAY == 2) && (gSaveContext.permanentSceneFlags[globalCtx->sceneNum].unk_14 & 2))) { + ((CURRENT_DAY == 2) && (gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 & 2))) { return true; } return false; @@ -362,7 +362,7 @@ void func_80B413C8(EnKgy* this) { } s32 func_80B41460(void) { - if ((gSaveContext.playerForm != PLAYER_FORM_HUMAN) || + if ((gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) || ((CUR_FORM_EQUIP(EQUIP_SLOT_B) != ITEM_SWORD_KOKIRI) && (CUR_FORM_EQUIP(EQUIP_SLOT_B) != ITEM_SWORD_RAZOR) && (CUR_FORM_EQUIP(EQUIP_SLOT_B) != ITEM_SWORD_GILDED))) { return 0xC38; @@ -457,7 +457,7 @@ void func_80B4163C(EnKgy* this, GlobalContext* globalCtx) { void func_80B417B8(EnKgy* this, GlobalContext* globalCtx) { func_80B4163C(this, globalCtx); - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); func_80B413C8(this); this->actor.flags &= ~ACTOR_FLAG_100; @@ -481,8 +481,8 @@ void func_80B41858(EnKgy* this, GlobalContext* globalCtx) { void func_80B418C4(EnKgy* this, GlobalContext* globalCtx) { func_80B4163C(this, globalCtx); if ((this->unk_2E4 <= 0) && !(this->unk_29C & 2) && (func_80B40E54(this) == 0) && - (Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx) && - ((globalCtx->msgCtx.unk11F04 == 0xC4E) || (globalCtx->msgCtx.unk11F04 == 0xC4F))) { + (Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx) && + ((globalCtx->msgCtx.currentTextId == 0xC4E) || (globalCtx->msgCtx.currentTextId == 0xC4F))) { func_801477B4(globalCtx); this->actor.textId = 0xC4F; func_80B413C8(this); @@ -616,14 +616,14 @@ void func_80B41E18(EnKgy* this, GlobalContext* globalCtx) { if ((this->unk_2E4 <= 0) && !(this->unk_29C & 2) && func_80B40E54(this) == 0) { switch (Message_GetState(&globalCtx->msgCtx)) { case 4: - if (func_80147624(globalCtx)) { - temp = globalCtx->msgCtx.unk11F04; + if (Message_ShouldAdvance(globalCtx)) { + temp = globalCtx->msgCtx.currentTextId; switch (temp) { case 0xC3B: switch (globalCtx->msgCtx.choiceIndex) { case 0: - if (gSaveContext.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { play_sound(NA_SE_SY_ERROR); func_80B40E74(this, globalCtx, 0xC3F); } else { @@ -658,8 +658,8 @@ void func_80B41E18(EnKgy* this, GlobalContext* globalCtx) { break; case 5: - if (func_80147624(globalCtx)) { - temp = globalCtx->msgCtx.unk11F04; + if (Message_ShouldAdvance(globalCtx)) { + temp = globalCtx->msgCtx.currentTextId; switch (temp) { case 0xC35: @@ -856,7 +856,7 @@ void func_80B425A0(EnKgy* this, GlobalContext* globalCtx) { void func_80B42660(EnKgy* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); this->actor.focus.pos = this->unk_2A8; - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); func_80B413C8(this); this->actor.flags &= ~ACTOR_FLAG_100; @@ -897,8 +897,8 @@ void func_80B427C8(EnKgy* this, GlobalContext* globalCtx) { } if ((this->unk_2E4 <= 0) && !(this->unk_29C & 2) && (func_80B40E54(this) == 0) && - (Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - temp_a2 = globalCtx->msgCtx.unk11F04; + (Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + temp_a2 = globalCtx->msgCtx.currentTextId; switch (temp_a2) { case 0xC30: @@ -969,8 +969,8 @@ void func_80B42A8C(EnKgy* this, GlobalContext* globalCtx) { } if ((this->unk_2E4 <= 0) && !(this->unk_29C & 2) && (func_80B40E54(this) == 0) && - (Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - temp_a2 = globalCtx->msgCtx.unk11F04; + (Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + temp_a2 = globalCtx->msgCtx.currentTextId; switch (temp_a2) { case 0xC1D: case 0xC2D: @@ -1056,7 +1056,7 @@ void func_80B42D28(EnKgy* this, GlobalContext* globalCtx) { func_80B40BC0(this, 1); } else { EnKgy_ChangeAnim(this, 5, 2, -5.0f); - gSaveContext.weekEventReg[20] |= 0x80; + gSaveContext.save.weekEventReg[20] |= 0x80; } func_80B411DC(this, globalCtx, 0); func_80B40E18(this, this->actor.textId); @@ -1064,7 +1064,7 @@ void func_80B42D28(EnKgy* this, GlobalContext* globalCtx) { if (Flags_GetSwitch(globalCtx, ENKGY_GET_FE00(&this->actor))) { this->actor.textId = 0xC30; this->actionFunc = func_80B4296C; - gSaveContext.weekEventReg[21] |= 1; + gSaveContext.save.weekEventReg[21] |= 1; } else if (this->actor.xzDistToPlayer < 200.0f) { if (this->unk_2D2 == 4) { this->actor.textId = 0xC2D; diff --git a/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.c b/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.c index cde9056535..caf235b058 100644 --- a/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.c +++ b/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.c @@ -2,9 +2,12 @@ * File: z_en_kujiya.c * Overlay: ovl_En_Kujiya * Description: Clock Town - Lottery Shop + * + * (kuji = lottery, ya = shop) */ #include "z_en_kujiya.h" +#include "objects/object_kujiya/object_kujiya.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_8000000) @@ -15,14 +18,22 @@ void EnKujiya_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnKujiya_Update(Actor* thisx, GlobalContext* globalCtx); void EnKujiya_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80BB09BC(EnKujiya* this, GlobalContext* globalCtx); -void func_80BB0E58(EnKujiya* this, GlobalContext* globalCtx); -void func_80BB0F38(EnKujiya* this, GlobalContext* globalCtx); -void func_80BB0FA8(EnKujiya* this, GlobalContext* globalCtx); -void func_80BB1180(EnKujiya* this, GlobalContext* globalCtx); -void func_80BB1268(EnKujiya* this, GlobalContext* globalCtx); +void EnKujiya_SetupWait(EnKujiya* this); +void EnKujiya_Wait(EnKujiya* this, GlobalContext* globalCtx); +void EnKujiya_SetupTalk(EnKujiya* this); +void EnKujiya_Talk(EnKujiya* this, GlobalContext* globalCtx); +void EnKujiya_SetupGivePrize(EnKujiya* this); +void EnKujiya_GivePrize(EnKujiya* this, GlobalContext* globalCtx); +void EnKujiya_SetupFinishGivePrize(EnKujiya* this); +void EnKujiya_FinishGivePrize(EnKujiya* this, GlobalContext* globalCtx); +s32 EnKujiya_CheckBoughtTicket(void); +void EnKujiya_SetBoughtTicket(void); +void EnKujiya_UnsetBoughtTicket(void); +void EnKujiya_SetupTurnToOpen(EnKujiya* this); +void EnKujiya_TurnToOpen(EnKujiya* this, GlobalContext* globalCtx); +void EnKujiya_SetupTurnToClosed(EnKujiya* this); +void EnKujiya_TurnToClosed(EnKujiya* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Kujiya_InitVars = { ACTOR_EN_KUJIYA, ACTORCAT_NPC, @@ -35,48 +46,332 @@ const ActorInit En_Kujiya_InitVars = { (ActorFunc)EnKujiya_Draw, }; -#endif +#define CHECK_LOTTERY_NUMBERS \ + (((u32)((void)0, gSaveContext.save.lotteryCodes[CURRENT_DAY - 1][0]) == \ + ((((void)0, gSaveContext.save.lotteryCodeGuess & 0xFFFF) & 0xF00) >> 8)) && \ + ((u32)((void)0, gSaveContext.save.lotteryCodes[CURRENT_DAY - 1][1]) == \ + ((((void)0, gSaveContext.save.lotteryCodeGuess & 0xFFFF) & 0xF0) >> 4)) && \ + ((u32)((void)0, gSaveContext.save.lotteryCodes[CURRENT_DAY - 1][2]) == \ + (((void)0, gSaveContext.save.lotteryCodeGuess & 0xFFFF) & 0xF))) -extern UNK_TYPE D_06006198; +void EnKujiya_Init(Actor* thisx, GlobalContext* globalCtx) { + EnKujiya* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/EnKujiya_Init.s") + Actor_SetScale(&this->actor, 0.1f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/EnKujiya_Destroy.s") + this->actor.flags &= ~ACTOR_FLAG_1; + this->actor.targetMode = 6; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB09A8.s") + this->actor.focus.pos = this->actor.world.pos; + this->actor.focus.pos.y += 30.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB09BC.s") + if (EnKujiya_CheckBoughtTicket() && (gSaveContext.save.time >= CLOCK_TIME(6, 0)) && + (gSaveContext.save.time < CLOCK_TIME(18, 0))) { + this->actor.shape.rot.y = 0; + } else { + this->actor.shape.rot.y = 0x7555; + } + EnKujiya_SetupWait(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB0B28.s") +void EnKujiya_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB0BF8.s") +void EnKujiya_SetupWait(EnKujiya* this) { + this->actionFunc = EnKujiya_Wait; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB0E44.s") +void EnKujiya_Wait(EnKujiya* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if ((gSaveContext.save.time >= CLOCK_TIME(6, 0)) && (gSaveContext.save.time < CLOCK_TIME(18, 0))) { + if (EnKujiya_CheckBoughtTicket()) { + Message_StartTextbox(globalCtx, 0x2B61, &this->actor); + this->textId = 0x2B61; // Come back tomorrow + } else { + Message_StartTextbox(globalCtx, 0x2B5C, &this->actor); + this->textId = 0x2B5C; // Pick 3 numbers + } + } else if (EnKujiya_CheckBoughtTicket()) { + Message_StartTextbox(globalCtx, 0x2B64, &this->actor); + this->textId = 0x2B64; // Announce winning numbers + } else { + Message_StartTextbox(globalCtx, 0x2B63, &this->actor); + this->textId = 0x2B63; // Exchanging winning tickets + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB0E58.s") + EnKujiya_SetupTalk(this); + } else if ((gSaveContext.save.time >= CLOCK_TIME(18, 0)) && EnKujiya_CheckBoughtTicket() && + (this->actor.shape.rot.y == 0)) { + EnKujiya_SetupTurnToOpen(this); + } else if (this->actor.xzDistToPlayer < 100.0f) { + func_800B8614(&this->actor, globalCtx, 100.0f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB0F24.s") +void EnKujiya_HandlePlayerChoice(EnKujiya* this, GlobalContext* globalCtx) { + if (Message_ShouldAdvance(globalCtx)) { + if (globalCtx->msgCtx.choiceIndex == 0) { // Buy + if (gSaveContext.save.playerData.rupees < 10) { + play_sound(NA_SE_SY_ERROR); + Message_StartTextbox(globalCtx, 0x2B62, &this->actor); + this->textId = 0x2B62; // Not enough Rupees + } else { + func_8019F208(); + func_801159EC(-10); + Message_StartTextbox(globalCtx, 0x2B5F, &this->actor); + this->textId = 0x2B5F; // Enter number + } + } else { // Don't buy + func_8019F230(); + Message_StartTextbox(globalCtx, 0x2B5E, &this->actor); + this->textId = 0x2B5E; // Too bad + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB0F38.s") +void EnKujiya_ChooseNextDialogue(EnKujiya* this, GlobalContext* globalCtx) { + // Build suspense + if (this->textId == 0x2B65) { // Your numbers vs winning numbers + if (this->timer != 0) { + this->timer--; + return; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB0F94.s") + if (Message_ShouldAdvance(globalCtx)) { + switch (this->textId) { + case 0x2B5C: + Message_StartTextbox(globalCtx, 0x2B5D, &this->actor); + this->textId = 0x2B5D; // Buy or not + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB0FA8.s") + case 0x2B60: + EnKujiya_SetBoughtTicket(); + func_801477B4(globalCtx); + EnKujiya_SetupTurnToClosed(this); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB0FF8.s") + case 0x2B64: + EnKujiya_UnsetBoughtTicket(); + this->timer = 20; + Message_StartTextbox(globalCtx, 0x2B65, &this->actor); + this->textId = 0x2B65; // Your numbers vs winning numbers + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB1088.s") + case 0x2B65: + if (CHECK_LOTTERY_NUMBERS) { + Message_StartTextbox(globalCtx, 0x2B66, &this->actor); + this->textId = 0x2B66; // Won 50 Rupees + } else { + Message_StartTextbox(globalCtx, 0x2B67, &this->actor); + this->textId = 0x2B67; // Lost, come back tomorrow + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB10F8.s") + case 0x2B66: + func_801477B4(globalCtx); + EnKujiya_SetupGivePrize(this); + EnKujiya_GivePrize(this, globalCtx); + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB1168.s") +void EnKujiya_SetupTalk(EnKujiya* this) { + this->actionFunc = EnKujiya_Talk; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB1180.s") +void EnKujiya_Talk(EnKujiya* this, GlobalContext* globalCtx) { + switch (Message_GetState(&globalCtx->msgCtx)) { + case 0: + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB1250.s") + case 4: + EnKujiya_HandlePlayerChoice(this, globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB1268.s") + case 5: + EnKujiya_ChooseNextDialogue(this, globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/EnKujiya_Update.s") + case 6: + if (Message_ShouldAdvance(globalCtx)) { + EnKujiya_SetupWait(this); + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/EnKujiya_Draw.s") + case 17: + if (Message_ShouldAdvance(globalCtx)) { + Inventory_SaveLotteryCodeGuess(globalCtx); + Message_StartTextbox(globalCtx, 0x2B60, &this->actor); + this->textId = 0x2B60; // Will announce winning numbers after 6 + } + break; + } +} + +void EnKujiya_SetupGivePrize(EnKujiya* this) { + this->actionFunc = EnKujiya_GivePrize; +} + +void EnKujiya_GivePrize(EnKujiya* this, GlobalContext* globalCtx) { + if (Actor_HasParent(&this->actor, globalCtx)) { + EnKujiya_SetupFinishGivePrize(this); + } else { + Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_PURPLE, 500.0f, 100.0f); + } +} + +void EnKujiya_SetupFinishGivePrize(EnKujiya* this) { + this->actionFunc = EnKujiya_FinishGivePrize; +} + +void EnKujiya_FinishGivePrize(EnKujiya* this, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == 6) && Message_ShouldAdvance(globalCtx)) { + EnKujiya_SetupWait(this); + } +} + +s32 EnKujiya_CheckBoughtTicket(void) { + switch (CURRENT_DAY) { + case 1: + if (gSaveContext.save.weekEventReg[33] & 0x10) { + return true; + } + break; + + case 2: + if (gSaveContext.save.weekEventReg[33] & 0x20) { + return true; + } + break; + + case 3: + if (gSaveContext.save.weekEventReg[33] & 0x40) { + return true; + } + break; + } + return false; +} + +void EnKujiya_SetBoughtTicket(void) { + switch (CURRENT_DAY) { + case 1: + gSaveContext.save.weekEventReg[33] |= 0x10; + break; + + case 2: + gSaveContext.save.weekEventReg[33] |= 0x20; + break; + + case 3: + gSaveContext.save.weekEventReg[33] |= 0x40; + break; + } +} + +/** + * Used when player turns in a ticket + */ +void EnKujiya_UnsetBoughtTicket(void) { + switch (CURRENT_DAY) { + case 1: + gSaveContext.save.weekEventReg[33] &= (u8)~0x10; + break; + + case 2: + gSaveContext.save.weekEventReg[33] &= (u8)~0x20; + break; + + case 3: + gSaveContext.save.weekEventReg[33] &= (u8)~0x40; + break; + } +} + +void EnKujiya_SetupTurnToOpen(EnKujiya* this) { + this->timer = 0; + this->actionFunc = EnKujiya_TurnToOpen; +} + +void EnKujiya_TurnToOpen(EnKujiya* this, GlobalContext* globalCtx) { + if (this->actor.cutscene != -1) { + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } + } + + if (!Math_SmoothStepToS(&this->actor.shape.rot.y, 0x7555, 0xA, 0x16C, 0x16C)) { + if (this->timer > 20) { + if (ActorCutscene_GetCurrentIndex() == this->actor.cutscene) { + ActorCutscene_Stop(this->actor.cutscene); + } + EnKujiya_SetupWait(this); + } else { + this->timer++; + } + } else { + func_800B9010(&this->actor, NA_SE_EV_WINDMILL_LEVEL - SFX_FLAG); + } +} + +void EnKujiya_SetupTurnToClosed(EnKujiya* this) { + this->timer = 0; + this->actionFunc = EnKujiya_TurnToClosed; +} + +void EnKujiya_TurnToClosed(EnKujiya* this, GlobalContext* globalCtx) { + if (this->actor.cutscene != -1) { + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } + } + + if (!Math_SmoothStepToS(&this->actor.shape.rot.y, 0, 0xA, 0x16C, 0x16C)) { + if (this->timer > 20) { + if (ActorCutscene_GetCurrentIndex() == this->actor.cutscene) { + ActorCutscene_Stop(this->actor.cutscene); + } + EnKujiya_SetupWait(this); + } else { + this->timer++; + } + } else { + func_800B9010(&this->actor, NA_SE_EV_WINDMILL_LEVEL - SFX_FLAG); + } +} + +void EnKujiya_Update(Actor* thisx, GlobalContext* globalCtx) { + EnKujiya* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void EnKujiya_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnKujiya* this = THIS; + + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(gLotteryShopTexAnim)); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gLotteryShopCylinderDL); + gSPDisplayList(POLY_OPA_DISP++, gLotteryShopBackSignDL); + gSPDisplayList(POLY_OPA_DISP++, gLotteryShopOpenBoxDL); + gSPDisplayList(POLY_OPA_DISP++, gLotteryShopScrollingEffectsDL); + gSPDisplayList(POLY_OPA_DISP++, gLotteryShopRedRupeesDL); + gSPDisplayList(POLY_OPA_DISP++, gLotteryShopGreenRupeesDL); + gSPDisplayList(POLY_OPA_DISP++, gLotteryShopBlueRupeesDL); + gSPDisplayList(POLY_OPA_DISP++, gLotteryShopTargetArrowAndSignDL); + gSPDisplayList(POLY_OPA_DISP++, gLotteryShopScrollingArrowDL); + gSPDisplayList(POLY_OPA_DISP++, gLotteryShopMaskDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.h b/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.h index 72aeb93b7c..b95a5bb366 100644 --- a/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.h +++ b/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.h @@ -8,9 +8,10 @@ struct EnKujiya; typedef void (*EnKujiyaActionFunc)(struct EnKujiya*, GlobalContext*); typedef struct EnKujiya { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnKujiyaActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x4]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnKujiyaActionFunc actionFunc; + /* 0x148 */ s16 timer; + /* 0x14A */ s16 textId; } EnKujiya; // size = 0x14C extern const ActorInit En_Kujiya_InitVars; diff --git a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c index 9b8b869691..4c9f10ff8e 100644 --- a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c +++ b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c @@ -4,7 +4,11 @@ * Description: Grass / Bush */ +#include "prevent_bss_reordering.h" #include "z_en_kusa.h" +#include "objects/object_kusa/object_kusa.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/gameplay_field_keep/gameplay_field_keep.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_800000) @@ -14,15 +18,46 @@ void EnKusa_Init(Actor* thisx, GlobalContext* globalCtx); void EnKusa_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnKusa_Update(Actor* thisx, GlobalContext* globalCtx); -void func_809358D8(EnKusa* this, GlobalContext* globalCtx); -void func_809359AC(EnKusa* this, GlobalContext* globalCtx); -void func_80935BBC(EnKusa* this, GlobalContext* globalCtx); -void func_80935D64(EnKusa* this, GlobalContext* globalCtx); -void func_809361A4(EnKusa* this, GlobalContext* globalCtx); -void func_80936220(EnKusa* this, GlobalContext* globalCtx); -void func_809362D8(EnKusa* this, GlobalContext* globalCtx); +s32 EnKusa_SnapToFloor(EnKusa* this, GlobalContext* globalCtx, f32 yOffset); +void EnKusa_DropCollectible(EnKusa* this, GlobalContext* globalCtx); +void EnKusa_UpdateVelY(EnKusa* this); +void EnKusa_RandScaleVecToZero(Vec3f* vec, f32 scaleFactor); +void EnKusa_SetScaleSmall(EnKusa* this); +s32 EnKusa_GetWaterBox(EnKusa* this, GlobalContext* globalCtx); +void EnKusa_SetupWaitObject(EnKusa* this); +void EnKusa_WaitObject(EnKusa* this, GlobalContext* globalCtx); +void EnKusa_WaitForInteract(EnKusa* this, GlobalContext* globalCtx); +void EnKusa_SetupLiftedUp(EnKusa* this); +void EnKusa_LiftedUp(EnKusa* this, GlobalContext* globalCtx); +void EnKusa_WaitObject(EnKusa* this, GlobalContext* globalCtx); +void EnKusa_SetupInteract(EnKusa* this); +void EnKusa_SetupFall(EnKusa* this); +void EnKusa_Fall(EnKusa* this, GlobalContext* globalCtx); +void EnKusa_SetupCut(EnKusa* this); +void EnKusa_CutWaitRegrow(EnKusa* this, GlobalContext* globalCtx); +void EnKusa_DoNothing(EnKusa* this, GlobalContext* globalCtx); +void EnKusa_SetupUprootedWaitRegrow(EnKusa* this); +void EnKusa_UprootedWaitRegrow(EnKusa* this, GlobalContext* globalCtx); +void EnKusa_SetupRegrow(EnKusa* this); +void EnKusa_Regrow(EnKusa* this, GlobalContext* globalCtx); +void EnKusa_DrawBush(Actor* thisx, GlobalContext* globalCtx2); +void EnKusa_DrawGrass(Actor* thisx, GlobalContext* globalCtx); + +s16 rotSpeedXtarget = 0; +s16 rotSpeedX = 0; +s16 rotSpeedYtarget = 0; +s16 rotSpeedY = 0; +s16 D_809366B0 = 0; +u8 D_809366B4 = true; + +u32 kusaGameplayFrames; +MtxF D_80936AD8[8]; +s16 D_80936CD8; +s16 D_80936CDA; +s16 D_80936CDC; +s16 D_80936CDE; +s16 D_80936CE0; -#if 0 const ActorInit En_Kusa_InitVars = { ACTOR_EN_KUSA, ACTORCAT_PROP, @@ -35,18 +70,40 @@ const ActorInit En_Kusa_InitVars = { (ActorFunc)NULL, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_809366E0 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_PLAYER, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_2, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00400000, 0x00, 0x02 }, { 0x0580C71C, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NONE, BUMP_ON, OCELEM_ON, }, +static s16 objectIds[] = { GAMEPLAY_FIELD_KEEP, OBJECT_KUSA, OBJECT_KUSA, OBJECT_KUSA }; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_PLAYER, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_2, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00400000, 0x00, 0x02 }, + { 0x0580C71C, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NONE, + BUMP_ON, + OCELEM_ON, + }, { 6, 44, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit D_8093670C = { 0, 12, 30, MASS_IMMOVABLE }; +static CollisionCheckInfoInit sColChkInfoInit = { 0, 12, 30, MASS_IMMOVABLE }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80936754[] = { +static Vec3f sUnitDirections[] = { + { 0.0f, 0.7071f, 0.7071f }, + { 0.7071f, 0.7071f, 0.0f }, + { 0.0f, 0.7071f, -0.7071f }, + { -0.7071f, 0.7071f, 0.0f }, +}; + +static s16 sFragmentScales[] = { 108, 102, 96, 84, 66, 55, 42, 38 }; + +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 400, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -3200, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(terminalVelocity, -17000, ICHAIN_CONTINUE), @@ -55,72 +112,623 @@ static InitChainEntry D_80936754[] = { ICHAIN_F32(uncullZoneDownward, 200, ICHAIN_STOP), }; -#endif +/** + * @brief Applies a "swaying" motion to the provided matrix + * + */ +void EnKusa_ApplySway(MtxF* matrix) { + MtxF* mtxState = Matrix_GetCurrentState(); + f32* tmp = &mtxState->mf[0][0]; + f32* tmp2 = &matrix->mf[0][0]; + s32 i; -extern ColliderCylinderInit D_809366E0; -extern CollisionCheckInfoInit D_8093670C; -extern InitChainEntry D_80936754[]; + for (i = 0; i < 16; i++) { + *tmp++ += *tmp2++; + } +} -extern UNK_TYPE D_060002E0; +/** + * @brief Updates the matrix controlling movement of the leaves of grass to simulate a swaying motion from the wind + * blowing. + */ +void EnKusa_Sway(void) { + s32 i; + s32 pad; + f32 sin_6CDA; + f32* ptr; + f32 sin_6CDE; + f32 sin_6CE0; + f32 tempf1; + f32 tempf2; + f32 tempf3; + f32 tempf4; + f32 tempf5; + f32 sp7C[8]; + f32 cos_6CE0; + f32 cos_6CDA; + f32 cos_6CDC; + f32 cos_6CDE; + f32 cos_6CD8; + f32 sin_6CD8; + f32 sin_6CDC; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_809349E0.s") + D_80936CD8 += 0x46; + D_80936CDA += 0x12C; + D_80936CDC += 0x2BC; + D_80936CDE += 0x514; + D_80936CE0 += 0x22C4; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_80934AB4.s") + sin_6CD8 = Math_SinS(D_80936CD8); + sin_6CDA = Math_SinS(D_80936CDA); + sin_6CDC = Math_SinS(D_80936CDC); + sin_6CDE = Math_SinS(D_80936CDE) * 1.2f; + sin_6CE0 = Math_SinS(D_80936CE0) * 1.5f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_80934F58.s") + cos_6CD8 = Math_CosS(D_80936CD8); + cos_6CDA = Math_CosS(D_80936CDA); + cos_6CDC = Math_CosS(D_80936CDC); + cos_6CDE = Math_CosS(D_80936CDE) * 1.3f; + cos_6CE0 = Math_CosS(D_80936CE0) * 1.7f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_80934FFC.s") + sp7C[0] = (sin_6CD8 - cos_6CDA) * sin_6CDC * cos_6CD8 * sin_6CD8 * 0.0015f; + sp7C[1] = (sin_6CDA - cos_6CDC) * sin_6CDE * cos_6CDA * sin_6CD8 * 0.0015f; + sp7C[2] = (sin_6CDC - cos_6CDE) * cos_6CDC * sin_6CD8 * cos_6CD8 * 0.0015f; + sp7C[3] = (sin_6CDE - cos_6CDA) * cos_6CDE * sin_6CDA * cos_6CD8 * 0.0015f; + sp7C[4] = (sin_6CD8 - cos_6CDC) * sin_6CD8 * sin_6CDA * sin_6CE0 * 0.0015f; + sp7C[5] = (sin_6CDA - cos_6CDE) * sin_6CDC * sin_6CDE * sin_6CE0 * 0.0015f; + sp7C[6] = (sin_6CDC - cos_6CD8) * cos_6CD8 * cos_6CDA * cos_6CE0 * 0.0015f; + sp7C[7] = (sin_6CDE - cos_6CDA) * cos_6CDC * cos_6CDE * cos_6CE0 * 0.0015f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_809350C4.s") + for (i = 0; i < ARRAY_COUNT(D_80936AD8); i++) { + ptr = &D_80936AD8[i].mf[0][0]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_809350F8.s") + tempf1 = sp7C[i & 7]; + tempf2 = sp7C[(i + 1) & 7]; + tempf3 = sp7C[(i + 2) & 7]; + tempf4 = sp7C[(i + 3) & 7]; + tempf5 = sp7C[(i + 4) & 7]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_8093517C.s") + ptr[0] = sp7C[1] * 0.2f; + ptr[1] = tempf1; + ptr[2] = tempf2; + ptr[3] = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_809351A0.s") + ptr[4] = tempf3; + ptr[5] = sp7C[0]; + ptr[6] = tempf3; + ptr[7] = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_809354F8.s") + ptr[8] = tempf4; + ptr[9] = tempf5; + ptr[10] = sp7C[3] * 0.2f; + ptr[11] = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_809355A4.s") + ptr[12] = 0.0f; + ptr[13] = 0.0f; + ptr[14] = 0.0f; + ptr[15] = 0.0f; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_8093561C.s") +/** + * @brief Detects if a bush is able to snap to the floor. BgCheck_EntityRaycastFloor5 will give the intersect point + * if no poit is found, a false value is returned. + * + * @param this + * @param globalCtx + * @param yOffset offset of Y coordinate, can be positive or negative. + * @return true/false if the bush is able to snap to the floor and is above BGCHECK_Y_MIN + */ +s32 EnKusa_SnapToFloor(EnKusa* this, GlobalContext* globalCtx, f32 yOffset) { + s32 pad; + CollisionPoly* poly; + Vec3f pos; + s32 bgId; + f32 floorY; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/EnKusa_Init.s") + pos.x = this->actor.world.pos.x; + pos.y = this->actor.world.pos.y + 30.0f; + pos.z = this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/EnKusa_Destroy.s") + floorY = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &poly, &bgId, &this->actor, &pos); + if (floorY > BGCHECK_Y_MIN) { + this->actor.world.pos.y = floorY + yOffset; + Math_Vec3f_Copy(&this->actor.home.pos, &this->actor.world.pos); + return true; + } else { + return false; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_809358C4.s") +void EnKusa_DropCollectible(EnKusa* this, GlobalContext* globalCtx) { + s32 collectible; + s32 collectableParams; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_809358D8.s") + if ((GET_KUSA_TYPE(&this->actor) == ENKUSA_TYPE_GRASS) || (GET_KUSA_TYPE(&this->actor) == ENKUSA_TYPE_BUSH)) { + if (!(KUSA_GET_PARAMS_0C(&this->actor))) { + Item_DropCollectibleRandom(globalCtx, NULL, &this->actor.world.pos, + KUSA_GET_RAND_COLLECTIBLE_ID(&this->actor) * 0x10); + } + } else if (GET_KUSA_TYPE(&this->actor) == ENKUSA_TYPE_REGROWING_GRASS) { + Item_DropCollectible(globalCtx, &this->actor.world.pos, 3); + } else { + collectible = func_800A8150(KUSA_GET_PARAMS_3F(&this->actor)); + if (collectible >= 0) { + collectableParams = KUSA_GET_COLLECTIBLE_ID(&this->actor); + Item_DropCollectible(globalCtx, &this->actor.world.pos, (collectableParams << 8) | collectible); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_80935988.s") +void EnKusa_UpdateVelY(EnKusa* this) { + this->actor.velocity.y += this->actor.gravity; + if (this->actor.velocity.y < this->actor.terminalVelocity) { + this->actor.velocity.y = this->actor.terminalVelocity; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_809359AC.s") +/** + * @brief Scales a vector down by provided scale factor + * + * @param vec vector to be scaled + * @param scaleFactor scale factor to be applied to vector + */ +void EnKusa_RandScaleVecToZero(Vec3f* vec, f32 scaleFactor) { + scaleFactor += ((Rand_ZeroOne() * 0.2f) - 0.1f) * scaleFactor; + vec->x -= vec->x * scaleFactor; + vec->y -= vec->y * scaleFactor; + vec->z -= vec->z * scaleFactor; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_80935B94.s") +void EnKusa_SetScaleSmall(EnKusa* this) { + this->actor.scale.y = 160.0f * 0.001f; + this->actor.scale.x = 120.0f * 0.001f; + this->actor.scale.z = 120.0f * 0.001f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_80935BBC.s") +void EnKusa_SpawnFragments(EnKusa* this, GlobalContext* globalCtx) { + Vec3f velocity; + Vec3f pos; + s32 i; + s32 scaleIndex; + Vec3f* directon; + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_80935CE8.s") + for (i = 0; i < ARRAY_COUNT(sUnitDirections); i++) { + directon = &sUnitDirections[i]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_80935D64.s") + pos.x = this->actor.world.pos.x + (directon->x * this->actor.scale.x * 20.0f); + pos.y = this->actor.world.pos.y + (directon->y * this->actor.scale.y * 20.0f) + 10.0f; + pos.z = this->actor.world.pos.z + (directon->z * this->actor.scale.z * 20.0f); + velocity.x = (Rand_ZeroOne() - 0.5f) * 8.0f; + velocity.y = Rand_ZeroOne() * 10.0f; + velocity.z = (Rand_ZeroOne() - 0.5f) * 8.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_80936120.s") + scaleIndex = (s32)(Rand_ZeroOne() * 111.1f) & 7; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_80936168.s") + EffectSsKakera_Spawn(globalCtx, &pos, &velocity, &pos, -100, 64, 40, 3, 0, sFragmentScales[scaleIndex], 0, 0, + 0x50, -1, 1, gKakeraLeafMiddle); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_809361A4.s") + pos.x = this->actor.world.pos.x + (directon->x * this->actor.scale.x * 40.0f); + pos.y = this->actor.world.pos.y + (directon->y * this->actor.scale.y * 40.0f) + 10.0f; + pos.z = this->actor.world.pos.z + (directon->z * this->actor.scale.z * 40.0f); + velocity.x = (Rand_ZeroOne() - 0.5f) * 6.0f; + velocity.y = Rand_ZeroOne() * 10.0f; + velocity.z = (Rand_ZeroOne() - 0.5f) * 6.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_809361B4.s") + scaleIndex = (s32)(Rand_ZeroOne() * 111.1f) % 7; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_80936220.s") + EffectSsKakera_Spawn(globalCtx, &pos, &velocity, &pos, -100, 64, 40, 3, 0, sFragmentScales[scaleIndex], 0, 0, + 0x50, -1, 1, gKakeraLeafTip); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_80936290.s") +void EnKusa_SpawnBugs(EnKusa* this, GlobalContext* globalCtx) { + u32 numBugs; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_809362D8.s") + for (numBugs = 0; numBugs < 3; numBugs++) { + Actor* bug = Actor_SpawnAsChildAndCutscene( + &globalCtx->actorCtx, globalCtx, ACTOR_EN_INSECT, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 0, 0, 0, 1, this->actor.cutscene, this->actor.unk20, 0); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/EnKusa_Update.s") + if (bug == NULL) { + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_80936414.s") +s32 EnKusa_GetWaterBox(EnKusa* this, GlobalContext* globalCtx) { + s32 pad; + WaterBox* waterBox; + f32 ySurface; + s32 bgId; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_809365CC.s") + if (WaterBox_GetSurfaceImpl(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &ySurface, &waterBox, &bgId) && + (this->actor.world.pos.y < ySurface)) { + return true; + } + return false; +} + +void EnKusa_InitCollider(Actor* thisx, GlobalContext* globalCtx) { + EnKusa* this = THIS; + + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_UpdateCylinder(thisx, &this->collider); +} + +void EnKusa_Init(Actor* thisx, GlobalContext* globalCtx) { + EnKusa* this = THIS; + s32 pad; + s32 kusaType = GET_KUSA_TYPE(&this->actor); + + Actor_ProcessInitChain(&this->actor, sInitChain); + + if (globalCtx->csCtx.state != 0) { + this->actor.uncullZoneForward += 1000.0f; + } + EnKusa_InitCollider(&this->actor, globalCtx); + CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); + + if (kusaType == ENKUSA_TYPE_BUSH) { + this->actor.shape.shadowScale = 1.0f; + this->actor.shape.shadowAlpha = 60; + } else { + this->actor.shape.shadowScale = 0.9f; + this->actor.shape.shadowAlpha = 70; + } + + if (this->actor.shape.rot.y == 0) { + this->actor.shape.rot.y = ((u32)Rand_Next() >> 0x10); + this->actor.home.rot.y = this->actor.shape.rot.y; + this->actor.world.rot.y = this->actor.shape.rot.y; + } + if (!EnKusa_SnapToFloor(this, globalCtx, 0.0f)) { + Actor_MarkForDeath(&this->actor); + return; + } + if (EnKusa_GetWaterBox(this, globalCtx)) { + this->isInWater |= 1; + } + + this->objIndex = Object_GetIndex(&globalCtx->objectCtx, objectIds[(GET_KUSA_TYPE(&this->actor))]); + if (this->objIndex < 0) { + Actor_MarkForDeath(&this->actor); + return; + } + + EnKusa_SetupWaitObject(this); + if (D_809366B4) { + D_80936CD8 = ((u32)Rand_Next() >> 0x10); + D_80936CDA = ((u32)Rand_Next() >> 0x10); + D_80936CDC = ((u32)Rand_Next() >> 0x10); + D_80936CDE = ((u32)Rand_Next() >> 0x10); + D_80936CE0 = ((u32)Rand_Next() >> 0x10); + D_809366B4 = false; + EnKusa_Sway(); + kusaGameplayFrames = globalCtx->gameplayFrames; + } + this->kusaMtxIdx = D_809366B0 & 7; + D_809366B0++; +} + +void EnKusa_Destroy(Actor* thisx, GlobalContext* globalCtx) { + GlobalContext* globalCtx2 = globalCtx; + EnKusa* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +void EnKusa_SetupWaitObject(EnKusa* this) { + this->actionFunc = EnKusa_WaitObject; +} + +void EnKusa_WaitObject(EnKusa* this, GlobalContext* globalCtx) { + s32 pad; + + if (Object_IsLoaded(&globalCtx->objectCtx, this->objIndex)) { + s32 kusaType = GET_KUSA_TYPE(&this->actor); + + if (this->isCut) { + EnKusa_SetupCut(this); + } else { + EnKusa_SetupInteract(this); + } + if (kusaType == ENKUSA_TYPE_BUSH) { + this->actor.draw = EnKusa_DrawBush; + } else { + this->actor.draw = EnKusa_DrawGrass; + } + this->actor.objBankIndex = this->objIndex; + this->actor.flags &= ~ACTOR_FLAG_10; + } +} + +void EnKusa_SetupInteract(EnKusa* this) { + this->actionFunc = EnKusa_WaitForInteract; + this->actor.flags &= ~ACTOR_FLAG_10; +} + +void EnKusa_WaitForInteract(EnKusa* this, GlobalContext* globalCtx) { + s32 pad; + + if (Actor_HasParent(&this->actor, globalCtx)) { + EnKusa_SetupLiftedUp(this); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_PL_PULL_UP_PLANT); + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; + + } else if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + EnKusa_SpawnFragments(this, globalCtx); + EnKusa_DropCollectible(this, globalCtx); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_PLANT_BROKEN); + + if (KUSA_SHOULD_SPAWN_BUGS(&this->actor)) { + if (GET_KUSA_TYPE(&this->actor) != ENKUSA_TYPE_GRASS_2) { + EnKusa_SpawnBugs(this, globalCtx); + } + } + if (GET_KUSA_TYPE(&this->actor) == ENKUSA_TYPE_BUSH) { + Actor_MarkForDeath(&this->actor); + } else { + EnKusa_SetupCut(this); + this->isCut = true; + } + + } else { + if (!(this->collider.base.ocFlags1 & OC1_TYPE_PLAYER) && (this->actor.xzDistToPlayer > 12.0f)) { + this->collider.base.ocFlags1 |= OC1_TYPE_PLAYER; + } + + if (this->actor.xzDistToPlayer < 600.0f) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + + if (this->actor.xzDistToPlayer < 400.0f) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + if (this->actor.xzDistToPlayer < 100.0f) { + if (GET_KUSA_TYPE(&this->actor) != ENKUSA_TYPE_GRASS_2) { + Actor_LiftActor(&this->actor, globalCtx); + } + } + } + } + } +} + +void EnKusa_SetupLiftedUp(EnKusa* this) { + this->actionFunc = EnKusa_LiftedUp; + this->actor.room = -1; + this->actor.flags |= ACTOR_FLAG_10; +} + +void EnKusa_LiftedUp(EnKusa* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f pos; + s32 bgId; + + if (Actor_HasNoParent(&this->actor, globalCtx)) { + this->actor.room = globalCtx->roomCtx.currRoom.num; + EnKusa_SetupFall(this); + this->actor.velocity.x = this->actor.speedXZ * Math_SinS(this->actor.world.rot.y); + this->actor.velocity.z = this->actor.speedXZ * Math_CosS(this->actor.world.rot.y); + this->actor.colChkInfo.mass = 80; + this->actor.gravity = -0.1f; + EnKusa_UpdateVelY(this); + EnKusa_RandScaleVecToZero(&this->actor.velocity, 0.005f); + Actor_UpdatePos(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 7.5f, 35.0f, 0.0f, 0xC5); + this->actor.gravity = -3.2f; + } else { + pos.x = this->actor.world.pos.x; + pos.y = this->actor.world.pos.y + 20.0f; + pos.z = this->actor.world.pos.z; + this->actor.floorHeight = + BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->actor.floorPoly, &bgId, &this->actor, &pos); + } +} + +void EnKusa_SetupFall(EnKusa* this) { + this->actionFunc = EnKusa_Fall; + rotSpeedXtarget = -0xBB8; + rotSpeedYtarget = (Rand_ZeroOne() - 0.5f) * 1600.0f; + rotSpeedX = 0; + rotSpeedY = 0; + this->timer = 0; +} + +void EnKusa_Fall(EnKusa* this, GlobalContext* globalCtx) { + s32 pad; + s32 wasHit; + Vec3f contactPos; + s32 i; + s16 angleOffset; + + wasHit = (this->collider.base.atFlags & AT_HIT) != 0; + + if (wasHit) { + this->collider.base.atFlags &= ~AT_HIT; + } + this->timer++; + if ((this->actor.bgCheckFlags & 0xB) || wasHit || (this->timer >= 100)) { + if (!(this->actor.bgCheckFlags & 0x20)) { + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_PLANT_BROKEN); + } + EnKusa_SpawnFragments(this, globalCtx); + EnKusa_DropCollectible(this, globalCtx); + switch (GET_KUSA_TYPE(&this->actor)) { + case ENKUSA_TYPE_BUSH: + case ENKUSA_TYPE_GRASS: + Actor_MarkForDeath(&this->actor); + break; + + case ENKUSA_TYPE_REGROWING_GRASS: + EnKusa_SetupUprootedWaitRegrow(this); + this->actor.shape.shadowDraw = NULL; + break; + } + + } else { + if (this->actor.bgCheckFlags & 0x40) { + contactPos.y = this->actor.world.pos.y + this->actor.depthInWater; + for (angleOffset = 0, i = 0; i < 4; i++, angleOffset += 0x4000) { + contactPos.x = + (Math_SinS((s32)(Rand_ZeroOne() * 7200.0f) + angleOffset) * 15.0f) + this->actor.world.pos.x; + contactPos.z = + (Math_CosS((s32)(Rand_ZeroOne() * 7200.0f) + angleOffset) * 15.0f) + this->actor.world.pos.z; + EffectSsGSplash_Spawn(globalCtx, &contactPos, NULL, NULL, 0, 190); + } + contactPos.x = this->actor.world.pos.x; + contactPos.z = this->actor.world.pos.z; + EffectSsGSplash_Spawn(globalCtx, &contactPos, NULL, NULL, 0, 280); + EffectSsGRipple_Spawn(globalCtx, &contactPos, 300, 700, 0); + this->actor.terminalVelocity = -3.0f; + this->actor.velocity.x *= 0.1f; + this->actor.velocity.y *= 0.4f; + this->actor.velocity.z *= 0.1f; + this->actor.gravity *= 0.5f; + rotSpeedX >>= 1; + rotSpeedXtarget >>= 1; + rotSpeedY >>= 1; + rotSpeedYtarget >>= 1; + this->actor.bgCheckFlags &= ~0x40; + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_DIVE_INTO_WATER_L); + } + EnKusa_UpdateVelY(this); + Math_StepToS(&rotSpeedX, rotSpeedXtarget, 500); + Math_StepToS(&rotSpeedY, rotSpeedYtarget, 170); + this->actor.shape.rot.x += rotSpeedX; + this->actor.shape.rot.y += rotSpeedY; + EnKusa_RandScaleVecToZero(&this->actor.velocity, 0.05f); + Actor_UpdatePos(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 7.5f, 35.0f, 0.0f, 0xC5); + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +void EnKusa_SetupCut(EnKusa* this) { + switch (GET_KUSA_TYPE(&this->actor)) { + case ENKUSA_TYPE_GRASS: + case ENKUSA_TYPE_GRASS_2: + this->actionFunc = EnKusa_DoNothing; + break; + case ENKUSA_TYPE_REGROWING_GRASS: + this->actionFunc = EnKusa_CutWaitRegrow; + break; + } + this->timer = 0; +} + +void EnKusa_CutWaitRegrow(EnKusa* this, GlobalContext* globalCtx) { + this->timer++; + if (this->timer >= 120) { + EnKusa_SetupRegrow(this); + } +} + +void EnKusa_DoNothing(EnKusa* this, GlobalContext* globalCtx) { +} + +void EnKusa_SetupUprootedWaitRegrow(EnKusa* this) { + this->actor.world.pos.x = this->actor.home.pos.x; + this->actor.world.pos.y = this->actor.home.pos.y - 9.0f; + this->actor.world.pos.z = this->actor.home.pos.z; + EnKusa_SetScaleSmall(this); + this->timer = 0; + this->actor.shape.rot = this->actor.home.rot; + this->actionFunc = EnKusa_UprootedWaitRegrow; +} + +void EnKusa_UprootedWaitRegrow(EnKusa* this, GlobalContext* globalCtx) { + this->timer++; + if (this->timer > 120) { + if (Math_StepToF(&this->actor.world.pos.y, this->actor.home.pos.y, 0.6f) && (this->timer >= 170)) { + EnKusa_SetupRegrow(this); + } + } +} + +void EnKusa_SetupRegrow(EnKusa* this) { + this->actionFunc = EnKusa_Regrow; + EnKusa_SetScaleSmall(this); + this->isCut = false; + this->actor.shape.rot = this->actor.home.rot; +} + +void EnKusa_Regrow(EnKusa* this, GlobalContext* globalCtx) { + s32 isFullyGrown = 1; + + isFullyGrown &= Math_StepToF(&this->actor.scale.y, 0.4f, 0.014f); + isFullyGrown &= Math_StepToF(&this->actor.scale.x, 0.4f, 0.011f); + this->actor.scale.z = this->actor.scale.x; + if (isFullyGrown) { + Actor_SetScale(&this->actor, 0.4f); + EnKusa_SetupInteract(this); + this->collider.base.ocFlags1 &= ~OC1_TYPE_PLAYER; + } +} + +void EnKusa_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnKusa* this = THIS; + + this->actionFunc(this, globalCtx); + + if (this->isCut) { + this->actor.shape.yOffset = -6.25f; + } else { + this->actor.shape.yOffset = 0.0f; + } + if ((kusaGameplayFrames != globalCtx->gameplayFrames) && (globalCtx->roomCtx.currRoom.unk3 == 0)) { + EnKusa_Sway(); + kusaGameplayFrames = globalCtx->gameplayFrames; + } +} + +void EnKusa_DrawBush(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnKusa* this = THIS; + + if ((this->actor.projectedPos.z <= 1200.0f) || ((this->isInWater & 1) && (this->actor.projectedPos.z < 1300.0f))) { + + if ((globalCtx->roomCtx.currRoom.unk3 == 0) && (this->actionFunc == EnKusa_WaitForInteract) && + (this->actor.projectedPos.z > -150.0f) && (this->actor.projectedPos.z < 400.0f)) { + EnKusa_ApplySway(&D_80936AD8[this->kusaMtxIdx]); + } + + Gfx_DrawDListOpa(globalCtx, gKusaBushType1); + + } else if (this->actor.projectedPos.z < 1300.0f) { + s32 alpha; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + alpha = (1300.0f - this->actor.projectedPos.z) * 2.55f; + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, alpha); + gSPDisplayList(POLY_XLU_DISP++, gKusaBushType2); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +void EnKusa_DrawGrass(Actor* thisx, GlobalContext* globalCtx) { + EnKusa* this = THIS; + + if (this->isCut) { + Gfx_DrawDListOpa(globalCtx, gKusaStump); + } else { + if ((globalCtx->roomCtx.currRoom.unk3 == 0) && (this->actionFunc == EnKusa_WaitForInteract)) { + if ((this->actor.projectedPos.z > -150.0f) && (this->actor.projectedPos.z < 400.0f)) { + EnKusa_ApplySway(&D_80936AD8[this->kusaMtxIdx]); + } + } + Gfx_DrawDListOpa(globalCtx, gKusaSprout); + } +} diff --git a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.h b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.h index 612f7b2eff..2f0d29dd97 100644 --- a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.h +++ b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.h @@ -7,12 +7,33 @@ struct EnKusa; typedef void (*EnKusaActionFunc)(struct EnKusa*, GlobalContext*); +typedef enum { + /* 0 */ ENKUSA_TYPE_BUSH, + /* 1 */ ENKUSA_TYPE_REGROWING_GRASS, + /* 2 */ ENKUSA_TYPE_GRASS, + /* 3 */ ENKUSA_TYPE_GRASS_2 +} EnKusaType; + typedef struct EnKusa { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnKusaActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x54]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnKusaActionFunc actionFunc; + /* 0x148 */ ColliderCylinder collider; + /* 0x194 */ u8 timer; + /* 0x195 */ s8 objIndex; + /* 0x196 */ s8 kusaMtxIdx; + /* 0x197 */ u8 isCut; + /* 0x198 */ u8 isInWater; } EnKusa; // size = 0x19C extern const ActorInit En_Kusa_InitVars; +#define KUSA_GET_COLLECTIBLE_ID(thisx) ((((thisx)->params >> 8) & 0x7F)) +#define KUSA_GET_RAND_COLLECTIBLE_ID(thisx) (((thisx)->params >> 8) & 0xF) +#define KUSA_SHOULD_SPAWN_BUGS(thisx) (((thisx)->params >> 0x4) & 1) +#define KUSA_GET_PARAMS_0C(thisx) (((thisx)->params >> 0xC) & 0x1) +#define KUSA_GET_PARAMS_3F(thisx) (((thisx)->params >> 0x2) & 0x3F) + + +#define GET_KUSA_TYPE(thisx)((thisx)->params & 0x3) + #endif // Z_EN_KUSA_H diff --git a/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c b/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c index 1d37f0fa95..e4e8214279 100644 --- a/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c +++ b/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c @@ -4,6 +4,7 @@ * Description: Keaton grass */ +#include "prevent_bss_reordering.h" #include "z_en_kusa2.h" #include "objects/gameplay_field_keep/gameplay_field_keep.h" #include "objects/gameplay_keep/gameplay_keep.h" @@ -1310,8 +1311,8 @@ void EnKusa2_Update(Actor* thisx, GlobalContext* globalCtx) { void func_80A5E6F0(Actor* thisx, GlobalContext* globalCtx) { static Gfx* D_80A5EB68[] = { - gameplay_keep_DL_0528B0, - gameplay_keep_DL_0527F0, + gKakeraLeafTip, + gKakeraLeafMiddle, }; EnKusa2* this = THIS; s32 i; @@ -1343,7 +1344,7 @@ void func_80A5E80C(GlobalContext* globalCtx, s32 arg1) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, arg1); - gSPDisplayList(POLY_XLU_DISP++, gameplay_field_keep_DL_007938); + gSPDisplayList(POLY_XLU_DISP++, gKusaBushType2); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -1356,7 +1357,7 @@ void EnKusa2_Draw(Actor* thisx, GlobalContext* globalCtx) { (this->actor.projectedPos.z < 400.0f)) { func_80A5B954(&D_80A60908[this->unk_1CE], 0.0015f); } - Gfx_DrawDListOpa(globalCtx, gameplay_field_keep_DL_0078A0); + Gfx_DrawDListOpa(globalCtx, gKusaBushType1); } else if (this->actor.projectedPos.z < 1300.0f) { func_80A5E80C(globalCtx, (1300.0f - this->actor.projectedPos.z) * 2.55f); } @@ -1370,14 +1371,14 @@ void func_80A5E9B4(Actor* thisx, GlobalContext* globalCtx) { sp18.z = thisx->shape.rot.z + D_80A5EAFC.z; Matrix_SetStateRotationAndTranslation(thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, &sp18); Matrix_Scale(thisx->scale.x, thisx->scale.y, thisx->scale.z, MTXMODE_APPLY); - Gfx_DrawDListOpa(globalCtx, gameplay_field_keep_DL_0078A0); + Gfx_DrawDListOpa(globalCtx, gKusaBushType1); } void func_80A5EA48(Actor* thisx, GlobalContext* globalCtx) { EnKusa2* this = THIS; if (this->unk_1CF == 0xFF) { - Gfx_DrawDListOpa(globalCtx, gameplay_field_keep_DL_0078A0); + Gfx_DrawDListOpa(globalCtx, gKusaBushType1); } else { func_80A5E80C(globalCtx, this->unk_1CF); } diff --git a/src/overlays/actors/ovl_En_Light/z_en_light.c b/src/overlays/actors/ovl_En_Light/z_en_light.c index fdb2cf1234..f815147a2a 100644 --- a/src/overlays/actors/ovl_En_Light/z_en_light.c +++ b/src/overlays/actors/ovl_En_Light/z_en_light.c @@ -5,6 +5,7 @@ */ #include "z_en_light.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS 0x00000000 @@ -15,7 +16,8 @@ void EnLight_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnLight_Update(Actor* thisx, GlobalContext* globalCtx); void EnLight_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80865F38(Actor* thisx, GlobalContext* globalCtx); + const ActorInit En_Light_InitVars = { ACTOR_EN_LIGHT, ACTORCAT_ITEMACTION, @@ -28,16 +30,173 @@ const ActorInit En_Light_InitVars = { (ActorFunc)EnLight_Draw, }; -#endif +typedef struct { + /* 0x00 */ Color_RGBA8 unk_00; + /* 0x04 */ Color_RGB8 unk_04; + /* 0x07 */ u8 unk_07; +} EnLightStruct; // size = 0x8 -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Light/EnLight_Init.s") +EnLightStruct D_808666D0[] = { + { { 255, 200, 0, 255 }, { 255, 0, 0 }, 75 }, { { 255, 235, 175, 255 }, { 255, 0, 0 }, 75 }, + { { 0, 170, 255, 255 }, { 0, 0, 255 }, 75 }, { { 170, 255, 0, 255 }, { 0, 150, 0 }, 75 }, + { { 255, 200, 0, 255 }, { 255, 0, 0 }, 40 }, { { 255, 200, 0, 255 }, { 255, 0, 0 }, 75 }, + { { 170, 255, 0, 255 }, { 0, 150, 0 }, 75 }, { { 0, 170, 255, 255 }, { 0, 0, 255 }, 75 }, + { { 255, 0, 170, 255 }, { 200, 0, 0 }, 75 }, { { 255, 255, 170, 255 }, { 255, 50, 0 }, 75 }, + { { 255, 255, 170, 255 }, { 255, 255, 0 }, 75 }, { { 255, 255, 170, 255 }, { 100, 255, 0 }, 75 }, + { { 255, 170, 255, 255 }, { 255, 0, 100 }, 75 }, { { 255, 170, 255, 255 }, { 100, 0, 255 }, 75 }, + { { 170, 255, 255, 255 }, { 0, 0, 255 }, 75 }, { { 170, 255, 255, 255 }, { 0, 150, 255 }, 75 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Light/EnLight_Destroy.s") +void EnLight_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnLight* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Light/func_80865BF8.s") + if (!ENLIGHT_GET_4000(&this->actor)) { + if ((gSaveContext.gameMode == 3) || ENLIGHT_GET_2000(&this->actor)) { + Lights_PointNoGlowSetInfo(&this->lightInfo, this->actor.world.pos.x, + ((this->actor.params < 0) ? 1 : 40) + (s32)this->actor.world.pos.y, + this->actor.world.pos.z, 255, 255, 180, -1); + } else { + Lights_PointGlowSetInfo(&this->lightInfo, this->actor.world.pos.x, + ((this->actor.params < 0) ? 1 : 40) + (s32)this->actor.world.pos.y, + this->actor.world.pos.z, 255, 255, 180, -1); + } + this->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfo); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Light/EnLight_Update.s") + Actor_SetScale(&this->actor, D_808666D0[ENLIGHT_GET_F(&this->actor)].unk_07 * 0.0001f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Light/func_80865F38.s") + this->unk_144 = (s8)(Rand_ZeroOne() * 255.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Light/EnLight_Draw.s") + if (ENLIGHT_GET_800(&this->actor)) { + this->actor.update = func_80865F38; + if (ENLIGHT_GET_1000(&this->actor) && Flags_GetSwitch(globalCtx, ENLIGHT_SWITCHFLAG(&this->actor))) { + Actor_SetScale(&this->actor, 0.0f); + } + } else if (ENLIGHT_GET_2000(&this->actor)) { + this->actor.draw = NULL; + } +} + +void EnLight_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnLight* this = THIS; + + if (!ENLIGHT_GET_4000(&this->actor)) { + LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lightNode); + } +} + +void func_80865BF8(EnLight* this, GlobalContext* globalCtx) { + this->actor.shape.rot.y = BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))); + + if (this->actor.parent != NULL) { + Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.parent->world.pos); + this->actor.world.pos.y += 17.0f; + } + + this->unk_144++; +} + +void EnLight_Update(Actor* thisx, GlobalContext* globalCtx) { + EnLight* this = THIS; + + if (!ENLIGHT_GET_4000(&this->actor)) { + EnLightStruct* sp28 = &D_808666D0[ENLIGHT_GET_F(&this->actor)]; + f32 temp_f2 = (Rand_ZeroOne() * 0.5f) + 0.5f; + s32 radius = (this->actor.params < 0) ? 100 : ENLIGHT_GET_2000(&this->actor) ? 730 : 300; + + Lights_PointSetColorAndRadius(&this->lightInfo, (u8)(sp28->unk_00.r * temp_f2), (u8)(sp28->unk_00.g * temp_f2), + (u8)(sp28->unk_00.b * temp_f2), radius); + } + + func_80865BF8(this, globalCtx); + + if ((this->actor.params >= 0) && !ENLIGHT_GET_4000(&this->actor)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_TORCH - SFX_FLAG); + } +} + +void func_80865F38(Actor* thisx, GlobalContext* globalCtx) { + EnLight* this = THIS; + EnLightStruct* sp38 = &D_808666D0[ENLIGHT_GET_F(&this->actor)]; + f32 temp_f2; + f32 sp30 = this->actor.scale.x / (sp38->unk_07 * 0.0001f); + s32 sp2C = false; + + if (ENLIGHT_GET_1000(&this->actor)) { + if (Flags_GetSwitch(globalCtx, ENLIGHT_SWITCHFLAG(&this->actor))) { + Math_StepToF(&sp30, 1.0f, 0.05f); + sp2C = true; + } else { + if (sp30 < 0.1f) { + Actor_SetScale(&this->actor, 0.0f); + sp30 = 0.0f; + } + Math_StepToF(&sp30, 0.0f, 0.05f); + } + } else if (Flags_GetSwitch(globalCtx, ENLIGHT_SWITCHFLAG(&this->actor))) { + if (sp30 < 0.1f) { + Actor_SetScale(&this->actor, 0.0f); + sp30 = 0.0f; + } + Math_StepToF(&sp30, 0.0f, 0.05f); + } else { + Math_StepToF(&sp30, 1.0f, 0.05f); + sp2C = true; + } + + Actor_SetScale(&this->actor, sp38->unk_07 * 0.0001f * sp30); + + if (!ENLIGHT_GET_4000(&this->actor)) { + temp_f2 = (Rand_ZeroOne() * 0.5f) + 0.5f; + Lights_PointSetColorAndRadius(&this->lightInfo, (u8)(sp38->unk_00.r * temp_f2), (u8)(sp38->unk_00.g * temp_f2), + (u8)(sp38->unk_00.b * temp_f2), 300.0f * sp30); + } + + func_80865BF8(this, globalCtx); + + if ((this->actor.params >= 0) && (sp2C == true)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_TORCH - SFX_FLAG); + } +} + +void EnLight_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnLight* this = THIS; + EnLightStruct* sp6C = &D_808666D0[ENLIGHT_GET_F(&this->actor)]; + Gfx* sp68; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + if (this->actor.params >= 0) { + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, (this->unk_144 * -20) & 0x1FF, + 0x20, 0x80)); + sp68 = gGameplayKeepDrawFlameDL; + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, sp6C->unk_00.r, sp6C->unk_00.g, sp6C->unk_00.b, sp6C->unk_00.a); + gDPSetEnvColor(POLY_XLU_DISP++, sp6C->unk_04.r, sp6C->unk_04.g, sp6C->unk_04.b, 0); + } else { + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x10, 0x20, 1, (this->unk_144 * 2) & 0x3F, + (this->unk_144 * -6) & 0x7F, 0x10, 0x20)); + sp68 = gameplay_keep_DL_01ACF0; + gDPSetPrimColor(POLY_XLU_DISP++, 0xC0, 0xC0, 255, 200, 0, 0); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); + } + + Matrix_RotateY(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - this->actor.shape.rot.y), + MTXMODE_APPLY); + + if (ENLIGHT_GET_1(&this->actor)) { + Matrix_InsertYRotation_f(M_PI, MTXMODE_APPLY); + } + + Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, sp68); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Light/z_en_light.h b/src/overlays/actors/ovl_En_Light/z_en_light.h index f1aff8de96..b17f55fd72 100644 --- a/src/overlays/actors/ovl_En_Light/z_en_light.h +++ b/src/overlays/actors/ovl_En_Light/z_en_light.h @@ -5,9 +5,19 @@ struct EnLight; +#define ENLIGHT_GET_1(thisx) ((thisx)->params & 1) +#define ENLIGHT_GET_F(thisx) ((thisx)->params & 0xF) +#define ENLIGHT_GET_800(thisx) ((thisx)->params & 0x800) +#define ENLIGHT_SWITCHFLAG(thisx) (((thisx)->params & 0x7F0) >> 4) +#define ENLIGHT_GET_1000(thisx) ((thisx)->params & 0x1000) +#define ENLIGHT_GET_2000(thisx) ((thisx)->params & 0x2000) +#define ENLIGHT_GET_4000(thisx) ((thisx)->params & 0x4000) + typedef struct EnLight { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x18]; + /* 0x144 */ u8 unk_144; + /* 0x148 */ LightNode* lightNode; + /* 0x14C */ LightInfo lightInfo; } EnLight; // size = 0x15C extern const ActorInit En_Light_InitVars; diff --git a/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c b/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c index c38faff3e3..73a559a70c 100644 --- a/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c +++ b/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c @@ -15,7 +15,14 @@ void EnLookNuts_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnLookNuts_Update(Actor* thisx, GlobalContext* globalCtx); void EnLookNuts_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void EnLookNuts_SetupPatrol(EnLookNuts* this); +void EnLookNuts_Patrol(EnLookNuts* this, GlobalContext* globalCtx); +void EnLookNuts_SetupStandAndWait(EnLookNuts* this); +void EnLookNuts_StandAndWait(EnLookNuts* this, GlobalContext* globalCtx); +void EnLookNuts_RunToPlayer(EnLookNuts* this, GlobalContext* globalCtx); +void EnLookNuts_SetupSendPlayerToSpawn(EnLookNuts* this); +void EnLookNuts_SendPlayerToSpawn(EnLookNuts* this, GlobalContext* globalCtx); + const ActorInit En_Look_Nuts_InitVars = { ACTOR_EN_LOOK_NUTS, ACTORCAT_NPC, @@ -28,15 +35,29 @@ const ActorInit En_Look_Nuts_InitVars = { (ActorFunc)EnLookNuts_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A68600 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 20, 50, 0, { 0, 0, 0 } }, }; -// static DamageTable sDamageTable = { -static DamageTable D_80A68630 = { +s32 D_80A6862C = 0; + +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(1, 0xF), /* Deku Stick */ DMG_ENTRY(1, 0xF), /* Horse trample */ DMG_ENTRY(1, 0xF), @@ -71,34 +92,304 @@ static DamageTable D_80A68630 = { /* Powder Keg */ DMG_ENTRY(1, 0xF), }; -#endif +typedef enum { + /* 0x01 */ PALACE_GUARD_PATROLLING, + /* 0x01 */ PALACE_GUARD_WAITING, + /* 0x02 */ PALACE_GUARD_RUNNING_TO_PLAYER, + /* 0x03 */ PALACE_GUARD_CAUGHT_PLAYER +} PalaceGuardState; -extern ColliderCylinderInit D_80A68600; -extern DamageTable D_80A68630; +void EnLookNuts_Init(Actor* thisx, GlobalContext* globalCtx) { + EnLookNuts* this = THIS; -extern UNK_TYPE D_06000430; -extern UNK_TYPE D_06002B6C; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); + SkelAnime_Init(globalCtx, &this->skelAnime, &gDekuPalaceGuardSkel, &gDekuPalaceGuardDigAnim, this->jointTable, + this->morphTable, DEKU_PALACE_GUARD_LIMB_MAX); + Actor_SetScale(&this->actor, 0.01f); + this->actor.colChkInfo.damageTable = &sDamageTable; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->actor.targetMode = 1; + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + this->actor.flags |= ACTOR_FLAG_8000000; + this->pathLocation = LOOKNUTS_GET_PATROL_LOCATION(&this->actor); + this->switchFlag = LOOKNUTS_GET_SCENE_FLAG(&this->actor); + this->spawnIndex = LOOKNUTS_GET_SPAWN_INDEX(&this->actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Look_Nuts/EnLookNuts_Init.s") + if (this->switchFlag == 0x7F) { + this->switchFlag = -1; + } + if ((this->switchFlag >= 0) && (Flags_GetSwitch(globalCtx, this->switchFlag))) { + Actor_MarkForDeath(&this->actor); + return; + } + if (this->pathLocation == 0x1F) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Look_Nuts/EnLookNuts_Destroy.s") + this->state = PALACE_GUARD_PATROLLING; + EnLookNuts_SetupPatrol(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Look_Nuts/func_80A67A34.s") +void EnLookNuts_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnLookNuts* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Look_Nuts/func_80A67AA8.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Look_Nuts/func_80A67C48.s") +void EnLookNuts_SetupPatrol(EnLookNuts* this) { + Animation_Change(&this->skelAnime, &gDekuPalaceGuardWalkAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gDekuPalaceGuardWalkAnim), 0, -10.0f); + this->state = PALACE_GUARD_PATROLLING; + this->actionFunc = EnLookNuts_Patrol; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Look_Nuts/func_80A67D0C.s") +void EnLookNuts_Patrol(EnLookNuts* this, GlobalContext* globalCtx) { + f32 sp34 = 0.0f; + f32 sp30; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Look_Nuts/func_80A67F30.s") + SkelAnime_Update(&this->skelAnime); + if (Play_InCsMode(globalCtx)) { + this->actor.speedXZ = 0.0f; + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Look_Nuts/func_80A67FC4.s") + this->actor.speedXZ = 2.0f; + if (Animation_OnFrame(&this->skelAnime, 1.0f) || Animation_OnFrame(&this->skelAnime, 5.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_WALK); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Look_Nuts/func_80A68080.s") + if (D_80A6862C != 0) { + Math_ApproachZeroF(&this->actor.speedXZ, 0.3f, 1.0f); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Look_Nuts/func_80A680FC.s") + this->path = SubS_GetPathByIndex(globalCtx, this->pathLocation, 0x1F); + if (this->path != NULL) { + sp34 = SubS_GetDistSqAndOrientPath(this->path, this->currentPathIndex, &this->actor.world.pos, &sp30); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Look_Nuts/EnLookNuts_Update.s") + //! @bug sp30 is uninitialised if path == NULL. Fix by enclosing everything in the path NULL check. + if (sp30 < 10.0f) { + if (this->path != NULL) { + this->currentPathIndex++; + if (this->currentPathIndex >= this->path->count) { + this->currentPathIndex = 0; + } + if (Rand_ZeroOne() < 0.6f) { + EnLookNuts_SetupStandAndWait(this); + return; + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Look_Nuts/EnLookNuts_Draw.s") + Math_SmoothStepToS(&this->actor.shape.rot.y, sp34, 1, 0x1388, 0); + this->actor.world.rot.y = this->actor.shape.rot.y; +} + +void EnLookNuts_SetupStandAndWait(EnLookNuts* this) { + Animation_Change(&this->skelAnime, &gDekuPalaceGuardWalkAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gDekuPalaceGuardWalkAnim), 2, -10.0f); + this->waitTimer = Rand_S16Offset(1, 3); + this->headRotTarget.y = 10000.0f; + + if (Rand_ZeroOne() < 0.5f) { + this->headRotTarget.y = -10000.0f; + } + this->eventTimer = 10; + this->state = PALACE_GUARD_WAITING; + this->actionFunc = EnLookNuts_StandAndWait; +} + +// Patrol Guards will stand in place and wait for a maximum of ~12 frames. +void EnLookNuts_StandAndWait(EnLookNuts* this, GlobalContext* globalCtx) { + s16 randOffset; + + SkelAnime_Update(&this->skelAnime); + Math_ApproachZeroF(&this->actor.speedXZ, 0.3f, 1.0f); + if (!Play_InCsMode(globalCtx) && (D_80A6862C == 0) && (this->eventTimer == 0)) { + this->eventTimer = 10; + switch (this->waitTimer) { + case 0: + case 1: + case 2: + case 3: + case 4: + this->waitTimer++; + this->headRotTarget.y *= -1.0f; + break; + case 5: + this->headRotTarget.y = 0.0f; + randOffset = Rand_S16Offset(1, 2); + this->eventTimer = 0; + this->waitTimer += randOffset; + break; + case 6: + if (fabsf(this->headRotTarget.y - this->headRotation.y) < 10.0f) { + this->waitTimer = 10; + this->headRotTarget.x = 4000.0f; + this->eventTimer = 5; + } + break; + case 7: + if (fabsf(this->headRotTarget.y - this->headRotation.y) < 10.0f) { + this->headRotTarget.z = 4000.0f; + this->waitTimer++; + } + break; + case 8: + this->waitTimer = 10; + this->eventTimer = 20; + this->headRotTarget.z = -8000.0f; + break; + case 10: + Math_Vec3f_Copy(&this->headRotTarget, &gZeroVec3f); + this->waitTimer = 11; + break; + case 11: + if ((fabsf(this->headRotation.x) < 30.0f) && (fabsf(this->headRotation.y) < 30.0f) && + (fabsf(this->headRotation.z) < 30.0f)) { + this->waitTimer = 12; + } + break; + } + if (this->waitTimer == 12) { + this->waitTimer = 0; + EnLookNuts_SetupPatrol(this); + } + } +} + +void EnLookNuts_DetectedPlayer(EnLookNuts* this, GlobalContext* globalCtx) { + Animation_Change(&this->skelAnime, &gDekuPalaceGuardWalkAnim, 2.0f, 0.0f, + Animation_GetLastFrame(&gDekuPalaceGuardWalkAnim), 0, -10.0f); + this->state = PALACE_GUARD_RUNNING_TO_PLAYER; + this->eventTimer = 300; + Message_StartTextbox(globalCtx, 0x833, &this->actor); + this->actionFunc = EnLookNuts_RunToPlayer; +} + +void EnLookNuts_RunToPlayer(EnLookNuts* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + if (Animation_OnFrame(&this->skelAnime, 1.0f) || Animation_OnFrame(&this->skelAnime, 5.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_WALK); + } + + this->actor.speedXZ = 4.0f; + Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1, 0xBB8, 0); + if ((this->actor.xzDistToPlayer < 70.0f) || (this->eventTimer == 0)) { + this->actor.speedXZ = 0.0f; + EnLookNuts_SetupSendPlayerToSpawn(this); + } +} + +void EnLookNuts_SetupSendPlayerToSpawn(EnLookNuts* this) { + Animation_Change(&this->skelAnime, &gDekuPalaceGuardWalkAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gDekuPalaceGuardWalkAnim), 2, -10.0f); + this->state = PALACE_GUARD_CAUGHT_PLAYER; + this->actionFunc = EnLookNuts_SendPlayerToSpawn; +} + +void EnLookNuts_SendPlayerToSpawn(EnLookNuts* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1, 0xBB8, 0); + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + func_801477B4(globalCtx); + globalCtx->nextEntranceIndex = Entrance_CreateIndexFromSpawn(this->spawnIndex); + gSaveContext.nextCutsceneIndex = 0; + Scene_SetExitFade(globalCtx); + globalCtx->sceneLoadFlag = 0x14; + gSaveContext.save.weekEventReg[17] |= 4; + } +} + +static Vec3f effectVecInitialize = { 0.0f, 0.0f, 0.0f }; + +void EnLookNuts_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnLookNuts* this = THIS; + Vec3f effectVelOffset; + Vec3f effectPos; + Vec3f effectVel; + + if (this->blinkTimer == 0) { + this->eyeState++; + if (this->eyeState >= 3) { + this->eyeState = 0; + this->blinkTimer = (s16)Rand_ZeroFloat(60.0f) + 20; + } + } + this->actionFunc(this, globalCtx); + if (this->blinkTimer != 0) { + this->blinkTimer--; + } + if (this->eventTimer != 0) { + this->eventTimer--; + } + Actor_MoveWithGravity(&this->actor); + if (D_80A6862C == 0) { + if ((this->state < 2) && (this->actor.xzDistToPlayer < 320.0f) && (this->actor.playerHeightRel < 80.0f)) { + effectVelOffset = effectVecInitialize; + Math_Vec3f_Copy(&effectPos, &this->actor.world.pos); + effectPos.x += Math_SinS((this->actor.world.rot.y + (s16)this->headRotation.y)) * 10.0f; + effectPos.y += 30.0f; + effectPos.z += Math_CosS((this->actor.world.rot.y + (s16)this->headRotation.y)) * 10.0f; + Matrix_StatePush(); + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); + effectVelOffset.z = 20.0f; + Matrix_MultiplyVector3fByState(&effectVelOffset, &effectVel); + Matrix_StatePop(); + if (!this->isPlayerDetected) { + s16 drawFlag = 1; + if (gSaveContext.save.isNight) { + drawFlag = 0; + } + if (Player_GetMask(globalCtx) != PLAYER_MASK_STONE) { + EffectSsSolderSrchBall_Spawn(globalCtx, &effectPos, &effectVel, &gZeroVec3f, 50, + &this->isPlayerDetected, drawFlag); + } + } + + if ((this->isPlayerDetected == true) || (this->actor.xzDistToPlayer < 20.0f)) { + Player* player = GET_PLAYER(globalCtx); + + if (!(player->stateFlags3 & 0x100) && !Play_InCsMode(globalCtx)) { + Math_Vec3f_Copy(&this->headRotTarget, &gZeroVec3f); + this->state = PALACE_GUARD_RUNNING_TO_PLAYER; + play_sound(NA_SE_SY_FOUND); + func_800B7298(globalCtx, &this->actor, 0x1A); + D_80A6862C = 1; + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_10); + this->actor.gravity = 0.0f; + EnLookNuts_DetectedPlayer(this, globalCtx); + } else { + this->isPlayerDetected = false; + } + } + } + Math_ApproachF(&this->headRotation.x, this->headRotTarget.x, 1.0f, 3000.0f); + Math_ApproachF(&this->headRotation.y, this->headRotTarget.y, 1.0f, 6000.0f); + Math_ApproachF(&this->headRotation.z, this->headRotTarget.z, 1.0f, 2000.0f); + this->actor.shape.rot.y = this->actor.world.rot.y; + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +static TexturePtr sEyeTextures[] = { + gDekuPalaceGuardEyeOpenTex, + gDekuPalaceGuardEyeHalfTex, + gDekuPalaceGuardEyeClosedTex, +}; + +void EnLookNuts_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnLookNuts* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeState])); + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.h b/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.h index cb011be7ae..e6eb6597ae 100644 --- a/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.h +++ b/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.h @@ -2,16 +2,37 @@ #define Z_EN_LOOK_NUTS_H #include "global.h" +#include "objects/object_dnk/object_dnk.h" struct EnLookNuts; typedef void (*EnLookNutsActionFunc)(struct EnLookNuts*, GlobalContext*); +#define LOOKNUTS_GET_SPAWN_INDEX(thisx) (((thisx)->params >> 0xC) & 0xF) +#define LOOKNUTS_GET_SCENE_FLAG(thisx) ((thisx)->params & 0x7F) +#define LOOKNUTS_GET_PATROL_LOCATION(thisx) (((thisx)->params >> 0x7) & 0x1F) + typedef struct EnLookNuts { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xC8]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[DEKU_PALACE_GUARD_LIMB_MAX]; + /* 0x01CA */ Vec3s morphTable[DEKU_PALACE_GUARD_LIMB_MAX]; /* 0x020C */ EnLookNutsActionFunc actionFunc; - /* 0x0210 */ char unk_210[0x80]; + /* 0x0210 */ Path *path; + /* 0x0214 */ s16 currentPathIndex; // Index for the point where the deku guard is in its path + /* 0x0216 */ s16 eyeState; + /* 0x0218 */ s16 blinkTimer; + /* 0x021A */ s16 eventTimer; // Timer to trigger when another event within the actor will happen + /* 0x021C */ s16 state; + /* 0x021E */ s16 switchFlag; + /* 0x0220 */ s16 pathLocation; // Determines path that a guard will patrol + /* 0x0222 */ s16 isPlayerDetected; + /* 0x0224 */ s16 waitTimer; // Timer for how long the deku guard will take a break for + /* 0x0226 */ s16 spawnIndex; + /* 0x0228 */ UNK_TYPE4 pad228; // Unused necessary padding + /* 0x022C */ Vec3f headRotation; + /* 0x0238 */ Vec3f headRotTarget; // Target value for head rotation + /* 0x0244 */ ColliderCylinder collider; } EnLookNuts; // size = 0x290 extern const ActorInit En_Look_Nuts_InitVars; diff --git a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c index b5080ec794..031f2113f2 100644 --- a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c +++ b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c @@ -202,7 +202,7 @@ void EnMa4_Init(Actor* thisx, GlobalContext* globalCtx) { if (CURRENT_DAY == 1) { this->type = MA4_TYPE_DAY1; - } else if (gSaveContext.weekEventReg[22] & 1) { // Aliens defeated + } else if (gSaveContext.save.weekEventReg[22] & 1) { // Aliens defeated this->type = MA4_TYPE_ALIENS_DEFEATED; } else { this->type = MA4_TYPE_ALIENS_WON; @@ -216,10 +216,10 @@ void EnMa4_Init(Actor* thisx, GlobalContext* globalCtx) { } else { EnMa4_InitPath(this, globalCtx); - if (gSaveContext.entranceIndex == 0x6410) { + if (gSaveContext.save.entranceIndex == 0x6410) { EnMa4_ChangeAnim(this, 0); this->state = MA4_STATE_AFTERHORSEBACKGAME; - } else if (gSaveContext.entranceIndex == 0x64A0) { + } else if (gSaveContext.save.entranceIndex == 0x64A0) { EnMa4_ChangeAnim(this, 0); this->state = MA4_STATE_AFTERDESCRIBETHEMCS; } else { @@ -240,7 +240,7 @@ void EnMa4_Destroy(Actor* thisx, GlobalContext* globalCtx) { EnMa4* this = THIS; Collider_DestroyCylinder(globalCtx, &this->collider); - gSaveContext.weekEventReg[8] &= (u8)~1; + gSaveContext.save.weekEventReg[8] &= (u8)~1; } // Running in circles in the ranch @@ -357,7 +357,7 @@ void EnMa4_Wait(EnMa4* this, GlobalContext* globalCtx) { // Chooses the next dialogue based on player's selection void EnMa4_HandlePlayerChoice(EnMa4* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx) != 0) { switch (this->textId) { case 0x3339: if (globalCtx->msgCtx.choiceIndex == 0) { @@ -374,7 +374,7 @@ void EnMa4_HandlePlayerChoice(EnMa4* this, GlobalContext* globalCtx) { case 0x3341: if (globalCtx->msgCtx.choiceIndex == 0) { func_8019F208(); - gSaveContext.weekEventReg[21] |= 0x20; + gSaveContext.save.weekEventReg[21] |= 0x20; Message_StartTextbox(globalCtx, 0x3343, &this->actor); this->textId = 0x3343; } else { @@ -390,7 +390,7 @@ void EnMa4_HandlePlayerChoice(EnMa4* this, GlobalContext* globalCtx) { case 0x3346: if (globalCtx->msgCtx.choiceIndex == 0) { func_8019F208(); - gSaveContext.weekEventReg[21] |= 0x20; + gSaveContext.save.weekEventReg[21] |= 0x20; Message_StartTextbox(globalCtx, 0x3343, &this->actor); this->textId = 0x3343; } else { @@ -491,7 +491,7 @@ void EnMa4_ChooseNextDialogue(EnMa4* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 aux; - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx) != 0) { switch (this->textId) { case 0x2390: func_801477B4(globalCtx); @@ -605,7 +605,7 @@ void EnMa4_ChooseNextDialogue(EnMa4* this, GlobalContext* globalCtx) { break; case 0x3358: - if ((gSaveContext.playerForm != PLAYER_FORM_HUMAN) || !(CHECK_QUEST_ITEM(QUEST_SONG_EPONA))) { + if ((gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) || !(CHECK_QUEST_ITEM(QUEST_SONG_EPONA))) { Message_StartTextbox(globalCtx, 0x335C, &this->actor); this->textId = 0x335C; func_80151BB4(globalCtx, 5); @@ -643,7 +643,7 @@ void EnMa4_DialogueHandler(EnMa4* this, GlobalContext* globalCtx) { break; case 6: // End conversation - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx) != 0) { if ((globalCtx->msgCtx.unk120B1 == 0) || !CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { EnMa4_SetupWait(this); } @@ -694,7 +694,7 @@ void EnMa4_InitHorsebackGame(EnMa4* this, GlobalContext* globalCtx) { globalCtx->interfaceCtx.unk_280 = 1; func_8010E9F0(4, 0); - gSaveContext.weekEventReg[8] |= 1; + gSaveContext.save.weekEventReg[8] |= 1; func_80112AFC(globalCtx); player->stateFlags1 |= 0x20; this->actionFunc = EnMa4_SetupHorsebackGameWait; @@ -730,7 +730,7 @@ void EnMa4_HorsebackGameWait(EnMa4* this, GlobalContext* globalCtx) { } void EnMa4_SetupHorsebackGameEnd(EnMa4* this, GlobalContext* globalCtx) { - gSaveContext.weekEventReg[8] &= (u8)~1; + gSaveContext.save.weekEventReg[8] &= (u8)~1; this->actionFunc = EnMa4_HorsebackGameEnd; Audio_QueueSeqCmd(NA_BGM_STOP); Audio_QueueSeqCmd(NA_BGM_HORSE_GOAL | 0x8000); @@ -876,8 +876,8 @@ void EnMa4_StartDialogue(EnMa4* this, GlobalContext* globalCtx) { switch (this->type) { case MA4_TYPE_DAY1: - if (gSaveContext.playerForm != PLAYER_FORM_HUMAN) { - if ((gSaveContext.weekEventReg[21] & 0x80)) { + if (gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) { + if ((gSaveContext.save.weekEventReg[21] & 0x80)) { EnMa4_SetFaceExpression(this, 3, 3); Message_StartTextbox(globalCtx, 0x3337, &this->actor); this->textId = 0x3337; @@ -885,11 +885,11 @@ void EnMa4_StartDialogue(EnMa4* this, GlobalContext* globalCtx) { } else { Message_StartTextbox(globalCtx, 0x3335, &this->actor); this->textId = 0x3335; - gSaveContext.weekEventReg[21] |= 0x80; + gSaveContext.save.weekEventReg[21] |= 0x80; } } else if (this->state == MA4_STATE_DEFAULT) { - if ((gSaveContext.weekEventReg[21] & 0x40)) { - if (!(gSaveContext.weekEventReg[21] & 0x20)) { + if ((gSaveContext.save.weekEventReg[21] & 0x40)) { + if (!(gSaveContext.save.weekEventReg[21] & 0x20)) { Message_StartTextbox(globalCtx, 0x3346, &this->actor); this->textId = 0x3346; } else { @@ -899,7 +899,7 @@ void EnMa4_StartDialogue(EnMa4* this, GlobalContext* globalCtx) { } else { Message_StartTextbox(globalCtx, 0x3338, &this->actor); this->textId = 0x3338; - gSaveContext.weekEventReg[21] |= 0x40; + gSaveContext.save.weekEventReg[21] |= 0x40; } } else if (this->state == MA4_STATE_AFTERHORSEBACKGAME) { if (gSaveContext.unk_3DE0[4] >= 2 * 60 * 100) { @@ -909,9 +909,9 @@ void EnMa4_StartDialogue(EnMa4* this, GlobalContext* globalCtx) { this->textId = 0x336D; } else { time = gSaveContext.unk_3DE0[4]; - if ((s32)time < (s32)gSaveContext.horseBackBalloonHighScore) { + if ((s32)time < (s32)gSaveContext.save.horseBackBalloonHighScore) { // [Score] New record! - gSaveContext.horseBackBalloonHighScore = time; + gSaveContext.save.horseBackBalloonHighScore = time; EnMa4_SetFaceExpression(this, 0, 3); Message_StartTextbox(globalCtx, 0x3350, &this->actor); this->textId = 0x3350; @@ -932,8 +932,8 @@ void EnMa4_StartDialogue(EnMa4* this, GlobalContext* globalCtx) { break; case MA4_TYPE_ALIENS_DEFEATED: - if (gSaveContext.playerForm != PLAYER_FORM_HUMAN) { - if ((gSaveContext.weekEventReg[21] & 0x80)) { + if (gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) { + if ((gSaveContext.save.weekEventReg[21] & 0x80)) { EnMa4_SetFaceExpression(this, 3, 3); Message_StartTextbox(globalCtx, 0x3337, &this->actor); this->textId = 0x3337; @@ -941,7 +941,7 @@ void EnMa4_StartDialogue(EnMa4* this, GlobalContext* globalCtx) { } else { Message_StartTextbox(globalCtx, 0x3335, &this->actor); this->textId = 0x3335; - gSaveContext.weekEventReg[21] |= 0x80; + gSaveContext.save.weekEventReg[21] |= 0x80; } } else if (this->state == MA4_STATE_DEFAULT) { Message_StartTextbox(globalCtx, 0x3354, &this->actor); @@ -953,8 +953,8 @@ void EnMa4_StartDialogue(EnMa4* this, GlobalContext* globalCtx) { this->textId = 0x3356; } else { time = gSaveContext.unk_3DE0[4]; - if ((s32)time < (s32)gSaveContext.horseBackBalloonHighScore) { - gSaveContext.horseBackBalloonHighScore = time; + if ((s32)time < (s32)gSaveContext.save.horseBackBalloonHighScore) { + gSaveContext.save.horseBackBalloonHighScore = time; EnMa4_SetFaceExpression(this, 0, 3); Message_StartTextbox(globalCtx, 0x3350, &this->actor); this->textId = 0x3350; @@ -980,9 +980,9 @@ void EnMa4_StartDialogue(EnMa4* this, GlobalContext* globalCtx) { this->textId = 0x3356; } else { time = gSaveContext.unk_3DE0[4]; - if ((s32)time < (s32)gSaveContext.horseBackBalloonHighScore) { + if ((s32)time < (s32)gSaveContext.save.horseBackBalloonHighScore) { // New record - gSaveContext.horseBackBalloonHighScore = time; + gSaveContext.save.horseBackBalloonHighScore = time; Message_StartTextbox(globalCtx, 0x335D, &this->actor); this->textId = 0x335D; } else { diff --git a/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c b/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c index 9294a6a71b..5847aa8977 100644 --- a/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c +++ b/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c @@ -22,7 +22,6 @@ void EnMaYto_ChooseAction(EnMaYto* this, GlobalContext* globalCtx); s32 EnMaYto_TryFindRomani(EnMaYto* this, GlobalContext* globalCtx); void EnMaYto_SetupKeepLookingForRomani(EnMaYto* this); void EnMaYto_KeepLookingForRomani(EnMaYto* this, GlobalContext* globalCtx); - void EnMaYto_SetupDefaultWait(EnMaYto* this); void EnMaYto_DefaultWait(EnMaYto* this, GlobalContext* globalCtx); void EnMaYto_SetupDefaultDialogueHandler(EnMaYto* this); @@ -44,7 +43,6 @@ void EnMaYto_SetupAfterMilkRunInit(EnMaYto* this); void EnMaYto_AfterMilkRunInit(EnMaYto* this, GlobalContext* globalCtx); void EnMaYto_SetupAfterMilkRunDialogueHandler(EnMaYto* this); void EnMaYto_AfterMilkRunDialogueHandler(EnMaYto* this, GlobalContext* globalCtx); - void EnMaYto_AfterMilkRunChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx); void EnMaYto_SetupPostMilkRunGiveReward(EnMaYto* this); void EnMaYto_PostMilkRunGiveReward(EnMaYto* this, GlobalContext* globalCtx); @@ -53,7 +51,6 @@ void EnMaYto_PostMilkRunExplainReward(EnMaYto* this, GlobalContext* globalCtx); void EnMaYto_SetupBeginWarmFuzzyFeelingCs(EnMaYto* this); void EnMaYto_BeginWarmFuzzyFeelingCs(EnMaYto* this, GlobalContext* globalCtx); void EnMaYto_SetupWarmFuzzyFeelingCs(EnMaYto* this); - void EnMaYto_WarmFuzzyFeelingCs(EnMaYto* this, GlobalContext* globalCtx); void EnMaYto_SetupPostMilkRunWaitDialogueEnd(EnMaYto* this); void EnMaYto_PostMilkRunWaitDialogueEnd(EnMaYto* this, GlobalContext* globalCtx); @@ -68,9 +65,8 @@ void func_80B90E50(EnMaYto* this, s16); void EnMaYto_SetRomaniFaceExpression(EnMaYto* this, s16 overrideEyeTexIndex, s16 mouthTexIndex); void EnMaYto_SetFaceExpression(EnMaYto* this, s16 overrideEyeTexIndex, s16 mouthIndex); void EnMaYto_InitFaceExpression(EnMaYto* this); -s32 EnMaYto_HasSpokeToPlayerToday(); - -s32 EnMaYto_HasSpokeToPlayer(void); +s32 EnMaYto_HasSpokenToPlayerToday(void); +s32 EnMaYto_HasSpokenToPlayer(void); void EnMaYto_SetTalkedFlag(void); const ActorInit En_Ma_Yto_InitVars = { @@ -146,7 +142,7 @@ void EnMaYto_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk320 = 0; this->eyeTexIndex = 0; - if (CURRENT_DAY == 1 || (gSaveContext.weekEventReg[22] & 1)) { + if (CURRENT_DAY == 1 || (gSaveContext.save.weekEventReg[22] & 1)) { EnMaYto_SetFaceExpression(this, 0, 1); } else { EnMaYto_SetFaceExpression(this, 5, 2); @@ -180,34 +176,34 @@ void EnMaYto_Init(Actor* thisx, GlobalContext* globalCtx) { s32 EnMaYto_CheckValidSpawn(EnMaYto* this, GlobalContext* globalCtx) { switch (this->type) { case MA_YTO_TYPE_DEFAULT: - if (CURRENT_DAY == 3 && !(gSaveContext.weekEventReg[22] & 1)) { + if (CURRENT_DAY == 3 && !(gSaveContext.save.weekEventReg[22] & 1)) { return false; } break; case MA_YTO_TYPE_DINNER: - if (CURRENT_DAY != 1 && (gSaveContext.weekEventReg[22] & 1)) { + if (CURRENT_DAY != 1 && (gSaveContext.save.weekEventReg[22] & 1)) { return false; } break; case MA_YTO_TYPE_BARN: - if (gSaveContext.weekEventReg[22] & 1) { + if (gSaveContext.save.weekEventReg[22] & 1) { if (((this->actor.params & 0x0F00) >> 8) != 0) { return false; } } else if (((this->actor.params & 0x0F00) >> 8) == 0) { return false; } - if (gSaveContext.time >= CLOCK_TIME(20, 0) && CURRENT_DAY == 3) { + if (gSaveContext.save.time >= CLOCK_TIME(20, 0) && CURRENT_DAY == 3) { return false; } break; case MA_YTO_TYPE_AFTERMILKRUN: - // if (!(ProtectedCremia) && !(gSaveContext.weekEventReg[52] & 2)) || (PlayedMilkMinigame)) - if ((!(gSaveContext.weekEventReg[52] & 1) && !(gSaveContext.weekEventReg[52] & 2)) || - (gSaveContext.weekEventReg[14] & 1)) { + // if (!(ProtectedCremia) && !(gSaveContext.save.weekEventReg[52] & 2)) || (PlayedMilkMinigame)) + if ((!(gSaveContext.save.weekEventReg[52] & 1) && !(gSaveContext.save.weekEventReg[52] & 2)) || + (gSaveContext.save.weekEventReg[14] & 1)) { return false; } break; @@ -235,7 +231,7 @@ void EnMaYto_InitAnimation(EnMaYto* this, GlobalContext* globalCtx) { case MA_YTO_TYPE_BARN: // if (AliensDefeated) - if (gSaveContext.weekEventReg[22] & 1) { + if (gSaveContext.save.weekEventReg[22] & 1) { EnMaYto_ChangeAnim(this, 12); } else { EnMaYto_ChangeAnim(this, 8); @@ -273,7 +269,7 @@ void EnMaYto_ChooseAction(EnMaYto* this, GlobalContext* globalCtx) { case MA_YTO_TYPE_AFTERMILKRUN: this->unk310 = 0; - if (INV_CONTENT(ITEM_MASK_ROMANI) == ITEM_MASK_ROMANI && (gSaveContext.weekEventReg[52] & 1) && + if (INV_CONTENT(ITEM_MASK_ROMANI) == ITEM_MASK_ROMANI && (gSaveContext.save.weekEventReg[52] & 1) && (Rand_Next() & 0x80)) { EnMaYto_SetupBeginWarmFuzzyFeelingCs(this); } else { @@ -328,7 +324,7 @@ s32 EnMaYto_TryFindRomani(EnMaYto* this, GlobalContext* globalCtx) { return 0; case MA_YTO_TYPE_DINNER: - if (!(gSaveContext.weekEventReg[22] & 1) && CURRENT_DAY == 2) { + if (!(gSaveContext.save.weekEventReg[22] & 1) && CURRENT_DAY == 2) { return 0; } if (EnMaYto_SearchRomani(this, globalCtx)) { @@ -338,7 +334,7 @@ s32 EnMaYto_TryFindRomani(EnMaYto* this, GlobalContext* globalCtx) { case MA_YTO_TYPE_BARN: // if (AliensDefeated) - if (gSaveContext.weekEventReg[22] & 1) { + if (gSaveContext.save.weekEventReg[22] & 1) { if (EnMaYto_SearchRomani(this, globalCtx)) { return 2; } @@ -422,7 +418,7 @@ void EnMaYto_DefaultDialogueHandler(EnMaYto* this, GlobalContext* globalCtx) { break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { this->unk31E = 0; EnMaYto_SetupDefaultWait(this); } @@ -443,7 +439,7 @@ void EnMaYto_DefaultDialogueHandler(EnMaYto* this, GlobalContext* globalCtx) { } void EnMaYto_DefaultHandlePlayerChoice(EnMaYto* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (globalCtx->msgCtx.choiceIndex == 0) { // Yes func_8019F208(); EnMaYto_SetFaceExpression(this, 0, 3); @@ -460,7 +456,7 @@ void EnMaYto_DefaultHandlePlayerChoice(EnMaYto* this, GlobalContext* globalCtx) } void EnMaYto_DefaultChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->textId) { case 0x3391: EnMaYto_SetFaceExpression(this, 0, 3); @@ -492,7 +488,7 @@ void EnMaYto_DefaultChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) } void EnMaYto_SetupDinnerWait(EnMaYto* this) { - if (CURRENT_DAY == 1 || (gSaveContext.weekEventReg[22] & 1)) { + if (CURRENT_DAY == 1 || (gSaveContext.save.weekEventReg[22] & 1)) { func_80B90E50(this, 0); this->unk31E = 0; } else { @@ -533,7 +529,7 @@ void EnMaYto_DinnerWait(EnMaYto* this, GlobalContext* globalCtx) { } void EnMaYto_SetupDinnerDialogueHandler(EnMaYto* this) { - if (CURRENT_DAY == 1 || (gSaveContext.weekEventReg[22] & 1)) { + if (CURRENT_DAY == 1 || (gSaveContext.save.weekEventReg[22] & 1)) { func_80B90E50(this, 1); } else { func_80B90E50(this, 2); @@ -554,7 +550,7 @@ void EnMaYto_DinnerDialogueHandler(EnMaYto* this, GlobalContext* globalCtx) { break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { EnMaYto_SetupDinnerWait(this); } break; @@ -568,7 +564,7 @@ void EnMaYto_DinnerDialogueHandler(EnMaYto* this, GlobalContext* globalCtx) { } void EnMaYto_DinnerHandlePlayerChoice(EnMaYto* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (globalCtx->msgCtx.choiceIndex == 0) { // Yes func_8019F208(); EnMaYto_SetFaceExpression(this, 0, 3); @@ -585,7 +581,7 @@ void EnMaYto_DinnerHandlePlayerChoice(EnMaYto* this, GlobalContext* globalCtx) { } void EnMaYto_DinnerChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->textId) { case 0x3398: EnMaYto_SetFaceExpression(this, 0, 3); @@ -684,7 +680,7 @@ void EnMaYto_DinnerChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { } void EnMaYto_SetupBarnWait(EnMaYto* this) { - if (CURRENT_DAY == 1 || (gSaveContext.weekEventReg[22] & 1)) { + if (CURRENT_DAY == 1 || (gSaveContext.save.weekEventReg[22] & 1)) { EnMaYto_ChangeAnim(this, 13); func_80B90E50(this, 0); this->unk31E = 0; @@ -712,7 +708,7 @@ void EnMaYto_BarnWait(EnMaYto* this, GlobalContext* globalCtx) { Actor_ChangeFocus(&this->actor, globalCtx, &this->actor); EnMaYto_BarnStartDialogue(this, globalCtx); EnMaYto_SetupBarnDialogueHandler(this); - } else if (!(gSaveContext.weekEventReg[22] & 1) || ABS_ALT(direction) < 0x2000) { + } else if (!(gSaveContext.save.weekEventReg[22] & 1) || ABS_ALT(direction) < 0x2000) { func_800B8614(&this->actor, globalCtx, 100.0f); child = this->actor.child; @@ -724,7 +720,7 @@ void EnMaYto_BarnWait(EnMaYto* this, GlobalContext* globalCtx) { } void EnMaYto_SetupBarnDialogueHandler(EnMaYto* this) { - if (CURRENT_DAY == 1 || (gSaveContext.weekEventReg[22] & 1)) { + if (CURRENT_DAY == 1 || (gSaveContext.save.weekEventReg[22] & 1)) { func_80B90E50(this, 1); } else { func_80B90E50(this, 2); @@ -740,7 +736,7 @@ void EnMaYto_BarnDialogueHandler(EnMaYto* this, GlobalContext* globalCtx) { break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { this->unk31E = 0; EnMaYto_SetupBarnWait(this); } @@ -756,7 +752,7 @@ void EnMaYto_BarnDialogueHandler(EnMaYto* this, GlobalContext* globalCtx) { } void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->textId) { case 0x33A9: func_80B90E50(this, 0); @@ -872,7 +868,7 @@ void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { } void EnMaYto_SetupAfterMilkRunInit(EnMaYto* this) { - if (gSaveContext.weekEventReg[52] & 1) { // if (ProtectedCremia) + if (gSaveContext.save.weekEventReg[52] & 1) { // if (ProtectedCremia) EnMaYto_SetFaceExpression(this, 3, 1); } else { func_801A3098(NA_BGM_FAILURE_1); @@ -887,7 +883,7 @@ void EnMaYto_AfterMilkRunInit(EnMaYto* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actor.flags &= ~ACTOR_FLAG_10000; - if (gSaveContext.weekEventReg[52] & 1) { // if (ProtectedCremia) + if (gSaveContext.save.weekEventReg[52] & 1) { // if (ProtectedCremia) Message_StartTextbox(globalCtx, 0x33C1, &this->actor); this->textId = 0x33C1; } else { @@ -896,7 +892,7 @@ void EnMaYto_AfterMilkRunInit(EnMaYto* this, GlobalContext* globalCtx) { Message_StartTextbox(globalCtx, 0x33C0, &this->actor); this->textId = 0x33C0; // Attempted Cremia Cart Ride - gSaveContext.weekEventReg[14] |= 1; + gSaveContext.save.weekEventReg[14] |= 1; this->unk310 = 4; EnMaYto_SetupPostMilkRunWaitDialogueEnd(this); func_80151BB4(globalCtx, 6); @@ -932,7 +928,7 @@ void EnMaYto_AfterMilkRunDialogueHandler(EnMaYto* this, GlobalContext* globalCtx } void EnMaYto_AfterMilkRunChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->textId) { case 0x33C1: EnMaYto_SetFaceExpression(this, 3, 1); @@ -978,7 +974,7 @@ void EnMaYto_PostMilkRunExplainReward(EnMaYto* this, GlobalContext* globalCtx) { Message_StartTextbox(globalCtx, 0x33C3, &this->actor); this->textId = 0x33C3; // Attempted Cremia Cart Ride - gSaveContext.weekEventReg[14] |= 1; + gSaveContext.save.weekEventReg[14] |= 1; this->unk310 = 3; func_80151BB4(globalCtx, 0x20); func_80151BB4(globalCtx, 0x1F); @@ -990,7 +986,7 @@ void EnMaYto_PostMilkRunExplainReward(EnMaYto* this, GlobalContext* globalCtx) { Message_StartTextbox(globalCtx, 0x33D0, &this->actor); this->textId = 0x33D0; // Attempted Cremia Cart Ride - gSaveContext.weekEventReg[14] |= 1; + gSaveContext.save.weekEventReg[14] |= 1; this->unk310 = 3; func_80151BB4(globalCtx, 6); EnMaYto_SetupPostMilkRunWaitDialogueEnd(this); @@ -1041,7 +1037,7 @@ void EnMaYto_WarmFuzzyFeelingCs(EnMaYto* this, GlobalContext* globalCtx) { case 2: // Attempted Cremia Cart Ride - gSaveContext.weekEventReg[14] |= 1; + gSaveContext.save.weekEventReg[14] |= 1; EnMaYto_ChangeAnim(this, 18); break; @@ -1068,7 +1064,7 @@ void EnMaYto_SetupPostMilkRunWaitDialogueEnd(EnMaYto* this) { void EnMaYto_PostMilkRunWaitDialogueEnd(EnMaYto* this, GlobalContext* globalCtx) { if (Message_GetState(&globalCtx->msgCtx) == 6 || Message_GetState(&globalCtx->msgCtx) == 5) { - if (func_80147624(globalCtx) && Message_GetState(&globalCtx->msgCtx) == 5) { + if (Message_ShouldAdvance(globalCtx) && Message_GetState(&globalCtx->msgCtx) == 5) { func_800B7298(globalCtx, &this->actor, 7); func_801477B4(globalCtx); } @@ -1099,7 +1095,7 @@ void EnMaYto_PostMilkRunEnd(EnMaYto* this, GlobalContext* globalCtx) { void EnMaYto_DefaultStartDialogue(EnMaYto* this, GlobalContext* globalCtx) { if (CURRENT_DAY == 1) { - if (Player_GetMask(globalCtx) != PLAYER_MASK_NONE && gSaveContext.playerForm == PLAYER_FORM_HUMAN) { + if (Player_GetMask(globalCtx) != PLAYER_MASK_NONE && gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { switch (Player_GetMask(globalCtx)) { case PLAYER_MASK_ROMANI: Message_StartTextbox(globalCtx, 0x235D, &this->actor); @@ -1129,7 +1125,7 @@ void EnMaYto_DefaultStartDialogue(EnMaYto* this, GlobalContext* globalCtx) { break; } } else { - if (EnMaYto_HasSpokeToPlayer()) { + if (EnMaYto_HasSpokenToPlayer()) { Message_StartTextbox(globalCtx, 0x3394, &this->actor); this->textId = 0x3394; } else { @@ -1140,7 +1136,7 @@ void EnMaYto_DefaultStartDialogue(EnMaYto* this, GlobalContext* globalCtx) { } } } else if (CURRENT_DAY == 3) { - if (EnMaYto_HasSpokeToPlayerToday()) { + if (EnMaYto_HasSpokenToPlayerToday()) { EnMaYto_SetFaceExpression(this, 0, 3); Message_StartTextbox(globalCtx, 0x33C5, &this->actor); this->textId = 0x33C5; @@ -1158,7 +1154,7 @@ void EnMaYto_DefaultStartDialogue(EnMaYto* this, GlobalContext* globalCtx) { void EnMaYto_DinnerStartDialogue(EnMaYto* this, GlobalContext* globalCtx) { switch (CURRENT_DAY) { case 1: - if (Player_GetMask(globalCtx) != PLAYER_MASK_NONE && gSaveContext.playerForm == PLAYER_FORM_HUMAN) { + if (Player_GetMask(globalCtx) != PLAYER_MASK_NONE && gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { switch (Player_GetMask(globalCtx)) { case PLAYER_MASK_ROMANI: Message_StartTextbox(globalCtx, 0x235D, &this->actor); @@ -1186,7 +1182,7 @@ void EnMaYto_DinnerStartDialogue(EnMaYto* this, GlobalContext* globalCtx) { break; } } else { - if (EnMaYto_HasSpokeToPlayer()) { + if (EnMaYto_HasSpokenToPlayer()) { Message_StartTextbox(globalCtx, 0x339F, &this->actor); this->textId = 0x339F; } else { @@ -1198,7 +1194,7 @@ void EnMaYto_DinnerStartDialogue(EnMaYto* this, GlobalContext* globalCtx) { break; case 2: - if (EnMaYto_HasSpokeToPlayer()) { + if (EnMaYto_HasSpokenToPlayer()) { Message_StartTextbox(globalCtx, 0x33A6, &this->actor); this->textId = 0x33A6; func_80151BB4(globalCtx, 6); @@ -1210,7 +1206,7 @@ void EnMaYto_DinnerStartDialogue(EnMaYto* this, GlobalContext* globalCtx) { break; case 3: - if (EnMaYto_HasSpokeToPlayer()) { + if (EnMaYto_HasSpokenToPlayer()) { Message_StartTextbox(globalCtx, 0x33A8, &this->actor); this->textId = 0x33A8; func_80151BB4(globalCtx, 6); @@ -1225,7 +1221,7 @@ void EnMaYto_DinnerStartDialogue(EnMaYto* this, GlobalContext* globalCtx) { void EnMaYto_BarnStartDialogue(EnMaYto* this, GlobalContext* globalCtx) { // if (AliensDefeated) - if (gSaveContext.weekEventReg[22] & 1) { + if (gSaveContext.save.weekEventReg[22] & 1) { if (CURRENT_DAY == 2) { if (this->unk310 == 1) { Message_StartTextbox(globalCtx, 0x33AE, &this->actor); @@ -1249,7 +1245,7 @@ void EnMaYto_BarnStartDialogue(EnMaYto* this, GlobalContext* globalCtx) { } } } else { - if (EnMaYto_HasSpokeToPlayer()) { + if (EnMaYto_HasSpokenToPlayer()) { this->unk31E = 2; EnMaYto_SetFaceExpression(this, 5, 3); Message_StartTextbox(globalCtx, 0x33B3, &this->actor); @@ -1348,7 +1344,7 @@ void EnMaYto_SetFaceExpression(EnMaYto* this, s16 overrideEyeTexIndex, s16 mouth } void EnMaYto_InitFaceExpression(EnMaYto* this) { - if (CURRENT_DAY == 1 || (gSaveContext.weekEventReg[22] & 1)) { + if (CURRENT_DAY == 1 || (gSaveContext.save.weekEventReg[22] & 1)) { EnMaYto_SetFaceExpression(this, 0, 1); EnMaYto_SetRomaniFaceExpression(this, 0, 0); } else { @@ -1357,22 +1353,22 @@ void EnMaYto_InitFaceExpression(EnMaYto* this) { } } -s32 EnMaYto_HasSpokeToPlayerToday(void) { +s32 EnMaYto_HasSpokenToPlayerToday(void) { switch (CURRENT_DAY) { case 1: - if (gSaveContext.weekEventReg[13] & 4) { + if (gSaveContext.save.weekEventReg[13] & 4) { return true; } break; case 2: - if (gSaveContext.weekEventReg[13] & 8) { + if (gSaveContext.save.weekEventReg[13] & 8) { return true; } break; case 3: - if (gSaveContext.weekEventReg[13] & 0x10) { + if (gSaveContext.save.weekEventReg[13] & 0x10) { return true; } break; @@ -1380,21 +1376,21 @@ s32 EnMaYto_HasSpokeToPlayerToday(void) { return false; } -s32 EnMaYto_HasSpokeToPlayer(void) { +s32 EnMaYto_HasSpokenToPlayer(void) { // Please note each case doesn't have their respective `break`s. switch (CURRENT_DAY) { case 3: - if (gSaveContext.weekEventReg[13] & 0x10) { + if (gSaveContext.save.weekEventReg[13] & 0x10) { return true; } case 2: - if (gSaveContext.weekEventReg[13] & 8) { + if (gSaveContext.save.weekEventReg[13] & 8) { return true; } case 1: - if (gSaveContext.weekEventReg[13] & 4) { + if (gSaveContext.save.weekEventReg[13] & 4) { return true; } } @@ -1404,15 +1400,15 @@ s32 EnMaYto_HasSpokeToPlayer(void) { void EnMaYto_SetTalkedFlag(void) { switch (CURRENT_DAY) { case 1: - gSaveContext.weekEventReg[13] |= 4; + gSaveContext.save.weekEventReg[13] |= 4; break; case 2: - gSaveContext.weekEventReg[13] |= 8; + gSaveContext.save.weekEventReg[13] |= 8; break; case 3: - gSaveContext.weekEventReg[13] |= 0x10; + gSaveContext.save.weekEventReg[13] |= 0x10; break; } } @@ -1464,7 +1460,7 @@ void EnMaYto_Draw(Actor* thisx, GlobalContext* globalCtx) { s32 pad; OPEN_DISPS(globalCtx->state.gfxCtx); - if (this->type == MA_YTO_TYPE_BARN && (gSaveContext.weekEventReg[22] & 1)) { // Aliens defeated + if (this->type == MA_YTO_TYPE_BARN && (gSaveContext.save.weekEventReg[22] & 1)) { // Aliens defeated gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gCremiaWoodenBox); } diff --git a/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c b/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c index bb88e44355..29eb6cdcc7 100644 --- a/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c +++ b/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c @@ -145,7 +145,7 @@ void EnMaYts_InitAnimation(EnMaYts* this, GlobalContext* globalCtx) { case MA_YTS_TYPE_SITTING: this->actor.targetMode = 6; // Day 1 or "Winning" the alien invasion - if (CURRENT_DAY == 1 || (gSaveContext.weekEventReg[22] & 1)) { + if (CURRENT_DAY == 1 || (gSaveContext.save.weekEventReg[22] & 1)) { EnMaYts_ChangeAnim(this, 14); } else { EnMaYts_ChangeAnim(this, 18); @@ -178,14 +178,14 @@ s32 EnMaYts_CheckValidSpawn(EnMaYts* this, GlobalContext* globalCtx) { case 2: // Failing the alien invasion - if (!(gSaveContext.weekEventReg[22] & 1)) { + if (!(gSaveContext.save.weekEventReg[22] & 1)) { return false; } break; case 3: // "Winning" the alien invasion - if (gSaveContext.weekEventReg[22] & 1) { + if (gSaveContext.save.weekEventReg[22] & 1) { return false; } break; @@ -194,16 +194,16 @@ s32 EnMaYts_CheckValidSpawn(EnMaYts* this, GlobalContext* globalCtx) { case MA_YTS_TYPE_BARN: // Failing the alien invasion - if (!(gSaveContext.weekEventReg[22] & 1)) { + if (!(gSaveContext.save.weekEventReg[22] & 1)) { return false; - } else if (gSaveContext.time >= CLOCK_TIME(20, 0) && CURRENT_DAY == 3) { + } else if (gSaveContext.save.time >= CLOCK_TIME(20, 0) && CURRENT_DAY == 3) { return false; } break; case MA_YTS_TYPE_SLEEPING: // "Winning" the alien invasion - if (gSaveContext.weekEventReg[22] & 1) { + if (gSaveContext.save.weekEventReg[22] & 1) { return false; } break; @@ -250,7 +250,7 @@ void EnMaYts_Init(Actor* thisx, GlobalContext* globalCtx) { this->hasBow = false; } - if (CURRENT_DAY == 1 || (gSaveContext.weekEventReg[22] & 1)) { + if (CURRENT_DAY == 1 || (gSaveContext.save.weekEventReg[22] & 1)) { this->overrideEyeTexIndex = 0; this->eyeTexIndex = 0; this->mouthTexIndex = 0; @@ -268,7 +268,7 @@ void EnMaYts_Init(Actor* thisx, GlobalContext* globalCtx) { this->mouthTexIndex = 0; this->unk_32C = 2; EnMaYts_SetupEndCreditsHandler(this); - } else if (CURRENT_DAY == 2 && gSaveContext.isNight == 1 && (gSaveContext.weekEventReg[22] & 1)) { + } else if (CURRENT_DAY == 2 && gSaveContext.save.isNight == 1 && (gSaveContext.save.weekEventReg[22] & 1)) { EnMaYts_SetupStartDialogue(this); } else { EnMaYts_SetupDoNothing(this); @@ -297,10 +297,10 @@ void EnMaYts_StartDialogue(EnMaYts* this, GlobalContext* globalCtx) { s16 sp26 = this->actor.shape.rot.y - this->actor.yawTowardsPlayer; if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - if (!(gSaveContext.playerForm == PLAYER_FORM_HUMAN)) { - if (!(gSaveContext.weekEventReg[65] & 0x80)) { + if (!(gSaveContext.save.playerForm == PLAYER_FORM_HUMAN)) { + if (!(gSaveContext.save.weekEventReg[65] & 0x80)) { // Saying to non-human Link: "Cremia went to town." - gSaveContext.weekEventReg[65] |= 0x80; + gSaveContext.save.weekEventReg[65] |= 0x80; EnMaYts_SetFaceExpression(this, 0, 0); Message_StartTextbox(globalCtx, 0x335F, &this->actor); this->textId = 0x335F; @@ -312,8 +312,8 @@ void EnMaYts_StartDialogue(EnMaYts* this, GlobalContext* globalCtx) { func_80151BB4(globalCtx, 5); } } else if (Player_GetMask(globalCtx) != PLAYER_MASK_NONE) { - if (!(gSaveContext.weekEventReg[65] & 0x40)) { - gSaveContext.weekEventReg[65] |= 0x40; + if (!(gSaveContext.save.weekEventReg[65] & 0x40)) { + gSaveContext.save.weekEventReg[65] |= 0x40; EnMaYts_SetFaceExpression(this, 0, 0); Message_StartTextbox(globalCtx, 0x3363, &this->actor); this->textId = 0x3363; @@ -323,14 +323,14 @@ void EnMaYts_StartDialogue(EnMaYts* this, GlobalContext* globalCtx) { this->textId = 0x3366; func_80151BB4(globalCtx, 5); } - } else if (!(gSaveContext.weekEventReg[21] & 0x20)) { + } else if (!(gSaveContext.save.weekEventReg[21] & 0x20)) { EnMaYts_SetFaceExpression(this, 0, 0); Message_StartTextbox(globalCtx, 0x3367, &this->actor); this->textId = 0x3367; } else { - if (!(gSaveContext.weekEventReg[65] & 0x20)) { + if (!(gSaveContext.save.weekEventReg[65] & 0x20)) { // Saying to Grasshopper: "Cremia went to town." - gSaveContext.weekEventReg[65] |= 0x20; + gSaveContext.save.weekEventReg[65] |= 0x20; EnMaYts_SetFaceExpression(this, 4, 2); Message_StartTextbox(globalCtx, 0x3369, &this->actor); this->textId = 0x3369; @@ -359,7 +359,7 @@ void EnMaYts_DialogueHandler(EnMaYts* this, GlobalContext* globalCtx) { break; case 6: // End conversation - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx) != 0) { EnMaYts_SetupStartDialogue(this); } break; @@ -426,7 +426,7 @@ void EnMaYts_EndCreditsHandler(EnMaYts* this, GlobalContext* globalCtx) { // Select the following dialogue based on the current one, and an appropiate face expression void EnMaYts_ChooseNextDialogue(EnMaYts* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx) != 0) { switch (this->textId) { case 0x335F: EnMaYts_SetFaceExpression(this, 0, 2); diff --git a/src/overlays/actors/ovl_En_Mag/z_en_mag.c b/src/overlays/actors/ovl_En_Mag/z_en_mag.c index 9e6b3e9e9e..907ba619b1 100644 --- a/src/overlays/actors/ovl_En_Mag/z_en_mag.c +++ b/src/overlays/actors/ovl_En_Mag/z_en_mag.c @@ -162,7 +162,7 @@ void EnMag_Init(Actor* thisx, GlobalContext* globalCtx) { this->state = MAG_STATE_FADE_IN_MASK; sInputDelayTimer = 20; gSaveContext.fadeDuration = 1; - gSaveContext.unk_3F51 = 255; + gSaveContext.fadeSpeed = 255; } Font_LoadOrderedFont(&this->font); @@ -246,7 +246,7 @@ void EnMag_Update(Actor* thisx, GlobalContext* globalCtx) { this->unk11F02 = 30; sInputDelayTimer = 20; gSaveContext.fadeDuration = 1; - gSaveContext.unk_3F51 = 255; + gSaveContext.fadeSpeed = 255; } } } else { @@ -392,7 +392,7 @@ void EnMag_Update(Actor* thisx, GlobalContext* globalCtx) { globalCtx->sceneLoadFlag = 0x14; globalCtx->unk_1887F = 2; globalCtx->nextEntranceIndex = 0x1C00; - gSaveContext.cutscene = 0; + gSaveContext.save.cutscene = 0; gSaveContext.sceneSetupIndex = 0; } this->unk11F54 = 15; diff --git a/src/overlays/actors/ovl_En_Maruta/z_en_maruta.c b/src/overlays/actors/ovl_En_Maruta/z_en_maruta.c index 0c736886ef..9d6f6312ea 100644 --- a/src/overlays/actors/ovl_En_Maruta/z_en_maruta.c +++ b/src/overlays/actors/ovl_En_Maruta/z_en_maruta.c @@ -5,6 +5,8 @@ */ #include "z_en_maruta.h" +#include "overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.h" +#include "objects/object_maruta/object_maruta.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_10) @@ -15,16 +17,25 @@ void EnMaruta_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnMaruta_Update(Actor* thisx, GlobalContext* globalCtx); void EnMaruta_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80B372B8(EnMaruta* this); void func_80B372CC(EnMaruta* this, GlobalContext* globalCtx); +void func_80B37364(EnMaruta* this); void func_80B3738C(EnMaruta* this, GlobalContext* globalCtx); +void func_80B373F4(EnMaruta* this); void func_80B37428(EnMaruta* this, GlobalContext* globalCtx); void func_80B374FC(EnMaruta* this, GlobalContext* globalCtx); +void func_80B37590(EnMaruta* this, GlobalContext* globalCtx); void func_80B37950(EnMaruta* this, GlobalContext* globalCtx); void func_80B379C0(EnMaruta* this, GlobalContext* globalCtx); +void func_80B37A14(EnMaruta* this); void func_80B37A64(EnMaruta* this, GlobalContext* globalCtx); void func_80B37AA0(EnMaruta* this, GlobalContext* globalCtx); +void func_80B37C04(s16* arg0); +void func_80B37EC0(EnMaruta* this, GlobalContext* globalCtx); +void func_80B38060(EnMaruta* this, Vec3f* arg1); +void func_80B3828C(Vec3f* arg0, Vec3f* arg1, s16 arg2, s16 arg3, s32 arg4); +void func_80B382E4(GlobalContext* globalCtx, Vec3f arg1); -#if 0 const ActorInit En_Maruta_InitVars = { ACTOR_EN_MARUTA, ACTORCAT_PROP, @@ -37,15 +48,94 @@ const ActorInit En_Maruta_InitVars = { (ActorFunc)EnMaruta_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B38AFC = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, +Gfx* D_80B386A0[] = { + object_maruta_DL_002220, object_maruta_DL_0023D0, object_maruta_DL_002568, object_maruta_DL_002660, + object_maruta_DL_002758, object_maruta_DL_002850, object_maruta_DL_002948, object_maruta_DL_002AE0, +}; + +u8 D_80B386C0[] = { + 0xFF, 0x2B, 0xD4, 0x17, 0xE8, 0x55, 0xAA, 0x0F, 0xF0, +}; + +s32 D_80B386CC[] = { + 5, 5, 3, 3, 7, 7, 7, 7, 3, 3, 3, 3, 7, 7, 3, 3, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, +}; + +Vec3f D_80B38754 = { -2.0f, 3.0f, 0.0f }; +Vec3f D_80B38760 = { -2.0f, 3.0f, 0.0f }; +Vec3f D_80B3876C = { 2.0f, 3.0f, 0.0f }; +Vec3f D_80B38778 = { -2.0f, 10.0f, 0.0f }; +Vec3f D_80B38784 = { -2.5f, 5.0f, 0.0f }; +Vec3f D_80B38790 = { -3.0f, 10.0f, 0.0f }; +Vec3f D_80B3879C = { 2.5f, 5.0f, 0.0f }; +Vec3f D_80B387A8 = { 3.0f, 10.0f, 0.0f }; +Vec3f D_80B387B4 = { -1.0f, 7.0f, -1.0f }; +Vec3f D_80B387C0 = { 1.0f, 7.0f, -1.0f }; +Vec3f D_80B387CC = { 0.0f, 8.0f, -1.5f }; +Vec3f D_80B387D8 = { 0.0f, 8.0f, -1.5f }; + +Vec3f D_80B387E4[] = { + { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { -10.0f, 460.0f, 0.0f }, + { 0.0f, 0.0f, 0.0f }, { 10.0f, 460.0f, 0.0f }, { -40.0f, 315.0f, 0.0f }, + { 40.0f, 315.0f, 0.0f }, { 0.0f, 140.0f, 0.0f }, { 0.0f, 445.0f, 0.0f }, +}; + +Vec3f D_80B38850[] = { + { 0.0f, 0.0f, 1.0f }, { 0.0f, 0.0f, -1.0f }, { 0.0f, 0.0f, -1.0f }, { 0.0f, 0.0f, 1.0f }, { 0.0f, 0.0f, 1.0f }, + { 0.0f, 0.0f, 1.0f }, { 0.0f, 0.0f, -1.0f }, { -1.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 1.0f }, +}; + +Vec3f D_80B388BC[] = { + { 90.0f, 630.0f, -78.0f }, { -90.0f, 630.0f, -78.0f }, { -90.0f, 630.0f, 78.0f }, { 90.0f, 630.0f, 78.0f }, + { 90.0f, 350.0f, -78.0f }, { -90.0f, 170.0f, -78.0f }, { -90.0f, 170.0f, 78.0f }, { 90.0f, 350.0f, 78.0f }, +}; + +Vec3f D_80B3891C[] = { + { 90.0f, 630.0f, -78.0f }, { -90.0f, 630.0f, -78.0f }, { -90.0f, 630.0f, 78.0f }, { 90.0f, 630.0f, 78.0f }, + { 90.0f, 170.0f, -78.0f }, { -90.0f, 350.0f, -78.0f }, { -90.0f, 350.0f, 78.0f }, { 90.0f, 170.0f, 78.0f }, +}; + +Vec3f D_80B3897C[] = { + { 0.0f, 630.0f, -104.0f }, { -90.0f, 630.0f, -52.0f }, { -90.0f, 630.0f, 52.0f }, { 0.0f, 630.0f, 104.0f }, + { 0.0f, 0.0f, -104.0f }, { -90.0f, 0.0f, -52.0f }, { -90.0f, 0.0f, 52.0f }, { 0.0f, 0.0f, 104.0f }, +}; + +Vec3f D_80B389DC[] = { + { 0.0f, 630.0f, -104.0f }, { 90.0f, 630.0f, -52.0f }, { 90.0f, 630.0f, 52.0f }, { 0.0f, 630.0f, 104.0f }, + { 0.0f, 0.0f, -104.0f }, { 90.0f, 0.0f, -52.0f }, { 90.0f, 0.0f, 52.0f }, { 0.0f, 0.0f, 104.0f }, +}; + +Vec3f D_80B38A3C[] = { + { 90.0f, 630.0f, -78.0f }, { -90.0f, 630.0f, -78.0f }, { -90.0f, 630.0f, 78.0f }, { 90.0f, 630.0f, 78.0f }, + { 90.0f, 260.0f, -78.0f }, { -90.0f, 260.0f, -78.0f }, { -90.0f, 260.0f, 78.0f }, { 90.0f, 260.0f, 78.0f }, +}; + +Vec3f D_80B38A9C[] = { + { 90.0f, 260.0f, -78.0f }, { -90.0f, 260.0f, -78.0f }, { -90.0f, 260.0f, 78.0f }, { 90.0f, 260.0f, 78.0f }, + { 90.0f, 20.0f, -78.0f }, { -90.0f, 20.0f, -78.0f }, { -90.0f, 20.0f, 78.0f }, { 90.0f, 20.0f, 78.0f }, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 12, 65, 0, { 0, 0, 0 } }, }; -// static DamageTable sDamageTable = { -static DamageTable D_80B38B28 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x0), /* Deku Stick */ DMG_ENTRY(0, 0xF), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -80,71 +170,530 @@ static DamageTable D_80B38B28 = { /* Powder Keg */ DMG_ENTRY(0, 0x0), }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80B38B48 = { 8, 0, 0, 0, MASS_HEAVY }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 8, 0, 0, 0, MASS_HEAVY }; -#endif +Vec3f D_80B38B54 = { 0.0f, 0.0f, 0.0f }; -extern ColliderCylinderInit D_80B38AFC; -extern DamageTable D_80B38B28; -extern CollisionCheckInfoInit2 D_80B38B48; +void EnMaruta_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnMaruta* this = THIS; + s32 i; -extern UNK_TYPE D_06002EC0; + Actor_SetScale(&this->actor, 0.1f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/EnMaruta_Init.s") + this->actor.targetMode = 6; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/EnMaruta_Destroy.s") + this->actor.focus.pos = this->actor.world.pos; + this->actor.focus.pos.y += 50.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B372B8.s") + this->actor.colChkInfo.health = 1; + this->actor.world.pos.y -= 4.0f; + this->actor.home.pos.y -= 4.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B372CC.s") + this->unk_210 = ENMARUTA_GET_FF00(&this->actor); + this->unk_218 = 0; + this->unk_21A = 0; + this->unk_1A0 = NULL; + this->unk_21C = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B37364.s") + this->unk_194.x = 0.0f; + this->unk_194.y = 0.0f; + this->unk_194.z = 1.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B3738C.s") + for (i = 0; i < ARRAY_COUNT(this->unk_1A4); i++) { + this->unk_1A4[i] = D_80B38B54; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B373F4.s") + this->unk_214 = -1; + this->unk_220 = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B37428.s") + if (this->unk_210 == 0) { + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B374B8.s") + if (this->unk_210 == 0) { + if (ENMARUTA_GET_FF(&this->actor) == 0xFF) { + func_80B372B8(this); + } else { + func_80B37364(this); + } + } else { + func_80B37590(this, globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B374FC.s") +void EnMaruta_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnMaruta* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B37590.s") + if (this->unk_210 == 0) { + Collider_DestroyCylinder(globalCtx, &this->collider); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B37950.s") +void func_80B372B8(EnMaruta* this) { + this->actionFunc = func_80B372CC; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B37998.s") +void func_80B372CC(EnMaruta* this, GlobalContext* globalCtx) { + s16 temp_v1 = BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B379C0.s") + if (temp_v1 > 0x1555) { + this->actor.shape.rot.y += 0x2AAA; + } else if (temp_v1 < -0x1555) { + this->actor.shape.rot.y -= 0x2AAA; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B37A14.s") + if (this->unk_220 == 1) { + func_80B373F4(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B37A64.s") + if ((this->actor.parent != NULL) && (this->actor.parent->id == ACTOR_EN_KENDO_JS)) { + EnKendoJs* kendoJs = (EnKendoJs*)this->actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B37A8C.s") + kendoJs->unk_292 = this->actor.isTargeted; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B37AA0.s") +void func_80B37364(EnMaruta* this) { + this->actor.world.pos.y = this->actor.home.pos.y - 630.0f; + this->actionFunc = func_80B3738C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B37B78.s") +void func_80B3738C(EnMaruta* this, GlobalContext* globalCtx) { + if (Math_SmoothStepToF(&this->actor.world.pos.y, this->actor.home.pos.y, 0.4f, 100.0f, 10.0f) == 0.0f) { + func_80B372B8(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B37C04.s") +void func_80B373F4(EnMaruta* this) { + this->collider.base.acFlags |= AC_HIT; + this->actor.velocity.y = 0.0f; + this->actor.gravity = -2.0f; + this->actionFunc = func_80B37428; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B37C60.s") +void func_80B37428(EnMaruta* this, GlobalContext* globalCtx) { + if ((this->actor.floorHeight - 630.0f) < this->actor.world.pos.y) { + this->actor.velocity.y += this->actor.gravity; + this->actor.world.pos.y += this->actor.velocity.y; + } else { + if ((this->actor.parent != NULL) && (this->actor.parent->id == ACTOR_EN_KENDO_JS)) { + EnKendoJs* kendoJs = (EnKendoJs*)this->actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B37CA0.s") + kendoJs->unk_28C--; + } + Actor_MarkForDeath(&this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B37EC0.s") +void func_80B374B8(EnMaruta* this) { + this->actor.flags &= ~ACTOR_FLAG_1; + if (this->actionFunc != func_80B37428) { + this->unk_21E = 0; + this->actor.gravity = -2.0f; + this->actionFunc = func_80B374FC; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B38028.s") +void func_80B374FC(EnMaruta* this, GlobalContext* globalCtx) { + if (this->unk_21E == 40) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B38060.s") + if (((this->actor.floorHeight - 630.0f) < this->actor.world.pos.y) && (this->unk_21E > 30)) { + this->actor.velocity.y += this->actor.gravity; + this->actor.world.pos.y += this->actor.velocity.y; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B3828C.s") + this->unk_21E++; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B382E4.s") +void func_80B37590(EnMaruta* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f sp48; + s16 sp46; + Vec3f sp38; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/EnMaruta_Update.s") + this->unk_21E = 0; + this->unk_21C = 0; + this->actor.gravity = -2.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/EnMaruta_Draw.s") + switch (this->unk_210) { + case 2: + sp48 = D_80B38754; + this->unk_1A0 = D_80B388BC; + break; + + case 4: + if (player->swordAnimation == 8) { + sp48 = D_80B3876C; + } else { + sp48 = D_80B38778; + } + this->unk_1A0 = D_80B3891C; + break; + + case 5: + if (player->swordAnimation == 0) { + sp48 = D_80B38784; + } else { + sp48 = D_80B38790; + } + this->unk_1A0 = D_80B3897C; + break; + + case 6: + if (player->swordAnimation == 0) { + sp48 = D_80B3879C; + } else { + sp48 = D_80B387A8; + } + this->unk_1A0 = D_80B389DC; + break; + + case 8: + if (player->swordAnimation == 4) { + sp48 = D_80B387B4; + } else { + sp48 = D_80B387C0; + } + this->unk_1A0 = D_80B38A3C; + break; + + case 7: + sp48 = D_80B387CC; + this->unk_1A0 = D_80B38A9C; + break; + + default: + sp48 = D_80B38B54; + break; + } + + sp46 = this->actor.shape.rot.y; + this->actor.velocity.x = (sp48.x * Math_CosS(sp46) + (Math_SinS(sp46) * sp48.z)); + this->actor.velocity.y = sp48.y; + this->actor.velocity.z = (-sp48.x * Math_SinS(sp46) + (Math_CosS(sp46) * sp48.z)); + + sp38 = D_80B38850[this->unk_210]; + + func_80B3828C(&sp38, &this->unk_194, Rand_Next() & 0xFFF, Rand_Next() & 0xFFF, 0); + this->unk_21A = Rand_Next() & 0x7FF; + + if (this->unk_210 == 7) { + this->unk_21A |= 0x3F; + } else { + this->unk_21A |= 0xFF; + } + + this->actor.flags &= ~ACTOR_FLAG_1; + this->actionFunc = func_80B37950; +} + +void func_80B37950(EnMaruta* this, GlobalContext* globalCtx) { + this->unk_218 += this->unk_21A; + this->actor.velocity.y += this->actor.gravity; + func_80B37EC0(this, globalCtx); + Actor_UpdatePos(&this->actor); +} + +void func_80B37998(EnMaruta* this) { + this->unk_21E = 0; + this->actor.gravity = 0.0f; + this->actor.velocity.y = 0.0f; + this->unk_21A = 0; + this->actionFunc = func_80B379C0; +} + +void func_80B379C0(EnMaruta* this, GlobalContext* globalCtx) { + if (this->unk_21E == 40) { + func_80B37A14(this); + } else { + this->unk_21E++; + } + func_80B37C04(&this->unk_218); +} + +void func_80B37A14(EnMaruta* this) { + s16 temp = this->unk_218 & 0x7FFF; + + if (((this->unk_210 == 5) || (this->unk_210 == 6)) && !temp) { + this->unk_21E = 100; + } else { + this->unk_21E = 0; + } + this->actionFunc = func_80B37A64; +} + +void func_80B37A64(EnMaruta* this, GlobalContext* globalCtx) { + if (this->unk_21E > 100) { + this->actor.colChkInfo.health = 0; + } else { + this->unk_21E++; + } +} + +void func_80B37A8C(EnMaruta* this) { + this->actionFunc = func_80B37AA0; +} + +void func_80B37AA0(EnMaruta* this, GlobalContext* globalCtx) { + if (this->actor.scale.y == 0.0f) { + if (this->actor.scale.x == 0.0f) { + Actor_MarkForDeath(&this->actor); + return; + } + Math_SmoothStepToF(&this->actor.scale.x, 0.0f, 0.2f, 0.01f, 0.001f); + Math_SmoothStepToF(&this->actor.scale.z, 0.0f, 0.2f, 0.01f, 0.001f); + } else { + Math_SmoothStepToF(&this->actor.scale.y, 0.0f, 0.2f, 0.003f, 0.001f); + } +} + +s32 func_80B37B78(EnMaruta* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 temp_v1 = BINANG_SUB(this->actor.yawTowardsPlayer, 0x8000); + + temp_v1 = BINANG_SUB(temp_v1, player->actor.shape.rot.y); + if ((ABS_ALT(temp_v1) < 0x1555) || + ((player->swordState != 0) && ((player->swordAnimation == 4) || (player->swordAnimation == 6) || + (player->swordAnimation == 0x1E) || (player->swordAnimation == 0x20)))) { + return true; + } + return false; +} + +void func_80B37C04(s16* arg0) { + s16 temp_a1 = *arg0 & 0xC000; + s16 temp = *arg0 & 0x3FFF; + + if (temp > 0x2000) { + temp_a1 += 0x4000; + } + Math_SmoothStepToS(arg0, temp_a1, 1, 0xAAA, 0xB6); +} + +void func_80B37C60(EnMaruta* this) { + if ((this->actionFunc != func_80B37AA0) && (this->actor.colChkInfo.health == 0)) { + func_80B37A8C(this); + } +} + +void func_80B37CA0(EnMaruta* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if ((this->actionFunc == func_80B372CC) || (this->actionFunc == func_80B3738C) || + (this->actionFunc == func_80B374FC) || (this->actionFunc == func_80B37AA0) || + ((this->actionFunc == func_80B37428) && !(this->actor.world.pos.y < (this->actor.floorHeight - 20.0f)))) { + if ((this->collider.base.acFlags & AC_HIT) && (this->actionFunc == func_80B372CC)) { + this->collider.base.acFlags &= ~AC_HIT; + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_SWORD_STRIKE); + + if (D_80B386CC[player->swordAnimation] != 0) { + s32 temp = D_80B386CC[player->swordAnimation] + 1; + + temp = (temp << 8) & 0xFF00; + this->unk_210 = D_80B386CC[player->swordAnimation]; + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_MARUTA, + this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, + this->actor.shape.rot.y, 0, temp); + this->actor.world.rot.y = this->actor.shape.rot.y; + if ((this->unk_210 == 5) || ((this->unk_210 == 7) && (player->swordAnimation == 0xC))) { + func_80B37590(this, globalCtx); + } else { + func_80B374B8(this); + } + + if ((this->actor.parent != NULL) && (this->actor.parent->id == ACTOR_EN_KENDO_JS)) { + EnKendoJs* kendoJs = (EnKendoJs*)this->actor.parent; + + kendoJs->unk_28E = 1; + kendoJs->unk_28C--; + } + return; + } + } + + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + + if (func_80B37B78(this, globalCtx) && (this->actionFunc == func_80B372CC)) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + } +} + +void func_80B37EC0(EnMaruta* this, GlobalContext* globalCtx) { + Vec3f sp34 = this->unk_204; + s32 phi_a2 = -1; + s32 i; + f32 temp; + + for (i = 0; i < ARRAY_COUNT(this->unk_1A4); i++) { + if (this->unk_1A4[i].y < sp34.y) { + sp34 = this->unk_1A4[i]; + phi_a2 = i; + } + this->unk_214 = phi_a2; + } + + if (sp34.y < this->actor.floorHeight) { + this->unk_218 -= this->unk_21A; + + temp = this->actor.floorHeight - sp34.y; + this->actor.velocity.y -= this->actor.gravity; + this->actor.velocity.x *= 0.6f; + this->actor.velocity.z *= 0.6f; + this->actor.world.pos.y += temp; + + if (this->actor.velocity.y < -this->actor.gravity) { + func_80B382E4(globalCtx, sp34); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_LOG_BOUND); + this->actor.velocity.y *= -0.6f; + func_80B38060(this, &sp34); + } + } +} + +f32 func_80B38028(Vec3f* arg0, Vec3f* arg1, Vec3f* arg2) { + f32 x0 = arg0->x; + f32 z0 = arg0->z; + f32 dx = arg2->x - arg1->x; + f32 dz = arg2->z - arg1->z; + + return z0 * dx - x0 * dz; +} + +void func_80B38060(EnMaruta* this, Vec3f* arg1) { + Vec3f sp44; + s32 pad; + f32 temp_f0; + f32 phi_f2; + + func_80B3828C(&this->unk_194, &sp44, 0, this->actor.shape.rot.y, 0); + temp_f0 = func_80B38028(&sp44, &this->unk_204, arg1); + + if ((this->unk_210 == 5) || (this->unk_210 == 6)) { + phi_f2 = 8.0f; + } else if (this->unk_210 == 4) { + phi_f2 = 5.0f; + } else { + phi_f2 = 2.0f; + } + + if ((temp_f0 < phi_f2) && (-phi_f2 < temp_f0)) { + phi_f2 = 3.0f; + } else { + phi_f2 = 1.2f; + } + + if (temp_f0 > 0.0f) { + if (this->unk_21A > 0) { + this->unk_21A *= phi_f2; + } else { + this->unk_21A *= -0.8f; + } + } else { + if (this->unk_21A > 0) { + this->unk_21A *= -0.8f; + } else { + this->unk_21A *= phi_f2; + } + } + + if ((ABS_ALT(this->unk_21A) < 0x38E) && + (((this->unk_218 & 0x3FFF) < 0x71C) || ((this->unk_218 & 0x3FFF) >= 0x38E4))) { + this->actor.gravity *= 0.8f; + this->unk_21C++; + if (this->unk_21C == 2) { + func_80B37998(this); + } + } else if (ABS_ALT(this->unk_21A) > 0x38E) { + if (this->unk_21A < 0) { + this->unk_21A = -0x38E; + } else { + this->unk_21A = 0x38E; + } + } +} + +void func_80B3828C(Vec3f* arg0, Vec3f* arg1, s16 arg2, s16 arg3, s32 arg4) { + Matrix_StatePush(); + Matrix_InsertRotation(arg2, arg3, arg4, MTXMODE_NEW); + Matrix_MultiplyVector3fByState(arg0, arg1); + Matrix_StatePop(); +} + +void func_80B382E4(GlobalContext* globalCtx, Vec3f arg1) { + Vec3f sp84 = arg1; + Vec3f sp78; + Vec3f sp6C; + Color_RGBA8 sp68 = { 170, 130, 90, 255 }; + Color_RGBA8 sp64 = { 100, 60, 20, 255 }; + s32 i; + + sp6C.y = 0.0f; + sp84.y += 15.0f; + + for (i = 0; i < 10; i++) { + sp78.x = Rand_Centered() * 10.0f; + sp78.y = 2.0f * Rand_ZeroOne(); + sp78.z = Rand_Centered() * 10.0f; + sp6C.x = -0.2f * sp78.x; + sp6C.z = -0.2f * sp78.z; + func_800B0EB0(globalCtx, &sp84, &sp78, &sp6C, &sp68, &sp64, 60, 20, 10); + } +} + +void EnMaruta_Update(Actor* thisx, GlobalContext* globalCtx) { + EnMaruta* this = THIS; + + this->actionFunc(this, globalCtx); + + func_80B37CA0(this, globalCtx); + func_80B37C60(this); +} + +void EnMaruta_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnMaruta* this = THIS; + Vec3f sp50; + s32 i; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + if (this->unk_210 == 0) { + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_maruta_DL_002EC0); + } else { + sp50 = D_80B387E4[this->unk_210]; + + Matrix_StatePush(); + Matrix_InsertTranslation(sp50.x, sp50.y, sp50.z, MTXMODE_APPLY); + Matrix_InsertRotationAroundUnitVector_s(this->unk_218, &this->unk_194, MTXMODE_APPLY); + Matrix_InsertTranslation(-sp50.x, -sp50.y, -sp50.z, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + for (i = 0; i < 8; i++) { + if (D_80B386C0[this->unk_210] & (1 << i)) { + gSPDisplayList(POLY_OPA_DISP++, D_80B386A0[i]); + } + } + + if (this->unk_1A0 != NULL) { + for (i = 0; i < ARRAY_COUNT(this->unk_1A4); i++) { + Matrix_MultiplyVector3fByState(&this->unk_1A0[i], &this->unk_1A4[i]); + } + Matrix_MultiplyVector3fByState(&sp50, &this->unk_204); + } + + Matrix_StatePop(); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Maruta/z_en_maruta.h b/src/overlays/actors/ovl_En_Maruta/z_en_maruta.h index 0fc546e4d0..162618fc6a 100644 --- a/src/overlays/actors/ovl_En_Maruta/z_en_maruta.h +++ b/src/overlays/actors/ovl_En_Maruta/z_en_maruta.h @@ -7,10 +7,23 @@ struct EnMaruta; typedef void (*EnMarutaActionFunc)(struct EnMaruta*, GlobalContext*); +#define ENMARUTA_GET_FF(thisx) ((thisx)->params & 0xFF) +#define ENMARUTA_GET_FF00(thisx) (((thisx)->params & 0xFF00) >> 8) + typedef struct EnMaruta { /* 0x0000 */ Actor actor; /* 0x0144 */ EnMarutaActionFunc actionFunc; - /* 0x0148 */ char unk_148[0xD8]; + /* 0x0148 */ ColliderCylinder collider; + /* 0x0194 */ Vec3f unk_194; + /* 0x01A0 */ Vec3f* unk_1A0; + /* 0x01A4 */ Vec3f unk_1A4[8]; + /* 0x0204 */ Vec3f unk_204; + /* 0x0210 */ s32 unk_210; + /* 0x0214 */ s32 unk_214; + /* 0x0218 */ s16 unk_218; + /* 0x021A */ s16 unk_21A; + /* 0x021C */ s16 unk_21C; + /* 0x021E */ s16 unk_21E; /* 0x0220 */ s16 unk_220; } EnMaruta; // size = 0x224 diff --git a/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c b/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c index 806ffe71a5..27192800ef 100644 --- a/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c +++ b/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c @@ -66,7 +66,7 @@ static TexturePtr D_808A4D74[] = { object_fr_Tex_005BA0, }; -// gSaveContext.weekEventReg[KEY] = VALUE +// gSaveContext.save.weekEventReg[KEY] = VALUE // KEY | VALUE static u16 isFrogReturnedFlags[] = { (0 << 8) | 0x00, // NULL @@ -114,7 +114,7 @@ void EnMinifrog_Init(Actor* thisx, GlobalContext* globalCtx) { if (1) {} if (!EN_MINIFROG_IS_RETURNED(this)) { if ((this->frogIndex == MINIFROG_YELLOW) || - ((gSaveContext.weekEventReg[isFrogReturnedFlags[this->frogIndex] >> 8] & + ((gSaveContext.save.weekEventReg[isFrogReturnedFlags[this->frogIndex] >> 8] & (u8)isFrogReturnedFlags[this->frogIndex]))) { Actor_MarkForDeath(&this->actor); } else { @@ -129,7 +129,7 @@ void EnMinifrog_Init(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc = EnMinifrog_SetupYellowFrogDialog; // Not spoken to MINIFROG_YELLOW - if (!(gSaveContext.weekEventReg[34] & 1)) { + if (!(gSaveContext.save.weekEventReg[34] & 1)) { this->actor.flags |= ACTOR_FLAG_10000; } @@ -140,7 +140,7 @@ void EnMinifrog_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.flags &= ~ACTOR_FLAG_1; // Frog has been returned - if ((gSaveContext.weekEventReg[isFrogReturnedFlags[this->frogIndex] >> 8] & + if ((gSaveContext.save.weekEventReg[isFrogReturnedFlags[this->frogIndex] >> 8] & (u8)isFrogReturnedFlags[this->frogIndex])) { this->actionFunc = EnMinifrog_SetupNextFrogInit; } else { @@ -259,26 +259,26 @@ void EnMinifrog_ReturnFrogCutscene(EnMinifrog* this, GlobalContext* globalCtx) { EnMinifrog_TurnToPlayer(this); EnMinifrog_Jump(this); - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { EnMinifrog_SetJumpState(this); - switch (globalCtx->msgCtx.unk11F04) { + switch (globalCtx->msgCtx.currentTextId) { case 0xD81: // "Ah! Don Gero! It has been so long." case 0xD83: // "Could it be... Has spring finally come to the mountains?" case 0xD84: // "That look...It is true! Winter was so long that I began to lose all hope." case 0xD86: // "Could it be... You came all this way looking for me?" case 0xD87: // "Ah! You need not say a thing. Upon seeing that face, I understand!" ... - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; - case 0xD82: // "What has brought you all this way?" - if (gSaveContext.weekEventReg[33] & 0x80) { // Mountain village is unfrozen + case 0xD82: // "What has brought you all this way?" + if (gSaveContext.save.weekEventReg[33] & 0x80) { // Mountain village is unfrozen func_80151938(globalCtx, 0xD83); // "Could it be... Has spring finally come to the mountains?" } else { func_80151938(globalCtx, 0xD86); // "Could it be... You came all this way looking for me?" } - flag = gSaveContext.weekEventReg[isFrogReturnedFlags[this->frogIndex] >> 8]; - gSaveContext.weekEventReg[isFrogReturnedFlags[this->frogIndex] >> 8] = + flag = gSaveContext.save.weekEventReg[isFrogReturnedFlags[this->frogIndex] >> 8]; + gSaveContext.save.weekEventReg[isFrogReturnedFlags[this->frogIndex] >> 8] = flag | (u8)isFrogReturnedFlags[this->frogIndex]; break; case 0xD85: // "I understand. I shall head for the mountains immediately." @@ -496,7 +496,7 @@ void EnMinifrog_YellowFrogDialog(EnMinifrog* this, GlobalContext* globalCtx) { EnMinifrog_Jump(this); switch (Message_GetState(&globalCtx->msgCtx)) { case 4: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: // Yes func_8019F208(); @@ -511,32 +511,32 @@ void EnMinifrog_YellowFrogDialog(EnMinifrog* this, GlobalContext* globalCtx) { } break; case 5: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { EnMinifrog_SetJumpState(this); - switch (globalCtx->msgCtx.unk11F04) { + switch (globalCtx->msgCtx.currentTextId) { case 0xD76: // "I have been waiting for you, Don Gero. Forgive me if I'm mistaken, but it looks like // you've lost a little weight..." - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); this->actor.flags &= ~ACTOR_FLAG_10000; - gSaveContext.weekEventReg[34] |= 1; // Spoken to MINIFROG_YELLOW + gSaveContext.save.weekEventReg[34] |= 1; // Spoken to MINIFROG_YELLOW break; case 0xD78: // "Unfortunately, it seems not all of our members have gathered." case 0xD79: // "Perhaps it is because winter was too long? They must not have realized that spring // has come to the mountains..." case 0xD7A: // "And when the great Don Gero has come for us, too...What a pity." case 0xD7F: // "Well, if it isn't the great Don Gero." - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0xD77: // "Let us begin our chorus" this->actionFunc = EnMinifrog_BeginChoirCutscene; globalCtx->msgCtx.unk11F10 = 0; break; case 0xD7C: // "The conducting was spectacular. And all of our members rose to the occasion!" - if (gSaveContext.weekEventReg[35] & 0x80) { // Obtained Heart Piece + if (gSaveContext.save.weekEventReg[35] & 0x80) { // Obtained Heart Piece func_80151938(globalCtx, 0xD7E); } else { func_80151938(globalCtx, 0xD7D); // Get Heart Piece - gSaveContext.weekEventReg[35] |= 0x80; + gSaveContext.save.weekEventReg[35] |= 0x80; } break; case 0xD7D: // "This is how deeply we were moved by your spectacular conducting..." @@ -564,7 +564,7 @@ void EnMinifrog_SetupYellowFrogDialog(EnMinifrog* this, GlobalContext* globalCtx EnMinifrog_JumpTimer(this); if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = EnMinifrog_YellowFrogDialog; - if (!(gSaveContext.weekEventReg[34] & 1)) { // Not spoken with MINIFROG_YELLOW + if (!(gSaveContext.save.weekEventReg[34] & 1)) { // Not spoken with MINIFROG_YELLOW Message_StartTextbox(globalCtx, 0xD76, &this->actor); // "I have been waiting for you, Don Gero. Forgive me if I'm mistaken, // but it looks like you've lost a little weight..." diff --git a/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c b/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c index ea43899175..4efc187144 100644 --- a/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c +++ b/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c @@ -506,7 +506,7 @@ void EnMinislime_SetupMoveToBigslime(EnMinislime* this) { } this->frozenAlpha = 0; - if CHECK_FLAG_ALL (this->actor.flags, ACTOR_FLAG_2000) { + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_2000)) { this->actor.flags &= ~ACTOR_FLAG_2000; } this->actionFunc = EnMinislime_MoveToBigslime; @@ -562,7 +562,7 @@ void EnMinislime_SetupDefeatIdle(EnMinislime* this) { } this->frozenAlpha = 0; - if CHECK_FLAG_ALL (this->actor.flags, ACTOR_FLAG_2000) { + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_2000)) { this->actor.flags &= ~ACTOR_FLAG_2000; } @@ -630,7 +630,7 @@ void EnMinislime_SetupMoveToGekko(EnMinislime* this) { this->actor.velocity.y = 0.0f; this->collider.base.acFlags &= ~AC_ON; this->collider.base.ocFlags1 &= ~OC1_ON; - if CHECK_FLAG_ALL (this->actor.flags, ACTOR_FLAG_2000) { + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_2000)) { this->actor.flags &= ~ACTOR_FLAG_2000; } @@ -720,7 +720,7 @@ void EnMinislime_Update(Actor* thisx, GlobalContext* globalCtx) { } else if ((this->actor.params == MINISLIME_FORM_BIGSLIME) && (this->actionFunc != EnMinislime_MoveToBigslime)) { EnMinislime_SetupMoveToBigslime(this); } else { - if CHECK_FLAG_ALL (this->actor.flags, ACTOR_FLAG_2000) { + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_2000)) { this->collider.base.acFlags &= ~AC_HIT; return; } diff --git a/src/overlays/actors/ovl_En_Mk/z_en_mk.c b/src/overlays/actors/ovl_En_Mk/z_en_mk.c index 1cc0cffcea..8c20b41066 100644 --- a/src/overlays/actors/ovl_En_Mk/z_en_mk.c +++ b/src/overlays/actors/ovl_En_Mk/z_en_mk.c @@ -15,6 +15,7 @@ void EnMk_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnMk_Update(Actor* thisx, GlobalContext* globalCtx); void EnMk_Draw(Actor* thisx, GlobalContext* globalCtx); +s32 func_80959524(GlobalContext* globalCtx); void func_809596A0(EnMk* this, GlobalContext* globalCtx); void func_80959774(EnMk* this, GlobalContext* globalCtx); void func_80959A24(EnMk* this, GlobalContext* globalCtx); @@ -22,7 +23,6 @@ void func_80959C94(EnMk* this, GlobalContext* globalCtx); void func_80959D28(EnMk* this, GlobalContext* globalCtx); void func_80959E18(EnMk* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Mk_InitVars = { ACTOR_EN_MK, ACTORCAT_NPC, @@ -35,49 +35,453 @@ const ActorInit En_Mk_InitVars = { (ActorFunc)EnMk_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_8095A260 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_ENEMY, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_ENEMY, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 30, 40, 0, { 0, 0, 0 } }, }; -#endif +s32 func_809592E0(EnMk* this, s16 index) { + AnimationHeader* sAnimations[] = { + &object_mk_Anim_001C38, &object_mk_Anim_000438, &object_mk_Anim_0007D8, + &object_mk_Anim_0010F4, &object_mk_Anim_001964, + }; -extern ColliderCylinderInit D_8095A260; + if (index == this->unk_27C) { + return false; + } -extern UNK_TYPE D_06001C38; + if ((index < 0) || (index >= 5)) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_809592E0.s") + Animation_PlayLoop(&this->skelAnime, sAnimations[index]); + this->unk_27C = index; + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/EnMk_Init.s") +void EnMk_Init(Actor* thisx, GlobalContext* globalCtx) { + EnMk* this = THIS; + s16 cs; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/EnMk_Destroy.s") + this->actor.terminalVelocity = -4.0f; + this->actor.gravity = -1.0f; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_mk_Skel_006CA0, &object_mk_Anim_001C38, this->jointTable, + this->morphTable, OBJECT_MK_LIMB_MAX); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_80959524.s") + this->unk_27C = -1; + func_809592E0(this, 0); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_8095954C.s") + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_80959624.s") + Actor_SetScale(&this->actor, 0.01f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_809596A0.s") + this->actionFunc = func_80959E18; + this->unk_27A = 0; + this->actor.targetMode = 6; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_80959774.s") + if (func_80959524(globalCtx) < 7) { + this->unk_27A |= 2; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_80959844.s") + cs = this->actor.cutscene; + for (i = 0; i < ARRAY_COUNT(this->unk_276); i++) { + this->unk_276[i] = cs; + if (cs != -1) { + this->actor.cutscene = cs; + cs = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_80959A24.s") + this->actor.cutscene = this->unk_276[0]; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_80959C94.s") +void EnMk_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnMk* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_80959D28.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_80959E18.s") +s32 func_80959524(GlobalContext* globalCtx) { + return gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 & 7; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/EnMk_Update.s") +void func_8095954C(EnMk* this, GlobalContext* globalCtx) { + if (Cutscene_CheckActorAction(globalCtx, 0x7F)) { + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, Cutscene_GetActorActionIndex(globalCtx, 0x7F)); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_8095A150.s") + switch (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 0x7F)]->action) { + case 1: + case 2: + case 3: + case 4: + case 5: + func_809592E0(this, + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 0x7F)]->action - 1); + break; + } + } else { + func_809592E0(this, 0); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_8095A198.s") +void func_80959624(EnMk* this, GlobalContext* globalCtx) { + u16 textId; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/EnMk_Draw.s") + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { + if (this->unk_27A & 4) { + textId = 0xFB9; + } else if (gSaveContext.save.weekEventReg[55] & 0x80) { + textId = 0xFBC; + } else { + textId = 0xFBB; + } + } else { + textId = 0xFBA; + } + Message_StartTextbox(globalCtx, textId, &this->actor); +} + +void func_809596A0(EnMk* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + + if ((globalCtx->msgCtx.currentTextId == 0xFB9) || (globalCtx->msgCtx.currentTextId == 0xFBB) || + (globalCtx->msgCtx.currentTextId == 0xFBC)) { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 0x400, 0x80); + this->actor.world.rot.y = this->actor.shape.rot.y; + } + + switch (Message_GetState(&globalCtx->msgCtx)) { + case 5: + if (Message_ShouldAdvance(globalCtx)) { + func_801477B4(globalCtx); + this->actionFunc = func_80959774; + } + break; + + case 2: + this->actionFunc = func_80959774; + break; + } +} + +void func_80959774(EnMk* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 3, 0x400, 0x80); + this->actor.world.rot.y = this->actor.shape.rot.y; + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + func_80959624(this, globalCtx); + this->actionFunc = func_809596A0; + } else if ((this->actor.xzDistToPlayer < 120.0f) && Player_IsFacingActor(&this->actor, 0x3000, globalCtx)) { + func_800B8614(&this->actor, globalCtx, 130.0f); + } + + func_8095954C(this, globalCtx); +} + +void func_80959844(EnMk* this, GlobalContext* globalCtx) { + u16 textId; + + if ((this->unk_27A & 2) && (func_80959524(globalCtx) >= 7)) { + textId = 0xFB3; + } else if (gSaveContext.save.weekEventReg[20] & 0x40) { + textId = 0xFB9; + } else if (gSaveContext.save.weekEventReg[19] & 0x40) { + textId = 0xFB5; + } else if (func_80959524(globalCtx) >= 7) { + textId = 0xFB3; + } else { + switch (gSaveContext.save.playerForm) { + case PLAYER_FORM_DEKU: + if (gSaveContext.save.weekEventReg[19] & 0x10) { + if (gSaveContext.save.weekEventReg[55] & 0x80) { + textId = 0xFAF; + } else { + textId = 0xFAE; + } + } else { + textId = 0xFAC; + } + break; + + case PLAYER_FORM_GORON: + if (gSaveContext.save.weekEventReg[19] & 8) { + if (gSaveContext.save.weekEventReg[55] & 0x80) { + textId = 0xFAB; + } else { + textId = 0xFAA; + } + } else { + textId = 0xFA8; + } + break; + + case PLAYER_FORM_FIERCE_DEITY: + case PLAYER_FORM_HUMAN: + if (func_80959524(globalCtx) > 0) { + textId = 0xFA7; + } else if (gSaveContext.save.weekEventReg[19] & 4) { + if (gSaveContext.save.weekEventReg[55] & 0x80) { + textId = 0xFBF; + } else { + textId = 0xFA6; + } + } else { + textId = 0xFA0; + } + break; + + default: + if (func_80959524(globalCtx) > 0) { + textId = 0xFB0; + } else if (gSaveContext.save.weekEventReg[19] & 0x20) { + textId = 0xFB2; + } else { + textId = 0xFB1; + } + break; + } + } + Message_StartTextbox(globalCtx, textId, &this->actor); +} + +void func_80959A24(EnMk* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + this->unk_27A |= 1; + + switch (Message_GetState(&globalCtx->msgCtx)) { + case 2: + break; + + case 5: + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { + case 0xFA1: + case 0xFA3: + case 0xFA4: + case 0xFAA: + case 0xFAE: + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + break; + + case 0xFA2: + if (gSaveContext.save.weekEventReg[55] & 0x80) { + func_801477B4(globalCtx); + this->actionFunc = func_80959E18; + break; + } + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + break; + + case 0xFA5: + case 0xFA6: + case 0xFA7: + case 0xFA9: + case 0xFAB: + case 0xFAD: + case 0xFAF: + case 0xFB0: + case 0xFB2: + case 0xFBD: + case 0xFBE: + case 0xFBF: + func_801477B4(globalCtx); + this->actionFunc = func_80959E18; + break; + + case 0xFA0: + gSaveContext.save.weekEventReg[19] |= 4; + func_80151938(globalCtx, 0xFA1); + break; + + case 0xFA8: + gSaveContext.save.weekEventReg[19] |= 8; + if (gSaveContext.save.weekEventReg[55] & 0x80) { + func_80151938(globalCtx, 0xFBD); + break; + } + func_80151938(globalCtx, 0xFA9); + break; + + case 0xFAC: + gSaveContext.save.weekEventReg[19] |= 0x10; + if (gSaveContext.save.weekEventReg[55] & 0x80) { + func_80151938(globalCtx, 0xFBE); + break; + } + func_80151938(globalCtx, 0xFAD); + break; + + case 0xFB1: + gSaveContext.save.weekEventReg[19] |= 0x20; + func_801477B4(globalCtx); + this->actionFunc = func_80959E18; + break; + + case 0xFB3: + case 0xFB4: + func_801477B4(globalCtx); + this->actionFunc = func_80959E18; + this->actor.flags &= ~ACTOR_FLAG_10000; + break; + + case 0xFB5: + func_801477B4(globalCtx); + this->actionFunc = func_80959E18; + break; + + default: + func_801477B4(globalCtx); + this->actionFunc = func_80959E18; + break; + } + } + break; + } +} + +void func_80959C94(EnMk* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = func_80959A24; + this->unk_27A &= ~2; + Message_StartTextbox(globalCtx, 0xFB3, &this->actor); + } else { + this->actor.flags |= ACTOR_FLAG_10000; + func_800B8500(&this->actor, globalCtx, 350.0f, 1000.0f, -1); + } +} + +void func_80959D28(EnMk* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + + if ((globalCtx->csCtx.state == 0) && (this->actor.cutscene == -1)) { + if (gSaveContext.save.weekEventReg[20] & 0x40) { + this->unk_27A &= ~1; + this->actionFunc = func_80959774; + this->actor.home.rot.y += 0x4E20; + this->unk_27A |= 4; + } else { + this->actionFunc = func_80959E18; + } + this->actor.cutscene = this->unk_276[0]; + } else { + if (this->actor.cutscene != -1) { + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + this->actor.cutscene = -1; + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } + } + func_8095954C(this, globalCtx); + } +} + +void func_80959E18(EnMk* this, GlobalContext* globalCtx) { + s32 pad; + s16 sp22 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; + + SkelAnime_Update(&this->skelAnime); + + if (gSaveContext.save.weekEventReg[20] & 0x40) { + this->unk_27A &= ~1; + this->actionFunc = func_80959774; + this->actor.home.rot.y += 0x4E20; + return; + } + + if (func_800B8718(&this->actor, &globalCtx->state)) { + globalCtx->msgCtx.ocarinaMode = 4; + this->actionFunc = func_80959D28; + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { + this->actor.cutscene = this->unk_276[0]; + gSaveContext.save.weekEventReg[20] |= 0x40; + Item_Give(globalCtx, ITEM_SONG_NOVA); + } else { + this->actor.cutscene = this->unk_276[1]; + } + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } else if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + func_80959844(this, globalCtx); + this->actionFunc = func_80959A24; + this->unk_27A |= 1; + } else if ((this->unk_27A & 2) && (func_80959524(globalCtx) >= 7)) { + this->actionFunc = func_80959C94; + } else if ((this->actor.xzDistToPlayer < 120.0f) && (ABS_ALT(sp22) <= 0x4300)) { + this->unk_27A |= 1; + func_800B8614(&this->actor, globalCtx, 200.0f); + if (!(gSaveContext.save.weekEventReg[20] & 0x40) && (gSaveContext.save.weekEventReg[19] & 0x40)) { + func_800B874C(&this->actor, globalCtx, 200.0f, 100.0f); + } + } else { + this->unk_27A &= ~1; + } + func_8095954C(this, globalCtx); +} + +void EnMk_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnMk* this = THIS; + Vec3s sp38; + + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + + this->actionFunc(this, globalCtx); + + if ((this->unk_27A & 1) && !Cutscene_CheckActorAction(globalCtx, 0x7F)) { + func_800E9250(globalCtx, &this->actor, &this->unk_270, &sp38, this->actor.focus.pos); + } else { + Math_SmoothStepToS(&this->unk_270.x, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->unk_270.y, 0, 6, 0x1838, 0x64); + } +} + +s32 EnMk_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnMk* this = THIS; + + if (limbIndex == OBJECT_MK_LIMB_0B) { + rot->y -= this->unk_270.y; + rot->z += this->unk_270.x; + } + return false; +} + +Vec3f D_8095A2A0 = { 1000.0f, -100.0f, 0.0f }; + +void EnMk_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnMk* this = THIS; + + if (limbIndex == OBJECT_MK_LIMB_0B) { + Matrix_MultiplyVector3fByState(&D_8095A2A0, &this->actor.focus.pos); + } +} + +void EnMk_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnMk* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnMk_OverrideLimbDraw, EnMk_PostLimbDraw, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Mk/z_en_mk.h b/src/overlays/actors/ovl_En_Mk/z_en_mk.h index 715a07c84d..fee132ccd4 100644 --- a/src/overlays/actors/ovl_En_Mk/z_en_mk.h +++ b/src/overlays/actors/ovl_En_Mk/z_en_mk.h @@ -2,6 +2,7 @@ #define Z_EN_MK_H #include "global.h" +#include "objects/object_mk/object_mk.h" struct EnMk; @@ -9,7 +10,14 @@ typedef void (*EnMkActionFunc)(struct EnMk*, GlobalContext*); typedef struct EnMk { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x13C]; + /* 0x0144 */ ColliderCylinder collider; + /* 0x0190 */ SkelAnime skelAnime; + /* 0x01D4 */ Vec3s jointTable[OBJECT_MK_LIMB_MAX]; + /* 0x0222 */ Vec3s morphTable[OBJECT_MK_LIMB_MAX]; + /* 0x0270 */ Vec3s unk_270; + /* 0x0276 */ s16 unk_276[2]; + /* 0x027A */ u16 unk_27A; + /* 0x027C */ s16 unk_27C; /* 0x0280 */ EnMkActionFunc actionFunc; } EnMk; // size = 0x284 diff --git a/src/overlays/actors/ovl_En_Mm/z_en_mm.c b/src/overlays/actors/ovl_En_Mm/z_en_mm.c index dfb69be0f5..5f79cf9e4d 100644 --- a/src/overlays/actors/ovl_En_Mm/z_en_mm.c +++ b/src/overlays/actors/ovl_En_Mm/z_en_mm.c @@ -74,8 +74,8 @@ void EnMm_Init(Actor* thisx, GlobalContext* globalCtx) { EnMm* this = THIS; EnMmActionFunc action; - if ((this->actor.params >= 0) && ((!(gSaveContext.weekEventReg[37] & 0x10)) || - (gSaveContext.weekEventReg[37] & 8) || (gSaveContext.unk_1014 != 0))) { + if ((this->actor.params >= 0) && ((!(gSaveContext.save.weekEventReg[37] & 0x10)) || + (gSaveContext.save.weekEventReg[37] & 8) || (gSaveContext.unk_1014 != 0))) { Actor_MarkForDeath(&this->actor); return; } diff --git a/src/overlays/actors/ovl_En_Mm2/z_en_mm2.c b/src/overlays/actors/ovl_En_Mm2/z_en_mm2.c index 718f384f32..79b4987e9a 100644 --- a/src/overlays/actors/ovl_En_Mm2/z_en_mm2.c +++ b/src/overlays/actors/ovl_En_Mm2/z_en_mm2.c @@ -49,7 +49,7 @@ void EnMm2_Reading(EnMm2* this, GlobalContext* globalCtx) { u8 talkState = Message_GetState(&globalCtx->msgCtx); if (talkState != 2) { - if (talkState == 5 && func_80147624(globalCtx)) { + if (talkState == 5 && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); this->actionFunc = EnMm2_WaitForRead; } diff --git a/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c b/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c index fd676186ef..396a3f0406 100644 --- a/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c +++ b/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c @@ -102,7 +102,7 @@ void EnMm3_Init(Actor* thisx, GlobalContext* globalCtx) { void EnMm3_Destroy(Actor* thisx, GlobalContext* globalCtx) { EnMm3* this = THIS; - gSaveContext.weekEventReg[63] &= (u8)~1; + gSaveContext.save.weekEventReg[63] &= (u8)~1; Collider_DestroyCylinder(globalCtx, &this->collider); } @@ -139,12 +139,12 @@ void func_80A6F2C8(EnMm3* this, GlobalContext* globalCtx) { } void func_80A6F3B4(EnMm3* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->unk_2B4) { case 0x278E: if (globalCtx->msgCtx.choiceIndex == 0) { if (this->unk_2B2 & 0x20) { - if (gSaveContext.rupees >= globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees >= globalCtx->msgCtx.unk1206C) { func_8019F208(); Message_StartTextbox(globalCtx, 0x2790, &this->actor); this->unk_2B4 = 0x2790; @@ -170,7 +170,7 @@ void func_80A6F3B4(EnMm3* this, GlobalContext* globalCtx) { case 0x279A: if (globalCtx->msgCtx.choiceIndex == 0) { - if (gSaveContext.rupees >= globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees >= globalCtx->msgCtx.unk1206C) { func_8019F208(); Message_StartTextbox(globalCtx, 0x2790, &this->actor); this->unk_2B4 = 0x2790; @@ -193,7 +193,7 @@ void func_80A6F3B4(EnMm3* this, GlobalContext* globalCtx) { } void func_80A6F5E4(EnMm3* this, GlobalContext* globalCtx) { - if (((this->unk_2B4 != 0x2791) || (this->unk_2AC == 0)) && func_80147624(globalCtx)) { + if (((this->unk_2B4 != 0x2791) || (this->unk_2AC == 0)) && Message_ShouldAdvance(globalCtx)) { switch (this->unk_2B4) { case 0x278A: if (func_80A6FFAC(this, globalCtx)) { @@ -274,7 +274,7 @@ void func_80A6F5E4(EnMm3* this, GlobalContext* globalCtx) { case 0x2795: case 0x2796: case 0x2797: - if (gSaveContext.weekEventReg[63] & 2) { + if (gSaveContext.save.weekEventReg[63] & 2) { Message_StartTextbox(globalCtx, 0x279B, &this->actor); this->unk_2B4 = 0x279B; func_80151BB4(globalCtx, 0xB); @@ -332,7 +332,7 @@ void func_80A6F9DC(EnMm3* this, GlobalContext* globalCtx) { break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (this->unk_2B4 == 0x2790) { Player* player = GET_PLAYER(globalCtx); @@ -346,8 +346,8 @@ void func_80A6F9DC(EnMm3* this, GlobalContext* globalCtx) { play_sound(NA_SE_SY_START_SHOT); func_80A6FBA0(this); } else { - gSaveContext.weekEventReg[63] &= (u8)~1; - gSaveContext.weekEventReg[63] &= (u8)~2; + gSaveContext.save.weekEventReg[63] &= (u8)~1; + gSaveContext.save.weekEventReg[63] &= (u8)~2; func_80A6F270(this); } } @@ -368,8 +368,8 @@ void func_80A6F9DC(EnMm3* this, GlobalContext* globalCtx) { void func_80A6FBA0(EnMm3* this) { func_801A5BD0(0x6F); func_801A0238(0, 5); - gSaveContext.weekEventReg[63] |= 1; - gSaveContext.weekEventReg[63] &= (u8)~2; + gSaveContext.save.weekEventReg[63] |= 1; + gSaveContext.save.weekEventReg[63] &= (u8)~2; this->actionFunc = func_80A6FBFC; } @@ -424,12 +424,12 @@ void func_80A6FE1C(EnMm3* this) { void func_80A6FE30(EnMm3* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { - if (!(gSaveContext.weekEventReg[77] & 1)) { - gSaveContext.weekEventReg[77] |= 1; + if (!(gSaveContext.save.weekEventReg[77] & 1)) { + gSaveContext.save.weekEventReg[77] |= 1; } this->actor.parent = NULL; func_80A6FED8(this); - } else if (gSaveContext.weekEventReg[77] & 1) { + } else if (gSaveContext.save.weekEventReg[77] & 1) { Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_PURPLE, 500.0f, 100.0f); } else { Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 500.0f, 100.0f); @@ -457,7 +457,7 @@ void func_80A6FEEC(EnMm3* this, GlobalContext* globalCtx) { } s32 func_80A6FFAC(EnMm3* this, GlobalContext* globalCtx) { - switch (gSaveContext.playerForm) { + switch (gSaveContext.save.playerForm) { case 4: if (Player_GetMask(globalCtx) == PLAYER_MASK_BUNNY) { if (this->unk_2B2 & 0x10) { @@ -491,7 +491,7 @@ s32 func_80A6FFAC(EnMm3* this, GlobalContext* globalCtx) { } void func_80A70084(EnMm3* this, GlobalContext* globalCtx) { - switch (gSaveContext.playerForm) { + switch (gSaveContext.save.playerForm) { case 4: if (Player_GetMask(globalCtx) == PLAYER_MASK_BUNNY) { this->unk_2B2 |= 0x10; diff --git a/src/overlays/actors/ovl_En_Ms/z_en_ms.c b/src/overlays/actors/ovl_En_Ms/z_en_ms.c index 59aa5a22bc..729e36d496 100644 --- a/src/overlays/actors/ovl_En_Ms/z_en_ms.c +++ b/src/overlays/actors/ovl_En_Ms/z_en_ms.c @@ -83,7 +83,7 @@ void EnMs_Destroy(Actor* thisx, GlobalContext* globalCtx) { void EnMs_Wait(EnMs* this, GlobalContext* globalCtx) { s16 yawDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - if (gSaveContext.inventory.items[SLOT_MAGIC_BEANS] == ITEM_NONE) { + if (gSaveContext.save.inventory.items[SLOT_MAGIC_BEANS] == ITEM_NONE) { this->actor.textId = 0x92E; // "[...] You're the first customer [...]" } else { this->actor.textId = 0x932; // "[...] So you liked my Magic Beans [...]" @@ -99,13 +99,13 @@ void EnMs_Wait(EnMs* this, GlobalContext* globalCtx) { void EnMs_Talk(EnMs* this, GlobalContext* globalCtx) { switch (Message_GetState(&globalCtx->msgCtx)) { case 6: - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx) != 0) { this->actionFunc = EnMs_Wait; } break; case 5: - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx) != 0) { func_801477B4(globalCtx); Actor_PickUp(&this->actor, globalCtx, GI_MAGIC_BEANS, this->actor.xzDistToPlayer, this->actor.playerHeightRel); @@ -114,11 +114,11 @@ void EnMs_Talk(EnMs* this, GlobalContext* globalCtx) { break; case 4: - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx) != 0) { switch (globalCtx->msgCtx.choiceIndex) { case 0: // yes func_801477B4(globalCtx); - if (gSaveContext.rupees < 10) { + if (gSaveContext.save.playerData.rupees < 10) { play_sound(NA_SE_SY_ERROR); func_80151938(globalCtx, 0x935); // "[...] You don't have enough Rupees." } else if (AMMO(ITEM_MAGIC_BEANS) >= 20) { diff --git a/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.c b/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.c index d74f329265..6952f10c21 100644 --- a/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.c +++ b/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.c @@ -14,15 +14,20 @@ void EnMttag_Init(Actor* thisx, GlobalContext* globalCtx); void EnMttag_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnMttag_Update(Actor* thisx, GlobalContext* globalCtx); -void func_809CF9A0(EnMttag* this, GlobalContext* globalCtx); -void func_809CFA00(EnMttag* this, GlobalContext* globalCtx); -void func_809CFA54(EnMttag* this, GlobalContext* globalCtx); -void func_809CFC38(EnMttag* this, GlobalContext* globalCtx); -void func_809CFD98(EnMttag* this, GlobalContext* globalCtx); -void func_809CFE28(EnMttag* this, GlobalContext* globalCtx); -void func_809CFF94(EnMttag* this, GlobalContext* globalCtx); +void EnMttag_ShowIntroCutscene(EnMttag* this, GlobalContext* globalCtx); +void EnMttag_WaitForIntroCutsceneToEnd(EnMttag* this, GlobalContext* globalCtx); +void EnMttag_RaceStart(EnMttag* this, GlobalContext* globalCtx); +void EnMttag_Race(EnMttag* this, GlobalContext* globalCtx); +void EnMttag_RaceFinish(EnMttag* this, GlobalContext* globalCtx); +void EnMttag_PotentiallyRestartRace(EnMttag* this, GlobalContext* globalCtx); +void EnMttag_HandleCantWinChoice(EnMttag* this, GlobalContext* globalCtx); + +typedef enum { + GORON_RACE_CHEAT_NO_CHEATING, + GORON_RACE_CHEAT_FALSE_START, + GORON_RACE_CHEAT_TRYING_TO_REACH_GOAL_FROM_BEHIND, +} PlayerCheatStatus; -#if 0 const ActorInit En_Mt_tag_InitVars = { ACTOR_EN_MT_TAG, ACTORCAT_BG, @@ -35,42 +40,475 @@ const ActorInit En_Mt_tag_InitVars = { (ActorFunc)NULL, }; -#endif +static s32 sStartingCheckpointPerSceneExitIndex[] = { + 0, 0, 0, 0, 1, 9, 12, 16, 19, 22, 26, 29, 30, 32, 34, 36, 39, 42, 45, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CF350.s") +// The Y-positions here are never used by any part of this actor. +static Vec3f sCheckpointPositions[] = { + { -105.0f, 1000.0f, -240.0f }, { -1751.0f, 1000.0f, -240.0f }, { -3138.0f, 1000.0f, -74.0f }, + { -4617.0f, 1000.0f, 277.0f }, { -5060.0f, 1000.0f, 388.0f }, { -5412.0f, 1000.0f, 573.0f }, + { -5523.0f, 1000.0f, 1035.0f }, { -5393.0f, 1000.0f, 1405.0f }, { -5060.0f, 1000.0f, 1553.0f }, + { -3933.0f, 1000.0f, 1479.0f }, { -3212.0f, 1000.0f, 1461.0f }, { -2805.0f, 1000.0f, 1645.0f }, + { -2638.0f, 1000.0f, 2071.0f }, { -2823.0f, 1000.0f, 2422.0f }, { -3212.0f, 1000.0f, 2607.0f }, + { -3785.0f, 1000.0f, 2977.0f }, { -4321.0f, 1000.0f, 3501.0f }, { -4654.0f, 1000.0f, 4185.0f }, + { -4802.0f, 1000.0f, 4779.0f }, { -4672.0f, 1000.0f, 5426.0f }, { -4339.0f, 1000.0f, 6037.0f }, + { -3748.0f, 1000.0f, 6314.0f }, { -2749.0f, 1000.0f, 6478.0f }, { -2453.0f, 1000.0f, 6922.0f }, + { -2269.0f, 1000.0f, 7754.0f }, { -2453.0f, 1000.0f, 8309.0f }, { -3008.0f, 1000.0f, 8438.0f }, + { -3304.0f, 1000.0f, 8179.0f }, { -3600.0f, 1000.0f, 7606.0f }, { -3600.0f, 1000.0f, 6885.0f }, + { -3618.0f, 1000.0f, 4392.0f }, { -3600.0f, 1000.0f, 3855.0f }, { -3396.0f, 1000.0f, 3189.0f }, + { -3396.0f, 1000.0f, 2283.0f }, { -3600.0f, 1000.0f, 818.0f }, { -3803.0f, 1000.0f, -88.0f }, + { -4543.0f, 1000.0f, -2457.0f }, { -4543.0f, 1000.0f, -2938.0f }, { -4543.0f, 1000.0f, -3530.0f }, + { -4284.0f, 1000.0f, -4333.0f }, { -3581.0f, 1000.0f, -4795.0f }, { -2805.0f, 1000.0f, -4850.0f }, + { -1825.0f, 1000.0f, -4703.0f }, { -1326.0f, 1000.0f, -4166.0f }, { -1122.0f, 1000.0f, -3186.0f }, + { -1085.0f, 1000.0f, -2059.0f }, { -1067.0f, 1000.0f, -912.0f }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CF394.s") +/** + * Returns true if the specified position is in the finish line. + * The range extends a little bit beyond the finish line's in-game visual. + */ +s32 EnMttag_IsInFinishLine(Vec3f* pos) { + return Math3D_XZBoundCheck(-1261.0f, -901.0f, -1600.0f, -1520.0f, pos->x, pos->z); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CF444.s") +/** + * Returns a value in PlayerCheatStatus that indicates if the player is cheating + * and, if so, what kind of cheating the player is performing. + */ +s32 EnMttag_CheckPlayerCheatStatus(Vec3f* pos) { + if (!(gSaveContext.eventInf[1] & 1)) { + if (Math3D_XZBoundCheck(-466.0f, -386.0f, -687.0f, 193.0f, pos->x, pos->z)) { + // The race hasn't started yet, but the player is beyond the starting line. + return GORON_RACE_CHEAT_FALSE_START; + } + } else if (Math3D_XZBoundCheck(-1127.0f, -1007.0f, -867.0f, -787.0f, pos->x, pos->z)) { + // The goal is actually quite close to the start, just behind a large wall. + // This checks if the player is in an area "behind" the goal that is not accessible + // in normal play; it can only be reached by climbing the wall somehow. Perhaps they + // were worried that players would find a way to climb the wall with a glitch, or + // perhaps they just wanted to punish people using cheat codes. + return GORON_RACE_CHEAT_TRYING_TO_REACH_GOAL_FROM_BEHIND; + } + return GORON_RACE_CHEAT_NO_CHEATING; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CF4EC.s") +/** + * This function tries to find all four Race Gorons present in the racetrack. + * If it finds them, it stores a pointer to each one in the actor's struct. + * Returns true if all four Race Gorons are found. + */ +s32 EnMttag_AreFourRaceGoronsPresent(EnMttag* this, GlobalContext* globalCtx) { + Actor* actor = NULL; + s32 i = 0; + s32 areGoronsPresent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CF67C.s") + do { + actor = SubS_FindActor(globalCtx, actor, ACTORCAT_NPC, ACTOR_EN_RG); + if (actor != NULL) { + this->raceGorons[i] = (EnRg*)actor; + i++; + } else if ((actor == NULL) || (actor->next == NULL)) { + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CF848.s") + actor = actor->next; + } while (i < ARRAY_COUNT(this->raceGorons)); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CF8EC.s") + if (i < ARRAY_COUNT(this->raceGorons)) { + areGoronsPresent = false; + } else { + areGoronsPresent = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CF950.s") + return areGoronsPresent; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CF9A0.s") +/** + * Returns the checkpoint number for the supplied actor. + * At the start of the race, all race entrants are at checkpoint 1, and their + * checkpoint number gradually increases as they move forward through the racetrack. + * The player can have a checkpoint number of -1 if they move far enough backwards + * from the starting line. + */ +s32 EnMttag_GetCurrentCheckpoint(Actor* actor, GlobalContext* globalCtx, s32* upcomingCheckpoint, + f32* outPerpendicularPointX, f32* outPerpendicularPointZ) { + s32 curentCheckpoint = -1; + s32 hasSetCurrentCheckpointOnce = false; + f32 minLineLengthSq = 0.0f; + s32 sceneExitIndex; + f32 perpendicularPointX; + f32 perpendicularPointZ; + f32 lineLenSq; + s32 checkpointIterator; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CFA00.s") + // The Goron Racetrack is configured such that the sceneExitIndex for any given floor polygon + // gradually increases as you move forward through the racetrack. + sceneExitIndex = SurfaceType_GetSceneExitIndex(&globalCtx->colCtx, actor->floorPoly, actor->floorBgId); + if ((sceneExitIndex < 4) || (sceneExitIndex >= 19)) { + //! @bug - upcomingCheckpoint is not initialized here + return -1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CFA54.s") + checkpointIterator = sStartingCheckpointPerSceneExitIndex[sceneExitIndex]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CFBC4.s") + // Iterates through all possible checkpoints that are associated with this sceneExitIndex. + do { + if ((Math3D_PointDistToLine2D( + actor->world.pos.x, actor->world.pos.z, (&sCheckpointPositions[checkpointIterator])[-1].x, + (&sCheckpointPositions[checkpointIterator])[-1].z, (&sCheckpointPositions[checkpointIterator])[1].x, + (&sCheckpointPositions[checkpointIterator])[1].z, &perpendicularPointX, &perpendicularPointZ, + &lineLenSq)) && + (!hasSetCurrentCheckpointOnce || ((curentCheckpoint + 1) == checkpointIterator) || + (lineLenSq < minLineLengthSq))) { + minLineLengthSq = lineLenSq; + curentCheckpoint = checkpointIterator; + *outPerpendicularPointX = perpendicularPointX; + *outPerpendicularPointZ = perpendicularPointZ; + hasSetCurrentCheckpointOnce = true; + } + checkpointIterator++; + } while (checkpointIterator < sStartingCheckpointPerSceneExitIndex[sceneExitIndex + 1]); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CFC38.s") + *upcomingCheckpoint = curentCheckpoint + 1; + return curentCheckpoint; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CFD98.s") +/** + * Returns true if the player is almost certainly going to lose the race. + * Specifically, it checks if the player's current checkpoint is 24 or more + * checkpoints behind the leading racer. This value was probably chosen because + * falling off the wooden bridge in the middle of the track can set the player + * back up to 23 checkpoints. + * + * This function also has the side effect of updating the number of checkpoints + * ahead of the player each Race Goron is. + */ +s32 EnMttag_UpdateCheckpoints(EnMttag* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + EnRg* rg; + s32 currentCheckpoints[5]; + s32 upcomingCheckpoints[5]; + f32 perpendicularPointsX[5]; + f32 perpendicularPointsZ[5]; + s32 highestCurrentCheckpoint; + s32 i; + s32 playerIsLikelyToLose = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CFE28.s") + highestCurrentCheckpoint = -1; + currentCheckpoints[0] = EnMttag_GetCurrentCheckpoint(&player->actor, globalCtx, &upcomingCheckpoints[0], + &perpendicularPointsX[0], &perpendicularPointsZ[0]); + for (i = 1; i < ARRAY_COUNT(this->raceGorons) + 1; i++) { + currentCheckpoints[i] = + EnMttag_GetCurrentCheckpoint(&this->raceGorons[i - 1]->actor, globalCtx, &upcomingCheckpoints[i], + &perpendicularPointsX[i], &perpendicularPointsZ[i]); + if (highestCurrentCheckpoint < currentCheckpoints[i]) { + highestCurrentCheckpoint = currentCheckpoints[i]; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CFF94.s") + for (i = 1; i < ARRAY_COUNT(this->raceGorons) + 1; i++) { + rg = this->raceGorons[i - 1]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/EnMttag_Init.s") + // Because of the bug described in EnMttag_GetCurrentCheckpoint, these values may not be initialized. + //! @bug When initialized, this check is pointless because upcomingCheckpoint is always 0 or higher. + if ((upcomingCheckpoints[i] != -1) && (upcomingCheckpoints[0] != -1)) { + rg->numCheckpointsAheadOfPlayer = (upcomingCheckpoints[i] - upcomingCheckpoints[0]); + } else { + rg->numCheckpointsAheadOfPlayer = 0; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/EnMttag_Destroy.s") + if ((currentCheckpoints[0] > 0) && (currentCheckpoints[0] < highestCurrentCheckpoint) && + (player->actor.bgCheckFlags & 1) && ((highestCurrentCheckpoint - currentCheckpoints[0]) >= 24)) { + playerIsLikelyToLose = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/EnMttag_Update.s") + return playerIsLikelyToLose; +} + +/** + * Exits the race and returns the player back to "normal" gameplay. + * Whether the player won or lost the race is determined by arg1 and nextTransition. + */ +s32 EnMttag_ExitRace(GlobalContext* globalCtx, s32 arg1, s32 nextTransition) { + CUR_FORM_EQUIP(EQUIP_SLOT_B) = ITEM_SWORD_KOKIRI; + globalCtx->nextEntranceIndex = 0xD020; + if ((gSaveContext.save.weekEventReg[33] & 0x80)) { + // Spring + gSaveContext.nextCutsceneIndex = 0xFFF0; + } else { + // Winter + gSaveContext.nextCutsceneIndex = 0; + } + + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = arg1; + gSaveContext.nextTransition = nextTransition; + func_801477B4(globalCtx); + return 1; +} + +/** + * Displays the text which says that the player has made a false start. + */ +void EnMttag_ShowFalseStartMessage(EnMttag* this, GlobalContext* globalCtx) { + gSaveContext.unk_3DD0[4] = 0; + Message_StartTextbox(globalCtx, 0xE95, NULL); // An entrant made a false start + func_800B7298(globalCtx, &this->actor, 7); + Audio_QueueSeqCmd(0x101400FF); + this->actionFunc = EnMttag_PotentiallyRestartRace; +} + +/** + * Displays the text from the Goron Elder's child which tells the player that + * they probably can't win the race. + */ +void EnMttag_ShowCantWinMessage(EnMttag* this, GlobalContext* globalCtx) { + Message_StartTextbox(globalCtx, 0xE97, NULL); // You can't win now... + func_800B7298(globalCtx, &this->actor, 7); + this->actionFunc = EnMttag_HandleCantWinChoice; +} + +/** + * Shows the cutscene that pans over the race track and shows all five race entrants. + */ +void EnMttag_ShowIntroCutscene(EnMttag* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + this->actionFunc = EnMttag_WaitForIntroCutsceneToEnd; + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } +} + +/** + * When the intro cutscene concludes, this sets the weekEventReg to prevent it + * from showing again and starts the race. + */ +void EnMttag_WaitForIntroCutsceneToEnd(EnMttag* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCurrentIndex() != this->actor.cutscene) { + gSaveContext.save.weekEventReg[12] |= 2; + this->actionFunc = EnMttag_RaceStart; + } +} + +/** + * Handles the race from when the Gorons are first lined up at the + * starting block to when the countdown finishes. + */ +void EnMttag_RaceStart(EnMttag* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 playerCheatStatus; + + if (this->raceInitialized == true) { + playerCheatStatus = EnMttag_CheckPlayerCheatStatus(&player->actor.world.pos); + if (playerCheatStatus != GORON_RACE_CHEAT_NO_CHEATING) { + if (playerCheatStatus == GORON_RACE_CHEAT_FALSE_START) { + this->shouldRestartRace = true; + } else { + this->shouldRestartRace = false; + } + + EnMttag_ShowFalseStartMessage(this, globalCtx); + gSaveContext.eventInf[1] |= 8; + } else { + if (DECR(this->timer) == 60) { + func_8010E9F0(4, 0); + globalCtx->interfaceCtx.unk_280 = 1; + Audio_QueueSeqCmd(NA_BGM_GORON_RACE | 0x8000); + globalCtx->envCtx.unk_E4 = 0xFE; + player->stateFlags1 &= ~0x20; + } else if ((this->timer < 60) && (globalCtx->interfaceCtx.unk_280 == 8)) { + this->timer = 0; + gSaveContext.eventInf[1] |= 1; + this->actionFunc = EnMttag_Race; + } + } + } else { + if (EnMttag_AreFourRaceGoronsPresent(this, globalCtx)) { + this->raceInitialized = true; + } + } +} + +/** + * Returns true if any Race Goron is over the finish line. + */ +s32 EnMttag_IsAnyRaceGoronOverFinishLine(EnMttag* this) { + s32 isAnyRaceGoronOverFinishLine = false; + s32 i; + + for (i = 0; i < ARRAY_COUNT(this->raceGorons); i++) { + if ((EnMttag_IsInFinishLine(&this->raceGorons[i]->actor.world.pos)) && + (this->raceGorons[i]->actor.update != NULL)) { + isAnyRaceGoronOverFinishLine = true; + break; + } + } + return isAnyRaceGoronOverFinishLine; +} + +/** + * Handles the race from when the countdown finishes to when + * any race entrant crosses the finish line. + */ +void EnMttag_Race(EnMttag* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f* playerPos = &player->actor.world.pos; + s32 playerCheatStatus; + + if (EnMttag_IsInFinishLine(playerPos)) { + gSaveContext.unk_3DD0[4] = 6; + play_sound(NA_SE_SY_START_SHOT); + Audio_QueueSeqCmd(NA_BGM_GORON_GOAL | 0x8000); + this->timer = 55; + gSaveContext.eventInf[1] |= 2; + this->actionFunc = EnMttag_RaceFinish; + } else if (EnMttag_IsAnyRaceGoronOverFinishLine(this)) { + gSaveContext.unk_3DD0[4] = 6; + play_sound(NA_SE_SY_START_SHOT); + Audio_QueueSeqCmd(NA_BGM_GORON_GOAL | 0x8000); + this->timer = 55; + gSaveContext.eventInf[1] |= 4; + this->actionFunc = EnMttag_RaceFinish; + } else { + playerCheatStatus = EnMttag_CheckPlayerCheatStatus(playerPos); + if (playerCheatStatus != GORON_RACE_CHEAT_NO_CHEATING) { + if (playerCheatStatus == GORON_RACE_CHEAT_FALSE_START) { + this->shouldRestartRace = true; + } else { + this->shouldRestartRace = false; + } + + EnMttag_ShowFalseStartMessage(this, globalCtx); + gSaveContext.eventInf[1] |= 8; + } else if ((EnMttag_UpdateCheckpoints(this, globalCtx)) && (this->timer == 0)) { + EnMttag_ShowCantWinMessage(this, globalCtx); + gSaveContext.eventInf[1] |= 8; + } + } +} + +/** + * Handles the race after any race entrant crosses the finish line. + * This function simply waits for a bit before exiting the race. + */ +void EnMttag_RaceFinish(EnMttag* this, GlobalContext* globalCtx) { + if (DECR(this->timer) == 0) { + if ((gSaveContext.eventInf[1] & 2)) { + // Player won + EnMttag_ExitRace(globalCtx, 3, 3); + } else { + // A non-player Goron won + EnMttag_ExitRace(globalCtx, 2, 2); + } + + Actor_MarkForDeath(&this->actor); + } +} + +/** + * Restarts the race if this->shouldRestartRace is true. Otherwise, it exits the race. + * In practice, the only time this exits the race is if the player tries to cheat by + * reaching the goal from behind. + */ +void EnMttag_PotentiallyRestartRace(EnMttag* this, GlobalContext* globalCtx) { + u8 talkState = Message_GetState(&globalCtx->msgCtx); + + if (((talkState == 5 && Message_ShouldAdvance(globalCtx)) || talkState == 2)) { + if (this->shouldRestartRace) { + globalCtx->nextEntranceIndex = 0xD010; + + if (gSaveContext.save.weekEventReg[33] & 0x80) { + // Spring + gSaveContext.nextCutsceneIndex = 0xFFF0; + } else { + // Winter + gSaveContext.nextCutsceneIndex = 0; + } + + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 2; + gSaveContext.nextTransition = 2; + func_801477B4(globalCtx); + func_800B7298(globalCtx, &this->actor, 7); + Parameter_AddMagic(globalCtx, + ((void)0, gSaveContext.unk_3F30) + (gSaveContext.save.playerData.doubleMagic * 48) + 48); + + gSaveContext.eventInf[1] &= (u8)~1; + gSaveContext.eventInf[1] &= (u8)~2; + gSaveContext.eventInf[1] &= (u8)~4; + gSaveContext.eventInf[1] &= (u8)~8; + gSaveContext.eventInf[2] = ((gSaveContext.eventInf[2] & 0xF) + 1) | (gSaveContext.eventInf[2] & 0xF0); + } else { + EnMttag_ExitRace(globalCtx, 2, 2); + } + Actor_MarkForDeath(&this->actor); + } +} + +/** + * This function either exits the race or resumes it based on how the player + * responded to the Goron Elder's son's question. + */ +void EnMttag_HandleCantWinChoice(EnMttag* this, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == 4) && (Message_ShouldAdvance(globalCtx))) { + if (globalCtx->msgCtx.choiceIndex != 0) { + // Exit the race + func_8019F230(); + gSaveContext.unk_3DD0[4] = 0; + EnMttag_ExitRace(globalCtx, 2, 2); + gSaveContext.eventInf[1] &= (u8)~8; + gSaveContext.eventInf[1] |= 4; + Actor_MarkForDeath(&this->actor); + } else { + // Keep racing + func_8019F208(); + func_801477B4(globalCtx); + func_800B7298(globalCtx, &this->actor, 6); + gSaveContext.eventInf[1] &= (u8)~8; + this->timer = 100; + this->actionFunc = EnMttag_Race; + } + } +} + +void EnMttag_Init(Actor* thisx, GlobalContext* globalCtx) { + Player* player; + EnMttag* this = THIS; + + if (gSaveContext.save.entranceIndex == 0xD010) { + player = GET_PLAYER(globalCtx); + player->stateFlags1 |= 0x20; + this->raceInitialized = false; + this->timer = 100; + + gSaveContext.eventInf[1] &= (u8)~1; + gSaveContext.eventInf[1] &= (u8)~2; + gSaveContext.eventInf[1] &= (u8)~4; + gSaveContext.eventInf[1] &= (u8)~8; + + if (!(gSaveContext.save.weekEventReg[12] & 2)) { + this->actionFunc = EnMttag_ShowIntroCutscene; + } else { + s32 requiredScopeTemp; + + this->actionFunc = EnMttag_RaceStart; + } + } else { + Actor_MarkForDeath(&this->actor); + } +} + +void EnMttag_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnMttag* this = THIS; + if (gSaveContext.unk_3DD0[4] != 6) { + gSaveContext.unk_3DD0[4] = 5; + } +} + +void EnMttag_Update(Actor* thisx, GlobalContext* globalCtx) { + EnMttag* this = THIS; + this->actionFunc(this, globalCtx); +} diff --git a/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.h b/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.h index 796482b141..796dff17a6 100644 --- a/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.h +++ b/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.h @@ -2,15 +2,20 @@ #define Z_EN_MT_TAG_H #include "global.h" +#include "overlays/actors/ovl_En_Rg/z_en_rg.h" struct EnMttag; typedef void (*EnMttagActionFunc)(struct EnMttag*, GlobalContext*); typedef struct EnMttag { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnMttagActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x20]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnMttagActionFunc actionFunc; + /* 0x148 */ EnRg* raceGorons[4]; + /* 0x158 */ u16 raceInitialized; + /* 0x15A */ s16 timer; + /* 0x15C */ UNK_TYPE1 unk_15C[0x8]; + /* 0x164 */ s32 shouldRestartRace; } EnMttag; // size = 0x168 extern const ActorInit En_Mt_tag_InitVars; diff --git a/src/overlays/actors/ovl_En_Muto/z_en_muto.c b/src/overlays/actors/ovl_En_Muto/z_en_muto.c index 0e3cbded40..4aed3132f2 100644 --- a/src/overlays/actors/ovl_En_Muto/z_en_muto.c +++ b/src/overlays/actors/ovl_En_Muto/z_en_muto.c @@ -70,11 +70,11 @@ void EnMuto_Init(Actor* thisx, GlobalContext* globalCtx) { if (!this->isInMayorsRoom) { this->shouldSetHeadRotation = true; this->textIdIndex = 2; - if (gSaveContext.weekEventReg[60] & 0x80) { + if (gSaveContext.save.weekEventReg[60] & 0x80) { this->textIdIndex = 3; } - if (gSaveContext.day != 3 || !gSaveContext.isNight) { + if (gSaveContext.save.day != 3 || !gSaveContext.save.isNight) { Actor_MarkForDeath(&this->actor); } } else { @@ -82,7 +82,7 @@ void EnMuto_Init(Actor* thisx, GlobalContext* globalCtx) { this->collider.dim.height = 60; this->collider.dim.yShift = 0; - if (gSaveContext.weekEventReg[63] & 0x80 || (gSaveContext.day == 3 && gSaveContext.isNight)) { + if (gSaveContext.save.weekEventReg[63] & 0x80 || (gSaveContext.save.day == 3 && gSaveContext.save.isNight)) { Actor_MarkForDeath(&this->actor); } } @@ -134,7 +134,7 @@ void EnMuto_Idle(EnMuto* this, GlobalContext* globalCtx) { this->actor.textId = sTextIds[this->textIdIndex]; if (!this->isInMayorsRoom && (player = GET_PLAYER(globalCtx))->transformation == PLAYER_FORM_DEKU) { - if (!(gSaveContext.weekEventReg[88] & 8)) { + if (!(gSaveContext.save.weekEventReg[88] & 8)) { this->actor.textId = 0x62C; } else { this->actor.textId = 0x62B; @@ -161,7 +161,7 @@ void EnMuto_Idle(EnMuto* this, GlobalContext* globalCtx) { } } else { this->textIdIndex = 0; - if (gSaveContext.weekEventReg[60] & 8) { + if (gSaveContext.save.weekEventReg[60] & 8) { this->textIdIndex = 1; } if (Player_GetMask(globalCtx) == PLAYER_MASK_COUPLE) { @@ -195,14 +195,14 @@ void EnMuto_SetupDialogue(EnMuto* this, GlobalContext* globalCtx) { void EnMuto_InDialogue(EnMuto* this, GlobalContext* globalCtx) { if (!this->isInMayorsRoom) { this->yawTowardsTarget = this->actor.yawTowardsPlayer; - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); if (this->actor.textId == 0x62C) { - gSaveContext.weekEventReg[88] |= 8; + gSaveContext.save.weekEventReg[88] |= 8; } if (this->actor.textId == 0x624) { - gSaveContext.weekEventReg[60] |= 0x80; + gSaveContext.save.weekEventReg[60] |= 0x80; } this->textIdIndex = 3; @@ -226,13 +226,13 @@ void EnMuto_InDialogue(EnMuto* this, GlobalContext* globalCtx) { } } - if (globalCtx->msgCtx.unk11F04 == 0x2AC6 || globalCtx->msgCtx.unk11F04 == 0x2AC7 || - globalCtx->msgCtx.unk11F04 == 0x2AC8) { + if (globalCtx->msgCtx.currentTextId == 0x2AC6 || globalCtx->msgCtx.currentTextId == 0x2AC7 || + globalCtx->msgCtx.currentTextId == 0x2AC8) { this->skelAnime.playSpeed = 0.0f; this->yawTowardsTarget = this->actor.yawTowardsPlayer; this->skelAnime.curFrame = 30.0f; } - if (globalCtx->msgCtx.unk11F04 == 0x2ACF) { + if (globalCtx->msgCtx.currentTextId == 0x2ACF) { this->skelAnime.playSpeed = 0.0f; } @@ -251,7 +251,7 @@ void EnMuto_Update(Actor* thisx, GlobalContext* globalCtx2) { EnMuto_SetHeadRotation(this); } - if (this->isInMayorsRoom && gSaveContext.day == 3 && gSaveContext.isNight) { + if (this->isInMayorsRoom && gSaveContext.save.day == 3 && gSaveContext.save.isNight) { Actor_MarkForDeath(&this->actor); return; } diff --git a/src/overlays/actors/ovl_En_Neo_Reeba/z_en_neo_reeba.c b/src/overlays/actors/ovl_En_Neo_Reeba/z_en_neo_reeba.c index 5e288df38b..591d4ddcbb 100644 --- a/src/overlays/actors/ovl_En_Neo_Reeba/z_en_neo_reeba.c +++ b/src/overlays/actors/ovl_En_Neo_Reeba/z_en_neo_reeba.c @@ -5,6 +5,7 @@ */ #include "z_en_neo_reeba.h" +#include "objects/object_rb/object_rb.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_200) @@ -15,7 +16,26 @@ void EnNeoReeba_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnNeoReeba_Update(Actor* thisx, GlobalContext* globalCtx); void EnNeoReeba_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void EnNeoReeba_SetupWaitUnderground(EnNeoReeba* this); +void EnNeoReeba_WaitUnderground(EnNeoReeba* this, GlobalContext* globalCtx); +void EnNeoReeba_ChooseAction(EnNeoReeba* this, GlobalContext* globalCtx); +void EnNeoReeba_SetupSink(EnNeoReeba* this); +void EnNeoReeba_Sink(EnNeoReeba* this, GlobalContext* globalCtx); +void EnNeoReeba_SetupRise(EnNeoReeba* this); +void EnNeoReeba_RiseOutOfGround(EnNeoReeba* this, GlobalContext* globalCtx); +void EnNeoReeba_SetupMove(EnNeoReeba* this); +void EnNeoReeba_Move(EnNeoReeba* this, GlobalContext* globalCtx); +void EnNeoReeba_SetupReturnHome(EnNeoReeba* this); +void EnNeoReeba_ReturnHome(EnNeoReeba* this, GlobalContext* globalCtx); +void EnNeoReeba_Bounce(EnNeoReeba* this, GlobalContext* globalCtx); +void EnNeoReeba_Stunned(EnNeoReeba* this, GlobalContext* globalCtx); +void EnNeoReeba_Frozen(EnNeoReeba* this, GlobalContext* globalCtx); +void EnNeoReeba_SetupDamageAnim(EnNeoReeba* this); +void EnNeoReeba_DamageAnim(EnNeoReeba* this, GlobalContext* globalCtx); +void EnNeoReeba_SetupDeathEffects(EnNeoReeba* this); +void EnNeoReeba_PlayDeathEffects(EnNeoReeba* this, GlobalContext* globalCtx); +void EnNeoReeba_SpawnIce(EnNeoReeba* this, GlobalContext* globalCtx); + const ActorInit En_Neo_Reeba_InitVars = { ACTOR_EN_NEO_REEBA, ACTORCAT_ENEMY, @@ -28,118 +48,701 @@ const ActorInit En_Neo_Reeba_InitVars = { (ActorFunc)EnNeoReeba_Draw, }; -// static DamageTable sDamageTable = { -static DamageTable D_80B7E500 = { - /* Deku Nut */ DMG_ENTRY(0, 0x0), - /* Deku Stick */ DMG_ENTRY(1, 0xE), - /* Horse trample */ DMG_ENTRY(1, 0xF), - /* Explosives */ DMG_ENTRY(1, 0xF), - /* Zora boomerang */ DMG_ENTRY(1, 0xE), - /* Normal arrow */ DMG_ENTRY(1, 0xE), - /* UNK_DMG_0x06 */ DMG_ENTRY(1, 0xF), - /* Hookshot */ DMG_ENTRY(0, 0xC), - /* Goron punch */ DMG_ENTRY(1, 0xF), - /* Sword */ DMG_ENTRY(1, 0xF), - /* Goron pound */ DMG_ENTRY(1, 0xF), - /* Fire arrow */ DMG_ENTRY(2, 0x2), - /* Ice arrow */ DMG_ENTRY(2, 0x3), - /* Light arrow */ DMG_ENTRY(2, 0x4), - /* Goron spikes */ DMG_ENTRY(1, 0xF), - /* Deku spin */ DMG_ENTRY(0, 0x1), - /* Deku bubble */ DMG_ENTRY(1, 0xE), - /* Deku launch */ DMG_ENTRY(2, 0xF), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0x0), - /* Zora barrier */ DMG_ENTRY(0, 0xD), - /* Normal shield */ DMG_ENTRY(0, 0x0), - /* Light ray */ DMG_ENTRY(0, 0x0), - /* Thrown object */ DMG_ENTRY(1, 0xF), - /* Zora punch */ DMG_ENTRY(1, 0xF), - /* Spin attack */ DMG_ENTRY(1, 0xF), - /* Sword beam */ DMG_ENTRY(0, 0x0), - /* Normal Roll */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0x0), - /* Powder Keg */ DMG_ENTRY(1, 0xF), +typedef enum { + /* 0x0 */ EN_NEO_REEBA_DMGEFF_IMMUNE, // No effect on the leever + /* 0x1 */ EN_NEO_REEBA_DMGEFF_STUN, // Turns blue, frozen in place + /* 0x2 */ EN_NEO_REEBA_DMGEFF_FIRE, + /* 0x3 */ EN_NEO_REEBA_DMGEFF_FREEZE, // Ice effects, frozen in place + /* 0x4 */ EN_NEO_REEBA_DMGEFF_LIGHT, + /* 0xC */ EN_NEO_REEBA_DMGEFF_HOOKSHOT = 0xC, // No damage, used only for hookshot + /* 0xD */ EN_NEO_REEBA_DMGEFF_ELECTRIC_STUN, // Electric effects, frozen in place + /* 0xE */ EN_NEO_REEBA_DMGEFF_NONE, // Normal hit + /* 0xF */ EN_NEO_REEBA_DMGEFF_SHATTER, // Normal hit that can break ice if leever is frozen +} EnNeoReebaDamageEffect; + +static DamageTable sDamageTable = { + /* Deku Nut */ DMG_ENTRY(0, EN_NEO_REEBA_DMGEFF_IMMUNE), + /* Deku Stick */ DMG_ENTRY(1, EN_NEO_REEBA_DMGEFF_NONE), + /* Horse trample */ DMG_ENTRY(1, EN_NEO_REEBA_DMGEFF_SHATTER), + /* Explosives */ DMG_ENTRY(1, EN_NEO_REEBA_DMGEFF_SHATTER), + /* Zora boomerang */ DMG_ENTRY(1, EN_NEO_REEBA_DMGEFF_NONE), + /* Normal arrow */ DMG_ENTRY(1, EN_NEO_REEBA_DMGEFF_NONE), + /* UNK_DMG_0x06 */ DMG_ENTRY(1, EN_NEO_REEBA_DMGEFF_SHATTER), + /* Hookshot */ DMG_ENTRY(0, EN_NEO_REEBA_DMGEFF_HOOKSHOT), + /* Goron punch */ DMG_ENTRY(1, EN_NEO_REEBA_DMGEFF_SHATTER), + /* Sword */ DMG_ENTRY(1, EN_NEO_REEBA_DMGEFF_SHATTER), + /* Goron pound */ DMG_ENTRY(1, EN_NEO_REEBA_DMGEFF_SHATTER), + /* Fire arrow */ DMG_ENTRY(2, EN_NEO_REEBA_DMGEFF_FIRE), + /* Ice arrow */ DMG_ENTRY(2, EN_NEO_REEBA_DMGEFF_FREEZE), + /* Light arrow */ DMG_ENTRY(2, EN_NEO_REEBA_DMGEFF_LIGHT), + /* Goron spikes */ DMG_ENTRY(1, EN_NEO_REEBA_DMGEFF_SHATTER), + /* Deku spin */ DMG_ENTRY(0, EN_NEO_REEBA_DMGEFF_STUN), + /* Deku bubble */ DMG_ENTRY(1, EN_NEO_REEBA_DMGEFF_NONE), + /* Deku launch */ DMG_ENTRY(2, EN_NEO_REEBA_DMGEFF_SHATTER), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, EN_NEO_REEBA_DMGEFF_IMMUNE), + /* Zora barrier */ DMG_ENTRY(0, EN_NEO_REEBA_DMGEFF_ELECTRIC_STUN), + /* Normal shield */ DMG_ENTRY(0, EN_NEO_REEBA_DMGEFF_IMMUNE), + /* Light ray */ DMG_ENTRY(0, EN_NEO_REEBA_DMGEFF_IMMUNE), + /* Thrown object */ DMG_ENTRY(1, EN_NEO_REEBA_DMGEFF_SHATTER), + /* Zora punch */ DMG_ENTRY(1, EN_NEO_REEBA_DMGEFF_SHATTER), + /* Spin attack */ DMG_ENTRY(1, EN_NEO_REEBA_DMGEFF_SHATTER), + /* Sword beam */ DMG_ENTRY(0, EN_NEO_REEBA_DMGEFF_IMMUNE), + /* Normal Roll */ DMG_ENTRY(0, EN_NEO_REEBA_DMGEFF_IMMUNE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, EN_NEO_REEBA_DMGEFF_IMMUNE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, EN_NEO_REEBA_DMGEFF_IMMUNE), + /* Unblockable */ DMG_ENTRY(0, EN_NEO_REEBA_DMGEFF_IMMUNE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, EN_NEO_REEBA_DMGEFF_IMMUNE), + /* Powder Keg */ DMG_ENTRY(1, EN_NEO_REEBA_DMGEFF_SHATTER), }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B7E520 = { - { COLTYPE_HIT5, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x08, 0x04 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT5, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x08, 0x04 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 18, 30, 0, { 0, 0, 0 } }, }; -#endif +void EnNeoReeba_Init(Actor* thisx, GlobalContext* globalCtx) { + EnNeoReeba* this = THIS; -extern DamageTable D_80B7E500; -extern ColliderCylinderInit D_80B7E520; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 0.0f); + SkelAnime_Init(globalCtx, &this->skelAnime, &gLeeverSkel, &gLeeverSpinAnim, this->jointTable, this->morphTable, + LEEVER_LIMB_MAX); -extern UNK_TYPE D_060001E4; + if (!EN_NEO_REEBA_IS_LARGE(&this->actor)) { + Actor_SetScale(&this->actor, 0.04f); + this->actor.colChkInfo.mass = 90; + this->actor.colChkInfo.health = 1; + } else { + Actor_SetScale(&this->actor, 0.05f); + this->actor.colChkInfo.mass = 180; + this->actor.colChkInfo.health = 3; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/EnNeoReeba_Init.s") + this->actor.colChkInfo.damageTable = &sDamageTable; + this->actor.targetMode = 2; + this->actor.hintId = 0x47; + this->actor.gravity = -0.5f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/EnNeoReeba_Destroy.s") + this->targetPos = gZeroVec3f; + this->velToTarget = gZeroVec3f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7CA34.s") + this->rotationAngle = 0; + this->sfxTimer = 0; + this->stunTimer = 0; + this->actionTimer = 0; + this->sinkRiseRate = 0.0f; + this->rotationSpeed = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7CA70.s") + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7CB3C.s") + EnNeoReeba_SetupWaitUnderground(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7CB88.s") +void EnNeoReeba_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnNeoReeba* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7CCE0.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7CD28.s") +void EnNeoReeba_SetupWaitUnderground(EnNeoReeba* this) { + this->actor.flags &= ~ACTOR_FLAG_1; + this->actor.draw = NULL; + this->actionTimer = 10; + this->actionFunc = EnNeoReeba_WaitUnderground; + this->actor.shape.yOffset = -2000.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7CE34.s") +void EnNeoReeba_WaitUnderground(EnNeoReeba* this, GlobalContext* globalCtx) { + s32 pad; + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7CE94.s") + if ((Actor_XZDistanceToPoint(&player->actor, &this->actor.home.pos) < 200.0f) && + (Player_GetMask(globalCtx) != PLAYER_MASK_STONE) && (fabsf(this->actor.playerHeightRel) < 100.0f)) { + EnNeoReeba_SetupRise(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7CFA0.s") + if (this->actionTimer == 0) { + this->actor.world.pos = this->actor.home.pos; + this->actionTimer = -1; + } else { + this->actionTimer--; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7CFFC.s") +void EnNeoReeba_SetupChooseAction(EnNeoReeba* this) { + this->actor.shape.yOffset = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7D130.s") + if (this->actionFunc == EnNeoReeba_Move) { + this->actionTimer = 20; + } else { + this->actionTimer = 10; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7D150.s") + this->actionFunc = EnNeoReeba_ChooseAction; + this->skelAnime.playSpeed = 1.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7D254.s") +void EnNeoReeba_ChooseAction(EnNeoReeba* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 distToPlayer = Actor_XZDistanceToPoint(&player->actor, &this->actor.home.pos); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7D2E4.s") + if ((distToPlayer > 200.0f) || (fabsf(this->actor.playerHeightRel) > 100.0f)) { + EnNeoReeba_SetupSink(this); + } else { + if (this->actionTimer == 0) { + if ((distToPlayer < 140.0f) && (fabsf(this->actor.playerHeightRel) < 100.0f)) { + this->targetPos = player->actor.world.pos; + this->targetPos.x += 10.0f * player->actor.speedXZ * Math_SinS(player->actor.world.rot.y); + this->targetPos.z += 10.0f * player->actor.speedXZ * Math_CosS(player->actor.world.rot.y); + EnNeoReeba_SetupMove(this); + } else { + EnNeoReeba_SetupReturnHome(this); + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7D360.s") + if (this->actionTimer != 0) { + this->actionTimer--; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7D398.s") +void EnNeoReeba_SetupSink(EnNeoReeba* this) { + this->sinkRiseRate = 0.0f; + this->skelAnime.playSpeed = 2.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); + this->actionFunc = EnNeoReeba_Sink; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7D3EC.s") +void EnNeoReeba_Sink(EnNeoReeba* this, GlobalContext* globalCtx) { + if (Math_SmoothStepToF(&this->actor.shape.yOffset, -2000.0f, 0.5f, this->sinkRiseRate, 10.0f) == 0.0f) { + EnNeoReeba_SetupWaitUnderground(this); + } else if (globalCtx->gameplayFrames % 4 == 0) { + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, this->actor.shape.shadowScale, 1, + 8.0f, 500, 10, 1); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7D47C.s") + if (this->sinkRiseRate < 300.0f) { + this->sinkRiseRate += 20.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7D4FC.s") + Math_ApproachF(&this->actor.shape.shadowScale, 0.0f, 1.0f, 1.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7D5A4.s") +void EnNeoReeba_SetupRise(EnNeoReeba* this) { + this->actor.draw = EnNeoReeba_Draw; + this->sinkRiseRate = 300.0f; + this->skelAnime.playSpeed = 2.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_APPEAR); + this->actor.flags |= ACTOR_FLAG_1; + this->actionFunc = EnNeoReeba_RiseOutOfGround; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7D6D0.s") +void EnNeoReeba_RiseOutOfGround(EnNeoReeba* this, GlobalContext* globalCtx) { + if (Math_SmoothStepToF(&this->actor.shape.yOffset, 0.0f, 0.5f, this->sinkRiseRate, 10.0f) == 0.0f) { + EnNeoReeba_SetupChooseAction(this); + } else if (globalCtx->gameplayFrames % 4 == 0) { + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, this->actor.shape.shadowScale, 1, + 8.0f, 500, 10, 1); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7D788.s") + if (this->sinkRiseRate > 20.0f) { + this->sinkRiseRate -= 10.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7D9B8.s") + Math_ApproachF(&this->actor.shape.shadowScale, 12.0f, 1.0f, 1.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7DC80.s") +void EnNeoReeba_SetupMove(EnNeoReeba* this) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIVA_MOVE); + this->sfxTimer = 10; + this->actionTimer = 60; + this->actionFunc = EnNeoReeba_Move; + this->skelAnime.playSpeed = 2.0f; + this->actor.speedXZ = 14.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7DD7C.s") +void EnNeoReeba_Move(EnNeoReeba* this, GlobalContext* globalCtx) { + f32 remainingDist = Math_Vec3f_StepToXZ(&this->actor.world.pos, &this->targetPos, this->actor.speedXZ); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7DF34.s") + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, this->actor.shape.shadowScale, 1, 4.0f, + 0xFA, 0xA, 1); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7E0BC.s") + if (remainingDist < 2.0f) { + EnNeoReeba_SetupChooseAction(this); + } else if (remainingDist < 40.0f && this->actor.speedXZ > 3.0f) { + this->actor.speedXZ -= 2.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7E260.s") + if (this->sfxTimer == 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIVA_MOVE); + this->sfxTimer = 10; + } else { + this->sfxTimer--; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/EnNeoReeba_Update.s") + if (this->actionTimer == 0) { + EnNeoReeba_SetupChooseAction(this); + } else { + this->actionTimer--; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7E378.s") +void EnNeoReeba_SetupReturnHome(EnNeoReeba* this) { + this->actionFunc = EnNeoReeba_ReturnHome; + this->actor.speedXZ = 6.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/EnNeoReeba_Draw.s") +void EnNeoReeba_ReturnHome(EnNeoReeba* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 pad; + f32 remainingDist = Math_Vec3f_StepToXZ(&this->actor.world.pos, &this->actor.home.pos, this->actor.speedXZ); + + if (remainingDist < 2.0f) { + EnNeoReeba_SetupChooseAction(this); + } else if (remainingDist < 40.0f && this->actor.speedXZ > 3.0f) { + this->actor.speedXZ -= 1.0f; + } + + if (Actor_XZDistanceToPoint(&player->actor, &this->actor.home.pos) > 200.0f || + fabsf(this->actor.playerHeightRel) > 100.0f) { + EnNeoReeba_SetupSink(this); + } +} + +void EnNeoReeba_SetupBounce(EnNeoReeba* this) { + this->actionTimer = 60; + this->targetPos = this->actor.world.pos; + this->targetPos.x -= 20.0f * Math_SinS(this->actor.yawTowardsPlayer); + this->targetPos.z -= 20.0f * Math_CosS(this->actor.yawTowardsPlayer); + this->actionFunc = EnNeoReeba_Bounce; +} + +void EnNeoReeba_Bounce(EnNeoReeba* this, GlobalContext* globalCtx) { + if (Math_Vec3f_StepToXZ(&this->actor.world.pos, &this->targetPos, this->actor.speedXZ) < 2.0f) { + EnNeoReeba_SetupChooseAction(this); + } + + if (this->actionTimer == 0) { + EnNeoReeba_SetupChooseAction(this); + } else { + this->actionTimer--; + } +} + +void EnNeoReeba_SetupStun(EnNeoReeba* this) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + this->actionFunc = EnNeoReeba_Stunned; +} + +void EnNeoReeba_Stunned(EnNeoReeba* this, GlobalContext* globalCtx) { + if (this->stunTimer > 0) { + this->stunTimer--; + } else { + this->drawEffectAlpha = 0.0f; + this->drawEffectScale = 0.0f; + } + + if (this->actor.colorFilterTimer == 0) { + this->stunTimer = 0; + EnNeoReeba_SetupChooseAction(this); + } +} + +void EnNeoReeba_SetupFrozen(EnNeoReeba* this) { + this->drawEffectType = ACTOR_DRAW_DMGEFF_FROZEN_SFX; + this->drawEffectScale = 0.5f; + this->drawEffectAlpha = 1.0f; + + if (EN_NEO_REEBA_IS_LARGE(&this->actor)) { + this->drawEffectScale *= 1.5f; + } + + if (this->actor.colChkInfo.health != 0) { + this->stunTimer = 80; + } else { + this->stunTimer = 12; + } + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + this->actionFunc = EnNeoReeba_Frozen; +} + +void EnNeoReeba_Frozen(EnNeoReeba* this, GlobalContext* globalCtx) { + if (this->stunTimer == 0) { + this->stunTimer = 0; + this->drawEffectScale = 0.0f; + this->drawEffectAlpha = 0.0f; + + if (this->actor.colChkInfo.health != 0) { + EnNeoReeba_SetupDamageAnim(this); + } else { + EnNeoReeba_SetupDeathEffects(this); + } + } else if (this->stunTimer == 1) { + this->stunTimer--; + EnNeoReeba_SpawnIce(this, globalCtx); + } else { + this->stunTimer--; + } +} + +void EnNeoReeba_SetupDamageAnim(EnNeoReeba* this) { + this->actionTimer = 10; + this->skelAnime.playSpeed = 1.0f; + this->velToTarget.x = Math_SinS(this->actor.yawTowardsPlayer) * -12.0f; + this->velToTarget.z = Math_CosS(this->actor.yawTowardsPlayer) * -12.0f; + this->rotationSpeed = 4551.0f; + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 25); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIVA_DAMAGE); + this->actionFunc = EnNeoReeba_DamageAnim; +} + +static f32 sDamageAnimXZScales[] = { 0.04, 0.04, 0.039, 0.042, 0.045, 0.043, 0.04, 0.035, 0.03, 0.033, 0.04 }; +static f32 sDamageAnimYScales[] = { 0.04f, 0.04f, 0.041f, 0.038f, 0.035f, 0.037f, 0.04f, 0.045f, 0.05f, 0.047f, 0.04f }; + +void EnNeoReeba_DamageAnim(EnNeoReeba* this, GlobalContext* globalCtx) { + if (this->actionTimer == 0) { + this->rotationSpeed = 0.0f; + EnNeoReeba_SetupChooseAction(this); + } else { + this->rotationAngle -= 0x1F40; + Math_SmoothStepToF(&this->rotationSpeed, 0.0f, 0.5f, 182.0f, 18.0f); + this->actor.scale.x = this->actor.scale.z = sDamageAnimXZScales[this->actionTimer]; + this->actor.scale.y = sDamageAnimYScales[this->actionTimer]; + + if (EN_NEO_REEBA_IS_LARGE(&this->actor)) { + this->actor.scale.x *= 1.5f; + this->actor.scale.y *= 1.5f; + this->actor.scale.z *= 1.5f; + } + + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, this->actor.shape.shadowScale, 1, + 4.0f, 250, 10, 1); + this->actionTimer--; + } +} + +void EnNeoReeba_SetupDeathEffects(EnNeoReeba* this) { + this->actionTimer = 10; + + this->velToTarget.x = Math_SinS(this->actor.yawTowardsPlayer) * -12.0f; + this->velToTarget.z = Math_CosS(this->actor.yawTowardsPlayer) * -12.0f; + + this->rotationSpeed = 3640.0f; + Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 25); + this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags &= ~ACTOR_FLAG_1; + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIVA_DEAD); + this->actionFunc = EnNeoReeba_PlayDeathEffects; +} + +void EnNeoReeba_PlayDeathEffects(EnNeoReeba* this, GlobalContext* globalCtx) { + static Vec3f sDeadDbVel = { 0.0f, 0.0f, 0.0f }; + static Vec3f sDeadDbAccel = { 0.0f, 4.0f, 0.0f }; + + if (this->actionTimer == 0) { + Math_ApproachZeroF(&this->actor.scale.x, 0.1f, 0.01f); + Math_ApproachZeroF(&this->actor.scale.y, 0.1f, 0.01f); + Math_ApproachZeroF(&this->actor.scale.z, 0.1f, 0.01f); + Math_ApproachZeroF(&this->drawEffectAlpha, 0.1f, 0.1f); + Math_ApproachZeroF(&this->drawEffectScale, 0.1f, 0.1f); + + if (this->actor.scale.x < 0.01f) { + func_800B3030(globalCtx, &this->actor.world.pos, &sDeadDbAccel, &sDeadDbVel, 120, 0, 0); + Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x60); + Actor_MarkForDeath(&this->actor); + } + } else { + if (this->actionTimer <= 10) { + this->rotationAngle -= 0x1388; + this->actor.scale.x = this->actor.scale.z = sDamageAnimXZScales[this->actionTimer]; + this->actor.scale.y = sDamageAnimYScales[this->actionTimer]; + + if (EN_NEO_REEBA_IS_LARGE(&this->actor)) { + this->actor.scale.x *= 1.5f; + this->actor.scale.y *= 1.5f; + this->actor.scale.z *= 1.5f; + } + } + + if (this->drawEffectType == ACTOR_DRAW_DMGEFF_FIRE) { + f32 target = 1.2f; + + if (EN_NEO_REEBA_IS_LARGE(&this->actor)) { + target *= 1.5f; + } + + Math_SmoothStepToF(&this->drawEffectScale, target, 0.5f, 0.3f, 0.0f); + } else { + f32 target = 1.6f; + + if (EN_NEO_REEBA_IS_LARGE(&this->actor)) { + target *= 1.5f; + } + + Math_SmoothStepToF(&this->drawEffectScale, target, 0.5f, 0.3f, 0.0f); + } + this->actionTimer--; + } +} + +void EnNeoReeba_HandleHit(EnNeoReeba* this, GlobalContext* globalCtx) { + Actor_SetFocus(&this->actor, 20.0f); + + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + + if (this->actionFunc == EnNeoReeba_Frozen) { + switch (this->actor.colChkInfo.damageEffect) { + case EN_NEO_REEBA_DMGEFF_STUN: + case EN_NEO_REEBA_DMGEFF_FREEZE: + case EN_NEO_REEBA_DMGEFF_LIGHT: + case EN_NEO_REEBA_DMGEFF_ELECTRIC_STUN: + case EN_NEO_REEBA_DMGEFF_NONE: + return; + default: + if (this->stunTimer >= 2) { + EnNeoReeba_SpawnIce(this, globalCtx); + } + this->stunTimer = 0; + } + } + + Actor_ApplyDamage(&this->actor); + + switch (this->actor.colChkInfo.damageEffect) { + case EN_NEO_REEBA_DMGEFF_FREEZE: + EnNeoReeba_SetupFrozen(this); + break; + + case EN_NEO_REEBA_DMGEFF_FIRE: + case EN_NEO_REEBA_DMGEFF_LIGHT: + if (this->actor.colChkInfo.damageEffect == EN_NEO_REEBA_DMGEFF_FIRE) { + this->drawEffectType = ACTOR_DRAW_DMGEFF_FIRE; + this->stunTimer = 80; + } else { + this->drawEffectType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->stunTimer = 40; + } + this->drawEffectAlpha = 1.0f; + this->drawEffectScale = 0.0f; + /* fallthrough */ + case EN_NEO_REEBA_DMGEFF_NONE: + case EN_NEO_REEBA_DMGEFF_SHATTER: + if ((this->actor.colChkInfo.damageEffect == EN_NEO_REEBA_DMGEFF_SHATTER) || + (this->actor.colChkInfo.damageEffect == EN_NEO_REEBA_DMGEFF_NONE)) { + this->stunTimer = 0; + } + if (this->actor.colChkInfo.health > 0) { + EnNeoReeba_SetupDamageAnim(this); + } else { + Enemy_StartFinishingBlow(globalCtx, &this->actor); + EnNeoReeba_SetupDeathEffects(this); + } + break; + + case EN_NEO_REEBA_DMGEFF_ELECTRIC_STUN: + this->drawEffectType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; + this->stunTimer = 40; + this->drawEffectAlpha = 1.0f; + this->drawEffectScale = 2.0f; + Actor_SetColorFilter(&this->actor, 0, 0x78, 0, 40); + EnNeoReeba_SetupStun(this); + break; + + case EN_NEO_REEBA_DMGEFF_STUN: + Actor_SetColorFilter(&this->actor, 0, 0x78, 0, 40); + EnNeoReeba_SetupStun(this); + break; + } + } else { + if (((this->collider.base.ocFlags2 & OC2_HIT_PLAYER) || (this->collider.base.atFlags & AT_BOUNCED)) && + (this->actionFunc == EnNeoReeba_Move)) { + EnNeoReeba_SetupBounce(this); + } + } + if ((this->actionFunc != EnNeoReeba_WaitUnderground) && (this->actionFunc != EnNeoReeba_Sink) && + (this->actionFunc != EnNeoReeba_RiseOutOfGround) && (this->actionFunc != EnNeoReeba_DamageAnim) && + (this->actionFunc != EnNeoReeba_PlayDeathEffects)) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + + if (this->actionFunc != EnNeoReeba_Stunned) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + } +} + +void EnNeoReeba_UpdatePosition(EnNeoReeba* this, GlobalContext* globalCtx) { + if ((this->actionFunc != EnNeoReeba_WaitUnderground) && (this->actionFunc != EnNeoReeba_Sink) && + (this->actionFunc != EnNeoReeba_RiseOutOfGround)) { + this->actor.velocity.y += this->actor.gravity; + + this->actor.world.pos.y += this->actor.velocity.y; + this->actor.world.pos.x += this->actor.colChkInfo.displacement.x; + this->actor.world.pos.z += this->actor.colChkInfo.displacement.z; + + this->actor.world.pos.x += this->velToTarget.x; + this->actor.world.pos.z += this->velToTarget.z; + + Math_ApproachZeroF(&this->velToTarget.x, 1.0f, 2.0f); + Math_ApproachZeroF(&this->velToTarget.z, 1.0f, 2.0f); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 40.0f, 40.0f, 5); + } +} + +void EnNeoReeba_DrawFrozenEffects(EnNeoReeba* this, GlobalContext* globalCtx) { + s32 i; + f32 limbPosScale = 10.0f; + f32 phi_f2 = 20.0f; + f32 drawEffectScale = 0.8f; + + if (EN_NEO_REEBA_IS_LARGE(&this->actor)) { + limbPosScale *= 1.5f; + phi_f2 *= 1.5f; + drawEffectScale *= 1.5f; + } + + for (i = 0; i < ARRAY_COUNT(this->limbPos) - 1; i++) { + this->limbPos[i] = this->actor.world.pos; + + this->limbPos[i].x += limbPosScale * Math_SinS(BINANG_ADD(this->actor.shape.rot.y, i * 0x5555)); + this->limbPos[i].z += limbPosScale * Math_CosS(BINANG_ADD(this->actor.shape.rot.y, i * 0x5555)); + this->limbPos[i].y += 5.0f; + } + + this->limbPos[ARRAY_COUNT(this->limbPos) - 1] = this->actor.world.pos; + this->limbPos[ARRAY_COUNT(this->limbPos) - 1].y += phi_f2; + + this->drawEffectScale = drawEffectScale; + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), drawEffectScale, 0.5f, + this->drawEffectAlpha, this->drawEffectType); +} + +void EnNeoReeba_DrawEffects(EnNeoReeba* this, GlobalContext* globalCtx) { + s32 i; + f32 scale = 15.0f; + + if (EN_NEO_REEBA_IS_LARGE(&this->actor)) { + scale *= 1.5f; + } + + if ((this->drawEffectType == ACTOR_DRAW_DMGEFF_FIRE) || (this->drawEffectType == ACTOR_DRAW_DMGEFF_LIGHT_ORBS) || + (this->drawEffectType == ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL)) { + for (i = 0; i < ARRAY_COUNT(this->limbPos) - 1; i++) { + this->limbPos[i] = this->actor.world.pos; + this->limbPos[i].x += scale * Math_SinS(BINANG_ADD(this->actor.shape.rot.y, i * 0x5555)); + this->limbPos[i].z += scale * Math_CosS(BINANG_ADD(this->actor.shape.rot.y, i * 0x5555)); + this->limbPos[i].y += -20.0f; + } + + this->limbPos[ARRAY_COUNT(this->limbPos) - 1] = this->actor.world.pos; + Actor_DrawDamageEffects(globalCtx, NULL, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawEffectScale, 0.5f, + this->drawEffectAlpha, this->drawEffectType); + } +} + +void EnNeoReeba_SpawnIce(EnNeoReeba* this, GlobalContext* globalCtx) { + static Color_RGBA8 sIcePrimColor = { 170, 255, 255, 255 }; + static Color_RGBA8 sIceEnvColor = { 200, 200, 255, 255 }; + static Vec3f sIceAccel = { 0.0f, -1.0f, 0.0f }; + Vec3f iceVel; + f32 xVel; + f32 zVel; + s32 i; + s16 yaw; + s32 j; + + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 30, NA_SE_EV_ICE_BROKEN); + + for (i = 0; i < ARRAY_COUNT(this->limbPos); i++) { + yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &this->limbPos[i]); + xVel = Math_SinS(yaw) * 3.0f; + zVel = Math_CosS(yaw) * 3.0f; + + for (j = 0; j < 4; j++) { + iceVel.x = (Rand_Centered() * 3.0f) + xVel; + iceVel.z = (Rand_Centered() * 3.0f) + zVel; + iceVel.y = (Rand_ZeroOne() * 6.0f) + 4.0f; + EffectSsEnIce_Spawn(globalCtx, &this->limbPos[i], 0.7f, &iceVel, &sIceAccel, &sIcePrimColor, &sIceEnvColor, + 30); + } + } +} + +void EnNeoReeba_SinkIfStoneMask(EnNeoReeba* this, GlobalContext* globalCtx) { + if ((this->actionFunc == EnNeoReeba_ChooseAction) || (this->actionFunc == EnNeoReeba_Move) || + (this->actionFunc == EnNeoReeba_ReturnHome)) { + if (Player_GetMask(globalCtx) == PLAYER_MASK_STONE) { + EnNeoReeba_SetupSink(this); + } + } +} + +void EnNeoReeba_Update(Actor* thisx, GlobalContext* globalCtx) { + EnNeoReeba* this = THIS; + + if (EN_NEO_REEBA_IS_LARGE(&this->actor)) { + this->collider.dim.radius = 27; + this->collider.dim.height = 45; + } + + this->actionFunc(this, globalCtx); + + if ((this->actionFunc != EnNeoReeba_WaitUnderground) && (this->actionFunc != EnNeoReeba_Stunned) && + (this->actionFunc != EnNeoReeba_Frozen)) { + SkelAnime_Update(&this->skelAnime); + } + + EnNeoReeba_HandleHit(this, globalCtx); + EnNeoReeba_UpdatePosition(this, globalCtx); + EnNeoReeba_SinkIfStoneMask(this, globalCtx); +} + +s32 EnNeoReeba_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnNeoReeba* this = THIS; + + if ((limbIndex == OBJECT_RB_LIMB_03) && (this->rotationSpeed != 0.0f)) { + rot->y += (s16)(this->rotationSpeed * Math_SinS(this->rotationAngle)); + rot->z += (s16)(this->rotationSpeed * Math_CosS(this->rotationAngle)); + } + + return false; +} + +void EnNeoReeba_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnNeoReeba* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + OPEN_DISPS(globalCtx->state.gfxCtx); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x01, 255, 255, 255, 255); + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnNeoReeba_OverrideLimbDraw, + NULL, &this->actor); + CLOSE_DISPS(globalCtx->state.gfxCtx); + + if (this->stunTimer > 0) { + if (this->drawEffectType == ACTOR_DRAW_DMGEFF_FROZEN_SFX) { + EnNeoReeba_DrawFrozenEffects(this, globalCtx); + } else { + EnNeoReeba_DrawEffects(this, globalCtx); + } + } +} diff --git a/src/overlays/actors/ovl_En_Neo_Reeba/z_en_neo_reeba.h b/src/overlays/actors/ovl_En_Neo_Reeba/z_en_neo_reeba.h index 8d1091dfca..df6aaab1d0 100644 --- a/src/overlays/actors/ovl_En_Neo_Reeba/z_en_neo_reeba.h +++ b/src/overlays/actors/ovl_En_Neo_Reeba/z_en_neo_reeba.h @@ -2,16 +2,33 @@ #define Z_EN_NEO_REEBA_H #include "global.h" +#include "objects/object_rb/object_rb.h" + +#define EN_NEO_REEBA_IS_LARGE(thisx) ((thisx)->params & 0x8000) struct EnNeoReeba; typedef void (*EnNeoReebaActionFunc)(struct EnNeoReeba*, GlobalContext*); typedef struct EnNeoReeba { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x168]; - /* 0x02AC */ EnNeoReebaActionFunc actionFunc; - /* 0x02B0 */ char unk_2B0[0x64]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ ColliderCylinder collider; + /* 0x1D4 */ Vec3s jointTable[LEEVER_LIMB_MAX]; + /* 0x240 */ Vec3s morphTable[LEEVER_LIMB_MAX]; + /* 0x2AC */ EnNeoReebaActionFunc actionFunc; + /* 0x2B0 */ Vec3f targetPos; + /* 0x2BC */ Vec3f velToTarget; + /* 0x2C8 */ Vec3f limbPos[4]; + /* 0x2F8 */ f32 sinkRiseRate; + /* 0x2FC */ f32 rotationSpeed; + /* 0x300 */ f32 drawEffectAlpha; + /* 0x304 */ f32 drawEffectScale; + /* 0x308 */ s16 rotationAngle; + /* 0x30A */ s16 actionTimer; + /* 0x30C */ s16 sfxTimer; + /* 0x30E */ s16 stunTimer; + /* 0x310 */ u8 drawEffectType; } EnNeoReeba; // size = 0x314 extern const ActorInit En_Neo_Reeba_InitVars; diff --git a/src/overlays/actors/ovl_En_Osk/z_en_osk.c b/src/overlays/actors/ovl_En_Osk/z_en_osk.c index 2faed6abb7..30d9a1666e 100644 --- a/src/overlays/actors/ovl_En_Osk/z_en_osk.c +++ b/src/overlays/actors/ovl_En_Osk/z_en_osk.c @@ -5,6 +5,8 @@ */ #include "z_en_osk.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_ikn_demo/object_ikn_demo.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) @@ -20,7 +22,6 @@ void func_80BF61EC(EnOsk* this, GlobalContext* globalCtx); void func_80BF656C(EnOsk* this, GlobalContext* globalCtx); void func_80BF6A20(EnOsk* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Osk_InitVars = { ACTOR_EN_OSK, ACTORCAT_NPC, @@ -33,42 +34,533 @@ const ActorInit En_Osk_InitVars = { (ActorFunc)EnOsk_Draw, }; -#endif +AnimationHeader* D_80BF6FA0[] = { + &object_ikn_demo_Anim_003CAC, &object_ikn_demo_Anim_004208, &object_ikn_demo_Anim_004514, + &object_ikn_demo_Anim_004A58, &object_ikn_demo_Anim_0065D8, +}; -extern UNK_TYPE D_06006808; +AnimationHeader* D_80BF6FB4[] = { + &object_ikn_demo_Anim_0067B8, &object_ikn_demo_Anim_0083F4, &object_ikn_demo_Anim_0081A8, + &object_ikn_demo_Anim_008AF4, &object_ikn_demo_Anim_008724, &object_ikn_demo_Anim_008F1C, + &object_ikn_demo_Anim_008CEC, &object_ikn_demo_Anim_009254, &object_ikn_demo_Anim_009044, + &object_ikn_demo_Anim_0098E4, &object_ikn_demo_Anim_009CC8, &object_ikn_demo_Anim_009A44, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/EnOsk_Init.s") +AnimationHeader* D_80BF6FE4[] = { + &object_ikn_demo_Anim_009EA8, &object_ikn_demo_Anim_00B8C0, &object_ikn_demo_Anim_00B704, + &object_ikn_demo_Anim_00BDB4, &object_ikn_demo_Anim_00B9E4, &object_ikn_demo_Anim_00C154, + &object_ikn_demo_Anim_00BF04, &object_ikn_demo_Anim_00CA74, &object_ikn_demo_Anim_00C804, + &object_ikn_demo_Anim_00D044, &object_ikn_demo_Anim_00CD28, &object_ikn_demo_Anim_00C59C, + &object_ikn_demo_Anim_00C2C4, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/EnOsk_Destroy.s") +Vec3f D_80BF7018 = { 0.0f, 0.5f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/func_80BF5E00.s") +Vec3f D_80BF7024 = { 0.0f, 0.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/func_80BF5E68.s") +void EnOsk_Init(Actor* thisx, GlobalContext* globalCtx) { + EnOsk* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/func_80BF5EBC.s") + Actor_SetScale(&this->actor, 0.013f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 10.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/func_80BF5F60.s") + this->actionFunc = func_80BF5F60; + this->unk_254 = -1; + this->unk_256 = -1; + this->actor.flags &= ~ACTOR_FLAG_1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/func_80BF5F70.s") + switch (ENOSK_GET_F(&this->actor)) { + case ENOSK_1: + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_ikn_demo_Skel_007B48, &object_ikn_demo_Anim_006808, + this->jointTable, this->morphTable, 7); + Animation_PlayLoop(&this->skelAnime, &object_ikn_demo_Anim_006808); + this->actionFunc = func_80BF656C; + this->unk_258 = 0x210; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/func_80BF609C.s") + case ENOSK_2: + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_ikn_demo_Skel_00B490, &object_ikn_demo_Anim_009F00, + this->jointTable, this->morphTable, 7); + Animation_PlayLoop(&this->skelAnime, &object_ikn_demo_Anim_006808); + this->actionFunc = func_80BF6A20; + this->unk_258 = 0x211; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/func_80BF61EC.s") + default: + Actor_SetScale(&this->actor, 0.017f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_ikn_demo_Skel_0038F0, &object_ikn_demo_Anim_0000B8, + this->jointTable, this->morphTable, 17); + Animation_PlayLoop(&this->skelAnime, &object_ikn_demo_Anim_0000B8); + this->actionFunc = func_80BF61EC; + this->unk_258 = 0x212; + this->actor.home.rot.z = 0; + this->unk_25C = 0.0f; + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/func_80BF6314.s") +void EnOsk_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/func_80BF6478.s") +void func_80BF5E00(EnOsk* this, AnimationHeader** animations, s16 index, f32 morphFrame) { + if (index == this->unk_254) { + return; + } + Animation_MorphToLoop(&this->skelAnime, animations[index], morphFrame); + this->unk_254 = index; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/func_80BF656C.s") +void func_80BF5E68(EnOsk* this, AnimationHeader** animations, s16 index, f32 playSpeed) { + Animation_MorphToPlayOnce(&this->skelAnime, animations[index], playSpeed); + this->unk_254 = index; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/func_80BF67A8.s") +void func_80BF5EBC(EnOsk* this, GlobalContext* globalCtx) { + Vec3f sp2C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/func_80BF68E0.s") + sp2C.x = randPlusMinusPoint5Scaled(30.0f) + this->actor.world.pos.x; + sp2C.z = randPlusMinusPoint5Scaled(30.0f) + this->actor.world.pos.z; + sp2C.y = randPlusMinusPoint5Scaled(30.0f) + this->actor.world.pos.y; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/func_80BF6A20.s") + func_800B3030(globalCtx, &sp2C, &D_80BF7018, &D_80BF7018, 100, 0, 2); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/EnOsk_Update.s") +void func_80BF5F60(EnOsk* this, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/func_80BF6C54.s") +void func_80BF5F70(EnOsk* this) { + if ((this->unk_256 != 1) && (this->unk_256 != 6)) { + this->actor.draw = EnOsk_Draw; + Actor_SetScale(&this->actor, 0.017f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/EnOsk_Draw.s") + switch (this->unk_256) { + case 1: + this->actor.draw = NULL; + break; + + case 2: + func_80BF5E00(this, D_80BF6FA0, 3, -5.0f); + break; + + case 3: + func_80BF5E00(this, D_80BF6FA0, 2, -5.0f); + break; + + case 4: + func_80BF5E00(this, D_80BF6FA0, 1, -5.0f); + break; + + case 5: + func_80BF5E00(this, D_80BF6FA0, 0, -5.0f); + break; + + case 6: + func_80BF5E00(this, D_80BF6FA0, 1, -5.0f); + break; + + case 7: + func_80BF5E00(this, D_80BF6FA0, 4, -5.0f); + this->actor.home.rot.z = 1; + break; + } +} + +void func_80BF609C(EnOsk* this, GlobalContext* globalCtx) { + if (this->actor.draw != NULL) { + if (this->actor.home.rot.z != 0) { + if (globalCtx->msgCtx.currentTextId == 0x1531) { + this->actor.home.rot.z = 0; + } + } else { + if (Animation_OnFrame(&this->skelAnime, 5.0f)) { + this->unk_25C = Rand_ZeroFloat(3.0f); + } + + switch (this->unk_254) { + case 0: + if (Animation_OnFrame(&this->skelAnime, this->unk_25C) || + Animation_OnFrame(&this->skelAnime, this->unk_25C + 8.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BOSU_TALK); + } + break; + + case 1: + if (Animation_OnFrame(&this->skelAnime, this->unk_25C)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BOSU_TALK); + } + break; + + case 2: + if (Animation_OnFrame(&this->skelAnime, this->unk_25C) || + Animation_OnFrame(&this->skelAnime, this->unk_25C + 6.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BOSU_TALK); + } + break; + } + } + } +} + +void func_80BF61EC(EnOsk* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + + if (Cutscene_CheckActorAction(globalCtx, this->unk_258)) { + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, Cutscene_GetActorActionIndex(globalCtx, this->unk_258)); + if (this->unk_256 != + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->unk_258)]->action) { + this->unk_256 = + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->unk_258)]->action; + func_80BF5F70(this); + } + func_80BF609C(this, globalCtx); + } else { + this->actor.draw = NULL; + } + + if (this->unk_256 == 6) { + if (this->actor.scale.x > 0.85f * 0.001f) { + this->actor.scale.x -= 0.85f * 0.001f; + Actor_SetScale(&this->actor, this->actor.scale.x); + func_80BF5EBC(this, globalCtx); + func_800B9010(&this->actor, NA_SE_EN_COMMON_EXTINCT_LEV - SFX_FLAG); + } else { + this->actor.draw = NULL; + } + } +} + +void func_80BF6314(EnOsk* this) { + if ((this->unk_256 != 1) && (this->unk_256 != 9)) { + this->actor.draw = EnOsk_Draw; + Actor_SetScale(&this->actor, 0.013f); + } + + switch (this->unk_256) { + case 1: + this->actor.draw = NULL; + break; + + case 2: + func_80BF5E00(this, D_80BF6FB4, 9, -5.0f); + Actor_SetScale(&this->actor, 0.0f); + break; + + case 3: + func_80BF5E68(this, D_80BF6FB4, 2, -5.0f); + break; + + case 4: + func_80BF5E68(this, D_80BF6FB4, 4, 0); + break; + + case 5: + func_80BF5E68(this, D_80BF6FB4, 8, -5.0f); + break; + + case 6: + func_80BF5E68(this, D_80BF6FB4, 11, -5.0f); + break; + + case 7: + func_80BF5E68(this, D_80BF6FB4, 6, -5.0f); + break; + + case 8: + func_80BF5E00(this, D_80BF6FB4, 0, -5.0f); + break; + + case 9: + func_80BF5E00(this, D_80BF6FB4, 0, -5.0f); + break; + } +} + +void func_80BF6478(EnOsk* this) { + if (this->actor.draw != NULL) { + switch (this->unk_254) { + case 1: + if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 6.0f) || + Animation_OnFrame(&this->skelAnime, 11.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEBU_HEAD_UP); + } + break; + + case 3: + if (Animation_OnFrame(&this->skelAnime, 11.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEBU_HEAD_UP); + } + break; + + case 4: + if (Animation_OnFrame(&this->skelAnime, 5.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEBU_HEAD_UP); + } + break; + + case 10: + case 11: + func_800B9010(&this->actor, NA_SE_EN_YASE_LAUGH_K - SFX_FLAG); + break; + } + } +} + +void func_80BF656C(EnOsk* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + switch (this->unk_254) { + case 2: + func_80BF5E00(this, D_80BF6FB4, 1, 0.0f); + break; + + case 4: + func_80BF5E00(this, D_80BF6FB4, 3, 0.0f); + break; + + case 8: + func_80BF5E00(this, D_80BF6FB4, 7, -5.0f); + break; + + case 11: + func_80BF5E00(this, D_80BF6FB4, 10, -5.0f); + break; + + case 6: + func_80BF5E00(this, D_80BF6FB4, 5, -5.0f); + break; + } + } + + if (Cutscene_CheckActorAction(globalCtx, this->unk_258)) { + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, Cutscene_GetActorActionIndex(globalCtx, this->unk_258)); + if (this->unk_256 != + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->unk_258)]->action) { + this->unk_256 = + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->unk_258)]->action; + func_80BF6314(this); + } + func_80BF6478(this); + } else { + this->actor.draw = NULL; + } + + if ((this->unk_256 == 2) && (this->actor.scale.x < 13.0f * 0.001f)) { + this->actor.scale.x += 0.65f * 0.001f; + Actor_SetScale(&this->actor, this->actor.scale.x); + } + + if (this->unk_256 == 9) { + if (this->actor.scale.x > 0.65f * 0.001f) { + this->actor.scale.x -= 0.65f * 0.001f; + Actor_SetScale(&this->actor, this->actor.scale.x); + func_80BF5EBC(this, globalCtx); + func_800B9010(&this->actor, NA_SE_EN_COMMON_EXTINCT_LEV - SFX_FLAG); + } else { + this->actor.draw = NULL; + } + } +} + +void func_80BF67A8(EnOsk* this) { + if ((this->unk_256 != 1) && (this->unk_256 != 8)) { + this->actor.draw = EnOsk_Draw; + Actor_SetScale(&this->actor, 0.013f); + } + + switch (this->unk_256) { + case 1: + this->actor.draw = NULL; + break; + + case 2: + func_80BF5E68(this, D_80BF6FE4, 2, -5.0f); + break; + + case 3: + func_80BF5E68(this, D_80BF6FE4, 8, -5.0f); + break; + + case 4: + func_80BF5E68(this, D_80BF6FE4, 4, -5.0f); + break; + + case 5: + func_80BF5E68(this, D_80BF6FE4, 6, -5.0f); + break; + + case 6: + func_80BF5E68(this, D_80BF6FE4, 10, -5.0f); + break; + + case 7: + case 8: + func_80BF5E00(this, D_80BF6FE4, 0, -5.0f); + break; + + case 9: + func_80BF5E68(this, D_80BF6FE4, 12, -5.0f); + break; + } +} + +void func_80BF68E0(EnOsk* this) { + if (this->actor.draw != NULL) { + switch (this->unk_254) { + case 1: + case 7: + if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 6.0f) || + Animation_OnFrame(&this->skelAnime, 11.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEBU_HEAD_UP); + } + break; + + case 2: + if (Animation_OnFrame(&this->skelAnime, 4.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEBU_HEAD_UP); + } + break; + + case 4: + if (Animation_OnFrame(&this->skelAnime, 5.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEBU_HEAD_UP); + } + break; + + case 5: + if ((Animation_OnFrame(&this->skelAnime, 6.0f)) || Animation_OnFrame(&this->skelAnime, 11.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEBU_HEAD_UP); + } + break; + + case 8: + if (Animation_OnFrame(&this->skelAnime, 13.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEBU_HEAD_UP); + } + break; + } + } +} + +void func_80BF6A20(EnOsk* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + switch (this->unk_254) { + case 2: + func_80BF5E00(this, D_80BF6FE4, 1, -5.0f); + break; + + case 8: + func_80BF5E00(this, D_80BF6FE4, 7, -5.0f); + break; + + case 4: + func_80BF5E00(this, D_80BF6FE4, 3, -5.0f); + break; + + case 6: + func_80BF5E00(this, D_80BF6FE4, 5, -5.0f); + break; + + case 10: + func_80BF5E00(this, D_80BF6FE4, 9, -5.0f); + break; + + case 12: + func_80BF5E00(this, D_80BF6FE4, 11, -5.0f); + break; + } + } + + if (Cutscene_CheckActorAction(globalCtx, this->unk_258)) { + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, Cutscene_GetActorActionIndex(globalCtx, this->unk_258)); + if (this->unk_256 != + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->unk_258)]->action) { + this->unk_256 = + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->unk_258)]->action; + func_80BF67A8(this); + } + func_80BF68E0(this); + } else { + this->actor.draw = NULL; + } + + if (this->unk_256 == 8) { + if (this->actor.scale.x > 0.65f * 0.001f) { + this->actor.scale.x -= 0.65f * 0.001f; + Actor_SetScale(&this->actor, this->actor.scale.x); + func_80BF5EBC(this, globalCtx); + func_800B9010(&this->actor, NA_SE_EN_COMMON_EXTINCT_LEV - SFX_FLAG); + } else { + this->actor.draw = NULL; + } + } +} + +void EnOsk_Update(Actor* thisx, GlobalContext* globalCtx) { + EnOsk* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void func_80BF6C54(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnOsk* this = THIS; + + if (limbIndex == 1) { + Matrix_MultiplyVector3fByState(&D_80BF7024, &this->actor.focus.pos); + } +} + +void EnOsk_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnOsk* this = THIS; + Gfx* gfx; + Vec3f sp80; + s32 pad2[4]; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Gfx_PrimColor(globalCtx->state.gfxCtx, 0x80, 255, 255, 255, 255)); + + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + NULL, func_80BF6C54, &this->actor); + + { + s16 sp62; + s16 sp60; + Vec3f sp54; + + sp54 = GET_ACTIVE_CAM(globalCtx)->eye; + + sp62 = Math_Vec3f_Yaw(&sp54, &this->actor.focus.pos); + sp60 = -Math_Vec3f_Pitch(&sp54, &this->actor.focus.pos); + + sp80.x = -(15.0f * (Math_SinS(sp62)) * Math_CosS(sp60)); + sp80.y = -(Math_SinS(sp60) * 15.0f); + sp80.z = -(15.0f * (Math_CosS(sp62)) * Math_CosS(sp60)); + + Matrix_InsertTranslation(this->actor.focus.pos.x + sp80.x, this->actor.focus.pos.y + sp80.y, + sp80.z = this->actor.focus.pos.z + sp80.z, MTXMODE_NEW); + + sp80.z = Math_SinS(globalCtx->gameplayFrames << 0xE); + sp80.z = ((sp80.z + 1.0f) * 0.1f) + 2.0f; + Matrix_Scale(this->actor.scale.x * sp80.z, this->actor.scale.y * sp80.z, this->actor.scale.z * sp80.z, + MTXMODE_APPLY); + } + + gfx = func_8012C868(POLY_XLU_DISP); + + gSPSetOtherMode(gfx++, G_SETOTHERMODE_H, 4, 4, 0x00000080); + if (1) {} + if (1) {} + if (1) {} + gDPSetCombineLERP(gfx++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0); + gSPDisplayList(gfx++, gameplay_keep_DL_029CB0); + gDPSetPrimColor(gfx++, 0, 0, 130, 0, 255, 100); + gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(gfx++, gameplay_keep_DL_029CF0); + + POLY_XLU_DISP = gfx; + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Osk/z_en_osk.h b/src/overlays/actors/ovl_En_Osk/z_en_osk.h index f98437897a..9515e97059 100644 --- a/src/overlays/actors/ovl_En_Osk/z_en_osk.h +++ b/src/overlays/actors/ovl_En_Osk/z_en_osk.h @@ -7,9 +7,20 @@ struct EnOsk; typedef void (*EnOskActionFunc)(struct EnOsk*, GlobalContext*); +#define ENOSK_GET_F(thisx) ((thisx)->params & 0xF) + +#define ENOSK_1 1 +#define ENOSK_2 2 + typedef struct EnOsk { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x11C]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[17]; + /* 0x01EE */ Vec3s morphTable[17]; + /* 0x0254 */ s16 unk_254; + /* 0x0256 */ s16 unk_256; + /* 0x0258 */ u16 unk_258; + /* 0x025C */ f32 unk_25C; /* 0x0260 */ EnOskActionFunc actionFunc; } EnOsk; // size = 0x264 diff --git a/src/overlays/actors/ovl_En_Osn/z_en_osn.c b/src/overlays/actors/ovl_En_Osn/z_en_osn.c index 620d4450a3..48a87b30ef 100644 --- a/src/overlays/actors/ovl_En_Osn/z_en_osn.c +++ b/src/overlays/actors/ovl_En_Osn/z_en_osn.c @@ -324,7 +324,8 @@ s32 func_80AD0B38(EnOsn* this, GlobalContext* globalCtx) { break; } this->unk_1EA |= 0x20; - if (gSaveContext.day == 3 && gSaveContext.time >= CLOCK_TIME(5, 0) && gSaveContext.time < CLOCK_TIME(6, 0)) { + if (gSaveContext.save.day == 3 && gSaveContext.save.time >= CLOCK_TIME(5, 0) && + gSaveContext.save.time < CLOCK_TIME(6, 0)) { return 0x2006; } return 0x1FCD; @@ -333,13 +334,13 @@ s32 func_80AD0B38(EnOsn* this, GlobalContext* globalCtx) { s32 func_80AD0E10(EnOsn* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if ((gSaveContext.inventory.items[SLOT_OCARINA] != ITEM_NONE) && CHECK_QUEST_ITEM(QUEST_SONG_HEALING)) { + if ((gSaveContext.save.inventory.items[SLOT_OCARINA] != ITEM_NONE) && CHECK_QUEST_ITEM(QUEST_SONG_HEALING)) { if (this->unk_1EA & 1) { this->unk_1EA |= 0x20; - if ((gSaveContext.inventory.items[SLOT_OCARINA] != ITEM_NONE) && + if ((gSaveContext.save.inventory.items[SLOT_OCARINA] != ITEM_NONE) && (INV_CONTENT(ITEM_MASK_DEKU) == ITEM_MASK_DEKU)) { - if ((gSaveContext.day == 3) && (gSaveContext.time >= CLOCK_TIME(5, 0)) && - (gSaveContext.time < CLOCK_TIME(6, 0))) { + if ((gSaveContext.save.day == 3) && (gSaveContext.save.time >= CLOCK_TIME(5, 0)) && + (gSaveContext.save.time < CLOCK_TIME(6, 0))) { return 0x2006; } return 0x1FCD; @@ -350,8 +351,8 @@ s32 func_80AD0E10(EnOsn* this, GlobalContext* globalCtx) { if (player->transformation == PLAYER_FORM_DEKU) { if (this->unk_1EA & 4) { this->unk_1EA |= 0x20; - if ((gSaveContext.day == 3) && (gSaveContext.time >= CLOCK_TIME(5, 0)) && - (gSaveContext.time < CLOCK_TIME(6, 0))) { + if ((gSaveContext.save.day == 3) && (gSaveContext.save.time >= CLOCK_TIME(5, 0)) && + (gSaveContext.save.time < CLOCK_TIME(6, 0))) { return 0x2006; } return 0x1FCD; @@ -363,43 +364,43 @@ s32 func_80AD0E10(EnOsn* this, GlobalContext* globalCtx) { if (player->transformation == PLAYER_FORM_GORON) { if (this->unk_1EA & 8) { this->unk_1EA |= 0x20; - if ((gSaveContext.day == 3) && (gSaveContext.time >= CLOCK_TIME(5, 0)) && - (gSaveContext.time < CLOCK_TIME(6, 0))) { + if ((gSaveContext.save.day == 3) && (gSaveContext.save.time >= CLOCK_TIME(5, 0)) && + (gSaveContext.save.time < CLOCK_TIME(6, 0))) { return 0x2006; } return 0x1FCD; } this->unk_1EA |= 8; - if (gSaveContext.weekEventReg[76] & 0x20) { + if (gSaveContext.save.weekEventReg[76] & 0x20) { return 0x1FC8; } - gSaveContext.weekEventReg[76] |= 0x20; + gSaveContext.save.weekEventReg[76] |= 0x20; return 0x1FCE; } if (player->transformation == PLAYER_FORM_ZORA) { if (this->unk_1EA & 0x10) { this->unk_1EA |= 0x20; - if ((gSaveContext.day == 3) && (gSaveContext.time >= CLOCK_TIME(5, 0)) && - (gSaveContext.time < CLOCK_TIME(6, 0))) { + if ((gSaveContext.save.day == 3) && (gSaveContext.save.time >= CLOCK_TIME(5, 0)) && + (gSaveContext.save.time < CLOCK_TIME(6, 0))) { return 0x2006; } return 0x1FCD; } this->unk_1EA |= 0x10; - if (gSaveContext.weekEventReg[76] & 0x40) { + if (gSaveContext.save.weekEventReg[76] & 0x40) { return 0x1FC8; } - gSaveContext.weekEventReg[76] |= 0x40; + gSaveContext.save.weekEventReg[76] |= 0x40; return 0x1FD0; } if (Player_GetMask(globalCtx) == PLAYER_MASK_NONE) { if (this->unk_1EA & 2) { this->unk_1EA |= 0x20; - if ((gSaveContext.day == 3) && (gSaveContext.time >= CLOCK_TIME(5, 0)) && - (gSaveContext.time < CLOCK_TIME(6, 0))) { + if ((gSaveContext.save.day == 3) && (gSaveContext.save.time >= CLOCK_TIME(5, 0)) && + (gSaveContext.save.time < CLOCK_TIME(6, 0))) { return 0x2006; } return 0x1FCD; @@ -412,7 +413,8 @@ s32 func_80AD0E10(EnOsn* this, GlobalContext* globalCtx) { } this->unk_1EA |= 0x20; - if ((gSaveContext.day == 3) && (gSaveContext.time >= CLOCK_TIME(5, 0)) && (gSaveContext.time < CLOCK_TIME(6, 0))) { + if ((gSaveContext.save.day == 3) && (gSaveContext.save.time >= CLOCK_TIME(5, 0)) && + (gSaveContext.save.time < CLOCK_TIME(6, 0))) { return 0x2004; } @@ -430,8 +432,8 @@ void func_80AD10FC(EnOsn* this, GlobalContext* globalCtx) { break; case 0x1FCA: - if ((gSaveContext.day == 3 && gSaveContext.time >= CLOCK_TIME(5, 0)) && - gSaveContext.time < CLOCK_TIME(6, 0)) { + if ((gSaveContext.save.day == 3 && gSaveContext.save.time >= CLOCK_TIME(5, 0)) && + gSaveContext.save.time < CLOCK_TIME(6, 0)) { this->unk_1F4 = 0x2007; } else { this->unk_1F4 = 0x1FCB; @@ -579,10 +581,11 @@ void func_80AD10FC(EnOsn* this, GlobalContext* globalCtx) { void func_80AD1398(EnOsn* this) { this->cutscene = this->actor.cutscene; - if ((gSaveContext.inventory.items[SLOT_OCARINA] == ITEM_NONE) || (INV_CONTENT(ITEM_MASK_DEKU) == ITEM_MASK_DEKU)) { + if ((gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) || + (INV_CONTENT(ITEM_MASK_DEKU) == ITEM_MASK_DEKU)) { this->cutscene = ActorCutscene_GetAdditionalCutscene(this->cutscene); - if ((gSaveContext.inventory.items[SLOT_OCARINA] != ITEM_NONE) || + if ((gSaveContext.save.inventory.items[SLOT_OCARINA] != ITEM_NONE) || (INV_CONTENT(ITEM_MASK_DEKU) == ITEM_MASK_DEKU)) { this->cutscene = ActorCutscene_GetAdditionalCutscene(this->cutscene); } @@ -604,7 +607,7 @@ void func_80AD144C(EnOsn* this, GlobalContext* globalCtx) { void func_80AD14C8(EnOsn* this, GlobalContext* globalCtx) { s16 temp_v1 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - if (gSaveContext.inventory.items[SLOT_OCARINA] != ITEM_NONE && !CHECK_QUEST_ITEM(QUEST_SONG_HEALING)) { + if (gSaveContext.save.inventory.items[SLOT_OCARINA] != ITEM_NONE && !CHECK_QUEST_ITEM(QUEST_SONG_HEALING)) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_80AD1634; } else if ((((this->actor.xzDistToPlayer < 100.0f) || this->actor.isTargeted) && (temp_v1 < 0x4000)) && @@ -746,7 +749,7 @@ void func_80AD16A8(EnOsn* this, GlobalContext* globalCtx) { void func_80AD19A0(EnOsn* this, GlobalContext* globalCtx) { u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); - if ((temp_v0 == 6 || temp_v0 == 5) && func_80147624(globalCtx)) { + if ((temp_v0 == 6 || temp_v0 == 5) && Message_ShouldAdvance(globalCtx)) { if (this->unk_1EA & 0x20) { this->unk_1EA &= ~0x20; globalCtx->msgCtx.msgMode = 0x43; @@ -774,17 +777,17 @@ void EnOsn_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_1FA = 255; switch (ENOSN_GET_3(&this->actor)) { case 0: - if (((gSaveContext.entranceIndex == 0xC020) || (gSaveContext.entranceIndex == 0xC030)) || - (gSaveContext.entranceIndex == 0xC060)) { + if (((gSaveContext.save.entranceIndex == 0xC020) || (gSaveContext.save.entranceIndex == 0xC030)) || + (gSaveContext.save.entranceIndex == 0xC060)) { this->unk_1EA |= 1; } this->unk_1F0 = 1; if (globalCtx->sceneNum == SCENE_INSIDETOWER) { - if ((gSaveContext.entranceIndex == 0xC020) || (gSaveContext.entranceIndex == 0xC060)) { + if ((gSaveContext.save.entranceIndex == 0xC020) || (gSaveContext.save.entranceIndex == 0xC060)) { this->actionFunc = func_80AD16A8; return; } - if (gSaveContext.entranceIndex == 0xC030) { + if (gSaveContext.save.entranceIndex == 0xC030) { func_80AD1398(this); this->actionFunc = func_80AD1634; return; @@ -894,7 +897,7 @@ void EnOsn_Draw(Actor* thisx, GlobalContext* globalCtx) { if (this->unk_1FA == 0xFF) { func_8012C28C(globalCtx->state.gfxCtx); if ((this->unk_1EC == 0xB) || (this->unk_1EC == 0xC) || (this->unk_1EC == 0x17) || - (globalCtx->msgCtx.unk11F04 == 0x1FCA)) { + (globalCtx->msgCtx.currentTextId == 0x1FCA)) { gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80AD258C)); gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80AD2594)); } else if ((this->unk_1EC == 7) || (this->unk_1EC == 3) || (this->unk_1EC == 0xD)) { diff --git a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c index 7e32762637..3464314b11 100644 --- a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c +++ b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c @@ -6,8 +6,6 @@ #include "z_en_ossan.h" #include "objects/gameplay_keep/gameplay_keep.h" -#include "objects/object_fsn/object_fsn.h" -#include "objects/object_ani/object_ani.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) @@ -20,17 +18,19 @@ void EnOssan_Init(Actor* thisx, GlobalContext* globalCtx); void EnOssan_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnOssan_Update(Actor* thisx, GlobalContext* globalCtx); -void EnOssan_DrawCuriosityShopMan(Actor* thisx, GlobalContext* globalCtx); -void EnOssan_DrawPartTimeWorker(Actor* thisx, GlobalContext* globalCtx); +void EnOssan_CuriosityShopMan_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnOssan_PartTimeWorker_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnOssan_CuriosityShopMan_Init(EnOssan* this, GlobalContext* globalCtx); +u16 EnOssan_CuriosityShopMan_GetWelcome(EnOssan* this, GlobalContext* globalCtx); + +void EnOssan_PartTimeWorker_Init(EnOssan* this, GlobalContext* globalCtx); +u16 EnOssan_PartTimerWorker_GetWelcome(EnOssan* this, GlobalContext* globalCtx); -void EnOssan_InitCuriosityShopMan(EnOssan* this, GlobalContext* globalCtx); -void EnOssan_InitPartTimeWorker(EnOssan* this, GlobalContext* globalCtx); -u16 EnOssan_GetWelcomeCuriosityShopMan(EnOssan* this, GlobalContext* globalCtx); void EnOssan_InitShop(EnOssan* this, GlobalContext* globalCtx); void EnOssan_Idle(EnOssan* this, GlobalContext* globalCtx); void EnOssan_BeginInteraction(EnOssan* this, GlobalContext* globalCtx); void EnOssan_Hello(EnOssan* this, GlobalContext* globalCtx); -u16 EnOssan_GetWelcomePartTimeWorker(EnOssan* this, GlobalContext* globalCtx); void EnOssan_SetHaveMet(EnOssan* this); void EnOssan_StartShopping(GlobalContext* globalCtx, EnOssan* this); void EnOssan_FaceShopkeeper(EnOssan* this, GlobalContext* globalCtx); @@ -53,6 +53,45 @@ void EnOssan_GetCutscenes(EnOssan* this, GlobalContext* globalCtx); s32 EnOssan_ReturnItemToShelf(EnOssan* this); s32 EnOssan_TakeItemOffShelf(EnOssan* this); +typedef enum { + /* 0 */ ENOSSAN_CUTSCENESTATE_STOPPED, + /* 1 */ ENOSSAN_CUTSCENESTATE_WAITING, + /* 2 */ ENOSSAN_CUTSCENESTATE_PLAYING +} EnOssanCutsceneState; + +typedef enum { + /* 00 */ FSN_ANIMATION_IDLE, + /* 01 */ FSN_ANIMATION_SCRATCH_BACK, + /* 02 */ FSN_ANIMATION_TURN_AROUND_FORWARD, + /* 03 */ FSN_ANIMATION_TURN_AROUND_REVERSE, + /* 04 */ FSN_ANIMATION_HANDS_ON_COUNTER_START, + /* 05 */ FSN_ANIMATION_HANDS_ON_COUNTER_LOOP, + /* 06 */ FSN_ANIMATION_HAND_ON_FACE_START, + /* 07 */ FSN_ANIMATION_HAND_ON_FACE_LOOP, + /* 08 */ FSN_ANIMATION_LEAN_FORWARD_START, + /* 09 */ FSN_ANIMATION_LEAN_FORWARD_LOOP, + /* 10 */ FSN_ANIMATION_SLAM_COUNTER_START, + /* 11 */ FSN_ANIMATION_SLAM_COUNTER_LOOP, + /* 12 */ FSN_ANIMATION_MAKE_OFFER, + /* 13 */ FSN_ANIMATION_MAX +} FsnAnimation; + +typedef enum { + /* 00 */ ANI_ANIMATION_STANDING_NORMAL_LOOP_1, + /* 01 */ ANI_ANIMATION_STANDING_NORMAL_LOOP_2, + /* 02 */ ANI_ANIMATION_STANDING_NORMAL_ONCE_FORWARD_1, + /* 03 */ ANI_ANIMATION_STANDING_NORMAL_ONCE_REVERSE, + /* 04 */ ANI_ANIMATION_STANDING_NORMAL_ONCE_FORWARD_2, + /* 05 */ ANI_ANIMATION_STANDING_NORMAL_LOOP_3, + /* 06 */ ANI_ANIMATION_STANDING_NORMAL_ONCE_FORWARD_3, + /* 07 */ ANI_ANIMATION_STANDING_NORMAL_LOOP_4, + /* 08 */ ANI_ANIMATION_APOLOGY_START, + /* 09 */ ANI_ANIMATION_APOLOGY_LOOP, + /* 10 */ ANI_ANIMATION_STANDING_NORMAL_ONCE_FORWARD_4, + /* 11 */ ANI_ANIMATION_STANDING_NORMAL_LOOP_5, + /* 12 */ ANI_ANIMATION_MAX +} AniAnimation; + const ActorInit En_Ossan_InitVars = { ACTOR_EN_OSSAN, ACTORCAT_NPC, @@ -66,19 +105,19 @@ const ActorInit En_Ossan_InitVars = { }; static AnimationInfoS sAnimationsCuriosityShopMan[] = { - { &object_fsn_Anim_012C34, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_fsn_Anim_0131FC, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_fsn_Anim_00C58C, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_fsn_Anim_00C58C, -1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_fsn_Anim_00E3EC, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_fsn_Anim_00F00C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_fsn_Anim_00CB3C, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_fsn_Anim_00D354, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_fsn_Anim_0138B0, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_fsn_Anim_01430C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_fsn_Anim_00B9D8, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_fsn_Anim_00C26C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_fsn_Anim_00DE34, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gFsnIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gFsnScratchBackAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gFsnTurnAroundAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gFsnTurnAroundAnim, -1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gFsnHandsOnCounterStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gFsnHandsOnCounterLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gFsnHandOnFaceStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gFsnHandOnFaceLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gFsnLeanForwardStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gFsnLeanForwardLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gFsnSlamCounterStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gFsnSlamCounterLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gFsnMakeOfferAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, }; static AnimationInfoS sAnimationsPartTimeWorker[] = { @@ -168,10 +207,10 @@ s32 EnOssan_TestItemSelected(GlobalContext* globalCtx) { } void EnOssan_CheckValidSpawn(EnOssan* this) { - switch (gSaveContext.day) { + switch (gSaveContext.save.day) { case 1: case 2: - if (gSaveContext.time <= CLOCK_TIME(21, 30) && gSaveContext.time > CLOCK_TIME(6, 00)) { + if (gSaveContext.save.time <= CLOCK_TIME(21, 30) && gSaveContext.save.time > CLOCK_TIME(6, 00)) { if (this->actor.params != ENOSSAN_CURIOSITY_SHOP_MAN) { Actor_MarkForDeath(&this->actor); } @@ -183,7 +222,7 @@ void EnOssan_CheckValidSpawn(EnOssan* this) { if (this->actor.params == ENOSSAN_CURIOSITY_SHOP_MAN) { Actor_MarkForDeath(&this->actor); } - if (!(gSaveContext.time <= CLOCK_TIME(22, 00) && gSaveContext.time >= CLOCK_TIME(6, 00))) { + if (!(gSaveContext.save.time <= CLOCK_TIME(22, 00) && gSaveContext.save.time >= CLOCK_TIME(6, 00))) { if (this->actor.params != ENOSSAN_CURIOSITY_SHOP_MAN) { Actor_MarkForDeath(&this->actor); } @@ -352,9 +391,9 @@ void EnOssan_Idle(EnOssan* this, GlobalContext* globalCtx) { void EnOssan_BeginInteraction(EnOssan* this, GlobalContext* globalCtx) { AnimationInfoS* animations = sAnimations[this->actor.params]; s16 curFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(animations[this->animationIdx].animation); + s16 frameCount = Animation_GetLastFrame(animations[this->animationIndex].animation); - if (this->animationIdx == 3) { + if (this->animationIndex == FSN_ANIMATION_TURN_AROUND_REVERSE) { frameCount = 0; } if (this->cutsceneState == ENOSSAN_CUTSCENESTATE_WAITING) { @@ -367,47 +406,47 @@ void EnOssan_BeginInteraction(EnOssan* this, GlobalContext* globalCtx) { } if (this->actor.params == ENOSSAN_CURIOSITY_SHOP_MAN) { if (curFrame == frameCount) { - switch (this->animationIdx) { - case 1: - this->animationIdx = 2; - SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, 2); + switch (this->animationIndex) { + case FSN_ANIMATION_SCRATCH_BACK: + this->animationIndex = FSN_ANIMATION_TURN_AROUND_FORWARD; + SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, FSN_ANIMATION_TURN_AROUND_FORWARD); break; - case 2: + case FSN_ANIMATION_TURN_AROUND_FORWARD: EnOssan_SetHaveMet(this); - this->textId = EnOssan_GetWelcomeCuriosityShopMan(this, globalCtx); - SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, this->animationIdx); + this->textId = EnOssan_CuriosityShopMan_GetWelcome(this, globalCtx); + SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, this->animationIndex); break; - case 4: - case 6: - case 8: - case 10: - this->animationIdx++; - SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, this->animationIdx); + case FSN_ANIMATION_HANDS_ON_COUNTER_START: + case FSN_ANIMATION_HAND_ON_FACE_START: + case FSN_ANIMATION_LEAN_FORWARD_START: + case FSN_ANIMATION_SLAM_COUNTER_START: + this->animationIndex++; + SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, this->animationIndex); Message_StartTextbox(globalCtx, this->textId, &this->actor); EnOssan_SetupStartShopping(globalCtx, this, false); break; - case 5: - case 7: - case 9: - case 11: - this->animationIdx = 3; - SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, 3); + case FSN_ANIMATION_HANDS_ON_COUNTER_LOOP: + case FSN_ANIMATION_HAND_ON_FACE_LOOP: + case FSN_ANIMATION_LEAN_FORWARD_LOOP: + case FSN_ANIMATION_SLAM_COUNTER_LOOP: + this->animationIndex = FSN_ANIMATION_TURN_AROUND_REVERSE; + SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, FSN_ANIMATION_TURN_AROUND_REVERSE); break; - case 3: - this->animationIdx = 1; - SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, 1); + case FSN_ANIMATION_TURN_AROUND_REVERSE: + this->animationIndex = FSN_ANIMATION_SCRATCH_BACK; + SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, FSN_ANIMATION_SCRATCH_BACK); EnOssan_SetupAction(this, EnOssan_Idle); break; default: - this->animationIdx = 1; - SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, 1); + this->animationIndex = FSN_ANIMATION_SCRATCH_BACK; + SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, FSN_ANIMATION_SCRATCH_BACK); EnOssan_SetupAction(this, EnOssan_Idle); break; } } } else { EnOssan_SetHaveMet(this); - this->textId = EnOssan_GetWelcomePartTimeWorker(this, globalCtx); + this->textId = EnOssan_PartTimerWorker_GetWelcome(this, globalCtx); Message_StartTextbox(globalCtx, this->textId, &this->actor); EnOssan_SetupStartShopping(globalCtx, this, false); } @@ -524,9 +563,9 @@ void EnOssan_Hello(EnOssan* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); EnOssan_RotateHead(this, globalCtx); - if (talkState == 5 && func_80147624(globalCtx)) { - if (this->animationIdx == 9 && this->actor.params == ENOSSAN_PART_TIME_WORKER) { - this->animationIdx = 1; + if (talkState == 5 && Message_ShouldAdvance(globalCtx)) { + if ((this->animationIndex == ANI_ANIMATION_APOLOGY_LOOP) && (this->actor.params == ENOSSAN_PART_TIME_WORKER)) { + this->animationIndex = ANI_ANIMATION_STANDING_NORMAL_LOOP_2; SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, 1); } this->flags &= ~LOOKED_AT_PLAYER; @@ -541,12 +580,12 @@ void EnOssan_Hello(EnOssan* this, GlobalContext* globalCtx) { return; } } - if (talkState == 10 && this->actor.params == ENOSSAN_PART_TIME_WORKER && - player->transformation == PLAYER_FORM_ZORA && func_80147624(globalCtx)) { - this->animationIdx = 9; - SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, 9); + if ((talkState == 10) && (this->actor.params == ENOSSAN_PART_TIME_WORKER) && + (player->transformation == PLAYER_FORM_ZORA) && Message_ShouldAdvance(globalCtx)) { + this->animationIndex = ANI_ANIMATION_APOLOGY_LOOP; + SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, ANI_ANIMATION_APOLOGY_LOOP); } - if (this->animationIdx == 11 && Animation_OnFrame(&this->skelAnime, 18.0f)) { + if ((this->animationIndex == FSN_ANIMATION_SLAM_COUNTER_LOOP) && Animation_OnFrame(&this->skelAnime, 18.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HANKO); } } @@ -558,8 +597,8 @@ s32 EnOssan_FacingShopkeeperDialogResult(EnOssan* this, GlobalContext* globalCtx switch (globalCtx->msgCtx.choiceIndex) { case 0: func_8019F208(); - if (this->actor.params == ENOSSAN_PART_TIME_WORKER && player->transformation == PLAYER_FORM_ZORA) { - this->animationIdx = 9; + if ((this->actor.params == ENOSSAN_PART_TIME_WORKER) && (player->transformation == PLAYER_FORM_ZORA)) { + this->animationIndex = ANI_ANIMATION_APOLOGY_LOOP; SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, 9); } EnOssan_SetupAction(this, EnOssan_TalkToShopkeeper); @@ -593,7 +632,7 @@ void EnOssan_FaceShopkeeper(EnOssan* this, GlobalContext* globalCtx) { if (talkState == 4) { func_8011552C(globalCtx, 6); if (!EnOssan_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx)) && - (!func_80147624(globalCtx) || !EnOssan_FacingShopkeeperDialogResult(this, globalCtx))) { + (!Message_ShouldAdvance(globalCtx) || !EnOssan_FacingShopkeeperDialogResult(this, globalCtx))) { if (this->stickAccumX < 0) { cursorIdx = EnOssan_SetCursorIndexFromNeutral(this, 4); if (cursorIdx != CURSOR_INVALID) { @@ -626,9 +665,9 @@ void EnOssan_FaceShopkeeper(EnOssan* this, GlobalContext* globalCtx) { void EnOssan_TalkToShopkeeper(EnOssan* this, GlobalContext* globalCtx) { AnimationInfoS* animations = sAnimations[this->actor.params]; - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { - if (this->animationIdx == 9 && this->actor.params == ENOSSAN_PART_TIME_WORKER) { - this->animationIdx = 1; + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { + if ((this->animationIndex == ANI_ANIMATION_APOLOGY_LOOP) && (this->actor.params == ENOSSAN_PART_TIME_WORKER)) { + this->animationIndex = ANI_ANIMATION_STANDING_NORMAL_LOOP_2; SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, 1); } EnOssan_StartShopping(globalCtx, this); @@ -1014,7 +1053,7 @@ void EnOssan_SelectItem(EnOssan* this, GlobalContext* globalCtx) { if (EnOssan_TakeItemOffShelf(this) && talkState == 4) { func_8011552C(globalCtx, 6); - if (!EnOssan_TestCancelOption(this, globalCtx, CONTROLLER1(globalCtx)) && func_80147624(globalCtx)) { + if (!EnOssan_TestCancelOption(this, globalCtx, CONTROLLER1(globalCtx)) && Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: EnOssan_HandleCanBuyItem(globalCtx, this); @@ -1030,7 +1069,7 @@ void EnOssan_SelectItem(EnOssan* this, GlobalContext* globalCtx) { } void EnOssan_CannotBuy(EnOssan* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { this->actionFunc = this->tmpActionFunc; func_80151938(globalCtx, this->items[this->cursorIdx]->actor.textId); } @@ -1039,7 +1078,7 @@ void EnOssan_CannotBuy(EnOssan* this, GlobalContext* globalCtx) { void EnOssan_CanBuy(EnOssan* this, GlobalContext* globalCtx) { EnGirlA* item; - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { this->shopItemSelectedTween = 0.0f; EnOssan_ResetItemPosition(this); item = this->items[this->cursorIdx]; @@ -1059,7 +1098,7 @@ void EnOssan_BuyItemWithFanfare(EnOssan* this, GlobalContext* globalCtx) { } void EnOssan_SetupItemPurchased(EnOssan* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 6 && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; EnOssan_SetupAction(this, EnOssan_ItemPurchased); @@ -1081,7 +1120,7 @@ void EnOssan_ContinueShopping(EnOssan* this, GlobalContext* globalCtx) { if (talkState == 4) { func_8011552C(globalCtx, 6); - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { EnOssan_ResetItemPosition(this); item = this->items[this->cursorIdx]; item->restockFunc(globalCtx, item); @@ -1103,7 +1142,7 @@ void EnOssan_ContinueShopping(EnOssan* this, GlobalContext* globalCtx) { } } } - } else if (talkState == 5 && func_80147624(globalCtx)) { + } else if (talkState == 5 && Message_ShouldAdvance(globalCtx)) { EnOssan_ResetItemPosition(this); item = this->items[this->cursorIdx]; item->restockFunc(globalCtx, item); @@ -1238,10 +1277,7 @@ void EnOssan_UpdateCursorAnim(EnOssan* this) { void EnOssan_UpdateStickDirectionPromptAnim(EnOssan* this) { f32 arrowAnimTween = this->arrowAnimTween; f32 stickAnimTween = this->stickAnimTween; - - // Possibly Fake - s32 maxColor = 255; - f32 tmp; + s32 maxColor = 255; // POSSIBLY FAKE if (this->arrowAnimState == 0) { arrowAnimTween += 0.05f; @@ -1268,31 +1304,33 @@ void EnOssan_UpdateStickDirectionPromptAnim(EnOssan* this) { stickAnimTween = 0.0f; this->stickAnimState = 0; } - - tmp = 155.0f * arrowAnimTween; - this->stickAnimTween = stickAnimTween; this->stickLeftPrompt.arrowColor.r = COL_CHAN_MIX(255, 155.0f, arrowAnimTween); this->stickLeftPrompt.arrowColor.g = COL_CHAN_MIX(maxColor, 155.0f, arrowAnimTween); - this->stickLeftPrompt.arrowColor.b = COL_CHAN_MIX(0, -100, arrowAnimTween); + this->stickLeftPrompt.arrowColor.b = COL_CHAN_MIX(0, -100.0f, arrowAnimTween); this->stickLeftPrompt.arrowColor.a = COL_CHAN_MIX(200, 50.0f, arrowAnimTween); - this->stickRightPrompt.arrowColor.r = (maxColor - ((s32)tmp)) & 0xFF; - this->stickRightPrompt.arrowColor.g = (255 - ((s32)tmp)) & 0xFF; + this->stickRightPrompt.arrowTexX = 290.0f; + + this->stickRightPrompt.arrowColor.r = COL_CHAN_MIX(maxColor, 155.0f, arrowAnimTween); + this->stickRightPrompt.arrowColor.g = COL_CHAN_MIX(255, 155.0f, arrowAnimTween); this->stickRightPrompt.arrowColor.b = COL_CHAN_MIX(0, -100.0f, arrowAnimTween); this->stickRightPrompt.arrowColor.a = COL_CHAN_MIX(200, 50.0f, arrowAnimTween); - this->stickRightPrompt.arrowTexX = 290.0f; this->stickLeftPrompt.arrowTexX = 33.0f; this->stickRightPrompt.stickTexX = 274.0f; this->stickRightPrompt.stickTexX += 8.0f * stickAnimTween; + this->stickLeftPrompt.stickTexX = 49.0f; this->stickLeftPrompt.stickTexX -= 8.0f * stickAnimTween; - this->stickLeftPrompt.arrowTexY = this->stickRightPrompt.arrowTexY = 91.0f; - this->stickLeftPrompt.stickTexY = this->stickRightPrompt.stickTexY = 95.0f; + this->stickRightPrompt.arrowTexY = 91.0f; + this->stickLeftPrompt.arrowTexY = 91.0f; + + this->stickRightPrompt.stickTexY = 95.0f; + this->stickLeftPrompt.stickTexY = 95.0f; } void EnOssan_WaitForBlink(EnOssan* this) { @@ -1324,52 +1362,52 @@ void EnOssan_Blink(EnOssan* this) { } } -void EnOssan_InitCuriosityShopMan(EnOssan* this, GlobalContext* globalCtx) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_fsn_Skel_013320, &object_fsn_Anim_012C34, this->jointTable, - this->morphTable, 19); - this->actor.draw = EnOssan_DrawCuriosityShopMan; +void EnOssan_CuriosityShopMan_Init(EnOssan* this, GlobalContext* globalCtx) { + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gFsnSkel, &gFsnIdleAnim, this->jointTable, this->morphTable, + ENOSSAN_LIMB_MAX); + this->actor.draw = EnOssan_CuriosityShopMan_Draw; } -void EnOssan_InitPartTimeWorker(EnOssan* this, GlobalContext* globalCtx) { +void EnOssan_PartTimeWorker_Init(EnOssan* this, GlobalContext* globalCtx) { SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gAniSkeleton, &gAniStandingNormalAnim, this->jointTable, this->morphTable, 16); - this->actor.draw = EnOssan_DrawPartTimeWorker; + this->actor.draw = EnOssan_PartTimeWorker_Draw; } -u16 EnOssan_GetWelcomeCuriosityShopMan(EnOssan* this, GlobalContext* globalCtx) { +u16 EnOssan_CuriosityShopMan_GetWelcome(EnOssan* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); u16 textId = Text_GetFaceReaction(globalCtx, 0x2F); if (textId != 0) { - this->animationIdx = 4; + this->animationIndex = FSN_ANIMATION_HANDS_ON_COUNTER_START; this->flags |= END_INTERACTION; return textId; } switch (player->transformation) { case PLAYER_FORM_DEKU: - this->animationIdx = 10; - if (gSaveContext.weekEventReg[18] & 0x10) { + this->animationIndex = FSN_ANIMATION_SLAM_COUNTER_START; + if (gSaveContext.save.weekEventReg[18] & 0x10) { return sWelcomeDekuTextIds[ENOSSAN_CURIOSITY_SHOP_MAN]; } return sWelcomeDekuFirstTimeTextIds[ENOSSAN_CURIOSITY_SHOP_MAN]; case PLAYER_FORM_ZORA: - this->animationIdx = 8; - if (gSaveContext.weekEventReg[18] & 8) { + this->animationIndex = FSN_ANIMATION_LEAN_FORWARD_START; + if (gSaveContext.save.weekEventReg[18] & 8) { return sWelcomeZoraTextIds[ENOSSAN_CURIOSITY_SHOP_MAN]; } return sWelcomeZoraFirstTimeTextIds[ENOSSAN_CURIOSITY_SHOP_MAN]; case PLAYER_FORM_GORON: - this->animationIdx = 6; - if (gSaveContext.weekEventReg[18] & 4) { + this->animationIndex = FSN_ANIMATION_HAND_ON_FACE_START; + if (gSaveContext.save.weekEventReg[18] & 4) { return sWelcomeGoronTextIds[ENOSSAN_CURIOSITY_SHOP_MAN]; } return sWelcomeGoronFirstTimeTextIds[ENOSSAN_CURIOSITY_SHOP_MAN]; } - this->animationIdx = 4; + this->animationIndex = FSN_ANIMATION_HANDS_ON_COUNTER_START; return sWelcomeHumanTextIds[ENOSSAN_CURIOSITY_SHOP_MAN]; } -u16 EnOssan_GetWelcomePartTimeWorker(EnOssan* this, GlobalContext* globalCtx) { +u16 EnOssan_PartTimerWorker_GetWelcome(EnOssan* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); u16 textId = Text_GetFaceReaction(globalCtx, 0x36); @@ -1379,17 +1417,17 @@ u16 EnOssan_GetWelcomePartTimeWorker(EnOssan* this, GlobalContext* globalCtx) { } switch (player->transformation) { case PLAYER_FORM_DEKU: - if (gSaveContext.weekEventReg[55] & 0x10) { + if (gSaveContext.save.weekEventReg[55] & 0x10) { return sWelcomeDekuTextIds[ENOSSAN_PART_TIME_WORKER]; } return sWelcomeDekuFirstTimeTextIds[ENOSSAN_PART_TIME_WORKER]; case PLAYER_FORM_ZORA: - if (gSaveContext.weekEventReg[55] & 8) { + if (gSaveContext.save.weekEventReg[55] & 8) { return sWelcomeZoraTextIds[ENOSSAN_PART_TIME_WORKER]; } return sWelcomeZoraFirstTimeTextIds[ENOSSAN_PART_TIME_WORKER]; case PLAYER_FORM_GORON: - if (gSaveContext.weekEventReg[55] & 4) { + if (gSaveContext.save.weekEventReg[55] & 4) { return sWelcomeGoronTextIds[ENOSSAN_PART_TIME_WORKER]; } return sWelcomeGoronFirstTimeTextIds[ENOSSAN_PART_TIME_WORKER]; @@ -1400,28 +1438,28 @@ u16 EnOssan_GetWelcomePartTimeWorker(EnOssan* this, GlobalContext* globalCtx) { void EnOssan_SetHaveMet(EnOssan* this) { switch (this->textId) { case 0x06A9: - gSaveContext.weekEventReg[18] |= 0x10; + gSaveContext.save.weekEventReg[18] |= 0x10; break; case 0x06C6: - gSaveContext.weekEventReg[55] |= 0x10; + gSaveContext.save.weekEventReg[55] |= 0x10; break; case 0x06A7: - gSaveContext.weekEventReg[18] |= 8; + gSaveContext.save.weekEventReg[18] |= 8; break; case 0x06C4: - gSaveContext.weekEventReg[55] |= 8; + gSaveContext.save.weekEventReg[55] |= 8; break; case 0x06A5: - gSaveContext.weekEventReg[18] |= 4; + gSaveContext.save.weekEventReg[18] |= 4; break; case 0x06C2: - gSaveContext.weekEventReg[55] |= 4; + gSaveContext.save.weekEventReg[55] |= 4; break; } } void EnOssan_InitShop(EnOssan* this, GlobalContext* globalCtx) { - static EnOssanActionFunc sInitFuncs[] = { EnOssan_InitCuriosityShopMan, EnOssan_InitPartTimeWorker }; + static EnOssanActionFunc sInitFuncs[] = { EnOssan_CuriosityShopMan_Init, EnOssan_PartTimeWorker_Init }; ShopItem* shopItems; if (Object_IsLoaded(&globalCtx->objectCtx, this->objIndex)) { @@ -1486,8 +1524,9 @@ void EnOssan_InitShop(EnOssan* this, GlobalContext* globalCtx) { this->arrowAnimTween = 0.0f; this->stickAnimTween = 0.0f; this->shopItemSelectedTween = 0.0f; + Actor_SetScale(&this->actor, sActorScales[this->actor.params]); - this->animationIdx = 1; + this->animationIndex = 1; // FSN_ANIMATION_SCRATCH_BACK and ANI_ANIMATION_STANDING_NORMAL_LOOP_2 SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations[this->actor.params], 1); EnOssan_SpawnShopItems(this, globalCtx, shopItems); this->blinkTimer = 20; @@ -1524,19 +1563,22 @@ void EnOssan_Update(Actor* thisx, GlobalContext* globalCtx) { } void EnOssan_DrawCursor(GlobalContext* globalCtx, EnOssan* this, f32 x, f32 y, f32 z, u8 drawCursor) { - s32 ulx, uly, lrx, lry; + s32 ulx; + s32 uly; + s32 lrx; + s32 lry; f32 w; s32 dsdx; - ((void)"../z_en_oB1.c"); // Unreferenced + (void)"../z_en_oB1.c"; OPEN_DISPS(globalCtx->state.gfxCtx); if (drawCursor != 0) { func_8012C654(globalCtx->state.gfxCtx); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, this->cursorColor.r, this->cursorColor.g, this->cursorColor.b, this->cursorColor.a); - gDPLoadTextureBlock_4b(OVERLAY_DISP++, gameplay_keep_Tex_01F740, G_IM_FMT_IA, 16, 16, 0, - G_TX_MIRROR | G_TX_WRAP, G_TX_MIRROR | G_TX_WRAP, 4, 4, G_TX_NOLOD, G_TX_NOLOD); + gDPLoadTextureBlock_4b(OVERLAY_DISP++, gSelectionCursorTex, G_IM_FMT_IA, 16, 16, 0, G_TX_MIRROR | G_TX_WRAP, + G_TX_MIRROR | G_TX_WRAP, 4, 4, G_TX_NOLOD, G_TX_NOLOD); w = 16.0f * z; ulx = (x - w) * 4.0f; uly = (y - w) * 4.0f; @@ -1551,11 +1593,16 @@ void EnOssan_DrawCursor(GlobalContext* globalCtx, EnOssan* this, f32 x, f32 y, f void EnOssan_DrawTextRec(GlobalContext* globalCtx, s32 r, s32 g, s32 b, s32 a, f32 x, f32 y, f32 z, s32 s, s32 t, f32 dx, f32 dy) { f32 unk; - s32 ulx, uly, lrx, lry; - f32 w, h; - s32 dsdx, dtdy; + s32 ulx; + s32 uly; + s32 lrx; + s32 lry; + f32 w; + f32 h; + s32 dsdx; + s32 dtdy; - ((void)"../z_en_oB1.c"); // Unreferenced + (void)"../z_en_oB1.c"; OPEN_DISPS(globalCtx->state.gfxCtx); gDPPipeSync(OVERLAY_DISP++); @@ -1581,21 +1628,15 @@ void EnOssan_DrawStickDirectionPrompts(GlobalContext* globalCtx, EnOssan* this) s32 drawStickRightPrompt = this->stickLeftPrompt.isEnabled; s32 drawStickLeftPrompt = this->stickRightPrompt.isEnabled; - ((void)"../z_en_oB1.c"); // Unreferenced + (void)"../z_en_oB1.c"; OPEN_DISPS(globalCtx->state.gfxCtx); if (drawStickRightPrompt || drawStickLeftPrompt) { func_8012C654(globalCtx->state.gfxCtx); gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); - gDPSetTextureImage(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 1, gameplay_keep_Tex_01F8C0); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 0, 0x0000, G_TX_LOADTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPLoadSync(OVERLAY_DISP++); - gDPLoadBlock(OVERLAY_DISP++, G_TX_LOADTILE, 0, 0, 191, 1024); - gDPPipeSync(OVERLAY_DISP++); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_8b, 2, 0x0000, G_TX_RENDERTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPSetTileSize(OVERLAY_DISP++, G_TX_RENDERTILE, 0, 0, 15 * 4, 23 * 4); + gDPLoadTextureBlock(OVERLAY_DISP++, gArrowCursorTex, G_IM_FMT_IA, G_IM_SIZ_8b, 16, 24, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); if (drawStickRightPrompt) { EnOssan_DrawTextRec(globalCtx, this->stickLeftPrompt.arrowColor.r, this->stickLeftPrompt.arrowColor.g, this->stickLeftPrompt.arrowColor.b, this->stickLeftPrompt.arrowColor.a, @@ -1608,15 +1649,9 @@ void EnOssan_DrawStickDirectionPrompts(GlobalContext* globalCtx, EnOssan* this) this->stickRightPrompt.arrowTexX, this->stickRightPrompt.arrowTexY, this->stickRightPrompt.texZ, 0, 0, 1.0f, 1.0f); } - gDPSetTextureImage(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 1, gameplay_keep_Tex_01F7C0); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 0, 0x0000, G_TX_LOADTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPLoadSync(OVERLAY_DISP++); - gDPLoadBlock(OVERLAY_DISP++, G_TX_LOADTILE, 0, 0, 127, 1024); - gDPPipeSync(OVERLAY_DISP++); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_8b, 2, 0x0000, G_TX_RENDERTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPSetTileSize(OVERLAY_DISP++, G_TX_RENDERTILE, 0, 0, 15 * 4, 15 * 4); + gDPLoadTextureBlock(OVERLAY_DISP++, gControlStickTex, G_IM_FMT_IA, G_IM_SIZ_8b, 16, 16, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); if (drawStickRightPrompt) { EnOssan_DrawTextRec(globalCtx, this->stickLeftPrompt.stickColor.r, this->stickLeftPrompt.stickColor.g, this->stickLeftPrompt.stickColor.b, this->stickLeftPrompt.stickColor.a, @@ -1633,72 +1668,73 @@ void EnOssan_DrawStickDirectionPrompts(GlobalContext* globalCtx, EnOssan* this) CLOSE_DISPS(globalCtx->state.gfxCtx); } -s32 EnOssan_OverrideLimbDrawCuriosityShopMan(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, - Vec3s* rot, Actor* thisx) { +s32 EnOssan_CuriosityShopMan_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, + Vec3s* rot, Actor* thisx) { EnOssan* this = THIS; - if (limbIndex == 16) { + if (limbIndex == FSN_LIMB_HEAD) { Matrix_InsertXRotation_s(this->headRot.y, MTXMODE_APPLY); } return false; } -s32 EnOssan_OverrideLimbDrawPartTimeWorker(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnOssan_PartTimeWorker_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, + Vec3s* rot, Actor* thisx) { EnOssan* this = THIS; - if (limbIndex == 15) { + if (limbIndex == ANI_LIMB_HEAD) { Matrix_InsertXRotation_s(this->headRotPartTimeWorker.y, MTXMODE_APPLY); Matrix_InsertZRotation_s(this->headRotPartTimeWorker.x, MTXMODE_APPLY); } return false; } -void EnOssan_PostLimbDrawCuriosityShopMan(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, - Actor* thisx) { +void EnOssan_CuriosityShopMan_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, + Actor* thisx) { EnOssan* this = THIS; - if (limbIndex == 1 || limbIndex == 9 || limbIndex == 12) { + if (limbIndex == FSN_LIMB_PELVIS || limbIndex == FSN_LIMB_LEFT_UPPER_ARM || limbIndex == FSN_LIMB_RIGHT_UPPER_ARM) { rot->y += (s16)Math_SinS(this->limbRotTableY[limbIndex]) * 200; rot->z += (s16)Math_CosS(this->limbRotTableZ[limbIndex]) * 200; } } -void EnOssan_PostLimbDrawPartTimeWorker(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, - Actor* thisx) { +void EnOssan_PartTimeWorker_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, + Actor* thisx) { static Vec3f sPartTimeWorkerFocusOffset = { 800.0f, 500.0f, 0.0f }; EnOssan* this = THIS; - if (limbIndex == 15) { + if (limbIndex == ANI_LIMB_HEAD) { Matrix_MultiplyVector3fByState(&sPartTimeWorkerFocusOffset, &this->actor.focus.pos); } } -void EnOssan_DrawCuriosityShopMan(Actor* thisx, GlobalContext* globalCtx) { - static TexturePtr sEyeTextures[] = { object_fsn_Tex_005BC0, object_fsn_Tex_006D40, object_fsn_Tex_007140 }; - EnOssan* this = THIS; +void EnOssan_CuriosityShopMan_Draw(Actor* thisx, GlobalContext* globalCtx) { + static TexturePtr sEyeTextures[] = { gFsnEyeOpenTex, gFsnEyeHalfTex, gFsnEyeClosedTex }; s32 pad; + EnOssan* this = THIS; OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeTexIndex])); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnOssan_OverrideLimbDrawCuriosityShopMan, EnOssan_PostLimbDrawCuriosityShopMan, &this->actor); + EnOssan_CuriosityShopMan_OverrideLimbDraw, EnOssan_CuriosityShopMan_PostLimbDraw, + &this->actor); EnOssan_DrawCursor(globalCtx, this, this->cursorPos.x, this->cursorPos.y, this->cursorPos.z, this->drawCursor); EnOssan_DrawStickDirectionPrompts(globalCtx, this); CLOSE_DISPS(globalCtx->state.gfxCtx); } -void EnOssan_DrawPartTimeWorker(Actor* thisx, GlobalContext* globalCtx) { +void EnOssan_PartTimeWorker_Draw(Actor* thisx, GlobalContext* globalCtx) { static TexturePtr sEyeTextures[] = { gAniOpenEyeTex, gAniClosingEyeTex, gAniClosedEyeTex }; - EnOssan* this = THIS; s32 pad; + EnOssan* this = THIS; OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeTexIndex])); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnOssan_OverrideLimbDrawPartTimeWorker, EnOssan_PostLimbDrawPartTimeWorker, &this->actor); + EnOssan_PartTimeWorker_OverrideLimbDraw, EnOssan_PartTimeWorker_PostLimbDraw, &this->actor); EnOssan_DrawCursor(globalCtx, this, this->cursorPos.x, this->cursorPos.y, this->cursorPos.z, this->drawCursor); EnOssan_DrawStickDirectionPrompts(globalCtx, this); CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.h b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.h index 53f8b8f394..58c638d8e3 100644 --- a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.h +++ b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.h @@ -2,8 +2,11 @@ #define Z_EN_OSSAN_H #include "global.h" - #include "overlays/actors/ovl_En_GirlA/z_en_girla.h" +#include "objects/object_ani/object_ani.h" +#include "objects/object_fsn/object_fsn.h" + +#define ENOSSAN_LIMB_MAX MAX(FSN_LIMB_MAX + 1, ANI_LIMB_MAX) struct EnOssan; @@ -50,9 +53,9 @@ typedef struct EnOssan { /* 0x2CC */ Vec3s unk2CC; // Set but never used /* 0x2D2 */ s16 limbRotTableY[19]; /* 0x2F8 */ s16 limbRotTableZ[19]; - /* 0x31E */ Vec3s jointTable[19]; - /* 0x390 */ Vec3s morphTable[19]; - /* 0x402 */ s16 animationIdx; + /* 0x31E */ Vec3s jointTable[ENOSSAN_LIMB_MAX]; + /* 0x390 */ Vec3s morphTable[ENOSSAN_LIMB_MAX]; + /* 0x402 */ s16 animationIndex; /* 0x404 */ Vec3s headRotPartTimeWorker; /* 0x40A */ u16 flags; } EnOssan; // size = 0x40C @@ -68,12 +71,6 @@ typedef enum { /* 1 */ ENOSSAN_PART_TIME_WORKER } EnOssanWorker; -typedef enum { - /* 0 */ ENOSSAN_CUTSCENESTATE_STOPPED, - /* 1 */ ENOSSAN_CUTSCENESTATE_WAITING, - /* 2 */ ENOSSAN_CUTSCENESTATE_PLAYING -} EnOssanCutsceneState; - extern const ActorInit En_Ossan_InitVars; #endif // Z_EN_OSSAN_H diff --git a/src/overlays/actors/ovl_En_Ot/z_en_ot.c b/src/overlays/actors/ovl_En_Ot/z_en_ot.c index 6eb555ef15..7573947e6e 100644 --- a/src/overlays/actors/ovl_En_Ot/z_en_ot.c +++ b/src/overlays/actors/ovl_En_Ot/z_en_ot.c @@ -180,7 +180,7 @@ void EnOt_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.world.pos.y = BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, &this->actor.floorPoly, &bgId, &this->actor.world.pos) + 50.0f; - if (gSaveContext.weekEventReg[84] & 0x10) { + if (gSaveContext.save.weekEventReg[84] & 0x10) { Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); Matrix_GetStateTranslationAndScaledZ(52.519997f, &sp64); Math_Vec3f_Sum(&this->actor.world.pos, &sp64, &sp64); @@ -195,7 +195,7 @@ void EnOt_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_394.y = this->actor.world.pos.y; this->unk_394.z = (this->actor.world.pos.z + this->unk_360->actor.world.pos.z) * 0.5f; Math_Vec3f_Copy(&this->unk_360->unk_394, &this->unk_394); - if (gSaveContext.weekEventReg[32] & 1) { + if (gSaveContext.save.weekEventReg[32] & 1) { func_80B5C244(this, globalCtx); } else { func_80B5C684(this, globalCtx); @@ -230,7 +230,7 @@ void EnOt_Init(Actor* thisx, GlobalContext* globalCtx) { switch (this->unk_344) { case 0: Actor_SetScale(&this->actor, 0.0f); - if (!(gSaveContext.weekEventReg[13] & 1)) { + if (!(gSaveContext.save.weekEventReg[13] & 1)) { Actor_SetScale(&this->actor, 0.0f); func_80B5C910(this, globalCtx); } else { @@ -250,8 +250,8 @@ void EnOt_Init(Actor* thisx, GlobalContext* globalCtx) { case 1: Actor_SetScale(&this->actor, 0.012999999f); - if (gSaveContext.weekEventReg[84] & 0x10) { - if (gSaveContext.weekEventReg[32] & 1) { + if (gSaveContext.save.weekEventReg[84] & 0x10) { + if (gSaveContext.save.weekEventReg[32] & 1) { func_80B5C244(this, globalCtx); } else { func_80B5C684(this, globalCtx); @@ -264,7 +264,7 @@ void EnOt_Init(Actor* thisx, GlobalContext* globalCtx) { break; case 3: - if (!(gSaveContext.weekEventReg[26] & 8)) { + if (!(gSaveContext.save.weekEventReg[26] & 8)) { this->actor.flags |= ACTOR_FLAG_8000000; this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); Actor_SetScale(&this->actor, 0.0064999997f); @@ -376,11 +376,11 @@ void func_80B5BFB8(EnOt* this, GlobalContext* globalCtx) { } void func_80B5C154(EnOt* this, GlobalContext* globalCtx) { - if (gSaveContext.weekEventReg[32] & 1) { + if (gSaveContext.save.weekEventReg[32] & 1) { this->unk_38C = GI_RUPEE_RED; } else { this->unk_38C = GI_HEART_PIECE; - gSaveContext.weekEventReg[32] |= 1; + gSaveContext.save.weekEventReg[32] |= 1; } Actor_PickUp(&this->actor, globalCtx, this->unk_38C, this->actor.xzDistToPlayer, this->actor.playerHeightRel); this->actionFunc = func_80B5C1CC; @@ -482,7 +482,7 @@ void func_80B5C634(EnOt* this, GlobalContext* globalCtx) { } void func_80B5C64C(EnOt* this, GlobalContext* globalCtx) { - if (gSaveContext.weekEventReg[26] & 8) { + if (gSaveContext.save.weekEventReg[26] & 8) { Actor_MarkForDeath(&this->actor); } } @@ -505,7 +505,7 @@ void func_80B5C6DC(EnOt* this, GlobalContext* globalCtx) { Matrix_GetStateTranslationAndScaledZ(26.259998f, &sp30); } else { if (this->unk_73C == 0) { - gSaveContext.weekEventReg[84] |= 0x10; + gSaveContext.save.weekEventReg[84] |= 0x10; switch (this->unk_388) { case 0: ActorCutscene_Stop(this->cutscenes[2]); @@ -527,7 +527,7 @@ void func_80B5C6DC(EnOt* this, GlobalContext* globalCtx) { Math_SmoothStepToF(&this->actor.world.pos.x, this->unk_348.x, 1.0f, 2.0f, 0.01f); Math_SmoothStepToF(&this->actor.world.pos.z, this->unk_348.z, 1.0f, 2.0f, 0.01f); Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 0xE38, 0x38E); - if ((gSaveContext.weekEventReg[84] & 0x10) && (this->unk_33C == 1)) { + if ((gSaveContext.save.weekEventReg[84] & 0x10) && (this->unk_33C == 1)) { this->actor.textId = 0; this->unk_384 = 1; if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { @@ -556,7 +556,7 @@ void func_80B5C910(EnOt* this, GlobalContext* globalCtx) { void func_80B5C950(EnOt* this, GlobalContext* globalCtx) { if (this->unk_32C & 8) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SEAHORSE_OUT_BOTTLE); - gSaveContext.weekEventReg[25] |= 4; + gSaveContext.save.weekEventReg[25] |= 4; func_80B5CAD0(this, globalCtx); } } @@ -650,7 +650,7 @@ void func_80B5CD40(EnOt* this, GlobalContext* globalCtx) { this->actor.world.rot.y = this->actor.shape.rot.y; if (1) {} if (!temp) { - gSaveContext.weekEventReg[23] |= 0x10; + gSaveContext.save.weekEventReg[23] |= 0x10; Message_StartTextbox(globalCtx, 0x1069, NULL); } break; @@ -663,7 +663,7 @@ void func_80B5CD40(EnOt* this, GlobalContext* globalCtx) { case 4: case 5: case 6: - if (func_80147624(globalCtx) && (globalCtx->msgCtx.unk11F04 == 0x1069)) { + if (Message_ShouldAdvance(globalCtx) && (globalCtx->msgCtx.currentTextId == 0x1069)) { this->unk_32C |= 4; ActorCutscene_Stop(this->cutscenes[0]); player->stateFlags2 &= ~0x20000000; @@ -701,7 +701,7 @@ void func_80B5CEC8(EnOt* this, GlobalContext* globalCtx) { } } - if (!(gSaveContext.weekEventReg[84] & 0x10) && (ENOT_GET_C000(&this->actor) == 1)) { + if (!(gSaveContext.save.weekEventReg[84] & 0x10) && (ENOT_GET_C000(&this->actor) == 1)) { if ((fabsf(this->actor.xzDistToPlayer) <= 130.0f) && (fabsf(this->actor.playerHeightRel) <= 130.0f)) { player->unk_B2B = 29; } @@ -754,7 +754,7 @@ void func_80B5D160(EnOt* this, GlobalContext* globalCtx) { phi_a1 = 0x1069; } } else if (Flags_GetSwitch(globalCtx, ENOT_GET_3F80(&this->actor))) { - if (gSaveContext.weekEventReg[23] & 0x10) { + if (gSaveContext.save.weekEventReg[23] & 0x10) { phi_a1 = 0x106C; } else { phi_a1 = 0x106B; @@ -786,8 +786,8 @@ void func_80B5D160(EnOt* this, GlobalContext* globalCtx) { case 4: case 5: case 6: - if (func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { default: case 0x1068: case 0x106B: @@ -817,31 +817,27 @@ void func_80B5D160(EnOt* this, GlobalContext* globalCtx) { } } -s32 func_80B5D37C(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1) { - s32 pad; - EnOt* temp_s0 = (EnOt*)arg1->actor; - f32 sp24; - f32 sp20; +s32 EnOt_ActorPathing_Move(GlobalContext* globalCtx, ActorPathing* actorPath) { + Actor* thisx = actorPath->actor; + EnOt* this = (EnOt*)thisx; + f32 sp24 = Math_CosS(-thisx->world.rot.x) * thisx->speedXZ; + f32 sp20 = gFramerateDivisorHalf; - sp24 = Math_CosS(temp_s0->actor.world.rot.x * -1) * temp_s0->actor.speedXZ; - sp20 = gFramerateDivisorHalf; + thisx->velocity.x = Math_SinS(thisx->world.rot.y) * sp24; + thisx->velocity.y = Math_SinS(-thisx->world.rot.x) * thisx->speedXZ; + thisx->velocity.z = Math_CosS(thisx->world.rot.y) * sp24; - temp_s0->actor.velocity.x = Math_SinS(temp_s0->actor.world.rot.y) * sp24; - temp_s0->actor.velocity.y = Math_SinS(temp_s0->actor.world.rot.x * -1) * temp_s0->actor.speedXZ; - do { - temp_s0->actor.velocity.z = Math_CosS(temp_s0->actor.world.rot.y) * sp24; - temp_s0->unk_330.x += (temp_s0->actor.velocity.x * sp20) + temp_s0->actor.colChkInfo.displacement.x; - temp_s0->unk_330.y += (temp_s0->actor.velocity.y * sp20) + temp_s0->actor.colChkInfo.displacement.y; - } while (0); - temp_s0->unk_330.z += (temp_s0->actor.velocity.z * sp20) + temp_s0->actor.colChkInfo.displacement.z; + this->unk_330.x += (thisx->velocity.x * sp20) + thisx->colChkInfo.displacement.x; + this->unk_330.y += (thisx->velocity.y * sp20) + thisx->colChkInfo.displacement.y; + this->unk_330.z += (thisx->velocity.z * sp20) + thisx->colChkInfo.displacement.z; return false; } -s32 func_80B5D470(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1) { +s32 EnOt_ActorPathing_UpdateActorInfo(GlobalContext* globalCtx, ActorPathing* actorPath) { + Actor* thisx = actorPath->actor; + s32 ret = false; s32 pad; - s32 ret; - Actor* temp_s1 = arg1->actor; Vec3f sp50; Vec3f sp44; f32 temp; @@ -849,32 +845,31 @@ s32 func_80B5D470(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1) { s32 sp30; s32 sp34; - ret = false; - temp_s1->gravity = 0.0f; - Math_SmoothStepToF(&temp_s1->speedXZ, 10.0f, 0.8f, 2.0f, 0.0f); + thisx->gravity = 0.0f; + Math_SmoothStepToF(&thisx->speedXZ, 10.0f, 0.8f, 2.0f, 0.0f); - sp50.x = arg1->unk_20.x - temp_s1->world.pos.x; - sp50.y = arg1->unk_20.y - temp_s1->world.pos.y; - sp50.z = arg1->unk_20.z - temp_s1->world.pos.z; + sp50.x = actorPath->curPoint.x - thisx->world.pos.x; + sp50.y = actorPath->curPoint.y - thisx->world.pos.y; + sp50.z = actorPath->curPoint.z - thisx->world.pos.z; - sp44.x = arg1->unk_20.x - arg1->unk_38.x; - sp44.y = arg1->unk_20.y - arg1->unk_38.y; - sp44.z = arg1->unk_20.z - arg1->unk_38.z; + sp44.x = actorPath->curPoint.x - actorPath->prevPoint.x; + sp44.y = actorPath->curPoint.y - actorPath->prevPoint.y; + sp44.z = actorPath->curPoint.z - actorPath->prevPoint.z; temp = Math3D_Parallel(&sp50, &sp44); - if ((arg1->unk_4C < SQ(temp_s1->speedXZ)) || (temp <= 0.0f)) { + if ((actorPath->distSqToCurPointXZ < SQ(thisx->speedXZ)) || (temp <= 0.0f)) { ret = true; } else { - temp = SQ(temp_s1->speedXZ) / arg1->unk_50; - sp34 = ABS(arg1->unk_54.x - temp_s1->world.rot.x); + temp = SQ(thisx->speedXZ) / actorPath->distSqToCurPoint; + sp34 = ABS(actorPath->rotToCurPoint.x - thisx->world.rot.x); sp2C = (s32)(sp34 * temp) + 0xAAA; - sp34 = ABS(arg1->unk_54.y - temp_s1->world.rot.y); + sp34 = ABS(actorPath->rotToCurPoint.y - thisx->world.rot.y); - Math_SmoothStepToS(&temp_s1->world.rot.x, arg1->unk_54.x, 1, sp2C, 0); + Math_SmoothStepToS(&thisx->world.rot.x, actorPath->rotToCurPoint.x, 1, sp2C, 0); sp2C = (s32)(sp34 * temp) + 0xAAA; - Math_SmoothStepToS(&temp_s1->world.rot.y, arg1->unk_54.y, 1, sp2C, 0); - Math_SmoothStepToS(&temp_s1->shape.rot.y, temp_s1->world.rot.y, 2, sp2C, 0); + Math_SmoothStepToS(&thisx->world.rot.y, actorPath->rotToCurPoint.y, 1, sp2C, 0); + Math_SmoothStepToS(&thisx->shape.rot.y, thisx->world.rot.y, 2, sp2C, 0); } return ret; @@ -883,12 +878,12 @@ s32 func_80B5D470(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1) { void func_80B5D648(EnOt* this, GlobalContext* globalCtx) { func_80B5B2E0(globalCtx, &this->actor.world.pos, this->unk_346, &this->unk_348, &this->unk_340); Math_Vec3f_Copy(&this->unk_330, &this->actor.world.pos); - func_8013DCE0(globalCtx, &this->unk_330, &this->actor, &this->unk_2C0, globalCtx->setupPathList, this->unk_346, 0, - 0, this->unk_340, 0); + SubS_ActorPathing_Init(globalCtx, &this->unk_330, &this->actor, &this->actorPath, globalCtx->setupPathList, + this->unk_346, 0, 0, this->unk_340, 0); this->unk_32C = 0; - this->unk_2C0.unk_2C.x = 0.0f; - this->unk_2C0.unk_2C.y = 0.0f; - this->unk_2C0.unk_2C.z = 0.0f; + this->actorPath.pointOffset.x = 0.0f; + this->actorPath.pointOffset.y = 0.0f; + this->actorPath.pointOffset.z = 0.0f; this->actor.gravity = 0.0f; this->actor.speedXZ = 0.0f; SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 1, &this->animIdx); @@ -900,16 +895,18 @@ void func_80B5D648(EnOt* this, GlobalContext* globalCtx) { void func_80B5D750(EnOt* this, GlobalContext* globalCtx) { if (!(this->unk_32C & 1) && !(this->unk_32C & 2)) { - func_8013DE04(globalCtx, &this->unk_2C0, func_8013DF3C, func_80B5D470, func_80B5D37C, func_8013E0A4); + SubS_ActorPathing_Update(globalCtx, &this->actorPath, SubS_ActorPathing_ComputePointInfo, + EnOt_ActorPathing_UpdateActorInfo, EnOt_ActorPathing_Move, + SubS_ActorPathing_SetNextPoint); } Math_Vec3f_Copy(&this->actor.world.pos, &this->unk_330); - if (this->unk_2C0.unk_1C & 0x40) { + if (this->actorPath.flags & ACTOR_PATHING_REACHED_POINT_TEMPORARY) { this->unk_32C |= 2; } - if (this->unk_2C0.unk_1C & 0x80) { + if (this->actorPath.flags & ACTOR_PATHING_REACHED_END_TEMPORARY) { this->unk_32C |= 1; } @@ -988,8 +985,8 @@ void func_80B5DB6C(Actor* thisx, GlobalContext* globalCtx) { EnOt* this = THIS; Player* player = GET_PLAYER(globalCtx); - if (!(gSaveContext.weekEventReg[84] & 0x10) && !(this->unk_32C & 8)) { - if (gSaveContext.weekEventReg[25] & 4) { + if (!(gSaveContext.save.weekEventReg[84] & 0x10) && !(this->unk_32C & 8)) { + if (gSaveContext.save.weekEventReg[25] & 4) { Vec3f sp50; func_80B5B2E0(globalCtx, &this->actor.world.pos, ENOT_GET_7F(&this->actor), &sp50, &this->unk_340); @@ -1001,7 +998,7 @@ void func_80B5DB6C(Actor* thisx, GlobalContext* globalCtx) { } else if (D_80B5E888 != NULL) { s32 sp4C = false; - if (gSaveContext.weekEventReg[13] & 1) { + if (gSaveContext.save.weekEventReg[13] & 1) { if (!SurfaceType_IsHorseBlocked(&globalCtx->colCtx, player->actor.floorPoly, player->actor.floorBgId)) { sp4C = true; } diff --git a/src/overlays/actors/ovl_En_Ot/z_en_ot.h b/src/overlays/actors/ovl_En_Ot/z_en_ot.h index 3a52b48c6c..902cbecd7c 100644 --- a/src/overlays/actors/ovl_En_Ot/z_en_ot.h +++ b/src/overlays/actors/ovl_En_Ot/z_en_ot.h @@ -36,7 +36,7 @@ typedef struct EnOt { /* 0x01D8 */ Vec3s jointTable[19]; /* 0x024A */ Vec3s morphTable[19]; /* 0x02BC */ s32 animIdx; - /* 0x02C0 */ struct_8013DF3C_arg1 unk_2C0; + /* 0x02C0 */ ActorPathing actorPath; /* 0x032C */ u16 unk_32C; /* 0x0330 */ Vec3f unk_330; /* 0x033C */ s32 unk_33C; diff --git a/src/overlays/actors/ovl_En_Owl/z_en_owl.c b/src/overlays/actors/ovl_En_Owl/z_en_owl.c index f7eb614906..ab8f721aef 100644 --- a/src/overlays/actors/ovl_En_Owl/z_en_owl.c +++ b/src/overlays/actors/ovl_En_Owl/z_en_owl.c @@ -157,7 +157,7 @@ void EnOwl_Init(Actor* thisx, GlobalContext* globalCtx) { break; case ENOWL_GET_TYPE_2: - if (gSaveContext.inventory.items[SLOT_LENS] == ITEM_LENS) { + if (gSaveContext.save.inventory.items[ITEM_LENS] == ITEM_LENS) { Actor_MarkForDeath(&this->actor); return; } @@ -183,7 +183,7 @@ void EnOwl_Init(Actor* thisx, GlobalContext* globalCtx) { case ENOWL_GET_TYPE_2: this->actionFunc = func_8095BE0C; - if (gSaveContext.weekEventReg[9] & 0x20) { + if (gSaveContext.save.weekEventReg[9] & 0x20) { this->actor.textId = 0xBF0; } else { this->actor.textId = 0xBEA; @@ -324,7 +324,7 @@ void func_8095ACEC(EnOwl* this) { } void func_8095AD54(EnOwl* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 4) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 4) && Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case OWL_REPEAT: func_80151938(globalCtx, 0x7D1); @@ -340,14 +340,14 @@ void func_8095AD54(EnOwl* this, GlobalContext* globalCtx) { } void func_8095AE00(EnOwl* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_80151938(globalCtx, 0x7D2); this->actionFunc = func_8095AD54; } } void func_8095AE60(EnOwl* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_80151938(globalCtx, 0x7D1); this->actionFunc = func_8095AE00; } @@ -364,13 +364,13 @@ void func_8095AEC0(EnOwl* this, GlobalContext* globalCtx) { void func_8095AF2C(EnOwl* this, GlobalContext* globalCtx) { switch (Message_GetState(&globalCtx->msgCtx)) { case 5: - if (func_80147624(globalCtx)) { - if (globalCtx->msgCtx.unk11F04 == 0xBFE) { + if (Message_ShouldAdvance(globalCtx)) { + if (globalCtx->msgCtx.currentTextId == 0xBFE) { func_8095ACEC(this); func_801477B4(globalCtx); this->actionFunc = func_8095ABF0; } else { - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); } } break; @@ -607,16 +607,16 @@ void func_8095BA84(EnOwl* this, GlobalContext* globalCtx) { switch (Message_GetState(&globalCtx->msgCtx)) { case 4: - if (func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0xBEC: switch (globalCtx->msgCtx.choiceIndex) { case 0: func_8019F208(); - if (gSaveContext.weekEventReg[9] & 0x40) { + if (gSaveContext.save.weekEventReg[9] & 0x40) { func_80151938(globalCtx, 0xBF4); } else { - gSaveContext.weekEventReg[9] |= 0x40; + gSaveContext.save.weekEventReg[9] |= 0x40; func_80151938(globalCtx, 0xBED); } break; @@ -646,10 +646,10 @@ void func_8095BA84(EnOwl* this, GlobalContext* globalCtx) { break; case 5: - if (func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0xBEA: - gSaveContext.weekEventReg[9] |= 0x20; + gSaveContext.save.weekEventReg[9] |= 0x20; func_80151938(globalCtx, 0xBEB); break; diff --git a/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c b/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c index 467ef3901f..06cf9b22dd 100644 --- a/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c +++ b/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c @@ -155,14 +155,14 @@ void EnPamera_Init(Actor* thisx, GlobalContext* globalCtx) { func_80BD8588(this, globalCtx); func_80BD8658(this); if (1) {} - if (!(gSaveContext.weekEventReg[14] & 4) || (gSaveContext.weekEventReg[52] & 0x20) || - (gSaveContext.weekEventReg[75] & 0x20) || (gSaveContext.entranceIndex == 0x2090)) { + if (!(gSaveContext.save.weekEventReg[14] & 4) || (gSaveContext.save.weekEventReg[52] & 0x20) || + (gSaveContext.save.weekEventReg[75] & 0x20) || (gSaveContext.save.entranceIndex == 0x2090)) { Actor_MarkForDeath(&this->actor); } - if (gSaveContext.weekEventReg[61] & 4) { - if (!(gSaveContext.weekEventReg[59] & 1) || (gSaveContext.entranceIndex != 0x2020)) { - if ((gSaveContext.entranceIndex != 0x2020) && (gSaveContext.weekEventReg[59] & 1)) { - gSaveContext.weekEventReg[59] &= (u8)~1; + if (gSaveContext.save.weekEventReg[61] & 4) { + if (!(gSaveContext.save.weekEventReg[59] & 1) || (gSaveContext.save.entranceIndex != 0x2020)) { + if ((gSaveContext.save.entranceIndex != 0x2020) && (gSaveContext.save.weekEventReg[59] & 1)) { + gSaveContext.save.weekEventReg[59] &= (u8)~1; } func_80BD8700(this); } else { @@ -173,7 +173,7 @@ void EnPamera_Init(Actor* thisx, GlobalContext* globalCtx) { func_80BD8CCC(this); } } else { - gSaveContext.weekEventReg[59] |= 1; + gSaveContext.save.weekEventReg[59] |= 1; func_80BD8FF0(this); } } @@ -200,7 +200,7 @@ void func_80BD8588(EnPamera* this, GlobalContext* globalCtx) { if (path == NULL) { Actor_MarkForDeath(&this->actor); } - if (gSaveContext.weekEventReg[61] & 4) { + if (gSaveContext.save.weekEventReg[61] & 4) { path = &globalCtx->setupPathList[path->unk1]; } this->pathPoints = Lib_SegmentedToVirtual(path->points); @@ -289,7 +289,7 @@ void func_80BD8964(EnPamera* this, GlobalContext* globalCtx) { if (Math_Vec3f_StepTo(&this->actor.world.pos, &vec, 1.0f) < 5.0f) { this->actor.speedXZ = 1.5f; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); - gSaveContext.weekEventReg[59] |= 1; + gSaveContext.save.weekEventReg[59] |= 1; func_80BD8B50(this); } } @@ -304,10 +304,10 @@ void func_80BD8A7C(EnPamera* this, GlobalContext* globalCtx) { 0x3000, 0x100); this->actor.world.rot.y = this->actor.shape.rot.y; if (Math_Vec3f_StepTo(&this->actor.world.pos, &this->actor.home.pos, 1.5f) < 10.0f) { - gSaveContext.weekEventReg[59] &= (u8)~1; - if (!(gSaveContext.weekEventReg[61] & 4)) { + gSaveContext.save.weekEventReg[59] &= (u8)~1; + if (!(gSaveContext.save.weekEventReg[61] & 4)) { func_80BD92D0(this, globalCtx); - gSaveContext.weekEventReg[61] |= 4; + gSaveContext.save.weekEventReg[61] |= 4; } func_80BD8700(this); } @@ -567,7 +567,7 @@ void func_80BD9840(EnPamera* this, GlobalContext* globalCtx) { this->actor.update = func_80BDA344; this->actor.flags |= ACTOR_FLAG_2000000; this->actor.flags |= ACTOR_FLAG_100000; - if ((gSaveContext.weekEventReg[75] & 0x20) || (gSaveContext.weekEventReg[52] & 0x20)) { + if ((gSaveContext.save.weekEventReg[75] & 0x20) || (gSaveContext.save.weekEventReg[52] & 0x20)) { func_80BD9E60(this); func_80BD9938(this); } else { @@ -575,7 +575,7 @@ void func_80BD9840(EnPamera* this, GlobalContext* globalCtx) { func_80BD9E60(this); func_80BD9904(this); } - if (gSaveContext.weekEventReg[14] & 4) { + if (gSaveContext.save.weekEventReg[14] & 4) { func_801A0204(NA_BGM_MUSIC_BOX_HOUSE); } else { func_801A0204(NA_BGM_INSIDE_A_HOUSE); @@ -602,8 +602,8 @@ void func_80BD994C(EnPamera* this, GlobalContext* globalCtx) { Message_StartTextbox(globalCtx, 0x15A8, &this->actor); this->unk_324 = 0x15A8; - } else if ((gSaveContext.playerForm != PLAYER_FORM_HUMAN) || - ((gSaveContext.weekEventReg[52] & 0x20) && (!(gSaveContext.weekEventReg[75] & 0x20)))) { + } else if ((gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) || + ((gSaveContext.save.weekEventReg[52] & 0x20) && (!(gSaveContext.save.weekEventReg[75] & 0x20)))) { func_80BD93CC(this, 1, 0); Message_StartTextbox(globalCtx, 0x158E, &this->actor); this->unk_324 = 0x158E; @@ -639,7 +639,7 @@ void EnPamera_HandleDialogue(EnPamera* this, GlobalContext* globalCtx) { func_80BD9B4C(this, globalCtx); break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { func_80BD9938(this); } break; @@ -651,7 +651,7 @@ void EnPamera_HandleDialogue(EnPamera* this, GlobalContext* globalCtx) { } void func_80BD9B4C(EnPamera* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->unk_324) { case 0x1587: Message_StartTextbox(globalCtx, 0x1588, &this->actor); @@ -726,7 +726,7 @@ s32 func_80BD9CB8(EnPamera* this, GlobalContext* globalCtx) { this->setupFunc(this, globalCtx); return 1; } - if ((globalCtx->csCtx.state == 0) && (gSaveContext.weekEventReg[75] & 0x20)) { + if ((globalCtx->csCtx.state == 0) && (gSaveContext.save.weekEventReg[75] & 0x20)) { if ((this->actionFunc != func_80BD994C) && (this->actionFunc != EnPamera_HandleDialogue)) { this->actor.shape.rot.y = this->actor.world.rot.y; func_80BD9904(this); @@ -850,11 +850,11 @@ void func_80BDA344(Actor* thisx, GlobalContext* globalCtx) { func_80BD9384(this, globalCtx); if (func_80BD9CB8(this, globalCtx)) { // Pamela is outside - if (gSaveContext.weekEventReg[59] & 1) { - gSaveContext.weekEventReg[59] &= (u8)~1; + if (gSaveContext.save.weekEventReg[59] & 1) { + gSaveContext.save.weekEventReg[59] &= (u8)~1; } - if (!(gSaveContext.weekEventReg[61] & 4)) { - gSaveContext.weekEventReg[61] |= 4; + if (!(gSaveContext.save.weekEventReg[61] & 4)) { + gSaveContext.save.weekEventReg[61] |= 4; } func_800E8F08(&this->limb9Rot, &this->limb8Rot); } else { @@ -863,7 +863,7 @@ void func_80BDA344(Actor* thisx, GlobalContext* globalCtx) { Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); } - if (gSaveContext.weekEventReg[14] & 4) { + if (gSaveContext.save.weekEventReg[14] & 4) { globalCtx->roomCtx.unk7A[0]++; } } diff --git a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c index bab9aee20e..542238a17b 100644 --- a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c +++ b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c @@ -170,7 +170,7 @@ static InitChainEntry sInitChain[] = { ICHAIN_U8(targetMode, 10, ICHAIN_STOP), }; -// gSaveContext.weekEventReg[KEY] = VALUE +// gSaveContext.save.weekEventReg[KEY] = VALUE // KEY | VALUE static s32 isFrogReturnedFlags[] = { (32 << 8) | 0x40, // Woodfall Temple Frog Returned @@ -192,7 +192,7 @@ void EnPametfrog_Init(Actor* thisx, GlobalContext* globalCtx) { this->params = CLAMP(this->actor.params, 1, 4); if (Flags_GetClear(globalCtx, globalCtx->roomCtx.currRoom.num)) { Actor_MarkForDeath(&this->actor); - if (!(gSaveContext.weekEventReg[isFrogReturnedFlags[this->actor.params - 1] >> 8] & + if (!(gSaveContext.save.weekEventReg[isFrogReturnedFlags[this->actor.params - 1] >> 8] & (u8)isFrogReturnedFlags[this->actor.params - 1])) { Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_MINIFROG, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, this->actor.shape.rot.y, 0, this->params); @@ -231,21 +231,21 @@ u8 EnPametfrog_Vec3fNormalize(Vec3f* vec) { } void EnPametfrog_Freeze(EnPametfrog* this) { - this->drawEffect = GEKKO_DRAW_EFFECT_FROZEN; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; this->collider.base.colType = COLTYPE_HIT3; this->collider.elements->info.elemType = ELEMTYPE_UNK0; - this->unk_2C8 = 0.75f; - this->unk_2CC = 1.125f; - this->unk_2C4 = 1.0f; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffFrozenSteamScale = 1.125f; + this->drawDmgEffAlpha = 1.0f; } void EnPametfrog_Thaw(EnPametfrog* this, GlobalContext* globalCtx) { this->freezeTimer = 0; - if (this->drawEffect == GEKKO_DRAW_EFFECT_FROZEN) { - this->drawEffect = GEKKO_DRAW_EFFECT_THAW; + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->collider.base.colType = COLTYPE_HIT6; this->collider.elements->info.elemType = ELEMTYPE_UNK1; - this->unk_2C4 = 0.0f; + this->drawDmgEffAlpha = 0.0f; Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), 2, 0.3f, 0.2f); } } @@ -387,13 +387,13 @@ void EnPametfrog_JumpOnGround(EnPametfrog* this, GlobalContext* globalCtx) { void EnPametfrog_ApplyMagicArrowEffects(EnPametfrog* this, GlobalContext* globalCtx) { if (this->actor.colChkInfo.damageEffect == GEKKO_DMGEFF_FIRE) { - this->drawEffect = GEKKO_DRAW_EFFECT_THAW; - this->unk_2C4 = 3.0f; - this->unk_2C8 = 0.75f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffAlpha = 3.0f; + this->drawDmgEffScale = 0.75f; } else if (this->actor.colChkInfo.damageEffect == GEKKO_DMGEFF_LIGHT) { - this->drawEffect = GEKKO_DRAW_EFFECT_LIGHT_ORBS; - this->unk_2C8 = 0.75f; - this->unk_2C4 = 3.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffAlpha = 3.0f; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->collider.elements[0].info.bumper.hitPos.x, this->collider.elements[0].info.bumper.hitPos.y, this->collider.elements[0].info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); @@ -406,9 +406,9 @@ void EnPametfrog_ApplyElectricStun(EnPametfrog* this) { this->freezeTimer = 40; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); - this->drawEffect = GEKKO_DRAW_EFFECT_ELECTRIC_STUN; - this->unk_2C8 = 0.75f; - this->unk_2C4 = 2.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffAlpha = 2.0f; } void EnPametfrog_ApplyStun(EnPametfrog* this) { @@ -1035,7 +1035,7 @@ void EnPametfrog_LookAround(EnPametfrog* this, GlobalContext* globalCtx) { EnPametfrog_IdleWaterEffects(this, globalCtx); Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 5, 0x400, 0x80); this->actor.shape.rot.y = this->actor.world.rot.y; - if (SkelAnime_Update(&this->skelAnime) && (func_801690CC(globalCtx) == 0)) { + if (SkelAnime_Update(&this->skelAnime) && !Play_InCsMode(globalCtx)) { if (!this->unk_2AE) { func_801A2E54(NA_BGM_MINI_BOSS); this->unk_2AE = true; @@ -1265,7 +1265,7 @@ void EnPametfrog_TransitionGekkoSnapper(EnPametfrog* this, GlobalContext* global void EnPametfrog_ApplyDamageEffect(EnPametfrog* this, GlobalContext* globalCtx) { if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; - if ((this->drawEffect != GEKKO_DRAW_EFFECT_FROZEN) || + if ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || !(this->collider.elements->info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { if (this->actor.params == GEKKO_PRE_SNAPPER) { if (Actor_ApplyDamage(&this->actor) == 0) { @@ -1286,13 +1286,13 @@ void EnPametfrog_ApplyDamageEffect(EnPametfrog* this, GlobalContext* globalCtx) } else { EnPametfrog_Thaw(this, globalCtx); if (this->actor.colChkInfo.damageEffect == GEKKO_DMGEFF_FIRE) { - this->drawEffect = GEKKO_DRAW_EFFECT_THAW; - this->unk_2C8 = 0.75f; - this->unk_2C4 = 4.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffAlpha = 4.0f; } else if (this->actor.colChkInfo.damageEffect == GEKKO_DMGEFF_LIGHT) { - this->drawEffect = GEKKO_DRAW_EFFECT_LIGHT_ORBS; - this->unk_2C8 = 0.75f; - this->unk_2C4 = 4.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffAlpha = 4.0f; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->collider.elements[0].info.bumper.hitPos.x, this->collider.elements[0].info.bumper.hitPos.y, @@ -1357,13 +1357,14 @@ void EnPametfrog_Update(Actor* thisx, GlobalContext* globalCtx) { CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); } - if (this->unk_2C4 > 0.0f) { - if ((this->drawEffect != GEKKO_DRAW_EFFECT_FROZEN) && (this->actionFunc != EnPametfrog_PlayCutscene)) { - Math_StepToF(&this->unk_2C4, 0.0f, 0.05f); - unk2C4 = ((this->unk_2C4 + 1.0f) * 0.375f); - this->unk_2C8 = unk2C4; - this->unk_2C8 = unk2C4 > 0.75f ? 0.75f : this->unk_2C8; - } else if (!Math_StepToF(&this->unk_2CC, 0.75f, (3.0f / 160.0f))) { + if (this->drawDmgEffAlpha > 0.0f) { + if ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) && + (this->actionFunc != EnPametfrog_PlayCutscene)) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + unk2C4 = ((this->drawDmgEffAlpha + 1.0f) * 0.375f); + this->drawDmgEffScale = unk2C4; + this->drawDmgEffScale = unk2C4 > 0.75f ? 0.75f : this->drawDmgEffScale; + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.75f, (3.0f / 160.0f))) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } @@ -1420,6 +1421,6 @@ void EnPametfrog_Draw(Actor* thisx, GlobalContext* globalCtx) { Matrix_RotateY(this->spinYaw, MTXMODE_APPLY); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, EnPametfrog_PostLimbDraw, &this->actor); - func_800BE680(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->unk_2C8, this->unk_2CC, - this->unk_2C4, this->drawEffect); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, + this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, this->drawDmgEffType); } diff --git a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.h b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.h index 97a682825b..2b21f3ea35 100644 --- a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.h +++ b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.h @@ -20,13 +20,6 @@ typedef enum { /* 0x9 */ GEKKO_DEFEAT, } EnPametfrogState; -typedef enum { - /* 00 */ GEKKO_DRAW_EFFECT_THAW, - /* 10 */ GEKKO_DRAW_EFFECT_FROZEN = 10, - /* 20 */ GEKKO_DRAW_EFFECT_LIGHT_ORBS = 20, - /* 30 */ GEKKO_DRAW_EFFECT_ELECTRIC_STUN = 30, -} EnPametfrogDrawEffectType; - typedef enum { /* 0x00 */ GEKKO_LIMB_NONE, /* 0x01 */ GEKKO_LIMB_ROOT, @@ -61,7 +54,7 @@ typedef struct EnPametfrog { /* 0x188 */ Vec3s jointTable[GEKKO_LIMB_MAX]; /* 0x218 */ Vec3s morphTable[GEKKO_LIMB_MAX]; /* 0x2A8 */ EnPametfrogActionFunc actionFunc; - /* 0x2AC */ u8 drawEffect; + /* 0x2AC */ u8 drawDmgEffType; /* 0x2AD */ u8 wallPauseTimer; // Gekko stops 10 times along wall/ceiling after being blown off of Snapper /* 0x2AE */ u8 unk_2AE; // True/False /* 0x2B0 */ s16 cutscene; @@ -72,9 +65,9 @@ typedef struct EnPametfrog { /* 0x2BA */ s16 subCamId; /* 0x2BC */ s16 freezeTimer; /* 0x2C0 */ f32 wallRotation; - /* 0x2C4 */ f32 unk_2C4; - /* 0x2C8 */ f32 unk_2C8; - /* 0x2CC */ f32 unk_2CC; + /* 0x2C4 */ f32 drawDmgEffAlpha; + /* 0x2C8 */ f32 drawDmgEffScale; + /* 0x2CC */ f32 drawDmgEffFrozenSteamScale; /* 0x2D0 */ Vec3f unk_2D0; // MtxF zx/zy/zz /* 0x2DC */ Vec3f unk_2DC; // MtxF yx/yy/yz: wallNorm/floorNorm/Base of Gekko walking??? /* 0x2E8 */ Vec3f unk_2E8; // MtxF xx/xy/xz diff --git a/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c b/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c index f6da4cba28..a5321bf269 100644 --- a/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c +++ b/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c @@ -189,7 +189,7 @@ void EnPeehat_Init(Actor* thisx, GlobalContext* globalCtx) { if (this->actor.params == 0) { CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit1); - if (gSaveContext.isNight) { + if (gSaveContext.save.isNight) { this->actor.shape.yOffset = -1000.0f; } Actor_SetScale(&this->actor, 0.036f); @@ -227,21 +227,21 @@ void EnPeehat_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void func_80897170(EnPeehat* this) { - this->unk_2AE = 10; - this->unk_2CC = 1.1f; - this->unk_2D0 = 1.6500001f; - this->unk_2C8 = 1.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; + this->drawDmgEffScale = 1.1f; + this->drawDmgEffFrozenSteamScale = 1.6500001f; + this->drawDmgEffAlpha = 1.0f; this->colliderSphere.base.colType = COLTYPE_HIT3; this->unk_2B0 = 80; Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); } void func_808971DC(EnPeehat* this, GlobalContext* globalCtx) { - if (this->unk_2AE == 10) { - this->unk_2AE = 0; + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->colliderSphere.base.colType = COLTYPE_HIT6; - this->unk_2C8 = 0.0f; - Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_2EC, ARRAY_COUNT(this->unk_2EC), 2, 0.5f, 0.35f); + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), 2, 0.5f, 0.35f); } } @@ -296,7 +296,7 @@ void func_80897498(EnPeehat* this) { } void func_80897520(EnPeehat* this, GlobalContext* globalCtx) { - if (!gSaveContext.isNight) { + if (!gSaveContext.save.isNight) { this->actor.flags |= ACTOR_FLAG_1; this->colliderSphere.base.acFlags |= AC_ON; if (this->actor.xzDistToPlayer < 740.0f) { @@ -381,7 +381,7 @@ void func_80897910(EnPeehat* this, GlobalContext* globalCtx) { Math_StepToF(&this->actor.speedXZ, 3.0f, 0.25f); Math_StepToF(&this->actor.world.pos.y, this->actor.floorHeight + 80.0f, 3.0f); SkelAnime_Update(&this->skelAnime); - if (!gSaveContext.isNight && (Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) < 1200.0f)) { + if (!gSaveContext.save.isNight && (Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) < 1200.0f)) { Math_ScaledStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1000); this->actor.shape.rot.y += (s16)(this->unk_2AD * 450); } else { @@ -521,7 +521,7 @@ void func_80897F44(EnPeehat* this, GlobalContext* globalCtx) { this->actor.world.rot.y += this->unk_2B6; this->actor.shape.rot.y += 0x15E; - if (!gSaveContext.isNight && (Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) < 1200.0f)) { + if (!gSaveContext.save.isNight && (Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) < 1200.0f)) { this->actor.world.rot.y = this->actor.yawTowardsPlayer; func_80897864(this); } else { @@ -566,7 +566,7 @@ void func_80898144(EnPeehat* this, GlobalContext* globalCtx) { func_80897D00(this); } - if (!gSaveContext.isNight && (Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) < 1200.0f)) { + if (!gSaveContext.save.isNight && (Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) < 1200.0f)) { func_80897864(this); } func_800B9010(&this->actor, NA_SE_EN_PIHAT_FLY - SFX_FLAG); @@ -685,7 +685,8 @@ void func_8089874C(EnPeehat* this, GlobalContext* globalCtx) { if (this->colliderSphere.base.acFlags & AC_HIT) { this->colliderSphere.base.acFlags &= ~AC_HIT; - if ((this->unk_2AE != 10) || !(this->colliderSphere.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { + if ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || + !(this->colliderSphere.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { if (!Actor_ApplyDamage(&this->actor)) { Enemy_StartFinishingBlow(globalCtx, &this->actor); } @@ -698,9 +699,9 @@ void func_8089874C(EnPeehat* this, GlobalContext* globalCtx) { this->unk_2B0 = 40; Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); - this->unk_2CC = 1.1f; - this->unk_2C8 = 2.0f; - this->unk_2AE = 32; + this->drawDmgEffScale = 1.1f; + this->drawDmgEffAlpha = 2.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_LARGE; func_80898414(this); } else if (this->actor.colChkInfo.damageEffect == 1) { this->unk_2B0 = 40; @@ -716,13 +717,13 @@ void func_8089874C(EnPeehat* this, GlobalContext* globalCtx) { func_80898414(this); } else { if (this->actor.colChkInfo.damageEffect == 2) { - this->unk_2C8 = 4.0f; - this->unk_2CC = 2.1f; - this->unk_2AE = 0; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 2.1f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; } else if (this->actor.colChkInfo.damageEffect == 4) { - this->unk_2C8 = 4.0f; - this->unk_2CC = 1.1f; - this->unk_2AE = 20; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 1.1f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->colliderSphere.info.bumper.hitPos.x, this->colliderSphere.info.bumper.hitPos.y, this->colliderSphere.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); @@ -731,8 +732,10 @@ void func_8089874C(EnPeehat* this, GlobalContext* globalCtx) { func_808984E0(this); } } - } else if ((this->unk_2AE == 10) && (this->colliderCylinder.base.acFlags & AC_HIT) && - ((this->unk_2AE != 10) || !(this->colliderCylinder.info.acHitInfo->toucher.dmgFlags & 0xDB0B3))) { + } else if ((this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) && + (this->colliderCylinder.base.acFlags & AC_HIT) && + ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || + !(this->colliderCylinder.info.acHitInfo->toucher.dmgFlags & 0xDB0B3))) { func_808971DC(this, globalCtx); this->actor.colorFilterTimer = 0; func_80897648(this); @@ -812,17 +815,17 @@ void EnPeehat_Update(Actor* thisx, GlobalContext* globalCtx2) { Math_StepToF(&this->unk_2C4, 0.0f, 0.001f); } - if (this->unk_2C8 > 0.0f) { - if (this->unk_2AE != 10) { - Math_StepToF(&this->unk_2C8, 0.0f, 0.05f); - if (this->unk_2AE == 0) { - this->unk_2CC = (this->unk_2C8 + 1.0f) * 1.05f; - this->unk_2CC = CLAMP_MAX(this->unk_2CC, 2.1f); + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FIRE) { + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 1.05f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 2.1f); } else { - this->unk_2CC = (this->unk_2C8 + 1.0f) * 0.55f; - this->unk_2CC = CLAMP_MAX(this->unk_2CC, 1.1f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.55f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 1.1f); } - } else if (!Math_StepToF(&this->unk_2D0, 1.1f, 0.0275f)) { + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 1.1f, 0.0275f)) { func_800B9010(thisx, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } @@ -879,8 +882,8 @@ void EnPeehat_PostLimbDraw(GlobalContext* globalCtx2, s32 limbIndex, Gfx** dList Gfx* gfx; if (index != -1) { - Matrix_GetStateTranslationAndScaledX(2000.0f, &this->unk_2EC[index]); - Matrix_GetStateTranslationAndScaledX(4000.0f, &this->unk_2EC[index + 1]); + Matrix_GetStateTranslationAndScaledX(2000.0f, &this->limbPos[index]); + Matrix_GetStateTranslationAndScaledX(4000.0f, &this->limbPos[index + 1]); } if (limbIndex == 4) { @@ -888,7 +891,7 @@ void EnPeehat_PostLimbDraw(GlobalContext* globalCtx2, s32 limbIndex, Gfx** dList Matrix_GetStateTranslationAndScaledZ(-5500.0f, &this->unk_2D4[1]); } else if ((limbIndex == 3) && (thisx->params == 0)) { Vec3f* vec = &D_80899570[0]; - Vec3f* vec2 = &this->unk_2EC[12]; + Vec3f* vec2 = &this->limbPos[12]; for (i = 0; i < ARRAY_COUNT(D_80899570); i++, vec++, vec2++) { Matrix_MultiplyVector3fByState(vec, vec2); @@ -937,12 +940,12 @@ void EnPeehat_Draw(Actor* thisx, GlobalContext* globalCtx) { Collider_SetTrisVertices(&this->colliderTris, 1, &sp40, &sp58, &sp4C); } - if (this->unk_2AE == 0) { - for (i = 0; i < ARRAY_COUNT(this->unk_2EC); i++) { - this->unk_2EC[i].y -= 50.0f; + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FIRE) { + for (i = 0; i < ARRAY_COUNT(this->limbPos); i++) { + this->limbPos[i].y -= 50.0f; } } - func_800BE680(globalCtx, &this->actor, this->unk_2EC, ARRAY_COUNT(this->unk_2EC), this->unk_2CC, this->unk_2D0, - this->unk_2C8, this->unk_2AE); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, + this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, this->drawDmgEffType); } diff --git a/src/overlays/actors/ovl_En_Peehat/z_en_peehat.h b/src/overlays/actors/ovl_En_Peehat/z_en_peehat.h index 0aee3a7427..a7bda3577a 100644 --- a/src/overlays/actors/ovl_En_Peehat/z_en_peehat.h +++ b/src/overlays/actors/ovl_En_Peehat/z_en_peehat.h @@ -15,7 +15,7 @@ typedef struct EnPeehat { /* 0x2A8 */ EnPeehatActionFunc actionFunc; /* 0x2AC */ u8 unk_2AC; /* 0x2AD */ s8 unk_2AD; - /* 0x2AE */ u8 unk_2AE; + /* 0x2AE */ u8 drawDmgEffType; /* 0x2B0 */ s16 unk_2B0; /* 0x2B2 */ s16 unk_2B2; /* 0x2B4 */ s16 unk_2B4; @@ -24,11 +24,11 @@ typedef struct EnPeehat { /* 0x2BC */ f32 unk_2BC; /* 0x2C0 */ f32 unk_2C0; /* 0x2C4 */ f32 unk_2C4; - /* 0x2C8 */ f32 unk_2C8; - /* 0x2CC */ f32 unk_2CC; - /* 0x2D0 */ f32 unk_2D0; + /* 0x2C8 */ f32 drawDmgEffAlpha; + /* 0x2CC */ f32 drawDmgEffScale; + /* 0x2D0 */ f32 drawDmgEffFrozenSteamScale; /* 0x2D4 */ Vec3f unk_2D4[2]; - /* 0x2EC */ Vec3f unk_2EC[18]; + /* 0x2EC */ Vec3f limbPos[18]; /* 0x3C4 */ ColliderCylinder colliderCylinder; /* 0x410 */ ColliderSphere colliderSphere; /* 0x468 */ ColliderTris colliderTris; diff --git a/src/overlays/actors/ovl_En_Pm/z_en_pm.c b/src/overlays/actors/ovl_En_Pm/z_en_pm.c index 7792e578f4..4d59617326 100644 --- a/src/overlays/actors/ovl_En_Pm/z_en_pm.c +++ b/src/overlays/actors/ovl_En_Pm/z_en_pm.c @@ -20,69 +20,365 @@ void EnPm_Draw(Actor* thisx, GlobalContext* globalCtx); void func_80AFA4D0(EnPm* this, GlobalContext* globalCtx); void func_80AFA5FC(EnPm* this, GlobalContext* globalCtx); -// Game scripts -static UNK_TYPE D_80AFAD80[] = { - 0x0D000102, 0x3B030900, 0x0C00010B, 0x030C000D, 0x0100F902, 0x0D010F00, 0x12020F00, 0x00050105, 0x0A002E06, - 0x0E0F0000, 0x0508050A, 0x006D3102, 0x0D010D04, 0x25020D04, 0x0D151902, 0x0E300E38, 0x0D020E38, 0x0F000105, - 0x0E0E380F, 0x00020E0E, 0x300E383E, 0x0E0D040D, 0x15350E0D, 0x010D0401, 0x0A006F31, 0x020D040D, 0x1525020D, - 0x150D2719, 0x020E260E, 0x300D020E, 0x300E3801, 0x050E0E30, 0x0E383D0E, 0x0E260E30, 0x3C0E0D15, 0x0D27370E, - 0x0D040D15, 0x360A006C, 0x31020D27, 0x0D382502, 0x0D380E00, 0x19020E1A, 0x0E1E0D02, 0x0E1E0E26, 0x01050E0E, - 0x1E0E263B, 0x0E0E1A0E, 0x1E0B0E0D, 0x380E000A, 0x0E0D270D, 0x38380A00, 0x613D020D, 0x380E0031, 0x020E000E, - 0x0825020E, 0x080E1219, 0x020E120E, 0x1A0D020E, 0x1A0E1E01, 0x050E0E1A, 0x0E1E0D0E, 0x0E120E1A, 0x3A0E0E08, - 0x0E12100E, 0x0E000E08, 0x390E0D38, 0x0E000C05, 0x0A002E06, 0x0E0C000D, 0x0109050A, 0x006D3102, 0x09000903, - 0x25020903, 0x09111902, 0x0B2B0B39, 0x0D020B39, 0x0C000105, 0x0E0B390C, 0x00020E0B, 0x2B0B3934, 0x0E090309, - 0x11260E09, 0x00090301, 0x0A006F61, 0x02090309, 0x11550209, 0x11091F49, 0x02091F09, 0x233D0209, 0x23093131, - 0x020A390B, 0x0B25020B, 0x0B0B1919, 0x020B190B, 0x1D0D020B, 0x1D0B2B01, 0x050E0B1D, 0x0B2B320E, 0x0B190B1D, - 0x070E0B0B, 0x0B19300E, 0x0A390B0B, 0x2F0E0923, 0x0931290E, 0x091F0923, 0x030E0911, 0x091F280E, 0x09030911, - 0x270A006E, 0x25020931, 0x0A031902, 0x0A030A07, 0x0D020A07, 0x0A150105, 0x0E0A070A, 0x152B0E0A, 0x030A0704, - 0x0E09310A, 0x032A0A00, 0x6C61020A, 0x150A2355, 0x020A230A, 0x2749020A, 0x270A353D, 0x020A350A, 0x3931020A, - 0x390B0B25, 0x020B0B0B, 0x1919020B, 0x190B1D0D, 0x020B1D0B, 0x2B01050E, 0x0B1D0B2B, 0x330E0B19, 0x0B1D070E, - 0x0B0B0B19, 0x310E0A39, 0x0B0B2E0E, 0x0A350A39, 0x060E0A27, 0x0A352D0E, 0x0A230A27, 0x050E0A15, 0x0A232C05, - 0x0D000201, 0xCF011C08, 0x00A50309, 0x000C00FE, 0xC6030C00, 0x0D01008C, 0x020D010F, 0x007E0200, 0x00020001, - 0x050A006D, 0x31020000, 0x00042502, 0x0004001F, 0x1902011D, 0x01380D02, 0x01380200, 0x01050E01, 0x38020002, - 0x0E011D01, 0x384F0E00, 0x04001F4A, 0x0E000000, 0x04010A00, 0x6F3D0200, 0x04001F31, 0x02001F00, 0x3A250200, - 0x3A010219, 0x02010201, 0x1D0D0201, 0x1D013801, 0x050E011D, 0x01384E0E, 0x0102011D, 0x4D0E003A, 0x0102120E, - 0x001F003A, 0x4C0E0004, 0x001F4B05, 0x0A002E03, 0x04000E05, 0x0A002E06, 0x0E0C000D, 0x01140503, 0x09000C00, - 0xFE21030C, 0x000D0101, 0x0C020D01, 0x11001202, 0x11000005, 0x01050A00, 0x2E060E11, 0x00000508, 0x050A006D, - 0x31020D01, 0x0D042502, 0x0D040D0F, 0x19021023, 0x10390D02, 0x10391100, 0x01050E10, 0x39110002, 0x0E102310, - 0x39490E0D, 0x040D0F3F, 0x0E0D010D, 0x04010A00, 0x6F31020D, 0x040D0F25, 0x020D0F0D, 0x1E19020D, 0x340E2D0D, - 0x02100F10, 0x2301050E, 0x100F1023, 0x480E0D34, 0x0E2D430E, 0x0D0F0D1E, 0x410E0D04, 0x0D0F400A, 0x006C1902, - 0x0D1E0D34, 0x0D020D34, 0x0E320105, 0x0E0D340E, 0x32440E0D, 0x1E0D3442, 0x0A007068, 0x020E2D0F, 0x055C0C00, - 0x0231020F, 0x050F1425, 0x020F140F, 0x1919020F, 0x190F280D, 0x020F2810, 0x0F01050E, 0x0F28100F, 0x510E0F19, - 0x0F28110E, 0x0F140F19, 0x500E0F05, 0x0F141702, 0x0F050F14, 0x1B020F14, 0x0F320F02, 0x0F32100F, 0x03040000, - 0x0E0F3210, 0x0F470E0F, 0x140F3219, 0x0E0F050F, 0x14170E0E, 0x2D0F0546, 0x050A002E, 0x060E0C00, 0x0D011505, - 0x0D000301, 0x6F011C08, 0x013F011C, 0x10010C03, 0x09000C00, 0xFCED030C, 0x000D0100, 0xF6020D01, 0x0F000F02, - 0x12000600, 0x01050A00, 0x2E030400, 0x18050A00, 0x6D31020D, 0x000D0125, 0x020D050D, 0x0F19020E, 0x2D0E370D, - 0x020E370F, 0x0001050E, 0x0E370F00, 0x020E0E2D, 0x0E37340E, 0x0D050D0F, 0x260E0D00, 0x0D01010A, 0x006F4902, - 0x0D050D0F, 0x3D020D0F, 0x0D193102, 0x0D190D23, 0x25020E0F, 0x0E191902, 0x0E190E23, 0x0D020E23, 0x0E2D0105, - 0x0E0E230E, 0x2D320E0E, 0x190E2330, 0x0E0E0F0E, 0x192F0E0D, 0x190D2329, 0x0E0D0F0D, 0x19280E0D, 0x050D0F27, - 0x0A006E19, 0x020D230D, 0x2D0D020D, 0x2D0D3701, 0x050E0D2D, 0x0D372B0E, 0x0D230D2D, 0x2A0A006C, 0x3D020D37, - 0x0E053102, 0x0E050E0F, 0x25020E0F, 0x0E191902, 0x0E190E23, 0x0D020E23, 0x0E2D0105, 0x0E0E230E, 0x2D330E0E, - 0x190E2331, 0x0E0E0F0E, 0x192E0E0E, 0x050E0F2D, 0x0E0D370E, 0x052C050A, 0x002E0304, 0x00160503, 0x09000C00, - 0xFBE1020C, 0x000D0116, 0x030D0111, 0x00FDD202, 0x12000600, 0x01050A00, 0x2E030400, 0x18050A00, 0x2E060E0C, - 0x000D0115, 0x05030900, 0x0C00FBB3, 0x020C000D, 0x0116030D, 0x010F00FE, 0xD5021200, 0x06000105, 0x0A002E03, - 0x04001805, 0x0A002E03, 0x04001405, 0x05000000, +static u8 D_80AFAD80[] = { + /* 0x000 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_L(1, 0x240 - 0x005), + /* 0x005 */ SCHEDULE_CMD_CHECK_TIME_RANGE_L(9, 0, 12, 0, 0x117 - 0x00C), + /* 0x00C */ SCHEDULE_CMD_CHECK_TIME_RANGE_L(12, 0, 13, 1, 0x10C - 0x013), + /* 0x013 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 1, 15, 0, 0x02B - 0x019), + /* 0x019 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(15, 0, 0, 5, 0x020 - 0x01F), + /* 0x01F */ SCHEDULE_CMD_RET_NONE(), + /* 0x020 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_POSTHOUSE, 0x02A - 0x024), + /* 0x024 */ SCHEDULE_CMD_RET_TIME(15, 0, 0, 5, 8), + /* 0x02A */ SCHEDULE_CMD_RET_NONE(), + /* 0x02B */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_ICHIBA, 0x060 - 0x02F), + /* 0x02F */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 1, 13, 4, 0x05A - 0x035), + /* 0x035 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 4, 13, 21, 0x054 - 0x03B), + /* 0x03B */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 48, 14, 56, 0x04E - 0x041), + /* 0x041 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 56, 15, 0, 0x048 - 0x047), + /* 0x047 */ SCHEDULE_CMD_RET_NONE(), + /* 0x048 */ SCHEDULE_CMD_RET_TIME(14, 56, 15, 0, 2), + /* 0x04E */ SCHEDULE_CMD_RET_TIME(14, 48, 14, 56, 62), + /* 0x054 */ SCHEDULE_CMD_RET_TIME(13, 4, 13, 21, 53), + /* 0x05A */ SCHEDULE_CMD_RET_TIME(13, 1, 13, 4, 1), + /* 0x060 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_CLOCKTOWER, 0x095 - 0x064), + /* 0x064 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 4, 13, 21, 0x08F - 0x06A), + /* 0x06A */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 21, 13, 39, 0x089 - 0x070), + /* 0x070 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 38, 14, 48, 0x083 - 0x076), + /* 0x076 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 48, 14, 56, 0x07D - 0x07C), + /* 0x07C */ SCHEDULE_CMD_RET_NONE(), + /* 0x07D */ SCHEDULE_CMD_RET_TIME(14, 48, 14, 56, 61), + /* 0x083 */ SCHEDULE_CMD_RET_TIME(14, 38, 14, 48, 60), + /* 0x089 */ SCHEDULE_CMD_RET_TIME(13, 21, 13, 39, 55), + /* 0x08F */ SCHEDULE_CMD_RET_TIME(13, 4, 13, 21, 54), + /* 0x095 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_TOWN, 0x0CA - 0x099), + /* 0x099 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 39, 13, 56, 0x0C4 - 0x09F), + /* 0x09F */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 56, 14, 0, 0x0BE - 0x0A5), + /* 0x0A5 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 26, 14, 30, 0x0B8 - 0x0AB), + /* 0x0AB */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 30, 14, 38, 0x0B2 - 0x0B1), + /* 0x0B1 */ SCHEDULE_CMD_RET_NONE(), + /* 0x0B2 */ SCHEDULE_CMD_RET_TIME(14, 30, 14, 38, 59), + /* 0x0B8 */ SCHEDULE_CMD_RET_TIME(14, 26, 14, 30, 11), + /* 0x0BE */ SCHEDULE_CMD_RET_TIME(13, 56, 14, 0, 10), + /* 0x0C4 */ SCHEDULE_CMD_RET_TIME(13, 39, 13, 56, 56), + /* 0x0CA */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_YADOYA, 0x10B - 0x0CE), + /* 0x0CE */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 56, 14, 0, 0x105 - 0x0D4), + /* 0x0D4 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 0, 14, 8, 0x0FF - 0x0DA), + /* 0x0DA */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 8, 14, 18, 0x0F9 - 0x0E0), + /* 0x0E0 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 18, 14, 26, 0x0F3 - 0x0E6), + /* 0x0E6 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 26, 14, 30, 0x0ED - 0x0EC), + /* 0x0EC */ SCHEDULE_CMD_RET_NONE(), + /* 0x0ED */ SCHEDULE_CMD_RET_TIME(14, 26, 14, 30, 13), + /* 0x0F3 */ SCHEDULE_CMD_RET_TIME(14, 18, 14, 26, 58), + /* 0x0F9 */ SCHEDULE_CMD_RET_TIME(14, 8, 14, 18, 16), + /* 0x0FF */ SCHEDULE_CMD_RET_TIME(14, 0, 14, 8, 57), + /* 0x105 */ SCHEDULE_CMD_RET_TIME(13, 56, 14, 0, 12), + /* 0x10B */ SCHEDULE_CMD_RET_NONE(), + /* 0x10C */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_POSTHOUSE, 0x116 - 0x110), + /* 0x110 */ SCHEDULE_CMD_RET_TIME(12, 0, 13, 1, 9), + /* 0x116 */ SCHEDULE_CMD_RET_NONE(), + /* 0x117 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_ICHIBA, 0x14C - 0x11B), + /* 0x11B */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(9, 0, 9, 3, 0x146 - 0x121), + /* 0x121 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(9, 3, 9, 17, 0x140 - 0x127), + /* 0x127 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(11, 43, 11, 57, 0x13A - 0x12D), + /* 0x12D */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(11, 57, 12, 0, 0x134 - 0x133), + /* 0x133 */ SCHEDULE_CMD_RET_NONE(), + /* 0x134 */ SCHEDULE_CMD_RET_TIME(11, 57, 12, 0, 2), + /* 0x13A */ SCHEDULE_CMD_RET_TIME(11, 43, 11, 57, 52), + /* 0x140 */ SCHEDULE_CMD_RET_TIME(9, 3, 9, 17, 38), + /* 0x146 */ SCHEDULE_CMD_RET_TIME(9, 0, 9, 3, 1), + /* 0x14C */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_CLOCKTOWER, 0x1B1 - 0x150), + /* 0x150 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(9, 3, 9, 17, 0x1AB - 0x156), + /* 0x156 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(9, 17, 9, 31, 0x1A5 - 0x15C), + /* 0x15C */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(9, 31, 9, 35, 0x19F - 0x162), + /* 0x162 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(9, 35, 9, 49, 0x199 - 0x168), + /* 0x168 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 57, 11, 11, 0x193 - 0x16E), + /* 0x16E */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(11, 11, 11, 25, 0x18D - 0x174), + /* 0x174 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(11, 25, 11, 29, 0x187 - 0x17A), + /* 0x17A */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(11, 29, 11, 43, 0x181 - 0x180), + /* 0x180 */ SCHEDULE_CMD_RET_NONE(), + /* 0x181 */ SCHEDULE_CMD_RET_TIME(11, 29, 11, 43, 50), + /* 0x187 */ SCHEDULE_CMD_RET_TIME(11, 25, 11, 29, 7), + /* 0x18D */ SCHEDULE_CMD_RET_TIME(11, 11, 11, 25, 48), + /* 0x193 */ SCHEDULE_CMD_RET_TIME(10, 57, 11, 11, 47), + /* 0x199 */ SCHEDULE_CMD_RET_TIME(9, 35, 9, 49, 41), + /* 0x19F */ SCHEDULE_CMD_RET_TIME(9, 31, 9, 35, 3), + /* 0x1A5 */ SCHEDULE_CMD_RET_TIME(9, 17, 9, 31, 40), + /* 0x1AB */ SCHEDULE_CMD_RET_TIME(9, 3, 9, 17, 39), + /* 0x1B1 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_BACKTOWN, 0x1DA - 0x1B5), + /* 0x1B5 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(9, 49, 10, 3, 0x1D4 - 0x1BB), + /* 0x1BB */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 3, 10, 7, 0x1CE - 0x1C1), + /* 0x1C1 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 7, 10, 21, 0x1C8 - 0x1C7), + /* 0x1C7 */ SCHEDULE_CMD_RET_NONE(), + /* 0x1C8 */ SCHEDULE_CMD_RET_TIME(10, 7, 10, 21, 43), + /* 0x1CE */ SCHEDULE_CMD_RET_TIME(10, 3, 10, 7, 4), + /* 0x1D4 */ SCHEDULE_CMD_RET_TIME(9, 49, 10, 3, 42), + /* 0x1DA */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_TOWN, 0x23F - 0x1DE), + /* 0x1DE */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 21, 10, 35, 0x239 - 0x1E4), + /* 0x1E4 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 35, 10, 39, 0x233 - 0x1EA), + /* 0x1EA */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 39, 10, 53, 0x22D - 0x1F0), + /* 0x1F0 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 53, 10, 57, 0x227 - 0x1F6), + /* 0x1F6 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 57, 11, 11, 0x221 - 0x1FC), + /* 0x1FC */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(11, 11, 11, 25, 0x21B - 0x202), + /* 0x202 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(11, 25, 11, 29, 0x215 - 0x208), + /* 0x208 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(11, 29, 11, 43, 0x20F - 0x20E), + /* 0x20E */ SCHEDULE_CMD_RET_NONE(), + /* 0x20F */ SCHEDULE_CMD_RET_TIME(11, 29, 11, 43, 51), + /* 0x215 */ SCHEDULE_CMD_RET_TIME(11, 25, 11, 29, 7), + /* 0x21B */ SCHEDULE_CMD_RET_TIME(11, 11, 11, 25, 49), + /* 0x221 */ SCHEDULE_CMD_RET_TIME(10, 57, 11, 11, 46), + /* 0x227 */ SCHEDULE_CMD_RET_TIME(10, 53, 10, 57, 6), + /* 0x22D */ SCHEDULE_CMD_RET_TIME(10, 39, 10, 53, 45), + /* 0x233 */ SCHEDULE_CMD_RET_TIME(10, 35, 10, 39, 5), + /* 0x239 */ SCHEDULE_CMD_RET_TIME(10, 21, 10, 35, 44), + /* 0x23F */ SCHEDULE_CMD_RET_NONE(), + /* 0x240 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_L(2, 0x414 - 0x245), + /* 0x245 */ SCHEDULE_CMD_CHECK_FLAG_L(0x1C, 0x08, 0x2EF - 0x24A), + /* 0x24A */ SCHEDULE_CMD_CHECK_TIME_RANGE_L(9, 0, 12, 0, 0x117 - 0x251), + /* 0x251 */ SCHEDULE_CMD_CHECK_TIME_RANGE_L(12, 0, 13, 1, 0x2E4 - 0x258), + /* 0x258 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 1, 15, 0, 0x2DC - 0x25E), + /* 0x25E */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 0, 2, 0, 0x265 - 0x264), + /* 0x264 */ SCHEDULE_CMD_RET_NONE(), + /* 0x265 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_ICHIBA, 0x29A - 0x269), + /* 0x269 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 0, 0, 4, 0x294 - 0x26F), + /* 0x26F */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 4, 0, 31, 0x28E - 0x275), + /* 0x275 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(1, 29, 1, 56, 0x288 - 0x27B), + /* 0x27B */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(1, 56, 2, 0, 0x282 - 0x281), + /* 0x281 */ SCHEDULE_CMD_RET_NONE(), + /* 0x282 */ SCHEDULE_CMD_RET_TIME(1, 56, 2, 0, 2), + /* 0x288 */ SCHEDULE_CMD_RET_TIME(1, 29, 1, 56, 79), + /* 0x28E */ SCHEDULE_CMD_RET_TIME(0, 4, 0, 31, 74), + /* 0x294 */ SCHEDULE_CMD_RET_TIME(0, 0, 0, 4, 1), + /* 0x29A */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_CLOCKTOWER, 0x2DB - 0x29E), + /* 0x29E */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 4, 0, 31, 0x2D5 - 0x2A4), + /* 0x2A4 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 31, 0, 58, 0x2CF - 0x2AA), + /* 0x2AA */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 58, 1, 2, 0x2C9 - 0x2B0), + /* 0x2B0 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(1, 2, 1, 29, 0x2C3 - 0x2B6), + /* 0x2B6 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(1, 29, 1, 56, 0x2BD - 0x2BC), + /* 0x2BC */ SCHEDULE_CMD_RET_NONE(), + /* 0x2BD */ SCHEDULE_CMD_RET_TIME(1, 29, 1, 56, 78), + /* 0x2C3 */ SCHEDULE_CMD_RET_TIME(1, 2, 1, 29, 77), + /* 0x2C9 */ SCHEDULE_CMD_RET_TIME(0, 58, 1, 2, 18), + /* 0x2CF */ SCHEDULE_CMD_RET_TIME(0, 31, 0, 58, 76), + /* 0x2D5 */ SCHEDULE_CMD_RET_TIME(0, 4, 0, 31, 75), + /* 0x2DB */ SCHEDULE_CMD_RET_NONE(), + /* 0x2DC */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_POSTHOUSE, 0x2E3 - 0x2E0), + /* 0x2E0 */ SCHEDULE_CMD_RET_VAL_L(14), + /* 0x2E3 */ SCHEDULE_CMD_RET_NONE(), + /* 0x2E4 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_POSTHOUSE, 0x2EE - 0x2E8), + /* 0x2E8 */ SCHEDULE_CMD_RET_TIME(12, 0, 13, 1, 20), + /* 0x2EE */ SCHEDULE_CMD_RET_NONE(), + /* 0x2EF */ SCHEDULE_CMD_CHECK_TIME_RANGE_L(9, 0, 12, 0, 0x117 - 0x2F6), + /* 0x2F6 */ SCHEDULE_CMD_CHECK_TIME_RANGE_L(12, 0, 13, 1, 0x409 - 0x2FD), + /* 0x2FD */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 1, 17, 0, 0x315 - 0x303), + /* 0x303 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(17, 0, 0, 5, 0x30A - 0x309), + /* 0x309 */ SCHEDULE_CMD_RET_NONE(), + /* 0x30A */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_POSTHOUSE, 0x314 - 0x30E), + /* 0x30E */ SCHEDULE_CMD_RET_TIME(17, 0, 0, 5, 8), + /* 0x314 */ SCHEDULE_CMD_RET_NONE(), + /* 0x315 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_ICHIBA, 0x34A - 0x319), + /* 0x319 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 1, 13, 4, 0x344 - 0x31F), + /* 0x31F */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 4, 13, 15, 0x33E - 0x325), + /* 0x325 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(16, 35, 16, 57, 0x338 - 0x32B), + /* 0x32B */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(16, 57, 17, 0, 0x332 - 0x331), + /* 0x331 */ SCHEDULE_CMD_RET_NONE(), + /* 0x332 */ SCHEDULE_CMD_RET_TIME(16, 57, 17, 0, 2), + /* 0x338 */ SCHEDULE_CMD_RET_TIME(16, 35, 16, 57, 73), + /* 0x33E */ SCHEDULE_CMD_RET_TIME(13, 4, 13, 15, 63), + /* 0x344 */ SCHEDULE_CMD_RET_TIME(13, 1, 13, 4, 1), + /* 0x34A */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_CLOCKTOWER, 0x37F - 0x34E), + /* 0x34E */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 4, 13, 15, 0x379 - 0x354), + /* 0x354 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 15, 13, 30, 0x373 - 0x35A), + /* 0x35A */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 52, 14, 45, 0x36D - 0x360), + /* 0x360 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(16, 15, 16, 35, 0x367 - 0x366), + /* 0x366 */ SCHEDULE_CMD_RET_NONE(), + /* 0x367 */ SCHEDULE_CMD_RET_TIME(16, 15, 16, 35, 72), + /* 0x36D */ SCHEDULE_CMD_RET_TIME(13, 52, 14, 45, 67), + /* 0x373 */ SCHEDULE_CMD_RET_TIME(13, 15, 13, 30, 65), + /* 0x379 */ SCHEDULE_CMD_RET_TIME(13, 4, 13, 15, 64), + /* 0x37F */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_TOWN, 0x39C - 0x383), + /* 0x383 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 30, 13, 52, 0x396 - 0x389), + /* 0x389 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 52, 14, 50, 0x390 - 0x38F), + /* 0x38F */ SCHEDULE_CMD_RET_NONE(), + /* 0x390 */ SCHEDULE_CMD_RET_TIME(13, 52, 14, 50, 68), + /* 0x396 */ SCHEDULE_CMD_RET_TIME(13, 30, 13, 52, 66), + /* 0x39C */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_ALLEY, 0x408 - 0x3A0), + /* 0x3A0 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 45, 15, 5, 0x402 - 0x3A6), + /* 0x3A6 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(2, 0x3DB - 0x3AA), + /* 0x3AA */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(15, 5, 15, 20, 0x3D5 - 0x3B0), + /* 0x3B0 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(15, 20, 15, 25, 0x3CF - 0x3B6), + /* 0x3B6 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(15, 25, 15, 40, 0x3C9 - 0x3BC), + /* 0x3BC */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(15, 40, 16, 15, 0x3C3 - 0x3C2), + /* 0x3C2 */ SCHEDULE_CMD_RET_NONE(), + /* 0x3C3 */ SCHEDULE_CMD_RET_TIME(15, 40, 16, 15, 81), + /* 0x3C9 */ SCHEDULE_CMD_RET_TIME(15, 25, 15, 40, 17), + /* 0x3CF */ SCHEDULE_CMD_RET_TIME(15, 20, 15, 25, 80), + /* 0x3D5 */ SCHEDULE_CMD_RET_TIME(15, 5, 15, 20, 23), + /* 0x3DB */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(15, 5, 15, 20, 0x3FC - 0x3E1), + /* 0x3E1 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(15, 20, 15, 50, 0x3F6 - 0x3E7), + /* 0x3E7 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(15, 50, 16, 15, 0x3F0 - 0x3ED), + /* 0x3ED */ SCHEDULE_CMD_RET_VAL_L(0), + /* 0x3F0 */ SCHEDULE_CMD_RET_TIME(15, 50, 16, 15, 71), + /* 0x3F6 */ SCHEDULE_CMD_RET_TIME(15, 20, 15, 50, 25), + /* 0x3FC */ SCHEDULE_CMD_RET_TIME(15, 5, 15, 20, 23), + /* 0x402 */ SCHEDULE_CMD_RET_TIME(14, 45, 15, 5, 70), + /* 0x408 */ SCHEDULE_CMD_RET_NONE(), + /* 0x409 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_POSTHOUSE, 0x413 - 0x40D), + /* 0x40D */ SCHEDULE_CMD_RET_TIME(12, 0, 13, 1, 21), + /* 0x413 */ SCHEDULE_CMD_RET_NONE(), + /* 0x414 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_L(3, 0x588 - 0x419), + /* 0x419 */ SCHEDULE_CMD_CHECK_FLAG_L(0x1C, 0x08, 0x55D - 0x41E), + /* 0x41E */ SCHEDULE_CMD_CHECK_FLAG_L(0x1C, 0x10, 0x52F - 0x423), + /* 0x423 */ SCHEDULE_CMD_CHECK_TIME_RANGE_L(9, 0, 12, 0, 0x117 - 0x42A), + /* 0x42A */ SCHEDULE_CMD_CHECK_TIME_RANGE_L(12, 0, 13, 1, 0x527 - 0x431), + /* 0x431 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 1, 15, 0, 0x446 - 0x437), + /* 0x437 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(18, 0, 6, 0, 0x43E - 0x43D), + /* 0x43D */ SCHEDULE_CMD_RET_NONE(), + /* 0x43E */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_POSTHOUSE, 0x445 - 0x442), + /* 0x442 */ SCHEDULE_CMD_RET_VAL_L(24), + /* 0x445 */ SCHEDULE_CMD_RET_NONE(), + /* 0x446 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_ICHIBA, 0x47B - 0x44A), + /* 0x44A */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 0, 13, 1, 0x475 - 0x450), + /* 0x450 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 5, 13, 15, 0x46F - 0x456), + /* 0x456 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 45, 14, 55, 0x469 - 0x45C), + /* 0x45C */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 55, 15, 0, 0x463 - 0x462), + /* 0x462 */ SCHEDULE_CMD_RET_NONE(), + /* 0x463 */ SCHEDULE_CMD_RET_TIME(14, 55, 15, 0, 2), + /* 0x469 */ SCHEDULE_CMD_RET_TIME(14, 45, 14, 55, 52), + /* 0x46F */ SCHEDULE_CMD_RET_TIME(13, 5, 13, 15, 38), + /* 0x475 */ SCHEDULE_CMD_RET_TIME(13, 0, 13, 1, 1), + /* 0x47B */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_CLOCKTOWER, 0x4C8 - 0x47F), + /* 0x47F */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 5, 13, 15, 0x4C2 - 0x485), + /* 0x485 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 15, 13, 25, 0x4BC - 0x48B), + /* 0x48B */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 25, 13, 35, 0x4B6 - 0x491), + /* 0x491 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 15, 14, 25, 0x4B0 - 0x497), + /* 0x497 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 25, 14, 35, 0x4AA - 0x49D), + /* 0x49D */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 35, 14, 45, 0x4A4 - 0x4A3), + /* 0x4A3 */ SCHEDULE_CMD_RET_NONE(), + /* 0x4A4 */ SCHEDULE_CMD_RET_TIME(14, 35, 14, 45, 50), + /* 0x4AA */ SCHEDULE_CMD_RET_TIME(14, 25, 14, 35, 48), + /* 0x4B0 */ SCHEDULE_CMD_RET_TIME(14, 15, 14, 25, 47), + /* 0x4B6 */ SCHEDULE_CMD_RET_TIME(13, 25, 13, 35, 41), + /* 0x4BC */ SCHEDULE_CMD_RET_TIME(13, 15, 13, 25, 40), + /* 0x4C2 */ SCHEDULE_CMD_RET_TIME(13, 5, 13, 15, 39), + /* 0x4C8 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_BACKTOWN, 0x4E5 - 0x4CC), + /* 0x4CC */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 35, 13, 45, 0x4DF - 0x4D2), + /* 0x4D2 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 45, 13, 55, 0x4D9 - 0x4D8), + /* 0x4D8 */ SCHEDULE_CMD_RET_NONE(), + /* 0x4D9 */ SCHEDULE_CMD_RET_TIME(13, 45, 13, 55, 43), + /* 0x4DF */ SCHEDULE_CMD_RET_TIME(13, 35, 13, 45, 42), + /* 0x4E5 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_TOWN, 0x526 - 0x4E9), + /* 0x4E9 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 55, 14, 5, 0x520 - 0x4EF), + /* 0x4EF */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 5, 14, 15, 0x51A - 0x4F5), + /* 0x4F5 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 15, 14, 25, 0x514 - 0x4FB), + /* 0x4FB */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 25, 14, 35, 0x50E - 0x501), + /* 0x501 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 35, 14, 45, 0x508 - 0x507), + /* 0x507 */ SCHEDULE_CMD_RET_NONE(), + /* 0x508 */ SCHEDULE_CMD_RET_TIME(14, 35, 14, 45, 51), + /* 0x50E */ SCHEDULE_CMD_RET_TIME(14, 25, 14, 35, 49), + /* 0x514 */ SCHEDULE_CMD_RET_TIME(14, 15, 14, 25, 46), + /* 0x51A */ SCHEDULE_CMD_RET_TIME(14, 5, 14, 15, 45), + /* 0x520 */ SCHEDULE_CMD_RET_TIME(13, 55, 14, 5, 44), + /* 0x526 */ SCHEDULE_CMD_RET_NONE(), + /* 0x527 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_POSTHOUSE, 0x52E - 0x52B), + /* 0x52B */ SCHEDULE_CMD_RET_VAL_L(22), + /* 0x52E */ SCHEDULE_CMD_RET_NONE(), + /* 0x52F */ SCHEDULE_CMD_CHECK_TIME_RANGE_L(9, 0, 12, 0, 0x117 - 0x536), + /* 0x536 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(12, 0, 13, 1, 0x552 - 0x53C), + /* 0x53C */ SCHEDULE_CMD_CHECK_TIME_RANGE_L(13, 1, 17, 0, 0x315 - 0x543), + /* 0x543 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(18, 0, 6, 0, 0x54A - 0x549), + /* 0x549 */ SCHEDULE_CMD_RET_NONE(), + /* 0x54A */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_POSTHOUSE, 0x551 - 0x54E), + /* 0x54E */ SCHEDULE_CMD_RET_VAL_L(24), + /* 0x551 */ SCHEDULE_CMD_RET_NONE(), + /* 0x552 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_POSTHOUSE, 0x55C - 0x556), + /* 0x556 */ SCHEDULE_CMD_RET_TIME(12, 0, 13, 1, 21), + /* 0x55C */ SCHEDULE_CMD_RET_NONE(), + /* 0x55D */ SCHEDULE_CMD_CHECK_TIME_RANGE_L(9, 0, 12, 0, 0x117 - 0x564), + /* 0x564 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(12, 0, 13, 1, 0x580 - 0x56A), + /* 0x56A */ SCHEDULE_CMD_CHECK_TIME_RANGE_L(13, 1, 15, 0, 0x446 - 0x571), + /* 0x571 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(18, 0, 6, 0, 0x578 - 0x577), + /* 0x577 */ SCHEDULE_CMD_RET_NONE(), + /* 0x578 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_POSTHOUSE, 0x57F - 0x57C), + /* 0x57C */ SCHEDULE_CMD_RET_VAL_L(24), + /* 0x57F */ SCHEDULE_CMD_RET_NONE(), + /* 0x580 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_POSTHOUSE, 0x587 - 0x584), + /* 0x584 */ SCHEDULE_CMD_RET_VAL_L(20), + /* 0x587 */ SCHEDULE_CMD_RET_NONE(), + /* 0x588 */ SCHEDULE_CMD_RET_NONE(), }; -static UNK_TYPE D_80AFB30C[] = { - 0x0A002E2E, 0x02000000, 0x0A220200, 0x0A000D19, 0x02000D00, 0x170D0200, 0x17001A01, 0x050E0017, 0x001A200E, - 0x000D0017, 0x5304001B, 0x0E000000, 0x0A520A00, 0x6D190200, 0x17001A0D, 0x02001A00, 0x2401050E, 0x001A0024, - 0x540E0017, 0x001A210A, 0x006F1902, 0x001A0024, 0x0D020024, 0x002E0105, 0x0E002400, 0x2E560E00, 0x1A002455, - 0x0A006C19, 0x02002E00, 0x380D0200, 0x38003B01, 0x050E0038, 0x003B220E, 0x002E0038, 0x570A0015, 0x25020038, - 0x003B1902, 0x003B0109, 0x0D020109, 0x01280105, 0x0E010901, 0x281C0E00, 0x3B010958, 0x0E003800, 0x3B240500, +static u8 D_80AFB30C[] = { + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_POSTHOUSE, 0x32 - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 0, 0, 10, 0x2C - 0x0A), + /* 0x0A */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 10, 0, 13, 0x29 - 0x10), + /* 0x10 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 13, 0, 23, 0x23 - 0x16), + /* 0x16 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 23, 0, 26, 0x1D - 0x1C), + /* 0x1C */ SCHEDULE_CMD_RET_NONE(), + /* 0x1D */ SCHEDULE_CMD_RET_TIME(0, 23, 0, 26, 32), + /* 0x23 */ SCHEDULE_CMD_RET_TIME(0, 13, 0, 23, 83), + /* 0x29 */ SCHEDULE_CMD_RET_VAL_L(27), + /* 0x2C */ SCHEDULE_CMD_RET_TIME(0, 0, 0, 10, 82), + /* 0x32 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_ICHIBA, 0x4F - 0x36), + /* 0x36 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 23, 0, 26, 0x49 - 0x3C), + /* 0x3C */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 26, 0, 36, 0x43 - 0x42), + /* 0x42 */ SCHEDULE_CMD_RET_NONE(), + /* 0x43 */ SCHEDULE_CMD_RET_TIME(0, 26, 0, 36, 84), + /* 0x49 */ SCHEDULE_CMD_RET_TIME(0, 23, 0, 26, 33), + /* 0x4F */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_CLOCKTOWER, 0x6C - 0x53), + /* 0x53 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 26, 0, 36, 0x66 - 0x59), + /* 0x59 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 36, 0, 46, 0x60 - 0x5F), + /* 0x5F */ SCHEDULE_CMD_RET_NONE(), + /* 0x60 */ SCHEDULE_CMD_RET_TIME(0, 36, 0, 46, 86), + /* 0x66 */ SCHEDULE_CMD_RET_TIME(0, 26, 0, 36, 85), + /* 0x6C */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_TOWN, 0x89 - 0x70), + /* 0x70 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 46, 0, 56, 0x83 - 0x76), + /* 0x76 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 56, 0, 59, 0x7D - 0x7C), + /* 0x7C */ SCHEDULE_CMD_RET_NONE(), + /* 0x7D */ SCHEDULE_CMD_RET_TIME(0, 56, 0, 59, 34), + /* 0x83 */ SCHEDULE_CMD_RET_TIME(0, 46, 0, 56, 87), + /* 0x89 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_MILK_BAR, 0xB2 - 0x8D), + /* 0x8D */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 56, 0, 59, 0xAC - 0x93), + /* 0x93 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 59, 1, 9, 0xA6 - 0x99), + /* 0x99 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(1, 9, 1, 40, 0xA0 - 0x9F), + /* 0x9F */ SCHEDULE_CMD_RET_NONE(), + /* 0xA0 */ SCHEDULE_CMD_RET_TIME(1, 9, 1, 40, 28), + /* 0xA6 */ SCHEDULE_CMD_RET_TIME(0, 59, 1, 9, 88), + /* 0xAC */ SCHEDULE_CMD_RET_TIME(0, 56, 0, 59, 36), + /* 0xB2 */ SCHEDULE_CMD_RET_NONE(), }; -static UNK_TYPE D_80AFB3C0[] = { - 0x0A006C19, 0x02000A00, 0x0D0D0200, 0x0D001701, 0x050E000D, 0x00175A0E, 0x000A000D, 0x230A0015, - 0x19020000, 0x000A0D02, 0x000A000D, 0x01050E00, 0x0A000D25, 0x0E000000, 0x0A590500, +static u8 D_80AFB3C0[] = { + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_TOWN, 0x1D - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 10, 0, 13, 0x17 - 0x0A), + /* 0x0A */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 13, 0, 23, 0x11 - 0x10), + /* 0x10 */ SCHEDULE_CMD_RET_NONE(), + /* 0x11 */ SCHEDULE_CMD_RET_TIME(0, 13, 0, 23, 90), + /* 0x17 */ SCHEDULE_CMD_RET_TIME(0, 10, 0, 13, 35), + /* 0x1D */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_MILK_BAR, 0x3A - 0x21), + /* 0x21 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 0, 0, 10, 0x34 - 0x27), + /* 0x27 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 10, 0, 13, 0x2E - 0x2D), + /* 0x2D */ SCHEDULE_CMD_RET_NONE(), + /* 0x2E */ SCHEDULE_CMD_RET_TIME(0, 10, 0, 13, 37), + /* 0x34 */ SCHEDULE_CMD_RET_TIME(0, 0, 0, 10, 89), + /* 0x3A */ SCHEDULE_CMD_RET_NONE(), }; -static UNK_TYPE D_80AFB3FC[] = { - 0x0A006C19, 0x02120006, 0x000D0205, 0x00050A01, 0x050E0500, 0x050A5B0E, 0x12000600, 0x1D050000, +static u8 D_80AFB3FC[] = { + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_TOWN, 0x1D - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(18, 0, 6, 0, 0x17 - 0x0A), + /* 0x0A */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(5, 0, 5, 10, 0x11 - 0x10), + /* 0x10 */ SCHEDULE_CMD_RET_NONE(), + /* 0x11 */ SCHEDULE_CMD_RET_TIME(5, 0, 5, 10, 91), + /* 0x17 */ SCHEDULE_CMD_RET_TIME(18, 0, 6, 0, 29), + /* 0x1D */ SCHEDULE_CMD_RET_NONE(), }; -static UNK_TYPE D_80AFB41C[] = { - 0x0A006C0D, 0x02000000, 0x0A01050E, 0x0000000A, 0x5B050000, +static u8 D_80AFB41C[] = { + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_TOWN, 0x11 - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 0, 0, 10, 0x0B - 0x0A), + /* 0x0A */ SCHEDULE_CMD_RET_NONE(), + /* 0x0B */ SCHEDULE_CMD_RET_TIME(0, 0, 0, 10, 91), + /* 0x11 */ SCHEDULE_CMD_RET_NONE(), }; static s32 D_80AFB430[] = { @@ -248,19 +544,19 @@ static AnimationInfoS sAnimations[] = { }; s32 func_80AF7B40(void) { - if (gSaveContext.weekEventReg[90] & 1) { + if (gSaveContext.save.weekEventReg[90] & 1) { return 4; } - if (gSaveContext.weekEventReg[89] & 0x40) { + if (gSaveContext.save.weekEventReg[89] & 0x40) { return 3; } - if (gSaveContext.weekEventReg[89] & 8) { + if (gSaveContext.save.weekEventReg[89] & 8) { return 2; } - if (gSaveContext.weekEventReg[86] & 1) { + if (gSaveContext.save.weekEventReg[86] & 1) { return 1; } @@ -270,29 +566,29 @@ s32 func_80AF7B40(void) { s32 func_80AF7BAC(EnPm* this) { switch (this->unk_38C) { case 0: - if (gSaveContext.weekEventReg[86] & 1) { - D_801F4E78 = gSaveContext.time; + if (gSaveContext.save.weekEventReg[86] & 1) { + D_801F4E78 = gSaveContext.save.time; this->unk_38C++; } break; case 1: - if (gSaveContext.weekEventReg[89] & 8) { - D_801F4E78 = gSaveContext.time; + if (gSaveContext.save.weekEventReg[89] & 8) { + D_801F4E78 = gSaveContext.save.time; this->unk_38C++; } break; case 2: - if (gSaveContext.weekEventReg[89] & 0x40) { + if (gSaveContext.save.weekEventReg[89] & 0x40) { D_801F4E78 = 0; this->unk_38C++; } break; case 3: - if (gSaveContext.weekEventReg[90] & 1) { - D_801F4E78 = gSaveContext.time; + if (gSaveContext.save.weekEventReg[90] & 1) { + D_801F4E78 = gSaveContext.save.time; this->unk_38C++; } break; @@ -547,7 +843,7 @@ s32 func_80AF81E8(EnPm* this, GlobalContext* globalCtx) { case 1: case 3: case 5: - if ((gSaveContext.weekEventReg[86] & 8) && (this->unk_378 == 3)) { + if ((gSaveContext.save.weekEventReg[86] & 8) && (this->unk_378 == 3)) { ActorCutscene_Stop(sp2A); } else { Camera_SetTargetActor(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), &this->actor); @@ -816,30 +1112,32 @@ void func_80AF8BA8(s32 arg0) { }; s32 temp; - if (!(gSaveContext.weekEventReg[88] & 2)) { - if (gSaveContext.weekEventReg[D_80AFB8D4[arg0] >> 8] & (D_80AFB8D4[arg0] & (1 | 2 | 4 | 0x38 | 0x40 | 0x80))) { - switch (gSaveContext.day) { + if (!(gSaveContext.save.weekEventReg[88] & 2)) { + if (gSaveContext.save.weekEventReg[D_80AFB8D4[arg0] >> 8] & + (D_80AFB8D4[arg0] & (1 | 2 | 4 | 0x38 | 0x40 | 0x80))) { + switch (gSaveContext.save.day) { case 2: - gSaveContext.weekEventReg[28] |= 8; + gSaveContext.save.weekEventReg[28] |= 8; break; case 3: - gSaveContext.weekEventReg[28] |= 0x10; + gSaveContext.save.weekEventReg[28] |= 0x10; break; } - gSaveContext.weekEventReg[51] |= 2; - gSaveContext.weekEventReg[90] |= 8; + gSaveContext.save.weekEventReg[51] |= 2; + gSaveContext.save.weekEventReg[90] |= 8; } } - temp = gSaveContext.weekEventReg[D_80AFB8E0[arg0] >> 8]; - gSaveContext.weekEventReg[D_80AFB8E0[arg0] >> 8] = temp | (D_80AFB8E0[arg0] & (1 | 2 | 4 | 0x38 | 0x40 | 0x80)); + temp = gSaveContext.save.weekEventReg[D_80AFB8E0[arg0] >> 8]; + gSaveContext.save.weekEventReg[D_80AFB8E0[arg0] >> 8] = + temp | (D_80AFB8E0[arg0] & (1 | 2 | 4 | 0x38 | 0x40 | 0x80)); } void func_80AF8C68(EnPm* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 sp28 = Message_GetState(&globalCtx->msgCtx); - u16 temp_a0 = globalCtx->msgCtx.unk11F04; + u16 temp_a0 = globalCtx->msgCtx.currentTextId; if ((player->targetActor == &this->actor) && ((temp_a0 < 255) || (temp_a0 > 512)) && (sp28 == 3) && (this->unk_388 == 3)) { @@ -873,7 +1171,7 @@ s32 func_80AF8D84(EnPm* this, GlobalContext* globalCtx) { s32 func_80AF8DD4(EnPm* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - u16 temp = globalCtx->msgCtx.unk11F04; + u16 temp = globalCtx->msgCtx.currentTextId; s32 pad; if (player->stateFlags1 & (0x400 | 0x40)) { @@ -902,7 +1200,7 @@ s32 func_80AF8DD4(EnPm* this, GlobalContext* globalCtx) { return 0; } -s32 func_80AF8ED4(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2, u8 actorCat, s16 actorId) { +s32 func_80AF8ED4(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2, u8 actorCat, s16 actorId) { u8 sp4F = this->actor.params & 0xFF; Vec3s* sp48; Vec3f sp3C; @@ -913,8 +1211,8 @@ s32 func_80AF8ED4(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_234 = NULL; sp2C = func_80AF7CB0(this, globalCtx, actorCat, actorId); - if (D_80AFB430[arg2->unk0] >= 0) { - this->unk_234 = func_8013BB34(globalCtx, sp4F, D_80AFB430[arg2->unk0]); + if (D_80AFB430[arg2->result] >= 0) { + this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80AFB430[arg2->result]); } if ((sp2C != NULL) && (sp2C->update != NULL)) { @@ -932,8 +1230,8 @@ s32 func_80AF8ED4(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80AF9008(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { - u16 sp56 = gSaveContext.time - 0x3FFC; +s32 func_80AF9008(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { + u16 sp56 = SCHEDULE_TIME_NOW; u8 sp55 = this->actor.params & 0xFF; EnDoor* door; Vec3s* sp4C; @@ -943,9 +1241,9 @@ s32 func_80AF9008(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar s32 ret = false; this->unk_234 = NULL; - door = func_80AF7D60(globalCtx, arg2->unk0); - if (D_80AFB430[arg2->unk0] >= 0) { - this->unk_234 = func_8013BB34(globalCtx, sp55, D_80AFB430[arg2->unk0]); + door = func_80AF7D60(globalCtx, arg2->result); + if (D_80AFB430[arg2->result] >= 0) { + this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp55, D_80AFB430[arg2->result]); } if ((door != NULL) && (door->dyna.actor.update != NULL)) { @@ -964,10 +1262,10 @@ s32 func_80AF9008(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_260 = 0x4B; } - this->unk_36C = arg2->unk8 - arg2->unk4; - this->unk_36E = sp56 - arg2->unk4; + this->unk_36C = arg2->time1 - arg2->time0; + this->unk_36E = sp56 - arg2->time0; this->actor.flags &= ~ACTOR_FLAG_1; - if (gSaveContext.weekEventReg[90] & 8) { + if (gSaveContext.save.weekEventReg[90] & 8) { this->unk_356 |= 0x800; } this->unk_356 |= 0x9000; @@ -980,8 +1278,8 @@ s32 func_80AF9008(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80AF91E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { - u16 sp2E = (u16)(gSaveContext.time - 0x3FFC); +s32 func_80AF91E8(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { + u16 sp2E = SCHEDULE_TIME_NOW; u16 phi_v1; u8 sp2B = this->actor.params & 0xFF; s32 pad; @@ -989,8 +1287,8 @@ s32 func_80AF91E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_234 = NULL; - if (D_80AFB430[arg2->unk0] >= 0) { - this->unk_234 = func_8013BB34(globalCtx, sp2B, D_80AFB430[arg2->unk0]); + if (D_80AFB430[arg2->result] >= 0) { + this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp2B, D_80AFB430[arg2->result]); } if ((this->unk_234 != NULL) && (this->unk_234->count < 3)) { @@ -1001,13 +1299,13 @@ s32 func_80AF91E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar if ((this->unk_258 < 38) && (this->unk_258 != 0) && (this->unk_374 >= 0)) { phi_v1 = sp2E; } else { - phi_v1 = arg2->unk4; + phi_v1 = arg2->time0; } - if (arg2->unk8 < phi_v1) { - this->unk_248 = (phi_v1 - arg2->unk8) + 0xFFFF; + if (arg2->time1 < phi_v1) { + this->unk_248 = (phi_v1 - arg2->time1) + 0xFFFF; } else { - this->unk_248 = arg2->unk8 - phi_v1; + this->unk_248 = arg2->time1 - phi_v1; } this->unk_254 = sp2E - phi_v1; @@ -1021,7 +1319,7 @@ s32 func_80AF91E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar Flags_UnsetSwitch(globalCtx, 0); } - switch (arg2->unk0) { + switch (arg2->result) { case 83: case 84: case 85: @@ -1045,7 +1343,7 @@ s32 func_80AF91E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar default: SubS_UpdateFlags(&this->unk_356, 3, 7); func_80AF7E98(this, 0); - if (gSaveContext.weekEventReg[90] & 8) { + if (gSaveContext.save.weekEventReg[90] & 8) { this->unk_356 |= 0x800; } this->unk_356 |= 0x9000; @@ -1060,7 +1358,7 @@ s32 func_80AF91E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80AF94AC(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80AF94AC(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { u8 sp4F = this->actor.params & 0xFF; Vec3f sp40; Vec3f sp34; @@ -1069,8 +1367,8 @@ s32 func_80AF94AC(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar s32 ret = false; this->unk_234 = NULL; - if (D_80AFB430[arg2->unk0] >= 0) { - this->unk_234 = func_8013BB34(globalCtx, sp4F, D_80AFB430[arg2->unk0]); + if (D_80AFB430[arg2->result] >= 0) { + this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80AFB430[arg2->result]); } if ((this->unk_234 != 0) && (this->unk_234->count >= 2)) { @@ -1081,10 +1379,10 @@ s32 func_80AF94AC(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); Math_Vec3f_Copy(&this->actor.world.pos, &sp40); Math_Vec3f_Copy(&this->actor.prevPos, &sp40); - if (arg2->unk0 == 24) { + if (arg2->result == 24) { Flags_UnsetSwitch(globalCtx, 0); Flags_UnsetSwitch(globalCtx, 1); - this->unk_394 = 0; + this->unk_394 = EXCH_ITEM_NONE; this->unk_368 = 60.0f; func_80AF7E98(this, 9); } @@ -1093,7 +1391,7 @@ s32 func_80AF94AC(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80AF95E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80AF95E8(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { u8 sp4F = this->actor.params & 0xFF; Vec3f sp40; Vec3f sp34; @@ -1102,13 +1400,13 @@ s32 func_80AF95E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar s32 ret = false; s32 phi_a3 = -1; - switch (arg2->unk0) { + switch (arg2->result) { case 3: case 4: case 5: case 6: case 7: - phi_a3 = arg2->unk0 - 3; + phi_a3 = arg2->result - 3; break; case 19: @@ -1121,9 +1419,9 @@ s32 func_80AF95E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar } this->unk_234 = NULL; - phi_a3 = D_80AFB430[arg2->unk0]; + phi_a3 = D_80AFB430[arg2->result]; if (phi_a3 >= 0) { - this->unk_234 = func_8013BB34(globalCtx, sp4F, phi_a3); + this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp4F, phi_a3); } if ((this->unk_234 != 0) && (this->unk_234->count >= 2)) { @@ -1135,7 +1433,7 @@ s32 func_80AF95E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar Math_Vec3f_Copy(&this->actor.world.pos, &sp40); Math_Vec3f_Copy(&this->actor.prevPos, &sp40); - switch (arg2->unk0) { + switch (arg2->result) { case 27: Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ROOM_CARTAIN); Flags_SetSwitch(globalCtx, 0); @@ -1161,13 +1459,13 @@ s32 func_80AF95E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar break; case 23: - if (gSaveContext.weekEventReg[90] & 8) { + if (gSaveContext.save.weekEventReg[90] & 8) { this->unk_356 |= 0x800; } - gSaveContext.weekEventReg[60] |= 4; + gSaveContext.save.weekEventReg[60] |= 4; default: - if (arg2->unk0 == 0x1D) { + if (arg2->result == 0x1D) { this->actor.world.rot.y = BINANG_ROT180(this->actor.world.rot.y); } SubS_UpdateFlags(&this->unk_356, 3, 7); @@ -1180,7 +1478,7 @@ s32 func_80AF95E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80AF98A0(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80AF98A0(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret = false; if (Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_MM3, 116.0f, 26.0f, -219.0f, 0, @@ -1191,7 +1489,7 @@ s32 func_80AF98A0(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80AF992C(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80AF992C(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { static Vec3f D_80AFB8EC = { 116.0f, 26.0f, -219.0f }; static Vec3s D_80AFB8F8 = { 0x0000, 0xC0BA, 0x0000 }; s32 pad; @@ -1203,7 +1501,7 @@ s32 func_80AF992C(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->actor.targetMode = 6; this->actor.gravity = -1.0f; this->unk_368 = 80.0f; - if (arg2->unk0 == 14) { + if (arg2->result == 14) { this->unk_356 &= ~0x200; func_80AF7E98(this, 13); } else { @@ -1213,7 +1511,7 @@ s32 func_80AF992C(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return true; } -s32 func_80AF9A0C(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80AF9A0C(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret = false; if (func_80AF8ED4(this, globalCtx, arg2, ACTORCAT_NPC, ACTOR_EN_AN)) { @@ -1231,7 +1529,7 @@ s32 func_80AF9A0C(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80AF9AB0(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80AF9AB0(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret = false; if (func_80AF8ED4(this, globalCtx, arg2, ACTORCAT_NPC, ACTOR_EN_TEST3)) { @@ -1249,7 +1547,7 @@ s32 func_80AF9AB0(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80AF9B54(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80AF9B54(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret = false; if (func_80AF8ED4(this, globalCtx, arg2, ACTORCAT_NPC, ACTOR_EN_AL)) { @@ -1267,16 +1565,16 @@ s32 func_80AF9B54(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80AF9BF8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80AF9BF8(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret; this->actor.flags |= ACTOR_FLAG_1; this->actor.targetMode = 0; - this->unk_394 = 0; + this->unk_394 = EXCH_ITEM_NONE; this->unk_356 = 0; this->unk_368 = 40.0f; - switch (arg2->unk0) { + switch (arg2->result) { case 16: ret = func_80AF9A0C(this, globalCtx, arg2); break; @@ -1407,7 +1705,7 @@ s32 func_80AF9D04(EnPm* this, GlobalContext* globalCtx) { Vec3f* sp28; f32 temp; - if (!func_8013AD6C(globalCtx) && (this->unk_374 != 0)) { + if (!SubS_InCsMode(globalCtx) && (this->unk_374 != 0)) { if ((door != NULL) && (door->dyna.actor.update != NULL)) { if (((f32)this->unk_36E / this->unk_36C) <= 0.9f) { door->unk_1A7 = this->unk_260; @@ -1455,7 +1753,7 @@ s32 func_80AF9E7C(EnPm* this, GlobalContext* globalCtx) { this->actor.world.pos.x = sp58.x; this->actor.world.pos.z = sp58.z; - if (func_8013AD6C(globalCtx)) { + if (SubS_InCsMode(globalCtx)) { sp54 = this->unk_254; sp50 = this->unk_250; sp58 = this->actor.world.pos; @@ -1472,7 +1770,7 @@ s32 func_80AF9E7C(EnPm* this, GlobalContext* globalCtx) { this->actor.world.rot.y = Math_Vec3f_Yaw(&sp70, &sp64); } - if (func_8013AD6C(globalCtx)) { + if (SubS_InCsMode(globalCtx)) { this->unk_254 = sp54; this->unk_250 = sp50; this->unk_238 = sp58; @@ -1482,11 +1780,11 @@ s32 func_80AF9E7C(EnPm* this, GlobalContext* globalCtx) { } if ((this->unk_356 & 0x10) && (this->unk_258 == 90)) { - u8 val = gSaveContext.weekEventReg[89] | 0x40; + u8 val = gSaveContext.save.weekEventReg[89] | 0x40; - gSaveContext.weekEventReg[89] = val; + gSaveContext.save.weekEventReg[89] = val; if (val == 0) { - gSaveContext.weekEventReg[89] |= 0x40; + gSaveContext.save.weekEventReg[89] |= 0x40; } } @@ -1499,8 +1797,8 @@ s32 func_80AFA170(EnPm* this, GlobalContext* globalCtx) { switch (this->unk_258) { case 28: - if (gSaveContext.time >= CLOCK_TIME(1, 39)) { - gSaveContext.weekEventReg[89] |= 8; + if (gSaveContext.save.time >= CLOCK_TIME(1, 39)) { + gSaveContext.save.weekEventReg[89] |= 8; } case 16: @@ -1686,36 +1984,36 @@ void func_80AFA438(EnPm* this, GlobalContext* globalCtx) { } void func_80AFA4D0(EnPm* this, GlobalContext* globalCtx) { - static UNK_PTR D_80AFB900[] = { + static u8* D_80AFB900[] = { D_80AFAD80, D_80AFB30C, D_80AFB3C0, D_80AFB3FC, D_80AFB41C, }; - u16 time = gSaveContext.time; + u16 time = gSaveContext.save.time; u16 sp3C = 0; - u32* unk_14 = &gSaveContext.unk_14; - struct_80133038_arg2 sp2C; + ScheduleResult sp2C; + u32* unk_14 = &gSaveContext.save.daySpeed; this->unk_374 = REG(15) + *unk_14; if (this->unk_38C != 0) { - time = gSaveContext.time - D_801F4E78; - sp3C = gSaveContext.time; - gSaveContext.time = time; + time = gSaveContext.save.time - D_801F4E78; + sp3C = gSaveContext.save.time; + gSaveContext.save.time = time; } - if (!func_80133038(globalCtx, D_80AFB900[this->unk_38C], &sp2C) || - ((this->unk_258 != sp2C.unk0) && !func_80AF9BF8(this, globalCtx, &sp2C))) { + if (!Schedule_RunScript(globalCtx, D_80AFB900[this->unk_38C], &sp2C) || + ((this->unk_258 != sp2C.result) && !func_80AF9BF8(this, globalCtx, &sp2C))) { this->actor.shape.shadowDraw = NULL; this->actor.flags &= ~ACTOR_FLAG_1; - sp2C.unk0 = 0; + sp2C.result = 0; } else { this->actor.shape.shadowDraw = ActorShadow_DrawCircle; this->actor.flags |= ACTOR_FLAG_1; } - this->unk_258 = sp2C.unk0; + this->unk_258 = sp2C.result; this->unk_268 = func_80AF8040(this, globalCtx); func_80AFA438(this, globalCtx); if (this->unk_38C != 0) { - gSaveContext.time = sp3C; + gSaveContext.save.time = sp3C; } } @@ -1824,7 +2122,7 @@ void EnPm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec Matrix_MultiplyVector3fByState(&gZeroVec3f, &this->actor.focus.pos); Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); } - if ((this->unk_356 & 0x8000) && !(gSaveContext.weekEventReg[90] & 4)) { + if ((this->unk_356 & 0x8000) && !(gSaveContext.save.weekEventReg[90] & 4)) { func_80AF8890(this, gfx, 1); } break; diff --git a/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c b/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c index b5a3655ac5..29dc269d46 100644 --- a/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c +++ b/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c @@ -219,7 +219,7 @@ void func_80B1A768(EnPoSisters* this, GlobalContext* globalCtx) { Math_StepToF(&this->unk_2EC, 170.0f, 10.0f); } sp20 = this->unk_2EC; - } else if (this->unk_18D != 0) { + } else if (this->unk_18D != 0) { // An else would be sufficient sp20 = this->actor.parent->xzDistToPlayer; } @@ -872,8 +872,8 @@ void func_80B1C408(EnPoSisters* this, GlobalContext* globalCtx) { } if (this->actor.colChkInfo.damageEffect == 4) { - this->unk_2F0 = 4.0f; - this->unk_2F4 = 0.5f; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.5f; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->collider.info.bumper.hitPos.x, this->collider.info.bumper.hitPos.y, this->collider.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); @@ -922,17 +922,17 @@ void EnPoSisters_Update(Actor* thisx, GlobalContext* globalCtx) { this->actor.shape.shadowAlpha = this->unk_229; Actor_SetFocus(&this->actor, 40.0f); - if (this->unk_2F0 > 0.0f) { - Math_StepToF(&this->unk_2F0, 0.0f, 0.05f); + if (this->drawDmgEffAlpha > 0.0f) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); if (this->unk_229 != 255) { temp_f2 = this->unk_229 * (1.0f / 255); if (temp_f2 < this->unk_229) { - this->unk_2F0 = temp_f2; + this->drawDmgEffAlpha = temp_f2; } } - this->unk_2F4 = (this->unk_2F0 + 1.0f) * 0.25f; - this->unk_2F4 = CLAMP_MAX(this->unk_2F4, 0.5f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.25f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 0.5f); } if (this->unk_191 & (0x10 | 0x8 | 0x4 | 0x2 | 0x1)) { @@ -1057,14 +1057,14 @@ void EnPoSisters_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi f32 temp_f2; if (D_80B1DB08[limbIndex] != -1) { - Matrix_GetStateTranslation(&this->unk_28C[D_80B1DB08[limbIndex]]); + Matrix_GetStateTranslation(&this->limbPos[D_80B1DB08[limbIndex]]); } else if (limbIndex == 9) { - Matrix_GetStateTranslationAndScaledY(-2500.0f, &this->unk_28C[4]); - Matrix_GetStateTranslationAndScaledY(3000.0f, &this->unk_28C[5]); + Matrix_GetStateTranslationAndScaledY(-2500.0f, &this->limbPos[4]); + Matrix_GetStateTranslationAndScaledY(3000.0f, &this->limbPos[5]); } else if (limbIndex == 10) { - Matrix_GetStateTranslationAndScaledY(-4000.0f, &this->unk_28C[6]); + Matrix_GetStateTranslationAndScaledY(-4000.0f, &this->limbPos[6]); } else if (limbIndex == 11) { - Matrix_GetStateTranslationAndScaledX(3000.0f, &this->unk_28C[7]); + Matrix_GetStateTranslationAndScaledX(3000.0f, &this->limbPos[7]); } if ((this->actionFunc == func_80B1BA90) && (this->unk_192 >= 8) && (limbIndex == 9)) { @@ -1179,8 +1179,9 @@ void EnPoSisters_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPDisplayList(POLY_XLU_DISP++, gGameplayKeepDrawFlameDL); } - func_800BE680(globalCtx, &this->actor, this->unk_28C, ARRAY_COUNT(this->unk_28C), - this->actor.scale.x * 142.857131958f * this->unk_2F4, 0.0f, this->unk_2F0, 20); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + this->actor.scale.x * 142.857131958f * this->drawDmgEffScale, 0.0f, this->drawDmgEffAlpha, + ACTOR_DRAW_DMGEFF_LIGHT_ORBS); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.h b/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.h index 741ebbcce0..3350f8f03b 100644 --- a/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.h +++ b/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.h @@ -30,10 +30,10 @@ typedef struct EnPoSisters { /* 0x0228 */ u8 unk_228; /* 0x0229 */ u8 unk_229; /* 0x022C */ Vec3f unk_22C[8]; - /* 0x028C */ Vec3f unk_28C[8]; + /* 0x028C */ Vec3f limbPos[8]; /* 0x02EC */ f32 unk_2EC; - /* 0x02F0 */ f32 unk_2F0; - /* 0x02F4 */ f32 unk_2F4; + /* 0x02F0 */ f32 drawDmgEffAlpha; + /* 0x02F4 */ f32 drawDmgEffScale; /* 0x02F8 */ LightNode* lightNode; /* 0x02FC */ LightInfo lightInfo; /* 0x030C */ ColliderCylinder collider; diff --git a/src/overlays/actors/ovl_En_Poh/z_en_poh.c b/src/overlays/actors/ovl_En_Poh/z_en_poh.c index e3a5d30be7..22f590c440 100644 --- a/src/overlays/actors/ovl_En_Poh/z_en_poh.c +++ b/src/overlays/actors/ovl_En_Poh/z_en_poh.c @@ -707,8 +707,8 @@ void func_80B2E438(EnPoh* this, GlobalContext* globalCtx) { func_80B2D924(this); } else { if (this->actor.colChkInfo.damageEffect == 4) { - this->unk_298 = 4.0f; - this->unk_29C = 0.45f; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.45f; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->colliderCylinder.info.bumper.hitPos.x, this->colliderCylinder.info.bumper.hitPos.y, @@ -834,16 +834,16 @@ void EnPoh_Update(Actor* thisx, GlobalContext* globalCtx2) { func_80B2E8E0(this); this->actor.shape.shadowAlpha = this->unk_197; - if (this->unk_298 > 0.0f) { - Math_StepToF(&this->unk_298, 0.0f, 0.05f); + if (this->drawDmgEffAlpha > 0.0f) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); if (this->unk_197 != 255) { if (this->unk_197 * (1.0f / 255.0f) < this->unk_197) { - this->unk_298 = this->unk_197 * (1.0f / 255.0f); + this->drawDmgEffAlpha = this->unk_197 * (1.0f / 255.0f); } } - this->unk_29C = (this->unk_298 + 1.0f) * (9.0f / 40.0f); - this->unk_29C = CLAMP_MAX(this->unk_29C, 0.45f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * (9.0f / 40.0f); + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 0.45f); } } @@ -899,18 +899,18 @@ void EnPoh_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve temp_s3 = D_80B2F71C[limbIndex]; if (temp_s3 != -1) { if (temp_s3 < 4) { - Matrix_GetStateTranslation(&this->unk_2A0[temp_s3]); + Matrix_GetStateTranslation(&this->limbPos[temp_s3]); } else if (temp_s3 == 4) { - Matrix_GetStateTranslationAndScaledX(2000.0f, &this->unk_2A0[temp_s3]); + Matrix_GetStateTranslationAndScaledX(2000.0f, &this->limbPos[temp_s3]); } else { s32 i; - Vec3f* vec = &this->unk_2A0[temp_s3 + 2]; + Vec3f* vec = &this->limbPos[temp_s3 + 2]; Vec3f* vec2 = &D_80B2F734[0]; - Matrix_GetStateTranslationAndScaledX(-2000.0f, &this->unk_2A0[temp_s3]); - Matrix_GetStateTranslationAndScaledY(-2000.0f, &this->unk_2A0[temp_s3 + 1]); + Matrix_GetStateTranslationAndScaledX(-2000.0f, &this->limbPos[temp_s3]); + Matrix_GetStateTranslationAndScaledY(-2000.0f, &this->limbPos[temp_s3 + 1]); - for (i = temp_s3 + 2; i < ARRAY_COUNT(this->unk_2A0); i++, vec++, vec2++) { + for (i = temp_s3 + 2; i < ARRAY_COUNT(this->limbPos); i++, vec++, vec2++) { Matrix_MultiplyVector3fByState(vec2, vec); } } @@ -958,8 +958,9 @@ void EnPoh_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPDisplayList(&gfx[3], object_po_DL_002D28); POLY_OPA_DISP = &gfx[4]; - func_800BE680(globalCtx, &this->actor, this->unk_2A0, 10, this->actor.scale.x * 100.0f * this->unk_29C, 0.0f, - this->unk_298, 20); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + this->actor.scale.x * 100.0f * this->drawDmgEffScale, 0.0f, this->drawDmgEffAlpha, + ACTOR_DRAW_DMGEFF_LIGHT_ORBS); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Poh/z_en_poh.h b/src/overlays/actors/ovl_En_Poh/z_en_poh.h index fe579e027b..f4787b3577 100644 --- a/src/overlays/actors/ovl_En_Poh/z_en_poh.h +++ b/src/overlays/actors/ovl_En_Poh/z_en_poh.h @@ -26,9 +26,9 @@ typedef struct EnPoh { /* 0x019B */ u8 unk_19B; /* 0x019C */ Vec3s jointTable[21]; /* 0x021A */ Vec3s morphTable[21]; - /* 0x0298 */ f32 unk_298; - /* 0x029C */ f32 unk_29C; - /* 0x02A0 */ Vec3f unk_2A0[10]; + /* 0x0298 */ f32 drawDmgEffAlpha; + /* 0x029C */ f32 drawDmgEffScale; + /* 0x02A0 */ Vec3f limbPos[10]; /* 0x0318 */ LightNode* lightNode; /* 0x031C */ LightInfo lightInfo; /* 0x032C */ ColliderCylinder colliderCylinder; diff --git a/src/overlays/actors/ovl_En_Pr/z_en_pr.c b/src/overlays/actors/ovl_En_Pr/z_en_pr.c index cbc26c8b76..8c5d417f39 100644 --- a/src/overlays/actors/ovl_En_Pr/z_en_pr.c +++ b/src/overlays/actors/ovl_En_Pr/z_en_pr.c @@ -345,7 +345,7 @@ void func_80A32B20(EnPr* this, GlobalContext* globalCtx) { this->actor.speedXZ = BREG(57) + 3.0f; Math_SmoothStepToS(&this->unk_22C, this->actor.yawTowardsPlayer, BREG(49) + 1, BREG(50) + 1000, BREG(51)); - this->unk_2B8 = D_80A338C0[(void)0, gSaveContext.playerForm] + player->actor.world.pos.y; + this->unk_2B8 = D_80A338C0[(void)0, gSaveContext.save.playerForm] + player->actor.world.pos.y; func_80A324E0(this, globalCtx); if (!(player->stateFlags1 & 0x8000000)) { @@ -382,7 +382,7 @@ void func_80A32D28(EnPr* this, GlobalContext* globalCtx) { } else { Math_SmoothStepToS(&this->unk_22C, this->actor.yawTowardsPlayer, BREG(49) + 1, BREG(50) + 1000, BREG(51)); func_80A325E4(this); - this->unk_2B8 = D_80A338C0[(void)0, gSaveContext.playerForm] + player->actor.world.pos.y; + this->unk_2B8 = D_80A338C0[(void)0, gSaveContext.save.playerForm] + player->actor.world.pos.y; func_80A324E0(this, globalCtx); if (this->unk_2C8 < sqrtf(SQ(player->actor.world.pos.x - this->actor.home.pos.x) + SQ(player->actor.world.pos.z - this->actor.home.pos.z))) { @@ -457,15 +457,15 @@ void func_80A33098(EnPr* this, GlobalContext* globalCtx) { if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; if (this->actor.colChkInfo.damageEffect == 4) { - this->unk_22E = 40; - this->unk_230 = 20; + this->drawDmgEffAlpha = 40; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->actor.focus.pos.x, this->actor.focus.pos.y, this->actor.focus.pos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); } if ((player->stateFlags1 & 0x8000000) && (this->actor.colChkInfo.damageEffect == 5)) { - this->unk_22E = 40; - this->unk_230 = 31; + this->drawDmgEffAlpha = 40; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_MEDIUM; } if ((this->unk_206 != 6) && (this->unk_206 != 7)) { @@ -580,9 +580,9 @@ void EnPr_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec if ((limbIndex == 0) || (limbIndex == 1) || (limbIndex == 2) || (limbIndex == 3) || (limbIndex == 4) || (limbIndex == 5) || (limbIndex == 6) || (limbIndex == 7) || (limbIndex == 8) || (limbIndex == 9)) { - Matrix_GetStateTranslation(&this->unk_23C[this->unk_228]); + Matrix_GetStateTranslation(&this->limbPos[this->unk_228]); this->unk_228++; - if (this->unk_228 >= ARRAY_COUNT(this->unk_23C)) { + if (this->unk_228 >= ARRAY_COUNT(this->limbPos)) { this->unk_228 = 0; } } @@ -613,12 +613,13 @@ void EnPr_Draw(Actor* thisx, GlobalContext* globalCtx) { this->skelAnime.dListCount, NULL, NULL, &this->actor, POLY_XLU_DISP); } - if (this->unk_22E != 0) { - f32 temp = this->unk_22E * 0.05f; + if (this->drawDmgEffAlpha != 0) { + f32 drawDmgEffAlpha = this->drawDmgEffAlpha * 0.05f; this->unk_238 = 0.8f; this->unk_234 = 0.8f; - func_800BE680(globalCtx, &this->actor, this->unk_23C, 10, 0.8f, 0.8f, temp, this->unk_230); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), 0.8f, 0.8f, + drawDmgEffAlpha, this->drawDmgEffType); } CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Pr/z_en_pr.h b/src/overlays/actors/ovl_En_Pr/z_en_pr.h index 6506c0d74d..18123e1191 100644 --- a/src/overlays/actors/ovl_En_Pr/z_en_pr.h +++ b/src/overlays/actors/ovl_En_Pr/z_en_pr.h @@ -33,11 +33,11 @@ typedef struct EnPr { /* 0x0220 */ UNK_TYPE1 unk220[0x8]; /* 0x0228 */ s32 unk_228; /* 0x022C */ s16 unk_22C; - /* 0x022E */ s16 unk_22E; - /* 0x0230 */ s16 unk_230; + /* 0x022E */ s16 drawDmgEffAlpha; + /* 0x0230 */ s16 drawDmgEffType; /* 0x0234 */ f32 unk_234; /* 0x0238 */ f32 unk_238; - /* 0x023C */ Vec3f unk_23C[10]; + /* 0x023C */ Vec3f limbPos[10]; /* 0x02B4 */ f32 unk_2B4; /* 0x02B8 */ f32 unk_2B8; /* 0x02BC */ f32 unk_2BC; diff --git a/src/overlays/actors/ovl_En_Pr2/z_en_pr2.c b/src/overlays/actors/ovl_En_Pr2/z_en_pr2.c index 6fa76d817b..6bb60f174e 100644 --- a/src/overlays/actors/ovl_En_Pr2/z_en_pr2.c +++ b/src/overlays/actors/ovl_En_Pr2/z_en_pr2.c @@ -152,7 +152,7 @@ void EnPr2_Init(Actor* thisx, GlobalContext* globalCtx) { if (parent->update != NULL) { this->unk_1C8 = ((EnEncount1*)parent)->unk_15A; - this->path = func_8013D648(globalCtx, this->unk_1C8, 0x3F); + this->path = SubS_GetPathByIndex(globalCtx, this->unk_1C8, 0x3F); this->unk_208 = parent->world.rot.z * 20.0f; if (this->unk_208 < 20.0f) { this->unk_208 = 20.0f; @@ -186,10 +186,10 @@ void EnPr2_Destroy(Actor* thisx, GlobalContext* globalCtx) { } if (this->actor.parent != NULL) { - Actor* parent = this->actor.parent; + EnEncount1* encount1 = (EnEncount1*)this->actor.parent; - if ((parent->update != NULL) && (((EnEncount1*)parent)->unk_14E > 0)) { - ((EnEncount1*)parent)->unk_14E--; + if ((encount1->actor.update != NULL) && (encount1->unk_14E > 0)) { + encount1->unk_14E--; } } } @@ -276,7 +276,7 @@ void func_80A745FC(EnPr2* this, GlobalContext* globalCtx) { Math_ApproachF(&this->actor.speedXZ, 10.0f, 0.3f, 1.0f); } - if ((this->path != NULL) && !func_8013D68C(this->path, this->unk_1D0, &this->unk_21C)) { + if ((this->path != NULL) && !SubS_CopyPointFromPath(this->path, this->unk_1D0, &this->unk_21C)) { Actor_MarkForDeath(&this->actor); } diff --git a/src/overlays/actors/ovl_En_Prz/z_en_prz.c b/src/overlays/actors/ovl_En_Prz/z_en_prz.c index 2a86294dc6..29df2aa2c2 100644 --- a/src/overlays/actors/ovl_En_Prz/z_en_prz.c +++ b/src/overlays/actors/ovl_En_Prz/z_en_prz.c @@ -354,7 +354,7 @@ void func_80A767A8(EnPrz* this, GlobalContext* globalCtx) { this->unk_1C8 = 1; } - playerForm = gSaveContext.playerForm; + playerForm = gSaveContext.save.playerForm; this->unk_1D8.y = (player->actor.world.pos.y + D_80A771E0[playerForm]) + randPlusMinusPoint5Scaled((2.0f * this->unk_1E6) + 1.0f); func_80A76070(this, Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_1D8), globalCtx); diff --git a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c index b490d8d1dc..e6fb2535a3 100644 --- a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c +++ b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c @@ -9,7 +9,7 @@ */ #include "z_en_racedog.h" -#include "objects/object_dog/object_dog.h" +#include "overlays/actors/ovl_En_Dg/z_en_dg.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_80000000) @@ -20,26 +20,63 @@ void EnRacedog_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnRacedog_Update(Actor* thisx, GlobalContext* globalCtx); void EnRacedog_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80B24C14(EnRacedog* this, GlobalContext* globalCtx); -void func_80B24CB4(EnRacedog* this, GlobalContext* globalCtx); -void func_80B24E14(EnRacedog* this); -void func_80B24F08(EnRacedog* this); -void func_80B251EC(EnRacedog* this); -void func_80B252F8(EnRacedog* this); -void func_80B2538C(EnRacedog* this); -void func_80B25448(EnRacedog* this); -s32 func_80B25490(EnRacedog* this, Vec2f* arg1); -void func_80B255AC(EnRacedog* this, GlobalContext* globalCtx); -void func_80B256BC(EnRacedog* this); +void EnRacedog_RaceStart(EnRacedog* this, GlobalContext* globalCtx); +void EnRacedog_Race(EnRacedog* this, GlobalContext* globalCtx); +void EnRacedog_UpdateTextId(EnRacedog* this); +void EnRacedog_UpdateSpeed(EnRacedog* this); +void EnRacedog_CalculateFinalStretchTargetSpeed(EnRacedog* this); +void EnRacedog_UpdateRaceVariables(EnRacedog* this); +void EnRacedog_CheckForFinish(EnRacedog* this); +void EnRacedog_UpdateRunAnimationPlaySpeed(EnRacedog* this); +s32 EnRacedog_IsOverFinishLine(EnRacedog* this, Vec2f* arg1); +void EnRacedog_SpawnFloorDustRing(EnRacedog* this, GlobalContext* globalCtx); +void EnRacedog_PlayWalkSfx(EnRacedog* this); +/** + * Dogs can be in three conditions, which is indicated by the message it says when + * you pick it up prior to entering the race. + * If it starts with "Ruff!", it's in good condition. + * If it starts with "Rrr-Ruff!", it's in normal condition. + * If it starts with "Hoo-whine", it's in bad condition. + * These text boxes are grouped up like so: + * - 0x3538 - 0x353D: Good condition + * - 0x353E - 0x3541: Normal condition + * - 0x3542 - 0x3546: Bad condition + */ +#define DOG_IS_IN_GOOD_CONDITION(this) (sDogInfo[this->index].textId < 0x353E) +#define DOG_IS_IN_BAD_CONDITION(this) (sDogInfo[this->index].textId >= 0x3542) + +typedef enum { + /* 0 */ RACEDOG_ANIMATION_IDLE, + /* 1 */ RACEDOG_ANIMATION_WALK_1, + /* 2 */ RACEDOG_ANIMATION_RUN, + /* 3 */ RACEDOG_ANIMATION_BARK, + /* 4 */ RACEDOG_ANIMATION_SIT_DOWN_1, + /* 5 */ RACEDOG_ANIMATION_SIT_DOWN_2, + /* 6 */ RACEDOG_ANIMATION_LYING_DOWN_START_1, + /* 7 */ RACEDOG_ANIMATION_LYING_DOWN_LOOP, + /* 8 */ RACEDOG_ANIMATION_LYING_DOWN_START_2, + /* 9 */ RACEDOG_ANIMATION_LYING_DOWN_START_3, + /* 10 */ RACEDOG_ANIMATION_LYING_DOWN_START_4, + /* 11 */ RACEDOG_ANIMATION_WALK_2, + /* 12 */ RACEDOG_ANIMATION_JUMP, + /* 13 */ RACEDOG_ANIMATION_LONG_JUMP, + /* 14 */ RACEDOG_ANIMATION_JUMP_2, + /* 15 */ RACEDOG_ANIMATION_WALK_3, + /* 16 */ RACEDOG_ANIMATION_MAX +} RacedogAnimationIndex; + +/** + * Stores various information for each dog in the race, mostly related to speed. + */ typedef struct { - f32 unk_00; - f32 unk_04; - s16 unk_08; - s16 unk_0A; - s16 unk_0C; - s16 unk_0E; -} UnkRacedogStruct; + f32 sprintSpeedMultiplier; // Target speed is multiplied by this when the dog is in the last 1/4 of the race + f32 goodConditionSpeedMultiplier; // Target speed is multiplied by this if the dog is in good condition + s16 color; // The dog's color, which is used as an index into sBaseSpeeds + s16 index; // The dog's index within sDogInfo + s16 pointToUseSecondBaseSpeed; // When the dog is at or after this point, the second value in sBaseSpeeds is used + s16 textId; // Used to determine the dog's condition +} RaceDogInfo; const ActorInit En_Racedog_InitVars = { ACTOR_EN_RACEDOG, @@ -53,31 +90,65 @@ const ActorInit En_Racedog_InitVars = { (ActorFunc)EnRacedog_Draw, }; -static s16 D_80B25D40 = 0; +static s16 sNumberOfDogsFinished = 0; -static s16 D_80B25D44 = -1; +/** + * The furthest point along the race track path that any dog has reached. + */ +static s16 sFurthestPoint = -1; -static s16 D_80B25D48 = 0; +/** + * Starts counting up as soon as the first-place dog gets 3/4ths of the way through the race track, + * and stops counting up as soon as the first-place dog finishes. Used to scale up the sprint + * multiplier in EnRacedog_CalculateFinalStretchTargetSpeed. + */ +static s16 sSprintTimer = 0; -static s16 D_80B25D4C = -1; +/** + * The index of the dog currently in first place. It's determined by checking, for each dog on the track, + * if its current point along the race track path is greater than or equal to sFurthestPoint. + */ +static s16 sFirstPlaceIndex = -1; -static f32 D_80B25D50[][2] = { +/** + * The base speeds for each dog indexed by its color. The two values are used during different parts of the race. + * - At the very start of the race, all dogs will use the first value for their color, but only for a single point + * along the race track's path. After that, they will have a base speed of 5.0, regardless of what's in the table + * for their color. The sole exception to this is the blue dog, who will use its first value for the entire + * first 1/4th of the race. + * - For the last 3/4ths of the race, all dogs will check to see if their current point along the race track path is + * greater than or equal to the pointToUseSecondBaseSpeed for their RaceDogInfo. If it is, then they will use the + * second value for their color as their base speed; otherwise, they will use 5.0. + */ +static f32 sBaseSpeeds[][2] = { { 0.0f, 0.0f }, { 5.0f, 5.5f }, { 5.0f, 5.0f }, { 5.5f, 5.0f }, { 4.5f, 5.5f }, { 6.0f, 4.0f }, { 4.0f, 6.0f }, }; -static UnkRacedogStruct D_80B25D88[] = { - { -1.0f, 1.20000004768f, 3, 0, 9, 0x3539 }, { -1.0f, 1.20000004768f, 1, 1, 9, 0x353A }, - { -1.0f, 1.20000004768f, 5, 2, 10, 0x353B }, { -1.0f, 1.20000004768f, 2, 3, 9, 0x353C }, - { -1.0f, 1.20000004768f, 4, 4, 8, 0x353D }, { -1.0f, 1.20000004768f, 2, 5, 9, 0x353E }, - { -1.0f, 1.20000004768f, 3, 6, 9, 0x353F }, { -1.0f, 1.20000004768f, 1, 7, 9, 0x3540 }, - { -1.0f, 1.20000004768f, 1, 8, 9, 0x3541 }, { -1.0f, 1.20000004768f, 6, 9, 8, 0x3542 }, - { -1.0f, 1.20000004768f, 2, 10, 9, 0x3543 }, { -1.0f, 1.20000004768f, 3, 11, 9, 0x3544 }, - { -1.0f, 1.20000004768f, 1, 12, 9, 0x3545 }, { -1.0f, 1.20000004768f, 4, 13, 8, 0x3546 }, +/** + * A table of RaceDogInfo for every dog in the race. Note that the sprintSpeedMultiplier and + * textId values in this table are updated by functions within this actor. + */ +static RaceDogInfo sDogInfo[] = { + { -1.0f, 1.2f, DOG_COLOR_BEIGE, 0, 9, 0x3539 }, { -1.0f, 1.2f, DOG_COLOR_WHITE, 1, 9, 0x353A }, + { -1.0f, 1.2f, DOG_COLOR_BLUE, 2, 10, 0x353B }, { -1.0f, 1.2f, DOG_COLOR_GRAY, 3, 9, 0x353C }, + { -1.0f, 1.2f, DOG_COLOR_BROWN, 4, 8, 0x353D }, { -1.0f, 1.2f, DOG_COLOR_GRAY, 5, 9, 0x353E }, + { -1.0f, 1.2f, DOG_COLOR_BEIGE, 6, 9, 0x353F }, { -1.0f, 1.2f, DOG_COLOR_WHITE, 7, 9, 0x3540 }, + { -1.0f, 1.2f, DOG_COLOR_WHITE, 8, 9, 0x3541 }, { -1.0f, 1.2f, DOG_COLOR_GOLD, 9, 8, 0x3542 }, + { -1.0f, 1.2f, DOG_COLOR_GRAY, 10, 9, 0x3543 }, { -1.0f, 1.2f, DOG_COLOR_BEIGE, 11, 9, 0x3544 }, + { -1.0f, 1.2f, DOG_COLOR_WHITE, 12, 9, 0x3545 }, { -1.0f, 1.2f, DOG_COLOR_BROWN, 13, 8, 0x3546 }, }; -static UnkRacedogStruct D_80B25E68 = { -1.0f, 1.0, 0, -1, 0, 0x353E }; +/** + * Stores the RacedogInfo for the dog that is selected by the player. These values are just + * placeholders, and the actual value gets grabbed from sDogInfo in EnRacedog_Init. + */ +static RaceDogInfo sSelectedDogInfo = { -1.0f, 1.0, DOG_COLOR_DEFAULT, -1, 0, 0x353E }; -static Vec2f D_80B25E78[] = { +/** + * The XZ-coordinates used to determine if the dog is inside the finish line. + * They're a little bit bigger than the in-game visual. + */ +static Vec2f sFinishLineCoordinates[] = { { -3914.0f, 1283.0f }, { -3747.0f, 1104.0f }, { -3717.0f, 1169.0f }, @@ -141,44 +212,36 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(0, 0x0), }; -static AnimationInfoS D_80B25EF0[] = { - { &object_dog_Anim_0021C8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_dog_Anim_0021C8, 1.0f, 0, -1, ANIMMODE_LOOP, -6 }, - { &object_dog_Anim_001BD8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_dog_Anim_000998, 1.0f, 0, -1, ANIMMODE_LOOP, -6 }, - { &object_dog_Anim_001FB0, 1.0f, 0, -1, ANIMMODE_ONCE, -6 }, - { &object_dog_Anim_001FB0, 1.0f, 0, -1, ANIMMODE_LOOP_PARTIAL, -6 }, - { &object_dog_Anim_001048, 1.0f, 0, -1, ANIMMODE_ONCE, -6 }, - { &object_dog_Anim_001348, 1.0f, 0, -1, ANIMMODE_LOOP, -6 }, - { &object_dog_Anim_001048, 1.0f, 0, 27, ANIMMODE_ONCE, -6 }, - { &object_dog_Anim_001048, 1.0f, 28, -1, ANIMMODE_ONCE, -6 }, - { &object_dog_Anim_001048, 1.0f, 54, 54, ANIMMODE_ONCE, -6 }, - { &object_dog_Anim_0021C8, -1.5f, -1, 0, ANIMMODE_LOOP, -6 }, - { &object_dog_Anim_001560, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_dog_Anim_001A84, 1.2f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_dog_Anim_0017C0, 1.2f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_dog_Anim_0021C8, 0.5f, 0, -1, ANIMMODE_LOOP, 0 }, +static AnimationInfoS sAnimations[] = { + { &gDogWalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, { &gDogWalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -6 }, + { &gDogRunAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, { &gDogBarkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -6 }, + { &gDogSitAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -6 }, { &gDogSitAnim, 1.0f, 0, -1, ANIMMODE_LOOP_PARTIAL, -6 }, + { &gDogLyingDownAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -6 }, { &gDogLyingDownLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -6 }, + { &gDogLyingDownAnim, 1.0f, 0, 27, ANIMMODE_ONCE, -6 }, { &gDogLyingDownAnim, 1.0f, 28, -1, ANIMMODE_ONCE, -6 }, + { &gDogLyingDownAnim, 1.0f, 54, 54, ANIMMODE_ONCE, -6 }, { &gDogWalkAnim, -1.5f, -1, 0, ANIMMODE_LOOP, -6 }, + { &gDogJumpAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, { &gDogLongJumpAnim, 1.2f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gDogJump2Anim, 1.2f, 0, -1, ANIMMODE_ONCE, 0 }, { &gDogWalkAnim, 0.5f, 0, -1, ANIMMODE_LOOP, 0 }, }; static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_STOP), }; -void func_80B24630(SkelAnime* skelAnime, AnimationInfoS arg1[], s32 arg2) { +void EnRacedog_ChangeAnimation(SkelAnime* skelAnime, AnimationInfoS* animationInfo, s32 index) { f32 frameCount; - arg1 += arg2; - if (arg1->frameCount < 0) { - frameCount = Animation_GetLastFrame(arg1->animation); + animationInfo += index; + if (animationInfo->frameCount < 0) { + frameCount = Animation_GetLastFrame(animationInfo->animation); } else { - frameCount = arg1->frameCount; + frameCount = animationInfo->frameCount; } - Animation_Change(skelAnime, arg1->animation, arg1->playSpeed + (BREG(88) * 0.1f), arg1->startFrame, frameCount, - arg1->mode, arg1->morphFrames); + Animation_Change(skelAnime, animationInfo->animation, animationInfo->playSpeed + (BREG(88) * 0.1f), + animationInfo->startFrame, frameCount, animationInfo->mode, animationInfo->morphFrames); } -void func_80B246F4(EnRacedog* this, GlobalContext* globalCtx) { +void EnRacedog_UpdateCollision(EnRacedog* this, GlobalContext* globalCtx) { this->collider.dim.pos.x = this->actor.world.pos.x; this->collider.dim.pos.y = this->actor.world.pos.y; this->collider.dim.pos.z = this->actor.world.pos.z; @@ -186,40 +249,44 @@ void func_80B246F4(EnRacedog* this, GlobalContext* globalCtx) { Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 26.0f, 10.0f, 0.0f, 5); } -s16 func_80B2478C(Path* path, s32 arg1, Vec3f* pos, f32* arg3) { +/** + * Returns the Y-rotation the dog should have to move to the next point along the race track path. + * There is a small degree of randomness incorporated into this angle. + */ +s16 EnRacedog_GetYRotation(Path* path, s32 pointIndex, Vec3f* pos, f32* distSQ) { Vec3s* point; - f32 phi_f14; - f32 sp1C; + f32 xDiffRand; + f32 zDiffRand; f32 xDiff; f32 zDiff; if (path != NULL) { point = Lib_SegmentedToVirtual(path->points); - point = &point[arg1]; - phi_f14 = (randPlusMinusPoint5Scaled(100.0f) + point->x) - pos->x; - sp1C = (randPlusMinusPoint5Scaled(100.0f) + point->z) - pos->z; + point = &point[pointIndex]; + xDiffRand = (randPlusMinusPoint5Scaled(100.0f) + point->x) - pos->x; + zDiffRand = (randPlusMinusPoint5Scaled(100.0f) + point->z) - pos->z; xDiff = point->x - pos->x; zDiff = point->z - pos->z; } else { - phi_f14 = 0.0f; - sp1C = 0.0f; + xDiffRand = 0.0f; + zDiffRand = 0.0f; xDiff = 0.0f; zDiff = 0.0f; } - *arg3 = SQ(xDiff) + SQ(zDiff); - return RADF_TO_BINANG(Math_Acot2F(sp1C, phi_f14)); + *distSQ = SQ(xDiff) + SQ(zDiff); + return RADF_TO_BINANG(Math_Acot2F(zDiffRand, xDiffRand)); } -void func_80B248B8(EnRacedog* this, Vec3f* arg1) { - f32 sp20; - f32 sp1C; +void EnRacedog_GetFloorRot(EnRacedog* this, Vec3f* floorRot) { + f32 ny; + f32 nz; if (this->actor.floorPoly != NULL) { - sp20 = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.y); - sp1C = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.z); + ny = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.y); + nz = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.z); - arg1->x = -Math_Acot2F(1.0f, -sp1C * sp20); + floorRot->x = -Math_Acot2F(1.0f, -nz * ny); } } @@ -228,50 +295,57 @@ void EnRacedog_Init(Actor* thisx, GlobalContext* globalCtx) { ColliderCylinder* collider = &this->collider; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_dog_Skel_0080F0, NULL, this->jointTable, this->morphTable, - 13); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gDogSkel, NULL, this->jointTable, this->morphTable, DOG_LIMB_MAX); Collider_InitCylinder(globalCtx, collider); Collider_SetCylinder(globalCtx, collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); Actor_ProcessInitChain(&this->actor, sInitChain); - this->unk_1E0 = func_8013D648(globalCtx, ENRACEDOG_GET_PATH(&this->actor), 0x3F); + this->path = SubS_GetPathByIndex(globalCtx, ENRACEDOG_GET_PATH(&this->actor), 0x3F); Actor_SetScale(&this->actor, 0.0075f); this->actor.gravity = -3.0f; - if (ENRACEDOG_GET_3E0(&this->actor) < 14) { - this->unk_290 = ENRACEDOG_GET_3E0(&this->actor); + if (ENRACEDOG_GET_INDEX(&this->actor) < 14) { + this->index = ENRACEDOG_GET_INDEX(&this->actor); } else { Actor_MarkForDeath(&this->actor); } - this->unk_2BC = 0xFF; - this->unk_2C0 = 0x32; - this->unk_288 = 0xC; - this->unk_2A0.x = 0.0f; - this->unk_2A0.y = 0.0f; - this->unk_2A0.z = 0.0f; - this->unk_2C4 = 1.0f; + this->selectionArrowGreenPrimColor = 255; + this->selectionArrowGreenEnvColor = 50; + this->selectionArrowTimer = 12; + this->prevRot.x = 0.0f; + this->prevRot.y = 0.0f; + this->prevRot.z = 0.0f; + this->selectionArrowScale = 1.0f; - if ((D_80B25D88[this->unk_290].unk_0E >= 0x353F) && (this->unk_290 == (s16)Rand_ZeroFloat(20.0f))) { - this->unk_28C = 5; + // The first part of this check is a bit strange. If they intended to check for dogs that were + // in good condition, they should've stopped at 0x353D instead of 0x353E. Additionally, this + // runs before EnRacedog_UpdateTextId is called to set the text IDs to their "correct" values, + // meaning that the IDs are just whatever their default values in sDogInfo are. As a result, + // the blue dog, one beige dog, one white dog, one brown dog, and two gray dogs never bother + // to do the random 1/20 check here, regardless of anything else. + if ((sDogInfo[this->index].textId > 0x353E) && (this->index == (s16)Rand_ZeroFloat(20.0f))) { + this->extraTimeBeforeRaceStart = 5; } else { - this->unk_28C = 0; + this->extraTimeBeforeRaceStart = 0; } - this->unk_28A = 60; - this->unk_28A += this->unk_28C; - this->unk_298 = D_80B25D50[D_80B25D88[this->unk_290].unk_08][0]; - this->unk_29C = 0; - this->unk_2B8 = -1; + this->raceStartTimer = 60; + this->raceStartTimer += this->extraTimeBeforeRaceStart; + this->targetSpeed = sBaseSpeeds[sDogInfo[this->index].color][0]; + this->raceStatus = RACEDOG_RACE_STATUS_BEFORE_POINT_9; + this->pointForCurrentTargetSpeed = -1; - func_80B24E14(this); + EnRacedog_UpdateTextId(this); this->actor.flags |= ACTOR_FLAG_10; this->actor.flags |= ACTOR_FLAG_20; - D_80B25E68 = D_80B25D88[(s16)((gSaveContext.eventInf[0] & 0xF8) >> 3)]; - this->unk_292 = D_80B25E68.unk_0A; - func_80B24630(&this->skelAnime, D_80B25EF0, 0); - D_80B25EF0->playSpeed = Rand_ZeroFloat(0.5f) + 1.0f; - this->actionFunc = func_80B24C14; + + sSelectedDogInfo = sDogInfo[(s16)((gSaveContext.eventInf[0] & 0xF8) >> 3)]; + this->selectedDogIndex = sSelectedDogInfo.index; + + EnRacedog_ChangeAnimation(&this->skelAnime, sAnimations, RACEDOG_ANIMATION_IDLE); + sAnimations[RACEDOG_ANIMATION_IDLE].playSpeed = Rand_ZeroFloat(0.5f) + 1.0f; + this->actionFunc = EnRacedog_RaceStart; } void EnRacedog_Destroy(Actor* thisx, GlobalContext* globalCtx) { @@ -280,125 +354,150 @@ void EnRacedog_Destroy(Actor* thisx, GlobalContext* globalCtx) { Collider_DestroyCylinder(globalCtx, &this->collider); } -void func_80B24C14(EnRacedog* this, GlobalContext* globalCtx) { - s16 phi_v1; - - if (this->unk_28A == 0) { - phi_v1 = 0; - } else { - this->unk_28A--; - phi_v1 = this->unk_28A; - } - - if (phi_v1 == 0) { - this->unk_28A = Rand_S16Offset(50, 50); - if (this->unk_28C == 0) { +/** + * This function makes the dog wait at the starting line until the race actually begins. + * It's also responsible for playing the starting shot sound once the race begins. + */ +void EnRacedog_RaceStart(EnRacedog* this, GlobalContext* globalCtx) { + if (DECR(this->raceStartTimer) == 0) { + this->raceStartTimer = Rand_S16Offset(50, 50); + if (this->extraTimeBeforeRaceStart == 0) { play_sound(NA_SE_SY_START_SHOT); } - func_80B24630(&this->skelAnime, D_80B25EF0, 2); - this->actionFunc = func_80B24CB4; + EnRacedog_ChangeAnimation(&this->skelAnime, sAnimations, RACEDOG_ANIMATION_RUN); + this->actionFunc = EnRacedog_Race; } } -void func_80B24CB4(EnRacedog* this, GlobalContext* globalCtx) { - s16 phi_a1; - f32 sp30; +/** + * This function handles the dog's behavior and state for the entire time the race is going. + */ +void EnRacedog_Race(EnRacedog* this, GlobalContext* globalCtx) { + s16 yRotation; + f32 distSq; this->collider.dim.radius = 15; - if (this->unk_1E0 != 0) { - phi_a1 = func_80B2478C(this->unk_1E0, this->unk_1E8, &this->actor.world.pos, &sp30); + if (this->path != NULL) { + yRotation = EnRacedog_GetYRotation(this->path, this->currentPoint, &this->actor.world.pos, &distSq); if (this->actor.bgCheckFlags & 8) { - phi_a1 = this->actor.wallYaw; + yRotation = this->actor.wallYaw; } - Math_SmoothStepToS(&this->actor.world.rot.y, phi_a1, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->actor.world.rot.y, yRotation, 4, 0x3E8, 1); this->actor.shape.rot.y = this->actor.world.rot.y; - if (sp30 <= 2500.0f) { - this->unk_1E8++; - if (this->unk_1E8 >= (this->unk_1E0->count - 1)) { - this->unk_1E8 = 0; + if (distSq <= SQ(50.0f)) { + this->currentPoint++; + if (this->currentPoint >= (this->path->count - 1)) { + this->currentPoint = 0; } } - func_80B24F08(this); - if ((this->unk_1E8 >= ((this->unk_1E0->count / 4) * 3)) && (this->unk_290 == D_80B25D4C)) { - D_80B25D48++; + EnRacedog_UpdateSpeed(this); + + // Putting this after EnRacedog_UpdateSpeed will ensure that when EnRacedog_CalculateFinalStretchTargetSpeed + // is called for the first-place dog, the sprint timer will be 0, so the first-place dog will be guaranteed + // to have a sprint speed multiplier of 1. + if ((this->currentPoint >= ((this->path->count / 4) * 3)) && (this->index == sFirstPlaceIndex)) { + sSprintTimer++; } - func_80B252F8(this); - func_80B2538C(this); + EnRacedog_UpdateRaceVariables(this); + EnRacedog_CheckForFinish(this); Actor_MoveWithGravity(&this->actor); } - func_80B25448(this); - func_80B256BC(this); - func_80B255AC(this, globalCtx); + EnRacedog_UpdateRunAnimationPlaySpeed(this); + EnRacedog_PlayWalkSfx(this); + EnRacedog_SpawnFloorDustRing(this, globalCtx); } -void func_80B24E14(EnRacedog* this) { - if (this->unk_290 % 2) { - D_80B25D88[this->unk_290].unk_0E = - (((gSaveContext.weekEventReg[42 + (this->unk_290 / 2)]) & (0x10 | 0x20 | 0x40 | 0x80)) >> 4) + 0x3539; +/** + * Updates the text ID in sDogInfo based on what was set in the weekEventRegs by + * En_Aob_01. This makes it so sDogInfo can be used in other functions to determine + * the condition of the dog. + */ +void EnRacedog_UpdateTextId(EnRacedog* this) { + if (this->index % 2) { + sDogInfo[this->index].textId = + (((gSaveContext.save.weekEventReg[42 + (this->index / 2)]) & (0x10 | 0x20 | 0x40 | 0x80)) >> 4) + 0x3539; } else { - D_80B25D88[this->unk_290].unk_0E = - ((gSaveContext.weekEventReg[42 + (this->unk_290 / 2)]) & (1 | 2 | 4 | 8)) + 0x3539; + sDogInfo[this->index].textId = + ((gSaveContext.save.weekEventReg[42 + (this->index / 2)]) & (1 | 2 | 4 | 8)) + 0x3539; } - if ((D_80B25D88[this->unk_290].unk_0E >= 0x3547) || (D_80B25D88[this->unk_290].unk_0E < 0x3539)) { - D_80B25D88[this->unk_290].unk_0E = 0x353E; + // This makes sure the text ID is something in the range of 0x3539 to 0x3547. + if ((sDogInfo[this->index].textId >= 0x3547) || (sDogInfo[this->index].textId < 0x3539)) { + sDogInfo[this->index].textId = 0x353E; } - if (D_80B25D88[this->unk_290].unk_0E == 0x3547) { - D_80B25D88[this->unk_290].unk_0E = 0x3538; + + // Actual valid text IDs for the race dogs range between 0x3538 and 0x3546, so this + // code makes the two ranges match up. Perhaps the text got shifted? + if (sDogInfo[this->index].textId == 0x3547) { + sDogInfo[this->index].textId = 0x3538; } } -void func_80B24F08(EnRacedog* this) { - s32 temp_a0; - s32 temp_v1 = this->unk_1E0->count; +/** + * Responsible for calculating the dog's target speed and for making its actual speed + * approach the target speed. + */ +void EnRacedog_UpdateSpeed(EnRacedog* this) { + s32 quarterPathCount; + s32 pathCount = this->path->count; - if (this->unk_2B8 < this->unk_1E8) { - this->unk_2B8 = this->unk_1E8; - if (this->unk_1E8 == 0) { - this->unk_298 = D_80B25D50[D_80B25D88[this->unk_290].unk_08][0]; + // Only update the target speed if the dog is at a further point along the path + // than it was when the target speed was last updated. + if (this->pointForCurrentTargetSpeed < this->currentPoint) { + this->pointForCurrentTargetSpeed = this->currentPoint; + if (this->currentPoint == 0) { + // The dog is at the very start of the race track. + this->targetSpeed = sBaseSpeeds[sDogInfo[this->index].color][0]; } else { - temp_a0 = temp_v1 / 4; - if (this->unk_1E8 < temp_a0) { - if (D_80B25D88[this->unk_290].unk_08 == 5) { - this->unk_298 = D_80B25D50[D_80B25D88[this->unk_290].unk_08][0] + randPlusMinusPoint5Scaled(1.0f); + quarterPathCount = pathCount / 4; + if (this->currentPoint < quarterPathCount) { + // The dog is past the very start, but is still less than 1/4th of the way through the race track. + // This code will give the blue dog a higher base speed than any other dog (6.0 instead of 5.0). + if (sDogInfo[this->index].color == DOG_COLOR_BLUE) { + this->targetSpeed = sBaseSpeeds[sDogInfo[this->index].color][0] + randPlusMinusPoint5Scaled(1.0f); } else { - this->unk_298 = 5.0f + randPlusMinusPoint5Scaled(1.0f); + this->targetSpeed = 5.0f + randPlusMinusPoint5Scaled(1.0f); } - if ((D_80B25D88[this->unk_290].unk_0E < 0x353E) && (this->unk_290 != D_80B25D4C)) { - this->unk_298 *= D_80B25D88[this->unk_290].unk_04; + if (DOG_IS_IN_GOOD_CONDITION(this) && (this->index != sFirstPlaceIndex)) { + this->targetSpeed *= sDogInfo[this->index].goodConditionSpeedMultiplier; } - } else if (this->unk_1E8 < (temp_a0 * 3)) { - if (this->unk_1E8 < D_80B25D88[this->unk_290].unk_0C) { - this->unk_298 = 5.0f + randPlusMinusPoint5Scaled(1.0f); + } else if (this->currentPoint < (quarterPathCount * 3)) { + // The dog is between 1/4th and 3/4ths of the way through the race track. + if (this->currentPoint < sDogInfo[this->index].pointToUseSecondBaseSpeed) { + this->targetSpeed = 5.0f + randPlusMinusPoint5Scaled(1.0f); } else { - this->unk_298 = D_80B25D50[D_80B25D88[this->unk_290].unk_08][1] + randPlusMinusPoint5Scaled(1.0f); + this->targetSpeed = sBaseSpeeds[sDogInfo[this->index].color][1] + randPlusMinusPoint5Scaled(1.0f); - if ((D_80B25D88[this->unk_290].unk_0E < 0x353E) && (this->unk_290 != D_80B25D4C)) { - this->unk_298 *= D_80B25D88[this->unk_290].unk_04; + if (DOG_IS_IN_GOOD_CONDITION(this) && (this->index != sFirstPlaceIndex)) { + this->targetSpeed *= sDogInfo[this->index].goodConditionSpeedMultiplier; } } - } else if (this->unk_1E8 < temp_v1) { - func_80B251EC(this); + } else if (this->currentPoint < pathCount) { + // The dog is more than 3/4ths of the way through the race track. + EnRacedog_CalculateFinalStretchTargetSpeed(this); } else { - this->unk_298 = randPlusMinusPoint5Scaled(1.0f) + 5.0f; + this->targetSpeed = randPlusMinusPoint5Scaled(1.0f) + 5.0f; } } } - if ((this->unk_1E8 != 0) || (this->unk_29C != 0)) { + // Seemingly the only point of this raceStatus check is to ensure this code still runs when + // the dog has finished the race and is at point 0 along their second lap. + if ((this->currentPoint != 0) || (this->raceStatus != RACEDOG_RACE_STATUS_BEFORE_POINT_9)) { this->actor.shape.rot.y = this->actor.world.rot.y; } - Math_ApproachF(&this->actor.speedXZ, this->unk_298, 0.5f, 3.0f); + Math_ApproachF(&this->actor.speedXZ, this->targetSpeed, 0.5f, 3.0f); - if (this->unk_290 == this->unk_292) { + // The dog that the player has selected has a slightly higher max speed than the other dogs. + if (this->index == this->selectedDogIndex) { if (this->actor.speedXZ > 7.5f) { this->actor.speedXZ = 7.5f; } @@ -409,66 +508,90 @@ void func_80B24F08(EnRacedog* this) { } } -void func_80B251EC(EnRacedog* this) { - f32 temp; +/** + * This function handles updating targetSpeed for the final stretch of the race, + * where the dog starts sprinting towards the finish line. + */ +void EnRacedog_CalculateFinalStretchTargetSpeed(EnRacedog* this) { + f32 sprintSpeedMultiplier; - if (D_80B25D88[this->unk_290].unk_00 == -1.0f) { - if (D_80B25D48 < 100.0f) { - D_80B25D88[this->unk_290].unk_00 = 200.0f / (200.0f - D_80B25D48); + // Dogs are only allowed to update their sprintSpeedMultiplier once, so its value will + // depend on the value of sSprintTimer when they first hit the 3/4th mark on the track. + if (sDogInfo[this->index].sprintSpeedMultiplier == -1.0f) { + if (sSprintTimer < 100.0f) { + sDogInfo[this->index].sprintSpeedMultiplier = 200.0f / (200.0f - sSprintTimer); } else { - D_80B25D88[this->unk_290].unk_00 = 2.0f; + sDogInfo[this->index].sprintSpeedMultiplier = 2.0f; } } - if (D_80B25D88[this->unk_290].unk_0E < 0x3542) { - temp = D_80B25D88[this->unk_290].unk_00; - this->unk_298 = temp * D_80B25D50[D_80B25D88[this->unk_290].unk_08][1]; + if (!DOG_IS_IN_BAD_CONDITION(this)) { + sprintSpeedMultiplier = sDogInfo[this->index].sprintSpeedMultiplier; + this->targetSpeed = sprintSpeedMultiplier * sBaseSpeeds[sDogInfo[this->index].color][1]; } - if ((D_80B25D88[this->unk_290].unk_0E < 0x353E) && (this->unk_290 != D_80B25D4C)) { - this->unk_298 *= D_80B25D88[this->unk_290].unk_04; + if (DOG_IS_IN_GOOD_CONDITION(this) && (this->index != sFirstPlaceIndex)) { + this->targetSpeed *= sDogInfo[this->index].goodConditionSpeedMultiplier; } } -void func_80B252F8(EnRacedog* this) { - if ((this->unk_1E8 >= 9) && (this->unk_29C == 0)) { - this->unk_29C = 1; +/** + * Responsible for updating the raceStatus variable for this dog, as well as updating the + * sFurthestPoint and sFirstPlaceIndex variables. + */ +void EnRacedog_UpdateRaceVariables(EnRacedog* this) { + if ((this->currentPoint >= 9) && (this->raceStatus == RACEDOG_RACE_STATUS_BEFORE_POINT_9)) { + this->raceStatus = RACEDOG_RACE_STATUS_BETWEEN_POINTS_9_AND_11; } - if ((this->unk_1E8 >= 0xB) && (this->unk_29C == 1)) { - this->unk_29C = 2; + if ((this->currentPoint >= 11) && (this->raceStatus == RACEDOG_RACE_STATUS_BETWEEN_POINTS_9_AND_11)) { + this->raceStatus = RACEDOG_RACE_STATUS_AFTER_POINT_11; } - if (((this->unk_1E8 >= D_80B25D44) || (this->unk_29C <= 0)) && (this->unk_1E8 > D_80B25D44)) { - D_80B25D44 = this->unk_1E8; - D_80B25D4C = this->unk_290; + if (((this->currentPoint >= sFurthestPoint) || (this->raceStatus <= RACEDOG_RACE_STATUS_BEFORE_POINT_9)) && + (this->currentPoint > sFurthestPoint)) { + sFurthestPoint = this->currentPoint; + sFirstPlaceIndex = this->index; } } -void func_80B2538C(EnRacedog* this) { - if (func_80B25490(this, D_80B25E78) && this->unk_29C == 2) { - D_80B25D40++; - if (D_80B25D40 == 1) { +/** + * Checks to see if this dog has finished the race. This function is responsible for changing the + * music when the first dog finishes the race, and it is also responsible for updating the event + * flags with what position the player's selected dog finished in. + */ +void EnRacedog_CheckForFinish(EnRacedog* this) { + if (EnRacedog_IsOverFinishLine(this, sFinishLineCoordinates) && + this->raceStatus == RACEDOG_RACE_STATUS_AFTER_POINT_11) { + sNumberOfDogsFinished++; + if (sNumberOfDogsFinished == 1) { Audio_QueueSeqCmd(NA_BGM_HORSE_GOAL | 0x8000); play_sound(NA_SE_SY_START_SHOT); } - this->unk_29C = 3; - if (this->unk_290 == this->unk_292) { - gSaveContext.eventInf[0] = (gSaveContext.eventInf[0] & 7) | (D_80B25D40 * 8); + this->raceStatus = RACEDOG_RACE_STATUS_FINISHED; + if (this->index == this->selectedDogIndex) { + gSaveContext.eventInf[0] = (gSaveContext.eventInf[0] & 7) | (sNumberOfDogsFinished * 8); } } } -void func_80B25448(EnRacedog* this) { +/** + * Slows the dog's running speed animation if its speed is less than 3.0, and sets it + * to normal speed otherwise. + */ +void EnRacedog_UpdateRunAnimationPlaySpeed(EnRacedog* this) { if (this->actor.speedXZ < 3.0f) { - D_80B25EF0[2].playSpeed = 0.9f; + sAnimations[RACEDOG_ANIMATION_RUN].playSpeed = 0.9f; } else { - D_80B25EF0[2].playSpeed = 1.0f; + sAnimations[RACEDOG_ANIMATION_RUN].playSpeed = 1.0f; } } -s32 func_80B25490(EnRacedog* this, Vec2f* arg1) { +/** + * Returns true if the dog's current position is in the finish line. + */ +s32 EnRacedog_IsOverFinishLine(EnRacedog* this, Vec2f* finishLineCoordinates) { f32 xDistToTopFront; f32 zDistToTopFront; f32 xDistToBottomFront; @@ -477,53 +600,57 @@ s32 func_80B25490(EnRacedog* this, Vec2f* arg1) { f32 zDistToBottomFront; f32 zDistToTopBack; f32 xDistToTopBack; - f32 temp_f0; - f32 temp; + f32 frontPointsCrossProduct; + f32 crossProductTemp; - xDistToTopFront = this->actor.world.pos.x - arg1[0].x; - zDistToTopFront = this->actor.world.pos.z - arg1[0].y; - xDistToBottomFront = this->actor.world.pos.x - arg1[1].x; - zDistToBottomFront = this->actor.world.pos.z - arg1[1].y; - xDistToBottomBack = this->actor.world.pos.x - arg1[2].x; - zDistToBottomBack = this->actor.world.pos.z - arg1[2].y; - xDistToTopBack = this->actor.world.pos.x - arg1[3].x; - zDistToTopBack = this->actor.world.pos.z - arg1[3].y; + xDistToTopFront = this->actor.world.pos.x - finishLineCoordinates[0].x; + zDistToTopFront = this->actor.world.pos.z - finishLineCoordinates[0].z; + xDistToBottomFront = this->actor.world.pos.x - finishLineCoordinates[1].x; + zDistToBottomFront = this->actor.world.pos.z - finishLineCoordinates[1].z; + xDistToBottomBack = this->actor.world.pos.x - finishLineCoordinates[2].x; + zDistToBottomBack = this->actor.world.pos.z - finishLineCoordinates[2].z; + xDistToTopBack = this->actor.world.pos.x - finishLineCoordinates[3].x; + zDistToTopBack = this->actor.world.pos.z - finishLineCoordinates[3].z; - temp_f0 = ((xDistToTopFront * zDistToBottomFront) - (xDistToBottomFront * zDistToTopFront)); - temp = (((xDistToBottomFront * zDistToBottomBack) - (xDistToBottomBack * zDistToBottomFront))); - if (temp_f0 * temp < 0.0f) { + // frontPointsCrossProduct is positive if the dog is to the left of the line formed by the front points + // crossProductTemp is positive if the dog is above the line formed by the bottom points + frontPointsCrossProduct = ((xDistToTopFront * zDistToBottomFront) - (xDistToBottomFront * zDistToTopFront)); + crossProductTemp = (((xDistToBottomFront * zDistToBottomBack) - (xDistToBottomBack * zDistToBottomFront))); + if (frontPointsCrossProduct * crossProductTemp < 0.0f) { return false; } - temp_f0 = ((xDistToTopFront * zDistToBottomFront) - (xDistToBottomFront * zDistToTopFront)); - temp = ((xDistToBottomBack * zDistToTopBack) - (xDistToTopBack * zDistToBottomBack)); - if (temp_f0 * temp < 0.0f) { + // crossProductTemp is positive if the dog is to the right of the line formed by the back points + frontPointsCrossProduct = ((xDistToTopFront * zDistToBottomFront) - (xDistToBottomFront * zDistToTopFront)); + crossProductTemp = ((xDistToBottomBack * zDistToTopBack) - (xDistToTopBack * zDistToBottomBack)); + if (frontPointsCrossProduct * crossProductTemp < 0.0f) { return false; } - temp_f0 = ((xDistToTopFront * zDistToBottomFront) - (xDistToBottomFront * zDistToTopFront)); - temp = ((xDistToTopBack * zDistToTopFront) - (xDistToTopFront * zDistToTopBack)); - if (temp_f0 * temp < 0.0f) { + // crossProductTemp is positive if the dog is below the line formed by the top points + frontPointsCrossProduct = ((xDistToTopFront * zDistToBottomFront) - (xDistToBottomFront * zDistToTopFront)); + crossProductTemp = ((xDistToTopBack * zDistToTopFront) - (xDistToTopFront * zDistToTopBack)); + if (frontPointsCrossProduct * crossProductTemp < 0.0f) { return false; } return true; } -void func_80B255AC(EnRacedog* this, GlobalContext* globalCtx) { +void EnRacedog_SpawnFloorDustRing(EnRacedog* this, GlobalContext* globalCtx) { s16 curFrame = this->skelAnime.curFrame; s16 mod = (this->actor.speedXZ > 6.0f) ? 2 : 3; - Vec3f sp38; + Vec3f pos; - if (((this->unk_290 + curFrame) % mod) == 0) { - sp38.x = this->actor.world.pos.x + randPlusMinusPoint5Scaled(15.0f); - sp38.y = this->actor.world.pos.y; - sp38.z = this->actor.world.pos.z + randPlusMinusPoint5Scaled(15.0f); - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &sp38, 10.0f, 0, 2.0f, 300, 0, true); + if (((this->index + curFrame) % mod) == 0) { + pos.x = this->actor.world.pos.x + randPlusMinusPoint5Scaled(15.0f); + pos.y = this->actor.world.pos.y; + pos.z = this->actor.world.pos.z + randPlusMinusPoint5Scaled(15.0f); + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &pos, 10.0f, 0, 2.0f, 300, 0, true); } } -void func_80B256BC(EnRacedog* this) { +void EnRacedog_PlayWalkSfx(EnRacedog* this) { s16 curFrame = this->skelAnime.curFrame; if ((curFrame == 1) || (curFrame == 7)) { @@ -534,18 +661,20 @@ void func_80B256BC(EnRacedog* this) { void EnRacedog_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnRacedog* this = THIS; - Vec3f sp2C = { 0.0f, 0.0f, 0.0f }; + Vec3f floorRot = { 0.0f, 0.0f, 0.0f }; - this->unk_292 = D_80B25E68.unk_0A; + this->selectedDogIndex = sSelectedDogInfo.index; this->actionFunc(this, globalCtx); - func_80B246F4(this, globalCtx); - func_80B248B8(this, &sp2C); - Math_ApproachF(&this->unk_2AC.x, sp2C.x, 0.2f, 0.1f); + EnRacedog_UpdateCollision(this, globalCtx); + EnRacedog_GetFloorRot(this, &floorRot); + Math_ApproachF(&this->curRot.x, floorRot.x, 0.2f, 0.1f); - if (this->unk_2A0.x > 0.0f) { - if ((this->unk_2AC.x < 0.0f) && (this->unk_2AC.x > -0.1f)) { + if (this->prevRot.x > 0.0f) { + if ((this->curRot.x < 0.0f) && (this->curRot.x > -0.1f)) { + // Moves to the part of the running animation where the dog has four feet + // on the ground and is about to lift its feet off the ground. this->skelAnime.curFrame = 4.0f; this->actor.velocity.y = 5.5f; } @@ -555,54 +684,46 @@ void EnRacedog_Update(Actor* thisx, GlobalContext* globalCtx) { this->skelAnime.curFrame = 0.0f; } - this->unk_2A0 = this->unk_2AC; + this->prevRot = this->curRot; SkelAnime_Update(&this->skelAnime); } -void func_80B2583C(EnRacedog* this) { - s16 phi_v1; - - if (this->unk_288 >= 7) { - this->unk_2BC -= 0x10; - this->unk_2C0 += 8; - this->unk_2C4 += 0.05f; +void EnRacedog_UpdateSelectionArrow(EnRacedog* this) { + if (this->selectionArrowTimer > 6) { + this->selectionArrowGreenPrimColor -= 16; + this->selectionArrowGreenEnvColor += 8; + this->selectionArrowScale += 0.05f; } else { - this->unk_2BC += 0x10; - this->unk_2C0 -= 8; - this->unk_2C4 -= 0.05f; + this->selectionArrowGreenPrimColor += 16; + this->selectionArrowGreenEnvColor -= 8; + this->selectionArrowScale -= 0.05f; } - if (this->unk_288 == 0) { - phi_v1 = 0; - } else { - this->unk_288--; - phi_v1 = this->unk_288; - } - - if (phi_v1 == 0) { - this->unk_288 = 0xC; + if (DECR(this->selectionArrowTimer) == 0) { + this->selectionArrowTimer = 12; } } -void func_80B258D8(EnRacedog* this, GlobalContext* globalCtx) { - Vec3s sp48 = gZeroVec3s; - s32 phi_v0 = (this->unk_290 == this->unk_292) ? true : false; +void EnRacedog_DrawSelectionArrow(EnRacedog* this, GlobalContext* globalCtx) { + Vec3s rotation = gZeroVec3s; + s32 shouldDrawSelectionArrow = (this->index == this->selectedDogIndex) ? true : false; - if (phi_v0) { + if (shouldDrawSelectionArrow) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); - func_80B2583C(this); + EnRacedog_UpdateSelectionArrow(this); Matrix_SetStateRotationAndTranslation(this->actor.world.pos.x, this->actor.world.pos.y + 40.0f, - this->actor.world.pos.z, &sp48); + this->actor.world.pos.z, &rotation); gDPPipeSync(POLY_OPA_DISP++); - gDPSetPrimColor(POLY_OPA_DISP++, 0, 255, 255, this->unk_2BC, 0, 255); - gDPSetEnvColor(POLY_OPA_DISP++, 255, this->unk_2C0, 0, 255); - Matrix_Scale(this->unk_2C4 * 2.0f, this->unk_2C4 * 2.0f, this->unk_2C4 * 2.0f, MTXMODE_APPLY); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 255, 255, this->selectionArrowGreenPrimColor, 0, 255); + gDPSetEnvColor(POLY_OPA_DISP++, 255, this->selectionArrowGreenEnvColor, 0, 255); + Matrix_Scale(this->selectionArrowScale * 2.0f, this->selectionArrowScale * 2.0f, + this->selectionArrowScale * 2.0f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, object_dog_DL_000618); - gSPDisplayList(POLY_OPA_DISP++, object_dog_DL_000550); + gSPDisplayList(POLY_OPA_DISP++, gDogSelectionArrowEmptyDL); + gSPDisplayList(POLY_OPA_DISP++, gDogSelectionArrowDL); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -616,14 +737,14 @@ s32 EnRacedog_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dL void EnRacedog_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { s32 pad; EnRacedog* this = THIS; - Vec3f sp1C = { 0.0f, 20.0f, 0.0f }; + Vec3f focusOffset = { 0.0f, 20.0f, 0.0f }; - if (limbIndex == 5) { - Matrix_MultiplyVector3fByState(&sp1C, &this->actor.focus.pos); + if (limbIndex == DOG_LIMB_HEAD) { + Matrix_MultiplyVector3fByState(&focusOffset, &this->actor.focus.pos); } - if (limbIndex == 12) { - func_80B258D8(this, globalCtx); + if (limbIndex == DOG_LIMB_TAIL) { + EnRacedog_DrawSelectionArrow(this, globalCtx); } } @@ -636,32 +757,38 @@ void EnRacedog_Draw(Actor* thisx, GlobalContext* globalCtx) { gDPPipeSync(POLY_OPA_DISP++); - switch (D_80B25D88[this->unk_290].unk_08) { - case 3: + switch (sDogInfo[this->index].color) { + case DOG_COLOR_BEIGE: gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 200, 0); break; - case 1: + + case DOG_COLOR_WHITE: gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 0); break; - case 5: + + case DOG_COLOR_BLUE: gDPSetEnvColor(POLY_OPA_DISP++, 79, 79, 143, 0); break; - case 6: + + case DOG_COLOR_GOLD: gDPSetEnvColor(POLY_OPA_DISP++, 255, 207, 47, 0); break; - case 4: + + case DOG_COLOR_BROWN: gDPSetEnvColor(POLY_OPA_DISP++, 143, 79, 47, 0); break; - case 2: + + case DOG_COLOR_GRAY: gDPSetEnvColor(POLY_OPA_DISP++, 143, 143, 143, 0); break; + default: gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 200, 0); break; } Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); - Matrix_RotateStateAroundXAxis(this->unk_2AC.x); + Matrix_RotateStateAroundXAxis(this->curRot.x); Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); diff --git a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.h b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.h index 2f9f9b06b9..a4406b04cd 100644 --- a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.h +++ b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.h @@ -2,10 +2,22 @@ #define Z_EN_RACEDOG_H #include "global.h" +#include "objects/object_dog/object_dog.h" -#define ENRACEDOG_GET_3E0(thisx) (((thisx)->params & 0x3E0) >> 5) +#define ENRACEDOG_GET_INDEX(thisx) (((thisx)->params & 0x3E0) >> 5) #define ENRACEDOG_GET_PATH(thisx) (((thisx)->params & 0xFC00) >> 10) +/** + * The main point of this seems to be some very light anti-cheat detection. The dog + * must progress through these statuses in a linear order to finish the race. + */ +typedef enum { + /* 0 */ RACEDOG_RACE_STATUS_BEFORE_POINT_9, + /* 1 */ RACEDOG_RACE_STATUS_BETWEEN_POINTS_9_AND_11, + /* 2 */ RACEDOG_RACE_STATUS_AFTER_POINT_11, + /* 3 */ RACEDOG_RACE_STATUS_FINISHED +} RacedogRaceStatus; + struct EnRacedog; typedef void (*EnRacedogActionFunc)(struct EnRacedog*, GlobalContext*); @@ -17,26 +29,26 @@ typedef struct EnRacedog { /* 0x14C */ SkelAnime skelAnime; /* 0x190 */ ColliderCylinder collider; /* 0x1DC */ UNK_TYPE1 unk_1DC[0x4]; - /* 0x1E0 */ Path* unk_1E0; + /* 0x1E0 */ Path* path; /* 0x1E4 */ UNK_TYPE1 unk_1E4[0x4]; - /* 0x1E8 */ s32 unk_1E8; - /* 0x1EC */ Vec3s jointTable[13]; - /* 0x23A */ Vec3s morphTable[13]; - /* 0x288 */ s16 unk_288; - /* 0x28A */ s16 unk_28A; - /* 0x28C */ s16 unk_28C; + /* 0x1E8 */ s32 currentPoint; + /* 0x1EC */ Vec3s jointTable[DOG_LIMB_MAX]; + /* 0x23A */ Vec3s morphTable[DOG_LIMB_MAX]; + /* 0x288 */ s16 selectionArrowTimer; + /* 0x28A */ s16 raceStartTimer; + /* 0x28C */ s16 extraTimeBeforeRaceStart; /* 0x28A */ UNK_TYPE1 unk_28E[0x2]; - /* 0x290 */ s16 unk_290; - /* 0x292 */ s16 unk_292; + /* 0x290 */ s16 index; + /* 0x292 */ s16 selectedDogIndex; /* 0x294 */ UNK_TYPE1 unk_294[0x4]; - /* 0x298 */ f32 unk_298; - /* 0x29C */ s16 unk_29C; - /* 0x2A0 */ Vec3f unk_2A0; - /* 0x2AC */ Vec3f unk_2AC; - /* 0x2B8 */ s32 unk_2B8; - /* 0x2BC */ s32 unk_2BC; - /* 0x2C0 */ s32 unk_2C0; - /* 0x2C4 */ f32 unk_2C4; + /* 0x298 */ f32 targetSpeed; + /* 0x29C */ s16 raceStatus; + /* 0x2A0 */ Vec3f prevRot; + /* 0x2AC */ Vec3f curRot; + /* 0x2B8 */ s32 pointForCurrentTargetSpeed; + /* 0x2BC */ s32 selectionArrowGreenPrimColor; + /* 0x2C0 */ s32 selectionArrowGreenEnvColor; + /* 0x2C4 */ f32 selectionArrowScale; } EnRacedog; // size = 0x2C8 extern const ActorInit En_Racedog_InitVars; diff --git a/src/overlays/actors/ovl_En_Raf/z_en_raf.c b/src/overlays/actors/ovl_En_Raf/z_en_raf.c index a328116202..4d880a389e 100644 --- a/src/overlays/actors/ovl_En_Raf/z_en_raf.c +++ b/src/overlays/actors/ovl_En_Raf/z_en_raf.c @@ -1,7 +1,7 @@ /* * File: z_en_raf.c * Overlay: ovl_En_Raf - * Description: Carnivorous Lilypad + * Description: Carnivorous Lily Pad */ #include "z_en_raf.h" @@ -15,16 +15,58 @@ void EnRaf_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnRaf_Update(Actor* thisx, GlobalContext* globalCtx); void EnRaf_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80A171D8(EnRaf* this, GlobalContext* globalCtx); -void func_80A17464(EnRaf* this, GlobalContext* globalCtx); -void func_80A175E4(EnRaf* this, GlobalContext* globalCtx); -void func_80A178A0(EnRaf* this, GlobalContext* globalCtx); -void func_80A17C6C(EnRaf* this, GlobalContext* globalCtx); -void func_80A17D54(EnRaf* this, GlobalContext* globalCtx); -void func_80A17E1C(EnRaf* this, GlobalContext* globalCtx); -void func_80A180B4(EnRaf* this, GlobalContext* globalCtx); +void EnRaf_SetupIdle(EnRaf* this); +void EnRaf_Idle(EnRaf* this, GlobalContext* globalCtx); +void EnRaf_SetupGrab(EnRaf* this); +void EnRaf_Grab(EnRaf* this, GlobalContext* globalCtx); +void EnRaf_SetupChew(EnRaf* this); +void EnRaf_Chew(EnRaf* this, GlobalContext* globalCtx); +void EnRaf_SetupThrow(EnRaf* this, GlobalContext* globalCtx); +void EnRaf_Throw(EnRaf* this, GlobalContext* globalCtx); +void EnRaf_Explode(EnRaf* this, GlobalContext* globalCtx); +void EnRaf_PostDetonation(EnRaf* this, GlobalContext* globalCtx); +void EnRaf_Convulse(EnRaf* this, GlobalContext* globalCtx); +void EnRaf_SetupDissolve(EnRaf* this); +void EnRaf_Dissolve(EnRaf* this, GlobalContext* globalCtx); +void EnRaf_SetupDormant(EnRaf* this); +void EnRaf_Dormant(EnRaf* this, GlobalContext* globalCtx); +void EnRaf_InitializeParticle(EnRaf* this, Vec3f* position, Vec3f* velocity, Vec3f* acceleration, f32 scale, s16 timer); +void EnRaf_UpdateParticles(EnRaf* this, GlobalContext* globalCtx); +void EnRaf_DrawParticles(EnRaf* this, GlobalContext* globalCtx); + +typedef enum { + /* 0 */ EN_RAF_ANIMATION_IDLE, + /* 1 */ EN_RAF_ANIMATION_CLOSE, + /* 2 */ EN_RAF_ANIMATION_CHEW, + /* 3 */ EN_RAF_ANIMATION_SPIT, + /* 4 */ EN_RAF_ANIMATION_CONVULSE, + /* 5 */ EN_RAF_ANIMATION_DEATH, +} EnRafAnimationIndex; + +typedef enum { + /* 0 */ EN_RAF_ACTION_IDLE, + /* 1 */ EN_RAF_ACTION_GRAB, + /* 2 */ EN_RAF_ACTION_CHEW, + /* 3 */ EN_RAF_ACTION_THROW, + /* 4 */ EN_RAF_ACTION_EXPLODE, + /* 5 */ EN_RAF_ACTION_CONVULSE, + /* 6 */ EN_RAF_ACTION_DISSOLVE, + /* 7 */ EN_RAF_ACTION_DORMANT, +} EnRafAction; + +typedef enum { + /* 0 */ EN_RAF_GRAB_TARGET_PLAYER, + /* 1 */ EN_RAF_GRAB_TARGET_EXPLOSIVE, + /* 2 */ EN_RAF_GRAB_TARGET_GORON_PLAYER +} EnRafGrabTarget; + +typedef enum { + /* 0 */ EN_RAF_PETAL_SCALE_TYPE_DEAD, + /* 1 */ EN_RAF_PETAL_SCALE_TYPE_GRAB, + /* 2 */ EN_RAF_PETAL_SCALE_TYPE_CHEW, + /* 3 */ EN_RAF_PETAL_SCALE_TYPE_IDLE_OR_THROW +} EnRafPetalScaleType; -#if 0 const ActorInit En_Raf_InitVars = { ACTOR_EN_RAF, ACTORCAT_PROP, @@ -37,15 +79,71 @@ const ActorInit En_Raf_InitVars = { (ActorFunc)EnRaf_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A18EE0 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_ENEMY, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x04, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x04, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 50, 10, -10, { 0, 0, 0 } }, }; -// static DamageTable sDamageTable = { -static DamageTable D_80A1939C = { +static u8 sTeethClearPixelTableFirstPass[] = { + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, + 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, +}; + +static u8 sTeethClearPixelTableSecondPass[] = { + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, +}; + +static u8 sPetalClearPixelTableFirstPass[] = { + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, + 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, + 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, + 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, + 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, + 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, + 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, + 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, + 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, + 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, +}; + +static u8 sPetalClearPixelTableSecondPass[] = { + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, +}; + +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0xF), /* Deku Stick */ DMG_ENTRY(0, 0xF), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -80,65 +178,786 @@ static DamageTable D_80A1939C = { /* Powder Keg */ DMG_ENTRY(0, 0xF), }; -#endif +/** + * Sets the `index`th pixel of the trap teeth texture to 0 (transparent black) + * according to the `clearPixelTable`. Only works if the texture uses 16-bit pixels. + */ +void EnRaf_ClearPixelTeeth(u16* texture, u8* clearPixelTable, s32 index) { + if ((index < (8 * 8)) && (clearPixelTable[index] != 0)) { + texture[index] = 0; + } +} -extern ColliderCylinderInit D_80A18EE0; -extern DamageTable D_80A1939C; +/** + * Sets the `index`th pixel of the trap petal texture to 0 (transparent black) + * according to the `clearPixelTable`. Only works if the texture uses 16-bit pixels. + */ +void EnRaf_ClearPixelPetal(u16* texture, u8* clearPixelTable, s32 index) { + if (clearPixelTable[index] != 0) { + texture[index] = 0; + } +} -extern UNK_TYPE D_06000108; -extern UNK_TYPE D_060024E0; -extern UNK_TYPE D_060032F8; +void EnRaf_Init(Actor* thisx, GlobalContext* globalCtx) { + EnRaf* this = THIS; + Vec3f limbScale = { 1.0f, 1.0f, 1.0f }; + s32 pad; + s32 i; + CollisionHeader* colHeader = NULL; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A16D40.s") + DynaPolyActor_Init(&this->dyna, 0); + CollisionHeader_GetVirtual(&gCarnivorousLilyPadCol, &colHeader); + this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit); + this->dyna.actor.targetMode = 3; + this->dyna.actor.colChkInfo.mass = MASS_IMMOVABLE; + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gCarnivorousLilyPadSkel, &gCarnivorousLilyPadSpitAnim, + this->jointTable, this->morphTable, CARNIVOROUS_LILY_PAD_LIMB_MAX); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A16D6C.s") + for (i = 0; i < ARRAY_COUNT(this->limbScale); i++) { + Math_Vec3f_Copy(&this->targetLimbScale[i], &limbScale); + Math_Vec3f_Copy(&this->limbScale[i], &limbScale); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/EnRaf_Init.s") + this->dyna.actor.colChkInfo.damageTable = &sDamageTable; + this->dyna.actor.colChkInfo.health = BREG(1) + 2; + this->mainType = EN_RAF_GET_TYPE(&this->dyna.actor); + this->reviveTimer = EN_RAF_GET_REVIVE_TIMER(&this->dyna.actor); + this->switchFlag = EN_RAF_GET_SWITCH_FLAG(&this->dyna.actor); + if (this->switchFlag == 0x7F) { + this->switchFlag = -1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/EnRaf_Destroy.s") + if (this->reviveTimer == 31) { + this->reviveTimer = -1; + } else { + this->reviveTimer = 30; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A17060.s") + if (((this->switchFlag >= 0) || (this->mainType == EN_RAF_TYPE_DORMANT) || + (gSaveContext.save.weekEventReg[12] & 1)) && + ((Flags_GetSwitch(globalCtx, this->switchFlag)) || (this->mainType == EN_RAF_TYPE_DORMANT))) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A1712C.s") + for (i = CARNIVOROUS_LILY_PAD_LIMB_TRAP_1_LOWER_SEGMENT; i <= CARNIVOROUS_LILY_PAD_LIMB_TRAP_3_UPPER_SEGMENT; + i++) { + Math_Vec3f_Copy(&this->limbScale[i], &gZeroVec3f); + Math_Vec3f_Copy(&this->targetLimbScale[i], &gZeroVec3f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A171D8.s") + EnRaf_SetupDormant(this); + } else { + this->bobPhase = Rand_ZeroFloat(1.0f) * 20000.0f; + Actor_SetScale(&this->dyna.actor, 0.01f); + EnRaf_SetupIdle(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A17414.s") +void EnRaf_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnRaf* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A17464.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A17530.s") +void EnRaf_ChangeAnimation(EnRaf* this, s32 index) { + static AnimationHeader* sAnimations[] = { + &gCarnivorousLilyPadSpitAnim, &gCarnivorousLilyPadCloseAnim, &gCarnivorousLilyPadChewAnim, + &gCarnivorousLilyPadSpitAnim, &gCarnivorousLilyPadConvulseAnim, &gCarnivorousLilyPadDeathAnim, + }; + static u8 sAnimationModes[] = { + ANIMMODE_ONCE, ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_ONCE, + }; + f32 startFrame = 0.0f; + f32 playSpeed = 1.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A175E4.s") + this->endFrame = Animation_GetLastFrame(sAnimations[index]); + if (index == EN_RAF_ANIMATION_IDLE) { + startFrame = this->endFrame; + } else if (index == EN_RAF_ANIMATION_CLOSE) { + playSpeed = 2.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A17848.s") + Animation_Change(&this->skelAnime, sAnimations[index], playSpeed, startFrame, this->endFrame, + sAnimationModes[index], -4.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A178A0.s") +void EnRaf_SetupIdle(EnRaf* this) { + Vec3f targetLimbScale = { 1.0f, 1.0f, 1.0f }; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A179C8.s") + EnRaf_ChangeAnimation(this, EN_RAF_ANIMATION_IDLE); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A17C6C.s") + for (i = CARNIVOROUS_LILY_PAD_LIMB_TRAP_1_LOWER_SEGMENT; i <= CARNIVOROUS_LILY_PAD_LIMB_TRAP_3_UPPER_SEGMENT; i++) { + Math_Vec3f_Copy(&this->targetLimbScale[i], &targetLimbScale); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A17D14.s") + this->petalScaleType = EN_RAF_PETAL_SCALE_TYPE_IDLE_OR_THROW; + this->action = EN_RAF_ACTION_IDLE; + this->actionFunc = EnRaf_Idle; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A17D54.s") +/** + * Sits around waiting for the player or an explosive to get near in order to grab them. + */ +void EnRaf_Idle(EnRaf* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Actor* explosive; + f32 xDiff; + f32 yDiff; + f32 zDiff; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A17DDC.s") + if (this->timer == 0) { + if ((player->transformation != PLAYER_FORM_DEKU) && + (this->dyna.actor.xzDistToPlayer < (BREG(48) + 80.0f) && (player->invincibilityTimer == 0) && + DynaPolyActor_IsInRidingMovingState(&this->dyna) && !(player->stateFlags1 & 0x8000000) && + globalCtx->grabPlayer(globalCtx, player))) { + player->actor.parent = &this->dyna.actor; + this->grabTarget = EN_RAF_GRAB_TARGET_PLAYER; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A17E1C.s") + if (player->transformation == PLAYER_FORM_GORON) { + this->grabTarget = EN_RAF_GRAB_TARGET_GORON_PLAYER; + } else { + player->unk_AE8 = 50; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A18080.s") + this->playerRotYWhenGrabbed = player->actor.world.rot.y; + EnRaf_SetupGrab(this); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A180B4.s") + if ((globalCtx->gameplayFrames % 2) == 0) { + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/EnRaf_Update.s") + explosive = globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVES].first; + while (explosive != NULL) { + // This check is pointless, since EnRaf is never in the explosive category. + if ((EnRaf*)explosive == this) { + explosive = explosive->next; + continue; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A1859C.s") + xDiff = explosive->world.pos.x - this->dyna.actor.world.pos.x; + yDiff = explosive->world.pos.y - this->dyna.actor.world.pos.y; + zDiff = explosive->world.pos.z - this->dyna.actor.world.pos.z; + if ((fabsf(xDiff) < 80.0f) && (fabsf(yDiff) < 30.0f) && (fabsf(zDiff) < 80.0f) && + (explosive->update != NULL) && (explosive->velocity.y != 0.0f)) { + Actor_MarkForDeath(explosive); + this->grabTarget = EN_RAF_GRAB_TARGET_EXPLOSIVE; + this->collider.dim.radius = 30; + this->collider.dim.height = 90; + this->collider.dim.yShift = -10; + EnRaf_SetupGrab(this); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/EnRaf_Draw.s") + explosive = explosive->next; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A18A90.s") +void EnRaf_SetupGrab(EnRaf* this) { + EnRaf_ChangeAnimation(this, EN_RAF_ANIMATION_CLOSE); + this->petalScaleType = EN_RAF_PETAL_SCALE_TYPE_GRAB; + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EN_SUISEN_DRINK); + this->action = EN_RAF_ACTION_GRAB; + this->actionFunc = EnRaf_Grab; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A18B8C.s") +/** + * Grabs the player or explosive that entered its range. + */ +void EnRaf_Grab(EnRaf* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 curFrame = this->skelAnime.curFrame; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A18DA0.s") + if ((this->grabTarget != EN_RAF_GRAB_TARGET_EXPLOSIVE) && (player->stateFlags2 & 0x80) && + (&this->dyna.actor == player->actor.parent)) { + Math_ApproachF(&player->actor.world.pos.x, this->dyna.actor.world.pos.x, 0.3f, 10.0f); + Math_ApproachF(&player->actor.world.pos.y, this->dyna.actor.world.pos.y, 0.3f, 10.0f); + Math_ApproachF(&player->actor.world.pos.z, this->dyna.actor.world.pos.z, 0.3f, 10.0f); + } + + if (this->endFrame <= curFrame) { + EnRaf_SetupChew(this); + } +} + +void EnRaf_SetupChew(EnRaf* this) { + s32 i; + + EnRaf_ChangeAnimation(this, EN_RAF_ANIMATION_CHEW); + this->chewCount = 0; + for (i = 0; i < ARRAY_COUNT(this->chewLimbRot); i++) { + this->chewLimbRot[i].x = Rand_S16Offset(8, 8) << 8; + this->chewLimbRot[i].y = Rand_S16Offset(8, 8) << 8; + this->chewLimbRot[i].z = Rand_S16Offset(8, 8) << 8; + } + + this->petalScaleType = EN_RAF_PETAL_SCALE_TYPE_CHEW; + this->action = EN_RAF_ACTION_CHEW; + this->actionFunc = EnRaf_Chew; +} + +/** + * Chews the player or explosive that was grabbed. If it grabbed a non-Goron player, it will deal + * damage to them and eventually throw them. If it grabbed a Goron player or explosive, it will + * instead explode after chewing them a bit. + */ +void EnRaf_Chew(EnRaf* this, GlobalContext* globalCtx) { + f32 targetChewScale; + f32 curFrame; + Player* player = GET_PLAYER(globalCtx); + + curFrame = this->skelAnime.curFrame; + targetChewScale = (BREG(51) / 100.0f) + 0.2f; + Math_ApproachF(&this->chewScale, targetChewScale, 0.2f, 0.03f); + + if ((player->stateFlags2 & 0x80) && (this->grabTarget != EN_RAF_GRAB_TARGET_EXPLOSIVE) && + (&this->dyna.actor == player->actor.parent)) { + Math_ApproachF(&player->actor.world.pos.x, this->dyna.actor.world.pos.x, 0.3f, 10.0f); + Math_ApproachF(&player->actor.world.pos.y, this->dyna.actor.world.pos.y, 0.3f, 10.0f); + Math_ApproachF(&player->actor.world.pos.z, this->dyna.actor.world.pos.z, 0.3f, 10.0f); + } + + if (this->endFrame <= curFrame) { + if (BREG(52) == 0) { + this->chewCount++; + } + + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EN_SUISEN_EAT); + switch (this->grabTarget) { + case EN_RAF_GRAB_TARGET_PLAYER: + globalCtx->damagePlayer(globalCtx, -2); + func_800B8E58((Player*)this, player->ageProperties->unk_92 + NA_SE_VO_LI_DAMAGE_S); + CollisionCheck_GreenBlood(globalCtx, NULL, &player->actor.world.pos); + if ((this->chewCount > (BREG(53) + 5)) || !(player->stateFlags2 & 0x80)) { + player->actor.freezeTimer = 10; + EnRaf_SetupThrow(this, globalCtx); + return; + } + break; + + case EN_RAF_GRAB_TARGET_EXPLOSIVE: + Actor_ApplyDamage(&this->dyna.actor); + if (this->chewCount > (BREG(54) + 4)) { + EnRaf_Explode(this, globalCtx); + return; + } + break; + + case EN_RAF_GRAB_TARGET_GORON_PLAYER: + if (this->chewCount > (BREG(54) + 4)) { + player->actor.parent = NULL; + player->unk_AE8 = 1000; + EnRaf_Explode(this, globalCtx); + } + break; + } + } +} + +void EnRaf_SetupThrow(EnRaf* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + EnRaf_ChangeAnimation(this, EN_RAF_ANIMATION_SPIT); + player->actor.freezeTimer = 10; + this->petalScaleType = EN_RAF_PETAL_SCALE_TYPE_IDLE_OR_THROW; + this->action = EN_RAF_ACTION_THROW; + this->actionFunc = EnRaf_Throw; +} + +/** + * Spits out the grabbed player. + */ +void EnRaf_Throw(EnRaf* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 curFrame = this->skelAnime.curFrame; + + if (Animation_OnFrame(&this->skelAnime, 10.0f)) { + player->actor.freezeTimer = 0; + player->actor.parent = NULL; + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EN_SUISEN_THROW); + func_800B8D50(globalCtx, &this->dyna.actor, BREG(55) + 3.0f, this->playerRotYWhenGrabbed + 0x8000, + BREG(56) + 10.0f, 0); + } else if (curFrame < 10.0f) { + player->actor.freezeTimer = 10; + } + + if (this->endFrame <= curFrame) { + this->petalScaleType = EN_RAF_PETAL_SCALE_TYPE_IDLE_OR_THROW; + this->action = EN_RAF_ACTION_IDLE; + this->timer = 20; + this->actionFunc = EnRaf_Idle; + } +} + +/** + * Creates an explosion effect/sound and spawns particles. + */ +void EnRaf_Explode(EnRaf* this, GlobalContext* globalCtx) { + Vec3f velocity = { 0.0f, 0.0f, 0.0f }; + Vec3f acceleration = { 0.0f, 0.0f, 0.0f }; + Vec3f explosionPos; + s32 i; + s32 pad; + + this->action = EN_RAF_ACTION_EXPLODE; + Math_Vec3f_Copy(&explosionPos, &this->dyna.actor.world.pos); + explosionPos.y += 10.0f; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, explosionPos.x, explosionPos.y, explosionPos.z, 0, + 0, 0, CLEAR_TAG_SMALL_EXPLOSION); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_IT_BOMB_EXPLOSION); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EN_SUISEN_DEAD); + if (this->switchFlag >= 0) { + Flags_SetSwitch(globalCtx, this->switchFlag); + } + + this->petalScaleType = EN_RAF_PETAL_SCALE_TYPE_DEAD; + for (i = 0; i < BREG(57) + 30; i++) { + acceleration.x = (Rand_ZeroOne() - 0.5f) * 0.5f; + acceleration.y = -0.3f; + acceleration.z = (Rand_ZeroOne() - 0.5f) * 0.5f; + velocity.x = Rand_ZeroOne() - 0.5f; + velocity.y = Rand_ZeroOne() * 10.0f; + velocity.z = Rand_ZeroOne() - 0.5f; + EnRaf_InitializeParticle(this, &this->dyna.actor.world.pos, &velocity, &acceleration, + (Rand_ZeroFloat(1.0f) / 500.0f) + 0.002f, 90); + } + + for (i = CARNIVOROUS_LILY_PAD_LIMB_TRAP_1_LOWER_SEGMENT; i <= CARNIVOROUS_LILY_PAD_LIMB_TRAP_3_UPPER_SEGMENT; i++) { + Math_Vec3f_Copy(&this->targetLimbScale[i], &gZeroVec3f); + } + + this->timer = 5; + if (this->grabTarget == EN_RAF_GRAB_TARGET_EXPLOSIVE) { + func_800BC154(globalCtx, &globalCtx->actorCtx, &this->dyna.actor, 5); + this->dyna.actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_4); + } + + this->actionFunc = EnRaf_PostDetonation; +} + +/** + * Switches the lily pad to the "dead" state once the timer reaches 0. + */ +void EnRaf_PostDetonation(EnRaf* this, GlobalContext* globalCtx) { + if (this->timer == 0) { + this->collider.dim.radius = 50; + this->collider.dim.height = 10; + func_800BC154(globalCtx, &globalCtx->actorCtx, &this->dyna.actor, 6); + this->dyna.actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_4); + EnRaf_SetupDormant(this); + } else if (this->grabTarget == EN_RAF_GRAB_TARGET_EXPLOSIVE) { + this->collider.dim.radius = 80; + this->collider.dim.height = 50; + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +void EnRaf_SetupConvulse(EnRaf* this) { + EnRaf_ChangeAnimation(this, EN_RAF_ANIMATION_CONVULSE); + this->chewCount = 0; + this->action = EN_RAF_ACTION_CONVULSE; + this->actionFunc = EnRaf_Convulse; +} + +/** + * Plays the convulsing animation and sets the lily pad's switch flag to prevent it from + * ever coming back to life. When the water in Woodfall Temple is purified, this function + * and EnRaf_Dissolve are jointly responsible for controlling the lily pad's death. + */ +void EnRaf_Convulse(EnRaf* this, GlobalContext* globalCtx) { + f32 curFrame = this->skelAnime.curFrame; + + if (this->endFrame <= curFrame) { + this->chewCount++; + if (this->chewCount > (BREG(2) + 2)) { + if (this->switchFlag >= 0) { + Flags_SetSwitch(globalCtx, this->switchFlag); + } + + EnRaf_SetupDissolve(this); + } + } +} + +void EnRaf_SetupDissolve(EnRaf* this) { + EnRaf_ChangeAnimation(this, EN_RAF_ANIMATION_DEATH); + this->action = EN_RAF_ACTION_DISSOLVE; + this->dissolveTimer = 0; + this->actionFunc = EnRaf_Dissolve; +} + +/** + * Makes the trap petals on the lily pad dissolve and switches the lily pad to the "dead" state. + * When the water in Woodfall Temple is purified, this function and EnRaf_Convulse are jointly + * responsible for controlling the lily pad's death. + */ +void EnRaf_Dissolve(EnRaf* this, GlobalContext* globalCtx) { + f32 curFrame = this->skelAnime.curFrame; + s32 i; + + if (this->endFrame <= curFrame) { + this->dissolveTimer++; + if (this->dissolveTimer < (BREG(3) + 105)) { + for (i = 0; i < (BREG(4) + 5); i++) { + EnRaf_ClearPixelPetal(Lib_SegmentedToVirtual(&gCarnivorousLilyPadTrapPetalTex), + sPetalClearPixelTableFirstPass, this->petalClearPixelFirstPassIndex); + EnRaf_ClearPixelTeeth(Lib_SegmentedToVirtual(&gCarnivorousLilyPadTrapTeethTex), + sTeethClearPixelTableFirstPass, this->teethClearPixelFirstPassIndex); + if (this->petalClearPixelFirstPassIndex < (16 * 32)) { + this->petalClearPixelFirstPassIndex++; + } + + if (this->teethClearPixelFirstPassIndex < (8 * 8)) { + this->teethClearPixelFirstPassIndex++; + } + } + } + } + + if (this->dissolveTimer > (BREG(5) + 50)) { + for (i = 0; i < (BREG(6) + 5); i++) { + EnRaf_ClearPixelPetal(Lib_SegmentedToVirtual(&gCarnivorousLilyPadTrapPetalTex), + sPetalClearPixelTableSecondPass, this->petalClearPixelSecondPassIndex); + EnRaf_ClearPixelTeeth(Lib_SegmentedToVirtual(&gCarnivorousLilyPadTrapTeethTex), + sTeethClearPixelTableSecondPass, this->teethClearPixelSecondPassIndex); + if (this->petalClearPixelSecondPassIndex < (16 * 32)) { + this->petalClearPixelSecondPassIndex++; + } + + if (this->teethClearPixelSecondPassIndex < (8 * 8)) { + this->teethClearPixelSecondPassIndex++; + } + } + } + + if (this->dissolveTimer > (BREG(7) + 160)) { + for (i = CARNIVOROUS_LILY_PAD_LIMB_TRAP_1_LOWER_SEGMENT; i <= CARNIVOROUS_LILY_PAD_LIMB_TRAP_3_UPPER_SEGMENT; + i++) { + Math_Vec3f_Copy(&this->limbScale[i], &gZeroVec3f); + Math_Vec3f_Copy(&this->targetLimbScale[i], &gZeroVec3f); + } + + EnRaf_SetupDormant(this); + } +} + +void EnRaf_SetupDormant(EnRaf* this) { + if (this->action == EN_RAF_ACTION_EXPLODE) { + this->timer = 90; + } else { + this->action = EN_RAF_ACTION_DORMANT; + } + + this->actionFunc = EnRaf_Dormant; +} + +/** + * Simply sits around doing nothing. If the revive timer is non-zero, then this function + * will decrement the revive timer and revive the trap petals once it reaches 0. + */ +void EnRaf_Dormant(EnRaf* this, GlobalContext* globalCtx) { + Vec3f targetLimbScale = { 1.0f, 1.0f, 1.0f }; + s32 i; + + if (this->timer == 0) { + this->action = EN_RAF_ACTION_DORMANT; + } + + if (this->reviveTimer >= 0) { + DECR(this->reviveTimer); + + if (this->reviveTimer == 0) { + EnRaf_ChangeAnimation(this, EN_RAF_ANIMATION_SPIT); + + for (i = CARNIVOROUS_LILY_PAD_LIMB_TRAP_1_LOWER_SEGMENT; + i <= CARNIVOROUS_LILY_PAD_LIMB_TRAP_3_UPPER_SEGMENT; i++) { + Math_Vec3f_Copy(&this->targetLimbScale[i], &targetLimbScale); + } + + this->petalScaleType = EN_RAF_PETAL_SCALE_TYPE_IDLE_OR_THROW; + this->action = EN_RAF_ACTION_IDLE; + this->reviveTimer = EN_RAF_GET_REVIVE_TIMER(&this->dyna.actor); + this->reviveTimer += 30; + this->actionFunc = EnRaf_Idle; + } + } +} + +void EnRaf_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnRaf* this = THIS; + WaterBox* waterBox; + f32 ySurface; + Vec3f ripplePos; + s32 i; + + SkelAnime_Update(&this->skelAnime); + DECR(this->rippleTimer); + DECR(this->timer); + this->actionFunc(this, globalCtx); + + if ((this->action == EN_RAF_ACTION_IDLE) && (gSaveContext.save.weekEventReg[12] & 1)) { + this->petalScaleType = EN_RAF_PETAL_SCALE_TYPE_DEAD; + EnRaf_SetupConvulse(this); + return; + } + + if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + if ((this->heightDiffFromPlayer > -0.1f) && !this->isCurrentlyInRidingMovingState) { + this->heightDiffFromPlayer = -20.0f; + this->isCurrentlyInRidingMovingState = true; + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EN_COMMON_WATER_MID); + } + } else { + this->isCurrentlyInRidingMovingState = false; + } + + this->bobPhase += 3000.0f; + this->bobOffset = 2.0f * Math_SinS(this->bobPhase); + if (this->mainType != EN_RAF_TYPE_NO_WATER_INTERACTIONS) { + ySurface = BREG(60) + (this->dyna.actor.world.pos.y - 60.0f); + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->dyna.actor.world.pos.x, + this->dyna.actor.world.pos.z, &ySurface, &waterBox)) { + ySurface -= this->bobOffset + BREG(59); + Math_ApproachF(&this->dyna.actor.world.pos.y, this->heightDiffFromPlayer + ySurface, 0.5f, 40.0f); + if (this->rippleTimer == 0) { + this->rippleTimer = 30; + if (this->petalScaleType == EN_RAF_PETAL_SCALE_TYPE_CHEW) { + this->rippleTimer = 10; + } + + Math_Vec3f_Copy(&ripplePos, &this->dyna.actor.world.pos); + ripplePos.y = ySurface; + EffectSsGRipple_Spawn(globalCtx, &ripplePos, 650, 3150, 0); + } + } + } else { + Math_ApproachF(&this->dyna.actor.world.pos.y, + (this->dyna.actor.home.pos.y + this->heightDiffFromPlayer) - this->bobOffset, 0.5f, 40.0f); + } + + Math_ApproachZeroF(&this->heightDiffFromPlayer, 0.3f, 2.0f); + if (this->action == EN_RAF_ACTION_EXPLODE) { + EnRaf_UpdateParticles(this, globalCtx); + } + + for (i = 0; i < ARRAY_COUNT(this->limbScale); i++) { + if (this->action < EN_RAF_ACTION_EXPLODE) { + Math_ApproachF(&this->limbScale[i].x, this->targetLimbScale[i].x, 0.4f, 0.5f); + Math_ApproachF(&this->limbScale[i].y, this->targetLimbScale[i].y, 0.4f, 0.5f); + Math_ApproachF(&this->limbScale[i].z, this->targetLimbScale[i].z, 0.4f, 0.5f); + } else { + Math_ApproachF(&this->limbScale[i].x, this->targetLimbScale[i].x, 1.0f, 1.0f); + Math_ApproachF(&this->limbScale[i].y, this->targetLimbScale[i].y, 1.0f, 1.0f); + Math_ApproachF(&this->limbScale[i].z, this->targetLimbScale[i].z, 1.0f, 1.0f); + } + } + + Collider_UpdateCylinder(&this->dyna.actor, &this->collider); + if (this->action < EN_RAF_ACTION_EXPLODE) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +static s16 sGrabAnimationCheckFrames[] = { 0, 4, 6 }; + +static Vec3f sMiddleSegmentTargetScaleDuringGrab[] = { + { 1.0f, 1.0f, 1.0f }, + { 1.0f, 2.0f, 1.0f }, + { 0.0f, 1.5f, 0.7f }, +}; + +static Vec3f sUpperSegmentTargetScaleDuringGrab[] = { + { 1.0f, 1.0f, 1.0f }, + { 3.0f, 2.0f, 1.5f }, + { 1.5f, 1.2f, 0.8f }, +}; + +static s16 sSpitAnimationCheckFrames[] = { 0, 7, 9, 13, 19 }; + +static Vec3f sMiddleSegmentTargetScaleDuringSpit[] = { + { 1.0f, 1.5f, 0.7f }, { 1.0f, 2.0f, 1.5f }, { 1.0f, 2.0f, 0.5f }, { 1.0f, 2.0f, 0.5f }, { 1.0f, 1.0f, 1.0f }, +}; + +static Vec3f sUpperSegmentTargetScaleDuringSpit[] = { + { 1.5f, 1.5f, 1.7f }, { 1.5f, 1.5f, 1.3f }, { 3.0f, 1.0f, 0.5f }, { 1.0f, 1.0f, 0.5f }, { 1.0f, 1.0f, 1.0f }, +}; + +void EnRaf_TransformLimbDraw(GlobalContext* globalCtx2, s32 limbIndex, Actor* thisx) { + GlobalContext* globalCtx = globalCtx2; + EnRaf* this = THIS; + s32 i; + + switch (this->petalScaleType) { + case EN_RAF_PETAL_SCALE_TYPE_GRAB: + if ((limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_1_MIDDLE_SEGMENT) || + (limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_3_MIDDLE_SEGMENT) || + (limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_2_MIDDLE_SEGMENT)) { + for (i = 0; i < ARRAY_COUNT(sGrabAnimationCheckFrames); i++) { + if ((s16)this->skelAnime.curFrame == sGrabAnimationCheckFrames[i]) { + Math_Vec3f_Copy(&this->targetLimbScale[limbIndex], &sMiddleSegmentTargetScaleDuringGrab[i]); + } + } + } + + if ((limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_1_UPPER_SEGMENT) || + (limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_3_UPPER_SEGMENT) || + (limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_2_UPPER_SEGMENT)) { + for (i = 0; i < ARRAY_COUNT(sGrabAnimationCheckFrames); i++) { + if ((s16)this->skelAnime.curFrame == sGrabAnimationCheckFrames[i]) { + Math_Vec3f_Copy(&this->targetLimbScale[limbIndex], &sUpperSegmentTargetScaleDuringGrab[i]); + } + } + } + break; + + case EN_RAF_PETAL_SCALE_TYPE_CHEW: + if ((limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_1_MIDDLE_SEGMENT) || + (limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_3_MIDDLE_SEGMENT) || + (limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_2_MIDDLE_SEGMENT)) { + Math_Vec3f_Copy(&this->targetLimbScale[limbIndex], &sMiddleSegmentTargetScaleDuringGrab[2]); + } else if ((limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_1_UPPER_SEGMENT) || + (limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_3_UPPER_SEGMENT) || + (limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_2_UPPER_SEGMENT)) { + Math_Vec3f_Copy(&this->targetLimbScale[limbIndex], &sUpperSegmentTargetScaleDuringGrab[2]); + } + + // These matrix operations make the trap petals look a bit more "wobbly" as it chews + // by stretching the limbs in various random directions. + if ((limbIndex > CARNIVOROUS_LILY_PAD_LIMB_FLOWER) && (limbIndex < CARNIVOROUS_LILY_PAD_LIMB_ROOTS)) { + Matrix_RotateY((this->chewLimbRot[limbIndex].y * globalCtx->gameplayFrames), MTXMODE_APPLY); + Matrix_InsertXRotation_s((this->chewLimbRot[limbIndex].x * globalCtx->gameplayFrames), MTXMODE_APPLY); + Matrix_InsertZRotation_s((this->chewLimbRot[limbIndex].z * globalCtx->gameplayFrames), MTXMODE_APPLY); + Matrix_Scale(this->chewScale + 1.0f, 1.0f, 1.0f, MTXMODE_APPLY); + Matrix_InsertZRotation_s(-(this->chewLimbRot[limbIndex].z * globalCtx->gameplayFrames), MTXMODE_APPLY); + Matrix_InsertXRotation_s(-(this->chewLimbRot[limbIndex].x * globalCtx->gameplayFrames), MTXMODE_APPLY); + Matrix_RotateY(-(this->chewLimbRot[limbIndex].y * globalCtx->gameplayFrames), MTXMODE_APPLY); + } + break; + + case EN_RAF_PETAL_SCALE_TYPE_IDLE_OR_THROW: + if ((limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_1_MIDDLE_SEGMENT) || + (limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_3_MIDDLE_SEGMENT) || + (limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_2_MIDDLE_SEGMENT)) { + for (i = 0; i < ARRAY_COUNT(sSpitAnimationCheckFrames); i++) { + if ((s16)this->skelAnime.curFrame == sSpitAnimationCheckFrames[i]) { + Math_Vec3f_Copy(&this->targetLimbScale[limbIndex], &sMiddleSegmentTargetScaleDuringSpit[i]); + } + } + } + + if ((limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_1_UPPER_SEGMENT) || + (limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_3_UPPER_SEGMENT) || + (limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_2_UPPER_SEGMENT)) { + for (i = 0; i < 4; i++) { + if ((s16)this->skelAnime.curFrame == sSpitAnimationCheckFrames[i]) { + Math_Vec3f_Copy(&this->targetLimbScale[limbIndex], &sUpperSegmentTargetScaleDuringSpit[i]); + } + } + } + break; + } + + Matrix_Scale(this->limbScale[limbIndex].x, this->limbScale[limbIndex].y, this->limbScale[limbIndex].z, + MTXMODE_APPLY); +} + +void EnRaf_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnRaf* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); + SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, NULL, NULL, EnRaf_TransformLimbDraw, &this->dyna.actor); + + if (this->action == EN_RAF_ACTION_EXPLODE) { + EnRaf_DrawParticles(this, globalCtx); + } +} + +void EnRaf_InitializeParticle(EnRaf* this, Vec3f* position, Vec3f* velocity, Vec3f* acceleration, f32 scale, + s16 timer) { + s16 i; + EnRafParticle* particle = this->particles; + + for (i = 0; i < ARRAY_COUNT(this->particles); i++, particle++) { + if (!particle->isVisible) { + particle->isVisible = true; + particle->position = *position; + particle->velocity = *velocity; + particle->acceleration = *acceleration; + particle->scale = scale; + particle->timer = timer; + particle->rotation.x = randPlusMinusPoint5Scaled(30000.0f); + particle->rotation.y = randPlusMinusPoint5Scaled(30000.0f); + particle->rotation.z = randPlusMinusPoint5Scaled(30000.0f); + return; + } + } +} + +void EnRaf_UpdateParticles(EnRaf* this, GlobalContext* globalCtx) { + s32 i; + EnRafParticle* particle = this->particles; + + for (i = 0; i < ARRAY_COUNT(this->particles); i++, particle++) { + if (particle->isVisible) { + particle->position.x += particle->velocity.x; + particle->position.y += particle->velocity.y; + particle->position.z += particle->velocity.z; + particle->rotation.x += 0xBB8; + particle->rotation.y += 0xBB8; + particle->rotation.z += 0xBB8; + particle->velocity.x += particle->acceleration.x; + particle->velocity.y += particle->acceleration.y; + particle->velocity.z += particle->acceleration.z; + + if (this->mainType != EN_RAF_TYPE_NO_WATER_INTERACTIONS) { + if (particle->position.y < (this->dyna.actor.world.pos.y - 10.0f)) { + EffectSsGSplash_Spawn(globalCtx, &particle->position, NULL, NULL, 0, particle->scale * 200000.0f); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &particle->position, 50, NA_SE_EV_BOMB_DROP_WATER); + particle->isVisible = false; + } + } else if (particle->position.y < (this->dyna.actor.world.pos.y - 10.0f)) { + Math_ApproachZeroF(&particle->scale, 0.2f, 0.001f); + if (particle->scale <= 0.0001f) { + particle->timer = 0; + } + } + + if (particle->timer != 0) { + particle->timer--; + } else { + particle->isVisible = false; + } + } + } +} + +void EnRaf_DrawParticles(EnRaf* this, GlobalContext* globalCtx) { + s16 i; + EnRafParticle* particle = this->particles; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + + OPEN_DISPS(gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + for (i = 0; i < ARRAY_COUNT(this->particles); i++, particle++) { + if (particle->isVisible) { + Matrix_InsertTranslation(particle->position.x, particle->position.y, particle->position.z, MTXMODE_NEW); + Matrix_Scale(particle->scale, particle->scale, particle->scale, MTXMODE_APPLY); + Matrix_InsertXRotation_s(particle->rotation.x, MTXMODE_APPLY); + Matrix_RotateY(particle->rotation.y, MTXMODE_APPLY); + Matrix_InsertZRotation_s(particle->rotation.z, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gCarnivorousLilyPadParticleDL); + } + } + + CLOSE_DISPS(gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Raf/z_en_raf.h b/src/overlays/actors/ovl_En_Raf/z_en_raf.h index 95ddfc54db..f639244027 100644 --- a/src/overlays/actors/ovl_En_Raf/z_en_raf.h +++ b/src/overlays/actors/ovl_En_Raf/z_en_raf.h @@ -2,16 +2,64 @@ #define Z_EN_RAF_H #include "global.h" +#include "objects/object_raf/object_raf.h" + +#define EN_RAF_GET_TYPE(thisx) (((thisx)->params >> 12) & 0xF) +#define EN_RAF_GET_REVIVE_TIMER(thisx) (((thisx)->params >> 7) & 0x1F) +#define EN_RAF_GET_SWITCH_FLAG(thisx) ((thisx)->params & 0x7F) + +typedef enum { + /* 0 */ EN_RAF_TYPE_NORMAL, + /* 1 */ EN_RAF_TYPE_DORMANT, // Spawns without trap, so it can't eat bombs/player + /* 2 */ EN_RAF_TYPE_NO_WATER_INTERACTIONS // Won't produce ripples, and particles won't produce splashes +} EnRafType; struct EnRaf; typedef void (*EnRafActionFunc)(struct EnRaf*, GlobalContext*); +typedef struct { + /* 0x00 */ u8 isVisible; + /* 0x04 */ Vec3f position; + /* 0x10 */ Vec3f velocity; + /* 0x1C */ Vec3f acceleration; + /* 0x28 */ Vec3s rotation; + /* 0x30 */ f32 scale; + /* 0x34 */ s16 timer; +} EnRafParticle; // size = 0x38 + typedef struct EnRaf { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xEC]; - /* 0x0230 */ EnRafActionFunc actionFunc; - /* 0x0234 */ char unk_234[0x8B0]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ SkelAnime skelAnime; + /* 0x1A0 */ Vec3s jointTable[CARNIVOROUS_LILY_PAD_LIMB_MAX]; + /* 0x1E8 */ Vec3s morphTable[CARNIVOROUS_LILY_PAD_LIMB_MAX]; + /* 0x230 */ EnRafActionFunc actionFunc; + /* 0x234 */ Vec3f limbScale[CARNIVOROUS_LILY_PAD_LIMB_MAX]; + /* 0x2C4 */ Vec3f targetLimbScale[CARNIVOROUS_LILY_PAD_LIMB_MAX]; + /* 0x354 */ Vec3s chewLimbRot[CARNIVOROUS_LILY_PAD_LIMB_MAX]; + /* 0x39C */ s16 grabTarget; + /* 0x39E */ u8 isCurrentlyInRidingMovingState; + /* 0x3A0 */ f32 endFrame; + /* 0x3A4 */ f32 chewScale; + /* 0x3A8 */ f32 bobOffset; + /* 0x3AC */ f32 heightDiffFromPlayer; + /* 0x3B0 */ f32 bobPhase; + /* 0x3B4 */ s16 timer; + /* 0x3B6 */ s16 dissolveTimer; + /* 0x3B8 */ s16 rippleTimer; + /* 0x3BA */ s16 reviveTimer; + /* 0x3BC */ s16 playerRotYWhenGrabbed; + /* 0x3BE */ s16 mainType; + /* 0x3C0 */ s16 switchFlag; + /* 0x3C2 */ s16 petalScaleType; + /* 0x3C4 */ s16 chewCount; + /* 0x3C6 */ s16 action; + /* 0x3C8 */ s16 petalClearPixelFirstPassIndex; + /* 0x3CA */ s16 teethClearPixelFirstPassIndex; + /* 0x3CC */ s16 petalClearPixelSecondPassIndex; + /* 0x3CE */ s16 teethClearPixelSecondPassIndex; + /* 0x3D0 */ ColliderCylinder collider; + /* 0x41C */ EnRafParticle particles[31]; } EnRaf; // size = 0xAE4 extern const ActorInit En_Raf_InitVars; diff --git a/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.c b/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.c index f29f3b6a7f..e1971c182f 100644 --- a/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.c +++ b/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.c @@ -194,7 +194,7 @@ void func_80B708C0(EnRailSkb* this, GlobalContext* globalCtx) { s32 func_80B70AB4(Vec2f arg0, Vec2f arg1) { s32 phi_v1; - if ((arg1.x * arg0.y) < (arg0.x * arg1.y)) { + if ((arg1.x * arg0.z) < (arg0.x * arg1.z)) { phi_v1 = 1; } else { phi_v1 = -1; @@ -213,9 +213,9 @@ s32 func_80B70B04(EnRailSkb* this, Vec3f pos) { s32 j; sp60.x = this->unk_230[0].z - pos.z; - sp60.y = this->unk_230[0].x - pos.x; + sp60.z = this->unk_230[0].x - pos.x; sp58.x = this->unk_230[1].z - pos.z; - sp58.y = this->unk_230[1].x - pos.x; + sp58.z = this->unk_230[1].x - pos.x; j = 1; temp_s3 = func_80B70AB4(sp60, sp58); @@ -229,9 +229,9 @@ s32 func_80B70B04(EnRailSkb* this, Vec3f pos) { } sp60.x = this->unk_230[i].z - pos.z; - sp60.y = this->unk_230[i].x - pos.x; + sp60.z = this->unk_230[i].x - pos.x; sp58.x = this->unk_230[j].z - pos.z; - sp58.y = this->unk_230[j].x - pos.x; + sp58.z = this->unk_230[j].x - pos.x; if (func_80B70AB4(sp60, sp58) != temp_s3) { ret = false; @@ -287,7 +287,7 @@ void EnRailSkb_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_2E4 = -1; this->unk_3FC = 0; this->unk_3FA = 0; - this->unk_403 = 0; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->unk_3FE = 0; if (this->actor.parent == NULL) { @@ -351,10 +351,10 @@ void func_80B71114(EnRailSkb* this) { } void func_80B7114C(EnRailSkb* this, GlobalContext* globalCtx) { - if (this->unk_3F0 == 0) { - this->unk_3F0 = 0; - this->unk_2F0 = 0.0f; - this->unk_2EC = 0.0f; + if (this->drawDmgEffTimer == 0) { + this->drawDmgEffTimer = 0; + this->drawDmgEffScale = 0.0f; + this->drawDmgEffAlpha = 0.0f; if (this->actor.colChkInfo.health != 0) { Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); @@ -365,7 +365,7 @@ void func_80B7114C(EnRailSkb* this, GlobalContext* globalCtx) { SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_STALKID_DEAD); func_80B71488(this); } - } else if (this->unk_3F0 == 1) { + } else if (this->drawDmgEffTimer == 1) { func_80B726B4(this, globalCtx); } } @@ -375,10 +375,10 @@ void func_80B71228(EnRailSkb* this) { } void func_80B7123C(EnRailSkb* this, GlobalContext* globalCtx) { - if (this->unk_3F0 == 0) { - this->unk_3F0 = 0; - this->unk_2F0 = 0.0f; - this->unk_2EC = 0.0f; + if (this->drawDmgEffTimer == 0) { + this->drawDmgEffTimer = 0; + this->drawDmgEffScale = 0.0f; + this->drawDmgEffAlpha = 0.0f; if (this->actor.colChkInfo.health != 0) { Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); @@ -534,7 +534,7 @@ void func_80B717E0(EnRailSkb* this, GlobalContext* globalCtx) { break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { func_80B71650(this); } break; @@ -671,8 +671,8 @@ void func_80B71DF0(EnRailSkb* this) { this->actor.draw = EnRailSkb_Draw; this->actor.shape.shadowAlpha = 0; this->actor.shape.rot.y = this->actor.world.rot.y; - } else if ((this->actionFunc == func_80B7114C) && (this->unk_3F0 >= 2)) { - this->unk_3F0 = 0; + } else if ((this->actionFunc == func_80B7114C) && (this->drawDmgEffTimer > 1)) { + this->drawDmgEffTimer = 0; } Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 11); @@ -700,7 +700,7 @@ void func_80B71F3C(EnRailSkb* this, GlobalContext* globalCtx) { this->unk_3F2 = 1; } - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->unk_400) { case 0x13EC: Message_StartTextbox(globalCtx, 0x13ED, &this->actor); @@ -753,7 +753,7 @@ void func_80B71F3C(EnRailSkb* this, GlobalContext* globalCtx) { } void func_80B72100(EnRailSkb* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (globalCtx->msgCtx.choiceIndex == 0) { func_8019F208(); Message_StartTextbox(globalCtx, 0x13F1, &this->actor); @@ -855,20 +855,20 @@ void func_80B72430(EnRailSkb* this, GlobalContext* globalCtx, s32 arg2) { } void func_80B725C0(EnRailSkb* this, GlobalContext* globalCtx) { - if (this->unk_3F0 > 0) { - this->unk_3F0--; + if (this->drawDmgEffTimer > 0) { + this->drawDmgEffTimer--; } if (this->actionFunc != func_80B7114C) { - if (this->unk_3F0 < 20) { + if (this->drawDmgEffTimer < 20) { if (this->actionFunc == func_80B7123C) { - Math_SmoothStepToF(&this->unk_2F0, 0.0f, 0.5f, 0.03f, 0.0f); + Math_SmoothStepToF(&this->drawDmgEffScale, 0.0f, 0.5f, 0.03f, 0.0f); } else { - Math_SmoothStepToF(&this->unk_2F0, 0.0f, 0.5f, 0.01f, 0.0f); + Math_SmoothStepToF(&this->drawDmgEffScale, 0.0f, 0.5f, 0.01f, 0.0f); } - this->unk_2EC = this->unk_3F0 * 0.05f; + this->drawDmgEffAlpha = this->drawDmgEffTimer * 0.05f; } else { - Math_SmoothStepToF(&this->unk_2F0, 0.5f, 0.1f, 0.02f, 0.0f); + Math_SmoothStepToF(&this->drawDmgEffScale, 0.5f, 0.1f, 0.02f, 0.0f); } } } @@ -883,21 +883,21 @@ void func_80B726B4(EnRailSkb* this, GlobalContext* globalCtx) { s16 yaw; if (this->unk_402 & 2) { - end = ARRAY_COUNT(this->unk_234) - 1; + end = ARRAY_COUNT(this->limbPos) - 1; } else { - end = ARRAY_COUNT(this->unk_234); + end = ARRAY_COUNT(this->limbPos); } SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 30, NA_SE_EV_ICE_BROKEN); for (i = 0; i < end; i++) { - yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_234[i]); + yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &this->limbPos[i]); sp84.x = Math_SinS(yaw) * 3.0f; sp84.z = Math_CosS(yaw) * 3.0f; sp84.y = (Rand_ZeroOne() * 4.0f) + 4.0f; - EffectSsEnIce_Spawn(globalCtx, &this->unk_234[i], 0.6f, &sp84, &D_80B734B8, &D_80B734B0, &D_80B734B4, 30); + EffectSsEnIce_Spawn(globalCtx, &this->limbPos[i], 0.6f, &sp84, &D_80B734B8, &D_80B734B0, &D_80B734B4, 30); } } @@ -964,10 +964,10 @@ void func_80B72970(EnRailSkb* this, GlobalContext* globalCtx) { return; default: - if (this->unk_3F0 >= 2) { + if (this->drawDmgEffTimer >= 2) { func_80B726B4(this, globalCtx); } - this->unk_3F0 = 0; + this->drawDmgEffTimer = 0; break; } } @@ -981,10 +981,10 @@ void func_80B72970(EnRailSkb* this, GlobalContext* globalCtx) { switch (this->actor.colChkInfo.damageEffect) { case 11: - this->unk_3F0 = 40; - this->unk_403 = 30; - this->unk_2EC = 1.0f; - this->unk_2F0 = 0.0f; + this->drawDmgEffTimer = 40; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffScale = 0.0f; Actor_SetColorFilter(&this->actor, 0, 120, 0, 40); func_80B710AC(this); break; @@ -995,10 +995,10 @@ void func_80B72970(EnRailSkb* this, GlobalContext* globalCtx) { break; case 2: - this->unk_3F0 = 80; - this->unk_403 = 0; - this->unk_2EC = 1.0f; - this->unk_2F0 = 0.0f; + this->drawDmgEffTimer = 80; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffScale = 0.0f; Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); @@ -1009,22 +1009,22 @@ void func_80B72970(EnRailSkb* this, GlobalContext* globalCtx) { case 3: if (this->actor.colChkInfo.health != 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); - this->unk_3F0 = 80; + this->drawDmgEffTimer = 80; } else { - this->unk_3F0 = 3; + this->drawDmgEffTimer = 3; } - this->unk_403 = 11; - this->unk_2EC = 1.0f; - this->unk_2F0 = 0.5f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_SFX; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffScale = 0.5f; Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); func_80B71114(this); break; case 4: - this->unk_3F0 = 40; - this->unk_403 = 20; - this->unk_2EC = 1.0f; - this->unk_2F0 = 0.5f; + this->drawDmgEffTimer = 40; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffScale = 0.5f; Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); @@ -1125,15 +1125,15 @@ void EnRailSkb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList Actor_SpawnBodyParts(&this->actor, globalCtx, 1, dList); } - if (this->unk_3F0 != 0) { + if (this->drawDmgEffTimer != 0) { if ((limbIndex == 2) || (limbIndex == 4) || (limbIndex == 5) || (limbIndex == 6) || (limbIndex == 7) || (limbIndex == 8) || (limbIndex == 9) || (limbIndex == 13) || (limbIndex == 14) || (limbIndex == 15) || (limbIndex == 16) || (limbIndex == 17) || (limbIndex == 18)) { - Matrix_GetStateTranslation(&this->unk_234[this->unk_2DC]); - this->unk_2DC++; + Matrix_GetStateTranslation(&this->limbPos[this->limbCount]); + this->limbCount++; } else if ((limbIndex == 11) && !(this->unk_402 & 2)) { - Matrix_MultiplyVector3fByState(&D_80B734D0, &this->unk_234[this->unk_2DC]); - this->unk_2DC++; + Matrix_MultiplyVector3fByState(&D_80B734D0, &this->limbPos[this->limbCount]); + this->limbCount++; } } } @@ -1142,13 +1142,13 @@ void EnRailSkb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList void EnRailSkb_Draw(Actor* thisx, GlobalContext* globalCtx) { EnRailSkb* this = THIS; - this->unk_2DC = 0; + this->limbCount = 0; func_8012C28C(globalCtx->state.gfxCtx); SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnRailSkb_OverrideLimbDraw, EnRailSkb_PostLimbDraw, &this->actor); - if (this->unk_3F0 > 0) { - func_800BE680(globalCtx, &this->actor, this->unk_234, this->unk_2DC, this->unk_2F0, 0.5f, this->unk_2EC, - this->unk_403); + if (this->drawDmgEffTimer > 0) { + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, this->limbCount, this->drawDmgEffScale, 0.5f, + this->drawDmgEffAlpha, this->drawDmgEffType); } if ((this->unk_402 & 0x40) && !(this->unk_402 & 0x80)) { diff --git a/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.h b/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.h index 23202ef199..6346eebe20 100644 --- a/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.h +++ b/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.h @@ -19,17 +19,17 @@ typedef struct EnRailSkb { /* 0x228 */ EnRailSkbActionFunc actionFunc; /* 0x22C */ ObjHakaisi* unk_22C; /* 0x230 */ Vec3s* unk_230; - /* 0x234 */ Vec3f unk_234[14]; - /* 0x2DC */ s32 unk_2DC; + /* 0x234 */ Vec3f limbPos[14]; + /* 0x2DC */ s32 limbCount; /* 0x2E0 */ s32 unk_2E0; /* 0x2E4 */ s32 unk_2E4; /* 0x2E8 */ s32 unk_2E8; - /* 0x2EC */ f32 unk_2EC; - /* 0x2F0 */ f32 unk_2F0; + /* 0x2EC */ f32 drawDmgEffAlpha; + /* 0x2F0 */ f32 drawDmgEffScale; /* 0x2F4 */ Vec3s jointTable[20]; /* 0x36C */ Vec3s morphTable[20]; /* 0x3E4 */ UNK_TYPE1 unk3E4[0xC]; - /* 0x3F0 */ s16 unk_3F0; + /* 0x3F0 */ s16 drawDmgEffTimer; /* 0x3F2 */ s16 unk_3F2; /* 0x3F4 */ s16 unk_3F4; /* 0x3F6 */ s16 unk_3F6; @@ -39,7 +39,7 @@ typedef struct EnRailSkb { /* 0x3FE */ s16 unk_3FE; /* 0x400 */ u16 unk_400; /* 0x402 */ u8 unk_402; - /* 0x403 */ u8 unk_403; + /* 0x403 */ u8 drawDmgEffType; } EnRailSkb; // size = 0x404 extern const ActorInit En_Rail_Skb_InitVars; diff --git a/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c b/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c index 39232befa9..70d9fb7088 100644 --- a/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c +++ b/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c @@ -254,8 +254,8 @@ void EnRailgibud_Init(Actor* thisx, GlobalContext* globalCtx) { EnRailgibud_SpawnOtherGibdosAndSetPositionAndRotation(this, globalCtx); this->playerStunWaitTimer = 0; - this->timeInitialized = gSaveContext.time; - this->effectType = 0; + this->timeInitialized = gSaveContext.save.time; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->type = EN_RAILGIBUD_TYPE_GIBDO; this->textId = 0; this->isInvincible = false; @@ -270,7 +270,7 @@ void EnRailgibud_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); - if (gSaveContext.weekEventReg[14] & 4) { + if (gSaveContext.save.weekEventReg[14] & 4) { Actor_MarkForDeath(&this->actor); } @@ -381,7 +381,8 @@ void EnRailgibud_WalkToPlayer(EnRailgibud* this, GlobalContext* globalCtx) { if (EnRailgibud_PlayerInRangeWithCorrectState(this, globalCtx) && Actor_IsFacingPlayer(&this->actor, 0x38E3)) { if ((this->grabWaitTimer == 0) && (this->actor.xzDistToPlayer <= 45.0f)) { player->actor.freezeTimer = 0; - if ((gSaveContext.playerForm == PLAYER_FORM_GORON) || (gSaveContext.playerForm == PLAYER_FORM_DEKU)) { + if ((gSaveContext.save.playerForm == PLAYER_FORM_GORON) || + (gSaveContext.save.playerForm == PLAYER_FORM_DEKU)) { // If the Gibdo/Redead tries to grab Goron or Deku Link, it will fail to // do so. It will appear to take damage and shake its head side-to-side. EnRailgibud_SetupGrabFail(this); @@ -552,7 +553,7 @@ void EnRailgibud_WalkToHome(EnRailgibud* this, GlobalContext* globalCtx) { this->actor.world.rot = this->actor.shape.rot; } if (EnRailgibud_PlayerInRangeWithCorrectState(this, globalCtx)) { - if ((gSaveContext.playerForm != PLAYER_FORM_GORON) && (gSaveContext.playerForm != PLAYER_FORM_DEKU) && + if ((gSaveContext.save.playerForm != PLAYER_FORM_GORON) && (gSaveContext.save.playerForm != PLAYER_FORM_DEKU) && Actor_IsFacingPlayer(&this->actor, 0x38E3)) { EnRailgibud_SetupWalkToPlayer(this); } @@ -577,7 +578,8 @@ void EnRailgibud_Damage(EnRailgibud* this, GlobalContext* globalCtx) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_405 = -1; this->actor.world.rot.y = this->actor.shape.rot.y; - if ((this->effectTimer > 0) && (this->effectType == 0) && (this->type == EN_RAILGIBUD_TYPE_GIBDO)) { + if ((this->drawDmgEffTimer > 0) && (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FIRE) && + (this->type == EN_RAILGIBUD_TYPE_GIBDO)) { this->actor.hintId = 0x2A; SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gRedeadSkel, NULL, this->jointTable, this->morphTable, GIBDO_LIMB_MAX); @@ -592,7 +594,7 @@ void EnRailgibud_SetupStunned(EnRailgibud* this) { this->actor.world.rot.y = this->actor.shape.rot.y; this->stunTimer = 10; - if (this->effectTimer != 0) { + if (this->drawDmgEffTimer != 0) { Actor_SetColorFilter(&this->actor, 0, 0xC8, 0, 0x28); } else { Actor_SetColorFilter(&this->actor, 0, 0xC8, 0, 0x28); @@ -649,7 +651,7 @@ void EnRailgibud_Dead(EnRailgibud* this, GlobalContext* globalCtx) { this->deathTimer++; } - if ((this->deathTimer == 20) && (this->effectTimer > 0) && (this->effectType == 0) && + if ((this->deathTimer == 20) && (this->drawDmgEffTimer > 0) && (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FIRE) && (this->type == EN_RAILGIBUD_TYPE_GIBDO)) { SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gRedeadSkel, NULL, this->jointTable, this->morphTable, GIBDO_LIMB_MAX); @@ -810,9 +812,9 @@ void EnRailgibud_UpdateDamage(EnRailgibud* this, GlobalContext* globalCtx) { } else { EnRailgibud_SetupDamage(this); } - this->effectType = 0; - this->effectTimer = 180; - this->effectAlpha = 1.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffTimer = 180; + this->drawDmgEffAlpha = 1.0f; break; case EN_RAILGIBUD_DMGEFF_LIGHT_ARROW: @@ -822,17 +824,17 @@ void EnRailgibud_UpdateDamage(EnRailgibud* this, GlobalContext* globalCtx) { } else { EnRailgibud_SetupDamage(this); } - this->effectType = 20; - this->effectTimer = 60; - this->effectAlpha = 1.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->drawDmgEffTimer = 60; + this->drawDmgEffAlpha = 1.0f; break; case EN_RAILGIBUD_DMGEFF_ZORA_MAGIC: if ((this->actionFunc != EnRailgibud_Grab) && ((this->actionFunc != EnRailgibud_Stunned) || (this->stunTimer == 0))) { - this->effectType = 30; - this->effectTimer = 40; - this->effectAlpha = 1.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; + this->drawDmgEffTimer = 40; + this->drawDmgEffAlpha = 1.0f; EnRailgibud_SetupStunned(this); } break; @@ -864,7 +866,7 @@ s32 EnRailgibud_MoveToIdealGrabPositionAndRotation(EnRailgibud* this, GlobalCont distanceFromTargetPos = Math_Vec3f_StepTo(&this->actor.world.pos, &targetPos, 10.0f); distanceFromTargetAngle = Math_SmoothStepToS(&this->actor.shape.rot.y, player->actor.shape.rot.y, 1, 0x1770, 0x64); this->actor.world.rot.y = this->actor.shape.rot.y; - if (gSaveContext.playerForm == PLAYER_FORM_HUMAN) { + if (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { distanceFromTargetYOffset = Math_SmoothStepToF(&this->actor.shape.yOffset, -1500.0f, 1.0f, 150.0f, 0.0f); } @@ -911,15 +913,15 @@ void EnRailgibud_MoveGrabbedPlayerAwayFromWall(EnRailgibud* this, GlobalContext* } void EnRailgibud_UpdateEffect(EnRailgibud* this, GlobalContext* globalCtx) { - if (this->effectTimer > 0) { - this->effectTimer--; + if (this->drawDmgEffTimer > 0) { + this->drawDmgEffTimer--; } - if (this->effectTimer < 20) { - Math_SmoothStepToF(&this->effectScale, 0.0f, 0.5f, 0.03f, 0.0f); - this->effectAlpha = this->effectTimer * 0.05f; + if (this->drawDmgEffTimer < 20) { + Math_SmoothStepToF(&this->drawDmgEffScale, 0.0f, 0.5f, 0.03f, 0.0f); + this->drawDmgEffAlpha = this->drawDmgEffTimer * 0.05f; } else { - Math_SmoothStepToF(&this->effectScale, 0.5f, 0.1f, 0.02f, 0.0f); + Math_SmoothStepToF(&this->drawDmgEffScale, 0.5f, 0.1f, 0.02f, 0.0f); } } @@ -967,14 +969,14 @@ void EnRailgibud_CheckIfTalkingToPlayer(EnRailgibud* this, GlobalContext* global } else { switch (Message_GetState(&globalCtx->msgCtx)) { case 5: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { Message_StartTextbox(globalCtx, 0x13B3, &this->actor); this->textId = 0x13B3; } break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { this->textId = 0; this->isInvincible = false; this->actor.speedXZ = 0.6f; @@ -1050,7 +1052,7 @@ void EnRailgibud_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi Gfx** gfx) { EnRailgibud* this = THIS; - if ((this->effectTimer != 0) && + if ((this->drawDmgEffTimer != 0) && ((limbIndex == GIBDO_LIMB_LEFT_THIGH) || (limbIndex == GIBDO_LIMB_LEFT_SHIN) || (limbIndex == GIBDO_LIMB_LEFT_FOOT) || (limbIndex == GIBDO_LIMB_RIGHT_THIGH) || (limbIndex == GIBDO_LIMB_RIGHT_SHIN) || (limbIndex == GIBDO_LIMB_RIGHT_FOOT) || @@ -1089,9 +1091,9 @@ void EnRailgibud_Draw(Actor* thisx, GlobalContext* globalCtx) { EnRailgibud_PostLimbDraw, &this->actor, POLY_XLU_DISP); } - if (this->effectTimer > 0) { - func_800BE680(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->effectScale, 0.5f, - this->effectAlpha, this->effectType); + if (this->drawDmgEffTimer > 0) { + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + this->drawDmgEffScale, 0.5f, this->drawDmgEffAlpha, this->drawDmgEffType); } CLOSE_DISPS(globalCtx->state.gfxCtx); @@ -1111,8 +1113,7 @@ void EnRailgibud_InitCutsceneGibdo(EnRailgibud* this, GlobalContext* globalCtx) Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); - - if (gSaveContext.entranceIndex != 0x2090) { // NOT Cutscene: Music Box House Opens + if (gSaveContext.save.entranceIndex != 0x2090) { // NOT Cutscene: Music Box House Opens Actor_MarkForDeath(&this->actor); } diff --git a/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.h b/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.h index 0ca4ec0b83..a51fd37d4b 100644 --- a/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.h +++ b/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.h @@ -23,8 +23,8 @@ typedef struct EnRailgibud { /* 0x0294 */ Vec3s* points; /* 0x0298 */ s32 currentPoint; /* 0x029C */ s32 pathCount; - /* 0x02A0 */ f32 effectAlpha; - /* 0x02A4 */ f32 effectScale; + /* 0x02A0 */ f32 drawDmgEffAlpha; + /* 0x02A4 */ f32 drawDmgEffScale; /* 0x02A8 */ Vec3s jointTable[GIBDO_LIMB_MAX]; /* 0x0344 */ Vec3s morphTable[GIBDO_LIMB_MAX]; /* 0x03E0 */ Vec3s headRotation; @@ -44,14 +44,14 @@ typedef struct EnRailgibud { s16 sinkTimer; }; /* 0x03F4 */ s16 grabWaitTimer; // Cannot grab the player if this is non-zero - /* 0x03F6 */ s16 effectTimer; + /* 0x03F6 */ s16 drawDmgEffTimer; /* 0x03F8 */ s16 type; /* 0x03FA */ s16 isInvincible; /* 0x03FC */ u16 actorActionCommand; /* 0x03FE */ u16 csAction; /* 0x0400 */ u16 textId; /* 0x0402 */ s16 timeInitialized; // unused other than setting it - /* 0x0404 */ u8 effectType; + /* 0x0404 */ u8 drawDmgEffType; /* 0x0405 */ s8 unk_405; // related to player->unk_ADD } EnRailgibud; // size = 0x408 diff --git a/src/overlays/actors/ovl_En_Rd/z_en_rd.c b/src/overlays/actors/ovl_En_Rd/z_en_rd.c index 4548364943..0326c13b70 100644 --- a/src/overlays/actors/ovl_En_Rd/z_en_rd.c +++ b/src/overlays/actors/ovl_En_Rd/z_en_rd.c @@ -1172,9 +1172,9 @@ void EnRd_UpdateDamage(EnRd* this, GlobalContext* globalCtx) { switch (this->damageEffect) { case EN_RD_DMGEFF_ZORA_MAGIC: if ((this->actionFunc != EnRd_Grab) && ((this->actionFunc != EnRd_Stunned) || (this->stunTimer == 0))) { - this->effectTimer = 40; - this->effectType = 30; - this->effectAlpha = 1.0f; + this->drawDmgEffTimer = 40; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; + this->drawDmgEffAlpha = 1.0f; EnRd_SetupStunned(this); } return; @@ -1185,20 +1185,20 @@ void EnRd_UpdateDamage(EnRd* this, GlobalContext* globalCtx) { case EN_RD_DMGEFF_FIRE_ARROW: Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 40); - this->effectTimer = 180; - this->effectType = 0; + this->drawDmgEffTimer = 180; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->stunnedBySunsSong = false; this->sunsSongStunTimer = 0; - this->effectAlpha = 1.0f; + this->drawDmgEffAlpha = 1.0f; break; case EN_RD_DMGEFF_LIGHT_ARROW: Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 40); - this->effectTimer = 60; - this->effectType = 20; + this->drawDmgEffTimer = 60; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; this->stunnedBySunsSong = false; this->sunsSongStunTimer = 0; - this->effectAlpha = 1.0f; + this->drawDmgEffAlpha = 1.0f; break; case EN_RD_DMGEFF_DAMAGE: @@ -1243,15 +1243,15 @@ void EnRd_UpdateCollision(EnRd* this, GlobalContext* globalCtx) { } void EnRd_UpdateEffect(EnRd* this, GlobalContext* globalCtx) { - if (this->effectTimer > 0) { - this->effectTimer--; + if (this->drawDmgEffTimer > 0) { + this->drawDmgEffTimer--; } - if (this->effectTimer < 20) { - Math_SmoothStepToF(&this->effectScale, 0.0f, 0.5f, 0.03f, 0.0f); - this->effectAlpha = this->effectTimer * 0.05f; + if (this->drawDmgEffTimer < 20) { + Math_SmoothStepToF(&this->drawDmgEffScale, 0.0f, 0.5f, 0.03f, 0.0f); + this->drawDmgEffAlpha = this->drawDmgEffTimer * 0.05f; } else { - Math_SmoothStepToF(&this->effectScale, 0.5f, 0.1f, 0.02f, 0.0f); + Math_SmoothStepToF(&this->drawDmgEffScale, 0.5f, 0.1f, 0.02f, 0.0f); } } @@ -1308,7 +1308,7 @@ s32 EnRd_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, void EnRd_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { EnRd* this = THIS; - if ((this->effectTimer != 0) && + if ((this->drawDmgEffTimer != 0) && ((limbIndex == REDEAD_LIMB_LEFT_THIGH) || (limbIndex == REDEAD_LIMB_LEFT_SHIN) || (limbIndex == REDEAD_LIMB_LEFT_FOOT) || (limbIndex == REDEAD_LIMB_RIGHT_THIGH) || (limbIndex == REDEAD_LIMB_RIGHT_SHIN) || (limbIndex == REDEAD_LIMB_RIGHT_FOOT) || @@ -1357,8 +1357,8 @@ void EnRd_Draw(Actor* thisx, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx); - if (this->effectTimer > 0) { - func_800BE680(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->effectScale, 0.5f, - this->effectAlpha, this->effectType); + if (this->drawDmgEffTimer > 0) { + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + this->drawDmgEffScale, 0.5f, this->drawDmgEffAlpha, this->drawDmgEffType); } } diff --git a/src/overlays/actors/ovl_En_Rd/z_en_rd.h b/src/overlays/actors/ovl_En_Rd/z_en_rd.h index 0340c7833a..7bf5a6ddc7 100644 --- a/src/overlays/actors/ovl_En_Rd/z_en_rd.h +++ b/src/overlays/actors/ovl_En_Rd/z_en_rd.h @@ -38,8 +38,8 @@ typedef struct EnRd { /* 0x0190 */ ColliderCylinder collider; /* 0x01DC */ Vec3f limbPos[15]; /* 0x0290 */ s32 limbIndex; - /* 0x0294 */ f32 effectAlpha; - /* 0x0298 */ f32 effectScale; + /* 0x0294 */ f32 drawDmgEffAlpha; + /* 0x0298 */ f32 drawDmgEffScale; /* 0x029C */ Vec3s jointTable[REDEAD_LIMB_MAX]; /* 0x0338 */ Vec3s morphTable[REDEAD_LIMB_MAX]; /* 0x03D4 */ s16 headShakeTimer; @@ -59,8 +59,8 @@ typedef struct EnRd { s16 danceEndTimer; s16 pirouetteRotationalVelocity; }; - /* 0x03E6 */ s16 effectTimer; - /* 0x03E8 */ u8 effectType; + /* 0x03E6 */ s16 drawDmgEffTimer; + /* 0x03E8 */ u8 drawDmgEffType; /* 0x03E9 */ u8 stunnedBySunsSong; /* 0x03EA */ u8 grabDamageTimer; /* 0x03EB */ u8 grabState; diff --git a/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c b/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c index 226cc821df..8c2f5b6c83 100644 --- a/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c +++ b/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c @@ -144,13 +144,13 @@ void EnRecepgirl_Talk(EnRecepgirl* this, GlobalContext* globalCtx) { if (temp_v0_2 == 2) { this->actor.textId = 0x2ADC; // hear directions again? EnRecepgirl_SetupWait(this); - } else if ((temp_v0_2 == 5) && (func_80147624(globalCtx) != 0)) { + } else if ((temp_v0_2 == 5) && (Message_ShouldAdvance(globalCtx) != 0)) { if (this->actor.textId == 0x2AD9) { // "Welcome..." Flags_SetSwitch(globalCtx, this->actor.params); Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00AD98, 10.0f); - if (gSaveContext.weekEventReg[63] & 0x80) { // showed Couple's Mask to meeting - this->actor.textId = 0x2ADF; // Mayor's office is on the left (meeting ended) + if (gSaveContext.save.weekEventReg[63] & 0x80) { // showed Couple's Mask to meeting + this->actor.textId = 0x2ADF; // Mayor's office is on the left (meeting ended) } else { this->actor.textId = 0x2ADA; // Mayor's office is on the left (meeting ongoing) } diff --git a/src/overlays/actors/ovl_En_Rg/z_en_rg.c b/src/overlays/actors/ovl_En_Rg/z_en_rg.c index f8fd33a271..09d2093ce3 100644 --- a/src/overlays/actors/ovl_En_Rg/z_en_rg.c +++ b/src/overlays/actors/ovl_En_Rg/z_en_rg.c @@ -383,8 +383,8 @@ s32 func_80BF43FC(EnRg* this) { s32 phi_s0 = D_80BF57E4[this->unk_344][temp_s7]; while (true) { - func_8013C8B8(this->path, phi_s0 - 1, &sp9C); - func_8013C8B8(this->path, phi_s0 + 1, &sp90); + SubS_CopyPointFromPathCheckBounds(this->path, phi_s0 - 1, &sp9C); + SubS_CopyPointFromPathCheckBounds(this->path, phi_s0 + 1, &sp90); if (Math3D_PointDistToLine2D(this->actor.world.pos.x, this->actor.world.pos.z, sp9C.x, sp9C.z, sp90.x, sp90.z, &sp8C, &sp88, &sp84) && (!phi_s6 || ((phi_s4 + 1) == phi_s0) || (sp84 < phi_f20))) { @@ -401,6 +401,7 @@ s32 func_80BF43FC(EnRg* this) { return phi_s4; } #else +s32 func_80BF43FC(EnRg* this); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rg/func_80BF43FC.s") #endif @@ -477,11 +478,11 @@ s32 func_80BF47AC(EnRg* this, GlobalContext* globalCtx) { if ((this->unk_310 & 0x400) || (this->unk_310 & 0x1000)) { phi_f0 = 0.0f; - } else if (this->unk_348 >= 2) { + } else if (this->numCheckpointsAheadOfPlayer >= 2) { phi_f0 = phi_f2 * 0.5f; - } else if (this->unk_348 == 1) { + } else if (this->numCheckpointsAheadOfPlayer == 1) { phi_f0 = phi_f2 * 0.75f; - } else if (this->unk_348 == 0) { + } else if (this->numCheckpointsAheadOfPlayer == 0) { s16 temp_v0_3 = this->actor.yawTowardsPlayer - this->actor.world.rot.y; if ((ABS_ALT(temp_v0_3) > 0x4000) || (this->unk_326 > 0)) { @@ -489,7 +490,7 @@ s32 func_80BF47AC(EnRg* this, GlobalContext* globalCtx) { } else { phi_f0 = phi_f2 * 0.94f; } - } else if (this->unk_348 == -1) { + } else if (this->numCheckpointsAheadOfPlayer == -1) { phi_f0 = phi_f2 * 1.6f; } else { phi_f0 = 2.0f * phi_f2; @@ -521,7 +522,7 @@ void func_80BF4964(EnRg* this) { if (this->path != NULL) { sp3C = Lib_SegmentedToVirtual(this->path->points); - if (func_8013BD40(&this->actor, this->path, this->unk_33C)) { + if (SubS_HasReachedPoint(&this->actor, this->path, this->unk_33C)) { if ((this->path->count - 1) < (this->unk_33C + 1)) { this->unk_33C = this->path->count - 1; } else { @@ -667,7 +668,7 @@ void func_80BF4EBC(EnRg* this, GlobalContext* globalCtx) { this->actor.shape.yOffset = 14.0f; this->actionFunc = func_80BF4FC4; } - } else if (gSaveContext.weekEventReg[12] & 2) { + } else if (gSaveContext.save.weekEventReg[12] & 2) { if (DECR(this->unk_318) == 0) { func_80BF409C(this, 1); this->unk_310 &= ~8; @@ -683,7 +684,7 @@ void func_80BF4EBC(EnRg* this, GlobalContext* globalCtx) { void func_80BF4FC4(EnRg* this, GlobalContext* globalCtx) { this->unk_344 = func_80BF4560(this, globalCtx); - if (!func_801690CC(globalCtx)) { + if (!Play_InCsMode(globalCtx)) { if (this->actor.bgCheckFlags & 2) { if (this->unk_310 & 0x400) { this->unk_310 &= ~0x400; @@ -733,7 +734,7 @@ void func_80BF4FC4(EnRg* this, GlobalContext* globalCtx) { void EnRg_Init(Actor* thisx, GlobalContext* globalCtx) { EnRg* this = THIS; - if (gSaveContext.entranceIndex == 0xD010) { + if (gSaveContext.save.entranceIndex == 0xD010) { ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_oF1d_map_Skel_011AC8, NULL, this->jointTable, this->morphTable, 18); @@ -749,7 +750,7 @@ void EnRg_Init(Actor* thisx, GlobalContext* globalCtx) { Effect_Add(globalCtx, &this->unk_340, EFFECT_TIRE_MARK, 0, 0, &D_80BF59F0); - this->path = func_8013BEDC(globalCtx, ENRG_GET_7F80(&this->actor), 255, &this->unk_33C); + this->path = SubS_GetDayDependentPath(globalCtx, ENRG_GET_7F80(&this->actor), 255, &this->unk_33C); if (this->path != NULL) { this->unk_33C = 1; } @@ -759,7 +760,7 @@ void EnRg_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.gravity = -1.0f; SubS_UpdateFlags(&this->unk_310, 3, 7); - if (!(gSaveContext.weekEventReg[12] & 2)) { + if (!(gSaveContext.save.weekEventReg[12] & 2)) { this->unk_318 = Rand_S16Offset(30, 30); } @@ -802,7 +803,7 @@ void EnRg_Update(Actor* thisx, GlobalContext* globalCtx) { func_80BF3ED4(this, globalCtx); - if (!func_801690CC(globalCtx)) { + if (!Play_InCsMode(globalCtx)) { func_80BF3C64(this); } } diff --git a/src/overlays/actors/ovl_En_Rg/z_en_rg.h b/src/overlays/actors/ovl_En_Rg/z_en_rg.h index 87f712fe84..9f7e60ba48 100644 --- a/src/overlays/actors/ovl_En_Rg/z_en_rg.h +++ b/src/overlays/actors/ovl_En_Rg/z_en_rg.h @@ -48,7 +48,7 @@ typedef struct EnRg { /* 0x033C */ s32 unk_33C; /* 0x0340 */ s32 unk_340; /* 0x0344 */ s32 unk_344; - /* 0x0348 */ s32 unk_348; + /* 0x0348 */ s32 numCheckpointsAheadOfPlayer; /* 0x034C */ EnRgStruct unk_34C[32]; } EnRg; // size = 0xACC diff --git a/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.c b/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.c index db20137b18..2084130cec 100644 --- a/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.c +++ b/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.c @@ -1,7 +1,7 @@ /* * File: z_en_river_sound.c * Overlay: ovl_En_River_Sound - * Description: Various environment Sfx (e.g., ocean waves, gulls, waterfall, lava, etc) + * Description: Various environment Sfx along a path (e.g., ocean waves, gulls, waterfall, lava, etc) */ #include "z_en_river_sound.h" @@ -14,7 +14,6 @@ void EnRiverSound_Init(Actor* thisx, GlobalContext* globalCtx); void EnRiverSound_Update(Actor* thisx, GlobalContext* globalCtx); void EnRiverSound_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit En_River_Sound_InitVars = { ACTOR_EN_RIVER_SOUND, ACTORCAT_ITEMACTION, @@ -27,10 +26,68 @@ const ActorInit En_River_Sound_InitVars = { (ActorFunc)EnRiverSound_Draw, }; -#endif +void EnRiverSound_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnRiverSound* this = THIS; + Path* path; + s32 pathIndex; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_River_Sound/EnRiverSound_Init.s") + this->playSound = false; + pathIndex = RS_GET_PATH_INDEX(&this->actor); + this->actor.params = RS_GET_TYPE(&this->actor); + if (pathIndex == 0xFF) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_River_Sound/EnRiverSound_Update.s") + path = &globalCtx->setupPathList[pathIndex]; + this->pathPoints = Lib_SegmentedToVirtual(path->points); + this->numPoints = path->count; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_River_Sound/EnRiverSound_Draw.s") +void EnRiverSound_Update(Actor* thisx, GlobalContext* globalCtx) { + EnRiverSound* this = THIS; + Vec3f* worldPos = &this->actor.world.pos; + Vec3f eye; + s32 bgId; + + Math_Vec3f_Copy(&eye, &globalCtx->view.eye); + + if (this->actor.params < RS_RIVER_DEFAULT_LOW_FREQ) { + // All sfx from river_sound that accesses gAudioEnvironmentalSfx is associated with a closed-loop + // path that is used to play a regional sfx + Actor_GetClosestPosOnPath(this->pathPoints, this->numPoints, &eye, worldPos, true); + } else { + Actor_GetClosestPosOnPath(this->pathPoints, this->numPoints, &eye, worldPos, false); + if (BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->actor.floorPoly, &bgId, &this->actor, worldPos) != + BGCHECK_Y_MIN) { + this->soundFreqIndex = SurfaceType_GetConveyorSpeed(&globalCtx->colCtx, this->actor.floorPoly, bgId); + } else { + this->soundFreqIndex = 0; + } + + if (this->soundFreqIndex == 0) { + this->soundFreqIndex = this->actor.params - RS_RIVER_DEFAULT_LOW_FREQ; + } else { + this->soundFreqIndex--; + } + + this->soundFreqIndex = CLAMP_MAX(this->soundFreqIndex, 2); + } +} + +void EnRiverSound_Draw(Actor* thisx, GlobalContext* globalCtx) { + static f32 freqScale[] = { + 0.7f, // 1 / sqrt(2) + 1.0f, // 1 + 1.4f, // sqrt(2) + }; + EnRiverSound* this = THIS; + s16 params = this->actor.params; + + if (params < RS_RIVER_DEFAULT_LOW_FREQ) { + Actor_PlaySfxAtPos(&this->actor, gAudioEnvironmentalSfx[params]); + } else { + Audio_PlaySfxForRiver(&this->actor.projectedPos, freqScale[this->soundFreqIndex]); + } +} diff --git a/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.h b/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.h index dc02f58fac..b8dbcc513c 100644 --- a/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.h +++ b/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.h @@ -5,9 +5,44 @@ struct EnRiverSound; +#define RS_GET_TYPE(thisx) ((thisx)->params & 0xFF); +#define RS_GET_PATH_INDEX(thisx) (((thisx)->params >> 8) & 0xFF); + +// Any param not as one of these values will result in UB +typedef enum { + /* 0x00 */ RS_RIVER_STREAM, + /* 0x01 */ RS_WAVE, + /* 0x02 */ RS_WATER_WALL_BIG, + /* 0x03 */ RS_WATER_WALL, + /* 0x04 */ RS_MAGMA_LEVEL, + /* 0x05 */ RS_MAGMA_LEVEL_M, + /* 0x06 */ RS_MAGMA_LEVEL_L, + /* 0x07 */ RS_TORCH, + /* 0x08 */ RS_FOUNTAIN, + /* 0x09 */ RS_DRAIN, + /* 0x0A */ RS_CROWD, + /* 0x0B */ RS_WATER_CONVECTION, + /* 0x0C */ RS_GORON_CHEER, + /* 0x0D */ RS_WATER_WALL_BIG_SILENT, + /* 0x0E */ RS_WATER_BUBBLE, + /* 0x0F */ RS_COW_CRY_LV, + /* 0x10 */ RS_MAKE_TURRET, + /* 0x11 */ RS_BOILED_WATER_S, + /* 0x12 */ RS_BOILED_WATER_L, + /* 0x13 */ RS_WAVE_0, + /* 0x14 */ RS_WAVE_1, + /* 0x15 */ RS_WAVE_2, + /* 0xFD */ RS_RIVER_DEFAULT_LOW_FREQ = 0xFD, + /* 0xFE */ RS_RIVER_DEFAULT_MEDIUM_FREQ, + /* 0xFF */ RS_RIVER_DEFAULT_HIGH_FREQ +} RiverSoundType; + typedef struct EnRiverSound { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x8]; + /* 0x144 */ u8 playSound; // Unused remnant of OoT + /* 0x145 */ u8 soundFreqIndex; + /* 0x146 */ u8 numPoints; + /* 0x148 */ Vec3s* pathPoints; } EnRiverSound; // size = 0x14C extern const ActorInit En_River_Sound_InitVars; diff --git a/src/overlays/actors/ovl_En_Rr/z_en_rr.c b/src/overlays/actors/ovl_En_Rr/z_en_rr.c index 57f4b9bcdc..4bd5bcf324 100644 --- a/src/overlays/actors/ovl_En_Rr/z_en_rr.c +++ b/src/overlays/actors/ovl_En_Rr/z_en_rr.c @@ -170,43 +170,43 @@ void EnRr_Destroy(Actor* thisx, GlobalContext* globalCtx) { void func_808FA01C(EnRr* this, GlobalContext* globalCtx, ColliderCylinder* collider) { if (this->actor.colChkInfo.damageEffect == 2) { - this->unk_220 = 0.85f; - this->unk_21C = 4.0f; - this->unk_1E0 = 0; + this->drawDmgEffScale = 0.85f; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; } else if (this->actor.colChkInfo.damageEffect == 4) { - this->unk_220 = 0.85f; - this->unk_21C = 4.0f; - this->unk_1E0 = 20; + this->drawDmgEffScale = 0.85f; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, collider->info.bumper.hitPos.x, collider->info.bumper.hitPos.y, collider->info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); } else if (this->actor.colChkInfo.damageEffect == 5) { - this->unk_220 = 0.85f; - this->unk_21C = 4.0f; - this->unk_1E0 = 30; + this->drawDmgEffScale = 0.85f; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; } } void func_808FA11C(EnRr* this) { - this->unk_1E0 = 10; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; this->collider1.base.colType = COLTYPE_HIT3; this->collider1.info.elemType = ELEMTYPE_UNK0; this->unk_1EE = 80; - this->unk_220 = 0.85f; - this->unk_224 = 1.2750001f; - this->unk_21C = 1.0f; + this->drawDmgEffScale = 0.85f; + this->drawDmgEffFrozenSteamScale = 1.2750001f; + this->drawDmgEffAlpha = 1.0f; this->actor.flags &= ~ACTOR_FLAG_400; Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); } void func_808FA19C(EnRr* this, GlobalContext* globalCtx) { this->unk_1EE = 0; - if (this->unk_1E0 == 10) { - this->unk_1E0 = 0; + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->collider1.base.colType = COLTYPE_HIT0; this->collider1.info.elemType = ELEMTYPE_UNK1; - this->unk_21C = 0.0f; - Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_234, 20, 2, this->actor.scale.y * 23.333334f, + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, 20, 2, this->actor.scale.y * 23.333334f, this->actor.scale.y * 20.000002f); this->actor.flags |= ACTOR_FLAG_400; } @@ -304,8 +304,8 @@ void func_808FA4F4(EnRr* this, GlobalContext* globalCtx) { this->unk_210 = 0.0f; this->unk_20C = 0x800; - if (((this->unk_1E2 == 0) && (gSaveContext.playerForm == PLAYER_FORM_HUMAN)) && - (CUR_EQUIP_VALUE_VOID(EQUIP_SHIELD) == EQUIP_SHIELD)) { + if (((this->unk_1E2 == 0) && (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN)) && + (GET_CUR_EQUIP_VALUE(EQUIP_SHIELD) == 1)) { sp34 = true; this->unk_1E2 = Inventory_DeleteEquipment(globalCtx, 1); } else { @@ -456,7 +456,8 @@ s32 func_808FAA94(EnRr* this, GlobalContext* globalCtx) { this->collider1.base.acFlags &= ~AC_HIT; this->collider2.base.acFlags &= ~AC_HIT; - if ((this->unk_1E0 == 10) && (sp2C->info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { + if ((this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) && + (sp2C->info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { return false; } @@ -672,7 +673,7 @@ void func_808FB398(EnRr* this, GlobalContext* globalCtx) { return; } - if (this->unk_1E0 == 30) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL) { if (this->unk_1EC & 2) { phi_v1 = 1000; } else { @@ -854,12 +855,12 @@ void EnRr_Update(Actor* thisx, GlobalContext* globalCtx) { Math_StepToF(&this->unk_210, 1.0f, 0.2f); } - if (this->unk_21C > 0.0f) { - if (this->unk_1E0 != 10) { - Math_StepToF(&this->unk_21C, 0.0f, 0.05f); - this->unk_220 = (this->unk_21C + 1.0f) * 0.425f; - this->unk_220 = CLAMP_MAX(this->unk_220, 0.85f); - } else if (!Math_StepToF(&this->unk_224, 0.85f, 0.02125f)) { + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.425f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 0.85f); + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.85f, 0.02125f)) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } @@ -890,7 +891,7 @@ void EnRr_Draw(Actor* thisx, GlobalContext* globalCtx2) { Matrix_Scale((1.0f + this->unk_324[0].unk_10) * this->unk_324[0].unk_08, 1.0f, (1.0f + this->unk_324[0].unk_10) * this->unk_324[0].unk_08, MTXMODE_APPLY); - vecPtr = &this->unk_234[0]; + vecPtr = &this->limbPos[0]; gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -932,8 +933,9 @@ void EnRr_Draw(Actor* thisx, GlobalContext* globalCtx2) { gSPDisplayList(POLY_OPA_DISP++, object_rr_DL_000470); - func_800BE680(globalCtx, &this->actor, this->unk_234, ARRAY_COUNT(this->unk_234), - this->actor.scale.y * 66.66667f * this->unk_220, this->unk_224, this->unk_21C, this->unk_1E0); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + this->actor.scale.y * 66.66667f * this->drawDmgEffScale, this->drawDmgEffFrozenSteamScale, + this->drawDmgEffAlpha, this->drawDmgEffType); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Rr/z_en_rr.h b/src/overlays/actors/ovl_En_Rr/z_en_rr.h index 0361074776..e2c935b47a 100644 --- a/src/overlays/actors/ovl_En_Rr/z_en_rr.h +++ b/src/overlays/actors/ovl_En_Rr/z_en_rr.h @@ -31,7 +31,7 @@ typedef struct EnRr { /* 0x144 */ EnRrActionFunc actionFunc; /* 0x148 */ ColliderCylinder collider1; /* 0x194 */ ColliderCylinder collider2; - /* 0x1E0 */ u8 unk_1E0; + /* 0x1E0 */ u8 drawDmgEffType; /* 0x1E1 */ u8 unk_1E1; /* 0x1E2 */ u8 unk_1E2; /* 0x1E4 */ s16 unk_1E4; @@ -54,11 +54,11 @@ typedef struct EnRr { /* 0x210 */ f32 unk_210; /* 0x214 */ f32 unk_214; /* 0x218 */ f32 unk_218; - /* 0x21C */ f32 unk_21C; - /* 0x220 */ f32 unk_220; - /* 0x224 */ f32 unk_224; + /* 0x21C */ f32 drawDmgEffAlpha; + /* 0x220 */ f32 drawDmgEffScale; + /* 0x224 */ f32 drawDmgEffFrozenSteamScale; /* 0x228 */ Vec3f unk_228; - /* 0x234 */ Vec3f unk_234[20]; + /* 0x234 */ Vec3f limbPos[20]; /* 0x324 */ EnRrStruct unk_324[5]; } EnRr; // size = 0x3C4 diff --git a/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.c b/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.c index 7cfefa59cc..2b4026858a 100644 --- a/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.c +++ b/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.c @@ -225,7 +225,7 @@ void EnRuppecrow_ShatterIce(EnRuppecrow* this, GlobalContext* globalCtx) { if (this->currentEffect == ENRUPPECROW_EFFECT_ICE) { this->currentEffect = ENRUPPECROW_EFFECT_NONE; this->unk_2C8 = 0.0f; - Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, ENRUPPECROW_LIMB_POS_COUNT, 0x2, 0.2f, 0.2f); + Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), 0x2, 0.2f, 0.2f); } } @@ -440,7 +440,7 @@ void EnRuppecrow_HandleDeath(EnRuppecrow* this) { this->actor.speedXZ *= Math_CosS(this->actor.world.rot.x); this->actor.velocity.y = 0.0f; - Animation_Change(&this->skelAnime, &object_crow_Anim_0000F0, 0.4f, 0.0f, 0.0f, 0x1, -3.0f); + Animation_Change(&this->skelAnime, &gGuayFlyAnim, 0.4f, 0.0f, 0.0f, 0x1, -3.0f); this->actor.shape.yOffset = 0.0f; this->actor.targetArrowOffset = 0.0f; @@ -627,8 +627,8 @@ void EnRuppecrow_Init(Actor* thisx, GlobalContext* globalCtx2) { EnRuppecrow* this = THIS; Actor_ProcessInitChain(&this->actor, sInitChain); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_crow_Skel_0010C0, &object_crow_Anim_0000F0, this->joinTable, - this->morphTable, ENRUPPECROW_LIMB_COUNT); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGuaySkel, &gGuayFlyAnim, this->joinTable, this->morphTable, + OBJECT_CROW_LIMB_MAX); ActorShape_Init(&this->actor.shape, 2000.0f, ActorShadow_DrawCircle, 20.0f); Collider_InitJntSph(globalCtx, &this->collider); @@ -639,7 +639,7 @@ void EnRuppecrow_Init(Actor* thisx, GlobalContext* globalCtx2) { Actor_SetScale(&this->actor, 0.01f); this->actor.flags |= ACTOR_FLAG_2000000; - this->path = func_8013D648(globalCtx, ENRUPPECROW_GET_PATH(&this->actor), 0x3F); + this->path = SubS_GetPathByIndex(globalCtx, ENRUPPECROW_GET_PATH(&this->actor), 0x3F); if (this->path != NULL) { this->actionFunc = EnRuppecrow_HandleSong; } else { diff --git a/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.h b/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.h index 4c9cafa675..de9fceac91 100644 --- a/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.h +++ b/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.h @@ -2,11 +2,11 @@ #define Z_EN_RUPPECROW_H #include "global.h" +#include "objects/object_crow/object_crow.h" #define ENRUPPECROW_GET_PATH(thisx) (((thisx)->params & 0xFC00) >> 0xA) #define ENRUPPECROW_RUPEE_COUNT 20 -#define ENRUPPECROW_LIMB_COUNT 9 #define ENRUPPECROW_LIMB_POS_COUNT 4 struct EnRuppecrow; @@ -19,8 +19,8 @@ typedef struct EnRuppecrow { /* 0x194 */ SkelAnime skelAnime; /* 0x1D8 */ EnRuppecrowActionFunc actionFunc; /* 0x1DC */ UNK_TYPE4 unk_1DC; // unused - /* 0x1E0 */ Vec3s joinTable[ENRUPPECROW_LIMB_COUNT]; - /* 0x216 */ Vec3s morphTable[ENRUPPECROW_LIMB_COUNT]; + /* 0x1E0 */ Vec3s joinTable[OBJECT_CROW_LIMB_MAX]; + /* 0x216 */ Vec3s morphTable[OBJECT_CROW_LIMB_MAX]; /* 0x24C */ Path* path; /* 0x250 */ s32 currentPoint; /* 0x254 */ ColliderJntSph collider; diff --git a/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c b/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c index 0eabcd80f7..dc7715fa07 100644 --- a/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c +++ b/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c @@ -90,7 +90,7 @@ static AnimationInfoS sAnimations[] = { { &object_dnt_Anim_002670, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, }; -Gfx* D_80BCCCDC[] = { gameplay_keep_DL_0527F0, gameplay_keep_DL_0528B0 }; +Gfx* D_80BCCCDC[] = { gKakeraLeafMiddle, gKakeraLeafTip }; Vec3f D_80BCCCE4 = { 0.0f, -0.5f, 0.0f }; @@ -170,7 +170,7 @@ void func_80BCAE78(EnScopenuts* this, GlobalContext* globalCtx) { s16 func_80BCAF0C(EnScopenuts* this) { switch (this->unk_33C) { case 0x0: - if (gSaveContext.weekEventReg[53] & 2) { + if (gSaveContext.save.weekEventReg[53] & 2) { this->unk_328 |= 1; return 0x1638; } @@ -239,7 +239,7 @@ void func_80BCB1C8(EnScopenuts* this, GlobalContext* globalCtx) { this->unk_350 *= 0.92f; Actor_SetScale(&this->actor, this->unk_350); if (this->actor.bgCheckFlags & 1) { - gSaveContext.weekEventReg[52] |= 0x40; + gSaveContext.save.weekEventReg[52] |= 0x40; Actor_MarkForDeath(&this->actor); } } @@ -315,7 +315,7 @@ void func_80BCB6D0(EnScopenuts* this, GlobalContext* globalCtx) { u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); if (temp_v0 == 5) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (this->unk_328 & 1) { this->unk_328 &= ~1; globalCtx->msgCtx.msgMode = 0x43; @@ -331,10 +331,10 @@ void func_80BCB6D0(EnScopenuts* this, GlobalContext* globalCtx) { } } } else if (temp_v0 == 4) { - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx) != 0) { switch (globalCtx->msgCtx.choiceIndex) { case 0: - if (gSaveContext.rupees < this->unk_358) { + if (gSaveContext.save.playerData.rupees < this->unk_358) { play_sound(NA_SE_SY_ERROR); this->unk_33C = 0x1636; this->unk_328 |= 1; @@ -368,7 +368,7 @@ void func_80BCB6D0(EnScopenuts* this, GlobalContext* globalCtx) { void func_80BCB90C(EnScopenuts* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { this->actor.parent = NULL; - gSaveContext.weekEventReg[53] |= 2; + gSaveContext.save.weekEventReg[53] |= 2; this->actionFunc = func_80BCB6D0; } else { Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 300.0f, 300.0f); @@ -594,7 +594,7 @@ void func_80BCBFFC(EnScopenuts* this, GlobalContext* globalCtx) { if (sp32 == 3) { if (this->unk_334 >= (this->path->count - 1)) { ActorCutscene_Stop(this->unk_338); - gSaveContext.weekEventReg[52] &= (u8)~0x40; + gSaveContext.save.weekEventReg[52] &= (u8)~0x40; this->actionFunc = func_80BCC288; } else { this->unk_334++; @@ -684,7 +684,8 @@ void EnScopenuts_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnScopenuts* this = THIS; - if (!(gSaveContext.weekEventReg[74] & 0x40) && (gSaveContext.inventory.items[ITEM_OCARINA] == ITEM_NONE)) { + if (!(gSaveContext.save.weekEventReg[74] & 0x40) && + (gSaveContext.save.inventory.items[ITEM_OCARINA] == ITEM_NONE)) { Actor_MarkForDeath(&this->actor); return; } @@ -704,10 +705,10 @@ void EnScopenuts_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.speedXZ = 0.0f; if (ENSCOPENUTS_GET_3E0(&this->actor) == ENSCOPENUTS_3E0_0) { - if (gSaveContext.weekEventReg[52] & 0x40) { + if (gSaveContext.save.weekEventReg[52] & 0x40) { Actor_MarkForDeath(&this->actor); } else if (globalCtx->actorCtx.unk5 & 2) { - this->path = func_8013D648(globalCtx, ENSCOPENUTS_GET_FC00(&this->actor), 0x3F); + this->path = SubS_GetPathByIndex(globalCtx, ENSCOPENUTS_GET_FC00(&this->actor), 0x3F); this->actor.draw = NULL; this->actionFunc = func_80BCAFA8; this->actor.gravity = 0.0f; @@ -715,8 +716,8 @@ void EnScopenuts_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_MarkForDeath(&this->actor); } } else if (ENSCOPENUTS_GET_3E0(&this->actor) == ENSCOPENUTS_3E0_1) { - if (gSaveContext.weekEventReg[52] & 0x40) { - this->path = func_8013D648(globalCtx, ENSCOPENUTS_GET_FC00(&this->actor), 0x3F); + if (gSaveContext.save.weekEventReg[52] & 0x40) { + this->path = SubS_GetPathByIndex(globalCtx, ENSCOPENUTS_GET_FC00(&this->actor), 0x3F); if (this->path == NULL) { Actor_MarkForDeath(&this->actor); } else { diff --git a/src/overlays/actors/ovl_En_Sda/z_en_sda.c b/src/overlays/actors/ovl_En_Sda/z_en_sda.c index 3a355b3611..0103b1d629 100644 --- a/src/overlays/actors/ovl_En_Sda/z_en_sda.c +++ b/src/overlays/actors/ovl_En_Sda/z_en_sda.c @@ -15,7 +15,11 @@ void EnSda_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnSda_Update(Actor* thisx, GlobalContext* globalCtx); void EnSda_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_8094702C(EnSda* this, u8* shadowTexture, Player* player, GlobalContext* globalCtx); +void func_80947668(u8* shadowTexture, Player* player, GlobalContext* globalCtx); + +Vec3f D_80947EA0[16]; + const ActorInit En_Sda_InitVars = { ACTOR_EN_SDA, ACTORCAT_BOSS, @@ -28,18 +32,327 @@ const ActorInit En_Sda_InitVars = { (ActorFunc)EnSda_Draw, }; -#endif +Vec3f D_80947A60 = { 0.0f, 0.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sda/EnSda_Init.s") +s16 D_80947A6C[] = { 1, 2, 3, 3, 2, 1 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sda/EnSda_Destroy.s") +s16 D_80947A78[] = { 2, 3, 4, 4, 4, 3, 2, 0 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sda/EnSda_Update.s") +s16 D_80947A88[] = { 2, 3, 4, 4, 4, 4, 3, 2 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sda/EnSda_Draw.s") +s16 D_80947A98[] = { 2, 4, 5, 5, 6, 6, 6, 6, 5, 5, 4, 2 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sda/func_809469C0.s") +s16 D_80947AB0[] = { 2, 4, 5, 6, 7, 8, 8, 8, 8, 7, 6, 5, 4, 2 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sda/func_8094702C.s") +s16 D_80947ACC[] = { 1, -1, 1, 1, 3, 4, 1, 6, 7, 2, 9, 0xA, 2, 0xC, 0xD, 0 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sda/func_80947668.s") +u8 D_80947AEC[] = { + 2, 2, 2, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 3, +}; + +s8 D_80947AFC[] = { + 2, 9, 10, 11, 12, 13, 14, 0, 15, -1, 3, 4, 5, 6, 7, 8, -1, 1, 0, 0, +}; + +Vec3f D_80947B10[] = { + { -1.0f, 2.0f, -0.2f }, { 0.0f, 2.0f, -0.5f }, { 1.0f, 2.0f, -0.2f }, { -2.0f, 1.0f, -0.5f }, + { -1.0f, 1.0f, -0.2f }, { 0.0f, 1.0f, -0.2f }, { 1.0f, 1.0f, -0.2f }, { 2.0f, 1.0f, -0.5f }, + { -2.0f, 0.0f, -0.5f }, { -1.0f, 0.0f, -0.2f }, { 0.0f, 0.0f, 0.0f }, { 1.0f, 0.0f, -0.2f }, + { 2.0f, 0.0f, -0.5f }, { -2.0f, -1.0f, -0.5f }, { -1.0f, -1.0f, -0.2f }, { 0.0f, -1.0f, -0.1f }, + { 1.0f, -1.0f, -0.2f }, { 2.0f, -1.0f, -0.5f }, { -1.0f, -2.0f, -0.2f }, { 0.0f, -2.0f, -0.2f }, + { 1.0f, -2.0f, -0.2f }, { 0.0f, -3.0f, -0.5f }, { -1.0f, 2.0f, -0.2f }, { 0.0f, 2.0f, -0.5f }, + { 1.0f, 2.0f, -0.2f }, { -2.0f, 1.0f, -0.5f }, { -1.0f, 1.0f, -0.2f }, { 0.0f, 1.0f, -0.2f }, + { 1.0f, 1.0f, -0.2f }, { 2.0f, 1.0f, -0.5f }, { -2.0f, 0.0f, -0.5f }, { -1.0f, 0.0f, -0.2f }, + { 0.0f, 0.0f, 0.0f }, { 1.0f, 0.0f, -0.2f }, { 2.0f, 0.0f, -0.5f }, { -2.0f, -1.0f, -0.5f }, + { -1.0f, -1.0f, -0.2f }, { 0.0f, -1.0f, -0.1f }, { 1.0f, -1.0f, -0.2f }, { 2.0f, -1.0f, -0.5f }, + { -1.0f, -2.0f, -0.2f }, { 0.0f, -2.0f, -0.2f }, { 1.0f, -2.0f, -0.2f }, { 0.0f, -3.0f, -0.5f }, +}; + +static s32 sPad[2] = { 0, 0 }; + +#include "overlays/ovl_En_Sda/ovl_En_Sda.c" + +void EnSda_Init(Actor* thisx, GlobalContext* globalCtx) { +} + +void EnSda_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void EnSda_Update(Actor* thisx, GlobalContext* globalCtx) { + EnSda* this = THIS; + Player* player; + + if (this->actor.params == ENSDA_1) { + player = (Player*)this->actor.parent; + } else { + player = GET_PLAYER(globalCtx); + } + this->actor.world.pos = player->actor.world.pos; +} + +void EnSda_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnSda* this = THIS; + Player* player; + u8* shadowTexture = GRAPH_ALLOC(globalCtx->state.gfxCtx, 64 * 64); + + if (this->actor.params == ENSDA_1) { + player = (Player*)this->actor.parent; + } else { + player = GET_PLAYER(globalCtx); + } + + player->actor.shape.shadowAlpha = 0; + func_8094702C(this, shadowTexture, player, globalCtx); + + if (KREG(0) < 5) { + func_80947668(shadowTexture, player, globalCtx); + } +} + +void func_809469C0(Player* player, u8* shadowTexture, f32 arg2) { + s16 temp_t0; + s16 temp_t1; + s16 temp_v1; + s16 temp_v0; + s16 phi_a0; + s16 phi_a3; + s16 i; + s16 j; + Vec3f lerp; + Vec3f sp88; + Vec3f sp7C; + + for (i = 0; i < 16; i++) { + if ((arg2 == 0.0f) || ((j = D_80947ACC[i]) >= 0)) { + if (arg2 > 0.0f) { + lerp.x = D_80947EA0[i].x + (D_80947EA0[j].x - D_80947EA0[i].x) * arg2; + lerp.y = D_80947EA0[i].y + (D_80947EA0[j].y - D_80947EA0[i].y) * arg2; + lerp.z = D_80947EA0[i].z + (D_80947EA0[j].z - D_80947EA0[i].z) * arg2; + + sp88.x = lerp.x - player->actor.world.pos.x; + sp88.y = lerp.y - player->actor.world.pos.y + BREG(48) + 76.0f + 30.0f - 105.0f + 15.0f; + sp88.z = lerp.z - player->actor.world.pos.z; + } else { + sp88.x = D_80947EA0[i].x - player->actor.world.pos.x; + sp88.y = D_80947EA0[i].y - player->actor.world.pos.y + BREG(48) + 76.0f + 30.0f - 105.0f + 15.0f; + sp88.z = D_80947EA0[i].z - player->actor.world.pos.z; + } + + Matrix_MultiplyVector3fByState(&sp88, &sp7C); + sp7C.x *= (1.0f + (BREG(49) / 100.0f)); + sp7C.y *= (1.0f + (BREG(49) / 100.0f)); + temp_t0 = sp7C.x + 32.0f; + temp_t1 = sp7C.y * 64.0f; + + if (D_80947AEC[i] == 2) { + for (j = 0, phi_a3 = -0x180; j < 12; j++, phi_a3 += 0x40) { + for (phi_a0 = -D_80947A98[j]; phi_a0 < D_80947A98[j]; phi_a0++) { + temp_v1 = temp_t0 + phi_a0; + if ((temp_v1 >= 0) && (temp_v1 < 0x40)) { + temp_v0 = temp_t1 + phi_a3; + if ((temp_v0 >= 0) && (temp_v0 < 0x1000)) { + shadowTexture[temp_v1 + temp_v0] = 255; + } + } + } + } + } else if (D_80947AEC[i] == 1) { + for (j = 0, phi_a3 = -0x100; j < 8; j++, phi_a3 += 0x40) { + for (phi_a0 = -D_80947A88[j]; phi_a0 < D_80947A88[j]; phi_a0++) { + temp_v1 = temp_t0 + phi_a0; + if ((temp_v1 >= 0) && (temp_v1 < 0x40)) { + temp_v0 = temp_t1 + phi_a3; + if ((temp_v0 >= 0) && (temp_v0 < 0x1000)) { + shadowTexture[temp_v1 + temp_v0] = 255; + } + } + } + } + } else if (D_80947AEC[i] == 0) { + for (j = 0, phi_a3 = -0xC0; j < 7; j++, phi_a3 += 0x40) { + for (phi_a0 = -D_80947A78[j]; phi_a0 < D_80947A78[j] - 1; phi_a0++) { + temp_v1 = temp_t0 + phi_a0; + if ((temp_v1 >= 0) && (temp_v1 < 0x40)) { + temp_v0 = temp_t1 + phi_a3; + if ((temp_v0 >= 0) && (temp_v0 < 0x1000)) { + shadowTexture[temp_v1 + temp_v0] = 255; + } + } + } + } + } else if (D_80947AEC[i] == 4) { + for (j = 0, phi_a3 = -0x1C0; j < 14; j++, phi_a3 += 0x40) { + for (phi_a0 = -D_80947AB0[j]; phi_a0 < D_80947AB0[j]; phi_a0++) { + temp_v1 = temp_t0 + phi_a0; + if ((temp_v1 >= 0) && (temp_v1 < 0x40)) { + temp_v0 = temp_t1 + phi_a3; + if ((temp_v0 >= 0) && (temp_v0 < 0x1000)) { + shadowTexture[temp_v1 + temp_v0] = 255; + } + } + } + } + } else { + for (j = 0, phi_a3 = -0x80; j < 6; j++, phi_a3 += 0x40) { + for (phi_a0 = -D_80947A6C[j]; phi_a0 < D_80947A6C[j] - 1; phi_a0++) { + temp_v1 = temp_t0 + phi_a0; + if ((temp_v1 >= 0) && (temp_v1 < 0x40)) { + temp_v0 = temp_t1 + phi_a3; + if ((temp_v0 >= 0) && (temp_v0 < 0x1000)) { + shadowTexture[temp_v1 + temp_v0] = 255; + } + } + } + } + } + } + } +} + +void func_8094702C(EnSda* this, u8* shadowTexture, Player* player, GlobalContext* globalCtx) { + s16 temp_t0; + s16 temp_t1; + s16 temp_v0; + s16 temp_v1; + s16 phi_a0; + s16 phi_a3; + s16 i; + s16 j; + Vec3f sp194; + Vec3f sp188; + s32* shadowTextureTemp32; + u8* shadowTextureTemp; + Vec3s sp178; + Vec3f sp16C; + Vec3f sp64[22]; + + if (BREG(57) != 0) { + for (shadowTextureTemp = shadowTexture, i = 0; i < 0x1000; i++, shadowTextureTemp++) { + if ((i >= 0 && i < 0x40) || (i >= 0xFC0 && i < 0x1000) || ((i & 0x3F) == 0) || ((i & 0x3F) == 0x3F)) { + *shadowTextureTemp = 255; + } else { + *shadowTextureTemp = 0; + } + } + } else { + for (shadowTextureTemp32 = (s32*)shadowTexture, i = 0; i < 0x400; i++, shadowTextureTemp32++) { + *shadowTextureTemp32 = 0; + } + } + + Matrix_SetStateXRotation((BREG(50) + 70) / 100.0f); + + for (i = 0; i < 18; i++) { + if (D_80947AFC[i] >= 0) { + D_80947EA0[D_80947AFC[i]] = player->bodyPartsPos[i]; + } + } + + D_80947EA0[0].y += 3.0f; + D_80947EA0[15].x = D_80947EA0[0].x + ((D_80947EA0[15].x - D_80947EA0[0].x) * 1.2f); + D_80947EA0[15].y = D_80947EA0[0].y + ((D_80947EA0[15].y - D_80947EA0[0].y) * -1.2f); + D_80947EA0[15].z = D_80947EA0[0].z + ((D_80947EA0[15].z - D_80947EA0[0].z) * 1.2f); + + for (i = 0; i < 6; i++) { + func_809469C0(player, shadowTexture, i / 5.0f); + } + + if (this->actor.params != ENSDA_1) { + func_8018219C(&player->shieldMf, &sp178, false); + + sp178.y += (KREG(87) * 0x8000) + 0x8000; + sp178.x *= (KREG(88) - 1); + + Matrix_InsertMatrix(&player->shieldMf, MTXMODE_NEW); + Matrix_MultiplyVector3fByState(&D_80947A60, &sp16C); + Matrix_RotateY(sp178.y, MTXMODE_NEW); + Matrix_InsertXRotation_s(sp178.x, MTXMODE_APPLY); + + for (i = 0; i < 22; i++) { + Matrix_MultiplyVector3fByState(&D_80947B10[i], &sp188); + sp64[i].x = (((KREG(82) / 100.0f) + 4.0f) * sp188.x) + sp16C.x; + sp64[i].y = (((KREG(82) / 100.0f) + 4.0f) * sp188.y) + sp16C.y; + sp64[i].z = (((KREG(82) / 100.0f) + 4.0f) * sp188.z) + sp16C.z; + } + + Matrix_SetStateXRotation((BREG(50) + 70) / 100.0f); + + for (i = 0; i < 22; i++) { + sp194.x = sp64[i].x - player->actor.world.pos.x; + sp194.y = sp64[i].y - player->actor.world.pos.y + KREG(80) + 16.0f; + sp194.z = sp64[i].z - player->actor.world.pos.z; + + Matrix_MultiplyVector3fByState(&sp194, &sp188); + + sp188.x *= (1.0f + (KREG(90) / 100.0f)); + sp188.y *= (1.0f + (KREG(90) / 100.0f)); + temp_t0 = sp188.x + 32.0f; + temp_t1 = sp188.y * 64.0f; + + do { + for (j = 0, phi_a3 = -0xC0; j < 7; j++, phi_a3 += 0x40) { + for (phi_a0 = -D_80947A78[j]; phi_a0 < D_80947A78[j] - 1; phi_a0++) { + temp_v0 = temp_t0 + phi_a0; + if ((temp_v0 >= 0) && (temp_v0 < 0x40)) { + temp_v1 = temp_t1 + phi_a3; + if ((temp_v1 >= 0) && (temp_v1 < 0x1000)) { + shadowTexture[temp_v0 + temp_v1] = 255; + } + } + } + } + j++; + } while (j < 6); + } + } + + if (BREG(61) == 1) { + for (shadowTextureTemp = shadowTexture, i = 0; i < 0x1000; i++, shadowTextureTemp++) { + if (*shadowTextureTemp != 0) { + *shadowTextureTemp = -((i >> 6) * (BREG(60) + 4)) + (255 - BREG(61)); + } + } + } +} + +void func_80947668(u8* shadowTexture, Player* player, GlobalContext* globalCtx) { + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + f32 tempx; + f32 tempz; + s16 i; + + OPEN_DISPS(gfxCtx); + + func_8012C448(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x00, 0, 0, 0, (BREG(52) + 50)); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, 0); + + Matrix_InsertTranslation(player->actor.world.pos.x, player->actor.floorHeight, player->actor.world.pos.z, + MTXMODE_NEW); + Matrix_InsertYRotation_f(BREG(51) / 100.0f, MTXMODE_APPLY); + Matrix_Scale(1.0f, 1.0f, (BREG(63) / 10.0f) + 1.0f, MTXMODE_APPLY); + + tempx = (BREG(62) / 10.0f) + 2.0f; + tempz = ((player->actor.world.pos.y - player->actor.floorHeight + BREG(54)) * (BREG(55) - 5) / 10.0f) + BREG(58) - + 20.0f; + + Matrix_InsertTranslation(tempx, 0.0f, tempz, MTXMODE_APPLY); + Matrix_Scale(((BREG(56) - 250) / 1000.0f) + 0.6f, 1.0f, ((BREG(59) - 250) / 1000.0f) + 0.6f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, ovl_En_Sda_DL_1498); + gDPLoadTextureBlock(POLY_XLU_DISP++, shadowTexture, G_IM_FMT_I, G_IM_SIZ_8b, 64, 64, 0, G_TX_NOMIRROR | G_TX_CLAMP, + G_TX_NOMIRROR | G_TX_CLAMP, 6, 6, G_TX_NOLOD, G_TX_NOLOD); + gSPDisplayList(POLY_XLU_DISP++, ovl_En_Sda_DL_14B8); + + for (i = 0; i < KREG(78); i++) { + Matrix_Scale((KREG(79) / 100.0f) + 1.0f, 1.0f, (KREG(79) / 100.0f) + 1.0f, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, ovl_En_Sda_DL_14B8); + } + + CLOSE_DISPS(gfxCtx); + + if (1) {} +} diff --git a/src/overlays/actors/ovl_En_Sda/z_en_sda.h b/src/overlays/actors/ovl_En_Sda/z_en_sda.h index fff04d6010..ff17a25382 100644 --- a/src/overlays/actors/ovl_En_Sda/z_en_sda.h +++ b/src/overlays/actors/ovl_En_Sda/z_en_sda.h @@ -5,6 +5,8 @@ struct EnSda; +#define ENSDA_1 1 + typedef struct EnSda { /* 0x000 */ Actor actor; } EnSda; // size = 0x144 diff --git a/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c b/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c index a357151708..5735d1e28d 100644 --- a/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c +++ b/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c @@ -348,21 +348,21 @@ void func_80ADB544(EnSellnuts* this, GlobalContext* globalCtx) { } else { switch (this->unk_340) { case 0x60E: - gSaveContext.weekEventReg[17] |= 0x20; - gSaveContext.weekEventReg[86] |= 4; + gSaveContext.save.weekEventReg[17] |= 0x20; + gSaveContext.save.weekEventReg[86] |= 4; Message_StartTextbox(globalCtx, this->unk_340, &this->actor); this->actionFunc = func_80ADB0D8; break; case 0x628: - gSaveContext.weekEventReg[77] |= 0x40; - gSaveContext.weekEventReg[86] |= 4; + gSaveContext.save.weekEventReg[77] |= 0x40; + gSaveContext.save.weekEventReg[86] |= 4; Message_StartTextbox(globalCtx, this->unk_340, &this->actor); this->actionFunc = func_80ADB0D8; break; case 0x614: - gSaveContext.weekEventReg[17] |= 0x40; + gSaveContext.save.weekEventReg[17] |= 0x40; Message_StartTextbox(globalCtx, this->unk_340, &this->actor); this->actionFunc = func_80ADB0D8; break; @@ -384,22 +384,22 @@ void func_80ADB544(EnSellnuts* this, GlobalContext* globalCtx) { this->actor.isTargeted) { func_800B85E0(&this->actor, globalCtx, 80.0f, EXCH_ITEM_2A); if (player->transformation == PLAYER_FORM_DEKU) { - if (gSaveContext.day == 3) { + if (gSaveContext.save.day == 3) { this->unk_33A = 2; - if (gSaveContext.weekEventReg[77] & 0x40) { + if (gSaveContext.save.weekEventReg[77] & 0x40) { this->unk_340 = D_80ADD918[this->unk_33A]; } else { this->unk_340 = D_80ADD910[this->unk_33A]; } } else { this->unk_33A = 1; - if (gSaveContext.weekEventReg[17] & 0x20) { + if (gSaveContext.save.weekEventReg[17] & 0x20) { this->unk_340 = D_80ADD918[this->unk_33A]; } else { this->unk_340 = D_80ADD910[this->unk_33A]; } } - } else if (gSaveContext.weekEventReg[17] & 0x40) { + } else if (gSaveContext.save.weekEventReg[17] & 0x40) { this->unk_340 = D_80ADD918[this->unk_33A]; } else { this->unk_340 = D_80ADD910[this->unk_33A]; @@ -438,7 +438,7 @@ void func_80ADB924(EnSellnuts* this, GlobalContext* globalCtx) { func_80151938(globalCtx, this->unk_340); this->actionFunc = func_80ADB0D8; } - } else if ((msgState == 5) && func_80147624(globalCtx)) { + } else if ((msgState == 5) && Message_ShouldAdvance(globalCtx)) { if (this->unk_340 == D_80ADD910[this->unk_33A]) { this->unk_340 = D_80ADD938[this->unk_33A]; func_80151938(globalCtx, this->unk_340); @@ -468,7 +468,7 @@ void func_80ADBAB8(EnSellnuts* this, GlobalContext* globalCtx) { SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 6); } - if ((sp27 == 5) && func_80147624(globalCtx)) { + if ((sp27 == 5) && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; this->actionFunc = func_80ADBBEC; @@ -479,7 +479,7 @@ void func_80ADBAB8(EnSellnuts* this, GlobalContext* globalCtx) { void func_80ADBBEC(EnSellnuts* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { this->actor.parent = NULL; - gSaveContext.weekEventReg[17] |= 0x80; + gSaveContext.save.weekEventReg[17] |= 0x80; this->actionFunc = func_80ADBCE4; } else { Actor_PickUp(&this->actor, globalCtx, GI_DEED_LAND, 300.0f, 300.0f); @@ -497,7 +497,7 @@ void func_80ADBC60(EnSellnuts* this, GlobalContext* globalCtx) { } void func_80ADBCE4(EnSellnuts* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 6) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 6) && Message_ShouldAdvance(globalCtx)) { func_800B85E0(&this->actor, globalCtx, 400.0f, EXCH_ITEM_MINUS1); this->unk_340 = D_80ADD930[this->unk_33A]; this->actionFunc = func_80ADBC60; @@ -514,7 +514,7 @@ void func_80ADBD64(EnSellnuts* this, GlobalContext* globalCtx) { SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 0); } - if ((sp27 == 5) && func_80147624(globalCtx)) { + if ((sp27 == 5) && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; this->unk_338 &= ~2; @@ -556,7 +556,7 @@ void func_80ADBE80(EnSellnuts* this, GlobalContext* globalCtx) { } void func_80ADBFA0(EnSellnuts* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; if (this->unk_34C == 0) { @@ -719,11 +719,11 @@ void func_80ADC5A4(EnSellnuts* this, GlobalContext* globalCtx) { void func_80ADC6D0(EnSellnuts* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; if (player->transformation == PLAYER_FORM_DEKU) { - if (gSaveContext.day == 3) { + if (gSaveContext.save.day == 3) { this->unk_33A = 2; } else { this->unk_33A = 1; @@ -749,7 +749,7 @@ void func_80ADC7B4(EnSellnuts* this, GlobalContext* globalCtx) { } ActorCutscene_SetIntentToPlay(this->cutscene); } - } else if ((this->unk_366 == 1) && (temp == 5) && func_80147624(globalCtx)) { + } else if ((this->unk_366 == 1) && (temp == 5) && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; this->unk_366 = 0; @@ -835,7 +835,7 @@ void func_80ADCA64(EnSellnuts* this, GlobalContext* globalCtx) { SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 17); } else if (this->unk_34C == 17) { ActorCutscene_Stop(this->cutscene); - gSaveContext.weekEventReg[73] |= 4; + gSaveContext.save.weekEventReg[73] |= 4; Actor_MarkForDeath(&this->actor); } } @@ -871,7 +871,7 @@ void func_80ADCC04(EnSellnuts* this, GlobalContext* globalCtx) { void func_80ADCD3C(EnSellnuts* this, GlobalContext* globalCtx) { Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0xE38); - if (gSaveContext.weekEventReg[73] & 4) { + if (gSaveContext.save.weekEventReg[73] & 4) { this->unk_338 |= 2; this->unk_338 |= 1; this->unk_340 = 0x626; @@ -915,7 +915,7 @@ s32 func_80ADCE4C(EnSellnuts* this, Path* path, s32 arg2) { pointY = points[var + 1].z - points[var - 1].z; } - func_8017B7F8(&sp30, func_80086B30(pointX, pointY) * 10430.378f, &sp44, &sp40, &sp3C); + func_8017B7F8(&sp30, RADF_TO_BINANG(func_80086B30(pointX, pointY)), &sp44, &sp40, &sp3C); if (((this->actor.world.pos.x * sp44) + (sp40 * this->actor.world.pos.z) + sp3C) > 0.0f) { ret = true; } @@ -947,7 +947,7 @@ void EnSellnuts_Init(Actor* thisx, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 pad2; - if ((gSaveContext.weekEventReg[17] & 0x80) || (gSaveContext.weekEventReg[61] & 0x10)) { + if ((gSaveContext.save.weekEventReg[17] & 0x80) || (gSaveContext.save.weekEventReg[61] & 0x10)) { Actor_MarkForDeath(&this->actor); } @@ -957,7 +957,7 @@ void EnSellnuts_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinderType1(globalCtx, &this->collider, &this->actor, &sCylinderInit); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 35.0f); - this->path = func_8013D648(globalCtx, ENSELLNUTS_GET_FC00(&this->actor), 0x3F); + this->path = SubS_GetPathByIndex(globalCtx, ENSELLNUTS_GET_FC00(&this->actor), 0x3F); this->cutscene = this->actor.cutscene; Actor_SetScale(&this->actor, 0.01f); this->actor.colChkInfo.cylRadius = 0; @@ -969,7 +969,7 @@ void EnSellnuts_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_36C = 0.01f; this->actor.speedXZ = 0.0f; this->actor.velocity.y = 0.0f; - if (gSaveContext.weekEventReg[73] & 4) { + if (gSaveContext.save.weekEventReg[73] & 4) { if (ENSELLNUTS_GET_1(&this->actor)) { Actor_MarkForDeath(&this->actor); return; @@ -977,7 +977,7 @@ void EnSellnuts_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_338 |= 2; this->unk_338 |= 1; if (player->transformation == PLAYER_FORM_DEKU) { - if (gSaveContext.day == 3) { + if (gSaveContext.save.day == 3) { this->unk_33A = 2; } else { this->unk_33A = 1; @@ -1035,7 +1035,7 @@ void EnSellnuts_Update(Actor* thisx, GlobalContext* globalCtx) { this->unk_328++; if (player->transformation == PLAYER_FORM_DEKU) { - if (gSaveContext.day == 3) { + if (gSaveContext.save.day == 3) { this->unk_33A = 2; } else { this->unk_33A = 1; diff --git a/src/overlays/actors/ovl_En_Shn/z_en_shn.c b/src/overlays/actors/ovl_En_Shn/z_en_shn.c index 6d886fad3f..2ab16fb6a5 100644 --- a/src/overlays/actors/ovl_En_Shn/z_en_shn.c +++ b/src/overlays/actors/ovl_En_Shn/z_en_shn.c @@ -64,10 +64,10 @@ const ActorInit En_Shn_InitVars = { }; static AnimationInfoS sAnimations[] = { - { &object_shn_Anim_00D9D0, 1.0f, 0, -1, 0, 0 }, - { &object_shn_Anim_00D9D0, 1.0f, 0, -1, 0, -4 }, - { &object_shn_Anim_00E6C4, 1.0f, 0, -1, 0, 0 }, - { &object_shn_Anim_00E6C4, 1.0f, 0, -1, 0, -4 }, + { &gBurlyGuyHandsOnTableAnim, 1.0f, 0, -1, 0, 0 }, + { &gBurlyGuyHandsOnTableAnim, 1.0f, 0, -1, 0, -4 }, + { &gSwampGuideChinScratchAnim, 1.0f, 0, -1, 0, 0 }, + { &gSwampGuideChinScratchAnim, 1.0f, 0, -1, 0, -4 }, }; static s32 D_80AE7258[] = { 0, 2, 3, 8, 10, 1 }; @@ -186,8 +186,8 @@ void func_80AE6488(EnShn* this, GlobalContext* globalCtx) { this->unk_2D4 = CLAMP(this->unk_2D4, 0.0f, 80.0f); Matrix_InsertTranslation(this->unk_2D4, 0.0f, 0.0f, 1); if ((&this->actor == player->targetActor) && - ((globalCtx->msgCtx.unk11F04 < 0xFF) || (globalCtx->msgCtx.unk11F04 >= 0x201)) && (tempMsgState == 3) && - (this->msgState == 3)) { + ((globalCtx->msgCtx.currentTextId < 0xFF) || (globalCtx->msgCtx.currentTextId >= 0x201)) && + (tempMsgState == 3) && (this->msgState == 3)) { if (globalCtx->state.frames % 2 == 0) { if (this->unk_2D0 != 0.0f) { this->unk_2D0 = 0.0f; @@ -203,7 +203,7 @@ void func_80AE6488(EnShn* this, GlobalContext* globalCtx) { s32 func_80AE65F4(EnShn* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - u16 temp = globalCtx->msgCtx.unk11F04; + u16 temp = globalCtx->msgCtx.currentTextId; if (player->stateFlags1 & 0x40) { if (this->unk_1DA != temp) { @@ -220,7 +220,7 @@ s32 func_80AE65F4(EnShn* this, GlobalContext* globalCtx) { this->unk_1DA = temp; this->unk_1D8 |= 0x40; } else if (this->unk_1D8 & 0x40) { - if (!(gSaveContext.weekEventReg[23] & 8)) { + if (!(gSaveContext.save.weekEventReg[23] & 8)) { func_80AE615C(this, 3); } this->unk_1DA = 0; @@ -256,7 +256,7 @@ s32 func_80AE6704(EnShn* thisx, GlobalContext* globalCtx) { } break; case 6: - gSaveContext.weekEventReg[90] &= (u8)~0x40; + gSaveContext.save.weekEventReg[90] &= (u8)~0x40; func_800B7298(globalCtx, &this->actor, 7); globalCtx->nextEntranceIndex = 0x8460; gSaveContext.nextCutsceneIndex = 0; @@ -301,7 +301,7 @@ s32 func_80AE68F0(EnShn* this, GlobalContext* globalCtx) { SubS_UpdateFlags(&this->unk_1D8, 0, 7); this->unk_1DC = func_80AE6880(this, globalCtx); this->unk_2C6 = 0; - if (gSaveContext.weekEventReg[23] & 8) { + if (gSaveContext.save.weekEventReg[23] & 8) { this->unk_1D8 |= 8; } this->actionFunc = func_80AE6A64; @@ -313,7 +313,7 @@ s32 func_80AE68F0(EnShn* this, GlobalContext* globalCtx) { void func_80AE69E8(EnShn* this, GlobalContext* globalCtx) { Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 3, 0x2AA8); - if ((gSaveContext.weekEventReg[23] & 8) && EnShn_IsFacingPlayer(this)) { + if ((gSaveContext.save.weekEventReg[23] & 8) && EnShn_IsFacingPlayer(this)) { this->unk_1D8 |= 8; } else { this->unk_1D8 &= ~0x8; @@ -345,10 +345,10 @@ void EnShn_Init(Actor* thisx, GlobalContext* globalCtx) { EnShn* this = THIS; ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gObjectShnSkel, NULL, this->jointTable, this->morphTable, - OBJECT_SHN_LIMB_MAX); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gBurlyGuySkel, NULL, this->jointTable, this->morphTable, + BURLY_GUY_LIMB_MAX); this->unk_2E8 = -1; - if (gSaveContext.weekEventReg[23] & 8) { + if (gSaveContext.save.weekEventReg[23] & 8) { func_80AE615C(this, 0); } else { func_80AE615C(this, 2); @@ -358,7 +358,7 @@ void EnShn_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_2E0 = 0; this->unk_2D8 = 0; this->unk_1D8 = 0; - if (gSaveContext.entranceIndex != 0xA820) { + if (gSaveContext.save.entranceIndex != 0xA820) { SubS_UpdateFlags(&this->unk_1D8, 3, 7); this->unk_2BE = 0; } else { @@ -380,22 +380,22 @@ void EnShn_Update(Actor* thisx, GlobalContext* globalCtx) { func_80AE6130(this); func_80AE63A8(this, globalCtx); this->unk_2E0 = 0; - func_8013C964(&this->actor, globalCtx, 120.0f, 40.0f, 0, this->unk_1D8 & 7); + func_8013C964(&this->actor, globalCtx, 120.0f, 40.0f, EXCH_ITEM_NONE, this->unk_1D8 & 7); } s32 EnShn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnShn* this = THIS; - if (limbIndex == OBJECT_SHN_LIMB_HEAD) { + if (limbIndex == BURLY_GUY_LIMB_HEAD) { func_80AE6488(this, globalCtx); - *dList = gObjectShnSwampGuideHead; + *dList = gSwampGuideHeadDL; } return false; } Vec3f D_80AE7270 = { 1200.0f, 0.0f, 0.0f }; void EnShn_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { - if (limbIndex == OBJECT_SHN_LIMB_HEAD) { + if (limbIndex == BURLY_GUY_LIMB_HEAD) { Matrix_MultiplyVector3fByState(&D_80AE7270, &thisx->focus.pos); Math_Vec3s_Copy(&thisx->focus.rot, &thisx->world.rot); } @@ -418,7 +418,7 @@ void EnShn_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thi phi_v0 = 0; } - if (limbIndex == OBJECT_SHN_LIMB_HEAD) { + if (limbIndex == BURLY_GUY_LIMB_HEAD) { func_8013AD9C((this->unk_2BA + 0x4000), (this->unk_2BC + this->actor.shape.rot.y + 0x4000), &this->unk_1E8, &this->unk_1F4, phi_v0, phi_v1); Matrix_StatePop(); diff --git a/src/overlays/actors/ovl_En_Shn/z_en_shn.h b/src/overlays/actors/ovl_En_Shn/z_en_shn.h index bb54a88152..22e10ca329 100644 --- a/src/overlays/actors/ovl_En_Shn/z_en_shn.h +++ b/src/overlays/actors/ovl_En_Shn/z_en_shn.h @@ -20,8 +20,8 @@ typedef struct EnShn { /* 0x1E4 */ Player* shnPlayerRef; /* 0x1E8 */ Vec3f unk_1E8; /* 0x1F4 */ Vec3s unk_1F4; - /* 0x1FA */ Vec3s jointTable[OBJECT_SHN_LIMB_MAX]; - /* 0x25A */ Vec3s morphTable[OBJECT_SHN_LIMB_MAX]; + /* 0x1FA */ Vec3s jointTable[BURLY_GUY_LIMB_MAX]; + /* 0x25A */ Vec3s morphTable[BURLY_GUY_LIMB_MAX]; /* 0x2BA */ s16 unk_2BA; /* 0x2BC */ s16 unk_2BC; /* 0x2BE */ s16 unk_2BE; diff --git a/src/overlays/actors/ovl_En_Skb/z_en_skb.c b/src/overlays/actors/ovl_En_Skb/z_en_skb.c index 4984c61609..f7fca74480 100644 --- a/src/overlays/actors/ovl_En_Skb/z_en_skb.c +++ b/src/overlays/actors/ovl_En_Skb/z_en_skb.c @@ -372,7 +372,7 @@ void func_80995190(EnSkb* this, GlobalContext* globalCtx) { break; case 5: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { Message_StartTextbox(globalCtx, 0x13F7, &this->actor); if (this->unk_3DE == 2) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 11); @@ -381,7 +381,7 @@ void func_80995190(EnSkb* this, GlobalContext* globalCtx) { break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { this->actionFunc = func_80995244; } break; @@ -754,10 +754,10 @@ void func_809962D4(EnSkb* this) { } void func_8099630C(EnSkb* this, GlobalContext* globalCtx) { - if (this->unk_3D2 == 0) { - this->unk_3D2 = 0; - this->unk_230 = 0.0f; - this->unk_22C = 0.0f; + if (this->drawDmgEffTimer == 0) { + this->drawDmgEffTimer = 0; + this->drawDmgEffScale = 0.0f; + this->drawDmgEffAlpha = 0.0f; if (this->actor.colChkInfo.health != 0) { Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); @@ -766,7 +766,7 @@ void func_8099630C(EnSkb* this, GlobalContext* globalCtx) { } else { func_809961E4(this, globalCtx); } - } else if (this->unk_3D2 == 1) { + } else if (this->drawDmgEffTimer == 1) { func_80996BEC(this, globalCtx); } } @@ -776,10 +776,10 @@ void func_809963C4(EnSkb* this) { } void func_809963D8(EnSkb* this, GlobalContext* globalCtx) { - if (this->unk_3D2 == 0) { - this->unk_3D2 = 0; - this->unk_230 = 0.0f; - this->unk_22C = 0.0f; + if (this->drawDmgEffTimer == 0) { + this->drawDmgEffTimer = 0; + this->drawDmgEffScale = 0.0f; + this->drawDmgEffAlpha = 0.0f; if (this->actor.colChkInfo.health != 0) { Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); @@ -807,7 +807,7 @@ void func_809964A0(EnSkb* this, GlobalContext* globalCtx) { void func_809964DC(EnSkb* this, GlobalContext* globalCtx) { if (this->unk_3D6 == 0) { if ((this->actionFunc != func_80994E94) && (this->actionFunc != func_80996284) && - (this->actionFunc != func_809964A0) && (gSaveContext.weekEventReg[85] & 0x40)) { + (this->actionFunc != func_809964A0) && (gSaveContext.save.weekEventReg[85] & 0x40)) { this->actor.colChkInfo.health = 0; func_809961E4(this, globalCtx); } @@ -817,7 +817,7 @@ void func_809964DC(EnSkb* this, GlobalContext* globalCtx) { s32 func_80996544(Vec2f arg0, Vec2f arg1) { s32 ret; - if ((arg1.x * arg0.y) < (arg0.x * arg1.y)) { + if ((arg1.x * arg0.z) < (arg0.x * arg1.z)) { ret = 1; } else { ret = -1; @@ -840,9 +840,9 @@ s32 func_80996594(EnSkb* this, GlobalContext* globalCtx) { worldX = this->actor.world.pos.x; sp60.x = D_80997468[0].z - worldZ; - sp60.y = D_80997468[0].x - worldX; + sp60.z = D_80997468[0].x - worldX; sp58.x = D_80997468[1].z - worldZ; - sp58.y = D_80997468[1].x - worldX; + sp58.z = D_80997468[1].x - worldX; j = 1; temp_s2 = func_80996544(sp60, sp58); @@ -856,9 +856,9 @@ s32 func_80996594(EnSkb* this, GlobalContext* globalCtx) { j = 0; } sp60.x = D_80997468[i].z - worldZ; - sp60.y = D_80997468[i].x - worldX; + sp60.z = D_80997468[i].x - worldX; sp58.x = D_80997468[j].z - worldZ; - sp58.y = D_80997468[j].x - worldX; + sp58.z = D_80997468[j].x - worldX; if (func_80996544(sp60, sp58) != temp_s2) { sp54 = false; break; @@ -885,10 +885,10 @@ void func_8099672C(EnSkb* this, GlobalContext* globalCtx) { if (this->actionFunc == func_8099630C) { switch (this->actor.colChkInfo.damageEffect) { default: - if (this->unk_3D2 >= 2) { + if (this->drawDmgEffTimer > 1) { func_80996BEC(this, globalCtx); } - this->unk_3D2 = 0; + this->drawDmgEffTimer = 0; break; case 1: @@ -909,10 +909,10 @@ void func_8099672C(EnSkb* this, GlobalContext* globalCtx) { switch (this->actor.colChkInfo.damageEffect) { case 11: - this->unk_3E6 = 30; - this->unk_3D2 = 40; - this->unk_22C = 1.0f; - this->unk_230 = 0.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; + this->drawDmgEffTimer = 40; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffScale = 0.0f; Actor_SetColorFilter(&this->actor, 0, 0x78, 0, 40); func_80995E08(this); break; @@ -923,10 +923,10 @@ void func_8099672C(EnSkb* this, GlobalContext* globalCtx) { break; case 2: - this->unk_3D2 = 0x50; - this->unk_3E6 = 0; - this->unk_22C = 1.0f; - this->unk_230 = 0.0f; + this->drawDmgEffTimer = 80; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffScale = 0.0f; Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); this->unk_3D8 |= 1; func_80995F98(this); @@ -935,22 +935,22 @@ void func_8099672C(EnSkb* this, GlobalContext* globalCtx) { case 3: if (this->actor.colChkInfo.health != 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); - this->unk_3D2 = 0x50; + this->drawDmgEffTimer = 80; } else { - this->unk_3D2 = 3; + this->drawDmgEffTimer = 3; } - this->unk_3E6 = 0xB; - this->unk_22C = 1.0f; - this->unk_230 = 0.5f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_SFX; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffScale = 0.5f; Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); func_809962D4(this); break; case 4: - this->unk_3D2 = 0x28; - this->unk_3E6 = 0x14; - this->unk_22C = 1.0f; - this->unk_230 = 0.5f; + this->drawDmgEffTimer = 40; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffScale = 0.5f; Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); @@ -1015,29 +1015,29 @@ void func_80996BEC(EnSkb* this, GlobalContext* globalCtx) { SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 30, NA_SE_EV_ICE_BROKEN); for (i = 0; i < end; i++) { - yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_234[i]); + yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &this->limbPos[i]); sp84.x = Math_SinS(yaw) * 3.0f; sp84.z = Math_CosS(yaw) * 3.0f; sp84.y = (Rand_ZeroOne() * 4.0f) + 4.0f; - EffectSsEnIce_Spawn(globalCtx, &this->unk_234[i], 0.6f, &sp84, &D_80997558, &D_80997550, &D_80997554, 30); + EffectSsEnIce_Spawn(globalCtx, &this->limbPos[i], 0.6f, &sp84, &D_80997558, &D_80997550, &D_80997554, 30); } } void func_80996D68(EnSkb* this, GlobalContext* globalCtx) { - if (this->unk_3D2 > 0) { - this->unk_3D2--; + if (this->drawDmgEffTimer > 0) { + this->drawDmgEffTimer--; } if (this->actionFunc != func_8099630C) { - if (this->unk_3D2 < 20) { + if (this->drawDmgEffTimer < 20) { if (this->actionFunc == func_809963D8) { - Math_SmoothStepToF(&this->unk_230, 0.0f, 0.5f, 0.03f, 0.0f); + Math_SmoothStepToF(&this->drawDmgEffScale, 0.0f, 0.5f, 0.03f, 0.0f); } else { - Math_SmoothStepToF(&this->unk_230, 0.0f, 0.5f, 0.01f, 0.0f); + Math_SmoothStepToF(&this->drawDmgEffScale, 0.0f, 0.5f, 0.01f, 0.0f); } - this->unk_22C = this->unk_3D2 * 0.05f; + this->drawDmgEffAlpha = this->drawDmgEffTimer * 0.05f; } else { - Math_SmoothStepToF(&this->unk_230, 0.5f, 0.1f, 0.02f, 0.0f); + Math_SmoothStepToF(&this->drawDmgEffScale, 0.5f, 0.1f, 0.02f, 0.0f); } } } @@ -1108,15 +1108,15 @@ void EnSkb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve Actor_SpawnBodyParts(&this->actor, globalCtx, 1, dList); } - if (this->unk_3D2 != 0) { + if (this->drawDmgEffTimer != 0) { if ((limbIndex == 2) || (limbIndex == 4) || (limbIndex == 5) || (limbIndex == 6) || (limbIndex == 7) || (limbIndex == 8) || (limbIndex == 9) || (limbIndex == 13) || (limbIndex == 14) || (limbIndex == 15) || (limbIndex == 16) || (limbIndex == 17) || (limbIndex == 18)) { - Matrix_GetStateTranslation(&this->unk_234[this->unk_2DC]); - this->unk_2DC++; + Matrix_GetStateTranslation(&this->limbPos[this->limbCount]); + this->limbCount++; } else if ((limbIndex == 11) && !(this->unk_3D8 & 2)) { - Matrix_MultiplyVector3fByState(&D_80997564, &this->unk_234[this->unk_2DC]); - this->unk_2DC++; + Matrix_MultiplyVector3fByState(&D_80997564, &this->limbPos[this->limbCount]); + this->limbCount++; } } } @@ -1124,13 +1124,13 @@ void EnSkb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve void EnSkb_Draw(Actor* thisx, GlobalContext* globalCtx) { EnSkb* this = THIS; - this->unk_2DC = 0; + this->limbCount = 0; func_8012C28C(globalCtx->state.gfxCtx); SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnSkb_OverrideLimbDraw, EnSkb_PostLimbDraw, &this->actor); - if (this->unk_3D2 > 0) { - func_800BE680(globalCtx, &this->actor, this->unk_234, this->unk_2DC, this->unk_230, 0.5f, this->unk_22C, - this->unk_3E6); + if (this->drawDmgEffTimer > 0) { + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, this->limbCount, this->drawDmgEffScale, 0.5f, + this->drawDmgEffAlpha, this->drawDmgEffType); } if (this->unk_3D8 & 0x40) { diff --git a/src/overlays/actors/ovl_En_Skb/z_en_skb.h b/src/overlays/actors/ovl_En_Skb/z_en_skb.h index 0e31345610..fe5722e53b 100644 --- a/src/overlays/actors/ovl_En_Skb/z_en_skb.h +++ b/src/overlays/actors/ovl_En_Skb/z_en_skb.h @@ -15,14 +15,14 @@ typedef struct EnSkb { /* 0x0188 */ ColliderJntSph collider; /* 0x01A8 */ ColliderJntSphElement colliderElements[2]; /* 0x0228 */ EnSkbActionFunc actionFunc; - /* 0x022C */ f32 unk_22C; - /* 0x0230 */ f32 unk_230; - /* 0x0234 */ Vec3f unk_234[14]; - /* 0x02DC */ s32 unk_2DC; + /* 0x022C */ f32 drawDmgEffAlpha; + /* 0x0230 */ f32 drawDmgEffScale; + /* 0x0234 */ Vec3f limbPos[14]; + /* 0x02DC */ s32 limbCount; /* 0x02E0 */ Vec3s jointTable[20]; /* 0x0358 */ Vec3s morphTable[20]; /* 0x03D0 */ s16 unk_3D0; - /* 0x03D2 */ s16 unk_3D2; + /* 0x03D2 */ s16 drawDmgEffTimer; /* 0x03D4 */ s16 unk_3D4; /* 0x03D6 */ s16 unk_3D6; /* 0x03D8 */ s16 unk_3D8; @@ -33,7 +33,7 @@ typedef struct EnSkb { /* 0x03E2 */ s16 unk_3E2; /* 0x03E4 */ u8 unk_3E4; /* 0x03E5 */ u8 unk_3E5; - /* 0x03E6 */ u8 unk_3E6; + /* 0x03E6 */ u8 drawDmgEffType; } EnSkb; // size = 0x3E8 extern const ActorInit En_Skb_InitVars; diff --git a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c index ecf1f814be..fc2ba14320 100644 --- a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c +++ b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c @@ -20,13 +20,14 @@ void EnSob1_Init(Actor* thisx, GlobalContext* globalCtx); void EnSob1_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnSob1_Update(Actor* thisx, GlobalContext* globalCtx); -void EnSob1_DrawZoraShopkeeper(Actor* thisx, GlobalContext* globalCtx); -void EnSob1_DrawGoronShopkeeper(Actor* thisx, GlobalContext* globalCtx); -void EnSob1_DrawBombShopkeeper(Actor* thisx, GlobalContext* globalCtx); +void EnSob1_ZoraShopkeeper_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnSob1_GoronShopkeeper_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnSob1_BombShopkeeper_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnSob1_ZoraShopkeeper_Init(EnSob1* this, GlobalContext* globalCtx); +void EnSob1_GoronShopkeeper_Init(EnSob1* this, GlobalContext* globalCtx); +void EnSob1_BombShopkeeper_Init(EnSob1* this, GlobalContext* globalCtx); -void EnSob1_InitZoraShopkeeper(EnSob1* this, GlobalContext* globalCtx); -void EnSob1_InitGoronShopkeeper(EnSob1* this, GlobalContext* globalCtx); -void EnSob1_InitBombShopkeeper(EnSob1* this, GlobalContext* globalCtx); void EnSob1_InitShop(EnSob1* this, GlobalContext* globalCtx); void EnSob1_Idle(EnSob1* this, GlobalContext* globalCtx); void EnSob1_Walk(EnSob1* this, GlobalContext* globalCtx); @@ -52,7 +53,7 @@ void EnSob1_Blink(EnSob1* this); s32 EnSob1_TakeItemOffShelf(EnSob1* this); s32 EnSob1_ReturnItemToShelf(EnSob1* this); -s16 EnSob1_GetXZAngleAndDistanceSqToPoint(Path* path, s32 pointIdx, Vec3f* pos, f32* distSq); +s16 EnSob1_GetDistSqAndOrient(Path* path, s32 pointIdx, Vec3f* pos, f32* distSq); static AnimationInfoS sAnimationsBombShopkeeper[] = { { &object_rs_Anim_009120, 2.0f, 0, -1, ANIMMODE_LOOP, 20 }, @@ -139,10 +140,10 @@ static InitChainEntry sInitChain[] = { }; static EnSob1ActionFunc sInitFuncs[] = { - EnSob1_InitZoraShopkeeper, - EnSob1_InitGoronShopkeeper, - EnSob1_InitBombShopkeeper, - EnSob1_InitGoronShopkeeper, + EnSob1_ZoraShopkeeper_Init, + EnSob1_GoronShopkeeper_Init, + EnSob1_BombShopkeeper_Init, + EnSob1_GoronShopkeeper_Init, }; static Vec3f sPosOffset[] = { @@ -184,9 +185,9 @@ u16 EnSob1_GetTalkOption(EnSob1* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (this->shopType == BOMB_SHOP) { - if (gSaveContext.day == 1 && gSaveContext.time >= CLOCK_TIME(6, 00)) { + if (gSaveContext.save.day == 1 && gSaveContext.save.time >= CLOCK_TIME(6, 00)) { return 0x648; - } else if (gSaveContext.weekEventReg[33] & 8) { + } else if (gSaveContext.save.weekEventReg[33] & 8) { return 0x649; } else { return 0x64A; @@ -256,58 +257,58 @@ u16 EnSob1_GetWelcome(EnSob1* this, GlobalContext* globalCtx) { } else if (this->shopType == ZORA_SHOP) { switch (player->transformation) { case PLAYER_FORM_HUMAN: - if (gSaveContext.weekEventReg[57] & 0x10) { + if (gSaveContext.save.weekEventReg[57] & 0x10) { return 0x12CF; } - gSaveContext.weekEventReg[57] |= 0x10; + gSaveContext.save.weekEventReg[57] |= 0x10; return 0x12CE; case PLAYER_FORM_DEKU: - if (gSaveContext.weekEventReg[57] & 0x20) { + if (gSaveContext.save.weekEventReg[57] & 0x20) { return 0x12D1; } - gSaveContext.weekEventReg[57] |= 0x20; + gSaveContext.save.weekEventReg[57] |= 0x20; return 0x12D0; case PLAYER_FORM_GORON: - if (gSaveContext.weekEventReg[57] & 0x40) { + if (gSaveContext.save.weekEventReg[57] & 0x40) { return 0x12D3; } - gSaveContext.weekEventReg[57] |= 0x40; + gSaveContext.save.weekEventReg[57] |= 0x40; return 0x12D2; case PLAYER_FORM_ZORA: - if (gSaveContext.weekEventReg[57] & 0x80) { + if (gSaveContext.save.weekEventReg[57] & 0x80) { return 0x12D5; } - gSaveContext.weekEventReg[57] |= 0x80; + gSaveContext.save.weekEventReg[57] |= 0x80; return 0x12D4; default: return 0x12CE; } } else if (this->shopType == GORON_SHOP) { if (player->transformation != PLAYER_FORM_GORON) { - if (gSaveContext.weekEventReg[58] & 4) { + if (gSaveContext.save.weekEventReg[58] & 4) { return 0xBB9; } - gSaveContext.weekEventReg[58] |= 4; + gSaveContext.save.weekEventReg[58] |= 4; return 0xBB8; } else { - if (gSaveContext.weekEventReg[58] & 8) { + if (gSaveContext.save.weekEventReg[58] & 8) { return 0xBBB; } - gSaveContext.weekEventReg[58] |= 8; + gSaveContext.save.weekEventReg[58] |= 8; return 0xBBA; } } else if (this->shopType == GORON_SHOP_SPRING) { if (player->transformation != PLAYER_FORM_GORON) { - if (gSaveContext.weekEventReg[58] & 0x10) { + if (gSaveContext.save.weekEventReg[58] & 0x10) { return 0xBBD; } - gSaveContext.weekEventReg[58] |= 0x10; + gSaveContext.save.weekEventReg[58] |= 0x10; return 0xBBC; } else { - if (gSaveContext.weekEventReg[58] & 0x20) { + if (gSaveContext.save.weekEventReg[58] & 0x20) { return 0xBBF; } - gSaveContext.weekEventReg[58] |= 0x20; + gSaveContext.save.weekEventReg[58] |= 0x20; return 0xBBE; } } @@ -316,11 +317,11 @@ u16 EnSob1_GetWelcome(EnSob1* this, GlobalContext* globalCtx) { u16 EnSob1_GetGoodbye(EnSob1* this) { if (this->shopType == BOMB_SHOP) { - if (gSaveContext.day == 1) { + if (gSaveContext.save.day == 1) { return 0x64C; - } else if (gSaveContext.day == 2) { + } else if (gSaveContext.save.day == 2) { return 0x64D; - } else if (!gSaveContext.isNight) { + } else if (!gSaveContext.save.isNight) { return 0x64E; } else { return 0x64F; @@ -329,7 +330,7 @@ u16 EnSob1_GetGoodbye(EnSob1* this) { return 0x64C; } -void EnSob1_EndInteractionBombShop(EnSob1* this, GlobalContext* globalCtx) { +void EnSob1_BombShopkeeper_EndInteraction(EnSob1* this, GlobalContext* globalCtx) { this->drawCursor = 0; this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = false; @@ -382,7 +383,7 @@ void EnSob1_Init(Actor* thisx, GlobalContext* globalCtx) { this->shopType = ZORA_SHOP; break; case GORON_SHOP: - if (gSaveContext.weekEventReg[33] & 0x80) { + if (gSaveContext.save.weekEventReg[33] & 0x80) { this->shopType = GORON_SHOP_SPRING; } else { this->shopType = GORON_SHOP; @@ -451,7 +452,7 @@ void EnSob1_EndInteraction(GlobalContext* globalCtx, EnSob1* this) { s32 EnSob1_TestEndInteraction(EnSob1* this, GlobalContext* globalCtx, Input* input) { if (CHECK_BTN_ALL(input->press.button, BTN_B)) { if (this->shopType == BOMB_SHOP) { - EnSob1_EndInteractionBombShop(this, globalCtx); + EnSob1_BombShopkeeper_EndInteraction(this, globalCtx); } else { EnSob1_EndInteraction(globalCtx, this); } @@ -502,7 +503,7 @@ void EnSob1_SetupLookToShopkeeperFromShelf(GlobalContext* globalCtx, EnSob1* thi } void EnSob1_EndingInteraction(EnSob1* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 6 && Message_ShouldAdvance(globalCtx)) { EnSob1_EndInteraction(globalCtx, this); } } @@ -606,7 +607,7 @@ void EnSob1_Hello(EnSob1* this, GlobalContext* globalCtx) { ActorCutscene_SetIntentToPlay(this->cutscene); } } - if ((talkState == 5) && (func_80147624(globalCtx)) && + if ((talkState == 5) && (Message_ShouldAdvance(globalCtx)) && (!EnSob1_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx)))) { if (this->welcomeTextId == 0x68A) { // Welcome text when wearing Kafei's mask EnSob1_EndInteraction(globalCtx, this); @@ -625,7 +626,7 @@ s32 EnSob1_FacingShopkeeperDialogResult(EnSob1* this, GlobalContext* globalCtx) case 1: func_8019F230(); if (this->shopType == BOMB_SHOP) { - EnSob1_EndInteractionBombShop(this, globalCtx); + EnSob1_BombShopkeeper_EndInteraction(this, globalCtx); } else { EnSob1_EndInteraction(globalCtx, this); } @@ -658,7 +659,7 @@ void EnSob1_FaceShopkeeper(EnSob1* this, GlobalContext* globalCtx) { if (talkState == 4) { func_8011552C(globalCtx, 6); if (!EnSob1_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx))) { - if (!func_80147624(globalCtx) || !EnSob1_FacingShopkeeperDialogResult(this, globalCtx)) { + if (!Message_ShouldAdvance(globalCtx) || !EnSob1_FacingShopkeeperDialogResult(this, globalCtx)) { if (this->stickAccumX > 0) { cursorIdx = EnSob1_SetCursorIndexFromNeutral(this, 2); if (cursorIdx != CURSOR_INVALID) { @@ -676,7 +677,7 @@ void EnSob1_FaceShopkeeper(EnSob1* this, GlobalContext* globalCtx) { } void EnSob1_TalkingToShopkeeper(EnSob1* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { EnSob1_StartShopping(globalCtx, this); } } @@ -710,10 +711,9 @@ void EnSob1_EndWalk(EnSob1* this, GlobalContext* globalCtx) { s16 curFrame = this->skelAnime.curFrame / this->skelAnime.playSpeed; s16 animLastFrame = Animation_GetLastFrame(&object_rs_Anim_009120) / (s16)this->skelAnime.playSpeed; - Math_SmoothStepToS( - &this->actor.world.rot.y, - EnSob1_GetXZAngleAndDistanceSqToPoint(this->path, this->pathPointsIdx - 1, &this->actor.world.pos, &distSq), 4, - 1000, 1); + Math_SmoothStepToS(&this->actor.world.rot.y, + EnSob1_GetDistSqAndOrient(this->path, this->pathPointsIdx - 1, &this->actor.world.pos, &distSq), + 4, 1000, 1); this->actor.shape.rot.y = this->actor.world.rot.y; Math_ApproachF(&this->actor.speedXZ, 0.5f, 0.2f, 1.0f); if (distSq < 12.0f) { @@ -749,10 +749,9 @@ void EnSob1_Walk(EnSob1* this, GlobalContext* globalCtx) { } } if (this->path != NULL) { - Math_SmoothStepToS( - &this->actor.world.rot.y, - EnSob1_GetXZAngleAndDistanceSqToPoint(this->path, this->pathPointsIdx, &this->actor.world.pos, &distSq), 4, - 1000, 1); + Math_SmoothStepToS(&this->actor.world.rot.y, + EnSob1_GetDistSqAndOrient(this->path, this->pathPointsIdx, &this->actor.world.pos, &distSq), + 4, 1000, 1); this->actor.shape.rot.y = this->actor.world.rot.y; this->actor.speedXZ = 2.0f; if (distSq < SQ(5.0f)) { @@ -1019,7 +1018,7 @@ void EnSob1_SelectItem(EnSob1* this, GlobalContext* globalCtx) { if (EnSob1_TakeItemOffShelf(this) && talkState == 4) { func_8011552C(globalCtx, 6); - if (!EnSob1_TestCancelOption(this, globalCtx, CONTROLLER1(globalCtx)) && func_80147624(globalCtx)) { + if (!EnSob1_TestCancelOption(this, globalCtx, CONTROLLER1(globalCtx)) && Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: EnSob1_HandleCanBuyItem(globalCtx, this); @@ -1036,7 +1035,7 @@ void EnSob1_SelectItem(EnSob1* this, GlobalContext* globalCtx) { void EnSob1_CannotBuy(EnSob1* this, GlobalContext* globalCtx) { if (Message_GetState(&globalCtx->msgCtx) == 5) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { this->actionFunc = this->tmpActionFunc; func_80151938(globalCtx, this->items[this->cursorIdx]->actor.textId); } @@ -1046,7 +1045,7 @@ void EnSob1_CannotBuy(EnSob1* this, GlobalContext* globalCtx) { void EnSob1_CanBuy(EnSob1* this, GlobalContext* globalCtx) { EnGirlA* item; - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { this->shopItemSelectedTween = 0.0f; EnSob1_ResetItemPosition(this); item = this->items[this->cursorIdx]; @@ -1066,7 +1065,7 @@ void EnSob1_BuyItemWithFanfare(EnSob1* this, GlobalContext* globalCtx) { } void EnSob1_SetupItemPurchased(EnSob1* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 6 && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; EnSob1_SetupAction(this, EnSob1_ItemPurchased); @@ -1085,7 +1084,7 @@ void EnSob1_ContinueShopping(EnSob1* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); EnGirlA* item; - if ((Message_GetState(&globalCtx->msgCtx) == 5) && (func_80147624(globalCtx))) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && (Message_ShouldAdvance(globalCtx))) { EnSob1_ResetItemPosition(this); item = this->items[this->cursorIdx]; item->restockFunc(globalCtx, item); @@ -1192,10 +1191,7 @@ void EnSob1_UpdateCursorAnim(EnSob1* this) { void EnSob1_UpdateStickDirectionPromptAnim(EnSob1* this) { f32 arrowAnimTween = this->arrowAnimTween; f32 stickAnimTween = this->stickAnimTween; - - // Possbily fake temps - s32 maxColor = 255; - f32 tmp; + s32 maxColor = 255; // POSSIBLY FAKE if (this->arrowAnimState == 0) { arrowAnimTween += 0.05f; @@ -1222,34 +1218,36 @@ void EnSob1_UpdateStickDirectionPromptAnim(EnSob1* this) { stickAnimTween = 0.0f; this->stickAnimState = 0; } - - tmp = 155.0f * arrowAnimTween; - this->stickAnimTween = stickAnimTween; this->stickLeftPrompt.arrowColor.r = COL_CHAN_MIX(255, 155.0f, arrowAnimTween); this->stickLeftPrompt.arrowColor.g = COL_CHAN_MIX(maxColor, 155.0f, arrowAnimTween); - this->stickLeftPrompt.arrowColor.b = COL_CHAN_MIX(0, -100, arrowAnimTween); + this->stickLeftPrompt.arrowColor.b = COL_CHAN_MIX(0, -100.0f, arrowAnimTween); this->stickLeftPrompt.arrowColor.a = COL_CHAN_MIX(200, 50.0f, arrowAnimTween); - this->stickRightPrompt.arrowColor.r = (maxColor - ((s32)tmp)) & 0xFF; - this->stickRightPrompt.arrowColor.g = (255 - ((s32)tmp)) & 0xFF; + this->stickRightPrompt.arrowTexX = 290.0f; + + this->stickRightPrompt.arrowColor.r = COL_CHAN_MIX(maxColor, 155.0f, arrowAnimTween); + this->stickRightPrompt.arrowColor.g = COL_CHAN_MIX(255, 155.0f, arrowAnimTween); this->stickRightPrompt.arrowColor.b = COL_CHAN_MIX(0, -100.0f, arrowAnimTween); this->stickRightPrompt.arrowColor.a = COL_CHAN_MIX(200, 50.0f, arrowAnimTween); - this->stickRightPrompt.arrowTexX = 290.0f; this->stickLeftPrompt.arrowTexX = 33.0f; this->stickRightPrompt.stickTexX = 274.0f; this->stickRightPrompt.stickTexX += 8.0f * stickAnimTween; + this->stickLeftPrompt.stickTexX = 49.0f; this->stickLeftPrompt.stickTexX -= 8.0f * stickAnimTween; - this->stickLeftPrompt.arrowTexY = this->stickRightPrompt.arrowTexY = 91.0f; - this->stickLeftPrompt.stickTexY = this->stickRightPrompt.stickTexY = 95.0f; + this->stickRightPrompt.arrowTexY = 91.0f; + this->stickLeftPrompt.arrowTexY = 91.0f; + + this->stickRightPrompt.stickTexY = 95.0f; + this->stickLeftPrompt.stickTexY = 95.0f; } -s16 EnSob1_GetXZAngleAndDistanceSqToPoint(Path* path, s32 pointIdx, Vec3f* pos, f32* distSq) { +s16 EnSob1_GetDistSqAndOrient(Path* path, s32 pointIdx, Vec3f* pos, f32* distSq) { Vec3s* points; f32 diffX; f32 diffZ; @@ -1319,42 +1317,38 @@ s32 EnSob1_AreObjectsLoaded(EnSob1* this, GlobalContext* globalCtx) { return false; } -void EnSob1_InitZoraShopkeeper(EnSob1* this, GlobalContext* globalCtx) { +void EnSob1_ZoraShopkeeper_Init(EnSob1* this, GlobalContext* globalCtx) { SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gZoraSkel, NULL, this->jointTable, this->morphTable, 20); gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->objIndices[2]].segment); Animation_Change(&this->skelAnime, &object_masterzoora_Anim_00078C, 1.0f, 0.0f, Animation_GetLastFrame(&object_masterzoora_Anim_00078C), 0, 0.0f); - this->actor.draw = EnSob1_DrawZoraShopkeeper; + this->actor.draw = EnSob1_ZoraShopkeeper_Draw; this->changeObjectFunc = EnSob1_ChangeObject; } -void EnSob1_InitGoronShopkeeper(EnSob1* this, GlobalContext* globalCtx) { +void EnSob1_GoronShopkeeper_Init(EnSob1* this, GlobalContext* globalCtx) { SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_oF1d_map_Skel_011AC8, NULL, this->jointTable, this->morphTable, 18); gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->objIndices[2]].segment); Animation_Change(&this->skelAnime, &object_mastergolon_Anim_0000FC, 1.0f, 0.0f, Animation_GetLastFrame(&object_mastergolon_Anim_0000FC), 0, 0.0f); - this->actor.draw = EnSob1_DrawGoronShopkeeper; + this->actor.draw = EnSob1_GoronShopkeeper_Draw; this->changeObjectFunc = EnSob1_ChangeObject; } -void EnSob1_InitBombShopkeeper(EnSob1* this, GlobalContext* globalCtx) { +void EnSob1_BombShopkeeper_Init(EnSob1* this, GlobalContext* globalCtx) { SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_rs_Skel_009220, &object_rs_Anim_009120, this->jointTable, this->morphTable, 16); - this->actor.draw = EnSob1_DrawBombShopkeeper; + this->actor.draw = EnSob1_BombShopkeeper_Draw; this->changeObjectFunc = NULL; this->skelAnime.playSpeed = 2.0f; } void EnSob1_InitShop(EnSob1* this, GlobalContext* globalCtx) { ShopItem* shopItems; - EnSob1XZRange* unkStruct; + EnSob1XZRange* xzRange; Vec3f* posOffset; - // Possibly fake temps - EnSob1* this2; - u32 maxColor = 255; - if (EnSob1_AreObjectsLoaded(this, globalCtx)) { this->actor.flags &= ~ACTOR_FLAG_10; this->actor.objBankIndex = this->objIndices[0]; @@ -1364,7 +1358,7 @@ void EnSob1_InitShop(EnSob1* this, GlobalContext* globalCtx) { this->actor.world.pos.y += posOffset->y; this->actor.world.pos.z += posOffset->z; shopItems = sShops[this->shopType]; - if ((this->shopType == BOMB_SHOP) && (gSaveContext.weekEventReg[33] & 8)) { + if ((this->shopType == BOMB_SHOP) && (gSaveContext.save.weekEventReg[33] & 8)) { sShops[this->shopType][0].shopItemId = SI_BOMB_BAG_30_2; } @@ -1379,7 +1373,7 @@ void EnSob1_InitShop(EnSob1* this, GlobalContext* globalCtx) { this->pathPointsIdx = 0; if (this->shopType == BOMB_SHOP) { - this->path = func_8013D648(globalCtx, ENSOB1_GET_PATH(&this->actor), 0x1F); + this->path = SubS_GetPathByIndex(globalCtx, ENSOB1_GET_PATH(&this->actor), 0x1F); } if (this->shopType == BOMB_SHOP) { EnSob1_SetupAction(this, EnSob1_SetupWalk); @@ -1387,65 +1381,63 @@ void EnSob1_InitShop(EnSob1* this, GlobalContext* globalCtx) { EnSob1_SetupAction(this, EnSob1_Idle); } - this->cursorPos.y = (this->cursorPos.x = 100.0f); - this->stickAccumX = (this->stickAccumY = 0); + this->cursorPos.y = this->cursorPos.x = 100.0f; + this->stickAccumY = 0; + this->stickAccumX = 0; + this->cursorIdx = 0; this->cursorPos.z = 1.2f; this->cursorColor.r = 0; this->cursorColor.g = 80; - this->cursorColor.b = maxColor; - this->cursorColor.a = maxColor; + this->cursorColor.b = 255; + this->cursorColor.a = 255; this->cursorAnimTween = 0.0f; this->cursorAnimState = 0; this->drawCursor = 0; - this2 = this; + this->stickLeftPrompt.stickColor.r = 200; + this->stickLeftPrompt.stickColor.g = 200; + this->stickLeftPrompt.stickColor.b = 200; + this->stickLeftPrompt.stickColor.a = 180; + this->stickLeftPrompt.stickTexX = 49.0f; + this->stickLeftPrompt.stickTexY = 95.0f; + this->stickLeftPrompt.arrowColor.r = 255; + this->stickLeftPrompt.arrowColor.g = 255; + this->stickLeftPrompt.arrowColor.b = 0; + this->stickLeftPrompt.arrowColor.a = 200; + this->stickLeftPrompt.arrowTexX = 33.0f; + this->stickLeftPrompt.arrowTexY = 91.0f; + this->stickLeftPrompt.texZ = 1.0f; + this->stickLeftPrompt.isEnabled = false; - this2->stickLeftPrompt.stickColor.r = 200; - this2->stickLeftPrompt.stickColor.g = 200; - this2->stickLeftPrompt.stickColor.b = 200; - this2->stickLeftPrompt.stickColor.a = 180; - this2->stickLeftPrompt.stickTexX = 49.0f; - this2->stickLeftPrompt.stickTexY = 95.0f; - this2->stickLeftPrompt.arrowColor.r = maxColor; - this2->stickLeftPrompt.arrowColor.g = maxColor; - this2->stickLeftPrompt.arrowColor.b = 0; - this2->stickLeftPrompt.arrowColor.a = 200; - this2->stickLeftPrompt.arrowTexX = 33.0f; - this2->stickLeftPrompt.arrowTexY = 91.0f; - this2->stickLeftPrompt.texZ = 1.0f; - this2->stickLeftPrompt.isEnabled = 0; + this->stickRightPrompt.stickColor.r = 200; + this->stickRightPrompt.stickColor.g = 200; + this->stickRightPrompt.stickColor.b = 200; + this->stickRightPrompt.stickColor.a = 180; + this->stickRightPrompt.stickTexX = 274.0f; + this->stickRightPrompt.stickTexY = 95.0f; + this->stickRightPrompt.arrowColor.r = 255; + this->stickRightPrompt.arrowColor.g = 0; + this->stickRightPrompt.arrowColor.b = 0; + this->stickRightPrompt.arrowColor.a = 200; + this->stickRightPrompt.arrowTexX = 290.0f; + this->stickRightPrompt.arrowTexY = 91.0f; + this->stickRightPrompt.texZ = 1.0f; + this->stickRightPrompt.isEnabled = false; - if (1) {} + this->arrowAnimState = 0; + this->stickAnimState = 0; + this->arrowAnimTween = 0.0f; + this->stickAnimTween = 0.0f; + this->shopItemSelectedTween = 0.0f; - this2->stickRightPrompt.stickColor.r = 200; - this2->stickRightPrompt.stickColor.g = 200; - this2->stickRightPrompt.stickColor.b = 200; - this2->stickRightPrompt.stickColor.a = 180; - this2->stickRightPrompt.stickTexX = 274.0f; - this2->stickRightPrompt.stickTexY = 95.0f; - this2->stickRightPrompt.arrowColor.r = maxColor; - this2->stickRightPrompt.arrowColor.g = 0; - this2->stickRightPrompt.arrowColor.b = 0; - this2->stickRightPrompt.arrowColor.a = 200; - this2->stickRightPrompt.arrowTexX = 290.0f; - this2->stickRightPrompt.arrowTexY = 91.0f; - this2->stickRightPrompt.texZ = 1.0f; - this2->stickRightPrompt.isEnabled = 0; - - this2->arrowAnimState = 0; - this2->stickAnimState = 0; - this2->arrowAnimTween = 0.0f; - this2->stickAnimTween = 0.0f; - this2->shopItemSelectedTween = 0.0f; - - this2->actor.gravity = 0.0f; - this2->posXZRange = sPosXZRanges[this2->shopType]; - Actor_SetScale(&this2->actor, sActorScales[this2->shopType]); - EnSob1_SpawnShopItems(this2, globalCtx, shopItems); + this->actor.gravity = 0.0f; + this->posXZRange = sPosXZRanges[this->shopType]; + Actor_SetScale(&this->actor, sActorScales[this->shopType]); + EnSob1_SpawnShopItems(this, globalCtx, shopItems); this->headRot = this->headRotTarget = 0; - this2->blinkTimer = 20; - this2->eyeTexIndex = 0; + this->blinkTimer = 20; + this->eyeTexIndex = 0; this->blinkFunc = EnSob1_WaitForBlink; this->actor.flags &= ~ACTOR_FLAG_1; } @@ -1475,7 +1467,10 @@ void EnSob1_Update(Actor* thisx, GlobalContext* globalCtx) { } void EnSob1_DrawCursor(GlobalContext* globalCtx, EnSob1* this, f32 x, f32 y, f32 z, u8 drawCursor) { - s32 ulx, uly, lrx, lry; + s32 ulx; + s32 uly; + s32 lrx; + s32 lry; f32 w; s32 dsdx; s32 pad; @@ -1485,8 +1480,8 @@ void EnSob1_DrawCursor(GlobalContext* globalCtx, EnSob1* this, f32 x, f32 y, f32 func_8012C654(globalCtx->state.gfxCtx); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, this->cursorColor.r, this->cursorColor.g, this->cursorColor.b, this->cursorColor.a); - gDPLoadTextureBlock_4b(OVERLAY_DISP++, gameplay_keep_Tex_01F740, G_IM_FMT_IA, 16, 16, 0, - G_TX_MIRROR | G_TX_WRAP, G_TX_MIRROR | G_TX_WRAP, 4, 4, G_TX_NOLOD, G_TX_NOLOD); + gDPLoadTextureBlock_4b(OVERLAY_DISP++, gSelectionCursorTex, G_IM_FMT_IA, 16, 16, 0, G_TX_MIRROR | G_TX_WRAP, + G_TX_MIRROR | G_TX_WRAP, 4, 4, G_TX_NOLOD, G_TX_NOLOD); w = 16.0f * z; ulx = (x - w) * 4.0f; uly = (y - w + -12.0f) * 4.0f; @@ -1501,11 +1496,16 @@ void EnSob1_DrawCursor(GlobalContext* globalCtx, EnSob1* this, f32 x, f32 y, f32 void EnSob1_DrawTextRec(GlobalContext* globalCtx, s32 r, s32 g, s32 b, s32 a, f32 x, f32 y, f32 z, s32 s, s32 t, f32 dx, f32 dy) { f32 unk; - s32 ulx, uly, lrx, lry; - f32 w, h; - s32 dsdx, dtdy; + s32 ulx; + s32 uly; + s32 lrx; + s32 lry; + f32 w; + f32 h; + s32 dsdx; + s32 dtdy; - ((void)"../z_en_soB1.c"); // Unreferenced + (void)"../z_en_soB1.c"; OPEN_DISPS(globalCtx->state.gfxCtx); gDPPipeSync(OVERLAY_DISP++); @@ -1531,21 +1531,15 @@ void EnSob1_DrawStickDirectionPrompt(GlobalContext* globalCtx, EnSob1* this) { s32 drawStickRightPrompt = this->stickLeftPrompt.isEnabled; s32 drawStickLeftPrompt = this->stickRightPrompt.isEnabled; - ((void)"../z_en_soB1.c"); // Unreferenced + (void)"../z_en_soB1.c"; OPEN_DISPS(globalCtx->state.gfxCtx); if (drawStickRightPrompt || drawStickLeftPrompt) { func_8012C654(globalCtx->state.gfxCtx); gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); - gDPSetTextureImage(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 1, gameplay_keep_Tex_01F8C0); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 0, 0x0000, G_TX_LOADTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPLoadSync(OVERLAY_DISP++); - gDPLoadBlock(OVERLAY_DISP++, G_TX_LOADTILE, 0, 0, 191, 1024); - gDPPipeSync(OVERLAY_DISP++); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_8b, 2, 0x0000, G_TX_RENDERTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPSetTileSize(OVERLAY_DISP++, G_TX_RENDERTILE, 0, 0, 15 * 4, 23 * 4); + gDPLoadTextureBlock(OVERLAY_DISP++, gArrowCursorTex, G_IM_FMT_IA, G_IM_SIZ_8b, 16, 24, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); if (drawStickRightPrompt) { EnSob1_DrawTextRec(globalCtx, this->stickLeftPrompt.arrowColor.r, this->stickLeftPrompt.arrowColor.g, this->stickLeftPrompt.arrowColor.b, this->stickLeftPrompt.arrowColor.a, @@ -1558,15 +1552,9 @@ void EnSob1_DrawStickDirectionPrompt(GlobalContext* globalCtx, EnSob1* this) { this->stickRightPrompt.arrowTexX, this->stickRightPrompt.arrowTexY, this->stickRightPrompt.texZ, 0, 0, 1.0f, 1.0f); } - gDPSetTextureImage(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 1, gameplay_keep_Tex_01F7C0); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 0, 0x0000, G_TX_LOADTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPLoadSync(OVERLAY_DISP++); - gDPLoadBlock(OVERLAY_DISP++, G_TX_LOADTILE, 0, 0, 127, 1024); - gDPPipeSync(OVERLAY_DISP++); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_8b, 2, 0x0000, G_TX_RENDERTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPSetTileSize(OVERLAY_DISP++, G_TX_RENDERTILE, 0, 0, 15 * 4, 15 * 4); + gDPLoadTextureBlock(OVERLAY_DISP++, gControlStickTex, G_IM_FMT_IA, G_IM_SIZ_8b, 16, 16, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); if (drawStickRightPrompt) { EnSob1_DrawTextRec(globalCtx, this->stickLeftPrompt.stickColor.r, this->stickLeftPrompt.stickColor.g, this->stickLeftPrompt.stickColor.b, this->stickLeftPrompt.stickColor.a, @@ -1583,8 +1571,8 @@ void EnSob1_DrawStickDirectionPrompt(GlobalContext* globalCtx, EnSob1* this) { CLOSE_DISPS(globalCtx->state.gfxCtx); } -s32 EnSob1_OverrideLimbDrawZoraShopkeeper(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnSob1_ZoraShopkeeper_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { EnSob1* this = THIS; if (limbIndex == 15) { @@ -1593,8 +1581,8 @@ s32 EnSob1_OverrideLimbDrawZoraShopkeeper(GlobalContext* globalCtx, s32 limbInde return false; } -s32 EnSob1_OverrideLimbDrawBombShopkeeper(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnSob1_BombShopkeeper_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { EnSob1* this = THIS; if (limbIndex == 15) { @@ -1603,7 +1591,8 @@ s32 EnSob1_OverrideLimbDrawBombShopkeeper(GlobalContext* globalCtx, s32 limbInde return false; } -void EnSob1_PostLimbDrawBombShopkeeper(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnSob1_BombShopkeeper_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, + Actor* thisx) { OPEN_DISPS(globalCtx->state.gfxCtx); if (limbIndex == 11) { gSPDisplayList(POLY_OPA_DISP++, object_rs_DL_000970); @@ -1621,7 +1610,7 @@ Gfx* EnSob1_EndDList(GraphicsContext* gfxCtx) { return dList; } -void EnSob1_DrawZoraShopkeeper(Actor* thisx, GlobalContext* globalCtx) { +void EnSob1_ZoraShopkeeper_Draw(Actor* thisx, GlobalContext* globalCtx) { static TexturePtr sZoraShopkeeperEyeTextures[] = { gZoraEyeOpenTex, gZoraEyeHalfTex, gZoraEyeClosedTex }; EnSob1* this = THIS; s32 pad; @@ -1633,7 +1622,7 @@ void EnSob1_DrawZoraShopkeeper(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(POLY_OPA_DISP++, 0x0C, EnSob1_EndDList(globalCtx->state.gfxCtx)); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sZoraShopkeeperEyeTextures[this->eyeTexIndex])); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnSob1_OverrideLimbDrawZoraShopkeeper, NULL, &this->actor); + EnSob1_ZoraShopkeeper_OverrideLimbDraw, NULL, &this->actor); for (i = 0; i < ARRAY_COUNT(this->items); i++) { this->items[i]->actor.scale.x = 0.2f; this->items[i]->actor.scale.y = 0.2f; @@ -1644,7 +1633,7 @@ void EnSob1_DrawZoraShopkeeper(Actor* thisx, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx); } -void EnSob1_DrawGoronShopkeeper(Actor* thisx, GlobalContext* globalCtx) { +void EnSob1_GoronShopkeeper_Draw(Actor* thisx, GlobalContext* globalCtx) { static TexturePtr sGoronShopkeeperEyeTextures[] = { object_oF1d_map_Tex_010438, object_oF1d_map_Tex_010C38, object_oF1d_map_Tex_011038 }; EnSob1* this = THIS; @@ -1666,7 +1655,7 @@ void EnSob1_DrawGoronShopkeeper(Actor* thisx, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx); } -void EnSob1_DrawBombShopkeeper(Actor* thisx, GlobalContext* globalCtx) { +void EnSob1_BombShopkeeper_Draw(Actor* thisx, GlobalContext* globalCtx) { EnSob1* this = THIS; s32 pad; u32 frames; @@ -1676,7 +1665,7 @@ void EnSob1_DrawBombShopkeeper(Actor* thisx, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(object_rs_Tex_005458)); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnSob1_OverrideLimbDrawBombShopkeeper, EnSob1_PostLimbDrawBombShopkeeper, &this->actor); + EnSob1_BombShopkeeper_OverrideLimbDraw, EnSob1_BombShopkeeper_PostLimbDraw, &this->actor); for (i = 0; i < ARRAY_COUNT(this->items); i++) { this->items[i]->actor.scale.x = 0.2f; this->items[i]->actor.scale.y = 0.2f; diff --git a/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c b/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c index 4c0983545e..d880c48738 100644 --- a/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c +++ b/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c @@ -683,8 +683,8 @@ void EnSsh_Wait(EnSsh* this, GlobalContext* globalCtx) { void EnSsh_Talk(EnSsh* this, GlobalContext* globalCtx) { EnSsh_Bob(this, globalCtx); - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x904: case 0x905: case 0x906: @@ -693,7 +693,7 @@ void EnSsh_Talk(EnSsh* this, GlobalContext* globalCtx) { case 0x911: case 0x912: case 0x914: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; default: @@ -707,11 +707,11 @@ void EnSsh_Talk(EnSsh* this, GlobalContext* globalCtx) { void func_809756D0(EnSsh* this, GlobalContext* globalCtx) { u16 phi_a1; - if (gSaveContext.weekEventReg[34] & 8) { + if (gSaveContext.save.weekEventReg[34] & 8) { phi_a1 = 0x914; } else { phi_a1 = 0x910; - gSaveContext.weekEventReg[34] |= 8; + gSaveContext.save.weekEventReg[34] |= 8; } Message_StartTextbox(globalCtx, phi_a1, &this->actor); } diff --git a/src/overlays/actors/ovl_En_St/z_en_st.c b/src/overlays/actors/ovl_En_St/z_en_st.c index 0bd9a6125d..a50bf92b44 100644 --- a/src/overlays/actors/ovl_En_St/z_en_st.c +++ b/src/overlays/actors/ovl_En_St/z_en_st.c @@ -274,15 +274,15 @@ s32 func_808A576C(EnSt* this) { s16 phi_s2 = (s16)((s16)(Rand_ZeroOne() * 1000.0f) % 12) * 0x1555; for (i = 0; i < ARRAY_COUNT(this->unk_31C); i++, phi_s2 += 0x1555) { - if (this->unk_18E != 10) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { this->unk_31C[i] = (Rand_ZeroOne() * 16.0f) + 8.0f; } else { this->unk_31C[i] = 80; } this->unk_334[i] = this->unk_31C[i]; - this->unk_2DC[i] = 0.90000004f; + this->drawDmgEffFrozenSteamScales[i] = 0.90000004f; - if ((this->unk_18E == 0) || (this->unk_18E == 1)) { + if ((this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FIRE) || (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_BLUE_FIRE)) { this->unk_358[i].y = ((Rand_ZeroOne() - 0.5f) * 40.0f) - 10.0f; } else { this->unk_358[i].y = ((Rand_ZeroOne() - 0.5f) * 30.0f) + 10.0f; @@ -298,29 +298,30 @@ s32 func_808A576C(EnSt* this) { s32 func_808A5988(EnSt* this, GlobalContext* globalCtx, s32 arg2) { s32 ret = false; - u8 sp53; - Vec3f sp44; - f32 sp40; + u8 drawDmgEffType; + Vec3f limbPos[1]; + f32 drawDmgEffAlpha; if (arg2 < this->unk_31A) { if (this->unk_31C[arg2] != 0) { - sp40 = (f32)this->unk_31C[arg2] / this->unk_334[arg2]; - sp53 = this->unk_18E; + drawDmgEffAlpha = (f32)this->unk_31C[arg2] / this->unk_334[arg2]; + drawDmgEffType = this->drawDmgEffType; - Math_ApproachF(&this->unk_2DC[arg2], 0.6f, 0.3f, 0.5f); - Math_Vec3f_Copy(&sp44, &this->actor.world.pos); + Math_ApproachF(&this->drawDmgEffFrozenSteamScales[arg2], 0.6f, 0.3f, 0.5f); + Math_Vec3f_Copy(&limbPos[0], &this->actor.world.pos); - sp44.x += this->unk_358[arg2].x; - sp44.y += this->unk_358[arg2].y; - sp44.z += this->unk_358[arg2].z; + limbPos[0].x += this->unk_358[arg2].x; + limbPos[0].y += this->unk_358[arg2].y; + limbPos[0].z += this->unk_358[arg2].z; - if (sp53 == 10) { + if (drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { if ((this->unk_334[arg2] - this->unk_31C[arg2]) < 20) { - sp53 = 11; + drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_SFX; } - sp40 = 1.0f; + drawDmgEffAlpha = 1.0f; } - func_800BE680(globalCtx, &this->actor, &sp44, 1, 0.6f, this->unk_2DC[arg2], sp40, sp53); + Actor_DrawDamageEffects(globalCtx, &this->actor, limbPos, ARRAY_COUNT(limbPos), 0.6f, + this->drawDmgEffFrozenSteamScales[arg2], drawDmgEffAlpha, drawDmgEffType); ret = true; } } @@ -556,7 +557,7 @@ s32 func_808A6580(EnSt* this, GlobalContext* globalCtx) { } if (this->collider3.base.acFlags & AC_HIT) { - if (this->unk_18E == 10) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { // clang-format off for (i = 0; i < ARRAY_COUNT(this->unk_31C); i++) { this->unk_31C[i] = 0; } // clang-format on @@ -579,7 +580,7 @@ s32 func_808A6580(EnSt* this, GlobalContext* globalCtx) { this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); } - if (this->unk_18E == 10) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { // clang-format off for (i = 0; i < ARRAY_COUNT(this->unk_31C); i++) { this->unk_31C[i] = 0; } // clang-format on @@ -594,7 +595,7 @@ s32 func_808A6580(EnSt* this, GlobalContext* globalCtx) { break; case 5: - this->unk_18E = 30; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; this->unk_312 = 40; func_808A576C(this); Actor_SetColorFilter(&this->actor, 0, 200, 0, this->unk_312); @@ -622,30 +623,30 @@ s32 func_808A6580(EnSt* this, GlobalContext* globalCtx) { switch (this->actor.colChkInfo.damageEffect) { case 4: - this->unk_18E = 20; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; this->unk_318 = 20; func_808A576C(this); break; case 3: - this->unk_18E = 10; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; this->unk_318 = 0; func_808A576C(this); break; case 2: - this->unk_18E = 0; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->unk_318 = 20; func_808A576C(this); break; default: - this->unk_18E = 1; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_BLUE_FIRE; this->unk_318 = 0; break; } - if (this->unk_18E != 10) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 7); this->unk_2CC = 0.0f; this->unk_2D4 = 0.0f; @@ -757,7 +758,7 @@ void func_808A6E24(EnSt* this, GlobalContext* globalCtx) { s32 i; s32 count = 0; - if (this->unk_18E == 10) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { for (i = 0; i < ARRAY_COUNT(this->unk_31C); i++) { if (DECR(this->unk_31C[i]) == 0) { count++; @@ -766,7 +767,7 @@ void func_808A6E24(EnSt* this, GlobalContext* globalCtx) { if (count == ARRAY_COUNT(this->unk_31C)) { SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 7); - this->unk_18E = 1; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_BLUE_FIRE; this->unk_2CC = 0.0f; this->unk_2D4 = 0.0f; this->actor.gravity = -1.0f; @@ -828,7 +829,7 @@ void func_808A701C(EnSt* this, GlobalContext* globalCtx) { } } else if (DECR(this->unk_318) == 0) { this->unk_18C |= 0x40; - if (this->unk_18E == 1) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_BLUE_FIRE) { func_808A576C(this); this->unk_318 = 10; } @@ -873,7 +874,7 @@ void EnSt_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc = func_808A6E24; } else if (DECR(this->unk_312) == 0) { this->actionFunc(this, globalCtx); - if (this->unk_18E != 10) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { SkelAnime_Update(&this->skelAnime); } Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 5); @@ -884,7 +885,7 @@ void EnSt_Update(Actor* thisx, GlobalContext* globalCtx) { idx += this->actor.world.rot.y; this->actor.shape.rot.y = idx; - if (this->unk_18E == 30) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL) { if (this->unk_312 == 1) { s32 i; diff --git a/src/overlays/actors/ovl_En_St/z_en_st.h b/src/overlays/actors/ovl_En_St/z_en_st.h index a82ff397b4..f3a8275157 100644 --- a/src/overlays/actors/ovl_En_St/z_en_st.h +++ b/src/overlays/actors/ovl_En_St/z_en_st.h @@ -18,7 +18,7 @@ typedef struct EnSt { /* 0x144 */ SkelAnime skelAnime; /* 0x188 */ EnStActionFunc actionFunc; /* 0x18C */ u16 unk_18C; - /* 0x18E */ u8 unk_18E; + /* 0x18E */ u8 drawDmgEffType; /* 0x190 */ ColliderCylinder collider1; /* 0x1DC */ ColliderCylinder collider2; /* 0x228 */ ColliderCylinder collider3; @@ -30,7 +30,7 @@ typedef struct EnSt { /* 0x2D0 */ f32 unk_2D0; /* 0x2D4 */ f32 unk_2D4; /* 0x2D8 */ f32 unk_2D8; - /* 0x2DC */ f32 unk_2DC[12]; + /* 0x2DC */ f32 drawDmgEffFrozenSteamScales[12]; /* 0x30C */ s16 unk_30C; /* 0x30E */ s16 unk_30E; /* 0x310 */ s16 unk_310; diff --git a/src/overlays/actors/ovl_En_Sth/z_en_sth.c b/src/overlays/actors/ovl_En_Sth/z_en_sth.c index 601e9e4f32..339a2b9a0c 100644 --- a/src/overlays/actors/ovl_En_Sth/z_en_sth.c +++ b/src/overlays/actors/ovl_En_Sth/z_en_sth.c @@ -119,13 +119,13 @@ void EnSth_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_MarkForDeath(&this->actor); } this->actor.textId = 0; - if (!(gSaveContext.weekEventReg[34] & 0x40) || !(gSaveContext.weekEventReg[34] & 8)) { + if (!(gSaveContext.save.weekEventReg[34] & 0x40) || !(gSaveContext.save.weekEventReg[34] & 8)) { this->unk_29C |= 1; } break; case ENSTH_F_3: - if ((gSaveContext.skullTokenCount & 0xFFFF) >= 30) { + if ((gSaveContext.save.skullTokenCount & 0xFFFF) >= 30) { Actor_MarkForDeath(&this->actor); return; } @@ -136,19 +136,20 @@ void EnSth_Init(Actor* thisx, GlobalContext* globalCtx) { break; case ENSTH_F_4: - if (gSaveContext.weekEventReg[13] & 0x20) { + if (gSaveContext.save.weekEventReg[13] & 0x20) { Actor_MarkForDeath(&this->actor); return; } this->actor.textId = 0; this->actionFunc = func_80B677BC; - if (gSaveContext.weekEventReg[13] & 0x80) { + if (gSaveContext.save.weekEventReg[13] & 0x80) { this->unk_29C |= 2; } break; case ENSTH_F_5: - if (!(gSaveContext.weekEventReg[13] & 0x20) || (Inventory_GetSkullTokenCount(globalCtx->sceneNum) < 30)) { + if (!(gSaveContext.save.weekEventReg[13] & 0x20) || + (Inventory_GetSkullTokenCount(globalCtx->sceneNum) < 30)) { Actor_MarkForDeath(&this->actor); return; } @@ -200,7 +201,7 @@ void func_80B67148(EnSth* this, GlobalContext* globalCtx) { void func_80B671A0(EnSth* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { this->actionFunc = func_80B67208; func_801477B4(globalCtx); } @@ -258,7 +259,7 @@ void func_80B67348(EnSth* this, GlobalContext* globalCtx) { break; case 5: - if (gSaveContext.weekEventReg[13] & 0x40) { + if (gSaveContext.save.weekEventReg[13] & 0x40) { phi_a1 = 0x113D; } else { phi_a1 = 0x113C; @@ -266,7 +267,7 @@ void func_80B67348(EnSth* this, GlobalContext* globalCtx) { break; default: - if (gSaveContext.weekEventReg[13] & 0x40) { + if (gSaveContext.save.weekEventReg[13] & 0x40) { phi_a1 = 0x1142; } else { phi_a1 = 0x1141; @@ -313,10 +314,10 @@ void func_80B67540(EnSth* this, GlobalContext* globalCtx) { switch (Message_GetState(&globalCtx->msgCtx)) { case 5: - if (func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x1134: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x1132: @@ -331,14 +332,14 @@ void func_80B67540(EnSth* this, GlobalContext* globalCtx) { break; case 0x1136: - gSaveContext.weekEventReg[13] |= 0x80; + gSaveContext.save.weekEventReg[13] |= 0x80; switch (sp2C) { case 0: - if (gSaveContext.weekEventReg[13] & 0x40) { + if (gSaveContext.save.weekEventReg[13] & 0x40) { this->actor.home.rot.z = 6; } else { - gSaveContext.weekEventReg[13] |= 0x40; + gSaveContext.save.weekEventReg[13] |= 0x40; switch (CUR_UPG_VALUE(UPG_WALLET)) { case 0: this->actor.home.rot.z = 8; @@ -403,7 +404,7 @@ void func_80B677BC(EnSth* this, GlobalContext* globalCtx) { void func_80B67838(EnSth* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { this->actionFunc = func_80B678A8; func_801477B4(globalCtx); } @@ -416,7 +417,7 @@ void func_80B678A8(EnSth* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_80B67838; } else if (func_80B6703C(this, globalCtx) || this->actor.isTargeted) { - if ((gSaveContext.time >= CLOCK_TIME(6, 0)) && (gSaveContext.time <= CLOCK_TIME(18, 0))) { + if ((gSaveContext.save.time >= CLOCK_TIME(6, 0)) && (gSaveContext.save.time <= CLOCK_TIME(18, 0))) { this->actor.textId = 0x1130; } else { this->actor.textId = 0x1131; @@ -433,14 +434,14 @@ void func_80B67958(EnSth* this, GlobalContext* globalCtx) { void func_80B67984(EnSth* this, GlobalContext* globalCtx) { u16 sp1E; - if (gSaveContext.weekEventReg[34] & 0x10) { + if (gSaveContext.save.weekEventReg[34] & 0x10) { sp1E = 0x903; func_80B670A4(this, 2); - } else if (gSaveContext.weekEventReg[34] & 0x20) { + } else if (gSaveContext.save.weekEventReg[34] & 0x20) { sp1E = 0x90F; func_80B670A4(this, 2); - } else if (gSaveContext.weekEventReg[34] & 0x40) { - if (!(gSaveContext.weekEventReg[34] & 8)) { + } else if (gSaveContext.save.weekEventReg[34] & 0x40) { + if (!(gSaveContext.save.weekEventReg[34] & 8)) { sp1E = 0x91B; } else { sp1E = 0x918; @@ -453,11 +454,11 @@ void func_80B67984(EnSth* this, GlobalContext* globalCtx) { } else { sp1E = 0x916; } - } else if (gSaveContext.weekEventReg[34] & 2) { + } else if (gSaveContext.save.weekEventReg[34] & 2) { sp1E = 0x8FF; } else { sp1E = 0x8FC; - gSaveContext.weekEventReg[34] |= 2; + gSaveContext.save.weekEventReg[34] |= 2; } Message_StartTextbox(globalCtx, sp1E, &this->actor); } @@ -467,7 +468,7 @@ void func_80B67AB4(EnSth* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_80B67C1C; - gSaveContext.weekEventReg[34] |= 0x40; + gSaveContext.save.weekEventReg[34] |= 0x40; Message_StartTextbox(globalCtx, 0x918, &this->actor); } else { func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); @@ -484,7 +485,7 @@ void func_80B67B50(EnSth* this, GlobalContext* globalCtx) { func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); } else { this->unk_29C &= ~1; - gSaveContext.weekEventReg[34] |= 8; + gSaveContext.save.weekEventReg[34] |= 8; Actor_PickUp(&this->actor, globalCtx, GI_MASK_TRUTH, 10000.0f, 50.0f); } } @@ -494,17 +495,17 @@ void func_80B67C1C(EnSth* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x90C: func_80B670A4(this, 2); - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x916: case 0x919: func_80B670A4(this, 3); - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x8FC: @@ -512,7 +513,7 @@ void func_80B67C1C(EnSth* this, GlobalContext* globalCtx) { case 0x900: case 0x90A: case 0x90D: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x901: @@ -524,8 +525,8 @@ void func_80B67C1C(EnSth* this, GlobalContext* globalCtx) { break; case 0x91A: - gSaveContext.weekEventReg[34] |= 0x40; - gSaveContext.weekEventReg[34] &= (u8)~8; + gSaveContext.save.weekEventReg[34] |= 0x40; + gSaveContext.save.weekEventReg[34] &= (u8)~8; case 0x902: case 0x903: @@ -579,8 +580,9 @@ void EnSth_Update(Actor* thisx, GlobalContext* globalCtx) { this->jointTable, this->morphTable, 16); Animation_PlayLoop(&this->skelAnime, &ovl_En_Sth_Anim_0045B4); this->unk_29A = 1; - if ((gSaveContext.weekEventReg[34] & 0x10) || (gSaveContext.weekEventReg[34] & 0x20) || - (gSaveContext.weekEventReg[34] & 0x40) || (Inventory_GetSkullTokenCount(globalCtx->sceneNum) >= 30)) { + if ((gSaveContext.save.weekEventReg[34] & 0x10) || (gSaveContext.save.weekEventReg[34] & 0x20) || + (gSaveContext.save.weekEventReg[34] & 0x40) || + (Inventory_GetSkullTokenCount(globalCtx->sceneNum) >= 30)) { func_80B670A4(this, 3); } } else { @@ -598,7 +600,7 @@ void EnSth_Update(Actor* thisx, GlobalContext* globalCtx) { break; case ENSTH_F_4: - if (gSaveContext.weekEventReg[13] & 0x80) { + if (gSaveContext.save.weekEventReg[13] & 0x80) { func_80B670A4(this, 5); } else { func_80B670A4(this, 5); diff --git a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c index 733ecb8a66..a4e6cfd419 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c @@ -124,13 +124,54 @@ static u16 D_80BAE800[] = { 4000, 4, 1, 3, 6000, 4, 1, 6, 4000, 4, 1, 3, 6000, 4, 1, 6, }; -static UNK_TYPE D_80BAE820[] = { - 0xC00027C, 0x210877, 0xA006D31, 0x2000000, 0x19250200, 0x19001E19, 0x2010F01, 0x140D0201, 0x14012D01, - 0x50E0114, 0x12D0E0E, 0x10F0114, 0x70E0019, 0x1E060E, 0x19, 0xD0A000D, 0x3D020019, 0x1E3102, - 0x1E002D, 0x2502002D, 0x1001902, 0x100010F, 0xD02010F, 0x1140105, 0xE010F01, 0x14090E01, 0x10F0B, - 0xE002D01, 0x20E00, 0x1E002D0A, 0xE001900, 0x1E080505, 0xC000125, 0xA006E20, 0x2120000, 0x14140200, - 0x14001E08, 0xF001E03, 0x4000405, 0xE001400, 0x1E0F0E12, 0x1403, 0x50C0003, 0x270A0013, 0x22021200, - 0x13001602, 0x13001319, 0xD021319, 0x105, 0xE131900, 0x10400, 0x50E1200, 0x13000C05, 0x5000000, +static u8 D_80BAE820[] = { + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(2, 0x80 - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_FLAG_S(0x21, 0x08, 0x7F - 0x08), + /* 0x08 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_ICHIBA, 0x3D - 0x0C), + /* 0x0C */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 0, 0, 25, 0x37 - 0x12), + /* 0x12 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 25, 0, 30, 0x31 - 0x18), + /* 0x18 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(1, 15, 1, 20, 0x2B - 0x1E), + /* 0x1E */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(1, 20, 1, 45, 0x25 - 0x24), + /* 0x24 */ SCHEDULE_CMD_RET_NONE(), + /* 0x25 */ SCHEDULE_CMD_RET_TIME(1, 20, 1, 45, 14), + /* 0x2B */ SCHEDULE_CMD_RET_TIME(1, 15, 1, 20, 7), + /* 0x31 */ SCHEDULE_CMD_RET_TIME(0, 25, 0, 30, 6), + /* 0x37 */ SCHEDULE_CMD_RET_TIME(0, 0, 0, 25, 13), + /* 0x3D */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_AYASHIISHOP, 0x7E - 0x41), + /* 0x41 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 25, 0, 30, 0x78 - 0x47), + /* 0x47 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 30, 0, 45, 0x72 - 0x4D), + /* 0x4D */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 45, 1, 0, 0x6C - 0x53), + /* 0x53 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(1, 0, 1, 15, 0x66 - 0x59), + /* 0x59 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(1, 15, 1, 20, 0x60 - 0x5F), + /* 0x5F */ SCHEDULE_CMD_RET_NONE(), + /* 0x60 */ SCHEDULE_CMD_RET_TIME(1, 15, 1, 20, 9), + /* 0x66 */ SCHEDULE_CMD_RET_TIME(1, 0, 1, 15, 11), + /* 0x6C */ SCHEDULE_CMD_RET_TIME(0, 45, 1, 0, 2), + /* 0x72 */ SCHEDULE_CMD_RET_TIME(0, 30, 0, 45, 10), + /* 0x78 */ SCHEDULE_CMD_RET_TIME(0, 25, 0, 30, 8), + /* 0x7E */ SCHEDULE_CMD_RET_NONE(), + /* 0x7F */ SCHEDULE_CMD_RET_NONE(), + /* 0x80 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(1, 0xA9 - 0x84), + /* 0x84 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_BACKTOWN, 0xA8 - 0x88), + /* 0x88 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(18, 0, 0, 20, 0xA2 - 0x8E), + /* 0x8E */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 20, 0, 30, 0x9C - 0x94), + /* 0x94 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(0, 30, 0x9B - 0x98), + /* 0x98 */ SCHEDULE_CMD_RET_VAL_L(4), + /* 0x9B */ SCHEDULE_CMD_RET_NONE(), + /* 0x9C */ SCHEDULE_CMD_RET_TIME(0, 20, 0, 30, 15), + /* 0xA2 */ SCHEDULE_CMD_RET_TIME(18, 0, 0, 20, 3), + /* 0xA8 */ SCHEDULE_CMD_RET_NONE(), + /* 0xA9 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(3, 0xD4 - 0xAD), + /* 0xAD */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_IKANA, 0xD3 - 0xB1), + /* 0xB1 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(18, 0, 19, 0, 0xCD - 0xB7), + /* 0xB7 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(19, 0, 19, 25, 0xCA - 0xBD), + /* 0xBD */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(19, 25, 0, 0, 0xC4 - 0xC3), + /* 0xC3 */ SCHEDULE_CMD_RET_NONE(), + /* 0xC4 */ SCHEDULE_CMD_RET_TIME(19, 25, 0, 0, 1), + /* 0xCA */ SCHEDULE_CMD_RET_VAL_L(5), + /* 0xCD */ SCHEDULE_CMD_RET_TIME(18, 0, 19, 0, 12), + /* 0xD3 */ SCHEDULE_CMD_RET_NONE(), + /* 0xD4 */ SCHEDULE_CMD_RET_NONE(), }; static s32 D_80BAE8F8[] = { @@ -186,12 +227,12 @@ void EnSuttari_SetNextEntrance(GlobalContext* globalCtx, u16 nextEntranceIndex) } void EnSuttari_UpdateTime(void) { - u32* unk_14 = &gSaveContext.unk_14; - u16 time = gSaveContext.time; + u32* unk_14 = &gSaveContext.save.daySpeed; + u16 time = gSaveContext.save.time; - gSaveContext.time = (u16)REG(15) + time; - time = gSaveContext.time; - gSaveContext.time = (u16)*unk_14 + time; + gSaveContext.save.time = (u16)REG(15) + time; + time = gSaveContext.save.time; + gSaveContext.save.time = (u16)*unk_14 + time; } s32 func_80BAA904(EnSuttari* this, GlobalContext* globalCtx) { @@ -210,7 +251,7 @@ s32 func_80BAA904(EnSuttari* this, GlobalContext* globalCtx) { void func_80BAA9B4(EnSuttari* this) { s16 curFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIdx].animation); + s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); switch (this->textId) { case 0x1454: @@ -221,15 +262,15 @@ void func_80BAA9B4(EnSuttari* this) { case 0x1459: case 0x145A: case 0x145B: - if ((this->animationIdx != 8) && (curFrame == frameCount)) { - this->animationIdx = 8; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIdx); + if ((this->animationIndex != 8) && (curFrame == frameCount)) { + this->animationIndex = 8; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); } break; default: - if ((this->animationIdx != 1) && (curFrame == frameCount)) { - this->animationIdx = 1; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIdx); + if ((this->animationIndex != 1) && (curFrame == frameCount)) { + this->animationIndex = 1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); } } } @@ -237,8 +278,8 @@ void func_80BAA9B4(EnSuttari* this) { void func_80BAAA94(EnSuttari* this) { switch (this->textId) { case 0x29E5: - this->animationIdx = 1; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIdx); + this->animationIndex = 1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); break; case 0x29E9: this->enFsn->flags |= ENFSN_ANGRY; @@ -250,12 +291,12 @@ void func_80BAAA94(EnSuttari* this) { this->enFsn->flags |= ENFSN_OFFER_FINAL_PRICE; break; case 0x29EC: - this->animationIdx = 7; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIdx); + this->animationIndex = 7; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); break; case 0x29ED: - this->animationIdx = 1; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIdx); + this->animationIndex = 1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); break; } } @@ -323,7 +364,7 @@ void func_80BAAB78(EnSuttari* this, GlobalContext* globalCtx) { } else if (this->flags1 & 1) { switch (this->textId) { case 0: - if (gSaveContext.weekEventReg[81] & 1) { + if (gSaveContext.save.weekEventReg[81] & 1) { this->textId = 0x1455; ((EnElf*)GET_PLAYER(globalCtx)->tatlActor)->unk_264 |= 8; this->flags2 |= 1; @@ -341,12 +382,12 @@ void func_80BAAB78(EnSuttari* this, GlobalContext* globalCtx) { } else { this->flags1 |= 0x400; this->textId = 0x1452; - gSaveContext.weekEventReg[81] |= 1; + gSaveContext.save.weekEventReg[81] |= 1; } break; case 0x1453: this->flags1 |= 0x400; - gSaveContext.weekEventReg[81] |= 1; + gSaveContext.save.weekEventReg[81] |= 1; ((EnElf*)GET_PLAYER(globalCtx)->tatlActor)->unk_264 |= 8; this->flags2 |= 1; this->textId = 0x1454; @@ -377,14 +418,14 @@ void func_80BAAB78(EnSuttari* this, GlobalContext* globalCtx) { void func_80BAAF1C(EnSuttari* this) { s16 curFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIdx].animation); + s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); - if (this->animationIdx == 5) { - this->animationIdx = 3; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIdx); - } else if ((this->animationIdx == 3) && (curFrame == frameCount)) { - this->animationIdx = 6; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIdx); + if (this->animationIndex == 5) { + this->animationIndex = 3; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); + } else if ((this->animationIndex == 3) && (curFrame == frameCount)) { + this->animationIndex = 6; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); this->flags1 &= ~0x100; } } @@ -414,7 +455,7 @@ void func_80BAAFDC(EnSuttari* this, GlobalContext* globalCtx) { if (this->unk1F4[0] != 0) { this->unk1F4[0]--; } - gSaveContext.weekEventReg[61] |= 8; + gSaveContext.save.weekEventReg[61] |= 8; this->unk3F6 = 20; this->actionFunc = func_80BADE8C; } @@ -446,7 +487,7 @@ void func_80BAB1A0(EnSuttari* this, GlobalContext* globalCtx) { if (this->unk1F4[0] != 0) { this->unk1F4[0]--; } - gSaveContext.weekEventReg[61] |= 8; + gSaveContext.save.weekEventReg[61] |= 8; this->unk3F6 = 20; this->actionFunc = func_80BADE8C; } else { @@ -473,8 +514,8 @@ void func_80BAB434(EnSuttari* this) { } void EnSuttari_GetPaths(EnSuttari* this, GlobalContext* globalCtx) { - this->paths[0] = func_8013D648(globalCtx, ENSUTTARI_GET_PATH(&this->actor), 0x3F); - this->paths[1] = func_8013D648(globalCtx, this->paths[0]->unk1, 0x3F); + this->paths[0] = SubS_GetPathByIndex(globalCtx, ENSUTTARI_GET_PATH(&this->actor), 0x3F); + this->paths[1] = SubS_GetPathByIndex(globalCtx, this->paths[0]->unk1, 0x3F); } void func_80BAB4F0(EnSuttari* this, GlobalContext* globalCtx) { @@ -504,28 +545,29 @@ void func_80BAB4F0(EnSuttari* this, GlobalContext* globalCtx) { SubS_FillLimbRotTables(globalCtx, this->unk2FA, this->unk31A, ARRAY_COUNT(this->unk2FA)); } -s16 func_80BAB698(Path* path, s32 idx, Vec3f* pos, f32* distSQ) { +s16 EnSuttari_GetDistSqAndOrient(Path* path, s32 index, Vec3f* pos, f32* distSq) { Vec3s* points; f32 diffX; f32 diffZ; if (path != NULL) { points = Lib_SegmentedToVirtual(path->points); - points = &points[idx]; + points = &points[index]; diffX = points->x - pos->x; diffZ = points->z - pos->z; } else { diffX = 0.0f; diffZ = 0.0f; } - *distSQ = SQ(diffX) + SQ(diffZ); - return Math_Acot2F(diffZ, diffX) * (0x8000 / M_PI); + + *distSq = SQ(diffX) + SQ(diffZ); + return RADF_TO_BINANG(Math_Acot2F(diffZ, diffX)); } s32 func_80BAB758(EnSuttari* this, Path* path, s32 arg2) { Vec3s* sp5C = Lib_SegmentedToVirtual(path->points); s32 sp58 = path->count; - s32 idx = arg2; + s32 index = arg2; s32 ret = false; f32 sp54; f32 sp48; @@ -534,16 +576,16 @@ s32 func_80BAB758(EnSuttari* this, Path* path, s32 arg2) { f32 sp3C; Vec3f sp30; - Math_Vec3s_ToVec3f(&sp30, &sp5C[idx]); - if (idx == 0) { + Math_Vec3s_ToVec3f(&sp30, &sp5C[index]); + if (index == 0) { sp54 = sp5C[1].x - sp5C[0].x; sp48 = sp5C[1].z - sp5C[0].z; - } else if (idx == sp58 - 1) { + } else if (index == sp58 - 1) { sp54 = sp5C[sp58 - 1].x - sp5C[sp58 - 2].x; sp48 = sp5C[sp58 - 1].z - sp5C[sp58 - 2].z; } else { - sp54 = sp5C[idx + 1].x - sp5C[idx - 1].x; - sp48 = sp5C[idx + 1].z - sp5C[idx - 1].z; + sp54 = sp5C[index + 1].x - sp5C[index - 1].x; + sp48 = sp5C[index + 1].z - sp5C[index - 1].z; } func_8017B7F8(&sp30, RADF_TO_BINANG(func_80086B30(sp54, sp48)), &sp44, &sp40, &sp3C); if (((sp44 * this->actor.world.pos.x) + (sp40 * this->actor.world.pos.z) + sp3C) > 0.0f) { @@ -554,29 +596,26 @@ s32 func_80BAB758(EnSuttari* this, Path* path, s32 arg2) { s32 func_80BAB8F4(EnSuttari* this, Path* path, s32 arg2) { Vec3s* sp5C = Lib_SegmentedToVirtual(path->points); - s32 sp58; + s32 sp58 = path->count; + s32 index = arg2; + s32 ret = false; f32 sp54; - s32 ret; - s32 pad4C; f32 sp48; f32 sp44; f32 sp40; f32 sp3C; Vec3f sp30; - if (sp5C[arg2 - 1].x) {} - sp58 = path->count; - ret = false; - Math_Vec3s_ToVec3f(&sp30, &sp5C[arg2]); - if (arg2 == 0) { + Math_Vec3s_ToVec3f(&sp30, &sp5C[index]); + if (index == 0) { sp54 = sp5C[0].x - sp5C[1].x; sp48 = sp5C[0].z - sp5C[1].z; - } else if (arg2 == sp58 - 1) { + } else if (index == sp58 - 1) { sp54 = sp5C[sp58 - 2].x - sp5C[sp58 - 1].x; sp48 = sp5C[sp58 - 2].z - sp5C[sp58 - 1].z; } else { - sp54 = sp5C[arg2 - 1].x - sp5C[arg2 + 1].x; - sp48 = sp5C[arg2 - 1].z - sp5C[arg2 + 1].z; + sp54 = sp5C[index - 1].x - sp5C[index + 1].x; + sp48 = sp5C[index - 1].z - sp5C[index + 1].z; } func_8017B7F8(&sp30, RADF_TO_BINANG(func_80086B30(sp54, sp48)), &sp44, &sp40, &sp3C); if (((sp44 * this->actor.world.pos.x) + (sp40 * this->actor.world.pos.z) + sp3C) > 0.0f) { @@ -590,7 +629,7 @@ void func_80BABA90(EnSuttari* this, s32 arg1, u8 arg2) { f32 dist; if (this->paths[arg1] != NULL) { - target = func_80BAB698(this->paths[arg1], this->unk1F4[arg1], &this->actor.world.pos, &dist); + target = EnSuttari_GetDistSqAndOrient(this->paths[arg1], this->unk1F4[arg1], &this->actor.world.pos, &dist); if (this->actor.bgCheckFlags & 8) { if (arg2 == 2) { this->unk1F4[arg1] = -0x63; @@ -619,7 +658,7 @@ void func_80BABB90(EnSuttari* this, s32 arg1) { f32 sp30; if (this->paths[arg1] != NULL) { - target = func_80BAB698(this->paths[arg1], this->unk1F4[arg1], &this->actor.world.pos, &sp30); + target = EnSuttari_GetDistSqAndOrient(this->paths[arg1], this->unk1F4[arg1], &this->actor.world.pos, &sp30); if (this->actor.bgCheckFlags & 8) { target = this->actor.wallYaw; } @@ -635,16 +674,16 @@ void func_80BABB90(EnSuttari* this, s32 arg1) { } } -s32 func_80BABC48(EnSuttari* this, GlobalContext* globalCtx, struct_80133038_arg2* unkStruct) { - u16 sp26 = gSaveContext.time - 0x3FFC; +s32 func_80BABC48(EnSuttari* this, GlobalContext* globalCtx, ScheduleResult* unkStruct) { + u16 sp26 = SCHEDULE_TIME_NOW; u16 pad1; u8 sp23 = ENSUTTARI_GET_PATH(&this->actor); u16 pad2; - UNK_TYPE sp1C = D_80BAE8F8[unkStruct->unk0]; + UNK_TYPE sp1C = D_80BAE8F8[unkStruct->result]; u16 phi_a0; if (sp1C >= 0) { - this->unk404 = func_8013BB34(globalCtx, sp23, sp1C); + this->unk404 = SubS_GetAdditionalPath(globalCtx, sp23, sp1C); } if (this->unk404 == NULL) { return 0; @@ -652,12 +691,12 @@ s32 func_80BABC48(EnSuttari* this, GlobalContext* globalCtx, struct_80133038_arg if ((this->unk428 != 0 && this->unk428 < 0xC) && (this->unk42A >= 0)) { phi_a0 = sp26; } else { - phi_a0 = unkStruct->unk4; + phi_a0 = unkStruct->time0; } - if (unkStruct->unk8 < phi_a0) { - this->unk418 = (phi_a0 - unkStruct->unk8) + 0xFFFF; + if (unkStruct->time1 < phi_a0) { + this->unk418 = (phi_a0 - unkStruct->time1) + 0xFFFF; } else { - this->unk418 = unkStruct->unk8 - phi_a0; + this->unk418 = unkStruct->time1 - phi_a0; } this->unk424 = sp26 - phi_a0; phi_a0 = this->unk404->count - 2; @@ -668,7 +707,7 @@ s32 func_80BABC48(EnSuttari* this, GlobalContext* globalCtx, struct_80133038_arg return 1; } -s32 func_80BABDD8(EnSuttari* this, GlobalContext* globalCtx, struct_80133038_arg2* unkStruct) { +s32 func_80BABDD8(EnSuttari* this, GlobalContext* globalCtx, ScheduleResult* unkStruct) { s32 pad; EnDoor* sp48; u8 sp47; @@ -679,14 +718,14 @@ s32 func_80BABDD8(EnSuttari* this, GlobalContext* globalCtx, struct_80133038_arg UNK_TYPE sp24; sp47 = ENSUTTARI_GET_PATH(&this->actor); - sp44 = gSaveContext.time - 0x3FFC; + sp44 = SCHEDULE_TIME_NOW; if (this->unk428 == 10 || this->unk428 == 11 || this->unk428 == 2) { return 0; } sp48 = (EnDoor*)SubS_FindNearestActor(&this->actor, globalCtx, ACTORCAT_DOOR, ACTOR_EN_DOOR); - sp24 = D_80BAE8F8[unkStruct->unk0]; + sp24 = D_80BAE8F8[unkStruct->result]; if ((sp48 != NULL) && (sp24 >= 0)) { - this->unk404 = func_8013BB34(globalCtx, sp47, sp24); + this->unk404 = SubS_GetAdditionalPath(globalCtx, sp47, sp24); } if ((sp48 == NULL) || (this->unk404 == NULL)) { return 0; @@ -694,9 +733,9 @@ s32 func_80BABDD8(EnSuttari* this, GlobalContext* globalCtx, struct_80133038_arg sp28 = Lib_SegmentedToVirtual(this->unk404->points); Math_Vec3s_ToVec3f(&sp38, &sp28[0]); Math_Vec3s_ToVec3f(&sp2C, &sp28[1]); - this->unk434 = sp44 - unkStruct->unk4; - this->unk436 = unkStruct->unk8 - unkStruct->unk4; - if (unkStruct->unk0 != 10 && unkStruct->unk0 != 11) { + this->unk434 = sp44 - unkStruct->time0; + this->unk436 = unkStruct->time1 - unkStruct->time0; + if (unkStruct->result != 10 && unkStruct->result != 11) { sp48->unk_1A7 = 0x4B; } Math_Vec3f_Copy(&this->unk438, &sp38); @@ -706,10 +745,10 @@ s32 func_80BABDD8(EnSuttari* this, GlobalContext* globalCtx, struct_80133038_arg return 1; } -s32 func_80BABF64(EnSuttari* this, GlobalContext* globalCtx, struct_80133038_arg2* unkStruct) { +s32 func_80BABF64(EnSuttari* this, GlobalContext* globalCtx, ScheduleResult* unkStruct) { s32 ret; - switch (unkStruct->unk0) { + switch (unkStruct->result) { case 15: case 14: case 13: @@ -760,7 +799,7 @@ s32 func_80BABFD4(EnSuttari* this, GlobalContext* globalCtx) { } this->actor.world.pos.x = sp58.x; this->actor.world.pos.z = sp58.z; - if (func_8013AD6C(globalCtx)) { + if (SubS_InCsMode(globalCtx)) { sp54 = this->unk424; sp50 = this->unk420; sp58 = this->actor.world.pos; @@ -774,7 +813,7 @@ s32 func_80BABFD4(EnSuttari* this, GlobalContext* globalCtx) { sp64 = this->unk408; this->actor.world.rot.y = Math_Vec3f_Yaw(&sp70, &sp64); } - if (func_8013AD6C(globalCtx)) { + if (SubS_InCsMode(globalCtx)) { this->unk424 = sp54; this->unk420 = sp50; this->unk408 = sp58; @@ -806,7 +845,7 @@ s32 func_80BAC220(EnSuttari* this, GlobalContext* globalCtx) { void func_80BAC2FC(EnSuttari* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s16 curFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIdx].animation); + s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); switch (this->unk428) { case 12: @@ -815,11 +854,11 @@ void func_80BAC2FC(EnSuttari* this, GlobalContext* globalCtx) { func_80BABFD4(this, globalCtx); break; case 15: - if ((this->animationIdx == 1) && (curFrame == frameCount)) { - this->animationIdx = 2; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIdx); + if ((this->animationIndex == 1) && (curFrame == frameCount)) { + this->animationIndex = 2; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); } - if (!(gSaveContext.weekEventReg[83] & 4) && !(this->flags1 & 0x1000)) { + if (!(gSaveContext.save.weekEventReg[83] & 4) && !(this->flags1 & 0x1000)) { if (ActorCutscene_GetCanPlayNext(this->cutscenes[0])) { ActorCutscene_Start(this->cutscenes[0], &this->actor); if (!(player->stateFlags1 & 0x10000000)) { @@ -848,9 +887,9 @@ void func_80BAC2FC(EnSuttari* this, GlobalContext* globalCtx) { this->flags1 |= 0x80; this->flags1 |= 0x20; this->enFsn->flags &= ~ENFSN_HAGGLE; - if (this->animationIdx != 2) { - this->animationIdx = 2; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIdx); + if (this->animationIndex != 2) { + this->animationIndex = 2; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); } func_80BAC220(this, globalCtx); break; @@ -868,7 +907,7 @@ void func_80BAC2FC(EnSuttari* this, GlobalContext* globalCtx) { Actor_MarkForDeath(&this->actor); break; case 2: - if (!(gSaveContext.weekEventReg[81] & 4)) { + if (!(gSaveContext.save.weekEventReg[81] & 4)) { this->flags1 |= 0x80; this->actor.world.pos.x = -16.0f; this->actor.world.pos.z = -16.0f; @@ -878,10 +917,10 @@ void func_80BAC2FC(EnSuttari* this, GlobalContext* globalCtx) { } break; case 4: - if (!(gSaveContext.weekEventReg[33] & 8)) { - if (this->animationIdx == 2 || this->animationIdx == 1) { - this->animationIdx = 5; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIdx); + if (!(gSaveContext.save.weekEventReg[33] & 8)) { + if (this->animationIndex == 2 || this->animationIndex == 1) { + this->animationIndex = 5; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); } this->flags1 |= 0x10; if (this->flags2 & 2) { @@ -908,52 +947,52 @@ void func_80BAC6E8(EnSuttari* this, GlobalContext* globalCtx) { this->actor.flags |= ACTOR_FLAG_1; if (globalCtx->sceneNum == SCENE_IKANA) { this->flags1 |= 1; - if (gSaveContext.day == 1 || gSaveContext.day == 2) { - this->animationIdx = 2; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIdx); + if (gSaveContext.save.day == 1 || gSaveContext.save.day == 2) { + this->animationIndex = 2; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); this->flags1 |= 0x80; this->actionFunc = func_80BACA14; return; - } else if ((gSaveContext.day == 3) && (gSaveContext.time <= CLOCK_TIME(19, 00)) && - !(gSaveContext.weekEventReg[61] & 8) && !(gSaveContext.weekEventReg[33] & 8) && - (gSaveContext.weekEventReg[51] & 8)) { - this->animationIdx = 2; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIdx); + } else if ((gSaveContext.save.day == 3) && (gSaveContext.save.time <= CLOCK_TIME(19, 0)) && + !(gSaveContext.save.weekEventReg[61] & 8) && !(gSaveContext.save.weekEventReg[33] & 8) && + (gSaveContext.save.weekEventReg[51] & 8)) { + this->animationIndex = 2; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); this->actionFunc = func_80BACEE0; return; } } else if (globalCtx->sceneNum == SCENE_BACKTOWN) { - if (gSaveContext.time >= CLOCK_TIME(0, 20) && gSaveContext.time < CLOCK_TIME(6, 00)) { + if (gSaveContext.save.time >= CLOCK_TIME(0, 20) && gSaveContext.save.time < CLOCK_TIME(6, 00)) { Actor_MarkForDeath(&this->actor); } - if ((gSaveContext.entranceIndex == 0xD670) || (gSaveContext.weekEventReg[58] & 0x40)) { + if ((gSaveContext.save.entranceIndex == 0xD670) || (gSaveContext.save.weekEventReg[58] & 0x40)) { Actor_MarkForDeath(&this->actor); } this->cutscenes[0] = this->actor.cutscene; this->cutscenes[1] = ActorCutscene_GetAdditionalCutscene(this->cutscenes[0]); this->flags1 |= 0x80; this->flags1 |= 8; - this->animationIdx = 1; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIdx); + this->animationIndex = 1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); this->actionFunc = func_80BAD004; return; } else if (globalCtx->sceneNum == SCENE_ICHIBA) { - if (gSaveContext.weekEventReg[33] & 8) { + if (gSaveContext.save.weekEventReg[33] & 8) { Actor_MarkForDeath(&this->actor); return; } - this->animationIdx = 0; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIdx); + this->animationIndex = 0; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); this->flags1 |= 2; this->actionFunc = func_80BAD5F8; return; } else if (globalCtx->sceneNum == SCENE_AYASHIISHOP) { - if (gSaveContext.weekEventReg[33] & 8) { + if (gSaveContext.save.weekEventReg[33] & 8) { Actor_MarkForDeath(&this->actor); return; } - this->animationIdx = 0; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIdx); + this->animationIndex = 0; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); this->cutscenes[0] = this->actor.cutscene; this->cutscenes[1] = ActorCutscene_GetAdditionalCutscene(this->cutscenes[0]); this->flags1 |= 4; @@ -971,9 +1010,9 @@ void func_80BAC6E8(EnSuttari* this, GlobalContext* globalCtx) { void func_80BACA14(EnSuttari* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (this->animationIdx == 1 || this->animationIdx == 8) { - this->animationIdx = 2; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIdx); + if (this->animationIndex == 1 || this->animationIndex == 8) { + this->animationIndex = 2; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); } func_80BABA90(this, 0, 0); func_80BAB434(this); @@ -982,7 +1021,7 @@ void func_80BACA14(EnSuttari* this, GlobalContext* globalCtx) { this->unk3F2 = this->unk2DC.y; this->actionFunc = func_80BACBB0; } - } else if ((player->transformation == PLAYER_FORM_HUMAN) && CUR_EQUIP_VALUE_VOID(EQUIP_SWORD) != 0) { + } else if ((player->transformation == PLAYER_FORM_HUMAN) && GET_CUR_EQUIP_VALUE(EQUIP_SWORD) != 0) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->unk3F2 = this->unk2DC.y; func_80BAAB78(this, globalCtx); @@ -1061,22 +1100,21 @@ void func_80BACE4C(EnSuttari* this, GlobalContext* globalCtx) { } void func_80BACEE0(EnSuttari* this, GlobalContext* globalCtx) { - u32* unk_14 = &gSaveContext.unk_14; - struct_80133038_arg2 unkStruct; + ScheduleResult unkStruct; - this->unk42A = REG(15) + *unk_14; - if (!func_80133038(globalCtx, D_80BAE820, &unkStruct) || - ((this->unk428 != unkStruct.unk0) && !func_80BABF64(this, globalCtx, &unkStruct))) { + this->unk42A = REG(15) + ((void)0, gSaveContext.save.daySpeed); + if (!Schedule_RunScript(globalCtx, D_80BAE820, &unkStruct) || + ((this->unk428 != unkStruct.result) && !func_80BABF64(this, globalCtx, &unkStruct))) { this->actor.flags &= ~ACTOR_FLAG_1; - unkStruct.unk0 = 0; + unkStruct.result = 0; } else { this->actor.flags |= ACTOR_FLAG_1; } - this->unk428 = unkStruct.unk0; + this->unk428 = unkStruct.result; func_80BAC2FC(this, globalCtx); func_80BAB434(this); if (this->unk428 == 5) { - gSaveContext.weekEventReg[58] |= 0x80; + gSaveContext.save.weekEventReg[58] |= 0x80; this->actionFunc = func_80BADDB4; this->actor.speedXZ = 0.0f; } else if (Player_GetMask(globalCtx) != PLAYER_MASK_STONE) { @@ -1086,18 +1124,17 @@ void func_80BACEE0(EnSuttari* this, GlobalContext* globalCtx) { } void func_80BAD004(EnSuttari* this, GlobalContext* globalCtx) { - u32* unk_14 = &gSaveContext.unk_14; - struct_80133038_arg2 unkStruct; + ScheduleResult unkStruct; - this->unk42A = REG(15) + *unk_14; - if (!func_80133038(globalCtx, D_80BAE820, &unkStruct) || - ((this->unk428 != unkStruct.unk0) && !func_80BABF64(this, globalCtx, &unkStruct))) { + this->unk42A = REG(15) + ((void)0, gSaveContext.save.daySpeed); + if (!Schedule_RunScript(globalCtx, D_80BAE820, &unkStruct) || + ((this->unk428 != unkStruct.result) && !func_80BABF64(this, globalCtx, &unkStruct))) { this->actor.flags &= ~ACTOR_FLAG_1; - unkStruct.unk0 = 0; + unkStruct.result = 0; } else { this->actor.flags |= ACTOR_FLAG_1; } - this->unk428 = unkStruct.unk0; + this->unk428 = unkStruct.result; func_80BAC2FC(this, globalCtx); if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { Message_StartTextbox(globalCtx, 0x2A3A, &this->actor); @@ -1111,7 +1148,7 @@ void func_80BAD004(EnSuttari* this, GlobalContext* globalCtx) { void func_80BAD130(EnSuttari* this, GlobalContext* globalCtx) { u8 talkState = Message_GetState(&globalCtx->msgCtx); - if ((talkState == 5 || talkState == 6) && func_80147624(globalCtx)) { + if ((talkState == 5 || talkState == 6) && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; if (this->flags1 & 8) { @@ -1142,7 +1179,7 @@ void func_80BAD230(EnSuttari* this, GlobalContext* globalCtx) { } void func_80BAD2B4(EnSuttari* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { if (this->textId == 0x2A30) { ActorCutscene_Stop(this->cutscenes[0]); ActorCutscene_SetIntentToPlay(this->cutscenes[1]); @@ -1162,13 +1199,13 @@ void func_80BAD380(EnSuttari* this, GlobalContext* globalCtx) { u8 talkState = Message_GetState(&globalCtx->msgCtx); Player* player = GET_PLAYER(globalCtx); - if ((player->stateFlags1 & 0x40) && (globalCtx->msgCtx.unk11F04 != 0x2A31)) { + if ((player->stateFlags1 & 0x40) && (globalCtx->msgCtx.currentTextId != 0x2A31)) { this->flags1 |= 0x8000; this->actor.speedXZ = 0.0f; } else { this->flags1 &= ~0x8000; func_80BABA90(this, 1, 1); - if ((this->flags1 & 0x4000) && (talkState == 5) && func_80147624(globalCtx)) { + if ((this->flags1 & 0x4000) && (talkState == 5) && Message_ShouldAdvance(globalCtx)) { this->flags2 &= ~0x10; player->stateFlags1 &= ~0x10000000; this->flags1 &= ~0x4000; @@ -1181,7 +1218,7 @@ void func_80BAD380(EnSuttari* this, GlobalContext* globalCtx) { this->flags2 |= 8; func_80BAAF1C(this); } else if (this->flags1 & 0x200) { - gSaveContext.weekEventReg[79] |= 0x40; + gSaveContext.save.weekEventReg[79] |= 0x40; this->flags2 |= 4; this->actor.speedXZ = 0.0f; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->actor.world.pos.x, @@ -1192,7 +1229,7 @@ void func_80BAD380(EnSuttari* this, GlobalContext* globalCtx) { } if (this->unk1F4[1] == -0x63) { if (this->flags2 & 8) { - gSaveContext.weekEventReg[33] |= 8; + gSaveContext.save.weekEventReg[33] |= 8; } this->actor.speedXZ = 0.0f; Audio_QueueSeqCmd(0x101400FF); @@ -1208,31 +1245,30 @@ void func_80BAD380(EnSuttari* this, GlobalContext* globalCtx) { } void func_80BAD5F8(EnSuttari* this, GlobalContext* globalCtx) { - u32* unk_14 = &gSaveContext.unk_14; - struct_80133038_arg2 unkStruct; + ScheduleResult unkStruct; s16 curFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIdx].animation); + s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); - if ((curFrame == frameCount) && (this->animationIdx == 0) && (this->flags1 & 0x20)) { - this->animationIdx = 2; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIdx); + if ((curFrame == frameCount) && (this->animationIndex == 0) && (this->flags1 & 0x20)) { + this->animationIndex = 2; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); } - this->unk42A = REG(15) + *unk_14; - if (!func_80133038(globalCtx, D_80BAE820, &unkStruct) || - ((this->unk428 != unkStruct.unk0) && !func_80BABF64(this, globalCtx, &unkStruct))) { + this->unk42A = REG(15) + ((void)0, gSaveContext.save.daySpeed); + if (!Schedule_RunScript(globalCtx, D_80BAE820, &unkStruct) || + ((this->unk428 != unkStruct.result) && !func_80BABF64(this, globalCtx, &unkStruct))) { this->actor.flags &= ~ACTOR_FLAG_1; - unkStruct.unk0 = 0; + unkStruct.result = 0; } else { this->actor.flags |= ACTOR_FLAG_1; } - this->unk428 = unkStruct.unk0; + this->unk428 = unkStruct.result; func_80BAC2FC(this, globalCtx); if ((this->unk430 == 1) && (this->unk404->unk1 == 0xFF)) { Actor_MarkForDeath(&this->actor); return; } func_80BAB434(this); - if ((this->flags1 & 0x20) && (this->unk430 == 0) && (unkStruct.unk0 != 7)) { + if ((this->flags1 & 0x20) && (this->unk430 == 0) && (unkStruct.result != 7)) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { Message_StartTextbox(globalCtx, 0x2A02, &this->actor); this->actionFunc = func_80BAD130; @@ -1244,33 +1280,32 @@ void func_80BAD5F8(EnSuttari* this, GlobalContext* globalCtx) { } void func_80BAD7F8(EnSuttari* this, GlobalContext* globalCtx) { - u32* unk_14 = &gSaveContext.unk_14; - struct_80133038_arg2 unkStruct; + ScheduleResult unkStruct; s16 curFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIdx].animation); + s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); if (this->enFsn == NULL) { this->enFsn = (EnFsn*)EnSuttari_GetActorById(globalCtx, ACTOR_EN_FSN); } else { - if ((this->flags1 & 0x2000) && (this->animationIdx == 1) && (curFrame == frameCount)) { - this->animationIdx = 2; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIdx); + if ((this->flags1 & 0x2000) && (this->animationIndex == 1) && (curFrame == frameCount)) { + this->animationIndex = 2; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); } - this->unk42A = REG(15) + *unk_14; - if (!func_80133038(globalCtx, D_80BAE820, &unkStruct) || - ((this->unk428 != unkStruct.unk0) && !func_80BABF64(this, globalCtx, &unkStruct))) { + this->unk42A = REG(15) + ((void)0, gSaveContext.save.daySpeed); + if (!Schedule_RunScript(globalCtx, D_80BAE820, &unkStruct) || + ((this->unk428 != unkStruct.result) && !func_80BABF64(this, globalCtx, &unkStruct))) { this->actor.flags &= ~ACTOR_FLAG_1; - unkStruct.unk0 = 0; + unkStruct.result = 0; } else { this->actor.flags |= ACTOR_FLAG_1; } - this->unk428 = unkStruct.unk0; + this->unk428 = unkStruct.result; func_80BAC2FC(this, globalCtx); if ((this->unk430 == 1) && (this->unk404->unk1 == 0xFF)) { Actor_MarkForDeath(&this->actor); return; } - if ((this->flags1 & 0x20) && (unkStruct.unk0 != 9)) { + if ((this->flags1 & 0x20) && (unkStruct.result != 9)) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { Message_StartTextbox(globalCtx, 0x2A02, &this->actor); this->actionFunc = func_80BAD130; @@ -1286,7 +1321,7 @@ void func_80BADA08(EnSuttari* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actor.flags &= ~ACTOR_FLAG_10000; func_80BAAB78(this, globalCtx); - gSaveContext.weekEventReg[81] |= 4; + gSaveContext.save.weekEventReg[81] |= 4; } else if (this->actor.xzDistToPlayer < 500.0f) { this->actor.flags |= ACTOR_FLAG_10000; func_800B8614(&this->actor, globalCtx, 500.0f); @@ -1296,17 +1331,17 @@ void func_80BADA08(EnSuttari* this, GlobalContext* globalCtx) { void func_80BADA9C(EnSuttari* this, GlobalContext* globalCtx) { u8 talkstate = Message_GetState(&globalCtx->msgCtx); s16 curFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIdx].animation); + s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); if (this->flags1 & 1) { this->unk3F2 = this->unk2DC.y; func_80BAA9B4(this); - } else if ((this->animationIdx == 7) && (curFrame == frameCount)) { - this->animationIdx = 1; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIdx); + } else if ((this->animationIndex == 7) && (curFrame == frameCount)) { + this->animationIndex = 1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); } if (talkstate == 5) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (this->flags1 & 0x400) { if (this->textId == 0x29EE) { ActorCutscene_Stop(this->cutscenes[this->cutsceneIdx]); @@ -1328,7 +1363,7 @@ void func_80BADA9C(EnSuttari* this, GlobalContext* globalCtx) { } func_80BAAB78(this, globalCtx); } - } else if ((talkstate == 4) && func_80147624(globalCtx)) { + } else if ((talkstate == 4) && Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_8019F208(); @@ -1364,7 +1399,7 @@ void func_80BADD0C(EnSuttari* this, GlobalContext* globalCtx) { void func_80BADDB4(EnSuttari* this, GlobalContext* globalCtx) { func_80BABA90(this, 1, 1); func_80BAB434(this); - if (gSaveContext.weekEventReg[51] & 0x10) { + if (gSaveContext.save.weekEventReg[51] & 0x10) { this->actionFunc = func_80BADE14; } Actor_MoveWithGravity(&this->actor); @@ -1410,7 +1445,7 @@ void EnSuttari_Init(Actor* thisx, GlobalContext* globalCtx) { EnSuttari* this = THIS; s32 pad; - if (gSaveContext.weekEventReg[79] & 0x40) { + if (gSaveContext.save.weekEventReg[79] & 0x40) { Actor_MarkForDeath(&this->actor); return; } @@ -1449,11 +1484,11 @@ void EnSuttari_Update(Actor* thisx, GlobalContext* globalCtx) { EnSuttari_UpdateTime(); } if (this->unk428 != 0) { - if (this->animationIdx == 2 || this->animationIdx == 6) { + if (this->animationIndex == 2 || this->animationIndex == 6) { if (Animation_OnFrame(&this->skelAnime, 8.0f) || Animation_OnFrame(&this->skelAnime, 16.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_PAMERA_WALK); } - } else if (this->animationIdx == 0 || this->animationIdx == 5) { + } else if (this->animationIndex == 0 || this->animationIndex == 5) { if (Animation_OnFrame(&this->skelAnime, 8.0f) || Animation_OnFrame(&this->skelAnime, 17.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_PAMERA_WALK); } diff --git a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.h b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.h index 9c62be60f6..c6f8cc1530 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.h +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.h @@ -55,7 +55,7 @@ typedef struct EnSuttari { /* 0x436 */ s16 unk436; /* 0x438 */ Vec3f unk438; /* 0x444 */ Vec3f unk444; - /* 0x450 */ s32 animationIdx; + /* 0x450 */ s32 animationIndex; /* 0x454 */ UNK_TYPE1 unk_454[0x2]; /* 0x456 */ s16 cutscenes[2]; /* 0x45A */ s16 cutsceneIdx; diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.c b/src/overlays/actors/ovl_En_Sw/z_en_sw.c index 14e4dfc8b6..91d602f87c 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.c +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.c @@ -176,14 +176,15 @@ s32 func_808D8B58(EnSw* this) { s32 i; for (i = 0; i < ARRAY_COUNT(this->unk_464); i++, phi_s2 += 0x1555) { - if (this->unk_412 != 10) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { this->unk_464[i] = (Rand_ZeroOne() * 16.0f) + 8.0f; } else { this->unk_464[i] = 80; } this->unk_47C[i] = this->unk_464[i]; - this->unk_418[i] = 0.45000002f; - if ((this->unk_412 == 0) || (this->unk_412 == 1) || (this->unk_412 == 10)) { + this->drawDmgEffFrozenSteamScales[i] = 0.45000002f; + if ((this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FIRE) || (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_BLUE_FIRE) || + (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX)) { this->unk_380[i].y = (Rand_ZeroOne() - 0.5f) * 20.0f; } else { this->unk_380[i].y = ((Rand_ZeroOne() - 0.5f) * 20.0f) + 10.0f; @@ -197,26 +198,27 @@ s32 func_808D8B58(EnSw* this) { s32 func_808D8D60(EnSw* this, GlobalContext* globalCtx, s32 arg2) { s32 ret = false; - u8 sp53; - Vec3f sp44; - f32 sp40; + u8 drawDmgEffType; + Vec3f limbPos[1]; + f32 drawDmgEffAlpha; if (arg2 < this->unk_462) { if (this->unk_464[arg2] != 0) { - sp40 = (f32)this->unk_464[arg2] / this->unk_47C[arg2]; - sp53 = this->unk_412; - Math_ApproachF(&this->unk_418[arg2], 0.3f, 0.3f, 0.5f); - Math_Vec3f_Copy(&sp44, &this->actor.world.pos); - sp44.x += this->unk_380[arg2].x; - sp44.y += this->unk_380[arg2].y; - sp44.z += this->unk_380[arg2].z; - if (sp53 == 10) { + drawDmgEffAlpha = (f32)this->unk_464[arg2] / this->unk_47C[arg2]; + drawDmgEffType = this->drawDmgEffType; + Math_ApproachF(&this->drawDmgEffFrozenSteamScales[arg2], 0.3f, 0.3f, 0.5f); + Math_Vec3f_Copy(&limbPos[0], &this->actor.world.pos); + limbPos[0].x += this->unk_380[arg2].x; + limbPos[0].y += this->unk_380[arg2].y; + limbPos[0].z += this->unk_380[arg2].z; + if (drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { if ((this->unk_47C[arg2] - this->unk_464[arg2]) < 20) { - sp53 = 11; + drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_SFX; } - sp40 = 1.0f; + drawDmgEffAlpha = 1.0f; } - func_800BE680(globalCtx, &this->actor, &sp44, 1, 0.3f, this->unk_418[arg2], sp40, sp53); + Actor_DrawDamageEffects(globalCtx, &this->actor, limbPos, ARRAY_COUNT(limbPos), 0.3f, + this->drawDmgEffFrozenSteamScales[arg2], drawDmgEffAlpha, drawDmgEffType); ret = true; } } @@ -448,6 +450,7 @@ void func_808D94D0(EnSw* this, GlobalContext* globalCtx, s32 arg2, s32 arg3, s16 } } #else +void func_808D94D0(EnSw* this, GlobalContext* globalCtx, s32 arg2, s32 arg3, s16 arg4); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808D94D0.s") #endif @@ -665,7 +668,7 @@ s32 func_808DA08C(EnSw* this, GlobalContext* globalCtx) { this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); } - if (this->unk_412 == 10) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { // clang-format off for (i = 0; i < ARRAY_COUNT(this->unk_464); i++) { this->unk_464[i] = 0; } // clang-format on @@ -681,36 +684,36 @@ s32 func_808DA08C(EnSw* this, GlobalContext* globalCtx) { switch (this->actor.colChkInfo.damageEffect) { case 4: - this->unk_412 = 20; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; this->unk_45C = 20; func_808D8B58(this); break; case 3: - this->unk_412 = 10; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; this->unk_45C = 0; func_808D8B58(this); break; case 2: - this->unk_412 = 0; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->unk_45C = 20; func_808D8B58(this); break; case 5: - this->unk_412 = 30; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; this->unk_45C = 20; func_808D8B58(this); break; default: - this->unk_412 = 1; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_BLUE_FIRE; this->unk_45C = 0; break; } - if (!ENSW_GET_3(&this->actor) && (this->unk_412 != 10)) { + if (!ENSW_GET_3(&this->actor) && (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX)) { func_808D9E44(this); } this->unk_458 = 20; @@ -814,6 +817,7 @@ void func_808DA578(EnSw* this, GlobalContext* globalCtx) { this->unk_414 = temp_f0; } #else +void func_808DA578(EnSw* this, GlobalContext* globalCtx); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808DA578.s") #endif @@ -852,11 +856,12 @@ void func_808DA6FC(EnSw* this, GlobalContext* globalCtx) { this->unk_414 = sp4C; } #else +void func_808DA6FC(EnSw* this, GlobalContext* globalCtx); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808DA6FC.s") #endif void func_808DA89C(EnSw* this, GlobalContext* globalCtx) { - if (this->unk_412 == 10) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { s32 i; s32 count; s16 phi_a0; @@ -877,7 +882,7 @@ void func_808DA89C(EnSw* this, GlobalContext* globalCtx) { if (!ENSW_GET_3(&this->actor)) { func_808D9E44(this); } - this->unk_412 = 1; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_BLUE_FIRE; func_808D8ED0(this, globalCtx); } return; @@ -1011,6 +1016,7 @@ void func_808DACF4(EnSw* this, GlobalContext* globalCtx) { this->unk_414 = sp4C; } #else +void func_808DACF4(EnSw* this, GlobalContext* globalCtx); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808DACF4.s") #endif @@ -1065,7 +1071,7 @@ void func_808DAEB4(EnSw* this, GlobalContext* globalCtx) { phi_a0 = DECR(this->unk_45C); if (phi_a0 == 0) { this->unk_410 |= 2; - if (!ENSW_GET_3(&this->actor) && (this->unk_412 == 1)) { + if (!ENSW_GET_3(&this->actor) && (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_BLUE_FIRE)) { func_808D8B58(this); this->unk_45C = 10; } else { @@ -1173,7 +1179,7 @@ void EnSw_Init(Actor* thisx, GlobalContext* globalCtx) { this->collider.info.toucher.damage = 16; } - this->unk_1E4 = func_8013BEDC(globalCtx, ENSW_GET_FF00(&this->actor), 255, &this->unk_4A0); + this->unk_1E4 = SubS_GetDayDependentPath(globalCtx, ENSW_GET_FF00(&this->actor), 255, &this->unk_4A0); if (this->unk_1E4 != NULL) { this->unk_4A0 = 1; } @@ -1249,7 +1255,7 @@ void EnSw_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); } - if ((this->unk_412 != 10) || (this->unk_45A != 0)) { + if ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || (this->unk_45A != 0)) { SkelAnime_Update(&this->skelAnime); } diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.h b/src/overlays/actors/ovl_En_Sw/z_en_sw.h index 4c30b49655..b740627055 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.h +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.h @@ -25,9 +25,9 @@ typedef struct EnSw { /* 0x0374 */ Vec3f unk_374; /* 0x0380 */ Vec3f unk_380[12]; /* 0x0410 */ u16 unk_410; - /* 0x0412 */ u8 unk_412; + /* 0x0412 */ u8 drawDmgEffType; /* 0x0414 */ f32 unk_414; - /* 0x0418 */ f32 unk_418[12]; + /* 0x0418 */ f32 drawDmgEffFrozenSteamScales[12]; /* 0x0448 */ f32 unk_448; /* 0x044C */ f32 unk_44C; /* 0x0450 */ f32 unk_450; diff --git a/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.c b/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.c index 1b6397f25e..23a16debcb 100644 --- a/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.c +++ b/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.c @@ -83,22 +83,20 @@ void EnSyatekiCrow_Init(Actor* thisx, GlobalContext* globalCtx2) { EnSyatekiCrow* this = THIS; Path* path; EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; - s32 temp; + s32 i; path = syatekiMan->path; while (path->unk2 != 0) { path = &globalCtx->setupPathList[path->unk1]; } - temp = 0; - while (temp < EN_SYATEKI_CROW_GET_PARAM_FF00(&this->actor)) { - temp++; + for (i = 0; i < EN_SYATEKI_CROW_GET_PARAM_FF00(&this->actor); i++) { path = &globalCtx->setupPathList[path->unk1]; } Actor_ProcessInitChain(&this->actor, sInitChain); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_crow_Skel_0010C0, &object_crow_Anim_0000F0, - this->jointTable, this->morphTable, 9); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGuaySkel, &gGuayFlyAnim, this->jointTable, this->morphTable, + OBJECT_CROW_LIMB_MAX); Collider_InitJntSph(globalCtx, &this->unk_23C); Collider_SetJntSph(globalCtx, &this->unk_23C, &this->actor, &sJntSphInit, &this->unk_25C); this->unk_23C.elements->dim.worldSphere.radius = sJntSphInit.elements[0].dim.modelSphere.radius; @@ -227,7 +225,7 @@ void func_809CAAF8(EnSyatekiCrow* this) { this->unk_1C2 = 0; this->actor.speedXZ *= Math_CosS(this->actor.world.rot.x); this->actor.velocity.y = 0.0f; - Animation_Change(&this->skelAnime, &object_crow_Anim_0000F0, 0.4f, 0.0f, 0.0f, 1, -3.0f); + Animation_Change(&this->skelAnime, &gGuayFlyAnim, 0.4f, 0.0f, 0.0f, 1, -3.0f); this->actor.bgCheckFlags &= ~1; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KAICHO_DEAD); Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 40); @@ -292,10 +290,10 @@ s32 EnSyatekiCrow_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx* Actor* thisx) { EnSyatekiCrow* this = THIS; - if (limbIndex == 7) { - rot->y += (s16)(3072.0f * sin_rad(this->skelAnime.curFrame * 0.7853982f)); - } else if (limbIndex == 8) { - rot->y += (s16)(5120.0f * sin_rad((this->skelAnime.curFrame + 2.5f) * 0.7853982f)); + if (limbIndex == OBJECT_CROW_LIMB_UPPER_TAIL) { + rot->y += (s16)(3072.0f * sin_rad(this->skelAnime.curFrame * (M_PI / 4))); + } else if (limbIndex == OBJECT_CROW_LIMB_TAIL) { + rot->y += (s16)(5120.0f * sin_rad((this->skelAnime.curFrame + 2.5f) * (M_PI / 4))); } return false; @@ -305,10 +303,11 @@ void EnSyatekiCrow_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** d EnSyatekiCrow* this = THIS; Vec3f* sp1C; - if (limbIndex == 2) { + if (limbIndex == OBJECT_CROW_LIMB_BODY) { Matrix_MultiplyVector3fByState(&D_809CB0D8, &this->unk_144[0]); this->unk_144[0].y -= 20.0f; - } else if ((limbIndex == 4) || (limbIndex == 6) || (limbIndex == 8)) { + } else if ((limbIndex == OBJECT_CROW_LIMB_RIGHT_WING_TIP) || (limbIndex == OBJECT_CROW_LIMB_LEFT_WING_TIP) || + (limbIndex == OBJECT_CROW_LIMB_TAIL)) { sp1C = &this->unk_144[(limbIndex >> 1) - 1]; Matrix_MultiplyVector3fByState(&D_809CB050, sp1C); sp1C->y -= 20.0f; diff --git a/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.c b/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.c index 65849b7e51..92168ef765 100644 --- a/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.c +++ b/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.c @@ -5,6 +5,8 @@ */ #include "z_en_syateki_dekunuts.h" +#include "overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.h" +#include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_8000000) @@ -15,16 +17,23 @@ void EnSyatekiDekunuts_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnSyatekiDekunuts_Update(Actor* thisx, GlobalContext* globalCtx); void EnSyatekiDekunuts_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80A2BE54(EnSyatekiDekunuts* this); void func_80A2BF18(EnSyatekiDekunuts* this, GlobalContext* globalCtx); +void func_80A2BFC4(EnSyatekiDekunuts* this); void func_80A2C0F8(EnSyatekiDekunuts* this, GlobalContext* globalCtx); +void func_80A2C150(EnSyatekiDekunuts* this); void func_80A2C168(EnSyatekiDekunuts* this, GlobalContext* globalCtx); +void func_80A2C1AC(EnSyatekiDekunuts* this); void func_80A2C208(EnSyatekiDekunuts* this, GlobalContext* globalCtx); +void func_80A2C27C(EnSyatekiDekunuts* this); void func_80A2C2E0(EnSyatekiDekunuts* this, GlobalContext* globalCtx); +void func_80A2C33C(EnSyatekiDekunuts* this, GlobalContext* globalCtx); +void func_80A2C3AC(EnSyatekiDekunuts* this); void func_80A2C3F0(EnSyatekiDekunuts* this, GlobalContext* globalCtx); +void func_80A2C478(EnSyatekiDekunuts* this); void func_80A2C48C(EnSyatekiDekunuts* this, GlobalContext* globalCtx); void func_80A2C5DC(EnSyatekiDekunuts* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Syateki_Dekunuts_InitVars = { ACTOR_EN_SYATEKI_DEKUNUTS, ACTORCAT_ENEMY, @@ -37,69 +46,390 @@ const ActorInit En_Syateki_Dekunuts_InitVars = { (ActorFunc)EnSyatekiDekunuts_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A2CAB0 = { - { COLTYPE_HIT6, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT6, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 48, 80, 0, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80A2CB90[] = { +static Cylinder16 D_80A2CADC[] = { { 24, 40, 0, { 0, 0, 0 } } }; + +static AnimationInfo sAnimations[] = { + { &gDekuScrubUpAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &gDekuScrubBurrowAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &gDekuScrubIdleAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -1.0f }, + { &gDekuScrubLookAroundAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -1.0f }, + { &gDekuScrubDamageAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &gDekuScrubDieAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &gDekuScrubUnburrowAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_S8(hintId, 77, ICHAIN_CONTINUE), ICHAIN_F32(gravity, 0, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 2600, ICHAIN_STOP), }; -#endif +void EnSyatekiDekunuts_Init(Actor* thisx, GlobalContext* globalCtx2) { + static s32 D_80A2CB9C = 1; + EnSyatekiDekunuts* this = THIS; + GlobalContext* globalCtx = globalCtx2; + s32 phi_v0; + Path* path; + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; + s32 i; -extern ColliderCylinderInit D_80A2CAB0; -extern InitChainEntry D_80A2CB90[]; + path = syatekiMan->path; + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); -extern UNK_TYPE D_06001E50; -extern UNK_TYPE D_06002A5C; -extern UNK_TYPE D_06003180; + if (EN_SYATEKI_DEKUNUTS_GET_PARAM_F(&this->actor) == 1) { + Actor_SetScale(&this->actor, 0.01f); + this->collider.dim = D_80A2CADC[0]; + phi_v0 = 3; + } else { + Actor_SetScale(&this->actor, 0.02f); + phi_v0 = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/EnSyatekiDekunuts_Init.s") + while (path->unk2 != phi_v0) { + path = &globalCtx->setupPathList[path->unk1]; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/EnSyatekiDekunuts_Destroy.s") + for (i = 0; i < EN_SYATEKI_DEKUNUTS_GET_PARAM_FF00(&this->actor); i++) { + path = &globalCtx->setupPathList[path->unk1]; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2BE54.s") + if (D_80A2CB9C == 1) { + this->unk_1EC = 1; + D_80A2CB9C = 0; + } else { + this->unk_1EC = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2BF18.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 35.0f); + SkelAnime_Init(globalCtx, &this->skelAnime, &gDekuScrubSkel, &gDekuScrubBurrowAnim, this->jointTable, + this->morphTable, DEKU_SCRUB_LIMB_MAX); + if (path == NULL) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2BFC4.s") + this->unk_1E4 = Lib_SegmentedToVirtual(path->points); + this->unk_1E8 = EN_SYATEKI_DEKUNUTS_GET_PARAM_F0(&this->actor); + this->unk_1EA = path->count; + this->unk_1D8 = 0; + this->unk_1DC = 0; + this->unk_1DA = 0; + func_80A2BE54(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2C0F8.s") +void EnSyatekiDekunuts_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnSyatekiDekunuts* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2C150.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2C168.s") +void func_80A2BE54(EnSyatekiDekunuts* this) { + Animation_PlayOnceSetSpeed(&this->skelAnime, &gDekuScrubUpAnim, 0.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2C1AC.s") + this->actor.speedXZ = 0.0f; + this->actor.world = this->actor.home; + this->actor.prevPos = this->actor.home.pos; + this->actor.shape.rot = this->actor.world.rot; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2C208.s") + this->unk_1D8 = 0; + this->unk_1DC = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2C27C.s") + if (EN_SYATEKI_DEKUNUTS_GET_PARAM_F(&this->actor) != 1) { + this->unk_1E2 = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2C2E0.s") + this->actionFunc = func_80A2BF18; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2C33C.s") +void func_80A2BF18(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2C3AC.s") + if ((syatekiMan->unk_26A == 1) && (this->unk_1E2 == 1) && ((syatekiMan->unk_272 & (1 << this->unk_1E8)) != 0)) { + func_80A2BFC4(this); + } else if (syatekiMan->unk_26A != 1) { + this->unk_1E2 = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2C3F0.s") + if ((syatekiMan->unk_272 == 0) && (syatekiMan->unk_274 == 0) && + (EN_SYATEKI_DEKUNUTS_GET_PARAM_F(&this->actor) != 1)) { + this->unk_1E2 = 1; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2C478.s") +void func_80A2BFC4(EnSyatekiDekunuts* this) { + Vec3f sp14; + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2C48C.s") + this->unk_1D8 = 0; + sp14.x = this->unk_1E4[this->unk_1E8].x; + sp14.y = this->unk_1E4[this->unk_1E8].y; + sp14.z = this->unk_1E4[this->unk_1E8].z; + this->actor.world.pos = this->actor.prevPos = sp14; + this->actor.world.rot.y = this->actor.yawTowardsPlayer; + this->actor.shape.rot.y = this->actor.yawTowardsPlayer; + this->unk_1EE = 140 - (syatekiMan->unk_27C * 20); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2C4D0.s") + if ((syatekiMan->unk_27C & 1) != 0) { + this->unk_1F0 = 1; + this->unk_1F2 = 0; + } else { + this->unk_1F0 = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2C5DC.s") + this->actionFunc = func_80A2C0F8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/EnSyatekiDekunuts_Update.s") +void func_80A2C0F8(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { + EnSyatekiMan* syatekiMan; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2C8A0.s") + if (this->unk_1DA > 20) { + syatekiMan = (EnSyatekiMan*)this->actor.parent; + Actor_PlaySfxAtPos(&syatekiMan->actor, NA_SE_EN_NUTS_DAMAGE); + this->unk_1DA = 0; + func_80A2C150(this); + } else { + this->unk_1DA++; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/EnSyatekiDekunuts_Draw.s") +void func_80A2C150(EnSyatekiDekunuts* this) { + this->unk_1D8 = 0; + this->actionFunc = func_80A2C168; +} + +void func_80A2C168(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { + if (this->unk_1DA > 20) { + func_80A2C1AC(this); + this->unk_1DA = 0; + } else { + this->unk_1DA++; + } +} + +void func_80A2C1AC(EnSyatekiDekunuts* this) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + this->actor.shape.rot.y = this->actor.yawTowardsPlayer; + this->actor.world.rot.y = this->actor.yawTowardsPlayer; + this->actionFunc = func_80A2C208; +} + +void func_80A2C208(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + func_80A2C27C(this); + } + + if (this->unk_1F0 == 1) { + Math_SmoothStepToS(&this->unk_1F2, -0x8000, 5, 0x1000, 0x100); + } + + this->unk_1D8++; +} + +void func_80A2C27C(EnSyatekiDekunuts* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); + if (EN_SYATEKI_DEKUNUTS_GET_PARAM_F(&this->actor) != 1) { + this->actionFunc = func_80A2C2E0; + } else { + this->actionFunc = func_80A2C33C; + } +} + +void func_80A2C2E0(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; + + if ((this->unk_1EE < this->unk_1D8) || (syatekiMan->unk_26A != 1)) { + func_80A2C3AC(this); + } + + this->unk_1D8++; +} + +void func_80A2C33C(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; + + if ((gSaveContext.unk_3DE0[1] <= 0) || (syatekiMan->unk_26A != 1)) { + func_80A2C3AC(this); + } + + if (this->unk_1D8 < 11) { + this->unk_1D8++; + } +} + +void func_80A2C3AC(EnSyatekiDekunuts* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + this->actionFunc = func_80A2C3F0; +} + +void func_80A2C3F0(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; + + if (syatekiMan->unk_26A == 1) { + if (this->unk_1D8 > 160 && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + this->unk_1D8 = 0; + func_80A2C150(this); + } else { + this->unk_1D8++; + } + } else { + func_80A2C478(this); + } +} + +void func_80A2C478(EnSyatekiDekunuts* this) { + this->actionFunc = func_80A2C48C; +} + +void func_80A2C48C(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { + if (this->unk_1DA > 20) { + func_80A2BE54(this); + this->unk_1DA = 0; + } else { + this->unk_1DA++; + } +} + +void func_80A2C4D0(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { + static Vec3f D_80A2CBA0 = { 0.0f, 20.0f, 0.0f }; + static Vec3f D_80A2CBAC = { 0.0f, 0.0f, 0.0f }; + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; + + if (EN_SYATEKI_DEKUNUTS_GET_PARAM_F(&this->actor) == 1) { + EffectSsExtra_Spawn(globalCtx, &this->actor.world.pos, &D_80A2CBA0, &D_80A2CBAC, 5, 2); + syatekiMan->unk_280 += 100; + syatekiMan->unk_26E++; + } else { + EffectSsExtra_Spawn(globalCtx, &this->actor.world.pos, &D_80A2CBA0, &D_80A2CBAC, 5, 0); + syatekiMan->unk_280 += 30; + syatekiMan->unk_278++; + } + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DAMAGE); + this->unk_1E2 = 0; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 4); + this->unk_1D8 = 160; + this->actionFunc = func_80A2C5DC; +} + +void func_80A2C5DC(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { + static Color_RGBA8 D_80A2CBB8 = { 255, 255, 255, 255 }; + static Color_RGBA8 D_80A2CBBC = { 150, 150, 150, 0 }; + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; + + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + if (this->unk_1D8 == 160) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 5); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DEAD); + this->unk_1D8--; + } else if (this->unk_1D8 < 160) { + Vec3f sp40; + + sp40.x = this->actor.world.pos.x; + sp40.y = this->actor.world.pos.y + 18.0f; + sp40.z = this->actor.world.pos.z; + EffectSsDeadDb_Spawn(globalCtx, &sp40, &gZeroVec3f, &gZeroVec3f, &D_80A2CBB8, &D_80A2CBBC, 200, 0, 13); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 30, NA_SE_EN_EXTINCT); + sp40.y = this->actor.world.pos.y + 10.0f; + EffectSsHahen_SpawnBurst(globalCtx, &sp40, 3.0f, 0, 12, 3, 15, HAHEN_OBJECT_DEFAULT, 10, NULL); + + if (EN_SYATEKI_DEKUNUTS_GET_PARAM_F(&this->actor) != 1) { + syatekiMan->unk_272 &= ~(1 << this->unk_1E8); + } + + func_80A2BE54(this); + } + } else if (this->unk_1D8 < 160) { + this->unk_1D8--; + } +} + +void EnSyatekiDekunuts_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnSyatekiDekunuts* this = THIS; + + this->actionFunc(this, globalCtx); + + if ((this->actionFunc != func_80A2BF18) && (this->unk_1D8 < this->unk_1EE) && (this->unk_1D8 > 10)) { + if ((this->collider.base.acFlags & AC_HIT) && (this->unk_1E2 == 1)) { + if (EN_SYATEKI_DEKUNUTS_GET_PARAM_F(&this->actor) == 1) { + func_801A3098(NA_BGM_GET_ITEM | 0x900); + } else { + play_sound(NA_SE_SY_TRE_BOX_APPEAR); + } + + this->collider.base.acFlags &= ~AC_HIT; + func_80A2C4D0(this, globalCtx); + } + + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } else { + this->collider.base.acFlags &= ~AC_HIT; + } + + SkelAnime_Update(&this->skelAnime); +} + +s32 EnSyatekiDekunuts_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnSyatekiDekunuts* this = THIS; + + if ((limbIndex == DEKU_SCRUB_LIMB_HEADDRESS) && (this->unk_1F0 == 1)) { + rot->z += this->unk_1F2; + } + + return false; +} + +void EnSyatekiDekunuts_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnSyatekiDekunuts* this = THIS; + Vec3f temp_f20; + s32 i; + + if (this->actionFunc != func_80A2BF18) { + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + EnSyatekiDekunuts_OverrideLimbDraw, NULL, &this->actor); + } + + if (this->unk_1EC == 1) { + for (i = 0; i < this->unk_1EA; i++) { + temp_f20.x = this->unk_1E4[i].x; + temp_f20.y = this->unk_1E4[i].y; + temp_f20.z = this->unk_1E4[i].z; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + Matrix_InsertTranslation(temp_f20.x, temp_f20.y, temp_f20.z, MTXMODE_NEW); + Matrix_Scale(0.02f, 0.02f, 0.02f, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gDekuScrubFlowerDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + } +} diff --git a/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.h b/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.h index 30712d9176..50361894ba 100644 --- a/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.h +++ b/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.h @@ -2,16 +2,36 @@ #define Z_EN_SYATEKI_DEKUNUTS_H #include "global.h" +#include "objects/object_dekunuts/object_dekunuts.h" + +#define EN_SYATEKI_DEKUNUTS_GET_PARAM_F(thisx) ((thisx)->params & 0xF) +#define EN_SYATEKI_DEKUNUTS_GET_PARAM_F0(thisx) (((thisx)->params & 0xF0) >> 4) +#define EN_SYATEKI_DEKUNUTS_GET_PARAM_FF00(thisx) (((thisx)->params & 0xFF00) >> 8) struct EnSyatekiDekunuts; typedef void (*EnSyatekiDekunutsActionFunc)(struct EnSyatekiDekunuts*, GlobalContext*); typedef struct EnSyatekiDekunuts { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; - /* 0x0188 */ EnSyatekiDekunutsActionFunc actionFunc; - /* 0x018C */ char unk_18C[0xE4]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnSyatekiDekunutsActionFunc actionFunc; + /* 0x18C */ ColliderCylinder collider; + /* 0x1D8 */ s16 unk_1D8; + /* 0x1DA */ s16 unk_1DA; + /* 0x1CD */ s16 unk_1DC; + /* 0x1DE */ UNK_TYPE1 unk_1DE[0x4]; + /* 0x1E2 */ s16 unk_1E2; + /* 0x1E4 */ Vec3s* unk_1E4; + /* 0x1E8 */ s16 unk_1E8; + /* 0x1EA */ s16 unk_1EA; + /* 0x1EC */ s16 unk_1EC; + /* 0x1EE */ s16 unk_1EE; + /* 0x1F0 */ s16 unk_1F0; + /* 0x1F2 */ s16 unk_1F2; + /* 0x1F4 */ Vec3s jointTable[DEKU_SCRUB_LIMB_MAX]; + /* 0x230 */ Vec3s morphTable[DEKU_SCRUB_LIMB_MAX]; + /* 0x26C */ UNK_TYPE1 unk_26C[0x4]; } EnSyatekiDekunuts; // size = 0x270 extern const ActorInit En_Syateki_Dekunuts_InitVars; diff --git a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c index ae1f01934e..1bc5484ffe 100644 --- a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c +++ b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c @@ -5,7 +5,6 @@ */ #include "z_en_syateki_man.h" -#include "objects/object_shn/object_shn.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_8000000) @@ -48,9 +47,9 @@ const ActorInit En_Syateki_Man_InitVars = { }; static AnimationInfo sAnimations[] = { - { &object_shn_Anim_00D9D0, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, - { &object_shn_Anim_00DFEC, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, - { &object_shn_Anim_00D2F8, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &gBurlyGuyHandsOnTableAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &gSwampShootingGalleryManHeadScratchLoopAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &gSwampShootingGalleryManHeadScratchEndAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, }; static s16 D_809C91C8[] = { @@ -132,11 +131,11 @@ void EnSyatekiMan_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.targetMode = 1; Actor_SetScale(&this->actor, 0.01f); if (globalCtx->sceneNum == SCENE_SYATEKI_MORI) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gObjectShnSkel, &object_shn_Anim_00DFEC, this->jointTable, - this->morphTable, OBJECT_SHN_LIMB_MAX); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gBurlyGuySkel, &gSwampShootingGalleryManHeadScratchLoopAnim, + this->jointTable, this->morphTable, BURLY_GUY_LIMB_MAX); } else { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gObjectShnSkel, &object_shn_Anim_00D9D0, this->jointTable, - this->morphTable, OBJECT_SHN_LIMB_MAX); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gBurlyGuySkel, &gBurlyGuyHandsOnTableAnim, this->jointTable, + this->morphTable, BURLY_GUY_LIMB_MAX); } this->actor.colChkInfo.cylRadius = 100; @@ -154,8 +153,8 @@ void EnSyatekiMan_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_284 = 0; this->unk_194 = 0; this->unk_282 = 0; - this->unk_264 = 0; - this->unk_266 = 0; + this->eyeIndex = 0; + this->blinkTimer = 0; if (globalCtx->sceneNum == SCENE_SYATEKI_MORI) { this->path = sp34; @@ -164,7 +163,7 @@ void EnSyatekiMan_Init(Actor* thisx, GlobalContext* globalCtx) { } void EnSyatekiMan_Destroy(Actor* thisx, GlobalContext* globalCtx) { - gSaveContext.weekEventReg[63] &= (u8)~1; + gSaveContext.save.weekEventReg[63] &= (u8)~1; } s32 func_809C6720(GlobalContext* globalCtx, Vec3f arg1) { @@ -252,13 +251,13 @@ void func_809C6848(EnSyatekiMan* this, GlobalContext* globalCtx) { void func_809C6A04(EnSyatekiMan* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (globalCtx->msgCtx.choiceIndex == 0) { if (!CUR_UPG_VALUE(UPG_QUIVER)) { play_sound(NA_SE_SY_ERROR); Message_StartTextbox(globalCtx, 0xA30, &this->actor); this->unk_284 = 0xA30; - } else if (gSaveContext.rupees < 20) { + } else if (gSaveContext.save.playerData.rupees < 20) { play_sound(NA_SE_SY_ERROR); Message_StartTextbox(globalCtx, 0xA31, &this->actor); this->unk_284 = 0xA31; @@ -269,8 +268,8 @@ void func_809C6A04(EnSyatekiMan* this, GlobalContext* globalCtx) { } else { func_8019F208(); func_801159EC(-20); - gSaveContext.weekEventReg[63] |= 1; - gSaveContext.weekEventReg[63] &= (u8)~2; + gSaveContext.save.weekEventReg[63] |= 1; + gSaveContext.save.weekEventReg[63] &= (u8)~2; globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; this->unk_26A = 7; @@ -309,7 +308,7 @@ void func_809C6A04(EnSyatekiMan* this, GlobalContext* globalCtx) { void func_809C6C2C(EnSyatekiMan* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->unk_284) { case 0xA28: case 0xA29: @@ -332,11 +331,11 @@ void func_809C6C2C(EnSyatekiMan* this, GlobalContext* globalCtx) { break; case 0xA32: - if (gSaveContext.weekEventReg[63] & 2) { + if (gSaveContext.save.weekEventReg[63] & 2) { func_801477B4(globalCtx); player->stateFlags1 &= ~0x20; - gSaveContext.weekEventReg[63] &= (u8)~1; - gSaveContext.weekEventReg[63] &= (u8)~2; + gSaveContext.save.weekEventReg[63] &= (u8)~1; + gSaveContext.save.weekEventReg[63] &= (u8)~2; this->actionFunc = func_809C6848; gSaveContext.minigameState = 3; this->unk_26A = 0; @@ -387,12 +386,12 @@ void func_809C6E30(EnSyatekiMan* this, GlobalContext* globalCtx) { break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; player->stateFlags1 &= ~0x20; - gSaveContext.weekEventReg[63] &= (u8)~1; - gSaveContext.weekEventReg[63] &= (u8)~2; + gSaveContext.save.weekEventReg[63] &= (u8)~1; + gSaveContext.save.weekEventReg[63] &= (u8)~2; this->actionFunc = func_809C6848; this->unk_26A = 0; } @@ -408,7 +407,7 @@ void func_809C6E30(EnSyatekiMan* this, GlobalContext* globalCtx) { break; } - if (this->skelAnime.animation == &object_shn_Anim_00D2F8) { + if (this->skelAnime.animation == &gSwampShootingGalleryManHeadScratchEndAnim) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); } @@ -416,7 +415,7 @@ void func_809C6E30(EnSyatekiMan* this, GlobalContext* globalCtx) { } void func_809C6F98(EnSyatekiMan* this, GlobalContext* globalCtx) { - switch (gSaveContext.playerForm) { + switch (gSaveContext.save.playerForm) { case PLAYER_FORM_HUMAN: Flags_SetAllTreasure(globalCtx, Flags_GetAllTreasure(globalCtx) + 1); if (CURRENT_DAY != 3) { @@ -519,7 +518,7 @@ void func_809C72D8(EnSyatekiMan* this, GlobalContext* globalCtx) { void func_809C7380(EnSyatekiMan* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (globalCtx->msgCtx.choiceIndex == 0) { if (!CUR_UPG_VALUE(UPG_QUIVER)) { play_sound(NA_SE_SY_ERROR); @@ -530,7 +529,7 @@ void func_809C7380(EnSyatekiMan* this, GlobalContext* globalCtx) { Message_StartTextbox(globalCtx, 0x3FA, &this->actor); this->unk_284 = 0x3FA; } - } else if (gSaveContext.rupees < 20) { + } else if (gSaveContext.save.playerData.rupees < 20) { play_sound(NA_SE_SY_ERROR); if (CURRENT_DAY != 3) { Message_StartTextbox(globalCtx, 0x3FB, &this->actor); @@ -557,8 +556,8 @@ void func_809C7380(EnSyatekiMan* this, GlobalContext* globalCtx) { Message_StartTextbox(globalCtx, 0x3FF, &this->actor); this->unk_284 = 0x3FF; } - gSaveContext.weekEventReg[63] |= 1; - gSaveContext.weekEventReg[63] &= (u8)~2; + gSaveContext.save.weekEventReg[63] |= 1; + gSaveContext.save.weekEventReg[63] &= (u8)~2; } } else { func_8019F230(); @@ -582,7 +581,7 @@ void func_809C7380(EnSyatekiMan* this, GlobalContext* globalCtx) { void func_809C7620(EnSyatekiMan* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->unk_284) { case 0x3E8: case 0x3E9: @@ -633,8 +632,8 @@ void func_809C7620(EnSyatekiMan* this, GlobalContext* globalCtx) { player->actor.freezeTimer = 0; this->unk_26A = 7; player->stateFlags1 |= 0x20; - gSaveContext.weekEventReg[63] |= 1; - gSaveContext.weekEventReg[63] &= (u8)~2; + gSaveContext.save.weekEventReg[63] |= 1; + gSaveContext.save.weekEventReg[63] &= (u8)~2; this->actionFunc = func_809C8710; } break; @@ -653,10 +652,10 @@ void func_809C7620(EnSyatekiMan* this, GlobalContext* globalCtx) { break; case 0x401: - if (gSaveContext.weekEventReg[63] & 2) { + if (gSaveContext.save.weekEventReg[63] & 2) { func_801477B4(globalCtx); - gSaveContext.weekEventReg[63] &= (u8)~1; - gSaveContext.weekEventReg[63] &= (u8)~2; + gSaveContext.save.weekEventReg[63] &= (u8)~1; + gSaveContext.save.weekEventReg[63] &= (u8)~2; this->unk_26A = 0; this->actionFunc = func_809C72D8; } else { @@ -666,10 +665,10 @@ void func_809C7620(EnSyatekiMan* this, GlobalContext* globalCtx) { break; case 0x403: - if (gSaveContext.weekEventReg[63] & 2) { + if (gSaveContext.save.weekEventReg[63] & 2) { func_801477B4(globalCtx); - gSaveContext.weekEventReg[63] &= (u8)~1; - gSaveContext.weekEventReg[63] &= (u8)~2; + gSaveContext.save.weekEventReg[63] &= (u8)~1; + gSaveContext.save.weekEventReg[63] &= (u8)~2; this->unk_26A = 0; this->actionFunc = func_809C72D8; } else { @@ -721,9 +720,9 @@ void func_809C7990(EnSyatekiMan* this, GlobalContext* globalCtx) { break; case 6: - if (func_80147624(globalCtx)) { - gSaveContext.weekEventReg[63] &= (u8)~1; - gSaveContext.weekEventReg[63] &= (u8)~2; + if (Message_ShouldAdvance(globalCtx)) { + gSaveContext.save.weekEventReg[63] &= (u8)~1; + gSaveContext.save.weekEventReg[63] &= (u8)~2; player->stateFlags1 &= ~0x20; this->actionFunc = func_809C72D8; this->unk_26A = 0; @@ -745,19 +744,19 @@ void func_809C7A90(EnSyatekiMan* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (Actor_HasParent(&this->actor, globalCtx)) { - if (!(gSaveContext.weekEventReg[59] & 0x10)) { - gSaveContext.weekEventReg[59] |= 0x10; - } else if (!(gSaveContext.weekEventReg[32] & 2) && (this->unk_280 >= 0x884)) { - gSaveContext.weekEventReg[32] |= 2; + if (!(gSaveContext.save.weekEventReg[59] & 0x10)) { + gSaveContext.save.weekEventReg[59] |= 0x10; + } else if (!(gSaveContext.save.weekEventReg[32] & 2) && (this->unk_280 >= 0x884)) { + gSaveContext.save.weekEventReg[32] |= 2; } this->actor.parent = NULL; this->actionFunc = func_809C7C14; } else { - if ((CUR_UPG_VALUE(UPG_QUIVER) < 3) && !(gSaveContext.weekEventReg[59] & 0x10)) { + if ((CUR_UPG_VALUE(UPG_QUIVER) < 3) && !(gSaveContext.save.weekEventReg[59] & 0x10)) { Actor_PickUp(&this->actor, globalCtx, GI_QUIVER_30 + CUR_UPG_VALUE(UPG_QUIVER), 500.0f, 100.0f); } else if (this->unk_280 < 0x884) { Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_RED, 500.0f, 100.0f); - } else if (!(gSaveContext.weekEventReg[32] & 2)) { + } else if (!(gSaveContext.save.weekEventReg[32] & 2)) { Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 500.0f, 100.0f); } else { Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_PURPLE, 500.0f, 100.0f); @@ -774,7 +773,7 @@ void func_809C7C14(EnSyatekiMan* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - if ((CURRENT_DAY == 3) && (gSaveContext.time > CLOCK_TIME(12, 00))) { + if ((CURRENT_DAY == 3) && (gSaveContext.save.time > CLOCK_TIME(12, 0))) { Message_StartTextbox(globalCtx, 0xA36, &this->actor); this->unk_284 = 0xA36; } else { @@ -796,26 +795,26 @@ void func_809C7D14(EnSyatekiMan* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { if (this->unk_284 == 0x407) { - if (!(gSaveContext.weekEventReg[59] & 0x20)) { - gSaveContext.weekEventReg[59] |= 0x20; + if (!(gSaveContext.save.weekEventReg[59] & 0x20)) { + gSaveContext.save.weekEventReg[59] |= 0x20; } } if ((this->unk_284 == 0x405) || (this->unk_284 == 0x406)) { - if (!(gSaveContext.weekEventReg[32] & 4)) { - gSaveContext.weekEventReg[32] |= 4; + if (!(gSaveContext.save.weekEventReg[32] & 4)) { + gSaveContext.save.weekEventReg[32] |= 4; } } this->actor.parent = NULL; this->actionFunc = func_809C7EB4; } else { if (this->unk_284 == 0x407) { - if ((CUR_UPG_VALUE(UPG_QUIVER) < 3) && !(gSaveContext.weekEventReg[59] & 0x20)) { + if ((CUR_UPG_VALUE(UPG_QUIVER) < 3) && !(gSaveContext.save.weekEventReg[59] & 0x20)) { Actor_PickUp(&this->actor, globalCtx, GI_QUIVER_30 + CUR_UPG_VALUE(UPG_QUIVER), 500.0f, 100.0f); } else { Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_PURPLE, 500.0f, 100.0f); } - } else if (!(gSaveContext.weekEventReg[32] & 4)) { + } else if (!(gSaveContext.save.weekEventReg[32] & 4)) { Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 500.0f, 100.0f); } else { Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_HUGE, 500.0f, 100.0f); @@ -832,12 +831,12 @@ void func_809C7EB4(EnSyatekiMan* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (CURRENT_DAY != 3) { - if ((Message_GetState(&globalCtx->msgCtx) == 6) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 6) && Message_ShouldAdvance(globalCtx)) { player->stateFlags1 &= ~0x20; this->unk_280 = 0; this->unk_26A = 0; - gSaveContext.weekEventReg[63] &= (u8)~1; - gSaveContext.weekEventReg[63] &= (u8)~2; + gSaveContext.save.weekEventReg[63] &= (u8)~1; + gSaveContext.save.weekEventReg[63] &= (u8)~2; this->actionFunc = func_809C6810; } } else if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { @@ -974,8 +973,8 @@ void func_809C8488(EnSyatekiMan* this, GlobalContext* globalCtx) { this->unk_274 = 0; this->unk_276 = 0; if (this->unk_270 <= 0) { - if ((s32)((gSaveContext.unk_EF4 & 0xFFFF0000) >> 0x10) < this->unk_280) { - gSaveContext.unk_EF4 = ((gSaveContext.unk_EF4) & 0xFFFF) | ((u16)this->unk_280 << 0x10); + if ((s32)((gSaveContext.save.unk_EF4 & 0xFFFF0000) >> 0x10) < this->unk_280) { + gSaveContext.save.unk_EF4 = ((gSaveContext.save.unk_EF4) & 0xFFFF) | ((u16)this->unk_280 << 0x10); } this->unk_270 = 15; if (this->unk_280 >= 0x848) { @@ -983,9 +982,9 @@ void func_809C8488(EnSyatekiMan* this, GlobalContext* globalCtx) { this->unk_284 = 0xA34; this->unk_26A = 6; } else if (this->unk_280 >= 0x7D0) { - if (gSaveContext.weekEventReg[63] & 2) { - gSaveContext.weekEventReg[63] &= (u8)~1; - gSaveContext.weekEventReg[63] &= (u8)~2; + if (gSaveContext.save.weekEventReg[63] & 2) { + gSaveContext.save.weekEventReg[63] &= (u8)~1; + gSaveContext.save.weekEventReg[63] &= (u8)~2; this->unk_26A = 0; gSaveContext.minigameState = 3; this->actionFunc = func_809C6848; @@ -1039,7 +1038,7 @@ void func_809C8610(EnSyatekiMan* this, GlobalContext* globalCtx) { void func_809C8710(EnSyatekiMan* this, GlobalContext* globalCtx) { Vec3f sp24; - if (gSaveContext.playerForm == PLAYER_FORM_FIERCE_DEITY) { + if (gSaveContext.save.playerForm == PLAYER_FORM_FIERCE_DEITY) { sp24 = D_809C9480; } else { sp24 = D_809C948C; @@ -1164,9 +1163,9 @@ void func_809C8BF0(EnSyatekiMan* this, GlobalContext* globalCtx) { if ((this->unk_270 <= 0) && (globalCtx->interfaceCtx.unk_286 == 0)) { Flags_SetAllTreasure(globalCtx, this->unk_280); this->unk_270 = 15; - if (((s32)(gSaveContext.unk_EF4 & 0xFFFF) < this->unk_280) || (this->unk_280 == 50)) { - if ((s32)(gSaveContext.unk_EF4 & 0xFFFF) < this->unk_280) { - if (!(gSaveContext.weekEventReg[59] & 0x20)) { + if (((s32)(gSaveContext.save.unk_EF4 & 0xFFFF) < this->unk_280) || (this->unk_280 == 50)) { + if ((s32)(gSaveContext.save.unk_EF4 & 0xFFFF) < this->unk_280) { + if (!(gSaveContext.save.weekEventReg[59] & 0x20)) { Message_StartTextbox(globalCtx, 0x407, &this->actor); this->unk_284 = 0x407; } else if (this->unk_280 == 50) { @@ -1180,7 +1179,7 @@ void func_809C8BF0(EnSyatekiMan* this, GlobalContext* globalCtx) { Message_StartTextbox(globalCtx, 0x406, &this->actor); this->unk_284 = 0x406; } - gSaveContext.unk_EF4 = (gSaveContext.unk_EF4 & 0xFFFF0000) | (this->unk_280 & 0xFFFF); + gSaveContext.save.unk_EF4 = (gSaveContext.save.unk_EF4 & 0xFFFF0000) | (this->unk_280 & 0xFFFF); this->unk_26A = 6; } else { if (CURRENT_DAY != 3) { @@ -1203,32 +1202,32 @@ void func_809C8BF0(EnSyatekiMan* this, GlobalContext* globalCtx) { } } -void func_809C8DE8(EnSyatekiMan* this) { - switch (this->unk_266) { +void EnSyatekiMan_Blink(EnSyatekiMan* this) { + switch (this->blinkTimer) { case 1: - this->unk_264 = 2; + this->eyeIndex = 2; break; case 2: - this->unk_264 = 1; + this->eyeIndex = 1; break; case 40: - this->unk_266 = 0; + this->blinkTimer = 0; default: - this->unk_264 = 0; + this->eyeIndex = 0; break; } - this->unk_266++; + this->blinkTimer++; } void EnSyatekiMan_Update(Actor* thisx, GlobalContext* globalCtx) { EnSyatekiMan* this = THIS; this->actionFunc(this, globalCtx); - func_809C8DE8(this); + EnSyatekiMan_Blink(this); this->actor.focus.pos.y = 70.0f; Actor_SetFocus(&this->actor, 70.0f); if (this->unk_26A != 1) { @@ -1241,16 +1240,16 @@ s32 EnSyatekiMan_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** Actor* thisx) { EnSyatekiMan* this = THIS; - if ((globalCtx->sceneNum == SCENE_SYATEKI_MIZU) && (limbIndex == 15)) { - *dList = object_shn_DL_00F2D0; + if ((globalCtx->sceneNum == SCENE_SYATEKI_MIZU) && (limbIndex == BURLY_GUY_LIMB_HEAD)) { + *dList = gTownShootingGalleryManHeadDL; } - if (limbIndex == 15) { + if (limbIndex == BURLY_GUY_LIMB_HEAD) { Matrix_InsertTranslation(3000.0f, 0.0f, 0.0f, MTXMODE_APPLY); Matrix_InsertZRotation_s(this->unk_258.x, MTXMODE_APPLY); Matrix_InsertXRotation_s(this->unk_258.y, MTXMODE_APPLY); Matrix_InsertTranslation(-3000.0f, 0.0f, 0.0f, MTXMODE_APPLY); - } else if (limbIndex == 8) { + } else if (limbIndex == BURLY_GUY_LIMB_TORSO) { Matrix_InsertXRotation_s(-this->unk_25E.y, MTXMODE_APPLY); } @@ -1261,36 +1260,36 @@ void EnSyatekiMan_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dL EnSyatekiMan* this = THIS; Vec3f sp18 = { 1600.0f, 0.0f, 0.0f }; - if (limbIndex == 15) { + if (limbIndex == BURLY_GUY_LIMB_HEAD) { Matrix_MultiplyVector3fByState(&sp18, &this->actor.focus.pos); } } void EnSyatekiMan_Draw(Actor* thisx, GlobalContext* globalCtx) { - static TexturePtr D_809C94B8[] = { - object_shn_Tex_005AC8, - object_shn_Tex_0062C8, - object_shn_Tex_0062C8, + static TexturePtr sEyeTextures[] = { + gSwampShootingGalleryManEyeOpenTex, + gSwampShootingGalleryManEyeHalfTex, + gSwampShootingGalleryManEyeHalfTex, }; EnSyatekiMan* this = THIS; s32 pad; if (globalCtx->sceneNum == SCENE_SYATEKI_MIZU) { - D_809C94B8[0] = object_shn_Tex_00FB90; - D_809C94B8[1] = object_shn_Tex_010390; - D_809C94B8[2] = object_shn_Tex_010390; + sEyeTextures[0] = gTownShootingGalleryManEyeOpenTex; + sEyeTextures[1] = gTownShootingGalleryManEyeClosedTex; + sEyeTextures[2] = gTownShootingGalleryManEyeClosedTex; } else { - D_809C94B8[0] = object_shn_Tex_005AC8; - D_809C94B8[1] = object_shn_Tex_0062C8; - D_809C94B8[2] = object_shn_Tex_0062C8; + sEyeTextures[0] = gSwampShootingGalleryManEyeOpenTex; + sEyeTextures[1] = gSwampShootingGalleryManEyeHalfTex; + sEyeTextures[2] = gSwampShootingGalleryManEyeHalfTex; } OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C5B0(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_809C94B8[this->unk_264])); - gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_809C94B8[this->unk_264])); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeIndex])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(sEyeTextures[this->eyeIndex])); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnSyatekiMan_OverrideLimbDraw, EnSyatekiMan_PostLimbDraw, &this->actor); diff --git a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.h b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.h index 80f2a10687..16585ac841 100644 --- a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.h +++ b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.h @@ -2,6 +2,8 @@ #define Z_EN_SYATEKI_MAN_H #include "global.h" +#include "objects/object_shn/object_shn.h" + struct EnSyatekiMan; @@ -24,12 +26,12 @@ typedef struct EnSyatekiMan { /* 0x018C */ Path* path; /* 0x0190 */ s32 unk_190; /* 0x0194 */ s32 unk_194; - /* 0x0198 */ Vec3s jointTable[16]; - /* 0x01F8 */ Vec3s morphTable[16]; + /* 0x0198 */ Vec3s jointTable[BURLY_GUY_LIMB_MAX]; + /* 0x01F8 */ Vec3s morphTable[BURLY_GUY_LIMB_MAX]; /* 0x0258 */ Vec3s unk_258; /* 0x025E */ Vec3s unk_25E; - /* 0x0264 */ s16 unk_264; - /* 0x0266 */ s16 unk_266; + /* 0x0264 */ s16 eyeIndex; + /* 0x0266 */ s16 blinkTimer; /* 0x0268 */ UNK_TYPE1 unk268[0x2]; /* 0x026A */ s16 unk_26A; /* 0x026C */ s16 unk_26C; diff --git a/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.c b/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.c index cffef2fc95..617577884f 100644 --- a/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.c +++ b/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.c @@ -5,6 +5,7 @@ */ #include "z_en_syateki_okuta.h" +#include "overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_8000000) @@ -15,14 +16,18 @@ void EnSyatekiOkuta_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnSyatekiOkuta_Update(Actor* thisx, GlobalContext* globalCtx); void EnSyatekiOkuta_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80A36260(EnSyatekiOkuta* this); void func_80A362A8(EnSyatekiOkuta* this, GlobalContext* globalCtx); +void func_80A362F8(EnSyatekiOkuta* this); void func_80A36350(EnSyatekiOkuta* this, GlobalContext* globalCtx); void func_80A363B4(EnSyatekiOkuta* this, GlobalContext* globalCtx); +void func_80A36444(EnSyatekiOkuta* this); void func_80A36488(EnSyatekiOkuta* this, GlobalContext* globalCtx); +void func_80A364C0(EnSyatekiOkuta* this); void func_80A36504(EnSyatekiOkuta* this, GlobalContext* globalCtx); void func_80A365EC(EnSyatekiOkuta* this, GlobalContext* globalCtx); +void func_80A36CB0(EnSyatekiOkuta* this); -#if 0 const ActorInit En_Syateki_Okuta_InitVars = { ACTOR_EN_SYATEKI_OKUTA, ACTORCAT_ENEMY, @@ -35,72 +40,483 @@ const ActorInit En_Syateki_Okuta_InitVars = { (ActorFunc)EnSyatekiOkuta_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A37570 = { - { COLTYPE_HIT3, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT3, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 20, 40, -30, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80A37B88[] = { +static AnimationInfo sAnimations[] = { + { &gOctorokShootAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &gOctorokDieAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &gOctorokHideAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &gOctorokFloatAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -1.0f }, + { &gOctorokAppearAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &gOctorokHitAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, +}; + +#include "assets/overlays/ovl_En_Syateki_Okuta/ovl_En_Syateki_Okuta.c" + +static InitChainEntry sInitChain[] = { ICHAIN_S8(hintId, 66, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 6500, ICHAIN_STOP), }; -#endif +Color_RGBA8 D_80A37B90 = { 255, 255, 255, 255 }; -extern ColliderCylinderInit D_80A37570; -extern InitChainEntry D_80A37B88[]; +Color_RGBA8 D_80A37B94 = { 150, 150, 150, 255 }; -extern UNK_TYPE D_0600466C; +Vec3f D_80A37B98 = { 0.0f, -0.5, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/EnSyatekiOkuta_Init.s") +Color_RGBA8 D_80A37BA4 = { 255, 255, 255, 255 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/EnSyatekiOkuta_Destroy.s") +Color_RGBA8 D_80A37BA8 = { 150, 150, 150, 0 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A36148.s") +void EnSyatekiOkuta_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnSyatekiOkuta* this = THIS; + WaterBox* waterbox; + f32 ySurface; + s32 bgId; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A361B0.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + SkelAnime_Init(globalCtx, &this->skelAnime, &gOctorokSkel, &gOctorokAppearAnim, this->jointTable, this->morphTable, + OCTOROK_LIMB_MAX); + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A361F4.s") + this->actor.floorHeight = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->actor.floorPoly, &bgId, + &this->actor, &this->actor.world.pos); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A36260.s") + if (!(WaterBox_GetSurface1_2(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &ySurface, &waterbox)) || + (ySurface <= this->actor.floorHeight)) { + Actor_MarkForDeath(&this->actor); + } else { + this->actor.world.pos.y = this->actor.home.pos.y = ySurface; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A362A8.s") + this->unk_2A4 = 0; + this->unk_2AA = 0; + func_80A36260(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A362F8.s") +void EnSyatekiOkuta_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnSyatekiOkuta* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A36350.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A36360.s") +void func_80A36148(Vec3f* pos, Vec3f* velocity, s16 scaleStep, GlobalContext* globalCtx) { + func_800B0DE0(globalCtx, pos, velocity, &gZeroVec3f, &D_80A37B90, &D_80A37B94, 400, scaleStep); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A363B4.s") +void func_80A361B0(EnSyatekiOkuta* this, GlobalContext* globalCtx) { + EffectSsGSplash_Spawn(globalCtx, &this->actor.home.pos, NULL, NULL, 0, 800); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A36444.s") +s32 func_80A361F4(EnSyatekiOkuta* this) { + s32 temp_a0; + s32 temp_a1; + s32 temp_v1; + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A36488.s") + temp_v1 = EN_SYATEKI_OKUTA_GET_F(&this->actor); + if ((temp_v1 == 1) || (temp_v1 == 4)) { + temp_a0 = syatekiMan->unk_190; + temp_a1 = (temp_v1 * 2) + 6; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A364C0.s") + if ((temp_a0 >> temp_a1) & 3) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A36504.s") + if ((temp_a1 == 8) && ((temp_a0 >> 0xE) & 3)) { + return true; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A3657C.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A365EC.s") +void func_80A36260(EnSyatekiOkuta* this) { + Animation_PlayOnceSetSpeed(&this->skelAnime, &gOctorokAppearAnim, 0.0f); + this->actor.draw = NULL; + this->actionFunc = func_80A362A8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A368E0.s") +void func_80A362A8(EnSyatekiOkuta* this, GlobalContext* globalCtx) { + Actor* actorIt = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A36A90.s") + while (actorIt != NULL) { + if (actorIt->id == ACTOR_EN_SYATEKI_MAN) { + this->actor.parent = actorIt; + func_80A362F8(this); + break; + } else { + actorIt = actorIt->next; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A36AF8.s") +void func_80A362F8(EnSyatekiOkuta* this) { + Animation_PlayOnceSetSpeed(&this->skelAnime, &gOctorokAppearAnim, 0.0f); + this->actor.draw = NULL; + Actor_SetScale(&this->actor, 0.01f); + this->actionFunc = func_80A36350; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/EnSyatekiOkuta_Update.s") +void func_80A36350(EnSyatekiOkuta* this, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A36CB0.s") +void func_80A36360(EnSyatekiOkuta* this) { + this->actor.draw = EnSyatekiOkuta_Draw; + this->unk_2AA = 0; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 4); + this->actionFunc = func_80A363B4; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A370EC.s") +void func_80A363B4(EnSyatekiOkuta* this, GlobalContext* globalCtx) { + if ((Animation_OnFrame(&this->skelAnime, 2.0f)) || (Animation_OnFrame(&this->skelAnime, 15.0f))) { + if (func_80A361F4(this)) { + return; + } else { + func_80A361B0(this, globalCtx); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_OCTAROCK_JUMP); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A37294.s") + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + func_80A36444(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/EnSyatekiOkuta_Draw.s") +void func_80A36444(EnSyatekiOkuta* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); + this->actionFunc = func_80A36488; +} + +void func_80A36488(EnSyatekiOkuta* this, GlobalContext* globalCtx) { + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; + + if (syatekiMan->unk_26C >= 0x46) { + func_80A364C0(this); + } +} + +void func_80A364C0(EnSyatekiOkuta* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + this->actionFunc = func_80A36504; +} + +void func_80A36504(EnSyatekiOkuta* this, GlobalContext* globalCtx) { + if (Animation_OnFrame(&this->skelAnime, 4.0f)) { + func_80A361B0(this, globalCtx); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DAIOCTA_LAND); + } else if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + func_80A362F8(this); + } +} + +void func_80A3657C(EnSyatekiOkuta* this) { + this->unk_2A4 = 0; + this->unk_2AA = 300; + if (this->unk_2A6 == 1) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_OCTAROCK_DEAD1); + } + + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + this->actionFunc = func_80A365EC; +} + +void func_80A365EC(EnSyatekiOkuta* this, GlobalContext* globalCtx) { + Vec3f sp84; + Vec3f sp78; + s32 pad; + s32 i; + + if (this->unk_2AA > 0) { + this->unk_2AA -= 15; + } + + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + if (this->unk_2A4 == 0) { + sp78.x = this->actor.world.pos.x; + sp78.y = this->actor.world.pos.y + 40.0f; + sp78.z = this->actor.world.pos.z; + sp84.x = 0.0f; + sp84.y = -0.5f; + sp84.z = 0.0f; + func_80A36148(&sp78, &sp84, -20, globalCtx); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_OCTAROCK_DEAD2); + } + + this->unk_2A4++; + } + + if (Animation_OnFrame(&this->skelAnime, 15.0f)) { + func_80A361B0(this, globalCtx); + } + + if (this->unk_2A4 < 3) { + Actor_SetScale(&this->actor, ((this->unk_2A4 * 0.25f) + 1.0f) * 0.01f); + } else if (this->unk_2A4 < 6) { + Actor_SetScale(&this->actor, (1.5f - ((this->unk_2A4 - 2) * 0.2333f)) * 0.01f); + } else if (this->unk_2A4 < 11) { + Actor_SetScale(&this->actor, (((this->unk_2A4 - 5) * 0.04f) + 0.8f) * 0.01f); + } else { + if (Math_StepToF(&this->actor.scale.x, 0.0f, 0.002f)) { + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 30, NA_SE_EN_COMMON_WATER_MID); + for (i = 0; i < 10; i++) { + sp84.x = (Rand_ZeroOne() - 0.5f) * 7.0f; + sp84.y = Rand_ZeroOne() * 7.0f; + sp84.z = (Rand_ZeroOne() - 0.5f) * 7.0f; + EffectSsDtBubble_SpawnCustomColor(globalCtx, &this->actor.world.pos, &sp84, &D_80A37B98, &D_80A37BA4, + &D_80A37BA8, Rand_S16Offset(100, 50), 25, 0); + } + + func_80A362F8(this); + } + + this->actor.scale.y = this->actor.scale.x; + this->actor.scale.z = this->actor.scale.x; + } +} + +void func_80A368E0(EnSyatekiOkuta* this, GlobalContext* globalCtx) { + this->collider.dim.height = + (sCylinderInit.dim.height - this->collider.dim.yShift) * this->unk_1D8.y * this->actor.scale.y * 100.0f; + this->collider.dim.radius = sCylinderInit.dim.radius * this->actor.scale.x * 100.0f; + + if (this->actionFunc == func_80A363B4) { + if ((this->unk_2A6 == 2) && func_80A361F4(this)) { + return; + } + + if (this->skelAnime.curFrame < (this->skelAnime.endFrame - 5.0f)) { + this->collider.dim.height *= 1.35f; + } + } + + if (this->unk_2A6 == 1) { + this->collider.dim.radius += 10; + this->collider.dim.height += 15; + } + + this->collider.dim.pos.x = this->actor.world.pos.x; + // jointTable->y is the y-translation of the skeleton root + this->collider.dim.pos.y = this->actor.world.pos.y + (this->skelAnime.jointTable->y * this->actor.scale.y); + this->collider.dim.pos.z = this->actor.world.pos.z; + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +s32 func_80A36A90(EnSyatekiOkuta* this, GlobalContext* globalCtx) { + if ((this->actionFunc == func_80A365EC) || (this->actionFunc == func_80A36350)) { + return false; + } + + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + return true; + } + + func_80A368E0(this, globalCtx); + return false; +} + +void func_80A36AF8(EnSyatekiOkuta* this, GlobalContext* globalCtx) { + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; + s16 temp_v1_2; + + if ((this->actionFunc != func_80A36488) && (this->actionFunc != func_80A363B4) && (syatekiMan->unk_26A == 1) && + (syatekiMan->unk_26C == 0)) { + temp_v1_2 = (syatekiMan->unk_190 >> (EN_SYATEKI_OKUTA_GET_F(&this->actor) * 2)) & 3; + if (temp_v1_2 > 0) { + Actor_SetScale(&this->actor, 0.01f); + this->unk_2A6 = temp_v1_2; + func_80A36360(this); + } + } +} + +void EnSyatekiOkuta_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnSyatekiOkuta* this = THIS; + EnSyatekiMan* syatekiMan; + + this->actionFunc(this, globalCtx); + + if (this->actionFunc != func_80A36350) { + SkelAnime_Update(&this->skelAnime); + } + + func_80A36AF8(this, globalCtx); + + if (func_80A36A90(this, globalCtx)) { + syatekiMan = (EnSyatekiMan*)this->actor.parent; + if (this->unk_2A6 == 1) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); + globalCtx->interfaceCtx.unk_25C++; + syatekiMan->unk_280++; + syatekiMan->unk_26E = 1; + } else { + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_ERROR); + syatekiMan->unk_26E = 2; + } + + func_80A3657C(this); + } else { + this->collider.base.acFlags &= ~AC_HIT; + } + + func_80A36CB0(this); +} + +void func_80A36CB0(EnSyatekiOkuta* this) { + f32 curFrame = this->skelAnime.curFrame; + + if (this->actionFunc == func_80A363B4) { + if (curFrame < 8.0f) { + this->unk_1D8.x = this->unk_1D8.y = this->unk_1D8.z = 1.0f; + } else if (curFrame < 10.0f) { + this->unk_1D8.x = this->unk_1D8.z = 1.0f; + this->unk_1D8.y = ((curFrame - 7.0f) * 0.4f) + 1.0f; + } else if (curFrame < 14.0f) { + this->unk_1D8.x = this->unk_1D8.z = ((curFrame - 9.0f) * 0.075f) + 1.0f; + this->unk_1D8.y = 1.8f - ((curFrame - 9.0f) * 0.25f); + } else { + this->unk_1D8.x = this->unk_1D8.z = 1.3f - ((curFrame - 13.0f) * 0.05f); + this->unk_1D8.y = ((curFrame - 13.0f) * 0.0333f) + 0.8f; + } + } else if (this->actionFunc == func_80A36488) { + this->unk_1D8.x = this->unk_1D8.z = 1.0f; + this->unk_1D8.y = (sin_rad((M_PI / 16) * curFrame) * 0.2f) + 1.0f; + } else if (this->actionFunc == func_80A36504) { + if (curFrame < 3.0f) { + this->unk_1D8.y = 1.0f; + } else if (curFrame < 4.0f) { + this->unk_1D8.y = (curFrame - 2.0f) + 1.0f; + } else { + this->unk_1D8.y = 2.0f - ((curFrame - 3.0f) * 0.333f); + } + this->unk_1D8.x = this->unk_1D8.z = 1.0f; + } else if (this->actionFunc == func_80A365EC) { + curFrame += this->unk_2A4; + if (curFrame >= 35.0f) { + this->unk_1D8.x = this->unk_1D8.y = this->unk_1D8.z = 1.0f; + } else if (curFrame < 4.0f) { + this->unk_1D8.x = this->unk_1D8.z = 1.0f - (curFrame * 0.0666f); + this->unk_1D8.y = (curFrame * 0.1666f) + 1.0f; + } else if (curFrame < 25.0f) { + this->unk_1D8.x = this->unk_1D8.z = ((curFrame - 4.0f) * 0.01f) + 0.8f; + this->unk_1D8.y = 1.5f - ((curFrame - 4.0f) * 0.025f); + } else if (curFrame < 27.0f) { + this->unk_1D8.x = this->unk_1D8.y = this->unk_1D8.z = ((curFrame - 24.0f) * 0.25f) + 1.0f; + } else if (curFrame < 30.0f) { + this->unk_1D8.x = this->unk_1D8.y = this->unk_1D8.z = 1.5f - ((curFrame - 26.0f) * 0.233f); + } else { + this->unk_1D8.x = this->unk_1D8.y = this->unk_1D8.z = ((curFrame - 29.0f) * 0.04f) + 0.8f; + } + } else { + this->unk_1D8.x = this->unk_1D8.y = this->unk_1D8.z = 1.0f; + } +} + +s32 func_80A370EC(EnSyatekiOkuta* this, f32 arg1, Vec3f* arg2) { + if (this->actionFunc == func_80A363B4) { + arg2->y = 1.0f; + arg2->z = 1.0f; + arg2->x = (sin_rad((M_PI / 16) * arg1) * 0.4f) + 1.0f; + } else if (this->actionFunc == func_80A365EC) { + if ((arg1 >= 35.0f) || (arg1 < 25.0f)) { + return false; + } + + if (arg1 < 27.0f) { + arg2->z = 1.0f; + arg2->x = arg2->y = ((arg1 - 24.0f) * 0.5f) + 1.0f; + } else if (arg1 < 30.0f) { + arg2->z = (arg1 - 26.0f) * 0.333f + 1.0f; + arg2->x = arg2->y = 2.0f - (arg1 - 26.0f) * 0.333f; + } else { + arg2->z = 2.0f - ((arg1 - 29.0f) * 0.2f); + arg2->x = arg2->y = 1.0f; + } + } else { + return false; + } + + return true; +} + +s32 EnSyatekiOkuta_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + s32 pad; + Vec3f sp20; + f32 curFrame; + EnSyatekiOkuta* this = THIS; + + curFrame = this->skelAnime.curFrame; + if (this->actionFunc == func_80A365EC) { + curFrame += this->unk_2A4; + } + + if (limbIndex == OCTOROK_LIMB_HEAD) { + sp20 = this->unk_1D8; + Matrix_Scale(sp20.x, sp20.y, sp20.z, MTXMODE_APPLY); + } else if ((limbIndex == OCTOROK_LIMB_SNOUT) && (func_80A370EC(this, curFrame, &sp20))) { + Matrix_Scale(sp20.x, sp20.y, sp20.z, MTXMODE_APPLY); + } + + return false; +} + +void EnSyatekiOkuta_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnSyatekiOkuta* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + if (this->unk_2A6 == 1) { + gSPSegment(POLY_OPA_DISP++, 0x08, D_801AEFA0); + } else { + gSPSegment(POLY_OPA_DISP++, 0x08, gShootingGalleryOctorokBlueMaterialDL); + } + + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnSyatekiOkuta_OverrideLimbDraw, + NULL, &this->actor); + func_8012C2DC(globalCtx->state.gfxCtx); + if (this->actionFunc == func_80A365EC) { + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y + 30.0f, + this->actor.world.pos.z + 20.0f, 0); + + if (this->unk_2AA >= 256) { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 210, 64, 32, 255); + } else { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 210, 64, 32, this->unk_2AA); + } + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + if (this->unk_2A6 == 2) { + gSPDisplayList(POLY_XLU_DISP++, gShootingGalleryOctorokCrossDL); + } else { + gSPDisplayList(POLY_XLU_DISP++, gShootingGalleryOctorokCircleDL); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.h b/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.h index f3f569eda2..17fafe94d6 100644 --- a/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.h +++ b/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.h @@ -2,16 +2,26 @@ #define Z_EN_SYATEKI_OKUTA_H #include "global.h" +#include "objects/object_okuta/object_okuta.h" + +#define EN_SYATEKI_OKUTA_GET_F(thisx) ((thisx)->params & 0xF) struct EnSyatekiOkuta; typedef void (*EnSyatekiOkutaActionFunc)(struct EnSyatekiOkuta*, GlobalContext*); typedef struct EnSyatekiOkuta { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; - /* 0x0188 */ EnSyatekiOkutaActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x120]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnSyatekiOkutaActionFunc actionFunc; + /* 0x18C */ ColliderCylinder collider; + /* 0x1DC */ Vec3f unk_1D8; + /* 0x1E4 */ Vec3s jointTable[OCTOROK_LIMB_MAX]; + /* 0x244 */ Vec3s morphTable[OCTOROK_LIMB_MAX]; + /* 0x2A4 */ s16 unk_2A4; + /* 0x2A6 */ s16 unk_2A6; + /* 0x2A8 */ UNK_TYPE1 unk_2A8[0x2]; + /* 0x2AA */ s16 unk_2AA; } EnSyatekiOkuta; // size = 0x2AC extern const ActorInit En_Syateki_Okuta_InitVars; diff --git a/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.c b/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.c index 6e53877a36..e72cb296d2 100644 --- a/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.c +++ b/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.c @@ -6,7 +6,6 @@ #include "z_en_syateki_wf.h" #include "overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.h" -#include "objects/object_wf/object_wf.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_8000000) @@ -115,13 +114,13 @@ const ActorInit En_Syateki_Wf_InitVars = { }; static AnimationInfo sAnimations[] = { - { &object_wf_Anim_00A3CC, 2.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -1.0f }, - { &object_wf_Anim_005700, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, - { &object_wf_Anim_005700, 1.0f, 0.0f, 4.0f, ANIMMODE_ONCE, 1.0f }, - { &object_wf_Anim_005700, 1.0f, 4.0f, 8.0f, ANIMMODE_ONCE, 1.0f }, - { &object_wf_Anim_004A90, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, - { &object_wf_Anim_009A50, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 8.0f }, - { &object_wf_Anim_0053D0, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &gWolfosWaitingAnim, 2.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -1.0f }, + { &gWolfosRunningAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &gWolfosRunningAnim, 1.0f, 0.0f, 4.0f, ANIMMODE_ONCE, 1.0f }, + { &gWolfosRunningAnim, 1.0f, 4.0f, 8.0f, ANIMMODE_ONCE, 1.0f }, + { &gWolfosBackflippingAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &gWolfosDamagedAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 8.0f }, + { &gWolfosRearingUpFallingOverAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, }; static InitChainEntry sInitChain[] = { @@ -134,10 +133,10 @@ static Vec3f D_80A20FC4 = { 0.0f, 0.5f, 0.0f }; static Vec3f D_80A20FD0 = { 1200.0f, 0.0f, 0.0f }; static TexturePtr sEyeTextures[] = { - object_wf_Tex_007AA8, - object_wf_Tex_0082A8, - object_wf_Tex_0084A8, - object_wf_Tex_0082A8, + gWolfosNormalEyeOpenTex, + gWolfosNormalEyeHalfTex, + gWolfosNormalEyeNarrowTex, + gWolfosNormalEyeHalfTex, }; void EnSyatekiWf_Init(Actor* thisx, GlobalContext* globalCtx) { @@ -145,16 +144,14 @@ void EnSyatekiWf_Init(Actor* thisx, GlobalContext* globalCtx) { EnSyatekiWf* this = THIS; Path* path; EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; - s32 temp; + s32 i; path = syatekiMan->path; while (path->unk2 != 2) { path = &globalCtx->setupPathList[path->unk1]; } - temp = 0; - while (temp < EN_SYATEKI_WF_GET_PARAM_FF00(&this->actor)) { - temp++; + for (i = 0; i < EN_SYATEKI_WF_GET_PARAM_FF00(&this->actor); i++) { path = &globalCtx->setupPathList[path->unk1]; } @@ -183,11 +180,11 @@ void EnSyatekiWf_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_InitCylinder(globalCtx, &this->unk_300); Collider_SetCylinder(globalCtx, &this->unk_300, &this->actor, &sCylinderInit2); Collider_InitJntSph(globalCtx, &this->unk_34C); - Collider_SetJntSph(globalCtx, &this->unk_34C, &this->actor, &sJntSphInit, &this->unk_36C); + Collider_SetJntSph(globalCtx, &this->unk_34C, &this->actor, &sJntSphInit, this->unk_36C); this->unk_34C.elements->dim.worldSphere.radius = sJntSphInit.elements[0].dim.modelSphere.radius; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_wf_Skel_0095D0, &object_wf_Anim_00A3CC, this->jointTable, - this->morphTable, 22); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gWolfosNormalSkel, &gWolfosWaitingAnim, this->jointTable, + this->morphTable, WOLFOS_NORMAL_LIMB_MAX); Actor_SetScale(&this->actor, 0.01f); this->actor.hintId = 0x4C; @@ -463,7 +460,7 @@ void EnSyatekiWf_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi Vec3f sp18; Collider_UpdateSpheres(limbIndex, &this->unk_34C); - if (limbIndex == 6) { + if (limbIndex == WOLFOS_NORMAL_LIMB_TAIL) { Matrix_MultiplyVector3fByState(&D_80A20FD0, &sp18); this->unk_300.dim.pos.x = sp18.x; this->unk_300.dim.pos.y = sp18.y; diff --git a/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.h b/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.h index 23977fa021..a43c76f778 100644 --- a/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.h +++ b/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.h @@ -2,6 +2,7 @@ #define Z_EN_SYATEKI_WF_H #include "global.h" +#include "objects/object_wf/object_wf.h" #define EN_SYATEKI_WF_GET_PARAM_F0(thisx) (((thisx)->params & 0xF0) >> 4) #define EN_SYATEKI_WF_GET_PARAM_FF00(thisx) (((thisx)->params & 0xFF00) >> 8) @@ -13,8 +14,8 @@ typedef void (*EnSyatekiWfActionFunc)(struct EnSyatekiWf*, GlobalContext*); typedef struct EnSyatekiWf { /* 0x000 */ Actor actor; /* 0x144 */ SkelAnime skelAnime; - /* 0x188 */ Vec3s jointTable[22]; - /* 0x20C */ Vec3s morphTable[22]; + /* 0x188 */ Vec3s jointTable[WOLFOS_NORMAL_LIMB_MAX]; + /* 0x20C */ Vec3s morphTable[WOLFOS_NORMAL_LIMB_MAX]; /* 0x290 */ UNK_TYPE1 unk_290[0x4]; /* 0x294 */ EnSyatekiWfActionFunc actionFunc; /* 0x298 */ s16 unk_298; @@ -29,7 +30,7 @@ typedef struct EnSyatekiWf { /* 0x2B4 */ ColliderCylinder unk_2B4; /* 0x300 */ ColliderCylinder unk_300; /* 0x34C */ ColliderJntSph unk_34C; - /* 0x36C */ ColliderJntSphElement unk_36C; + /* 0x36C */ ColliderJntSphElement unk_36C[1]; /* 0x3AC */ UNK_TYPE1 unk_3AC[0x20]; } EnSyatekiWf; // size = 0x3CC diff --git a/src/overlays/actors/ovl_En_Tab/z_en_tab.c b/src/overlays/actors/ovl_En_Tab/z_en_tab.c index a22faeb59e..f1c9c6bbce 100644 --- a/src/overlays/actors/ovl_En_Tab/z_en_tab.c +++ b/src/overlays/actors/ovl_En_Tab/z_en_tab.c @@ -20,9 +20,22 @@ void EnTab_Draw(Actor* thisx, GlobalContext* globalCtx); void func_80BE127C(EnTab* this, GlobalContext* globalCtx); void func_80BE1348(EnTab* this, GlobalContext* globalCtx); -s32 D_80BE18D0[] = { - 0x0C000320, 0x0A00151B, 0x02093212, 0x010F0212, 0x00060003, 0x0400000E, 0x12000600, 0x020E0932, 0x12010105, - 0x0A001519, 0x02093215, 0x050D0215, 0x37050501, 0x050E1537, 0x0505020E, 0x09321505, 0x01050000, +static u8 D_80BE18D0[] = { + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(3, 0x24 - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_MILK_BAR, 0x23 - 0x08), + /* 0x08 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(9, 50, 18, 1, 0x1D - 0x0E), + /* 0x0E */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(18, 0, 6, 0, 0x17 - 0x14), + /* 0x14 */ SCHEDULE_CMD_RET_VAL_L(0), + /* 0x17 */ SCHEDULE_CMD_RET_TIME(18, 0, 6, 0, 2), + /* 0x1D */ SCHEDULE_CMD_RET_TIME(9, 50, 18, 1, 1), + /* 0x23 */ SCHEDULE_CMD_RET_NONE(), + /* 0x24 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_MILK_BAR, 0x41 - 0x28), + /* 0x28 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(9, 50, 21, 5, 0x3B - 0x2E), + /* 0x2E */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(21, 55, 5, 5, 0x35 - 0x34), + /* 0x34 */ SCHEDULE_CMD_RET_NONE(), + /* 0x35 */ SCHEDULE_CMD_RET_TIME(21, 55, 5, 5, 2), + /* 0x3B */ SCHEDULE_CMD_RET_TIME(9, 50, 21, 5, 1), + /* 0x41 */ SCHEDULE_CMD_RET_NONE(), }; s32 D_80BE1914[] = { @@ -256,7 +269,7 @@ void func_80BE0A98(EnTab* this, GlobalContext* globalCtx) { Matrix_InsertTranslation(this->unk_308, 0.0f, 0.0f, MTXMODE_APPLY); if ((&this->actor == player->targetActor) && - ((globalCtx->msgCtx.unk11F04 < 0xFF) || (globalCtx->msgCtx.unk11F04 > 0x200)) && (sp20 == 3) && + ((globalCtx->msgCtx.currentTextId < 0xFF) || (globalCtx->msgCtx.currentTextId > 0x200)) && (sp20 == 3) && (this->unk_334 == 3)) { if ((globalCtx->state.frames % 2) == 0) { if (this->unk_304 != 0.0f) { @@ -333,7 +346,7 @@ s32* func_80BE0E04(EnTab* this, GlobalContext* globalCtx) { return D_80BE1998; } - if (gSaveContext.day == 3) { + if (gSaveContext.save.day == 3) { return D_80BE1A0C; } return D_80BE19A0; @@ -353,7 +366,7 @@ s32* func_80BE0E04(EnTab* this, GlobalContext* globalCtx) { return NULL; } -s32 func_80BE0F04(EnTab* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BE0F04(EnTab* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret = false; EnGm* sp28 = func_80BE04E0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_GM); @@ -372,7 +385,7 @@ s32 func_80BE0F04(EnTab* this, GlobalContext* globalCtx, struct_80133038_arg2* a return ret; } -s32 func_80BE0FC4(EnTab* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BE0FC4(EnTab* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 pad; Math_Vec3f_Copy(&this->actor.world.pos, &D_80BE1B04); @@ -386,12 +399,12 @@ s32 func_80BE0FC4(EnTab* this, GlobalContext* globalCtx, struct_80133038_arg2* a return true; } -s32 func_80BE1060(EnTab* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BE1060(EnTab* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret; this->unk_2FC = 0; - switch (arg2->unk0) { + switch (arg2->result) { case 1: ret = func_80BE0F04(this, globalCtx, arg2); break; @@ -415,14 +428,15 @@ s32 func_80BE10BC(EnTab* this, GlobalContext* globalCtx) { switch (this->unk_1D8) { case 1: - if ((player->stateFlags1 & 0x40) && !(globalCtx->msgCtx.unk11F04 <= 0x2B00) && - (globalCtx->msgCtx.unk11F04 < 0x2B08)) { + if ((player->stateFlags1 & 0x40) && !(globalCtx->msgCtx.currentTextId <= 0x2B00) && + (globalCtx->msgCtx.currentTextId < 0x2B08)) { this->actor.child = &this->unk_1E4->actor; this->unk_2FC |= 8; } else { dist = Math_Vec3f_DistXYZ(&this->actor.world.pos, &this->unk_1E4->actor.world.pos); - if ((gSaveContext.weekEventReg[75] & 1) || (this->unk_1E4->actor.draw == NULL) || !(dist < 160.0f)) { + if ((gSaveContext.save.weekEventReg[75] & 1) || (this->unk_1E4->actor.draw == NULL) || + !(dist < 160.0f)) { tempActor = &GET_PLAYER(globalCtx)->actor; this->actor.child = tempActor; } else { @@ -458,21 +472,20 @@ void func_80BE1224(EnTab* this, GlobalContext* globalCtx) { } void func_80BE127C(EnTab* this, GlobalContext* globalCtx) { - u32* unk_14 = &gSaveContext.unk_14; - struct_80133038_arg2 sp18; + ScheduleResult sp18; - this->unk_31A = REG(15) + *unk_14; + this->unk_31A = REG(15) + ((void)0, gSaveContext.save.daySpeed); - if (!func_80133038(globalCtx, D_80BE18D0, &sp18) || - ((this->unk_1D8 != sp18.unk0) && !func_80BE1060(this, globalCtx, &sp18))) { + if (!Schedule_RunScript(globalCtx, D_80BE18D0, &sp18) || + ((this->unk_1D8 != sp18.result) && !func_80BE1060(this, globalCtx, &sp18))) { this->actor.shape.shadowDraw = NULL; this->actor.flags &= ~ACTOR_FLAG_1; - sp18.unk0 = 0; + sp18.result = 0; } else { this->actor.shape.shadowDraw = ActorShadow_DrawCircle; this->actor.flags |= ACTOR_FLAG_1; } - this->unk_1D8 = sp18.unk0; + this->unk_1D8 = sp18.result; func_80BE1224(this, globalCtx); } @@ -540,7 +553,7 @@ void EnTab_Update(Actor* thisx, GlobalContext* globalCtx) { radius = this->collider.dim.radius + this->unk_30C; height = this->collider.dim.height + 10; - func_8013C964(&this->actor, globalCtx, radius, height, 0, this->unk_2FC & 7); + func_8013C964(&this->actor, globalCtx, radius, height, EXCH_ITEM_NONE, this->unk_2FC & 7); Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); func_80BE0620(this, globalCtx); diff --git a/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c b/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c index a4822cad3d..a2324aaf6d 100644 --- a/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c +++ b/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c @@ -242,14 +242,14 @@ void EnTalkGibud_Init(Actor* thisx, GlobalContext* globalCtx) { this->grabState = EN_TALK_GIBUD_GRAB_START; this->grabWaitTimer = 0; this->itemActionParam = PLAYER_AP_NONE; - this->effectTimer = 0; - this->effectType = 0; + this->drawDmgEffTimer = 0; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->isTalking = false; this->type = EN_TALK_GIBUD_TYPE_GIBDO; this->requestedItemIndex = EN_TALK_GIBUD_REQUESTED_ITEM_INDEX(thisx); this->switchFlag = EN_TALK_GIBUD_SWITCH_FLAG(thisx); - this->effectAlpha = 0.0f; - this->effectScale = 0.0f; + this->drawDmgEffAlpha = 0.0f; + this->drawDmgEffScale = 0.0f; for (i = 0; i < ARRAY_COUNT(this->limbPos); i++) { this->limbPos[i] = gZeroVec3f; @@ -344,7 +344,7 @@ void EnTalkGibud_WalkToPlayer(EnTalkGibud* this, GlobalContext* globalCtx) { if (EnTalkGibud_PlayerInRangeWithCorrectState(this, globalCtx) && Actor_IsFacingPlayer(&this->actor, 0x38E3)) { if ((this->grabWaitTimer == 0) && (this->actor.xzDistToPlayer <= 45.0f)) { player->actor.freezeTimer = 0; - if ((gSaveContext.playerForm == PLAYER_FORM_GORON) || (gSaveContext.playerForm == PLAYER_FORM_DEKU)) { + if (gSaveContext.save.playerForm == PLAYER_FORM_GORON || gSaveContext.save.playerForm == PLAYER_FORM_DEKU) { // If the Gibdo/Redead tries to grab Goron or Deku Link, it will fail to // do so. It will appear to take damage and shake its head side-to-side. EnTalkGibud_SetupGrabFail(this); @@ -510,7 +510,7 @@ void EnTalkGibud_WalkToHome(EnTalkGibud* this, GlobalContext* globalCtx) { this->actor.world.rot = this->actor.shape.rot; } if (EnTalkGibud_PlayerInRangeWithCorrectState(this, globalCtx)) { - if ((gSaveContext.playerForm != PLAYER_FORM_GORON) && (gSaveContext.playerForm != PLAYER_FORM_DEKU) && + if (gSaveContext.save.playerForm != PLAYER_FORM_GORON && gSaveContext.save.playerForm != PLAYER_FORM_DEKU && Actor_IsFacingPlayer(&this->actor, 0x38E3)) { EnTalkGibud_SetupWalkToPlayer(this); } @@ -522,7 +522,7 @@ void EnTalkGibud_SetupStunned(EnTalkGibud* this) { this->actor.speedXZ = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; - if (this->effectTimer != 0) { + if (this->drawDmgEffTimer != 0) { Actor_SetColorFilter(&this->actor, 0, 0xC8, 0, 0x28); } else { Actor_SetColorFilter(&this->actor, 0, 0xC8, 0, 0x28); @@ -563,7 +563,8 @@ void EnTalkGibud_Damage(EnTalkGibud* this, GlobalContext* globalCtx) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_3F7 = -1; this->actor.world.rot.y = this->actor.shape.rot.y; - if ((this->effectTimer > 0) && (this->effectType == 0) && (this->type == EN_TALK_GIBUD_TYPE_GIBDO)) { + if ((this->drawDmgEffTimer > 0) && (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FIRE) && + (this->type == EN_TALK_GIBUD_TYPE_GIBDO)) { this->actor.hintId = 0x2A; this->actor.flags &= ~(ACTOR_FLAG_8 | ACTOR_FLAG_1); this->actor.flags |= (ACTOR_FLAG_4 | ACTOR_FLAG_1); @@ -597,7 +598,7 @@ void EnTalkGibud_Dead(EnTalkGibud* this, GlobalContext* globalCtx) { this->deathTimer++; } - if ((this->deathTimer == 20) && (this->effectTimer > 0) && (this->effectType == 0) && + if ((this->deathTimer == 20) && (this->drawDmgEffTimer > 0) && (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FIRE) && (this->type == EN_TALK_GIBUD_TYPE_GIBDO)) { SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gRedeadSkel, NULL, this->jointTable, this->morphTable, GIBDO_LIMB_MAX); @@ -677,7 +678,7 @@ void EnTalkGibud_GetTextIdForRequestedItem(EnTalkGibud* this, GlobalContext* glo } void EnTalkGibud_GetNextTextBoxId(EnTalkGibud* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->textId) { case 0x1388: EnTalkGibud_GetTextIdForRequestedItem(this, globalCtx); @@ -813,7 +814,7 @@ void EnTalkGibud_Talk(EnTalkGibud* this, GlobalContext* globalCtx) { break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (this->textId == 0x138A) { // Remove the requested item/amount from the player's inventory requestedItem = &sRequestedItemTable[this->requestedItemIndex]; @@ -979,7 +980,7 @@ s32 EnTalkGibud_MoveToIdealGrabPositionAndRotation(EnTalkGibud* this, GlobalCont distanceFromTargetPos = Math_Vec3f_StepTo(&this->actor.world.pos, &targetPos, 10.0f); distanceFromTargetAngle = Math_SmoothStepToS(&this->actor.shape.rot.y, player->actor.shape.rot.y, 1, 0x1770, 0x64); this->actor.world.rot.y = this->actor.shape.rot.y; - if (gSaveContext.playerForm == PLAYER_FORM_HUMAN) { + if (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { distanceFromTargetYOffset = Math_SmoothStepToF(&this->actor.shape.yOffset, -1500.0f, 1.0f, 150.0f, 0.0f); } @@ -1040,9 +1041,9 @@ void EnTalkGibud_UpdateDamage(EnTalkGibud* this, GlobalContext* globalCtx) { } else { EnTalkGibud_SetupDamage(this); } - this->effectTimer = 180; - this->effectType = 0; - this->effectAlpha = 1.0f; + this->drawDmgEffTimer = 180; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffAlpha = 1.0f; break; case EN_TALK_GIBUD_DMGEFF_LIGHT_ARROW: @@ -1052,17 +1053,17 @@ void EnTalkGibud_UpdateDamage(EnTalkGibud* this, GlobalContext* globalCtx) { } else { EnTalkGibud_SetupDamage(this); } - this->effectTimer = 60; - this->effectType = 20; - this->effectAlpha = 1.0f; + this->drawDmgEffTimer = 60; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->drawDmgEffAlpha = 1.0f; break; case EN_TALK_GIBUD_DMGEFF_ZORA_MAGIC: if (this->actionFunc != EnTalkGibud_Grab && (this->actionFunc != EnTalkGibud_Stunned || this->stunTimer == 0)) { - this->effectAlpha = 1.0f; - this->effectTimer = 40; - this->effectType = 30; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffTimer = 40; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; EnTalkGibud_SetupStunned(this); } break; @@ -1117,15 +1118,15 @@ void EnTalkGibud_MoveGrabbedPlayerAwayFromWall(EnTalkGibud* this, GlobalContext* } void EnTalkGibud_UpdateEffect(EnTalkGibud* this, GlobalContext* globalCtx) { - if (this->effectTimer > 0) { - this->effectTimer--; + if (this->drawDmgEffTimer > 0) { + this->drawDmgEffTimer--; } - if (this->effectTimer < 20) { - Math_SmoothStepToF(&this->effectScale, 0.0f, 0.5f, 0.03f, 0.0f); - this->effectAlpha = this->effectTimer * 0.05f; + if (this->drawDmgEffTimer < 20) { + Math_SmoothStepToF(&this->drawDmgEffScale, 0.0f, 0.5f, 0.03f, 0.0f); + this->drawDmgEffAlpha = this->drawDmgEffTimer * 0.05f; } else { - Math_SmoothStepToF(&this->effectScale, 0.5f, 0.1f, 0.02f, 0.0f); + Math_SmoothStepToF(&this->drawDmgEffScale, 0.5f, 0.1f, 0.02f, 0.0f); } } @@ -1164,7 +1165,7 @@ void EnTalkGibud_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi Gfx** gfx) { EnTalkGibud* this = THIS; - if ((this->effectTimer != 0) && + if ((this->drawDmgEffTimer != 0) && ((limbIndex == GIBDO_LIMB_LEFT_THIGH) || (limbIndex == GIBDO_LIMB_LEFT_SHIN) || (limbIndex == GIBDO_LIMB_LEFT_FOOT) || (limbIndex == GIBDO_LIMB_RIGHT_THIGH) || (limbIndex == GIBDO_LIMB_RIGHT_SHIN) || (limbIndex == GIBDO_LIMB_RIGHT_FOOT) || @@ -1203,9 +1204,9 @@ void EnTalkGibud_Draw(Actor* thisx, GlobalContext* globalCtx) { EnTalkGibud_PostLimbDraw, &this->actor, POLY_XLU_DISP); } - if (this->effectTimer > 0) { - func_800BE680(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->effectScale, 0.5f, - this->effectAlpha, this->effectType); + if (this->drawDmgEffTimer > 0) { + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + this->drawDmgEffScale, 0.5f, this->drawDmgEffAlpha, this->drawDmgEffType); } CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.h b/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.h index ae3afab497..b2d5b06b88 100644 --- a/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.h +++ b/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.h @@ -21,8 +21,8 @@ typedef struct EnTalkGibud { /* 0x290 */ s32 requestedItemIndex; /* 0x294 */ s32 itemActionParam; /* 0x298 */ s32 switchFlag; - /* 0x29C */ f32 effectAlpha; - /* 0x2A0 */ f32 effectScale; + /* 0x29C */ f32 drawDmgEffAlpha; + /* 0x2A0 */ f32 drawDmgEffScale; /* 0x2A4 */ Vec3s jointTable[GIBDO_LIMB_MAX]; /* 0x340 */ Vec3s morphTable[GIBDO_LIMB_MAX]; /* 0x3DC */ s16 textId; @@ -38,10 +38,10 @@ typedef struct EnTalkGibud { }; /* 0x3EC */ s16 grabState; /* 0x3EE */ s16 grabWaitTimer; // Cannot grab the player if this is non-zero - /* 0x3F0 */ s16 effectTimer; + /* 0x3F0 */ s16 drawDmgEffTimer; /* 0x3F2 */ s16 type; /* 0x3F4 */ s16 isTalking; - /* 0x3F6 */ u8 effectType; + /* 0x3F6 */ u8 drawDmgEffType; /* 0x3F7 */ s8 unk_3F7; // related to player->unk_ADD } EnTalkGibud; // size = 0x3F8 diff --git a/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.c b/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.c index 5985e77f98..b7e5588f71 100644 --- a/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.c +++ b/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.c @@ -15,7 +15,9 @@ void EnTanron1_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnTanron1_Update(Actor* thisx, GlobalContext* globalCtx); void EnTanron1_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80BB5318(EnTanron1* this, GlobalContext* globalCtx); +void func_80BB5AAC(EnTanron1* this, GlobalContext* globalCtx); + const ActorInit En_Tanron1_InitVars = { ACTOR_EN_TANRON1, ACTORCAT_ENEMY, @@ -28,18 +30,387 @@ const ActorInit En_Tanron1_InitVars = { (ActorFunc)EnTanron1_Draw, }; -#endif +static u64 sPad = { 0 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron1/EnTanron1_Init.s") +#include "overlays/ovl_En_Tanron1/ovl_En_Tanron1.c" -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron1/EnTanron1_Destroy.s") +void EnTanron1_Init(Actor* thisx, GlobalContext* globalCtx) { + EnTanron1* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron1/func_80BB4E50.s") + this->actor.flags &= ~ACTOR_FLAG_1; + if (!ENTANRON1_GET_100(&this->actor)) { + this->unk_144 = 0; + } else { + this->actor.params = 200; + this->unk_144 = 1; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron1/EnTanron1_Update.s") +void EnTanron1_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron1/EnTanron1_Draw.s") +void func_80BB4E50(EnTanron1Struct* arg0, Vec3f* arg1, s16 arg2) { + s16 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron1/func_80BB5318.s") + for (i = 0; i < 200; i++, arg0++) { + if (arg0->unk_24 == 0) { + arg0->unk_24 = 1; + arg0->unk_2C = 0.0f; + arg0->unk_00 = *arg1; + arg0->unk_18 = arg0->unk_1C = 0; + arg0->unk_1A = arg2; + arg0->unk_26 = Rand_ZeroFloat(100.0f); + arg0->unk_28 = 0; + if (Rand_ZeroOne() < 0.5f) { + arg0->unk_2A = 0xC00; + } else { + arg0->unk_2A = -0xC00; + } + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron1/func_80BB5AAC.s") +void EnTanron1_Update(Actor* thisx, GlobalContext* globalCtx) { + EnTanron1* this = THIS; + Actor* temp_a0; + Player* player = GET_PLAYER(globalCtx); + s16 i; + EnTanron1Struct* ptr = &this->unk_160[0]; + Vec3f temp; + f32 phi_f18; + s32 pad; + + if (this->unk_148 != 0) { + this->unk_148--; + } + + switch (this->unk_144) { + case 0: + for (i = 0; i < this->actor.params; i++) { + func_80BB4E50(this->unk_160, &this->actor.world.pos, Rand_ZeroFloat(0x10000)); + } + this->unk_144 = 200; + break; + + case 1: + this->unk_14C.x = player->actor.world.pos.x; + this->unk_14C.y = player->actor.world.pos.y + 60.0f; + this->unk_14C.z = player->actor.world.pos.z; + if (this->unk_148 != 0) { + func_80BB4E50(this->unk_160, &this->actor.world.pos, this->actor.world.rot.y); + } + this->unk_158 = 0x1000; + this->unk_15C = 150.0f; + break; + + case 100: + phi_f18 = 10.0f; + + while (phi_f18 < 1000.0f) { + temp_a0 = globalCtx->actorCtx.actorLists[ACTORCAT_PROP].first; + while (temp_a0 != NULL) { + if (temp_a0->id != ACTOR_OBJ_SYOKUDAI) { + temp_a0 = temp_a0->next; + continue; + } + + temp.x = this->unk_14C.x - temp_a0->world.pos.x; + temp.y = (this->unk_14C.y - temp_a0->world.pos.y) + 70.0f; + temp.z = this->unk_14C.z - temp_a0->world.pos.z; + + if (sqrtf(SQXYZ(temp)) < phi_f18) { + this->unk_14C.x = temp_a0->world.pos.x; + this->unk_14C.y = temp_a0->world.pos.y + 70.0f; + this->unk_14C.z = temp_a0->world.pos.z; + goto end; + } + temp_a0 = temp_a0->next; + } + phi_f18 += 20.0f; + } + end: + break; + + case 200: + this->unk_14C = this->actor.world.pos; + this->unk_158 = 0x5000; + this->unk_15C = 50.0f; + break; + + case 250: + for (i = 0; i < ARRAY_COUNT(this->unk_160); i++, ptr++) { + if ((ptr->unk_24 != 0) && (ptr->unk_28 < 8)) { + ptr->unk_28 = 8; + ptr->unk_24 = 2; + } + } + this->unk_144 = 1; + break; + } + + if ((player->itemActionParam == 7) && (player->unk_B28 != 0)) { + this->unk_14C.x = player->swordInfo[0].tip.x; + this->unk_14C.y = player->swordInfo[0].tip.y; + this->unk_14C.z = player->swordInfo[0].tip.z; + + this->unk_158 = 0x5000; + this->unk_15C = 50.0f; + if (this->unk_144 != 1) { + this->unk_144 = 100; + } + } else { + temp_a0 = globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVES].first; + while (temp_a0 != NULL) { + if (temp_a0->params == 1) { + temp_a0 = temp_a0->next; + continue; + } + + this->unk_14C.x = temp_a0->world.pos.x; + this->unk_14C.y = temp_a0->world.pos.y + 50.0f; + this->unk_14C.z = temp_a0->world.pos.z; + + this->unk_15C = 150.0f; + this->unk_158 = 0x1000; + if (this->unk_144 != 1) { + this->unk_144 = 100; + } + break; + } + } + func_80BB5318(this, globalCtx); +} + +void EnTanron1_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnTanron1* this = THIS; + + func_80BB5AAC(this, globalCtx); +} + +void func_80BB5318(EnTanron1* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + EnTanron1Struct* ptr = NULL; + f32 phi_f28 = 0.0f; + Vec3f* phi_s2 = NULL; + Vec3f temp; + s16 spBA = 0; + s16 spB8 = 0; + Vec3f* spB4 = NULL; + f32 spB0; + Vec3f spA4; + WaterBox* spA0; + f32 sp9C; + CollisionPoly* sp98; + Actor* temp_v0; + s16 i; + f32 temp_f30 = this->unk_15C; + + if (player->unk_ADC != 0) { + phi_s2 = &player->swordInfo[0].tip; + if (player->swordAnimation >= 30) { + phi_f28 = 2500.0f; + } else { + phi_f28 = 400.0f; + } + } + + temp_v0 = globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVES].first; + while (temp_v0 != NULL) { + if (temp_v0->params != 1) { + temp_v0 = temp_v0->next; + continue; + } + phi_s2 = &temp_v0->world.pos; + phi_f28 = 40000.0f; + break; + } + + ptr = &this->unk_160[0]; + for (i = 0; i < this->actor.params; i++, ptr++) { + if (ptr->unk_24 != 0) { + ptr->unk_26++; + ptr->unk_00.x += ptr->unk_0C.x; + ptr->unk_00.y += ptr->unk_0C.y; + ptr->unk_00.z += ptr->unk_0C.z; + + if (ptr->unk_24 == 0) { + } else { + spB4 = &ptr->unk_00; + if (ptr->unk_28 == 0) { + spBA++; + ptr->unk_2C = Math_SinS(ptr->unk_26 * 0x5000) * 1.2f; + if ((ptr->unk_26 & 3) == 0) { + temp.x = ptr->unk_30 + (this->unk_14C.x - ptr->unk_00.x); + temp.y = ptr->unk_34 + (this->unk_14C.y - ptr->unk_00.y); + temp.z = ptr->unk_38 + (this->unk_14C.z - ptr->unk_00.z); + + ptr->unk_20 = Math_Atan2S(temp.x, temp.z); + ptr->unk_1E = Math_Atan2S(temp.y, sqrtf(SQXZ(temp))); + if ((ptr->unk_26 & 0xF) == 0) { + ptr->unk_30 = randPlusMinusPoint5Scaled(temp_f30); + ptr->unk_34 = randPlusMinusPoint5Scaled(temp_f30 * 0.5f); + ptr->unk_38 = randPlusMinusPoint5Scaled(temp_f30); + } + + temp.x = player->actor.world.pos.x - ptr->unk_00.x; + temp.y = (player->actor.world.pos.y + 40.0f) - ptr->unk_00.y; + temp.z = player->actor.world.pos.z - ptr->unk_00.z; + + if ((SQXYZ(temp) < 400.0f) && (player->transformation != PLAYER_FORM_DEKU)) { + func_800B8D10(globalCtx, &this->actor, 0.0f, 0, 0.0f, 1, 1); + } + } + + Math_ApproachS(&ptr->unk_1A, ptr->unk_20, 2, this->unk_158); + Math_ApproachS(&ptr->unk_18, ptr->unk_1E, 2, this->unk_158); + Matrix_RotateY(ptr->unk_1A, MTXMODE_NEW); + Matrix_InsertXRotation_s(-ptr->unk_18, MTXMODE_APPLY); + Matrix_GetStateTranslationAndScaledZ(6.0f, &ptr->unk_0C); + + if (phi_s2 != NULL) { + temp.x = phi_s2->x - ptr->unk_00.x; + temp.y = phi_s2->y - ptr->unk_00.y; + temp.z = phi_s2->z - ptr->unk_00.z; + + if (SQXYZ(temp) < phi_f28) { + ptr->unk_20 = Math_Atan2S(temp.x, temp.z); + ptr->unk_1E = Math_Atan2S(temp.y, sqrtf(SQXZ(temp))); + + Matrix_RotateY(ptr->unk_20, MTXMODE_NEW); + Matrix_InsertXRotation_s(-ptr->unk_1E, MTXMODE_APPLY); + Matrix_GetStateTranslationAndScaledZ(-20.0f, &ptr->unk_0C); + + if (phi_f28 >= 100000.0f) { + ptr->unk_28 = 1; + } else { + ptr->unk_28 = 6; + } + ptr->unk_24 = 2; + spB8++; + } + } + } else if (ptr->unk_28 < 9) { + ptr->unk_18 += 0x3000; + ptr->unk_1A += 0x5000; + ptr->unk_30 = 0.0f; + ptr->unk_34 = 0.0f; + ptr->unk_28++; + } else { + ptr->unk_1A += ptr->unk_2A; + Math_ApproachS(&ptr->unk_18, 0, 0xA, 0x1000); + Matrix_RotateY(ptr->unk_1A, MTXMODE_NEW); + Matrix_GetStateTranslationAndScaledZ(ptr->unk_30, &spA4); + + ptr->unk_0C.x = spA4.x; + ptr->unk_0C.z = spA4.z; + ptr->unk_0C.y = -2.0f; + + if (phi_s2 != NULL) { + temp.x = phi_s2->x - ptr->unk_00.x; + temp.y = phi_s2->y - ptr->unk_00.y; + temp.z = phi_s2->z - ptr->unk_00.z; + + if (SQXYZ(temp) < phi_f28) { + ptr->unk_20 = Math_Atan2S(temp.x, temp.z); + ptr->unk_1E = Math_Atan2S(temp.y, sqrtf(SQXZ(temp))); + + Matrix_RotateY(ptr->unk_20, MTXMODE_NEW); + Matrix_InsertXRotation_s(-ptr->unk_1E, MTXMODE_APPLY); + Matrix_GetStateTranslationAndScaledZ(-20.0f, &ptr->unk_0C); + + ptr->unk_3C = ptr->unk_00.y - 1000.0f; + ptr->unk_30 = 5.0f; + } + } + + if (ptr->unk_00.y <= (ptr->unk_3C + 5.0f)) { + ptr->unk_00.y = (ptr->unk_3C + 5.0f); + Math_ApproachZeroF(&ptr->unk_30, 1.0f, 0.3f); + Math_ApproachS(&ptr->unk_2A, 0, 1, 0x100); + ptr->unk_28++; + if (ptr->unk_28 > 50) { + ptr->unk_24 = 0; + } + } else { + Math_ApproachF(&ptr->unk_30, ptr->unk_34, 1.0f, 0.5f); + if ((ptr->unk_26 & 0xF) == 0) { + if (Rand_ZeroOne() < 0.5f) { + ptr->unk_34 = randPlusMinusPoint5Scaled(12.0f); + } + ptr->unk_3C = BgCheck_EntityRaycastFloor1(&globalCtx->colCtx, &sp98, &ptr->unk_00); + sp9C = ptr->unk_00.y; + WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, ptr->unk_00.x, ptr->unk_00.z, &sp9C, + &spA0); + if ((sp9C < ptr->unk_00.y) && (ptr->unk_3C < sp9C)) { + ptr->unk_3C = sp9C; + } + } + } + } + } + } + } + + if (spB4 != NULL) { + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, spB4, &this->unk_3360, &spB0); + if (spB8 >= (s16)(KREG(39) + 20)) { + Audio_PlaySfxAtPos(&this->unk_3360, NA_SE_EN_MB_MOTH_DEAD); + } else if (spBA >= 20) { + Audio_PlaySfxAtPos(&this->unk_3360, NA_SE_EN_MB_MOTH_FLY - SFX_FLAG); + } + } +} + +void func_80BB5AAC(EnTanron1* this, GlobalContext* globalCtx) { + EnTanron1Struct* ptrBase = &this->unk_160[0]; + s16 i; + u8 flag = 0; + EnTanron1Struct* ptr = ptrBase; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + for (i = 0; i < this->actor.params; i++, ptr++) { + if (ptr->unk_24 == 1) { + if (!flag) { + gSPDisplayList(POLY_OPA_DISP++, ovl_En_Tanron1_DL_001888); + flag++; + } + Matrix_InsertTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, MTXMODE_NEW); + Matrix_RotateY(ptr->unk_1A, MTXMODE_APPLY); + Matrix_InsertXRotation_s(ptr->unk_18 * -1, MTXMODE_APPLY); + Matrix_Scale(1.2f, ptr->unk_2C, 1.2f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, ovl_En_Tanron1_DL_001900); + } + } + + flag = 0; + ptr = ptrBase; + for (i = 0; i < this->actor.params; i++, ptr++) { + if (ptr->unk_24 != 2) { + continue; + } + + if (!flag) { + gSPDisplayList(POLY_OPA_DISP++, ovl_En_Tanron1_DL_001888); + gDPLoadTextureBlock(POLY_OPA_DISP++, ovl_En_Tanron1_DL_001428, G_IM_FMT_RGBA, G_IM_SIZ_16b, 16, 32, 0, + G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, 4, 5, G_TX_NOLOD, G_TX_NOLOD); + flag++; + } + + Matrix_InsertTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, MTXMODE_NEW); + Matrix_RotateY(ptr->unk_1A, MTXMODE_APPLY); + Matrix_InsertXRotation_s(ptr->unk_18 * -1, MTXMODE_APPLY); + Matrix_Scale(1.0f, ptr->unk_2C, 1.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, ovl_En_Tanron1_DL_001900); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.h b/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.h index b32810084e..d8e96537f3 100644 --- a/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.h +++ b/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.h @@ -5,9 +5,38 @@ struct EnTanron1; +#define ENTANRON1_GET_100(thisx) ((thisx)->params & 0x100) + +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ Vec3f unk_0C; + /* 0x18 */ s16 unk_18; + /* 0x1A */ s16 unk_1A; + /* 0x1C */ s16 unk_1C; + /* 0x1E */ s16 unk_1E; + /* 0x20 */ s16 unk_20; + /* 0x22 */ UNK_TYPE1 unk_22[0x2]; + /* 0x24 */ u8 unk_24; + /* 0x26 */ s16 unk_26; + /* 0x28 */ s16 unk_28; + /* 0x2A */ s16 unk_2A; + /* 0x2C */ f32 unk_2C; + /* 0x30 */ f32 unk_30; + /* 0x34 */ f32 unk_34; + /* 0x38 */ f32 unk_38; + /* 0x3C */ f32 unk_3C; +} EnTanron1Struct; // size = 0x40 + typedef struct EnTanron1 { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_0144[0x3228]; + /* 0x0144 */ u8 unk_144; + /* 0x0145 */ UNK_TYPE1 pad145[3]; + /* 0x0148 */ s16 unk_148; + /* 0x014C */ Vec3f unk_14C; + /* 0x0158 */ s16 unk_158; + /* 0x015C */ f32 unk_15C; + /* 0x0160 */ EnTanron1Struct unk_160[200]; + /* 0x3360 */ Vec3f unk_3360; } EnTanron1; // size = 0x336C extern const ActorInit En_Tanron1_InitVars; diff --git a/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.c b/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.c index f845d9fa24..15d307326e 100644 --- a/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.c +++ b/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.c @@ -86,12 +86,12 @@ static ColliderCylinderInit sUnusedCylinderInit = { }; void EnTanron3_CreateEffect(GlobalContext* globalCtx, Vec3f* effectPos) { - UnkTanron3Effect* effectPtr = (UnkTanron3Effect*)globalCtx->specialEffects; + GyorgEffect* effectPtr = globalCtx->specialEffects; s16 i; - for (i = 0; i < 150; i++, effectPtr++) { - if ((effectPtr->type == 0) || (effectPtr->type == 1)) { - effectPtr->type = 2; + for (i = 0; i < GYORG_EFFECT_COUNT; i++, effectPtr++) { + if ((effectPtr->type == GYORG_EFFECT_NONE) || (effectPtr->type == GYORG_EFFECT_BUBBLE)) { + effectPtr->type = GYORG_EFFECT_DROPLET; effectPtr->pos = *effectPos; effectPtr->velocity = *sZeroVec; effectPtr->accel = *sZeroVec; @@ -124,7 +124,7 @@ void EnTanron3_Init(Actor* thisx, GlobalContext* globalCtx) { } void EnTanron3_Destroy(Actor* thisx, GlobalContext* globalCtx) { - sGyorg->unk_252--; + sGyorg->numSpawnedSmallFish--; } void EnTanron3_SpawnBubbles(EnTanron3* this, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.h b/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.h index 9d67154df6..5f984e2efc 100644 --- a/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.h +++ b/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.h @@ -10,17 +10,6 @@ typedef void (*EnTanron3ActionFunc)(struct EnTanron3*, GlobalContext*); #define TANRON3_WORK_TIMER_MAX 3 -typedef struct { - /* 0x00 */ u8 type; - /* 0x02 */ s16 unk_02; - /* 0x04 */ Vec3f pos; - /* 0x10 */ Vec3f velocity; - /* 0x1C */ Vec3f accel; - /* 0x28 */ char unk_28[0xC]; - /* 0x34 */ Vec3f unk_34; - /* 0x40 */ char unk_40[0x4]; -} UnkTanron3Effect; - typedef struct EnTanron3 { /* 0x000 */ Actor actor; /* 0x144 */ SkelAnime skelAnime; diff --git a/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.c b/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.c index 9912baf601..969a87cf6e 100644 --- a/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.c +++ b/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.c @@ -1,7 +1,7 @@ /* * File: z_en_tanron4.c * Overlay: ovl_En_Tanron4 - * Description: Flock of Seagulls + * Description: Seagull */ #include "z_en_tanron4.h" @@ -15,7 +15,22 @@ void EnTanron4_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnTanron4_Update(Actor* thisx, GlobalContext* globalCtx); void EnTanron4_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void EnTanron4_SetupFlyNearHome(EnTanron4* this); +void EnTanron4_SetupFlyNearActor(EnTanron4* this); + +void EnTanron4_FlyNearHome(EnTanron4* this, GlobalContext* globalCtx); +void EnTanron4_FlyNearActor(EnTanron4* this, GlobalContext* globalCtx); + +typedef enum { + /* 0 */ SEAGULL_FLY_FLAP, + /* 1 */ SEAGULL_FLY_GLIDE, +} SeagullFlyState; + +typedef enum { + /* 0 */ SEAGULL_TIMER_FLY_STATE, + /* 1 */ SEAGULL_TIMER_CHOOSE_TARGET, +} SeagullTimers; + const ActorInit En_Tanron4_InitVars = { ACTOR_EN_TANRON4, ACTORCAT_ITEMACTION, @@ -28,22 +43,241 @@ const ActorInit En_Tanron4_InitVars = { (ActorFunc)EnTanron4_Draw, }; -#endif +void EnTanron4_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnTanron4* this = THIS; -extern UNK_TYPE D_06000168; + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gSeagullSkel, &gSeagullFlapAnim, this->jointTable, + this->morphTable, OBJECT_TANRON4_LIMB_MAX); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron4/EnTanron4_Init.s") + thisx->flags &= ~ACTOR_FLAG_1; + thisx->speedXZ = 3.0f + KREG(48); + thisx->uncullZoneForward = 10000.0f + KREG(70); + this->randRollTimer = Rand_ZeroFloat(10.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron4/EnTanron4_Destroy.s") + if (thisx->params == SEAGULL_FOLLOW_ACTOR) { + EnTanron4_SetupFlyNearActor(this); + } else { + EnTanron4_SetupFlyNearHome(this); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron4/func_80BE3DC0.s") + // spawn number of seagulls specified by params + if (thisx->params >= 0) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron4/func_80BE3DFC.s") + for (i = 0; i < thisx->params; i++) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_TANRON4, + thisx->world.pos.x + randPlusMinusPoint5Scaled(500.0f), + thisx->world.pos.y + randPlusMinusPoint5Scaled(100.0f), + thisx->world.pos.z + randPlusMinusPoint5Scaled(500.0f), 0, Rand_ZeroFloat(65536.0f), 0, + SEAGULL_CLONE); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron4/func_80BE4268.s") + if ((gSaveContext.save.time > CLOCK_TIME(20, 0)) || (gSaveContext.save.time < CLOCK_TIME(4, 0))) { + this->timeInfluence = 1500.0f; + thisx->world.pos.y += 1500.0f; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron4/func_80BE42A4.s") +void EnTanron4_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron4/EnTanron4_Update.s") +void EnTanron4_SetupFlyNearHome(EnTanron4* this) { + this->actionFunc = EnTanron4_FlyNearHome; + Animation_MorphToLoop(&this->skelAnime, &gSeagullFlapAnim, 0.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron4/EnTanron4_Draw.s") +void EnTanron4_FlyNearHome(EnTanron4* this, GlobalContext* globalCtx) { + f32 xDiff; + f32 yDiff; + f32 zDiff; + f32 distToTarget; + s16 xRot; + s16 yRot; + s16 zRot; + + // `timeInfluence` controls both the height of the seagulls and when they are visible. + // They fly higher in the sky as the night goes on, and they disapear as dawn approaches. + if ((gSaveContext.save.time > CLOCK_TIME(20, 0)) || (gSaveContext.save.time < CLOCK_TIME(4, 0))) { + Math_ApproachF(&this->timeInfluence, 1500.0f, 1.0f, 1.0f); + } else { + Math_ApproachZeroF(&this->timeInfluence, 1.0f, 1.0f); + } + + xDiff = this->targetPos.x - this->actor.world.pos.x; + yDiff = (this->targetPos.y + this->timeInfluence) - this->actor.world.pos.y; + zDiff = this->targetPos.z - this->actor.world.pos.z; + + distToTarget = sqrtf(SQ(xDiff) + SQ(zDiff)); + + if ((this->timers[SEAGULL_TIMER_CHOOSE_TARGET] == 0) || (distToTarget < 100.0f)) { + this->targetPos.x = this->actor.home.pos.x + randPlusMinusPoint5Scaled(500.0f); + this->targetPos.y = this->actor.home.pos.y + randPlusMinusPoint5Scaled(100.0f); + this->targetPos.z = this->actor.home.pos.z + randPlusMinusPoint5Scaled(500.0f); + + this->timers[SEAGULL_TIMER_CHOOSE_TARGET] = Rand_ZeroFloat(100.0f) + 60.0f; + this->step = 0; + } + + yRot = Math_Atan2S(xDiff, zDiff); + xRot = Math_Atan2S(yDiff, distToTarget); + zRot = Math_SmoothStepToS(&this->actor.world.rot.y, yRot, 0xA, this->step, 0); + + if (zRot > 0x1000) { + zRot = 0x1000; + } else if (zRot < -0x1000) { + zRot = -0x1000; + } + + Math_ApproachS(&this->actor.world.rot.x, xRot, 0xA, this->step); + Math_ApproachS(&this->actor.world.rot.z, -zRot, 0xA, this->step); + + Math_ApproachS(&this->step, 0x200, 1, 0x10); + + SkelAnime_Update(&this->skelAnime); + + switch (this->flyState) { + case SEAGULL_FLY_FLAP: + if ((this->timers[SEAGULL_TIMER_FLY_STATE] == 0) && + (Animation_OnFrame(&this->skelAnime, 2.0f + KREG(42)))) { + this->flyState = SEAGULL_FLY_GLIDE; + this->timers[SEAGULL_TIMER_FLY_STATE] = Rand_ZeroFloat(50.0f) + 50.0f; + Animation_MorphToLoop(&this->skelAnime, &gSeagullFlapAnim, -15.0f + KREG(43)); + this->skelAnime.curFrame = 2.0f + KREG(42); + this->skelAnime.playSpeed = 0.0f; + } + break; + + case SEAGULL_FLY_GLIDE: + if (((this->randRollTimer % 8) == 0) && (Rand_ZeroOne() < 0.5f)) { + this->rollTarget = randPlusMinusPoint5Scaled(3000.0f + KREG(44)); + } + + if (this->timers[SEAGULL_TIMER_FLY_STATE] == 0) { + this->flyState = SEAGULL_FLY_FLAP; + this->timers[SEAGULL_TIMER_FLY_STATE] = Rand_ZeroFloat(50.0f) + 70.0f; + Animation_MorphToLoop(&this->skelAnime, &gSeagullFlapAnim, -10.0f + KREG(43)); + this->skelAnime.curFrame = 2.0f + KREG(42); + } + break; + } + + this->actor.shape.rot.x = -this->actor.world.rot.x; + this->actor.shape.rot.y = this->actor.world.rot.y; + this->actor.shape.rot.z = this->actor.world.rot.z; + + Math_ApproachS(&this->roll, this->rollTarget, 3, 0x3E8 + KREG(45)); +} + +void EnTanron4_SetupFlyNearActor(EnTanron4* this) { + this->actionFunc = EnTanron4_FlyNearActor; + Animation_MorphToLoop(&this->skelAnime, &gSeagullFlapAnim, 0.0f); +} + +void EnTanron4_FlyNearActor(EnTanron4* this, GlobalContext* globalCtx) { + f32 xDiff; + f32 yDiff; + f32 zDiff; + f32 distToTarget; + s16 xRot; + s16 yRot; + s16 zRot; + Actor* targetActor = this->actor.parent; + + xDiff = this->targetPos.x - this->actor.world.pos.x; + yDiff = this->targetPos.y - this->actor.world.pos.y; + zDiff = this->targetPos.z - this->actor.world.pos.z; + + distToTarget = sqrtf(SQ(xDiff) + SQ(zDiff)); + + if ((this->timers[SEAGULL_TIMER_CHOOSE_TARGET] == 0) || (distToTarget < 100.0f)) { + this->targetPos.x = targetActor->world.pos.x + randPlusMinusPoint5Scaled(200.0f + KREG(82)); + this->targetPos.y = targetActor->world.pos.y + KREG(80) + 100.0f + randPlusMinusPoint5Scaled(100.0f + KREG(81)); + this->targetPos.z = targetActor->world.pos.z + randPlusMinusPoint5Scaled(200.0f + KREG(82)); + + this->timers[SEAGULL_TIMER_CHOOSE_TARGET] = Rand_ZeroFloat(100.0f) + 60.0f; + this->step = 0; + } + + yRot = Math_Atan2S(xDiff, zDiff); + xRot = Math_Atan2S(yDiff, distToTarget); + zRot = Math_SmoothStepToS(&this->actor.world.rot.y, yRot, 0xA, this->step, 0); + + if (zRot > 0x1000) { + zRot = 0x1000; + } else if (zRot < -0x1000) { + zRot = -0x1000; + } + + Math_ApproachS(&this->actor.world.rot.x, xRot, 0xA, this->step); + Math_ApproachS(&this->actor.world.rot.z, -zRot, 0xA, this->step); + Math_ApproachS(&this->step, 0x200, 1, 0x10); + + SkelAnime_Update(&this->skelAnime); + + switch (this->flyState) { + case SEAGULL_FLY_FLAP: + if ((this->timers[SEAGULL_TIMER_FLY_STATE] == 0) && + (Animation_OnFrame(&this->skelAnime, 2.0f + KREG(42)))) { + this->flyState = SEAGULL_FLY_GLIDE; + this->timers[SEAGULL_TIMER_FLY_STATE] = Rand_ZeroFloat(50.0f) + 50.0f; + Animation_MorphToLoop(&this->skelAnime, &gSeagullFlapAnim, -15.0f + KREG(43)); + this->skelAnime.curFrame = 2.0f + KREG(42); + this->skelAnime.playSpeed = 0.0f; + } + break; + + case SEAGULL_FLY_GLIDE: + if (((this->randRollTimer % 8) == 0) && (Rand_ZeroOne() < 0.5f)) { + this->rollTarget = randPlusMinusPoint5Scaled(3000.0f + KREG(44)); + } + + if (this->timers[SEAGULL_TIMER_FLY_STATE] == 0) { + this->flyState = SEAGULL_FLY_FLAP; + this->timers[SEAGULL_TIMER_FLY_STATE] = Rand_ZeroFloat(50.0f) + 70.0f; + Animation_MorphToLoop(&this->skelAnime, &gSeagullFlapAnim, -10.0f + KREG(43)); + this->skelAnime.curFrame = 2.0f + KREG(42); + } + break; + } + + this->actor.shape.rot.x = -this->actor.world.rot.x; + this->actor.shape.rot.y = this->actor.world.rot.y; + this->actor.shape.rot.z = this->actor.world.rot.z; + + Math_ApproachS(&this->roll, this->rollTarget, 3, 0x3E8 + KREG(45)); +} + +void EnTanron4_Update(Actor* thisx, GlobalContext* globalCtx) { + EnTanron4* this = THIS; + + Actor_SetScale(&this->actor, 0.001f * KREG(16) + 0.01f); + + if (KREG(63) == 0) { + s32 i; + + this->randRollTimer++; + + for (i = 0; i < ARRAY_COUNT(this->timers); i++) { + if (this->timers[i] != 0) { + this->timers[i]--; + } + } + + this->actionFunc(this, globalCtx); + + Actor_UpdateVelocityWithoutGravity(&this->actor); + Actor_UpdatePos(&this->actor); + } +} + +void EnTanron4_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnTanron4* this = THIS; + + if (this->timeInfluence < 1400.0f) { + Matrix_InsertZRotation_s(this->roll, MTXMODE_APPLY); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, NULL, NULL, &this->actor); + } +} diff --git a/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.h b/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.h index abbcc66332..250a62cf12 100644 --- a/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.h +++ b/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.h @@ -2,17 +2,32 @@ #define Z_EN_TANRON4_H #include "global.h" +#include "assets/objects/object_tanron4/object_tanron4.h" struct EnTanron4; typedef void (*EnTanron4ActionFunc)(struct EnTanron4*, GlobalContext*); typedef struct EnTanron4 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xE8]; + /* 0x000 */ Actor actor; + /* 0x144 */ s16 randRollTimer; + /* 0x146 */ s16 timers[2]; + /* 0x14A */ u8 flyState; + /* 0x14C */ Vec3f targetPos; + /* 0x158 */ s16 step; + /* 0x15A */ s16 roll; + /* 0x15C */ s16 rollTarget; + /* 0x160 */ f32 timeInfluence; + /* 0x164 */ SkelAnime skelAnime; + /* 0x1A8 */ Vec3s jointTable[OBJECT_TANRON4_LIMB_MAX]; + /* 0x1EA */ Vec3s morphTable[OBJECT_TANRON4_LIMB_MAX]; /* 0x022C */ EnTanron4ActionFunc actionFunc; } EnTanron4; // size = 0x230 +// other than these magic values, params is the number of desired seagulls in the flock +#define SEAGULL_CLONE -1 +#define SEAGULL_FOLLOW_ACTOR 100 + extern const ActorInit En_Tanron4_InitVars; #endif // Z_EN_TANRON4_H diff --git a/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c b/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c index 36f5073271..85baedbc87 100644 --- a/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c +++ b/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c @@ -5,6 +5,9 @@ */ #include "z_en_tanron5.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_boss02/object_boss02.h" +#include "overlays/actors/ovl_Boss_02/z_boss_02.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -15,7 +18,11 @@ void EnTanron5_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnTanron5_Update(Actor* thisx, GlobalContext* globalCtx); void EnTanron5_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80BE5818(Actor* thisx, GlobalContext* globalCtx); +void func_80BE5C10(Actor* thisx, GlobalContext* globalCtx); + +s32 D_80BE5D80 = 0; + const ActorInit En_Tanron5_InitVars = { ACTOR_EN_TANRON5, ACTORCAT_BOSS, @@ -28,32 +35,494 @@ const ActorInit En_Tanron5_InitVars = { (ActorFunc)EnTanron5_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BE5DA4 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_ALL, AC_ON | AC_TYPE_PLAYER | AC_TYPE_ENEMY | AC_TYPE_OTHER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK2, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ALL, + AC_ON | AC_TYPE_PLAYER | AC_TYPE_ENEMY | AC_TYPE_OTHER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK2, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 70, 450, 0, { 0, 0, 0 } }, }; -#endif +f32 D_80BE5DD0 = 1.0f; -extern ColliderCylinderInit D_80BE5DA4; +Vec2s D_80BE5DD4[] = { + { 0x4B0, 0x9C4 }, { -0x4B0, 0x9C4 }, { 0x4B0, -0x9C4 }, { -0x4B0, -0x9C4 }, { 0x9C4, 0x4B0 }, + { -0x9C4, 0x4B0 }, { 0x9C4, -0x4B0 }, { -0x9C4, -0x4B0 }, { 0x3E8, 0x3E8 }, { -0x3E8, 0x3E8 }, + { 0x3E8, -0x3E8 }, { -0x3E8, -0x3E8 }, { 0x000, -0x3E8 }, { 0x000, 0x3E8 }, { 0x3E8, 0x000 }, + { -0x3E8, 0x000 }, { 0x000, -0x7D0 }, { 0x000, 0x7D0 }, { 0x7D0, 0x000 }, { -0x7D0, 0x000 }, +}; -extern UNK_TYPE D_06007A88; -extern UNK_TYPE D_06007D18; +Gfx* D_80BE5E24[] = { + gTwinmoldMajoraPillarDL, gTwinmoldMajoraPillarDL, gTwinmoldMajoraPillarDL, gTwinmoldMajoraPillarDL, + gTwinmoldMajoraPillarDL, gTwinmoldMajoraPillarDL, gTwinmoldMajoraPillarDL, gTwinmoldMajoraPillarDL, + gTwinmoldMajoraPillarDL, gTwinmoldMajoraPillarDL, gTwinmoldMajoraPillarDL, gTwinmoldMajoraPillarDL, + gTwinmoldPyramidRuinDL, gTwinmoldPyramidRuinDL, gTwinmoldPyramidRuinDL, gTwinmoldPyramidRuinDL, + gTwinmoldPyramidRuinDL, gTwinmoldPyramidRuinDL, gTwinmoldPyramidRuinDL, gTwinmoldPyramidRuinDL, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron5/func_80BE4930.s") +f32 D_80BE5E74[] = { + 0.09f, 0.09f, 0.09f, 0.09f, 0.09f, 0.09f, 0.09f, 0.09f, 0.09f, 0.09f, + 0.09f, 0.09f, 0.09f, 0.09f, 0.09f, 0.09f, 0.09f, 0.09f, 0.09f, 0.09f, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron5/func_80BE4A2C.s") +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ f32 unk_10; + /* 0x14 */ f32 unk_14; + /* 0x18 */ Vec3f unk_18; + /* 0x24 */ u8 unk_24; + /* 0x26 */ s16 unk_26; + /* 0x28 */ UNK_TYPE1 unk28[0x4]; + /* 0x2C */ s16 unk_2C; + /* 0x2E */ UNK_TYPE1 unk2E[0x6]; + /* 0x34 */ f32 unk_34; + /* 0x38 */ f32 unk_38; +} EnTanron5Effect; // size = 0x3C -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron5/EnTanron5_Init.s") +void func_80BE4930(EnTanron5Effect* effect, Vec3f* arg1, f32 arg2) { + s16 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron5/EnTanron5_Destroy.s") + for (i = 0; i < 150; i++, effect++) { + if (effect->unk_24 == 0) { + effect->unk_24 = 1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron5/EnTanron5_Update.s") + effect->unk_00 = *arg1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron5/func_80BE5818.s") + effect->unk_0C = randPlusMinusPoint5Scaled(10.0f); + effect->unk_10 = Rand_ZeroFloat(2.0f) + 3.0f; + effect->unk_14 = randPlusMinusPoint5Scaled(10.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron5/EnTanron5_Draw.s") + effect->unk_18.y = -0.15f; + effect->unk_18.x = 0.0f; + effect->unk_18.z = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron5/func_80BE5C10.s") + effect->unk_2C = Rand_ZeroFloat(100.0f) + 200.0f; + effect->unk_26 = 0; + effect->unk_34 = arg2; + effect->unk_38 = 2.0f * arg2; + break; + } + } +} + +void func_80BE4A2C(EnTanron5Effect* effect, Vec3f* arg1, f32 arg2) { + s16 i; + + for (i = 0; i < 150; i++, effect++) { + if (effect->unk_24 == 0) { + effect->unk_24 = 2; + + effect->unk_00 = *arg1; + + effect->unk_0C = randPlusMinusPoint5Scaled(30.0f); + effect->unk_10 = Rand_ZeroFloat(7.0f); + effect->unk_14 = randPlusMinusPoint5Scaled(30.0f); + + effect->unk_18.y = -0.3f; + effect->unk_18.x = 0.0f; + effect->unk_18.z = 0.0f; + + effect->unk_2C = Rand_ZeroFloat(70.0f) + 150.0f; + effect->unk_26 = 0; + effect->unk_34 = arg2; + effect->unk_38 = 2.0f * arg2; + break; + } + } +} + +void EnTanron5_Init(Actor* thisx, GlobalContext* globalCtx) { + EnTanron5* this = THIS; + + if (ENTANRON5_GET(&this->actor) >= ENTANRON5_100) { + D_80BE5D80++; + if (D_80BE5D80 > 60) { + Actor_MarkForDeath(&this->actor); + return; + } + + this->unk_198 = randPlusMinusPoint5Scaled(0x2000); + this->unk_19A = randPlusMinusPoint5Scaled(0x2000); + + if (ENTANRON5_GET(&this->actor) < ENTANRON5_107) { + Actor_SetScale(&this->actor, (Rand_ZeroFloat(0.025f) + 0.085f) * D_80BE5DD0); + } else { + Actor_SetScale(&this->actor, (Rand_ZeroFloat(0.015f) + 0.01f) * D_80BE5DD0); + } + + this->actor.speedXZ = (Rand_ZeroFloat(10.0f) + 10.0f) * D_80BE5DD0; + this->actor.velocity.y = (Rand_ZeroFloat(10.0f) + 15.0f) * D_80BE5DD0; + this->actor.gravity = -2.5f * D_80BE5DD0; + this->actor.terminalVelocity = -1000.0f * D_80BE5DD0; + this->actor.update = func_80BE5818; + + if (ENTANRON5_GET(&this->actor) >= ENTANRON5_110) { + this->actor.draw = func_80BE5C10; + this->unk_1A0 = Rand_ZeroFloat(1.999f); + Actor_SetScale(&this->actor, D_80BE5DD0 * 0.03f); + this->unk_144 = 250; + this->actor.shape.rot.x = this->actor.shape.rot.y = this->actor.shape.rot.z = 0; + } else { + this->unk_148 = gRuinFragmentDL; + this->unk_144 = 150; + } + } else if (ENTANRON5_GET(&this->actor) == ENTANRON5_0) { + EnTanron5* child; + s32 i; + + for (i = 0; i < ARRAY_COUNT(D_80BE5E74); i++) { + child = + (EnTanron5*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_TANRON5, D_80BE5DD4[i].x, + this->actor.world.pos.y, D_80BE5DD4[i].z, 0, Rand_ZeroFloat(0x10000), 0, i + 1); + + child->actor.parent = this->actor.parent; + child->unk_19C = D_80BE5E74[i]; + + Actor_SetScale(&child->actor, child->unk_19C); + + child->unk_148 = D_80BE5E24[i]; + if (child->unk_148 == gTwinmoldPyramidRuinDL) { + child->actor.shape.rot.y = 0; + } + + Collider_InitAndSetCylinder(globalCtx, &child->collider, &child->actor, &sCylinderInit); + } + + Actor_MarkForDeath(&this->actor); + } else { + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 50.0f, 150.0f, 100.0f, 4); + this->actor.world.pos.y = this->actor.floorHeight + -20.0f; + } +} + +void EnTanron5_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnTanron5* this = THIS; + + if (ENTANRON5_GET(&this->actor) >= ENTANRON5_100) { + D_80BE5D80--; + } +} + +void EnTanron5_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnTanron5* this = THIS; + Boss02* boss02 = (Boss02*)this->actor.parent; + Player* player = GET_PLAYER(globalCtx2); + s32 i; + s32 phi_v0; + s32 spC4; + Vec3f spB8; + + if (this->unk_1A0 >= 3) { + this->unk_1A0++; + Actor_SetScale(&this->actor, 0.0f); + if (this->unk_1A0 >= 40) { + Actor_MarkForDeath(&this->actor); + } + return; + } else { + // required + } + + if (this->unk_144 != 0) { + this->unk_144--; + } + + if (boss02->actor.update != NULL) { + D_80BE5DD0 = boss02->unk_01AC; + } else { + D_80BE5DD0 = 1.0f; + } + + Actor_SetScale(&this->actor, this->unk_19C * D_80BE5DD0); + + if (this->unk_148 == gTwinmoldMajoraPillarDL) { + this->collider.dim.radius = 65.0f * D_80BE5DD0; + this->collider.dim.height = 380.0f * D_80BE5DD0; + } else if (this->unk_1A0 == 0) { + this->collider.dim.radius = 85.0f * D_80BE5DD0; + this->collider.dim.height = 200.0f * D_80BE5DD0; + } else if (this->unk_1A0 == 1) { + this->collider.dim.radius = 95.0f * D_80BE5DD0; + this->collider.dim.height = 100.0f * D_80BE5DD0; + } else if (this->unk_1A0 == 2) { + this->collider.dim.radius = 95.0f * D_80BE5DD0; + this->collider.dim.height = 30.0f * D_80BE5DD0; + } + + if (this->unk_144 == 0) { + if (this->collider.base.acFlags & AC_HIT) { + ColliderInfo* acHitInfo = this->collider.info.acHitInfo; + Actor* ac = this->collider.base.ac; + + this->collider.base.acFlags &= ~AC_HIT; + spC4 = 10; + + if (Play_InCsMode(globalCtx)) { + this->unk_144 = 1; + } else { + this->unk_144 = 5; + spC4 = (s32)Rand_ZeroFloat(2.99f) + 10; + } + + if ((KREG(19) != 0) || ((acHitInfo->toucher.dmgFlags & 0x05000202) && (D_80BE5DD0 < 0.5f)) || + (ac->id == ACTOR_BOSS_02)) { + if (this->unk_148 == gTwinmoldMajoraPillarDL) { + Math_Vec3f_Copy(&spB8, &this->actor.world.pos); + spB8.y += D_80BE5DD0 * 300.0f; + + for (i = 3; i < spC4; i++) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_TANRON5, spB8.x, spB8.y, spB8.z, + Rand_ZeroFloat(0x10000), Rand_ZeroFloat(0x10000), 0, i + 100); + } + + for (i = 0; i < 6; i++) { + func_80BE4A2C(globalCtx->specialEffects, &spB8, Rand_ZeroFloat(3.0f) + 6.0f); + } + + this->actor.world.pos.y -= D_80BE5DD0 * 130.0f; + } else { + f32 spAC; + f32 spA8; + Vec3f sp9C; + + if (this->unk_1A0 == 0) { + spAC = 180.0f; + this->unk_19C *= 1.4f; + } else if (this->unk_1A0 == 1) { + spAC = 230.0f; + this->unk_19C *= 1.37f; + } else if (this->unk_1A0 == 2) { + spAC = 780.0f; + this->unk_19C *= 1.5f; + } + // TODO: determine if unk_1A0 ever has a different value from these 3, which will cause UB from spAC + // being uninitialised + this->actor.world.pos.y -= D_80BE5DD0 * spAC; + Actor_SetScale(&this->actor, this->unk_19C * D_80BE5DD0); + Math_Vec3f_Copy(&spB8, &this->actor.world.pos); + + for (i = 0; i < spC4; i++) { + if (this->unk_1A0 == 0) { + spA8 = 100.0f; + spAC = 180.0f; + } else if (this->unk_1A0 == 1) { + spA8 = 200.0f; + spAC = 100.0f; + } else if (this->unk_1A0 == 2) { + spA8 = 250.0f; + spAC = 50.0f; + } + + sp9C.x = (randPlusMinusPoint5Scaled(spA8) * D_80BE5DD0) + spB8.x; + sp9C.z = (randPlusMinusPoint5Scaled(spA8) * D_80BE5DD0) + spB8.z; + sp9C.y = this->actor.floorHeight + (spAC * D_80BE5DD0); + + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_TANRON5, sp9C.x, sp9C.y, sp9C.z, + Rand_ZeroFloat(0x10000), Rand_ZeroFloat(0x10000), 0, i + 100); + + if (i < 8) { + func_80BE4A2C(globalCtx->specialEffects, &sp9C, Rand_ZeroFloat(3.0f) + 6.0f); + } + } + } + + if (Rand_ZeroOne() < 0.333f) { + phi_v0 = 0x4000; + } else if (Rand_ZeroOne() < 0.5f) { + phi_v0 = -0x8000; + } else { + phi_v0 = -0x4000; + } + + this->actor.shape.rot.y += phi_v0; + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_BIG_BOMB_EXPLOSION); + func_800BC848(&this->actor, globalCtx, 4, 4); + this->unk_1A0++; + } else { + Vec3f sp90; + ColliderInfo* info = this->collider.info.acHitInfo; + + sp90.x = info->bumper.hitPos.x; + sp90.y = info->bumper.hitPos.y; + sp90.z = info->bumper.hitPos.z; + + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_SHIELD_REFLECT_SW); + CollisionCheck_SpawnShieldParticlesMetal(globalCtx, &sp90); + } + } + } + + Collider_UpdateCylinder(&this->actor, &this->collider); + if (this->unk_148 == gTwinmoldPyramidRuinDL) { + this->collider.dim.pos.y = this->actor.floorHeight; + } + + if ((this->unk_148 == gTwinmoldMajoraPillarDL) || (D_80BE5DD0 < 0.5f)) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } else { + f32 xDiff = player->actor.world.pos.x - this->actor.world.pos.x; + f32 yDiff = player->actor.world.pos.z - this->actor.world.pos.z; + + if ((fabsf(xDiff) < 120.0f) && (fabsf(yDiff) < 120.0f)) { + if (fabsf(yDiff) < fabsf(xDiff)) { + if (xDiff > 0.0f) { + player->actor.prevPos.x = player->actor.world.pos.x = this->actor.world.pos.x + 120.0f; + } else { + player->actor.prevPos.x = player->actor.world.pos.x = this->actor.world.pos.x - 120.0f; + } + } else if (yDiff > 0.0f) { + player->actor.prevPos.z = player->actor.world.pos.z = this->actor.world.pos.z + 120.0f; + } else { + player->actor.prevPos.z = player->actor.world.pos.z = this->actor.world.pos.z - 120.0f; + } + } + } + + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +void func_80BE5818(Actor* thisx, GlobalContext* globalCtx2) { + f32 sp6C; + s32 i; + Vec3f sp5C; + EnTanron5* this = THIS; + GlobalContext* globalCtx = globalCtx2; + + if ((ENTANRON5_GET(&this->actor) < ENTANRON5_110) && (this->unk_1A0 != 0)) { + this->unk_1A0++; + this->actor.world.pos.y -= 2.0f * D_80BE5DD0; + if (this->unk_1A0 == 40) { + Actor_MarkForDeath(&this->actor); + } + return; + } + + if (DECR(this->unk_144) == 0) { + Actor_MarkForDeath(&this->actor); + } + + if (this->actor.speedXZ > 0.02f) { + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 50.0f, 150.0f, 100.0f, 4); + } + + if (ENTANRON5_GET(&this->actor) < ENTANRON5_110) { + this->actor.shape.rot.x += this->unk_198; + this->actor.shape.rot.y += this->unk_19A; + sp6C = 1225.0f; + + if (this->actor.bgCheckFlags & 1) { + if (ENTANRON5_GET(&this->actor) < ENTANRON5_108) { + Math_Vec3f_Copy(&sp5C, &this->actor.world.pos); + sp5C.y = this->actor.floorHeight; + + for (i = 0; i < 4; i++) { + func_80BE4930(globalCtx->specialEffects, &sp5C, Rand_ZeroFloat(1.0f) + 2.0f); + } + this->unk_1A0++; + } else { + Actor_MarkForDeath(&this->actor); + } + } + } else { + sp6C = 400.0f; + this->unk_198 += 0x2000; + if (this->actor.bgCheckFlags & 1) { + this->unk_198 = 0; + this->actor.speedXZ = 0.0f; + } + } + + if (this->unk_1A1 == 0) { + if ((D_80BE5DD0 > 0.5f) && + ((ENTANRON5_GET(&this->actor) < ENTANRON5_108) || (ENTANRON5_GET(&this->actor) >= ENTANRON5_110))) { + Player* player = GET_PLAYER(globalCtx); + Vec3f temp; + + temp.x = player->actor.world.pos.x - this->actor.world.pos.x; + temp.y = (player->actor.world.pos.y + 10.0f) - this->actor.world.pos.y; + temp.z = player->actor.world.pos.z - this->actor.world.pos.z; + + if (SQXYZ(temp) < sp6C) { + if (ENTANRON5_GET(&this->actor) >= ENTANRON5_110) { + if (this->unk_1A0 == 0) { + Item_Give(globalCtx, ITEM_ARROWS_10); + } else { + Item_Give(globalCtx, ITEM_MAGIC_LARGE); + } + Actor_MarkForDeath(&this->actor); + play_sound(NA_SE_SY_GET_ITEM); + } else { + this->unk_1A1 = 20; + func_800B8D50(globalCtx, NULL, 5.0f, this->actor.world.rot.y, 0.0f, 8); + } + } + } + } else { + this->unk_1A1--; + } +} + +void EnTanron5_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnTanron5* this = THIS; + + if ((-500.0f * D_80BE5DD0) < this->actor.projectedPos.z) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, this->unk_148); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +void func_80BE5C10(Actor* thisx, GlobalContext* globalCtx) { + EnTanron5* this = THIS; + TexturePtr texture; + s32 phi_v0; + + if ((this->unk_144 > 50) || (this->unk_144 & 1)) { + phi_v0 = true; + } else { + phi_v0 = false; + } + + if (((-500.0f * D_80BE5DD0) < this->actor.projectedPos.z) && phi_v0) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + if (this->unk_1A0 == 0) { + texture = gameplay_keep_Tex_05BEF0; + } else { + texture = gameplay_keep_Tex_0617C0; + } + + POLY_OPA_DISP = func_8012C724(POLY_OPA_DISP); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(texture)); + + Matrix_InsertTranslation(0.0f, 200.0f, 0.0f, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_198, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_05F6F0); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.h b/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.h index c19bb1dedd..576309694f 100644 --- a/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.h +++ b/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.h @@ -5,9 +5,24 @@ struct EnTanron5; +#define ENTANRON5_GET(thisx) ((thisx)->params) + +#define ENTANRON5_0 0 +#define ENTANRON5_100 100 +#define ENTANRON5_107 107 +#define ENTANRON5_108 108 +#define ENTANRON5_110 110 + typedef struct EnTanron5 { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x60]; + /* 0x0144 */ s16 unk_144; + /* 0x0148 */ Gfx* unk_148; + /* 0x014C */ ColliderCylinder collider; + /* 0x0198 */ s16 unk_198; + /* 0x019A */ s16 unk_19A; + /* 0x019C */ f32 unk_19C; + /* 0x01A0 */ u8 unk_1A0; + /* 0x01A1 */ u8 unk_1A1; } EnTanron5; // size = 0x1A4 extern const ActorInit En_Tanron5_InitVars; diff --git a/src/overlays/actors/ovl_En_Test/z_en_test.c b/src/overlays/actors/ovl_En_Test/z_en_test.c index 0a0b86ea1c..7f99833b42 100644 --- a/src/overlays/actors/ovl_En_Test/z_en_test.c +++ b/src/overlays/actors/ovl_En_Test/z_en_test.c @@ -5,6 +5,7 @@ */ #include "z_en_test.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_10) @@ -15,7 +16,6 @@ void EnTest_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnTest_Update(Actor* thisx, GlobalContext* globalCtx); void EnTest_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit En_Test_InitVars = { ACTOR_EN_TEST, ACTORCAT_ITEMACTION, @@ -28,22 +28,247 @@ const ActorInit En_Test_InitVars = { (ActorFunc)EnTest_Draw, }; -#endif +void func_80862B70(EnTestStruct* arg0) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test/func_80862B70.s") + for (i = 0; i < 20; i++) { + EnTestStruct* ptr = &arg0[i]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test/func_80862CBC.s") + ptr->unk_00 = false; + ptr->unk_04 = 0; + ptr->unk_08.x = 0.0f; + ptr->unk_08.y = 0.0f; + ptr->unk_08.z = 0.0f; + ptr->unk_14.x = 0.0f; + ptr->unk_14.y = 0.0f; + ptr->unk_14.z = 0.0f; + ptr->unk_20.x = 0.0f; + ptr->unk_20.y = 0.0f; + ptr->unk_20.z = 0.0f; + ptr->unk_2C = 0.001f; + ptr->unk_30.x = 0; + ptr->unk_30.y = 0; + ptr->unk_30.z = 0; + ptr->unk_36.x = 0; + ptr->unk_36.y = 0; + ptr->unk_36.z = 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test/func_80862EDC.s") +void func_80862CBC(EnTestStruct* arg0, Vec3f* arg1) { + EnTestStruct* ptr; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test/func_80863048.s") + for (i = 0; i < 20; i++) { + ptr = &arg0[i]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test/EnTest_Init.s") + if (!ptr->unk_00) { + s16 sp26 = Rand_ZeroOne() * 0xFFFF; + f32 sp20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test/EnTest_Destroy.s") + ptr->unk_00 = true; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test/EnTest_Update.s") + ptr->unk_08.x = (Math_CosS(sp26) * 20.0f) + arg1->x; + ptr->unk_08.y = arg1->y; + ptr->unk_08.z = (Math_SinS(sp26) * 20.0f) + arg1->z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test/func_808634B8.s") + sp20 = Rand_ZeroOne(); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test/EnTest_Draw.s") + ptr->unk_14.x = Math_CosS(sp26) * 13.0f * sp20; + ptr->unk_14.y = (Rand_ZeroOne() * 5.0f) + 8.0f; + ptr->unk_14.z = (Math_SinS(sp26) * 13.0f) * sp20; + + ptr->unk_20.x = 0.0f; + ptr->unk_20.z = 0.0f; + ptr->unk_20.y = -2.0f; + + ptr->unk_2C = (Rand_ZeroOne() * 0.0004f) + 0.0004f; + + ptr->unk_30.x = Rand_ZeroOne() * 0x7FFE; + ptr->unk_30.y = Rand_ZeroOne() * 0x7FFE; + ptr->unk_30.z = Rand_ZeroOne() * 0x7FFE; + + ptr->unk_36.x = Rand_ZeroOne() * 0x2000; + ptr->unk_36.y = Rand_ZeroOne() * 0x2000; + ptr->unk_36.z = Rand_ZeroOne() * 0x2000; + + ptr->unk_04 = 10; + break; + } + } +} + +void func_80862EDC(EnTestStruct* arg0) { + s32 i; + EnTestStruct* ptr; + + for (i = 0; i < 20; i++) { + ptr = &arg0[i]; + + if (ptr->unk_00) { + ptr->unk_04--; + if (ptr->unk_04 < 0) { + ptr->unk_00 = false; + } + + ptr->unk_08.x += ptr->unk_14.x; + ptr->unk_08.y += ptr->unk_14.y; + ptr->unk_08.z += ptr->unk_14.z; + + ptr->unk_14.x += ptr->unk_20.x; + ptr->unk_14.y += ptr->unk_20.y; + ptr->unk_14.z += ptr->unk_20.z; + + ptr->unk_30.x += ptr->unk_36.x; + ptr->unk_30.y += ptr->unk_36.y; + ptr->unk_30.z += ptr->unk_36.z; + } + } +} + +void func_80863048(GlobalContext* globalCtx, EnTestStruct* arg1) { + EnTestStruct* ptr; + s32 i; + Mtx* mtx; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x80, 255, 255, 255, 255); + gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 255); + + for (i = 0; i < 20; i++) { + ptr = &arg1[i]; + + if (!ptr->unk_00) { + continue; + } + + Matrix_InsertTranslation(ptr->unk_08.x, ptr->unk_08.y, ptr->unk_08.z, MTXMODE_NEW); + Matrix_InsertRotation(ptr->unk_30.x, ptr->unk_30.y, ptr->unk_30.z, MTXMODE_APPLY); + Matrix_Scale(ptr->unk_2C, ptr->unk_2C, ptr->unk_2C, MTXMODE_APPLY); + + mtx = Matrix_NewMtx(globalCtx->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_06AB30); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void EnTest_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnTest* this = THIS; + MtxF sp38; + s32 sp34; + + this->unk_209 = 0; + this->unk_174 = 0; + + if (thisx->params > 0) { + Actor_SetScale(thisx, thisx->params / 100000.0f); + this->unk_20A = 0; + } else { + thisx->floorPoly = NULL; + thisx->world.pos.y += 10.0f; + thisx->floorHeight = + BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, &thisx->floorPoly, &sp34, &thisx->world.pos); + + if ((thisx->floorPoly == NULL) || (thisx->floorHeight == BGCHECK_Y_MIN)) { + Actor_MarkForDeath(thisx); + return; + } + + thisx->world.pos.y = thisx->floorHeight; + func_800C0094(thisx->floorPoly, thisx->world.pos.x, thisx->floorHeight, thisx->world.pos.z, &sp38); + func_8018219C(&sp38, &thisx->shape.rot, 1); + thisx->world.rot = thisx->shape.rot; + this->unk_20A = func_800C9BB8(&globalCtx->colCtx, thisx->floorPoly, sp34); + } + + func_80183430(&this->skeletonInfo, &gameplay_keep_Blob_06EB70, &gameplay_keep_Blob_06BB0C, this->unk_178, + this->unk_1C0, NULL); + func_801834A8(&this->skeletonInfo, &gameplay_keep_Blob_06BB0C); + this->skeletonInfo.frameCtrl.unk_10 = 9.0f; + func_80862B70(this->unk_20C); +} + +void EnTest_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnTest* this = THIS; + + func_8018349C(&this->skeletonInfo); +} + +void EnTest_Update(Actor* thisx, GlobalContext* globalCtx) { + EnTest* this = THIS; + s32 i; + + this->unk_208 = this->skeletonInfo.frameCtrl.unk_10; + + if (func_80183DE0(&this->skeletonInfo) && (this->actor.parent == NULL) && (this->actor.params != -1)) { + this->unk_209++; + if (this->unk_209 > 20) { + Actor_MarkForDeath(&this->actor); + } + } + + if ((this->actor.params != -1) && (this->unk_208 >= 2)) { + if (!(this->unk_174 & 1)) { + this->unk_174 |= 1; + + for (i = 0; i < ARRAY_COUNT(this->unk_20C); i++) { + func_80862CBC(this->unk_20C, &this->actor.world.pos); + } + } + } + func_80862EDC(this->unk_20C); +} + +s32 EnTest_OverrideKeyframeDraw(GlobalContext* globalCtx, SkeletonInfo* skeletonInfo, s32 limbIndex, Gfx** dList, + u8* flags, Actor* thisx, Vec3f* scale, Vec3s* rot, Vec3f* pos) { + EnTest* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if ((this->actor.params == -1) && ((limbIndex == 1) || (limbIndex == 2))) { + *dList = NULL; + } + + if ((this->actor.params == -2) && (limbIndex == 3)) { + *dList = NULL; + } + + if (limbIndex == 3) { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 0, 0, 0, ((20 - this->unk_209) * 255.0f) / 20.0f); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, ((20 - this->unk_209) * 255.0f) / 20.0f); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + return true; +} + +void EnTest_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnTest* this = THIS; + Mtx* sp28; + s32 sp2C = this->unk_208 - 1; + + if (sp2C >= 29) { + sp2C = 29; + } + + if ((this->unk_20A == 15) || (this->unk_20A == 14)) { + AnimatedMat_DrawStep(globalCtx, Lib_SegmentedToVirtual(gameplay_keep_Matanimheader_06B730), sp2C); + } else { + AnimatedMat_DrawStep(globalCtx, Lib_SegmentedToVirtual(gameplay_keep_Matanimheader_06B6A0), sp2C); + } + + sp28 = GRAPH_ALLOC(globalCtx->state.gfxCtx, ALIGN16(this->skeletonInfo.unk_18->unk_1 * sizeof(Mtx))); + + if (sp28 != NULL) { + func_8012C2DC(globalCtx->state.gfxCtx); + func_8018450C(globalCtx, &this->skeletonInfo, sp28, EnTest_OverrideKeyframeDraw, NULL, thisx); + func_80863048(globalCtx, this->unk_20C); + } +} diff --git a/src/overlays/actors/ovl_En_Test/z_en_test.h b/src/overlays/actors/ovl_En_Test/z_en_test.h index 32015ecb17..bcb0c4a1e4 100644 --- a/src/overlays/actors/ovl_En_Test/z_en_test.h +++ b/src/overlays/actors/ovl_En_Test/z_en_test.h @@ -5,9 +5,27 @@ struct EnTest; +typedef struct { + /* 0x00 */ s32 unk_00; + /* 0x04 */ s32 unk_04; + /* 0x08 */ Vec3f unk_08; + /* 0x14 */ Vec3f unk_14; + /* 0x20 */ Vec3f unk_20; + /* 0x2C */ f32 unk_2C; + /* 0x30 */ Vec3s unk_30; + /* 0x36 */ Vec3s unk_36; +} EnTestStruct; // size = 0x3C + typedef struct EnTest { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x578]; + /* 0x144 */ SkeletonInfo skeletonInfo; + /* 0x174 */ s32 unk_174; + /* 0x178 */ Vec3s unk_178[12]; + /* 0x1C0 */ s16 unk_1C0[36]; + /* 0x208 */ u8 unk_208; + /* 0x209 */ u8 unk_209; + /* 0x20A */ u8 unk_20A; + /* 0x20C */ EnTestStruct unk_20C[20]; } EnTest; // size = 0x6BC extern const ActorInit En_Test_InitVars; diff --git a/src/overlays/actors/ovl_En_Test4/z_en_test4.c b/src/overlays/actors/ovl_En_Test4/z_en_test4.c index 6886d2b29e..729a82a705 100644 --- a/src/overlays/actors/ovl_En_Test4/z_en_test4.c +++ b/src/overlays/actors/ovl_En_Test4/z_en_test4.c @@ -51,11 +51,11 @@ void func_80A41D70(EnTest4* this, GlobalContext* globalCtx) { } else if ((sCutscenes[this->unk_144] < 0) || ((globalCtx->actorCtx.unk5 & 2) != 0)) { if (globalCtx->actorCtx.unk5 & 2) { Sram_IncrementDay(); - gSaveContext.time = CLOCK_TIME(6, 0); + gSaveContext.save.time = CLOCK_TIME(6, 0); func_80151A68(globalCtx, sDayMessages1[CURRENT_DAY - 1]); } else { this->unk_144 = 0; - this->unk_146 = gSaveContext.time += CLOCK_TIME_MINUTE; + this->unk_146 = gSaveContext.save.time += CLOCK_TIME_MINUTE; } func_8010EE74(globalCtx, CURRENT_DAY); @@ -84,7 +84,7 @@ void func_80A41D70(EnTest4* this, GlobalContext* globalCtx) { this->unk_144 = 0; } - this->unk_146 = gSaveContext.time += CLOCK_TIME_MINUTE; + this->unk_146 = gSaveContext.save.time += CLOCK_TIME_MINUTE; } } @@ -93,7 +93,7 @@ void func_80A41FA4(EnTest4* this, GlobalContext* globalCtx) { func_80151A68(globalCtx, sNightMessages2[CURRENT_DAY - 1]); } else if ((sCutscenes[this->unk_144] < 0) || ((globalCtx->actorCtx.unk5 & 2) != 0)) { Sram_IncrementDay(); - gSaveContext.time = CLOCK_TIME(6, 0); + gSaveContext.save.time = CLOCK_TIME(6, 0); func_8010EE74(globalCtx, CURRENT_DAY); func_80151A68(globalCtx, sDayMessages2[CURRENT_DAY - 1]); D_801BDBC8 = 0xFE; @@ -121,168 +121,168 @@ void func_80A41FA4(EnTest4* this, GlobalContext* globalCtx) { this->unk_144 = 0; } - this->unk_146 = gSaveContext.time += CLOCK_TIME_MINUTE; + this->unk_146 = gSaveContext.save.time += CLOCK_TIME_MINUTE; } } // Bells on last day void func_80A42198(EnTest4* this) { - if ((gSaveContext.time >= CLOCK_TIME(6, 0)) && (gSaveContext.time <= CLOCK_TIME(18, 0))) { - if (gSaveContext.time < CLOCK_TIME(17, 30)) { + if ((gSaveContext.save.time >= CLOCK_TIME(6, 0)) && (gSaveContext.save.time <= CLOCK_TIME(18, 0))) { + if (gSaveContext.save.time < CLOCK_TIME(17, 30)) { this->nextBellTime = CLOCK_TIME(17, 30); - } else if (gSaveContext.time < CLOCK_TIME(17, 36)) { + } else if (gSaveContext.save.time < CLOCK_TIME(17, 36)) { this->nextBellTime = CLOCK_TIME(17, 36); - } else if (gSaveContext.time < CLOCK_TIME(17, 42)) { + } else if (gSaveContext.save.time < CLOCK_TIME(17, 42)) { this->nextBellTime = CLOCK_TIME(17, 42); - } else if (gSaveContext.time < CLOCK_TIME(17, 48)) { + } else if (gSaveContext.save.time < CLOCK_TIME(17, 48)) { this->nextBellTime = CLOCK_TIME(17, 48); - } else if (gSaveContext.time < CLOCK_TIME(17, 54)) { + } else if (gSaveContext.save.time < CLOCK_TIME(17, 54)) { this->nextBellTime = CLOCK_TIME(17, 54); } else { this->nextBellTime = CLOCK_TIME(0, 0); } - } else if (gSaveContext.time > CLOCK_TIME(6, 0)) { + } else if (gSaveContext.save.time > CLOCK_TIME(6, 0)) { this->nextBellTime = CLOCK_TIME(0, 0); - } else if (gSaveContext.time < CLOCK_TIME(0, 10)) { + } else if (gSaveContext.save.time < CLOCK_TIME(0, 10)) { this->nextBellTime = CLOCK_TIME(0, 10); - } else if (gSaveContext.time < CLOCK_TIME(0, 20)) { + } else if (gSaveContext.save.time < CLOCK_TIME(0, 20)) { this->nextBellTime = CLOCK_TIME(0, 20); - } else if (gSaveContext.time < CLOCK_TIME(0, 30)) { + } else if (gSaveContext.save.time < CLOCK_TIME(0, 30)) { this->nextBellTime = CLOCK_TIME(0, 30); - } else if (gSaveContext.time < CLOCK_TIME(0, 40)) { + } else if (gSaveContext.save.time < CLOCK_TIME(0, 40)) { this->nextBellTime = CLOCK_TIME(0, 40); - } else if (gSaveContext.time < CLOCK_TIME(0, 50)) { + } else if (gSaveContext.save.time < CLOCK_TIME(0, 50)) { this->nextBellTime = CLOCK_TIME(0, 50); - } else if (gSaveContext.time < CLOCK_TIME(1, 0)) { + } else if (gSaveContext.save.time < CLOCK_TIME(1, 0)) { this->nextBellTime = CLOCK_TIME(1, 0); - } else if (gSaveContext.time < CLOCK_TIME(1, 10)) { + } else if (gSaveContext.save.time < CLOCK_TIME(1, 10)) { this->nextBellTime = CLOCK_TIME(1, 10); - } else if (gSaveContext.time < CLOCK_TIME(1, 20)) { + } else if (gSaveContext.save.time < CLOCK_TIME(1, 20)) { this->nextBellTime = CLOCK_TIME(1, 20); - } else if (gSaveContext.time < CLOCK_TIME(1, 30) - 1) { + } else if (gSaveContext.save.time < CLOCK_TIME(1, 30) - 1) { this->nextBellTime = CLOCK_TIME(1, 30) - 1; - } else if (gSaveContext.time < CLOCK_TIME(1, 40) - 1) { + } else if (gSaveContext.save.time < CLOCK_TIME(1, 40) - 1) { this->nextBellTime = CLOCK_TIME(1, 40) - 1; - } else if (gSaveContext.time < CLOCK_TIME(1, 50) - 1) { + } else if (gSaveContext.save.time < CLOCK_TIME(1, 50) - 1) { this->nextBellTime = CLOCK_TIME(1, 50) - 1; - } else if (gSaveContext.time < CLOCK_TIME(2, 0)) { + } else if (gSaveContext.save.time < CLOCK_TIME(2, 0)) { this->nextBellTime = CLOCK_TIME(2, 0); - } else if (gSaveContext.time < CLOCK_TIME(2, 10)) { + } else if (gSaveContext.save.time < CLOCK_TIME(2, 10)) { this->nextBellTime = CLOCK_TIME(2, 10); - } else if (gSaveContext.time < CLOCK_TIME(2, 20)) { + } else if (gSaveContext.save.time < CLOCK_TIME(2, 20)) { this->nextBellTime = CLOCK_TIME(2, 20); - } else if (gSaveContext.time < CLOCK_TIME(2, 30)) { + } else if (gSaveContext.save.time < CLOCK_TIME(2, 30)) { this->nextBellTime = CLOCK_TIME(2, 30); - } else if (gSaveContext.time < CLOCK_TIME(2, 40)) { + } else if (gSaveContext.save.time < CLOCK_TIME(2, 40)) { this->nextBellTime = CLOCK_TIME(2, 40); - } else if (gSaveContext.time < CLOCK_TIME(2, 50)) { + } else if (gSaveContext.save.time < CLOCK_TIME(2, 50)) { this->nextBellTime = CLOCK_TIME(2, 50); - } else if (gSaveContext.time < CLOCK_TIME(3, 0)) { + } else if (gSaveContext.save.time < CLOCK_TIME(3, 0)) { this->nextBellTime = CLOCK_TIME(3, 0); - } else if (gSaveContext.time < CLOCK_TIME(3, 10)) { + } else if (gSaveContext.save.time < CLOCK_TIME(3, 10)) { this->nextBellTime = CLOCK_TIME(3, 10); - } else if (gSaveContext.time < CLOCK_TIME(3, 20)) { + } else if (gSaveContext.save.time < CLOCK_TIME(3, 20)) { this->nextBellTime = CLOCK_TIME(3, 20); - } else if (gSaveContext.time < CLOCK_TIME(3, 30)) { + } else if (gSaveContext.save.time < CLOCK_TIME(3, 30)) { this->nextBellTime = CLOCK_TIME(3, 30); - } else if (gSaveContext.time < CLOCK_TIME(3, 40)) { + } else if (gSaveContext.save.time < CLOCK_TIME(3, 40)) { this->nextBellTime = CLOCK_TIME(3, 40); - } else if (gSaveContext.time < CLOCK_TIME(3, 50)) { + } else if (gSaveContext.save.time < CLOCK_TIME(3, 50)) { this->nextBellTime = CLOCK_TIME(3, 50); - } else if (gSaveContext.time < CLOCK_TIME(4, 0)) { + } else if (gSaveContext.save.time < CLOCK_TIME(4, 0)) { this->nextBellTime = CLOCK_TIME(4, 0); - } else if (gSaveContext.time < CLOCK_TIME(4, 10)) { + } else if (gSaveContext.save.time < CLOCK_TIME(4, 10)) { this->nextBellTime = CLOCK_TIME(4, 10); - } else if (gSaveContext.time < CLOCK_TIME(4, 20)) { + } else if (gSaveContext.save.time < CLOCK_TIME(4, 20)) { this->nextBellTime = CLOCK_TIME(4, 20); - } else if (gSaveContext.time < CLOCK_TIME(4, 30) - 1) { + } else if (gSaveContext.save.time < CLOCK_TIME(4, 30) - 1) { this->nextBellTime = CLOCK_TIME(4, 30) - 1; - } else if (gSaveContext.time < CLOCK_TIME(4, 40) - 1) { + } else if (gSaveContext.save.time < CLOCK_TIME(4, 40) - 1) { this->nextBellTime = CLOCK_TIME(4, 40) - 1; - } else if (gSaveContext.time < CLOCK_TIME(4, 50) - 1) { + } else if (gSaveContext.save.time < CLOCK_TIME(4, 50) - 1) { this->nextBellTime = CLOCK_TIME(4, 50) - 1; - } else if (gSaveContext.time < CLOCK_TIME(5, 0)) { + } else if (gSaveContext.save.time < CLOCK_TIME(5, 0)) { this->nextBellTime = CLOCK_TIME(5, 0); - } else if (gSaveContext.time < CLOCK_TIME(5, 5)) { + } else if (gSaveContext.save.time < CLOCK_TIME(5, 5)) { this->nextBellTime = CLOCK_TIME(5, 5); - } else if (gSaveContext.time < CLOCK_TIME(5, 10)) { + } else if (gSaveContext.save.time < CLOCK_TIME(5, 10)) { this->nextBellTime = CLOCK_TIME(5, 10); - } else if (gSaveContext.time < CLOCK_TIME(5, 15) - 1) { + } else if (gSaveContext.save.time < CLOCK_TIME(5, 15) - 1) { this->nextBellTime = CLOCK_TIME(5, 15) - 1; - } else if (gSaveContext.time < CLOCK_TIME(5, 20)) { + } else if (gSaveContext.save.time < CLOCK_TIME(5, 20)) { this->nextBellTime = CLOCK_TIME(5, 20); - } else if (gSaveContext.time < CLOCK_TIME(5, 25) - 1) { + } else if (gSaveContext.save.time < CLOCK_TIME(5, 25) - 1) { this->nextBellTime = CLOCK_TIME(5, 25) - 1; - } else if (gSaveContext.time < CLOCK_TIME(5, 30)) { + } else if (gSaveContext.save.time < CLOCK_TIME(5, 30)) { this->nextBellTime = CLOCK_TIME(5, 30); - } else if (gSaveContext.time < CLOCK_TIME(5, 33) - 1) { + } else if (gSaveContext.save.time < CLOCK_TIME(5, 33) - 1) { this->nextBellTime = CLOCK_TIME(5, 33) - 1; - } else if (gSaveContext.time < CLOCK_TIME(5, 36)) { + } else if (gSaveContext.save.time < CLOCK_TIME(5, 36)) { this->nextBellTime = CLOCK_TIME(5, 36); - } else if (gSaveContext.time < CLOCK_TIME(5, 39) - 1) { + } else if (gSaveContext.save.time < CLOCK_TIME(5, 39) - 1) { this->nextBellTime = CLOCK_TIME(5, 39) - 1; - } else if (gSaveContext.time < CLOCK_TIME(5, 42)) { + } else if (gSaveContext.save.time < CLOCK_TIME(5, 42)) { this->nextBellTime = CLOCK_TIME(5, 42); - } else if (gSaveContext.time < CLOCK_TIME(5, 45)) { + } else if (gSaveContext.save.time < CLOCK_TIME(5, 45)) { this->nextBellTime = CLOCK_TIME(5, 45); - } else if (gSaveContext.time < CLOCK_TIME(5, 48)) { + } else if (gSaveContext.save.time < CLOCK_TIME(5, 48)) { this->nextBellTime = CLOCK_TIME(5, 48); - } else if (gSaveContext.time < CLOCK_TIME(5, 51)) { + } else if (gSaveContext.save.time < CLOCK_TIME(5, 51)) { this->nextBellTime = CLOCK_TIME(5, 51); - } else if (gSaveContext.time < CLOCK_TIME(5, 54)) { + } else if (gSaveContext.save.time < CLOCK_TIME(5, 54)) { this->nextBellTime = CLOCK_TIME(5, 54); - } else if (gSaveContext.time < CLOCK_TIME(5, 57)) { + } else if (gSaveContext.save.time < CLOCK_TIME(5, 57)) { this->nextBellTime = CLOCK_TIME(5, 57); - } else if (gSaveContext.time < CLOCK_TIME(6, 0)) { + } else if (gSaveContext.save.time < CLOCK_TIME(6, 0)) { this->nextBellTime = CLOCK_TIME(6, 0); } } // Bells on first and second day void func_80A425E4(EnTest4* this, GlobalContext* globalCtx) { - gSaveContext.unk_3F64 = 1000.0f; + gSaveContext.screenScale = 1000.0f; - if ((gSaveContext.time >= CLOCK_TIME(6, 0)) && (gSaveContext.time < CLOCK_TIME(18, 0))) { - if (gSaveContext.time < CLOCK_TIME(17, 30)) { + if ((gSaveContext.save.time >= CLOCK_TIME(6, 0)) && (gSaveContext.save.time < CLOCK_TIME(18, 0))) { + if (gSaveContext.save.time < CLOCK_TIME(17, 30)) { this->nextBellTime = CLOCK_TIME(17, 30); - } else if (gSaveContext.time < CLOCK_TIME(17, 36)) { + } else if (gSaveContext.save.time < CLOCK_TIME(17, 36)) { this->nextBellTime = CLOCK_TIME(17, 36); - } else if (gSaveContext.time < CLOCK_TIME(17, 42)) { + } else if (gSaveContext.save.time < CLOCK_TIME(17, 42)) { this->nextBellTime = CLOCK_TIME(17, 42); - } else if (gSaveContext.time < CLOCK_TIME(17, 48)) { + } else if (gSaveContext.save.time < CLOCK_TIME(17, 48)) { this->nextBellTime = CLOCK_TIME(17, 48); - } else if (gSaveContext.time < CLOCK_TIME(17, 54)) { + } else if (gSaveContext.save.time < CLOCK_TIME(17, 54)) { this->nextBellTime = CLOCK_TIME(17, 54); } else { this->nextBellTime = CLOCK_TIME(5, 30); } } else { - if (gSaveContext.time < CLOCK_TIME(5, 30)) { + if (gSaveContext.save.time < CLOCK_TIME(5, 30)) { this->nextBellTime = CLOCK_TIME(5, 30); - } else if (gSaveContext.time < CLOCK_TIME(5, 36)) { + } else if (gSaveContext.save.time < CLOCK_TIME(5, 36)) { this->nextBellTime = CLOCK_TIME(5, 36); - } else if (gSaveContext.time < CLOCK_TIME(5, 42)) { + } else if (gSaveContext.save.time < CLOCK_TIME(5, 42)) { this->nextBellTime = CLOCK_TIME(5, 42); - gSaveContext.unk_3F64 -= 50.0f; - } else if (gSaveContext.time < CLOCK_TIME(5, 48)) { + gSaveContext.screenScale -= 50.0f; + } else if (gSaveContext.save.time < CLOCK_TIME(5, 48)) { this->nextBellTime = CLOCK_TIME(5, 48); - gSaveContext.unk_3F64 -= 100.0f; - } else if (gSaveContext.time < CLOCK_TIME(5, 54)) { + gSaveContext.screenScale -= 100.0f; + } else if (gSaveContext.save.time < CLOCK_TIME(5, 54)) { this->nextBellTime = CLOCK_TIME(5, 54); - gSaveContext.unk_3F64 -= 150.0f; - } else if (gSaveContext.time < CLOCK_TIME(6, 0)) { + gSaveContext.screenScale -= 150.0f; + } else if (gSaveContext.save.time < CLOCK_TIME(6, 0)) { this->nextBellTime = CLOCK_TIME(17, 30); - gSaveContext.unk_3F64 -= 200.0f; + gSaveContext.screenScale -= 200.0f; } else { this->nextBellTime = CLOCK_TIME(17, 30); } if ((sCutscenes[this->unk_144] < 0) || ((globalCtx->actorCtx.unk5 & 2) != 0) || (CURRENT_DAY == 3) || - (gSaveContext.time >= CLOCK_TIME(17, 0))) { - gSaveContext.unk_3F64 = 1000.0f; + (gSaveContext.save.time >= CLOCK_TIME(17, 0))) { + gSaveContext.screenScale = 1000.0f; } - if (gSaveContext.unk_3F64 != 1000.0f) { - gSaveContext.unk_3F60 = 1; + if (gSaveContext.screenScale != 1000.0f) { + gSaveContext.screenScaleFlag = 1; } } } @@ -309,11 +309,11 @@ void EnTest4_Init(Actor* thisx, GlobalContext* globalCtx) { } else { sIsLoaded = true; this->actor.room = -1; - gSaveContext.unk_3F60 = 0; - gSaveContext.unk_3F64 = 1000.0f; + gSaveContext.screenScaleFlag = 0; + gSaveContext.screenScale = 1000.0f; if (CURRENT_DAY == 0) { - if (gSaveContext.time < CLOCK_TIME(6, 1)) { - gSaveContext.time = CLOCK_TIME(6, 0); + if (gSaveContext.save.time < CLOCK_TIME(6, 1)) { + gSaveContext.save.time = CLOCK_TIME(6, 0); gSaveContext.gameMode = 0; { GameState* state = &globalCtx->state; @@ -322,17 +322,17 @@ void EnTest4_Init(Actor* thisx, GlobalContext* globalCtx) { SET_NEXT_GAMESTATE(&globalCtx->state, Daytelop_Init, DaytelopContext); if (this && this && this) {} this->unk_144 = 1; - gSaveContext.time = CLOCK_TIME(6, 0); + gSaveContext.save.time = CLOCK_TIME(6, 0); Actor_MarkForDeath(&this->actor); } else { - gSaveContext.day = 1; - dayTemp = gSaveContext.day; - gSaveContext.daysElapsed = dayTemp; + gSaveContext.save.day = 1; + dayTemp = gSaveContext.save.day; + gSaveContext.save.daysElapsed = dayTemp; this->unk_144 = 1; - this->unk_146 = gSaveContext.time; + this->unk_146 = gSaveContext.save.time; this->actionFunc = func_80A42AB8; } - } else if (gSaveContext.time == CLOCK_TIME(6, 0)) { + } else if (gSaveContext.save.time == CLOCK_TIME(6, 0)) { this->unk_144 = 0; func_80A41D70(this, globalCtx); if ((gSaveContext.cutsceneTrigger == 0) && (sCutscenes[this->unk_144] >= 0) && @@ -340,12 +340,12 @@ void EnTest4_Init(Actor* thisx, GlobalContext* globalCtx) { player->stateFlags1 |= 0x200; } } else { - if ((gSaveContext.time > CLOCK_TIME(18, 0)) || (gSaveContext.time < CLOCK_TIME(6, 0))) { + if ((gSaveContext.save.time > CLOCK_TIME(18, 0)) || (gSaveContext.save.time < CLOCK_TIME(6, 0))) { this->unk_144 = 0; } else { this->unk_144 = 1; } - this->unk_146 = gSaveContext.time; + this->unk_146 = gSaveContext.save.time; this->actionFunc = func_80A42AB8; } } @@ -356,10 +356,10 @@ void EnTest4_Init(Actor* thisx, GlobalContext* globalCtx) { func_80A425E4(this, globalCtx); } - this->lastBellTime = gSaveContext.time; + this->lastBellTime = gSaveContext.save.time; if ((sCutscenes[this->unk_144] < 0) || (globalCtx->actorCtx.unk5 & 2)) { - gSaveContext.unk_3F60 = 0; - gSaveContext.unk_3F64 = 1000.0f; + gSaveContext.screenScaleFlag = 0; + gSaveContext.screenScale = 1000.0f; } } @@ -369,7 +369,7 @@ void EnTest4_Destroy(Actor* thisx, GlobalContext* globalCtx) { void func_80A42AB8(EnTest4* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if ((globalCtx->unk_18B4A == 0) && (func_801690CC(globalCtx) == 0) && (globalCtx->numSetupActors <= 0) && + if ((globalCtx->unk_18B4A == 0) && !Play_InCsMode(globalCtx) && (globalCtx->numSetupActors <= 0) && (globalCtx->roomCtx.unk31 == 0) && (func_8016A168() == 0)) { s16 temp_a2; u16 temp_a0 = D_80A43364[this->unk_144]; @@ -377,10 +377,10 @@ void func_80A42AB8(EnTest4* this, GlobalContext* globalCtx) { s16 bellDiff; s16 new_var; - temp_a3 = gSaveContext.time - temp_a0; + temp_a3 = gSaveContext.save.time - temp_a0; temp_a2 = this->unk_146 - temp_a0; bellDiff = this->lastBellTime - this->nextBellTime; - new_var = gSaveContext.time - this->nextBellTime; + new_var = gSaveContext.save.time - this->nextBellTime; if ((temp_a3 * temp_a2) <= 0) { gSaveContext.unk_3CA7 = 1; @@ -398,14 +398,14 @@ void func_80A42AB8(EnTest4* this, GlobalContext* globalCtx) { } else if (((sCutscenes[this->unk_144] < 0) || (globalCtx->actorCtx.unk5 & 2)) && CURRENT_DAY != 3) { func_80A41FA4(this, globalCtx); } else { - gSaveContext.unk_3F64 = 0.0f; - Play_SetRespawnData(&globalCtx->state, 0, Entrance_CreateIndexFromSpawn(0), player->unk_3CE, 0xBFF, - &player->unk_3C0, player->unk_3CC); + gSaveContext.screenScale = 0.0f; + Play_SetRespawnData(&globalCtx->state, RESTART_MODE_DOWN, Entrance_CreateIndexFromSpawn(0), + player->unk_3CE, 0xBFF, &player->unk_3C0, player->unk_3CC); func_80169EFC(&globalCtx->state); if (player->stateFlags1 & 0x800000) { EnHorse* rideActor = (EnHorse*)player->rideActor; - if ((rideActor->unk_150 == 0) || (rideActor->unk_150 == 2)) { + if ((rideActor->type == HORSE_EPONA) || (rideActor->type == HORSE_2)) { if (CURRENT_DAY < 3) { D_801BDA9C = 1; } else { @@ -422,7 +422,7 @@ void func_80A42AB8(EnTest4* this, GlobalContext* globalCtx) { if ((sCutscenes[this->unk_144] >= 0) && ((globalCtx->actorCtx.unk5 & 2) == 0)) { player->stateFlags1 |= 0x200; - this->unk_146 = gSaveContext.time; + this->unk_146 = gSaveContext.save.time; } else { if (this->unk_144 == 0) { this->unk_144 = 1; @@ -430,26 +430,26 @@ void func_80A42AB8(EnTest4* this, GlobalContext* globalCtx) { this->unk_144 = 0; } - this->unk_146 = gSaveContext.time += CLOCK_TIME_MINUTE; + this->unk_146 = gSaveContext.save.time += CLOCK_TIME_MINUTE; } } else if ((new_var * bellDiff) <= 0) { func_801A0124(&this->actor.projectedPos, (this->actor.params >> 5) & 0xF); - this->lastBellTime = gSaveContext.time; + this->lastBellTime = gSaveContext.save.time; if (CURRENT_DAY == 3) { if ((this->nextBellTime == CLOCK_TIME(0, 0)) && - ((gSaveContext.inventory.items[SLOT_OCARINA] == ITEM_NONE) || + ((gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) || (globalCtx->sceneNum == SCENE_CLOCKTOWER))) { s32 playerParams; - u32 entranceIndex = gSaveContext.entranceIndex; + u32 entranceIndex = gSaveContext.save.entranceIndex; if ((globalCtx->actorCtx.unk5 & 2)) { playerParams = 0xCFF; } else { playerParams = 0xBFF; } - Play_SetRespawnData(&globalCtx->state, 1, entranceIndex, player->unk_3CE, playerParams, - &player->unk_3C0, player->unk_3CC); + Play_SetRespawnData(&globalCtx->state, RESTART_MODE_RETURN, entranceIndex, player->unk_3CE, + playerParams, &player->unk_3C0, player->unk_3CC); if ((globalCtx->sceneNum == SCENE_TENMON_DAI) || (globalCtx->sceneNum == SCENE_00KEIKOKU)) { globalCtx->nextEntranceIndex = 0x5400; @@ -494,8 +494,8 @@ void func_80A42F20(EnTest4* this, GlobalContext* globalCtx) { if (this->transitionCsTimer == 60) { Player* player = GET_PLAYER(globalCtx); - gSaveContext.time += CLOCK_TIME_MINUTE; - this->unk_146 = gSaveContext.time; + gSaveContext.save.time += CLOCK_TIME_MINUTE; + this->unk_146 = gSaveContext.save.time; globalCtx->numSetupActors = -globalCtx->numSetupActors; player->stateFlags1 &= ~0x200; } @@ -517,8 +517,8 @@ void func_80A42F20(EnTest4* this, GlobalContext* globalCtx) { } void func_80A430C8(EnTest4* this, GlobalContext* globalCtx) { - if ((CURRENT_DAY == 2) && (gSaveContext.time >= CLOCK_TIME(7, 0)) && (gSaveContext.time < CLOCK_TIME(17, 30)) && - (globalCtx->envCtx.unk_F2[2] == 0)) { + if ((CURRENT_DAY == 2) && (gSaveContext.save.time >= CLOCK_TIME(7, 0)) && + (gSaveContext.save.time < CLOCK_TIME(17, 30)) && (globalCtx->envCtx.unk_F2[2] == 0)) { // rain? D_801BDBB0 = 1; @@ -542,7 +542,7 @@ void func_80A430C8(EnTest4* this, GlobalContext* globalCtx) { } void func_80A431C8(EnTest4* this, GlobalContext* globalCtx) { - if (((gSaveContext.time >= CLOCK_TIME(17, 30)) && (gSaveContext.time < CLOCK_TIME(23, 0)) && + if (((gSaveContext.save.time >= CLOCK_TIME(17, 30)) && (gSaveContext.save.time < CLOCK_TIME(23, 0)) && (globalCtx->envCtx.unk_F2[0] != 0)) || (globalCtx->envCtx.unk_F2[2] != 0)) { D_801BDBB0 = 0; diff --git a/src/overlays/actors/ovl_En_Test6/z_en_test6.c b/src/overlays/actors/ovl_En_Test6/z_en_test6.c index 3305d4c042..de1a18241c 100644 --- a/src/overlays/actors/ovl_En_Test6/z_en_test6.c +++ b/src/overlays/actors/ovl_En_Test6/z_en_test6.c @@ -5,6 +5,7 @@ */ #include "z_en_test6.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_200000 | ACTOR_FLAG_2000000) @@ -15,14 +16,31 @@ void EnTest6_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnTest6_Update(Actor* thisx, GlobalContext* globalCtx); void EnTest6_Draw(Actor* thisx, GlobalContext* globalCtx); +struct EnTest6Struct; + +typedef void (*EnTest6StructFunc)(EnTest6*, GlobalContext*, struct EnTest6Struct*); + +typedef struct EnTest6Struct { + /* 0x00 */ s32 unk_00; + /* 0x04 */ f32 unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ f32 unk_10; + /* 0x14 */ EnTest6StructFunc unk_14; +} EnTest6Struct; // size = 0x18 + +void func_80A90D34(EnTest6* this, GlobalContext* globalCtx, EnTest6Struct* ptr); +void func_80A90FC0(EnTest6* this, GlobalContext* globalCtx, EnTest6Struct* ptr); +void EnTest6_SetupAction(EnTest6* this, EnTest6ActionFunc actionFunc); void func_80A9156C(EnTest6* this, GlobalContext* globalCtx); +void func_80A91690(EnTest6* this, GlobalContext* globalCtx); void func_80A91760(EnTest6* this, GlobalContext* globalCtx); +void func_80A920C8(EnTest6* this, GlobalContext* globalCtx); void func_80A92188(EnTest6* this, GlobalContext* globalCtx); void func_80A92950(EnTest6* this, GlobalContext* globalCtx); -void EnTest6_SetupAction(EnTest6* this, EnTest6ActionFunc actionFunc); +EnTest6Struct D_80A94910[12]; -#if 0 const ActorInit En_Test6_InitVars = { ACTOR_EN_TEST6, ACTORCAT_ITEMACTION, @@ -35,50 +53,1268 @@ const ActorInit En_Test6_InitVars = { (ActorFunc)EnTest6_Draw, }; -#endif +u8 D_80A93E80[] = { + 0x00, 0x0D, 0x01, 0xA8, 0x00, 0x00, 0x00, 0x64, 0x04, 0x64, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x15, 0xFF, 0xED, 0x00, + 0x00, 0x04, 0x64, 0x00, 0x12, 0x00, 0x00, 0x00, 0x15, 0xFF, 0xED, 0x00, 0x00, 0x04, 0x64, 0x00, 0x10, 0x00, 0x00, + 0x00, 0x15, 0xFF, 0xED, 0x00, 0x00, 0x04, 0x64, 0x00, 0x11, 0xFF, 0xE6, 0xFF, 0xFB, 0xFF, 0xE0, 0x00, 0x00, 0x04, + 0x64, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x12, 0xFF, 0xE0, 0x00, 0x00, 0x04, 0x64, 0x00, 0x0E, 0x00, 0x01, 0x00, 0x16, + 0xFF, 0xE5, 0x00, 0x00, 0x04, 0x64, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFB, 0x00, 0x00, 0x04, 0x64, 0x00, + 0x07, 0x00, 0x10, 0x00, 0x1D, 0xFF, 0xB3, 0x00, 0x00, 0x04, 0x64, 0x00, 0x03, 0x00, 0x01, 0x00, 0x13, 0x00, 0x6F, + 0x00, 0x00, 0x04, 0x64, 0x00, 0x03, 0xFF, 0xC5, 0x00, 0x15, 0x00, 0x5B, 0x00, 0x00, 0x04, 0x64, 0x00, 0x03, 0xFF, + 0xED, 0x00, 0x3B, 0x00, 0x54, 0x00, 0x00, 0x04, 0x64, 0x00, 0x88, 0xFF, 0xED, 0x00, 0x3B, 0x00, 0x54, 0x00, 0x00, + 0x04, 0x64, 0x00, 0x6C, 0xFF, 0xEF, 0x00, 0x39, 0x00, 0x52, 0x00, 0x00, 0x04, 0x64, 0x00, 0x0D, 0x00, 0x00, 0x00, + 0x32, 0x02, 0xA9, 0x00, 0x00, 0x04, 0x64, 0x00, 0x12, 0x00, 0x00, 0x00, 0x32, 0x02, 0xA9, 0x00, 0x00, 0x04, 0x64, + 0x00, 0x10, 0x00, 0x00, 0x00, 0x32, 0x02, 0xA9, 0x00, 0x00, 0x04, 0x64, 0x00, 0x11, 0xFF, 0x98, 0x01, 0x77, 0x01, + 0x59, 0x00, 0x00, 0x04, 0x64, 0x00, 0x0F, 0x00, 0x00, 0xFF, 0xC2, 0x01, 0x21, 0x00, 0x00, 0x04, 0x64, 0x00, 0x0E, + 0xFF, 0xD1, 0x00, 0x7D, 0x00, 0xCD, 0x00, 0x00, 0x04, 0x64, 0x00, 0x0C, 0xFF, 0xC6, 0xFF, 0xEF, 0x00, 0xC7, 0x00, + 0x00, 0x04, 0x64, 0x00, 0x07, 0x00, 0x10, 0x00, 0x35, 0x00, 0xD3, 0x00, 0x00, 0x04, 0x64, 0x00, 0x03, 0xFF, 0xE1, + 0x00, 0x3F, 0x02, 0x6F, 0x00, 0x00, 0x04, 0x64, 0x00, 0x03, 0xFE, 0xAB, 0x01, 0xD0, 0x02, 0x1E, 0x00, 0x00, 0x04, + 0x64, 0x00, 0x03, 0xFE, 0xAB, 0x01, 0xD0, 0x02, 0x1E, 0x00, 0x00, 0x04, 0x64, 0x00, 0x88, 0xFE, 0xAB, 0x01, 0xD0, + 0x02, 0x1E, 0x00, 0x00, 0x04, 0x64, 0x00, 0x6C, 0xFE, 0xAD, 0x01, 0xCE, 0x02, 0x1C, 0x00, 0x00, 0x00, 0x0F, 0x00, + 0x0A, 0x00, 0x46, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x0A, 0x00, 0x46, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x0A, 0x00, 0x46, + 0x00, 0x00, 0x00, 0x0A, 0x00, 0x02, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x0A, 0xFF, 0xEC, 0x00, 0x37, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x2B, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x06, 0x00, 0x2F, 0x00, 0x00, 0x00, 0x05, 0xFF, 0xFB, + 0x00, 0x32, 0x00, 0x00, 0x00, 0x02, 0xFF, 0xDC, 0x00, 0x6C, 0x00, 0x00, 0x00, 0x02, 0xFF, 0xD8, 0x00, 0x78, 0x00, + 0x00, 0x00, 0x02, 0xFF, 0xC4, 0x00, 0x78, 0x00, 0x00, 0x00, 0x02, 0xFF, 0xBA, 0x00, 0x82, 0x00, 0x00, 0x00, 0x02, + 0xFF, 0xB0, 0x00, 0x8C, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x04, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A90730.s") +TexturePtr D_80A9402C[] = { + NULL, + gameplay_keep_Tex_05B6F0, + gameplay_keep_Tex_05CEF0, + gameplay_keep_Tex_0607C0, + gameplay_keep_Tex_060FC0, + gameplay_keep_Tex_061FC0, + gameplay_keep_Tex_061FE0, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A90C08.s") +Color_RGB8 D_80A94048 = { 230, 230, 220 }; +Color_RGB8 D_80A9404C = { 120, 120, 100 }; +Color_RGB8 D_80A94050 = { 0, 0, 0 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A90C34.s") +s16 D_80A94054 = 500; +s16 D_80A94058 = 1500; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A90C54.s") +Vec3f D_80A9405C = { 0.0f, 1.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A90D20.s") +Color_RGB8 D_80A94068 = { 225, 230, 225 }; +Color_RGB8 D_80A9406C = { 120, 120, 100 }; +Color_RGB8 D_80A94070 = { 0, 0, 0 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A90D34.s") +s16 D_80A94074 = 940; +s16 D_80A94078 = 2000; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A90FC0.s") +void func_80A90730(EnTest6* this, GlobalContext* globalCtx) { + s32 i; + Player* player = GET_PLAYER(globalCtx); + s32 phi_s0; + f32 phi_f24; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/EnTest6_SetupAction.s") + this->actor.home.pos = player->actor.world.pos; + this->actor.home.rot = player->actor.shape.rot; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/EnTest6_Init.s") + switch (ENTEST6_GET(&this->actor)) { + case ENTEST6_24: + case ENTEST6_25: + func_80A91690(this, globalCtx); + ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[8]); + return; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/EnTest6_Destroy.s") + case ENTEST6_26: + func_80A920C8(this, globalCtx); + ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[8]); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A9156C.s") + phi_s0 = 0; + phi_f24 = -900.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A91690.s") + if (gSaveContext.eventInf[7] & 1) { + for (i = 0; i < 6; i++) { + D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 5; + } + D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 5; + D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 6; + phi_s0 |= 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A916F0.s") + if (gSaveContext.eventInf[7] & 0x10) { + D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 1; + D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 1; + if (!(phi_s0 & 1)) { + D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 1; + D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 1; + } + phi_s0 |= 0x10; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A91760.s") + if (gSaveContext.eventInf[7] & 2) { + D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 2; + D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 2; + if (!(phi_s0 & 1)) { + D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 2; + D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 2; + } + phi_s0 |= 2; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A920C8.s") + if (gSaveContext.eventInf[7] & 4) { + D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 3; + if (!(phi_s0 & (0x10 | 0x2 | 0x1))) { + D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 3; + } + phi_s0 |= 4; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A92118.s") + if (gSaveContext.eventInf[7] & 8) { + D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 4; + if (!(phi_s0 & (0x10 | 0x2 | 0x1))) { + D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 4; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A92188.s") + for (i = 0; i < ARRAY_COUNT(D_80A94910); i++) { + D_80A94910[i].unk_08 = ((2.0f * Rand_ZeroOne()) - 1.0f) * 80.0f; + D_80A94910[i].unk_10 = ((2.0f * Rand_ZeroOne()) - 1.0f) * 80.0f; + D_80A94910[i].unk_0C = (((2.0f * Rand_ZeroOne()) - 1.0f) * 40.0f) + phi_f24; + D_80A94910[i].unk_04 = -10.0f; + if (D_80A94910[i].unk_00 < 5) { + D_80A94910[i].unk_14 = func_80A90D34; + } else { + D_80A94910[i].unk_14 = func_80A90FC0; + } + phi_f24 += 50.0f; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/EnTest6_Update.s") +void func_80A90C08(s16 arg0) { + func_8016566C(arg0); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A92950.s") +void func_80A90C34(void) { + func_80165690(); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A93298.s") +void func_80A90C54(GlobalContext* globalCtx, f32 arg1) { + globalCtx->envCtx.fillScreen = 1; + globalCtx->envCtx.screenFillColor[0] = 250; + globalCtx->envCtx.screenFillColor[1] = 250; + globalCtx->envCtx.screenFillColor[2] = 250; + globalCtx->envCtx.screenFillColor[3] = 255.0f * arg1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A9369C.s") +void func_80A90D20(GlobalContext* globalCtx) { + globalCtx->envCtx.fillScreen = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A939E8.s") +void func_80A90D34(EnTest6* this, GlobalContext* globalCtx, EnTest6Struct* ptr) { + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/EnTest6_Draw.s") + OPEN_DISPS(globalCtx->state.gfxCtx); + + if (ptr->unk_00 != 0) { + Matrix_InsertTranslation(ptr->unk_08 * ptr->unk_04, ptr->unk_0C, ptr->unk_10 * ptr->unk_04, MTXMODE_NEW); + Matrix_Scale(ptr->unk_04 * 0.02f, ptr->unk_04 * 0.02f, ptr->unk_04 * 0.02f, MTXMODE_APPLY); + POLY_OPA_DISP = func_801660B8(globalCtx, POLY_OPA_DISP); + POLY_OPA_DISP = func_8012C724(POLY_OPA_DISP); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80A9402C[ptr->unk_00])); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_05F6F0); + } + + Matrix_InsertTranslation(ptr->unk_08 * ptr->unk_04, ptr->unk_0C, ptr->unk_10 * ptr->unk_04, MTXMODE_NEW); + Matrix_Scale(2.0f * ptr->unk_04, 2.0f * ptr->unk_04, 2.0f * ptr->unk_04, MTXMODE_APPLY); + Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_InsertZRotation_s(globalCtx->state.frames * 512, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, 0.0f, 2.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + func_8012C2DC(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 210, 210, 230, 128); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, 0); + gSPClearGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_054A90); + gSPSetGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80A90FC0(EnTest6* this, GlobalContext* globalCtx, EnTest6Struct* ptr) { + s32 pad; + Gfx* gfx = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(Gfx) * 2); + Gfx* gfx2 = gfx; + Hilite* sp70; + Vec3f sp64; + + sp64.x = ptr->unk_08 * ptr->unk_04; + sp64.y = ptr->unk_0C; + sp64.z = ptr->unk_10 * ptr->unk_04; + + sp70 = func_800BCBF4(&sp64, globalCtx); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if (gfx != NULL) { + func_8012C28C(globalCtx->state.gfxCtx); + + gDPSetTileSize(gfx++, 1, sp70->h.x1 & 0xFFFF, sp70->h.y1 & 0xFFFF, (sp70->h.x1 + 60) & 0xFFFF, + (sp70->h.y1 + 60) & 0xFFFF); + gSPEndDisplayList(gfx); + + gSPSegment(POLY_OPA_DISP++, 0x07, gfx2); + + Matrix_InsertTranslation(sp64.x, sp64.y, sp64.z, MTXMODE_NEW); + Matrix_Scale(ptr->unk_04 * 0.018f, ptr->unk_04 * 0.018f, ptr->unk_04 * 0.018f, MTXMODE_APPLY); + Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80A9402C[ptr->unk_00])); + gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_0622C0); + } + + Matrix_InsertTranslation(ptr->unk_08 * ptr->unk_04, ptr->unk_0C, ptr->unk_10 * ptr->unk_04, MTXMODE_NEW); + Matrix_Scale(ptr->unk_04 * 2.5f, ptr->unk_04 * 2.5f, ptr->unk_04 * 2.5f, MTXMODE_APPLY); + Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_InsertZRotation_s(globalCtx->state.frames * 256, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, 0.0f, 4.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + func_8012C2DC(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 220, 220, 230, 192); + gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 0); + gSPClearGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_054A90); + gSPSetGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void EnTest6_SetupAction(EnTest6* this, EnTest6ActionFunc actionFunc) { + this->actionFunc = actionFunc; +} + +void EnTest6_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnTest6* this = THIS; + s32 i; + + if (((ENTEST6_GET(&this->actor) == ENTEST6_24) || (ENTEST6_GET(&this->actor) == ENTEST6_25) || + (ENTEST6_GET(&this->actor) == ENTEST6_26)) && + (globalCtx->playerActorCsIds[8] == -1)) { + Actor_MarkForDeath(&this->actor); + return; + } + + for (i = 0; i < ARRAY_COUNT(this->lights); i++) { + Lights_PointNoGlowSetInfo(&this->lights[i].info, this->actor.world.pos.x, (s32)this->actor.world.pos.y - 20, + this->actor.world.pos.z, 255, 255, 180, -1); + this->lights[i].node = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lights[i].info); + } + + this->unk_286 = 0; + this->unk_274 = 0; + this->unk_278 = 0; + this->unk_276 = 99; + func_80A90730(this, globalCtx); + EnTest6_SetupAction(this, func_80A9156C); +} + +void EnTest6_Destroy(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnTest6* this = THIS; + s32 i; + + globalCtx->envCtx.lightSettings.ambientColor[0] = 0; + globalCtx->envCtx.lightSettings.ambientColor[1] = 0; + globalCtx->envCtx.lightSettings.ambientColor[2] = 0; + globalCtx->envCtx.lightSettings.diffuseColor1[0] = 0; + globalCtx->envCtx.lightSettings.diffuseColor1[1] = 0; + globalCtx->envCtx.lightSettings.diffuseColor1[2] = 0; + globalCtx->envCtx.lightSettings.diffuseColor2[0] = 0; + globalCtx->envCtx.lightSettings.diffuseColor2[1] = 0; + globalCtx->envCtx.lightSettings.diffuseColor2[2] = 0; + globalCtx->envCtx.lightSettings.fogColor[0] = 0; + globalCtx->envCtx.lightSettings.fogColor[1] = 0; + globalCtx->envCtx.lightSettings.fogColor[2] = 0; + globalCtx->envCtx.lightSettings.fogNear = 0; + globalCtx->envCtx.lightSettings.fogFar = 0; + globalCtx->envCtx.fillScreen = 0; + + for (i = 0; i < ARRAY_COUNT(this->lights); i++) { + LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lights[i].node); + } +} + +void func_80A9156C(EnTest6* this, GlobalContext* globalCtx) { + switch (ENTEST6_GET(&this->actor)) { + case ENTEST6_24: + case ENTEST6_25: + if (!ActorCutscene_GetCanPlayNext(globalCtx->playerActorCsIds[8])) { + ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[8]); + } else { + ActorCutscene_Start(globalCtx->playerActorCsIds[8], NULL); + this->unk_284 = ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8]); + EnTest6_SetupAction(this, func_80A91760); + } + break; + + case ENTEST6_26: + if (!ActorCutscene_GetCanPlayNext(globalCtx->playerActorCsIds[8])) { + ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[8]); + } else { + ActorCutscene_Start(globalCtx->playerActorCsIds[8], NULL); + this->unk_284 = ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8]); + EnTest6_SetupAction(this, func_80A92188); + } + break; + + default: + gSaveContext.save.daysElapsed = 0; + gSaveContext.save.day = false; + gSaveContext.save.time = CLOCK_TIME(6, 0) - 1; + EnTest6_SetupAction(this, func_80A92950); + break; + } +} + +void func_80A91690(EnTest6* this, GlobalContext* globalCtx) { + this->unk_274 = 90; + this->unk_27A = 100; + this->unk_286 = 0; + if (ENTEST6_GET(&this->actor) == ENTEST6_25) { + play_sound(NA_SE_SY_TIME_CONTROL_SLOW); + } else if (ENTEST6_GET(&this->actor) == ENTEST6_24) { + play_sound(NA_SE_SY_TIME_CONTROL_NORMAL); + } +} + +void func_80A916F0(EnTest6* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + player->actor.freezeTimer = 0; + globalCtx->unk_18844 = 0; + ActorCutscene_Stop(globalCtx->playerActorCsIds[8]); + func_800B7298(globalCtx, NULL, 6); + func_80A90C34(); + Distortion_ClearType(0x20); + Actor_MarkForDeath(&this->actor); +} + +void func_80A91760(EnTest6* this, GlobalContext* globalCtx) { + Input* input = CONTROLLER1(globalCtx); + s16 temp_s0; + Player* player = GET_PLAYER(globalCtx); + Camera* sp78; + Vec3f sp6C; + Vec3f sp60; + Vec3f sp54; + s32 i; + f32 sp4C; + Camera* temp_s3 = Play_GetCamera(globalCtx, this->unk_284); + + sp78 = Play_GetCamera(globalCtx, CAM_ID_MAIN); + + switch (this->unk_274) { + case 90: + this->unk_276 = 2; + this->unk_15C = 0.0f; + this->unk_14C = 0.1f; + this->unk_282 = 0; + this->unk_278 = 0; + this->unk_274 = 91; + break; + + case 91: + this->unk_15C += this->unk_14C; + func_800FD59C(globalCtx, &D_80A9404C, this->unk_15C); + func_800FD5E0(globalCtx, &D_80A94050, this->unk_15C); + func_800FD654(globalCtx, &D_80A94048, this->unk_15C); + func_800FD698(globalCtx, D_80A94054, D_80A94058, this->unk_15C); + + if (this->unk_27A == 90) { + this->unk_282 = 0; + if (ENTEST6_GET(&this->actor) == ENTEST6_24) { + this->unk_27C = 0x200; + this->unk_150 = 0.0f; + sp4C = -100.0f; + } else { + this->unk_27C = 0x570; + this->unk_150 = 110.0f; + sp4C = 100.0f; + } + this->unk_14C = 1.0f; + + for (i = 0; i < ARRAY_COUNT(this->unk_20C); i++) { + this->unk_20C[i].x = player->actor.world.pos.x; + this->unk_20C[i].y = player->actor.world.pos.y; + this->unk_20C[i].z = player->actor.world.pos.z; + } + + this->unk_254 = ZeldaArena_Malloc(sizeof(Vec3f) * 64); + if (this->unk_254 != NULL) { + for (i = 0; i < ARRAY_COUNT(this->unk_254[0]); i++) { + (*this->unk_254)[i].x = (((2.0f * Rand_ZeroOne()) - 1.0f) * 40.0f) + temp_s3->eye.x + + ((temp_s3->at.x - temp_s3->eye.x) * 0.2f); + (*this->unk_254)[i].y = (((2.0f * Rand_ZeroOne()) - 1.0f) * 120.0f) + temp_s3->eye.y + + ((temp_s3->at.y - temp_s3->eye.y) * 0.2f) + sp4C; + (*this->unk_254)[i].z = (((2.0f * Rand_ZeroOne()) - 1.0f) * 40.0f) + temp_s3->eye.z + + ((temp_s3->at.z - temp_s3->eye.z) * 0.2f); + } + } + func_80A90C08(0x78); + Distortion_SetType(0x20); + Distortion_SetCountdown(80); + globalCtx->unk_18844 = 1; + this->unk_274 = 95; + } + break; + + case 95: + if (this->unk_27A > 80) { + this->unk_282 += 25; + } + + if (this->unk_27A < 20) { + this->unk_282 -= 25; + } + + func_800FD59C(globalCtx, &D_80A9404C, this->unk_15C); + func_800FD5E0(globalCtx, &D_80A94050, this->unk_15C); + func_800FD654(globalCtx, &D_80A94048, this->unk_15C); + func_800FD698(globalCtx, D_80A94054 + this->unk_282, D_80A94058 + this->unk_282, this->unk_15C); + + this->unk_278 -= this->unk_27C; + temp_s0 = this->unk_278; + if (ENTEST6_GET(&this->actor) == ENTEST6_24) { + this->unk_27C += 8; + this->unk_150 += this->unk_14C; + } else { + this->unk_27C -= 8; + this->unk_150 -= this->unk_14C; + } + + for (i = 0; i < ARRAY_COUNT(this->unk_20C); i++) { + temp_s0 += 0x10000 / ARRAY_COUNT(this->unk_20C); + if (player) {} + this->unk_20C[i].x = (Math_SinS(temp_s0) * this->unk_150) + player->actor.world.pos.x; + this->unk_20C[i].y = player->actor.world.pos.y; + this->unk_20C[i].z = (Math_CosS(temp_s0) * this->unk_150) + player->actor.world.pos.z; + } + + if (this->unk_254 != NULL) { + for (i = 0; i < ARRAY_COUNT(this->unk_254[0]); i++) { + (*this->unk_254)[i].x += 2.0f * ((2.0f * Rand_ZeroOne()) - 1.0f); + if (ENTEST6_GET(&this->actor) == ENTEST6_24) { + (*this->unk_254)[i].y += 1.0f; + } else { + if (1) {} + (*this->unk_254)[i].y -= 1.0f; + } + (*this->unk_254)[i].z += 2.0f * ((2.0f * Rand_ZeroOne()) - 1.0f); + } + } + + if (this->unk_27A == 10) { + this->unk_14C = 0.1f; + func_80A90C34(); + Distortion_ClearType(0x20); + globalCtx->unk_18844 = 0; + if (this->unk_254 != NULL) { + ZeldaArena_Free(this->unk_254); + } + this->unk_274 = 99; + } + break; + + case 99: + this->unk_15C -= this->unk_14C; + func_800FD59C(globalCtx, &D_80A9404C, this->unk_15C); + func_800FD5E0(globalCtx, &D_80A94050, this->unk_15C); + func_800FD654(globalCtx, &D_80A94048, this->unk_15C); + func_800FD698(globalCtx, D_80A94054, D_80A94058, this->unk_15C); + break; + } + + if (this->unk_286 != 0) { + func_800B7298(globalCtx, NULL, 7); + } else { + if (this->unk_27A == 90) { + func_800B7298(globalCtx, NULL, 0x42); + } + + if (this->unk_27A == 70) { + func_800B7298(globalCtx, NULL, 0x52); + } + + if (this->unk_27A == 30) { + func_800B7298(globalCtx, NULL, 0x51); + } + + if (this->unk_27A == 5) { + func_800B7298(globalCtx, NULL, 0x4A); + } + } + + if (this->unk_27A > 80) { + temp_s3->fov += (90.0f - temp_s3->fov) / (this->unk_27A - 80); + } else if (this->unk_27A > 60) { + sp4C = 1.0f / (this->unk_27A - 60); + + sp6C.x = temp_s3->at.x + ((player->actor.world.pos.x - temp_s3->at.x) * sp4C); + sp6C.y = temp_s3->at.y + (((player->actor.focus.pos.y - temp_s3->at.y) - 20.0f) * sp4C); + sp6C.z = temp_s3->at.z + ((player->actor.world.pos.z - temp_s3->at.z) * sp4C); + + sp54.x = (Math_SinS(player->actor.world.rot.y) * 80.0f) + sp6C.x; + sp54.y = sp6C.y + 20.0f; + sp54.z = (Math_CosS(player->actor.world.rot.y) * 80.0f) + sp6C.z; + sp4C *= 0.75f; + + VEC3F_LERPIMPDST(&sp60, &temp_s3->eye, &sp54, sp4C); + + Play_CameraSetAtEye(globalCtx, this->unk_284, &sp6C, &sp60); + } else if ((this->unk_27A < 11) && (this->unk_27A > 0)) { + temp_s3->fov += (sp78->fov - temp_s3->fov) / this->unk_27A; + } + + if (this->unk_286 != 0) { + func_80A90C54(globalCtx, this->unk_286 * 0.05f); + temp_s3->fov += (sp78->fov - temp_s3->fov) * 0.05f; + this->unk_286++; + if (this->unk_286 >= 20) { + this->unk_27A = 1; + } + } else if ((this->unk_27A <= 60) && (this->unk_27A > 40) && + (CHECK_BTN_ALL(input->press.button, BTN_A) || CHECK_BTN_ALL(input->press.button, BTN_B))) { + this->unk_286 = 1; + if (ENTEST6_GET(&this->actor) == ENTEST6_25) { + func_801A75E8(NA_SE_SY_TIME_CONTROL_SLOW); + } else if (ENTEST6_GET(&this->actor) == ENTEST6_24) { + func_801A75E8(NA_SE_SY_TIME_CONTROL_NORMAL); + } + } + + if (DECR(this->unk_27A) == 0) { + func_80A916F0(this, globalCtx); + globalCtx->msgCtx.ocarinaMode = 4; + } +} + +void func_80A920C8(EnTest6* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + this->unk_27A = 120; + this->unk_286 = 0; + this->unk_160 = 0.0f; + this->actor.home.pos = player->actor.world.pos; + this->actor.home.rot = player->actor.shape.rot; +} + +void func_80A92118(EnTest6* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + player->actor.freezeTimer = 0; + globalCtx->unk_18844 = 0; + ActorCutscene_Stop(globalCtx->playerActorCsIds[8]); + func_800B7298(globalCtx, NULL, 6); + func_80A90C34(); + Distortion_ClearType(0x20); + Actor_MarkForDeath(&this->actor); +} + +void func_80A92188(EnTest6* this, GlobalContext* globalCtx) { + Input* input = CONTROLLER1(globalCtx); + Player* player = GET_PLAYER(globalCtx); + Camera* camera; + s32 pad; + s16 sp46; + s16 sp44; + + if (this->unk_27A > 115) { + this->unk_160 += 0.2f; + func_80A90C54(globalCtx, this->unk_160); + } else if (this->unk_27A > 90) { + this->unk_160 -= 0.05f; + func_80A90C54(globalCtx, this->unk_160); + } else if (this->unk_27A == 90) { + this->unk_160 = 0.0f; + func_80A90D20(globalCtx); + } + + if (this->unk_27A == 1) { + this->unk_160 = 0.0f; + func_80A90D20(globalCtx); + } else if (this->unk_27A < 17) { + this->unk_160 -= 0.06666666f; + func_80A90C54(globalCtx, this->unk_160); + } else if (this->unk_27A < 22) { + this->unk_160 += 0.2f; + func_80A90C54(globalCtx, this->unk_160); + } + + if (this->unk_27A == 115) { + func_800FD59C(globalCtx, &D_80A9406C, 1.0f); + func_800FD5E0(globalCtx, &D_80A94070, 1.0f); + func_800FD654(globalCtx, &D_80A94068, 1.0f); + func_800FD698(globalCtx, D_80A94074, D_80A94078, 1.0f); + globalCtx->unk_18844 = 1; + } + + if (this->unk_27A == 15) { + func_800FD59C(globalCtx, &D_80A9406C, 0.0f); + func_800FD5E0(globalCtx, &D_80A94070, 0.0f); + func_800FD654(globalCtx, &D_80A94068, 0.0f); + func_800FD698(globalCtx, D_80A94074, D_80A94078, 0.0f); + globalCtx->unk_18844 = 0; + } + + if (this->unk_286 >= 20) { + func_800FD59C(globalCtx, &D_80A9406C, this->unk_160); + func_800FD5E0(globalCtx, &D_80A94070, this->unk_160); + func_800FD654(globalCtx, &D_80A94068, this->unk_160); + func_800FD698(globalCtx, D_80A94074, D_80A94078, this->unk_160); + globalCtx->unk_18844 = 0; + } + + func_800B8F98(&player->actor, NA_SE_PL_FLYING_AIR - SFX_FLAG); + + switch (this->unk_27A) { + case 119: + func_80A90C08(0x32); + break; + + case 115: + func_80A90C08(0x14); + Distortion_SetType(0x20); + Distortion_SetCountdown(90); + this->unk_274 = 2; + break; + + case 110: + func_801A3098(0x4A); + break; + + case 38: + case 114: + this->unk_274 = 1; + break; + + case 76: + this->unk_274 = 3; + break; + + case 61: + func_80A90C08(0x96); + this->unk_274 = 4; + break; + + case 51: + func_80A90C08(0xB4); + this->unk_274 = 5; + break; + + case 14: + case 15: + func_80A90C08(0x32); + Distortion_ClearType(0x20); + this->unk_274 = 0; + break; + + case 1: + func_80A90C34(); + if (gSaveContext.eventInf[5] & 4) { + this->unk_274 = 9; + } + break; + } + + func_80A92950(this, globalCtx); + + if (this->unk_27A == 115) { + sp44 = ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8]); + camera = Play_GetCamera(globalCtx, sp44); + + this->unk_258 = camera->at; + this->unk_264 = camera->eye; + this->unk_270 = camera->fov; + func_8016119C(camera, &this->unk_18C); + } + + if ((this->unk_27A <= 115) && (this->unk_27A >= 16)) { + func_80161998(D_80A93E80, &this->unk_18C); + } else if (this->unk_27A < 16) { + sp46 = ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8]); + + Play_CameraSetAtEyeUp(globalCtx, sp46, &this->unk_258, &this->unk_264, &D_80A9405C); + Play_CameraSetFov(globalCtx, sp46, this->unk_270); + Play_CameraSetRoll(globalCtx, sp46, 0); + } + + switch (this->unk_27A) { + case 116: + player->actor.freezeTimer = 2; + player->actor.shape.rot.x = 0; + player->actor.shape.rot.y = 0; + player->actor.world.pos.x = 0.0f; + player->actor.world.pos.y = 0.0f; + player->actor.world.pos.z = 0.0f; + player->actor.home.pos.x = 0.0f; + player->actor.home.pos.y = 0.0f; + player->actor.home.pos.z = 0.0f; + break; + + case 98: + func_800B7298(globalCtx, NULL, 0x40); + break; + + case 68: + func_800B7298(globalCtx, NULL, 0x41); + break; + + case 52: + func_800B7298(globalCtx, NULL, 0x58); + break; + + case 43: + func_800B7298(globalCtx, NULL, 0x72); + break; + + case 38: + func_800B7298(globalCtx, NULL, 7); + break; + + case 14: + player->actor.freezeTimer = 5; + player->actor.world.pos = player->actor.home.pos = this->actor.home.pos; + player->actor.shape.rot = this->actor.home.rot; + player->actor.focus.rot.y = player->actor.shape.rot.y; + player->currentYaw = player->actor.shape.rot.y; + player->unk_ABC = 0.0f; + player->unk_AC0 = 0.0f; + player->actor.shape.yOffset = 0.0f; + break; + } + + if ((this->unk_286 > 0) && (this->unk_286 < 20)) { + func_80A90C54(globalCtx, this->unk_286 * 0.05f); + this->unk_286++; + if (this->unk_286 >= 20) { + this->unk_27A = 15; + this->unk_160 = 0.9333333f; + } + } else if ((this->unk_27A < 96) && (this->unk_27A > 50) && + (CHECK_BTN_ALL(input->press.button, BTN_A) || CHECK_BTN_ALL(input->press.button, BTN_B))) { + this->unk_286 = 1; + this->unk_27A = 39; + Audio_QueueSeqCmd(0x111400FF); + } + + if (DECR(this->unk_27A) == 0) { + func_80A92118(this, globalCtx); + } +} + +void EnTest6_Update(Actor* thisx, GlobalContext* globalCtx) { + EnTest6* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void func_80A92950(EnTest6* this, GlobalContext* globalCtx) { + s32 pad[2]; + Player* player = GET_PLAYER(globalCtx); + f32 temp_f0; + s32 i; + s32 temp_v0; + + if (Cutscene_CheckActorAction(globalCtx, 0x1F9)) { + temp_v0 = Cutscene_GetActorActionIndex(globalCtx, 0x1F9); + this->unk_274 = globalCtx->csCtx.actorActions[temp_v0]->action; + + switch (this->unk_274) { + case 1: + break; + + case 2: + this->unk_276 = 0; + this->unk_278 = 0; + this->unk_27C = 0; + player->actor.shape.shadowDraw = NULL; + + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.x != 0) { + this->unk_154 = (u32)globalCtx->csCtx.actorActions[temp_v0]->startPos.x; + } else { + this->unk_154 = 150.0f; + } + + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.y != 0) { + this->unk_280 = globalCtx->csCtx.actorActions[temp_v0]->startPos.y; + } else { + this->unk_280 = 38; + } + + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.z != 0) { + this->unk_150 = (u32)globalCtx->csCtx.actorActions[temp_v0]->startPos.z; + } else { + this->unk_150 = 480.0f; + } + break; + + case 3: + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.x != 0) { + this->unk_154 += (u32)globalCtx->csCtx.actorActions[temp_v0]->startPos.x; + } + + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.y != 0) { + this->unk_280 += (s16)globalCtx->csCtx.actorActions[temp_v0]->startPos.y; + + } else { + this->unk_280 += 6; + } + + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.z != 0) { + this->unk_158 = (u32)globalCtx->csCtx.actorActions[temp_v0]->startPos.z; + } else { + this->unk_158 = -32.0f; + } + this->unk_150 += this->unk_158; + break; + + case 4: + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.x != 0) { + this->unk_154 += (u32)globalCtx->csCtx.actorActions[temp_v0]->startPos.x; + } + + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.y != 0) { + this->unk_280 += (s16)globalCtx->csCtx.actorActions[temp_v0]->startPos.y; + } else { + this->unk_280 -= 4; + } + break; + + case 5: + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.x != 0) { + this->unk_154 += (u32)globalCtx->csCtx.actorActions[temp_v0]->startPos.x; + } + + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.y != 0) { + this->unk_280 += (s16)globalCtx->csCtx.actorActions[temp_v0]->startPos.y; + } else { + this->unk_280 -= 8; + } + + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.z != 0) { + this->unk_158 += (u32)globalCtx->csCtx.actorActions[temp_v0]->startPos.z; + } else { + this->unk_158 += 20.0f; + } + + this->unk_150 += this->unk_158; + if (this->unk_150 > 3500.0f) { + this->unk_150 = 3500.0f; + this->unk_274 = 0; + } + break; + + case 6: + this->unk_276 = 1; + this->unk_278 = 0; + this->unk_27C = 0; + player->actor.shape.shadowDraw = NULL; + + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.x != 0) { + this->unk_154 = (u32)globalCtx->csCtx.actorActions[temp_v0]->startPos.x; + } else { + this->unk_154 = 100.0f; + } + + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.y != 0) { + this->unk_14C = (u32)globalCtx->csCtx.actorActions[temp_v0]->startPos.y; + } else { + this->unk_14C = 20.0f; + } + + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.z != 0) { + this->unk_150 = (u32)globalCtx->csCtx.actorActions[temp_v0]->startPos.z; + } else { + this->unk_150 = 300.0f; + } + this->unk_158 = 0.0f; + break; + + case 7: + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.x != 0) { + this->unk_158 = (u32)globalCtx->csCtx.actorActions[temp_v0]->startPos.x; + } else { + this->unk_158 = -5.0f; + } + this->unk_154 += this->unk_158; + break; + + case 8: + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.x != 0) { + this->unk_158 += (u32)globalCtx->csCtx.actorActions[temp_v0]->startPos.x; + } else { + this->unk_158 += 2.0f; + } + + this->unk_154 += this->unk_158; + if (this->unk_154 > 10000.0f) { + this->unk_154 = 10000.0f; + this->unk_274 = 0; + } + break; + + case 0: + default: + this->unk_276 = 99; + return; + + case 9: + Play_SetRespawnData(&globalCtx->state, 1, ((void)0, gSaveContext.save.entranceIndex & 0xFFFF), + player->unk_3CE, 0xBFF, &player->unk_3C0, player->unk_3CC); + this->unk_276 = 99; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->nextEntranceIndex = gSaveContext.respawn[RESTART_MODE_RETURN].entranceIndex; + globalCtx->unk_1887F = 2; + if ((gSaveContext.save.time > CLOCK_TIME(18, 0)) || (gSaveContext.save.time < CLOCK_TIME(6, 0))) { + gSaveContext.respawnFlag = -0x63; + gSaveContext.eventInf[2] |= 0x80; + } else { + gSaveContext.respawnFlag = 2; + } + globalCtx->msgCtx.ocarinaMode = 4; + return; + } + } else { + switch (this->unk_274) { + case 2: + this->unk_276 = 0; + this->unk_278 = 0; + this->unk_27C = 0; + player->actor.shape.shadowDraw = NULL; + this->unk_280 = 38; + this->unk_154 = 150.0f; + this->unk_150 = 480.0f; + + case 1: + break; + + case 3: + this->unk_158 = -32.0f; + this->unk_280 += 6; + this->unk_150 += -32.0f; + break; + + case 4: + this->unk_280 -= 4; + break; + + case 5: + this->unk_280 -= 8; + this->unk_158 += 20.0f; + this->unk_150 += this->unk_158; + if (this->unk_150 > 3500.0f) { + this->unk_150 = 3500.0f; + this->unk_274 = 0; + } + break; + + case 6: + this->unk_276 = 1; + this->unk_278 = 0; + this->unk_27C = 0; + player->actor.shape.shadowDraw = NULL; + this->unk_154 = 100.0f; + this->unk_14C = 20.0f; + this->unk_150 = 300.0f; + this->unk_158 = 0.0f; + break; + + case 7: + this->unk_158 = -5.0f; + this->unk_154 += -5.0f; + break; + + case 8: + this->unk_158 += 2.0f; + this->unk_154 += this->unk_158; + if (this->unk_154 > 10000.0f) { + this->unk_154 = 10000.0f; + this->unk_274 = 0; + } + break; + + case 0: + default: + this->unk_276 = 99; + return; + + case 9: + if (gSaveContext.save.time > CLOCK_TIME(12, 0)) { + Play_SetRespawnData(&globalCtx->state, 1, ((void)0, gSaveContext.save.entranceIndex & 0xFFFF), + player->unk_3CE, 0xBFF, &player->unk_3C0, player->unk_3CC); + this->unk_276 = 99; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->nextEntranceIndex = gSaveContext.respawn[RESTART_MODE_RETURN].entranceIndex; + globalCtx->unk_1887F = 2; + gSaveContext.respawnFlag = 2; + globalCtx->msgCtx.ocarinaMode = 4; + } + return; + } + } + + if (this->unk_276 == 1) { + for (i = 0; i < ARRAY_COUNT(D_80A94910); i++) { + D_80A94910[i].unk_08 += 2.0f * ((2.0f * Rand_ZeroOne()) - 1.0f); + D_80A94910[i].unk_10 += 2.0f * ((2.0f * Rand_ZeroOne()) - 1.0f); + D_80A94910[i].unk_0C += 3.0f; + + if (player->actor.world.pos.y < D_80A94910[i].unk_0C) { + temp_f0 = D_80A94910[i].unk_0C - player->actor.world.pos.y; + if (temp_f0 > 550.0f) { + temp_f0 = 1.0f; + } else { + temp_f0 = temp_f0 / 550.0f; + } + D_80A94910[i].unk_04 = SQ(temp_f0); + } else { + D_80A94910[i].unk_04 = -10.0f; + } + } + } + this->unk_278++; +} + +void func_80A93298(EnTest6* this, GlobalContext* globalCtx) { + s16 temp_s3; + s16 temp_s4; + f32 phi_f24; + s16 phi_s2; + s32 i; + f32 cos; + f32 sin; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + this->unk_148 = POLY_OPA_DISP; + phi_f24 = 0.0f; + + temp_s3 = this->unk_27C; + temp_s4 = (s32)(Math_SinS(globalCtx->state.frames) * 12000.0f) + temp_s3 + 0x4E20; + phi_s2 = (globalCtx->state.frames & 0x3C) * 1024; + phi_s2 *= (this->unk_154 / 200.0f); + this->unk_27C += (s16)this->unk_154; + this->unk_27E = (s16)((this->unk_154 / 200.0f) * 256.0f); + + for (i = 0; i < ARRAY_COUNT(this->unk_254[0]); i++) { + temp_s3 += 0x1000; + cos = Math_CosS(temp_s3) * this->unk_150; + sin = Math_SinS(temp_s3) * this->unk_150; + Matrix_InsertTranslation(cos, phi_f24, sin, MTXMODE_NEW); + Matrix_InsertXRotation_s(0x4000, MTXMODE_APPLY); + Matrix_Scale(0.8f, 0.8f, 0.8f, MTXMODE_APPLY); + Matrix_InsertZRotation_s(phi_s2, MTXMODE_APPLY); + + gSPMatrix(this->unk_148++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(this->unk_148++, 0, 0xFF, 28, 28, 28, 255); + gDPSetEnvColor(this->unk_148++, 255, 255, 255, 255); + gDPSetRenderMode(this->unk_148++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_OPA_SURF2); + gSPDisplayList(this->unk_148++, gameplay_keep_DL_07AFB0); + + temp_s4 += 0x1000; + cos = Math_CosS(temp_s4) * this->unk_150; + sin = Math_SinS(temp_s4) * this->unk_150; + Matrix_InsertTranslation(cos, phi_f24, sin, MTXMODE_NEW); + Matrix_InsertXRotation_s(0x4000, MTXMODE_APPLY); + Matrix_Scale(0.8f, 0.8f, 0.8f, MTXMODE_APPLY); + Matrix_InsertZRotation_s(-phi_s2, MTXMODE_APPLY); + + gSPMatrix(this->unk_148++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(this->unk_148++, 0, 0xFF, 28, 28, 28, 255); + gDPSetEnvColor(this->unk_148++, 255, 255, 255, 255); + gDPSetRenderMode(this->unk_148++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_OPA_SURF2); + gSPDisplayList(this->unk_148++, gameplay_keep_DL_07AFB0); + + phi_f24 -= this->unk_14C; + phi_s2 += this->unk_27E; + } + + POLY_OPA_DISP = this->unk_148; + + for (i = 0; i < ARRAY_COUNT(D_80A94910); i++) { + if (D_80A94910[i].unk_04 > 0.0f) { + D_80A94910[i].unk_14(this, globalCtx, &D_80A94910[i]); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80A9369C(Actor* thisx, GlobalContext* globalCtx2) { + EnTest6* this = THIS; + GlobalContext* globalCtx = globalCtx2; + f32 temp_f20; + f32 temp_f22; + f32 phi_f26; + s16 phi_s2; + s16 sp78; + s32 i; + Player* player = GET_PLAYER(globalCtx); + s32 pad; + + if (this) {} + OPEN_DISPS(globalCtx->state.gfxCtx); + + this->unk_148 = POLY_OPA_DISP; + this->unk_27C += (s16)this->unk_154; + this->unk_27E = this->unk_27C * 2; + sp78 = (globalCtx->state.frames & 0x3C) * 1024; + phi_s2 = this->unk_27C + 0x4000; + + switch (player->transformation) { + default: + phi_f26 = player->actor.world.pos.y + 40.0f; + break; + + case PLAYER_FORM_DEKU: + phi_f26 = player->actor.world.pos.y + 40.0f; + break; + + case PLAYER_FORM_GORON: + phi_f26 = player->actor.world.pos.y + 40.0f; + break; + + case PLAYER_FORM_ZORA: + phi_f26 = player->actor.world.pos.y + 40.0f; + break; + + case PLAYER_FORM_FIERCE_DEITY: + phi_f26 = player->actor.world.pos.y + 40.0f; + break; + } + + for (i = 0; i < 51; i++) { + temp_f20 = Math_CosS(phi_s2) * this->unk_150; + temp_f22 = Math_SinS(phi_s2) * this->unk_150; + Matrix_InsertZRotation_s(this->unk_27E, MTXMODE_NEW); + Matrix_InsertTranslation(phi_f26, temp_f20, temp_f22, MTXMODE_APPLY); + Matrix_Scale(0.85f, 0.85f, 0.85f, MTXMODE_APPLY); + Matrix_InsertXRotation_s(phi_s2, MTXMODE_APPLY); + Matrix_InsertZRotation_s(sp78, MTXMODE_APPLY); + + gSPMatrix(this->unk_148++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(this->unk_148++, 0, 0xFF, this->unk_280, this->unk_280, this->unk_280, 255); + gDPSetEnvColor(this->unk_148++, 235, 238, 235, 255); + gDPSetRenderMode(this->unk_148++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_OPA_SURF2); + gSPDisplayList(this->unk_148++, gameplay_keep_DL_07AFB0); + + phi_s2 += 0x505; + } + + Lights_PointSetPosition(&this->lights[0].info, player->actor.world.pos.x, player->actor.world.pos.y - 10.0f, + player->actor.world.pos.z); + Lights_PointSetColorAndRadius(&this->lights[0].info, 100, 250, 100, 200); + + POLY_OPA_DISP = this->unk_148; + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80A939E8(EnTest6* this, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + Player* player = GET_PLAYER(globalCtx); + f32 temp_f20; + s32 i; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + switch (this->unk_274) { + case 91: + case 93: + Lights_PointSetPosition(&this->lights[0].info, player->actor.world.pos.x, player->actor.world.pos.y - 10.0f, + player->actor.world.pos.z); + Lights_PointSetColorAndRadius(&this->lights[0].info, 245, 245, 200, this->unk_282); + break; + + case 95: + this->unk_148 = POLY_XLU_DISP; + + for (i = 0; i < ARRAY_COUNT(this->unk_20C); i++) { + Matrix_InsertTranslation(this->unk_20C[i].x, this->unk_20C[i].y, this->unk_20C[i].z, MTXMODE_NEW); + Matrix_Scale(0.3f, 0.3f, 0.3f, MTXMODE_APPLY); + Matrix_InsertXRotation_s(-0x4000, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_278, MTXMODE_APPLY); + + gSPMatrix(this->unk_148++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(this->unk_148++, 0, 0xFF, 28, 28, 28, 255); + gDPSetEnvColor(this->unk_148++, 245, 245, 200, this->unk_282); + gDPSetRenderMode(this->unk_148++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_XLU_SURF2); + gSPDisplayList(this->unk_148++, gameplay_keep_DL_07AFB0); + + POLY_XLU_DISP = this->unk_148; + } + + if (this->unk_254 != NULL) { + for (i = 0; i < ARRAY_COUNT(this->unk_254[0]); i++) { + temp_f20 = Rand_ZeroOne() * 0.0025f; + Matrix_InsertTranslation((*this->unk_254)[i].x, (*this->unk_254)[i].y, (*this->unk_254)[i].z, + MTXMODE_NEW); + Matrix_Scale(temp_f20, temp_f20, temp_f20, MTXMODE_APPLY); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 128, 128, 128, this->unk_282 >> 1); + gDPSetEnvColor(POLY_XLU_DISP++, 230, 230, 180, this->unk_282); + + func_8012C2DC(globalCtx->state.gfxCtx); + Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_278 + (i << 2), MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gOwlStatueWhiteFlashDL); + } + } + Lights_PointSetPosition(&this->lights[0].info, player->actor.world.pos.x, player->actor.world.pos.y - 10.0f, + player->actor.world.pos.z); + Lights_PointSetColorAndRadius(&this->lights[0].info, 250, 250, 100, this->unk_282); + break; + + case 90: + case 92: + case 94: + case 96: + case 97: + case 98: + case 99: + break; + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void EnTest6_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnTest6* this = THIS; + + if (this->unk_274 != 0) { + switch (this->unk_276) { + case 1: + func_80A93298(this, globalCtx); + break; + + case 0: + func_80A9369C(thisx, globalCtx); + break; + + case 2: + func_80A939E8(this, globalCtx); + break; + } + } +} diff --git a/src/overlays/actors/ovl_En_Test6/z_en_test6.h b/src/overlays/actors/ovl_En_Test6/z_en_test6.h index 9cee7cf1d2..0c1aab3b07 100644 --- a/src/overlays/actors/ovl_En_Test6/z_en_test6.h +++ b/src/overlays/actors/ovl_En_Test6/z_en_test6.h @@ -7,10 +7,46 @@ struct EnTest6; typedef void (*EnTest6ActionFunc)(struct EnTest6*, GlobalContext*); +#define ENTEST6_GET(thisx) ((thisx)->params) + +enum { + /* 24 */ ENTEST6_24 = 24, + /* 25 */ ENTEST6_25, + /* 26 */ ENTEST6_26, +}; + +typedef struct { + /* 0x00 */ LightNode* node; + /* 0x04 */ LightInfo info; +} EnTest6Light; + typedef struct EnTest6 { /* 0x0000 */ Actor actor; /* 0x0144 */ EnTest6ActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x140]; + /* 0x0148 */ Gfx* unk_148; + /* 0x014C */ f32 unk_14C; + /* 0x0150 */ f32 unk_150; + /* 0x0154 */ f32 unk_154; + /* 0x0158 */ f32 unk_158; + /* 0x015C */ f32 unk_15C; + /* 0x0160 */ f32 unk_160; + /* 0x0164 */ EnTest6Light lights[2]; + /* 0x018C */ DbCameraUnkStruct unk_18C; + /* 0x020C */ Vec3f unk_20C[6]; + /* 0x0254 */ Vec3f (*unk_254)[64]; + /* 0x0258 */ Vec3f unk_258; + /* 0x0264 */ Vec3f unk_264; + /* 0x0270 */ f32 unk_270; + /* 0x0274 */ s16 unk_274; + /* 0x0276 */ s16 unk_276; + /* 0x0278 */ s16 unk_278; + /* 0x027A */ s16 unk_27A; + /* 0x027C */ s16 unk_27C; + /* 0x027E */ s16 unk_27E; + /* 0x0280 */ s16 unk_280; + /* 0x0282 */ s16 unk_282; + /* 0x0284 */ s16 unk_284; + /* 0x0286 */ s16 unk_286; } EnTest6; // size = 0x288 extern const ActorInit En_Test6_InitVars; diff --git a/src/overlays/actors/ovl_En_Test7/z_en_test7.c b/src/overlays/actors/ovl_En_Test7/z_en_test7.c index e84e2d3fd0..c5fda21f08 100644 --- a/src/overlays/actors/ovl_En_Test7/z_en_test7.c +++ b/src/overlays/actors/ovl_En_Test7/z_en_test7.c @@ -5,6 +5,7 @@ */ #include "z_en_test7.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_100000 | ACTOR_FLAG_200000 | ACTOR_FLAG_2000000) @@ -15,11 +16,24 @@ void EnTest7_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnTest7_Update(Actor* thisx, GlobalContext* globalCtx); void EnTest7_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80AF2854(EnTest7* this, GlobalContext* globalCtx); - void EnTest7_SetupAction(EnTest7* this, EnTest7ActionFunc actionFunc); +void func_80AF19A8(EnTest7* this, GlobalContext* globalCtx); +void func_80AF1A2C(EnTest7* this, GlobalContext* globalCtx); +void func_80AF1CA0(EnTest7* this, GlobalContext* globalCtx); +void func_80AF1E44(EnTest7* this, GlobalContext* globalCtx); +void func_80AF1F48(EnTest7* this, GlobalContext* globalCtx); +void func_80AF2030(EnTest7* this, GlobalContext* globalCtx); +void func_80AF21E8(EnTest7* this, GlobalContext* globalCtx); +void func_80AF2318(EnTest7* this, GlobalContext* globalCtx); +void func_80AF2350(EnTest7* this, GlobalContext* globalCtx); +void func_80AF2854(EnTest7* this, GlobalContext* globalCtx); +void func_80AF2938(EnTest7* this, GlobalContext* globalCtx); +void func_80AF2AE8(EnTest7* this, GlobalContext* globalCtx); +void func_80AF2C48(EnTest7* this, GlobalContext* globalCtx); +void func_80AF2EC8(EnTest7* this, GlobalContext* globalCtx); +void func_80AF2F98(EnTest7* this, GlobalContext* globalCtx); +void func_80AF30F4(EnTest7* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Test7_InitVars = { ACTOR_EN_TEST7, ACTORCAT_ITEMACTION, @@ -32,80 +46,936 @@ const ActorInit En_Test7_InitVars = { (ActorFunc)EnTest7_Draw, }; -#endif +void EnTest7_SetupAction(EnTest7* this, EnTest7ActionFunc actionFunc) { + this->actionFunc = actionFunc; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/EnTest7_SetupAction.s") +void func_80AF082C(EnTest7* this, EnTest7UnkFunc func) { + this->unk_1E58 = func; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF082C.s") +void func_80AF0838(EnTest7Struct2* arg0) { + EnTest7Struct2* ptr = arg0; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF0838.s") + for (i = 0, ptr = arg0; i < 100; i++, ptr++) { + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF0984.s") + ptr->unk_00 = 0; + ptr->unk_04 = 0; + ptr->unk_08.x = 0.0f; + ptr->unk_08.y = 0.0f; + ptr->unk_08.z = 0.0f; + ptr->unk_14 = 0.0f; + ptr->unk_18 = 0.0f; + ptr->unk_1C = 0.0f; + ptr->unk_20 = 0.0f; + ptr->unk_24 = 0.0f; + ptr->unk_28 = 0.0f; + ptr->unk_2C = 0.00001f; + ptr->unk_30.x = 0; + ptr->unk_30.y = 0; + ptr->unk_30.z = 0; + ptr->unk_36 = 0; + ptr->unk_38 = 0; + ptr->unk_3A = 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF0C30.s") +void func_80AF0984(EnTest7Struct2* arg0, Vec3f* arg1, s32 arg2) { + s16 sp26 = Rand_ZeroOne() * 0xFFFF; + f32 sp20; + f32 temp_f0; + f32 temp_f0_2; + f32 temp_f0_3; + f32 temp_f4; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF0CDC.s") + arg0->unk_08 = *arg1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF10D8.s") + if (arg2 != 0) { + Math_CosS(sp26); + arg0->unk_08.x = arg0->unk_08.x; + arg0->unk_08.y += (Rand_ZeroOne() * 100.0f) - 20.0f; + Math_SinS(sp26); + arg0->unk_08.z = arg0->unk_08.z; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF118C.s") + sp20 = (Rand_ZeroOne() * 4.0f) + 2.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF14FC.s") + arg0->unk_14 = Math_CosS(sp26) * sp20; + arg0->unk_18 = Rand_ZeroOne(); + arg0->unk_1C = Math_SinS(sp26) * sp20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF1730.s") + arg0->unk_20 = 0.0f; + arg0->unk_24 = 0.0f; + arg0->unk_28 = 0.0f; + arg0->unk_2C = 0.25f; + arg0->unk_30.x = Rand_ZeroOne() * 0x10000; + arg0->unk_30.y = Rand_ZeroOne() * 0x10000; + arg0->unk_30.z = Rand_ZeroOne() * 0x10000; + arg0->unk_04 = 60; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/EnTest7_Init.s") + if (Rand_ZeroOne() < 0.9f) { + arg0->unk_00 = 1; + arg0->unk_30.x = Rand_ZeroOne() * 0x10000; + arg0->unk_30.y = Rand_ZeroOne() * 0x10000; + arg0->unk_30.z = Rand_ZeroOne() * 0x10000; + arg0->unk_36 = 0; + arg0->unk_38 = 0; + arg0->unk_3A = 0; + } else { + arg0->unk_00 = 2; + arg0->unk_30.x = 0; + arg0->unk_30.y = 0; + arg0->unk_30.z = Rand_ZeroOne() * 5000.0f; + arg0->unk_36 = 0; + arg0->unk_38 = (Rand_ZeroOne() * 8000.0f) + 2000.0f; + if (Rand_ZeroOne() > 0.5f) { + arg0->unk_38 = -arg0->unk_38; + } + arg0->unk_3A = 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/EnTest7_Destroy.s") +void func_80AF0C30(EnTest7Struct2* arg0, Vec3f* arg1, s32 arg2) { + static s32 D_80AF3410 = 0; + s32 i; + s32 phi_t0 = false; + EnTest7Struct2* ptr; + s32 idx; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF19A8.s") + for (i = 0, ptr = arg0; i < 100; i++, ptr++) { + if (ptr->unk_00 == 0) { + func_80AF0984(ptr, arg1, arg2); + D_80AF3410 = i; + phi_t0 = true; + break; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF1A2C.s") + if (!phi_t0) { + idx = D_80AF3410 + 1; + if (idx >= 100) { + idx = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF1B68.s") + func_80AF0984(&arg0[idx], arg1, arg2); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF1CA0.s") +Vec3f D_80AF3414 = { 0.0f, 1.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF1E44.s") +Vec3f D_80AF3420 = { 0.0f, 0.0f, 1.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF1F48.s") +void func_80AF0CDC(GlobalContext* globalCtx, EnTest7Struct2* arg1) { + static MtxF D_80AF38B0; + static Vec3f D_80AF38F0; + static f32 D_80AF38FC; + static Vec3f D_80AF3900; + s32 sp2C; + s32 sp28; + s32 sp24; + s16 temp_v0_2; + s16 temp_v0_3; + s32 temp_v0; + f32 phi_f8; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF2030.s") + sp2C = arg1->unk_04 % 41; + sp24 = 0; + sp28 = (arg1->unk_04 + 0x1B58) % 41; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF21E8.s") + SkinMatrix_SetRotateRPY(&D_80AF38B0, arg1->unk_30.x, arg1->unk_30.y, arg1->unk_30.z); + SkinMatrix_Vec3fMtxFMultXYZ(&D_80AF38B0, &D_80AF3414, &D_80AF38F0); + SkinMatrix_Vec3fMtxFMultXYZ(&D_80AF38B0, &D_80AF3420, &D_80AF3900); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF2318.s") + if (arg1->unk_30.x < 0x3448) { + arg1->unk_30.x += 0x384; + } else if (arg1->unk_30.x >= 0x4BB9) { + arg1->unk_30.x -= 0x384; + } else { + arg1->unk_30.x = (Math_SinS((sp2C * 65535.0f) / 41.0f) * 2000.0f) + 16384.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF2350.s") + if (arg1->unk_30.y < -0xBB8) { + arg1->unk_30.y += 0x384; + } else if (arg1->unk_30.y > 0xBB8) { + arg1->unk_30.y -= 0x384; + } else { + sp24 = 1; + arg1->unk_30.y = Math_SinS((sp28 * 65535.0f) / 41.0f) * 2000.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF24D8.s") + if (sp24 == 1) { + if (D_80AF38F0.y < 0.0f) { + arg1->unk_14 += D_80AF38F0.x * 0.5f; + arg1->unk_18 += (D_80AF38F0.y * 0.5f) + 0.08f; + arg1->unk_1C += (D_80AF38F0.z * 0.5f); + } else { + arg1->unk_14 += -D_80AF38F0.x * 0.5f; + arg1->unk_18 += (-D_80AF38F0.y * 0.5f) + 0.08f; + arg1->unk_1C += -D_80AF38F0.z * 0.5f; + } + } else if (D_80AF38F0.y < 0.0f) { + arg1->unk_14 += D_80AF38F0.x * 0.2f; + arg1->unk_18 += (D_80AF38F0.y * 0.2f) + 0.08f; + arg1->unk_1C += D_80AF38F0.z * 0.2f; + } else { + arg1->unk_14 += -D_80AF38F0.x * 0.2f; + arg1->unk_18 += (-D_80AF38F0.y * 0.2f) + 0.08f; + arg1->unk_1C += (-D_80AF38F0.z * 0.2f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF2654.s") + arg1->unk_08.x += arg1->unk_14; + arg1->unk_08.y += arg1->unk_18; + arg1->unk_08.z += arg1->unk_1C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF2808.s") +void func_80AF10D8(GlobalContext* globalCtx, EnTest7Struct2* arg1) { + arg1->unk_30.y += arg1->unk_38; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF2854.s") + arg1->unk_20 = Rand_Centered(); + arg1->unk_24 = Rand_Centered() + -0.01f; + arg1->unk_28 = Rand_Centered(); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF2938.s") + arg1->unk_14 += arg1->unk_20; + arg1->unk_18 += arg1->unk_24; + arg1->unk_1C += arg1->unk_28; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF29C0.s") + arg1->unk_08.x += arg1->unk_14; + arg1->unk_08.y += arg1->unk_18; + arg1->unk_08.z += arg1->unk_1C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF2AE8.s") +void func_80AF118C(GlobalContext* globalCtx, EnTest7Struct2* arg1, EnTest7* this, s32 arg3, s32 arg4) { + s32 pad[4]; + EnTest7Struct2* ptr; + s16 phi_s1; + s32 i; + f32 temp_f28; + Vec3f sp8C; + f32 temp_f0; + f32 temp_f22; + f32 temp_f24; + f32 temp_f26; + f32 temp_f2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF2BAC.s") + for (i = 0, ptr = arg1; i < (s32)(ARRAY_COUNT(this->unk_15C) * sizeof(this->unk_15C[0])); + i += sizeof(this->unk_15C[0]), ptr++) { + arg1 = ptr; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF2C48.s") + if (arg1->unk_00 == 0) { + continue; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF2DB4.s") + if (arg1->unk_00 == 1) { + func_80AF0CDC(globalCtx, arg1); + } else { + func_80AF10D8(globalCtx, arg1); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF2EC8.s") + if (arg3) { + temp_f22 = arg1->unk_08.x - this->actor.world.pos.x; + temp_f24 = arg1->unk_08.z - this->actor.world.pos.z; + temp_f0 = SQ(temp_f22) + SQ(temp_f24); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF2F98.s") + phi_s1 = -10000; + if (temp_f0 > SQ(20.0f)) { + phi_s1 /= ((temp_f0 - SQ(20.0f)) * 0.00125f) + 1.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF30F4.s") + temp_f26 = (temp_f22 * Math_CosS(phi_s1)) - (Math_SinS(phi_s1) * temp_f24); + temp_f28 = (temp_f22 * Math_SinS(phi_s1)) + (Math_CosS(phi_s1) * temp_f24); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/EnTest7_Update.s") + arg1->unk_08.x = this->actor.world.pos.x + temp_f26; + arg1->unk_08.z = this->actor.world.pos.z + temp_f28; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF31D0.s") + temp_f22 = arg1->unk_14; + temp_f24 = arg1->unk_1C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/EnTest7_Draw.s") + arg1->unk_14 = (temp_f22 * Math_CosS(phi_s1)) - (Math_SinS(phi_s1) * temp_f24); + arg1->unk_1C = (temp_f22 * Math_SinS(phi_s1)) + (Math_CosS(phi_s1) * temp_f24); + + temp_f22 = arg1->unk_20; + temp_f24 = arg1->unk_28; + + arg1->unk_20 = (temp_f22 * Math_CosS(phi_s1)) - (Math_SinS(phi_s1) * temp_f24); + arg1->unk_28 = (temp_f22 * Math_SinS(phi_s1)) + (Math_CosS(phi_s1) * temp_f24); + } + + if (arg4) { + sp8C.x = arg1->unk_08.x - this->actor.world.pos.x; + sp8C.y = arg1->unk_08.y - (this->actor.world.pos.y + 40.0f); + sp8C.z = arg1->unk_08.z - this->actor.world.pos.z; + + temp_f2 = 1.0f - (0.5f / ((Math3D_Vec3fMagnitude(&sp8C) / 500.0f) + 1.0f)); + + sp8C.x *= temp_f2; + sp8C.y *= temp_f2; + sp8C.z *= temp_f2; + + arg1->unk_08.x = this->actor.world.pos.x + sp8C.x; + arg1->unk_08.y = this->actor.world.pos.y + sp8C.y + 40.0f; + arg1->unk_08.z = this->actor.world.pos.z + sp8C.z; + } + } +} + +void func_80AF14FC(GlobalContext* globalCtx2, EnTest7Struct2* arg1) { + s32 pad[3]; + GlobalContext* globalCtx = globalCtx2; + Mtx* temp_v0; + EnTest7Struct2* ptr; + s32 i; + MtxF sp6C; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C1C0(globalCtx->state.gfxCtx); + + Matrix_StatePush(); + + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x80, 255, 255, 255, 255); + gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 255); + + for (i = 0, ptr = arg1; i < 0x1770; i += 0x3C, ptr++) { + if (ptr->unk_00 == 0) { + continue; + } + + if ((ptr->unk_08.x > 30000.0f) || (ptr->unk_08.x < -30000.0f) || (ptr->unk_08.y > 30000.0f) || + (ptr->unk_08.y < -30000.0f) || (ptr->unk_08.z > 30000.0f) || (ptr->unk_08.z < -30000.0f)) { + ptr->unk_00 = 0; + continue; + } + + Matrix_InsertTranslation(ptr->unk_08.x, ptr->unk_08.y, ptr->unk_08.z, MTXMODE_NEW); + + if (ptr->unk_00 == 1) { + Matrix_InsertRotation(ptr->unk_30.x, ptr->unk_30.y, ptr->unk_30.z, MTXMODE_APPLY); + } else { + SkinMatrix_SetRotateYRP(&sp6C, ptr->unk_30.x, ptr->unk_30.y, ptr->unk_30.z); + Matrix_InsertMatrix(&sp6C, MTXMODE_APPLY); + } + + Matrix_Scale(ptr->unk_2C, ptr->unk_2C, ptr->unk_2C, MTXMODE_APPLY); + if (ptr->unk_00 == 2) { + Matrix_InsertTranslation(0.0f, 30.0f, 0.0f, MTXMODE_APPLY); + } + + temp_v0 = Matrix_NewMtx(globalCtx->state.gfxCtx); + if (temp_v0 != NULL) { + gSPMatrix(POLY_OPA_DISP++, temp_v0, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_081628); + } + } + + if (ptr) {} + + Matrix_StatePop(); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80AF1730(EnTest7Struct* arg0) { + arg0->unk_00 = 0.0f; + arg0->unk_04 = 0.0f; + arg0->unk_08 = 1.0f; + arg0->unk_0C = 1.0f; + arg0->unk_10 = 0; +} + +void EnTest7_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnTest7* this = THIS; + Player* player = GET_PLAYER(globalCtx); + Player* player2 = GET_PLAYER(globalCtx); + + this->actor.world.rot.y = this->actor.shape.rot.y = player->actor.shape.rot.y; + this->unk_144 = 0; + this->unk_1E54 = 0; + this->unk_1E8E = player->actor.shape.rot.y; + this->unk_1E90 = player->actor.scale.x; + this->unk_1E94 = player->actor.scale.z; + + func_80183430(&this->unk_18CC, &gameplay_keep_Blob_085640, &gameplay_keep_Blob_083534, this->unk_18FC, + this->unk_1BA8, 0); + func_801834A8(&this->unk_18CC, &gameplay_keep_Blob_083534); + func_80AF0838(this->unk_15C); + func_80AF1730(&this->unk_148); + + if (ENTEST7_GET(&this->actor) == ENTEST7_MINUS1) { + func_80AF082C(this, func_80AF2938); + EnTest7_SetupAction(this, NULL); + } else { + func_80AF082C(this, func_80AF19A8); + EnTest7_SetupAction(this, func_80AF2854); + func_801A2E54(NA_BGM_SONG_OF_SOARING); + } + + if (globalCtx->playerActorCsIds[8] == -1) { + Actor_MarkForDeath(&this->actor); + return; + } + + ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[8]); + player2->stateFlags1 |= 0x20; + Lights_PointNoGlowSetInfo(&this->lightInfo, (Math_SinS(this->unk_1E8E) * 90.0f) + player->actor.world.pos.x, + player->actor.world.pos.y + 10.0f, + (Math_CosS(this->unk_1E8E) * 90.0f) + player->actor.world.pos.z, 255, 255, 255, 255); + this->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfo); +} + +void EnTest7_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnTest7* this = THIS; + + ActorCutscene_Stop(globalCtx->playerActorCsIds[8]); + LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lightNode); +} + +void func_80AF19A8(EnTest7* this, GlobalContext* globalCtx) { + if (!ActorCutscene_GetCanPlayNext(globalCtx->playerActorCsIds[8])) { + ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[8]); + } else { + ActorCutscene_Start(globalCtx->playerActorCsIds[8], NULL); + func_80AF082C(this, func_80AF1A2C); + globalCtx->unk_18844 = 1; + } +} + +void func_80AF1A2C(EnTest7* this, GlobalContext* globalCtx) { + Color_RGB8 sp34 = { 64, 0, 0 }; + Color_RGB8 sp30 = { 220, 220, 255 }; + f32 sp2C = this->unk_1E54 / 10.0f; + + func_800FD59C(globalCtx, &sp30, sp2C); + func_800FD654(globalCtx, &sp34, sp2C); + func_800FD698(globalCtx, 2000, 4000, sp2C); + + if (this->unk_1E54 >= 10) { + Camera* camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8])); + + this->unk_1E60 = camera->eye; + this->unk_1E6C = camera->at; + this->unk_1E78 = camera->fov; + + func_80AF082C(this, func_80AF1CA0); + this->unk_144 |= 0x20; + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_PL_WARP_WING_OPEN); + func_8016566C(0x78); + } +} + +void func_80AF1B68(EnTest7* this, GlobalContext* globalCtx) { + this->unk_144 |= 2; + + if (this->unk_148.unk_04 < 11.0f) { + this->unk_148.unk_04 = this->unk_148.unk_04 + 0.3f; + this->unk_148.unk_08 = ((this->unk_148.unk_00 * -0.45f) / 11.0f) + 0.7f; + this->unk_148.unk_0C = ((this->unk_148.unk_00 * -0.29999998f) / 11.0f) + 0.7f; + } + + if (this->unk_148.unk_00 < 11.0f) { + this->unk_148.unk_00 += 1.0f; + if (this->unk_148.unk_00 > 6.0f) { + Player* player = GET_PLAYER(globalCtx); + + this->unk_144 &= ~1; + player->actor.draw = NULL; + } + } else if (this->unk_1E54 >= 87) { + func_80AF082C(this, func_80AF1F48); + this->unk_144 &= -9; + this->unk_148.unk_10 -= 0x2EE0; + } else { + this->unk_148.unk_10 -= 0x2EE0; + } +} + +void func_80AF1CA0(EnTest7* this, GlobalContext* globalCtx) { + Vec3f sp34; + + if (func_80183DE0(&this->unk_18CC)) { + func_80AF082C(this, func_80AF1E44); + } + + if (this->unk_18CC.frameCtrl.unk_10 > 60.0f) { + func_80AF1B68(this, globalCtx); + } + + if ((this->unk_18CC.frameCtrl.unk_10 > 20.0f) && !(this->unk_144 & 0x40)) { + this->unk_144 |= 0x40; + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_PL_WARP_WING_CLOSE); + } + + if (this->unk_18CC.frameCtrl.unk_10 > 42.0f) { + if (!(this->unk_144 & 0x80)) { + this->unk_144 |= 0x80; + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_PL_WARP_WING_ROLL); + } + + if (Rand_ZeroOne() < 0.3f) { + Camera* camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8])); + f32 rand = Rand_ZeroOne(); + + sp34.x = ((camera->eye.x - this->actor.world.pos.x) * rand) + this->actor.world.pos.x; + sp34.y = ((camera->eye.y - this->actor.world.pos.y) * rand) + this->actor.world.pos.y; + sp34.z = ((camera->eye.z - this->actor.world.pos.z) * rand) + this->actor.world.pos.z; + + func_80AF0C30(this->unk_15C, &sp34, 1); + this->unk_144 |= 8; + } + } else { + this->unk_144 |= 1; + } +} + +void func_80AF1E44(EnTest7* this, GlobalContext* globalCtx) { + Vec3f sp34; + Camera* camera; + f32 rand; + + func_80AF1B68(this, globalCtx); + + if (Rand_ZeroOne() < 0.3f) { + camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8])); + rand = Rand_ZeroOne(); + sp34.x = ((camera->eye.x - this->actor.world.pos.x) * rand) + this->actor.world.pos.x; + sp34.y = ((camera->eye.y - this->actor.world.pos.y) * rand) + this->actor.world.pos.y; + sp34.z = ((camera->eye.z - this->actor.world.pos.z) * rand) + this->actor.world.pos.z; + func_80AF0C30(this->unk_15C, &sp34, 1); + } + + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); + func_80AF0C30(this->unk_15C, &sp34, 1); + this->unk_18FC[1].y += 0x2EE0; +} + +void func_80AF1F48(EnTest7* this, GlobalContext* globalCtx) { + s32 pad; + s32 temp = this->unk_1E54 - 86; + f32 temp_f0 = temp / 10.0f; + Vec3f sp20; + + this->unk_144 |= 0x10; + + this->unk_148.unk_08 = (-0.15f * temp_f0) + 0.25f; + this->unk_148.unk_0C = (-0.3f * temp_f0) + 0.4f; + this->unk_148.unk_10 -= 0x2EE0; + + this->unk_144 |= 4; + + if (this->unk_1E54 >= 96) { + func_80AF082C(this, func_80AF2030); + this->unk_144 &= ~0x10; + } + Math_Vec3f_Copy(&sp20, &this->actor.world.pos); + func_80AF0C30(this->unk_15C, &sp20, 1); +} + +void func_80AF2030(EnTest7* this, GlobalContext* globalCtx) { + s32 temp = this->unk_1E54 - 96; + f32 four = 4; + f32 sp1C = 1.0f - (temp / four); + Camera* camera; + f32 temp_f2; + f32 temp_f4; + + this->unk_148.unk_08 = ((temp * -0.1f) / four) + 0.1f; + this->unk_148.unk_0C = ((temp * 5.9f) / four) + 0.1f; + this->unk_148.unk_10 -= 0x2EE0; + this->actor.world.pos.y += 100.0f; + + camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8])); + camera->player = NULL; + + camera->eye.x = ((camera->eye.x - this->unk_1E60.x) * sp1C) + this->unk_1E60.x; + camera->eye.y = ((camera->eye.y - this->unk_1E60.y) * sp1C) + this->unk_1E60.y; + camera->eye.z = ((camera->eye.z - this->unk_1E60.z) * sp1C) + this->unk_1E60.z; + camera->fov = ((camera->fov - this->unk_1E78) * sp1C) + this->unk_1E78; + + if (this->unk_1E54 >= 100) { + MREG(64) = 1; + MREG(65) = 255; + MREG(66) = 255; + MREG(67) = 255; + MREG(68) = 255; + globalCtx->unk_18844 = 0; + this->unk_144 &= ~4; + func_80AF082C(this, func_80AF21E8); + func_80165690(); + } +} + +void func_80AF21E8(EnTest7* this, GlobalContext* globalCtx) { + s32 sp2C = this->unk_1E54 - 100; + f32 sp1C; + Color_RGB8 sp24 = { 64, 0, 0 }; + Color_RGB8 sp20 = { 220, 220, 255 }; + + if (MREG(64) != 0) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_PL_WARP_WING_VANISH); + MREG(64) = 0; + MREG(65) = 0; + MREG(66) = 0; + MREG(67) = 0; + MREG(68) = 0; + } + + sp1C = 1.0f - (sp2C / 10.0f); + func_800FD59C(globalCtx, &sp20, sp1C); + func_800FD654(globalCtx, &sp24, sp1C); + func_800FD698(globalCtx, 2000, 4000, sp1C); + + if (this->unk_1E54 >= 110) { + func_80AF082C(this, func_80AF2318); + } +} + +void func_80AF2318(EnTest7* this, GlobalContext* globalCtx) { + if (this->unk_1E54 >= 130) { + func_80AF082C(this, func_80AF2350); + } +} + +u16 D_80AF343C[] = { + 0x68B0, 0x6A60, 0xB230, 0x9A80, 0xD890, 0x3E40, 0x8640, 0x84A0, 0x2040, 0xAA30, +}; + +void func_80AF2350(EnTest7* this, GlobalContext* globalCtx) { + Vec3f sp2C; + + if (this) {} + + Math_Vec3f_Copy(&sp2C, &this->actor.world.pos); + + if (Rand_ZeroOne() < 0.1f) { + func_80AF0C30(this->unk_15C, &sp2C, 1); + } + + this->unk_148.unk_10 -= 0x2EE0; + + if (globalCtx->sceneNum == SCENE_SECOM) { + globalCtx->nextEntranceIndex = 0x2060; + } else if (ENTEST7_GET(&this->actor) == ENTEST7_26) { + func_80169F78(&globalCtx->state); + gSaveContext.respawn[2].playerParams = (gSaveContext.respawn[2].playerParams & 0xFF) | 0x600; + gSaveContext.respawnFlag = -6; + } else { + globalCtx->nextEntranceIndex = D_80AF343C[ENTEST7_GET(&this->actor) - ENTEST7_1C]; + if ((globalCtx->nextEntranceIndex == 0x84A0) && (gSaveContext.save.weekEventReg[20] & 2)) { + globalCtx->nextEntranceIndex = 0xCA0; + } else if ((globalCtx->nextEntranceIndex == 0x9A80) && (gSaveContext.save.weekEventReg[33] & 0x80)) { + globalCtx->nextEntranceIndex = 0xAE80; + } + } + + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 2; + gSaveContext.seqIndex = 0xFF; + gSaveContext.nightSeqIndex = 0xFF; +} + +void func_80AF24D8(EnTest7* this, GlobalContext* globalCtx, f32 arg2) { + Vec3f sp3C; + Vec3f* pos; + Player* player = GET_PLAYER(globalCtx); + Camera* camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8])); + + pos = &player->actor.world.pos; + camera->player = NULL; + + sp3C.x = ((180.0f * Math_SinS(this->unk_1E8E)) * Math_CosS(0xFA0)) + pos->x; + sp3C.y = (Math_SinS(0xFA0) * 180.0f) + pos->y; + sp3C.z = ((180.0f * Math_CosS(this->unk_1E8E)) * Math_CosS(0xFA0)) + pos->z; + + camera->eye.x = ((sp3C.x - camera->eye.x) * arg2) + camera->eye.x; + camera->eye.y = ((sp3C.y - camera->eye.y) * arg2) + camera->eye.y; + camera->eye.z = ((sp3C.z - camera->eye.z) * arg2) + camera->eye.z; + + camera->fov = ((this->unk_1E78 - camera->fov) * arg2) + camera->fov; + camera->at.y += 1.4444444f; +} + +void func_80AF2654(EnTest7* this, GlobalContext* globalCtx, f32 arg2) { + Vec3f* pos; + Player* player = GET_PLAYER(globalCtx); + Camera* camera; + Vec3f sp30; + + camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8])); + camera->player = NULL; + + pos = &player->actor.world.pos; + + sp30.x = ((80.0f * Math_SinS(this->unk_1E8E)) * Math_CosS(0xBB8)) + pos->x; + sp30.y = (Math_SinS(0xBB8) * 80.0f) + pos->y; + sp30.z = ((80.0f * Math_CosS(this->unk_1E8E)) * Math_CosS(0xBB8)) + pos->z; + + camera->eye.x = ((sp30.x - camera->eye.x) * arg2) + camera->eye.x; + camera->eye.y = ((sp30.y - camera->eye.y) * arg2) + camera->eye.y; + camera->eye.z = ((sp30.z - camera->eye.z) * arg2) + camera->eye.z; + + camera->at.x = ((pos->x - camera->at.x) * arg2) + camera->at.x; + camera->at.y = (((pos->y + 40.0f) - camera->at.y) * arg2) + camera->at.y; + camera->at.z = ((pos->z - camera->at.z) * arg2) + camera->at.z; + + camera->fov = ((this->unk_1E78 - camera->fov) * arg2) + camera->fov; +} + +void func_80AF2808(EnTest7* this, GlobalContext* globalCtx, f32 arg2) { + Player* player = GET_PLAYER(globalCtx); + + player->actor.shape.rot.y += 0x2EE0; + player->actor.scale.x = ((0.0f - this->unk_1E90) * arg2) + this->unk_1E90; + player->actor.scale.z = ((0.0f - this->unk_1E94) * arg2) + this->unk_1E94; +} + +void func_80AF2854(EnTest7* this, GlobalContext* globalCtx) { + f32 temp; + f32 sixteen = 16.0f; + + if ((this->unk_1E54 >= 12) && (this->unk_1E54 < 31)) { + temp = (this->unk_1E54 - 12) / 18.0f; + func_80AF24D8(this, globalCtx, temp); + } else if ((this->unk_1E54 >= 79) && (this->unk_1E54 < 96)) { + temp = (this->unk_1E54 - 79) / sixteen; + func_80AF2654(this, globalCtx, temp); + } + + if ((this->unk_1E54 >= 42) && (this->unk_1E54 < 69)) { + temp = (this->unk_1E54 - 42) / 26.0f; + func_80AF2808(this, globalCtx, temp); + } +} + +void func_80AF2938(EnTest7* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + this->unk_1E98 = player->actor.draw; + player->actor.draw = NULL; + player->stateFlags2 |= 0x20000000; + this->unk_144 |= 2; + this->unk_148.unk_04 = 30.0f; + if (globalCtx->roomCtx.currRoom.unk3 != 1) { + func_80AF082C(this, func_80AF2AE8); + } else { + func_80AF082C(this, func_80AF2EC8); + } +} + +s16 D_80AF3450[] = { 0, 0x31C7 }; + +f32 D_80AF3454 = 3500.0f; + +void func_80AF29C0(EnTest7* this, GlobalContext* globalCtx) { + s32 pad; + Player* player = GET_PLAYER(globalCtx); + Vec3f* pos = &player->actor.world.pos; + Camera* temp_s0 = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8])); + + temp_s0->at.x = ((D_80AF3454 * Math_SinS(D_80AF3450[0]) * Math_CosS(D_80AF3450[1]))) + pos->x; + temp_s0->at.y = (Math_SinS(D_80AF3450[1]) * D_80AF3454) + pos->y; + temp_s0->at.z = ((D_80AF3454 * Math_CosS(D_80AF3450[0])) * Math_CosS(D_80AF3450[1])) + pos->z; + + this->actor.world.pos.x = temp_s0->at.x; + this->actor.world.pos.y = temp_s0->at.y - 40.0f; + this->actor.world.pos.z = temp_s0->at.z; +} + +void func_80AF2AE8(EnTest7* this, GlobalContext* globalCtx) { + Camera* camera; + + if (!ActorCutscene_GetCanPlayNext(globalCtx->playerActorCsIds[8])) { + ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[8]); + return; + } + + ActorCutscene_Start(globalCtx->playerActorCsIds[8], NULL); + func_80AF082C(this, func_80AF2C48); + + camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8])); + this->unk_1E60 = camera->eye; + this->unk_1E6C = camera->at; + + func_80AF29C0(this, globalCtx); +} + +void func_80AF2BAC(EnTest7* this, GlobalContext* globalCtx, Vec3f* arg2, f32 arg3) { + f32 x; + f32 y; + f32 z; + Camera* camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8])); + + camera->player = NULL; + x = ((camera->at.x - arg2->x) * arg3) + arg2->x; + y = ((camera->at.y - arg2->y) * arg3) + arg2->y; + z = ((camera->at.z - arg2->z) * arg3) + arg2->z; + + camera->at.x = x; + camera->at.y = y; + camera->at.z = z; +} + +void func_80AF2C48(EnTest7* this, GlobalContext* globalCtx) { + f32 sp24 = (40 - this->unk_1E54) / 40.0f; + Camera* camera; + + this->unk_148.unk_00 = 11.0f; + this->unk_144 |= 4; + this->unk_148.unk_08 = 0.05f; + this->unk_148.unk_0C = 0.05f; + this->unk_148.unk_10 += 0x2EE0; + + this->actor.world.pos.x = ((this->actor.world.pos.x - this->actor.home.pos.x) * sp24) + this->actor.home.pos.x; + this->actor.world.pos.y = ((this->actor.world.pos.y - this->actor.home.pos.y) * sp24) + this->actor.home.pos.y; + this->actor.world.pos.z = ((this->actor.world.pos.z - this->actor.home.pos.z) * sp24) + this->actor.home.pos.z; + + camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8])); + func_80AF2BAC(this, globalCtx, &this->actor.home.pos, sp24); + + camera->at.x = this->actor.world.pos.x; + camera->at.y = this->actor.world.pos.y + 40.0f; + camera->at.z = this->actor.world.pos.z; + + func_800B9010(&this->actor, NA_SE_PL_WARP_WING_ROLL_2 - SFX_FLAG); + if (this->unk_1E54 >= 40) { + this->unk_144 &= ~4; + func_80AF082C(this, func_80AF2F98); + } +} + +void func_80AF2DB4(EnTest7* this, GlobalContext* globalCtx) { + Camera* camera; + Player* player = GET_PLAYER(globalCtx); + Vec3f* pos = &player->actor.world.pos; + + camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8])); + + camera->eye.x = (Math_SinS(-player->actor.shape.rot.y) * 200.0f * -0.83907f) + pos->x; + camera->eye.y = pos->y + 108.8042f; + camera->eye.z = (Math_CosS(-player->actor.shape.rot.y) * 200.0f * -0.83907f) + pos->z; + + camera->at.x = pos->x; + camera->at.y = pos->y + 40.0f; + camera->at.z = pos->z; +} + +void func_80AF2EC8(EnTest7* this, GlobalContext* globalCtx) { + Camera* camera; + + if (!ActorCutscene_GetCanPlayNext(globalCtx->playerActorCsIds[8])) { + ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[8]); + } else { + ActorCutscene_Start(globalCtx->playerActorCsIds[8], NULL); + func_80AF082C(this, func_80AF2F98); + + camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8])); + this->unk_1E60 = camera->eye; + this->unk_1E6C = camera->at; + this->unk_1E54 = 40; + + func_80AF2DB4(this, globalCtx); + } +} + +void func_80AF2F98(EnTest7* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Player* player2 = GET_PLAYER(globalCtx); + Vec3f sp2C; + + func_800B9010(&this->actor, NA_SE_PL_WARP_WING_ROLL_2 - SFX_FLAG); + + sp2C = this->actor.world.pos; + + func_80AF0C30(this->unk_15C, &sp2C, 1); + func_80AF0C30(this->unk_15C, &sp2C, 1); + this->unk_148.unk_04 = 70 - this->unk_1E54; + if (this->unk_1E54 > 70) { + func_80AF082C(this, func_80AF30F4); + } + + if (this->unk_148.unk_04 > 11.0f) { + f32 temp = this->unk_148.unk_04 - 11.0f; + + this->unk_148.unk_08 = ((-0.35f * temp) / 19.0f) + 0.4f; + this->unk_148.unk_0C = ((-0.35f * temp) / 19.0f) + 0.4f; + this->unk_148.unk_10 += 0x2EE0; + } else { + player2->actor.draw = this->unk_1E98; + this->unk_148.unk_00 = this->unk_148.unk_04; + this->unk_148.unk_08 = ((this->unk_148.unk_04 * -0.29999998f) / 11.0f) + 0.7f; + this->unk_148.unk_0C = ((this->unk_148.unk_04 * -0.29999998f) / 11.0f) + 0.7f; + player->stateFlags2 &= ~0x20000000; + } +} + +void func_80AF30F4(EnTest7* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (this->unk_1E54 > 90) { + player->stateFlags1 &= ~0x20; + player->stateFlags1 &= ~0x20000000; + Actor_MarkForDeath(&this->actor); + } +} + +void EnTest7_Update(Actor* thisx, GlobalContext* globalCtx) { + EnTest7* this = THIS; + + this->unk_1E58(this, globalCtx); + + if (this->actionFunc != NULL) { + this->actionFunc(this, globalCtx); + } + + this->unk_1E54++; + + func_80AF118C(globalCtx, this->unk_15C, this, (this->unk_144 & 8) != 0, (this->unk_144 & 0x10) != 0); +} + +s32 func_80AF31D0(GlobalContext* globalCtx, SkeletonInfo* skeletonInfo, s32 limbIndex, Gfx** dList, u8* flags, + Actor* thisx, Vec3f* scale, Vec3s* rot, Vec3f* pos) { + EnTest7* this = THIS; + Vec3f sp18; + + if ((*dList != NULL) && (Rand_ZeroOne() < 0.03f)) { + Matrix_MultiplyVector3fByState(&gZeroVec3f, &sp18); + func_80AF0C30(this->unk_15C, &sp18, 0); + } + return true; +} + +void EnTest7_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad[2]; + EnTest7* this = THIS; + s32 sp40; + + if (this->unk_144 & 1) { + Mtx* mtx = GRAPH_ALLOC(globalCtx->state.gfxCtx, ALIGN16(sizeof(Mtx) * this->unk_18CC.unk_18->unk_1)); + + if (mtx != NULL) { + func_8018450C(globalCtx, &this->unk_18CC, mtx, func_80AF31D0, NULL, &this->actor); + } else { + return; + } + } + + if (this->unk_144 & 2) { + Matrix_StatePush(); + Matrix_InsertTranslation(0.0f, 4000.0f, 0.0f, MTXMODE_APPLY); + Matrix_InsertRotation(0, this->unk_148.unk_10, 0, MTXMODE_APPLY); + Matrix_Scale(this->unk_148.unk_08 * 100.0f, this->unk_148.unk_0C * 100.0f, this->unk_148.unk_08 * 100.0f, + MTXMODE_APPLY); + sp40 = this->unk_148.unk_00; + AnimatedMat_DrawStep(globalCtx, Lib_SegmentedToVirtual(&gameplay_keep_Matanimheader_0815D0), sp40); + Gfx_DrawDListXlu(globalCtx, gameplay_keep_DL_080FC8); + Matrix_StatePop(); + } + + func_80AF14FC(globalCtx, this->unk_15C); + + if (this->unk_144 & 4) { + func_800F9824(globalCtx, &globalCtx->envCtx, &globalCtx->view, globalCtx->state.gfxCtx, this->actor.world.pos, + 70.0f, 5.0f, 0, 0); + } +} diff --git a/src/overlays/actors/ovl_En_Test7/z_en_test7.h b/src/overlays/actors/ovl_En_Test7/z_en_test7.h index 0973b42456..a074c78750 100644 --- a/src/overlays/actors/ovl_En_Test7/z_en_test7.h +++ b/src/overlays/actors/ovl_En_Test7/z_en_test7.h @@ -6,12 +6,60 @@ struct EnTest7; typedef void (*EnTest7ActionFunc)(struct EnTest7*, GlobalContext*); +typedef void (*EnTest7UnkFunc)(struct EnTest7*, GlobalContext*); +typedef void (*EnTest7UnkDrawFunc)(Actor*, GlobalContext*); + +#define ENTEST7_GET(thisx) ((thisx)->params) + +#define ENTEST7_MINUS1 -1 +#define ENTEST7_26 0x26 +#define ENTEST7_1C 0x1C + +typedef struct { + /* 0x00 */ f32 unk_00; + /* 0x04 */ f32 unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ s16 unk_10; +} EnTest7Struct; // size >= 0x14 + +typedef struct { + /* 0x00 */ s32 unk_00; + /* 0x04 */ s32 unk_04; + /* 0x08 */ Vec3f unk_08; + /* 0x14 */ f32 unk_14; + /* 0x18 */ f32 unk_18; + /* 0x1C */ f32 unk_1C; + /* 0x20 */ f32 unk_20; + /* 0x24 */ f32 unk_24; + /* 0x28 */ f32 unk_28; + /* 0x2C */ f32 unk_2C; + /* 0x30 */ Vec3s unk_30; + /* 0x36 */ s16 unk_36; + /* 0x38 */ s16 unk_38; + /* 0x3A */ s16 unk_3A; +} EnTest7Struct2; // size = 0x3C typedef struct EnTest7 { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x1D18]; + /* 0x0144 */ s32 unk_144; + /* 0x0148 */ EnTest7Struct unk_148; + /* 0x015C */ EnTest7Struct2 unk_15C[100]; + /* 0x18CC */ SkeletonInfo unk_18CC; + /* 0x18FC */ Vec3s unk_18FC[114]; + /* 0x1BA8 */ s16 unk_1BA8[342]; + /* 0x1E54 */ s32 unk_1E54; + /* 0x1E58 */ EnTest7UnkFunc unk_1E58; /* 0x1E5C */ EnTest7ActionFunc actionFunc; - /* 0x1E60 */ char unk_1E60[0x3C]; + /* 0x1E60 */ Vec3f unk_1E60; + /* 0x1E6C */ Vec3f unk_1E6C; + /* 0x1E78 */ f32 unk_1E78; + /* 0x1E7C */ LightNode* lightNode; + /* 0x1E80 */ LightInfo lightInfo; + /* 0x1E8E */ s16 unk_1E8E; + /* 0x1E90 */ f32 unk_1E90; + /* 0x1E94 */ f32 unk_1E94; + /* 0x1E98 */ EnTest7UnkDrawFunc unk_1E98; } EnTest7; // size = 0x1E9C extern const ActorInit En_Test7_InitVars; diff --git a/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c b/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c index 5aaf7adb60..5a89347e76 100644 --- a/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c +++ b/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c @@ -168,7 +168,7 @@ void EnThiefbird_Init(Actor* thisx, GlobalContext* globalCtx) { D_80C1392C = 1; Math_Vec3f_Copy(&D_80C13920, &this->actor.world.pos); Actor_MarkForDeath(&this->actor); - } else if ((gSaveContext.stolenItems & 0xFF000000) >> 0x18) { + } else if (STOLEN_ITEM_1 != STOLEN_ITEM_NONE) { Actor_MarkForDeath(&this->actor); } else { func_80C11538(this); @@ -213,17 +213,17 @@ s32 func_80C10B0C(EnThiefbird* this, GlobalContext* globalCtx) { s32 itemId1; s16 itemId2 = 0; - for (; slotId < ARRAY_COUNT(gSaveContext.inventory.items); slotId++) { - if ((gSaveContext.inventory.items[slotId] >= ITEM_BOTTLE) && - (gSaveContext.inventory.items[slotId] <= ITEM_POTION_BLUE)) { + for (; slotId < 24; slotId++) { + if ((gSaveContext.save.inventory.items[slotId] >= ITEM_BOTTLE) && + (gSaveContext.save.inventory.items[slotId] <= ITEM_POTION_BLUE)) { isItemFound = true; - itemId2 = gSaveContext.inventory.items[slotId]; + itemId2 = gSaveContext.save.inventory.items[slotId]; break; } } - if (gSaveContext.playerForm == PLAYER_FORM_HUMAN) { - phi_a3 = CUR_EQUIP_VALUE_VOID(EQUIP_SWORD); + if (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { + phi_a3 = GET_CUR_EQUIP_VALUE(EQUIP_SWORD); if (INV_CONTENT(ITEM_SWORD_GREAT_FAIRY) == ITEM_SWORD_GREAT_FAIRY) { phi_a3 += 4; } @@ -271,10 +271,10 @@ s32 func_80C10B0C(EnThiefbird* this, GlobalContext* globalCtx) { return false; } - if (!((gSaveContext.stolenItems & 0xFF000000) >> 0x18)) { - gSaveContext.stolenItems = (gSaveContext.stolenItems & 0xFFFFFF) | ((itemId1 & 0xFF) << 0x18); + if (STOLEN_ITEM_1 == STOLEN_ITEM_NONE) { + SET_STOLEN_ITEM_1(itemId1); } else { - gSaveContext.stolenItems = (gSaveContext.stolenItems & 0xFF00FFFF) | ((itemId1 & 0xFF) << 0x10); + SET_STOLEN_ITEM_2(itemId1); } return true; @@ -334,7 +334,7 @@ s32 func_80C10E98(GlobalContext* globalCtx) { spAC = 0; } - sp98 = (gSaveContext.rupees / 4) * 3; + sp98 = (gSaveContext.save.playerData.rupees / 4) * 3; phi_s0_2 = sp98 / 50; sp5C = (-spB0 - spAC); sp5C += 8; @@ -443,19 +443,19 @@ void func_80C11338(EnThiefbird* this, GlobalContext* globalCtx) { } void func_80C11454(EnThiefbird* this) { - this->unk_18C = 10; - this->unk_3D8 = 0.5f; - this->unk_3DC = 0.75f; - this->unk_3D4 = 1.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; + this->drawDmgEffScale = 0.5f; + this->drawDmgEffFrozenSteamScale = 0.75f; + this->drawDmgEffAlpha = 1.0f; this->actor.flags &= ~ACTOR_FLAG_200; Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); } void func_80C114C0(EnThiefbird* this, GlobalContext* globalCtx) { - if (this->unk_18C == 10) { - this->unk_18C = 0; - this->unk_3D4 = 0.0f; - Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_350, 11, 2, 0.2f, 0.2f); + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, 11, 2, 0.2f, 0.2f); this->actor.flags |= ACTOR_FLAG_200; } } @@ -570,8 +570,7 @@ void func_80C1193C(EnThiefbird* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_THIEFBIRD_VOICE); if (!(this->collider.base.atFlags & AT_BOUNCED)) { if ((D_80C1392C != 0) && CUR_UPG_VALUE(UPG_QUIVER) && - (!((gSaveContext.stolenItems & 0xFF000000) >> 0x18) || - !((gSaveContext.stolenItems & 0xFF0000) >> 0x10)) && + ((STOLEN_ITEM_1 == STOLEN_ITEM_NONE) || (STOLEN_ITEM_2 == STOLEN_ITEM_NONE)) && (Rand_ZeroOne() < 0.5f) && func_80C10B0C(this, globalCtx)) { func_80C1242C(this); } else if (func_80C10E98(globalCtx)) { @@ -611,7 +610,7 @@ void func_80C11D14(EnThiefbird* this, GlobalContext* globalCtx) { this->unk_18E--; } - if (this->unk_18C == 10) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { if (this->unk_18E < 38) { func_80C114C0(this, globalCtx); this->actor.speedXZ = 4.0f; @@ -646,8 +645,8 @@ void func_80C11DF0(EnThiefbird* this, GlobalContext* globalCtx) { } if ((this->actor.bgCheckFlags & 1) || (this->actor.floorHeight == BGCHECK_Y_MIN)) { - for (i = 0; i < ARRAY_COUNT(this->unk_350); i++) { - func_800B3030(globalCtx, &this->unk_350[i], &gZeroVec3f, &gZeroVec3f, 0x8C, 0, 0); + for (i = 0; i < ARRAY_COUNT(this->limbPos); i++) { + func_800B3030(globalCtx, &this->limbPos[i], &gZeroVec3f, &gZeroVec3f, 0x8C, 0, 0); } SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 11, NA_SE_EN_EXTINCT); @@ -713,7 +712,7 @@ void func_80C1215C(EnThiefbird* this, GlobalContext* globalCtx) { this->unk_18E--; } - if (this->unk_18C == 10) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { if (this->unk_18E < 38) { func_80C114C0(this, globalCtx); this->actor.speedXZ = 4.0f; @@ -877,10 +876,10 @@ void func_80C127F4(EnThiefbird* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, Actor_YawBetweenActors(&this->actor, &this->unk_3EC->actor), 3, 0x2000, 0x100); } - temp_v0 = Math_Vec3f_Pitch(&this->unk_350[9], &this->unk_3EC->actor.world.pos); + temp_v0 = Math_Vec3f_Pitch(&this->limbPos[9], &this->unk_3EC->actor.world.pos); temp_v0 = CLAMP(temp_v0, -0x3000, 0x3000); Math_SmoothStepToS(&this->actor.shape.rot.x, temp_v0, 4, 0x800, 0x80); - temp_f0 = Actor_DistanceToPoint(&this->unk_3EC->actor, &this->unk_350[9]); + temp_f0 = Actor_DistanceToPoint(&this->unk_3EC->actor, &this->limbPos[9]); this->actor.speedXZ = (0.02f * temp_f0) + 2.0f; this->actor.speedXZ = CLAMP_MAX(this->actor.speedXZ, 4.0f); if ((this->unk_3EC->actor.speedXZ <= 0.0f) && (temp_f0 < 40.0f)) { @@ -933,22 +932,22 @@ void func_80C12B1C(EnThiefbird* this, GlobalContext* globalCtx) { if (this->actor.colChkInfo.damageEffect == 3) { func_80C11454(this); } else if (this->actor.colChkInfo.damageEffect == 4) { - this->unk_18C = 20; - this->unk_3D8 = 0.5f; - this->unk_3D4 = 4.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->drawDmgEffScale = 0.5f; + this->drawDmgEffAlpha = 4.0f; if (i != ARRAY_COUNT(this->colliderElements)) { sph = &this->collider.elements[i]; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, sph->info.bumper.hitPos.x, sph->info.bumper.hitPos.y, sph->info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); } } else if (this->actor.colChkInfo.damageEffect == 2) { - this->unk_18C = 0; - this->unk_3D8 = 0.5f; - this->unk_3D4 = 4.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffScale = 0.5f; + this->drawDmgEffAlpha = 4.0f; } else if (this->actor.colChkInfo.damageEffect == 5) { - this->unk_18C = 0x1E; - this->unk_3D8 = 0.5f; - this->unk_3D4 = 2.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; + this->drawDmgEffScale = 0.5f; + this->drawDmgEffAlpha = 2.0f; } if (this->unk_3E8 != 0) { @@ -1020,12 +1019,12 @@ void EnThiefbird_Update(Actor* thisx, GlobalContext* globalCtx2) { } CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - if (this->unk_3D4 > 0.0f) { - if (this->unk_18C != 10) { - Math_StepToF(&this->unk_3D4, 0.0f, 0.05f); - this->unk_3D8 = (this->unk_3D4 + 1.0f) * 0.25f; - this->unk_3D8 = CLAMP_MAX(this->unk_3D8, 0.5f); - } else if (!Math_StepToF(&this->unk_3DC, 0.5f, 0.0125f)) { + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.25f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 0.5f); + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.5f, 0.0125f)) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } @@ -1099,11 +1098,11 @@ void EnThiefbird_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi idx = D_80C13698[limbIndex]; if (idx != -1) { if (idx == 9) { - Matrix_GetStateTranslationAndScaledX(1000.0f, &this->unk_350[idx]); + Matrix_GetStateTranslationAndScaledX(1000.0f, &this->limbPos[idx]); } else { - Matrix_GetStateTranslation(&this->unk_350[idx]); + Matrix_GetStateTranslation(&this->limbPos[idx]); if ((idx == 3) || (idx == 5)) { - Matrix_GetStateTranslationAndScaledX(2000.0f, &this->unk_350[idx + 1]); + Matrix_GetStateTranslationAndScaledX(2000.0f, &this->limbPos[idx + 1]); } } } @@ -1151,7 +1150,7 @@ void EnThiefbird_Draw(Actor* thisx, GlobalContext* globalCtx) { func_800AE5A0(globalCtx); } func_80C13354(this, globalCtx); - func_800BE680(globalCtx, &this->actor, this->unk_350, 11, this->unk_3D8, this->unk_3DC, this->unk_3D4, - this->unk_18C); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, + this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, this->drawDmgEffType); Math_Vec3s_ToVec3f(&this->actor.focus.pos, &this->collider.elements[1].dim.worldSphere.center); } diff --git a/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.h b/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.h index 5581f11558..990b4b2c56 100644 --- a/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.h +++ b/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.h @@ -21,7 +21,7 @@ typedef struct EnThiefbird { /* 0x0000 */ Actor actor; /* 0x0144 */ SkelAnime skelAnime; /* 0x0188 */ EnThiefbirdActionFunc actionFunc; - /* 0x018C */ u8 unk_18C; + /* 0x018C */ u8 drawDmgEffType; /* 0x018E */ s16 unk_18E; /* 0x0190 */ s16 unk_190; /* 0x0192 */ s16 unk_192; @@ -31,10 +31,10 @@ typedef struct EnThiefbird { /* 0x0208 */ Vec3s morphTable[17]; /* 0x0270 */ ColliderJntSph collider; /* 0x0290 */ ColliderJntSphElement colliderElements[3]; - /* 0x0350 */ Vec3f unk_350[11]; - /* 0x03D4 */ f32 unk_3D4; - /* 0x03D8 */ f32 unk_3D8; - /* 0x03DC */ f32 unk_3DC; + /* 0x0350 */ Vec3f limbPos[11]; + /* 0x03D4 */ f32 drawDmgEffAlpha; + /* 0x03D8 */ f32 drawDmgEffScale; + /* 0x03DC */ f32 drawDmgEffFrozenSteamScale; /* 0x03E0 */ f32 unk_3E0; /* 0x03E4 */ Gfx* unk_3E4; /* 0x03E8 */ Gfx* unk_3E8; diff --git a/src/overlays/actors/ovl_En_Tite/z_en_tite.c b/src/overlays/actors/ovl_En_Tite/z_en_tite.c index 3665cdfde8..7839e45859 100644 --- a/src/overlays/actors/ovl_En_Tite/z_en_tite.c +++ b/src/overlays/actors/ovl_En_Tite/z_en_tite.c @@ -242,15 +242,15 @@ void func_80893BCC(EnTite* this, GlobalContext* globalCtx) { u32 surface = func_800C9BB8(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId); if ((surface == COLPOLY_SURFACE_GROUND) || (surface == COLPOLY_SURFACE_SAND)) { - for (i = 5; i < ARRAY_COUNT(this->unk_2D0); i++) { - func_800BBFB0(globalCtx, &this->unk_2D0[i], 1.0f, 2, 80, 15, 1); + for (i = 5; i < ARRAY_COUNT(this->limbPos); i++) { + func_800BBFB0(globalCtx, &this->limbPos[i], 1.0f, 2, 80, 15, 1); } } else if (surface == COLPOLY_SURFACE_SNOW) { Vec3f* ptr; - for (i = 5; i < ARRAY_COUNT(this->unk_2D0); i++) { + for (i = 5; i < ARRAY_COUNT(this->limbPos); i++) { for (j = 0; j < 2; j++) { - ptr = &this->unk_2D0[i]; + ptr = &this->limbPos[i]; sp7C.x = ptr->x + randPlusMinusPoint5Scaled(1.0f); sp7C.y = ptr->y + randPlusMinusPoint5Scaled(1.0f); sp7C.z = ptr->z + randPlusMinusPoint5Scaled(1.0f); @@ -264,22 +264,22 @@ void func_80893BCC(EnTite* this, GlobalContext* globalCtx) { } void func_80893DD4(EnTite* this) { - this->unk_2BB = 10; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; this->collider.base.colType = COLTYPE_HIT3; this->unk_2BC = 80; - this->unk_2C8 = 0.5f; - this->unk_2CC = 0.75f; - this->unk_2C4 = 1.0f; + this->drawDmgEffScale = 0.5f; + this->drawDmgEffFrozenSteamScale = 0.75f; + this->drawDmgEffAlpha = 1.0f; Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); this->actor.flags &= ~ACTOR_FLAG_200; } void func_80893E54(EnTite* this, GlobalContext* globalCtx) { - if (this->unk_2BB == 10) { - this->unk_2BB = 0; + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->collider.base.colType = COLTYPE_HIT6; - this->unk_2C4 = 0.0f; - Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_2D0, 9, 2, 0.2f, 0.2f); + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, 9, 2, 0.2f, 0.2f); this->actor.flags |= ACTOR_FLAG_200; } } @@ -643,8 +643,8 @@ void func_80895020(EnTite* this, GlobalContext* globalCtx) { this->actor.speedXZ = 0.0f; ptr = &this->unk_33C[0]; - for (i = 0; i < ARRAY_COUNT(this->unk_2D0); i++, ptr++) { - Math_Vec3f_Diff(&this->unk_2D0[i], &this->actor.world.pos, &sp74); + for (i = 0; i < ARRAY_COUNT(this->limbPos); i++, ptr++) { + Math_Vec3f_Diff(&this->limbPos[i], &this->actor.world.pos, &sp74); temp_f0 = Math3D_Vec3fMagnitude(&sp74); if (temp_f0 > 1.0f) { temp_f0 = 1.2f / temp_f0; @@ -664,14 +664,14 @@ void func_808951B8(EnTite* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.world.rot.z, 0x4000, 4, 0x1000, 0x400); if (this->unk_2BC == 0) { - for (i = 0; i < ARRAY_COUNT(this->unk_2D0); i++) { - func_800B3030(globalCtx, &this->unk_2D0[i], &gZeroVec3f, &gZeroVec3f, 40, 7, 1); - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->unk_2D0[i], 11, NA_SE_EN_EXTINCT); + for (i = 0; i < ARRAY_COUNT(this->limbPos); i++) { + func_800B3030(globalCtx, &this->limbPos[i], &gZeroVec3f, &gZeroVec3f, 40, 7, 1); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->limbPos[i], 11, NA_SE_EN_EXTINCT); } Actor_MarkForDeath(&this->actor); } else { for (i = 0; i < ARRAY_COUNT(this->unk_33C); i++) { - Math_Vec3f_Sum(&this->unk_2D0[i], &this->unk_33C[i], &this->unk_2D0[i]); + Math_Vec3f_Sum(&this->limbPos[i], &this->unk_33C[i], &this->limbPos[i]); this->unk_33C[i].y += this->actor.gravity; } } @@ -940,7 +940,8 @@ void func_80895FF8(EnTite* this, GlobalContext* globalCtx) { Actor_SetDropFlag(&this->actor, &this->collider.info); - if ((this->unk_2BB != 10) || !(this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { + if ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || + !(this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { func_80893E54(this, globalCtx); if (this->actor.shape.yOffset < 0.0f) { func_80895DE8(this); @@ -956,9 +957,9 @@ void func_80895FF8(EnTite* this, GlobalContext* globalCtx) { this->unk_2BC = 40; Actor_SetColorFilter(&this->actor, 0, 200, 0, 40); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); - this->unk_2BB = 32; - this->unk_2C8 = 0.5f; - this->unk_2C4 = 2.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_LARGE; + this->drawDmgEffScale = 0.5f; + this->drawDmgEffAlpha = 2.0f; func_80894DD0(this); return; } @@ -982,13 +983,13 @@ void func_80895FF8(EnTite* this, GlobalContext* globalCtx) { } if (this->actor.colChkInfo.damageEffect == 2) { - this->unk_2BB = 0; - this->unk_2C4 = 4.0f; - this->unk_2C8 = 0.5f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.5f; } else if (this->actor.colChkInfo.damageEffect == 4) { - this->unk_2BB = 0x14; - this->unk_2C4 = 4.0f; - this->unk_2C8 = 0.5f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.5f; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->collider.info.bumper.hitPos.x, this->collider.info.bumper.hitPos.y, this->collider.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); @@ -1031,8 +1032,8 @@ void func_808963B4(EnTite* this, GlobalContext* globalCtx) { Vec3f sp48; if (this->actor.bgCheckFlags & 0x40) { - for (i = 5; i < ARRAY_COUNT(this->unk_2D0); i++) { - Math_Vec3f_Copy(&sp48, &this->unk_2D0[i]); + for (i = 5; i < ARRAY_COUNT(this->limbPos); i++) { + Math_Vec3f_Copy(&sp48, &this->limbPos[i]); sp48.y = this->actor.world.pos.y + this->actor.depthInWater; EffectSsGRipple_Spawn(globalCtx, &sp48, 0, 220, 0); } @@ -1040,7 +1041,7 @@ void func_808963B4(EnTite* this, GlobalContext* globalCtx) { s32 temp = globalCtx->gameplayFrames & 7; if (!(temp & 1) && (this->actor.depthInWater < 10.0f)) { - Math_Vec3f_Copy(&sp48, &this->unk_2D0[5 + (temp >> 1)]); + Math_Vec3f_Copy(&sp48, &this->limbPos[5 + (temp >> 1)]); sp48.y = this->actor.world.pos.y + this->actor.depthInWater; EffectSsGRipple_Spawn(globalCtx, &sp48, 0, 220, 0); } @@ -1083,12 +1084,12 @@ void EnTite_Update(Actor* thisx, GlobalContext* globalCtx) { } CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - if (this->unk_2C4 > 0.0f) { - if (this->unk_2BB != 10) { - Math_StepToF(&this->unk_2C4, 0.0f, 0.05f); - this->unk_2C8 = (this->unk_2C4 + 1.0f) * 0.25f; - this->unk_2C8 = CLAMP_MAX(this->unk_2C8, 0.5f); - } else if (!Math_StepToF(&this->unk_2CC, 0.5f, 0.0125f)) { + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.25f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 0.5f); + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.5f, 0.0125f)) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } @@ -1120,14 +1121,14 @@ void EnTite_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, V if (this->unk_2BA == 0) { idx = D_80896B70[limbIndex]; if (idx != -1) { - Matrix_GetStateTranslation(&this->unk_2D0[idx]); + Matrix_GetStateTranslation(&this->limbPos[idx]); if (idx >= 1) { - Matrix_GetStateTranslationAndScaledX(2500.0f, &this->unk_2D0[idx + 4]); + Matrix_GetStateTranslationAndScaledX(2500.0f, &this->limbPos[idx + 4]); } } } else if (this->unk_2BA > 0) { if (D_80896B8C[limbIndex] != -1) { - Matrix_GetStateTranslation(&this->unk_2D0[D_80896B8C[limbIndex]]); + Matrix_GetStateTranslation(&this->limbPos[D_80896B8C[limbIndex]]); } if (limbIndex == 24) { @@ -1137,9 +1138,9 @@ void EnTite_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, V OPEN_DISPS(globalCtx->state.gfxCtx); matrix = Matrix_GetCurrentState(); - matrix->wx = this->unk_2D0[D_80896B8C[limbIndex]].x; - matrix->wy = this->unk_2D0[D_80896B8C[limbIndex]].y; - matrix->wz = this->unk_2D0[D_80896B8C[limbIndex]].z; + matrix->wx = this->limbPos[D_80896B8C[limbIndex]].x; + matrix->wy = this->limbPos[D_80896B8C[limbIndex]].y; + matrix->wz = this->limbPos[D_80896B8C[limbIndex]].z; Matrix_InsertZRotation_s(this->actor.world.rot.z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -1172,8 +1173,8 @@ void EnTite_Draw(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnTite_OverrideLimbDraw, EnTite_PostLimbDraw, &this->actor); - func_800BE680(globalCtx, &this->actor, this->unk_2D0, ARRAY_COUNT(this->unk_2D0), this->unk_2C8, this->unk_2CC, - this->unk_2C4, this->unk_2BB); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, + this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, this->drawDmgEffType); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Tite/z_en_tite.h b/src/overlays/actors/ovl_En_Tite/z_en_tite.h index 91bbfc7c2d..24f3bd6308 100644 --- a/src/overlays/actors/ovl_En_Tite/z_en_tite.h +++ b/src/overlays/actors/ovl_En_Tite/z_en_tite.h @@ -24,14 +24,14 @@ typedef struct EnTite { /* 0x02B8 */ u8 unk_2B8; /* 0x02B9 */ u8 unk_2B9; /* 0x02BA */ s8 unk_2BA; - /* 0x02BB */ u8 unk_2BB; + /* 0x02BB */ u8 drawDmgEffType; /* 0x02BC */ s16 unk_2BC; /* 0x02BE */ s16 unk_2BE; /* 0x02C0 */ s32 unk_2C0; - /* 0x02C4 */ f32 unk_2C4; - /* 0x02C8 */ f32 unk_2C8; - /* 0x02CC */ f32 unk_2CC; - /* 0x02D0 */ Vec3f unk_2D0[9]; + /* 0x02C4 */ f32 drawDmgEffAlpha; + /* 0x02C8 */ f32 drawDmgEffScale; + /* 0x02CC */ f32 drawDmgEffFrozenSteamScale; + /* 0x02D0 */ Vec3f limbPos[9]; /* 0x033C */ Vec3f unk_33C[9]; /* 0x03A8 */ Gfx* unk_3A8; /* 0x03AC */ ColliderSphere collider; diff --git a/src/overlays/actors/ovl_En_Tk/z_en_tk.c b/src/overlays/actors/ovl_En_Tk/z_en_tk.c index 32e4c9c814..d239a6cb70 100644 --- a/src/overlays/actors/ovl_En_Tk/z_en_tk.c +++ b/src/overlays/actors/ovl_En_Tk/z_en_tk.c @@ -24,8 +24,8 @@ void func_80AECB0C(EnTk* this, GlobalContext* globalCtx); void func_80AECB6C(EnTk* this, GlobalContext* globalCtx); void func_80AECE0C(EnTk* this, GlobalContext* globalCtx); s32 func_80AECE60(EnTk* this, GlobalContext* globalCtx); -s32 func_80AED354(EnTk* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2); -s32 func_80AED38C(EnTk* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2); +s32 func_80AED354(EnTk* this, GlobalContext* globalCtx, ScheduleResult* arg2); +s32 func_80AED38C(EnTk* this, GlobalContext* globalCtx, ScheduleResult* arg2); void func_80AED4F8(EnTk* this, GlobalContext* globalCtx); void func_80AED610(EnTk* this, GlobalContext* globalCtx); void func_80AED898(EnTk* this, GlobalContext* globalCtx); @@ -62,11 +62,11 @@ void func_80AEF5F4(Actor* thisx, GlobalContext* globalCtx); static s32 D_80AF0050; -static u32 D_80AEF800[] = { - 0x03060012, - 0x00000105, - 0x0E060012, - 0x00010500, +static u8 D_80AEF800[] = { + /* 0x0 */ SCHEDULE_CMD_CHECK_TIME_RANGE_L(6, 0, 18, 0, 0x8 - 0x7), + /* 0x7 */ SCHEDULE_CMD_RET_NONE(), + /* 0x8 */ SCHEDULE_CMD_RET_TIME(6, 0, 18, 0, 1), + /* 0xE */ SCHEDULE_CMD_RET_NONE(), }; const ActorInit En_Tk_InitVars = { @@ -313,8 +313,8 @@ void func_80AECB6C(EnTk* this, GlobalContext* globalCtx) { s32 temp3; f32 sp48; f32 sp44; + ScheduleResult sp34; u8 temp4; - struct_80133038_arg2 sp34; this->actor.textId = 0; if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { @@ -347,14 +347,14 @@ void func_80AECB6C(EnTk* this, GlobalContext* globalCtx) { this->unk_2DC -= temp3; this->unk_2E0 += REG(15); - if (func_80133038(globalCtx, (UNK_TYPE*)D_80AEF800, &sp34)) { - if ((this->unk_3CC != sp34.unk0) && !func_80AED354(this, globalCtx, &sp34)) { + if (Schedule_RunScript(globalCtx, D_80AEF800, &sp34)) { + if ((this->unk_3CC != sp34.result) && !func_80AED354(this, globalCtx, &sp34)) { return; } - temp4 = sp34.unk0; + temp4 = sp34.result; } else { - sp34.unk0 = 0; - temp4 = sp34.unk0; + sp34.result = 0; + temp4 = sp34.result; } if (!temp4 && (this->unk_3CC != 0)) { @@ -365,7 +365,7 @@ void func_80AECB6C(EnTk* this, GlobalContext* globalCtx) { this->actor.draw = EnTk_Draw; } - this->unk_3CC = sp34.unk0; + this->unk_3CC = sp34.result; func_80AECE0C(this, globalCtx); if (this->unk_3CE & 8) { @@ -486,28 +486,28 @@ s32 func_80AECE60(EnTk* this, GlobalContext* globalCtx) { } if (!(this->unk_3CE & 8) && !(this->unk_2CA & 0x10) && (this->actor.xzDistToPlayer < 100.0f)) { - func_8013E8F8(&this->actor, globalCtx, 100.0f, 100.0f, 0, 0x4000, 0x4000); + func_8013E8F8(&this->actor, globalCtx, 100.0f, 100.0f, EXCH_ITEM_NONE, 0x4000, 0x4000); } return false; } -s32 func_80AED354(EnTk* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80AED354(EnTk* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 phi_v1 = false; - if (arg2->unk0 != 0) { + if (arg2->result != 0) { phi_v1 = func_80AED38C(this, globalCtx, arg2); } return phi_v1; } -s32 func_80AED38C(EnTk* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { - u16 sp1E = gSaveContext.time - 0x3FFC; +s32 func_80AED38C(EnTk* this, GlobalContext* globalCtx, ScheduleResult* arg2) { + u16 sp1E = SCHEDULE_TIME_NOW; u8 params = ENTK_GET_F800(&this->actor); u16 phi_a1; - s32 idx = arg2->unk0 - 1; + s32 idx = arg2->result - 1; - this->unk_3C8 = func_8013BB34(globalCtx, params, D_80AEF8E8[idx + 1]); + this->unk_3C8 = SubS_GetAdditionalPath(globalCtx, params, D_80AEF8E8[idx + 1]); if (this->unk_3C8 == 0) { return false; } @@ -515,10 +515,10 @@ s32 func_80AED38C(EnTk* this, GlobalContext* globalCtx, struct_80133038_arg2* ar if ((this->unk_3CC <= 0) && (this->unk_3CC != 0) && (this->unk_3D0 >= 0)) { phi_a1 = sp1E; } else { - phi_a1 = arg2->unk4; + phi_a1 = arg2->time0; } - this->unk_3E4 = arg2->unk8 - phi_a1; + this->unk_3E4 = arg2->time1 - phi_a1; this->unk_3F0 = sp1E - phi_a1; phi_a1 = this->unk_3C8->count - 2; this->unk_3E8 = this->unk_3E4 / phi_a1; @@ -534,14 +534,14 @@ void func_80AED4F8(EnTk* this, GlobalContext* globalCtx) { } void func_80AED544(EnTk* this, GlobalContext* globalCtx) { - if (!(gSaveContext.weekEventReg[31] & 0x10)) { + if (!(gSaveContext.save.weekEventReg[31] & 0x10)) { Message_StartTextbox(globalCtx, 0x13FE, &this->actor); - gSaveContext.weekEventReg[31] |= 0x10; - } else if (gSaveContext.time < CLOCK_TIME(9, 0)) { + gSaveContext.save.weekEventReg[31] |= 0x10; + } else if (gSaveContext.save.time < CLOCK_TIME(9, 0)) { Message_StartTextbox(globalCtx, 0x13FF, &this->actor); - } else if (gSaveContext.time < CLOCK_TIME(12, 0)) { + } else if (gSaveContext.save.time < CLOCK_TIME(12, 0)) { Message_StartTextbox(globalCtx, 0x1400, &this->actor); - } else if (gSaveContext.time < CLOCK_TIME(15, 0)) { + } else if (gSaveContext.save.time < CLOCK_TIME(15, 0)) { Message_StartTextbox(globalCtx, 0x1401, &this->actor); } else { Message_StartTextbox(globalCtx, 0x1402, &this->actor); @@ -563,7 +563,7 @@ void func_80AED610(EnTk* this, GlobalContext* globalCtx) { func_80AED544(this, globalCtx); } else if (!Flags_GetSwitch(globalCtx, ENTK_GET_7F0(&this->actor))) { Message_StartTextbox(globalCtx, 0x1403, &this->actor); - } else if (gSaveContext.weekEventReg[60] & 2) { + } else if (gSaveContext.save.weekEventReg[60] & 2) { func_80AED544(this, globalCtx); } else { Message_StartTextbox(globalCtx, 0x1413, &this->actor); @@ -579,8 +579,8 @@ void func_80AED610(EnTk* this, GlobalContext* globalCtx) { case 4: case 5: case 6: - if (func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x13FD: this->unk_2CA |= 0x10; SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 0, &this->unk_2D4); @@ -594,7 +594,7 @@ void func_80AED610(EnTk* this, GlobalContext* globalCtx) { case 0x1413: func_801159EC(30); - gSaveContext.weekEventReg[60] |= 2; + gSaveContext.save.weekEventReg[60] |= 2; func_80151938(globalCtx, 0x13FF); break; @@ -695,7 +695,7 @@ void func_80AED940(EnTk* this, GlobalContext* globalCtx) { func_80AEDE10(this, globalCtx); } else if (!(this->unk_2CA & 0x80)) { if (this->actor.xzDistToPlayer < 100.0f) { - func_8013E8F8(&this->actor, globalCtx, 100.0f, 100.0f, 0, 0x4000, 0x4000); + func_8013E8F8(&this->actor, globalCtx, 100.0f, 100.0f, EXCH_ITEM_NONE, 0x4000, 0x4000); } } else { func_800B8500(&this->actor, globalCtx, this->actor.xzDistToPlayer, this->actor.playerHeightRel, 0); @@ -757,7 +757,7 @@ void func_80AEDE10(EnTk* this, GlobalContext* globalCtx) { switch (this->unk_310) { case 0: this->unk_2CA &= ~0x1000; - if (!(gSaveContext.weekEventReg[52] & 0x80)) { + if (!(gSaveContext.save.weekEventReg[52] & 0x80)) { this->unk_2E6 = 0x1405; } else { this->unk_2E6 = 0x140B; @@ -828,8 +828,8 @@ void func_80AEDF5C(EnTk* this, GlobalContext* globalCtx) { case 4: case 5: case 6: - if (func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x1404: this->unk_2CA |= 0x1000; func_80AED898(this, globalCtx); @@ -862,7 +862,7 @@ void func_80AEDF5C(EnTk* this, GlobalContext* globalCtx) { break; case 0x140A: - gSaveContext.weekEventReg[52] |= 0x80; + gSaveContext.save.weekEventReg[52] |= 0x80; case 0x140B: func_80AEE784(this, globalCtx); @@ -1043,7 +1043,7 @@ s32 func_80AEE86C(EnTk* this, GlobalContext* globalCtx) { (this->actor.xyzDistToPlayerSq <= SQ(115.0f)) && func_80AEE7E0(&this->actor.world.pos, 100.0f, this->unk_324, this->unk_36C) && (((this->unk_2CA & 2) && (Math_Vec3f_DistXZ(&this->unk_300, &sp28) >= 100.0f)) || !(this->unk_2CA & 2)) && - !func_801690CC(globalCtx)) { + !Play_InCsMode(globalCtx)) { Math_Vec3f_Copy(&this->unk_300, &sp28); ret = true; } @@ -1189,7 +1189,7 @@ void func_80AEED38(EnTk* this, GlobalContext* globalCtx) { this->actor.shape.rot.y = this->actor.world.rot.y; } - if (Message_GetState(&globalCtx->msgCtx) == 0 && !func_801690CC(globalCtx) && (this->unk_2C6-- <= 0)) { + if (Message_GetState(&globalCtx->msgCtx) == 0 && !Play_InCsMode(globalCtx) && (this->unk_2C6-- <= 0)) { Message_StartTextbox(globalCtx, 0x140C, NULL); this->unk_2CA |= 0x4000; this->unk_2C6 = 200; diff --git a/src/overlays/actors/ovl_En_Torch/z_en_torch.c b/src/overlays/actors/ovl_En_Torch/z_en_torch.c index b5c891af0a..fc06cff18c 100644 --- a/src/overlays/actors/ovl_En_Torch/z_en_torch.c +++ b/src/overlays/actors/ovl_En_Torch/z_en_torch.c @@ -21,7 +21,7 @@ static u8 sChestContents[] = { 0x02, 0x04, 0x05, 0x06, 0x36, 0x3A, 0x14, 0x14 }; void EnTorch_Init(Actor* thisx, GlobalContext* globalCtx) { EnTorch* this = THIS; - s8 returnData = gSaveContext.respawn[3].data; + s8 returnData = gSaveContext.respawn[RESPAWN_MODE_UNK_3].data; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOX, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, this->actor.shape.rot.y, 0, diff --git a/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c b/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c index 3789bb99ab..c6931fac5c 100644 --- a/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c +++ b/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c @@ -87,8 +87,8 @@ void EnTorch2_Destroy(Actor* thisx, GlobalContext* globalCtx) { EnTorch2* this = THIS; Collider_DestroyCylinder(globalCtx, &this->collider); - Play_SetRespawnData(&globalCtx->state, this->actor.params + 3, 0xFF, 0, 0xBFF, &this->actor.world.pos, - this->actor.shape.rot.y); + Play_SetRespawnData(&globalCtx->state, this->actor.params + RESPAWN_MODE_GORON - 1, 0xFF, 0, 0xBFF, + &this->actor.world.pos, this->actor.shape.rot.y); globalCtx->actorCtx.unk254[this->actor.params] = 0; } diff --git a/src/overlays/actors/ovl_En_Toto/z_en_toto.c b/src/overlays/actors/ovl_En_Toto/z_en_toto.c index 9334180cdb..f12baac71c 100644 --- a/src/overlays/actors/ovl_En_Toto/z_en_toto.c +++ b/src/overlays/actors/ovl_En_Toto/z_en_toto.c @@ -11,7 +11,7 @@ #define THIS ((EnToto*)thisx) -#define ENTOTO_WEEK_EVENT_FLAGS (gSaveContext.weekEventReg[50] & 1 || gSaveContext.weekEventReg[51] & 0x80) +#define ENTOTO_WEEK_EVENT_FLAGS (gSaveContext.save.weekEventReg[50] & 1 || gSaveContext.save.weekEventReg[51] & 0x80) void EnToto_Init(Actor* thisx, GlobalContext* globalCtx); void EnToto_Destroy(Actor* thisx, GlobalContext* globalCtx); @@ -185,7 +185,7 @@ void EnToto_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->actor, sInitChain); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); if (globalCtx->sceneNum == SCENE_MILK_BAR && - (gSaveContext.time >= CLOCK_TIME(6, 0) && gSaveContext.time < CLOCK_TIME(21, 30))) { + (gSaveContext.save.time >= CLOCK_TIME(6, 0) && gSaveContext.save.time < CLOCK_TIME(21, 30))) { Actor_MarkForDeath(&this->actor); return; } @@ -207,7 +207,7 @@ void EnToto_Destroy(Actor* thisx, GlobalContext* globalCtx) { void func_80BA383C(EnToto* this, GlobalContext* globalCtx) { if (SkelAnime_Update(&this->skelAnime) && this->actionFuncIndex == 1 && this->skelAnime.animation != &object_zm_Anim_000C80) { - if (globalCtx->msgCtx.unk11F04 != 0x2A98 && globalCtx->msgCtx.unk11F04 != 0x2A99) { + if (globalCtx->msgCtx.currentTextId != 0x2A98 && globalCtx->msgCtx.currentTextId != 0x2A99) { if (this->unk2B4 & 1 || Rand_ZeroOne() > 0.5f) { this->unk2B4 = (this->unk2B4 + 1) & 3; } @@ -253,7 +253,7 @@ void func_80BA39C8(EnToto* this, GlobalContext* globalCtx) { //! @TODO: 0xED02 nor 0xED01 match CLOCK_TIME macro if ((globalCtx->sceneNum == SCENE_MILK_BAR && - !(gSaveContext.time >= CLOCK_TIME(6, 0) && gSaveContext.time < 0xED02)) || + !(gSaveContext.save.time >= CLOCK_TIME(6, 0) && gSaveContext.save.time < 0xED02)) || (globalCtx->sceneNum != SCENE_MILK_BAR && func_80BA397C(this, 0x2000))) { if (this->unk2B6 != 0) { this->text = D_80BA5044; @@ -408,7 +408,7 @@ s32 func_80BA407C(EnToto* this, GlobalContext* globalCtx) { } s32 func_80BA40D4(EnToto* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { return 1; } return 0; @@ -422,7 +422,7 @@ s32 func_80BA4128(EnToto* this, GlobalContext* globalCtx) { } s32 func_80BA415C(EnToto* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 4 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 4 && Message_ShouldAdvance(globalCtx)) { if (globalCtx->msgCtx.choiceIndex != 0) { func_8019F230(); } else { @@ -438,7 +438,7 @@ s32 func_80BA4204(EnToto* this, GlobalContext* globalCtx) { if (DECR(this->unk2B1) == 0) { if (!ENTOTO_WEEK_EVENT_FLAGS) { - temp_v1_2 = &D_80BA50DC[gSaveContext.playerForm - 1]; + temp_v1_2 = &D_80BA50DC[gSaveContext.save.playerForm - 1]; Message_StartTextbox(globalCtx, (this->text->unk0 == 6) ? temp_v1_2->unk0 : temp_v1_2->unk4, NULL); } return 1; @@ -516,7 +516,7 @@ s32 func_80BA4530(EnToto* this, GlobalContext* globalCtx) { return this->text->unk1; } if (player->actor.bgCheckFlags & 1) { - temp_s0 = &D_80BA50DC[gSaveContext.playerForm - 1]; + temp_s0 = &D_80BA50DC[gSaveContext.save.playerForm - 1]; if (func_80BA44D4(temp_s0, player)) { Math_Vec3s_ToVec3f(&player->actor.world.pos, &temp_s0->unk6); player->actor.shape.rot.y = 0; @@ -529,8 +529,8 @@ s32 func_80BA4530(EnToto* this, GlobalContext* globalCtx) { if (this->unk2B1 < 10) { this->unk2B1++; if (this->unk2B1 >= 10) { - Message_StartTextbox(globalCtx, D_80BA50DC[((void)0, gSaveContext.playerForm) - 1].unk2, - NULL); + Message_StartTextbox(globalCtx, + D_80BA50DC[((void)0, gSaveContext.save.playerForm) - 1].unk2, NULL); } } return 0; @@ -550,17 +550,17 @@ s32 func_80BA46D8(EnToto* this, GlobalContext* globalCtx) { s32 func_80BA4740(EnToto* this, GlobalContext* globalCtx) { if (globalCtx->msgCtx.ocarinaMode == 4) { - if (gSaveContext.playerForm == PLAYER_FORM_HUMAN) { - gSaveContext.weekEventReg[56] |= 0x10; + if (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { + gSaveContext.save.weekEventReg[56] |= 0x10; } - if (gSaveContext.playerForm == PLAYER_FORM_DEKU) { - gSaveContext.weekEventReg[56] |= 0x20; + if (gSaveContext.save.playerForm == PLAYER_FORM_DEKU) { + gSaveContext.save.weekEventReg[56] |= 0x20; } - if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { - gSaveContext.weekEventReg[56] |= 0x40; + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { + gSaveContext.save.weekEventReg[56] |= 0x40; } - if (gSaveContext.playerForm == PLAYER_FORM_GORON) { - gSaveContext.weekEventReg[56] |= 0x80; + if (gSaveContext.save.playerForm == PLAYER_FORM_GORON) { + gSaveContext.save.weekEventReg[56] |= 0x80; } return 1; } @@ -572,20 +572,20 @@ s32 func_80BA47E0(EnToto* this, GlobalContext* globalCtx) { s32 i; this->unk2B3 = 0; - if (gSaveContext.weekEventReg[56] & 0x10) { + if (gSaveContext.save.weekEventReg[56] & 0x10) { this->unk2B3 += 1; } - if (gSaveContext.weekEventReg[56] & 0x20) { + if (gSaveContext.save.weekEventReg[56] & 0x20) { this->unk2B3 += 2; } - if (gSaveContext.weekEventReg[56] & 0x40) { + if (gSaveContext.save.weekEventReg[56] & 0x40) { this->unk2B3 += 4; } - if (gSaveContext.weekEventReg[56] & 0x80) { + if (gSaveContext.save.weekEventReg[56] & 0x80) { this->unk2B3 += 8; } for (i = 0; i < 4; i++) { - if (gSaveContext.playerForm != (i + 1) && (D_80BA5128[i] & this->unk2B3)) { + if (gSaveContext.save.playerForm != (i + 1) && (D_80BA5128[i] & this->unk2B3)) { Math_Vec3s_ToVec3f(&spawnPos, &D_80BA50DC[i].unk6); Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_PLAYER, spawnPos.x, spawnPos.y, spawnPos.z, i + 2, 0, 0, -1); @@ -622,9 +622,9 @@ s32 func_80BA4A00(EnToto* this, GlobalContext* globalCtx) { func_800B7298(globalCtx, NULL, 0x45); if (this->unk2B3 == 0xF) { if (CURRENT_DAY == 1) { - gSaveContext.weekEventReg[50] |= 1; + gSaveContext.save.weekEventReg[50] |= 1; } else { - gSaveContext.weekEventReg[51] |= 0x80; + gSaveContext.save.weekEventReg[51] |= 0x80; } } else { func_80BA402C(this, globalCtx); diff --git a/src/overlays/actors/ovl_En_Trt/z_en_trt.c b/src/overlays/actors/ovl_En_Trt/z_en_trt.c index 075d42337d..dde803708f 100644 --- a/src/overlays/actors/ovl_En_Trt/z_en_trt.c +++ b/src/overlays/actors/ovl_En_Trt/z_en_trt.c @@ -22,11 +22,11 @@ void EnTrt_Update(Actor* thisx, GlobalContext* globalCtx); void EnTrt_Draw(Actor* thisx, GlobalContext* globalCtx); void EnTrt_GetCutscenes(EnTrt* this, GlobalContext* globalCtx); -s32 EnTrt_ReturnItemToShelf(EnTrt* this); void EnTrt_ResetItemPosition(EnTrt* this); +void EnTrt_UpdateHeadYawAndPitch(EnTrt* this, GlobalContext* globalCtx); +s32 EnTrt_ReturnItemToShelf(EnTrt* this); s32 EnTrt_FacingShopkeeperDialogResult(EnTrt* this, GlobalContext* globalCtx); s32 EnTrt_TakeItemOffShelf(EnTrt* this); -void EnTrt_UpdateHeadYawAndPitch(EnTrt* this, GlobalContext* globalCtx); void EnTrt_BeginInteraction(EnTrt* this, GlobalContext* globalCtx); void EnTrt_IdleSleeping(EnTrt* this, GlobalContext* globalCtx); @@ -189,7 +189,7 @@ u16 EnTrt_GetItemTextId(EnTrt* this) { u16 EnTrt_GetItemChoiceTextId(EnTrt* this) { EnGirlA* item = this->items[this->cursorIdx]; - if (item->actor.params == SI_POTION_BLUE && !(gSaveContext.weekEventReg[53] & 0x10)) { + if (item->actor.params == SI_POTION_BLUE && !(gSaveContext.save.weekEventReg[53] & 0x10)) { this->textId = 0x881; return 0x881; } @@ -312,7 +312,7 @@ void EnTrt_Hello(EnTrt* this, GlobalContext* globalCtx) { ActorCutscene_SetIntentToPlay(this->cutscene); } } - if (talkState == 5 && func_80147624(globalCtx)) { + if (talkState == 5 && Message_ShouldAdvance(globalCtx)) { play_sound(NA_SE_SY_MESSAGE_PASS); if (!EnTrt_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx))) { EnTrt_StartShopping(globalCtx, this); @@ -330,12 +330,12 @@ void EnTrt_GetMushroom(EnTrt* this, GlobalContext* globalCtx) { if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING_SPECIAL) { player->stateFlags2 &= ~0x20000000; } - } else if (talkState == 5 && func_80147624(globalCtx)) { + } else if (talkState == 5 && Message_ShouldAdvance(globalCtx)) { switch (this->textId) { case 0x883: this->textId = 0x884; Message_StartTextbox(globalCtx, this->textId, &this->actor); - gSaveContext.weekEventReg[53] |= 8; + gSaveContext.save.weekEventReg[53] |= 8; func_80123D50(globalCtx, GET_PLAYER(globalCtx), ITEM_BOTTLE, PLAYER_AP_BOTTLE); break; case 0x888: @@ -370,7 +370,7 @@ void EnTrt_PayForMushroom(EnTrt* this, GlobalContext* globalCtx) { } void EnTrt_Goodbye(EnTrt* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { switch (this->textId) { case 0x886: this->textId = 0x887; @@ -385,9 +385,9 @@ void EnTrt_Goodbye(EnTrt* this, GlobalContext* globalCtx) { } void EnTrt_SetupTryToGiveRedPotion(EnTrt* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { if (this->textId == 0x88F) { - if (Interface_HasEmptyBottle() || !(gSaveContext.weekEventReg[12] & 0x10)) { + if (Interface_HasEmptyBottle() || !(gSaveContext.save.weekEventReg[12] & 0x10)) { if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); this->cutsceneState = ENTRT_CUTSCENESTATE_STOPPED; @@ -398,28 +398,28 @@ void EnTrt_SetupTryToGiveRedPotion(EnTrt* this, GlobalContext* globalCtx) { } else { this->tmpTextId = this->textId; this->textId = 0x88E; - gSaveContext.weekEventReg[85] |= 8; + gSaveContext.save.weekEventReg[85] |= 8; Message_StartTextbox(globalCtx, this->textId, &this->actor); this->actionFunc = EnTrt_EndConversation; } } else { - if (gSaveContext.weekEventReg[12] & 8) { + if (gSaveContext.save.weekEventReg[12] & 8) { this->textId = 0x83D; EnTrt_SetupStartShopping(globalCtx, this, 0); - } else if (gSaveContext.weekEventReg[84] & 0x40) { + } else if (gSaveContext.save.weekEventReg[84] & 0x40) { this->textId = 0x83B; if (Interface_HasItemInBottle(ITEM_POTION_RED)) { EnTrt_SetupStartShopping(globalCtx, this, false); } else { this->actionFunc = EnTrt_TryToGiveRedPotion; } - } else if (gSaveContext.weekEventReg[16] & 0x10) { + } else if (gSaveContext.save.weekEventReg[16] & 0x10) { this->timer = 30; this->textId = 0x838; this->cutsceneState = ENTRT_CUTSCENESTATE_PLAYING_SPECIAL; this->actionFunc = EnTrt_Surprised; return; - } else if (gSaveContext.weekEventReg[17] & 1) { + } else if (gSaveContext.save.weekEventReg[17] & 1) { this->textId = 0x835; EnTrt_SetupStartShopping(globalCtx, this, false); } @@ -433,13 +433,13 @@ void EnTrt_GiveRedPotionForKoume(EnTrt* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { this->actor.parent = NULL; - if (!(gSaveContext.weekEventReg[12] & 0x10)) { - gSaveContext.weekEventReg[12] |= 0x10; + if (!(gSaveContext.save.weekEventReg[12] & 0x10)) { + gSaveContext.save.weekEventReg[12] |= 0x10; } - gSaveContext.weekEventReg[84] |= 0x40; + gSaveContext.save.weekEventReg[84] |= 0x40; player->stateFlags2 &= ~0x20000000; this->actionFunc = EnTrt_GivenRedPotionForKoume; - } else if (gSaveContext.weekEventReg[12] & 0x10) { + } else if (gSaveContext.save.weekEventReg[12] & 0x10) { Actor_PickUp(&this->actor, globalCtx, GI_POTION_RED, 300.0f, 300.0f); } else { Actor_PickUp(&this->actor, globalCtx, GI_BOTTLE_POTION_RED, 300.0f, 300.0f); @@ -450,7 +450,7 @@ void EnTrt_GivenRedPotionForKoume(EnTrt* this, GlobalContext* globalCtx) { //! @bug: player is set to NULL not PLAYER Player* player = NULL; - if (Message_GetState(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 6 && Message_ShouldAdvance(globalCtx)) { if (this->cutsceneState == ENTRT_CUTSCENESTATE_STOPPED) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); @@ -475,11 +475,11 @@ void EnTrt_EndConversation(EnTrt* this, GlobalContext* globalCtx) { u8 talkState = Message_GetState(&globalCtx->msgCtx); if (talkState == 5) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { EnTrt_EndInteraction(globalCtx, this); } } else if (talkState == 6) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { EnTrt_EndInteraction(globalCtx, this); } } @@ -521,7 +521,7 @@ void EnTrt_FaceShopkeeper(EnTrt* this, GlobalContext* globalCtx) { } else if (talkState == 4) { func_8011552C(globalCtx, 6); if (!EnTrt_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx))) { - if ((!func_80147624(globalCtx) || !EnTrt_FacingShopkeeperDialogResult(this, globalCtx)) && + if ((!Message_ShouldAdvance(globalCtx) || !EnTrt_FacingShopkeeperDialogResult(this, globalCtx)) && (this->stickAccumX > 0)) { cursorIdx = EnTrt_SetCursorIndexFromNeutral(this, 2); if (cursorIdx != CURSOR_INVALID) { @@ -707,7 +707,7 @@ void EnTrt_SelectItem(EnTrt* this, GlobalContext* globalCtx) { if (EnTrt_TakeItemOffShelf(this)) { if (talkState == 4) { func_8011552C(globalCtx, 6); - if (!EnTrt_TestCancelOption(this, globalCtx, CONTROLLER1(globalCtx)) && func_80147624(globalCtx)) { + if (!EnTrt_TestCancelOption(this, globalCtx, CONTROLLER1(globalCtx)) && Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: EnTrt_HandleCanBuyItem(globalCtx, this); @@ -719,7 +719,7 @@ void EnTrt_SelectItem(EnTrt* this, GlobalContext* globalCtx) { break; } } - } else if (talkState == 5 && func_80147624(globalCtx)) { + } else if (talkState == 5 && Message_ShouldAdvance(globalCtx)) { if (!Interface_HasEmptyBottle()) { play_sound(NA_SE_SY_ERROR); EnTrt_SetupCannotBuy(globalCtx, this, 0x846); @@ -732,7 +732,7 @@ void EnTrt_SelectItem(EnTrt* this, GlobalContext* globalCtx) { this->drawCursor = 0; this->shopItemSelectedTween = 0.0f; item->boughtFunc(globalCtx, item); - gSaveContext.weekEventReg[53] |= 0x10; + gSaveContext.save.weekEventReg[53] |= 0x10; } } } @@ -741,14 +741,14 @@ void EnTrt_SelectItem(EnTrt* this, GlobalContext* globalCtx) { void EnTrt_IdleSleeping(EnTrt* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if ((gSaveContext.weekEventReg[85] & 8) && !(gSaveContext.weekEventReg[84] & 0x40)) { + if ((gSaveContext.save.weekEventReg[85] & 8) && !(gSaveContext.save.weekEventReg[84] & 0x40)) { this->textId = 0x88F; } else if (!(this->flags & ENTRT_MET)) { this->textId = 0x834; } else { this->textId = 0x83E; } - if (!(gSaveContext.weekEventReg[53] & 8)) { + if (!(gSaveContext.save.weekEventReg[53] & 8)) { this->talkOptionTextId = 0x845; } else if (this->flags & ENTRT_GIVEN_MUSHROOM) { this->talkOptionTextId = 0x882; @@ -786,7 +786,7 @@ void EnTrt_IdleSleeping(EnTrt* this, GlobalContext* globalCtx) { if (DECR(this->timer) == 0) { this->timer = 40; EnTrt_ChangeAnim(&this->skelAnime, sAnimations, 1); - this->animationIdx = 1; + this->animationIndex = 1; this->actionFunc = EnTrt_IdleAwake; this->blinkFunc = EnTrt_OpenThenCloseEyes; } @@ -832,7 +832,7 @@ void EnTrt_IdleAwake(EnTrt* this, GlobalContext* globalCtx) { if (DECR(this->timer) == 0) { this->timer = Rand_S16Offset(150, 100); EnTrt_ChangeAnim(&this->skelAnime, sAnimations, 2); - this->animationIdx = 2; + this->animationIndex = 2; this->sleepSoundTimer = 10; this->actor.textId = 0; this->actionFunc = EnTrt_IdleSleeping; @@ -852,10 +852,10 @@ void EnTrt_BeginInteraction(EnTrt* this, GlobalContext* globalCtx) { ActorCutscene_SetIntentToPlay(this->cutscene); } } else if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING_SPECIAL) { - if (this->animationIdx != 5) { + if (this->animationIndex != 5) { if (curFrame == animLastFrame) { EnTrt_ChangeAnim(&this->skelAnime, sAnimations, 3); - this->animationIdx = 3; + this->animationIndex = 3; this->blinkFunc = EnTrt_OpenEyesThenSetToBlink; this->timer = 10; this->cutsceneState = ENTRT_CUTSCENESTATE_PLAYING; @@ -870,11 +870,11 @@ void EnTrt_BeginInteraction(EnTrt* this, GlobalContext* globalCtx) { this->timer = Rand_S16Offset(40, 20); EnTrt_ChangeAnim(&this->skelAnime, sAnimations, 5); Message_StartTextbox(globalCtx, this->textId, &this->actor); - this->animationIdx = 5; + this->animationIndex = 5; switch (this->textId) { case 0x834: - if (!(gSaveContext.weekEventReg[12] & 8) && !(gSaveContext.weekEventReg[84] & 0x40) && - !(gSaveContext.weekEventReg[16] & 0x10) && !(gSaveContext.weekEventReg[17] & 1)) { + if (!(gSaveContext.save.weekEventReg[12] & 8) && !(gSaveContext.save.weekEventReg[84] & 0x40) && + !(gSaveContext.save.weekEventReg[16] & 0x10) && !(gSaveContext.save.weekEventReg[17] & 1)) { func_8011552C(globalCtx, 6); this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = true; @@ -911,7 +911,7 @@ void EnTrt_Surprised(EnTrt* this, GlobalContext* globalCtx) { } else if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING_SPECIAL) { if (DECR(this->timer) == 0) { EnTrt_ChangeAnim(&this->skelAnime, sAnimations, 4); - this->animationIdx = 4; + this->animationIndex = 4; this->blinkFunc = EnTrt_OpenEyes2; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KOTAKE_SURPRISED); this->timer = 30; @@ -921,7 +921,7 @@ void EnTrt_Surprised(EnTrt* this, GlobalContext* globalCtx) { this->timer = Rand_S16Offset(40, 20); EnTrt_ChangeAnim(&this->skelAnime, sAnimations, 5); Message_StartTextbox(globalCtx, this->textId, &this->actor); - this->animationIdx = 5; + this->animationIndex = 5; this->actionFunc = EnTrt_TryToGiveRedPotionAfterSurprised; } } @@ -930,8 +930,8 @@ void EnTrt_TryToGiveRedPotionAfterSurprised(EnTrt* this, GlobalContext* globalCt u8 talkState = Message_GetState(&globalCtx->msgCtx); this->blinkFunc = EnTrt_Blink; - if (talkState == 6 && func_80147624(globalCtx)) { - if (Interface_HasEmptyBottle() || !(gSaveContext.weekEventReg[12] & 0x10)) { + if (talkState == 6 && Message_ShouldAdvance(globalCtx)) { + if (Interface_HasEmptyBottle() || !(gSaveContext.save.weekEventReg[12] & 0x10)) { if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); this->cutsceneState = ENTRT_CUTSCENESTATE_STOPPED; @@ -940,7 +940,7 @@ void EnTrt_TryToGiveRedPotionAfterSurprised(EnTrt* this, GlobalContext* globalCt } else { this->tmpTextId = this->textId; this->textId = 0x88E; - gSaveContext.weekEventReg[85] |= 8; + gSaveContext.save.weekEventReg[85] |= 8; Message_StartTextbox(globalCtx, this->textId, &this->actor); this->actionFunc = EnTrt_EndConversation; } @@ -948,7 +948,7 @@ void EnTrt_TryToGiveRedPotionAfterSurprised(EnTrt* this, GlobalContext* globalCt } void EnTrt_TryToGiveRedPotion(EnTrt* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { if (this->textId == 0x83C) { if (Interface_HasEmptyBottle()) { if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING) { @@ -961,7 +961,7 @@ void EnTrt_TryToGiveRedPotion(EnTrt* this, GlobalContext* globalCtx) { } else { this->tmpTextId = this->textId; this->textId = 0x88E; - gSaveContext.weekEventReg[85] |= 8; + gSaveContext.save.weekEventReg[85] |= 8; Message_StartTextbox(globalCtx, this->textId, &this->actor); this->actionFunc = EnTrt_EndConversation; } @@ -1015,7 +1015,7 @@ void EnTrt_ItemGiven(EnTrt* this, GlobalContext* globalCtx) { } void EnTrt_SetupEndInteraction(EnTrt* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { EnTrt_EndInteraction(globalCtx, this); } } @@ -1032,8 +1032,8 @@ void EnTrt_ShopkeeperGone(EnTrt* this, GlobalContext* globalCtx) { func_800B8614(&this->actor, globalCtx, 200.0f); } } - if (talkState == 6 && func_80147624(globalCtx)) { - if (gSaveContext.weekEventReg[20] & 2) { + if (talkState == 6 && Message_ShouldAdvance(globalCtx)) { + if (gSaveContext.save.weekEventReg[20] & 2) { globalCtx->nextEntranceIndex = 0xC50; } else { globalCtx->nextEntranceIndex = 0x8450; @@ -1045,7 +1045,7 @@ void EnTrt_ShopkeeperGone(EnTrt* this, GlobalContext* globalCtx) { } void EnTrt_CannotBuy(EnTrt* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { this->actionFunc = this->tmpActionFunc; func_80151938(globalCtx, EnTrt_GetItemTextId(this)); } @@ -1054,7 +1054,7 @@ void EnTrt_CannotBuy(EnTrt* this, GlobalContext* globalCtx) { void EnTrt_CanBuy(EnTrt* this, GlobalContext* globalCtx) { EnGirlA* item; - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { this->shopItemSelectedTween = 0.0f; EnTrt_ResetItemPosition(this); item = this->items[this->cursorIdx]; @@ -1074,7 +1074,7 @@ void EnTrt_BuyItemWithFanfare(EnTrt* this, GlobalContext* globalCtx) { } void EnTrt_SetupItemGiven(EnTrt* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 6 && Message_ShouldAdvance(globalCtx)) { this->actionFunc = EnTrt_ItemGiven; if (this->cutsceneState == ENTRT_CUTSCENESTATE_STOPPED) { if (ActorCutscene_GetCurrentIndex() == 0x7C) { @@ -1094,7 +1094,7 @@ void EnTrt_ContinueShopping(EnTrt* this, GlobalContext* globalCtx) { if (talkState == 4) { func_8011552C(globalCtx, 6); - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { EnTrt_ResetItemPosition(this); item = this->items[this->cursorIdx]; item->restockFunc(globalCtx, item); @@ -1117,7 +1117,7 @@ void EnTrt_ContinueShopping(EnTrt* this, GlobalContext* globalCtx) { } } } else if (talkState == 5) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { EnTrt_ResetItemPosition(this); item = this->items[this->cursorIdx]; item->restockFunc(globalCtx, item); @@ -1221,10 +1221,7 @@ void EnTrt_UpdateCursorAnim(EnTrt* this) { void EnTrt_UpdateStickDirectionPromptAnim(EnTrt* this) { f32 arrowAnimTween = this->arrowAnimTween; f32 stickAnimTween = this->stickAnimTween; - - // Possbily fake temps - s32 maxColor = 255; - f32 tmp; + s32 maxColor = 255; // POSSIBLY FAKE if (this->arrowAnimState == 0) { arrowAnimTween += 0.05f; @@ -1251,31 +1248,33 @@ void EnTrt_UpdateStickDirectionPromptAnim(EnTrt* this) { stickAnimTween = 0.0f; this->stickAnimState = 0; } - - tmp = 155.0f * arrowAnimTween; - this->stickAnimTween = stickAnimTween; this->stickLeftPrompt.arrowColor.r = COL_CHAN_MIX(255, 155.0f, arrowAnimTween); this->stickLeftPrompt.arrowColor.g = COL_CHAN_MIX(maxColor, 155.0f, arrowAnimTween); - this->stickLeftPrompt.arrowColor.b = COL_CHAN_MIX(0, -100, arrowAnimTween); + this->stickLeftPrompt.arrowColor.b = COL_CHAN_MIX(0, -100.0f, arrowAnimTween); this->stickLeftPrompt.arrowColor.a = COL_CHAN_MIX(200, 50.0f, arrowAnimTween); - this->stickRightPrompt.arrowColor.r = (maxColor - ((s32)tmp)) & 0xFF; - this->stickRightPrompt.arrowColor.g = (255 - ((s32)tmp)) & 0xFF; + this->stickRightPrompt.arrowTexX = 290.0f; + + this->stickRightPrompt.arrowColor.r = COL_CHAN_MIX(maxColor, 155.0f, arrowAnimTween); + this->stickRightPrompt.arrowColor.g = COL_CHAN_MIX(255, 155.0f, arrowAnimTween); this->stickRightPrompt.arrowColor.b = COL_CHAN_MIX(0, -100.0f, arrowAnimTween); this->stickRightPrompt.arrowColor.a = COL_CHAN_MIX(200, 50.0f, arrowAnimTween); - this->stickRightPrompt.arrowTexX = 290.0f; this->stickLeftPrompt.arrowTexX = 33.0f; this->stickRightPrompt.stickTexX = 274.0f; this->stickRightPrompt.stickTexX += 8.0f * stickAnimTween; + this->stickLeftPrompt.stickTexX = 49.0f; this->stickLeftPrompt.stickTexX -= 8.0f * stickAnimTween; - this->stickLeftPrompt.arrowTexY = this->stickRightPrompt.arrowTexY = 91.0f; - this->stickLeftPrompt.stickTexY = this->stickRightPrompt.stickTexY = 95.0f; + this->stickRightPrompt.arrowTexY = 91.0f; + this->stickLeftPrompt.arrowTexY = 91.0f; + + this->stickRightPrompt.stickTexY = 95.0f; + this->stickLeftPrompt.stickTexY = 95.0f; } void EnTrt_OpenEyes(EnTrt* this) { @@ -1363,7 +1362,7 @@ void EnTrt_TalkToShopkeeper(EnTrt* this, GlobalContext* globalCtx) { s32 itemGiven; if (talkState == 5) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (this->talkOptionTextId == 0x845 || this->talkOptionTextId == 0x882) { func_80151938(globalCtx, 0xFF); } else { @@ -1374,7 +1373,7 @@ void EnTrt_TalkToShopkeeper(EnTrt* this, GlobalContext* globalCtx) { itemGiven = func_80123810(globalCtx); if (itemGiven > EXCH_ITEM_NONE) { if (itemGiven == EXCH_ITEM_1E) { - if (gSaveContext.weekEventReg[53] & 8) { + if (gSaveContext.save.weekEventReg[53] & 8) { player->actor.textId = 0x888; } else { player->actor.textId = 0x883; @@ -1443,7 +1442,8 @@ void EnTrt_LookToShopkeeperFromShelf(EnTrt* this, GlobalContext* globalCtx) { void EnTrt_InitShopkeeper(EnTrt* this, GlobalContext* globalCtx) { SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_trt_Skel_00FEF0, &object_trt_Anim_00FD34, NULL, NULL, 0); - if (!(gSaveContext.weekEventReg[12] & 8) && !(gSaveContext.weekEventReg[84] & 0x40) && gSaveContext.day >= 2) { + if (!(gSaveContext.save.weekEventReg[12] & 8) && !(gSaveContext.save.weekEventReg[84] & 0x40) && + gSaveContext.save.day >= 2) { this->actor.draw = NULL; } else { this->actor.draw = EnTrt_Draw; @@ -1451,9 +1451,6 @@ void EnTrt_InitShopkeeper(EnTrt* this, GlobalContext* globalCtx) { } void EnTrt_InitShop(EnTrt* this, GlobalContext* globalCtx) { - u32 maxcolor = 255; - EnTrt* this2; - EnTrt_GetCutscenes(this, globalCtx); this->cutscene = this->lookForwardCutscene; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); @@ -1461,7 +1458,8 @@ void EnTrt_InitShop(EnTrt* this, GlobalContext* globalCtx) { this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->actor.colChkInfo.cylRadius = 50; this->timer = Rand_S16Offset(40, 20); - if (!(gSaveContext.weekEventReg[12] & 8) && !(gSaveContext.weekEventReg[84] & 0x40) && gSaveContext.day >= 2) { + if (!(gSaveContext.save.weekEventReg[12] & 8) && !(gSaveContext.save.weekEventReg[84] & 0x40) && + gSaveContext.save.day >= 2) { this->textId = 0x84A; this->actionFunc = EnTrt_ShopkeeperGone; } else { @@ -1470,58 +1468,55 @@ void EnTrt_InitShop(EnTrt* this, GlobalContext* globalCtx) { this->actionFunc = EnTrt_IdleSleeping; } + this->cursorPos.y = this->cursorPos.x = 100.0f; this->stickAccumY = 0; this->stickAccumX = 0; + this->cursorIdx = 0; - this->cursorPos.y = this->cursorPos.x = 100.0f; this->cursorPos.z = 1.2f; this->cursorColor.r = 0; this->cursorColor.g = 80; - this->cursorColor.b = maxcolor; - this->cursorColor.a = maxcolor; + this->cursorColor.b = 255; + this->cursorColor.a = 255; this->cursorAnimTween = 0.0f; this->cursorAnimState = 0; this->drawCursor = 0; - this2 = this; - this->stickLeftPrompt.stickColor.r = 200; - this2->stickLeftPrompt.stickColor.g = 200; - this2->stickLeftPrompt.stickColor.b = 200; - this2->stickLeftPrompt.stickColor.a = 180; - this2->stickLeftPrompt.stickTexX = 49.0f; - this2->stickLeftPrompt.stickTexY = 95.0f; - this2->stickLeftPrompt.arrowColor.r = maxcolor; - this2->stickLeftPrompt.arrowColor.g = maxcolor; - this2->stickLeftPrompt.arrowColor.b = 0; - this2->stickLeftPrompt.arrowColor.a = 200; - this2->stickLeftPrompt.arrowTexX = 33.0f; - this2->stickLeftPrompt.arrowTexY = 91.0f; - this2->stickLeftPrompt.texZ = 1.0f; - this2->stickLeftPrompt.isEnabled = false; + this->stickLeftPrompt.stickColor.g = 200; + this->stickLeftPrompt.stickColor.b = 200; + this->stickLeftPrompt.stickColor.a = 180; + this->stickLeftPrompt.stickTexX = 49.0f; + this->stickLeftPrompt.stickTexY = 95.0f; + this->stickLeftPrompt.arrowColor.r = 255; + this->stickLeftPrompt.arrowColor.g = 255; + this->stickLeftPrompt.arrowColor.b = 0; + this->stickLeftPrompt.arrowColor.a = 200; + this->stickLeftPrompt.arrowTexX = 33.0f; + this->stickLeftPrompt.arrowTexY = 91.0f; + this->stickLeftPrompt.texZ = 1.0f; + this->stickLeftPrompt.isEnabled = false; - if (1) {} + this->stickRightPrompt.stickColor.r = 200; + this->stickRightPrompt.stickColor.g = 200; + this->stickRightPrompt.stickColor.b = 200; + this->stickRightPrompt.stickColor.a = 180; + this->stickRightPrompt.stickTexX = 274.0f; + this->stickRightPrompt.stickTexY = 95.0f; + this->stickRightPrompt.arrowColor.r = 255; + this->stickRightPrompt.arrowColor.g = 0; + this->stickRightPrompt.arrowColor.b = 0; + this->stickRightPrompt.arrowColor.a = 200; + this->stickRightPrompt.arrowTexX = 290.0f; + this->stickRightPrompt.arrowTexY = 91.0f; + this->stickRightPrompt.texZ = 1.0f; + this->stickRightPrompt.isEnabled = false; - this2->stickRightPrompt.stickColor.r = 200; - this2->stickRightPrompt.stickColor.g = 200; - this2->stickRightPrompt.stickColor.b = 200; - this2->stickRightPrompt.stickColor.a = 180; - this2->stickRightPrompt.stickTexX = 274.0f; - this2->stickRightPrompt.stickTexY = 95.0f; - this2->stickRightPrompt.arrowColor.r = maxcolor; - this2->stickRightPrompt.arrowColor.g = 0; - this2->stickRightPrompt.arrowColor.b = 0; - this2->stickRightPrompt.arrowColor.a = 200; - this2->stickRightPrompt.arrowTexX = 290.0f; - this2->stickRightPrompt.arrowTexY = 91.0f; - this2->stickRightPrompt.texZ = 1.0f; - this2->stickRightPrompt.isEnabled = false; - - this2->arrowAnimTween = 0.0f; - this2->stickAnimTween = 0.0f; - this2->arrowAnimState = 0; - this2->stickAnimState = 0; - this2->shopItemSelectedTween = 0.0f; + this->arrowAnimTween = 0.0f; + this->stickAnimTween = 0.0f; + this->arrowAnimState = 0; + this->stickAnimState = 0; + this->shopItemSelectedTween = 0.0f; this->actor.gravity = 0.0f; Actor_SetScale(&this->actor, sActorScale); @@ -1529,7 +1524,7 @@ void EnTrt_InitShop(EnTrt* this, GlobalContext* globalCtx) { this->blinkTimer = 20; this->eyeTextureIdx = 0; this->blinkFunc = EnTrt_EyesClosed; - if (gSaveContext.weekEventReg[53] & 8) { + if (gSaveContext.save.weekEventReg[53] & 8) { this->flags |= ENTRT_GIVEN_MUSHROOM; } @@ -1544,7 +1539,10 @@ void EnTrt_GetCutscenes(EnTrt* this, GlobalContext* globalCtx) { } void EnTrt_DrawCursor(GlobalContext* globalCtx, EnTrt* this, f32 x, f32 y, f32 z, u8 drawCursor) { - s32 ulx, uly, lrx, lry; + s32 ulx; + s32 uly; + s32 lrx; + s32 lry; f32 w; s32 dsdx; s32 pad; @@ -1554,8 +1552,8 @@ void EnTrt_DrawCursor(GlobalContext* globalCtx, EnTrt* this, f32 x, f32 y, f32 z func_8012C654(globalCtx->state.gfxCtx); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, this->cursorColor.r, this->cursorColor.g, this->cursorColor.b, this->cursorColor.a); - gDPLoadTextureBlock_4b(OVERLAY_DISP++, gameplay_keep_Tex_01F740, G_IM_FMT_IA, 16, 16, 0, - G_TX_MIRROR | G_TX_WRAP, G_TX_MIRROR | G_TX_WRAP, 4, 4, G_TX_NOLOD, G_TX_NOLOD); + gDPLoadTextureBlock_4b(OVERLAY_DISP++, gSelectionCursorTex, G_IM_FMT_IA, 16, 16, 0, G_TX_MIRROR | G_TX_WRAP, + G_TX_MIRROR | G_TX_WRAP, 4, 4, G_TX_NOLOD, G_TX_NOLOD); w = 16.0f * z; ulx = (x - w) * 4.0f; uly = (y - w + -12.0f) * 4.0f; @@ -1570,11 +1568,16 @@ void EnTrt_DrawCursor(GlobalContext* globalCtx, EnTrt* this, f32 x, f32 y, f32 z void EnTrt_DrawTextRec(GlobalContext* globalCtx, s32 r, s32 g, s32 b, s32 a, f32 x, f32 y, f32 z, s32 s, s32 t, f32 dx, f32 dy) { f32 unk; - s32 ulx, uly, lrx, lry; - f32 w, h; - s32 dsdx, dtdy; + s32 ulx; + s32 uly; + s32 lrx; + s32 lry; + f32 w; + f32 h; + s32 dsdx; + s32 dtdy; - ((void)"../z_en_trt.c"); // Unreferenced + (void)"../z_en_trt.c"; OPEN_DISPS(globalCtx->state.gfxCtx); gDPPipeSync(OVERLAY_DISP++); @@ -1600,21 +1603,15 @@ void EnTrt_DrawStickDirectionPrompt(GlobalContext* globalCtx, EnTrt* this) { s32 drawStickRightPrompt = this->stickLeftPrompt.isEnabled; s32 drawStickLeftPrompt = this->stickRightPrompt.isEnabled; - ((void)"../z_en_trt.c"); // Unreferenced + (void)"../z_en_trt.c"; OPEN_DISPS(globalCtx->state.gfxCtx); if (drawStickRightPrompt || drawStickLeftPrompt) { func_8012C654(globalCtx->state.gfxCtx); gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); - gDPSetTextureImage(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 1, gameplay_keep_Tex_01F8C0); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 0, 0x0000, G_TX_LOADTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPLoadSync(OVERLAY_DISP++); - gDPLoadBlock(OVERLAY_DISP++, G_TX_LOADTILE, 0, 0, 191, 1024); - gDPPipeSync(OVERLAY_DISP++); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_8b, 2, 0x0000, G_TX_RENDERTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPSetTileSize(OVERLAY_DISP++, G_TX_RENDERTILE, 0, 0, 15 * 4, 23 * 4); + gDPLoadTextureBlock(OVERLAY_DISP++, gArrowCursorTex, G_IM_FMT_IA, G_IM_SIZ_8b, 16, 24, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); if (drawStickRightPrompt) { EnTrt_DrawTextRec(globalCtx, this->stickLeftPrompt.arrowColor.r, this->stickLeftPrompt.arrowColor.g, this->stickLeftPrompt.arrowColor.b, this->stickLeftPrompt.arrowColor.a, @@ -1627,15 +1624,9 @@ void EnTrt_DrawStickDirectionPrompt(GlobalContext* globalCtx, EnTrt* this) { this->stickRightPrompt.arrowTexX, this->stickRightPrompt.arrowTexY, this->stickRightPrompt.texZ, 0, 0, 1.0f, 1.0f); } - gDPSetTextureImage(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 1, gameplay_keep_Tex_01F7C0); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 0, 0x0000, G_TX_LOADTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPLoadSync(OVERLAY_DISP++); - gDPLoadBlock(OVERLAY_DISP++, G_TX_LOADTILE, 0, 0, 127, 1024); - gDPPipeSync(OVERLAY_DISP++); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_8b, 2, 0x0000, G_TX_RENDERTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPSetTileSize(OVERLAY_DISP++, G_TX_RENDERTILE, 0, 0, 15 * 4, 15 * 4); + gDPLoadTextureBlock(OVERLAY_DISP++, gControlStickTex, G_IM_FMT_IA, G_IM_SIZ_8b, 16, 16, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); if (drawStickRightPrompt) { EnTrt_DrawTextRec(globalCtx, this->stickLeftPrompt.stickColor.r, this->stickLeftPrompt.stickColor.g, this->stickLeftPrompt.stickColor.b, this->stickLeftPrompt.stickColor.a, diff --git a/src/overlays/actors/ovl_En_Trt/z_en_trt.h b/src/overlays/actors/ovl_En_Trt/z_en_trt.h index 2df343dfce..eb243317b9 100644 --- a/src/overlays/actors/ovl_En_Trt/z_en_trt.h +++ b/src/overlays/actors/ovl_En_Trt/z_en_trt.h @@ -41,7 +41,7 @@ typedef struct EnTrt { /* 0x3F0 */ Color_RGBAu32 cursorColor; /* 0x400 */ u8 drawCursor; /* 0x402 */ s16 timer; - /* 0x404 */ s16 animationIdx; + /* 0x404 */ s16 animationIndex; /* 0x406 */ u16 textId; /* 0x408 */ u16 tmpTextId; /* 0x40A */ u16 talkOptionTextId; diff --git a/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c b/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c index 9560ea8427..0af7ac4bb0 100644 --- a/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c +++ b/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c @@ -131,13 +131,13 @@ void func_80AD341C(EnTrt2* this, GlobalContext* globalCtx) { } void func_80AD349C(EnTrt2* this) { - if ((gSaveContext.weekEventReg[85] & 0x10) && !(gSaveContext.weekEventReg[84] & 0x40)) { + if ((gSaveContext.save.weekEventReg[85] & 0x10) && !(gSaveContext.save.weekEventReg[84] & 0x40)) { this->unk_3A8 = 0x88F; } else if (this->unk_3A8 == 0) { this->unk_3A8 = 0x84B; - } else if (gSaveContext.weekEventReg[16] & 0x10) { + } else if (gSaveContext.save.weekEventReg[16] & 0x10) { this->unk_3A8 = 0x838; - } else if (gSaveContext.weekEventReg[17] & 1) { + } else if (gSaveContext.save.weekEventReg[17] & 1) { this->unk_3A8 = 0x84D; } else { this->unk_3A8 = 0x849; @@ -203,7 +203,7 @@ void func_80AD36EC(EnTrt2* this, GlobalContext* globalCtx) { this->unk_1E4 = 0; this->unk_3D9 = 1; this->actor.velocity.y = 0.0f; - this->path = func_8013D648(globalCtx, this->path->unk1, -1); + this->path = SubS_GetPathByIndex(globalCtx, this->path->unk1, -1); ActorCutscene_Stop(this->unk_3DA); this->unk_3DA = ActorCutscene_GetAdditionalCutscene(this->unk_3DA); ActorCutscene_SetIntentToPlay(this->unk_3DA); @@ -332,7 +332,7 @@ void func_80AD3CEC(EnTrt2* this, GlobalContext* globalCtx) { if (this->unk_3D8) { Message_StartTextbox(globalCtx, this->unk_3A8, &this->actor); this->unk_3D8 = false; - } else if ((sp27 == 5) && func_80147624(globalCtx)) { + } else if ((sp27 == 5) && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; func_80AD3380(&this->skelAnime, sAnimations, 6); @@ -359,13 +359,13 @@ void func_80AD3DA4(EnTrt2* this, GlobalContext* globalCtx) { } void func_80AD3E34(EnTrt2* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { if (Interface_HasEmptyBottle()) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; this->unk_3B2 = 12; } else { - gSaveContext.weekEventReg[85] |= 0x10; + gSaveContext.save.weekEventReg[85] |= 0x10; this->unk_3A8 = 0x88E; Message_StartTextbox(globalCtx, this->unk_3A8, &this->actor); this->unk_3B2 = 10; @@ -377,18 +377,18 @@ void func_80AD3EF0(EnTrt2* this, GlobalContext* globalCtx) { u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); if (temp_v0 == 6) { - if (func_80147624(globalCtx)) { - if ((Interface_HasEmptyBottle() && !(gSaveContext.weekEventReg[84] & 0x40)) || - !(gSaveContext.weekEventReg[12] & 0x10)) { + if (Message_ShouldAdvance(globalCtx)) { + if ((Interface_HasEmptyBottle() && !(gSaveContext.save.weekEventReg[84] & 0x40)) || + !(gSaveContext.save.weekEventReg[12] & 0x10)) { this->unk_3B2 = 12; } else { - gSaveContext.weekEventReg[85] |= 0x10; + gSaveContext.save.weekEventReg[85] |= 0x10; this->unk_3A8 = 0x88E; Message_StartTextbox(globalCtx, this->unk_3A8, &this->actor); this->unk_3B2 = 10; } } - } else if ((temp_v0 == 5) && func_80147624(globalCtx)) { + } else if ((temp_v0 == 5) && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; this->unk_3B2 = 12; @@ -397,13 +397,13 @@ void func_80AD3EF0(EnTrt2* this, GlobalContext* globalCtx) { void func_80AD3FF4(EnTrt2* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { - if (!(gSaveContext.weekEventReg[12] & 0x10)) { - gSaveContext.weekEventReg[12] |= 0x10; + if (!(gSaveContext.save.weekEventReg[12] & 0x10)) { + gSaveContext.save.weekEventReg[12] |= 0x10; } - gSaveContext.weekEventReg[84] |= 0x40; + gSaveContext.save.weekEventReg[84] |= 0x40; this->actor.parent = NULL; this->unk_3B2 = 14; - } else if (gSaveContext.weekEventReg[12] & 0x10) { + } else if (gSaveContext.save.weekEventReg[12] & 0x10) { Actor_PickUp(&this->actor, globalCtx, GI_POTION_RED, 300.0f, 300.0f); } else { Actor_PickUp(&this->actor, globalCtx, GI_BOTTLE_POTION_RED, 300.0f, 300.0f); @@ -411,7 +411,7 @@ void func_80AD3FF4(EnTrt2* this, GlobalContext* globalCtx) { } void func_80AD40AC(EnTrt2* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 6) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 6) && Message_ShouldAdvance(globalCtx)) { func_800B85E0(&this->actor, globalCtx, 400.0f, -1); this->unk_3B2 = 13; } @@ -428,7 +428,7 @@ void func_80AD4110(EnTrt2* this, GlobalContext* globalCtx) { } void func_80AD417C(EnTrt2* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { if (this->unk_3A8 == 0x84B) { func_80AD349C(this); func_80AD3DA4(this, globalCtx); @@ -437,7 +437,7 @@ void func_80AD417C(EnTrt2* this, GlobalContext* globalCtx) { globalCtx->msgCtx.unk12023 = 4; if (this->unk_3A8 == 0x84C) { func_80AD3380(&this->skelAnime, sAnimations, 6); - this->path = func_8013D648(globalCtx, ENTRT2_GET_FC00(&this->actor), 0x3F); + this->path = SubS_GetPathByIndex(globalCtx, ENTRT2_GET_FC00(&this->actor), 0x3F); this->unk_3B2 = 18; } else if (this->unk_3A8 == 0x88F) { this->unk_3A8 = 0x88E; @@ -514,7 +514,7 @@ void func_80AD4550(EnTrt2* this, GlobalContext* globalCtx) { this->unk_3B2 = 17; } - if ((sp23 == 5) && func_80147624(globalCtx)) { + if ((sp23 == 5) && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; } @@ -708,7 +708,7 @@ void func_80AD4DB4(EnTrt2* this, GlobalContext* globalCtx) { this->actor.flags &= ~ACTOR_FLAG_10; Actor_SetObjectDependency(globalCtx, &this->actor); Actor_SetScale(&this->actor, 0.008f); - this->path = func_8013D648(globalCtx, ENTRT2_GET_FC00(&this->actor), 0x3F); + this->path = SubS_GetPathByIndex(globalCtx, ENTRT2_GET_FC00(&this->actor), 0x3F); this->unk_3AE = Rand_S16Offset(100, 50); this->unk_3B0 = 10; this->unk_3A8 = 0; @@ -729,20 +729,20 @@ void func_80AD4DB4(EnTrt2* this, GlobalContext* globalCtx) { this->unk_3B8 = 0; this->unk_3BC = func_80AD4608; - if (gSaveContext.weekEventReg[12] & 8) { + if (gSaveContext.save.weekEventReg[12] & 8) { Actor_MarkForDeath(&this->actor); return; } - if (gSaveContext.weekEventReg[84] & 0x40) { + if (gSaveContext.save.weekEventReg[84] & 0x40) { Actor_MarkForDeath(&this->actor); return; } if ((globalCtx->sceneNum == SCENE_20SICHITAI) || (globalCtx->sceneNum == SCENE_20SICHITAI2)) { - if (gSaveContext.day == 2) { - if (!(gSaveContext.weekEventReg[15] & 0x80)) { - gSaveContext.weekEventReg[15] |= 0x80; + if (gSaveContext.save.day == 2) { + if (!(gSaveContext.save.weekEventReg[15] & 0x80)) { + gSaveContext.save.weekEventReg[15] |= 0x80; this->unk_3B2 = 3; } else { Actor_MarkForDeath(&this->actor); @@ -752,14 +752,14 @@ void func_80AD4DB4(EnTrt2* this, GlobalContext* globalCtx) { Actor_MarkForDeath(&this->actor); return; } - } else if (gSaveContext.day == 2) { - if (gSaveContext.weekEventReg[15] & 0x80) { + } else if (gSaveContext.save.day == 2) { + if (gSaveContext.save.weekEventReg[15] & 0x80) { this->unk_3B2 = 4; } else { Actor_MarkForDeath(&this->actor); return; } - } else if (gSaveContext.day == 3) { + } else if (gSaveContext.save.day == 3) { this->unk_3B2 = 4; } this->actionFunc = func_80AD4FE4; diff --git a/src/overlays/actors/ovl_En_Tru/z_en_tru.c b/src/overlays/actors/ovl_En_Tru/z_en_tru.c index 31f87f6037..7cf13c6afd 100644 --- a/src/overlays/actors/ovl_En_Tru/z_en_tru.c +++ b/src/overlays/actors/ovl_En_Tru/z_en_tru.c @@ -320,6 +320,7 @@ void func_80A85F84(EnTruUnkStruct* arg0, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx); } #else +void func_80A85F84(EnTruUnkStruct* arg0, GlobalContext* globalCtx); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru/func_80A85F84.s") #endif @@ -580,7 +581,6 @@ s32 func_80A86DB8(EnTru* this) { if (this->skelAnime.curFrame < 57.0f) { if (DECR(this->unk_36C) == 0) { - this = this; this->unk_36C = Rand_S16Offset(8, 8); this->unk_36E = 2; } else { @@ -654,11 +654,11 @@ UNK_TYPE* func_80A871E0(EnTru* this, GlobalContext* globalCtx) { return D_80A88924; } - if (!(this->unk_34E & 0x40) && !(gSaveContext.weekEventReg[16] & 0x10)) { + if (!(this->unk_34E & 0x40) && !(gSaveContext.save.weekEventReg[16] & 0x10)) { return D_80A88918; } - if ((this->unk_34E & 0x1000) && !(gSaveContext.weekEventReg[16] & 0x10)) { + if ((this->unk_34E & 0x1000) && !(gSaveContext.save.weekEventReg[16] & 0x10)) { return D_80A88910; } @@ -723,7 +723,7 @@ s32 func_80A87400(EnTru* this, GlobalContext* globalCtx) { if (this->path != NULL) { sp4C = Lib_SegmentedToVirtual(this->path->points); - if (func_8013BD40(&this->actor, this->path, this->unk_384)) { + if (SubS_HasReachedPoint(&this->actor, this->path, this->unk_384)) { if (this->unk_384 > this->unk_384 + 1) { this->unk_384 = this->path->count - 2; ret = true; @@ -753,7 +753,7 @@ s32 func_80A875AC(Actor* thisx, GlobalContext* globalCtx) { switch (this->unk_364) { case 0: - if ((this->unk_34E & 0x40) || (gSaveContext.weekEventReg[16] & 0x10)) { + if ((this->unk_34E & 0x40) || (gSaveContext.save.weekEventReg[16] & 0x10)) { this->unk_374 = this->actor.cutscene; this->unk_364++; } else { @@ -807,42 +807,33 @@ s32 func_80A875AC(Actor* thisx, GlobalContext* globalCtx) { } s32 func_80A8777C(Actor* thisx, GlobalContext* globalCtx) { - s32 temp_v0; + EnTru* this = THIS; s32 ret = 0; - - temp_v0 = Message_GetState(&globalCtx->msgCtx); + s32 temp_v0 = Message_GetState(&globalCtx->msgCtx); switch (temp_v0) { - default: - if (temp_v0 != 0x10) { - break; - } - if (0) { - - case 4: - case 5: - if (!func_80147624(globalCtx)) { - break; + case 4: + case 5: + if (Message_ShouldAdvance(globalCtx)) { + case 16: + temp_v0 = func_80123810(globalCtx); + if ((temp_v0 == 35) || (temp_v0 == 36)) { + this->unk_34E |= 8; + if (temp_v0 == 35) { + this->unk_390 = 1; + } else { + this->unk_390 = 2; + } + this->unk_378 = func_80A87880; + this->unk_364 = 0; + ret = 1; + } else if (temp_v0 < 0) { + ret = 3; + } else if (temp_v0 != 0) { + ret = 2; } + break; } - - temp_v0 = func_80123810(globalCtx); - if ((temp_v0 == 35) || (temp_v0 == 36)) { - ((EnTru*)thisx)->unk_34E |= 8; - if (temp_v0 == 35) { - ((EnTru*)thisx)->unk_390 = 1; - } else { - ((EnTru*)thisx)->unk_390 = 2; - } - ((EnTru*)thisx)->unk_378 = func_80A87880; - ((EnTru*)thisx)->unk_364 = 0; - ret = 1; - } else if (temp_v0 < 0) { - ret = 3; - } else if (temp_v0 != 0) { - ret = 2; - } - break; } return ret; @@ -1029,7 +1020,7 @@ s32 func_80A87DC0(Actor* thisx, GlobalContext* globalCtx) { case 4: if (func_80A87400(this, globalCtx) || (DECR(this->unk_362) == 0)) { ret = true; - gSaveContext.weekEventReg[12] |= 8; + gSaveContext.save.weekEventReg[12] |= 8; } break; } @@ -1046,7 +1037,7 @@ s32 func_80A87DC0(Actor* thisx, GlobalContext* globalCtx) { void func_80A87FD0(EnTru* this, GlobalContext* globalCtx) { if (this->actor.draw != NULL) { - if ((this->unk_34E & 0x80) || (gSaveContext.weekEventReg[16] & 0x10)) { + if ((this->unk_34E & 0x80) || (gSaveContext.save.weekEventReg[16] & 0x10)) { if (func_80A873B8(this)) { SubS_UpdateFlags(&this->unk_34E, 3, 7); } else { @@ -1068,7 +1059,7 @@ void func_80A87FD0(EnTru* this, GlobalContext* globalCtx) { func_80A86924(this, 2); } } - } else if (!(gSaveContext.weekEventReg[16] & 0x10) && (fabsf(this->actor.playerHeightRel) < 10.0f) && + } else if (!(gSaveContext.save.weekEventReg[16] & 0x10) && (fabsf(this->actor.playerHeightRel) < 10.0f) && (this->actor.xzDistToPlayer < 140.0f)) { SubS_UpdateFlags(&this->unk_34E, 4, 7); this->unk_34E |= 0x1040; @@ -1093,12 +1084,12 @@ void func_80A881E0(EnTru* this, GlobalContext* globalCtx) { ActorCutscene_Stop(ActorCutscene_GetCurrentIndex()); } - if (!(this->unk_34E & 0x40) && !(gSaveContext.weekEventReg[16] & 0x10)) { + if (!(this->unk_34E & 0x40) && !(gSaveContext.save.weekEventReg[16] & 0x10)) { func_80A86924(this, 0); } else if (this->unk_34E & 0x80) { func_80A86924(this, 0); func_80A86460(this); - } else if (gSaveContext.weekEventReg[16] & 0x10) { + } else if (gSaveContext.save.weekEventReg[16] & 0x10) { func_80A86924(this, 6); } @@ -1115,7 +1106,7 @@ void func_80A881E0(EnTru* this, GlobalContext* globalCtx) { void EnTru_Init(Actor* thisx, GlobalContext* globalCtx) { EnTru* this = THIS; - if ((gSaveContext.entranceIndex != 0xC200) || (gSaveContext.weekEventReg[12] & 8)) { + if ((gSaveContext.save.entranceIndex != 0xC200) || (gSaveContext.save.weekEventReg[12] & 8)) { Actor_MarkForDeath(&this->actor); return; } @@ -1127,7 +1118,7 @@ void EnTru_Init(Actor* thisx, GlobalContext* globalCtx) { CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); this->unk_37C = -1; func_80A86924(this, 0); - this->path = func_8013BEDC(globalCtx, this->actor.params & 0xFF, 255, &this->unk_384); + this->path = SubS_GetDayDependentPath(globalCtx, ENTRU_GET_PATH(&this->actor), 255, &this->unk_384); if (this->path != NULL) { this->unk_384 = 1; } @@ -1136,10 +1127,10 @@ void EnTru_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, 0.008f); this->unk_34E = 0; - if (gSaveContext.weekEventReg[16] & 0x10) { + if (gSaveContext.save.weekEventReg[16] & 0x10) { func_80A86924(this, 5); } else { - this->unk_388 = 0; + this->unk_388 = EXCH_ITEM_NONE; } this->actionFunc = func_80A87FD0; @@ -1165,7 +1156,7 @@ void EnTru_Update(Actor* thisx, GlobalContext* globalCtx) { func_80A86DB8(this); radius = this->collider.dim.worldSphere.radius + 30; - this->unk_388 = !(this->unk_34E & 0x80) ? 0 : 0; + this->unk_388 = !(this->unk_34E & 0x80) ? EXCH_ITEM_NONE : EXCH_ITEM_NONE; func_8013C964(&this->actor, globalCtx, radius, 20.0f, this->unk_388, this->unk_34E & 7); func_80A8697C(this, globalCtx); diff --git a/src/overlays/actors/ovl_En_Tru/z_en_tru.h b/src/overlays/actors/ovl_En_Tru/z_en_tru.h index 4127fcdff8..d1090cec44 100644 --- a/src/overlays/actors/ovl_En_Tru/z_en_tru.h +++ b/src/overlays/actors/ovl_En_Tru/z_en_tru.h @@ -8,6 +8,8 @@ struct EnTru; typedef void (*EnTruActionFunc)(struct EnTru*, GlobalContext*); typedef s32 (*EnTruUnkFunc)(Actor*, GlobalContext*); +#define ENTRU_GET_PATH(thisx) ((thisx)->params & 0xFF) + typedef struct { /* 0x00 */ u8 unk_00; /* 0x01 */ u8 unk_01; diff --git a/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c b/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c index 2cb79a8c16..e191cc3cd3 100644 --- a/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c +++ b/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c @@ -5,6 +5,7 @@ */ #include "z_en_tru_mt.h" +#include "overlays/actors/ovl_En_Jc_Mato/z_en_jc_mato.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -19,7 +20,6 @@ void func_80B76A64(EnTruMt* this, GlobalContext* globalCtx); void func_80B76BB8(EnTruMt* this, GlobalContext* globalCtx); void func_80B76C38(EnTruMt* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Tru_Mt_InitVars = { ACTOR_EN_TRU_MT, ACTORCAT_NPC, @@ -32,15 +32,27 @@ const ActorInit En_Tru_Mt_InitVars = { (ActorFunc)EnTruMt_Draw, }; -// static ColliderSphereInit sSphereInit = { -static ColliderSphereInit D_80B77510 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_SPHERE, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderSphereInit sSphereInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_SPHERE, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 22 }, 100 }, }; -// static DamageTable sDamageTable = { -static DamageTable D_80B7753C = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(1, 0x0), /* Deku Stick */ DMG_ENTRY(1, 0x0), /* Horse trample */ DMG_ENTRY(1, 0x0), @@ -75,58 +87,492 @@ static DamageTable D_80B7753C = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -#endif +static AnimationInfoS D_80B7755C[] = { + { &object_tru_Anim_00F9A0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_tru_Anim_00F9A0, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_tru_Anim_0108AC, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_tru_Anim_009348, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_tru_Anim_00EEDC, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_tru_Anim_015CA0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_tru_Anim_015CA0, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_tru_Anim_014728, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_tru_Anim_01B5C4, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_tru_Anim_007FA0, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_tru_Anim_016B4C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_tru_Anim_011F88, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_tru_Anim_00446C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_tru_Anim_003698, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_tru_Anim_002BD8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_tru_Anim_00446C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, +}; -extern ColliderSphereInit D_80B77510; -extern DamageTable D_80B7753C; +Vec3f D_80B7765C = { 3000.0f, -800.0f, 0.0f }; -extern UNK_TYPE D_060004C8; -extern UNK_TYPE D_0601AA60; +Vec3f D_80B77668 = { 0.0f, 0.0f, -3000.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B76030.s") +s32 func_80B76030(SkelAnime* skelAnime, s16 arg1) { + s16 endFrame; + s16 startFrame; + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B76110.s") + if ((arg1 >= 0) && (arg1 < ARRAY_COUNT(D_80B7755C))) { + endFrame = D_80B7755C[arg1].frameCount; + if (endFrame < 0) { + endFrame = Animation_GetLastFrame(D_80B7755C[arg1].animation); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B76188.s") + startFrame = D_80B7755C[arg1].startFrame; + if (startFrame < 0) { + startFrame = Animation_GetLastFrame(D_80B7755C[arg1].animation); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B761FC.s") + Animation_Change(skelAnime, D_80B7755C[arg1].animation, D_80B7755C[arg1].playSpeed, startFrame, endFrame, + D_80B7755C[arg1].mode, D_80B7755C[arg1].morphFrames); + ret = true; + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B76368.s") +void func_80B76110(EnTruMt* this) { + if (DECR(this->unk_34E) == 0) { + this->unk_34C++; + if (this->unk_34C >= 3) { + this->unk_34E = Rand_S16Offset(30, 30); + this->unk_34C = 0; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B763C4.s") +void func_80B76188(EnTruMt* this) { + this->unk_38E.x = Math_CosS(this->unk_38A) * this->unk_38C; + this->unk_38A += 0x1555; + Math_SmoothStepToS(&this->unk_38C, 0, 4, 0x3E8, 1); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B76440.s") +s32 func_80B761FC(EnTruMt* this, GlobalContext* globalCtx) { + this->collider.dim.worldSphere.center.x = this->actor.world.pos.x; + this->collider.dim.worldSphere.center.y = this->actor.world.pos.y + 16.0f; + this->collider.dim.worldSphere.center.z = this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B76540.s") + if ((this->collider.base.acFlags & AC_HIT) && (this->actor.colChkInfo.damageEffect == 0xF)) { + if (!(((EnJcMato*)this->actor.child)->collider.base.acFlags & AC_HIT) && + (this->actor.child->colChkInfo.damageEffect != 0xF)) { + this->collider.base.acFlags &= ~AC_HIT; + if (this->unk_3A4 == 0) { + this->unk_3A4 = 1; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KOUME_DAMAGE); + } else { + this->unk_3A4 = 0; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KOUME_DAMAGE2); + } + globalCtx->interfaceCtx.unk_25E = 1; + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 25); + return true; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B76600.s") + if (this->unk_38C >= 0xB7) { + func_80B76188(this); + } else { + this->unk_38E.x = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B7679C.s") + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B768F0.s") +s32 func_80B76368(EnTruMt* this, GlobalContext* globalCtx) { + Actor* bgActor = globalCtx->actorCtx.actorLists[ACTORCAT_BG].first; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B76924.s") + while (bgActor != NULL) { + if (bgActor->id == ACTOR_BG_INGATE) { + this->unk_394 = bgActor->shape.rot.y; + this->unk_398 = bgActor->world.pos; + return true; + } + bgActor = bgActor->next; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B76980.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B76A64.s") +s32 func_80B763C4(EnTruMt* this, GlobalContext* globalCtx) { + Actor* foundActor; + Actor* actor = NULL; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B76BB8.s") + while (true) { + foundActor = SubS_FindActor(globalCtx, actor, ACTORCAT_NPC, ACTOR_EN_TRU_MT); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B76C38.s") + if (foundActor == NULL) { + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/EnTruMt_Init.s") + if ((EnTruMt*)foundActor != this) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/EnTruMt_Destroy.s") + foundActor = foundActor->next; + if (foundActor == NULL) { + break; + } + actor = foundActor; + }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/EnTruMt_Update.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B76ED4.s") +void func_80B76440(EnTruMt* this, GlobalContext* globalCtx) { + if (func_80B76368(this, globalCtx)) { + s16 temp_v1 = this->unk_394 - Math_Vec3f_Yaw(&this->unk_398, &this->actor.world.pos); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B77008.s") + if ((temp_v1 <= -0x2000) || (temp_v1 >= 0x2000)) { + Math_ApproachF(&this->actor.speedXZ, 7.0f, 0.2f, 1.0f); + } else if (this->actor.xzDistToPlayer < 300.0f) { + Math_ApproachF(&this->actor.speedXZ, 7.0f, 0.2f, 1.0f); + } else if (this->actor.xzDistToPlayer > 500.0f) { + Math_ApproachF(&this->actor.speedXZ, 2.5f, 0.2f, 1.0f); + } else { + Math_ApproachF(&this->actor.speedXZ, 4.0f, 0.2f, 1.0f); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B77078.s") +f32 func_80B76540(Path* path, s32 arg1, Vec3f* arg2, Vec3s* arg3) { + s32 pad; + Vec3f sp20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B77354.s") + if (path != NULL) { + Vec3s* temp_v1 = Lib_SegmentedToVirtual(path->points); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/EnTruMt_Draw.s") + temp_v1 = &temp_v1[arg1]; + sp20.x = temp_v1->x; + sp20.y = temp_v1->y; + sp20.z = temp_v1->z; + } + arg3->y = Math_Vec3f_Yaw(arg2, &sp20); + arg3->x = Math_Vec3f_Pitch(arg2, &sp20); + + return sp20.y - arg2->y; +} + +s32 func_80B76600(EnTruMt* this, Path* path, s32 arg2) { + Vec3s* sp5C = Lib_SegmentedToVirtual(path->points); + s32 sp58 = path->count; + s32 idx = arg2; + s32 sp50 = false; + f32 phi_f12; + f32 phi_f14; + f32 sp44; + f32 sp40; + f32 sp3C; + Vec3f sp30; + + Math_Vec3s_ToVec3f(&sp30, &sp5C[idx]); + + if (idx == 0) { + phi_f12 = sp5C[1].x - sp5C[0].x; + phi_f14 = sp5C[1].z - sp5C[0].z; + } else if (idx == (sp58 - 1)) { + phi_f12 = sp5C[sp58 - 1].x - sp5C[sp58 - 2].x; + phi_f14 = sp5C[sp58 - 1].z - sp5C[sp58 - 2].z; + } else { + phi_f12 = sp5C[idx + 1].x - sp5C[idx - 1].x; + phi_f14 = sp5C[idx + 1].z - sp5C[idx - 1].z; + } + + func_8017B7F8(&sp30, RADF_TO_BINANG(func_80086B30(phi_f12, phi_f14)), &sp44, &sp40, &sp3C); + if (((this->actor.world.pos.x * sp44) + (sp40 * this->actor.world.pos.z) + sp3C) > 0.0f) { + sp50 = true; + } + + return sp50; +} + +void func_80B7679C(EnTruMt* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f sp40; + Vec3f sp34; + + Math_SmoothStepToS(&this->unk_34A, (this->actor.yawTowardsPlayer - this->actor.shape.rot.y) - 0x4000, 4, 0x38E0, 1); + this->unk_34A = CLAMP(this->unk_34A, -0x38E0, 0x38E0); + + sp40 = player->actor.world.pos; + sp40.y = player->bodyPartsPos[7].y + 3.0f; + + sp34 = this->actor.world.pos; + sp34.y += 30.0f; + + Math_SmoothStepToS(&this->unk_348, Math_Vec3f_Pitch(&sp34, &sp40), 4, 0x1C70, 1); + this->unk_348 = CLAMP(this->unk_348, -0x1C70, 0x1C70); +} + +s32 func_80B768F0(EnTruMt* this, GlobalContext* globalCtx) { + if (this->unk_328 & 0x10) { + func_80B7679C(this, globalCtx); + } + return true; +} + +void func_80B76924(EnTruMt* this) { + this->unk_38E.z = Math_SinS(this->unk_388) * 30.0f * (0x10000 / 360.0f); + this->unk_388 += 0x400; +} + +void func_80B76980(EnTruMt* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (gSaveContext.unk_3F3C >= 10) { + Message_StartTextbox(globalCtx, 0x87F, &this->actor); + gSaveContext.eventInf[3] |= 0x40; + gSaveContext.eventInf[4] |= 1; + player->stateFlags3 &= ~0x400; + this->actor.speedXZ = 0.0f; + this->actionFunc = func_80B76BB8; + } else if (gSaveContext.eventInf[4] & 1) { + u32 score = gSaveContext.minigameScore; + + if (((gSaveContext.save.unk_EE8 & 0xFFFF0000) >> 0x10) < score) { + gSaveContext.save.unk_EE8 = + ((gSaveContext.minigameScore & 0xFFFF) << 0x10) | (gSaveContext.save.unk_EE8 & 0xFFFF); + gSaveContext.eventInf[3] |= 0x80; + } + } +} + +void func_80B76A64(EnTruMt* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3s sp34; + + func_80B76924(this); + func_80B76980(this, globalCtx); + player->stateFlags3 |= 0x400; + + if (this->path != NULL) { + func_80B76540(this->path, this->unk_36C, &this->actor.world.pos, &sp34); + Math_SmoothStepToS(&this->actor.world.rot.y, sp34.y, 4, 0x3E8, 1); + this->actor.shape.rot.y = this->actor.world.rot.y; + Math_SmoothStepToS(&this->actor.shape.rot.x, sp34.x, 4, 0x3E8, 1); + + this->actor.world.rot.x = -this->actor.shape.rot.x; + this->actor.shape.rot.z = CLAMP(this->actor.world.rot.y, -0x1770, 0x1770); + this->actor.world.rot.z = this->actor.shape.rot.z; + + if (func_80B76600(this, this->path, this->unk_36C)) { + if (this->unk_36C >= (this->path->count - 1)) { + this->actionFunc = func_80B76C38; + this->actor.speedXZ = 0.0f; + return; + } + this->unk_36C++; + } + func_80B76440(this, globalCtx); + } +} + +void func_80B76BB8(EnTruMt* this, GlobalContext* globalCtx) { + if (Message_GetState(&globalCtx->msgCtx) == 5) { + if (Message_ShouldAdvance(globalCtx)) { + globalCtx->nextEntranceIndex = 0xA810; + globalCtx->unk_1887F = 3; + gSaveContext.nextTransition = 3; + globalCtx->sceneLoadFlag = 0x14; + } + } +} + +void func_80B76C38(EnTruMt* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + func_80B76924(this); + func_80B76980(this, globalCtx); + player->stateFlags3 |= 0x400; +} + +void EnTruMt_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnTruMt* this = THIS; + + if (!(gSaveContext.eventInf[3] & 0x20)) { + Actor_MarkForDeath(&this->actor); + return; + } + + if (func_80B763C4(this, globalCtx)) { + Actor_MarkForDeath(&this->actor); + return; + } + + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_tru_Skel_01AA60, NULL, this->jointTable, this->morphTable, + OBJECT_TRU_LIMB_MAX); + + Collider_InitSphere(globalCtx, &this->collider); + Collider_SetSphere(globalCtx, &this->collider, &this->actor, &sSphereInit); + + this->collider.dim.worldSphere.radius = 22; + this->actor.colChkInfo.damageTable = &sDamageTable; + this->path = SubS_GetPathByIndex(globalCtx, ENTRUMT_GET_FF(&this->actor), 0x3F); + this->actor.targetMode = 0; + + Actor_SetScale(&this->actor, 0.008f); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + + this->unk_328 = 0; + this->actor.room = -1; + this->path = SubS_GetPathByIndex(globalCtx, ENTRUMT_GET_FC00(&this->actor), 0x3F); + func_80B76030(&this->skelAnime, 14); + this->actionFunc = func_80B76A64; +} + +void EnTruMt_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnTruMt* this = THIS; + + Collider_DestroySphere(globalCtx, &this->collider); +} + +void EnTruMt_Update(Actor* thisx, GlobalContext* globalCtx) { + EnTruMt* this = THIS; + + func_80B768F0(this, globalCtx); + SkelAnime_Update(&this->skelAnime); + + this->actionFunc(this, globalCtx); + + func_80B76110(this); + Actor_SetFocus(&this->actor, 34.0f); + + if (!(gSaveContext.eventInf[4] & 1)) { + func_80B761FC(this, globalCtx); + } + + Actor_MoveWithoutGravity(&this->actor); +} + +void func_80B76ED4(s16 arg0, s16 arg1, Vec3f* arg2, Vec3s* arg3, s32 arg4) { + Vec3f sp7C; + Vec3f sp70 = gZeroVec3f; + Vec3s sp68; + MtxF sp28; + + Matrix_MultiplyVector3fByState(&sp70, &sp7C); + Matrix_CopyCurrentState(&sp28); + func_8018219C(&sp28, &sp68, 0); + + *arg2 = sp7C; + + if (arg4 != 0) { + sp68.x += arg0; + sp68.y += arg1; + Math_SmoothStepToS(&arg3->x, sp68.x, 4, 0x1FFE, 1); + Math_SmoothStepToS(&arg3->y, sp68.y, 4, 0x1FFE, 1); + Math_SmoothStepToS(&arg3->z, sp68.z, 4, 0x1FFE, 1); + } else { + arg3->x = sp68.x; + arg3->y = sp68.y; + arg3->z = sp68.z; + } +} + +s32 EnTruMt_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnTruMt* this = THIS; + + if (limbIndex == OBJECT_TRU_LIMB_15) { + Matrix_MultiplyVector3fByState(&gZeroVec3f, &this->unk_35C); + } + + if (limbIndex == OBJECT_TRU_LIMB_15) { + Matrix_MultiplyVector3fByState(&D_80B7765C, &this->unk_350); + } + return false; +} + +void EnTruMt_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + s32 pad; + EnTruMt* this = THIS; + MtxF* sp54; + s32 phi_v0; + + if (limbIndex == OBJECT_TRU_LIMB_15) { + if (this->unk_328 & 0x10) { + phi_v0 = 1; + } else { + phi_v0 = 0; + } + func_80B76ED4(this->unk_348, this->unk_34A, &this->unk_33C, &this->unk_336, phi_v0); + Matrix_InsertTranslation(this->unk_33C.x, this->unk_33C.y, this->unk_33C.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateY(this->unk_336.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_336.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_336.z, MTXMODE_APPLY); + } + + if (limbIndex == OBJECT_TRU_LIMB_0E) { + func_8012C28C(globalCtx->state.gfxCtx); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_MultiplyVector3fByState(&D_80B77668, &this->unk_370); + Matrix_InsertTranslation(this->unk_370.x, this->unk_370.y, this->unk_370.z, MTXMODE_NEW); + Matrix_RotateY(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_38E.z, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_38E.x, MTXMODE_APPLY); + Matrix_Scale(0.008f, 0.008f, 0.008f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_tru_DL_0004C8); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + sp54 = Matrix_GetCurrentState(); + if ((this->actor.child == NULL) || (this->actor.child->update == NULL)) { + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_JC_MATO, sp54->wx, sp54->wy, + sp54->wz, this->unk_38E.x, BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), + this->unk_38E.z, -1); + } else if (!((EnJcMato*)this->actor.child)->hitFlag) { + this->actor.child->world.pos.x = sp54->wx; + this->actor.child->world.pos.y = sp54->wy; + this->actor.child->world.pos.z = sp54->wz; + + this->actor.child->world.rot = this->unk_38E; + this->actor.child->world.rot.y = BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))); + + this->actor.child->shape.rot = this->actor.child->world.rot; + } + } +} + +void EnTruMt_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { + EnTruMt* this = THIS; + + if (limbIndex == OBJECT_TRU_LIMB_15) { + Matrix_InsertTranslation(this->unk_33C.x, this->unk_33C.y, this->unk_33C.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateY(this->unk_336.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_336.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_336.z, MTXMODE_APPLY); + } +} + +void EnTruMt_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnTruMt* this = THIS; + TexturePtr sp48[] = { + object_tru_Tex_018FA0, + object_tru_Tex_0197A0, + object_tru_Tex_019FA0, + }; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sp48[this->unk_34C])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(sp48[this->unk_34C])); + + SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, EnTruMt_OverrideLimbDraw, EnTruMt_PostLimbDraw, + EnTruMt_TransformLimbDraw, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.h b/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.h index 793958ed74..049c11ecdc 100644 --- a/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.h +++ b/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.h @@ -2,15 +2,43 @@ #define Z_EN_TRU_MT_H #include "global.h" +#include "objects/object_tru/object_tru.h" struct EnTruMt; typedef void (*EnTruMtActionFunc)(struct EnTruMt*, GlobalContext*); +#define ENTRUMT_GET_FF(thisx) ((thisx)->params & 0xFF) +#define ENTRUMT_GET_FC00(thisx) (((thisx)->params & 0xFC00) >> 0xA) + typedef struct EnTruMt { /* 0x0000 */ Actor actor; /* 0x0144 */ EnTruMtActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x260]; + /* 0x0148 */ SkelAnime skelAnime; + /* 0x018C */ ColliderSphere collider; + /* 0x01E4 */ Vec3s jointTable[OBJECT_TRU_LIMB_MAX]; + /* 0x0286 */ Vec3s morphTable[OBJECT_TRU_LIMB_MAX]; + /* 0x0328 */ u16 unk_328; + /* 0x032A */ UNK_TYPE1 unk32A[0xC]; + /* 0x0336 */ Vec3s unk_336; + /* 0x033C */ Vec3f unk_33C; + /* 0x0348 */ s16 unk_348; + /* 0x034A */ s16 unk_34A; + /* 0x034C */ s16 unk_34C; + /* 0x034E */ s16 unk_34E; + /* 0x0350 */ Vec3f unk_350; + /* 0x035C */ Vec3f unk_35C; + /* 0x0368 */ Path* path; + /* 0x036C */ s32 unk_36C; + /* 0x0370 */ Vec3f unk_370; + /* 0x037C */ UNK_TYPE1 unk37C[0xC]; + /* 0x0388 */ s16 unk_388; + /* 0x038A */ s16 unk_38A; + /* 0x038C */ s16 unk_38C; + /* 0x038E */ Vec3s unk_38E; + /* 0x0394 */ s16 unk_394; + /* 0x0398 */ Vec3f unk_398; + /* 0x03A4 */ u8 unk_3A4; } EnTruMt; // size = 0x3A8 extern const ActorInit En_Tru_Mt_InitVars; diff --git a/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c b/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c index 022aa44bcb..7a3075fe72 100644 --- a/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c +++ b/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c @@ -5,6 +5,7 @@ */ #include "z_en_tsn.h" +#include "objects/object_tsn/object_tsn.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_2000000) @@ -15,7 +16,18 @@ void EnTsn_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnTsn_Update(Actor* thisx, GlobalContext* globalCtx); void EnTsn_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80AE0010(EnTsn* this, GlobalContext* globalCtx); +void func_80AE0304(EnTsn* this, GlobalContext* globalCtx); +void func_80AE0418(EnTsn* this, GlobalContext* globalCtx); +void func_80AE0460(EnTsn* this, GlobalContext* globalCtx); +void func_80AE04C4(EnTsn* this, GlobalContext* globalCtx); +void func_80AE04FC(EnTsn* this, GlobalContext* globalCtx); +void func_80AE0704(EnTsn* this, GlobalContext* globalCtx); +void func_80AE0C88(EnTsn* this, GlobalContext* globalCtx); +void func_80AE0D10(EnTsn* this, GlobalContext* globalCtx); +void func_80AE0D78(EnTsn* this, GlobalContext* globalCtx); +void func_80AE0F84(Actor* thisx, GlobalContext* globalCtx); + const ActorInit En_Tsn_InitVars = { ACTOR_EN_TSN, ACTORCAT_NPC, @@ -28,58 +40,597 @@ const ActorInit En_Tsn_InitVars = { (ActorFunc)EnTsn_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80AE1190 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_ENEMY, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_ENEMY, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 30, 40, 0, { 0, 0, 0 } }, }; -#endif +Vec3f D_80AE11BC = { 0.0f, 0.0f, 0.0f }; -extern ColliderCylinderInit D_80AE1190; +TexturePtr D_80AE11C8[] = { object_tsn_Tex_0073B8, object_tsn_Tex_0085B8 }; -extern UNK_TYPE D_06001198; -extern UNK_TYPE D_060092FC; +EnTsn* func_80ADFCA0(GlobalContext* globalCtx) { + Actor* npc = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80ADFCA0.s") + while (npc != NULL) { + if ((npc->id == ACTOR_EN_TSN) && !ENTSN_GET_100(npc)) { + return (EnTsn*)npc; + } + npc = npc->next; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80ADFCEC.s") + return NULL; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/EnTsn_Init.s") +void func_80ADFCEC(EnTsn* this, GlobalContext* globalCtx) { + this->actionFunc = func_80AE0C88; + this->actor.update = func_80AE0F84; + this->actor.destroy = NULL; + this->actor.draw = NULL; + this->actor.targetMode = 7; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/EnTsn_Destroy.s") + switch (ENTSN_GET_F(&this->actor)) { + case ENTSN_F_0: + if (gSaveContext.save.weekEventReg[26] & 8) { + Actor_MarkForDeath(&this->actor); + return; + } + this->actor.textId = 0x106E; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80ADFF84.s") + case ENTSN_F_1: + if (gSaveContext.save.weekEventReg[26] & 4) { + this->actor.textId = 0x1091; + } else { + this->actor.textId = 0x108A; + } + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80AE0010.s") + if (gSaveContext.save.weekEventReg[55] & 0x80) { + if ((ENTSN_GET_F(&this->actor)) == ENTSN_F_0) { + this->actionFunc = func_80AE0D78; + } else { + Actor_MarkForDeath(&this->actor); + } + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80AE0304.s") + this->unk_1D8 = func_80ADFCA0(globalCtx); + this->unk_220 = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80AE0418.s") + if (this->unk_1D8 == NULL) { + Actor_MarkForDeath(&this->actor); + } else if ((ENTSN_GET_F(&this->actor)) == ENTSN_F_1) { + func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, 6); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80AE0460.s") +void EnTsn_Init(Actor* thisx, GlobalContext* globalCtx) { + EnTsn* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80AE04C4.s") + if (ENTSN_GET_100(&this->actor)) { + func_80ADFCEC(this, globalCtx); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80AE04FC.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_tsn_Skel_008AB8, &object_tsn_Anim_0092FC, NULL, NULL, 0); + Animation_PlayLoop(&this->skelAnime, &object_tsn_Anim_0092FC); + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80AE0698.s") + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->unk_220 = 0; + this->actionFunc = func_80AE0304; + this->actor.textId = 0; + this->actor.velocity.y = 0.0f; + this->actor.terminalVelocity = -9.0f; + this->actor.gravity = -1.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80AE0704.s") + if (gSaveContext.save.weekEventReg[55] & 0x80) { + Actor_MarkForDeath(&this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80AE0C88.s") +void EnTsn_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnTsn* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80AE0D10.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80AE0D78.s") +void func_80ADFF84(EnTsn* this, GlobalContext* globalCtx) { + u16 textId; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/EnTsn_Update.s") + if (gSaveContext.save.weekEventReg[26] & 8) { + textId = 0x107E; + } else if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.weekEventReg[25] & 0x80) { + textId = 0x1083; + } else { + textId = 0x107F; + } + } else if (gSaveContext.save.weekEventReg[26] & 1) { + textId = 0x1089; + } else { + textId = 0x1084; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80AE0F84.s") + Message_StartTextbox(globalCtx, textId, &this->actor); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80AE0FA8.s") +void func_80AE0010(EnTsn* this, GlobalContext* globalCtx) { + switch (globalCtx->msgCtx.currentTextId) { + case 0x107F: + case 0x1080: + case 0x1081: + case 0x1082: + case 0x1083: + case 0x1084: + case 0x1085: + case 0x1086: + case 0x1087: + case 0x1088: + case 0x1089: + case 0x1093: + Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 6, 0x1838, 0x64); + this->actor.shape.rot.y = this->actor.world.rot.y; + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80AE1024.s") + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { + case 0x107F: + case 0x1081: + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/EnTsn_Draw.s") + case 0x1080: + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + Animation_MorphToLoop(&this->skelAnime, &object_tsn_Anim_001198, -10.0f); + break; + + case 0x1082: + Animation_MorphToLoop(&this->skelAnime, &object_tsn_Anim_0092FC, -10.0f); + gSaveContext.save.weekEventReg[25] |= 0x80; + func_801477B4(globalCtx); + this->actionFunc = func_80AE0304; + this->actor.textId = 0; + break; + + case 0x1083: + gSaveContext.save.weekEventReg[25] |= 0x80; + func_801477B4(globalCtx); + this->actionFunc = func_80AE0304; + this->actor.textId = 0; + break; + + case 0x1084: + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + Animation_MorphToLoop(&this->skelAnime, &object_tsn_Anim_000964, -10.0f); + break; + + case 0x1085: + case 0x1086: + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + break; + + case 0x1089: + case 0x1093: + gSaveContext.save.weekEventReg[26] |= 1; + func_801477B4(globalCtx); + Animation_MorphToLoop(&this->skelAnime, &object_tsn_Anim_0092FC, -10.0f); + this->actionFunc = func_80AE0304; + this->actor.textId = 0; + break; + + case 0x1087: + Animation_MorphToLoop(&this->skelAnime, &object_tsn_Anim_001198, -10.0f); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + break; + + case 0x1088: + gSaveContext.save.weekEventReg[26] |= 1; + if (INV_CONTENT(ITEM_MASK_ZORA) == ITEM_MASK_ZORA) { + func_801477B4(globalCtx); + Animation_MorphToLoop(&this->skelAnime, &object_tsn_Anim_0092FC, -10.0f); + this->actionFunc = func_80AE0304; + this->actor.textId = 0; + } else { + func_80151938(globalCtx, 0x1093); + Animation_MorphToLoop(&this->skelAnime, &object_tsn_Anim_0092FC, -10.0f); + } + break; + + case 0x107E: + func_801477B4(globalCtx); + this->actionFunc = func_80AE0304; + this->actor.textId = 0; + break; + } + } +} + +void func_80AE0304(EnTsn* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = func_80AE0010; + this->unk_220 |= 1; + if (this->actor.textId == 0) { + func_80ADFF84(this, globalCtx); + } + } else if ((this->actor.xzDistToPlayer < 150.0f) && Player_IsFacingActor(&this->actor, 0x3000, globalCtx)) { + func_800B8614(&this->actor, globalCtx, 160.0f); + this->unk_220 |= 1; + } else { + this->unk_220 &= ~1; + } + if (ENTSN_GET_Z(&this->actor)) { + Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 6, 0x1838, 0x64); + } else { + Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.home.rot.y, 6, 0x1838, 0x64); + } + this->actor.shape.rot.y = this->actor.world.rot.y; +} + +void func_80AE0418(EnTsn* this, GlobalContext* globalCtx) { + if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { + Message_StartTextbox(globalCtx, 0x107D, NULL); + Actor_MarkForDeath(&this->actor); + } +} + +void func_80AE0460(EnTsn* this, GlobalContext* globalCtx) { + if (Actor_HasParent(&this->actor, globalCtx)) { + ENTSN_SET_Z(&this->unk_1D8->actor, false); + this->actionFunc = func_80AE0418; + } else { + Actor_PickUp(&this->actor, globalCtx, GI_SEAHORSE, 2000.0f, 1000.0f); + } +} + +void func_80AE04C4(EnTsn* this, GlobalContext* globalCtx) { + if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { + this->actionFunc = func_80AE0C88; + } +} + +void func_80AE04FC(EnTsn* this, GlobalContext* globalCtx) { + s32 sp24; + Player* player = GET_PLAYER(globalCtx); + + if (Message_GetState(&globalCtx->msgCtx) == 0x10) { + sp24 = func_80123810(globalCtx); + if (sp24 != 0) { + gSaveContext.save.weekEventReg[26] |= 2; + } + + if (sp24 > 0) { + func_801477B4(globalCtx); + this->actionFunc = func_80AE0704; + if (sp24 == 19) { + if (CHECK_QUEST_ITEM(QUEST_UNK_19)) { + if (func_8013A4C4(1 | 8)) { + player->actor.textId = 0x107B; + return; + } + + if (func_8013A4C4(1 | 2 | 8)) { + player->actor.textId = 0x10A9; + return; + } + + player->actor.textId = 0x1078; + this->unk_220 |= 8; + return; + } + + player->actor.textId = 0x1078; + this->unk_220 |= 8; + return; + } + + if (sp24 == 13) { + player->actor.textId = 0x1075; + return; + } + + player->actor.textId = 0x1078; + this->unk_220 |= 8; + return; + } + + if (sp24 < 0) { + func_80151938(globalCtx, 0x1078); + Animation_MorphToLoop(&this->unk_1D8->skelAnime, &object_tsn_Anim_001198, -10.0f); + this->actionFunc = func_80AE0704; + } + } +} + +void func_80AE0698(EnTsn* this, GlobalContext* globalCtx) { + func_801477B4(globalCtx); + this->actionFunc = func_80AE0C88; + this->unk_220 &= ~2; + this->actor.focus.pos = this->actor.world.pos; + ActorCutscene_Stop(this->actor.cutscene); + ENTSN_SET_Z(&this->unk_1D8->actor, false); +} + +void func_80AE0704(EnTsn* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 pad[2]; + + if ((this->unk_220 & 8) && (globalCtx->msgCtx.currentTextId == 0x1078)) { + this->unk_220 &= ~8; + Animation_MorphToLoop(&this->unk_1D8->skelAnime, &object_tsn_Anim_001198, -10.0f); + } + + switch (Message_GetState(&globalCtx->msgCtx)) { + case 2: + break; + + case 5: + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { + case 0x106E: + if (gSaveContext.save.weekEventReg[25] & 0x40) { + func_80151938(globalCtx, 0x1074); + } else { + func_80151938(globalCtx, 0x106F); + } + this->unk_220 |= 2; + gSaveContext.save.weekEventReg[25] |= 0x40; + ENTSN_SET_Z(&this->unk_1D8->actor, true); + this->unk_220 |= 4; + break; + + case 0x106F: + case 0x1070: + case 0x1071: + case 0x1072: + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + break; + + case 0x1076: + case 0x1079: + Animation_MorphToLoop(&this->unk_1D8->skelAnime, &object_tsn_Anim_000964, -10.0f); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + break; + + case 0x107A: + func_80151938(globalCtx, 0x10A6); + break; + + case 0x1075: + case 0x1078: + player->exchangeItemId = 0; + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + Animation_MorphToLoop(&this->unk_1D8->skelAnime, &object_tsn_Anim_0092FC, -10.0f); + break; + + case 0x107C: + if (Interface_HasEmptyBottle()) { + gSaveContext.save.weekEventReg[26] |= 8; + func_801477B4(globalCtx); + this->actionFunc = func_80AE0460; + func_80AE0460(this, globalCtx); + this->unk_220 &= ~2; + this->actor.focus.pos = this->actor.world.pos; + ActorCutscene_Stop(this->actor.cutscene); + this->actor.flags &= ~ACTOR_FLAG_100; + REMOVE_QUEST_ITEM(QUEST_UNK_19); + } else { + func_80151938(globalCtx, 0x10A8); + } + break; + + case 0x1073: + case 0x1074: + func_80151938(globalCtx, 0xFF); + this->actionFunc = func_80AE04FC; + break; + + case 0x107B: + player->exchangeItemId = 0; + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + Animation_MorphToLoop(&this->unk_1D8->skelAnime, &object_tsn_Anim_0092FC, -10.0f); + break; + + case 0x1077: + case 0x10A6: + case 0x10A8: + Animation_MorphToLoop(&this->unk_1D8->skelAnime, &object_tsn_Anim_0092FC, -10.0f); + func_80AE0698(this, globalCtx); + this->actor.flags &= ~ACTOR_FLAG_100; + this->actionFunc = func_80AE04C4; + break; + + case 0x108A: + case 0x1091: + gSaveContext.save.weekEventReg[26] |= 4; + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + this->unk_220 |= 2; + this->actor.textId = 0x1091; + break; + + case 0x108B: + case 0x108C: + case 0x108D: + case 0x108E: + case 0x108F: + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + break; + + case 0x1092: + if (gSaveContext.save.weekEventReg[26] & 8) { + func_80AE0698(this, globalCtx); + } else { + func_80151938(globalCtx, 0x10A7); + Animation_MorphToLoop(&this->unk_1D8->skelAnime, &object_tsn_Anim_000964, -10.0f); + } + break; + + case 0x10A7: + Animation_MorphToLoop(&this->unk_1D8->skelAnime, &object_tsn_Anim_0092FC, -10.0f); + func_80AE0698(this, globalCtx); + break; + + case 0x1090: + func_80AE0698(this, globalCtx); + break; + + case 0x10A9: + func_80AE0698(this, globalCtx); + this->actor.flags &= ~ACTOR_FLAG_100; + this->actionFunc = func_80AE04C4; + break; + } + } + } + + if (this->unk_220 & 2) { + if (this->unk_1D8 != NULL) { + Math_SmoothStepToF(&this->actor.focus.pos.x, this->unk_1D8->actor.focus.pos.x, 0.8f, 100.0f, 5.0f); + Math_SmoothStepToF(&this->actor.focus.pos.y, this->unk_1D8->actor.focus.pos.y, 0.8f, 100.0f, 5.0f); + Math_SmoothStepToF(&this->actor.focus.pos.z, this->unk_1D8->actor.focus.pos.z, 0.8f, 100.0f, 5.0f); + } + } + + if (this->unk_220 & 4) { + if (this->actor.cutscene == -1) { + this->unk_220 &= ~4; + } else if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + this->unk_220 &= ~4; + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } + } +} + +void func_80AE0C88(EnTsn* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = func_80AE0704; + if ((this->actor.textId == 0x108A) || (this->actor.textId == 0x1091)) { + this->unk_220 |= 4; + ENTSN_SET_Z(&this->unk_1D8->actor, true); + } + } else if (this->actor.isTargeted) { + func_800B8614(&this->actor, globalCtx, 1000.0f); + } +} + +void func_80AE0D10(EnTsn* this, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + func_801477B4(globalCtx); + this->actionFunc = func_80AE0D78; + ActorCutscene_Stop(this->actor.cutscene); + } +} + +void func_80AE0D78(EnTsn* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = func_80AE0D10; + this->unk_220 |= 4; + } else if (this->actor.isTargeted) { + func_800B8614(&this->actor, globalCtx, 1000.0f); + } +} + +void EnTsn_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnTsn* this = THIS; + + this->actionFunc(this, globalCtx); + + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 25.0f, 0.0f, 4); + SkelAnime_Update(&this->skelAnime); + + if (this->unk_220 & 1) { + func_800E9250(globalCtx, &this->actor, &this->unk_222, &this->unk_228, this->actor.focus.pos); + } else { + Math_SmoothStepToS(&this->unk_222.x, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->unk_222.y, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->unk_228.x, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->unk_228.y, 0, 6, 0x1838, 0x64); + } + + if (DECR(this->unk_230) == 0) { + this->unk_230 = Rand_S16Offset(60, 60); + } + + if ((this->unk_230 == 1) || (this->unk_230 == 3)) { + this->unk_22E = 1; + } else { + this->unk_22E = 0; + } +} + +void func_80AE0F84(Actor* thisx, GlobalContext* globalCtx) { + EnTsn* this = THIS; + + this->actionFunc(this, globalCtx); +} + +s32 EnTsn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnTsn* this = THIS; + s16 shifted = this->unk_222.x >> 1; + + if (limbIndex == 15) { + rot->x += this->unk_222.y; + rot->z += shifted; + } + + if (limbIndex == 8) { + rot->x += this->unk_228.y; + rot->z += shifted; + } + return false; +} + +void EnTsn_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnTsn* this = THIS; + Vec3f sp18 = D_80AE11BC; + + if (limbIndex == 15) { + Matrix_MultiplyVector3fByState(&sp18, &this->actor.focus.pos); + } +} + +void EnTsn_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnTsn* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C5B0(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80AE11C8[this->unk_22E])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80AE11C8[this->unk_22E])); + + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnTsn_OverrideLimbDraw, EnTsn_PostLimbDraw, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Tsn/z_en_tsn.h b/src/overlays/actors/ovl_En_Tsn/z_en_tsn.h index 6b7810cf6b..64df6ac423 100644 --- a/src/overlays/actors/ovl_En_Tsn/z_en_tsn.h +++ b/src/overlays/actors/ovl_En_Tsn/z_en_tsn.h @@ -7,11 +7,26 @@ struct EnTsn; typedef void (*EnTsnActionFunc)(struct EnTsn*, GlobalContext*); +#define ENTSN_GET_F(thisx) ((thisx)->params & 0xF) +#define ENTSN_GET_100(thisx) ((thisx)->params & 0x100) +#define ENTSN_GET_Z(thisx) ((thisx)->home.rot.z) +#define ENTSN_SET_Z(thisx, state) ((thisx)->home.rot.z = state) + +#define ENTSN_F_0 0 +#define ENTSN_F_1 1 + typedef struct EnTsn { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x90]; + /* 0x0144 */ ColliderCylinder collider; + /* 0x0190 */ SkelAnime skelAnime; /* 0x01D4 */ EnTsnActionFunc actionFunc; - /* 0x01D8 */ char unk_1D8[0x5C]; + /* 0x01D8 */ struct EnTsn* unk_1D8; + /* 0x01DC */ UNK_TYPE1 unk1DC[0x44]; + /* 0x0220 */ u16 unk_220; + /* 0x0222 */ Vec3s unk_222; + /* 0x0228 */ Vec3s unk_228; + /* 0x022E */ s16 unk_22E; + /* 0x0230 */ s16 unk_230; } EnTsn; // size = 0x234 extern const ActorInit En_Tsn_InitVars; diff --git a/src/overlays/actors/ovl_En_Vm/z_en_vm.c b/src/overlays/actors/ovl_En_Vm/z_en_vm.c index 81ef8312b0..6103cb5773 100644 --- a/src/overlays/actors/ovl_En_Vm/z_en_vm.c +++ b/src/overlays/actors/ovl_En_Vm/z_en_vm.c @@ -5,6 +5,9 @@ */ #include "z_en_vm.h" +#include "overlays/actors/ovl_En_Bom/z_en_bom.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_vm/object_vm.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_400) @@ -15,7 +18,17 @@ void EnVm_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnVm_Update(Actor* thisx, GlobalContext* globalCtx); void EnVm_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_808CC420(EnVm* this); +void func_808CC490(EnVm* this, GlobalContext* globalCtx); +void func_808CC5C4(EnVm* this); +void func_808CC610(EnVm* this, GlobalContext* globalCtx); +void func_808CC788(EnVm* this); +void func_808CC820(EnVm* this, GlobalContext* globalCtx); +void func_808CCAA4(EnVm* this, GlobalContext* globalCtx); +void func_808CCB08(EnVm* this); +void func_808CCB50(EnVm* this, GlobalContext* globalCtx); +void func_808CCCF0(EnVm* this, GlobalContext* globalCtx); + const ActorInit En_Vm_InitVars = { ACTOR_EN_VM, ACTORCAT_ENEMY, @@ -28,40 +41,72 @@ const ActorInit En_Vm_InitVars = { (ActorFunc)EnVm_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[2] = { -static ColliderJntSphElementInit D_808CD4C0[2] = { +static ColliderJntSphElementInit sJntSphElementsInit[] = { { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 2, { { 0, 0, 0 }, 20 }, 100 }, }, { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 10, { { 0, 2300, 0 }, 33 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_808CD508 = { - { COLTYPE_METAL, AT_NONE, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 2, D_808CD4C0, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_METAL, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 2, + sJntSphElementsInit, }; -// static ColliderTrisElementInit sTrisElementsInit[1] = { -static ColliderTrisElementInit D_808CD518[1] = { +static ColliderTrisElementInit sTrisElementsInit[] = { { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, }, }; -// static ColliderTrisInit sTrisInit = { -static ColliderTrisInit D_808CD554 = { - { COLTYPE_METAL, AT_ON | AT_TYPE_ENEMY, AC_NONE, OC1_NONE, OC2_NONE, COLSHAPE_TRIS, }, - 1, D_808CD518, // sTrisElementsInit, +static ColliderTrisInit sTrisInit = { + { + COLTYPE_METAL, + AT_ON | AT_TYPE_ENEMY, + AC_NONE, + OC1_NONE, + OC2_NONE, + COLSHAPE_TRIS, + }, + 1, + sTrisElementsInit, }; -// static DamageTable sDamageTable = { -static DamageTable D_808CD564 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0xF), /* Deku Stick */ DMG_ENTRY(0, 0xF), /* Horse trample */ DMG_ENTRY(0, 0xF), @@ -96,62 +141,418 @@ static DamageTable D_808CD564 = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -// sColChkInfoInit -static CollisionCheckInfoInit D_808CD584 = { 2, 25, 100, MASS_IMMOVABLE }; +static CollisionCheckInfoInit sColChkInfoInit = { 2, 25, 100, MASS_IMMOVABLE }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808CD5AC[] = { +TexturePtr D_808CD58C[] = { + gameplay_keep_Tex_03F300, gameplay_keep_Tex_03FB00, gameplay_keep_Tex_040300, gameplay_keep_Tex_040B00, + gameplay_keep_Tex_041300, gameplay_keep_Tex_041B00, gameplay_keep_Tex_042300, gameplay_keep_Tex_042B00, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 14, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 1000, ICHAIN_CONTINUE), ICHAIN_S8(hintId, 57, ICHAIN_STOP), }; -#endif +s32 D_808CD5B8 = false; -extern ColliderJntSphElementInit D_808CD4C0[2]; -extern ColliderJntSphInit D_808CD508; -extern ColliderTrisElementInit D_808CD518[1]; -extern ColliderTrisInit D_808CD554; -extern DamageTable D_808CD564; -extern CollisionCheckInfoInit D_808CD584; -extern InitChainEntry D_808CD5AC[]; +Color_RGBA8 D_808CD5BC = { 0, 0, 255, 0 }; -extern UNK_TYPE D_06000068; +Color_RGBA8 D_808CD5C0 = { 255, 255, 255, 255 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/EnVm_Init.s") +void EnVm_Init(Actor* thisx, GlobalContext* globalCtx) { + EnVm* this = THIS; + s32 i; + s32 params; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/EnVm_Destroy.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 35.0f); + SkelAnime_Init(globalCtx, &this->skelAnime, &object_vm_Skel_003F60, &object_vm_Anim_000068, this->jointTable, + this->morphTable, 11); + Collider_InitAndSetTris(globalCtx, &this->colliderTris, &this->actor, &sTrisInit, this->colliderTrisElements); + Collider_InitAndSetJntSph(globalCtx, &this->colliderJntSph, &this->actor, &sJntSphInit, + this->colliderJntSphElements); + CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/func_808CC420.s") + params = ENVM_GET_FF00(thisx); + if ((params == ENVM_FF00_FF) || (params == ENVM_FF00_0)) { + params = ENVM_FF00_5; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/func_808CC490.s") + this->unk_21C = params * 40.0f; + thisx->params &= 0xFF; + this->actor.bgCheckFlags |= 0x400; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/func_808CC5C4.s") + if (!D_808CD5B8) { + for (i = 0; i < ARRAY_COUNT(D_808CD58C); i++) { + D_808CD58C[i] = Lib_SegmentedToVirtual(D_808CD58C[i]); + } + D_808CD5B8 = true; + } + func_808CC420(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/func_808CC610.s") +void EnVm_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnVm* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/func_808CC788.s") + Collider_DestroyTris(globalCtx, &this->colliderTris); + Collider_DestroyJntSph(globalCtx, &this->colliderJntSph); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/func_808CC820.s") +void func_808CC420(EnVm* this) { + f32 lastFrame = Animation_GetLastFrame(&object_vm_Anim_000068); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/func_808CCA10.s") + Animation_Change(&this->skelAnime, &object_vm_Anim_000068, 1.0f, lastFrame, lastFrame, ANIMMODE_ONCE, 0.0f); + this->actionFunc = func_808CC490; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/func_808CCAA4.s") +void func_808CC490(EnVm* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 sp22; + s16 temp_v0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/func_808CCB08.s") + Math_ApproachS(&this->unk_216, 0, 0xA, 0x5DC); + this->unk_218 -= 0x1F4; + func_800B9010(&this->actor, NA_SE_EN_BIMOS_ROLL_HEAD - SFX_FLAG); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/func_808CCB50.s") + if (this->actor.xzDistToPlayer <= this->unk_21C) { + if ((this->actor.playerHeightRel <= 80.0f) && (this->actor.playerHeightRel >= -160.0f)) { + sp22 = BINANG_SUB(this->actor.yawTowardsPlayer - this->unk_218, this->actor.shape.rot.y); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/func_808CCBE4.s") + temp_v0 = Math_Vec3f_Pitch(&this->actor.focus.pos, &player->actor.world.pos); + if (temp_v0 > 0x1B91) { + temp_v0 = 0x1B91; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/func_808CCCF0.s") + if ((ABS_ALT(sp22) <= 0x2710) && (temp_v0 >= 0xE38) && (Player_GetMask(globalCtx) != PLAYER_MASK_STONE)) { + func_808CC5C4(this); + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/func_808CCDE4.s") +void func_808CC5C4(EnVm* this) { + Animation_PlayLoopSetSpeed(&this->skelAnime, &object_vm_Anim_000068, 2.0f); + this->unk_214 = 10; + this->actionFunc = func_808CC610; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/EnVm_Update.s") +void func_808CC610(EnVm* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 sp3A; + s16 sp38; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/func_808CD020.s") + SkelAnime_Update(&this->skelAnime); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/func_808CD08C.s") + sp38 = Math_Vec3f_Pitch(&this->actor.focus.pos, &player->actor.world.pos); + sp38 = CLAMP_MAX(sp38, 0x1B91); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/EnVm_Draw.s") + sp3A = BINANG_ADD((s32)((this->unk_21C - this->actor.xzDistToPlayer) * 60.0f), 4000); + sp3A = CLAMP_MAX(sp3A, 0x1000); + + Math_SmoothStepToS(&this->unk_216, sp38, 10, 4000, 0); + + if ((sp38 < 0xAAA) || (sp3A <= 0)) { + func_808CC420(this); + } else if (Math_ScaledStepToS(&this->unk_218, BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y), + sp3A)) { + this->unk_214--; + if (this->unk_214 == 0) { + EffectSsDeadDd_Spawn(globalCtx, &this->unk_228, &gZeroVec3f, &gZeroVec3f, &D_808CD5BC, &D_808CD5C0, 150, + -25, 16, 20); + func_808CC788(this); + } + } +} + +void func_808CC788(EnVm* this) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BIMOS_AIM); + Animation_Change(&this->skelAnime, &object_vm_Anim_000068, 3.0f, 3.0f, 7.0f, ANIMMODE_ONCE, 0.0f); + this->unk_214 = 305; + this->unk_220 = 0.06f; + this->colliderTris.base.atFlags &= ~AT_HIT; + this->actionFunc = func_808CC820; +} + +void func_808CC820(EnVm* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 sp32; + f32 temp_f2; + + if (SkelAnime_Update(&this->skelAnime)) { + this->skelAnime.curFrame = this->skelAnime.startFrame; + } + + sp32 = Math_Vec3f_Pitch(&this->actor.focus.pos, &player->actor.world.pos); + sp32 = CLAMP_MAX(sp32, 0x1B91); + + if (this->colliderTris.base.atFlags & AT_HIT) { + this->colliderTris.base.atFlags &= ~AT_HIT; + this->unk_214 = 0; + if (this->unk_220 > 0.01f) { + this->unk_220 = 0.01f; + } + } + + if ((this->unk_216 < 0xAAA) || (Player_GetMask(globalCtx) == PLAYER_MASK_STONE) || (this->unk_214 == 0)) { + this->unk_214 = 0; + if (Math_StepToF(&this->unk_220, 0.0f, 0.003f)) { + this->unk_210 = 0; + this->unk_224 = 0.0f; + func_808CC420(this); + } + } else { + this->unk_214--; + if (this->unk_214 <= 300) { + Math_ApproachS(&this->unk_218, this->actor.yawTowardsPlayer - this->actor.shape.rot.y, 0xA, 0xDAC); + Math_ApproachS(&this->unk_216, sp32, 0xA, 0xDAC); + + temp_f2 = Math_Vec3f_DistXYZ(&this->actor.focus.pos, &player->actor.world.pos) + 40.0f; + if (this->unk_224 < temp_f2) { + Math_StepToF(&this->unk_224, temp_f2, 40.0f); + } + + Math_StepToF(&this->unk_220, 0.01f, 0.012f); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderTris.base); + + if (this->unk_210 == 0) { + this->unk_210 = 1; + } + } + } +} + +void func_808CCA10(EnVm* this) { + Animation_Change(&this->skelAnime, &object_vm_Anim_000068, -1.0f, Animation_GetLastFrame(&object_vm_Anim_000068), + 0.0f, ANIMMODE_ONCE, 0.0f); + this->unk_214 = 100; + this->unk_210 = 0; + this->unk_224 = 0.0f; + this->unk_220 = 0.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + this->actionFunc = func_808CCAA4; +} + +void func_808CCAA4(EnVm* this, GlobalContext* globalCtx) { + Math_ApproachS(&this->unk_216, 0, 0xA, 0x5DC); + SkelAnime_Update(&this->skelAnime); + if (this->unk_214 == 0) { + func_808CCB08(this); + } else { + this->unk_214--; + } +} + +void func_808CCB08(EnVm* this) { + Animation_PlayOnce(&this->skelAnime, &object_vm_Anim_000068); + this->unk_214 = -1; + this->actionFunc = func_808CCB50; +} + +void func_808CCB50(EnVm* this, GlobalContext* globalCtx) { + Math_ApproachS(&this->unk_216, 0, 0xA, 0x5DC); + + if (this->unk_214 > 0) { + this->unk_214--; + } else if (SkelAnime_Update(&this->skelAnime)) { + if (this->unk_214 == -1) { + this->unk_214 = 10; + this->skelAnime.curFrame = 0.0f; + this->skelAnime.playSpeed = 2.0f; + } else { + func_808CC420(this); + } + } +} + +void func_808CCBE4(EnVm* this, GlobalContext* globalCtx) { + Animation_Change(&this->skelAnime, &object_vm_Anim_000068, -1.0f, Animation_GetLastFrame(&object_vm_Anim_000068), + 0.0f, ANIMMODE_ONCE, 0.0f); + Enemy_StartFinishingBlow(globalCtx, &this->actor); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 33); + this->unk_214 = 33; + this->unk_220 = 0.0f; + this->unk_224 = 0.0f; + this->actor.shape.yOffset = (this->actor.world.pos.y - this->actor.focus.pos.y) * 71.428566f; + this->actor.world.pos.y = this->actor.focus.pos.y; + this->actor.velocity.y = 8.0f; + this->actor.gravity = -0.5f; + this->actor.speedXZ = Rand_ZeroOne() + 1.0f; + this->unk_210 = 0; + this->actor.flags |= ACTOR_FLAG_10; + this->actionFunc = func_808CCCF0; +} + +void func_808CCCF0(EnVm* this, GlobalContext* globalCtx) { + this->unk_216 += 0x5DC; + this->unk_218 += 0x9C4; + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 20.0f, 40.0f, 7); + + this->unk_214--; + if (this->unk_214 == 1) { + EnBom* bomb = (EnBom*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0x6FF, 0); + + if (bomb != NULL) { + bomb->timer = 0; + } + } else if (this->unk_214 == 0) { + Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0xB0); + Actor_MarkForDeath(&this->actor); + } +} + +void func_808CCDE4(EnVm* this, GlobalContext* globalCtx) { + s32 i; + s16 temp_v0; + + if (this->colliderJntSph.base.acFlags & AC_HIT) { + this->colliderJntSph.base.acFlags &= ~AC_HIT; + + for (i = 0; i < ARRAY_COUNT(this->colliderJntSphElements); i++) { + if (this->colliderJntSph.elements[i].info.bumperFlags & BUMP_HIT) { + break; + } + } + + if (i != ARRAY_COUNT(this->colliderJntSphElements)) { + func_800BE5CC(&this->actor, &this->colliderJntSph, i); + if (this->actor.colChkInfo.damageEffect == 0) { + func_808CCBE4(this, globalCtx); + } else if ((i == 0) && (this->actionFunc != func_808CCAA4)) { + temp_v0 = (this->actor.world.rot.y - this->actor.shape.rot.y) - this->unk_218; + if (ABS_ALT(temp_v0) > 0x6000) { + func_808CCA10(this); + } + } + } + } +} + +void EnVm_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnVm* this = THIS; + + func_808CCDE4(this, globalCtx); + + if (this->unk_210 == 2) { + func_800B31BC(globalCtx, &this->unk_234, 20, -1, 155, 10); + if ((globalCtx->gameplayFrames % 2) != 0) { + func_800BBFB0(globalCtx, &this->unk_234, 6.0f, 1, 120, 20, 1); + } + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BIMOS_LAZER_GND - SFX_FLAG); + } + + if (this->unk_224 > 0.0f) { + func_800B9010(&this->actor, NA_SE_EN_BIMOS_LAZER - SFX_FLAG); + } + + this->actionFunc(this, globalCtx); + + this->unk_212 += 12; + + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderJntSph.base); + if (this->actionFunc != func_808CCCF0) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderJntSph.base); + } +} + +s32 EnVm_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnVm* this = THIS; + + if (limbIndex == OBJECT_VM_LIMB_02) { + rot->x += this->unk_216; + rot->y += this->unk_218; + } else if ((limbIndex == OBJECT_VM_LIMB_0A) && (this->actionFunc == func_808CCCF0)) { + *dList = NULL; + } + return false; +} + +void EnVm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + s32 pad; + EnVm* this = THIS; + Vec3f sp5C; + Vec3f sp50; + CollisionPoly* sp4C; + s32 sp48; + + Collider_UpdateSpheres(limbIndex, &this->colliderJntSph); + + if (limbIndex == OBJECT_VM_LIMB_02) { + sp4C = NULL; + + Matrix_GetStateTranslation(&this->actor.focus.pos); + Matrix_GetStateTranslationAndScaledZ(1600.0f, &this->unk_228); + Matrix_GetStateTranslationAndScaledZ(this->unk_224 * 71.428566f, &this->unk_234); + + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.focus.pos, &this->unk_234, &sp5C, &sp4C, true, + true, false, true, &sp48)) { + this->unk_224 = Math_Vec3f_DistXYZ(&this->actor.focus.pos, &sp5C) - 5.0f; + this->unk_210 = 2; + Math_Vec3f_Copy(&this->unk_234, &sp5C); + } else if (this->unk_210 != 0) { + this->unk_210 = 1; + } + + sp50.x = this->unk_234.x + (Math_CosS(this->actor.shape.rot.y + this->unk_218) * 5.0f); + sp50.y = this->unk_234.y; + sp50.z = this->unk_234.z - (Math_SinS(this->actor.shape.rot.y + this->unk_218) * 5.0f); + + Collider_SetTrisVertices(&this->colliderTris, 0, &this->actor.focus.pos, &this->unk_234, &sp50); + } +} + +void EnVm_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnVm* this = THIS; + Gfx* gfx; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gfx = POLY_OPA_DISP; + + gSPDisplayList(&gfx[0], &sSetupDL[6 * 25]); + + POLY_OPA_DISP = &gfx[1]; + + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnVm_OverrideLimbDraw, + EnVm_PostLimbDraw, &this->actor); + + if (this->unk_210 == 2) { + gfx = POLY_XLU_DISP; + + gSPDisplayList(&gfx[0], &sSetupDL[6 * 60]); + gDPSetColorDither(&gfx[1], G_CD_DISABLE); + + Matrix_InsertTranslation(this->unk_234.x, this->unk_234.y + 10.0f, this->unk_234.z, MTXMODE_NEW); + Matrix_Scale(0.8f, 0.8f, 0.8f, MTXMODE_APPLY); + + gSPMatrix(&gfx[2], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(&gfx[3], 0, 0, 255, 255, 255, 168); + gDPSetEnvColor(&gfx[4], 0, 0, 255, 0); + gSPSegment(&gfx[5], 0x08, D_808CD58C[globalCtx->gameplayFrames & 7]); + gSPDisplayList(&gfx[6], gameplay_keep_DL_044300); + + POLY_XLU_DISP = &gfx[7]; + } + + if (this->unk_224 > 0.0f) { + gfx = POLY_OPA_DISP; + + gSPSegment(&gfx[0], 0x08, func_8012CB28(globalCtx->state.gfxCtx, 0, this->unk_212)); + + Matrix_InsertTranslation(this->actor.focus.pos.x, this->actor.focus.pos.y, this->actor.focus.pos.z, + MTXMODE_NEW); + Matrix_InsertRotation(this->unk_216, this->unk_218 + this->actor.shape.rot.y, 0, MTXMODE_APPLY); + Matrix_Scale(this->unk_220, this->unk_220, this->unk_224 * 0.0015f, MTXMODE_APPLY); + + gSPMatrix(&gfx[1], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&gfx[2], object_vm_DL_002728); + + POLY_OPA_DISP = &gfx[3]; + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Vm/z_en_vm.h b/src/overlays/actors/ovl_En_Vm/z_en_vm.h index ad5c43abb0..1901ac34af 100644 --- a/src/overlays/actors/ovl_En_Vm/z_en_vm.h +++ b/src/overlays/actors/ovl_En_Vm/z_en_vm.h @@ -7,11 +7,32 @@ struct EnVm; typedef void (*EnVmActionFunc)(struct EnVm*, GlobalContext*); +#define ENVM_GET_FF00(thisx) (((thisx)->params >> 8) & 0xFF) + +#define ENVM_FF00_0 0 +#define ENVM_FF00_5 5 +#define ENVM_FF00_FF 0xFF + typedef struct EnVm { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xC8]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[11]; + /* 0x01CA */ Vec3s morphTable[11]; /* 0x020C */ EnVmActionFunc actionFunc; - /* 0x0210 */ char unk_210[0x14C]; + /* 0x0210 */ u8 unk_210; + /* 0x0212 */ s16 unk_212; + /* 0x0214 */ s16 unk_214; + /* 0x0216 */ s16 unk_216; + /* 0x0218 */ s16 unk_218; + /* 0x021C */ f32 unk_21C; + /* 0x0220 */ f32 unk_220; + /* 0x0224 */ f32 unk_224; + /* 0x0228 */ Vec3f unk_228; + /* 0x0234 */ Vec3f unk_234; + /* 0x0240 */ ColliderJntSph colliderJntSph; + /* 0x0260 */ ColliderJntSphElement colliderJntSphElements[2]; + /* 0x02E0 */ ColliderTris colliderTris; + /* 0x0300 */ ColliderTrisElement colliderTrisElements[1]; } EnVm; // size = 0x35C extern const ActorInit En_Vm_InitVars; diff --git a/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c b/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c index 0bdb51729a..1b88d692b2 100644 --- a/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c +++ b/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c @@ -5,6 +5,8 @@ */ #include "z_en_wallmas.h" +#include "overlays/actors/ovl_En_Encount1/z_en_encount1.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_400) @@ -15,22 +17,32 @@ void EnWallmas_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnWallmas_Update(Actor* thisx, GlobalContext* globalCtx); void EnWallmas_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80874BE4(EnWallmas* this, GlobalContext* globalCtx); -void func_80874DE8(EnWallmas* this, GlobalContext* globalCtx); -void func_80874FD8(EnWallmas* this, GlobalContext* globalCtx); -void func_80875054(EnWallmas* this, GlobalContext* globalCtx); -void func_80875108(EnWallmas* this, GlobalContext* globalCtx); -void func_8087520C(EnWallmas* this, GlobalContext* globalCtx); -void func_808752CC(EnWallmas* this, GlobalContext* globalCtx); -void func_80875484(EnWallmas* this, GlobalContext* globalCtx); -void func_8087556C(EnWallmas* this, GlobalContext* globalCtx); -void func_80875638(EnWallmas* this, GlobalContext* globalCtx); -void func_8087571C(EnWallmas* this, GlobalContext* globalCtx); -void func_80875910(EnWallmas* this, GlobalContext* globalCtx); -void func_8087596C(EnWallmas* this, GlobalContext* globalCtx); -void func_80875A0C(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_TimerInit(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_WaitToDrop(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_SetupDrop(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_Drop(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_SetupLand(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_Land(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_SetupStand(EnWallmas* this); +void EnWallmas_Stand(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_SetupWalk(EnWallmas* this); +void EnWallmas_Walk(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_SetupJumpToCeiling(EnWallmas* this); +void EnWallmas_JumpToCeiling(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_SetupReturnToCeiling(EnWallmas* this); +void EnWallmas_ReturnToCeiling(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_Damage(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_SetupCooldown(EnWallmas* this); +void EnWallmas_Cooldown(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_SetupDie(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_Die(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_SetupTakePlayer(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_TakePlayer(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_ProximityOrSwitchInit(EnWallmas* this); +void EnWallmas_WaitForProximity(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_WaitForSwitchFlag(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_Stun(EnWallmas* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Wallmas_InitVars = { ACTOR_EN_WALLMAS, ACTORCAT_ENEMY, @@ -43,147 +55,704 @@ const ActorInit En_Wallmas_InitVars = { (ActorFunc)EnWallmas_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80876360 = { - { COLTYPE_HIT0, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT0, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 30, 40, 0, { 0, 0, 0 } }, }; -// static DamageTable sDamageTable = { -static DamageTable D_8087638C = { - /* Deku Nut */ DMG_ENTRY(0, 0x1), - /* Deku Stick */ DMG_ENTRY(1, 0x0), - /* Horse trample */ DMG_ENTRY(1, 0x0), - /* Explosives */ DMG_ENTRY(1, 0x0), - /* Zora boomerang */ DMG_ENTRY(1, 0x0), - /* Normal arrow */ DMG_ENTRY(1, 0x0), - /* UNK_DMG_0x06 */ DMG_ENTRY(1, 0x0), - /* Hookshot */ DMG_ENTRY(0, 0xF), - /* Goron punch */ DMG_ENTRY(1, 0x0), - /* Sword */ DMG_ENTRY(1, 0x0), - /* Goron pound */ DMG_ENTRY(1, 0x0), - /* Fire arrow */ DMG_ENTRY(2, 0x2), - /* Ice arrow */ DMG_ENTRY(1, 0x3), - /* Light arrow */ DMG_ENTRY(2, 0x4), - /* Goron spikes */ DMG_ENTRY(1, 0x0), - /* Deku spin */ DMG_ENTRY(0, 0x1), - /* Deku bubble */ DMG_ENTRY(1, 0x0), - /* Deku launch */ DMG_ENTRY(2, 0x0), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0x1), - /* Zora barrier */ DMG_ENTRY(0, 0x5), - /* Normal shield */ DMG_ENTRY(0, 0x0), - /* Light ray */ DMG_ENTRY(0, 0x0), - /* Thrown object */ DMG_ENTRY(1, 0x0), - /* Zora punch */ DMG_ENTRY(1, 0x0), - /* Spin attack */ DMG_ENTRY(1, 0x0), - /* Sword beam */ DMG_ENTRY(0, 0x0), - /* Normal Roll */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0x0), - /* Powder Keg */ DMG_ENTRY(1, 0x0), +typedef enum { + /* 0x0 */ WALLMASTER_DMGEFF_NONE, + /* 0x1 */ WALLMASTER_DMGEFF_STUN, + /* 0x2 */ WALLMASTER_DMGEFF_FIRE_ARROW, + /* 0x3 */ WALLMASTER_DMGEFF_ICE_ARROW, + /* 0x4 */ WALLMASTER_DMGEFF_LIGHT_ARROW, + /* 0x5 */ WALLMASTER_DMGEFF_ZORA_MAGIC, + /* 0xF */ WALLMASTER_DMGEFF_HOOKSHOT = 0xF +} EnWallmasDamageEffect; + +static DamageTable sDamageTable = { + /* Deku Nut */ DMG_ENTRY(0, WALLMASTER_DMGEFF_STUN), + /* Deku Stick */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Horse trample */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Explosives */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Zora boomerang */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Normal arrow */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* UNK_DMG_0x06 */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Hookshot */ DMG_ENTRY(0, WALLMASTER_DMGEFF_HOOKSHOT), + /* Goron punch */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Sword */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Goron pound */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Fire arrow */ DMG_ENTRY(2, WALLMASTER_DMGEFF_FIRE_ARROW), + /* Ice arrow */ DMG_ENTRY(1, WALLMASTER_DMGEFF_ICE_ARROW), + /* Light arrow */ DMG_ENTRY(2, WALLMASTER_DMGEFF_LIGHT_ARROW), + /* Goron spikes */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Deku spin */ DMG_ENTRY(0, WALLMASTER_DMGEFF_STUN), + /* Deku bubble */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Deku launch */ DMG_ENTRY(2, WALLMASTER_DMGEFF_NONE), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, WALLMASTER_DMGEFF_STUN), + /* Zora barrier */ DMG_ENTRY(0, WALLMASTER_DMGEFF_ZORA_MAGIC), + /* Normal shield */ DMG_ENTRY(0, WALLMASTER_DMGEFF_NONE), + /* Light ray */ DMG_ENTRY(0, WALLMASTER_DMGEFF_NONE), + /* Thrown object */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Zora punch */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Spin attack */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Sword beam */ DMG_ENTRY(0, WALLMASTER_DMGEFF_NONE), + /* Normal Roll */ DMG_ENTRY(0, WALLMASTER_DMGEFF_NONE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, WALLMASTER_DMGEFF_NONE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, WALLMASTER_DMGEFF_NONE), + /* Unblockable */ DMG_ENTRY(0, WALLMASTER_DMGEFF_NONE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, WALLMASTER_DMGEFF_NONE), + /* Powder Keg */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), }; -// sColChkInfoInit -static CollisionCheckInfoInit D_808763AC = { 3, 30, 40, 150 }; +static CollisionCheckInfoInit sColChkInfoInit = { 3, 30, 40, 150 }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808763B4[] = { +static InitChainEntry sInitChain[] = { ICHAIN_S8(hintId, 48, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 5500, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -1500, ICHAIN_STOP), }; -#endif +static f32 sYOffsetPerForm[] = { 50.0f, 55.0f, 50.0f, 20.0f, 30.0f }; -extern ColliderCylinderInit D_80876360; -extern DamageTable D_8087638C; -extern CollisionCheckInfoInit D_808763AC; -extern InitChainEntry D_808763B4[]; +/** + * This maps a given limb based on its limbIndex to its appropriate index + * in the limbPos array. An index of -1 indicates that the limb is not part + * of the limbPos array. + */ +static s8 sLimbIndexToLimbPosIndex[] = { + -1, -1, -1, -1, 0, -1, -1, 1, -1, 2, -1, -1, 3, -1, 4, -1, -1, 5, -1, -1, -1, 6, 7, -1, 8, +}; -extern UNK_TYPE D_06000590; -extern UNK_TYPE D_06000EA4; -extern UNK_TYPE D_060019CC; -extern UNK_TYPE D_0600299C; -extern UNK_TYPE D_060041F4; -extern UNK_TYPE D_06008688; -extern UNK_TYPE D_06009244; -extern UNK_TYPE D_06009520; -extern UNK_TYPE D_06009DB0; -extern UNK_TYPE D_0600A054; +void EnWallmas_Init(Actor* thisx, GlobalContext* globalCtx) { + EnWallmas* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/EnWallmas_Init.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.5f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gWallmasterSkel, &gWallmasterIdleAnim, this->jointTable, + this->morphTable, WALLMASTER_LIMB_MAX); + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/EnWallmas_Destroy.s") + this->switchFlag = WALLMASTER_GET_SWITCH_FLAG(thisx); + this->actor.params &= 0xFF; + this->detectionRadius = this->actor.shape.rot.x * 40.0f * 0.1f; + this->actor.shape.rot.x = 0; + this->actor.world.rot.x = 0; + if (this->detectionRadius <= 0.0f) { + this->detectionRadius = 200.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80874A88.s") + Actor_SetFocus(&this->actor, 25.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80874B04.s") + if (WALLMASTER_IS_FROZEN(&this->actor)) { + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_OBJ_ICE_POLY, this->actor.world.pos.x, + this->actor.world.pos.y - 15.0f, this->actor.world.pos.z, this->actor.world.rot.x, + (this->actor.world.rot.y + 0x5900), this->actor.world.rot.z, 0xFF50); + this->actor.params &= ~0x80; + EnWallmas_SetupReturnToCeiling(this); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80874B88.s") + if (WALLMASTER_GET_TYPE(&this->actor) == WALLMASTER_TYPE_FLAG) { + if (Flags_GetSwitch(globalCtx, this->switchFlag)) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80874BE4.s") + EnWallmas_ProximityOrSwitchInit(this); + } else if (WALLMASTER_GET_TYPE(&this->actor) == WALLMASTER_TYPE_PROXIMITY) { + EnWallmas_ProximityOrSwitchInit(this); + } else { + EnWallmas_TimerInit(this, globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80874D1C.s") +void EnWallmas_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnWallmas* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80874DE8.s") + Collider_DestroyCylinder(globalCtx, &this->collider); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80874F14.s") + if (this->actor.parent != NULL) { + EnEncount1* encount1 = (EnEncount1*)this->actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80874FD8.s") + if ((encount1->actor.update != NULL) && (encount1->unk_14E > 0)) { + encount1->unk_14E--; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80875014.s") +void EnWallmas_Freeze(EnWallmas* this) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffFrozenSteamScale = 0.82500005f; + this->drawDmgEffAlpha = 1.0f; + this->collider.base.colType = 3; + this->timer = 80; + this->actor.flags &= ~ACTOR_FLAG_400; + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80875054.s") +void EnWallmas_ThawIfFrozen(EnWallmas* this, GlobalContext* globalCtx) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->collider.base.colType = 0; + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, 11, 2, 0.3f, 0.2f); + this->actor.flags |= ACTOR_FLAG_400; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_808750B8.s") +void EnWallmas_TimerInit(EnWallmas* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80875108.s") + this->actor.flags &= ~ACTOR_FLAG_1; + this->actor.flags |= ACTOR_FLAG_20; + this->timer = 130; + this->actor.velocity.y = 0.0f; + this->actor.world.pos.y = player->actor.world.pos.y; + this->actor.floorHeight = player->actor.floorHeight; + this->actor.draw = EnWallmas_Draw; + this->actionFunc = EnWallmas_WaitToDrop; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_808751C4.s") +void EnWallmas_WaitToDrop(EnWallmas* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f* playerPos = &player->actor.world.pos; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_8087520C.s") + this->actor.world.pos = *playerPos; + this->actor.floorHeight = player->actor.floorHeight; + this->actor.floorPoly = player->actor.floorPoly; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80875248.s") + if (this->timer != 0) { + this->timer--; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_808752CC.s") + if ((player->stateFlags1 & 0x08100000) || (player->stateFlags2 & 0x80) || (player->unk_B5E > 0) || + (player->actor.freezeTimer > 0) || !(player->actor.bgCheckFlags & 1) || + ((WALLMASTER_GET_TYPE(&this->actor) == WALLMASTER_TYPE_PROXIMITY) && + (Math_Vec3f_DistXZ(&this->actor.home.pos, playerPos) > (120.f + this->detectionRadius)))) { + func_801A75E8(NA_SE_EN_FALL_AIM); + this->timer = 130; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_808753F0.s") + if (this->timer == 80) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_AIM); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80875484.s") + if (this->timer == 0) { + EnWallmas_SetupDrop(this, globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80875518.s") +void EnWallmas_SetupDrop(EnWallmas* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_8087556C.s") + Animation_Change(&this->skelAnime, &gWallmasterLungeAnim, 0.0f, 20.0f, + Animation_GetLastFrame(&gWallmasterLungeAnim), ANIMMODE_ONCE, 0.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_808755A8.s") + this->yTarget = player->actor.world.pos.y; + this->actor.world.pos.y = player->actor.world.pos.y + 300.0f; + this->actor.shape.rot.y = player->actor.shape.rot.y + 0x8000; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actor.floorHeight = player->actor.floorHeight; + this->actor.flags |= ACTOR_FLAG_1; + this->actor.flags &= ~ACTOR_FLAG_20; + this->actionFunc = EnWallmas_Drop; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80875638.s") +void EnWallmas_Drop(EnWallmas* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_808756AC.s") + if ((player->stateFlags2 & 0x80) || (player->actor.freezeTimer > 0)) { + EnWallmas_SetupReturnToCeiling(this); + } else if (!Play_InCsMode(globalCtx) && !(player->stateFlags2 & 0x10) && (player->invincibilityTimer >= 0) && + (this->actor.xzDistToPlayer < 30.0f) && (this->actor.playerHeightRel < -5.0f) && + (-(f32)(player->cylinder.dim.height + 10) < this->actor.playerHeightRel)) { + EnWallmas_SetupTakePlayer(this, globalCtx); + } else if (this->actor.world.pos.y <= this->yTarget) { + this->actor.world.pos.y = this->yTarget; + this->actor.velocity.y = 0.0f; + EnWallmas_SetupLand(this, globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_8087571C.s") +void EnWallmas_SetupLand(EnWallmas* this, GlobalContext* globalCtx) { + Animation_Change(&this->skelAnime, &gWallmasterJumpAnim, 1.0f, 41.0f, Animation_GetLastFrame(&gWallmasterJumpAnim), + ANIMMODE_ONCE, -3.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_808758C8.s") + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 15.0f, 6, 20.0f, 300, 100, true); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_LAND); + this->actionFunc = EnWallmas_Land; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80875910.s") +void EnWallmas_Land(EnWallmas* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + EnWallmas_SetupStand(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_8087596C.s") +void EnWallmas_SetupStand(EnWallmas* this) { + Animation_PlayOnce(&this->skelAnime, &gWallmasterStandUpAnim); + this->actionFunc = EnWallmas_Stand; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_808759B8.s") +void EnWallmas_Stand(EnWallmas* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + EnWallmas_SetupWalk(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80875A0C.s") + Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer + 0x8000, 0xB6); + this->actor.world.rot.y = this->actor.shape.rot.y; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80875A74.s") +void EnWallmas_SetupWalk(EnWallmas* this) { + Animation_PlayOnceSetSpeed(&this->skelAnime, &gWallmasterWalkAnim, 3.0f); + this->actor.speedXZ = 3.0f; + this->actionFunc = EnWallmas_Walk; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/EnWallmas_Update.s") +void EnWallmas_Walk(EnWallmas* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + EnWallmas_SetupJumpToCeiling(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80875F04.s") + Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer + 0x8000, 0xB6); + this->actor.world.rot.y = this->actor.shape.rot.y; + if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 12.0f) || + Animation_OnFrame(&this->skelAnime, 24.0f) || Animation_OnFrame(&this->skelAnime, 36.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_WALK); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_808760A4.s") +void EnWallmas_SetupJumpToCeiling(EnWallmas* this) { + Animation_PlayOnce(&this->skelAnime, &gWallmasterStopWalkAnim); + this->actor.speedXZ = 0.0f; + this->actionFunc = EnWallmas_JumpToCeiling; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80876118.s") +void EnWallmas_JumpToCeiling(EnWallmas* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + EnWallmas_SetupReturnToCeiling(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/EnWallmas_Draw.s") +void EnWallmas_SetupReturnToCeiling(EnWallmas* this) { + this->timer = 0; + this->actor.speedXZ = 0.0f; + Animation_Change(&this->skelAnime, &gWallmasterJumpAnim, 3.0f, 0.0f, Animation_GetLastFrame(&gWallmasterJumpAnim), + ANIMMODE_ONCE, -3.0f); + this->actionFunc = EnWallmas_ReturnToCeiling; +} + +void EnWallmas_ReturnToCeiling(EnWallmas* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + SkelAnime_Update(&this->skelAnime); + if (this->skelAnime.curFrame > 20.0f) { + this->actor.world.pos.y += 30.0f; + this->timer += 9; + this->actor.flags &= ~ACTOR_FLAG_2000; + } + + if (Animation_OnFrame(&this->skelAnime, 20.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_UP); + } + + if (this->actor.playerHeightRel < -900.0f) { + if (WALLMASTER_GET_TYPE(&this->actor) == WALLMASTER_TYPE_FLAG) { + Actor_MarkForDeath(&this->actor); + return; + } + + if ((WALLMASTER_GET_TYPE(&this->actor) == WALLMASTER_TYPE_TIMER_ONLY) || + (Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) < this->detectionRadius)) { + EnWallmas_TimerInit(this, globalCtx); + } else { + EnWallmas_ProximityOrSwitchInit(this); + } + } +} + +void EnWallmas_SetupDamage(EnWallmas* this, s32 arg1) { + Animation_MorphToPlayOnce(&this->skelAnime, &gWallmasterDamageAnim, -3.0f); + + if (arg1) { + func_800BE504(&this->actor, &this->collider); + } + + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 20); + this->actor.speedXZ = 5.0f; + this->actor.velocity.y = 10.0f; + this->actionFunc = EnWallmas_Damage; +} + +void EnWallmas_Damage(EnWallmas* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + if (this->actor.colChkInfo.health == 0) { + EnWallmas_SetupDie(this, globalCtx); + } else { + EnWallmas_SetupCooldown(this); + } + } + + if (Animation_OnFrame(&this->skelAnime, 13.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); + } + + Math_StepToF(&this->actor.speedXZ, 0.0f, 0.2f); +} + +void EnWallmas_SetupCooldown(EnWallmas* this) { + Animation_PlayOnce(&this->skelAnime, &gWallmasterRecoverFromDamageAnim); + this->actor.speedXZ = 0.0f; + this->actor.velocity.y = 0.0f; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actionFunc = EnWallmas_Cooldown; +} + +void EnWallmas_Cooldown(EnWallmas* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + EnWallmas_SetupReturnToCeiling(this); + } +} + +void EnWallmas_SetupDie(EnWallmas* this, GlobalContext* globalCtx) { + this->actor.speedXZ = 0.0f; + this->actor.velocity.y = 0.0f; + func_800B3030(globalCtx, &this->actor.world.pos, &gZeroVec3f, &gZeroVec3f, 250, -10, 2); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 11, NA_SE_EN_EXTINCT); + this->actionFunc = EnWallmas_Die; +} + +void EnWallmas_Die(EnWallmas* this, GlobalContext* globalCtx) { + if (Math_StepToF(&this->actor.scale.x, 0.0f, 0.0015f)) { + Actor_SetScale(&this->actor, 0.01f); + Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x90); + Actor_MarkForDeath(&this->actor); + } + + this->actor.scale.z = this->actor.scale.x; + this->actor.scale.y = this->actor.scale.x; +} + +void EnWallmas_SetupTakePlayer(EnWallmas* this, GlobalContext* globalCtx) { + Animation_MorphToPlayOnce(&this->skelAnime, &gWallmasterHoverAnim, -5.0f); + this->timer = -30; + this->actionFunc = EnWallmas_TakePlayer; + this->actor.speedXZ = 0.0f; + this->actor.velocity.y = 0.0f; + this->yTarget = this->actor.playerHeightRel; + func_800B724C(globalCtx, &this->actor, 18); +} + +void EnWallmas_TakePlayer(EnWallmas* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (Animation_OnFrame(&this->skelAnime, 1.0f)) { + func_800B8E58(player, player->ageProperties->unk_92 + NA_SE_VO_LI_DAMAGE_S); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_CATCH); + } + + if (SkelAnime_Update(&this->skelAnime)) { + player->actor.world.pos.x = this->actor.world.pos.x; + player->actor.world.pos.z = this->actor.world.pos.z; + + if (this->timer < 0) { + this->actor.world.pos.y += 2.0f; + } else { + this->actor.world.pos.y += 10.0f; + } + + player->actor.world.pos.y = this->actor.world.pos.y - sYOffsetPerForm[((void)0, gSaveContext.save.playerForm)]; + if (this->timer == -30) { + func_800B8E58(player, player->ageProperties->unk_92 + NA_SE_VO_LI_TAKEN_AWAY); + } + + if (this->timer == 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_UP); + } + + this->timer += 2; + } else { + Math_StepToF(&this->actor.world.pos.y, + sYOffsetPerForm[((void)0, gSaveContext.save.playerForm)] + player->actor.world.pos.y, 5.0f); + } + + Math_StepToF(&this->actor.world.pos.x, player->actor.world.pos.x, 3.0f); + Math_StepToF(&this->actor.world.pos.z, player->actor.world.pos.z, 3.0f); + + if (this->timer == 30) { + play_sound(NA_SE_OC_ABYSS); + func_80169FDC(&globalCtx->state); + } +} + +void EnWallmas_ProximityOrSwitchInit(EnWallmas* this) { + this->timer = 0; + this->actor.draw = NULL; + this->actor.flags &= ~ACTOR_FLAG_1; + if (WALLMASTER_GET_TYPE(&this->actor) == WALLMASTER_TYPE_PROXIMITY) { + this->actionFunc = EnWallmas_WaitForProximity; + } else { + this->actionFunc = EnWallmas_WaitForSwitchFlag; + } +} + +void EnWallmas_WaitForProximity(EnWallmas* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) < this->detectionRadius) { + EnWallmas_TimerInit(this, globalCtx); + } +} + +void EnWallmas_WaitForSwitchFlag(EnWallmas* this, GlobalContext* globalCtx) { + if (Flags_GetSwitch(globalCtx, this->switchFlag)) { + EnWallmas_TimerInit(this, globalCtx); + this->timer = 81; + } +} + +void EnWallmas_SetupStun(EnWallmas* this) { + this->actor.speedXZ = 0.0f; + if (this->actor.velocity.y > 0.0f) { + this->actor.velocity.y = 0.0f; + } + + func_800BE504(&this->actor, &this->collider); + this->actionFunc = EnWallmas_Stun; +} + +void EnWallmas_Stun(EnWallmas* this, GlobalContext* globalCtx) { + if (this->timer != 0) { + this->timer--; + } + + if (this->timer == 0) { + EnWallmas_ThawIfFrozen(this, globalCtx); + if (this->actor.colChkInfo.health == 0) { + EnWallmas_SetupDamage(this, false); + } else { + this->actor.world.rot.y = this->actor.shape.rot.y; + EnWallmas_SetupReturnToCeiling(this); + } + } +} + +void EnWallmas_UpdateDamage(EnWallmas* this, GlobalContext* globalCtx) { + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + Actor_SetDropFlag(&this->actor, &this->collider.info); + + if ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || + (!(this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3))) { + if (Actor_ApplyDamage(&this->actor) == 0) { + Enemy_StartFinishingBlow(globalCtx, &this->actor); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DAIOCTA_REVERSE); + this->actor.flags &= ~ACTOR_FLAG_1; + } else if (this->actor.colChkInfo.damage != 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_DAMAGE); + } + + EnWallmas_ThawIfFrozen(this, globalCtx); + + if (this->actor.colChkInfo.damageEffect != WALLMASTER_DMGEFF_HOOKSHOT) { + if (this->actor.colChkInfo.damageEffect == WALLMASTER_DMGEFF_ICE_ARROW) { + EnWallmas_Freeze(this); + if (this->actor.colChkInfo.health == 0) { + this->timer = 3; + this->collider.base.acFlags &= ~AC_ON; + } + + EnWallmas_SetupStun(this); + } else if (this->actor.colChkInfo.damageEffect == WALLMASTER_DMGEFF_STUN) { + this->timer = 40; + Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + EnWallmas_SetupStun(this); + } else if (this->actor.colChkInfo.damageEffect == WALLMASTER_DMGEFF_ZORA_MAGIC) { + this->timer = 40; + Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + this->drawDmgEffScale = 0.55f; + this->drawDmgEffAlpha = 2.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_MEDIUM; + EnWallmas_SetupStun(this); + } else { + if (this->actor.colChkInfo.damageEffect == WALLMASTER_DMGEFF_FIRE_ARROW) { + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + } else if (this->actor.colChkInfo.damageEffect == WALLMASTER_DMGEFF_LIGHT_ARROW) { + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, + this->collider.info.bumper.hitPos.x, this->collider.info.bumper.hitPos.y, + this->collider.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); + } + + EnWallmas_SetupDamage(this, true); + } + } + } + } +} + +void EnWallmas_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnWallmas* this = THIS; + + EnWallmas_UpdateDamage(this, globalCtx); + this->actionFunc(this, globalCtx); + + if ((this->actionFunc != EnWallmas_WaitToDrop) && (this->actionFunc != EnWallmas_WaitForProximity) && + (this->actionFunc != EnWallmas_TakePlayer) && (this->actionFunc != EnWallmas_WaitForSwitchFlag)) { + if ((this->actionFunc != EnWallmas_ReturnToCeiling) && (this->actionFunc != EnWallmas_TakePlayer)) { + Actor_MoveWithGravity(&this->actor); + } + + if (this->actionFunc != EnWallmas_Drop) { + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 25.0f, 0.0f, 0x1DU); + } + + if ((this->actionFunc != EnWallmas_Die) && (this->actionFunc != EnWallmas_Drop)) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + if ((this->actionFunc != EnWallmas_Damage) && (this->actor.bgCheckFlags & 1) && + (this->actor.freezeTimer == 0)) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + } + + Actor_SetFocus(&this->actor, 25.0f); + + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.275f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 0.55f); + } else if (Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.55f, 0.01375f) == 0) { + func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); + } + } + } +} + +void EnWallmas_DrawShadow(EnWallmas* this, GlobalContext* globalCtx) { + s32 pad; + f32 xzScale; + MtxF mf; + Gfx* gfx; + + if ((this->actor.floorPoly != NULL) && ((this->timer < 81) || (this->actionFunc == EnWallmas_Stun))) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + gfx = POLY_OPA_DISP; + + gSPDisplayList(&gfx[0], &sSetupDL[6 * 44]); + gDPSetPrimColor(&gfx[1], 0, 0, 0, 0, 0, 255); + func_800C0094(this->actor.floorPoly, this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, + &mf); + Matrix_InsertMatrix(&mf, MTXMODE_NEW); + + if ((this->actionFunc != EnWallmas_WaitToDrop) && (this->actionFunc != EnWallmas_ReturnToCeiling) && + (this->actionFunc != EnWallmas_TakePlayer) && (this->actionFunc != EnWallmas_WaitForSwitchFlag)) { + xzScale = this->actor.scale.x * 50.0f; + } else { + xzScale = CLAMP_MAX(80 - this->timer, 80) * 0.00625f; + } + + Matrix_Scale(xzScale, 1.0f, xzScale, MTXMODE_APPLY); + gSPMatrix(&gfx[2], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&gfx[3], gCircleShadowDL); + + POLY_OPA_DISP = &gfx[4]; + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +s32 EnWallmas_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnWallmas* this = THIS; + + if (limbIndex == WALLMASTER_LIMB_ROOT) { + if (this->actionFunc != EnWallmas_TakePlayer) { + pos->z -= 1600.0f; + } else { + pos->z -= (1600.0f * (this->skelAnime.endFrame - this->skelAnime.curFrame)) / this->skelAnime.endFrame; + } + } + + return false; +} + +void EnWallmas_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnWallmas* this = THIS; + Gfx* gfx; + + if (sLimbIndexToLimbPosIndex[limbIndex] != -1) { + Matrix_GetStateTranslation(&this->limbPos[sLimbIndexToLimbPosIndex[limbIndex]]); + } + + if (limbIndex == WALLMASTER_LIMB_WRIST) { + Matrix_GetStateTranslationAndScaledX(1000.0f, &this->limbPos[9]); + Matrix_GetStateTranslationAndScaledX(-1000.0f, &this->limbPos[10]); + } else if (limbIndex == WALLMASTER_LIMB_HAND) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + gfx = POLY_OPA_DISP; + + Matrix_StatePush(); + Matrix_InsertTranslation(1600.0f, -700.0f, -1700.0f, MTXMODE_APPLY); + Matrix_RotateY(0x2AAA, MTXMODE_APPLY); + Matrix_InsertZRotation_s(0xAAA, MTXMODE_APPLY); + Matrix_Scale(2.0f, 2.0f, 2.0f, MTXMODE_APPLY); + + gSPMatrix(&gfx[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&gfx[1], gWallmasterLittleFingerDL); + + POLY_OPA_DISP = &gfx[2]; + + Matrix_StatePop(); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +void EnWallmas_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnWallmas* this = THIS; + + if (this->actionFunc != EnWallmas_WaitToDrop) { + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, EnWallmas_OverrideLimbDraw, EnWallmas_PostLimbDraw, + &this->actor); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + this->drawDmgEffScale, this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, + this->drawDmgEffType); + } + + if (this->actor.colorFilterTimer != 0) { + func_800AE5A0(globalCtx); + } + + EnWallmas_DrawShadow(this, globalCtx); +} diff --git a/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.h b/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.h index 1bd6fbe837..06d4d24d15 100644 --- a/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.h +++ b/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.h @@ -2,16 +2,54 @@ #define Z_EN_WALLMAS_H #include "global.h" +#include "objects/object_wallmaster/object_wallmaster.h" + +#define WALLMASTER_GET_TYPE(thisx) ((thisx)->params) +#define WALLMASTER_GET_SWITCH_FLAG(thisx) (((thisx)->params >> 8) & 0xFF) +#define WALLMASTER_IS_FROZEN(thisx) ((thisx)->params & 0x80) + +/** + * This type determines under what conditions the Wallmaster will drop from the ceiling. + * - WALLMASTER_TYPE_TIMER_ONLY: These Wallmasters don't check for anything to determine + * whether or not to drop; they just set a 130-frame timer and drop once it reaches 0. + * - WALLMASTER_TYPE_PROXIMITY: These Wallmasters ensure that the player in within a certain + * distance of their current position (as dictated by detectionRadius); once the player + * enters that range, they set a 130-frame timer and drop once it reaches 0. + * - WALLMASTER_TYPE_FLAG: These Wallmasters wait for a certain switch flag to be activated, + * as specified in their params. Once this switch is activated, they set an 81-frame timer + * and drop once it reaches 0. + * + * While in the "waiting to drop" state, all Wallmaster variations can be forced to reset the + * timer to 130 frames if the player enters certain states (e.g., if the player is no longer + * touching the ground). Additionally, WALLMASTER_TYPE_PROXIMITY-type Wallmasters will reset + * the timer to 130 frames if the player strays too far from the Wallmaster's current position. + */ +typedef enum { + /* 0x00 */ WALLMASTER_TYPE_TIMER_ONLY, + /* 0x01 */ WALLMASTER_TYPE_PROXIMITY, + /* 0x02 */ WALLMASTER_TYPE_FLAG +} WallmasterType; struct EnWallmas; typedef void (*EnWallmasActionFunc)(struct EnWallmas*, GlobalContext*); typedef struct EnWallmas { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; - /* 0x0188 */ EnWallmasActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x218]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnWallmasActionFunc actionFunc; + /* 0x18C */ u8 drawDmgEffType; + /* 0x18E */ s16 timer; + /* 0x190 */ s16 switchFlag; + /* 0x192 */ Vec3s jointTable[WALLMASTER_LIMB_MAX]; + /* 0x228 */ Vec3s morphTable[WALLMASTER_LIMB_MAX]; + /* 0x2C0 */ f32 yTarget; + /* 0x2C4 */ f32 detectionRadius; + /* 0x2C8 */ f32 drawDmgEffAlpha; + /* 0x2CC */ f32 drawDmgEffScale; + /* 0x2D0 */ f32 drawDmgEffFrozenSteamScale; + /* 0x2D4 */ Vec3f limbPos[11]; + /* 0x358 */ ColliderCylinder collider; } EnWallmas; // size = 0x3A4 extern const ActorInit En_Wallmas_InitVars; diff --git a/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c b/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c index ffbb9526b8..51ef3ef38f 100644 --- a/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c +++ b/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c @@ -112,7 +112,7 @@ void func_80A66278(EnWarpUzu* this, GlobalContext* globalCtx) { void func_80A66384(EnWarpUzu* this, GlobalContext* globalCtx) { globalCtx->nextEntranceIndex = 0x22A0; - gSaveContext.respawn[0].entranceIndex = globalCtx->nextEntranceIndex; + gSaveContext.respawn[RESTART_MODE_DOWN].entranceIndex = globalCtx->nextEntranceIndex; func_80169EFC(&globalCtx->state); gSaveContext.respawnFlag = -2; this->actionFunc = EnWarpUzu_DoNothing; diff --git a/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.c b/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.c index ce6367b877..5759b0a9bd 100644 --- a/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.c +++ b/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.c @@ -2,9 +2,11 @@ * File: z_en_warp_tag.c * Overlay: ovl_En_Warp_tag * Description: Warp to Trial Entrance + * if GoronTrial, has model: Uses GAMEPLAY_DANGEON_KEEP object assigned in EnWarptag_Init */ #include "z_en_warp_tag.h" +#include "objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_10 | ACTOR_FLAG_2000000 | ACTOR_FLAG_8000000) @@ -13,15 +15,15 @@ void EnWarptag_Init(Actor* thisx, GlobalContext* globalCtx); void EnWarptag_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnWarptag_Update(Actor* thisx, GlobalContext* globalCtx); +void EnWarpTag_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_809C085C(EnWarptag* this, GlobalContext* globalCtx); -void func_809C08E0(EnWarptag* this, GlobalContext* globalCtx); -void func_809C09A0(EnWarptag* this, GlobalContext* globalCtx); -void func_809C0A20(EnWarptag* this, GlobalContext* globalCtx); -void func_809C0AB4(EnWarptag* this, GlobalContext* globalCtx); -void func_809C0E30(EnWarptag* this, GlobalContext* globalCtx); +void EnWarpTag_CheckDungeonKeepObject(EnWarptag* this, GlobalContext* globalCtx); +void EnWarpTag_WaitForPlayer(EnWarptag* this, GlobalContext* globalCtx); +void EnWarpTag_Unused809C09A0(EnWarptag* this, GlobalContext* globalCtx); +void EnWarpTag_Unused809C0A20(EnWarptag* this, GlobalContext* globalCtx); +void EnWarpTag_RespawnPlayer(EnWarptag* this, GlobalContext* globalCtx); +void EnWarpTag_GrottoReturn(EnWarptag* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Warp_tag_InitVars = { ACTOR_EN_WARP_TAG, ACTORCAT_ITEMACTION, @@ -34,32 +36,238 @@ const ActorInit En_Warp_tag_InitVars = { (ActorFunc)NULL, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_809C1008[] = { +// this appears to be unused, as the code never accesses it in known vanilla cases +// these unknown values get passed to a unknown z_message function +u8 D_809C1000[] = { 0x28, 0x29, 0x2A, 0x2B, 0x2D, 0x2C, 0, 0 }; + +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F(scale, 1, ICHAIN_CONTINUE), ICHAIN_VEC3S(shape.rot, 0, ICHAIN_STOP), }; -#endif +void EnWarptag_Init(Actor* thisx, GlobalContext* globalCtx) { + EnWarptag* this = THIS; -extern InitChainEntry D_809C1008[]; + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + Actor_SetFocus(&this->dyna.actor, 0.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Warp_tag/EnWarptag_Init.s") + if (GET_WARPTAG_3C0_MAX(thisx) == WARPTAG_3C0_MAX) { + this->dyna.actor.flags &= ~ACTOR_FLAG_1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Warp_tag/EnWarptag_Destroy.s") + if (GET_WARPTAG_INVISIBLE(&this->dyna.actor)) { + this->actionFunc = EnWarpTag_WaitForPlayer; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Warp_tag/func_809C085C.s") + } else { + if ((this->dangeonKeepObject = Object_GetIndex(&globalCtx->objectCtx, GAMEPLAY_DANGEON_KEEP)) < 0) { + Actor_MarkForDeath(&this->dyna.actor); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Warp_tag/func_809C08E0.s") + this->actionFunc = EnWarpTag_CheckDungeonKeepObject; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Warp_tag/func_809C09A0.s") + } else { // not used by known variants + this->actionFunc = EnWarpTag_Unused809C09A0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Warp_tag/func_809C0A20.s") +void EnWarptag_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnWarptag* this = THIS; + if (this->dyna.actor.draw != NULL) { + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Warp_tag/func_809C0AB4.s") +/** + * Loads DynaPoly from GAMEPLAY_DANGEON_KEEP. + */ +void EnWarpTag_CheckDungeonKeepObject(EnWarptag* this, GlobalContext* globalCtx) { + if (Object_IsLoaded(&globalCtx->objectCtx, this->dangeonKeepObject)) { + this->actionFunc = EnWarpTag_WaitForPlayer; + DynaPolyActor_Init(&this->dyna, 0x1); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gWarpTagGoronTrialBaseCollider); + this->dyna.actor.objBankIndex = this->dangeonKeepObject; + this->dyna.actor.draw = EnWarpTag_Draw; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Warp_tag/func_809C0E30.s") +void EnWarpTag_WaitForPlayer(EnWarptag* this, GlobalContext* globalCtx) { + if (!Player_InCsMode(&globalCtx->state) && (this->dyna.actor.xzDistToPlayer <= 30.0f) && + (this->dyna.actor.playerHeightRel <= 10.0f)) { + if (GET_WARPTAG_INVISIBLE(&this->dyna.actor)) { + func_800B7298(globalCtx, NULL, 0x51); + this->actionFunc = EnWarpTag_GrottoReturn; + } else { + func_800B7298(globalCtx, NULL, 0xF); + this->actionFunc = EnWarpTag_RespawnPlayer; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Warp_tag/EnWarptag_Update.s") +/** + * Unused ActionFunc: assigned in EnWarpTag_Init, no known variants use. + */ +void EnWarpTag_Unused809C09A0(EnWarptag* this, GlobalContext* globalCtx) { + if (func_800B8718(&this->dyna.actor, &globalCtx->state)) { + // func above: checks for ACTOR_FLAG_20000000, returns true and resets if set, else return false + // this actor doesnt have that flag set default, or in init, and this is called shortly after init + // and I doubt its set externally by another actor, so I believe this is unused + // might be a bug, they might have meant to set actor flag (0x2000 0000) up above but mistyped (0x200 0000) + // also GET_WARPTAG_3C0 should always return 2C0 -> 0xF for all known in-game uses, which is OOB + func_80152434(globalCtx, D_809C1000[GET_WARPTAG_3C0(&this->dyna.actor)]); // unk message function + this->actionFunc = EnWarpTag_Unused809C0A20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Warp_tag/func_809C0F3C.s") + } else { + func_800B8804(&this->dyna.actor, globalCtx, 50.0f); // updates player->unk_A90 + } +} + +/** + * Unused ActionFunc: assigned by EnWarpTag_Unused809C09A0, no known variants use. + */ +void EnWarpTag_Unused809C0A20(EnWarptag* this, GlobalContext* globalCtx) { + if (globalCtx->msgCtx.ocarinaMode == 9) { + func_800B7298(globalCtx, NULL, 7); + this->actionFunc = EnWarpTag_RespawnPlayer; + ActorCutscene_Stop(ActorCutscene_GetCurrentIndex()); + + } else if (globalCtx->msgCtx.ocarinaMode >= 2) { + globalCtx->msgCtx.ocarinaMode = 4; + this->actionFunc = EnWarpTag_Unused809C09A0; + } +} + +/** + * ActionFunc: Goron Trial (Moon), respawn at the beginning of goron rolling track, try again. + */ +void EnWarpTag_RespawnPlayer(EnWarptag* this, GlobalContext* globalCtx) { + ActorEntry* playerActorEntry; + Player* player; + s32 playerSpawnIndex; + s32 new15E; + s32 entranceIndex; + u32 playerSpawnIndexPerForm[PLAYER_FORM_MAX]; + u8 playerForm; + s16 playerParams; + + player = GET_PLAYER(globalCtx); + if (globalCtx->playerActorCsIds[4] >= 0 && ActorCutscene_GetCurrentIndex() != globalCtx->playerActorCsIds[4]) { + if (ActorCutscene_GetCanPlayNext(globalCtx->playerActorCsIds[4]) == 0) { + ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[4]); + + } else { + ActorCutscene_StartAndSetUnkLinkFields(globalCtx->playerActorCsIds[4], &this->dyna.actor); + func_800B8E58(player, NA_SE_PL_WARP_PLATE); + func_8016566C(0); + } + + } else { + f32 diffX = player->actor.world.pos.x - this->dyna.actor.world.pos.x; + Vec3f newRespawnPos; + f32 diffZ = player->actor.world.pos.z - this->dyna.actor.world.pos.z; + f32 distance = sqrtf(SQ(diffX) + SQ(diffZ)); + + // some weird float behavior prevention? + if (distance != 0.0f) { + distance = (distance - 1.0f) / distance; + distance = CLAMP_MIN(distance, 0.0f); + } + + player->actor.world.pos.x = this->dyna.actor.world.pos.x + (diffX * distance); + player->actor.world.pos.z = this->dyna.actor.world.pos.z + (diffZ * distance); + + if (Math_StepToS(&this->unkValue15E, 0x2710, 0xC8)) { + player->stateFlags3 |= 0x1; + player->actor.gravity = -0.5f; + + if (this->dyna.actor.playerHeightRel < -80.0f) { + playerSpawnIndexPerForm[PLAYER_FORM_FIERCE_DEITY] = GET_WARPTAG_EXIT_INDEX(&this->dyna.actor); + playerSpawnIndexPerForm[PLAYER_FORM_HUMAN] = playerSpawnIndexPerForm[PLAYER_FORM_FIERCE_DEITY]; + playerSpawnIndexPerForm[PLAYER_FORM_GORON] = this->dyna.actor.world.rot.x; + playerSpawnIndexPerForm[PLAYER_FORM_ZORA] = this->dyna.actor.world.rot.y; + playerSpawnIndexPerForm[PLAYER_FORM_DEKU] = this->dyna.actor.world.rot.z; + + if (this->dyna.actor.draw != NULL) { + playerForm = PLAYER_BOOTS_FIERCE_DEITY; + } else { + playerForm = player->transformation; + } + + entranceIndex = gSaveContext.save.entranceIndex; + + playerSpawnIndex = playerSpawnIndexPerForm[playerForm]; + playerActorEntry = &globalCtx->linkActorEntry[playerSpawnIndex]; + newRespawnPos.x = playerActorEntry->pos.x; + newRespawnPos.y = playerActorEntry->pos.y; + newRespawnPos.z = playerActorEntry->pos.z; + + if (GET_WARPTAG_3C0_MAX(&this->dyna.actor) == WARPTAG_3C0_MAX) { + playerParams = 0x9FF; + } else { // not used by any known variant + playerParams = 0x8FF; + } + + // why are we getting player home rotation from the room data? doesnt player have home.rot.y? + // especially because we are converting from deg to binang, but isnt home.rot.y already in binang?? + Play_SetRespawnData( + &globalCtx->state, 0, entranceIndex, // parameter 3 is called "sceneSetup" + globalCtx->setupEntranceList[playerSpawnIndex].room, playerParams, &newRespawnPos, + ((((playerActorEntry->rot.y >> 7) & 0x1FF) / 180.0f) * 32768.0f)); // DEG_TO_BINANG ? + + func_80169EFC(&globalCtx->state); + gSaveContext.respawnFlag = ~0x4; + func_80165690(); + } + } + + player->actor.shape.rot.y += this->unkValue15E; + new15E = this->unkValue15E - 0xFA0; + if (new15E < 0) { + new15E = 0; + } + func_80165658(new15E * 0.04f); // unknown Play_ function + } +} + +/** + * ActionFunc: Deku Playground, return to North Clock Town. + */ +void EnWarpTag_GrottoReturn(EnWarptag* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCurrentIndex() != this->dyna.actor.cutscene) { + if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } + } + + if (this->grottoExitDelay++ == 10) { + globalCtx->nextEntranceIndex = globalCtx->setupExitList[GET_WARPTAG_EXIT_INDEX(&this->dyna.actor)]; + Scene_SetExitFade(globalCtx); + globalCtx->sceneLoadFlag = 0x14; + func_8019F128(NA_SE_OC_SECRET_HOLE_OUT); + func_801A4058(5); + if (1) {} + gSaveContext.seqIndex = 0xFF; + gSaveContext.nightSeqIndex = 0xFF; + } +} + +void EnWarptag_Update(Actor* thisx, GlobalContext* globalCtx) { + EnWarptag* this = THIS; + this->actionFunc(this, globalCtx); +} + +/** + * Only draws for Goron Trial (a rainblow animated target). + */ +void EnWarpTag_Draw(Actor* thisx, GlobalContext* globalCtx) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&gWarpTagRainbowAnimMat)); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_OPA_DISP++, gWarpTagGoronTrialBaseDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.h b/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.h index 1be6eb5ec7..925fda9305 100644 --- a/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.h +++ b/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.h @@ -8,11 +8,27 @@ struct EnWarptag; typedef void (*EnWarptagActionFunc)(struct EnWarptag*, GlobalContext*); typedef struct EnWarptag { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x1C]; - /* 0x0160 */ EnWarptagActionFunc actionFunc; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ s8 dangeonKeepObject; + /* 0x15E */ union { + s16 reusedValue; // default name + s16 unkValue15E; // passed to unk play func, mods player rotation, stepped to 0x2710 + s16 grottoExitDelay; // 10 frame delay before player can leave the grotto + }; + /* 0x160 */ EnWarptagActionFunc actionFunc; } EnWarptag; // size = 0x164 extern const ActorInit En_Warp_tag_InitVars; +// Only two known Variants: +// Goron Trial (MOON): 0x03C1 +// Deku Playground: 0x83C0 + +#define GET_WARPTAG_3C0_MAX(thisx) ((thisx)->params & 0x3C0) +#define GET_WARPTAG_3C0(thisx) (((thisx)->params >> 6) & 0xF) +#define GET_WARPTAG_EXIT_INDEX(thisx) ((thisx)->params & 0x3F) +#define GET_WARPTAG_INVISIBLE(thisx) ((thisx)->params < 0) // 0x8000 flag + +#define WARPTAG_3C0_MAX 0x3C0 + #endif // Z_EN_WARP_TAG_H diff --git a/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.c b/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.c index 314d168cc5..127bcc1c2f 100644 --- a/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.c +++ b/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.c @@ -405,7 +405,7 @@ void func_80A59C04(Actor* thisx, GlobalContext* globalCtx2) { if ((rotaryRoom != NULL) && Flags_GetSwitch(globalCtx, (rotaryRoom->params >> 1) & 0x7F)) { this->unk_DC6 = Rand_ZeroFloat(150.0f) + 100.0f; - } else if (!func_801690CC(globalCtx)) { + } else if (!Play_InCsMode(globalCtx)) { this->unk_DC4++; if (this->unk_DC6 == 0) { this->unk_DC6 = Rand_ZeroFloat(150.0f) + 100.0f; diff --git a/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c b/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c index 7e025ce434..f4d999fae0 100644 --- a/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c +++ b/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c @@ -77,7 +77,7 @@ void EnWeatherTag_Init(Actor* thisx, GlobalContext* globalCtx) { EnWeatherTag_SetupAction(this, func_80966A08); break; case WEATHERTAG_TYPE_UNK1: - if (gSaveContext.weekEventReg[52] & 0x20) { // if cleared STT + if (gSaveContext.save.weekEventReg[52] & 0x20) { // if cleared STT Actor_MarkForDeath(&this->actor); } EnWeatherTag_SetupAction(this, func_80966B08); @@ -252,7 +252,7 @@ void func_80966BF4(EnWeatherTag* this, GlobalContext* globalCtx) { if (Cutscene_CheckActorAction(globalCtx, 567)) { tmpAction = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 567)]; if ((globalCtx->csCtx.frames >= tmpAction->startFrame) && (tmpAction->action >= 2)) { - switch (gSaveContext.day) { + switch (gSaveContext.save.day) { case 0: case 1: default: @@ -282,7 +282,7 @@ void func_80966BF4(EnWeatherTag* this, GlobalContext* globalCtx) { void func_80966D20(EnWeatherTag* this, GlobalContext* globalCtx) { u8 newUnk20; - switch (gSaveContext.day) { + switch (gSaveContext.save.day) { case 0: case 1: default: @@ -422,8 +422,8 @@ void func_809672DC(EnWeatherTag* this, GlobalContext* globalCtx) { f32 range; f32 strength = 0.0f; - func_800BCCDC(this->pathPoints, this->pathCount, &GET_PLAYER(globalCtx)->actor.world.pos, &this->actor.world.pos, - 0); + Actor_GetClosestPosOnPath(this->pathPoints, this->pathCount, &GET_PLAYER(globalCtx)->actor.world.pos, + &this->actor.world.pos, false); distance = Actor_XZDistanceBetweenActors(&player->actor, &this->actor); range = WEATHER_TAG_RANGE100(this); @@ -452,7 +452,7 @@ void func_809674C8(EnWeatherTag* this, GlobalContext* globalCtx) { if (Actor_XZDistanceBetweenActors(&player->actor, &this->actor) < WEATHER_TAG_RANGE100(this)) { if (CURRENT_DAY == 2) { - if ((gSaveContext.time >= CLOCK_TIME(7, 0)) && (gSaveContext.time < CLOCK_TIME(17, 30)) && + if ((gSaveContext.save.time >= CLOCK_TIME(7, 0)) && (gSaveContext.save.time < CLOCK_TIME(17, 30)) && (globalCtx->envCtx.unk_F2[2] == 0)) { D_801BDBB0 = 1; @@ -485,15 +485,15 @@ void EnWeatherTag_Update(Actor* thisx, GlobalContext* globalCtx) { u16 oldTime; this->actionFunc(this, globalCtx); - if ((globalCtx->actorCtx.unk5 & 2) && (globalCtx->msgCtx.msgMode != 0) && (globalCtx->msgCtx.unk11F04 == 0x5E6) && - (!FrameAdvance_IsEnabled(&globalCtx->state)) && (globalCtx->sceneLoadFlag == 0) && - (ActorCutscene_GetCurrentIndex() == -1) && (globalCtx->csCtx.state == 0)) { + if ((globalCtx->actorCtx.unk5 & 2) && (globalCtx->msgCtx.msgMode != 0) && + (globalCtx->msgCtx.currentTextId == 0x5E6) && (!FrameAdvance_IsEnabled(&globalCtx->state)) && + (globalCtx->sceneLoadFlag == 0) && (ActorCutscene_GetCurrentIndex() == -1) && (globalCtx->csCtx.state == 0)) { - oldTime = gSaveContext.time; - gSaveContext.time = (u16)REG(0xF) + oldTime; // cast req + oldTime = gSaveContext.save.time; + gSaveContext.save.time = (u16)REG(0xF) + oldTime; // cast req if (REG(0xF) != 0) { - oldTime = gSaveContext.time; - gSaveContext.time = (u16)gSaveContext.unk_14 + oldTime; + oldTime = gSaveContext.save.time; + gSaveContext.save.time = (u16)gSaveContext.save.daySpeed + oldTime; } } } diff --git a/src/overlays/actors/ovl_En_Wf/z_en_wf.c b/src/overlays/actors/ovl_En_Wf/z_en_wf.c index 9f109b1cd9..fdd82b864d 100644 --- a/src/overlays/actors/ovl_En_Wf/z_en_wf.c +++ b/src/overlays/actors/ovl_En_Wf/z_en_wf.c @@ -7,7 +7,6 @@ #include "z_en_wf.h" #include "overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.h" #include "overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.h" -#include "objects/object_wf/object_wf.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_400) @@ -240,18 +239,18 @@ static DamageTable sDamageTable2 = { static CollisionCheckInfoInit sColChkInfoInit = { 8, 50, 100, MASS_HEAVY }; -static TexturePtr D_809942B0[] = { - object_wf_Tex_007AA8, - object_wf_Tex_0082A8, - object_wf_Tex_0084A8, - object_wf_Tex_0082A8, +static TexturePtr sNormalEyeTextures[] = { + gWolfosNormalEyeOpenTex, + gWolfosNormalEyeHalfTex, + gWolfosNormalEyeNarrowTex, + gWolfosNormalEyeHalfTex, }; -static TexturePtr D_809942C0[] = { - object_wf_Tex_000300, - object_wf_Tex_0027D8, - object_wf_Tex_0029D8, - object_wf_Tex_0027D8, +static TexturePtr sWhiteEyeTextures[] = { + gWolfosWhiteEyeOpenTex, + gWolfosWhiteEyeHalfTex, + gWolfosWhiteEyeNarrowTex, + gWolfosWhiteEyeHalfTex, }; static InitChainEntry sInitChain[] = { @@ -318,16 +317,16 @@ void EnWf_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, 0.0075f); if (this->actor.params == 0) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_wf_Skel_0095D0, &object_wf_Anim_00A3CC, - this->jointTable, this->morphTable, 22); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gWolfosNormalSkel, &gWolfosWaitingAnim, this->jointTable, + this->morphTable, WOLFOS_NORMAL_LIMB_MAX); this->actor.hintId = 0x4C; CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable2, &sColChkInfoInit); this->collider1.elements[0].info.toucher.damage = 8; this->collider1.elements[1].info.toucher.damage = 8; this->actor.colChkInfo.health = 6; } else { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_wf_Skel_003BC0, &object_wf_Anim_00A3CC, - this->jointTable, this->morphTable, 22); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gWolfosWhiteSkel, &gWolfosWaitingAnim, this->jointTable, + this->morphTable, WOLFOS_WHITE_LIMB_MAX); this->actor.hintId = 0x57; CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable1, &sColChkInfoInit); } @@ -342,9 +341,9 @@ void EnWf_Init(Actor* thisx, GlobalContext* globalCtx) { func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, 5); if (D_809942D8 == 0) { - for (i = 0; i < ARRAY_COUNT(D_809942B0); i++) { - D_809942B0[i] = Lib_SegmentedToVirtual(D_809942B0[i]); - D_809942C0[i] = Lib_SegmentedToVirtual(D_809942C0[i]); + for (i = 0; i < ARRAY_COUNT(sNormalEyeTextures); i++) { + sNormalEyeTextures[i] = Lib_SegmentedToVirtual(sNormalEyeTextures[i]); + sWhiteEyeTextures[i] = Lib_SegmentedToVirtual(sWhiteEyeTextures[i]); } D_809942D8 = 1; } @@ -360,10 +359,10 @@ void EnWf_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void func_809907D4(EnWf* this) { - this->unk_2B0 = 0.75f; - this->unk_2B4 = 1.125f; - this->unk_2AC = 1.0f; - this->unk_296 = 10; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffFrozenSteamScale = 1.125f; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; this->collider2.base.colType = COLTYPE_HIT3; this->collider3.base.colType = COLTYPE_HIT3; this->unk_2A0 = 80; @@ -372,24 +371,24 @@ void func_809907D4(EnWf* this) { } void func_80990854(EnWf* this, GlobalContext* globalCtx) { - if (this->unk_296 == 10) { - this->unk_296 = 0; + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->collider2.base.colType = COLTYPE_HIT5; this->collider3.base.colType = COLTYPE_HIT5; - this->unk_2AC = 0.0f; - Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_2B8, 10, 2, 0.3f, 0.2f); + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, 10, 2, 0.3f, 0.2f); this->actor.flags |= ACTOR_FLAG_400; } } -void func_809908E0(EnWf* this) { - if (this->unk_294 != 0) { - this->unk_294++; - if (this->unk_294 == 4) { - this->unk_294 = 0; +void EnWf_Blink(EnWf* this) { + if (this->eyeIndex != 0) { + this->eyeIndex++; + if (this->eyeIndex == 4) { + this->eyeIndex = 0; } } else if (Rand_ZeroOne() < 0.05f) { - this->unk_294 = 1; + this->eyeIndex = 1; } } @@ -550,7 +549,7 @@ void func_80990F50(EnWf* this, GlobalContext* globalCtx) { } void func_80990FC8(EnWf* this) { - Animation_Change(&this->skelAnime, &object_wf_Anim_0053D0, 0.5f, 0.0f, 7.0f, 3, 0.0f); + Animation_Change(&this->skelAnime, &gWolfosRearingUpFallingOverAnim, 0.5f, 0.0f, 7.0f, 3, 0.0f); this->unk_2A0 = 5; this->actor.flags |= ACTOR_FLAG_1; this->actionFunc = func_80991040; @@ -573,7 +572,7 @@ void func_80991040(EnWf* this, GlobalContext* globalCtx) { void func_809910F0(EnWf* this) { this->collider2.base.acFlags &= ~AC_ON; this->actor.speedXZ = 0.0f; - Animation_Change(&this->skelAnime, &object_wf_Anim_0053D0, 0.5f, 0.0f, 7.0f, 3, -5.0f); + Animation_Change(&this->skelAnime, &gWolfosRearingUpFallingOverAnim, 0.5f, 0.0f, 7.0f, 3, -5.0f); this->unk_2A0 = 5; this->actionFunc = func_80991174; } @@ -592,7 +591,7 @@ void func_80991174(EnWf* this, GlobalContext* globalCtx) { void func_80991200(EnWf* this) { this->collider2.base.acFlags |= AC_ON; - Animation_MorphToLoop(&this->skelAnime, &object_wf_Anim_00A3CC, -4.0f); + Animation_MorphToLoop(&this->skelAnime, &gWolfosWaitingAnim, -4.0f); this->unk_2A0 = (s32)Rand_ZeroFloat(10.0f) + 2; this->actor.world.rot.y = this->actor.shape.rot.y; this->actionFunc = func_80991280; @@ -643,7 +642,7 @@ void func_80991280(EnWf* this, GlobalContext* globalCtx) { void func_80991438(EnWf* this) { this->collider2.base.acFlags |= AC_ON; - Animation_MorphToLoop(&this->skelAnime, &object_wf_Anim_005700, -4.0f); + Animation_MorphToLoop(&this->skelAnime, &gWolfosRunningAnim, -4.0f); this->actor.world.rot.y = this->actor.shape.rot.y; this->actor.speedXZ = 8.0f; this->actionFunc = func_8099149C; @@ -704,7 +703,7 @@ void func_8099149C(EnWf* this, GlobalContext* globalCtx) { } void func_80991738(EnWf* this) { - Animation_MorphToLoop(&this->skelAnime, &object_wf_Anim_009808, -4.0f); + Animation_MorphToLoop(&this->skelAnime, &gWolfosSidesteppingAnim, -4.0f); this->actionFunc = func_8099177C; } @@ -756,7 +755,7 @@ void func_8099177C(EnWf* this, GlobalContext* globalCtx) { void func_80991948(EnWf* this) { this->collider2.base.acFlags |= AC_ON; - Animation_MorphToLoop(&this->skelAnime, &object_wf_Anim_005700, -4.0f); + Animation_MorphToLoop(&this->skelAnime, &gWolfosRunningAnim, -4.0f); if (Rand_ZeroOne() > 0.5f) { this->unk_29A = 16000; } else { @@ -810,7 +809,7 @@ void func_809919F4(EnWf* this, GlobalContext* globalCtx) { void func_80991C04(EnWf* this) { this->collider2.base.acFlags |= AC_ON; - Animation_PlayOnce(&this->skelAnime, &object_wf_Anim_004638); + Animation_PlayOnce(&this->skelAnime, &gWolfosSlashingAnim); this->collider1.base.atFlags &= ~AT_BOUNCED; this->actor.shape.rot.y = this->actor.yawTowardsPlayer; this->unk_2A0 = 7; @@ -880,7 +879,7 @@ void func_80991FD8(EnWf* this) { if (this->skelAnime.curFrame > 15.0f) { phi_f0 = 15.0f; } - Animation_Change(&this->skelAnime, &object_wf_Anim_004638, -0.5f, this->skelAnime.curFrame - 1.0f, phi_f0, 3, 0.0f); + Animation_Change(&this->skelAnime, &gWolfosSlashingAnim, -0.5f, this->skelAnime.curFrame - 1.0f, phi_f0, 3, 0.0f); this->collider1.base.atFlags &= ~AT_ON; this->actionFunc = func_80992068; } @@ -923,7 +922,7 @@ void func_80992068(EnWf* this, GlobalContext* globalCtx) { void func_8099223C(EnWf* this) { this->collider2.base.acFlags &= ~AC_ON; - Animation_MorphToPlayOnce(&this->skelAnime, &object_wf_Anim_004A90, -3.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &gWolfosBackflippingAnim, -3.0f); this->unk_2A0 = 0; this->actor.speedXZ = -6.0f; this->actor.shape.rot.y = this->actor.yawTowardsPlayer; @@ -973,7 +972,7 @@ void func_809923E4(EnWf* this, GlobalContext* globalCtx) { void func_8099245C(EnWf* this) { this->collider2.base.acFlags &= ~AC_ON; - Animation_MorphToPlayOnce(&this->skelAnime, &object_wf_Anim_009A50, -4.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &gWolfosDamagedAnim, -4.0f); if (this->actor.bgCheckFlags & 1) { this->actor.speedXZ = -4.0f; } @@ -1021,8 +1020,8 @@ void func_809924EC(EnWf* this, GlobalContext* globalCtx) { void func_809926D0(EnWf* this) { this->collider2.base.acFlags &= ~AC_ON; - Animation_Change(&this->skelAnime, &object_wf_Anim_004A90, -1.0f, - Animation_GetLastFrame(&object_wf_Anim_004A90.common), 0.0f, 2, -3.0f); + Animation_Change(&this->skelAnime, &gWolfosBackflippingAnim, -1.0f, + Animation_GetLastFrame(&gWolfosBackflippingAnim.common), 0.0f, 2, -3.0f); this->unk_2A0 = 0; this->actor.speedXZ = 6.5f; this->actor.velocity.y = 15.0f; @@ -1053,8 +1052,8 @@ void func_8099282C(EnWf* this) { this->collider1.base.atFlags &= ~AT_ON; this->unk_2A0 = 10; this->actor.speedXZ = 0.0f; - Animation_Change(&this->skelAnime, &object_wf_Anim_004C44, -1.0f, - Animation_GetLastFrame(&object_wf_Anim_004C44.common), 0.0f, 2, -2.0f); + Animation_Change(&this->skelAnime, &gWolfosBlockingAnim, -1.0f, Animation_GetLastFrame(&gWolfosBlockingAnim.common), + 0.0f, 2, -2.0f); this->actionFunc = func_809928CC; } @@ -1091,7 +1090,7 @@ void func_80992A74(EnWf* this, GlobalContext* globalCtx) { f32 temp_f0; this->collider2.base.acFlags |= AC_ON; - Animation_MorphToLoop(&this->skelAnime, &object_wf_Anim_005700, -4.0f); + Animation_MorphToLoop(&this->skelAnime, &gWolfosRunningAnim, -4.0f); player = GET_PLAYER(globalCtx); temp_f0 = Math_SinS((player->actor.shape.rot.y + this->unk_29A) - this->actor.yawTowardsPlayer); if (temp_f0 > 0.0f) { @@ -1153,7 +1152,7 @@ void func_80992B8C(EnWf* this, GlobalContext* globalCtx) { void func_80992D6C(EnWf* this) { this->collider2.base.acFlags &= ~AC_ON; - Animation_MorphToPlayOnce(&this->skelAnime, &object_wf_Anim_0053D0, -4.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &gWolfosRearingUpFallingOverAnim, -4.0f); this->actor.world.rot.y = this->actor.yawTowardsPlayer; if (this->actor.bgCheckFlags & 1) { this->actor.speedXZ = -6.0f; @@ -1205,7 +1204,7 @@ void func_80992E0C(EnWf* this, GlobalContext* globalCtx) { } void func_80992FD4(EnWf* this) { - Animation_MorphToLoop(&this->skelAnime, &object_wf_Anim_00A3CC, -4.0f); + Animation_MorphToLoop(&this->skelAnime, &gWolfosWaitingAnim, -4.0f); this->actionFunc = func_80993018; } @@ -1232,7 +1231,7 @@ void func_80993018(EnWf* this, GlobalContext* globalCtx) { } void func_80993148(EnWf* this) { - Animation_MorphToLoop(&this->skelAnime, &object_wf_Anim_005700, -4.0f); + Animation_MorphToLoop(&this->skelAnime, &gWolfosRunningAnim, -4.0f); this->actor.speedXZ = 0.0f; this->actionFunc = func_80993194; } @@ -1277,7 +1276,7 @@ void func_80993194(EnWf* this, GlobalContext* globalCtx) { } void func_80993350(EnWf* this) { - Animation_MorphToLoop(&this->skelAnime, &object_wf_Anim_005700, -4.0f); + Animation_MorphToLoop(&this->skelAnime, &gWolfosRunningAnim, -4.0f); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_APPEAR); this->actionFunc = func_809933A0; } @@ -1317,7 +1316,7 @@ void func_809933A0(EnWf* this, GlobalContext* globalCtx) { } void func_80993524(EnWf* this) { - Animation_MorphToLoop(&this->skelAnime, &object_wf_Anim_005700, -4.0f); + Animation_MorphToLoop(&this->skelAnime, &gWolfosRunningAnim, -4.0f); this->actor.speedXZ = 6.0f; this->actor.world.rot.y = this->actor.shape.rot.y; this->actionFunc = func_8099357C; @@ -1410,7 +1409,7 @@ void func_8099386C(EnWf* this, GlobalContext* globalCtx) { this->collider3.base.acFlags &= ~AC_HIT; this->collider1.base.atFlags &= ~AT_ON; - if (((this->unk_296 != 10) || + if (((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || !(collider->info.acHitInfo->toucher.dmgFlags & (0x80000 | 0x40000 | 0x10000 | 0x8000 | 0x2000 | 0x1000 | 0x80 | 0x20 | 0x10 | 0x2 | 0x1))) && (this->actor.colChkInfo.damageEffect != 0xF)) { @@ -1428,9 +1427,9 @@ void func_8099386C(EnWf* this, GlobalContext* globalCtx) { } else if (this->actor.colChkInfo.damageEffect == 5) { this->unk_2A0 = 40; Actor_SetColorFilter(&this->actor, 0, 0xFF, 0, 40); - this->unk_296 = 30; - this->unk_2B0 = 0.75f; - this->unk_2AC = 2.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffAlpha = 2.0f; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); func_809923B0(this); } else if (this->actor.colChkInfo.damageEffect == 3) { @@ -1442,13 +1441,13 @@ void func_8099386C(EnWf* this, GlobalContext* globalCtx) { func_809923B0(this); } else { if (this->actor.colChkInfo.damageEffect == 2) { - this->unk_296 = 0; - this->unk_2B0 = 0.75f; - this->unk_2AC = 4.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffAlpha = 4.0f; } else if (this->actor.colChkInfo.damageEffect == 4) { - this->unk_296 = 20; - this->unk_2B0 = 0.75f; - this->unk_2AC = 4.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffAlpha = 4.0f; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, collider->info.bumper.hitPos.x, collider->info.bumper.hitPos.y, collider->info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); @@ -1477,7 +1476,7 @@ void EnWf_Update(Actor* thisx, GlobalContext* globalCtx) { func_8099386C(this, globalCtx); if (this->actionFunc != func_809923E4) { - func_809908E0(this); + EnWf_Blink(this); } this->actionFunc(this, globalCtx); @@ -1517,16 +1516,16 @@ void EnWf_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_SetFocus(&this->actor, 25.0f); - if (this->unk_2AC > 0.0f) { - if (this->unk_296 != 10) { - Math_StepToF(&this->unk_2AC, 0.0f, 0.05f); - this->unk_2B0 = (this->unk_2AC + 1.0f) * 0.375f; - if (this->unk_2B0 > 0.75f) { - this->unk_2B0 = 0.75f; + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.375f; + if (this->drawDmgEffScale > 0.75f) { + this->drawDmgEffScale = 0.75f; } else { - this->unk_2B0 = this->unk_2B0; + this->drawDmgEffScale = this->drawDmgEffScale; } - } else if (!Math_StepToF(&this->unk_2B4, 0.75f, 0.01875f)) { + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.75f, 0.01875f)) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } @@ -1535,7 +1534,7 @@ void EnWf_Update(Actor* thisx, GlobalContext* globalCtx) { s32 EnWf_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnWf* this = THIS; - if ((limbIndex == 17) || (limbIndex == 18)) { + if ((limbIndex == WOLFOS_NORMAL_LIMB_HEAD) || (limbIndex == WOLFOS_NORMAL_LIMB_EYES)) { rot->y -= this->unk_29E; } return false; @@ -1551,10 +1550,10 @@ void EnWf_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec Collider_UpdateSpheres(limbIndex, &this->collider1); if (D_809942FC[limbIndex] != -1) { - Matrix_GetStateTranslation(&this->unk_2B8[D_809942FC[limbIndex]]); + Matrix_GetStateTranslation(&this->limbPos[D_809942FC[limbIndex]]); } - if (limbIndex == 6) { + if (limbIndex == WOLFOS_NORMAL_LIMB_TAIL) { Matrix_GetStateTranslationAndScaledX(1200.0f, &sp20); this->collider3.dim.pos.x = sp20.x; this->collider3.dim.pos.y = sp20.y; @@ -1571,17 +1570,18 @@ void EnWf_Draw(Actor* thisx, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); if (this->actor.params == 0) { - gSPSegment(POLY_OPA_DISP++, 0x08, D_809942B0[this->unk_294]); + gSPSegment(POLY_OPA_DISP++, 0x08, sNormalEyeTextures[this->eyeIndex]); } else { - gSPSegment(POLY_OPA_DISP++, 0x08, D_809942C0[this->unk_294]); + gSPSegment(POLY_OPA_DISP++, 0x08, sWhiteEyeTextures[this->eyeIndex]); } CLOSE_DISPS(globalCtx->state.gfxCtx); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnWf_OverrideLimbDraw, EnWf_PostLimbDraw, &this->actor); - func_800BE680(globalCtx, &this->actor, this->unk_2B8, 10, this->unk_2B0, this->unk_2B4, this->unk_2AC, - this->unk_296); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + this->drawDmgEffScale, this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, + this->drawDmgEffType); } } diff --git a/src/overlays/actors/ovl_En_Wf/z_en_wf.h b/src/overlays/actors/ovl_En_Wf/z_en_wf.h index defd8fc793..94cfb18e72 100644 --- a/src/overlays/actors/ovl_En_Wf/z_en_wf.h +++ b/src/overlays/actors/ovl_En_Wf/z_en_wf.h @@ -2,6 +2,7 @@ #define Z_EN_WF_H #include "global.h" +#include "objects/object_wf/object_wf.h" struct EnWf; @@ -12,12 +13,12 @@ typedef void (*EnWfActionFunc)(struct EnWf*, GlobalContext*); typedef struct EnWf { /* 0x0000 */ Actor actor; /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ Vec3s jointTable[22]; - /* 0x020C */ Vec3s morphTable[22]; + /* 0x0188 */ Vec3s jointTable[WOLFOS_NORMAL_LIMB_MAX]; + /* 0x020C */ Vec3s morphTable[WOLFOS_NORMAL_LIMB_MAX]; /* 0x0290 */ EnWfActionFunc actionFunc; - /* 0x0294 */ u8 unk_294; + /* 0x0294 */ u8 eyeIndex; /* 0x0295 */ u8 unk_295; - /* 0x0296 */ u8 unk_296; + /* 0x0296 */ u8 drawDmgEffType; /* 0x0298 */ s16 unk_298; /* 0x029A */ s16 unk_29A; /* 0x029C */ s16 unk_29C; @@ -26,10 +27,10 @@ typedef struct EnWf { /* 0x02A2 */ u16 unk_2A2; /* 0x02A4 */ f32 unk_2A4; /* 0x02A8 */ f32 unk_2A8; - /* 0x02AC */ f32 unk_2AC; - /* 0x02B0 */ f32 unk_2B0; - /* 0x02B4 */ f32 unk_2B4; - /* 0x02B8 */ Vec3f unk_2B8[10]; + /* 0x02AC */ f32 drawDmgEffAlpha; + /* 0x02B0 */ f32 drawDmgEffScale; + /* 0x02B4 */ f32 drawDmgEffFrozenSteamScale; + /* 0x02B8 */ Vec3f limbPos[10]; /* 0x0330 */ ColliderJntSph collider1; /* 0x0350 */ ColliderJntSphElement collider1Elements[4]; /* 0x0450 */ ColliderCylinder collider2; diff --git a/src/overlays/actors/ovl_En_Wood02/z_en_wood02.c b/src/overlays/actors/ovl_En_Wood02/z_en_wood02.c index e24a5af959..446d92cbdd 100644 --- a/src/overlays/actors/ovl_En_Wood02/z_en_wood02.c +++ b/src/overlays/actors/ovl_En_Wood02/z_en_wood02.c @@ -5,6 +5,7 @@ */ #include "z_en_wood02.h" +#include "objects/object_wood02/object_wood02.h" #define FLAGS 0x00000000 @@ -15,7 +16,28 @@ void EnWood02_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnWood02_Update(Actor* thisx, GlobalContext* globalCtx); void EnWood02_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +/** + * WOOD_SPAWN_SPAWNER is also used by some individual trees: EnWood02_Update also checks for parent before running any + * despawning code. + * */ +typedef enum { + /* 0 */ WOOD_SPAWN_NORMAL, + /* 1 */ WOOD_SPAWN_SPAWNED, + /* 2 */ WOOD_SPAWN_SPAWNER +} WoodSpawnType; + +typedef enum { + /* 0 */ WOOD_DRAW_TREE_CONICAL, + /* 1 */ WOOD_DRAW_TREE_OVAL, + /* 2 */ WOOD_DRAW_TREE_KAKARIKO_ADULT, + /* 3 */ WOOD_DRAW_BUSH_GREEN, + /* 4 */ WOOD_DRAW_4, // Used for black bushes and green leaves + /* 5 */ WOOD_DRAW_LEAF_YELLOW +} WoodDrawType; + +static f32 sSpawnCos; +static f32 sSpawnSin; + const ActorInit En_Wood02_InitVars = { ACTOR_EN_WOOD02, ACTORCAT_PROP, @@ -28,29 +50,464 @@ const ActorInit En_Wood02_InitVars = { (ActorFunc)EnWood02_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_808C4D00 = { - { COLTYPE_TREE, AT_NONE, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK5, { 0x00000000, 0x00, 0x00 }, { 0x0100020A, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_TREE, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK5, + { 0x00000000, 0x00, 0x00 }, + { 0x0100020A, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 18, 60, 0, { 0, 0, 0 } }, }; -#endif +static f32 sSpawnDistance[] = { 707.0f, 525.0f, 510.0f, 500.0f, 566.0f, 141.0f }; -extern ColliderCylinderInit D_808C4D00; +static s16 sSpawnAngle[] = { 0x1FFF, 0x4C9E, 0x77F5, 0xA5C9, -0x293D, 0xA000 }; -extern UNK_TYPE D_06000700; +static InitChainEntry sInitChain[] = { + ICHAIN_F32(targetArrowOffset, 5600, ICHAIN_STOP), +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wood02/func_808C3C00.s") +Gfx* D_808C4D54[] = { + object_wood02_DL_0078D0, object_wood02_DL_007CA0, object_wood02_DL_008160, object_wood02_DL_000090, + object_wood02_DL_000340, object_wood02_DL_000340, object_wood02_DL_000700, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wood02/func_808C3D28.s") +Gfx* D_808C4D70[] = { + object_wood02_DL_007968, + object_wood02_DL_007D38, + object_wood02_DL_0080D0, + NULL, + NULL, + NULL, + object_wood02_DL_007AD0, + object_wood02_DL_007E20, + object_wood02_DL_009340, + object_wood02_DL_000160, + object_wood02_DL_000440, + object_wood02_DL_000700, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wood02/EnWood02_Init.s") +s32 EnWood02_SpawnZoneCheck(EnWood02* this, GlobalContext* globalCtx, Vec3f* arg2) { + f32 phi_f12; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wood02/EnWood02_Destroy.s") + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, arg2, &this->actor.projectedPos, + &this->actor.projectedW); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wood02/func_808C4458.s") + if (this->actor.projectedW == 0.0f) { + phi_f12 = 1000.0f; + } else { + phi_f12 = fabsf(1.0f / this->actor.projectedW); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wood02/EnWood02_Update.s") + if (((-this->actor.uncullZoneScale < this->actor.projectedPos.z) && + (this->actor.projectedPos.z < (this->actor.uncullZoneForward + this->actor.uncullZoneScale)) && + (((fabsf(this->actor.projectedPos.x) - this->actor.uncullZoneScale) * phi_f12) < 1.0f)) && + (((this->actor.projectedPos.y + this->actor.uncullZoneDownward) * phi_f12) > -1.0f) && + (((this->actor.projectedPos.y - this->actor.uncullZoneScale) * phi_f12) < 1.0f)) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wood02/EnWood02_Draw.s") +/** Spawns similar-looking trees or bushes only when the player is sufficiently close. Presumably done this way to keep + * memory usage down in Hyrule Field. */ +void EnWood02_SpawnOffspring(EnWood02* this, GlobalContext* globalCtx) { + EnWood02* child; + s32 extraRot; + Vec3f childPos; + s32 unk; + s32 i; + s16 childParams; + + for (i = 4; i >= 0; i--) { + extraRot = 0; + if (!(this->unk_14A[i] & 0x7F)) { + if (this->actor.params == WOOD_BUSH_GREEN_LARGE_SPAWNER) { + extraRot = 0x4000; + } + + sSpawnCos = Math_CosS(sSpawnAngle[i] + this->actor.world.rot.y + extraRot); + sSpawnSin = Math_SinS(sSpawnAngle[i] + this->actor.world.rot.y + extraRot); + + childPos.x = (sSpawnDistance[i] * sSpawnSin) + this->actor.home.pos.x; + childPos.y = this->actor.home.pos.y; + childPos.z = (sSpawnDistance[i] * sSpawnCos) + this->actor.home.pos.z; + + if (EnWood02_SpawnZoneCheck(this, globalCtx, &childPos)) { + if (this->unk_14A[i] & 0x80) { + unk = 0; + } else { + unk = this->actor.home.rot.z; + } + + childParams = ((this->unk_144 << 8) & 0xFF00) | (this->actor.params + 1); + child = (EnWood02*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_WOOD02, + childPos.x, childPos.y, childPos.z, this->actor.world.rot.x, + sSpawnAngle[i], unk, childParams); + if (child != NULL) { + child->unk_14A[0] = i; + this->unk_14A[i] |= 1; + child->actor.projectedPos = this->actor.projectedPos; + } else { + this->unk_14A[i] &= 0x80; + } + } + } + } +} + +void EnWood02_Init(Actor* thisx, GlobalContext* globalCtx) { + s16 spawnType = 0; + f32 actorScale = 1.0f; + EnWood02* this = THIS; + s32 pad; + CollisionPoly* outPoly; + s32 bgId; + f32 floorY; + s16 extraRot; + + this->actor.world.rot.z = 0; + this->unk_144 = ENWOOD02_GET_FF00(&this->actor); + this->unk_146 = -1; + this->actor.shape.rot.z = this->actor.world.rot.z; + + if (this->unk_144 & 0x80) { + this->unk_144 = -1; + } + + this->actor.params &= 0xFF; + this->unk_148 = this->actor.home.rot.z; + + Actor_ProcessInitChain(&this->actor, sInitChain); + + if ((this->actor.params < WOOD_BUSH_GREEN_SMALL) || (this->actor.params == WOOD_TREE_SPECIAL)) { + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + } + + if ((this->actor.params == WOOD_TREE_SPECIAL) && !gSaveContext.save.isNight && (this->unk_144 != -1) && + !Flags_GetCollectible(globalCtx, this->unk_144)) { + this->actor.child = + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_ANI, this->actor.world.pos.x, + this->actor.world.pos.y + 120.0f, this->actor.world.pos.z - 15.0f, 0, 0, 0, 1); + if (this->actor.child != NULL) { + this->actor.child->cutscene = this->actor.cutscene; + } + this->unk_151 = 1; + } else { + this->actor.child = NULL; + this->unk_151 = 0; + } + + switch (this->actor.params) { + case WOOD_BUSH_GREEN_LARGE_SPAWNER: + case WOOD_BUSH_BLACK_LARGE_SPAWNER: + spawnType = 1; + + case WOOD_BUSH_GREEN_LARGE_SPAWNED: + case WOOD_BUSH_BLACK_LARGE_SPAWNED: + spawnType++; + + case WOOD_TREE_CONICAL_LARGE: + case WOOD_BUSH_GREEN_LARGE: + case WOOD_BUSH_BLACK_LARGE: + case WOOD_TREE_SPECIAL: + actorScale = 1.5f; + this->actor.uncullZoneForward = 4000.0f; + this->actor.uncullZoneScale = 2000.0f; + this->actor.uncullZoneDownward = 2400.0f; + break; + + case WOOD_TREE_CONICAL_SPAWNER: + case WOOD_TREE_OVAL_YELLOW_SPAWNER: + case WOOD_TREE_OVAL_GREEN_SPAWNER: + case WOOD_BUSH_GREEN_SMALL_SPAWNER: + case WOOD_BUSH_BLACK_SMALL_SPAWNER: + spawnType = 1; + + case WOOD_TREE_CONICAL_SPAWNED: + case WOOD_TREE_OVAL_YELLOW_SPAWNED: + case WOOD_TREE_OVAL_GREEN_SPAWNED: + case WOOD_BUSH_GREEN_SMALL_SPAWNED: + case WOOD_BUSH_BLACK_SMALL_SPAWNED: + spawnType++; + + case WOOD_TREE_CONICAL_MEDIUM: + case WOOD_TREE_OVAL_GREEN: + case WOOD_TREE_KAKARIKO_ADULT: + case WOOD_BUSH_GREEN_SMALL: + case WOOD_BUSH_BLACK_SMALL: + this->actor.uncullZoneForward = 4000.0f; + this->actor.uncullZoneScale = 800.0f; + this->actor.uncullZoneDownward = 1800.0f; + break; + + case WOOD_TREE_CONICAL_SMALL: + actorScale = 0.6f; + this->actor.uncullZoneForward = 4000.0f; + this->actor.uncullZoneScale = 400.0f; + this->actor.uncullZoneDownward = 1000.0f; + break; + + case WOOD_LEAF_GREEN: + case WOOD_LEAF_YELLOW: + this->unk_14A[0] = 75; + actorScale = 0.02f; + this->actor.velocity.x = randPlusMinusPoint5Scaled(6.0f); + this->actor.velocity.z = randPlusMinusPoint5Scaled(6.0f); + this->actor.velocity.y = (Rand_ZeroOne() * 1.25f) + -3.1f; + break; + } + + if (this->actor.params < WOOD_TREE_OVAL_GREEN) { + this->drawType = WOOD_DRAW_TREE_CONICAL; + } else if (this->actor.params < WOOD_TREE_KAKARIKO_ADULT) { + this->drawType = WOOD_DRAW_TREE_OVAL; + } else if (this->actor.params < WOOD_BUSH_GREEN_SMALL) { + this->drawType = WOOD_DRAW_TREE_KAKARIKO_ADULT; + } else if (this->actor.params < WOOD_BUSH_BLACK_SMALL) { + this->drawType = WOOD_DRAW_BUSH_GREEN; + } else if (this->actor.params < WOOD_LEAF_YELLOW) { + this->drawType = WOOD_DRAW_4; + } else if (this->actor.params == WOOD_TREE_SPECIAL) { + this->drawType = WOOD_DRAW_TREE_CONICAL; + } else { + this->drawType = WOOD_DRAW_LEAF_YELLOW; + } + + Actor_SetScale(&this->actor, actorScale); + this->spawnType = spawnType; + + if (spawnType != WOOD_SPAWN_NORMAL) { + extraRot = 0; + if (this->actor.params == WOOD_BUSH_GREEN_LARGE_SPAWNER) { + extraRot = 0x4000; + } + + if (spawnType == WOOD_SPAWN_SPAWNER) { + EnWood02_SpawnOffspring(this, globalCtx); + sSpawnCos = Math_CosS(sSpawnAngle[5] + this->actor.world.rot.y + extraRot); + sSpawnSin = Math_SinS(sSpawnAngle[5] + this->actor.world.rot.y + extraRot); + this->actor.world.pos.x += sSpawnSin * sSpawnDistance[5]; + this->actor.world.pos.z += sSpawnCos * sSpawnDistance[5]; + } else { + this->actor.flags |= ACTOR_FLAG_10; + this->unk_151 = 2; + } + + // Snap to floor, or remove if over void + this->actor.world.pos.y += 200.0f; + floorY = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &outPoly, &bgId, &this->actor, &this->actor.world.pos); + + if (floorY > BGCHECK_Y_MIN) { + this->actor.world.pos.y = floorY; + } else { + Actor_MarkForDeath(&this->actor); + return; + } + } + + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); + this->actor.home.rot.y = 0; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; +} + +void EnWood02_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnWood02* this = THIS; + + if ((this->actor.params < WOOD_BUSH_GREEN_SMALL) || (this->actor.params == WOOD_TREE_SPECIAL)) { + Collider_DestroyCylinder(globalCtx, &this->collider); + } +} + +void func_808C4458(EnWood02* this, GlobalContext* globalCtx, Vec3f* arg2, u16 arg3) { + s32 pad[2]; + s32 sp24; + + if (this->unk_148 != 0) { + if ((this->unk_144 == -1) || !Flags_GetCollectible(globalCtx, this->unk_144)) { + if ((this->unk_148 < 0) && (this->unk_148 >= -0x10)) { + if (arg3 & 1) { + Item_DropCollectibleRandom(globalCtx, &this->actor, arg2, ((-1 - this->unk_148) * 0x10) | 0x8000); + } else { + Item_DropCollectibleRandom(globalCtx, &this->actor, arg2, (-1 - this->unk_148) * 0x10); + } + } else if (this->unk_148 > 0) { + sp24 = func_800A8150(this->unk_148 - 1); + if (sp24 >= 0) { + if (this->unk_144 == -1) { + Item_DropCollectible(globalCtx, arg2, sp24); + } else { + Item_DropCollectible(globalCtx, arg2, ((this->unk_144 & 0x7F) << 8) | sp24); + } + } + } + } + this->unk_148 = 0; + } +} + +void EnWood02_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnWood02* this = THIS; + f32 wobbleAmplitude; + + // Despawn extra trees in a group if out of range + if ((this->spawnType == WOOD_SPAWN_SPAWNED) && (thisx->parent != NULL)) { + if (!(thisx->flags & 0x40) && (this->unk_151 != 2)) { + s32 index = this->unk_14A[0]; + s32 phi_v0 = 0; + + if (this->unk_148 == 0) { + phi_v0 = 0x80; + } + + ((EnWood02*)thisx->parent)->unk_14A[index] = phi_v0; + + Actor_MarkForDeath(thisx); + return; + } + this->unk_151 = 0; + } else if (this->spawnType == WOOD_SPAWN_SPAWNER) { + EnWood02_SpawnOffspring(this, globalCtx); + } + + if ((thisx->params < WOOD_BUSH_GREEN_SMALL) || (thisx->params == WOOD_TREE_SPECIAL)) { + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + Actor_PlaySfxAtPos(thisx, NA_SE_IT_REFLECTION_WOOD); + } + + if (thisx->home.rot.y != 0) { + Vec3f dropsSpawnPt = thisx->world.pos; + + dropsSpawnPt.y += 200.0f; + + func_808C4458(this, globalCtx, &dropsSpawnPt, 0); + + // Spawn falling leaves + if (this->unk_146 >= -1) { + s32 i; + s32 leavesParams = WOOD_LEAF_GREEN; + + if ((thisx->params == WOOD_TREE_OVAL_YELLOW_SPAWNER) || + (thisx->params == WOOD_TREE_OVAL_YELLOW_SPAWNED)) { + leavesParams = WOOD_LEAF_YELLOW; + } + Actor_PlaySfxAtPos(thisx, NA_SE_EV_TREE_SWING); + + for (i = 3; i >= 0; i--) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_WOOD02, dropsSpawnPt.x, dropsSpawnPt.y, + dropsSpawnPt.z, 0, randPlusMinusPoint5Scaled(0xFFFF), 0, leavesParams); + } + } + + if ((thisx->child != NULL) && (this->unk_151 == 1)) { + thisx->child->home.rot.x = 1; + this->unk_151 = 0; + } + + if ((thisx->params == WOOD_TREE_SPECIAL) && (this->unk_144 != -1)) { + Flags_SetCollectible(globalCtx, this->unk_144); + this->unk_144 = -1; + } + this->unk_146 = -0x15; + thisx->home.rot.y = 0; + } + + if (thisx->xzDistToPlayer < 600.0f) { + Collider_UpdateCylinder(thisx, &this->collider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + } else if ((thisx->params < WOOD_LEAF_GREEN) || (thisx->params == WOOD_TREE_SPECIAL)) { // not leaves + Player* player = GET_PLAYER(globalCtx); + + if ((this->unk_146 >= -1) && (((player->rideActor == NULL) && (sqrtf(thisx->xyzDistToPlayerSq) < 20.0f) && + (player->linearVelocity != 0.0f)) || + ((player->rideActor != NULL) && (sqrtf(thisx->xyzDistToPlayerSq) < 60.0f) && + (player->rideActor->speedXZ != 0.0f)))) { + func_808C4458(this, globalCtx, &thisx->world.pos, 1); + this->unk_146 = -0x15; + Actor_PlaySfxAtPos(thisx, NA_SE_EV_TREE_SWING); + } + } else { // Leaves + this->unk_146++; + Math_ApproachF(&thisx->velocity.x, 0.0f, 1.0f, 5.0f * 0.01f); + Math_ApproachF(&thisx->velocity.z, 0.0f, 1.0f, 5.0f * 0.01f); + Actor_UpdatePos(thisx); + thisx->shape.rot.z = Math_SinS(this->unk_146 * 0xBB8) * 16384.0f; + this->unk_14A[0]--; + if (this->unk_14A[0] == 0) { + Actor_MarkForDeath(thisx); + } + } + + // Wobble from impact + if (this->unk_146 < -1) { + this->unk_146++; + wobbleAmplitude = Math_SinS((this->unk_146 ^ 0xFFFF) * 0x3332) * 250.0f; + thisx->shape.rot.x = Math_CosS(thisx->yawTowardsPlayer - thisx->shape.rot.y) * wobbleAmplitude; + thisx->shape.rot.z = Math_SinS(thisx->yawTowardsPlayer - thisx->shape.rot.y) * wobbleAmplitude; + } +} + +void EnWood02_Draw(Actor* thisx, GlobalContext* globalCtx) { + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + s16 type; + s16 pad; + u8 red; + u8 green; + u8 blue; + + OPEN_DISPS(gfxCtx); + type = thisx->params; + + if ((type == WOOD_TREE_OVAL_GREEN_SPAWNER) || (type == WOOD_TREE_OVAL_GREEN_SPAWNED) || + (type == WOOD_TREE_OVAL_GREEN) || (type == WOOD_LEAF_GREEN)) { + red = 50; + green = 170; + blue = 70; + } else if ((type == WOOD_TREE_OVAL_YELLOW_SPAWNER) || (type == WOOD_TREE_OVAL_YELLOW_SPAWNED) || + (type == WOOD_LEAF_YELLOW)) { + red = 180; + green = 155; + blue = 0; + } else { + red = green = blue = 255; + } + + func_8012C2DC(gfxCtx); + + if ((thisx->params == WOOD_LEAF_GREEN) || (thisx->params == WOOD_LEAF_YELLOW)) { + func_8012C28C(gfxCtx); + + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, red, green, blue, 127); + + Gfx_DrawDListOpa(globalCtx, object_wood02_DL_000700); + } else if (D_808C4D70[THIS->drawType & 0xF] != NULL) { + Gfx_DrawDListOpa(globalCtx, D_808C4D54[THIS->drawType & 0xF]); + + gDPSetEnvColor(POLY_XLU_DISP++, red, green, blue, 0); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, D_808C4D70[THIS->drawType & 0xF]); + } else { + func_8012C2DC(gfxCtx); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, D_808C4D54[THIS->drawType & 0xF]); + } + + CLOSE_DISPS(gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Wood02/z_en_wood02.h b/src/overlays/actors/ovl_En_Wood02/z_en_wood02.h index ef638cfcd8..310d1e5de3 100644 --- a/src/overlays/actors/ovl_En_Wood02/z_en_wood02.h +++ b/src/overlays/actors/ovl_En_Wood02/z_en_wood02.h @@ -5,11 +5,51 @@ struct EnWood02; +#define ENWOOD02_GET_FF00(thisx) (((thisx)->params >> 8) & 0xFF) + typedef struct EnWood02 { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x5C]; + /* 0x144 */ s16 unk_144; + /* 0x146 */ s16 unk_146; + /* 0x148 */ s16 unk_148; + /* 0x14A */ u8 unk_14A[5]; + /* 0x14F */ u8 spawnType; + /* 0x150 */ u8 drawType; + /* 0x151 */ u8 unk_151; + /* 0x154 */ ColliderCylinder collider; } EnWood02; // size = 0x1A0 +// Types with SPAWNED in the name are those that can be managed by a spawner, however the actor allows you to spawn them +// on their own without a spawner as well. +typedef enum { + /* 0x00 */ WOOD_TREE_CONICAL_LARGE, + /* 0x01 */ WOOD_TREE_CONICAL_MEDIUM, + /* 0x02 */ WOOD_TREE_CONICAL_SMALL, + /* 0x03 */ WOOD_TREE_CONICAL_SPAWNER, + /* 0x04 */ WOOD_TREE_CONICAL_SPAWNED, + /* 0x05 */ WOOD_TREE_OVAL_GREEN, + /* 0x06 */ WOOD_TREE_OVAL_YELLOW_SPAWNER, + /* 0x07 */ WOOD_TREE_OVAL_YELLOW_SPAWNED, + /* 0x08 */ WOOD_TREE_OVAL_GREEN_SPAWNER, + /* 0x09 */ WOOD_TREE_OVAL_GREEN_SPAWNED, + /* 0x0A */ WOOD_TREE_KAKARIKO_ADULT, + /* 0x0B */ WOOD_BUSH_GREEN_SMALL, + /* 0x0C */ WOOD_BUSH_GREEN_LARGE, + /* 0x0D */ WOOD_BUSH_GREEN_SMALL_SPAWNER, + /* 0x0E */ WOOD_BUSH_GREEN_SMALL_SPAWNED, + /* 0x0F */ WOOD_BUSH_GREEN_LARGE_SPAWNER, + /* 0x10 */ WOOD_BUSH_GREEN_LARGE_SPAWNED, + /* 0x11 */ WOOD_BUSH_BLACK_SMALL, + /* 0x12 */ WOOD_BUSH_BLACK_LARGE, + /* 0x13 */ WOOD_BUSH_BLACK_SMALL_SPAWNER, + /* 0x14 */ WOOD_BUSH_BLACK_SMALL_SPAWNED, + /* 0x15 */ WOOD_BUSH_BLACK_LARGE_SPAWNER, + /* 0x16 */ WOOD_BUSH_BLACK_LARGE_SPAWNED, + /* 0x17 */ WOOD_LEAF_GREEN, + /* 0x18 */ WOOD_LEAF_YELLOW, + /* 0x1A */ WOOD_TREE_SPECIAL = 0x1A +} WoodType; + extern const ActorInit En_Wood02_InitVars; #endif // Z_EN_WOOD02_H diff --git a/src/overlays/actors/ovl_En_Yb/z_en_yb.c b/src/overlays/actors/ovl_En_Yb/z_en_yb.c index fec9af08fa..25cf4c4736 100644 --- a/src/overlays/actors/ovl_En_Yb/z_en_yb.c +++ b/src/overlays/actors/ovl_En_Yb/z_en_yb.c @@ -112,7 +112,7 @@ void EnYb_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.cutscene = this->cutscenes[0]; // between midnight and morning start spawned - if (gSaveContext.time < CLOCK_TIME(6, 0)) { + if (gSaveContext.save.time < CLOCK_TIME(6, 0)) { this->alpha = 255; } else { // else (night 6pm to midnight): wait to appear this->alpha = 0; @@ -121,7 +121,7 @@ void EnYb_Init(Actor* thisx, GlobalContext* globalCtx) { } // check if already healed - if (gSaveContext.weekEventReg[82] & 4) { + if (gSaveContext.save.weekEventReg[82] & 4) { Actor_MarkForDeath(&this->actor); } } @@ -287,12 +287,12 @@ void EnYb_Talk(EnYb* this, GlobalContext* globalCtx) { this->actor.world.rot.y = this->actor.shape.rot.y; EnYb_UpdateAnimation(this, globalCtx); - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx) != 0) { - switch (globalCtx->msgCtx.unk11F04) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx) != 0) { + switch (globalCtx->msgCtx.currentTextId) { case 0x147D: // I am counting on you func_801477B4(globalCtx); this->actionFunc = EnYb_Disappear; - gSaveContext.weekEventReg[82] |= 0x4; + gSaveContext.save.weekEventReg[82] |= 0x4; break; case 0x147C: // Spread my dance across the world if (Player_GetMask(globalCtx) == PLAYER_MASK_KAMARO) { @@ -353,7 +353,7 @@ void EnYb_Idle(EnYb* this, GlobalContext* globalCtx) { EnYb_UpdateAnimation(this, globalCtx); if (this->actor.xzDistToPlayer < 180.0f && fabsf(this->actor.playerHeightRel) < 50.0f && globalCtx->msgCtx.ocarinaMode == 3 && globalCtx->msgCtx.unk1202E == 7 && - gSaveContext.playerForm == PLAYER_FORM_HUMAN) { + gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { this->actionFunc = EnYb_TeachingDance; this->teachingCutsceneTimer = 200; EnYb_ChangeCutscene(this, 0); @@ -385,7 +385,7 @@ void EnYb_Idle(EnYb* this, GlobalContext* globalCtx) { } void EnYb_WaitForMidnight(EnYb* this, GlobalContext* globalCtx) { - if (gSaveContext.time < CLOCK_TIME(6, 0)) { + if (gSaveContext.save.time < CLOCK_TIME(6, 0)) { EnYb_UpdateAnimation(this, globalCtx); this->alpha += 5; if (this->alpha > 250) { diff --git a/src/overlays/actors/ovl_En_Zo/z_en_zo.c b/src/overlays/actors/ovl_En_Zo/z_en_zo.c index 3a9872406c..8759d3b861 100644 --- a/src/overlays/actors/ovl_En_Zo/z_en_zo.c +++ b/src/overlays/actors/ovl_En_Zo/z_en_zo.c @@ -99,9 +99,9 @@ static AnimationInfoS sAnimations[] = { { &gZoraWalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, }; -s8 D_8099F578[] = { -1, 1, 12, 13, 14, 9, 10, 11, 0, 6, 7, 8, 3, 4, 5, 2, -1, -1, -1, -1 }; -s8 D_8099F58C[] = { 0, 0, 0, 0, 3, 4, 0, 6, 7, 0, 9, 10, 0, 12, 13 }; -u8 D_8099F59C[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +s8 sBodyParts[] = { -1, 1, 12, 13, 14, 9, 10, 11, 0, 6, 7, 8, 3, 4, 5, 2, -1, -1, -1, -1 }; +s8 sParentBodyParts[] = { 0, 0, 0, 0, 3, 4, 0, 6, 7, 0, 9, 10, 0, 12, 13 }; +u8 sShadowSizes[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; s32 EnZo_SetAnimation(SkelAnime* skelAnime, s16 index) { s16 frameCount; @@ -141,12 +141,12 @@ s32 EnZo_PlayWalkingSound(EnZo* this, GlobalContext* globalCtx) { sfxId = SurfaceType_GetSfx(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId) + SFX_FLAG; } - this->isLeftFootGrounded = isFootGrounded = func_8013DB90(globalCtx, &this->leftFootPos, -6.0f); + this->isLeftFootGrounded = isFootGrounded = SubS_IsFloorAbove(globalCtx, &this->leftFootPos, -6.0f); if ((this->isLeftFootGrounded) && (!leftWasGrounded) && (isFootGrounded)) { Actor_PlaySfxAtPos(&this->actor, sfxId); } - this->isRightFootGrounded = isFootGrounded = func_8013DB90(globalCtx, &this->rightFootPos, -6.0f); + this->isRightFootGrounded = isFootGrounded = SubS_IsFloorAbove(globalCtx, &this->rightFootPos, -6.0f); if ((this->isRightFootGrounded) && (!rightWasGrounded) && (isFootGrounded)) { Actor_PlaySfxAtPos(&this->actor, sfxId); } @@ -218,7 +218,7 @@ void EnZo_FollowPath(EnZo* this, GlobalContext* globalCtx) { Math_SmoothStepToF(&this->actor.speedXZ, 1.0f, 0.4f, 1000.0f, 0.0f); speed = this->actor.speedXZ * 400.0f; - if (func_8013D68C(this->path, this->waypoint, &pos) && func_8013D768(&this->actor, &pos, speed)) { + if (SubS_CopyPointFromPath(this->path, this->waypoint, &pos) && SubS_MoveActorToPoint(&this->actor, &pos, speed)) { this->waypoint++; if (this->waypoint >= this->path->count) { this->waypoint = 0; @@ -259,7 +259,7 @@ void EnZo_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); - this->path = func_8013D648(globalCtx, ENZO_GET_PATH(&this->actor), ENZO_NO_PATH); + this->path = SubS_GetPathByIndex(globalCtx, ENZO_GET_PATH(&this->actor), ENZO_NO_PATH); Actor_SetScale(&this->actor, 0.01f); this->actionFunc = EnZo_Walk; @@ -310,8 +310,8 @@ void EnZo_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec Vec3f sp30 = { 400.0f, 0.0f, 0.0f }; Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; - if (D_8099F578[limbIndex] >= 0) { - Matrix_MultiplyVector3fByState(&zeroVec, &this->unk_364[D_8099F578[limbIndex]]); + if (sBodyParts[limbIndex] >= 0) { + Matrix_MultiplyVector3fByState(&zeroVec, &this->bodyPartsPos[sBodyParts[limbIndex]]); } if (limbIndex == 15) { Matrix_MultiplyVector3fByState(&sp30, &this->actor.focus.pos); @@ -336,9 +336,9 @@ static Gfx sTransparencyDlist[] = { void EnZo_Draw(Actor* thisx, GlobalContext* globalCtx) { EnZo* this = THIS; s32 i; - u8* shadowTex = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(u8) * SQ(64)); + u8* shadowTex = GRAPH_ALLOC(globalCtx->state.gfxCtx, SUBS_SHADOW_TEX_SIZE); u8* shadowTexIter; - TexturePtr eyeTextures[] = { &gZoraEyeOpenTex, &gZoraEyeHalfTex, &gZoraEyeClosedTex }; + TexturePtr eyeTextures[] = { gZoraEyeOpenTex, gZoraEyeHalfTex, gZoraEyeClosedTex }; OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); @@ -354,14 +354,15 @@ void EnZo_Draw(Actor* thisx, GlobalContext* globalCtx) { EnZo_OverrideLimbDraw, EnZo_PostLimbDraw, &this->actor, POLY_OPA_DISP); Matrix_InsertXRotation_s(0, 0); - for (i = 0, shadowTexIter = shadowTex; i < (s32)sizeof(u8) * SQ(64); i++) { + for (i = 0, shadowTexIter = shadowTex; i < SUBS_SHADOW_TEX_SIZE; i++) { *shadowTexIter = 0; shadowTexIter++; } for (i = 0; i < 5; i++) { - func_8013CD64(this->unk_364, &this->actor.world.pos, shadowTex, i / 5.0f, 15, D_8099F59C, D_8099F58C); + SubS_GenShadowTex(this->bodyPartsPos, &this->actor.world.pos, shadowTex, i / 5.0f, + ARRAY_COUNT(this->bodyPartsPos), sShadowSizes, sParentBodyParts); } - func_8013CF04(&this->actor, &globalCtx->state.gfxCtx, shadowTex); + SubS_DrawShadowTex(&this->actor, &globalCtx->state, shadowTex); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Zo/z_en_zo.h b/src/overlays/actors/ovl_En_Zo/z_en_zo.h index 0b9f8dab16..155c947d40 100644 --- a/src/overlays/actors/ovl_En_Zo/z_en_zo.h +++ b/src/overlays/actors/ovl_En_Zo/z_en_zo.h @@ -30,7 +30,7 @@ typedef struct EnZo { /* 0x0300 */ UNK_TYPE1 unk_300[0x12]; /* 0x0312 */ s16 limbRotY[20]; /* 0x033A */ s16 limbRotZ[20]; - /* 0x0364 */ Vec3f unk_364[15]; + /* 0x0364 */ Vec3f bodyPartsPos[15]; /* 0x041A */ UNK_TYPE1 unk_41A[0x6]; /* 0x041E */ s16 eyeIndex; /* 0x0420 */ s16 blinkTimer; diff --git a/src/overlays/actors/ovl_En_Zob/z_en_zob.c b/src/overlays/actors/ovl_En_Zob/z_en_zob.c index a3f5038743..6e9ddb5c0a 100644 --- a/src/overlays/actors/ovl_En_Zob/z_en_zob.c +++ b/src/overlays/actors/ovl_En_Zob/z_en_zob.c @@ -114,13 +114,13 @@ void EnZob_Init(Actor* thisx, GlobalContext* globalCtx) { switch (ENZOB_GET_F(&this->actor)) { case ENZOB_F_1: - if (gSaveContext.weekEventReg[78] & 1) { + if (gSaveContext.save.weekEventReg[78] & 1) { this->actionFunc = func_80BA0BB4; } else { this->actionFunc = func_80BA0AD8; } - if (!(gSaveContext.weekEventReg[55] & 0x80)) { + if (!(gSaveContext.save.weekEventReg[55] & 0x80)) { Actor_MarkForDeath(&this->actor); return; } @@ -135,7 +135,7 @@ void EnZob_Init(Actor* thisx, GlobalContext* globalCtx) { break; default: - if (gSaveContext.weekEventReg[55] & 0x80) { + if (gSaveContext.save.weekEventReg[55] & 0x80) { Actor_MarkForDeath(&this->actor); } this->actor.flags |= ACTOR_FLAG_10; @@ -210,8 +210,8 @@ void func_80B9FA3C(EnZob* this, GlobalContext* globalCtx) { this->unk_2F4 |= 1; - if (gSaveContext.playerForm != PLAYER_FORM_ZORA) { - if (gSaveContext.weekEventReg[30] & 2) { + if (gSaveContext.save.playerForm != PLAYER_FORM_ZORA) { + if (gSaveContext.save.weekEventReg[30] & 2) { textId = 0x11F9; } else { textId = 0x11F8; @@ -222,7 +222,7 @@ void func_80B9FA3C(EnZob* this, GlobalContext* globalCtx) { textId = 0x1210; this->unk_304 = 3; func_80B9F7E4(this, 5, 2); - } else if (gSaveContext.weekEventReg[31] & 8) { + } else if (gSaveContext.save.weekEventReg[31] & 8) { textId = 0x1205; this->unk_304 = 1; func_80B9F7E4(this, 3, 0); @@ -234,12 +234,12 @@ void func_80B9FA3C(EnZob* this, GlobalContext* globalCtx) { textId = 0x1203; this->unk_304 = 1; func_80B9F7E4(this, 2, 2); - } else if (gSaveContext.weekEventReg[30] & 8) { + } else if (gSaveContext.save.weekEventReg[30] & 8) { textId = 0x11FA; this->unk_304 = 1; func_80B9F7E4(this, 2, 2); - } else if (!(gSaveContext.weekEventReg[30] & 4)) { - gSaveContext.weekEventReg[30] |= 4; + } else if (!(gSaveContext.save.weekEventReg[30] & 4)) { + gSaveContext.save.weekEventReg[30] |= 4; textId = 0x11FB; this->unk_304 = 1; func_80B9F7E4(this, 2, 2); @@ -368,7 +368,7 @@ void func_80BA00BC(EnZob* this, GlobalContext* globalCtx) { switch (Message_GetState(&globalCtx->msgCtx)) { case 4: - if (func_80147624(globalCtx) && (globalCtx->msgCtx.unk11F04 == 0x1212)) { + if (Message_ShouldAdvance(globalCtx) && (globalCtx->msgCtx.currentTextId == 0x1212)) { switch (globalCtx->msgCtx.choiceIndex) { case 1: func_8019F208(); @@ -386,12 +386,12 @@ void func_80BA00BC(EnZob* this, GlobalContext* globalCtx) { break; case 5: - if (func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x1208: case 0x120E: case 0x1216: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x120C: @@ -405,7 +405,7 @@ void func_80BA00BC(EnZob* this, GlobalContext* globalCtx) { case 0x1211: case 0x1213: case 0x1217: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); this->unk_304 = 3; func_80B9F7E4(this, 4, 2); break; @@ -420,7 +420,7 @@ void func_80BA00BC(EnZob* this, GlobalContext* globalCtx) { break; case 0x120F: - gSaveContext.weekEventReg[31] |= 8; + gSaveContext.save.weekEventReg[31] |= 8; this->unk_2F4 |= 0x10; func_80B9FCA0(this, globalCtx); break; @@ -453,7 +453,7 @@ void func_80BA0374(EnZob* this, GlobalContext* globalCtx) { switch (Message_GetState(&globalCtx->msgCtx)) { case 4: - if (func_80147624(globalCtx) && (globalCtx->msgCtx.unk11F04 == 0x1205)) { + if (Message_ShouldAdvance(globalCtx) && (globalCtx->msgCtx.currentTextId == 0x1205)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_8019F208(); @@ -470,10 +470,10 @@ void func_80BA0374(EnZob* this, GlobalContext* globalCtx) { break; case 5: - if (func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x11F8: - gSaveContext.weekEventReg[30] |= 2; + gSaveContext.save.weekEventReg[30] |= 2; func_80151938(globalCtx, 0x11F9); break; @@ -490,19 +490,19 @@ void func_80BA0374(EnZob* this, GlobalContext* globalCtx) { case 0x11FF: case 0x1201: case 0x1203: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x11FD: this->unk_304 = 3; func_80B9F7E4(this, 4, 2); - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x11FE: this->unk_304 = 1; func_80B9F7E4(this, 3, 0); - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x11FA: @@ -563,9 +563,9 @@ void func_80BA0728(EnZob* this, GlobalContext* globalCtx) { func_80B9F86C(this); if (func_800B8718(&this->actor, &globalCtx->state)) { - if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { Message_StartTextbox(globalCtx, 0x1208, NULL); - gSaveContext.weekEventReg[30] |= 8; + gSaveContext.save.weekEventReg[30] |= 8; } else { Message_StartTextbox(globalCtx, 0x1216, NULL); } @@ -594,18 +594,18 @@ void func_80BA0728(EnZob* this, GlobalContext* globalCtx) { void func_80BA08E8(EnZob* this, GlobalContext* globalCtx) { s32 textId; - if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { - if (gSaveContext.weekEventReg[79] & 1) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.weekEventReg[79] & 1) { textId = 0x1257; this->unk_304 = 3; func_80B9F7E4(this, 4, 2); - } else if (gSaveContext.weekEventReg[78] & 0x40) { + } else if (gSaveContext.save.weekEventReg[78] & 0x40) { textId = 0x1256; this->unk_304 = 1; func_80B9F7E4(this, 2, 2); } else { textId = 0x1255; - gSaveContext.weekEventReg[78] |= 0x40; + gSaveContext.save.weekEventReg[78] |= 0x40; this->unk_304 = 1; func_80B9F7E4(this, 2, 2); } @@ -631,7 +631,7 @@ void func_80BA0A04(EnZob* this, GlobalContext* globalCtx) { temp_v0 = Message_GetState(&globalCtx->msgCtx); if (temp_v0 != 2) { - if ((temp_v0 == 5) && func_80147624(globalCtx)) { + if ((temp_v0 == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); this->actionFunc = func_80BA0AD8; this->unk_304 = 0; @@ -663,7 +663,7 @@ void func_80BA0AD8(EnZob* this, GlobalContext* globalCtx) { void func_80BA0BB4(EnZob* this, GlobalContext* globalCtx) { func_80B9F86C(this); - if (gSaveContext.weekEventReg[79] & 1) { + if (gSaveContext.save.weekEventReg[79] & 1) { this->actionFunc = func_80BA09E0; func_80B9F7E4(this, 0, 2); this->unk_304 = 5; diff --git a/src/overlays/actors/ovl_En_Zog/z_en_zog.c b/src/overlays/actors/ovl_En_Zog/z_en_zog.c index 5e12cba0d2..f4514a9aa0 100644 --- a/src/overlays/actors/ovl_En_Zog/z_en_zog.c +++ b/src/overlays/actors/ovl_En_Zog/z_en_zog.c @@ -265,7 +265,7 @@ void EnZog_Init(Actor* thisx, GlobalContext* globalCtx) { } } - if ((ENZOG_GET_F(&this->actor) != ENZOG_F_2) && (gSaveContext.weekEventReg[88] & 0x10)) { + if ((ENZOG_GET_F(&this->actor) != ENZOG_F_2) && (gSaveContext.save.weekEventReg[88] & 0x10)) { this->unk_302 = this->unk_300 = 0; this->unk_2FC = this->unk_2FE = 3; this->actor.flags |= ACTOR_FLAG_2000000; @@ -275,7 +275,7 @@ void EnZog_Init(Actor* thisx, GlobalContext* globalCtx) { Animation_PlayLoop(&this->skelAnime, D_80B958DC[0]); this->actor.textId = 0x1009; - if (gSaveContext.weekEventReg[91] & 2) { + if (gSaveContext.save.weekEventReg[91] & 2) { this->actor.textId = 0x103C; this->actionFunc = func_80B9451C; } else { @@ -613,7 +613,7 @@ void func_80B943EC(EnZog* this, GlobalContext* globalCtx) { void func_80B94470(EnZog* this, GlobalContext* globalCtx) { if (Message_GetState(&globalCtx->msgCtx) == 5) { - if (func_80147624(globalCtx) && (globalCtx->msgCtx.unk11F04 == 0x103C)) { + if (Message_ShouldAdvance(globalCtx) && (globalCtx->msgCtx.currentTextId == 0x103C)) { func_801477B4(globalCtx); this->actionFunc = func_80B9451C; this->unk_300 = this->unk_302 = 0; @@ -629,7 +629,7 @@ void func_80B9451C(EnZog* this, GlobalContext* globalCtx) { this->unk_300 = 2; this->actionFunc = func_80B94470; } else if ((globalCtx->msgCtx.ocarinaMode == 3) && (this->actor.xzDistToPlayer < 120.0f)) { - if ((globalCtx->msgCtx.unk1202E == 7) && (gSaveContext.playerForm == PLAYER_FORM_HUMAN)) { + if ((globalCtx->msgCtx.unk1202E == 7) && (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN)) { func_80B93BA8(this, 2); this->actionFunc = func_80B943C0; this->actor.shape.shadowDraw = NULL; @@ -645,7 +645,7 @@ void func_80B9461C(EnZog* this, GlobalContext* globalCtx) { this->actor.textId = 0x103C; this->actionFunc = func_80B9451C; this->actor.flags |= ACTOR_FLAG_2000000; - gSaveContext.weekEventReg[91] |= 2; + gSaveContext.save.weekEventReg[91] |= 2; } if ((this->unk_304 == 11) && ((s32)this->skelAnime.curFrame >= 55)) { @@ -664,7 +664,7 @@ void func_80B946B4(EnZog* this, GlobalContext* globalCtx) { void func_80B946FC(EnZog* this, GlobalContext* globalCtx) { switch (Message_GetState(&globalCtx->msgCtx)) { case 4: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_8019F208(); @@ -682,19 +682,19 @@ void func_80B946FC(EnZog* this, GlobalContext* globalCtx) { break; case 5: - if (func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x1008: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x1009: this->unk_300 = 4; - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x1014: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x1015: @@ -717,7 +717,7 @@ void func_80B948A8(EnZog* this, GlobalContext* globalCtx) { this->unk_300 = 2; this->actionFunc = func_80B946FC; } else if ((globalCtx->msgCtx.ocarinaMode == 3) && (this->actor.xzDistToPlayer < 120.0f)) { - if ((globalCtx->msgCtx.unk1202E == 7) && (gSaveContext.playerForm == PLAYER_FORM_HUMAN)) { + if ((globalCtx->msgCtx.unk1202E == 7) && (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN)) { func_80B93BA8(this, 2); this->actionFunc = func_80B943C0; this->actor.shape.shadowDraw = NULL; @@ -747,11 +747,11 @@ void func_80B94A00(EnZog* this, GlobalContext* globalCtx) { if (func_80B93BE0(this, globalCtx)) { this->actionFunc = func_80B948A8; this->actor.flags |= ACTOR_FLAG_2000000; - if (gSaveContext.weekEventReg[29] & 0x20) { + if (gSaveContext.save.weekEventReg[29] & 0x20) { this->actor.textId = 0x1009; } else { this->actor.textId = 0x1008; - gSaveContext.weekEventReg[29] |= 0x20; + gSaveContext.save.weekEventReg[29] |= 0x20; } this->unk_300 = 2; this->unk_31C = 2; @@ -827,13 +827,13 @@ void func_80B94D0C(EnZog* this, GlobalContext* globalCtx) { this->unk_31E = 0; } - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { this->unk_320 = 5; - switch (globalCtx->msgCtx.unk11F04) { + switch (globalCtx->msgCtx.currentTextId) { case 0x1004: case 0x1005: case 0x1006: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x1007: @@ -904,7 +904,7 @@ void func_80B94E34(EnZog* this, GlobalContext* globalCtx) { this->unk_31C = 1; this->unk_31E = 0; func_80B93BA8(this, 0); - gSaveContext.weekEventReg[88] |= 0x10; + gSaveContext.save.weekEventReg[88] |= 0x10; } else if ((this->actor.yawTowardsPlayer > 16000) && (this->actor.yawTowardsPlayer < 32000) && (this->unk_302 == 0)) { func_800B8614(&this->actor, globalCtx, 150.0f); @@ -938,7 +938,7 @@ void func_80B95128(EnZog* this, GlobalContext* globalCtx) { } this->actor.flags &= ~ACTOR_FLAG_10000; - gSaveContext.weekEventReg[91] |= 1; + gSaveContext.save.weekEventReg[91] |= 1; } else { func_800B8614(&this->actor, globalCtx, 150.0f); } diff --git a/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.c b/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.c index 7250daaa84..61be7c8e75 100644 --- a/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.c +++ b/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.c @@ -118,7 +118,7 @@ void EnZoraegg_Init(Actor* thisx, GlobalContext* globalCtx) { case ENZORAEGG_1F_7: case ENZORAEGG_1F_8: case ENZORAEGG_1F_9: - if (gSaveContext.weekEventReg[19] & 0x40) { + if (gSaveContext.save.weekEventReg[19] & 0x40) { Actor_MarkForDeath(&this->actor); return; } @@ -131,7 +131,7 @@ void EnZoraegg_Init(Actor* thisx, GlobalContext* globalCtx) { case ENZORAEGG_1F_14: case ENZORAEGG_1F_15: case ENZORAEGG_1F_16: - if (!(gSaveContext.weekEventReg[19] & 0x40)) { + if (!(gSaveContext.save.weekEventReg[19] & 0x40)) { Actor_MarkForDeath(&this->actor); return; } @@ -206,13 +206,13 @@ void EnZoraegg_Destroy(Actor* thisx, GlobalContext* globalCtx) { } s32 func_80B319A8(GlobalContext* globalCtx) { - return gSaveContext.permanentSceneFlags[globalCtx->sceneNum].unk_14 & 7; + return gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 & 7; } void func_80B319D0(GlobalContext* globalCtx, s32 arg1) { if ((arg1 < 8) && (arg1 >= 0)) { - gSaveContext.permanentSceneFlags[globalCtx->sceneNum].unk_14 &= ~7; - gSaveContext.permanentSceneFlags[globalCtx->sceneNum].unk_14 |= arg1; + gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 &= ~7; + gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 |= arg1; } } @@ -479,7 +479,7 @@ void func_80B326F4(EnZoraegg* this, GlobalContext* globalCtx) { Animation_GetLastFrame(&object_zoraegg_Anim_004D20), 2, 5.0f); this->unk_1E8 = 0; this->actionFunc = func_80B32644; - gSaveContext.weekEventReg[19] |= 0x40; + gSaveContext.save.weekEventReg[19] |= 0x40; this->unk_1EC = 2; this->unk_1EE = 100; Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ZORA_KIDS_SWIM_2); diff --git a/src/overlays/actors/ovl_En_Zos/z_en_zos.c b/src/overlays/actors/ovl_En_Zos/z_en_zos.c index a69223d09c..419d3325e4 100644 --- a/src/overlays/actors/ovl_En_Zos/z_en_zos.c +++ b/src/overlays/actors/ovl_En_Zos/z_en_zos.c @@ -84,11 +84,11 @@ void EnZos_Init(Actor* thisx, GlobalContext* globalCtx) { switch (ENZOS_GET_F(&this->actor)) { case ENZOS_F_1: - if (!(gSaveContext.weekEventReg[55] & 0x80)) { + if (!(gSaveContext.save.weekEventReg[55] & 0x80)) { Actor_MarkForDeath(&this->actor); } - if (gSaveContext.weekEventReg[78] & 1) { + if (gSaveContext.save.weekEventReg[78] & 1) { this->actionFunc = func_80BBC24C; } else { this->actionFunc = func_80BBC14C; @@ -104,7 +104,7 @@ void EnZos_Init(Actor* thisx, GlobalContext* globalCtx) { break; default: - if (gSaveContext.weekEventReg[55] & 0x80) { + if (gSaveContext.save.weekEventReg[55] & 0x80) { Actor_MarkForDeath(&this->actor); } this->actor.flags |= ACTOR_FLAG_10; @@ -115,7 +115,7 @@ void EnZos_Init(Actor* thisx, GlobalContext* globalCtx) { void EnZos_Destroy(Actor* thisx, GlobalContext* globalCtx) { EnZos* this = THIS; - gSaveContext.weekEventReg[52] &= (u8)~0x10; + gSaveContext.save.weekEventReg[52] &= (u8)~0x10; } void func_80BBAE84(EnZos* this, s16 arg1, u8 arg2) { @@ -187,7 +187,7 @@ void func_80BBB0D4(EnZos* this, GlobalContext* globalCtx) { void func_80BBB15C(EnZos* this, GlobalContext* globalCtx) { s32 textId; - if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { if (this->unk_2B6 & 8) { textId = 0x1235; func_80BBAE84(this, 6, 0); @@ -196,7 +196,7 @@ void func_80BBB15C(EnZos* this, GlobalContext* globalCtx) { textId = 0x123E; func_80BBAE84(this, 6, 0); this->unk_2B6 |= 2; - } else if (gSaveContext.weekEventReg[40] & 0x20) { + } else if (gSaveContext.save.weekEventReg[40] & 0x20) { textId = 0x1236; func_80BBAE84(this, 6, 0); this->unk_2B6 |= 0x80; @@ -207,13 +207,13 @@ void func_80BBB15C(EnZos* this, GlobalContext* globalCtx) { } } else { this->unk_2B6 &= ~2; - if (gSaveContext.weekEventReg[39] & 0x10) { + if (gSaveContext.save.weekEventReg[39] & 0x10) { textId = 0x1243; func_80BBAE84(this, 6, 0); this->unk_2B6 |= 0x80; } else { textId = 0x1244; - gSaveContext.weekEventReg[39] |= 0x10; + gSaveContext.save.weekEventReg[39] |= 0x10; func_80BBAE84(this, 4, 0); this->unk_2B6 |= 0x10; } @@ -237,11 +237,11 @@ void func_80BBB354(EnZos* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { this->actor.parent = NULL; this->actionFunc = func_80BBB2C4; - gSaveContext.weekEventReg[39] |= 0x20; + gSaveContext.save.weekEventReg[39] |= 0x20; this->actor.flags |= ACTOR_FLAG_10000; func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); } else { - if (gSaveContext.weekEventReg[39] & 0x20) { + if (gSaveContext.save.weekEventReg[39] & 0x20) { item = GI_RUPEE_PURPLE; } else { item = GI_HEART_PIECE; @@ -301,8 +301,8 @@ void func_80BBB574(EnZos* this, GlobalContext* globalCtx) { } } - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x124B: if (this->unk_2B8 == 9) { globalCtx->msgCtx.unk11F10 = 0; @@ -348,22 +348,22 @@ void func_80BBB718(EnZos* this, GlobalContext* globalCtx) { player->actor.textId = 0x1232; func_80BBAE84(this, 5, 0); this->unk_2B6 |= 8; - gSaveContext.weekEventReg[40] |= 0x20; - } else if (gSaveContext.weekEventReg[39] & 8) { + gSaveContext.save.weekEventReg[40] |= 0x20; + } else if (gSaveContext.save.weekEventReg[39] & 8) { player->actor.textId = 0x1241; } else { player->actor.textId = 0x1237; - gSaveContext.weekEventReg[39] |= 8; + gSaveContext.save.weekEventReg[39] |= 8; func_80BBAE84(this, 4, 0); this->unk_2B6 |= 4; } this->actionFunc = func_80BBB8AC; } else if (sp24 < 0) { - if (gSaveContext.weekEventReg[39] & 8) { + if (gSaveContext.save.weekEventReg[39] & 8) { func_80151938(globalCtx, 0x1241); } else { func_80151938(globalCtx, 0x1237); - gSaveContext.weekEventReg[39] |= 8; + gSaveContext.save.weekEventReg[39] |= 8; func_80BBAE84(this, 4, 0); this->unk_2B6 |= 4; } @@ -386,8 +386,8 @@ void func_80BBB8AC(EnZos* this, GlobalContext* globalCtx) { } } - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x1237: player->exchangeItemId = 0; @@ -397,13 +397,13 @@ void func_80BBB8AC(EnZos* this, GlobalContext* globalCtx) { case 0x123C: case 0x123E: case 0x123F: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x1244: this->unk_2B6 &= ~0x10; func_80BBAE84(this, 6, 0); - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x1232: @@ -413,18 +413,18 @@ void func_80BBB8AC(EnZos* this, GlobalContext* globalCtx) { case 0x1239: case 0x1246: func_80BBAE84(this, 6, 0); - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x1233: func_80BBAE84(this, 5, 0); - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x1245: case 0x1248: func_80BBAE84(this, 3, 0); - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x1231: @@ -470,17 +470,17 @@ void func_80BBB8AC(EnZos* this, GlobalContext* globalCtx) { void func_80BBBB84(EnZos* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actor.flags &= ~ACTOR_FLAG_10000; - if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { Message_StartTextbox(globalCtx, 0x1248, &this->actor); this->actionFunc = func_80BBB8AC; func_80BBAE84(this, 6, 0); this->unk_2B6 |= 2; - } else if (gSaveContext.weekEventReg[41] & 0x10) { + } else if (gSaveContext.save.weekEventReg[41] & 0x10) { Message_StartTextbox(globalCtx, 0x124A, &this->actor); this->actionFunc = func_80BBB8AC; func_80BBAE84(this, 6, 0); } else { - gSaveContext.weekEventReg[41] |= 0x10; + gSaveContext.save.weekEventReg[41] |= 0x10; Message_StartTextbox(globalCtx, 0x124B, &this->actor); this->actionFunc = func_80BBB574; func_80BBAE84(this, 9, 2); @@ -544,9 +544,9 @@ void func_80BBBDE0(EnZos* this, GlobalContext* globalCtx) { } if (!Actor_IsFacingPlayer(&this->actor, 0x4000) && (this->actor.xzDistToPlayer < 100.0f)) { - gSaveContext.weekEventReg[52] |= 0x10; + gSaveContext.save.weekEventReg[52] |= 0x10; } else { - gSaveContext.weekEventReg[52] &= (u8)~0x10; + gSaveContext.save.weekEventReg[52] &= (u8)~0x10; } sp28.x = this->actor.projectedPos.x; @@ -558,14 +558,14 @@ void func_80BBBDE0(EnZos* this, GlobalContext* globalCtx) { void func_80BBBFBC(EnZos* this, GlobalContext* globalCtx) { u16 textId; - if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { - if (gSaveContext.weekEventReg[79] & 1) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.weekEventReg[79] & 1) { textId = 0x125B; - } else if (gSaveContext.weekEventReg[78] & 0x80) { + } else if (gSaveContext.save.weekEventReg[78] & 0x80) { textId = 0x125A; } else { textId = 0x1259; - gSaveContext.weekEventReg[78] |= 0x80; + gSaveContext.save.weekEventReg[78] |= 0x80; } func_80BBAE84(this, 5, 0); } else { @@ -582,7 +582,7 @@ void func_80BBC070(EnZos* this, GlobalContext* globalCtx) { switch (Message_GetState(&globalCtx->msgCtx)) { case 5: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { func_80BBAE84(this, 2, 0); func_801477B4(globalCtx); this->actionFunc = func_80BBC14C; @@ -626,7 +626,7 @@ void func_80BBC22C(EnZos* this, GlobalContext* globalCtx) { void func_80BBC24C(EnZos* this, GlobalContext* globalCtx) { func_80BBB0D4(this, globalCtx); - if (gSaveContext.weekEventReg[79] & 1) { + if (gSaveContext.save.weekEventReg[79] & 1) { this->actionFunc = func_80BBC22C; func_80BBAE84(this, 7, 2); } diff --git a/src/overlays/actors/ovl_En_Zot/z_en_zot.c b/src/overlays/actors/ovl_En_Zot/z_en_zot.c index 08a49d8914..bfab9fcf66 100644 --- a/src/overlays/actors/ovl_En_Zot/z_en_zot.c +++ b/src/overlays/actors/ovl_En_Zot/z_en_zot.c @@ -184,14 +184,14 @@ void EnZot_Init(Actor* thisx, GlobalContext* globalCtx2) { func_80B96BEC(this, 2, 0); this->actor.colChkInfo.cylRadius = 0; this->actor.shape.yOffset = -1400.0f; - if (!(gSaveContext.weekEventReg[55] & 0x80)) { + if (!(gSaveContext.save.weekEventReg[55] & 0x80)) { Actor_MarkForDeath(&this->actor); } break; case 18: this->actionFunc = func_80B99384; - if (!(gSaveContext.weekEventReg[55] & 0x80)) { + if (!(gSaveContext.save.weekEventReg[55] & 0x80)) { Actor_MarkForDeath(&this->actor); } break; @@ -219,7 +219,7 @@ void EnZot_Init(Actor* thisx, GlobalContext* globalCtx2) { break; } - if ((ENZOT_GET_1F(thisx) >= 2) && (ENZOT_GET_1F(thisx) < 11) && (gSaveContext.weekEventReg[55] & 0x80)) { + if ((ENZOT_GET_1F(thisx) >= 2) && (ENZOT_GET_1F(thisx) < 11) && (gSaveContext.save.weekEventReg[55] & 0x80)) { Actor_MarkForDeath(&this->actor); } } @@ -229,7 +229,7 @@ void EnZot_Destroy(Actor* thisx, GlobalContext* globalCtx) { Collider_DestroyCylinder(globalCtx, &this->collider); if (ENZOT_GET_1F(&this->actor) == 8) { - gSaveContext.weekEventReg[41] &= (u8)~0x20; + gSaveContext.save.weekEventReg[41] &= (u8)~0x20; } } @@ -359,30 +359,30 @@ void func_80B97100(EnZot* this, GlobalContext* globalCtx) { void func_80B97110(EnZot* this, GlobalContext* globalCtx) { u16 textId; - if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { textId = 0x125F; - if (gSaveContext.weekEventReg[28] & 0x80) { + if (gSaveContext.save.weekEventReg[28] & 0x80) { textId = 0x1261; } else { - gSaveContext.weekEventReg[28] |= 0x80; + gSaveContext.save.weekEventReg[28] |= 0x80; } } else { textId = 0x125C; - if (gSaveContext.weekEventReg[28] & 0x40) { + if (gSaveContext.save.weekEventReg[28] & 0x40) { textId = 0x125E; } else { - gSaveContext.weekEventReg[28] |= 0x40; + gSaveContext.save.weekEventReg[28] |= 0x40; } } Message_StartTextbox(globalCtx, textId, &this->actor); } void func_80B97194(EnZot* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x125C: case 0x125F: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x125D: @@ -409,35 +409,35 @@ void func_80B97240(EnZot* this, GlobalContext* globalCtx) { void func_80B972E8(EnZot* this, GlobalContext* globalCtx) { u16 textId; - if (gSaveContext.weekEventReg[29] & 0x10) { - if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.weekEventReg[29] & 0x10) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { textId = 0x126A; - if (gSaveContext.weekEventReg[29] & 1) { + if (gSaveContext.save.weekEventReg[29] & 1) { textId = 0x126D; } else { - gSaveContext.weekEventReg[29] |= 1; + gSaveContext.save.weekEventReg[29] |= 1; } } else { textId = 0x1267; - if (gSaveContext.weekEventReg[29] & 2) { + if (gSaveContext.save.weekEventReg[29] & 2) { textId = 0x1269; } else { - gSaveContext.weekEventReg[29] |= 2; + gSaveContext.save.weekEventReg[29] |= 2; } } - } else if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + } else if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { textId = 0x1265; - if (gSaveContext.weekEventReg[29] & 4) { + if (gSaveContext.save.weekEventReg[29] & 4) { textId = 0x1266; } else { - gSaveContext.weekEventReg[29] |= 4; + gSaveContext.save.weekEventReg[29] |= 4; } } else { textId = 0x1262; - if (gSaveContext.weekEventReg[29] & 8) { + if (gSaveContext.save.weekEventReg[29] & 8) { textId = 0x1264; } else { - gSaveContext.weekEventReg[29] |= 8; + gSaveContext.save.weekEventReg[29] |= 8; } } Message_StartTextbox(globalCtx, textId, &this->actor); @@ -447,13 +447,13 @@ void func_80B973BC(EnZot* this, GlobalContext* globalCtx) { func_80B96D4C(this); Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x800, 0x100); this->actor.world.rot.y = this->actor.shape.rot.y; - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x126E: case 0x1270: case 0x1273: case 0x1274: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x1272: @@ -466,7 +466,7 @@ void func_80B973BC(EnZot* this, GlobalContext* globalCtx) { break; case 0x1275: - if (gSaveContext.rupees < 10) { + if (gSaveContext.save.playerData.rupees < 10) { func_80151938(globalCtx, 0x1277); } else { func_80151938(globalCtx, 0x1278); @@ -521,15 +521,15 @@ void func_80B975F8(EnZot* this, GlobalContext* globalCtx) { void func_80B9765C(EnZot* this, GlobalContext* globalCtx) { func_80B96D4C(this); - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { s32 requiredScopeTemp; - switch (globalCtx->msgCtx.unk11F04) { + switch (globalCtx->msgCtx.currentTextId) { case 0x1262: case 0x1267: case 0x126A: case 0x126B: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; default: func_801477B4(globalCtx); @@ -559,15 +559,15 @@ void func_80B97708(EnZot* this, GlobalContext* globalCtx) { } if (phi_v1 != 0) { - gSaveContext.weekEventReg[29] |= 0x10; + gSaveContext.save.weekEventReg[29] |= 0x10; this->actor.flags |= ACTOR_FLAG_10000; if (phi_v1 == 5) { - if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { this->actor.textId = 0x126E; } else { this->actor.textId = 0x1272; } - } else if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + } else if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { this->actor.textId = 0x1273; } else { this->actor.textId = 0x1276; @@ -584,61 +584,61 @@ void func_80B9787C(EnZot* this, GlobalContext* globalCtx) { u16 textId; if (this->actor.textId == 0) { - if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { switch (ENZOT_GET_1F(&this->actor)) { case 2: - if (gSaveContext.weekEventReg[37] & 0x40) { + if (gSaveContext.save.weekEventReg[37] & 0x40) { textId = 0x127E; } else { textId = 0x127C; - gSaveContext.weekEventReg[37] |= 0x40; + gSaveContext.save.weekEventReg[37] |= 0x40; } break; case 3: - if (gSaveContext.weekEventReg[38] & 1) { + if (gSaveContext.save.weekEventReg[38] & 1) { textId = 0x1284; } else { textId = 0x1282; - gSaveContext.weekEventReg[38] |= 1; + gSaveContext.save.weekEventReg[38] |= 1; } break; default: - if (gSaveContext.weekEventReg[38] & 4) { + if (gSaveContext.save.weekEventReg[38] & 4) { textId = 0x128A; } else { textId = 0x1288; - gSaveContext.weekEventReg[38] |= 4; + gSaveContext.save.weekEventReg[38] |= 4; } break; } } else { switch (ENZOT_GET_1F(&this->actor)) { case 2: - if (gSaveContext.weekEventReg[37] & 0x20) { + if (gSaveContext.save.weekEventReg[37] & 0x20) { textId = 0x127B; } else { textId = 0x1279; - gSaveContext.weekEventReg[37] |= 0x20; + gSaveContext.save.weekEventReg[37] |= 0x20; } break; case 3: - if (gSaveContext.weekEventReg[37] & 0x80) { + if (gSaveContext.save.weekEventReg[37] & 0x80) { textId = 0x1281; } else { textId = 0x127F; - gSaveContext.weekEventReg[37] |= 0x80; + gSaveContext.save.weekEventReg[37] |= 0x80; } break; default: - if (gSaveContext.weekEventReg[38] & 2) { + if (gSaveContext.save.weekEventReg[38] & 2) { textId = 0x1287; } else { textId = 0x1285; - gSaveContext.weekEventReg[38] |= 2; + gSaveContext.save.weekEventReg[38] |= 2; } break; } @@ -658,15 +658,15 @@ void func_80B979DC(EnZot* this, GlobalContext* globalCtx) { } void func_80B97A44(EnZot* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x1279: case 0x127C: case 0x127F: case 0x1282: case 0x1285: case 0x1288: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x127D: @@ -707,7 +707,7 @@ void func_80B97B5C(EnZot* this, GlobalContext* globalCtx) { void func_80B97BF8(EnZot* this, GlobalContext* globalCtx) { u16 textId; - if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { textId = 0x128C; } else { textId = 0x128B; @@ -718,7 +718,7 @@ void func_80B97BF8(EnZot* this, GlobalContext* globalCtx) { void func_80B97C40(EnZot* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x800, 0x100); this->actor.world.rot.y = this->actor.shape.rot.y; - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); this->actionFunc = func_80B97CC8; } @@ -767,18 +767,18 @@ void func_80B97E4C(EnZot* this, GlobalContext* globalCtx) { this->actor.world.rot.y = this->actor.shape.rot.y; } - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x128C: this->unk_2F2 &= ~4; func_80B96BEC(this, 6, 2); - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x128D: case 0x128E: case 0x128F: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x1290: @@ -786,7 +786,7 @@ void func_80B97E4C(EnZot* this, GlobalContext* globalCtx) { this->actionFunc = func_80B97D6C; this->unk_2F2 |= 4; func_80B96BEC(this, 3, 0); - gSaveContext.weekEventReg[38] |= 8; + gSaveContext.save.weekEventReg[38] |= 8; break; case 0x128B: @@ -803,8 +803,8 @@ void func_80B97FD0(EnZot* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_80B97E4C; func_80B97BF8(this, globalCtx); - } else if (gSaveContext.weekEventReg[38] & 8) { - if ((this->actor.xzDistToPlayer < 120.0f) && (gSaveContext.playerForm == PLAYER_FORM_ZORA)) { + } else if (gSaveContext.save.weekEventReg[38] & 8) { + if ((this->actor.xzDistToPlayer < 120.0f) && (gSaveContext.save.playerForm == PLAYER_FORM_ZORA)) { this->unk_2F2 |= 4; this->actionFunc = func_80B97E0C; func_80B96BEC(this, 6, 2); @@ -834,38 +834,38 @@ void func_80B98178(EnZot* this, GlobalContext* globalCtx) { switch (ENZOT_GET_1F(&this->actor)) { case 6: - if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { if (CURRENT_DAY == 3) { textId = 0x129D; - } else if (gSaveContext.weekEventReg[39] & 1) { + } else if (gSaveContext.save.weekEventReg[39] & 1) { textId = 0x129C; } else { textId = 0x129B; - gSaveContext.weekEventReg[39] |= 1; + gSaveContext.save.weekEventReg[39] |= 1; } - } else if (gSaveContext.weekEventReg[38] & 0x80) { + } else if (gSaveContext.save.weekEventReg[38] & 0x80) { textId = 0x1293; } else { textId = 0x1291; - gSaveContext.weekEventReg[38] |= 0x80; + gSaveContext.save.weekEventReg[38] |= 0x80; } break; case 7: - if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { - if (gSaveContext.weekEventReg[39] & 4) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.weekEventReg[39] & 4) { textId = 0x12AA; } else { textId = 0x12A6; - gSaveContext.weekEventReg[39] |= 4; + gSaveContext.save.weekEventReg[39] |= 4; } } else if (Flags_GetSwitch(globalCtx, this->actor.home.rot.z & 0x7F)) { textId = 0x12A0; - } else if (gSaveContext.weekEventReg[39] & 2) { + } else if (gSaveContext.save.weekEventReg[39] & 2) { textId = 0x12A5; } else { textId = 0x12A2; - gSaveContext.weekEventReg[39] |= 2; + gSaveContext.save.weekEventReg[39] |= 2; } break; @@ -877,18 +877,18 @@ void func_80B98178(EnZot* this, GlobalContext* globalCtx) { case 16: case 17: phi_v0 = (ENZOT_GET_1F(&this->actor) * 4) - 44; - if (gSaveContext.weekEventReg[79] & 1) { + if (gSaveContext.save.weekEventReg[79] & 1) { phi_v0 += 2; } - if (gSaveContext.playerForm != PLAYER_FORM_ZORA) { + if (gSaveContext.save.playerForm != PLAYER_FORM_ZORA) { phi_v0++; } textId = phi_v0 + 0x1302; break; default: - if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { textId = 0x129F; } else { textId = 0x1295; @@ -979,7 +979,7 @@ void func_80B98728(EnZot* this, GlobalContext* globalCtx) { switch (Message_GetState(&globalCtx->msgCtx)) { case 4: - if (func_80147624(globalCtx) && (globalCtx->msgCtx.unk11F04 == 0x1293)) { + if (Message_ShouldAdvance(globalCtx) && (globalCtx->msgCtx.currentTextId == 0x1293)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_8019F208(); @@ -995,8 +995,8 @@ void func_80B98728(EnZot* this, GlobalContext* globalCtx) { break; case 5: - if (func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x1291: case 0x1292: case 0x1296: @@ -1013,7 +1013,7 @@ void func_80B98728(EnZot* this, GlobalContext* globalCtx) { case 0x12A7: case 0x12A8: case 0x12AE: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x12A9: @@ -1074,44 +1074,44 @@ void func_80B98998(EnZot* this, GlobalContext* globalCtx) { void func_80B98A4C(EnZot* this, GlobalContext* globalCtx) { u16 textId; - if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { - if (gSaveContext.weekEventReg[39] & 0x80) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.weekEventReg[39] & 0x80) { textId = 0x12B6; } else { textId = 0x12B4; - gSaveContext.weekEventReg[39] |= 0x80; + gSaveContext.save.weekEventReg[39] |= 0x80; } - } else if (gSaveContext.weekEventReg[39] & 0x40) { + } else if (gSaveContext.save.weekEventReg[39] & 0x40) { textId = 0x12B3; } else { textId = 0x12B1; - gSaveContext.weekEventReg[39] |= 0x40; + gSaveContext.save.weekEventReg[39] |= 0x40; } Message_StartTextbox(globalCtx, textId, &this->actor); } void func_80B98AD0(EnZot* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x12B1: case 0x12B4: case 0x12B7: case 0x12B9: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x12B8: func_801477B4(globalCtx); this->actionFunc = func_80B98CA8; - gSaveContext.weekEventReg[41] &= (u8)~0x20; - func_8019C300(0); + gSaveContext.save.weekEventReg[41] &= (u8)~0x20; + AudioOcarina_SetInstrumentId(OCARINA_INSTRUMENT_OFF); break; case 0x12BA: func_801477B4(globalCtx); this->actionFunc = func_80B98CA8; - gSaveContext.weekEventReg[41] |= 0x20; - func_8019C300(0); + gSaveContext.save.weekEventReg[41] |= 0x20; + AudioOcarina_SetInstrumentId(OCARINA_INSTRUMENT_OFF); break; default: @@ -1125,7 +1125,7 @@ void func_80B98AD0(EnZot* this, GlobalContext* globalCtx) { void func_80B98BF4(EnZot* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actor.flags &= ~ACTOR_FLAG_10000; - if (gSaveContext.weekEventReg[41] & 0x20) { + if (gSaveContext.save.weekEventReg[41] & 0x20) { Message_StartTextbox(globalCtx, 0x12B7, &this->actor); this->actionFunc = func_80B98AD0; } else { @@ -1140,7 +1140,7 @@ void func_80B98BF4(EnZot* this, GlobalContext* globalCtx) { void func_80B98CA8(EnZot* this, GlobalContext* globalCtx) { if (func_800B8718(&this->actor, &globalCtx->state)) { globalCtx->msgCtx.ocarinaMode = 4; - func_8019B544(0xFFFF); + AudioOcarina_StartDefault(0xFFFF); this->actionFunc = func_80B98BF4; this->actor.flags |= ACTOR_FLAG_10000; func_800B8614(&this->actor, globalCtx, 120.0f); @@ -1152,32 +1152,32 @@ void func_80B98CA8(EnZot* this, GlobalContext* globalCtx) { func_800B8614(&this->actor, globalCtx, 120.0f); } - if ((gSaveContext.playerForm == PLAYER_FORM_ZORA) || (this->actor.xzDistToPlayer < 100.0f)) { + if ((gSaveContext.save.playerForm == PLAYER_FORM_ZORA) || (this->actor.xzDistToPlayer < 100.0f)) { func_800B874C(&this->actor, globalCtx, 120.0, 100.0f); } } if (this->actor.xzDistToPlayer > 100.0f) { - gSaveContext.weekEventReg[41] &= (u8)~0x20; + gSaveContext.save.weekEventReg[41] &= (u8)~0x20; } } void func_80B98E10(EnZot* this, GlobalContext* globalCtx) { u16 textId; - if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { if (Flags_GetSwitch(globalCtx, this->actor.home.rot.z & 0x7F)) { - if (gSaveContext.weekEventReg[40] & 4) { + if (gSaveContext.save.weekEventReg[40] & 4) { textId = 0x12C5; } else { textId = 0x12C3; - gSaveContext.weekEventReg[40] |= 4; + gSaveContext.save.weekEventReg[40] |= 4; } - } else if (gSaveContext.weekEventReg[40] & 2) { + } else if (gSaveContext.save.weekEventReg[40] & 2) { textId = 0x12C2; } else { textId = 0x12C0; - gSaveContext.weekEventReg[40] |= 2; + gSaveContext.save.weekEventReg[40] |= 2; } } else { if (Flags_GetSwitch(globalCtx, this->actor.home.rot.z & 0x7F)) { @@ -1187,10 +1187,10 @@ void func_80B98E10(EnZot* this, GlobalContext* globalCtx) { textId = 0x12BE; this->unk_2F2 |= 0x10; } - } else if (gSaveContext.weekEventReg[40] & 1) { + } else if (gSaveContext.save.weekEventReg[40] & 1) { textId = 0x12BC; } else { - gSaveContext.weekEventReg[40] |= 1; + gSaveContext.save.weekEventReg[40] |= 1; this->unk_2F2 |= 4; textId = 0x12BB; } @@ -1213,15 +1213,15 @@ void func_80B98F94(EnZot* this, GlobalContext* globalCtx) { this->actor.world.rot.y = this->actor.shape.rot.y; } - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x12BB: this->unk_2F2 &= ~4; case 0x12BC: case 0x12C0: case 0x12C3: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x12BE: @@ -1252,18 +1252,18 @@ void func_80B990A4(EnZot* this, GlobalContext* globalCtx) { void func_80B99160(EnZot* this, GlobalContext* globalCtx) { u16 textId; - if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { - if (gSaveContext.weekEventReg[40] & 0x10) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.weekEventReg[40] & 0x10) { textId = 0x12CD; } else { textId = 0x12CA; - gSaveContext.weekEventReg[40] |= 0x10; + gSaveContext.save.weekEventReg[40] |= 0x10; } - } else if (gSaveContext.weekEventReg[40] & 8) { + } else if (gSaveContext.save.weekEventReg[40] & 8) { textId = 0x12C9; } else { textId = 0x12C6; - gSaveContext.weekEventReg[40] |= 8; + gSaveContext.save.weekEventReg[40] |= 8; } Message_StartTextbox(globalCtx, textId, &this->actor); } @@ -1274,8 +1274,8 @@ void func_80B991E4(EnZot* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x800, 0x100); this->actor.world.rot.y = this->actor.shape.rot.y; - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - u16 temp = globalCtx->msgCtx.unk11F04; + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + u16 temp = globalCtx->msgCtx.currentTextId; u32 temp2; if ((temp == 0x12C6) || (temp == 0x12C7) || (temp == 0x12CA) || (temp == 0x12CB)) { diff --git a/src/overlays/actors/ovl_En_Zov/z_en_zov.c b/src/overlays/actors/ovl_En_Zov/z_en_zov.c index 724f074daf..f593709cff 100644 --- a/src/overlays/actors/ovl_En_Zov/z_en_zov.c +++ b/src/overlays/actors/ovl_En_Zov/z_en_zov.c @@ -107,7 +107,7 @@ void EnZov_Init(Actor* thisx, GlobalContext* globalCtx) { case ENZOV_F_1: this->actionFunc = func_80BD1F1C; func_80BD1570(this, 9, 0); - if (!(gSaveContext.weekEventReg[55] & 0x80)) { + if (!(gSaveContext.save.weekEventReg[55] & 0x80)) { Actor_MarkForDeath(&this->actor); return; } @@ -120,7 +120,7 @@ void EnZov_Init(Actor* thisx, GlobalContext* globalCtx) { default: this->unk_320 |= 2; - if ((gSaveContext.weekEventReg[55] & 0x80) || (gSaveContext.weekEventReg[53] & 0x20)) { + if ((gSaveContext.save.weekEventReg[55] & 0x80) || (gSaveContext.save.weekEventReg[53] & 0x20)) { Actor_MarkForDeath(&this->actor); } break; @@ -185,9 +185,9 @@ s32 func_80BD15A4(EnZov* this, GlobalContext* globalCtx) { void func_80BD160C(EnZov* this, GlobalContext* globalCtx) { s32 textId = 0; - if (gSaveContext.weekEventReg[53] & 0x20) { + if (gSaveContext.save.weekEventReg[53] & 0x20) { this->unk_320 &= ~2; - if (gSaveContext.playerForm != PLAYER_FORM_ZORA) { + if (gSaveContext.save.playerForm != PLAYER_FORM_ZORA) { textId = 0x1024; if ((this->unk_322 == 0) || (this->unk_322 == 4)) { func_80BD1570(this, 4, 2); @@ -201,7 +201,7 @@ void func_80BD160C(EnZov* this, GlobalContext* globalCtx) { this->unk_320 |= 4; func_80BD1570(this, 3, 2); } - } else if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + } else if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { func_80BD1570(this, 2, 2); this->actionFunc = func_80BD19FC; this->unk_324 = 10; @@ -261,8 +261,8 @@ void func_80BD187C(EnZov* this, GlobalContext* globalCtx) { switch (Message_GetState(&globalCtx->msgCtx)) { case 5: - if (func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x1022: func_80151938(globalCtx, 0x1023); break; @@ -390,8 +390,8 @@ void func_80BD1C84(EnZov* this, GlobalContext* globalCtx) { void func_80BD1D30(EnZov* this, GlobalContext* globalCtx) { u16 textId; - if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { - if (gSaveContext.weekEventReg[79] & 1) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.weekEventReg[79] & 1) { textId = 0x1032; } else { textId = 0x1033; @@ -411,22 +411,22 @@ void func_80BD1DB8(EnZov* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x1000, 0x200); this->actor.world.rot.y = this->actor.shape.rot.y; - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x1033: case 0x1034: case 0x1035: case 0x1036: case 0x1037: case 0x1038: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x1039: globalCtx->nextEntranceIndex = globalCtx->setupExitList[ENZOV_GET_FE00(&this->actor)]; globalCtx->unk_1887F = 5; globalCtx->sceneLoadFlag = 0x14; - gSaveContext.weekEventReg[78] |= 1; + gSaveContext.save.weekEventReg[78] |= 1; this->actionFunc = func_80BD1D94; globalCtx->msgCtx.unk11F10 = 0; Audio_QueueSeqCmd(0x101400FF); diff --git a/src/overlays/actors/ovl_En_Zow/z_en_zow.c b/src/overlays/actors/ovl_En_Zow/z_en_zow.c index cf4e03e54d..cf609e0fec 100644 --- a/src/overlays/actors/ovl_En_Zow/z_en_zow.c +++ b/src/overlays/actors/ovl_En_Zow/z_en_zow.c @@ -360,45 +360,45 @@ void func_80BDD1E0(EnZow* this, GlobalContext* globalCtx) { u16 phi_a1; if (ENZOW_GET_F(&this->actor) == ENZOW_F_1) { - if (gSaveContext.weekEventReg[55] & 0x80) { - if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { - if (gSaveContext.weekEventReg[78] & 4) { + if (gSaveContext.save.weekEventReg[55] & 0x80) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.weekEventReg[78] & 4) { phi_a1 = 0x12FD; } else { phi_a1 = 0x12FA; - gSaveContext.weekEventReg[78] |= 4; + gSaveContext.save.weekEventReg[78] |= 4; } - } else if (gSaveContext.weekEventReg[78] & 0x10) { + } else if (gSaveContext.save.weekEventReg[78] & 0x10) { phi_a1 = 0x1301; } else { - gSaveContext.weekEventReg[78] |= 0x10; + gSaveContext.save.weekEventReg[78] |= 0x10; phi_a1 = 0x12FF; } - } else if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { - if (gSaveContext.weekEventReg[78] & 8) { + } else if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.weekEventReg[78] & 8) { phi_a1 = 0x12F8; } else { phi_a1 = 0x12F3; - gSaveContext.weekEventReg[78] |= 8; + gSaveContext.save.weekEventReg[78] |= 8; } - } else if (gSaveContext.weekEventReg[78] & 0x10) { + } else if (gSaveContext.save.weekEventReg[78] & 0x10) { phi_a1 = 0x1301; } else { - gSaveContext.weekEventReg[78] |= 0x10; + gSaveContext.save.weekEventReg[78] |= 0x10; phi_a1 = 0x12FF; } - } else if (gSaveContext.weekEventReg[55] & 0x80) { - if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + } else if (gSaveContext.save.weekEventReg[55] & 0x80) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { phi_a1 = 0x12EC; } else { phi_a1 = 0x12F1; } - } else if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { - if (gSaveContext.weekEventReg[78] & 2) { + } else if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.weekEventReg[78] & 2) { phi_a1 = 0x12EB; } else { phi_a1 = 0x12E8; - gSaveContext.weekEventReg[78] |= 2; + gSaveContext.save.weekEventReg[78] |= 2; } } else { phi_a1 = 0x12EF; @@ -463,8 +463,8 @@ void func_80BDD570(EnZow* this, GlobalContext* globalCtx) { switch (Message_GetState(&globalCtx->msgCtx)) { case 5: - if (func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x12E8: case 0x12E9: case 0x12EC: @@ -480,7 +480,7 @@ void func_80BDD570(EnZow* this, GlobalContext* globalCtx) { case 0x12FB: case 0x12FD: case 0x12FF: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; default: diff --git a/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c b/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c index 18aafc07ad..c6de60ce2b 100644 --- a/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c +++ b/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c @@ -465,7 +465,8 @@ void MirRay_SetupReflectionPolys(MirRay* this, GlobalContext* globalCtx, MirRayS // Remove reflections that are in the same position and are sufficiently near to the same plane void MirRay_RemoveSimilarReflections(MirRayShieldReflection* reflection) { - s32 i, j; + s32 i; + s32 j; for (i = 0; i < 6; i++) { for (j = i + 1; j < 6; j++) { diff --git a/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.c b/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.c index 1da636c1d2..15bef2ca50 100644 --- a/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.c +++ b/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.c @@ -5,6 +5,7 @@ */ #include "z_mir_ray3.h" +#include "objects/object_mir_ray/object_mir_ray.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -15,7 +16,6 @@ void MirRay3_Destroy(Actor* thisx, GlobalContext* globalCtx); void MirRay3_Update(Actor* thisx, GlobalContext* globalCtx); void MirRay3_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Mir_Ray3_InitVars = { ACTOR_MIR_RAY3, ACTORCAT_ITEMACTION, @@ -28,39 +28,398 @@ const ActorInit Mir_Ray3_InitVars = { (ActorFunc)MirRay3_Draw, }; -// static ColliderQuadInit sQuadInit = { -static ColliderQuadInit D_80B9F420 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_PLAYER, AC_NONE, OC1_NONE, OC2_NONE, COLSHAPE_QUAD, }, - { ELEMTYPE_UNK0, { 0x00200000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_NONE, }, +static ColliderQuadInit sQuadInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_PLAYER, + AC_NONE, + OC1_NONE, + OC2_NONE, + COLSHAPE_QUAD, + }, + { + ELEMTYPE_UNK0, + { 0x00200000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_NONE, + }, { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B9F470 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER | AC_TYPE_OTHER, OC1_NONE, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00200000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER | AC_TYPE_OTHER, + OC1_NONE, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00200000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 10, 10, 0, { 0, 0, 0 } }, }; +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ MtxF unk_0C; + /* 0x4C */ CollisionPoly* unk_4C; + /* 0x50 */ u8 unk_50; +} MirRay3Struct; // size = 0x54 + +void MirRay3_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + MirRay3* this = THIS; + + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); + Actor_SetScale(&this->actor, 1.0f); + + this->unk_218[0].x = -536.0f; + this->unk_218[0].y = -939.0f; + + this->unk_218[1].x = -1690.0f; + this->unk_218[1].y = 0.0f; + + this->unk_218[2].x = -536.0f; + this->unk_218[2].y = 938.0f; + + this->unk_218[3].x = 921.0f; + this->unk_218[3].y = 0.0f; + + this->unk_218[4].x = 758.0f; + this->unk_218[4].y = 800.0f; + + this->unk_218[5].x = 758.0f; + this->unk_218[5].y = -800.0f; + + Collider_InitQuad(globalCtx, &this->colliderQuad); + Collider_SetQuad(globalCtx, &this->colliderQuad, &this->actor, &sQuadInit); + Collider_InitCylinder(globalCtx, &this->colliderCylinder); + Collider_SetCylinder(globalCtx, &this->colliderCylinder, &this->actor, &sCylinderInit); + this->actor.world.rot.x = this->actor.shape.rot.x = 0; +} + +void MirRay3_Destroy(Actor* thisx, GlobalContext* globalCtx) { + MirRay3* this = THIS; + + Collider_DestroyQuad(globalCtx, &this->colliderQuad); + Collider_DestroyCylinder(globalCtx, &this->colliderCylinder); +} + +void MirRay3_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad[2]; + MirRay3* this = THIS; + Player* player = GET_PLAYER(globalCtx); + + this->unk_210 &= ~1; + + if (this->unk_214 > 0.5f) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderQuad.base); + } + + this->unk_210 &= ~2; + + if (func_8012405C(globalCtx)) { + if (this->colliderCylinder.base.acFlags & AC_HIT) { + this->unk_210 |= 2; + } + this->actor.world.pos.x = player->shieldMf.mf[3][0]; + this->actor.world.pos.y = player->shieldMf.mf[3][1]; + this->actor.world.pos.z = player->shieldMf.mf[3][2]; + Collider_UpdateCylinder(&this->actor, &this->colliderCylinder); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); + } + + if (this->unk_214 > 0.1f) { + func_800B8F98(&player->actor, NA_SE_IT_SHIELD_BEAM - SFX_FLAG); + } + + Math_ApproachZeroF(&this->unk_214, 1.0f, 0.1f); +} + +void func_80B9E544(MirRay3* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + MtxF* shieldMtx = &player->shieldMf; + f32 temp_f0; + + if (this->unk_210 & 2) { + temp_f0 = sqrtf(SQ(shieldMtx->mf[2][0]) + SQ(shieldMtx->mf[2][1]) + SQ(shieldMtx->mf[2][2])); + if (temp_f0 == 0.0f) { + this->unk_260 = 1.0f; + } else { + this->unk_260 = 1.0f / temp_f0; + } + Math_ApproachF(&this->unk_214, 1.0f, 0.5f, 0.25f); + } +} + +void func_80B9E5F4(MirRay3* this, GlobalContext* globalCtx, MirRay3Struct* ptr) { + Player* player = GET_PLAYER(globalCtx); + MtxF* shieldMtx = &player->shieldMf; + s32 i; + Vec3f sp88; + Vec3f sp7C; + Vec3f sp70; + CollisionPoly* sp6C; + f32 sp60[3]; + + sp60[0] = -(shieldMtx->mf[2][0] * this->unk_260) * this->unk_214 * 400.0f; + sp60[1] = -(shieldMtx->mf[2][1] * this->unk_260) * this->unk_214 * 400.0f; + sp60[2] = -(shieldMtx->mf[2][2] * this->unk_260) * this->unk_214 * 400.0f; + + for (i = 0; i < ARRAY_COUNT(this->unk_218); i++) { + sp88.x = (shieldMtx->mf[3][0] + (this->unk_218[i].x * shieldMtx->mf[0][0])) + + (this->unk_218[i].y * shieldMtx->mf[1][0]); + sp88.y = (shieldMtx->mf[3][1] + (this->unk_218[i].x * shieldMtx->mf[0][1])) + + (this->unk_218[i].y * shieldMtx->mf[1][1]); + sp88.z = (shieldMtx->mf[3][2] + (this->unk_218[i].x * shieldMtx->mf[0][2])) + + (this->unk_218[i].y * shieldMtx->mf[1][2]); + + sp7C.x = sp60[0] + sp88.x; + sp7C.y = sp60[1] + sp88.y; + sp7C.z = sp60[2] + sp88.z; + + if (BgCheck_AnyLineTest1(&globalCtx->colCtx, &sp88, &sp7C, &sp70, &sp6C, true)) { + ptr[i].unk_4C = sp6C; + } else { + ptr[i].unk_4C = NULL; + } + } +} + +void func_80B9E7D0(MirRay3Struct* ptr) { + s32 i; + s32 j; + + for (i = 0; i < 6; i++) { + for (j = i + 1; j < 6; j++) { + if ((ptr[i].unk_4C != NULL) && (ptr[j].unk_4C != NULL)) { + if ((ABS(ptr[i].unk_4C->normal.x - ptr[j].unk_4C->normal.x) < 100) && + (ABS(ptr[i].unk_4C->normal.y - ptr[j].unk_4C->normal.y) < 100) && + (ABS(ptr[i].unk_4C->normal.z - ptr[j].unk_4C->normal.z) < 100) && + (ptr[i].unk_4C->dist == ptr[j].unk_4C->dist)) { + ptr[j].unk_4C = NULL; + } + } + } + } +} + +#ifdef NON_MATCHING +void func_80B9E8D4(MirRay3* this, GlobalContext* globalCtx, MirRay3Struct* ptr) { + Player* player = GET_PLAYER(globalCtx); + s32 i; + MtxF* shieldMf = &player->shieldMf; + Vec3f sp140; + Vec3f sp134; + Vec3f sp128; + Vec3f sp11C; + Vec3f sp110; + Vec3f sp104; + f32 spF8[3]; + f32 spEC[3]; + f32 temp_f0; + f32 temp_f26; + f32 temp_f2; + Vec3f spD4; + Vec3f spC8; + CollisionPoly* spC4; + + spF8[0] = -(shieldMf->mf[2][0] * this->unk_260) * this->unk_214 * 400.0f; + spF8[1] = -(shieldMf->mf[2][1] * this->unk_260) * this->unk_214 * 400.0f; + spF8[2] = -(shieldMf->mf[2][2] * this->unk_260) * this->unk_214 * 400.0f; + + sp140.x = shieldMf->mf[3][0]; + sp140.y = shieldMf->mf[3][1]; + sp140.z = shieldMf->mf[3][2]; + + sp134.x = spF8[0] + sp140.x; + sp134.y = spF8[1] + sp140.y; + sp134.z = spF8[2] + sp140.z; + + temp_f26 = this->unk_214 * 400.0f; + + for (i = 0; i < ARRAY_COUNT(this->unk_218); i++) { + if (ptr[i].unk_4C != NULL) { + spEC[0] = COLPOLY_GET_NORMAL(ptr[i].unk_4C->normal.x); + spEC[1] = COLPOLY_GET_NORMAL(ptr[i].unk_4C->normal.y); + spEC[2] = COLPOLY_GET_NORMAL(ptr[i].unk_4C->normal.z); + + if (Math3D_LineSegVsPlane(spEC[0], spEC[1], spEC[2], ptr[i].unk_4C->dist, &sp140, &sp134, &sp128, true)) { + ptr[i].unk_00.x = sp128.x; + ptr[i].unk_00.y = sp128.y; + ptr[i].unk_00.z = sp128.z; + + temp_f0 = sqrtf(SQ(sp128.x - sp140.x) + SQ(sp128.y - sp140.y) + SQ(sp128.z - sp140.z)); + + if (temp_f0 < (temp_f26 * 0.9f)) { + ptr[i].unk_50 = 0xFF; + } else if (temp_f26 < temp_f0) { + ptr[i].unk_50 = 0; + } else { + ptr[i].unk_50 = (s32)((10.0f - ((10.0f / temp_f26) * temp_f0)) * 255.0f); + } + + sp11C.x = (shieldMf->mf[0][0] * 100.0f) + sp140.x; + sp11C.y = (shieldMf->mf[0][1] * 100.0f) + sp140.y; + sp11C.z = (shieldMf->mf[0][2] * 100.0f) + sp140.z; + + sp110.x = (spF8[0] * 4.0f) + sp11C.x; + sp110.y = (spF8[1] * 4.0f) + sp11C.y; + sp110.z = (spF8[2] * 4.0f) + sp11C.z; + + ptr[i].unk_0C.mf[0][0] = ptr[i].unk_0C.mf[1][1] = ptr[i].unk_0C.mf[2][2] = ptr[i].unk_0C.mf[3][3] = + 1.0f; + + ptr[i].unk_0C.mf[0][1] = ptr[i].unk_0C.mf[0][2] = ptr[i].unk_0C.mf[0][3] = ptr[i].unk_0C.mf[1][0] = + ptr[i].unk_0C.mf[1][2] = ptr[i].unk_0C.mf[1][3] = ptr[i].unk_0C.mf[2][0] = ptr[i].unk_0C.mf[2][1] = + ptr[i].unk_0C.mf[2][3] = ptr[i].unk_0C.mf[3][0] = ptr[i].unk_0C.mf[3][1] = + ptr[i].unk_0C.mf[3][2] = 0.0f; + + if (Math3D_LineSegVsPlane(spEC[0], spEC[1], spEC[2], ptr[i].unk_4C->dist, &sp11C, &sp110, &sp104, + true)) { + ptr[i].unk_0C.mf[0][0] = sp104.x - sp128.x; + ptr[i].unk_0C.mf[0][1] = sp104.y - sp128.y; + ptr[i].unk_0C.mf[0][2] = sp104.z - sp128.z; + } + + sp11C.x = (shieldMf->mf[1][0] * 100.0f) + sp140.x; + sp11C.y = (shieldMf->mf[1][1] * 100.0f) + sp140.y; + sp11C.z = (shieldMf->mf[1][2] * 100.0f) + sp140.z; + + sp110.x = (spF8[0] * 4.0f) + sp11C.x; + sp110.y = (spF8[1] * 4.0f) + sp11C.y; + sp110.z = (spF8[2] * 4.0f) + sp11C.z; + + if (Math3D_LineSegVsPlane(spEC[0], spEC[1], spEC[2], ptr[i].unk_4C->dist, &sp11C, &sp110, &sp104, + true)) { + ptr[i].unk_0C.mf[1][0] = sp104.x - sp128.x; + ptr[i].unk_0C.mf[1][1] = sp104.y - sp128.y; + ptr[i].unk_0C.mf[1][2] = sp104.z - sp128.z; + } + } else { + ptr[i].unk_4C = NULL; + } + } + } + + temp_f2 = this->unk_214 * 400.0f; + + spF8[0] = -(this->unk_260 * shieldMf->mf[2][0]); + spF8[1] = -(this->unk_260 * shieldMf->mf[2][1]); + spF8[2] = -(this->unk_260 * shieldMf->mf[2][2]); + + sp134.x = (spF8[0] * temp_f2) + sp140.x; + sp134.y = (spF8[1] * temp_f2) + sp140.y; + sp134.z = (spF8[2] * temp_f2) + sp140.z; + + if (!BgCheck_AnyLineTest1(&globalCtx->colCtx, &sp140, &sp134, &sp128, &spC4, 1)) { + Math_Vec3f_Copy(&sp128, &sp134); + } + + sp128.x += spF8[0] * 5.0f; + sp128.y += spF8[1] * 5.0f; + sp128.z += spF8[2] * 5.0f; + + spD4.x = (shieldMf->mf[0][0] * 300.0f) + sp140.x; + spD4.y = (shieldMf->mf[0][1] * 300.0f) + sp140.y; + spD4.z = (shieldMf->mf[0][2] * 300.0f) + sp140.z; + + spC8.x = (shieldMf->mf[0][0] * 300.0f) + sp128.x; + spC8.y = (shieldMf->mf[0][1] * 300.0f) + sp128.y; + spC8.z = (shieldMf->mf[0][2] * 300.0f) + sp128.z; + + Collider_SetQuadVertices(&this->colliderQuad, &spD4, &sp140, &spC8, &sp128); +} +#else +void func_80B9E8D4(MirRay3* this, GlobalContext* globalCtx, MirRay3Struct* ptr); +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray3/func_80B9E8D4.s") #endif -extern ColliderQuadInit D_80B9F420; -extern ColliderCylinderInit D_80B9F470; +void MirRay3_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad[2]; + MirRay3* this = THIS; + MirRay3Struct sp8C[6]; + Player* player = GET_PLAYER(globalCtx); + s32 i; + f32 temp; + u16 phi_a0; -extern UNK_TYPE D_060003F8; + if (!(this->unk_210 & 1) && func_8012405C(globalCtx)) { + Matrix_InsertMatrix(&player->shieldMf, MTXMODE_NEW); + func_80B9E544(this, globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray3/MirRay3_Init.s") + if (this->unk_214 <= 0.1f) { + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray3/MirRay3_Destroy.s") + OPEN_DISPS(globalCtx->state.gfxCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray3/MirRay3_Update.s") + func_8012C2DC(globalCtx->state.gfxCtx); + Matrix_Scale(1.0f, 1.0f, this->unk_214, MTXMODE_APPLY); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray3/func_80B9E544.s") + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray3/func_80B9E5F4.s") + if (MIRRAY3_GET_F(&this->actor) == MIRRAY3_F_1) { + phi_a0 = gSaveContext.save.time; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray3/func_80B9E7D0.s") + if (phi_a0 > CLOCK_TIME(12, 0)) { + phi_a0 = 0xFFFF - phi_a0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray3/func_80B9E8D4.s") + temp = (phi_a0 * (1.0f / 0x8000)); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x78, 255, 255, 255, (u8)(s8)(100 * this->unk_214)); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray3/MirRay3_Draw.s") + gDPSetEnvColor(POLY_XLU_DISP++, 218, 225, (u8)((100.0f * temp) + 105.0f), 255); + } else { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x78, 255, 255, 255, (u8)(s8)(100 * this->unk_214)); + gDPSetEnvColor(POLY_XLU_DISP++, 218, 225, 205, 255); + } + + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(object_mir_ray_Matanimheader_0003F8)); + + gSPDisplayList(POLY_XLU_DISP++, object_mir_ray_DL_000168); + + func_80B9E5F4(this, globalCtx, sp8C); + func_80B9E7D0(sp8C); + func_80B9E8D4(this, globalCtx, sp8C); + + if (sp8C[0].unk_4C == NULL) { + sp8C[0].unk_50 = 0; + } + + for (i = 1; i < ARRAY_COUNT(sp8C); i++) { + if ((sp8C[i].unk_4C != NULL) && (sp8C[0].unk_50 < sp8C[i].unk_50)) { + sp8C[0].unk_50 = sp8C[i].unk_50; + } + } + + gDPSetRenderMode(POLY_XLU_DISP++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_XLU_DECAL2); + + for (i = 0; i < ARRAY_COUNT(sp8C); i++) { + if (sp8C[i].unk_4C != NULL) { + Matrix_InsertTranslation(sp8C[i].unk_00.x, sp8C[i].unk_00.y, sp8C[i].unk_00.z, MTXMODE_NEW); + Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); + Matrix_InsertMatrix(&sp8C[i].unk_0C, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, sp8C[0].unk_50); + gSPDisplayList(POLY_XLU_DISP++, object_mir_ray_DL_0004B0); + } + } + + this->unk_210 |= 1; + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.h b/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.h index 18510673d3..7aecd111fc 100644 --- a/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.h +++ b/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.h @@ -5,9 +5,18 @@ struct MirRay3; +#define MIRRAY3_GET_F(thisx) ((thisx)->params & 0xF) + +#define MIRRAY3_F_1 1 + typedef struct MirRay3 { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x120]; + /* 0x144 */ ColliderQuad colliderQuad; + /* 0x1C4 */ ColliderCylinder colliderCylinder; + /* 0x210 */ u16 unk_210; + /* 0x214 */ f32 unk_214; + /* 0x218 */ Vec3f unk_218[6]; + /* 0x260 */ f32 unk_260; } MirRay3; // size = 0x264 extern const ActorInit Mir_Ray3_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.c b/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.c index 2d7db7644c..998e85d682 100644 --- a/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.c +++ b/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.c @@ -5,6 +5,7 @@ */ #include "z_obj_armos.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_4000000) @@ -15,11 +16,13 @@ void ObjArmos_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjArmos_Update(Actor* thisx, GlobalContext* globalCtx); void ObjArmos_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_809A54B4(ObjArmos* this); void func_809A54E0(ObjArmos* this, GlobalContext* globalCtx); +void func_809A5610(ObjArmos* this); void func_809A562C(ObjArmos* this, GlobalContext* globalCtx); +void func_809A57D8(ObjArmos* this); void func_809A57F4(ObjArmos* this, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Armos_InitVars = { ACTOR_OBJ_ARMOS, ACTORCAT_PROP, @@ -32,51 +35,358 @@ const ActorInit Obj_Armos_InitVars = { (ActorFunc)ObjArmos_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_809A5BC0[] = { - ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 120, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 250, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(gravity, -4000, ICHAIN_CONTINUE), +s16 D_809A5BB0[] = { 1, -1, 0, 0 }; +s16 D_809A5BB8[] = { 0, 0, 1, -1 }; + +static InitChainEntry sInitChain[] = { + ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 120, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 250, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -4000, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 10, ICHAIN_STOP), }; -#endif +s32 func_809A4E00(ObjArmos* this, GlobalContext* globalCtx, s16 arg2) { + return !DynaPolyActor_ValidateMove(globalCtx, &this->dyna, 30, arg2, 1) || + !DynaPolyActor_ValidateMove(globalCtx, &this->dyna, 30, arg2, 28); +} -extern InitChainEntry D_809A5BC0[]; +s32 func_809A4E68(ObjArmos* this) { + s16 temp_v0; -extern UNK_TYPE D_0600033C; + if (fabsf(this->dyna.pushForce) > 0.1f) { + temp_v0 = BINANG_ADD(this->dyna.yRotation, 0x2000); + if (this->dyna.pushForce < 0.0f) { + temp_v0 = BINANG_ROT180(temp_v0); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/func_809A4E00.s") + if (temp_v0 < -0x4000) { + return 3; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/func_809A4E68.s") + if (temp_v0 < 0) { + return 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/func_809A4F00.s") + if (temp_v0 < 0x4000) { + return 2; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/func_809A500C.s") + return 0; + } + return -1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/func_809A518C.s") +s32 func_809A4F00(ObjArmos* this, s32 arg1) { + s32 temp_v0 = OBJARMOS_GET_ROTZ_7(&this->dyna.actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/ObjArmos_Init.s") + if (temp_v0 == OBJARMOS_ROT_7_0) { + return arg1 == 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/ObjArmos_Destroy.s") + if (temp_v0 == OBJARMOS_ROT_7_1) { + return arg1 == 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/func_809A54B4.s") + if (temp_v0 == OBJARMOS_ROT_7_2) { + return arg1 == 2; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/func_809A54E0.s") + if (temp_v0 == OBJARMOS_ROT_7_3) { + return arg1 == 3; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/func_809A5610.s") + if (temp_v0 == OBJARMOS_ROT_7_4) { + return arg1 == 0 || arg1 == 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/func_809A562C.s") + if (temp_v0 == OBJARMOS_ROT_7_5) { + return arg1 == 2 || arg1 == 3; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/func_809A57D8.s") + if (temp_v0 == OBJARMOS_ROT_7_6) { + if (this->unk_26E != 0) { + return arg1 == 0 || arg1 == 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/func_809A57F4.s") + if (this->unk_270 != 0) { + return arg1 == 2 || arg1 == 3; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/ObjArmos_Update.s") + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/func_809A5960.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/func_809A5A3C.s") +s32 func_809A500C(ObjArmos* this, s32 arg1) { + s32 temp_v0 = OBJARMOS_GET_ROTZ_7(&this->dyna.actor); + s32 temp_v1 = OBJARMOS_GET_ROTX_F(&this->dyna.actor); + s32 temp; + s32 temp2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/ObjArmos_Draw.s") + if (temp_v0 == OBJARMOS_ROT_7_0) { + return this->unk_26E < temp_v1; + } + + if (temp_v0 == OBJARMOS_ROT_7_1) { + return -temp_v1 < this->unk_26E; + } + + if (temp_v0 == OBJARMOS_ROT_7_2) { + return this->unk_270 < temp_v1; + } + + if (temp_v0 == OBJARMOS_ROT_7_3) { + return -temp_v1 < this->unk_270; + } + + if (temp_v0 == OBJARMOS_ROT_7_4) { + temp = D_809A5BB0[arg1] + this->unk_26E; + return temp <= temp_v1 && -temp_v1 <= temp; + } + + if (temp_v0 == OBJARMOS_ROT_7_5) { + temp2 = D_809A5BB8[arg1] + this->unk_270; + return temp2 <= temp_v1 && -temp_v1 <= temp2; + } + + if (temp_v0 == OBJARMOS_ROT_7_6) { + if ((arg1 == 0) || (arg1 == 1)) { + temp = D_809A5BB0[arg1] + this->unk_26E; + return temp <= temp_v1 && -temp_v1 <= temp; + } + + temp2 = D_809A5BB8[arg1] + this->unk_270; + return temp2 <= temp_v1 && -temp_v1 <= temp2; + } + + return false; +} + +void func_809A518C(ObjArmos* this, s32 arg1) { + this->unk_26E += D_809A5BB0[arg1]; + this->unk_270 += D_809A5BB8[arg1]; + + if ((arg1 == 0) || (arg1 == 1)) { + this->unk_25C = &this->dyna.actor.world.pos.x; + this->unk_260 = this->dyna.actor.home.pos.x + (this->unk_26E * 60); + } else { + this->unk_25C = &this->dyna.actor.world.pos.z; + this->unk_260 = this->dyna.actor.home.pos.z + (this->unk_270 * 60); + } + this->unk_264 = arg1; +} + +void ObjArmos_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjArmos* this = THIS; + s32 sp44 = OBJARMOS_GET_ROTZ_7(&this->dyna.actor); + s32 sp40 = OBJARMOS_GET_ROTX_F(&this->dyna.actor); + f32 sp3C = Animation_GetLastFrame(&gArmosPushedBackAnim); + + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + + this->dyna.actor.home.rot.y = this->dyna.actor.world.rot.x = this->dyna.actor.world.rot.y = + this->dyna.actor.world.rot.z = this->dyna.actor.shape.rot.x = this->dyna.actor.shape.rot.z = 0; + + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_am_Colheader_005CF8); + + SkelAnime_Init(globalCtx, &this->skelAnime, &object_am_Skel_005948, &gArmosPushedBackAnim, this->jointTable, + this->morphTable, OBJECT_AM_LIMB_MAX); + + Animation_Change(&this->skelAnime, &gArmosPushedBackAnim, 0.0f, sp3C, sp3C, ANIMMODE_ONCE, 0.0f); + + if (sp40 == 0) { + func_809A57D8(this); + } else if (Flags_GetSwitch(globalCtx, OBJARMOS_GET_7F(&this->dyna.actor))) { + if (sp44 == OBJARMOS_ROT_7_0) { + this->dyna.actor.world.pos.x = this->dyna.actor.home.pos.x + (sp40 * 60); + func_809A57D8(this); + } else if (sp44 == OBJARMOS_ROT_7_1) { + this->dyna.actor.world.pos.x = this->dyna.actor.home.pos.x - (sp40 * 60); + func_809A57D8(this); + } else if (sp44 == OBJARMOS_ROT_7_2) { + this->dyna.actor.world.pos.z = this->dyna.actor.home.pos.z + (sp40 * 60); + func_809A57D8(this); + } else if (sp44 == OBJARMOS_ROT_7_3) { + this->dyna.actor.world.pos.z = this->dyna.actor.home.pos.z - (sp40 * 60); + func_809A57D8(this); + } else { + func_809A54B4(this); + } + } else { + func_809A54B4(this); + } +} + +void ObjArmos_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjArmos* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} + +void func_809A54B4(ObjArmos* this) { + this->actionFunc = func_809A54E0; + this->unk_24C = 4; + this->unk_266[1] = 0; + this->unk_266[2] = 0; + this->unk_266[3] = 0; + this->unk_266[0] = 0; +} + +void func_809A54E0(ObjArmos* this, GlobalContext* globalCtx) { + s32 i; + s32 sp20 = func_809A4E68(this); + + for (i = 0; i < ARRAY_COUNT(this->unk_266); i++) { + if (sp20 == i) { + this->unk_266[i]++; + } else if (this->unk_266[i] > 0) { + this->unk_266[i]--; + } + } + + if (sp20 != -1) { + if ((this->unk_266[sp20] >= 9) && func_809A4F00(this, sp20) && func_809A500C(this, sp20) && + !func_809A4E00(this, globalCtx, (this->dyna.pushForce > 0.0f) ? 90 : 120)) { + func_809A518C(this, sp20); + func_809A5610(this); + } else { + GET_PLAYER(globalCtx)->stateFlags2 &= ~0x10; + this->dyna.pushForce = 0.0f; + } + } +} + +void func_809A5610(ObjArmos* this) { + this->actionFunc = func_809A562C; + this->unk_24C = 5; +} + +void func_809A562C(ObjArmos* this, GlobalContext* globalCtx) { + s32 pad[2]; + Player* player; + f32 temp2 = this->unk_260 - *this->unk_25C; + s32 temp; + s32 sp20; + + if (Math_StepToF(this->unk_25C, this->unk_260, (Math_SinS(fabsf(temp2) * 546.13336f) * 1.6f) + 1.0f)) { + player = GET_PLAYER(globalCtx); + temp = OBJARMOS_GET_ROTZ_7(&this->dyna.actor); + sp20 = false; + + if ((temp == OBJARMOS_ROT_7_4) || (temp == OBJARMOS_ROT_7_5) || (temp == OBJARMOS_ROT_7_6)) { + if (!func_809A500C(this, this->unk_264) || func_809A4E00(this, globalCtx, 0x5A)) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + } + } else if (func_809A500C(this, this->unk_264)) { + if (func_809A4E00(this, globalCtx, 0x5A)) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + } + } else { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + Flags_SetSwitch(globalCtx, OBJARMOS_GET_7F(&this->dyna.actor)); + sp20 = true; + } + + player->stateFlags2 &= ~0x10; + this->dyna.pushForce = 0.0f; + + if (!sp20) { + func_809A54B4(this); + } else { + func_809A57D8(this); + } + } else { + func_800B9010(&this->dyna.actor, NA_SE_EV_ROCK_SLIDE - SFX_FLAG); + } +} + +void func_809A57D8(ObjArmos* this) { + this->actionFunc = func_809A57F4; + this->unk_24C = 4; +} + +void func_809A57F4(ObjArmos* this, GlobalContext* globalCtx) { + if (fabsf(this->dyna.pushForce) > 0.1f) { + GET_PLAYER(globalCtx)->stateFlags2 &= ~0x10; + this->dyna.pushForce = 0.0f; + } +} + +void ObjArmos_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + ObjArmos* this = THIS; + s32 sp2C; + + this->actionFunc(this, globalCtx); + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; + + if (this->unk_24C != 0) { + Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 20.0f, 30.0f, 0.0f, this->unk_24C); + + if ((this->actionFunc == func_809A54E0) && (this->dyna.actor.bgCheckFlags & 1) && + (DynaPoly_GetActor(&globalCtx->colCtx, this->dyna.actor.floorBgId) == NULL)) { + this->unk_24C = 0; + } + + this->unk_250.x = (Math_SinS(this->dyna.actor.shape.rot.y) * -9.0f) + this->dyna.actor.world.pos.x; + this->unk_250.y = this->dyna.actor.world.pos.y + 20.0f; + this->unk_250.z = (Math_CosS(this->dyna.actor.shape.rot.y) * -9.0f) + this->dyna.actor.world.pos.z; + + this->dyna.actor.floorHeight = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->dyna.actor.floorPoly, + &sp2C, &this->dyna.actor, &this->unk_250); + } +} + +void func_809A5960(ObjArmos* this, GlobalContext* globalCtx) { + s32 pad; + + OPEN_DISPS(globalCtx->state.gfxCtx); + Vec3f sp28; + + sp28.x = Math_SinS(this->dyna.actor.shape.rot.y); + Matrix_SetStateRotationAndTranslation( + (sp28.x * -9.0f) + this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + (Math_CosS(this->dyna.actor.shape.rot.y) * -9.0f) + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Matrix_Scale(0.014f, 0.014f, 0.014f, MTXMODE_APPLY); + func_8012C28C(globalCtx->state.gfxCtx); + + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0); + + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, &this->dyna.actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_809A5A3C(ObjArmos* this, GlobalContext* globalCtx) { + s32 pad[2]; + MtxF sp48; + + if (this->dyna.actor.floorPoly != NULL) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C448(globalCtx->state.gfxCtx); + + gDPSetCombineLERP(POLY_XLU_DISP++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, COMBINED, 0, 0, 0, + COMBINED); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, 255); + + func_800C0094(this->dyna.actor.floorPoly, this->unk_250.x, this->dyna.actor.floorHeight, this->unk_250.z, + &sp48); + Matrix_SetCurrentState(&sp48); + Matrix_Scale(0.6f, 1.0f, 0.6f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gCircleShadowDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +void ObjArmos_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjArmos* this = THIS; + + func_809A5960(this, globalCtx); + func_809A5A3C(this, globalCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.h b/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.h index cfc360daa1..0a03d49159 100644 --- a/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.h +++ b/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.h @@ -2,16 +2,40 @@ #define Z_OBJ_ARMOS_H #include "global.h" +#include "objects/object_am/object_am.h" struct ObjArmos; typedef void (*ObjArmosActionFunc)(struct ObjArmos*, GlobalContext*); +#define OBJARMOS_GET_7F(thisx) ((thisx)->params & 0x7F) +#define OBJARMOS_GET_ROTZ_7(thisx) ((thisx)->home.rot.z & 7) +#define OBJARMOS_GET_ROTX_F(thisx) ((thisx)->home.rot.x & 0xF) + +enum { + /* 0 */ OBJARMOS_ROT_7_0, + /* 1 */ OBJARMOS_ROT_7_1, + /* 2 */ OBJARMOS_ROT_7_2, + /* 3 */ OBJARMOS_ROT_7_3, + /* 4 */ OBJARMOS_ROT_7_4, + /* 5 */ OBJARMOS_ROT_7_5, + /* 6 */ OBJARMOS_ROT_7_6, +}; + typedef struct ObjArmos { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x104]; + /* 0x0000 */ DynaPolyActor dyna; + /* 0x015C */ SkelAnime skelAnime; + /* 0x01A0 */ Vec3s jointTable[OBJECT_AM_LIMB_MAX]; + /* 0x01F4 */ Vec3s morphTable[OBJECT_AM_LIMB_MAX]; /* 0x0248 */ ObjArmosActionFunc actionFunc; - /* 0x024C */ char unk_24C[0x28]; + /* 0x024C */ u32 unk_24C; + /* 0x0250 */ Vec3f unk_250; + /* 0x025C */ f32* unk_25C; + /* 0x0260 */ f32 unk_260; + /* 0x0264 */ s16 unk_264; + /* 0x0266 */ s16 unk_266[4]; + /* 0x026E */ s16 unk_26E; + /* 0x0270 */ s16 unk_270; } ObjArmos; // size = 0x274 extern const ActorInit Obj_Armos_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c b/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c index 467a81de0c..a02f7f604a 100644 --- a/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c +++ b/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c @@ -234,7 +234,7 @@ void func_809372D0(ObjBean* this) { sp34 = Math3D_Vec3fMagnitude(&actor->velocity); temp_f2 = D_80938FF8[this->unk_1DE].x; - temp_f12 = D_80938FF8[this->unk_1DE].y; + temp_f12 = D_80938FF8[this->unk_1DE].z; if (sp34 < (actor->speedXZ * 8.0f)) { temp_f2 = ((temp_f2 - 2.0f) * 0.1f) + 2.0f; temp_f12 *= 0.4f; @@ -303,8 +303,8 @@ void func_809375C8(ObjBean* this, GlobalContext* globalCtx) { void func_809375F4(ObjBean* this, GlobalContext* globalCtx) { static Gfx* D_80939024[] = { - gameplay_keep_DL_0527F0, - gameplay_keep_DL_0528B0, + gKakeraLeafMiddle, + gKakeraLeafTip, }; Vec3f spC4; Vec3f spB8; @@ -346,7 +346,7 @@ void func_809375F4(ObjBean* this, GlobalContext* globalCtx) { phi_v0 = 0x40; } EffectSsKakera_Spawn(globalCtx, &spC4, &spB8, &spC4, phi_s3, phi_v0, 40, 3, 0, temp_s2, 0, 0, - (temp_s2 >> 3) + 40, -1, 1, D_80939024[i & 1]); + (temp_s2 >> 3) + 40, -1, GAMEPLAY_KEEP, D_80939024[i & 1]); } } diff --git a/src/overlays/actors/ovl_Obj_Bell/z_obj_bell.c b/src/overlays/actors/ovl_Obj_Bell/z_obj_bell.c index dd57b99e41..14e25c57d0 100644 --- a/src/overlays/actors/ovl_Obj_Bell/z_obj_bell.c +++ b/src/overlays/actors/ovl_Obj_Bell/z_obj_bell.c @@ -119,19 +119,16 @@ s32 func_80A35510(ObjBell* this, s32 arg1) { if (((arg1 == 0) && (this->unk_21C < 1000.0f)) || ((arg1 == 1) && (this->unk_21C < 4000.0f)) || (arg1 == 2)) { phi_a3 = true; - } else { - phi_a3 = phi_a3; } switch (arg1) { case 0: - this->unk_21C += this->unk_21C > 1000.0f ? 250.0f : 1000.0f; + this->unk_21C += ((this->unk_21C > 1000.0f) ? 250.0f : 1000.0f); break; case 1: - this->unk_21C += this->unk_21C > 3000.0f ? 750.0f : 3000.0f; + this->unk_21C += ((this->unk_21C > 3000.0f) ? 750.0f : 3000.0f); break; case 2: - if (1) {} this->unk_21C += 9000.0f; break; } diff --git a/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.c b/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.c index 1995aacf91..b4a85a3a04 100644 --- a/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.c +++ b/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.c @@ -5,6 +5,8 @@ */ #include "z_obj_bigicicle.h" +#include "overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.h" +#include "objects/object_bigicicle/object_bigicicle.h" #define FLAGS 0x00000000 @@ -21,7 +23,6 @@ void func_80AE9180(ObjBigicicle* this, GlobalContext* globalCtx); void func_80AE9258(ObjBigicicle* this, GlobalContext* globalCtx); void func_80AE939C(ObjBigicicle* this, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Bigicicle_InitVars = { ACTOR_OBJ_BIGICICLE, ACTORCAT_PROP, @@ -34,51 +35,287 @@ const ActorInit Obj_Bigicicle_InitVars = { (ActorFunc)ObjBigicicle_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80AE9820 = { - { COLTYPE_HARD, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00003820, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit1 = { + { + COLTYPE_HARD, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00003820, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 23, 68, -40, { 0, 0, 0 } }, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80AE984C = { - { COLTYPE_HARD, AT_NONE, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit2 = { + { + COLTYPE_HARD, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 31, 90, -150, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80AE9888[] = { +AnimatedMaterial* D_80AE9878 = object_bigicicle_Matanimheader_001678; + +Vec3f D_80AE987C = { 0.0f, -1.0f, 0.0f }; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(gravity, -2, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 5600, ICHAIN_STOP), }; -#endif +s32 D_80AE9890 = false; -extern ColliderCylinderInit D_80AE9820; -extern ColliderCylinderInit D_80AE984C; -extern InitChainEntry D_80AE9888[]; +Color_RGBA8 D_80AE9894 = { 250, 250, 250, 255 }; +Color_RGBA8 D_80AE9898 = { 180, 180, 180, 255 }; -extern UNK_TYPE D_060009B0; -extern UNK_TYPE D_060014F0; +Gfx* D_80AE989C[] = { object_bigicicle_DL_001D10, object_bigicicle_DL_002530, object_bigicicle_DL_002C20 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bigicicle/ObjBigicicle_Init.s") +Gfx* D_80AE98A8[] = { + object_bigicicle_DL_000B20, + object_bigicicle_DL_000D60, + object_bigicicle_DL_000F40, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bigicicle/ObjBigicicle_Destroy.s") +void ObjBigicicle_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjBigicicle* this = THIS; + f32 sp30; + s32 sp28; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bigicicle/func_80AE8DE4.s") + Actor_ProcessInitChain(&this->actor, sInitChain); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bigicicle/func_80AE8FD4.s") + sp28 = OBJBIGICLE_GET_FF00(&this->actor); + if ((sp28 == 0) || (sp28 == 0xFF)) { + sp28 = 0x3C; + } + Actor_SetScale(&this->actor, sp28 * 0.001f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bigicicle/func_80AE9090.s") + this->actor.params &= 0xFF; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + sp30 = sp28 * (1.0f / 60.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bigicicle/func_80AE9180.s") + Collider_InitAndSetCylinder(globalCtx, &this->collider1, &this->actor, &sCylinderInit1); + this->collider1.dim.radius = this->collider1.dim.radius * sp30; + this->collider1.dim.height = this->collider1.dim.height * sp30; + this->collider1.dim.yShift = this->collider1.dim.yShift * sp30; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bigicicle/func_80AE9258.s") + Collider_InitAndSetCylinder(globalCtx, &this->collider2, &this->actor, &sCylinderInit2); + this->collider2.dim.radius = this->collider2.dim.radius * sp30; + this->collider2.dim.height = this->collider2.dim.height * sp30; + this->collider2.dim.yShift = this->collider2.dim.yShift * sp30; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bigicicle/func_80AE939C.s") + if (Flags_GetSwitch(globalCtx, this->actor.params)) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bigicicle/ObjBigicicle_Update.s") + this->unk_148 = this->actor.shape.rot.x; + this->actor.shape.rot.x = 0x4000; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bigicicle/ObjBigicicle_Draw.s") + Collider_UpdateCylinder(&this->actor, &this->collider1); + Collider_UpdateCylinder(&this->actor, &this->collider2); + + if (!D_80AE9890) { + D_80AE9878 = Lib_SegmentedToVirtual(D_80AE9878); + D_80AE9890 = true; + } + + this->unk_149 = 0; + this->actionFunc = func_80AE8FD4; +} + +void ObjBigicicle_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjBigicicle* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->collider1); + Collider_DestroyCylinder(globalCtx, &this->collider2); +} + +void func_80AE8DE4(ObjBigicicle* this, GlobalContext* globalCtx) { + s32 i; + Vec3f sp98; + Vec3f sp8C; + f32 temp_f20 = this->actor.scale.x * (50.0f / 3.0f); + + for (i = 0; i < 10; i++) { + sp98.x = (randPlusMinusPoint5Scaled(4.0f) * temp_f20) + this->actor.world.pos.x; + sp98.y = ((Rand_ZeroFloat(20.0f) - 35.0f) * temp_f20) + this->actor.world.pos.y; + sp98.z = (randPlusMinusPoint5Scaled(4.0f) * temp_f20) + this->actor.world.pos.z; + + sp8C.x = randPlusMinusPoint5Scaled(13.0f); + sp8C.y = Rand_ZeroFloat(2.0f); + sp8C.z = randPlusMinusPoint5Scaled(13.0f); + + EffectSsHahen_Spawn(globalCtx, &sp98, &sp8C, &D_80AE987C, 2, (Rand_ZeroFloat(20.0f) + 30.0f) * temp_f20, + OBJECT_BIGICICLE, 0x28, object_bigicicle_DL_0009B0); + } + + sp98.x = this->actor.world.pos.x; + sp98.y = this->actor.world.pos.y - (25.0f * temp_f20); + sp98.z = this->actor.world.pos.z; + + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &sp98, 40, NA_SE_EV_ICE_PIECE); +} + +void func_80AE8FD4(ObjBigicicle* this, GlobalContext* globalCtx) { + if ((this->collider1.base.acFlags & AC_HIT) || + ((this->collider2.base.acFlags & AC_HIT) && (this->collider2.info.acHitInfo->toucher.dmgFlags & 0x3820))) { + if ((this->unk_148 == 0) || (this->unk_149 == 1)) { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + this->actionFunc = func_80AE9090; + return; + } + + func_80AE8DE4(this, globalCtx); + this->unk_149++; + this->unk_14A = 50; + this->actionFunc = func_80AE9180; + } +} + +void func_80AE9090(ObjBigicicle* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + this->unk_149++; + func_80AE8DE4(this, globalCtx); + if (this->unk_149 == 2) { + f32 temp_f0 = this->actor.scale.y * 2100.0f; + + this->actor.flags |= ACTOR_FLAG_10; + this->actor.shape.yOffset = 2100.0f; + this->actor.world.pos.y -= temp_f0; + this->collider1.dim.yShift += (s16)temp_f0; + this->collider2.dim.yShift += (s16)temp_f0; + this->actionFunc = func_80AE9258; + } else { + this->unk_14A = 50; + this->actionFunc = func_80AE9180; + } + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } +} + +void func_80AE9180(ObjBigicicle* this, GlobalContext* globalCtx) { + this->unk_14A--; + + if (this->unk_14A > 0) { + this->unk_14A--; + this->actor.shape.rot.x = BINANG_ADD((s32)(randPlusMinusPoint5Scaled(1408.0f) * 0.02f * this->unk_14A), 0x4000); + this->actor.shape.rot.z = randPlusMinusPoint5Scaled(1408.0f) * 0.02f * this->unk_14A; + } else { + this->actor.shape.rot.x = 0x4000; + this->actor.shape.rot.z = 0; + ActorCutscene_Stop(this->actor.cutscene); + this->actionFunc = func_80AE8FD4; + } +} + +void func_80AE9258(ObjBigicicle* this, GlobalContext* globalCtx) { + Actor* itemAction; + f32 temp_f0; + ObjIcePoly* icePoly; + + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + + itemAction = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; + + while (itemAction != NULL) { + if (itemAction->id == ACTOR_OBJ_ICE_POLY) { + icePoly = (ObjIcePoly*)itemAction; + temp_f0 = this->actor.world.pos.y - icePoly->actor.world.pos.y; + if ((temp_f0 < icePoly->colliders1[0].dim.height) && (temp_f0 > 0.0f) && + (Actor_XZDistanceBetweenActors(&this->actor, &icePoly->actor) < icePoly->colliders1[0].dim.radius)) { + Flags_SetSwitch(globalCtx, this->actor.params); + this->actionFunc = func_80AE939C; + return; + } + } + itemAction = itemAction->next; + } + + if (this->actor.bgCheckFlags & 1) { + this->actionFunc = func_80AE939C; + } else { + Collider_UpdateCylinder(&this->actor, &this->collider1); + Collider_UpdateCylinder(&this->actor, &this->collider2); + } +} + +void func_80AE939C(ObjBigicicle* this, GlobalContext* globalCtx) { + s32 i; + Vec3f sp98; + Vec3f sp8C; + f32 temp_f20 = this->actor.scale.x * (50.0f / 3.0f); + + for (i = 0; i < 20; i++) { + sp8C.x = randPlusMinusPoint5Scaled(15.0f); + sp8C.y = Rand_ZeroFloat(7.0f) + 3.0f; + sp8C.z = randPlusMinusPoint5Scaled(15.0f); + + sp98.x = this->actor.world.pos.x + (sp8C.x * 5.0f * temp_f20); + sp98.y = this->actor.world.pos.y + (sp8C.y * 7.0f * temp_f20); + sp98.z = this->actor.world.pos.z + (sp8C.z * 5.0f * temp_f20); + + EffectSsHahen_Spawn(globalCtx, &sp98, &sp8C, &D_80AE987C, 2, (Rand_ZeroFloat(30.0f) + 40.0f) * temp_f20, + OBJECT_BIGICICLE, 30, object_bigicicle_DL_0009B0); + } + + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_GLASSBROKEN_IMPACT); + ActorCutscene_Stop(this->actor.cutscene); + Actor_MarkForDeath(&this->actor); +} + +void ObjBigicicle_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjBigicicle* this = THIS; + Vec3f sp44; + + this->actionFunc(this, globalCtx); + + if (Rand_ZeroOne() < 0.05f) { + sp44.x = (((215.0f + Rand_ZeroFloat(65.0f)) * ((Rand_ZeroOne() < 0.5f) ? -1 : 1)) * this->actor.scale.x) + + this->actor.world.pos.x; + sp44.y = ((((Rand_ZeroFloat(1400.0f) + -150.0f) - 2100.0f) + this->actor.shape.yOffset) * this->actor.scale.y) + + this->actor.world.pos.y; + sp44.z = (((215.0f + Rand_ZeroFloat(65.0f)) * ((Rand_ZeroOne() < 0.5f) ? -1 : 1)) * this->actor.scale.z) + + this->actor.world.pos.z; + + EffectSsKiraKira_SpawnDispersed(globalCtx, &sp44, &gZeroVec3f, &gZeroVec3f, &D_80AE9894, &D_80AE9898, 2000, 5); + } + + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); +} + +void ObjBigicicle_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjBigicicle* this = THIS; + + Gfx_DrawDListXlu(globalCtx, D_80AE989C[this->unk_149]); + Gfx_DrawDListXlu(globalCtx, D_80AE98A8[this->unk_149]); + AnimatedMat_Draw(globalCtx, D_80AE9878); + Gfx_DrawDListXlu(globalCtx, object_bigicicle_DL_0014F0); +} diff --git a/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.h b/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.h index 5c3235ef2a..1744a81b46 100644 --- a/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.h +++ b/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.h @@ -7,10 +7,16 @@ struct ObjBigicicle; typedef void (*ObjBigicicleActionFunc)(struct ObjBigicicle*, GlobalContext*); +#define OBJBIGICLE_GET_FF00(thisx) (((thisx)->params >> 8) & 0xFF) + typedef struct ObjBigicicle { /* 0x0000 */ Actor actor; /* 0x0144 */ ObjBigicicleActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x9C]; + /* 0x0148 */ u8 unk_148; + /* 0x0149 */ u8 unk_149; + /* 0x014A */ s16 unk_14A; + /* 0x014C */ ColliderCylinder collider1; + /* 0x0198 */ ColliderCylinder collider2; } ObjBigicicle; // size = 0x1E4 extern const ActorInit Obj_Bigicicle_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.c b/src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.c index 0d937d1c06..2d3a6f2d54 100644 --- a/src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.c +++ b/src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.c @@ -5,6 +5,7 @@ */ #include "z_obj_blockstop.h" +#include "overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.h" #define FLAGS (ACTOR_FLAG_10) @@ -13,9 +14,9 @@ void ObjBlockstop_Init(Actor* thisx, GlobalContext* globalCtx); void ObjBlockstop_Update(Actor* thisx, GlobalContext* globalCtx); -void func_809466F0(ObjBlockstop* this, GlobalContext* globalCtx); +void ObjBlockstop_CheckForBlock(ObjBlockstop* this, GlobalContext* globalCtx); +void ObjBlockstop_TryPlayCutscene(ObjBlockstop* this, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Blockstop_InitVars = { ACTOR_OBJ_BLOCKSTOP, ACTORCAT_PROP, @@ -28,12 +29,47 @@ const ActorInit Obj_Blockstop_InitVars = { (ActorFunc)NULL, }; -#endif +void ObjBlockstop_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjBlockstop* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Blockstop/ObjBlockstop_Init.s") + if (Flags_GetSwitch(globalCtx, this->actor.params)) { + Actor_MarkForDeath(&this->actor); + } + this->actionFunc = ObjBlockstop_CheckForBlock; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Blockstop/func_809466F0.s") +void ObjBlockstop_CheckForBlock(ObjBlockstop* this, GlobalContext* globalCtx) { + Actor* prop = globalCtx->actorCtx.actorLists[ACTORCAT_PROP].first; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Blockstop/func_809467E8.s") + while (prop != NULL) { + if ((prop->id == ACTOR_OBJ_OSHIHIKI) && (fabsf(prop->world.pos.x - this->actor.world.pos.x) < 20.0f) && + (fabsf(prop->world.pos.z - this->actor.world.pos.z) < 20.0f) && + (fabsf(prop->world.pos.y - this->actor.world.pos.y) < 20.0f)) { -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Blockstop/ObjBlockstop_Update.s") + s32 params = OBJOSHIHIKI_GET_F(prop); + if (params < 3) { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + this->actionFunc = ObjBlockstop_TryPlayCutscene; + } + } + prop = prop->next; + } +} + +void ObjBlockstop_TryPlayCutscene(ObjBlockstop* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + Flags_SetSwitch(globalCtx, this->actor.params); + if (ActorCutscene_GetLength(this->actor.cutscene) != -1) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + } + Actor_MarkForDeath(&this->actor); + return; + } + ActorCutscene_SetIntentToPlay(this->actor.cutscene); +} + +void ObjBlockstop_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjBlockstop* this = THIS; + + this->actionFunc(this, globalCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c b/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c index 465c660c69..8a822bea4b 100644 --- a/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c +++ b/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c @@ -2,23 +2,32 @@ * File: z_obj_chan.c * Overlay: ovl_Obj_Chan * Description: Goron Shrine chandelier + * + * This actor class is used for both the chandelier and its sub-components. + * The distinction is made using the subtype actor parameter: + * - 0 for the chandelier itself + * - 1 for one of the 5 breakable pots that are attached to the chandelier */ #include "z_obj_chan.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_obj_chan/object_obj_chan.h" +#include "objects/object_tsubo/object_tsubo.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjChan*)thisx) +#define OBJCHAN_ROTATION_SPEED 364 // == (65536 * 2/360) i.e. 2 degrees per second + void ObjChan_Init(Actor* thisx, GlobalContext* globalCtx); void ObjChan_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjChan_Update(Actor* thisx, GlobalContext* globalCtx); void ObjChan_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80BB9F24(ObjChan* this, GlobalContext* globalCtx); -void func_80BBA314(ObjChan* this, GlobalContext* globalCtx); +void ObjChan_ChandelierAction(ObjChan* this, GlobalContext* globalCtx); +void ObjChan_PotAction(ObjChan* this, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Chan_InitVars = { ACTOR_OBJ_CHAN, ACTORCAT_BG, @@ -31,49 +40,399 @@ const ActorInit Obj_Chan_InitVars = { (ActorFunc)ObjChan_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BBAB30 = { - { COLTYPE_HARD, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderCylinderInit sObjChanCylinderInit = { + { + COLTYPE_HARD, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 48, 76, -60, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80BBAB5C[] = { +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#endif +void ObjChan_InitChandelier(ObjChan* this2, GlobalContext* globalCtx); +void ObjChan_InitPot(ObjChan* this, GlobalContext* globalCtx); +void ObjChan_CreateSmashParticles(ObjChan* this, GlobalContext* globalCtx); +void ObjChan_DrawPot(Actor* thisx, GlobalContext* globalCtx); +void ObjChan_DrawFire(ObjChan* this, GlobalContext* globalCtx); -extern ColliderCylinderInit D_80BBAB30; -extern InitChainEntry D_80BBAB5C[]; +static Vec3f sObjChanFlameSize[2] = { + { 0.16f, 0.11f, 1.0f }, + { 0.13f, 0.09f, 1.0f }, +}; +static f32 sObjChanFlameYOffset[2] = { 1800, 1800 }; +static s32 sObjChanLoaded; -extern UNK_TYPE D_06000AF0; -extern UNK_TYPE D_06001960; -extern UNK_TYPE D_06002358; +void ObjChan_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjChan* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chan/ObjChan_Init.s") + if (OBJCHAN_SUBTYPE(&this->actor) == OBJCHAN_SUBTYPE_CHANDELIER) { + if (sObjChanLoaded) { + Actor_MarkForDeath(&this->actor); + return; + } + this->actor.room = -1; + sObjChanLoaded = true; + } + Actor_ProcessInitChain(&this->actor, sInitChain); + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sObjChanCylinderInit); + SubS_FillCutscenesList(&this->actor, this->cutscenes, ARRAY_COUNT(this->cutscenes)); + switch (OBJCHAN_SUBTYPE(&this->actor)) { + case OBJCHAN_SUBTYPE_CHANDELIER: + this->rotation = this->actor.shape.rot.y; + this->actor.shape.rot.y = 0; + ObjChan_InitChandelier(this, globalCtx); + break; + case OBJCHAN_SUBTYPE_POT: + this->actor.draw = ObjChan_DrawPot; + ObjChan_InitPot(this, globalCtx); + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chan/ObjChan_Destroy.s") +void ObjChan_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjChan* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chan/func_80BB9A1C.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chan/func_80BB9B40.s") +u32 func_80BB9A1C(ObjChan* this, f32 arg1) { + f32 temp_f6; + f32 sp20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chan/func_80BB9C08.s") + sp20 = Math_SinS(this->unk1D4) * this->unk1D0; + temp_f6 = (Math_CosS(this->unk1D4) * 0.03834952f * this->unk1D0) + arg1; + if (temp_f6 != 0.0f) { + this->unk1D4 = RADF_TO_BINANG(func_80086B30(sp20 * 0.03834952f, temp_f6)); + } else if (sp20 >= 0.0f) { + this->unk1D4 = 0x4000; + } else { + this->unk1D4 = -0x4000; + } + if (Math_CosS(this->unk1D4) != 0.0f) { + this->unk1D0 = (temp_f6 / (Math_CosS(this->unk1D4) * 0.03834952f)); + } else { + this->unk1D0 = sp20; + } + return 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chan/func_80BB9F24.s") +void ObjChan_CalculatePotPosition(Vec3f* childPosOut, Vec3s* childRotOut, Vec3f* parentPos, Vec3s* parentRot, + s16 childAngle) { + Vec3f offset; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chan/func_80BBA2FC.s") + Matrix_RotateY(parentRot->y, MTXMODE_NEW); + Matrix_InsertXRotation_s(parentRot->x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(parentRot->z, MTXMODE_APPLY); + Matrix_RotateY(childAngle, MTXMODE_APPLY); + Matrix_GetStateTranslationAndScaledX(-280.0f, &offset); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chan/func_80BBA314.s") + childPosOut->x = parentPos->x + offset.x; + childPosOut->y = parentPos->y + offset.y; + childPosOut->z = parentPos->z + offset.z; + Math_Vec3s_Copy(childRotOut, parentRot); + childRotOut->y += childAngle; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chan/func_80BBA488.s") +//! @TODO: Possibly takes actor and recasts +void ObjChan_InitChandelier(ObjChan* this2, GlobalContext* globalCtx) { + ObjChan* this = this2; + s32 i; + ObjChan* temp_v0; + Vec3f childPos; + Vec3s childRot; + CollisionPoly* sp94; + s32 sp90; + Vec3f sp84; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chan/ObjChan_Update.s") + Math_Vec3f_Copy(&this->unk1C0, &this->actor.world.pos); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chan/ObjChan_Draw.s") + Math_Vec3f_Copy(&sp84, &this->actor.world.pos); + sp84.y += 1600.0f; + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &sp84, &this->unk1C0, &sp94, false, false, + true, true, &sp90)) { + this->unk1CC = this->actor.world.pos.y - this->unk1C0.y; + } else { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chan/func_80BBA894.s") + for (i = 0; i < 5; i++) { + ObjChan_CalculatePotPosition(&childPos, &childRot, &this->actor.world.pos, &this->actor.shape.rot, + (s32)(i * 360.0f / 5.0f * (65536.0f / 360.0f)) + this->rotation); + temp_v0 = (ObjChan*)Actor_SpawnAsChildAndCutscene( + &globalCtx->actorCtx, globalCtx, ACTOR_OBJ_CHAN, childPos.x, childPos.y, childPos.z, childRot.x, childRot.y, + childRot.z, (this->actor.params & 0xFFF) | 0x1000, this->actor.cutscene, this->actor.unk20, &this->actor); + if (temp_v0 != NULL) { + this->pots[i] = temp_v0; + temp_v0->myPotIndex = i; + temp_v0->actor.cutscene = this->actor.cutscene; + } else { + Actor_MarkForDeath(&this->actor); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chan/func_80BBA930.s") + if (Flags_GetSwitch(globalCtx, this->actor.params & 0x7F)) { + this->stateFlags |= OBJCHAN_STATE_FIRE_DELAY; + this->stateFlags |= OBJCHAN_STATE_ON_FIRE; + + this->rotationSpeed = OBJCHAN_ROTATION_SPEED; + this->flameSize = 1.0f; + + for (i = 0; i < 5; i++) { + if (this->pots[i] != NULL) { + this->pots[i]->stateFlags |= OBJCHAN_STATE_FIRE_DELAY; + this->pots[i]->stateFlags |= OBJCHAN_STATE_ON_FIRE; + this->pots[i]->flameSize = 1.0f; + } + } + } + this->collider.dim.radius = 45; + this->collider.dim.height = 60; + this->collider.dim.yShift = -20; + this->actionFunc = ObjChan_ChandelierAction; +} + +//! @TODO: More descriptive name than Action? +void ObjChan_ChandelierAction(ObjChan* this2, GlobalContext* globalCtx) { + ObjChan* this = this2; + ObjChan* temp; + s32 i; + Vec3f sp60; + Vec3s sp58; + + if (this->unk1D0 > 0.0f) { + this->unk1D4 += 0x190; + if (this->unk1D0 <= 400.0f) { + this->unk1D0 = this->unk1D0 * 0.99f; + } else { + this->unk1D0 = this->unk1D0 - 1.0f; + } + if (this->unk1D0 < 0.0f) { + this->unk1D4 = 0; + this->unk1D0 = 0.0f; + } + } + this->actor.shape.rot.z = (Math_SinS(this->unk1D4) * this->unk1D0); + if ((this->stateFlags & OBJCHAN_STATE_START_CUTSCENE) && + SubS_StartActorCutscene(&this->actor, this->cutscenes[0], -1, 0)) { + this->stateFlags |= OBJCHAN_STATE_CUTSCENE; + this->stateFlags &= ~OBJCHAN_STATE_START_CUTSCENE; + } + if ((this->stateFlags & OBJCHAN_STATE_CUTSCENE) && this->rotationSpeed == OBJCHAN_ROTATION_SPEED) { + this->stateFlags &= ~OBJCHAN_STATE_CUTSCENE; + ActorCutscene_Stop(this->cutscenes[0]); + } + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_InsertXRotation_s(this->actor.shape.rot.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_RotateY(this->rotation, MTXMODE_APPLY); + Matrix_GetStateTranslationAndScaledY(this->unk1CC, &this->actor.world.pos); + Math_Vec3f_Sum(&this->actor.world.pos, &this->unk1C0, &this->actor.world.pos); + Collider_UpdateCylinder(&this->actor, &this->collider); + for (i = 0; i < 5; i++) { + temp = this->pots[i]; + if (temp != NULL) { + ObjChan_CalculatePotPosition(&sp60, &sp58, &this->actor.world.pos, &this->actor.shape.rot, + (s32)(i * 360.0f / 5.0f * (65536.0f / 360.0f)) + this->rotation); + Math_Vec3f_Copy(&temp->actor.world.pos, &sp60); + Math_Vec3s_Copy(&temp->actor.shape.rot, &this->actor.shape.rot); + temp->actor.shape.rot.y = this->rotation; + Math_Vec3f_ToVec3s(&temp->collider.dim.pos, &temp->actor.world.pos); + } + } + if ((this->collider.base.acFlags & AC_HIT) && (this->collider.info.acHitInfo->toucher.dmgFlags & 0x800)) { + Flags_SetSwitch(globalCtx, this->actor.params & 0x7F); + } + if (Flags_GetSwitch(globalCtx, this->actor.params & 0x7F)) { + if (!(this->stateFlags & OBJCHAN_STATE_FIRE_DELAY)) { + this->rotationSpeed = 0; + this->flameSize = 0.0f; + for (i = 0; i < 5; i++) { + temp = this->pots[i]; + if (temp != NULL) { + this->pots[i]->stateFlags |= OBJCHAN_STATE_FIRE_DELAY; + this->pots[i]->fireDelayFrames = 20 + i * 5; + this->pots[i]->flameSize = 0.0f; + } + } + this->stateFlags |= OBJCHAN_STATE_FIRE_DELAY; + this->stateFlags |= OBJCHAN_STATE_ON_FIRE; + this->stateFlags |= OBJCHAN_STATE_START_CUTSCENE; + } else { + Math_StepToF(&this->flameSize, 1.0f, 0.05f); + this->rotation += this->rotationSpeed; + Math_StepToS(&this->rotationSpeed, OBJCHAN_ROTATION_SPEED, 5); + func_800B9010(&this->actor, NA_SE_EV_CHANDELIER_ROLL - SFX_FLAG); + } + } +} + +void ObjChan_InitPot(ObjChan* this, GlobalContext* globalCtx) { + this->actionFunc = ObjChan_PotAction; +} + +void ObjChan_PotAction(ObjChan* this, GlobalContext* globalCtx) { + s32 potBreaks; + s16 temp_v0_2; + s32 phi_v1; + + potBreaks = false; + if ((this->collider.base.acFlags & AC_HIT) && (this->collider.info.acHitInfo->toucher.dmgFlags & 0x4004000)) { + potBreaks = true; + } + if (this->stateFlags & OBJCHAN_STATE_ON_FIRE) { + Math_StepToF(&this->flameSize, 1.0f, 0.05f); + } else if (this->stateFlags & OBJCHAN_STATE_FIRE_DELAY) { + this->fireDelayFrames--; + if (this->fireDelayFrames <= 0) { + this->stateFlags |= OBJCHAN_STATE_ON_FIRE; + } + } + if (potBreaks) { + ObjChan_CreateSmashParticles(this, globalCtx); + ((ObjChan*)this->actor.parent)->pots[this->myPotIndex] = NULL; + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_CHANDELIER_BROKEN); + func_80BB9A1C((ObjChan*)this->actor.parent, 40.0f); + if (this->myPotIndex == 4) { + temp_v0_2 = gSaveContext.save.weekEventReg[0x25]; + if (!(temp_v0_2 & 0x10)) { + gSaveContext.save.weekEventReg[0x25] = temp_v0_2 | 0x10; + Actor_SpawnAsChildAndCutscene(&globalCtx->actorCtx, globalCtx, ACTOR_EN_MM, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0x8000, + this->actor.cutscene, this->actor.unk20, NULL); + } + } + Actor_MarkForDeath(&this->actor); + } +} + +void ObjChan_CreateSmashParticles(ObjChan* this, GlobalContext* globalCtx) { + s16 new_var = 0; + s32 phi_s0; + Vec3f spDC; + Vec3f spD0; + f32 temp_f0; + f32 new_var2; + s16 temp_s1 = 0; + s32 temp_s2; + f32 spAC; + f32 spA8 = new_var + 15.0f; + f32 spA4 = new_var + (spAC = 110.0f); + + for (temp_s2 = 0, temp_s1 = 0; temp_s2 != 18; temp_s2++, temp_s1 += 0x4E20) { + f32 sin = Math_SinS(temp_s1); + f32 cos = Math_CosS(temp_s1); + spDC.x = sin * 8.0f; + spDC.y = Rand_ZeroOne() * 12.0f + 2.0f; + spDC.z = cos * 8.0f; + spD0.x = spDC.x * 0.23f; + spD0.y = Rand_ZeroOne() * 5.0f + 2.5f; + spD0.z = spDC.z * 0.23f; + temp_f0 = Rand_ZeroOne(); + if (temp_f0 < 0.2f) { + phi_s0 = 0x60; + } else if (temp_f0 < 0.6f) { + phi_s0 = 0x40; + } else { + phi_s0 = 0x20; + } + new_var2 = spA4 * Rand_ZeroOne(); + EffectSsKakera_Spawn(globalCtx, &spDC, &spD0, &this->actor.world.pos, -260, phi_s0, 20, 0, 0, spA8 + new_var2, + 0, 0, 50, -1, OBJECT_TSUBO, object_tsubo_DL_001960); + } + func_800BBFB0(globalCtx, &this->actor.world.pos, 30.0f, 2, 20, 50, true); + func_800BBFB0(globalCtx, &this->actor.world.pos, 30.0f, 2, 10, 80, true); +} + +void ObjChan_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjChan* this = THIS; + + this->actionFunc(this, globalCtx); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +void ObjChan_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjChan* this = THIS; + Gfx* opa; + Gfx* xlu; + + OPEN_DISPS(globalCtx->state.gfxCtx); + Matrix_RotateY(this->rotation, MTXMODE_APPLY); + + opa = Gfx_CallSetupDL(POLY_OPA_DISP, 0x19); + gSPMatrix(&opa[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_LOAD); + gSPDisplayList(&opa[1], object_obj_chan_DL_000AF0); + POLY_OPA_DISP = &opa[2]; + + xlu = func_8012C2B4(POLY_XLU_DISP); + gSPMatrix(&xlu[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_LOAD); + gSPDisplayList(&xlu[1], object_obj_chan_DL_000A10); + POLY_XLU_DISP = &xlu[2]; + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + Matrix_StatePush(); + if (this->stateFlags & OBJCHAN_STATE_ON_FIRE) { + ObjChan_DrawFire(this, globalCtx); + } + Matrix_StatePop(); +} + +void ObjChan_DrawPot(Actor* thisx, GlobalContext* globalCtx) { + ObjChan* this = THIS; + s32 pad; + Gfx* dl; + + OPEN_DISPS(globalCtx->state.gfxCtx); + dl = Gfx_CallSetupDL(POLY_OPA_DISP, 0x19); + gSPMatrix(&dl[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_LOAD); + gSPDisplayList(&dl[1], object_obj_chan_DL_002358); + POLY_OPA_DISP = &dl[2]; + CLOSE_DISPS(globalCtx->state.gfxCtx); + + if (this->stateFlags & OBJCHAN_STATE_ON_FIRE) { + ObjChan_DrawFire(this, globalCtx); + } +} + +void ObjChan_DrawFire(ObjChan* this, GlobalContext* globalCtx) { + u32 sp4C; + Gfx* dl; + OPEN_DISPS(globalCtx->state.gfxCtx); + + sp4C = globalCtx->gameplayFrames; + + Matrix_RotateY(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - this->actor.shape.rot.y - this->rotation + 0x8000, + MTXMODE_APPLY); + Matrix_Scale(sObjChanFlameSize[OBJCHAN_SUBTYPE(&this->actor)].x * this->flameSize, + sObjChanFlameSize[OBJCHAN_SUBTYPE(&this->actor)].y * this->flameSize, 1.0f, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, sObjChanFlameYOffset[OBJCHAN_SUBTYPE(&this->actor)], 0.0f, MTXMODE_APPLY); + + dl = func_8012C2B4(POLY_XLU_DISP); + gSPMatrix(&dl[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_LOAD); + gMoveWd(&dl[1], 6, 32, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0U, -sp4C * 20, 32, 128)); + gDPSetPrimColor(&dl[2], 128, 128, 255, 255, 0, 255); + gDPSetEnvColor(&dl[3], 255, 0, 0, 0); + gSPDisplayList(&dl[4], &gGameplayKeepDrawFlameDL); + POLY_XLU_DISP = &dl[5]; + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.h b/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.h index 8b498f39e5..2b11335b3f 100644 --- a/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.h +++ b/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.h @@ -5,12 +5,56 @@ struct ObjChan; +#define OBJCHAN_SUBTYPE(thisx) (((thisx)->params >> 12) & 0xF) +#define OBJCHAN_SUBTYPE_CHANDELIER 0 +#define OBJCHAN_SUBTYPE_POT 1 + +/*** stateFlags ***/ +/* + * After the chandelier is hit by a fire attack, each pot gets OBJCHAN_STATE_FIRE_DELAY state and counts down a number of frames until it catches fire. + * The delay is different for each pot. Remaining frame count is stored in fireDelayFrames. + * The main actor also gets this flag but it's always equivalent to OBJCHAN_STATE_ON_FIRE. + */ +#define OBJCHAN_STATE_FIRE_DELAY (1 << 0) +/** + * Pot is now on fire. After this state is set the flame grows to full size over 20 frames. Flame size is stored in flameSize. + * OBJCHAN_STATE_FIRE_DELAY is not cleared when this flag is set. + * The main actor also gets this flag. + */ +#define OBJCHAN_STATE_ON_FIRE (1 << 1) // Pot has fire. Flame grows to full size over about 1 second. Flame size is stored in fireSize. +/** + * Only for the main actor. + * Once set, the actor tries to start a cutscene. + * Once cutscene is started, this flag is unset and OBJCHAN_STATE_MAIN_STOP_CUTSCENE_AT_FULL_SPEED is set. + */ +#define OBJCHAN_STATE_START_CUTSCENE (1 << 2) +/** + * Only for the main actor. + * Cutscene is running. Once set, the actor waits for full rotation speed and then cancels the cutscene. + */ +#define OBJCHAN_STATE_CUTSCENE (1 << 3) + + + typedef void (*ObjChanActionFunc)(struct ObjChan*, GlobalContext*); typedef struct ObjChan { /* 0x0000 */ Actor actor; /* 0x0144 */ ObjChanActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x9C]; + /* 0x0148 */ ColliderCylinder collider; + /* 0x0194 */ u8 myPotIndex; // For OBJCHAN_SUBTYPE_POT: which pot is this? + /* 0x0196 */ s16 fireDelayFrames; + /* 0x0198 */ UNK_TYPE1 unk198[0x12]; + /* 0x01AA */ u8 stateFlags; + /* 0x01AC */ struct ObjChan* pots[5]; // For OBJCHAN_SUBTYPE_BODY: pointers to pot actors + /* 0x01C0 */ Vec3f unk1C0; + /* 0x01CC */ f32 unk1CC; + /* 0x01D0 */ f32 unk1D0; + /* 0x01D4 */ s16 unk1D4; + /* 0x01D8 */ f32 flameSize; + /* 0x01DC */ s16 rotationSpeed; // Main object only. Slowly ramps up under some circumstances. In other circumstances it's immediately set to maximum speed. + /* 0x01DE */ s16 rotation; // Increases as the chandelier spins. Don't know why they didn't use the actor's rotation variable. + /* 0x01E0 */ s16 cutscenes[2]; } ObjChan; // size = 0x1E4 extern const ActorInit Obj_Chan_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c b/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c index f406340448..573b34fdc5 100644 --- a/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c +++ b/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c @@ -334,7 +334,7 @@ void ObjComb_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->actor, sInitChain); Collider_InitJntSph(globalCtx, &this->collider); - if ((sp2C == 1) && OBJCOMB_GET_10(&this->actor) && (gSaveContext.weekEventReg[83] & 2)) { + if ((sp2C == 1) && OBJCOMB_GET_10(&this->actor) && (gSaveContext.save.weekEventReg[83] & 2)) { Actor_MarkForDeath(&this->actor); return; } @@ -531,7 +531,7 @@ void ObjComb_Update(Actor* thisx, GlobalContext* globalCtx) { if (((OBJCOMB_GET_8000(&this->actor) | OBJCOMB_GET_80(&this->actor)) == 1) && OBJCOMB_GET_10(&this->actor)) { - gSaveContext.weekEventReg[83] |= 2; + gSaveContext.save.weekEventReg[83] |= 2; } this->unk_1B5 = 2; diff --git a/src/overlays/actors/ovl_Obj_Dinner/z_obj_dinner.c b/src/overlays/actors/ovl_Obj_Dinner/z_obj_dinner.c index 03e73043fb..57f9d75505 100644 --- a/src/overlays/actors/ovl_Obj_Dinner/z_obj_dinner.c +++ b/src/overlays/actors/ovl_Obj_Dinner/z_obj_dinner.c @@ -31,7 +31,7 @@ const ActorInit Obj_Dinner_InitVars = { void ObjDinner_Init(Actor* thisx, GlobalContext* globalCtx) { ObjDinner* this = THIS; - if (gSaveContext.isNight != true || (CURRENT_DAY == 3 && gSaveContext.weekEventReg[22] & 1)) { + if (gSaveContext.save.isNight != true || (CURRENT_DAY == 3 && gSaveContext.save.weekEventReg[22] & 1)) { Actor_MarkForDeath(&this->actor); } Actor_SetScale(&this->actor, 0.1f); diff --git a/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.c b/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.c index 1d77cc2578..a1d149f3d1 100644 --- a/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.c +++ b/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.c @@ -5,6 +5,7 @@ */ #include "z_obj_dora.h" +#include "assets/objects/object_dora/object_dora.h" #define FLAGS (ACTOR_FLAG_10) @@ -15,7 +16,25 @@ void ObjDora_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjDora_Update(Actor* thisx, GlobalContext* globalCtx); void ObjDora_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void ObjDora_SetupWait(ObjDora* this); +void ObjDora_Wait(ObjDora* this, GlobalContext* globalCtx); +void ObjDora_SetupMoveGong(ObjDora* this); +void ObjDora_MoveGong(ObjDora* this, GlobalContext* globalCtx); +s32 ObjDora_IsHalfHour(u16 time); +void ObjDora_UpdateCollision(ObjDora* this, GlobalContext* globalCtx); + +typedef enum { + /* 0x0 */ DORA_HIT_NONE, + /* 0x1 */ DORA_HIT_LIGHT, + /* 0x2 */ DORA_HIT_STRONG +} ObjDoraHitStrength; + +typedef enum { + /* 0x0 */ DORA_DMGEFF_NONE, + /* 0xE */ DORA_DMGEFF_STRONG = 0xE, + /* 0xF */ DORA_DMGEFF_LIGHT +} ObjDoraDamageEffect; + const ActorInit Obj_Dora_InitVars = { ACTOR_OBJ_DORA, ACTORCAT_NPC, @@ -28,104 +47,306 @@ const ActorInit Obj_Dora_InitVars = { (ActorFunc)ObjDora_Draw, }; -// static ColliderTrisElementInit sTrisElementsInit[6] = { -static ColliderTrisElementInit D_80B61310[6] = { +static ColliderTrisElementInit sTrisElementsInit[6] = { { - { ELEMTYPE_UNK5, { 0x00000000, 0x00, 0x00 }, { 0x00100000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK5, + { 0x00000000, 0x00, 0x00 }, + { 0x00100000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 0.0f, -35.0f, 0.0f }, { 260.0f, -185.0f, 0.0f }, { 0.0f, -335.0f, 0.0f } } }, }, { - { ELEMTYPE_UNK5, { 0x00000000, 0x00, 0x00 }, { 0x00100000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK5, + { 0x00000000, 0x00, 0x00 }, + { 0x00100000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 260.0f, -185.0f, 0.0f }, { 260.0f, -485.0f, 0.0f }, { 0.0f, -335.0f, 0.0f } } }, }, { - { ELEMTYPE_UNK5, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK5, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 260.0f, -485.0f, 0.0f }, { 0.0f, -635.0f, 0.0f }, { 0.0f, -335.0f, 0.0f } } }, }, { - { ELEMTYPE_UNK5, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK5, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 0.0f, -635.0f, 0.0f }, { -260.0f, -485.0f, 0.0f }, { 0.0f, -335.0f, 0.0f } } }, }, { - { ELEMTYPE_UNK5, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK5, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { -260.0f, -485.0f, 0.0f }, { -260.0f, -185.0f, 0.0f }, { 0.0f, -335.0f, 0.0f } } }, }, { - { ELEMTYPE_UNK5, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK5, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { -260.0f, -185.0f, 0.0f }, { 0.0f, -35.0f, 0.0f }, { 0.0f, -335.0f, 0.0f } } }, }, }; -// static ColliderTrisInit sTrisInit = { -static ColliderTrisInit D_80B61478 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_TRIS, }, - 6, D_80B61310, // sTrisElementsInit, +static ColliderTrisInit sTrisInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_TRIS, + }, + 6, + sTrisElementsInit, }; -// static DamageTable sDamageTable = { -static DamageTable D_80B61488 = { - /* Deku Nut */ DMG_ENTRY(0, 0x0), - /* Deku Stick */ DMG_ENTRY(2, 0xF), - /* Horse trample */ DMG_ENTRY(0, 0x0), - /* Explosives */ DMG_ENTRY(0, 0x0), - /* Zora boomerang */ DMG_ENTRY(0, 0xF), - /* Normal arrow */ DMG_ENTRY(0, 0xF), - /* UNK_DMG_0x06 */ DMG_ENTRY(2, 0xF), - /* Hookshot */ DMG_ENTRY(0, 0xF), - /* Goron punch */ DMG_ENTRY(2, 0xE), - /* Sword */ DMG_ENTRY(1, 0xF), - /* Goron pound */ DMG_ENTRY(1, 0xF), - /* Fire arrow */ DMG_ENTRY(0, 0xF), - /* Ice arrow */ DMG_ENTRY(0, 0xF), - /* Light arrow */ DMG_ENTRY(0, 0xF), - /* Goron spikes */ DMG_ENTRY(1, 0xF), - /* Deku spin */ DMG_ENTRY(0, 0xF), - /* Deku bubble */ DMG_ENTRY(0, 0x0), - /* Deku launch */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0x0), - /* Zora barrier */ DMG_ENTRY(0, 0x0), - /* Normal shield */ DMG_ENTRY(0, 0x0), - /* Light ray */ DMG_ENTRY(0, 0x0), - /* Thrown object */ DMG_ENTRY(1, 0xF), - /* Zora punch */ DMG_ENTRY(0, 0xF), - /* Spin attack */ DMG_ENTRY(1, 0x0), - /* Sword beam */ DMG_ENTRY(0, 0x0), - /* Normal Roll */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0x0), - /* Powder Keg */ DMG_ENTRY(0, 0x0), +static DamageTable sDamageTable = { + /* Deku Nut */ DMG_ENTRY(0, DORA_DMGEFF_NONE), + /* Deku Stick */ DMG_ENTRY(2, DORA_DMGEFF_LIGHT), + /* Horse trample */ DMG_ENTRY(0, DORA_DMGEFF_NONE), + /* Explosives */ DMG_ENTRY(0, DORA_DMGEFF_NONE), + /* Zora boomerang */ DMG_ENTRY(0, DORA_DMGEFF_LIGHT), + /* Normal arrow */ DMG_ENTRY(0, DORA_DMGEFF_LIGHT), + /* UNK_DMG_0x06 */ DMG_ENTRY(2, DORA_DMGEFF_LIGHT), + /* Hookshot */ DMG_ENTRY(0, DORA_DMGEFF_LIGHT), + /* Goron punch */ DMG_ENTRY(2, DORA_DMGEFF_STRONG), + /* Sword */ DMG_ENTRY(1, DORA_DMGEFF_LIGHT), + /* Goron pound */ DMG_ENTRY(1, DORA_DMGEFF_LIGHT), + /* Fire arrow */ DMG_ENTRY(0, DORA_DMGEFF_LIGHT), + /* Ice arrow */ DMG_ENTRY(0, DORA_DMGEFF_LIGHT), + /* Light arrow */ DMG_ENTRY(0, DORA_DMGEFF_LIGHT), + /* Goron spikes */ DMG_ENTRY(1, DORA_DMGEFF_LIGHT), + /* Deku spin */ DMG_ENTRY(0, DORA_DMGEFF_LIGHT), + /* Deku bubble */ DMG_ENTRY(0, DORA_DMGEFF_NONE), + /* Deku launch */ DMG_ENTRY(0, DORA_DMGEFF_NONE), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, DORA_DMGEFF_NONE), + /* Zora barrier */ DMG_ENTRY(0, DORA_DMGEFF_NONE), + /* Normal shield */ DMG_ENTRY(0, DORA_DMGEFF_NONE), + /* Light ray */ DMG_ENTRY(0, DORA_DMGEFF_NONE), + /* Thrown object */ DMG_ENTRY(1, DORA_DMGEFF_LIGHT), + /* Zora punch */ DMG_ENTRY(0, DORA_DMGEFF_LIGHT), + /* Spin attack */ DMG_ENTRY(1, DORA_DMGEFF_NONE), + /* Sword beam */ DMG_ENTRY(0, DORA_DMGEFF_NONE), + /* Normal Roll */ DMG_ENTRY(0, DORA_DMGEFF_NONE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, DORA_DMGEFF_NONE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, DORA_DMGEFF_NONE), + /* Unblockable */ DMG_ENTRY(0, DORA_DMGEFF_NONE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, DORA_DMGEFF_NONE), + /* Powder Keg */ DMG_ENTRY(0, DORA_DMGEFF_NONE), }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80B614A8 = { 8, 0, 0, 0, MASS_HEAVY }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 8, 0, 0, 0, MASS_HEAVY }; -#endif +void ObjDora_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjDora* this = THIS; + s32 i; + s32 j; + Vec3f vtx[3]; + s32 buf = 0; + s32 buff2 = 0; -extern ColliderTrisElementInit D_80B61310[6]; -extern ColliderTrisInit D_80B61478; -extern DamageTable D_80B61488; -extern CollisionCheckInfoInit2 D_80B614A8; + Actor_SetScale(&this->actor, 0.1f); + ActorShape_Init(&this->actor.shape, 0.0f, &ActorShadow_DrawCircle, 36.0f); -extern UNK_TYPE D_06004160; + this->gongRotation.x = 0; + this->gongRotation.z = 0; + this->gongAngle.x = 0; + this->gongAngle.z = 0; + this->lastGongHitType = DORA_HIT_NONE; + this->rupeeDropTimer = 0; + this->collisionCooldownTimer = 0; + this->unk3AA = 0; + this->gongForce.x = 0.0f; + this->gongForce.y = 0.0f; + this->gongForce.z = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dora/ObjDora_Init.s") + Collider_InitTris(globalCtx, &this->colliderTris); + Collider_SetTris(globalCtx, &this->colliderTris, &this->actor, &sTrisInit, this->colliderTrisElements); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dora/ObjDora_Destroy.s") + Matrix_SetStateRotationAndTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + &this->actor.shape.rot); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dora/func_80B60C9C.s") + for (i = 0; i < ARRAY_COUNT(this->colliderTrisElements); i++) { + for (j = 0; j < ARRAY_COUNT(vtx); j++) { + Matrix_MultiplyVector3fByState(&sTrisElementsInit[i].dim.vtx[j], &vtx[j]); + } + Collider_SetTrisVertices(&this->colliderTris, i, &vtx[0], &vtx[1], &vtx[2]); + } + ObjDora_SetupWait(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dora/func_80B60CB0.s") +void ObjDora_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjDora* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dora/func_80B60CC0.s") + Collider_DestroyTris(globalCtx, &this->colliderTris); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dora/func_80B60D34.s") +void ObjDora_SetupWait(ObjDora* this) { + this->actionFunc = ObjDora_Wait; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dora/func_80B60E54.s") +void ObjDora_Wait(ObjDora* this, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dora/func_80B60EE8.s") +void ObjDora_SetupMoveGong(ObjDora* this) { + if (this->lastGongHitType == DORA_HIT_LIGHT) { + this->gongForce.x = 2.0f; + this->gongForce.y = 5461.0f; + this->gongForce.z = 1820.0f; + } else { + this->gongForce.x = 4.0f; + this->gongForce.y = 12743.0f; + this->gongForce.z = 5461.0f; + } + this->gongAngle.x = 0; + this->gongAngle.z = 0; + this->actionFunc = ObjDora_MoveGong; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dora/ObjDora_Update.s") +void ObjDora_MoveGong(ObjDora* this, GlobalContext* globalCtx) { -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dora/ObjDora_Draw.s") + if ((this->gongForce.y < 182.0f) && (this->gongForce.z < 182.0f)) { + this->lastGongHitType = DORA_HIT_LIGHT; + ObjDora_SetupWait(this); + } + + Math_SmoothStepToF(&this->gongForce.x, 0, 0.2f, 0.2f, 0.1f); + Math_SmoothStepToF(&this->gongForce.y, 0, 0.5f, 54.0f, 18.0f); + Math_SmoothStepToF(&this->gongForce.z, 0, 0.5f, 54.0f, 18.0f); + this->gongAngle.x += 0x1555; + this->gongAngle.z += 0x238E; + this->gongRotation.x = Math_SinS(this->gongAngle.x) * this->gongForce.y; + this->gongRotation.z = Math_SinS(this->gongAngle.z) * this->gongForce.z; +} + +s32 ObjDora_IsHalfHour(u16 time) { + f32 timeHalfHour = time; + + timeHalfHour -= (CLOCK_TIME_F(0, 30) * (s32)(time / CLOCK_TIME_F(0, 30))); + if ((timeHalfHour < CLOCK_TIME_F(0, 1)) || (CLOCK_TIME_F(0, 29) < timeHalfHour)) { + return true; + } + + return false; +} + +void ObjDora_UpdateCollision(ObjDora* this, GlobalContext* globalCtx) { + Actor* itemDrop; + u16 time; + + if (this->colliderTris.base.acFlags & AC_HIT) { + time = gSaveContext.save.time; + this->colliderTris.base.acFlags &= ~AC_HIT; + this->collisionCooldownTimer = 5; + + switch (this->actor.colChkInfo.damageEffect) { + case DORA_DMGEFF_STRONG: + case DORA_DMGEFF_LIGHT: + if (this->actor.colChkInfo.damageEffect == DORA_DMGEFF_LIGHT) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DORA_S); + this->lastGongHitType = DORA_HIT_LIGHT; + } else { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DORA_L); + this->lastGongHitType = DORA_HIT_STRONG; + } + + func_800BC848(&this->actor, globalCtx, 5, 10); + ObjDora_SetupMoveGong(this); + + if ((ObjDora_IsHalfHour(time) == true) && (this->rupeeDropTimer == 0)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); + itemDrop = Item_DropCollectible(globalCtx, &this->actor.world.pos, ITEM00_RUPEE_BLUE); + itemDrop->world.rot.y = this->actor.world.rot.y; + itemDrop->world.rot.y += (s32)(Rand_Centered() * 90.0f * (0x10000 / 360.0f)); + itemDrop->velocity.y = 5.0f; + itemDrop->gravity = -1.0f; + this->rupeeDropTimer = 40; + } + break; + } + } + + if (this->rupeeDropTimer > 0) { + this->rupeeDropTimer--; + } + + if (this->collisionCooldownTimer > 0) { + this->collisionCooldownTimer--; + } else { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderTris.base); + } +} + +void ObjDora_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjDora* this = THIS; + + this->actionFunc(this, globalCtx); + ObjDora_UpdateCollision(this, globalCtx); +} + +void ObjDora_Draw(Actor* thisx, GlobalContext* globalCtx) { + static Vec3f position = { 0.0f, -61.5f, 0.0f }; + ObjDora* this = THIS; + f32 gongForceX; + + OPEN_DISPS(globalCtx->state.gfxCtx); + func_8012C28C(globalCtx->state.gfxCtx); + + if (this->actionFunc == ObjDora_MoveGong) { + gongForceX = this->gongForce.x; + if ((globalCtx->state.frames % 2) != 0) { + gongForceX *= -1.0f; + } + + Matrix_StatePush(); + Matrix_InsertXRotation_s(this->gongRotation.x, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, &gDoraGongDL); + + Matrix_InsertTranslation(position.x, position.y + gongForceX, position.z + gongForceX, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->gongRotation.z - this->gongRotation.x, MTXMODE_APPLY); + Matrix_InsertTranslation(-position.x, -position.y, -position.z, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, &gDoraChainDL); + + Matrix_StatePop(); + } else { + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, &gDoraChainDL); + gSPDisplayList(POLY_OPA_DISP++, &gDoraGongDL); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.h b/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.h index a40405b34d..a2dbbea162 100644 --- a/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.h +++ b/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.h @@ -9,9 +9,16 @@ typedef void (*ObjDoraActionFunc)(struct ObjDora*, GlobalContext*); typedef struct ObjDora { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x248]; + /* 0x0144 */ ColliderTris colliderTris; + /* 0x0164 */ ColliderTrisElement colliderTrisElements[6]; /* 0x038C */ ObjDoraActionFunc actionFunc; - /* 0x0390 */ char unk_390[0x1C]; + /* 0x0390 */ Vec3f gongForce; + /* 0x039C */ Vec2s gongAngle; + /* 0x03A0 */ s16 lastGongHitType; + /* 0x03A2 */ Vec2s gongRotation; // gongAngle * gongForce. Used in ObjDora_Draw. + /* 0x03A6 */ s16 rupeeDropTimer; + /* 0x03A8 */ s16 collisionCooldownTimer; + /* 0x03AA */ s16 unk3AA; // Set but not used } ObjDora; // size = 0x3AC extern const ActorInit Obj_Dora_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.c b/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.c index f193fbbc15..660e68b6db 100644 --- a/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.c +++ b/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.c @@ -5,6 +5,7 @@ */ #include "z_obj_driftice.h" +#include "objects/object_driftice/object_driftice.h" #define FLAGS 0x00000000 @@ -15,7 +16,15 @@ void ObjDriftice_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjDriftice_Update(Actor* thisx, GlobalContext* globalCtx); void ObjDriftice_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80A671A8(ObjDriftice* this); +void func_80A671BC(ObjDriftice* this, GlobalContext* globalCtx); +void func_80A671CC(ObjDriftice* this); +void func_80A671E0(ObjDriftice* this, GlobalContext* globalCtx); +void func_80A6743C(ObjDriftice* this); +void func_80A67450(ObjDriftice* this, GlobalContext* globalCtx); +void func_80A674A8(ObjDriftice* this); +void func_80A674C4(ObjDriftice* this, GlobalContext* globalCtx); + const ActorInit Obj_Driftice_InitVars = { ACTOR_OBJ_DRIFTICE, ACTORCAT_BG, @@ -28,52 +37,431 @@ const ActorInit Obj_Driftice_InitVars = { (ActorFunc)ObjDriftice_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80A676F4[] = { +static f32 D_80A67620[][3] = { + { 1.0f, 150.0f, 150.0f }, + { 1.5f, 250.0f, 200.0f }, + { 2.0f, 350.0f, 250.0f }, +}; + +static f32 D_80A67644[] = { 1.5f, 3.0f, 4.5f, 6.0f, 7.5f, 9.0f, 10.5f, 0.0f }; + +static f32 D_80A67664[][4] = { + { 0.6f, 0.5f, 0.2f, 0.4f }, + { 0.8f, 0.7f, 0.35f, 0.7f }, + { 1.0f, 1.0f, 0.8f, 1.0f }, +}; + +typedef struct { + /* 0x0 */ s16 unk_00; + /* 0x2 */ s16 unk_02; + /* 0x4 */ f32 unk_04; + /* 0x8 */ f32 unk_08; +} ObjDrifticeDataStruct; // size = 0xC + +static ObjDrifticeDataStruct D_80A67694[] = { + { 0x12C, 0x64, 1.3f, 2.0f }, + { 0x258, 0x1F4, 1.2f, 1.8f }, + { 0x4B0, 0x3E8, 1.1f, 1.5f }, +}; + +static ObjDrifticeDataStruct D_80A676B8[] = { { 0x320, 0x190, 200.0f, 400.0f }, { 0x5DC, 0x258, 100.0f, 300.0f } }; + +static ObjDrifticeDataStruct D_80A676D0[] = { + { 0x12C, 0x64, 300.0f, 700.0f }, + { 0x258, 0x258, 200.0f, 400.0f }, + { 0x4B0, 0x4B0, 100.0f, 300.0f }, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_STOP), }; +void func_80A66570(ObjDriftice* this, s32 arg1) { + Math_Vec3s_ToVec3f(&this->dyna.actor.world.pos, &this->unk_16C[arg1]); +} + +void func_80A665AC(s16* arg0, s16 arg1) { + if (arg1 < *arg0) { + *arg0 = arg1; + } else if (*arg0 < -arg1) { + *arg0 = -arg1; + } +} + +f32 func_80A665EC(ObjDrifticeStruct* arg0, ObjDriftice* this) { + f32 phi_f2 = 0.0f; + f32 sp20; + + if (this->unk_248 >= 10) { + sp20 = -8.0f; + } else if (this->unk_248 < -9) { + sp20 = 0.0f; + } else if (this->unk_248 > 0) { + sp20 = (Math_CosS(fabsf(this->unk_248) * (0x8000 * 0.1f)) - 1.0f) * 4.0f; + } else { + sp20 = (Math_CosS(fabsf(this->unk_248) * (0x8000 * 0.1f)) + 1.0f) * -4.0f; + } + + if (this->unk_248 > 0) { + if (arg0->unk_00.unk_00 > 0) { + arg0->unk_00.unk_00--; + } else { + arg0->unk_00.unk_00 = Rand_S16Offset(30, 70); + arg0->unk_00.unk_04 = Rand_S16Offset(1000, 1000); + arg0->unk_00.unk_0C = (Rand_ZeroOne() * 1.5f) + 1.0f; + arg0->unk_00.unk_10 = fabsf(arg0->unk_00.unk_0C - arg0->unk_00.unk_08) * 0.05f; + } + } else { + arg0->unk_00.unk_00 = 0; + arg0->unk_00.unk_0C = phi_f2; + arg0->unk_00.unk_10 = (fabsf(arg0->unk_00.unk_0C - arg0->unk_00.unk_08) * 0.05f) + 0.02f; + } + + arg0->unk_00.unk_02 += arg0->unk_00.unk_04; + Math_StepToF(&arg0->unk_00.unk_08, arg0->unk_00.unk_0C, arg0->unk_00.unk_10); + + sp20 += (Math_SinS(arg0->unk_00.unk_02) * arg0->unk_00.unk_08); + return sp20; +} + +f32 func_80A667F0(ObjDrifticeStruct3* arg0, ObjDriftice* this) { + f32 temp_f20 = 0.0f; + ObjDrifticeStruct3* temp_s0; + s32 i; + + for (i = 0; i < 3; i++) { + temp_s0 = &arg0[i]; + + if (temp_s0->unk_00 > 0) { + temp_s0->unk_00--; + } else { + temp_s0->unk_00 = Rand_S16Offset(30, 70); + temp_s0->unk_04 = Rand_S16Offset(D_80A67694[i].unk_00, D_80A67694[i].unk_02); + temp_s0->unk_0C = D_80A67694[i].unk_04 + (D_80A67694[i].unk_08 * Rand_ZeroOne()); + temp_s0->unk_10 = fabsf(temp_s0->unk_0C - temp_s0->unk_08) * 0.05f; + } + temp_s0->unk_02 += temp_s0->unk_04; + Math_StepToF(&temp_s0->unk_08, temp_s0->unk_0C, temp_s0->unk_10); + temp_f20 += Math_SinS(temp_s0->unk_02) * temp_s0->unk_08; + } + + return temp_f20; +} + +#ifdef NON_MATCHING +void func_80A66930(ObjDrifticeStruct2* arg0, ObjDriftice* this, s16* arg2, s16* arg3) { + ObjDrifticeStruct3* temp_s0; + f32 temp_f22 = 0.0f; + s16 phi_s0; + s32 i; + + if (this->unk_248 > 0) { + f32 temp_f20 = this->dyna.actor.xzDistToPlayer * this->unk_240 * 0.0007075472f; + if (temp_f20 > 1.0f) { + temp_f20 = 1.0f; + } else if (temp_f20 < 0.01f) { + temp_f20 = 0.01f; + } + + Math_StepToS(&arg0->unk_00[1], 1200.0f * temp_f20, 0x64); + phi_s0 = 2500.0f * temp_f20; + Math_StepToS(&arg0->unk_00[3], Math_CosS(arg0->unk_00[2] * 6.5536f) * (120.0f * temp_f20), 0x28); + Math_StepToF(&arg0->unk_08, 1.0f, 0.02f); + } else { + Math_StepToS(&arg0->unk_00[1], 0, 0x96); + phi_s0 = 0; + Math_StepToS(&arg0->unk_00[3], 20, 7); + Math_StepToF(&arg0->unk_08, 0.0f, 0.02f); + } + Math_ScaledStepToS(arg0->unk_00, this->dyna.actor.yawTowardsPlayer, arg0->unk_00[1]); + *arg3 = arg0->unk_00[0]; + Math_ScaledStepToS(&arg0->unk_00[2], phi_s0, arg0->unk_00[3]); + + for (i = 0; i < 2; i++) { + temp_s0 = &arg0->unk_0C[i]; + + if (temp_s0->unk_00 > 0) { + temp_s0->unk_00--; + } else { + temp_s0->unk_00 = Rand_S16Offset(30, 70); + temp_s0->unk_04 = Rand_S16Offset(D_80A676B8[i].unk_00, D_80A676B8[i].unk_02); + temp_s0->unk_0C = D_80A676B8[i].unk_04 + (D_80A676B8[i].unk_08 * Rand_ZeroOne()); + temp_s0->unk_10 = fabsf(temp_s0->unk_0C - temp_s0->unk_08) * 0.033333335f; + } + temp_s0->unk_02 += temp_s0->unk_04; + Math_StepToF(&temp_s0->unk_08, temp_s0->unk_0C, temp_s0->unk_10); + temp_f22 += Math_SinS(temp_s0->unk_02) * temp_s0->unk_08; + } + + temp_f22 *= arg0->unk_08; + + *arg2 = (s32)temp_f22 + arg0->unk_00[2]; +} +#else +void func_80A66930(ObjDrifticeStruct2* arg0, ObjDriftice* this, s16* arg2, s16* arg3); +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A66930.s") #endif -extern InitChainEntry D_80A676F4[]; +void func_80A66C4C(ObjDrifticeStruct4* arg0, ObjDriftice* this, s16* arg2, s16* arg3) { + ObjDrifticeStruct3* temp_s0; + f32 temp_f20 = 0.0f; + s32 i; -extern UNK_TYPE D_060016A0; -extern UNK_TYPE D_06001AA8; + if (arg0->unk_00[0] > 0) { + arg0->unk_00[0]--; + } else { + arg0->unk_00[0] = Rand_S16Offset(30, 70); + arg0->unk_00[2] = Rand_S16Offset(-200, 200); + arg0->unk_00[4] = Rand_S16Offset(-400, 400); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A66570.s") + Math_StepToS(&arg0->unk_00[1], arg0->unk_00[2], 0x32); + Math_StepToS(&arg0->unk_00[3], arg0->unk_00[4], 0x32); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A665AC.s") + *arg3 = arg0->unk_00[3] + arg0->unk_00[1]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A665EC.s") + for (i = 0; i < 3; i++) { + temp_s0 = &arg0->unk_0C[i]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A667F0.s") + if (temp_s0->unk_00 > 0) { + temp_s0->unk_00--; + } else { + temp_s0->unk_00 = Rand_S16Offset(30, 70); + temp_s0->unk_04 = Rand_S16Offset(D_80A676D0[i].unk_00, D_80A676D0[i].unk_02); + temp_s0->unk_0C = D_80A676D0[i].unk_04 + (D_80A676D0[i].unk_08 * Rand_ZeroOne()); + temp_s0->unk_10 = fabsf(temp_s0->unk_0C - temp_s0->unk_08) * 0.033333335f; + } + temp_s0->unk_02 += temp_s0->unk_04; + Math_StepToF(&temp_s0->unk_08, temp_s0->unk_0C, temp_s0->unk_10); + temp_f20 += Math_SinS(temp_s0->unk_02) * temp_s0->unk_08; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A66930.s") + *arg2 = temp_f20; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A66C4C.s") +void func_80A66E30(ObjDrifticeStruct* arg0, ObjDriftice* this) { + f32 temp; + f32* temp_s1 = D_80A67664[OBJDRIFTICE_GET_ROT(&this->dyna.actor) - 1]; + s16 sp36; + s16 sp34; + s16 sp32; + s16 sp30; + f32 sp2C; + f32 sp28; + f32 sp24; + s16 sp22; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A66E30.s") + sp2C = func_80A665EC(arg0, this); + sp28 = func_80A667F0(arg0->unk_14, this); + func_80A66930(&arg0->unk_50, this, &sp32, &sp30); + func_80A66C4C(&arg0->unk_84, this, &sp36, &sp34); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/ObjDriftice_Init.s") + this->dyna.actor.shape.yOffset = this->unk_240 * ((sp28 * temp_s1[1]) + (sp2C * temp_s1[0])); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/ObjDriftice_Destroy.s") + sp24 = (sp32 * temp_s1[2]) + (sp36 * temp_s1[3]) * (temp = 1.0f); + sp22 = (sp34 + sp30) - this->dyna.actor.shape.rot.y; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A671A8.s") + this->dyna.actor.shape.rot.x = Math_CosS(sp22) * sp24; + func_80A665AC(&this->dyna.actor.shape.rot.x, 0xA28); + this->dyna.actor.shape.rot.z = -Math_SinS(sp22) * sp24; + func_80A665AC(&this->dyna.actor.shape.rot.z, 0xA28); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A671BC.s") +void ObjDriftice_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjDriftice* this = THIS; + f32* sp2C = D_80A67620[OBJDRIFTICE_GET_3(&this->dyna.actor)]; + Path* path; + s32 phi_a1; + s32 sp20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A671CC.s") + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + this->dyna.actor.shape.rot.x = 0; + this->dyna.actor.world.rot.x = 0; + this->dyna.actor.shape.rot.z = 0; + this->dyna.actor.world.rot.z = 0; + + Actor_SetScale(&this->dyna.actor, sp2C[0] * 0.035377357f); + this->dyna.actor.uncullZoneScale = sp2C[1]; + this->dyna.actor.uncullZoneDownward = sp2C[2]; + this->unk_240 = 1.0f / this->dyna.actor.scale.x; + this->unk_23C = D_80A67644[OBJDRIFTICE_GET_E00(&this->dyna.actor)]; + + sp20 = 0; + if (this->unk_23C < 0.01f) { + sp20 = 1; + } + + this->unk_244 = thisx->home.rot.z * 45.511112f; + + phi_a1 = 0; + if (sp20 == 0) { + phi_a1 = 1; + } + + if (thisx->home.rot.z != 0) { + phi_a1 |= 3; + } + + DynaPolyActor_Init(&this->dyna, phi_a1); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_driftice_Colheader_001AA8); + + if (sp20 != 0) { + func_80A671A8(this); + } else { + this->dyna.actor.flags |= ACTOR_FLAG_10; + + path = &globalCtx->setupPathList[OBJDRIFTICE_GET_1FC(&this->dyna.actor)]; + this->unk_164 = 0; + this->unk_160 = path->count - 1; + this->unk_168 = 1; + + this->unk_16C = Lib_SegmentedToVirtual(path->points); + func_80A66570(this, this->unk_164); + func_80A671CC(this); + } +} + +void ObjDriftice_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjDriftice* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} + +void func_80A671A8(ObjDriftice* this) { + this->actionFunc = func_80A671BC; +} + +void func_80A671BC(ObjDriftice* this, GlobalContext* globalCtx) { +} + +void func_80A671CC(ObjDriftice* this) { + this->actionFunc = func_80A671E0; +} + +#ifdef NON_MATCHING +// stack +void func_80A671E0(ObjDriftice* this, GlobalContext* globalCtx) { + f32 phi_f0; + Vec3f sp40; + f32 sp3C; + f32 phi_f12; + Vec3s* points; + s32 sp30; + Vec3s* points2; + + Math_Vec3s_ToVec3f(&sp40, &(&this->unk_16C[this->unk_164])[this->unk_168]); + Math_Vec3f_Diff(&sp40, &this->dyna.actor.world.pos, &this->dyna.actor.velocity); + + sp3C = Math3D_Vec3fMagnitude(&this->dyna.actor.velocity); + if (sp3C < (this->unk_23C * 8.0f)) { + phi_f0 = this->unk_23C * 0.4f; + phi_f12 = this->unk_23C * 0.05f; + } else { + phi_f0 = this->unk_23C; + phi_f12 = this->unk_23C * 0.13f; + } + + Math_StepToF(&this->dyna.actor.speedXZ, phi_f0, phi_f12); + + if ((this->dyna.actor.speedXZ + 0.05f) < sp3C) { + Math_Vec3f_Scale(&this->dyna.actor.velocity, this->dyna.actor.speedXZ / sp3C); + this->dyna.actor.world.pos.x += this->dyna.actor.velocity.x; + this->dyna.actor.world.pos.y += this->dyna.actor.velocity.y; + this->dyna.actor.world.pos.z += this->dyna.actor.velocity.z; + } else { + sp30 = true; + this->unk_164 += this->unk_168; + + if (1) {} + + this->dyna.actor.speedXZ *= 0.5f; + if (((this->unk_164 >= this->unk_160) && (this->unk_168 > 0)) || + ((this->unk_164 <= 0) && (this->unk_168 < 0))) { + if (!OBJDRIFTICE_GET_1000(&this->dyna.actor)) { + this->unk_168 = -this->unk_168; + func_80A674A8(this); + } else { + points = &this->unk_16C[this->unk_160]; + + if (this->unk_168 > 0) { + this->unk_164 = 0; + } else { + this->unk_164 = this->unk_160; + } + + points2 = &this->unk_16C[0]; + if ((points2->x != points->x) || (points2->y != points->y) || (points2->z != points->z)) { + func_80A6743C(this); + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + sp30 = false; + } + } + } + + if (sp30) { + func_80A66570(this, this->unk_164); + } + } +} +#else #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A671E0.s") +#endif -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A6743C.s") +void func_80A6743C(ObjDriftice* this) { + this->actionFunc = func_80A67450; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A67450.s") +void func_80A67450(ObjDriftice* this, GlobalContext* globalCtx) { + if (this->unk_248 < 0) { + func_80A66570(this, this->unk_164); + func_800C6314(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + func_80A671CC(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A674A8.s") +void func_80A674A8(ObjDriftice* this) { + this->unk_24C = 10; + this->actionFunc = func_80A674C4; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A674C4.s") +void func_80A674C4(ObjDriftice* this, GlobalContext* globalCtx) { + this->unk_24C--; + if (this->unk_24C <= 0) { + this->dyna.actor.speedXZ = 0.0f; + func_80A671CC(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/ObjDriftice_Update.s") +void ObjDriftice_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjDriftice* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/ObjDriftice_Draw.s") + if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + if (this->unk_248 < 0) { + this->unk_248 = 1; + } else { + this->unk_248++; + } + } else { + if (this->unk_248 > 0) { + this->unk_248 = -1; + } else { + this->unk_248--; + } + } + + this->dyna.actor.shape.rot.y += this->unk_244; + + this->actionFunc(this, globalCtx); + + if (OBJDRIFTICE_GET_ROT(&this->dyna.actor) && (this->dyna.actor.flags & ACTOR_FLAG_40)) { + func_80A66E30(&this->unk_170, this); + } +} + +void ObjDriftice_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjDriftice* this = THIS; + + Gfx_DrawDListOpa(globalCtx, object_driftice_DL_0016A0); +} diff --git a/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.h b/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.h index cdfc01f174..190fbdcb64 100644 --- a/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.h +++ b/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.h @@ -7,11 +7,53 @@ struct ObjDriftice; typedef void (*ObjDrifticeActionFunc)(struct ObjDriftice*, GlobalContext*); +#define OBJDRIFTICE_GET_3(thisx) ((thisx)->params & 3) +#define OBJDRIFTICE_GET_1FC(thisx) (((thisx)->params >> 2) & 0x7F) +#define OBJDRIFTICE_GET_E00(thisx) (((thisx)->params >> 9) & 7) +#define OBJDRIFTICE_GET_1000(thisx) (((thisx)->params >> 0xC) & 1) +#define OBJDRIFTICE_GET_ROT(thisx) ((thisx)->home.rot.x & 3) + +typedef struct { + /* 0x00 */ s16 unk_00; + /* 0x02 */ s16 unk_02; + /* 0x04 */ s16 unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ f32 unk_10; +} ObjDrifticeStruct3; // size = 0x14 + +typedef struct { + /* 0x00 */ s16 unk_00[2]; + /* 0x04 */ f32 unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ ObjDrifticeStruct3 unk_0C[2]; +} ObjDrifticeStruct2; // size = 0x34 + +typedef struct { + /* 0x00 */ s16 unk_00[6]; + /* 0x0C */ ObjDrifticeStruct3 unk_0C[3]; +} ObjDrifticeStruct4; // size = 0x48 + +typedef struct { + /* 0x00 */ ObjDrifticeStruct3 unk_00; + /* 0x14 */ ObjDrifticeStruct3 unk_14[3]; + /* 0x50 */ ObjDrifticeStruct2 unk_50; + /* 0x84 */ ObjDrifticeStruct4 unk_84; +} ObjDrifticeStruct; // size = 0xCC + typedef struct ObjDriftice { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; + /* 0x0000 */ DynaPolyActor dyna; /* 0x015C */ ObjDrifticeActionFunc actionFunc; - /* 0x0160 */ char unk_160[0xF0]; + /* 0x0160 */ s32 unk_160; + /* 0x0164 */ s32 unk_164; + /* 0x0168 */ s32 unk_168; + /* 0x016C */ Vec3s* unk_16C; + /* 0x0170 */ ObjDrifticeStruct unk_170; + /* 0x023C */ f32 unk_23C; + /* 0x0240 */ f32 unk_240; + /* 0x0244 */ s16 unk_244; + /* 0x0248 */ s32 unk_248; + /* 0x024C */ s32 unk_24C; } ObjDriftice; // size = 0x250 extern const ActorInit Obj_Driftice_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.c b/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.c index 72f0a8015d..8ed2379279 100644 --- a/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.c +++ b/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.c @@ -5,6 +5,7 @@ */ #include "z_obj_entotu.h" +#include "objects/object_f53_obj/object_f53_obj.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -15,7 +16,6 @@ void ObjEntotu_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjEntotu_Update(Actor* thisx, GlobalContext* globalCtx); void ObjEntotu_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Entotu_InitVars = { ACTOR_OBJ_ENTOTU, ACTORCAT_PROP, @@ -28,23 +28,147 @@ const ActorInit Obj_Entotu_InitVars = { (ActorFunc)ObjEntotu_Draw, }; -#endif +#include "overlays/ovl_Obj_Entotu/ovl_Obj_Entotu.c" -extern UNK_TYPE D_06000158; -extern UNK_TYPE D_06001C00; +s32 func_80A34700(s16 minutes) { + s32 ret = 0; + s16 time = TIME_TO_MINUTES_F(gSaveContext.save.time); + s32 hours = time / 60; + s32 currMinutes = time % 60; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Entotu/func_80A34700.s") + if (hours >= 16) { + if ((hours == 16) && (currMinutes < minutes)) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Entotu/func_80A349C0.s") + if (hours >= 20) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Entotu/func_80A34A44.s") + if ((hours == 19) && (minutes < currMinutes)) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Entotu/func_80A34B28.s") + ret = 3; + } else if (hours >= 11) { + if ((hours == 11) && (currMinutes < minutes)) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Entotu/ObjEntotu_Init.s") + if (hours >= 14) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Entotu/ObjEntotu_Destroy.s") + if ((hours == 13) && (minutes < currMinutes)) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Entotu/ObjEntotu_Update.s") + ret = 2; + } else if (hours >= 6) { + if ((hours == 6) && (currMinutes < minutes)) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Entotu/ObjEntotu_Draw.s") + if (hours >= 9) { + return 0; + } + + if ((hours == 8) && (minutes < currMinutes)) { + return 0; + } + + ret = 1; + } + return ret; +} + +void func_80A349C0(ObjEntotu* this) { + s32 temp_v0 = func_80A34700(this->unk_1C6); + u8 temp = temp_v0; + s16 temp2 = this->unk_1C4; + + if (temp_v0 != temp2) { + this->unk_1C4 = temp; + this->unk_1C6 = Rand_S16Offset(0, 59); + } + + temp2 = this->unk_1C4; + Math_ApproachF(&this->unk_1B8.x, (temp2 == 0) ? 0.0f : 1.0f, 0.02f, 1000.0f); +} + +void func_80A34A44(ObjEntotu* this, GlobalContext* globalCtx) { + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + this->actor.shape.rot.y = BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))); + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Scale(0.1f, 0.1f, 0.0f, MTXMODE_APPLY); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_f53_obj_DL_000158); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80A34B28(ObjEntotu* this, GlobalContext* globalCtx) { + u8 sp57; + u8 sp56; + s32 i; + + this->unk_1B8.y += 1.8f; + this->unk_1B8.z += 0.6f; + sp57 = 0x7F - (u8)this->unk_1B8.y; + sp56 = 0x7F - (u8)this->unk_1B8.z; + + this->unk_1B8.x = CLAMP(this->unk_1B8.x, 0.0f, 1.0f); + + for (i = 0; i < ARRAY_COUNT(ovl_Obj_Entotu_Vtx_000D10); i++) { + this->unk_148[i].v.cn[3] = ovl_Obj_Entotu_Vtx_000D10[i].v.cn[3] * this->unk_1B8.x; + } + + if (this->unk_1B8.x > 0.0f) { + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + MTXMODE_NEW); + this->actor.shape.rot.y = BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))); + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Scale(0.1f, 0.1f, 0.0f, MTXMODE_APPLY); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, sp57, 0x20, 0x20, 1, 0, sp56, 0x20, 0x20)); + gSPSegment(POLY_XLU_DISP++, 0x09, Lib_SegmentedToVirtual(this->unk_148)); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_f53_obj_DL_001C00); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +void ObjEntotu_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjEntotu* this = THIS; + + Lib_MemCpy(this->unk_148, ovl_Obj_Entotu_Vtx_000D10, sizeof(ovl_Obj_Entotu_Vtx_000D10)); + this->unk_1C6 = Rand_S16Offset(0, 59); + this->unk_1C4 = 0; +} + +void ObjEntotu_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void ObjEntotu_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjEntotu* this = THIS; + + func_80A349C0(this); +} + +void ObjEntotu_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjEntotu* this = THIS; + + func_80A34B28(this, globalCtx); + func_80A34A44(this, globalCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.h b/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.h index 5d0b3cedd2..a00a7fcd49 100644 --- a/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.h +++ b/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.h @@ -7,7 +7,11 @@ struct ObjEntotu; typedef struct ObjEntotu { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x84]; + /* 0x144 */ UNK_TYPE1 unk144[4]; + /* 0x148 */ Vtx unk_148[7]; + /* 0x1B8 */ Vec3f unk_1B8; + /* 0x1C4 */ u8 unk_1C4; + /* 0x1C6 */ s16 unk_1C6; } ObjEntotu; // size = 0x1C8 extern const ActorInit Obj_Entotu_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Fireshield/z_obj_fireshield.c b/src/overlays/actors/ovl_Obj_Fireshield/z_obj_fireshield.c index 00810af230..705dc93bf0 100644 --- a/src/overlays/actors/ovl_Obj_Fireshield/z_obj_fireshield.c +++ b/src/overlays/actors/ovl_Obj_Fireshield/z_obj_fireshield.c @@ -5,6 +5,7 @@ */ #include "z_obj_fireshield.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_10) @@ -15,12 +16,12 @@ void ObjFireshield_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjFireshield_Update(Actor* thisx, GlobalContext* globalCtx); void ObjFireshield_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80A4CABC(ObjFireshield* this, GlobalContext* globalCtx); -void func_80A4CB7C(ObjFireshield* this, GlobalContext* globalCtx); -void func_80A4CCBC(ObjFireshield* this, GlobalContext* globalCtx); -void func_80A4CD28(ObjFireshield* this, GlobalContext* globalCtx); +void func_80A4CABC(ObjFireshield* this); +void func_80A4CB7C(ObjFireshield* this); +void func_80A4CC54(ObjFireshield* this); +void func_80A4CCBC(ObjFireshield* this); +void func_80A4CD28(ObjFireshield* this); -#if 0 const ActorInit Obj_Fireshield_InitVars = { ACTOR_OBJ_FIRESHIELD, ACTORCAT_PROP, @@ -33,49 +34,365 @@ const ActorInit Obj_Fireshield_InitVars = { (ActorFunc)ObjFireshield_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A4D820 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_ENEMY, AC_NONE, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x20000000, 0x01, 0x04 }, { 0x00000000, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NONE, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_NONE, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x20000000, 0x01, 0x04 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NONE, + BUMP_NONE, + OCELEM_ON, + }, { 28, 144, 0, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80A4D8A4[] = { +typedef struct { + /* 0x00 */ f32 unk_00; + /* 0x04 */ f32 unk_04; +} ObjFireshieldStruct; // size = 0x8 + +ObjFireshieldStruct D_80A4D84C[] = { + { 1.0f, 200.0f }, + { 2.0f, 400.0f }, + { 3.0f, 700.0f }, +}; + +s32 D_80A4D864[] = { 0, 0, 0, 0 }; +s32 D_80A4D874[] = { 0, 0, 0, 0 }; +s32 D_80A4D884[] = { 0, 0, 0, 0 }; +s32 D_80A4D894[] = { 0, 0, 0, 0 }; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 400, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#endif +void func_80A4CA90(ObjFireshield* this) { + if (this->actor.cutscene >= 0) { + this->actionFunc = func_80A4CABC; + } else { + this->actionFunc = func_80A4CC54; + } +} -extern ColliderCylinderInit D_80A4D820; -extern InitChainEntry D_80A4D8A4[]; +void func_80A4CABC(ObjFireshield* this) { + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Fireshield/func_80A4CA90.s") + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + s32 sp18 = OBJFIRESHIELD_GET_7F(&this->actor); + s32 temp_a0 = (sp18 & ~0x1F) >> 5; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Fireshield/func_80A4CABC.s") + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + this->actionFunc = func_80A4CB7C; + this->unk_194 = 20; + D_80A4D884[temp_a0] |= 1 << (sp18 & 0x1F); + D_80A4D894[temp_a0] |= 1 << (sp18 & 0x1F); + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Fireshield/func_80A4CB7C.s") +void func_80A4CB7C(ObjFireshield* this) { + s32 pad; + s32 sp18 = OBJFIRESHIELD_GET_7F(&this->actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Fireshield/func_80A4CC54.s") + if (this->unk_194 > 0) { + if (this->unk_194 == 20) { + D_80A4D884[(sp18 & ~0x1F) >> 5] &= ~(1 << (sp18 & 0x1F)); + } + this->unk_194--; + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Fireshield/func_80A4CCBC.s") + ActorCutscene_Stop(this->actor.cutscene); + this->actionFunc = func_80A4CD28; + D_80A4D894[(sp18 & ~0x1F) >> 5] &= ~(1 << (sp18 & 0x1F)); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Fireshield/func_80A4CD28.s") +void func_80A4CC54(ObjFireshield* this) { + s32 temp_v0 = OBJFIRESHIELD_GET_7F(&this->actor); + s32 temp_v1 = 1 << (temp_v0 & 0x1F); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Fireshield/func_80A4CD34.s") + this->actionFunc = func_80A4CCBC; + D_80A4D884[(temp_v0 & ~0x1F) >> 5] |= temp_v1; + D_80A4D894[(temp_v0 & ~0x1F) >> 5] |= temp_v1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Fireshield/func_80A4CE28.s") +void func_80A4CCBC(ObjFireshield* this) { + s32 temp_v0 = OBJFIRESHIELD_GET_7F(&this->actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Fireshield/func_80A4D174.s") + this->actionFunc = func_80A4CD28; + D_80A4D884[(temp_v0 & ~0x1F) >> 5] &= ~(1 << (temp_v0 & 0x1F)); + D_80A4D894[(temp_v0 & ~0x1F) >> 5] &= ~(1 << (temp_v0 & 0x1F)); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Fireshield/func_80A4D1CC.s") +void func_80A4CD28(ObjFireshield* this) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Fireshield/ObjFireshield_Init.s") +void func_80A4CD34(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjFireshield* this = THIS; + s32 sp24 = Flags_GetSwitch(globalCtx, OBJFIRESHIELD_GET_7F(&this->actor)); + s32 phi_v1; + s32 phi_a0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Fireshield/ObjFireshield_Destroy.s") + if (this->unk_1A8 == 0) { + if (OBJFIRESHIELD_GET_2000(&this->actor)) { + phi_v1 = false; + phi_a0 = false; + } else { + phi_v1 = Flags_GetTreasure(globalCtx, OBJFIRESHIELD_GET_1F00(&this->actor)); + phi_a0 = false; + } + } else { + phi_a0 = Flags_GetSwitch(globalCtx, OBJFIRESHIELD_GET_3F80(&this->actor)); + phi_v1 = false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Fireshield/ObjFireshield_Update.s") + if (phi_v1 || phi_a0) { + this->unk_19C = 0; + } else if (sp24) { + this->unk_19C = 0; + } else { + this->unk_19C = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Fireshield/ObjFireshield_Draw.s") + if (this->unk_19C == 0) { + this->unk_198 = 0.0f; + } else { + this->unk_198 = 1.0f; + } +} + +void func_80A4CE28(ObjFireshield* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp30 = OBJFIRESHIELD_GET_7F(&this->actor); + s32 pad2[2]; + s32 sp24; + s32 sp20; + + if (this->unk_1A8 == 0) { + if (OBJFIRESHIELD_GET_2000(&this->actor)) { + sp24 = false; + sp20 = false; + } else { + sp24 = Flags_GetTreasure(globalCtx, OBJFIRESHIELD_GET_1F00(&this->actor)); + sp20 = false; + } + } else { + sp20 = Flags_GetSwitch(globalCtx, OBJFIRESHIELD_GET_3F80(&this->actor)); + sp24 = false; + } + + if (!sp24 || !sp20 || (this->unk_19C != 0)) { + s32 sp1C = Flags_GetSwitch(globalCtx, sp30); + s32 temp_v0 = (sp30 & ~0x1F) >> 5; + + if (this->unk_19C == 2) { + if (Math_StepToF(&this->unk_198, 1.0f, 0.03f)) { + this->unk_19C = 1; + if (((this->actor.home.rot.z * 10) > 0) && (this->unk_1A7 != 0)) { + Flags_UnsetSwitch(globalCtx, sp30); + sp1C = false; + } + } + } else if (this->unk_19C == 3) { + if (Math_StepToF(&this->unk_198, 0.0f, 0.03f)) { + this->unk_19C = 0; + } + } + + if ((this->unk_1A0 > 0) && (this->unk_19C == 1) && ((this->actor.home.rot.z * 10) > 0) && + !(D_80A4D894[temp_v0] & (1 << (sp30 & 0x1F)))) { + this->unk_1A0 = 0; + } + + if ((this->unk_19C == 0) || (this->unk_19C == 3)) { + if (!sp24 && !sp20) { + if ((this->actor.home.rot.z * 10) > 0) { + if (this->unk_1A0 > 1) { + this->unk_1A0--; + } + + if (this->unk_1A0 == 1) { + this->unk_19C = 2; + } + } + + if (!sp1C) { + this->unk_19C = 2; + } + } + } else if (sp24 || sp20) { + this->unk_19C = 3; + } else if (sp1C && ((this->unk_19C == 1) || (this->unk_19C == 2))) { + if ((D_80A4D884[temp_v0] & 1 << (sp30 & 0x1F)) && !(D_80A4D874[temp_v0] & 1 << (sp30 & 0x1F))) { + this->unk_19C = 3; + } else if (((this->actor.home.rot.z * 10) == 0) || (this->unk_1A0 == 0)) { + if ((this->actor.home.rot.z * 10) > 0) { + this->unk_1A0 = this->actor.home.rot.z * 10; + } + + if (this->unk_1A7 != 0) { + func_80A4CA90(this); + } + } + } + } +} + +void func_80A4D174(ObjFireshield* this) { + s32 temp_v0 = OBJFIRESHIELD_GET_7F(&this->actor); + s32 temp_v1 = 1 << (temp_v0 & 0x1F); + + if (!(D_80A4D864[(temp_v0 & ~0x1F) >> 5] & temp_v1)) { + this->unk_1A7 = 1; + D_80A4D864[(temp_v0 & ~0x1F) >> 5] |= temp_v1; + } +} + +void func_80A4D1CC(void) { + D_80A4D864[0] = 0; + D_80A4D864[1] = 0; + D_80A4D864[2] = 0; + D_80A4D864[3] = 0; +} + +void ObjFireshield_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjFireshield* this = THIS; + s32 temp = 0x8000; + ObjFireshieldStruct* sp2C = &D_80A4D84C[OBJFIRESHIELD_GET_C000(&this->actor)]; + s32 sp28 = OBJFIRESHIELD_GET_ROTX(&this->actor); + + Actor_ProcessInitChain(&this->actor, sInitChain); + + if (sp28) { + this->actor.shape.rot.z = temp; + } else { + this->actor.shape.rot.z = 0; + } + + this->actor.world.rot.z = 0; + this->actor.shape.rot.x = 0; + this->actor.world.rot.x = 0; + + this->actor.scale.x = sp2C->unk_00 * 0.0348f; + this->actor.scale.z = this->actor.scale.x; + this->actor.scale.y = 0.05f; + + this->actor.uncullZoneScale = sp2C->unk_04; + this->unk_1A4 = Rand_ZeroOne() * 128.0f; + + if ((this->actor.home.rot.z * 10) < 0) { + this->unk_1A8 = 1; + this->actor.home.rot.z = -thisx->home.rot.z; + } + + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_UpdateCylinder(&this->actor, &this->collider); + + this->collider.dim.radius *= sp2C->unk_00; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + func_80A4D174(this); + func_80A4CD34(&this->actor, globalCtx); + this->actionFunc = func_80A4CD28; +} + +void ObjFireshield_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjFireshield* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +void ObjFireshield_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjFireshield* this = THIS; + ObjFireshield* this2 = THIS; + s32 sp44 = OBJFIRESHIELD_GET_ROTX(&this->actor); + s32 sp40 = OBJFIRESHIELD_GET_7F(&this->actor); + s32 temp_a0; + s32 temp_v1; + + func_80A4D1CC(); + + if (this->unk_1A7 != 0) { + temp_a0 = (sp40 & ~0x1F) >> 5; + temp_v1 = 1 << (sp40 & 0x1F); + if ((D_80A4D884[temp_a0] & temp_v1)) { + D_80A4D874[temp_a0] |= temp_v1; + } else { + D_80A4D874[temp_a0] &= ~temp_v1; + } + } + + this->unk_1A4++; + + this->actionFunc(this); + + if (this->actionFunc == func_80A4CABC) { + this->collider.base.atFlags &= ~AT_HIT; + } else if (this->collider.base.atFlags & AT_HIT) { + this->collider.base.atFlags &= ~AT_HIT; + func_800B8D98(globalCtx, &this->actor, 5.0f, this->actor.yawTowardsPlayer, 1.0f); + } + + func_80A4CE28(this, globalCtx); + + this->actor.world.pos.y = ((sp44 ? 144.0f : -144.0f) * (1.0f - this2->unk_198)) + this->actor.home.pos.y; + + this->unk_1A6 = this->unk_198 * 255.0f; + + if (this->unk_198 >= 0.7f) { + Player* player = GET_PLAYER(globalCtx); + + this->collider.dim.height = this->unk_198 * 80.0f; + + if (sp44) { + this->collider.dim.yShift = + (s32)(this->actor.home.pos.y - this->actor.world.pos.y) - this->collider.dim.height; + } else { + this->collider.dim.yShift = this->actor.home.pos.y - this->actor.world.pos.y; + } + + func_800B9010(&this->actor, NA_SE_EV_BURNING - SFX_FLAG); + + if (player->transformation == PLAYER_FORM_GORON) { + this->collider.info.toucher.damage = 0; + this->collider.info.toucher.effect = 0; + } else { + this->collider.info.toucher.damage = 4; + this->collider.info.toucher.effect = 1; + } + + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +void ObjFireshield_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjFireshield* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 220, 0, this->unk_1A6); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, this->unk_1A4 & 0x7F, 0, 0x20, 0x40, 1, 0, + (this->unk_1A4 * -15) & 0xFF, 0x20, 0x40)); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_02E510); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Fireshield/z_obj_fireshield.h b/src/overlays/actors/ovl_Obj_Fireshield/z_obj_fireshield.h index f39039793b..4d6a971eb0 100644 --- a/src/overlays/actors/ovl_Obj_Fireshield/z_obj_fireshield.h +++ b/src/overlays/actors/ovl_Obj_Fireshield/z_obj_fireshield.h @@ -5,13 +5,27 @@ struct ObjFireshield; -typedef void (*ObjFireshieldActionFunc)(struct ObjFireshield*, GlobalContext*); +typedef void (*ObjFireshieldActionFunc)(struct ObjFireshield*); + +#define OBJFIRESHIELD_GET_7F(thisx) ((thisx)->params & 0x7F) +#define OBJFIRESHIELD_GET_1F00(thisx) (((thisx)->params >> 8) & 0x1F) +#define OBJFIRESHIELD_GET_2000(thisx) (((thisx)->params >> 0xD) & 1) +#define OBJFIRESHIELD_GET_3F80(thisx) (((thisx)->params >> 7) & 0x7F) +#define OBJFIRESHIELD_GET_C000(thisx) (((thisx)->params >> 0xE) & 3) +#define OBJFIRESHIELD_GET_ROTX(thisx) ((thisx)->home.rot.x & 1) typedef struct ObjFireshield { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x4C]; + /* 0x0144 */ ColliderCylinder collider; /* 0x0190 */ ObjFireshieldActionFunc actionFunc; - /* 0x0194 */ char unk_194[0x18]; + /* 0x0194 */ s32 unk_194; + /* 0x0198 */ f32 unk_198; + /* 0x019C */ s32 unk_19C; + /* 0x01A0 */ s32 unk_1A0; + /* 0x01A4 */ s16 unk_1A4; + /* 0x01A6 */ u8 unk_1A6; + /* 0x01A7 */ s8 unk_1A7; + /* 0x01A8 */ s8 unk_1A8; } ObjFireshield; // size = 0x1AC extern const ActorInit Obj_Fireshield_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Ghaka/z_obj_ghaka.c b/src/overlays/actors/ovl_Obj_Ghaka/z_obj_ghaka.c index cf5269fc83..bedb0a38f5 100644 --- a/src/overlays/actors/ovl_Obj_Ghaka/z_obj_ghaka.c +++ b/src/overlays/actors/ovl_Obj_Ghaka/z_obj_ghaka.c @@ -44,7 +44,7 @@ static InitChainEntry D_80B3C96C[] = { }; void func_80B3C260(ObjGhaka* this) { - if (gSaveContext.weekEventReg[20] & 0x20) { + if (gSaveContext.save.weekEventReg[20] & 0x20) { this->dyna.actor.world.pos.z = this->dyna.actor.home.pos.z + 100.0f; } this->actionFunc = func_80B3C39C; @@ -59,7 +59,7 @@ void func_80B3C2B0(ObjGhaka* this) { } void func_80B3C2C4(ObjGhaka* this, GlobalContext* globalCtx) { - if (!(gSaveContext.weekEventReg[20] & 0x20)) { + if (!(gSaveContext.save.weekEventReg[20] & 0x20)) { Actor_SpawnAsChildAndCutscene(&globalCtx->actorCtx, globalCtx, ACTOR_BG_GORON_OYU, 0.0f, 25.0f, 261.0f, 0, 0, 0, 0, this->dyna.actor.cutscene, this->dyna.actor.unk20, 0); } else { @@ -84,7 +84,8 @@ void func_80B3C39C(ObjGhaka* this, GlobalContext* globalCtx) { } } } - if (this->dyna.pushForce < 0.0f && !(gSaveContext.weekEventReg[20] & 0x20) && + + if (this->dyna.pushForce < 0.0f && !(gSaveContext.save.weekEventReg[20] & 0x20) && player->transformation == PLAYER_FORM_GORON) { func_80B3C2B0(this); } else { @@ -97,13 +98,13 @@ void func_80B3C4E0(ObjGhaka* this, GlobalContext* globalCtx) { u8 talkState = Message_GetState(&globalCtx->msgCtx); if (talkState == 5) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; func_80B3C260(this); } } else if (talkState == 4) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_8019F208(); @@ -135,7 +136,7 @@ void func_80B3C624(ObjGhaka* this, GlobalContext* globalCtx) { player->stateFlags2 &= ~0x10; this->dyna.pushForce = 0.0f; func_80B3C2C4(this, globalCtx); - gSaveContext.weekEventReg[20] |= 0x20; + gSaveContext.save.weekEventReg[20] |= 0x20; func_80B3C260(this); Audio_PlaySfxAtPos(&D_80B3C960, NA_SE_EV_BLOCK_BOUND); } else { @@ -157,7 +158,7 @@ void ObjGhaka_Init(Actor* thisx, GlobalContext* globalCtx) { if (this->dyna.actor.floorPoly == 0) { Actor_MarkForDeath(&this->dyna.actor); } - if (gSaveContext.weekEventReg[20] & 0x20) { + if (gSaveContext.save.weekEventReg[20] & 0x20) { func_80B3C2C4(this, globalCtx); } func_80B3C260(this); diff --git a/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c b/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c index ae70ba013e..d95cc0631c 100644 --- a/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c +++ b/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c @@ -5,6 +5,8 @@ */ #include "z_obj_grass.h" +#include "overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -15,7 +17,13 @@ void ObjGrass_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjGrass_Update(Actor* thisx, GlobalContext* globalCtx); void ObjGrass_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +ObjGrassStruct1* D_809AADA0[4]; +f32 D_809AADB0[4]; +ObjGrassStruct1_1* D_809AADC0[20]; +f32 D_809AAE10[20]; + +#include "overlays/ovl_Obj_Grass/ovl_Obj_Grass.c" + const ActorInit Obj_Grass_InitVars = { ACTOR_OBJ_GRASS, ACTORCAT_PROP, @@ -28,41 +36,486 @@ const ActorInit Obj_Grass_InitVars = { (ActorFunc)ObjGrass_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_809AAB20 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_2, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x0580C71C, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_2, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x0580C71C, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 6, 44, 0, { 0, 0, 0 } }, }; -#endif +Vec3f D_809AAB4C[] = { + { 0.0f, 0.707099974155f, 0.707099974155f }, + { 0.707099974155f, 0.707099974155f, 0.0f }, + { 0.0f, 0.707099974155f, -0.707099974155f }, + { -0.707099974155f, 0.707099974155f, 0.0f }, +}; -extern ColliderCylinderInit D_809AAB20; +s16 D_809AAB7C[] = { 0x6C, 0x66, 0x60, 0x54, 0x42, 0x37, 0x2A, 0x26 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass/func_809A9110.s") +s32 func_809A9110(GlobalContext* globalCtx, Vec3f* arg1) { + f32 sp2C; + Vec3f sp20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass/func_809A91FC.s") + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, arg1, &sp20, &sp2C); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass/func_809A92D0.s") + if ((globalCtx->unk_187F0.z * -130.13191f) < sp20.z) { + if (sp2C < 1.0f) { + sp2C = 1.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass/func_809A9314.s") + if (((fabsf(sp20.x) - (130.13191f * globalCtx->unk_187F0.x)) < sp2C) && + ((fabsf(sp20.y) - (130.13191f * globalCtx->unk_187F0.y)) < sp2C)) { + return true; + } + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass/ObjGrass_Init.s") +void func_809A91FC(MtxF* matrix) { + s32 i; + MtxF* temp = Matrix_GetCurrentState(); + f32* tmp = &temp->xx; + f32* tmp2 = &matrix->xx; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass/ObjGrass_Destroy.s") + for (i = 0; i < 16; i++) { + *tmp++ += *tmp2++; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass/func_809A9790.s") +void func_809A92D0(ObjGrassStruct1_1* ptr, GlobalContext* globalCtx) { + if (!(ptr->unk_0E & 0x10)) { + Item_DropCollectibleRandom(globalCtx, NULL, &ptr->unk_00, ptr->unk_0E * 0x10); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass/func_809A983C.s") +void func_809A9314(ObjGrassStruct1_1* ptr, GlobalContext* globalCtx) { + Vec3f spBC; + Vec3f spB0; + s32 i; + Vec3f* ptr2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass/func_809A9DB8.s") + for (i = 0; i < ARRAY_COUNT(D_809AAB4C); i++) { + ptr2 = &D_809AAB4C[i]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass/ObjGrass_Update.s") + spB0.x = ptr->unk_00.x + (ptr2->x * 8.0f); + spB0.y = (ptr->unk_00.y + (ptr2->y * 8.0f)) + 10.0f; + spB0.z = ptr->unk_00.z + (ptr2->z * 8.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass/func_809AA278.s") + spBC.x = (Rand_ZeroOne() - 0.5f) * 8.0f; + spBC.y = Rand_ZeroOne() * 10.0f; + spBC.z = (Rand_ZeroOne() - 0.5f) * 8.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass/func_809AA54C.s") + EffectSsKakera_Spawn(globalCtx, &spB0, &spBC, &spB0, -100, 64, 40, 3, 0, + D_809AAB7C[(s32)(Rand_ZeroOne() * 111.1f) & 7], 0, 0, 80, -1, 1, gKakeraLeafMiddle); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass/func_809AA798.s") + spB0.x = ptr->unk_00.x + (ptr2->x * 16.0f); + spB0.y = (ptr->unk_00.y + (ptr2->y * 16.0f)) + 10.0f; + spB0.z = ptr->unk_00.z + (ptr2->z * 16.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass/ObjGrass_Draw.s") + spBC.x = (Rand_ZeroOne() - 0.5f) * 6.0f; + spBC.y = Rand_ZeroOne() * 10.0f; + spBC.z = (Rand_ZeroOne() - 0.5f) * 6.0f; + + EffectSsKakera_Spawn(globalCtx, &spB0, &spBC, &spB0, -100, 64, 40, 3, 0, + D_809AAB7C[(s32)(Rand_ZeroOne() * 111.1f) % 7], 0, 0, 80, -1, 1, gKakeraLeafTip); + } +} + +void ObjGrass_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjGrass* this = THIS; + s32 i; + + Actor_SetScale(&this->actor, 0.4f); + + for (i = 0; i < ARRAY_COUNT(this->unk_2948); i++) { + Collider_InitCylinder(globalCtx, &this->unk_2948[i].collider); + Collider_SetCylinder(globalCtx, &this->unk_2948[i].collider, &this->actor, &sCylinderInit); + } + + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->unk_3288 = (u32)Rand_Next() >> 0x10; + this->unk_328A = (u32)Rand_Next() >> 0x10; + this->unk_328C = (u32)Rand_Next() >> 0x10; + this->unk_328E = (u32)Rand_Next() >> 0x10; + this->unk_3290 = (u32)Rand_Next() >> 0x10; +} + +void ObjGrass_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjGrass* this = THIS; + s32 i; + + for (i = 0; i < ARRAY_COUNT(this->unk_2948); i++) { + Collider_DestroyCylinder(globalCtx, &this->unk_2948[i].collider); + } + + for (i = 0; i < ARRAY_COUNT(this->unk_3298); i++) { + ObjGrassCarry** ptr = &this->unk_3298[i]; + + if (*ptr != NULL) { + (*ptr)->unk_190 = 0; + *ptr = NULL; + } + } +} + +void func_809A9790(ObjGrass* this, GlobalContext* globalCtx) { + s32 i; + + for (i = 0; i < ARRAY_COUNT(this->unk_2948); i++) { + ObjGrassStruct1_1* ptr = this->unk_2948[i].unk_4C; + + if ((ptr != NULL) && (this->unk_2948[i].collider.base.acFlags & AC_HIT)) { + func_809A9314(ptr, globalCtx); + func_809A92D0(ptr, globalCtx); + ptr->unk_0F |= 4; + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &ptr->unk_00, 20, NA_SE_EV_PLANT_BROKEN); + } + } +} + +void func_809A983C(ObjGrass* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 i; + s32 j; + s32 x; + s32 y; + f32 temp_f0; + ObjGrassStruct1* ptr; + ObjGrassStruct1_1* ptr2; + ObjGrassStruct2* ptr3; + s16 yaw; + + for (i = 0; i < ARRAY_COUNT(D_809AADC0); i++) { + D_809AADC0[i] = NULL; + D_809AAE10[i] = 422500.0f; + } + + for (i = 0; i < ARRAY_COUNT(D_809AADA0); i++) { + D_809AADA0[i] = NULL; + D_809AADB0[i] = 422500.0f; + } + + for (i = 0; i < this->unk_2944; i++) { + ptr = &this->unk_144[i]; + + for (j = 0; j < ptr->unk_FC; j++) { + ptr->unk_0C[j].unk_0F &= (u16)~2; + } + } + + for (i = 0; i < this->unk_2944; i++) { + ptr = &this->unk_144[i]; + temp_f0 = Math3D_Vec3fDistSq(&ptr->unk_00, &player->actor.world.pos); + + for (j = 0; j < ARRAY_COUNT(D_809AADB0); j++) { + if (temp_f0 < D_809AADB0[j]) { + break; + } + } + + if (j < ARRAY_COUNT(D_809AADB0)) { + for (x = 2; x >= j; x--) { + D_809AADB0[x + 1] = D_809AADB0[x]; + D_809AADA0[x + 1] = D_809AADA0[x]; + } + + D_809AADB0[j] = temp_f0; + D_809AADA0[j] = ptr; + } + } + + this->unk_3294 = NULL; + + for (i = 0; i < ARRAY_COUNT(D_809AADA0); i++) { + ptr = D_809AADA0[i]; + + if (ptr != NULL) { + for (j = 0; j < ptr->unk_FC; j++) { + if (!(ptr->unk_0C[j].unk_0F & 4)) { + temp_f0 = Math3D_Vec3fDistSq(&ptr->unk_0C[j].unk_00, &player->actor.world.pos); + + for (x = 0; x < ARRAY_COUNT(D_809AAE10); x++) { + if (temp_f0 < D_809AAE10[x]) { + break; + } + } + + if (x < ARRAY_COUNT(D_809AAE10)) { + for (y = 18; y >= x; y--) { + D_809AAE10[y + 1] = D_809AAE10[y]; + D_809AADC0[y + 1] = D_809AADC0[y]; + } + + D_809AAE10[x] = temp_f0; + D_809AADC0[x] = &ptr->unk_0C[j]; + + if (temp_f0 < 2500.0f) { + yaw = player->actor.shape.rot.y - + Math_Vec3f_Yaw(&player->actor.world.pos, &ptr->unk_0C[j].unk_00); + + if (ABS_ALT(yaw) < 0x2000) { + this->unk_3294 = &ptr->unk_0C[j]; + } + } + } + } + } + } + } + + for (i = 0; i < ARRAY_COUNT(this->unk_2948); i++) { + ptr3 = &this->unk_2948[i]; + + ptr3->collider.base.acFlags &= (u16)~AC_HIT; + ptr3->collider.base.ocFlags1 &= (u16)~OC1_HIT; + + ptr2 = D_809AADC0[i]; + if (ptr2 != NULL) { + ptr3->collider.dim.pos.x = ptr2->unk_00.x; + ptr3->collider.dim.pos.y = ptr2->unk_00.y; + ptr3->collider.dim.pos.z = ptr2->unk_00.z; + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &ptr3->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &ptr3->collider.base); + ptr2->unk_0F |= 2; + ptr3->unk_4C = ptr2; + } else { + ptr3->unk_4C = NULL; + } + } +} + +void func_809A9DB8(ObjGrass* this) { + s32 i; + s32 pad; + f32* ptr; + f32 temp_f28; + f32 spA4; + f32 spA0; + f32 temp_f22; + f32 temp_f24; + f32 sp94; + f32 sp90; + f32 temp_f26; + f32 sp6C[8]; + f32 tempf1; + f32 tempf2; + f32 tempf3; + f32 tempf4; + f32 tempf5; + f32 temp_f16; + f32 temp_f20; + + this->unk_3288 += 70; + this->unk_328A += 300; + this->unk_328C += 700; + this->unk_328E += 1300; + this->unk_3290 += 8900; + + temp_f24 = Math_SinS(this->unk_3288); + temp_f28 = Math_SinS(this->unk_328A); + temp_f26 = Math_SinS(this->unk_328C); + spA4 = Math_SinS(this->unk_328E) * 1.2f; + spA0 = Math_SinS(this->unk_3290) * 1.5f; + temp_f22 = Math_CosS(this->unk_3288); + temp_f20 = Math_CosS(this->unk_328A); + sp94 = Math_CosS(this->unk_328C); + sp90 = Math_CosS(this->unk_328E) * 1.3f; + temp_f16 = Math_CosS(this->unk_3290) * 1.7f; + + sp6C[0] = (temp_f24 - temp_f20) * temp_f26 * temp_f22 * temp_f24 * 0.0015f; + sp6C[1] = (temp_f28 - sp94) * spA4 * temp_f20 * temp_f24 * 0.0015f; + sp6C[2] = (temp_f26 - sp90) * sp94 * temp_f24 * temp_f22 * 0.0015f; + sp6C[3] = (spA4 - temp_f20) * sp90 * temp_f28 * temp_f22 * 0.0015f; + sp6C[4] = (temp_f24 - sp94) * temp_f24 * temp_f28 * spA0 * 0.0015f; + sp6C[5] = (temp_f28 - sp90) * temp_f26 * spA4 * spA0 * 0.0015f; + sp6C[6] = (temp_f26 - temp_f22) * temp_f22 * temp_f20 * temp_f16 * 0.0015f; + sp6C[7] = (spA4 - temp_f20) * sp94 * sp90 * temp_f16 * 0.0015f; + + for (i = 0; i < ARRAY_COUNT(this->unk_2F88); i++) { + ptr = &this->unk_2F88[i].mf[0][0]; + + tempf1 = sp6C[(i + 0) & 7]; + tempf2 = sp6C[(i + 1) & 7]; + tempf3 = sp6C[(i + 2) & 7]; + tempf4 = sp6C[(i + 3) & 7]; + tempf5 = sp6C[(i + 4) & 7]; + + ptr[0] = sp6C[1] * 0.2f; + ptr[1] = tempf1; + ptr[2] = tempf2; + ptr[3] = 0.0f; + + ptr[4] = tempf3; + ptr[5] = sp6C[0]; + ptr[6] = tempf3; + ptr[7] = 0.0f; + + ptr[8] = tempf4; + ptr[9] = tempf5; + ptr[10] = sp6C[3] * 0.2f; + ptr[11] = 0.0f; + + ptr[12] = 0.0f; + ptr[13] = 0.0f; + ptr[14] = 0.0f; + ptr[15] = 0.0f; + } +} + +void ObjGrass_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjGrass* this = THIS; + + func_809A9790(this, globalCtx); + func_809A983C(this, globalCtx); + func_809A9DB8(this); +} + +void func_809AA278(ObjGrass* this, GlobalContext* globalCtx) { + ObjGrassStruct1* ptr; + ObjGrassStruct1_1* ptr2; + s32 i; + s32 j; + f32 distSq; + f32 temp_f22; + + for (i = 0; i < this->unk_2944; i++) { + ptr = &this->unk_144[i]; + + temp_f22 = Math3D_Vec3fDistSq(&ptr->unk_00, &GET_ACTIVE_CAM(globalCtx)->eye); + + if ((temp_f22 < SQ(1280.0f)) && func_809A9110(globalCtx, &ptr->unk_00)) { + ptr->unk_FE |= 1; + + for (j = 0; j < ptr->unk_FC; j++) { + ptr2 = &ptr->unk_0C[j]; + + if (ptr2->unk_0F & 4) { + ptr2->unk_10 = 255; + ptr2->unk_0F &= ~1; + } else { + ptr2->unk_0F |= 1; + if (temp_f22 < SQ(980.0f)) { + ptr2->unk_10 = 255; + } else { + distSq = Math3D_Vec3fDistSq(&ptr2->unk_00, &GET_ACTIVE_CAM(globalCtx)->eye); + if ((distSq <= SQ(1080.0f)) || ((ptr2->unk_0F & 8) && (distSq < SQ(1180.0f)))) { + ptr2->unk_10 = 255; + } else if (distSq >= SQ(1180.0f)) { + ptr2->unk_10 = 0; + } else { + ptr2->unk_10 = (1180.0f - sqrtf(distSq)) * 2.55f; + } + } + } + } + } else { + ptr->unk_FE &= ~1; + } + } +} + +void func_809AA54C(Actor* thisx, GlobalContext* globalCtx2) { + ObjGrass* this = THIS; + GlobalContext* globalCtx = globalCtx2; + Lights* temp_s0; + ObjGrassStruct1* ptr; + s32 i; + s32 j; + Vec3s sp70 = { 0, 0, 0 }; + ObjGrassStruct1_1* ptr2; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); + gSPDisplayList(POLY_OPA_DISP++, gObjGrass_D_809AA9F0); + + for (i = 0; i < this->unk_2944; i++) { + ptr = &this->unk_144[i]; + + if (ptr->unk_FE & 1) { + temp_s0 = LightContext_NewLights(&globalCtx->lightCtx, globalCtx->state.gfxCtx); + Lights_BindAll(temp_s0, globalCtx->lightCtx.listHead, &ptr->unk_00, globalCtx); + Lights_Draw(temp_s0, globalCtx->state.gfxCtx); + + for (j = 0; j < ptr->unk_FC; j++) { + ptr2 = &ptr->unk_0C[j]; + + if ((ptr2->unk_0F & 1) && (ptr2->unk_10 == 255)) { + sp70.y = ptr2->unk_0C; + Matrix_SetStateRotationAndTranslation(ptr2->unk_00.x, ptr2->unk_00.y, ptr2->unk_00.z, &sp70); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + if (ptr2->unk_0F & 2) { + func_809A91FC(&this->unk_2F88[j]); + } + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gObjGrass_D_809AAAE0); + } + } + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_809AA798(Actor* thisx, GlobalContext* globalCtx) { + ObjGrass* this = THIS; + ObjGrassStruct1* ptr; + ObjGrassStruct1_1* ptr2; + s32 i; + s32 j; + Vec3s sp6C = { 0, 0, 0 }; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPDisplayList(POLY_XLU_DISP++, gObjGrass_D_809AAA68); + + for (i = 0; i < this->unk_2944; i++) { + ptr = &this->unk_144[i]; + + if (ptr->unk_FE & 1) { + for (j = 0; j < ptr->unk_FC; j++) { + ptr2 = &ptr->unk_0C[j]; + + if ((ptr2->unk_0F & 1) && (ptr2->unk_10 > 0) && (ptr2->unk_10 < 255)) { + sp6C.y = ptr2->unk_0C; + Matrix_SetStateRotationAndTranslation(ptr2->unk_00.x, ptr2->unk_00.y, ptr2->unk_00.z, &sp6C); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, ptr2->unk_10); + gSPDisplayList(POLY_XLU_DISP++, gObjGrass_D_809AAAE0); + } + } + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void ObjGrass_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjGrass* this = THIS; + + func_809AA278(this, globalCtx); + func_809AA54C(thisx, globalCtx); + func_809AA798(thisx, globalCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.h b/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.h index e05e1618e6..1c87108dfe 100644 --- a/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.h +++ b/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.h @@ -2,12 +2,46 @@ #define Z_OBJ_GRASS_H #include "global.h" +#include "overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.h" struct ObjGrass; +struct ObjGrassCarry; + +typedef struct ObjGrassStruct1_1 { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ s16 unk_0C; + /* 0x0E */ s8 unk_0E; + /* 0x0F */ u8 unk_0F; + /* 0x10 */ u8 unk_10; + /* 0x11 */ UNK_TYPE1 unk_11[0x3]; +} ObjGrassStruct1_1; // size = 0x14 + +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ ObjGrassStruct1_1 unk_0C[12]; + /* 0xFC */ s16 unk_FC; + /* 0xFE */ u8 unk_FE; +} ObjGrassStruct1; // size = 0x100 + +typedef struct { + /* 0x00 */ ColliderCylinder collider; + /* 0x4C */ ObjGrassStruct1_1* unk_4C; +} ObjGrassStruct2; // size = 0x50 typedef struct ObjGrass { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_0144[0x315C]; + /* 0x0144 */ ObjGrassStruct1 unk_144[40]; + /* 0x2944 */ s16 unk_2944; + /* 0x2948 */ ObjGrassStruct2 unk_2948[20]; + /* 0x2F88 */ MtxF unk_2F88[12]; + /* 0x3288 */ s16 unk_3288; + /* 0x328A */ s16 unk_328A; + /* 0x328C */ s16 unk_328C; + /* 0x328E */ s16 unk_328E; + /* 0x3290 */ s16 unk_3290; + /* 0x3292 */ s16 unk_3292; + /* 0x3294 */ ObjGrassStruct1_1* unk_3294; + /* 0x3298 */ struct ObjGrassCarry* unk_3298[2]; } ObjGrass; // size = 0x32A0 extern const ActorInit Obj_Grass_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.c b/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.c index 0a703c9655..2e9df3323b 100644 --- a/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.c +++ b/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.c @@ -5,6 +5,9 @@ */ #include "z_obj_grass_carry.h" +#include "objects/gameplay_field_keep/gameplay_field_keep.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "overlays/actors/ovl_Obj_Grass/z_obj_grass.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_800000) @@ -14,7 +17,18 @@ void ObjGrassCarry_Init(Actor* thisx, GlobalContext* globalCtx); void ObjGrassCarry_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjGrassCarry_Update(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_809AB3C4(ObjGrassCarry* this); +void func_809AB3D8(ObjGrassCarry* this, GlobalContext* globalCtx); +void func_809AB428(ObjGrassCarry* this); +void func_809AB43C(ObjGrassCarry* this, GlobalContext* globalCtx); +void func_809AB474(ObjGrassCarry* this); +void func_809AB4A8(ObjGrassCarry* this, GlobalContext* globalCtx); +void func_809AB5FC(ObjGrassCarry* this); +void func_809AB610(ObjGrassCarry* this, GlobalContext* globalCtx); +void func_809AB6FC(ObjGrassCarry* this); +void func_809AB77C(ObjGrassCarry* this, GlobalContext* globalCtx); +void func_809ABB7C(Actor* this, GlobalContext* globalCtx); + const ActorInit Obj_Grass_Carry_InitVars = { ACTOR_OBJ_GRASS_CARRY, ACTORCAT_PROP, @@ -27,61 +41,320 @@ const ActorInit Obj_Grass_Carry_InitVars = { (ActorFunc)NULL, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_809ABBD0 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_PLAYER, AC_NONE, OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_2, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00400000, 0x00, 0x02 }, { 0x00000000, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NONE, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_PLAYER, + AC_NONE, + OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_2, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00400000, 0x00, 0x02 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NONE, + BUMP_NONE, + OCELEM_ON, + }, { 10, 44, 0, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_809ABC4C[] = { +s16 D_809ABBFC = 0; +s16 D_809ABC00 = 0; +s16 D_809ABC04 = 0; +s16 D_809ABC08 = 0; + +Vec3f D_809ABC0C[] = { + { 0.0f, 0.7071f, 0.7071f }, + { 0.7071f, 0.7071f, 0.0f }, + { 0.0f, 0.7071f, -0.7071f }, + { -0.7071f, 0.7071f, 0.0f }, +}; + +s16 D_809ABC3C[] = { 0x6C, 0x66, 0x60, 0x54, 0x42, 0x37, 0x2A, 0x26 }; + +static InitChainEntry sInitChain[] = { ICHAIN_F32_DIV1000(gravity, -3200, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(terminalVelocity, -17000, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 400, ICHAIN_STOP), }; -#endif +void func_809AAE60(ObjGrassCarry* this) { + this->actor.velocity.y += this->actor.gravity; + if (this->actor.velocity.y < this->actor.terminalVelocity) { + this->actor.velocity.y = this->actor.terminalVelocity; + } +} -extern ColliderCylinderInit D_809ABBD0; -extern InitChainEntry D_809ABC4C[]; +void func_809AAE94(Vec3f* arg0, f32 arg1) { + arg1 += ((Rand_ZeroOne() * 0.2f) - 0.1f) * arg1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AAE60.s") + arg0->x -= (arg0->x * arg1); + arg0->y -= (arg0->y * arg1); + arg0->z -= (arg0->z * arg1); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AAE94.s") +void func_809AAF18(ObjGrassCarry* this) { + func_809AAE60(this); + func_809AAE94(&this->actor.velocity, 0.05f); + Actor_UpdatePos(&this->actor); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AAF18.s") +void func_809AAF58(ObjGrassCarry* this, GlobalContext* globalCtx) { + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 7.5f, 35.0f, 0.0f, 0xC5); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AAF58.s") +void func_809AAF9C(Vec3f* arg0, s16 arg1, GlobalContext* globalCtx) { + if (!(arg1 & 0x10)) { + Item_DropCollectibleRandom(globalCtx, NULL, arg0, arg1 * 0x10); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AAF9C.s") +void func_809AAFE8(Vec3f* arg0, GlobalContext* globalCtx) { + Vec3f spBC; + Vec3f spB0; + s32 i; + Vec3f* ptr; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AAFE8.s") + for (i = 0; i < ARRAY_COUNT(D_809ABC0C); i++) { + ptr = &D_809ABC0C[i]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/ObjGrassCarry_Init.s") + spB0.x = arg0->x + (ptr->x * 8.0f); + spB0.y = arg0->y + (ptr->y * 8.0f) + 10.0f; + spB0.z = arg0->z + (ptr->z * 8.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/ObjGrassCarry_Destroy.s") + spBC.x = (Rand_ZeroOne() - 0.5f) * 8.0f; + spBC.y = Rand_ZeroOne() * 10.0f; + spBC.z = (Rand_ZeroOne() - 0.5f) * 8.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AB3C4.s") + EffectSsKakera_Spawn(globalCtx, &spB0, &spBC, &spB0, -100, 64, 40, 3, 0, + D_809ABC3C[(s32)(Rand_ZeroOne() * 111.1f) & 7], 0, 0, 80, -1, 1, gKakeraLeafMiddle); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AB3D8.s") + spB0.x = arg0->x + (ptr->x * 16.0f); + spB0.y = arg0->y + (ptr->y * 16.0f) + 10.0f; + spB0.z = arg0->z + (ptr->z * 16.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AB428.s") + spBC.x = (Rand_ZeroOne() - 0.5f) * 6.0f; + spBC.y = Rand_ZeroOne() * 10.0f; + spBC.z = (Rand_ZeroOne() - 0.5f) * 6.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AB43C.s") + EffectSsKakera_Spawn(globalCtx, &spB0, &spBC, &spB0, -100, 64, 40, 3, 0, + D_809ABC3C[(s32)(Rand_ZeroOne() * 111.1f) % 7], 0, 0, 80, -1, 1, gKakeraLeafTip); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AB474.s") +void ObjGrassCarry_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjGrassCarry* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AB4A8.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + this->actor.colChkInfo.mass = 80; + func_809AB3C4(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AB5FC.s") +void ObjGrassCarry_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjGrassCarry* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AB610.s") + Collider_DestroyCylinder(globalCtx, &this->collider); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AB6FC.s") + if (this->unk_190 != NULL) { + ObjGrassCarry** carry = &this->unk_190->unk_3298[this->actor.params]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AB77C.s") + if (this == *carry) { + *carry = NULL; + this->unk_190 = NULL; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/ObjGrassCarry_Update.s") +void func_809AB3C4(ObjGrassCarry* this) { + this->actionFunc = func_809AB3D8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809ABB7C.s") +void func_809AB3D8(ObjGrassCarry* this, GlobalContext* globalCtx) { + if (this->unk_190 != NULL) { + if (this->actor.params != this->unk_190->unk_3292) { + func_809AB474(this); + } else { + func_809AB428(this); + } + } +} + +void func_809AB428(ObjGrassCarry* this) { + this->actionFunc = func_809AB43C; +} + +void func_809AB43C(ObjGrassCarry* this, GlobalContext* globalCtx) { + if (this->actor.params != this->unk_190->unk_3292) { + func_809AB474(this); + } +} + +void func_809AB474(ObjGrassCarry* this) { + this->actor.shape.rot.z = 0; + this->actionFunc = func_809AB4A8; + this->unk_194 = NULL; + this->actor.shape.rot.y = this->actor.shape.rot.z; + this->actor.shape.rot.x = this->actor.shape.rot.z; + this->actor.world.rot.z = this->actor.shape.rot.z; + this->actor.world.rot.y = this->actor.shape.rot.z; + this->actor.world.rot.x = this->actor.shape.rot.z; +} + +void func_809AB4A8(ObjGrassCarry* this, GlobalContext* globalCtx) { + ObjGrassCarry* this2 = this; + + if (Actor_HasParent(&this->actor, globalCtx)) { + func_809AB5FC(this); + if (this->unk_194 != NULL) { + this->unk_194->unk_0F |= 4; + } + this->actor.draw = func_809ABB7C; + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; + this->actor.shape.shadowAlpha = 60; + this->actor.shape.shadowScale = 1.0f; + this->unk_190->unk_3292 ^= 1; + this->actor.room = -1; + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_PL_PULL_UP_PLANT); + } else if (this->unk_190->unk_3294 != NULL) { + Player* player = GET_PLAYER(globalCtx); + + this->unk_194 = this->unk_190->unk_3294; + Math_Vec3f_Copy(&this->actor.world.pos, &this->unk_194->unk_00); + this->actor.shape.rot.y = this->actor.world.rot.y = this->unk_194->unk_0C; + this->unk_198 = this2->unk_194->unk_0E; + this->actor.xzDistToPlayer = Actor_XZDistanceBetweenActors(&this->actor, &player->actor); + this->actor.playerHeightRel = Actor_HeightDiff(&this->actor, &player->actor); + this->actor.xyzDistToPlayerSq = SQ(this->actor.xzDistToPlayer) + SQ(this->actor.playerHeightRel); + this->actor.yawTowardsPlayer = Actor_YawBetweenActors(&this->actor, &player->actor); + Actor_LiftActor(&this->actor, globalCtx); + } +} + +void func_809AB5FC(ObjGrassCarry* this) { + this->actionFunc = func_809AB610; +} + +void func_809AB610(ObjGrassCarry* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp30; + s32 sp2C; + + if (Actor_HasNoParent(&this->actor, globalCtx)) { + func_809AB6FC(this); + this->actor.velocity.x = Math_SinS(this->actor.world.rot.y) * this->actor.speedXZ; + this->actor.velocity.z = Math_CosS(this->actor.world.rot.y) * this->actor.speedXZ; + this->actor.gravity = -0.1f; + this->actor.terminalVelocity = -17.0f; + func_809AAF18(this); + func_809AAF58(this, globalCtx); + this->actor.gravity = -3.2f; + } else { + sp30.x = this->actor.world.pos.x; + sp30.y = this->actor.world.pos.y + 20.0f; + sp30.z = this->actor.world.pos.z; + this->actor.floorHeight = + BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->actor.floorPoly, &sp2C, &this->actor, &sp30); + } +} + +void func_809AB6FC(ObjGrassCarry* this) { + this->actionFunc = func_809AB77C; + D_809ABBFC = -0xBB8; + D_809ABC04 = (Rand_ZeroOne() - 0.5f) * 1600.0f; + D_809ABC00 = 0; + D_809ABC08 = 0; + this->unk_19A = 60; +} + +void func_809AB77C(ObjGrassCarry* this, GlobalContext* globalCtx) { + s16 phi_s0; + s32 temp_v0 = (this->collider.base.atFlags & AT_HIT) != 0; + Vec3f sp5C; + s32 i; + + if (temp_v0) { + this->collider.base.atFlags &= ~AT_HIT; + } + + this->unk_19A--; + + if ((this->actor.bgCheckFlags & (1 | 2 | 8)) || temp_v0 || (this->unk_19A <= 0)) { + func_809AAFE8(&this->actor.world.pos, globalCtx); + func_809AAF9C(&this->actor.world.pos, this->unk_198, globalCtx); + + this->actor.draw = NULL; + this->actor.shape.shadowDraw = NULL; + + if (this->unk_190 != NULL) { + this->actor.room = this->unk_190->actor.room; + } + + if (!(this->actor.bgCheckFlags & 0x20)) { + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_PLANT_BROKEN); + } + func_809AB428(this); + return; + } + + if (this->actor.bgCheckFlags & 0x40) { + sp5C.y = this->actor.world.pos.y + this->actor.depthInWater; + + for (phi_s0 = 0, i = 0; i < 4; i++, phi_s0 += 0x4000) { + sp5C.x = (Math_SinS((s32)(Rand_ZeroOne() * 7200.0f) + phi_s0) * 15.0f) + this->actor.world.pos.x; + sp5C.z = (Math_CosS((s32)(Rand_ZeroOne() * 7200.0f) + phi_s0) * 15.0f) + this->actor.world.pos.z; + EffectSsGSplash_Spawn(globalCtx, &sp5C, NULL, NULL, 0, 190); + } + + sp5C.x = this->actor.world.pos.x; + sp5C.z = this->actor.world.pos.z; + + EffectSsGSplash_Spawn(globalCtx, &sp5C, NULL, NULL, 0, 280); + EffectSsGRipple_Spawn(globalCtx, &sp5C, 300, 700, 0); + + this->actor.terminalVelocity = -3.0f; + this->actor.velocity.x *= 0.1f; + this->actor.velocity.y *= 0.4f; + this->actor.velocity.z *= 0.1f; + this->actor.gravity *= 0.5f; + + D_809ABC00 = D_809ABC00 >> 1; + D_809ABBFC = D_809ABBFC >> 1; + D_809ABC08 = D_809ABC08 >> 1; + D_809ABC04 = D_809ABC04 >> 1; + this->actor.bgCheckFlags &= ~0x40; + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_DIVE_INTO_WATER_L); + } + + Math_StepToS(&D_809ABC00, D_809ABBFC, 0x1F4); + Math_StepToS(&D_809ABC08, D_809ABC04, 0xAA); + this->actor.shape.rot.x += D_809ABC00; + this->actor.shape.rot.y += D_809ABC08; + func_809AAF18(this); + func_809AAF58(this, globalCtx); + + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +void ObjGrassCarry_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjGrassCarry* this = THIS; + + if (this->unk_190 == NULL) { + if ((this->actionFunc != func_809AB610) && (this->actionFunc != func_809AB77C)) { + Actor_MarkForDeath(&this->actor); + return; + } + } + + this->actionFunc(this, globalCtx); +} + +void func_809ABB7C(Actor* this, GlobalContext* globalCtx) { + Gfx_DrawDListOpa(globalCtx, gKusaBushType1); +} diff --git a/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.h b/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.h index 90ded06c5c..50d2f61f71 100644 --- a/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.h +++ b/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.h @@ -4,12 +4,18 @@ #include "global.h" struct ObjGrassCarry; +struct ObjGrass; +struct ObjGrassStruct1_1; typedef void (*ObjGrassCarryActionFunc)(struct ObjGrassCarry*, GlobalContext*); typedef struct ObjGrassCarry { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x58]; + /* 0x0144 */ ColliderCylinder collider; + /* 0x0190 */ struct ObjGrass* unk_190; + /* 0x0194 */ struct ObjGrassStruct1_1* unk_194; + /* 0x0198 */ s16 unk_198; + /* 0x019A */ s16 unk_19A; /* 0x019C */ ObjGrassCarryActionFunc actionFunc; } ObjGrassCarry; // size = 0x1A0 diff --git a/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.c b/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.c index b887f7a1b3..10d8891ef7 100644 --- a/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.c +++ b/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.c @@ -5,6 +5,7 @@ */ #include "z_obj_hamishi.h" +#include "objects/gameplay_field_keep/gameplay_field_keep.h" #define FLAGS (ACTOR_FLAG_10) @@ -15,7 +16,6 @@ void ObjHamishi_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjHamishi_Update(Actor* thisx, GlobalContext* globalCtx); void ObjHamishi_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Hamishi_InitVars = { ACTOR_OBJ_HAMISHI, ACTORCAT_PROP, @@ -28,44 +28,261 @@ const ActorInit Obj_Hamishi_InitVars = { (ActorFunc)ObjHamishi_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_809A1AA0 = { - { COLTYPE_HARD, AT_NONE, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x81C37FB6, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HARD, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x81C37FB6, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 50, 70, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit D_809A1ACC = { 0, 12, 60, MASS_IMMOVABLE }; +static CollisionCheckInfoInit sColChkInfoInit = { 0, 12, 60, MASS_IMMOVABLE }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_809A1AE8[] = { +s16 D_809A1AD4[] = { + 145, 135, 115, 85, 75, 53, 45, 40, 35, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 400, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 2000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 250, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 500, ICHAIN_STOP), }; -#endif +void func_809A0F20(Actor* thisx, GlobalContext* globalCtx) { + ObjHamishi* this = THIS; -extern ColliderCylinderInit D_809A1AA0; -extern CollisionCheckInfoInit D_809A1ACC; -extern InitChainEntry D_809A1AE8[]; + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_UpdateCylinder(&this->actor, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hamishi/func_809A0F20.s") +void func_809A0F78(ObjHamishi* this) { + if (this->unk_198 > 0) { + this->unk_198--; + this->unk_19A += 0x1388; + this->unk_19C += 0xE10; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hamishi/func_809A0F78.s") + Math_StepToF(&this->unk_190, 0.0f, 0.15f); + Math_StepToF(&this->unk_194, 0.0f, 40.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hamishi/func_809A10F4.s") + this->actor.world.pos.x = (Math_SinS(this->unk_19A * 4) * this->unk_190) + this->actor.home.pos.x; + this->actor.world.pos.z = (Math_CosS(this->unk_19A * 7) * this->unk_190) + this->actor.home.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hamishi/func_809A13A0.s") + this->actor.shape.rot.x = (s32)(Math_SinS(this->unk_19C * 4) * this->unk_194) + this->actor.home.rot.x; + this->actor.shape.rot.z = (s32)(Math_CosS(this->unk_19C * 7) * this->unk_194) + this->actor.home.rot.z; + } else { + Math_StepToF(&this->actor.world.pos.x, this->actor.home.pos.x, 1.0f); + Math_StepToF(&this->actor.world.pos.z, this->actor.home.pos.z, 1.0f); + Math_ScaledStepToS(&this->actor.shape.rot.x, this->actor.home.rot.x, 0xBB8); + Math_ScaledStepToS(&this->actor.shape.rot.z, this->actor.home.rot.z, 0xBB8); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hamishi/func_809A1408.s") +void func_809A10F4(ObjHamishi* this, GlobalContext* globalCtx) { + s32 i; + Vec3f spC8; + Vec3f spBC; + f32 temp_f20; + s16 temp_s0 = 1000; + s32 gravity; + s32 phi_v0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hamishi/ObjHamishi_Init.s") + for (i = 0; i < ARRAY_COUNT(D_809A1AD4); i++) { + temp_s0 += 0x4E20; + temp_f20 = Rand_ZeroOne() * 10.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hamishi/ObjHamishi_Destroy.s") + spBC.x = (Math_SinS(temp_s0) * temp_f20) + this->actor.world.pos.x; + spBC.y = (Rand_ZeroOne() * 40.0f) + this->actor.world.pos.y + 5.0f; + spBC.z = (Math_CosS(temp_s0) * temp_f20) + this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hamishi/ObjHamishi_Update.s") + temp_f20 = (Rand_ZeroOne() * 10.0f) + 2.0f; + spC8.x = Math_SinS(temp_s0) * temp_f20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hamishi/ObjHamishi_Draw.s") + spC8.y = (Rand_ZeroOne() * 15.0f) + (Rand_ZeroOne() * i * 2.5f); + spC8.z = Math_CosS(temp_s0) * temp_f20; + + if (i == 0) { + phi_v0 = 41; + gravity = -450; + } else if (i < 4) { + phi_v0 = 37; + gravity = -380; + } else { + phi_v0 = 69; + gravity = -320; + } + + EffectSsKakera_Spawn(globalCtx, &spBC, &spC8, &this->actor.world.pos, gravity, phi_v0, 30, 5, 0, D_809A1AD4[i], + 3, 0, 70, 1, GAMEPLAY_FIELD_KEEP, gameplay_field_keep_DL_006420); + } + + func_800BBFB0(globalCtx, &this->actor.world.pos, 140.0f, 6, 180, 90, 1); + func_800BBFB0(globalCtx, &this->actor.world.pos, 140.0f, 12, 80, 90, 1); +} + +void func_809A13A0(ObjHamishi* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp28; + s32 sp24; + + sp28.x = this->actor.world.pos.x; + sp28.y = this->actor.world.pos.y + 30.0f; + sp28.z = this->actor.world.pos.z; + + this->actor.floorHeight = + BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->actor.floorPoly, &sp24, &this->actor, &sp28); +} + +s32 func_809A1408(ObjHamishi* this, GlobalContext* globalCtx) { + s32 pad; + WaterBox* sp30; + f32 sp2C; + s32 sp28; + + if (WaterBox_GetSurfaceImpl(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp2C, + &sp30, &sp28) && + (this->actor.world.pos.y < sp2C)) { + return true; + } + return false; +} + +void ObjHamishi_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjHamishi* this = THIS; + + Actor_ProcessInitChain(&this->actor, sInitChain); + + if (globalCtx->csCtx.state != 0) { + this->actor.uncullZoneForward += 1000.0f; + } + + if (this->actor.shape.rot.y == 0) { + this->actor.shape.rot.y = (u32)Rand_Next() >> 0x10; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actor.home.rot.y = this->actor.shape.rot.y; + } + + func_809A0F20(&this->actor, globalCtx); + CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); + func_809A13A0(this, globalCtx); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 2.3f); + + if (Flags_GetSwitch(globalCtx, OBJHAMISHI_GET_SWITCHFLAG(&this->actor))) { + Actor_MarkForDeath(&this->actor); + return; + } + + this->actor.shape.yOffset = 80.0f; + + if (func_809A1408(this, globalCtx)) { + this->unk_1A2 |= 1; + } +} + +void ObjHamishi_Destroy(Actor* thisx, GlobalContext* globalCtx) { + Collider_DestroyCylinder(globalCtx, &THIS->collider); +} + +void ObjHamishi_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjHamishi* this = THIS; + s32 sp24 = (this->collider.base.acFlags & AC_HIT) != 0; + + func_809A0F78(this); + + if (sp24) { + this->unk_1A1 = 5; + this->collider.base.acFlags &= ~AC_HIT; + } + + if (sp24) { + if (this->collider.info.acHitInfo->toucher.dmgFlags & 0x80000500) { + if (this->collider.info.acHitInfo->toucher.dmgFlags & 0x400) { + this->unk_1A0 = 26; + } else { + this->unk_1A0 = 11; + } + + if (this->collider.info.acHitInfo->toucher.dmgFlags & 0x80000000) { + this->unk_19E = 2; + } else { + this->unk_19E++; + } + + if (this->unk_19E < 2) { + this->unk_198 = 15; + this->unk_190 = 2.0f; + this->unk_194 = 400.0f; + } else { + func_809A10F4(this, globalCtx); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_WALL_BROKEN); + Flags_SetSwitch(globalCtx, OBJHAMISHI_GET_SWITCHFLAG(&this->actor)); + Actor_MarkForDeath(&this->actor); + } + } + } + + if (this->actor.update != NULL) { + if (this->unk_1A1 > 0) { + this->unk_1A1--; + if (this->unk_1A1 == 0) { + this->collider.base.colType = COLTYPE_HARD; + } else { + this->collider.base.colType = COLTYPE_NONE; + } + } + + if (this->unk_1A0 > 0) { + this->unk_1A0--; + } else if ((this->actor.flags & ACTOR_FLAG_40) && (this->actor.xzDistToPlayer < 1000.0f)) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + if (this->actor.xzDistToPlayer < 600.0f) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + } +} + +void ObjHamishi_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjHamishi* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if ((thisx->projectedPos.z <= 2150.0f) || ((this->unk_1A2 & 1) && (thisx->projectedPos.z < 2250.0f))) { + thisx->shape.shadowAlpha = 160; + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, D_801AEFA0); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 170, 130, 255); + gSPDisplayList(POLY_OPA_DISP++, gameplay_field_keep_DL_0061E8); + } else if (thisx->projectedPos.z < 2250.0f) { + f32 sp20 = (2250.0f - thisx->projectedPos.z) * 2.55f; + + thisx->shape.shadowAlpha = sp20 * 0.627451f; + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x08, D_801AEF88); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 170, 130, (s32)sp20); + gSPDisplayList(POLY_XLU_DISP++, gameplay_field_keep_DL_0061E8); + } else { + thisx->shape.shadowAlpha = 0; + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.h b/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.h index 1305f49eeb..da838d4802 100644 --- a/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.h +++ b/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.h @@ -5,9 +5,20 @@ struct ObjHamishi; +#define OBJHAMISHI_GET_SWITCHFLAG(thisx) ((thisx)->params & 0x7F) + typedef struct ObjHamishi { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x60]; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ f32 unk_190; + /* 0x194 */ f32 unk_194; + /* 0x198 */ s16 unk_198; + /* 0x19A */ s16 unk_19A; + /* 0x19C */ s16 unk_19C; + /* 0x19E */ s16 unk_19E; + /* 0x1A0 */ s8 unk_1A0; + /* 0x1A1 */ s8 unk_1A1; + /* 0x1A2 */ u8 unk_1A2; } ObjHamishi; // size = 0x1A4 extern const ActorInit Obj_Hamishi_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.c b/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.c index 0caec6ea4f..f07b9c6d4f 100644 --- a/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.c +++ b/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.c @@ -5,6 +5,7 @@ */ #include "z_obj_hariko.h" +#include "assets/objects/object_hariko/object_hariko.h" #define FLAGS (ACTOR_FLAG_20 | ACTOR_FLAG_2000000) @@ -15,10 +16,12 @@ void ObjHariko_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjHariko_Update(Actor* thisx, GlobalContext* globalCtx); void ObjHariko_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80B66A90(ObjHariko* this, GlobalContext* globalCtx); -void func_80B66AC4(ObjHariko* this, GlobalContext* globalCtx); +void ObjHariko_SetupWait(ObjHariko* this); +void ObjHariko_Wait(ObjHariko* this, GlobalContext* globalCtx); +void ObjHariko_SetupBobHead(ObjHariko* this); +void ObjHariko_BobHead(ObjHariko* this, GlobalContext* globalCtx); +void ObjHariko_CheckForQuakes(ObjHariko* this); -#if 0 const ActorInit Obj_Hariko_InitVars = { ACTOR_OBJ_HARIKO, ACTORCAT_PROP, @@ -31,24 +34,71 @@ const ActorInit Obj_Hariko_InitVars = { (ActorFunc)ObjHariko_Draw, }; -#endif +void ObjHariko_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjHariko* this = THIS; -extern UNK_TYPE D_06000080; + Actor_SetScale(&this->actor, 0.1f); + this->headRotation.x = 0; + this->headRotation.y = 0; + this->headRotation.z = 0; + this->headOffset = 0; + this->bobbleStep = 0.0f; + ObjHariko_SetupWait(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hariko/ObjHariko_Init.s") +void ObjHariko_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hariko/ObjHariko_Destroy.s") +void ObjHariko_SetupWait(ObjHariko* this) { + this->actionFunc = ObjHariko_Wait; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hariko/func_80B66A7C.s") +void ObjHariko_Wait(ObjHariko* this, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hariko/func_80B66A90.s") +void ObjHariko_SetupBobHead(ObjHariko* this) { + this->bobbleStep = 2730.0f; + this->unk154 = 0; + this->actionFunc = ObjHariko_BobHead; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hariko/func_80B66AA0.s") +void ObjHariko_BobHead(ObjHariko* this, GlobalContext* globalCtx) { + this->headOffset += 0x1555; + this->headRotation.x = Math_SinS(this->headOffset) * this->bobbleStep; + this->headRotation.y = Math_CosS(this->headOffset) * this->bobbleStep; + Math_SmoothStepToF(&this->bobbleStep, 0, 0.5f, 18.0f, 18.0f); + if (this->bobbleStep < 182.0f) { + ObjHariko_SetupWait(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hariko/func_80B66AC4.s") +void ObjHariko_CheckForQuakes(ObjHariko* this) { + if (Quake_NumActiveQuakes() != 0) { + ObjHariko_SetupBobHead(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hariko/func_80B66B78.s") +void ObjHariko_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjHariko* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hariko/ObjHariko_Update.s") + this->actionFunc(this, globalCtx); + ObjHariko_CheckForQuakes(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hariko/ObjHariko_Draw.s") +void ObjHariko_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjHariko* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + func_8012C28C(globalCtx->state.gfxCtx); + + Matrix_StatePush(); + Matrix_InsertXRotation_s(this->headRotation.x, MTXMODE_APPLY); + Matrix_RotateY(this->headRotation.y, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gHarikoBodyDL); + gSPDisplayList(POLY_OPA_DISP++, gHarikoFaceDL); + + Matrix_StatePop(); + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.h b/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.h index d9ac284bdc..12d4fe5052 100644 --- a/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.h +++ b/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.h @@ -10,7 +10,10 @@ typedef void (*ObjHarikoActionFunc)(struct ObjHariko*, GlobalContext*); typedef struct ObjHariko { /* 0x0000 */ Actor actor; /* 0x0144 */ ObjHarikoActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x10]; + /* 0x0148 */ f32 bobbleStep; + /* 0x014C */ Vec3s headRotation; + /* 0x0152 */ s16 headOffset; + /* 0x0154 */ s16 unk154; // Set but not used } ObjHariko; // size = 0x158 extern const ActorInit Obj_Hariko_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Hgdoor/z_obj_hgdoor.c b/src/overlays/actors/ovl_Obj_Hgdoor/z_obj_hgdoor.c index 6c37e68b55..4e6b3791de 100644 --- a/src/overlays/actors/ovl_Obj_Hgdoor/z_obj_hgdoor.c +++ b/src/overlays/actors/ovl_Obj_Hgdoor/z_obj_hgdoor.c @@ -96,7 +96,7 @@ void ObjHgdoor_SetupCheckShouldOpen(ObjHgdoor* this) { } void ObjHgdoor_CheckShouldOpen(ObjHgdoor* this, GlobalContext* globalCtx) { - if (!(gSaveContext.weekEventReg[75] & 0x20) && !(gSaveContext.weekEventReg[52] & 0x20) && + if (!(gSaveContext.save.weekEventReg[75] & 0x20) && !(gSaveContext.save.weekEventReg[52] & 0x20) && (this->dyna.actor.xzDistToPlayer < 100.0f) && (this->dyna.actor.playerHeightRel < 40.0f) && OBJHGDOOR_IS_RIGHT_DOOR(&this->dyna.actor)) { ObjHgdoor_SetChild(this, globalCtx); diff --git a/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c b/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c index 74e00403c3..06293bf40c 100644 --- a/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c +++ b/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c @@ -409,7 +409,7 @@ void func_80A54CEC(ObjHugebombiwa* this, GlobalContext* globalCtx) { Flags_SetSwitch(globalCtx, ENHUGEBOMBIWA_GET_7F(&this->actor)); if (!(ENHUGEBOMBIWA_GET_100(&this->actor)) && ((globalCtx->sceneNum == SCENE_17SETUGEN) || (globalCtx->sceneNum == SCENE_17SETUGEN2))) { - gSaveContext.weekEventReg[19] |= 2; + gSaveContext.save.weekEventReg[19] |= 2; } if (!(ENHUGEBOMBIWA_GET_100(&this->actor))) { diff --git a/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.c b/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.c index 05f6b212da..4e09bb6554 100644 --- a/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.c +++ b/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.c @@ -4,6 +4,7 @@ * Description: Switch-Activated Geyser */ +#include "prevent_bss_reordering.h" #include "z_obj_hunsui.h" #include "objects/object_hunsui/object_hunsui.h" diff --git a/src/overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.c b/src/overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.c index f122dca410..d6ac6f3427 100644 --- a/src/overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.c +++ b/src/overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.c @@ -116,7 +116,7 @@ void ObjIcePoly_Init(Actor* thisx, GlobalContext* globalCtx) { thisx->shape.rot.z = -0x500; if (((this->unk_149 != OBJICEPOLY_FF_FF) && Flags_GetSwitch(globalCtx, this->unk_149)) || - ((globalCtx->sceneNum == SCENE_KAJIYA) && (gSaveContext.weekEventReg[33] & 0x80))) { + ((globalCtx->sceneNum == SCENE_KAJIYA) && (gSaveContext.save.weekEventReg[33] & 0x80))) { Actor_MarkForDeath(thisx); return; } diff --git a/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c b/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c index 28de274f5e..582c3a2996 100644 --- a/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c +++ b/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c @@ -16,8 +16,8 @@ void ObjIceblock_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjIceblock_Update(Actor* thisx, GlobalContext* globalCtx); void ObjIceblock_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80A257A0(ObjIceblock* this); -void func_80A257B4(ObjIceblock* this, GlobalContext* globalCtx); +void ObjIceBlock_SetupAttemptSpawnCutscene(ObjIceblock* this); +void ObjIceBlock_AttemptSpawnCutscene(ObjIceblock* this, GlobalContext* globalCtx); void func_80A25824(ObjIceblock* this); void func_80A2586C(ObjIceblock* this, GlobalContext* globalCtx); void func_80A25978(ObjIceblock* this); @@ -77,7 +77,7 @@ static ColliderCylinderInit sCylinderInit = { { 44, 62, -31, { 0, 0, 0 } }, }; -static AnimatedMaterial* D_80A26E7C = NULL; +static AnimatedMaterial* sCubeSublimatingAirTexMat = NULL; s16 func_80A23090(s16 arg0, s16 arg1, s16 arg2) { if (arg0 >= 0) { @@ -915,28 +915,29 @@ void ObjIceblock_Init(Actor* thisx, GlobalContext* globalCtx) { this->dyna.actor.world.rot.z = 0; this->dyna.actor.home.rot.x = 0; this->dyna.actor.home.rot.z = 0; - if (!OBJICEBLOCK_GET_2(&this->dyna.actor)) { + if (!GET_ICEBLOCK_SNAP_ROT(&this->dyna.actor)) { this->dyna.actor.shape.rot.y = (this->dyna.actor.shape.rot.y + 0x2000) & 0xC000; this->dyna.actor.home.rot.y = this->dyna.actor.shape.rot.y; this->dyna.actor.world.rot.y = this->dyna.actor.shape.rot.y; } DynaPolyActor_Init(&this->dyna, 1); - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_ice_block_Colheader_000438); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gIceBlockDynaColHeader); func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit); - if (OBJICEBLOCK_GET_1(&this->dyna.actor)) { + if (GET_ICEBLOCK_ICEBERG(&this->dyna.actor)) { this->collider.dim.yShift = -100; this->collider.dim.height = 126; this->collider.dim.radius = 29; } - if (D_80A26E7C == NULL) { - D_80A26E7C = Lib_SegmentedToVirtual(object_ice_block_Matanimheader_000328); + if (sCubeSublimatingAirTexMat == NULL) { + sCubeSublimatingAirTexMat = Lib_SegmentedToVirtual(gIceBlockCubeSublimatingAirTexAnim); } + // ... this is init, why would this value be set? if (!(this->unk_1B0 & 8)) { parent = this->dyna.actor.parent; if (parent != NULL) { @@ -948,14 +949,14 @@ void ObjIceblock_Init(Actor* thisx, GlobalContext* globalCtx) { } } - if (OBJICEBLOCK_GET_1(&this->dyna.actor)) { + if (GET_ICEBLOCK_ICEBERG(&this->dyna.actor)) { this->unk_2B4 = -1.0f; } this->unk_2B0 = 0; - this->unkFunc = func_80A26B64; - func_80A257A0(this); - this->unk_2AE = 450; + this->extendedDrawFunc = func_80A26B64; + ObjIceBlock_SetupAttemptSpawnCutscene(this); + this->meltTimer = 450; // (450/20) = 22 seconds } void ObjIceblock_Destroy(Actor* thisx, GlobalContext* globalCtx) { @@ -965,15 +966,15 @@ void ObjIceblock_Destroy(Actor* thisx, GlobalContext* globalCtx) { Collider_DestroyCylinder(globalCtx, &this->collider); } -void func_80A257A0(ObjIceblock* this) { - this->actionFunc = func_80A257B4; +void ObjIceBlock_SetupAttemptSpawnCutscene(ObjIceblock* this) { + this->actionFunc = ObjIceBlock_AttemptSpawnCutscene; } -void func_80A257B4(ObjIceblock* this, GlobalContext* globalCtx) { +void ObjIceBlock_AttemptSpawnCutscene(ObjIceblock* this, GlobalContext* globalCtx) { if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); - this->unkFunc = func_80A26BF8; - this->unk_2B1 = 80; + this->extendedDrawFunc = func_80A26BF8; + this->spawnCutsceneTimer = 80; func_80A25824(this); } else { ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); @@ -982,7 +983,7 @@ void func_80A257B4(ObjIceblock* this, GlobalContext* globalCtx) { void func_80A25824(ObjIceblock* this) { this->actionFunc = func_80A2586C; - this->unk_2A0 = 2; + this->stateTimer = 2; Actor_SetScale(&this->dyna.actor, 0.01f); func_80A2319C(this, this->dyna.actor.scale.x); } @@ -990,20 +991,20 @@ void func_80A25824(ObjIceblock* this) { void func_80A2586C(ObjIceblock* this, GlobalContext* globalCtx) { func_80A236D4(this, &this->dyna.actor.home.pos); - if (this->unk_2A0 > 0) { - this->unk_2A0--; + if (this->stateTimer > 0) { + this->stateTimer--; return; } if (Math_StepToF(&this->dyna.actor.scale.x, 0.1f, 0.02f)) { Actor_SetScale(&this->dyna.actor, 0.1f); - if (OBJICEBLOCK_GET_1(&this->dyna.actor)) { + if (GET_ICEBLOCK_ICEBERG(&this->dyna.actor)) { this->unk_2B4 = 0.05f; } func_80A25978(this); } else { Actor_SetScale(&this->dyna.actor, this->dyna.actor.scale.x); - this->unk_2A0 = 2; + this->stateTimer = 2; } func_80A2319C(this, this->dyna.actor.scale.x); @@ -1015,7 +1016,7 @@ void func_80A2586C(ObjIceblock* this, GlobalContext* globalCtx) { void func_80A25978(ObjIceblock* this) { this->actionFunc = func_80A25994; - this->unk_2A0 = 4; + this->stateTimer = 4; } void func_80A25994(ObjIceblock* this, GlobalContext* globalCtx) { @@ -1023,14 +1024,14 @@ void func_80A25994(ObjIceblock* this, GlobalContext* globalCtx) { Vec3f sp30; func_80A236D4(this, &this->dyna.actor.home.pos); - if (this->unk_2A0 > 0) { - this->unk_2A0--; + if (this->stateTimer > 0) { + this->stateTimer--; return; } if (this->dyna.actor.flags & ACTOR_FLAG_40) { func_80A2339C(globalCtx, &this->dyna.actor.world.pos, this->dyna.actor.scale.x, 1.2f, 15); - if (OBJICEBLOCK_GET_1(&this->dyna.actor)) { + if (GET_ICEBLOCK_ICEBERG(&this->dyna.actor)) { sp30.x = this->dyna.actor.world.pos.x; sp30.y = this->dyna.actor.world.pos.y - 30.0f; sp30.z = this->dyna.actor.world.pos.z; @@ -1038,17 +1039,17 @@ void func_80A25994(ObjIceblock* this, GlobalContext* globalCtx) { } } - if (OBJICEBLOCK_GET_1(&this->dyna.actor)) { + if (GET_ICEBLOCK_ICEBERG(&this->dyna.actor)) { this->unk_2B4 = 0.1f; } func_80A25A8C(this); - this->unkFunc = func_80A26B74; + this->extendedDrawFunc = func_80A26B74; } void func_80A25A8C(ObjIceblock* this) { this->actionFunc = func_80A25AA8; - this->unk_2A0 = 2; + this->stateTimer = 2; } void func_80A25AA8(ObjIceblock* this, GlobalContext* globalCtx) { @@ -1056,8 +1057,8 @@ void func_80A25AA8(ObjIceblock* this, GlobalContext* globalCtx) { f32 sp24; s32 temp = func_80A236D4(this, &this->dyna.actor.home.pos); - if (this->unk_2A0 > 0) { - this->unk_2A0--; + if (this->stateTimer > 0) { + this->stateTimer--; return; } @@ -1074,7 +1075,7 @@ void func_80A25AA8(ObjIceblock* this, GlobalContext* globalCtx) { this->dyna.actor.shape.yOffset = 300.0f; this->unk_248.y += sp24; - if (OBJICEBLOCK_GET_1(&this->dyna.actor)) { + if (GET_ICEBLOCK_ICEBERG(&this->dyna.actor)) { this->collider.dim.yShift = -69; } else { this->collider.dim.yShift = 0; @@ -1226,7 +1227,7 @@ void func_80A260E8(ObjIceblock* this) { this->unk_260 = D_80A26FC0[this->unk_26C]; this->unk_25C = 0.0f; this->dyna.actor.velocity.y = 0.0f; - this->unk_2A0 = 15; + this->stateTimer = 15; func_80A24DC4(this); this->actionFunc = func_80A26144; } @@ -1237,8 +1238,8 @@ void func_80A26144(ObjIceblock* this, GlobalContext* globalCtx) { s32 isBool; s32 sp24; - if (this->unk_2A0 > 0) { - this->unk_2A0--; + if (this->stateTimer > 0) { + this->stateTimer--; } Math_StepToF(&this->unk_25C, this->unk_260, 0.75f); @@ -1248,7 +1249,7 @@ void func_80A26144(ObjIceblock* this, GlobalContext* globalCtx) { sp24 = func_80A23F90(this, globalCtx); isBool = sp24 == 0; - if (isBool || sp28 || (this->unk_2A0 == 1)) { + if (isBool || sp28 || (this->stateTimer == 1)) { func_80A2541C(this, globalCtx); } @@ -1275,7 +1276,7 @@ void func_80A26144(ObjIceblock* this, GlobalContext* globalCtx) { void func_80A262BC(ObjIceblock* this) { this->actionFunc = func_80A262EC; this->dyna.actor.velocity.y *= 0.7f; - this->unk_2A0 = -1; + this->stateTimer = -1; } void func_80A262EC(ObjIceblock* this, GlobalContext* globalCtx) { @@ -1289,20 +1290,20 @@ void func_80A262EC(ObjIceblock* this, GlobalContext* globalCtx) { func_80A2541C(this, globalCtx); } - if (this->unk_2A0 > 0) { - this->unk_2A0--; + if (this->stateTimer > 0) { + this->stateTimer--; } - if (this->unk_2A0 == -1) { + if (this->stateTimer == -1) { if ((this->dyna.actor.velocity.y < 0.0f) && (this->dyna.actor.world.pos.y < this->unk_244) && ((this->unk_244 - (600.0f * this->dyna.actor.scale.y)) <= this->dyna.actor.world.pos.y)) { func_80A24BDC(this, globalCtx, 1.0f, 0.9f, 11); func_80A24B74(this, globalCtx); - this->unk_2A0 = 3; + this->stateTimer = 3; } else { - this->unk_2A0 = 0; + this->stateTimer = 0; } - } else if (this->unk_2A0 == 1) { + } else if (this->stateTimer == 1) { func_80A24BDC(this, globalCtx, 0.7f, 1.3f, 6); func_80A24B74(this, globalCtx); } @@ -1344,7 +1345,7 @@ void func_80A26574(ObjIceblock* this) { this->unk_27C.unk_18 = 500; this->unk_27C.unk_22 = 500; this->unk_27C.unk_08 = 7.0f; - this->unk_2A0 = 40; + this->stateTimer = 40; } void func_80A265C0(ObjIceblock* this, GlobalContext* globalCtx) { @@ -1355,11 +1356,11 @@ void func_80A265C0(ObjIceblock* this, GlobalContext* globalCtx) { func_80A2541C(this, globalCtx); } - if (this->unk_2A0 > 0) { - this->unk_2A0--; + if (this->stateTimer > 0) { + this->stateTimer--; } else { ptr = &this->unk_27C; - this->unk_2A0 = Rand_S16Offset(30, 60); + this->stateTimer = Rand_S16Offset(30, 60); ptr->unk_0C = Rand_S16Offset(300, 300); ptr->unk_0E = Rand_S16Offset(900, 600); ptr->unk_04 = (2.0f * Rand_ZeroOne()) + 1.0f; @@ -1400,7 +1401,7 @@ void func_80A266E0(ObjIceblock* this, GlobalContext* globalCtx) { actor->scale.z = actor->scale.x; } - if (OBJICEBLOCK_GET_1(&this->dyna.actor)) { + if (GET_ICEBLOCK_ICEBERG(&this->dyna.actor)) { this->unk_2B4 = actor->scale.y; this->collider.dim.height = (s32)(actor->scale.y * 1230.0f) + 1; this->collider.dim.yShift = actor->scale.y * -1000.0f; @@ -1441,14 +1442,14 @@ void ObjIceblock_Update(Actor* thisx, GlobalContext* globalCtx) { } if ((this->unk_2B0 == 1) || (this->unk_2B0 == 2) || (this->unk_2B0 == 3)) { - if (this->unk_2AE > 0) { - this->unk_2AE--; + if (this->meltTimer > 0) { + this->meltTimer--; } } if (((this->collider.base.acFlags & AC_HIT) && (this->collider.info.acHitInfo->toucher.dmgFlags & 0x800)) || - (this->unk_2AE == 0)) { - this->unk_2AE = -1; + (this->meltTimer == 0)) { + this->meltTimer = -1; this->unk_2B0 = 4; this->unk_1B0 &= ~0x100; if (this->unk_1B0 & 1) { @@ -1458,9 +1459,10 @@ void ObjIceblock_Update(Actor* thisx, GlobalContext* globalCtx) { func_80A266C4(this); } - if (this->unk_2B1 > 0) { - this->unk_2B1--; - if (this->unk_2B1 == 0) { + // this could have been in the actionFunc? + if (this->spawnCutsceneTimer > 0) { + this->spawnCutsceneTimer--; + if (this->spawnCutsceneTimer == 0) { ActorCutscene_Stop(this->dyna.actor.cutscene); } } @@ -1482,7 +1484,7 @@ void ObjIceblock_Update(Actor* thisx, GlobalContext* globalCtx) { Collider_UpdateCylinder(&this->dyna.actor, &this->collider); if (this->unk_1B0 & 0x10) { - if (OBJICEBLOCK_GET_1(&this->dyna.actor) && (this->unk_2B4 > 0.0f)) { + if (GET_ICEBLOCK_ICEBERG(&this->dyna.actor) && (this->unk_2B4 > 0.0f)) { this->collider.base.ocFlags1 &= ~OC1_NO_PUSH; this->collider.base.ocFlags1 |= (OC1_TYPE_2 | OC1_TYPE_1 | OC1_TYPE_PLAYER); this->collider.info.bumper.dmgFlags |= @@ -1507,14 +1509,16 @@ void ObjIceblock_Update(Actor* thisx, GlobalContext* globalCtx) { void func_80A26B64(ObjIceblock* this, GlobalContext* globalCtx) { } +// draw func void func_80A26B74(ObjIceblock* this, GlobalContext* globalCtx) { - Gfx_DrawDListXlu(globalCtx, object_ice_block_DL_0001A0); - if (OBJICEBLOCK_GET_1(&this->dyna.actor) && (this->unk_2B4 > 0.0f)) { - AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(object_ice_block_Matanimheader_0009D0)); - Gfx_DrawDListXlu(globalCtx, object_ice_block_DL_0007F0); + Gfx_DrawDListXlu(globalCtx, gIceBlockCubeDL); + if (GET_ICEBLOCK_ICEBERG(&this->dyna.actor) && (this->unk_2B4 > 0.0f)) { + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(gIceBlockIceBergSublimatingAirTexAnim)); + Gfx_DrawDListXlu(globalCtx, gIceBlockIceBergDL); } } +// draw func void func_80A26BF8(ObjIceblock* this, GlobalContext* globalCtx) { s32 pad[2]; ObjIceBlockUnkStruct* ptr; @@ -1535,17 +1539,17 @@ void func_80A26BF8(ObjIceblock* this, GlobalContext* globalCtx) { Matrix_Scale(ptr->unk_04, ptr->unk_08, ptr->unk_0C, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_ice_block_DL_0001A0); + gSPDisplayList(POLY_XLU_DISP++, gIceBlockCubeDL); } - if (OBJICEBLOCK_GET_1(&this->dyna.actor) && (this->unk_2B4 > 0.0f)) { - AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(object_ice_block_Matanimheader_0009D0)); + if (GET_ICEBLOCK_ICEBERG(&this->dyna.actor) && (this->unk_2B4 > 0.0f)) { + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(gIceBlockIceBergSublimatingAirTexAnim)); Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y - 20.0f, this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); Matrix_Scale(this->unk_2B4, this->unk_2B4, this->unk_2B4, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_ice_block_DL_0007F0); + gSPDisplayList(POLY_XLU_DISP++, gIceBlockIceBergDL); } CLOSE_DISPS(globalCtx->state.gfxCtx); @@ -1554,7 +1558,7 @@ void func_80A26BF8(ObjIceblock* this, GlobalContext* globalCtx) { void ObjIceblock_Draw(Actor* thisx, GlobalContext* globalCtx) { ObjIceblock* this = THIS; - AnimatedMat_Draw(globalCtx, D_80A26E7C); - this->unkFunc(this, globalCtx); + AnimatedMat_Draw(globalCtx, sCubeSublimatingAirTexMat); + this->extendedDrawFunc(this, globalCtx); func_80A24AA8(this, globalCtx); } diff --git a/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.h b/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.h index 6a4875bb31..52460b87d8 100644 --- a/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.h +++ b/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.h @@ -6,10 +6,10 @@ struct ObjIceblock; typedef void (*ObjIceblockActionFunc)(struct ObjIceblock*, GlobalContext*); -typedef void (*ObjIceblockUnkFunc)(struct ObjIceblock*, GlobalContext*); +typedef void (*ObjIceblockExtendedDrawFunc)(struct ObjIceblock*, GlobalContext*); -#define OBJICEBLOCK_GET_2(thisx) (((thisx)->params >> 1) & 1) -#define OBJICEBLOCK_GET_1(thisx) ((thisx)->params & 1) +#define GET_ICEBLOCK_SNAP_ROT(thisx) (((thisx)->params >> 1) & 1) +#define GET_ICEBLOCK_ICEBERG(thisx) ((thisx)->params & 1) typedef struct { /* 0x00 */ s16 unk_00; @@ -51,7 +51,7 @@ typedef struct ObjIceblock { /* 0x0000 */ DynaPolyActor dyna; /* 0x015C */ ColliderCylinder collider; /* 0x01A8 */ ObjIceblockActionFunc actionFunc; - /* 0x01AC */ ObjIceblockUnkFunc unkFunc; + /* 0x01AC */ ObjIceblockExtendedDrawFunc extendedDrawFunc; /* 0x01B0 */ s32 unk_1B0; /* 0x01B4 */ ObjIceBlockUnkStruct unk_1B4[4]; /* 0x01F4 */ ObjIceBlockUnkStruct2 unk_1F4[5]; @@ -67,14 +67,14 @@ typedef struct ObjIceblock { /* 0x0276 */ s16 unk_276; /* 0x0278 */ s16 unk_278; /* 0x027C */ ObjIceBlockUnkStruct4 unk_27C; - /* 0x02A0 */ s16 unk_2A0; + /* 0x02A0 */ s16 stateTimer; // re-used per-actionFunc /* 0x02A2 */ s16 unk_2A2; /* 0x02A4 */ f32 unk_2A4; /* 0x02A8 */ f32 unk_2A8; /* 0x02AC */ s16 unk_2AC; - /* 0x02AE */ s16 unk_2AE; + /* 0x02AE */ s16 meltTimer; // starts at 450 frames = 22 seconds /* 0x02B0 */ s8 unk_2B0; - /* 0x02B1 */ s8 unk_2B1; + /* 0x02B1 */ s8 spawnCutsceneTimer; /* 0x02B4 */ f32 unk_2B4; } ObjIceblock; // size = 0x2B8 diff --git a/src/overlays/actors/ovl_Obj_Jgame_Light/z_obj_jgame_light.h b/src/overlays/actors/ovl_Obj_Jgame_Light/z_obj_jgame_light.h index 12d958e730..50023c252d 100644 --- a/src/overlays/actors/ovl_Obj_Jgame_Light/z_obj_jgame_light.h +++ b/src/overlays/actors/ovl_Obj_Jgame_Light/z_obj_jgame_light.h @@ -5,6 +5,8 @@ struct ObjJgameLight; +#define OBJJGAMELIGHT_GET_7F(thisx) ((thisx)->params & 0x7F) + typedef struct ObjJgameLight { /* 0x000 */ Actor actor; /* 0x144 */ char unk_144[0x78]; diff --git a/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.c b/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.c index 82e4e4de2d..d6a2df4cfd 100644 --- a/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.c +++ b/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.c @@ -5,6 +5,7 @@ */ #include "z_obj_kendo_kanban.h" +#include "objects/object_dora/object_dora.h" #define FLAGS 0x00000000 @@ -15,11 +16,14 @@ void ObjKendoKanban_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjKendoKanban_Update(Actor* thisx, GlobalContext* globalCtx); void ObjKendoKanban_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80B65880(ObjKendoKanban* this); void func_80B65894(ObjKendoKanban* this, GlobalContext* globalCtx); +void func_80B658A4(ObjKendoKanban* this, GlobalContext* globalCtx); void func_80B65CE0(ObjKendoKanban* this, GlobalContext* globalCtx); void func_80B65D68(ObjKendoKanban* this, GlobalContext* globalCtx); +void func_80B65DA8(ObjKendoKanban* this, GlobalContext* globalCtx); +s32 func_80B6618C(ObjKendoKanban* this, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Kendo_Kanban_InitVars = { ACTOR_OBJ_KENDO_KANBAN, ACTORCAT_NPC, @@ -32,33 +36,89 @@ const ActorInit Obj_Kendo_Kanban_InitVars = { (ActorFunc)ObjKendoKanban_Draw, }; -// static ColliderTrisElementInit sTrisElementsInit[2] = { -static ColliderTrisElementInit D_80B6673C[2] = { +Vec3f D_80B66660 = { -1.5f, 10.0f, 0.5f }; +Vec3f D_80B6666C = { 1.5f, 10.0f, 0.5f }; +Vec3f D_80B66678 = { 0.0f, 4.0f, -1.0f }; +Vec3f D_80B66684 = { 1.0f, 7.0f, 4.0f }; +Vec3f D_80B66690 = { -150.0f, 425.0f, 40.0f }; +Vec3f D_80B6669C = { 150.0f, 425.0f, 40.0f }; +Vec3f D_80B666A8 = { 0.0f, 140.0f, 40.0f }; +Vec3f D_80B666B4 = { 0.0f, 565.0f, 40.0f }; + +Gfx* D_80B666C0 = gKendoKanbanTopRightDL; +Gfx* D_80B666C4 = gKendoKanbanTopLeftDL; +Gfx* D_80B666C8 = gKendoKanbanBottomRightDL; +Gfx* D_80B666CC = gKendoKanbanBottomLeftDL; + +Vec3f D_80B666D0 = { -300.0f, 850.0f, 40.0f }; +Vec3f D_80B666DC = { 10.0f, 850.0f, 40.0f }; +Vec3f D_80B666E8 = { 300.0f, 850.0f, 40.0f }; +Vec3f D_80B666F4 = { -300.0f, 310.0f, 40.0f }; +Vec3f D_80B66700 = { 0.0f, 280.0f, 40.0f }; +Vec3f D_80B6670C = { 300.0f, 250.0f, 40.0f }; +Vec3f D_80B66718 = { -300.0f, 10.0f, 40.0f }; +Vec3f D_80B66724 = { 0.0f, 10.0f, 40.0f }; +Vec3f D_80B66730 = { 300.0f, 10.0f, 40.0f }; + +static ColliderTrisElementInit sTrisElementsInit[] = { { - { ELEMTYPE_UNK5, { 0x00000000, 0x00, 0x00 }, { 0x01000202, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK5, + { 0x00000000, 0x00, 0x00 }, + { 0x01000202, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { -300.0f, 850.0f, 40.0f }, { -300.0f, 10.0f, 40.0f }, { 300.0f, 850.0f, 40.0f } } }, }, { - { ELEMTYPE_UNK5, { 0x00000000, 0x00, 0x00 }, { 0x01000202, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK5, + { 0x00000000, 0x00, 0x00 }, + { 0x01000202, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 300.0f, 850.0f, 40.0f }, { 300.0f, 10.0f, 40.0f }, { -300.0f, 10.0f, 40.0f } } }, }, }; -// static ColliderTrisInit sTrisInit = { -static ColliderTrisInit D_80B667B4 = { - { COLTYPE_TREE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_TYPE_1, COLSHAPE_TRIS, }, - 2, D_80B6673C, // sTrisElementsInit, +static ColliderTrisInit sTrisInit = { + { + COLTYPE_TREE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_1, + COLSHAPE_TRIS, + }, + 2, + sTrisElementsInit, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B667C4 = { - { COLTYPE_TREE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_TREE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 33, 80, 0, { 0, 0, 0 } }, }; -// static DamageTable sDamageTable = { -static DamageTable D_80B667F0 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x0), /* Deku Stick */ DMG_ENTRY(0, 0xF), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -93,41 +153,357 @@ static DamageTable D_80B667F0 = { /* Powder Keg */ DMG_ENTRY(0, 0x0), }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80B66810 = { 8, 0, 0, 0, MASS_HEAVY }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 8, 0, 0, 0, MASS_HEAVY }; -#endif +Vec3f D_80B6681C = { 0.0f, 0.0f, 0.0f }; +Vec3f D_80B66828 = { 1.0f, 0.0f, 0.0f }; -extern ColliderTrisElementInit D_80B6673C[2]; -extern ColliderTrisInit D_80B667B4; -extern ColliderCylinderInit D_80B667C4; -extern DamageTable D_80B667F0; -extern CollisionCheckInfoInit2 D_80B66810; +void ObjKendoKanban_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad[2]; + ObjKendoKanban* this = THIS; + Vec3f sp70[3]; + s32 i; + s32 j; -extern UNK_TYPE D_06000180; + Actor_SetScale(&this->actor, 0.1f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kendo_Kanban/ObjKendoKanban_Init.s") + Collider_InitCylinder(globalCtx, &this->colliderCylinder); + Collider_SetCylinder(globalCtx, &this->colliderCylinder, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + Collider_InitTris(globalCtx, &this->colliderTris); + Collider_SetTris(globalCtx, &this->colliderTris, &this->actor, &sTrisInit, this->colliderTrisElements); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kendo_Kanban/ObjKendoKanban_Destroy.s") + Matrix_SetStateRotationAndTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + &this->actor.shape.rot); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kendo_Kanban/func_80B65880.s") + for (i = 0; i < ARRAY_COUNT(this->colliderTrisElements); i++) { + for (j = 0; j < ARRAY_COUNT(sp70); j++) { + Matrix_MultiplyVector3fByState(&sTrisElementsInit[i].dim.vtx[j], &sp70[j]); + } + Collider_SetTrisVertices(&this->colliderTris, i, &sp70[0], &sp70[1], &sp70[2]); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kendo_Kanban/func_80B65894.s") + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kendo_Kanban/func_80B658A4.s") + this->unk_30C = OBJKENDOKANBAN_GET_F(&this->actor); + this->actor.gravity = -2.0f; + this->unk_2CC = D_80B6681C; + this->unk_2D8 = D_80B6681C; + this->unk_2E4 = D_80B6681C; + this->unk_2F0 = D_80B66828; + this->unk_302 = 0; + this->unk_304 = 0; + this->unk_2FC = -1; + this->unk_300 = 0; + this->unk_308 = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kendo_Kanban/func_80B65CE0.s") + for (i = 0; i < ARRAY_COUNT(this->unk_26C); i++) { + this->unk_26C[i] = this->unk_29C[i] = D_80B6681C; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kendo_Kanban/func_80B65D54.s") + this->unk_30A = 0; + if (this->unk_30C == OBJKENDOKANBAN_F_0) { + func_80B65880(this); + } else { + func_80B658A4(this, globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kendo_Kanban/func_80B65D68.s") +void ObjKendoKanban_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjKendoKanban* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kendo_Kanban/func_80B65DA8.s") + Collider_DestroyCylinder(globalCtx, &this->colliderCylinder); + Collider_DestroyTris(globalCtx, &this->colliderTris); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kendo_Kanban/func_80B6618C.s") +void func_80B65880(ObjKendoKanban* this) { + this->actionFunc = func_80B65894; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kendo_Kanban/func_80B66304.s") +void func_80B65894(ObjKendoKanban* this, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kendo_Kanban/ObjKendoKanban_Update.s") +void func_80B658A4(ObjKendoKanban* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + if (this->unk_30C == OBJKENDOKANBAN_F_0) { + if ((player->swordAnimation == 0) || (player->swordAnimation == 1) || (player->swordAnimation == 0x14)) { + this->unk_30C = (OBJKENDOKANBAN_F_4 | OBJKENDOKANBAN_F_1); + this->unk_304 = 0x71C; + this->actor.velocity = D_80B6666C; + this->unk_2CC = D_80B6669C; + + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_OBJ_KENDO_KANBAN, + this->actor.home.pos.x - 5.0f, this->actor.home.pos.y, this->actor.home.pos.z, 0, 0, 0, + 0xA); + + this->unk_29C[0] = D_80B666DC; + this->unk_29C[1] = D_80B666E8; + this->unk_29C[2] = D_80B66730; + this->unk_29C[3] = D_80B66724; + } else { + this->unk_30C = (OBJKENDOKANBAN_F_8 | OBJKENDOKANBAN_F_4); + this->unk_304 = -0x71C; + this->actor.velocity = D_80B66678; + this->unk_2CC = D_80B666A8; + + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_OBJ_KENDO_KANBAN, + this->actor.home.pos.x, this->actor.home.pos.y + 5.0f, this->actor.home.pos.z, 0, 0, 0, + 3); + + this->unk_29C[0] = D_80B666F4; + this->unk_29C[1] = D_80B6670C; + this->unk_29C[2] = D_80B66730; + this->unk_29C[3] = D_80B66718; + } + } else if (this->unk_30C == (OBJKENDOKANBAN_F_8 | OBJKENDOKANBAN_F_2)) { + this->unk_304 = 0x71C; + this->actor.velocity = D_80B66660; + this->unk_2CC = D_80B66690; + + this->unk_29C[0] = D_80B666D0; + this->unk_29C[1] = D_80B666DC; + this->unk_29C[2] = D_80B66724; + this->unk_29C[3] = D_80B66718; + } else if (this->unk_30C == (OBJKENDOKANBAN_F_2 | OBJKENDOKANBAN_F_1)) { + this->unk_304 = 0x71C; + this->actor.velocity = D_80B66684; + this->unk_2CC = D_80B666B4; + + this->unk_29C[0] = D_80B666D0; + this->unk_29C[1] = D_80B666E8; + this->unk_29C[2] = D_80B6670C; + this->unk_29C[3] = D_80B666F4; + } + + this->unk_30A = 0; + this->actionFunc = func_80B65CE0; +} + +void func_80B65CE0(ObjKendoKanban* this, GlobalContext* globalCtx) { + this->actor.velocity.y += this->actor.gravity; + Actor_UpdatePos(&this->actor); + this->unk_302 += this->unk_304; + func_80B65DA8(this, globalCtx); + if (this->actor.world.pos.y < -200.0f) { + this->actor.world.pos.y = -200.0f; + } +} + +void func_80B65D54(ObjKendoKanban* this) { + this->actionFunc = func_80B65D68; +} + +void func_80B65D68(ObjKendoKanban* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (func_80B6618C(this, globalCtx) == 1) { + player->unk_AC0 = 700.0f; + } +} + +void func_80B65DA8(ObjKendoKanban* this, GlobalContext* globalCtx) { + Vec3f sp5C; + s32 pad[2]; + Vec3f sp48; + s32 pad2; + s32 index = 0; + s32 i; + f32 sp38; + + sp5C = this->unk_26C[0]; + sp48 = this->actor.world.pos; + + sp48.x -= this->unk_2D8.x; + sp48.y -= this->unk_2D8.y; + sp48.z -= this->unk_2D8.z; + + sp38 = (this->unk_2F0.x * sp48.z) + (this->unk_2F0.z * -sp48.x); + + if (sp38 < 0.0f) { + this->unk_304 += 0x64; + } else { + this->unk_304 -= 0x64; + } + + for (i = 0; i < ARRAY_COUNT(this->unk_26C); i++) { + if (this->unk_26C[i].y < sp5C.y) { + sp5C = this->unk_26C[i]; + index = i; + } + } + + if (index != this->unk_2FC) { + this->unk_300 = 1; + this->unk_2FC = index; + this->unk_2E4 = this->unk_29C[index]; + + Matrix_StatePush(); + Matrix_SetStateRotationAndTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + &this->actor.shape.rot); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_MultiplyVector3fByState(&this->unk_2E4, &this->actor.world.pos); + this->actor.world.pos = sp5C; + this->actor.prevPos = this->actor.world.pos; + Matrix_StatePop(); + } + + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + + if (this->actor.bgCheckFlags & 1) { + this->actor.velocity.x *= 0.8f; + this->actor.velocity.z *= 0.8f; + } + + if (this->unk_300 == 1) { + if (this->unk_308 >= 7) { + s16 temp_v0_3 = this->unk_302 & 0x3FFF; + + if (temp_v0_3 >= 0x2000) { + temp_v0_3 -= 0x4000; + } + this->unk_302 -= temp_v0_3; + this->unk_304 = 0; + func_80B65D54(this); + return; + } + + if (this->actor.bgCheckFlags & 2) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WOODPLATE_BOUND); + this->unk_300 = 0; + this->actor.velocity.y *= 0.5f; + } else if (this->actor.bgCheckFlags & 1) { + this->unk_308++; + this->unk_300 = 0; + this->actor.velocity.x *= 0.3f; + this->actor.velocity.z *= 0.3f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WOODPLATE_BOUND); + + if (sp38 > 0.0f) { + if (this->unk_304 > 0) { + this->unk_304 *= 1.2f; + } else { + this->unk_304 *= -0.6f; + } + } else if (this->unk_304 < 0) { + this->unk_304 *= 1.2f; + } else { + this->unk_304 *= -0.6f; + } + } + } +} + +s32 func_80B6618C(ObjKendoKanban* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 phi_v0; + s32 phi_v1 = 0; + s32 i; + f32 x; + f32 z; + f32 x2; + f32 z2; + + for (i = 0; i < ARRAY_COUNT(this->unk_26C); i++) { + if (i != 3) { + phi_v0 = i + 1; + } else { + phi_v0 = 0; + } + + z = this->unk_26C[i].z - player->actor.world.pos.z; + x = this->unk_26C[i].x - player->actor.world.pos.x; + + z2 = (this->unk_26C[phi_v0].z - player->actor.world.pos.z); + x2 = (this->unk_26C[phi_v0].x - player->actor.world.pos.x); + + if ((x * z2) < (z * x2)) { + if (phi_v1 == 0) { + phi_v1 = 1; + } else if (phi_v1 != 1) { + return false; + } + } else if (phi_v1 == 0) { + phi_v1 = -1; + } else if (phi_v1 != -1) { + return false; + } + } + return true; +} + +void func_80B66304(ObjKendoKanban* this, GlobalContext* globalCtx) { + if ((this->actionFunc != func_80B65CE0) && (this->actionFunc != func_80B65D68)) { + if (this->colliderTris.base.acFlags & AC_HIT) { + this->colliderTris.base.acFlags &= ~AC_HIT; + func_80B658A4(this, globalCtx); + } + + Collider_UpdateCylinder(&this->actor, &this->colliderCylinder); + this->colliderCylinder.dim.pos.z -= (s16)(20.0f * Math_CosS(this->actor.shape.rot.y)); + this->colliderCylinder.dim.pos.x -= (s16)(20.0f * Math_SinS(this->actor.shape.rot.y)); + + if (this->actionFunc == func_80B65894) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderTris.base); + } + + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); + } +} + +void ObjKendoKanban_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjKendoKanban* this = THIS; + + this->actionFunc(this, globalCtx); + + func_80B66304(this, globalCtx); +} + +#ifdef NON_MATCHING +void ObjKendoKanban_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjKendoKanban* this = THIS; + s32 i; + Gfx* poly; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + if (this->unk_30C == OBJKENDOKANBAN_F_0) { + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gKendoKanbanDL); + } else { + Matrix_InsertRotationAroundUnitVector_s(this->unk_302, &this->unk_2F0, MTXMODE_APPLY); + Matrix_InsertTranslation(-this->unk_2E4.x, -this->unk_2E4.y, -this->unk_2E4.z, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + if (this->unk_30C & OBJKENDOKANBAN_F_1) { + gSPDisplayList(POLY_OPA_DISP++, D_80B666C0); + } + + if (this->unk_30C & OBJKENDOKANBAN_F_2) { + gSPDisplayList(POLY_OPA_DISP++, D_80B666C4); + } + + if (this->unk_30C & OBJKENDOKANBAN_F_4) { + gSPDisplayList(POLY_OPA_DISP++, D_80B666C8); + } + + if (this->unk_30C & OBJKENDOKANBAN_F_8) { + gSPDisplayList(POLY_OPA_DISP++, D_80B666CC); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + for (i = 0; i < ARRAY_COUNT(this->unk_26C); i++) { + Matrix_MultiplyVector3fByState(&this->unk_29C[i], &this->unk_26C[i]); + } + + Matrix_MultiplyVector3fByState(&this->unk_2CC, &this->unk_2D8); +} +#else #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kendo_Kanban/ObjKendoKanban_Draw.s") +#endif diff --git a/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.h b/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.h index 6adb95dd1e..a8c4f8d7c4 100644 --- a/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.h +++ b/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.h @@ -7,11 +7,34 @@ struct ObjKendoKanban; typedef void (*ObjKendoKanbanActionFunc)(struct ObjKendoKanban*, GlobalContext*); +#define OBJKENDOKANBAN_GET_F(thisx) ((thisx)->params & 0xF) + +#define OBJKENDOKANBAN_F_0 0 +#define OBJKENDOKANBAN_F_1 (1 << 0) +#define OBJKENDOKANBAN_F_2 (1 << 1) +#define OBJKENDOKANBAN_F_4 (1 << 2) +#define OBJKENDOKANBAN_F_8 (1 << 3) + typedef struct ObjKendoKanban { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x124]; + /* 0x0144 */ ColliderCylinder colliderCylinder; + /* 0x0190 */ ColliderTris colliderTris; + /* 0x01B0 */ ColliderTrisElement colliderTrisElements[2]; /* 0x0268 */ ObjKendoKanbanActionFunc actionFunc; - /* 0x026C */ char unk_26C[0xA4]; + /* 0x026C */ Vec3f unk_26C[4]; + /* 0x029C */ Vec3f unk_29C[4]; + /* 0x02CC */ Vec3f unk_2CC; + /* 0x02D8 */ Vec3f unk_2D8; + /* 0x02E4 */ Vec3f unk_2E4; + /* 0x02F0 */ Vec3f unk_2F0; + /* 0x02FC */ s32 unk_2FC; + /* 0x0300 */ s16 unk_300; + /* 0x0302 */ s16 unk_302; + /* 0x0304 */ s16 unk_304; + /* 0x0306 */ UNK_TYPE1 pad306[2]; + /* 0x0308 */ s16 unk_308; + /* 0x030A */ s16 unk_30A; + /* 0x030C */ u8 unk_30C; } ObjKendoKanban; // size = 0x310 extern const ActorInit Obj_Kendo_Kanban_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Milk_Bin/z_obj_milk_bin.c b/src/overlays/actors/ovl_Obj_Milk_Bin/z_obj_milk_bin.c index 81090139ba..a32f791bc8 100644 --- a/src/overlays/actors/ovl_Obj_Milk_Bin/z_obj_milk_bin.c +++ b/src/overlays/actors/ovl_Obj_Milk_Bin/z_obj_milk_bin.c @@ -58,7 +58,7 @@ void ObjMilkBin_Init(Actor* thisx, GlobalContext* globalCtx) { this->disableDraw = 0; this->type = thisx->params; - if ((this->type == OBJ_MILK_BIN_TYPE_2) && !(gSaveContext.weekEventReg[52] & 1)) { + if ((this->type == OBJ_MILK_BIN_TYPE_2) && !(gSaveContext.save.weekEventReg[52] & 1)) { this->disableDraw |= 1; } } @@ -74,14 +74,14 @@ void ObjMilkBin_Update(Actor* thisx, GlobalContext* globalCtx2) { ObjMilkBin* this = THIS; if (this->type == OBJ_MILK_BIN_TYPE_1) { - if (gSaveContext.weekEventReg[22] & 1) { - if (((gSaveContext.day == 2) && (gSaveContext.isNight == 1)) || (gSaveContext.day >= 3)) { + if (gSaveContext.save.weekEventReg[22] & 1) { + if (((gSaveContext.save.day == 2) && (gSaveContext.save.isNight == 1)) || (gSaveContext.save.day >= 3)) { Actor_MarkForDeath(&this->actor); return; } } } else if (this->type == OBJ_MILK_BIN_TYPE_2) { - if (gSaveContext.weekEventReg[52] & 1) { + if (gSaveContext.save.weekEventReg[52] & 1) { this->disableDraw &= ~1; } else { this->disableDraw |= 1; diff --git a/src/overlays/actors/ovl_Obj_Moon_Stone/z_obj_moon_stone.c b/src/overlays/actors/ovl_Obj_Moon_Stone/z_obj_moon_stone.c index a0fc2eff7f..546f0db16e 100644 --- a/src/overlays/actors/ovl_Obj_Moon_Stone/z_obj_moon_stone.c +++ b/src/overlays/actors/ovl_Obj_Moon_Stone/z_obj_moon_stone.c @@ -49,17 +49,15 @@ void ObjMoonStone_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.colChkInfo.health = 0; this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); func_80C0662C(this); - } else { - if ((gSaveContext.weekEventReg[74] & 0x40) == 0) { - if ((gSaveContext.weekEventReg[74] & 0x80)) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, 1, this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, 0, 0, 0, -1); - } - this->actor.flags &= ~ACTOR_FLAG_1; - func_80C0673C(this); - } else { - Actor_MarkForDeath(&this->actor); + } else if (!(gSaveContext.save.weekEventReg[74] & 0x40)) { + if ((gSaveContext.save.weekEventReg[74] & 0x80)) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, 1, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 0, 0, 0, -1); } + this->actor.flags &= ~ACTOR_FLAG_1; + func_80C0673C(this); + } else { + Actor_MarkForDeath(&this->actor); } } @@ -99,15 +97,15 @@ void func_80C0670C(ObjMoonStone* this, GlobalContext* globalCtx) { } void func_80C0673C(ObjMoonStone* this) { - if ((gSaveContext.weekEventReg[74] & 0x80) == 0) { + if (!(gSaveContext.save.weekEventReg[74] & 0x80)) { this->actor.draw = NULL; } this->actionFunc = func_80C06768; } void func_80C06768(ObjMoonStone* this, GlobalContext* globalCtx) { - if ((gSaveContext.weekEventReg[74] & 0x80)) { - if (this->actor.draw == 0) { + if ((gSaveContext.save.weekEventReg[74] & 0x80)) { + if (this->actor.draw == NULL) { this->actor.draw = ObjMoonStone_Draw; Actor_Spawn(&globalCtx->actorCtx, globalCtx, 1, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, -1); @@ -129,8 +127,8 @@ void func_80C0685C(ObjMoonStone* this) { } void func_80C06870(ObjMoonStone* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx)) { - gSaveContext.weekEventReg[74] |= 0x40; + if (Message_GetState(&globalCtx->msgCtx) == 6 && Message_ShouldAdvance(globalCtx)) { + gSaveContext.save.weekEventReg[74] |= 0x40; Actor_MarkForDeath(&this->actor); } } @@ -139,7 +137,7 @@ void ObjMoonStone_Update(Actor* thisx, GlobalContext* globalCtx) { ObjMoonStone* this = THIS; Player* player = GET_PLAYER(globalCtx); - if ((player->stateFlags1 & 0x10000282) == 0) { + if (!(player->stateFlags1 & 0x10000282)) { this->actionFunc(this, globalCtx); } } diff --git a/src/overlays/actors/ovl_Obj_Mu_Pict/z_obj_mu_pict.c b/src/overlays/actors/ovl_Obj_Mu_Pict/z_obj_mu_pict.c index 16ca763174..f81b4fe47e 100644 --- a/src/overlays/actors/ovl_Obj_Mu_Pict/z_obj_mu_pict.c +++ b/src/overlays/actors/ovl_Obj_Mu_Pict/z_obj_mu_pict.c @@ -40,7 +40,7 @@ const ActorInit Obj_Mu_Pict_InitVars = { void ObjMuPict_Init(Actor* thisx, GlobalContext* globalCtx) { ObjMuPict* this = THIS; - if (!(gSaveContext.weekEventReg[75] & 0x20) && !(gSaveContext.weekEventReg[52] & 0x20)) { + if (!(gSaveContext.save.weekEventReg[75] & 0x20) && !(gSaveContext.save.weekEventReg[52] & 0x20)) { Actor_MarkForDeath(&this->actor); } @@ -109,7 +109,7 @@ void func_80C06CD8(ObjMuPict* this, GlobalContext* globalCtx) { func_80C06E88(this, globalCtx); break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { func_80C06B5C(this); if (this->actor.cutscene >= 0) { ActorCutscene_Stop(this->actor.cutscene); @@ -154,7 +154,7 @@ void func_80C06DC8(ObjMuPict* this, GlobalContext* globalCtx) { } void func_80C06E88(ObjMuPict* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->textId) { case 0x159A: Message_StartTextbox(globalCtx, 0x159B, &this->actor); diff --git a/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.c b/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.c index ba5b62151f..2ff0e093ec 100644 --- a/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.c +++ b/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.c @@ -5,6 +5,8 @@ */ #include "z_obj_nozoki.h" +#include "objects/object_secom_obj/object_secom_obj.h" +#include "prevent_bss_reordering.h" #define FLAGS (ACTOR_FLAG_10) @@ -14,17 +16,23 @@ void ObjNozoki_Init(Actor* thisx, GlobalContext* globalCtx); void ObjNozoki_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjNozoki_Update(Actor* thisx, GlobalContext* globalCtx); +void ObjNozoki_SetupAction(ObjNozoki* this, ObjNozokiActionFunc actionFunc); void func_80BA2514(ObjNozoki* this, GlobalContext* globalCtx); +void func_80BA27C4(ObjNozoki* this, GlobalContext* globalCtx); void func_80BA28DC(ObjNozoki* this, GlobalContext* globalCtx); void func_80BA2AB4(ObjNozoki* this, GlobalContext* globalCtx); void func_80BA2BA4(ObjNozoki* this, GlobalContext* globalCtx); +void func_80BA2C94(ObjNozoki* this, GlobalContext* globalCtx); void func_80BA3044(ObjNozoki* this, GlobalContext* globalCtx); +void func_80BA311C(ObjNozoki* this, GlobalContext* globalCtx); void func_80BA3230(ObjNozoki* this, GlobalContext* globalCtx); void func_80BA3344(ObjNozoki* this, GlobalContext* globalCtx); +void ObjNozoki_Draw(Actor* thisx, GlobalContext* globalCtx); -void ObjNozoki_SetupAction(ObjNozoki* this, ObjNozokiActionFunc actionFunc); +s32 D_80BA36B0; +s32 D_80BA36B4; +f32 D_80BA36B8; -#if 0 const ActorInit Obj_Nozoki_InitVars = { ACTOR_OBJ_NOZOKI, ACTORCAT_ITEMACTION, @@ -37,54 +45,428 @@ const ActorInit Obj_Nozoki_InitVars = { (ActorFunc)NULL, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80BA34B0[] = { +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F(scale, 1, ICHAIN_CONTINUE), ICHAIN_U8(targetMode, 0, ICHAIN_STOP), }; -#endif +s16 D_80BA34B8[] = { OBJECT_SECOM_OBJ, OBJECT_GI_MSSA, OBJECT_SECOM_OBJ, OBJECT_SECOM_OBJ }; -extern InitChainEntry D_80BA34B0[]; +Vec3f D_80BA34C0 = { 0.0f, 0.0f, -1110.0f }; -extern UNK_TYPE D_060001C0; +Vec3f D_80BA34CC = { 0.0f, 0.0f, 38.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/ObjNozoki_SetupAction.s") +f32 D_80BA34D8[] = { 100.0f, 9999.0f, 9999.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/ObjNozoki_Init.s") +f32 D_80BA34E4[] = { 0.5f, 0.25f, 1.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/ObjNozoki_Destroy.s") +void ObjNozoki_SetupAction(ObjNozoki* this, ObjNozokiActionFunc actionFunc) { + this->actionFunc = actionFunc; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/func_80BA2514.s") +void ObjNozoki_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjNozoki* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/func_80BA26A8.s") + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + this->dyna.actor.shape.rot.x = 0; + this->dyna.actor.shape.rot.z = 0; + this->unk_15F = this->dyna.actor.cutscene; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/func_80BA2708.s") + if (globalCtx->sceneNum == SCENE_AYASHIISHOP) { + this->unk_15C = 4; + ObjNozoki_SetupAction(this, func_80BA3230); + this->dyna.actor.colChkInfo.cylRadius = -40; + } else { + this->unk_15C = OBJNOZOKI_GET_180(&this->dyna.actor); + if (this->unk_15C == 0) { + DynaPolyActor_Init(&this->dyna, 0); + } + ObjNozoki_SetupAction(this, func_80BA2514); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/func_80BA2790.s") +void ObjNozoki_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjNozoki* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/func_80BA27C4.s") + if (this->unk_15C == 0) { + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/func_80BA28DC.s") +void func_80BA2514(ObjNozoki* this, GlobalContext* globalCtx) { + s32 sp24 = Object_GetIndex(&globalCtx->objectCtx, D_80BA34B8[this->unk_15C]); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/func_80BA2AB4.s") + if (sp24 < 0) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/func_80BA2B64.s") + if (Object_IsLoaded(&globalCtx->objectCtx, sp24)) { + this->dyna.actor.objBankIndex = sp24; + this->dyna.actor.draw = ObjNozoki_Draw; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/func_80BA2BA4.s") + if (this->unk_15C == 0) { + Actor_SetObjectDependency(globalCtx, &this->dyna.actor); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_secom_obj_Colheader_0001C0); + if (ActorCutscene_GetAdditionalCutscene(this->unk_15F) >= 0) { + this->dyna.actor.params |= OBJNOZOKI_400; + } + ObjNozoki_SetupAction(this, func_80BA27C4); + } else if (this->unk_15C == 1) { + Lib_Vec3f_TranslateAndRotateY(&this->dyna.actor.world.pos, this->dyna.actor.shape.rot.y, &D_80BA34C0, + &this->dyna.actor.home.pos); + Actor_SetScale(&this->dyna.actor, 0.6f); + this->dyna.actor.flags |= ACTOR_FLAG_20; + ObjNozoki_SetupAction(this, func_80BA2BA4); + } else if (this->unk_15C == 2) { + Lib_Vec3f_TranslateAndRotateY(&this->dyna.actor.home.pos, this->dyna.actor.shape.rot.y, &D_80BA34CC, + &this->dyna.actor.focus.pos); + Math_Vec3f_Copy(&this->dyna.actor.world.pos, &this->dyna.actor.focus.pos); + ObjNozoki_SetupAction(this, func_80BA3044); + } else { + ObjNozoki_SetupAction(this, func_80BA311C); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/func_80BA2C28.s") +s32 func_80BA26A8(ObjNozoki* this) { + if (this->unk_15F < 0) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/func_80BA2C94.s") + if (ActorCutscene_GetCanPlayNext(this->unk_15F)) { + ActorCutscene_StartAndSetUnkLinkFields(this->unk_15F, &this->dyna.actor); + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/func_80BA3044.s") + ActorCutscene_SetIntentToPlay(this->unk_15F); + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/func_80BA311C.s") +s32 func_80BA2708(ObjNozoki* this, GlobalContext* globalCtx) { + Actor* enemy = globalCtx->actorCtx.actorLists[ACTORCAT_ENEMY].first; + Vec3f sp30; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/func_80BA3230.s") + while (enemy != NULL) { + Actor_OffsetOfPointInActorCoords(&this->dyna.actor, &sp30, &enemy->world.pos); + if (sp30.z >= 0.0f) { + return false; + } + enemy = enemy->next; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/func_80BA3344.s") + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/ObjNozoki_Update.s") +void func_80BA2790(ObjNozoki* this) { + ObjNozoki_SetupAction(this, func_80BA28DC); + this->dyna.actor.velocity.y = 0.0f; + this->unk_15E = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/func_80BA3434.s") +void func_80BA27C4(ObjNozoki* this, GlobalContext* globalCtx) { + if (!(globalCtx->actorCtx.unk5 & 0x20)) { + if (OBJNOZOKI_GET_200(&this->dyna.actor)) { + if (!func_80BA2708(this, globalCtx)) { + return; + } + } else { + if (D_80BA36B0 != 0) { + globalCtx->actorCtx.unk5 |= 0x80; + } + + if (!Flags_GetSwitch(globalCtx, OBJNOZOKI_GET_SWITCHFLAG1(&this->dyna.actor))) { + return; + } + } + + if ((D_80BA36B0 == 0) || func_80BA26A8(this)) { + func_80BA2790(this); + if (D_80BA36B0 == 0) { + this->unk_15E = 25; + play_sound(NA_SE_SY_SECOM_WARNING); + } else { + this->unk_15E = ActorCutscene_GetLength(this->unk_15F); + if (this->unk_15E < 0) { + this->unk_15E = 50; + } + globalCtx->actorCtx.unk5 |= 0x10; + } + } + GET_PLAYER(globalCtx)->linearVelocity = 0.0f; + } +} + +void func_80BA28DC(ObjNozoki* this, GlobalContext* globalCtx) { + if (this->unk_15E != 0) { + if (DECR(this->unk_15E) == 0) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SLIDE_DOOR_OPEN); + } + return; + } + + if (!(globalCtx->actorCtx.unk5 & 0x20)) { + Math_StepToF(&this->dyna.actor.velocity.y, 15.0f, 3.0f); + Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y + 200.0f, this->dyna.actor.velocity.y); + + if (OBJNOZOKI_GET_200(&this->dyna.actor)) { + if (!Flags_GetSwitch(globalCtx, OBJNOZOKI_GET_SWITCHFLAG1(&this->dyna.actor))) { + return; + } + } else if (Flags_GetSwitch(globalCtx, OBJNOZOKI_GET_SWITCHFLAG1(&this->dyna.actor))) { + s32 cs = this->dyna.actor.cutscene; + + if (cs == this->unk_15F) { + if (OBJNOZOKI_GET_400(&this->dyna.actor)) { + Vec3f sp28; + + Actor_OffsetOfPointInActorCoords(&this->dyna.actor, &sp28, &GET_PLAYER(globalCtx)->actor.world.pos); + if (sp28.z < -20.0f) { + this->unk_15F = ActorCutscene_GetAdditionalCutscene(this->unk_15F); + } + } + } else if (D_80BA36B4 == 0) { + if (func_80BA26A8(this)) { + D_80BA36B4 = 1; + } + } else if (ActorCutscene_GetCurrentIndex() != this->unk_15F) { + this->unk_15F = cs; + this->dyna.actor.params &= ~OBJNOZOKI_400; + Audio_QueueSeqCmd(0x881A); + } + return; + } + } + + ObjNozoki_SetupAction(this, func_80BA2AB4); + this->dyna.actor.velocity.y = 0.0f; + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SLIDE_DOOR_CLOSE); +} + +void func_80BA2AB4(ObjNozoki* this, GlobalContext* globalCtx) { + this->dyna.actor.velocity.y = 30.0f; + + if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y, 30.0f) && (D_80BA36B0 == 0)) { + ObjNozoki_SetupAction(this, func_80BA27C4); + D_80BA36B0 = 1; + } + + if (!(globalCtx->actorCtx.unk5 & 0x20)) { + if (!(OBJNOZOKI_GET_200(&this->dyna.actor)) && + Flags_GetSwitch(globalCtx, OBJNOZOKI_GET_SWITCHFLAG1(&this->dyna.actor))) { + func_80BA2790(this); + } + } +} + +void func_80BA2B64(ObjNozoki* this, GlobalContext* globalCtx, s32 arg2, s32 arg3) { + this->unk_15D = arg2; + this->unk_15E = 80; + Flags_UnsetSwitch(globalCtx, arg3); +} + +void func_80BA2BA4(ObjNozoki* this, GlobalContext* globalCtx) { + if (!Flags_GetSwitch(globalCtx, OBJNOZOKI_GET_SWITCHFLAG1(&this->dyna.actor))) { + this->dyna.actor.shape.rot.x = -0x1F40; + this->unk_15E = 80; + } else if (DECR(this->unk_15E) == 0) { + ObjNozoki_SetupAction(this, func_80BA2C94); + } +} + +s32 func_80BA2C28(ObjNozoki* this) { + s32 i; + s16 cs = this->unk_15F; + + for (i = 0; i < 3; i++) { + if (ActorCutscene_GetCurrentIndex() == cs) { + return i; + } + cs = ActorCutscene_GetAdditionalCutscene(cs); + } + + return -1; +} + +void func_80BA2C94(ObjNozoki* this, GlobalContext* globalCtx) { + s32 temp_v0 = func_80BA2C28(this); + f32 sp38; + f32 sp34; + f32 temp_f0; + + if (temp_v0 >= 0) { + D_80BA36B4 = temp_v0; + } + + if ((temp_v0 < 0) && Play_InCsMode(globalCtx)) { + return; + } + + if (D_80BA36B8 < D_80BA34D8[D_80BA36B4]) { + sp38 = this->dyna.actor.home.pos.y - this->dyna.actor.world.pos.y; + + if ((this->unk_15D != 1) && Flags_GetSwitch(globalCtx, this->dyna.actor.world.rot.z)) { + func_80BA2B64(this, globalCtx, 1, this->dyna.actor.world.rot.x); + } else if ((this->unk_15D != 2) && Flags_GetSwitch(globalCtx, this->dyna.actor.world.rot.x)) { + func_80BA2B64(this, globalCtx, 2, this->dyna.actor.world.rot.z); + } else if (DECR(this->unk_15E) == 0) { + this->unk_15D = 0; + Flags_UnsetSwitch(globalCtx, this->dyna.actor.world.rot.z); + Flags_UnsetSwitch(globalCtx, this->dyna.actor.world.rot.x); + } + + Math_StepToF(&this->dyna.actor.speedXZ, D_80BA34E4[this->unk_15D], 0.1f); + + if ((globalCtx->actorCtx.unk5 & 0x40) || (globalCtx->actorCtx.unk5 & 0x20)) { + temp_f0 = 0.5f; + } else { + temp_f0 = this->dyna.actor.speedXZ; + } + + sp34 = Math_Vec3f_StepToXZ(&this->dyna.actor.world.pos, &this->dyna.actor.home.pos, temp_f0); + + D_80BA36B8 += this->dyna.actor.speedXZ; + + if (globalCtx->actorCtx.unk5 & 0x40) { + if (sp34 <= 5.0f) { + Actor_MarkForDeath(&this->dyna.actor); + } + } else if (!(globalCtx->actorCtx.unk5 & 0x20) && (GET_PLAYER(globalCtx)->actor.id == ACTOR_PLAYER) && + Flags_GetSwitch(globalCtx, OBJNOZOKI_GET_SWITCHFLAG2(&this->dyna.actor)) && (sp38 < 20.0f)) { + static Vec3f D_80BA34F0 = { 0.0f, 0.0f, 50.0f }; + + globalCtx->actorCtx.unk5 |= 0x40; + Lib_Vec3f_TranslateAndRotateY(&this->dyna.actor.home.pos, this->dyna.actor.shape.rot.y, &D_80BA34F0, + &this->dyna.actor.world.pos); + this->dyna.actor.shape.rot.x = -0x1F40; + } else if (sp34 < 50.0f) { + globalCtx->actorCtx.unk5 |= 0x20; + + if (sp34 < 20.0f) { + this->dyna.actor.velocity.y -= 0.4f; + this->dyna.actor.world.pos.y += this->dyna.actor.velocity.y; + + sp38 = this->dyna.actor.home.pos.y - this->dyna.actor.world.pos.y; + if (sp38 >= 100.0f) { + Actor_MarkForDeath(&this->dyna.actor); + } + + this->dyna.actor.shape.rot.x = -0x1F40 - (s16)(sp38 * 400.0f); + } + } + } + + this->dyna.actor.velocity.x += this->dyna.actor.speedXZ * 0.66f; + if (this->dyna.actor.velocity.x >= 0x10000) { + this->dyna.actor.velocity.x -= 0x10000; + } + + globalCtx->roomCtx.unk7A[0] = this->dyna.actor.velocity.x; + + func_8019FAD8(&D_801DB4A4, NA_SE_EV_SECOM_CONVEYOR - SFX_FLAG, this->dyna.actor.speedXZ); +} + +void func_80BA3044(ObjNozoki* this, GlobalContext* globalCtx) { + Vec3f* sp1C = &this->dyna.actor.focus.pos; + + if (this->unk_15D == 0) { + if (globalCtx->actorCtx.unk5 & 0x40) { + this->unk_15D = 1; + this->unk_15E = 20; + Math_Vec3f_Copy(&this->dyna.actor.world.pos, sp1C); + } else if (!(globalCtx->actorCtx.unk5 & 0x20) && + Flags_GetSwitch(globalCtx, OBJNOZOKI_GET_SWITCHFLAG1(&this->dyna.actor))) { + sp1C = &this->dyna.actor.home.pos; + } + } else if (DECR(this->unk_15E) == 0) { + sp1C = &this->dyna.actor.home.pos; + } + + Math_Vec3f_StepToXZ(&this->dyna.actor.world.pos, sp1C, 8.0f); +} + +void func_80BA311C(ObjNozoki* this, GlobalContext* globalCtx) { + if (this->unk_15D == 0) { + if (Flags_GetSwitch(globalCtx, OBJNOZOKI_GET_SWITCHFLAG1(&this->dyna.actor))) { + this->unk_15D = 1; + this->unk_15E = 70; + } + } else if (this->unk_15D == 1) { + if (D_80BA36B8 > 40.0f) { + this->unk_15D = 2; + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_PL_SIT_ON_HORSE); + } else if (this->unk_15E != 0) { + if (DECR(this->unk_15E) == 0) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_CONVEYOR_SHUTTER_OPEN); + } + } else { + Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y + 50.0f, 4.0f); + } + } else { + Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y, 4.0f); + } +} + +void func_80BA3230(ObjNozoki* this, GlobalContext* globalCtx) { + if (gSaveContext.save.weekEventReg[64] & 0x20) { + Actor* npc = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; + Actor* test3 = SubS_FindActor(globalCtx, npc, ACTORCAT_NPC, ACTOR_EN_TEST3); + + if ((test3 != NULL) && (test3->draw != NULL)) { + if ((globalCtx->curSpawn == 3) && !(gSaveContext.save.weekEventReg[64] & 0x40)) { + this->dyna.actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10000); + this->dyna.actor.textId = 0x297A; + } else { + this->dyna.actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); + if (gSaveContext.save.weekEventReg[64] & 0x40) { + this->dyna.actor.textId = 0; + } else { + this->dyna.actor.textId = 0x2979; + } + } + + if (Actor_ProcessTalkRequest(&this->dyna.actor, &globalCtx->state)) { + ObjNozoki_SetupAction(this, func_80BA3344); + } else { + func_800B8614(&this->dyna.actor, globalCtx, 50.0f); + } + } + } +} + +void func_80BA3344(ObjNozoki* this, GlobalContext* globalCtx) { + if ((globalCtx->curSpawn == 3) && !(gSaveContext.save.weekEventReg[64] & 0x40)) { + if (Actor_TextboxIsClosing(&this->dyna.actor, globalCtx)) { + gSaveContext.save.weekEventReg[64] |= 0x40; + this->dyna.actor.flags &= ~ACTOR_FLAG_10000; + ObjNozoki_SetupAction(this, func_80BA3230); + } + } else if ((this->dyna.actor.textId == 0) || Actor_TextboxIsClosing(&this->dyna.actor, globalCtx)) { + globalCtx->nextEntranceIndex = 0xE20; + globalCtx->sceneLoadFlag = 0x14; + } +} + +void ObjNozoki_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjNozoki* this = THIS; + + this->actionFunc(this, globalCtx); +} + +Gfx* D_80BA34FC[] = { + object_secom_obj_DL_000080, + (Gfx*)0x0A0001A0, //! @bug This dlist should point to a dlist in OBJECT_GI_MSSA, but the segment and the offset are + //! wrong. This doesn't have side effects because of the extra check in the Draw function + object_secom_obj_DL_001230, + object_secom_obj_DL_001300, +}; + +void ObjNozoki_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjNozoki* this = THIS; + + if (this->unk_15C == 1) { + GetItem_Draw(globalCtx, GID_39); + } else { + Gfx_DrawDListOpa(globalCtx, D_80BA34FC[this->unk_15C]); + } +} diff --git a/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.h b/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.h index 164e25ecc6..08af2bc02a 100644 --- a/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.h +++ b/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.h @@ -7,9 +7,20 @@ struct ObjNozoki; typedef void (*ObjNozokiActionFunc)(struct ObjNozoki*, GlobalContext*); +#define OBJNOZOKI_GET_SWITCHFLAG1(thisx) ((thisx)->params & 0x7F) +#define OBJNOZOKI_GET_180(thisx) (((thisx)->params >> 7) & 3) +#define OBJNOZOKI_GET_200(thisx) ((thisx)->params & 0x200) +#define OBJNOZOKI_GET_400(thisx) ((thisx)->params & 0x400) +#define OBJNOZOKI_GET_SWITCHFLAG2(thisx) (((thisx)->params >> 9) & 0x7F) + +#define OBJNOZOKI_400 0x400 + typedef struct ObjNozoki { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x1C]; + /* 0x0000 */ DynaPolyActor dyna; + /* 0x015C */ u8 unk_15C; + /* 0x015D */ u8 unk_15D; + /* 0x015E */ s8 unk_15E; + /* 0x015F */ s8 unk_15F; /* 0x0160 */ ObjNozokiActionFunc actionFunc; } ObjNozoki; // size = 0x164 diff --git a/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c b/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c index 359d474f1f..fa3b46cf71 100644 --- a/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c +++ b/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c @@ -332,7 +332,7 @@ s32 ObjOshihiki_CheckWall(GlobalContext* globalCtx, s16 angle, f32 direction, Ob maxDist = maxDists[D_80918940[i]]; faceVtxOffset.x = (sFaceVtx[i].x * this->dyna.actor.scale.x * 10.0f) + sFaceDirection[i].x; - faceVtxOffset.y = (sFaceVtx[i].y * this->dyna.actor.scale.y * 10.0f) + sFaceDirection[i].y; + faceVtxOffset.y = (sFaceVtx[i].z * this->dyna.actor.scale.y * 10.0f) + sFaceDirection[i].z; faceVtxOffset.z = 0.0f; ObjOshihiki_RotateXZ(&faceVtx, &faceVtxOffset, sn, cs); diff --git a/src/overlays/actors/ovl_Obj_Pzlblock/z_obj_pzlblock.c b/src/overlays/actors/ovl_Obj_Pzlblock/z_obj_pzlblock.c index d6f35c491e..95b9a3a13d 100644 --- a/src/overlays/actors/ovl_Obj_Pzlblock/z_obj_pzlblock.c +++ b/src/overlays/actors/ovl_Obj_Pzlblock/z_obj_pzlblock.c @@ -5,6 +5,8 @@ */ #include "z_obj_pzlblock.h" +#include "objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h" +#include "objects/object_secom_obj/object_secom_obj.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_4000000) @@ -14,7 +16,15 @@ void ObjPzlblock_Init(Actor* thisx, GlobalContext* globalCtx); void ObjPzlblock_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjPzlblock_Update(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_809A3A48(ObjPzlblock* this); +void func_809A3A74(ObjPzlblock* this, GlobalContext* globalCtx); +void func_809A3BA4(ObjPzlblock* this); +void func_809A3BC0(ObjPzlblock* this, GlobalContext* globalCtx); +void func_809A3D1C(ObjPzlblock* this); +void func_809A3D38(ObjPzlblock* this, GlobalContext* globalCtx); +void func_809A3E58(Actor* thisx, GlobalContext* globalCtx); +void func_809A3F0C(Actor* thisx, GlobalContext* globalCtx); + const ActorInit Obj_Pzlblock_InitVars = { ACTOR_OBJ_PZLBLOCK, ACTORCAT_PROP, @@ -27,46 +37,337 @@ const ActorInit Obj_Pzlblock_InitVars = { (ActorFunc)NULL, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_809A4078[] = { +s16 D_809A4050[] = { 1, -1, 0, 0 }; +s16 D_809A4058[] = { 0, 0, 1, -1 }; + +typedef struct { + /* 0x0 */ s16 unk_00; + /* 0x4 */ CollisionHeader* unk_04; + /* 0x8 */ Gfx* unk_08; +} ObjPzlblockStruct; + +ObjPzlblockStruct D_809A4060[] = { + { GAMEPLAY_DANGEON_KEEP, &gameplay_dangeon_keep_Colheader_01D488, gameplay_dangeon_keep_DL_01C228 }, + { OBJECT_SECOM_OBJ, &object_secom_obj_Colheader_002CB8, object_secom_obj_DL_001A58 }, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_VEC3S(world.rot, 0, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 200, ICHAIN_STOP), }; -#endif +Color_RGB8 D_809A4088[] = { + { 180, 150, 250 }, { 100, 180, 150 }, { 0, 0, 255 }, { 255, 255, 0 }, + { 0, 255, 255 }, { 255, 0, 255 }, { 0, 0, 0 }, { 255, 255, 255 }, +}; -extern InitChainEntry D_809A4078[]; +s32 func_809A33E0(ObjPzlblock* this, GlobalContext* globalCtx, s16 arg2) { + return !DynaPolyActor_ValidateMove(globalCtx, &this->dyna, 30, arg2, 1) || + !DynaPolyActor_ValidateMove(globalCtx, &this->dyna, 30, arg2, 28); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/func_809A33E0.s") +s32 func_809A3448(ObjPzlblock* this) { + s16 temp_v0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/func_809A3448.s") + if (fabsf(this->dyna.pushForce) > 0.1f) { + temp_v0 = BINANG_ADD(this->dyna.yRotation, 0x2000); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/func_809A34E0.s") + if (this->dyna.pushForce < 0.0f) { + temp_v0 = BINANG_ROT180(temp_v0); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/func_809A35EC.s") + if (temp_v0 < -0x4000) { + return 3; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/func_809A376C.s") + if (temp_v0 < 0) { + return 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/ObjPzlblock_Init.s") + if (temp_v0 < 0x4000) { + return 2; + } + return 0; + } + return -1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/ObjPzlblock_Destroy.s") +s32 func_809A34E0(ObjPzlblock* this, s32 arg1) { + s32 temp_v0 = OBJPZLBLOCK_GET_ROTZ(&this->dyna.actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/func_809A3A48.s") + if (temp_v0 == 0) { + return arg1 == 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/func_809A3A74.s") + if (temp_v0 == 1) { + return arg1 == 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/func_809A3BA4.s") + if (temp_v0 == 2) { + return arg1 == 2; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/func_809A3BC0.s") + if (temp_v0 == 3) { + return arg1 == 3; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/func_809A3D1C.s") + if (temp_v0 == 4) { + return arg1 == 0 || arg1 == 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/func_809A3D38.s") + if (temp_v0 == 5) { + return arg1 == 2 || arg1 == 3; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/ObjPzlblock_Update.s") + if (temp_v0 == 6) { + if (this->unk_176 != 0) { + return arg1 == 0 || arg1 == 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/func_809A3E58.s") + if (this->unk_178 != 0) { + return arg1 == 2 || arg1 == 3; + } + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/func_809A3F0C.s") +s32 func_809A35EC(ObjPzlblock* this, s32 arg1) { + s32 temp_v0 = OBJPZLBLOCK_GET_ROTZ(&this->dyna.actor); + s32 temp_v1 = this->dyna.actor.home.rot.x & 0xF; + s32 temp; + + if (temp_v0 == 0) { + return this->unk_176 < temp_v1; + } + + if (temp_v0 == 1) { + return -temp_v1 < this->unk_176; + } + + if (temp_v0 == 2) { + return this->unk_178 < temp_v1; + } + + if (temp_v0 == 3) { + return -temp_v1 < this->unk_178; + } + + if (temp_v0 == 4) { + temp = D_809A4050[arg1] + this->unk_176; + return (temp_v1 >= temp) && (-temp_v1 <= temp); + } + + if (temp_v0 == 5) { + temp = D_809A4058[arg1] + this->unk_178; + return (temp_v1 >= temp) && (-temp_v1 <= temp); + } + + if (temp_v0 == 6) { + if ((arg1 == 0) || (arg1 == 1)) { + temp = D_809A4050[arg1] + this->unk_176; + return (temp_v1 >= temp) && (-temp_v1 <= temp); + } + + temp = D_809A4058[arg1] + this->unk_178; + return (temp_v1 >= temp) && (-temp_v1 <= temp); + } + + return false; +} + +void func_809A376C(ObjPzlblock* this, s32 arg1) { + this->unk_176 += D_809A4050[arg1]; + this->unk_178 += D_809A4058[arg1]; + if ((arg1 == 0) || (arg1 == 1)) { + this->unk_164 = &this->dyna.actor.world.pos.x; + this->unk_168 = this->dyna.actor.home.pos.x + (this->unk_176 * 60); + } else { + this->unk_164 = &this->dyna.actor.world.pos.z; + this->unk_168 = this->dyna.actor.home.pos.z + (this->unk_178 * 60); + } + this->unk_16C = arg1; +} + +void ObjPzlblock_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjPzlblock* this = THIS; + s32 sp2C = OBJPZLBLOCK_GET_ROTZ(&this->dyna.actor); + s32 sp28 = this->dyna.actor.home.rot.x & 0xF; + ObjPzlblockStruct* sp24 = &D_809A4060[OBJPZLBLOCK_GET_1000(&this->dyna.actor)]; + + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + Actor_SetScale(&this->dyna.actor, 0.1f); + + this->dyna.actor.home.rot.y = 0; + this->dyna.actor.shape.rot.x = 0; + this->dyna.actor.shape.rot.z = 0; + + DynaPolyActor_Init(&this->dyna, 0); + + this->unk_17A = Object_GetIndex(&globalCtx->objectCtx, sp24->unk_00); + + if (sp28 == 0) { + func_809A3D1C(this); + } else if (Flags_GetSwitch(globalCtx, OBJPZLBLOCK_GET_7F(&this->dyna.actor))) { + if (sp2C == 0) { + this->dyna.actor.world.pos.x = this->dyna.actor.home.pos.x + (sp28 * 60); + func_809A3D1C(this); + } else if (sp2C == 1) { + this->dyna.actor.world.pos.x = this->dyna.actor.home.pos.x - (sp28 * 60); + func_809A3D1C(this); + } else if (sp2C == 2) { + this->dyna.actor.world.pos.z = this->dyna.actor.home.pos.z + (sp28 * 60); + func_809A3D1C(this); + } else if (sp2C == 3) { + this->dyna.actor.world.pos.z = this->dyna.actor.home.pos.z - (sp28 * 60); + func_809A3D1C(this); + } else { + func_809A3A48(this); + } + } else { + func_809A3A48(this); + } +} + +void ObjPzlblock_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjPzlblock* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} + +void func_809A3A48(ObjPzlblock* this) { + this->actionFunc = func_809A3A74; + this->unk_16E[1] = 0; + this->unk_16E[2] = 0; + this->unk_16E[3] = 0; + this->unk_16E[0] = 0; + this->unk_160 = 4; +} + +void func_809A3A74(ObjPzlblock* this, GlobalContext* globalCtx) { + s32 i; + s32 sp20 = func_809A3448(this); + + for (i = 0; i < ARRAY_COUNT(this->unk_16E); i++) { + if (sp20 == i) { + this->unk_16E[i]++; + } else if (this->unk_16E[i] > 0) { + this->unk_16E[i]--; + } + } + + if (sp20 != -1) { + if ((this->unk_16E[sp20] >= 11) && func_809A34E0(this, sp20) && func_809A35EC(this, sp20)) { + if (!func_809A33E0(this, globalCtx, (this->dyna.pushForce > 0.0f) ? 90 : 120)) { + func_809A376C(this, sp20); + func_809A3BA4(this); + return; + } + } + + GET_PLAYER(globalCtx)->stateFlags2 &= ~0x10; + this->dyna.pushForce = 0.0f; + } +} + +void func_809A3BA4(ObjPzlblock* this) { + this->actionFunc = func_809A3BC0; + this->unk_160 = 5; +} + +void func_809A3BC0(ObjPzlblock* this, GlobalContext* globalCtx) { + if (Math_StepToF(this->unk_164, this->unk_168, 2.3f)) { + Player* player = GET_PLAYER(globalCtx); + s32 params = OBJPZLBLOCK_GET_ROTZ(&this->dyna.actor); + s32 pad; + s32 sp20 = 0; + + if ((params == 4) || (params == 5) || (params == 6)) { + if (!func_809A35EC(this, this->unk_16C) || func_809A33E0(this, globalCtx, 0x5A)) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + } + } else if (func_809A35EC(this, this->unk_16C)) { + if (func_809A33E0(this, globalCtx, 0x5A)) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + } + } else { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + Flags_SetSwitch(globalCtx, OBJPZLBLOCK_GET_7F(&this->dyna.actor)); + sp20 = 1; + } + + player->stateFlags2 &= ~0x10; + this->dyna.pushForce = 0.0f; + if (sp20 == 0) { + func_809A3A48(this); + } else { + func_809A3D1C(this); + } + } else { + func_800B9010(&this->dyna.actor, NA_SE_EV_ROCK_SLIDE - SFX_FLAG); + } +} + +void func_809A3D1C(ObjPzlblock* this) { + this->actionFunc = func_809A3D38; + this->unk_160 = 4; +} + +void func_809A3D38(ObjPzlblock* this, GlobalContext* globalCtx) { + if (fabsf(this->dyna.pushForce) > 0.1f) { + GET_PLAYER(globalCtx)->stateFlags2 &= ~0x10; + this->dyna.pushForce = 0.0f; + } +} + +void ObjPzlblock_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjPzlblock* this = THIS; + + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; + Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 15.0f, 30.0f, 0.0f, 4); + + if (Object_IsLoaded(&globalCtx->objectCtx, this->unk_17A)) { + ObjPzlblockStruct* sp2C = &D_809A4060[OBJPZLBLOCK_GET_1000(&this->dyna.actor)]; + + this->dyna.actor.objBankIndex = this->unk_17A; + Actor_SetObjectDependency(globalCtx, &this->dyna.actor); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, sp2C->unk_04); + this->dyna.actor.update = func_809A3E58; + this->dyna.actor.draw = func_809A3F0C; + } +} + +void func_809A3E58(Actor* thisx, GlobalContext* globalCtx) { + ObjPzlblock* this = THIS; + + this->actionFunc(this, globalCtx); + + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; + + if (this->unk_160 != 0) { + Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 15.0f, 30.0f, 0.0f, this->unk_160); + if (((this->actionFunc == func_809A3A74) || (this->actionFunc == func_809A3D38)) && + (this->dyna.actor.bgCheckFlags & 1) && !DynaPoly_GetActor(&globalCtx->colCtx, this->dyna.actor.floorBgId)) { + this->unk_160 = 0; + } + } +} + +void func_809A3F0C(Actor* thisx, GlobalContext* globalCtx) { + ObjPzlblockStruct* sp2C = &D_809A4060[OBJPZLBLOCK_GET_1000(thisx)]; + Color_RGB8* sp28 = &D_809A4088[OBJPZLBLOCK_GET_700(thisx)]; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, sp28->r, sp28->g, sp28->b, 255); + gSPDisplayList(POLY_OPA_DISP++, sp2C->unk_08); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Pzlblock/z_obj_pzlblock.h b/src/overlays/actors/ovl_Obj_Pzlblock/z_obj_pzlblock.h index 437583f621..fa1ca1f59f 100644 --- a/src/overlays/actors/ovl_Obj_Pzlblock/z_obj_pzlblock.h +++ b/src/overlays/actors/ovl_Obj_Pzlblock/z_obj_pzlblock.h @@ -5,9 +5,24 @@ struct ObjPzlblock; +typedef void (*ObjPzlblockActionFunc)(struct ObjPzlblock*, GlobalContext*); + +#define OBJPZLBLOCK_GET_7F(thisx) ((thisx)->params & 0x7F) +#define OBJPZLBLOCK_GET_700(thisx) (((thisx)->params >> 8) & 7) +#define OBJPZLBLOCK_GET_1000(thisx) (((thisx)->params >> 0xC) & 1) +#define OBJPZLBLOCK_GET_ROTZ(thisx) ((thisx)->home.rot.z & 7) + typedef struct ObjPzlblock { - /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x38]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ObjPzlblockActionFunc actionFunc; + /* 0x160 */ s32 unk_160; + /* 0x164 */ f32* unk_164; + /* 0x168 */ f32 unk_168; + /* 0x16C */ s16 unk_16C; + /* 0x16E */ s16 unk_16E[4]; + /* 0x176 */ s16 unk_176; + /* 0x178 */ s16 unk_178; + /* 0x17A */ s8 unk_17A; } ObjPzlblock; // size = 0x17C extern const ActorInit Obj_Pzlblock_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.c b/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.c index 8219bc581d..1253747e4e 100644 --- a/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.c +++ b/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.c @@ -5,6 +5,7 @@ */ #include "z_obj_skateblock.h" +#include "objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h" #define FLAGS (ACTOR_FLAG_10) @@ -15,7 +16,17 @@ void ObjSkateblock_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjSkateblock_Update(Actor* thisx, GlobalContext* globalCtx); void ObjSkateblock_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80A22308(ObjSkateblock* this); +void func_80A22334(ObjSkateblock* this, GlobalContext* globalCtx); +void func_80A2244C(ObjSkateblock* this); +void func_80A224A4(ObjSkateblock* this, GlobalContext* globalCtx); +void func_80A22628(ObjSkateblock* this); +void func_80A2264C(ObjSkateblock* this, GlobalContext* globalCtx); +void func_80A22728(ObjSkateblock* this); +void func_80A2273C(ObjSkateblock* this, GlobalContext* globalCtx); +void func_80A227A4(ObjSkateblock* this); +void func_80A227C0(ObjSkateblock* this, GlobalContext* globalCtx); + const ActorInit Obj_Skateblock_InitVars = { ACTOR_OBJ_SKATEBLOCK, ACTORCAT_BG, @@ -28,76 +39,658 @@ const ActorInit Obj_Skateblock_InitVars = { (ActorFunc)ObjSkateblock_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80A22AE0[] = { - ICHAIN_F32_DIV1000(gravity, -1700, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(terminalVelocity, -20000, ICHAIN_CONTINUE), - ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 150, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 200, ICHAIN_STOP), +s32 D_80A22A10 = 0; + +s32 D_80A22A14 = 0; + +AnimatedMaterial* D_80A22A18 = NULL; + +Vec2f D_80A22A1C[] = { + { -300.0f, 300.0f }, { 300.0f, 300.0f }, { -300.0f, -300.0f }, { 300.0f, -300.0f }, { 0.0f, 0.0f }, }; -#endif +Vec2f D_80A22A44[] = { + { 0.5f, -0.5f }, { -0.5f, -0.5f }, { 0.5f, 0.5f }, { -0.5f, 0.5f }, { 0.0f, 0.0f }, +}; -extern InitChainEntry D_80A22AE0[]; +Vec2f D_80A22A6C[] = { + { -300.0f, 0.0f }, { 300.0f, 0.0f }, { -300.0f, 600.0f }, { 300.0f, 600.0f }, { 0.0f, 300.0f }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21150.s") +Vec2f D_80A22A94[] = { + { 1.0f, 1.0f }, { -1.0f, 1.0f }, { 1.0f, -1.0f }, { -1.0f, -1.0f }, { 0.0f, 0.0f }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A211F4.s") +f32 D_80A22ABC[] = { -300.0f, 300.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A212F0.s") +f32 D_80A22AC4[] = { 1.0f, -1.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21370.s") +Vec3f D_80A22ACC = { 0.0f, 0.3f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21548.s") +Color_RGBA8 D_80A22AD8 = { 250, 250, 250, 255 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A216D4.s") +Color_RGBA8 D_80A22ADC = { 180, 180, 180, 255 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21934.s") +static InitChainEntry sInitChain[] = { + ICHAIN_F32_DIV1000(gravity, -1700, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(terminalVelocity, -20000, ICHAIN_CONTINUE), + ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 150, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 200, ICHAIN_STOP), +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21990.s") +f32 D_80A22AF8[] = { 14.0f, -14.0f, 14.0f, -14.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21C30.s") +Color_RGB8 D_80A22B08[] = { + { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 }, + { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 }, + { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21C88.s") +s32 func_80A21150(ObjSkateblock* this) { + s32 temp_v0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21CB4.s") + if (fabsf(this->dyna.pushForce) > 0.1f) { + if (this->dyna.pushForce > 0.0f) { + temp_v0 = BINANG_ADD(this->dyna.yRotation, 0x2000); + } else { + temp_v0 = BINANG_SUB(this->dyna.yRotation, 0x6000); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21CD8.s") + if (temp_v0 < -0x4000) { + return 3; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21D1C.s") + if (temp_v0 < 0) { + return 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21E9C.s") + if (temp_v0 < 0x4000) { + return 2; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21F68.s") + return 0; + } + return -1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21F74.s") +void func_80A211F4(ObjSkateblock* this, s32 arg1) { + s32 i; + s32 phi_v0 = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/ObjSkateblock_Init.s") + if (this->dyna.pushForce > 0.0f) { + phi_v0 = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/ObjSkateblock_Destroy.s") + for (i = 0; i < ARRAY_COUNT(this->unk_172); i++) { + if ((arg1 == i) && phi_v0) { + this->unk_172[i]++; + } else if (this->unk_172[i] > 0) { + this->unk_172[i]--; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A22308.s") +void func_80A212F0(Vec3f* arg0, Vec3f* arg1, s16 arg2) { + f32 sp1C = Math_SinS(arg2); + f32 temp_f0 = Math_CosS(arg2); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A22334.s") + arg0->x = (arg1->z * sp1C) + (arg1->x * temp_f0); + arg0->y = arg1->y; + arg0->z = (arg1->z * temp_f0) - (arg1->x * sp1C); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A2244C.s") +s32 func_80A21370(ObjSkateblock* this, GlobalContext* globalCtx) { + ObjSkateblockFloor* floor; + s32 i; + s32 pad; + s32 sp98; + Vec3f sp8C; + s32 sp88; + f32 phi_f20 = BGCHECK_Y_MIN; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A224A4.s") + sp88 = false; + sp8C.y = this->dyna.actor.world.pos.y + 40.0f; + sp98 = -1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A22628.s") + for (i = 0; i < ARRAY_COUNT(this->unk_184); i++) { + floor = &this->unk_184[i]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A2264C.s") + floor->poly = NULL; + floor->height = BGCHECK_Y_MIN; + floor->bgId = BG_ACTOR_MAX; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A22728.s") + sp8C.x = this->dyna.actor.world.pos.x + ((D_80A22A1C[i].x * this->dyna.actor.scale.x) + D_80A22A44[i].x); + sp8C.z = this->dyna.actor.world.pos.z + ((D_80A22A1C[i].z * this->dyna.actor.scale.z) + D_80A22A44[i].z); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A2273C.s") + floor->height = + BgCheck_EntityRaycastFloor6(&globalCtx->colCtx, &floor->poly, &floor->bgId, &this->dyna.actor, &sp8C, 0.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A227A4.s") + if (floor->height > BGCHECK_Y_MIN + 1.0f) { + sp88 = true; + if (phi_f20 < floor->height) { + phi_f20 = floor->height; + sp98 = i; + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A227C0.s") + if (sp98 >= 0) { + this->dyna.actor.floorPoly = this->unk_184[sp98].poly; + this->dyna.actor.floorHeight = this->unk_184[sp98].height; + this->dyna.actor.floorBgId = this->unk_184[sp98].bgId; + } + return sp88; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/ObjSkateblock_Update.s") +s32 func_80A21548(ObjSkateblock* this, GlobalContext* globalCtx) { + s32 i; + ObjSkateblockFloor* floor; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/ObjSkateblock_Draw.s") + this->unk_1C1 &= ~4; + + if (func_80A21370(this, globalCtx)) { + f32 maxHeight = BGCHECK_Y_MIN; + s32 phi_v1 = false; + f32 temp_f12 = this->dyna.actor.world.pos.y - 10.0f; + + for (i = 0; i < ARRAY_COUNT(this->unk_184); i++) { + floor = &this->unk_184[i]; + if ((temp_f12 < floor->height) && (floor->height > maxHeight)) { + maxHeight = floor->height; + phi_v1 = true; + } + } + + if (phi_v1) { + this->dyna.actor.world.pos.y = maxHeight; + this->unk_1C1 |= 4; + this->dyna.actor.velocity.y = 0.0f; + } + return phi_v1; + } + return false; +} + +s32 func_80A216D4(ObjSkateblock* this, GlobalContext* globalCtx, f32 arg2, Vec3f* arg3) { + s32 pad; + f32 spE8; + f32 spE4; + s32 i; + Vec3f spD4; + Vec3f spC8; + Vec3f spBC; + Vec3f spB0; + f32 temp_f20; + f32 temp_f24; + s32 spA4; + CollisionPoly* spA0; + s32 ret; + f32 temp_f26; + s16 sp96 = this->dyna.yRotation; + f32 temp_f2; + + if (this->dyna.pushForce < 0.0f) { + sp96 -= 0x8000; + } + spE8 = Math_SinS(sp96); + spE4 = Math_CosS(sp96); + + temp_f2 = Math3D_Distance(&this->dyna.actor.world.pos, &this->dyna.actor.prevPos) + + (300.0f * this->dyna.actor.scale.z) + arg2; + temp_f24 = temp_f2 * spE8; + temp_f26 = temp_f2 * spE4; + + ret = false; + temp_f20 = FLT_MAX; + + for (i = 0; i < ARRAY_COUNT(D_80A22A6C); i++) { + spBC.x = (D_80A22A6C[i].x * this->dyna.actor.scale.x) + D_80A22A94[i].x; + spBC.y = (D_80A22A6C[i].z * this->dyna.actor.scale.y) + D_80A22A94[i].z; + spBC.z = 0.0f; + + func_80A212F0(&spD4, &spBC, sp96); + + spD4.x += this->dyna.actor.prevPos.x; + spD4.y += this->dyna.actor.prevPos.y; + spD4.z += this->dyna.actor.prevPos.z; + + spC8.x = temp_f24 + spD4.x; + spC8.y = spD4.y; + spC8.z = temp_f26 + spD4.z; + + if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &spD4, &spC8, &spB0, &spA0, true, false, false, true, &spA4, + &this->dyna.actor, 0.0f)) { + temp_f2 = Math3D_Vec3fDistSq(&spD4, &spB0); + if (temp_f2 < temp_f20) { + temp_f20 = temp_f2; + ret = true; + Math_Vec3f_Diff(&spB0, &spC8, arg3); + } + } + } + return ret; +} + +s32 func_80A21934(ObjSkateblock* this, GlobalContext* globalCtx) { + Vec3f sp1C; + + if (func_80A216D4(this, globalCtx, 0.0f, &sp1C)) { + this->dyna.actor.world.pos.x += sp1C.x; + this->dyna.actor.world.pos.z += sp1C.z; + return true; + } + return false; +} + +s32 func_80A21990(ObjSkateblock* this, GlobalContext* globalCtx, Vec3f* arg2) { + s32 i; + f32 sp100; + s16 phi_s6 = this->dyna.yRotation; + f32 phi_f22; + Vec3f spEC; + Vec3f spE0; + Vec3f spD4; + Vec3f spC8; + f32 temp_f0; + f32 temp_f12; + s32 spBC; + CollisionPoly* spB8; + s32 ret; + f32 temp_f26; + f32 temp_f28; + f32 temp_f30; + + if (this->dyna.pushForce < 0.0f) { + phi_s6 -= 0x8000; + } + + sp100 = Math_SinS(phi_s6); + temp_f26 = Math_CosS(phi_s6); + + temp_f12 = + (300.0f * this->dyna.actor.scale.z + Math3D_Distance(&this->dyna.actor.world.pos, &this->dyna.actor.prevPos)) + + 2.0f; + temp_f28 = -temp_f12 * sp100; + temp_f30 = -temp_f12 * temp_f26; + + ret = false; + phi_f22 = FLT_MAX; + + for (i = 0; i < ARRAY_COUNT(D_80A22ABC); i++) { + spD4.x = (D_80A22ABC[i] * this->dyna.actor.scale.x) + D_80A22AC4[i]; + spD4.y = -10.0f; + spD4.z = 0.0f; + + func_80A212F0(&spEC, &spD4, phi_s6); + + spEC.x += this->dyna.actor.world.pos.x; + spEC.y += this->dyna.actor.world.pos.y; + spEC.z += this->dyna.actor.world.pos.z; + + spE0.x = temp_f28 + spEC.x; + spE0.y = spEC.y; + spE0.z = temp_f30 + spEC.z; + + if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &spEC, &spE0, &spC8, &spB8, true, false, false, true, &spBC, + &this->dyna.actor, 0.0f)) { + temp_f0 = Math3D_Vec3fDistSq(&spEC, &spC8); + if (temp_f0 < phi_f22) { + ret = true; + arg2->x = (spC8.x - spEC.x) + (300.0f * this->dyna.actor.scale.z * sp100); + arg2->y = 0.0f; + arg2->z = (spC8.z - spEC.z) + (300.0f * this->dyna.actor.scale.z * temp_f26); + phi_f22 = temp_f0; + } + } + } + return ret; +} + +s32 func_80A21C30(ObjSkateblock* this, GlobalContext* globalCtx) { + Vec3f sp1C; + + if (func_80A21990(this, globalCtx, &sp1C)) { + this->dyna.actor.world.pos.x += sp1C.x; + this->dyna.actor.world.pos.z += sp1C.z; + return true; + } + + return false; +} + +void func_80A21C88(ObjSkateblock* this, s32 arg1) { + if ((arg1 == 0) || (arg1 == 1)) { + this->unk_16C = &this->dyna.actor.world.pos.x; + } else { + this->unk_16C = &this->dyna.actor.world.pos.z; + } + this->unk_170 = arg1; +} + +void func_80A21CB4(ObjSkateblock* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + player->stateFlags2 &= ~0x10; + this->dyna.pushForce = 0.0f; +} + +void func_80A21CD8(ObjSkateblock* this) { + this->dyna.actor.velocity.y += this->dyna.actor.gravity; + if (this->dyna.actor.velocity.y < this->dyna.actor.terminalVelocity) { + this->dyna.actor.velocity.y = this->dyna.actor.terminalVelocity; + } + this->dyna.actor.world.pos.y += this->dyna.actor.velocity.y; +} + +void func_80A21D1C(ObjSkateblock* this) { + f32 sp4; + f32 temp_f14; + f32 temp_f16; + f32 temp_f6; + f32 phi_f2; + + temp_f14 = this->dyna.actor.world.pos.x - this->dyna.actor.home.pos.x; + phi_f2 = ((temp_f14 >= 0.0f) ? 0.5f : -0.5f); + sp4 = ((s32)(phi_f2 + temp_f14) / 30) * 30; + temp_f14 -= sp4; + + if (fabsf(temp_f14) < 3.0f) { + this->dyna.actor.world.pos.x = this->dyna.actor.home.pos.x + sp4; + } + + temp_f16 = this->dyna.actor.world.pos.z - this->dyna.actor.home.pos.z; + phi_f2 = ((temp_f16 >= 0.0f) ? 0.5f : -0.5f); + temp_f6 = ((s32)(phi_f2 + temp_f16) / 30) * 30; + temp_f16 -= temp_f6; + + if (fabsf(temp_f16) < 3.0f) { + this->dyna.actor.world.pos.z = this->dyna.actor.home.pos.z + temp_f6; + } +} + +void func_80A21E9C(ObjSkateblock* this, GlobalContext* globalCtx) { + DynaPolyActor* temp_v0; + s32 i; + ObjSkateblockFloor* ptr; + + if (!(this->unk_1C1 & 4)) { + return; + } + + for (i = 0; i < ARRAY_COUNT(this->unk_184); i++) { + ptr = &this->unk_184[i]; + + temp_v0 = DynaPoly_GetActor(&globalCtx->colCtx, ptr->bgId); + if ((temp_v0 != NULL) && (temp_v0->actor.id == ACTOR_OBJ_SKATEBLOCK)) { + ObjSkateblock* skateBlock = (ObjSkateblock*)temp_v0; + f32 height = this->dyna.actor.world.pos.y - ptr->height; + + if (fabsf(height) < 0.1f) { + skateBlock->unk_1C1 |= 2; + } + } + } +} + +void func_80A21F68(ObjSkateblock* this) { + this->unk_17C = 0; +} + +void func_80A21F74(ObjSkateblock* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f spA8; + Vec3f sp9C; + f32 phi_f22; + s32 i; + f32 temp; + s32 pad2; + s16 sp8A = this->dyna.yRotation; + + if (this->dyna.pushForce < 0.0f) { + sp8A -= 0x8000; + } + + this->unk_17C++; + + if (this->dyna.actor.flags & ACTOR_FLAG_40) { + if (this->unk_17C >= 46) { + phi_f22 = 1.0f; + } else { + phi_f22 = (this->unk_17C * 0.017777778f) + 0.2f; + } + sp9C.y = 12.0f; + + for (i = 0; i < 2; i++) { + if (phi_f22 < (Rand_ZeroOne() * 1.2f)) { + continue; + } + this->unk_180 += Rand_ZeroOne(); + + if (this->unk_180 > 1.0f) { + this->unk_180 -= 1.0f; + } + + sp9C.x = (this->unk_180 - 0.5f) * 600.0f * this->dyna.actor.scale.x; + sp9C.z = (this->dyna.actor.scale.z * -300.0f) + 4.0f; + + func_80A212F0(&spA8, &sp9C, sp8A); + + spA8.x += this->dyna.actor.world.pos.x; + spA8.y += this->dyna.actor.world.pos.y; + spA8.z += this->dyna.actor.world.pos.z; + + temp = ((Rand_ZeroOne() * 800.0f) + (1600.0f * this->dyna.actor.scale.x)) * phi_f22; + func_800B0E48(globalCtx, &spA8, &gZeroVec3f, &D_80A22ACC, &D_80A22AD8, &D_80A22ADC, temp, + (Rand_ZeroOne() * 20.0f) + 30.0f); + } + } +} + +void ObjSkateblock_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjSkateblock* this = THIS; + + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gameplay_dangeon_keep_Colheader_007498); + if (D_80A22A18 == NULL) { + D_80A22A18 = Lib_SegmentedToVirtual(gameplay_dangeon_keep_Matanimheader_01B370); + } + func_80A22308(this); + this->unk_1C0 = D_80A22A14; + D_80A22A14++; + D_80A22A14 &= 0x1F; +} + +void ObjSkateblock_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjSkateblock* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} + +void func_80A22308(ObjSkateblock* this) { + this->actionFunc = func_80A22334; + this->unk_172[1] = 0; + this->unk_172[2] = 0; + this->unk_172[3] = 0; + this->unk_172[0] = 0; + this->dyna.actor.velocity.y = 0.0f; +} + +void func_80A22334(ObjSkateblock* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp30; + s32 sp2C; + Vec3f sp20; + + func_80A21CD8(this); + func_80A21548(this, globalCtx); + sp2C = func_80A21150(this); + func_80A211F4(this, sp2C); + + sp30 = true; + + if (sp2C == -1) { + sp30 = false; + } else if (!(this->unk_1C1 & 2) && (this->unk_172[sp2C] > 10) && (D_80A22A10 == 0) && + !func_80A216D4(this, globalCtx, 2.0f, &sp20) && !Player_InCsMode(&globalCtx->state)) { + func_80A21C88(this, sp2C); + func_80A2244C(this); + sp30 = false; + func_800B7298(globalCtx, &this->dyna.actor, 7); + this->unk_1C1 |= 1; + } + + if (sp30) { + func_80A21CB4(this, globalCtx); + } +} + +void func_80A2244C(ObjSkateblock* this) { + this->actionFunc = func_80A224A4; + this->unk_168 = D_80A22AF8[this->unk_170]; + this->unk_164 = 0.0f; + this->unk_17A = 15; + this->dyna.actor.velocity.y = this->dyna.actor.gravity; + func_80A21F68(this); +} + +void func_80A224A4(ObjSkateblock* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp28 = false; + s32 sp24 = false; + + Math_StepToF(&this->unk_164, this->unk_168, 0.75f); + + *this->unk_16C += this->unk_164; + + if (func_80A21934(this, globalCtx)) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + func_80A21D1C(this); + sp28 = true; + } else { + func_800B9010(&this->dyna.actor, NA_SE_PL_SLIP_ICE_LEVEL - SFX_FLAG); + } + + func_80A21CD8(this); + + if (!func_80A21548(this, globalCtx)) { + func_80A21C30(this, globalCtx); + func_80A21D1C(this); + func_80A22628(this); + sp24 = true; + } else if (sp28) { + func_80A22308(this); + } + + if (this->unk_17A > 0) { + this->unk_17A--; + } + + if (sp24 || sp28 || (this->unk_17A == 1)) { + func_80A21CB4(this, globalCtx); + } + + if ((this->unk_1C1 & 1) && (sp24 || sp28 || (this->dyna.actor.xzDistToPlayer > 400.0f))) { + this->unk_1C1 &= ~1; + func_800B7298(globalCtx, &this->dyna.actor, 6); + } + + func_80A21F74(this, globalCtx); +} + +void func_80A22628(ObjSkateblock* this) { + this->actionFunc = func_80A2264C; + this->unk_160 = this->dyna.actor.world.pos.y; + this->dyna.actor.velocity.y = this->dyna.actor.gravity; +} + +void func_80A2264C(ObjSkateblock* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp20; + + if (func_80A21150(this) != -1) { + func_80A21CB4(this, globalCtx); + } + func_80A21CD8(this); + + sp20 = func_80A21548(this, globalCtx); + if (sp20 || ((this->unk_160 - this->dyna.actor.world.pos.y) > 300.0f)) { + if (func_800C9B40(&globalCtx->colCtx, this->dyna.actor.floorPoly, this->dyna.actor.floorBgId) == 12) { + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + this->dyna.actor.draw = NULL; + func_80A22728(this); + return; + } + } + + if (sp20) { + func_80A22308(this); + } +} + +void func_80A22728(ObjSkateblock* this) { + this->actionFunc = func_80A2273C; +} + +void func_80A2273C(ObjSkateblock* this, GlobalContext* globalCtx) { + if (!DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + this->dyna.actor.world.pos.x = this->dyna.actor.home.pos.x; + this->dyna.actor.world.pos.y = (this->dyna.actor.home.pos.y - (600.0f * this->dyna.actor.scale.y)) - 10.0f; + this->dyna.actor.world.pos.z = this->dyna.actor.home.pos.z; + + func_80A227A4(this); + } +} + +void func_80A227A4(ObjSkateblock* this) { + this->actionFunc = func_80A227C0; + this->unk_17A = 40; +} + +void func_80A227C0(ObjSkateblock* this, GlobalContext* globalCtx) { + if (func_80A21150(this) != -1) { + func_80A21CB4(this, globalCtx); + } + + if (this->unk_17A > 0) { + this->unk_17A--; + return; + } + + func_800C6314(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + this->dyna.actor.draw = ObjSkateblock_Draw; + + if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y, 1.0f)) { + func_80A22308(this); + } + + if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + D_80A22A10 |= 1 << this->unk_1C0; + } +} + +void ObjSkateblock_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjSkateblock* this = THIS; + + D_80A22A10 &= ~(1 << this->unk_1C0); + this->actionFunc(this, globalCtx); + this->unk_1C1 &= ~2; +} + +void ObjSkateblock_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjSkateblock* this = THIS; + Color_RGB8* sp2C = &D_80A22B08[OBJSKAEBLOCK_GET_F(&this->dyna.actor)]; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + AnimatedMat_DrawStep(globalCtx, D_80A22A18, 0); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_OPA_DISP++, 0xFF, 0xFF, sp2C->r, sp2C->g, sp2C->b, 255); + gSPDisplayList(POLY_OPA_DISP++, gameplay_dangeon_keep_DL_0182A8); + + func_80A21E9C(this, globalCtx); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.h b/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.h index 00f3a0f1b1..c26a93844b 100644 --- a/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.h +++ b/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.h @@ -7,11 +7,29 @@ struct ObjSkateblock; typedef void (*ObjSkateblockActionFunc)(struct ObjSkateblock*, GlobalContext*); +#define OBJSKAEBLOCK_GET_F(thisx) ((thisx)->params & 0xF) + +typedef struct { + /* 0x00 */ CollisionPoly* poly; + /* 0x04 */ f32 height; + /* 0x08 */ s32 bgId; +} ObjSkateblockFloor; // size = 0xC + typedef struct ObjSkateblock { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; + /* 0x0000 */ DynaPolyActor dyna; /* 0x015C */ ObjSkateblockActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x64]; + /* 0x0160 */ f32 unk_160; + /* 0x0164 */ f32 unk_164; + /* 0x0168 */ f32 unk_168; + /* 0x016C */ f32* unk_16C; + /* 0x0170 */ s16 unk_170; + /* 0x0172 */ s16 unk_172[4]; + /* 0x017A */ s16 unk_17A; + /* 0x017C */ s16 unk_17C; + /* 0x0180 */ f32 unk_180; + /* 0x0184 */ ObjSkateblockFloor unk_184[5]; + /* 0x01C0 */ u8 unk_1C0; + /* 0x01C1 */ u8 unk_1C1; } ObjSkateblock; // size = 0x1C4 extern const ActorInit Obj_Skateblock_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.c b/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.c index badd4318ea..ded17da2da 100644 --- a/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.c +++ b/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.c @@ -5,6 +5,7 @@ */ #include "z_obj_smork.h" +#include "objects/object_f53_obj/object_f53_obj.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -15,7 +16,6 @@ void ObjSmork_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjSmork_Update(Actor* thisx, GlobalContext* globalCtx); void ObjSmork_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Smork_InitVars = { ACTOR_OBJ_SMORK, ACTORCAT_PROP, @@ -28,20 +28,125 @@ const ActorInit Obj_Smork_InitVars = { (ActorFunc)ObjSmork_Draw, }; -#endif +#include "overlays/ovl_Obj_Smork/ovl_Obj_Smork.c" -extern UNK_TYPE D_06001C00; +u8 func_80A3D680(s16 arg0) { + u8 ret = 0; + s16 temp_f18 = TIME_TO_MINUTES_F(gSaveContext.save.time); + s32 hours = temp_f18 / 60; + s32 minutes = temp_f18 % 60; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Smork/func_80A3D680.s") + if (hours >= 16) { + if ((hours == 16) && (minutes < arg0)) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Smork/func_80A3D940.s") + if (hours >= 20) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Smork/func_80A3D9C4.s") + if ((hours == 19) && (arg0 < minutes)) { + return 0; + } + ret = 3; + } else if (hours >= 11) { + if ((hours == 11) && (minutes < arg0)) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Smork/ObjSmork_Init.s") + if (hours >= 14) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Smork/ObjSmork_Destroy.s") + if ((hours == 13) && (arg0 < minutes)) { + return 0; + } + ret = 2; + } else if (hours >= 6) { + if ((hours == 6) && (minutes < arg0)) { + return 0; + } + if (hours >= 9) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Smork/ObjSmork_Update.s") + if ((hours == 8) && (arg0 < minutes)) { + return 0; + } + ret = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Smork/ObjSmork_Draw.s") + return ret; +} + +void func_80A3D940(ObjSmork* this) { + u8 temp_v0 = func_80A3D680(this->unk_1C6); + + if (temp_v0 != this->unk_1C4) { + this->unk_1C4 = temp_v0; + this->unk_1C6 = Rand_S16Offset(0, 59); + } + + Math_ApproachF(&this->unk_1B8, (this->unk_1C4 == 0) ? 0.0f : 1.0f, 0.02f, 1000.0f); +} + +void func_80A3D9C4(ObjSmork* this, GlobalContext* globalCtx) { + u8 sp57; + u8 sp56; + s32 i; + + this->unk_1BC += 1.8f; + this->unk_1C0 += 0.6f; + + sp57 = 127 - (u8)this->unk_1BC; + sp56 = 127 - (u8)this->unk_1C0; + + this->unk_1B8 = CLAMP(this->unk_1B8, 0.0f, 1.0f); + + for (i = 0; i < ARRAY_COUNT(this->unk_148); i++) { + this->unk_148[i].v.cn[3] = ovl_Obj_Smork_Vtx_000C10[i].v.cn[3] * this->unk_1B8; + } + + if (this->unk_1B8 > 0.0f) { + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + MTXMODE_NEW); + this->actor.shape.rot.y = BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))); + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Scale(0.1f, 0.1f, 0.0f, MTXMODE_APPLY); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, sp57, 0x20, 0x20, 1, 0, sp56, 0x20, 0x20)); + gSPSegment(POLY_XLU_DISP++, 0x09, Lib_SegmentedToVirtual(this->unk_148)); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_f53_obj_DL_001C00); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +void ObjSmork_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjSmork* this = THIS; + + Lib_MemCpy(this->unk_148, ovl_Obj_Smork_Vtx_000C10, sizeof(Vtx) * ARRAY_COUNT(ovl_Obj_Smork_Vtx_000C10)); + this->unk_1C6 = Rand_S16Offset(0, 59); + this->unk_1C4 = 0; +} + +void ObjSmork_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void ObjSmork_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjSmork* this = THIS; + + func_80A3D940(this); +} + +void ObjSmork_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjSmork* this = THIS; + + func_80A3D9C4(this, globalCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.h b/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.h index dd6ab4cf72..5ab3e405c4 100644 --- a/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.h +++ b/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.h @@ -7,7 +7,13 @@ struct ObjSmork; typedef struct ObjSmork { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x84]; + /* 0x144 */ UNK_TYPE1 unk_144[4]; + /* 0x148 */ Vtx unk_148[7]; + /* 0x1B8 */ f32 unk_1B8; + /* 0x1BC */ f32 unk_1BC; + /* 0x1C0 */ f32 unk_1C0; + /* 0x1C4 */ u8 unk_1C4; + /* 0x1C6 */ s16 unk_1C6; } ObjSmork; // size = 0x1C8 extern const ActorInit Obj_Smork_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c b/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c index 632d1b8c6a..15a63746b9 100644 --- a/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c +++ b/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c @@ -228,8 +228,8 @@ void func_80B030F8(ObjSnowball* this, GlobalContext* globalCtx) { scale = ((Rand_ZeroOne() * 15.0f) + 30.0f) * this->unk_20C; - EffectSsKakera_Spawn(globalCtx, &spFC, &spF0, &spFC, gravity, phi_s0, 30, 0, 0, scale, phi_s4, 0, 50, -1, 0xEF, - temp_s2); + EffectSsKakera_Spawn(globalCtx, &spFC, &spF0, &spFC, gravity, phi_s0, 30, 0, 0, scale, phi_s4, 0, 50, -1, + OBJECT_GOROIWA, temp_s2); if ((this->unk_210 == 0) && (temp_s7 >= 3)) { spFC.x += (Rand_ZeroOne() * 120.0f) - 60.0f; spFC.y += Rand_ZeroOne() * 80.0f; @@ -333,7 +333,6 @@ void func_80B03688(ObjSnowball* this, GlobalContext* globalCtx) { } } -#ifdef NON_MATCHING void func_80B03A80(GlobalContext* globalCtx, f32 arg1, Vec3f* arg2) { f32 temp_f30 = sqrtf(arg1); Vec3f spD8; @@ -341,14 +340,16 @@ void func_80B03A80(GlobalContext* globalCtx, f32 arg1, Vec3f* arg2) { s32 i; Gfx* temp_s1; f32 temp_f20; - s32 phi_s5; - s32 pad; s16 phi_s2; - s32 pad2; s16 phi_s0; s16 phi_s3; + s32 phi_s5; + s32 tmp; + s32 pad; for (i = 0, phi_s5 = 0; i < 13; i++, phi_s5 += 0x1999) { + tmp = i & 3; + temp_f20 = (Rand_ZeroOne() * (40.0f * arg1)) + 20.0f; spD8.x = Math_SinS((s32)(Rand_ZeroOne() * 6553.6f) + phi_s5) * temp_f20; @@ -363,7 +364,7 @@ void func_80B03A80(GlobalContext* globalCtx, f32 arg1, Vec3f* arg2) { spD8.y += arg2->y; spD8.z += arg2->z; - if ((i & 3) == 0) { + if (tmp == 0) { temp_s1 = D_80B04FC8[0]; phi_s2 = -400; phi_s3 = 1; @@ -372,7 +373,7 @@ void func_80B03A80(GlobalContext* globalCtx, f32 arg1, Vec3f* arg2) { } else { phi_s0 = 0x41; } - } else if ((i & 3) == 1) { + } else if (tmp == 1) { temp_s1 = D_80B04FC8[1]; phi_s2 = -340; phi_s3 = 1; @@ -389,7 +390,7 @@ void func_80B03A80(GlobalContext* globalCtx, f32 arg1, Vec3f* arg2) { } EffectSsKakera_Spawn(globalCtx, &spD8, &spCC, &spD8, phi_s2, phi_s0, 30, 0, 0, - ((Rand_ZeroOne() * 15.0f) + 25.0f) * arg1, phi_s3, 0, 0x36, -1, 0xEF, temp_s1); + ((Rand_ZeroOne() * 15.0f) + 25.0f) * arg1, phi_s3, 0, 0x36, -1, OBJECT_GOROIWA, temp_s1); spD8.x += (Rand_ZeroOne() * 80.0f) - 40.0f; spD8.y += Rand_ZeroOne() * 55.0f; @@ -401,10 +402,6 @@ void func_80B03A80(GlobalContext* globalCtx, f32 arg1, Vec3f* arg2) { (s32)(Rand_ZeroOne() * 30.0f * temp_f30) + 60); } } -#else -void func_80B03A80(GlobalContext* globalCtx, f32 arg1, Vec3f* arg2); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball/func_80B03A80.s") -#endif void func_80B03E2C(ObjSnowball* this, GlobalContext* globalCtx) { ObjSnowballStruct* ptr; diff --git a/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.c b/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.c index 76111148a9..229cdf516c 100644 --- a/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.c +++ b/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.c @@ -178,7 +178,7 @@ void func_80B39108(ObjSnowball2* this, GlobalContext* globalCtx) { } EffectSsKakera_Spawn(globalCtx, &spD0, &spDC, &spD0, -300, phi_s1, 30, 0, 0, (temp >> 0x1D) + 8, phi_v0, 0, 50, - -1, 0xEF, D_80B3A91C[i & 3]); + -1, OBJECT_GOROIWA, D_80B3A91C[i & 3]); spD0.x += (Rand_ZeroOne() - 0.5f) * 40.0f; spD0.y += (Rand_ZeroOne() - 0.3f) * 45.0f; diff --git a/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.c b/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.c index 20e2622981..1bc0f57b28 100644 --- a/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.c +++ b/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.c @@ -5,6 +5,7 @@ */ #include "z_obj_spidertent.h" +#include "objects/object_spidertent/object_spidertent.h" #define FLAGS (ACTOR_FLAG_10000000) @@ -15,7 +16,13 @@ void ObjSpidertent_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjSpidertent_Update(Actor* thisx, GlobalContext* globalCtx); void ObjSpidertent_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80B307E0(ObjSpidertent* this); +void func_80B30808(ObjSpidertent* this, GlobalContext* globalCtx); +void func_80B30A2C(ObjSpidertent* this); +void func_80B30A4C(ObjSpidertent* this, GlobalContext* globalCtx); +void func_80B30AD4(ObjSpidertent* this); +void func_80B30AF8(ObjSpidertent* this, GlobalContext* globalCtx); + const ActorInit Obj_Spidertent_InitVars = { ACTOR_OBJ_SPIDERTENT, ACTORCAT_BG, @@ -28,118 +35,789 @@ const ActorInit Obj_Spidertent_InitVars = { (ActorFunc)ObjSpidertent_Draw, }; -// static ColliderTrisElementInit sTrisElementsInit[6] = { -static ColliderTrisElementInit D_80B31060[6] = { +static ColliderTrisElementInit sTrisElementsInit1[] = { { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { 68.80000305175781f, 0.0f, 18.799999237060547f }, { 76.30000305175781f, 0.0f, -63.79999923706055f }, { 1.2999999523162842f, 40.0f, -3.799999952316284f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { 68.80000305175781f, 0.0f, 18.799999237060547f }, + { 76.30000305175781f, 0.0f, -63.79999923706055f }, + { 1.2999999523162842f, 40.0f, -3.799999952316284f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { 76.30000305175781f, 0.0f, -63.79999923706055f }, { 23.799999237060547f, 0.0f, -116.30000305175781f }, { 1.2999999523162842f, 40.0f, -3.799999952316284f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { 76.30000305175781f, 0.0f, -63.79999923706055f }, + { 23.799999237060547f, 0.0f, -116.30000305175781f }, + { 1.2999999523162842f, 40.0f, -3.799999952316284f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { 23.799999237060547f, 0.0f, -116.30000305175781f }, { -111.30000305175781f, 0.0f, -26.299999237060547f }, { 1.2999999523162842f, 40.0f, -3.799999952316284f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { 23.799999237060547f, 0.0f, -116.30000305175781f }, + { -111.30000305175781f, 0.0f, -26.299999237060547f }, + { 1.2999999523162842f, 40.0f, -3.799999952316284f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { -111.30000305175781f, 0.0f, -26.299999237060547f }, { -81.30000305175781f, 0.0f, 78.80000305175781f }, { 1.2999999523162842f, 40.0f, -3.799999952316284f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { -111.30000305175781f, 0.0f, -26.299999237060547f }, + { -81.30000305175781f, 0.0f, 78.80000305175781f }, + { 1.2999999523162842f, 40.0f, -3.799999952316284f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { -81.30000305175781f, 0.0f, 78.80000305175781f }, { 23.799999237060547f, 0.0f, 108.80000305175781f }, { 1.2999999523162842f, 40.0f, -3.799999952316284f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { -81.30000305175781f, 0.0f, 78.80000305175781f }, + { 23.799999237060547f, 0.0f, 108.80000305175781f }, + { 1.2999999523162842f, 40.0f, -3.799999952316284f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { 23.799999237060547f, 0.0f, 108.80000305175781f }, { 68.80000305175781f, 0.0f, 18.799999237060547f }, { 1.2999999523162842f, 40.0f, -3.799999952316284f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { 23.799999237060547f, 0.0f, 108.80000305175781f }, + { 68.80000305175781f, 0.0f, 18.799999237060547f }, + { 1.2999999523162842f, 40.0f, -3.799999952316284f } } }, }, }; -// static ColliderTrisInit sTrisInit = { -static ColliderTrisInit D_80B311C8 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_TRIS, }, - 6, D_80B31060, // sTrisElementsInit, +static ColliderTrisInit sTrisInit1 = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_TRIS, + }, + 6, + sTrisElementsInit1, }; -// static ColliderTrisElementInit sTrisElementsInit[6] = { -static ColliderTrisElementInit D_80B311D8[6] = { +static ColliderTrisElementInit sTrisElementsInit2[] = { { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { 17.799999237060547f, 0.0f, 81.5999984741211f }, { 51.599998474121094f, 0.0f, 14.100000381469727f }, { 0.8999999761581421f, 30.0f, -2.799999952316284f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { 17.799999237060547f, 0.0f, 81.5999984741211f }, + { 51.599998474121094f, 0.0f, 14.100000381469727f }, + { 0.8999999761581421f, 30.0f, -2.799999952316284f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { -60.900001525878906f, 0.0f, 59.099998474121094f }, { 17.799999237060547f, 0.0f, 81.5999984741211f }, { 0.8999999761581421f, 30.0f, -2.799999952316284f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { -60.900001525878906f, 0.0f, 59.099998474121094f }, + { 17.799999237060547f, 0.0f, 81.5999984741211f }, + { 0.8999999761581421f, 30.0f, -2.799999952316284f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { -83.4000015258789f, 0.0f, -19.700000762939453f }, { -60.900001525878906f, 0.0f, 59.099998474121094f }, { 0.8999999761581421f, 30.0f, -2.799999952316284f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { -83.4000015258789f, 0.0f, -19.700000762939453f }, + { -60.900001525878906f, 0.0f, 59.099998474121094f }, + { 0.8999999761581421f, 30.0f, -2.799999952316284f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { 17.799999237060547f, 0.0f, -87.19999694824219f }, { -83.4000015258789f, 0.0f, -19.700000762939453f }, { 0.8999999761581421f, 30.0f, -2.799999952316284f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { 17.799999237060547f, 0.0f, -87.19999694824219f }, + { -83.4000015258789f, 0.0f, -19.700000762939453f }, + { 0.8999999761581421f, 30.0f, -2.799999952316284f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { 57.20000076293945f, 0.0f, -47.79999923706055f }, { 17.799999237060547f, 0.0f, -87.19999694824219f }, { 0.8999999761581421f, 30.0f, -2.799999952316284f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { 57.20000076293945f, 0.0f, -47.79999923706055f }, + { 17.799999237060547f, 0.0f, -87.19999694824219f }, + { 0.8999999761581421f, 30.0f, -2.799999952316284f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { 51.599998474121094f, 0.0f, 14.100000381469727f }, { 57.20000076293945f, 0.0f, -47.79999923706055f }, { 0.8999999761581421f, 30.0f, -2.799999952316284f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { 51.599998474121094f, 0.0f, 14.100000381469727f }, + { 57.20000076293945f, 0.0f, -47.79999923706055f }, + { 0.8999999761581421f, 30.0f, -2.799999952316284f } } }, }, }; -// static ColliderTrisInit sTrisInit = { -static ColliderTrisInit D_80B31340 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_TRIS, }, - 6, D_80B311D8, // sTrisElementsInit, +static ColliderTrisInit sTrisInit2 = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_TRIS, + }, + 6, + sTrisElementsInit2, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B31418[] = { +typedef struct { + /* 0x00 */ Gfx* unk_00; + /* 0x04 */ CollisionHeader* unk_04; + /* 0x08 */ ColliderTrisInit* unk_08; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ f32 unk_10; + /* 0x14 */ f32 unk_14; + /* 0x18 */ f32 unk_18; + /* 0x1C */ f32 unk_1C; + /* 0x20 */ f32 unk_20; + /* 0x24 */ f32 unk_24; +} ObjSpidertentStruct; + +ObjSpidertentStruct D_80B31350[] = { + { + object_spidertent_DL_000070, + &object_spidertent_Colheader_0011AC, + &sTrisInit1, + 0.9f, + 1.3f, + 40.0f, + -3.8f, + SQ(120.0f), + 240.0f, + 200.0f, + }, + { + object_spidertent_DL_001250, + &object_spidertent_Colheader_00238C, + &sTrisInit2, + 0.9f, + 0.9f, + 30.0f, + -2.8f, + SQ(88.0f), + 176.0f, + 168.0f, + }, +}; + +typedef struct { + /* 0x00 */ f32 unk_00; + /* 0x04 */ f32 unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ s16 unk_0C; + /* 0x0E */ s8 unk_0E; + /* 0x0F */ s8 unk_0F; + /* 0x10 */ Color_RGBA8 unk_10; + /* 0x14 */ Color_RGBA8 unk_14; +} ObjSpidertentStruct2; + +ObjSpidertentStruct2 D_80B313A0[] = { + { + -20.0f, + 6.0f, + 0.0f, + 100, + 14, + 5, + { 255, 255, 160, 160 }, + { 255, 0, 0, 0 }, + }, + { + 0.0f, + 4.0f, + 1.2f, + 80, + 9, + 3, + { 255, 255, 160, 120 }, + { 255, 0, 0, 0 }, + }, + { + 0.0f, + 4.2f, + 0.3f, + 70, + 12, + 2, + { 255, 255, 160, 100 }, + { 55, 0, 0, 0 }, + }, + { + 0.0f, + 3.0f, + 0.0f, + 20, + 6, + 2, + { 255, 100, 20, 80 }, + { 255, 0, 0, 0 }, + }, +}; + +Vec3f D_80B31400 = { 1.0f, 0.0f, 0.0f }; +Vec3f D_80B3140C = { 0.0f, 1.0f, 0.0f }; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 200, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 200, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_STOP), }; +s32 func_80B2FB10(Vec3f* arg0, Vec3f* arg1) { + f32 temp_f0 = Math3D_LengthSquared(arg0); + f32 temp_f2; + + if (temp_f0 < 9.999999e-9f) { + return false; + } + temp_f2 = 1.0f / sqrtf(temp_f0); + arg1->x = arg0->x * temp_f2; + arg1->y = arg0->y * temp_f2; + arg1->z = arg0->z * temp_f2; + return true; +} + +s32 func_80B2FB94(Vec3f* arg0, f32 arg1, TriNorm* triNorm, Vec3f* arg3, f32* arg4) { + f32 temp_f0; + f32 temp_f0_2; + f32 temp_f16; + Vec3f sp48; + Vec3f sp3C; + f32 temp_f2; + f32 temp_f2_2; + + temp_f0 = triNorm->plane.normal.x * arg1; + temp_f2 = triNorm->plane.normal.y * arg1; + temp_f16 = triNorm->plane.normal.z * arg1; + + sp48.x = arg0->x + temp_f0; + sp48.y = arg0->y + temp_f2; + sp48.z = arg0->z + temp_f16; + + sp3C.x = arg0->x - temp_f0; + sp3C.y = arg0->y - temp_f2; + sp3C.z = arg0->z - temp_f16; + + if (Math3D_LineSegVsPlane(triNorm->plane.normal.x, triNorm->plane.normal.y, triNorm->plane.normal.z, + triNorm->plane.originDist, &sp48, &sp3C, arg3, 0)) { + temp_f0_2 = Math3D_Vec3fDistSq(arg0, arg3); + temp_f2_2 = SQ(arg1) - temp_f0_2; + if (SQ(arg1) < temp_f0_2) { + return false; + } + *arg4 = sqrtf(temp_f2_2); + return true; + } + return false; +} + +s32 func_80B2FC98(TriNorm* triNorm, Vec3f* arg1) { + Vec3f sp84; + Vec3f sp78; + Vec3f* vtx; + Vec3f* vtx2; + Vec3f sp4C[3]; + s32 i; + + if (triNorm->plane.normal.x > 0.5f) { + vtx = &triNorm->vtx[0]; + vtx2 = &triNorm->vtx[2]; + + for (i = 0; i < ARRAY_COUNT(sp4C); i++, vtx = &triNorm->vtx[i]) { + sp84.x = 0.0f; + sp84.y = vtx->y - arg1->y; + sp84.z = vtx->z - arg1->z; + + sp78.x = 0.0f; + sp78.y = vtx2->y - arg1->y; + sp78.z = vtx2->z - arg1->z; + + Math3D_CrossProduct(&sp84, &sp78, &sp4C[i]); + + vtx2 = vtx; + } + + return ((sp4C[0].x >= 0.0f) && (sp4C[1].x >= 0.0f) && (sp4C[2].x >= 0.0f)) || + ((sp4C[0].x < 0.0f) && (sp4C[1].x < 0.0f) && (sp4C[2].x < 0.0f)); + } else if (triNorm->plane.normal.y > 0.5f) { + vtx = &triNorm->vtx[0]; + vtx2 = &triNorm->vtx[2]; + + for (i = 0; i < ARRAY_COUNT(sp4C); i++, vtx = &triNorm->vtx[i]) { + sp84.x = vtx->x - arg1->x; + sp84.y = 0.0f; + sp84.z = vtx->z - arg1->z; + + sp78.x = vtx2->x - arg1->x; + sp78.y = 0.0f; + sp78.z = vtx2->z - arg1->z; + + Math3D_CrossProduct(&sp84, &sp78, &sp4C[i]); + + vtx2 = vtx; + } + + return ((sp4C[0].y >= 0.0f) && (sp4C[1].y >= 0.0f) && (sp4C[2].y >= 0.0f)) || + ((sp4C[0].y < 0.0f) && (sp4C[1].y < 0.0f) && (sp4C[2].y < 0.0f)); + } else { + vtx = &triNorm->vtx[0]; + vtx2 = &triNorm->vtx[2]; + + for (i = 0; i < ARRAY_COUNT(sp4C); i++, vtx = &triNorm->vtx[i]) { + sp84.x = vtx->x - arg1->x; + sp84.y = vtx->y - arg1->y; + sp84.z = 0.0f; + + sp78.x = vtx2->x - arg1->x; + sp78.y = vtx2->y - arg1->y; + sp78.z = 0.0f; + + Math3D_CrossProduct(&sp84, &sp78, &sp4C[i]); + + vtx2 = vtx; + } + + return ((sp4C[0].z >= 0.0f) && (sp4C[1].z >= 0.0f) && (sp4C[2].z >= 0.0f)) || + ((sp4C[0].z < 0.0f) && (sp4C[1].z < 0.0f) && (sp4C[2].z < 0.0f)); + } +} + +void func_80B300F4(ObjSpidertent* thisx, GlobalContext* globalCtx, TriNorm* triNorm, Vec3f* arg3, f32 arg4, s32 arg5) { + ObjSpidertent* this = THIS; + ObjSpidertentStruct* spE0 = &D_80B31350[OBJSPIDERTENT_GET_1(&this->dyna.actor)]; + f32 temp_f24; + f32 phi_f22; + s32 i; + f32 temp_f0; + Vec3f spC4; + Vec3f spB8; + Vec3f spAC; + Vec3f spA0; + Vec3f sp94; + Vec3f sp88; + f32 temp_f2; + ObjSpidertentStruct2* sp80 = &D_80B313A0[arg5]; + + spAC.x = triNorm->plane.normal.x; + spAC.y = triNorm->plane.normal.y; + spAC.z = triNorm->plane.normal.z; + + if (triNorm->plane.normal.y < 0.5f) { + Math3D_CrossProduct(&spAC, &D_80B3140C, &sp88); + } else { + Math3D_CrossProduct(&spAC, &D_80B31400, &sp88); + } + + if (func_80B2FB10(&sp88, &spA0)) { + phi_f22 = 0.0f; + temp_f24 = (2 * M_PI) / sp80->unk_0F; + + for (i = 0; i < sp80->unk_0F; i++) { + temp_f2 = (Rand_ZeroOne() * temp_f24) + phi_f22; + Matrix_InsertRotationAroundUnitVector_f(temp_f2, &spAC, MTXMODE_NEW); + Matrix_MultiplyVector3fByState(&spA0, &sp94); + + if (arg5 == 0) { + spC4.x = (sp94.x * arg4) + arg3->x; + spC4.y = (sp94.y * arg4) + arg3->y; + spC4.z = (sp94.z * arg4) + arg3->z; + } else { + temp_f0 = Rand_ZeroOne(); + temp_f0 = (1.0f - SQ(temp_f0)) * arg4; + spC4.x = (sp94.x * temp_f0) + arg3->x; + spC4.y = (sp94.y * temp_f0) + arg3->y; + spC4.z = (sp94.z * temp_f0) + arg3->z; + } + + if ((Math3D_Vec3fDistSq(&spC4, &this->dyna.actor.world.pos) < spE0->unk_1C) && + func_80B2FC98(triNorm, &spC4)) { + spB8.x = sp80->unk_08 * sp94.x; + spB8.y = sp80->unk_08 * sp94.y; + spB8.z = sp80->unk_08 * sp94.z; + + EffectSsDeadDb_Spawn(globalCtx, &spC4, &spB8, &gZeroVec3f, &sp80->unk_10, &sp80->unk_14, sp80->unk_0C, + 0, sp80->unk_0E); + } + + phi_f22 += temp_f24; + } + } +} + +void func_80B30410(ObjSpidertent* this, Vec3f* arg1) { + s32 i; + + Math_Vec3f_Copy(&this->unk_3A4, arg1); + this->unk_3C2 = 255; + this->unk_3C3 = 255; + this->unk_3C4 = 255; + this->unk_3C5 = 255; + for (i = 0; i < ARRAY_COUNT(D_80B313A0); i++) { + this->unk_3B0[i] = D_80B313A0[i].unk_00; + } + this->unk_3C0 = 0; +} + +s32 func_80B30480(ObjSpidertent* this, GlobalContext* globalCtx, Vec3f* arg2) { + Player* player = GET_PLAYER(globalCtx); + TriNorm* triNorm; + s32 i; + Vec3f sp58; + f32 sp54; + + if (player->itemActionParam == 7) { + if (player->unk_B28 > 0) { + for (i = 0; i < ARRAY_COUNT(this->colliderElements); i++) { + triNorm = &this->collider.elements[i].dim; + + if (func_80B2FB94(&player->swordInfo[0].tip, 6.0f, triNorm, &sp58, &sp54) && + func_80B2FC98(triNorm, &sp58)) { + break; + } + } + + if (i < ARRAY_COUNT(this->colliderElements)) { + Math_Vec3f_Copy(arg2, &player->swordInfo[0].tip); + return true; + } + } + } + return false; +} + +void ObjSpidertent_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjSpidertent* this = THIS; + s32 temp_s1 = OBJSPIDERTENT_GET_1(&this->dyna.actor); + ObjSpidertentStruct* ptr = &D_80B31350[temp_s1]; + ColliderTrisElementInit* element; + Vec3f sp70[3]; + Vec3f sp64; + s32 i, j; + + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 0); + Collider_InitTris(globalCtx, &this->collider); + + if (Flags_GetSwitch(globalCtx, OBJSPIDERTENT_GET_7F00(&this->dyna.actor))) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } + + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, ptr->unk_04); + Collider_SetTris(globalCtx, &this->collider, &this->dyna.actor, D_80B31350[temp_s1].unk_08, this->colliderElements); + Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + + sp64.x = ptr->unk_10 * 1.2f; + sp64.y = ptr->unk_10 * 1.2f; + sp64.z = ptr->unk_10 * 1.2f; + + Matrix_MultiplyVector3fByState(&sp64, &this->dyna.actor.focus.pos); + Matrix_InsertTranslation(ptr->unk_10, ptr->unk_14 + 5.0f, ptr->unk_18, MTXMODE_APPLY); + Matrix_Scale(ptr->unk_0C, ptr->unk_0C, ptr->unk_0C, MTXMODE_APPLY); + Matrix_InsertTranslation(-ptr->unk_10, -ptr->unk_14, -ptr->unk_18, MTXMODE_APPLY); + + for (i = 0; i < 6; i++) { + element = &ptr->unk_08->elements[i]; + + for (j = 0; j < ARRAY_COUNT(sp70); j++) { + Matrix_MultiplyVector3fByState(&element->dim.vtx[j], &sp70[j]); + } + + Collider_SetTrisVertices(&this->collider, i, &sp70[0], &sp70[1], &sp70[2]); + } + + func_80B307E0(this); +} + +void ObjSpidertent_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjSpidertent* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + Collider_DestroyTris(globalCtx, &this->collider); +} + +void func_80B307E0(ObjSpidertent* this) { + this->unk_3C2 = 255; + this->unk_3C3 = 255; + this->unk_3C4 = 255; + this->unk_3C5 = 255; + this->actionFunc = func_80B30808; +} + +void func_80B30808(ObjSpidertent* this, GlobalContext* globalCtx) { + s32 phi_s4; + s32 i; + ObjSpidertentStruct* ptr2 = &D_80B31350[OBJSPIDERTENT_GET_1(&this->dyna.actor)]; + Vec3f sp70; + Vec3s* hitPos; + ColliderTrisElement* ptr; + f32 temp_f0; + s32 phi_s1; + Vec3f sp54; + f32 phi_f20; + s32 phi_s0 = false; + + if (this->collider.base.acFlags & AC_HIT) { + Player* player = GET_PLAYER(globalCtx); + + this->collider.base.acFlags &= ~AC_HIT; + phi_s1 = 0; + phi_s4 = -1; + phi_f20 = FLT_MAX; + + for (i = 0; i < ARRAY_COUNT(this->colliderElements); i++) { + ptr = &this->collider.elements[i]; + + if (ptr->info.bumperFlags & BUMP_HIT) { + sp54.x = ptr->info.bumper.hitPos.x; + sp54.y = ptr->info.bumper.hitPos.y; + sp54.z = ptr->info.bumper.hitPos.z; + + temp_f0 = Math3D_Vec3fDistSq(&sp54, &player->actor.world.pos); + if (temp_f0 < phi_f20) { + phi_f20 = temp_f0; + phi_s4 = i; + } + } + } + + if (phi_s4 >= 0) { + hitPos = &this->collider.elements[phi_s4].info.bumper.hitPos; + + sp70.x = hitPos->x; + sp70.y = hitPos->y; + sp70.z = hitPos->z; + } else { + Math_Vec3f_Copy(&sp70, &this->dyna.actor.world.pos); + } + phi_s0 = true; + } else if ((this->dyna.actor.xzDistToPlayer < ptr2->unk_24) && func_80B30480(this, globalCtx, &sp70)) { + phi_s0 = true; + } + + if (phi_s0) { + func_80B30410(this, &sp70); + func_80B30A2C(this); + } else { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +void func_80B30A2C(ObjSpidertent* this) { + this->dyna.actor.flags |= ACTOR_FLAG_10; + this->actionFunc = func_80B30A4C; +} + +void func_80B30A4C(ObjSpidertent* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + if (this->dyna.actor.cutscene >= 0) { + func_800B7298(globalCtx, &this->dyna.actor, 1); + } + Flags_SetSwitch(globalCtx, OBJSPIDERTENT_GET_7F00(&this->dyna.actor)); + func_80B30AD4(this); + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } +} + +void func_80B30AD4(ObjSpidertent* this) { + this->unk_3C1 = 80; + this->unk_3C6 = 0; + this->unk_3C7 = 0; + this->actionFunc = func_80B30AF8; +} + +#ifdef NON_MATCHING +void func_80B30AF8(ObjSpidertent* this, GlobalContext* globalCtx) { + ObjSpidertentStruct* temp_s0 = &D_80B31350[OBJSPIDERTENT_GET_1(&this->dyna.actor)]; + TriNorm* triNorm; + s32 i, j; + ObjSpidertentStruct2* ptr; + Vec3f sp60; + f32 sp5C; + + this->unk_3C6++; + + if (this->unk_3C6 < 40) { + if (this->unk_3C2 > 2) { + this->unk_3C2 -= 2; + } else { + this->unk_3C2 = 0; + } + + if (this->unk_3C3 > 5) { + this->unk_3C3 -= 5; + } else { + this->unk_3C3 = 0; + } + + if (this->unk_3C4 > 5) { + this->unk_3C4 -= 5; + } else { + this->unk_3C4 = 0; + } + + if (this->unk_3C5 > 1) { + this->unk_3C5--; + } else { + this->unk_3C5 = 0; + } + } else { + if (this->unk_3C2 > 4) { + this->unk_3C2 -= 4; + } else { + this->unk_3C2 = 0; + } + + if (this->unk_3C3 < 255) { + this->unk_3C3++; + } else { + this->unk_3C3 = 255; + } + + if (this->unk_3C4 < 255) { + this->unk_3C4++; + } else { + this->unk_3C4 = 255; + } + + if (this->unk_3C5 > 10) { + this->unk_3C5 -= 10; + } else { + this->unk_3C5 = 0; + } + } + + this->unk_3C1--; + if (this->unk_3C1 == 40) { + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + } + + if (this->unk_3C1 >= 0x20) { + if (this->unk_3C7 > 0) { + this->unk_3C7--; + } else if (this->unk_3C1 >= 0x33) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EN_EXTINCT); + this->unk_3C7 = Rand_S16Offset(2, 2); + } else { + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->dyna.actor.world.pos, 11, NA_SE_EN_EXTINCT); + this->unk_3C7 = Rand_S16Offset(2, 4); + } + + for (j = 0; j < ARRAY_COUNT(this->unk_3B0); j++) { + this->unk_3B0[j] += D_80B313A0[j].unk_04; + if (temp_s0->unk_20 < this->unk_3B0[j]) { + this->unk_3C0 |= (1 << j); + } + } + + for (i = 0; i < ARRAY_COUNT(this->colliderElements); i++) { + triNorm = &this->collider.elements[i].dim; + + for (j = 0; j < ARRAY_COUNT(this->unk_3B0); j++) { + if (!(this->unk_3B0[j] < 5.0f) && !(this->unk_3C0 & (1 << j)) && + func_80B2FB94(&this->unk_3A4, this->unk_3B0[j], triNorm, &sp60, &sp5C)) { + func_80B300F4(this, globalCtx, triNorm, &sp60, sp5C, j); + } + } + } + } else if (this->unk_3C1 <= 0) { + ActorCutscene_Stop(this->dyna.actor.cutscene); + Actor_MarkForDeath(&this->dyna.actor); + } +} +#else +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/func_80B30AF8.s") #endif -extern ColliderTrisElementInit D_80B31060[6]; -extern ColliderTrisInit D_80B311C8; -extern ColliderTrisElementInit D_80B311D8[6]; -extern ColliderTrisInit D_80B31340; -extern InitChainEntry D_80B31418[]; +void ObjSpidertent_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjSpidertent* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/func_80B2FB10.s") + this->actionFunc(this, globalCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/func_80B2FB94.s") +void ObjSpidertent_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjSpidertent* this = THIS; + s32 params = OBJSPIDERTENT_GET_1(&this->dyna.actor); + s32 temp_f18 = this->unk_3C5 * (29.0f / 51); + Gfx* gfx; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/func_80B2FC98.s") + OPEN_DISPS(globalCtx->state.gfxCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/func_80B300F4.s") + gfx = POLY_XLU_DISP; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/func_80B30410.s") + gSPDisplayList(gfx++, &sSetupDL[6 * 25]); + gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(gfx++, 0, 0xFF, this->unk_3C2, this->unk_3C3, this->unk_3C4, temp_f18); + gSPDisplayList(gfx++, D_80B31350[params].unk_00); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/func_80B30480.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/ObjSpidertent_Init.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/ObjSpidertent_Destroy.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/func_80B307E0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/func_80B30808.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/func_80B30A2C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/func_80B30A4C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/func_80B30AD4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/func_80B30AF8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/ObjSpidertent_Update.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/ObjSpidertent_Draw.s") + POLY_XLU_DISP = gfx; + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.h b/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.h index a40faa86a9..9289bd3656 100644 --- a/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.h +++ b/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.h @@ -7,9 +7,23 @@ struct ObjSpidertent; typedef void (*ObjSpidertentActionFunc)(struct ObjSpidertent*, GlobalContext*); +#define OBJSPIDERTENT_GET_1(thisx) ((thisx)->params & 1) +#define OBJSPIDERTENT_GET_7F00(thisx) (((thisx)->params >> 8) & 0x7F) + typedef struct ObjSpidertent { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x284]; + /* 0x0000 */ DynaPolyActor dyna; + /* 0x015C */ ColliderTris collider; + /* 0x017C */ ColliderTrisElement colliderElements[6]; + /* 0x03A4 */ Vec3f unk_3A4; + /* 0x03B0 */ f32 unk_3B0[4]; + /* 0x03C0 */ u8 unk_3C0; + /* 0x03C1 */ s8 unk_3C1; + /* 0x03C2 */ u8 unk_3C2; + /* 0x03C3 */ u8 unk_3C3; + /* 0x03C4 */ u8 unk_3C4; + /* 0x03C5 */ u8 unk_3C5; + /* 0x03C6 */ s8 unk_3C6; + /* 0x03C7 */ s8 unk_3C7; /* 0x03C8 */ ObjSpidertentActionFunc actionFunc; } ObjSpidertent; // size = 0x3CC diff --git a/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.c b/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.c index 9547aa04f7..20f4a1c50b 100644 --- a/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.c +++ b/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.c @@ -5,6 +5,7 @@ */ #include "z_obj_spinyroll.h" +#include "objects/object_spinyroll/object_spinyroll.h" #define FLAGS (ACTOR_FLAG_10) @@ -15,7 +16,18 @@ void ObjSpinyroll_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjSpinyroll_Update(Actor* thisx, GlobalContext* globalCtx); void ObjSpinyroll_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80A1E9C4(ObjSpinyroll* this); +void func_80A1E9E0(ObjSpinyroll* this, GlobalContext* globalCtx); +void func_80A1EA4C(ObjSpinyroll* this, GlobalContext* globalCtx); +void func_80A1EAAC(ObjSpinyroll* this); +void func_80A1EAE0(ObjSpinyroll* this, GlobalContext* globalCtx); +void func_80A1EB40(ObjSpinyroll* this); +void func_80A1EB54(ObjSpinyroll* this, GlobalContext* globalCtx); +void func_80A1EC24(ObjSpinyroll* this); +void func_80A1EC38(ObjSpinyroll* this, GlobalContext* globalCtx); +void func_80A1ECC0(ObjSpinyroll* this); +void func_80A1ECD4(ObjSpinyroll* this, GlobalContext* globalCtx); + const ActorInit Obj_Spinyroll_InitVars = { ACTOR_OBJ_SPINYROLL, ACTORCAT_PROP, @@ -28,121 +40,669 @@ const ActorInit Obj_Spinyroll_InitVars = { (ActorFunc)ObjSpinyroll_Draw, }; -// static ColliderTrisElementInit sTrisElementsInit[6] = { -static ColliderTrisElementInit D_80A1F040[6] = { +static ColliderTrisElementInit sTrisElementsInit[] = { { - { ELEMTYPE_UNK0, { 0x20000000, 0x00, 0x04 }, { 0x01C37BB6, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0x20000000, 0x00, 0x04 }, + { 0x01C37BB6, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { -60.0f, 0.0f, 17.0f }, { 60.0f, 0.0f, 17.0f }, { 60.0f, 40.0f, 17.0f } } }, }, { - { ELEMTYPE_UNK0, { 0x20000000, 0x00, 0x04 }, { 0x01C37BB6, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0x20000000, 0x00, 0x04 }, + { 0x01C37BB6, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { -60.0f, 0.0f, 17.0f }, { 60.0f, 40.0f, 17.0f }, { -60.0f, 40.0f, 17.0f } } }, }, { - { ELEMTYPE_UNK0, { 0x20000000, 0x00, 0x04 }, { 0x01C37BB6, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0x20000000, 0x00, 0x04 }, + { 0x01C37BB6, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 60.0f, 0.0f, -17.0f }, { -60.0f, 0.0f, -17.0f }, { -60.0f, 40.0f, -17.0f } } }, }, { - { ELEMTYPE_UNK0, { 0x20000000, 0x00, 0x04 }, { 0x01C37BB6, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0x20000000, 0x00, 0x04 }, + { 0x01C37BB6, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 60.0f, 0.0f, -17.0f }, { -60.0f, 40.0f, -17.0f }, { 60.0f, 40.0f, -17.0f } } }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x04, 0x04 }, { 0x01C37BB6, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x04, 0x04 }, + { 0x01C37BB6, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 60.0f, 20.0f, -12.0f }, { -60.0f, 20.0f, -12.0f }, { -60.0f, 20.0f, 12.0f } } }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x04, 0x04 }, { 0x01C37BB6, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x04, 0x04 }, + { 0x01C37BB6, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 60.0f, 20.0f, -12.0f }, { -60.0f, 20.0f, 12.0f }, { 60.0f, 20.0f, 12.0f } } }, }, }; -// static ColliderTrisInit sTrisInit = { -static ColliderTrisInit D_80A1F1A8 = { - { COLTYPE_METAL, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_TRIS, }, - 6, D_80A1F040, // sTrisElementsInit, +static ColliderTrisInit sTrisInit = { + { + COLTYPE_METAL, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_TRIS, + }, + 6, + sTrisElementsInit, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80A1F204[] = { +f32 D_80A1F1B8[] = { 1.0f, 2.0f, 4.0f }; + +f32 D_80A1F1C4[] = { + 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, +}; + +s16 D_80A1F1E4[] = { + 1, 10, 20, 30, 40, 50, 60, 70, +}; + +f32 D_80A1F1F4[] = { 30.0f, -30.0f }; + +f32 D_80A1F1FC[] = { 9.0f, -9.0f }; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 500, ICHAIN_STOP), }; +s16 D_80A1F20C[] = { 0xFA0, -0xFA0 }; + +void func_80A1DA50(GlobalContext* globalCtx, ObjSpinyroll* this, Vec3f* arg2, Vec3f* arg3) { + Vec3f sp1C; + + Math_Vec3f_Sum(arg2, arg3, &sp1C); + Math_Vec3f_Scale(&sp1C, 0.5f); + EffectSsHitMark_SpawnFixedScale(globalCtx, 3, &sp1C); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_IT_SHIELD_REFLECT_SW); +} + +void func_80A1DAAC(Vec3f* arg0, Vec3f* arg1, s16 arg2) { + f32 sp1C = Math_SinS(arg2); + f32 sp18 = Math_CosS(arg2); + + arg0->x = (arg1->z * sp1C) + (arg1->x * sp18); + arg0->y = arg1->y; + arg0->z = (arg1->z * sp18) - (arg1->x * sp1C); +} + +void func_80A1DB2C(Actor* thisx) { + ObjSpinyroll* this = THIS; + s32 i; + s32 j; + s32 params = OBJSPINYROLL_GET_C000(&this->dyna.actor); + Vec3f sp7C[3]; + Vec3f sp70; + f32 temp = D_80A1F1B8[params]; + ColliderTrisElementInit* ptr; + + for (i = 0; i < ARRAY_COUNT(this->colliderElements); i++) { + for (j = 0; j < ARRAY_COUNT(sp7C); j++) { + ptr = &sTrisInit.elements[i]; + + sp70.x = ptr->dim.vtx[j].x * temp; + sp70.y = ptr->dim.vtx[j].y; + sp70.z = ptr->dim.vtx[j].z; + + func_80A1DAAC(&sp7C[j], &sp70, this->dyna.actor.shape.rot.y); + Math_Vec3f_Sum(&sp7C[j], &this->dyna.actor.world.pos, &sp7C[j]); + } + Collider_SetTrisVertices(&this->collider, i, &sp7C[0], &sp7C[1], &sp7C[2]); + } +} + +void func_80A1DC5C(ObjSpinyroll* this) { + this->unk_4D8 += 0x5DC0; + Math_StepToF(&this->unk_4D4, 0.0f, 0.32f); + this->unk_4D0 = ((Math_SinS(this->unk_4D8) + 1.0f) * this->unk_4D4) + 24.0f; +} + +void func_80A1DCCC(ObjSpinyroll* this) { + f32 phi_f2; + + if (this->dyna.actor.speedXZ > 3.0f) { + phi_f2 = 3.0f; + } else { + phi_f2 = this->dyna.actor.speedXZ; + } + + if (this->unk_4D4 < phi_f2) { + this->unk_4D4 = phi_f2; + } +} + +void func_80A1DD18(ObjSpinyroll* this) { + f32 temp_f0; + Vec3f* sp20 = &this->unk_4AC[this->unk_4A8 ^ 1]; + + Math_Vec3f_Diff(sp20, &this->dyna.actor.world.pos, &this->unk_4C4); + + temp_f0 = Math3D_Vec3fMagnitude(&this->unk_4C4); + if (temp_f0 < 0.01f) { + Math_Vec3f_Diff(sp20, &this->unk_4AC[this->unk_4A8], &this->unk_4C4); + + temp_f0 = Math3D_Vec3fMagnitude(&this->unk_4C4); + if (temp_f0 < 0.01f) { + Math_Vec3f_Copy(&this->unk_4C4, &gZeroVec3f); + return; + } + } + Math_Vec3f_Scale(&this->unk_4C4, 1.0f / temp_f0); +} + +void func_80A1DE10(ObjSpinyroll* this) { + this->dyna.actor.world.rot.y = Math_Vec3f_Yaw(&this->dyna.actor.world.pos, &this->unk_4AC[this->unk_4A8 ^ 1]); +} + +void func_80A1DE58(ObjSpinyroll* this) { + this->unk_4A8 = 0; + func_80A1DE10(this); + func_80A1DD18(this); +} + +void func_80A1DE84(ObjSpinyroll* this) { + this->unk_4A8 ^= 1; + func_80A1DE10(this); + func_80A1DD18(this); +} + +s32 func_80A1DEB8(ObjSpinyroll* this) { + s32 pad; + s32 sp30 = this->unk_4A8 ^ 1; + Vec3f sp24; + + Math_StepToF(&this->dyna.actor.speedXZ, this->unk_4A4, this->unk_4A4 * 0.2f); + + this->dyna.actor.world.pos.x += this->dyna.actor.speedXZ * this->unk_4C4.x; + this->dyna.actor.world.pos.y += this->dyna.actor.speedXZ * this->unk_4C4.y; + this->dyna.actor.world.pos.z += this->dyna.actor.speedXZ * this->unk_4C4.z; + + Math_Vec3f_Diff(&this->unk_4AC[sp30], &this->dyna.actor.world.pos, &sp24); + + return Math3D_LengthSquared(&sp24) < (SQ(this->dyna.actor.speedXZ) + 0.05f); +} + +void func_80A1DFA0(ObjSpinyroll* this) { + f32 temp_f0; + f32 phi_f12; + s32 i; + s32 j; + f32 temp_f2; + + this->unk_3A4.unk_F4 = (s32)(D_80A1F1B8[OBJSPINYROLL_GET_C000(&this->dyna.actor)] * 120.0f * (1.0f / 58)) + 2; + + temp_f0 = (D_80A1F1B8[OBJSPINYROLL_GET_C000(&this->dyna.actor)] * 120.0f) - 2.0f; + temp_f2 = temp_f0 / (this->unk_3A4.unk_F4 - 1); + temp_f0 *= 0.5f; + + for (i = 0; i < ARRAY_COUNT(this->unk_3A4.unk_00); i++) { + for (j = 0, phi_f12 = temp_f0; j < this->unk_3A4.unk_F4; j++, phi_f12 -= temp_f2) { + this->unk_3A4.unk_00[i].unk_00[j].unk_00 = phi_f12; + } + } +} + +#ifdef NON_MATCHING +// globalCtx not in s reg, something with ptr->unk_F0 = temp_s1; line +s32 func_80A1E074(ObjSpinyroll* this, GlobalContext* globalCtx, Vec3f* arg2, s32 arg3) { + s32 i; + s32 j; + ObjSpinyrollStruct2* ptr = &this->unk_3A4; + f32 temp_f0; + f32 temp_f20; + Vec3f spC8; + Vec3f spBC; + Vec3f spB0; + ObjSpinyrollStruct* temp_s1; + f32 temp_f22; + f32 temp_f24; + f32 temp; + s32 sp98; + + spC8.y = this->dyna.actor.world.pos.y + 10.0f; + spBC.y = spC8.y; + sp98 = false; + temp_f20 = FLT_MAX; + ptr->unk_F0 = NULL; + + for (i = 0; i < ARRAY_COUNT(this->unk_3A4.unk_00); i++) { + temp = D_80A1F1F4[i]; + temp_f22 = temp * this->unk_4C4.x; + temp_f24 = temp * this->unk_4C4.z; + temp_s1 = &ptr->unk_00[i]; + + for (j = 0; j < ptr->unk_F4; j++) { + spC8.x = + (temp_s1->unk_00[j].unk_00 * Math_CosS(this->dyna.actor.world.rot.y)) + this->dyna.actor.world.pos.x; + spC8.z = + (temp_s1->unk_00[j].unk_00 * -Math_SinS(this->dyna.actor.world.rot.y)) + this->dyna.actor.world.pos.z; + + spBC.x = temp_f22 + spC8.x; + spBC.z = temp_f24 + spC8.z; + + if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &spC8, &spBC, &spB0, &temp_s1->unk_00[j].unk_04, 1, 0, 0, 1, + &temp_s1->unk_00[j].bgId, &this->dyna.actor, 0.0f)) { + if (arg3 && (this->dyna.actor.flags & ACTOR_FLAG_40)) { + func_80A1DA50(globalCtx, this, &spC8, &spB0); + } + + temp_f0 = Math3D_Vec3fDistSq(&spC8, &spB0); + if (temp_f0 < temp_f20) { + temp_f20 = temp_f0; + sp98 = true; + Math_Vec3f_Diff(&spB0, &spBC, arg2); + ptr->unk_F0 = temp_s1; + } + } + } + } + + return sp98; +} +#else +s32 func_80A1E074(ObjSpinyroll* this, GlobalContext* globalCtx, Vec3f* arg2, s32 arg3); +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1E074.s") #endif -extern ColliderTrisElementInit D_80A1F040[6]; -extern ColliderTrisInit D_80A1F1A8; -extern InitChainEntry D_80A1F204[]; +s32 func_80A1E2D8(ObjSpinyroll* this, GlobalContext* globalCtx, s32 arg2) { + Vec3f sp1C; -extern UNK_TYPE D_06000460; -extern UNK_TYPE D_06000E68; + if (func_80A1E074(this, globalCtx, &sp1C, arg2)) { + this->dyna.actor.world.pos.x += sp1C.x; + this->dyna.actor.world.pos.z += sp1C.z; + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1DA50.s") +s32 func_80A1E334(CollisionContext* colCtx, f32* arg1, CollisionPoly** polyOut, s32* bgId, Vec3f* arg4, + ObjSpinyroll* this) { + f32 temp_f0 = BgCheck_EntityRaycastFloor5(colCtx, polyOut, bgId, &this->dyna.actor, arg4); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1DAAC.s") + *arg1 = temp_f0; + return *arg1 > (BGCHECK_Y_MIN + 1); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1DB2C.s") +s32 func_80A1E394(CollisionContext* colCtx, f32* arg1, CollisionPoly** polyOut, s32* bgId, Vec3f* arg4, + ObjSpinyroll* this) { + return BgCheck_EntityCheckCeiling(colCtx, arg1, arg4, 24.0f, polyOut, bgId, &this->dyna.actor); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1DC5C.s") +#ifdef NON_MATCHING +s32 func_80A1E3D8(ObjSpinyroll* this, GlobalContext* globalCtx, f32* arg2, s32 arg3) { + f32 temp_f20; + ObjSpinyrollStruct2* spC8; + f32 phi_f22; + ObjSpinyrollColFunc spC0; + s32 i; + s32 j; + Vec3f spAC; + Vec3f spA0; + Vec3f sp94; + ObjSpinyrollStruct* temp_s0; + f32 phi_f26; + s32 sp84; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1DCCC.s") + spC8 = &this->unk_3A4; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1DD18.s") + if (this->unk_4C4.y > 0.0f) { + spC0 = func_80A1E394; + phi_f26 = this->dyna.actor.world.pos.y + 48.0f; + } else { + spC0 = func_80A1E334; + phi_f26 = this->dyna.actor.world.pos.y; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1DE10.s") + sp84 = false; + sp94.y = this->dyna.actor.world.pos.y + 24.0f; + phi_f22 = FLT_MAX; + spC8->unk_F0 = NULL; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1DE58.s") + for (i = 0; i < ARRAY_COUNT(this->unk_3A4.unk_00); i++) { + sp94.z = D_80A1F1FC[i]; + temp_s0 = &spC8->unk_00[i]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1DE84.s") + for (j = 0; j < spC8->unk_F4; j++) { + sp94.x = temp_s0->unk_00[j].unk_00; + func_80A1DAAC(&spAC, &sp94, this->dyna.actor.world.rot.y); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1DEB8.s") + spAC.x += this->dyna.actor.world.pos.x; + spAC.z += this->dyna.actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1DFA0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1E074.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1E2D8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1E334.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1E394.s") + if (spC0(&globalCtx->colCtx, &spA0.y, &temp_s0->unk_00[j].unk_04, &temp_s0->unk_00[j].bgId, &spAC, this)) { + temp_f20 = fabsf(spA0.y - spAC.y); + if (temp_f20 <= 24.0f) { + if (arg3 && (this->dyna.actor.flags & ACTOR_FLAG_40)) { + spA0.x = spAC.x; + spA0.z = spAC.z; + func_80A1DA50(globalCtx, this, &spAC, &spA0); + } + if (temp_f20 < phi_f22) { + sp84 = true; + *arg2 = spA0.y - phi_f26; + phi_f22 = temp_f20; + spC8->unk_F0 = temp_s0; + } + } + } + } + } + return sp84; +} +#else +s32 func_80A1E3D8(ObjSpinyroll* this, GlobalContext* globalCtx, f32* arg2, s32 arg3); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1E3D8.s") +#endif -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1E648.s") +s32 func_80A1E648(ObjSpinyroll* this, GlobalContext* globalCtx, s32 arg2) { + f32 sp1C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1E694.s") + if (func_80A1E3D8(this, globalCtx, &sp1C, arg2)) { + this->dyna.actor.world.pos.y += sp1C; + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1E6D4.s") +DynaPolyActor* func_80A1E694(ObjSpinyroll* this, GlobalContext* globalCtx) { + if (this->unk_3A4.unk_F0 != NULL) { + return DynaPoly_GetActor(&globalCtx->colCtx, this->unk_3A4.unk_F0->unk_00[0].bgId); + } + return NULL; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/ObjSpinyroll_Init.s") +s32 func_80A1E6D4(ObjSpinyroll* this, GlobalContext* globalCtx) { + DynaPolyActor* temp_v0 = func_80A1E694(this, globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/ObjSpinyroll_Destroy.s") + if ((temp_v0 != NULL) && (Math3D_Vec3fDistSq(&temp_v0->actor.world.pos, &temp_v0->actor.prevPos) > SQ(0.01f))) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1E9C4.s") +void ObjSpinyroll_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjSpinyroll* this = THIS; + f32 sp44; + Path* path; + s32 pad2; + Vec3s* points; + Vec3s* sp34; + Vec3s* sp30; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1E9E0.s") + sp44 = D_80A1F1B8[OBJSPINYROLL_GET_C000(&this->dyna.actor)]; + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + this->dyna.actor.world.rot.x = 0; + this->dyna.actor.world.rot.z = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1EA10.s") + this->dyna.actor.shape.rot.x = 0; + this->dyna.actor.shape.rot.z = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1EA4C.s") + this->dyna.actor.scale.x = 0.1f * sp44; + this->dyna.actor.scale.y = 0.1f; + this->dyna.actor.scale.z = 0.1f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1EAAC.s") + this->dyna.actor.uncullZoneScale = 250.0f * sp44; + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_spinyroll_Colheader_000E68); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1EAE0.s") + Collider_InitTris(globalCtx, &this->collider); + Collider_SetTris(globalCtx, &this->collider, &this->dyna.actor, &sTrisInit, this->colliderElements); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1EB40.s") + if (OBJSPINYROLL_GET_7F(&this->dyna.actor) == OBJSPINYROLL_GET_7F_7F) { + func_80A1E9C4(this); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1EB54.s") + this->dyna.actor.world.rot.y = 0; + func_80A1DFA0(this); + this->unk_4A4 = D_80A1F1C4[OBJSPINYROLL_GET_380(thisx)]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1EC24.s") + path = &globalCtx->setupPathList[OBJSPINYROLL_GET_7F(&this->dyna.actor)]; + points = Lib_SegmentedToVirtual(path->points); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1EC38.s") + sp34 = &points[0]; + sp30 = &points[1]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1ECC0.s") + Math_Vec3s_ToVec3f(&this->unk_4AC[0], sp34); + Math_Vec3s_ToVec3f(&this->unk_4AC[1], sp30); + Math_Vec3f_Copy(&this->dyna.actor.world.pos, &this->unk_4AC[0]); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1ECD4.s") + if ((sp34->x == sp30->x) && (sp34->y != sp30->y) && (sp34->z == sp30->z)) { + this->unk_49C = true; + } else if (((sp34->x != sp30->x) && (sp34->y == sp30->y) && (sp34->z == sp30->z)) || + ((sp34->x == sp30->x) && (sp34->y == sp30->y) && (sp34->z != sp30->z))) { + this->unk_49C = false; + } else { + Actor_MarkForDeath(&this->dyna.actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/ObjSpinyroll_Update.s") + func_80A1DE58(this); + this->dyna.actor.shape.rot.y = this->dyna.actor.world.rot.y; + func_80A1EAAC(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/ObjSpinyroll_Draw.s") +void ObjSpinyroll_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjSpinyroll* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + Collider_DestroyTris(globalCtx, &this->collider); +} + +void func_80A1E9C4(ObjSpinyroll* this) { + this->dyna.actor.speedXZ = 0.0f; + this->actionFunc = func_80A1E9E0; +} + +void func_80A1E9E0(ObjSpinyroll* this, GlobalContext* globalCtx) { + this->unk_4DA += 0x6E; + if (this->unk_4DA > 0xFA0) { + this->unk_4DA = 0xFA0; + } +} + +void func_80A1EA10(ObjSpinyroll* this) { + this->actionFunc = func_80A1EA4C; + this->unk_4E2 = D_80A1F1E4[OBJSPINYROLL_GET_1C00(&this->dyna.actor)]; + this->dyna.actor.speedXZ = 0.0f; +} + +void func_80A1EA4C(ObjSpinyroll* this, GlobalContext* globalCtx) { + if (Math_ScaledStepToS(&this->unk_4DA, 0, this->unk_4DE)) { + if (this->unk_4E2 > 0) { + this->unk_4E2--; + if (this->unk_4E2 <= 0) { + func_80A1EAAC(this); + } + } + } +} + +void func_80A1EAAC(ObjSpinyroll* this) { + this->actionFunc = func_80A1EAE0; + this->unk_4DC = D_80A1F20C[this->unk_4A8]; + this->dyna.actor.speedXZ = 0.0f; +} + +void func_80A1EAE0(ObjSpinyroll* this, GlobalContext* globalCtx) { + if (Math_ScaledStepToS(&this->unk_4DA, this->unk_4DC, 0x6E)) { + if (!this->unk_49C) { + func_80A1EB40(this); + } else { + func_80A1ECC0(this); + } + } +} + +void func_80A1EB40(ObjSpinyroll* this) { + this->actionFunc = func_80A1EB54; +} + +void func_80A1EB54(ObjSpinyroll* this, GlobalContext* globalCtx) { + s32 sp24 = func_80A1DEB8(this); + + if (func_80A1E2D8(this, globalCtx, 1)) { + if (func_80A1E694(this, globalCtx) != NULL) { + func_80A1DCCC(this); + this->unk_4DE = 0x7D0; + func_80A1EC24(this); + } else { + func_80A1DE84(this); + func_80A1DCCC(this); + this->unk_4DE = 0x7D0; + func_80A1EA10(this); + } + } else if (sp24 != 0) { + func_80A1DE84(this); + func_80A1DCCC(this); + this->unk_4DE = 0x78; + func_80A1EA10(this); + } +} + +void func_80A1EC24(ObjSpinyroll* this) { + this->actionFunc = func_80A1EC38; +} + +void func_80A1EC38(ObjSpinyroll* this, GlobalContext* globalCtx) { + s32 sp24 = true; + + Math_ScaledStepToS(&this->unk_4DA, 0, this->unk_4DE); + + if (func_80A1E2D8(this, globalCtx, 0) && func_80A1E6D4(this, globalCtx)) { + sp24 = false; + } + + if (sp24) { + func_80A1DE84(this); + func_80A1EA10(this); + } +} + +void func_80A1ECC0(ObjSpinyroll* this) { + this->actionFunc = func_80A1ECD4; +} + +void func_80A1ECD4(ObjSpinyroll* this, GlobalContext* globalCtx) { + s32 sp24 = func_80A1DEB8(this); + + if (func_80A1E648(this, globalCtx, 1)) { + func_80A1DE84(this); + func_80A1DCCC(this); + this->unk_4DE = 0x7D0; + func_80A1EA10(this); + } else if (sp24) { + func_80A1DE84(this); + func_80A1DCCC(this); + this->unk_4DE = 0x78; + func_80A1EA10(this); + } +} + +void ObjSpinyroll_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + ObjSpinyroll* this = THIS; + + if (this->collider.base.atFlags & AT_HIT) { + this->collider.base.atFlags &= ~AT_HIT; + func_80A1DCCC(this); + } + + this->actionFunc(this, globalCtx); + + this->unk_4E0 += this->unk_4DA; + func_80A1DC5C(this); + func_80A1DB2C(thisx); + + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +void ObjSpinyroll_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjSpinyroll* this = THIS; + f32 temp_f26; + f32 temp_f28; + s32 temp_s1 = OBJSPINYROLL_GET_C000(&this->dyna.actor); + s32 phi_s4; + f32 phi_f22; + f32 phi_f24; + s32 i; + f32 temp_f30; + Vec3s sp84; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + temp_f26 = Math_CosS(this->dyna.actor.shape.rot.y) * 120.0f; + temp_f28 = Math_SinS(this->dyna.actor.shape.rot.y) * -120.0f; + temp_f30 = this->dyna.actor.world.pos.y + this->unk_4D0; + + if (temp_s1 == OBJSPINYROLL_GET_C000_0) { + phi_s4 = 1; + phi_f22 = this->dyna.actor.world.pos.x; + phi_f24 = this->dyna.actor.world.pos.z; + } else if (temp_s1 == OBJSPINYROLL_GET_C000_1) { + phi_s4 = 2; + phi_f22 = this->dyna.actor.world.pos.x - (temp_f26 * 0.5f); + phi_f24 = this->dyna.actor.world.pos.z - (temp_f28 * 0.5f); + } else { + phi_s4 = 4; + phi_f22 = this->dyna.actor.world.pos.x - (temp_f26 * 1.5f); + phi_f24 = this->dyna.actor.world.pos.z - (temp_f28 * 1.5f); + } + + sp84.x = this->dyna.actor.shape.rot.x + this->unk_4E0; + sp84.y = this->dyna.actor.shape.rot.y; + sp84.z = this->dyna.actor.shape.rot.z; + + for (i = 0; i < phi_s4; i++) { + Matrix_SetStateRotationAndTranslation(phi_f22, temp_f30, phi_f24, &sp84); + Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_spinyroll_DL_000460); + + phi_f22 += temp_f26; + phi_f24 += temp_f28; + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.h b/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.h index b060643168..b35627b135 100644 --- a/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.h +++ b/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.h @@ -6,12 +6,54 @@ struct ObjSpinyroll; typedef void (*ObjSpinyrollActionFunc)(struct ObjSpinyroll*, GlobalContext*); +typedef s32 (*ObjSpinyrollColFunc)(CollisionContext*, f32*, CollisionPoly**, s32*, Vec3f*, struct ObjSpinyroll*); + +#define OBJSPINYROLL_GET_7F(thisx) ((thisx)->params & 0x7F) +#define OBJSPINYROLL_GET_380(thisx) (((thisx)->params >> 7) & 7) +#define OBJSPINYROLL_GET_1C00(thisx) (((thisx)->params >> 0xA) & 7) +#define OBJSPINYROLL_GET_C000(thisx) (((thisx)->params >> 0xE) & 3) + +#define OBJSPINYROLL_GET_7F_7F 0x7F +#define OBJSPINYROLL_GET_C000_0 0 +#define OBJSPINYROLL_GET_C000_1 1 + +typedef struct { + /* 0x00 */ f32 unk_00; + /* 0x04 */ CollisionPoly* unk_04; + /* 0x08 */ s32 bgId; +} ObjSpinyrollSubStruct; // size = 0xC + +typedef struct { + /* 0x00 */ ObjSpinyrollSubStruct unk_00[10]; +} ObjSpinyrollStruct; // size = 0x78 + +typedef struct { + /* 0x00 */ ObjSpinyrollStruct unk_00[2]; + /* 0xF0 */ ObjSpinyrollStruct* unk_F0; + /* 0xF4 */ s32 unk_F4; +} ObjSpinyrollStruct2; // size = 0xF8? typedef struct ObjSpinyroll { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x35C]; + /* 0x0000 */ DynaPolyActor dyna; + /* 0x015C */ ColliderTris collider; + /* 0x017C */ ColliderTrisElement colliderElements[6]; + /* 0x03A4 */ ObjSpinyrollStruct2 unk_3A4; + ///* 0x0494 */ ObjSpinyrollStruct* unk_494; // alternative testing + ///* 0x0498 */ s32 unk_498; + /* 0x049C */ s32 unk_49C; /* 0x04A0 */ ObjSpinyrollActionFunc actionFunc; - /* 0x04A4 */ char unk_4A4[0x40]; + /* 0x04A4 */ f32 unk_4A4; + /* 0x04A8 */ s32 unk_4A8; + /* 0x04AC */ Vec3f unk_4AC[2]; + /* 0x04C4 */ Vec3f unk_4C4; + /* 0x04D0 */ f32 unk_4D0; + /* 0x04D4 */ f32 unk_4D4; + /* 0x04D8 */ s16 unk_4D8; + /* 0x04DA */ s16 unk_4DA; + /* 0x04DC */ s16 unk_4DC; + /* 0x04DE */ s16 unk_4DE; + /* 0x04E0 */ s16 unk_4E0; + /* 0x04E2 */ s16 unk_4E2; } ObjSpinyroll; // size = 0x4E4 extern const ActorInit Obj_Spinyroll_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c b/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c index 4a69fc1ebc..bfe1f24b14 100644 --- a/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c +++ b/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c @@ -5,17 +5,71 @@ */ #include "z_obj_switch.h" +#include "objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h" #define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjSwitch*)thisx) +#define COS_OF_5_PI_DIV_8 -0.38268343f + void ObjSwitch_Init(Actor* thisx, GlobalContext* globalCtx); void ObjSwitch_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjSwitch_Update(Actor* thisx, GlobalContext* globalCtx); void ObjSwitch_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void ObjSwitch_FloorSwitchUpInit(ObjSwitch* this); +void ObjSwitch_FloorSwitchPushDownInit(ObjSwitch* this); +void ObjSwitch_FloorSwitchDownInit(ObjSwitch* this); +void ObjSwitch_FloorSwitchRiseUpInit(ObjSwitch* this); +void ObjSwitch_EyeSwitchFrozenInit(ObjSwitch* this); +void ObjSwitch_EyeSwitchOpenInit(ObjSwitch* this); +void ObjSwitch_EyeSwitchClosingInit(ObjSwitch* this); +void ObjSwitch_EyeSwitchClosedInit(ObjSwitch* this); +void ObjSwitch_EyeSwitchOpeningInit(ObjSwitch* this); +void ObjSwitch_CrystalSwitchOffInit(ObjSwitch* this); +void ObjSwitch_CrystalSwitchTurnOnInit(ObjSwitch* this); +void ObjSwitch_CrystalSwitchOnInit(ObjSwitch* this); +void ObjSwitch_CrystalSwitchTurnOffInit(ObjSwitch* this); +void ObjSwitch_LargeFloorSwitchUpInit(ObjSwitch* this); +void ObjSwitch_LargeFloorSwitchPushDownInit(ObjSwitch* this); +void ObjSwitch_LargeFloorSwitchDownInit(ObjSwitch* this); +void ObjSwitch_LargeFloorSwitchRiseUpInit(ObjSwitch* this); + +void ObjSwitch_FloorSwitchSnapPlayerToSwitchEdge(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_TryPlayCutscene(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_FloorSwitchUp(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_FloorSwitchPushDown(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_FloorSwitchDown(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_FloorSwitchRiseUp(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_EyeSwitchUnfrozen(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_EyeSwitchOpen(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_EyeSwitchClosing(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_EyeSwitchClosed(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_EyeSwitchOpening(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_CrystalSwitchOff(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_CrystalSwitchTurnOn(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_CrystalSwitchOn(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_CrystalSwitchTurnOff(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_LargeFloorSwitchUp(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_LargeFloorSwitchPushDown(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_LargeFloorSwitchDown(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_LargeFloorSwitchRiseUp(ObjSwitch* this, GlobalContext* globalCtx); + +void ObjSwitch_DrawFloorSwitch(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_DrawRustyFloorSwitch(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_DrawVisibleEyeSwitch(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_DrawInvisibleEyeSwitch(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_DrawEyeSwitch(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_DrawCrystalSwitch(ObjSwitch* this, GlobalContext* globalCtx); + +static TexturePtr sEyeSwitchTextures[][4] = { + { gEyeSwitchGoldOpenTex, gEyeSwitchGoldOpeningTex, gEyeSwitchGoldClosingTex, gEyeSwitchGoldClosedTex }, + { gEyeSwitchSilverOpenTex, gEyeSwitchSilverHalfTex, gEyeSwitchSilverClosedTex, gEyeSwitchSilverClosedTex }, +}; + +static s32 sIsSegmentTableInit = false; + const ActorInit Obj_Switch_InitVars = { ACTOR_OBJ_SWITCH, ACTORCAT_SWITCH, @@ -28,183 +82,969 @@ const ActorInit Obj_Switch_InitVars = { (ActorFunc)ObjSwitch_Draw, }; -// static ColliderTrisElementInit sTrisElementsInit[2] = { -static ColliderTrisElementInit D_8093CCD4[2] = { +static f32 sHeights[] = { 10.0f, 10.0f, 0.0f, 30.0f, 30.0f, 15.0f }; + +static f32 sScale[] = { 0.123f, 0.123f, 0.1f, 0.118f, 0.118f, 0.248f }; + +static ColliderTrisElementInit sRustyFloorTrisElementsInit[2] = { { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00000400, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000400, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { -20.0f, 19.0f, -20.0f }, { -20.0f, 19.0f, 20.0f }, { 20.0f, 19.0f, 20.0f } } }, }, { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00000400, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000400, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 20.0f, 19.0f, 20.0f }, { 20.0f, 19.0f, -20.0f }, { -20.0f, 19.0f, -20.0f } } }, }, }; -// static ColliderTrisInit sTrisInit = { -static ColliderTrisInit D_8093CD4C = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_TRIS, }, - 2, D_8093CCD4, // sTrisElementsInit, +static ColliderTrisInit sRustyFloorTrisInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_TRIS, + }, + ARRAY_COUNT(sRustyFloorTrisElementsInit), + sRustyFloorTrisElementsInit, }; -// static ColliderTrisElementInit sTrisElementsInit[2] = { -static ColliderTrisElementInit D_8093CD5C[2] = { +static ColliderTrisElementInit sEyeSwitchTrisElementsInit[2] = { { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00003820, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00003820, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 0.0f, 23.0f, 8.5f }, { -23.0f, 0.0f, 8.5f }, { 0.0f, -23.0f, 8.5f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00003820, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00003820, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 0.0f, 23.0f, 8.5f }, { 0.0f, -23.0f, 8.5f }, { 23.0f, 0.0f, 8.5f } } }, }, }; -// static ColliderTrisInit sTrisInit = { -static ColliderTrisInit D_8093CDD4 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_TRIS, }, - 2, D_8093CD5C, // sTrisElementsInit, +static ColliderTrisInit sEyeSwitchTrisInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_TRIS, + }, + ARRAY_COUNT(sEyeSwitchTrisElementsInit), + sEyeSwitchTrisElementsInit, }; -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_8093CDE4[1] = { +static ColliderJntSphElementInit sJntSphElementsInit[1] = { { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x01CBFFBE, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x01CBFFBE, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 0, { { 0, 300, 0 }, 20 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_8093CE08 = { - { COLTYPE_METAL, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_JNTSPH, }, - 1, D_8093CDE4, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_METAL, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_JNTSPH, + }, + ARRAY_COUNT(sJntSphElementsInit), + sJntSphElementsInit, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_8093CE18[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 200, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 200, ICHAIN_STOP), }; -#endif +static Color_RGB8 sSakonHideoutColor[2] = { { 250, 90, 60 }, { 255, 255, 255 } }; -extern ColliderTrisElementInit D_8093CCD4[2]; -extern ColliderTrisInit D_8093CD4C; -extern ColliderTrisElementInit D_8093CD5C[2]; -extern ColliderTrisInit D_8093CDD4; -extern ColliderJntSphElementInit D_8093CDE4[1]; -extern ColliderJntSphInit D_8093CE08; -extern InitChainEntry D_8093CE18[]; +static Gfx* sFloorSwitchDL[] = { gFloorSwitch1DL, gFloorSwitch3DL, gFloorSwitch2DL, gFloorSwitch2DL, gFloorSwitch1DL }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093ABD0.s") +static Gfx* sEyeSwitchDL[] = { gEyeSwitchGoldDL, gEyeSwitchSilverDL }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093AC6C.s") +static AnimatedMaterial* sCrystalSwitchAnimatedMat; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093ADA8.s") +void ObjSwitch_InitJntSphCollider(ObjSwitch* this, GlobalContext* globalCtx, ColliderJntSphInit* init) { + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093AE1C.s") + Collider_InitJntSph(globalCtx, &this->colliderJntSph); + Collider_SetJntSph(globalCtx, &this->colliderJntSph, &this->dyna.actor, init, this->colliderJntSphElements); + Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, + this->dyna.actor.world.pos.y + + (this->dyna.actor.shape.yOffset * this->dyna.actor.scale.y), + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Matrix_Scale(this->dyna.actor.scale.x, this->dyna.actor.scale.y, this->dyna.actor.scale.z, MTXMODE_APPLY); + Collider_UpdateSpheres(0, &this->colliderJntSph); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093AE74.s") +void ObjSwitch_InitTrisCollider(ObjSwitch* this, GlobalContext* globalCtx, ColliderTrisInit* init) { + s32 pad; + s32 i; + s32 j; + Vec3f vtx[3]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093AE88.s") + Collider_InitTris(globalCtx, &this->colliderTris); + Collider_SetTris(globalCtx, &this->colliderTris, &this->dyna.actor, init, this->colliderTrisElements); + Matrix_StatePush(); + Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, + this->dyna.actor.world.pos.y + + this->dyna.actor.shape.yOffset * this->dyna.actor.scale.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093AEC4.s") + for (i = 0; i < ARRAY_COUNT(this->colliderTrisElements); i++) { + if (this) {} + for (j = 0; j < ARRAY_COUNT(vtx); j++) { + Matrix_MultiplyVector3fByState(&init->elements[i].dim.vtx[j], &vtx[j]); + } + Collider_SetTrisVertices(&this->colliderTris, i, &vtx[0], &vtx[1], &vtx[2]); + } + Matrix_StatePop(); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093AEF0.s") +Actor* ObjSwitch_SpawnIce(ObjSwitch* this, GlobalContext* globalCtx) { + return Actor_SpawnAsChild(&globalCtx->actorCtx, &this->dyna.actor, globalCtx, ACTOR_OBJ_ICE_POLY, + this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y - 25.0f, + this->dyna.actor.world.pos.z, this->dyna.actor.world.rot.x, this->dyna.actor.world.rot.y, + this->dyna.actor.world.rot.z, 0xFF32); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093AF1C.s") +void ObjSwitch_SetSwitchFlagState(ObjSwitch* this, GlobalContext* globalCtx, s32 setFlag) { + if (setFlag) { + s32 flag = OBJ_SWITCH_GET_SWITCH_FLAG(&this->dyna.actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093AF54.s") + Flags_SetSwitch(globalCtx, flag); + } else { + s32 flag = OBJ_SWITCH_GET_SWITCH_FLAG(&this->dyna.actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/ObjSwitch_Init.s") + Flags_UnsetSwitch(globalCtx, flag); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/ObjSwitch_Destroy.s") +void ObjSwitch_CrystalUpdateTimer(ObjSwitch* this) { + this->crystalAnimTimer++; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093B648.s") +void ObjSwitch_StopCutscene(ObjSwitch* this) { + if (this->isPlayingCutscene) { + ActorCutscene_Stop(this->dyna.actor.cutscene); + this->isPlayingCutscene = false; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093B668.s") +void ObjSwitch_PlayFootSwitchSfx(ObjSwitch* this) { + if (this->sfxTimer <= 0) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_FOOT_SWITCH); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093B6F4.s") +void ObjSwitch_PlayDiamondSwitchSfx(ObjSwitch* this) { + if (this->sfxTimer <= 0) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_DIAMOND_SWITCH); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093B710.s") +void ObjSwitch_SetFloorSwitchSnapPlayerState(ObjSwitch* this, s32 state) { + if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + this->floorSwitchPlayerSnapState = state; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093B92C.s") +void ObjSwitch_FloorSwitchSnapPlayerToSwitchEdge(ObjSwitch* this, GlobalContext* globalCtx) { + s32 pad; + Player* player; + f32 centerDisplacement; + s16 yaw; + f32 cos; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093B940.s") + if (globalCtx->actorCtx.unk5 & 0x80) { + player = GET_PLAYER(globalCtx); + // compute yawTowardsPlayer relative to model space + yaw = BINANG_SUB(this->dyna.actor.yawTowardsPlayer, this->dyna.actor.shape.rot.y); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093B9C0.s") + // clamps yaw to the range -45 to 45 degrees, such that 0 degrees follows along the apothem + yaw += 0x2000; + yaw &= 0x3FFF; + yaw -= 0x2000; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093B9E4.s") + // set centerDisplacement to the length of the apothem for the floor switch square + // only OBJSWITCH_TYPE_FLOOR and OBJSWITCH_TYPE_FLOOR_LARGE are supported + centerDisplacement = OBJ_SWITCH_GET_TYPE(&this->dyna.actor) == OBJSWITCH_TYPE_FLOOR ? 24.0f : 48.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093BB5C.s") + cos = Math_CosS(yaw); + if (fabsf(cos) > 0.01f) { + // compute how far to displace the player so that the player is touching an edge + centerDisplacement /= cos; + // if the player is already inside the square, don't move them + if (centerDisplacement < this->dyna.actor.xzDistToPlayer) { + player->actor.world.pos.x = + Math_SinS(this->dyna.actor.yawTowardsPlayer) * centerDisplacement + this->dyna.actor.world.pos.x; + player->actor.world.pos.z = + Math_CosS(this->dyna.actor.yawTowardsPlayer) * centerDisplacement + this->dyna.actor.world.pos.z; + } + player->linearVelocity = 0.0f; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093BB70.s") +void ObjSwitch_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + s32 type; + u32 isSwitchFlagSet; + ObjSwitch* this = THIS; + s32 pad2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093BBD0.s") + isSwitchFlagSet = Flags_GetSwitch(globalCtx, OBJ_SWITCH_GET_SWITCH_FLAG(&this->dyna.actor)); + type = OBJ_SWITCH_GET_TYPE(&this->dyna.actor); + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + Actor_SetScale(&this->dyna.actor, sScale[type]); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093BCC8.s") + if (type == OBJSWITCH_TYPE_FLOOR || type == OBJSWITCH_TYPE_FLOOR_RUSTY || type == OBJSWITCH_TYPE_FLOOR_LARGE) { + if (type == OBJSWITCH_TYPE_FLOOR_LARGE) { + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + 1.9f; + } else { + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + 1.0f; + } + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gFloorSwitchCol); + } + if (type == OBJSWITCH_TYPE_FLOOR) { + if (globalCtx->sceneNum == SCENE_SECOM) { + this->floorSwitchUpScale = 33.0f / 200.0f / 3.0f; + this->floorSwitchDownScale = 33.0f / 2000.0f / 3.0f; + } else { + this->floorSwitchUpScale = 33.0f / 200.0f; + this->floorSwitchDownScale = 33.0f / 2000.0f; + } + } + if (type == OBJSWITCH_TYPE_FLOOR || type == OBJSWITCH_TYPE_FLOOR_LARGE) { + if (globalCtx->sceneNum == SCENE_SECOM) { + Color_RGB8* color = &sSakonHideoutColor[OBJ_SWITCH_GET_COLOR_ID(&this->dyna.actor)]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093BCDC.s") + this->color.r = color->r; + this->color.g = color->g; + this->color.b = color->b; + this->dyna.actor.shape.rot.z = 0; + this->dyna.actor.world.rot.z = 0; + } else { + this->color.r = 255; + this->color.g = 255; + this->color.b = 255; + } + } + Actor_SetFocus(&this->dyna.actor, sHeights[type]); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093BD34.s") + if (type == OBJSWITCH_TYPE_FLOOR_RUSTY) { + ObjSwitch_InitTrisCollider(this, globalCtx, &sRustyFloorTrisInit); + } else if (type == OBJSWITCH_TYPE_EYE) { + ObjSwitch_InitTrisCollider(this, globalCtx, &sEyeSwitchTrisInit); + } else if (type == OBJSWITCH_TYPE_CRYSTAL || type == OBJSWITCH_TYPE_CRYSTAL_TARGETABLE) { + ObjSwitch_InitJntSphCollider(this, globalCtx, &sJntSphInit); + } + if (type == OBJSWITCH_TYPE_CRYSTAL_TARGETABLE) { + this->dyna.actor.targetMode = 4; + this->dyna.actor.flags |= 1; + } + this->dyna.actor.colChkInfo.mass = MASS_IMMOVABLE; + if (OBJ_SWITCH_IS_FROZEN(&this->dyna.actor)) { + if (ObjSwitch_SpawnIce(this, globalCtx) == NULL) { + OBJ_SWITCH_UNSET_FROZEN(&this->dyna.actor); + } + this->sfxTimer = 0; + } else { + this->sfxTimer = 10; + } + if (OBJ_SWITCH_IS_INVISIBLE(&this->dyna.actor)) { + this->dyna.actor.flags |= 0x80; + } + if (type == OBJSWITCH_TYPE_EYE) { + if (sIsSegmentTableInit == false) { + s32 i, j; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093BD4C.s") + sIsSegmentTableInit = true; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093BDAC.s") + for (i = 0; i < ARRAY_COUNT(sEyeSwitchTextures); i++) { + for (j = 0; j < ARRAY_COUNT(*sEyeSwitchTextures); j++) { + sEyeSwitchTextures[i][j] = Lib_SegmentedToVirtual(sEyeSwitchTextures[i][j]); + } + } + } + } + if (type == OBJSWITCH_TYPE_CRYSTAL) { + sCrystalSwitchAnimatedMat = Lib_SegmentedToVirtual(&gCrystalSwitchAnimatedMat); + } + if (OBJ_SWITCH_IS_FROZEN(&this->dyna.actor)) { + ObjSwitch_EyeSwitchFrozenInit(this); + } else if (type == OBJSWITCH_TYPE_FLOOR || type == OBJSWITCH_TYPE_FLOOR_RUSTY) { + if (OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor) == OBJSWITCH_SUBTYPE_RESET_INVERTED) { + if (isSwitchFlagSet) { + ObjSwitch_FloorSwitchUpInit(this); + } else { + ObjSwitch_FloorSwitchDownInit(this); + } + } else { + if (isSwitchFlagSet) { + ObjSwitch_FloorSwitchDownInit(this); + } else { + ObjSwitch_FloorSwitchUpInit(this); + } + } + } else if (type == OBJSWITCH_TYPE_EYE) { + if (isSwitchFlagSet) { + ObjSwitch_EyeSwitchClosedInit(this); + } else { + ObjSwitch_EyeSwitchOpenInit(this); + } + } else if (type == OBJSWITCH_TYPE_CRYSTAL || type == OBJSWITCH_TYPE_CRYSTAL_TARGETABLE) { + if (isSwitchFlagSet) { + ObjSwitch_CrystalSwitchOnInit(this); + } else { + ObjSwitch_CrystalSwitchOffInit(this); + } + } else if (type == OBJSWITCH_TYPE_FLOOR_LARGE) { + if (OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor) == OBJSWITCH_SUBTYPE_RESET_INVERTED) { + if (isSwitchFlagSet) { + ObjSwitch_LargeFloorSwitchUpInit(this); + } else { + ObjSwitch_LargeFloorSwitchDownInit(this); + } + } else { + if (isSwitchFlagSet) { + ObjSwitch_LargeFloorSwitchDownInit(this); + } else { + ObjSwitch_LargeFloorSwitchUpInit(this); + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093BDC0.s") +void ObjSwitch_Destroy(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjSwitch* this = THIS; + s32 type = OBJ_SWITCH_GET_TYPE(&this->dyna.actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093BE10.s") + if (type == OBJSWITCH_TYPE_FLOOR || type == OBJSWITCH_TYPE_FLOOR_RUSTY || type == OBJSWITCH_TYPE_FLOOR_LARGE) { + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + } + switch (type) { + case OBJSWITCH_TYPE_FLOOR_RUSTY: + case OBJSWITCH_TYPE_EYE: + Collider_DestroyTris(globalCtx, &this->colliderTris); + break; + case OBJSWITCH_TYPE_CRYSTAL: + case OBJSWITCH_TYPE_CRYSTAL_TARGETABLE: + Collider_DestroyJntSph(globalCtx, &this->colliderJntSph); + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093BE2C.s") +void ObjSwitch_TryPlayCutsceneInit(ObjSwitch* this, GlobalContext* globalCtx, ObjSwitchSetupActionFunc actionFunc, + s32 nextSwitchFlagState) { + this->setupFunc = actionFunc; + this->nextSwitchFlagState = nextSwitchFlagState; + this->actionFunc = ObjSwitch_TryPlayCutscene; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093BEF0.s") +void ObjSwitch_TryPlayCutscene(ObjSwitch* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + ObjSwitch_SetSwitchFlagState(this, globalCtx, this->nextSwitchFlagState); + if (this->floorSwitchPlayerSnapState == 1) { + this->floorSwitchPlayerSnapState = 2; + } + this->isPlayingCutscene = true; + this->setupFunc(this); + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093BF04.s") +void ObjSwitch_FloorSwitchUpInit(ObjSwitch* this) { + this->actionFunc = ObjSwitch_FloorSwitchUp; + this->dyna.actor.scale.y = this->floorSwitchUpScale; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093BF50.s") +void ObjSwitch_FloorSwitchUp(ObjSwitch* this, GlobalContext* globalCtx) { + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093BF70.s") + if (OBJ_SWITCH_GET_TYPE(&this->dyna.actor) == OBJSWITCH_TYPE_FLOOR_RUSTY) { + if (this->colliderTris.base.acFlags & AC_HIT) { + this->colliderTris.base.acFlags &= ~AT_HIT; + ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_FloorSwitchPushDownInit, true); + } else { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderTris.base); + } + } else { + switch (OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor)) { + case OBJSWITCH_SUBTYPE_ONCE: + if (DynaPolyActor_IsInSwitchPressedState(&this->dyna)) { + ObjSwitch_SetFloorSwitchSnapPlayerState(this, 1); + ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_FloorSwitchPushDownInit, true); + } + break; + case OBJSWITCH_SUBTYPE_SYNC: + if (DynaPolyActor_IsInSwitchPressedState(&this->dyna)) { + ObjSwitch_SetFloorSwitchSnapPlayerState(this, 1); + ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_FloorSwitchPushDownInit, true); + } else if (Flags_GetSwitch(globalCtx, OBJ_SWITCH_GET_SWITCH_FLAG(&this->dyna.actor))) { + ObjSwitch_FloorSwitchPushDownInit(this); + } + break; + case OBJSWITCH_SUBTYPE_TOGGLE: + if (DynaPolyActor_IsInSwitchPressedState(&this->dyna)) { + s32 isSwitchFlagNotSet = + Flags_GetSwitch(globalCtx, OBJ_SWITCH_GET_SWITCH_FLAG(&this->dyna.actor)) ? false : true; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C0A4.s") + ObjSwitch_SetFloorSwitchSnapPlayerState(this, 1); + ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_FloorSwitchPushDownInit, + isSwitchFlagNotSet); + } + break; + case OBJSWITCH_SUBTYPE_RESET: + if (DynaPolyActor_IsInSwitchPressedState(&this->dyna)) { + ObjSwitch_SetFloorSwitchSnapPlayerState(this, 1); + ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_FloorSwitchPushDownInit, true); + } + break; + case OBJSWITCH_SUBTYPE_RESET_INVERTED: + if (DynaPolyActor_IsInSwitchPressedState(&this->dyna)) { + ObjSwitch_SetFloorSwitchSnapPlayerState(this, 2); + ObjSwitch_SetSwitchFlagState(this, globalCtx, false); + ObjSwitch_FloorSwitchPushDownInit(this); + } + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C0B8.s") +void ObjSwitch_FloorSwitchPushDownInit(ObjSwitch* this) { + this->actionFunc = ObjSwitch_FloorSwitchPushDown; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C138.s") +void ObjSwitch_FloorSwitchPushDown(ObjSwitch* this, GlobalContext* globalCtx) { + this->dyna.actor.scale.y -= 0.0495f; + if (this->dyna.actor.scale.y <= this->floorSwitchDownScale) { + ObjSwitch_PlayFootSwitchSfx(this); + func_8013ECE0(this->dyna.actor.xyzDistToPlayerSq, 120, 20, 10); + ObjSwitch_StopCutscene(this); + ObjSwitch_FloorSwitchDownInit(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C15C.s") +void ObjSwitch_FloorSwitchDownInit(ObjSwitch* this) { + this->floorSwitchReleaseTimer = 6; + this->actionFunc = ObjSwitch_FloorSwitchDown; + this->dyna.actor.scale.y = this->floorSwitchDownScale; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C23C.s") +void ObjSwitch_FloorSwitchDown(ObjSwitch* this, GlobalContext* globalCtx) { + s32 pad; + u32 subType = OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C250.s") + switch (subType) { + case OBJSWITCH_SUBTYPE_ONCE: + case OBJSWITCH_SUBTYPE_SYNC: + if (!Flags_GetSwitch(globalCtx, OBJ_SWITCH_GET_SWITCH_FLAG(&this->dyna.actor))) { + if (globalCtx->sceneNum == SCENE_SECOM && DynaPolyActor_IsInSwitchPressedState(&this->dyna)) { + ObjSwitch_SetSwitchFlagState(this, globalCtx, true); + } else { + ObjSwitch_FloorSwitchRiseUpInit(this); + } + } + break; + case OBJSWITCH_SUBTYPE_TOGGLE: + case OBJSWITCH_SUBTYPE_RESET: + case OBJSWITCH_SUBTYPE_RESET_INVERTED: + if (!DynaPolyActor_IsInSwitchPressedState(&this->dyna) && + (Player_InCsMode(&globalCtx->state) == 0 || globalCtx->sceneNum == SCENE_SECOM)) { + if (this->floorSwitchReleaseTimer <= 0) { + if (subType == OBJSWITCH_SUBTYPE_RESET) { + ObjSwitch_SetSwitchFlagState(this, globalCtx, false); + ObjSwitch_FloorSwitchRiseUpInit(this); + } else if (subType == OBJSWITCH_SUBTYPE_RESET_INVERTED) { + ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_FloorSwitchRiseUpInit, true); + } else { + ObjSwitch_FloorSwitchRiseUpInit(this); + } + } + } else { + if (globalCtx->sceneNum == SCENE_SECOM) { + this->floorSwitchReleaseTimer = 2; + } else { + this->floorSwitchReleaseTimer = 6; + } + } + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C2B4.s") +void ObjSwitch_FloorSwitchRiseUpInit(ObjSwitch* this) { + this->actionFunc = ObjSwitch_FloorSwitchRiseUp; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C2D4.s") +void ObjSwitch_FloorSwitchRiseUp(ObjSwitch* this, GlobalContext* globalCtx) { + this->dyna.actor.scale.y += 0.0495f; + if (this->floorSwitchUpScale <= this->dyna.actor.scale.y) { + ObjSwitch_PlayFootSwitchSfx(this); + ObjSwitch_StopCutscene(this); + ObjSwitch_FloorSwitchUpInit(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C3C8.s") +s32 ObjSwitch_IsEyeSwitchHit(ObjSwitch* this) { + Actor* acActor; + Actor* actor = &this->dyna.actor; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C3DC.s") + if ((this->colliderTris.base.acFlags & AC_HIT) && !(this->collisionFlags & AC_HIT)) { + acActor = this->colliderTris.base.ac; + if (acActor != NULL) { + Vec3f sp2C; + Vec3f sp20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C460.s") + Matrix_StatePush(); + Matrix_RotateY(acActor->world.rot.y, MTXMODE_NEW); + Matrix_InsertXRotation_s(acActor->world.rot.x, MTXMODE_APPLY); + Matrix_GetStateTranslationAndScaledZ(1.0f, &sp2C); + Matrix_RotateY(actor->shape.rot.y, MTXMODE_NEW); + Matrix_InsertXRotation_s(actor->shape.rot.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(actor->shape.rot.z, MTXMODE_APPLY); + Matrix_GetStateTranslationAndScaledZ(1.0f, &sp20); + Matrix_StatePop(); + if ((Math3D_Parallel(&sp2C, &sp20) < COS_OF_5_PI_DIV_8)) { + return true; + } + } + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C488.s") +void ObjSwitch_EyeSwitchFrozenInit(ObjSwitch* this) { + this->actionFunc = ObjSwitch_EyeSwitchUnfrozen; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C584.s") +void ObjSwitch_EyeSwitchUnfrozen(ObjSwitch* this, GlobalContext* globalCtx) { + if (Flags_GetSwitch(globalCtx, OBJ_SWITCH_GET_SWITCH_FLAG(&this->dyna.actor))) { + ObjSwitch_EyeSwitchClosedInit(this); + } else { + ObjSwitch_EyeSwitchOpenInit(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C598.s") +void ObjSwitch_EyeSwitchOpenInit(ObjSwitch* this) { + this->actionFunc = ObjSwitch_EyeSwitchOpen; + this->eyeTexIndex = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/ObjSwitch_Update.s") +void ObjSwitch_EyeSwitchOpen(ObjSwitch* this, GlobalContext* globalCtx) { + if (ObjSwitch_IsEyeSwitchHit(this) || OBJ_SWITCH_IS_FROZEN(&this->dyna.actor)) { + OBJ_SWITCH_UNSET_FROZEN(&this->dyna.actor); + ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_EyeSwitchClosingInit, true); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C778.s") +void ObjSwitch_EyeSwitchClosingInit(ObjSwitch* this) { + this->actionFunc = ObjSwitch_EyeSwitchClosing; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C888.s") +void ObjSwitch_EyeSwitchClosing(ObjSwitch* this, GlobalContext* globalCtx) { + this->eyeTexIndex++; + if (this->eyeTexIndex >= 3) { + ObjSwitch_StopCutscene(this); + ObjSwitch_PlayFootSwitchSfx(this); + ObjSwitch_EyeSwitchClosedInit(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C8B8.s") +void ObjSwitch_EyeSwitchClosedInit(ObjSwitch* this) { + this->actionFunc = ObjSwitch_EyeSwitchClosed; + this->eyeTexIndex = 3; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C99C.s") +void ObjSwitch_EyeSwitchClosed(ObjSwitch* this, GlobalContext* globalCtx) { + switch (OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor)) { + case OBJSWITCH_SUBTYPE_ONCE: + if (!Flags_GetSwitch(globalCtx, OBJ_SWITCH_GET_SWITCH_FLAG(&this->dyna.actor))) { + OBJ_SWITCH_UNSET_FROZEN(&this->dyna.actor); + ObjSwitch_EyeSwitchOpeningInit(this); + } + break; + case OBJSWITCH_SUBTYPE_TOGGLE: + if (ObjSwitch_IsEyeSwitchHit(this) || OBJ_SWITCH_IS_FROZEN(&this->dyna.actor)) { + OBJ_SWITCH_UNSET_FROZEN(&this->dyna.actor); + ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_EyeSwitchOpeningInit, false); + } + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093CA80.s") +void ObjSwitch_EyeSwitchOpeningInit(ObjSwitch* this) { + this->actionFunc = ObjSwitch_EyeSwitchOpening; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093CAC4.s") +void ObjSwitch_EyeSwitchOpening(ObjSwitch* this, GlobalContext* globalCtx) { + this->eyeTexIndex--; + if (this->eyeTexIndex <= 0) { + ObjSwitch_StopCutscene(this); + ObjSwitch_PlayFootSwitchSfx(this); + ObjSwitch_EyeSwitchOpenInit(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/ObjSwitch_Draw.s") +void ObjSwitch_CrystalSwitchOffInit(ObjSwitch* this) { + this->color.r = 0; + this->color.g = 0; + this->color.b = 0; + this->actionFunc = ObjSwitch_CrystalSwitchOff; +} + +void ObjSwitch_CrystalSwitchOff(ObjSwitch* this, GlobalContext* globalCtx) { + s32 switchHit = (this->colliderJntSph.base.acFlags & AC_HIT) != 0; + s32 canActivate = switchHit && !(this->collisionFlags & AC_HIT) && (this->disableCrystalSwitchTimer <= 0); + + if (switchHit) { + this->disableCrystalSwitchTimer = 10; + } + switch (OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor)) { + case OBJSWITCH_SUBTYPE_ONCE: + if (canActivate) { + ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_CrystalSwitchTurnOnInit, true); + } + break; + case OBJSWITCH_SUBTYPE_SYNC: + if (canActivate) { + ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_CrystalSwitchTurnOnInit, true); + + } else if (Flags_GetSwitch(globalCtx, OBJ_SWITCH_GET_SWITCH_FLAG(&this->dyna.actor))) { + this->disableCrystalSwitchTimer = 10; + ObjSwitch_CrystalSwitchTurnOnInit(this); + } + break; + case OBJSWITCH_SUBTYPE_TOGGLE: + if (canActivate) { + ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_CrystalSwitchTurnOnInit, true); + } + ObjSwitch_CrystalUpdateTimer(this); + break; + } +} + +void ObjSwitch_CrystalSwitchTurnOnInit(ObjSwitch* this) { + this->actionFunc = ObjSwitch_CrystalSwitchTurnOn; +} + +void ObjSwitch_CrystalSwitchTurnOn(ObjSwitch* this, GlobalContext* globalCtx) { + s32 switchHit = (this->colliderJntSph.base.acFlags & AC_HIT) != 0; + s32 subType = OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor); + + if (switchHit) { + this->disableCrystalSwitchTimer = 10; + } + ObjSwitch_StopCutscene(this); + if (subType == OBJSWITCH_SUBTYPE_TOGGLE) { + ObjSwitch_CrystalUpdateTimer(this); + } + ObjSwitch_PlayDiamondSwitchSfx(this); + ObjSwitch_CrystalSwitchOnInit(this); +} + +void ObjSwitch_CrystalSwitchOnInit(ObjSwitch* this) { + this->color.r = 255; + this->color.g = 255; + this->color.b = 255; + this->actionFunc = ObjSwitch_CrystalSwitchOn; +} + +void ObjSwitch_CrystalSwitchOn(ObjSwitch* this, GlobalContext* globalCtx) { + s32 switchHit = (this->colliderJntSph.base.acFlags & AC_HIT) != 0; + s32 canActivate = switchHit && !(this->collisionFlags & AC_HIT) && (this->disableCrystalSwitchTimer <= 0); + + if (switchHit) { + this->disableCrystalSwitchTimer = 10; + } + switch (OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor)) { + case OBJSWITCH_SUBTYPE_ONCE: + case OBJSWITCH_SUBTYPE_SYNC: + if (!Flags_GetSwitch(globalCtx, OBJ_SWITCH_GET_SWITCH_FLAG(&this->dyna.actor))) { + this->disableCrystalSwitchTimer = 10; + ObjSwitch_CrystalSwitchTurnOffInit(this); + } + break; + case OBJSWITCH_SUBTYPE_TOGGLE: + if (canActivate) { + ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_CrystalSwitchTurnOffInit, false); + } + } + ObjSwitch_CrystalUpdateTimer(this); +} + +void ObjSwitch_CrystalSwitchTurnOffInit(ObjSwitch* this) { + this->actionFunc = ObjSwitch_CrystalSwitchTurnOff; +} + +void ObjSwitch_CrystalSwitchTurnOff(ObjSwitch* this, GlobalContext* globalCtx) { + s32 switchHit = (this->colliderJntSph.base.acFlags & AC_HIT) != 0; + + if (switchHit) { + this->disableCrystalSwitchTimer = 10; + } + ObjSwitch_StopCutscene(this); + ObjSwitch_CrystalUpdateTimer(this); + ObjSwitch_PlayDiamondSwitchSfx(this); + ObjSwitch_CrystalSwitchOffInit(this); +} + +void ObjSwitch_LargeFloorSwitchUpInit(ObjSwitch* this) { + this->dyna.actor.scale.y = 0.2475f; + this->actionFunc = ObjSwitch_LargeFloorSwitchUp; +} + +void ObjSwitch_LargeFloorSwitchUp(ObjSwitch* this, GlobalContext* globalCtx) { + s32 subType = OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor); + + if (subType == OBJSWITCH_SUBTYPE_ONCE) { + if (DynaPolyActor_IsInHeavySwitchPressedState(&this->dyna)) { + ObjSwitch_SetFloorSwitchSnapPlayerState(this, 1); + ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_LargeFloorSwitchPushDownInit, true); + } + } else if (subType == OBJSWITCH_SUBTYPE_RESET) { + if (DynaPolyActor_IsInHeavySwitchPressedState(&this->dyna)) { + ObjSwitch_SetFloorSwitchSnapPlayerState(this, 1); + ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_LargeFloorSwitchPushDownInit, true); + } + } else if (subType == OBJSWITCH_SUBTYPE_RESET_INVERTED && DynaPolyActor_IsInHeavySwitchPressedState(&this->dyna)) { + ObjSwitch_SetFloorSwitchSnapPlayerState(this, 2); + ObjSwitch_SetSwitchFlagState(this, globalCtx, false); + ObjSwitch_LargeFloorSwitchPushDownInit(this); + } +} + +void ObjSwitch_LargeFloorSwitchPushDownInit(ObjSwitch* this) { + this->actionFunc = ObjSwitch_LargeFloorSwitchPushDown; +} + +void ObjSwitch_LargeFloorSwitchPushDown(ObjSwitch* this, GlobalContext* globalCtx) { + this->dyna.actor.scale.y -= 0.074250005f; + if (this->dyna.actor.scale.y <= 33.0f / 2000.0f) { + ObjSwitch_PlayFootSwitchSfx(this); + func_8013ECE0(this->dyna.actor.xyzDistToPlayerSq, 120, 20, 10); + ObjSwitch_StopCutscene(this); + ObjSwitch_LargeFloorSwitchDownInit(this); + } +} + +void ObjSwitch_LargeFloorSwitchDownInit(ObjSwitch* this) { + this->dyna.actor.scale.y = 33.0f / 2000.0f; + this->floorSwitchReleaseTimer = 6; + this->actionFunc = ObjSwitch_LargeFloorSwitchDown; +} + +void ObjSwitch_LargeFloorSwitchDown(ObjSwitch* this, GlobalContext* globalCtx) { + s32 subType = OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor); + + if (subType == OBJSWITCH_SUBTYPE_ONCE) { + if (!Flags_GetSwitch(globalCtx, OBJ_SWITCH_GET_SWITCH_FLAG(&this->dyna.actor))) { + ObjSwitch_LargeFloorSwitchRiseUpInit(this); + } + } else if (subType == OBJSWITCH_SUBTYPE_RESET || subType == OBJSWITCH_SUBTYPE_RESET_INVERTED) { + if (!DynaPolyActor_IsInHeavySwitchPressedState(&this->dyna) && !Player_InCsMode(&globalCtx->state)) { + if (this->floorSwitchReleaseTimer <= 0) { + if (OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor) == OBJSWITCH_SUBTYPE_RESET) { + ObjSwitch_SetSwitchFlagState(this, globalCtx, false); + ObjSwitch_LargeFloorSwitchRiseUpInit(this); + } else { + ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_LargeFloorSwitchRiseUpInit, true); + } + } + } else { + this->floorSwitchReleaseTimer = 6; + } + } +} + +void ObjSwitch_LargeFloorSwitchRiseUpInit(ObjSwitch* this) { + this->actionFunc = ObjSwitch_LargeFloorSwitchRiseUp; +} + +void ObjSwitch_LargeFloorSwitchRiseUp(ObjSwitch* this, GlobalContext* globalCtx) { + this->dyna.actor.scale.y += 0.074250005f; + if (this->dyna.actor.scale.y >= 0.2475f) { + ObjSwitch_PlayFootSwitchSfx(this); + ObjSwitch_StopCutscene(this); + ObjSwitch_LargeFloorSwitchUpInit(this); + } +} + +void ObjSwitch_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjSwitch* this = THIS; + + if (this->floorSwitchReleaseTimer > 0) { + this->floorSwitchReleaseTimer--; + } + if (this->sfxTimer > 0) { + this->sfxTimer--; + } + this->actionFunc(this, globalCtx); + if (this->floorSwitchPlayerSnapState != 0) { + s32 pad; + + dummy: + ObjSwitch_FloorSwitchSnapPlayerToSwitchEdge(this, globalCtx); + if (this->floorSwitchPlayerSnapState == 2) { + this->floorSwitchPlayerSnapState = 0; + } + } + switch (OBJ_SWITCH_GET_TYPE(&this->dyna.actor)) { + case OBJSWITCH_TYPE_FLOOR: + case OBJSWITCH_TYPE_FLOOR_RUSTY: + case OBJSWITCH_TYPE_FLOOR_LARGE: + this->collisionFlags = this->dyna.stateFlags; + break; + case OBJSWITCH_TYPE_EYE: + this->collisionFlags = this->colliderTris.base.acFlags; + this->colliderTris.base.acFlags &= ~AC_HIT; + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderTris.base); + break; + case OBJSWITCH_TYPE_CRYSTAL: + case OBJSWITCH_TYPE_CRYSTAL_TARGETABLE: + if (!Player_InCsMode(&globalCtx->state)) { + if (this->disableCrystalSwitchTimer > 0) { + this->disableCrystalSwitchTimer--; + } + } + if (this->disableCrystalSwitchTimer == 0) { + this->colliderJntSph.base.colType = sJntSphInit.base.colType; + } else { + this->colliderJntSph.base.colType = COLTYPE_NONE; + } + this->collisionFlags = this->colliderJntSph.base.acFlags; + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderJntSph.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderJntSph.base); + } +} + +void ObjSwitch_DrawFloorSwitch(ObjSwitch* this, GlobalContext* globalCtx) { + s32 pad[2]; + + if (OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor) == OBJSWITCH_SUBTYPE_ONCE) { + Gfx* opa; + + OPEN_DISPS(globalCtx->state.gfxCtx); + opa = POLY_OPA_DISP; + gSPDisplayList(opa++, &sSetupDL[6 * 25]); + gSPMatrix(opa++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(opa++, 0, 0x80, this->color.r, this->color.g, this->color.b, 255); + gSPDisplayList(opa++, gFloorSwitch1DL); + POLY_OPA_DISP = opa; + CLOSE_DISPS(globalCtx->state.gfxCtx); + } else { + Gfx_DrawDListOpa(globalCtx, sFloorSwitchDL[OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor)]); + } +} + +void ObjSwitch_DrawRustyFloorSwitch(ObjSwitch* this, GlobalContext* globalCtx) { + Gfx_DrawDListOpa(globalCtx, gRustyFloorSwitchDL); +} + +void ObjSwitch_DrawVisibleEyeSwitch(ObjSwitch* this, GlobalContext* globalCtx) { + s32 pad; + s32 subType = OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_OPA_DISP++, 0x08, sEyeSwitchTextures[subType][this->eyeTexIndex]); + gSPDisplayList(POLY_OPA_DISP++, sEyeSwitchDL[subType]); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void ObjSwitch_DrawInvisibleEyeSwitch(ObjSwitch* this, GlobalContext* globalCtx) { + s32 pad; + s32 subType = OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_XLU_DISP++, 0x08, sEyeSwitchTextures[subType][this->eyeTexIndex]); + gSPDisplayList(POLY_XLU_DISP++, sEyeSwitchDL[subType]); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void ObjSwitch_DrawEyeSwitch(ObjSwitch* this, GlobalContext* globalCtx) { + if (OBJ_SWITCH_IS_INVISIBLE(&this->dyna.actor)) { + ObjSwitch_DrawInvisibleEyeSwitch(this, globalCtx); + } else { + ObjSwitch_DrawVisibleEyeSwitch(this, globalCtx); + } +} + +void ObjSwitch_DrawCrystalSwitch(ObjSwitch* this, GlobalContext* globalCtx) { + s32 pad[2]; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_800B8118(&this->dyna.actor, globalCtx, 0); + AnimatedMat_DrawStep(globalCtx, sCrystalSwitchAnimatedMat, this->crystalAnimTimer); + func_8012C28C(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gCrystalSwitchBaseDL); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x80, this->color.r, this->color.g, this->color.b, 255); + gSPDisplayList(POLY_OPA_DISP++, gCrystalSwitchCoreDL); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gCrystalSwitchDiamondDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void ObjSwitch_Draw(Actor* thisx, GlobalContext* globalCtx) { + static ObjSwitchDrawFunc drawFunc[] = { + ObjSwitch_DrawFloorSwitch, ObjSwitch_DrawRustyFloorSwitch, ObjSwitch_DrawEyeSwitch, + ObjSwitch_DrawCrystalSwitch, ObjSwitch_DrawCrystalSwitch, ObjSwitch_DrawFloorSwitch, + }; + ObjSwitch* this = THIS; + + drawFunc[OBJ_SWITCH_GET_TYPE(&this->dyna.actor)](this, globalCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.h b/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.h index 5d1134f124..42ee4207fd 100644 --- a/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.h +++ b/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.h @@ -5,7 +5,26 @@ struct ObjSwitch; -typedef void (*ObjSwitchActionFunc)(struct ObjSwitch*, GlobalContext*); +typedef void (*ObjSwitchActionFunc)(struct ObjSwitch* this, GlobalContext* globalCtx); +typedef void (*ObjSwitchDrawFunc)(struct ObjSwitch* this, GlobalContext* globalCtx); +typedef void (*ObjSwitchSetupActionFunc)(struct ObjSwitch* this); + +typedef enum { + /* 0 */ OBJSWITCH_TYPE_FLOOR, + /* 1 */ OBJSWITCH_TYPE_FLOOR_RUSTY, // Unused, incomplete implementation + /* 2 */ OBJSWITCH_TYPE_EYE, + /* 3 */ OBJSWITCH_TYPE_CRYSTAL, + /* 4 */ OBJSWITCH_TYPE_CRYSTAL_TARGETABLE, + /* 5 */ OBJSWITCH_TYPE_FLOOR_LARGE +} ObjSwitchType; + +typedef enum { + /* 0 */ OBJSWITCH_SUBTYPE_ONCE, // Set Switch Flag when activated, stays activated + /* 1 */ OBJSWITCH_SUBTYPE_TOGGLE, // Toggle Switch Flag when activated + /* 2 */ OBJSWITCH_SUBTYPE_RESET, // Floor type only, set switch flag when pressed, unset when released + /* 3 */ OBJSWITCH_SUBTYPE_RESET_INVERTED, // Floor type only, set switch flag when not pressed, unset when pressed + /* 4 */ OBJSWITCH_SUBTYPE_SYNC // Crystal type only, syncronizes all crystal fl +} ObjSwitchSubType; #define OBJSWITCH_GET_33(thisx) ((thisx)->params & 0x33) #define OBJSWITCH_GET_7F00(thisx) (((thisx)->params >> 8) & 0x7F) @@ -14,12 +33,41 @@ typedef void (*ObjSwitchActionFunc)(struct ObjSwitch*, GlobalContext*); #define OBJSWITCH_INVERSE_BLUE 0x30 typedef struct ObjSwitch { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; + /* 0x0000 */ DynaPolyActor dyna; /* 0x015C */ ObjSwitchActionFunc actionFunc; - /* 0x0160 */ char unk_160[0xF8]; + /* 0x0160 */ s16 floorSwitchReleaseTimer; + /* 0x0162 */ s16 disableCrystalSwitchTimer; + /* 0x0164 */ s8 eyeTexIndex; + /* 0x0165 */ s8 sfxTimer; + /* 0x0168 */ s32 crystalAnimTimer; + /* 0x016C */ Color_RGB8 color; + /* 0x016F */ u8 collisionFlags; + /* 0x0170 */ s8 floorSwitchPlayerSnapState; + /* 0x0171 */ s8 nextSwitchFlagState; + /* 0x0172 */ s8 isPlayingCutscene; + /* 0x0174 */ ObjSwitchSetupActionFunc setupFunc; + union { + struct { + /* 0x0178 */ ColliderJntSph colliderJntSph; + /* 0x0198 */ ColliderJntSphElement colliderJntSphElements[1]; + }; + struct { + /* 0x0178 */ ColliderTris colliderTris; + /* 0x0198 */ ColliderTrisElement colliderTrisElements[2]; + }; + }; + /* 0x0250 */ f32 floorSwitchUpScale; + /* 0x0254 */ f32 floorSwitchDownScale; } ObjSwitch; // size = 0x258 extern const ActorInit Obj_Switch_InitVars; +#define OBJ_SWITCH_GET_TYPE(thisx) ((thisx)->params&7) +#define OBJ_SWITCH_GET_SUBTYPE(thisx) ((thisx)->params >> 4 & 7) +#define OBJ_SWITCH_GET_SWITCH_FLAG(thisx) ((thisx)->params >> 8 & 0x7F) +#define OBJ_SWITCH_IS_FROZEN(thisx) ((thisx)->params >> 7 & 1) +#define OBJ_SWITCH_UNSET_FROZEN(thisx) ((thisx)->params &= ~(1 << 7)) +#define OBJ_SWITCH_IS_INVISIBLE(thisx) ((thisx)->params >> 3 & 1) +#define OBJ_SWITCH_GET_COLOR_ID(thisx) ((thisx)->home.rot.z&1) + #endif // Z_OBJ_SWITCH_H diff --git a/src/overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.c b/src/overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.c index 9ff5b45999..b46f2626e9 100644 --- a/src/overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.c +++ b/src/overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.c @@ -197,7 +197,7 @@ void ObjTokeiStep_Init(Actor* thisx, GlobalContext* globalCtx) { DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gClocktowerPanelCol); ObjTokeiStep_InitSteps(this); ObjTokeiStep_SetupBeginOpen(this); - } else if (((CURRENT_DAY == 3) && (gSaveContext.time < CLOCK_TIME(6, 0))) || (gSaveContext.day >= 4)) { + } else if (((CURRENT_DAY == 3) && (gSaveContext.save.time < CLOCK_TIME(6, 0))) || (gSaveContext.save.day >= 4)) { this->dyna.actor.draw = ObjTokeiStep_DrawOpen; ObjTokeiStep_InitStepsOpen(this); ObjTokeiStep_SetupDoNothingOpen(this); diff --git a/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c b/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c index 3ecac575f6..95f0eb3a88 100644 --- a/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c +++ b/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c @@ -87,8 +87,8 @@ static InitChainEntry sInitChain[] = { * angle can differ from the target angle if the panel is in * the middle of rotating. */ -s32 ObjTokeidai_GetTargetSunMoonPanelRotation() { - if (gSaveContext.isNight) { +s32 ObjTokeidai_GetTargetSunMoonPanelRotation(void) { + if (gSaveContext.save.isNight) { return 0x8000; } return 0; @@ -126,11 +126,11 @@ void ObjTokeidai_ExteriorGear_Init(ObjTokeidai* this, GlobalContext* globalCtx) ((globalCtx->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 2) && (globalCtx->csCtx.currentCsIndex == 0))) { ObjTokeidai_SetupTowerOpening(this); - } else if ((CURRENT_DAY == 3 && gSaveContext.time < CLOCK_TIME(6, 0)) || CURRENT_DAY >= 4) { + } else if ((CURRENT_DAY == 3 && gSaveContext.save.time < CLOCK_TIME(6, 0)) || CURRENT_DAY >= 4) { this->actionFunc = ObjTokeidai_ExteriorGear_OpenedIdle; this->actor.world.pos.y += this->actor.scale.y * 1900.0f; this->actor.shape.yOffset = 1500.0f; - gSaveContext.weekEventReg[8] |= 0x40; + gSaveContext.save.weekEventReg[8] |= 0x40; } else { this->actionFunc = ObjTokeidai_ExteriorGear_Idle; } @@ -145,7 +145,7 @@ void ObjTokeidai_TowerClock_Init(ObjTokeidai* this, GlobalContext* globalCtx) { ((globalCtx->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 2) && (globalCtx->csCtx.currentCsIndex == 0))) { ObjTokeidai_SetupTowerOpening(this); - } else if ((CURRENT_DAY == 3 && gSaveContext.time < CLOCK_TIME(6, 0)) || CURRENT_DAY >= 4) { + } else if ((CURRENT_DAY == 3 && gSaveContext.save.time < CLOCK_TIME(6, 0)) || CURRENT_DAY >= 4) { this->actor.world.pos.y += (this->actor.scale.y * 5191.0f) - 50.0f; this->actor.world.pos.x += Math_SinS(this->actor.world.rot.y) * this->actor.scale.z * 1791.0f; this->actor.world.pos.z += -Math_CosS(this->actor.world.rot.y) * this->actor.scale.z * 1791.0f; @@ -169,7 +169,7 @@ void ObjTokeidai_Counterweight_Init(ObjTokeidai* this, GlobalContext* globalCtx) this->actor.draw = ObjTokeidai_Counterweight_Draw; this->opaDList = gClockTowerCounterweightDL; this->xluDList = gClockTowerSpotlightDL; - if (gSaveContext.isNight) { + if (gSaveContext.save.isNight) { this->spotlightIntensity = 100; } else { this->spotlightIntensity = 0; @@ -199,7 +199,7 @@ void ObjTokeidai_Counterweight_Init(ObjTokeidai* this, GlobalContext* globalCtx) this->actor.child->home.rot.x = 0x12C; } } - } else if ((CURRENT_DAY == 3 && gSaveContext.time < CLOCK_TIME(6, 0)) || CURRENT_DAY >= 4) { + } else if ((CURRENT_DAY == 3 && gSaveContext.save.time < CLOCK_TIME(6, 0)) || CURRENT_DAY >= 4) { this->spotlightIntensity = 0; this->actor.world.pos.y += this->actor.scale.y * -2160.0f; this->actor.world.pos.x += Math_SinS(this->actor.world.rot.y) * this->actor.scale.z * 5400.0f; @@ -221,7 +221,7 @@ void ObjTokeidai_Init(Actor* thisx, GlobalContext* globalCtx) { this->xRotation = 0; this->yTranslation = 0; this->clockFaceZTranslation = 0; - this->clockTime = gSaveContext.time; + this->clockTime = gSaveContext.save.time; this->actor.home.rot.x = 0; switch (OBJ_TOKEIDAI_TYPE(&this->actor)) { @@ -448,19 +448,19 @@ void ObjTokeidai_TerminaFieldWalls_Idle(ObjTokeidai* this, GlobalContext* global void ObjTokeidai_TowerOpening_EndCutscene(ObjTokeidai* this, GlobalContext* globalCtx) { if (Cutscene_CheckActorAction(globalCtx, 132) != 0 && globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 132)]->action == 5) { - gSaveContext.weekEventReg[8] |= 0x40; + gSaveContext.save.weekEventReg[8] |= 0x40; if (((globalCtx->sceneNum == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 2) && (globalCtx->csCtx.currentCsIndex == 0)) || ((globalCtx->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 2) && (globalCtx->csCtx.currentCsIndex == 0))) { Audio_SetCutsceneFlag(false); - gSaveContext.cutscene = 0; + gSaveContext.save.cutscene = 0; gSaveContext.nextCutsceneIndex = 0; gSaveContext.respawnFlag = 2; globalCtx->sceneLoadFlag = 0x14; - globalCtx->nextEntranceIndex = gSaveContext.respawn[1].entranceIndex; + globalCtx->nextEntranceIndex = gSaveContext.respawn[RESTART_MODE_RETURN].entranceIndex; globalCtx->unk_1887F = 2; - if (gSaveContext.respawn[1].playerParams == 0xCFF) { + if (gSaveContext.respawn[RESTART_MODE_RETURN].playerParams == 0xCFF) { gSaveContext.nextTransition = 0x15; } else { gSaveContext.nextTransition = 2; @@ -595,7 +595,7 @@ void ObjTokeidai_TowerOpening_RaiseTower(ObjTokeidai* this, GlobalContext* globa void ObjTokeidai_TowerOpening_Start(ObjTokeidai* this, GlobalContext* globalCtx) { if ((Cutscene_CheckActorAction(globalCtx, 132) && globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 132)]->action == 4) || - (gSaveContext.weekEventReg[8] & 0x40)) { + (gSaveContext.save.weekEventReg[8] & 0x40)) { this->actionFunc = ObjTokeidai_TowerOpening_RaiseTower; } } @@ -617,8 +617,8 @@ void ObjTokeidai_DoNothing(ObjTokeidai* this, GlobalContext* globalCtx) { } void ObjTokeidai_StaircaseToRooftop_Idle(ObjTokeidai* this, GlobalContext* globalCtx) { - if (((CURRENT_DAY == 3 && gSaveContext.time < CLOCK_TIME(6, 0)) || CURRENT_DAY >= 4) || - (gSaveContext.weekEventReg[8] & 0x40)) { + if (((CURRENT_DAY == 3 && gSaveContext.save.time < CLOCK_TIME(6, 0)) || CURRENT_DAY >= 4) || + (gSaveContext.save.weekEventReg[8] & 0x40)) { this->actor.draw = ObjTokeidai_Draw; } else { this->actor.draw = NULL; @@ -626,10 +626,10 @@ void ObjTokeidai_StaircaseToRooftop_Idle(ObjTokeidai* this, GlobalContext* globa } s32 ObjTokeidai_IsPostFirstCycleFinalHours(ObjTokeidai* this, GlobalContext* globalCtx) { - if (gSaveContext.inventory.items[SLOT_OCARINA] == ITEM_NONE) { + if (gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) { return false; } - if (CURRENT_DAY == 3 && gSaveContext.time < CLOCK_TIME(6, 0)) { + if (CURRENT_DAY == 3 && gSaveContext.save.time < CLOCK_TIME(6, 0)) { ObjTokeidai_SetupTowerOpening(this); return true; } @@ -690,10 +690,10 @@ void ObjTokeidai_RotateOnHourChange(ObjTokeidai* this, GlobalContext* globalCtx) } void ObjTokeidai_TowerClock_Idle(ObjTokeidai* this, GlobalContext* globalCtx) { - if (CURRENT_DAY == 3 && this->clockHour < 6 && gSaveContext.time < CLOCK_TIME(6, 0)) { + if (CURRENT_DAY == 3 && this->clockHour < 6 && gSaveContext.save.time < CLOCK_TIME(6, 0)) { this->actor.draw = ObjTokeidai_Clock_Draw; ObjTokeidai_SetupTowerOpening(this); - gSaveContext.weekEventReg[8] |= 0x40; + gSaveContext.save.weekEventReg[8] |= 0x40; return; } @@ -707,21 +707,21 @@ void ObjTokeidai_TowerClock_Idle(ObjTokeidai* this, GlobalContext* globalCtx) { ActorCutscene_GetCurrentIndex() == -1) { this->actor.draw = NULL; } - this->clockTime = gSaveContext.time; + this->clockTime = gSaveContext.save.time; if (this->actor.home.rot.x != 0) { ObjTokeidai_Clock_Init(this); this->actor.home.rot.x = 0; } } - if (CURRENT_DAY != 3 || gSaveContext.time >= CLOCK_TIME(6, 0)) { + if (CURRENT_DAY != 3 || gSaveContext.save.time >= CLOCK_TIME(6, 0)) { ObjTokeidai_RotateOnMinuteChange(this, true); } ObjTokeidai_RotateOnHourChange(this, globalCtx); } void ObjTokeidai_WallClock_Idle(ObjTokeidai* this, GlobalContext* globalCtx) { - this->clockTime = gSaveContext.time; + this->clockTime = gSaveContext.save.time; ObjTokeidai_RotateOnMinuteChange(this, true); ObjTokeidai_RotateOnHourChange(this, globalCtx); } @@ -740,7 +740,7 @@ void ObjTokeidai_ExteriorGear_Idle(ObjTokeidai* this, GlobalContext* globalCtx) ActorCutscene_GetCurrentIndex() == -1) { this->actor.draw = NULL; } - this->clockTime = gSaveContext.time; + this->clockTime = gSaveContext.save.time; if (this->actor.home.rot.x != 0) { ObjTokeidai_SetupClockOrExteriorGear(this); this->actor.home.rot.x = 0; @@ -775,7 +775,7 @@ void ObjTokeidai_Counterweight_Idle(ObjTokeidai* this, GlobalContext* globalCtx) } } else { this->actor.shape.rot.y -= 0x40; - if (gSaveContext.isNight) { + if (gSaveContext.save.isNight) { if (this->spotlightIntensity < 100) { this->spotlightIntensity += 4; } diff --git a/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c b/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c index 10d87e6bc5..9e36e5a2a4 100644 --- a/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c +++ b/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c @@ -5,6 +5,7 @@ */ #include "z_obj_vspinyroll.h" +#include "objects/object_spinyroll/object_spinyroll.h" #define FLAGS (ACTOR_FLAG_10) @@ -15,13 +16,17 @@ void ObjVspinyroll_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjVspinyroll_Update(Actor* thisx, GlobalContext* globalCtx); void ObjVspinyroll_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80A3CEC4(ObjVspinyroll* this); void func_80A3CEE0(ObjVspinyroll* this, GlobalContext* globalCtx); void func_80A3CF4C(ObjVspinyroll* this, GlobalContext* globalCtx); +void func_80A3CFAC(ObjVspinyroll* this); void func_80A3CFE0(ObjVspinyroll* this, GlobalContext* globalCtx); +void func_80A3D024(ObjVspinyroll* this); void func_80A3D038(ObjVspinyroll* this, GlobalContext* globalCtx); +void func_80A3D0E8(ObjVspinyroll* this); void func_80A3D0FC(ObjVspinyroll* this, GlobalContext* globalCtx); +void func_80A3D2C0(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Vspinyroll_InitVars = { ACTOR_OBJ_VSPINYROLL, ACTORCAT_PROP, @@ -34,77 +39,420 @@ const ActorInit Obj_Vspinyroll_InitVars = { (ActorFunc)ObjVspinyroll_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A3D488 = { - { COLTYPE_METAL, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x20000000, 0x00, 0x04 }, { 0x01C37BB6, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +f32 D_80A3D450[] = { 1.0f, 2.0f }; + +f32 D_80A3D458[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f }; + +s16 D_80A3D478[] = { 1, 10, 20, 30, 40, 50, 60, 70 }; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_METAL, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x20000000, 0x00, 0x04 }, + { 0x01C37BB6, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 30, 120, 0, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80A3D4D4[] = { +f32 D_80A3D4B4[] = { 1.0f, 1.0f, -1.0f, -1.0f }; + +f32 D_80A3D4C4[] = { 29.0f, -29.0f, 29.0f, -29.0f }; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 500, ICHAIN_STOP), }; +s16 D_80A3D4DC[] = { 0xFA0, -0xFA0 }; + +void func_80A3C4E0(Vec3f* arg0, Vec3f* arg1, s16 arg2) { + f32 sp1C = Math_SinS(arg2); + f32 temp_f0 = Math_CosS(arg2); + + arg0->x = (arg1->z * sp1C) + (arg1->x * temp_f0); + arg0->y = arg1->y; + arg0->z = (arg1->z * temp_f0) - (arg1->x * sp1C); +} + +void func_80A3C560(ObjVspinyroll* this) { + f32 magnitude; + Vec3f* sp20 = &this->unk_39C[this->unk_398 ^ 1]; + + Math_Vec3f_Diff(sp20, &this->dyna.actor.world.pos, &this->unk_3B4); + magnitude = Math3D_Vec3fMagnitude(&this->unk_3B4); + if (magnitude < 0.01f) { + Math_Vec3f_Diff(sp20, &this->unk_39C[this->unk_398], &this->unk_3B4); + magnitude = Math3D_Vec3fMagnitude(&this->unk_3B4); + if (magnitude < 0.01f) { + Math_Vec3f_Copy(&this->unk_3B4, &gZeroVec3f); + return; + } + } + Math_Vec3f_Scale(&this->unk_3B4, 1.0f / magnitude); +} + +void func_80A3C658(ObjVspinyroll* this) { + this->dyna.actor.world.rot.y = Math_Vec3f_Yaw(&this->dyna.actor.world.pos, &this->unk_39C[this->unk_398 ^ 1]); +} + +void func_80A3C6A0(ObjVspinyroll* this) { + this->unk_398 = 0; + func_80A3C658(this); + func_80A3C560(this); +} + +void func_80A3C6CC(ObjVspinyroll* this) { + this->unk_398 ^= 1; + func_80A3C658(this); + func_80A3C560(this); +} + +s32 func_80A3C700(ObjVspinyroll* this) { + s32 pad; + s32 sp30 = this->unk_398 ^ 1; + Vec3f sp24; + + Math_StepToF(&this->dyna.actor.speedXZ, this->unk_394, this->unk_394 * 0.2f); + + this->dyna.actor.world.pos.x += this->dyna.actor.speedXZ * this->unk_3B4.x; + this->dyna.actor.world.pos.y += this->dyna.actor.speedXZ * this->unk_3B4.y; + this->dyna.actor.world.pos.z += this->dyna.actor.speedXZ * this->unk_3B4.z; + + Math_Vec3f_Diff(&this->unk_39C[sp30], &this->dyna.actor.world.pos, &sp24); + return Math3D_LengthSquared(&sp24) < (SQ(this->dyna.actor.speedXZ) + 0.05f); +} + +void func_80A3C7E8(ObjVspinyroll* this) { + f32 phi_f2; + s32 i; + s32 j; + f32 tempf; + s32 index = D_80A3D450[OBJVSPINYROLL_GET_4000(&this->dyna.actor)] * 120.0f * (1.0f / 58.0f); + + index += 2; + this->unk_38C = index * 4; + + tempf = ((D_80A3D450[OBJVSPINYROLL_GET_4000(&this->dyna.actor)] * 120.0f) - 2.0f) / (index - 1); + phi_f2 = 1.0f; + + for (i = 0, j = 0; i < this->unk_38C; i++) { + this->unk_1A8[i].unk_00.x = D_80A3D4C4[j]; + this->unk_1A8[i].unk_00.y = phi_f2; + this->unk_1A8[i].unk_00.z = D_80A3D4B4[j]; + + j++; + if (j >= 4) { + j = 0; + phi_f2 += tempf; + } + } +} + +#ifdef NON_MATCHING +s32 func_80A3C8D8(ObjVspinyroll* this, GlobalContext* globalCtx, Vec3f* arg2, s32 arg3) { + s32 pad; + ObjVspinyrollStruct2* ptr = &this->unk_1A8[0]; + s32 pad2; + s32 i; + Vec3f spE4; + Vec3f spD8; + Vec3f spCC; + Vec3f spC0; + Vec3f spB4; + Vec3f spA8; + f32 temp_f20 = FLT_MAX; + f32 temp_f0; + s32 sp9C; + + spE4.z = 0.0f; + sp9C = false; + this->unk_388 = NULL; + + for (i = 0; i < this->unk_38C; i++, ptr++) { + spE4.x = ptr->unk_00.x; + spE4.y = ptr->unk_00.y; + func_80A3C4E0(&spD8, &spE4, this->dyna.actor.world.rot.y); + + spD8.x += this->dyna.actor.world.pos.x; + spD8.y += this->dyna.actor.world.pos.y; + spD8.z += this->dyna.actor.world.pos.z; + + Math_Vec3f_Copy(&spCC, &spD8); + + spCC.x += 30.0f * this->unk_3B4.x; + spCC.z += 30.0f * this->unk_3B4.z; + + if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &spD8, &spCC, &spC0, &this->unk_1A8[i].collisionPoly, true, + false, false, true, &this->unk_1A8[i].bgId, &this->dyna.actor, 0.0f)) { + if ((arg3 != 0) && (this->dyna.actor.flags & ACTOR_FLAG_40)) { + spA8.x = ptr->unk_00.x * 0.2f; + spA8.y = ptr->unk_00.y; + spA8.z = 20.0f; + + func_80A3C4E0(&spB4, &spA8, this->dyna.actor.world.rot.y); + + spB4.x += this->dyna.actor.world.pos.x; + spB4.y += this->dyna.actor.world.pos.y; + spB4.z += this->dyna.actor.world.pos.z; + + EffectSsHitMark_SpawnFixedScale(globalCtx, 3, &spB4); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_IT_SHIELD_REFLECT_SW); + } + + temp_f0 = Math3D_Vec3fDistSq(&spD8, &spC0); + if (temp_f0 < temp_f20) { + temp_f20 = temp_f0; + sp9C = true; + Math_Vec3f_Diff(&spC0, &spCC, arg2); + this->unk_388 = ptr; + } + } + } + + return sp9C; +} +#else +s32 func_80A3C8D8(ObjVspinyroll* this, GlobalContext* globalCtx, Vec3f* arg2, s32 arg3); +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3C8D8.s") #endif -extern ColliderCylinderInit D_80A3D488; -extern InitChainEntry D_80A3D4D4[]; +s32 func_80A3CB94(ObjVspinyroll* this, GlobalContext* globalCtx, s32 arg2) { + Vec3f sp1C; -extern UNK_TYPE D_06000460; -extern UNK_TYPE D_06000F80; + if (func_80A3C8D8(this, globalCtx, &sp1C, arg2)) { + this->dyna.actor.world.pos.x += sp1C.x; + this->dyna.actor.world.pos.z += sp1C.z; + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3C4E0.s") +DynaPolyActor* func_80A3CBF0(ObjVspinyroll* this, GlobalContext* globalCtx) { + if (this->unk_388 != NULL) { + return DynaPoly_GetActor(&globalCtx->colCtx, this->unk_388->bgId); + } + return NULL; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3C560.s") +s32 func_80A3CC30(ObjVspinyroll* this, GlobalContext* globalCtx) { + DynaPolyActor* actor = func_80A3CBF0(this, globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3C658.s") + if ((actor != NULL) && (Math3D_Vec3fDistSq(&actor->actor.world.pos, &actor->actor.prevPos) > 0.0001f)) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3C6A0.s") +void func_80A3CC84(f32 arg0) { + MtxF* matrix = Matrix_GetCurrentState(); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3C6CC.s") + matrix->wy += arg0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3C700.s") +void ObjVspinyroll_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjVspinyroll* this = THIS; + s32 params = OBJVSPINYROLL_GET_4000(&this->dyna.actor); + f32 sp40 = D_80A3D450[params]; + s32 pad2; + Path* path; + Vec3s* points; + Vec3s* point1; + Vec3s* point2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3C7E8.s") + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3C8D8.s") + this->dyna.actor.world.rot.x = 0; + this->dyna.actor.world.rot.z = 0; + this->dyna.actor.shape.rot.x = 0; + this->dyna.actor.shape.rot.z = 0; + this->dyna.actor.scale.y = 0.1f * sp40; + this->dyna.actor.scale.z = 0.1f; + this->dyna.actor.uncullZoneScale = 300.0f * sp40; + this->dyna.actor.scale.x = 0.1f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3CB94.s") + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_spinyroll_Colheader_000F80); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3CBF0.s") + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3CC30.s") + if (params == OBJVSPINYROLL_4000_1) { + this->dyna.actor.draw = func_80A3D2C0; + this->collider.dim.height = 240; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3CC84.s") + if (OBJVSPINYROLL_GET_7F(&this->dyna.actor) == OBJVSPINYROLL_7F_7F) { + func_80A3CEC4(this); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/ObjVspinyroll_Init.s") + this->dyna.actor.world.rot.y = 0; + func_80A3C7E8(this); + this->unk_394 = D_80A3D458[OBJVSPINYROLL_GET_380(thisx)]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/ObjVspinyroll_Destroy.s") + path = &globalCtx->setupPathList[OBJVSPINYROLL_GET_7F(&this->dyna.actor)]; + points = Lib_SegmentedToVirtual(path->points); + point1 = &points[0]; + point2 = &points[1]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3CEC4.s") + Math_Vec3s_ToVec3f(&this->unk_39C[0], point1); + Math_Vec3s_ToVec3f(&this->unk_39C[1], point2); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3CEE0.s") + Math_Vec3f_Copy(&this->dyna.actor.world.pos, &this->unk_39C[0]); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3CF10.s") + func_80A3C6A0(this); + this->dyna.actor.shape.rot.y = this->dyna.actor.world.rot.y; + func_80A3CFAC(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3CF4C.s") +void ObjVspinyroll_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjVspinyroll* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3CFAC.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3CFE0.s") +void func_80A3CEC4(ObjVspinyroll* this) { + this->dyna.actor.speedXZ = 0.0f; + this->actionFunc = func_80A3CEE0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3D024.s") +void func_80A3CEE0(ObjVspinyroll* this, GlobalContext* globalCtx) { + this->unk_3C0 += 0x6E; + if (this->unk_3C0 > 0xFA0) { + this->unk_3C0 = 0xFA0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3D038.s") +void func_80A3CF10(ObjVspinyroll* this) { + this->actionFunc = func_80A3CF4C; + this->unk_3C8 = D_80A3D478[OBJVSPINYROLL_GET_1C00(&this->dyna.actor)]; + this->dyna.actor.speedXZ = 0.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3D0E8.s") +void func_80A3CF4C(ObjVspinyroll* this, GlobalContext* globalCtx) { + if (Math_ScaledStepToS(&this->unk_3C0, 0, this->unk_3C4) && (this->unk_3C8 > 0)) { + this->unk_3C8--; + if (this->unk_3C8 <= 0) { + func_80A3CFAC(this); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3D0FC.s") +void func_80A3CFAC(ObjVspinyroll* this) { + this->actionFunc = func_80A3CFE0; + this->unk_3C2 = D_80A3D4DC[this->unk_398]; + this->dyna.actor.speedXZ = 0.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/ObjVspinyroll_Update.s") +void func_80A3CFE0(ObjVspinyroll* this, GlobalContext* globalCtx) { + if (Math_ScaledStepToS(&this->unk_3C0, this->unk_3C2, 0x6E)) { + func_80A3D024(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/ObjVspinyroll_Draw.s") +void func_80A3D024(ObjVspinyroll* this) { + this->actionFunc = func_80A3D038; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3D2C0.s") +void func_80A3D038(ObjVspinyroll* this, GlobalContext* globalCtx) { + s32 sp24 = func_80A3C700(this); + + if (func_80A3CB94(this, globalCtx, 1)) { + this->unk_3C4 = 0x7D0; + if (func_80A3CBF0(this, globalCtx) != NULL) { + func_80A3D0E8(this); + } else { + func_80A3C6CC(this); + func_80A3CF10(this); + } + } else if (sp24 != 0) { + func_80A3C6CC(this); + this->unk_3C4 = 120; + func_80A3CF10(this); + } +} + +void func_80A3D0E8(ObjVspinyroll* this) { + this->actionFunc = func_80A3D0FC; +} + +void func_80A3D0FC(ObjVspinyroll* this, GlobalContext* globalCtx) { + s32 sp24 = true; + + Math_ScaledStepToS(&this->unk_3C0, 0, this->unk_3C4); + if (func_80A3CB94(this, globalCtx, 0) && func_80A3CC30(this, globalCtx)) { + sp24 = false; + } + + if (sp24) { + func_80A3C6CC(this); + func_80A3CF10(this); + } +} + +void ObjVspinyroll_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + ObjVspinyroll* this = THIS; + + this->actionFunc(this, globalCtx); + + this->unk_3C6 += this->unk_3C0; + + Collider_UpdateCylinder(&this->dyna.actor, &this->collider); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +void ObjVspinyroll_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjVspinyroll* this = THIS; + + Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y + 60.0f, + this->dyna.actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->dyna.actor.shape.rot.z + 0x4000, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->dyna.actor.shape.rot.x + this->unk_3C6, MTXMODE_APPLY); + Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); + Gfx_DrawDListOpa(globalCtx, object_spinyroll_DL_000460); +} + +void func_80A3D2C0(Actor* thisx, GlobalContext* globalCtx) { + ObjVspinyroll* this = THIS; + Vec3s sp3C; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + sp3C.x = this->dyna.actor.shape.rot.x + this->unk_3C6; + sp3C.y = this->dyna.actor.shape.rot.y; + sp3C.z = this->dyna.actor.shape.rot.z + 0x4000; + + func_8012C28C(globalCtx->state.gfxCtx); + Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y + 60.0f, + this->dyna.actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateY(sp3C.y, MTXMODE_APPLY); + Matrix_InsertZRotation_s(sp3C.z, MTXMODE_APPLY); + Matrix_InsertXRotation_s(sp3C.x, MTXMODE_APPLY); + Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_spinyroll_DL_000460); + + func_80A3CC84(120.0f); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_spinyroll_DL_000460); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.h b/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.h index 371eb7b4f7..af1048267e 100644 --- a/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.h +++ b/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.h @@ -7,11 +7,36 @@ struct ObjVspinyroll; typedef void (*ObjVspinyrollActionFunc)(struct ObjVspinyroll*, GlobalContext*); +#define OBJVSPINYROLL_GET_7F(thisx) ((thisx)->params & 0x7F) +#define OBJVSPINYROLL_GET_380(thisx) (((thisx)->params >> 7) & 7) +#define OBJVSPINYROLL_GET_1C00(thisx) (((thisx)->params >> 0xA) & 7) +#define OBJVSPINYROLL_GET_4000(thisx) (((thisx)->params >> 0xE) & 1) + +#define OBJVSPINYROLL_7F_7F 0x7F +#define OBJVSPINYROLL_4000_1 1 + +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ CollisionPoly* collisionPoly; + /* 0x10 */ s32 bgId; +} ObjVspinyrollStruct2; // size = 0x14 + typedef struct ObjVspinyroll { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x24C]; + /* 0x0000 */ DynaPolyActor dyna; + /* 0x015C */ ColliderCylinder collider; + /* 0x01A8 */ ObjVspinyrollStruct2 unk_1A8[24]; + /* 0x0388 */ ObjVspinyrollStruct2* unk_388; + /* 0x038C */ s32 unk_38C; /* 0x0390 */ ObjVspinyrollActionFunc actionFunc; - /* 0x0394 */ char unk_394[0x38]; + /* 0x0394 */ f32 unk_394; + /* 0x0398 */ s32 unk_398; + /* 0x039C */ Vec3f unk_39C[2]; + /* 0x03B4 */ Vec3f unk_3B4; + /* 0x03C0 */ s16 unk_3C0; + /* 0x03C2 */ s16 unk_3C2; + /* 0x03C4 */ s16 unk_3C4; + /* 0x03C6 */ s16 unk_3C6; + /* 0x03C8 */ s16 unk_3C8; } ObjVspinyroll; // size = 0x3CC extern const ActorInit Obj_Vspinyroll_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c b/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c index 37a1412649..fde0406f15 100644 --- a/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c +++ b/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c @@ -110,7 +110,7 @@ s32 ObjWarpstone_BeginOpeningCutscene(ObjWarpstone* this, GlobalContext* globalC s32 ObjWarpstone_PlayOpeningCutscene(ObjWarpstone* this, GlobalContext* globalCtx) { if (this->openingCSTimer++ >= OBJ_WARPSTONE_TIMER_ACTIVATE_THRESHOLD) { ActorCutscene_Stop(this->dyna.actor.cutscene); - func_80143A10(OBJ_WARPSTONE_GET_ID(this)); + Sram_ActivateOwl(OBJ_WARPSTONE_GET_ID(this)); ObjWarpstone_SetupAction(this, ObjWarpstone_OpenedIdle); } else if (this->openingCSTimer < OBJ_WARPSTONE_TIMER_OPEN_THRESHOLD) { Math_StepToF(&this->dyna.actor.velocity.x, 0.01f, 0.001f); @@ -138,13 +138,13 @@ void ObjWarpstone_Update(Actor* thisx, GlobalContext* globalCtx) { if (this->isTalking) { if (Actor_TextboxIsClosing(&this->dyna.actor, globalCtx)) { this->isTalking = false; - } else if ((Message_GetState(&globalCtx->msgCtx) == 4) && (func_80147624(globalCtx))) { + } else if ((Message_GetState(&globalCtx->msgCtx) == 4) && (Message_ShouldAdvance(globalCtx))) { if (globalCtx->msgCtx.choiceIndex != 0) { func_8019F208(); globalCtx->msgCtx.msgMode = 0x4D; globalCtx->msgCtx.unk120D6 = 0; globalCtx->msgCtx.unk120D4 = 0; - gSaveContext.owlSaveLocation = OBJ_WARPSTONE_GET_ID(this); + gSaveContext.save.owlSaveLocation = OBJ_WARPSTONE_GET_ID(this); } else { func_801477B4(globalCtx); } diff --git a/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.h b/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.h index 47163ec2c9..37cfb99abd 100644 --- a/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.h +++ b/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.h @@ -29,6 +29,6 @@ typedef struct ObjWarpstone { extern const ActorInit Obj_Warpstone_InitVars; #define OBJ_WARPSTONE_GET_ID(this) ((u16)(this->dyna.actor.params & 0xF)) -#define OBJ_WARPSTONE_IS_ACTIVATED(owlId) (((void)0,gSaveContext.owlActivationFlags) & (u16)gBitFlags[owlId]) +#define OBJ_WARPSTONE_IS_ACTIVATED(owlId) (((void)0, gSaveContext.save.playerData.owlActivationFlags) & (u16)gBitFlags[owlId]) #endif // Z_OBJ_WARPSTONE_H diff --git a/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.c b/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.c index 225587cdc9..34d82523ff 100644 --- a/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.c +++ b/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.c @@ -13,42 +13,116 @@ void ObjWturn_Init(Actor* thisx, GlobalContext* globalCtx); void ObjWturn_Update(Actor* thisx, GlobalContext* globalCtx); +void func_808A7954(ObjWturn* this); void func_808A7968(ObjWturn* this, GlobalContext* globalCtx); +void func_808A7A24(ObjWturn* this); void func_808A7A5C(ObjWturn* this, GlobalContext* globalCtx); +void func_808A7AAC(ObjWturn* this, GlobalContext* globalCtx); void func_808A7BA0(ObjWturn* this, GlobalContext* globalCtx); +void func_808A7C04(ObjWturn* this, GlobalContext* globalCtx); void func_808A7C78(ObjWturn* this, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Wturn_InitVars = { - ACTOR_OBJ_WTURN, - ACTORCAT_ITEMACTION, - FLAGS, - GAMEPLAY_KEEP, - sizeof(ObjWturn), - (ActorFunc)ObjWturn_Init, - (ActorFunc)Actor_Noop, - (ActorFunc)ObjWturn_Update, - (ActorFunc)NULL, + ACTOR_OBJ_WTURN, ACTORCAT_ITEMACTION, FLAGS, + GAMEPLAY_KEEP, sizeof(ObjWturn), (ActorFunc)ObjWturn_Init, + (ActorFunc)Actor_Noop, (ActorFunc)ObjWturn_Update, (ActorFunc)NULL, }; -#endif +void ObjWturn_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjWturn* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Wturn/ObjWturn_Init.s") + func_808A7954(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Wturn/func_808A7954.s") +void func_808A7954(ObjWturn* this) { + this->actionFunc = func_808A7968; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Wturn/func_808A7968.s") +void func_808A7968(ObjWturn* this, GlobalContext* globalCtx) { + if (globalCtx->msgCtx.ocarinaMode >= 28 && globalCtx->msgCtx.ocarinaMode < 39) { + Flags_UnsetSwitch(globalCtx, this->actor.params); + Actor_MarkForDeath(&this->actor); + } else if ((Flags_GetSwitch(globalCtx, this->actor.params) && (globalCtx->sceneNum == SCENE_F40)) || + (!Flags_GetSwitch(globalCtx, this->actor.params) && (globalCtx->sceneNum == SCENE_F41))) { + func_808A7A24(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Wturn/func_808A7A24.s") +void func_808A7A24(ObjWturn* this) { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + this->actionFunc = func_808A7A5C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Wturn/func_808A7A5C.s") +void func_808A7A5C(ObjWturn* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + func_808A7AAC(this, globalCtx); + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Wturn/func_808A7AAC.s") +void func_808A7AAC(ObjWturn* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f eye; + Vec3f at; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Wturn/func_808A7BA0.s") + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + func_8016566C(140); + this->camId = ActorCutscene_GetCurrentCamera(this->actor.cutscene); + func_800B7298(globalCtx, &this->actor, 21); + at.x = player->actor.focus.pos.x; + at.z = player->actor.focus.pos.z; + at.y = player->actor.focus.pos.y; + eye.x = (Math_SinS(this->actor.shape.rot.y) * 150.0f) + at.x; + eye.z = (Math_CosS(this->actor.shape.rot.y) * 150.0f) + at.z; + eye.y = at.y + 4.0f; + Play_CameraSetAtEye(globalCtx, this->camId, &at, &eye); + this->actionFunc = func_808A7BA0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Wturn/func_808A7C04.s") +void func_808A7BA0(ObjWturn* this, GlobalContext* globalCtx) { + if (Math_ScaledStepToS(&this->actor.shape.rot.z, -0x8000, 0x0200)) { + func_808A7C04(this, globalCtx); + } + func_800B8FE8(&this->actor, NA_SE_EV_EARTHQUAKE - SFX_FLAG); + Play_CameraSetRoll(globalCtx, this->camId, this->actor.shape.rot.z); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Wturn/func_808A7C78.s") +void func_808A7C04(ObjWturn* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Wturn/ObjWturn_Update.s") + this->actor.world.pos.y += this->actor.playerHeightRel; + player->actor.shape.shadowAlpha = 0; + func_800B7298(globalCtx, &this->actor, 0x54); + func_800B8E58(player, NA_SE_VO_NAVY_ENEMY); + this->unk_14A = 0; + func_80165690(); + this->actionFunc = func_808A7C78; +} + +void func_808A7C78(ObjWturn* this, GlobalContext* globalCtx) { + static Vec3f D_808A7DC0 = { 0.0f, -1.0f, 0.0f }; + Camera* camera = Play_GetCamera(globalCtx, this->camId); + Player* player = GET_PLAYER(globalCtx); + + this->unk_14A++; + player->actor.world.pos.y = this->actor.world.pos.y + this->unk_14A * 4.0f; + Play_CameraSetAtEyeUp(globalCtx, this->camId, &player->actor.focus.pos, &camera->eye, &D_808A7DC0); + if (this->unk_14A == 1) { + globalCtx->unk_1887F = 0x40; + gSaveContext.nextTransition = 3; + gSaveContext.nextCutsceneIndex = 0; + if (globalCtx->sceneNum == 0x58) { + globalCtx->nextEntranceIndex = 0xAC00; + } else { + globalCtx->nextEntranceIndex = 0xAA10; + } + globalCtx->sceneLoadFlag = 0x14; + } +} + +void ObjWturn_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjWturn* this = THIS; + + this->actionFunc(this, globalCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.h b/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.h index 0b0b8b3752..0390ac7a89 100644 --- a/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.h +++ b/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.h @@ -10,7 +10,8 @@ typedef void (*ObjWturnActionFunc)(struct ObjWturn*, GlobalContext*); typedef struct ObjWturn { /* 0x0000 */ Actor actor; /* 0x0144 */ ObjWturnActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x4]; + /* 0x0148 */ s16 camId; + /* 0x014A */ s16 unk_14A; } ObjWturn; // size = 0x14C extern const ActorInit Obj_Wturn_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Yado/z_obj_yado.c b/src/overlays/actors/ovl_Obj_Yado/z_obj_yado.c index 91bc39495e..997941057a 100644 --- a/src/overlays/actors/ovl_Obj_Yado/z_obj_yado.c +++ b/src/overlays/actors/ovl_Obj_Yado/z_obj_yado.c @@ -39,7 +39,7 @@ void ObjYado_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->actor, sInitChain); D_80C16470 = Lib_SegmentedToVirtual(object_yado_obj_Matanimheader_0012E8); - this->isNight = gSaveContext.isNight; + this->isNight = gSaveContext.save.isNight; } void ObjYado_Destroy(Actor* thisx, GlobalContext* globalCtx) { @@ -48,7 +48,7 @@ void ObjYado_Destroy(Actor* thisx, GlobalContext* globalCtx) { void ObjYado_Update(Actor* thisx, GlobalContext* globalCtx) { ObjYado* this = THIS; - this->isNight = gSaveContext.isNight; + this->isNight = gSaveContext.save.isNight; } void ObjYado_Draw(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.c b/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.c index 5668371fbe..3ed7879184 100644 --- a/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.c +++ b/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.c @@ -5,17 +5,19 @@ */ #include "z_obj_yasi.h" +#include "objects/object_obj_yasi/object_obj_yasi.h" #define FLAGS 0x00000000 #define THIS ((ObjYasi*)thisx) +#define CAN_DROP_NUT(thisx) (thisx->params < 0) + void ObjYasi_Init(Actor* thisx, GlobalContext* globalCtx); void ObjYasi_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjYasi_Update(Actor* thisx, GlobalContext* globalCtx); void ObjYasi_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Yasi_InitVars = { ACTOR_OBJ_YASI, ACTORCAT_PROP, @@ -28,25 +30,72 @@ const ActorInit Obj_Yasi_InitVars = { (ActorFunc)ObjYasi_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80BB4D90[] = { +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 400, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 800, ICHAIN_STOP), }; -#endif +void ObjYasi_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjYasi* this = THIS; -extern InitChainEntry D_80BB4D90[]; + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_obj_yasi_Colheader_001428); -extern UNK_TYPE D_06000360; -extern UNK_TYPE D_06001428; + this->dyna.actor.home.rot.y = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Yasi/ObjYasi_Init.s") + if (OBJYASI_IS_WIDE(thisx)) { + this->dyna.actor.scale.x = 0.2f; + this->dyna.actor.scale.z = 0.2f; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Yasi/ObjYasi_Destroy.s") +void ObjYasi_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjYasi* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Yasi/ObjYasi_Update.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Yasi/ObjYasi_Draw.s") +void ObjYasi_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjYasi* this = THIS; + s16 temp; + Vec3f dropPos; + + if (this->dyna.actor.home.rot.z != 0) { + if (CAN_DROP_NUT(thisx)) { + if (Rand_ZeroOne() < 0.5f) { + dropPos.x = this->dyna.actor.world.pos.x; + dropPos.y = this->dyna.actor.world.pos.y + 280.0f; + dropPos.z = this->dyna.actor.world.pos.z; + Item_DropCollectible(globalCtx, &dropPos, ITEM00_NUTS_1); + } + } + this->dyna.actor.home.rot.y = GET_PLAYER(globalCtx)->actor.shape.rot.y; + this->dyna.actor.home.rot.x = 400; + this->dyna.actor.home.rot.z = 0; + } + temp = (s16)(this->dyna.actor.shape.rot.x * 0.1f); + this->dyna.actor.home.rot.x -= temp; + this->dyna.actor.shape.rot.x += + BINANG_SUB(this->dyna.actor.home.rot.x, (s16)(this->dyna.actor.shape.rot.x * 0.08f)); +} + +void ObjYasi_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjYasi* this = THIS; + + Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, + MTXMODE_NEW); + + if (this->dyna.actor.shape.rot.x != 0) { + Matrix_RotateY(this->dyna.actor.home.rot.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->dyna.actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateY(BINANG_SUB(this->dyna.actor.shape.rot.y, this->dyna.actor.home.rot.y), MTXMODE_APPLY); + } else { + Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + } + + Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); + Gfx_DrawDListOpa(globalCtx, object_obj_yasi_DL_000360); +} diff --git a/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.h b/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.h index 3671a776cd..f4ab9ca9ca 100644 --- a/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.h +++ b/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.h @@ -6,10 +6,11 @@ struct ObjYasi; typedef struct ObjYasi { - /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x18]; + /* 0x000 */ DynaPolyActor dyna; } ObjYasi; // size = 0x15C extern const ActorInit Obj_Yasi_InitVars; +#define OBJYASI_IS_WIDE(thisx) ((thisx)->params & 1) + #endif // Z_OBJ_YASI_H diff --git a/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c b/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c index a8745c0152..f91385daa2 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c +++ b/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c @@ -4,6 +4,7 @@ * Description: Unused OoT Saria's Song Ocarina Effect */ +#include "prevent_bss_reordering.h" #include "z_oceff_wipe3.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000) diff --git a/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.c b/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.c index 6bde6902cc..a16821f000 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.c +++ b/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.c @@ -15,7 +15,6 @@ void OceffWipe6_Destroy(Actor* thisx, GlobalContext* globalCtx); void OceffWipe6_Update(Actor* thisx, GlobalContext* globalCtx); void OceffWipe6_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Oceff_Wipe6_InitVars = { ACTOR_OCEFF_WIPE6, ACTORCAT_ITEMACTION, @@ -28,12 +27,75 @@ const ActorInit Oceff_Wipe6_InitVars = { (ActorFunc)OceffWipe6_Draw, }; -#endif +#include "overlays/ovl_Oceff_Wipe6/ovl_Oceff_Wipe6.c" -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe6/OceffWipe6_Init.s") +void OceffWipe6_Init(Actor* thisx, GlobalContext* globalCtx) { + OceffWipe6* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe6/OceffWipe6_Destroy.s") + Actor_SetScale(&this->actor, 1.0f); + this->counter = 0; + this->actor.world.pos = GET_ACTIVE_CAM(globalCtx)->eye; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe6/OceffWipe6_Update.s") +void OceffWipe6_Destroy(Actor* thisx, GlobalContext* globalCtx) { + func_80115D5C(&globalCtx->state); + globalCtx->msgCtx.unk120B0 = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe6/OceffWipe6_Draw.s") +void OceffWipe6_Update(Actor* thisx, GlobalContext* globalCtx) { + OceffWipe6* this = THIS; + + this->actor.world.pos = GET_ACTIVE_CAM(globalCtx)->eye; + if (this->counter < 100) { + this->counter++; + } else { + Actor_MarkForDeath(&this->actor); + } +} + +void OceffWipe6_Draw(Actor* thisx, GlobalContext* globalCtx) { + OceffWipe6* this = THIS; + f32 z; + u8 alpha; + s32 i; + s32 counter; + Vec3f activeCamEye; + s32 pad; + Vec3f quakeOffset; + s32 pad2; + + activeCamEye = GET_ACTIVE_CAM(globalCtx)->eye; + Camera_GetQuakeOffset(&quakeOffset, GET_ACTIVE_CAM(globalCtx)); + + if (this->counter < 32) { + counter = this->counter; + z = Math_SinS(counter * 0x200) * 1220.0f; + } else { + z = 1220.0f; + } + + if (this->counter >= 80) { + alpha = 12 * (100 - this->counter); + } else { + alpha = 255; + } + + for (i = 1; i < ARRAY_COUNT(gOceff6Vtx); i += 2) { + gOceff6Vtx[i].v.cn[3] = alpha; + } + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + Matrix_InsertTranslation(activeCamEye.x + quakeOffset.x, activeCamEye.y + quakeOffset.y, + activeCamEye.z + quakeOffset.z, MTXMODE_NEW); + Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); + Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_InsertXRotation_s(0x708, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, 0.0f, -z, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + AnimatedMat_Draw(globalCtx, ovl_Oceff_Wipe6_Matanimheader_000338); + gSPDisplayList(POLY_XLU_DISP++, gOceff6DL); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.h b/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.h index 0b845e1337..c37e3f9d43 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.h +++ b/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.h @@ -7,7 +7,7 @@ struct OceffWipe6; typedef struct OceffWipe6 { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x4]; + /* 0x144 */ s16 counter; } OceffWipe6; // size = 0x148 extern const ActorInit Oceff_Wipe6_InitVars; diff --git a/src/overlays/effects/ovl_Effect_En_Ice_Block/z_eff_en_ice_block.c b/src/overlays/effects/ovl_Effect_En_Ice_Block/z_eff_en_ice_block.c index 62c56c04bc..29ac6b18bc 100644 --- a/src/overlays/effects/ovl_Effect_En_Ice_Block/z_eff_en_ice_block.c +++ b/src/overlays/effects/ovl_Effect_En_Ice_Block/z_eff_en_ice_block.c @@ -1,31 +1,85 @@ /* * File: z_eff_en_ice_block.c * Overlay: ovl_Effect_En_Ice_Block - * Description: + * Description: Ice Shard (Pentagon shaped) thrown off of the Obj_Iceblock actor during growth animation + * Object Requirement: OBJECT_ICE_BLOCK */ #include "z_eff_en_ice_block.h" +#include "objects/object_ice_block/object_ice_block.h" #define PARAMS ((EffectEnIceBlockInitParams*)initParamsx) -s32 EffectEnIceBlock_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); +u32 EffectEnIceBlock_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); void EffectEnIceBlock_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); void EffectEnIceBlock_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_En_Ice_Block_InitVars = { EFFECT_EN_ICE_BLOCK, EffectEnIceBlock_Init, }; -#endif +#define rObjId regs[0] +#define rScale regs[1] +#define rRot regs[2] +#define rRotVel regs[3] -extern UNK_TYPE D_06000A38; +u32 EffectEnIceBlock_CheckIceBlockObject(EffectSs* this, GlobalContext* globalCtx) { + if (((this->rObjId = Object_GetIndex(&globalCtx->objectCtx, OBJECT_ICE_BLOCK)) < 0) || + (!Object_IsLoaded(&globalCtx->objectCtx, this->rObjId))) { + this->life = -1; + this->draw = NULL; + return false; + } else { + return true; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_En_Ice_Block/func_80A22D40.s") +u32 EffectEnIceBlock_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { + EffectEnIceBlockInitParams* params = PARAMS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_En_Ice_Block/EffectEnIceBlock_Init.s") + Math_Vec3f_Copy(&this->pos, ¶ms->pos); + Math_Vec3f_Copy(&this->velocity, ¶ms->velocity); + Math_Vec3f_Copy(&this->accel, ¶ms->accel); + this->rScale = params->scale; + this->rRot = Rand_ZeroOne() * 65535.0f; + this->rRotVel = (s32)(Rand_ZeroOne() * 512.0f) + 0x400; + this->life = 40; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_En_Ice_Block/EffectEnIceBlock_Draw.s") + this->draw = EffectEnIceBlock_Draw; + this->update = EffectEnIceBlock_Update; + EffectEnIceBlock_CheckIceBlockObject(this, globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_En_Ice_Block/EffectEnIceBlock_Update.s") + return 1; +} + +void EffectEnIceBlock_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { + s32 pad; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + + if (EffectEnIceBlock_CheckIceBlockObject(this, globalCtx)) { + f32 scale = this->rScale * 0.1f * 0.01f; + + OPEN_DISPS(gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x06, + globalCtx->objectCtx.status[this->rObjId].segment); // object: OBJECT_ICE_BLOCK + + func_8012C2DC(globalCtx->state.gfxCtx); + Matrix_InsertTranslation(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->rRot, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_XLU_DISP++, &gIceBlockShardEffectDL); + + CLOSE_DISPS(gfxCtx); + } +} + +void EffectEnIceBlock_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { + this->rRot += this->rRotVel; + EffectEnIceBlock_CheckIceBlockObject(this, globalCtx); +} diff --git a/src/overlays/effects/ovl_Effect_Ss_Bubble/z_eff_ss_bubble.c b/src/overlays/effects/ovl_Effect_Ss_Bubble/z_eff_ss_bubble.c index d18f57bb7c..41a8f92ff3 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Bubble/z_eff_ss_bubble.c +++ b/src/overlays/effects/ovl_Effect_Ss_Bubble/z_eff_ss_bubble.c @@ -5,23 +5,103 @@ */ #include "z_eff_ss_bubble.h" +#include "objects/gameplay_keep/gameplay_keep.h" + +#define rScale regs[0] +#define rVecAdjX regs[1] +#define rVecAdjZ regs[2] #define PARAMS ((EffectSsBubbleInitParams*)initParamsx) -s32 EffectSsBubble_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); +u32 EffectSsBubble_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); void EffectSsBubble_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); void EffectSsBubble_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_Ss_Bubble_InitVars = { EFFECT_SS_BUBBLE, EffectSsBubble_Init, }; -#endif +static f32 sVecAdjMaximums[] = { 291.0f, 582.0f, 1600.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Bubble/EffectSsBubble_Init.s") +u32 EffectSsBubble_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { + EffectSsBubbleInitParams* initParams = (EffectSsBubbleInitParams*)initParamsx; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Bubble/EffectSsBubble_Draw.s") + { + TexturePtr tex = (Rand_ZeroOne() < 0.5f) ? gEffBubble1Tex : gEffBubble2Tex; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Bubble/EffectSsBubble_Update.s") + this->gfx = VIRTUAL_TO_PHYSICAL(SEGMENTED_TO_VIRTUAL(tex)); + } + + this->pos.x = ((Rand_ZeroOne() - 0.5f) * initParams->xzPosRandScale) + initParams->pos.x; + this->pos.y = (((Rand_ZeroOne() - 0.5f) * initParams->yPosRandScale) + initParams->yPosOffset) + initParams->pos.y; + this->pos.z = ((Rand_ZeroOne() - 0.5f) * initParams->xzPosRandScale) + initParams->pos.z; + Math_Vec3f_Copy(&this->vec, &this->pos); + this->life = 1; + this->rScale = (((Rand_ZeroOne() * 0.5f) + 1.0f) * initParams->scale) * 100.0f; + this->draw = EffectSsBubble_Draw; + this->update = EffectSsBubble_Update; + + return 1; +} + +void EffectSsBubble_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + f32 scale = this->rScale / 100.0f; + + OPEN_DISPS(gfxCtx); + + Matrix_InsertTranslation(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C28C(gfxCtx); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); + gDPSetEnvColor(POLY_OPA_DISP++, 150, 150, 150, 0); + gSPSegment(POLY_OPA_DISP++, 0x08, this->gfx); + gSPDisplayList(POLY_OPA_DISP++, gEffBubbleDL); + + CLOSE_DISPS(gfxCtx); +} + +void EffectSsBubble_Update(GlobalContext* globalCtx2, u32 index, EffectSs* this) { + WaterBox* waterBox; + f32 waterSurfaceY = this->pos.y; + Vec3f ripplePos; + GlobalContext* globalCtx = globalCtx2; + + if (!WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->pos.x, this->pos.z, &waterSurfaceY, &waterBox)) { + this->life = -1; + return; + } + if (waterSurfaceY < this->pos.y) { + ripplePos.x = this->pos.x; + ripplePos.y = waterSurfaceY; + ripplePos.z = this->pos.z; + EffectSsGRipple_Spawn(globalCtx, &ripplePos, 0, 80, 0); + this->life = -1; + label: + return; + } + if (((globalCtx->gameplayFrames + index) % 8) == 0) { + CollisionPoly* colPoly; + u32 speed; + s16 direction; + f32 rVecAdjMax; + + BgCheck_EntityRaycastFloor2_1(globalCtx, &globalCtx->colCtx, &colPoly, &this->pos); + speed = SurfaceType_GetConveyorSpeed(&globalCtx->colCtx, colPoly, BGCHECK_SCENE); + if ((speed != 0) && !SurfaceType_GetConveyorType(&globalCtx->colCtx, colPoly, BGCHECK_SCENE)) { + direction = SurfaceType_GetConveyorDirection(&globalCtx->colCtx, colPoly, BGCHECK_SCENE) << 0xA; + rVecAdjMax = sVecAdjMaximums[speed - 1]; + this->rVecAdjX = Math_SinS(direction) * rVecAdjMax; + this->rVecAdjZ = Math_CosS(direction) * rVecAdjMax; + } + } + this->vec.x += this->rVecAdjX / 100.0f; + this->vec.z += this->rVecAdjZ / 100.0f; + this->pos.x = ((Rand_ZeroOne() * 0.5f) - 0.25f) + this->vec.x; + this->accel.y = (Rand_ZeroOne() - 0.3f) * 0.2f; + this->pos.z = (Rand_ZeroOne() * 0.5f - 0.25f) + this->vec.z; + this->life++; +} diff --git a/src/overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.c b/src/overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.c index fe070b28de..d2ea02f7ce 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.c +++ b/src/overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.c @@ -6,43 +6,59 @@ #include "z_eff_ss_kakera.h" +#define rReg0 regs[0] +#define rGravity regs[1] +#define rPitch regs[2] +#define rYaw regs[3] +#define rReg4 regs[4] +#define rReg5 regs[5] +#define rReg6 regs[6] +#define rScale regs[7] +#define rReg8 regs[8] +#define rReg9 regs[9] +#define rObjId regs[10] +#define rObjBankIndex regs[11] +#define rColorIndex regs[12] + #define PARAMS ((EffectSsKakeraInitParams*)initParamsx) u32 EffectSsKakera_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); void EffectSsKakera_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); void EffectSsKakera_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -void func_8097E130(EffectSs* this, GlobalContext* globalCtx); +void EffectSsKakera_CheckForObject(EffectSs* this, GlobalContext* globalCtx); const EffectSsInit Effect_Ss_Kakera_InitVars = { EFFECT_SS_KAKERA, EffectSsKakera_Init, }; + KakeraColorStruct D_8097EAD8[] = { { 0, { 255, 255, 255 } }, { 0, { 235, 170, 130 } }, { 1, { 210, 190, 170 } }, }; + f32 D_8097EAE4[] = { 1.0f, 100.0f, 40.0f, 5.0f, 100.0f, 40.0f, 5.0f, 100.0f, 40.0f, 5.0f }; u32 EffectSsKakera_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { - EffectSsKakeraInitParams* params = PARAMS; + EffectSsKakeraInitParams* initParams = PARAMS; - this->pos = params->pos; - this->velocity = params->velocity; - this->life = params->life; + this->pos = initParams->pos; + this->velocity = initParams->velocity; + this->life = initParams->life; this->priority = 101; - if (params->dList != NULL) { - this->gfx = params->dList; - switch (params->objId) { + if (initParams->dList != NULL) { + this->gfx = initParams->dList; + switch (initParams->objId) { case GAMEPLAY_KEEP: case GAMEPLAY_FIELD_KEEP: case GAMEPLAY_DANGEON_KEEP: - this->regs[10] = KAKERA_OBJECT_DEFAULT; + this->rObjId = KAKERA_OBJECT_DEFAULT; break; default: - this->regs[10] = params->objId; - func_8097E130(this, globalCtx); + this->rObjId = initParams->objId; + EffectSsKakera_CheckForObject(this, globalCtx); break; } } else { @@ -50,18 +66,18 @@ u32 EffectSsKakera_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, voi } this->draw = EffectSsKakera_Draw; this->update = EffectSsKakera_Update; - this->vec = params->unk_18; - this->regs[0] = params->unk_2C; - this->regs[1] = params->gravity; - this->regs[2] = Rand_ZeroOne() * 0x8000; - this->regs[3] = Rand_ZeroOne() * 0x8000; - this->regs[4] = params->unk_26; - this->regs[5] = params->unk_28; - this->regs[6] = params->unk_2A; - this->regs[7] = params->scale; - this->regs[8] = params->unk_30; - this->regs[9] = params->unk_32; - this->regs[12] = params->colorIdx; + this->vec = initParams->unk_18; + this->rReg0 = initParams->unk_2C; + this->rGravity = initParams->gravity; + this->rPitch = Rand_ZeroOne() * 0x8000; + this->rYaw = Rand_ZeroOne() * 0x8000; + this->rReg4 = initParams->unk_26; + this->rReg5 = initParams->unk_28; + this->rReg6 = initParams->unk_2A; + this->rScale = initParams->scale; + this->rReg8 = initParams->unk_30; + this->rReg9 = initParams->unk_32; + this->rColorIndex = initParams->colorIdx; return 1; } @@ -72,24 +88,24 @@ f32 func_8097DE30(f32 center, f32 range) { void EffectSsKakera_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; s16 pad; - f32 scale = this->regs[7] / 256.0f; - s32 colorIndex = this->regs[12]; + f32 scale = this->rScale / 256.0f; + s32 colorIndex = this->rColorIndex; OPEN_DISPS(gfxCtx); - if (this->regs[10] != KAKERA_OBJECT_DEFAULT) { - if ((((this->regs[4] >> 7) & 1) << 7) == 0x80) { - gSPSegment(POLY_XLU_DISP++, 0x06, globalCtx->objectCtx.status[this->regs[11]].segment); + if (this->rObjId != KAKERA_OBJECT_DEFAULT) { + if ((((this->rReg4 >> 7) & 1) << 7) == 0x80) { + gSPSegment(POLY_XLU_DISP++, 0x06, globalCtx->objectCtx.status[this->rObjBankIndex].segment); } else { - gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[this->regs[11]].segment); + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[this->rObjBankIndex].segment); } } Matrix_InsertTranslation(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); - Matrix_RotateY(this->regs[3], MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->regs[2], MTXMODE_APPLY); + Matrix_RotateY(this->rYaw, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->rPitch, MTXMODE_APPLY); Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); - if ((((this->regs[4] >> 7) & 1) << 7) == 0x80) { + if ((((this->rReg4 >> 7) & 1) << 7) == 0x80) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); func_8012C2DC(globalCtx->state.gfxCtx); if (colorIndex >= 0) { @@ -109,9 +125,9 @@ void EffectSsKakera_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { CLOSE_DISPS(gfxCtx); } -void func_8097E130(EffectSs* this, GlobalContext* globalCtx) { - this->regs[11] = Object_GetIndex(&globalCtx->objectCtx, this->regs[10]); - if ((this->regs[11] < 0) || (!Object_IsLoaded(&globalCtx->objectCtx, this->regs[11]))) { +void EffectSsKakera_CheckForObject(EffectSs* this, GlobalContext* globalCtx) { + this->rObjBankIndex = Object_GetIndex(&globalCtx->objectCtx, this->rObjId); + if ((this->rObjBankIndex < 0) || (!Object_IsLoaded(&globalCtx->objectCtx, this->rObjBankIndex))) { this->life = 0; this->draw = NULL; } @@ -127,9 +143,9 @@ void func_8097E19C(EffectSs* this) { f32 temp_f20; f32 temp_f2_2; - temp_f18 = this->regs[5] / 1024.0f; - temp_f20 = this->regs[6] / 1024.0f; - range = (this->regs[9] / 1024.0f) * 4.0f; + temp_f18 = this->rReg5 / 1024.0f; + temp_f20 = this->rReg6 / 1024.0f; + range = (this->rReg9 / 1024.0f) * 4.0f; temp_f2 = this->velocity.x - func_8097DE30(0.0f, range); temp_f16 = this->velocity.y - func_8097DE30(0.0f, range); temp_f12 = this->velocity.z - func_8097DE30(0.0f, range); @@ -187,7 +203,7 @@ f32 func_8097E400(f32 arg0, s32 index) { s32 func_8097E420(EffectSs* this, Vec3f* diff, f32 distance) { static f32 D_8097EB0C[] = { 0.05f, 1.0f }; f32 phi_f0; - s32 index = this->regs[0] & 3; + s32 index = this->rReg0 & 3; if (index != 0) { if (distance > 1.0f) { @@ -198,23 +214,23 @@ s32 func_8097E420(EffectSs* this, Vec3f* diff, f32 distance) { this->accel.x += D_8097EB0C[index - 1] * diff->z * phi_f0; this->accel.z -= D_8097EB0C[index - 1] * diff->x * phi_f0; } - return 1; + return true; } s32 func_8097E4B0(EffectSs* this, Vec3f* diff, f32 distance) { static f32 D_8097EB14[] = { 4.0f, 0.1f, 0.3f, 0.9f, -0.1f, -0.3f, -0.9f }; - s32 index = (this->regs[0] >> 2) & 7; + s32 index = (this->rReg0 >> 2) & 7; if (index != 0) { this->accel.y += D_8097EB14[index]; } - return 1; + return true; } s32 func_8097E4F0(EffectSs* this, Vec3f* diff, f32 distance) { static f32 D_8097EB30[] = { 0.1f, 1.0f, 6.0f }; f32 phi_f0; - s32 index = (this->regs[0] >> 5) & 3; + s32 index = (this->rReg0 >> 5) & 3; if (index != 0) { if (distance > 1.0f) { @@ -225,32 +241,33 @@ s32 func_8097E4F0(EffectSs* this, Vec3f* diff, f32 distance) { this->accel.x -= diff->x * D_8097EB30[index - 1] * phi_f0; this->accel.z -= diff->z * D_8097EB30[index - 1] * phi_f0; } - return 1; + return true; } s32 func_8097E584(EffectSs* this, Vec3f* diff, f32 distance) { - static f32 (*D_8097EB3C[])(f32, - s32) = { func_8097E368, func_8097E384, func_8097E384, func_8097E384, func_8097E3C0, - func_8097E3C0, func_8097E3C0, func_8097E400, func_8097E400, func_8097E400 }; + static f32 (*D_8097EB3C[])(f32, s32) = { + func_8097E368, func_8097E384, func_8097E384, func_8097E384, func_8097E3C0, + func_8097E3C0, func_8097E3C0, func_8097E400, func_8097E400, func_8097E400, + }; f32 center; f32 rand; s32 index; - index = (this->regs[0] >> 7) & 0xF; + index = (this->rReg0 >> 7) & 0xF; center = D_8097EB3C[index](distance, index); - rand = func_8097DE30(center, (this->regs[9] * center) / 1024.0f); + rand = func_8097DE30(center, (this->rReg9 * center) / 1024.0f); this->accel.x *= rand; this->accel.y *= rand; this->accel.z *= rand; this->accel.x += rand * 0.01f; this->accel.y += rand * 0.01f; this->accel.z += rand * 0.01f; - return 1; + return true; } s32 func_8097E660(EffectSs* this, Vec3f* diff, f32 distance) { - this->accel.y += this->regs[1] / 256.0f; - return 1; + this->accel.y += this->rGravity / 256.0f; + return true; } s32 func_8097E698(EffectSs* this) { @@ -265,21 +282,21 @@ s32 func_8097E698(EffectSs* this) { if (distance > 1000.0f) { return false; } - if (this->regs[0] != 0) { - if (func_8097E420(this, &diff, distance) == 0) { + if (this->rReg0 != 0) { + if (!func_8097E420(this, &diff, distance)) { return false; } - if (func_8097E4B0(this, &diff, distance) == 0) { + if (!func_8097E4B0(this, &diff, distance)) { return false; } - if (func_8097E4F0(this, &diff, distance) == 0) { + if (!func_8097E4F0(this, &diff, distance)) { return false; } - if (func_8097E584(this, &diff, distance) == 0) { + if (!func_8097E584(this, &diff, distance)) { return false; } } - if (func_8097E660(this, &diff, distance) == 0) { + if (!func_8097E660(this, &diff, distance)) { return false; } else { return true; @@ -290,41 +307,41 @@ void func_8097E7E0(EffectSs* this, GlobalContext* globalCtx) { static f32 D_8097EB64[] = { 10.0f, 20.0f, 40.0f }; Player* player = GET_PLAYER(globalCtx); - if (this->regs[8] == 0) { - if ((((this->regs[4] >> 4) & 1) << 4) == (1 << 4)) { - if (this->pos.y <= (player->actor.floorHeight - ((this->regs[4] >> 2) & 3))) { - this->regs[9] = 0; - this->regs[0] = 0; - this->regs[4] &= ~0x60; + if (this->rReg8 == 0) { + if ((((this->rReg4 >> 4) & 1) << 4) == (1 << 4)) { + if (this->pos.y <= (player->actor.floorHeight - ((this->rReg4 >> 2) & 3))) { + this->rReg9 = 0; + this->rReg0 = 0; + this->rReg4 &= ~0x60; this->accel.x = this->accel.y = this->accel.z = 0.0f; this->velocity.x = this->velocity.y = this->velocity.z = 0.0f; - this->regs[5] = this->regs[9]; - this->regs[1] = this->regs[9]; + this->rReg5 = this->rReg9; + this->rGravity = this->rReg9; } } else { - if (this->pos.y <= ((player->actor.floorHeight - ((this->regs[4] >> 2) & 3)) - 600.0f)) { + if (this->pos.y <= ((player->actor.floorHeight - ((this->rReg4 >> 2) & 3)) - 600.0f)) { this->life = 0; } } } else { - switch (this->regs[4] & 3) { + switch (this->rReg4 & 3) { case 0: - this->regs[8] = 0; + this->rReg8 = 0; break; case 1: if ((this->velocity.y < 0.0f) && - (BgCheck_SphVsFirstPoly(&globalCtx->colCtx, &this->pos, D_8097EB64[(this->regs[4] >> 2) & 3]))) { + (BgCheck_SphVsFirstPoly(&globalCtx->colCtx, &this->pos, D_8097EB64[(this->rReg4 >> 2) & 3]))) { this->velocity.x *= func_8097DE30(0.9f, 0.2f); this->velocity.y *= -0.8f; this->velocity.z *= func_8097DE30(0.9f, 0.2f); - if (this->regs[8] > 0) { - this->regs[8]--; + if (this->rReg8 > 0) { + this->rReg8--; } } break; case 2: - if (BgCheck_SphVsFirstPoly(&globalCtx->colCtx, &this->pos, D_8097EB64[(this->regs[4] >> 2) & 3])) { - this->regs[8] = 0; + if (BgCheck_SphVsFirstPoly(&globalCtx->colCtx, &this->pos, D_8097EB64[(this->rReg4 >> 2) & 3])) { + this->rReg8 = 0; } break; } @@ -332,18 +349,18 @@ void func_8097E7E0(EffectSs* this, GlobalContext* globalCtx) { } void EffectSsKakera_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { - switch (((this->regs[4] >> 5) & 3) << 5) { + switch (((this->rReg4 >> 5) & 3) << 5) { case 0x20: - this->regs[2] += 0x47B; - this->regs[3] += 0x139; + this->rPitch += 0x47B; + this->rYaw += 0x139; break; case 0x40: - this->regs[2] += 0x1A7C; - this->regs[3] += 0x47B; + this->rPitch += 0x1A7C; + this->rYaw += 0x47B; break; case 0x60: - this->regs[2] += 0x3F27; - this->regs[3] += 0xCA1; + this->rPitch += 0x3F27; + this->rYaw += 0xCA1; break; } func_8097E19C(this); @@ -351,7 +368,7 @@ void EffectSsKakera_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) this->life = 0; } func_8097E7E0(this, globalCtx); - if (this->regs[10] != KAKERA_OBJECT_DEFAULT) { - func_8097E130(this, globalCtx); + if (this->rObjId != KAKERA_OBJECT_DEFAULT) { + EffectSsKakera_CheckForObject(this, globalCtx); } } diff --git a/src/overlays/effects/ovl_Effect_Ss_Sbn/z_eff_ss_sbn.c b/src/overlays/effects/ovl_Effect_Ss_Sbn/z_eff_ss_sbn.c index b09dca0142..26901bac56 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Sbn/z_eff_ss_sbn.c +++ b/src/overlays/effects/ovl_Effect_Ss_Sbn/z_eff_ss_sbn.c @@ -1,30 +1,208 @@ /* * File: z_eff_ss_sbn.c * Overlay: ovl_Effect_Ss_Sbn - * Description: + * Description: Popped Deku Bubble + * + * Note: The gfx field is used to store the colPoly, not anything gfx related + * This is not a problem since gfx is already void* */ #include "z_eff_ss_sbn.h" +#include "objects/gameplay_keep/gameplay_keep.h" + +#define rScrollStep regs[0] +#define rScroll regs[1] +#define rTexIndex regs[2] +#define rAlpha regs[3] +#define rReg4 regs[4] +#define rReg4Step regs[5] +#define rRotAngle regs[6] +#define rScale regs[7] +#define rReg8 regs[8] #define PARAMS ((EffectSsSbnInitParams*)initParamsx) -s32 EffectSsSbn_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); +u32 EffectSsSbn_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); void EffectSsSbn_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); -void func_80AC8ECC(GlobalContext* globalCtx, u32 index, EffectSs* this); -void func_80AC9164(GlobalContext* globalCtx, u32 index, EffectSs* this); +void EffectSsSbn_DrawSliding(GlobalContext* globalCtx, u32 index, EffectSs* this); +void EffectSsSbn_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_Ss_Sbn_InitVars = { EFFECT_SS_SBN, EffectSsSbn_Init, }; -#endif +static TexturePtr sSlidingTextures[] = { + gEffPoppedDekuBubbleSliding1Tex, gEffPoppedDekuBubbleSliding2Tex, gEffPoppedDekuBubbleSliding3Tex, + gEffPoppedDekuBubbleSliding4Tex, gEffPoppedDekuBubbleSliding5Tex, gEffPoppedDekuBubbleSliding6Tex, + gEffPoppedDekuBubbleSliding7Tex, gEffPoppedDekuBubbleSliding8Tex, gEffPoppedDekuBubbleSliding9Tex, + gEffPoppedDekuBubbleSliding10Tex, gEffPoppedDekuBubbleSliding11Tex, gEffPoppedDekuBubbleSliding12Tex, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Sbn/EffectSsSbn_Init.s") +static TexturePtr sTextures[] = { + gEffPoppedDekuBubble1Tex, gEffPoppedDekuBubble2Tex, gEffPoppedDekuBubble3Tex, + gEffPoppedDekuBubble4Tex, gEffPoppedDekuBubble5Tex, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Sbn/func_80AC8ECC.s") +u32 EffectSsSbn_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { + EffectSsSbnInitParams* initParams = PARAMS; + CollisionPoly* colPoly; + MtxF mtx; + Vec3f normal; + Vec3f colPolyVec; + Vec3f bubbleVec; + f32 angle; + f32 opposite; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Sbn/func_80AC9164.s") + Math_Vec3f_Copy(&this->pos, &initParams->pos); + Math_Vec3f_Copy(&this->velocity, &gZeroVec3f); + Math_Vec3f_Copy(&this->accel, &gZeroVec3f); + this->flags = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Sbn/EffectSsSbn_Update.s") + this->gfx = initParams->colPoly; + + this->rScroll = 0; + this->rScrollStep = 7; + this->rTexIndex = 0; + this->rAlpha = 200; + this->rReg4 = 250; + this->rReg4Step = 30; + + this->rScale = randPlusMinusPoint5Scaled(100.0f) + (initParams->scale * 120.0f); + if (this->rScale < 600) { + this->rScale = 600; + } else if (this->rScale > 1500) { + this->rScale = 1500; + } + + this->rReg8 = 1000; + this->rRotAngle = 0; + this->life = 93; + this->draw = EffectSsSbn_DrawSliding; + this->update = EffectSsSbn_Update; + + if (this->gfx != NULL) { + colPoly = this->gfx; + func_800C0094(colPoly, this->pos.x, this->pos.y, this->pos.z, &mtx); + normal.x = COLPOLY_GET_NORMAL(colPoly->normal.x); + normal.y = COLPOLY_GET_NORMAL(colPoly->normal.y); + normal.z = COLPOLY_GET_NORMAL(colPoly->normal.z); + if ((normal.y > 0.95f) || (normal.y < -0.95f)) { + this->draw = EffectSsSbn_Draw; + return 1; + } + if (normal.y > 0.05f) { + colPolyVec.x = normal.x * 10.0f; + colPolyVec.y = (-(SQ(normal.x) + SQ(normal.z)) * 10.0f) / normal.y; + colPolyVec.z = normal.z * 10.0f; + } else if (normal.y < -0.05f) { + colPolyVec.x = -normal.x * 10.0f; + colPolyVec.y = (-(SQ(normal.x) + SQ(normal.z)) * 10.0f) / -normal.y; + colPolyVec.z = -normal.z * 10.0f; + } else { + colPolyVec.x = 0.0f; + colPolyVec.y = -10.0f; + colPolyVec.z = 0.0f; + } + bubbleVec.x = -mtx.mf[2][0] * 10.0f; + bubbleVec.y = -mtx.mf[2][1] * 10.0f; + bubbleVec.z = -mtx.mf[2][2] * 10.0f; + Math3D_AngleBetweenVectors(&colPolyVec, &bubbleVec, &angle); + + opposite = (SQ(angle) >= 1.0f) ? 0.0f : sqrtf(1.0f - SQ(angle)); + if (((mtx.mf[0][0] * colPolyVec.x) + (mtx.mf[0][1] * colPolyVec.y) + (mtx.mf[0][2] * colPolyVec.z)) < 0.0f) { + this->rRotAngle = Math_FAtan2F(angle, opposite); + } else { + this->rRotAngle = -Math_FAtan2F(angle, opposite); + } + } + + return 1; +} + +void EffectSsSbn_DrawSliding(GlobalContext* globalCtx, u32 index, EffectSs* this) { + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + MtxF mtx; + f32 scale = this->rScale * 0.001f; + s32 pad; + + func_800C0094(this->gfx, this->pos.x, this->pos.y, this->pos.z, &mtx); + SkinMatrix_MulYRotation(&mtx, this->rRotAngle); + Matrix_InsertMatrix(&mtx, MTXMODE_NEW); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + Matrix_Scale(0.05f, 0.05f, 0.05f, MTXMODE_APPLY); + + OPEN_DISPS(gfxCtx); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C2DC(gfxCtx); + gDPSetRenderMode(POLY_XLU_DISP++, G_RM_FOG_SHADE_A, G_RM_ZB_XLU_DECAL2); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, this->rAlpha); + + if (this->rTexIndex < ARRAY_COUNT(sSlidingTextures)) { + { + TexturePtr tex = sSlidingTextures[this->rTexIndex]; + + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(tex)); + } + this->rTexIndex++; + this->rScroll += this->rScrollStep; + } else { + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gEffPoppedDekuBubbleSliding12Tex)); + if ((this->rScrollStep >= 2) && ((globalCtx->state.frames % 2) == 0)) { + this->rScrollStep--; + } + this->rScroll += this->rScrollStep; + } + gSPSegment(POLY_XLU_DISP++, 0x09, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, this->rScroll, 0x20, 0x20)); + gSPDisplayList(POLY_XLU_DISP++, gEffPoppedDekuBubbleSlidingDL); + + CLOSE_DISPS(gfxCtx); +} + +void EffectSsSbn_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + MtxF mtx; + f32 scale = this->rScale * 0.001f; + + func_800C0094(this->gfx, this->pos.x, this->pos.y, this->pos.z, &mtx); + SkinMatrix_MulYRotation(&mtx, this->rRotAngle); + Matrix_InsertMatrix(&mtx, MTXMODE_NEW); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + Matrix_Scale(0.05f, 0.05f, 0.05f, MTXMODE_APPLY); + + OPEN_DISPS(gfxCtx); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C2DC(gfxCtx); + gDPSetRenderMode(POLY_XLU_DISP++, G_RM_FOG_SHADE_A, G_RM_ZB_XLU_DECAL2); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, this->rAlpha); + + if (this->rTexIndex < ARRAY_COUNT(sTextures)) { + { + TexturePtr tex = sTextures[this->rTexIndex]; + + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(tex)); + } + this->rTexIndex++; + } else { + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gEffPoppedDekuBubble5Tex)); + } + gSPDisplayList(POLY_XLU_DISP++, gEffPoppedDekuBubbleDL); + + CLOSE_DISPS(gfxCtx); +} + +void EffectSsSbn_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { + if (this->life < 10) { + this->rAlpha -= 20; + } else if (this->life >= 45) { + if (this->life < 85) { + this->rReg8 += 12; + this->rReg4 -= this->rReg4Step; + } else { + this->rReg8 = 1000; + } + } +} diff --git a/src/overlays/effects/ovl_Effect_Ss_Sbn/z_eff_ss_sbn.h b/src/overlays/effects/ovl_Effect_Ss_Sbn/z_eff_ss_sbn.h index ba2355d232..439ef88a01 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Sbn/z_eff_ss_sbn.h +++ b/src/overlays/effects/ovl_Effect_Ss_Sbn/z_eff_ss_sbn.h @@ -4,11 +4,10 @@ #include "global.h" typedef struct { - /* 0x00 */ Vec3f unk_00; - /* 0x0C */ CollisionPoly* unk_0C; - /* 0x10 */ f32 unk_10; - /* 0x14 */ char unk_14[UNK_SIZE]; -} EffectSsSbnInitParams; // size = ? + /* 0x00 */ Vec3f pos; + /* 0x0C */ CollisionPoly* colPoly; + /* 0x10 */ f32 scale; +} EffectSsSbnInitParams; // size = 0x14 extern const EffectSsInit Effect_Ss_Sbn_InitVars; diff --git a/src/overlays/effects/ovl_Effect_Ss_Sibuki/z_eff_ss_sibuki.c b/src/overlays/effects/ovl_Effect_Ss_Sibuki/z_eff_ss_sibuki.c index 6d2d4c6dd9..d4356f90cf 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Sibuki/z_eff_ss_sibuki.c +++ b/src/overlays/effects/ovl_Effect_Ss_Sibuki/z_eff_ss_sibuki.c @@ -5,23 +5,117 @@ */ #include "z_eff_ss_sibuki.h" +#include "objects/gameplay_keep/gameplay_keep.h" + +#define rPrimColorR regs[0] +#define rPrimColorG regs[1] +#define rPrimColorB regs[2] +#define rPrimColorA regs[3] +#define rEnvColorR regs[4] +#define rEnvColorG regs[5] +#define rEnvColorB regs[6] +#define rEnvColorA regs[7] +#define rMoveDelay regs[8] +#define rDirection regs[9] +#define rScale regs[10] #define PARAMS ((EffectSsSibukiInitParams*)initParamsx) -s32 EffectSsSibuki_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); +u32 EffectSsSibuki_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); void EffectSsSibuki_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); void EffectSsSibuki_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_Ss_Sibuki_InitVars = { EFFECT_SS_SIBUKI, EffectSsSibuki_Init, }; -#endif +u32 EffectSsSibuki_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { + EffectSsSibukiInitParams* initParams = PARAMS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Sibuki/EffectSsSibuki_Init.s") + this->pos = initParams->pos; + this->velocity = initParams->velocity; + this->accel = initParams->accel; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Sibuki/EffectSsSibuki_Draw.s") + { + TexturePtr tex = (KREG(2) != 0) ? gEffBubble2Tex : gEffBubble1Tex; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Sibuki/EffectSsSibuki_Update.s") + this->gfx = VIRTUAL_TO_PHYSICAL(SEGMENTED_TO_VIRTUAL(tex)); + } + + this->life = ((s32)((Rand_ZeroOne() * (500.0f + KREG(64))) * 0.01f)) + KREG(65) + 10; + this->rMoveDelay = initParams->moveDelay + 1; + this->draw = EffectSsSibuki_Draw; + this->update = EffectSsSibuki_Update; + this->rDirection = initParams->direction; + this->rScale = initParams->scale; + this->rPrimColorR = 100; + this->rPrimColorG = 100; + this->rPrimColorB = 100; + this->rPrimColorA = 100; + this->rEnvColorR = 255; + this->rEnvColorG = 255; + this->rEnvColorB = 255; + this->rEnvColorA = 255; + + return 1; +} + +void EffectSsSibuki_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + f32 scale = this->rScale / 100.0f; + + OPEN_DISPS(gfxCtx); + + Matrix_InsertTranslation(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C28C(gfxCtx); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, this->rPrimColorR, this->rPrimColorG, this->rPrimColorB, this->rPrimColorA); + gDPSetEnvColor(POLY_OPA_DISP++, this->rEnvColorR, this->rEnvColorG, this->rEnvColorB, this->rEnvColorA); + gSPSegment(POLY_OPA_DISP++, 0x08, this->gfx); + gSPDisplayList(POLY_OPA_DISP++, gEffBubbleDL); + + CLOSE_DISPS(gfxCtx); +} + +void EffectSsSibuki_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { + Player* player = GET_PLAYER(globalCtx); + s32 pad[2]; + f32 xzVelScale; + + if (this->pos.y <= player->actor.floorHeight) { + this->life = 0; + } + + if (this->rMoveDelay != 0) { + this->rMoveDelay--; + + if (this->rMoveDelay == 0) { + s16 yaw = Camera_GetInputDirYaw(Play_GetCamera(globalCtx, CAM_ID_MAIN)); + + xzVelScale = ((200.0f + KREG(20)) * 0.01f) + ((0.1f * Rand_ZeroOne()) * (KREG(23) + 20.0f)); + + if (this->rDirection != 0) { + xzVelScale *= -1.0f; + } + + this->velocity.x = Math_CosS(yaw) * xzVelScale; + this->velocity.z = -Math_SinS(yaw) * xzVelScale; + + this->velocity.y = ((700.0f + KREG(21)) * 0.01f) + ((0.1f * Rand_ZeroOne()) * (KREG(24) + 20.0f)); + this->accel.y = ((-100.0f + KREG(22)) * 0.01f) + ((0.1f * Rand_ZeroOne()) * KREG(25)); + + if (KREG(3) != 0) { + this->velocity.x *= (KREG(3) * 0.01f); + this->velocity.y *= (KREG(3) * 0.01f); + this->velocity.z *= (KREG(3) * 0.01f); + this->accel.y *= (KREG(4) * 0.01f); + } + } + } else { + if (this->rScale != 0) { + this->rScale = (this->rScale - KREG(26)) - 3; + } + } +} diff --git a/src/overlays/effects/ovl_Effect_Ss_Stick/z_eff_ss_stick.c b/src/overlays/effects/ovl_Effect_Ss_Stick/z_eff_ss_stick.c index c490592625..d261357292 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Stick/z_eff_ss_stick.c +++ b/src/overlays/effects/ovl_Effect_Ss_Stick/z_eff_ss_stick.c @@ -7,6 +7,9 @@ #include "z_eff_ss_stick.h" #include "objects/gameplay_keep/gameplay_keep.h" +#define rObjBankIndex regs[0] +#define rYaw regs[1] + #define PARAMS ((EffectSsStickInitParams*)initParamsx) u32 EffectSsStick_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); @@ -19,16 +22,16 @@ const EffectSsInit Effect_Ss_Stick_InitVars = { }; u32 EffectSsStick_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { - EffectSsStickInitParams* params = PARAMS; + EffectSsStickInitParams* initParams = PARAMS; Vec3f pos; - this->regs[0] = Object_GetIndex(&globalCtx->objectCtx, GAMEPLAY_KEEP); - pos = params->pos; + this->rObjBankIndex = Object_GetIndex(&globalCtx->objectCtx, GAMEPLAY_KEEP); + pos = initParams->pos; this->pos = pos; this->vec = pos; - this->regs[1] = params->yaw; - this->velocity.x = Math_SinS(params->yaw) * 6.0f; - this->velocity.z = Math_CosS(params->yaw) * 6.0f; + this->rYaw = initParams->yaw; + this->velocity.x = Math_SinS(initParams->yaw) * 6.0f; + this->velocity.z = Math_CosS(initParams->yaw) * 6.0f; this->life = 20; this->draw = EffectSsStick_Draw; this->update = EffectSsStick_Update; @@ -42,14 +45,16 @@ void EffectSsStick_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; OPEN_DISPS(gfxCtx); + Matrix_InsertTranslation(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); Matrix_Scale(0.01f, 0.0025f, 0.01f, MTXMODE_APPLY); - Matrix_InsertRotation(0, this->regs[1], 0, MTXMODE_APPLY); + Matrix_InsertRotation(0, this->rYaw, 0, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); func_8012C28C(gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[this->regs[0]].segment); + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[this->rObjBankIndex].segment); gSPSegment(POLY_OPA_DISP++, 0x0C, D_801C0850); - gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_0032B0); + gSPDisplayList(POLY_OPA_DISP++, gDekuStickDL); + CLOSE_DISPS(gfxCtx); } diff --git a/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.c b/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.c index 714ce0b8ca..06cfa5b18d 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.c +++ b/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.c @@ -5,23 +5,78 @@ */ #include "z_eff_ss_stone1.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define PARAMS ((EffectSsStone1InitParams*)initParamsx) -s32 EffectSsStone1_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); +#define rReg0 regs[0] + +u32 EffectSsStone1_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); void EffectSsStone1_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); void EffectSsStone1_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_Ss_Stone1_InitVars = { EFFECT_SS_STONE1, EffectSsStone1_Init, }; -#endif +typedef struct { + /* 0x00 */ TexturePtr texture; + /* 0x04 */ Color_RGBA8 primColor; + /* 0x08 */ Color_RGBA8 envColor; +} EffStoneDrawInfo; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Stone1/EffectSsStone1_Init.s") +static EffStoneDrawInfo sDrawInfo[] = { + { gEffStone8Tex, { 200, 0, 0, 255 }, { 0, 0, 0, 255 } }, + { gEffStone7Tex, { 255, 100, 0, 255 }, { 100, 0, 0, 255 } }, + { gEffStone6Tex, { 255, 200, 0, 255 }, { 200, 0, 0, 255 } }, + { gEffStone5Tex, { 255, 255, 0, 255 }, { 255, 0, 0, 255 } }, + { gEffStone4Tex, { 255, 255, 150, 255 }, { 255, 150, 0, 255 } }, + { gEffStone3Tex, { 255, 255, 255, 255 }, { 255, 255, 0, 255 } }, + { gEffStone2Tex, { 255, 255, 255, 255 }, { 0, 255, 0, 255 } }, + { gEffStone1Tex, { 255, 255, 255, 255 }, { 0, 255, 255, 255 } }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Stone1/EffectSsStone1_Draw.s") +u32 EffectSsStone1_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { + EffectSsStone1InitParams* initParams = PARAMS; + Vec3f pos = initParams->pos; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Stone1/EffectSsStone1_Update.s") + this->pos = pos; + this->vec = pos; + this->life = 8; + this->rReg0 = initParams->reg0; + this->draw = EffectSsStone1_Draw; + this->update = EffectSsStone1_Update; + + return 1; +} + +void EffectSsStone1_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + EffStoneDrawInfo* drawParams = &sDrawInfo[this->life]; + Vec3f mfVec; + f32 mfW; + f32 scale; + + OPEN_DISPS(gfxCtx); + + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &this->pos, &mfVec, &mfW); + scale = (mfW < 1500.0f) ? 3.0f : (mfW / 1500.0f) * 3.0f; + Matrix_InsertTranslation(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C9BC(gfxCtx); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(drawParams->texture)); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, drawParams->primColor.r, drawParams->primColor.g, drawParams->primColor.b, + 255); + gDPSetEnvColor(POLY_XLU_DISP++, drawParams->envColor.r, drawParams->envColor.g, drawParams->envColor.b, 255); + gSPDisplayList(POLY_XLU_DISP++, gEffStoneDL); + + CLOSE_DISPS(gfxCtx); +} + +void EffectSsStone1_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { + if ((this->life == 6) && (this->rReg0 != 0)) { + iREG(50) = 0; + } +} diff --git a/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.h b/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.h index 566811a8a5..365585a8e7 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.h +++ b/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.h @@ -5,7 +5,7 @@ typedef struct { /* 0x00 */ Vec3f pos; - /* 0x00 */ s32 unk_C; + /* 0x0C */ s32 reg0; } EffectSsStone1InitParams; // size = 0x10 extern const EffectSsInit Effect_Ss_Stone1_InitVars; diff --git a/src/overlays/gamestates/ovl_daytelop/z_daytelop.c b/src/overlays/gamestates/ovl_daytelop/z_daytelop.c index 1637e19781..0ac471162d 100644 --- a/src/overlays/gamestates/ovl_daytelop/z_daytelop.c +++ b/src/overlays/gamestates/ovl_daytelop/z_daytelop.c @@ -70,11 +70,11 @@ void Daytelop_Update(DaytelopContext* this, GameState* gameState) { this->transitionCountdown--; if (this->transitionCountdown == 0) { - if (gSaveContext.day < 9) { + if (gSaveContext.save.day < 9) { gSaveContext.gameMode = 0; } else { gSaveContext.nextCutsceneIndex = 0xFFF6; - gSaveContext.day = 1; + gSaveContext.save.day = 1; } { @@ -83,7 +83,7 @@ void Daytelop_Update(DaytelopContext* this, GameState* gameState) { } SET_NEXT_GAMESTATE(&this->state, Play_Init, GlobalContext); - gSaveContext.time = CLOCK_TIME(6, 0); + gSaveContext.save.time = CLOCK_TIME(6, 0); D_801BDBC8 = 0xFE; } else if (this->transitionCountdown == 90) { this->fadeInState = DAYTELOP_HOURSTEXT_FADEIN; @@ -132,7 +132,7 @@ void Daytelop_Draw(DaytelopContext* this) { OPEN_DISPS(gfxCtx); func_8012C628(this->state.gfxCtx); - if (gSaveContext.day >= 9) { + if (gSaveContext.save.day >= 9) { // Draw a white screen gDPSetRenderMode(POLY_OPA_DISP++, G_RM_XLU_SURF, G_RM_XLU_SURF2); gDPSetCombineMode(POLY_OPA_DISP++, G_CC_PRIMITIVE, G_CC_PRIMITIVE); @@ -145,12 +145,12 @@ void Daytelop_Draw(DaytelopContext* this) { gDPSetRenderMode(POLY_OPA_DISP++, G_RM_OPA_SURF, G_RM_OPA_SURF2); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); - if (gSaveContext.day >= 9) { + if (gSaveContext.save.day >= 9) { gDPSetAlphaCompare(POLY_OPA_DISP++, G_AC_NONE); } // Draw the left side of the "Dawn of" texture - if (gSaveContext.day < 9) { + if (gSaveContext.save.day < 9) { gDPLoadTextureBlock_4b(POLY_OPA_DISP++, sDayLeftTextures[CURRENT_DAY - 1], G_IM_FMT_I, 128, 64, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); @@ -163,7 +163,7 @@ void Daytelop_Draw(DaytelopContext* this) { 0x0400, 0x0400); // Draw the right side of the "Dawn of" texture - if (gSaveContext.day < 9) { + if (gSaveContext.save.day < 9) { gDPLoadTextureBlock_4b(POLY_OPA_DISP++, sDayRightTextures[CURRENT_DAY - 1], G_IM_FMT_I, 128, 64, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); @@ -176,7 +176,7 @@ void Daytelop_Draw(DaytelopContext* this) { 0x0400, 0x0400); // Draw the "Hours left" texture - if (gSaveContext.day < 9) { + if (gSaveContext.save.day < 9) { gDPPipeSync(POLY_OPA_DISP++); gDPSetRenderMode(POLY_OPA_DISP++, G_RM_XLU_SURF, G_RM_XLU_SURF2); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, this->alpha); @@ -193,7 +193,7 @@ void Daytelop_Draw(DaytelopContext* this) { void Daytelop_Main(GameState* thisx) { DaytelopContext* this = (DaytelopContext*)thisx; - func_8012CF0C(this->state.gfxCtx, 1, 1, 0, 0, 0); + func_8012CF0C(this->state.gfxCtx, true, true, 0, 0, 0); OPEN_DISPS(this->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x09, this->daytelopStaticFile); @@ -234,9 +234,9 @@ void Daytelop_Init(GameState* thisx) { this->transitionCountdown = 140; this->fadeInState = DAYTELOP_HOURSTEXT_OFF; - if (gSaveContext.day < 9) { - if (gSaveContext.day == 0) { - func_80143AC4(); + if (gSaveContext.save.day < 9) { + if (gSaveContext.save.day == 0) { + Sram_ClearFlagsAtDawnOfTheFirstDay(); } Sram_IncrementDay(); } diff --git a/src/overlays/gamestates/ovl_file_choose/z_file_choose.h b/src/overlays/gamestates/ovl_file_choose/z_file_choose.h index d2e71587dd..78c4a9a624 100644 --- a/src/overlays/gamestates/ovl_file_choose/z_file_choose.h +++ b/src/overlays/gamestates/ovl_file_choose/z_file_choose.h @@ -1,12 +1,12 @@ -#ifndef _Z64_FILE_CHOOSE_H_ -#define _Z64_FILE_CHOOSE_H_ +#ifndef Z64_FILE_CHOOSE_H +#define Z64_FILE_CHOOSE_H #include "global.h" void FileChoose_Init(GameState* thisx); void FileChoose_Destroy(GameState* thisx); -typedef struct { +typedef struct FileChooseContext { /* 0x00000 */ GameState state; /* 0x000A4 */ Vtx* unk_A4; /* 0x000A8 */ u8* staticSegment; @@ -21,23 +21,35 @@ typedef struct { /* 0x242E0 */ EnvironmentContext envCtx; /* 0x243E0 */ Vtx* unk_243E0; /* 0x243E4 */ Vtx* unk_243E4; - /* 0x243E8 */ Vtx* unk_243E8; - /* 0x243EC */ Vtx* unk_243EC; - /* 0x243F0 */ Vtx* unk_243F0; - /* 0x243F4 */ u8 newf[6][4]; - /* 0x2440C */ u16 unk_2440C[4]; - /* 0x24414 */ u8 unk_24414[8][4]; - /* 0x24434 */ s16 healthCapacity[4]; - /* 0x2443C */ s16 health[4]; - /* 0x24444 */ u32 unk_24444[4]; - /* 0x24454 */ s8 unk_24454[4]; - /* 0x24458 */ u16 unk_24458[4]; - /* 0x24460 */ s16 unk_24460[4]; - /* 0x24468 */ u8 unk_24468[4]; - /* 0x2446C */ s16 rupees[4]; - /* 0x24474 */ u8 unk_24474[4]; - /* 0x24478 */ u8 unk_24478[4]; - /* 0x2447C */ u8 unk_2447C[4]; + /* 0x243E8 */ u8 newf2[2][6]; + /* 0x243F4 */ u8 newf[2][6]; + /* 0x24400 */ UNK_TYPE1 unk_24400[0xC]; + /* 0x2440C */ u16 unk_2440C[2]; + /* 0x24410 */ u16 unk_24410[2]; + /* 0x24414 */ u8 unk_24414[2][8]; // playername + /* 0x24424 */ u8 unk_24424[2][8]; // playername + /* 0x24434 */ s16 healthCapacity[2]; + /* 0x24438 */ u16 unk_24438[2]; + /* 0x2443C */ s16 health[2]; + /* 0x24440 */ u16 unk_24440[2]; + /* 0x24444 */ u32 unk_24444[2]; + /* 0x2444C */ u32 unk_2444C[2]; + /* 0x24454 */ s8 unk_24454[2]; + /* 0x24456 */ u8 unk_24456[2]; + /* 0x24458 */ u16 unk_24458[2]; + /* 0x2445C */ u16 unk_2445C[2]; + /* 0x24460 */ s16 unk_24460[2]; + /* 0x24464 */ s16 unk_24464[2]; + /* 0x24468 */ u8 unk_24468[2]; + /* 0x2446A */ u8 unk_2446A[2]; + /* 0x2446C */ s16 rupees[2]; + /* 0x24470 */ s16 unk_24470[2]; + /* 0x24474 */ s8 unk_24474[2]; + /* 0x24476 */ s8 unk_24476[2]; + /* 0x24478 */ s8 maskCount[2]; + /* 0x2447A */ s8 unk_2447A[2]; + /* 0x2447C */ s8 heartPieceCount[2]; + /* 0x2447E */ s8 unk_2447E[2]; /* 0x24480 */ s16 unk_24480; /* 0x24482 */ s16 unk_24482; /* 0x24484 */ s16 unk_24484; @@ -50,7 +62,7 @@ typedef struct { /* 0x24492 */ s16 unk_24492[3]; /* 0x24498 */ s16 unk_24498; /* 0x2449A */ s16 unk_2449A[6]; - /* 0x244A6 */ s16 unk_244A6; + /* 0x244A6 */ s16 fileNum; /* 0x244A8 */ s16 unk_244A8; /* 0x244AA */ s16 unk_244AA; /* 0x244AC */ s16 unk_244AC; @@ -101,4 +113,13 @@ typedef struct { /* 0x24550 */ s16 unk_24550; } FileChooseContext; // size = 0x24558 +// TODO: Confirm those values has the same meaning as their OoT counterparts +typedef enum { + /* 0x00 */ PAUSE_0, // PAUSE_ITEM + /* 0x01 */ PAUSE_1, // PAUSE_MAP + /* 0x02 */ PAUSE_2, // PAUSE_QUEST + /* 0x03 */ PAUSE_3, // PAUSE_EQUIP + /* 0x04 */ PAUSE_4 // PAUSE_WORLD_MAP +} PauseMenuPage; + #endif diff --git a/src/overlays/gamestates/ovl_opening/z_opening.c b/src/overlays/gamestates/ovl_opening/z_opening.c index 96fe615fc6..f0dd8190e0 100644 --- a/src/overlays/gamestates/ovl_opening/z_opening.c +++ b/src/overlays/gamestates/ovl_opening/z_opening.c @@ -13,21 +13,21 @@ void Opening_SetupForTitleCutscene(OpeningContext* this) { gSaveContext.eventInf[1] &= (u8)~0x80; gSaveContext.gameMode = 1; - func_80144890(); + Sram_InitNewSave(); - gSaveContext.entranceIndex = openingEntrances[D_801BB12C]; - gSaveContext.nextCutsceneIndex = gSaveContext.cutscene = openingCutscenes[D_801BB12C]; + gSaveContext.save.entranceIndex = openingEntrances[D_801BB12C]; + gSaveContext.nextCutsceneIndex = gSaveContext.save.cutscene = openingCutscenes[D_801BB12C]; gSaveContext.sceneSetupIndex = 0; - gSaveContext.time = CLOCK_TIME(8, 0); - gSaveContext.day = 1; + gSaveContext.save.time = CLOCK_TIME(8, 0); + gSaveContext.save.day = 1; { GameState* thisx = &this->gameState; thisx->running = false; } SET_NEXT_GAMESTATE(&this->gameState, Play_Init, GlobalContext); - gSaveContext.playerForm = PLAYER_FORM_HUMAN; + gSaveContext.save.playerForm = PLAYER_FORM_HUMAN; } void func_80803EA0(OpeningContext* this) { @@ -37,7 +37,7 @@ void func_80803EA0(OpeningContext* this) { void Opening_Main(GameState* thisx) { OpeningContext* this = (OpeningContext*)thisx; - func_8012CF0C(this->gameState.gfxCtx, 0, 1, 0, 0, 0); + func_8012CF0C(this->gameState.gfxCtx, false, true, 0, 0, 0); Opening_SetupForTitleCutscene(this); func_80803EA0(this); } @@ -57,8 +57,8 @@ void Opening_Init(GameState* thisx) { this->gameState.destroy = Opening_Destroy; gSaveContext.respawnFlag = 0; - gSaveContext.respawn[4].entranceIndex = 0xFF; - gSaveContext.respawn[5].entranceIndex = 0xFF; - gSaveContext.respawn[6].entranceIndex = 0xFF; - gSaveContext.respawn[7].entranceIndex = 0xFF; + gSaveContext.respawn[RESPAWN_MODE_GORON].entranceIndex = 0xFF; + gSaveContext.respawn[RESPAWN_MODE_ZORA].entranceIndex = 0xFF; + gSaveContext.respawn[RESPAWN_MODE_DEKU].entranceIndex = 0xFF; + gSaveContext.respawn[RESPAWN_MODE_HUMAN].entranceIndex = 0xFF; } diff --git a/src/overlays/gamestates/ovl_select/z_select.c b/src/overlays/gamestates/ovl_select/z_select.c index 1cae35a850..53dbc266ff 100644 --- a/src/overlays/gamestates/ovl_select/z_select.c +++ b/src/overlays/gamestates/ovl_select/z_select.c @@ -33,26 +33,26 @@ void Select_LoadGame(SelectContext* this, u32 entranceIndex, s32 opt) { gSaveContext.unk_3F24 = 0; Audio_QueueSeqCmd(NA_BGM_STOP); - gSaveContext.entranceIndex = entranceIndex; + gSaveContext.save.entranceIndex = entranceIndex; if (opt != 0) { - gSaveContext.entranceIndex = - Entrance_CreateIndex((s32)gSaveContext.entranceIndex >> 9, opt, gSaveContext.entranceIndex & 0xF); + gSaveContext.save.entranceIndex = + Entrance_CreateIndex((s32)gSaveContext.save.entranceIndex >> 9, opt, gSaveContext.save.entranceIndex & 0xF); } - if (gSaveContext.entranceIndex == 0xC000) { - gSaveContext.day = 0; - gSaveContext.time = CLOCK_TIME(6, 0) - 1; + if (gSaveContext.save.entranceIndex == 0xC000) { + gSaveContext.save.day = 0; + gSaveContext.save.time = CLOCK_TIME(6, 0) - 1; } - gSaveContext.respawn[0].entranceIndex = 0xFFFF; + gSaveContext.respawn[RESTART_MODE_DOWN].entranceIndex = 0xFFFF; gSaveContext.seqIndex = (u8)NA_BGM_DISABLED; gSaveContext.nightSeqIndex = 0xFF; gSaveContext.showTitleCard = true; gSaveContext.respawnFlag = 0; - gSaveContext.respawn[4].entranceIndex = 0xFF; - gSaveContext.respawn[5].entranceIndex = 0xFF; - gSaveContext.respawn[6].entranceIndex = 0xFF; - gSaveContext.respawn[7].entranceIndex = 0xFF; + gSaveContext.respawn[RESPAWN_MODE_GORON].entranceIndex = 0xFF; + gSaveContext.respawn[RESPAWN_MODE_ZORA].entranceIndex = 0xFF; + gSaveContext.respawn[RESPAWN_MODE_DEKU].entranceIndex = 0xFF; + gSaveContext.respawn[RESPAWN_MODE_HUMAN].entranceIndex = 0xFF; D_801BDBB0 = 0; do { @@ -382,78 +382,78 @@ void Select_UpdateMenu(SelectContext* this) { } if (CHECK_BTN_ALL(controller1->press.button, BTN_B)) { - playerForm = gSaveContext.playerForm - 1; + playerForm = gSaveContext.save.playerForm - 1; if (playerForm < PLAYER_FORM_FIERCE_DEITY) { playerForm = PLAYER_FORM_HUMAN; } - gSaveContext.playerForm = playerForm; + gSaveContext.save.playerForm = playerForm; } if (CHECK_BTN_ALL(controller1->press.button, BTN_Z)) { - if (gSaveContext.cutscene == 0x8000) { - gSaveContext.cutscene = 0; - } else if (gSaveContext.cutscene == 0) { - gSaveContext.cutscene = 0x8800; - } else if (gSaveContext.cutscene == 0x8800) { - gSaveContext.cutscene = 0xFFF0; - } else if (gSaveContext.cutscene == 0xFFF0) { - gSaveContext.cutscene = 0xFFF1; - } else if (gSaveContext.cutscene == 0xFFF1) { - gSaveContext.cutscene = 0xFFF2; - } else if (gSaveContext.cutscene == 0xFFF2) { - gSaveContext.cutscene = 0xFFF3; - } else if (gSaveContext.cutscene == 0xFFF3) { - gSaveContext.cutscene = 0xFFF4; - } else if (gSaveContext.cutscene == 0xFFF4) { - gSaveContext.cutscene = 0xFFF5; - } else if (gSaveContext.cutscene == 0xFFF5) { - gSaveContext.cutscene = 0xFFF6; - } else if (gSaveContext.cutscene == 0xFFF6) { - gSaveContext.cutscene = 0xFFF7; - } else if (gSaveContext.cutscene == 0xFFF7) { - gSaveContext.cutscene = 0xFFF8; - } else if (gSaveContext.cutscene == 0xFFF8) { - gSaveContext.cutscene = 0xFFF9; - } else if (gSaveContext.cutscene == 0xFFF9) { - gSaveContext.cutscene = 0xFFFA; - } else if (gSaveContext.cutscene == 0xFFFA) { - gSaveContext.cutscene = 0x8000; + if (gSaveContext.save.cutscene == 0x8000) { + gSaveContext.save.cutscene = 0; + } else if (gSaveContext.save.cutscene == 0) { + gSaveContext.save.cutscene = 0x8800; + } else if (gSaveContext.save.cutscene == 0x8800) { + gSaveContext.save.cutscene = 0xFFF0; + } else if (gSaveContext.save.cutscene == 0xFFF0) { + gSaveContext.save.cutscene = 0xFFF1; + } else if (gSaveContext.save.cutscene == 0xFFF1) { + gSaveContext.save.cutscene = 0xFFF2; + } else if (gSaveContext.save.cutscene == 0xFFF2) { + gSaveContext.save.cutscene = 0xFFF3; + } else if (gSaveContext.save.cutscene == 0xFFF3) { + gSaveContext.save.cutscene = 0xFFF4; + } else if (gSaveContext.save.cutscene == 0xFFF4) { + gSaveContext.save.cutscene = 0xFFF5; + } else if (gSaveContext.save.cutscene == 0xFFF5) { + gSaveContext.save.cutscene = 0xFFF6; + } else if (gSaveContext.save.cutscene == 0xFFF6) { + gSaveContext.save.cutscene = 0xFFF7; + } else if (gSaveContext.save.cutscene == 0xFFF7) { + gSaveContext.save.cutscene = 0xFFF8; + } else if (gSaveContext.save.cutscene == 0xFFF8) { + gSaveContext.save.cutscene = 0xFFF9; + } else if (gSaveContext.save.cutscene == 0xFFF9) { + gSaveContext.save.cutscene = 0xFFFA; + } else if (gSaveContext.save.cutscene == 0xFFFA) { + gSaveContext.save.cutscene = 0x8000; } } else if (CHECK_BTN_ALL(controller1->press.button, BTN_R)) { - if (gSaveContext.cutscene == 0x8000) { - gSaveContext.cutscene = 0xFFFA; - } else if (gSaveContext.cutscene == 0) { - gSaveContext.cutscene = 0x8000; - } else if (gSaveContext.cutscene == 0x8800) { - gSaveContext.cutscene = 0; - } else if (gSaveContext.cutscene == 0xFFF0) { - gSaveContext.cutscene = 0x8800; - } else if (gSaveContext.cutscene == 0xFFF1) { - gSaveContext.cutscene = 0xFFF0; - } else if (gSaveContext.cutscene == 0xFFF2) { - gSaveContext.cutscene = 0xFFF1; - } else if (gSaveContext.cutscene == 0xFFF3) { - gSaveContext.cutscene = 0xFFF2; - } else if (gSaveContext.cutscene == 0xFFF4) { - gSaveContext.cutscene = 0xFFF3; - } else if (gSaveContext.cutscene == 0xFFF5) { - gSaveContext.cutscene = 0xFFF4; - } else if (gSaveContext.cutscene == 0xFFF6) { - gSaveContext.cutscene = 0xFFF5; - } else if (gSaveContext.cutscene == 0xFFF7) { - gSaveContext.cutscene = 0xFFF6; - } else if (gSaveContext.cutscene == 0xFFF8) { - gSaveContext.cutscene = 0xFFF7; - } else if (gSaveContext.cutscene == 0xFFF9) { - gSaveContext.cutscene = 0xFFF8; - } else if (gSaveContext.cutscene == 0xFFFA) { - gSaveContext.cutscene = 0xFFF9; + if (gSaveContext.save.cutscene == 0x8000) { + gSaveContext.save.cutscene = 0xFFFA; + } else if (gSaveContext.save.cutscene == 0) { + gSaveContext.save.cutscene = 0x8000; + } else if (gSaveContext.save.cutscene == 0x8800) { + gSaveContext.save.cutscene = 0; + } else if (gSaveContext.save.cutscene == 0xFFF0) { + gSaveContext.save.cutscene = 0x8800; + } else if (gSaveContext.save.cutscene == 0xFFF1) { + gSaveContext.save.cutscene = 0xFFF0; + } else if (gSaveContext.save.cutscene == 0xFFF2) { + gSaveContext.save.cutscene = 0xFFF1; + } else if (gSaveContext.save.cutscene == 0xFFF3) { + gSaveContext.save.cutscene = 0xFFF2; + } else if (gSaveContext.save.cutscene == 0xFFF4) { + gSaveContext.save.cutscene = 0xFFF3; + } else if (gSaveContext.save.cutscene == 0xFFF5) { + gSaveContext.save.cutscene = 0xFFF4; + } else if (gSaveContext.save.cutscene == 0xFFF6) { + gSaveContext.save.cutscene = 0xFFF5; + } else if (gSaveContext.save.cutscene == 0xFFF7) { + gSaveContext.save.cutscene = 0xFFF6; + } else if (gSaveContext.save.cutscene == 0xFFF8) { + gSaveContext.save.cutscene = 0xFFF7; + } else if (gSaveContext.save.cutscene == 0xFFF9) { + gSaveContext.save.cutscene = 0xFFF8; + } else if (gSaveContext.save.cutscene == 0xFFFA) { + gSaveContext.save.cutscene = 0xFFF9; } } - gSaveContext.isNight = false; - if (gSaveContext.cutscene == 0x8800) { - gSaveContext.isNight = true; + gSaveContext.save.isNight = false; + if (gSaveContext.save.cutscene == 0x8800) { + gSaveContext.save.isNight = true; } if (CHECK_BTN_ALL(controller1->press.button, BTN_CUP)) { @@ -464,14 +464,14 @@ void Select_UpdateMenu(SelectContext* this) { } if (CHECK_BTN_ALL(controller1->press.button, BTN_CLEFT)) { - if (gSaveContext.day > 1) { - gSaveContext.day--; + if (gSaveContext.save.day > 1) { + gSaveContext.save.day--; } } if (CHECK_BTN_ALL(controller1->press.button, BTN_CRIGHT)) { - if (gSaveContext.day < 4) { - gSaveContext.day++; + if (gSaveContext.save.day < 4) { + gSaveContext.save.day++; } } @@ -723,19 +723,19 @@ void Select_PrintCutsceneSetting(SelectContext* this, GfxPrint* printer, u16 csI case 0: // clang-format off // "Afternoon-jara" - gSaveContext.time = CLOCK_TIME(12, 0); stage = "\x8Dオヒル\x8Cジャラ"; + gSaveContext.save.time = CLOCK_TIME(12, 0); stage = "\x8Dオヒル\x8Cジャラ"; // clang-format on break; case 0x8000: // clang-format off // "Morning-jara" - gSaveContext.time = CLOCK_TIME(6, 0) + 1; stage = "\x8Dアサ \x8Cジャラ"; + gSaveContext.save.time = CLOCK_TIME(6, 0) + 1; stage = "\x8Dアサ \x8Cジャラ"; // clang-format on break; case 0x8800: - gSaveContext.time = CLOCK_TIME(18, 1); + gSaveContext.save.time = CLOCK_TIME(18, 1); // "Night-jara" stage = "\x8Dï¾–ï¾™ \x8Cジャラ"; break; @@ -743,7 +743,7 @@ void Select_PrintCutsceneSetting(SelectContext* this, GfxPrint* printer, u16 csI case 0xFFF0: // clang-format off // "Cutscene 00" - gSaveContext.time = CLOCK_TIME(12, 0); stage = "デモ00"; + gSaveContext.save.time = CLOCK_TIME(12, 0); stage = "デモ00"; // clang-format on break; case 0xFFF1: @@ -791,13 +791,13 @@ void Select_PrintCutsceneSetting(SelectContext* this, GfxPrint* printer, u16 csI stage = "???"; break; } - gSaveContext.environmentTime = gSaveContext.time; + gSaveContext.environmentTime = gSaveContext.save.time; GfxPrint_Printf(printer, "Stage:\x8C%s", stage); GfxPrint_SetPos(printer, 23, 25); GfxPrint_SetColor(printer, 255, 255, 55, 255); - switch (gSaveContext.day) { + switch (gSaveContext.save.day) { case 1: // "The First Day" day = "\x8Dサイショノヒ"; @@ -815,7 +815,7 @@ void Select_PrintCutsceneSetting(SelectContext* this, GfxPrint* printer, u16 csI day = "\x8Dクリアーノヒ"; break; default: - gSaveContext.day = 1; + gSaveContext.save.day = 1; // "The First Day" day = "\x8Dサイショノヒ"; break; @@ -837,8 +837,8 @@ void Select_DrawMenu(SelectContext* this) { GfxPrint_Open(printer, POLY_OPA_DISP); Select_PrintMenu(this, printer); - Select_PrintAgeSetting(this, printer, ((void)0, gSaveContext.playerForm)); - Select_PrintCutsceneSetting(this, printer, ((void)0, gSaveContext.cutscene)); + Select_PrintAgeSetting(this, printer, ((void)0, gSaveContext.save.playerForm)); + Select_PrintCutsceneSetting(this, printer, ((void)0, gSaveContext.save.cutscene)); POLY_OPA_DISP = GfxPrint_Close(printer); GfxPrint_Destroy(printer); @@ -868,7 +868,7 @@ void Select_DrawLoadingScreen(SelectContext* this) { void Select_Draw(SelectContext* this) { GraphicsContext* gfxCtx = this->state.gfxCtx; - func_8012CF0C(gfxCtx, 1, 1, 0, 0, 0); + func_8012CF0C(gfxCtx, true, true, 0, 0, 0); SET_FULLSCREEN_VIEWPORT(&this->view); View_RenderView(&this->view, 0xF); @@ -928,7 +928,7 @@ void Select_Init(GameState* thisx) { } Game_SetFramerateDivisor(&this->state, 1); - gSaveContext.cutscene = 0; - gSaveContext.playerForm = PLAYER_FORM_HUMAN; - gSaveContext.linkAge = 0; + gSaveContext.save.cutscene = 0; + gSaveContext.save.playerForm = PLAYER_FORM_HUMAN; + gSaveContext.save.linkAge = 0; } diff --git a/src/overlays/gamestates/ovl_title/z_title.c b/src/overlays/gamestates/ovl_title/z_title.c index 827c273871..afeafe09fe 100644 --- a/src/overlays/gamestates/ovl_title/z_title.c +++ b/src/overlays/gamestates/ovl_title/z_title.c @@ -119,7 +119,7 @@ void Title_Draw(GameState* thisx) { void Title_Main(GameState* thisx) { TitleContext* this = (TitleContext*)thisx; - func_8012CF0C(this->gameState.gfxCtx, 1, 1, 0, 0, 0); + func_8012CF0C(this->gameState.gfxCtx, true, true, 0, 0, 0); OPEN_DISPS(this->gameState.gfxCtx); @@ -145,7 +145,7 @@ void Title_Main(GameState* thisx) { void Title_Destroy(GameState* thisx) { TitleContext* this = (TitleContext*)thisx; - func_80146E40(&this->gameState, &this->sramCtx); + Sram_InitSram(&this->gameState, &this->sramCtx); ShrinkWindow_Destroy(); CIC6105_Nop80081828(); } @@ -173,7 +173,7 @@ void Title_Init(GameState* thisx) { gSaveContext.fileNum = 0xFF; } - gSaveContext.unk_3F3F = 1; + gSaveContext.unk_3F3F = true; Sram_Alloc(thisx, &this->sramCtx); this->ult = 0; this->timer = 20; diff --git a/tools/ZAPD/.gitrepo b/tools/ZAPD/.gitrepo index 475415d994..ddbb4547d3 100644 --- a/tools/ZAPD/.gitrepo +++ b/tools/ZAPD/.gitrepo @@ -6,7 +6,7 @@ [subrepo] remote = https://github.com/zeldaret/ZAPD.git branch = master - commit = 119a6883e6f795815744b9afd6a79084c619ddb6 - parent = 66a66f61b6368af0ed711803c54a963494329217 + commit = 87cb648b4311d20673452111edaf4d38a5290c28 + parent = 06412c070f0240eacfaa860eee99b9c723245b7f method = merge cmdver = 0.4.3 diff --git a/tools/ZAPD/ExporterTest/CollisionExporter.cpp b/tools/ZAPD/ExporterTest/CollisionExporter.cpp index e00f5c1b0b..87b9a05a28 100644 --- a/tools/ZAPD/ExporterTest/CollisionExporter.cpp +++ b/tools/ZAPD/ExporterTest/CollisionExporter.cpp @@ -50,10 +50,10 @@ void ExporterExample_Collision::Save(ZResource* res, [[maybe_unused]] fs::path o writer->Write(col->polygons[i].vtxA); writer->Write(col->polygons[i].vtxB); writer->Write(col->polygons[i].vtxC); - writer->Write(col->polygons[i].a); - writer->Write(col->polygons[i].b); - writer->Write(col->polygons[i].c); - writer->Write(col->polygons[i].d); + writer->Write(col->polygons[i].normX); + writer->Write(col->polygons[i].normY); + writer->Write(col->polygons[i].normZ); + writer->Write(col->polygons[i].dist); } writer->Seek(col->polyTypeDefSegmentOffset, SeekOffsetType::Start); diff --git a/tools/ZAPD/ExporterTest/ExporterTest.vcxproj b/tools/ZAPD/ExporterTest/ExporterTest.vcxproj index 839d451023..5bdfc7aa6d 100644 --- a/tools/ZAPD/ExporterTest/ExporterTest.vcxproj +++ b/tools/ZAPD/ExporterTest/ExporterTest.vcxproj @@ -1,160 +1,160 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - Win32Proj - {65608eb0-1a47-45ad-ab66-192fb64c762c} - ExporterTest - 10.0 - ExporterExample - - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - StaticLibrary - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - - - - - - - - - - - - - - - - - - - true - - - false - - - true - $(ProjectDir)..\ZAPD\;$(ProjectDir)..\ZAPDUtils;$(ProjectDir)..\lib\tinyxml2;$(ProjectDir)..\lib\libgfxd;$(ProjectDir)..\lib\elfio;$(ProjectDir)..\lib\stb;$(ProjectDir);$(IncludePath) - - - false - - - - Level3 - true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - Level3 - true - _DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - true - stdcpp17 - stdc11 - MultiThreadedDebug - - - Console - true - - - - - Level3 - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - - - - - - - - - - - - + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {65608eb0-1a47-45ad-ab66-192fb64c762c} + ExporterTest + 10.0 + ExporterExample + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + StaticLibrary + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + false + + + true + $(ProjectDir)..\ZAPD\;$(ProjectDir)..\ZAPDUtils;$(ProjectDir)..\lib\tinyxml2;$(ProjectDir)..\lib\libgfxd;$(ProjectDir)..\lib\elfio;$(ProjectDir)..\lib\stb;$(ProjectDir);$(IncludePath) + + + false + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true + stdcpp17 + stdc11 + MultiThreadedDebug + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tools/ZAPD/ZAPD/OtherStructs/CutsceneMM_Commands.cpp b/tools/ZAPD/ZAPD/OtherStructs/CutsceneMM_Commands.cpp new file mode 100644 index 0000000000..b69f47321d --- /dev/null +++ b/tools/ZAPD/ZAPD/OtherStructs/CutsceneMM_Commands.cpp @@ -0,0 +1,208 @@ +#include "CutsceneMM_Commands.h" + +#include +#include + +#include "Utils/BitConverter.h" +#include "Utils/StringHelper.h" + +// Specific for command lists where each entry has size 8 bytes +const std::unordered_map csCommandsDescMM = { + {CutsceneMMCommands::CS_CMD_MISC, {"CS_MISC", "(0x%02X, %i, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_SET_LIGHTING, {"CS_LIGHTING", "(0x%02X, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_SCENE_TRANS_FX, {"CS_SCENE_TRANS_FX", "(%i, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_MOTIONBLUR, {"CS_MOTIONBLUR", "(%i, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_GIVETATL, {"CS_GIVETATL", "(%i, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_PLAYSEQ, {"CS_PLAYSEQ", "(0x%04X, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_130, {"CS_SCENE_UNK_130", "(0x%04X, %i, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_131, {"CS_SCENE_UNK_131", "(0x%04X, %i, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_132, {"CS_SCENE_UNK_132", "(%i, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_STOPSEQ, {"CS_STOPSEQ", "(0x%04X, %i, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_PLAYAMBIENCE, {"CS_PLAYAMBIENCE", "(0x%04X, %i, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_FADEAMBIENCE, {"CS_FADEAMBIENCE", "(0x%04X, %i, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_TERMINATOR, {"CS_TERMINATOR", "(%i, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_CHOOSE_CREDITS_SCENES, + {"CS_CHOOSE_CREDITS_SCENES", "(%i, %i, %i)"}}, +}; + +CutsceneSubCommandEntry_GenericMMCmd::CutsceneSubCommandEntry_GenericMMCmd( + const std::vector& rawData, offset_t rawDataIndex, CutsceneMMCommands cmdId) + : CutsceneSubCommandEntry(rawData, rawDataIndex), commandId(cmdId) +{ +} + +std::string CutsceneSubCommandEntry_GenericMMCmd::GetBodySourceCode() const +{ + const auto& element = csCommandsDescMM.find(commandId); + std::string entryFmt = "CS_UNK_DATA(0x%02X, %i, %i, %i)"; + + if (element != csCommandsDescMM.end()) + { + entryFmt = element->second.cmdMacro; + entryFmt += element->second.args; + } + + return StringHelper::Sprintf(entryFmt.c_str(), base, startFrame, endFrame, pad); +} + +CutsceneMMCommand_GenericCmd::CutsceneMMCommand_GenericCmd(const std::vector& rawData, + offset_t rawDataIndex, + CutsceneMMCommands cmdId) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + commandID = static_cast(cmdId); + + for (size_t i = 0; i < numEntries; i++) + { + auto* entry = new CutsceneSubCommandEntry_GenericMMCmd(rawData, rawDataIndex, cmdId); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } +} + +std::string CutsceneMMCommand_GenericCmd::GetCommandMacro() const +{ + const auto& element = csCommandsDescMM.find(static_cast(commandID)); + + if (element != csCommandsDescMM.end()) + { + return StringHelper::Sprintf("%s_LIST(%i)", element->second.cmdMacro, numEntries); + } + + return StringHelper::Sprintf("CS_UNK_DATA_LIST(0x%X, %i)", commandID, numEntries); +} + +CutsceneSubCommandEntry_Camera::CutsceneSubCommandEntry_Camera(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneSubCommandEntry(rawData, rawDataIndex) +{ +} + +std::string CutsceneSubCommandEntry_Camera::GetBodySourceCode() const +{ + return StringHelper::Sprintf("CMD_HH(0x%04X, 0x%04X)", base, startFrame); +} + +size_t CutsceneSubCommandEntry_Camera::GetRawSize() const +{ + return 0x04; +} + +CutsceneMMCommand_Camera::CutsceneMMCommand_Camera(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + for (size_t i = 0; i < numEntries / 4; i++) + { + auto* entry = new CutsceneSubCommandEntry_Camera(rawData, rawDataIndex); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } +} + +std::string CutsceneMMCommand_Camera::GetCommandMacro() const +{ + return StringHelper::Sprintf("CS_CAMERA_LIST(%i)", numEntries); +} + +CutsceneSubCommandEntry_FadeScreen::CutsceneSubCommandEntry_FadeScreen( + const std::vector& rawData, offset_t rawDataIndex) + : CutsceneSubCommandEntry(rawData, rawDataIndex) +{ + unk_06 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x06); + unk_07 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x07); + unk_08 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x08); + unk_09 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x09); + unk_0A = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x0A); + unk_0B = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x0B); +} + +std::string CutsceneSubCommandEntry_FadeScreen::GetBodySourceCode() const +{ + return StringHelper::Sprintf("CS_FADESCREEN(0x%02X, %i, %i, %i, %i, %i)", base, startFrame, + endFrame, unk_06, unk_07, unk_08); +} + +size_t CutsceneSubCommandEntry_FadeScreen::GetRawSize() const +{ + return 0x0C; +} + +CutsceneMMCommand_FadeScreen::CutsceneMMCommand_FadeScreen(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + for (size_t i = 0; i < numEntries; i++) + { + auto* entry = new CutsceneSubCommandEntry_FadeScreen(rawData, rawDataIndex); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } +} + +std::string CutsceneMMCommand_FadeScreen::GetCommandMacro() const +{ + return StringHelper::Sprintf("CS_FADESCREEN_LIST(%i)", numEntries); +} + +CutsceneSubCommandEntry_FadeSeq::CutsceneSubCommandEntry_FadeSeq( + const std::vector& rawData, offset_t rawDataIndex) + : CutsceneSubCommandEntry(rawData, rawDataIndex) +{ + unk_08 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 8); +} + +std::string CutsceneSubCommandEntry_FadeSeq::GetBodySourceCode() const +{ + return StringHelper::Sprintf("CS_FADESEQ(%i, %i, %i)", base, startFrame, endFrame); +} + +size_t CutsceneSubCommandEntry_FadeSeq::GetRawSize() const +{ + return 0x0C; +} + +CutsceneMMCommand_FadeSeq::CutsceneMMCommand_FadeSeq(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + for (size_t i = 0; i < numEntries; i++) + { + auto* entry = new CutsceneSubCommandEntry_FadeSeq(rawData, rawDataIndex); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } +} + +std::string CutsceneMMCommand_FadeSeq::GetCommandMacro() const +{ + return StringHelper::Sprintf("CS_FADESEQ_LIST(%i)", numEntries); +} + +CutsceneSubCommandEntry_NonImplemented::CutsceneSubCommandEntry_NonImplemented( + const std::vector& rawData, offset_t rawDataIndex) + : CutsceneSubCommandEntry(rawData, rawDataIndex) +{ +} + +CutsceneMMCommand_NonImplemented::CutsceneMMCommand_NonImplemented( + const std::vector& rawData, offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + for (size_t i = 0; i < numEntries; i++) + { + auto* entry = new CutsceneSubCommandEntry_NonImplemented(rawData, rawDataIndex); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } +} diff --git a/tools/ZAPD/ZAPD/OtherStructs/CutsceneMM_Commands.h b/tools/ZAPD/ZAPD/OtherStructs/CutsceneMM_Commands.h new file mode 100644 index 0000000000..c8ae4eb603 --- /dev/null +++ b/tools/ZAPD/ZAPD/OtherStructs/CutsceneMM_Commands.h @@ -0,0 +1,140 @@ +#pragma once + +#include "Cutscene_Commands.h" + +enum class CutsceneMMCommands +{ + /* 0x00A */ CS_CMD_TEXTBOX = 0xA, + /* 0x05A */ CS_CMD_CAMERA = 0x5A, + /* 0x096 */ CS_CMD_MISC = 0x96, + /* 0x097 */ CS_CMD_SET_LIGHTING, + /* 0x098 */ CS_CMD_SCENE_TRANS_FX, + /* 0x099 */ CS_CMD_MOTIONBLUR, + /* 0x09A */ CS_CMD_GIVETATL, + /* 0x09B */ CS_CMD_FADESCREEN, + /* 0x09C */ CS_CMD_FADESEQ, + /* 0x09D */ CS_CMD_SETTIME, + /* 0x0C8 */ CS_CMD_SET_PLAYER_ACTION = 0xC8, + /* 0x0FA */ CS_CMD_UNK_FA = 0xFA, + /* 0x0FE */ CS_CMD_UNK_FE = 0xFE, + /* 0x0FF */ CS_CMD_UNK_FF, + /* 0x100 */ CS_CMD_UNK_100, + /* 0x101 */ CS_CMD_UNK_101, + /* 0x102 */ CS_CMD_UNK_102, + /* 0x103 */ CS_CMD_UNK_103, + /* 0x104 */ CS_CMD_UNK_104, + /* 0x105 */ CS_CMD_UNK_105, + /* 0x108 */ CS_CMD_UNK_108 = 0x108, + /* 0x109 */ CS_CMD_UNK_109, + /* 0x12C */ CS_CMD_PLAYSEQ = 0x12C, + /* 0x12D */ CS_CMD_UNK_12D, + /* 0x130 */ CS_CMD_130 = 0x130, + /* 0x131 */ CS_CMD_131 = 0x131, + /* 0x132 */ CS_CMD_132 = 0x132, + /* 0x133 */ CS_CMD_STOPSEQ, + /* 0x134 */ CS_CMD_PLAYAMBIENCE, + /* 0x135 */ CS_CMD_FADEAMBIENCE, + /* 0x15E */ CS_CMD_TERMINATOR = 0x15E, + /* 0x15F */ CS_CMD_CHOOSE_CREDITS_SCENES, + /* 0x190 */ CS_CMD_RUMBLE = 0x190, +}; + +class CutsceneSubCommandEntry_GenericMMCmd : public CutsceneSubCommandEntry +{ +public: + CutsceneMMCommands commandId; + + CutsceneSubCommandEntry_GenericMMCmd(const std::vector& rawData, offset_t rawDataIndex, + CutsceneMMCommands cmdId); + + std::string GetBodySourceCode() const override; +}; + +class CutsceneMMCommand_GenericCmd : public CutsceneCommand +{ +public: + CutsceneMMCommand_GenericCmd(const std::vector& rawData, offset_t rawDataIndex, + CutsceneMMCommands cmdId); + + std::string GetCommandMacro() const override; +}; + +// TODO: MM cutscene camera command is implemented as a placeholder until we better understand how +// it works +class CutsceneSubCommandEntry_Camera : public CutsceneSubCommandEntry +{ +public: + uint32_t unk_08; + + CutsceneSubCommandEntry_Camera(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetBodySourceCode() const override; + + size_t GetRawSize() const override; +}; + +class CutsceneMMCommand_Camera : public CutsceneCommand +{ +public: + CutsceneMMCommand_Camera(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetCommandMacro() const override; +}; + +class CutsceneSubCommandEntry_FadeScreen : public CutsceneSubCommandEntry +{ +public: + uint8_t unk_06; + uint8_t unk_07; + uint8_t unk_08; + uint8_t unk_09; + uint8_t unk_0A; + uint8_t unk_0B; + + CutsceneSubCommandEntry_FadeScreen(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetBodySourceCode() const override; + + size_t GetRawSize() const override; +}; + +class CutsceneMMCommand_FadeScreen : public CutsceneCommand +{ +public: + CutsceneMMCommand_FadeScreen(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetCommandMacro() const override; +}; + +class CutsceneSubCommandEntry_FadeSeq : public CutsceneSubCommandEntry +{ +public: + uint32_t unk_08; + + CutsceneSubCommandEntry_FadeSeq(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetBodySourceCode() const override; + + size_t GetRawSize() const override; +}; + +class CutsceneMMCommand_FadeSeq : public CutsceneCommand +{ +public: + CutsceneMMCommand_FadeSeq(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetCommandMacro() const override; +}; + +class CutsceneSubCommandEntry_NonImplemented : public CutsceneSubCommandEntry +{ +public: + CutsceneSubCommandEntry_NonImplemented(const std::vector& rawData, + offset_t rawDataIndex); +}; + +class CutsceneMMCommand_NonImplemented : public CutsceneCommand +{ +public: + CutsceneMMCommand_NonImplemented(const std::vector& rawData, offset_t rawDataIndex); +}; diff --git a/tools/ZAPD/ZAPD/OtherStructs/Cutscene_Commands.cpp b/tools/ZAPD/ZAPD/OtherStructs/Cutscene_Commands.cpp new file mode 100644 index 0000000000..a716176b9b --- /dev/null +++ b/tools/ZAPD/ZAPD/OtherStructs/Cutscene_Commands.cpp @@ -0,0 +1,591 @@ +#include "Cutscene_Commands.h" + +#include +#include + +#include "CutsceneMM_Commands.h" +#include "Globals.h" +#include "Utils/BitConverter.h" +#include "Utils/StringHelper.h" + +/* CutsceneSubCommandEntry */ + +CutsceneSubCommandEntry::CutsceneSubCommandEntry(const std::vector& rawData, + offset_t rawDataIndex) +{ + base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); + startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); + endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); + pad = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); +} + +std::string CutsceneSubCommandEntry::GetBodySourceCode() const +{ + return StringHelper::Sprintf("CMD_HH(0x%04X, 0x%04X), CMD_HH(0x%04X, 0x%04X)", base, startFrame, + endFrame, pad); +} + +size_t CutsceneSubCommandEntry::GetRawSize() const +{ + return 0x08; +} + +/* CutsceneCommand */ + +CutsceneCommand::CutsceneCommand(const std::vector& rawData, offset_t rawDataIndex) +{ + numEntries = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0); +} + +CutsceneCommand::~CutsceneCommand() +{ + for (auto& entry : entries) + { + delete entry; + } +} + +std::string CutsceneCommand::GetCommandMacro() const +{ + return StringHelper::Sprintf("CMD_W(0x%08X), CMD_W(0x%08X)", commandID, numEntries); +} + +std::string CutsceneCommand::GenerateSourceCode() const +{ + std::string result; + + result += GetCommandMacro(); + result += ",\n"; + + for (auto& entry : entries) + { + result += " "; + result += entry->GetBodySourceCode(); + result += ",\n"; + } + + return result; +} + +size_t CutsceneCommand::GetCommandSize() const +{ + size_t size = 0; + if (entries.size() > 0) + { + size = entries.at(0)->GetRawSize() * entries.size(); + } + else + { + size = 0x08 * numEntries; + } + return 0x08 + size; +} + +void CutsceneCommand::SetCommandID(uint32_t nCommandID) +{ + commandID = nCommandID; + + for (auto& entry : entries) + { + entry->commandID = commandID; + } +} + +// Specific for command lists where each entry has size 0x30 bytes +const std::unordered_map csCommandsDesc = { + {CutsceneCommands::Misc, + {"CS_MISC", "(0x%04X, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i)"}}, + {CutsceneCommands::SetLighting, + {"CS_LIGHTING", "(0x%02X, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i)"}}, + {CutsceneCommands::PlayBGM, {"CS_PLAY_BGM", "(%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i)"}}, + {CutsceneCommands::StopBGM, {"CS_STOP_BGM", "(%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i)"}}, + {CutsceneCommands::FadeBGM, {"CS_FADE_BGM", "(%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i)"}}, +}; + +CutsceneSubCommandEntry_GenericCmd::CutsceneSubCommandEntry_GenericCmd( + const std::vector& rawData, offset_t rawDataIndex, CutsceneCommands cmdId) + : CutsceneSubCommandEntry(rawData, rawDataIndex), commandId(cmdId) +{ + word0 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x0); + word1 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x4); + + unused1 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x8); + unused2 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0xC); + unused3 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x10); + unused4 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x14); + unused5 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x18); + unused6 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x1C); + unused7 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x20); + unused8 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x24); + unused9 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x28); + unused10 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x2C); +} + +std::string CutsceneSubCommandEntry_GenericCmd::GetBodySourceCode() const +{ + const auto& element = csCommandsDesc.find(commandId); + + if (element != csCommandsDesc.end()) + { + std::string entryFmt = element->second.cmdMacro; + entryFmt += element->second.args; + + return StringHelper::Sprintf(entryFmt.c_str(), base, startFrame, endFrame, pad, unused1, + unused2, unused3, unused4, unused5, unused6, unused7, unused8, + unused9, unused10); + } + + return StringHelper::Sprintf("CS_UNK_DATA(0x%08X, 0x%08X, 0x%08X, 0x%08X, 0x%08X, 0x%08X, " + "0x%08X, 0x%08X, 0x%08X, 0x%08X, 0x%08X, 0x%08X)", + word0, word1, unused1, unused2, unused3, unused4, unused5, unused6, + unused7, unused8, unused9, unused10); +} + +size_t CutsceneSubCommandEntry_GenericCmd::GetRawSize() const +{ + return 0x30; +} + +CutsceneCommand_GenericCmd::CutsceneCommand_GenericCmd(const std::vector& rawData, + offset_t rawDataIndex, + CutsceneCommands cmdId) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + commandID = static_cast(cmdId); + + for (size_t i = 0; i < numEntries; i++) + { + auto* entry = new CutsceneSubCommandEntry_GenericCmd(rawData, rawDataIndex, cmdId); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } +} + +std::string CutsceneCommand_GenericCmd::GetCommandMacro() const +{ + const auto& element = csCommandsDesc.find(static_cast(commandID)); + + if (element != csCommandsDesc.end()) + { + return StringHelper::Sprintf("%s_LIST(%i)", element->second.cmdMacro, numEntries); + } + + return StringHelper::Sprintf("CS_UNK_DATA_LIST(0x%X, %i)", commandID, numEntries); +} + +CutsceneCameraPoint::CutsceneCameraPoint(const std::vector& rawData, offset_t rawDataIndex) + : CutsceneSubCommandEntry(rawData, rawDataIndex) +{ + continueFlag = BitConverter::ToInt8BE(rawData, rawDataIndex + 0); + cameraRoll = BitConverter::ToInt8BE(rawData, rawDataIndex + 1); + nextPointFrame = BitConverter::ToInt16BE(rawData, rawDataIndex + 2); + viewAngle = BitConverter::ToFloatBE(rawData, rawDataIndex + 4); + + posX = BitConverter::ToInt16BE(rawData, rawDataIndex + 8); + posY = BitConverter::ToInt16BE(rawData, rawDataIndex + 10); + posZ = BitConverter::ToInt16BE(rawData, rawDataIndex + 12); + + unused = BitConverter::ToInt16BE(rawData, rawDataIndex + 14); +} + +std::string CutsceneCameraPoint::GetBodySourceCode() const +{ + std::string result = ""; + + if (commandID == (int32_t)CutsceneCommands::SetCameraFocus) + { + result += "CS_CAM_FOCUS_POINT"; + } + else if (commandID == (int32_t)CutsceneCommands::SetCameraFocusLink) + { + result += "CS_CAM_FOCUS_POINT_PLAYER"; + } + else if (commandID == (int32_t)CutsceneCommands::SetCameraPosLink) + { + result += "CS_CAM_POS_PLAYER"; + } + else + { + result += "CS_CAM_POS"; + } + + std::string continueMacro = "CS_CMD_CONTINUE"; + if (continueFlag != 0) + continueMacro = "CS_CMD_STOP"; + + result += + StringHelper::Sprintf("(%s, 0x%02X, %i, %ff, %i, %i, %i, 0x%04X)", continueMacro.c_str(), + cameraRoll, nextPointFrame, viewAngle, posX, posY, posZ, unused); + return result; +} + +size_t CutsceneCameraPoint::GetRawSize() const +{ + return 0x10; +} + +CutsceneCommandSetCameraPos::CutsceneCommandSetCameraPos(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); + startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); + endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); + unused = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); + + bool shouldContinue = true; + + uint32_t currentPtr = rawDataIndex + 8; + + while (shouldContinue) + { + CutsceneCameraPoint* camPoint = new CutsceneCameraPoint(rawData, currentPtr); + entries.push_back(camPoint); + + if (camPoint->continueFlag == -1) + shouldContinue = false; + + currentPtr += camPoint->GetRawSize(); + } +} + +std::string CutsceneCommandSetCameraPos::GetCommandMacro() const +{ + std::string result; + + std::string listStr; + + if (commandID == (int32_t)CutsceneCommands::SetCameraFocus) + { + listStr = "CS_CAM_FOCUS_POINT_LIST"; + } + else if (commandID == (int32_t)CutsceneCommands::SetCameraFocusLink) + { + listStr = "CS_CAM_FOCUS_POINT_PLAYER_LIST"; + } + else if (commandID == (int32_t)CutsceneCommands::SetCameraPosLink) + { + listStr = "CS_CAM_POS_PLAYER_LIST"; + } + else + { + listStr = "CS_CAM_POS_LIST"; + } + + result += StringHelper::Sprintf("%s(%i, %i)", listStr.c_str(), startFrame, endFrame); + + return result; +} + +size_t CutsceneCommandSetCameraPos::GetCommandSize() const +{ + return 0x0C + entries.at(0)->GetRawSize() * entries.size(); +} + +CutsceneSubCommandEntry_Rumble::CutsceneSubCommandEntry_Rumble(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneSubCommandEntry(rawData, rawDataIndex) +{ + unk_06 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x06); + unk_07 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x07); + unk_08 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x08); + unk_09 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x09); + unk_0A = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x0A); + unk_0B = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x0B); +} + +std::string CutsceneSubCommandEntry_Rumble::GetBodySourceCode() const +{ + if (Globals::Instance->game == ZGame::MM_RETAIL) + { + return StringHelper::Sprintf("CS_RUMBLE(%i, %i, %i, 0x%02X, 0x%02X, 0x%02X)", base, + startFrame, endFrame, unk_06, unk_07, unk_08); + } + + return StringHelper::Sprintf("CS_CMD_09(%i, %i, %i, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X)", + base, startFrame, endFrame, unk_06, unk_07, unk_08, unk_09, unk_0A, + unk_0B); +} + +size_t CutsceneSubCommandEntry_Rumble::GetRawSize() const +{ + return 0x0C; +} + +CutsceneCommand_Rumble::CutsceneCommand_Rumble(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + for (size_t i = 0; i < numEntries; i++) + { + auto* entry = new CutsceneSubCommandEntry_Rumble(rawData, rawDataIndex); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } +} + +std::string CutsceneCommand_Rumble::GetCommandMacro() const +{ + if (Globals::Instance->game == ZGame::MM_RETAIL) + { + return StringHelper::Sprintf("CS_RUMBLE_LIST(%i)", numEntries); + } + return StringHelper::Sprintf("CS_CMD_09_LIST(%i)", numEntries); +} + +CutsceneSubCommandEntry_SetTime::CutsceneSubCommandEntry_SetTime( + const std::vector& rawData, offset_t rawDataIndex) + : CutsceneSubCommandEntry(rawData, rawDataIndex) +{ + hour = BitConverter::ToUInt8BE(rawData, rawDataIndex + 6); + minute = BitConverter::ToUInt8BE(rawData, rawDataIndex + 7); + unk_08 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 8); +} + +std::string CutsceneSubCommandEntry_SetTime::GetBodySourceCode() const +{ + return StringHelper::Sprintf("CS_TIME(%i, %i, %i, %i, %i, %i)", base, startFrame, endFrame, + hour, minute, unk_08); +} + +size_t CutsceneSubCommandEntry_SetTime::GetRawSize() const +{ + return 0x0C; +} + +CutsceneCommand_SetTime::CutsceneCommand_SetTime(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + for (size_t i = 0; i < numEntries; i++) + { + auto* entry = new CutsceneSubCommandEntry_SetTime(rawData, rawDataIndex); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } +} + +std::string CutsceneCommand_SetTime::GetCommandMacro() const +{ + return StringHelper::Sprintf("CS_TIME_LIST(%i)", numEntries); +} + +CutsceneSubCommandEntry_TextBox::CutsceneSubCommandEntry_TextBox( + const std::vector& rawData, offset_t rawDataIndex) + : CutsceneSubCommandEntry(rawData, rawDataIndex) +{ + type = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x6); + textId1 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x8); + textId2 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0xA); +} + +std::string CutsceneSubCommandEntry_TextBox::GetBodySourceCode() const +{ + if (type == 0xFFFF) + { + return StringHelper::Sprintf("CS_TEXT_NONE(%i, %i)", startFrame, endFrame); + } + if (type == 2) + { + return StringHelper::Sprintf("CS_TEXT_LEARN_SONG(%i, %i, %i, 0x%X)", base, startFrame, + endFrame, textId1); + } + + if (Globals::Instance->game == ZGame::MM_RETAIL) + { + switch (type) + { + case 0: + return StringHelper::Sprintf("CS_TEXT_DEFAULT(0x%X, %i, %i, 0x%X, 0x%X)", base, + startFrame, endFrame, textId1, textId2); + + case 1: + return StringHelper::Sprintf("CS_TEXT_TYPE_1(0x%X, %i, %i, 0x%X, 0x%X)", base, + startFrame, endFrame, textId1, textId2); + + case 3: + return StringHelper::Sprintf("CS_TEXT_TYPE_3(0x%X, %i, %i, 0x%X, 0x%X)", base, + startFrame, endFrame, textId1, textId2); + + case 4: + return StringHelper::Sprintf("CS_TEXT_BOSSES_REMAINS(0x%X, %i, %i, 0x%X)", base, + startFrame, endFrame, textId1); + + case 5: + return StringHelper::Sprintf("CS_TEXT_ALL_NORMAL_MASKS(0x%X, %i, %i, 0x%X)", base, + startFrame, endFrame, textId1); + } + } + + return StringHelper::Sprintf("CS_TEXT_DISPLAY_TEXTBOX(0x%X, %i, %i, %i, 0x%X, 0x%X)", base, + startFrame, endFrame, type, textId1, textId2); +} + +size_t CutsceneSubCommandEntry_TextBox::GetRawSize() const +{ + return 0x0C; +} + +CutsceneCommand_TextBox::CutsceneCommand_TextBox(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + for (size_t i = 0; i < numEntries; i++) + { + auto* entry = new CutsceneSubCommandEntry_TextBox(rawData, rawDataIndex); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } +} + +std::string CutsceneCommand_TextBox::GetCommandMacro() const +{ + return StringHelper::Sprintf("CS_TEXT_LIST(%i)", numEntries); +} + +CutsceneSubCommandEntry_ActorAction::CutsceneSubCommandEntry_ActorAction( + const std::vector& rawData, offset_t rawDataIndex) + : CutsceneSubCommandEntry(rawData, rawDataIndex) +{ + rotX = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x6); + rotY = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x8); + rotZ = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0xA); + startPosX = BitConverter::ToInt32BE(rawData, rawDataIndex + 0xC); + startPosY = BitConverter::ToInt32BE(rawData, rawDataIndex + 0x10); + startPosZ = BitConverter::ToInt32BE(rawData, rawDataIndex + 0x14); + endPosX = BitConverter::ToInt32BE(rawData, rawDataIndex + 0x18); + endPosY = BitConverter::ToInt32BE(rawData, rawDataIndex + 0x1C); + endPosZ = BitConverter::ToInt32BE(rawData, rawDataIndex + 0x20); + normalX = BitConverter::ToFloatBE(rawData, rawDataIndex + 0x24); + normalY = BitConverter::ToFloatBE(rawData, rawDataIndex + 0x28); + normalZ = BitConverter::ToFloatBE(rawData, rawDataIndex + 0x2C); +} + +std::string CutsceneSubCommandEntry_ActorAction::GetBodySourceCode() const +{ + std::string result; + + if (Globals::Instance->game == ZGame::MM_RETAIL) + { + if (static_cast(commandID) == + CutsceneMMCommands::CS_CMD_SET_PLAYER_ACTION) + { + result = "CS_PLAYER_ACTION"; + } + else + { + result = "CS_ACTOR_ACTION"; + } + } + else + { + if (static_cast(commandID) == CutsceneCommands::SetPlayerAction) + { + result = "CS_PLAYER_ACTION"; + } + else + { + result = "CS_NPC_ACTION"; + } + } + + result += + StringHelper::Sprintf("(%i, %i, %i, 0x%04X, 0x%04X, 0x%04X, %i, %i, " + "%i, %i, %i, %i, %.11ef, %.11ef, %.11ef)", + base, startFrame, endFrame, rotX, rotY, rotZ, startPosX, startPosY, + startPosZ, endPosX, endPosY, endPosZ, normalX, normalY, normalZ); + return result; +} + +size_t CutsceneSubCommandEntry_ActorAction::GetRawSize() const +{ + return 0x30; +} + +CutsceneCommand_ActorAction::CutsceneCommand_ActorAction(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + for (size_t i = 0; i < numEntries; i++) + { + auto* entry = new CutsceneSubCommandEntry_ActorAction(rawData, rawDataIndex); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } +} + +std::string CutsceneCommand_ActorAction::GetCommandMacro() const +{ + if (Globals::Instance->game == ZGame::MM_RETAIL) + { + if (static_cast(commandID) == + CutsceneMMCommands::CS_CMD_SET_PLAYER_ACTION) + { + return StringHelper::Sprintf("CS_PLAYER_ACTION_LIST(%i)", numEntries); + } + return StringHelper::Sprintf("CS_ACTOR_ACTION_LIST(0x%03X, %i)", commandID, numEntries); + } + + if (static_cast(commandID) == CutsceneCommands::SetPlayerAction) + { + return StringHelper::Sprintf("CS_PLAYER_ACTION_LIST(%i)", entries.size()); + } + return StringHelper::Sprintf("CS_NPC_ACTION_LIST(0x%03X, %i)", commandID, entries.size()); +} + +CutsceneCommand_Terminator::CutsceneCommand_Terminator(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); + startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); + endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); + unknown = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); // endFrame duplicate +} + +std::string CutsceneCommand_Terminator::GenerateSourceCode() const +{ + std::string result; + + result += StringHelper::Sprintf("CS_TERMINATOR(%i, %i, %i),\n", base, startFrame, endFrame); + + return result; +} + +size_t CutsceneCommand_Terminator::GetCommandSize() const +{ + return 0x10; +} + +CutsceneCommandSceneTransFX::CutsceneCommandSceneTransFX(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); + startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); + endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); +} + +std::string CutsceneCommandSceneTransFX::GenerateSourceCode() const +{ + return StringHelper::Sprintf("CS_SCENE_TRANS_FX(%i, %i, %i),\n", base, startFrame, endFrame); +} + +size_t CutsceneCommandSceneTransFX::GetCommandSize() const +{ + return 0x10; +} diff --git a/tools/ZAPD/ZAPD/OtherStructs/Cutscene_Commands.h b/tools/ZAPD/ZAPD/OtherStructs/Cutscene_Commands.h new file mode 100644 index 0000000000..c462735873 --- /dev/null +++ b/tools/ZAPD/ZAPD/OtherStructs/Cutscene_Commands.h @@ -0,0 +1,267 @@ +#pragma once + +#include +#include +#include + +#include "Declaration.h" + +enum class CutsceneCommands +{ + SetCameraPos = 0x0001, + SetCameraFocus = 0x0002, + Misc = 0x0003, + SetLighting = 0x0004, + SetCameraPosLink = 0x0005, + SetCameraFocusLink = 0x0006, + Cmd07 = 0x0007, + Cmd08 = 0x0008, + Cmd09 = 0x0009, // Rumble + Textbox = 0x0013, + SetPlayerAction = 0x000A, + SetActorAction1 = 0x000F, + SetActorAction2 = 0x000E, + SetActorAction3 = 0x0019, + SetActorAction4 = 0x001D, + SetActorAction5 = 0x001E, + SetActorAction6 = 0x002C, + SetActorAction7 = 0x001F, + SetActorAction8 = 0x0031, + SetActorAction9 = 0x003E, + SetActorAction10 = 0x008F, + SetSceneTransFX = 0x002D, + PlayBGM = 0x0056, + StopBGM = 0x0057, + FadeBGM = 0x007C, + SetTime = 0x008C, + Terminator = 0x03E8, +}; + +typedef struct CsCommandListDescriptor +{ + const char* cmdMacro; + const char* args; +} CsCommandListDescriptor; + +class CutsceneSubCommandEntry +{ +public: + uint16_t base; + uint16_t startFrame; + uint16_t endFrame; + uint16_t pad; + + uint32_t commandID; + + CutsceneSubCommandEntry(const std::vector& rawData, offset_t rawDataIndex); + virtual ~CutsceneSubCommandEntry() = default; + + virtual std::string GetBodySourceCode() const; + + virtual size_t GetRawSize() const; +}; + +class CutsceneCommand +{ +public: + uint32_t commandID; + uint32_t commandIndex; + + uint32_t numEntries; + std::vector entries; + + CutsceneCommand(const std::vector& rawData, offset_t rawDataIndex); + virtual ~CutsceneCommand(); + + virtual std::string GetCommandMacro() const; + virtual std::string GenerateSourceCode() const; + virtual size_t GetCommandSize() const; + + virtual void SetCommandID(uint32_t nCommandID); +}; + +class CutsceneSubCommandEntry_GenericCmd : public CutsceneSubCommandEntry +{ +public: + CutsceneCommands commandId; + + uint32_t word0 = 0; + uint32_t word1 = 0; + + uint32_t unused1 = 0; + uint32_t unused2 = 0; + uint32_t unused3 = 0; + uint32_t unused4 = 0; + uint32_t unused5 = 0; + uint32_t unused6 = 0; + uint32_t unused7 = 0; + uint32_t unused8 = 0; + uint32_t unused9 = 0; + uint32_t unused10 = 0; + + CutsceneSubCommandEntry_GenericCmd(const std::vector& rawData, offset_t rawDataIndex, + CutsceneCommands cmdId); + + std::string GetBodySourceCode() const override; + + size_t GetRawSize() const override; +}; + +class CutsceneCommand_GenericCmd : public CutsceneCommand +{ +public: + CutsceneCommand_GenericCmd(const std::vector& rawData, offset_t rawDataIndex, + CutsceneCommands cmdId); + + std::string GetCommandMacro() const override; +}; + +class CutsceneCameraPoint : public CutsceneSubCommandEntry +{ +public: + int8_t continueFlag; + int8_t cameraRoll; + int16_t nextPointFrame; + float viewAngle; + int16_t posX, posY, posZ; + int16_t unused; + + CutsceneCameraPoint(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetBodySourceCode() const override; + + size_t GetRawSize() const override; +}; + +class CutsceneCommandSetCameraPos : public CutsceneCommand +{ +public: + uint16_t base; + uint16_t startFrame; + uint16_t endFrame; + uint16_t unused; + + CutsceneCommandSetCameraPos(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetCommandMacro() const override; + + size_t GetCommandSize() const override; +}; + +class CutsceneCommandSceneTransFX : public CutsceneCommand +{ +public: + uint16_t base; + uint16_t startFrame; + uint16_t endFrame; + + CutsceneCommandSceneTransFX(const std::vector& rawData, offset_t rawDataIndex); + + std::string GenerateSourceCode() const override; + size_t GetCommandSize() const override; +}; + +class CutsceneSubCommandEntry_Rumble : public CutsceneSubCommandEntry +{ +public: + uint8_t unk_06; + uint8_t unk_07; + uint8_t unk_08; + uint8_t unk_09; + uint8_t unk_0A; + uint8_t unk_0B; + + CutsceneSubCommandEntry_Rumble(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetBodySourceCode() const override; + + size_t GetRawSize() const override; +}; + +class CutsceneCommand_Rumble : public CutsceneCommand +{ +public: + CutsceneCommand_Rumble(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetCommandMacro() const override; +}; + +class CutsceneSubCommandEntry_SetTime : public CutsceneSubCommandEntry +{ +public: + uint8_t hour; + uint8_t minute; + uint32_t unk_08; + + CutsceneSubCommandEntry_SetTime(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetBodySourceCode() const override; + + size_t GetRawSize() const override; +}; + +class CutsceneCommand_SetTime : public CutsceneCommand +{ +public: + CutsceneCommand_SetTime(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetCommandMacro() const override; +}; + +class CutsceneSubCommandEntry_TextBox : public CutsceneSubCommandEntry +{ +public: + uint16_t type; + uint16_t textId1; + uint16_t textId2; + + CutsceneSubCommandEntry_TextBox(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetBodySourceCode() const override; + + size_t GetRawSize() const override; +}; + +class CutsceneCommand_TextBox : public CutsceneCommand +{ +public: + CutsceneCommand_TextBox(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetCommandMacro() const override; +}; + +class CutsceneSubCommandEntry_ActorAction : public CutsceneSubCommandEntry +{ +public: + uint16_t rotX, rotY, rotZ; + int32_t startPosX, startPosY, startPosZ; + int32_t endPosX, endPosY, endPosZ; + float normalX, normalY, normalZ; + + CutsceneSubCommandEntry_ActorAction(const std::vector& rawData, offset_t rawDataIndex); + std::string GetBodySourceCode() const override; + + size_t GetRawSize() const override; +}; + +class CutsceneCommand_ActorAction : public CutsceneCommand +{ +public: + CutsceneCommand_ActorAction(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetCommandMacro() const override; +}; + +class CutsceneCommand_Terminator : public CutsceneCommand +{ +public: + uint16_t base; + uint16_t startFrame; + uint16_t endFrame; + uint16_t unknown; + + CutsceneCommand_Terminator(const std::vector& rawData, offset_t rawDataIndex); + + std::string GenerateSourceCode() const override; + size_t GetCommandSize() const override; +}; diff --git a/tools/ZAPD/ZAPD/ZAPD.vcxproj b/tools/ZAPD/ZAPD/ZAPD.vcxproj index 431abb73b9..f3bb35a3f2 100644 --- a/tools/ZAPD/ZAPD/ZAPD.vcxproj +++ b/tools/ZAPD/ZAPD/ZAPD.vcxproj @@ -1,343 +1,362 @@ - - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 15.0 - {B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36} - ZAPD - 10.0 - ZAPD - - - - Application - true - v142 - MultiByte - - - Application - false - v142 - true - MultiByte - - - Application - true - v142 - MultiByte - - - Application - false - v142 - true - MultiByte - - - - - - - - - - - - - - - - - - - - - $(OutDir);$(ProjectDir)..\lib\libgfxd;$(ProjectDir)..\packages\libpng-v142.1.6.37.2\build\native\lib\x64\v142\Debug\;$(LibraryPath) - $(ProjectDir)..\ZAPDUtils;$(ProjectDir)..\lib\tinyxml2;$(ProjectDir)..\lib\libgfxd;$(ProjectDir)..\lib\elfio;$(ProjectDir)..\lib\stb;$(ProjectDir);$(IncludePath) - - - $(IncludePath) - - - $(SolutionDir)ZAPD\lib\tinyxml2;$(SolutionDir)ZAPD\lib\libgfxd;$(SolutionDir)ZAPD\lib\elfio;$(SolutionDir)ZAPD\lib\stb;$(ProjectDir);$(IncludePath) - $(SolutionDir)ZAPD\lib\libgfxd;$(SolutionDir)x64\Debug;$(SolutionDir)packages\libpng.1.6.28.1\build\native\lib\x64\v140\dynamic\Debug;$(LibraryPath) - - - - Level3 - Disabled - true - true - stdcpp17 - stdc11 - _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - - - true - - - - - Level3 - Disabled - true - true - stdcpp17 - _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - EnableFastChecks - stdc11 - MultiThreadedDebug - - - true - ZAPDUtils.lib;/WHOLEARCHIVE:ExporterExample.lib;%(AdditionalDependencies) - false - - + + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 15.0 + {B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36} + ZAPD + 10.0 + ZAPD + + + + Application + true + v143 + MultiByte + + + Application + false + v143 + true + MultiByte + + + Application + true + v143 + MultiByte + + + Application + false + v143 + true + MultiByte + + + + + + + + + + + + + + + + + + + + + $(OutDir);$(ProjectDir)..\lib\libgfxd;$(ProjectDir)..\packages\libpng-v142.1.6.37.2\build\native\lib\x64\v142\Debug\;$(LibraryPath) + $(ProjectDir)..\ZAPDUtils;$(ProjectDir)..\lib\tinyxml2;$(ProjectDir)..\lib\libgfxd;$(ProjectDir)..\lib\elfio;$(ProjectDir)..\lib\stb;$(ProjectDir);$(IncludePath) + + + $(IncludePath) + + + $(SolutionDir)ZAPD\lib\tinyxml2;$(SolutionDir)ZAPD\lib\libgfxd;$(SolutionDir)ZAPD\lib\elfio;$(SolutionDir)ZAPD\lib\stb;$(ProjectDir);$(IncludePath) + $(SolutionDir)ZAPD\lib\libgfxd;$(SolutionDir)x64\Debug;$(SolutionDir)packages\libpng.1.6.28.1\build\native\lib\x64\v140\dynamic\Debug;$(LibraryPath) + + + + Level3 + Disabled + true + true + stdcpp17 + stdc11 + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + + + true + + cd .. mkdir build\ZAPD -python3 ZAPD/genbuildinfo.py - - - - - Level3 - MaxSpeed - true - true - true - true - - - true - true - - - - - Level3 - MaxSpeed - true - true - true - true - stdcpplatest - _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - - - true - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - - - - - - - - - - - - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - - - + python ZAPD/genbuildinfo.py + + + + + Level3 + Disabled + true + true + stdcpp17 + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + EnableFastChecks + stdc11 + MultiThreadedDebug + + + true + ZAPDUtils.lib;/WHOLEARCHIVE:ExporterExample.lib;%(AdditionalDependencies) + false + + + cd .. +mkdir build\ZAPD + python ZAPD/genbuildinfo.py + + + + + Level3 + MaxSpeed + true + true + true + true + + + true + true + + + cd .. +mkdir build\ZAPD + python ZAPD/genbuildinfo.py + + + + + Level3 + MaxSpeed + true + true + true + true + stdcpplatest + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + + + true + true + + + cd .. +mkdir build\ZAPD + python ZAPD/genbuildinfo.py + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + + + + + + + + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + + \ No newline at end of file diff --git a/tools/ZAPD/ZAPD/ZAPD.vcxproj.filters b/tools/ZAPD/ZAPD/ZAPD.vcxproj.filters index b8a7daaacf..4de236fad4 100644 --- a/tools/ZAPD/ZAPD/ZAPD.vcxproj.filters +++ b/tools/ZAPD/ZAPD/ZAPD.vcxproj.filters @@ -1,554 +1,566 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;ipp;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - {02148456-5068-4613-8478-f10addc58e70} - - - {bcab3136-95ba-4839-833c-43d78ad6e335} - - - {dc06ed84-f6fe-4277-80f3-d62bd5cdbb98} - - - {6049c045-bc38-4221-b29e-ca6d4d8af4aa} - - - {490e3a08-047b-48d3-ab53-3a860a3b92aa} - - - {26c06845-8e8e-4b79-ad18-07c4f9c0f801} - - - {d45c420d-2378-47ac-92c5-80db9475c195} - - - {03cc56a2-e0e8-4167-80a0-98fb900a959a} - - - {73db0879-6df8-4f6a-8cc2-a1f836e9e796} - - - {be9a5be0-ec6a-4200-8e39-bb58c7da7aa8} - - - {7ee79d97-c6a8-4e82-93ef-37981f4d7838} - - - {85600275-99fe-491d-8189-bcc3dc1a8903} - - - {ba9990b0-1082-48bb-874c-6108534b5455} - - - {ce9d91b0-ba20-4296-bc2d-8630965bb392} - - - {730beb67-6d59-4849-9d9b-702c4a565fc0} - - - - - Source Files - - - Source Files\Z64\ZRoom - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files - - - Source Files\Z64 - - - Source Files\Libraries\libgfxd - - - Source Files\Libraries\libgfxd - - - Source Files\Libraries\libgfxd - - - Source Files\Libraries\libgfxd - - - Source Files\Libraries\libgfxd - - - Source Files\Libraries\libgfxd - - - Source Files\Libraries\libgfxd - - - Source Files\Z64 - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64 - - - Source Files - - - Source Files - - - Source Files\Z64 - - - Source Files - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files - - - Source Files\Z64 - - - Source Files - - - - - Header Files\Z64\ZRoom - - - Header Files\Z64\ZRoom - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Libraries\elfio - - - Header Files\Libraries\elfio - - - Header Files\Libraries\elfio - - - Header Files\Libraries\elfio - - - Header Files\Libraries\elfio - - - Header Files\Libraries\elfio - - - Header Files\Libraries\elfio - - - Header Files\Libraries\elfio - - - Header Files\Libraries\elfio - - - Header Files\Libraries\elfio - - - Header Files\Libraries\elfio - - - Header Files\Libraries\elfio - - - Header Files - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Libraries - - - Header Files\Libraries - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files - - - Header Files\Z64 - - - Header Files - - - Header Files\Z64 - - - Header Files\Libraries\libgfxd - - - Header Files\Libraries\libgfxd - - - Header Files\Libraries\libgfxd - - - Header Files\Z64 - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files\Z64\ZRoom\Commands - - - Header Files - - - Header Files\Z64 - - - Header Files - - - Header Files\Z64 - - - Header Files - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files - - - - - Resource Files - - - any\any - - - NuGet - - - - - + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + {02148456-5068-4613-8478-f10addc58e70} + + + {bcab3136-95ba-4839-833c-43d78ad6e335} + + + {dc06ed84-f6fe-4277-80f3-d62bd5cdbb98} + + + {6049c045-bc38-4221-b29e-ca6d4d8af4aa} + + + {490e3a08-047b-48d3-ab53-3a860a3b92aa} + + + {26c06845-8e8e-4b79-ad18-07c4f9c0f801} + + + {d45c420d-2378-47ac-92c5-80db9475c195} + + + {03cc56a2-e0e8-4167-80a0-98fb900a959a} + + + {73db0879-6df8-4f6a-8cc2-a1f836e9e796} + + + {be9a5be0-ec6a-4200-8e39-bb58c7da7aa8} + + + {7ee79d97-c6a8-4e82-93ef-37981f4d7838} + + + {85600275-99fe-491d-8189-bcc3dc1a8903} + + + {ba9990b0-1082-48bb-874c-6108534b5455} + + + {ce9d91b0-ba20-4296-bc2d-8630965bb392} + + + {730beb67-6d59-4849-9d9b-702c4a565fc0} + + + + + Source Files + + + Source Files\Z64\ZRoom + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files + + + Source Files\Z64 + + + Source Files\Libraries\libgfxd + + + Source Files\Libraries\libgfxd + + + Source Files\Libraries\libgfxd + + + Source Files\Libraries\libgfxd + + + Source Files\Libraries\libgfxd + + + Source Files\Libraries\libgfxd + + + Source Files\Libraries\libgfxd + + + Source Files\Z64 + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64 + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64 + + + Source Files + + + Source Files + + + Source Files\Z64 + + + Source Files + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files + + + Source Files\Z64 + + + Source Files + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64 + + + + + Header Files\Z64\ZRoom + + + Header Files\Z64\ZRoom + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Libraries\elfio + + + Header Files\Libraries\elfio + + + Header Files\Libraries\elfio + + + Header Files\Libraries\elfio + + + Header Files\Libraries\elfio + + + Header Files\Libraries\elfio + + + Header Files\Libraries\elfio + + + Header Files\Libraries\elfio + + + Header Files\Libraries\elfio + + + Header Files\Libraries\elfio + + + Header Files\Libraries\elfio + + + Header Files\Libraries\elfio + + + Header Files + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Libraries + + + Header Files\Libraries + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files + + + Header Files\Z64 + + + Header Files + + + Header Files\Z64 + + + Header Files\Libraries\libgfxd + + + Header Files\Libraries\libgfxd + + + Header Files\Libraries\libgfxd + + + Header Files\Z64 + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64 + + + Header Files\Z64\ZRoom\Commands + + + Header Files + + + Header Files\Z64 + + + Header Files + + + Header Files\Z64 + + + Header Files + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files\Z64 + + + + + Resource Files + + + any\any + + + NuGet + + + + + \ No newline at end of file diff --git a/tools/ZAPD/ZAPD/ZArray.cpp b/tools/ZAPD/ZAPD/ZArray.cpp index b6d9e50e50..d4f55d6c85 100644 --- a/tools/ZAPD/ZAPD/ZArray.cpp +++ b/tools/ZAPD/ZAPD/ZArray.cpp @@ -106,6 +106,7 @@ std::string ZArray::GetBodySourceCode() const case ZResourceType::Pointer: case ZResourceType::Scalar: case ZResourceType::Vertex: + case ZResourceType::CollisionPoly: output += resList.at(i)->GetBodySourceCode(); break; diff --git a/tools/ZAPD/ZAPD/ZCollision.cpp b/tools/ZAPD/ZAPD/ZCollision.cpp index 0b04ca5c17..992332db78 100644 --- a/tools/ZAPD/ZAPD/ZCollision.cpp +++ b/tools/ZAPD/ZAPD/ZCollision.cpp @@ -61,18 +61,22 @@ void ZCollisionHeader::ParseRawData() currentPtr += vec.GetRawDataSize(); vertices.push_back(vec); } - + for (uint16_t i = 0; i < numPolygons; i++) - polygons.push_back(PolygonEntry(rawData, polySegmentOffset + (i * 16))); + { + ZCollisionPoly poly(parent); + poly.SetRawDataIndex(polySegmentOffset + (i * 16)); + poly.ParseRawData(); + polygons.push_back(poly); + } uint16_t highestPolyType = 0; - for (PolygonEntry poly : polygons) + for (ZCollisionPoly poly : polygons) { if (poly.type > highestPolyType) highestPolyType = poly.type; } - for (uint16_t i = 0; i < highestPolyType + 1; i++) polygonTypes.push_back( BitConverter::ToUInt64BE(rawData, polyTypeDefSegmentOffset + (i * 8))); @@ -149,16 +153,13 @@ void ZCollisionHeader::DeclareReferences(const std::string& prefix) for (size_t i = 0; i < polygons.size(); i++) { - declaration += StringHelper::Sprintf( - "\t{ 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X },", - polygons[i].type, polygons[i].vtxA, polygons[i].vtxB, polygons[i].vtxC, - polygons[i].a, polygons[i].b, polygons[i].c, polygons[i].d); + declaration += StringHelper::Sprintf("\t%s,", polygons[i].GetBodySourceCode().c_str()); if (i + 1 < polygons.size()) declaration += "\n"; } parent->AddDeclarationArray( - polySegmentOffset, DeclarationAlignment::Align4, polygons.size() * 16, "CollisionPoly", + polySegmentOffset, DeclarationAlignment::Align4, polygons.size() * 16, polygons[0].GetSourceTypeName().c_str(), StringHelper::Sprintf("%sPolygons", auxName.c_str()), polygons.size(), declaration); } @@ -254,18 +255,6 @@ size_t ZCollisionHeader::GetRawDataSize() const return 44; } -PolygonEntry::PolygonEntry(const std::vector& rawData, uint32_t rawDataIndex) -{ - type = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - vtxA = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - vtxB = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); - vtxC = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); - a = BitConverter::ToUInt16BE(rawData, rawDataIndex + 8); - b = BitConverter::ToUInt16BE(rawData, rawDataIndex + 10); - c = BitConverter::ToUInt16BE(rawData, rawDataIndex + 12); - d = BitConverter::ToUInt16BE(rawData, rawDataIndex + 14); -} - WaterBoxHeader::WaterBoxHeader(const std::vector& rawData, uint32_t rawDataIndex) { xMin = BitConverter::ToInt16BE(rawData, rawDataIndex + 0); diff --git a/tools/ZAPD/ZAPD/ZCollision.h b/tools/ZAPD/ZAPD/ZCollision.h index 222fd25f9a..7481a8526b 100644 --- a/tools/ZAPD/ZAPD/ZCollision.h +++ b/tools/ZAPD/ZAPD/ZCollision.h @@ -4,7 +4,9 @@ #include "ZResource.h" #include "ZRoom/ZRoom.h" #include "ZVector.h" +#include "ZCollisionPoly.h" +#if 0 class PolygonEntry { public: @@ -14,6 +16,7 @@ public: PolygonEntry(const std::vector& rawData, uint32_t rawDataIndex); }; +#endif class WaterBoxHeader { @@ -78,7 +81,7 @@ public: waterBoxSegmentOffset; std::vector vertices; - std::vector polygons; + std::vector polygons; std::vector polygonTypes; std::vector waterBoxes; CameraDataList* camData = nullptr; diff --git a/tools/ZAPD/ZAPD/ZCollisionPoly.cpp b/tools/ZAPD/ZAPD/ZCollisionPoly.cpp new file mode 100644 index 0000000000..eb2c14ab9b --- /dev/null +++ b/tools/ZAPD/ZAPD/ZCollisionPoly.cpp @@ -0,0 +1,76 @@ +#include "ZCollisionPoly.h" + +#include "Globals.h" +#include "Utils/BitConverter.h" +#include "Utils/StringHelper.h" + +REGISTER_ZFILENODE(CollisionPoly, ZCollisionPoly); + +ZCollisionPoly::ZCollisionPoly(ZFile* nParent) : ZResource(nParent) +{ +} + +ZCollisionPoly::~ZCollisionPoly() +{ +} + +void ZCollisionPoly::ParseRawData() +{ + const auto& rawData = parent->GetRawData(); + type = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); + + vtxA = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); + vtxB = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); + vtxC = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); + + normX = BitConverter::ToUInt16BE(rawData, rawDataIndex + 8); + normY = BitConverter::ToUInt16BE(rawData, rawDataIndex + 10); + normZ = BitConverter::ToUInt16BE(rawData, rawDataIndex + 12); + + dist = BitConverter::ToUInt16BE(rawData, rawDataIndex + 14); +} + +void ZCollisionPoly::DeclareReferences(const std::string& prefix) +{ + std::string declaration; + std::string auxName = name; + + if (name == "") + auxName = GetDefaultName(prefix); + + parent->AddDeclaration(rawDataIndex, DeclarationAlignment::Align4,GetRawDataSize(), GetSourceTypeName(), name.c_str(),GetBodySourceCode()); +} + +std::string ZCollisionPoly::GetBodySourceCode() const +{ + std::string declaration; + + declaration += StringHelper::Sprintf("{0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X}", type, vtxA, vtxB, vtxC, normX, normY, normZ, dist); + return declaration; +} + +std::string ZCollisionPoly::GetDefaultName(const std::string& prefix) const +{ + return StringHelper::Sprintf("%sCollisionPoly_%06X", prefix.c_str(), rawDataIndex); +} + + +ZResourceType ZCollisionPoly::GetResourceType() const +{ + return ZResourceType::CollisionPoly; +} + +size_t ZCollisionPoly::GetRawDataSize() const +{ + return 16; +} + +std::string ZCollisionPoly::GetSourceTypeName() const +{ + return "CollisionPoly"; +} + +bool ZCollisionPoly::DoesSupportArray() const +{ + return true; +} \ No newline at end of file diff --git a/tools/ZAPD/ZAPD/ZCollisionPoly.h b/tools/ZAPD/ZAPD/ZCollisionPoly.h new file mode 100644 index 0000000000..9596d2253d --- /dev/null +++ b/tools/ZAPD/ZAPD/ZCollisionPoly.h @@ -0,0 +1,30 @@ +#pragma once + +#include "ZFile.h" +#include "ZResource.h" + + +class ZCollisionPoly : public ZResource +{ +public: + uint16_t type; + uint16_t vtxA, vtxB, vtxC; + uint16_t normX, normY, normZ; + uint16_t dist; + + ZCollisionPoly(ZFile* nParent); + ~ZCollisionPoly(); + + void ParseRawData() override; + void DeclareReferences(const std::string& prefix) override; + + std::string GetBodySourceCode() const override; + std::string GetDefaultName(const std::string& prefix) const override; + + std::string GetSourceTypeName() const override; + ZResourceType GetResourceType() const override; + + bool DoesSupportArray() const override; + + size_t GetRawDataSize() const override; +}; \ No newline at end of file diff --git a/tools/ZAPD/ZAPD/ZCutscene.cpp b/tools/ZAPD/ZAPD/ZCutscene.cpp index 71bb690c76..62f814b13d 100644 --- a/tools/ZAPD/ZAPD/ZCutscene.cpp +++ b/tools/ZAPD/ZAPD/ZCutscene.cpp @@ -1,5 +1,9 @@ #include "ZCutscene.h" +#include + +#include "Globals.h" +#include "OtherStructs/CutsceneMM_Commands.h" #include "Utils/BitConverter.h" #include "Utils/StringHelper.h" #include "WarningHandler.h" @@ -7,7 +11,7 @@ REGISTER_ZFILENODE(Cutscene, ZCutscene); -ZCutscene::ZCutscene(ZFile* nParent) : ZCutsceneBase(nParent) +ZCutscene::ZCutscene(ZFile* nParent) : ZResource(nParent) { } @@ -16,91 +20,20 @@ ZCutscene::~ZCutscene() for (CutsceneCommand* cmd : commands) delete cmd; } -CutsceneCommandSetCameraPos::~CutsceneCommandSetCameraPos() -{ - for (auto e : entries) - delete e; -} - -CutsceneCommandSpecialAction::~CutsceneCommandSpecialAction() -{ - for (auto e : entries) - delete e; -} - -CutsceneCommandFadeBGM::~CutsceneCommandFadeBGM() -{ - for (auto e : entries) - delete e; -} - -CutsceneCommandPlayBGM::~CutsceneCommandPlayBGM() -{ - for (auto e : entries) - delete e; -} - -CutsceneCommandStopBGM::~CutsceneCommandStopBGM() -{ - for (auto e : entries) - delete e; -} - -CutsceneCommandEnvLighting::~CutsceneCommandEnvLighting() -{ - for (auto e : entries) - delete e; -} - -CutsceneCommandUnknown9::~CutsceneCommandUnknown9() -{ - for (auto e : entries) - delete e; -} - -CutsceneCommandUnknown::~CutsceneCommandUnknown() -{ - for (auto e : entries) - delete e; -} - -CutsceneCommandDayTime::~CutsceneCommandDayTime() -{ - for (auto e : entries) - delete e; -} - -CutsceneCommandTextbox::~CutsceneCommandTextbox() -{ - for (auto e : entries) - delete e; -} - -CutsceneCommandActorAction::~CutsceneCommandActorAction() -{ - for (auto e : entries) - delete e; -} - -CutsceneCommandSceneTransFX::~CutsceneCommandSceneTransFX() -{ -} std::string ZCutscene::GetBodySourceCode() const { std::string output = ""; - uint32_t curPtr = 0; output += StringHelper::Sprintf(" CS_BEGIN_CUTSCENE(%i, %i),\n", commands.size(), endFrame); for (size_t i = 0; i < commands.size(); i++) { CutsceneCommand* cmd = commands[i]; - output += " " + cmd->GenerateSourceCode(curPtr); - curPtr += cmd->GetCommandSize(); + output += " " + cmd->GenerateSourceCode(); } - output += StringHelper::Sprintf(" CS_END(),\n", commands.size(), endFrame); + output += StringHelper::Sprintf(" CS_END(),", commands.size(), endFrame); return output; } @@ -115,12 +48,19 @@ size_t ZCutscene::GetRawDataSize() const for (size_t i = 0; i < commands.size(); i++) { CutsceneCommand* cmd = commands[i]; + size += cmd->GetCommandSize(); - size += 4; } // End - size += 8; + if (Globals::Instance->game == ZGame::MM_RETAIL) + { + size += 4; + } + else + { + size += 8; + } return size; } @@ -135,153 +75,68 @@ void ZCutscene::ParseRawData() commands = std::vector(); endFrame = BitConverter::ToInt32BE(rawData, rawDataIndex + 4); - uint32_t currentPtr = rawDataIndex + 8; + offset_t currentPtr = rawDataIndex + 8; for (int32_t i = 0; i < numCommands; i++) { - int32_t id = BitConverter::ToInt32BE(rawData, currentPtr); + uint32_t id = BitConverter::ToUInt32BE(rawData, currentPtr); - if (id == -1) + if (id == 0xFFFFFFFF) break; - CutsceneCommands cmdID = (CutsceneCommands)GetCommandFromID(id); + if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_DEBUG) + { + printf("Cutscene Command: 0x%X (%i)\n", id, id); + } + currentPtr += 4; - int32_t numEntries = 1; + CutsceneCommand* cmd = nullptr; - for (int32_t j = 0; j < numEntries; j++) + if (Globals::Instance->game == ZGame::MM_RETAIL) { - CutsceneCommand* cmd = nullptr; - - switch (cmdID) - { - case CutsceneCommands::Cmd00: - break; - case CutsceneCommands::SetCameraPos: - cmd = new CutsceneCommandSetCameraPos(rawData, currentPtr); - break; - case CutsceneCommands::SetCameraFocus: - cmd = new CutsceneCommandSetCameraPos(rawData, currentPtr); - break; - case CutsceneCommands::SpecialAction: - cmd = new CutsceneCommandSpecialAction(rawData, currentPtr); - break; - case CutsceneCommands::SetLighting: - cmd = new CutsceneCommandEnvLighting(rawData, currentPtr); - break; - case CutsceneCommands::SetCameraPosLink: - cmd = new CutsceneCommandSetCameraPos(rawData, currentPtr); - break; - case CutsceneCommands::SetCameraFocusLink: - cmd = new CutsceneCommandSetCameraPos(rawData, currentPtr); - break; - case CutsceneCommands::Cmd07: - break; - case CutsceneCommands::Cmd08: - break; - case CutsceneCommands::Cmd09: - cmd = new CutsceneCommandUnknown9(rawData, currentPtr); - break; - case CutsceneCommands::Textbox: - cmd = new CutsceneCommandTextbox(rawData, currentPtr); - break; - case CutsceneCommands::Unknown: - cmd = new CutsceneCommandUnknown(rawData, currentPtr); - break; - case CutsceneCommands::SetActorAction0: - case CutsceneCommands::SetActorAction1: - case CutsceneCommands::SetActorAction2: - case CutsceneCommands::SetActorAction3: - case CutsceneCommands::SetActorAction4: - case CutsceneCommands::SetActorAction5: - case CutsceneCommands::SetActorAction6: - case CutsceneCommands::SetActorAction7: - case CutsceneCommands::SetActorAction8: - case CutsceneCommands::SetActorAction9: - case CutsceneCommands::SetActorAction10: - cmd = new CutsceneCommandActorAction(rawData, currentPtr); - break; - case CutsceneCommands::SetSceneTransFX: - cmd = new CutsceneCommandSceneTransFX(rawData, currentPtr); - break; - case CutsceneCommands::Nop: - cmd = new CutsceneCommandNop(rawData, currentPtr); - break; - case CutsceneCommands::PlayBGM: - cmd = new CutsceneCommandPlayBGM(rawData, currentPtr); - break; - case CutsceneCommands::StopBGM: - cmd = new CutsceneCommandStopBGM(rawData, currentPtr); - break; - case CutsceneCommands::FadeBGM: - cmd = new CutsceneCommandFadeBGM(rawData, currentPtr); - break; - case CutsceneCommands::SetTime: - cmd = new CutsceneCommandDayTime(rawData, currentPtr); - break; - case CutsceneCommands::Terminator: - cmd = new CutsceneCommandTerminator(rawData, currentPtr); - break; - case CutsceneCommands::End: - cmd = new CutsceneCommandEnd(rawData, currentPtr); - break; - case CutsceneCommands::Error: - HANDLE_WARNING_RESOURCE(WarningType::NotImplemented, parent, this, rawDataIndex, - StringHelper::Sprintf("cutscene command error %d", cmdID), - ""); - break; - } - - cmd->commandIndex = i; - cmd->commandID = (uint32_t)id; - currentPtr += (uint32_t)cmd->GetCommandSize(); - - commands.push_back(cmd); + cmd = GetCommandMM(id, currentPtr); } + else + { + cmd = GetCommandOoT(id, currentPtr); + } + + if (cmd == nullptr) + { + HANDLE_WARNING_RESOURCE( + WarningType::NotImplemented, parent, this, rawDataIndex, + StringHelper::Sprintf("Cutscene command not implemented"), + StringHelper::Sprintf("Command ID: 0x%X\nIndex: %d\ncurrentPtr-rawDataIndex: 0x%X", + id, i, currentPtr - rawDataIndex)); + cmd = new CutsceneMMCommand_NonImplemented(rawData, currentPtr); + } + + assert(cmd != nullptr); + + cmd->commandIndex = i; + cmd->SetCommandID(id); + size_t commmandSize = cmd->GetCommandSize(); + if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_DEBUG) + { + printf("\t Command size: 0x%zX (%zu)\n", commmandSize, commmandSize); + } + currentPtr += commmandSize - 4; + + commands.push_back(cmd); } } -CutsceneCommands ZCutscene::GetCommandFromID(int32_t id) +CutsceneCommand* ZCutscene::GetCommandOoT(uint32_t id, offset_t currentPtr) const { + CutsceneCommands cmdID = static_cast(id); + + const auto& rawData = parent->GetRawData(); + switch (id) { - case 0x0003: - return CutsceneCommands::SpecialAction; - case 0x0004: - return CutsceneCommands::SetLighting; - case 0x0056: - return CutsceneCommands::PlayBGM; - case 0x0057: - return CutsceneCommands::StopBGM; - case 0x007C: - return CutsceneCommands::FadeBGM; - case 0x0009: - return CutsceneCommands::Cmd09; - case 0x0013: - return CutsceneCommands::Textbox; - case 0x008C: - return CutsceneCommands::SetTime; - case 0x0001: - return CutsceneCommands::SetCameraPos; - case 0x0002: - return CutsceneCommands::SetCameraFocus; - case 0x0005: - return CutsceneCommands::SetCameraPosLink; - case 0x0006: - return CutsceneCommands::SetCameraFocusLink; - case 0x0007: - return CutsceneCommands::Cmd07; - case 0x0008: - return CutsceneCommands::Cmd08; - case 0x03E8: - return CutsceneCommands::Terminator; - case 0xFFFF: - return CutsceneCommands::End; - case 0x002D: - return CutsceneCommands::SetSceneTransFX; - case 10: - return CutsceneCommands::SetActorAction0; - case 15: + case 10: // CutsceneCommands::SetPlayerAction + case 15: // CutsceneCommands::SetActorAction1 case 17: case 18: case 23: @@ -299,8 +154,7 @@ CutsceneCommands ZCutscene::GetCommandFromID(int32_t id) case 138: case 139: case 144: - return CutsceneCommands::SetActorAction1; - case 14: + case 14: // CutsceneCommands::SetActorAction2 case 16: case 24: case 35: @@ -318,8 +172,7 @@ CutsceneCommands ZCutscene::GetCommandFromID(int32_t id) case 125: case 131: case 141: - return CutsceneCommands::SetActorAction2; - case 25: + case 25: // CutsceneCommands::SetActorAction3 case 36: case 41: case 50: @@ -332,8 +185,7 @@ CutsceneCommands ZCutscene::GetCommandFromID(int32_t id) case 121: case 126: case 132: - return CutsceneCommands::SetActorAction3; - case 29: + case 29: // CutsceneCommands::SetActorAction4 case 37: case 42: case 51: @@ -346,8 +198,7 @@ CutsceneCommands ZCutscene::GetCommandFromID(int32_t id) case 108: case 127: case 133: - return CutsceneCommands::SetActorAction4; - case 30: + case 30: // CutsceneCommands::SetActorAction5 case 38: case 43: case 47: @@ -356,16 +207,14 @@ CutsceneCommands ZCutscene::GetCommandFromID(int32_t id) case 83: case 128: case 135: - return CutsceneCommands::SetActorAction5; - case 44: + case 44: // CutsceneCommands::SetActorAction6 case 55: case 77: case 84: case 90: case 129: case 136: - return CutsceneCommands::SetActorAction6; - case 31: + case 31: // CutsceneCommands::SetActorAction7 case 52: case 57: case 58: @@ -373,19 +222,17 @@ CutsceneCommands ZCutscene::GetCommandFromID(int32_t id) case 115: case 130: case 137: - return CutsceneCommands::SetActorAction7; - case 49: + case 49: // CutsceneCommands::SetActorAction8 case 60: case 89: case 111: case 114: case 134: case 142: - return CutsceneCommands::SetActorAction8; - case 62: - return CutsceneCommands::SetActorAction9; - case 143: - return CutsceneCommands::SetActorAction10; + case 62: // CutsceneCommands::SetActorAction9 + case 143: // CutsceneCommands::SetActorAction10 + return new CutsceneCommand_ActorAction(rawData, currentPtr); + case 0x0B: case 0x0D: case 0x1A: @@ -403,835 +250,120 @@ CutsceneCommands ZCutscene::GetCommandFromID(int32_t id) case 0x70: case 0x71: case 0x4A: - return CutsceneCommands::Unknown; + return new CutsceneCommand_GenericCmd(rawData, currentPtr, cmdID); } - HANDLE_WARNING_RESOURCE( - WarningType::NotImplemented, parent, this, rawDataIndex, - StringHelper::Sprintf("could not identify cutscene command. ID 0x%04X", id), ""); - - return CutsceneCommands::Error; -} - -ZResourceType ZCutscene::GetResourceType() const -{ - return ZResourceType::Cutscene; -} - -CutsceneCommand::CutsceneCommand([[maybe_unused]] const std::vector& rawData, - [[maybe_unused]] uint32_t rawDataIndex) -{ -} - -CutsceneCommand::~CutsceneCommand() -{ -} - -std::string CutsceneCommand::GetCName() -{ - return "SCmdCutsceneData"; -} - -std::string CutsceneCommand::GenerateSourceCode(uint32_t baseAddress) -{ - return StringHelper::Sprintf("%s CutsceneData%04XCmd%02X = { 0x%02X,", GetCName().c_str(), - baseAddress, commandIndex, commandID); -} - -size_t CutsceneCommand::GetCommandSize() -{ - return 4; -} - -CutsceneCameraPoint::CutsceneCameraPoint(const std::vector& rawData, uint32_t rawDataIndex) -{ - continueFlag = rawData.at(rawDataIndex + 0); - cameraRoll = rawData.at(rawDataIndex + 1); - nextPointFrame = BitConverter::ToInt16BE(rawData, rawDataIndex + 2); - viewAngle = BitConverter::ToFloatBE(rawData, rawDataIndex + 4); - - posX = BitConverter::ToInt16BE(rawData, rawDataIndex + 8); - posY = BitConverter::ToInt16BE(rawData, rawDataIndex + 10); - posZ = BitConverter::ToInt16BE(rawData, rawDataIndex + 12); - - unused = BitConverter::ToInt16BE(rawData, rawDataIndex + 14); -} - -CutsceneCommandSetCameraPos::CutsceneCommandSetCameraPos(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); - unused = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); - - entries = std::vector(); - - bool shouldContinue = true; - - uint32_t currentPtr = rawDataIndex + 8; - - while (shouldContinue) + switch (cmdID) { - CutsceneCameraPoint* camPoint = new CutsceneCameraPoint(rawData, currentPtr); - entries.push_back(camPoint); + case CutsceneCommands::Misc: + case CutsceneCommands::SetLighting: + case CutsceneCommands::PlayBGM: + case CutsceneCommands::StopBGM: + case CutsceneCommands::FadeBGM: + return new CutsceneCommand_GenericCmd(rawData, currentPtr, cmdID); - if (camPoint->continueFlag == -1) - shouldContinue = false; + case CutsceneCommands::SetCameraPos: + case CutsceneCommands::SetCameraFocus: + case CutsceneCommands::SetCameraPosLink: + case CutsceneCommands::SetCameraFocusLink: + return new CutsceneCommandSetCameraPos(rawData, currentPtr); - currentPtr += 16; + case CutsceneCommands::Cmd07: + break; + case CutsceneCommands::Cmd08: + break; + case CutsceneCommands::Cmd09: + return new CutsceneCommand_Rumble(rawData, currentPtr); + case CutsceneCommands::Textbox: + return new CutsceneCommand_TextBox(rawData, currentPtr); + + case CutsceneCommands::SetPlayerAction: + case CutsceneCommands::SetActorAction1: + case CutsceneCommands::SetActorAction2: + case CutsceneCommands::SetActorAction3: + case CutsceneCommands::SetActorAction4: + case CutsceneCommands::SetActorAction5: + case CutsceneCommands::SetActorAction6: + case CutsceneCommands::SetActorAction7: + case CutsceneCommands::SetActorAction8: + case CutsceneCommands::SetActorAction9: + case CutsceneCommands::SetActorAction10: + break; + + case CutsceneCommands::SetSceneTransFX: + return new CutsceneCommandSceneTransFX(rawData, currentPtr); + + case CutsceneCommands::SetTime: + return new CutsceneCommand_SetTime(rawData, currentPtr); + case CutsceneCommands::Terminator: + return new CutsceneCommand_Terminator(rawData, currentPtr); } + + return nullptr; } -// TODO -std::string CutsceneCommandSetCameraPos::GetCName() +CutsceneCommand* ZCutscene::GetCommandMM(uint32_t id, offset_t currentPtr) const { - return ""; -} + CutsceneMMCommands cmdID = static_cast(id); -std::string CutsceneCommandSetCameraPos::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; + const auto& rawData = parent->GetRawData(); - std::string listStr; - std::string posStr; - - if (commandID == (int32_t)CutsceneCommands::SetCameraFocus) + if (((id >= 100) && (id < 150)) || (id == 201) || ((id >= 450) && (id < 600))) { - listStr = "CS_CAM_FOCUS_POINT_LIST"; - posStr = "CS_CAM_FOCUS_POINT"; + return new CutsceneCommand_ActorAction(rawData, currentPtr); } - else if (commandID == (int32_t)CutsceneCommands::SetCameraFocusLink) + + switch (cmdID) { - listStr = "CS_CAM_FOCUS_POINT_PLAYER_LIST"; - posStr = "CS_CAM_FOCUS_POINT_PLAYER"; - } - else if (commandID == (int32_t)CutsceneCommands::SetCameraPosLink) - { - listStr = "CS_CAM_POS_PLAYER_LIST"; - posStr = "CS_CAM_POS_PLAYER"; - } - else - { - listStr = "CS_CAM_POS_LIST"; - posStr = "CS_CAM_POS"; + case CutsceneMMCommands::CS_CMD_MISC: + case CutsceneMMCommands::CS_CMD_SET_LIGHTING: + case CutsceneMMCommands::CS_CMD_SCENE_TRANS_FX: + case CutsceneMMCommands::CS_CMD_MOTIONBLUR: + case CutsceneMMCommands::CS_CMD_GIVETATL: + case CutsceneMMCommands::CS_CMD_PLAYSEQ: + case CutsceneMMCommands::CS_CMD_130: + case CutsceneMMCommands::CS_CMD_131: + case CutsceneMMCommands::CS_CMD_132: + case CutsceneMMCommands::CS_CMD_STOPSEQ: + case CutsceneMMCommands::CS_CMD_PLAYAMBIENCE: + case CutsceneMMCommands::CS_CMD_FADEAMBIENCE: + case CutsceneMMCommands::CS_CMD_TERMINATOR: + case CutsceneMMCommands::CS_CMD_CHOOSE_CREDITS_SCENES: + + case CutsceneMMCommands::CS_CMD_UNK_FA: + case CutsceneMMCommands::CS_CMD_UNK_FE: + case CutsceneMMCommands::CS_CMD_UNK_FF: + case CutsceneMMCommands::CS_CMD_UNK_100: + case CutsceneMMCommands::CS_CMD_UNK_101: + case CutsceneMMCommands::CS_CMD_UNK_102: + case CutsceneMMCommands::CS_CMD_UNK_103: + case CutsceneMMCommands::CS_CMD_UNK_104: + case CutsceneMMCommands::CS_CMD_UNK_105: + case CutsceneMMCommands::CS_CMD_UNK_108: + case CutsceneMMCommands::CS_CMD_UNK_109: + case CutsceneMMCommands::CS_CMD_UNK_12D: + return new CutsceneMMCommand_GenericCmd(rawData, currentPtr, cmdID); + + case CutsceneMMCommands::CS_CMD_TEXTBOX: + return new CutsceneCommand_TextBox(rawData, currentPtr); + case CutsceneMMCommands::CS_CMD_CAMERA: + return new CutsceneMMCommand_Camera(rawData, currentPtr); + case CutsceneMMCommands::CS_CMD_FADESCREEN: + return new CutsceneMMCommand_FadeScreen(rawData, currentPtr); + case CutsceneMMCommands::CS_CMD_FADESEQ: + return new CutsceneMMCommand_FadeSeq(rawData, currentPtr); + case CutsceneMMCommands::CS_CMD_SETTIME: + return new CutsceneCommand_SetTime(rawData, currentPtr); + case CutsceneMMCommands::CS_CMD_SET_PLAYER_ACTION: + return new CutsceneCommand_ActorAction(rawData, currentPtr); + case CutsceneMMCommands::CS_CMD_RUMBLE: + return new CutsceneCommand_Rumble(rawData, currentPtr); } - result += StringHelper::Sprintf("%s(%i, %i),\n", listStr.c_str(), startFrame, endFrame); - - for (size_t i = 0; i < entries.size(); i++) - { - std::string continueMacro = "CS_CMD_CONTINUE"; - if (entries[i]->continueFlag != 0) - continueMacro = "CS_CMD_STOP"; - result += StringHelper::Sprintf(" %s(%s, 0x%02X, %i, %ff, %i, %i, %i, 0x%04X),\n", - posStr.c_str(), continueMacro.c_str(), - entries[i]->cameraRoll, entries[i]->nextPointFrame, - entries[i]->viewAngle, entries[i]->posX, entries[i]->posY, - entries[i]->posZ, entries[i]->unused); - } - - return result; -} - -size_t CutsceneCommandSetCameraPos::GetCommandSize() -{ - return 8 + (entries.size() * 16); -} - -MusicFadeEntry::MusicFadeEntry(const std::vector& rawData, uint32_t rawDataIndex) -{ - base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); - unknown0 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); - unknown1 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 8); - unknown2 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 12); - unknown3 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 16); - unknown4 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 20); - unknown5 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 24); - unknown6 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 28); - unknown7 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 32); - unknown8 = BitConverter::ToUInt32BE(rawData, - rawDataIndex + 36); // Macro hardcodes it as zero - unknown9 = BitConverter::ToUInt32BE(rawData, - rawDataIndex + 40); // Macro hardcodes it as zero - unknown10 = BitConverter::ToUInt32BE(rawData, - rawDataIndex + 44); // Macro hardcodes it as zero -} - -CutsceneCommandFadeBGM::CutsceneCommandFadeBGM(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - uint32_t numEntries = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0); - - rawDataIndex += 4; - - for (uint32_t i = 0; i < numEntries; i++) - { - entries.push_back(new MusicFadeEntry(rawData, rawDataIndex)); - rawDataIndex += 0x30; - } -} - -std::string CutsceneCommandFadeBGM::GetCName() -{ - return "CsCmdMusicFade"; -} - -std::string CutsceneCommandFadeBGM::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; - - result += StringHelper::Sprintf("CS_FADE_BGM_LIST(%i),\n", entries.size()); - - for (size_t i = 0; i < entries.size(); i++) - { - result += StringHelper::Sprintf( - " CS_FADE_BGM(%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i),\n", entries[i]->base, - entries[i]->startFrame, entries[i]->endFrame, entries[i]->unknown0, - entries[i]->unknown1, entries[i]->unknown2, entries[i]->unknown3, entries[i]->unknown4, - entries[i]->unknown5, entries[i]->unknown6, entries[i]->unknown7); - } - - return result; -} - -size_t CutsceneCommandFadeBGM::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + 0x30 * entries.size(); -} - -MusicChangeEntry::MusicChangeEntry(const std::vector& rawData, uint32_t rawDataIndex) -{ - sequence = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); - unknown0 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); - unknown1 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 8); - unknown2 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 12); - unknown3 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 16); - unknown4 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 20); - unknown5 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 24); - unknown6 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 28); - unknown7 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 32); -} - -CutsceneCommandPlayBGM::CutsceneCommandPlayBGM(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - uint32_t numEntries = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0); - - rawDataIndex += 4; - - for (uint32_t i = 0; i < numEntries; i++) - { - entries.push_back(new MusicChangeEntry(rawData, rawDataIndex)); - rawDataIndex += 0x30; - } -} - -std::string CutsceneCommandPlayBGM::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; - - result += StringHelper::Sprintf("CS_PLAY_BGM_LIST(%i),\n", entries.size()); - - for (size_t i = 0; i < entries.size(); i++) - { - result += StringHelper::Sprintf( - " CS_PLAY_BGM(%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i),\n", - entries[i]->sequence, entries[i]->startFrame, entries[i]->endFrame, - entries[i]->unknown0, entries[i]->unknown1, entries[i]->unknown2, entries[i]->unknown3, - entries[i]->unknown4, entries[i]->unknown5, entries[i]->unknown6, entries[i]->unknown7); - } - - return result; -} - -std::string CutsceneCommandPlayBGM::GetCName() -{ - return "CsCmdMusicChange"; -} - -size_t CutsceneCommandPlayBGM::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + 0x30; -} - -CutsceneCommandStopBGM::CutsceneCommandStopBGM(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - uint32_t numEntries = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0); - - rawDataIndex += 4; - - for (uint32_t i = 0; i < numEntries; i++) - { - entries.push_back(new MusicChangeEntry(rawData, rawDataIndex)); - rawDataIndex += 0x30; - } -} - -std::string CutsceneCommandStopBGM::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; - - result += StringHelper::Sprintf("CS_STOP_BGM_LIST(%i),\n", entries.size()); - - for (size_t i = 0; i < entries.size(); i++) - { - result += StringHelper::Sprintf( - "\t\tCS_STOP_BGM(%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i),\n", entries[i]->sequence, - entries[i]->startFrame, entries[i]->endFrame, entries[i]->unknown0, - entries[i]->unknown1, entries[i]->unknown2, entries[i]->unknown3, entries[i]->unknown4, - entries[i]->unknown5, entries[i]->unknown6, entries[i]->unknown7); - } - - return result; -} - -std::string CutsceneCommandStopBGM::GetCName() -{ - return "CsCmdMusicChange"; -} - -size_t CutsceneCommandStopBGM::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + 0x30; -} - -EnvLightingEntry::EnvLightingEntry(const std::vector& rawData, uint32_t rawDataIndex) -{ - setting = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); - unused0 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); - unused1 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 8); - unused2 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 12); - unused3 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 16); - unused4 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 20); - unused5 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 24); - unused6 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 28); - unused7 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 32); -} - -CutsceneCommandEnvLighting::CutsceneCommandEnvLighting(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - int32_t numEntries = BitConverter::ToInt32BE(rawData, rawDataIndex + 0); - - rawDataIndex += 4; - - for (int32_t i = 0; i < numEntries; i++) - { - entries.push_back(new EnvLightingEntry(rawData, rawDataIndex)); - rawDataIndex += 0x30; - } -} - -std::string CutsceneCommandEnvLighting::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; - - result += StringHelper::Sprintf("CS_LIGHTING_LIST(%i),\n", entries.size()); - - for (size_t i = 0; i < entries.size(); i++) - { - result += StringHelper::Sprintf( - "\t\tCS_LIGHTING(%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i),\n", entries[i]->setting, - entries[i]->startFrame, entries[i]->endFrame, entries[i]->unused0, entries[i]->unused1, - entries[i]->unused2, entries[i]->unused3, entries[i]->unused4, entries[i]->unused5, - entries[i]->unused6, entries[i]->unused7); - } - - return result; -} - -std::string CutsceneCommandEnvLighting::GetCName() -{ - return "CsCmdEnvLighting"; -} - -size_t CutsceneCommandEnvLighting::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + (0x30 * entries.size()); -} - -Unknown9Entry::Unknown9Entry(const std::vector& rawData, uint32_t rawDataIndex) -{ - base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); - unk2 = rawData[rawDataIndex + 6]; - unk3 = rawData[rawDataIndex + 7]; - unk4 = rawData[rawDataIndex + 8]; - unused0 = rawData[rawDataIndex + 10]; - unused1 = rawData[rawDataIndex + 11]; - ; -} - -CutsceneCommandUnknown9::CutsceneCommandUnknown9(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - int32_t numEntries = BitConverter::ToInt32BE(rawData, rawDataIndex); - - rawDataIndex += 4; - - for (int32_t i = 0; i < numEntries; i++) - { - entries.push_back(new Unknown9Entry(rawData, rawDataIndex)); - rawDataIndex += 0x0C; - } -} - -std::string CutsceneCommandUnknown9::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; - - result += StringHelper::Sprintf("CS_CMD_09_LIST(%i),\n", entries.size()); - - for (size_t i = 0; i < entries.size(); i++) - { - result += StringHelper::Sprintf("\t\tCS_CMD_09(%i, %i, %i, %i, %i, %i, %i, %i),\n", - entries[i]->base, entries[i]->startFrame, - entries[i]->endFrame, entries[i]->unk2, entries[i]->unk3, - entries[i]->unk4, entries[i]->unused0, entries[i]->unused1); - } - - return result; -} - -std::string CutsceneCommandUnknown9::GetCName() -{ - return "CsCmdUnknown9"; -} - -size_t CutsceneCommandUnknown9::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + (entries.size() * 12); -} - -UnkEntry::UnkEntry(const std::vector& rawData, uint32_t rawDataIndex) -{ - unused0 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0); - unused1 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 4); - unused2 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 8); - unused3 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 12); - unused4 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 16); - unused5 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 20); - unused6 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 24); - unused7 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 28); - unused8 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 32); - unused9 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 36); - unused10 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 40); - unused11 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 44); -} - -CutsceneCommandUnknown::CutsceneCommandUnknown(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - int32_t numEntries = BitConverter::ToInt32BE(rawData, rawDataIndex); - - rawDataIndex += 4; - - for (int32_t i = 0; i < numEntries; i++) - { - entries.push_back(new UnkEntry(rawData, rawDataIndex)); - rawDataIndex += 0x30; - } -} - -std::string CutsceneCommandUnknown::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; - - result += StringHelper::Sprintf("CS_UNK_DATA_LIST(0x%02X, %i),\n", commandID, entries.size()); - - for (size_t i = 0; i < entries.size(); i++) - { - result += StringHelper::Sprintf( - " CS_UNK_DATA(%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i),\n", - entries[i]->unused0, entries[i]->unused1, entries[i]->unused2, entries[i]->unused3, - entries[i]->unused4, entries[i]->unused5, entries[i]->unused6, entries[i]->unused7, - entries[i]->unused8, entries[i]->unused9, entries[i]->unused10, entries[i]->unused11); - } - - return result; -} - -std::string CutsceneCommandUnknown::GetCName() -{ - return "CsCmdUnknown1A"; -} - -size_t CutsceneCommandUnknown::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + (entries.size() * 0x30); -} - -DayTimeEntry::DayTimeEntry(const std::vector& rawData, uint32_t rawDataIndex) -{ - base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); - hour = rawData[rawDataIndex + 6]; - minute = rawData[rawDataIndex + 7]; - unused = rawData[rawDataIndex + 8]; -} - -CutsceneCommandDayTime::CutsceneCommandDayTime(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - int32_t numEntries = BitConverter::ToInt32BE(rawData, rawDataIndex); - - rawDataIndex += 4; - - for (int32_t i = 0; i < numEntries; i++) - { - entries.push_back(new DayTimeEntry(rawData, rawDataIndex)); - rawDataIndex += 12; - } -} - -std::string CutsceneCommandDayTime::GetCName() -{ - return "CsCmdDayTime"; -} - -std::string CutsceneCommandDayTime::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; - - result += StringHelper::Sprintf("CS_TIME_LIST(%i),\n", entries.size()); - - for (size_t i = 0; i < entries.size(); i++) - { - result += StringHelper::Sprintf( - " CS_TIME(%i, %i, %i, %i, %i, %i),\n", entries[i]->base, entries[i]->startFrame, - entries[i]->endFrame, entries[i]->hour, entries[i]->minute, entries[i]->unused); - } - - return result; -} - -size_t CutsceneCommandDayTime::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + (entries.size() * 12); -} - -TextboxEntry::TextboxEntry(const std::vector& rawData, uint32_t rawDataIndex) -{ - base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); - type = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); - textID1 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 8); - textID2 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 10); -} - -CutsceneCommandTextbox::CutsceneCommandTextbox(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - int32_t numEntries = BitConverter::ToInt32BE(rawData, rawDataIndex); - - rawDataIndex += 4; - - for (int32_t i = 0; i < numEntries; i++) - { - entries.push_back(new TextboxEntry(rawData, rawDataIndex)); - rawDataIndex += 12; - } -} - -std::string CutsceneCommandTextbox::GetCName() -{ - return "CsCmdTextbox"; -} - -std::string CutsceneCommandTextbox::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; - - result += StringHelper::Sprintf("CS_TEXT_LIST(%i),\n", entries.size()); - - for (size_t i = 0; i < entries.size(); i++) - { - if (entries[i]->base == 0xFFFF) - { - result += StringHelper::Sprintf(" CS_TEXT_NONE(%i, %i),\n", - entries[i]->startFrame, entries[i]->endFrame); - } - else - { - result += StringHelper::Sprintf( - " CS_TEXT_DISPLAY_TEXTBOX(%i, %i, %i, %i, %i, %i),\n", entries[i]->base, - entries[i]->startFrame, entries[i]->endFrame, entries[i]->type, entries[i]->textID1, - entries[i]->textID2); - } - } - - return result; -} - -size_t CutsceneCommandTextbox::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + (entries.size() * 12); -} - -ActorAction::ActorAction(const std::vector& rawData, uint32_t rawDataIndex) -{ - action = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); - rotX = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); - rotY = BitConverter::ToUInt16BE(rawData, rawDataIndex + 8); - rotZ = BitConverter::ToUInt16BE(rawData, rawDataIndex + 10); - startPosX = BitConverter::ToInt32BE(rawData, rawDataIndex + 12); - startPosY = BitConverter::ToInt32BE(rawData, rawDataIndex + 16); - startPosZ = BitConverter::ToInt32BE(rawData, rawDataIndex + 20); - endPosX = BitConverter::ToInt32BE(rawData, rawDataIndex + 24); - endPosY = BitConverter::ToInt32BE(rawData, rawDataIndex + 28); - endPosZ = BitConverter::ToInt32BE(rawData, rawDataIndex + 32); - normalX = BitConverter::ToFloatBE(rawData, rawDataIndex + 36); - normalY = BitConverter::ToFloatBE(rawData, rawDataIndex + 40); - normalZ = BitConverter::ToFloatBE(rawData, rawDataIndex + 44); -} - -CutsceneCommandActorAction::CutsceneCommandActorAction(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - int32_t numEntries = BitConverter::ToInt32BE(rawData, rawDataIndex); - - rawDataIndex += 4; - - for (int32_t i = 0; i < numEntries; i++) - { - entries.push_back(new ActorAction(rawData, rawDataIndex)); - rawDataIndex += 0x30; - } -} - -std::string CutsceneCommandActorAction::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; - std::string subCommand; - - if (commandID == 10) - { - result += StringHelper::Sprintf("CS_PLAYER_ACTION_LIST(%i),\n", entries.size()); - subCommand = "CS_PLAYER_ACTION"; - } - else - { - result += StringHelper::Sprintf("CS_NPC_ACTION_LIST(%i, %i),\n", commandID, entries.size()); - subCommand = "CS_NPC_ACTION"; - } - - for (size_t i = 0; i < entries.size(); i++) - { - result += StringHelper::Sprintf( - "\t\t%s(0x%04X, %i, %i, 0x%04X, 0x%04X, 0x%04X, %i, %i, %i, %i, %i, %i, %.11ef, " - "%.11ef, %.11ef),\n", - subCommand.c_str(), entries[i]->action, entries[i]->startFrame, entries[i]->endFrame, - entries[i]->rotX, entries[i]->rotY, entries[i]->rotZ, entries[i]->startPosX, - entries[i]->startPosY, entries[i]->startPosZ, entries[i]->endPosX, entries[i]->endPosY, - entries[i]->endPosZ, entries[i]->normalX, entries[i]->normalY, entries[i]->normalZ); - } - - return result; -} - -std::string CutsceneCommandActorAction::GetCName() -{ - return "CsCmdBase"; -} - -size_t CutsceneCommandActorAction::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + (entries.size() * 0x30); -} - -CutsceneCommandTerminator::CutsceneCommandTerminator(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - rawDataIndex += 4; - - base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); - unknown = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); // endFrame duplicate -} - -std::string CutsceneCommandTerminator::GetCName() -{ - return "CsCmdBase"; -} - -std::string CutsceneCommandTerminator::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; - - result += StringHelper::Sprintf("CS_TERMINATOR(0x%04X, %i, %i),\n", base, startFrame, endFrame); - - return result; -} - -size_t CutsceneCommandTerminator::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + 8; -} - -CutsceneCommandEnd::CutsceneCommandEnd(const std::vector& rawData, uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); -} - -std::string CutsceneCommandEnd::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; - - result += StringHelper::Sprintf("CS_END(),\n"); - - return result; -} - -std::string CutsceneCommandEnd::GetCName() -{ - return "CsCmdBase"; -} - -size_t CutsceneCommandEnd::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + 6; -} - -SpecialActionEntry::SpecialActionEntry(const std::vector& rawData, uint32_t rawDataIndex) -{ - base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); - unused0 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); - unused1 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 8); - unused2 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 12); - unused3 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 16); - unused4 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 20); - unused5 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 24); - unused6 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 28); - unused7 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 32); - unused8 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 36); - unused9 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 40); - unused10 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 44); -} - -CutsceneCommandSpecialAction::CutsceneCommandSpecialAction(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - int32_t numEntries = BitConverter::ToInt32BE(rawData, rawDataIndex + 0); - - rawDataIndex += 4; - - for (int32_t i = 0; i < numEntries; i++) - { - entries.push_back(new SpecialActionEntry(rawData, rawDataIndex)); - rawDataIndex += 0x30; - } -} - -std::string CutsceneCommandSpecialAction::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; - - result += StringHelper::Sprintf("CS_MISC_LIST(%i),\n", entries.size()); - - for (size_t i = 0; i < entries.size(); i++) - { - result += StringHelper::Sprintf( - "\t\tCS_MISC(0x%04X, %i, %i, 0x%04X, 0x%04X, 0x%04X, %i, %i, %i, %i, %i, %i, %i, " - "%i),\n", - entries[i]->base, entries[i]->startFrame, entries[i]->endFrame, entries[i]->unused0, - entries[i]->unused1, entries[i]->unused2, entries[i]->unused3, entries[i]->unused4, - entries[i]->unused5, entries[i]->unused6, entries[i]->unused7, entries[i]->unused8, - entries[i]->unused9, entries[i]->unused10); - } - - return result; -} - -std::string CutsceneCommandSpecialAction::GetCName() -{ - return "CsCmdBase"; -} - -size_t CutsceneCommandSpecialAction::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + (0x30 * entries.size()); -} - -CutsceneCommandNop::CutsceneCommandNop(const std::vector& rawData, uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); -} - -std::string CutsceneCommandNop::GetCName() -{ - return "CsCmdBase"; -} - -size_t CutsceneCommandNop::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + 6; -} - -CutsceneCommandSceneTransFX::CutsceneCommandSceneTransFX(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - rawDataIndex += 4; - - base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); -} - -std::string CutsceneCommandSceneTransFX::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - return StringHelper::Sprintf("CS_SCENE_TRANS_FX(%i, %i, %i),\n", base, startFrame, endFrame); -} - -std::string CutsceneCommandSceneTransFX::GetCName() -{ - return "CsCmdBase"; -} - -size_t CutsceneCommandSceneTransFX::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + 8; -} - -ZCutsceneBase::ZCutsceneBase(ZFile* nParent) : ZResource(nParent) -{ + return nullptr; } -Declaration* ZCutsceneBase::DeclareVar(const std::string& prefix, const std::string& bodyStr) +Declaration* ZCutscene::DeclareVar(const std::string& prefix, const std::string& bodyStr) { std::string auxName = name; @@ -1245,7 +377,12 @@ Declaration* ZCutsceneBase::DeclareVar(const std::string& prefix, const std::str return decl; } -std::string ZCutsceneBase::GetSourceTypeName() const +std::string ZCutscene::GetSourceTypeName() const { return "CutsceneData"; } + +ZResourceType ZCutscene::GetResourceType() const +{ + return ZResourceType::Cutscene; +} diff --git a/tools/ZAPD/ZAPD/ZCutscene.h b/tools/ZAPD/ZAPD/ZCutscene.h index 8e901e3075..098f3ad868 100644 --- a/tools/ZAPD/ZAPD/ZCutscene.h +++ b/tools/ZAPD/ZAPD/ZCutscene.h @@ -3,422 +3,13 @@ #include #include #include -#include "ZFile.h" -#include "ZResource.h" #include "tinyxml2.h" -enum class CutsceneCommands -{ - Cmd00 = 0x0000, - SetCameraPos = 0x0001, - SetCameraFocus = 0x0002, - SpecialAction = 0x0003, - SetLighting = 0x0004, - SetCameraPosLink = 0x0005, - SetCameraFocusLink = 0x0006, - Cmd07 = 0x0007, - Cmd08 = 0x0008, - Cmd09 = 0x0009, - Unknown = 0x001A, - Textbox = 0x0013, - SetActorAction0 = 0x000A, - SetActorAction1 = 0x000F, - SetActorAction2 = 0x000E, - SetActorAction3 = 0x0019, - SetActorAction4 = 0x001D, - SetActorAction5 = 0x001E, - SetActorAction6 = 0x002C, - SetActorAction7 = 0x001F, - SetActorAction8 = 0x0031, - SetActorAction9 = 0x003E, - SetActorAction10 = 0x008F, - SetSceneTransFX = 0x002D, - Nop = 0x000B, - PlayBGM = 0x0056, - StopBGM = 0x0057, - FadeBGM = 0x007C, - SetTime = 0x008C, - Terminator = 0x03E8, - End = 0xFFFF, - Error = 0xFEAF, -}; +#include "OtherStructs/Cutscene_Commands.h" +#include "ZFile.h" +#include "ZResource.h" -class CutsceneCameraPoint -{ -public: - int8_t continueFlag; - int8_t cameraRoll; - int16_t nextPointFrame; - float viewAngle; - int16_t posX, posY, posZ; - int16_t unused; - - CutsceneCameraPoint(const std::vector& rawData, uint32_t rawDataIndex); -}; - -class CutsceneCommand -{ -public: - uint32_t commandID; - uint32_t commandIndex; - virtual ~CutsceneCommand(); - CutsceneCommand(const std::vector& rawData, uint32_t rawDataIndex); - virtual std::string GetCName(); - virtual std::string GenerateSourceCode(uint32_t baseAddress); - virtual size_t GetCommandSize(); -}; - -class CutsceneCommandSetCameraPos : public CutsceneCommand -{ -public: - uint16_t base; - uint16_t startFrame; - uint16_t endFrame; - uint16_t unused; - - std::vector entries; - ~CutsceneCommandSetCameraPos(); - CutsceneCommandSetCameraPos(const std::vector& rawData, uint32_t rawDataIndex); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class SpecialActionEntry -{ -public: - uint16_t base; - uint16_t startFrame; - uint16_t endFrame; - uint16_t unused0; - uint32_t unused1; - uint32_t unused2; - uint32_t unused3; - uint32_t unused4; - uint32_t unused5; - uint32_t unused6; - uint32_t unused7; - uint32_t unused8; - uint32_t unused9; - uint32_t unused10; - - SpecialActionEntry(const std::vector& rawData, uint32_t rawDataIndex); -}; - -class CutsceneCommandSpecialAction : public CutsceneCommand -{ -public: - std::vector entries; - - CutsceneCommandSpecialAction(const std::vector& rawData, uint32_t rawDataIndex); - ~CutsceneCommandSpecialAction(); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class MusicFadeEntry -{ -public: - uint16_t base; - uint16_t startFrame; - uint16_t endFrame; - uint16_t unknown0; - uint32_t unknown1; - uint32_t unknown2; - uint32_t unknown3; - uint32_t unknown4; - uint32_t unknown5; - uint32_t unknown6; - uint32_t unknown7; - uint32_t unknown8; - uint32_t unknown9; - uint32_t unknown10; - - MusicFadeEntry(const std::vector& rawData, uint32_t rawDataIndex); -}; - -class CutsceneCommandFadeBGM : public CutsceneCommand -{ -public: - std::vector entries; - - CutsceneCommandFadeBGM(const std::vector& rawData, uint32_t rawDataIndex); - ~CutsceneCommandFadeBGM(); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class MusicChangeEntry -{ -public: - uint16_t sequence; - uint16_t startFrame; - uint16_t endFrame; - uint16_t unknown0; - uint32_t unknown1; - uint32_t unknown2; - uint32_t unknown3; - uint32_t unknown4; - uint32_t unknown5; - uint32_t unknown6; - uint32_t unknown7; - - MusicChangeEntry(const std::vector& rawData, uint32_t rawDataIndex); -}; - -class CutsceneCommandPlayBGM : public CutsceneCommand -{ -public: - std::vector entries; - - CutsceneCommandPlayBGM(const std::vector& rawData, uint32_t rawDataIndex); - ~CutsceneCommandPlayBGM(); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class CutsceneCommandStopBGM : public CutsceneCommand -{ -public: - std::vector entries; - - CutsceneCommandStopBGM(const std::vector& rawData, uint32_t rawDataIndex); - ~CutsceneCommandStopBGM(); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class EnvLightingEntry -{ -public: - uint16_t setting; - uint16_t startFrame; - uint16_t endFrame; - uint16_t unused0; - uint32_t unused1; - uint32_t unused2; - uint32_t unused3; - uint32_t unused4; - uint32_t unused5; - uint32_t unused6; - uint32_t unused7; - - EnvLightingEntry(const std::vector& rawData, uint32_t rawDataIndex); -}; - -class CutsceneCommandEnvLighting : public CutsceneCommand -{ -public: - std::vector entries; - - CutsceneCommandEnvLighting(const std::vector& rawData, uint32_t rawDataIndex); - ~CutsceneCommandEnvLighting(); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class CutsceneCommandSceneTransFX : public CutsceneCommand -{ -public: - uint16_t base; - uint16_t startFrame; - uint16_t endFrame; - ~CutsceneCommandSceneTransFX(); - CutsceneCommandSceneTransFX(const std::vector& rawData, uint32_t rawDataIndex); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class Unknown9Entry -{ -public: - uint16_t base; - uint16_t startFrame; - uint16_t endFrame; - uint16_t unk2; - uint16_t unk3; - uint16_t unk4; - uint8_t unused0; - uint8_t unused1; - - Unknown9Entry(const std::vector& rawData, uint32_t rawDataIndex); -}; - -class CutsceneCommandUnknown9 : public CutsceneCommand -{ -public: - std::vector entries; - - CutsceneCommandUnknown9(const std::vector& rawData, uint32_t rawDataIndex); - ~CutsceneCommandUnknown9(); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class UnkEntry -{ -public: - uint32_t unused0; - uint32_t unused1; - uint32_t unused2; - uint32_t unused3; - uint32_t unused4; - uint32_t unused5; - uint32_t unused6; - uint32_t unused7; - uint32_t unused8; - uint32_t unused9; - uint32_t unused10; - uint32_t unused11; - - UnkEntry(const std::vector& rawData, uint32_t rawDataIndex); -}; - -class CutsceneCommandUnknown : public CutsceneCommand -{ -public: - std::vector entries; - - CutsceneCommandUnknown(const std::vector& rawData, uint32_t rawDataIndex); - ~CutsceneCommandUnknown(); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class DayTimeEntry -{ -public: - uint16_t base; - uint16_t startFrame; - uint16_t endFrame; - uint8_t hour; - uint8_t minute; - uint8_t unused; - - DayTimeEntry(const std::vector& rawData, uint32_t rawDataIndex); -}; - -class CutsceneCommandDayTime : public CutsceneCommand -{ -public: - std::vector entries; - - CutsceneCommandDayTime(const std::vector& rawData, uint32_t rawDataIndex); - ~CutsceneCommandDayTime(); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class TextboxEntry -{ -public: - uint16_t base; - uint16_t startFrame; - uint16_t endFrame; - uint16_t type; - uint16_t textID1; - uint16_t textID2; - - TextboxEntry(const std::vector& rawData, uint32_t rawDataIndex); -}; - -class CutsceneCommandTextbox : public CutsceneCommand -{ -public: - std::vector entries; - - CutsceneCommandTextbox(const std::vector& rawData, uint32_t rawDataIndex); - ~CutsceneCommandTextbox(); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class ActorAction -{ -public: - uint16_t action; - uint16_t startFrame; - uint16_t endFrame; - int16_t rotX, rotY, rotZ; - int32_t startPosX, startPosY, startPosZ; - int32_t endPosX, endPosY, endPosZ; - float normalX, normalY, normalZ; - - ActorAction(const std::vector& rawData, uint32_t rawDataIndex); -}; - -class CutsceneCommandActorAction : public CutsceneCommand -{ -public: - std::vector entries; - - CutsceneCommandActorAction(const std::vector& rawData, uint32_t rawDataIndex); - ~CutsceneCommandActorAction(); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class CutsceneCommandTerminator : public CutsceneCommand -{ -public: - uint16_t base; - uint16_t startFrame; - uint16_t endFrame; - uint16_t unknown; - - CutsceneCommandTerminator(const std::vector& rawData, uint32_t rawDataIndex); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class CutsceneCommandEnd : public CutsceneCommand -{ -public: - uint16_t base; - uint16_t startFrame; - uint16_t endFrame; - - CutsceneCommandEnd(const std::vector& rawData, uint32_t rawDataIndex); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class CutsceneCommandNop : public CutsceneCommand -{ -public: - uint16_t base; - uint16_t startFrame; - uint16_t endFrame; - - CutsceneCommandNop(const std::vector& rawData, uint32_t rawDataIndex); - std::string GetCName(); - size_t GetCommandSize(); -}; - -class ZCutsceneBase : public ZResource -{ -public: - ZCutsceneBase(ZFile* nParent); - - Declaration* DeclareVar(const std::string& prefix, const std::string& bodyStr) override; - - std::string GetSourceTypeName() const override; -}; - -class ZCutscene : public ZCutsceneBase +class ZCutscene : public ZResource { public: ZCutscene(ZFile* nParent); @@ -426,15 +17,20 @@ public: void ParseRawData() override; + Declaration* DeclareVar(const std::string& prefix, const std::string& bodyStr) override; + std::string GetBodySourceCode() const override; size_t GetRawDataSize() const override; + std::string GetSourceTypeName() const override; ZResourceType GetResourceType() const override; - CutsceneCommands GetCommandFromID(int32_t id); - int32_t numCommands; int32_t endFrame; std::vector commands; + +protected: + CutsceneCommand* GetCommandOoT(uint32_t id, offset_t currentPtr) const; + CutsceneCommand* GetCommandMM(uint32_t id, offset_t currentPtr) const; }; diff --git a/tools/ZAPD/ZAPD/ZCutsceneMM.cpp b/tools/ZAPD/ZAPD/ZCutsceneMM.cpp deleted file mode 100644 index d0208bc070..0000000000 --- a/tools/ZAPD/ZAPD/ZCutsceneMM.cpp +++ /dev/null @@ -1,61 +0,0 @@ -#include "ZCutsceneMM.h" - -#include "Utils/BitConverter.h" -#include "Utils/StringHelper.h" - -ZCutsceneMM::ZCutsceneMM(ZFile* nParent) : ZCutsceneBase(nParent) -{ -} - -ZCutsceneMM::~ZCutsceneMM() -{ - for (CutsceneCommand* cmd : commands) - delete cmd; -} - -std::string ZCutsceneMM::GetBodySourceCode() const -{ - std::string output; - - output += StringHelper::Sprintf(" CS_BEGIN_CUTSCENE(%i, %i),", numCommands, endFrame); - - for (size_t i = 0; i < data.size(); i++) - { - if ((i % 4) == 0) - output += "\n "; - output += StringHelper::Sprintf("0x%08X, ", data[i]); - } - - return output; -} - -size_t ZCutsceneMM::GetRawDataSize() const -{ - return 8 + data.size() * 4; -} - -void ZCutsceneMM::ParseRawData() -{ - const auto& rawData = parent->GetRawData(); - - numCommands = BitConverter::ToInt32BE(rawData, rawDataIndex + 0); - commands = std::vector(); - - endFrame = BitConverter::ToInt32BE(rawData, rawDataIndex + 4); - uint32_t currentPtr = rawDataIndex + 8; - uint32_t lastData = 0; - - // TODO currently cutscenes aren't being parsed, so just consume words until we see an end - // marker. - do - { - lastData = BitConverter::ToInt32BE(rawData, currentPtr); - data.push_back(lastData); - currentPtr += 4; - } while (lastData != 0xFFFFFFFF); -} - -ZResourceType ZCutsceneMM::GetResourceType() const -{ - return ZResourceType::Cutscene; -} diff --git a/tools/ZAPD/ZAPD/ZCutsceneMM.h b/tools/ZAPD/ZAPD/ZCutsceneMM.h deleted file mode 100644 index 44b108d6c1..0000000000 --- a/tools/ZAPD/ZAPD/ZCutsceneMM.h +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once - -#include -#include -#include -#include "ZCutscene.h" -#include "ZFile.h" -#include "tinyxml2.h" - -class ZCutsceneMM : public ZCutsceneBase -{ -public: - ZCutsceneMM(ZFile* nParent); - virtual ~ZCutsceneMM(); - - std::string GetBodySourceCode() const override; - - size_t GetRawDataSize() const override; - - void ParseRawData() override; - ZResourceType GetResourceType() const override; - -protected: - int32_t numCommands; - int32_t endFrame; - std::vector commands; - - std::vector data; -}; diff --git a/tools/ZAPD/ZAPD/ZFile.cpp b/tools/ZAPD/ZAPD/ZFile.cpp index d9733f3269..b81399e2a4 100644 --- a/tools/ZAPD/ZAPD/ZFile.cpp +++ b/tools/ZAPD/ZAPD/ZFile.cpp @@ -695,7 +695,7 @@ bool ZFile::GetDeclarationArrayIndexedName(segptr_t segAddress, size_t elementSi return true; } -Declaration* ZFile::GetDeclaration(uint32_t address) const +Declaration* ZFile::GetDeclaration(offset_t address) const { if (declarations.find(address) != declarations.end()) return declarations.at(address); @@ -703,7 +703,7 @@ Declaration* ZFile::GetDeclaration(uint32_t address) const return nullptr; } -Declaration* ZFile::GetDeclarationRanged(uint32_t address) const +Declaration* ZFile::GetDeclarationRanged(offset_t address) const { for (const auto decl : declarations) { @@ -714,7 +714,7 @@ Declaration* ZFile::GetDeclarationRanged(uint32_t address) const return nullptr; } -bool ZFile::HasDeclaration(uint32_t address) +bool ZFile::HasDeclaration(offset_t address) { assert(GETSEGNUM(address) == 0); return declarations.find(address) != declarations.end(); diff --git a/tools/ZAPD/ZAPD/ZFile.h b/tools/ZAPD/ZAPD/ZFile.h index 365c7bbbb5..275e27f1b3 100644 --- a/tools/ZAPD/ZAPD/ZFile.h +++ b/tools/ZAPD/ZAPD/ZFile.h @@ -81,9 +81,9 @@ public: const std::string& expectedType, std::string& declName) const; - Declaration* GetDeclaration(uint32_t address) const; - Declaration* GetDeclarationRanged(uint32_t address) const; - bool HasDeclaration(uint32_t address); + Declaration* GetDeclaration(offset_t address) const; + Declaration* GetDeclarationRanged(offset_t address) const; + bool HasDeclaration(offset_t address); std::string GetHeaderInclude() const; std::string GetZRoomHeaderInclude() const; diff --git a/tools/ZAPD/ZAPD/ZResource.cpp b/tools/ZAPD/ZAPD/ZResource.cpp index 2dfe6d5eaa..8825cc97bd 100644 --- a/tools/ZAPD/ZAPD/ZResource.cpp +++ b/tools/ZAPD/ZAPD/ZResource.cpp @@ -247,6 +247,11 @@ offset_t ZResource::GetRawDataIndex() const return rawDataIndex; } +void ZResource::SetRawDataIndex(offset_t nRawDataIndex) +{ + rawDataIndex = nRawDataIndex; +} + std::string ZResource::GetBodySourceCode() const { return "ERROR"; diff --git a/tools/ZAPD/ZAPD/ZResource.h b/tools/ZAPD/ZAPD/ZResource.h index c65c3c31b4..35984679c7 100644 --- a/tools/ZAPD/ZAPD/ZResource.h +++ b/tools/ZAPD/ZAPD/ZResource.h @@ -31,6 +31,7 @@ enum class ZResourceType Background, Blob, CollisionHeader, + CollisionPoly, Cutscene, DisplayList, Limb, @@ -150,6 +151,8 @@ public: [[nodiscard]] const std::string& GetOutName() const; void SetOutName(const std::string& nName); [[nodiscard]] offset_t GetRawDataIndex() const; + void SetRawDataIndex(offset_t nRawDataIndex); + /** * The size of the current struct being extracted, not counting data referenced by it */ diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.cpp b/tools/ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.cpp index e51e550b09..3820203ef8 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.cpp @@ -10,53 +10,65 @@ SetCutscenes::SetCutscenes(ZFile* nParent) : ZRoomCommand(nParent) { } -SetCutscenes::~SetCutscenes() -{ - for (ZCutsceneBase* cutscene : cutscenes) - delete cutscene; -} - void SetCutscenes::ParseRawData() { ZRoomCommand::ParseRawData(); - std::string output; numCutscenes = cmdArg1; - if (Globals::Instance->game == ZGame::OOT_RETAIL || Globals::Instance->game == ZGame::OOT_SW97) - { - ZCutscene* cutscene = new ZCutscene(parent); - cutscene->ExtractFromFile(segmentOffset); - auto decl = parent->GetDeclaration(segmentOffset); - if (decl == nullptr) - { - cutscene->DeclareVar(zRoom->GetName().c_str(), ""); - } - - cutscenes.push_back(cutscene); - } - else + if (Globals::Instance->game == ZGame::MM_RETAIL) { int32_t currentPtr = segmentOffset; - std::string declaration; for (uint8_t i = 0; i < numCutscenes; i++) { CutsceneEntry entry(parent->GetRawData(), currentPtr); cutsceneEntries.push_back(entry); currentPtr += 8; + } + } +} - // TODO: don't hardcode %sCutsceneData_%06X, look up for the declared name instead - declaration += StringHelper::Sprintf( - " { %sCutsceneData_%06X, 0x%04X, 0x%02X, 0x%02X },", zRoom->GetName().c_str(), - entry.segmentOffset, entry.exit, entry.entrance, entry.flag); +void SetCutscenes::DeclareReferences(const std::string& prefix) +{ + std::string varPrefix = name; + if (varPrefix == "") + varPrefix = prefix; - if (i < numCutscenes - 1) + if (Globals::Instance->game == ZGame::MM_RETAIL) + { + std::string declaration; + size_t i = 0; + + for (const auto& entry : cutsceneEntries) + { + if (entry.segmentPtr != SEGMENTED_NULL && + GETSEGNUM(entry.segmentPtr) == parent->segment) + { + offset_t csOffset = Seg2Filespace(entry.segmentPtr, parent->baseAddress); + if (!parent->HasDeclaration(csOffset)) + { + auto* cutscene = new ZCutscene(parent); + cutscene->ExtractFromFile(csOffset); + cutscene->SetName(cutscene->GetDefaultName(varPrefix)); + cutscene->DeclareVar(varPrefix, ""); + cutscene->DeclareReferences(varPrefix); + parent->AddResource(cutscene); + } + } + + std::string csName; + Globals::Instance->GetSegmentedPtrName(entry.segmentPtr, parent, "CutsceneData", + csName); + + declaration += + StringHelper::Sprintf(" { %s, 0x%04X, 0x%02X, 0x%02X },", csName.c_str(), + entry.exit, entry.entrance, entry.flag); + + if (i + 1 < numCutscenes) declaration += "\n"; - ZCutsceneMM* cutscene = new ZCutsceneMM(parent); - cutscene->ExtractFromFile(entry.segmentOffset); - cutscenes.push_back(cutscene); + i++; } parent->AddDeclarationArray(segmentOffset, DeclarationAlignment::Align4, @@ -65,19 +77,19 @@ void SetCutscenes::ParseRawData() zRoom->GetName().c_str(), segmentOffset), cutsceneEntries.size(), declaration); } - - for (ZCutsceneBase* cutscene : cutscenes) + else { - if (cutscene->GetRawDataIndex() != 0) + if (cmdArg2 != SEGMENTED_NULL && GETSEGNUM(cmdArg2) == parent->segment) { - Declaration* decl = parent->GetDeclaration(cutscene->GetRawDataIndex()); - if (decl == nullptr) + offset_t csOffset = Seg2Filespace(cmdArg2, parent->baseAddress); + if (!parent->HasDeclaration(csOffset)) { - cutscene->GetSourceOutputCode(zRoom->GetName()); - } - else if (decl->text == "") - { - decl->text = cutscene->GetBodySourceCode(); + auto* cutscene = new ZCutscene(parent); + cutscene->ExtractFromFile(csOffset); + cutscene->SetName(cutscene->GetDefaultName(varPrefix)); + cutscene->DeclareVar(varPrefix, ""); + cutscene->DeclareReferences(varPrefix); + parent->AddResource(cutscene); } } } @@ -86,11 +98,15 @@ void SetCutscenes::ParseRawData() std::string SetCutscenes::GetBodySourceCode() const { std::string listName; - Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "CutsceneData", listName); if (Globals::Instance->game == ZGame::MM_RETAIL) + { + Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "CutsceneEntry", listName); return StringHelper::Sprintf("SCENE_CMD_CUTSCENE_LIST(%i, %s)", numCutscenes, listName.c_str()); + } + + Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "CutsceneData", listName); return StringHelper::Sprintf("SCENE_CMD_CUTSCENE_DATA(%s)", listName.c_str()); } @@ -105,7 +121,7 @@ RoomCommand SetCutscenes::GetRoomCommand() const } CutsceneEntry::CutsceneEntry(const std::vector& rawData, uint32_t rawDataIndex) - : segmentOffset(GETSEGOFFSET(BitConverter::ToInt32BE(rawData, rawDataIndex + 0))), + : segmentPtr(BitConverter::ToInt32BE(rawData, rawDataIndex + 0)), exit(BitConverter::ToInt16BE(rawData, rawDataIndex + 4)), entrance(rawData[rawDataIndex + 6]), flag(rawData[rawDataIndex + 7]) { diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.h b/tools/ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.h index ad032bbe6a..81a622c5b3 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.h +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.h @@ -1,7 +1,6 @@ #pragma once #include "ZCutscene.h" -#include "ZCutsceneMM.h" #include "ZRoom/ZRoomCommand.h" class CutsceneEntry @@ -9,7 +8,7 @@ class CutsceneEntry public: CutsceneEntry(const std::vector& rawData, uint32_t rawDataIndex); - uint32_t segmentOffset; + segptr_t segmentPtr; uint16_t exit; uint8_t entrance; uint8_t flag; @@ -18,14 +17,13 @@ public: class SetCutscenes : public ZRoomCommand { public: - std::vector cutscenes; std::vector cutsceneEntries; // (MM Only) uint8_t numCutscenes; // (MM Only) SetCutscenes(ZFile* nParent); - ~SetCutscenes(); void ParseRawData() override; + void DeclareReferences(const std::string& prefix) override; std::string GetBodySourceCode() const override; diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetRoomList.cpp b/tools/ZAPD/ZAPD/ZRoom/Commands/SetRoomList.cpp index 7027fa1f98..20138dd4d7 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetRoomList.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetRoomList.cpp @@ -104,9 +104,8 @@ std::string RomFile::GetBodySourceCode() const if (!isFirst) declaration += "\n"; - declaration += - StringHelper::Sprintf("\t{ (u32)_%sSegmentRomStart, (u32)_%sSegmentRomEnd },", - roomName.c_str(), roomName.c_str()); + declaration += StringHelper::Sprintf("\t{ _%sSegmentRomStart, _%sSegmentRomEnd },", + roomName.c_str(), roomName.c_str()); isFirst = false; } } diff --git a/tools/ZAPD/ZAPD/ZSkeleton.cpp b/tools/ZAPD/ZAPD/ZSkeleton.cpp index ff43331299..b3f7ce8c01 100644 --- a/tools/ZAPD/ZAPD/ZSkeleton.cpp +++ b/tools/ZAPD/ZAPD/ZSkeleton.cpp @@ -159,8 +159,8 @@ std::string ZSkeleton::GetBodySourceCode() const return StringHelper::Sprintf("\n\t%s, %s\n", limbArrayName.c_str(), countStr.c_str()); case ZSkeletonType::Flex: - return StringHelper::Sprintf("\n\t{ %s, %s }, %i\n", limbArrayName.c_str(), countStr.c_str(), - dListCount); + return StringHelper::Sprintf("\n\t{ %s, %s }, %i\n", limbArrayName.c_str(), + countStr.c_str(), dListCount); } // TODO: Throw exception? diff --git a/tools/ZAPD/ZAPDUtils/Utils/BitConverter.h b/tools/ZAPD/ZAPDUtils/Utils/BitConverter.h index 98c46bc790..646fa1274c 100644 --- a/tools/ZAPD/ZAPDUtils/Utils/BitConverter.h +++ b/tools/ZAPD/ZAPDUtils/Utils/BitConverter.h @@ -3,6 +3,7 @@ #include #include #include +#include #include #include @@ -10,6 +11,10 @@ #define ALIGN16(val) (((val) + 0xF) & ~0xF) #define ALIGN64(val) (((val) + 0x3F) & ~0x3F) +#ifdef _MSC_VER +#define __PRETTY_FUNCTION__ __FUNCSIG__ +#endif + class BitConverter { public: diff --git a/tools/ZAPD/ZAPDUtils/ZAPDUtils.vcxproj b/tools/ZAPD/ZAPDUtils/ZAPDUtils.vcxproj index 0a09666e03..c0ef260dd7 100644 --- a/tools/ZAPD/ZAPDUtils/ZAPDUtils.vcxproj +++ b/tools/ZAPD/ZAPDUtils/ZAPDUtils.vcxproj @@ -1,168 +1,168 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - Win32Proj - {a2e01c3e-d647-45d1-9788-043debc1a908} - ZAPDUtils - 10.0 - - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - StaticLibrary - true - v142 - MultiByte - - - Application - false - v142 - true - Unicode - - - - - - - - - - - - - - - - - - - - - true - - - false - - - true - - - false - - - - Level3 - true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - Level3 - true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - MultiThreadedDebug - Default - - - Console - true - - - - - Level3 - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {a2e01c3e-d647-45d1-9788-043debc1a908} + ZAPDUtils + 10.0 + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + StaticLibrary + true + v143 + MultiByte + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + false + + + true + + + false + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + MultiThreadedDebug + Default + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tools/ZAPDConfigs/MM/SymbolMap_MM.txt b/tools/ZAPDConfigs/MM/SymbolMap_MM.txt index 015e7e88a3..cc7b36b5e6 100644 --- a/tools/ZAPDConfigs/MM/SymbolMap_MM.txt +++ b/tools/ZAPDConfigs/MM/SymbolMap_MM.txt @@ -1 +1 @@ -8012DB20 gMtxClear \ No newline at end of file +801D1DE0 gIdentityMtx diff --git a/tools/asm-differ/.gitrepo b/tools/asm-differ/.gitrepo index 48e215c08c..8d0a6445dc 100644 --- a/tools/asm-differ/.gitrepo +++ b/tools/asm-differ/.gitrepo @@ -6,7 +6,7 @@ [subrepo] remote = https://github.com/simonlindholm/asm-differ branch = main - commit = 6f8f80b719359d018a2b734288c977aae6538870 - parent = 91a6e9f647d2035eba281d286c78f089f70f269f + commit = 1236288d1520335c2bfb672078fec65084d7cb5c + parent = 2c5690701a350c7e7c3d6252dff925ad65d59910 method = merge cmdver = 0.4.3 diff --git a/tools/asm-differ/.pre-commit-config.yaml b/tools/asm-differ/.pre-commit-config.yaml index 6695f71ac9..ccc4afc0ee 100644 --- a/tools/asm-differ/.pre-commit-config.yaml +++ b/tools/asm-differ/.pre-commit-config.yaml @@ -1,6 +1,5 @@ repos: - repo: https://github.com/psf/black - rev: 20.8b1 + rev: 22.1.0 hooks: - id: black - language_version: python3.6 diff --git a/tools/asm-differ/README.md b/tools/asm-differ/README.md index 4a7f329b34..205310d394 100644 --- a/tools/asm-differ/README.md +++ b/tools/asm-differ/README.md @@ -11,10 +11,10 @@ Nice differ for assembly code. Currently supports MIPS, PPC, AArch64, and ARM32; ## Usage -Create a file `diff_settings.sh` in some directory (see the one in this repo for an example). Then from that directory, run +Create a file `diff_settings.py` in some directory (see the one in this repo for an example). Then from that directory, run ```bash -/path/to/diff.sh [flags] (function|rom addr) +/path/to/diff.py [flags] (function|rom addr) ``` Recommended flags are `-mwo` (automatically run `make` on source file changes, and include symbols in diff). See `--help` for more details. diff --git a/tools/asm-differ/diff.py b/tools/asm-differ/diff.py index 9781420bb3..4b5bc892ee 100755 --- a/tools/asm-differ/diff.py +++ b/tools/asm-differ/diff.py @@ -109,6 +109,15 @@ if __name__ == "__main__": help="""Diff .o files rather than a whole binary. This makes it possible to see symbol names. (Recommended)""", ) + parser.add_argument( + "-f", + "--objfile", + dest="objfile", + type=str, + help="""File path for an object file being diffed. When used + the map file isn't searched for the function given. Useful for dynamically + linked libraries.""", + ) parser.add_argument( "-e", "--elf", @@ -132,6 +141,14 @@ if __name__ == "__main__": help="""Tweak --source handling to make it work with binutils < 2.33. Implies --source.""", ) + parser.add_argument( + "-j", + "--section", + dest="diff_section", + default=".text", + metavar="SECTION", + help="Diff restricted to a given output section.", + ) parser.add_argument( "-L", "--line-numbers", @@ -356,6 +373,7 @@ except ModuleNotFoundError as e: class ProjectSettings: arch_str: str objdump_executable: str + objdump_flags: List[str] build_command: List[str] map_format: str mw_build_dir: str @@ -365,6 +383,7 @@ class ProjectSettings: source_directories: Optional[List[str]] source_extensions: List[str] show_line_numbers_default: bool + disassemble_all: bool @dataclass @@ -379,8 +398,10 @@ class Config: # Build/objdump options diff_obj: bool + objfile: Optional[str] make: bool source_old_binutils: bool + diff_section: str inlines: bool max_function_size_lines: int max_function_size_bytes: int @@ -422,9 +443,11 @@ def create_project_settings(settings: Dict[str, Any]) -> ProjectSettings: "source_extensions", [".c", ".h", ".cpp", ".hpp", ".s"] ), objdump_executable=get_objdump_executable(settings.get("objdump_executable")), + objdump_flags=settings.get("objdump_flags", []), map_format=settings.get("map_format", "gnu"), mw_build_dir=settings.get("mw_build_dir", "build/"), show_line_numbers_default=settings.get("show_line_numbers_default", True), + disassemble_all=settings.get("disassemble_all", False), ) @@ -461,8 +484,10 @@ def create_config(args: argparse.Namespace, project: ProjectSettings) -> Config: arch=arch, # Build/objdump options diff_obj=args.diff_obj, + objfile=args.objfile, make=args.make, source_old_binutils=args.source_old_binutils, + diff_section=args.diff_section, inlines=args.inlines, max_function_size_lines=args.max_lines, max_function_size_bytes=args.max_lines * 4, @@ -518,7 +543,7 @@ def get_arch(arch_str: str) -> "ArchSettings": raise ValueError(f"Unknown architecture: {arch_str}") -BUFFER_CMD: List[str] = ["tail", "-c", str(10 ** 9)] +BUFFER_CMD: List[str] = ["tail", "-c", str(10**9)] # -S truncates long lines instead of wrapping them # -R interprets color escape sequences @@ -809,12 +834,7 @@ class JsonFormatter(Formatter): return {"text": s, "format": f.name.lower()} elif isinstance(f, RotationFormat): attrs = asdict(f) - attrs.update( - { - "text": s, - "format": "rotation", - } - ) + attrs.update({"text": s, "format": "rotation"}) return attrs else: static_assert_unreachable(f) @@ -962,7 +982,7 @@ def restrict_to_function(dump: str, fn_name: str) -> str: return "" -def serialize_data_references(references: List[Tuple[int, int, str]]) -> str: +def serialize_rodata_references(references: List[Tuple[int, int, str]]) -> str: return "".join( f"DATAREF {text_offset} {from_offset} {from_section}\n" for (text_offset, from_offset, from_section) in references @@ -991,7 +1011,11 @@ def run_objdump(cmd: ObjdumpCommand, config: Config, project: ProjectSettings) - flags, target, restrict = cmd try: out = subprocess.run( - [project.objdump_executable] + config.arch.arch_flags + flags + [target], + [project.objdump_executable] + + config.arch.arch_flags + + project.objdump_flags + + flags + + [target], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, @@ -1009,11 +1033,11 @@ def run_objdump(cmd: ObjdumpCommand, config: Config, project: ProjectSettings) - with open(target, "rb") as f: obj_data = f.read() - return preprocess_objdump_out(restrict, obj_data, out) + return preprocess_objdump_out(restrict, obj_data, out, config) def preprocess_objdump_out( - restrict: Optional[str], obj_data: Optional[bytes], objdump_out: str + restrict: Optional[str], obj_data: Optional[bytes], objdump_out: str, config: Config ) -> str: """ Preprocess the output of objdump into a format that `process()` expects. @@ -1033,13 +1057,16 @@ def preprocess_objdump_out( out = out.rstrip("\n") if obj_data: - out = serialize_data_references(parse_elf_data_references(obj_data)) + out + out = ( + serialize_rodata_references(parse_elf_rodata_references(obj_data, config)) + + out + ) return out def search_map_file( - fn_name: str, project: ProjectSettings + fn_name: str, project: ProjectSettings, config: Config ) -> Tuple[Optional[str], Optional[int]]: if not project.mapfile: fail(f"No map file configured; cannot find function {fn_name}.") @@ -1059,7 +1086,7 @@ def search_map_file( cands = [] last_line = "" for line in lines: - if line.startswith(" .text"): + if line.startswith(" " + config.diff_section): cur_objfile = line.split()[3] if "load address" in line: tokens = last_line.split() + line.split() @@ -1084,9 +1111,12 @@ def search_map_file( re.compile( # ram elf rom r" \S+ \S+ (\S+) (\S+) . " - + fn_name - # object name - + r"(?: \(entry of \.(?:init|text)\))? \t(\S+)" + + re.escape(fn_name) + + r"(?: \(entry of " + + re.escape(config.diff_section) + + r"\))? \t" + # object name + + "(\S+)" ), contents, ) @@ -1121,7 +1151,9 @@ def search_map_file( return None, None -def parse_elf_data_references(data: bytes) -> List[Tuple[int, int, str]]: +def parse_elf_rodata_references( + data: bytes, config: Config +) -> List[Tuple[int, int, str]]: e_ident = data[:16] if e_ident[:4] != b"\x7FELF": return [] @@ -1134,7 +1166,6 @@ def parse_elf_data_references(data: bytes) -> List[Tuple[int, int, str]]: is_little_endian = e_ident[5] == 1 str_end = "<" if is_little_endian else ">" str_off = "I" if is_32bit else "Q" - sym_size = {"B": 1, "H": 2, "I": 4, "Q": 8} def read(spec: str, offset: int) -> Tuple[int, ...]: spec = spec.replace("P", str_off) @@ -1186,7 +1217,12 @@ def parse_elf_data_references(data: bytes) -> List[Tuple[int, int, str]]: assert len(symtab_sections) == 1 symtab = sections[symtab_sections[0]] - text_sections = [i for i in range(e_shnum) if sec_names[i] == b".text" and sections[i].sh_size != 0] + section_name = config.diff_section.encode("utf-8") + text_sections = [ + i + for i in range(e_shnum) + if sec_names[i] == section_name and sections[i].sh_size != 0 + ] if len(text_sections) != 1: return [] text_section = text_sections[0] @@ -1195,11 +1231,10 @@ def parse_elf_data_references(data: bytes) -> List[Tuple[int, int, str]]: for s in sections: if s.sh_type == SHT_REL or s.sh_type == SHT_RELA: if s.sh_info == text_section: - # Skip .text -> .text references + # Skip section_name -> section_name references continue sec_name = sec_names[s.sh_info].decode("latin1") - if sec_name == ".mwcats.text": - # Skip Metrowerks CATS Utility section + if sec_name != ".rodata": continue sec_base = sections[s.sh_info].sh_offset for i in range(0, s.sh_size, s.sh_entsize): @@ -1257,11 +1292,16 @@ def dump_elf( f"--stop-address={end_addr}", ] + if project.disassemble_all: + disassemble_flag = "-D" + else: + disassemble_flag = "-d" + flags2 = [ f"--disassemble={diff_elf_symbol}", ] - objdump_flags = ["-drz", "-j", ".text"] + objdump_flags = [disassemble_flag, "-rz", "-j", config.diff_section] return ( project.myimg, (objdump_flags + flags1, project.baseimg, None), @@ -1283,7 +1323,10 @@ def dump_objfile( if start.startswith("0"): fail("numerical start address not supported with -o; pass a function name") - objfile, _ = search_map_file(start, project) + objfile = config.objfile + if not objfile: + objfile, _ = search_map_file(start, project, config) + if not objfile: fail("Not able to find .o file for function.") @@ -1297,7 +1340,12 @@ def dump_objfile( if not os.path.isfile(refobjfile): fail(f'Please ensure an OK .o file exists at "{refobjfile}".') - objdump_flags = ["-drz", "-j", ".text"] + if project.disassemble_all: + disassemble_flag = "-D" + else: + disassemble_flag = "-d" + + objdump_flags = [disassemble_flag, "-rz", "-j", config.diff_section] return ( objfile, (objdump_flags, refobjfile, start), @@ -1314,7 +1362,7 @@ def dump_binary( run_make(project.myimg, project) start_addr = maybe_eval_int(start) if start_addr is None: - _, start_addr = search_map_file(start, project) + _, start_addr = search_map_file(start, project, config) if start_addr is None: fail("Not able to find function in map file.") if end is not None: @@ -1333,6 +1381,7 @@ def dump_binary( (objdump_flags + flags2, project.myimg, None), ) + # Example: "ldr r4, [pc, #56] ; (4c )" ARM32_LOAD_POOL_PATTERN = r"(ldr\s+r([0-9]|1[0-3]),\s+\[pc,.*;\s*)(\([a-fA-F0-9]+.*\))" @@ -1363,7 +1412,7 @@ class AsmProcessor: class AsmProcessorMIPS(AsmProcessor): def process_reloc(self, row: str, prev: str) -> str: arch = self.config.arch - if "R_MIPS_NONE" in row: + if "R_MIPS_NONE" in row or "R_MIPS_JALR" in row: # GNU as emits no-op relocations immediately after real ones when # assembling with -mabi=64. Return without trying to parse 'imm' as an # integer. @@ -1378,12 +1427,9 @@ class AsmProcessorMIPS(AsmProcessor): # TODO: handle unambiguous cases where all addends for a symbol are the # same, or show "+???". mnemonic = prev.split()[0] - if ( - mnemonic in arch.instructions_with_address_immediates - and not imm.startswith("0x") - ): - imm = "0x" + imm - repl += "+" + imm if int(imm, 0) > 0 else imm + if mnemonic in arch.instructions_with_address_immediates: + imm = hex(int(imm, 16)) + repl += ("" if imm.startswith("-") else "+") + imm if "R_MIPS_LO16" in row: repl = f"%lo({repl})" elif "R_MIPS_HI16" in row: @@ -1398,6 +1444,12 @@ class AsmProcessorMIPS(AsmProcessor): # Branch to glabel. This gives confusing output, but there's not much # we can do here. pass + elif "R_MIPS_GPREL16" in row: + repl = f"%gp_rel({repl})" + elif "R_MIPS_GOT16" in row: + repl = f"%got({repl})" + elif "R_MIPS_CALL16" in row: + repl = f"%call16({repl})" else: assert False, f"unknown relocation type '{row}' for line '{prev}'" return before + repl + after @@ -1544,6 +1596,7 @@ class ArchSettings: big_endian: Optional[bool] = True delay_slot_instructions: Set[str] = field(default_factory=set) + MIPS_BRANCH_LIKELY_INSTRUCTIONS = { "beql", "bnel", @@ -1651,10 +1704,13 @@ PPC_BRANCH_INSTRUCTIONS = { MIPS_SETTINGS = ArchSettings( name="mips", re_int=re.compile(r"[0-9]+"), - re_comment=re.compile(r"<.*?>"), - re_reg=re.compile( - r"\$?\b(a[0-7]|t[0-9]|s[0-8]|at|v[01]|f[12]?[0-9]|f3[01]|kt?[01]|fp|ra|zero)\b" - ), + re_comment=re.compile(r"<.*>"), + # Includes: + # - General purpose registers v0..1, a0..7, t0..9, s0..8, zero, at, fp, k0..1/kt0..1 + # - Float registers f0..31, or fv0..1, fa0..7, ft0..15, fs0..8 plus odd complements + # (actually used number depends on ABI) + # sp, gp should not be in this list + re_reg=re.compile(r"\$?\b([astv][0-9]|at|f[astv]?[0-9]+f?|kt?[01]|fp|ra|zero)\b"), re_sprel=re.compile(r"(?<=,)([0-9]+|0x[0-9a-f]+)\(sp\)"), re_large_imm=re.compile(r"-?[1-9][0-9]{2,}|-?0x[0-9a-f]{3,}"), re_imm=re.compile(r"(\b|-)([0-9]+|0x[0-9a-fA-F]+)\b(?!\(sp)|%(lo|hi)\([^)]*\)"), @@ -1672,7 +1728,7 @@ MIPSEL_SETTINGS = replace(MIPS_SETTINGS, name="mipsel", big_endian=False) ARM32_SETTINGS = ArchSettings( name="arm32", re_int=re.compile(r"[0-9]+"), - re_comment=re.compile(r"(<.*?>|//.*$)"), + re_comment=re.compile(r"(<.*>|//.*$)"), # Includes: # - General purpose registers: r0..13 # - Frame pointer registers: lr (r14), pc (r15) @@ -1690,26 +1746,33 @@ ARM32_SETTINGS = ArchSettings( proc=AsmProcessorARM32, ) +ARMEL_SETTINGS = replace(ARM32_SETTINGS, name="armel", big_endian=False) + AARCH64_SETTINGS = ArchSettings( name="aarch64", re_int=re.compile(r"[0-9]+"), - re_comment=re.compile(r"(<.*?>|//.*$)"), - # GPRs and FP registers: X0-X30, W0-W30, [DSHQ]0..31 + re_comment=re.compile(r"(<.*>|//.*$)"), + # GPRs and FP registers: X0-X30, W0-W30, [BHSDVQ]0..31 + # (FP registers may be followed by data width and number of elements, e.g. V0.4S) # The zero registers and SP should not be in this list. - re_reg=re.compile(r"\$?\b([dshq][12]?[0-9]|[dshq]3[01]|[xw][12]?[0-9]|[xw]30)\b"), + re_reg=re.compile( + r"\$?\b([bhsdvq]([12]?[0-9]|3[01])(\.\d\d?[bhsdvq])?|[xw][12]?[0-9]|[xw]30)\b" + ), re_sprel=re.compile(r"sp, #-?(0x[0-9a-fA-F]+|[0-9]+)\b"), re_large_imm=re.compile(r"-?[1-9][0-9]{2,}|-?0x[0-9a-f]{3,}"), re_imm=re.compile(r"(?|//.*$)"), + re_comment=re.compile(r"(<.*>|//.*$)"), re_reg=re.compile(r"\$?\b([rf][0-9]+)\b"), re_sprel=re.compile(r"(?<=,)(-?[0-9]+|-?0x[0-9a-f]+)\(r1\)"), re_large_imm=re.compile(r"-?[1-9][0-9]{2,}|-?0x[0-9a-f]{3,}"), @@ -1724,6 +1787,7 @@ ARCH_SETTINGS = [ MIPS_SETTINGS, MIPSEL_SETTINGS, ARM32_SETTINGS, + ARMEL_SETTINGS, AARCH64_SETTINGS, PPC_SETTINGS, ] @@ -1743,6 +1807,7 @@ def hexify_int(row: str, pat: Match[str], arch: ArchSettings) -> str: def parse_relocated_line(line: str) -> Tuple[str, str, str]: + # Pick out the last argument for c in ",\t ": if c in line: ind2 = line.rindex(c) @@ -1751,6 +1816,7 @@ def parse_relocated_line(line: str) -> Tuple[str, str, str]: raise Exception(f"failed to parse relocated line: {line}") before = line[: ind2 + 1] after = line[ind2 + 1 :] + # Move an optional ($reg) part of it to 'after' ind2 = after.find("(") if ind2 == -1: imm, after = after, "" @@ -1879,8 +1945,15 @@ def process(dump: str, config: Config) -> List[Line]: row_parts = [part.lstrip() for part in row.split(" ", 1)] mnemonic = row_parts[0].strip() - if mnemonic not in arch.instructions_with_address_immediates: - row = re.sub(arch.re_int, lambda m: hexify_int(row, m, arch), row) + addr = "" + if mnemonic in arch.instructions_with_address_immediates: + row, addr = split_off_address(row) + # objdump prefixes addresses with 0x/-0x if they don't resolve to some + # symbol + offset. Strip that. + addr = addr.replace("0x", "") + + row = re.sub(arch.re_int, lambda m: hexify_int(row, m, arch), row) + row += addr # Let 'original' be 'row' with relocations applied, while we continue # transforming 'row' into a coarser version that ignores registers and @@ -1900,9 +1973,6 @@ def process(dump: str, config: Config) -> List[Line]: scorable_line = normalized_original if not config.score_stack_differences: scorable_line = re.sub(arch.re_sprel, "addr(sp)", scorable_line) - if mnemonic in arch.branch_instructions: - # Replace the final argument with "" - scorable_line = re.sub(r"[^, \t]+$", "", scorable_line) if skip_next: skip_next = False @@ -1925,8 +1995,6 @@ def process(dump: str, config: Config) -> List[Line]: branch_target = None if mnemonic in arch.branch_instructions: branch_target = int(row_parts[1].strip().split(",")[-1], 16) - if mnemonic in arch.branch_likely_instructions: - branch_target -= 4 output.append( Line( @@ -1974,7 +2042,9 @@ def split_off_address(line: str) -> Tuple[str, str]: parts = line.split(",") if len(parts) < 2: parts = line.split(None, 1) - off = len(line) - len(parts[-1]) + if len(parts) < 2: + parts.append("") + off = len(line) - len(parts[-1].strip()) return line[:off], line[off:] @@ -1990,7 +2060,7 @@ def diff_sequences( ) -> List[Tuple[str, int, int, int, int]]: if ( algorithm != "levenshtein" - or len(seq1) * len(seq2) > 4 * 10 ** 8 + or len(seq1) * len(seq2) > 4 * 10**8 or len(seq1) + len(seq2) >= 0x110000 ): return diff_sequences_difflib(seq1, seq2) @@ -2177,10 +2247,15 @@ class Diff: def trim_nops(lines: List[Line], arch: ArchSettings) -> List[Line]: lines = lines[:] - while lines and lines[-1].mnemonic == "nop" and (len(lines) == 1 or lines[-2].mnemonic not in arch.delay_slot_instructions): + while ( + lines + and lines[-1].mnemonic == "nop" + and (len(lines) == 1 or lines[-2].mnemonic not in arch.delay_slot_instructions) + ): lines.pop() return lines + def do_diff(lines1: List[Line], lines2: List[Line], config: Config) -> Diff: if config.show_source: import cxxfilt @@ -2212,7 +2287,6 @@ def do_diff(lines1: List[Line], lines2: List[Line], config: Config) -> Diff: lines2 = trim_nops(lines2, arch) diffed_lines = diff_lines(lines1, lines2, config.algorithm) - score = score_diff_lines(diffed_lines, config) max_score = len(lines1) * config.penalty_deletion line_num_base = -1 @@ -2281,10 +2355,15 @@ def do_diff(lines1: List[Line], lines2: List[Line], config: Config) -> Diff: line2_line = line_num_2to1[line2.line_num] line2_target = (line2_line[0] + (target - line2.line_num), 0) - # Set the key for three-way diffing to a normalized version. + # Adjust the branch target for scoring and three-way diffing. norm2, norm_branch2 = split_off_address(line2.normalized_original) - if norm_branch2 != "": - line2.normalized_original = norm2 + str(line2_target) + if norm_branch2 != "": + retargetted = hex(line2_target[0]).replace("0x", "") + if line2_target[1] != 0: + retargetted += f"+{line2_target[1]}" + line2.normalized_original = norm2 + retargetted + sc_base, _ = split_off_address(line2.scorable_line) + line2.scorable_line = sc_base + retargetted same_target = line2_target == (line1.branch_target, 0) else: # Do a naive comparison for non-branches (e.g. function calls). @@ -2444,6 +2523,7 @@ def do_diff(lines1: List[Line], lines2: List[Line], config: Config) -> Diff: ) ) + score = score_diff_lines(diffed_lines, config) output = output[config.skip_lines :] return Diff(lines=output, score=score, max_score=max_score) diff --git a/tools/asm-processor/asm_processor.py b/tools/asm-processor/asm_processor.py index 6923752be4..544b1b1b77 100644 --- a/tools/asm-processor/asm_processor.py +++ b/tools/asm-processor/asm_processor.py @@ -783,6 +783,13 @@ def parse_source(f, opt, framepointer, mips1, input_enc, output_enc, out_depende else: min_instr_count = 2 skip_instr_count = 1 + elif opt == 'O0': + if framepointer: + min_instr_count = 8 + skip_instr_count = 8 + else: + min_instr_count = 4 + skip_instr_count = 4 elif opt == 'g': if framepointer: min_instr_count = 7 @@ -792,7 +799,7 @@ def parse_source(f, opt, framepointer, mips1, input_enc, output_enc, out_depende skip_instr_count = 4 else: if opt != 'g3': - raise Failure("must pass one of -g, -O1, -O2, -O2 -g3") + raise Failure("must pass one of -g, -O0, -O1, -O2, -O2 -g3") if framepointer: min_instr_count = 4 skip_instr_count = 4 @@ -813,6 +820,7 @@ def parse_source(f, opt, framepointer, mips1, input_enc, output_enc, out_depende ] is_cutscene_data = False + is_early_include = False for line_no, raw_line in enumerate(f, 1): raw_line = raw_line.rstrip() @@ -832,44 +840,51 @@ def parse_source(f, opt, framepointer, mips1, input_enc, output_enc, out_depende global_asm = None else: global_asm.process_line(raw_line, output_enc) + elif line in ['GLOBAL_ASM(', '#pragma GLOBAL_ASM(']: + global_asm = GlobalAsmBlock("GLOBAL_ASM block at line " + str(line_no)) + start_index = len(output_lines) + elif ((line.startswith('GLOBAL_ASM("') or line.startswith('#pragma GLOBAL_ASM("')) + and line.endswith('")')): + fname = line[line.index('(') + 2 : -2] + out_dependencies.append(fname) + global_asm = GlobalAsmBlock(fname) + with open(fname, encoding=input_enc) as f: + for line2 in f: + global_asm.process_line(line2.rstrip(), output_enc) + src, fn = global_asm.finish(state) + output_lines[-1] = ''.join(src) + asm_functions.append(fn) + global_asm = None + elif line == '#pragma asmproc recurse': + # C includes qualified as + # #pragma asmproc recurse + # #include "file.c" + # will be processed recursively when encountered + is_early_include = True + elif is_early_include: + # Previous line was a #pragma asmproc recurse + is_early_include = False + if not line.startswith("#include "): + raise Failure("#pragma asmproc recurse must be followed by an #include ") + fpath = os.path.dirname(f.name) + fname = os.path.join(fpath, line[line.index(' ') + 2 : -1]) + out_dependencies.append(fname) + include_src = StringIO() + with open(fname, encoding=input_enc) as include_file: + parse_source(include_file, opt, framepointer, mips1, input_enc, output_enc, out_dependencies, include_src) + include_src.write('#line ' + str(line_no + 1) + ' "' + f.name + '"') + output_lines[-1] = include_src.getvalue() + include_src.close() else: - if line in ['GLOBAL_ASM(', '#pragma GLOBAL_ASM(']: - global_asm = GlobalAsmBlock("GLOBAL_ASM block at line " + str(line_no)) - start_index = len(output_lines) - elif ((line.startswith('GLOBAL_ASM("') or line.startswith('#pragma GLOBAL_ASM("')) - and line.endswith('")')): - fname = line[line.index('(') + 2 : -2] - out_dependencies.append(fname) - global_asm = GlobalAsmBlock(fname) - with open(fname, encoding=input_enc) as f: - for line2 in f: - global_asm.process_line(line2.rstrip(), output_enc) - src, fn = global_asm.finish(state) - output_lines[-1] = ''.join(src) - asm_functions.append(fn) - global_asm = None - elif line.startswith('#include "') and line.endswith('" EARLY'): - # C includes qualified with EARLY (i.e. #include "file.c" EARLY) will be - # processed recursively when encountered - fpath = os.path.dirname(f.name) - fname = os.path.join(fpath, line[line.index(' ') + 2 : -7]) - out_dependencies.append(fname) - include_src = StringIO() - with open(fname, encoding=input_enc) as include_file: - parse_source(include_file, opt, framepointer, mips1, input_enc, output_enc, out_dependencies, include_src) - include_src.write('#line ' + str(line_no + 1) + ' "' + f.name + '"') - output_lines[-1] = include_src.getvalue() - include_src.close() - else: - # This is a hack to replace all floating-point numbers in an array of a particular type - # (in this case CutsceneData) with their corresponding IEEE-754 hexadecimal representation - if cutscene_data_regexpr.search(line) is not None: - is_cutscene_data = True - elif line.endswith("};"): - is_cutscene_data = False - if is_cutscene_data: - raw_line = re.sub(float_regexpr, repl_float_hex, raw_line) - output_lines[-1] = raw_line + # This is a hack to replace all floating-point numbers in an array of a particular type + # (in this case CutsceneData) with their corresponding IEEE-754 hexadecimal representation + if cutscene_data_regexpr.search(line) is not None: + is_cutscene_data = True + elif line.endswith("};"): + is_cutscene_data = False + if is_cutscene_data: + raw_line = re.sub(float_regexpr, repl_float_hex, raw_line) + output_lines[-1] = raw_line if print_source: if isinstance(print_source, StringIO): @@ -877,7 +892,14 @@ def parse_source(f, opt, framepointer, mips1, input_enc, output_enc, out_depende print_source.write(line + '\n') else: for line in output_lines: - print_source.write(line.encode(output_enc) + b'\n') + try: + line_encoded = line.encode(output_enc) + except UnicodeEncodeError: + print("Failed to encode a line to", output_enc) + print("The line:", line) + print("The line, utf-8-encoded:", line.encode("utf-8")) + raise + print_source.write(line_encoded + b'\n') print_source.flush() if print_source != sys.stdout.buffer: print_source.close() @@ -1239,6 +1261,7 @@ def run_wrapped(argv, outfile, functions): parser.add_argument('-mips1', dest='mips1', action='store_true') parser.add_argument('-g3', dest='g3', action='store_true') group = parser.add_mutually_exclusive_group(required=True) + group.add_argument('-O0', dest='opt', action='store_const', const='O0') group.add_argument('-O1', dest='opt', action='store_const', const='O1') group.add_argument('-O2', dest='opt', action='store_const', const='O2') group.add_argument('-g', dest='opt', action='store_const', const='g') diff --git a/tools/asm-processor/build.py b/tools/asm-processor/build.py index 493afd4d5f..480dec9ed1 100755 --- a/tools/asm-processor/build.py +++ b/tools/asm-processor/build.py @@ -10,30 +10,49 @@ dir_path = os.path.dirname(os.path.realpath(__file__)) prelude = os.path.join(dir_path, "prelude.inc") all_args = sys.argv[1:] -sep1 = all_args.index('--') -sep2 = all_args.index('--', sep1+1) +sep0 = [index for index, arg in enumerate(all_args) if not arg.startswith("-")][0] +sep1 = all_args.index("--") +sep2 = all_args.index("--", sep1 + 1) -compiler = all_args[:sep1] +asmproc_flags = all_args[:sep0] +compiler = all_args[sep0:sep1] -assembler = all_args[sep1+1:sep2] -assembler_sh = ' '.join(shlex.quote(x) for x in assembler) +assembler = all_args[sep1 + 1 : sep2] +assembler_sh = " ".join(shlex.quote(x) for x in assembler) -compile_args = all_args[sep2+1:] +compile_args = all_args[sep2 + 1 :] in_file = compile_args[-1] -out_ind = compile_args.index('-o') +out_ind = compile_args.index("-o") out_file = compile_args[out_ind + 1] del compile_args[-1] del compile_args[out_ind + 1] del compile_args[out_ind] in_dir = os.path.split(os.path.realpath(in_file))[0] -opt_flags = [x for x in compile_args if x in ['-g3', '-g', '-O1', '-O2', '-framepointer']] +opt_flags = [ + x for x in compile_args if x in ["-g3", "-g", "-O0", "-O1", "-O2", "-framepointer"] +] +if "-mips2" not in compile_args: + opt_flags.append("-mips1") -preprocessed_file = tempfile.NamedTemporaryFile(prefix='preprocessed', suffix='.c', delete=False) +asmproc_flags += opt_flags + [in_file] + +# Drop .mdebug and .gptab sections from resulting binaries. This makes +# resulting .o files much smaller and speeds up builds, but loses line +# number debug data. +# asmproc_flags += ["--drop-mdebug-gptab"] + +# Convert encoding before compiling. +# asmproc_flags += ["--input-enc", "utf-8", "--output-enc", "euc-jp"] + +preprocessed_file = tempfile.NamedTemporaryFile( + prefix="preprocessed", suffix=".c", delete=False +) try: - asmproc_flags = opt_flags + [in_file, '--input-enc', 'utf-8', '--output-enc', 'euc-jp'] - compile_cmdline = compiler + compile_args + ['-I', in_dir, '-o', out_file, preprocessed_file.name] + compile_cmdline = ( + compiler + compile_args + ["-I", in_dir, "-o", out_file, preprocessed_file.name] + ) functions, deps = asm_processor.run(asmproc_flags, outfile=preprocessed_file) try: @@ -41,13 +60,24 @@ try: except subprocess.CalledProcessError as e: print("Failed to compile file " + in_file + ". Command line:") print() - print(' '.join(shlex.quote(x) for x in compile_cmdline)) + print(" ".join(shlex.quote(x) for x in compile_cmdline)) print() sys.exit(55) # To keep the preprocessed file: # os._exit(1) - asm_processor.run(asmproc_flags + ['--post-process', out_file, '--assembler', assembler_sh, '--asm-prelude', prelude], functions=functions) + asm_processor.run( + asmproc_flags + + [ + "--post-process", + out_file, + "--assembler", + assembler_sh, + "--asm-prelude", + prelude, + ], + functions=functions, + ) deps_file = out_file[:-2] + ".asmproc.d" if deps: diff --git a/tools/asm-processor/prelude.inc b/tools/asm-processor/prelude.inc index 1ec8c60361..3e58ff1498 100644 --- a/tools/asm-processor/prelude.inc +++ b/tools/asm-processor/prelude.inc @@ -1,5 +1,43 @@ .set noat .set noreorder .set gp=64 -.include "macro.inc" +.macro glabel label + .global \label + \label: +.endm + +# Float register aliases (o32 ABI, odd ones are rarely used) + +.set $fv0, $f0 +.set $fv0f, $f1 +.set $fv1, $f2 +.set $fv1f, $f3 +.set $ft0, $f4 +.set $ft0f, $f5 +.set $ft1, $f6 +.set $ft1f, $f7 +.set $ft2, $f8 +.set $ft2f, $f9 +.set $ft3, $f10 +.set $ft3f, $f11 +.set $fa0, $f12 +.set $fa0f, $f13 +.set $fa1, $f14 +.set $fa1f, $f15 +.set $ft4, $f16 +.set $ft4f, $f17 +.set $ft5, $f18 +.set $ft5f, $f19 +.set $fs0, $f20 +.set $fs0f, $f21 +.set $fs1, $f22 +.set $fs1f, $f23 +.set $fs2, $f24 +.set $fs2f, $f25 +.set $fs3, $f26 +.set $fs3f, $f27 +.set $fs4, $f28 +.set $fs4f, $f29 +.set $fs5, $f30 +.set $fs5f, $f31 diff --git a/tools/disasm/disasm.py b/tools/disasm/disasm.py index 103860ed2e..cb634d1385 100755 --- a/tools/disasm/disasm.py +++ b/tools/disasm/disasm.py @@ -2,34 +2,44 @@ import argparse, ast, math, os, re, struct import bisect -from mips_isa import * -from multiprocessing import * +import multiprocessing from pathlib import Path +import mips_isa + +# Consider implementing gpr naming too, but already uses abi names by default +fpr_name_options = { + "numeric": mips_isa.numeric_fpr_names, + "o32": mips_isa.o32_fpr_names, +} parser = argparse.ArgumentParser() parser.add_argument( "-j", dest="jobs", type=int, default=1, help="number of processes to run at once" ) parser.add_argument( - "--full", - "-f", - dest="full", + "-a", + "--all", + dest="all", action="store_true", default=False, help="Decompile all files regardless of whether they are used or not", ) parser.add_argument( - "-files", + "-f", "--files", dest="files", nargs="+", required=False, help="Optional list of files to diassemble separated by a space. This is a whitelist, all files will be skipped besides the ones listed here if used.", ) +parser.add_argument("--reg-names", choices=fpr_name_options.keys(), help="How to name registers in the output") args = parser.parse_args() jobs = args.jobs +mips_isa.mips_fpr_names = fpr_name_options.get(args.reg_names, mips_isa.mips_fpr_names) + + ASM_OUT = "asm/" DATA_OUT = "data/" @@ -122,71 +132,71 @@ def discard_decomped_files(files_spec, include_files): MIPS_BRANCH_LIKELY_INSNS = [ - MIPS_INS_BEQL, - MIPS_INS_BGEZALL, - MIPS_INS_BGEZL, - MIPS_INS_BGTZL, - MIPS_INS_BLEZL, - MIPS_INS_BLTZALL, - MIPS_INS_BLTZL, - MIPS_INS_BNEL, - MIPS_INS_BC1TL, - MIPS_INS_BC1FL, + mips_isa.MIPS_INS_BEQL, + mips_isa.MIPS_INS_BGEZALL, + mips_isa.MIPS_INS_BGEZL, + mips_isa.MIPS_INS_BGTZL, + mips_isa.MIPS_INS_BLEZL, + mips_isa.MIPS_INS_BLTZALL, + mips_isa.MIPS_INS_BLTZL, + mips_isa.MIPS_INS_BNEL, + mips_isa.MIPS_INS_BC1TL, + mips_isa.MIPS_INS_BC1FL, ] MIPS_BRANCH_INSNS = [ *MIPS_BRANCH_LIKELY_INSNS, - MIPS_INS_BEQ, - MIPS_INS_BGEZ, - MIPS_INS_BGEZAL, - MIPS_INS_BGTZ, - MIPS_INS_BNE, - MIPS_INS_BLTZ, - MIPS_INS_BLTZAL, - MIPS_INS_BLEZ, - MIPS_INS_BC1T, - MIPS_INS_BC1F, - MIPS_INS_BEQZ, - MIPS_INS_BNEZ, - MIPS_INS_B, + mips_isa.MIPS_INS_BEQ, + mips_isa.MIPS_INS_BGEZ, + mips_isa.MIPS_INS_BGEZAL, + mips_isa.MIPS_INS_BGTZ, + mips_isa.MIPS_INS_BNE, + mips_isa.MIPS_INS_BLTZ, + mips_isa.MIPS_INS_BLTZAL, + mips_isa.MIPS_INS_BLEZ, + mips_isa.MIPS_INS_BC1T, + mips_isa.MIPS_INS_BC1F, + mips_isa.MIPS_INS_BEQZ, + mips_isa.MIPS_INS_BNEZ, + mips_isa.MIPS_INS_B, ] -MIPS_JUMP_INSNS = [MIPS_INS_JAL, MIPS_INS_JALR, MIPS_INS_J, MIPS_INS_JR] +MIPS_JUMP_INSNS = [mips_isa.MIPS_INS_JAL, mips_isa.MIPS_INS_JALR, mips_isa.MIPS_INS_J, mips_isa.MIPS_INS_JR] -MIPS_FP_LOAD_INSNS = [MIPS_INS_LWC1, MIPS_INS_LDC1] +MIPS_FP_LOAD_INSNS = [mips_isa.MIPS_INS_LWC1, mips_isa.MIPS_INS_LDC1] -MIPS_FP_STORE_INSNS = [MIPS_INS_SWC1, MIPS_INS_SDC1] +MIPS_FP_STORE_INSNS = [mips_isa.MIPS_INS_SWC1, mips_isa.MIPS_INS_SDC1] MIPS_FP_LOAD_STORE_INSNS = [*MIPS_FP_LOAD_INSNS, *MIPS_FP_STORE_INSNS] MIPS_STORE_INSNS = [ - MIPS_INS_SB, - MIPS_INS_SH, - MIPS_INS_SW, - MIPS_INS_SWL, - MIPS_INS_SWR, - MIPS_INS_SD, - MIPS_INS_SDL, - MIPS_INS_SDR, - MIPS_INS_SC, - MIPS_INS_SCD, + mips_isa.MIPS_INS_SB, + mips_isa.MIPS_INS_SH, + mips_isa.MIPS_INS_SW, + mips_isa.MIPS_INS_SWL, + mips_isa.MIPS_INS_SWR, + mips_isa.MIPS_INS_SD, + mips_isa.MIPS_INS_SDL, + mips_isa.MIPS_INS_SDR, + mips_isa.MIPS_INS_SC, + mips_isa.MIPS_INS_SCD, *MIPS_FP_STORE_INSNS, ] MIPS_LOAD_STORE_INSNS = [ - MIPS_INS_LB, - MIPS_INS_LBU, - MIPS_INS_LH, - MIPS_INS_LHU, - MIPS_INS_LW, - MIPS_INS_LWL, - MIPS_INS_LWR, - MIPS_INS_LWU, - MIPS_INS_LD, - MIPS_INS_LDL, - MIPS_INS_LDR, - MIPS_INS_LL, - MIPS_INS_LLD, + mips_isa.MIPS_INS_LB, + mips_isa.MIPS_INS_LBU, + mips_isa.MIPS_INS_LH, + mips_isa.MIPS_INS_LHU, + mips_isa.MIPS_INS_LW, + mips_isa.MIPS_INS_LWL, + mips_isa.MIPS_INS_LWR, + mips_isa.MIPS_INS_LWU, + mips_isa.MIPS_INS_LD, + mips_isa.MIPS_INS_LDL, + mips_isa.MIPS_INS_LDR, + mips_isa.MIPS_INS_LL, + mips_isa.MIPS_INS_LLD, *MIPS_STORE_INSNS, *MIPS_FP_LOAD_STORE_INSNS, ] @@ -615,7 +625,7 @@ def find_symbols_in_text(section, rodata_section, data_regions): # assert insn.value_forname(insn.fields[0]) is not None # print(f"insn: {insn.mnemonic}, rt: {insn.rt}, first: {insn.value_forname(insn.fields[0])}") - # assert insn.id not in [MIPS_INS_ORI, MIPS_INS_ADDIU, *MIPS_LOAD_STORE_INSNS] or insn.rt == insn.value_forname(insn.fields[0]) + # assert insn.id not in [MIPS_INS_ORI, mips_isa.MIPS_INS_ADDIU, *MIPS_LOAD_STORE_INSNS] or insn.rt == insn.value_forname(insn.fields[0]) if ( delay_slot @@ -636,9 +646,9 @@ def find_symbols_in_text(section, rodata_section, data_regions): insns = [] for i, raw_insn in enumerate(raw_insns, 0): - insn = decode_insn(raw_insn, vram + i * 4) + insn = mips_isa.decode_insn(raw_insn, vram + i * 4) - if insn.id == MIPS_INS_JR and insn.rs != MIPS_REG_RA: + if insn.id == mips_isa.MIPS_INS_JR and insn.rs != mips_isa.MIPS_REG_RA: # It's hard to find when two jump tables next to each other end, so do a naive first pass # to try and find as many jump tables as possible. # Luckily IDO has a very homogeneous output for jump tables for which it is very unlikely @@ -651,9 +661,9 @@ def find_symbols_in_text(section, rodata_section, data_regions): insn_m2 = insns[-2] insn_m3 = insns[-3] if ( - insn_m1.id == MIPS_INS_LW - and insn_m2.id == MIPS_INS_ADDU - and insn_m3.id == MIPS_INS_LUI + insn_m1.id == mips_isa.MIPS_INS_LW + and insn_m2.id == mips_isa.MIPS_INS_ADDU + and insn_m3.id == mips_isa.MIPS_INS_LUI ): prospective_jtbls.add((insn_m3.imm << 0x10) + insn_m1.imm) insns.append(insn) @@ -674,7 +684,7 @@ def find_symbols_in_text(section, rodata_section, data_regions): Relocated jump targets give us functions in this section """ assert ( - insn.id == MIPS_INS_JAL + insn.id == mips_isa.MIPS_INS_JAL ), f"R_MIPS_26 applied to {insn.mnemonic} when it should be JAL" put_symbol(symbols_dict, "functions", insn.target) elif reloc[1] == 5: # R_MIPS_HI16 @@ -682,7 +692,7 @@ def find_symbols_in_text(section, rodata_section, data_regions): Relocated %hi gives us %hi values to match with associated %lo """ assert ( - insn.id == MIPS_INS_LUI + insn.id == mips_isa.MIPS_INS_LUI ), f"R_MIPS_HI16 applied to {insn.mnemonic} when it should be LUI" prev_hi = insn.imm hi_vram = vram + reloc[2] @@ -691,7 +701,7 @@ def find_symbols_in_text(section, rodata_section, data_regions): Relocated %lo + a %hi to match with gives us relocated symbols in data sections """ assert ( - insn.id == MIPS_INS_ADDIU or insn.id in MIPS_LOAD_STORE_INSNS + insn.id == mips_isa.MIPS_INS_ADDIU or insn.id in MIPS_LOAD_STORE_INSNS ), f"R_MIPS_HI16 applied to {insn.mnemonic} when it should be ADDIU or a load/store" symbol_value = (prev_hi << 0x10) + insn.imm put_symbols(symbols_dict, "symbols", {hi_vram: symbol_value}) @@ -757,16 +767,16 @@ def find_symbols_in_text(section, rodata_section, data_regions): if insn.id in MIPS_BRANCH_INSNS: func_branch_labels.add(insn.offset) delayed_insn = insn - elif insn.id == MIPS_INS_ERET: + elif insn.id == mips_isa.MIPS_INS_ERET: put_symbol(symbols_dict, "functions", vaddr + 4) elif insn.id in MIPS_JUMP_INSNS: - if insn.id == MIPS_INS_JAL: + if insn.id == mips_isa.MIPS_INS_JAL: # mark function at target put_symbol(symbols_dict, "functions", insn.target) - elif insn.id == MIPS_INS_J: + elif insn.id == mips_isa.MIPS_INS_J: # mark label at target func_branch_labels.add(insn.target) - elif insn.id == MIPS_INS_JR: + elif insn.id == mips_isa.MIPS_INS_JR: # check if anything branches past it in either branch or jtbl labels if vaddr >= max(func_branch_labels, default=0) and vaddr >= max( func_jtbl_labels, default=0 @@ -792,7 +802,7 @@ def find_symbols_in_text(section, rodata_section, data_regions): symbols_dict, "functions", vaddr + 8 + n_padding * 4 ) delayed_insn = insn - elif insn.id == MIPS_INS_LUI: + elif insn.id == mips_isa.MIPS_INS_LUI: """ Process LUI instruction @@ -809,34 +819,34 @@ def find_symbols_in_text(section, rodata_section, data_regions): save_tracker(delayed_insn.offset, {insn.rt: (vaddr, insn.imm)}) else: lui_tracker.update({insn.rt: (vaddr, insn.imm)}) - elif insn.id == MIPS_INS_ADDIU or insn.id in MIPS_LOAD_STORE_INSNS: + elif insn.id == mips_isa.MIPS_INS_ADDIU or insn.id in MIPS_LOAD_STORE_INSNS: # try match with tracked lui and mark symbol hi_vram, imm_value = lui_tracker.get( - insn.rs if insn.id == MIPS_INS_ADDIU else insn.base, (None, None) + insn.rs if insn.id == mips_isa.MIPS_INS_ADDIU else insn.base, (None, None) ) # if a match was found, validate and record the symbol, TODO improve validation if hi_vram != None and ( (((imm_value >> 0x8) & 0xF) != 0 and imm_value < 0x1000) or (imm_value >= 0x8000 and imm_value < 0x80D0) or (imm_value >= 0xA400 and imm_value < 0xA480) - or (imm_value < 0x0400 and insn.id == MIPS_INS_ADDIU) + or (imm_value < 0x0400 and insn.id == mips_isa.MIPS_INS_ADDIU) ): lo_vram = vaddr symbol_value = (imm_value << 0x10) + insn.imm put_symbols(symbols_dict, "symbols", {hi_vram: symbol_value}) put_symbols(symbols_dict, "symbols", {lo_vram: symbol_value}) - if insn.id == MIPS_INS_LW: + if insn.id == mips_isa.MIPS_INS_LW: # try find jr within the same block cur_idx = i lookahead_insn = insns[cur_idx] # TODO fix vaddr here # still in same block unless one of these instructions are found while lookahead_insn.id not in [ *MIPS_BRANCH_INSNS, - MIPS_INS_JAL, - MIPS_INS_JALR, - MIPS_INS_J, + mips_isa.MIPS_INS_JAL, + mips_isa.MIPS_INS_JALR, + mips_isa.MIPS_INS_J, ]: - if lookahead_insn.id == MIPS_INS_JR: + if lookahead_insn.id == mips_isa.MIPS_INS_JR: if lookahead_insn.rs == ( insn.ft if insn.id in MIPS_FP_LOAD_STORE_INSNS @@ -884,24 +894,24 @@ def find_symbols_in_text(section, rodata_section, data_regions): if cur_idx >= len(raw_insns): break lookahead_insn = insns[cur_idx] # TODO fix vaddr here - elif insn.id == MIPS_INS_LD: # doubleword loads + elif insn.id == mips_isa.MIPS_INS_LD: # doubleword loads put_symbol(symbols_dict, "dwords", symbol_value) - elif insn.id in [MIPS_INS_LWC1, MIPS_INS_SWC1]: # float load/stores + elif insn.id in [mips_isa.MIPS_INS_LWC1, mips_isa.MIPS_INS_SWC1]: # float load/stores # add float put_symbol(symbols_dict, "floats", symbol_value) - elif insn.id in [MIPS_INS_LDC1, MIPS_INS_SDC1]: # double load/stores + elif insn.id in [mips_isa.MIPS_INS_LDC1, mips_isa.MIPS_INS_SDC1]: # double load/stores # add double put_symbol(symbols_dict, "doubles", symbol_value) elif ( - insn.id == MIPS_INS_ADDIU and vaddr % 4 == 0 + insn.id == mips_isa.MIPS_INS_ADDIU and vaddr % 4 == 0 ): # strings seem to only ever be 4-byte aligned # add possible string put_symbol(symbols_dict, "prospective_strings", symbol_value) # clear lui tracking state if register is clobbered by the addiu/load instruction itself - # insn.rt == (insn.rs if insn.id == MIPS_INS_ADDIU else insn.base) and + # insn.rt == (insn.rs if insn.id == mips_isa.MIPS_INS_ADDIU else insn.base) and if insn.id not in MIPS_STORE_INSNS and insn.id not in MIPS_FP_LOAD_INSNS: clobber_conditionally(insn) - elif insn.id == MIPS_INS_ORI: + elif insn.id == mips_isa.MIPS_INS_ORI: # try match with tracked lui and mark constant hi_vram, imm_value = lui_tracker.get(insn.rs, (None, None)) if hi_vram != None: # found match @@ -916,7 +926,7 @@ def find_symbols_in_text(section, rodata_section, data_regions): else: # clear lui tracking if register is clobbered by something unrelated if ( - insn.id == MIPS_INS_ADDU + insn.id == mips_isa.MIPS_INS_ADDU and insn.rs in lui_tracker.keys() and (insn.rd == insn.rs) ): @@ -929,35 +939,35 @@ def find_symbols_in_text(section, rodata_section, data_regions): pass # insns listed either write to fprs/cop0 or don't write to any elif insn.id not in [ - MIPS_INS_MTC0, - MIPS_INS_MTC1, - MIPS_INS_DMTC1, - MIPS_INS_MULT, - MIPS_INS_MULTU, - MIPS_INS_DMULT, - MIPS_INS_DMULTU, - MIPS_INS_DIV, - MIPS_INS_DIVU, - MIPS_INS_DDIV, - MIPS_INS_DDIVU, - MIPS_INS_MTHI, - MIPS_INS_MTLO, - MIPS_INS_CTC1, - MIPS_INS_NOP, - MIPS_INS_BREAK, - MIPS_INS_TLBP, - MIPS_INS_TLBR, - MIPS_INS_TLBWI, - MIPS_INS_MOV_S, - MIPS_INS_MOV_D, - MIPS_INS_C_LT_S, - MIPS_INS_C_LT_D, - MIPS_INS_DIV_S, - MIPS_INS_MUL_S, - MIPS_INS_TRUNC_W_S, - MIPS_INS_CVT_S_W, - MIPS_INS_SUB_S, - MIPS_INS_ADD_S, + mips_isa.MIPS_INS_MTC0, + mips_isa.MIPS_INS_MTC1, + mips_isa.MIPS_INS_DMTC1, + mips_isa.MIPS_INS_MULT, + mips_isa.MIPS_INS_MULTU, + mips_isa.MIPS_INS_DMULT, + mips_isa.MIPS_INS_DMULTU, + mips_isa.MIPS_INS_DIV, + mips_isa.MIPS_INS_DIVU, + mips_isa.MIPS_INS_DDIV, + mips_isa.MIPS_INS_DDIVU, + mips_isa.MIPS_INS_MTHI, + mips_isa.MIPS_INS_MTLO, + mips_isa.MIPS_INS_CTC1, + mips_isa.MIPS_INS_NOP, + mips_isa.MIPS_INS_BREAK, + mips_isa.MIPS_INS_TLBP, + mips_isa.MIPS_INS_TLBR, + mips_isa.MIPS_INS_TLBWI, + mips_isa.MIPS_INS_MOV_S, + mips_isa.MIPS_INS_MOV_D, + mips_isa.MIPS_INS_C_LT_S, + mips_isa.MIPS_INS_C_LT_D, + mips_isa.MIPS_INS_DIV_S, + mips_isa.MIPS_INS_MUL_S, + mips_isa.MIPS_INS_TRUNC_W_S, + mips_isa.MIPS_INS_CVT_S_W, + mips_isa.MIPS_INS_SUB_S, + mips_isa.MIPS_INS_ADD_S, ]: clobber_conditionally(insn) @@ -1000,18 +1010,18 @@ def find_symbols_in_text(section, rodata_section, data_regions): part += ", " op_str.append(part) - elif insn.id == MIPS_INS_LUI: + elif insn.id == mips_isa.MIPS_INS_LUI: op_str = [op_str] instr["rt"] = insn.rt - elif insn.id == MIPS_INS_ADDIU or insn.id in MIPS_LOAD_STORE_INSNS: + elif insn.id == mips_isa.MIPS_INS_ADDIU or insn.id in MIPS_LOAD_STORE_INSNS: op_str = [op_str] instr["rt"] = insn.rt instr["rs"] = insn.rs instr["ft"] = insn.ft instr["base"] = insn.base - elif insn.id == MIPS_INS_ORI: + elif insn.id == mips_isa.MIPS_INS_ORI: op_str = [op_str] instr["rt"] = insn.rt instr["rs"] = insn.rs @@ -1031,13 +1041,13 @@ def find_symbols_in_text(section, rodata_section, data_regions): if delay_slot and delayed_insn is not None: if ( - delayed_insn.id == MIPS_INS_JAL - or delayed_insn.id == MIPS_INS_JALR - or (delayed_insn.id == MIPS_INS_JR and delayed_insn.rs == MIPS_REG_RA) + delayed_insn.id == mips_isa.MIPS_INS_JAL + or delayed_insn.id == mips_isa.MIPS_INS_JALR + or (delayed_insn.id == mips_isa.MIPS_INS_JR and delayed_insn.rs == mips_isa.MIPS_REG_RA) ): # destroy lui tracking state lui_tracker.clear() - elif delayed_insn.id == MIPS_INS_JR and vaddr == next_jtbl_jr + 4: + elif delayed_insn.id == mips_isa.MIPS_INS_JR and vaddr == next_jtbl_jr + 4: # save lui tracking state for each jtbl label for label in individual_jtbl_labels[next_jtbl_jr]: save_tracker(label, lui_tracker.copy()) @@ -1046,7 +1056,7 @@ def find_symbols_in_text(section, rodata_section, data_regions): # save lui tracking state save_tracker(delayed_insn.offset, lui_tracker.copy()) # destroy current lui tracking state for unconditional branches - if delayed_insn.id == MIPS_INS_B: + if delayed_insn.id == mips_isa.MIPS_INS_B: lui_tracker.clear() delayed_insn = None @@ -1265,35 +1275,35 @@ def fixup_text_symbols(data, vram, data_regions, info): else: line += op_part - elif insn["id"] == MIPS_INS_LUI: + elif insn["id"] == mips_isa.MIPS_INS_LUI: symbol_value = symbols.get(vaddr, None) if symbol_value is not None: line += ( - f"{mips_gpr_names[insn['rt']]}, %hi({proper_name(symbol_value)})" + f"{ mips_isa.mips_gpr_names[insn['rt']]}, %hi({proper_name(symbol_value)})" ) else: constant_value = constants.get(vaddr, None) if constant_value is not None: line += ( - f"{mips_gpr_names[insn['rt']]}, (0x{constant_value:08X} >> 16)" + f"{ mips_isa.mips_gpr_names[insn['rt']]}, (0x{constant_value:08X} >> 16)" ) else: line += entry["op"][0] - elif insn["id"] == MIPS_INS_ADDIU or insn["id"] in MIPS_LOAD_STORE_INSNS: + elif insn["id"] == mips_isa.MIPS_INS_ADDIU or insn["id"] in MIPS_LOAD_STORE_INSNS: symbol_value = symbols.get(vaddr, None) if symbol_value is not None: - if insn["id"] == MIPS_INS_ADDIU: - line += f"{mips_gpr_names[insn['rt']]}, {mips_gpr_names[insn['rs']]}, %lo({proper_name(symbol_value)})" + if insn["id"] == mips_isa.MIPS_INS_ADDIU: + line += f"{ mips_isa.mips_gpr_names[insn['rt']]}, { mips_isa.mips_gpr_names[insn['rs']]}, %lo({proper_name(symbol_value)})" else: - line += f"{mips_fpr_names[insn['ft']] if insn['id'] in MIPS_FP_LOAD_STORE_INSNS else mips_gpr_names[insn['rt']]}, %lo({proper_name(symbol_value)})({mips_gpr_names[insn['base']]})" + line += f"{mips_isa.mips_fpr_names[insn['ft']] if insn['id'] in MIPS_FP_LOAD_STORE_INSNS else mips_isa.mips_gpr_names[insn['rt']]}, %lo({proper_name(symbol_value)})({ mips_isa.mips_gpr_names[insn['base']]})" else: line += entry["op"][0] - elif insn["id"] == MIPS_INS_ORI: + elif insn["id"] == mips_isa.MIPS_INS_ORI: constant_value = constants.get(vaddr, None) if constant_value is not None: - line += f"{mips_gpr_names[insn['rt']]}, {mips_gpr_names[insn['rs']]}, (0x{constant_value:08X} & 0xFFFF)" + line += f"{ mips_isa.mips_gpr_names[insn['rt']]}, { mips_isa.mips_gpr_names[insn['rs']]}, (0x{constant_value:08X} & 0xFFFF)" else: line += entry["op"][0] @@ -1329,7 +1339,7 @@ def disassemble_text(data, vram, data_regions, info): for i, raw_insn in enumerate(raw_insns, 0): i *= 4 vaddr = vram + i - insn = decode_insn(raw_insns[i // 4], vaddr) + insn = mips_isa.decode_insn(raw_insns[i // 4], vaddr) mnemonic = insn.mnemonic op_str = insn.op_str @@ -1389,27 +1399,27 @@ def disassemble_text(data, vram, data_regions, info): op_str_parts.append(insn.format_field(field)) op_str = ", ".join(op_str_parts) delayed_insn = insn - elif insn.id == MIPS_INS_LUI: + elif insn.id == mips_isa.MIPS_INS_LUI: symbol_value = symbols.get(vaddr, None) if symbol_value is not None: - op_str = f"{mips_gpr_names[insn.rt]}, %hi({proper_name(symbol_value)})" + op_str = f"{ mips_isa.mips_gpr_names[insn.rt]}, %hi({proper_name(symbol_value)})" else: constant_value = constants.get(vaddr, None) if constant_value is not None: op_str = ( - f"{mips_gpr_names[insn.rt]}, (0x{constant_value:08X} >> 16)" + f"{ mips_isa.mips_gpr_names[insn.rt]}, (0x{constant_value:08X} >> 16)" ) - elif insn.id == MIPS_INS_ADDIU or insn.id in MIPS_LOAD_STORE_INSNS: + elif insn.id == mips_isa.MIPS_INS_ADDIU or insn.id in MIPS_LOAD_STORE_INSNS: symbol_value = symbols.get(vaddr, None) if symbol_value is not None: - if insn.id == MIPS_INS_ADDIU: - op_str = f"{mips_gpr_names[insn.rt]}, {mips_gpr_names[insn.rs]}, %lo({proper_name(symbol_value)})" + if insn.id == mips_isa.MIPS_INS_ADDIU: + op_str = f"{ mips_isa.mips_gpr_names[insn.rt]}, { mips_isa.mips_gpr_names[insn.rs]}, %lo({proper_name(symbol_value)})" else: - op_str = f"{mips_fpr_names[insn.ft] if insn.id in MIPS_FP_LOAD_STORE_INSNS else mips_gpr_names[insn.rt]}, %lo({proper_name(symbol_value)})({mips_gpr_names[insn.base]})" - elif insn.id == MIPS_INS_ORI: + op_str = f"{mips_isa.mips_fpr_names[insn.ft] if insn.id in MIPS_FP_LOAD_STORE_INSNS else mips_isa.mips_gpr_names[insn.rt]}, %lo({proper_name(symbol_value)})({ mips_isa.mips_gpr_names[insn.base]})" + elif insn.id == mips_isa.MIPS_INS_ORI: constant_value = constants.get(vaddr, None) if constant_value is not None: - op_str = f"{mips_gpr_names[insn.rt]}, {mips_gpr_names[insn.rs]}, (0x{constant_value:08X} & 0xFFFF)" + op_str = f"{ mips_isa.mips_gpr_names[insn.rt]}, { mips_isa.mips_gpr_names[insn.rs]}, (0x{constant_value:08X} & 0xFFFF)" if delay_slot: mnemonic = " " + mnemonic @@ -2205,7 +2215,7 @@ for segment in files_spec: new[offset] = name full_file_list[segment[0]] = new -if args.full: +if args.all: new_spec = [] for segment in files_spec: if args.files and not any( @@ -2357,7 +2367,7 @@ for segment in files_spec: del files_spec[:] -pool = get_context("fork").Pool(jobs) +pool = multiprocessing.get_context("fork").Pool(jobs) # Find symbols for each segment for section in all_sections: if section[-1]["name"] == "makerom": @@ -2393,7 +2403,7 @@ for section in all_sections: pool.close() pool.join() -pool = get_context("fork").Pool(jobs) +pool = multiprocessing.get_context("fork").Pool(jobs) for section in all_sections: if section[-1]["type"] == "makerom": continue @@ -2418,7 +2428,7 @@ for section in all_sections: vrom_addrs = {addr for _, addr in vrom_variables} # Textual disassembly for each segment -with get_context("fork").Pool(jobs) as p: +with multiprocessing.get_context("fork").Pool(jobs) as p: p.map( disassemble_segment, [ diff --git a/tools/disasm/files.txt b/tools/disasm/files.txt index a43ef93f45..d8cd09c995 100644 --- a/tools/disasm/files.txt +++ b/tools/disasm/files.txt @@ -418,7 +418,7 @@ 0x8012F2E0 : "z_scene", 0x801307C0 : "z_scene_proc", 0x801322C0 : "z_scene_table", - 0x801323D0 : "code_801323D0", + 0x801323D0 : "z_schedule", 0x801330E0 : "z_skelanime", 0x80137970 : "z_skin", 0x80138410 : "z_skin_awb", @@ -554,13 +554,14 @@ 0x801C2730 : "", 0x801C3B60 : "z_scene_proc", 0x801C3CA0 : "z_scene_table", - 0x801C5C50 : "", + 0x801C5C50 : "z_schedule", 0x801C5CB0 : "z_skelanime", 0x801C5CD0 : "z_skin_matrix", 0x801C5D10 : "z_sub_s", 0x801C5DD0 : "z_vimode", 0x801C5E30 : "z_vr_box", 0x801C5FC0 : "z_sram_NES", + 0x801C6A70 : "z_message", 0x801D0470 : "z_message_nes", 0x801D0B50 : "z_player_call", 0x801D0B70 : "z_kaleido_manager", diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 33bd070229..f489634c01 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -12,8 +12,8 @@ 0x80080514:("Idle_ThreadEntry",), 0x800805E0:("ViConfig_UpdateVi",), 0x80080748:("ViConfig_UpdateBlack",), - 0x80080790:("DmaMgr_DMARomToRam",), - 0x800808D4:("DmaMgr_DmaCallback0",), + 0x80080790:("DmaMgr_DmaRomToRam",), + 0x800808D4:("DmaMgr_DmaHandler",), 0x800808F4:("DmaMgr_FindDmaEntry",), 0x80080950:("DmaMgr_TranslateVromToRom",), 0x800809BC:("DmaMgr_FindDmaIndex",), @@ -158,12 +158,12 @@ 0x80086280:("__assert",), 0x800862B4:("func_800862B4",), 0x800862E0:("SystemArena_MallocMin1",), - 0x80086310:("SystemArena_FreeNull",), - 0x8008633C:("func_8008633C",), - 0x800863AC:("func_800863AC",), - 0x8008641C:("func_8008641C",), - 0x800864EC:("func_800864EC",), - 0x80086588:("func_80086588",), + 0x80086310:("SystemArena_FreeNullCheck",), + 0x8008633C:("SystemArena_RunBlockFunc",), + 0x800863AC:("SystemArena_RunBlockFunc1",), + 0x8008641C:("SystemArena_RunBlockFunc8",), + 0x800864EC:("SystemArena_RunBlockFunc1Reverse",), + 0x80086588:("SystemArena_RunInits",), 0x800865F8:("SystemArena_Init",), 0x80086620:("PadSetup_Init",), 0x80086760:("func_80086760",), @@ -867,7 +867,7 @@ 0x800BCB70:("Actor_SetColorFilter",), 0x800BCBF4:("func_800BCBF4",), 0x800BCC68:("func_800BCC68",), - 0x800BCCDC:("func_800BCCDC",), + 0x800BCCDC:("Actor_GetClosestPosOnPath",), 0x800BD2B4:("func_800BD2B4",), 0x800BD384:("func_800BD384",), 0x800BD6B8:("func_800BD6B8",), @@ -893,7 +893,7 @@ 0x800BE568:("func_800BE568",), 0x800BE5CC:("func_800BE5CC",), 0x800BE63C:("Actor_IsSmallChest",), - 0x800BE680:("func_800BE680",), + 0x800BE680:("Actor_DrawDamageEffects",), 0x800BF7CC:("Actor_SpawnIceEffects",), 0x800BF9A0:("ActorOverlayTable_FaultPrint",), 0x800BFA78:("ActorOverlayTable_FaultAddrConv",), @@ -1290,7 +1290,7 @@ 0x800DFFAC:("func_800DFFAC",), 0x800E007C:("func_800E007C",), 0x800E01AC:("func_800E01AC",), - 0x800E01B8:("func_800E01B8",), + 0x800E01B8:("Camera_GetQuakeOffset",), 0x800E01DC:("func_800E01DC",), 0x800E0228:("func_800E0228",), 0x800E0238:("func_800E0238",), @@ -1699,7 +1699,7 @@ 0x800F4540:("Jpeg_ParseMarkers",), 0x800F470C:("Jpeg_Decode",), 0x800F4A10:("func_800F4A10",), - 0x800F4C0C:("func_800F4C0C",), + 0x800F4C0C:("KaleidoSetup_Update",), 0x800F4E20:("KaleidoSetup_Init",), 0x800F4F28:("KaleidoSetup_Destroy",), 0x800F4F40:("Font_LoadChar",), @@ -2499,26 +2499,26 @@ 0x80132338:("Entrance_GetSceneNumAbsolute",), 0x80132374:("Entrance_GetSpawnNum",), 0x801323A0:("Entrance_GetTransitionFlags",), - 0x801323D0:("func_801323D0",), - 0x80132428:("func_80132428",), - 0x80132494:("func_80132494",), - 0x801326B8:("func_801326B8",), - 0x801328F0:("func_801328F0",), - 0x80132920:("func_80132920",), - 0x80132938:("func_80132938",), - 0x80132954:("func_80132954",), - 0x8013296C:("func_8013296C",), - 0x80132A18:("func_80132A18",), - 0x80132A3C:("func_80132A3C",), - 0x80132A80:("func_80132A80",), - 0x80132AD8:("func_80132AD8",), - 0x80132B24:("func_80132B24",), - 0x80132B84:("func_80132B84",), - 0x80132D70:("func_80132D70",), - 0x80132E9C:("func_80132E9C",), - 0x80132FDC:("func_80132FDC",), - 0x80133000:("func_80133000",), - 0x80133038:("func_80133038",), + 0x801323D0:("Schedule_CheckFlagS",), + 0x80132428:("Schedule_CheckFlagL",), + 0x80132494:("Schedule_CheckTimeRangeS",), + 0x801326B8:("Schedule_CheckTimeRangeL",), + 0x801328F0:("Schedule_ReturnValueL",), + 0x80132920:("Schedule_ReturnNone",), + 0x80132938:("Schedule_ReturnEmpty",), + 0x80132954:("Schedule_Nop",), + 0x8013296C:("Schedule_CheckMiscS",), + 0x80132A18:("Schedule_ReturnValueS",), + 0x80132A3C:("Schedule_CheckSceneS",), + 0x80132A80:("Schedule_CheckSceneL",), + 0x80132AD8:("Schedule_CheckDayS",), + 0x80132B24:("Schedule_CheckDayL",), + 0x80132B84:("Schedule_ReturnTime",), + 0x80132D70:("Schedule_CheckBeforeTimeS",), + 0x80132E9C:("Schedule_CheckBeforeTimeL",), + 0x80132FDC:("Schedule_BranchL",), + 0x80133000:("Schedule_JumpL",), + 0x80133038:("Schedule_RunScript",), 0x801330E0:("SkelAnime_DrawLimbLod",), 0x801332F0:("SkelAnime_DrawLod",), 0x801334A0:("SkelAnime_DrawFlexLimbLod",), @@ -2608,23 +2608,23 @@ 0x801378B8:("Animation_OnFrame",), 0x801378E0:("SkelAnime_Free",), 0x8013792C:("SkelAnime_CopyFrameTable",), - 0x80137970:("func_80137970",), - 0x80137B34:("func_80137B34",), - 0x80137EBC:("func_80137EBC",), - 0x80137F58:("func_80137F58",), - 0x80138050:("func_80138050",), + 0x80137970:("Skin_UpdateVertices",), + 0x80137B34:("Skin_ApplyLimbModifications",), + 0x80137EBC:("Skin_DrawAnimatedLimb",), + 0x80137F58:("Skin_DrawLimb",), + 0x80138050:("Skin_DrawImpl",), 0x80138228:("func_80138228",), 0x80138258:("func_80138258",), 0x8013828C:("func_8013828C",), 0x801382C4:("func_801382C4",), - 0x80138300:("func_80138300",), - 0x8013835C:("func_8013835C",), - 0x80138410:("func_80138410",), - 0x80138424:("func_80138424",), - 0x8013859C:("func_8013859C",), - 0x80138700:("func_80138700",), + 0x80138300:("Skin_GetLimbPos",), + 0x8013835C:("Skin_GetVertexPos",), + 0x80138410:("Skin_Setup",), + 0x80138424:("Skin_InitAnimatedLimb",), + 0x8013859C:("Skin_Init",), + 0x80138700:("Skin_Free",), 0x801387D4:("func_801387D4",), - 0x801388E4:("func_801388E4",), + 0x801388E4:("Skin_ApplyAnimTransformations",), 0x80138BA0:("SkinMatrix_Vec3fMtxFMultXYZW",), 0x80138C88:("SkinMatrix_Vec3fMtxFMultXYZ",), 0x80138D38:("SkinMatrix_MtxFMtxFMult",), @@ -2658,7 +2658,7 @@ 0x8013A7C0:("SubS_FindDoor",), 0x8013A860:("SubS_DrawTransformFlexLimb",), 0x8013AB00:("SubS_DrawTransformFlex",), - 0x8013AD6C:("func_8013AD6C",), + 0x8013AD6C:("SubS_InCsMode",), 0x8013AD9C:("func_8013AD9C",), 0x8013AED4:("SubS_UpdateFlags",), 0x8013AF00:("func_8013AF00",), @@ -2667,47 +2667,47 @@ 0x8013B350:("func_8013B350",), 0x8013B6B0:("func_8013B6B0",), 0x8013B878:("func_8013B878",), - 0x8013BB34:("func_8013BB34",), + 0x8013BB34:("SubS_GetAdditionalPath",), 0x8013BB7C:("SubS_FindNearestActor",), 0x8013BC6C:("SubS_ChangeAnimationByInfoS",), - 0x8013BD40:("func_8013BD40",), - 0x8013BEDC:("func_8013BEDC",), + 0x8013BD40:("SubS_HasReachedPoint",), + 0x8013BEDC:("SubS_GetDayDependentPath",), 0x8013C068:("func_8013C068",), 0x8013C624:("func_8013C624",), - 0x8013C8B8:("func_8013C8B8",), + 0x8013C8B8:("SubS_CopyPointFromPathCheckBounds",), 0x8013C964:("func_8013C964",), - 0x8013CC2C:("func_8013CC2C",), - 0x8013CD64:("func_8013CD64",), - 0x8013CF04:("func_8013CF04",), + 0x8013CC2C:("SubS_FillShadowTex",), + 0x8013CD64:("SubS_GenShadowTex",), + 0x8013CF04:("SubS_DrawShadowTex",), 0x8013D0E0:("func_8013D0E0",), 0x8013D2E0:("func_8013D2E0",), 0x8013D5E8:("SubS_AngleDiffLessEqual",), - 0x8013D648:("func_8013D648",), - 0x8013D68C:("func_8013D68C",), - 0x8013D720:("func_8013D720",), - 0x8013D768:("func_8013D768",), - 0x8013D83C:("func_8013D83C",), + 0x8013D648:("SubS_GetPathByIndex",), + 0x8013D68C:("SubS_CopyPointFromPath",), + 0x8013D720:("SubS_GetDistSqAndOrientPoints",), + 0x8013D768:("SubS_MoveActorToPoint",), + 0x8013D83C:("SubS_GetDistSqAndOrientPath",), 0x8013D8DC:("SubS_IsObjectLoaded",), 0x8013D924:("SubS_GetObjectIndex",), 0x8013D960:("SubS_FindActor",), 0x8013D9C8:("SubS_FillLimbRotTables",), - 0x8013DB90:("func_8013DB90",), - 0x8013DC40:("func_8013DC40",), - 0x8013DCCC:("func_8013DCCC",), - 0x8013DCE0:("func_8013DCE0",), - 0x8013DE04:("func_8013DE04",), - 0x8013DF3C:("func_8013DF3C",), - 0x8013E054:("func_8013E054",), - 0x8013E07C:("func_8013E07C",), - 0x8013E0A4:("func_8013E0A4",), + 0x8013DB90:("SubS_IsFloorAbove",), + 0x8013DC40:("SubS_CopyPointFromPathList",), + 0x8013DCCC:("SubS_GetPathCount",), + 0x8013DCE0:("SubS_ActorPathing_Init",), + 0x8013DE04:("SubS_ActorPathing_Update",), + 0x8013DF3C:("SubS_ActorPathing_ComputePointInfo",), + 0x8013E054:("SubS_ActorPathing_MoveWithGravity",), + 0x8013E07C:("SubS_ActorPathing_MoveWithoutGravityReverse",), + 0x8013E0A4:("SubS_ActorPathing_SetNextPoint",), 0x8013E1C8:("SubS_ChangeAnimationBySpeedInfo",), 0x8013E2D4:("SubS_StartActorCutscene",), 0x8013E3B8:("SubS_FillCutscenesList",), - 0x8013E4B0:("func_8013E4B0",), - 0x8013E5CC:("func_8013E5CC",), + 0x8013E4B0:("SubS_ConstructPlane",), + 0x8013E5CC:("SubS_LineSegVsPlane",), 0x8013E640:("SubS_FindActorCustom",), 0x8013E748:("func_8013E748",), - 0x8013E7C0:("func_8013E7C0",), + 0x8013E7C0:("SubS_ActorAndPlayerFaceEachOther",), 0x8013E8F8:("func_8013E8F8",), 0x8013E950:("func_8013E950",), 0x8013EC10:("func_8013EC10",), @@ -2787,30 +2787,30 @@ 0x80143624:("SkyboxDraw_SetColors",), 0x80143668:("SkyboxDraw_Draw",), 0x80143A04:("SkyboxDraw_Noop",), - 0x80143A10:("func_80143A10",), - 0x80143A54:("func_80143A54",), - 0x80143AC4:("func_80143AC4",), - 0x80143B0C:("func_80143B0C",), + 0x80143A10:("Sram_ActivateOwl",), + 0x80143A54:("Sram_ClearHighscores",), + 0x80143AC4:("Sram_ClearFlagsAtDawnOfTheFirstDay",), + 0x80143B0C:("Sram_SaveEndOfCycle",), 0x80144574:("Sram_IncrementDay",), 0x801445E4:("Sram_CalcChecksum",), - 0x80144628:("func_80144628",), + 0x80144628:("Sram_ResetSave",), 0x80144684:("Sram_GenerateRandomSaveFields",), - 0x80144890:("func_80144890",), + 0x80144890:("Sram_InitNewSave",), 0x80144968:("Sram_InitDebugSave",), 0x80144A94:("func_80144A94",), - 0x80144E78:("func_80144E78",), + 0x80144E78:("Sram_OpenSave",), 0x8014546C:("func_8014546C",), 0x80145698:("func_80145698",), 0x801457CC:("func_801457CC",), 0x80146580:("func_80146580",), 0x80146628:("func_80146628",), - 0x80146AA0:("func_80146AA0",), + 0x80146AA0:("Sram_InitSave",), 0x80146DF8:("func_80146DF8",), - 0x80146E40:("func_80146E40",), + 0x80146E40:("Sram_InitSram",), 0x80146E70:("Sram_Alloc",), 0x80146EBC:("func_80146EBC",), - 0x80146EE8:("func_80146EE8",), - 0x80146F5C:("func_80146F5C",), + 0x80146EE8:("Sram_SaveSpecialEnterClockTown",), + 0x80146F5C:("Sram_SaveSpecialNewDay",), 0x80147008:("func_80147008",), 0x80147020:("func_80147020",), 0x80147068:("func_80147068",), @@ -2822,8 +2822,8 @@ 0x8014750C:("Sram_nop8014750C",), 0x80147520:("func_80147520",), 0x80147564:("func_80147564",), - 0x80147624:("func_80147624",), - 0x80147734:("func_80147734",), + 0x80147624:("Message_ShouldAdvance",), + 0x80147734:("Message_ShouldAdvanceSilent",), 0x801477B4:("func_801477B4",), 0x80147818:("func_80147818",), 0x80147F18:("func_80147F18",), @@ -2837,12 +2837,12 @@ 0x801496C8:("func_801496C8",), 0x8014995C:("func_8014995C",), 0x80149C18:("func_80149C18",), - 0x80149EBC:("func_80149EBC",), + 0x80149EBC:("Message_FindMessage",), 0x80149F74:("func_80149F74",), 0x8014AAD0:("func_8014AAD0",), 0x8014ADBC:("func_8014ADBC",), 0x8014C70C:("func_8014C70C",), - 0x8014CC14:("func_8014CC14",), + 0x8014CC14:("Message_LoadChar",), 0x8014CCB4:("func_8014CCB4",), 0x8014CDF0:("func_8014CDF0",), 0x8014CFDC:("func_8014CFDC",), @@ -2874,17 +2874,17 @@ 0x8015680C:("func_8015680C",), 0x801586A4:("func_801586A4",), 0x801586D4:("Message_Init",), - 0x801588D0:("func_801588D0",), - 0x80158988:("func_80158988",), - 0x80158A24:("func_80158A24",), - 0x80158C04:("func_80158C04",), - 0x80158D98:("func_80158D98",), - 0x80158FB0:("func_80158FB0",), - 0x8015926C:("func_8015926C",), + 0x801588D0:("Message_FindMessageNES",), + 0x80158988:("Message_LoadCharNES",), + 0x80158A24:("Message_LoadPluralRupeesNES",), + 0x80158C04:("Message_LoadLocalizedRupeesNES",), + 0x80158D98:("Message_LoadRupeesNES",), + 0x80158FB0:("Message_LoadTimeNES",), + 0x8015926C:("Message_LoadAreaTextNES",), 0x80159438:("func_80159438",), 0x8015966C:("func_8015966C",), 0x8015B198:("func_8015B198",), - 0x8015E750:("func_8015E750",), + 0x8015E750:("Message_FindCreditsMessage",), 0x8015E7EC:("func_8015E7EC",), 0x8015F8A8:("func_8015F8A8",), 0x80160A90:("PlayerCall_InitFuncPtrs",), @@ -2998,7 +2998,7 @@ 0x80168090:("Play_Draw",), 0x80168DAC:("func_80168DAC",), 0x80168F64:("Play_Update",), - 0x801690CC:("func_801690CC",), + 0x801690CC:("Play_InCsMode",), 0x80169100:("func_80169100",), 0x801691F0:("func_801691F0",), 0x80169220:("Play_LoadScene",), @@ -3548,138 +3548,138 @@ 0x8018AE34:("func_8018AE34",), 0x8018B0F0:("func_8018B0F0",), 0x8018B10C:("func_8018B10C",), - 0x8018B250:("func_8018B250",), - 0x8018B318:("func_8018B318",), - 0x8018B3FC:("func_8018B3FC",), - 0x8018B474:("func_8018B474",), - 0x8018B4F8:("func_8018B4F8",), - 0x8018B520:("func_8018B520",), - 0x8018B578:("func_8018B578",), + 0x8018B250:("AudioHeap_ResetLoadStatus",), + 0x8018B318:("AudioHeap_DiscardFont",), + 0x8018B3FC:("AudioHeap_ReleaseNotesForFont",), + 0x8018B474:("AudioHeap_DiscardSequence",), + 0x8018B4F8:("AudioHeap_WritebackDCache",), + 0x8018B520:("AudioHeap_AllocZeroedAttemptExternal",), + 0x8018B578:("AudioHeap_AllocAttemptExternal",), 0x8018B5D0:("AudioHeap_AllocDmaMemory",), - 0x8018B608:("func_8018B608",), - 0x8018B640:("func_8018B640",), - 0x8018B69C:("func_8018B69C",), - 0x8018B6E8:("func_8018B6E8",), - 0x8018B740:("func_8018B740",), - 0x8018B768:("func_8018B768",), - 0x8018B77C:("func_8018B77C",), - 0x8018B7AC:("func_8018B7AC",), - 0x8018B7BC:("func_8018B7BC",), - 0x8018B8FC:("func_8018B8FC",), - 0x8018B95C:("func_8018B95C",), - 0x8018B9E0:("func_8018B9E0",), - 0x8018BA64:("func_8018BA64",), - 0x8018BB28:("func_8018BB28",), - 0x8018BBEC:("func_8018BBEC",), - 0x8018C380:("func_8018C380",), - 0x8018C3D8:("func_8018C3D8",), + 0x8018B608:("AudioHeap_AllocDmaMemoryZeroed",), + 0x8018B640:("AudioHeap_AllocZeroed",), + 0x8018B69C:("AudioHeap_TestAlloc",), + 0x8018B6E8:("AudioHeap_Alloc",), + 0x8018B740:("AudioHeap_AllocPoolInit",), + 0x8018B768:("AudioHeap_ClearPersistentCache",), + 0x8018B77C:("AudioHeap_ClearTemporaryCache",), + 0x8018B7AC:("AudioHeap_ResetPool",), + 0x8018B7BC:("AudioHeap_PopCache",), + 0x8018B8FC:("AudioHeap_InitMainPool",), + 0x8018B95C:("AudioHeap_InitSessionPool",), + 0x8018B9E0:("AudioHeap_InitCachePool",), + 0x8018BA64:("AudioHeap_InitPersistentCache",), + 0x8018BB28:("AudioHeap_InitTemporaryCache",), + 0x8018BBEC:("AudioHeap_AllocCached",), + 0x8018C380:("AudioHeap_SearchCaches",), + 0x8018C3D8:("AudioHeap_SearchRegularCaches",), 0x8018C4E4:("func_8018C4E4",), - 0x8018C8B8:("func_8018C8B8",), - 0x8018C8E8:("func_8018C8E8",), - 0x8018C93C:("func_8018C93C",), - 0x8018C994:("func_8018C994",), - 0x8018CB70:("func_8018CB70",), - 0x8018CB78:("func_8018CB78",), - 0x8018CC3C:("func_8018CC3C",), - 0x8018CCA8:("func_8018CCA8",), - 0x8018CFAC:("func_8018CFAC",), - 0x8018D57C:("func_8018D57C",), - 0x8018D5D4:("func_8018D5D4",), - 0x8018D658:("func_8018D658",), - 0x8018D6C8:("func_8018D6C8",), - 0x8018D760:("func_8018D760",), - 0x8018DA50:("func_8018DA50",), - 0x8018DBC4:("func_8018DBC4",), - 0x8018DCB4:("func_8018DCB4",), - 0x8018DCF8:("func_8018DCF8",), - 0x8018DD98:("func_8018DD98",), - 0x8018DDD4:("func_8018DDD4",), - 0x8018DF24:("func_8018DF24",), - 0x8018DFE0:("func_8018DFE0",), - 0x8018E00C:("func_8018E00C",), - 0x8018E03C:("func_8018E03C",), - 0x8018E2A8:("func_8018E2A8",), - 0x8018E344:("func_8018E344",), - 0x8018E8C8:("func_8018E8C8",), - 0x8018EB60:("func_8018EB60",), - 0x8018EC4C:("func_8018EC4C",), - 0x8018EF88:("func_8018EF88",), + 0x8018C8B8:("AudioHeap_ClearFilter",), + 0x8018C8E8:("AudioHeap_LoadLowPassFilter",), + 0x8018C93C:("AudioHeap_LoadHighPassFilter",), + 0x8018C994:("AudioHeap_LoadFilter",), + 0x8018CB70:("AudioHeap_UpdateReverb",), + 0x8018CB78:("AudioHeap_UpdateReverbs",), + 0x8018CC3C:("AudioHeap_ClearAiBuffers",), + 0x8018CCA8:("AudioHeap_ResetStep",), + 0x8018CFAC:("AudioHeap_Init",), + 0x8018D57C:("AudioHeap_SearchPermanentCache",), + 0x8018D5D4:("AudioHeap_AllocPermanent",), + 0x8018D658:("AudioHeap_AllocSampleCache",), + 0x8018D6C8:("AudioHeap_InitSampleCaches",), + 0x8018D760:("AudioHeap_AllocTemporarySampleCacheEntry",), + 0x8018DA50:("AudioHeap_UnapplySampleCacheForFont",), + 0x8018DBC4:("AudioHeap_DiscardSampleCacheEntry",), + 0x8018DCB4:("AudioHeap_UnapplySampleCache",), + 0x8018DCF8:("AudioHeap_AllocPersistentSampleCacheEntry",), + 0x8018DD98:("AudioHeap_DiscardSampleCacheForFont",), + 0x8018DDD4:("AudioHeap_DiscardSampleCaches",), + 0x8018DF24:("AudioHeap_ChangeStorage",), + 0x8018DFE0:("AudioHeap_DiscardSampleBank",), + 0x8018E00C:("AudioHeap_ApplySampleBankCache",), + 0x8018E03C:("AudioHeap_ApplySampleBankCacheInternal",), + 0x8018E2A8:("AudioHeap_DiscardSampleBanks",), + 0x8018E344:("AudioHeap_SetReverbData",), + 0x8018E8C8:("AudioHeap_InitReverb",), + 0x8018EB60:("AudioLoad_DecreaseSampleDmaTtls",), + 0x8018EC4C:("AudioLoad_DmaSampleData",), + 0x8018EF88:("AudioLoad_InitSampleDmaBuffers",), 0x8018F220:("AudioLoad_IsFontLoadComplete",), - 0x8018F298:("func_8018F298",), - 0x8018F310:("func_8018F310",), - 0x8018F388:("func_8018F388",), - 0x8018F3B8:("func_8018F3B8",), - 0x8018F3E8:("func_8018F3E8",), - 0x8018F448:("func_8018F448",), - 0x8018F478:("func_8018F478",), - 0x8018F4D8:("func_8018F4D8",), - 0x8018F588:("func_8018F588",), - 0x8018F604:("func_8018F604",), - 0x8018F6F0:("func_8018F6F0",), - 0x8018F7C0:("func_8018F7C0",), - 0x8018F7F8:("func_8018F7F8",), - 0x8018F83C:("func_8018F83C",), - 0x8018F880:("func_8018F880",), - 0x8018F8C4:("func_8018F8C4",), - 0x8018F908:("func_8018F908",), - 0x8018F9B8:("func_8018F9B8",), + 0x8018F298:("AudioLoad_IsSeqLoadComplete",), + 0x8018F310:("AudioLoad_IsSampleLoadComplete",), + 0x8018F388:("AudioLoad_SetFontLoadStatus",), + 0x8018F3B8:("AudioLoad_SetSeqLoadStatus",), + 0x8018F3E8:("AudioLoad_SetSampleFontLoadStatusAndApplyCaches",), + 0x8018F448:("AudioLoad_SetSampleFontLoadStatus",), + 0x8018F478:("AudioLoad_InitTable",), + 0x8018F4D8:("AudioLoad_SyncLoadSeqFonts",), + 0x8018F588:("AudioLoad_SyncLoadSeqParts",), + 0x8018F604:("AudioLoad_SyncLoadSample",), + 0x8018F6F0:("AudioLoad_SyncLoadInstrument",), + 0x8018F7C0:("AudioLoad_AsyncLoad",), + 0x8018F7F8:("AudioLoad_AsyncLoadSeq",), + 0x8018F83C:("AudioLoad_AsyncLoadSampleBank",), + 0x8018F880:("AudioLoad_AsyncLoadFont",), + 0x8018F8C4:("AudioLoad_GetFontsForSequence",), + 0x8018F908:("AudioLoad_DiscardSeqFonts",), + 0x8018F9B8:("AudioLoad_DiscardFont",), 0x8018FA60:("func_8018FA60",), - 0x8018FAD0:("func_8018FAD0",), - 0x8018FB20:("func_8018FB20",), - 0x8018FB78:("func_8018FB78",), - 0x8018FCCC:("func_8018FCCC",), - 0x8018FD20:("func_8018FD20",), - 0x8018FD40:("func_8018FD40",), - 0x8018FE5C:("func_8018FE5C",), - 0x8018FF60:("func_8018FF60",), - 0x80190204:("func_80190204",), - 0x80190240:("func_80190240",), - 0x80190294:("func_80190294",), - 0x801902D8:("func_801902D8",), - 0x80190544:("func_80190544",), - 0x80190668:("func_80190668",), - 0x8019067C:("func_8019067C",), - 0x80190754:("func_80190754",), - 0x8019075C:("func_8019075C",), - 0x8019077C:("func_8019077C",), - 0x80190B08:("func_80190B08",), - 0x80190B38:("func_80190B38",), - 0x80190B44:("func_80190B44",), - 0x80190B50:("func_80190B50",), - 0x80190BB0:("func_80190BB0",), - 0x80190F50:("func_80190F50",), - 0x80190F64:("func_80190F64",), - 0x80191134:("func_80191134",), - 0x801911C4:("func_801911C4",), - 0x801911CC:("func_801911CC",), - 0x80191240:("func_80191240",), - 0x801913C8:("func_801913C8",), - 0x8019144C:("func_8019144C",), - 0x80191460:("func_80191460",), - 0x80191568:("func_80191568",), - 0x80191598:("func_80191598",), - 0x8019161C:("func_8019161C",), - 0x80191740:("func_80191740",), - 0x80191864:("func_80191864",), - 0x80191870:("func_80191870",), - 0x801919AC:("func_801919AC",), - 0x80191B40:("func_80191B40",), - 0x80191BD0:("func_80191BD0",), - 0x80191C40:("func_80191C40",), - 0x80191C54:("func_80191C54",), - 0x80191D94:("func_80191D94",), - 0x8019218C:("func_8019218C",), - 0x80192340:("func_80192340",), - 0x80192388:("func_80192388",), - 0x801924BC:("func_801924BC",), - 0x80192514:("func_80192514",), - 0x80192990:("func_80192990",), - 0x80192AD0:("func_80192AD0",), - 0x80192AD8:("func_80192AD8",), - 0x80192AE0:("func_80192AE0",), - 0x80192AE8:("func_80192AE8",), - 0x80192B54:("func_80192B54",), - 0x80192BAC:("func_80192BAC",), + 0x8018FAD0:("AudioLoad_SyncInitSeqPlayer",), + 0x8018FB20:("AudioLoad_SyncInitSeqPlayerSkipTicks",), + 0x8018FB78:("AudioLoad_SyncInitSeqPlayerInternal",), + 0x8018FCCC:("AudioLoad_SyncLoadSeq",), + 0x8018FD20:("AudioLoad_GetSampleBank",), + 0x8018FD40:("AudioLoad_TrySyncLoadSampleBank",), + 0x8018FE5C:("AudioLoad_SyncLoadFont",), + 0x8018FF60:("AudioLoad_SyncLoad",), + 0x80190204:("AudioLoad_GetRealTableIndex",), + 0x80190240:("AudioLoad_SearchCaches",), + 0x80190294:("AudioLoad_GetLoadTable",), + 0x801902D8:("AudioLoad_RelocateFont",), + 0x80190544:("AudioLoad_SyncDma",), + 0x80190668:("AudioLoad_SyncDmaUnkMedium",), + 0x8019067C:("AudioLoad_Dma",), + 0x80190754:("AudioLoad_Unused1",), + 0x8019075C:("AudioLoad_SyncLoadSimple",), + 0x8019077C:("AudioLoad_AsyncLoadInner",), + 0x80190B08:("AudioLoad_ProcessLoads",), + 0x80190B38:("AudioLoad_SetDmaHandler",), + 0x80190B44:("AudioLoad_SetUnusedHandler",), + 0x80190B50:("AudioLoad_InitSoundFontMeta",), + 0x80190BB0:("AudioLoad_Init",), + 0x80190F50:("AudioLoad_InitSlowLoads",), + 0x80190F64:("AudioLoad_SlowLoadSample",), + 0x80191134:("AudioLoad_GetFontSample",), + 0x801911C4:("AudioLoad_Unused2",), + 0x801911CC:("AudioLoad_FinishSlowLoad",), + 0x80191240:("AudioLoad_ProcessSlowLoads",), + 0x801913C8:("AudioLoad_DmaSlowCopy",), + 0x8019144C:("AudioLoad_DmaSlowCopyUnkMedium",), + 0x80191460:("AudioLoad_SlowLoadSeq",), + 0x80191568:("AudioLoad_InitAsyncLoads",), + 0x80191598:("AudioLoad_StartAsyncLoadUnkMedium",), + 0x8019161C:("AudioLoad_StartAsyncLoad",), + 0x80191740:("AudioLoad_ProcessAsyncLoads",), + 0x80191864:("AudioLoad_ProcessAsyncLoadUnkMedium",), + 0x80191870:("AudioLoad_FinishAsyncLoad",), + 0x801919AC:("AudioLoad_ProcessAsyncLoad",), + 0x80191B40:("AudioLoad_AsyncDma",), + 0x80191BD0:("AudioLoad_AsyncDmaRamUnloaded",), + 0x80191C40:("AudioLoad_AsyncDmaUnkMedium",), + 0x80191C54:("AudioLoad_RelocateSample",), + 0x80191D94:("AudioLoad_RelocateFontAndPreloadSamples",), + 0x8019218C:("AudioLoad_ProcessSamplePreloads",), + 0x80192340:("AudioLoad_AddToSampleSet",), + 0x80192388:("AudioLoad_GetSamplesForFont",), + 0x801924BC:("AudioLoad_AddUsedSample",), + 0x80192514:("AudioLoad_PreloadSamplesForFont",), + 0x80192990:("AudioLoad_LoadPermanentSamples",), + 0x80192AD0:("AudioLoad_Unused3",), + 0x80192AD8:("AudioLoad_Unused4",), + 0x80192AE0:("AudioLoad_Unused5",), + 0x80192AE8:("AudioLoad_ScriptLoad",), + 0x80192B54:("AudioLoad_ProcessScriptLoads",), + 0x80192BAC:("AudioLoad_InitScriptLoads",), 0x80192BE0:("func_80192BE0",), 0x80192C00:("func_80192C00",), 0x8019319C:("func_8019319C",), @@ -3689,7 +3689,7 @@ 0x8019380C:("func_8019380C",), 0x80193858:("func_80193858",), 0x8019387C:("func_8019387C",), - 0x801938A0:("func_801938A0",), + 0x801938A0:("Audio_QueueCmdS8",), 0x801938D0:("func_801938D0",), 0x80193900:("func_80193900",), 0x80193990:("func_80193990",), @@ -3718,8 +3718,8 @@ 0x80194528:("func_80194528",), 0x80194548:("func_80194548",), 0x80194568:("func_80194568",), - 0x80194668:("func_80194668",), - 0x801946E4:("func_801946E4",), + 0x80194668:("Audio_NextRandom",), + 0x801946E4:("Audio_InitMesgQueues",), 0x80194710:("Audio_InvalDCache",), 0x80194750:("Audio_WritebackDCache",), 0x80194790:("func_80194790",), @@ -3777,7 +3777,7 @@ 0x80197B14:("func_80197B14",), 0x80197C0C:("func_80197C0C",), 0x80197C8C:("func_80197C8C",), - 0x80197D24:("func_80197D24",), + 0x80197D24:("AudioSeq_SequencePlayerDisableAsFinished",), 0x80197D4C:("AudioSeq_SequencePlayerDisable",), 0x80197E08:("AudioSeq_AudioListPushBack",), 0x80197E48:("AudioSeq_AudioListPopBack",), @@ -3799,23 +3799,23 @@ 0x8019A0BC:("func_8019A0BC",), 0x8019AA3C:("func_8019AA3C",), 0x8019AAF0:("func_8019AAF0",), - 0x8019AB40:("func_8019AB40",), - 0x8019AC10:("func_8019AC10",), + 0x8019AB40:("AudioSeq_ResetSequencePlayer",), + 0x8019AC10:("AudioSeq_InitSequencePlayerChannels",), 0x8019ACEC:("func_8019ACEC",), - 0x8019ADBC:("func_8019ADBC",), + 0x8019ADBC:("AudioSeq_InitSequencePlayers",), 0x8019AE40:("func_8019AE40",), 0x8019AEC0:("func_8019AEC0",), 0x8019AF00:("func_8019AF00",), 0x8019AF58:("func_8019AF58",), 0x8019AFE8:("func_8019AFE8",), 0x8019B02C:("func_8019B02C",), - 0x8019B074:("func_8019B074",), + 0x8019B074:("AudioOcarina_MapSongFromNotesToButtons",), 0x8019B144:("func_8019B144",), 0x8019B378:("func_8019B378",), 0x8019B38C:("func_8019B38C",), 0x8019B3D0:("func_8019B3D0",), 0x8019B4B8:("func_8019B4B8",), - 0x8019B544:("func_8019B544",), + 0x8019B544:("AudioOcarina_StartDefault",), 0x8019B568:("func_8019B568",), 0x8019B5AC:("func_8019B5AC",), 0x8019B5EC:("func_8019B5EC",), @@ -3828,7 +3828,7 @@ 0x8019C1D0:("func_8019C1D0",), 0x8019C268:("func_8019C268",), 0x8019C2E4:("func_8019C2E4",), - 0x8019C300:("func_8019C300",), + 0x8019C300:("AudioOcarina_SetInstrumentId",), 0x8019C398:("func_8019C398",), 0x8019C5A0:("func_8019C5A0",), 0x8019C8D8:("func_8019C8D8",), @@ -3838,12 +3838,12 @@ 0x8019CEBC:("func_8019CEBC",), 0x8019CF6C:("func_8019CF6C",), 0x8019CF78:("func_8019CF78",), - 0x8019CF9C:("func_8019CF9C",), + 0x8019CF9C:("AudioOcarina_GetPlaybackStaff",), 0x8019CFA8:("func_8019CFA8",), - 0x8019D134:("func_8019D134",), - 0x8019D26C:("func_8019D26C",), - 0x8019D488:("func_8019D488",), - 0x8019D4F8:("func_8019D4F8",), + 0x8019D134:("AudioOcarina_TerminaWallValidateNotes",), + 0x8019D26C:("AudioOcarina_TerminaWallGenerateNotes",), + 0x8019D488:("AudioOcarina_MemoryGameSetNumNotes",), + 0x8019D4F8:("AudioOcarina_MemoryGameGenerateNotes",), 0x8019D600:("func_8019D600",), 0x8019D758:("func_8019D758",), 0x8019D864:("func_8019D864",), @@ -3897,18 +3897,18 @@ 0x8019FE74:("func_8019FE74",), 0x8019FEDC:("func_8019FEDC",), 0x8019FF38:("func_8019FF38",), - 0x8019FF9C:("func_8019FF9C",), - 0x801A0048:("func_801A0048",), - 0x801A00EC:("func_801A00EC",), + 0x8019FF9C:("Audio_PlaySfxForRiver",), + 0x801A0048:("Audio_PlaySfxForWaterfall",), + 0x801A00EC:("Audio_StepFreqLerp",), 0x801A0124:("func_801A0124",), 0x801A0184:("func_801A0184",), 0x801A01C4:("func_801A01C4",), 0x801A0204:("func_801A0204",), 0x801A0238:("func_801A0238",), - 0x801A026C:("func_801A026C",), - 0x801A0318:("func_801A0318",), - 0x801A0450:("func_801A0450",), - 0x801A046C:("func_801A046C",), + 0x801A026C:("Audio_SetGanonsTowerBgmVolumeLevel",), + 0x801A0318:("Audio_SetGanonsTowerBgmVolume",), + 0x801A0450:("Audio_LowerMainBgmVolume",), + 0x801A046C:("Audio_UpdateRiverSoundVolumes",), 0x801A0554:("func_801A0554",), 0x801A05E4:("func_801A05E4",), 0x801A05F0:("func_801A05F0",), @@ -3916,9 +3916,9 @@ 0x801A0810:("func_801A0810",), 0x801A0868:("func_801A0868",), 0x801A09D4:("func_801A09D4",), - 0x801A0C70:("func_801A0C70",), - 0x801A0C90:("func_801A0C90",), - 0x801A0CB0:("func_801A0CB0",), + 0x801A0C70:("Audio_ClearSariaBgm",), + 0x801A0C90:("Audio_ClearSariaBgmAtPos",), + 0x801A0CB0:("Audio_SplitBgmChannels",), 0x801A0E44:("func_801A0E44",), 0x801A1290:("func_801A1290",), 0x801A1348:("func_801A1348",), @@ -3935,8 +3935,8 @@ 0x801A1F88:("func_801A1F88",), 0x801A1FB4:("func_801A1FB4",), 0x801A2090:("func_801A2090",), - 0x801A21FC:("func_801A21FC",), - 0x801A2460:("func_801A2460",), + 0x801A21FC:("Audio_PlaySariaBgm",), + 0x801A2460:("Audio_ClearSariaBgm2",), 0x801A246C:("func_801A246C",), 0x801A2544:("func_801A2544",), 0x801A257C:("func_801A257C",), @@ -4050,7 +4050,7 @@ 0x801A7794:("func_801A7794",), 0x801A7828:("func_801A7828",), 0x801A787C:("func_801A787C",), - 0x801A78E4:("func_801A78E4",), + 0x801A78E4:("Audio_IsSfxPlaying",), 0x801A794C:("func_801A794C",), 0x801A7B10:("func_801A7B10",), 0x801A7D04:("func_801A7D04",), @@ -4061,7 +4061,7 @@ 0x801A8ABC:("func_801A8ABC",), 0x801A8B14:("func_801A8B14",), 0x801A8B2C:("func_801A8B2C",), - 0x801A8BD0:("func_801A8BD0",), + 0x801A8BD0:("Audio_SetVolumeScale",), 0x801A8D5C:("func_801A8D5C",), 0x801A9768:("func_801A9768",), 0x801A982C:("func_801A982C",), @@ -4893,7 +4893,7 @@ 0x80863188:("EnTest_Init",), 0x80863310:("EnTest_Destroy",), 0x8086333C:("EnTest_Update",), - 0x808634B8:("func_808634B8",), + 0x808634B8:("EnTest_OverrideKeyframeDraw",), 0x808636A8:("EnTest_Draw",), 0x80863870:("EnGirlA_SetupAction",), 0x8086387C:("EnGirlA_InitObjIndex",), @@ -5108,40 +5108,40 @@ 0x80872BC0:("func_80872BC0",), 0x80874810:("EnWallmas_Init",), 0x80874A28:("EnWallmas_Destroy",), - 0x80874A88:("func_80874A88",), - 0x80874B04:("func_80874B04",), - 0x80874B88:("func_80874B88",), - 0x80874BE4:("func_80874BE4",), - 0x80874D1C:("func_80874D1C",), - 0x80874DE8:("func_80874DE8",), - 0x80874F14:("func_80874F14",), - 0x80874FD8:("func_80874FD8",), - 0x80875014:("func_80875014",), - 0x80875054:("func_80875054",), - 0x808750B8:("func_808750B8",), - 0x80875108:("func_80875108",), - 0x808751C4:("func_808751C4",), - 0x8087520C:("func_8087520C",), - 0x80875248:("func_80875248",), - 0x808752CC:("func_808752CC",), - 0x808753F0:("func_808753F0",), - 0x80875484:("func_80875484",), - 0x80875518:("func_80875518",), - 0x8087556C:("func_8087556C",), - 0x808755A8:("func_808755A8",), - 0x80875638:("func_80875638",), - 0x808756AC:("func_808756AC",), - 0x8087571C:("func_8087571C",), - 0x808758C8:("func_808758C8",), - 0x80875910:("func_80875910",), - 0x8087596C:("func_8087596C",), - 0x808759B8:("func_808759B8",), - 0x80875A0C:("func_80875A0C",), - 0x80875A74:("func_80875A74",), + 0x80874A88:("EnWallmas_Freeze",), + 0x80874B04:("EnWallmas_ThawIfFrozen",), + 0x80874B88:("EnWallmas_TimerInit",), + 0x80874BE4:("EnWallmas_WaitToDrop",), + 0x80874D1C:("EnWallmas_SetupDrop",), + 0x80874DE8:("EnWallmas_Drop",), + 0x80874F14:("EnWallmas_SetupLand",), + 0x80874FD8:("EnWallmas_Land",), + 0x80875014:("EnWallmas_SetupStand",), + 0x80875054:("EnWallmas_Stand",), + 0x808750B8:("EnWallmas_SetupWalk",), + 0x80875108:("EnWallmas_Walk",), + 0x808751C4:("EnWallmas_SetupJumpToCeiling",), + 0x8087520C:("EnWallmas_JumpToCeiling",), + 0x80875248:("EnWallmas_SetupReturnToCeiling",), + 0x808752CC:("EnWallmas_ReturnToCeiling",), + 0x808753F0:("EnWallmas_SetupDamage",), + 0x80875484:("EnWallmas_Damage",), + 0x80875518:("EnWallmas_SetupCooldown",), + 0x8087556C:("EnWallmas_Cooldown",), + 0x808755A8:("EnWallmas_SetupDie",), + 0x80875638:("EnWallmas_Die",), + 0x808756AC:("EnWallmas_SetupTakePlayer",), + 0x8087571C:("EnWallmas_TakePlayer",), + 0x808758C8:("EnWallmas_ProximityOrSwitchInit",), + 0x80875910:("EnWallmas_WaitForProximity",), + 0x8087596C:("EnWallmas_WaitForSwitchFlag",), + 0x808759B8:("EnWallmas_SetupStun",), + 0x80875A0C:("EnWallmas_Stun",), + 0x80875A74:("EnWallmas_Update",), 0x80875CF4:("EnWallmas_Update",), - 0x80875F04:("func_80875F04",), - 0x808760A4:("func_808760A4",), - 0x80876118:("func_80876118",), + 0x80875F04:("EnWallmas_DrawShadow",), + 0x808760A4:("EnWallmas_OverrideLimbDraw",), + 0x80876118:("EnWallmas_PostLimbDraw",), 0x80876268:("EnWallmas_Draw",), 0x80876670:("EnDodongo_Init",), 0x808768D0:("EnDodongo_Destroy",), @@ -5206,82 +5206,82 @@ 0x8087AF48:("EnFirefly_OverrideLimbDraw",), 0x8087AF98:("EnFirefly_PostLimbDraw",), 0x8087B320:("EnFirefly_Draw",), - 0x8087B730:("func_8087B730",), - 0x8087B784:("func_8087B784",), + 0x8087B730:("EnHorse_RaceWaypointPos",), + 0x8087B784:("EnHorse_RotateToPoint",), 0x8087B7C0:("func_8087B7C0",), - 0x8087C0AC:("func_8087C0AC",), + 0x8087C0AC:("EnHorse_PlayWalkingSound",), 0x8087C178:("func_8087C178",), 0x8087C1C0:("func_8087C1C0",), - 0x8087C208:("func_8087C208",), + 0x8087C208:("EnHorse_SlopeSpeedMultiplier",), 0x8087C288:("func_8087C288",), 0x8087C2B8:("func_8087C2B8",), 0x8087C38C:("func_8087C38C",), - 0x8087C43C:("func_8087C43C",), - 0x8087C590:("func_8087C590",), - 0x8087C8B8:("func_8087C8B8",), - 0x8087C8D0:("func_8087C8D0",), - 0x8087C8E0:("func_8087C8E0",), - 0x8087C9D4:("func_8087C9D4",), - 0x8087C9EC:("func_8087C9EC",), + 0x8087C43C:("EnHorse_IdleAnimSounds",), + 0x8087C590:("EnHorse_Spawn",), + 0x8087C8B8:("EnHorse_ResetCutscene",), + 0x8087C8D0:("EnHorse_ResetRace",), + 0x8087C8E0:("EnHorse_PlayerCanMove",), + 0x8087C9D4:("EnHorse_ResetHorsebackArchery",), + 0x8087C9EC:("EnHorse_ClearDustFlags",), 0x8087C9F8:("func_8087C9F8",), 0x8087CA04:("func_8087CA04",), 0x8087CA14:("EnHorse_Init",), 0x8087D540:("func_8087D540",), 0x8087D69C:("EnHorse_Destroy",), - 0x8087D70C:("func_8087D70C",), - 0x8087D75C:("func_8087D75C",), - 0x8087D814:("func_8087D814",), - 0x8087D988:("func_8087D988",), - 0x8087DDEC:("func_8087DDEC",), - 0x8087DE28:("func_8087DE28",), - 0x8087DF64:("func_8087DF64",), - 0x8087E080:("func_8087E080",), - 0x8087E0A4:("func_8087E0A4",), - 0x8087E18C:("func_8087E18C",), - 0x8087E2A8:("func_8087E2A8",), - 0x8087E350:("func_8087E350",), - 0x8087E564:("func_8087E564",), - 0x8087E5B4:("func_8087E5B4",), - 0x8087E5D8:("func_8087E5D8",), - 0x8087E684:("func_8087E684",), - 0x8087E6D8:("func_8087E6D8",), - 0x8087E92C:("func_8087E92C",), - 0x8087E9D0:("func_8087E9D0",), - 0x8087EA1C:("func_8087EA1C",), - 0x8087EB54:("func_8087EB54",), - 0x8087EB78:("func_8087EB78",), - 0x8087EC20:("func_8087EC20",), - 0x8087EC78:("func_8087EC78",), - 0x8087ED10:("func_8087ED10",), - 0x8087EEC4:("func_8087EEC4",), - 0x8087F078:("func_8087F078",), - 0x8087F1FC:("func_8087F1FC",), - 0x8087F39C:("func_8087F39C",), - 0x8087F590:("func_8087F590",), - 0x8087F5B4:("func_8087F5B4",), - 0x8087F658:("func_8087F658",), - 0x8087F9A0:("func_8087F9A0",), - 0x8087F9C4:("func_8087F9C4",), - 0x8087FB08:("func_8087FB08",), - 0x8087FB14:("func_8087FB14",), - 0x8087FD94:("func_8087FD94",), - 0x8087FDB8:("func_8087FDB8",), - 0x8087FF08:("func_8087FF08",), - 0x8087FF14:("func_8087FF14",), - 0x808801A8:("func_808801A8",), - 0x808801F8:("func_808801F8",), - 0x808802D0:("func_808802D0",), - 0x808804A4:("func_808804A4",), - 0x808804CC:("func_808804CC",), - 0x80880500:("func_80880500",), - 0x80880534:("func_80880534",), - 0x808806DC:("func_808806DC",), - 0x80880844:("func_80880844",), - 0x80880978:("func_80880978",), - 0x80880D50:("func_80880D50",), - 0x80880DA8:("func_80880DA8",), - 0x80880E00:("func_80880E00",), - 0x80881128:("func_80881128",), + 0x8087D70C:("EnHorse_RotateToPlayer",), + 0x8087D75C:("EnHorse_Freeze",), + 0x8087D814:("EnHorse_Frozen",), + 0x8087D988:("EnHorse_UpdateSpeed",), + 0x8087DDEC:("EnHorse_StartMountedIdleResetAnim",), + 0x8087DE28:("EnHorse_StartMountedIdle",), + 0x8087DF64:("EnHorse_MountedIdle",), + 0x8087E080:("EnHorse_MountedIdleAnim",), + 0x8087E0A4:("EnHorse_MountedIdleWhinney",), + 0x8087E18C:("EnHorse_MountedIdleWhinneying",), + 0x8087E2A8:("EnHorse_StartTurning",), + 0x8087E350:("EnHorse_MountedTurn",), + 0x8087E564:("EnHorse_StartWalkingFromIdle",), + 0x8087E5B4:("EnHorse_StartWalkingInterruptable",), + 0x8087E5D8:("EnHorse_StartWalking",), + 0x8087E684:("EnHorse_MountedWalkingReset",), + 0x8087E6D8:("EnHorse_MountedWalk",), + 0x8087E92C:("EnHorse_StartTrotting",), + 0x8087E9D0:("EnHorse_MountedTrotReset",), + 0x8087EA1C:("EnHorse_MountedTrot",), + 0x8087EB54:("EnHorse_StartGallopingInterruptable",), + 0x8087EB78:("EnHorse_StartGalloping",), + 0x8087EC20:("EnHorse_MountedGallopReset",), + 0x8087EC78:("EnHorse_JumpLanding",), + 0x8087ED10:("EnHorse_MountedGallop",), + 0x8087EEC4:("EnHorse_StartRearing",), + 0x8087F078:("EnHorse_MountedRearing",), + 0x8087F1FC:("EnHorse_StartBraking",), + 0x8087F39C:("EnHorse_Stopping",), + 0x8087F590:("EnHorse_StartReversingInterruptable",), + 0x8087F5B4:("EnHorse_StartReversing",), + 0x8087F658:("EnHorse_Reverse",), + 0x8087F9A0:("EnHorse_LowJumpInit",), + 0x8087F9C4:("EnHorse_StartLowJump",), + 0x8087FB08:("EnHorse_Stub1",), + 0x8087FB14:("EnHorse_LowJump",), + 0x8087FD94:("EnHorse_HighJumpInit",), + 0x8087FDB8:("EnHorse_StartHighJump",), + 0x8087FF08:("EnHorse_Stub2",), + 0x8087FF14:("EnHorse_HighJump",), + 0x808801A8:("EnHorse_InitInactive",), + 0x808801F8:("EnHorse_Inactive",), + 0x808802D0:("EnHorse_PlayIdleAnimation",), + 0x808804A4:("EnHorse_ChangeIdleAnimation",), + 0x808804CC:("EnHorse_ResetIdleAnimation",), + 0x80880500:("EnHorse_StartIdleRidable",), + 0x80880534:("EnHorse_Idle",), + 0x808806DC:("EnHorse_StartMovingAnimation",), + 0x80880844:("EnHorse_SetFollowAnimation",), + 0x80880978:("EnHorse_FollowPlayer",), + 0x80880D50:("EnHorse_InitIngoHorse",), + 0x80880DA8:("EnHorse_SetIngoAnimation",), + 0x80880E00:("EnHorse_UpdateIngoHorseAnim",), + 0x80881128:("EnHorse_UpdateIngoRace",), 0x8088126C:("func_8088126C",), 0x80881290:("func_80881290",), 0x80881398:("func_80881398",), @@ -5289,26 +5289,26 @@ 0x80881634:("func_80881634",), 0x8088168C:("func_8088168C",), 0x808819D8:("func_808819D8",), - 0x80881BDC:("func_80881BDC",), - 0x80881C54:("func_80881C54",), - 0x80881DA4:("func_80881DA4",), - 0x80881DC8:("func_80881DC8",), - 0x80881F10:("func_80881F10",), - 0x80881F48:("func_80881F48",), - 0x808821C8:("func_808821C8",), - 0x808822CC:("func_808822CC",), - 0x8088247C:("func_8088247C",), - 0x80882564:("func_80882564",), - 0x808826B4:("func_808826B4",), - 0x80882820:("func_80882820",), - 0x808829D0:("func_808829D0",), - 0x808829F4:("func_808829F4",), - 0x80882A44:("func_80882A44",), - 0x80882B9C:("func_80882B9C",), - 0x80882D8C:("func_80882D8C",), - 0x80882DC0:("func_80882DC0",), - 0x80883104:("func_80883104",), - 0x80883308:("func_80883308",), + 0x80881BDC:("EnHorse_CsMoveInit",), + 0x80881C54:("EnHorse_CsMoveToPoint",), + 0x80881DA4:("EnHorse_CsSetAnimHighJump",), + 0x80881DC8:("EnHorse_CsPlayHighJumpAnim",), + 0x80881F10:("EnHorse_CsJumpInit",), + 0x80881F48:("EnHorse_CsJump",), + 0x808821C8:("EnHorse_CsRearingInit",), + 0x808822CC:("EnHorse_CsRearing",), + 0x8088247C:("EnHorse_WarpMoveInit",), + 0x80882564:("EnHorse_CsWarpMoveToPoint",), + 0x808826B4:("EnHorse_CsWarpRearingInit",), + 0x80882820:("EnHorse_CsWarpRearing",), + 0x808829D0:("EnHorse_InitCutscene",), + 0x808829F4:("EnHorse_GetCutsceneFunctionIndex",), + 0x80882A44:("EnHorse_CutsceneUpdate",), + 0x80882B9C:("EnHorse_UpdateHbaRaceInfo",), + 0x80882D8C:("EnHorse_InitHorsebackArchery",), + 0x80882DC0:("EnHorse_UpdateHbaAnim",), + 0x80883104:("EnHorse_UpdateHorsebackArchery",), + 0x80883308:("EnHorse_FleePlayer",), 0x80883B70:("func_80883B70",), 0x80883BEC:("func_80883BEC",), 0x80883CB0:("func_80883CB0",), @@ -5338,29 +5338,29 @@ 0x80884A40:("func_80884A40",), 0x80884D04:("func_80884D04",), 0x80884E0C:("func_80884E0C",), - 0x80885060:("func_80885060",), - 0x808850DC:("func_808850DC",), - 0x80885220:("func_80885220",), - 0x808853E0:("func_808853E0",), - 0x8088598C:("func_8088598C",), - 0x80885A80:("func_80885A80",), - 0x80885AF4:("func_80885AF4",), - 0x80885B4C:("func_80885B4C",), - 0x80885C90:("func_80885C90",), - 0x80885DA4:("func_80885DA4",), + 0x80885060:("EnHorse_Vec3fOffset",), + 0x808850DC:("EnHorse_CalcFloorHeight",), + 0x80885220:("EnHorse_ObstructMovement",), + 0x808853E0:("EnHorse_CheckFloors",), + 0x8088598C:("EnHorse_MountDismount",), + 0x80885A80:("EnHorse_StickDirection",), + 0x80885AF4:("EnHorse_UpdateStick",), + 0x80885B4C:("EnHorse_ResolveCollision",), + 0x80885C90:("EnHorse_BgCheckSlowMoving",), + 0x80885DA4:("EnHorse_UpdateBgCheckInfo",), 0x80886C00:("func_80886C00",), - 0x80886DC4:("func_80886DC4",), - 0x80886FA8:("func_80886FA8",), - 0x808870A4:("func_808870A4",), - 0x808871A0:("func_808871A0",), - 0x80887270:("func_80887270",), + 0x80886DC4:("EnHorse_RegenBoost",), + 0x80886FA8:("EnHorse_UpdatePlayerDir",), + 0x808870A4:("EnHorse_TiltBody",), + 0x808871A0:("EnHorse_UpdateConveyors",), + 0x80887270:("EnHorse_RandInt",), 0x808872A4:("EnHorse_Update",), - 0x80887D20:("func_80887D20",), - 0x80887D60:("func_80887D60",), - 0x80887E64:("func_80887E64",), - 0x80887EBC:("func_80887EBC",), - 0x80887F58:("func_80887F58",), - 0x80888C48:("func_80888C48",), + 0x80887D20:("EnHorse_PlayerDirToMountSide",), + 0x80887D60:("EnHorse_MountSideCheck",), + 0x80887E64:("EnHorse_GetMountSide",), + 0x80887EBC:("EnHorse_RandomOffset",), + 0x80887F58:("EnHorse_PostDraw",), + 0x80888C48:("EnHorse_OverrideLimbDraw",), 0x80888D18:("func_80888D18",), 0x80888D78:("EnHorse_Draw",), 0x8088A240:("EnArrow_Init",), @@ -5802,10 +5802,10 @@ 0x808AAB30:("EnOssan_UpdateStickDirectionPromptAnim",), 0x808AACE0:("EnOssan_WaitForBlink",), 0x808AAD14:("EnOssan_Blink",), - 0x808AADB4:("EnOssan_InitCuriosityShopMan",), - 0x808AAE1C:("EnOssan_InitPartTimeWorker",), - 0x808AAE84:("EnOssan_GetWelcomeCuriosityShopMan",), - 0x808AAFB0:("EnOssan_GetWelcomePartTimeWorker",), + 0x808AADB4:("EnOssan_CuriosityShopMan_Init",), + 0x808AAE1C:("EnOssan_PartTimeWorker_Init",), + 0x808AAE84:("EnOssan_CuriosityShopMan_GetWelcome",), + 0x808AAFB0:("EnOssan_PartTimerWorker_GetWelcome",), 0x808AB0B0:("EnOssan_SetHaveMet",), 0x808AB16C:("EnOssan_InitShop",), 0x808AB404:("EnOssan_GetCutscenes",), @@ -5813,12 +5813,12 @@ 0x808AB52C:("EnOssan_DrawCursor",), 0x808AB78C:("EnOssan_DrawTextRec",), 0x808AB928:("EnOssan_DrawStickDirectionPrompts",), - 0x808ABCD0:("EnOssan_OverrideLimbDrawCuriosityShopMan",), - 0x808ABD10:("EnOssan_OverrideLimbDrawPartTimeWorker",), - 0x808ABD60:("EnOssan_PostLimbDrawCuriosityShopMan",), - 0x808ABE18:("EnOssan_PostLimbDrawPartTimeWorker",), - 0x808ABE58:("EnOssan_DrawCuriosityShopMan",), - 0x808ABF30:("EnOssan_DrawPartTimeWorker",), + 0x808ABCD0:("EnOssan_CuriosityShopMan_OverrideLimbDraw",), + 0x808ABD10:("EnOssan_PartTimeWorker_OverrideLimbDraw",), + 0x808ABD60:("EnOssan_CuriosityShopMan_PostLimbDraw",), + 0x808ABE18:("EnOssan_PartTimeWorker_PostLimbDraw",), + 0x808ABE58:("EnOssan_CuriosityShopMan_Draw",), + 0x808ABF30:("EnOssan_PartTimeWorker_Draw",), 0x808AC920:("EnFamos_Init",), 0x808ACB08:("EnFamos_Destroy",), 0x808ACB58:("func_808ACB58",), @@ -5971,7 +5971,7 @@ 0x808B74D8:("func_808B74D8",), 0x808B751C:("func_808B751C",), 0x808B75B0:("BgBreakwall_Init",), - 0x808B767C:("func_808B767C",), + 0x808B767C:("BgBreakwall_Destroy",), 0x808B76CC:("func_808B76CC",), 0x808B77D0:("func_808B77D0",), 0x808B77E0:("func_808B77E0",), @@ -5984,7 +5984,7 @@ 0x808B7A90:("func_808B7A90",), 0x808B7B54:("func_808B7B54",), 0x808B7D34:("func_808B7D34",), - 0x808B7FE4:("func_808B7FE4",), + 0x808B7FE4:("BgBreakwall_Draw",), 0x808B8490:("DoorWarp1_SetupAction",), 0x808B849C:("func_808B849C",), 0x808B8568:("func_808B8568",), @@ -6071,33 +6071,33 @@ 0x808BEE38:("EnDekunuts_Draw",), 0x808BF220:("EnBbfall_Init",), 0x808BF318:("EnBbfall_Destroy",), - 0x808BF344:("func_808BF344",), - 0x808BF3B8:("func_808BF3B8",), - 0x808BF438:("func_808BF438",), - 0x808BF4B4:("func_808BF4B4",), - 0x808BF514:("func_808BF514",), - 0x808BF578:("func_808BF578",), - 0x808BF5AC:("func_808BF5AC",), - 0x808BF5E0:("func_808BF5E0",), - 0x808BF734:("func_808BF734",), - 0x808BF7A0:("func_808BF7A0",), - 0x808BF830:("func_808BF830",), - 0x808BF894:("func_808BF894",), - 0x808BF8DC:("func_808BF8DC",), - 0x808BFA18:("func_808BFA18",), - 0x808BFA3C:("func_808BFA3C",), - 0x808BFAB4:("func_808BFAB4",), - 0x808BFB4C:("func_808BFB4C",), - 0x808BFCCC:("func_808BFCCC",), - 0x808BFE58:("func_808BFE58",), - 0x808BFF8C:("func_808BFF8C",), - 0x808C00A0:("func_808C00A0",), - 0x808C013C:("func_808C013C",), - 0x808C0178:("func_808C0178",), - 0x808C01E0:("func_808C01E0",), + 0x808BF344:("EnBbfall_Freeze",), + 0x808BF3B8:("EnBbfall_Thaw",), + 0x808BF438:("EnBbfall_IsTouchingLava",), + 0x808BF4B4:("EnBbfall_PlaySfx",), + 0x808BF514:("EnBbfall_CheckForWall",), + 0x808BF578:("EnBbfall_EnableColliders",), + 0x808BF5AC:("EnBbfall_DisableColliders",), + 0x808BF5E0:("EnBbfall_SetupWaitForPlayer",), + 0x808BF734:("EnBbfall_WaitForPlayer",), + 0x808BF7A0:("EnBbfall_SetupEmerge",), + 0x808BF830:("EnBbfall_Emerge",), + 0x808BF894:("EnBbfall_SetupFly",), + 0x808BF8DC:("EnBbfall_Fly",), + 0x808BFA18:("EnBbfall_SetupSinkIntoLava",), + 0x808BFA3C:("EnBbfall_SinkIntoLava",), + 0x808BFAB4:("EnBbfall_SetupDown",), + 0x808BFB4C:("EnBbfall_Down",), + 0x808BFCCC:("EnBbfall_SetupDead",), + 0x808BFE58:("EnBbfall_Dead",), + 0x808BFF8C:("EnBbfall_SetupDamage",), + 0x808C00A0:("EnBbfall_Damage",), + 0x808C013C:("EnBbfall_SetupFrozen",), + 0x808C0178:("EnBbfall_Frozen",), + 0x808C01E0:("EnBbfall_UpdateDamage",), 0x808C03EC:("EnBbfall_Update",), - 0x808C07D4:("func_808C07D4",), - 0x808C080C:("func_808C080C",), + 0x808C07D4:("EnBbfall_OverrideLimbDraw",), + 0x808C080C:("EnBbfall_PostLimbDraw",), 0x808C0A04:("EnBbfall_Draw",), 0x808C1030:("ArmsHook_SetupAction",), 0x808C103C:("ArmsHook_Init",), @@ -6113,37 +6113,37 @@ 0x808C1918:("ArmsHook_Draw",), 0x808C1D40:("EnBb_Init",), 0x808C1E68:("EnBb_Destroy",), - 0x808C1E94:("func_808C1E94",), - 0x808C1F00:("func_808C1F00",), - 0x808C1F74:("func_808C1F74",), - 0x808C1FF4:("func_808C1FF4",), - 0x808C20D4:("func_808C20D4",), - 0x808C2238:("func_808C2238",), - 0x808C2344:("func_808C2344",), - 0x808C23EC:("func_808C23EC",), - 0x808C254C:("func_808C254C",), - 0x808C25E0:("func_808C25E0",), - 0x808C272C:("func_808C272C",), - 0x808C28CC:("func_808C28CC",), - 0x808C2A00:("func_808C2A00",), - 0x808C2B1C:("func_808C2B1C",), - 0x808C2B94:("func_808C2B94",), - 0x808C2BD0:("func_808C2BD0",), - 0x808C2C38:("func_808C2C38",), - 0x808C2CB4:("func_808C2CB4",), - 0x808C2CF0:("func_808C2CF0",), - 0x808C2D78:("func_808C2D78",), - 0x808C2E34:("func_808C2E34",), + 0x808C1E94:("EnBb_CheckForWall",), + 0x808C1F00:("EnBb_Freeze",), + 0x808C1F74:("EnBb_Thaw",), + 0x808C1FF4:("EnBb_UpdateStateForFlying",), + 0x808C20D4:("EnBb_SetupFlyIdle",), + 0x808C2238:("EnBb_FlyIdle",), + 0x808C2344:("EnBb_SetupAttack",), + 0x808C23EC:("EnBb_Attack",), + 0x808C254C:("EnBb_SetupDown",), + 0x808C25E0:("EnBb_Down",), + 0x808C272C:("EnBb_SetupDead",), + 0x808C28CC:("EnBb_Dead",), + 0x808C2A00:("EnBb_SetupDamage",), + 0x808C2B1C:("EnBb_Damage",), + 0x808C2B94:("EnBb_SetupFrozen",), + 0x808C2BD0:("EnBb_Frozen",), + 0x808C2C38:("EnBb_SetupWaitForRevive",), + 0x808C2CB4:("EnBb_WaitForRevive",), + 0x808C2CF0:("EnBb_SetupRevive",), + 0x808C2D78:("EnBb_Revive",), + 0x808C2E34:("EnBb_UpdateDamage",), 0x808C30A0:("EnBb_Update",), - 0x808C32EC:("func_808C32EC",), - 0x808C3324:("func_808C3324",), + 0x808C32EC:("EnBb_OverrideLimbDraw",), + 0x808C3324:("EnBb_PostLimbDraw",), 0x808C351C:("EnBb_Draw",), 0x808C3A50:("BgKeikokuSpr_Init",), 0x808C3A78:("BgKeikokuSpr_Destroy",), 0x808C3A88:("BgKeikokuSpr_Update",), 0x808C3A98:("BgKeikokuSpr_Draw",), - 0x808C3C00:("func_808C3C00",), - 0x808C3D28:("func_808C3D28",), + 0x808C3C00:("EnWood02_SpawnZoneCheck",), + 0x808C3D28:("EnWood02_SpawnOffspring",), 0x808C3F30:("EnWood02_Init",), 0x808C4414:("EnWood02_Destroy",), 0x808C4458:("func_808C4458",), @@ -6258,8 +6258,8 @@ 0x808CCCF0:("func_808CCCF0",), 0x808CCDE4:("func_808CCDE4",), 0x808CCEE4:("EnVm_Update",), - 0x808CD020:("func_808CD020",), - 0x808CD08C:("func_808CD08C",), + 0x808CD020:("EnVm_OverrideLimbDraw",), + 0x808CD08C:("EnVm_PostLimbDraw",), 0x808CD238:("EnVm_Draw",), 0x808CD740:("DemoEffect_Init",), 0x808CD8E8:("DemoEffect_Destroy",), @@ -6749,17 +6749,17 @@ 0x808F69B4:("EnIn_Draw",), 0x808F74B0:("EnBomChu_Init",), 0x808F7580:("EnBomChu_Destroy",), - 0x808F75D0:("func_808F75D0",), - 0x808F77E4:("func_808F77E4",), - 0x808F7868:("func_808F7868",), - 0x808F7944:("func_808F7944",), - 0x808F79D4:("func_808F79D4",), - 0x808F7A84:("func_808F7A84",), - 0x808F7E74:("func_808F7E74",), - 0x808F7FA0:("func_808F7FA0",), - 0x808F7FD0:("func_808F7FD0",), - 0x808F8080:("func_808F8080",), - 0x808F818C:("func_808F818C",), + 0x808F75D0:("EnBomChu_UpdateFloorPoly",), + 0x808F77E4:("EnBomChu_UpdateRotation",), + 0x808F7868:("EnBomChu_WaitForRelease",), + 0x808F7944:("EnBomChu_IsOnCollisionPoly",), + 0x808F79D4:("EnBomChu_SetupMove",), + 0x808F7A84:("EnBomChu_Move",), + 0x808F7E74:("EnBomChu_Explode",), + 0x808F7FA0:("EnBomChu_WaitForDeath",), + 0x808F7FD0:("EnBomChu_ActorCoordsToWorld",), + 0x808F8080:("EnBomChu_SpawnRipplesAndSplashes",), + 0x808F818C:("EnBomChu_HandleNonSceneCollision",), 0x808F83B8:("EnBomChu_Update",), 0x808F8714:("EnBomChu_Draw",), 0x808F8AA0:("func_808F8AA0",), @@ -7000,12 +7000,12 @@ 0x80920340:("ArrowFire_SetupAction",), 0x8092034C:("ArrowFire_Init",), 0x809203F8:("ArrowFire_Destroy",), - 0x80920440:("func_80920440",), + 0x80920440:("FireArrow_ChargeAndWait",), 0x80920534:("FireArrow_Lerp",), - 0x8092058C:("func_8092058C",), - 0x809207A0:("func_809207A0",), + 0x8092058C:("FireArrow_Hit",), + 0x809207A0:("FireArrow_Fly",), 0x809208F4:("ArrowFire_Update",), - 0x80920948:("func_80920948",), + 0x80920948:("FireArrow_SetQuadVerticies",), 0x80920A24:("ArrowFire_Draw",), 0x80922430:("ArrowIce_SetupAction",), 0x8092243C:("ArrowIce_Init",), @@ -7019,10 +7019,10 @@ 0x80924300:("ArrowLight_SetupAction",), 0x8092430C:("ArrowLight_Init",), 0x80924388:("ArrowLight_Destroy",), - 0x809243AC:("func_809243AC",), - 0x809244A0:("func_809244A0",), - 0x809244F8:("func_809244F8",), - 0x809246C4:("func_809246C4",), + 0x809243AC:("ArrowLight_Charge",), + 0x809244A0:("ArrowLight_Lerp",), + 0x809244F8:("ArrowLight_Hit",), + 0x809246C4:("ArrowLight_Fly",), 0x80924818:("ArrowLight_Update",), 0x8092486C:("ArrowLight_Draw",), 0x809261B0:("ObjKibako_SpawnCollectible",), @@ -7251,37 +7251,37 @@ 0x809340BC:("func_809340BC",), 0x80934178:("func_80934178",), 0x80934464:("func_80934464",), - 0x809349E0:("func_809349E0",), - 0x80934AB4:("func_80934AB4",), - 0x80934F58:("func_80934F58",), - 0x80934FFC:("func_80934FFC",), - 0x809350C4:("func_809350C4",), - 0x809350F8:("func_809350F8",), - 0x8093517C:("func_8093517C",), - 0x809351A0:("func_809351A0",), - 0x809354F8:("func_809354F8",), - 0x809355A4:("func_809355A4",), - 0x8093561C:("func_8093561C",), + 0x809349E0:("EnKusa_ApplySway",), + 0x80934AB4:("EnKusa_Sway",), + 0x80934F58:("EnKusa_SnapToFloor",), + 0x80934FFC:("EnKusa_DropCollectible",), + 0x809350C4:("EnKusa_UpdateVelY",), + 0x809350F8:("EnKusa_RandScaleVecToZero",), + 0x8093517C:("EnKusa_SetScaleSmall",), + 0x809351A0:("EnKusa_SpawnFragments",), + 0x809354F8:("EnKusa_SpawnBugs",), + 0x809355A4:("EnKusa_GetWaterBox",), + 0x8093561C:("EnKusa_InitCollider",), 0x80935674:("EnKusa_Init",), 0x80935898:("EnKusa_Destroy",), - 0x809358C4:("func_809358C4",), - 0x809358D8:("func_809358D8",), - 0x80935988:("func_80935988",), - 0x809359AC:("func_809359AC",), - 0x80935B94:("func_80935B94",), - 0x80935BBC:("func_80935BBC",), - 0x80935CE8:("func_80935CE8",), - 0x80935D64:("func_80935D64",), - 0x80936120:("func_80936120",), - 0x80936168:("func_80936168",), - 0x809361A4:("func_809361A4",), - 0x809361B4:("func_809361B4",), - 0x80936220:("func_80936220",), - 0x80936290:("func_80936290",), - 0x809362D8:("func_809362D8",), + 0x809358C4:("EnKusa_SetupWaitObject",), + 0x809358D8:("EnKusa_WaitObject",), + 0x80935988:("EnKusa_SetupInteract",), + 0x809359AC:("EnKusa_WaitForInteract",), + 0x80935B94:("EnKusa_SetupLiftedUp",), + 0x80935BBC:("EnKusa_LiftedUp",), + 0x80935CE8:("EnKusa_SetupFall",), + 0x80935D64:("EnKusa_Fall",), + 0x80936120:("EnKusa_SetupCut",), + 0x80936168:("EnKusa_CutWaitRegrow",), + 0x809361A4:("EnKusa_DoNothing",), + 0x809361B4:("EnKusa_SetupUprootedWaitRegrow",), + 0x80936220:("EnKusa_UprootedWaitRegrow",), + 0x80936290:("EnKusa_SetupRegrow",), + 0x809362D8:("EnKusa_Regrow",), 0x80936370:("EnKusa_Update",), - 0x80936414:("func_80936414",), - 0x809365CC:("func_809365CC",), + 0x80936414:("EnKusa_DrawBush",), + 0x809365CC:("EnKusa_DrawGrass",), 0x80936CF0:("func_80936CF0",), 0x80936D58:("func_80936D58",), 0x80936F04:("func_80936F04",), @@ -7361,62 +7361,62 @@ 0x8093A3F4:("ObjBombiwa_Update",), 0x8093A418:("func_8093A418",), 0x8093A608:("func_8093A608",), - 0x8093ABD0:("func_8093ABD0",), - 0x8093AC6C:("func_8093AC6C",), - 0x8093ADA8:("func_8093ADA8",), - 0x8093AE1C:("func_8093AE1C",), - 0x8093AE74:("func_8093AE74",), - 0x8093AE88:("func_8093AE88",), - 0x8093AEC4:("func_8093AEC4",), - 0x8093AEF0:("func_8093AEF0",), - 0x8093AF1C:("func_8093AF1C",), - 0x8093AF54:("func_8093AF54",), + 0x8093ABD0:("ObjSwitch_InitJntSphCollider",), + 0x8093AC6C:("ObjSwitch_InitTrisCollider",), + 0x8093ADA8:("ObjSwitch_SpawnIce",), + 0x8093AE1C:("ObjSwitch_SetSwitchFlagState",), + 0x8093AE74:("ObjSwitch_CrystalUpdateTimer",), + 0x8093AE88:("ObjSwitch_StopCutscene",), + 0x8093AEC4:("ObjSwitch_PlayFootSwitchSfx",), + 0x8093AEF0:("ObjSwitch_PlayDiamondSwitchSfx",), + 0x8093AF1C:("ObjSwitch_SetFloorSwitchSnapPlayerState",), + 0x8093AF54:("ObjSwitch_FloorSwitchSnapPlayerToSwitchEdge",), 0x8093B084:("ObjSwitch_Init",), 0x8093B59C:("ObjSwitch_Destroy",), - 0x8093B648:("func_8093B648",), - 0x8093B668:("func_8093B668",), - 0x8093B6F4:("func_8093B6F4",), - 0x8093B710:("func_8093B710",), - 0x8093B92C:("func_8093B92C",), - 0x8093B940:("func_8093B940",), - 0x8093B9C0:("func_8093B9C0",), - 0x8093B9E4:("func_8093B9E4",), - 0x8093BB5C:("func_8093BB5C",), - 0x8093BB70:("func_8093BB70",), - 0x8093BBD0:("func_8093BBD0",), - 0x8093BCC8:("func_8093BCC8",), - 0x8093BCDC:("func_8093BCDC",), - 0x8093BD34:("func_8093BD34",), - 0x8093BD4C:("func_8093BD4C",), - 0x8093BDAC:("func_8093BDAC",), - 0x8093BDC0:("func_8093BDC0",), - 0x8093BE10:("func_8093BE10",), - 0x8093BE2C:("func_8093BE2C",), - 0x8093BEF0:("func_8093BEF0",), - 0x8093BF04:("func_8093BF04",), - 0x8093BF50:("func_8093BF50",), - 0x8093BF70:("func_8093BF70",), - 0x8093C0A4:("func_8093C0A4",), - 0x8093C0B8:("func_8093C0B8",), - 0x8093C138:("func_8093C138",), - 0x8093C15C:("func_8093C15C",), - 0x8093C23C:("func_8093C23C",), - 0x8093C250:("func_8093C250",), - 0x8093C2B4:("func_8093C2B4",), - 0x8093C2D4:("func_8093C2D4",), - 0x8093C3C8:("func_8093C3C8",), - 0x8093C3DC:("func_8093C3DC",), - 0x8093C460:("func_8093C460",), - 0x8093C488:("func_8093C488",), - 0x8093C584:("func_8093C584",), - 0x8093C598:("func_8093C598",), + 0x8093B648:("ObjSwitch_TryPlayCutsceneInit",), + 0x8093B668:("ObjSwitch_TryPlayCutscene",), + 0x8093B6F4:("ObjSwitch_FloorSwitchUpInit",), + 0x8093B710:("ObjSwitch_FloorSwitchUp",), + 0x8093B92C:("ObjSwitch_FloorSwitchPushDownInit",), + 0x8093B940:("ObjSwitch_FloorSwitchPushDown",), + 0x8093B9C0:("ObjSwitch_FloorSwitchDownInit",), + 0x8093B9E4:("ObjSwitch_FloorSwitchDown",), + 0x8093BB5C:("ObjSwitch_FloorSwitchRiseUpInit",), + 0x8093BB70:("ObjSwitch_FloorSwitchRiseUp",), + 0x8093BBD0:("ObjSwitch_IsEyeSwitchHit",), + 0x8093BCC8:("ObjSwitch_EyeSwitchFrozenInit",), + 0x8093BCDC:("ObjSwitch_EyeSwitchUnfrozen",), + 0x8093BD34:("ObjSwitch_EyeSwitchOpenInit",), + 0x8093BD4C:("ObjSwitch_EyeSwitchOpen",), + 0x8093BDAC:("ObjSwitch_EyeSwitchClosingInit",), + 0x8093BDC0:("ObjSwitch_EyeSwitchClosing",), + 0x8093BE10:("ObjSwitch_EyeSwitchClosedInit",), + 0x8093BE2C:("ObjSwitch_EyeSwitchClosed",), + 0x8093BEF0:("ObjSwitch_EyeSwitchOpeningInit",), + 0x8093BF04:("ObjSwitch_EyeSwitchOpening",), + 0x8093BF50:("ObjSwitch_CrystalSwitchOffInit",), + 0x8093BF70:("ObjSwitch_CrystalSwitchOff",), + 0x8093C0A4:("ObjSwitch_CrystalSwitchTurnOnInit",), + 0x8093C0B8:("ObjSwitch_CrystalSwitchTurnOn",), + 0x8093C138:("ObjSwitch_CrystalSwitchOnInit",), + 0x8093C15C:("ObjSwitch_CrystalSwitchOn",), + 0x8093C23C:("ObjSwitch_CrystalSwitchTurnOffInit",), + 0x8093C250:("ObjSwitch_CrystalSwitchTurnOff",), + 0x8093C2B4:("ObjSwitch_LargeFloorSwitchUpInit",), + 0x8093C2D4:("ObjSwitch_LargeFloorSwitchUp",), + 0x8093C3C8:("ObjSwitch_LargeFloorSwitchPushDownInit",), + 0x8093C3DC:("ObjSwitch_LargeFloorSwitchPushDown",), + 0x8093C460:("ObjSwitch_LargeFloorSwitchDownInit",), + 0x8093C488:("ObjSwitch_LargeFloorSwitchDown",), + 0x8093C584:("ObjSwitch_LargeFloorSwitchRiseUpInit",), + 0x8093C598:("ObjSwitch_LargeFloorSwitchRiseUp",), 0x8093C5FC:("ObjSwitch_Update",), - 0x8093C778:("func_8093C778",), - 0x8093C888:("func_8093C888",), - 0x8093C8B8:("func_8093C8B8",), - 0x8093C99C:("func_8093C99C",), - 0x8093CA80:("func_8093CA80",), - 0x8093CAC4:("func_8093CAC4",), + 0x8093C778:("ObjSwitch_DrawFloorSwitch",), + 0x8093C888:("ObjSwitch_DrawRustyFloorSwitch",), + 0x8093C8B8:("ObjSwitch_DrawVisibleEyeSwitch",), + 0x8093C99C:("ObjSwitch_DrawInvisibleEyeSwitch",), + 0x8093CA80:("ObjSwitch_DrawEyeSwitch",), + 0x8093CAC4:("ObjSwitch_DrawCrystalSwitch",), 0x8093CC24:("ObjSwitch_Draw",), 0x8093D3C0:("func_8093D3C0",), 0x8093D628:("ObjLift_Init",), @@ -7553,8 +7553,8 @@ 0x80946368:("func_80946368",), 0x80946400:("EnGe1_Draw",), 0x809466A0:("ObjBlockstop_Init",), - 0x809466F0:("func_809466F0",), - 0x809467E8:("func_809467E8",), + 0x809466F0:("ObjBlockstop_CheckForBlock",), + 0x809467E8:("ObjBlockstop_TryPlayCutscene",), 0x8094685C:("ObjBlockstop_Update",), 0x809468D0:("EnSda_Init",), 0x809468E0:("EnSda_Destroy",), @@ -7652,8 +7652,8 @@ 0x809533A0:("func_809533A0",), 0x8095345C:("func_8095345C",), 0x8095359C:("EnHs_Update",), - 0x8095376C:("func_8095376C",), - 0x80953848:("func_80953848",), + 0x8095376C:("EnHs_OverrideLimbDraw",), + 0x80953848:("EnHs_PostLimbDraw",), 0x80953888:("EnHs_Draw",), 0x80953A90:("BgIngate_FindActor",), 0x80953B40:("func_80953B40",), @@ -7686,7 +7686,7 @@ 0x80958974:("func_80958974",), 0x80958BE4:("func_80958BE4",), 0x80958CA8:("EnAttackNiw_Update",), - 0x80958F6C:("func_80958F6C",), + 0x80958F6C:("EnAttackNiw_OverrideLimbDraw",), 0x8095909C:("EnAttackNiw_Draw",), 0x809592E0:("func_809592E0",), 0x80959390:("EnMk_Init",), @@ -7702,8 +7702,8 @@ 0x80959D28:("func_80959D28",), 0x80959E18:("func_80959E18",), 0x8095A028:("EnMk_Update",), - 0x8095A150:("func_8095A150",), - 0x8095A198:("func_8095A198",), + 0x8095A150:("EnMk_OverrideLimbDraw",), + 0x8095A198:("EnMk_PostLimbDraw",), 0x8095A1D8:("EnMk_Draw",), 0x8095A510:("func_8095A510",), 0x8095A560:("EnOwl_Init",), @@ -8201,7 +8201,7 @@ 0x8097DCA0:("EffectSsKakera_Init",), 0x8097DE30:("func_8097DE30",), 0x8097DE6C:("EffectSsKakera_Draw",), - 0x8097E130:("func_8097E130",), + 0x8097E130:("EffectSsKakera_CheckForObject",), 0x8097E19C:("func_8097E19C",), 0x8097E34C:("func_8097E34C",), 0x8097E368:("func_8097E368",), @@ -8429,7 +8429,7 @@ 0x80990784:("EnWf_Destroy",), 0x809907D4:("func_809907D4",), 0x80990854:("func_80990854",), - 0x809908E0:("func_809908E0",), + 0x809908E0:("EnWf_Blink",), 0x80990948:("func_80990948",), 0x80990C6C:("func_80990C6C",), 0x80990E4C:("func_80990E4C",), @@ -8573,23 +8573,23 @@ 0x8099AA84:("func_8099AA84",), 0x8099AB30:("EnCrow_Init",), 0x8099AC2C:("EnCrow_Destroy",), - 0x8099AC58:("func_8099AC58",), - 0x8099AC8C:("func_8099AC8C",), - 0x8099B098:("func_8099B098",), - 0x8099B0CC:("func_8099B0CC",), - 0x8099B318:("func_8099B318",), - 0x8099B384:("func_8099B384",), - 0x8099B584:("func_8099B584",), - 0x8099B6AC:("func_8099B6AC",), - 0x8099B6C4:("func_8099B6C4",), - 0x8099B778:("func_8099B778",), - 0x8099B838:("func_8099B838",), - 0x8099B8EC:("func_8099B8EC",), - 0x8099B9E8:("func_8099B9E8",), - 0x8099BAB4:("func_8099BAB4",), + 0x8099AC58:("EnCrow_SetupFlyIdle",), + 0x8099AC8C:("EnCrow_FlyIdle",), + 0x8099B098:("EnCrow_SetupDiveAttack",), + 0x8099B0CC:("EnCrow_DiveAttack",), + 0x8099B318:("EnCrow_CheckIfFrozen",), + 0x8099B384:("EnCrow_SetupDamaged",), + 0x8099B584:("EnCrow_Damaged",), + 0x8099B6AC:("EnCrow_SetupDie",), + 0x8099B6C4:("EnCrow_Die",), + 0x8099B778:("EnCrow_SetupTurnAway",), + 0x8099B838:("EnCrow_TurnAway",), + 0x8099B8EC:("EnCrow_SetupRespawn",), + 0x8099B9E8:("EnCrow_Respawn",), + 0x8099BAB4:("EnCrow_UpdateDamage",), 0x8099BB84:("EnCrow_Update",), - 0x8099BE48:("func_8099BE48",), - 0x8099BF20:("func_8099BF20",), + 0x8099BE48:("EnCrow_OverrideLimbDraw",), + 0x8099BF20:("EnCrow_PostLimbDraw",), 0x8099BFA4:("EnCrow_Draw",), 0x8099C290:("func_8099C290",), 0x8099C328:("func_8099C328",), @@ -8989,14 +8989,14 @@ 0x809BD858:("func_809BD858",), 0x809C0760:("EnWarptag_Init",), 0x809C0824:("EnWarptag_Destroy",), - 0x809C085C:("func_809C085C",), - 0x809C08E0:("func_809C08E0",), - 0x809C09A0:("func_809C09A0",), - 0x809C0A20:("func_809C0A20",), - 0x809C0AB4:("func_809C0AB4",), - 0x809C0E30:("func_809C0E30",), + 0x809C085C:("EnWarpTag_CheckDungeonKeepObject",), + 0x809C08E0:("EnWarpTag_WaitForPlayer",), + 0x809C09A0:("EnWarpTag_Unused809C09A0",), + 0x809C0A20:("EnWarpTag_Unused809C0A20",), + 0x809C0AB4:("EnWarpTag_RespawnPlayer",), + 0x809C0E30:("EnWarpTag_GrottoReturn",), 0x809C0F18:("EnWarptag_Update",), - 0x809C0F3C:("func_809C0F3C",), + 0x809C0F3C:("EnWarpTag_Draw",), 0x809C10B0:("func_809C10B0",), 0x809C1124:("func_809C1124",), 0x809C1158:("func_809C1158",), @@ -9107,7 +9107,7 @@ 0x809C8808:("func_809C8808",), 0x809C898C:("func_809C898C",), 0x809C8BF0:("func_809C8BF0",), - 0x809C8DE8:("func_809C8DE8",), + 0x809C8DE8:("EnSyatekiMan_Blink",), 0x809C8E44:("EnSyatekiMan_Update",), 0x809C8EE4:("EnSyatekiMan_OverrideLimbDraw",), 0x809C8FAC:("EnSyatekiMan_PostLimbDraw",), @@ -9198,22 +9198,22 @@ 0x809CEEAC:("func_809CEEAC",), 0x809CEF0C:("BgSpdweb_Update",), 0x809CEF30:("BgSpdweb_Draw",), - 0x809CF350:("func_809CF350",), - 0x809CF394:("func_809CF394",), - 0x809CF444:("func_809CF444",), - 0x809CF4EC:("func_809CF4EC",), - 0x809CF67C:("func_809CF67C",), - 0x809CF848:("func_809CF848",), - 0x809CF8EC:("func_809CF8EC",), - 0x809CF950:("func_809CF950",), - 0x809CF9A0:("func_809CF9A0",), - 0x809CFA00:("func_809CFA00",), - 0x809CFA54:("func_809CFA54",), - 0x809CFBC4:("func_809CFBC4",), - 0x809CFC38:("func_809CFC38",), - 0x809CFD98:("func_809CFD98",), - 0x809CFE28:("func_809CFE28",), - 0x809CFF94:("func_809CFF94",), + 0x809CF350:("EnMttag_IsInFinishLine",), + 0x809CF394:("EnMttag_CheckPlayerCheatStatus",), + 0x809CF444:("EnMttag_AreFourRaceGoronsPresent",), + 0x809CF4EC:("EnMttag_GetCurrentCheckpoint",), + 0x809CF67C:("EnMttag_UpdateCheckpoints",), + 0x809CF848:("EnMttag_ExitRace",), + 0x809CF8EC:("EnMttag_ShowFalseStartMessage",), + 0x809CF950:("EnMttag_ShowCantWinMessage",), + 0x809CF9A0:("EnMttag_ShowIntroCutscene",), + 0x809CFA00:("EnMttag_WaitForIntroCutsceneToEnd",), + 0x809CFA54:("EnMttag_RaceStart",), + 0x809CFBC4:("EnMttag_IsAnyRaceGoronOverFinishLine",), + 0x809CFC38:("EnMttag_Race",), + 0x809CFD98:("EnMttag_RaceFinish",), + 0x809CFE28:("EnMttag_PotentiallyRestartRace",), + 0x809CFF94:("EnMttag_HandleCantWinChoice",), 0x809D0090:("EnMttag_Init",), 0x809D0138:("EnMttag_Destroy",), 0x809D0168:("EnMttag_Update",), @@ -9315,52 +9315,52 @@ 0x809DD2F8:("func_809DD2F8",), 0x809DD934:("func_809DD934",), 0x809DEAC4:("func_809DEAC4",), - 0x809E2760:("func_809E2760",), - 0x809E2788:("func_809E2788",), - 0x809E2880:("func_809E2880",), - 0x809E299C:("func_809E299C",), - 0x809E2AB4:("func_809E2AB4",), - 0x809E2B8C:("func_809E2B8C",), - 0x809E2C1C:("func_809E2C1C",), - 0x809E2C3C:("func_809E2C3C",), - 0x809E2D64:("func_809E2D64",), - 0x809E2DA0:("func_809E2DA0",), + 0x809E2760:("Boss03_PlayUnderwaterSfx",), + 0x809E2788:("Boss03_SpawnEffectWetSpot",), + 0x809E2880:("Boss03_SpawnEffectDroplet",), + 0x809E299C:("Boss03_SpawnEffectSplash",), + 0x809E2AB4:("Boss03_SpawnEffectBubble",), + 0x809E2B8C:("Boss03_UpdateSphereElement",), + 0x809E2C1C:("Boss03_SeedRand",), + 0x809E2C3C:("Boss03_RandZeroOne",), + 0x809E2D64:("Boss03_FindActorDblueMovebg",), + 0x809E2DA0:("Boss03_SpawnDust",), 0x809E2F7C:("Boss03_Init",), 0x809E343C:("Boss03_Destroy",), 0x809E344C:("func_809E344C",), 0x809E34B8:("func_809E34B8",), - 0x809E38EC:("func_809E38EC",), - 0x809E3968:("func_809E3968",), - 0x809E3D34:("func_809E3D34",), - 0x809E3D98:("func_809E3D98",), - 0x809E4180:("func_809E4180",), - 0x809E421C:("func_809E421C",), - 0x809E4674:("func_809E4674",), - 0x809E475C:("func_809E475C",), - 0x809E4910:("func_809E4910",), - 0x809E497C:("func_809E497C",), - 0x809E4C34:("func_809E4C34",), - 0x809E4C90:("func_809E4C90",), - 0x809E4E2C:("func_809E4E2C",), - 0x809E4E80:("func_809E4E80",), - 0x809E5ADC:("func_809E5ADC",), - 0x809E5B64:("func_809E5B64",), - 0x809E65F4:("func_809E65F4",), - 0x809E6640:("func_809E6640",), - 0x809E69A4:("func_809E69A4",), - 0x809E6A38:("func_809E6A38",), - 0x809E6B70:("func_809E6B70",), - 0x809E6BC0:("func_809E6BC0",), - 0x809E6CB4:("func_809E6CB4",), + 0x809E38EC:("Boss03_SetupChasePlayer",), + 0x809E3968:("Boss03_ChasePlayer",), + 0x809E3D34:("Boss03_SetupCatchPlayer",), + 0x809E3D98:("Boss03_CatchPlayer",), + 0x809E4180:("Boss03_SetupChewPlayer",), + 0x809E421C:("Boss03_ChewPlayer",), + 0x809E4674:("Boss03_SetupPrepareCharge",), + 0x809E475C:("Boss03_PrepareCharge",), + 0x809E4910:("Boss03_SetupCharge",), + 0x809E497C:("Boss03_Charge",), + 0x809E4C34:("Boss03_SetupJumpOverPlatform",), + 0x809E4C90:("Boss03_JumpOverPlatform",), + 0x809E4E2C:("Boss03_SetupIntroCutscene",), + 0x809E4E80:("Boss03_IntroCutscene",), + 0x809E5ADC:("Boss03_SetupDeathCutscene",), + 0x809E5B64:("Boss03_DeathCutscene",), + 0x809E65F4:("Boss03_SetupSpawnSmallFishesCutscene",), + 0x809E6640:("Boss03_SpawnSmallFishesCutscene",), + 0x809E69A4:("Boss03_SetupStunned",), + 0x809E6A38:("Boss03_Stunned",), + 0x809E6B70:("Boss03_SetupDamaged",), + 0x809E6BC0:("Boss03_Damaged",), + 0x809E6CB4:("Boss03_UpdateCollision",), 0x809E70EC:("Boss03_Update",), - 0x809E7920:("func_809E7920",), - 0x809E79C4:("func_809E79C4",), - 0x809E7AA8:("func_809E7AA8",), + 0x809E7920:("Boss03_SetObject",), + 0x809E79C4:("Boss03_OverrideLimbDraw",), + 0x809E7AA8:("Boss03_PostLimbDraw",), 0x809E7C0C:("Boss03_Draw",), - 0x809E7D00:("func_809E7D00",), - 0x809E81E4:("func_809E81E4",), - 0x809E8810:("func_809E8810",), - 0x809E8BEC:("func_809E8BEC",), + 0x809E7D00:("Boss03_UpdateEffects",), + 0x809E81E4:("Boss03_DrawEffects",), + 0x809E8810:("Boss03_SeaweedUpdate",), + 0x809E8BEC:("Boss03_SeaweedDraw",), 0x809EC040:("func_809EC040",), 0x809EC0D0:("Boss04_Init",), 0x809EC534:("Boss04_Destroy",), @@ -9605,7 +9605,7 @@ 0x80A0C938:("EnSob1_GetTalkOption",), 0x80A0CA38:("EnSob1_GetWelcome",), 0x80A0CC88:("EnSob1_GetGoodbye",), - 0x80A0CCEC:("EnSob1_EndInteractionBombShop",), + 0x80A0CCEC:("EnSob1_BombShopkeeper_EndInteraction",), 0x80A0CD48:("EnSob1_SpawnShopItems",), 0x80A0CE10:("EnSob1_GetObjIndices",), 0x80A0CED4:("EnSob1_Init",), @@ -9654,27 +9654,27 @@ 0x80A0EEC8:("EnSob1_UpdateItemSelectedProperty",), 0x80A0EF48:("EnSob1_UpdateCursorAnim",), 0x80A0F014:("EnSob1_UpdateStickDirectionPromptAnim",), - 0x80A0F1C4:("EnSob1_GetXZAngleAndDistanceSqToPoint",), + 0x80A0F1C4:("EnSob1_GetDistSqAndOrient",), 0x80A0F284:("EnSob1_GetCutscenes",), 0x80A0F2C8:("EnSob1_WaitForBlink",), 0x80A0F2FC:("EnSob1_Blink",), 0x80A0F39C:("EnSob1_ChangeObject",), 0x80A0F3D4:("EnSob1_AreObjectsLoaded",), - 0x80A0F470:("EnSob1_InitZoraShopkeeper",), - 0x80A0F554:("EnSob1_InitGoronShopkeeper",), - 0x80A0F638:("EnSob1_InitBombShopkeeper",), + 0x80A0F470:("EnSob1_ZoraShopkeeper_Init",), + 0x80A0F554:("EnSob1_GoronShopkeeper_Init",), + 0x80A0F638:("EnSob1_BombShopkeeper_Init",), 0x80A0F6B0:("EnSob1_InitShop",), 0x80A0FA0C:("EnSob1_Update",), 0x80A0FADC:("EnSob1_DrawCursor",), 0x80A0FD4C:("EnSob1_DrawTextRec",), 0x80A0FEE8:("EnSob1_DrawStickDirectionPrompt",), - 0x80A10290:("EnSob1_OverrideLimbDrawZoraShopkeeper",), - 0x80A102C8:("EnSob1_OverrideLimbDrawBombShopkeeper",), - 0x80A10308:("EnSob1_PostLimbDrawBombShopkeeper",), + 0x80A10290:("EnSob1_ZoraShopkeeper_OverrideLimbDraw",), + 0x80A102C8:("EnSob1_BombShopkeeper_OverrideLimbDraw",), + 0x80A10308:("EnSob1_BombShopkeeper_PostLimbDraw",), 0x80A10344:("EnSob1_EndDList",), - 0x80A10368:("EnSob1_DrawZoraShopkeeper",), - 0x80A104E4:("EnSob1_DrawGoronShopkeeper",), - 0x80A10608:("EnSob1_DrawBombShopkeeper",), + 0x80A10368:("EnSob1_ZoraShopkeeper_Draw",), + 0x80A104E4:("EnSob1_GoronShopkeeper_Draw",), + 0x80A10608:("EnSob1_BombShopkeeper_Draw",), 0x80A10FD0:("func_80A10FD0",), 0x80A11144:("func_80A11144",), 0x80A1143C:("func_80A1143C",), @@ -9745,33 +9745,33 @@ 0x80A15D04:("EnGo_OverrideLimbDraw",), 0x80A15E38:("EnGo_TransfromLimbDraw",), 0x80A15FEC:("func_80A15FEC",), - 0x80A16D40:("func_80A16D40",), - 0x80A16D6C:("func_80A16D6C",), + 0x80A16D40:("EnRaf_ClearPixelTeeth",), + 0x80A16D6C:("EnRaf_ClearPixelPetal",), 0x80A16D90:("EnRaf_Init",), 0x80A17018:("EnRaf_Destroy",), - 0x80A17060:("func_80A17060",), - 0x80A1712C:("func_80A1712C",), - 0x80A171D8:("func_80A171D8",), - 0x80A17414:("func_80A17414",), - 0x80A17464:("func_80A17464",), - 0x80A17530:("func_80A17530",), - 0x80A175E4:("func_80A175E4",), - 0x80A17848:("func_80A17848",), - 0x80A178A0:("func_80A178A0",), - 0x80A179C8:("func_80A179C8",), - 0x80A17C6C:("func_80A17C6C",), - 0x80A17D14:("func_80A17D14",), - 0x80A17D54:("func_80A17D54",), - 0x80A17DDC:("func_80A17DDC",), - 0x80A17E1C:("func_80A17E1C",), - 0x80A18080:("func_80A18080",), - 0x80A180B4:("func_80A180B4",), + 0x80A17060:("EnRaf_ChangeAnimation",), + 0x80A1712C:("EnRaf_SetupIdle",), + 0x80A171D8:("EnRaf_Idle",), + 0x80A17414:("EnRaf_SetupGrab",), + 0x80A17464:("EnRaf_Grab",), + 0x80A17530:("EnRaf_SetupChew",), + 0x80A175E4:("EnRaf_Chew",), + 0x80A17848:("EnRaf_SetupThrow",), + 0x80A178A0:("EnRaf_Throw",), + 0x80A179C8:("EnRaf_Explode",), + 0x80A17C6C:("EnRaf_PostDetonation",), + 0x80A17D14:("EnRaf_SetupConvulse",), + 0x80A17D54:("EnRaf_Convulse",), + 0x80A17DDC:("EnRaf_SetupDissolve",), + 0x80A17E1C:("EnRaf_Dissolve",), + 0x80A18080:("EnRaf_SetupDormant",), + 0x80A180B4:("EnRaf_Dormant",), 0x80A181B4:("EnRaf_Update",), - 0x80A1859C:("func_80A1859C",), + 0x80A1859C:("EnRaf_TransformLimbDraw",), 0x80A18A08:("EnRaf_Draw",), - 0x80A18A90:("func_80A18A90",), - 0x80A18B8C:("func_80A18B8C",), - 0x80A18DA0:("func_80A18DA0",), + 0x80A18A90:("EnRaf_InitializeParticle",), + 0x80A18B8C:("EnRaf_UpdateParticles",), + 0x80A18DA0:("EnRaf_DrawParticles",), 0x80A19740:("ObjFunen_Init",), 0x80A19778:("ObjFunen_Draw",), 0x80A19910:("ObjRaillift_UpdatePosition",), @@ -9925,7 +9925,7 @@ 0x80A227C0:("func_80A227C0",), 0x80A22880:("ObjSkateblock_Update",), 0x80A228D8:("ObjSkateblock_Draw",), - 0x80A22D40:("func_80A22D40",), + 0x80A22D40:("EffectEnIceBlock_CheckIceBlockObject",), 0x80A22DB8:("EffectEnIceBlock_Init",), 0x80A22E94:("EffectEnIceBlock_Draw",), 0x80A22FE4:("EffectEnIceBlock_Update",), @@ -9963,8 +9963,8 @@ 0x80A25440:("func_80A25440",), 0x80A25598:("ObjIceblock_Init",), 0x80A25758:("ObjIceblock_Destroy",), - 0x80A257A0:("func_80A257A0",), - 0x80A257B4:("func_80A257B4",), + 0x80A257A0:("ObjIceBlock_SetupAttemptSpawnCutscene",), + 0x80A257B4:("ObjIceBlock_AttemptSpawnCutscene",), 0x80A25824:("func_80A25824",), 0x80A2586C:("func_80A2586C",), 0x80A25978:("func_80A25978",), @@ -10081,7 +10081,7 @@ 0x80A2C4D0:("func_80A2C4D0",), 0x80A2C5DC:("func_80A2C5DC",), 0x80A2C78C:("EnSyatekiDekunuts_Update",), - 0x80A2C8A0:("func_80A2C8A0",), + 0x80A2C8A0:("EnSyatekiDekunuts_OverrideLimbDraw",), 0x80A2C8E8:("EnSyatekiDekunuts_Draw",), 0x80A2CD10:("ElfMsg3_SetupAction",), 0x80A2CD1C:("func_80A2CD1C",), @@ -10238,7 +10238,7 @@ 0x80A36B9C:("EnSyatekiOkuta_Update",), 0x80A36CB0:("func_80A36CB0",), 0x80A370EC:("func_80A370EC",), - 0x80A37294:("func_80A37294",), + 0x80A37294:("EnSyatekiOkuta_OverrideLimbDraw",), 0x80A3735C:("EnSyatekiOkuta_Draw",), 0x80A37ED0:("ObjShutter_Init",), 0x80A37EE0:("ObjShutter_Destroy",), @@ -10845,14 +10845,14 @@ 0x80A675C4:("ObjDriftice_Draw",), 0x80A678B0:("EnLookNuts_Init",), 0x80A67A08:("EnLookNuts_Destroy",), - 0x80A67A34:("func_80A67A34",), + 0x80A67A34:("EnLookNuts_SetupPatrol",), 0x80A67AA8:("func_80A67AA8",), - 0x80A67C48:("func_80A67C48",), - 0x80A67D0C:("func_80A67D0C",), + 0x80A67C48:("EnLookNuts_SetupStandAndWait",), + 0x80A67D0C:("EnLookNuts_StandAndWait",), 0x80A67F30:("func_80A67F30",), 0x80A67FC4:("func_80A67FC4",), - 0x80A68080:("func_80A68080",), - 0x80A680FC:("func_80A680FC",), + 0x80A68080:("EnLookNuts_SetupSendPlayerToSpawn",), + 0x80A680FC:("EnLookNuts_SendPlayerToSpawn",), 0x80A681C4:("EnLookNuts_Update",), 0x80A68540:("EnLookNuts_Draw",), 0x80A687A0:("func_80A687A0",), @@ -11005,8 +11005,8 @@ 0x80A72BA4:("func_80A72BA4",), 0x80A72C04:("func_80A72C04",), 0x80A72CF8:("func_80A72CF8",), - 0x80A72D8C:("func_80A72D8C",), - 0x80A72FAC:("func_80A72FAC",), + 0x80A72D8C:("EnDno_ActorPathing_UpdateActorInfo",), + 0x80A72FAC:("EnDno_ActorPathing_Move",), 0x80A730A0:("func_80A730A0",), 0x80A73244:("func_80A73244",), 0x80A732C8:("func_80A732C8",), @@ -11804,16 +11804,16 @@ 0x80ABAE64:("func_80ABAE64",), 0x80ABB0E0:("EnGuardNuts_Init",), 0x80ABB1E4:("EnGuardNuts_Destroy",), - 0x80ABB210:("func_80ABB210",), - 0x80ABB29C:("func_80ABB29C",), - 0x80ABB2D4:("func_80ABB2D4",), + 0x80ABB210:("EnGuardNuts_ChangeAnim",), + 0x80ABB29C:("EnGuardNuts_SetupWait",), + 0x80ABB2D4:("EnGuardNuts_Wait",), 0x80ABB540:("func_80ABB540",), 0x80ABB590:("func_80ABB590",), - 0x80ABB854:("func_80ABB854",), - 0x80ABB91C:("func_80ABB91C",), - 0x80ABB990:("func_80ABB990",), + 0x80ABB854:("EnGuardNuts_Burrow",), + 0x80ABB91C:("EnGuardNuts_SetupUnburrow",), + 0x80ABB990:("EnGuardNuts_Unburrow",), 0x80ABBACC:("EnGuardNuts_Update",), - 0x80ABBC60:("func_80ABBC60",), + 0x80ABBC60:("EnGuardNuts_OverrideLimbDraw",), 0x80ABBCB8:("EnGuardNuts_Draw",), 0x80ABBFC0:("func_80ABBFC0",), 0x80ABC2E0:("func_80ABC2E0",), @@ -11997,8 +11997,8 @@ 0x80AC8A94:("TransitionWipe5_SetColor",), 0x80AC8AA0:("TransitionWipe5_SetEnvColor",), 0x80AC8B50:("EffectSsSbn_Init",), - 0x80AC8ECC:("func_80AC8ECC",), - 0x80AC9164:("func_80AC9164",), + 0x80AC8ECC:("EffectSsSbn_DrawSliding",), + 0x80AC9164:("EffectSsSbn_Draw",), 0x80AC933C:("EffectSsSbn_Update",), 0x80AC94C0:("func_80AC94C0",), 0x80AC94FC:("ObjOcarinalift_Init",), @@ -12384,8 +12384,8 @@ 0x80AE0D78:("func_80AE0D78",), 0x80AE0DDC:("EnTsn_Update",), 0x80AE0F84:("func_80AE0F84",), - 0x80AE0FA8:("func_80AE0FA8",), - 0x80AE1024:("func_80AE1024",), + 0x80AE0FA8:("EnTsn_OverrideLimbDraw",), + 0x80AE1024:("EnTsn_PostLimbDraw",), 0x80AE1080:("EnTsn_Draw",), 0x80AE1650:("func_80AE1650",), 0x80AE16A0:("func_80AE16A0",), @@ -12776,14 +12776,14 @@ 0x80AFAA44:("EnPm_PostLimbDraw",), 0x80AFABAC:("EnPm_TransformLimbDraw",), 0x80AFACAC:("EnPm_Draw",), - 0x80AFC960:("func_80AFC960",), + 0x80AFC960:("EnGakufu_ProcessNotes",), 0x80AFCA94:("EnGakufu_Init",), 0x80AFCB64:("EnGakufu_Destroy",), - 0x80AFCB94:("func_80AFCB94",), - 0x80AFCBD4:("func_80AFCBD4",), - 0x80AFCC14:("func_80AFCC14",), - 0x80AFCC24:("func_80AFCC24",), - 0x80AFCC58:("func_80AFCC58",), + 0x80AFCB94:("EnGakufu_DisplayOnTimer",), + 0x80AFCBD4:("EnGakufu_WaitForTimer",), + 0x80AFCC14:("EnGakufu_DoNothing",), + 0x80AFCC24:("EnGakufu_IsPlayerInRange",), + 0x80AFCC58:("EnGakufu_GiveReward",), 0x80AFCD44:("func_80AFCD44",), 0x80AFCDC8:("func_80AFCDC8",), 0x80AFCE70:("EnGakufu_Update",), @@ -13267,7 +13267,7 @@ 0x80B23910:("func_80B23910",), 0x80B23934:("func_80B23934",), 0x80B239FC:("EnHanabi_Update",), - 0x80B23A38:("func_80B23A38",), + 0x80B23A38:("EnHanabi_Draw",), 0x80B23D50:("func_80B23D50",), 0x80B23DD0:("func_80B23DD0",), 0x80B23E10:("ObjDowsing_Init",), @@ -13277,26 +13277,26 @@ 0x80B23F50:("ObjWind_Destroy",), 0x80B23F60:("ObjWind_Update",), 0x80B243C0:("ObjWind_Draw",), - 0x80B24630:("func_80B24630",), - 0x80B246F4:("func_80B246F4",), - 0x80B2478C:("func_80B2478C",), - 0x80B248B8:("func_80B248B8",), + 0x80B24630:("EnRacedog_ChangeAnimation",), + 0x80B246F4:("EnRacedog_UpdateCollision",), + 0x80B2478C:("EnRacedog_GetYRotation",), + 0x80B248B8:("EnRacedog_GetFloorRot",), 0x80B24930:("EnRacedog_Init",), 0x80B24BE8:("EnRacedog_Destroy",), - 0x80B24C14:("func_80B24C14",), - 0x80B24CB4:("func_80B24CB4",), - 0x80B24E14:("func_80B24E14",), - 0x80B24F08:("func_80B24F08",), - 0x80B251EC:("func_80B251EC",), - 0x80B252F8:("func_80B252F8",), - 0x80B2538C:("func_80B2538C",), - 0x80B25448:("func_80B25448",), - 0x80B25490:("func_80B25490",), - 0x80B255AC:("func_80B255AC",), - 0x80B256BC:("func_80B256BC",), + 0x80B24C14:("EnRacedog_RaceStart",), + 0x80B24CB4:("EnRacedog_Race",), + 0x80B24E14:("EnRacedog_UpdateTextId",), + 0x80B24F08:("EnRacedog_UpdateSpeed",), + 0x80B251EC:("EnRacedog_CalculateFinalStretchTargetSpeed",), + 0x80B252F8:("EnRacedog_UpdateRaceVariables",), + 0x80B2538C:("EnRacedog_CheckForFinish",), + 0x80B25448:("EnRacedog_UpdateRunAnimationPlaySpeed",), + 0x80B25490:("EnRacedog_IsOverFinishLine",), + 0x80B255AC:("EnRacedog_SpawnFloorDustRing",), + 0x80B256BC:("EnRacedog_PlayWalkSfx",), 0x80B25708:("EnRacedog_Update",), - 0x80B2583C:("func_80B2583C",), - 0x80B258D8:("func_80B258D8",), + 0x80B2583C:("EnRacedog_UpdateSelectionArrow",), + 0x80B258D8:("EnRacedog_DrawSelectionArrow",), 0x80B25A74:("EnRacedog_OverrideLimbDraw",), 0x80B25A90:("EnRacedog_PostLimbDraw",), 0x80B25B14:("EnRacedog_Draw",), @@ -13501,8 +13501,8 @@ 0x80B34574:("func_80B34574",), 0x80B34598:("func_80B34598",), 0x80B349A4:("EnKbt_Update",), - 0x80B349C8:("func_80B349C8",), - 0x80B34A00:("func_80B34A00",), + 0x80B349C8:("EnKbt_OverrideLimbDraw",), + 0x80B34A00:("EnKbt_PostLimbDraw",), 0x80B34A40:("EnKbt_Draw",), 0x80B34F70:("func_80B34F70",), 0x80B34FB4:("func_80B34FB4",), @@ -14116,8 +14116,8 @@ 0x80B5CEC8:("func_80B5CEC8",), 0x80B5D114:("func_80B5D114",), 0x80B5D160:("func_80B5D160",), - 0x80B5D37C:("func_80B5D37C",), - 0x80B5D470:("func_80B5D470",), + 0x80B5D37C:("EnOt_ActorPathing_Move",), + 0x80B5D470:("EnOt_ActorPathing_UpdateActorInfo",), 0x80B5D648:("func_80B5D648",), 0x80B5D750:("func_80B5D750",), 0x80B5D8AC:("EnOt_Update",), @@ -14130,24 +14130,24 @@ 0x80B5E1D8:("func_80B5E1D8",), 0x80B5E890:("EnDragon_Init",), 0x80B5EA74:("EnDragon_Destroy",), - 0x80B5EAA0:("func_80B5EAA0",), - 0x80B5EB40:("func_80B5EB40",), - 0x80B5ED90:("func_80B5ED90",), - 0x80B5EDF0:("func_80B5EDF0",), - 0x80B5EE3C:("func_80B5EE3C",), - 0x80B5EF88:("func_80B5EF88",), - 0x80B5EFD0:("func_80B5EFD0",), - 0x80B5F3A4:("func_80B5F3A4",), - 0x80B5F418:("func_80B5F418",), - 0x80B5F508:("func_80B5F508",), - 0x80B5F888:("func_80B5F888",), - 0x80B5F8D8:("func_80B5F8D8",), - 0x80B5FCC0:("func_80B5FCC0",), - 0x80B5FD68:("func_80B5FD68",), - 0x80B60138:("func_80B60138",), + 0x80B5EAA0:("EnDragon_ChangeAnimation",), + 0x80B5EB40:("EnDragon_SpawnBubbles",), + 0x80B5ED90:("EnDragon_RetreatOnceTimerEnds",), + 0x80B5EDF0:("EnDragon_SetupRetreatOrIdle",), + 0x80B5EE3C:("EnDragon_RetreatOrIdle",), + 0x80B5EF88:("EnDragon_SetupExtend",), + 0x80B5EFD0:("EnDragon_Extend",), + 0x80B5F3A4:("EnDragon_CameraSetAtEye",), + 0x80B5F418:("EnDragon_SetupGrab",), + 0x80B5F508:("EnDragon_Grab",), + 0x80B5F888:("EnDragon_SetupAttack",), + 0x80B5F8D8:("EnDragon_Attack",), + 0x80B5FCC0:("EnDragon_SetupDead",), + 0x80B5FD68:("EnDragon_Dead",), + 0x80B60138:("EnDragon_UpdateDamage",), 0x80B6031C:("EnDragon_Update",), - 0x80B6043C:("func_80B6043C",), - 0x80B60494:("func_80B60494",), + 0x80B6043C:("EnDragon_OverrideLimbDraw",), + 0x80B60494:("EnDragon_PostLimbDraw",), 0x80B60564:("EnDragon_Draw",), 0x80B60AD0:("ObjDora_Init",), 0x80B60C70:("ObjDora_Destroy",), @@ -14278,7 +14278,7 @@ 0x80B6849C:("func_80B6849C",), 0x80B6D660:("BgSinkaiKabe_Init",), 0x80B6D9EC:("BgSinkaiKabe_Destroy",), - 0x80B6DA20:("func_80B6DA20",), + 0x80B6DA20:("BgSinkaiKabe_WaitForPlayer",), 0x80B6DB20:("BgSinkaiKabe_Update",), 0x80B6DBE0:("BgHakaCurtain_Init",), 0x80B6DC64:("BgHakaCurtain_Destroy",), @@ -14457,9 +14457,9 @@ 0x80B76E1C:("EnTruMt_Destroy",), 0x80B76E48:("EnTruMt_Update",), 0x80B76ED4:("func_80B76ED4",), - 0x80B77008:("func_80B77008",), - 0x80B77078:("func_80B77078",), - 0x80B77354:("func_80B77354",), + 0x80B77008:("EnTruMt_OverrideLimbDraw",), + 0x80B77078:("EnTruMt_PostLimbDraw",), + 0x80B77354:("EnTruMt_TransformLimbDraw",), 0x80B773D0:("EnTruMt_Draw",), 0x80B77770:("func_80B77770",), 0x80B77FA4:("func_80B77FA4",), @@ -14517,36 +14517,36 @@ 0x80B7C03C:("ObjUm_Draw",), 0x80B7C890:("EnNeoReeba_Init",), 0x80B7CA08:("EnNeoReeba_Destroy",), - 0x80B7CA34:("func_80B7CA34",), - 0x80B7CA70:("func_80B7CA70",), - 0x80B7CB3C:("func_80B7CB3C",), - 0x80B7CB88:("func_80B7CB88",), - 0x80B7CCE0:("func_80B7CCE0",), - 0x80B7CD28:("func_80B7CD28",), - 0x80B7CE34:("func_80B7CE34",), - 0x80B7CE94:("func_80B7CE94",), - 0x80B7CFA0:("func_80B7CFA0",), - 0x80B7CFFC:("func_80B7CFFC",), - 0x80B7D130:("func_80B7D130",), - 0x80B7D150:("func_80B7D150",), - 0x80B7D254:("func_80B7D254",), - 0x80B7D2E4:("func_80B7D2E4",), - 0x80B7D360:("func_80B7D360",), - 0x80B7D398:("func_80B7D398",), - 0x80B7D3EC:("func_80B7D3EC",), - 0x80B7D47C:("func_80B7D47C",), - 0x80B7D4FC:("func_80B7D4FC",), - 0x80B7D5A4:("func_80B7D5A4",), - 0x80B7D6D0:("func_80B7D6D0",), - 0x80B7D788:("func_80B7D788",), - 0x80B7D9B8:("func_80B7D9B8",), - 0x80B7DC80:("func_80B7DC80",), - 0x80B7DD7C:("func_80B7DD7C",), - 0x80B7DF34:("func_80B7DF34",), - 0x80B7E0BC:("func_80B7E0BC",), - 0x80B7E260:("func_80B7E260",), + 0x80B7CA34:("EnNeoReeba_SetupWaitUnderground",), + 0x80B7CA70:("EnNeoReeba_WaitUnderground",), + 0x80B7CB3C:("EnNeoReeba_SetupChooseAction",), + 0x80B7CB88:("EnNeoReeba_ChooseAction",), + 0x80B7CCE0:("EnNeoReeba_SetupSink",), + 0x80B7CD28:("EnNeoReeba_Sink",), + 0x80B7CE34:("EnNeoReeba_SetupRise",), + 0x80B7CE94:("EnNeoReeba_RiseOutOfGround",), + 0x80B7CFA0:("EnNeoReeba_SetupMove",), + 0x80B7CFFC:("EnNeoReeba_Move",), + 0x80B7D130:("EnNeoReeba_SetupReturnHome",), + 0x80B7D150:("EnNeoReeba_ReturnHome",), + 0x80B7D254:("EnNeoReeba_SetupBounce",), + 0x80B7D2E4:("EnNeoReeba_Bounce",), + 0x80B7D360:("EnNeoReeba_SetupStun",), + 0x80B7D398:("EnNeoReeba_Stunned",), + 0x80B7D3EC:("EnNeoReeba_SetupFrozen",), + 0x80B7D47C:("EnNeoReeba_Frozen",), + 0x80B7D4FC:("EnNeoReeba_SetupDamageAnim",), + 0x80B7D5A4:("EnNeoReeba_DamageAnim",), + 0x80B7D6D0:("EnNeoReeba_SetupDeathEffects",), + 0x80B7D788:("EnNeoReeba_PlayDeathEffects",), + 0x80B7D9B8:("EnNeoReeba_HandleHit",), + 0x80B7DC80:("EnNeoReeba_UpdatePosition",), + 0x80B7DD7C:("EnNeoReeba_DrawFrozenEffects",), + 0x80B7DF34:("EnNeoReeba_DrawEffects",), + 0x80B7E0BC:("EnNeoReeba_SpawnIce",), + 0x80B7E260:("EnNeoReeba_SinkIfStoneMask",), 0x80B7E2C4:("EnNeoReeba_Update",), - 0x80B7E378:("func_80B7E378",), + 0x80B7E378:("EnNeoReeba_OverrideLimbDraw",), 0x80B7E424:("EnNeoReeba_Draw",), 0x80B7E930:("BgMbarChair_Init",), 0x80B7E980:("BgMbarChair_Destroy",), @@ -14808,8 +14808,8 @@ 0x80B90E84:("EnMaYto_SetRomaniFaceExpression",), 0x80B90EC8:("EnMaYto_SetFaceExpression",), 0x80B90EF0:("EnMaYto_InitFaceExpression",), - 0x80B90F84:("EnMaYto_HasSpokeToPlayerToday",), - 0x80B91014:("EnMaYto_HasSpokeToPlayer",), + 0x80B90F84:("EnMaYto_HasSpokenToPlayerToday",), + 0x80B91014:("EnMaYto_HasSpokenToPlayer",), 0x80B9109C:("EnMaYto_SetTalkedFlag",), 0x80B9110C:("EnMaYto_Update",), 0x80B91154:("EnMaYto_OverrideLimbDraw",), @@ -15076,7 +15076,7 @@ 0x80BA3230:("func_80BA3230",), 0x80BA3344:("func_80BA3344",), 0x80BA3410:("ObjNozoki_Update",), - 0x80BA3434:("func_80BA3434",), + 0x80BA3434:("ObjNozoki_Draw",), 0x80BA36C0:("func_80BA36C0",), 0x80BA36FC:("EnToto_Init",), 0x80BA3810:("EnToto_Destroy",), @@ -15211,7 +15211,7 @@ 0x80BAB434:("func_80BAB434",), 0x80BAB490:("EnSuttari_GetPaths",), 0x80BAB4F0:("func_80BAB4F0",), - 0x80BAB698:("func_80BAB698",), + 0x80BAB698:("EnSuttari_GetDistSqAndOrient",), 0x80BAB758:("func_80BAB758",), 0x80BAB8F4:("func_80BAB8F4",), 0x80BABA90:("func_80BABA90",), @@ -15274,23 +15274,23 @@ 0x80BB03E8:("EnZod_Draw",), 0x80BB08E0:("EnKujiya_Init",), 0x80BB0998:("EnKujiya_Destroy",), - 0x80BB09A8:("func_80BB09A8",), - 0x80BB09BC:("func_80BB09BC",), - 0x80BB0B28:("func_80BB0B28",), - 0x80BB0BF8:("func_80BB0BF8",), - 0x80BB0E44:("func_80BB0E44",), - 0x80BB0E58:("func_80BB0E58",), - 0x80BB0F24:("func_80BB0F24",), - 0x80BB0F38:("func_80BB0F38",), - 0x80BB0F94:("func_80BB0F94",), - 0x80BB0FA8:("func_80BB0FA8",), - 0x80BB0FF8:("func_80BB0FF8",), - 0x80BB1088:("func_80BB1088",), - 0x80BB10F8:("func_80BB10F8",), - 0x80BB1168:("func_80BB1168",), - 0x80BB1180:("func_80BB1180",), - 0x80BB1250:("func_80BB1250",), - 0x80BB1268:("func_80BB1268",), + 0x80BB09A8:("EnKujiya_SetupWait",), + 0x80BB09BC:("EnKujiya_Wait",), + 0x80BB0B28:("EnKujiya_HandlePlayerChoice",), + 0x80BB0BF8:("EnKujiya_ChooseNextDialogue",), + 0x80BB0E44:("EnKujiya_SetupTalk",), + 0x80BB0E58:("EnKujiya_Talk",), + 0x80BB0F24:("EnKujiya_SetupGivePrize",), + 0x80BB0F38:("EnKujiya_GivePrize",), + 0x80BB0F94:("EnKujiya_SetupFinishGivePrize",), + 0x80BB0FA8:("EnKujiya_FinishGivePrize",), + 0x80BB0FF8:("EnKujiya_CheckBoughtTicket",), + 0x80BB1088:("EnKujiya_SetBoughtTicket",), + 0x80BB10F8:("EnKujiya_UnsetBoughtTicket",), + 0x80BB1168:("EnKujiya_SetupTurnToOpen",), + 0x80BB1180:("EnKujiya_TurnToOpen",), + 0x80BB1250:("EnKujiya_SetupTurnToClosed",), + 0x80BB1268:("EnKujiya_TurnToClosed",), 0x80BB1338:("EnKujiya_Update",), 0x80BB135C:("EnKujiya_Draw",), 0x80BB16D0:("func_80BB16D0",), @@ -15375,15 +15375,15 @@ 0x80BB98E0:("ObjChan_Init",), 0x80BB99F0:("ObjChan_Destroy",), 0x80BB9A1C:("func_80BB9A1C",), - 0x80BB9B40:("func_80BB9B40",), - 0x80BB9C08:("func_80BB9C08",), - 0x80BB9F24:("func_80BB9F24",), - 0x80BBA2FC:("func_80BBA2FC",), - 0x80BBA314:("func_80BBA314",), - 0x80BBA488:("func_80BBA488",), + 0x80BB9B40:("ObjChan_CalculatePotPosition",), + 0x80BB9C08:("ObjChan_InitChandelier",), + 0x80BB9F24:("ObjChan_ChandelierAction",), + 0x80BBA2FC:("ObjChan_InitPot",), + 0x80BBA314:("ObjChan_PotAction",), + 0x80BBA488:("ObjChan_CreateSmashParticles",), 0x80BBA738:("ObjChan_Update",), 0x80BBA78C:("ObjChan_Draw",), - 0x80BBA894:("func_80BBA894",), + 0x80BBA894:("ObjChan_DrawPot",), 0x80BBA930:("func_80BBA930",), 0x80BBACA0:("EnZos_Init",), 0x80BBAE60:("EnZos_Destroy",), @@ -15531,14 +15531,14 @@ 0x80BC457C:("func_80BC457C",), 0x80BC458C:("BgF40Block_Update",), 0x80BC45CC:("BgF40Block_Draw",), - 0x80BC47B0:("func_80BC47B0",), + 0x80BC47B0:("BgF40Switch_CheckAll",), 0x80BC4A3C:("BgF40Switch_Init",), 0x80BC4AEC:("BgF40Switch_Destroy",), - 0x80BC4B20:("func_80BC4B20",), - 0x80BC4B94:("func_80BC4B94",), - 0x80BC4BB8:("func_80BC4BB8",), - 0x80BC4C68:("func_80BC4C68",), - 0x80BC4D30:("func_80BC4D30",), + 0x80BC4B20:("BgF40Switch_Unpress",), + 0x80BC4B94:("BgF40Switch_IdlePressed",), + 0x80BC4BB8:("BgF40Switch_Press",), + 0x80BC4C68:("BgF40Switch_WaitToPress",), + 0x80BC4D30:("BgF40Switch_IdleUnpressed",), 0x80BC4D54:("BgF40Switch_Update",), 0x80BC4D90:("BgF40Switch_Draw",), 0x80BC4F30:("EnPoComposer_Init",), @@ -16094,10 +16094,10 @@ 0x80BE393C:("EnRuppecrow_Draw",), 0x80BE3B80:("EnTanron4_Init",), 0x80BE3DB0:("EnTanron4_Destroy",), - 0x80BE3DC0:("func_80BE3DC0",), - 0x80BE3DFC:("func_80BE3DFC",), - 0x80BE4268:("func_80BE4268",), - 0x80BE42A4:("func_80BE42A4",), + 0x80BE3DC0:("EnTanron4_SetupFlyNearHome",), + 0x80BE3DFC:("EnTanron4_FlyNearHome",), + 0x80BE4268:("EnTanron4_SetupFlyNearActor",), + 0x80BE42A4:("EnTanron4_FlyNearActor",), 0x80BE4734:("EnTanron4_Update",), 0x80BE4804:("EnTanron4_Draw",), 0x80BE4930:("func_80BE4930",), @@ -16530,11 +16530,11 @@ 0x80C04354:("func_80C04354",), 0x80C043C8:("func_80C043C8",), 0x80C0443C:("EnBombers_Update",), - 0x80C045B4:("func_80C045B4",), + 0x80C045B4:("EnBombers_OverrideLimbDraw",), 0x80C04614:("EnBombers_Draw",), 0x80C04930:("EnBombers2_Init",), 0x80C04A80:("EnBombers2_Destroy",), - 0x80C04AAC:("func_80C04AAC",), + 0x80C04AAC:("EnBombers2_ChangeAnim",), 0x80C04B40:("func_80C04B40",), 0x80C04BA0:("func_80C04BA0",), 0x80C04D00:("func_80C04D00",), @@ -16811,8 +16811,8 @@ 0x80C14D14:("func_80C14D14",), 0x80C14D58:("func_80C14D58",), 0x80C14E08:("EnJgameTsn_Update",), - 0x80C14E64:("func_80C14E64",), - 0x80C14EE4:("func_80C14EE4",), + 0x80C14E64:("EnJgamesTsn_OverrideLimbDraw",), + 0x80C14EE4:("EnJgamesTsn_PostLimbDraw",), 0x80C14F1C:("EnJgameTsn_Draw",), 0x80C152F0:("ObjJgameLight_Init",), 0x80C1542C:("ObjJgameLight_Destroy",), @@ -17112,8 +17112,8 @@ 0x80C24BE0:("DmGm_Init",), 0x80C24C34:("DmGm_Destroy",), 0x80C24C44:("DmGm_Update",), - 0x80C24CD0:("func_80C24CD0",), - 0x80C24E4C:("func_80C24E4C",), + 0x80C24CD0:("DmGm_PostLimbDraw",), + 0x80C24E4C:("DmGm_TransformLimbDraw",), 0x80C25000:("func_80C25000",), 0x80C25360:("func_80C25360",), 0x80C253D0:("func_80C253D0",), diff --git a/tools/disasm/mips_isa.py b/tools/disasm/mips_isa.py index 44cddacd7d..337bbd021f 100644 --- a/tools/disasm/mips_isa.py +++ b/tools/disasm/mips_isa.py @@ -286,15 +286,26 @@ mips_cop0_names = [ "TagLo" , "TagHi" , "ErrorEPC" , "Reserved31", ] -mips_fpr_names = [ +numeric_fpr_names = [ "$f0", "$f1", "$f2", "$f3", "$f4", "$f5", "$f6", "$f7", "$f8", "$f9", "$f10", "$f11", "$f12", "$f13", "$f14", "$f15", "$f16", "$f17", "$f18", "$f19", "$f20", "$f21", "$f22", "$f23", "$f24", "$f25", "$f26", "$f27", "$f28", "$f29", "$f30", - "$31", + "$31", # Floating-point control/status register ] +o32_fpr_names = [ + "$fv0", "$fv0f", "$fv1", "$fv1f", + "$ft0", "$ft0f", "$ft1", "$ft1f", "$ft2", "$ft2f", "$ft3", "$ft3f", + "$fa0", "$fa0f", "$fa1", "$fa1f", + "$ft4", "$ft4f", "$ft5", "$ft5f", + "$fs0", "$fs0f", "$fs1", "$fs1f", "$fs2", "$fs2f", "$fs3", "$fs3f", "$fs4", "$fs4f", "$fs5", + "$31", # Floating-point control/status register +] + +mips_fpr_names = numeric_fpr_names + # Instruction field fetching def sign_extend_16(value): diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 633f86d35a..b49c9a68db 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -35,7 +35,9 @@ 0x80096CD0:("sGfxPrintUnkTLUT","u16","[16]",0x20), 0x80096CF0:("sGfxPrintUnkData","u8","[8]",0x8), 0x80096CF8:("sGfxPrintFontData","u8","[0x800]",0x800), - 0x80097500:("D_80097500","UNK_TYPE4","",0x4), + 0x80097500:("sInitFuncs","void*","",0x4), + 0x80097504:("sNew","char","[4]",0x4), + 0x80097508:("D_80097508","[24]","",0x18), 0x80097520:("qNaN0x3FFFFF","f32","",0x4), 0x80097524:("qNaN0x10000","f32","",0x4), 0x80097528:("sNaN0x3FFFFF","f32","",0x4), @@ -443,7 +445,7 @@ 0x801AEE38:("D_801AEE38","struct_801AEE38","[14]",0x150), 0x801AEF88:("D_801AEF88","UNK_TYPE1","",0x1), 0x801AEFA0:("D_801AEFA0","UNK_TYPE1","",0x1), - 0x801AEFA8:("D_801AEFA8","UNK_TYPE1","",0x1), + 0x801AEFA8:("sElectricSparkTextures","UNK_TYPE1","",0x1), 0x801AEFB8:("D_801AEFB8","UNK_TYPE1","",0x1), 0x801AEFBC:("D_801AEFBC","UNK_TYPE1","",0x1), 0x801AEFC0:("D_801AEFC0","UNK_TYPE1","",0x1), @@ -918,8 +920,8 @@ 0x801BC288:("D_801BC288","Gfx","[3]",0x18), 0x801BC2A0:("D_801BC2A0","UNK_TYPE1","",0x1), 0x801BC3F0:("gEnHyBodyParts","UNK_TYPE1","",0x1), - 0x801BC400:("gEnHyBodyPartsIndex","UNK_TYPE1","",0x1), - 0x801BC410:("gEnHyShadowSize","s32",[],0x10), + 0x801BC400:("gEnHyParentBodyParts","UNK_TYPE1","",0x1), + 0x801BC410:("gEnHyShadowSizes","s32",[],0x10), 0x801BC420:("sReactionTextIds","u16","[]",0x140A), 0x801BD830:("actorCutscenesGlobalCutscenes","ActorCutscene","[8]",0x80), 0x801BD8B0:("actorCutsceneCurrent","s16","",0x2), @@ -932,7 +934,8 @@ 0x801BD8C4:("actorCutsceneReturnCamera","s16","",0x2), 0x801BD8C6:("D_801BD8C6","s16","",0x2), 0x801BD8D0:("sFireObjCollisionInit","ColliderCylinderInit","",0x2c), - 0x801BD8FC:("sFireObjLightParams","FireObjLightParams","[2]",0x10), + 0x801BD8FC:("sFireObjColors","FireObjColors","[1]",0x08), + 0x801BD904:("sFireObjLightParams","FireObjLightParams","[1]",0x08), 0x801BD910:("gGameStateOverlayTable","GameStateOverlay","[7]",0x150), 0x801BDA60:("graphNumGameStates","UNK_TYPE4","",0x4), 0x801BDA70:("D_801BDA70","UNK_TYPE2","",0x2), @@ -957,8 +960,8 @@ 0x801BDAF0:("D_801BDAF0","UNK_TYPE4","",0x4), 0x801BDAF8:("D_801BDAF8","UNK_TYPE4","",0x4), 0x801BDB00:("D_801BDB00","UNK_TYPE1","",0x1), - 0x801BDB08:("D_801BDB08","UNK_TYPE1","",0x1), - 0x801BDB18:("D_801BDB18","UNK_TYPE1","",0x1), + 0x801BDB08:("sKaleidoSetupEyeX","UNK_TYPE1","",0x1), + 0x801BDB18:("sKaleidoSetupEyeZ","UNK_TYPE1","",0x1), 0x801BDB30:("kanfontOrdering","u8","[92]",0x5c), 0x801BDB90:("D_801BDB90","f32","",0x4), 0x801BDB94:("D_801BDB94","UNK_TYPE4","",0x4), @@ -1968,9 +1971,9 @@ 0x801C5CD0:("sMtxFClear","MtxF","",0x40), 0x801C5D10:("D_801C5D10","UNK_TYPE1","",0x1), 0x801C5D20:("D_801C5D20","UNK_TYPE1","",0x1), - 0x801C5D60:("D_801C5D60","UNK_TYPE1","",0x1), - 0x801C5D80:("D_801C5D80","UNK_TYPE1","",0x1), - 0x801C5DB0:("D_801C5DB0","UNK_TYPE1","",0x1), + 0x801C5D60:("gShadowDL","UNK_TYPE1","",0x1), + 0x801C5D80:("gShadowVtxDL","UNK_TYPE1","",0x1), + 0x801C5DB0:("gOneVec3f","UNK_TYPE1","",0x1), 0x801C5DD0:("D_801C5DD0","UNK_TYPE1","",0x1), 0x801C5DE0:("D_801C5DE0","UNK_TYPE1","",0x1), 0x801C5DF0:("D_801C5DF0","UNK_TYPE1","",0x1), @@ -1982,33 +1985,27 @@ 0x801C5EB0:("D_801C5EB0","UNK_TYPE4","",0x4), 0x801C5EC4:("D_801C5EC4","UNK_TYPE2","",0x2), 0x801C5F44:("D_801C5F44","UNK_TYPE4","",0x4), - 0x801C5FC0:("D_801C5FC0","UNK_TYPE4","",0x4), - 0x801C5FC4:("D_801C5FC4","UNK_TYPE4","",0x4), - 0x801C5FC8:("D_801C5FC8","UNK_TYPE4","",0x4), - 0x801C5FCC:("D_801C5FCC","UNK_TYPE4","",0x4), - 0x801C5FD0:("D_801C5FD0","UNK_TYPE4","",0x4), + 0x801C5FC0:("D_801C5FC0","u32","[452]",0x710), 0x801C66D0:("D_801C66D0","UNK_TYPE2","",0x2), 0x801C6798:("D_801C6798","UNK_TYPE4","",0x4), 0x801C67B0:("D_801C67B0","UNK_TYPE1","",0x1), - 0x801C67C8:("D_801C67C8","UNK_TYPE4","",0x4), - 0x801C67CC:("D_801C67CC","UNK_TYPE4","",0x4), + 0x801C67C8:("D_801C67C8","s32","[8]",0x20), 0x801C67E8:("D_801C67E8","UNK_TYPE4","",0x4), - 0x801C67F0:("D_801C67F0","UNK_TYPE4","",0x4), - 0x801C67F4:("D_801C67F4","UNK_TYPE4","",0x4), + 0x801C67F0:("D_801C67F0","s32","[8]",0x20), 0x801C6818:("D_801C6818","UNK_TYPE1","",0x1), 0x801C6838:("D_801C6838","UNK_TYPE4","",0x4), 0x801C6840:("D_801C6840","UNK_TYPE1","",0x1), 0x801C6850:("D_801C6850","UNK_TYPE1","",0x1), 0x801C6870:("D_801C6870","UNK_TYPE1","",0x1), 0x801C6890:("D_801C6890","UNK_TYPE1","",0x1), - 0x801C6898:("D_801C6898","SaveInfo","",0x28), - 0x801C68C0:("D_801C68C0","SaveContext_struct2","",0x22), - 0x801C68E4:("gSaveDefaultInventory","Inventory","",0x88), - 0x801C696C:("gSaveDefaultChecksum","u16","",0x2), - 0x801C6970:("D_801C6970","SaveInfo","",0x28), - 0x801C6998:("D_801C6998","SaveContext_struct2","",0x22), - 0x801C69BC:("D_801C69BC","Inventory","",0x88), - 0x801C6A44:("D_801C6A44","u16","",0x2), + 0x801C6898:("sSaveDefaultPlayerData","SavePlayerData","",0x28), + 0x801C68C0:("sSaveDefaultItemEquips","ItemEquips","",0x22), + 0x801C68E4:("sSaveDefaultInventory","Inventory","",0x88), + 0x801C696C:("sSaveDefaultChecksum","u16","",0x2), + 0x801C6970:("sSaveDebugPlayerData","SaveInfo","",0x28), + 0x801C6998:("sSaveDebugItemEquips","ItemEquips","",0x22), + 0x801C69BC:("sSaveDebugInventory","Inventory","",0x88), + 0x801C6A44:("sSaveDebugChecksum","u16","",0x2), 0x801C6A48:("D_801C6A48","UNK_TYPE1","",0x1), 0x801C6A50:("D_801C6A50","UNK_TYPE1","",0x1), 0x801C6A58:("D_801C6A58","UNK_TYPE1","",0x1), @@ -2285,7 +2282,7 @@ 0x801D5FD4:("D_801D5FD4","UNK_TYPE1","",0x1), 0x801D5FE0:("D_801D5FE0","UNK_PTR","",0x4), 0x801D5FE4:("D_801D5FE4","UNK_TYPE1","",0x1), - 0x801D5FE8:("D_801D5FE8","UNK_TYPE4","",0x4), + 0x801D5FE8:("gAudioContextInitalized","UNK_TYPE4","",0x4), 0x801D5FEC:("D_801D5FEC","UNK_TYPE4","",0x4), 0x801D5FF0:("D_801D5FF0","UNK_TYPE4","",0x4), 0x801D5FF4:("D_801D5FF4","UNK_TYPE4","",0x4), @@ -2350,11 +2347,11 @@ 0x801D6FB8:("sOcarinaInstrumentId","UNK_TYPE1","",0x1), 0x801D6FBC:("sCurOcarinaPitch","UNK_TYPE1","",0x1), 0x801D6FC0:("sPrevOcarinaPitch","UNK_TYPE1","",0x1), - 0x801D6FC4:("sCurOcarinaButtonIdx","UNK_TYPE1","",0x1), + 0x801D6FC4:("sCurOcarinaButtonIndex","UNK_TYPE1","",0x1), 0x801D6FC8:("sMusicStaffPrevPitch","UNK_TYPE1","",0x1), 0x801D6FCC:("sCurOcarinaBendFreq","f32","",0x4), 0x801D6FD0:("sDefaultOcarinaVolume","UNK_TYPE1","",0x1), - 0x801D6FD4:("sCurOcarinaBendIdx","UNK_TYPE1","",0x1), + 0x801D6FD4:("sCurOcarinaBendIndex","UNK_TYPE1","",0x1), 0x801D6FD8:("sCurOcarinaVolume","UNK_TYPE1","",0x1), 0x801D6FDC:("sCurOcarinaVibrato","UNK_TYPE1","",0x1), 0x801D6FE0:("sPlaybackState","UNK_TYPE1","",0x1), @@ -2376,8 +2373,8 @@ 0x801D7020:("sCurOcarinaSong","u8","[8]",0x8), 0x801D7028:("sOcarinaSongAppendPos","UNK_TYPE1","",0x1), 0x801D702C:("sOcarinaSongStartingPos","UNK_TYPE1","",0x1), - 0x801D7030:("sButtonToNoteMap","UNK_TYPE1","",0x1), - 0x801D7038:("sOcaMemoryGameAppendPos","UNK_TYPE1","",0x1), + 0x801D7030:("sButtonToPitchMap","UNK_TYPE1","",0x1), + 0x801D7038:("sOcarinaMemoryGameAppendPos","UNK_TYPE1","",0x1), 0x801D703C:("sOcaMemoryGameEndPos","UNK_TYPE1","",0x1), 0x801D7040:("sOcaMemoryGameNumNotes","UNK_TYPE1","",0x1), 0x801D7044:("sOcarinaSongNotes","OcarinaNote","[24][20]",0xF00), @@ -2392,9 +2389,9 @@ 0x801D8514:("sRecordOcarinaPitch","UNK_TYPE1","",0x1), 0x801D8518:("sRecordOcarinaVolume","UNK_TYPE1","",0x1), 0x801D851C:("sRecordOcarinaVibrato","UNK_TYPE1","",0x1), - 0x801D8520:("sRecordOcarinaBendIdx","UNK_TYPE1","",0x1), - 0x801D8524:("sRecordOcarinaButtonIdx","UNK_TYPE1","",0x1), - 0x801D8528:("sPlayedOcarinaSongIdxPlusOne","UNK_TYPE1","",0x1), + 0x801D8520:("sRecordOcarinaBendIndex","UNK_TYPE1","",0x1), + 0x801D8524:("sRecordOcarinaButtonIndex","UNK_TYPE1","",0x1), + 0x801D8528:("sPlayedOcarinaSongIndexPlusOne","UNK_TYPE1","",0x1), 0x801D852C:("sMusicStaffNumNotesPerTest","UNK_TYPE1","",0x1), 0x801D8530:("D_801D8530","UNK_TYPE1","",0x1), 0x801D8534:("D_801D8534","UNK_TYPE4","",0x4), @@ -2403,7 +2400,7 @@ 0x801D889C:("gScarecrowLongSongPtr","UNK_PTR","",0x4), 0x801D88A0:("gScarecrowSpawnSongPtr","UNK_PTR","",0x4), 0x801D88A4:("sTerminaWallSongPtr","UNK_PTR","",0x4), - 0x801D88A8:("sNoteToButtonMap","UNK_TYPE1","",0x1), + 0x801D88A8:("sPitchToButtonMap","UNK_TYPE1","",0x1), 0x801D88B8:("sCustomSequenceScript","UNK_TYPE1","",0x1), 0x801D8A48:("gOcarinaSongButtons","UNK_TYPE1","",0x1), 0x801D8B20:("sScarecrowAfterCreditsState","UNK_TYPE1","",0x1), @@ -2460,7 +2457,7 @@ 0x801DB8B8:("D_801DB8B8","UNK_TYPE1","",0x1), 0x801DB900:("D_801DB900","UNK_TYPE1","",0x1), 0x801DB930:("D_801DB930","UNK_PTR","",0x4), - 0x801DB958:("D_801DB958","AudioSpec","[21]",0x498), + 0x801DB958:("gAudioSpecs","AudioSpec","[21]",0x498), 0x801DBDF0:("D_801DBDF0","f32","",0x4), 0x801DBDF4:("jtbl_801DBDF4","UNK_PTR","",0x4), 0x801DBE68:("D_801DBE68","f32","",0x4), @@ -4071,7 +4068,8 @@ 0x801F5AA8:("sMatAnimAlphaRatio","f32","",0x4), 0x801F5AB0:("sAnimQueueFlags","UNK_TYPE1","",0x1), 0x801F5AB4:("sDisableAnimQueueFlags","UNK_TYPE1","",0x1), - 0x801F5AC0:("D_801F5AC0","UNK_TYPE1","",0x1), + 0x801F5AC0:("gSkinLimbMatrices","MtxF","[60]",0xF00), + 0x801F69C0:("D_801F69C0","UNK_TYPE1","",0x10), 0x801F69D0:("D_801F69D0","UNK_TYPE1","",0x1), 0x801F6A10:("D_801F6A10","UNK_TYPE1","",0x1), 0x801F6AD4:("D_801F6AD4","UNK_TYPE1","",0x1), @@ -4324,7 +4322,7 @@ 0x801FD3D9:("sObjSoundFanfareSeqId","UNK_TYPE1","",0x1), 0x801FD3DA:("sObjSoundFanfareRequested","UNK_TYPE1","",0x1), 0x801FD3E0:("sObjSoundFanfarePos","UNK_TYPE1","",0x1), - 0x801FD3EC:("sObjSoundPlayerIdx","UNK_TYPE1","",0x1), + 0x801FD3EC:("sObjSoundPlayerIndex","UNK_TYPE1","",0x1), 0x801FD3F0:("sObjSoundPos","UNK_TYPE1","",0x1), 0x801FD3FC:("sObjSoundFlags","UNK_TYPE1","",0x1), 0x801FD400:("sObjSoundMinDist","UNK_TYPE1","",0x1), @@ -4339,7 +4337,7 @@ 0x801FD432:("D_801FD432","UNK_TYPE1","",0x1), 0x801FD433:("sSpatialSubBgmFadeTimer","UNK_TYPE1","",0x1), 0x801FD434:("D_801FD434","UNK_TYPE1","",0x1), - 0x801FD435:("sSpatialSeqPlayerIdx","UNK_TYPE1","",0x1), + 0x801FD435:("sSpatialSeqPlayerIndex","UNK_TYPE1","",0x1), 0x801FD436:("sSpatialSeqFadeTimer","UNK_TYPE1","",0x1), 0x801FD438:("D_801FD438","UNK_TYPE1","",0x1), 0x801FD43A:("sPlayingStaff","OcarinaStaff","",0x3), @@ -4354,8 +4352,8 @@ 0x801FD460:("sOcarinaResetDelay","UNK_TYPE1","",0x1), 0x801FD461:("sOcarinaResetUnused","UNK_TYPE1","",0x1), 0x801FD462:("sOcarinaHasStartedSong","UNK_TYPE1","",0x1), - 0x801FD463:("sFirstOcarinaSongIdx","UNK_TYPE1","",0x1), - 0x801FD464:("sLastOcarinaSongIdx","UNK_TYPE1","",0x1), + 0x801FD463:("sFirstOcarinaSongIndex","UNK_TYPE1","",0x1), + 0x801FD464:("sLastOcarinaSongIndex","UNK_TYPE1","",0x1), 0x801FD468:("sOcarinaAvailSongs","UNK_TYPE1","",0x1), 0x801FD46C:("sOcarinaStaffPlayingPos","UNK_TYPE1","",0x1), 0x801FD470:("sMusicStaffPos","UNK_TYPE1","",0x1), @@ -5803,10 +5801,7 @@ 0x808763AC:("D_808763AC","UNK_TYPE1","",0x1), 0x808763B4:("D_808763B4","UNK_TYPE1","",0x1), 0x808763C0:("D_808763C0","UNK_TYPE1","",0x1), - 0x808763D4:("D_808763D4","UNK_TYPE1","",0x1), - 0x808763D6:("D_808763D6","UNK_TYPE1","",0x1), - 0x808763E6:("D_808763E6","UNK_TYPE1","",0x1), - 0x808763E7:("D_808763E7","UNK_TYPE1","",0x1), + 0x808763D4:("D_808763D4","s8","[25]",0x25), 0x808763F0:("D_808763F0","f32","",0x4), 0x808763F4:("D_808763F4","f32","",0x4), 0x808763F8:("D_808763F8","f32","",0x4), @@ -5898,19 +5893,18 @@ 0x8087B538:("D_8087B538","f32","",0x4), 0x80888EC0:("D_80888EC0","UNK_TYPE1","",0x1), 0x80888EE4:("D_80888EE4","UNK_TYPE1","",0x1), - 0x80888F08:("D_80888F08","UNK_TYPE1","",0x1), + 0x80888F08:("sAnimationHeaders","AnimationHeader*","[5]",0x14), 0x80888F1C:("D_80888F1C","UNK_TYPE1","",0x1), 0x80888F34:("D_80888F34","UNK_TYPE4","",0x4), - 0x80888F40:("D_80888F40","UNK_TYPE1","",0x1), + 0x80888F40:("sSkeletonHeaders","UNK_TYPE1","",0x1), 0x80888F54:("En_Horse_InitVars","UNK_TYPE1","",0x1), - 0x80888F74:("D_80888F74","UNK_TYPE1","",0x1), - 0x80888FA0:("D_80888FA0","UNK_TYPE1","",0x1), + 0x80888F74:("sCylinderInit1","UNK_TYPE1","",0x1), + 0x80888FA0:("sCylinderInit2","UNK_TYPE1","",0x1), 0x80888FCC:("D_80888FCC","UNK_TYPE1","",0x1), - 0x80888FF0:("D_80888FF0","UNK_TYPE1","",0x1), - 0x80888FFC:("D_80888FFC","UNK_PTR","",0x4), - 0x80889000:("D_80889000","UNK_TYPE1","",0x1), + 0x80888FF0:("sJntSphInit","UNK_TYPE1","",0x10), + 0x80889000:("sColChkInfoInit","UNK_TYPE1","",0x1), 0x80889008:("D_80889008","UNK_TYPE1","",0x1), - 0x80889010:("D_80889010","UNK_TYPE1","",0x1), + 0x80889010:("sInitChain","UNK_TYPE1","",0x1), 0x80889018:("D_80889018","UNK_TYPE1","",0x1), 0x80889030:("D_80889030","UNK_TYPE1","",0x1), 0x80889048:("D_80889048","UNK_TYPE1","",0x1), @@ -5925,7 +5919,7 @@ 0x8088911C:("D_8088911C","UNK_TYPE1","",0x1), 0x80889148:("D_80889148","UNK_TYPE4","",0x4), 0x80889154:("D_80889154","UNK_TYPE4","",0x4), - 0x80889160:("D_80889160","UNK_PTR","",0x4), + 0x80889160:("sActionFuncs","UNK_PTR","",0x4), 0x808891C8:("D_808891C8","UNK_TYPE4","",0x4), 0x808891D4:("D_808891D4","UNK_TYPE4","",0x4), 0x808891E0:("D_808891E0","UNK_TYPE4","",0x4), @@ -7990,15 +7984,14 @@ 0x8092024C:("D_8092024C","UNK_TYPE1","",0x1), 0x80920268:("D_80920268","UNK_TYPE1","",0x1), 0x80920290:("jtbl_80920290","UNK_PTR","",0x4), - 0x80920DF0:("arrowFireTexture1","u8","[2048]",0x800), - 0x809215F0:("arrowFireTexture2","u8","[2048]",0x800), - 0x80921DF0:("arrowFireVertices","F3DVertex","[43]",0x2b0), - 0x80921FF0:("D_80921FF0","UNK_TYPE1","",0x1), - 0x809220A0:("D_809220A0","Gfx","[22]",0xb0), - 0x80922150:("D_80922150","Gfx","[24]",0xc0), + 0x80920DF0:("gFireArrowTex","u8","[2048]",0x800), + 0x809215F0:("gFireArrowMaskTex","u8","[2048]",0x800), + 0x80921DF0:("gFireArrowVtx","F3DVertex","[43]",0x2b0), + 0x809220A0:("gIceArrowMaterialDL","Gfx","[22]",0xb0), + 0x80922150:("gIceArrowModelDL","Gfx","[24]",0xc0), 0x80922210:("Arrow_Fire_InitVars","ActorInit","",0x20), - 0x80922230:("D_80922230","UNK_TYPE1","",0x1), - 0x80922280:("fireArrowActorInitVars","ActorInitVar","[1]",0x4), + 0x80922230:("sQuadInit","UNK_TYPE1","",0x1), + 0x80922280:("sInitChain","ActorInitVar","[1]",0x4), 0x80922284:("D_80922284","Vec3f","",0xc), 0x80922290:("D_80922290","Vec3f","",0xc), 0x8092229C:("D_8092229C","Vec3f","",0xc), @@ -8039,7 +8032,7 @@ 0x80925F10:("D_80925F10","UNK_TYPE1","",0x1), 0x80925FC0:("D_80925FC0","UNK_TYPE1","",0x1), 0x80926080:("Arrow_Light_InitVars","UNK_TYPE1","",0x1), - 0x809260A0:("D_809260A0","UNK_TYPE1","",0x1), + 0x809260A0:("sInitChain","UNK_TYPE1","",0x1), 0x809260B0:("D_809260B0","char","[]",0x1), 0x809260B8:("D_809260B8","f32","",0x4), 0x809260BC:("D_809260BC","f32","",0x4), @@ -9003,8 +8996,8 @@ 0x80979150:("D_80979150","f32","",0x4), 0x80979560:("Effect_Ss_D_Fire_InitVars","UNK_TYPE1","",0x1), 0x80979568:("D_80979568","UNK_TYPE1","",0x1), - 0x80979AB0:("Effect_Ss_Bubble_InitVars","UNK_TYPE1","",0x1), - 0x80979AB8:("D_80979AB8","UNK_TYPE1","",0x1), + 0x80979AB0:("Effect_Ss_Bubble_InitVars","UNK_TYPE1","",0x8), + 0x80979AB8:("D_80979AB8","f32","[3]",0xC), 0x80979AD0:("D_80979AD0","f32","",0x4), 0x80979AD4:("D_80979AD4","f32","",0x4), 0x80979FF0:("Effect_Ss_G_Ripple_InitVars","UNK_TYPE1","",0x1), @@ -10315,17 +10308,17 @@ 0x809E8F14:("D_809E8F14","UNK_TYPE1","",0x1), 0x809E8F24:("D_809E8F24","UNK_TYPE1","",0x1), 0x809E8FD8:("D_809E8FD8","UNK_TYPE1","",0x1), - 0x809E8FE8:("D_809E8FE8","UNK_TYPE4","",0x4), - 0x809E90FC:("D_809E90FC","UNK_TYPE1","",0x1), - 0x809E9100:("D_809E9100","UNK_TYPE1","",0x1), + 0x809E8FE8:("sGyorgInitialPos","Vec3f","",0xC), + 0x809E8FF4:("D_809E8FF4","f32","",0x1), + 0x809E90FC:("sGyorgDustPrimColor","UNK_TYPE1","",0x1), + 0x809E9100:("sGyorgDustEnvColor","UNK_TYPE1","",0x1), 0x809E9104:("D_809E9104","UNK_TYPE1","",0x1), - 0x809E9128:("D_809E9128","UNK_TYPE1","",0x1), - 0x809E9136:("D_809E9136","UNK_TYPE1","",0x1), + 0x809E9128:("sGyorgSphElementIndices","s8","[30]",0x1E), 0x809E9148:("D_809E9148","UNK_TYPE1","",0x1), - 0x809E9154:("D_809E9154","UNK_TYPE1","",0x1), + 0x809E9154:("D_809E9154","Vec3f","[7]",0x54), 0x809E91A8:("D_809E91A8","UNK_TYPE1","",0x1), 0x809E91B4:("D_809E91B4","f32","",0x4), - 0x809E91C0:("D_809E91C0","UNK_TYPE4","",0x4), + 0x809E91C0:("sGyorgSeaweedDLs","UNK_TYPE4","",0x4), 0x809E91E0:("D_809E91E0","f32","",0x4), 0x809E91E4:("D_809E91E4","f32","",0x4), 0x809E91E8:("D_809E91E8","f32","",0x4), @@ -10388,13 +10381,11 @@ 0x809E9841:("D_809E9841","UNK_TYPE1","",0x1), 0x809E9842:("D_809E9842","UNK_TYPE1","",0x1), 0x809E9848:("D_809E9848","UNK_TYPE1","",0x1), - 0x809E9858:("D_809E9858","UNK_TYPE1","",0x1), - 0x809E989C:("D_809E989C","UNK_TYPE1","",0x1), - 0x809E98E0:("D_809E98E0","UNK_TYPE1","",0x1), - 0x809EC030:("D_809EC030","UNK_TYPE4","",0x4), - 0x809EC034:("D_809EC034","UNK_TYPE4","",0x4), - 0x809EC038:("D_809EC038","UNK_TYPE4","",0x4), - 0x809EC03C:("D_809EC03C","UNK_TYPE4","",0x4), + 0x809E9858:("sGyorgEffects","UNK_TYPE1","[150]",0x27D8), + 0x809EC030:("sGyorgBossInstance","UNK_TYPE4","",0x4), + 0x809EC034:("sRandSeed0","UNK_TYPE4","",0x4), + 0x809EC038:("sRandSeed1","UNK_TYPE4","",0x4), + 0x809EC03C:("sRandSeed2","UNK_TYPE4","",0x4), 0x809EE150:("D_809EE150","UNK_TYPE1","",0x1), 0x809EE170:("Boss_04_InitVars","UNK_TYPE1","",0x1), 0x809EE190:("D_809EE190","UNK_TYPE1","",0x1), @@ -10896,10 +10887,10 @@ 0x80A16818:("jtbl_80A16818","UNK_PTR","",0x4), 0x80A18EC0:("En_Raf_InitVars","UNK_TYPE1","",0x1), 0x80A18EE0:("D_80A18EE0","UNK_TYPE1","",0x1), - 0x80A18F0C:("D_80A18F0C","UNK_TYPE1","",0x1), - 0x80A18F4C:("D_80A18F4C","UNK_TYPE1","",0x1), - 0x80A18F8C:("D_80A18F8C","UNK_TYPE1","",0x1), - 0x80A1918C:("D_80A1918C","UNK_TYPE1","",0x1), + 0x80A18F0C:("D_80A18F0C","u8","[0x40]",0x40), + 0x80A18F4C:("D_80A18F4C","u8","[0x40]",0x40), + 0x80A18F8C:("D_80A18F8C","u8","[0x200]",0x200), + 0x80A1918C:("D_80A1918C","u8","[0x200]",0x200), 0x80A1939C:("D_80A1939C","UNK_TYPE1","",0x1), 0x80A193BC:("D_80A193BC","UNK_TYPE4","",0x4), 0x80A193C8:("D_80A193C8","UNK_TYPE1","",0x1), @@ -10909,10 +10900,8 @@ 0x80A19400:("D_80A19400","UNK_TYPE4","",0x4), 0x80A1940C:("D_80A1940C","UNK_TYPE4","",0x4), 0x80A19418:("D_80A19418","UNK_TYPE2","",0x2), - 0x80A19420:("D_80A19420","UNK_TYPE1","",0x1), - 0x80A19438:("D_80A19438","UNK_TYPE1","",0x1), - 0x80A19444:("D_80A19444","UNK_TYPE1","",0x1), - 0x80A1945C:("D_80A1945C","UNK_TYPE1","",0x1), + 0x80A19420:("D_80A19420","Vec3f","[3]",0x24), + 0x80A19444:("D_80A19444","Vec3f","[3]",0x24), 0x80A19468:("D_80A19468","UNK_TYPE2","",0x2), 0x80A19474:("D_80A19474","UNK_TYPE1","",0x1), 0x80A194B0:("D_80A194B0","UNK_TYPE1","",0x1), @@ -13478,10 +13467,9 @@ 0x80AF34F4:("D_80AF34F4","f32","",0x4), 0x80AF34F8:("D_80AF34F8","f32","",0x4), 0x80AF38B0:("D_80AF38B0","UNK_TYPE1","",0x1), - 0x80AF38F0:("D_80AF38F0","f32","",0x4), - 0x80AF38F4:("D_80AF38F4","f32","",0x4), - 0x80AF38F8:("D_80AF38F8","f32","",0x4), - 0x80AF3900:("D_80AF3900","UNK_TYPE1","",0x1), + 0x80AF38F0:("D_80AF38F0","Vec3f","",0xC), + 0x80AF38FC:("D_80AF38FC","UNK_TYPE4","",0x4), + 0x80AF3900:("D_80AF3900","Vec3f","",0xC), 0x80AF3E80:("Obj_Lightblock_InitVars","UNK_TYPE1","",0x1), 0x80AF3EA0:("D_80AF3EA0","UNK_TYPE1","",0x1), 0x80AF3ECC:("D_80AF3ECC","UNK_TYPE1","",0x1), @@ -14198,10 +14186,7 @@ 0x80B311D8:("D_80B311D8","UNK_TYPE1","",0x1), 0x80B31340:("D_80B31340","UNK_TYPE1","",0x1), 0x80B31350:("D_80B31350","UNK_TYPE1","",0x1), - 0x80B313A0:("D_80B313A0","UNK_TYPE1","",0x18), - 0x80B313B8:("D_80B313B8","UNK_TYPE1","",0x18), - 0x80B313D0:("D_80B313D0","UNK_TYPE1","",0x18), - 0x80B313E8:("D_80B313E8","UNK_TYPE1","",0x18), + 0x80B313A0:("D_80B313A0","ObjSpidertentStruct2","[4]",0x60), 0x80B31400:("D_80B31400","UNK_TYPE1","",0x1), 0x80B3140C:("D_80B3140C","UNK_TYPE1","",0x1), 0x80B31418:("D_80B31418","UNK_TYPE1","",0x1), @@ -14813,15 +14798,10 @@ 0x80B60754:("D_80B60754","UNK_TYPE1","",0x1), 0x80B60758:("D_80B60758","UNK_TYPE1","",0x1), 0x80B60764:("D_80B60764","UNK_TYPE1","",0x1), - 0x80B60770:("D_80B60770","f32","",0x4), - 0x80B60774:("D_80B60774","f32","",0x4), - 0x80B60778:("D_80B60778","f32","",0x4), - 0x80B6077C:("D_80B6077C","UNK_TYPE1","",0x1), - 0x80B60780:("D_80B60780","f32","",0x4), - 0x80B60788:("D_80B60788","UNK_TYPE1","",0x1), - 0x80B60790:("D_80B60790","f32","",0x4), - 0x80B607E8:("D_80B607E8","UNK_TYPE1","",0x1), - 0x80B607F0:("D_80B607F0","f32","",0x4), + 0x80B60770:("D_80B60770","Vec3f","",0xC), + 0x80B6077C:("D_80B6077C","Vec3f","",0xC), + 0x80B60788:("D_80B60788","Vec3f","[8]",0x60), + 0x80B607E8:("D_80B607E8","Vec3f","[8]",0x60), 0x80B60848:("D_80B60848","UNK_TYPE1","",0x1), 0x80B60858:("D_80B60858","UNK_TYPE1","",0x1), 0x80B60878:("D_80B60878","UNK_TYPE4","",0x4), @@ -15690,10 +15670,10 @@ 0x80BB97D0:("D_80BB97D0","f32","",0x4), 0x80BB97D4:("D_80BB97D4","f32","",0x4), 0x80BBAB10:("Obj_Chan_InitVars","UNK_TYPE1","",0x1), - 0x80BBAB30:("D_80BBAB30","UNK_TYPE1","",0x1), - 0x80BBAB5C:("D_80BBAB5C","UNK_TYPE1","",0x1), - 0x80BBAB60:("D_80BBAB60","UNK_TYPE4","",0x4), - 0x80BBAB78:("D_80BBAB78","f32","",0x4), + 0x80BBAB30:("sObjChanCylinderInit","UNK_TYPE1","",0x1), + 0x80BBAB5C:("sObjChanInitChain","UNK_TYPE1","",0x1), + 0x80BBAB60:("sObjChanFlameSize","UNK_TYPE4","",0x4), + 0x80BBAB78:("sObjChanFlameYOffset","f32","",0x4), 0x80BBAB80:("D_80BBAB80","f32","",0x4), 0x80BBAB84:("D_80BBAB84","f32","",0x4), 0x80BBAB88:("D_80BBAB88","f32","",0x4), @@ -15704,7 +15684,7 @@ 0x80BBAB9C:("D_80BBAB9C","f32","",0x4), 0x80BBABA0:("D_80BBABA0","f32","",0x4), 0x80BBABA4:("D_80BBABA4","f32","",0x4), - 0x80BBAC90:("D_80BBAC90","UNK_TYPE1","",0x1), + 0x80BBAC90:("sObjChanLoaded","UNK_TYPE1","",0x1), 0x80BBC6D0:("En_Zos_InitVars","UNK_TYPE1","",0x1), 0x80BBC6F0:("D_80BBC6F0","UNK_TYPE1","",0x1), 0x80BBC71C:("D_80BBC71C","UNK_TYPE1","",0x1), @@ -15770,8 +15750,8 @@ 0x80BC4668:("D_80BC4668","UNK_TYPE1","",0x1), 0x80BC4680:("jtbl_80BC4680","UNK_PTR","",0x4), 0x80BC4DD0:("Bg_F40_Switch_InitVars","UNK_TYPE1","",0x1), - 0x80BC4DF0:("D_80BC4DF0","UNK_TYPE4","",0x4), - 0x80BC4DF4:("D_80BC4DF4","UNK_TYPE4","",0x4), + 0x80BC4DF0:("sBgF40SwitchGlobalsInitialized","s32","",0x4), + 0x80BC4DF4:("sBgF40SwitchGlobalFlags","BgF40SwitchGlobalFlags","",0x10), 0x80BC4E04:("D_80BC4E04","UNK_TYPE1","",0x1), 0x80BC4E20:("D_80BC4E20","f32","",0x4), 0x80BC4E24:("D_80BC4E24","f32","",0x4), @@ -15780,7 +15760,7 @@ 0x80BC4E30:("D_80BC4E30","f32","",0x4), 0x80BC4E34:("D_80BC4E34","f32","",0x4), 0x80BC4E38:("D_80BC4E38","f32","",0x4), - 0x80BC4F20:("D_80BC4F20","UNK_TYPE1","",0x1), + 0x80BC4F20:("sBgF40SwitchLastUpdateFrame","u32","",0x4), 0x80BC6760:("En_Po_Composer_InitVars","UNK_TYPE1","",0x1), 0x80BC6780:("D_80BC6780","UNK_TYPE1","",0x1), 0x80BC67AC:("D_80BC67AC","UNK_TYPE1","",0x1), @@ -16146,9 +16126,9 @@ 0x80BE6150:("En_Tanron6_InitVars","UNK_TYPE1","",0x1), 0x80BE6170:("D_80BE6170","UNK_TYPE1","",0x1), 0x80BE78D0:("En_Daiku2_InitVars","UNK_TYPE1","",0x1), - 0x80BE78F0:("sTextIds","UNK_TYPE1","",0x1), + 0x80BE78F0:("sTextIds","s16","",0x1), 0x80BE7900:("D_80BE7900","UNK_TYPE1","",0x1), - 0x80BE792C:("sAnimations","UNK_TYPE1","",0x1), + 0x80BE792C:("sAnimations","AnimationHeader*","",0x1), 0x80BE7958:("D_80BE7958","UNK_TYPE1","",0x1), 0x80BE7970:("D_80BE7970","f32","",0x4), 0x80BE7974:("D_80BE7974","f32","",0x4), @@ -16415,13 +16395,13 @@ 0x80C0482C:("D_80C0482C","UNK_TYPE1","",0x1), 0x80C04838:("D_80C04838","UNK_TYPE1","",0x1), 0x80C05880:("En_Bombers2_InitVars","UNK_TYPE1","",0x1), - 0x80C058A0:("D_80C058A0","UNK_TYPE1","",0x1), - 0x80C058B0:("D_80C058B0","UNK_TYPE1","",0x1), - 0x80C058DC:("D_80C058DC","UNK_TYPE1","",0x1), - 0x80C058F8:("D_80C058F8","UNK_TYPE1","",0x1), - 0x80C05900:("D_80C05900","UNK_TYPE1","",0x1), - 0x80C05910:("D_80C05910","UNK_PTR","",0x4), - 0x80C05914:("D_80C05914","UNK_TYPE1","",0x1), + 0x80C058A0:("sTextIds","u16","",0x1), + 0x80C058B0:("sCylinderInit","UNK_TYPE1","",0x1), + 0x80C058DC:("sAnimations","AnimationHeader*","",0x1), + 0x80C058F8:("sAnimModes","u8","",0x1), + 0x80C05900:("sSetPrimColorDL","UNK_TYPE1","",0x1), + 0x80C05910:("sSetPrimColorDlPtr","Gfx*","",0x4), + 0x80C05914:("sEyeTextures","void*","",0x1), 0x80C05920:("D_80C05920","UNK_TYPE4","",0x4), 0x80C05930:("jtbl_80C05930","UNK_PTR","",0x4), 0x80C06440:("En_Bombal_InitVars","UNK_TYPE1","",0x1), diff --git a/tools/actorfixer.py b/tools/namefixer.py similarity index 70% rename from tools/actorfixer.py rename to tools/namefixer.py index 0d50455010..db7d97e822 100755 --- a/tools/actorfixer.py +++ b/tools/namefixer.py @@ -1,12 +1,24 @@ #!/usr/bin/env python3 -import argparse, os +import os +import argparse -# There are a few commented out entries that would produce unexpected renames. -# They are left as a comment so people can just grab them. +# all occurrences of keys will be replaced by associated value +simpleReplace = { + # "Math_Rand_":"Rand_", + # "ACTORTYPE":"ACTORCAT", + # "DistToLink":"DistToPlayer", + # "HitItem":"HitInfo", +} -# "old": "new" -animdict = { +# all occurrences of keys will be replaced by associated value, +# if the occurence is the whole word +# for example, if there is a space before and an open parenthesis after, +# like for a function call: ` func_8002E4B4(` +# +# Custom behaviour can be enabled by using a tuple as the value (see +# explanation in replace_single below) +wordReplace = { "Actor_GetSwitchFlag": "Flags_GetSwitch", "atan_flip": "Math_Acot2F", "atans": "Math_Atan2S", @@ -88,25 +100,25 @@ animdict = { "func_801A89A8": "Audio_QueueSeqCmd", "func_8019F1C0": "Audio_PlaySfxAtPos", "func_801A72CC": "Audio_StopSfxByPos", - "SkelAnime_LodDrawLimb(": "SkelAnime_DrawLimbLod(", - "SkelAnime_LodDraw(": "SkelAnime_DrawLod(", - "SkelAnime_LodDrawLimbSV(": "SkelAnime_DrawFlexLimbLod(", - "SkelAnime_LodDrawSV(": "SkelAnime_DrawFlexLod(", - #"SkelAnime_DrawLimb(": "SkelAnime_DrawLimbOpa(", - #"SkelAnime_Draw(": "SkelAnime_DrawOpa(", - "SkelAnime_DrawLimbSV(": "SkelAnime_DrawFlexLimbOpa(", - "SkelAnime_DrawSV(": "SkelAnime_DrawFlexOpa(", - #"SkelAnime_AnimateFrame(": "SkelAnime_GetFrameData(", - "SkelAnime_GetTotalFrames(": "Animation_GetLength(", - "SkelAnime_GetFrameCount(": "Animation_GetLastFrame(", - "SkelAnime_Draw2Limb(": "SkelAnime_DrawLimb(", - "SkelAnime_Draw2(": "SkelAnime_Draw(", - "SkelAnime_DrawLimbSV2(": "SkelAnime_DrawFlexLimb(", - "SkelAnime_DrawSV2(": "SkelAnime_DrawFlex(", + "SkelAnime_LodDrawLimb": "SkelAnime_DrawLimbLod", + "SkelAnime_LodDraw": "SkelAnime_DrawLod", + "SkelAnime_LodDrawLimbSV": "SkelAnime_DrawFlexLimbLod", + "SkelAnime_LodDrawSV": "SkelAnime_DrawFlexLod", + # "SkelAnime_DrawLimb": "SkelAnime_DrawLimbOpa", # A different function is called this now + # "SkelAnime_Draw": "SkelAnime_DrawOpa", # A different function is called this now + "SkelAnime_DrawLimbSV": "SkelAnime_DrawFlexLimbOpa", + "SkelAnime_DrawSV": "SkelAnime_DrawFlexOpa", + # "SkelAnime_AnimateFrame": "SkelAnime_GetFrameData", # A different function is called this now + "SkelAnime_GetTotalFrames": "Animation_GetLength", + "SkelAnime_GetFrameCount": "Animation_GetLastFrame", + "SkelAnime_Draw2Limb": "SkelAnime_DrawLimb", + "SkelAnime_Draw2": "SkelAnime_Draw", + "SkelAnime_DrawLimbSV2": "SkelAnime_DrawFlexLimb", + "SkelAnime_DrawSV2": "SkelAnime_DrawFlex", "func_80134FFC": "SkelAnime_GetFrameData2", "func_801353D4": "Animation_GetLimbCount2", - "SkelAnime_GetTotalFrames2(": "Animation_GetLength2(", - "SkelAnime_GetFrameCount2(": "Animation_GetLastFrame2(", + "SkelAnime_GetTotalFrames2": "Animation_GetLength2", + "SkelAnime_GetFrameCount2": "Animation_GetLastFrame2", "SkelAnime_InterpolateVec3s": "SkelAnime_InterpFrameTable", "SkelAnime_AnimationCtxReset": "AnimationContext_Reset", "func_801358D4": "AnimationContext_SetNextQueue", @@ -125,7 +137,7 @@ animdict = { "SkelAnime_AnimationType4Loaded": "AnimationContext_CopyFalse", "SkelAnime_AnimationType5Loaded": "AnimationContext_MoveActor", "func_80135EE8": "AnimationContext_Update", - "SkelAnime_InitLinkAnimetion(": "SkelAnime_InitLink(", + "SkelAnime_InitLinkAnimetion": "SkelAnime_InitLink", "func_801360A8": "LinkAnimation_SetUpdateFunction", "func_801360E0": "LinkAnimation_Update", "func_80136104": "LinkAnimation_Morph", @@ -158,7 +170,7 @@ animdict = { "func_801370B0": "SkelAnime_LoopPartial", "func_8013713C": "SkelAnime_Once", "SkelAnime_ChangeAnimImpl": "Animation_ChangeImpl", - "SkelAnime_ChangeAnim(": "Animation_Change(", + "SkelAnime_ChangeAnim": "Animation_Change", "SkelAnime_ChangeAnimDefaultStop": "Animation_PlayOnce", "SkelAnime_ChangeAnimTransitionStop": "Animation_MorphToPlayOnce", "SkelAnime_ChangeAnimPlaybackStop": "Animation_PlayOnceSetSpeed", @@ -188,12 +200,12 @@ animdict = { "Actor_SetChestFlag": "Flags_SetTreasure", "Actor_SetAllChestFlag": "Flags_SetAllTreasure", "Actor_GetAllChestFlag": "Flags_GetAllTreasure", - "Actor_GetRoomCleared(": "Flags_GetClear(", - "Actor_SetRoomCleared(": "Flags_SetClear(", - "Actor_UnsetRoomCleared(": "Flags_UnsetClear(", - "Actor_GetRoomClearedTemp(": "Flags_GetClearTemp(", - "Actor_SetRoomClearedTemp(": "Flags_SetClearTemp(", - "Actor_UnsetRoomClearedTemp(": "Flags_UnsetTempClear(", + "Actor_GetRoomCleared": "Flags_GetClear", + "Actor_SetRoomCleared": "Flags_SetClear", + "Actor_UnsetRoomCleared": "Flags_UnsetClear", + "Actor_GetRoomClearedTemp": "Flags_GetClearTemp", + "Actor_SetRoomClearedTemp": "Flags_SetClearTemp", + "Actor_UnsetRoomClearedTemp": "Flags_UnsetTempClear", "Actor_GetCollectibleFlag": "Flags_GetCollectible", "Actor_SetCollectibleFlag": "Flags_SetCollectible", "func_800B8A1C": "Actor_PickUp", @@ -214,7 +226,7 @@ animdict = { "Actor_TitleCardCreate": "TitleCard_InitBossName", "func_800B867C": "Actor_TextboxIsClosing", "func_800BDC5C": "Actor_ChangeAnimationByInfo", - "Actor_ChangeAnimation(": "Actor_ChangeAnimationByInfo(", + "Actor_ChangeAnimation": "Actor_ChangeAnimationByInfo", "func_80152498": "Message_GetState", "func_800B8898": "Actor_GetScreenPos", "Audio_PlayActorSound2": "Actor_PlaySfxAtPos", @@ -222,8 +234,8 @@ animdict = { "Actor_IsFacingPlayerAndWithinRange": "Actor_IsFacingAndNearPlayer", "func_800BC8B8": "Actor_DrawDoorLock", "func_800B86C8": "Actor_ChangeFocus", - "zelda_malloc(": "ZeldaArena_Malloc(", - "zelda_mallocR(": "ZeldaArena_MallocR(", + "zelda_malloc": "ZeldaArena_Malloc", + "zelda_mallocR": "ZeldaArena_MallocR", "zelda_realloc": "ZeldaArena_Realloc", "zelda_free": "ZeldaArena_Free", "zelda_calloc": "ZeldaArena_Calloc", @@ -232,9 +244,11 @@ animdict = { "MainHeap_Init": "ZeldaArena_Init", "MainHeap_Cleanup": "ZeldaArena_Cleanup", "MainHeap_IsInitialized": "ZeldaArena_IsInitialized", - # "BgCheck_RelocateMeshHeader": "CollisionHeader_GetVirtual", - # "BgCheck_AddActorMesh": "DynaPoly_SetBgActor", - # "BgCheck_RemoveActorMesh": "DynaPoly_DeleteBgActor", + "func_80138300": "Skin_GetLimbPos", + "func_8013835C": "Skin_GetVertexPos", + "BgCheck_RelocateMeshHeader": "CollisionHeader_GetVirtual", + "BgCheck_AddActorMesh": "DynaPoly_SetBgActor", + "BgCheck_RemoveActorMesh": "DynaPoly_DeleteBgActor", "BgCheck_PolygonLinkedListNodeInit": "SSNode_SetValue", "BgCheck_PolygonLinkedListResetHead": "SSList_SetNull", "BgCheck_ScenePolygonListsNodeInsert": "SSNodeList_SetSSListHead", @@ -263,7 +277,7 @@ animdict = { "BgCheck_GetIsDefaultSpecialScene": "BgCheck_IsSmallMemScene", "BgCheck_GetSpecialSceneMaxMemory": "BgCheck_TryGetCustomMemsize", "BgCheck_CalcSubdivisionSize": "BgCheck_SetSubdivisionDimension", - "BgCheck_Init(": "BgCheck_Allocate(", + "BgCheck_Init": "BgCheck_Allocate", "func_800C3C00": "BgCheck_SetContextFlags", "func_800C3C14": "BgCheck_UnsetContextFlags", "BgCheck_GetActorMeshHeader": "BgCheck_GetCollisionHeader", @@ -377,7 +391,7 @@ animdict = { "func_8017CEF0": "Math3D_TriChkPointParaZIntersect", "func_8017D020": "Math3D_TriChkLineSegParaZIntersect", "Math3D_ColSphereLineSeg": "Math3D_LineVsSph", - "Math3D_ColSphereSphere(": "Math3D_SphVsSph(", + "Math3D_ColSphereSphere": "Math3D_SphVsSph", "func_8017F9C0": "Math3D_XZInSphere", "func_8017FA34": "Math3D_XYInSphere", "func_8017FAA8": "Math3D_YZInSphere", @@ -401,6 +415,12 @@ animdict = { "func_80169BC4": "Play_CameraGetUID", "func_80169C64": "Play_GetCsCamDataSetting", "func_80169C84": "Play_GetCsCamDataVec3s", + "convert_scene_number_among_shared_scenes": "Play_GetOriginalSceneNumber", + "func_80169D40": "Play_SaveCycleSceneFlags", + "func_80169DCC": "Play_SetRespawnData", + "func_80169E6C": "Play_SetupRespawnPoint", + "func_8016A0AC": "Play_IsUnderwater", + "func_801690CC": "Play_InCsMode", "func_8017D2FC": "Math3D_LineSegVsPlane", "func_8013A7C0": "SubS_FindDoor", "func_8013E640": "SubS_FindActorCustom", @@ -409,14 +429,8 @@ animdict = { "func_800A81F0": "EffectBlure_AddVertex", "func_800A8514": "EffectBlure_AddSpace", "Effect_GetParams": "Effect_GetByIndex", - "convert_scene_number_among_shared_scenes": "Play_GetOriginalSceneNumber", - "func_80169D40": "Play_SaveCycleSceneFlags", - "func_80169DCC": "Play_SetRespawnData", - "func_80169E6C": "Play_SetupRespawnPoint", - "func_8016A0AC": "Play_IsUnderwater", "func_800F5A8C": "Environment_LerpWeight", "func_801A3F54": "Audio_SetCutsceneFlag", - "func_801518B0": "Message_StartTextbox", "func_800EA0D4": "Cutscene_Start", "func_800EA0EC": "Cutscene_End", "func_800EDE34": "Cutscene_ActorTranslate", @@ -437,6 +451,10 @@ animdict = { "func_80114E90": "Interface_HasEmptyBottle", "func_80114F2C": "Interface_HasItemInBottle", "func_80123C90": "Player_SetEquipmentData", + "Quake2_ClearType": "Distortion_ClearType", + "Quake2_SetType": "Distortion_SetType", + "Quake2_SetCountdown": "Distortion_SetCountdown", + "func_800BE680": "Actor_DrawDamageEffects", "func_8013E2D4": "SubS_StartActorCutscene", "func_8013E3B8": "SubS_FillCutscenesList", "func_8013AED4": "SubS_UpdateFlags", @@ -444,8 +462,41 @@ animdict = { "func_8013D924": "SubS_GetObjectIndex", "func_8013D5E8": "SubS_AngleDiffLessEqual", "func_8012F22C": "Inventory_GetSkullTokenCount", + "func_8013DCE0": "SubS_ActorPathing_Init", + "func_8013DE04": "SubS_ActorPathing_Update", + "func_8013DF3C": "SubS_ActorPathing_ComputePointInfo", + "func_8013E054": "SubS_ActorPathing_MoveWithGravity", + "func_8013E07C": "SubS_ActorPathing_MoveWithoutGravityReverse", + "func_8013E0A4": "SubS_ActorPathing_SetNextPoint", + "func_8013BB34": "SubS_GetAdditionalPath", + "func_8013BD40": "SubS_HasReachedPoint", + "func_8013BEDC": "SubS_GetDayDependentPath", + "func_8013C8B8": "SubS_CopyPointFromPathCheckBounds", + "func_8013D648": "SubS_GetPathByIndex", + "func_8013D68C": "SubS_CopyPointFromPath", + "func_8013D720": "SubS_GetDistSqAndOrientPoints", + "func_8013D768": "SubS_MoveActorToPoint", + "func_8013D83C": "SubS_GetDistSqAndOrientPath", + "func_8013DB90": "SubS_IsFloorAbove", + "func_8013DC40": "SubS_CopyPointFromPathList", + "func_8013DCCC": "SubS_GetPathCount", - # Structs members + "func_80147624": "Message_ShouldAdvance", + "func_80147734": "Message_ShouldAdvanceSilent", + "func_80149EBC": "Message_FindMessage", + "func_8014CC14": "Message_LoadChar", + "func_801518B0": "Message_StartTextbox", + "func_801588D0": "Message_FindMessageNES", + "func_80158988": "Message_LoadCharNES", + "func_80158A24": "Message_LoadPluralRupeesNES", + "func_80158C04": "Message_LoadLocalizedRupeesNES", + "func_80158D98": "Message_LoadRupeesNES", + "func_80158FB0": "Message_LoadTimeNES", + "func_8015926C": "Message_LoadAreaTextNES", + "func_8015E750": "Message_FindCreditsMessage", + "func_80133038": "Schedule_RunScript", + + # Struct members "skelAnime.unk03": "skelAnime.taper", "skelAnime.animCurrentSeg": "skelAnime.animation", "skelAnime.initialFrame": "skelAnime.startFrame", @@ -466,16 +517,36 @@ animdict = { "actor.minVelocityY": "actor.terminalVelocity", "actor.yDistToWater": "actor.depthInWater", "actor.yDistToPlayer": "actor.playerHeightRel", - "globalCtx->mf_187FC": "globalCtx->billboardMtxF", - "globalCtx->projectionMatrix": "globalCtx->viewProjectionMtxF", - "csCtx.npcActions": "csCtx.actorActions", - "csCtx->npcActions": "csCtx->actorActions", - "csCtx.unk_12": "csCtx.currentCsIndex", - "globalCtx->envCtx.unk_8C": "globalCtx->envCtx.lightSettings", - "globalCtx->envCtx.unk_E5": "globalCtx->envCtx.fillScreen", - "globalCtx->envCtx.unk_E6": "globalCtx->envCtx.screenFillColor", - "globalCtx->envCtx.unk_C3": "globalCtx->envCtx.lightSettingOverride", - "globalCtx->envCtx.unk_DC": "globalCtx->envCtx.lightBlend", + + "gSaveContext.weekEventReg": "gSaveContext.save.weekEventReg", + "gSaveContext.playerForm": "gSaveContext.save.playerForm", + "gSaveContext.day": "gSaveContext.save.day", + "gSaveContext.isNight": "gSaveContext.save.isNight", + "gSaveContext.naviTimer": "gSaveContext.save.playerData.tatlTimer", + "gSaveContext.tatlTimer": "gSaveContext.save.playerData.tatlTimer", + "gSaveContext.rupees": "gSaveContext.save.playerData.rupees", + "gSaveContext.magicAcquired": "gSaveContext.save.playerData.magicAcquired", + "gSaveContext.doubleMagic": "gSaveContext.save.playerData.doubleMagic", + "gSaveContext.doubleDefense": "gSaveContext.save.playerData.doubleDefense", + "gSaveContext.playerName": "gSaveContext.save.playerData.playerName", + "gSaveContext.inventory": "gSaveContext.save.inventory", + "gSaveContext.equippedMask": "gSaveContext.save.equippedMask", + "gSaveContext.entranceIndex": "gSaveContext.save.entranceIndex", + "gSaveContext.time": "gSaveContext.save.time", + "gSaveContext.unk_14": "gSaveContext.save.daySpeed", + "gSaveContext.unk_FE6": "gSaveContext.save.bombersCaughtNum", + "gSaveContext.unk_FE7": "gSaveContext.save.bombersCaughtOrder", + "gSaveContext.linkAge": "gSaveContext.save.linkAge", + "gSaveContext.dekuPlaygroundHighScores": "gSaveContext.save.dekuPlaygroundHighScores", + "gSaveContext.lotteryCodeGuess": "gSaveContext.save.lotteryCodeGuess", + "gSaveContext.permanentSceneFlags": "gSaveContext.save.permanentSceneFlags", + "gSaveContext.bomberCode": "gSaveContext.save.bomberCode", + "gSaveContext.skullTokenCount": "gSaveContext.save.skullTokenCount", + "gSaveContext.cutscene": "gSaveContext.save.cutscene", + "gSaveContext.health": "gSaveContext.save.playerData.health", + "gSaveContext.unk_1016": "gSaveContext.jinxTimer", + "gSaveContext.unk_3F58": "gSaveContext.sunsSongState", + "player->unk_A87": "player->exchangeItemId", "player->leftHandActor": "player->heldActor", "player->unk_384": "player->getItemId", @@ -483,11 +554,22 @@ animdict = { "player->unk_388": "player->interactRangeActor", "player->unk_38C": "player->mountSide", "player->unk_394": "player->csMode", + "csCtx.npcActions": "csCtx.actorActions", + "csCtx->npcActions": "csCtx->actorActions", + "csCtx.unk_12": "csCtx.currentCsIndex", + "globalCtx->mf_187FC": "globalCtx->billboardMtxF", + "globalCtx->projectionMatrix": "globalCtx->viewProjectionMtxF", "globalCtx->actorCtx.actorList[": "globalCtx->actorCtx.actorLists[", - "gSaveContext.unk_3F58": "gSaveContext.sunsSongState", + "globalCtx->envCtx.unk_8C": "globalCtx->envCtx.lightSettings", + "globalCtx->envCtx.unk_E5": "globalCtx->envCtx.fillScreen", + "globalCtx->envCtx.unk_E6": "globalCtx->envCtx.screenFillColor", + "globalCtx->envCtx.unk_C3": "globalCtx->envCtx.lightSettingOverride", + "globalCtx->envCtx.unk_DC": "globalCtx->envCtx.lightBlend", + "globalCtx->msgCtx.unk1202A": "globalCtx->msgCtx.ocarinaMode", "globalCtx->msgCtx.unk1202C": "globalCtx->msgCtx.ocarinaAction", "globalCtx->msgCtx.unk11F22": "globalCtx->msgCtx.msgMode", + "globalCtx->msgCtx.unk11F04": "globalCtx->msgCtx.currentTextId", "D_801D15B0" : "gZeroVec3f", "D_801D15BC" : "gZeroVec3s", @@ -502,67 +584,112 @@ animdict = { "ActorAnimationEntryS": "AnimationInfoS", "struct_80B8E1A8": "AnimationSpeedInfo", + # Macros + "CUR_EQUIP_VALUE_VOID": "GET_CUR_EQUIP_VALUE", + "CUR_UPG_VALUE_VOID": "GET_CUR_UPG_VALUE", "ICHAIN_F32_DIV1000(minVelocityY,": "ICHAIN_F32_DIV1000(terminalVelocity,", "ICHAIN_F32(minVelocityY,": "ICHAIN_F32(terminalVelocity,", + + # Example of custom behaviour: + # "PLAYER": ("GET_PLAYER(globalCtx)", {"ignore": (-1, '"PLAYER"')}), # ignore "PLAYER" in sSoundBankNames } -def replace_anim(file): - with open(file, 'r', encoding='utf-8') as infile: +# [a-zA-Z0-9_] +def is_word_char(c): + return (c >= 'a' and c <= 'z') or (c >= 'A' and c <= 'Z') or (c >= '0' and c <= '9') or c == '_' + +def replace_single(file): + with open(file, 'r', encoding = 'utf-8') as infile: srcdata = infile.read() - funcs = list(animdict.keys()) - fixes = 0 - for func in funcs: - newfunc = animdict.get(func) - if(newfunc is None): - print("How did this happen?") - return -1 - if(func in srcdata): - fixes += 1 - print(func) - srcdata = srcdata.replace(func, newfunc) + changesCount = 0 - if(fixes > 0): - print('Changed', fixes,'entr' + ('y' if fixes == 1 else 'ies') + ' in',file) + for old, new in simpleReplace.items(): + # replace `old` with `new` + if old in srcdata: + changesCount += 1 + print(old, "->", new) + srcdata = srcdata.replace(old, new) + + for old, new in wordReplace.items(): + # `new` can be a tuple where the first element is what to replace `old` with, + # and the second element is a dict containing "custom behavior" properties. + if isinstance(new, tuple): + custom_behavior = True + new, custom_behavior_data = new + # The "ignore" data is a tuple where the first element is an offset relative to + # where `old` was found, and the string from that index must differ from the + # tuple's second element for the replacement to be done. + custom_behavior_ignore_data = custom_behavior_data.get("ignore") + custom_behavior_ignore = custom_behavior_ignore_data is not None + if custom_behavior_ignore: + custom_behavior_ignore_offset, custom_behavior_ignore_match = custom_behavior_ignore_data + else: + custom_behavior = False + # replace `old` with `new` if the occurence of `old` is the whole word + oldStartIdx = srcdata.find(old) + if oldStartIdx >= 0: + old_start_as_word = is_word_char(old[0]) + old_end_as_word = is_word_char(old[-1]) + replaceCount = 0 + while oldStartIdx >= 0: + replace = True + if old_start_as_word: + if oldStartIdx == 0: + pass + elif is_word_char(srcdata[oldStartIdx-1]): + replace = False + if old_end_as_word: + oldEndIdx = oldStartIdx + len(old) + if oldEndIdx >= len(srcdata): + pass + elif is_word_char(srcdata[oldEndIdx]): + replace = False + if replace and custom_behavior and custom_behavior_ignore: + if srcdata[oldStartIdx + custom_behavior_ignore_offset:].startswith(custom_behavior_ignore_match): + replace = False + if replace: + srcdata = srcdata[:oldStartIdx] + new + srcdata[oldEndIdx:] + replaceCount += 1 + oldStartIdx = srcdata.find(old, oldStartIdx + len(new)) + if replaceCount > 0: + changesCount += 1 + print(old, "->", new) + + if changesCount > 0: + print('Changed', changesCount, 'entry' if changesCount == 1 else 'entries', 'in', file) with open(file, 'w', encoding = 'utf-8', newline = '\n') as outfile: outfile.write(srcdata) - return 1 -def replace_anim_all(repo): - for subdir, dirs, files in os.walk(repo + os.sep + 'src'): +def replace_all(repo): + for subdir, dirs, files in os.walk(os.path.join(repo,'src')): for filename in files: - if(filename.endswith('.c')): - file = subdir + os.sep + filename - replace_anim(file) + if filename.endswith('.c') or filename.endswith('.h'): + file = os.path.join(subdir,filename) + replace_single(file) - for subdir, dirs, files in os.walk(repo + os.sep + 'asm'): + for subdir, dirs, files in os.walk(os.path.join(repo,'asm')): for filename in files: - if(filename.endswith('.s')): - file = subdir + os.sep + filename - replace_anim(file) + if filename.endswith('.s'): + file = os.path.join(subdir,filename) + replace_single(file) - for subdir, dirs, files in os.walk(repo + os.sep + 'data'): + for subdir, dirs, files in os.walk(os.path.join(repo,'data')): for filename in files: - if(filename.endswith('.s')): - file = subdir + os.sep + filename - replace_anim(file) + if filename.endswith('.s'): + file = os.path.join(subdir,filename) + replace_single(file) - for subdir, dirs, files in os.walk(repo + os.sep + 'docs'): + for subdir, dirs, files in os.walk(os.path.join(repo,'docs')): for filename in files: - if(filename.endswith('.md')): - file = subdir + os.sep + filename - replace_anim(file) + if filename.endswith('.md'): + file = os.path.join(subdir,filename) + replace_single(file) - for subdir, dirs, files in os.walk(repo + os.sep + 'tools' + os.sep + 'sizes'): - for filename in files: - if(filename.endswith('.csv')): - file = subdir + os.sep + filename - replace_anim(file) - return 1 def dictSanityCheck(): - keys = animdict.keys() - values = animdict.values() + keys = wordReplace.keys() + values = wordReplace.values() for k in keys: if k in values: print(f"Key '{k}' found in values") @@ -570,15 +697,27 @@ def dictSanityCheck(): print(f"Fix this by removing said key from the dictionary") exit(-1) -if __name__ == "__main__": - parser = argparse.ArgumentParser(description='Update to the new animation names') - parser.add_argument('file', help="source file to be processed. use . to process the whole repo", default = None) + keys = simpleReplace.keys() + values = {*wordReplace.values(), *simpleReplace.values()} + for k in keys: + for value in values: + if k in value: + print(f"Key '{k}' found in values") + print(f"This would produce unintended renames") + print(f"Fix this by removing said key from the dictionary") + exit(-1) +def main(): + parser = argparse.ArgumentParser(description='Apply function renames to a file') + parser.add_argument('file', help="source file to be processed. use . to process the whole repo") args = parser.parse_args() dictSanityCheck() - if(args.file == '.'): - replace_anim_all(os.curdir) + if args.file == '.': + replace_all(os.curdir) else: - replace_anim(args.file) + replace_single(args.file) + +if __name__ == "__main__": + main() diff --git a/tools/overlayhelpers/scheduledis.py b/tools/overlayhelpers/scheduledis.py new file mode 100755 index 0000000000..b441b94c7e --- /dev/null +++ b/tools/overlayhelpers/scheduledis.py @@ -0,0 +1,264 @@ +#!/usr/bin/env python3 +# +# MM Event Script Disassembler +# + +import argparse, os, struct, math +from actor_symbols import resolve_symbol + +cmd_info = [ + ('SCHEDULE_CMD_CHECK_FLAG_S', 0x04, '>BBb', (2, )), + ('SCHEDULE_CMD_CHECK_FLAG_L', 0x05, '>BBh', (2, )), + ('SCHEDULE_CMD_CHECK_TIME_RANGE_S', 0x06, '>BBBBb', (4, )), + ('SCHEDULE_CMD_CHECK_TIME_RANGE_L', 0x07, '>BBBBh', (4, )), + ('SCHEDULE_CMD_RET_VAL_L', 0x03, '>H', ( )), + ('SCHEDULE_CMD_RET_NONE', 0x01, '', ( )), + ('SCHEDULE_CMD_RET_EMPTY', 0x01, '', ( )), + ('SCHEDULE_CMD_NOP', 0x04, '>BBB', ( )), + ('SCHEDULE_CMD_CHECK_MISC_S', 0x03, '>Bb', (1, )), + ('SCHEDULE_CMD_RET_VAL_S', 0x02, '>B', ( )), + ('SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S', 0x04, '>Hb', (1, )), + ('SCHEDULE_CMD_CHECK_NOT_IN_SCENE_L', 0x05, '>Hh', (1, )), + ('SCHEDULE_CMD_CHECK_NOT_IN_DAY_S', 0x04, '>Hb', (1, )), + ('SCHEDULE_CMD_CHECK_NOT_IN_DAY_L', 0x05, '>Hh', (1, )), + ('SCHEDULE_CMD_RET_TIME', 0x06, '>BBBBB', ( )), + ('SCHEDULE_CMD_CHECK_BEFORE_TIME_S', 0x04, '>BBb', (2, )), + ('SCHEDULE_CMD_CHECK_BEFORE_TIME_L', 0x05, '>BBh', (2, )), + ('SCHEDULE_CMD_BRANCH_S', 0x02, '>b', (0, )), + ('SCHEDULE_CMD_BRANCH_L', 0x03, '>h', (0, )), +] + +scene_names = [ + 'SCENE_20SICHITAI2', + 'SCENE_UNSET_1', + 'SCENE_UNSET_2', + 'SCENE_UNSET_3', + 'SCENE_UNSET_4', + 'SCENE_UNSET_5', + 'SCENE_UNSET_6', + 'SCENE_KAKUSIANA', + 'SCENE_SPOT00', + 'SCENE_UNSET_9', + 'SCENE_WITCH_SHOP', + 'SCENE_LAST_BS', + 'SCENE_HAKASHITA', + 'SCENE_AYASHIISHOP', + 'SCENE_UNSET_E', + 'SCENE_UNSET_F', + 'SCENE_OMOYA', + 'SCENE_BOWLING', + 'SCENE_SONCHONOIE', + 'SCENE_IKANA', + 'SCENE_KAIZOKU', + 'SCENE_MILK_BAR', + 'SCENE_INISIE_N', + 'SCENE_TAKARAYA', + 'SCENE_INISIE_R', + 'SCENE_OKUJOU', + 'SCENE_OPENINGDAN', + 'SCENE_MITURIN', + 'SCENE_13HUBUKINOMITI', + 'SCENE_CASTLE', + 'SCENE_DEKUTES', + 'SCENE_MITURIN_BS', + 'SCENE_SYATEKI_MIZU', + 'SCENE_HAKUGIN', + 'SCENE_ROMANYMAE', + 'SCENE_PIRATE', + 'SCENE_SYATEKI_MORI', + 'SCENE_SINKAI', + 'SCENE_YOUSEI_IZUMI', + 'SCENE_KINSTA1', + 'SCENE_KINDAN2', + 'SCENE_TENMON_DAI', + 'SCENE_LAST_DEKU', + 'SCENE_22DEKUCITY', + 'SCENE_KAJIYA', + 'SCENE_00KEIKOKU', + 'SCENE_POSTHOUSE', + 'SCENE_LABO', + 'SCENE_DANPEI2TEST', + 'SCENE_UNSET_31', + 'SCENE_16GORON_HOUSE', + 'SCENE_33ZORACITY', + 'SCENE_8ITEMSHOP', + 'SCENE_F01', + 'SCENE_INISIE_BS', + 'SCENE_30GYOSON', + 'SCENE_31MISAKI', + 'SCENE_TAKARAKUJI', + 'SCENE_UNSET_3A', + 'SCENE_TORIDE', + 'SCENE_FISHERMAN', + 'SCENE_GORONSHOP', + 'SCENE_DEKU_KING', + 'SCENE_LAST_GORON', + 'SCENE_24KEMONOMITI', + 'SCENE_F01_B', + 'SCENE_F01C', + 'SCENE_BOTI', + 'SCENE_HAKUGIN_BS', + 'SCENE_20SICHITAI', + 'SCENE_21MITURINMAE', + 'SCENE_LAST_ZORA', + 'SCENE_11GORONNOSATO2', + 'SCENE_SEA', + 'SCENE_35TAKI', + 'SCENE_REDEAD', + 'SCENE_BANDROOM', + 'SCENE_11GORONNOSATO', + 'SCENE_GORON_HAKA', + 'SCENE_SECOM', + 'SCENE_10YUKIYAMANOMURA', + 'SCENE_TOUGITES', + 'SCENE_DANPEI', + 'SCENE_IKANAMAE', + 'SCENE_DOUJOU', + 'SCENE_MUSICHOUSE', + 'SCENE_IKNINSIDE', + 'SCENE_MAP_SHOP', + 'SCENE_F40', + 'SCENE_F41', + 'SCENE_10YUKIYAMANOMURA2', + 'SCENE_14YUKIDAMANOMITI', + 'SCENE_12HAKUGINMAE', + 'SCENE_17SETUGEN', + 'SCENE_17SETUGEN2', + 'SCENE_SEA_BS', + 'SCENE_RANDOM', + 'SCENE_YADOYA', + 'SCENE_KONPEKI_ENT', + 'SCENE_INSIDETOWER', + 'SCENE_26SARUNOMORI', + 'SCENE_LOST_WOODS', + 'SCENE_LAST_LINK', + 'SCENE_SOUGEN', + 'SCENE_BOMYA', + 'SCENE_KYOJINNOMA', + 'SCENE_KOEPONARACE', + 'SCENE_GORONRACE', + 'SCENE_TOWN', + 'SCENE_ICHIBA', + 'SCENE_BACKTOWN', + 'SCENE_CLOCKTOWER', + 'SCENE_ALLEY' +] + +def read_bytes(data_file, offset, len): + data_file.seek(offset) + return bytearray(data_file.read(len)) + +def calc_length(data_file, offset): + off = 0 + cmd = None + branch_targets = [] + + # Parse script, just keeping track of branches, until we find the end + while any([branch >= off for branch in branch_targets]) or cmd not in [0x04, 0x05, 0x06, 0x09]: + cmd = read_bytes(data_file, offset + off, 1)[0] + + cmd_len = cmd_info[cmd][1] + cmd_args = cmd_info[cmd][2] + + if len(cmd_args) > 1: + arg_values = struct.unpack(cmd_args, read_bytes(data_file, offset + off + 1, cmd_len - 1)) + for i in cmd_info[cmd][3]: + branch_targets.append(off + arg_values[i] + cmd_len) + + off += cmd_len + + return off + +def disassemble_unk_script(data_file, offset): + off = 0 + cmd = None + branch_targets = [] + script_len = calc_length(data_file, offset); + script_len_num_digits = 0 if script_len == 1 else int(math.ceil(math.log(script_len - 1, 16))) + + out = "static u8 sScheduleScript[] = {\n" + + # Keep trying to disassemble until it hits a terminator and no commands branch past it + while any([branch >= off for branch in branch_targets]) or cmd not in [0x04, 0x05, 0x06, 0x09]: + cmd = read_bytes(data_file, offset + off, 1)[0] + + cmd_name = cmd_info[cmd][0] + cmd_len = cmd_info[cmd][1] + cmd_args = cmd_info[cmd][2] + + args_formatted = [] + if len(cmd_args) > 1: # handle args + arg_values = struct.unpack(cmd_args, read_bytes(data_file, offset + off + 1, cmd_len - 1)) + for i,(arg_value,arg_type) in enumerate(zip(arg_values, cmd_args[1:]),0): + arg_formatted = "" + if arg_type == "h": + arg_formatted = f"{arg_value:#x}" + elif arg_type == "b": + arg_formatted = f"{arg_value:#x}" + elif arg_type == "H": + if (cmd == 0x0A or cmd == 0x0B) and (arg_value < len(scene_names)): + arg_formatted = scene_names[arg_value] + else: + arg_formatted = f"{arg_value}" + elif arg_type == "B": + if cmd == 0x00 or cmd == 0x01: + arg_formatted = f"0x{arg_value:02X}" + elif cmd == 0x08: + if arg_value == 0: + arg_formatted = "SCHEDULE_CHECK_MISC_ROOM_KEY" + elif arg_value == 1: + arg_formatted = "SCHEDULE_CHECK_MISC_LETTER_TO_KAFEI" + elif arg_value == 2: + arg_formatted = "SCHEDULE_CHECK_MISC_MASK_ROMANI" + else: + arg_formatted = f"0x{arg_value:02X}" + else: + arg_formatted = f"{arg_value:2}" + elif arg_type == "S": + if arg_value < len(scene_names): + arg_formatted = scene_names[arg_value] + else: + arg_formatted = f"0x{arg_value:04X}" + + if i in cmd_info[cmd][3]: # skip argument indices + # add skip args to branch targets, and change the output to absolute differences rather than relative offsets + arg_value += cmd_len + branch_targets.append(off + arg_value) + if arg_value == cmd_len: + arg_formatted == "0" + else: + arg_formatted = f"0x{off + arg_value:0{script_len_num_digits}X} - 0x{off + cmd_len:0{script_len_num_digits}X}" + args_formatted.append(arg_formatted) + + args = ", ".join(args_formatted) if len(args_formatted) != 0 else "" + + out += f" /* 0x{off:0{script_len_num_digits}X} */ {cmd_name}({args}),\n" + + off += cmd_len + + out = out.strip() + out += "\n};" + + print(out) + +def hex_parse(s): + return int(s, 16) + +def main(): + parser = argparse.ArgumentParser(description="Disassembles MM event scripts") + parser.add_argument('address', help="VRAM or ROM address to disassemble at", type=hex_parse) + args = parser.parse_args() + + file_result = resolve_symbol(args.address) + + if file_result[0] is None: + print("Invalid address") + return + + print(hex(file_result[1]), "in", file_result[0].split(os.sep)[-1]) + + with open(file_result[0],"rb") as data_file: + disassemble_unk_script(data_file, file_result[1]) + +if __name__ == "__main__": + main() diff --git a/tools/permuter_settings.toml b/tools/permuter_settings.toml index eb2f1ac4b0..2676d13ee8 100644 --- a/tools/permuter_settings.toml +++ b/tools/permuter_settings.toml @@ -13,6 +13,7 @@ SQ = "int" CLAMP = "int" CLOCK_TIME = "int" CURRENT_DAY = "int" +CHECK_NEWF = "int" NULL = "int" [decompme.compilers] diff --git a/tools/reloc_spec_check.sh b/tools/reloc_spec_check.sh new file mode 100755 index 0000000000..434a49ec36 --- /dev/null +++ b/tools/reloc_spec_check.sh @@ -0,0 +1,112 @@ +#!/bin/bash + +# This script checks for overlay's relocs to be correctly used on the spec file depending on the overlay's NON_MATCHING/NON_EQUIVALENT +# and minimize possible broken NON_MATCHING builds. +# The script performs the following checks: +# - The extracted reloc isn't being used on the spec if the overlay has no other GLOBAL_ASM left (it has been matched). +# - Warn if an overlay is using both NON_MATCHING and NON_EQUIVALENT. +# - Warn if an overlay has NON_MATCHING ifdefs but some functions are still unattempted. +# - Both relocs (generated and extracted) are used on the spec on NON_MATCHING overlays. +# - The generated reloc isn't being used on NON_EQUIVALENT overlays. +# If any of those checks fails for any overlay, the script will print a warning and exit with a non-zero exit code. + +BOLD="$(tput bold)" +RED="$(tput setaf 1)" +PURPLE="$(tput setaf 5)" +WHITE="$(tput setaf 7)" +BLINK="$(tput blink)" +RST="$(tput sgr0)" + +# Run the script from the root of the project +DIR="$(dirname "$(readlink -f "$0")")" +cd "$DIR/.." + +EXIT_CODE=0 + +OVERLAYS_SUBFOLDERS="$(find src/overlays/*/* -type d)" + +while read OVL_FOLDER; do + # C files which are part of the current overlay + FILES_OF_OVERLAY="$(find "$OVL_FOLDER" -name '*.c')" + # List of files (of the current overlay) which doesn't contain GLOBAL_ASM + FILES_WITHOUT_PRAGMA="$(grep -L '#pragma GLOBAL_ASM' ${FILES_OF_OVERLAY})" + + if [ "$FILES_OF_OVERLAY" == "$FILES_WITHOUT_PRAGMA" ]; then + # This overlay is fully matched, so it should not be using the extracted reloc (use the generated one instead) + + OVL_NAME="$(cut -d '/' -f 4 <<< ${OVL_FOLDER})" + + # Parse the spec, searching for the extracted reloc of this overlay + OVL_WITH_EXTRACTED_RELOC="$(grep -F "$OVL_NAME".reloc spec)" + + if [ "$OVL_WITH_EXTRACTED_RELOC" != "" ]; then + echo "${BOLD} Matching overlay using extracted reloc on spec found: ${RED} ${OVL_FOLDER} ${RST}" + echo " Don't forget to change the extracted reloc to the generated one on the spec, otherwise the matched overlay won't be shiftable" + EXIT_CODE=1 + fi + else + # Overlay not fully matched + + # Search for files with NON_MATCHING and NON_EQUIVALENT + FILES_WITH_NON_MATCHING="$(grep -Fl '#ifdef NON_MATCHING' ${FILES_OF_OVERLAY})" + FILES_WITH_NON_EQUIVALENT="$(grep -Fl '#ifdef NON_EQUIVALENT' ${FILES_OF_OVERLAY})" + + if [ "$FILES_WITH_NON_MATCHING" != "" ] && [ "$FILES_WITH_NON_EQUIVALENT" != "" ]; then + # An overlay can't have both NON_MATCHINGs and NON_EQUIVALENTs, because relocs wouldn't be generated correctly + + echo "${BOLD} Overlay with both NON_MATCHINGs and NON_EQUIVALENTs found: ${RED} ${OVL_FOLDER} ${RST}" + echo " Overlays can't have both NON_MATCHING and NON_EQUIVALENT because it breaks NON_MATCHING builds" + echo " As an alternative you could mark NON_MATCHING functions as NON_EQUIVALENT and add a comment mentioning it is actually equivalent" + EXIT_CODE=1 + + elif [ "$FILES_WITH_NON_MATCHING" != "" ]; then + # Overlay only contains NON_MATCHINGs + + # Get the count of NON_MATCHING and GLOBAL_ASM of the current overlay + NON_MATCHINGS_COUNT_OF_OVERLAY="$(grep -F '#ifdef NON_MATCHING' ${FILES_WITH_NON_MATCHING} | wc -l)" + PRAGMAS_COUNT_OF_OVERLAY="$(grep -F '#pragma GLOBAL_ASM' ${FILES_WITH_NON_MATCHING} | wc -l)" + + if [ "$NON_MATCHINGS_COUNT_OF_OVERLAY" != "$PRAGMAS_COUNT_OF_OVERLAY" ]; then + # If an overlay uses NON_MATCHING, then every function should be either matching or marked as NON_MATCHING + + echo "${BOLD} Found an overlay with a differing number of NON_MATCHINGs and #pragma GLOBAL_ASM: ${RED} ${OVL_FOLDER} ${RST}" + echo " To use a NON_MATCHING check on an overlay, every function that does not match should verified to be equivalent" + echo " But the amount of NON_MATCHING ifdefs and GLOBAL_ASM does no match, which may suggest not every function of this overlay may have been attempted" + EXIT_CODE=1 + fi + + OVL_NAME="$(cut -d '/' -f 4 <<< ${OVL_FOLDER})" + + # Parse the spec, searching for the extracted reloc of this overlay + OVL_WITH_EXTRACTED_RELOC="$(grep -F "$OVL_NAME".reloc spec)" + + # Parse the spec, searching for the generated reloc of this overlay + OVL_WITH_GENERATED_RELOC="$(grep -F "$OVL_NAME"_reloc spec)" + + if [ "$OVL_WITH_EXTRACTED_RELOC" == "" ] || [ "$OVL_WITH_GENERATED_RELOC" == "" ]; then + # Overlays with NON_MATCHINGs should have both relocs on the spec + + echo "${BOLD} NON_MATCHING overlay missing either extracted or generated reloc on spec found: ${RED} ${OVL_FOLDER} ${RST}" + echo " Overlays with NON_MATCHING ifdefs must also add a NON_MATCHING ifdef on the spec to allow using the generated reloc on NON_MATCHING builds" + EXIT_CODE=1 + fi + elif [ "$FILES_WITH_NON_EQUIVALENT" != "" ]; then + # Overlay only contains NON_EQUIVALENTs + + OVL_NAME="$(cut -d '/' -f 4 <<< ${OVL_FOLDER})" + + # Parse the spec, searching for the generated reloc of this overlay + OVL_WITH_GENERATED_RELOC="$(grep -F "$OVL_NAME"_reloc spec)" + + if [ "$OVL_WITH_GENERATED_RELOC" != "" ]; then + # Overlays with NON_EQUIVALENTs should not use a generated reloc + + echo "${BOLD} NON_EQUIVALENT overlay with generated reloc on spec found: ${RED} ${OVL_FOLDER} ${RST}" + echo " Overlays with NON_EQUIVALENT ifdefs can't use generated relocs" + EXIT_CODE=1 + fi + fi + fi +done <<< ${OVERLAYS_SUBFOLDERS} + +exit $EXIT_CODE diff --git a/tools/sizes/boot_functions.csv b/tools/sizes/boot_functions.csv index 3685e3fa9c..6c5c92e168 100644 --- a/tools/sizes/boot_functions.csv +++ b/tools/sizes/boot_functions.csv @@ -9,8 +9,8 @@ asm/non_matchings/boot/idle/Idle_InitVideo.s,Idle_InitVideo,0x8008038C,0x62 asm/non_matchings/boot/idle/Idle_ThreadEntry.s,Idle_ThreadEntry,0x80080514,0x33 asm/non_matchings/boot/viconfig/ViConfig_UpdateVi.s,ViConfig_UpdateVi,0x800805E0,0x5A asm/non_matchings/boot/viconfig/ViConfig_UpdateBlack.s,ViConfig_UpdateBlack,0x80080748,0x12 -asm/non_matchings/boot/z_std_dma/DmaMgr_DMARomToRam.s,DmaMgr_DMARomToRam,0x80080790,0x51 -asm/non_matchings/boot/z_std_dma/DmaMgr_DmaCallback0.s,DmaMgr_DmaCallback0,0x800808D4,0x8 +asm/non_matchings/boot/z_std_dma/DmaMgr_DmaRomToRam.s,DmaMgr_DmaRomToRam,0x80080790,0x51 +asm/non_matchings/boot/z_std_dma/DmaMgr_DmaHandler.s,DmaMgr_DmaHandler,0x800808D4,0x8 asm/non_matchings/boot/z_std_dma/DmaMgr_FindDmaEntry.s,DmaMgr_FindDmaEntry,0x800808F4,0x17 asm/non_matchings/boot/z_std_dma/DmaMgr_TranslateVromToRom.s,DmaMgr_TranslateVromToRom,0x80080950,0x1B asm/non_matchings/boot/z_std_dma/DmaMgr_FindDmaIndex.s,DmaMgr_FindDmaIndex,0x800809BC,0xE @@ -155,14 +155,14 @@ asm/non_matchings/boot/mtxuty-cvt/MtxConv_L2F.s,MtxConv_L2F,0x80086258,0xA asm/non_matchings/boot/assert/__assert.s,__assert,0x80086280,0xD asm/non_matchings/boot/assert/func_800862B4.s,func_800862B4,0x800862B4,0xB asm/non_matchings/boot/boot_800862E0/SystemArena_MallocMin1.s,SystemArena_MallocMin1,0x800862E0,0xC -asm/non_matchings/boot/boot_800862E0/SystemArena_FreeNull.s,SystemArena_FreeNull,0x80086310,0xB -asm/non_matchings/boot/boot_800862E0/func_8008633C.s,func_8008633C,0x8008633C,0x1C -asm/non_matchings/boot/boot_800862E0/func_800863AC.s,func_800863AC,0x800863AC,0x1C -asm/non_matchings/boot/boot_800862E0/func_8008641C.s,func_8008641C,0x8008641C,0x34 -asm/non_matchings/boot/boot_800862E0/func_800864EC.s,func_800864EC,0x800864EC,0x27 -asm/non_matchings/boot/boot_800862E0/func_80086588.s,func_80086588,0x80086588,0x1C +asm/non_matchings/boot/boot_800862E0/SystemArena_FreeNullCheck.s,SystemArena_FreeNullCheck,0x80086310,0xB +asm/non_matchings/boot/boot_800862E0/SystemArena_RunBlockFunc.s,SystemArena_RunBlockFunc,0x8008633C,0x1C +asm/non_matchings/boot/boot_800862E0/SystemArena_RunBlockFunc1.s,SystemArena_RunBlockFunc1,0x800863AC,0x1C +asm/non_matchings/boot/boot_800862E0/SystemArena_RunBlockFunc8.s,SystemArena_RunBlockFunc8,0x8008641C,0x34 +asm/non_matchings/boot/boot_800862E0/SystemArena_RunBlockFunc1Reverse.s,SystemArena_RunBlockFunc1Reverse,0x800864EC,0x27 +asm/non_matchings/boot/boot_800862E0/SystemArena_RunInits.s,SystemArena_RunInits,0x80086588,0x1C asm/non_matchings/boot/boot_800862E0/SystemArena_Init.s,SystemArena_Init,0x800865F8,0xA -asm/non_matchings/boot/padsetup/func_80086620.s,func_80086620,0x80086620,0x50 +asm/non_matchings/boot/padsetup/PadSetup_Init.s,PadSetup_Init,0x80086620,0x50 asm/non_matchings/boot/boot_80086760/func_80086760.s,func_80086760,0x80086760,0xD asm/non_matchings/boot/boot_80086760/func_80086794.s,func_80086794,0x80086794,0x8 asm/non_matchings/boot/boot_80086760/func_800867B4.s,func_800867B4,0x800867B4,0x8 diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 109d1df8af..8452179ab7 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -381,7 +381,7 @@ asm/non_matchings/code/z_actor/Actor_SpawnShieldParticlesMetal.s,Actor_SpawnShie asm/non_matchings/code/z_actor/Actor_SetColorFilter.s,Actor_SetColorFilter,0x800BCB70,0x21 asm/non_matchings/code/z_actor/func_800BCBF4.s,func_800BCBF4,0x800BCBF4,0x1D asm/non_matchings/code/z_actor/func_800BCC68.s,func_800BCC68,0x800BCC68,0x1D -asm/non_matchings/code/z_actor/func_800BCCDC.s,func_800BCCDC,0x800BCCDC,0x176 +asm/non_matchings/code/z_actor/Actor_GetClosestPosOnPath.s,Actor_GetClosestPosOnPath,0x800BCCDC,0x176 asm/non_matchings/code/z_actor/func_800BD2B4.s,func_800BD2B4,0x800BD2B4,0x34 asm/non_matchings/code/z_actor/func_800BD384.s,func_800BD384,0x800BD384,0xCD asm/non_matchings/code/z_actor/func_800BD6B8.s,func_800BD6B8,0x800BD6B8,0xB @@ -407,7 +407,7 @@ asm/non_matchings/code/z_actor/func_800BE504.s,func_800BE504,0x800BE504,0x19 asm/non_matchings/code/z_actor/func_800BE568.s,func_800BE568,0x800BE568,0x19 asm/non_matchings/code/z_actor/func_800BE5CC.s,func_800BE5CC,0x800BE5CC,0x1C asm/non_matchings/code/z_actor/func_800BE63C.s,func_800BE63C,0x800BE63C,0x11 -asm/non_matchings/code/z_actor/func_800BE680.s,func_800BE680,0x800BE680,0x453 +asm/non_matchings/code/z_actor/Actor_DrawDamageEffects.s,Actor_DrawDamageEffects,0x800BE680,0x453 asm/non_matchings/code/z_actor/Actor_SpawnIceEffects.s,Actor_SpawnIceEffects,0x800BF7CC,0x75 asm/non_matchings/code/z_actor_dlftbls/ActorOverlayTable_FaultPrint.s,ActorOverlayTable_FaultPrint,0x800BF9A0,0x36 asm/non_matchings/code/z_actor_dlftbls/ActorOverlayTable_FaultAddrConv.s,ActorOverlayTable_FaultAddrConv,0x800BFA78,0x1C @@ -804,7 +804,7 @@ asm/non_matchings/code/z_camera/Camera_ClearFlags.s,Camera_ClearFlags,0x800DFF84 asm/non_matchings/code/z_camera/func_800DFFAC.s,func_800DFFAC,0x800DFFAC,0x34 asm/non_matchings/code/z_camera/func_800E007C.s,func_800E007C,0x800E007C,0x4C asm/non_matchings/code/z_camera/func_800E01AC.s,func_800E01AC,0x800E01AC,0x3 -asm/non_matchings/code/z_camera/func_800E01B8.s,func_800E01B8,0x800E01B8,0x9 +asm/non_matchings/code/z_camera/Camera_GetQuakeOffset.s,Camera_GetQuakeOffset,0x800E01B8,0x9 asm/non_matchings/code/z_camera/func_800E01DC.s,func_800E01DC,0x800E01DC,0x13 asm/non_matchings/code/z_camera/func_800E0228.s,func_800E0228,0x800E0228,0x4 asm/non_matchings/code/z_camera/func_800E0238.s,func_800E0238,0x800E0238,0x1D @@ -1034,7 +1034,7 @@ asm/non_matchings/code/code_800E8EA0/func_800E9138.s,func_800E9138,0x800E9138,0x asm/non_matchings/code/code_800E8EA0/func_800E9250.s,func_800E9250,0x800E9250,0x44 asm/non_matchings/code/z_common_data/func_800E9360.s,func_800E9360,0x800E9360,0x20 asm/non_matchings/code/z_debug/GameInfo_Init.s,GameInfo_Init,0x800E93E0,0x24 -asm/non_matchings/code/z_debug_display/func_800E9470.s,func_800E9470,0x800E9470,0x6 +asm/non_matchings/code/z_debug_display/DebugDisplay_Init.s,DebugDisplay_Init,0x800E9470,0x6 asm/non_matchings/code/z_debug_display/DebugDisplay_AddObject.s,DebugDisplay_AddObject,0x800E9488,0x37 asm/non_matchings/code/z_debug_display/DebugDisplay_DrawObjects.s,DebugDisplay_DrawObjects,0x800E9564,0x24 asm/non_matchings/code/z_debug_display/func_800E95F4.s,func_800E95F4,0x800E95F4,0x79 @@ -1213,7 +1213,7 @@ asm/non_matchings/code/z_jpeg/Jpeg_GetUnalignedU16.s,Jpeg_GetUnalignedU16,0x800F asm/non_matchings/code/z_jpeg/Jpeg_ParseMarkers.s,Jpeg_ParseMarkers,0x800F4540,0x73 asm/non_matchings/code/z_jpeg/Jpeg_Decode.s,Jpeg_Decode,0x800F470C,0xC1 asm/non_matchings/code/z_kaleido_setup/func_800F4A10.s,func_800F4A10,0x800F4A10,0x7F -asm/non_matchings/code/z_kaleido_setup/func_800F4C0C.s,func_800F4C0C,0x800F4C0C,0x85 +asm/non_matchings/code/z_kaleido_setup/KaleidoSetup_Update.s,KaleidoSetup_Update,0x800F4C0C,0x85 asm/non_matchings/code/z_kaleido_setup/func_800F4E20.s,func_800F4E20,0x800F4E20,0x42 asm/non_matchings/code/z_kaleido_setup/func_800F4F28.s,func_800F4F28,0x800F4F28,0x6 asm/non_matchings/code/z_kanfont/Font_LoadChar.s,Font_LoadChar,0x800F4F40,0x5 @@ -2122,23 +2122,23 @@ asm/non_matchings/code/z_skelanime/SkelAnime_UpdateTranslation.s,SkelAnime_Updat asm/non_matchings/code/z_skelanime/Animation_OnFrame.s,Animation_OnFrame,0x801378B8,0xA asm/non_matchings/code/z_skelanime/SkelAnime_Free.s,SkelAnime_Free,0x801378E0,0x13 asm/non_matchings/code/z_skelanime/SkelAnime_CopyFrameTable.s,SkelAnime_CopyFrameTable,0x8013792C,0x11 -asm/non_matchings/code/z_skin/func_80137970.s,func_80137970,0x80137970,0x71 -asm/non_matchings/code/z_skin/func_80137B34.s,func_80137B34,0x80137B34,0xE2 -asm/non_matchings/code/z_skin/func_80137EBC.s,func_80137EBC,0x80137EBC,0x27 -asm/non_matchings/code/z_skin/func_80137F58.s,func_80137F58,0x80137F58,0x3E -asm/non_matchings/code/z_skin/func_80138050.s,func_80138050,0x80138050,0x76 +asm/non_matchings/code/z_skin/Skin_UpdateVertices.s,Skin_UpdateVertices,0x80137970,0x71 +asm/non_matchings/code/z_skin/Skin_ApplyLimbModifications.s,Skin_ApplyLimbModifications,0x80137B34,0xE2 +asm/non_matchings/code/z_skin/Skin_DrawAnimatedLimb.s,Skin_DrawAnimatedLimb,0x80137EBC,0x27 +asm/non_matchings/code/z_skin/Skin_DrawLimb.s,Skin_DrawLimb,0x80137F58,0x3E +asm/non_matchings/code/z_skin/Skin_DrawImpl.s,Skin_DrawImpl,0x80138050,0x76 asm/non_matchings/code/z_skin/func_80138228.s,func_80138228,0x80138228,0xC asm/non_matchings/code/z_skin/func_80138258.s,func_80138258,0x80138258,0xD asm/non_matchings/code/z_skin/func_8013828C.s,func_8013828C,0x8013828C,0xE asm/non_matchings/code/z_skin/func_801382C4.s,func_801382C4,0x801382C4,0xF -asm/non_matchings/code/z_skin/func_80138300.s,func_80138300,0x80138300,0x17 -asm/non_matchings/code/z_skin/func_8013835C.s,func_8013835C,0x8013835C,0x2D -asm/non_matchings/code/z_skin_awb/func_80138410.s,func_80138410,0x80138410,0x5 -asm/non_matchings/code/z_skin_awb/func_80138424.s,func_80138424,0x80138424,0x5E -asm/non_matchings/code/z_skin_awb/func_8013859C.s,func_8013859C,0x8013859C,0x59 -asm/non_matchings/code/z_skin_awb/func_80138700.s,func_80138700,0x80138700,0x35 +asm/non_matchings/code/z_skin/Skin_GetLimbPos.s,Skin_GetLimbPos,0x80138300,0x17 +asm/non_matchings/code/z_skin/Skin_GetVertexPos.s,Skin_GetVertexPos,0x8013835C,0x2D +asm/non_matchings/code/z_skin_awb/Skin_Setup.s,Skin_Setup,0x80138410,0x5 +asm/non_matchings/code/z_skin_awb/Skin_InitAnimatedLimb.s,Skin_InitAnimatedLimb,0x80138424,0x5E +asm/non_matchings/code/z_skin_awb/Skin_Init.s,Skin_Init,0x8013859C,0x59 +asm/non_matchings/code/z_skin_awb/Skin_Free.s,Skin_Free,0x80138700,0x35 asm/non_matchings/code/z_skin_awb/func_801387D4.s,func_801387D4,0x801387D4,0x44 -asm/non_matchings/code/z_skin_awb/func_801388E4.s,func_801388E4,0x801388E4,0xAF +asm/non_matchings/code/z_skin_awb/Skin_ApplyAnimTransformations.s,Skin_ApplyAnimTransformations,0x801388E4,0xAF asm/non_matchings/code/z_skin_matrix/SkinMatrix_Vec3fMtxFMultXYZW.s,SkinMatrix_Vec3fMtxFMultXYZW,0x80138BA0,0x3A asm/non_matchings/code/z_skin_matrix/SkinMatrix_Vec3fMtxFMultXYZ.s,SkinMatrix_Vec3fMtxFMultXYZ,0x80138C88,0x2C asm/non_matchings/code/z_skin_matrix/SkinMatrix_MtxFMtxFMult.s,SkinMatrix_MtxFMtxFMult,0x80138D38,0xD7 @@ -2172,7 +2172,7 @@ asm/non_matchings/code/z_snap/func_8013A530.s,func_8013A530,0x8013A530,0xA4 asm/non_matchings/code/z_sub_s/SubS_FindDoor.s,SubS_FindDoor,0x8013A7C0,0x28 asm/non_matchings/code/z_sub_s/SubS_DrawTransformFlexLimb.s,SubS_DrawTransformFlexLimb,0x8013A860,0xA8 asm/non_matchings/code/z_sub_s/SubS_DrawTransformFlex.s,SubS_DrawTransformFlex,0x8013AB00,0x9B -asm/non_matchings/code/z_sub_s/func_8013AD6C.s,func_8013AD6C,0x8013AD6C,0xC +asm/non_matchings/code/z_sub_s/SubS_InCsMode.s,SubS_InCsMode,0x8013AD6C,0xC asm/non_matchings/code/z_sub_s/func_8013AD9C.s,func_8013AD9C,0x8013AD9C,0x4E asm/non_matchings/code/z_sub_s/SubS_UpdateFlags.s,SubS_UpdateFlags,0x8013AED4,0xB asm/non_matchings/code/z_sub_s/func_8013AF00.s,func_8013AF00,0x8013AF00,0x44 @@ -2181,47 +2181,47 @@ asm/non_matchings/code/z_sub_s/func_8013B0C8.s,func_8013B0C8,0x8013B0C8,0xA2 asm/non_matchings/code/z_sub_s/func_8013B350.s,func_8013B350,0x8013B350,0xD8 asm/non_matchings/code/z_sub_s/func_8013B6B0.s,func_8013B6B0,0x8013B6B0,0x72 asm/non_matchings/code/z_sub_s/func_8013B878.s,func_8013B878,0x8013B878,0xAF -asm/non_matchings/code/z_sub_s/func_8013BB34.s,func_8013BB34,0x8013BB34,0x12 +asm/non_matchings/code/z_sub_s/SubS_GetAdditionalPath.s,SubS_GetAdditionalPath,0x8013BB34,0x12 asm/non_matchings/code/z_sub_s/SubS_FindNearestActor.s,SubS_FindNearestActor,0x8013BB7C,0x3C asm/non_matchings/code/z_sub_s/SubS_ChangeAnimationByInfoS.s,SubS_ChangeAnimationByInfoS,0x8013BC6C,0x35 -asm/non_matchings/code/z_sub_s/func_8013BD40.s,func_8013BD40,0x8013BD40,0x67 -asm/non_matchings/code/z_sub_s/func_8013BEDC.s,func_8013BEDC,0x8013BEDC,0x63 +asm/non_matchings/code/z_sub_s/SubS_HasReachedPoint.s,SubS_HasReachedPoint,0x8013BD40,0x67 +asm/non_matchings/code/z_sub_s/SubS_GetDayDependentPath.s,SubS_GetDayDependentPath,0x8013BEDC,0x63 asm/non_matchings/code/z_sub_s/func_8013C068.s,func_8013C068,0x8013C068,0x16F asm/non_matchings/code/z_sub_s/func_8013C624.s,func_8013C624,0x8013C624,0xA5 -asm/non_matchings/code/z_sub_s/func_8013C8B8.s,func_8013C8B8,0x8013C8B8,0x2B +asm/non_matchings/code/z_sub_s/SubS_CopyPointFromPathCheckBounds.s,SubS_CopyPointFromPathCheckBounds,0x8013C8B8,0x2B asm/non_matchings/code/z_sub_s/func_8013C964.s,func_8013C964,0x8013C964,0xB2 -asm/non_matchings/code/z_sub_s/func_8013CC2C.s,func_8013CC2C,0x8013CC2C,0x4E -asm/non_matchings/code/z_sub_s/func_8013CD64.s,func_8013CD64,0x8013CD64,0x68 -asm/non_matchings/code/z_sub_s/func_8013CF04.s,func_8013CF04,0x8013CF04,0x77 +asm/non_matchings/code/z_sub_s/SubS_FillShadowTex.s,SubS_FillShadowTex,0x8013CC2C,0x4E +asm/non_matchings/code/z_sub_s/SubS_GenShadowTex.s,SubS_GenShadowTex,0x8013CD64,0x68 +asm/non_matchings/code/z_sub_s/SubS_DrawShadowTex.s,SubS_DrawShadowTex,0x8013CF04,0x77 asm/non_matchings/code/z_sub_s/func_8013D0E0.s,func_8013D0E0,0x8013D0E0,0x80 asm/non_matchings/code/z_sub_s/func_8013D2E0.s,func_8013D2E0,0x8013D2E0,0xC2 asm/non_matchings/code/z_sub_s/SubS_AngleDiffLessEqual.s,SubS_AngleDiffLessEqual,0x8013D5E8,0x18 -asm/non_matchings/code/z_sub_s/func_8013D648.s,func_8013D648,0x8013D648,0x11 -asm/non_matchings/code/z_sub_s/func_8013D68C.s,func_8013D68C,0x8013D68C,0x25 -asm/non_matchings/code/z_sub_s/func_8013D720.s,func_8013D720,0x8013D720,0x12 -asm/non_matchings/code/z_sub_s/func_8013D768.s,func_8013D768,0x8013D768,0x35 -asm/non_matchings/code/z_sub_s/func_8013D83C.s,func_8013D83C,0x8013D83C,0x28 +asm/non_matchings/code/z_sub_s/SubS_GetPathByIndex.s,SubS_GetPathByIndex,0x8013D648,0x11 +asm/non_matchings/code/z_sub_s/SubS_CopyPointFromPath.s,SubS_CopyPointFromPath,0x8013D68C,0x25 +asm/non_matchings/code/z_sub_s/SubS_GetDistSqAndOrientPoints.s,SubS_GetDistSqAndOrientPoints,0x8013D720,0x12 +asm/non_matchings/code/z_sub_s/SubS_MoveActorToPoint.s,SubS_MoveActorToPoint,0x8013D768,0x35 +asm/non_matchings/code/z_sub_s/SubS_GetDistSqAndOrientPath.s,SubS_GetDistSqAndOrientPath,0x8013D83C,0x28 asm/non_matchings/code/z_sub_s/SubS_IsObjectLoaded.s,SubS_IsObjectLoaded,0x8013D8DC,0x12 asm/non_matchings/code/z_sub_s/SubS_GetObjectIndex.s,SubS_GetObjectIndex,0x8013D924,0xF asm/non_matchings/code/z_sub_s/SubS_FindActor.s,SubS_FindActor,0x8013D960,0x1A asm/non_matchings/code/z_sub_s/SubS_FillLimbRotTables.s,SubS_FillLimbRotTables,0x8013D9C8,0x72 -asm/non_matchings/code/z_sub_s/func_8013DB90.s,func_8013DB90,0x8013DB90,0x2C -asm/non_matchings/code/z_sub_s/func_8013DC40.s,func_8013DC40,0x8013DC40,0x23 -asm/non_matchings/code/z_sub_s/func_8013DCCC.s,func_8013DCCC,0x8013DCCC,0x5 -asm/non_matchings/code/z_sub_s/func_8013DCE0.s,func_8013DCE0,0x8013DCE0,0x49 -asm/non_matchings/code/z_sub_s/func_8013DE04.s,func_8013DE04,0x8013DE04,0x4E -asm/non_matchings/code/z_sub_s/func_8013DF3C.s,func_8013DF3C,0x8013DF3C,0x46 -asm/non_matchings/code/z_sub_s/func_8013E054.s,func_8013E054,0x8013E054,0xA -asm/non_matchings/code/z_sub_s/func_8013E07C.s,func_8013E07C,0x8013E07C,0xA -asm/non_matchings/code/z_sub_s/func_8013E0A4.s,func_8013E0A4,0x8013E0A4,0x49 +asm/non_matchings/code/z_sub_s/SubS_IsFloorAbove.s,SubS_IsFloorAbove,0x8013DB90,0x2C +asm/non_matchings/code/z_sub_s/SubS_CopyPointFromPathList.s,SubS_CopyPointFromPathList,0x8013DC40,0x23 +asm/non_matchings/code/z_sub_s/SubS_GetPathCount.s,SubS_GetPathCount,0x8013DCCC,0x5 +asm/non_matchings/code/z_sub_s/SubS_ActorPathing_Init.s,SubS_ActorPathing_Init,0x8013DCE0,0x49 +asm/non_matchings/code/z_sub_s/SubS_ActorPathing_Update.s,SubS_ActorPathing_Update,0x8013DE04,0x4E +asm/non_matchings/code/z_sub_s/SubS_ActorPathing_ComputePointInfo.s,SubS_ActorPathing_ComputePointInfo,0x8013DF3C,0x46 +asm/non_matchings/code/z_sub_s/SubS_ActorPathing_MoveWithGravity.s,SubS_ActorPathing_MoveWithGravity,0x8013E054,0xA +asm/non_matchings/code/z_sub_s/SubS_ActorPathing_MoveWithoutGravityReverse.s,SubS_ActorPathing_MoveWithoutGravityReverse,0x8013E07C,0xA +asm/non_matchings/code/z_sub_s/SubS_ActorPathing_SetNextPoint.s,SubS_ActorPathing_SetNextPoint,0x8013E0A4,0x49 asm/non_matchings/code/z_sub_s/SubS_ChangeAnimationBySpeedInfo.s,SubS_ChangeAnimationBySpeedInfo,0x8013E1C8,0x43 asm/non_matchings/code/z_sub_s/SubS_StartActorCutscene.s,SubS_StartActorCutscene,0x8013E2D4,0x39 asm/non_matchings/code/z_sub_s/SubS_FillCutscenesList.s,SubS_FillCutscenesList,0x8013E3B8,0x3E -asm/non_matchings/code/z_sub_s/func_8013E4B0.s,func_8013E4B0,0x8013E4B0,0x47 -asm/non_matchings/code/z_sub_s/func_8013E5CC.s,func_8013E5CC,0x8013E5CC,0x1D +asm/non_matchings/code/z_sub_s/SubS_ConstructPlane.s,SubS_ConstructPlane,0x8013E4B0,0x47 +asm/non_matchings/code/z_sub_s/SubS_LineSegVsPlane.s,SubS_LineSegVsPlane,0x8013E5CC,0x1D asm/non_matchings/code/z_sub_s/SubS_FindActorCustom.s,SubS_FindActorCustom,0x8013E640,0x42 asm/non_matchings/code/z_sub_s/func_8013E748.s,func_8013E748,0x8013E748,0x1E -asm/non_matchings/code/z_sub_s/func_8013E7C0.s,func_8013E7C0,0x8013E7C0,0x4E +asm/non_matchings/code/z_sub_s/SubS_ActorAndPlayerFaceEachOther.s,SubS_ActorAndPlayerFaceEachOther,0x8013E7C0,0x4E asm/non_matchings/code/z_sub_s/func_8013E8F8.s,func_8013E8F8,0x8013E8F8,0x16 asm/non_matchings/code/z_sub_s/func_8013E950.s,func_8013E950,0x8013E950,0xB0 asm/non_matchings/code/code_8013EC10/func_8013EC10.s,func_8013EC10,0x8013EC10,0xD @@ -2301,30 +2301,30 @@ asm/non_matchings/code/z_vr_box_draw/func_801435A0.s,func_801435A0,0x801435A0,0x asm/non_matchings/code/z_vr_box_draw/func_80143624.s,func_80143624,0x80143624,0x11 asm/non_matchings/code/z_vr_box_draw/func_80143668.s,func_80143668,0x80143668,0xE7 asm/non_matchings/code/z_vr_box_draw/func_80143A04.s,func_80143A04,0x80143A04,0x3 -asm/non_matchings/code/z_sram_NES/func_80143A10.s,func_80143A10,0x80143A10,0x11 -asm/non_matchings/code/z_sram_NES/func_80143A54.s,func_80143A54,0x80143A54,0x1C -asm/non_matchings/code/z_sram_NES/func_80143AC4.s,func_80143AC4,0x80143AC4,0x12 -asm/non_matchings/code/z_sram_NES/func_80143B0C.s,func_80143B0C,0x80143B0C,0x29A +asm/non_matchings/code/z_sram_NES/Sram_ActivateOwl.s,Sram_ActivateOwl,0x80143A10,0x11 +asm/non_matchings/code/z_sram_NES/Sram_ClearHighscores.s,Sram_ClearHighscores,0x80143A54,0x1C +asm/non_matchings/code/z_sram_NES/Sram_ClearFlagsAtDawnOfTheFirstDay.s,Sram_ClearFlagsAtDawnOfTheFirstDay,0x80143AC4,0x12 +asm/non_matchings/code/z_sram_NES/Sram_SaveEndOfCycle.s,Sram_SaveEndOfCycle,0x80143B0C,0x29A asm/non_matchings/code/z_sram_NES/Sram_IncrementDay.s,Sram_IncrementDay,0x80144574,0x1C asm/non_matchings/code/z_sram_NES/Sram_CalcChecksum.s,Sram_CalcChecksum,0x801445E4,0x11 -asm/non_matchings/code/z_sram_NES/func_80144628.s,func_80144628,0x80144628,0x17 +asm/non_matchings/code/z_sram_NES/Sram_ResetSave.s,Sram_ResetSave,0x80144628,0x17 asm/non_matchings/code/z_sram_NES/Sram_GenerateRandomSaveFields.s,Sram_GenerateRandomSaveFields,0x80144684,0x83 asm/non_matchings/code/z_sram_NES/func_80144890.s,func_80144890,0x80144890,0x36 asm/non_matchings/code/z_sram_NES/Sram_InitDebugSave.s,Sram_InitDebugSave,0x80144968,0x4B asm/non_matchings/code/z_sram_NES/func_80144A94.s,func_80144A94,0x80144A94,0xF9 -asm/non_matchings/code/z_sram_NES/func_80144E78.s,func_80144E78,0x80144E78,0x17D +asm/non_matchings/code/z_sram_NES/Sram_OpenSave.s,Sram_OpenSave,0x80144E78,0x17D asm/non_matchings/code/z_sram_NES/func_8014546C.s,func_8014546C,0x8014546C,0x8B asm/non_matchings/code/z_sram_NES/func_80145698.s,func_80145698,0x80145698,0x4D asm/non_matchings/code/z_sram_NES/func_801457CC.s,func_801457CC,0x801457CC,0x36D asm/non_matchings/code/z_sram_NES/func_80146580.s,func_80146580,0x80146580,0x2A asm/non_matchings/code/z_sram_NES/func_80146628.s,func_80146628,0x80146628,0x11E -asm/non_matchings/code/z_sram_NES/func_80146AA0.s,func_80146AA0,0x80146AA0,0xD6 +asm/non_matchings/code/z_sram_NES/Sram_InitSave.s,Sram_InitSave,0x80146AA0,0xD6 asm/non_matchings/code/z_sram_NES/func_80146DF8.s,func_80146DF8,0x80146DF8,0x12 -asm/non_matchings/code/z_sram_NES/func_80146E40.s,func_80146E40,0x80146E40,0xC +asm/non_matchings/code/z_sram_NES/Sram_InitSram.s,Sram_InitSram,0x80146E40,0xC asm/non_matchings/code/z_sram_NES/Sram_Alloc.s,Sram_Alloc,0x80146E70,0x13 asm/non_matchings/code/z_sram_NES/func_80146EBC.s,func_80146EBC,0x80146EBC,0xB -asm/non_matchings/code/z_sram_NES/func_80146EE8.s,func_80146EE8,0x80146EE8,0x1D -asm/non_matchings/code/z_sram_NES/func_80146F5C.s,func_80146F5C,0x80146F5C,0x2B +asm/non_matchings/code/z_sram_NES/Sram_SaveSpecialEnterClockTown.s,Sram_SaveSpecialEnterClockTown,0x80146EE8,0x1D +asm/non_matchings/code/z_sram_NES/Sram_SaveSpecialNewDay.s,Sram_SaveSpecialNewDay,0x80146F5C,0x2B asm/non_matchings/code/z_sram_NES/func_80147008.s,func_80147008,0x80147008,0x6 asm/non_matchings/code/z_sram_NES/func_80147020.s,func_80147020,0x80147020,0x12 asm/non_matchings/code/z_sram_NES/func_80147068.s,func_80147068,0x80147068,0x34 @@ -2336,8 +2336,8 @@ asm/non_matchings/code/z_sram_NES/func_80147414.s,func_80147414,0x80147414,0x3E asm/non_matchings/code/z_sram_NES/Sram_nop8014750C.s,Sram_nop8014750C,0x8014750C,0x5 asm/non_matchings/code/z_message/func_80147520.s,func_80147520,0x80147520,0x11 asm/non_matchings/code/z_message/func_80147564.s,func_80147564,0x80147564,0x30 -asm/non_matchings/code/z_message/func_80147624.s,func_80147624,0x80147624,0x44 -asm/non_matchings/code/z_message/func_80147734.s,func_80147734,0x80147734,0x20 +asm/non_matchings/code/z_message/Message_ShouldAdvance.s,Message_ShouldAdvance,0x80147624,0x44 +asm/non_matchings/code/z_message/Message_ShouldAdvanceSilent.s,Message_ShouldAdvanceSilent,0x80147734,0x20 asm/non_matchings/code/z_message/func_801477B4.s,func_801477B4,0x801477B4,0x19 asm/non_matchings/code/z_message/func_80147818.s,func_80147818,0x80147818,0x1C0 asm/non_matchings/code/z_message/func_80147F18.s,func_80147F18,0x80147F18,0x190 @@ -2351,12 +2351,12 @@ asm/non_matchings/code/z_message/func_80149454.s,func_80149454,0x80149454,0x9D asm/non_matchings/code/z_message/func_801496C8.s,func_801496C8,0x801496C8,0xA5 asm/non_matchings/code/z_message/func_8014995C.s,func_8014995C,0x8014995C,0xAF asm/non_matchings/code/z_message/func_80149C18.s,func_80149C18,0x80149C18,0xA9 -asm/non_matchings/code/z_message/func_80149EBC.s,func_80149EBC,0x80149EBC,0x2E +asm/non_matchings/code/z_message/Message_FindMessage.s,Message_FindMessage,0x80149EBC,0x2E asm/non_matchings/code/z_message/func_80149F74.s,func_80149F74,0x80149F74,0x2D7 asm/non_matchings/code/z_message/func_8014AAD0.s,func_8014AAD0,0x8014AAD0,0xBB asm/non_matchings/code/z_message/func_8014ADBC.s,func_8014ADBC,0x8014ADBC,0x654 asm/non_matchings/code/z_message/func_8014C70C.s,func_8014C70C,0x8014C70C,0x142 -asm/non_matchings/code/z_message/func_8014CC14.s,func_8014CC14,0x8014CC14,0x28 +asm/non_matchings/code/z_message/Message_LoadChar.s,Message_LoadChar,0x8014CC14,0x28 asm/non_matchings/code/z_message/func_8014CCB4.s,func_8014CCB4,0x8014CCB4,0x4F asm/non_matchings/code/z_message/func_8014CDF0.s,func_8014CDF0,0x8014CDF0,0x7B asm/non_matchings/code/z_message/func_8014CFDC.s,func_8014CFDC,0x8014CFDC,0xCA @@ -2388,17 +2388,17 @@ asm/non_matchings/code/z_message/func_80156758.s,func_80156758,0x80156758,0x2D asm/non_matchings/code/z_message/func_8015680C.s,func_8015680C,0x8015680C,0x7A6 asm/non_matchings/code/z_message/func_801586A4.s,func_801586A4,0x801586A4,0xC asm/non_matchings/code/z_message/Message_Init.s,Message_Init,0x801586D4,0x7F -asm/non_matchings/code/z_message_nes/func_801588D0.s,func_801588D0,0x801588D0,0x2E -asm/non_matchings/code/z_message_nes/func_80158988.s,func_80158988,0x80158988,0x27 -asm/non_matchings/code/z_message_nes/func_80158A24.s,func_80158A24,0x80158A24,0x78 -asm/non_matchings/code/z_message_nes/func_80158C04.s,func_80158C04,0x80158C04,0x65 -asm/non_matchings/code/z_message_nes/func_80158D98.s,func_80158D98,0x80158D98,0x86 -asm/non_matchings/code/z_message_nes/func_80158FB0.s,func_80158FB0,0x80158FB0,0xAF -asm/non_matchings/code/z_message_nes/func_8015926C.s,func_8015926C,0x8015926C,0x73 +asm/non_matchings/code/z_message_nes/Message_FindMessageNES.s,Message_FindMessageNES,0x801588D0,0x2E +asm/non_matchings/code/z_message_nes/Message_LoadCharNES.s,Message_LoadCharNES,0x80158988,0x27 +asm/non_matchings/code/z_message_nes/Message_LoadPluralRupeesNES.s,Message_LoadPluralRupeesNES,0x80158A24,0x78 +asm/non_matchings/code/z_message_nes/Message_LoadLocalizedRupeesNES.s,Message_LoadLocalizedRupeesNES,0x80158C04,0x65 +asm/non_matchings/code/z_message_nes/Message_LoadRupeesNES.s,Message_LoadRupeesNES,0x80158D98,0x86 +asm/non_matchings/code/z_message_nes/Message_LoadTimeNES.s,Message_LoadTimeNES,0x80158FB0,0xAF +asm/non_matchings/code/z_message_nes/Message_LoadAreaTextNES.s,Message_LoadAreaTextNES,0x8015926C,0x73 asm/non_matchings/code/z_message_nes/func_80159438.s,func_80159438,0x80159438,0x8D asm/non_matchings/code/z_message_nes/func_8015966C.s,func_8015966C,0x8015966C,0x6CB asm/non_matchings/code/z_message_nes/func_8015B198.s,func_8015B198,0x8015B198,0xD6E -asm/non_matchings/code/z_message_staff/func_8015E750.s,func_8015E750,0x8015E750,0x27 +asm/non_matchings/code/z_message_staff/Message_FindCreditsMessage.s,Message_FindCreditsMessage,0x8015E750,0x27 asm/non_matchings/code/z_message_staff/func_8015E7EC.s,func_8015E7EC,0x8015E7EC,0x42F asm/non_matchings/code/z_message_staff/func_8015F8A8.s,func_8015F8A8,0x8015F8A8,0x47A asm/non_matchings/code/z_player_call/PlayerCall_InitFuncPtrs.s,PlayerCall_InitFuncPtrs,0x80160A90,0x1A @@ -2512,7 +2512,7 @@ asm/non_matchings/code/z_play/func_80167F0C.s,func_80167F0C,0x80167F0C,0x61 asm/non_matchings/code/z_play/Play_Draw.s,Play_Draw,0x80168090,0x347 asm/non_matchings/code/z_play/func_80168DAC.s,func_80168DAC,0x80168DAC,0x6E asm/non_matchings/code/z_play/Play_Update.s,Play_Update,0x80168F64,0x5A -asm/non_matchings/code/z_play/func_801690CC.s,func_801690CC,0x801690CC,0xD +asm/non_matchings/code/z_play/Play_InCsMode.s,Play_InCsMode,0x801690CC,0xD asm/non_matchings/code/z_play/func_80169100.s,func_80169100,0x80169100,0x3C asm/non_matchings/code/z_play/func_801691F0.s,func_801691F0,0x801691F0,0xC asm/non_matchings/code/z_play/Play_LoadScene.s,Play_LoadScene,0x80169220,0x17 @@ -3064,140 +3064,138 @@ asm/non_matchings/code/audio_synthesis/func_8018A768.s,func_8018A768,0x8018A768, asm/non_matchings/code/audio_synthesis/func_8018A808.s,func_8018A808,0x8018A808,0x12F asm/non_matchings/code/audio_synthesis/func_8018ACC4.s,func_8018ACC4,0x8018ACC4,0x5C asm/non_matchings/code/audio_synthesis/func_8018AE34.s,func_8018AE34,0x8018AE34,0xAF -asm/non_matchings/code/audio_heap/func_8018B0F0.s,func_8018B0F0,0x8018B0F0,0x7 -asm/non_matchings/code/audio_heap/func_8018B10C.s,func_8018B10C,0x8018B10C,0x51 -asm/non_matchings/code/audio_heap/func_8018B250.s,func_8018B250,0x8018B250,0x32 -asm/non_matchings/code/audio_heap/func_8018B318.s,func_8018B318,0x8018B318,0x39 -asm/non_matchings/code/audio_heap/func_8018B3FC.s,func_8018B3FC,0x8018B3FC,0x1E -asm/non_matchings/code/audio_heap/func_8018B474.s,func_8018B474,0x8018B474,0x21 -asm/non_matchings/code/audio_heap/func_8018B4F8.s,func_8018B4F8,0x8018B4F8,0xA -asm/non_matchings/code/audio_heap/func_8018B520.s,func_8018B520,0x8018B520,0x16 -asm/non_matchings/code/audio_heap/func_8018B578.s,func_8018B578,0x8018B578,0x16 +asm/non_matchings/code/audio_heap/AudioHeap_ResetLoadStatus.s,AudioHeap_ResetLoadStatus,0x8018B250,0x32 +asm/non_matchings/code/audio_heap/AudioHeap_DiscardFont.s,AudioHeap_DiscardFont,0x8018B318,0x39 +asm/non_matchings/code/audio_heap/AudioHeap_ReleaseNotesForFont.s,AudioHeap_ReleaseNotesForFont,0x8018B3FC,0x1E +asm/non_matchings/code/audio_heap/AudioHeap_DiscardSequence.s,AudioHeap_DiscardSequence,0x8018B474,0x21 +asm/non_matchings/code/audio_heap/AudioHeap_WritebackDCache.s,AudioHeap_WritebackDCache,0x8018B4F8,0xA +asm/non_matchings/code/audio_heap/AudioHeap_AllocZeroedAttemptExternal.s,AudioHeap_AllocZeroedAttemptExternal,0x8018B520,0x16 +asm/non_matchings/code/audio_heap/AudioHeap_AllocAttemptExternal.s,AudioHeap_AllocAttemptExternal,0x8018B578,0x16 asm/non_matchings/code/audio_heap/AudioHeap_AllocDmaMemory.s,AudioHeap_AllocDmaMemory,0x8018B5D0,0xE -asm/non_matchings/code/audio_heap/func_8018B608.s,func_8018B608,0x8018B608,0xE -asm/non_matchings/code/audio_heap/func_8018B640.s,func_8018B640,0x8018B640,0x17 -asm/non_matchings/code/audio_heap/func_8018B69C.s,func_8018B69C,0x8018B69C,0x13 -asm/non_matchings/code/audio_heap/func_8018B6E8.s,func_8018B6E8,0x8018B6E8,0x16 -asm/non_matchings/code/audio_heap/func_8018B740.s,func_8018B740,0x8018B740,0xA -asm/non_matchings/code/audio_heap/func_8018B768.s,func_8018B768,0x8018B768,0x5 -asm/non_matchings/code/audio_heap/func_8018B77C.s,func_8018B77C,0x8018B77C,0xC -asm/non_matchings/code/audio_heap/func_8018B7AC.s,func_8018B7AC,0x8018B7AC,0x4 -asm/non_matchings/code/audio_heap/func_8018B7BC.s,func_8018B7BC,0x8018B7BC,0x50 -asm/non_matchings/code/audio_heap/func_8018B8FC.s,func_8018B8FC,0x8018B8FC,0x18 -asm/non_matchings/code/audio_heap/func_8018B95C.s,func_8018B95C,0x8018B95C,0x21 -asm/non_matchings/code/audio_heap/func_8018B9E0.s,func_8018B9E0,0x8018B9E0,0x21 -asm/non_matchings/code/audio_heap/func_8018BA64.s,func_8018BA64,0x8018BA64,0x31 -asm/non_matchings/code/audio_heap/func_8018BB28.s,func_8018BB28,0x8018BB28,0x31 -asm/non_matchings/code/audio_heap/func_8018BBEC.s,func_8018BBEC,0x8018BBEC,0x1E5 -asm/non_matchings/code/audio_heap/func_8018C380.s,func_8018C380,0x8018C380,0x16 -asm/non_matchings/code/audio_heap/func_8018C3D8.s,func_8018C3D8,0x8018C3D8,0x43 +asm/non_matchings/code/audio_heap/AudioHeap_AllocDmaMemoryZeroed.s,AudioHeap_AllocDmaMemoryZeroed,0x8018B608,0xE +asm/non_matchings/code/audio_heap/AudioHeap_AllocZeroed.s,AudioHeap_AllocZeroed,0x8018B640,0x17 +asm/non_matchings/code/audio_heap/AudioHeap_TestAlloc.s,AudioHeap_TestAlloc,0x8018B69C,0x13 +asm/non_matchings/code/audio_heap/Audio_Alloc.s,Audio_Alloc,0x8018B6E8,0x16 +asm/non_matchings/code/audio_heap/AudioHeap_AllocPoolInit.s,AudioHeap_AllocPoolInit,0x8018B740,0xA +asm/non_matchings/code/audio_heap/AudioHeap_ClearPersistentCache.s,AudioHeap_ClearPersistentCache,0x8018B768,0x5 +asm/non_matchings/code/audio_heap/AudioHeap_ClearTemporaryCache.s,AudioHeap_ClearTemporaryCache,0x8018B77C,0xC +asm/non_matchings/code/audio_heap/AudioHeap_ResetPool.s,AudioHeap_ResetPool,0x8018B7AC,0x4 +asm/non_matchings/code/audio_heap/AudioHeap_PopCache.s,AudioHeap_PopCache,0x8018B7BC,0x50 +asm/non_matchings/code/audio_heap/AudioHeap_InitMainPool.s,AudioHeap_InitMainPool,0x8018B8FC,0x18 +asm/non_matchings/code/audio_heap/AudioHeap_InitSessionPool.s,AudioHeap_InitSessionPool,0x8018B95C,0x21 +asm/non_matchings/code/audio_heap/AudioHeap_InitCachePool.s,AudioHeap_InitCachePool,0x8018B9E0,0x21 +asm/non_matchings/code/audio_heap/AudioHeap_InitPersistentCache.s,AudioHeap_InitPersistentCache,0x8018BA64,0x31 +asm/non_matchings/code/audio_heap/AudioHeap_InitTemporaryCache.s,AudioHeap_InitTemporaryCache,0x8018BB28,0x31 +asm/non_matchings/code/audio_heap/AudioHeap_AllocCached.s,AudioHeap_AllocCached,0x8018BBEC,0x1E5 +asm/non_matchings/code/audio_heap/AudioHeap_SearchCaches.s,AudioHeap_SearchCaches,0x8018C380,0x16 +asm/non_matchings/code/audio_heap/AudioHeap_SearchRegularCaches.s,AudioHeap_SearchRegularCaches,0x8018C3D8,0x43 asm/non_matchings/code/audio_heap/func_8018C4E4.s,func_8018C4E4,0x8018C4E4,0xF5 -asm/non_matchings/code/audio_heap/func_8018C8B8.s,func_8018C8B8,0x8018C8B8,0xC -asm/non_matchings/code/audio_heap/func_8018C8E8.s,func_8018C8E8,0x8018C8E8,0x15 -asm/non_matchings/code/audio_heap/func_8018C93C.s,func_8018C93C,0x8018C93C,0x16 -asm/non_matchings/code/audio_heap/func_8018C994.s,func_8018C994,0x8018C994,0x77 -asm/non_matchings/code/audio_heap/func_8018CB70.s,func_8018CB70,0x8018CB70,0x2 -asm/non_matchings/code/audio_heap/func_8018CB78.s,func_8018CB78,0x8018CB78,0x31 -asm/non_matchings/code/audio_heap/func_8018CC3C.s,func_8018CC3C,0x8018CC3C,0x1B -asm/non_matchings/code/audio_heap/func_8018CCA8.s,func_8018CCA8,0x8018CCA8,0xC1 -asm/non_matchings/code/audio_heap/func_8018CFAC.s,func_8018CFAC,0x8018CFAC,0x174 -asm/non_matchings/code/audio_heap/func_8018D57C.s,func_8018D57C,0x8018D57C,0x16 -asm/non_matchings/code/audio_heap/func_8018D5D4.s,func_8018D5D4,0x8018D5D4,0x21 -asm/non_matchings/code/audio_heap/func_8018D658.s,func_8018D658,0x8018D658,0x1C -asm/non_matchings/code/audio_heap/func_8018D6C8.s,func_8018D6C8,0x8018D6C8,0x26 -asm/non_matchings/code/audio_heap/func_8018D760.s,func_8018D760,0x8018D760,0xBC -asm/non_matchings/code/audio_heap/func_8018DA50.s,func_8018DA50,0x8018DA50,0x5D -asm/non_matchings/code/audio_heap/func_8018DBC4.s,func_8018DBC4,0x8018DBC4,0x3C -asm/non_matchings/code/audio_heap/func_8018DCB4.s,func_8018DCB4,0x8018DCB4,0x11 -asm/non_matchings/code/audio_heap/func_8018DCF8.s,func_8018DCF8,0x8018DCF8,0x28 -asm/non_matchings/code/audio_heap/func_8018DD98.s,func_8018DD98,0x8018DD98,0xF -asm/non_matchings/code/audio_heap/func_8018DDD4.s,func_8018DDD4,0x8018DDD4,0x54 -asm/non_matchings/code/audio_heap/func_8018DF24.s,func_8018DF24,0x8018DF24,0x2F -asm/non_matchings/code/audio_heap/func_8018DFE0.s,func_8018DFE0,0x8018DFE0,0xB -asm/non_matchings/code/audio_heap/func_8018E00C.s,func_8018E00C,0x8018E00C,0xC -asm/non_matchings/code/audio_heap/func_8018E03C.s,func_8018E03C,0x8018E03C,0x9B -asm/non_matchings/code/audio_heap/func_8018E2A8.s,func_8018E2A8,0x8018E2A8,0x27 -asm/non_matchings/code/audio_heap/func_8018E344.s,func_8018E344,0x8018E344,0x161 -asm/non_matchings/code/audio_heap/func_8018E8C8.s,func_8018E8C8,0x8018E8C8,0xA6 -asm/non_matchings/code/audio_load/func_8018EB60.s,func_8018EB60,0x8018EB60,0x3B -asm/non_matchings/code/audio_load/func_8018EC4C.s,func_8018EC4C,0x8018EC4C,0xCF -asm/non_matchings/code/audio_load/func_8018EF88.s,func_8018EF88,0x8018EF88,0xA6 +asm/non_matchings/code/audio_heap/AudioHeap_ClearFilter.s,AudioHeap_ClearFilter,0x8018C8B8,0xC +asm/non_matchings/code/audio_heap/AudioHeap_LoadLowPassFilter.s,AudioHeap_LoadLowPassFilter,0x8018C8E8,0x15 +asm/non_matchings/code/audio_heap/AudioHeap_LoadHighPassFilter.s,AudioHeap_LoadHighPassFilter,0x8018C93C,0x16 +asm/non_matchings/code/audio_heap/AudioHeap_LoadFilter.s,AudioHeap_LoadFilter,0x8018C994,0x77 +asm/non_matchings/code/audio_heap/AudioHeap_UpdateReverb.s,AudioHeap_UpdateReverb,0x8018CB70,0x2 +asm/non_matchings/code/audio_heap/AudioHeap_UpdateReverbs.s,AudioHeap_UpdateReverbs,0x8018CB78,0x31 +asm/non_matchings/code/audio_heap/AudioHeap_ClearAiBuffers.s,AudioHeap_ClearAiBuffers,0x8018CC3C,0x1B +asm/non_matchings/code/audio_heap/AudioHeap_ResetStep.s,AudioHeap_ResetStep,0x8018CCA8,0xC1 +asm/non_matchings/code/audio_heap/AudioHeap_Init.s,AudioHeap_Init,0x8018CFAC,0x174 +asm/non_matchings/code/audio_heap/AudioHeap_SearchPermanentCache.s,AudioHeap_SearchPermanentCache,0x8018D57C,0x16 +asm/non_matchings/code/audio_heap/AudioHeap_AllocPermanent.s,AudioHeap_AllocPermanent,0x8018D5D4,0x21 +asm/non_matchings/code/audio_heap/AudioHeap_AllocSampleCache.s,AudioHeap_AllocSampleCache,0x8018D658,0x1C +asm/non_matchings/code/audio_heap/AudioHeap_InitSampleCaches.s,AudioHeap_InitSampleCaches,0x8018D6C8,0x26 +asm/non_matchings/code/audio_heap/AudioHeap_AllocTemporarySampleCacheEntry.s,AudioHeap_AllocTemporarySampleCacheEntry,0x8018D760,0xBC +asm/non_matchings/code/audio_heap/AudioHeap_UnapplySampleCacheForFont.s,AudioHeap_UnapplySampleCacheForFont,0x8018DA50,0x5D +asm/non_matchings/code/audio_heap/AudioHeap_DiscardSampleCacheEntry.s,AudioHeap_DiscardSampleCacheEntry,0x8018DBC4,0x3C +asm/non_matchings/code/audio_heap/AudioHeap_UnapplySampleCache.s,AudioHeap_UnapplySampleCache,0x8018DCB4,0x11 +asm/non_matchings/code/audio_heap/AudioHeap_AllocPersistentSampleCacheEntry.s,AudioHeap_AllocPersistentSampleCacheEntry,0x8018DCF8,0x28 +asm/non_matchings/code/audio_heap/AudioHeap_DiscardSampleCacheForFont.s,AudioHeap_DiscardSampleCacheForFont,0x8018DD98,0xF +asm/non_matchings/code/audio_heap/AudioHeap_DiscardSampleCaches.s,AudioHeap_DiscardSampleCaches,0x8018DDD4,0x54 +asm/non_matchings/code/audio_heap/AudioHeap_ChangeStorage.s,AudioHeap_ChangeStorage,0x8018DF24,0x2F +asm/non_matchings/code/audio_heap/AudioHeap_DiscardSampleBank.s,AudioHeap_DiscardSampleBank,0x8018DFE0,0xB +asm/non_matchings/code/audio_heap/AudioHeap_ApplySampleBankCache.s,AudioHeap_ApplySampleBankCache,0x8018E00C,0xC +asm/non_matchings/code/audio_heap/AudioHeap_ApplySampleBankCacheInternal.s,AudioHeap_ApplySampleBankCacheInternal,0x8018E03C,0x9B +asm/non_matchings/code/audio_heap/AudioHeap_DiscardSampleBanks.s,AudioHeap_DiscardSampleBanks,0x8018E2A8,0x27 +asm/non_matchings/code/audio_heap/AudioHeap_SetReverbData.s,AudioHeap_SetReverbData,0x8018E344,0x161 +asm/non_matchings/code/audio_heap/AudioHeap_InitReverb.s,AudioHeap_InitReverb,0x8018E8C8,0xA6 +asm/non_matchings/code/audio_load/AudioLoad_DecreaseSampleDmaTtls.s,AudioLoad_DecreaseSampleDmaTtls,0x8018EB60,0x3B +asm/non_matchings/code/audio_load/AudioLoad_DmaSampleData.s,AudioLoad_DmaSampleData,0x8018EC4C,0xCF +asm/non_matchings/code/audio_load/AudioLoad_InitSampleDmaBuffers.s,AudioLoad_InitSampleDmaBuffers,0x8018EF88,0xA6 asm/non_matchings/code/audio_load/AudioLoad_IsFontLoadComplete.s,AudioLoad_IsFontLoadComplete,0x8018F220,0x1E -asm/non_matchings/code/audio_load/func_8018F298.s,func_8018F298,0x8018F298,0x1E -asm/non_matchings/code/audio_load/func_8018F310.s,func_8018F310,0x8018F310,0x1E -asm/non_matchings/code/audio_load/func_8018F388.s,func_8018F388,0x8018F388,0xC -asm/non_matchings/code/audio_load/func_8018F3B8.s,func_8018F3B8,0x8018F3B8,0xC -asm/non_matchings/code/audio_load/func_8018F3E8.s,func_8018F3E8,0x8018F3E8,0x18 -asm/non_matchings/code/audio_load/func_8018F448.s,func_8018F448,0x8018F448,0xC -asm/non_matchings/code/audio_load/func_8018F478.s,func_8018F478,0x8018F478,0x18 -asm/non_matchings/code/audio_load/func_8018F4D8.s,func_8018F4D8,0x8018F4D8,0x2C -asm/non_matchings/code/audio_load/func_8018F588.s,func_8018F588,0x8018F588,0x1F -asm/non_matchings/code/audio_load/func_8018F604.s,func_8018F604,0x8018F604,0x3B -asm/non_matchings/code/audio_load/func_8018F6F0.s,func_8018F6F0,0x8018F6F0,0x34 -asm/non_matchings/code/audio_load/func_8018F7C0.s,func_8018F7C0,0x8018F7C0,0xE -asm/non_matchings/code/audio_load/func_8018F7F8.s,func_8018F7F8,0x8018F7F8,0x11 -asm/non_matchings/code/audio_load/func_8018F83C.s,func_8018F83C,0x8018F83C,0x11 -asm/non_matchings/code/audio_load/func_8018F880.s,func_8018F880,0x8018F880,0x11 -asm/non_matchings/code/audio_load/func_8018F8C4.s,func_8018F8C4,0x8018F8C4,0x11 -asm/non_matchings/code/audio_load/func_8018F908.s,func_8018F908,0x8018F908,0x2C -asm/non_matchings/code/audio_load/func_8018F9B8.s,func_8018F9B8,0x8018F9B8,0x2A +asm/non_matchings/code/audio_load/AudioLoad_IsSeqLoadComplete.s,AudioLoad_IsSeqLoadComplete,0x8018F298,0x1E +asm/non_matchings/code/audio_load/AudioLoad_IsSampleLoadComplete.s,AudioLoad_IsSampleLoadComplete,0x8018F310,0x1E +asm/non_matchings/code/audio_load/AudioLoad_SetFontLoadStatus.s,AudioLoad_SetFontLoadStatus,0x8018F388,0xC +asm/non_matchings/code/audio_load/AudioLoad_SetSeqLoadStatus.s,AudioLoad_SetSeqLoadStatus,0x8018F3B8,0xC +asm/non_matchings/code/audio_load/AudioLoad_SetSampleFontLoadStatusAndApplyCaches.s,AudioLoad_SetSampleFontLoadStatusAndApplyCaches,0x8018F3E8,0x18 +asm/non_matchings/code/audio_load/AudioLoad_SetSampleFontLoadStatus.s,AudioLoad_SetSampleFontLoadStatus,0x8018F448,0xC +asm/non_matchings/code/audio_load/AudioLoad_InitTable.s,AudioLoad_InitTable,0x8018F478,0x18 +asm/non_matchings/code/audio_load/AudioLoad_SyncLoadSeqFonts.s,AudioLoad_SyncLoadSeqFonts,0x8018F4D8,0x2C +asm/non_matchings/code/audio_load/AudioLoad_SyncLoadSeqParts.s,AudioLoad_SyncLoadSeqParts,0x8018F588,0x1F +asm/non_matchings/code/audio_load/AudioLoad_SyncLoadSample.s,AudioLoad_SyncLoadSample,0x8018F604,0x3B +asm/non_matchings/code/audio_load/AudioLoad_SyncLoadInstrument.s,AudioLoad_SyncLoadInstrument,0x8018F6F0,0x34 +asm/non_matchings/code/audio_load/AudioLoad_AsyncLoad.s,AudioLoad_AsyncLoad,0x8018F7C0,0xE +asm/non_matchings/code/audio_load/AudioLoad_AsyncLoadSeq.s,AudioLoad_AsyncLoadSeq,0x8018F7F8,0x11 +asm/non_matchings/code/audio_load/AudioLoad_AsyncLoadSampleBank.s,AudioLoad_AsyncLoadSampleBank,0x8018F83C,0x11 +asm/non_matchings/code/audio_load/AudioLoad_AsyncLoadFont.s,AudioLoad_AsyncLoadFont,0x8018F880,0x11 +asm/non_matchings/code/audio_load/AudioLoad_GetFontsForSequence.s,AudioLoad_GetFontsForSequence,0x8018F8C4,0x11 +asm/non_matchings/code/audio_load/AudioLoad_DiscardSeqFonts.s,AudioLoad_DiscardSeqFonts,0x8018F908,0x2C +asm/non_matchings/code/audio_load/AudioLoad_DiscardFont.s,AudioLoad_DiscardFont,0x8018F9B8,0x2A asm/non_matchings/code/audio_load/func_8018FA60.s,func_8018FA60,0x8018FA60,0x1C -asm/non_matchings/code/audio_load/func_8018FAD0.s,func_8018FAD0,0x8018FAD0,0x14 -asm/non_matchings/code/audio_load/func_8018FB20.s,func_8018FB20,0x8018FB20,0x16 -asm/non_matchings/code/audio_load/func_8018FB78.s,func_8018FB78,0x8018FB78,0x55 -asm/non_matchings/code/audio_load/func_8018FCCC.s,func_8018FCCC,0x8018FCCC,0x15 -asm/non_matchings/code/audio_load/func_8018FD20.s,func_8018FD20,0x8018FD20,0x8 -asm/non_matchings/code/audio_load/func_8018FD40.s,func_8018FD40,0x8018FD40,0x47 -asm/non_matchings/code/audio_load/func_8018FE5C.s,func_8018FE5C,0x8018FE5C,0x41 -asm/non_matchings/code/audio_load/func_8018FF60.s,func_8018FF60,0x8018FF60,0xA9 -asm/non_matchings/code/audio_load/func_80190204.s,func_80190204,0x80190204,0xF -asm/non_matchings/code/audio_load/func_80190240.s,func_80190240,0x80190240,0x15 -asm/non_matchings/code/audio_load/func_80190294.s,func_80190294,0x80190294,0x11 -asm/non_matchings/code/audio_load/func_801902D8.s,func_801902D8,0x801902D8,0x9B -asm/non_matchings/code/audio_load/func_80190544.s,func_80190544,0x80190544,0x49 -asm/non_matchings/code/audio_load/func_80190668.s,func_80190668,0x80190668,0x5 -asm/non_matchings/code/audio_load/func_8019067C.s,func_8019067C,0x8019067C,0x36 -asm/non_matchings/code/audio_load/func_80190754.s,func_80190754,0x80190754,0x2 -asm/non_matchings/code/audio_load/func_8019075C.s,func_8019075C,0x8019075C,0x8 -asm/non_matchings/code/audio_load/func_8019077C.s,func_8019077C,0x8019077C,0xE3 -asm/non_matchings/code/audio_load/func_80190B08.s,func_80190B08,0x80190B08,0xC -asm/non_matchings/code/audio_load/func_80190B38.s,func_80190B38,0x80190B38,0x3 -asm/non_matchings/code/audio_load/func_80190B44.s,func_80190B44,0x80190B44,0x3 -asm/non_matchings/code/audio_load/func_80190B50.s,func_80190B50,0x80190B50,0x18 -asm/non_matchings/code/audio_load/func_80190BB0.s,func_80190BB0,0x80190BB0,0xE8 -asm/non_matchings/code/audio_load/func_80190F50.s,func_80190F50,0x80190F50,0x5 -asm/non_matchings/code/audio_load/func_80190F64.s,func_80190F64,0x80190F64,0x74 -asm/non_matchings/code/audio_load/func_80191134.s,func_80191134,0x80191134,0x24 -asm/non_matchings/code/audio_load/func_801911C4.s,func_801911C4,0x801911C4,0x2 -asm/non_matchings/code/audio_load/func_801911CC.s,func_801911CC,0x801911CC,0x1D -asm/non_matchings/code/audio_load/func_80191240.s,func_80191240,0x80191240,0x62 -asm/non_matchings/code/audio_load/func_801913C8.s,func_801913C8,0x801913C8,0x21 -asm/non_matchings/code/audio_load/func_8019144C.s,func_8019144C,0x8019144C,0x5 -asm/non_matchings/code/audio_load/func_80191460.s,func_80191460,0x80191460,0x42 -asm/non_matchings/code/audio_load/func_80191568.s,func_80191568,0x80191568,0xC -asm/non_matchings/code/audio_load/func_80191598.s,func_80191598,0x80191598,0x21 -asm/non_matchings/code/audio_load/func_8019161C.s,func_8019161C,0x8019161C,0x49 -asm/non_matchings/code/audio_load/func_80191740.s,func_80191740,0x80191740,0x49 -asm/non_matchings/code/audio_load/func_80191864.s,func_80191864,0x80191864,0x3 -asm/non_matchings/code/audio_load/func_80191870.s,func_80191870,0x80191870,0x4F -asm/non_matchings/code/audio_load/func_801919AC.s,func_801919AC,0x801919AC,0x65 -asm/non_matchings/code/audio_load/func_80191B40.s,func_80191B40,0x80191B40,0x24 -asm/non_matchings/code/audio_load/func_80191BD0.s,func_80191BD0,0x80191BD0,0x1C -asm/non_matchings/code/audio_load/func_80191C40.s,func_80191C40,0x80191C40,0x5 -asm/non_matchings/code/audio_load/func_80191C54.s,func_80191C54,0x80191C54,0x50 -asm/non_matchings/code/audio_load/func_80191D94.s,func_80191D94,0x80191D94,0xFE -asm/non_matchings/code/audio_load/func_8019218C.s,func_8019218C,0x8019218C,0x6D -asm/non_matchings/code/audio_load/func_80192340.s,func_80192340,0x80192340,0x12 -asm/non_matchings/code/audio_load/func_80192388.s,func_80192388,0x80192388,0x4D -asm/non_matchings/code/audio_load/func_801924BC.s,func_801924BC,0x801924BC,0x16 -asm/non_matchings/code/audio_load/func_80192514.s,func_80192514,0x80192514,0x11F -asm/non_matchings/code/audio_load/func_80192990.s,func_80192990,0x80192990,0x50 -asm/non_matchings/code/audio_load/func_80192AD0.s,func_80192AD0,0x80192AD0,0x2 -asm/non_matchings/code/audio_load/func_80192AD8.s,func_80192AD8,0x80192AD8,0x2 -asm/non_matchings/code/audio_load/func_80192AE0.s,func_80192AE0,0x80192AE0,0x2 -asm/non_matchings/code/audio_load/func_80192AE8.s,func_80192AE8,0x80192AE8,0x1B -asm/non_matchings/code/audio_load/func_80192B54.s,func_80192B54,0x80192B54,0x16 -asm/non_matchings/code/audio_load/func_80192BAC.s,func_80192BAC,0x80192BAC,0xD +asm/non_matchings/code/audio_load/AudioLoad_SyncInitSeqPlayer.s,AudioLoad_SyncInitSeqPlayer,0x8018FAD0,0x14 +asm/non_matchings/code/audio_load/AudioLoad_SyncInitSeqPlayerSkipTicks.s,AudioLoad_SyncInitSeqPlayerSkipTicks,0x8018FB20,0x16 +asm/non_matchings/code/audio_load/AudioLoad_SyncInitSeqPlayerInternal.s,AudioLoad_SyncInitSeqPlayerInternal,0x8018FB78,0x55 +asm/non_matchings/code/audio_load/AudioLoad_SyncLoadSeq.s,AudioLoad_SyncLoadSeq,0x8018FCCC,0x15 +asm/non_matchings/code/audio_load/AudioLoad_GetSampleBank.s,AudioLoad_GetSampleBank,0x8018FD20,0x8 +asm/non_matchings/code/audio_load/AudioLoad_TrySyncLoadSampleBank.s,AudioLoad_TrySyncLoadSampleBank,0x8018FD40,0x47 +asm/non_matchings/code/audio_load/AudioLoad_SyncLoadFont.s,AudioLoad_SyncLoadFont,0x8018FE5C,0x41 +asm/non_matchings/code/audio_load/AudioLoad_SyncLoad.s,AudioLoad_SyncLoad,0x8018FF60,0xA9 +asm/non_matchings/code/audio_load/AudioLoad_GetRealTableIndex.s,AudioLoad_GetRealTableIndex,0x80190204,0xF +asm/non_matchings/code/audio_load/AudioLoad_SearchCaches.s,AudioLoad_SearchCaches,0x80190240,0x15 +asm/non_matchings/code/audio_load/AudioLoad_GetLoadTable.s,AudioLoad_GetLoadTable,0x80190294,0x11 +asm/non_matchings/code/audio_load/AudioLoad_RelocateFont.s,AudioLoad_RelocateFont,0x801902D8,0x9B +asm/non_matchings/code/audio_load/AudioLoad_SyncDma.s,AudioLoad_SyncDma,0x80190544,0x49 +asm/non_matchings/code/audio_load/AudioLoad_SyncDmaUnkMedium.s,AudioLoad_SyncDmaUnkMedium,0x80190668,0x5 +asm/non_matchings/code/audio_load/AudioLoad_Dma.s,AudioLoad_Dma,0x8019067C,0x36 +asm/non_matchings/code/audio_load/AudioLoad_Unused1.s,AudioLoad_Unused1,0x80190754,0x2 +asm/non_matchings/code/audio_load/AudioLoad_SyncLoadSimple.s,AudioLoad_SyncLoadSimple,0x8019075C,0x8 +asm/non_matchings/code/audio_load/AudioLoad_AsyncLoadInner.s,AudioLoad_AsyncLoadInner,0x8019077C,0xE3 +asm/non_matchings/code/audio_load/AudioLoad_ProcessLoads.s,AudioLoad_ProcessLoads,0x80190B08,0xC +asm/non_matchings/code/audio_load/AudioLoad_SetDmaHandler.s,AudioLoad_SetDmaHandler,0x80190B38,0x3 +asm/non_matchings/code/audio_load/AudioLoad_SetUnusedHandler.s,AudioLoad_SetUnusedHandler,0x80190B44,0x3 +asm/non_matchings/code/audio_load/AudioLoad_InitSoundFontMeta.s,AudioLoad_InitSoundFontMeta,0x80190B50,0x18 +asm/non_matchings/code/audio_load/AudioLoad_Init.s,AudioLoad_Init,0x80190BB0,0xE8 +asm/non_matchings/code/audio_load/AudioLoad_InitSlowLoads.s,AudioLoad_InitSlowLoads,0x80190F50,0x5 +asm/non_matchings/code/audio_load/AudioLoad_SlowLoadSample.s,AudioLoad_SlowLoadSample,0x80190F64,0x74 +asm/non_matchings/code/audio_load/AudioLoad_GetFontSample.s,AudioLoad_GetFontSample,0x80191134,0x24 +asm/non_matchings/code/audio_load/AudioLoad_Unused2.s,AudioLoad_Unused2,0x801911C4,0x2 +asm/non_matchings/code/audio_load/AudioLoad_FinishSlowLoad.s,AudioLoad_FinishSlowLoad,0x801911CC,0x1D +asm/non_matchings/code/audio_load/AudioLoad_ProcessSlowLoads.s,AudioLoad_ProcessSlowLoads,0x80191240,0x62 +asm/non_matchings/code/audio_load/AudioLoad_DmaSlowCopy.s,AudioLoad_DmaSlowCopy,0x801913C8,0x21 +asm/non_matchings/code/audio_load/AudioLoad_DmaSlowCopyUnkMedium.s,AudioLoad_DmaSlowCopyUnkMedium,0x8019144C,0x5 +asm/non_matchings/code/audio_load/AudioLoad_SlowLoadSeq.s,AudioLoad_SlowLoadSeq,0x80191460,0x42 +asm/non_matchings/code/audio_load/AudioLoad_InitAsyncLoads.s,AudioLoad_InitAsyncLoads,0x80191568,0xC +asm/non_matchings/code/audio_load/AudioLoad_StartAsyncLoadUnkMedium.s,AudioLoad_StartAsyncLoadUnkMedium,0x80191598,0x21 +asm/non_matchings/code/audio_load/AudioLoad_StartAsyncLoad.s,AudioLoad_StartAsyncLoad,0x8019161C,0x49 +asm/non_matchings/code/audio_load/AudioLoad_ProcessAsyncLoads.s,AudioLoad_ProcessAsyncLoads,0x80191740,0x49 +asm/non_matchings/code/audio_load/AudioLoad_ProcessAsyncLoadUnkMedium.s,AudioLoad_ProcessAsyncLoadUnkMedium,0x80191864,0x3 +asm/non_matchings/code/audio_load/AudioLoad_FinishAsyncLoad.s,AudioLoad_FinishAsyncLoad,0x80191870,0x4F +asm/non_matchings/code/audio_load/AudioLoad_ProcessAsyncLoad.s,AudioLoad_ProcessAsyncLoad,0x801919AC,0x65 +asm/non_matchings/code/audio_load/AudioLoad_AsyncDma.s,AudioLoad_AsyncDma,0x80191B40,0x24 +asm/non_matchings/code/audio_load/AudioLoad_AsyncDmaRamUnloaded.s,AudioLoad_AsyncDmaRamUnloaded,0x80191BD0,0x1C +asm/non_matchings/code/audio_load/AudioLoad_AsyncDmaUnkMedium.s,AudioLoad_AsyncDmaUnkMedium,0x80191C40,0x5 +asm/non_matchings/code/audio_load/AudioLoad_RelocateSample.s,AudioLoad_RelocateSample,0x80191C54,0x50 +asm/non_matchings/code/audio_load/AudioLoad_RelocateFontAndPreloadSamples.s,AudioLoad_RelocateFontAndPreloadSamples,0x80191D94,0xFE +asm/non_matchings/code/audio_load/AudioLoad_ProcessSamplePreloads.s,AudioLoad_ProcessSamplePreloads,0x8019218C,0x6D +asm/non_matchings/code/audio_load/AudioLoad_AddToSampleSet.s,AudioLoad_AddToSampleSet,0x80192340,0x12 +asm/non_matchings/code/audio_load/AudioLoad_GetSamplesForFont.s,AudioLoad_GetSamplesForFont,0x80192388,0x4D +asm/non_matchings/code/audio_load/AudioLoad_AddUsedSample.s,AudioLoad_AddUsedSample,0x801924BC,0x16 +asm/non_matchings/code/audio_load/AudioLoad_PreloadSamplesForFont.s,AudioLoad_PreloadSamplesForFont,0x80192514,0x11F +asm/non_matchings/code/audio_load/AudioLoad_LoadPermanentSamples.s,AudioLoad_LoadPermanentSamples,0x80192990,0x50 +asm/non_matchings/code/audio_load/AudioLoad_Unused3.s,AudioLoad_Unused3,0x80192AD0,0x2 +asm/non_matchings/code/audio_load/AudioLoad_Unused4.s,AudioLoad_Unused4,0x80192AD8,0x2 +asm/non_matchings/code/audio_load/AudioLoad_Unused5.s,AudioLoad_Unused5,0x80192AE0,0x2 +asm/non_matchings/code/audio_load/AudioLoad_ScriptLoad.s,AudioLoad_ScriptLoad,0x80192AE8,0x1B +asm/non_matchings/code/audio_load/AudioLoad_ProcessScriptLoads.s,AudioLoad_ProcessScriptLoads,0x80192B54,0x16 +asm/non_matchings/code/audio_load/AudioLoad_InitScriptLoads.s,AudioLoad_InitScriptLoads,0x80192BAC,0xD asm/non_matchings/code/code_80192BE0/func_80192BE0.s,func_80192BE0,0x80192BE0,0x8 asm/non_matchings/code/code_80192BE0/func_80192C00.s,func_80192C00,0x80192C00,0x167 asm/non_matchings/code/code_80192BE0/func_8019319C.s,func_8019319C,0x8019319C,0x14F @@ -3207,7 +3205,7 @@ asm/non_matchings/code/code_80192BE0/func_80193774.s,func_80193774,0x80193774,0x asm/non_matchings/code/code_80192BE0/func_8019380C.s,func_8019380C,0x8019380C,0x13 asm/non_matchings/code/code_80192BE0/func_80193858.s,func_80193858,0x80193858,0x9 asm/non_matchings/code/code_80192BE0/func_8019387C.s,func_8019387C,0x8019387C,0x9 -asm/non_matchings/code/code_80192BE0/func_801938A0.s,func_801938A0,0x801938A0,0xC +asm/non_matchings/code/code_80192BE0/Audio_QueueCmdS8.s,Audio_QueueCmdS8,0x801938A0,0xC asm/non_matchings/code/code_80192BE0/func_801938D0.s,func_801938D0,0x801938D0,0xC asm/non_matchings/code/code_80192BE0/func_80193900.s,func_80193900,0x80193900,0x24 asm/non_matchings/code/code_80192BE0/func_80193990.s,func_80193990,0x80193990,0x6 @@ -3236,8 +3234,8 @@ asm/non_matchings/code/code_80192BE0/func_8019440C.s,func_8019440C,0x8019440C,0x asm/non_matchings/code/code_80192BE0/func_80194528.s,func_80194528,0x80194528,0x8 asm/non_matchings/code/code_80192BE0/func_80194548.s,func_80194548,0x80194548,0x8 asm/non_matchings/code/code_80192BE0/func_80194568.s,func_80194568,0x80194568,0x40 -asm/non_matchings/code/code_80192BE0/func_80194668.s,func_80194668,0x80194668,0x1F -asm/non_matchings/code/code_80192BE0/func_801946E4.s,func_801946E4,0x801946E4,0xB +asm/non_matchings/code/code_80192BE0/Audio_NextRandom.s,Audio_NextRandom,0x80194668,0x1F +asm/non_matchings/code/code_80192BE0/Audio_InitMesgQueues.s,Audio_InitMesgQueues,0x801946E4,0xB asm/non_matchings/code/code_80194710/Audio_InvalDCache.s,Audio_InvalDCache,0x80194710,0x10 asm/non_matchings/code/code_80194710/Audio_WritebackDCache.s,Audio_WritebackDCache,0x80194750,0x10 asm/non_matchings/code/code_80194710/func_80194790.s,func_80194790,0x80194790,0x1D @@ -3295,7 +3293,7 @@ asm/non_matchings/code/audio_seqplayer/AudioSeq_SequenceChannelDisable.s,AudioSe asm/non_matchings/code/audio_seqplayer/func_80197B14.s,func_80197B14,0x80197B14,0x3E asm/non_matchings/code/audio_seqplayer/func_80197C0C.s,func_80197C0C,0x80197C0C,0x20 asm/non_matchings/code/audio_seqplayer/func_80197C8C.s,func_80197C8C,0x80197C8C,0x26 -asm/non_matchings/code/audio_seqplayer/func_80197D24.s,func_80197D24,0x80197D24,0xA +asm/non_matchings/code/audio_seqplayer/AudioSeq_SequencePlayerDisableAsFinished.s,AudioSeq_SequencePlayerDisableAsFinished,0x80197D24,0xA asm/non_matchings/code/audio_seqplayer/AudioSeq_SequencePlayerDisable.s,AudioSeq_SequencePlayerDisable,0x80197D4C,0x2F asm/non_matchings/code/audio_seqplayer/AudioSeq_AudioListPushBack.s,AudioSeq_AudioListPushBack,0x80197E08,0x10 asm/non_matchings/code/audio_seqplayer/AudioSeq_AudioListPopBack.s,AudioSeq_AudioListPopBack,0x80197E48,0x10 @@ -3317,23 +3315,23 @@ asm/non_matchings/code/audio_seqplayer/func_80199268.s,func_80199268,0x80199268, asm/non_matchings/code/audio_seqplayer/func_8019A0BC.s,func_8019A0BC,0x8019A0BC,0x260 asm/non_matchings/code/audio_seqplayer/func_8019AA3C.s,func_8019AA3C,0x8019AA3C,0x2D asm/non_matchings/code/audio_seqplayer/func_8019AAF0.s,func_8019AAF0,0x8019AAF0,0x14 -asm/non_matchings/code/audio_seqplayer/func_8019AB40.s,func_8019AB40,0x8019AB40,0x34 -asm/non_matchings/code/audio_seqplayer/func_8019AC10.s,func_8019AC10,0x8019AC10,0x37 +asm/non_matchings/code/audio_seqplayer/AudioSeq_ResetSequencePlayer.s,AudioSeq_ResetSequencePlayer,0x8019AB40,0x34 +asm/non_matchings/code/audio_seqplayer/AudioSeq_InitSequencePlayerChannels.s,AudioSeq_InitSequencePlayerChannels,0x8019AC10,0x37 asm/non_matchings/code/audio_seqplayer/func_8019ACEC.s,func_8019ACEC,0x8019ACEC,0x34 -asm/non_matchings/code/audio_seqplayer/func_8019ADBC.s,func_8019ADBC,0x8019ADBC,0x21 +asm/non_matchings/code/audio_seqplayer/AudioSeq_InitSequencePlayers.s,AudioSeq_InitSequencePlayers,0x8019ADBC,0x21 asm/non_matchings/code/code_8019AE40/func_8019AE40.s,func_8019AE40,0x8019AE40,0x1C asm/non_matchings/code/code_8019AEC0/func_8019AEC0.s,func_8019AEC0,0x8019AEC0,0x10 asm/non_matchings/code/code_8019AF00/func_8019AF00.s,func_8019AF00,0x8019AF00,0x16 asm/non_matchings/code/code_8019AF00/func_8019AF58.s,func_8019AF58,0x8019AF58,0x24 asm/non_matchings/code/code_8019AF00/func_8019AFE8.s,func_8019AFE8,0x8019AFE8,0x11 asm/non_matchings/code/code_8019AF00/func_8019B02C.s,func_8019B02C,0x8019B02C,0x12 -asm/non_matchings/code/code_8019AF00/func_8019B074.s,func_8019B074,0x8019B074,0x34 +asm/non_matchings/code/code_8019AF00/AudioOcarina_MapSongFromNotesToButtons.s,AudioOcarina_MapSongFromNotesToButtons,0x8019B074,0x34 asm/non_matchings/code/code_8019AF00/func_8019B144.s,func_8019B144,0x8019B144,0x8D asm/non_matchings/code/code_8019AF00/func_8019B378.s,func_8019B378,0x8019B378,0x5 asm/non_matchings/code/code_8019AF00/func_8019B38C.s,func_8019B38C,0x8019B38C,0x11 asm/non_matchings/code/code_8019AF00/func_8019B3D0.s,func_8019B3D0,0x8019B3D0,0x3A asm/non_matchings/code/code_8019AF00/func_8019B4B8.s,func_8019B4B8,0x8019B4B8,0x23 -asm/non_matchings/code/code_8019AF00/func_8019B544.s,func_8019B544,0x8019B544,0x9 +asm/non_matchings/code/code_8019AF00/AudioOcarina_StartDefault.s,AudioOcarina_StartDefault,0x8019B544,0x9 asm/non_matchings/code/code_8019AF00/func_8019B568.s,func_8019B568,0x8019B568,0x11 asm/non_matchings/code/code_8019AF00/func_8019B5AC.s,func_8019B5AC,0x8019B5AC,0x10 asm/non_matchings/code/code_8019AF00/func_8019B5EC.s,func_8019B5EC,0x8019B5EC,0xB @@ -3346,7 +3344,7 @@ asm/non_matchings/code/code_8019AF00/func_8019C1C0.s,func_8019C1C0,0x8019C1C0,0x asm/non_matchings/code/code_8019AF00/func_8019C1D0.s,func_8019C1D0,0x8019C1D0,0x26 asm/non_matchings/code/code_8019AF00/func_8019C268.s,func_8019C268,0x8019C268,0x1F asm/non_matchings/code/code_8019AF00/func_8019C2E4.s,func_8019C2E4,0x8019C2E4,0x7 -asm/non_matchings/code/code_8019AF00/func_8019C300.s,func_8019C300,0x8019C300,0x26 +asm/non_matchings/code/code_8019AF00/AudioOcarina_SetInstrumentId.s,AudioOcarina_SetInstrumentId,0x8019C300,0x26 asm/non_matchings/code/code_8019AF00/func_8019C398.s,func_8019C398,0x8019C398,0x82 asm/non_matchings/code/code_8019AF00/func_8019C5A0.s,func_8019C5A0,0x8019C5A0,0xCE asm/non_matchings/code/code_8019AF00/func_8019C8D8.s,func_8019C8D8,0x8019C8D8,0x10C @@ -3356,12 +3354,12 @@ asm/non_matchings/code/code_8019AF00/func_8019CE6C.s,func_8019CE6C,0x8019CE6C,0x asm/non_matchings/code/code_8019AF00/func_8019CEBC.s,func_8019CEBC,0x8019CEBC,0x2C asm/non_matchings/code/code_8019AF00/func_8019CF6C.s,func_8019CF6C,0x8019CF6C,0x3 asm/non_matchings/code/code_8019AF00/func_8019CF78.s,func_8019CF78,0x8019CF78,0x9 -asm/non_matchings/code/code_8019AF00/func_8019CF9C.s,func_8019CF9C,0x8019CF9C,0x3 +asm/non_matchings/code/code_8019AF00/AudioOcarina_GetPlaybackStaff.s,AudioOcarina_GetPlaybackStaff,0x8019CF9C,0x3 asm/non_matchings/code/code_8019AF00/func_8019CFA8.s,func_8019CFA8,0x8019CFA8,0x63 -asm/non_matchings/code/code_8019AF00/func_8019D134.s,func_8019D134,0x8019D134,0x4E -asm/non_matchings/code/code_8019AF00/func_8019D26C.s,func_8019D26C,0x8019D26C,0x87 -asm/non_matchings/code/code_8019AF00/func_8019D488.s,func_8019D488,0x8019D488,0x1C -asm/non_matchings/code/code_8019AF00/func_8019D4F8.s,func_8019D4F8,0x8019D4F8,0x42 +asm/non_matchings/code/code_8019AF00/AudioOcarina_TerminaWallValidateNotes.s,AudioOcarina_TerminaWallValidateNotes,0x8019D134,0x4E +asm/non_matchings/code/code_8019AF00/AudioOcarina_TerminaWallGenerateNotes.s,AudioOcarina_TerminaWallGenerateNotes,0x8019D26C,0x87 +asm/non_matchings/code/code_8019AF00/AudioOcarina_MemoryGameSetNumNotes.s,AudioOcarina_MemoryGameSetNumNotes,0x8019D488,0x1C +asm/non_matchings/code/code_8019AF00/AudioOcarina_MemoryGameGenerateNotes.s,AudioOcarina_MemoryGameGenerateNotes,0x8019D4F8,0x42 asm/non_matchings/code/code_8019AF00/func_8019D600.s,func_8019D600,0x8019D600,0x56 asm/non_matchings/code/code_8019AF00/func_8019D758.s,func_8019D758,0x8019D758,0x43 asm/non_matchings/code/code_8019AF00/func_8019D864.s,func_8019D864,0x8019D864,0x14 @@ -3415,18 +3413,18 @@ asm/non_matchings/code/code_8019AF00/func_8019FE1C.s,func_8019FE1C,0x8019FE1C,0x asm/non_matchings/code/code_8019AF00/func_8019FE74.s,func_8019FE74,0x8019FE74,0x1A asm/non_matchings/code/code_8019AF00/func_8019FEDC.s,func_8019FEDC,0x8019FEDC,0x17 asm/non_matchings/code/code_8019AF00/func_8019FF38.s,func_8019FF38,0x8019FF38,0x19 -asm/non_matchings/code/code_8019AF00/func_8019FF9C.s,func_8019FF9C,0x8019FF9C,0x2B -asm/non_matchings/code/code_8019AF00/func_801A0048.s,func_801A0048,0x801A0048,0x29 -asm/non_matchings/code/code_8019AF00/func_801A00EC.s,func_801A00EC,0x801A00EC,0xE +asm/non_matchings/code/code_8019AF00/Audio_PlaySfxForRiver.s,Audio_PlaySfxForRiver,0x8019FF9C,0x2B +asm/non_matchings/code/code_8019AF00/Audio_PlaySfxForWaterfall.s,Audio_PlaySfxForWaterfall,0x801A0048,0x29 +asm/non_matchings/code/code_8019AF00/Audio_StepFreqLerp.s,Audio_StepFreqLerp,0x801A00EC,0xE asm/non_matchings/code/code_8019AF00/func_801A0124.s,func_801A0124,0x801A0124,0x18 asm/non_matchings/code/code_8019AF00/func_801A0184.s,func_801A0184,0x801A0184,0x10 asm/non_matchings/code/code_8019AF00/func_801A01C4.s,func_801A01C4,0x801A01C4,0x10 asm/non_matchings/code/code_8019AF00/func_801A0204.s,func_801A0204,0x801A0204,0xD asm/non_matchings/code/code_8019AF00/func_801A0238.s,func_801A0238,0x801A0238,0xD -asm/non_matchings/code/code_8019AF00/func_801A026C.s,func_801A026C,0x801A026C,0x2B -asm/non_matchings/code/code_8019AF00/func_801A0318.s,func_801A0318,0x801A0318,0x4E -asm/non_matchings/code/code_8019AF00/func_801A0450.s,func_801A0450,0x801A0450,0x7 -asm/non_matchings/code/code_8019AF00/func_801A046C.s,func_801A046C,0x801A046C,0x3A +asm/non_matchings/code/code_8019AF00/Audio_SetGanonsTowerBgmVolumeLevel.s,Audio_SetGanonsTowerBgmVolumeLevel,0x801A026C,0x2B +asm/non_matchings/code/code_8019AF00/Audio_SetGanonsTowerBgmVolume.s,Audio_SetGanonsTowerBgmVolume,0x801A0318,0x4E +asm/non_matchings/code/code_8019AF00/Audio_LowerMainBgmVolume.s,Audio_LowerMainBgmVolume,0x801A0450,0x7 +asm/non_matchings/code/code_8019AF00/Audio_UpdateRiverSoundVolumes.s,Audio_UpdateRiverSoundVolumes,0x801A046C,0x3A asm/non_matchings/code/code_8019AF00/func_801A0554.s,func_801A0554,0x801A0554,0x24 asm/non_matchings/code/code_8019AF00/func_801A05E4.s,func_801A05E4,0x801A05E4,0x3 asm/non_matchings/code/code_8019AF00/func_801A05F0.s,func_801A05F0,0x801A05F0,0x19 @@ -3434,9 +3432,9 @@ asm/non_matchings/code/code_8019AF00/func_801A0654.s,func_801A0654,0x801A0654,0x asm/non_matchings/code/code_8019AF00/func_801A0810.s,func_801A0810,0x801A0810,0x16 asm/non_matchings/code/code_8019AF00/func_801A0868.s,func_801A0868,0x801A0868,0x5B asm/non_matchings/code/code_8019AF00/func_801A09D4.s,func_801A09D4,0x801A09D4,0xA7 -asm/non_matchings/code/code_8019AF00/func_801A0C70.s,func_801A0C70,0x801A0C70,0x8 -asm/non_matchings/code/code_8019AF00/func_801A0C90.s,func_801A0C90,0x801A0C90,0x8 -asm/non_matchings/code/code_8019AF00/func_801A0CB0.s,func_801A0CB0,0x801A0CB0,0x65 +asm/non_matchings/code/code_8019AF00/Audio_ClearSariaBgm.s,Audio_ClearSariaBgm,0x801A0C70,0x8 +asm/non_matchings/code/code_8019AF00/Audio_ClearSariaBgmAtPos.s,Audio_ClearSariaBgmAtPos,0x801A0C90,0x8 +asm/non_matchings/code/code_8019AF00/Audio_SplitBgmChannels.s,Audio_SplitBgmChannels,0x801A0CB0,0x65 asm/non_matchings/code/code_8019AF00/func_801A0E44.s,func_801A0E44,0x801A0E44,0x113 asm/non_matchings/code/code_8019AF00/func_801A1290.s,func_801A1290,0x801A1290,0x2E asm/non_matchings/code/code_8019AF00/func_801A1348.s,func_801A1348,0x801A1348,0x1D @@ -3453,8 +3451,8 @@ asm/non_matchings/code/code_8019AF00/func_801A1F00.s,func_801A1F00,0x801A1F00,0x asm/non_matchings/code/code_8019AF00/func_801A1F88.s,func_801A1F88,0x801A1F88,0xB asm/non_matchings/code/code_8019AF00/func_801A1FB4.s,func_801A1FB4,0x801A1FB4,0x37 asm/non_matchings/code/code_8019AF00/func_801A2090.s,func_801A2090,0x801A2090,0x5B -asm/non_matchings/code/code_8019AF00/func_801A21FC.s,func_801A21FC,0x801A21FC,0x99 -asm/non_matchings/code/code_8019AF00/func_801A2460.s,func_801A2460,0x801A2460,0x3 +asm/non_matchings/code/code_8019AF00/Audio_PlaySariaBgm.s,Audio_PlaySariaBgm,0x801A21FC,0x99 +asm/non_matchings/code/code_8019AF00/Audio_ClearSariaBgm2.s,Audio_ClearSariaBgm2,0x801A2460,0x3 asm/non_matchings/code/code_8019AF00/func_801A246C.s,func_801A246C,0x801A246C,0x36 asm/non_matchings/code/code_8019AF00/func_801A2544.s,func_801A2544,0x801A2544,0xE asm/non_matchings/code/code_8019AF00/func_801A257C.s,func_801A257C,0x801A257C,0x1A @@ -3568,7 +3566,7 @@ asm/non_matchings/code/code_801A5BD0/func_801A7720.s,func_801A7720,0x801A7720,0x asm/non_matchings/code/code_801A5BD0/func_801A7794.s,func_801A7794,0x801A7794,0x25 asm/non_matchings/code/code_801A5BD0/func_801A7828.s,func_801A7828,0x801A7828,0x15 asm/non_matchings/code/code_801A5BD0/func_801A787C.s,func_801A787C,0x801A787C,0x1A -asm/non_matchings/code/code_801A5BD0/func_801A78E4.s,func_801A78E4,0x801A78E4,0x1A +asm/non_matchings/code/code_801A5BD0/Audio_IsSfxPlaying.s,Audio_IsSfxPlaying,0x801A78E4,0x1A asm/non_matchings/code/code_801A5BD0/func_801A794C.s,func_801A794C,0x801A794C,0x71 asm/non_matchings/code/code_801A7B10/func_801A7B10.s,func_801A7B10,0x801A7B10,0x7D asm/non_matchings/code/code_801A7B10/func_801A7D04.s,func_801A7D04,0x801A7D04,0x20 @@ -3579,7 +3577,7 @@ asm/non_matchings/code/code_801A7B10/func_801A8A50.s,func_801A8A50,0x801A8A50,0x asm/non_matchings/code/code_801A7B10/func_801A8ABC.s,func_801A8ABC,0x801A8ABC,0x16 asm/non_matchings/code/code_801A7B10/func_801A8B14.s,func_801A8B14,0x801A8B14,0x6 asm/non_matchings/code/code_801A7B10/func_801A8B2C.s,func_801A8B2C,0x801A8B2C,0x29 -asm/non_matchings/code/code_801A7B10/func_801A8BD0.s,func_801A8BD0,0x801A8BD0,0x63 +asm/non_matchings/code/code_801A7B10/Audio_SetVolumeScale.s,Audio_SetVolumeScale,0x801A8BD0,0x63 asm/non_matchings/code/code_801A7B10/func_801A8D5C.s,func_801A8D5C,0x801A8D5C,0x283 asm/non_matchings/code/code_801A7B10/func_801A9768.s,func_801A9768,0x801A9768,0x31 asm/non_matchings/code/code_801A7B10/func_801A982C.s,func_801A982C,0x801A982C,0x63 diff --git a/undefined_syms.txt b/undefined_syms.txt index a003b1ae3d..1ef7e69420 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -430,7 +430,6 @@ D_040367B0 = 0x040367B0; D_040377B0 = 0x040377B0; D_04037850 = 0x04037850; D_0403A0F0 = 0x0403A0F0; -D_0403C190 = 0x0403C190; D_0403F230 = 0x0403F230; D_04044300 = 0x04044300; D_0404F250 = 0x0404F250; @@ -470,10 +469,6 @@ D_0406F380 = 0x0406F380; D_0406F9F0 = 0x0406F9F0; D_0406FAE0 = 0x0406FAE0; D_040706E0 = 0x040706E0; -D_04071230 = 0x04071230; -D_04073F00 = 0x04073F00; -D_04074330 = 0x04074330; -D_04075400 = 0x04075400; D_04075A40 = 0x04075A40; D_04076BC0 = 0x04076BC0; D_04079B10 = 0x04079B10; @@ -510,13 +505,10 @@ D_05006760 = 0x05006760; D_05007498 = 0x05007498; D_050078A0 = 0x050078A0; D_05007938 = 0x05007938; -D_05007E00 = 0x05007E00; -D_05008018 = 0x05008018; D_050085F0 = 0x050085F0; D_050089D0 = 0x050089D0; D_050182A8 = 0x050182A8; D_0501B370 = 0x0501B370; -D_0501B508 = 0x0501B508; D_0501BEE0 = 0x0501BEE0; D_0501BFB8 = 0x0501BFB8; D_0501C058 = 0x0501C058; @@ -560,36 +552,16 @@ D_06002498 = 0x06002498; D_06000638 = 0x06000638; D_06001BD8 = 0x06001BD8; -// ovl_Bg_Breakwall - -D_06000A50 = 0x06000A50; -D_06000C98 = 0x06000C98; - // ovl_Bg_Crace_Movebg D_060003A0 = 0x060003A0; D_06000E00 = 0x06000E00; -// ovl_Bg_Dblue_Balance - -D_0600CD10 = 0x0600CD10; -D_0600CE00 = 0x0600CE00; -D_0600D110 = 0x0600D110; -D_0600D250 = 0x0600D250; - // ovl_Bg_Dblue_Elevator D_060002C8 = 0x060002C8; D_060005C4 = 0x060005C4; -// ovl_Bg_Dblue_Waterfall - -D_06003250 = 0x06003250; -D_06003358 = 0x06003358; -D_06003770 = 0x06003770; -D_0600B280 = 0x0600B280; -D_0600B448 = 0x0600B448; - // ovl_Bg_Dkjail_Ivy D_06000080 = 0x06000080; @@ -603,22 +575,11 @@ D_0600D228 = 0x0600D228; D_0601C6F4 = 0x0601C6F4; D_0601C8B4 = 0x0601C8B4; -// ovl_Bg_F40_Block - -D_060043D0 = 0x060043D0; -D_06004640 = 0x06004640; - // ovl_Bg_F40_Flift D_06004038 = 0x06004038; D_06004240 = 0x06004240; -// ovl_Bg_F40_Switch - -D_06000118 = 0x06000118; -D_06000390 = 0x06000390; -D_06000438 = 0x06000438; - // ovl_Bg_F40_Swlift D_06003B08 = 0x06003B08; @@ -718,23 +679,11 @@ D_06000098 = 0x06000098; D_060003E8 = 0x060003E8; D_06001640 = 0x06001640; -// ovl_Bg_Open_Spot - -D_06001A60 = 0x06001A60; -D_06001B40 = 0x06001B40; -D_06002CE0 = 0x06002CE0; // ovl_Bg_Sinkai_Kabe D_06000048 = 0x06000048; -// ovl_Bg_Spdweb - -D_06000060 = 0x06000060; -D_060011C0 = 0x060011C0; -D_060012F0 = 0x060012F0; -D_06002678 = 0x06002678; - // ovl_Bg_Spout_Fire D_06000040 = 0x06000040; @@ -781,26 +730,6 @@ D_06022118 = 0x06022118; D_060222D0 = 0x060222D0; D_06022550 = 0x06022550; -// ovl_Boss_02 - -D_060003A0 = 0x060003A0; -D_060041A0 = 0x060041A0; - -// ovl_Boss_03 - -D_06004260 = 0x06004260; -D_060042B0 = 0x060042B0; -D_060042F8 = 0x060042F8; -D_06007E50 = 0x06007E50; -D_06007EB0 = 0x06007EB0; -D_06007EC8 = 0x06007EC8; -D_060093A8 = 0x060093A8; -D_06009554 = 0x06009554; -D_060099D0 = 0x060099D0; -D_06009C14 = 0x06009C14; -D_06009CF8 = 0x06009CF8; -D_0600A6C8 = 0x0600A6C8; - // ovl_Boss_05 D_060006A4 = 0x060006A4; @@ -910,12 +839,6 @@ D_060134D0 = 0x060134D0; D_06013828 = 0x06013828; D_06014040 = 0x06014040; -// ovl_Demo_Effect - -D_06000050 = 0x06000050; -D_06000060 = 0x06000060; -D_060012E8 = 0x060012E8; - // ovl_Demo_Moonend D_06001214 = 0x06001214; @@ -924,22 +847,6 @@ D_0600B5A0 = 0x0600B5A0; D_06010C40 = 0x06010C40; D_060129F0 = 0x060129F0; -// ovl_Demo_Syoten - -D_0600023C = 0x0600023C; -D_06001298 = 0x06001298; -D_06001328 = 0x06001328; -D_06001370 = 0x06001370; -D_06001448 = 0x06001448; -D_06001730 = 0x06001730; -D_060018B8 = 0x060018B8; -D_060018C0 = 0x060018C0; -D_06001DD0 = 0x06001DD0; -D_06002880 = 0x06002880; -D_06002A20 = 0x06002A20; -D_06002B88 = 0x06002B88; -D_06002B98 = 0x06002B98; - // ovl_Demo_Tre_Lgt D_06007D78 = 0x06007D78; @@ -952,11 +859,6 @@ D_06009E70 = 0x06009E70; D_0600A0D8 = 0x0600A0D8; -// ovl_Dm_An - -D_06000E70 = 0x06000E70; -D_06012618 = 0x06012618; - // ovl_Dm_Bal D_060005FC = 0x060005FC; @@ -988,11 +890,6 @@ D_0600E748 = 0x0600E748; D_0600005C = 0x0600005C; D_06001398 = 0x06001398; -// ovl_Dm_Gm - -D_06000E70 = 0x06000E70; -D_06012618 = 0x06012618; - // ovl_Dm_Opstage D_06000970 = 0x06000970; @@ -1024,10 +921,6 @@ D_060057D8 = 0x060057D8; D_060058C8 = 0x060058C8; D_06007238 = 0x06007238; -// ovl_Effect_En_Ice_Block - -D_06000A38 = 0x06000A38; - // ovl_Effect_Ss_D_Fire D_060098A0 = 0x060098A0; @@ -1066,10 +959,6 @@ D_06000180 = 0x06000180; D_060002A8 = 0x060002A8; D_06000F38 = 0x06000F38; -// ovl_En_Ah - -D_06009E70 = 0x06009E70; - // ovl_En_An D_06000308 = 0x06000308; @@ -1094,11 +983,6 @@ D_060028A0 = 0x060028A0; D_06009220 = 0x06009220; D_06009D34 = 0x06009D34; -// ovl_En_Attack_Niw - -D_060000E8 = 0x060000E8; -D_06002530 = 0x06002530; - // ovl_En_Az D_06007438 = 0x06007438; @@ -1121,18 +1005,6 @@ D_0600D530 = 0x0600D530; D_060000A0 = 0x060000A0; D_060000C8 = 0x060000C8; -// ovl_En_Bb - -D_06000184 = 0x06000184; -D_06000444 = 0x06000444; -D_06001A30 = 0x06001A30; - -// ovl_En_Bbfall - -D_06000184 = 0x06000184; -D_06000444 = 0x06000444; -D_06001A30 = 0x06001A30; - // ovl_En_Bee D_0600005C = 0x0600005C; @@ -1164,22 +1036,11 @@ D_06002390 = 0x06002390; D_06000A00 = 0x06000A00; D_06000D78 = 0x06000D78; -// ovl_En_Bombers - -D_060064B8 = 0x060064B8; -D_0600F82C = 0x0600F82C; - // ovl_En_Bombers2 D_060064B8 = 0x060064B8; D_0600F82C = 0x0600F82C; -// ovl_En_Bombf - -D_06000340 = 0x06000340; -D_06000408 = 0x06000408; -D_06000530 = 0x06000530; - // ovl_En_Bomjimb D_060064B8 = 0x060064B8; @@ -1253,11 +1114,6 @@ D_0600D640 = 0x0600D640; D_06002950 = 0x06002950; -// ovl_En_Dragon - -D_06004398 = 0x06004398; -D_060048B8 = 0x060048B8; - // ovl_En_Ds2n D_06008038 = 0x06008038; @@ -1314,21 +1170,6 @@ D_0600007C = 0x0600007C; D_0600CFE0 = 0x0600CFE0; D_06011058 = 0x06011058; -// ovl_En_Fu_Kago - -D_060006A0 = 0x060006A0; -D_06000740 = 0x06000740; -D_060007E0 = 0x060007E0; -D_06000880 = 0x06000880; -D_06000920 = 0x06000920; -D_060009C0 = 0x060009C0; -D_060015C0 = 0x060015C0; - -// ovl_En_Fu_Mato - -D_060023D4 = 0x060023D4; -D_06002720 = 0x06002720; - // ovl_En_Ge1 D_06002B98 = 0x06002B98; @@ -1354,12 +1195,6 @@ D_0600A808 = 0x0600A808; D_06000F9C = 0x06000F9C; D_06003F00 = 0x06003F00; -// ovl_En_Guard_Nuts - -D_06002700 = 0x06002700; -D_06002848 = 0x06002848; -D_06002A08 = 0x06002A08; - // ovl_En_Hata D_060000C0 = 0x060000C0; @@ -1372,41 +1207,11 @@ D_0600B644 = 0x0600B644; D_0600F248 = 0x0600F248; D_06012A58 = 0x06012A58; -// ovl_En_Hidden_Nuts - -D_060023B8 = 0x060023B8; -D_060024CC = 0x060024CC; - -// ovl_En_Horse - -D_06008C68 = 0x06008C68; -D_0600A8DC = 0x0600A8DC; -D_0600AD08 = 0x0600AD08; -D_0600B3E0 = 0x0600B3E0; -D_0600BDE0 = 0x0600BDE0; -D_0600D178 = 0x0600D178; -D_0600D4E8 = 0x0600D4E8; -D_060150D8 = 0x060150D8; - -// ovl_En_Horse_Game_Check - -D_060013A0 = 0x060013A0; -D_060014B0 = 0x060014B0; -D_06002FB8 = 0x06002FB8; -D_06003030 = 0x06003030; -D_060030C0 = 0x060030C0; -D_06003918 = 0x06003918; - // ovl_En_Horse_Link_Child D_06002F98 = 0x06002F98; D_0600A480 = 0x0600A480; -// ovl_En_Hs - -D_060005C0 = 0x060005C0; -D_06006260 = 0x06006260; - // ovl_En_Ik D_06000CE8 = 0x06000CE8; @@ -1438,11 +1243,6 @@ D_06012FC8 = 0x06012FC8; D_06013928 = 0x06013928; D_06016588 = 0x06016588; -// ovl_En_Jgame_Tsn - -D_06008AB8 = 0x06008AB8; -D_060092FC = 0x060092FC; - // ovl_En_Js D_06010880 = 0x06010880; @@ -1473,11 +1273,6 @@ D_0600D828 = 0x0600D828; D_06000C30 = 0x06000C30; D_06001630 = 0x06001630; -// ovl_En_Kbt - -D_06004274 = 0x06004274; -D_0600DEE8 = 0x0600DEE8; - // ovl_En_Kitan D_06000CE8 = 0x06000CE8; @@ -1544,36 +1339,11 @@ D_06021E34 = 0x06021E34; D_06022728 = 0x06022728; D_06022CAC = 0x06022CAC; -// ovl_En_Kujiya - -D_06002A80 = 0x06002A80; -D_06003030 = 0x06003030; -D_06003248 = 0x06003248; -D_06003358 = 0x06003358; -D_060034A8 = 0x060034A8; -D_060035B8 = 0x060035B8; -D_060036B0 = 0x060036B0; -D_060037C0 = 0x060037C0; -D_06003C80 = 0x06003C80; -D_06003D58 = 0x06003D58; -D_06006198 = 0x06006198; - -// ovl_En_Kusa - -D_06000140 = 0x06000140; -D_060002E0 = 0x060002E0; - // ovl_En_Lift_Nuts D_060029E8 = 0x060029E8; D_0600AC70 = 0x0600AC70; -// ovl_En_Look_Nuts - -D_06000430 = 0x06000430; -D_06002848 = 0x06002848; -D_06002B6C = 0x06002B6C; - // ovl_En_Mag D_06000000 = 0x06000000; @@ -1585,15 +1355,6 @@ D_06011740 = 0x06011740; D_06011BC0 = 0x06011BC0; D_06011E48 = 0x06011E48; -// ovl_En_Maruta - -D_06002EC0 = 0x06002EC0; - -// ovl_En_Mk - -D_06001C38 = 0x06001C38; -D_06006CA0 = 0x06006CA0; - // ovl_En_Mnk D_06003584 = 0x06003584; @@ -1635,15 +1396,6 @@ D_06003EE4 = 0x06003EE4; D_06004204 = 0x06004204; D_0600466C = 0x0600466C; -// ovl_En_Osk - -D_060000B8 = 0x060000B8; -D_060038F0 = 0x060038F0; -D_06006808 = 0x06006808; -D_06007B48 = 0x06007B48; -D_06009F00 = 0x06009F00; -D_0600B490 = 0x0600B490; - // ovl_En_Osn D_060192A0 = 0x060192A0; @@ -1678,15 +1430,6 @@ D_06004340 = 0x06004340; D_06001A80 = 0x06001A80; -// ovl_En_Raf - -D_06000108 = 0x06000108; -D_06000A64 = 0x06000A64; -D_060024E0 = 0x060024E0; -D_06002EF8 = 0x06002EF8; -D_060032F8 = 0x060032F8; -D_06003428 = 0x06003428; - // ovl_En_Rat D_06000174 = 0x06000174; @@ -1753,18 +1496,6 @@ D_0600D640 = 0x0600D640; D_06006C18 = 0x06006C18; D_0600D640 = 0x0600D640; -// ovl_En_Syateki_Dekunuts - -D_06001E50 = 0x06001E50; -D_06002468 = 0x06002468; -D_06002A5C = 0x06002A5C; -D_06003180 = 0x06003180; - -// ovl_En_Syateki_Okuta - -D_060033D0 = 0x060033D0; -D_0600466C = 0x0600466C; - // ovl_En_S_Goro D_060091A8 = 0x060091A8; @@ -1792,12 +1523,6 @@ D_06004550 = 0x06004550; D_06000168 = 0x06000168; D_06000E68 = 0x06000E68; -// ovl_En_Tanron5 - -D_06006FD0 = 0x06006FD0; -D_06007A88 = 0x06007A88; -D_06007D18 = 0x06007D18; - // ovl_En_Test3 D_0600CB60 = 0x0600CB60; @@ -1820,43 +1545,11 @@ D_06000A44 = 0x06000A44; D_0601A820 = 0x0601A820; D_0601A830 = 0x0601A830; -// ovl_En_Tru_Mt - -D_060004C8 = 0x060004C8; -D_0601AA60 = 0x0601AA60; - -// ovl_En_Tsn - -D_06000964 = 0x06000964; -D_06001198 = 0x06001198; -D_06008AB8 = 0x06008AB8; -D_060092FC = 0x060092FC; - // ovl_En_Twig D_060014C8 = 0x060014C8; D_06001C38 = 0x06001C38; -// ovl_En_Vm - -D_06000068 = 0x06000068; -D_06002728 = 0x06002728; -D_06003F60 = 0x06003F60; - -// ovl_En_Wallmas - -D_06000590 = 0x06000590; -D_06000EA4 = 0x06000EA4; -D_060019CC = 0x060019CC; -D_0600299C = 0x0600299C; -D_060041F4 = 0x060041F4; -D_06008688 = 0x06008688; -D_06008FB0 = 0x06008FB0; -D_06009244 = 0x06009244; -D_06009520 = 0x06009520; -D_06009DB0 = 0x06009DB0; -D_0600A054 = 0x0600A054; - // ovl_En_Wdhand D_060000F4 = 0x060000F4; @@ -1882,10 +1575,6 @@ D_06001690 = 0x06001690; D_06005870 = 0x06005870; D_06005C64 = 0x06005C64; -// ovl_En_Wood02 - -D_06000700 = 0x06000700; - // ovl_En_Zl4 D_06013328 = 0x06013328; @@ -1902,29 +1591,11 @@ D_06000168 = 0x06000168; D_060003F8 = 0x060003F8; D_060004B0 = 0x060004B0; -// ovl_Obj_Armos - -D_0600033C = 0x0600033C; -D_06005948 = 0x06005948; -D_06005CF8 = 0x06005CF8; - -// ovl_Obj_Bigicicle - -D_060009B0 = 0x060009B0; -D_060014F0 = 0x060014F0; - // ovl_Obj_Boat D_06007630 = 0x06007630; D_06009A88 = 0x06009A88; -// ovl_Obj_Chan - -D_06000A10 = 0x06000A10; -D_06000AF0 = 0x06000AF0; -D_06001960 = 0x06001960; -D_06002358 = 0x06002358; - // ovl_Obj_Chikuwa D_06000D10 = 0x06000D10; @@ -1935,34 +1606,10 @@ D_06000F00 = 0x06000F00; D_06000180 = 0x06000180; D_06000BA0 = 0x06000BA0; -// ovl_Obj_Dora - -D_06003FD0 = 0x06003FD0; -D_06004160 = 0x06004160; - -// ovl_Obj_Driftice - -D_060016A0 = 0x060016A0; -D_06001AA8 = 0x06001AA8; - -// ovl_Obj_Entotu - -D_06000158 = 0x06000158; -D_06001C00 = 0x06001C00; - -// ovl_Obj_Hariko - -D_06000080 = 0x06000080; -D_06000110 = 0x06000110; - // ovl_Obj_Jgame_Light D_060003A0 = 0x060003A0; -// ovl_Obj_Kendo_Kanban - -D_06000180 = 0x06000180; - // ovl_Obj_Lift D_06000D10 = 0x06000D10; @@ -1979,10 +1626,6 @@ D_06000030 = 0x06000030; D_06002068 = 0x06002068; D_06002188 = 0x06002188; -// ovl_Obj_Nozoki - -D_060001C0 = 0x060001C0; - // ovl_Obj_Ocarinalift D_06001DB0 = 0x06001DB0; @@ -1993,15 +1636,6 @@ D_060048D0 = 0x060048D0; D_060011E0 = 0x060011E0; -// ovl_Obj_Smork - -D_06001C00 = 0x06001C00; - -// ovl_Obj_Spinyroll - -D_06000460 = 0x06000460; -D_06000E68 = 0x06000E68; - // ovl_Obj_Takaraya_Wall D_06000B70 = 0x06000B70; @@ -2046,21 +1680,11 @@ D_06000098 = 0x06000098; D_06000838 = 0x06000838; D_060022AC = 0x060022AC; -// ovl_Obj_Vspinyroll - -D_06000460 = 0x06000460; -D_06000F80 = 0x06000F80; - // ovl_Obj_Y2lift D_06001680 = 0x06001680; D_060019B0 = 0x060019B0; -// ovl_Obj_Yasi - -D_06000360 = 0x06000360; -D_06001428 = 0x06001428; - // ovl_player_actor D_06008860 = 0x06008860;