From 5c147e5e03e9d693213537101f56d3a6eb53f16a Mon Sep 17 00:00:00 2001 From: Anghelo Carvajal Date: Tue, 27 Jul 2021 22:16:03 -0400 Subject: [PATCH] ZAPD update: Gotta go fast! (#877) * copy over the xml * Rename anims * A bunch of renames * minor extract_assets fixes * git subrepo pull --force tools/ZAPD subrepo: subdir: "tools/ZAPD" merged: "820678b4e" upstream: origin: "https://github.com/zeldaret/ZAPD.git" branch: "master" commit: "820678b4e" git-subrepo: version: "0.4.3" origin: "???" commit: "???" * Change rgb5a1 to rgba16 * eye and eyebrows * some dlists * git subrepo pull --force tools/ZAPD subrepo: subdir: "tools/ZAPD" merged: "6be9af65d" upstream: origin: "https://github.com/zeldaret/ZAPD.git" branch: "master" commit: "6be9af65d" git-subrepo: version: "0.4.3" origin: "???" commit: "???" --- assets/xml/objects/gameplay_dangeon_keep.xml | 26 +- assets/xml/objects/gameplay_field_keep.xml | 28 +- assets/xml/objects/gameplay_keep.xml | 104 +++--- assets/xml/objects/object_Bb.xml | 16 +- assets/xml/objects/object_ahg.xml | 2 +- assets/xml/objects/object_bba.xml | 4 +- assets/xml/objects/object_bg.xml | 16 +- assets/xml/objects/object_bigokuta.xml | 20 +- assets/xml/objects/object_bird.xml | 6 +- assets/xml/objects/object_bji.xml | 8 +- assets/xml/objects/object_bob.xml | 2 +- assets/xml/objects/object_boj.xml | 2 +- assets/xml/objects/object_bombiwa.xml | 2 +- assets/xml/objects/object_box.xml | 8 +- assets/xml/objects/object_brob.xml | 2 +- assets/xml/objects/object_bw.xml | 6 +- assets/xml/objects/object_bwall.xml | 2 +- assets/xml/objects/object_bxa.xml | 4 +- assets/xml/objects/object_cne.xml | 6 +- assets/xml/objects/object_cob.xml | 2 +- assets/xml/objects/object_crow.xml | 6 +- assets/xml/objects/object_cs.xml | 10 +- assets/xml/objects/object_daiku.xml | 6 +- assets/xml/objects/object_dekubaba.xml | 12 +- assets/xml/objects/object_dekujr.xml | 4 +- assets/xml/objects/object_dekunuts.xml | 12 +- assets/xml/objects/object_dh.xml | 12 +- assets/xml/objects/object_dnk.xml | 6 +- assets/xml/objects/object_dns.xml | 6 +- assets/xml/objects/object_dodojr.xml | 8 +- assets/xml/objects/object_dodongo.xml | 12 +- assets/xml/objects/object_ds2.xml | 2 +- assets/xml/objects/object_du.xml | 8 +- assets/xml/objects/object_fa.xml | 4 +- assets/xml/objects/object_fd.xml | 2 +- assets/xml/objects/object_firefly.xml | 20 +- assets/xml/objects/object_fish.xml | 58 ++-- assets/xml/objects/object_fr.xml | 10 +- assets/xml/objects/object_fu.xml | 4 +- assets/xml/objects/object_ganon.xml | 38 +-- assets/xml/objects/object_ganon2.xml | 46 +-- assets/xml/objects/object_ganon_objects.xml | 2 +- assets/xml/objects/object_ge1.xml | 12 +- assets/xml/objects/object_geldb.xml | 2 +- assets/xml/objects/object_gj.xml | 2 +- assets/xml/objects/object_gla.xml | 4 +- assets/xml/objects/object_gnd.xml | 44 +-- assets/xml/objects/object_gndd.xml | 52 +-- assets/xml/objects/object_gol.xml | 10 +- assets/xml/objects/object_goma.xml | 12 +- assets/xml/objects/object_gr.xml | 18 +- assets/xml/objects/object_haka_door.xml | 6 +- assets/xml/objects/object_haka_objects.xml | 32 +- assets/xml/objects/object_hakach_objects.xml | 12 +- assets/xml/objects/object_hata.xml | 4 +- assets/xml/objects/object_hidan_objects.xml | 2 +- assets/xml/objects/object_hni.xml | 20 +- assets/xml/objects/object_horse.xml | 24 +- assets/xml/objects/object_horse_ganon.xml | 6 +- .../xml/objects/object_horse_link_child.xml | 2 +- assets/xml/objects/object_horse_normal.xml | 2 +- assets/xml/objects/object_horse_zelda.xml | 8 +- assets/xml/objects/object_hs.xml | 6 +- assets/xml/objects/object_human.xml | 213 ++++++++++++ assets/xml/objects/object_ice_objects.xml | 8 +- assets/xml/objects/object_im.xml | 16 +- assets/xml/objects/object_in.xml | 18 +- assets/xml/objects/object_jj.xml | 38 +-- assets/xml/objects/object_jya_door.xml | 4 +- assets/xml/objects/object_jya_iron.xml | 4 +- assets/xml/objects/object_jya_obj.xml | 34 +- assets/xml/objects/object_ka.xml | 14 +- assets/xml/objects/object_kingdodongo.xml | 24 +- assets/xml/objects/object_kw1.xml | 4 +- assets/xml/objects/object_lightbox.xml | 4 +- assets/xml/objects/object_lightswitch.xml | 2 +- assets/xml/objects/object_link_child.xml | 70 ++-- assets/xml/objects/object_ma1.xml | 22 +- assets/xml/objects/object_ma2.xml | 20 +- assets/xml/objects/object_mb.xml | 2 +- assets/xml/objects/object_medal.xml | 12 +- assets/xml/objects/object_mjin.xml | 2 +- assets/xml/objects/object_mjin_oka.xml | 2 +- assets/xml/objects/object_mk.xml | 4 +- assets/xml/objects/object_mm.xml | 2 +- assets/xml/objects/object_mori_objects.xml | 4 +- assets/xml/objects/object_mu.xml | 4 +- assets/xml/objects/object_nb.xml | 16 +- assets/xml/objects/object_ny.xml | 6 +- assets/xml/objects/object_oA1.xml | 6 +- assets/xml/objects/object_oA10.xml | 14 +- assets/xml/objects/object_oA11.xml | 6 +- assets/xml/objects/object_oA3.xml | 10 +- assets/xml/objects/object_oA4.xml | 12 +- assets/xml/objects/object_oA5.xml | 12 +- assets/xml/objects/object_oA6.xml | 12 +- assets/xml/objects/object_oA7.xml | 8 +- assets/xml/objects/object_oA8.xml | 4 +- assets/xml/objects/object_oA9.xml | 4 +- assets/xml/objects/object_oB1.xml | 22 +- assets/xml/objects/object_oB2.xml | 20 +- assets/xml/objects/object_oB3.xml | 24 +- assets/xml/objects/object_oB4.xml | 12 +- assets/xml/objects/object_oE1.xml | 10 +- assets/xml/objects/object_oE10.xml | 10 +- assets/xml/objects/object_oE11.xml | 10 +- assets/xml/objects/object_oE12.xml | 14 +- assets/xml/objects/object_oE1s.xml | 8 +- assets/xml/objects/object_oE2.xml | 10 +- assets/xml/objects/object_oE3.xml | 10 +- assets/xml/objects/object_oE4.xml | 8 +- assets/xml/objects/object_oE4s.xml | 8 +- assets/xml/objects/object_oE5.xml | 12 +- assets/xml/objects/object_oE6.xml | 10 +- assets/xml/objects/object_oE7.xml | 8 +- assets/xml/objects/object_oE8.xml | 10 +- assets/xml/objects/object_oE9.xml | 10 +- assets/xml/objects/object_oF1s.xml | 4 +- assets/xml/objects/object_okuta.xml | 20 +- assets/xml/objects/object_os.xml | 4 +- assets/xml/objects/object_ossan.xml | 2 +- assets/xml/objects/object_ps.xml | 14 +- assets/xml/objects/object_pu_box.xml | 2 +- assets/xml/objects/object_rd.xml | 16 +- assets/xml/objects/object_reeba.xml | 6 +- assets/xml/objects/object_rl.xml | 4 +- assets/xml/objects/object_rs.xml | 2 +- assets/xml/objects/object_ru1.xml | 16 +- assets/xml/objects/object_sa.xml | 12 +- assets/xml/objects/object_sb.xml | 12 +- assets/xml/objects/object_sd.xml | 4 +- assets/xml/objects/object_shop_dungen.xml | 4 +- assets/xml/objects/object_skb.xml | 18 +- assets/xml/objects/object_skj.xml | 6 +- assets/xml/objects/object_spot02_objects.xml | 12 +- assets/xml/objects/object_spot05_objects.xml | 4 +- assets/xml/objects/object_spot07_object.xml | 10 +- assets/xml/objects/object_spot11_obj.xml | 4 +- assets/xml/objects/object_spot17_obj.xml | 2 +- assets/xml/objects/object_ssh.xml | 2 +- assets/xml/objects/object_sst.xml | 4 +- assets/xml/objects/object_st.xml | 14 +- assets/xml/objects/object_syokudai.xml | 10 +- assets/xml/objects/object_ta.xml | 8 +- assets/xml/objects/object_tite.xml | 4 +- assets/xml/objects/object_tk.xml | 6 +- assets/xml/objects/object_toryo.xml | 4 +- assets/xml/objects/object_tp.xml | 8 +- assets/xml/objects/object_tr.xml | 30 +- assets/xml/objects/object_ts.xml | 2 +- assets/xml/objects/object_tsubo.xml | 6 +- assets/xml/objects/object_vase.xml | 4 +- assets/xml/objects/object_wallmaster.xml | 14 +- assets/xml/objects/object_wf.xml | 20 +- assets/xml/objects/object_wood02.xml | 6 +- assets/xml/objects/object_ydan_objects.xml | 16 +- assets/xml/objects/object_zf.xml | 32 +- assets/xml/objects/object_zl2.xml | 26 +- assets/xml/objects/object_zo.xml | 10 +- assets/xml/overlays/ovl_Boss_Dodongo.xml | 4 +- assets/xml/overlays/ovl_En_Jsjutan.xml | 2 +- assets/xml/scenes/dungeons/ddan_boss.xml | 2 +- .../xml/textures/icon_item_dungeon_static.xml | 4 +- .../xml/textures/icon_item_field_static.xml | 2 +- assets/xml/textures/parameter_static.xml | 6 +- extract_assets.py | 31 +- spec | 3 +- tools/ZAPD/.gitrepo | 4 +- tools/ZAPD/Jenkinsfile | 30 ++ tools/ZAPD/Makefile | 47 +-- tools/ZAPD/README.md | 15 +- tools/ZAPD/ZAPD/BitConverter.h | 12 +- tools/ZAPD/ZAPD/Directory.h | 2 +- tools/ZAPD/ZAPD/File.h | 13 +- tools/ZAPD/ZAPD/Globals.cpp | 3 +- tools/ZAPD/ZAPD/Globals.h | 3 + .../ZAPD/HighLevel/HLModelIntermediette.cpp | 4 +- tools/ZAPD/ZAPD/Main.cpp | 52 ++- tools/ZAPD/ZAPD/StringHelper.h | 12 +- tools/ZAPD/ZAPD/ZAnimation.cpp | 195 ++++++++++- tools/ZAPD/ZAPD/ZAnimation.h | 50 ++- tools/ZAPD/ZAPD/ZArray.cpp | 4 +- tools/ZAPD/ZAPD/ZBackground.cpp | 10 +- tools/ZAPD/ZAPD/ZBackground.h | 7 +- tools/ZAPD/ZAPD/ZBlob.cpp | 3 +- tools/ZAPD/ZAPD/ZCollision.cpp | 33 +- tools/ZAPD/ZAPD/ZCutscene.cpp | 9 +- tools/ZAPD/ZAPD/ZCutscene.h | 3 +- tools/ZAPD/ZAPD/ZCutsceneMM.cpp | 6 +- tools/ZAPD/ZAPD/ZCutsceneMM.h | 3 +- tools/ZAPD/ZAPD/ZDisplayList.cpp | 101 +++--- tools/ZAPD/ZAPD/ZDisplayList.h | 20 +- tools/ZAPD/ZAPD/ZFile.cpp | 105 +++--- tools/ZAPD/ZAPD/ZFile.h | 15 +- tools/ZAPD/ZAPD/ZLimb.cpp | 190 ++++++++--- tools/ZAPD/ZAPD/ZLimb.h | 17 +- tools/ZAPD/ZAPD/ZMtx.cpp | 12 +- tools/ZAPD/ZAPD/ZMtx.h | 6 +- tools/ZAPD/ZAPD/ZPath.cpp | 6 +- tools/ZAPD/ZAPD/ZPath.h | 3 +- tools/ZAPD/ZAPD/ZResource.cpp | 17 +- tools/ZAPD/ZAPD/ZResource.h | 9 +- .../Commands/SetAnimatedMaterialList.cpp | 17 +- .../ZRoom/Commands/SetCollisionHeader.cpp | 1 - .../ZAPD/ZAPD/ZRoom/Commands/SetCsCamera.cpp | 1 - .../ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.cpp | 4 +- tools/ZAPD/ZAPD/ZRoom/Commands/SetMesh.cpp | 24 +- tools/ZAPD/ZAPD/ZRoom/Commands/SetMesh.h | 3 - tools/ZAPD/ZAPD/ZRoom/ZRoom.cpp | 18 +- tools/ZAPD/ZAPD/ZRoom/ZRoom.h | 3 +- tools/ZAPD/ZAPD/ZScalar.cpp | 37 +++ tools/ZAPD/ZAPD/ZScalar.h | 4 + tools/ZAPD/ZAPD/ZSkeleton.cpp | 314 +++++++++++------- tools/ZAPD/ZAPD/ZSkeleton.h | 55 ++- tools/ZAPD/ZAPD/ZString.cpp | 5 +- tools/ZAPD/ZAPD/ZSymbol.cpp | 6 - tools/ZAPD/ZAPD/ZSymbol.h | 3 - tools/ZAPD/ZAPD/ZTexture.cpp | 44 ++- tools/ZAPD/ZAPD/ZTexture.h | 7 +- tools/ZAPD/ZAPD/ZVector.cpp | 1 - tools/ZAPD/ZAPD/ZVtx.cpp | 3 + tools/ZAPD/ZAPD/genbuildinfo.py | 8 +- .../docs/zapd_extraction_xml_reference.md | 51 ++- tools/ZAPD/lib/libgfxd/.gitrepo | 4 +- tools/ZAPD/lib/libgfxd/gbi.h | 26 +- tools/ZAPD/lib/libgfxd/uc_macrofn.c | 37 ++- 226 files changed, 2350 insertions(+), 1492 deletions(-) create mode 100644 assets/xml/objects/object_human.xml diff --git a/assets/xml/objects/gameplay_dangeon_keep.xml b/assets/xml/objects/gameplay_dangeon_keep.xml index dfe90bba74..d973327ac3 100644 --- a/assets/xml/objects/gameplay_dangeon_keep.xml +++ b/assets/xml/objects/gameplay_dangeon_keep.xml @@ -2,10 +2,10 @@ - + - + @@ -31,19 +31,19 @@ - - - - - - - - + + + + + + + + - - - + + + diff --git a/assets/xml/objects/gameplay_field_keep.xml b/assets/xml/objects/gameplay_field_keep.xml index 4fc91d8ee6..c9a2378cbb 100644 --- a/assets/xml/objects/gameplay_field_keep.xml +++ b/assets/xml/objects/gameplay_field_keep.xml @@ -8,8 +8,8 @@ - - + + @@ -20,39 +20,39 @@ - + - + - - + + - - - + + + - + - + - - + + - + diff --git a/assets/xml/objects/gameplay_keep.xml b/assets/xml/objects/gameplay_keep.xml index 99e9cf1ac5..ce960a3765 100644 --- a/assets/xml/objects/gameplay_keep.xml +++ b/assets/xml/objects/gameplay_keep.xml @@ -1,12 +1,12 @@ - - - - - + + + + + - + @@ -614,17 +614,17 @@ - - + + - + - + @@ -638,7 +638,7 @@ - + @@ -651,15 +651,15 @@ - - + + - + @@ -687,19 +687,19 @@ - + - + - - + + @@ -837,12 +837,12 @@ - - + + - - + + @@ -875,37 +875,37 @@ - - - - - + + + + + - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + @@ -916,7 +916,7 @@ - + diff --git a/assets/xml/objects/object_Bb.xml b/assets/xml/objects/object_Bb.xml index 67b134182a..5d04bde451 100644 --- a/assets/xml/objects/object_Bb.xml +++ b/assets/xml/objects/object_Bb.xml @@ -9,14 +9,14 @@ - - - - - - - - + + + + + + + + diff --git a/assets/xml/objects/object_ahg.xml b/assets/xml/objects/object_ahg.xml index fa822377d6..803912a8c9 100644 --- a/assets/xml/objects/object_ahg.xml +++ b/assets/xml/objects/object_ahg.xml @@ -25,7 +25,7 @@ - - - - - + + + + + - - - + + + diff --git a/assets/xml/objects/object_bigokuta.xml b/assets/xml/objects/object_bigokuta.xml index 04740c2e0a..1c7d39e319 100644 --- a/assets/xml/objects/object_bigokuta.xml +++ b/assets/xml/objects/object_bigokuta.xml @@ -24,16 +24,16 @@ - - - - - - - - - - + + + + + + + + + + diff --git a/assets/xml/objects/object_bird.xml b/assets/xml/objects/object_bird.xml index 47ab0669c0..167a5022dc 100644 --- a/assets/xml/objects/object_bird.xml +++ b/assets/xml/objects/object_bird.xml @@ -13,9 +13,9 @@ - - - + + + diff --git a/assets/xml/objects/object_bji.xml b/assets/xml/objects/object_bji.xml index b628a641ed..3b993ca295 100644 --- a/assets/xml/objects/object_bji.xml +++ b/assets/xml/objects/object_bji.xml @@ -25,7 +25,7 @@ - - - + + + diff --git a/assets/xml/objects/object_bob.xml b/assets/xml/objects/object_bob.xml index 20234a0149..0aab07b21a 100644 --- a/assets/xml/objects/object_bob.xml +++ b/assets/xml/objects/object_bob.xml @@ -16,7 +16,7 @@ - + diff --git a/assets/xml/objects/object_boj.xml b/assets/xml/objects/object_boj.xml index 7bf2d9e7b5..10c97c4f68 100644 --- a/assets/xml/objects/object_boj.xml +++ b/assets/xml/objects/object_boj.xml @@ -25,7 +25,7 @@ - - + + diff --git a/assets/xml/objects/object_cob.xml b/assets/xml/objects/object_cob.xml index 0724ae670c..78b7327aa5 100644 --- a/assets/xml/objects/object_cob.xml +++ b/assets/xml/objects/object_cob.xml @@ -1,6 +1,6 @@ - + diff --git a/assets/xml/objects/object_crow.xml b/assets/xml/objects/object_crow.xml index 0d88355c9f..77337c6445 100644 --- a/assets/xml/objects/object_crow.xml +++ b/assets/xml/objects/object_crow.xml @@ -2,9 +2,9 @@ - - - + + + diff --git a/assets/xml/objects/object_cs.xml b/assets/xml/objects/object_cs.xml index 814bb5c337..c5d2688d06 100644 --- a/assets/xml/objects/object_cs.xml +++ b/assets/xml/objects/object_cs.xml @@ -39,11 +39,11 @@ - - - + + + - + @@ -51,7 +51,7 @@ - + diff --git a/assets/xml/objects/object_daiku.xml b/assets/xml/objects/object_daiku.xml index 49eee02cb8..cc437a3762 100644 --- a/assets/xml/objects/object_daiku.xml +++ b/assets/xml/objects/object_daiku.xml @@ -3,15 +3,15 @@ - + - + - + diff --git a/assets/xml/objects/object_dekubaba.xml b/assets/xml/objects/object_dekubaba.xml index 02dd3451e1..7202a833fc 100644 --- a/assets/xml/objects/object_dekubaba.xml +++ b/assets/xml/objects/object_dekubaba.xml @@ -13,11 +13,11 @@ - - - - - + + + + + @@ -33,6 +33,6 @@ - + diff --git a/assets/xml/objects/object_dekujr.xml b/assets/xml/objects/object_dekujr.xml index 0d01359fab..e4141a50ba 100644 --- a/assets/xml/objects/object_dekujr.xml +++ b/assets/xml/objects/object_dekujr.xml @@ -1,8 +1,8 @@ - + - + diff --git a/assets/xml/objects/object_dekunuts.xml b/assets/xml/objects/object_dekunuts.xml index ad2e59d80a..5fceef4165 100644 --- a/assets/xml/objects/object_dekunuts.xml +++ b/assets/xml/objects/object_dekunuts.xml @@ -16,17 +16,17 @@ - - - - - + + + + + - + diff --git a/assets/xml/objects/object_dh.xml b/assets/xml/objects/object_dh.xml index 65095069d9..7a52d7dbe7 100644 --- a/assets/xml/objects/object_dh.xml +++ b/assets/xml/objects/object_dh.xml @@ -7,8 +7,8 @@ - - + + @@ -17,10 +17,10 @@ - - - - + + + + diff --git a/assets/xml/objects/object_dnk.xml b/assets/xml/objects/object_dnk.xml index 8d903af86d..b1e79464b8 100644 --- a/assets/xml/objects/object_dnk.xml +++ b/assets/xml/objects/object_dnk.xml @@ -12,9 +12,9 @@ - - - + + + diff --git a/assets/xml/objects/object_dns.xml b/assets/xml/objects/object_dns.xml index b0d821e5af..086c4bd11c 100644 --- a/assets/xml/objects/object_dns.xml +++ b/assets/xml/objects/object_dns.xml @@ -13,9 +13,9 @@ - - - + + + diff --git a/assets/xml/objects/object_dodojr.xml b/assets/xml/objects/object_dodojr.xml index e09acc957e..4dfd7d6e45 100644 --- a/assets/xml/objects/object_dodojr.xml +++ b/assets/xml/objects/object_dodojr.xml @@ -10,10 +10,10 @@ - - - - + + + + diff --git a/assets/xml/objects/object_dodongo.xml b/assets/xml/objects/object_dodongo.xml index e114e1a16d..779e20e9dc 100644 --- a/assets/xml/objects/object_dodongo.xml +++ b/assets/xml/objects/object_dodongo.xml @@ -19,12 +19,12 @@ - - - - - - + + + + + + diff --git a/assets/xml/objects/object_ds2.xml b/assets/xml/objects/object_ds2.xml index 2c7c64897a..d036cf564b 100644 --- a/assets/xml/objects/object_ds2.xml +++ b/assets/xml/objects/object_ds2.xml @@ -9,7 +9,7 @@ - + diff --git a/assets/xml/objects/object_du.xml b/assets/xml/objects/object_du.xml index a9bd13f7d8..5982f84810 100644 --- a/assets/xml/objects/object_du.xml +++ b/assets/xml/objects/object_du.xml @@ -57,10 +57,10 @@ - - - - + + + + diff --git a/assets/xml/objects/object_fa.xml b/assets/xml/objects/object_fa.xml index aef62fee6b..4e2e2c6b1c 100644 --- a/assets/xml/objects/object_fa.xml +++ b/assets/xml/objects/object_fa.xml @@ -1,12 +1,12 @@ - + - + diff --git a/assets/xml/objects/object_fd.xml b/assets/xml/objects/object_fd.xml index 95dfffd6e4..d63b6b474c 100644 --- a/assets/xml/objects/object_fd.xml +++ b/assets/xml/objects/object_fd.xml @@ -61,7 +61,7 @@ - + diff --git a/assets/xml/objects/object_firefly.xml b/assets/xml/objects/object_firefly.xml index 6785a5396b..8c26a43418 100644 --- a/assets/xml/objects/object_firefly.xml +++ b/assets/xml/objects/object_firefly.xml @@ -6,16 +6,16 @@ - - - - - + + + + + - - - - - + + + + + diff --git a/assets/xml/objects/object_fish.xml b/assets/xml/objects/object_fish.xml index 8a23f45a11..c10b0fe33d 100644 --- a/assets/xml/objects/object_fish.xml +++ b/assets/xml/objects/object_fish.xml @@ -13,13 +13,13 @@ - - - - - - - + + + + + + + @@ -37,8 +37,8 @@ - - + + @@ -58,7 +58,7 @@ - + @@ -90,7 +90,7 @@ - + @@ -110,12 +110,12 @@ - + - + @@ -129,12 +129,12 @@ - - - - - - + + + + + + @@ -148,31 +148,31 @@ - - - + + + - - + + - - + + - + - - + + diff --git a/assets/xml/objects/object_fr.xml b/assets/xml/objects/object_fr.xml index 139731cfd1..c8533dd6ba 100644 --- a/assets/xml/objects/object_fr.xml +++ b/assets/xml/objects/object_fr.xml @@ -3,13 +3,13 @@ - + - - - - + + + + diff --git a/assets/xml/objects/object_fu.xml b/assets/xml/objects/object_fu.xml index 8033efb9a9..7692c41f27 100644 --- a/assets/xml/objects/object_fu.xml +++ b/assets/xml/objects/object_fu.xml @@ -17,8 +17,8 @@ - - + + diff --git a/assets/xml/objects/object_ganon.xml b/assets/xml/objects/object_ganon.xml index 88434d28b3..b880161b2b 100644 --- a/assets/xml/objects/object_ganon.xml +++ b/assets/xml/objects/object_ganon.xml @@ -21,34 +21,34 @@ - - - + + + - + - + - + - + - - - - - - - - - - - + + + + + + + + + + + - + diff --git a/assets/xml/objects/object_ganon2.xml b/assets/xml/objects/object_ganon2.xml index 4dc569887d..7e5c79ec05 100644 --- a/assets/xml/objects/object_ganon2.xml +++ b/assets/xml/objects/object_ganon2.xml @@ -45,43 +45,43 @@ - - + + - - - - - - - - - + + + + + + + + + - - + + - + - + - + - - + + - - - + + + - - + + diff --git a/assets/xml/objects/object_ganon_objects.xml b/assets/xml/objects/object_ganon_objects.xml index 0fe106db72..5e32610ffc 100644 --- a/assets/xml/objects/object_ganon_objects.xml +++ b/assets/xml/objects/object_ganon_objects.xml @@ -1,6 +1,6 @@ - + diff --git a/assets/xml/objects/object_ge1.xml b/assets/xml/objects/object_ge1.xml index b5965f2124..ca5d682a2c 100644 --- a/assets/xml/objects/object_ge1.xml +++ b/assets/xml/objects/object_ge1.xml @@ -39,8 +39,8 @@ - - + + @@ -54,7 +54,7 @@ - + @@ -65,9 +65,9 @@ - - - + + + diff --git a/assets/xml/objects/object_geldb.xml b/assets/xml/objects/object_geldb.xml index 69afc7d34e..343abdfc7c 100644 --- a/assets/xml/objects/object_geldb.xml +++ b/assets/xml/objects/object_geldb.xml @@ -22,7 +22,7 @@ - + diff --git a/assets/xml/objects/object_gj.xml b/assets/xml/objects/object_gj.xml index c15a32f9b3..50d6337b4a 100644 --- a/assets/xml/objects/object_gj.xml +++ b/assets/xml/objects/object_gj.xml @@ -29,7 +29,7 @@ - + diff --git a/assets/xml/objects/object_gla.xml b/assets/xml/objects/object_gla.xml index 36d26d6a40..6a041d2448 100644 --- a/assets/xml/objects/object_gla.xml +++ b/assets/xml/objects/object_gla.xml @@ -47,8 +47,8 @@ - - + + diff --git a/assets/xml/objects/object_gnd.xml b/assets/xml/objects/object_gnd.xml index 3b8354cc5e..0697c2af1c 100644 --- a/assets/xml/objects/object_gnd.xml +++ b/assets/xml/objects/object_gnd.xml @@ -39,28 +39,28 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_gndd.xml b/assets/xml/objects/object_gndd.xml index c2ec4bce5a..fc76de6a6b 100644 --- a/assets/xml/objects/object_gndd.xml +++ b/assets/xml/objects/object_gndd.xml @@ -37,35 +37,35 @@ - - - - + + + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - + + diff --git a/assets/xml/objects/object_gol.xml b/assets/xml/objects/object_gol.xml index 64b0a49ae7..48978799ae 100644 --- a/assets/xml/objects/object_gol.xml +++ b/assets/xml/objects/object_gol.xml @@ -18,11 +18,11 @@ - - - - - + + + + + diff --git a/assets/xml/objects/object_goma.xml b/assets/xml/objects/object_goma.xml index 6ab63133d2..51ad70634a 100644 --- a/assets/xml/objects/object_goma.xml +++ b/assets/xml/objects/object_goma.xml @@ -28,12 +28,12 @@ - - - - - - + + + + + + diff --git a/assets/xml/objects/object_gr.xml b/assets/xml/objects/object_gr.xml index 77bd0955c7..103d4412e9 100644 --- a/assets/xml/objects/object_gr.xml +++ b/assets/xml/objects/object_gr.xml @@ -3,14 +3,14 @@ - - - - - - - - - + + + + + + + + + diff --git a/assets/xml/objects/object_haka_door.xml b/assets/xml/objects/object_haka_door.xml index 7c021c113a..7534924457 100644 --- a/assets/xml/objects/object_haka_door.xml +++ b/assets/xml/objects/object_haka_door.xml @@ -1,12 +1,12 @@ - + - + - + diff --git a/assets/xml/objects/object_haka_objects.xml b/assets/xml/objects/object_haka_objects.xml index 5c0b03cc60..d76cb3b7c4 100644 --- a/assets/xml/objects/object_haka_objects.xml +++ b/assets/xml/objects/object_haka_objects.xml @@ -53,33 +53,33 @@ - - - - - - + + + + + + - - - - + + + + - - + + - + - - + + - + diff --git a/assets/xml/objects/object_hakach_objects.xml b/assets/xml/objects/object_hakach_objects.xml index 5a374e9285..b978e77a31 100644 --- a/assets/xml/objects/object_hakach_objects.xml +++ b/assets/xml/objects/object_hakach_objects.xml @@ -16,13 +16,13 @@ - - + + - - - - + + + + diff --git a/assets/xml/objects/object_hata.xml b/assets/xml/objects/object_hata.xml index 0c2c30677d..b0324c3be3 100644 --- a/assets/xml/objects/object_hata.xml +++ b/assets/xml/objects/object_hata.xml @@ -43,8 +43,8 @@ - - + + diff --git a/assets/xml/objects/object_hidan_objects.xml b/assets/xml/objects/object_hidan_objects.xml index 6d13e86b5f..76b7921abf 100644 --- a/assets/xml/objects/object_hidan_objects.xml +++ b/assets/xml/objects/object_hidan_objects.xml @@ -83,7 +83,7 @@ - + diff --git a/assets/xml/objects/object_hni.xml b/assets/xml/objects/object_hni.xml index 99c034f661..7f4f8a381d 100644 --- a/assets/xml/objects/object_hni.xml +++ b/assets/xml/objects/object_hni.xml @@ -14,7 +14,7 @@ - + @@ -23,18 +23,18 @@ - - + + - - + + - - + + @@ -42,10 +42,10 @@ - - + + - + diff --git a/assets/xml/objects/object_horse.xml b/assets/xml/objects/object_horse.xml index 0c2e70bd50..dbfdea96d6 100644 --- a/assets/xml/objects/object_horse.xml +++ b/assets/xml/objects/object_horse.xml @@ -12,14 +12,14 @@ - - + + - - - - + + + + @@ -30,10 +30,10 @@ - - - - + + + + @@ -43,14 +43,14 @@ - + - + diff --git a/assets/xml/objects/object_horse_ganon.xml b/assets/xml/objects/object_horse_ganon.xml index b2766fea80..22347ee2bd 100644 --- a/assets/xml/objects/object_horse_ganon.xml +++ b/assets/xml/objects/object_horse_ganon.xml @@ -15,8 +15,8 @@ - - - + + + diff --git a/assets/xml/objects/object_horse_link_child.xml b/assets/xml/objects/object_horse_link_child.xml index a6ba3dda85..3901215f60 100644 --- a/assets/xml/objects/object_horse_link_child.xml +++ b/assets/xml/objects/object_horse_link_child.xml @@ -13,7 +13,7 @@ - + diff --git a/assets/xml/objects/object_horse_normal.xml b/assets/xml/objects/object_horse_normal.xml index 1ebbf834bb..2bc2cb0c60 100644 --- a/assets/xml/objects/object_horse_normal.xml +++ b/assets/xml/objects/object_horse_normal.xml @@ -21,6 +21,6 @@ - + diff --git a/assets/xml/objects/object_horse_zelda.xml b/assets/xml/objects/object_horse_zelda.xml index 5773d952ed..98bf2f763f 100644 --- a/assets/xml/objects/object_horse_zelda.xml +++ b/assets/xml/objects/object_horse_zelda.xml @@ -5,10 +5,10 @@ - - - + + + - + diff --git a/assets/xml/objects/object_hs.xml b/assets/xml/objects/object_hs.xml index 9b8765abdc..da11d57fb3 100644 --- a/assets/xml/objects/object_hs.xml +++ b/assets/xml/objects/object_hs.xml @@ -15,14 +15,14 @@ - + - + - + diff --git a/assets/xml/objects/object_human.xml b/assets/xml/objects/object_human.xml new file mode 100644 index 0000000000..7736140f1a --- /dev/null +++ b/assets/xml/objects/object_human.xml @@ -0,0 +1,213 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_ice_objects.xml b/assets/xml/objects/object_ice_objects.xml index abaa53ad5d..ee8fb94ce2 100644 --- a/assets/xml/objects/object_ice_objects.xml +++ b/assets/xml/objects/object_ice_objects.xml @@ -12,14 +12,14 @@ - + - - + + - + diff --git a/assets/xml/objects/object_im.xml b/assets/xml/objects/object_im.xml index c1dd7dc1ec..e261066fd1 100644 --- a/assets/xml/objects/object_im.xml +++ b/assets/xml/objects/object_im.xml @@ -4,7 +4,7 @@ - + @@ -16,8 +16,8 @@ - - + + @@ -29,15 +29,15 @@ - - + + - - + + - + diff --git a/assets/xml/objects/object_in.xml b/assets/xml/objects/object_in.xml index 3933e6e642..7b788efd0b 100644 --- a/assets/xml/objects/object_in.xml +++ b/assets/xml/objects/object_in.xml @@ -4,8 +4,8 @@ - - + + @@ -17,15 +17,15 @@ - + - + - + - + @@ -51,8 +51,8 @@ - - + + @@ -61,7 +61,7 @@ - + diff --git a/assets/xml/objects/object_jj.xml b/assets/xml/objects/object_jj.xml index 8d3ff78f42..62bae8cb91 100644 --- a/assets/xml/objects/object_jj.xml +++ b/assets/xml/objects/object_jj.xml @@ -5,9 +5,9 @@ - - - + + + @@ -50,22 +50,22 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_jya_door.xml b/assets/xml/objects/object_jya_door.xml index 7f6a1c66f2..60a7b37886 100644 --- a/assets/xml/objects/object_jya_door.xml +++ b/assets/xml/objects/object_jya_door.xml @@ -2,7 +2,7 @@ - - + + diff --git a/assets/xml/objects/object_jya_iron.xml b/assets/xml/objects/object_jya_iron.xml index 2b7101c19b..c6f6773c6a 100644 --- a/assets/xml/objects/object_jya_iron.xml +++ b/assets/xml/objects/object_jya_iron.xml @@ -7,7 +7,7 @@ - - + + diff --git a/assets/xml/objects/object_jya_obj.xml b/assets/xml/objects/object_jya_obj.xml index fa1e8f2b93..1ae5113cfe 100644 --- a/assets/xml/objects/object_jya_obj.xml +++ b/assets/xml/objects/object_jya_obj.xml @@ -2,8 +2,8 @@ - - + + @@ -17,27 +17,27 @@ - + - - - - + + + + - - + + - - - + + + @@ -55,14 +55,14 @@ - + - + - + - - + + diff --git a/assets/xml/objects/object_ka.xml b/assets/xml/objects/object_ka.xml index 8956c59fed..eb952732b4 100644 --- a/assets/xml/objects/object_ka.xml +++ b/assets/xml/objects/object_ka.xml @@ -24,13 +24,13 @@ - - - - - - - + + + + + + + diff --git a/assets/xml/objects/object_kingdodongo.xml b/assets/xml/objects/object_kingdodongo.xml index a0b85a458c..970a6fe056 100644 --- a/assets/xml/objects/object_kingdodongo.xml +++ b/assets/xml/objects/object_kingdodongo.xml @@ -37,17 +37,17 @@ - - - - - - - - - - - + + + + + + + + + + + @@ -106,7 +106,7 @@ - + diff --git a/assets/xml/objects/object_kw1.xml b/assets/xml/objects/object_kw1.xml index f9c9f59312..b56355136a 100644 --- a/assets/xml/objects/object_kw1.xml +++ b/assets/xml/objects/object_kw1.xml @@ -25,14 +25,14 @@ + + + + + - - - - + + + + - - - - + + + + - - - + + + - - - - - + + + + + diff --git a/assets/xml/objects/object_ma1.xml b/assets/xml/objects/object_ma1.xml index 0d68f2d04b..5e6d058fa3 100644 --- a/assets/xml/objects/object_ma1.xml +++ b/assets/xml/objects/object_ma1.xml @@ -25,23 +25,23 @@ - + - - + + - - - - + + + + - - - + + + - + diff --git a/assets/xml/objects/object_ma2.xml b/assets/xml/objects/object_ma2.xml index 8d2ce93535..6951763a83 100644 --- a/assets/xml/objects/object_ma2.xml +++ b/assets/xml/objects/object_ma2.xml @@ -1,26 +1,26 @@ - - + + - + - + - - - - + + + + - + - + diff --git a/assets/xml/objects/object_mb.xml b/assets/xml/objects/object_mb.xml index a321bfb977..35e72fc641 100644 --- a/assets/xml/objects/object_mb.xml +++ b/assets/xml/objects/object_mb.xml @@ -39,7 +39,7 @@ - + diff --git a/assets/xml/objects/object_medal.xml b/assets/xml/objects/object_medal.xml index b2e87315ec..533872a551 100644 --- a/assets/xml/objects/object_medal.xml +++ b/assets/xml/objects/object_medal.xml @@ -7,11 +7,11 @@ - - - - - - + + + + + + diff --git a/assets/xml/objects/object_mjin.xml b/assets/xml/objects/object_mjin.xml index 0b817558a0..daf9b05412 100644 --- a/assets/xml/objects/object_mjin.xml +++ b/assets/xml/objects/object_mjin.xml @@ -2,7 +2,7 @@ - + diff --git a/assets/xml/objects/object_mjin_oka.xml b/assets/xml/objects/object_mjin_oka.xml index a5fb318d26..0f823b9237 100644 --- a/assets/xml/objects/object_mjin_oka.xml +++ b/assets/xml/objects/object_mjin_oka.xml @@ -2,7 +2,7 @@ - + diff --git a/assets/xml/objects/object_mk.xml b/assets/xml/objects/object_mk.xml index 3849bd075d..34733090c5 100644 --- a/assets/xml/objects/object_mk.xml +++ b/assets/xml/objects/object_mk.xml @@ -16,13 +16,13 @@ - + - + diff --git a/assets/xml/objects/object_mm.xml b/assets/xml/objects/object_mm.xml index 63ae005478..edd870330d 100644 --- a/assets/xml/objects/object_mm.xml +++ b/assets/xml/objects/object_mm.xml @@ -9,7 +9,7 @@ - + diff --git a/assets/xml/objects/object_mori_objects.xml b/assets/xml/objects/object_mori_objects.xml index cb0f768c1a..59425adb8d 100644 --- a/assets/xml/objects/object_mori_objects.xml +++ b/assets/xml/objects/object_mori_objects.xml @@ -1,8 +1,8 @@ - + - + diff --git a/assets/xml/objects/object_mu.xml b/assets/xml/objects/object_mu.xml index ef9a51e511..b18046d6ae 100644 --- a/assets/xml/objects/object_mu.xml +++ b/assets/xml/objects/object_mu.xml @@ -1,7 +1,7 @@ - + @@ -42,7 +42,7 @@ - + diff --git a/assets/xml/objects/object_nb.xml b/assets/xml/objects/object_nb.xml index a957c751bd..81b538d05d 100644 --- a/assets/xml/objects/object_nb.xml +++ b/assets/xml/objects/object_nb.xml @@ -45,9 +45,9 @@ - - - + + + @@ -55,13 +55,13 @@ - + - + - + @@ -70,7 +70,7 @@ - + @@ -78,7 +78,7 @@ - + diff --git a/assets/xml/objects/object_ny.xml b/assets/xml/objects/object_ny.xml index cec28d9577..e2e8187ff8 100644 --- a/assets/xml/objects/object_ny.xml +++ b/assets/xml/objects/object_ny.xml @@ -1,8 +1,8 @@ - - - + + + diff --git a/assets/xml/objects/object_oA1.xml b/assets/xml/objects/object_oA1.xml index d802e992e8..212a3aca7e 100644 --- a/assets/xml/objects/object_oA1.xml +++ b/assets/xml/objects/object_oA1.xml @@ -54,7 +54,7 @@ - + @@ -63,7 +63,7 @@ - - + + diff --git a/assets/xml/objects/object_oA10.xml b/assets/xml/objects/object_oA10.xml index 9c18a4cdfa..65d0808349 100644 --- a/assets/xml/objects/object_oA10.xml +++ b/assets/xml/objects/object_oA10.xml @@ -54,13 +54,13 @@ - - + + - - - - - + + + + + diff --git a/assets/xml/objects/object_oA11.xml b/assets/xml/objects/object_oA11.xml index 76d8649b78..652d931566 100644 --- a/assets/xml/objects/object_oA11.xml +++ b/assets/xml/objects/object_oA11.xml @@ -58,9 +58,9 @@ - + - - + + diff --git a/assets/xml/objects/object_oA3.xml b/assets/xml/objects/object_oA3.xml index a28c9de2cb..a492bd8751 100644 --- a/assets/xml/objects/object_oA3.xml +++ b/assets/xml/objects/object_oA3.xml @@ -2,10 +2,10 @@ - - - - - + + + + + diff --git a/assets/xml/objects/object_oA4.xml b/assets/xml/objects/object_oA4.xml index 344bcd1f55..dcdbbfff9b 100644 --- a/assets/xml/objects/object_oA4.xml +++ b/assets/xml/objects/object_oA4.xml @@ -54,11 +54,11 @@ - - - - - - + + + + + + diff --git a/assets/xml/objects/object_oA5.xml b/assets/xml/objects/object_oA5.xml index c05a7fd55e..55072176dd 100644 --- a/assets/xml/objects/object_oA5.xml +++ b/assets/xml/objects/object_oA5.xml @@ -54,11 +54,11 @@ - - - - - - + + + + + + diff --git a/assets/xml/objects/object_oA6.xml b/assets/xml/objects/object_oA6.xml index a2008b705e..c17a510881 100644 --- a/assets/xml/objects/object_oA6.xml +++ b/assets/xml/objects/object_oA6.xml @@ -54,11 +54,11 @@ - - - - - - + + + + + + diff --git a/assets/xml/objects/object_oA7.xml b/assets/xml/objects/object_oA7.xml index e7f19c52ba..52c68f6394 100644 --- a/assets/xml/objects/object_oA7.xml +++ b/assets/xml/objects/object_oA7.xml @@ -54,9 +54,9 @@ - - - - + + + + diff --git a/assets/xml/objects/object_oA8.xml b/assets/xml/objects/object_oA8.xml index ada9844268..8ed2d3df50 100644 --- a/assets/xml/objects/object_oA8.xml +++ b/assets/xml/objects/object_oA8.xml @@ -54,8 +54,8 @@ - - + + diff --git a/assets/xml/objects/object_oA9.xml b/assets/xml/objects/object_oA9.xml index 663c554fca..d5c16abfcd 100644 --- a/assets/xml/objects/object_oA9.xml +++ b/assets/xml/objects/object_oA9.xml @@ -1,7 +1,7 @@ - - + + diff --git a/assets/xml/objects/object_oB1.xml b/assets/xml/objects/object_oB1.xml index 58e9f852a7..2f50c967b2 100644 --- a/assets/xml/objects/object_oB1.xml +++ b/assets/xml/objects/object_oB1.xml @@ -54,16 +54,16 @@ - - - - - - - - - - - + + + + + + + + + + + diff --git a/assets/xml/objects/object_oB2.xml b/assets/xml/objects/object_oB2.xml index f05ef79df8..32e60fd1cf 100644 --- a/assets/xml/objects/object_oB2.xml +++ b/assets/xml/objects/object_oB2.xml @@ -62,15 +62,15 @@ - - - - - - - - - - + + + + + + + + + + diff --git a/assets/xml/objects/object_oB3.xml b/assets/xml/objects/object_oB3.xml index b5e6a30de7..1c42ddaccc 100644 --- a/assets/xml/objects/object_oB3.xml +++ b/assets/xml/objects/object_oB3.xml @@ -54,17 +54,17 @@ - - - - - - - - - - - - + + + + + + + + + + + + diff --git a/assets/xml/objects/object_oB4.xml b/assets/xml/objects/object_oB4.xml index ba710a9043..2924c9e753 100644 --- a/assets/xml/objects/object_oB4.xml +++ b/assets/xml/objects/object_oB4.xml @@ -54,11 +54,11 @@ - - - - - - + + + + + + diff --git a/assets/xml/objects/object_oE1.xml b/assets/xml/objects/object_oE1.xml index 88afa53dc8..f03afa5844 100644 --- a/assets/xml/objects/object_oE1.xml +++ b/assets/xml/objects/object_oE1.xml @@ -54,17 +54,17 @@ - + - + - - + + - + diff --git a/assets/xml/objects/object_oE10.xml b/assets/xml/objects/object_oE10.xml index eb3afcb6e8..3edb545b91 100644 --- a/assets/xml/objects/object_oE10.xml +++ b/assets/xml/objects/object_oE10.xml @@ -1,15 +1,15 @@ - + - + - + - - + + diff --git a/assets/xml/objects/object_oE11.xml b/assets/xml/objects/object_oE11.xml index 81bfebf3b5..0e5e1db057 100644 --- a/assets/xml/objects/object_oE11.xml +++ b/assets/xml/objects/object_oE11.xml @@ -1,15 +1,15 @@ - + - + - - - + + + diff --git a/assets/xml/objects/object_oE12.xml b/assets/xml/objects/object_oE12.xml index 72fd93201c..7937759ce6 100644 --- a/assets/xml/objects/object_oE12.xml +++ b/assets/xml/objects/object_oE12.xml @@ -1,15 +1,15 @@ - + - - - - - - + + + + + + diff --git a/assets/xml/objects/object_oE1s.xml b/assets/xml/objects/object_oE1s.xml index a1c0374eb7..b6dc068458 100644 --- a/assets/xml/objects/object_oE1s.xml +++ b/assets/xml/objects/object_oE1s.xml @@ -19,16 +19,16 @@ - + - - + + - + diff --git a/assets/xml/objects/object_oE2.xml b/assets/xml/objects/object_oE2.xml index ce1765b2d7..875812fa23 100644 --- a/assets/xml/objects/object_oE2.xml +++ b/assets/xml/objects/object_oE2.xml @@ -54,16 +54,16 @@ - + - + - - - + + + diff --git a/assets/xml/objects/object_oE3.xml b/assets/xml/objects/object_oE3.xml index 383dec1b41..b56e60aea1 100644 --- a/assets/xml/objects/object_oE3.xml +++ b/assets/xml/objects/object_oE3.xml @@ -54,19 +54,19 @@ - + - + - - + + - + diff --git a/assets/xml/objects/object_oE4.xml b/assets/xml/objects/object_oE4.xml index b1dc8fa363..06913315a3 100644 --- a/assets/xml/objects/object_oE4.xml +++ b/assets/xml/objects/object_oE4.xml @@ -54,16 +54,16 @@ - + - - + + - + diff --git a/assets/xml/objects/object_oE4s.xml b/assets/xml/objects/object_oE4s.xml index 73498d3d0f..5f7f55c061 100644 --- a/assets/xml/objects/object_oE4s.xml +++ b/assets/xml/objects/object_oE4s.xml @@ -18,15 +18,15 @@ - + - - + + - + diff --git a/assets/xml/objects/object_oE5.xml b/assets/xml/objects/object_oE5.xml index 139c86375c..6d11801f37 100644 --- a/assets/xml/objects/object_oE5.xml +++ b/assets/xml/objects/object_oE5.xml @@ -47,18 +47,18 @@ - + - + - - + + - - + + diff --git a/assets/xml/objects/object_oE6.xml b/assets/xml/objects/object_oE6.xml index 2115502eb6..249146a45c 100644 --- a/assets/xml/objects/object_oE6.xml +++ b/assets/xml/objects/object_oE6.xml @@ -1,15 +1,15 @@ - + - + - - - + + + diff --git a/assets/xml/objects/object_oE7.xml b/assets/xml/objects/object_oE7.xml index dd2cb23ed7..e3b3b8e171 100644 --- a/assets/xml/objects/object_oE7.xml +++ b/assets/xml/objects/object_oE7.xml @@ -1,14 +1,14 @@ - + - + - - + + diff --git a/assets/xml/objects/object_oE8.xml b/assets/xml/objects/object_oE8.xml index 478611a90b..e7bea5c122 100644 --- a/assets/xml/objects/object_oE8.xml +++ b/assets/xml/objects/object_oE8.xml @@ -1,15 +1,15 @@ - + - + - - + + - + diff --git a/assets/xml/objects/object_oE9.xml b/assets/xml/objects/object_oE9.xml index e3ced8b602..9d39ac89be 100644 --- a/assets/xml/objects/object_oE9.xml +++ b/assets/xml/objects/object_oE9.xml @@ -1,15 +1,15 @@ - + - + - - - + + + diff --git a/assets/xml/objects/object_oF1s.xml b/assets/xml/objects/object_oF1s.xml index f3e2ce1637..5a8b80d79a 100644 --- a/assets/xml/objects/object_oF1s.xml +++ b/assets/xml/objects/object_oF1s.xml @@ -30,10 +30,10 @@ - - - - - - - - - + + + + + + + + + - + diff --git a/assets/xml/objects/object_os.xml b/assets/xml/objects/object_os.xml index f3d0dff416..5ab83c9647 100644 --- a/assets/xml/objects/object_os.xml +++ b/assets/xml/objects/object_os.xml @@ -9,8 +9,8 @@ - - + + diff --git a/assets/xml/objects/object_ossan.xml b/assets/xml/objects/object_ossan.xml index 12cbe6f139..129c2a1a80 100644 --- a/assets/xml/objects/object_ossan.xml +++ b/assets/xml/objects/object_ossan.xml @@ -1,7 +1,7 @@ - + diff --git a/assets/xml/objects/object_ps.xml b/assets/xml/objects/object_ps.xml index a268e57b0b..043e232d64 100644 --- a/assets/xml/objects/object_ps.xml +++ b/assets/xml/objects/object_ps.xml @@ -1,13 +1,13 @@ - - - - - - - + + + + + + + diff --git a/assets/xml/objects/object_pu_box.xml b/assets/xml/objects/object_pu_box.xml index 943339f367..df9f8e25a7 100644 --- a/assets/xml/objects/object_pu_box.xml +++ b/assets/xml/objects/object_pu_box.xml @@ -8,6 +8,6 @@ - + diff --git a/assets/xml/objects/object_rd.xml b/assets/xml/objects/object_rd.xml index d23800ed16..05fa416d74 100644 --- a/assets/xml/objects/object_rd.xml +++ b/assets/xml/objects/object_rd.xml @@ -1,7 +1,7 @@ - - + + @@ -53,13 +53,13 @@ - - - - + + + + - - + + diff --git a/assets/xml/objects/object_reeba.xml b/assets/xml/objects/object_reeba.xml index 27dead1b95..4e103cb3f0 100644 --- a/assets/xml/objects/object_reeba.xml +++ b/assets/xml/objects/object_reeba.xml @@ -19,9 +19,9 @@ - - - + + + diff --git a/assets/xml/objects/object_rl.xml b/assets/xml/objects/object_rl.xml index bb33c2ce36..c7d10022a9 100644 --- a/assets/xml/objects/object_rl.xml +++ b/assets/xml/objects/object_rl.xml @@ -11,7 +11,7 @@ - + @@ -21,7 +21,7 @@ - + diff --git a/assets/xml/objects/object_rs.xml b/assets/xml/objects/object_rs.xml index d0c5b357ab..ef160d17b3 100644 --- a/assets/xml/objects/object_rs.xml +++ b/assets/xml/objects/object_rs.xml @@ -9,7 +9,7 @@ - + diff --git a/assets/xml/objects/object_ru1.xml b/assets/xml/objects/object_ru1.xml index 2d7e26246d..d4227792d5 100644 --- a/assets/xml/objects/object_ru1.xml +++ b/assets/xml/objects/object_ru1.xml @@ -39,8 +39,8 @@ - - + + @@ -49,17 +49,17 @@ - + - - - - - + + + + + diff --git a/assets/xml/objects/object_sa.xml b/assets/xml/objects/object_sa.xml index dd44fdde36..b83a5b5798 100644 --- a/assets/xml/objects/object_sa.xml +++ b/assets/xml/objects/object_sa.xml @@ -66,11 +66,11 @@ - - - - - + + + + + @@ -90,7 +90,7 @@ - + diff --git a/assets/xml/objects/object_sb.xml b/assets/xml/objects/object_sb.xml index 6bef59ffe0..64d3bb005a 100644 --- a/assets/xml/objects/object_sb.xml +++ b/assets/xml/objects/object_sb.xml @@ -8,14 +8,14 @@ - - - - - + + + + + - + diff --git a/assets/xml/objects/object_sd.xml b/assets/xml/objects/object_sd.xml index a16c1202d5..cf85ef91b4 100644 --- a/assets/xml/objects/object_sd.xml +++ b/assets/xml/objects/object_sd.xml @@ -43,7 +43,7 @@ - + @@ -54,7 +54,7 @@ - + diff --git a/assets/xml/objects/object_shop_dungen.xml b/assets/xml/objects/object_shop_dungen.xml index e0d2ae1e5a..594c43d390 100644 --- a/assets/xml/objects/object_shop_dungen.xml +++ b/assets/xml/objects/object_shop_dungen.xml @@ -1,10 +1,10 @@ - + - + diff --git a/assets/xml/objects/object_skb.xml b/assets/xml/objects/object_skb.xml index 5ff01449af..06e0b10516 100644 --- a/assets/xml/objects/object_skb.xml +++ b/assets/xml/objects/object_skb.xml @@ -44,15 +44,15 @@ - - - - - - - - - + + + + + + + + + diff --git a/assets/xml/objects/object_skj.xml b/assets/xml/objects/object_skj.xml index 84443d1add..3abdd610f8 100644 --- a/assets/xml/objects/object_skj.xml +++ b/assets/xml/objects/object_skj.xml @@ -53,9 +53,9 @@ - - - + + + diff --git a/assets/xml/objects/object_spot02_objects.xml b/assets/xml/objects/object_spot02_objects.xml index 539002c65f..1e8b44d07d 100644 --- a/assets/xml/objects/object_spot02_objects.xml +++ b/assets/xml/objects/object_spot02_objects.xml @@ -15,11 +15,11 @@ - - - - - - + + + + + + diff --git a/assets/xml/objects/object_spot05_objects.xml b/assets/xml/objects/object_spot05_objects.xml index fb9b9ba2f2..1e49c5a57c 100644 --- a/assets/xml/objects/object_spot05_objects.xml +++ b/assets/xml/objects/object_spot05_objects.xml @@ -1,9 +1,9 @@ - + - + diff --git a/assets/xml/objects/object_spot07_object.xml b/assets/xml/objects/object_spot07_object.xml index 2633529e0f..6623a564c1 100644 --- a/assets/xml/objects/object_spot07_object.xml +++ b/assets/xml/objects/object_spot07_object.xml @@ -2,22 +2,22 @@ - + - + - + - - + + diff --git a/assets/xml/objects/object_spot11_obj.xml b/assets/xml/objects/object_spot11_obj.xml index 4c507f5c57..257298f7cc 100644 --- a/assets/xml/objects/object_spot11_obj.xml +++ b/assets/xml/objects/object_spot11_obj.xml @@ -1,8 +1,8 @@ - + - + diff --git a/assets/xml/objects/object_spot17_obj.xml b/assets/xml/objects/object_spot17_obj.xml index ce66da06e1..eee4172d77 100644 --- a/assets/xml/objects/object_spot17_obj.xml +++ b/assets/xml/objects/object_spot17_obj.xml @@ -1,6 +1,6 @@ - + diff --git a/assets/xml/objects/object_ssh.xml b/assets/xml/objects/object_ssh.xml index 659a6c2c44..4a1249af05 100644 --- a/assets/xml/objects/object_ssh.xml +++ b/assets/xml/objects/object_ssh.xml @@ -1,7 +1,7 @@ - + diff --git a/assets/xml/objects/object_sst.xml b/assets/xml/objects/object_sst.xml index cb0aa17dfe..a80780741e 100644 --- a/assets/xml/objects/object_sst.xml +++ b/assets/xml/objects/object_sst.xml @@ -49,7 +49,7 @@ - - + + diff --git a/assets/xml/objects/object_st.xml b/assets/xml/objects/object_st.xml index 02b82d0ccc..653e19a56c 100644 --- a/assets/xml/objects/object_st.xml +++ b/assets/xml/objects/object_st.xml @@ -2,12 +2,12 @@ - - + + - - - + + + @@ -19,9 +19,9 @@ - + - + diff --git a/assets/xml/objects/object_syokudai.xml b/assets/xml/objects/object_syokudai.xml index 77ca102d87..717aaf15c4 100644 --- a/assets/xml/objects/object_syokudai.xml +++ b/assets/xml/objects/object_syokudai.xml @@ -3,10 +3,10 @@ - - - - - + + + + + diff --git a/assets/xml/objects/object_ta.xml b/assets/xml/objects/object_ta.xml index 691ff48c34..cbc90d9535 100644 --- a/assets/xml/objects/object_ta.xml +++ b/assets/xml/objects/object_ta.xml @@ -14,7 +14,7 @@ - + @@ -27,7 +27,7 @@ - + @@ -37,8 +37,8 @@ - - + + diff --git a/assets/xml/objects/object_tite.xml b/assets/xml/objects/object_tite.xml index 018cff7c44..f8c9ecab4b 100644 --- a/assets/xml/objects/object_tite.xml +++ b/assets/xml/objects/object_tite.xml @@ -9,8 +9,8 @@ - - + + diff --git a/assets/xml/objects/object_tk.xml b/assets/xml/objects/object_tk.xml index e6a65e91bb..59f14e0cc7 100644 --- a/assets/xml/objects/object_tk.xml +++ b/assets/xml/objects/object_tk.xml @@ -4,9 +4,9 @@ - - - + + + diff --git a/assets/xml/objects/object_toryo.xml b/assets/xml/objects/object_toryo.xml index d6668c5c95..4c935d2118 100644 --- a/assets/xml/objects/object_toryo.xml +++ b/assets/xml/objects/object_toryo.xml @@ -1,14 +1,14 @@ - + - + diff --git a/assets/xml/objects/object_tp.xml b/assets/xml/objects/object_tp.xml index 100ed171a2..8ea908825e 100644 --- a/assets/xml/objects/object_tp.xml +++ b/assets/xml/objects/object_tp.xml @@ -8,10 +8,10 @@ - - - + + + - + diff --git a/assets/xml/objects/object_tr.xml b/assets/xml/objects/object_tr.xml index fb54246e48..cb2f3391f3 100644 --- a/assets/xml/objects/object_tr.xml +++ b/assets/xml/objects/object_tr.xml @@ -27,20 +27,20 @@ - - - - + + + + - + - - - - + + + + @@ -53,9 +53,9 @@ - + - + @@ -103,9 +103,9 @@ - - - + + + @@ -115,7 +115,7 @@ - + diff --git a/assets/xml/objects/object_ts.xml b/assets/xml/objects/object_ts.xml index 6931ea0f52..08a5e71122 100644 --- a/assets/xml/objects/object_ts.xml +++ b/assets/xml/objects/object_ts.xml @@ -1,7 +1,7 @@ - + diff --git a/assets/xml/objects/object_tsubo.xml b/assets/xml/objects/object_tsubo.xml index 438f10c385..ee2c5e1846 100644 --- a/assets/xml/objects/object_tsubo.xml +++ b/assets/xml/objects/object_tsubo.xml @@ -1,8 +1,8 @@ - - - + + + diff --git a/assets/xml/objects/object_vase.xml b/assets/xml/objects/object_vase.xml index fb71ab9f7e..091d4c51e3 100644 --- a/assets/xml/objects/object_vase.xml +++ b/assets/xml/objects/object_vase.xml @@ -1,7 +1,7 @@ - - + + diff --git a/assets/xml/objects/object_wallmaster.xml b/assets/xml/objects/object_wallmaster.xml index 91886a8693..fbbc4f4af3 100644 --- a/assets/xml/objects/object_wallmaster.xml +++ b/assets/xml/objects/object_wallmaster.xml @@ -12,13 +12,13 @@ - - - - - - - + + + + + + + diff --git a/assets/xml/objects/object_wf.xml b/assets/xml/objects/object_wf.xml index eb50da38e5..2994536cb3 100644 --- a/assets/xml/objects/object_wf.xml +++ b/assets/xml/objects/object_wf.xml @@ -1,10 +1,10 @@ - - - - - + + + + + @@ -72,11 +72,11 @@ - - - - - + + + + + diff --git a/assets/xml/objects/object_wood02.xml b/assets/xml/objects/object_wood02.xml index bc7ea39c42..3245612bde 100644 --- a/assets/xml/objects/object_wood02.xml +++ b/assets/xml/objects/object_wood02.xml @@ -4,13 +4,13 @@ - + - + - + diff --git a/assets/xml/objects/object_ydan_objects.xml b/assets/xml/objects/object_ydan_objects.xml index d7d0e5634c..dab7962ecf 100644 --- a/assets/xml/objects/object_ydan_objects.xml +++ b/assets/xml/objects/object_ydan_objects.xml @@ -1,20 +1,20 @@ - + - - + + - + - + - - + + - + diff --git a/assets/xml/objects/object_zf.xml b/assets/xml/objects/object_zf.xml index 5fea2b0945..0c33d9a0fe 100644 --- a/assets/xml/objects/object_zf.xml +++ b/assets/xml/objects/object_zf.xml @@ -1,15 +1,15 @@ - + - - + + - + @@ -84,18 +84,18 @@ - - - - - - - - - - - - + + + + + + + + + + + + diff --git a/assets/xml/objects/object_zl2.xml b/assets/xml/objects/object_zl2.xml index 92c62d7289..9c7a6e681b 100644 --- a/assets/xml/objects/object_zl2.xml +++ b/assets/xml/objects/object_zl2.xml @@ -4,7 +4,7 @@ - + @@ -15,28 +15,28 @@ - + - + - + - - - - - - - - + + + + + + + + - + diff --git a/assets/xml/objects/object_zo.xml b/assets/xml/objects/object_zo.xml index 557703cdfd..c1eab1deeb 100644 --- a/assets/xml/objects/object_zo.xml +++ b/assets/xml/objects/object_zo.xml @@ -59,12 +59,12 @@ - - - + + + - + @@ -72,7 +72,7 @@ - + diff --git a/assets/xml/overlays/ovl_Boss_Dodongo.xml b/assets/xml/overlays/ovl_Boss_Dodongo.xml index 615252751a..24c6b90170 100644 --- a/assets/xml/overlays/ovl_Boss_Dodongo.xml +++ b/assets/xml/overlays/ovl_Boss_Dodongo.xml @@ -1,6 +1,6 @@ - - + + diff --git a/assets/xml/overlays/ovl_En_Jsjutan.xml b/assets/xml/overlays/ovl_En_Jsjutan.xml index ee30fc2b19..d7fe054972 100644 --- a/assets/xml/overlays/ovl_En_Jsjutan.xml +++ b/assets/xml/overlays/ovl_En_Jsjutan.xml @@ -1,7 +1,7 @@ - + diff --git a/assets/xml/scenes/dungeons/ddan_boss.xml b/assets/xml/scenes/dungeons/ddan_boss.xml index c8444850d2..03eb73ea30 100644 --- a/assets/xml/scenes/dungeons/ddan_boss.xml +++ b/assets/xml/scenes/dungeons/ddan_boss.xml @@ -6,7 +6,7 @@ - + diff --git a/assets/xml/textures/icon_item_dungeon_static.xml b/assets/xml/textures/icon_item_dungeon_static.xml index b86435c9e8..873c490fc5 100644 --- a/assets/xml/textures/icon_item_dungeon_static.xml +++ b/assets/xml/textures/icon_item_dungeon_static.xml @@ -17,7 +17,7 @@ - - + + diff --git a/assets/xml/textures/icon_item_field_static.xml b/assets/xml/textures/icon_item_field_static.xml index a48606646c..ed991406b5 100644 --- a/assets/xml/textures/icon_item_field_static.xml +++ b/assets/xml/textures/icon_item_field_static.xml @@ -1,7 +1,7 @@ - + diff --git a/assets/xml/textures/parameter_static.xml b/assets/xml/textures/parameter_static.xml index 7aaa991fc3..bd4173431c 100644 --- a/assets/xml/textures/parameter_static.xml +++ b/assets/xml/textures/parameter_static.xml @@ -19,9 +19,9 @@ - - - + + + diff --git a/extract_assets.py b/extract_assets.py index 5c2d378889..68c8daf113 100755 --- a/extract_assets.py +++ b/extract_assets.py @@ -39,13 +39,12 @@ def ExtractFunc(fullPath): outPath = os.path.join("assets", *pathList[2:], objectName) outSourcePath = outPath - if not globalForce: - if fullPath in globalExtractedAssetsTracker: - timestamp = globalExtractedAssetsTracker[fullPath]["timestamp"] - modificationTime = int(os.path.getmtime(fullPath)) - if modificationTime < timestamp: - # XML has not been modified since last extraction. - return + if fullPath in globalExtractedAssetsTracker: + timestamp = globalExtractedAssetsTracker[fullPath]["timestamp"] + modificationTime = int(os.path.getmtime(fullPath)) + if modificationTime < timestamp: + # XML has not been modified since last extraction. + return currentTimeStamp = int(time.time()) @@ -57,13 +56,11 @@ def ExtractFunc(fullPath): globalExtractedAssetsTracker[fullPath] = globalManager.dict() globalExtractedAssetsTracker[fullPath]["timestamp"] = currentTimeStamp -def initializeWorker(force: bool, abort, unaccounted: bool, extractedAssetsTracker: dict, manager): - global globalForce +def initializeWorker(abort, unaccounted: bool, extractedAssetsTracker: dict, manager): global globalAbort global globalUnaccounted global globalExtractedAssetsTracker global globalManager - globalForce = force globalAbort = abort globalUnaccounted = unaccounted globalExtractedAssetsTracker = extractedAssetsTracker @@ -82,15 +79,21 @@ def main(): signal.signal(signal.SIGINT, SignalHandler) extractedAssetsTracker = manager.dict() - if os.path.exists(EXTRACTED_ASSETS_NAMEFILE): + if os.path.exists(EXTRACTED_ASSETS_NAMEFILE) and not args.force: with open(EXTRACTED_ASSETS_NAMEFILE, encoding='utf-8') as f: extractedAssetsTracker.update(json.load(f, object_hook=manager.dict)) asset_path = args.single if asset_path is not None: - # Always force if -s is used. - initializeWorker(True, mainAbort, args.unaccounted, extractedAssetsTracker, manager) fullPath = os.path.join("assets", "xml", asset_path + ".xml") + if not os.path.exists(fullPath): + print(f"Error. File {fullPath} doesn't exists.", file=os.sys.stderr) + exit(1) + + initializeWorker(mainAbort, args.unaccounted, extractedAssetsTracker, manager) + # Always extract if -s is used. + if fullPath in extractedAssetsTracker: + del extractedAssetsTracker[fullPath] ExtractFunc(fullPath) else: xmlFiles = [] @@ -102,7 +105,7 @@ def main(): numCores = cpu_count() print("Extracting assets with " + str(numCores) + " CPU cores.") - with Pool(numCores, initializer=initializeWorker, initargs=(args.force, mainAbort, args.unaccounted, extractedAssetsTracker, manager)) as p: + with Pool(numCores, initializer=initializeWorker, initargs=(mainAbort, args.unaccounted, extractedAssetsTracker, manager)) as p: p.map(ExtractFunc, xmlFiles) with open(EXTRACTED_ASSETS_NAMEFILE, 'w', encoding='utf-8') as f: diff --git a/spec b/spec index 1666bef200..0a35f92a9b 100644 --- a/spec +++ b/spec @@ -3476,7 +3476,8 @@ endseg beginseg name "object_human" romalign 0x1000 - include "build/baserom/object_human.o" + include "build/assets/objects/object_human/object_human.o" + number 6 endseg beginseg diff --git a/tools/ZAPD/.gitrepo b/tools/ZAPD/.gitrepo index 3202e5a919..73ce262034 100644 --- a/tools/ZAPD/.gitrepo +++ b/tools/ZAPD/.gitrepo @@ -6,7 +6,7 @@ [subrepo] remote = https://github.com/zeldaret/ZAPD.git branch = master - commit = 86160be6968c9813fcf359b88a0ac188d87c2772 - parent = 07c93fd180beb092cb0f50faae04c57c0eff458a + commit = 6be9af65d39a1608ef854efbaf0bf9399aac5da1 + parent = 913b88b160c735d81f2d4f1d14717de8c7ba8dee method = merge cmdver = 0.4.3 diff --git a/tools/ZAPD/Jenkinsfile b/tools/ZAPD/Jenkinsfile index d7ea29396f..3062c4851b 100644 --- a/tools/ZAPD/Jenkinsfile +++ b/tools/ZAPD/Jenkinsfile @@ -38,6 +38,36 @@ pipeline { } } } + + stage('Checkout mm') { + steps { + dir('mm') { + git url: 'https://github.com/zeldaret/mm.git' + } + } + } + stage('Set up mm') { + steps { + dir('mm') { + sh 'cp /usr/local/etc/roms/mm.us.rev1.z64 baserom.mm.us.rev1.z64' + + // Identical to `make setup` except for copying our newer ZAPD.out into mm + sh 'git submodule update --init --recursive' + sh 'make -C tools' + sh 'cp ../ZAPD.out tools/ZAPD/' + sh 'python3 tools/extract_rom.py baserom.mm.us.rev1.z64' + sh 'python3 extract_assets.py' + } + } + } + stage('Build mm') { + steps { + dir('mm') { + sh 'make assembly -j' + sh 'make -j' + } + } + } } post { always { diff --git a/tools/ZAPD/Makefile b/tools/ZAPD/Makefile index 074e6a9736..afd50e0167 100644 --- a/tools/ZAPD/Makefile +++ b/tools/ZAPD/Makefile @@ -1,32 +1,41 @@ OPTIMIZATION_ON ?= 1 ASAN ?= 0 -DEPRECATION_OFF ?= 0 -CFLAGS ?= +DEPRECATION_ON ?= 1 +DEBUG ?= 0 +CXXFLAGS ?= +COPYCHECK_ARGS ?= -CC := g++ +CXX := g++ INC := -I ZAPD -I lib/assimp/include -I lib/elfio -I lib/json/include -I lib/stb -I lib/tinygltf -I lib/libgfxd -I lib/tinyxml2 -CFLAGS += -g3 -ggdb -fpic -std=c++17 -rdynamic -Wall -fno-omit-frame-pointer +CXXFLAGS += -fpic -std=c++17 -Wall -fno-omit-frame-pointer + +ifneq ($(DEBUG),0) + OPTIMIZATION_ON = 0 + DEPRECATION_OFF = 1 + CXXFLAGS += -g3 -DDEVELOPMENT + COPYCHECK_ARGS += --devel + DEPRECATION_ON = 0 +endif ifeq ($(OPTIMIZATION_ON),0) - CFLAGS += -O0 + CXXFLAGS += -O0 else - CFLAGS += -O2 +CXXFLAGS += -O2 -march=native -mtune=native endif + ifneq ($(ASAN),0) - CFLAGS += -fsanitize=address + CXXFLAGS += -fsanitize=address endif -ifneq ($(DEPRECATION_OFF),0) - CFLAGS += -DDEPRECATION_OFF +ifneq ($(DEPRECATION_ON),0) + CXXFLAGS += -DDEPRECATION_ON endif -# CFLAGS += -DTEXTURE_DEBUG +# CXXFLAGS += -DTEXTURE_DEBUG + +LDFLAGS := -lstdc++ -lm -ldl -lpng -LDFLAGS := -ldl -lpng UNAME := $(shell uname) - -FS_INC ?= ifneq ($(UNAME), Darwin) - FS_INC += -lstdc++fs - CFLAGS += -Wl,-export-dynamic + LDFLAGS += -Wl,-export-dynamic -lstdc++fs endif SRC_DIRS := ZAPD ZAPD/ZRoom ZAPD/ZRoom/Commands ZAPD/Overlays ZAPD/HighLevel @@ -40,7 +49,7 @@ O_FILES := $(CPP_FILES:.cpp=.o) all: ZAPD.out copycheck genbuildinfo: - python3 ZAPD/genbuildinfo.py + python3 ZAPD/genbuildinfo.py $(COPYCHECK_ARGS) copycheck: ZAPD.out python3 copycheck.py @@ -57,13 +66,13 @@ format: .PHONY: all genbuildinfo copycheck clean rebuild format %.o: %.cpp - $(CC) $(CFLAGS) $(INC) -c $< -o $@ $(LDFLAGS) + $(CXX) $(CXXFLAGS) $(INC) -c $< -o $@ ZAPD/Main.o: genbuildinfo ZAPD/Main.cpp - $(CC) $(CFLAGS) $(INC) -c ZAPD/Main.cpp -o $@ $(LDFLAGS) + $(CXX) $(CXXFLAGS) $(INC) -c ZAPD/Main.cpp -o $@ lib/libgfxd/libgfxd.a: $(MAKE) -C lib/libgfxd ZAPD.out: $(O_FILES) lib/libgfxd/libgfxd.a - $(CC) $(CFLAGS) $(INC) $(O_FILES) lib/libgfxd/libgfxd.a -o $@ $(FS_INC) $(LDFLAGS) + $(CXX) $(CXXFLAGS) $(INC) $(O_FILES) lib/libgfxd/libgfxd.a -o $@ $(FS_INC) $(LDFLAGS) diff --git a/tools/ZAPD/README.md b/tools/ZAPD/README.md index 22da732f01..719492d92b 100644 --- a/tools/ZAPD/README.md +++ b/tools/ZAPD/README.md @@ -24,9 +24,13 @@ ZAPD uses the clasic `Makefile` approach. To build just run `make` (or even bett You can configure a bit your ZAPD build with the following options: -- `OPTIMIZATION_ON`: If set to `0`, then optimizations will be disabled (compile with `-O0`). Any other value compiles with `-O2`. Defaults to `1`. +- `OPTIMIZATION_ON`: If set to `0` optimizations will be disabled (compile with `-O0`). Any other value compiles with `-O2`. Defaults to `1`. - `ASAN`: If it is set to a non-zero then ZAPD will be compiled with Address Sanitizer enabled (`-fsanitize=address`). Defaults to `0`. -- `DEPRECATION_OFF`: If it is set to a non-zero then deprecation warnings will be disabled. Defaults to `0`. +- `DEPRECATION_ON`: If it is set to a zero then deprecation warnings will be disabled. Defaults to `1`. +- `DEBUG`: If non-zero, ZAPD will be compiled in _development mode_. This implies the following: + - Debugging symbols enabled (`-g3`). They are disabled by default. + - `OPTIMIZATION_ON=0`: Disables optimizations (`-O0`). + - `DEPRECATION_OFF=1`: Disables deprecation warnings. As an example, if you want to build ZAPD with optimizations disabled and use the address sanitizer, you could use the following command: @@ -100,4 +104,11 @@ ZAPD also accepts the following list of extra parameters: - `2` (and higher): Debug. - `-wu` / `--warn-unaccounted`: Enable warnings for each unaccounted block of data found. - Can be used only in `e` or `bsf` modes. +- `-vu` / `--verbose-unaccounted`: Changes how unaccounteds are outputted. Max 4 bytes per line (a word) and add a comment with the offset of each of those lines. + - Could be useful for looking at raw data or testing. + - Can be used only in `e` or `bsf` modes. - `-tm MODE`: Test Mode (enables certain experimental features). To enable it, set `MODE` to `1`. +- `-wno` / `--warn-no-offsets` : Enable warnings for nodes that dont have offsets specified. Takes priority over `-eno`/ `--error-no-offsets`. +- `-eno`/ `--error-no-offsets` : Enable errors for nodes that dont have offsets specified. + +Additionally, you can pass the flag `--version` to see the current ZAPD version. If that flag is passed, ZAPD will ignore any other parameter passed. diff --git a/tools/ZAPD/ZAPD/BitConverter.h b/tools/ZAPD/ZAPD/BitConverter.h index 7df68de5e0..a36cc534f9 100644 --- a/tools/ZAPD/ZAPD/BitConverter.h +++ b/tools/ZAPD/ZAPD/BitConverter.h @@ -109,7 +109,7 @@ public: uint32_t floatData = ((uint32_t)data[offset + 0] << 24) + ((uint32_t)data[offset + 1] << 16) + ((uint32_t)data[offset + 2] << 8) + (uint32_t)data[offset + 3]; - static_assert(sizeof(uint32_t) == sizeof(float)); + static_assert(sizeof(uint32_t) == sizeof(float), "expected 32-bit float"); std::memcpy(&value, &floatData, sizeof(value)); return value; } @@ -120,7 +120,7 @@ public: uint32_t floatData = ((uint32_t)data[offset + 0] << 24) + ((uint32_t)data[offset + 1] << 16) + ((uint32_t)data[offset + 2] << 8) + (uint32_t)data[offset + 3]; - static_assert(sizeof(uint32_t) == sizeof(float)); + static_assert(sizeof(uint32_t) == sizeof(float), "expected 32-bit float"); std::memcpy(&value, &floatData, sizeof(value)); return value; } @@ -133,10 +133,10 @@ public: ((uint64_t)data[offset + 2] << 40) + ((uint64_t)data[offset + 3] << 32) + ((uint64_t)data[offset + 4] << 24) + ((uint64_t)data[offset + 5] << 16) + ((uint64_t)data[offset + 6] << 8) + ((uint64_t)data[offset + 7]); - static_assert(sizeof(uint64_t) == sizeof(double)); + static_assert(sizeof(uint64_t) == sizeof(double), "expected 64-bit double"); // Checks if the float format on the platform the ZAPD binary is running on supports the // same float format as the object file. - static_assert(std::numeric_limits::is_iec559); + static_assert(std::numeric_limits::is_iec559, "expected IEC559 floats on host machine"); std::memcpy(&value, &floatData, sizeof(value)); return value; } @@ -149,10 +149,10 @@ public: ((uint64_t)data[offset + 2] << 40) + ((uint64_t)data[offset + 3] << 32) + ((uint64_t)data[offset + 4] << 24) + ((uint64_t)data[offset + 5] << 16) + ((uint64_t)data[offset + 6] << 8) + ((uint64_t)data[offset + 7]); - static_assert(sizeof(uint64_t) == sizeof(double)); + static_assert(sizeof(uint64_t) == sizeof(double), "expected 64-bit double"); // Checks if the float format on the platform the ZAPD binary is running on supports the // same float format as the object file. - static_assert(std::numeric_limits::is_iec559); + static_assert(std::numeric_limits::is_iec559, "expected IEC559 doubles on host machine"); std::memcpy(&value, &floatData, sizeof(value)); return value; } diff --git a/tools/ZAPD/ZAPD/Directory.h b/tools/ZAPD/ZAPD/Directory.h index 74bb14ed6c..adb2e17d28 100644 --- a/tools/ZAPD/ZAPD/Directory.h +++ b/tools/ZAPD/ZAPD/Directory.h @@ -19,7 +19,7 @@ class Directory public: static std::string GetCurrentDirectory() { return fs::current_path().u8string(); } - static bool Exists(const std::string& path) { return fs::exists(fs::path(path)); } + static bool Exists(const fs::path& path) { return fs::exists(path); } static void CreateDirectory(const std::string& path) { diff --git a/tools/ZAPD/ZAPD/File.h b/tools/ZAPD/ZAPD/File.h index 69aa0441dc..4cb7b56093 100644 --- a/tools/ZAPD/ZAPD/File.h +++ b/tools/ZAPD/ZAPD/File.h @@ -5,18 +5,19 @@ #include #include #include +#include "Directory.h" #include "StringHelper.h" class File { public: - static bool Exists(const std::string& filePath) + static bool Exists(const fs::path& filePath) { std::ifstream file(filePath, std::ios::in | std::ios::binary | std::ios::ate); return file.good(); } - static std::vector ReadAllBytes(const std::string& filePath) + static std::vector ReadAllBytes(const fs::path& filePath) { std::ifstream file(filePath, std::ios::in | std::ios::binary | std::ios::ate); int32_t fileSize = (int32_t)file.tellg(); @@ -29,7 +30,7 @@ public: return result; }; - static std::string ReadAllText(const std::string& filePath) + static std::string ReadAllText(const fs::path& filePath) { std::ifstream file(filePath, std::ios::in | std::ios::binary | std::ios::ate); int32_t fileSize = (int32_t)file.tellg(); @@ -43,7 +44,7 @@ public: return str; }; - static std::vector ReadAllLines(const std::string& filePath) + static std::vector ReadAllLines(const fs::path& filePath) { std::string text = ReadAllText(filePath); std::vector lines = StringHelper::Split(text, "\n"); @@ -51,13 +52,13 @@ public: return lines; }; - static void WriteAllBytes(const std::string& filePath, const std::vector& data) + static void WriteAllBytes(const fs::path& filePath, const std::vector& data) { std::ofstream file(filePath, std::ios::binary); file.write((char*)data.data(), data.size()); }; - static void WriteAllText(const std::string& filePath, const std::string& text) + static void WriteAllText(const fs::path& filePath, const std::string& text) { std::ofstream file(filePath, std::ios::out); file.write(text.c_str(), text.size()); diff --git a/tools/ZAPD/ZAPD/Globals.cpp b/tools/ZAPD/ZAPD/Globals.cpp index a8676cc639..5de7843cdb 100644 --- a/tools/ZAPD/ZAPD/Globals.cpp +++ b/tools/ZAPD/ZAPD/Globals.cpp @@ -25,6 +25,7 @@ Globals::Globals() useExternalResources = true; lastScene = nullptr; verbosity = VerbosityLevel::VERBOSITY_SILENT; + outputPath = Directory::GetCurrentDirectory(); } std::string Globals::FindSymbolSegRef(int32_t segNumber, uint32_t symbolAddress) @@ -50,7 +51,7 @@ std::string Globals::FindSymbolSegRef(int32_t segNumber, uint32_t symbolAddress) { if (std::string(child->Name()) == "File") { - ZFile* file = new ZFile(fileMode, child, "", "", "", filePath, true); + ZFile* file = new ZFile(fileMode, child, "", "", filePath, true); file->GeneratePlaceholderDeclarations(); segmentRefFiles[segNumber] = file; break; diff --git a/tools/ZAPD/ZAPD/Globals.h b/tools/ZAPD/ZAPD/Globals.h index a7f1fed059..61c07f8d1c 100644 --- a/tools/ZAPD/ZAPD/Globals.h +++ b/tools/ZAPD/ZAPD/Globals.h @@ -53,6 +53,9 @@ public: ZGame game; GameConfig cfg; bool warnUnaccounted = false; + bool warnNoOffset = false; + bool errorNoOffset = false; + bool verboseUnaccounted = false; std::vector files; std::vector segments; diff --git a/tools/ZAPD/ZAPD/HighLevel/HLModelIntermediette.cpp b/tools/ZAPD/ZAPD/HighLevel/HLModelIntermediette.cpp index 88f66a46dd..f08dec4a86 100644 --- a/tools/ZAPD/ZAPD/HighLevel/HLModelIntermediette.cpp +++ b/tools/ZAPD/ZAPD/HighLevel/HLModelIntermediette.cpp @@ -244,7 +244,7 @@ void HLModelIntermediette::FromZSkeleton(HLModelIntermediette* model, ZSkeleton* model->hasSkeleton = true; // Start at the root skeleton node, go down... - ProcessZSkeletonLimb(model, zSkeleton, zSkeleton->limbs[0]); + // ProcessZSkeletonLimb(model, zSkeleton, zSkeleton->limbs[0]); } void HLModelIntermediette::ProcessZSkeletonLimb(HLModelIntermediette* model, ZSkeleton* zSkeleton, @@ -879,7 +879,7 @@ void HLTextureIntermediette::InitFromXML(tinyxml2::XMLElement* xmlElement) fileName = xmlElement->Attribute("TextureName"); // std::string format = xmlElement->Attribute("Format"); - std::string format = "rgb5a1"; // TEST + std::string format = "rgba16"; // TEST // tex = HLTexture::FromPNG(fileName, // (HLTextureType)ZTexture::GetTextureTypeFromString(format)); diff --git a/tools/ZAPD/ZAPD/Main.cpp b/tools/ZAPD/ZAPD/Main.cpp index 21c7c036ef..839e1ba990 100644 --- a/tools/ZAPD/ZAPD/Main.cpp +++ b/tools/ZAPD/ZAPD/Main.cpp @@ -27,8 +27,7 @@ using namespace tinyxml2; -bool Parse(const fs::path& xmlFilePath, const fs::path& basePath, const fs::path& outPath, - ZFileMode fileMode); +bool Parse(const fs::path& xmlFilePath, const fs::path& basePath, ZFileMode fileMode); void BuildAssetTexture(const fs::path& pngFilePath, TextureType texType, const fs::path& outPath); void BuildAssetBackground(const fs::path& imageFilePath, const fs::path& outPath); @@ -47,6 +46,7 @@ void ErrorHandler(int sig) fprintf(stderr, "\nZAPD crashed. (Signal: %i)\n", sig); + // Feel free to add more crash messages. const char* crashEasterEgg[] = { "\tYou've met with a terrible fate, haven't you?", "\tSEA BEARS FOAM. SLEEP BEARS DREAMS. \n\tBOTH END IN THE SAME WAY: CRASSSH!", @@ -92,14 +92,30 @@ void ErrorHandler(int sig) int main(int argc, char* argv[]) { - // Syntax: ZAPD.exe [mode (btex/bovl/e)] (Arbritrary Number of Arguments) + // Syntax: ZAPD.out [mode (btex/bovl/e)] (Arbritrary Number of Arguments) if (argc < 2) { - printf("ZAPD.exe (%s) [mode (btex/bovl/bsf/bblb/bmdlintr/bamnintr/e)] ...\n", gBuildHash); + printf("ZAPD.out (%s) [mode (btex/bovl/bsf/bblb/bmdlintr/bamnintr/e)] ...\n", gBuildHash); return 1; } + for (int i = 1; i < argc; i++) + { + if (!strcmp(argv[i], "--version")) + { + printf("ZAPD.out %s\n", gBuildHash); + return 0; + } + else if (!strcmp(argv[i], "--help") || !strcmp(argv[i], "-h")) + { + printf("Congratulations!\n"); + printf("You just found the (unimplemented and undocumented) ZAPD's help message.\n"); + printf("Feel free to implement it if you want :D\n"); + return 0; + } + } + Globals* g = new Globals(); // Parse File Mode @@ -225,6 +241,18 @@ int main(int argc, char* argv[]) { Globals::Instance->warnUnaccounted = true; } + else if (arg == "-wno" || arg == "--warn-no-offset") + { + Globals::Instance->warnNoOffset = true; + } + else if (arg == "-eno" || arg == "--error-no-offset") + { + Globals::Instance->errorNoOffset = true; + } + else if (arg == "-vu" || arg == "--verbose-unaccounted") // Verbose unaccounted + { + Globals::Instance->verboseUnaccounted = true; + } } if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_INFO) @@ -232,8 +260,8 @@ int main(int argc, char* argv[]) if (fileMode == ZFileMode::Extract || fileMode == ZFileMode::BuildSourceFile) { - bool parseSuccessful = Parse(Globals::Instance->inputPath, Globals::Instance->baseRomPath, - Globals::Instance->outputPath, fileMode); + bool parseSuccessful = + Parse(Globals::Instance->inputPath, Globals::Instance->baseRomPath, fileMode); if (!parseSuccessful) return 1; @@ -270,13 +298,11 @@ int main(int argc, char* argv[]) File::WriteAllText(Globals::Instance->outputPath.string(), overlay->GetSourceOutputCode("")); } - delete g; return 0; } -bool Parse(const fs::path& xmlFilePath, const fs::path& basePath, const fs::path& outPath, - ZFileMode fileMode) +bool Parse(const fs::path& xmlFilePath, const fs::path& basePath, ZFileMode fileMode) { XMLDocument doc; XMLError eResult = doc.LoadFile(xmlFilePath.string().c_str()); @@ -300,7 +326,7 @@ bool Parse(const fs::path& xmlFilePath, const fs::path& basePath, const fs::path { if (std::string(child->Name()) == "File") { - ZFile* file = new ZFile(fileMode, child, basePath, outPath, "", xmlFilePath, false); + ZFile* file = new ZFile(fileMode, child, basePath, "", xmlFilePath, false); Globals::Instance->files.push_back(file); } else @@ -315,9 +341,9 @@ bool Parse(const fs::path& xmlFilePath, const fs::path& basePath, const fs::path for (ZFile* file : Globals::Instance->files) { if (fileMode == ZFileMode::BuildSourceFile) - file->BuildSourceFile(outPath); + file->BuildSourceFile(); else - file->ExtractResources(outPath); + file->ExtractResources(); } // All done, free files @@ -380,7 +406,7 @@ void BuildAssetModelIntermediette(const fs::path& outPath) void BuildAssetAnimationIntermediette(const fs::path& animPath, const fs::path& outPath) { std::vector split = StringHelper::Split(outPath.string(), "/"); - ZFile* file = new ZFile("", split[split.size() - 2]); + ZFile* file = new ZFile(split[split.size() - 2]); HLAnimationIntermediette* anim = HLAnimationIntermediette::FromXML(animPath.string()); ZAnimation* zAnim = anim->ToZAnimation(); zAnim->SetName(Path::GetFileNameWithoutExtension(split[split.size() - 1])); diff --git a/tools/ZAPD/ZAPD/StringHelper.h b/tools/ZAPD/ZAPD/StringHelper.h index b07a99f0e4..26516d0fd8 100644 --- a/tools/ZAPD/ZAPD/StringHelper.h +++ b/tools/ZAPD/ZAPD/StringHelper.h @@ -1,11 +1,19 @@ #pragma once +#include #include #include #include #include #include -#include + +#ifndef __PRETTY_FUNCTION__ +#ifdef _MSC_VER +#define __PRETTY_FUNCTION__ __FUNCSIG__ +#else +#define __PRETTY_FUNCTION__ __func__ +#endif +#endif class StringHelper { @@ -101,7 +109,7 @@ public: static std::string BoolStr(bool b) { return b ? "true" : "false"; } - static bool HasOnlyDigits(const std::string &str) + static bool HasOnlyDigits(const std::string& str) { return std::all_of(str.begin(), str.end(), ::isdigit); } diff --git a/tools/ZAPD/ZAPD/ZAnimation.cpp b/tools/ZAPD/ZAPD/ZAnimation.cpp index 5f9f93472b..742d8135ee 100644 --- a/tools/ZAPD/ZAPD/ZAnimation.cpp +++ b/tools/ZAPD/ZAPD/ZAnimation.cpp @@ -10,6 +10,7 @@ REGISTER_ZFILENODE(Animation, ZNormalAnimation); REGISTER_ZFILENODE(PlayerAnimation, ZLinkAnimation); REGISTER_ZFILENODE(CurveAnimation, ZCurveAnimation); +REGISTER_ZFILENODE(LegacyAnimation, ZLegacyAnimation); ZAnimation::ZAnimation(ZFile* nParent) : ZResource(nParent) { @@ -18,10 +19,9 @@ ZAnimation::ZAnimation(ZFile* nParent) : ZResource(nParent) void ZAnimation::ParseRawData() { - const uint8_t* data = rawData.data(); + ZResource::ParseRawData(); - // Read the header - frameCount = BitConverter::ToInt16BE(data, rawDataIndex + 0); + frameCount = BitConverter::ToInt16BE(parent->GetRawData(), rawDataIndex + 0); } void ZAnimation::Save(const fs::path& outFolder) @@ -119,7 +119,7 @@ void ZNormalAnimation::ParseRawData() { ZAnimation::ParseRawData(); - const uint8_t* data = rawData.data(); + const uint8_t* data = parent->GetRawData().data(); rotationValuesSeg = BitConverter::ToInt32BE(data, rawDataIndex + 4) & 0x00FFFFFF; rotationIndicesSeg = BitConverter::ToInt32BE(data, rawDataIndex + 8) & 0x00FFFFFF; @@ -185,7 +185,7 @@ void ZLinkAnimation::ParseRawData() { ZAnimation::ParseRawData(); - const uint8_t* data = rawData.data(); + const uint8_t* data = parent->GetRawData().data(); segmentAddress = (BitConverter::ToInt32BE(data, rawDataIndex + 4)); } @@ -249,6 +249,7 @@ void ZCurveAnimation::ParseRawData() { ZAnimation::ParseRawData(); + const auto& rawData = parent->GetRawData(); refIndex = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0); transformData = BitConverter::ToUInt32BE(rawData, rawDataIndex + 4); copyValues = BitConverter::ToUInt32BE(rawData, rawDataIndex + 8); @@ -292,10 +293,9 @@ void ZCurveAnimation::ParseRawData() } } -void ZCurveAnimation::ExtractFromXML(tinyxml2::XMLElement* reader, - const std::vector& nRawData, uint32_t nRawDataIndex) +void ZCurveAnimation::ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) { - ZResource::ExtractFromXML(reader, nRawData, nRawDataIndex); + ZResource::ExtractFromXML(reader, nRawDataIndex); parent->AddDeclaration(rawDataIndex, DeclarationAlignment::Align16, GetRawDataSize(), GetSourceTypeName(), name, ""); @@ -472,3 +472,182 @@ std::string ZCurveAnimation::GetSourceTypeName() const { return "TransformUpdateIndex"; } + +/* ZLegacyAnimation */ + +ZLegacyAnimation::ZLegacyAnimation(ZFile* nParent) : ZAnimation(nParent) +{ +} + +void ZLegacyAnimation::ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) +{ + ZAnimation::ExtractFromXML(reader, nRawDataIndex); + + parent->AddDeclaration(rawDataIndex, DeclarationAlignment::Align4, GetRawDataSize(), + GetSourceTypeName(), name, ""); +} + +void ZLegacyAnimation::ParseRawData() +{ + ZAnimation::ParseRawData(); + + const auto& rawData = parent->GetRawData(); + limbCount = BitConverter::ToInt16BE(rawData, rawDataIndex + 0x02); + frameData = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x04); + jointKey = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x08); + + if (GETSEGNUM(frameData) == parent->segment && GETSEGNUM(jointKey) == parent->segment) + { + uint32_t frameDataOffset = Seg2Filespace(frameData, parent->baseAddress); + uint32_t jointKeyOffset = Seg2Filespace(jointKey, parent->baseAddress); + + uint32_t ptr = frameDataOffset; + for (size_t i = 0; i < (jointKeyOffset - frameDataOffset) / 2; i++) + { + frameDataArray.push_back(BitConverter::ToUInt16BE(rawData, ptr)); + ptr += 2; + } + + ptr = jointKeyOffset; + for (int32_t i = 0; i < limbCount + 1; i++) + { + JointKey key(parent); + key.ExtractFromFile(ptr); + + jointKeyArray.push_back(key); + ptr += key.GetRawDataSize(); + } + } +} + +void ZLegacyAnimation::DeclareReferences(const std::string& prefix) +{ + std::string varPrefix = prefix; + if (name != "") + varPrefix = name; + + ZAnimation::DeclareReferences(varPrefix); + + if (!frameDataArray.empty()) + { + uint32_t frameDataOffset = Seg2Filespace(frameData, parent->baseAddress); + if (GETSEGNUM(frameData) == parent->segment && !parent->HasDeclaration(frameDataOffset)) + { + std::string frameDataBody = "\t"; + + for (size_t i = 0; i < frameDataArray.size(); i++) + { + frameDataBody += StringHelper::Sprintf("0x%04X, ", frameDataArray[i]); + + if (i % 8 == 7 && i + 1 < frameDataArray.size()) + frameDataBody += "\n\t"; + } + + std::string frameDataName = StringHelper::Sprintf("%sFrameData", varPrefix.c_str()); + parent->AddDeclarationArray(frameDataOffset, DeclarationAlignment::Align4, + frameDataArray.size() * 2, "s16", frameDataName, + frameDataArray.size(), frameDataBody); + } + } + + if (!jointKeyArray.empty()) + { + uint32_t jointKeyOffset = Seg2Filespace(jointKey, parent->baseAddress); + if (GETSEGNUM(jointKey) == parent->segment && !parent->HasDeclaration(jointKeyOffset)) + { + const auto res = jointKeyArray.at(0); + std::string jointKeyBody = ""; + + for (size_t i = 0; i < jointKeyArray.size(); i++) + { + jointKeyBody += StringHelper::Sprintf("\t{ %s },", + jointKeyArray[i].GetBodySourceCode().c_str()); + + if (i + 1 < jointKeyArray.size()) + jointKeyBody += "\n"; + } + + std::string jointKeyName = StringHelper::Sprintf("%sJointKey", varPrefix.c_str()); + parent->AddDeclarationArray(jointKeyOffset, DeclarationAlignment::Align4, + jointKeyArray.size() * res.GetRawDataSize(), + res.GetSourceTypeName(), jointKeyName, jointKeyArray.size(), + jointKeyBody); + } + } +} + +std::string ZLegacyAnimation::GetBodySourceCode() const +{ + std::string body = "\n"; + + std::string frameDataName = parent->GetDeclarationPtrName(frameData); + std::string jointKeyName = parent->GetDeclarationPtrName(jointKey); + + body += StringHelper::Sprintf("\t%i, %i,\n", frameCount, limbCount); + body += StringHelper::Sprintf("\t%s,\n", frameDataName.c_str()); + body += StringHelper::Sprintf("\t%s\n", jointKeyName.c_str()); + + return body; +} + +std::string ZLegacyAnimation::GetSourceOutputCode(const std::string& prefix) +{ + std::string body = GetBodySourceCode(); + + Declaration* decl = parent->GetDeclaration(rawDataIndex); + if (decl == nullptr || decl->isPlaceholder) + parent->AddDeclaration(rawDataIndex, DeclarationAlignment::Align4, GetRawDataSize(), + GetSourceTypeName(), name, body); + else + decl->text = body; + + return ""; +} + +std::string ZLegacyAnimation::GetSourceTypeName() const +{ + return "LegacyAnimationHeader"; +} + +size_t ZLegacyAnimation::GetRawDataSize() const +{ + return 0x0C; +} + +JointKey::JointKey(ZFile* nParent) : ZResource(nParent) +{ +} + +void JointKey::ParseRawData() +{ + ZResource::ParseRawData(); + + const auto& rawData = parent->GetRawData(); + xMax = BitConverter::ToInt16BE(rawData, rawDataIndex + 0x00); + x = BitConverter::ToInt16BE(rawData, rawDataIndex + 0x02); + yMax = BitConverter::ToInt16BE(rawData, rawDataIndex + 0x04); + y = BitConverter::ToInt16BE(rawData, rawDataIndex + 0x06); + zMax = BitConverter::ToInt16BE(rawData, rawDataIndex + 0x08); + z = BitConverter::ToInt16BE(rawData, rawDataIndex + 0x0A); +} + +std::string JointKey::GetBodySourceCode() const +{ + return StringHelper::Sprintf("%6i, %6i, %6i, %6i, %6i, %6i", xMax, x, yMax, y, zMax, z); +} + +std::string JointKey::GetSourceTypeName() const +{ + return "JointKey"; +} + +ZResourceType JointKey::GetResourceType() const +{ + // TODO + return ZResourceType::Error; +} + +size_t JointKey::GetRawDataSize() const +{ + return 0x0C; +} diff --git a/tools/ZAPD/ZAPD/ZAnimation.h b/tools/ZAPD/ZAPD/ZAnimation.h index 2d23dddf4b..f7d2a7cf17 100644 --- a/tools/ZAPD/ZAPD/ZAnimation.h +++ b/tools/ZAPD/ZAPD/ZAnimation.h @@ -126,8 +126,7 @@ public: void ParseXML(tinyxml2::XMLElement* reader) override; void ParseRawData() override; - void ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector& nRawData, - const uint32_t nRawDataIndex) override; + void ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) override; void DeclareReferences(const std::string& prefix) override; size_t GetRawDataSize() const override; @@ -136,3 +135,50 @@ public: std::string GetSourceTypeName() const override; }; // TransformUpdateIndex + +/* ZLegacyAnimation */ + +class JointKey : public ZResource +{ +public: + JointKey(ZFile* nParent); + + void ParseRawData() override; + std::string GetBodySourceCode() const override; + + std::string GetSourceTypeName() const override; + ZResourceType GetResourceType() const override; + + size_t GetRawDataSize() const override; + +protected: + int16_t xMax, x; + int16_t yMax, y; + int16_t zMax, z; +}; + +class ZLegacyAnimation : public ZAnimation +{ +public: + ZLegacyAnimation(ZFile* nParent); + + void ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) override; + + void ParseRawData() override; + void DeclareReferences(const std::string& prefix) override; + std::string GetBodySourceCode() const override; + + std::string GetSourceOutputCode(const std::string& prefix) override; + + std::string GetSourceTypeName() const override; + + size_t GetRawDataSize() const override; + +protected: + int16_t limbCount; + segptr_t frameData; // s16* + segptr_t jointKey; // JointKey* + + std::vector frameDataArray; + std::vector jointKeyArray; +}; diff --git a/tools/ZAPD/ZAPD/ZArray.cpp b/tools/ZAPD/ZAPD/ZArray.cpp index 3194eac2d7..e514960fb0 100644 --- a/tools/ZAPD/ZAPD/ZArray.cpp +++ b/tools/ZAPD/ZAPD/ZArray.cpp @@ -22,7 +22,7 @@ void ZArray::ParseXML(tinyxml2::XMLElement* reader) { ZResource::ParseXML(reader); - arrayCnt = StringHelper::StrToL(registeredAttributes.at("Count").value, 0); + arrayCnt = reader->IntAttribute("Count", 0); // TODO: do a better check. assert(arrayCnt > 0); @@ -46,7 +46,7 @@ void ZArray::ParseXML(tinyxml2::XMLElement* reader) } res->parent = parent; res->SetInnerNode(true); - res->ExtractFromXML(child, rawData, childIndex); + res->ExtractFromXML(child, childIndex); childIndex += res->GetRawDataSize(); resList.push_back(res); diff --git a/tools/ZAPD/ZAPD/ZBackground.cpp b/tools/ZAPD/ZAPD/ZBackground.cpp index 94388bf28c..2bc4cbc9a5 100644 --- a/tools/ZAPD/ZAPD/ZBackground.cpp +++ b/tools/ZAPD/ZAPD/ZBackground.cpp @@ -15,11 +15,9 @@ ZBackground::ZBackground(ZFile* nParent) : ZResource(nParent) { } -ZBackground::ZBackground(const std::string& prefix, const std::vector& nRawData, - uint32_t nRawDataIndex, ZFile* nParent) +ZBackground::ZBackground(const std::string& prefix, uint32_t nRawDataIndex, ZFile* nParent) : ZResource(nParent) { - rawData.assign(nRawData.begin(), nRawData.end()); rawDataIndex = nRawDataIndex; name = GetDefaultName(prefix.c_str(), rawDataIndex); outName = name; @@ -31,6 +29,7 @@ void ZBackground::ParseRawData() { ZResource::ParseRawData(); + const auto& rawData = parent->GetRawData(); size_t i = 0; while (true) { @@ -61,10 +60,9 @@ void ZBackground::ParseBinaryFile(const std::string& inFolder, bool appendOutNam CheckValidJpeg(filepath.generic_string()); } -void ZBackground::ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector& nRawData, - uint32_t nRawDataIndex) +void ZBackground::ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) { - ZResource::ExtractFromXML(reader, nRawData, nRawDataIndex); + ZResource::ExtractFromXML(reader, nRawDataIndex); DeclareVar("", ""); } diff --git a/tools/ZAPD/ZAPD/ZBackground.h b/tools/ZAPD/ZAPD/ZBackground.h index 3df5c794b7..292d8a4363 100644 --- a/tools/ZAPD/ZAPD/ZBackground.h +++ b/tools/ZAPD/ZAPD/ZBackground.h @@ -11,12 +11,11 @@ protected: public: ZBackground(ZFile* nParent); - ZBackground(const std::string& prefix, const std::vector& nRawData, - uint32_t nRawDataIndex, ZFile* nParent); + ZBackground(const std::string& prefix, uint32_t nRawDataIndex, ZFile* nParent); + void ParseRawData() override; void ParseBinaryFile(const std::string& inFolder, bool appendOutName); - void ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector& nRawData, - uint32_t nRawDataIndex) override; + void ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) override; void CheckValidJpeg(const std::string& filepath); diff --git a/tools/ZAPD/ZAPD/ZBlob.cpp b/tools/ZAPD/ZAPD/ZBlob.cpp index e377bcf8c9..6964e4ea99 100644 --- a/tools/ZAPD/ZAPD/ZBlob.cpp +++ b/tools/ZAPD/ZAPD/ZBlob.cpp @@ -45,7 +45,8 @@ void ZBlob::ParseXML(tinyxml2::XMLElement* reader) void ZBlob::ParseRawData() { - blobData.assign(rawData.data() + rawDataIndex, rawData.data() + rawDataIndex + blobSize); + blobData.assign(parent->GetRawData().begin() + rawDataIndex, + parent->GetRawData().begin() + rawDataIndex + blobSize); } std::string ZBlob::GetSourceOutputCode(const std::string& prefix) diff --git a/tools/ZAPD/ZAPD/ZCollision.cpp b/tools/ZAPD/ZAPD/ZCollision.cpp index 34d7ee12d0..822b36584c 100644 --- a/tools/ZAPD/ZAPD/ZCollision.cpp +++ b/tools/ZAPD/ZAPD/ZCollision.cpp @@ -21,26 +21,26 @@ ZCollisionHeader::~ZCollisionHeader() void ZCollisionHeader::ParseRawData() { - const uint8_t* data = rawData.data(); + const auto& rawData = parent->GetRawData(); - absMinX = BitConverter::ToInt16BE(data, rawDataIndex + 0); - absMinY = BitConverter::ToInt16BE(data, rawDataIndex + 2); - absMinZ = BitConverter::ToInt16BE(data, rawDataIndex + 4); + absMinX = BitConverter::ToInt16BE(rawData, rawDataIndex + 0); + absMinY = BitConverter::ToInt16BE(rawData, rawDataIndex + 2); + absMinZ = BitConverter::ToInt16BE(rawData, rawDataIndex + 4); - absMaxX = BitConverter::ToInt16BE(data, rawDataIndex + 6); - absMaxY = BitConverter::ToInt16BE(data, rawDataIndex + 8); - absMaxZ = BitConverter::ToInt16BE(data, rawDataIndex + 10); + absMaxX = BitConverter::ToInt16BE(rawData, rawDataIndex + 6); + absMaxY = BitConverter::ToInt16BE(rawData, rawDataIndex + 8); + absMaxZ = BitConverter::ToInt16BE(rawData, rawDataIndex + 10); - numVerts = BitConverter::ToUInt16BE(data, rawDataIndex + 12); - vtxAddress = BitConverter::ToInt32BE(data, rawDataIndex + 16); + numVerts = BitConverter::ToUInt16BE(rawData, rawDataIndex + 12); + vtxAddress = BitConverter::ToInt32BE(rawData, rawDataIndex + 16); - numPolygons = BitConverter::ToUInt16BE(data, rawDataIndex + 20); - polyAddress = BitConverter::ToInt32BE(data, rawDataIndex + 24); - polyTypeDefAddress = BitConverter::ToInt32BE(data, rawDataIndex + 28); - camDataAddress = BitConverter::ToInt32BE(data, rawDataIndex + 32); + numPolygons = BitConverter::ToUInt16BE(rawData, rawDataIndex + 20); + polyAddress = BitConverter::ToInt32BE(rawData, rawDataIndex + 24); + polyTypeDefAddress = BitConverter::ToInt32BE(rawData, rawDataIndex + 28); + camDataAddress = BitConverter::ToInt32BE(rawData, rawDataIndex + 32); - numWaterBoxes = BitConverter::ToUInt16BE(data, rawDataIndex + 36); - waterBoxAddress = BitConverter::ToInt32BE(data, rawDataIndex + 40); + numWaterBoxes = BitConverter::ToUInt16BE(rawData, rawDataIndex + 36); + waterBoxAddress = BitConverter::ToInt32BE(rawData, rawDataIndex + 40); vtxSegmentOffset = Seg2Filespace(vtxAddress, parent->baseAddress); polySegmentOffset = Seg2Filespace(polyAddress, parent->baseAddress); @@ -66,7 +66,8 @@ void ZCollisionHeader::ParseRawData() } for (uint16_t i = 0; i < highestPolyType + 1; i++) - polygonTypes.push_back(BitConverter::ToUInt64BE(data, polyTypeDefSegmentOffset + (i * 8))); + polygonTypes.push_back( + BitConverter::ToUInt64BE(rawData, polyTypeDefSegmentOffset + (i * 8))); if (camDataAddress != 0) camData = new CameraDataList(parent, name, rawData, camDataSegmentOffset, diff --git a/tools/ZAPD/ZAPD/ZCutscene.cpp b/tools/ZAPD/ZAPD/ZCutscene.cpp index 48e6a46762..2c0f7d3e33 100644 --- a/tools/ZAPD/ZAPD/ZCutscene.cpp +++ b/tools/ZAPD/ZAPD/ZCutscene.cpp @@ -151,15 +151,18 @@ size_t ZCutscene::GetRawDataSize() const return size; } -void ZCutscene::ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector& nRawData, - const uint32_t nRawDataIndex) +void ZCutscene::ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) { - ZResource::ExtractFromXML(reader, nRawData, nRawDataIndex); + ZResource::ExtractFromXML(reader, nRawDataIndex); DeclareVar(parent->GetName(), ""); } void ZCutscene::ParseRawData() { + ZResource::ParseRawData(); + + const auto& rawData = parent->GetRawData(); + numCommands = BitConverter::ToInt32BE(rawData, rawDataIndex + 0); commands = std::vector(); diff --git a/tools/ZAPD/ZAPD/ZCutscene.h b/tools/ZAPD/ZAPD/ZCutscene.h index 4899c82f89..2167379589 100644 --- a/tools/ZAPD/ZAPD/ZCutscene.h +++ b/tools/ZAPD/ZAPD/ZCutscene.h @@ -434,8 +434,7 @@ public: ZResourceType GetResourceType() const override; - void ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector& nRawData, - const uint32_t nRawDataIndex) override; + void ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) override; protected: int32_t numCommands; diff --git a/tools/ZAPD/ZAPD/ZCutsceneMM.cpp b/tools/ZAPD/ZAPD/ZCutsceneMM.cpp index bb6724060c..ed663da81b 100644 --- a/tools/ZAPD/ZAPD/ZCutsceneMM.cpp +++ b/tools/ZAPD/ZAPD/ZCutsceneMM.cpp @@ -58,16 +58,16 @@ size_t ZCutsceneMM::GetRawDataSize() const return 8 + data.size() * 4; } -void ZCutsceneMM::ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector& nRawData, - const uint32_t nRawDataIndex) +void ZCutsceneMM::ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) { - ZResource::ExtractFromXML(reader, nRawData, nRawDataIndex); + ZResource::ExtractFromXML(reader, nRawDataIndex); DeclareVar(parent->GetName(), ""); } void ZCutsceneMM::ParseRawData() { segmentOffset = rawDataIndex; + const auto& rawData = parent->GetRawData(); numCommands = BitConverter::ToInt32BE(rawData, rawDataIndex + 0); commands = std::vector(); diff --git a/tools/ZAPD/ZAPD/ZCutsceneMM.h b/tools/ZAPD/ZAPD/ZCutsceneMM.h index c0438ed726..5cda5a1eeb 100644 --- a/tools/ZAPD/ZAPD/ZCutsceneMM.h +++ b/tools/ZAPD/ZAPD/ZCutsceneMM.h @@ -24,8 +24,7 @@ public: void ParseRawData() override; ZResourceType GetResourceType() const override; - void ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector& nRawData, - const uint32_t nRawDataIndex) override; + void ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) override; protected: int32_t numCommands; diff --git a/tools/ZAPD/ZAPD/ZDisplayList.cpp b/tools/ZAPD/ZAPD/ZDisplayList.cpp index de041f121c..9d9cca3fe9 100644 --- a/tools/ZAPD/ZAPD/ZDisplayList.cpp +++ b/tools/ZAPD/ZAPD/ZDisplayList.cpp @@ -1,7 +1,9 @@ #include "ZDisplayList.h" + #include #include #include +#include #include #include #include "BitConverter.h" @@ -41,46 +43,40 @@ ZDisplayList::~ZDisplayList() } // EXTRACT MODE -void ZDisplayList::ExtractFromXML(tinyxml2::XMLElement* reader, - const std::vector& nRawData, - const uint32_t nRawDataIndex) +void ZDisplayList::ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) { - rawData.assign(nRawData.begin(), nRawData.end()); rawDataIndex = nRawDataIndex; ParseXML(reader); - fileData = nRawData; int32_t rawDataSize = ZDisplayList::GetDListLength( - nRawData, rawDataIndex, + parent->GetRawData(), rawDataIndex, Globals::Instance->game == ZGame::OOT_SW97 ? DListType::F3DEX : DListType::F3DZEX); - dlistRawData.assign(nRawData.data() + rawDataIndex, - nRawData.data() + rawDataIndex + rawDataSize); + numInstructions = rawDataSize / 8; ParseRawData(); DeclareVar("", ""); } -ZDisplayList::ZDisplayList(std::vector nRawData, uint32_t nRawDataIndex, - int32_t rawDataSize, ZFile* nParent) +ZDisplayList::ZDisplayList(uint32_t nRawDataIndex, int32_t rawDataSize, ZFile* nParent) : ZDisplayList(nParent) { - rawData.assign(nRawData.begin(), nRawData.end()); - fileData = nRawData; rawDataIndex = nRawDataIndex; name = StringHelper::Sprintf("DL_%06X", rawDataIndex); - dlistRawData.assign(nRawData.data() + rawDataIndex, - nRawData.data() + rawDataIndex + rawDataSize); + numInstructions = rawDataSize / 8; ParseRawData(); } void ZDisplayList::ParseRawData() { - size_t numInstructions = dlistRawData.size() / 8; - + const auto& rawData = parent->GetRawData(); instructions.reserve(numInstructions); + uint32_t ptr = rawDataIndex; for (size_t i = 0; i < numInstructions; i++) - instructions.push_back(BitConverter::ToUInt64BE(dlistRawData, (i * 8))); + { + instructions.push_back(BitConverter::ToUInt64BE(rawData, ptr)); + ptr += 8; + } } Declaration* ZDisplayList::DeclareVar(const std::string& prefix, const std::string& bodyStr) @@ -262,9 +258,9 @@ void ZDisplayList::ParseF3DZEX(F3DZEXOpcode opcode, uint64_t data, int32_t i, st sprintf(line, "gsSPBranchLessZraw(%sDlist0x%06X, 0x%02X, 0x%02X),", prefix.c_str(), h & 0x00FFFFFF, (a / 5) | (b / 2), z); - ZDisplayList* nList = - new ZDisplayList(fileData, h & 0x00FFFFFF, - GetDListLength(fileData, h & 0x00FFFFFF, dListType), parent); + ZDisplayList* nList = new ZDisplayList( + h & 0x00FFFFFF, GetDListLength(parent->GetRawData(), h & 0x00FFFFFF, dListType), + parent); nList->scene = scene; otherDLists.push_back(nList); @@ -411,11 +407,9 @@ void ZDisplayList::ParseF3DEX(F3DEXOpcode opcode, uint64_t data, std::string pre } } -int32_t ZDisplayList::GetDListLength(std::vector rawData, uint32_t rawDataIndex, +int32_t ZDisplayList::GetDListLength(const std::vector& rawData, uint32_t rawDataIndex, DListType dListType) { - int32_t i = 0; - uint8_t endDLOpcode; if (dListType == DListType::F3DZEX) @@ -423,13 +417,25 @@ int32_t ZDisplayList::GetDListLength(std::vector rawData, uint32_t rawD else endDLOpcode = (uint8_t)F3DEXOpcode::G_ENDDL; + uint32_t ptr = rawDataIndex; + size_t rawDataSize = rawData.size(); while (true) { - uint8_t opcode = rawData.at(rawDataIndex + (i * 8)); - i++; + if (ptr > rawDataSize) + { + throw std::runtime_error( + StringHelper::Sprintf("%s: Fatal error.\n" + "\t End of file found when trying to find the end of the " + "DisplayList at offset: '0x%X'.\n", + __PRETTY_FUNCTION__, rawDataIndex)); + throw std::runtime_error(""); + } + + uint8_t opcode = rawData.at(ptr); + ptr += 8; if (opcode == endDLOpcode) - return i * 8; + return ptr - rawDataIndex; } } @@ -504,7 +510,7 @@ int32_t ZDisplayList::OptimizationCheck_LoadTextureBlock(int32_t startIndex, std fmt = (__ & 0xE0) >> 5; siz = (__ & 0x18) >> 3; texAddr = Seg2Filespace(data, parent->baseAddress); - int32_t segmentNumber = GETSEGNUM(data); + uint32_t segmentNumber = GETSEGNUM(data); lastTexSeg = segmentNumber; @@ -698,9 +704,9 @@ void ZDisplayList::Opcode_G_DL(uint64_t data, std::string prefix, char* line) } else { - ZDisplayList* nList = - new ZDisplayList(fileData, GETSEGOFFSET(data), - GetDListLength(fileData, GETSEGOFFSET(data), dListType), parent); + ZDisplayList* nList = new ZDisplayList( + GETSEGOFFSET(data), GetDListLength(parent->GetRawData(), GETSEGOFFSET(data), dListType), + parent); // if (scene != nullptr) { @@ -863,7 +869,6 @@ void ZDisplayList::Opcode_G_VTX(uint64_t data, char* line) for (int32_t i = 0; i < nn; i++) { ZVtx vtx(parent); - vtx.SetRawData(fileData); vtx.SetRawDataIndex(currentPtr); vtx.ParseRawData(); vtxList.push_back(vtx); @@ -1633,7 +1638,6 @@ static int32_t GfxdCallback_Vtx(uint32_t seg, int32_t count) for (int32_t i = 0; i < count; i++) { ZVtx vtx(self->parent); - vtx.SetRawData(self->fileData); vtx.SetRawDataIndex(currentPtr); vtx.ParseRawData(); @@ -1656,7 +1660,7 @@ static int32_t GfxdCallback_Texture(segptr_t seg, int32_t fmt, int32_t siz, int3 { ZDisplayList* self = static_cast(gfxd_udata_get()); uint32_t texOffset = Seg2Filespace(seg, self->parent->baseAddress); - int32_t texSegNum = GETSEGNUM(seg); + uint32_t texSegNum = GETSEGNUM(seg); self->lastTexWidth = width; self->lastTexHeight = height; @@ -1692,7 +1696,7 @@ static int32_t GfxdCallback_Palette(uint32_t seg, int32_t idx, int32_t count) { ZDisplayList* self = static_cast(gfxd_udata_get()); uint32_t palOffset = Seg2Filespace(seg, self->parent->baseAddress); - int32_t palSegNum = GETSEGNUM(seg); + uint32_t palSegNum = GETSEGNUM(seg); self->lastTexWidth = sqrt(count); self->lastTexHeight = sqrt(count); @@ -1728,13 +1732,14 @@ static int32_t GfxdCallback_DisplayList(uint32_t seg) { ZDisplayList* self = static_cast(gfxd_udata_get()); uint32_t dListOffset = GETSEGOFFSET(seg); - int32_t dListSegNum = GETSEGNUM(seg); + uint32_t dListSegNum = GETSEGNUM(seg); if ((dListSegNum <= 6) && Globals::Instance->HasSegment(dListSegNum)) { ZDisplayList* newDList = new ZDisplayList( - self->fileData, dListOffset, - self->GetDListLength(self->fileData, dListOffset, self->dListType), self->parent); + dListOffset, + self->GetDListLength(self->parent->GetRawData(), dListOffset, self->dListType), + self->parent); newDList->scene = self->scene; newDList->parent = self->parent; self->otherDLists.push_back(newDList); @@ -1764,8 +1769,7 @@ static int32_t GfxdCallback_Matrix(uint32_t seg) self->parent->GetDeclaration(Seg2Filespace(seg, self->parent->baseAddress)); if (decl == nullptr) { - ZMtx mtx(self->GetName(), self->fileData, Seg2Filespace(seg, self->parent->baseAddress), - self->parent); + ZMtx mtx(self->GetName(), Seg2Filespace(seg, self->parent->baseAddress), self->parent); mtx.GetSourceOutputCode(self->GetName()); self->mtxList.push_back(mtx); @@ -2032,8 +2036,8 @@ std::string ZDisplayList::ProcessGfxDis(const std::string& prefix) void ZDisplayList::TextureGenCheck(std::string prefix) { - if (TextureGenCheck(fileData, scene, parent, prefix, lastTexWidth, lastTexHeight, lastTexAddr, - lastTexSeg, lastTexFmt, lastTexSiz, lastTexLoaded, lastTexIsPalette, this)) + if (TextureGenCheck(scene, parent, prefix, lastTexWidth, lastTexHeight, lastTexAddr, lastTexSeg, + lastTexFmt, lastTexSiz, lastTexLoaded, lastTexIsPalette, this)) { lastTexAddr = 0; lastTexLoaded = false; @@ -2041,11 +2045,10 @@ void ZDisplayList::TextureGenCheck(std::string prefix) } } -bool ZDisplayList::TextureGenCheck(std::vector fileData, ZRoom* scene, ZFile* parent, - std::string prefix, int32_t texWidth, int32_t texHeight, - uint32_t texAddr, uint32_t texSeg, F3DZEXTexFormats texFmt, - F3DZEXTexSizes texSiz, bool texLoaded, bool texIsPalette, - ZDisplayList* self) +bool ZDisplayList::TextureGenCheck(ZRoom* scene, ZFile* parent, std::string prefix, + int32_t texWidth, int32_t texHeight, uint32_t texAddr, + uint32_t texSeg, F3DZEXTexFormats texFmt, F3DZEXTexSizes texSiz, + bool texLoaded, bool texIsPalette, ZDisplayList* self) { int32_t segmentNumber = GETSEGNUM(texSeg); @@ -2071,7 +2074,7 @@ bool ZDisplayList::TextureGenCheck(std::vector fileData, ZRoom* scene, else { tex = new ZTexture(parent); - tex->FromBinary(fileData, texAddr, texWidth, texHeight, + tex->FromBinary(texAddr, texWidth, texHeight, TexFormatToTexType(texFmt, texSiz), texIsPalette); parent->AddTextureResource(texAddr, tex); } @@ -2094,7 +2097,7 @@ bool ZDisplayList::TextureGenCheck(std::vector fileData, ZRoom* scene, else { tex = new ZTexture(scene->parent); - tex->FromBinary(scene->GetRawData(), texAddr, texWidth, texHeight, + tex->FromBinary(texAddr, texWidth, texHeight, TexFormatToTexType(texFmt, texSiz), texIsPalette); scene->parent->AddTextureResource(texAddr, tex); @@ -2144,7 +2147,7 @@ TextureType ZDisplayList::TexFormatToTexType(F3DZEXTexFormats fmt, F3DZEXTexSize else if (fmt == F3DZEXTexFormats::G_IM_FMT_IA) { if (siz == F3DZEXTexSizes::G_IM_SIZ_4b) - return TextureType::Grayscale4bpp; + return TextureType::GrayscaleAlpha4bpp; else if (siz == F3DZEXTexSizes::G_IM_SIZ_8b) return TextureType::GrayscaleAlpha8bpp; else if (siz == F3DZEXTexSizes::G_IM_SIZ_16b) diff --git a/tools/ZAPD/ZAPD/ZDisplayList.h b/tools/ZAPD/ZAPD/ZDisplayList.h index 091b4b27df..09394b263e 100644 --- a/tools/ZAPD/ZAPD/ZDisplayList.h +++ b/tools/ZAPD/ZAPD/ZDisplayList.h @@ -346,28 +346,24 @@ public: std::vector references; std::string defines; // Hack for special cases where vertex arrays intersect... - std::vector fileData; std::vector mtxList; ZDisplayList(ZFile* nParent); - ZDisplayList(std::vector nRawData, uint32_t rawDataIndex, int32_t rawDataSize, - ZFile* nParent); + ZDisplayList(uint32_t rawDataIndex, int32_t rawDataSize, ZFile* nParent); ~ZDisplayList(); - void ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector& nRawData, - const uint32_t nRawDataIndex) override; + void ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) override; void ParseRawData() override; Declaration* DeclareVar(const std::string& prefix, const std::string& bodyStr); void TextureGenCheck(std::string prefix); - static bool TextureGenCheck(std::vector fileData, ZRoom* scene, ZFile* parent, - std::string prefix, int32_t texWidth, int32_t texHeight, - uint32_t texAddr, uint32_t texSeg, F3DZEXTexFormats texFmt, - F3DZEXTexSizes texSiz, bool texLoaded, bool texIsPalette, - ZDisplayList* self); - static int32_t GetDListLength(std::vector rawData, uint32_t rawDataIndex, + static bool TextureGenCheck(ZRoom* scene, ZFile* parent, std::string prefix, int32_t texWidth, + int32_t texHeight, uint32_t texAddr, uint32_t texSeg, + F3DZEXTexFormats texFmt, F3DZEXTexSizes texSiz, bool texLoaded, + bool texIsPalette, ZDisplayList* self); + static int32_t GetDListLength(const std::vector& rawData, uint32_t rawDataIndex, DListType dListType); size_t GetRawDataSize() const override; @@ -384,5 +380,5 @@ public: ZResourceType GetResourceType() const override; protected: - std::vector dlistRawData; + size_t numInstructions; }; diff --git a/tools/ZAPD/ZAPD/ZFile.cpp b/tools/ZAPD/ZAPD/ZFile.cpp index ed106153f5..b09dc55c32 100644 --- a/tools/ZAPD/ZAPD/ZFile.cpp +++ b/tools/ZAPD/ZAPD/ZFile.cpp @@ -31,7 +31,6 @@ ZFile::ZFile() { resources = std::vector(); basePath = ""; - outputPath = Directory::GetCurrentDirectory(); declarations = std::map(); defines = ""; baseAddress = 0; @@ -39,15 +38,13 @@ ZFile::ZFile() rangeEnd = 0xFFFFFFFF; } -ZFile::ZFile(const fs::path& nOutPath, std::string nName) : ZFile() +ZFile::ZFile(std::string nName) : ZFile() { - outputPath = nOutPath; name = nName; } ZFile::ZFile(ZFileMode mode, tinyxml2::XMLElement* reader, const fs::path& nBasePath, - const fs::path& nOutPath, std::string filename, const fs::path& nXmlFilePath, - bool placeholderMode) + std::string filename, const fs::path& nXmlFilePath, bool placeholderMode) : ZFile() { xmlFilePath = nXmlFilePath; @@ -56,11 +53,6 @@ ZFile::ZFile(ZFileMode mode, tinyxml2::XMLElement* reader, const fs::path& nBase else basePath = nBasePath; - if (nOutPath == "") - outputPath = Directory::GetCurrentDirectory(); - else - outputPath = nOutPath; - ParseXML(mode, reader, filename, placeholderMode); DeclareResourceSubReferences(); } @@ -85,6 +77,11 @@ void ZFile::ParseXML(ZFileMode mode, XMLElement* reader, std::string filename, b else name = filename; + outName = name; + const char* outNameXml = reader->Attribute("OutName"); + if (outNameXml != nullptr) + outName = outNameXml; + // TODO: This should be a variable on the ZFile, but it is a large change in order to force all // ZResource types to have a parent ZFile. const char* gameStr = reader->Attribute("Game"); @@ -125,8 +122,6 @@ void ZFile::ParseXML(ZFileMode mode, XMLElement* reader, std::string filename, b Globals::Instance->AddSegment(segment, this); } - std::string folderName = (basePath / Path::GetFileNameWithoutExtension(name)).string(); - if (mode == ZFileMode::Extract) { if (!File::Exists((basePath / name).string())) @@ -166,6 +161,15 @@ void ZFile::ParseXML(ZFileMode mode, XMLElement* reader, std::string filename, b } offsetSet.insert(offsetXml); } + else if (Globals::Instance->warnNoOffset) + { + fprintf(stderr, "Warning No offset specified for: %s", nameXml); + } + else if (Globals::Instance->errorNoOffset) + { + throw std::runtime_error( + StringHelper::Sprintf("Error no offset specified for %s", nameXml)); + } if (outNameXml != nullptr) { if (outNameSet.find(outNameXml) != outNameSet.end()) @@ -194,7 +198,7 @@ void ZFile::ParseXML(ZFileMode mode, XMLElement* reader, std::string filename, b ZResource* nRes = nodeMap[nodeName](this); if (mode == ZFileMode::Extract) - nRes->ExtractFromXML(child, rawData, rawDataIndex); + nRes->ExtractFromXML(child, rawDataIndex); auto resType = nRes->GetResourceType(); if (resType == ZResourceType::Texture) @@ -228,14 +232,12 @@ void ZFile::DeclareResourceSubReferences() } } -void ZFile::BuildSourceFile(fs::path outputDir) +void ZFile::BuildSourceFile() { - std::string folderName = Path::GetFileNameWithoutExtension(outputPath.string()); + if (!Directory::Exists(Globals::Instance->outputPath)) + Directory::CreateDirectory(Globals::Instance->outputPath); - if (!Directory::Exists(outputPath.string())) - Directory::CreateDirectory(outputPath.string()); - - GenerateSourceFiles(outputDir); + GenerateSourceFiles(Globals::Instance->outputPath); } std::string ZFile::GetVarName(uint32_t address) @@ -264,28 +266,26 @@ const std::vector& ZFile::GetRawData() const return rawData; } -void ZFile::ExtractResources(fs::path outputDir) +void ZFile::ExtractResources() { - std::string folderName = Path::GetFileNameWithoutExtension(outputPath.string()); + if (!Directory::Exists(Globals::Instance->outputPath)) + Directory::CreateDirectory(Globals::Instance->outputPath); - if (!Directory::Exists(outputPath.string())) - Directory::CreateDirectory(outputPath.string()); - - if (!Directory::Exists(Globals::Instance->sourceOutputPath.string())) - Directory::CreateDirectory(Globals::Instance->sourceOutputPath.string()); + if (!Directory::Exists(GetSourceOutputFolderPath().string())) + Directory::CreateDirectory(GetSourceOutputFolderPath().string()); for (ZResource* res : resources) res->PreGenSourceFiles(); if (Globals::Instance->genSourceFile) - GenerateSourceFiles(outputDir); + GenerateSourceFiles(Globals::Instance->outputPath); for (ZResource* res : resources) { if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_INFO) printf("Saving resource %s\n", res->GetName().c_str()); - res->Save(outputPath); + res->Save(Globals::Instance->outputPath); } if (Globals::Instance->testMode) @@ -553,6 +553,7 @@ uint32_t ZFile::GetDeclarationRangedAddress(uint32_t address) const bool ZFile::HasDeclaration(uint32_t address) { + assert(GETSEGNUM(address) == 0); return declarations.find(address) != declarations.end(); } @@ -597,7 +598,7 @@ void ZFile::GenerateSourceFiles(fs::path outputDir) Globals::Instance->cfg.texturePool.end()) { incStr = Globals::Instance->cfg.texturePool[tex->hash].path.string() + "." + - res->GetExternalExtension() + ".inc"; + res->GetExternalExtension() + ".inc"; } } @@ -623,9 +624,10 @@ void ZFile::GenerateSourceFiles(fs::path outputDir) sourceOutput += ProcessDeclarations(); - std::string outPath = - (Globals::Instance->sourceOutputPath / (Path::GetFileNameWithoutExtension(name) + ".c")) - .string(); + fs::path outPath = GetSourceOutputFolderPath() / outName.stem().concat(".c"); + + if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_INFO) + printf("Writing C file: %s\n", outPath.c_str()); OutputFormatter formatter; formatter.Write(sourceOutput); @@ -650,10 +652,12 @@ void ZFile::GenerateSourceHeaderFiles() formatter.Write(ProcessExterns()); - fs::path headerFilename = - Globals::Instance->sourceOutputPath / (Path::GetFileNameWithoutExtension(name) + ".h"); + fs::path headerFilename = GetSourceOutputFolderPath() / outName.stem().concat(".h"); - File::WriteAllText(headerFilename.string(), formatter.GetOutput()); + if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_INFO) + printf("Writing H file: %s\n", headerFilename.c_str()); + + File::WriteAllText(headerFilename, formatter.GetOutput()); } void ZFile::GenerateHLIntermediette() @@ -675,7 +679,7 @@ void ZFile::GenerateHLIntermediette() std::string ZFile::GetHeaderInclude() { return StringHelper::Sprintf("#include \"%s\"\n\n", - (Path::GetFileNameWithoutExtension(name) + ".h").c_str()); + (outName.parent_path() / outName.stem().concat(".h")).c_str()); } void ZFile::GeneratePlaceholderDeclarations() @@ -706,6 +710,11 @@ ZTexture* ZFile::GetTextureResource(uint32_t offset) const return nullptr; } +fs::path ZFile::GetSourceOutputFolderPath() const +{ + return Globals::Instance->sourceOutputPath / outName.parent_path(); +} + std::map* ZFile::GetNodeMap() { static std::map nodeMap; @@ -909,8 +918,22 @@ std::string ZFile::ProcessDeclarations() nonZeroUnaccounted = true; } - if ((i % 16 == 15) && (i != (diff - 1))) - src += "\n "; + if (Globals::Instance->verboseUnaccounted) + { + if ((i % 4 == 3)) + { + src += StringHelper::Sprintf(" // 0x%06X", unaccountedAddress + i - 3); + if (i != (diff - 1)) + { + src += "\n\t"; + } + } + } + else + { + if ((i % 16 == 15) && (i != (diff - 1))) + src += "\n "; + } } if (declarations.find(unaccountedAddress) == declarations.end()) @@ -920,8 +943,14 @@ std::string ZFile::ProcessDeclarations() std::string unaccountedPrefix = "unaccounted"; if (diff < 16 && !nonZeroUnaccounted) + { unaccountedPrefix = "possiblePadding"; + // Strip unnecessary padding at the end of the file. + if (unaccountedAddress + diff >= rawData.size()) + break; + } + Declaration* decl = AddDeclarationArray( unaccountedAddress, DeclarationAlignment::None, diff, "static u8", StringHelper::Sprintf("%s_%06X", unaccountedPrefix.c_str(), diff --git a/tools/ZAPD/ZAPD/ZFile.h b/tools/ZAPD/ZAPD/ZFile.h index a3765a0a70..8ea976e8c3 100644 --- a/tools/ZAPD/ZAPD/ZFile.h +++ b/tools/ZAPD/ZAPD/ZFile.h @@ -33,21 +33,20 @@ public: std::map declarations; std::string defines; std::vector resources; - int32_t segment; + uint32_t segment; uint32_t baseAddress, rangeStart, rangeEnd; - ZFile(const fs::path& nOutPath, std::string nName); + ZFile(std::string nName); ZFile(ZFileMode mode, tinyxml2::XMLElement* reader, const fs::path& nBasePath, - const fs::path& nOutPath, std::string filename, const fs::path& nXmlFilePath, - bool placeholderMode); + std::string filename, const fs::path& nXmlFilePath, bool placeholderMode); ~ZFile(); std::string GetVarName(uint32_t address); std::string GetName() const; const fs::path& GetXmlFilePath() const; const std::vector& GetRawData() const; - void ExtractResources(fs::path outputDir); - void BuildSourceFile(fs::path outputDir); + void ExtractResources(); + void BuildSourceFile(); void AddResource(ZResource* res); ZResource* FindResource(uint32_t rawDataIndex); std::vector GetResourcesOfType(ZResourceType resType); @@ -89,14 +88,16 @@ public: void AddTextureResource(uint32_t offset, ZTexture* tex); ZTexture* GetTextureResource(uint32_t offset) const; + fs::path GetSourceOutputFolderPath() const; + static std::map* GetNodeMap(); static void RegisterNode(std::string nodeName, ZResourceFactoryFunc* nodeFunc); protected: std::vector rawData; std::string name; + fs::path outName = ""; fs::path basePath; - fs::path outputPath; fs::path xmlFilePath; // Keep track of every texture of this ZFile. // The pointers declared here are "borrowed" (somebody else is the owner), diff --git a/tools/ZAPD/ZAPD/ZLimb.cpp b/tools/ZAPD/ZAPD/ZLimb.cpp index ffb61e2762..ce62bac272 100644 --- a/tools/ZAPD/ZAPD/ZLimb.cpp +++ b/tools/ZAPD/ZAPD/ZLimb.cpp @@ -217,7 +217,7 @@ std::string Struct_800A598C::GetSourceTypeName() Struct_800A5E28::Struct_800A5E28(ZFile* parent, const std::vector& nRawData, uint32_t fileOffset) - : parent(parent), rawData(nRawData) + : parent(parent) { unk_0 = BitConverter::ToUInt16BE(nRawData, fileOffset + 0x00); unk_2 = BitConverter::ToUInt16BE(nRawData, fileOffset + 0x02); @@ -282,9 +282,9 @@ void Struct_800A5E28::PreGenSourceFiles(const std::string& prefix) uint32_t unk_8_Offset = Seg2Filespace(unk_8, parent->baseAddress); int32_t dlistLength = ZDisplayList::GetDListLength( - rawData, unk_8_Offset, + parent->GetRawData(), unk_8_Offset, Globals::Instance->game == ZGame::OOT_SW97 ? DListType::F3DEX : DListType::F3DZEX); - unk_8_dlist = new ZDisplayList(rawData, unk_8_Offset, dlistLength, parent); + unk_8_dlist = new ZDisplayList(unk_8_Offset, dlistLength, parent); std::string dListStr = StringHelper::Sprintf("%sSkinLimbDL_%06X", prefix.c_str(), unk_8_Offset); @@ -354,11 +354,9 @@ ZLimb::ZLimb(ZFile* nParent) : ZResource(nParent) RegisterOptionalAttribute("Type"); } -ZLimb::ZLimb(ZLimbType limbType, const std::string& prefix, const std::vector& nRawData, - uint32_t nRawDataIndex, ZFile* nParent) +ZLimb::ZLimb(ZLimbType limbType, const std::string& prefix, uint32_t nRawDataIndex, ZFile* nParent) : ZLimb(nParent) { - rawData.assign(nRawData.begin(), nRawData.end()); rawDataIndex = nRawDataIndex; parent = nParent; type = limbType; @@ -368,10 +366,9 @@ ZLimb::ZLimb(ZLimbType limbType, const std::string& prefix, const std::vector& nRawData, - const uint32_t nRawDataIndex) +void ZLimb::ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) { - ZResource::ExtractFromXML(reader, nRawData, nRawDataIndex); + ZResource::ExtractFromXML(reader, nRawDataIndex); parent->AddDeclaration(GetFileAddress(), DeclarationAlignment::None, GetRawDataSize(), GetSourceTypeName(), name, ""); @@ -397,23 +394,8 @@ void ZLimb::ParseXML(tinyxml2::XMLElement* reader) } else { - if (limbType == "Standard") - { - type = ZLimbType::Standard; - } - else if (limbType == "LOD") - { - type = ZLimbType::LOD; - } - else if (limbType == "Skin") - { - type = ZLimbType::Skin; - } - else if (limbType == "Curve") - { - type = ZLimbType::Curve; - } - else + type = GetTypeByAttributeName(limbType); + if (type == ZLimbType::Invalid) { fprintf(stderr, "ZLimb::ParseXML: Warning in '%s'.\n" @@ -429,6 +411,7 @@ void ZLimb::ParseRawData() { ZResource::ParseRawData(); + const auto& rawData = parent->GetRawData(); if (type == ZLimbType::Curve) { childIndex = rawData.at(rawDataIndex + 0); @@ -438,6 +421,19 @@ void ZLimb::ParseRawData() dList2Ptr = BitConverter::ToUInt32BE(rawData, rawDataIndex + 8); return; } + if (type == ZLimbType::Legacy) + { + dListPtr = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x00); + legTransX = BitConverter::ToFloatBE(rawData, rawDataIndex + 0x04); + legTransY = BitConverter::ToFloatBE(rawData, rawDataIndex + 0x08); + legTransZ = BitConverter::ToFloatBE(rawData, rawDataIndex + 0x0C); + rotX = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x10); + rotY = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x12); + rotZ = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x14); + childPtr = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x18); + siblingPtr = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x1C); + return; + } transX = BitConverter::ToInt16BE(rawData, rawDataIndex + 0); transY = BitConverter::ToInt16BE(rawData, rawDataIndex + 2); @@ -471,6 +467,47 @@ void ZLimb::ParseRawData() } } +void ZLimb::DeclareReferences(const std::string& prefix) +{ + ZResource::DeclareReferences(prefix); + + switch (type) + { + case ZLimbType::Legacy: + if (childPtr != 0 && GETSEGNUM(childPtr) == parent->segment) + { + uint32_t childOffset = Seg2Filespace(childPtr, parent->baseAddress); + if (!parent->HasDeclaration(childOffset)) + { + ZLimb* child = new ZLimb(ZLimbType::Legacy, prefix, childOffset, parent); + child->GetSourceOutputCode(prefix); + parent->AddResource(child); + } + } + if (siblingPtr != 0 && GETSEGNUM(siblingPtr) == parent->segment) + { + uint32_t siblingdOffset = Seg2Filespace(siblingPtr, parent->baseAddress); + if (!parent->HasDeclaration(siblingdOffset)) + { + ZLimb* sibling = new ZLimb(ZLimbType::Legacy, prefix, siblingdOffset, parent); + sibling->GetSourceOutputCode(prefix); + parent->AddResource(sibling); + } + } + break; + + // TODO + case ZLimbType::Standard: + case ZLimbType::LOD: + case ZLimbType::Skin: + case ZLimbType::Curve: + break; + + case ZLimbType::Invalid: + break; + } +} + size_t ZLimb::GetRawDataSize() const { switch (type) @@ -478,9 +515,16 @@ size_t ZLimb::GetRawDataSize() const case ZLimbType::Standard: case ZLimbType::Curve: return 0x0C; + case ZLimbType::LOD: case ZLimbType::Skin: return 0x10; + + case ZLimbType::Legacy: + return 0x20; + + case ZLimbType::Invalid: + break; } return 0x0C; @@ -493,26 +537,50 @@ std::string ZLimb::GetSourceOutputCode(const std::string& prefix) limbPrefix = type == ZLimbType::Curve ? "Curve" : "Far"; std::string dListStr2 = GetLimbDListSourceOutputCode(prefix, limbPrefix, dList2Ptr); - std::string entryStr = ""; - if (type != ZLimbType::Curve) + std::string entryStr = "\n\t"; + if (type == ZLimbType::Legacy) { - entryStr += StringHelper::Sprintf("\n { %i, %i, %i },", transX, transY, transZ); + std::string childName = parent->GetDeclarationPtrName(childPtr); + std::string siblingName = parent->GetDeclarationPtrName(siblingPtr); + + entryStr += StringHelper::Sprintf("%s,\n", dListStr.c_str()); + entryStr += + StringHelper::Sprintf("\t{ %ff, %ff, %ff },\n", legTransX, legTransY, legTransZ); + entryStr += StringHelper::Sprintf("\t{ 0x%04X, 0x%04X, 0x%04X },\n", rotX, rotY, rotZ); + entryStr += StringHelper::Sprintf("\t%s,\n", childName.c_str()); + entryStr += StringHelper::Sprintf("\t%s\n", siblingName.c_str()); } - - entryStr += StringHelper::Sprintf("\n 0x%02X, 0x%02X,\n", childIndex, siblingIndex); - - switch (type) + else { - case ZLimbType::Standard: - entryStr += StringHelper::Sprintf(" %s\n", dListStr.c_str()); - break; - case ZLimbType::LOD: - case ZLimbType::Curve: - entryStr += StringHelper::Sprintf(" { %s, %s }\n", dListStr.c_str(), dListStr2.c_str()); - break; - case ZLimbType::Skin: - entryStr += GetSourceOutputCodeSkin(prefix); - break; + if (type != ZLimbType::Curve) + { + entryStr += StringHelper::Sprintf("{ %i, %i, %i }, ", transX, transY, transZ); + } + + entryStr += StringHelper::Sprintf("0x%02X, 0x%02X,\n", childIndex, siblingIndex); + + switch (type) + { + case ZLimbType::Standard: + entryStr += StringHelper::Sprintf(" %s\n", dListStr.c_str()); + break; + + case ZLimbType::LOD: + case ZLimbType::Curve: + entryStr += + StringHelper::Sprintf(" { %s, %s }\n", dListStr.c_str(), dListStr2.c_str()); + break; + + case ZLimbType::Skin: + entryStr += GetSourceOutputCodeSkin(prefix); + break; + + case ZLimbType::Legacy: + break; + + case ZLimbType::Invalid: + break; + } } Declaration* decl = parent->GetDeclaration(GetFileAddress()); @@ -552,17 +620,49 @@ const char* ZLimb::GetSourceTypeName(ZLimbType limbType) { case ZLimbType::Standard: return "StandardLimb"; + case ZLimbType::LOD: return "LodLimb"; + case ZLimbType::Skin: return "SkinLimb"; + case ZLimbType::Curve: return "SkelCurveLimb"; + + case ZLimbType::Legacy: + return "LegacyLimb"; + default: return "StandardLimb"; } } +ZLimbType ZLimb::GetTypeByAttributeName(const std::string& attrName) +{ + if (attrName == "Standard") + { + return ZLimbType::Standard; + } + if (attrName == "LOD") + { + return ZLimbType::LOD; + } + if (attrName == "Skin") + { + return ZLimbType::Skin; + } + if (attrName == "Curve") + { + return ZLimbType::Curve; + } + if (attrName == "Legacy") + { + return ZLimbType::Legacy; + } + return ZLimbType::Invalid; +} + uint32_t ZLimb::GetFileAddress() { return Seg2Filespace(rawDataIndex, parent->baseAddress); @@ -607,9 +707,9 @@ std::string ZLimb::GetLimbDListSourceOutputCode(const std::string& prefix, StringHelper::Sprintf("%s%sLimbDL_%06X", prefix.c_str(), limbPrefix.c_str(), dListOffset); int32_t dlistLength = ZDisplayList::GetDListLength( - rawData, dListOffset, + parent->GetRawData(), dListOffset, Globals::Instance->game == ZGame::OOT_SW97 ? DListType::F3DEX : DListType::F3DZEX); - auto dList = new ZDisplayList(rawData, dListOffset, dlistLength, parent); + auto dList = new ZDisplayList(dListOffset, dlistLength, parent); dList->SetName(dListStr); dList->GetSourceOutputCode(prefix); return dListStr; diff --git a/tools/ZAPD/ZAPD/ZLimb.h b/tools/ZAPD/ZAPD/ZLimb.h index 8172bef44c..ac9f17d838 100644 --- a/tools/ZAPD/ZAPD/ZLimb.h +++ b/tools/ZAPD/ZAPD/ZLimb.h @@ -8,10 +8,12 @@ enum class ZLimbType { + Invalid, Standard, LOD, Skin, Curve, + Legacy, }; // TODO: check if more types exists @@ -93,7 +95,6 @@ class Struct_800A5E28 { protected: ZFile* parent; - std::vector rawData; uint16_t unk_0; // Vtx count uint16_t unk_2; // Length of unk_4 @@ -127,6 +128,12 @@ protected: Struct_800A5E28 segmentStruct; // Skin only segptr_t dList2Ptr; // LOD and Curve Only + // Legacy only + float legTransX, legTransY, legTransZ; // Vec3f + uint16_t rotX, rotY, rotZ; // Vec3s + segptr_t childPtr; // LegacyLimb* + segptr_t siblingPtr; // LegacyLimb* + std::string GetLimbDListSourceOutputCode(const std::string& prefix, const std::string& limbPrefix, segptr_t dListPtr); @@ -140,14 +147,13 @@ public: uint8_t childIndex, siblingIndex; ZLimb(ZFile* nParent); - ZLimb(ZLimbType limbType, const std::string& prefix, const std::vector& nRawData, - uint32_t nRawDataIndex, ZFile* nParent); + ZLimb(ZLimbType limbType, const std::string& prefix, uint32_t nRawDataIndex, ZFile* nParent); - void ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector& nRawData, - const uint32_t nRawDataIndex) override; + void ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) override; void ParseXML(tinyxml2::XMLElement* reader) override; void ParseRawData() override; + void DeclareReferences(const std::string& prefix) override; size_t GetRawDataSize() const override; std::string GetSourceOutputCode(const std::string& prefix) override; @@ -157,6 +163,7 @@ public: ZLimbType GetLimbType(); void SetLimbType(ZLimbType value); static const char* GetSourceTypeName(ZLimbType limbType); + static ZLimbType GetTypeByAttributeName(const std::string& attrName); uint32_t GetFileAddress(); void SetFileAddress(uint32_t nAddress); diff --git a/tools/ZAPD/ZAPD/ZMtx.cpp b/tools/ZAPD/ZAPD/ZMtx.cpp index 7beadeef1b..f92506cede 100644 --- a/tools/ZAPD/ZAPD/ZMtx.cpp +++ b/tools/ZAPD/ZAPD/ZMtx.cpp @@ -9,12 +9,10 @@ ZMtx::ZMtx(ZFile* nParent) : ZResource(nParent) { } -ZMtx::ZMtx(const std::string& prefix, const std::vector& nRawData, uint32_t nRawDataIndex, - ZFile* nParent) - : ZResource(nParent) +ZMtx::ZMtx(const std::string& prefix, uint32_t nRawDataIndex, ZFile* nParent) : ZResource(nParent) { name = GetDefaultName(prefix.c_str(), rawDataIndex); - ExtractFromFile(nRawData, nRawDataIndex); + ExtractFromFile(nRawDataIndex); DeclareVar("", ""); } @@ -22,15 +20,15 @@ void ZMtx::ParseRawData() { ZResource::ParseRawData(); + const auto& rawData = parent->GetRawData(); for (size_t i = 0; i < 4; ++i) for (size_t j = 0; j < 4; ++j) mtx[i][j] = BitConverter::ToInt32BE(rawData, rawDataIndex + (i * 4 + j) * 4); } -void ZMtx::ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector& nRawData, - uint32_t nRawDataIndex) +void ZMtx::ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) { - ZResource::ExtractFromXML(reader, nRawData, nRawDataIndex); + ZResource::ExtractFromXML(reader, nRawDataIndex); DeclareVar("", ""); } diff --git a/tools/ZAPD/ZAPD/ZMtx.h b/tools/ZAPD/ZAPD/ZMtx.h index 0771f29c43..7a98650efb 100644 --- a/tools/ZAPD/ZAPD/ZMtx.h +++ b/tools/ZAPD/ZAPD/ZMtx.h @@ -8,12 +8,10 @@ class ZMtx : public ZResource { public: ZMtx(ZFile* nParent); - ZMtx(const std::string& prefix, const std::vector& nRawData, uint32_t nRawDataIndex, - ZFile* nParent); + ZMtx(const std::string& prefix, uint32_t nRawDataIndex, ZFile* nParent); void ParseRawData() override; - void ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector& nRawData, - uint32_t nRawDataIndex) override; + void ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) override; size_t GetRawDataSize() const override; diff --git a/tools/ZAPD/ZAPD/ZPath.cpp b/tools/ZAPD/ZAPD/ZPath.cpp index 39e06fb0bf..890fa5e58d 100644 --- a/tools/ZAPD/ZAPD/ZPath.cpp +++ b/tools/ZAPD/ZAPD/ZPath.cpp @@ -13,10 +13,9 @@ ZPath::ZPath(ZFile* nParent) : ZResource(nParent) RegisterOptionalAttribute("NumPaths", "1"); } -void ZPath::ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector& nRawData, - const uint32_t nRawDataIndex) +void ZPath::ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) { - ZResource::ExtractFromXML(reader, nRawData, nRawDataIndex); + ZResource::ExtractFromXML(reader, nRawDataIndex); parent->AddDeclarationArray(rawDataIndex, DeclarationAlignment::Align4, pathways.size() * 8, GetSourceTypeName(), name, pathways.size(), ""); @@ -135,7 +134,6 @@ void PathwayEntry::ParseRawData() for (int32_t i = 0; i < numPoints; i++) { ZVector vec(parent); - vec.SetRawData(parentRawData); vec.SetRawDataIndex(currentPtr); vec.SetScalarType(ZScalarType::ZSCALAR_S16); vec.SetDimensions(3); diff --git a/tools/ZAPD/ZAPD/ZPath.h b/tools/ZAPD/ZAPD/ZPath.h index 55fc17dc2a..23e2933e61 100644 --- a/tools/ZAPD/ZAPD/ZPath.h +++ b/tools/ZAPD/ZAPD/ZPath.h @@ -32,8 +32,7 @@ class ZPath : public ZResource public: ZPath(ZFile* nParent); - void ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector& nRawData, - const uint32_t nRawDataIndex); + void ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex); void ParseXML(tinyxml2::XMLElement* reader) override; void ParseRawData() override; diff --git a/tools/ZAPD/ZAPD/ZResource.cpp b/tools/ZAPD/ZAPD/ZResource.cpp index 55e142faa8..f64ce4aa05 100644 --- a/tools/ZAPD/ZAPD/ZResource.cpp +++ b/tools/ZAPD/ZAPD/ZResource.cpp @@ -21,10 +21,8 @@ ZResource::ZResource(ZFile* nParent) RegisterOptionalAttribute("Custom"); } -void ZResource::ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector& nRawData, - const uint32_t nRawDataIndex) +void ZResource::ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) { - rawData = nRawData; rawDataIndex = nRawDataIndex; if (reader != nullptr) @@ -34,9 +32,8 @@ void ZResource::ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector& nRawData, uint32_t nRawDataIndex) +void ZResource::ExtractFromFile(uint32_t nRawDataIndex) { - rawData = nRawData; rawDataIndex = nRawDataIndex; ParseRawData(); @@ -160,16 +157,6 @@ std::string ZResource::GetExternalExtension() const return ""; } -const std::vector& ZResource::GetRawData() const -{ - return rawData; -} - -void ZResource::SetRawData(const std::vector& nData) -{ - rawData = nData; -} - bool ZResource::WasDeclaredInXml() const { return declaredInXml; diff --git a/tools/ZAPD/ZAPD/ZResource.h b/tools/ZAPD/ZAPD/ZResource.h index 24f1f561f1..6ebfcf8fce 100644 --- a/tools/ZAPD/ZAPD/ZResource.h +++ b/tools/ZAPD/ZAPD/ZResource.h @@ -36,6 +36,7 @@ enum class ZResourceType Cutscene, DisplayList, Limb, + LimbTable, Mtx, Path, Room, @@ -69,9 +70,8 @@ public: virtual ~ZResource() = default; // Parsing from File - virtual void ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector& nRawData, - uint32_t nRawDataIndex); - virtual void ExtractFromFile(const std::vector& nRawData, uint32_t nRawDataIndex); + virtual void ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex); + virtual void ExtractFromFile(uint32_t nRawDataIndex); // Misc virtual void ParseXML(tinyxml2::XMLElement* reader); @@ -101,15 +101,12 @@ public: virtual uint32_t GetRawDataIndex() const; virtual void SetRawDataIndex(uint32_t value); virtual size_t GetRawDataSize() const = 0; - virtual const std::vector& GetRawData() const; - virtual void SetRawData(const std::vector& nData); void SetInnerNode(bool inner); bool WasDeclaredInXml() const; protected: std::string name; std::string outName; - std::vector rawData; uint32_t rawDataIndex; std::string sourceOutput; bool isInner = false; // Is this resource an inner node of another resource? inside of diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetAnimatedMaterialList.cpp b/tools/ZAPD/ZAPD/ZRoom/Commands/SetAnimatedMaterialList.cpp index de0d05b068..aeef2e8ca4 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetAnimatedMaterialList.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetAnimatedMaterialList.cpp @@ -255,12 +255,12 @@ std::string FlashingTexture::GenerateSourceCode(ZRoom* zRoom, uint32_t baseAddre index++; } - zRoom->parent->AddDeclarationArray( - primColorSegmentOffset, DeclarationAlignment::Align4, primColors.size() * 5, - "F3DPrimColor", - StringHelper::Sprintf("%sAnimatedMaterialPrimColor_%06X", zRoom->GetName().c_str(), - primColorSegmentOffset), - primColors.size(), declaration); + zRoom->parent->AddDeclarationArray(primColorSegmentOffset, DeclarationAlignment::Align4, + primColors.size() * 5, "F3DPrimColor", + StringHelper::Sprintf("%sAnimatedMaterialPrimColor_%06X", + zRoom->GetName().c_str(), + primColorSegmentOffset), + primColors.size(), declaration); } if (envColorSegmentOffset != 0) @@ -281,7 +281,7 @@ std::string FlashingTexture::GenerateSourceCode(ZRoom* zRoom, uint32_t baseAddre zRoom->parent->AddDeclarationArray( envColorSegmentOffset, DeclarationAlignment::Align4, envColors.size() * 4, - "Color_RGBA8", + "F3DEnvColor", StringHelper::Sprintf("%sAnimatedMaterialEnvColors0x%06X", zRoom->GetName().c_str(), envColorSegmentOffset), envColors.size(), declaration); @@ -400,7 +400,8 @@ std::string AnimatedMatTexCycleParams::GenerateSourceCode(ZRoom* zRoom, uint32_t textureIndices.size(), declaration); } - std::string segmName = zRoom->parent->GetDeclarationPtrName(textureSegmentOffsetsSegmentAddress); + std::string segmName = + zRoom->parent->GetDeclarationPtrName(textureSegmentOffsetsSegmentAddress); std::string indexesName = zRoom->parent->GetDeclarationPtrName(textureIndicesSegmentAddress); return StringHelper::Sprintf("%i, %s, %s", cycleLength, segmName.c_str(), indexesName.c_str()); diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetCollisionHeader.cpp b/tools/ZAPD/ZAPD/ZRoom/Commands/SetCollisionHeader.cpp index 1eb13f6ba2..569a7c0785 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetCollisionHeader.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetCollisionHeader.cpp @@ -13,7 +13,6 @@ void SetCollisionHeader::ParseRawData() { ZRoomCommand::ParseRawData(); collisionHeader = new ZCollisionHeader(parent); - collisionHeader->SetRawData(parent->GetRawData()); collisionHeader->SetRawDataIndex(segmentOffset); collisionHeader->SetName( StringHelper::Sprintf("%sCollisionHeader_%06X", parent->GetName().c_str(), segmentOffset)); diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetCsCamera.cpp b/tools/ZAPD/ZAPD/ZRoom/Commands/SetCsCamera.cpp index 02e2e61784..0402d939e7 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetCsCamera.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetCsCamera.cpp @@ -33,7 +33,6 @@ void SetCsCamera::ParseRawData() for (int32_t i = 0; i < numPoints; i++) { ZVector vec(parent); - vec.SetRawData(parent->GetRawData()); vec.SetRawDataIndex(currentPtr); vec.SetScalarType(ZScalarType::ZSCALAR_S16); vec.SetDimensions(3); diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.cpp b/tools/ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.cpp index 8007ac0ab9..d9ecb7962b 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.cpp @@ -19,7 +19,7 @@ void SetCutscenes::ParseRawData() if (Globals::Instance->game == ZGame::OOT_RETAIL || Globals::Instance->game == ZGame::OOT_SW97) { ZCutscene* cutscene = new ZCutscene(parent); - cutscene->ExtractFromFile(parent->GetRawData(), segmentOffset); + cutscene->ExtractFromFile(segmentOffset); auto decl = parent->GetDeclaration(segmentOffset); if (decl == nullptr) @@ -48,7 +48,7 @@ void SetCutscenes::ParseRawData() declaration += "\n"; ZCutsceneMM* cutscene = new ZCutsceneMM(parent); - cutscene->ExtractFromFile(parent->GetRawData(), entry.segmentOffset); + cutscene->ExtractFromFile(entry.segmentOffset); cutscenes.push_back(cutscene); } diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetMesh.cpp b/tools/ZAPD/ZAPD/ZRoom/Commands/SetMesh.cpp index 2635e7ff3b..f2a9676901 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetMesh.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetMesh.cpp @@ -116,7 +116,6 @@ RoomCommand SetMesh::GetRoomCommand() const PolygonDlist::PolygonDlist(const std::string& prefix, const std::vector& nRawData, uint32_t nRawDataIndex, ZFile* nParent, ZRoom* nRoom) { - rawData.assign(nRawData.begin(), nRawData.end()); rawDataIndex = nRawDataIndex; parent = nParent; zRoom = nRoom; @@ -126,6 +125,7 @@ PolygonDlist::PolygonDlist(const std::string& prefix, const std::vector void PolygonDlist::ParseRawData() { + const auto& rawData = parent->GetRawData(); switch (polyType) { case 2: @@ -161,9 +161,9 @@ ZDisplayList* PolygonDlist::MakeDlist(segptr_t ptr, const std::string& prefix) uint32_t dlistAddress = Seg2Filespace(ptr, parent->baseAddress); int32_t dlistLength = ZDisplayList::GetDListLength( - rawData, dlistAddress, + parent->GetRawData(), dlistAddress, Globals::Instance->game == ZGame::OOT_SW97 ? DListType::F3DEX : DListType::F3DZEX); - ZDisplayList* dlist = new ZDisplayList(rawData, dlistAddress, dlistLength, parent); + ZDisplayList* dlist = new ZDisplayList(dlistAddress, dlistLength, parent); GenDListDeclarations(zRoom, parent, dlist); return dlist; @@ -271,7 +271,6 @@ std::string PolygonDlist::GetName() BgImage::BgImage(bool nIsSubStruct, const std::string& prefix, const std::vector& nRawData, uint32_t nRawDataIndex, ZFile* nParent) { - rawData.assign(nRawData.begin(), nRawData.end()); rawDataIndex = nRawDataIndex; parent = nParent; isSubStruct = nIsSubStruct; @@ -285,6 +284,7 @@ BgImage::BgImage(bool nIsSubStruct, const std::string& prefix, const std::vector void BgImage::ParseRawData() { size_t pad = 0x00; + const auto& rawData = parent->GetRawData(); if (!isSubStruct) { pad = 0x04; @@ -312,7 +312,7 @@ ZBackground* BgImage::MakeBackground(segptr_t ptr, const std::string& prefix) uint32_t backAddress = Seg2Filespace(ptr, parent->baseAddress); - ZBackground* background = new ZBackground(prefix, rawData, backAddress, parent); + ZBackground* background = new ZBackground(prefix, backAddress, parent); background->DeclareVar(prefix, ""); parent->resources.push_back(background); @@ -408,9 +408,9 @@ std::string BgImage::GetName() PolygonTypeBase::PolygonTypeBase(ZFile* nParent, const std::vector& nRawData, uint32_t nRawDataIndex, ZRoom* nRoom) - : rawData{nRawData}, rawDataIndex{nRawDataIndex}, parent{nParent}, zRoom{nRoom} + : rawDataIndex{nRawDataIndex}, parent{nParent}, zRoom{nRoom} { - type = BitConverter::ToUInt8BE(rawData, rawDataIndex); + type = BitConverter::ToUInt8BE(parent->GetRawData(), rawDataIndex); } void PolygonTypeBase::DeclareVar(const std::string& prefix, const std::string& bodyStr) @@ -477,6 +477,8 @@ PolygonType1::PolygonType1(ZFile* nParent, const std::vector& nRawData, void PolygonType1::ParseRawData() { + const auto& rawData = parent->GetRawData(); + format = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x01); dlist = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x04); @@ -506,7 +508,7 @@ void PolygonType1::DeclareReferences(const std::string& prefix) switch (format) { case 1: - single = BgImage(true, prefix, rawData, rawDataIndex + 0x08, parent); + single = BgImage(true, prefix, parent->GetRawData(), rawDataIndex + 0x08, parent); break; case 2: @@ -515,8 +517,8 @@ void PolygonType1::DeclareReferences(const std::string& prefix) listAddress = Seg2Filespace(list, parent->baseAddress); for (size_t i = 0; i < count; ++i) { - BgImage bg(false, prefix, rawData, listAddress + i * BgImage::GetRawDataSize(), - parent); + BgImage bg(false, prefix, parent->GetRawData(), + listAddress + i * BgImage::GetRawDataSize(), parent); multiList.push_back(bg); bgImageArrayBody += bg.GetBodySourceCode(true); if (i + 1 < count) @@ -609,6 +611,8 @@ PolygonType2::PolygonType2(ZFile* nParent, const std::vector& nRawData, void PolygonType2::ParseRawData() { + const auto& rawData = parent->GetRawData(); + num = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x01); start = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x04); diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetMesh.h b/tools/ZAPD/ZAPD/ZRoom/Commands/SetMesh.h index fb99dbdb30..20ec9c3ae2 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetMesh.h +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetMesh.h @@ -39,7 +39,6 @@ protected: ZDisplayList* opaDList = nullptr; // Gfx* ZDisplayList* xluDList = nullptr; // Gfx* - std::vector rawData; uint32_t rawDataIndex; ZFile* parent; ZRoom* zRoom; @@ -65,7 +64,6 @@ protected: ZBackground* sourceBackground; - std::vector rawData; uint32_t rawDataIndex; ZFile* parent; std::string name; @@ -114,7 +112,6 @@ protected: std::vector polyDLists; - std::vector rawData; uint32_t rawDataIndex; ZFile* parent; ZRoom* zRoom; diff --git a/tools/ZAPD/ZAPD/ZRoom/ZRoom.cpp b/tools/ZAPD/ZAPD/ZRoom/ZRoom.cpp index 936b014475..32dad6106f 100644 --- a/tools/ZAPD/ZAPD/ZRoom/ZRoom.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/ZRoom.cpp @@ -60,10 +60,9 @@ ZRoom::~ZRoom() delete cmd; } -void ZRoom::ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector& nRawData, - const uint32_t nRawDataIndex) +void ZRoom::ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) { - ZResource::ExtractFromXML(reader, nRawData, nRawDataIndex); + ZResource::ExtractFromXML(reader, nRawDataIndex); scene = Globals::Instance->lastScene; @@ -97,8 +96,8 @@ void ZRoom::ExtractFromXML(tinyxml2::XMLElement* reader, const std::vectorGetRawData(), address, Globals::Instance->game == ZGame::OOT_SW97 ? DListType::F3DEX : DListType::F3DZEX), @@ -115,7 +114,7 @@ void ZRoom::ExtractFromXML(tinyxml2::XMLElement* reader, const std::vectorSetInnerNode(true); - cutscene->ExtractFromXML(child, rawData, address); + cutscene->ExtractFromXML(child, address); cutscene->GetSourceOutputCode(name); @@ -152,7 +151,7 @@ void ZRoom::ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector& commandList, CommandSet co uint32_t commandsLeft = commandSet.commandCount; + const auto& rawData = parent->GetRawData(); while (shouldContinue) { if (commandsLeft <= 0) @@ -392,7 +392,7 @@ size_t ZRoom::GetDeclarationSizeFromNeighbor(uint32_t declarationAddress) auto nextDecl = currentDecl; std::advance(nextDecl, 1); if (nextDecl == parent->declarations.end()) - return rawData.size() - currentDecl->first; + return parent->GetRawData().size() - currentDecl->first; return nextDecl->first - currentDecl->first; } @@ -415,7 +415,7 @@ size_t ZRoom::GetCommandSizeFromNeighbor(ZRoomCommand* cmd) if (cmdIndex + 1 < (int32_t)commands.size()) return commands[cmdIndex + 1]->cmdAddress - commands[cmdIndex]->cmdAddress; else - return rawData.size() - commands[cmdIndex]->cmdAddress; + return parent->GetRawData().size() - commands[cmdIndex]->cmdAddress; } return 0; diff --git a/tools/ZAPD/ZAPD/ZRoom/ZRoom.h b/tools/ZAPD/ZAPD/ZRoom/ZRoom.h index 43f12ed7f7..518ca82bb8 100644 --- a/tools/ZAPD/ZAPD/ZRoom/ZRoom.h +++ b/tools/ZAPD/ZAPD/ZRoom/ZRoom.h @@ -36,8 +36,7 @@ public: ZRoom(ZFile* nParent); virtual ~ZRoom(); - void ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector& nRawData, - uint32_t nRawDataIndex) override; + void ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) override; void ParseCommands(std::vector& commandList, CommandSet commandSet); size_t GetDeclarationSizeFromNeighbor(uint32_t declarationAddress); diff --git a/tools/ZAPD/ZAPD/ZScalar.cpp b/tools/ZAPD/ZAPD/ZScalar.cpp index 797ac07a19..2f631acd44 100644 --- a/tools/ZAPD/ZAPD/ZScalar.cpp +++ b/tools/ZAPD/ZAPD/ZScalar.cpp @@ -36,6 +36,10 @@ ZScalarType ZScalar::MapOutputTypeToScalarType(const std::string& type) { return ZScalarType::ZSCALAR_U8; } + else if (type == "x8") + { + return ZScalarType::ZSCALAR_X8; + } else if (type == "s16") { return ZScalarType::ZSCALAR_S16; @@ -44,6 +48,10 @@ ZScalarType ZScalar::MapOutputTypeToScalarType(const std::string& type) { return ZScalarType::ZSCALAR_U16; } + else if (type == "x16") + { + return ZScalarType::ZSCALAR_X16; + } else if (type == "s32") { return ZScalarType::ZSCALAR_S32; @@ -52,6 +60,10 @@ ZScalarType ZScalar::MapOutputTypeToScalarType(const std::string& type) { return ZScalarType::ZSCALAR_U32; } + else if (type == "x32") + { + return ZScalarType::ZSCALAR_X32; + } else if (type == "s64") { return ZScalarType::ZSCALAR_S64; @@ -60,6 +72,10 @@ ZScalarType ZScalar::MapOutputTypeToScalarType(const std::string& type) { return ZScalarType::ZSCALAR_U64; } + else if (type == "x64") + { + return ZScalarType::ZSCALAR_X64; + } else if (type == "f32") { return ZScalarType::ZSCALAR_F32; @@ -79,18 +95,22 @@ std::string ZScalar::MapScalarTypeToOutputType(const ZScalarType scalarType) case ZScalarType::ZSCALAR_S8: return "s8"; case ZScalarType::ZSCALAR_U8: + case ZScalarType::ZSCALAR_X8: return "u8"; case ZScalarType::ZSCALAR_S16: return "s16"; case ZScalarType::ZSCALAR_U16: + case ZScalarType::ZSCALAR_X16: return "u16"; case ZScalarType::ZSCALAR_S32: return "s32"; case ZScalarType::ZSCALAR_U32: + case ZScalarType::ZSCALAR_X32: return "u32"; case ZScalarType::ZSCALAR_S64: return "s64"; case ZScalarType::ZSCALAR_U64: + case ZScalarType::ZSCALAR_X64: return "u64"; case ZScalarType::ZSCALAR_F32: return "f32"; @@ -108,18 +128,22 @@ size_t ZScalar::MapTypeToSize(const ZScalarType scalarType) case ZScalarType::ZSCALAR_S8: return sizeof(scalarData.s8); case ZScalarType::ZSCALAR_U8: + case ZScalarType::ZSCALAR_X8: return sizeof(scalarData.u8); case ZScalarType::ZSCALAR_S16: return sizeof(scalarData.s16); case ZScalarType::ZSCALAR_U16: + case ZScalarType::ZSCALAR_X16: return sizeof(scalarData.u16); case ZScalarType::ZSCALAR_S32: return sizeof(scalarData.s32); case ZScalarType::ZSCALAR_U32: + case ZScalarType::ZSCALAR_X32: return sizeof(scalarData.u32); case ZScalarType::ZSCALAR_S64: return sizeof(scalarData.s64); case ZScalarType::ZSCALAR_U64: + case ZScalarType::ZSCALAR_X64: return sizeof(scalarData.u64); case ZScalarType::ZSCALAR_F32: return sizeof(scalarData.f32); @@ -137,30 +161,35 @@ size_t ZScalar::GetRawDataSize() const void ZScalar::ParseRawData() { + const auto& rawData = parent->GetRawData(); switch (scalarType) { case ZScalarType::ZSCALAR_S8: scalarData.s8 = BitConverter::ToInt8BE(rawData, rawDataIndex); break; case ZScalarType::ZSCALAR_U8: + case ZScalarType::ZSCALAR_X8: scalarData.u8 = BitConverter::ToUInt8BE(rawData, rawDataIndex); break; case ZScalarType::ZSCALAR_S16: scalarData.s16 = BitConverter::ToInt16BE(rawData, rawDataIndex); break; case ZScalarType::ZSCALAR_U16: + case ZScalarType::ZSCALAR_X16: scalarData.u16 = BitConverter::ToUInt16BE(rawData, rawDataIndex); break; case ZScalarType::ZSCALAR_S32: scalarData.s32 = BitConverter::ToInt32BE(rawData, rawDataIndex); break; case ZScalarType::ZSCALAR_U32: + case ZScalarType::ZSCALAR_X32: scalarData.u32 = BitConverter::ToUInt32BE(rawData, rawDataIndex); break; case ZScalarType::ZSCALAR_S64: scalarData.s64 = BitConverter::ToInt64BE(rawData, rawDataIndex); break; case ZScalarType::ZSCALAR_U64: + case ZScalarType::ZSCALAR_X64: scalarData.u64 = BitConverter::ToUInt64BE(rawData, rawDataIndex); break; case ZScalarType::ZSCALAR_F32: @@ -189,18 +218,26 @@ std::string ZScalar::GetBodySourceCode() const return StringHelper::Sprintf("%hhd", scalarData.s8); case ZScalarType::ZSCALAR_U8: return StringHelper::Sprintf("%hhu", scalarData.u8); + case ZScalarType::ZSCALAR_X8: + return StringHelper::Sprintf("0x%02X", scalarData.u8); case ZScalarType::ZSCALAR_S16: return StringHelper::Sprintf("%hd", scalarData.s16); case ZScalarType::ZSCALAR_U16: return StringHelper::Sprintf("%hu", scalarData.u16); + case ZScalarType::ZSCALAR_X16: + return StringHelper::Sprintf("0x%04X", scalarData.u16); case ZScalarType::ZSCALAR_S32: return StringHelper::Sprintf("%d", scalarData.s32); case ZScalarType::ZSCALAR_U32: return StringHelper::Sprintf("%u", scalarData.u32); + case ZScalarType::ZSCALAR_X32: + return StringHelper::Sprintf("0x%08X", scalarData.u32); case ZScalarType::ZSCALAR_S64: return StringHelper::Sprintf("%lld", scalarData.s64); case ZScalarType::ZSCALAR_U64: return StringHelper::Sprintf("%llu", scalarData.u64); + case ZScalarType::ZSCALAR_X64: + return StringHelper::Sprintf("0x%016X", scalarData.u64); case ZScalarType::ZSCALAR_F32: return StringHelper::Sprintf("%f", scalarData.f32); case ZScalarType::ZSCALAR_F64: diff --git a/tools/ZAPD/ZAPD/ZScalar.h b/tools/ZAPD/ZAPD/ZScalar.h index a46c3a16ca..ca2082756b 100644 --- a/tools/ZAPD/ZAPD/ZScalar.h +++ b/tools/ZAPD/ZAPD/ZScalar.h @@ -11,12 +11,16 @@ enum class ZScalarType ZSCALAR_NONE, ZSCALAR_S8, ZSCALAR_U8, + ZSCALAR_X8, ZSCALAR_S16, ZSCALAR_U16, + ZSCALAR_X16, ZSCALAR_S32, ZSCALAR_U32, + ZSCALAR_X32, ZSCALAR_S64, ZSCALAR_U64, + ZSCALAR_X64, ZSCALAR_F32, ZSCALAR_F64 }; diff --git a/tools/ZAPD/ZAPD/ZSkeleton.cpp b/tools/ZAPD/ZAPD/ZSkeleton.cpp index dd5f8bd003..3e530a14fd 100644 --- a/tools/ZAPD/ZAPD/ZSkeleton.cpp +++ b/tools/ZAPD/ZAPD/ZSkeleton.cpp @@ -1,53 +1,25 @@ #include "ZSkeleton.h" + +#include #include "BitConverter.h" #include "HighLevel/HLModelIntermediette.h" #include "StringHelper.h" REGISTER_ZFILENODE(Skeleton, ZSkeleton); +REGISTER_ZFILENODE(LimbTable, ZLimbTable); -ZSkeleton::ZSkeleton(ZFile* nParent) : ZResource(nParent) +ZSkeleton::ZSkeleton(ZFile* nParent) : ZResource(nParent), limbsTable(nParent) { - type = ZSkeletonType::Normal; - limbType = ZLimbType::Standard; - dListCount = 0; - RegisterRequiredAttribute("Type"); RegisterRequiredAttribute("LimbType"); } -ZSkeleton::ZSkeleton(ZSkeletonType nType, ZLimbType nLimbType, const std::string& prefix, - const std::vector& nRawData, uint32_t nRawDataIndex, ZFile* nParent) - : ZSkeleton(nParent) +void ZSkeleton::ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) { - rawData.assign(nRawData.begin(), nRawData.end()); - rawDataIndex = nRawDataIndex; - parent = nParent; + ZResource::ExtractFromXML(reader, nRawDataIndex); - name = StringHelper::Sprintf("%sSkel_%06X", prefix.c_str(), rawDataIndex); - type = nType; - limbType = nLimbType; - - ParseRawData(); - - std::string defaultPrefix = name; - defaultPrefix.replace(0, 1, "s"); // replace g prefix with s for local variables - uint32_t ptr = Seg2Filespace(limbsArrayAddress, parent->baseAddress); - - for (size_t i = 0; i < limbCount; i++) - { - uint32_t ptr2 = Seg2Filespace(BitConverter::ToUInt32BE(rawData, ptr), parent->baseAddress); - - ZLimb* limb = new ZLimb(limbType, prefix, rawData, ptr2, parent); - limbs.push_back(limb); - - ptr += 4; - } -} - -ZSkeleton::~ZSkeleton() -{ - for (auto& limb : limbs) - delete limb; + parent->AddDeclaration(rawDataIndex, DeclarationAlignment::Align4, GetRawDataSize(), + GetSourceTypeName(), name, ""); } void ZSkeleton::ParseXML(tinyxml2::XMLElement* reader) @@ -71,16 +43,8 @@ void ZSkeleton::ParseXML(tinyxml2::XMLElement* reader) } std::string limbTypeXml = registeredAttributes.at("LimbType").value; - - if (limbTypeXml == "Standard") - limbType = ZLimbType::Standard; - else if (limbTypeXml == "LOD") - limbType = ZLimbType::LOD; - else if (limbTypeXml == "Skin") - limbType = ZLimbType::Skin; - else if (limbTypeXml == "Curve") - limbType = ZLimbType::Curve; - else + limbType = ZLimb::GetTypeByAttributeName(limbTypeXml); + if (limbType == ZLimbType::Invalid) { fprintf(stderr, "ZSkeleton::ParseXML: Warning in '%s'.\n" @@ -95,42 +59,56 @@ void ZSkeleton::ParseRawData() { ZResource::ParseRawData(); + const auto& rawData = parent->GetRawData(); limbsArrayAddress = BitConverter::ToUInt32BE(rawData, rawDataIndex); limbCount = BitConverter::ToUInt8BE(rawData, rawDataIndex + 4); dListCount = BitConverter::ToUInt8BE(rawData, rawDataIndex + 8); + + if (limbsArrayAddress != 0 && GETSEGNUM(limbsArrayAddress) == parent->segment) + { + uint32_t ptr = Seg2Filespace(limbsArrayAddress, parent->baseAddress); + limbsTable.ExtractFromBinary(ptr, limbType, limbCount); + } } -void ZSkeleton::ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector& nRawData, - const uint32_t nRawDataIndex) +void ZSkeleton::DeclareReferences(const std::string& prefix) { - ZResource::ExtractFromXML(reader, nRawData, nRawDataIndex); - - parent->AddDeclaration(rawDataIndex, DeclarationAlignment::Align16, GetRawDataSize(), - GetSourceTypeName(), name, ""); - std::string defaultPrefix = name; - defaultPrefix.replace(0, 1, "s"); // replace g prefix with s for local variables - uint32_t ptr = Seg2Filespace(limbsArrayAddress, parent->baseAddress); + if (defaultPrefix == "") + defaultPrefix = prefix; - for (size_t i = 0; i < limbCount; i++) + if (limbsArrayAddress != 0 && GETSEGNUM(limbsArrayAddress) == parent->segment) { - uint32_t ptr2 = Seg2Filespace(BitConverter::ToUInt32BE(rawData, ptr), parent->baseAddress); - - std::string limbName = StringHelper::Sprintf("%sLimb_%06X", defaultPrefix.c_str(), ptr2); - Declaration* decl = parent->GetDeclaration(ptr2); - if (decl != nullptr) - limbName = decl->varName; - - ZLimb* limb = new ZLimb(parent); - limb->SetLimbType(limbType); - limb->SetName(limbName); - limb->ExtractFromXML(nullptr, rawData, ptr2); - limbs.push_back(limb); - - ptr += 4; + uint32_t ptr = Seg2Filespace(limbsArrayAddress, parent->baseAddress); + if (!parent->HasDeclaration(ptr)) + { + limbsTable.SetName(StringHelper::Sprintf("%sLimbs", defaultPrefix.c_str())); + limbsTable.DeclareReferences(prefix); + limbsTable.GetSourceOutputCode(prefix); + } } } +std::string ZSkeleton::GetBodySourceCode() const +{ + std::string limbTableName = parent->GetDeclarationPtrName(limbsArrayAddress); + + std::string headerStr; + switch (type) + { + case ZSkeletonType::Normal: + case ZSkeletonType::Curve: + headerStr = StringHelper::Sprintf("\n\t%s, %i\n", limbTableName.c_str(), limbCount); + break; + case ZSkeletonType::Flex: + headerStr = StringHelper::Sprintf("\n\t{ %s, %i }, %i\n", limbTableName.c_str(), limbCount, + dListCount); + break; + } + + return headerStr; +} + void ZSkeleton::GenerateHLIntermediette(HLFileIntermediette& hlFile) { HLModelIntermediette* mdl = (HLModelIntermediette*)&hlFile; @@ -153,58 +131,7 @@ size_t ZSkeleton::GetRawDataSize() const std::string ZSkeleton::GetSourceOutputCode(const std::string& prefix) { - if (parent == nullptr) - return ""; - - std::string defaultPrefix = name.c_str(); - defaultPrefix.replace(0, 1, "s"); // replace g prefix with s for local variables - - for (auto& limb : limbs) - limb->GetSourceOutputCode(defaultPrefix); - - uint32_t ptr = Seg2Filespace(limbsArrayAddress, parent->baseAddress); - if (!parent->HasDeclaration(ptr)) - { - // Table - std::string tblStr = ""; - std::string limbArrTypeStr = "static void*"; - if (limbType == ZLimbType::Curve) - { - limbArrTypeStr = - StringHelper::Sprintf("static %s*", ZLimb::GetSourceTypeName(limbType)); - } - - for (size_t i = 0; i < limbs.size(); i++) - { - ZLimb* limb = limbs.at(i); - - std::string decl = StringHelper::Sprintf( - " &%s,", parent->GetDeclarationName(limb->GetFileAddress()).c_str()); - if (i != (limbs.size() - 1)) - { - decl += "\n"; - } - - tblStr += decl; - } - - parent->AddDeclarationArray(ptr, DeclarationAlignment::None, 4 * limbCount, limbArrTypeStr, - StringHelper::Sprintf("%sLimbs", defaultPrefix.c_str()), - limbCount, tblStr); - } - - std::string headerStr; - switch (type) - { - case ZSkeletonType::Normal: - case ZSkeletonType::Curve: - headerStr = StringHelper::Sprintf("\n\t%sLimbs, %i\n", defaultPrefix.c_str(), limbCount); - break; - case ZSkeletonType::Flex: - headerStr = StringHelper::Sprintf("\n\t{ %sLimbs, %i }, %i\n", defaultPrefix.c_str(), - limbCount, dListCount); - break; - } + std::string headerStr = GetBodySourceCode(); Declaration* decl = parent->GetDeclaration(GetAddress()); @@ -250,3 +177,146 @@ uint8_t ZSkeleton::GetLimbCount() { return limbCount; } + +/* ZLimbTable */ + +ZLimbTable::ZLimbTable(ZFile* nParent) : ZResource(nParent) +{ + RegisterRequiredAttribute("LimbType"); + RegisterRequiredAttribute("Count"); +} + +void ZLimbTable::ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) +{ + ZResource::ExtractFromXML(reader, nRawDataIndex); + + parent->AddDeclarationArray(rawDataIndex, DeclarationAlignment::Align4, GetRawDataSize(), + GetSourceTypeName(), name, limbsAddresses.size(), ""); +} + +void ZLimbTable::ExtractFromBinary(uint32_t nRawDataIndex, ZLimbType nLimbType, size_t nCount) +{ + rawDataIndex = nRawDataIndex; + limbType = nLimbType; + count = nCount; + + ParseRawData(); +} + +void ZLimbTable::ParseXML(tinyxml2::XMLElement* reader) +{ + ZResource::ParseXML(reader); + + std::string limbTypeXml = registeredAttributes.at("LimbType").value; + limbType = ZLimb::GetTypeByAttributeName(limbTypeXml); + if (limbType == ZLimbType::Invalid) + { + fprintf(stderr, + "ZLimbTable::ParseXML: Warning in '%s'.\n" + "\t Invalid LimbType found: '%s'.\n" + "\t Defaulting to 'Standard'.\n", + name.c_str(), limbTypeXml.c_str()); + limbType = ZLimbType::Standard; + } + + count = StringHelper::StrToL(registeredAttributes.at("Count").value); +} + +void ZLimbTable::ParseRawData() +{ + ZResource::ParseRawData(); + + const auto& rawData = parent->GetRawData(); + uint32_t ptr = rawDataIndex; + for (size_t i = 0; i < count; i++) + { + limbsAddresses.push_back(BitConverter::ToUInt32BE(rawData, ptr)); + ptr += 4; + } +} + +void ZLimbTable::DeclareReferences(const std::string& prefix) +{ + std::string varPrefix = prefix; + if (name != "") + varPrefix = name; + + ZResource::DeclareReferences(varPrefix); + + for (size_t i = 0; i < count; i++) + { + segptr_t limbAddress = limbsAddresses[i]; + + if (limbAddress != 0 && GETSEGNUM(limbAddress) == parent->segment) + { + uint32_t limbOffset = Seg2Filespace(limbAddress, parent->baseAddress); + if (!parent->HasDeclaration(limbOffset)) + { + ZLimb* limb = new ZLimb(limbType, varPrefix, limbOffset, parent); + limb->DeclareReferences(varPrefix); + limb->GetSourceOutputCode(varPrefix); + parent->AddResource(limb); + } + } + } +} + +std::string ZLimbTable::GetBodySourceCode() const +{ + std::string body = ""; + + for (size_t i = 0; i < count; i++) + { + std::string limbName = parent->GetDeclarationPtrName(limbsAddresses[i]); + body += StringHelper::Sprintf("\t%s,", limbName.c_str()); + + if (i + 1 < count) + body += "\n"; + } + + return body; +} + +std::string ZLimbTable::GetSourceOutputCode(const std::string& prefix) +{ + std::string body = GetBodySourceCode(); + + Declaration* decl = parent->GetDeclaration(rawDataIndex); + if (decl == nullptr || decl->isPlaceholder) + parent->AddDeclarationArray(rawDataIndex, DeclarationAlignment::Align4, GetRawDataSize(), + GetSourceTypeName(), name, limbsAddresses.size(), body); + else + decl->text = body; + + return ""; +} + +std::string ZLimbTable::GetSourceTypeName() const +{ + switch (limbType) + { + case ZLimbType::Standard: + case ZLimbType::LOD: + case ZLimbType::Skin: + return "void*"; + + case ZLimbType::Curve: + case ZLimbType::Legacy: + return StringHelper::Sprintf("%s*", ZLimb::GetSourceTypeName(limbType)); + + case ZLimbType::Invalid: + assert("Invalid limb type.\n"); + } + + return "ERROR"; +} + +ZResourceType ZLimbTable::GetResourceType() const +{ + return ZResourceType::LimbTable; +} + +size_t ZLimbTable::GetRawDataSize() const +{ + return 4 * limbsAddresses.size(); +} diff --git a/tools/ZAPD/ZAPD/ZSkeleton.h b/tools/ZAPD/ZAPD/ZSkeleton.h index 6841b828b1..29720fcb9c 100644 --- a/tools/ZAPD/ZAPD/ZSkeleton.h +++ b/tools/ZAPD/ZAPD/ZSkeleton.h @@ -3,6 +3,7 @@ #include #include #include + #include "ZDisplayList.h" #include "ZFile.h" #include "ZLimb.h" @@ -14,26 +15,51 @@ enum class ZSkeletonType Curve, }; -class ZSkeleton : public ZResource +class ZLimbTable : public ZResource { public: - ZSkeletonType type; - ZLimbType limbType; - std::vector limbs; - segptr_t limbsArrayAddress; - uint8_t limbCount; - uint8_t dListCount; // FLEX SKELETON ONLY + ZLimbTable(ZFile* nParent); - ZSkeleton(ZFile* nParent); - ZSkeleton(ZSkeletonType nType, ZLimbType nLimbType, const std::string& prefix, - const std::vector& nRawData, uint32_t nRawDataIndex, ZFile* nParent); - ~ZSkeleton(); - - void ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector& nRawData, - const uint32_t nRawDataIndex) override; + void ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) override; + void ExtractFromBinary(uint32_t nRawDataIndex, ZLimbType nLimbType, size_t nCount); void ParseXML(tinyxml2::XMLElement* reader) override; void ParseRawData() override; + void DeclareReferences(const std::string& prefix) override; + std::string GetBodySourceCode() const override; + + std::string GetSourceOutputCode(const std::string& prefix) override; + + std::string GetSourceTypeName() const override; + ZResourceType GetResourceType() const override; + + size_t GetRawDataSize() const override; + +protected: + ZLimbType limbType = ZLimbType::Standard; + size_t count = 0; + + std::vector limbsAddresses; +}; + +class ZSkeleton : public ZResource +{ +public: + ZSkeletonType type = ZSkeletonType::Normal; + ZLimbType limbType = ZLimbType::Standard; + segptr_t limbsArrayAddress; + uint8_t limbCount = 0; + uint8_t dListCount = 0; // FLEX SKELETON ONLY + + ZSkeleton(ZFile* nParent); + + void ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) override; + + void ParseXML(tinyxml2::XMLElement* reader) override; + void ParseRawData() override; + void DeclareReferences(const std::string& prefix) override; + std::string GetBodySourceCode() const override; + std::string GetSourceOutputCode(const std::string& prefix) override; void GenerateHLIntermediette(HLFileIntermediette& hlFile) override; @@ -46,4 +72,5 @@ public: uint8_t GetLimbCount(); protected: + ZLimbTable limbsTable; }; diff --git a/tools/ZAPD/ZAPD/ZString.cpp b/tools/ZAPD/ZAPD/ZString.cpp index 24ef2d699c..50545dafcb 100644 --- a/tools/ZAPD/ZAPD/ZString.cpp +++ b/tools/ZAPD/ZAPD/ZString.cpp @@ -13,7 +13,8 @@ ZString::ZString(ZFile* nParent) : ZResource(nParent) void ZString::ParseRawData() { size_t size = 0; - uint8_t* rawDataArr = rawData.data(); + const auto& rawData = parent->GetRawData(); + const auto& rawDataArr = rawData.data(); size_t rawDataSize = rawData.size(); for (size_t i = rawDataIndex; i < rawDataSize; ++i) { @@ -43,7 +44,7 @@ std::string ZString::GetSourceOutputCode(const std::string& prefix) std::string ZString::GetSourceOutputHeader(const std::string& prefix) { - return StringHelper::Sprintf("#define %s_macro \"%s\"", name.c_str(), rawData.data()); + return StringHelper::Sprintf("#define %s_macro \"%s\"", name.c_str(), strData.data()); } std::string ZString::GetSourceTypeName() const diff --git a/tools/ZAPD/ZAPD/ZSymbol.cpp b/tools/ZAPD/ZAPD/ZSymbol.cpp index 3ba69db685..25a1e49581 100644 --- a/tools/ZAPD/ZAPD/ZSymbol.cpp +++ b/tools/ZAPD/ZAPD/ZSymbol.cpp @@ -11,12 +11,6 @@ ZSymbol::ZSymbol(ZFile* nParent) : ZResource(nParent) RegisterOptionalAttribute("Count"); } -void ZSymbol::ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector& nRawData, - const uint32_t nRawDataIndex) -{ - ZResource::ExtractFromXML(reader, nRawData, nRawDataIndex); -} - void ZSymbol::ParseXML(tinyxml2::XMLElement* reader) { ZResource::ParseXML(reader); diff --git a/tools/ZAPD/ZAPD/ZSymbol.h b/tools/ZAPD/ZAPD/ZSymbol.h index ad818fe1a6..1094a0222c 100644 --- a/tools/ZAPD/ZAPD/ZSymbol.h +++ b/tools/ZAPD/ZAPD/ZSymbol.h @@ -14,9 +14,6 @@ protected: public: ZSymbol(ZFile* nParent); - void ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector& nRawData, - const uint32_t nRawDataIndex) override; - void ParseXML(tinyxml2::XMLElement* reader) override; size_t GetRawDataSize() const override; diff --git a/tools/ZAPD/ZAPD/ZTexture.cpp b/tools/ZAPD/ZAPD/ZTexture.cpp index b47fd23bb4..956a2f7b40 100644 --- a/tools/ZAPD/ZAPD/ZTexture.cpp +++ b/tools/ZAPD/ZAPD/ZTexture.cpp @@ -21,10 +21,9 @@ ZTexture::ZTexture(ZFile* nParent) : ZResource(nParent) RegisterOptionalAttribute("TlutOffset"); } -void ZTexture::ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector& nRawData, - uint32_t nRawDataIndex) +void ZTexture::ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) { - ZResource::ExtractFromXML(reader, nRawData, nRawDataIndex); + ZResource::ExtractFromXML(reader, nRawDataIndex); auto filepath = Globals::Instance->outputPath / fs::path(name).stem(); @@ -35,8 +34,8 @@ void ZTexture::ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector& nRawData, uint32_t nRawDataIndex, - int32_t nWidth, int32_t nHeight, TextureType nType, bool nIsPalette) +void ZTexture::FromBinary(uint32_t nRawDataIndex, int32_t nWidth, int32_t nHeight, + TextureType nType, bool nIsPalette) { width = nWidth; height = nHeight; @@ -46,8 +45,6 @@ void ZTexture::FromBinary(const std::vector& nRawData, uint32_t nRawDat name = GetDefaultName(parent->GetName()); outName = name; - rawData.assign(nRawData.begin(), nRawData.end()); - ParseRawData(); CalcHash(); } @@ -75,17 +72,17 @@ void ZTexture::ParseXML(tinyxml2::XMLElement* reader) if (!StringHelper::HasOnlyDigits(widthXml)) { - throw std::runtime_error(StringHelper::Sprintf( - "ZTexture::ParseXML: Error in %s\n" - "\t Value of 'Width' attribute has non-decimal digits: '%s'.\n", - name.c_str(), widthXml.c_str())); + throw std::runtime_error( + StringHelper::Sprintf("ZTexture::ParseXML: Error in %s\n" + "\t Value of 'Width' attribute has non-decimal digits: '%s'.\n", + name.c_str(), widthXml.c_str())); } if (!StringHelper::HasOnlyDigits(heightXml)) { - throw std::runtime_error(StringHelper::Sprintf( - "ZTexture::ParseXML: Error in %s\n" - "\t Value of 'Height' attribute has non-decimal digits: '%s'.\n", - name.c_str(), heightXml.c_str())); + throw std::runtime_error( + StringHelper::Sprintf("ZTexture::ParseXML: Error in %s\n" + "\t Value of 'Height' attribute has non-decimal digits: '%s'.\n", + name.c_str(), heightXml.c_str())); } width = StringHelper::StrToL(widthXml); @@ -348,7 +345,7 @@ void ZTexture::DeclareReferences(const std::string& prefix) GetExternalExtension().c_str()); tlut = new ZTexture(parent); - tlut->FromBinary(rawData, tlutOffset, tlutDim, tlutDim, TextureType::RGBA16bpp, true); + tlut->FromBinary(tlutOffset, tlutDim, tlutDim, TextureType::RGBA16bpp, true); parent->AddTextureResource(tlutOffset, tlut); parent->AddDeclarationIncludeArray(tlutOffset, incStr, tlut->GetRawDataSize(), tlut->GetSourceTypeName(), tlut->GetName(), 0); @@ -802,7 +799,7 @@ std::string ZTexture::GetExternalExtension() const case TextureType::RGBA32bpp: return "rgba32"; case TextureType::RGBA16bpp: - return "rgb5a1"; + return "rgba16"; case TextureType::Grayscale4bpp: return "i4"; case TextureType::Grayscale8bpp: @@ -836,8 +833,19 @@ TextureType ZTexture::GetTextureTypeFromString(std::string str) if (str == "rgba32") texType = TextureType::RGBA32bpp; - else if (str == "rgb5a1") + else if (str == "rgba16") texType = TextureType::RGBA16bpp; + else if (str == "rgb5a1") + { + texType = TextureType::RGBA16bpp; +#ifdef DEPRECATION_ON + fprintf(stderr, + "ZTexture::GetTextureTypeFromString: Deprecation warning.\n" + "\t The texture format 'rgb5a1' is currently deprecated, and will be removed in a future " + "version.\n" + "\t Use the format 'rgba16' instead.\n"); +#endif + } else if (str == "i4") texType = TextureType::Grayscale4bpp; else if (str == "i8") diff --git a/tools/ZAPD/ZAPD/ZTexture.h b/tools/ZAPD/ZAPD/ZTexture.h index c17ed0b5bb..807468a627 100644 --- a/tools/ZAPD/ZAPD/ZTexture.h +++ b/tools/ZAPD/ZAPD/ZTexture.h @@ -58,10 +58,9 @@ public: bool isPalette = false; - void ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector& nRawData, - uint32_t nRawDataIndex) override; - void FromBinary(const std::vector& nRawData, uint32_t nRawDataIndex, int32_t nWidth, - int32_t nHeight, TextureType nType, bool nIsPalette); + void ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) override; + void FromBinary(uint32_t nRawDataIndex, int32_t nWidth, int32_t nHeight, TextureType nType, + bool nIsPalette); void FromPNG(const fs::path& pngFilePath, TextureType texType); void FromHLTexture(HLTexture* hlTex); diff --git a/tools/ZAPD/ZAPD/ZVector.cpp b/tools/ZAPD/ZAPD/ZVector.cpp index 35845800eb..d1aef444f5 100644 --- a/tools/ZAPD/ZAPD/ZVector.cpp +++ b/tools/ZAPD/ZAPD/ZVector.cpp @@ -35,7 +35,6 @@ void ZVector::ParseRawData() { ZScalar scalar(scalarType, parent); scalar.rawDataIndex = currentRawDataIndex; - scalar.rawData = rawData; scalar.ParseRawData(); currentRawDataIndex += scalar.GetRawDataSize(); diff --git a/tools/ZAPD/ZAPD/ZVtx.cpp b/tools/ZAPD/ZAPD/ZVtx.cpp index d56f4faf5c..bead96fee9 100644 --- a/tools/ZAPD/ZAPD/ZVtx.cpp +++ b/tools/ZAPD/ZAPD/ZVtx.cpp @@ -21,6 +21,9 @@ ZVtx::ZVtx(ZFile* nParent) : ZResource(nParent) void ZVtx::ParseRawData() { + ZResource::ParseRawData(); + + const auto& rawData = parent->GetRawData(); x = BitConverter::ToInt16BE(rawData, rawDataIndex + 0); y = BitConverter::ToInt16BE(rawData, rawDataIndex + 2); z = BitConverter::ToInt16BE(rawData, rawDataIndex + 4); diff --git a/tools/ZAPD/ZAPD/genbuildinfo.py b/tools/ZAPD/ZAPD/genbuildinfo.py index 04925aa20c..fedd3ed575 100644 --- a/tools/ZAPD/ZAPD/genbuildinfo.py +++ b/tools/ZAPD/ZAPD/genbuildinfo.py @@ -1,12 +1,18 @@ #!/usr/bin/python3 +import argparse from datetime import datetime import getpass import subprocess +parser = argparse.ArgumentParser() +parser.add_argument("--devel", action="store_true") +args = parser.parse_args() + with open("ZAPD/BuildInfo.h", "w+") as buildFile: label = subprocess.check_output(["git", "describe", "--always"]).strip().decode("utf-8") now = datetime.now() + if args.devel: + label += " ~ Development version" buildFile.write("const char gBuildHash[] = \"" + label + "\";\n") #buildFile.write("const char gBuildDate[] = \"" + now.strftime("%Y-%m-%d %H:%M:%S") + "\";\n") - \ No newline at end of file diff --git a/tools/ZAPD/docs/zapd_extraction_xml_reference.md b/tools/ZAPD/docs/zapd_extraction_xml_reference.md index 8767512961..9d84525631 100644 --- a/tools/ZAPD/docs/zapd_extraction_xml_reference.md +++ b/tools/ZAPD/docs/zapd_extraction_xml_reference.md @@ -17,7 +17,9 @@ This document aims to be a small reference of how to create a compatible xml fil - [Animation](#animation) - [PlayerAnimation](#playeranimation) - [CurveAnimation](#curveanimation) + - [LegacyAnimation](#legacyanimation) - [Skeleton](#skeleton) + - [LimbTable](#limbtable) - [Limb](#limb) - [Symbol](#symbol) - [Collision](#collision) @@ -42,9 +44,9 @@ An example of an object xml: - - - + + + @@ -78,6 +80,7 @@ It's worth noting that every tag expects a `Name="gNameOfTheAsset"`. This is wil - Attributes: - `Name`: Required. The name of the file in `baserom/` which will be extracted. + - `OutName`: Optional. The output name of the generated C source file. Defaults to the value passed to `Name`. - `Segment`: Required. This is the segment number of the current file. Expects a decimal number, usually 6 if it is an object, or 128 for overlays (It's kinda a whacky hack to get around of the `0x80` addresses). - `BaseAddress`: Optional. RAM address of the file. Expects a hex number (with `0x` prefix). Default value: `0`. - `RangeStart`: Optional. File offset where the extraction will begin. Hex. Default value: `0x000000000`. @@ -108,7 +111,7 @@ u64 gCraterSmokeConeTex[] = { - `Name`: Required. Suxffixed by `Tex`, unless it is a palette, in that case it is suffixed by `TLUT`. - `OutName`: Required. The filename of the extracted `.png` file. - - `Format`: Required. The format of the image. Valid values: `rgba32`, `rgb5a1`, `i4`, `i8`, `ia4`, `ia8`, `ia16`, `ci4` and `ci8`. + - `Format`: Required. The format of the image. Valid values: `rgba32`, `rgba16`, `i4`, `i8`, `ia4`, `ia8`, `ia16`, `ci4` and `ci8`. - `Width`: Required. Width in pixels of the image. - `Height`: Required. Height in pixels of the image. - `TlutOffset`: Optional. Specifies the tlut's offset used by this texture. This attribute is only valid if `Format` is either `ci4` or `ci8`, otherwise an exception would be thrown. @@ -123,7 +126,7 @@ The following is a list of the texture formats the Nintendo 64 supports, with th | 8-bit I | `G_IM_FMT_I, G_IM_SIZ_8b` | `i8` | | 8-bit IA (4/4) | `G_IM_FMT_IA, G_IM_SIZ_8b` | `ia8` | | 8-bit CI | `G_IM_FMT_CI, G_IM_SIZ_8b` | `ci8` | -| 16-bit red, green, blue, alpha (RGBA) (5/5/5/1) | `G_IM_FMT_RGBA, G_IM_SIZ_16b` | `rgb5a1` | +| 16-bit red, green, blue, alpha (RGBA) (5/5/5/1) | `G_IM_FMT_RGBA, G_IM_SIZ_16b` | `rgba16` | | 16-bit IA (8/8) | `G_IM_FMT_IA, G_IM_SIZ_16b` | `ia16` | | 16-bit YUV (Luminance, Blue-Y, Red-Y) | `G_IM_FMT_YUV, G_IM_SIZ_16b` | (not used) | | 32-bit RGBA (8/8/8/8) | `G_IM_FMT_RGBA, G_IM_SIZ_32b` | `rgba8` | @@ -242,6 +245,22 @@ TODO. I'm hoping somebody else will do this. ------------------------- +### LegacyAnimation + +Useful only for the unused `object_human`'s animation data. + +- Example: + +```xml + +``` + +- Attributes: + + - `Name`: Required. Suxffixed by `Anim`. + +------------------------- + ### Skeleton - Example: @@ -254,12 +273,28 @@ TODO. I'm hoping somebody else will do this. - `Name`: Required. Suxffixed by `Skel`. - `Type`: Required. Valid values: `Normal`, `Flex` and `Curve`. - - `LimbType`: Required. Valid values: `Standard`, `LOD`, `Skin` and `Curve`. + - `LimbType`: Required. Valid values: `Standard`, `LOD`, `Skin`, `Curve` and `Legacy`. ※ There are no restrictions in the `Type` and `LimbType` attributes besides the valid values, so any skeleton type can be combined with any limb type. ------------------------- +### LimbTable + +- Example: + +```xml + +``` + +- Attributes: + + - `Name`: Required. Suxffixed by `Skel`. + - `LimbType`: Required. Valid values: `Standard`, `LOD`, `Skin`, `Curve` and `Legacy`. + - `Count`: Required. Amount of limbs. Integer. + +------------------------- + ### Limb - Example: @@ -271,7 +306,7 @@ TODO. I'm hoping somebody else will do this. - Attributes: - `Name`: Required. Suxffixed by `Limb`. - - `LimbType`: Required. Valid values: `Standard`, `LOD`, `Skin` and `Curve`. + - `LimbType`: Required. Valid values: `Standard`, `LOD`, `Skin`, `Curve` and `Legacy`. ------------------------- @@ -332,7 +367,7 @@ u64 pad34F8 = { 0 }; - Attributes: - `Name`: Required. Suxffixed by ~~`TBD`~~. - - `Type`: Required. Valid values: `s8`, `u8`, `s16`, `u16`, `s32`, `u32`, `s64`, `u64`, `f32` and `f64`. + - `Type`: Required. Valid values: `s8`, `u8`, `x8`, `s16`, `u16`, `x16`, `s32`, `u32`, `x32`, `s64`, `u64`, `x64`, `f32` and `f64`. ※ Can be wrapped in an [`Array`](#array) tag. diff --git a/tools/ZAPD/lib/libgfxd/.gitrepo b/tools/ZAPD/lib/libgfxd/.gitrepo index 59040be776..c5e0d085e8 100644 --- a/tools/ZAPD/lib/libgfxd/.gitrepo +++ b/tools/ZAPD/lib/libgfxd/.gitrepo @@ -6,7 +6,7 @@ [subrepo] remote = https://github.com/glankk/libgfxd.git branch = master - commit = 2f00ff7dff14ae44c12ed421be54b9fec815541b - parent = a43a526c4296d7dc48852f6017fe069724465494 + commit = 01db16329ef5cac23566b6d143b57d0525e22876 + parent = c6b352aac040527d2962f3e764e460eb9e813fe5 method = merge cmdver = 0.4.3 diff --git a/tools/ZAPD/lib/libgfxd/gbi.h b/tools/ZAPD/lib/libgfxd/gbi.h index 72df3584f6..bc264eea87 100644 --- a/tools/ZAPD/lib/libgfxd/gbi.h +++ b/tools/ZAPD/lib/libgfxd/gbi.h @@ -1,5 +1,5 @@ /** - * gbi.h version 0.3.4 + * gbi.h version 0.3.5 * n64 graphics microcode interface library * compatible with fast3d, f3dex, f3dex2, s2dex, and s2dex2 * @@ -2748,6 +2748,14 @@ #if defined(F3DEX_GBI) +# define gsSP1Triangle(v0, v1, v2, flag) \ + gO_( \ + G_TRI1, \ + 0, \ + gF_(gV3_(v0, v1, v2, flag) * 2, 8, 16) | \ + gF_(gV3_(v1, v2, v0, flag) * 2, 8, 8) | \ + gF_(gV3_(v2, v0, v1, flag) * 2, 8, 0)) + # define gsSP1Quadrangle(v0, v1, v2, v3, flag) \ gO_( \ G_TRI2, \ @@ -2772,14 +2780,6 @@ #if defined(F3DEX_GBI) || defined(F3DEX_GBI_2) -# define gsSP1Triangle(v0, v1, v2, flag) \ - gO_( \ - G_TRI1, \ - gF_(gV3_(v0, v1, v2, flag) * 2, 8, 16) | \ - gF_(gV3_(v1, v2, v0, flag) * 2, 8, 8) | \ - gF_(gV3_(v2, v0, v1, flag) * 2, 8, 0), \ - 0) - # define gsSP2Triangles(v00, v01, v02, flag0, v10, v11, v12, flag1) \ gO_( \ G_TRI2, \ @@ -2855,6 +2855,14 @@ #if defined(F3DEX_GBI_2) +# define gsSP1Triangle(v0, v1, v2, flag) \ + gO_( \ + G_TRI1, \ + gF_(gV3_(v0, v1, v2, flag) * 2, 8, 16) | \ + gF_(gV3_(v1, v2, v0, flag) * 2, 8, 8) | \ + gF_(gV3_(v2, v0, v1, flag) * 2, 8, 0), \ + 0) + # define gsSP1Quadrangle(v0, v1, v2, v3, flag) \ gO_( \ G_QUAD, \ diff --git a/tools/ZAPD/lib/libgfxd/uc_macrofn.c b/tools/ZAPD/lib/libgfxd/uc_macrofn.c index 2c70eeed50..59f72a2786 100644 --- a/tools/ZAPD/lib/libgfxd/uc_macrofn.c +++ b/tools/ZAPD/lib/libgfxd/uc_macrofn.c @@ -1024,7 +1024,36 @@ UCFUNC int d_SP1Triangle(gfxd_macro_t *m, uint32_t hi, uint32_t lo) } return ret; } -#elif defined(F3DEX_GBI) || defined(F3DEX_GBI_2) +#elif defined(F3DEX_GBI) +UCFUNC int d_SP1Triangle(gfxd_macro_t *m, uint32_t hi, uint32_t lo) +{ + m->id = gfxd_SP1Triangle; + int n0 = getfield(lo, 8, 16); + int n1 = getfield(lo, 8, 8); + int n2 = getfield(lo, 8, 0); + argi(m, 0, "v0", n0 / 2, gfxd_Vtx); + argi(m, 1, "v1", n1 / 2, gfxd_Vtx); + argi(m, 2, "v2", n2 / 2, gfxd_Vtx); + argi(m, 3, "flag", 0, gfxd_Vtxflag); + int ret = 0; + if (n0 % 2 != 0) + { + badarg(m, 0); + ret = -1; + } + if (n1 % 2 != 0) + { + badarg(m, 1); + ret = -1; + } + if (n2 % 2 != 0) + { + badarg(m, 2); + ret = -1; + } + return ret; +} +#elif defined(F3DEX_GBI_2) UCFUNC int d_SP1Triangle(gfxd_macro_t *m, uint32_t hi, uint32_t lo) { m->id = gfxd_SP1Triangle; @@ -1053,7 +1082,9 @@ UCFUNC int d_SP1Triangle(gfxd_macro_t *m, uint32_t hi, uint32_t lo) } return ret; } +#endif +#if defined(F3DEX_GBI) || defined(F3DEX_GBI_2) UCFUNC int d_SP1Quadrangle(gfxd_macro_t *m, uint32_t hi, uint32_t lo); UCFUNC int d_SP2Triangles(gfxd_macro_t *m, uint32_t hi, uint32_t lo) { @@ -2016,10 +2047,6 @@ UCFUNC int c_DPLoadTLUT(gfxd_macro_t *m, int n_macro) return 0; } -#ifdef _MSC_VER -#pragma warning(disable:4146) -#endif - #if defined(F3DEX_GBI) || defined(F3DEX_GBI_2) UCFUNC int d_BranchZ(gfxd_macro_t *m, uint32_t hi, uint32_t lo) {