diff --git a/.gitmodules b/.gitmodules index 0d73816e3..7098d9d08 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,9 @@ [submodule "libultraship"] path = libultraship url = https://github.com/kenix3/libultraship.git +[submodule "ZAPDTR"] + path = ZAPDTR + url = https://github.com/harbourmasters/ZAPDTR +[submodule "OTRExporter"] + path = OTRExporter + url = https://github.com/harbourmasters/OTRExporter diff --git a/CMakeLists.txt b/CMakeLists.txt index 229a63bbc..92ddc528d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -124,7 +124,7 @@ add_custom_target( ExtractAssets # CMake versions prior to 3.17 do not have the rm command, use remove instead for older versions COMMAND ${CMAKE_COMMAND} -E $,remove,rm> -f oot.otr oot-mq.otr soh.otr - COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter/extract_assets.py -z "$" --non-interactive + COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter/extract_assets.py -z "$" --non-interactive --xml-root ../soh/assets/xml --custom-otr-file soh.otr "--custom-assets-path" ${CMAKE_CURRENT_SOURCE_DIR}/soh/assets/custom COMMAND ${CMAKE_COMMAND} -DSYSTEM_NAME=${CMAKE_SYSTEM_NAME} -DTARGET_DIR="$" -DSOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} -DBINARY_DIR=${CMAKE_BINARY_DIR} -P ${CMAKE_CURRENT_SOURCE_DIR}/copy-existing-otrs.cmake WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter COMMENT "Running asset extraction..." @@ -135,7 +135,7 @@ add_custom_target( # Target to generate headers add_custom_target( ExtractAssetHeaders - COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter/extract_assets.py -z "$" --non-interactive --gen-headers + COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter/extract_assets.py -z "$" --non-interactive --xml-root ../soh/assets/xml --gen-headers WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter COMMENT "Generating asset headers..." DEPENDS ZAPD @@ -146,7 +146,7 @@ add_custom_target( GenerateSohOtr # CMake versions prior to 3.17 do not have the rm command, use remove instead for older versions COMMAND ${CMAKE_COMMAND} -E $,remove,rm> -f soh.otr - COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter/extract_assets.py -z "$" --norom + COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter/extract_assets.py -z "$" --norom --custom-otr-file soh.otr "--custom-assets-path" ${CMAKE_CURRENT_SOURCE_DIR}/soh/assets/custom COMMAND ${CMAKE_COMMAND} -DSYSTEM_NAME=${CMAKE_SYSTEM_NAME} -DTARGET_DIR="$" -DSOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} -DBINARY_DIR=${CMAKE_BINARY_DIR} -DONLYSOHOTR=On -P ${CMAKE_CURRENT_SOURCE_DIR}/copy-existing-otrs.cmake WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter COMMENT "Generating soh.otr..." @@ -219,4 +219,4 @@ elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin") endif() set(CPACK_PROJECT_CONFIG_FILE ${CMAKE_SOURCE_DIR}/CMake/Packaging-2.cmake) -include(CMake/Packaging.cmake) \ No newline at end of file +include(CMake/Packaging.cmake) diff --git a/OTRExporter/.gitignore b/OTRExporter/.gitignore deleted file mode 100644 index 2080ab480..000000000 --- a/OTRExporter/.gitignore +++ /dev/null @@ -1,353 +0,0 @@ -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. -## -## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore - - -# User-specific files -*.suo -*.user -*.userosscache -*.sln.docstates - -# User-specific files (MonoDevelop/Xamarin Studio) -*.userprefs - -# Build results -[Dd]ebug/ -[Dd]ebugPublic/ -[Rr]elease/ -[Rr]eleases/ -x64/ -x86/ -bld/ -[Bb]in/ -[Oo]bj/ -[Ll]og/ - -# Visual Studio 2015/2017 cache/options directory -.vs/ -# Uncomment if you have tasks that create the project's static files in wwwroot -#wwwroot/ - -# Visual Studio 2017 auto generated files -Generated\ Files/ - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -# NUNIT -*.VisualState.xml -TestResult.xml - -# Build Results of an ATL Project -[Dd]ebugPS/ -[Rr]eleasePS/ -dlldata.c - -# Benchmark Results -BenchmarkDotNet.Artifacts/ - -# .NET Core -project.lock.json -project.fragment.lock.json -artifacts/ -**/Properties/launchSettings.json - -# StyleCop -StyleCopReport.xml - -# Files built by Visual Studio -*_i.c -*_p.c -*_i.h -*.ilk -*.meta -*.obj -*.iobj -*.pch -*.pdb -*.ipdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.svclog -*.scc - -# Chutzpah Test files -_Chutzpah* - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opendb -*.opensdf -*.sdf -*.cachefile -*.VC.db -*.VC.VC.opendb - -# Visual Studio profiler -*.psess -*.vsp -*.vspx -*.sap - -# Visual Studio Trace Files -*.e2e - -# TFS 2012 Local Workspace -$tf/ - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper -*.DotSettings.user - -# JustCode is a .NET coding add-in -.JustCode - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# AxoCover is a Code Coverage Tool -.axoCover/* -!.axoCover/settings.json - -# Visual Studio code coverage results -*.coverage -*.coveragexml - -# NCrunch -_NCrunch_* -.*crunch*.local.xml -nCrunchTemp_* - -# MightyMoose -*.mm.* -AutoTest.Net/ - -# Web workbench (sass) -.sass-cache/ - -# Installshield output folder -[Ee]xpress/ - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish/ - -# Publish Web Output -*.[Pp]ublish.xml -*.azurePubxml -# Note: Comment the next line if you want to checkin your web deploy settings, -# but database connection strings (with potential passwords) will be unencrypted -*.pubxml -*.publishproj - -# Microsoft Azure Web App publish settings. Comment the next line if you want to -# checkin your Azure Web App publish settings, but sensitive information contained -# in these scripts will be unencrypted -PublishScripts/ - -# NuGet Packages -*.nupkg -# The packages folder can be ignored because of Package Restore -**/[Pp]ackages/* -# except build/, which is used as an MSBuild target. -!**/[Pp]ackages/build/ -# Uncomment if necessary however generally it will be regenerated when needed -#!**/[Pp]ackages/repositories.config -# NuGet v3's project.json files produces more ignorable files -*.nuget.props -*.nuget.targets - -# Microsoft Azure Build Output -csx/ -*.build.csdef - -# Microsoft Azure Emulator -ecf/ -rcf/ - -# Windows Store app package directories and files -AppPackages/ -BundleArtifacts/ -Package.StoreAssociation.xml -_pkginfo.txt -*.appx - -# Visual Studio cache files -# files ending in .cache can be ignored -*.[Cc]ache -# but keep track of directories ending in .cache -!*.[Cc]ache/ - -# Others -ClientBin/ -~$* -*~ -*.dbmdl -*.dbproj.schemaview -*.jfm -*.pfx -*.publishsettings -orleans.codegen.cs - -# Including strong name files can present a security risk -# (https://github.com/github/gitignore/pull/2483#issue-259490424) -#*.snk - -# Since there are multiple workflows, uncomment next line to ignore bower_components -# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) -#bower_components/ - -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file -# to a newer Visual Studio version. Backup files are not needed, -# because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm -ServiceFabricBackup/ -*.rptproj.bak - -# SQL Server files -*.mdf -*.ldf -*.ndf - -# Business Intelligence projects -*.rdl.data -*.bim.layout -*.bim_*.settings -*.rptproj.rsuser - -# Microsoft Fakes -FakesAssemblies/ - -# GhostDoc plugin setting file -*.GhostDoc.xml - -# Node.js Tools for Visual Studio -.ntvs_analysis.dat -node_modules/ - -# Visual Studio 6 build log -*.plg - -# Visual Studio 6 workspace options file -*.opt - -# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) -*.vbw - -# Visual Studio LightSwitch build output -**/*.HTMLClient/GeneratedArtifacts -**/*.DesktopClient/GeneratedArtifacts -**/*.DesktopClient/ModelManifest.xml -**/*.Server/GeneratedArtifacts -**/*.Server/ModelManifest.xml -_Pvt_Extensions - -# Paket dependency manager -.paket/paket.exe -paket-files/ - -# FAKE - F# Make -.fake/ - -# JetBrains Rider -.idea/ -*.sln.iml - -# CodeRush -.cr/ - -# Python Tools for Visual Studio (PTVS) -__pycache__/ -*.pyc - -# Cake - Uncomment if you are using it -# tools/** -# !tools/packages.config - -# Tabs Studio -*.tss - -# Telerik's JustMock configuration file -*.jmconfig - -# BizTalk build output -*.btp.cs -*.btm.cs -*.odx.cs -*.xsd.cs - -# OpenCover UI analysis results -OpenCover/ - -# Azure Stream Analytics local run output -ASALocalRun/ - -# MSBuild Binary and Structured Log -*.binlog - -# NVidia Nsight GPU debugger configuration file -*.nvuser - -# MFractors (Xamarin productivity tool) working folder -.mfractor/ - -*.out -*.o -*.d -lib/libgfxd/libgfxd.a -ExporterTest/ExporterTest.a -ZAPDUtils/ZAPDUtils.a -.vscode/ -build/ -ZAPDUtils/build/ -ZAPD/BuildInfo.h -baserom/ -baserom_ntsc/ -*.vtx.inc -*.otr -*.swp -*.a -*.z64 -*.n64 -Extract/ - -tmp.txt diff --git a/OTRExporter/.gitrepo b/OTRExporter/.gitrepo deleted file mode 100644 index 80e147d0c..000000000 --- a/OTRExporter/.gitrepo +++ /dev/null @@ -1,12 +0,0 @@ -; DO NOT EDIT (unless you know what you are doing) -; -; This subdirectory is a git "subrepo", and this file is maintained by the -; git-subrepo command. See https://github.com/git-commands/git-subrepo#readme -; -[subrepo] - remote = https://github.com/HarbourMasters/OTRExporter.git - branch = master - commit = 1503d3eefa0b51164371c60c2aae8ad057678319 - parent = d24c8453db1035f382e1b0853be00ebd281bbbdd - method = rebase - cmdver = 0.4.1 diff --git a/OTRExporter/CFG/ActorList_OoTMqDbg.txt b/OTRExporter/CFG/ActorList_OoTMqDbg.txt deleted file mode 100644 index a0395eb27..000000000 --- a/OTRExporter/CFG/ActorList_OoTMqDbg.txt +++ /dev/null @@ -1,472 +0,0 @@ -ACTOR_PLAYER -ACTOR_UNSET_1 -ACTOR_EN_TEST -ACTOR_UNSET_3 -ACTOR_EN_GIRLA -ACTOR_UNSET_5 -ACTOR_UNSET_6 -ACTOR_EN_PART -ACTOR_EN_LIGHT -ACTOR_EN_DOOR -ACTOR_EN_BOX -ACTOR_BG_DY_YOSEIZO -ACTOR_BG_HIDAN_FIREWALL -ACTOR_EN_POH -ACTOR_EN_OKUTA -ACTOR_BG_YDAN_SP -ACTOR_EN_BOM -ACTOR_EN_WALLMAS -ACTOR_EN_DODONGO -ACTOR_EN_FIREFLY -ACTOR_EN_HORSE -ACTOR_EN_ITEM00 -ACTOR_EN_ARROW -ACTOR_UNSET_17 -ACTOR_EN_ELF -ACTOR_EN_NIW -ACTOR_UNSET_1A -ACTOR_EN_TITE -ACTOR_EN_REEBA -ACTOR_EN_PEEHAT -ACTOR_EN_BUTTE -ACTOR_UNSET_1F -ACTOR_EN_INSECT -ACTOR_EN_FISH -ACTOR_UNSET_22 -ACTOR_EN_HOLL -ACTOR_EN_SCENE_CHANGE -ACTOR_EN_ZF -ACTOR_EN_HATA -ACTOR_BOSS_DODONGO -ACTOR_BOSS_GOMA -ACTOR_EN_ZL1 -ACTOR_EN_VIEWER -ACTOR_EN_GOMA -ACTOR_BG_PUSHBOX -ACTOR_EN_BUBBLE -ACTOR_DOOR_SHUTTER -ACTOR_EN_DODOJR -ACTOR_EN_BDFIRE -ACTOR_UNSET_31 -ACTOR_EN_BOOM -ACTOR_EN_TORCH2 -ACTOR_EN_BILI -ACTOR_EN_TP -ACTOR_UNSET_36 -ACTOR_EN_ST -ACTOR_EN_BW -ACTOR_EN_A_OBJ -ACTOR_EN_EIYER -ACTOR_EN_RIVER_SOUND -ACTOR_EN_HORSE_NORMAL -ACTOR_EN_OSSAN -ACTOR_BG_TREEMOUTH -ACTOR_BG_DODOAGO -ACTOR_BG_HIDAN_DALM -ACTOR_BG_HIDAN_HROCK -ACTOR_EN_HORSE_GANON -ACTOR_BG_HIDAN_ROCK -ACTOR_BG_HIDAN_RSEKIZOU -ACTOR_BG_HIDAN_SEKIZOU -ACTOR_BG_HIDAN_SIMA -ACTOR_BG_HIDAN_SYOKU -ACTOR_EN_XC -ACTOR_BG_HIDAN_CURTAIN -ACTOR_BG_SPOT00_HANEBASI -ACTOR_EN_MB -ACTOR_EN_BOMBF -ACTOR_EN_ZL2 -ACTOR_BG_HIDAN_FSLIFT -ACTOR_EN_OE2 -ACTOR_BG_YDAN_HASI -ACTOR_BG_YDAN_MARUTA -ACTOR_BOSS_GANONDROF -ACTOR_UNSET_53 -ACTOR_EN_AM -ACTOR_EN_DEKUBABA -ACTOR_EN_M_FIRE1 -ACTOR_EN_M_THUNDER -ACTOR_BG_DDAN_JD -ACTOR_BG_BREAKWALL -ACTOR_EN_JJ -ACTOR_EN_HORSE_ZELDA -ACTOR_BG_DDAN_KD -ACTOR_DOOR_WARP1 -ACTOR_OBJ_SYOKUDAI -ACTOR_ITEM_B_HEART -ACTOR_EN_DEKUNUTS -ACTOR_BG_MENKURI_KAITEN -ACTOR_BG_MENKURI_EYE -ACTOR_EN_VALI -ACTOR_BG_MIZU_MOVEBG -ACTOR_BG_MIZU_WATER -ACTOR_ARMS_HOOK -ACTOR_EN_FHG -ACTOR_BG_MORI_HINERI -ACTOR_EN_BB -ACTOR_BG_TOKI_HIKARI -ACTOR_EN_YUKABYUN -ACTOR_BG_TOKI_SWD -ACTOR_EN_FHG_FIRE -ACTOR_BG_MJIN -ACTOR_BG_HIDAN_KOUSI -ACTOR_DOOR_TOKI -ACTOR_BG_HIDAN_HAMSTEP -ACTOR_EN_BIRD -ACTOR_UNSET_73 -ACTOR_UNSET_74 -ACTOR_UNSET_75 -ACTOR_UNSET_76 -ACTOR_EN_WOOD02 -ACTOR_UNSET_78 -ACTOR_UNSET_79 -ACTOR_UNSET_7A -ACTOR_UNSET_7B -ACTOR_EN_LIGHTBOX -ACTOR_EN_PU_BOX -ACTOR_UNSET_7E -ACTOR_UNSET_7F -ACTOR_EN_TRAP -ACTOR_EN_AROW_TRAP -ACTOR_EN_VASE -ACTOR_UNSET_83 -ACTOR_EN_TA -ACTOR_EN_TK -ACTOR_BG_MORI_BIGST -ACTOR_BG_MORI_ELEVATOR -ACTOR_BG_MORI_KAITENKABE -ACTOR_BG_MORI_RAKKATENJO -ACTOR_EN_VM -ACTOR_DEMO_EFFECT -ACTOR_DEMO_KANKYO -ACTOR_BG_HIDAN_FWBIG -ACTOR_EN_FLOORMAS -ACTOR_EN_HEISHI1 -ACTOR_EN_RD -ACTOR_EN_PO_SISTERS -ACTOR_BG_HEAVY_BLOCK -ACTOR_BG_PO_EVENT -ACTOR_OBJ_MURE -ACTOR_EN_SW -ACTOR_BOSS_FD -ACTOR_OBJECT_KANKYO -ACTOR_EN_DU -ACTOR_EN_FD -ACTOR_EN_HORSE_LINK_CHILD -ACTOR_DOOR_ANA -ACTOR_BG_SPOT02_OBJECTS -ACTOR_BG_HAKA -ACTOR_MAGIC_WIND -ACTOR_MAGIC_FIRE -ACTOR_UNSET_A0 -ACTOR_EN_RU1 -ACTOR_BOSS_FD2 -ACTOR_EN_FD_FIRE -ACTOR_EN_DH -ACTOR_EN_DHA -ACTOR_EN_RL -ACTOR_EN_ENCOUNT1 -ACTOR_DEMO_DU -ACTOR_DEMO_IM -ACTOR_DEMO_TRE_LGT -ACTOR_EN_FW -ACTOR_BG_VB_SIMA -ACTOR_EN_VB_BALL -ACTOR_BG_HAKA_MEGANE -ACTOR_BG_HAKA_MEGANEBG -ACTOR_BG_HAKA_SHIP -ACTOR_BG_HAKA_SGAMI -ACTOR_UNSET_B2 -ACTOR_EN_HEISHI2 -ACTOR_EN_ENCOUNT2 -ACTOR_EN_FIRE_ROCK -ACTOR_EN_BROB -ACTOR_MIR_RAY -ACTOR_BG_SPOT09_OBJ -ACTOR_BG_SPOT18_OBJ -ACTOR_BOSS_VA -ACTOR_BG_HAKA_TUBO -ACTOR_BG_HAKA_TRAP -ACTOR_BG_HAKA_HUTA -ACTOR_BG_HAKA_ZOU -ACTOR_BG_SPOT17_FUNEN -ACTOR_EN_SYATEKI_ITM -ACTOR_EN_SYATEKI_MAN -ACTOR_EN_TANA -ACTOR_EN_NB -ACTOR_BOSS_MO -ACTOR_EN_SB -ACTOR_EN_BIGOKUTA -ACTOR_EN_KAREBABA -ACTOR_BG_BDAN_OBJECTS -ACTOR_DEMO_SA -ACTOR_DEMO_GO -ACTOR_EN_IN -ACTOR_EN_TR -ACTOR_BG_SPOT16_BOMBSTONE -ACTOR_UNSET_CE -ACTOR_BG_HIDAN_KOWARERUKABE -ACTOR_BG_BOMBWALL -ACTOR_BG_SPOT08_ICEBLOCK -ACTOR_EN_RU2 -ACTOR_OBJ_DEKUJR -ACTOR_BG_MIZU_UZU -ACTOR_BG_SPOT06_OBJECTS -ACTOR_BG_ICE_OBJECTS -ACTOR_BG_HAKA_WATER -ACTOR_UNSET_D8 -ACTOR_EN_MA2 -ACTOR_EN_BOM_CHU -ACTOR_EN_HORSE_GAME_CHECK -ACTOR_BOSS_TW -ACTOR_EN_RR -ACTOR_EN_BA -ACTOR_EN_BX -ACTOR_EN_ANUBICE -ACTOR_EN_ANUBICE_FIRE -ACTOR_BG_MORI_HASHIGO -ACTOR_BG_MORI_HASHIRA4 -ACTOR_BG_MORI_IDOMIZU -ACTOR_BG_SPOT16_DOUGHNUT -ACTOR_BG_BDAN_SWITCH -ACTOR_EN_MA1 -ACTOR_BOSS_GANON -ACTOR_BOSS_SST -ACTOR_UNSET_EA -ACTOR_UNSET_EB -ACTOR_EN_NY -ACTOR_EN_FR -ACTOR_ITEM_SHIELD -ACTOR_BG_ICE_SHELTER -ACTOR_EN_ICE_HONO -ACTOR_ITEM_OCARINA -ACTOR_UNSET_F2 -ACTOR_UNSET_F3 -ACTOR_MAGIC_DARK -ACTOR_DEMO_6K -ACTOR_EN_ANUBICE_TAG -ACTOR_BG_HAKA_GATE -ACTOR_BG_SPOT15_SAKU -ACTOR_BG_JYA_GOROIWA -ACTOR_BG_JYA_ZURERUKABE -ACTOR_UNSET_FB -ACTOR_BG_JYA_COBRA -ACTOR_BG_JYA_KANAAMI -ACTOR_FISHING -ACTOR_OBJ_OSHIHIKI -ACTOR_BG_GATE_SHUTTER -ACTOR_EFF_DUST -ACTOR_BG_SPOT01_FUSYA -ACTOR_BG_SPOT01_IDOHASHIRA -ACTOR_BG_SPOT01_IDOMIZU -ACTOR_BG_PO_SYOKUDAI -ACTOR_BG_GANON_OTYUKA -ACTOR_BG_SPOT15_RRBOX -ACTOR_BG_UMAJUMP -ACTOR_UNSET_109 -ACTOR_ARROW_FIRE -ACTOR_ARROW_ICE -ACTOR_ARROW_LIGHT -ACTOR_UNSET_10D -ACTOR_UNSET_10E -ACTOR_ITEM_ETCETERA -ACTOR_OBJ_KIBAKO -ACTOR_OBJ_TSUBO -ACTOR_EN_WONDER_ITEM -ACTOR_EN_IK -ACTOR_DEMO_IK -ACTOR_EN_SKJ -ACTOR_EN_SKJNEEDLE -ACTOR_EN_G_SWITCH -ACTOR_DEMO_EXT -ACTOR_DEMO_SHD -ACTOR_EN_DNS -ACTOR_ELF_MSG -ACTOR_EN_HONOTRAP -ACTOR_EN_TUBO_TRAP -ACTOR_OBJ_ICE_POLY -ACTOR_BG_SPOT03_TAKI -ACTOR_BG_SPOT07_TAKI -ACTOR_EN_FZ -ACTOR_EN_PO_RELAY -ACTOR_BG_RELAY_OBJECTS -ACTOR_EN_DIVING_GAME -ACTOR_EN_KUSA -ACTOR_OBJ_BEAN -ACTOR_OBJ_BOMBIWA -ACTOR_UNSET_128 -ACTOR_UNSET_129 -ACTOR_OBJ_SWITCH -ACTOR_OBJ_ELEVATOR -ACTOR_OBJ_LIFT -ACTOR_OBJ_HSBLOCK -ACTOR_EN_OKARINA_TAG -ACTOR_EN_YABUSAME_MARK -ACTOR_EN_GOROIWA -ACTOR_EN_EX_RUPPY -ACTOR_EN_TORYO -ACTOR_EN_DAIKU -ACTOR_UNSET_134 -ACTOR_EN_NWC -ACTOR_EN_BLKOBJ -ACTOR_ITEM_INBOX -ACTOR_EN_GE1 -ACTOR_OBJ_BLOCKSTOP -ACTOR_EN_SDA -ACTOR_EN_CLEAR_TAG -ACTOR_EN_NIW_LADY -ACTOR_EN_GM -ACTOR_EN_MS -ACTOR_EN_HS -ACTOR_BG_INGATE -ACTOR_EN_KANBAN -ACTOR_EN_HEISHI3 -ACTOR_EN_SYATEKI_NIW -ACTOR_EN_ATTACK_NIW -ACTOR_BG_SPOT01_IDOSOKO -ACTOR_EN_SA -ACTOR_EN_WONDER_TALK -ACTOR_BG_GJYO_BRIDGE -ACTOR_EN_DS -ACTOR_EN_MK -ACTOR_EN_BOM_BOWL_MAN -ACTOR_EN_BOM_BOWL_PIT -ACTOR_EN_OWL -ACTOR_EN_ISHI -ACTOR_OBJ_HANA -ACTOR_OBJ_LIGHTSWITCH -ACTOR_OBJ_MURE2 -ACTOR_EN_GO -ACTOR_EN_FU -ACTOR_UNSET_154 -ACTOR_EN_CHANGER -ACTOR_BG_JYA_MEGAMI -ACTOR_BG_JYA_LIFT -ACTOR_BG_JYA_BIGMIRROR -ACTOR_BG_JYA_BOMBCHUIWA -ACTOR_BG_JYA_AMISHUTTER -ACTOR_BG_JYA_BOMBIWA -ACTOR_BG_SPOT18_BASKET -ACTOR_UNSET_15D -ACTOR_EN_GANON_ORGAN -ACTOR_EN_SIOFUKI -ACTOR_EN_STREAM -ACTOR_UNSET_161 -ACTOR_EN_MM -ACTOR_EN_KO -ACTOR_EN_KZ -ACTOR_EN_WEATHER_TAG -ACTOR_BG_SST_FLOOR -ACTOR_EN_ANI -ACTOR_EN_EX_ITEM -ACTOR_BG_JYA_IRONOBJ -ACTOR_EN_JS -ACTOR_EN_JSJUTAN -ACTOR_EN_CS -ACTOR_EN_MD -ACTOR_EN_HY -ACTOR_EN_GANON_MANT -ACTOR_EN_OKARINA_EFFECT -ACTOR_EN_MAG -ACTOR_DOOR_GERUDO -ACTOR_ELF_MSG2 -ACTOR_DEMO_GT -ACTOR_EN_PO_FIELD -ACTOR_EFC_ERUPC -ACTOR_BG_ZG -ACTOR_EN_HEISHI4 -ACTOR_EN_ZL3 -ACTOR_BOSS_GANON2 -ACTOR_EN_KAKASI -ACTOR_EN_TAKARA_MAN -ACTOR_OBJ_MAKEOSHIHIKI -ACTOR_OCEFF_SPOT -ACTOR_END_TITLE -ACTOR_UNSET_180 -ACTOR_EN_TORCH -ACTOR_DEMO_EC -ACTOR_SHOT_SUN -ACTOR_EN_DY_EXTRA -ACTOR_EN_WONDER_TALK2 -ACTOR_EN_GE2 -ACTOR_OBJ_ROOMTIMER -ACTOR_EN_SSH -ACTOR_EN_STH -ACTOR_OCEFF_WIPE -ACTOR_OCEFF_STORM -ACTOR_EN_WEIYER -ACTOR_BG_SPOT05_SOKO -ACTOR_BG_JYA_1FLIFT -ACTOR_BG_JYA_HAHENIRON -ACTOR_BG_SPOT12_GATE -ACTOR_BG_SPOT12_SAKU -ACTOR_EN_HINTNUTS -ACTOR_EN_NUTSBALL -ACTOR_BG_SPOT00_BREAK -ACTOR_EN_SHOPNUTS -ACTOR_EN_IT -ACTOR_EN_GELDB -ACTOR_OCEFF_WIPE2 -ACTOR_OCEFF_WIPE3 -ACTOR_EN_NIW_GIRL -ACTOR_EN_DOG -ACTOR_EN_SI -ACTOR_BG_SPOT01_OBJECTS2 -ACTOR_OBJ_COMB -ACTOR_BG_SPOT11_BAKUDANKABE -ACTOR_OBJ_KIBAKO2 -ACTOR_EN_DNT_DEMO -ACTOR_EN_DNT_JIJI -ACTOR_EN_DNT_NOMAL -ACTOR_EN_GUEST -ACTOR_BG_BOM_GUARD -ACTOR_EN_HS2 -ACTOR_DEMO_KEKKAI -ACTOR_BG_SPOT08_BAKUDANKABE -ACTOR_BG_SPOT17_BAKUDANKABE -ACTOR_UNSET_1AA -ACTOR_OBJ_MURE3 -ACTOR_EN_TG -ACTOR_EN_MU -ACTOR_EN_GO2 -ACTOR_EN_WF -ACTOR_EN_SKB -ACTOR_DEMO_GJ -ACTOR_DEMO_GEFF -ACTOR_BG_GND_FIREMEIRO -ACTOR_BG_GND_DARKMEIRO -ACTOR_BG_GND_SOULMEIRO -ACTOR_BG_GND_NISEKABE -ACTOR_BG_GND_ICEBLOCK -ACTOR_EN_GB -ACTOR_EN_GS -ACTOR_BG_MIZU_BWALL -ACTOR_BG_MIZU_SHUTTER -ACTOR_EN_DAIKU_KAKARIKO -ACTOR_BG_BOWL_WALL -ACTOR_EN_WALL_TUBO -ACTOR_EN_PO_DESERT -ACTOR_EN_CROW -ACTOR_DOOR_KILLER -ACTOR_BG_SPOT11_OASIS -ACTOR_BG_SPOT18_FUTA -ACTOR_BG_SPOT18_SHUTTER -ACTOR_EN_MA3 -ACTOR_EN_COW -ACTOR_BG_ICE_TURARA -ACTOR_BG_ICE_SHUTTER -ACTOR_EN_KAKASI2 -ACTOR_EN_KAKASI3 -ACTOR_OCEFF_WIPE4 -ACTOR_EN_EG -ACTOR_BG_MENKURI_NISEKABE -ACTOR_EN_ZO -ACTOR_OBJ_MAKEKINSUTA -ACTOR_EN_GE3 -ACTOR_OBJ_TIMEBLOCK -ACTOR_OBJ_HAMISHI -ACTOR_EN_ZL4 -ACTOR_EN_MM2 -ACTOR_BG_JYA_BLOCK -ACTOR_OBJ_WARP2BLOCK -ACTOR_ID_MAX \ No newline at end of file diff --git a/OTRExporter/CFG/Config.xml b/OTRExporter/CFG/Config.xml deleted file mode 100644 index adec174ca..000000000 --- a/OTRExporter/CFG/Config.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/OTRExporter/CFG/ObjectList_OoTMqDbg.txt b/OTRExporter/CFG/ObjectList_OoTMqDbg.txt deleted file mode 100644 index 1ecc3441b..000000000 --- a/OTRExporter/CFG/ObjectList_OoTMqDbg.txt +++ /dev/null @@ -1,402 +0,0 @@ -OBJECT_INVALID -OBJECT_GAMEPLAY_KEEP -OBJECT_GAMEPLAY_FIELD_KEEP -OBJECT_GAMEPLAY_DANGEON_KEEP -OBJECT_UNSET_4 -OBJECT_UNSET_5 -OBJECT_HUMAN -OBJECT_OKUTA -OBJECT_CROW -OBJECT_POH -OBJECT_DY_OBJ -OBJECT_WALLMASTER -OBJECT_DODONGO -OBJECT_FIREFLY -OBJECT_BOX -OBJECT_FIRE -OBJECT_UNSET_10 -OBJECT_UNSET_11 -OBJECT_BUBBLE -OBJECT_NIW -OBJECT_LINK_BOY -OBJECT_LINK_CHILD -OBJECT_TITE -OBJECT_REEBA -OBJECT_PEEHAT -OBJECT_KINGDODONGO -OBJECT_HORSE -OBJECT_ZF -OBJECT_GOMA -OBJECT_ZL1 -OBJECT_GOL -OBJECT_DODOJR -OBJECT_TORCH2 -OBJECT_BL -OBJECT_TP -OBJECT_OA1 -OBJECT_ST -OBJECT_BW -OBJECT_EI -OBJECT_HORSE_NORMAL -OBJECT_OB1 -OBJECT_O_ANIME -OBJECT_SPOT04_OBJECTS -OBJECT_DDAN_OBJECTS -OBJECT_HIDAN_OBJECTS -OBJECT_HORSE_GANON -OBJECT_OA2 -OBJECT_SPOT00_OBJECTS -OBJECT_MB -OBJECT_BOMBF -OBJECT_SK2 -OBJECT_OE1 -OBJECT_OE_ANIME -OBJECT_OE2 -OBJECT_YDAN_OBJECTS -OBJECT_GND -OBJECT_AM -OBJECT_DEKUBABA -OBJECT_UNSET_3A -OBJECT_OA3 -OBJECT_OA4 -OBJECT_OA5 -OBJECT_OA6 -OBJECT_OA7 -OBJECT_JJ -OBJECT_OA8 -OBJECT_OA9 -OBJECT_OB2 -OBJECT_OB3 -OBJECT_OB4 -OBJECT_HORSE_ZELDA -OBJECT_OPENING_DEMO1 -OBJECT_WARP1 -OBJECT_B_HEART -OBJECT_DEKUNUTS -OBJECT_OE3 -OBJECT_OE4 -OBJECT_MENKURI_OBJECTS -OBJECT_OE5 -OBJECT_OE6 -OBJECT_OE7 -OBJECT_OE8 -OBJECT_OE9 -OBJECT_OE10 -OBJECT_OE11 -OBJECT_OE12 -OBJECT_VALI -OBJECT_OA10 -OBJECT_OA11 -OBJECT_MIZU_OBJECTS -OBJECT_FHG -OBJECT_OSSAN -OBJECT_MORI_HINERI1 -OBJECT_BB -OBJECT_TOKI_OBJECTS -OBJECT_YUKABYUN -OBJECT_ZL2 -OBJECT_MJIN -OBJECT_MJIN_FLASH -OBJECT_MJIN_DARK -OBJECT_MJIN_FLAME -OBJECT_MJIN_ICE -OBJECT_MJIN_SOUL -OBJECT_MJIN_WIND -OBJECT_MJIN_OKA -OBJECT_HAKA_OBJECTS -OBJECT_SPOT06_OBJECTS -OBJECT_ICE_OBJECTS -OBJECT_RELAY_OBJECTS -OBJECT_PO_FIELD -OBJECT_PO_COMPOSER -OBJECT_MORI_HINERI1A -OBJECT_MORI_HINERI2 -OBJECT_MORI_HINERI2A -OBJECT_MORI_OBJECTS -OBJECT_MORI_TEX -OBJECT_SPOT08_OBJ -OBJECT_WARP2 -OBJECT_HATA -OBJECT_BIRD -OBJECT_UNSET_78 -OBJECT_UNSET_79 -OBJECT_UNSET_7A -OBJECT_UNSET_7B -OBJECT_WOOD02 -OBJECT_UNSET_7D -OBJECT_UNSET_7E -OBJECT_UNSET_7F -OBJECT_UNSET_80 -OBJECT_LIGHTBOX -OBJECT_PU_BOX -OBJECT_UNSET_83 -OBJECT_UNSET_84 -OBJECT_TRAP -OBJECT_VASE -OBJECT_IM -OBJECT_TA -OBJECT_TK -OBJECT_XC -OBJECT_VM -OBJECT_BV -OBJECT_HAKACH_OBJECTS -OBJECT_EFC_CRYSTAL_LIGHT -OBJECT_EFC_FIRE_BALL -OBJECT_EFC_FLASH -OBJECT_EFC_LGT_SHOWER -OBJECT_EFC_STAR_FIELD -OBJECT_GOD_LGT -OBJECT_LIGHT_RING -OBJECT_TRIFORCE_SPOT -OBJECT_BDAN_OBJECTS -OBJECT_SD -OBJECT_RD -OBJECT_PO_SISTERS -OBJECT_HEAVY_OBJECT -OBJECT_GNDD -OBJECT_FD -OBJECT_DU -OBJECT_FW -OBJECT_MEDAL -OBJECT_HORSE_LINK_CHILD -OBJECT_SPOT02_OBJECTS -OBJECT_HAKA -OBJECT_RU1 -OBJECT_SYOKUDAI -OBJECT_FD2 -OBJECT_DH -OBJECT_RL -OBJECT_EFC_TW -OBJECT_DEMO_TRE_LGT -OBJECT_GI_KEY -OBJECT_MIR_RAY -OBJECT_BROB -OBJECT_GI_JEWEL -OBJECT_SPOT09_OBJ -OBJECT_SPOT18_OBJ -OBJECT_BDOOR -OBJECT_SPOT17_OBJ -OBJECT_SHOP_DUNGEN -OBJECT_NB -OBJECT_MO -OBJECT_SB -OBJECT_GI_MELODY -OBJECT_GI_HEART -OBJECT_GI_COMPASS -OBJECT_GI_BOSSKEY -OBJECT_GI_MEDAL -OBJECT_GI_NUTS -OBJECT_SA -OBJECT_GI_HEARTS -OBJECT_GI_ARROWCASE -OBJECT_GI_BOMBPOUCH -OBJECT_IN -OBJECT_TR -OBJECT_SPOT16_OBJ -OBJECT_OE1S -OBJECT_OE4S -OBJECT_OS_ANIME -OBJECT_GI_BOTTLE -OBJECT_GI_STICK -OBJECT_GI_MAP -OBJECT_OF1D_MAP -OBJECT_RU2 -OBJECT_GI_SHIELD_1 -OBJECT_DEKUJR -OBJECT_GI_MAGICPOT -OBJECT_GI_BOMB_1 -OBJECT_OF1S -OBJECT_MA2 -OBJECT_GI_PURSE -OBJECT_HNI -OBJECT_TW -OBJECT_RR -OBJECT_BXA -OBJECT_ANUBICE -OBJECT_GI_GERUDO -OBJECT_GI_ARROW -OBJECT_GI_BOMB_2 -OBJECT_GI_EGG -OBJECT_GI_SCALE -OBJECT_GI_SHIELD_2 -OBJECT_GI_HOOKSHOT -OBJECT_GI_OCARINA -OBJECT_GI_MILK -OBJECT_MA1 -OBJECT_GANON -OBJECT_SST -OBJECT_NY_UNUSED -OBJECT_UNSET_E4 -OBJECT_NY -OBJECT_FR -OBJECT_GI_PACHINKO -OBJECT_GI_BOOMERANG -OBJECT_GI_BOW -OBJECT_GI_GLASSES -OBJECT_GI_LIQUID -OBJECT_ANI -OBJECT_DEMO_6K -OBJECT_GI_SHIELD_3 -OBJECT_GI_LETTER -OBJECT_SPOT15_OBJ -OBJECT_JYA_OBJ -OBJECT_GI_CLOTHES -OBJECT_GI_BEAN -OBJECT_GI_FISH -OBJECT_GI_SAW -OBJECT_GI_HAMMER -OBJECT_GI_GRASS -OBJECT_GI_LONGSWORD -OBJECT_SPOT01_OBJECTS -OBJECT_MD_UNUSED -OBJECT_MD -OBJECT_KM1 -OBJECT_KW1 -OBJECT_ZO -OBJECT_KZ -OBJECT_UMAJUMP -OBJECT_MASTERKOKIRI -OBJECT_MASTERKOKIRIHEAD -OBJECT_MASTERGOLON -OBJECT_MASTERZOORA -OBJECT_AOB -OBJECT_IK -OBJECT_AHG -OBJECT_CNE -OBJECT_GI_NIWATORI -OBJECT_SKJ -OBJECT_GI_BOTTLE_LETTER -OBJECT_BJI -OBJECT_BBA -OBJECT_GI_OCARINA_0 -OBJECT_DS -OBJECT_ANE -OBJECT_BOJ -OBJECT_SPOT03_OBJECT -OBJECT_SPOT07_OBJECT -OBJECT_FZ -OBJECT_BOB -OBJECT_GE1 -OBJECT_YABUSAME_POINT -OBJECT_GI_BOOTS_2 -OBJECT_GI_SEED -OBJECT_GND_MAGIC -OBJECT_D_ELEVATOR -OBJECT_D_HSBLOCK -OBJECT_D_LIFT -OBJECT_MAMENOKI -OBJECT_GOROIWA -OBJECT_UNSET_120 -OBJECT_TORYO -OBJECT_DAIKU -OBJECT_UNSET_123 -OBJECT_NWC -OBJECT_BLKOBJ -OBJECT_GM -OBJECT_MS -OBJECT_HS -OBJECT_INGATE -OBJECT_LIGHTSWITCH -OBJECT_KUSA -OBJECT_TSUBO -OBJECT_GI_GLOVES -OBJECT_GI_COIN -OBJECT_KANBAN -OBJECT_GJYO_OBJECTS -OBJECT_OWL -OBJECT_MK -OBJECT_FU -OBJECT_GI_KI_TAN_MASK -OBJECT_GI_REDEAD_MASK -OBJECT_GI_SKJ_MASK -OBJECT_GI_RABIT_MASK -OBJECT_GI_TRUTH_MASK -OBJECT_GANON_OBJECTS -OBJECT_SIOFUKI -OBJECT_STREAM -OBJECT_MM -OBJECT_FA -OBJECT_OS -OBJECT_GI_EYE_LOTION -OBJECT_GI_POWDER -OBJECT_GI_MUSHROOM -OBJECT_GI_TICKETSTONE -OBJECT_GI_BROKENSWORD -OBJECT_JS -OBJECT_CS -OBJECT_GI_PRESCRIPTION -OBJECT_GI_BRACELET -OBJECT_GI_SOLDOUT -OBJECT_GI_FROG -OBJECT_MAG -OBJECT_DOOR_GERUDO -OBJECT_GT -OBJECT_EFC_ERUPC -OBJECT_ZL2_ANIME1 -OBJECT_ZL2_ANIME2 -OBJECT_GI_GOLONMASK -OBJECT_GI_ZORAMASK -OBJECT_GI_GERUDOMASK -OBJECT_GANON2 -OBJECT_KA -OBJECT_TS -OBJECT_ZG -OBJECT_GI_HOVERBOOTS -OBJECT_GI_M_ARROW -OBJECT_DS2 -OBJECT_EC -OBJECT_FISH -OBJECT_GI_SUTARU -OBJECT_GI_GODDESS -OBJECT_SSH -OBJECT_BIGOKUTA -OBJECT_BG -OBJECT_SPOT05_OBJECTS -OBJECT_SPOT12_OBJ -OBJECT_BOMBIWA -OBJECT_HINTNUTS -OBJECT_RS -OBJECT_SPOT00_BREAK -OBJECT_GLA -OBJECT_SHOPNUTS -OBJECT_GELDB -OBJECT_GR -OBJECT_DOG -OBJECT_JYA_IRON -OBJECT_JYA_DOOR -OBJECT_UNSET_16E -OBJECT_SPOT11_OBJ -OBJECT_KIBAKO2 -OBJECT_DNS -OBJECT_DNK -OBJECT_GI_FIRE -OBJECT_GI_INSECT -OBJECT_GI_BUTTERFLY -OBJECT_GI_GHOST -OBJECT_GI_SOUL -OBJECT_BOWL -OBJECT_DEMO_KEKKAI -OBJECT_EFC_DOUGHNUT -OBJECT_GI_DEKUPOUCH -OBJECT_GANON_ANIME1 -OBJECT_GANON_ANIME2 -OBJECT_GANON_ANIME3 -OBJECT_GI_RUPY -OBJECT_SPOT01_MATOYA -OBJECT_SPOT01_MATOYAB -OBJECT_MU -OBJECT_WF -OBJECT_SKB -OBJECT_GJ -OBJECT_GEFF -OBJECT_HAKA_DOOR -OBJECT_GS -OBJECT_PS -OBJECT_BWALL -OBJECT_COW -OBJECT_COB -OBJECT_GI_SWORD_1 -OBJECT_DOOR_KILLER -OBJECT_OUKE_HAKA -OBJECT_TIMEBLOCK -OBJECT_ZL4 \ No newline at end of file diff --git a/OTRExporter/CFG/SymbolMap_OoTMqDbg.txt b/OTRExporter/CFG/SymbolMap_OoTMqDbg.txt deleted file mode 100644 index 015e7e88a..000000000 --- a/OTRExporter/CFG/SymbolMap_OoTMqDbg.txt +++ /dev/null @@ -1 +0,0 @@ -8012DB20 gMtxClear \ No newline at end of file diff --git a/OTRExporter/CFG/TexturePool.xml b/OTRExporter/CFG/TexturePool.xml deleted file mode 100644 index 924ded703..000000000 --- a/OTRExporter/CFG/TexturePool.xml +++ /dev/null @@ -1,952 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/OTRExporter/CFG/filelists/dbg.txt b/OTRExporter/CFG/filelists/dbg.txt deleted file mode 100644 index 68af5e557..000000000 --- a/OTRExporter/CFG/filelists/dbg.txt +++ /dev/null @@ -1,1532 +0,0 @@ -makerom -boot -dmadata -Audiobank -Audioseq -Audiotable -link_animetion -icon_item_static -icon_item_24_static -icon_item_field_static -icon_item_dungeon_static -icon_item_gameover_static -icon_item_nes_static -icon_item_ger_static -icon_item_fra_static -item_name_static -map_name_static -do_action_static -message_static -message_texture_static -nes_font_static -nes_message_data_static -ger_message_data_static -fra_message_data_static -staff_message_data_static -map_grand_static -map_i_static -map_48x85_static -code -ovl_title -ovl_select -ovl_opening -ovl_file_choose -ovl_kaleido_scope -ovl_player_actor -ovl_map_mark_data -ovl_En_Test -ovl_Arms_Hook -ovl_Arrow_Fire -ovl_Arrow_Ice -ovl_Arrow_Light -ovl_Bg_Bdan_Objects -ovl_Bg_Bdan_Switch -ovl_Bg_Bom_Guard -ovl_Bg_Bombwall -ovl_Bg_Bowl_Wall -ovl_Bg_Breakwall -ovl_Bg_Ddan_Jd -ovl_Bg_Ddan_Kd -ovl_Bg_Dodoago -ovl_Bg_Dy_Yoseizo -ovl_Bg_Ganon_Otyuka -ovl_Bg_Gate_Shutter -ovl_Bg_Gjyo_Bridge -ovl_Bg_Gnd_Darkmeiro -ovl_Bg_Gnd_Firemeiro -ovl_Bg_Gnd_Iceblock -ovl_Bg_Gnd_Nisekabe -ovl_Bg_Gnd_Soulmeiro -ovl_Bg_Haka -ovl_Bg_Haka_Gate -ovl_Bg_Haka_Huta -ovl_Bg_Haka_Megane -ovl_Bg_Haka_MeganeBG -ovl_Bg_Haka_Sgami -ovl_Bg_Haka_Ship -ovl_Bg_Haka_Trap -ovl_Bg_Haka_Tubo -ovl_Bg_Haka_Water -ovl_Bg_Haka_Zou -ovl_Bg_Heavy_Block -ovl_Bg_Hidan_Curtain -ovl_Bg_Hidan_Dalm -ovl_Bg_Hidan_Firewall -ovl_Bg_Hidan_Fslift -ovl_Bg_Hidan_Fwbig -ovl_Bg_Hidan_Hamstep -ovl_Bg_Hidan_Hrock -ovl_Bg_Hidan_Kousi -ovl_Bg_Hidan_Kowarerukabe -ovl_Bg_Hidan_Rock -ovl_Bg_Hidan_Rsekizou -ovl_Bg_Hidan_Sekizou -ovl_Bg_Hidan_Sima -ovl_Bg_Hidan_Syoku -ovl_Bg_Ice_Objects -ovl_Bg_Ice_Shelter -ovl_Bg_Ice_Shutter -ovl_Bg_Ice_Turara -ovl_Bg_Ingate -ovl_Bg_Jya_1flift -ovl_Bg_Jya_Amishutter -ovl_Bg_Jya_Bigmirror -ovl_Bg_Jya_Block -ovl_Bg_Jya_Bombchuiwa -ovl_Bg_Jya_Bombiwa -ovl_Bg_Jya_Cobra -ovl_Bg_Jya_Goroiwa -ovl_Bg_Jya_Haheniron -ovl_Bg_Jya_Ironobj -ovl_Bg_Jya_Kanaami -ovl_Bg_Jya_Lift -ovl_Bg_Jya_Megami -ovl_Bg_Jya_Zurerukabe -ovl_Bg_Menkuri_Eye -ovl_Bg_Menkuri_Kaiten -ovl_Bg_Menkuri_Nisekabe -ovl_Bg_Mizu_Bwall -ovl_Bg_Mizu_Movebg -ovl_Bg_Mizu_Shutter -ovl_Bg_Mizu_Uzu -ovl_Bg_Mizu_Water -ovl_Bg_Mjin -ovl_Bg_Mori_Bigst -ovl_Bg_Mori_Elevator -ovl_Bg_Mori_Hashigo -ovl_Bg_Mori_Hashira4 -ovl_Bg_Mori_Hineri -ovl_Bg_Mori_Idomizu -ovl_Bg_Mori_Kaitenkabe -ovl_Bg_Mori_Rakkatenjo -ovl_Bg_Po_Event -ovl_Bg_Po_Syokudai -ovl_Bg_Pushbox -ovl_Bg_Relay_Objects -ovl_Bg_Spot00_Break -ovl_Bg_Spot00_Hanebasi -ovl_Bg_Spot01_Fusya -ovl_Bg_Spot01_Idohashira -ovl_Bg_Spot01_Idomizu -ovl_Bg_Spot01_Idosoko -ovl_Bg_Spot01_Objects2 -ovl_Bg_Spot02_Objects -ovl_Bg_Spot03_Taki -ovl_Bg_Spot05_Soko -ovl_Bg_Spot06_Objects -ovl_Bg_Spot07_Taki -ovl_Bg_Spot08_Bakudankabe -ovl_Bg_Spot08_Iceblock -ovl_Bg_Spot09_Obj -ovl_Bg_Spot11_Bakudankabe -ovl_Bg_Spot11_Oasis -ovl_Bg_Spot12_Gate -ovl_Bg_Spot12_Saku -ovl_Bg_Spot15_Rrbox -ovl_Bg_Spot15_Saku -ovl_Bg_Spot16_Bombstone -ovl_Bg_Spot16_Doughnut -ovl_Bg_Spot17_Bakudankabe -ovl_Bg_Spot17_Funen -ovl_Bg_Spot18_Basket -ovl_Bg_Spot18_Futa -ovl_Bg_Spot18_Obj -ovl_Bg_Spot18_Shutter -ovl_Bg_Sst_Floor -ovl_Bg_Toki_Hikari -ovl_Bg_Toki_Swd -ovl_Bg_Treemouth -ovl_Bg_Umajump -ovl_Bg_Vb_Sima -ovl_Bg_Ydan_Hasi -ovl_Bg_Ydan_Maruta -ovl_Bg_Ydan_Sp -ovl_Bg_Zg -ovl_Boss_Dodongo -ovl_Boss_Fd -ovl_Boss_Fd2 -ovl_Boss_Ganon -ovl_Boss_Ganon2 -ovl_Boss_Ganondrof -ovl_Boss_Goma -ovl_Boss_Mo -ovl_Boss_Sst -ovl_Boss_Tw -ovl_Boss_Va -ovl_Demo_6K -ovl_Demo_Du -ovl_Demo_Ec -ovl_Demo_Effect -ovl_Demo_Ext -ovl_Demo_Geff -ovl_Demo_Gj -ovl_Demo_Go -ovl_Demo_Gt -ovl_Demo_Ik -ovl_Demo_Im -ovl_Demo_Kankyo -ovl_Demo_Kekkai -ovl_Demo_Sa -ovl_Demo_Shd -ovl_Demo_Tre_Lgt -ovl_Door_Ana -ovl_Door_Gerudo -ovl_Door_Killer -ovl_Door_Shutter -ovl_Door_Toki -ovl_Door_Warp1 -ovl_Efc_Erupc -ovl_Eff_Dust -ovl_Effect_Ss_Blast -ovl_Effect_Ss_Bomb -ovl_Effect_Ss_Bomb2 -ovl_Effect_Ss_Bubble -ovl_Effect_Ss_D_Fire -ovl_Effect_Ss_Dead_Db -ovl_Effect_Ss_Dead_Dd -ovl_Effect_Ss_Dead_Ds -ovl_Effect_Ss_Dead_Sound -ovl_Effect_Ss_Dt_Bubble -ovl_Effect_Ss_Dust -ovl_Effect_Ss_En_Fire -ovl_Effect_Ss_En_Ice -ovl_Effect_Ss_Extra -ovl_Effect_Ss_Fcircle -ovl_Effect_Ss_Fhg_Flash -ovl_Effect_Ss_Fire_Tail -ovl_Effect_Ss_G_Fire -ovl_Effect_Ss_G_Magma -ovl_Effect_Ss_G_Magma2 -ovl_Effect_Ss_G_Ripple -ovl_Effect_Ss_G_Spk -ovl_Effect_Ss_G_Splash -ovl_Effect_Ss_Hahen -ovl_Effect_Ss_HitMark -ovl_Effect_Ss_Ice_Piece -ovl_Effect_Ss_Ice_Smoke -ovl_Effect_Ss_K_Fire -ovl_Effect_Ss_Kakera -ovl_Effect_Ss_KiraKira -ovl_Effect_Ss_Lightning -ovl_Effect_Ss_Sibuki -ovl_Effect_Ss_Sibuki2 -ovl_Effect_Ss_Solder_Srch_Ball -ovl_Effect_Ss_Stick -ovl_Effect_Ss_Stone1 -ovl_Elf_Msg -ovl_Elf_Msg2 -ovl_En_Am -ovl_En_Ani -ovl_En_Anubice -ovl_En_Anubice_Fire -ovl_En_Anubice_Tag -ovl_En_Arow_Trap -ovl_En_Arrow -ovl_En_Attack_Niw -ovl_En_Ba -ovl_En_Bb -ovl_En_Bdfire -ovl_En_Bigokuta -ovl_En_Bili -ovl_En_Bird -ovl_En_Blkobj -ovl_En_Bom -ovl_En_Bom_Bowl_Man -ovl_En_Bom_Bowl_Pit -ovl_En_Bom_Chu -ovl_En_Bombf -ovl_En_Boom -ovl_En_Box -ovl_En_Brob -ovl_En_Bubble -ovl_En_Butte -ovl_En_Bw -ovl_En_Bx -ovl_En_Changer -ovl_En_Clear_Tag -ovl_En_Cow -ovl_En_Crow -ovl_En_Cs -ovl_En_Daiku -ovl_En_Daiku_Kakariko -ovl_En_Dekubaba -ovl_En_Dekunuts -ovl_En_Dh -ovl_En_Dha -ovl_En_Diving_Game -ovl_En_Dns -ovl_En_Dnt_Demo -ovl_En_Dnt_Jiji -ovl_En_Dnt_Nomal -ovl_En_Dodojr -ovl_En_Dodongo -ovl_En_Dog -ovl_En_Door -ovl_En_Ds -ovl_En_Du -ovl_En_Dy_Extra -ovl_En_Eg -ovl_En_Eiyer -ovl_En_Elf -ovl_En_Encount1 -ovl_En_Encount2 -ovl_En_Ex_Item -ovl_En_Ex_Ruppy -ovl_En_Fd -ovl_En_Fd_Fire -ovl_En_Fhg_Fire -ovl_En_Fire_Rock -ovl_En_Firefly -ovl_En_Fish -ovl_En_Floormas -ovl_En_Fr -ovl_En_Fu -ovl_En_Fw -ovl_En_Fz -ovl_En_G_Switch -ovl_En_Ganon_Mant -ovl_En_Ganon_Organ -ovl_En_Gb -ovl_En_Ge1 -ovl_En_Ge2 -ovl_En_Ge3 -ovl_En_GeldB -ovl_En_GirlA -ovl_En_Gm -ovl_En_Go -ovl_En_Go2 -ovl_En_Goma -ovl_En_Goroiwa -ovl_En_Gs -ovl_En_Guest -ovl_En_Hata -ovl_En_Heishi1 -ovl_En_Heishi2 -ovl_En_Heishi3 -ovl_En_Heishi4 -ovl_En_Hintnuts -ovl_En_Holl -ovl_En_Honotrap -ovl_En_Horse -ovl_En_Horse_Game_Check -ovl_En_Horse_Ganon -ovl_En_Horse_Link_Child -ovl_En_Horse_Normal -ovl_En_Horse_Zelda -ovl_En_Hs -ovl_En_Hs2 -ovl_En_Hy -ovl_En_Ice_Hono -ovl_En_Ik -ovl_En_In -ovl_En_Insect -ovl_En_Ishi -ovl_En_It -ovl_En_Jj -ovl_En_Js -ovl_En_Jsjutan -ovl_En_Kakasi -ovl_En_Kakasi2 -ovl_En_Kakasi3 -ovl_En_Kanban -ovl_En_Karebaba -ovl_En_Ko -ovl_En_Kusa -ovl_En_Kz -ovl_En_Light -ovl_En_Lightbox -ovl_En_M_Fire1 -ovl_En_M_Thunder -ovl_En_Ma1 -ovl_En_Ma2 -ovl_En_Ma3 -ovl_En_Mag -ovl_En_Mb -ovl_En_Md -ovl_En_Mk -ovl_En_Mm -ovl_En_Mm2 -ovl_En_Ms -ovl_En_Mu -ovl_En_Nb -ovl_En_Niw -ovl_En_Niw_Girl -ovl_En_Niw_Lady -ovl_En_Nutsball -ovl_En_Nwc -ovl_En_Ny -ovl_En_OE2 -ovl_En_Okarina_Effect -ovl_En_Okarina_Tag -ovl_En_Okuta -ovl_En_Ossan -ovl_En_Owl -ovl_En_Part -ovl_En_Peehat -ovl_En_Po_Desert -ovl_En_Po_Field -ovl_En_Po_Relay -ovl_En_Po_Sisters -ovl_En_Poh -ovl_En_Pu_box -ovl_En_Rd -ovl_En_Reeba -ovl_En_River_Sound -ovl_En_Rl -ovl_En_Rr -ovl_En_Ru1 -ovl_En_Ru2 -ovl_En_Sa -ovl_En_Sb -ovl_En_Scene_Change -ovl_En_Sda -ovl_En_Shopnuts -ovl_En_Si -ovl_En_Siofuki -ovl_En_Skb -ovl_En_Skj -ovl_En_Skjneedle -ovl_En_Ssh -ovl_En_St -ovl_En_Sth -ovl_En_Stream -ovl_En_Sw -ovl_En_Syateki_Itm -ovl_En_Syateki_Man -ovl_En_Syateki_Niw -ovl_En_Ta -ovl_En_Takara_Man -ovl_En_Tana -ovl_En_Tg -ovl_En_Tite -ovl_En_Tk -ovl_En_Torch -ovl_En_Torch2 -ovl_En_Toryo -ovl_En_Tp -ovl_En_Tr -ovl_En_Trap -ovl_En_Tubo_Trap -ovl_En_Vali -ovl_En_Vase -ovl_En_Vb_Ball -ovl_En_Viewer -ovl_En_Vm -ovl_En_Wall_Tubo -ovl_En_Wallmas -ovl_En_Weather_Tag -ovl_En_Weiyer -ovl_En_Wf -ovl_En_Wonder_Item -ovl_En_Wonder_Talk -ovl_En_Wonder_Talk2 -ovl_En_Wood02 -ovl_En_Xc -ovl_En_Yabusame_Mark -ovl_En_Yukabyun -ovl_En_Zf -ovl_En_Zl1 -ovl_En_Zl2 -ovl_En_Zl3 -ovl_En_Zl4 -ovl_En_Zo -ovl_En_fHG -ovl_End_Title -ovl_Fishing -ovl_Item_B_Heart -ovl_Item_Etcetera -ovl_Item_Inbox -ovl_Item_Ocarina -ovl_Item_Shield -ovl_Magic_Dark -ovl_Magic_Fire -ovl_Magic_Wind -ovl_Mir_Ray -ovl_Obj_Bean -ovl_Obj_Blockstop -ovl_Obj_Bombiwa -ovl_Obj_Comb -ovl_Obj_Dekujr -ovl_Obj_Elevator -ovl_Obj_Hamishi -ovl_Obj_Hana -ovl_Obj_Hsblock -ovl_Obj_Ice_Poly -ovl_Obj_Kibako -ovl_Obj_Kibako2 -ovl_Obj_Lift -ovl_Obj_Lightswitch -ovl_Obj_Makekinsuta -ovl_Obj_Makeoshihiki -ovl_Obj_Mure -ovl_Obj_Mure2 -ovl_Obj_Mure3 -ovl_Obj_Oshihiki -ovl_Obj_Roomtimer -ovl_Obj_Switch -ovl_Obj_Syokudai -ovl_Obj_Timeblock -ovl_Obj_Tsubo -ovl_Obj_Warp2block -ovl_Object_Kankyo -ovl_Oceff_Spot -ovl_Oceff_Storm -ovl_Oceff_Wipe -ovl_Oceff_Wipe2 -ovl_Oceff_Wipe3 -ovl_Oceff_Wipe4 -ovl_Shot_Sun -gameplay_keep -gameplay_field_keep -gameplay_dangeon_keep -gameplay_object_exchange_static -object_link_boy -object_link_child -object_box -object_human -object_okuta -object_poh -object_wallmaster -object_dy_obj -object_firefly -object_dodongo -object_fire -object_niw -object_tite -object_reeba -object_peehat -object_kingdodongo -object_horse -object_zf -object_goma -object_zl1 -object_gol -object_bubble -object_dodojr -object_torch2 -object_bl -object_tp -object_oA1 -object_st -object_bw -object_ei -object_horse_normal -object_oB1 -object_o_anime -object_spot04_objects -object_ddan_objects -object_hidan_objects -object_horse_ganon -object_oA2 -object_spot00_objects -object_mb -object_bombf -object_sk2 -object_oE1 -object_oE_anime -object_oE2 -object_ydan_objects -object_gnd -object_am -object_dekubaba -object_oA3 -object_oA4 -object_oA5 -object_oA6 -object_oA7 -object_jj -object_oA8 -object_oA9 -object_oB2 -object_oB3 -object_oB4 -object_horse_zelda -object_opening_demo1 -object_warp1 -object_b_heart -object_dekunuts -object_oE3 -object_oE4 -object_menkuri_objects -object_oE5 -object_oE6 -object_oE7 -object_oE8 -object_oE9 -object_oE10 -object_oE11 -object_oE12 -object_vali -object_oA10 -object_oA11 -object_mizu_objects -object_fhg -object_ossan -object_mori_hineri1 -object_Bb -object_toki_objects -object_yukabyun -object_zl2 -object_mjin -object_mjin_flash -object_mjin_dark -object_mjin_flame -object_mjin_ice -object_mjin_soul -object_mjin_wind -object_mjin_oka -object_haka_objects -object_spot06_objects -object_ice_objects -object_relay_objects -object_mori_hineri1a -object_mori_hineri2 -object_mori_hineri2a -object_mori_objects -object_mori_tex -object_spot08_obj -object_warp2 -object_hata -object_bird -object_wood02 -object_lightbox -object_pu_box -object_trap -object_vase -object_im -object_ta -object_tk -object_xc -object_vm -object_bv -object_hakach_objects -object_efc_crystal_light -object_efc_fire_ball -object_efc_flash -object_efc_lgt_shower -object_efc_star_field -object_god_lgt -object_light_ring -object_triforce_spot -object_medal -object_bdan_objects -object_sd -object_rd -object_po_sisters -object_heavy_object -object_gndd -object_fd -object_du -object_fw -object_horse_link_child -object_spot02_objects -object_haka -object_ru1 -object_syokudai -object_fd2 -object_dh -object_rl -object_efc_tw -object_demo_tre_lgt -object_gi_key -object_mir_ray -object_brob -object_gi_jewel -object_spot09_obj -object_spot18_obj -object_bdoor -object_spot17_obj -object_shop_dungen -object_nb -object_mo -object_sb -object_gi_melody -object_gi_heart -object_gi_compass -object_gi_bosskey -object_gi_medal -object_gi_nuts -object_sa -object_gi_hearts -object_gi_arrowcase -object_gi_bombpouch -object_in -object_tr -object_spot16_obj -object_oE1s -object_oE4s -object_os_anime -object_gi_bottle -object_gi_stick -object_gi_map -object_oF1d_map -object_ru2 -object_gi_shield_1 -object_dekujr -object_gi_magicpot -object_gi_bomb_1 -object_oF1s -object_ma2 -object_gi_purse -object_hni -object_tw -object_rr -object_bxa -object_anubice -object_gi_gerudo -object_gi_arrow -object_gi_bomb_2 -object_gi_egg -object_gi_scale -object_gi_shield_2 -object_gi_hookshot -object_gi_ocarina -object_gi_milk -object_ma1 -object_ganon -object_sst -object_ny -object_fr -object_gi_pachinko -object_gi_boomerang -object_gi_bow -object_gi_glasses -object_gi_liquid -object_ani -object_demo_6k -object_gi_shield_3 -object_gi_letter -object_spot15_obj -object_jya_obj -object_gi_clothes -object_gi_bean -object_gi_fish -object_gi_saw -object_gi_hammer -object_gi_grass -object_gi_longsword -object_spot01_objects -object_md -object_km1 -object_kw1 -object_zo -object_kz -object_umajump -object_masterkokiri -object_masterkokirihead -object_mastergolon -object_masterzoora -object_aob -object_ik -object_ahg -object_cne -object_gi_niwatori -object_skj -object_gi_bottle_letter -object_bji -object_bba -object_gi_ocarina_0 -object_ds -object_ane -object_boj -object_spot03_object -object_spot07_object -object_fz -object_bob -object_ge1 -object_yabusame_point -object_gi_boots_2 -object_gi_seed -object_gnd_magic -object_d_elevator -object_d_hsblock -object_d_lift -object_mamenoki -object_goroiwa -object_toryo -object_daiku -object_nwc -object_blkobj -object_gm -object_ms -object_hs -object_ingate -object_lightswitch -object_kusa -object_tsubo -object_gi_gloves -object_gi_coin -object_kanban -object_gjyo_objects -object_owl -object_mk -object_fu -object_gi_ki_tan_mask -object_gi_redead_mask -object_gi_skj_mask -object_gi_rabit_mask -object_gi_truth_mask -object_ganon_objects -object_siofuki -object_stream -object_mm -object_fa -object_os -object_gi_eye_lotion -object_gi_powder -object_gi_mushroom -object_gi_ticketstone -object_gi_brokensword -object_js -object_cs -object_gi_prescription -object_gi_bracelet -object_gi_soldout -object_gi_frog -object_mag -object_door_gerudo -object_gt -object_efc_erupc -object_zl2_anime1 -object_zl2_anime2 -object_gi_golonmask -object_gi_zoramask -object_gi_gerudomask -object_ganon2 -object_ka -object_ts -object_zg -object_gi_hoverboots -object_gi_m_arrow -object_ds2 -object_ec -object_fish -object_gi_sutaru -object_gi_goddess -object_ssh -object_bigokuta -object_bg -object_spot05_objects -object_spot12_obj -object_bombiwa -object_hintnuts -object_rs -object_spot00_break -object_gla -object_shopnuts -object_geldb -object_gr -object_dog -object_jya_iron -object_jya_door -object_spot01_objects2 -object_spot11_obj -object_kibako2 -object_dns -object_dnk -object_gi_fire -object_gi_insect -object_gi_butterfly -object_gi_ghost -object_gi_soul -object_bowl -object_po_field -object_demo_kekkai -object_efc_doughnut -object_gi_dekupouch -object_ganon_anime1 -object_ganon_anime2 -object_ganon_anime3 -object_gi_rupy -object_spot01_matoya -object_spot01_matoyab -object_po_composer -object_mu -object_wf -object_skb -object_gj -object_geff -object_haka_door -object_gs -object_ps -object_bwall -object_crow -object_cow -object_cob -object_gi_sword_1 -object_door_killer -object_ouke_haka -object_timeblock -object_zl4 -g_pn_01 -g_pn_02 -g_pn_03 -g_pn_04 -g_pn_05 -g_pn_06 -g_pn_07 -g_pn_08 -g_pn_09 -g_pn_10 -g_pn_11 -g_pn_12 -g_pn_13 -g_pn_14 -g_pn_15 -g_pn_16 -g_pn_17 -g_pn_18 -g_pn_19 -g_pn_20 -g_pn_21 -g_pn_22 -g_pn_23 -g_pn_24 -g_pn_25 -g_pn_26 -g_pn_27 -g_pn_28 -g_pn_29 -g_pn_30 -g_pn_31 -g_pn_32 -g_pn_33 -g_pn_34 -g_pn_35 -g_pn_36 -g_pn_37 -g_pn_38 -g_pn_39 -g_pn_40 -g_pn_41 -g_pn_42 -g_pn_43 -g_pn_44 -g_pn_45 -g_pn_46 -g_pn_47 -g_pn_48 -g_pn_49 -g_pn_50 -g_pn_51 -g_pn_52 -g_pn_53 -g_pn_54 -g_pn_55 -g_pn_56 -g_pn_57 -z_select_static -nintendo_rogo_static -title_static -parameter_static -vr_fine0_static -vr_fine0_pal_static -vr_fine1_static -vr_fine1_pal_static -vr_fine2_static -vr_fine2_pal_static -vr_fine3_static -vr_fine3_pal_static -vr_cloud0_static -vr_cloud0_pal_static -vr_cloud1_static -vr_cloud1_pal_static -vr_cloud2_static -vr_cloud2_pal_static -vr_cloud3_static -vr_cloud3_pal_static -vr_holy0_static -vr_holy0_pal_static -vr_holy1_static -vr_holy1_pal_static -vr_MDVR_static -vr_MDVR_pal_static -vr_MNVR_static -vr_MNVR_pal_static -vr_RUVR_static -vr_RUVR_pal_static -vr_LHVR_static -vr_LHVR_pal_static -vr_KHVR_static -vr_KHVR_pal_static -vr_K3VR_static -vr_K3VR_pal_static -vr_K4VR_static -vr_K4VR_pal_static -vr_K5VR_static -vr_K5VR_pal_static -vr_SP1a_static -vr_SP1a_pal_static -vr_MLVR_static -vr_MLVR_pal_static -vr_KKRVR_static -vr_KKRVR_pal_static -vr_KR3VR_static -vr_KR3VR_pal_static -vr_IPVR_static -vr_IPVR_pal_static -vr_KSVR_static -vr_KSVR_pal_static -vr_GLVR_static -vr_GLVR_pal_static -vr_ZRVR_static -vr_ZRVR_pal_static -vr_DGVR_static -vr_DGVR_pal_static -vr_ALVR_static -vr_ALVR_pal_static -vr_NSVR_static -vr_NSVR_pal_static -vr_LBVR_static -vr_LBVR_pal_static -vr_TTVR_static -vr_TTVR_pal_static -vr_FCVR_static -vr_FCVR_pal_static -elf_message_field -elf_message_ydan -syotes_scene -syotes_room_0 -syotes2_scene -syotes2_room_0 -depth_test_scene -depth_test_room_0 -spot00_scene -spot00_room_0 -spot01_scene -spot01_room_0 -spot02_scene -spot02_room_0 -spot02_room_1 -spot03_scene -spot03_room_0 -spot03_room_1 -spot04_scene -spot04_room_0 -spot04_room_1 -spot04_room_2 -spot05_scene -spot05_room_0 -spot06_scene -spot06_room_0 -spot07_scene -spot07_room_0 -spot07_room_1 -spot08_scene -spot08_room_0 -spot09_scene -spot09_room_0 -spot10_scene -spot10_room_0 -spot10_room_1 -spot10_room_2 -spot10_room_3 -spot10_room_4 -spot10_room_5 -spot10_room_6 -spot10_room_7 -spot10_room_8 -spot10_room_9 -spot11_scene -spot11_room_0 -spot12_scene -spot12_room_0 -spot12_room_1 -spot13_scene -spot13_room_0 -spot13_room_1 -spot15_scene -spot15_room_0 -spot16_scene -spot16_room_0 -spot17_scene -spot17_room_0 -spot17_room_1 -spot18_scene -spot18_room_0 -spot18_room_1 -spot18_room_2 -spot18_room_3 -ydan_scene -ydan_room_0 -ydan_room_1 -ydan_room_2 -ydan_room_3 -ydan_room_4 -ydan_room_5 -ydan_room_6 -ydan_room_7 -ydan_room_8 -ydan_room_9 -ydan_room_10 -ydan_room_11 -ddan_scene -ddan_room_0 -ddan_room_1 -ddan_room_2 -ddan_room_3 -ddan_room_4 -ddan_room_5 -ddan_room_6 -ddan_room_7 -ddan_room_8 -ddan_room_9 -ddan_room_10 -ddan_room_11 -ddan_room_12 -ddan_room_13 -ddan_room_14 -ddan_room_15 -ddan_room_16 -bdan_scene -bdan_room_0 -bdan_room_1 -bdan_room_2 -bdan_room_3 -bdan_room_4 -bdan_room_5 -bdan_room_6 -bdan_room_7 -bdan_room_8 -bdan_room_9 -bdan_room_10 -bdan_room_11 -bdan_room_12 -bdan_room_13 -bdan_room_14 -bdan_room_15 -Bmori1_scene -Bmori1_room_0 -Bmori1_room_1 -Bmori1_room_2 -Bmori1_room_3 -Bmori1_room_4 -Bmori1_room_5 -Bmori1_room_6 -Bmori1_room_7 -Bmori1_room_8 -Bmori1_room_9 -Bmori1_room_10 -Bmori1_room_11 -Bmori1_room_12 -Bmori1_room_13 -Bmori1_room_14 -Bmori1_room_15 -Bmori1_room_16 -Bmori1_room_17 -Bmori1_room_18 -Bmori1_room_19 -Bmori1_room_20 -Bmori1_room_21 -Bmori1_room_22 -HIDAN_scene -HIDAN_room_0 -HIDAN_room_1 -HIDAN_room_2 -HIDAN_room_3 -HIDAN_room_4 -HIDAN_room_5 -HIDAN_room_6 -HIDAN_room_7 -HIDAN_room_8 -HIDAN_room_9 -HIDAN_room_10 -HIDAN_room_11 -HIDAN_room_12 -HIDAN_room_13 -HIDAN_room_14 -HIDAN_room_15 -HIDAN_room_16 -HIDAN_room_17 -HIDAN_room_18 -HIDAN_room_19 -HIDAN_room_20 -HIDAN_room_21 -HIDAN_room_22 -HIDAN_room_23 -HIDAN_room_24 -HIDAN_room_25 -HIDAN_room_26 -MIZUsin_scene -MIZUsin_room_0 -MIZUsin_room_1 -MIZUsin_room_2 -MIZUsin_room_3 -MIZUsin_room_4 -MIZUsin_room_5 -MIZUsin_room_6 -MIZUsin_room_7 -MIZUsin_room_8 -MIZUsin_room_9 -MIZUsin_room_10 -MIZUsin_room_11 -MIZUsin_room_12 -MIZUsin_room_13 -MIZUsin_room_14 -MIZUsin_room_15 -MIZUsin_room_16 -MIZUsin_room_17 -MIZUsin_room_18 -MIZUsin_room_19 -MIZUsin_room_20 -MIZUsin_room_21 -MIZUsin_room_22 -jyasinzou_scene -jyasinzou_room_0 -jyasinzou_room_1 -jyasinzou_room_2 -jyasinzou_room_3 -jyasinzou_room_4 -jyasinzou_room_5 -jyasinzou_room_6 -jyasinzou_room_7 -jyasinzou_room_8 -jyasinzou_room_9 -jyasinzou_room_10 -jyasinzou_room_11 -jyasinzou_room_12 -jyasinzou_room_13 -jyasinzou_room_14 -jyasinzou_room_15 -jyasinzou_room_16 -jyasinzou_room_17 -jyasinzou_room_18 -jyasinzou_room_19 -jyasinzou_room_20 -jyasinzou_room_21 -jyasinzou_room_22 -jyasinzou_room_23 -jyasinzou_room_24 -jyasinzou_room_25 -jyasinzou_room_26 -jyasinzou_room_27 -jyasinzou_room_28 -HAKAdan_scene -HAKAdan_room_0 -HAKAdan_room_1 -HAKAdan_room_2 -HAKAdan_room_3 -HAKAdan_room_4 -HAKAdan_room_5 -HAKAdan_room_6 -HAKAdan_room_7 -HAKAdan_room_8 -HAKAdan_room_9 -HAKAdan_room_10 -HAKAdan_room_11 -HAKAdan_room_12 -HAKAdan_room_13 -HAKAdan_room_14 -HAKAdan_room_15 -HAKAdan_room_16 -HAKAdan_room_17 -HAKAdan_room_18 -HAKAdan_room_19 -HAKAdan_room_20 -HAKAdan_room_21 -HAKAdan_room_22 -HAKAdanCH_scene -HAKAdanCH_room_0 -HAKAdanCH_room_1 -HAKAdanCH_room_2 -HAKAdanCH_room_3 -HAKAdanCH_room_4 -HAKAdanCH_room_5 -HAKAdanCH_room_6 -ice_doukutu_scene -ice_doukutu_room_0 -ice_doukutu_room_1 -ice_doukutu_room_2 -ice_doukutu_room_3 -ice_doukutu_room_4 -ice_doukutu_room_5 -ice_doukutu_room_6 -ice_doukutu_room_7 -ice_doukutu_room_8 -ice_doukutu_room_9 -ice_doukutu_room_10 -ice_doukutu_room_11 -men_scene -men_room_0 -men_room_1 -men_room_2 -men_room_3 -men_room_4 -men_room_5 -men_room_6 -men_room_7 -men_room_8 -men_room_9 -men_room_10 -ganontika_scene -ganontika_room_0 -ganontika_room_1 -ganontika_room_2 -ganontika_room_3 -ganontika_room_4 -ganontika_room_5 -ganontika_room_6 -ganontika_room_7 -ganontika_room_8 -ganontika_room_9 -ganontika_room_10 -ganontika_room_11 -ganontika_room_12 -ganontika_room_13 -ganontika_room_14 -ganontika_room_15 -ganontika_room_16 -ganontika_room_17 -ganontika_room_18 -ganontika_room_19 -market_day_scene -market_day_room_0 -market_night_scene -market_night_room_0 -testroom_scene -testroom_room_0 -testroom_room_1 -testroom_room_2 -testroom_room_3 -testroom_room_4 -kenjyanoma_scene -kenjyanoma_room_0 -tokinoma_scene -tokinoma_room_0 -tokinoma_room_1 -sutaru_scene -sutaru_room_0 -link_home_scene -link_home_room_0 -kokiri_shop_scene -kokiri_shop_room_0 -kokiri_home_scene -kokiri_home_room_0 -kakusiana_scene -kakusiana_room_0 -kakusiana_room_1 -kakusiana_room_2 -kakusiana_room_3 -kakusiana_room_4 -kakusiana_room_5 -kakusiana_room_6 -kakusiana_room_7 -kakusiana_room_8 -kakusiana_room_9 -kakusiana_room_10 -kakusiana_room_11 -kakusiana_room_12 -kakusiana_room_13 -entra_scene -entra_room_0 -moribossroom_scene -moribossroom_room_0 -moribossroom_room_1 -syatekijyou_scene -syatekijyou_room_0 -shop1_scene -shop1_room_0 -hairal_niwa_scene -hairal_niwa_room_0 -ganon_tou_scene -ganon_tou_room_0 -sasatest_scene -sasatest_room_0 -market_alley_scene -market_alley_room_0 -spot20_scene -spot20_room_0 -market_ruins_scene -market_ruins_room_0 -entra_n_scene -entra_n_room_0 -enrui_scene -enrui_room_0 -market_alley_n_scene -market_alley_n_room_0 -hiral_demo_scene -hiral_demo_room_0 -kokiri_home3_scene -kokiri_home3_room_0 -malon_stable_scene -malon_stable_room_0 -kakariko_scene -kakariko_room_0 -bdan_boss_scene -bdan_boss_room_0 -bdan_boss_room_1 -FIRE_bs_scene -FIRE_bs_room_0 -FIRE_bs_room_1 -hut_scene -hut_room_0 -daiyousei_izumi_scene -daiyousei_izumi_room_0 -hakaana_scene -hakaana_room_0 -yousei_izumi_tate_scene -yousei_izumi_tate_room_0 -yousei_izumi_yoko_scene -yousei_izumi_yoko_room_0 -golon_scene -golon_room_0 -zoora_scene -zoora_room_0 -drag_scene -drag_room_0 -alley_shop_scene -alley_shop_room_0 -night_shop_scene -night_shop_room_0 -impa_scene -impa_room_0 -labo_scene -labo_room_0 -tent_scene -tent_room_0 -nakaniwa_scene -nakaniwa_room_0 -ddan_boss_scene -ddan_boss_room_0 -ddan_boss_room_1 -ydan_boss_scene -ydan_boss_room_0 -ydan_boss_room_1 -HAKAdan_bs_scene -HAKAdan_bs_room_0 -HAKAdan_bs_room_1 -MIZUsin_bs_scene -MIZUsin_bs_room_0 -MIZUsin_bs_room_1 -ganon_scene -ganon_room_0 -ganon_room_1 -ganon_room_2 -ganon_room_3 -ganon_room_4 -ganon_room_5 -ganon_room_6 -ganon_room_7 -ganon_room_8 -ganon_room_9 -ganon_boss_scene -ganon_boss_room_0 -jyasinboss_scene -jyasinboss_room_0 -jyasinboss_room_1 -jyasinboss_room_2 -jyasinboss_room_3 -kokiri_home4_scene -kokiri_home4_room_0 -kokiri_home5_scene -kokiri_home5_room_0 -ganon_final_scene -ganon_final_room_0 -kakariko3_scene -kakariko3_room_0 -hairal_niwa2_scene -hairal_niwa2_room_0 -hakasitarelay_scene -hakasitarelay_room_0 -hakasitarelay_room_1 -hakasitarelay_room_2 -hakasitarelay_room_3 -hakasitarelay_room_4 -hakasitarelay_room_5 -hakasitarelay_room_6 -shrine_scene -shrine_room_0 -turibori_scene -turibori_room_0 -shrine_n_scene -shrine_n_room_0 -shrine_r_scene -shrine_r_room_0 -hakaana2_scene -hakaana2_room_0 -gerudoway_scene -gerudoway_room_0 -gerudoway_room_1 -gerudoway_room_2 -gerudoway_room_3 -gerudoway_room_4 -gerudoway_room_5 -hairal_niwa_n_scene -hairal_niwa_n_room_0 -bowling_scene -bowling_room_0 -hakaana_ouke_scene -hakaana_ouke_room_0 -hakaana_ouke_room_1 -hakaana_ouke_room_2 -hylia_labo_scene -hylia_labo_room_0 -souko_scene -souko_room_0 -souko_room_1 -souko_room_2 -miharigoya_scene -miharigoya_room_0 -mahouya_scene -mahouya_room_0 -takaraya_scene -takaraya_room_0 -takaraya_room_1 -takaraya_room_2 -takaraya_room_3 -takaraya_room_4 -takaraya_room_5 -takaraya_room_6 -ganon_sonogo_scene -ganon_sonogo_room_0 -ganon_sonogo_room_1 -ganon_sonogo_room_2 -ganon_sonogo_room_3 -ganon_sonogo_room_4 -ganon_demo_scene -ganon_demo_room_0 -besitu_scene -besitu_room_0 -face_shop_scene -face_shop_room_0 -kinsuta_scene -kinsuta_room_0 -ganontikasonogo_scene -ganontikasonogo_room_0 -ganontikasonogo_room_1 -test01_scene -test01_room_0 -bump_texture_static -anime_model_1_static -anime_model_2_static -anime_model_3_static -anime_model_4_static -anime_model_5_static -anime_model_6_static -anime_texture_1_static -anime_texture_2_static -anime_texture_3_static -anime_texture_4_static -anime_texture_5_static -anime_texture_6_static -softsprite_matrix_static \ No newline at end of file diff --git a/OTRExporter/CFG/filelists/gamecube.txt b/OTRExporter/CFG/filelists/gamecube.txt deleted file mode 100644 index 23794e1f6..000000000 --- a/OTRExporter/CFG/filelists/gamecube.txt +++ /dev/null @@ -1,1509 +0,0 @@ -makerom -boot -dmadata -Audiobank -Audioseq -Audiotable -kanji -link_animetion -icon_item_static -icon_item_24_static -icon_item_field_static -icon_item_dungeon_static -icon_item_gameover_static -icon_item_jpn_static -icon_item_nes_static -item_name_static -map_name_static -do_action_static -message_static -message_texture_static -nes_font_static -jpn_message_data_static -nes_message_data_static -staff_message_data_static -map_grand_static -map_48x85_static -map_i_static -code -ovl_title -ovl_select -ovl_opening -ovl_file_choose -ovl_kaleido_scope -ovl_player_actor -ovl_map_mark_data -ovl_En_Test -ovl_Arms_Hook -ovl_Arrow_Fire -ovl_Arrow_Ice -ovl_Arrow_Light -ovl_Bg_Bdan_Objects -ovl_Bg_Bdan_Switch -ovl_Bg_Bom_Guard -ovl_Bg_Bombwall -ovl_Bg_Bowl_Wall -ovl_Bg_Breakwall -ovl_Bg_Ddan_Jd -ovl_Bg_Ddan_Kd -ovl_Bg_Dodoago -ovl_Bg_Dy_Yoseizo -ovl_Bg_Ganon_Otyuka -ovl_Bg_Gate_Shutter -ovl_Bg_Gjyo_Bridge -ovl_Bg_Gnd_Darkmeiro -ovl_Bg_Gnd_Firemeiro -ovl_Bg_Gnd_Iceblock -ovl_Bg_Gnd_Nisekabe -ovl_Bg_Gnd_Soulmeiro -ovl_Bg_Haka -ovl_Bg_Haka_Gate -ovl_Bg_Haka_Huta -ovl_Bg_Haka_Megane -ovl_Bg_Haka_MeganeBG -ovl_Bg_Haka_Sgami -ovl_Bg_Haka_Ship -ovl_Bg_Haka_Trap -ovl_Bg_Haka_Tubo -ovl_Bg_Haka_Water -ovl_Bg_Haka_Zou -ovl_Bg_Heavy_Block -ovl_Bg_Hidan_Curtain -ovl_Bg_Hidan_Dalm -ovl_Bg_Hidan_Firewall -ovl_Bg_Hidan_Fslift -ovl_Bg_Hidan_Fwbig -ovl_Bg_Hidan_Hamstep -ovl_Bg_Hidan_Hrock -ovl_Bg_Hidan_Kousi -ovl_Bg_Hidan_Kowarerukabe -ovl_Bg_Hidan_Rock -ovl_Bg_Hidan_Rsekizou -ovl_Bg_Hidan_Sekizou -ovl_Bg_Hidan_Sima -ovl_Bg_Hidan_Syoku -ovl_Bg_Ice_Objects -ovl_Bg_Ice_Shelter -ovl_Bg_Ice_Shutter -ovl_Bg_Ice_Turara -ovl_Bg_Ingate -ovl_Bg_Jya_1flift -ovl_Bg_Jya_Amishutter -ovl_Bg_Jya_Bigmirror -ovl_Bg_Jya_Block -ovl_Bg_Jya_Bombchuiwa -ovl_Bg_Jya_Bombiwa -ovl_Bg_Jya_Cobra -ovl_Bg_Jya_Goroiwa -ovl_Bg_Jya_Haheniron -ovl_Bg_Jya_Ironobj -ovl_Bg_Jya_Kanaami -ovl_Bg_Jya_Lift -ovl_Bg_Jya_Megami -ovl_Bg_Jya_Zurerukabe -ovl_Bg_Menkuri_Eye -ovl_Bg_Menkuri_Kaiten -ovl_Bg_Menkuri_Nisekabe -ovl_Bg_Mizu_Bwall -ovl_Bg_Mizu_Movebg -ovl_Bg_Mizu_Shutter -ovl_Bg_Mizu_Uzu -ovl_Bg_Mizu_Water -ovl_Bg_Mjin -ovl_Bg_Mori_Bigst -ovl_Bg_Mori_Elevator -ovl_Bg_Mori_Hashigo -ovl_Bg_Mori_Hashira4 -ovl_Bg_Mori_Hineri -ovl_Bg_Mori_Idomizu -ovl_Bg_Mori_Kaitenkabe -ovl_Bg_Mori_Rakkatenjo -ovl_Bg_Po_Event -ovl_Bg_Po_Syokudai -ovl_Bg_Pushbox -ovl_Bg_Relay_Objects -ovl_Bg_Spot00_Break -ovl_Bg_Spot00_Hanebasi -ovl_Bg_Spot01_Fusya -ovl_Bg_Spot01_Idohashira -ovl_Bg_Spot01_Idomizu -ovl_Bg_Spot01_Idosoko -ovl_Bg_Spot01_Objects2 -ovl_Bg_Spot02_Objects -ovl_Bg_Spot03_Taki -ovl_Bg_Spot05_Soko -ovl_Bg_Spot06_Objects -ovl_Bg_Spot07_Taki -ovl_Bg_Spot08_Bakudankabe -ovl_Bg_Spot08_Iceblock -ovl_Bg_Spot09_Obj -ovl_Bg_Spot11_Bakudankabe -ovl_Bg_Spot11_Oasis -ovl_Bg_Spot12_Gate -ovl_Bg_Spot12_Saku -ovl_Bg_Spot15_Rrbox -ovl_Bg_Spot15_Saku -ovl_Bg_Spot16_Bombstone -ovl_Bg_Spot16_Doughnut -ovl_Bg_Spot17_Bakudankabe -ovl_Bg_Spot17_Funen -ovl_Bg_Spot18_Basket -ovl_Bg_Spot18_Futa -ovl_Bg_Spot18_Obj -ovl_Bg_Spot18_Shutter -ovl_Bg_Sst_Floor -ovl_Bg_Toki_Hikari -ovl_Bg_Toki_Swd -ovl_Bg_Treemouth -ovl_Bg_Umajump -ovl_Bg_Vb_Sima -ovl_Bg_Ydan_Hasi -ovl_Bg_Ydan_Maruta -ovl_Bg_Ydan_Sp -ovl_Bg_Zg -ovl_Boss_Dodongo -ovl_Boss_Fd -ovl_Boss_Fd2 -ovl_Boss_Ganon -ovl_Boss_Ganon2 -ovl_Boss_Ganondrof -ovl_Boss_Goma -ovl_Boss_Mo -ovl_Boss_Sst -ovl_Boss_Tw -ovl_Boss_Va -ovl_Demo_6K -ovl_Demo_Du -ovl_Demo_Ec -ovl_Demo_Effect -ovl_Demo_Ext -ovl_Demo_Geff -ovl_Demo_Gj -ovl_Demo_Go -ovl_Demo_Gt -ovl_Demo_Ik -ovl_Demo_Im -ovl_Demo_Kankyo -ovl_Demo_Kekkai -ovl_Demo_Sa -ovl_Demo_Shd -ovl_Demo_Tre_Lgt -ovl_Door_Ana -ovl_Door_Gerudo -ovl_Door_Killer -ovl_Door_Shutter -ovl_Door_Toki -ovl_Door_Warp1 -ovl_Efc_Erupc -ovl_Eff_Dust -ovl_Effect_Ss_Blast -ovl_Effect_Ss_Bomb -ovl_Effect_Ss_Bomb2 -ovl_Effect_Ss_Bubble -ovl_Effect_Ss_D_Fire -ovl_Effect_Ss_Dead_Db -ovl_Effect_Ss_Dead_Dd -ovl_Effect_Ss_Dead_Ds -ovl_Effect_Ss_Dead_Sound -ovl_Effect_Ss_Dt_Bubble -ovl_Effect_Ss_Dust -ovl_Effect_Ss_En_Fire -ovl_Effect_Ss_En_Ice -ovl_Effect_Ss_Extra -ovl_Effect_Ss_Fcircle -ovl_Effect_Ss_Fhg_Flash -ovl_Effect_Ss_Fire_Tail -ovl_Effect_Ss_G_Fire -ovl_Effect_Ss_G_Magma -ovl_Effect_Ss_G_Magma2 -ovl_Effect_Ss_G_Ripple -ovl_Effect_Ss_G_Spk -ovl_Effect_Ss_G_Splash -ovl_Effect_Ss_Hahen -ovl_Effect_Ss_HitMark -ovl_Effect_Ss_Ice_Piece -ovl_Effect_Ss_Ice_Smoke -ovl_Effect_Ss_K_Fire -ovl_Effect_Ss_Kakera -ovl_Effect_Ss_KiraKira -ovl_Effect_Ss_Lightning -ovl_Effect_Ss_Sibuki -ovl_Effect_Ss_Sibuki2 -ovl_Effect_Ss_Solder_Srch_Ball -ovl_Effect_Ss_Stick -ovl_Effect_Ss_Stone1 -ovl_Elf_Msg -ovl_Elf_Msg2 -ovl_En_Am -ovl_En_Ani -ovl_En_Anubice -ovl_En_Anubice_Fire -ovl_En_Anubice_Tag -ovl_En_Arow_Trap -ovl_En_Arrow -ovl_En_Attack_Niw -ovl_En_Ba -ovl_En_Bb -ovl_En_Bdfire -ovl_En_Bigokuta -ovl_En_Bili -ovl_En_Bird -ovl_En_Blkobj -ovl_En_Bom -ovl_En_Bom_Bowl_Man -ovl_En_Bom_Bowl_Pit -ovl_En_Bom_Chu -ovl_En_Bombf -ovl_En_Boom -ovl_En_Box -ovl_En_Brob -ovl_En_Bubble -ovl_En_Butte -ovl_En_Bw -ovl_En_Bx -ovl_En_Changer -ovl_En_Clear_Tag -ovl_En_Cow -ovl_En_Crow -ovl_En_Cs -ovl_En_Daiku -ovl_En_Daiku_Kakariko -ovl_En_Dekubaba -ovl_En_Dekunuts -ovl_En_Dh -ovl_En_Dha -ovl_En_Diving_Game -ovl_En_Dns -ovl_En_Dnt_Demo -ovl_En_Dnt_Jiji -ovl_En_Dnt_Nomal -ovl_En_Dodojr -ovl_En_Dodongo -ovl_En_Dog -ovl_En_Door -ovl_En_Ds -ovl_En_Du -ovl_En_Dy_Extra -ovl_En_Eg -ovl_En_Eiyer -ovl_En_Elf -ovl_En_Encount1 -ovl_En_Encount2 -ovl_En_Ex_Item -ovl_En_Ex_Ruppy -ovl_En_Fd -ovl_En_Fd_Fire -ovl_En_Fhg_Fire -ovl_En_Fire_Rock -ovl_En_Firefly -ovl_En_Fish -ovl_En_Floormas -ovl_En_Fr -ovl_En_Fu -ovl_En_Fw -ovl_En_Fz -ovl_En_G_Switch -ovl_En_Ganon_Mant -ovl_En_Ganon_Organ -ovl_En_Gb -ovl_En_Ge1 -ovl_En_Ge2 -ovl_En_Ge3 -ovl_En_GeldB -ovl_En_GirlA -ovl_En_Gm -ovl_En_Go -ovl_En_Go2 -ovl_En_Goma -ovl_En_Goroiwa -ovl_En_Gs -ovl_En_Guest -ovl_En_Hata -ovl_En_Heishi1 -ovl_En_Heishi2 -ovl_En_Heishi3 -ovl_En_Heishi4 -ovl_En_Hintnuts -ovl_En_Holl -ovl_En_Honotrap -ovl_En_Horse -ovl_En_Horse_Game_Check -ovl_En_Horse_Ganon -ovl_En_Horse_Link_Child -ovl_En_Horse_Normal -ovl_En_Horse_Zelda -ovl_En_Hs -ovl_En_Hs2 -ovl_En_Hy -ovl_En_Ice_Hono -ovl_En_Ik -ovl_En_In -ovl_En_Insect -ovl_En_Ishi -ovl_En_It -ovl_En_Jj -ovl_En_Js -ovl_En_Jsjutan -ovl_En_Kakasi -ovl_En_Kakasi2 -ovl_En_Kakasi3 -ovl_En_Kanban -ovl_En_Karebaba -ovl_En_Ko -ovl_En_Kusa -ovl_En_Kz -ovl_En_Light -ovl_En_Lightbox -ovl_En_M_Fire1 -ovl_En_M_Thunder -ovl_En_Ma1 -ovl_En_Ma2 -ovl_En_Ma3 -ovl_En_Mag -ovl_En_Mb -ovl_En_Md -ovl_En_Mk -ovl_En_Mm -ovl_En_Mm2 -ovl_En_Ms -ovl_En_Mu -ovl_En_Nb -ovl_En_Niw -ovl_En_Niw_Girl -ovl_En_Niw_Lady -ovl_En_Nutsball -ovl_En_Nwc -ovl_En_Ny -ovl_En_OE2 -ovl_En_Okarina_Effect -ovl_En_Okarina_Tag -ovl_En_Okuta -ovl_En_Ossan -ovl_En_Owl -ovl_En_Part -ovl_En_Peehat -ovl_En_Po_Desert -ovl_En_Po_Field -ovl_En_Po_Relay -ovl_En_Po_Sisters -ovl_En_Poh -ovl_En_Pu_box -ovl_En_Rd -ovl_En_Reeba -ovl_En_River_Sound -ovl_En_Rl -ovl_En_Rr -ovl_En_Ru1 -ovl_En_Ru2 -ovl_En_Sa -ovl_En_Sb -ovl_En_Scene_Change -ovl_En_Sda -ovl_En_Shopnuts -ovl_En_Si -ovl_En_Siofuki -ovl_En_Skb -ovl_En_Skj -ovl_En_Skjneedle -ovl_En_Ssh -ovl_En_St -ovl_En_Sth -ovl_En_Stream -ovl_En_Sw -ovl_En_Syateki_Itm -ovl_En_Syateki_Man -ovl_En_Syateki_Niw -ovl_En_Ta -ovl_En_Takara_Man -ovl_En_Tana -ovl_En_Tg -ovl_En_Tite -ovl_En_Tk -ovl_En_Torch -ovl_En_Torch2 -ovl_En_Toryo -ovl_En_Tp -ovl_En_Tr -ovl_En_Trap -ovl_En_Tubo_Trap -ovl_En_Vali -ovl_En_Vase -ovl_En_Vb_Ball -ovl_En_Viewer -ovl_En_Vm -ovl_En_Wall_Tubo -ovl_En_Wallmas -ovl_En_Weather_Tag -ovl_En_Weiyer -ovl_En_Wf -ovl_En_Wonder_Item -ovl_En_Wonder_Talk -ovl_En_Wonder_Talk2 -ovl_En_Wood02 -ovl_En_Xc -ovl_En_Yabusame_Mark -ovl_En_Yukabyun -ovl_En_Zf -ovl_En_Zl1 -ovl_En_Zl2 -ovl_En_Zl3 -ovl_En_Zl4 -ovl_En_Zo -ovl_En_fHG -ovl_End_Title -ovl_Fishing -ovl_Item_B_Heart -ovl_Item_Etcetera -ovl_Item_Inbox -ovl_Item_Ocarina -ovl_Item_Shield -ovl_Magic_Dark -ovl_Magic_Fire -ovl_Magic_Wind -ovl_Mir_Ray -ovl_Obj_Bean -ovl_Obj_Blockstop -ovl_Obj_Bombiwa -ovl_Obj_Comb -ovl_Obj_Dekujr -ovl_Obj_Elevator -ovl_Obj_Hamishi -ovl_Obj_Hana -ovl_Obj_Hsblock -ovl_Obj_Ice_Poly -ovl_Obj_Kibako -ovl_Obj_Kibako2 -ovl_Obj_Lift -ovl_Obj_Lightswitch -ovl_Obj_Makekinsuta -ovl_Obj_Makeoshihiki -ovl_Obj_Mure -ovl_Obj_Mure2 -ovl_Obj_Mure3 -ovl_Obj_Oshihiki -ovl_Obj_Roomtimer -ovl_Obj_Switch -ovl_Obj_Syokudai -ovl_Obj_Timeblock -ovl_Obj_Tsubo -ovl_Obj_Warp2block -ovl_Object_Kankyo -ovl_Oceff_Spot -ovl_Oceff_Storm -ovl_Oceff_Wipe -ovl_Oceff_Wipe2 -ovl_Oceff_Wipe3 -ovl_Oceff_Wipe4 -ovl_Shot_Sun -gameplay_keep -gameplay_field_keep -gameplay_dangeon_keep -gameplay_object_exchange_static -object_link_boy -object_link_child -object_box -object_human -object_okuta -object_poh -object_wallmaster -object_dy_obj -object_firefly -object_dodongo -object_fire -object_niw -object_tite -object_reeba -object_peehat -object_kingdodongo -object_horse -object_zf -object_goma -object_zl1 -object_gol -object_bubble -object_dodojr -object_torch2 -object_bl -object_tp -object_oA1 -object_st -object_bw -object_ei -object_horse_normal -object_oB1 -object_o_anime -object_spot04_objects -object_ddan_objects -object_hidan_objects -object_horse_ganon -object_oA2 -object_spot00_objects -object_mb -object_bombf -object_sk2 -object_oE1 -object_oE_anime -object_oE2 -object_ydan_objects -object_gnd -object_am -object_dekubaba -object_oA3 -object_oA4 -object_oA5 -object_oA6 -object_oA7 -object_jj -object_oA8 -object_oA9 -object_oB2 -object_oB3 -object_oB4 -object_horse_zelda -object_opening_demo1 -object_warp1 -object_b_heart -object_dekunuts -object_oE3 -object_oE4 -object_menkuri_objects -object_oE5 -object_oE6 -object_oE7 -object_oE8 -object_oE9 -object_oE10 -object_oE11 -object_oE12 -object_vali -object_oA10 -object_oA11 -object_mizu_objects -object_fhg -object_ossan -object_mori_hineri1 -object_Bb -object_toki_objects -object_yukabyun -object_zl2 -object_mjin -object_mjin_flash -object_mjin_dark -object_mjin_flame -object_mjin_ice -object_mjin_soul -object_mjin_wind -object_mjin_oka -object_haka_objects -object_spot06_objects -object_ice_objects -object_relay_objects -object_mori_hineri1a -object_mori_hineri2 -object_mori_hineri2a -object_mori_objects -object_mori_tex -object_spot08_obj -object_warp2 -object_hata -object_bird -object_wood02 -object_lightbox -object_pu_box -object_trap -object_vase -object_im -object_ta -object_tk -object_xc -object_vm -object_bv -object_hakach_objects -object_efc_crystal_light -object_efc_fire_ball -object_efc_flash -object_efc_lgt_shower -object_efc_star_field -object_god_lgt -object_light_ring -object_triforce_spot -object_medal -object_bdan_objects -object_sd -object_rd -object_po_sisters -object_heavy_object -object_gndd -object_fd -object_du -object_fw -object_horse_link_child -object_spot02_objects -object_haka -object_ru1 -object_syokudai -object_fd2 -object_dh -object_rl -object_efc_tw -object_demo_tre_lgt -object_gi_key -object_mir_ray -object_brob -object_gi_jewel -object_spot09_obj -object_spot18_obj -object_bdoor -object_spot17_obj -object_shop_dungen -object_nb -object_mo -object_sb -object_gi_melody -object_gi_heart -object_gi_compass -object_gi_bosskey -object_gi_medal -object_gi_nuts -object_sa -object_gi_hearts -object_gi_arrowcase -object_gi_bombpouch -object_in -object_tr -object_spot16_obj -object_oE1s -object_oE4s -object_os_anime -object_gi_bottle -object_gi_stick -object_gi_map -object_oF1d_map -object_ru2 -object_gi_shield_1 -object_dekujr -object_gi_magicpot -object_gi_bomb_1 -object_oF1s -object_ma2 -object_gi_purse -object_hni -object_tw -object_rr -object_bxa -object_anubice -object_gi_gerudo -object_gi_arrow -object_gi_bomb_2 -object_gi_egg -object_gi_scale -object_gi_shield_2 -object_gi_hookshot -object_gi_ocarina -object_gi_milk -object_ma1 -object_ganon -object_sst -object_ny -object_fr -object_gi_pachinko -object_gi_boomerang -object_gi_bow -object_gi_glasses -object_gi_liquid -object_ani -object_demo_6k -object_gi_shield_3 -object_gi_letter -object_spot15_obj -object_jya_obj -object_gi_clothes -object_gi_bean -object_gi_fish -object_gi_saw -object_gi_hammer -object_gi_grass -object_gi_longsword -object_spot01_objects -object_md -object_km1 -object_kw1 -object_zo -object_kz -object_umajump -object_masterkokiri -object_masterkokirihead -object_mastergolon -object_masterzoora -object_aob -object_ik -object_ahg -object_cne -object_gi_niwatori -object_skj -object_gi_bottle_letter -object_bji -object_bba -object_gi_ocarina_0 -object_ds -object_ane -object_boj -object_spot03_object -object_spot07_object -object_fz -object_bob -object_ge1 -object_yabusame_point -object_gi_boots_2 -object_gi_seed -object_gnd_magic -object_d_elevator -object_d_hsblock -object_d_lift -object_mamenoki -object_goroiwa -object_toryo -object_daiku -object_nwc -object_blkobj -object_gm -object_ms -object_hs -object_ingate -object_lightswitch -object_kusa -object_tsubo -object_gi_gloves -object_gi_coin -object_kanban -object_gjyo_objects -object_owl -object_mk -object_fu -object_gi_ki_tan_mask -object_gi_redead_mask -object_gi_skj_mask -object_gi_rabit_mask -object_gi_truth_mask -object_ganon_objects -object_siofuki -object_stream -object_mm -object_fa -object_os -object_gi_eye_lotion -object_gi_powder -object_gi_mushroom -object_gi_ticketstone -object_gi_brokensword -object_js -object_cs -object_gi_prescription -object_gi_bracelet -object_gi_soldout -object_gi_frog -object_mag -object_door_gerudo -object_gt -object_efc_erupc -object_zl2_anime1 -object_zl2_anime2 -object_gi_golonmask -object_gi_zoramask -object_gi_gerudomask -object_ganon2 -object_ka -object_ts -object_zg -object_gi_hoverboots -object_gi_m_arrow -object_ds2 -object_ec -object_fish -object_gi_sutaru -object_gi_goddess -object_ssh -object_bigokuta -object_bg -object_spot05_objects -object_spot12_obj -object_bombiwa -object_hintnuts -object_rs -object_spot00_break -object_gla -object_shopnuts -object_geldb -object_gr -object_dog -object_jya_iron -object_jya_door -object_spot01_objects2 -object_spot11_obj -object_kibako2 -object_dns -object_dnk -object_gi_fire -object_gi_insect -object_gi_butterfly -object_gi_ghost -object_gi_soul -object_bowl -object_po_field -object_demo_kekkai -object_efc_doughnut -object_gi_dekupouch -object_ganon_anime1 -object_ganon_anime2 -object_ganon_anime3 -object_gi_rupy -object_spot01_matoya -object_spot01_matoyab -object_po_composer -object_mu -object_wf -object_skb -object_gj -object_geff -object_haka_door -object_gs -object_ps -object_bwall -object_crow -object_cow -object_cob -object_gi_sword_1 -object_door_killer -object_ouke_haka -object_timeblock -object_zl4 -g_pn_01 -g_pn_02 -g_pn_03 -g_pn_04 -g_pn_05 -g_pn_06 -g_pn_07 -g_pn_08 -g_pn_09 -g_pn_10 -g_pn_11 -g_pn_12 -g_pn_13 -g_pn_14 -g_pn_15 -g_pn_16 -g_pn_17 -g_pn_18 -g_pn_19 -g_pn_20 -g_pn_21 -g_pn_22 -g_pn_23 -g_pn_24 -g_pn_25 -g_pn_26 -g_pn_27 -g_pn_28 -g_pn_29 -g_pn_30 -g_pn_31 -g_pn_32 -g_pn_33 -g_pn_34 -g_pn_35 -g_pn_36 -g_pn_37 -g_pn_38 -g_pn_39 -g_pn_40 -g_pn_41 -g_pn_42 -g_pn_43 -g_pn_44 -g_pn_45 -g_pn_46 -g_pn_47 -g_pn_48 -g_pn_49 -g_pn_50 -g_pn_51 -g_pn_52 -g_pn_53 -g_pn_54 -g_pn_55 -g_pn_56 -g_pn_57 -z_select_static -nintendo_rogo_static -title_static -parameter_static -vr_fine0_static -vr_fine0_pal_static -vr_fine1_static -vr_fine1_pal_static -vr_fine2_static -vr_fine2_pal_static -vr_fine3_static -vr_fine3_pal_static -vr_cloud0_static -vr_cloud0_pal_static -vr_cloud1_static -vr_cloud1_pal_static -vr_cloud2_static -vr_cloud2_pal_static -vr_cloud3_static -vr_cloud3_pal_static -vr_holy0_static -vr_holy0_pal_static -vr_holy1_static -vr_holy1_pal_static -vr_MDVR_static -vr_MDVR_pal_static -vr_MNVR_static -vr_MNVR_pal_static -vr_RUVR_static -vr_RUVR_pal_static -vr_LHVR_static -vr_LHVR_pal_static -vr_KHVR_static -vr_KHVR_pal_static -vr_K3VR_static -vr_K3VR_pal_static -vr_K4VR_static -vr_K4VR_pal_static -vr_K5VR_static -vr_K5VR_pal_static -vr_SP1a_static -vr_SP1a_pal_static -vr_MLVR_static -vr_MLVR_pal_static -vr_KKRVR_static -vr_KKRVR_pal_static -vr_KR3VR_static -vr_KR3VR_pal_static -vr_IPVR_static -vr_IPVR_pal_static -vr_KSVR_static -vr_KSVR_pal_static -vr_GLVR_static -vr_GLVR_pal_static -vr_ZRVR_static -vr_ZRVR_pal_static -vr_DGVR_static -vr_DGVR_pal_static -vr_ALVR_static -vr_ALVR_pal_static -vr_NSVR_static -vr_NSVR_pal_static -vr_LBVR_static -vr_LBVR_pal_static -vr_TTVR_static -vr_TTVR_pal_static -vr_FCVR_static -vr_FCVR_pal_static -elf_message_field -elf_message_ydan -ydan_scene -ydan_room_0 -ydan_room_1 -ydan_room_2 -ydan_room_3 -ydan_room_4 -ydan_room_5 -ydan_room_6 -ydan_room_7 -ydan_room_8 -ydan_room_9 -ydan_room_10 -ydan_room_11 -ddan_scene -ddan_room_0 -ddan_room_1 -ddan_room_2 -ddan_room_3 -ddan_room_4 -ddan_room_5 -ddan_room_6 -ddan_room_7 -ddan_room_8 -ddan_room_9 -ddan_room_10 -ddan_room_11 -ddan_room_12 -ddan_room_13 -ddan_room_14 -ddan_room_15 -ddan_room_16 -bdan_scene -bdan_room_0 -bdan_room_1 -bdan_room_2 -bdan_room_3 -bdan_room_4 -bdan_room_5 -bdan_room_6 -bdan_room_7 -bdan_room_8 -bdan_room_9 -bdan_room_10 -bdan_room_11 -bdan_room_12 -bdan_room_13 -bdan_room_14 -bdan_room_15 -Bmori1_scene -Bmori1_room_0 -Bmori1_room_1 -Bmori1_room_2 -Bmori1_room_3 -Bmori1_room_4 -Bmori1_room_5 -Bmori1_room_6 -Bmori1_room_7 -Bmori1_room_8 -Bmori1_room_9 -Bmori1_room_10 -Bmori1_room_11 -Bmori1_room_12 -Bmori1_room_13 -Bmori1_room_14 -Bmori1_room_15 -Bmori1_room_16 -Bmori1_room_17 -Bmori1_room_18 -Bmori1_room_19 -Bmori1_room_20 -Bmori1_room_21 -Bmori1_room_22 -HIDAN_scene -HIDAN_room_0 -HIDAN_room_1 -HIDAN_room_2 -HIDAN_room_3 -HIDAN_room_4 -HIDAN_room_5 -HIDAN_room_6 -HIDAN_room_7 -HIDAN_room_8 -HIDAN_room_9 -HIDAN_room_10 -HIDAN_room_11 -HIDAN_room_12 -HIDAN_room_13 -HIDAN_room_14 -HIDAN_room_15 -HIDAN_room_16 -HIDAN_room_17 -HIDAN_room_18 -HIDAN_room_19 -HIDAN_room_20 -HIDAN_room_21 -HIDAN_room_22 -HIDAN_room_23 -HIDAN_room_24 -HIDAN_room_25 -HIDAN_room_26 -MIZUsin_scene -MIZUsin_room_0 -MIZUsin_room_1 -MIZUsin_room_2 -MIZUsin_room_3 -MIZUsin_room_4 -MIZUsin_room_5 -MIZUsin_room_6 -MIZUsin_room_7 -MIZUsin_room_8 -MIZUsin_room_9 -MIZUsin_room_10 -MIZUsin_room_11 -MIZUsin_room_12 -MIZUsin_room_13 -MIZUsin_room_14 -MIZUsin_room_15 -MIZUsin_room_16 -MIZUsin_room_17 -MIZUsin_room_18 -MIZUsin_room_19 -MIZUsin_room_20 -MIZUsin_room_21 -MIZUsin_room_22 -jyasinzou_scene -jyasinzou_room_0 -jyasinzou_room_1 -jyasinzou_room_2 -jyasinzou_room_3 -jyasinzou_room_4 -jyasinzou_room_5 -jyasinzou_room_6 -jyasinzou_room_7 -jyasinzou_room_8 -jyasinzou_room_9 -jyasinzou_room_10 -jyasinzou_room_11 -jyasinzou_room_12 -jyasinzou_room_13 -jyasinzou_room_14 -jyasinzou_room_15 -jyasinzou_room_16 -jyasinzou_room_17 -jyasinzou_room_18 -jyasinzou_room_19 -jyasinzou_room_20 -jyasinzou_room_21 -jyasinzou_room_22 -jyasinzou_room_23 -jyasinzou_room_24 -jyasinzou_room_25 -jyasinzou_room_26 -jyasinzou_room_27 -jyasinzou_room_28 -HAKAdan_scene -HAKAdan_room_0 -HAKAdan_room_1 -HAKAdan_room_2 -HAKAdan_room_3 -HAKAdan_room_4 -HAKAdan_room_5 -HAKAdan_room_6 -HAKAdan_room_7 -HAKAdan_room_8 -HAKAdan_room_9 -HAKAdan_room_10 -HAKAdan_room_11 -HAKAdan_room_12 -HAKAdan_room_13 -HAKAdan_room_14 -HAKAdan_room_15 -HAKAdan_room_16 -HAKAdan_room_17 -HAKAdan_room_18 -HAKAdan_room_19 -HAKAdan_room_20 -HAKAdan_room_21 -HAKAdan_room_22 -HAKAdanCH_scene -HAKAdanCH_room_0 -HAKAdanCH_room_1 -HAKAdanCH_room_2 -HAKAdanCH_room_3 -HAKAdanCH_room_4 -HAKAdanCH_room_5 -HAKAdanCH_room_6 -ice_doukutu_scene -ice_doukutu_room_0 -ice_doukutu_room_1 -ice_doukutu_room_2 -ice_doukutu_room_3 -ice_doukutu_room_4 -ice_doukutu_room_5 -ice_doukutu_room_6 -ice_doukutu_room_7 -ice_doukutu_room_8 -ice_doukutu_room_9 -ice_doukutu_room_10 -ice_doukutu_room_11 -men_scene -men_room_0 -men_room_1 -men_room_2 -men_room_3 -men_room_4 -men_room_5 -men_room_6 -men_room_7 -men_room_8 -men_room_9 -men_room_10 -ganontika_scene -ganontika_room_0 -ganontika_room_1 -ganontika_room_2 -ganontika_room_3 -ganontika_room_4 -ganontika_room_5 -ganontika_room_6 -ganontika_room_7 -ganontika_room_8 -ganontika_room_9 -ganontika_room_10 -ganontika_room_11 -ganontika_room_12 -ganontika_room_13 -ganontika_room_14 -ganontika_room_15 -ganontika_room_16 -ganontika_room_17 -ganontika_room_18 -ganontika_room_19 -spot00_scene -spot00_room_0 -spot01_scene -spot01_room_0 -spot02_scene -spot02_room_0 -spot02_room_1 -spot03_scene -spot03_room_0 -spot03_room_1 -spot04_scene -spot04_room_0 -spot04_room_1 -spot04_room_2 -spot05_scene -spot05_room_0 -spot06_scene -spot06_room_0 -spot07_scene -spot07_room_0 -spot07_room_1 -spot08_scene -spot08_room_0 -spot09_scene -spot09_room_0 -spot10_scene -spot10_room_0 -spot10_room_1 -spot10_room_2 -spot10_room_3 -spot10_room_4 -spot10_room_5 -spot10_room_6 -spot10_room_7 -spot10_room_8 -spot10_room_9 -spot11_scene -spot11_room_0 -spot12_scene -spot12_room_0 -spot12_room_1 -spot13_scene -spot13_room_0 -spot13_room_1 -spot15_scene -spot15_room_0 -spot16_scene -spot16_room_0 -spot17_scene -spot17_room_0 -spot17_room_1 -spot18_scene -spot18_room_0 -spot18_room_1 -spot18_room_2 -spot18_room_3 -market_day_scene -market_day_room_0 -market_night_scene -market_night_room_0 -kenjyanoma_scene -kenjyanoma_room_0 -tokinoma_scene -tokinoma_room_0 -tokinoma_room_1 -link_home_scene -link_home_room_0 -kokiri_shop_scene -kokiri_shop_room_0 -kokiri_home_scene -kokiri_home_room_0 -kakusiana_scene -kakusiana_room_0 -kakusiana_room_1 -kakusiana_room_2 -kakusiana_room_3 -kakusiana_room_4 -kakusiana_room_5 -kakusiana_room_6 -kakusiana_room_7 -kakusiana_room_8 -kakusiana_room_9 -kakusiana_room_10 -kakusiana_room_11 -kakusiana_room_12 -kakusiana_room_13 -entra_scene -entra_room_0 -moribossroom_scene -moribossroom_room_0 -moribossroom_room_1 -syatekijyou_scene -syatekijyou_room_0 -shop1_scene -shop1_room_0 -hairal_niwa_scene -hairal_niwa_room_0 -ganon_tou_scene -ganon_tou_room_0 -market_alley_scene -market_alley_room_0 -spot20_scene -spot20_room_0 -market_ruins_scene -market_ruins_room_0 -entra_n_scene -entra_n_room_0 -enrui_scene -enrui_room_0 -market_alley_n_scene -market_alley_n_room_0 -hiral_demo_scene -hiral_demo_room_0 -kokiri_home3_scene -kokiri_home3_room_0 -malon_stable_scene -malon_stable_room_0 -kakariko_scene -kakariko_room_0 -bdan_boss_scene -bdan_boss_room_0 -bdan_boss_room_1 -FIRE_bs_scene -FIRE_bs_room_0 -FIRE_bs_room_1 -hut_scene -hut_room_0 -daiyousei_izumi_scene -daiyousei_izumi_room_0 -hakaana_scene -hakaana_room_0 -yousei_izumi_tate_scene -yousei_izumi_tate_room_0 -yousei_izumi_yoko_scene -yousei_izumi_yoko_room_0 -golon_scene -golon_room_0 -zoora_scene -zoora_room_0 -drag_scene -drag_room_0 -alley_shop_scene -alley_shop_room_0 -night_shop_scene -night_shop_room_0 -impa_scene -impa_room_0 -labo_scene -labo_room_0 -tent_scene -tent_room_0 -nakaniwa_scene -nakaniwa_room_0 -ddan_boss_scene -ddan_boss_room_0 -ddan_boss_room_1 -ydan_boss_scene -ydan_boss_room_0 -ydan_boss_room_1 -HAKAdan_bs_scene -HAKAdan_bs_room_0 -HAKAdan_bs_room_1 -MIZUsin_bs_scene -MIZUsin_bs_room_0 -MIZUsin_bs_room_1 -ganon_scene -ganon_room_0 -ganon_room_1 -ganon_room_2 -ganon_room_3 -ganon_room_4 -ganon_room_5 -ganon_room_6 -ganon_room_7 -ganon_room_8 -ganon_room_9 -ganon_boss_scene -ganon_boss_room_0 -jyasinboss_scene -jyasinboss_room_0 -jyasinboss_room_1 -jyasinboss_room_2 -jyasinboss_room_3 -kokiri_home4_scene -kokiri_home4_room_0 -kokiri_home5_scene -kokiri_home5_room_0 -ganon_final_scene -ganon_final_room_0 -kakariko3_scene -kakariko3_room_0 -hakasitarelay_scene -hakasitarelay_room_0 -hakasitarelay_room_1 -hakasitarelay_room_2 -hakasitarelay_room_3 -hakasitarelay_room_4 -hakasitarelay_room_5 -hakasitarelay_room_6 -shrine_scene -shrine_room_0 -turibori_scene -turibori_room_0 -shrine_n_scene -shrine_n_room_0 -shrine_r_scene -shrine_r_room_0 -hakaana2_scene -hakaana2_room_0 -gerudoway_scene -gerudoway_room_0 -gerudoway_room_1 -gerudoway_room_2 -gerudoway_room_3 -gerudoway_room_4 -gerudoway_room_5 -hairal_niwa_n_scene -hairal_niwa_n_room_0 -bowling_scene -bowling_room_0 -hakaana_ouke_scene -hakaana_ouke_room_0 -hakaana_ouke_room_1 -hakaana_ouke_room_2 -hylia_labo_scene -hylia_labo_room_0 -souko_scene -souko_room_0 -souko_room_1 -souko_room_2 -miharigoya_scene -miharigoya_room_0 -mahouya_scene -mahouya_room_0 -takaraya_scene -takaraya_room_0 -takaraya_room_1 -takaraya_room_2 -takaraya_room_3 -takaraya_room_4 -takaraya_room_5 -takaraya_room_6 -ganon_sonogo_scene -ganon_sonogo_room_0 -ganon_sonogo_room_1 -ganon_sonogo_room_2 -ganon_sonogo_room_3 -ganon_sonogo_room_4 -ganon_demo_scene -ganon_demo_room_0 -face_shop_scene -face_shop_room_0 -kinsuta_scene -kinsuta_room_0 -ganontikasonogo_scene -ganontikasonogo_room_0 -ganontikasonogo_room_1 -bump_texture_static -anime_model_1_static -anime_model_2_static -anime_model_3_static -anime_model_4_static -anime_model_5_static -anime_model_6_static -anime_texture_1_static -anime_texture_2_static -anime_texture_3_static -anime_texture_4_static -anime_texture_5_static -anime_texture_6_static -softsprite_matrix_static \ No newline at end of file diff --git a/OTRExporter/CFG/filelists/gamecube_pal.txt b/OTRExporter/CFG/filelists/gamecube_pal.txt deleted file mode 100644 index c9746c1da..000000000 --- a/OTRExporter/CFG/filelists/gamecube_pal.txt +++ /dev/null @@ -1,1510 +0,0 @@ -makerom -boot -dmadata -Audiobank -Audioseq -Audiotable -link_animetion -icon_item_static -icon_item_24_static -icon_item_field_static -icon_item_dungeon_static -icon_item_gameover_static -icon_item_nes_static -icon_item_ger_static -icon_item_fra_static -item_name_static -map_name_static -do_action_static -message_static -message_texture_static -nes_font_static -nes_message_data_static -ger_message_data_static -fra_message_data_static -staff_message_data_static -map_grand_static -map_48x85_static -map_i_static -code -ovl_title -ovl_select -ovl_opening -ovl_file_choose -ovl_kaleido_scope -ovl_player_actor -ovl_map_mark_data -ovl_En_Test -ovl_Arms_Hook -ovl_Arrow_Fire -ovl_Arrow_Ice -ovl_Arrow_Light -ovl_Bg_Bdan_Objects -ovl_Bg_Bdan_Switch -ovl_Bg_Bom_Guard -ovl_Bg_Bombwall -ovl_Bg_Bowl_Wall -ovl_Bg_Breakwall -ovl_Bg_Ddan_Jd -ovl_Bg_Ddan_Kd -ovl_Bg_Dodoago -ovl_Bg_Dy_Yoseizo -ovl_Bg_Ganon_Otyuka -ovl_Bg_Gate_Shutter -ovl_Bg_Gjyo_Bridge -ovl_Bg_Gnd_Darkmeiro -ovl_Bg_Gnd_Firemeiro -ovl_Bg_Gnd_Iceblock -ovl_Bg_Gnd_Nisekabe -ovl_Bg_Gnd_Soulmeiro -ovl_Bg_Haka -ovl_Bg_Haka_Gate -ovl_Bg_Haka_Huta -ovl_Bg_Haka_Megane -ovl_Bg_Haka_MeganeBG -ovl_Bg_Haka_Sgami -ovl_Bg_Haka_Ship -ovl_Bg_Haka_Trap -ovl_Bg_Haka_Tubo -ovl_Bg_Haka_Water -ovl_Bg_Haka_Zou -ovl_Bg_Heavy_Block -ovl_Bg_Hidan_Curtain -ovl_Bg_Hidan_Dalm -ovl_Bg_Hidan_Firewall -ovl_Bg_Hidan_Fslift -ovl_Bg_Hidan_Fwbig -ovl_Bg_Hidan_Hamstep -ovl_Bg_Hidan_Hrock -ovl_Bg_Hidan_Kousi -ovl_Bg_Hidan_Kowarerukabe -ovl_Bg_Hidan_Rock -ovl_Bg_Hidan_Rsekizou -ovl_Bg_Hidan_Sekizou -ovl_Bg_Hidan_Sima -ovl_Bg_Hidan_Syoku -ovl_Bg_Ice_Objects -ovl_Bg_Ice_Shelter -ovl_Bg_Ice_Shutter -ovl_Bg_Ice_Turara -ovl_Bg_Ingate -ovl_Bg_Jya_1flift -ovl_Bg_Jya_Amishutter -ovl_Bg_Jya_Bigmirror -ovl_Bg_Jya_Block -ovl_Bg_Jya_Bombchuiwa -ovl_Bg_Jya_Bombiwa -ovl_Bg_Jya_Cobra -ovl_Bg_Jya_Goroiwa -ovl_Bg_Jya_Haheniron -ovl_Bg_Jya_Ironobj -ovl_Bg_Jya_Kanaami -ovl_Bg_Jya_Lift -ovl_Bg_Jya_Megami -ovl_Bg_Jya_Zurerukabe -ovl_Bg_Menkuri_Eye -ovl_Bg_Menkuri_Kaiten -ovl_Bg_Menkuri_Nisekabe -ovl_Bg_Mizu_Bwall -ovl_Bg_Mizu_Movebg -ovl_Bg_Mizu_Shutter -ovl_Bg_Mizu_Uzu -ovl_Bg_Mizu_Water -ovl_Bg_Mjin -ovl_Bg_Mori_Bigst -ovl_Bg_Mori_Elevator -ovl_Bg_Mori_Hashigo -ovl_Bg_Mori_Hashira4 -ovl_Bg_Mori_Hineri -ovl_Bg_Mori_Idomizu -ovl_Bg_Mori_Kaitenkabe -ovl_Bg_Mori_Rakkatenjo -ovl_Bg_Po_Event -ovl_Bg_Po_Syokudai -ovl_Bg_Pushbox -ovl_Bg_Relay_Objects -ovl_Bg_Spot00_Break -ovl_Bg_Spot00_Hanebasi -ovl_Bg_Spot01_Fusya -ovl_Bg_Spot01_Idohashira -ovl_Bg_Spot01_Idomizu -ovl_Bg_Spot01_Idosoko -ovl_Bg_Spot01_Objects2 -ovl_Bg_Spot02_Objects -ovl_Bg_Spot03_Taki -ovl_Bg_Spot05_Soko -ovl_Bg_Spot06_Objects -ovl_Bg_Spot07_Taki -ovl_Bg_Spot08_Bakudankabe -ovl_Bg_Spot08_Iceblock -ovl_Bg_Spot09_Obj -ovl_Bg_Spot11_Bakudankabe -ovl_Bg_Spot11_Oasis -ovl_Bg_Spot12_Gate -ovl_Bg_Spot12_Saku -ovl_Bg_Spot15_Rrbox -ovl_Bg_Spot15_Saku -ovl_Bg_Spot16_Bombstone -ovl_Bg_Spot16_Doughnut -ovl_Bg_Spot17_Bakudankabe -ovl_Bg_Spot17_Funen -ovl_Bg_Spot18_Basket -ovl_Bg_Spot18_Futa -ovl_Bg_Spot18_Obj -ovl_Bg_Spot18_Shutter -ovl_Bg_Sst_Floor -ovl_Bg_Toki_Hikari -ovl_Bg_Toki_Swd -ovl_Bg_Treemouth -ovl_Bg_Umajump -ovl_Bg_Vb_Sima -ovl_Bg_Ydan_Hasi -ovl_Bg_Ydan_Maruta -ovl_Bg_Ydan_Sp -ovl_Bg_Zg -ovl_Boss_Dodongo -ovl_Boss_Fd -ovl_Boss_Fd2 -ovl_Boss_Ganon -ovl_Boss_Ganon2 -ovl_Boss_Ganondrof -ovl_Boss_Goma -ovl_Boss_Mo -ovl_Boss_Sst -ovl_Boss_Tw -ovl_Boss_Va -ovl_Demo_6K -ovl_Demo_Du -ovl_Demo_Ec -ovl_Demo_Effect -ovl_Demo_Ext -ovl_Demo_Geff -ovl_Demo_Gj -ovl_Demo_Go -ovl_Demo_Gt -ovl_Demo_Ik -ovl_Demo_Im -ovl_Demo_Kankyo -ovl_Demo_Kekkai -ovl_Demo_Sa -ovl_Demo_Shd -ovl_Demo_Tre_Lgt -ovl_Door_Ana -ovl_Door_Gerudo -ovl_Door_Killer -ovl_Door_Shutter -ovl_Door_Toki -ovl_Door_Warp1 -ovl_Efc_Erupc -ovl_Eff_Dust -ovl_Effect_Ss_Blast -ovl_Effect_Ss_Bomb -ovl_Effect_Ss_Bomb2 -ovl_Effect_Ss_Bubble -ovl_Effect_Ss_D_Fire -ovl_Effect_Ss_Dead_Db -ovl_Effect_Ss_Dead_Dd -ovl_Effect_Ss_Dead_Ds -ovl_Effect_Ss_Dead_Sound -ovl_Effect_Ss_Dt_Bubble -ovl_Effect_Ss_Dust -ovl_Effect_Ss_En_Fire -ovl_Effect_Ss_En_Ice -ovl_Effect_Ss_Extra -ovl_Effect_Ss_Fcircle -ovl_Effect_Ss_Fhg_Flash -ovl_Effect_Ss_Fire_Tail -ovl_Effect_Ss_G_Fire -ovl_Effect_Ss_G_Magma -ovl_Effect_Ss_G_Magma2 -ovl_Effect_Ss_G_Ripple -ovl_Effect_Ss_G_Spk -ovl_Effect_Ss_G_Splash -ovl_Effect_Ss_Hahen -ovl_Effect_Ss_HitMark -ovl_Effect_Ss_Ice_Piece -ovl_Effect_Ss_Ice_Smoke -ovl_Effect_Ss_K_Fire -ovl_Effect_Ss_Kakera -ovl_Effect_Ss_KiraKira -ovl_Effect_Ss_Lightning -ovl_Effect_Ss_Sibuki -ovl_Effect_Ss_Sibuki2 -ovl_Effect_Ss_Solder_Srch_Ball -ovl_Effect_Ss_Stick -ovl_Effect_Ss_Stone1 -ovl_Elf_Msg -ovl_Elf_Msg2 -ovl_En_Am -ovl_En_Ani -ovl_En_Anubice -ovl_En_Anubice_Fire -ovl_En_Anubice_Tag -ovl_En_Arow_Trap -ovl_En_Arrow -ovl_En_Attack_Niw -ovl_En_Ba -ovl_En_Bb -ovl_En_Bdfire -ovl_En_Bigokuta -ovl_En_Bili -ovl_En_Bird -ovl_En_Blkobj -ovl_En_Bom -ovl_En_Bom_Bowl_Man -ovl_En_Bom_Bowl_Pit -ovl_En_Bom_Chu -ovl_En_Bombf -ovl_En_Boom -ovl_En_Box -ovl_En_Brob -ovl_En_Bubble -ovl_En_Butte -ovl_En_Bw -ovl_En_Bx -ovl_En_Changer -ovl_En_Clear_Tag -ovl_En_Cow -ovl_En_Crow -ovl_En_Cs -ovl_En_Daiku -ovl_En_Daiku_Kakariko -ovl_En_Dekubaba -ovl_En_Dekunuts -ovl_En_Dh -ovl_En_Dha -ovl_En_Diving_Game -ovl_En_Dns -ovl_En_Dnt_Demo -ovl_En_Dnt_Jiji -ovl_En_Dnt_Nomal -ovl_En_Dodojr -ovl_En_Dodongo -ovl_En_Dog -ovl_En_Door -ovl_En_Ds -ovl_En_Du -ovl_En_Dy_Extra -ovl_En_Eg -ovl_En_Eiyer -ovl_En_Elf -ovl_En_Encount1 -ovl_En_Encount2 -ovl_En_Ex_Item -ovl_En_Ex_Ruppy -ovl_En_Fd -ovl_En_Fd_Fire -ovl_En_Fhg_Fire -ovl_En_Fire_Rock -ovl_En_Firefly -ovl_En_Fish -ovl_En_Floormas -ovl_En_Fr -ovl_En_Fu -ovl_En_Fw -ovl_En_Fz -ovl_En_G_Switch -ovl_En_Ganon_Mant -ovl_En_Ganon_Organ -ovl_En_Gb -ovl_En_Ge1 -ovl_En_Ge2 -ovl_En_Ge3 -ovl_En_GeldB -ovl_En_GirlA -ovl_En_Gm -ovl_En_Go -ovl_En_Go2 -ovl_En_Goma -ovl_En_Goroiwa -ovl_En_Gs -ovl_En_Guest -ovl_En_Hata -ovl_En_Heishi1 -ovl_En_Heishi2 -ovl_En_Heishi3 -ovl_En_Heishi4 -ovl_En_Hintnuts -ovl_En_Holl -ovl_En_Honotrap -ovl_En_Horse -ovl_En_Horse_Game_Check -ovl_En_Horse_Ganon -ovl_En_Horse_Link_Child -ovl_En_Horse_Normal -ovl_En_Horse_Zelda -ovl_En_Hs -ovl_En_Hs2 -ovl_En_Hy -ovl_En_Ice_Hono -ovl_En_Ik -ovl_En_In -ovl_En_Insect -ovl_En_Ishi -ovl_En_It -ovl_En_Jj -ovl_En_Js -ovl_En_Jsjutan -ovl_En_Kakasi -ovl_En_Kakasi2 -ovl_En_Kakasi3 -ovl_En_Kanban -ovl_En_Karebaba -ovl_En_Ko -ovl_En_Kusa -ovl_En_Kz -ovl_En_Light -ovl_En_Lightbox -ovl_En_M_Fire1 -ovl_En_M_Thunder -ovl_En_Ma1 -ovl_En_Ma2 -ovl_En_Ma3 -ovl_En_Mag -ovl_En_Mb -ovl_En_Md -ovl_En_Mk -ovl_En_Mm -ovl_En_Mm2 -ovl_En_Ms -ovl_En_Mu -ovl_En_Nb -ovl_En_Niw -ovl_En_Niw_Girl -ovl_En_Niw_Lady -ovl_En_Nutsball -ovl_En_Nwc -ovl_En_Ny -ovl_En_OE2 -ovl_En_Okarina_Effect -ovl_En_Okarina_Tag -ovl_En_Okuta -ovl_En_Ossan -ovl_En_Owl -ovl_En_Part -ovl_En_Peehat -ovl_En_Po_Desert -ovl_En_Po_Field -ovl_En_Po_Relay -ovl_En_Po_Sisters -ovl_En_Poh -ovl_En_Pu_box -ovl_En_Rd -ovl_En_Reeba -ovl_En_River_Sound -ovl_En_Rl -ovl_En_Rr -ovl_En_Ru1 -ovl_En_Ru2 -ovl_En_Sa -ovl_En_Sb -ovl_En_Scene_Change -ovl_En_Sda -ovl_En_Shopnuts -ovl_En_Si -ovl_En_Siofuki -ovl_En_Skb -ovl_En_Skj -ovl_En_Skjneedle -ovl_En_Ssh -ovl_En_St -ovl_En_Sth -ovl_En_Stream -ovl_En_Sw -ovl_En_Syateki_Itm -ovl_En_Syateki_Man -ovl_En_Syateki_Niw -ovl_En_Ta -ovl_En_Takara_Man -ovl_En_Tana -ovl_En_Tg -ovl_En_Tite -ovl_En_Tk -ovl_En_Torch -ovl_En_Torch2 -ovl_En_Toryo -ovl_En_Tp -ovl_En_Tr -ovl_En_Trap -ovl_En_Tubo_Trap -ovl_En_Vali -ovl_En_Vase -ovl_En_Vb_Ball -ovl_En_Viewer -ovl_En_Vm -ovl_En_Wall_Tubo -ovl_En_Wallmas -ovl_En_Weather_Tag -ovl_En_Weiyer -ovl_En_Wf -ovl_En_Wonder_Item -ovl_En_Wonder_Talk -ovl_En_Wonder_Talk2 -ovl_En_Wood02 -ovl_En_Xc -ovl_En_Yabusame_Mark -ovl_En_Yukabyun -ovl_En_Zf -ovl_En_Zl1 -ovl_En_Zl2 -ovl_En_Zl3 -ovl_En_Zl4 -ovl_En_Zo -ovl_En_fHG -ovl_End_Title -ovl_Fishing -ovl_Item_B_Heart -ovl_Item_Etcetera -ovl_Item_Inbox -ovl_Item_Ocarina -ovl_Item_Shield -ovl_Magic_Dark -ovl_Magic_Fire -ovl_Magic_Wind -ovl_Mir_Ray -ovl_Obj_Bean -ovl_Obj_Blockstop -ovl_Obj_Bombiwa -ovl_Obj_Comb -ovl_Obj_Dekujr -ovl_Obj_Elevator -ovl_Obj_Hamishi -ovl_Obj_Hana -ovl_Obj_Hsblock -ovl_Obj_Ice_Poly -ovl_Obj_Kibako -ovl_Obj_Kibako2 -ovl_Obj_Lift -ovl_Obj_Lightswitch -ovl_Obj_Makekinsuta -ovl_Obj_Makeoshihiki -ovl_Obj_Mure -ovl_Obj_Mure2 -ovl_Obj_Mure3 -ovl_Obj_Oshihiki -ovl_Obj_Roomtimer -ovl_Obj_Switch -ovl_Obj_Syokudai -ovl_Obj_Timeblock -ovl_Obj_Tsubo -ovl_Obj_Warp2block -ovl_Object_Kankyo -ovl_Oceff_Spot -ovl_Oceff_Storm -ovl_Oceff_Wipe -ovl_Oceff_Wipe2 -ovl_Oceff_Wipe3 -ovl_Oceff_Wipe4 -ovl_Shot_Sun -gameplay_keep -gameplay_field_keep -gameplay_dangeon_keep -gameplay_object_exchange_static -object_link_boy -object_link_child -object_box -object_human -object_okuta -object_poh -object_wallmaster -object_dy_obj -object_firefly -object_dodongo -object_fire -object_niw -object_tite -object_reeba -object_peehat -object_kingdodongo -object_horse -object_zf -object_goma -object_zl1 -object_gol -object_bubble -object_dodojr -object_torch2 -object_bl -object_tp -object_oA1 -object_st -object_bw -object_ei -object_horse_normal -object_oB1 -object_o_anime -object_spot04_objects -object_ddan_objects -object_hidan_objects -object_horse_ganon -object_oA2 -object_spot00_objects -object_mb -object_bombf -object_sk2 -object_oE1 -object_oE_anime -object_oE2 -object_ydan_objects -object_gnd -object_am -object_dekubaba -object_oA3 -object_oA4 -object_oA5 -object_oA6 -object_oA7 -object_jj -object_oA8 -object_oA9 -object_oB2 -object_oB3 -object_oB4 -object_horse_zelda -object_opening_demo1 -object_warp1 -object_b_heart -object_dekunuts -object_oE3 -object_oE4 -object_menkuri_objects -object_oE5 -object_oE6 -object_oE7 -object_oE8 -object_oE9 -object_oE10 -object_oE11 -object_oE12 -object_vali -object_oA10 -object_oA11 -object_mizu_objects -object_fhg -object_ossan -object_mori_hineri1 -object_Bb -object_toki_objects -object_yukabyun -object_zl2 -object_mjin -object_mjin_flash -object_mjin_dark -object_mjin_flame -object_mjin_ice -object_mjin_soul -object_mjin_wind -object_mjin_oka -object_haka_objects -object_spot06_objects -object_ice_objects -object_relay_objects -object_mori_hineri1a -object_mori_hineri2 -object_mori_hineri2a -object_mori_objects -object_mori_tex -object_spot08_obj -object_warp2 -object_hata -object_bird -object_wood02 -object_lightbox -object_pu_box -object_trap -object_vase -object_im -object_ta -object_tk -object_xc -object_vm -object_bv -object_hakach_objects -object_efc_crystal_light -object_efc_fire_ball -object_efc_flash -object_efc_lgt_shower -object_efc_star_field -object_god_lgt -object_light_ring -object_triforce_spot -object_medal -object_bdan_objects -object_sd -object_rd -object_po_sisters -object_heavy_object -object_gndd -object_fd -object_du -object_fw -object_horse_link_child -object_spot02_objects -object_haka -object_ru1 -object_syokudai -object_fd2 -object_dh -object_rl -object_efc_tw -object_demo_tre_lgt -object_gi_key -object_mir_ray -object_brob -object_gi_jewel -object_spot09_obj -object_spot18_obj -object_bdoor -object_spot17_obj -object_shop_dungen -object_nb -object_mo -object_sb -object_gi_melody -object_gi_heart -object_gi_compass -object_gi_bosskey -object_gi_medal -object_gi_nuts -object_sa -object_gi_hearts -object_gi_arrowcase -object_gi_bombpouch -object_in -object_tr -object_spot16_obj -object_oE1s -object_oE4s -object_os_anime -object_gi_bottle -object_gi_stick -object_gi_map -object_oF1d_map -object_ru2 -object_gi_shield_1 -object_dekujr -object_gi_magicpot -object_gi_bomb_1 -object_oF1s -object_ma2 -object_gi_purse -object_hni -object_tw -object_rr -object_bxa -object_anubice -object_gi_gerudo -object_gi_arrow -object_gi_bomb_2 -object_gi_egg -object_gi_scale -object_gi_shield_2 -object_gi_hookshot -object_gi_ocarina -object_gi_milk -object_ma1 -object_ganon -object_sst -object_ny -object_fr -object_gi_pachinko -object_gi_boomerang -object_gi_bow -object_gi_glasses -object_gi_liquid -object_ani -object_demo_6k -object_gi_shield_3 -object_gi_letter -object_spot15_obj -object_jya_obj -object_gi_clothes -object_gi_bean -object_gi_fish -object_gi_saw -object_gi_hammer -object_gi_grass -object_gi_longsword -object_spot01_objects -object_md -object_km1 -object_kw1 -object_zo -object_kz -object_umajump -object_masterkokiri -object_masterkokirihead -object_mastergolon -object_masterzoora -object_aob -object_ik -object_ahg -object_cne -object_gi_niwatori -object_skj -object_gi_bottle_letter -object_bji -object_bba -object_gi_ocarina_0 -object_ds -object_ane -object_boj -object_spot03_object -object_spot07_object -object_fz -object_bob -object_ge1 -object_yabusame_point -object_gi_boots_2 -object_gi_seed -object_gnd_magic -object_d_elevator -object_d_hsblock -object_d_lift -object_mamenoki -object_goroiwa -object_toryo -object_daiku -object_nwc -object_blkobj -object_gm -object_ms -object_hs -object_ingate -object_lightswitch -object_kusa -object_tsubo -object_gi_gloves -object_gi_coin -object_kanban -object_gjyo_objects -object_owl -object_mk -object_fu -object_gi_ki_tan_mask -object_gi_redead_mask -object_gi_skj_mask -object_gi_rabit_mask -object_gi_truth_mask -object_ganon_objects -object_siofuki -object_stream -object_mm -object_fa -object_os -object_gi_eye_lotion -object_gi_powder -object_gi_mushroom -object_gi_ticketstone -object_gi_brokensword -object_js -object_cs -object_gi_prescription -object_gi_bracelet -object_gi_soldout -object_gi_frog -object_mag -object_door_gerudo -object_gt -object_efc_erupc -object_zl2_anime1 -object_zl2_anime2 -object_gi_golonmask -object_gi_zoramask -object_gi_gerudomask -object_ganon2 -object_ka -object_ts -object_zg -object_gi_hoverboots -object_gi_m_arrow -object_ds2 -object_ec -object_fish -object_gi_sutaru -object_gi_goddess -object_ssh -object_bigokuta -object_bg -object_spot05_objects -object_spot12_obj -object_bombiwa -object_hintnuts -object_rs -object_spot00_break -object_gla -object_shopnuts -object_geldb -object_gr -object_dog -object_jya_iron -object_jya_door -object_spot01_objects2 -object_spot11_obj -object_kibako2 -object_dns -object_dnk -object_gi_fire -object_gi_insect -object_gi_butterfly -object_gi_ghost -object_gi_soul -object_bowl -object_po_field -object_demo_kekkai -object_efc_doughnut -object_gi_dekupouch -object_ganon_anime1 -object_ganon_anime2 -object_ganon_anime3 -object_gi_rupy -object_spot01_matoya -object_spot01_matoyab -object_po_composer -object_mu -object_wf -object_skb -object_gj -object_geff -object_haka_door -object_gs -object_ps -object_bwall -object_crow -object_cow -object_cob -object_gi_sword_1 -object_door_killer -object_ouke_haka -object_timeblock -object_zl4 -g_pn_01 -g_pn_02 -g_pn_03 -g_pn_04 -g_pn_05 -g_pn_06 -g_pn_07 -g_pn_08 -g_pn_09 -g_pn_10 -g_pn_11 -g_pn_12 -g_pn_13 -g_pn_14 -g_pn_15 -g_pn_16 -g_pn_17 -g_pn_18 -g_pn_19 -g_pn_20 -g_pn_21 -g_pn_22 -g_pn_23 -g_pn_24 -g_pn_25 -g_pn_26 -g_pn_27 -g_pn_28 -g_pn_29 -g_pn_30 -g_pn_31 -g_pn_32 -g_pn_33 -g_pn_34 -g_pn_35 -g_pn_36 -g_pn_37 -g_pn_38 -g_pn_39 -g_pn_40 -g_pn_41 -g_pn_42 -g_pn_43 -g_pn_44 -g_pn_45 -g_pn_46 -g_pn_47 -g_pn_48 -g_pn_49 -g_pn_50 -g_pn_51 -g_pn_52 -g_pn_53 -g_pn_54 -g_pn_55 -g_pn_56 -g_pn_57 -z_select_static -nintendo_rogo_static -title_static -parameter_static -vr_fine0_static -vr_fine0_pal_static -vr_fine1_static -vr_fine1_pal_static -vr_fine2_static -vr_fine2_pal_static -vr_fine3_static -vr_fine3_pal_static -vr_cloud0_static -vr_cloud0_pal_static -vr_cloud1_static -vr_cloud1_pal_static -vr_cloud2_static -vr_cloud2_pal_static -vr_cloud3_static -vr_cloud3_pal_static -vr_holy0_static -vr_holy0_pal_static -vr_holy1_static -vr_holy1_pal_static -vr_MDVR_static -vr_MDVR_pal_static -vr_MNVR_static -vr_MNVR_pal_static -vr_RUVR_static -vr_RUVR_pal_static -vr_LHVR_static -vr_LHVR_pal_static -vr_KHVR_static -vr_KHVR_pal_static -vr_K3VR_static -vr_K3VR_pal_static -vr_K4VR_static -vr_K4VR_pal_static -vr_K5VR_static -vr_K5VR_pal_static -vr_SP1a_static -vr_SP1a_pal_static -vr_MLVR_static -vr_MLVR_pal_static -vr_KKRVR_static -vr_KKRVR_pal_static -vr_KR3VR_static -vr_KR3VR_pal_static -vr_IPVR_static -vr_IPVR_pal_static -vr_KSVR_static -vr_KSVR_pal_static -vr_GLVR_static -vr_GLVR_pal_static -vr_ZRVR_static -vr_ZRVR_pal_static -vr_DGVR_static -vr_DGVR_pal_static -vr_ALVR_static -vr_ALVR_pal_static -vr_NSVR_static -vr_NSVR_pal_static -vr_LBVR_static -vr_LBVR_pal_static -vr_TTVR_static -vr_TTVR_pal_static -vr_FCVR_static -vr_FCVR_pal_static -elf_message_field -elf_message_ydan -ydan_scene -ydan_room_0 -ydan_room_1 -ydan_room_2 -ydan_room_3 -ydan_room_4 -ydan_room_5 -ydan_room_6 -ydan_room_7 -ydan_room_8 -ydan_room_9 -ydan_room_10 -ydan_room_11 -ddan_scene -ddan_room_0 -ddan_room_1 -ddan_room_2 -ddan_room_3 -ddan_room_4 -ddan_room_5 -ddan_room_6 -ddan_room_7 -ddan_room_8 -ddan_room_9 -ddan_room_10 -ddan_room_11 -ddan_room_12 -ddan_room_13 -ddan_room_14 -ddan_room_15 -ddan_room_16 -bdan_scene -bdan_room_0 -bdan_room_1 -bdan_room_2 -bdan_room_3 -bdan_room_4 -bdan_room_5 -bdan_room_6 -bdan_room_7 -bdan_room_8 -bdan_room_9 -bdan_room_10 -bdan_room_11 -bdan_room_12 -bdan_room_13 -bdan_room_14 -bdan_room_15 -Bmori1_scene -Bmori1_room_0 -Bmori1_room_1 -Bmori1_room_2 -Bmori1_room_3 -Bmori1_room_4 -Bmori1_room_5 -Bmori1_room_6 -Bmori1_room_7 -Bmori1_room_8 -Bmori1_room_9 -Bmori1_room_10 -Bmori1_room_11 -Bmori1_room_12 -Bmori1_room_13 -Bmori1_room_14 -Bmori1_room_15 -Bmori1_room_16 -Bmori1_room_17 -Bmori1_room_18 -Bmori1_room_19 -Bmori1_room_20 -Bmori1_room_21 -Bmori1_room_22 -HIDAN_scene -HIDAN_room_0 -HIDAN_room_1 -HIDAN_room_2 -HIDAN_room_3 -HIDAN_room_4 -HIDAN_room_5 -HIDAN_room_6 -HIDAN_room_7 -HIDAN_room_8 -HIDAN_room_9 -HIDAN_room_10 -HIDAN_room_11 -HIDAN_room_12 -HIDAN_room_13 -HIDAN_room_14 -HIDAN_room_15 -HIDAN_room_16 -HIDAN_room_17 -HIDAN_room_18 -HIDAN_room_19 -HIDAN_room_20 -HIDAN_room_21 -HIDAN_room_22 -HIDAN_room_23 -HIDAN_room_24 -HIDAN_room_25 -HIDAN_room_26 -MIZUsin_scene -MIZUsin_room_0 -MIZUsin_room_1 -MIZUsin_room_2 -MIZUsin_room_3 -MIZUsin_room_4 -MIZUsin_room_5 -MIZUsin_room_6 -MIZUsin_room_7 -MIZUsin_room_8 -MIZUsin_room_9 -MIZUsin_room_10 -MIZUsin_room_11 -MIZUsin_room_12 -MIZUsin_room_13 -MIZUsin_room_14 -MIZUsin_room_15 -MIZUsin_room_16 -MIZUsin_room_17 -MIZUsin_room_18 -MIZUsin_room_19 -MIZUsin_room_20 -MIZUsin_room_21 -MIZUsin_room_22 -jyasinzou_scene -jyasinzou_room_0 -jyasinzou_room_1 -jyasinzou_room_2 -jyasinzou_room_3 -jyasinzou_room_4 -jyasinzou_room_5 -jyasinzou_room_6 -jyasinzou_room_7 -jyasinzou_room_8 -jyasinzou_room_9 -jyasinzou_room_10 -jyasinzou_room_11 -jyasinzou_room_12 -jyasinzou_room_13 -jyasinzou_room_14 -jyasinzou_room_15 -jyasinzou_room_16 -jyasinzou_room_17 -jyasinzou_room_18 -jyasinzou_room_19 -jyasinzou_room_20 -jyasinzou_room_21 -jyasinzou_room_22 -jyasinzou_room_23 -jyasinzou_room_24 -jyasinzou_room_25 -jyasinzou_room_26 -jyasinzou_room_27 -jyasinzou_room_28 -HAKAdan_scene -HAKAdan_room_0 -HAKAdan_room_1 -HAKAdan_room_2 -HAKAdan_room_3 -HAKAdan_room_4 -HAKAdan_room_5 -HAKAdan_room_6 -HAKAdan_room_7 -HAKAdan_room_8 -HAKAdan_room_9 -HAKAdan_room_10 -HAKAdan_room_11 -HAKAdan_room_12 -HAKAdan_room_13 -HAKAdan_room_14 -HAKAdan_room_15 -HAKAdan_room_16 -HAKAdan_room_17 -HAKAdan_room_18 -HAKAdan_room_19 -HAKAdan_room_20 -HAKAdan_room_21 -HAKAdan_room_22 -HAKAdanCH_scene -HAKAdanCH_room_0 -HAKAdanCH_room_1 -HAKAdanCH_room_2 -HAKAdanCH_room_3 -HAKAdanCH_room_4 -HAKAdanCH_room_5 -HAKAdanCH_room_6 -ice_doukutu_scene -ice_doukutu_room_0 -ice_doukutu_room_1 -ice_doukutu_room_2 -ice_doukutu_room_3 -ice_doukutu_room_4 -ice_doukutu_room_5 -ice_doukutu_room_6 -ice_doukutu_room_7 -ice_doukutu_room_8 -ice_doukutu_room_9 -ice_doukutu_room_10 -ice_doukutu_room_11 -men_scene -men_room_0 -men_room_1 -men_room_2 -men_room_3 -men_room_4 -men_room_5 -men_room_6 -men_room_7 -men_room_8 -men_room_9 -men_room_10 -ganontika_scene -ganontika_room_0 -ganontika_room_1 -ganontika_room_2 -ganontika_room_3 -ganontika_room_4 -ganontika_room_5 -ganontika_room_6 -ganontika_room_7 -ganontika_room_8 -ganontika_room_9 -ganontika_room_10 -ganontika_room_11 -ganontika_room_12 -ganontika_room_13 -ganontika_room_14 -ganontika_room_15 -ganontika_room_16 -ganontika_room_17 -ganontika_room_18 -ganontika_room_19 -spot00_scene -spot00_room_0 -spot01_scene -spot01_room_0 -spot02_scene -spot02_room_0 -spot02_room_1 -spot03_scene -spot03_room_0 -spot03_room_1 -spot04_scene -spot04_room_0 -spot04_room_1 -spot04_room_2 -spot05_scene -spot05_room_0 -spot06_scene -spot06_room_0 -spot07_scene -spot07_room_0 -spot07_room_1 -spot08_scene -spot08_room_0 -spot09_scene -spot09_room_0 -spot10_scene -spot10_room_0 -spot10_room_1 -spot10_room_2 -spot10_room_3 -spot10_room_4 -spot10_room_5 -spot10_room_6 -spot10_room_7 -spot10_room_8 -spot10_room_9 -spot11_scene -spot11_room_0 -spot12_scene -spot12_room_0 -spot12_room_1 -spot13_scene -spot13_room_0 -spot13_room_1 -spot15_scene -spot15_room_0 -spot16_scene -spot16_room_0 -spot17_scene -spot17_room_0 -spot17_room_1 -spot18_scene -spot18_room_0 -spot18_room_1 -spot18_room_2 -spot18_room_3 -market_day_scene -market_day_room_0 -market_night_scene -market_night_room_0 -kenjyanoma_scene -kenjyanoma_room_0 -tokinoma_scene -tokinoma_room_0 -tokinoma_room_1 -link_home_scene -link_home_room_0 -kokiri_shop_scene -kokiri_shop_room_0 -kokiri_home_scene -kokiri_home_room_0 -kakusiana_scene -kakusiana_room_0 -kakusiana_room_1 -kakusiana_room_2 -kakusiana_room_3 -kakusiana_room_4 -kakusiana_room_5 -kakusiana_room_6 -kakusiana_room_7 -kakusiana_room_8 -kakusiana_room_9 -kakusiana_room_10 -kakusiana_room_11 -kakusiana_room_12 -kakusiana_room_13 -entra_scene -entra_room_0 -moribossroom_scene -moribossroom_room_0 -moribossroom_room_1 -syatekijyou_scene -syatekijyou_room_0 -shop1_scene -shop1_room_0 -hairal_niwa_scene -hairal_niwa_room_0 -ganon_tou_scene -ganon_tou_room_0 -market_alley_scene -market_alley_room_0 -spot20_scene -spot20_room_0 -market_ruins_scene -market_ruins_room_0 -entra_n_scene -entra_n_room_0 -enrui_scene -enrui_room_0 -market_alley_n_scene -market_alley_n_room_0 -hiral_demo_scene -hiral_demo_room_0 -kokiri_home3_scene -kokiri_home3_room_0 -malon_stable_scene -malon_stable_room_0 -kakariko_scene -kakariko_room_0 -bdan_boss_scene -bdan_boss_room_0 -bdan_boss_room_1 -FIRE_bs_scene -FIRE_bs_room_0 -FIRE_bs_room_1 -hut_scene -hut_room_0 -daiyousei_izumi_scene -daiyousei_izumi_room_0 -hakaana_scene -hakaana_room_0 -yousei_izumi_tate_scene -yousei_izumi_tate_room_0 -yousei_izumi_yoko_scene -yousei_izumi_yoko_room_0 -golon_scene -golon_room_0 -zoora_scene -zoora_room_0 -drag_scene -drag_room_0 -alley_shop_scene -alley_shop_room_0 -night_shop_scene -night_shop_room_0 -impa_scene -impa_room_0 -labo_scene -labo_room_0 -tent_scene -tent_room_0 -nakaniwa_scene -nakaniwa_room_0 -ddan_boss_scene -ddan_boss_room_0 -ddan_boss_room_1 -ydan_boss_scene -ydan_boss_room_0 -ydan_boss_room_1 -HAKAdan_bs_scene -HAKAdan_bs_room_0 -HAKAdan_bs_room_1 -MIZUsin_bs_scene -MIZUsin_bs_room_0 -MIZUsin_bs_room_1 -ganon_scene -ganon_room_0 -ganon_room_1 -ganon_room_2 -ganon_room_3 -ganon_room_4 -ganon_room_5 -ganon_room_6 -ganon_room_7 -ganon_room_8 -ganon_room_9 -ganon_boss_scene -ganon_boss_room_0 -jyasinboss_scene -jyasinboss_room_0 -jyasinboss_room_1 -jyasinboss_room_2 -jyasinboss_room_3 -kokiri_home4_scene -kokiri_home4_room_0 -kokiri_home5_scene -kokiri_home5_room_0 -ganon_final_scene -ganon_final_room_0 -kakariko3_scene -kakariko3_room_0 -hakasitarelay_scene -hakasitarelay_room_0 -hakasitarelay_room_1 -hakasitarelay_room_2 -hakasitarelay_room_3 -hakasitarelay_room_4 -hakasitarelay_room_5 -hakasitarelay_room_6 -shrine_scene -shrine_room_0 -turibori_scene -turibori_room_0 -shrine_n_scene -shrine_n_room_0 -shrine_r_scene -shrine_r_room_0 -hakaana2_scene -hakaana2_room_0 -gerudoway_scene -gerudoway_room_0 -gerudoway_room_1 -gerudoway_room_2 -gerudoway_room_3 -gerudoway_room_4 -gerudoway_room_5 -hairal_niwa_n_scene -hairal_niwa_n_room_0 -bowling_scene -bowling_room_0 -hakaana_ouke_scene -hakaana_ouke_room_0 -hakaana_ouke_room_1 -hakaana_ouke_room_2 -hylia_labo_scene -hylia_labo_room_0 -souko_scene -souko_room_0 -souko_room_1 -souko_room_2 -miharigoya_scene -miharigoya_room_0 -mahouya_scene -mahouya_room_0 -takaraya_scene -takaraya_room_0 -takaraya_room_1 -takaraya_room_2 -takaraya_room_3 -takaraya_room_4 -takaraya_room_5 -takaraya_room_6 -ganon_sonogo_scene -ganon_sonogo_room_0 -ganon_sonogo_room_1 -ganon_sonogo_room_2 -ganon_sonogo_room_3 -ganon_sonogo_room_4 -ganon_demo_scene -ganon_demo_room_0 -face_shop_scene -face_shop_room_0 -kinsuta_scene -kinsuta_room_0 -ganontikasonogo_scene -ganontikasonogo_room_0 -ganontikasonogo_room_1 -bump_texture_static -anime_model_1_static -anime_model_2_static -anime_model_3_static -anime_model_4_static -anime_model_5_static -anime_model_6_static -anime_texture_1_static -anime_texture_2_static -anime_texture_3_static -anime_texture_4_static -anime_texture_5_static -anime_texture_6_static -softsprite_matrix_static \ No newline at end of file diff --git a/OTRExporter/CFG/filelists/pal_oot.txt b/OTRExporter/CFG/filelists/pal_oot.txt deleted file mode 100644 index 812d3ebdd..000000000 --- a/OTRExporter/CFG/filelists/pal_oot.txt +++ /dev/null @@ -1,1511 +0,0 @@ -makerom -boot -dmadata -Audiobank -Audioseq -Audiotable -link_animetion -icon_item_static -icon_item_24_static -icon_item_field_static -icon_item_dungeon_static -icon_item_gameover_static -icon_item_nes_static -icon_item_ger_static -icon_item_fra_static -item_name_static -map_name_static -do_action_static -message_static -message_texture_static -nes_font_static -nes_message_data_static -ger_message_data_static -fra_message_data_static -staff_message_data_static -map_grand_static -map_i_static -map_48x85_static -code -n64dd -ovl_title -ovl_select -ovl_opening -ovl_file_choose -ovl_kaleido_scope -ovl_player_actor -ovl_map_mark_data -ovl_En_Test -ovl_En_GirlA -ovl_En_Part -ovl_En_Light -ovl_En_Door -ovl_En_Box -ovl_En_Poh -ovl_En_Okuta -ovl_En_Bom -ovl_En_Wallmas -ovl_En_Dodongo -ovl_En_Firefly -ovl_En_Horse -ovl_En_Arrow -ovl_En_Elf -ovl_En_Niw -ovl_En_Tite -ovl_En_Reeba -ovl_En_Peehat -ovl_En_Holl -ovl_En_Scene_Change -ovl_En_Zf -ovl_En_Hata -ovl_Boss_Dodongo -ovl_Boss_Goma -ovl_En_Zl1 -ovl_En_Viewer -ovl_En_Goma -ovl_Bg_Pushbox -ovl_En_Bubble -ovl_Door_Shutter -ovl_En_Dodojr -ovl_En_Bdfire -ovl_En_Boom -ovl_En_Torch2 -ovl_En_Bili -ovl_En_Tp -ovl_En_St -ovl_En_Bw -ovl_En_Eiyer -ovl_En_River_Sound -ovl_En_Horse_Normal -ovl_En_Ossan -ovl_Bg_Treemouth -ovl_Bg_Dodoago -ovl_Bg_Hidan_Dalm -ovl_Bg_Hidan_Hrock -ovl_En_Horse_Ganon -ovl_Bg_Hidan_Rock -ovl_Bg_Hidan_Rsekizou -ovl_Bg_Hidan_Sekizou -ovl_Bg_Hidan_Sima -ovl_Bg_Hidan_Syoku -ovl_En_Xc -ovl_Bg_Hidan_Curtain -ovl_Bg_Spot00_Hanebasi -ovl_En_Mb -ovl_En_Bombf -ovl_Bg_Hidan_Firewall -ovl_Bg_Dy_Yoseizo -ovl_En_Zl2 -ovl_Bg_Hidan_Fslift -ovl_En_OE2 -ovl_Bg_Ydan_Hasi -ovl_Bg_Ydan_Maruta -ovl_Boss_Ganondrof -ovl_En_Am -ovl_En_Dekubaba -ovl_En_M_Fire1 -ovl_En_M_Thunder -ovl_Bg_Ddan_Jd -ovl_Bg_Breakwall -ovl_En_Jj -ovl_En_Horse_Zelda -ovl_Bg_Ddan_Kd -ovl_Door_Warp1 -ovl_Obj_Syokudai -ovl_Item_B_Heart -ovl_En_Dekunuts -ovl_Bg_Menkuri_Kaiten -ovl_Bg_Menkuri_Eye -ovl_En_Vali -ovl_Bg_Mizu_Movebg -ovl_Bg_Mizu_Water -ovl_Arms_Hook -ovl_En_fHG -ovl_Bg_Mori_Hineri -ovl_En_Bb -ovl_Bg_Toki_Hikari -ovl_En_Yukabyun -ovl_Bg_Toki_Swd -ovl_En_Fhg_Fire -ovl_Bg_Mjin -ovl_Bg_Hidan_Kousi -ovl_Door_Toki -ovl_Bg_Hidan_Hamstep -ovl_En_Bird -ovl_En_Wood02 -ovl_En_Lightbox -ovl_En_Pu_box -ovl_En_Trap -ovl_En_Arow_Trap -ovl_En_Vase -ovl_En_Ta -ovl_En_Tk -ovl_Bg_Mori_Bigst -ovl_Bg_Mori_Elevator -ovl_Bg_Mori_Kaitenkabe -ovl_Bg_Mori_Rakkatenjo -ovl_En_Vm -ovl_Demo_Effect -ovl_Demo_Kankyo -ovl_Bg_Hidan_Fwbig -ovl_En_Floormas -ovl_En_Heishi1 -ovl_En_Rd -ovl_En_Po_Sisters -ovl_Bg_Heavy_Block -ovl_Bg_Po_Event -ovl_Obj_Mure -ovl_En_Sw -ovl_Boss_Fd -ovl_Object_Kankyo -ovl_En_Du -ovl_En_Fd -ovl_En_Horse_Link_Child -ovl_Door_Ana -ovl_Bg_Spot02_Objects -ovl_Bg_Haka -ovl_Magic_Wind -ovl_Magic_Fire -ovl_En_Ru1 -ovl_Boss_Fd2 -ovl_En_Fd_Fire -ovl_En_Dh -ovl_En_Dha -ovl_En_Rl -ovl_En_Encount1 -ovl_Demo_Du -ovl_Demo_Im -ovl_Demo_Tre_Lgt -ovl_En_Fw -ovl_Bg_Vb_Sima -ovl_En_Vb_Ball -ovl_Bg_Haka_Megane -ovl_Bg_Haka_MeganeBG -ovl_Bg_Haka_Ship -ovl_Bg_Haka_Sgami -ovl_En_Heishi2 -ovl_En_Encount2 -ovl_En_Fire_Rock -ovl_En_Brob -ovl_Mir_Ray -ovl_Bg_Spot09_Obj -ovl_Bg_Spot18_Obj -ovl_Boss_Va -ovl_Bg_Haka_Tubo -ovl_Bg_Haka_Trap -ovl_Bg_Haka_Huta -ovl_Bg_Haka_Zou -ovl_Bg_Spot17_Funen -ovl_En_Syateki_Itm -ovl_En_Syateki_Man -ovl_En_Tana -ovl_En_Nb -ovl_Boss_Mo -ovl_En_Sb -ovl_En_Bigokuta -ovl_En_Karebaba -ovl_Bg_Bdan_Objects -ovl_Demo_Sa -ovl_Demo_Go -ovl_En_In -ovl_En_Tr -ovl_Bg_Spot16_Bombstone -ovl_Bg_Hidan_Kowarerukabe -ovl_Bg_Bombwall -ovl_En_Ru2 -ovl_Obj_Dekujr -ovl_Bg_Mizu_Uzu -ovl_Bg_Spot06_Objects -ovl_Bg_Ice_Objects -ovl_Bg_Haka_Water -ovl_En_Ma2 -ovl_En_Bom_Chu -ovl_En_Horse_Game_Check -ovl_Boss_Tw -ovl_En_Rr -ovl_En_Ba -ovl_En_Bx -ovl_En_Anubice -ovl_En_Anubice_Fire -ovl_Bg_Mori_Hashigo -ovl_Bg_Mori_Hashira4 -ovl_Bg_Mori_Idomizu -ovl_Bg_Spot16_Doughnut -ovl_Bg_Bdan_Switch -ovl_En_Ma1 -ovl_Boss_Ganon -ovl_Boss_Sst -ovl_En_Ny -ovl_En_Fr -ovl_Item_Shield -ovl_Bg_Ice_Shelter -ovl_En_Ice_Hono -ovl_Item_Ocarina -ovl_Magic_Dark -ovl_Demo_6K -ovl_En_Anubice_Tag -ovl_Bg_Haka_Gate -ovl_Bg_Spot15_Saku -ovl_Bg_Jya_Goroiwa -ovl_Bg_Jya_Zurerukabe -ovl_Bg_Jya_Cobra -ovl_Bg_Jya_Kanaami -ovl_Fishing -ovl_Obj_Oshihiki -ovl_Bg_Gate_Shutter -ovl_Eff_Dust -ovl_Bg_Spot01_Fusya -ovl_Bg_Spot01_Idohashira -ovl_Bg_Spot01_Idomizu -ovl_Bg_Po_Syokudai -ovl_Bg_Ganon_Otyuka -ovl_Bg_Spot15_Rrbox -ovl_Bg_Umajump -ovl_En_Insect -ovl_En_Butte -ovl_En_Fish -ovl_Bg_Spot08_Iceblock -ovl_Item_Etcetera -ovl_Arrow_Fire -ovl_Arrow_Ice -ovl_Arrow_Light -ovl_Obj_Kibako -ovl_Obj_Tsubo -ovl_En_Wonder_Item -ovl_En_Ik -ovl_Demo_Ik -ovl_En_Skj -ovl_En_Skjneedle -ovl_En_G_Switch -ovl_Demo_Ext -ovl_Demo_Shd -ovl_En_Dns -ovl_Elf_Msg -ovl_En_Honotrap -ovl_En_Tubo_Trap -ovl_Obj_Ice_Poly -ovl_Bg_Spot03_Taki -ovl_Bg_Spot07_Taki -ovl_En_Fz -ovl_En_Po_Relay -ovl_Bg_Relay_Objects -ovl_En_Diving_Game -ovl_En_Kusa -ovl_Obj_Bean -ovl_Obj_Bombiwa -ovl_Obj_Switch -ovl_Obj_Elevator -ovl_Obj_Lift -ovl_Obj_Hsblock -ovl_En_Okarina_Tag -ovl_En_Yabusame_Mark -ovl_En_Goroiwa -ovl_En_Ex_Ruppy -ovl_En_Toryo -ovl_En_Daiku -ovl_En_Nwc -ovl_En_Blkobj -ovl_Item_Inbox -ovl_En_Ge1 -ovl_Obj_Blockstop -ovl_En_Sda -ovl_En_Clear_Tag -ovl_En_Niw_Lady -ovl_En_Gm -ovl_En_Ms -ovl_En_Hs -ovl_Bg_Ingate -ovl_En_Kanban -ovl_En_Heishi3 -ovl_En_Syateki_Niw -ovl_En_Attack_Niw -ovl_Bg_Spot01_Idosoko -ovl_En_Sa -ovl_En_Wonder_Talk -ovl_Bg_Gjyo_Bridge -ovl_En_Ds -ovl_En_Mk -ovl_En_Bom_Bowl_Man -ovl_En_Bom_Bowl_Pit -ovl_En_Owl -ovl_En_Ishi -ovl_Obj_Hana -ovl_Obj_Lightswitch -ovl_Obj_Mure2 -ovl_En_Go -ovl_En_Fu -ovl_En_Changer -ovl_Bg_Jya_Megami -ovl_Bg_Jya_Lift -ovl_Bg_Jya_Bigmirror -ovl_Bg_Jya_Bombchuiwa -ovl_Bg_Jya_Amishutter -ovl_Bg_Jya_Bombiwa -ovl_Bg_Spot18_Basket -ovl_En_Ganon_Organ -ovl_En_Siofuki -ovl_En_Stream -ovl_En_Mm -ovl_En_Ko -ovl_En_Kz -ovl_En_Weather_Tag -ovl_Bg_Sst_Floor -ovl_En_Ani -ovl_En_Ex_Item -ovl_Bg_Jya_Ironobj -ovl_En_Js -ovl_En_Jsjutan -ovl_En_Cs -ovl_En_Md -ovl_En_Hy -ovl_En_Ganon_Mant -ovl_En_Okarina_Effect -ovl_En_Mag -ovl_Door_Gerudo -ovl_Elf_Msg2 -ovl_Demo_Gt -ovl_En_Po_Field -ovl_Efc_Erupc -ovl_Bg_Zg -ovl_En_Heishi4 -ovl_En_Zl3 -ovl_Boss_Ganon2 -ovl_En_Kakasi -ovl_En_Takara_Man -ovl_Obj_Makeoshihiki -ovl_Oceff_Spot -ovl_End_Title -ovl_En_Torch -ovl_Demo_Ec -ovl_Shot_Sun -ovl_En_Dy_Extra -ovl_En_Wonder_Talk2 -ovl_En_Ge2 -ovl_Obj_Roomtimer -ovl_En_Ssh -ovl_En_Sth -ovl_Oceff_Wipe -ovl_Effect_Ss_Dust -ovl_Effect_Ss_KiraKira -ovl_Effect_Ss_Bomb -ovl_Effect_Ss_Bomb2 -ovl_Effect_Ss_Blast -ovl_Effect_Ss_G_Spk -ovl_Effect_Ss_D_Fire -ovl_Effect_Ss_Bubble -ovl_Effect_Ss_G_Ripple -ovl_Effect_Ss_G_Splash -ovl_Effect_Ss_G_Magma -ovl_Effect_Ss_G_Fire -ovl_Effect_Ss_Lightning -ovl_Effect_Ss_Dt_Bubble -ovl_Effect_Ss_Hahen -ovl_Effect_Ss_Stick -ovl_Effect_Ss_Sibuki -ovl_Effect_Ss_Sibuki2 -ovl_Effect_Ss_G_Magma2 -ovl_Effect_Ss_Stone1 -ovl_Effect_Ss_HitMark -ovl_Effect_Ss_Fhg_Flash -ovl_Effect_Ss_K_Fire -ovl_Effect_Ss_Solder_Srch_Ball -ovl_Effect_Ss_Kakera -ovl_Effect_Ss_Ice_Piece -ovl_Effect_Ss_En_Ice -ovl_Effect_Ss_Fire_Tail -ovl_Effect_Ss_En_Fire -ovl_Effect_Ss_Extra -ovl_Effect_Ss_Fcircle -ovl_Effect_Ss_Dead_Db -ovl_Effect_Ss_Dead_Dd -ovl_Effect_Ss_Dead_Ds -ovl_Effect_Ss_Dead_Sound -ovl_Oceff_Storm -ovl_En_Weiyer -ovl_Bg_Spot05_Soko -ovl_Bg_Jya_1flift -ovl_Bg_Jya_Haheniron -ovl_Bg_Spot12_Gate -ovl_Bg_Spot12_Saku -ovl_En_Hintnuts -ovl_En_Nutsball -ovl_Bg_Spot00_Break -ovl_En_Shopnuts -ovl_En_It -ovl_En_GeldB -ovl_Oceff_Wipe2 -ovl_Oceff_Wipe3 -ovl_En_Niw_Girl -ovl_En_Dog -ovl_En_Si -ovl_Bg_Spot01_Objects2 -ovl_Obj_Comb -ovl_Bg_Spot11_Bakudankabe -ovl_Obj_Kibako2 -ovl_En_Dnt_Demo -ovl_En_Dnt_Jiji -ovl_En_Dnt_Nomal -ovl_En_Guest -ovl_Bg_Bom_Guard -ovl_En_Hs2 -ovl_Demo_Kekkai -ovl_Bg_Spot08_Bakudankabe -ovl_Bg_Spot17_Bakudankabe -ovl_Obj_Mure3 -ovl_En_Tg -ovl_En_Mu -ovl_En_Go2 -ovl_En_Wf -ovl_En_Skb -ovl_Demo_Gj -ovl_Demo_Geff -ovl_Bg_Gnd_Firemeiro -ovl_Bg_Gnd_Darkmeiro -ovl_Bg_Gnd_Soulmeiro -ovl_Bg_Gnd_Nisekabe -ovl_Bg_Gnd_Iceblock -ovl_Bg_Ydan_Sp -ovl_En_Gb -ovl_En_Gs -ovl_Bg_Mizu_Bwall -ovl_Bg_Mizu_Shutter -ovl_En_Daiku_Kakariko -ovl_Bg_Bowl_Wall -ovl_En_Wall_Tubo -ovl_En_Po_Desert -ovl_En_Crow -ovl_Door_Killer -ovl_Bg_Spot11_Oasis -ovl_Bg_Spot18_Futa -ovl_Bg_Spot18_Shutter -ovl_En_Ma3 -ovl_En_Cow -ovl_Bg_Ice_Turara -ovl_Bg_Ice_Shutter -ovl_En_Kakasi2 -ovl_En_Kakasi3 -ovl_Oceff_Wipe4 -ovl_En_Eg -ovl_Bg_Menkuri_Nisekabe -ovl_En_Zo -ovl_Effect_Ss_Ice_Smoke -ovl_Obj_Makekinsuta -ovl_En_Ge3 -ovl_Obj_Timeblock -ovl_Obj_Hamishi -ovl_En_Zl4 -ovl_En_Mm2 -ovl_Bg_Jya_Block -ovl_Obj_Warp2block -gameplay_keep -gameplay_field_keep -gameplay_dangeon_keep -gameplay_object_exchange_static -object_link_boy -object_link_child -object_box -object_human -object_okuta -object_poh -object_wallmaster -object_dy_obj -object_firefly -object_dodongo -object_fire -object_niw -object_tite -object_reeba -object_peehat -object_kingdodongo -object_horse -object_zf -object_goma -object_zl1 -object_gol -object_bubble -object_dodojr -object_torch2 -object_bl -object_tp -object_oA1 -object_st -object_bw -object_ei -object_horse_normal -object_oB1 -object_o_anime -object_spot04_objects -object_ddan_objects -object_hidan_objects -object_horse_ganon -object_oA2 -object_spot00_objects -object_mb -object_bombf -object_sk2 -object_oE1 -object_oE_anime -object_oE2 -object_ydan_objects -object_gnd -object_am -object_dekubaba -object_oA3 -object_oA4 -object_oA5 -object_oA6 -object_oA7 -object_jj -object_oA8 -object_oA9 -object_oB2 -object_oB3 -object_oB4 -object_horse_zelda -object_opening_demo1 -object_warp1 -object_b_heart -object_dekunuts -object_oE3 -object_oE4 -object_menkuri_objects -object_oE5 -object_oE6 -object_oE7 -object_oE8 -object_oE9 -object_oE10 -object_oE11 -object_oE12 -object_vali -object_oA10 -object_oA11 -object_mizu_objects -object_fhg -object_ossan -object_mori_hineri1 -object_Bb -object_toki_objects -object_yukabyun -object_zl2 -object_mjin -object_mjin_flash -object_mjin_dark -object_mjin_flame -object_mjin_ice -object_mjin_soul -object_mjin_wind -object_mjin_oka -object_haka_objects -object_spot06_objects -object_ice_objects -object_relay_objects -object_mori_hineri1a -object_mori_hineri2 -object_mori_hineri2a -object_mori_objects -object_mori_tex -object_spot08_obj -object_warp2 -object_hata -object_bird -object_wood02 -object_lightbox -object_pu_box -object_trap -object_vase -object_im -object_ta -object_tk -object_xc -object_vm -object_bv -object_hakach_objects -object_efc_crystal_light -object_efc_fire_ball -object_efc_flash -object_efc_lgt_shower -object_efc_star_field -object_god_lgt -object_light_ring -object_triforce_spot -object_medal -object_bdan_objects -object_sd -object_rd -object_po_sisters -object_heavy_object -object_gndd -object_fd -object_du -object_fw -object_horse_link_child -object_spot02_objects -object_haka -object_ru1 -object_syokudai -object_fd2 -object_dh -object_rl -object_efc_tw -object_demo_tre_lgt -object_gi_key -object_mir_ray -object_brob -object_gi_jewel -object_spot09_obj -object_spot18_obj -object_bdoor -object_spot17_obj -object_shop_dungen -object_nb -object_mo -object_sb -object_gi_melody -object_gi_heart -object_gi_compass -object_gi_bosskey -object_gi_medal -object_gi_nuts -object_sa -object_gi_hearts -object_gi_arrowcase -object_gi_bombpouch -object_in -object_tr -object_spot16_obj -object_oE1s -object_oE4s -object_os_anime -object_gi_bottle -object_gi_stick -object_gi_map -object_oF1d_map -object_ru2 -object_gi_shield_1 -object_dekujr -object_gi_magicpot -object_gi_bomb_1 -object_oF1s -object_ma2 -object_gi_purse -object_hni -object_tw -object_rr -object_bxa -object_anubice -object_gi_gerudo -object_gi_arrow -object_gi_bomb_2 -object_gi_egg -object_gi_scale -object_gi_shield_2 -object_gi_hookshot -object_gi_ocarina -object_gi_milk -object_ma1 -object_ganon -object_sst -object_ny -object_fr -object_gi_pachinko -object_gi_boomerang -object_gi_bow -object_gi_glasses -object_gi_liquid -object_ani -object_demo_6k -object_gi_shield_3 -object_gi_letter -object_spot15_obj -object_jya_obj -object_gi_clothes -object_gi_bean -object_gi_fish -object_gi_saw -object_gi_hammer -object_gi_grass -object_gi_longsword -object_spot01_objects -object_md -object_km1 -object_kw1 -object_zo -object_kz -object_umajump -object_masterkokiri -object_masterkokirihead -object_mastergolon -object_masterzoora -object_aob -object_ik -object_ahg -object_cne -object_gi_niwatori -object_skj -object_gi_bottle_letter -object_bji -object_bba -object_gi_ocarina_0 -object_ds -object_ane -object_boj -object_spot03_object -object_spot07_object -object_fz -object_bob -object_ge1 -object_yabusame_point -object_gi_boots_2 -object_gi_seed -object_gnd_magic -object_d_elevator -object_d_hsblock -object_d_lift -object_mamenoki -object_goroiwa -object_toryo -object_daiku -object_nwc -object_blkobj -object_gm -object_ms -object_hs -object_ingate -object_lightswitch -object_kusa -object_tsubo -object_gi_gloves -object_gi_coin -object_kanban -object_gjyo_objects -object_owl -object_mk -object_fu -object_gi_ki_tan_mask -object_gi_redead_mask -object_gi_skj_mask -object_gi_rabit_mask -object_gi_truth_mask -object_ganon_objects -object_siofuki -object_stream -object_mm -object_fa -object_os -object_gi_eye_lotion -object_gi_powder -object_gi_mushroom -object_gi_ticketstone -object_gi_brokensword -object_js -object_cs -object_gi_prescription -object_gi_bracelet -object_gi_soldout -object_gi_frog -object_mag -object_door_gerudo -object_gt -object_efc_erupc -object_zl2_anime1 -object_zl2_anime2 -object_gi_golonmask -object_gi_zoramask -object_gi_gerudomask -object_ganon2 -object_ka -object_ts -object_zg -object_gi_hoverboots -object_gi_m_arrow -object_ds2 -object_ec -object_fish -object_gi_sutaru -object_gi_goddess -object_ssh -object_bigokuta -object_bg -object_spot05_objects -object_spot12_obj -object_bombiwa -object_hintnuts -object_rs -object_spot00_break -object_gla -object_shopnuts -object_geldb -object_gr -object_dog -object_jya_iron -object_jya_door -object_spot01_objects2 -object_spot11_obj -object_kibako2 -object_dns -object_dnk -object_gi_fire -object_gi_insect -object_gi_butterfly -object_gi_ghost -object_gi_soul -object_bowl -object_po_field -object_demo_kekkai -object_efc_doughnut -object_gi_dekupouch -object_ganon_anime1 -object_ganon_anime2 -object_ganon_anime3 -object_gi_rupy -object_spot01_matoya -object_spot01_matoyab -object_po_composer -object_mu -object_wf -object_skb -object_gj -object_geff -object_haka_door -object_gs -object_ps -object_bwall -object_crow -object_cow -object_cob -object_gi_sword_1 -object_door_killer -object_ouke_haka -object_timeblock -object_zl4 -g_pn_01 -g_pn_02 -g_pn_03 -g_pn_04 -g_pn_05 -g_pn_06 -g_pn_07 -g_pn_08 -g_pn_09 -g_pn_10 -g_pn_11 -g_pn_12 -g_pn_13 -g_pn_14 -g_pn_15 -g_pn_16 -g_pn_17 -g_pn_18 -g_pn_19 -g_pn_20 -g_pn_21 -g_pn_22 -g_pn_23 -g_pn_24 -g_pn_25 -g_pn_26 -g_pn_27 -g_pn_28 -g_pn_29 -g_pn_30 -g_pn_31 -g_pn_32 -g_pn_33 -g_pn_34 -g_pn_35 -g_pn_36 -g_pn_37 -g_pn_38 -g_pn_39 -g_pn_40 -g_pn_41 -g_pn_42 -g_pn_43 -g_pn_44 -g_pn_45 -g_pn_46 -g_pn_47 -g_pn_48 -g_pn_49 -g_pn_50 -g_pn_51 -g_pn_52 -g_pn_53 -g_pn_54 -g_pn_55 -g_pn_56 -g_pn_57 -z_select_static -nintendo_rogo_static -title_static -parameter_static -vr_fine0_static -vr_fine0_pal_static -vr_fine1_static -vr_fine1_pal_static -vr_fine2_static -vr_fine2_pal_static -vr_fine3_static -vr_fine3_pal_static -vr_cloud0_static -vr_cloud0_pal_static -vr_cloud1_static -vr_cloud1_pal_static -vr_cloud2_static -vr_cloud2_pal_static -vr_cloud3_static -vr_cloud3_pal_static -vr_holy0_static -vr_holy0_pal_static -vr_holy1_static -vr_holy1_pal_static -vr_MDVR_static -vr_MDVR_pal_static -vr_MNVR_static -vr_MNVR_pal_static -vr_RUVR_static -vr_RUVR_pal_static -vr_LHVR_static -vr_LHVR_pal_static -vr_KHVR_static -vr_KHVR_pal_static -vr_K3VR_static -vr_K3VR_pal_static -vr_K4VR_static -vr_K4VR_pal_static -vr_K5VR_static -vr_K5VR_pal_static -vr_SP1a_static -vr_SP1a_pal_static -vr_MLVR_static -vr_MLVR_pal_static -vr_KKRVR_static -vr_KKRVR_pal_static -vr_KR3VR_static -vr_KR3VR_pal_static -vr_IPVR_static -vr_IPVR_pal_static -vr_KSVR_static -vr_KSVR_pal_static -vr_GLVR_static -vr_GLVR_pal_static -vr_ZRVR_static -vr_ZRVR_pal_static -vr_DGVR_static -vr_DGVR_pal_static -vr_ALVR_static -vr_ALVR_pal_static -vr_NSVR_static -vr_NSVR_pal_static -vr_LBVR_static -vr_LBVR_pal_static -vr_TTVR_static -vr_TTVR_pal_static -vr_FCVR_static -vr_FCVR_pal_static -elf_message_field -elf_message_ydan -ddan_scene -ddan_room_0 -ddan_room_1 -ddan_room_2 -ddan_room_3 -ddan_room_4 -ddan_room_5 -ddan_room_6 -ddan_room_7 -ddan_room_8 -ddan_room_9 -ddan_room_10 -ddan_room_11 -ddan_room_12 -ddan_room_13 -ddan_room_14 -ddan_room_15 -ddan_room_16 -spot00_scene -spot00_room_0 -spot01_scene -spot01_room_0 -spot02_scene -spot02_room_0 -spot02_room_1 -spot03_scene -spot03_room_0 -spot03_room_1 -spot04_scene -spot04_room_0 -spot04_room_1 -spot04_room_2 -spot05_scene -spot05_room_0 -spot06_scene -spot06_room_0 -spot07_scene -spot07_room_0 -spot07_room_1 -spot08_scene -spot08_room_0 -spot09_scene -spot09_room_0 -spot10_scene -spot10_room_0 -spot10_room_1 -spot10_room_2 -spot10_room_3 -spot10_room_4 -spot10_room_5 -spot10_room_6 -spot10_room_7 -spot10_room_8 -spot10_room_9 -spot11_scene -spot11_room_0 -spot12_scene -spot12_room_0 -spot12_room_1 -spot13_scene -spot13_room_0 -spot13_room_1 -spot15_scene -spot15_room_0 -spot16_scene -spot16_room_0 -spot17_scene -spot17_room_0 -spot17_room_1 -spot18_scene -spot18_room_0 -spot18_room_1 -spot18_room_2 -spot18_room_3 -market_day_scene -market_day_room_0 -market_night_scene -market_night_room_0 -HIDAN_scene -HIDAN_room_0 -HIDAN_room_1 -HIDAN_room_2 -HIDAN_room_3 -HIDAN_room_4 -HIDAN_room_5 -HIDAN_room_6 -HIDAN_room_7 -HIDAN_room_8 -HIDAN_room_9 -HIDAN_room_10 -HIDAN_room_11 -HIDAN_room_12 -HIDAN_room_13 -HIDAN_room_14 -HIDAN_room_15 -HIDAN_room_16 -HIDAN_room_17 -HIDAN_room_18 -HIDAN_room_19 -HIDAN_room_20 -HIDAN_room_21 -HIDAN_room_22 -HIDAN_room_23 -HIDAN_room_24 -HIDAN_room_25 -HIDAN_room_26 -Bmori1_scene -Bmori1_room_0 -Bmori1_room_1 -Bmori1_room_2 -Bmori1_room_3 -Bmori1_room_4 -Bmori1_room_5 -Bmori1_room_6 -Bmori1_room_7 -Bmori1_room_8 -Bmori1_room_9 -Bmori1_room_10 -Bmori1_room_11 -Bmori1_room_12 -Bmori1_room_13 -Bmori1_room_14 -Bmori1_room_15 -Bmori1_room_16 -Bmori1_room_17 -Bmori1_room_18 -Bmori1_room_19 -Bmori1_room_20 -Bmori1_room_21 -Bmori1_room_22 -ydan_scene -ydan_room_0 -ydan_room_1 -ydan_room_2 -ydan_room_3 -ydan_room_4 -ydan_room_5 -ydan_room_6 -ydan_room_7 -ydan_room_8 -ydan_room_9 -ydan_room_10 -ydan_room_11 -kenjyanoma_scene -kenjyanoma_room_0 -tokinoma_scene -tokinoma_room_0 -tokinoma_room_1 -link_home_scene -link_home_room_0 -kokiri_shop_scene -kokiri_shop_room_0 -MIZUsin_scene -MIZUsin_room_0 -MIZUsin_room_1 -MIZUsin_room_2 -MIZUsin_room_3 -MIZUsin_room_4 -MIZUsin_room_5 -MIZUsin_room_6 -MIZUsin_room_7 -MIZUsin_room_8 -MIZUsin_room_9 -MIZUsin_room_10 -MIZUsin_room_11 -MIZUsin_room_12 -MIZUsin_room_13 -MIZUsin_room_14 -MIZUsin_room_15 -MIZUsin_room_16 -MIZUsin_room_17 -MIZUsin_room_18 -MIZUsin_room_19 -MIZUsin_room_20 -MIZUsin_room_21 -MIZUsin_room_22 -kokiri_home_scene -kokiri_home_room_0 -kakusiana_scene -kakusiana_room_0 -kakusiana_room_1 -kakusiana_room_2 -kakusiana_room_3 -kakusiana_room_4 -kakusiana_room_5 -kakusiana_room_6 -kakusiana_room_7 -kakusiana_room_8 -kakusiana_room_9 -kakusiana_room_10 -kakusiana_room_11 -kakusiana_room_12 -kakusiana_room_13 -entra_scene -entra_room_0 -bdan_scene -bdan_room_0 -bdan_room_1 -bdan_room_2 -bdan_room_3 -bdan_room_4 -bdan_room_5 -bdan_room_6 -bdan_room_7 -bdan_room_8 -bdan_room_9 -bdan_room_10 -bdan_room_11 -bdan_room_12 -bdan_room_13 -bdan_room_14 -bdan_room_15 -HAKAdan_scene -HAKAdan_room_0 -HAKAdan_room_1 -HAKAdan_room_2 -HAKAdan_room_3 -HAKAdan_room_4 -HAKAdan_room_5 -HAKAdan_room_6 -HAKAdan_room_7 -HAKAdan_room_8 -HAKAdan_room_9 -HAKAdan_room_10 -HAKAdan_room_11 -HAKAdan_room_12 -HAKAdan_room_13 -HAKAdan_room_14 -HAKAdan_room_15 -HAKAdan_room_16 -HAKAdan_room_17 -HAKAdan_room_18 -HAKAdan_room_19 -HAKAdan_room_20 -HAKAdan_room_21 -HAKAdan_room_22 -moribossroom_scene -moribossroom_room_0 -moribossroom_room_1 -syatekijyou_scene -syatekijyou_room_0 -men_scene -men_room_0 -men_room_1 -men_room_2 -men_room_3 -men_room_4 -men_room_5 -men_room_6 -men_room_7 -men_room_8 -men_room_9 -men_room_10 -shop1_scene -shop1_room_0 -hairal_niwa_scene -hairal_niwa_room_0 -ganon_tou_scene -ganon_tou_room_0 -market_alley_scene -market_alley_room_0 -spot20_scene -spot20_room_0 -market_ruins_scene -market_ruins_room_0 -entra_n_scene -entra_n_room_0 -enrui_scene -enrui_room_0 -market_alley_n_scene -market_alley_n_room_0 -hiral_demo_scene -hiral_demo_room_0 -kokiri_home3_scene -kokiri_home3_room_0 -jyasinzou_scene -jyasinzou_room_0 -jyasinzou_room_1 -jyasinzou_room_2 -jyasinzou_room_3 -jyasinzou_room_4 -jyasinzou_room_5 -jyasinzou_room_6 -jyasinzou_room_7 -jyasinzou_room_8 -jyasinzou_room_9 -jyasinzou_room_10 -jyasinzou_room_11 -jyasinzou_room_12 -jyasinzou_room_13 -jyasinzou_room_14 -jyasinzou_room_15 -jyasinzou_room_16 -jyasinzou_room_17 -jyasinzou_room_18 -jyasinzou_room_19 -jyasinzou_room_20 -jyasinzou_room_21 -jyasinzou_room_22 -jyasinzou_room_23 -jyasinzou_room_24 -jyasinzou_room_25 -jyasinzou_room_26 -jyasinzou_room_27 -jyasinzou_room_28 -ice_doukutu_scene -ice_doukutu_room_0 -ice_doukutu_room_1 -ice_doukutu_room_2 -ice_doukutu_room_3 -ice_doukutu_room_4 -ice_doukutu_room_5 -ice_doukutu_room_6 -ice_doukutu_room_7 -ice_doukutu_room_8 -ice_doukutu_room_9 -ice_doukutu_room_10 -ice_doukutu_room_11 -malon_stable_scene -malon_stable_room_0 -kakariko_scene -kakariko_room_0 -bdan_boss_scene -bdan_boss_room_0 -bdan_boss_room_1 -FIRE_bs_scene -FIRE_bs_room_0 -FIRE_bs_room_1 -hut_scene -hut_room_0 -daiyousei_izumi_scene -daiyousei_izumi_room_0 -hakaana_scene -hakaana_room_0 -yousei_izumi_tate_scene -yousei_izumi_tate_room_0 -yousei_izumi_yoko_scene -yousei_izumi_yoko_room_0 -golon_scene -golon_room_0 -zoora_scene -zoora_room_0 -drag_scene -drag_room_0 -alley_shop_scene -alley_shop_room_0 -night_shop_scene -night_shop_room_0 -impa_scene -impa_room_0 -labo_scene -labo_room_0 -tent_scene -tent_room_0 -nakaniwa_scene -nakaniwa_room_0 -ddan_boss_scene -ddan_boss_room_0 -ddan_boss_room_1 -ydan_boss_scene -ydan_boss_room_0 -ydan_boss_room_1 -HAKAdan_bs_scene -HAKAdan_bs_room_0 -HAKAdan_bs_room_1 -MIZUsin_bs_scene -MIZUsin_bs_room_0 -MIZUsin_bs_room_1 -ganon_scene -ganon_room_0 -ganon_room_1 -ganon_room_2 -ganon_room_3 -ganon_room_4 -ganon_room_5 -ganon_room_6 -ganon_room_7 -ganon_room_8 -ganon_room_9 -ganon_boss_scene -ganon_boss_room_0 -jyasinboss_scene -jyasinboss_room_0 -jyasinboss_room_1 -jyasinboss_room_2 -jyasinboss_room_3 -kokiri_home4_scene -kokiri_home4_room_0 -kokiri_home5_scene -kokiri_home5_room_0 -ganon_final_scene -ganon_final_room_0 -kakariko3_scene -kakariko3_room_0 -hakasitarelay_scene -hakasitarelay_room_0 -hakasitarelay_room_1 -hakasitarelay_room_2 -hakasitarelay_room_3 -hakasitarelay_room_4 -hakasitarelay_room_5 -hakasitarelay_room_6 -shrine_scene -shrine_room_0 -turibori_scene -turibori_room_0 -shrine_n_scene -shrine_n_room_0 -shrine_r_scene -shrine_r_room_0 -ganontika_scene -ganontika_room_0 -ganontika_room_1 -ganontika_room_2 -ganontika_room_3 -ganontika_room_4 -ganontika_room_5 -ganontika_room_6 -ganontika_room_7 -ganontika_room_8 -ganontika_room_9 -ganontika_room_10 -ganontika_room_11 -ganontika_room_12 -ganontika_room_13 -ganontika_room_14 -ganontika_room_15 -ganontika_room_16 -ganontika_room_17 -ganontika_room_18 -ganontika_room_19 -hakaana2_scene -hakaana2_room_0 -gerudoway_scene -gerudoway_room_0 -gerudoway_room_1 -gerudoway_room_2 -gerudoway_room_3 -gerudoway_room_4 -gerudoway_room_5 -HAKAdanCH_scene -HAKAdanCH_room_0 -HAKAdanCH_room_1 -HAKAdanCH_room_2 -HAKAdanCH_room_3 -HAKAdanCH_room_4 -HAKAdanCH_room_5 -HAKAdanCH_room_6 -hairal_niwa_n_scene -hairal_niwa_n_room_0 -bowling_scene -bowling_room_0 -hakaana_ouke_scene -hakaana_ouke_room_0 -hakaana_ouke_room_1 -hakaana_ouke_room_2 -hylia_labo_scene -hylia_labo_room_0 -souko_scene -souko_room_0 -souko_room_1 -souko_room_2 -miharigoya_scene -miharigoya_room_0 -mahouya_scene -mahouya_room_0 -takaraya_scene -takaraya_room_0 -takaraya_room_1 -takaraya_room_2 -takaraya_room_3 -takaraya_room_4 -takaraya_room_5 -takaraya_room_6 -ganon_sonogo_scene -ganon_sonogo_room_0 -ganon_sonogo_room_1 -ganon_sonogo_room_2 -ganon_sonogo_room_3 -ganon_sonogo_room_4 -ganon_demo_scene -ganon_demo_room_0 -face_shop_scene -face_shop_room_0 -kinsuta_scene -kinsuta_room_0 -ganontikasonogo_scene -ganontikasonogo_room_0 -ganontikasonogo_room_1 -bump_texture_static -anime_model_1_static -anime_model_2_static -anime_model_3_static -anime_model_4_static -anime_model_5_static -anime_model_6_static -anime_texture_1_static -anime_texture_2_static -anime_texture_3_static -anime_texture_4_static -anime_texture_5_static -anime_texture_6_static -softsprite_matrix_static \ No newline at end of file diff --git a/OTRExporter/CMake/Default.cmake b/OTRExporter/CMake/Default.cmake deleted file mode 100644 index f4d0ba084..000000000 --- a/OTRExporter/CMake/Default.cmake +++ /dev/null @@ -1,65 +0,0 @@ -################################################################################ -# Command for variable_watch. This command issues error message, if a variable -# is changed. If variable PROPERTY_READER_GUARD_DISABLED is TRUE nothing happens -# variable_watch( property_reader_guard) -################################################################################ -function(property_reader_guard VARIABLE ACCESS VALUE CURRENT_LIST_FILE STACK) - if("${PROPERTY_READER_GUARD_DISABLED}") - return() - endif() - - if("${ACCESS}" STREQUAL "MODIFIED_ACCESS") - message(FATAL_ERROR - " Variable ${VARIABLE} is not supposed to be changed.\n" - " It is used only for reading target property ${VARIABLE}.\n" - " Use\n" - " set_target_properties(\"\" PROPERTIES \"${VARIABLE}\" \"\")\n" - " or\n" - " set_target_properties(\"\" PROPERTIES \"${VARIABLE}_\" \"\")\n" - " instead.\n") - endif() -endfunction() - -################################################################################ -# Create variable with generator expression that expands to value of -# target property _. If property is empty or not set then property -# is used instead. Variable has watcher property_reader_guard that -# doesn't allow to edit it. -# create_property_reader() -# Input: -# name - Name of watched property and output variable -################################################################################ -function(create_property_reader NAME) - set(PROPERTY_READER_GUARD_DISABLED TRUE) - set(CONFIG_VALUE "$>>>") - set(IS_CONFIG_VALUE_EMPTY "$") - set(GENERAL_VALUE "$>") - set("${NAME}" "$" PARENT_SCOPE) - variable_watch("${NAME}" property_reader_guard) -endfunction() - -################################################################################ -# Set property $_${PROPS_CONFIG_U} of ${PROPS_TARGET} to -# set_config_specific_property( ) -# Input: -# name - Prefix of property name -# value - New value -################################################################################ -function(set_config_specific_property NAME VALUE) - set_target_properties("${PROPS_TARGET}" PROPERTIES "${NAME}_${PROPS_CONFIG_U}" "${VALUE}") -endfunction() - -################################################################################ - -create_property_reader("TARGET_NAME") -create_property_reader("OUTPUT_DIRECTORY") - -set_config_specific_property("TARGET_NAME" "${PROPS_TARGET}") -set_config_specific_property("OUTPUT_NAME" "${TARGET_NAME}") -set_config_specific_property("ARCHIVE_OUTPUT_NAME" "${TARGET_NAME}") -set_config_specific_property("LIBRARY_OUTPUT_NAME" "${TARGET_NAME}") -set_config_specific_property("RUNTIME_OUTPUT_NAME" "${TARGET_NAME}") - -set_config_specific_property("ARCHIVE_OUTPUT_DIRECTORY" "${OUTPUT_DIRECTORY}") -set_config_specific_property("LIBRARY_OUTPUT_DIRECTORY" "${OUTPUT_DIRECTORY}") -set_config_specific_property("RUNTIME_OUTPUT_DIRECTORY" "${OUTPUT_DIRECTORY}") \ No newline at end of file diff --git a/OTRExporter/CMake/DefaultCXX.cmake b/OTRExporter/CMake/DefaultCXX.cmake deleted file mode 100644 index e06b3cd2f..000000000 --- a/OTRExporter/CMake/DefaultCXX.cmake +++ /dev/null @@ -1,12 +0,0 @@ -include("${CMAKE_CURRENT_LIST_DIR}/Default.cmake") - -set_config_specific_property("OUTPUT_DIRECTORY" "${CMAKE_SOURCE_DIR}$<$>:/${CMAKE_VS_PLATFORM_NAME}>/${PROPS_CONFIG}") - -if(MSVC) - create_property_reader("DEFAULT_CXX_EXCEPTION_HANDLING") - create_property_reader("DEFAULT_CXX_DEBUG_INFORMATION_FORMAT") - - set_target_properties("${PROPS_TARGET}" PROPERTIES MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>DLL") - set_config_specific_property("DEFAULT_CXX_EXCEPTION_HANDLING" "/EHsc") - set_config_specific_property("DEFAULT_CXX_DEBUG_INFORMATION_FORMAT" "/Zi") -endif() diff --git a/OTRExporter/CMake/Utils.cmake b/OTRExporter/CMake/Utils.cmake deleted file mode 100644 index d9822f0a3..000000000 --- a/OTRExporter/CMake/Utils.cmake +++ /dev/null @@ -1,233 +0,0 @@ -# utils file for projects came from visual studio solution with cmake-converter. - -################################################################################ -# Wrap each token of the command with condition -################################################################################ -cmake_policy(PUSH) -cmake_policy(SET CMP0054 NEW) -macro(prepare_commands) - unset(TOKEN_ROLE) - unset(COMMANDS) - foreach(TOKEN ${ARG_COMMANDS}) - if("${TOKEN}" STREQUAL "COMMAND") - set(TOKEN_ROLE "KEYWORD") - elseif("${TOKEN_ROLE}" STREQUAL "KEYWORD") - set(TOKEN_ROLE "CONDITION") - elseif("${TOKEN_ROLE}" STREQUAL "CONDITION") - set(TOKEN_ROLE "COMMAND") - elseif("${TOKEN_ROLE}" STREQUAL "COMMAND") - set(TOKEN_ROLE "ARG") - endif() - - if("${TOKEN_ROLE}" STREQUAL "KEYWORD") - list(APPEND COMMANDS "${TOKEN}") - elseif("${TOKEN_ROLE}" STREQUAL "CONDITION") - set(CONDITION ${TOKEN}) - elseif("${TOKEN_ROLE}" STREQUAL "COMMAND") - list(APPEND COMMANDS "$<$:${DUMMY}>$<${CONDITION}:${TOKEN}>") - elseif("${TOKEN_ROLE}" STREQUAL "ARG") - list(APPEND COMMANDS "$<${CONDITION}:${TOKEN}>") - endif() - endforeach() -endmacro() -cmake_policy(POP) - -################################################################################ -# Transform all the tokens to absolute paths -################################################################################ -macro(prepare_output) - unset(OUTPUT) - foreach(TOKEN ${ARG_OUTPUT}) - if(IS_ABSOLUTE ${TOKEN}) - list(APPEND OUTPUT "${TOKEN}") - else() - list(APPEND OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/${TOKEN}") - endif() - endforeach() -endmacro() - -################################################################################ -# Parse add_custom_command_if args. -# -# Input: -# PRE_BUILD - Pre build event option -# PRE_LINK - Pre link event option -# POST_BUILD - Post build event option -# TARGET - Target -# OUTPUT - List of output files -# DEPENDS - List of files on which the command depends -# COMMANDS - List of commands(COMMAND condition1 commannd1 args1 COMMAND -# condition2 commannd2 args2 ...) -# Output: -# OUTPUT - Output files -# DEPENDS - Files on which the command depends -# COMMENT - Comment -# PRE_BUILD - TRUE/FALSE -# PRE_LINK - TRUE/FALSE -# POST_BUILD - TRUE/FALSE -# TARGET - Target name -# COMMANDS - Prepared commands(every token is wrapped in CONDITION) -# NAME - Unique name for custom target -# STEP - PRE_BUILD/PRE_LINK/POST_BUILD -################################################################################ -function(add_custom_command_if_parse_arguments) - cmake_parse_arguments("ARG" "PRE_BUILD;PRE_LINK;POST_BUILD" "TARGET;COMMENT" "DEPENDS;OUTPUT;COMMANDS" ${ARGN}) - - if(WIN32) - set(DUMMY "cd.") - elseif(UNIX) - set(DUMMY "true") - endif() - - prepare_commands() - prepare_output() - - set(DEPENDS "${ARG_DEPENDS}") - set(COMMENT "${ARG_COMMENT}") - set(PRE_BUILD "${ARG_PRE_BUILD}") - set(PRE_LINK "${ARG_PRE_LINK}") - set(POST_BUILD "${ARG_POST_BUILD}") - set(TARGET "${ARG_TARGET}") - if(PRE_BUILD) - set(STEP "PRE_BUILD") - elseif(PRE_LINK) - set(STEP "PRE_LINK") - elseif(POST_BUILD) - set(STEP "POST_BUILD") - endif() - set(NAME "${TARGET}_${STEP}") - - set(OUTPUT "${OUTPUT}" PARENT_SCOPE) - set(DEPENDS "${DEPENDS}" PARENT_SCOPE) - set(COMMENT "${COMMENT}" PARENT_SCOPE) - set(PRE_BUILD "${PRE_BUILD}" PARENT_SCOPE) - set(PRE_LINK "${PRE_LINK}" PARENT_SCOPE) - set(POST_BUILD "${POST_BUILD}" PARENT_SCOPE) - set(TARGET "${TARGET}" PARENT_SCOPE) - set(COMMANDS "${COMMANDS}" PARENT_SCOPE) - set(STEP "${STEP}" PARENT_SCOPE) - set(NAME "${NAME}" PARENT_SCOPE) -endfunction() - -################################################################################ -# Add conditional custom command -# -# Generating Files -# The first signature is for adding a custom command to produce an output: -# add_custom_command_if( -# -# -# -# [COMMAND condition command2 [args2...]] -# [DEPENDS [depends...]] -# [COMMENT comment] -# -# Build Events -# add_custom_command_if( -# -# -# -# [COMMAND condition command2 [args2...]] -# [COMMENT comment] -# -# Input: -# output - Output files the command is expected to produce -# condition - Generator expression for wrapping the command -# command - Command-line(s) to execute at build time. -# args - Command`s args -# depends - Files on which the command depends -# comment - Display the given message before the commands are executed at -# build time. -# PRE_BUILD - Run before any other rules are executed within the target -# PRE_LINK - Run after sources have been compiled but before linking the -# binary -# POST_BUILD - Run after all other rules within the target have been -# executed -################################################################################ -function(add_custom_command_if) - add_custom_command_if_parse_arguments(${ARGN}) - - if(OUTPUT AND TARGET) - message(FATAL_ERROR "Wrong syntax. A TARGET and OUTPUT can not both be specified.") - endif() - - if(OUTPUT) - add_custom_command(OUTPUT ${OUTPUT} - ${COMMANDS} - DEPENDS ${DEPENDS} - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMENT ${COMMENT}) - elseif(TARGET) - if(PRE_BUILD AND NOT ${CMAKE_GENERATOR} MATCHES "Visual Studio") - add_custom_target( - ${NAME} - ${COMMANDS} - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMENT ${COMMENT}) - add_dependencies(${TARGET} ${NAME}) - else() - add_custom_command( - TARGET ${TARGET} - ${STEP} - ${COMMANDS} - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMENT ${COMMENT}) - endif() - else() - message(FATAL_ERROR "Wrong syntax. A TARGET or OUTPUT must be specified.") - endif() -endfunction() - -################################################################################ -# Use props file for a target and configs -# use_props( ) -# Inside there are following variables: -# PROPS_TARGET - -# PROPS_CONFIG - One of -# PROPS_CONFIG_U - Uppercase PROPS_CONFIG -# Input: -# target - Target to apply props file -# configs - Build configurations to apply props file -# props_file - CMake script -################################################################################ -macro(use_props TARGET CONFIGS PROPS_FILE) - set(PROPS_TARGET "${TARGET}") - foreach(PROPS_CONFIG ${CONFIGS}) - string(TOUPPER "${PROPS_CONFIG}" PROPS_CONFIG_U) - - get_filename_component(ABSOLUTE_PROPS_FILE "${PROPS_FILE}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_LIST_DIR}") - if(EXISTS "${ABSOLUTE_PROPS_FILE}") - include("${ABSOLUTE_PROPS_FILE}") - else() - message(WARNING "Corresponding cmake file from props \"${ABSOLUTE_PROPS_FILE}\" doesn't exist") - endif() - endforeach() -endmacro() - -################################################################################ -# Add compile options to source file -# source_file_compile_options( [compile_options...]) -# Input: -# source_file - Source file -# compile_options - Options to add to COMPILE_FLAGS property -################################################################################ -function(source_file_compile_options SOURCE_FILE) - if("${ARGC}" LESS_EQUAL "1") - return() - endif() - - get_source_file_property(COMPILE_OPTIONS "${SOURCE_FILE}" COMPILE_OPTIONS) - - if(COMPILE_OPTIONS) - list(APPEND COMPILE_OPTIONS ${ARGN}) - else() - set(COMPILE_OPTIONS "${ARGN}") - endif() - - set_source_files_properties("${SOURCE_FILE}" PROPERTIES COMPILE_OPTIONS "${COMPILE_OPTIONS}") -endfunction() - -################################################################################ -# Default properties of visual studio projects -################################################################################ -set(DEFAULT_CXX_PROPS "${CMAKE_CURRENT_LIST_DIR}/DefaultCXX.cmake") diff --git a/OTRExporter/CMakeLists.txt b/OTRExporter/CMakeLists.txt deleted file mode 100644 index e759cd128..000000000 --- a/OTRExporter/CMakeLists.txt +++ /dev/null @@ -1,96 +0,0 @@ -cmake_minimum_required(VERSION 3.16.0 FATAL_ERROR) - -set(CMAKE_SYSTEM_VERSION 10.0 CACHE STRING "" FORCE) -set(CMAKE_CXX_STANDARD 20 CACHE STRING "The C++ standard to use") -#set(CMAKE_C_STANDARD 11 CACHE STRING "The C standard to use") -set(CMAKE_C_STANDARD 11) - -project(OTRExporter C CXX) - -################################################################################ -# Set target arch type if empty. Visual studio solution generator provides it. -################################################################################ -if (CMAKE_SYSTEM_NAME STREQUAL "Windows") - if(NOT CMAKE_VS_PLATFORM_NAME) - set(CMAKE_VS_PLATFORM_NAME "x64") - endif() - message("${CMAKE_VS_PLATFORM_NAME} architecture in use") - - if(NOT ("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64" - OR "${CMAKE_VS_PLATFORM_NAME}" STREQUAL "Win32")) - message(FATAL_ERROR "${CMAKE_VS_PLATFORM_NAME} arch is not supported!") - endif() -endif() - -################################################################################ -# Global configuration types -################################################################################ -set(CMAKE_CONFIGURATION_TYPES - "Debug" - "Release" - CACHE STRING "" FORCE -) - -################################################################################ -# Global compiler options -################################################################################ -if(MSVC) - # remove default flags provided with CMake for MSVC - set(CMAKE_C_FLAGS "") - set(CMAKE_C_FLAGS_DEBUG "") - set(CMAKE_C_FLAGS_RELEASE "") - set(CMAKE_CXX_FLAGS "") - set(CMAKE_CXX_FLAGS_DEBUG "") - set(CMAKE_CXX_FLAGS_RELEASE "") -endif() - -################################################################################ -# Global linker options -################################################################################ -if(MSVC) - # remove default flags provided with CMake for MSVC - set(CMAKE_EXE_LINKER_FLAGS "") - set(CMAKE_MODULE_LINKER_FLAGS "") - set(CMAKE_SHARED_LINKER_FLAGS "") - set(CMAKE_STATIC_LINKER_FLAGS "") - set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS}") - set(CMAKE_MODULE_LINKER_FLAGS_DEBUG "${CMAKE_MODULE_LINKER_FLAGS}") - set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS}") - set(CMAKE_STATIC_LINKER_FLAGS_DEBUG "${CMAKE_STATIC_LINKER_FLAGS}") - set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS}") - set(CMAKE_MODULE_LINKER_FLAGS_RELEASE "${CMAKE_MODULE_LINKER_FLAGS}") - set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS}") - set(CMAKE_STATIC_LINKER_FLAGS_RELEASE "${CMAKE_STATIC_LINKER_FLAGS}") -endif() - -################################################################################ -# Common utils -################################################################################ -include(CMake/Utils.cmake) - -################################################################################ -# Additional Global Settings(add specific info there) -################################################################################ -include(CMake/GlobalSettingsInclude.cmake OPTIONAL) - -################################################################################ -# Use solution folders feature -################################################################################ -set_property(GLOBAL PROPERTY USE_FOLDERS ON) - -################################################################################ -# Sub-projects -################################################################################ -if (NOT TARGET libultraship) - add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../libultraship ${CMAKE_BINARY_DIR}/libultraship) -endif() - -if (NOT TARGET ZAPD) - add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../ZAPDTR/ZAPD ${CMAKE_BINARY_DIR}/ZAPD) -endif() - -if (NOT TARGET ZAPDUtils) - add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../libultraship/extern/ZAPDUtils ${CMAKE_BINARY_DIR}/ZAPDUtils) -endif() - -add_subdirectory(OTRExporter) diff --git a/OTRExporter/LICENSE b/OTRExporter/LICENSE deleted file mode 100644 index 59ddd97bc..000000000 --- a/OTRExporter/LICENSE +++ /dev/null @@ -1,9 +0,0 @@ -Copyright (c) 2022 Harbour Masters - -MIT License - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/OTRExporter/OTRExporter/AnimationExporter.cpp b/OTRExporter/OTRExporter/AnimationExporter.cpp deleted file mode 100644 index 416d74725..000000000 --- a/OTRExporter/OTRExporter/AnimationExporter.cpp +++ /dev/null @@ -1,70 +0,0 @@ -#include "AnimationExporter.h" -#include - -void OTRExporter_Animation::Save(ZResource* res, const fs::path& outPath, BinaryWriter* writer) -{ - ZAnimation* anim = (ZAnimation*)res; - - WriteHeader(res, outPath, writer, LUS::ResourceType::SOH_Animation); - - ZNormalAnimation* normalAnim = dynamic_cast(anim); - ZCurveAnimation* curveAnim = dynamic_cast(anim); - ZLinkAnimation* linkAnim = dynamic_cast(anim); - if (linkAnim != nullptr) - { - writer->Write((uint32_t)LUS::AnimationType::Link); - writer->Write((uint16_t)linkAnim->frameCount); - writer->Write((uint32_t)linkAnim->segmentAddress); - } - else if (curveAnim != nullptr) - { - writer->Write((uint32_t)LUS::AnimationType::Curve); - writer->Write((uint16_t)curveAnim->frameCount); - - writer->Write((uint32_t)curveAnim->refIndexArr.size()); - - for (auto val : curveAnim->refIndexArr) - writer->Write(val); - - writer->Write((uint32_t)curveAnim->transformDataArr.size()); - - for (auto val : curveAnim->transformDataArr) - { - writer->Write(val.unk_00); - writer->Write(val.unk_02); - writer->Write(val.unk_04); - writer->Write(val.unk_06); - writer->Write(val.unk_08); - } - - writer->Write((uint32_t)curveAnim->copyValuesArr.size()); - - for (auto val : curveAnim->copyValuesArr) - writer->Write(val); - } - else if (normalAnim != nullptr) - { - writer->Write((uint32_t)LUS::AnimationType::Normal); - writer->Write((uint16_t)normalAnim->frameCount); - - writer->Write((uint32_t)normalAnim->rotationValues.size()); - - for (size_t i = 0; i < normalAnim->rotationValues.size(); i++) - writer->Write(normalAnim->rotationValues[i]); - - writer->Write((uint32_t)normalAnim->rotationIndices.size()); - - for (size_t i = 0; i < normalAnim->rotationIndices.size(); i++) - { - writer->Write(normalAnim->rotationIndices[i].x); - writer->Write(normalAnim->rotationIndices[i].y); - writer->Write(normalAnim->rotationIndices[i].z); - } - - writer->Write(normalAnim->limit); - } - else - { - writer->Write((uint32_t)LUS::AnimationType::Legacy); - } -} diff --git a/OTRExporter/OTRExporter/AnimationExporter.h b/OTRExporter/OTRExporter/AnimationExporter.h deleted file mode 100644 index 58fddb2fd..000000000 --- a/OTRExporter/OTRExporter/AnimationExporter.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once - -#include "ZResource.h" -#include "ZTexture.h" -#include "ZAnimation.h" -#include "Exporter.h" -#include - -class OTRExporter_Animation : public OTRExporter -{ -public: - virtual void Save(ZResource* res, const fs::path& outPath, BinaryWriter* writer) override; -}; \ No newline at end of file diff --git a/OTRExporter/OTRExporter/ArrayExporter.cpp b/OTRExporter/OTRExporter/ArrayExporter.cpp deleted file mode 100644 index f6b602bbb..000000000 --- a/OTRExporter/OTRExporter/ArrayExporter.cpp +++ /dev/null @@ -1,108 +0,0 @@ -#include "ArrayExporter.h" -#include "VtxExporter.h" -#include -void OTRExporter_Array::Save(ZResource* res, const fs::path& outPath, BinaryWriter* writer) -{ - ZArray* arr = (ZArray*)res; - - WriteHeader(res, outPath, writer, LUS::ResourceType::Array); - - writer->Write((uint32_t)arr->resList[0]->GetResourceType()); - writer->Write((uint32_t)arr->arrayCnt); - - for (size_t i = 0; i < arr->arrayCnt; i++) - { - if (arr->resList[i]->GetResourceType() == ZResourceType::Vertex) - { - ZVtx* vtx = (ZVtx*)arr->resList[i]; - writer->Write(vtx->x); - writer->Write(vtx->y); - writer->Write(vtx->z); - writer->Write(vtx->flag); - writer->Write(vtx->s); - writer->Write(vtx->t); - writer->Write(vtx->r); - writer->Write(vtx->g); - writer->Write(vtx->b); - writer->Write(vtx->a); - } - else if (arr->resList[i]->GetResourceType() == ZResourceType::Vector) - { - ZVector* vec = (ZVector*)arr->resList[i]; - writer->Write((uint32_t)vec->scalarType); - writer->Write((uint32_t)vec->dimensions); - - for (size_t k = 0; k < vec->dimensions; k++) - { - // OTRTODO: Duplicate code here. Cleanup at a later date... - switch (vec->scalarType) - { - case ZScalarType::ZSCALAR_U8: - writer->Write(vec->scalars[k].scalarData.u8); - break; - case ZScalarType::ZSCALAR_S8: - writer->Write(vec->scalars[k].scalarData.s8); - break; - case ZScalarType::ZSCALAR_U16: - writer->Write(vec->scalars[k].scalarData.u16); - break; - case ZScalarType::ZSCALAR_S16: - writer->Write(vec->scalars[k].scalarData.s16); - break; - case ZScalarType::ZSCALAR_S32: - writer->Write(vec->scalars[k].scalarData.s32); - break; - case ZScalarType::ZSCALAR_U32: - writer->Write(vec->scalars[k].scalarData.u32); - break; - case ZScalarType::ZSCALAR_S64: - writer->Write(vec->scalars[k].scalarData.s64); - break; - case ZScalarType::ZSCALAR_U64: - writer->Write(vec->scalars[k].scalarData.u64); - break; - // OTRTODO: ADD OTHER TYPES - default: - break; - } - } - } - else - { - ZScalar* scal = (ZScalar*)arr->resList[i]; - - writer->Write((uint32_t)scal->scalarType); - - switch (scal->scalarType) - { - case ZScalarType::ZSCALAR_U8: - writer->Write(scal->scalarData.u8); - break; - case ZScalarType::ZSCALAR_S8: - writer->Write(scal->scalarData.s8); - break; - case ZScalarType::ZSCALAR_U16: - writer->Write(scal->scalarData.u16); - break; - case ZScalarType::ZSCALAR_S16: - writer->Write(scal->scalarData.s16); - break; - case ZScalarType::ZSCALAR_S32: - writer->Write(scal->scalarData.s32); - break; - case ZScalarType::ZSCALAR_U32: - writer->Write(scal->scalarData.u32); - break; - case ZScalarType::ZSCALAR_S64: - writer->Write(scal->scalarData.s64); - break; - case ZScalarType::ZSCALAR_U64: - writer->Write(scal->scalarData.u64); - break; - // OTRTODO: ADD OTHER TYPES - default: - break; - } - } - } -} \ No newline at end of file diff --git a/OTRExporter/OTRExporter/ArrayExporter.h b/OTRExporter/OTRExporter/ArrayExporter.h deleted file mode 100644 index 1d2dc0f2b..000000000 --- a/OTRExporter/OTRExporter/ArrayExporter.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once -#include "ZResource.h" -#include "ZArray.h" -#include "Exporter.h" -#include - -class OTRExporter_Array : public OTRExporter -{ -public: - virtual void Save(ZResource* res, const fs::path& outPath, BinaryWriter* writer) override; - -}; \ No newline at end of file diff --git a/OTRExporter/OTRExporter/AudioExporter.cpp b/OTRExporter/OTRExporter/AudioExporter.cpp deleted file mode 100644 index 6e1f38e79..000000000 --- a/OTRExporter/OTRExporter/AudioExporter.cpp +++ /dev/null @@ -1,191 +0,0 @@ -#include "AudioExporter.h" -#include "Main.h" -#include -#include -#include -#include "DisplayListExporter.h" - -void OTRExporter_Audio::WriteSampleEntryReference(ZAudio* audio, SampleEntry* entry, std::map samples, BinaryWriter* writer) -{ - writer->Write((uint8_t)(entry != nullptr ? 1 : 0)); - - if (entry != nullptr) - { - if (audio->sampleOffsets[entry->bankId].find(entry->sampleLoopOffset) != audio->sampleOffsets[entry->bankId].end()) - { - if (audio->sampleOffsets[entry->bankId][entry->sampleLoopOffset].find(entry->sampleDataOffset) != audio->sampleOffsets[entry->bankId][entry->sampleLoopOffset].end()) - { - writer->Write(StringHelper::Sprintf("audio/samples/%s", audio->sampleOffsets[entry->bankId][entry->sampleLoopOffset][entry->sampleDataOffset].c_str())); - } - else - writer->Write(entry->fileName); - } - else - writer->Write(entry->fileName); - } - else - writer->Write(""); -} - -void OTRExporter_Audio::WriteSampleEntry(SampleEntry* entry, BinaryWriter* writer) -{ - WriteHeader(nullptr, "", writer, LUS::ResourceType::SOH_AudioSample, 2); - - writer->Write(entry->codec); - writer->Write(entry->medium); - writer->Write(entry->unk_bit26); - writer->Write(entry->unk_bit25); - - writer->Write((uint32_t)entry->data.size()); - writer->Write((char*)entry->data.data(), entry->data.size()); - - writer->Write((uint32_t)(entry->loop.start)); - writer->Write((uint32_t)(entry->loop.end)); - writer->Write((uint32_t)(entry->loop.count)); - writer->Write((uint32_t)entry->loop.states.size()); - - for (size_t i = 0; i < entry->loop.states.size(); i++) - writer->Write((entry->loop.states[i])); - - writer->Write((uint32_t)(entry->book.order)); - writer->Write((uint32_t)(entry->book.npredictors)); - writer->Write((uint32_t)entry->book.books.size()); - - for (size_t i = 0; i < entry->book.books.size(); i++) - writer->Write((entry->book.books[i])); -} - -void OTRExporter_Audio::WriteSoundFontEntry(ZAudio* audio, SoundFontEntry* entry, std::map samples, BinaryWriter* writer) -{ - writer->Write((uint8_t)(entry != nullptr ? 1 : 0)); - - if (entry != nullptr) - { - WriteSampleEntryReference(audio, entry->sampleEntry, samples, writer); - writer->Write(entry->tuning); - } -} - -void OTRExporter_Audio::WriteEnvData(std::vector envelopes, BinaryWriter* writer) -{ - writer->Write((uint32_t)envelopes.size()); - - for (auto env : envelopes) - { - writer->Write(env->delay); - writer->Write(env->arg); - } -} - -void OTRExporter_Audio::Save(ZResource* res, const fs::path& outPath, BinaryWriter* writer) -{ - ZAudio* audio = (ZAudio*)res; - - WriteHeader(res, outPath, writer, LUS::ResourceType::SOH_Audio, 2); - - // Write Samples as individual files - for (auto pair : audio->samples) - { - MemoryStream* sampleStream = new MemoryStream(); - BinaryWriter sampleWriter = BinaryWriter(sampleStream); - - writer->Write((uint32_t)pair.first); - WriteSampleEntry(pair.second, &sampleWriter); - - std::string basePath = ""; - - if (audio->sampleOffsets[pair.second->bankId].find(pair.second->sampleLoopOffset) != audio->sampleOffsets[pair.second->bankId].end()) - { - if (audio->sampleOffsets[pair.second->bankId][pair.second->sampleLoopOffset].find(pair.second->sampleDataOffset) != audio->sampleOffsets[pair.second->bankId][pair.second->sampleLoopOffset].end()) - basePath = StringHelper::Sprintf("samples/%s", audio->sampleOffsets[pair.second->bankId][pair.second->sampleLoopOffset][pair.second->sampleDataOffset].c_str()); - else - basePath = StringHelper::Sprintf("samples/sample_%08X", pair.first); - } - else - basePath = StringHelper::Sprintf("samples/sample_%08X", pair.first); - - std::string fName = OTRExporter_DisplayList::GetPathToRes(res, basePath); - AddFile(fName, sampleStream->ToVector()); - } - - // Write the soundfont table - for (size_t i = 0; i < audio->soundFontTable.size(); i++) - { - MemoryStream* fntStream = new MemoryStream(); - BinaryWriter fntWriter = BinaryWriter(fntStream); - - WriteHeader(nullptr, "", &fntWriter, LUS::ResourceType::SOH_AudioSoundFont, 2); - - fntWriter.Write((uint32_t)i); - fntWriter.Write(audio->soundFontTable[i].medium); - fntWriter.Write(audio->soundFontTable[i].cachePolicy); - fntWriter.Write(audio->soundFontTable[i].data1); - fntWriter.Write(audio->soundFontTable[i].data2); - fntWriter.Write(audio->soundFontTable[i].data3); - - fntWriter.Write((uint32_t)audio->soundFontTable[i].drums.size()); - fntWriter.Write((uint32_t)audio->soundFontTable[i].instruments.size()); - fntWriter.Write((uint32_t)audio->soundFontTable[i].soundEffects.size()); - - for (size_t k = 0; k < audio->soundFontTable[i].drums.size(); k++) - { - fntWriter.Write(audio->soundFontTable[i].drums[k].releaseRate); - fntWriter.Write(audio->soundFontTable[i].drums[k].pan); - fntWriter.Write(audio->soundFontTable[i].drums[k].loaded); - - WriteEnvData(audio->soundFontTable[i].drums[k].env, &fntWriter); - - WriteSampleEntryReference(audio, audio->soundFontTable[i].drums[k].sample, audio->samples, &fntWriter); - fntWriter.Write(audio->soundFontTable[i].drums[k].tuning); - } - - for (size_t k = 0; k < audio->soundFontTable[i].instruments.size(); k++) - { - fntWriter.Write((uint8_t)audio->soundFontTable[i].instruments[k].isValidInstrument); - - fntWriter.Write(audio->soundFontTable[i].instruments[k].loaded); - fntWriter.Write(audio->soundFontTable[i].instruments[k].normalRangeLo); - fntWriter.Write(audio->soundFontTable[i].instruments[k].normalRangeHi); - fntWriter.Write(audio->soundFontTable[i].instruments[k].releaseRate); - - WriteEnvData(audio->soundFontTable[i].instruments[k].env, &fntWriter); - - WriteSoundFontEntry(audio, audio->soundFontTable[i].instruments[k].lowNotesSound, audio->samples, &fntWriter); - WriteSoundFontEntry(audio, audio->soundFontTable[i].instruments[k].normalNotesSound, audio->samples, &fntWriter); - WriteSoundFontEntry(audio, audio->soundFontTable[i].instruments[k].highNotesSound, audio->samples, &fntWriter); - } - - for (size_t k = 0; k < audio->soundFontTable[i].soundEffects.size(); k++) - { - WriteSoundFontEntry(audio, audio->soundFontTable[i].soundEffects[k], audio->samples, &fntWriter); - } - - //std::string fName = OTRExporter_DisplayList::GetPathToRes(res, StringHelper::Sprintf("fonts/font_%02X", i)); - std::string fName = OTRExporter_DisplayList::GetPathToRes(res, StringHelper::Sprintf("fonts/%s", audio->soundFontNames[i].c_str())); - AddFile(fName, fntStream->ToVector()); - } - - // Write Sequences - for (size_t i = 0; i < audio->sequences.size(); i++) - { - auto seq = audio->sequences[i]; - - MemoryStream* seqStream = new MemoryStream(); - BinaryWriter seqWriter = BinaryWriter(seqStream); - - WriteHeader(nullptr, "", &seqWriter, LUS::ResourceType::SOH_AudioSequence, 2); - - seqWriter.Write((uint32_t)seq.size()); - seqWriter.Write(seq.data(), seq.size()); - seqWriter.Write((uint8_t)i); - seqWriter.Write((uint8_t)audio->sequenceTable[i].medium); - seqWriter.Write((uint8_t)audio->sequenceTable[i].cachePolicy); - seqWriter.Write((uint32_t)audio->fontIndices[i].size()); - - for (size_t k = 0; k < audio->fontIndices[i].size(); k++) - seqWriter.Write((uint8_t)audio->fontIndices[i][k]); - - std::string fName = OTRExporter_DisplayList::GetPathToRes(res, StringHelper::Sprintf("sequences/%s", audio->seqNames[i].c_str())); - AddFile(fName, seqStream->ToVector()); - } -} diff --git a/OTRExporter/OTRExporter/AudioExporter.h b/OTRExporter/OTRExporter/AudioExporter.h deleted file mode 100644 index 13a8cc0a0..000000000 --- a/OTRExporter/OTRExporter/AudioExporter.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once - -#include "ZResource.h" -#include "ZAudio.h" -#include "Exporter.h" -#include - -class OTRExporter_Audio : public OTRExporter -{ -public: - void WriteSampleEntry(SampleEntry* entry, BinaryWriter* writer); - void WriteSampleEntryReference(ZAudio* audio, SampleEntry* entry, std::map samples, BinaryWriter* writer); - void WriteSoundFontEntry(ZAudio* audio, SoundFontEntry* entry, std::map samples, BinaryWriter* writer); - void WriteEnvData(std::vector envelopes, BinaryWriter* writer); - virtual void Save(ZResource* res, const fs::path& outPath, BinaryWriter* writer) override; -}; \ No newline at end of file diff --git a/OTRExporter/OTRExporter/BackgroundExporter.cpp b/OTRExporter/OTRExporter/BackgroundExporter.cpp deleted file mode 100644 index f0f1a55f4..000000000 --- a/OTRExporter/OTRExporter/BackgroundExporter.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "BackgroundExporter.h" -#include "../ZAPD/ZFile.h" - -void OTRExporter_Background::Save(ZResource* res, const fs::path& outPath, BinaryWriter* writer) -{ - ZBackground* bg = (ZBackground*)res; - - WriteHeader(bg, outPath, writer, LUS::ResourceType::SOH_Background); - - writer->Write((uint32_t)bg->GetRawDataSize()); - - auto data = bg->parent->GetRawData(); - writer->Write((char*)data.data() + bg->GetRawDataIndex(), bg->GetRawDataSize()); -} \ No newline at end of file diff --git a/OTRExporter/OTRExporter/BackgroundExporter.h b/OTRExporter/OTRExporter/BackgroundExporter.h deleted file mode 100644 index 30c1adbbc..000000000 --- a/OTRExporter/OTRExporter/BackgroundExporter.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once - -#include "ZResource.h" -#include "ZBackground.h" -#include "Exporter.h" -#include - -class OTRExporter_Background : public OTRExporter -{ -public: - virtual void Save(ZResource* res, const fs::path& outPath, BinaryWriter* writer) override; -}; \ No newline at end of file diff --git a/OTRExporter/OTRExporter/BlobExporter.cpp b/OTRExporter/OTRExporter/BlobExporter.cpp deleted file mode 100644 index a547718e3..000000000 --- a/OTRExporter/OTRExporter/BlobExporter.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "BlobExporter.h" -#include "../ZAPD/ZFile.h" - -void OTRExporter_Blob::Save(ZResource* res, const fs::path& outPath, BinaryWriter* writer) -{ - ZBlob* blob = (ZBlob*)res; - - WriteHeader(blob, outPath, writer, LUS::ResourceType::Blob); - - auto start = std::chrono::steady_clock::now(); - - writer->Write((uint32_t)blob->GetRawDataSize()); - - auto data = blob->parent->GetRawData(); - - for (size_t i = blob->GetRawDataIndex(); i < blob->GetRawDataIndex() + blob->GetRawDataSize(); i++) - writer->Write(data[i]); - - auto end = std::chrono::steady_clock::now(); - size_t diff = std::chrono::duration_cast(end - start).count(); -} \ No newline at end of file diff --git a/OTRExporter/OTRExporter/BlobExporter.h b/OTRExporter/OTRExporter/BlobExporter.h deleted file mode 100644 index 43a262d5e..000000000 --- a/OTRExporter/OTRExporter/BlobExporter.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once - -#include "ZResource.h" -#include "ZBlob.h" -#include "Exporter.h" -#include - -class OTRExporter_Blob : public OTRExporter -{ -public: - virtual void Save(ZResource* res, const fs::path& outPath, BinaryWriter* writer) override; -}; \ No newline at end of file diff --git a/OTRExporter/OTRExporter/CMakeLists.txt b/OTRExporter/OTRExporter/CMakeLists.txt deleted file mode 100644 index 9d012af95..000000000 --- a/OTRExporter/OTRExporter/CMakeLists.txt +++ /dev/null @@ -1,245 +0,0 @@ -set(PROJECT_NAME OTRExporter) - -################################################################################ -# Source groups -################################################################################ -set(Header_Files - "AnimationExporter.h" - "ArrayExporter.h" - "AudioExporter.h" - "BackgroundExporter.h" - "BlobExporter.h" - "CollisionExporter.h" - "command_macros_base.h" - "CutsceneExporter.h" - "DisplayListExporter.h" - "Exporter.h" - "Main.h" - "MtxExporter.h" - "PathExporter.h" - "PlayerAnimationExporter.h" - "RoomExporter.h" - "SkeletonExporter.h" - "SkeletonLimbExporter.h" - "TextExporter.h" - "TextureExporter.h" - "VersionInfo.h" - "VtxExporter.h" - "z64cutscene.h" - "z64cutscene_commands.h" -) -source_group("Header Files" FILES ${Header_Files}) - -set(Source_Files - "AnimationExporter.cpp" - "ArrayExporter.cpp" - "AudioExporter.cpp" - "BackgroundExporter.cpp" - "BlobExporter.cpp" - "CollisionExporter.cpp" - "CutsceneExporter.cpp" - "DisplayListExporter.cpp" - "Exporter.cpp" - "Main.cpp" - "MtxExporter.cpp" - "PathExporter.cpp" - "PlayerAnimationExporter.cpp" - "RoomExporter.cpp" - "SkeletonExporter.cpp" - "SkeletonLimbExporter.cpp" - "TextExporter.cpp" - "TextureExporter.cpp" - "VersionInfo.cpp" - "VtxExporter.cpp" -) -source_group("Source Files" FILES ${Source_Files}) - -set(ALL_FILES - ${Header_Files} - ${Source_Files} -) - -################################################################################ -# Target -################################################################################ -add_library(${PROJECT_NAME} STATIC ${ALL_FILES}) - -if (CMAKE_SYSTEM_NAME STREQUAL "Windows") -use_props(${PROJECT_NAME} "${CMAKE_CONFIGURATION_TYPES}" "${DEFAULT_CXX_PROPS}") -endif() - -set(ROOT_NAMESPACE OTRExporter) - -if (CMAKE_SYSTEM_NAME STREQUAL "Windows") - set_target_properties(${PROJECT_NAME} PROPERTIES - VS_GLOBAL_KEYWORD "Win32Proj" - ) - if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64") - set_target_properties(${PROJECT_NAME} PROPERTIES - INTERPROCEDURAL_OPTIMIZATION_RELEASE "TRUE" - ) - elseif("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x86") - set_target_properties(${PROJECT_NAME} PROPERTIES - INTERPROCEDURAL_OPTIMIZATION_RELEASE "TRUE" - ) - endif() -endif() -################################################################################ -# MSVC runtime library -################################################################################ -if (CMAKE_SYSTEM_NAME STREQUAL "Windows") - get_property(MSVC_RUNTIME_LIBRARY_DEFAULT TARGET ${PROJECT_NAME} PROPERTY MSVC_RUNTIME_LIBRARY) - if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64") - string(CONCAT "MSVC_RUNTIME_LIBRARY_STR" - $<$: - MultiThreadedDebug - > - $<$: - MultiThreaded - > - $<$,$>>:${MSVC_RUNTIME_LIBRARY_DEFAULT}> - ) - endif() - set_target_properties(${PROJECT_NAME} PROPERTIES MSVC_RUNTIME_LIBRARY ${MSVC_RUNTIME_LIBRARY_STR}) -endif() -################################################################################ -# Compile definitions -################################################################################ -if (CMAKE_SYSTEM_NAME STREQUAL "Windows") - if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64") - target_compile_definitions(${PROJECT_NAME} PRIVATE - "$<$:" - "_DEBUG" - ">" - "$<$:" - "NDEBUG" - ">" - "_CONSOLE;" - "_CRT_SECURE_NO_WARNINGS;" - "UNICODE;" - "_UNICODE" - STORMLIB_NO_AUTO_LINK - ) - elseif("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x86") - target_compile_definitions(${PROJECT_NAME} PRIVATE - "$<$:" - "_DEBUG;" - "_CRT_SECURE_NO_WARNINGS" - ">" - "$<$:" - "NDEBUG" - ">" - "WIN32;" - "_CONSOLE;" - "UNICODE;" - "_UNICODE" - STORMLIB_NO_AUTO_LINK - ) - endif() -endif() - -if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU|Clang|AppleClang") - target_compile_definitions(${PROJECT_NAME} PRIVATE - "$<$:" - "_DEBUG" - ">" - "$<$:" - "NDEBUG" - ">" - "_CONSOLE;" - "_CRT_SECURE_NO_WARNINGS;" - "UNICODE;" - "_UNICODE" - ) -endif() -################################################################################ -# Compile and link options -################################################################################ - -target_include_directories(${PROJECT_NAME} PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/../../ZAPDTR/ZAPD/ - ${CMAKE_CURRENT_SOURCE_DIR}/../../libultraship/include - # TODO: these should no longer be necessary if we were to link against LUS - ${CMAKE_CURRENT_SOURCE_DIR}/../../libultraship - ${CMAKE_CURRENT_SOURCE_DIR}/../../libultraship/src - ${CMAKE_CURRENT_SOURCE_DIR}/../../libultraship/extern - ${CMAKE_CURRENT_SOURCE_DIR}/../../libultraship/extern/Mercury - ${CMAKE_CURRENT_SOURCE_DIR}/../../libultraship/extern/tinyxml2 - ${CMAKE_CURRENT_SOURCE_DIR}/../../libultraship/extern/ZAPDUtils - ${CMAKE_CURRENT_SOURCE_DIR}/../../libultraship/extern/StormLib/src - ${CMAKE_CURRENT_SOURCE_DIR}/../../libultraship/extern/spdlog/include - ${CMAKE_CURRENT_SOURCE_DIR}/../../libultraship/extern/nlohmann-json/include - ${CMAKE_CURRENT_SOURCE_DIR}/../../libultraship/src/resource - ${CMAKE_CURRENT_SOURCE_DIR}/../../soh/soh - . -) - -if(MSVC) - if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64") - target_compile_options(${PROJECT_NAME} PRIVATE - $<$: - /Oi; - /Gy - > - /permissive-; - /sdl; - /W3; - ${DEFAULT_CXX_DEBUG_INFORMATION_FORMAT}; - ${DEFAULT_CXX_EXCEPTION_HANDLING} - ) - elseif("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x86") - target_compile_options(${PROJECT_NAME} PRIVATE - $<$: - /Oi; - /Gy - > - /permissive-; - /sdl; - /W3; - ${DEFAULT_CXX_DEBUG_INFORMATION_FORMAT}; - ${DEFAULT_CXX_EXCEPTION_HANDLING} - ) - endif() - if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64") - target_link_options(${PROJECT_NAME} PRIVATE - $<$: - /OPT:REF; - /OPT:ICF - > - /SUBSYSTEM:CONSOLE - ) - elseif("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x86") - target_link_options(${PROJECT_NAME} PRIVATE - $<$: - /DEBUG; - /OPT:REF; - /OPT:ICF; - /INCREMENTAL:NO - > - /SUBSYSTEM:CONSOLE - ) - endif() -endif() - -if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU|Clang|AppleClang") - target_compile_options(${PROJECT_NAME} PRIVATE - -Wall -Wextra -Wno-error - -Wno-unused-parameter - -Wno-unused-function - -Wno-unused-variable - -Wno-missing-field-initializers - -Wno-parentheses - -Wno-narrowing - $<$:-Wno-deprecated-enum-enum-conversion> - ) -endif() -################################################################################ -# Dependencies -################################################################################ -add_dependencies(${PROJECT_NAME} - libultraship -) - -# Link with other targets. -target_link_libraries(${PROJECT_NAME} PUBLIC "${ADDITIONAL_LIBRARY_DEPENDENCIES}") - diff --git a/OTRExporter/OTRExporter/CollisionExporter.cpp b/OTRExporter/OTRExporter/CollisionExporter.cpp deleted file mode 100644 index cbcdbb35f..000000000 --- a/OTRExporter/OTRExporter/CollisionExporter.cpp +++ /dev/null @@ -1,84 +0,0 @@ -#include "CollisionExporter.h" -#include - -void OTRExporter_Collision::Save(ZResource* res, const fs::path& outPath, BinaryWriter* writer) -{ - ZCollisionHeader* col = (ZCollisionHeader*)res; - - WriteHeader(res, outPath, writer, LUS::ResourceType::SOH_CollisionHeader); - - writer->Write(col->absMinX); - writer->Write(col->absMinY); - writer->Write(col->absMinZ); - - writer->Write(col->absMaxX); - writer->Write(col->absMaxY); - writer->Write(col->absMaxZ); - - writer->Write((uint32_t)col->vertices.size()); - - for (uint16_t i = 0; i < col->vertices.size(); i++) - { - writer->Write(col->vertices[i].scalars[0].scalarData.s16); - writer->Write(col->vertices[i].scalars[1].scalarData.s16); - writer->Write(col->vertices[i].scalars[2].scalarData.s16); - } - - writer->Write((uint32_t)col->polygons.size()); - - for (uint16_t i = 0; i < col->polygons.size(); i++) - { - writer->Write(col->polygons[i].type); - writer->Write(col->polygons[i].vtxA); - writer->Write(col->polygons[i].vtxB); - writer->Write(col->polygons[i].vtxC); - writer->Write(col->polygons[i].normX); - writer->Write(col->polygons[i].normY); - writer->Write(col->polygons[i].normZ); - writer->Write(col->polygons[i].dist); - } - - writer->Write((uint32_t)col->PolygonTypes.size()); - - for (uint16_t i = 0; i < col->PolygonTypes.size(); i++) { - writer->Write(col->PolygonTypes[i].data[1]); - writer->Write(col->PolygonTypes[i].data[0]); - } - - writer->Write((uint32_t)col->camData->entries.size()); - - for (auto entry : col->camData->entries) - { - auto camPosDecl = col->parent->GetDeclarationRanged(Seg2Filespace(entry->cameraPosDataSeg, col->parent->baseAddress)); - - int idx = 0; - - if (camPosDecl != nullptr) - idx = ((entry->cameraPosDataSeg & 0x00FFFFFF) - camPosDecl->address) / 6; - - writer->Write(entry->cameraSType); - writer->Write(entry->numData); - writer->Write((uint32_t)idx); - } - - writer->Write((uint32_t)col->camData->cameraPositionData.size()); - - for (auto entry : col->camData->cameraPositionData) - { - writer->Write(entry->x); - writer->Write(entry->y); - writer->Write(entry->z); - } - - writer->Write((uint32_t)col->waterBoxes.size()); - - for (auto waterBox : col->waterBoxes) - { - writer->Write(waterBox.xMin); - writer->Write(waterBox.ySurface); - writer->Write(waterBox.zMin); - writer->Write(waterBox.xLength); - writer->Write(waterBox.zLength); - writer->Write(waterBox.properties); - } -} diff --git a/OTRExporter/OTRExporter/CollisionExporter.h b/OTRExporter/OTRExporter/CollisionExporter.h deleted file mode 100644 index 536d65344..000000000 --- a/OTRExporter/OTRExporter/CollisionExporter.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -#include "ZResource.h" -#include "ZCollision.h" -#include "Exporter.h" - -class OTRExporter_Collision : public OTRExporter -{ -public: - virtual void Save(ZResource* res, const fs::path& outPath, BinaryWriter* writer) override; -}; \ No newline at end of file diff --git a/OTRExporter/OTRExporter/CutsceneExporter.cpp b/OTRExporter/OTRExporter/CutsceneExporter.cpp deleted file mode 100644 index 2194ce65a..000000000 --- a/OTRExporter/OTRExporter/CutsceneExporter.cpp +++ /dev/null @@ -1,444 +0,0 @@ -#include "CutsceneExporter.h" -#include - -void OTRExporter_Cutscene::Save(ZResource* res, const fs::path& outPath, BinaryWriter* writer) -{ - ZCutscene* cs = (ZCutscene*)res; - - WriteHeader(cs, outPath, writer, LUS::ResourceType::SOH_Cutscene); - - writer->Write((uint32_t)0); - - const auto currentStream = writer->GetBaseAddress(); - - writer->Write(CS_BEGIN_CUTSCENE(cs->numCommands, cs->endFrame)); - - for (size_t i = 0; i < cs->commands.size(); i++) - { - switch (cs->commands[i]->commandID) - { - case (uint32_t)CutsceneCommands::SetCameraPos: - { - CutsceneCommandSetCameraPos* cmdCamPos = (CutsceneCommandSetCameraPos*)cs->commands[i]; - - writer->Write(CS_CMD_CAM_EYE); - writer->Write(CMD_HH(0x0001, ((CutsceneCommandSetCameraPos*)cs->commands[i])->startFrame)); - writer->Write(CMD_HH(cmdCamPos->endFrame, 0x0000)); - - for (const auto& e : cs->commands[i]->entries) - { - CutsceneCameraPoint* point = (CutsceneCameraPoint*)e; - writer->Write(CMD_BBH(point->continueFlag, point->cameraRoll, point->nextPointFrame)); - writer->Write(point->viewAngle); - writer->Write(CMD_HH(point->posX, point->posY)); - writer->Write(CMD_HH(point->posZ, point->unused)); - } - } - break; - case (uint32_t)CutsceneCommands::SetCameraFocus: - { - CutsceneCommandSetCameraPos* cmdCamPos = (CutsceneCommandSetCameraPos*)cs->commands[i]; - - writer->Write(CS_CMD_CAM_AT); - writer->Write(CMD_HH(0x0001, cmdCamPos->startFrame)); - writer->Write(CMD_HH(cmdCamPos->endFrame, 0x0000)); - - for (const auto& e : cs->commands[i]->entries) - { - CutsceneCameraPoint* point = (CutsceneCameraPoint*)e; - writer->Write(CMD_BBH(point->continueFlag, point->cameraRoll, point->nextPointFrame)); - writer->Write(point->viewAngle); - writer->Write(CMD_HH(point->posX, point->posY)); - writer->Write(CMD_HH(point->posZ, point->unused)); - } - break; - } - case (uint32_t)CutsceneCommands::Misc: - { - writer->Write(CS_CMD_MISC); - writer->Write((uint32_t)CMD_W((cs->commands[i])->entries.size())); - for (const auto& e : cs->commands[i]->entries) //All in OOT seem to only have 1 entry - { - CutsceneSubCommandEntry_GenericCmd* cmd = (CutsceneSubCommandEntry_GenericCmd*)e; - writer->Write(CMD_HH(cmd->base, cmd->startFrame)); - writer->Write(CMD_HH(cmd->endFrame, cmd->pad)); - writer->Write(CMD_W(cmd->unused1)); - writer->Write(CMD_W(cmd->unused2)); - writer->Write(CMD_W(cmd->unused3)); - writer->Write(CMD_W(cmd->unused4)); - writer->Write(CMD_W(cmd->unused5)); - writer->Write(CMD_W(cmd->unused6)); - writer->Write(CMD_W(cmd->unused7)); - writer->Write(CMD_W(cmd->unused8)); - writer->Write(CMD_W(cmd->unused9)); - writer->Write(CMD_W(cmd->unused10)); - } - break; - } - case (uint32_t)CutsceneCommands::SetLighting: - { - writer->Write(CS_CMD_SET_LIGHTING); - writer->Write((uint32_t)CMD_W((cs->commands[i])->entries.size())); - for (const auto& e : cs->commands[i]->entries) - { - CutsceneSubCommandEntry_GenericCmd* cmd = (CutsceneSubCommandEntry_GenericCmd*)e; - writer->Write(CMD_HH(cmd->base, cmd->startFrame)); - writer->Write(CMD_HH(cmd->endFrame, cmd->pad)); - writer->Write(CMD_W(cmd->unused1)); - writer->Write(CMD_W(cmd->unused2)); - writer->Write(CMD_W(cmd->unused3)); - writer->Write(CMD_W(cmd->unused4)); - writer->Write(CMD_W(cmd->unused5)); - writer->Write(CMD_W(cmd->unused6)); - writer->Write(CMD_W(cmd->unused7)); - writer->Write((uint32_t)0x0); - writer->Write((uint32_t)0x0); - writer->Write((uint32_t)0x0); - } - break; - } - case (uint32_t)CutsceneCommands::SetCameraPosLink: - { - CutsceneCommandSetCameraPos* cmdCamPos = (CutsceneCommandSetCameraPos*)cs->commands[i]; - - writer->Write(CS_CMD_CAM_EYE_REL_TO_PLAYER); - writer->Write(CMD_HH(0x0001, ((CutsceneCommandSetCameraPos*)cs->commands[i])->startFrame)); - writer->Write(CMD_HH(cmdCamPos->endFrame, 0x0000)); - - for (const auto& e : cs->commands[i]->entries) - { - CutsceneCameraPoint* point = (CutsceneCameraPoint*)e; - writer->Write(CMD_BBH(point->continueFlag, point->cameraRoll, point->nextPointFrame)); - writer->Write(point->viewAngle); - writer->Write(CMD_HH(point->posX, point->posY)); - writer->Write(CMD_HH(point->posZ, point->unused)); - } - break; - } - case (uint32_t)CutsceneCommands::SetCameraFocusLink: - { - CutsceneCommandSetCameraPos* cmdCamPos = (CutsceneCommandSetCameraPos*)cs->commands[i]; - - writer->Write(CS_CMD_CAM_AT_REL_TO_PLAYER); - writer->Write(CMD_HH(0x0001, ((CutsceneCommandSetCameraPos*)cs->commands[i])->startFrame)); - writer->Write(CMD_HH(cmdCamPos->endFrame, 0x0000)); - - for (const auto& e : cs->commands[i]->entries) - { - CutsceneCameraPoint* point = (CutsceneCameraPoint*)e; - writer->Write(CMD_BBH(point->continueFlag, point->cameraRoll, point->nextPointFrame)); - writer->Write(point->viewAngle); - writer->Write(CMD_HH(point->posX, point->posY)); - writer->Write(CMD_HH(point->posZ, point->unused)); - } - break; - } - - case (uint32_t)CutsceneCommands::Cmd07: // Not used in OOT - break; - case (uint32_t)CutsceneCommands::Cmd08: // Not used in OOT - break; - - case (uint32_t)CutsceneCommands::Cmd09: - { - writer->Write(CS_CMD_09); - writer->Write((uint32_t)CMD_W(((CutsceneCommand_Rumble*)cs->commands[i])->entries.size())); - - for (const auto& e : cs->commands[i]->entries) - { - CutsceneSubCommandEntry_Rumble* r = (CutsceneSubCommandEntry_Rumble*)e; - writer->Write(CMD_HH(r->base, r->startFrame)); - writer->Write(CMD_HBB(e->endFrame, r->unk_06, r->unk_07)); - writer->Write(CMD_BBH(r->unk_08, r->unk_09, r->unk_0A)); - } - break; - } - case 0x15://Both unused in OoT - case 0x1A://(uint32_t)CutsceneCommands::Unknown: - { -#if 0 - CutsceneCommandUnknown* cmdUnk = (CutsceneCommandUnknown*)cs->commands[i]; - writer->Write((uint32_t)cs->commands[i]->commandID); - writer->Write((uint32_t)cmdUnk->entries.size()); - - for (const auto e : cmdUnk->entries) - { - writer->Write(CMD_W(e->unused0)); - writer->Write(CMD_W(e->unused1)); - writer->Write(CMD_W(e->unused2)); - writer->Write(CMD_W(e->unused3)); - writer->Write(CMD_W(e->unused4)); - writer->Write(CMD_W(e->unused5)); - writer->Write(CMD_W(e->unused6)); - writer->Write(CMD_W(e->unused7)); - writer->Write(CMD_W(e->unused8)); - writer->Write(CMD_W(e->unused9)); - writer->Write(CMD_W(e->unused10)); - writer->Write(CMD_W(e->unused11)); - } -#endif - } - break; - case (uint32_t)CutsceneCommands::Textbox: - { - writer->Write(CS_CMD_TEXTBOX); - writer->Write((uint32_t)CMD_W((cs->commands[i])->entries.size())); - - for (const auto& e : cs->commands[i]->entries) - { - CutsceneSubCommandEntry_TextBox* textBox = (CutsceneSubCommandEntry_TextBox*)e; - if (textBox->base == 0xFFFF) // CS_TEXT_NONE - { - writer->Write(CMD_HH(0xFFFF, textBox->startFrame)); - writer->Write(CMD_HH(textBox->endFrame, 0xFFFF)); - writer->Write(CMD_HH(0xFFFF, 0xFFFF)); - } - else // CS_TEXT_DISPLAY_TEXTBOX - { - writer->Write(CMD_HH(textBox->base, textBox->startFrame)); - writer->Write(CMD_HH(textBox->endFrame, textBox->type)); - writer->Write(CMD_HH(textBox->textId1, textBox->textId2)); - } - } - break; - } - case 10: //ActorAction0 - case (uint32_t)CutsceneCommands::SetActorAction1: - case 17: - case 18: - case 23: - case 34: - case 39: - case 46: - case 76: - case 85: - case 93: - case 105: - case 107: - case 110: - case 119: - case 123: - case 138: - case 139: - case 144: - case (uint32_t)CutsceneCommands::SetActorAction2: - case 16: - case 24: - case 35: - case 40: - case 48: - case 64: - case 68: - case 70: - case 78: - case 80: - case 94: - case 116: - case 118: - case 120: - case 125: - case 131: - case 141: - case (uint32_t)CutsceneCommands::SetActorAction3: - case 36: - case 41: - case 50: - case 67: - case 69: - case 72: - case 74: - case 81: - case 106: - case 117: - case 121: - case 126: - case 132: - case (uint32_t)CutsceneCommands::SetActorAction4: - case 37: - case 42: - case 51: - case 53: - case 63: - case 65: - case 66: - case 75: - case 82: - case 108: - case 127: - case 133: - case (uint32_t)CutsceneCommands::SetActorAction5: - case 38: - case 43: - case 47: - case 54: - case 79: - case 83: - case 128: - case 135: - case (uint32_t)CutsceneCommands::SetActorAction6: - case 55: - case 77: - case 84: - case 90: - case 129: - case 136: - case (uint32_t)CutsceneCommands::SetActorAction7: - case 52: - case 57: - case 58: - case 88: - case 115: - case 130: - case 137: - case (uint32_t)CutsceneCommands::SetActorAction8: - case 60: - case 89: - case 111: - case 114: - case 134: - case 142: - case (uint32_t)CutsceneCommands::SetActorAction9: - case (uint32_t)CutsceneCommands::SetActorAction10: - { - writer->Write((uint32_t)(CutsceneCommands)cs->commands[i]->commandID); - writer->Write((uint32_t)CMD_W(cs->commands[i]->entries.size())); - - for (const auto& e : cs->commands[i]->entries) - { - CutsceneSubCommandEntry_ActorAction* actorAct = (CutsceneSubCommandEntry_ActorAction*)e; - writer->Write(CMD_HH(actorAct->base, actorAct->startFrame)); - writer->Write(CMD_HH(actorAct->endFrame, actorAct->rotX)); - writer->Write(CMD_HH(actorAct->rotY, actorAct->rotZ)); - writer->Write(CMD_W(actorAct->startPosX)); - writer->Write(CMD_W(actorAct->startPosY)); - writer->Write(CMD_W(actorAct->startPosZ)); - writer->Write(CMD_W(actorAct->endPosX)); - writer->Write(CMD_W(actorAct->endPosY)); - writer->Write(CMD_W(actorAct->endPosZ)); - writer->Write(CMD_W(actorAct->normalX)); - writer->Write(CMD_W(actorAct->normalY)); - writer->Write(CMD_W(actorAct->normalZ)); - } - - break; - } - case (uint32_t)CutsceneCommands::SetSceneTransFX: - { - CutsceneCommandSceneTransFX* cmdTFX = (CutsceneCommandSceneTransFX*)cs->commands[i]; - - writer->Write(CS_CMD_SCENE_TRANS_FX); - writer->Write((uint32_t)1); - writer->Write(CMD_HH((((CutsceneCommandSceneTransFX*)cs->commands[i])->base), ((CutsceneCommandSceneTransFX*)cs->commands[i])->startFrame)); - writer->Write(CMD_HH((((CutsceneCommandSceneTransFX*)cs->commands[i])->endFrame), ((CutsceneCommandSceneTransFX*)cs->commands[i])->endFrame)); - break; - } - case (uint32_t)CutsceneCommands::PlayBGM: - { - writer->Write(CS_CMD_PLAYBGM); - writer->Write((uint32_t)CMD_W(cs->commands[i]->entries.size())); - - for (const auto& e : cs->commands[i]->entries) - { - CutsceneSubCommandEntry_GenericCmd* cmd = (CutsceneSubCommandEntry_GenericCmd*)e; - writer->Write(CMD_HH(cmd->base, cmd->startFrame)); - writer->Write(CMD_HH(cmd->endFrame, cmd->pad)); - writer->Write(CMD_W(cmd->unused1)); - writer->Write(CMD_W(cmd->unused2)); - writer->Write(CMD_W(cmd->unused3)); - writer->Write(CMD_W(cmd->unused4)); - writer->Write(CMD_W(cmd->unused5)); - writer->Write(CMD_W(cmd->unused6)); - writer->Write(CMD_W(cmd->unused7)); - writer->Write((uint32_t)0); - writer->Write((uint32_t)0); - writer->Write((uint32_t)0); - } - break; - } - case (uint32_t)CutsceneCommands::StopBGM: - { - writer->Write(CS_CMD_STOPBGM); - writer->Write((uint32_t)CMD_W(cs->commands[i]->entries.size())); - - for (const auto& e : cs->commands[i]->entries) - { - CutsceneSubCommandEntry_GenericCmd* cmd = (CutsceneSubCommandEntry_GenericCmd*)e; - writer->Write(CMD_HH(cmd->base, cmd->startFrame)); - writer->Write(CMD_HH(cmd->endFrame, cmd->pad)); - writer->Write(CMD_W(cmd->unused1)); - writer->Write(CMD_W(cmd->unused2)); - writer->Write(CMD_W(cmd->unused3)); - writer->Write(CMD_W(cmd->unused4)); - writer->Write(CMD_W(cmd->unused5)); - writer->Write(CMD_W(cmd->unused6)); - writer->Write(CMD_W(cmd->unused7)); - writer->Write((uint32_t)0); - writer->Write((uint32_t)0); - writer->Write((uint32_t)0); - } - break; - } - case (uint32_t)CutsceneCommands::FadeBGM: - { - writer->Write(CS_CMD_FADEBGM); - writer->Write((uint32_t)CMD_W(cs->commands[i]->entries.size())); - - for (const auto& e : cs->commands[i]->entries) - { - CutsceneSubCommandEntry_GenericCmd* cmd = (CutsceneSubCommandEntry_GenericCmd*)e; - writer->Write(CMD_HH(cmd->base, cmd->startFrame)); - writer->Write(CMD_HH(cmd->endFrame, cmd->pad)); - writer->Write(CMD_W(cmd->unused1)); - writer->Write(CMD_W(cmd->unused2)); - writer->Write(CMD_W(cmd->unused3)); - writer->Write(CMD_W(cmd->unused4)); - writer->Write(CMD_W(cmd->unused5)); - writer->Write(CMD_W(cmd->unused6)); - writer->Write(CMD_W(cmd->unused7)); - writer->Write((uint32_t)0); - writer->Write((uint32_t)0); - writer->Write((uint32_t)0); - } - break; - } - case (uint32_t)CutsceneCommands::SetTime: - { - writer->Write(CS_CMD_SETTIME); - writer->Write((uint32_t)CMD_W(cs->commands[i]->entries.size())); - - for (const auto& e : cs->commands[i]->entries) - { - CutsceneSubCommandEntry_SetTime* t = (CutsceneSubCommandEntry_SetTime*)e; - writer->Write(CMD_HH(t->base, t->startFrame)); - writer->Write(CMD_HBB(t->endFrame, t->hour, t->minute)); - writer->Write((uint32_t)CMD_W(t->unk_08)); - } - break; - } - case (uint32_t)CutsceneCommands::Terminator: - { - CutsceneCommand_Terminator* t = (CutsceneCommand_Terminator*)cs->commands[i]; - writer->Write(CS_CMD_TERMINATOR); - writer->Write((uint32_t)1); - writer->Write(CMD_HH(t->base, t->startFrame)); - writer->Write(CMD_HH(t->endFrame, t->endFrame)); - break; - } - default: - { - //writer->Write((uint32_t)cs->commands[i]->commandID); - printf("Undefined CS Opcode: %04X\n", cs->commands[i]->commandID); - } - break; - } - } - - //CS_END - writer->Write(0xFFFFFFFF); - writer->Write((uint32_t)0); - - const auto endStream = writer->GetBaseAddress(); - writer->Seek((uint32_t)currentStream - 4, SeekOffsetType::Start); - writer->Write((uint32_t)((endStream - currentStream) / 4)); - writer->Seek((uint32_t)endStream, SeekOffsetType::Start); -} \ No newline at end of file diff --git a/OTRExporter/OTRExporter/CutsceneExporter.h b/OTRExporter/OTRExporter/CutsceneExporter.h deleted file mode 100644 index 96903fdba..000000000 --- a/OTRExporter/OTRExporter/CutsceneExporter.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once -#include "ZResource.h" -#include "ZCutscene.h" -#include "z64cutscene_commands.h" -#include "Exporter.h" - -class OTRExporter_Cutscene : public OTRExporter -{ -public: - virtual void Save(ZResource* res, const fs::path& outPath, BinaryWriter* writer) override; -}; \ No newline at end of file diff --git a/OTRExporter/OTRExporter/DisplayListExporter.cpp b/OTRExporter/OTRExporter/DisplayListExporter.cpp deleted file mode 100644 index 81863f09d..000000000 --- a/OTRExporter/OTRExporter/DisplayListExporter.cpp +++ /dev/null @@ -1,907 +0,0 @@ -#include "DisplayListExporter.h" -#include "Main.h" -#include "../ZAPD/ZFile.h" -#include -#include -#include "StrHash64/StrHash64.h" -#include "spdlog/spdlog.h" -#include -#include -#include -#include -#include "MtxExporter.h" -#include -#include "VersionInfo.h" - -#define GFX_SIZE 8 - -#define gsDPSetCombineLERP_NoMacros(a0, b0, c0, d0, Aa0, Ab0, Ac0, Ad0, \ - a1, b1, c1, d1, Aa1, Ab1, Ac1, Ad1) \ -{ \ - _SHIFTL(G_SETCOMBINE, 24, 8) | \ - _SHIFTL(GCCc0w0(a0, c0, \ - Aa0, Ac0) | \ - GCCc1w0(a1, c1), 0, 24), \ - (unsigned int)(GCCc0w1(b0, d0, \ - Ab0, Ad0) | \ - GCCc1w1(b1, Aa1, \ - Ac1, d1, \ - Ab1, Ad1)) \ -} - -#define gsSPBranchLessZraw2(dl, vtx, zval) \ -{ _SHIFTL(G_BRANCH_Z,24,8)|_SHIFTL((vtx)*5,12,12)|_SHIFTL((vtx)*2,0,12),\ - (unsigned int)(zval), } - -#define gsSPBranchLessZraw3(dl) \ -{ _SHIFTL(G_RDPHALF_1,24,8), \ - (unsigned int)(dl), } - -#define gsDPWordLo(wordlo) \ - gsImmp1(G_RDPHALF_2, (unsigned int)(wordlo)) - -#define gsSPTextureRectangle2(xl, yl, xh, yh, tile) \ -{ (_SHIFTL(G_TEXRECT, 24, 8) | _SHIFTL(xh, 12, 12) | _SHIFTL(yh, 0, 12)),\ - (_SHIFTL(tile, 24, 3) | _SHIFTL(xl, 12, 12) | _SHIFTL(yl, 0, 12)) } - -void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, BinaryWriter* writer) -{ - ZDisplayList* dList = (ZDisplayList*)res; - - //printf("Exporting DList %s\n", dList->GetName().c_str()); - - WriteHeader(res, outPath, writer, LUS::ResourceType::DisplayList); - - while (writer->GetBaseAddress() % 8 != 0) - writer->Write((uint8_t)0xFF); - - // DEBUG: Write in a marker - Declaration* dbgDecl = dList->parent->GetDeclaration(dList->GetRawDataIndex()); - std::string dbgName = StringHelper::Sprintf("%s/%s", GetParentFolderName(res).c_str(), dbgDecl->varName.c_str()); - uint64_t hash = CRC64(dbgName.c_str()); - writer->Write((uint32_t)(G_MARKER << 24)); - writer->Write((uint32_t)0xBEEFBEEF); - writer->Write((uint32_t)(hash >> 32)); - writer->Write((uint32_t)(hash & 0xFFFFFFFF)); - - auto dlStart = std::chrono::steady_clock::now(); - - //for (auto data : dList->instructions) - for (size_t dataIdx = 0; dataIdx < dList->instructions.size(); dataIdx++) - { - auto data = dList->instructions[dataIdx]; - uint32_t word0 = 0; - uint32_t word1 = 0; - uint8_t opcode = (uint8_t)(data >> 56); - F3DZEXOpcode opF3D = (F3DZEXOpcode)opcode; - - if ((int)opF3D == G_DL)// || (int)opF3D == G_BRANCH_Z) - opcode = (uint8_t)G_DL_OTR_HASH; - - if ((int)opF3D == G_MTX) - opcode = (uint8_t)G_MTX_OTR; - - if ((int)opF3D == G_BRANCH_Z) - opcode = (uint8_t)G_BRANCH_Z_OTR; - - if ((int)opF3D == G_VTX) - opcode = (uint8_t)G_VTX_OTR_HASH; - - if ((int)opF3D == G_SETTIMG) - opcode = (uint8_t)G_SETTIMG_OTR_HASH; - - word0 += (opcode << 24); - - switch ((int)opF3D) - { - case G_NOOP: - { - Gfx value = {gsDPNoOp()}; - word0 = value.words.w0; - word1 = value.words.w1; - } - break; - case G_ENDDL: - { - Gfx value = {gsSPEndDisplayList()}; - word0 = value.words.w0; - word1 = value.words.w1; - } - break; - case G_MODIFYVTX: - { - int32_t ww = (data & 0x00FF000000000000ULL) >> 48; - int32_t nnnn = (data & 0x0000FFFF00000000ULL) >> 32; - int32_t vvvvvvvv = (data & 0x00000000FFFFFFFFULL); - - Gfx value = {gsSPModifyVertex(nnnn / 2, ww, vvvvvvvv)}; - word0 = value.words.w0; - word1 = value.words.w1; - } - break; - default: - { - printf("Undefined opcode: %02X\n", opcode); - //word0 = _byteswap_ulong((uint32_t)(data >> 32)); - //word1 = _byteswap_ulong((uint32_t)(data & 0xFFFFFFFF)); - } - break; - case G_GEOMETRYMODE: - { - int32_t cccccc = (data & 0x00FFFFFF00000000) >> 32; - int32_t ssssssss = (data & 0xFFFFFFFF); - - Gfx value = {gsSPGeometryMode(~cccccc, ssssssss)}; - word0 = value.words.w0; - word1 = value.words.w1; - } - break; - case G_RDPPIPESYNC: - { - Gfx value = {gsDPPipeSync()}; - word0 = value.words.w0; - word1 = value.words.w1; - } - break; - case G_RDPLOADSYNC: - { - Gfx value = {gsDPLoadSync()}; - word0 = value.words.w0; - word1 = value.words.w1; - } - break; - case G_RDPTILESYNC: - { - Gfx value = {gsDPTileSync()}; - word0 = value.words.w0; - word1 = value.words.w1; - } - break; - case G_RDPFULLSYNC: - { - Gfx value = {gsDPFullSync()}; - word0 = value.words.w0; - word1 = value.words.w1; - } - break; - case G_RDPSETOTHERMODE: - { - int32_t hhhhhh = (data & 0x00FFFFFF00000000) >> 32; - int32_t llllllll = (data & 0x00000000FFFFFFFF); - - Gfx value = {gsDPSetOtherMode(hhhhhh, llllllll)}; - word0 = value.words.w0; - word1 = value.words.w1; - } - break; - case G_POPMTX: - { - Gfx value = {gsSPPopMatrix(data)}; - word0 = value.words.w0; - word1 = value.words.w1; - } - break; - case G_SETENVCOLOR: - { - uint8_t r = (uint8_t)((data & 0xFF000000) >> 24); - uint8_t g = (uint8_t)((data & 0x00FF0000) >> 16); - uint8_t b = (uint8_t)((data & 0xFF00FF00) >> 8); - uint8_t a = (uint8_t)((data & 0x000000FF) >> 0); - - Gfx value = {gsDPSetEnvColor(r, g, b, a)}; - word0 = value.words.w0; - word1 = value.words.w1; - } - break; - case G_MTX: - { - if ((!Globals::Instance->HasSegment(GETSEGNUM(data), res->parent->workerID)) || ((data & 0xFFFFFFFF) == 0x07000000)) // En_Zf and En_Ny place a DL in segment 7 - { - uint32_t pp = (data & 0x000000FF00000000) >> 32; - uint32_t mm = (data & 0x00000000FFFFFFFF); - - pp ^= G_MTX_PUSH; - - mm = (mm & 0x0FFFFFFF) + 1; - - Gfx value = {gsSPMatrix(mm, pp)}; - word0 = value.words.w0; - word1 = value.words.w1; - } - else - { - uint32_t pp = (data & 0x000000FF00000000) >> 32; - uint32_t mm = (data & 0x00000000FFFFFFFF); - pp ^= G_MTX_PUSH; - - Gfx value = {gsSPMatrix(mm, pp)}; - word0 = value.words.w0; - word1 = value.words.w1; - - word0 = (word0 & 0x00FFFFFF) + (G_MTX_OTR << 24); - - Declaration* mtxDecl = dList->parent->GetDeclaration(GETSEGOFFSET(mm)); - - int bp = 0; - - writer->Write(word0); - writer->Write(word1); - - if (mtxDecl != nullptr) - { - std::string vName = StringHelper::Sprintf("%s/%s", (GetParentFolderName(res).c_str()), mtxDecl->varName.c_str()); - - uint64_t hash = CRC64(vName.c_str()); - - word0 = hash >> 32; - word1 = hash & 0xFFFFFFFF; - } - else - { - word0 = 0; - word1 = 0; - spdlog::error(StringHelper::Sprintf("dListDecl == nullptr! Addr = {:08X}", GETSEGOFFSET(data))); - } - } - } - break; - case G_LOADBLOCK: - { - int32_t sss = (data & 0x00FFF00000000000) >> 48; - int32_t ttt = (data & 0x00000FFF00000000) >> 36; - int32_t i = (data & 0x000000000F000000) >> 24; - int32_t xxx = (data & 0x0000000000FFF000) >> 12; - int32_t ddd = (data & 0x0000000000000FFF); - - Gfx value = {gsDPLoadBlock(i, sss, ttt, xxx, ddd)}; - word0 = value.words.w0; - word1 = value.words.w1; - } - break; - case G_CULLDL: - { - int32_t vvvv = (data & 0xFFFF00000000) >> 32; - int32_t wwww = (data & 0x0000FFFF); - - Gfx value = {gsSPCullDisplayList(vvvv / 2, wwww / 2)}; - word0 = value.words.w0; - word1 = value.words.w1; - } - break; - case G_RDPHALF_1: - { - auto data2 = dList->instructions[dataIdx + 1]; - - if ((data2 >> 56) != G_BRANCH_Z) - { - uint32_t a = (data & 0x00FFF00000000000) >> 44; - uint32_t b = (data & 0x00000FFF00000000) >> 32; - uint32_t z = (data & 0x00000000FFFFFFFF) >> 0; - uint32_t h = (data & 0xFFFFFFFF); - - Gfx value = {gsSPBranchLessZraw3(h & 0x00FFFFFF)}; - word0 = value.words.w0; - word1 = value.words.w1; - } - else - { - word0 = (G_NOOP << 24); - word1 = 0; - } - } - break; - case G_RDPHALF_2: - { - Gfx value = {gsDPWordLo(data & 0xFFFFFFFF)}; - word0 = value.words.w0; - word1 = value.words.w1; - } - break; - case G_TEXRECT: - { - int32_t xxx = (data & 0x00FFF00000000000) >> 44; - int32_t yyy = (data & 0x00000FFF00000000) >> 32; - int32_t i = (data & 0x000000000F000000) >> 24; - int32_t XXX = (data & 0x0000000000FFF000) >> 12; - int32_t YYY = (data & 0x0000000000000FFF); - - Gfx value = {gsSPTextureRectangle2(XXX, YYY, xxx, yyy, i)}; - word0 = value.words.w0; - word1 = value.words.w1; - } - break; - case G_BRANCH_Z: - { - uint32_t a = (data & 0x00FFF00000000000) >> 44; - uint32_t b = (data & 0x00000FFF00000000) >> 32; - uint32_t z = (data & 0x00000000FFFFFFFF) >> 0; - uint32_t h = (data & 0xFFFFFFFF); - - auto data2 = dList->instructions[dataIdx - 1]; - uint32_t dListPtr = GETSEGOFFSET(data2); - - Declaration* dListDecl = dList->parent->GetDeclaration(dListPtr); - - int bp = 0; - - Gfx value = {gsSPBranchLessZraw2(0xDEADABCD, (a / 5) | (b / 2), z)}; - word0 = (value.words.w0 & 0x00FFFFFF) + (G_BRANCH_Z_OTR << 24); - word1 = value.words.w1; - - writer->Write(word0); - writer->Write(word1); - - if (dListDecl != nullptr) - { - std::string vName = StringHelper::Sprintf("%s/%s", (GetParentFolderName(res).c_str()), dListDecl->varName.c_str()); - - uint64_t hash = CRC64(vName.c_str()); - - word0 = hash >> 32; - word1 = hash & 0xFFFFFFFF; - } - else - { - word0 = 0; - word1 = 0; - spdlog::error(StringHelper::Sprintf("dListDecl == nullptr! Addr = {:08X}", GETSEGOFFSET(data))); - } - - for (size_t i = 0; i < dList->otherDLists.size(); i++) - { - Declaration* dListDecl2 = dList->parent->GetDeclaration(GETSEGOFFSET(dList->otherDLists[i]->GetRawDataIndex())); - - if (dListDecl2 != nullptr) - { - //std::string fName = StringHelper::Sprintf("%s\\%s", GetParentFolderName(res).c_str(), dListDecl2->varName.c_str()); - std::string fName = OTRExporter_DisplayList::GetPathToRes(res, dListDecl2->varName.c_str()); - - if (files.find(fName) == files.end() && !DiskFile::Exists("Extract/" + fName)) - { - MemoryStream* dlStream = new MemoryStream(); - BinaryWriter dlWriter = BinaryWriter(dlStream); - - Save(dList->otherDLists[i], outPath, &dlWriter); - AddFile(fName, dlStream->ToVector()); - } - } - else - { - spdlog::error(StringHelper::Sprintf("dListDecl2 == nullptr! Addr = {:08X}", GETSEGOFFSET(data))); - } - } - - //Gfx value = gsSPBranchLessZraw2(h & 0x00FFFFFF, (a / 5) | (b / 2), z); - //word0 = value.words.w0; - //word1 = value.words.w1; - } - break; - //case G_BRANCH_Z: - case G_DL: - { - if ((!Globals::Instance->HasSegment(GETSEGNUM(data), res->parent->workerID) && (int)opF3D != G_BRANCH_Z) - || ((data & 0xFFFFFFFF) == 0x07000000)) // En_Zf and En_Ny place a DL in segment 7 - { - int32_t pp = (data & 0x00FF000000000000) >> 56; - - Gfx value; - - u32 dListVal = (data & 0x0FFFFFFF) + 1; - - if (pp != 0) - value = {gsSPBranchList(dListVal)}; - else - value = {gsSPDisplayList(dListVal)}; - - word0 = value.words.w0; - word1 = value.words.w1; - } - else - { - uint32_t dListPtr = GETSEGOFFSET(data); - - if ((int)opF3D == G_BRANCH_Z) - { - auto data2 = dList->instructions[dataIdx - 1]; - dListPtr = GETSEGOFFSET(data2); - } - else - { - int bp = 0; - } - - Declaration* dListDecl = dList->parent->GetDeclaration(dListPtr); - - int bp = 0; - - writer->Write(word0); - writer->Write(word1); - - if (dListDecl != nullptr) - { - std::string vName = StringHelper::Sprintf("%s/%s", (GetParentFolderName(res).c_str()), dListDecl->varName.c_str()); - - uint64_t hash = CRC64(vName.c_str()); - - word0 = hash >> 32; - word1 = hash & 0xFFFFFFFF; - } - else - { - word0 = 0; - word1 = 0; - spdlog::error(StringHelper::Sprintf("dListDecl == nullptr! Addr = {:08X}", GETSEGOFFSET(data))); - } - - for (size_t i = 0; i < dList->otherDLists.size(); i++) - { - Declaration* dListDecl2 = dList->parent->GetDeclaration(GETSEGOFFSET(dList->otherDLists[i]->GetRawDataIndex())); - - if (dListDecl2 != nullptr) - { - //std::string fName = StringHelper::Sprintf("%s\\%s", GetParentFolderName(res).c_str(), dListDecl2->varName.c_str()); - std::string fName = OTRExporter_DisplayList::GetPathToRes(res, dListDecl2->varName.c_str()); - - if (files.find(fName) == files.end() && !DiskFile::Exists("Extract/" + fName)) - { - MemoryStream* dlStream = new MemoryStream(); - BinaryWriter dlWriter = BinaryWriter(dlStream); - - Save(dList->otherDLists[i], outPath, &dlWriter); - - AddFile(fName, dlStream->ToVector()); - } - } - else - { - spdlog::error(StringHelper::Sprintf("dListDecl2 == nullptr! Addr = {:08X}", GETSEGOFFSET(data))); - } - } - } - } - break; - case G_TEXTURE: - { - int32_t ____ = (data & 0x0000FFFF00000000) >> 32; - int32_t ssss = (data & 0x00000000FFFF0000) >> 16; - int32_t tttt = (data & 0x000000000000FFFF); - int32_t lll = (____ & 0x3800) >> 11; - int32_t ddd = (____ & 0x700) >> 8; - int32_t nnnnnnn = (____ & 0xFE) >> 1; - - Gfx value = {gsSPTexture(ssss, tttt, lll, ddd, nnnnnnn)}; - word0 = value.words.w0; - word1 = value.words.w1; - } - break; - case G_TRI1: - { - int32_t aa = ((data & 0x00FF000000000000ULL) >> 48) / 2; - int32_t bb = ((data & 0x0000FF0000000000ULL) >> 40) / 2; - int32_t cc = ((data & 0x000000FF00000000ULL) >> 32) / 2; - - Gfx test = {gsSP1Triangle(aa, bb, cc, 0)}; - word0 = test.words.w0; - word1 = test.words.w1; - } - break; - case G_TRI2: - { - int32_t aa = ((data & 0x00FF000000000000ULL) >> 48) / 2; - int32_t bb = ((data & 0x0000FF0000000000ULL) >> 40) / 2; - int32_t cc = ((data & 0x000000FF00000000ULL) >> 32) / 2; - int32_t dd = ((data & 0x00000000FF0000ULL) >> 16) / 2; - int32_t ee = ((data & 0x0000000000FF00ULL) >> 8) / 2; - int32_t ff = ((data & 0x000000000000FFULL) >> 0) / 2; - - Gfx test = {gsSP2Triangles(aa, bb, cc, 0, dd, ee, ff, 0)}; - word0 = test.words.w0; - word1 = test.words.w1; - } - break; - case G_QUAD: - { - int32_t aa = ((data & 0x00FF000000000000ULL) >> 48) / 2; - int32_t bb = ((data & 0x0000FF0000000000ULL) >> 40) / 2; - int32_t cc = ((data & 0x000000FF00000000ULL) >> 32) / 2; - int32_t dd = ((data & 0x000000000000FFULL)) / 2; - - Gfx test = {gsSP1Quadrangle(aa, bb, cc, dd, 0)}; - word0 = test.words.w0; - word1 = test.words.w1; - } - break; - case G_SETPRIMCOLOR: - { - int32_t mm = (data & 0x0000FF0000000000) >> 40; - int32_t ff = (data & 0x000000FF00000000) >> 32; - int32_t rr = (data & 0x00000000FF000000) >> 24; - int32_t gg = (data & 0x0000000000FF0000) >> 16; - int32_t bb = (data & 0x000000000000FF00) >> 8; - int32_t aa = (data & 0x00000000000000FF) >> 0; - - Gfx value = {gsDPSetPrimColor(mm, ff, rr, gg, bb, aa)}; - word0 = value.words.w0; - word1 = value.words.w1; - } - break; - case G_SETOTHERMODE_L: - { - int32_t ss = (data & 0x0000FF0000000000) >> 40; - int32_t len = ((data & 0x000000FF00000000) >> 32) + 1; - int32_t sft = 32 - (len)-ss; - int32_t dd = (data & 0xFFFFFFFF); - - // TODO: Output the correct render modes in data - - Gfx value = {gsSPSetOtherMode(0xE2, sft, len, dd)}; - word0 = value.words.w0; - word1 = value.words.w1; - } - break; - case G_SETOTHERMODE_H: - { - int32_t ss = (data & 0x0000FF0000000000) >> 40; - int32_t nn = (data & 0x000000FF00000000) >> 32; - int32_t dd = (data & 0xFFFFFFFF); - - int32_t sft = 32 - (nn + 1) - ss; - - Gfx value; - - if (sft == 14) // G_MDSFT_TEXTLUT - { - const char* types[] = { "G_TT_NONE", "G_TT_NONE", "G_TT_RGBA16", "G_TT_IA16" }; - value = {gsDPSetTextureLUT(dd >> 14)}; - } - else - { - value = {gsSPSetOtherMode(0xE3, sft, nn + 1, dd)}; - } - - word0 = value.words.w0; - word1 = value.words.w1; - } - break; - case G_SETTILE: - { - int32_t fff = (data & 0b0000000011100000000000000000000000000000000000000000000000000000) >> 53; - int32_t ii = (data & 0b0000000000011000000000000000000000000000000000000000000000000000) >> 51; - int32_t nnnnnnnnn = - (data & 0b0000000000000011111111100000000000000000000000000000000000000000) >> 41; - int32_t mmmmmmmmm = - (data & 0b0000000000000000000000011111111100000000000000000000000000000000) >> 32; - int32_t ttt = (data & 0b0000000000000000000000000000000000000111000000000000000000000000) >> 24; - int32_t pppp = - (data & 0b0000000000000000000000000000000000000000111100000000000000000000) >> 20; - int32_t cc = (data & 0b0000000000000000000000000000000000000000000011000000000000000000) >> 18; - int32_t aaaa = - (data & 0b0000000000000000000000000000000000000000000000111100000000000000) >> 14; - int32_t ssss = - (data & 0b0000000000000000000000000000000000000000000000000011110000000000) >> 10; - int32_t dd = (data & 0b0000000000000000000000000000000000000000000000000000001100000000) >> 8; - int32_t bbbb = (data & 0b0000000000000000000000000000000000000000000000000000000011110000) >> 4; - int32_t uuuu = (data & 0b0000000000000000000000000000000000000000000000000000000000001111); - - Gfx value = {gsDPSetTile(fff, ii, nnnnnnnnn, mmmmmmmmm, ttt, pppp, cc, aaaa, ssss, dd, bbbb, uuuu)}; - word0 = value.words.w0; - word1 = value.words.w1; - } - break; - case G_SETCOMBINE: - { - int32_t a0 = (data & 0b000000011110000000000000000000000000000000000000000000000000000) >> 52; - int32_t c0 = (data & 0b000000000001111100000000000000000000000000000000000000000000000) >> 47; - int32_t aa0 = (data & 0b00000000000000011100000000000000000000000000000000000000000000) >> 44; - int32_t ac0 = (data & 0b00000000000000000011100000000000000000000000000000000000000000) >> 41; - int32_t a1 = (data & 0b000000000000000000000011110000000000000000000000000000000000000) >> 37; - int32_t c1 = (data & 0b000000000000000000000000001111100000000000000000000000000000000) >> 32; - int32_t b0 = (data & 0b000000000000000000000000000000011110000000000000000000000000000) >> 28; - int32_t b1 = (data & 0b000000000000000000000000000000000001111000000000000000000000000) >> 24; - int32_t aa1 = (data & 0b00000000000000000000000000000000000000111000000000000000000000) >> 21; - int32_t ac1 = (data & 0b00000000000000000000000000000000000000000111000000000000000000) >> 18; - int32_t d0 = (data & 0b000000000000000000000000000000000000000000000111000000000000000) >> 15; - int32_t ab0 = (data & 0b00000000000000000000000000000000000000000000000111000000000000) >> 12; - int32_t ad0 = (data & 0b00000000000000000000000000000000000000000000000000111000000000) >> 9; - int32_t d1 = (data & 0b000000000000000000000000000000000000000000000000000000111000000) >> 6; - int32_t ab1 = (data & 0b00000000000000000000000000000000000000000000000000000000111000) >> 3; - int32_t ad1 = (data & 0b00000000000000000000000000000000000000000000000000000000000111) >> 0; - - Gfx value = { gsDPSetCombineLERP_NoMacros(a0, b0, c0, d0, aa0, ab0, ac0, ad0, a1, b1, c1, d1, aa1, ab1, ac1, ad1)}; - word0 = value.words.w0; - word1 = value.words.w1; - } - break; - case G_SETTILESIZE: - { - int32_t sss = (data & 0x00FFF00000000000) >> 44; - int32_t ttt = (data & 0x00000FFF00000000) >> 32; - int32_t uuu = (data & 0x0000000000FFF000) >> 12; - int32_t vvv = (data & 0x0000000000000FFF); - int32_t i = (data & 0x000000000F000000) >> 24; - - Gfx value = {gsDPSetTileSize(i, sss, ttt, uuu, vvv)}; - word0 = value.words.w0; - word1 = value.words.w1; - } - break; - case G_LOADTLUT: - { - int32_t t = (data & 0x0000000007000000) >> 24; - int32_t ccc = (data & 0x00000000003FF000) >> 14; - - Gfx value = {gsDPLoadTLUTCmd(t, ccc)}; - word0 = value.words.w0; - word1 = value.words.w1; - } - break; - case G_LOADTILE: - { - int sss = (data & 0x00FFF00000000000) >> 44; - int ttt = (data & 0x00000FFF00000000) >> 32; - int i = (data & 0x000000000F000000) >> 24; - int uuu = (data & 0x0000000000FFF000) >> 12; - int vvv= (data & 0x0000000000000FFF); - - Gfx value = {gsDPLoadTile(i, sss, ttt, uuu, vvv)}; - word0 = value.words.w0; - word1 = value.words.w1; - } - break; - case G_SETTIMG: - { - uint32_t seg = data & 0xFFFFFFFF; - int32_t texAddress = Seg2Filespace(data, dList->parent->baseAddress); - - if (!Globals::Instance->HasSegment(GETSEGNUM(seg), res->parent->workerID) || (res->GetName() == "sShadowMaterialDL")) - { - if (res->GetName() == "sShadowMaterialDL") { - // sShadowMaterialDL (In ovl_En_Jsjutan) has a texture in bss. This is a hack to override the reference to one - // to segment C. The actor has been modified to load the texture into segment C. - seg = 0x0C000000; - } - int32_t __ = (data & 0x00FF000000000000) >> 48; - int32_t www = (data & 0x00000FFF00000000) >> 32; - - uint32_t fmt = (__ & 0xE0) >> 5; - uint32_t siz = (__ & 0x18) >> 3; - - Gfx value = {gsDPSetTextureImage(fmt, siz, www + 1, (seg & 0x0FFFFFFF) + 1)}; - word0 = value.words.w0; - word1 = value.words.w1; - - writer->Write(word0); - writer->Write(word1); - } - else - { - std::string texName = ""; - bool foundDecl = Globals::Instance->GetSegmentedPtrName(seg, dList->parent, "", texName, res->parent->workerID); - - int32_t __ = (data & 0x00FF000000000000) >> 48; - int32_t www = (data & 0x00000FFF00000000) >> 32; - - uint32_t fmt = (__ & 0xE0) >> 5; - uint32_t siz = (__ & 0x18) >> 3; - - Gfx value = {gsDPSetTextureImage(fmt, siz, www + 1, __)}; - word0 = value.words.w0 & 0x00FFFFFF; - word0 += (G_SETTIMG_OTR_HASH << 24); - //word1 = value.words.w1; - word1 = 0; - - writer->Write(word0); - writer->Write(word1); - - if (foundDecl) - { - ZFile* assocFile = Globals::Instance->GetSegment(GETSEGNUM(seg), res->parent->workerID); - std::string assocFileName = assocFile->GetName(); - std::string fName = ""; - - if (GETSEGNUM(seg) == SEGMENT_SCENE || GETSEGNUM(seg) == SEGMENT_ROOM) - fName = GetPathToRes(res, texName.c_str()); - else - fName = GetPathToRes(assocFile->resources[0], texName.c_str()); - - uint64_t hash = CRC64(fName.c_str()); - - word0 = hash >> 32; - word1 = hash & 0xFFFFFFFF; - } - else - { - word0 = 0; - word1 = 0; - spdlog::error("texDecl == nullptr! PTR = 0x{:08X}", texAddress); - } - } - } - break; - case G_VTX: - { - if (GETSEGNUM(data) == 0xC || GETSEGNUM(data) == 0x8) - { - // hack for dynamic verticies used in en_ganon_mant and en_jsjutan - // TODO is there a better way? - int32_t aa = (data & 0x000000FF00000000ULL) >> 32; - int32_t nn = (data & 0x000FF00000000000ULL) >> 44; - - Gfx value = {gsSPVertex(data & 0xFFFFFFFF, nn, ((aa >> 1) - nn))}; - - word0 = value.words.w0; - word1 = value.words.w1 | 1; - } - else - { - // Write CRC64 of vtx file name - uint32_t addr = data & 0xFFFFFFFF; - - if (GETSEGNUM(data) == 0x80) - addr -= dList->parent->baseAddress; - - auto segOffset = GETSEGOFFSET(addr); - Declaration* vtxDecl = dList->parent->GetDeclarationRanged(segOffset); - - int32_t aa = (data & 0x000000FF00000000ULL) >> 32; - int32_t nn = (data & 0x000FF00000000000ULL) >> 44; - - if (vtxDecl != nullptr && vtxDecl->varType != "Gfx") - { - uint32_t diff = segOffset - vtxDecl->address; - - Gfx value = {gsSPVertex(diff, nn, ((aa >> 1) - nn))}; - - word0 = value.words.w0; - word0 &= 0x00FFFFFF; - word0 += (G_VTX_OTR_HASH << 24); - word1 = value.words.w1; - - writer->Write(word0); - writer->Write(word1); - - std::string fName = OTRExporter_DisplayList::GetPathToRes(res, vtxDecl->varName); - - uint64_t hash = CRC64(fName.c_str()); - - word0 = hash >> 32; - word1 = hash & 0xFFFFFFFF; - - if (files.find(fName) == files.end() && !DiskFile::Exists("Extract/" + fName)) - { - // Write vertices to file - MemoryStream* vtxStream = new MemoryStream(); - BinaryWriter vtxWriter = BinaryWriter(vtxStream); - - int arrCnt = 0; - - auto split = StringHelper::Split(vtxDecl->text, "\n"); - - for (size_t i = 0; i < split.size(); i++) - { - std::string line = split[i]; - - if (StringHelper::Contains(line, "VTX(")) - arrCnt++; - } - - // OTRTODO: Once we aren't relying on text representations, we should call ArrayExporter... - OTRExporter::WriteHeader(nullptr, "", &vtxWriter, LUS::ResourceType::Array); - - vtxWriter.Write((uint32_t)ZResourceType::Vertex); - vtxWriter.Write((uint32_t)arrCnt); - - auto start = std::chrono::steady_clock::now(); - - // God dammit this is so dumb - for (size_t i = 0; i < split.size(); i++) - { - std::string line = split[i]; - - if (StringHelper::Contains(line, "VTX(")) - { - auto split2 = StringHelper::Split(StringHelper::Split(StringHelper::Split(line, "VTX(")[1], ")")[0], ","); - - vtxWriter.Write((int16_t)std::stoi(split2[0], nullptr, 10)); // v.x - vtxWriter.Write((int16_t)std::stoi(split2[1], nullptr, 10)); // v.y - vtxWriter.Write((int16_t)std::stoi(split2[2], nullptr, 10)); // v.z - - vtxWriter.Write((int16_t)0); // v.flag - - vtxWriter.Write((int16_t)std::stoi(split2[3], nullptr, 10)); // v.s - vtxWriter.Write((int16_t)std::stoi(split2[4], nullptr, 10)); // v.t - - vtxWriter.Write((uint8_t)std::stoi(split2[5], nullptr, 10)); // v.r - vtxWriter.Write((uint8_t)std::stoi(split2[6], nullptr, 10)); // v.g - vtxWriter.Write((uint8_t)std::stoi(split2[7], nullptr, 10)); // v.b - vtxWriter.Write((uint8_t)std::stoi(split2[8], nullptr, 10)); // v.a - } - } - - AddFile(fName, vtxStream->ToVector()); - - auto end = std::chrono::steady_clock::now(); - size_t diff = std::chrono::duration_cast(end - start).count(); - } - } - else - { - spdlog::error("vtxDecl == nullptr!"); - } - } - } - break; - } - - writer->Write(word0); - writer->Write(word1); - } - - auto dlEnd = std::chrono::steady_clock::now(); - size_t dlDiff = std::chrono::duration_cast(dlEnd - dlStart).count(); - - //printf("Display List Gen in %zums\n", dlDiff); -} - -std::string OTRExporter_DisplayList::GetPathToRes(ZResource* res, std::string varName) -{ - std::string prefix = GetPrefix(res); - std::string fName = StringHelper::Sprintf("%s/%s", GetParentFolderName(res).c_str(), varName.c_str()); - - return fName; -} - -std::string OTRExporter_DisplayList::GetParentFolderName(ZResource* res) -{ - std::string prefix = GetPrefix(res); - std::string oName = res->parent->GetOutName(); - - if (StringHelper::Contains(oName, "_scene")) - { - auto split = StringHelper::Split(oName, "_"); - oName = ""; - for (size_t i = 0; i < split.size() - 1; i++) - oName += split[i] + "_"; - - oName += "scene"; - } - else if (StringHelper::Contains(oName, "_room")) - { - oName = StringHelper::Split(oName, "_room")[0] + "_scene"; - } - - if (prefix != "") - oName = prefix + "/" + oName; - - return oName; -} - -std::string OTRExporter_DisplayList::GetPrefix(ZResource* res) -{ - std::string oName = res->parent->GetOutName(); - std::string prefix = ""; - std::string xmlPath = StringHelper::Replace(res->parent->GetXmlFilePath().string(), "\\", "/"); - - if (StringHelper::Contains(oName, "_scene") || StringHelper::Contains(oName, "_room")) { - prefix = "scenes"; - if (Globals::Instance->rom->IsMQ()) { - prefix += "/mq"; - } else { - prefix += "/nonmq"; - } - } - else if (StringHelper::Contains(xmlPath, "objects/")) - prefix = "objects"; - else if (StringHelper::Contains(xmlPath, "textures/")) - prefix = "textures"; - else if (StringHelper::Contains(xmlPath, "overlays/")) - prefix = "overlays"; - else if (StringHelper::Contains(xmlPath, "misc/")) - prefix = "misc"; - else if (StringHelper::Contains(xmlPath, "text/")) - prefix = "text"; - else if (StringHelper::Contains(xmlPath, "code/")) - prefix = "code"; - - return prefix; -} diff --git a/OTRExporter/OTRExporter/DisplayListExporter.h b/OTRExporter/OTRExporter/DisplayListExporter.h deleted file mode 100644 index d8d96971c..000000000 --- a/OTRExporter/OTRExporter/DisplayListExporter.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -#include "ZResource.h" -#include "ZTexture.h" -#include "ZDisplayList.h" -#include "Exporter.h" -#include - -class OTRExporter_DisplayList : public OTRExporter -{ -public: - virtual void Save(ZResource* res, const fs::path& outPath, BinaryWriter* writer) override; - static std::string GetParentFolderName(ZResource* res); - static std::string GetPathToRes(ZResource* res, std::string varName); - static std::string GetPrefix(ZResource* res); - -}; \ No newline at end of file diff --git a/OTRExporter/OTRExporter/Exporter.cpp b/OTRExporter/OTRExporter/Exporter.cpp deleted file mode 100644 index a523bb16c..000000000 --- a/OTRExporter/OTRExporter/Exporter.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "Exporter.h" -#include "VersionInfo.h" - -void OTRExporter::WriteHeader(ZResource* res, const fs::path& outPath, BinaryWriter* writer, LUS::ResourceType resType, int32_t resVersion) -{ - writer->Write((uint8_t)Endianness::Little); // 0x00 - writer->Write((uint8_t)0); // 0x01 - writer->Write((uint8_t)0); // 0x02 - writer->Write((uint8_t)0); // 0x03 - - writer->Write((uint32_t)resType); // 0x04 - //writer->Write((uint32_t)MAJOR_VERSION); // 0x08 - writer->Write((uint32_t)resVersion); // 0x08 - writer->Write((uint64_t)0xDEADBEEFDEADBEEF); // id, 0x0C - writer->Write((uint32_t)resourceVersions[resType]); // 0x10 - writer->Write((uint64_t)0); // ROM CRC, 0x14 - writer->Write((uint32_t)0); // ROM Enum, 0x1C - - while (writer->GetBaseAddress() < 0x40) - writer->Write((uint32_t)0); // To be used at a later date! -} diff --git a/OTRExporter/OTRExporter/Exporter.h b/OTRExporter/OTRExporter/Exporter.h deleted file mode 100644 index cd4ed9adb..000000000 --- a/OTRExporter/OTRExporter/Exporter.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once -#include "ZResource.h" -#include "ZArray.h" -#include "stdint.h" -//#include "OTRExporter.h" -#include -#include -#include "VersionInfo.h" - -class OTRExporter : public ZResourceExporter -{ -protected: - static void WriteHeader(ZResource* res, const fs::path& outPath, BinaryWriter* writer, LUS::ResourceType resType, int32_t resVersion = 0); -}; \ No newline at end of file diff --git a/OTRExporter/OTRExporter/Main.cpp b/OTRExporter/OTRExporter/Main.cpp deleted file mode 100644 index 506f8bfd4..000000000 --- a/OTRExporter/OTRExporter/Main.cpp +++ /dev/null @@ -1,329 +0,0 @@ -#include "Main.h" -#include "Exporter.h" -#include "BackgroundExporter.h" -#include "TextureExporter.h" -#include "RoomExporter.h" -#include "CollisionExporter.h" -#include "DisplayListExporter.h" -#include "PlayerAnimationExporter.h" -#include "SkeletonExporter.h" -#include "SkeletonLimbExporter.h" -#include "ArrayExporter.h" -#include "VtxExporter.h" -#include "AnimationExporter.h" -#include "CutsceneExporter.h" -#include "PathExporter.h" -#include "TextExporter.h" -#include "BlobExporter.h" -#include "MtxExporter.h" -#include "AudioExporter.h" -#include -#include -#include -#include -#include -#include -#include -#include - -std::string otrFileName = "oot.otr"; -std::shared_ptr otrArchive; -BinaryWriter* fileWriter; -std::chrono::steady_clock::time_point fileStart, resStart; -std::map> files; -std::mutex fileMutex; - -void InitVersionInfo(); - -enum class ExporterFileMode -{ - BuildOTR = (int)ZFileMode::Custom + 1, -}; - -static void ExporterParseFileMode(const std::string& buildMode, ZFileMode& fileMode) -{ - if (buildMode == "botr") - { - fileMode = (ZFileMode)ExporterFileMode::BuildOTR; - - printf("BOTR: Generating OTR Archive...\n"); - - if (DiskFile::Exists(otrFileName)) - otrArchive = std::shared_ptr(new LUS::Archive(otrFileName, true)); - else - otrArchive = LUS::Archive::CreateArchive(otrFileName, 40000); - - auto lst = Directory::ListFiles("Extract"); - - for (auto item : lst) - { - auto fileData = DiskFile::ReadAllBytes(item); - otrArchive->AddFile(StringHelper::Split(item, "Extract/")[1], (uintptr_t)fileData.data(), fileData.size()); - } - } -} - -static void ExporterProgramEnd() -{ - uint32_t crc = 0xFFFFFFFF; - const uint8_t endianness = (uint8_t)Endianness::Big; - - if (Globals::Instance->fileMode == ZFileMode::ExtractDirectory) - { - std::string romPath = Globals::Instance->baseRomPath.string(); - std::vector romData = DiskFile::ReadAllBytes(romPath); - - BitConverter::RomToBigEndian(romData.data(), romData.size()); - - crc = BitConverter::ToUInt32BE(romData, 0x10); - printf("Creating version file...\n"); - - // Get crc from rom - - MemoryStream *versionStream = new MemoryStream(); - BinaryWriter writer(versionStream); - writer.SetEndianness(Endianness::Big); - writer.Write(endianness); - writer.Write(crc); - writer.Close(); - - printf("Created version file.\n"); - - printf("Generating OTR Archive...\n"); - otrArchive = LUS::Archive::CreateArchive(otrFileName, 40000); - - otrArchive->AddFile("version", (uintptr_t)versionStream->ToVector().data(), versionStream->GetLength()); - - for (const auto& item : files) - { - std::string fName = item.first; - if (fName.find("gTitleZeldaShieldLogoMQTex") != std::string::npos && !ZRom(romPath).IsMQ()) - { - size_t pos = 0; - if ((pos = fName.find("gTitleZeldaShieldLogoMQTex", 0)) != std::string::npos) - { - fName.replace(pos, 27, "gTitleZeldaShieldLogoTex"); - } - } - const auto& fileData = item.second; - otrArchive->AddFile(fName, (uintptr_t)fileData.data(), - fileData.size()); - } - } - otrArchive = nullptr; - delete fileWriter; - files.clear(); - - // Add any additional files that need to be manually copied... - if (DiskFile::Exists("soh.otr")) { - return; - } - const auto& lst = Directory::ListFiles("Extract"); - std::shared_ptr sohOtr = LUS::Archive::CreateArchive("soh.otr", 4096); - //sohOtr->AddFile("version", (uintptr_t)versionStream->ToVector().data(), versionStream->GetLength()); - - for (const auto& item : lst) - { - std::vector splitPath = StringHelper::Split(item, "."); - - if (splitPath.size() >= 3) - { - const std::string extension = splitPath.at(splitPath.size() - 1); - const std::string format = splitPath.at(splitPath.size() - 2); - splitPath.pop_back(); - splitPath.pop_back(); - std::string afterPath = std::accumulate(splitPath.begin(), splitPath.end(), std::string("")); - if (extension == "png" && (format == "rgba32" || format == "rgb5a1" || format == "i4" || format == "i8" || format == "ia4" || format == "ia8" || format == "ia16" || format == "ci4" || format == "ci8")) - { - ZTexture tex(nullptr); - Globals::Instance->buildRawTexture = true; - tex.FromPNG(item, ZTexture::GetTextureTypeFromString(format)); - printf("sohOtr->AddFile(%s)\n", StringHelper::Split(afterPath, "Extract/")[1].c_str()); - - OTRExporter_Texture exporter; - - MemoryStream* stream = new MemoryStream(); - BinaryWriter writer(stream); - - exporter.Save(&tex, "", &writer); - - std::string src = tex.GetBodySourceCode(); - writer.Write((char *)src.c_str(), src.size()); - - std::vector fileData = stream->ToVector(); - sohOtr->AddFile(StringHelper::Split(afterPath, "Extract/assets/")[1], (uintptr_t)fileData.data(), fileData.size()); - continue; - } - } - - if (item.find("accessibility") != std::string::npos) - { - std::string extension = splitPath.at(splitPath.size() - 1); - splitPath.pop_back(); - if (extension == "json") - { - const auto &fileData = DiskFile::ReadAllBytes(item); - printf("Adding accessibility texts %s\n", StringHelper::Split(item, "texts/")[1].c_str()); - sohOtr->AddFile(StringHelper::Split(item, "Extract/assets/")[1], (uintptr_t)fileData.data(), fileData.size()); - } - continue; - } - - const auto& fileData = DiskFile::ReadAllBytes(item); - printf("sohOtr->AddFile(%s)\n", StringHelper::Split(item, "Extract/")[1].c_str()); - sohOtr->AddFile(StringHelper::Split(item, item.find("Extract/assets/") != std::string::npos ? "Extract/assets/" : "Extract/")[1], (uintptr_t)fileData.data(), fileData.size()); - } - sohOtr = nullptr; -} - -static void ExporterParseArgs(int argc, char* argv[], int& i) -{ - std::string arg = argv[i]; - - if (arg == "--otrfile") - { - otrFileName = argv[i + 1]; - i++; - } -} - -static bool ExporterProcessFileMode(ZFileMode fileMode) -{ - // Do whatever work is associated with these custom file modes... - // Return true to indicate one of our own file modes is being processed - if (fileMode == (ZFileMode)ExporterFileMode::BuildOTR) - return true; - - return false; -} - -static void ExporterFileBegin(ZFile* file) -{ - fileStart = std::chrono::steady_clock::now(); - - MemoryStream* stream = new MemoryStream(); - fileWriter = new BinaryWriter(stream); -} - -static void ExporterFileEnd(ZFile* file) -{ - // delete fileWriter; -} - -static void ExporterResourceEnd(ZResource* res, BinaryWriter& writer) -{ - auto streamShared = writer.GetStream(); - MemoryStream* strem = (MemoryStream*)streamShared.get(); - - auto start = std::chrono::steady_clock::now(); - - if (res->GetName() != "") - { - std::string oName = res->parent->GetOutName(); - std::string rName = res->GetName(); - std::string prefix = OTRExporter_DisplayList::GetPrefix(res); - - //auto xmlFilePath = res->parent->GetXmlFilePath(); - //prefix = StringHelper::Split(StringHelper::Split(xmlFilePath.string(), "xml\\")[1], ".xml")[0]; - - if (StringHelper::Contains(oName, "_scene")) - { - auto split = StringHelper::Split(oName, "_"); - oName = ""; - for (size_t i = 0; i < split.size() - 1; i++) - oName += split[i] + "_"; - - oName += "scene"; - } - else if (StringHelper::Contains(oName, "_room")) - { - oName = StringHelper::Split(oName, "_room")[0] + "_scene"; - } - - std::string fName = ""; - - if (prefix != "") - fName = StringHelper::Sprintf("%s/%s/%s", prefix.c_str(), oName.c_str(), rName.c_str()); - else - fName = StringHelper::Sprintf("%s/%s", oName.c_str(), rName.c_str()); - - if (Globals::Instance->fileMode == ZFileMode::ExtractDirectory) - { - std::unique_lock Lock(fileMutex); - files[fName] = strem->ToVector(); - } - else - DiskFile::WriteAllBytes("Extract/" + fName, strem->ToVector()); - } - - auto end = std::chrono::steady_clock::now(); - size_t diff = std::chrono::duration_cast(end - start).count(); - - //if (diff > 10) - //printf("Exported Resource End %s in %zums\n", res->GetName().c_str(), diff); -} - -static void ExporterProcessCompilable(tinyxml2::XMLElement* reader) -{ - std::string nodeName = reader->Name(); -} - -static void ExporterXMLBegin() -{ -} - -static void ExporterXMLEnd() -{ -} - -void AddFile(std::string fName, std::vector data) -{ - if (Globals::Instance->fileMode != ZFileMode::ExtractDirectory) - DiskFile::WriteAllBytes("Extract/" + fName, data); - else - { - std::unique_lock Lock(fileMutex); - files[fName] = data; - } -} - -void ImportExporters() -{ - // In this example we set up a new exporter called "EXAMPLE". - // By running ZAPD with the argument -se EXAMPLE, we tell it that we want to use this exporter for our resources. - ExporterSet* exporterSet = new ExporterSet(); - exporterSet->processFileModeFunc = ExporterProcessFileMode; - exporterSet->parseFileModeFunc = ExporterParseFileMode; - exporterSet->processCompilableFunc = ExporterProcessCompilable; - exporterSet->parseArgsFunc = ExporterParseArgs; - exporterSet->beginFileFunc = ExporterFileBegin; - exporterSet->endFileFunc = ExporterFileEnd; - exporterSet->beginXMLFunc = ExporterXMLBegin; - exporterSet->endXMLFunc = ExporterXMLEnd; - exporterSet->resSaveFunc = ExporterResourceEnd; - exporterSet->endProgramFunc = ExporterProgramEnd; - - exporterSet->exporters[ZResourceType::Background] = new OTRExporter_Background(); - exporterSet->exporters[ZResourceType::Texture] = new OTRExporter_Texture(); - exporterSet->exporters[ZResourceType::Room] = new OTRExporter_Room(); - exporterSet->exporters[ZResourceType::AltHeader] = new OTRExporter_Room(); - exporterSet->exporters[ZResourceType::Scene] = new OTRExporter_Room(); - exporterSet->exporters[ZResourceType::CollisionHeader] = new OTRExporter_Collision(); - exporterSet->exporters[ZResourceType::DisplayList] = new OTRExporter_DisplayList(); - exporterSet->exporters[ZResourceType::PlayerAnimationData] = new OTRExporter_PlayerAnimationExporter(); - exporterSet->exporters[ZResourceType::Skeleton] = new OTRExporter_Skeleton(); - exporterSet->exporters[ZResourceType::Limb] = new OTRExporter_SkeletonLimb(); - exporterSet->exporters[ZResourceType::Animation] = new OTRExporter_Animation(); - exporterSet->exporters[ZResourceType::Cutscene] = new OTRExporter_Cutscene(); - exporterSet->exporters[ZResourceType::Vertex] = new OTRExporter_Vtx(); - exporterSet->exporters[ZResourceType::Array] = new OTRExporter_Array(); - exporterSet->exporters[ZResourceType::Path] = new OTRExporter_Path(); - exporterSet->exporters[ZResourceType::Text] = new OTRExporter_Text(); - exporterSet->exporters[ZResourceType::Blob] = new OTRExporter_Blob(); - exporterSet->exporters[ZResourceType::Mtx] = new OTRExporter_MtxExporter(); - exporterSet->exporters[ZResourceType::Audio] = new OTRExporter_Audio(); - - Globals::AddExporter("OTR", exporterSet); - - InitVersionInfo(); -} diff --git a/OTRExporter/OTRExporter/Main.h b/OTRExporter/OTRExporter/Main.h deleted file mode 100644 index 3aa68c7e1..000000000 --- a/OTRExporter/OTRExporter/Main.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -#include - -extern std::shared_ptr otrArchive; -extern std::map> files; - -void AddFile(std::string fName, std::vector data); \ No newline at end of file diff --git a/OTRExporter/OTRExporter/MtxExporter.cpp b/OTRExporter/OTRExporter/MtxExporter.cpp deleted file mode 100644 index 129e43aeb..000000000 --- a/OTRExporter/OTRExporter/MtxExporter.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "MtxExporter.h" - -void OTRExporter_MtxExporter::Save(ZResource* res, const fs::path& outPath, BinaryWriter* writer) -{ - ZMtx* mtx = (ZMtx*)res; - - WriteHeader(res, outPath, writer, LUS::ResourceType::Matrix); - - for (size_t i = 0; i < 4; i++) - for (size_t j = 0; j < 4; j++) - //TODO possibly utilize the array class better - writer->Write(mtx->mtx[i][j]); -} \ No newline at end of file diff --git a/OTRExporter/OTRExporter/MtxExporter.h b/OTRExporter/OTRExporter/MtxExporter.h deleted file mode 100644 index 895f2a40e..000000000 --- a/OTRExporter/OTRExporter/MtxExporter.h +++ /dev/null @@ -1,10 +0,0 @@ -#include "ZResource.h" -#include "ZMtx.h" -#include "Exporter.h" -#include - -class OTRExporter_MtxExporter : public OTRExporter -{ -public: - virtual void Save(ZResource* res, const fs::path& outPath, BinaryWriter* writer) override; -}; diff --git a/OTRExporter/OTRExporter/PathExporter.cpp b/OTRExporter/OTRExporter/PathExporter.cpp deleted file mode 100644 index cc507c7aa..000000000 --- a/OTRExporter/OTRExporter/PathExporter.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include "PathExporter.h" -#include "../ZAPD/ZFile.h" - -void OTRExporter_Path::Save(ZResource* res, const fs::path& outPath, BinaryWriter* writer) -{ - ZPath* path = (ZPath*)res; - - WriteHeader(res, outPath, writer, LUS::ResourceType::SOH_Path); - - writer->Write((uint32_t)path->pathways.size()); - - for (size_t k = 0; k < path->pathways.size(); k++) - { - writer->Write((uint32_t)path->pathways[k].points.size()); - - for (size_t i = 0; i < path->pathways[k].points.size(); i++) - { - writer->Write(path->pathways[k].points[i].scalars[0].scalarData.s16); - writer->Write(path->pathways[k].points[i].scalars[1].scalarData.s16); - writer->Write(path->pathways[k].points[i].scalars[2].scalarData.s16); - } - } -} \ No newline at end of file diff --git a/OTRExporter/OTRExporter/PathExporter.h b/OTRExporter/OTRExporter/PathExporter.h deleted file mode 100644 index 9614b84df..000000000 --- a/OTRExporter/OTRExporter/PathExporter.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once - -#include "ZResource.h" -#include "ZPath.h" -#include "Exporter.h" -#include - -class OTRExporter_Path : public OTRExporter -{ -public: - virtual void Save(ZResource* res, const fs::path& outPath, BinaryWriter* writer) override; -}; \ No newline at end of file diff --git a/OTRExporter/OTRExporter/PlayerAnimationExporter.cpp b/OTRExporter/OTRExporter/PlayerAnimationExporter.cpp deleted file mode 100644 index b735c4e42..000000000 --- a/OTRExporter/OTRExporter/PlayerAnimationExporter.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "PlayerAnimationExporter.h" -#include - -void OTRExporter_PlayerAnimationExporter::Save(ZResource* res, const fs::path& outPath, BinaryWriter* writer) -{ - ZPlayerAnimationData* anim = (ZPlayerAnimationData*)res; - - WriteHeader(res, outPath, writer, LUS::ResourceType::SOH_PlayerAnimation); - - auto start = std::chrono::steady_clock::now(); - - writer->Write((uint32_t)anim->limbRotData.size()); - - for (size_t i = 0; i < anim->limbRotData.size(); i++) - writer->Write(anim->limbRotData[i]); - - auto end = std::chrono::steady_clock::now(); - size_t diff = std::chrono::duration_cast(end - start).count(); - - //printf("Exported Player Anim %s in %zums\n", anim->GetName().c_str(), diff); -} diff --git a/OTRExporter/OTRExporter/PlayerAnimationExporter.h b/OTRExporter/OTRExporter/PlayerAnimationExporter.h deleted file mode 100644 index 49e5468a2..000000000 --- a/OTRExporter/OTRExporter/PlayerAnimationExporter.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once - -#include "ZResource.h" -#include "ZTexture.h" -#include "ZPlayerAnimationData.h" -#include "Exporter.h" -#include - -class OTRExporter_PlayerAnimationExporter : public OTRExporter -{ -public: - virtual void Save(ZResource* res, const fs::path& outPath, BinaryWriter* writer) override; -}; \ No newline at end of file diff --git a/OTRExporter/OTRExporter/RoomExporter.cpp b/OTRExporter/OTRExporter/RoomExporter.cpp deleted file mode 100644 index 3959d7639..000000000 --- a/OTRExporter/OTRExporter/RoomExporter.cpp +++ /dev/null @@ -1,521 +0,0 @@ -#include "RoomExporter.h" -#include "Utils/BinaryWriter.h" -#include "Utils/MemoryStream.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "CollisionExporter.h" -#include "DisplayListExporter.h" -#include -#include -#include -#include -#include "TextureExporter.h" -#include "Main.h" -#include -#include "CutsceneExporter.h" -#include -#include "PathExporter.h" -#undef FindResource - -void OTRExporter_Room::Save(ZResource* res, const fs::path& outPath, BinaryWriter* writer) -{ - ZRoom* room = (ZRoom*)res; - - WriteHeader(res, outPath, writer, LUS::ResourceType::SOH_Room); - - writer->Write((uint32_t)room->commands.size()); - - for (size_t i = 0; i < room->commands.size(); i++) - { - ZRoomCommand* cmd = room->commands[i]; - - writer->Write((uint32_t)cmd->cmdID); - - switch (cmd->cmdID) - { - case RoomCommand::SetTransitionActorList: - { - SetTransitionActorList* cmdTrans = (SetTransitionActorList*)cmd; - - writer->Write((uint32_t)cmdTrans->transitionActors.size()); - - for (const TransitionActorEntry& entry : cmdTrans->transitionActors) - { - writer->Write(entry.frontObjectRoom); - writer->Write(entry.frontTransitionReaction); - writer->Write(entry.backObjectRoom); - writer->Write(entry.backTransitionReaction); - writer->Write(entry.actorNum); - writer->Write(entry.posX); - writer->Write(entry.posY); - writer->Write(entry.posZ); - writer->Write(entry.rotY); - writer->Write(entry.initVar); - } - } - break; - case RoomCommand::SetActorList: - { - SetActorList* cmdSetActorList = (SetActorList*)cmd; - - // There are instance of the amount of actors in the file differing from the size listed in the command. - // This can cause issues if we export actors with garbage data, so let's trust the command size - writer->Write((uint32_t)cmdSetActorList->numActors); - - for (const auto& entry : cmdSetActorList->actorList->actors) - { - writer->Write(entry.actorNum); - writer->Write(entry.posX); - writer->Write(entry.posY); - writer->Write(entry.posZ); - writer->Write(entry.rotX); - writer->Write(entry.rotY); - writer->Write(entry.rotZ); - writer->Write(entry.params); - } - } - break; - case RoomCommand::SetWind: - { - SetWind* cmdSetWind = (SetWind*)cmd; - - writer->Write(cmdSetWind->windWest); // 0x04 - writer->Write(cmdSetWind->windVertical); // 0x05 - writer->Write(cmdSetWind->windSouth); // 0x06 - writer->Write(cmdSetWind->clothFlappingStrength); // 0x07 - } - break; - case RoomCommand::SetTimeSettings: - { - SetTimeSettings* cmdTime = (SetTimeSettings*)cmd; - - writer->Write(cmdTime->hour); // 0x04 - writer->Write(cmdTime->min); // 0x05 - writer->Write(cmdTime->unk); // 0x06 - } - break; - case RoomCommand::SetSkyboxModifier: - { - SetSkyboxModifier* cmdSkybox = (SetSkyboxModifier*)cmd; - - writer->Write(cmdSkybox->disableSky); // 0x04 - writer->Write(cmdSkybox->disableSunMoon); // 0x05 - } - break; - case RoomCommand::SetEchoSettings: - { - SetEchoSettings* cmdEcho = (SetEchoSettings*)cmd; - - writer->Write((uint8_t)cmdEcho->echo); // 0x07 - } - break; - case RoomCommand::SetSoundSettings: - { - SetSoundSettings* cmdSound = (SetSoundSettings*)cmd; - - writer->Write((uint8_t)cmdSound->reverb); // 0x01 - - writer->Write(cmdSound->nightTimeSFX); // 0x06 - writer->Write(cmdSound->musicSequence); // 0x07 - } - break; - case RoomCommand::SetSkyboxSettings: - { - SetSkyboxSettings* cmdSkybox = (SetSkyboxSettings*)cmd; - - writer->Write((uint8_t)cmdSkybox->unk1); // 0x01 - writer->Write((uint8_t)cmdSkybox->skyboxNumber); // 0x04 - writer->Write((uint8_t)cmdSkybox->cloudsType); // 0x05 - writer->Write((uint8_t)cmdSkybox->isIndoors); // 0x06 - } - break; - case RoomCommand::SetRoomBehavior: - { - SetRoomBehavior* cmdRoom = (SetRoomBehavior*)cmd; - - writer->Write((uint8_t)cmdRoom->gameplayFlags); // 0x01 - writer->Write(cmdRoom->gameplayFlags2); // 0x04 - } - break; - case RoomCommand::SetCsCamera: - { - SetCsCamera* cmdCsCam = (SetCsCamera*)cmd; - - writer->Write((uint32_t)cmdCsCam->cameras.size()); - - for (size_t i = 0; i < cmdCsCam->cameras.size(); i++) - { - writer->Write(cmdCsCam->cameras[i].baseOffset); - writer->Write(cmdCsCam->cameras[i].type); - writer->Write(cmdCsCam->cameras[i].numPoints); - } - - writer->Write((uint32_t)cmdCsCam->points.size()); - - for (size_t i = 0; i < cmdCsCam->points.size(); i++) - { - writer->Write(cmdCsCam->points[i].scalars[0].scalarData.s16); - writer->Write(cmdCsCam->points[i].scalars[1].scalarData.s16); - writer->Write(cmdCsCam->points[i].scalars[2].scalarData.s16); - } - } - break; - case RoomCommand::SetMesh: - { - SetMesh* cmdMesh = (SetMesh*)cmd; - - writer->Write((uint8_t)cmdMesh->data); // 0x01 - writer->Write(cmdMesh->meshHeaderType); - - if (cmdMesh->meshHeaderType == 0 || cmdMesh->meshHeaderType == 2) - { - PolygonType2* poly = (PolygonType2*)cmdMesh->polyType.get(); - - writer->Write(poly->num); - - for (int i = 0; i < poly->num; i++) - WritePolyDList(writer, room, &poly->polyDLists[i]); - } - else if (cmdMesh->meshHeaderType == 1) - { - PolygonType1* poly = (PolygonType1*)cmdMesh->polyType.get(); - - writer->Write(poly->format); - - auto test = (PolygonDlist*)&poly->polyDLists[0]; - Declaration* dListDeclOpa = poly->parent->GetDeclaration(GETSEGOFFSET(test->opa)); - Declaration* dListDeclXlu = poly->parent->GetDeclaration(GETSEGOFFSET(test->xlu)); - - if (test->opa != 0) - writer->Write(StringHelper::Sprintf("%s/%s", OTRExporter_DisplayList::GetParentFolderName(res).c_str(), dListDeclOpa->varName.c_str())); - else - writer->Write(""); - - if (test->xlu != 0) - writer->Write(StringHelper::Sprintf("%s/%s", OTRExporter_DisplayList::GetParentFolderName(res).c_str(), dListDeclXlu->varName.c_str())); - else - writer->Write(""); - - if (poly->format == 2) - { - writer->Write((uint32_t)poly->count); - - for (int i = 0; i < poly->count; i++) - { - writer->Write(poly->multiList[i].unk_00); - writer->Write(poly->multiList[i].id); - - Declaration* bgDecl = poly->parent->GetDeclarationRanged(GETSEGOFFSET(poly->multiList[i].source)); - - writer->Write(OTRExporter_DisplayList::GetPathToRes(poly->multiList[i].sourceBackground, bgDecl->varName)); - - writer->Write(poly->multiList[i].unk_0C); - writer->Write(poly->multiList[i].tlut); - writer->Write(poly->multiList[i].width); - writer->Write(poly->multiList[i].height); - writer->Write(poly->multiList[i].fmt); - writer->Write(poly->multiList[i].siz); - writer->Write(poly->multiList[i].mode0); - writer->Write(poly->multiList[i].tlutCount); - } - } - else - { - writer->Write((uint32_t)1); - - writer->Write(poly->single.unk_00); - writer->Write(poly->single.id); - - Declaration* bgDecl = poly->parent->GetDeclarationRanged(GETSEGOFFSET(poly->single.source)); - - writer->Write(OTRExporter_DisplayList::GetPathToRes(poly->single.sourceBackground, bgDecl->varName)); - - writer->Write(poly->single.unk_0C); - writer->Write(poly->single.tlut); - writer->Write(poly->single.width); - writer->Write(poly->single.height); - writer->Write(poly->single.fmt); - writer->Write(poly->single.siz); - writer->Write(poly->single.mode0); - writer->Write(poly->single.tlutCount); - } - - if (poly->dlist != 0) - WritePolyDList(writer, room, &poly->polyDLists[0]); - } - } - break; - case RoomCommand::SetCameraSettings: - { - SetCameraSettings* cmdCam = (SetCameraSettings*)cmd; - - writer->Write((uint8_t)cmdCam->cameraMovement); // 0x01 - writer->Write(cmdCam->mapHighlight); // 0x04 - } - break; - case RoomCommand::SetLightList: - { - SetLightList* cmdLight = (SetLightList*)cmd; - - writer->Write((uint32_t)cmdLight->lights.size()); - - for (size_t i = 0; i < cmdLight->lights.size(); i++) - { - writer->Write(cmdLight->lights[i].type); - writer->Write(cmdLight->lights[i].x); - writer->Write(cmdLight->lights[i].y); - writer->Write(cmdLight->lights[i].z); - writer->Write(cmdLight->lights[i].r); - writer->Write(cmdLight->lights[i].g); - writer->Write(cmdLight->lights[i].b); - writer->Write(cmdLight->lights[i].drawGlow); - writer->Write(cmdLight->lights[i].radius); - } - } - break; - case RoomCommand::SetLightingSettings: - { - SetLightingSettings* cmdLight = (SetLightingSettings*)cmd; - - writer->Write((uint32_t)cmdLight->settings.size()); // 0x01 - - for (const LightingSettings& setting : cmdLight->settings) - { - writer->Write(setting.ambientClrR); - writer->Write(setting.ambientClrG); - writer->Write(setting.ambientClrB); - - writer->Write(setting.diffuseClrA_R); - writer->Write(setting.diffuseClrA_G); - writer->Write(setting.diffuseClrA_B); - - writer->Write(setting.diffuseDirA_X); - writer->Write(setting.diffuseDirA_Y); - writer->Write(setting.diffuseDirA_Z); - - writer->Write(setting.diffuseClrB_R); - writer->Write(setting.diffuseClrB_G); - writer->Write(setting.diffuseClrB_B); - - writer->Write(setting.diffuseDirB_X); - writer->Write(setting.diffuseDirB_Y); - writer->Write(setting.diffuseDirB_Z); - - writer->Write(setting.fogClrR); - writer->Write(setting.fogClrG); - writer->Write(setting.fogClrB); - - writer->Write(setting.unk); - writer->Write(setting.drawDistance); - } - } - break; - case RoomCommand::SetRoomList: - { - SetRoomList* cmdRoom = (SetRoomList*)cmd; - - writer->Write((uint32_t)cmdRoom->romfile->numRooms); // 0x01 - - for (size_t i = 0;i < cmdRoom->romfile->numRooms; i++) - { - //std::string roomName = StringHelper::Sprintf("%s/%s_room_%i", (StringHelper::Split(room->GetName(), "_")[0] + "_scene").c_str(), StringHelper::Split(room->GetName(), "_scene")[0].c_str(), i); - std::string roomName = OTRExporter_DisplayList::GetPathToRes(room, StringHelper::Sprintf("%s_room_%i", StringHelper::Split(room->GetName(), "_scene")[0].c_str(), i)); - writer->Write(roomName); - writer->Write(cmdRoom->romfile->rooms[i].virtualAddressStart); - writer->Write(cmdRoom->romfile->rooms[i].virtualAddressEnd); - } - } - break; - case RoomCommand::SetCollisionHeader: - { - SetCollisionHeader* cmdCollHeader = (SetCollisionHeader*)cmd; - - Declaration* colHeaderDecl = room->parent->GetDeclaration(cmdCollHeader->segmentOffset); - std::string path = OTRExporter_DisplayList::GetPathToRes(room, colHeaderDecl->varName); - writer->Write(path); - } - break; - case RoomCommand::SetEntranceList: - { - SetEntranceList* cmdEntrance = (SetEntranceList*)cmd; - - writer->Write((uint32_t)cmdEntrance->entrances.size()); - - for (EntranceEntry entry : cmdEntrance->entrances) - { - writer->Write((uint8_t)entry.startPositionIndex); - writer->Write((uint8_t)entry.roomToLoad); - } - } - break; - case RoomCommand::SetSpecialObjects: - { - SetSpecialObjects* cmdSpecObj = (SetSpecialObjects*)cmd; - - writer->Write((uint8_t)cmdSpecObj->elfMessage); // 0x01 - writer->Write((uint16_t)cmdSpecObj->globalObject); // 0x06 - } - break; - case RoomCommand::SetStartPositionList: - { - SetStartPositionList* cmdStartPos = (SetStartPositionList*)cmd; - - uint32_t baseStreamEnd = writer->GetStream().get()->GetLength(); - - writer->Write((uint32_t)cmdStartPos->actors.size()); // 0x01 - - for (const ActorSpawnEntry& entry : cmdStartPos->actors) - { - writer->Write(entry.actorNum); - writer->Write(entry.posX); - writer->Write(entry.posY); - writer->Write(entry.posZ); - writer->Write(entry.rotX); - writer->Write(entry.rotY); - writer->Write(entry.rotZ); - writer->Write(entry.params); - } - } - break; - case RoomCommand::SetAlternateHeaders: - { - SetAlternateHeaders* cmdHeaders = (SetAlternateHeaders*)cmd; - - writer->Write((uint32_t)cmdHeaders->headers.size()); - - for (size_t i = 0; i < cmdHeaders->headers.size(); i++) - { - uint32_t seg = cmdHeaders->headers[i] & 0xFFFFFFFF; - std::string headerName = ""; - bool foundDecl = Globals::Instance->GetSegmentedPtrName(seg, room->parent, "", headerName, res->parent->workerID); - if (headerName == "NULL") - writer->Write(""); - else - { - std::string name = OTRExporter_DisplayList::GetPathToRes(room, headerName); - writer->Write(name); - } - } - } - break; - case RoomCommand::SetExitList: - { - SetExitList* cmdExit = (SetExitList*)cmd; - - writer->Write((uint32_t)cmdExit->exits.size()); - - for (size_t i = 0; i < cmdExit->exits.size(); i++) - writer->Write(cmdExit->exits[i]); - } - break; - case RoomCommand::SetObjectList: - { - SetObjectList* cmdSetObjectList = (SetObjectList*)cmd; - - writer->Write((uint32_t)cmdSetObjectList->objects.size()); - - for (size_t i = 0; i < cmdSetObjectList->objects.size(); i++) - writer->Write(cmdSetObjectList->objects[i]); - } - break; - case RoomCommand::SetCutscenes: - { - SetCutscenes* cmdSetCutscenes = (SetCutscenes*)cmd; - - std::string listName; - Globals::Instance->GetSegmentedPtrName(cmdSetCutscenes->cmdArg2, room->parent, "CutsceneData", listName, res->parent->workerID); - std::string fName = OTRExporter_DisplayList::GetPathToRes(room, listName); - //std::string fName = StringHelper::Sprintf("%s\\%s", OTRExporter_DisplayList::GetParentFolderName(room).c_str(), listName.c_str()); - writer->Write(fName); - - MemoryStream* csStream = new MemoryStream(); - BinaryWriter csWriter = BinaryWriter(csStream); - OTRExporter_Cutscene cs; - cs.Save(cmdSetCutscenes->cutscenes[0], "", &csWriter); - - AddFile(fName, csStream->ToVector()); - } - break; - case RoomCommand::SetPathways: - { - SetPathways* cmdSetPathways = (SetPathways*)cmd; - - writer->Write((uint32_t)cmdSetPathways->pathwayList.pathways.size()); - - for (size_t i = 0; i < cmdSetPathways->pathwayList.pathways.size(); i++) - { - Declaration* decl = room->parent->GetDeclaration(GETSEGOFFSET(cmdSetPathways->pathwayList.pathways[i].listSegmentAddress)); - //std::string path = StringHelper::Sprintf("%s\\%s", OTRExporter_DisplayList::GetParentFolderName(res).c_str(), decl->varName.c_str()); - std::string path = OTRExporter_DisplayList::GetPathToRes(room, decl->varName); - writer->Write(path); - - MemoryStream* pathStream = new MemoryStream(); - BinaryWriter pathWriter = BinaryWriter(pathStream); - OTRExporter_Path pathExp; - pathExp.Save(&cmdSetPathways->pathwayList, outPath, &pathWriter); - - AddFile(path, pathStream->ToVector()); - } - } - break; - case RoomCommand::EndMarker: - break; - default: - printf("UNIMPLEMENTED COMMAND: 0x%02X\n", (int)cmd->cmdID); - - break; - } - } -} - -void OTRExporter_Room::WritePolyDList(BinaryWriter* writer, ZRoom* room, PolygonDlist* dlist) -{ - writer->Write(dlist->polyType); - - switch (dlist->polyType) - { - case 2: - writer->Write(dlist->x); - writer->Write(dlist->y); - writer->Write(dlist->z); - writer->Write(dlist->unk_06); - [[fallthrough]]; - default: - //writer->Write(StringHelper::Sprintf("%s/%s", OTRExporter_DisplayList::GetParentFolderName(res).c_str(), dListDeclOpa->varName.c_str())); - - if (dlist->opaDList != nullptr) - { - auto opaDecl = room->parent->GetDeclaration(GETSEGOFFSET(dlist->opaDList->GetRawDataIndex())); - writer->Write(StringHelper::Sprintf("%s/%s", OTRExporter_DisplayList::GetParentFolderName(room).c_str(), opaDecl->varName.c_str())); - } - else - writer->Write(""); - - if (dlist->xluDList != nullptr) - { - auto xluDecl = room->parent->GetDeclaration(GETSEGOFFSET(dlist->xluDList->GetRawDataIndex())); - writer->Write(StringHelper::Sprintf("%s/%s", OTRExporter_DisplayList::GetParentFolderName(room).c_str(), xluDecl->varName.c_str())); - } - else - writer->Write(""); - break; - } -} diff --git a/OTRExporter/OTRExporter/RoomExporter.h b/OTRExporter/OTRExporter/RoomExporter.h deleted file mode 100644 index f748658a5..000000000 --- a/OTRExporter/OTRExporter/RoomExporter.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include "ZResource.h" -#include "Exporter.h" -#include "ZRoom/ZRoom.h" - -class PolygonDlist; - -class OTRExporter_Room : public OTRExporter -{ -public: - void WritePolyDList(BinaryWriter* writer, ZRoom* room, PolygonDlist* dlist); - virtual void Save(ZResource* res, const fs::path& outPath, BinaryWriter* writer) override; -}; \ No newline at end of file diff --git a/OTRExporter/OTRExporter/SkeletonExporter.cpp b/OTRExporter/OTRExporter/SkeletonExporter.cpp deleted file mode 100644 index fc4bba6fa..000000000 --- a/OTRExporter/OTRExporter/SkeletonExporter.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include "SkeletonExporter.h" -#include -#include -#include "DisplayListExporter.h" - -void OTRExporter_Skeleton::Save(ZResource* res, const fs::path& outPath, BinaryWriter* writer) -{ - ZSkeleton* skel = (ZSkeleton*)res; - - WriteHeader(res, outPath, writer, LUS::ResourceType::SOH_Skeleton); - - writer->Write((uint8_t)skel->type); - writer->Write((uint8_t)skel->limbType); - - writer->Write((uint32_t)skel->limbCount); - writer->Write((uint32_t)skel->dListCount); - - writer->Write((uint8_t)skel->limbsTable->limbType); - writer->Write((uint32_t)skel->limbsTable->count); - - for (size_t i = 0; i < skel->limbsTable->count; i++) - { - Declaration* skelDecl = skel->parent->GetDeclarationRanged(GETSEGOFFSET(skel->limbsTable->limbsAddresses[i])); - - std::string name; - bool foundDecl = Globals::Instance->GetSegmentedPtrName(skel->limbsTable->limbsAddresses[i], skel->parent, "", name, res->parent->workerID); - if (foundDecl) - { - if (name.at(0) == '&') - name.erase(0, 1); - - writer->Write(OTRExporter_DisplayList::GetPathToRes(res, name)); - } - else - { - writer->Write(""); - } - } -} diff --git a/OTRExporter/OTRExporter/SkeletonExporter.h b/OTRExporter/OTRExporter/SkeletonExporter.h deleted file mode 100644 index 36ffcf269..000000000 --- a/OTRExporter/OTRExporter/SkeletonExporter.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include "ZResource.h" -#include "ZTexture.h" -#include "ZDisplayList.h" -#include "ZSkeleton.h" -#include "Exporter.h" -#include - -class OTRExporter_Skeleton : public OTRExporter -{ -public: - virtual void Save(ZResource* res, const fs::path& outPath, BinaryWriter* writer) override; -}; \ No newline at end of file diff --git a/OTRExporter/OTRExporter/SkeletonLimbExporter.cpp b/OTRExporter/OTRExporter/SkeletonLimbExporter.cpp deleted file mode 100644 index 1ee17c444..000000000 --- a/OTRExporter/OTRExporter/SkeletonLimbExporter.cpp +++ /dev/null @@ -1,176 +0,0 @@ -#include "SkeletonLimbExporter.h" -#include "DisplayListExporter.h" -#include -#include - -void OTRExporter_SkeletonLimb::Save(ZResource* res, const fs::path& outPath, BinaryWriter* writer) -{ - ZLimb* limb = (ZLimb*)res; - - WriteHeader(res, outPath, writer, LUS::ResourceType::SOH_SkeletonLimb); - - writer->Write((uint8_t)limb->type); - writer->Write((uint8_t)limb->skinSegmentType); - - if (limb->skinSegmentType == ZLimbSkinType::SkinType_DList && limb->type == ZLimbType::Skin) - { - auto childDecl = limb->parent->GetDeclaration(GETSEGOFFSET(limb->skinSegment)); - - if (childDecl != nullptr) - writer->Write(OTRExporter_DisplayList::GetPathToRes(limb, childDecl->varName)); - else - writer->Write(""); - } - else - { - writer->Write(""); - } - - writer->Write((uint16_t)limb->segmentStruct.unk_0); - writer->Write((uint32_t)limb->segmentStruct.unk_4_arr.size()); - - for (auto item : limb->segmentStruct.unk_4_arr) - { - writer->Write(item.unk_4); - - writer->Write((uint32_t)item.unk_8_arr.size()); - - for (auto item2 : item.unk_8_arr) - { - writer->Write(item2.unk_0); - writer->Write(item2.unk_2); - writer->Write(item2.unk_4); - writer->Write(item2.unk_6); - writer->Write(item2.unk_7); - writer->Write(item2.unk_8); - writer->Write(item2.unk_9); - } - - writer->Write((uint32_t)item.unk_C_arr.size()); - - for (auto item2 : item.unk_C_arr) - { - writer->Write(item2.unk_0); - writer->Write(item2.x); - writer->Write(item2.y); - writer->Write(item2.z); - writer->Write(item2.unk_8); - } - } - - if (limb->segmentStruct.unk_8 != 0) - { - auto skinGfxDecl = limb->parent->GetDeclaration(GETSEGOFFSET(limb->segmentStruct.unk_8)); - - if (skinGfxDecl != nullptr) - { - writer->Write(OTRExporter_DisplayList::GetPathToRes(limb, skinGfxDecl->varName)); - } - else - { - writer->Write(""); - } - } - else - { - writer->Write(""); - } - - writer->Write(limb->legTransX); - writer->Write(limb->legTransY); - writer->Write(limb->legTransZ); - writer->Write(limb->rotX); - writer->Write(limb->rotY); - writer->Write(limb->rotZ); - - if (limb->childPtr != 0) - { - std::string name; - bool foundDecl = Globals::Instance->GetSegmentedPtrName(limb->childPtr, limb->parent, "", name, res->parent->workerID); - if (foundDecl) - { - if (name.at(0) == '&') - name.erase(0, 1); - - writer->Write(OTRExporter_DisplayList::GetPathToRes(limb, name)); - } - else - { - writer->Write(""); - } - } - else - { - writer->Write(""); - } - - if (limb->siblingPtr != 0) - { - std::string name; - bool foundDecl = Globals::Instance->GetSegmentedPtrName(limb->siblingPtr, limb->parent, "", name, res->parent->workerID); - if (foundDecl) - { - if (name.at(0) == '&') - name.erase(0, 1); - - writer->Write(OTRExporter_DisplayList::GetPathToRes(limb, name)); - } - else - { - writer->Write(""); - } - } - else - { - writer->Write(""); - } - - if (limb->dListPtr != 0) - { - std::string name; - bool foundDecl = Globals::Instance->GetSegmentedPtrName(limb->dListPtr, limb->parent, "", name, res->parent->workerID); - if (foundDecl) - { - if (name.at(0) == '&') - name.erase(0, 1); - - writer->Write(OTRExporter_DisplayList::GetPathToRes(limb, name)); - } - else - { - writer->Write(""); - } - } - else - { - writer->Write(""); - } - - if (limb->dList2Ptr != 0) - { - std::string name; - bool foundDecl = Globals::Instance->GetSegmentedPtrName(limb->dList2Ptr, limb->parent, "", name, res->parent->workerID); - if (foundDecl) - { - if (name.at(0) == '&') - name.erase(0, 1); - - writer->Write(OTRExporter_DisplayList::GetPathToRes(limb, name)); - } - else - { - writer->Write(""); - } - } - else - { - writer->Write(""); - } - - writer->Write(limb->transX); - writer->Write(limb->transY); - writer->Write(limb->transZ); - - writer->Write(limb->childIndex); - writer->Write(limb->siblingIndex); -} \ No newline at end of file diff --git a/OTRExporter/OTRExporter/SkeletonLimbExporter.h b/OTRExporter/OTRExporter/SkeletonLimbExporter.h deleted file mode 100644 index 000827443..000000000 --- a/OTRExporter/OTRExporter/SkeletonLimbExporter.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include "ZResource.h" -#include "ZTexture.h" -#include "ZDisplayList.h" -#include "ZSkeleton.h" -#include "ZLimb.h" -#include "Exporter.h" -#include - -class OTRExporter_SkeletonLimb : public OTRExporter -{ -public: - virtual void Save(ZResource* res, const fs::path& outPath, BinaryWriter* writer) override; -}; \ No newline at end of file diff --git a/OTRExporter/OTRExporter/TextExporter.cpp b/OTRExporter/OTRExporter/TextExporter.cpp deleted file mode 100644 index 2fcfe8251..000000000 --- a/OTRExporter/OTRExporter/TextExporter.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "TextExporter.h" -#include "../ZAPD/ZFile.h" - -void OTRExporter_Text::Save(ZResource* res, const fs::path& outPath, BinaryWriter* writer) -{ - ZText* txt = (ZText*)res; - - WriteHeader(txt, outPath, writer, LUS::ResourceType::SOH_Text); - - writer->Write((uint32_t)txt->messages.size()); - - for (size_t i = 0; i < txt->messages.size(); i++) - { - writer->Write(txt->messages[i].id); - writer->Write(txt->messages[i].textboxType); - writer->Write(txt->messages[i].textboxYPos); - writer->Write(txt->messages[i].msg); - } -} diff --git a/OTRExporter/OTRExporter/TextExporter.h b/OTRExporter/OTRExporter/TextExporter.h deleted file mode 100644 index 2eaf2ce71..000000000 --- a/OTRExporter/OTRExporter/TextExporter.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once - -#include "ZResource.h" -#include "ZText.h" -#include "Exporter.h" -#include - -class OTRExporter_Text : public OTRExporter -{ -public: - virtual void Save(ZResource* res, const fs::path& outPath, BinaryWriter* writer) override; -}; \ No newline at end of file diff --git a/OTRExporter/OTRExporter/TextureExporter.cpp b/OTRExporter/OTRExporter/TextureExporter.cpp deleted file mode 100644 index 77cc20955..000000000 --- a/OTRExporter/OTRExporter/TextureExporter.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include "TextureExporter.h" -#include "../ZAPD/ZFile.h" - -void OTRExporter_Texture::Save(ZResource* res, const fs::path& outPath, BinaryWriter* writer) -{ - ZTexture* tex = (ZTexture*)res; - - WriteHeader(tex, outPath, writer, LUS::ResourceType::Texture); - - auto start = std::chrono::steady_clock::now(); - - //printf("Exporting Texture %s\n", tex->GetName().c_str()); - - writer->Write((uint32_t)tex->GetTextureType()); - writer->Write((uint32_t)tex->GetWidth()); - writer->Write((uint32_t)tex->GetHeight()); - - writer->Write((uint32_t)tex->GetRawDataSize()); - - if (tex->parent != nullptr) { - auto data = tex->parent->GetRawData(); - writer->Write((char*)data.data() + tex->GetRawDataIndex(), tex->GetRawDataSize()); - } - - auto end = std::chrono::steady_clock::now(); - size_t diff = std::chrono::duration_cast(end - start).count(); - - //printf("Exported Texture %s in %zums\n", tex->GetName().c_str(), diff); - - //if (diff > 2) - //printf("Export took %lms\n", diff); -} \ No newline at end of file diff --git a/OTRExporter/OTRExporter/TextureExporter.h b/OTRExporter/OTRExporter/TextureExporter.h deleted file mode 100644 index cdf7491a8..000000000 --- a/OTRExporter/OTRExporter/TextureExporter.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once - -#include "ZResource.h" -#include "ZTexture.h" -#include "Exporter.h" -#include - -class OTRExporter_Texture : public OTRExporter -{ -public: - virtual void Save(ZResource* res, const fs::path& outPath, BinaryWriter* writer) override; -}; \ No newline at end of file diff --git a/OTRExporter/OTRExporter/VersionInfo.cpp b/OTRExporter/OTRExporter/VersionInfo.cpp deleted file mode 100644 index 50910bc31..000000000 --- a/OTRExporter/OTRExporter/VersionInfo.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "VersionInfo.h" -#include - -std::map resourceVersions; - -void InitVersionInfo() -{ - resourceVersions = std::map { - { LUS::ResourceType::SOH_Animation, 0 }, - { LUS::ResourceType::Texture, 0 }, - { LUS::ResourceType::SOH_PlayerAnimation, 0 }, - { LUS::ResourceType::DisplayList, 0 }, - { LUS::ResourceType::SOH_Room, 0 }, - { LUS::ResourceType::SOH_CollisionHeader, 0 }, - { LUS::ResourceType::SOH_Skeleton, 0 }, - { LUS::ResourceType::SOH_SkeletonLimb, 0 }, - { LUS::ResourceType::Matrix, 0 }, - { LUS::ResourceType::SOH_Path, 0 }, - { LUS::ResourceType::Vertex, 0 }, - { LUS::ResourceType::SOH_Cutscene, 0 }, - { LUS::ResourceType::Array, 0 }, - { LUS::ResourceType::SOH_Text, 0 }, - { LUS::ResourceType::Blob, 0 }, - }; -} diff --git a/OTRExporter/OTRExporter/VersionInfo.h b/OTRExporter/OTRExporter/VersionInfo.h deleted file mode 100644 index 03f8417f2..000000000 --- a/OTRExporter/OTRExporter/VersionInfo.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -#include -#include -#include "src/resource/Resource.h" - -extern std::map resourceVersions; \ No newline at end of file diff --git a/OTRExporter/OTRExporter/VtxExporter.cpp b/OTRExporter/OTRExporter/VtxExporter.cpp deleted file mode 100644 index 009545d77..000000000 --- a/OTRExporter/OTRExporter/VtxExporter.cpp +++ /dev/null @@ -1,44 +0,0 @@ -#include "VtxExporter.h" -#include -#include "VersionInfo.h" - - -void OTRExporter_Vtx::SaveArr(ZResource* res, const fs::path& outPath, const std::vector& vec, BinaryWriter* writer) -{ - WriteHeader(res, outPath, writer, LUS::ResourceType::Vertex); - - for (auto& res: vec) { - ZVtx* vtx = (ZVtx*)res; - writer->Write(vtx->x); - writer->Write(vtx->y); - writer->Write(vtx->z); - writer->Write(vtx->flag); - writer->Write(vtx->s); - writer->Write(vtx->t); - writer->Write(vtx->r); - writer->Write(vtx->g); - writer->Write(vtx->b); - writer->Write(vtx->a); - } - -} - -void OTRExporter_Vtx::Save(ZResource* res, const fs::path& outPath, BinaryWriter* writer) -{ - ZVtx* vtx = (ZVtx*)res; - - WriteHeader(res, outPath, writer, LUS::ResourceType::Vertex); - - writer->Write((uint32_t)1); //Yes I'm hard coding it to one, it *should* be fine. - - writer->Write(vtx->x); - writer->Write(vtx->y); - writer->Write(vtx->z); - writer->Write(vtx->flag); - writer->Write(vtx->s); - writer->Write(vtx->t); - writer->Write(vtx->r); - writer->Write(vtx->g); - writer->Write(vtx->b); - writer->Write(vtx->a); -} diff --git a/OTRExporter/OTRExporter/VtxExporter.h b/OTRExporter/OTRExporter/VtxExporter.h deleted file mode 100644 index 433aadd2c..000000000 --- a/OTRExporter/OTRExporter/VtxExporter.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once - -#include "ZResource.h" -#include "ZVtx.h" -#include "Exporter.h" -#include - -class OTRExporter_Vtx : public OTRExporter -{ -public: - void SaveArr(ZResource* res, const fs::path& outPath, const std::vector&, BinaryWriter* writer); - virtual void Save(ZResource* res, const fs::path& outPath, BinaryWriter* writer) override; -}; \ No newline at end of file diff --git a/OTRExporter/OTRExporter/command_macros_base.h b/OTRExporter/OTRExporter/command_macros_base.h deleted file mode 100644 index 3067d2ce1..000000000 --- a/OTRExporter/OTRExporter/command_macros_base.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef COMMAND_MACROS_BASE_H -#define COMMAND_MACROS_BASE_H - -/** - * Command Base macros intended for use in designing of more specific command macros - * Each macro packs bytes (B), halfwords (H) and words (W, for consistency) into a single word - */ - -#define _SHIFTL(v, s, w) \ - ((unsigned int) (((unsigned int)(v) & ((0x01 << (w)) - 1)) << (s))) -#define _SHIFTR(v, s, w) \ - ((unsigned int)(((unsigned int)(v) >> (s)) & ((0x01 << (w)) - 1))) - -//#define CMD_BBBB(a, b, c, d) (_SHIFTL(a, 24, 8) | _SHIFTL(b, 16, 8) | _SHIFTL(c, 8, 8) | _SHIFTL(d, 0, 8)) -#define CMD_BBBB(a, b, c, d) (_SHIFTL(d, 24, 8) | _SHIFTL(c, 16, 8) | _SHIFTL(b, 8, 8) | _SHIFTL(a, 0, 8)) - -//#define CMD_BBH(a, b, c) (_SHIFTL(a, 24, 8) | _SHIFTL(b, 16, 8) | _SHIFTL(c, 0, 16)) -#define CMD_BBH(a, b, c) (_SHIFTL(a, 0, 8) | _SHIFTL(b, 8, 8) | _SHIFTL(c, 16, 16)) - -//#define CMD_HBB(a, b, c) (_SHIFTL(a, 16, 16) | _SHIFTL(b, 8, 8) | _SHIFTL(c, 0, 8)) -#define CMD_HBB(a, b, c) (_SHIFTL(c, 24, 8) | _SHIFTL(b, 16, 8) | _SHIFTL(a, 0, 16)) - -//#define CMD_HH(a, b) (_SHIFTL(a, 16, 16) | _SHIFTL(b, 0, 16)) -#define CMD_HH(a, b) (_SHIFTL(b, 16, 16) | _SHIFTL(a, 0, 16)) - -#define CMD_W(a) (a) - -#if defined(__GNUC__) -#define CMD_F(a) {.f = (a)} -#else -#define CMD_F(a) {(a)} -#endif - -#define CMD_PTR(a) (u32)(a) - -#endif \ No newline at end of file diff --git a/OTRExporter/OTRExporter/z64cutscene.h b/OTRExporter/OTRExporter/z64cutscene.h deleted file mode 100644 index d5eb89482..000000000 --- a/OTRExporter/OTRExporter/z64cutscene.h +++ /dev/null @@ -1,290 +0,0 @@ -#ifndef Z64CUTSCENE_H -#define Z64CUTSCENE_H - -#if 0 -#include - -typedef struct { - /* 0x00 */ u16 entrance; // entrance index upon which the cutscene should trigger - /* 0x02 */ u8 ageRestriction; // 0 for adult only, 1 for child only, 2 for both ages - /* 0x03 */ u8 flag; // eventChkInf flag bound to the entrance cutscene - /* 0x04 */ void* segAddr; // segment offset location of the cutscene -} EntranceCutscene; // size = 0x8 - -typedef struct { - /* 0x00 */ s8 continueFlag; - /* 0x01 */ s8 cameraRoll; - /* 0x02 */ u16 nextPointFrame; - /* 0x04 */ f32 viewAngle; // in degrees - /* 0x08 */ Vec3s pos; -} CutsceneCameraPoint; // size = 0x10 - -typedef struct { - /* 0x00 */ Vec3f at; - /* 0x0C */ Vec3f eye; - /* 0x18 */ s16 roll; - /* 0x1A */ s16 fov; -} CutsceneCameraAngle; // size = 0x1C - -typedef struct { - /* 0x0 */ CutsceneCameraPoint* atPoints; - /* 0x4 */ CutsceneCameraPoint* eyePoints; - /* 0x8 */ s16 relativeToPlayer; -} CutsceneCameraMove; // size = 0xC - -typedef struct { - /* 0x00 */ u16 base; - /* 0x02 */ u16 startFrame; - /* 0x04 */ u16 endFrame; -} CsCmdBase; // size = 0x6 - -typedef struct { - /* 0x00 */ u8 unk_00; - /* 0x01 */ u8 setting; - /* 0x02 */ u16 startFrame; - /* 0x04 */ u16 endFrame; -} CsCmdEnvLighting; // size = 0x6 - -typedef struct { - /* 0x00 */ u8 unk_00; - /* 0x01 */ u8 sequence; - /* 0x02 */ u16 startFrame; - /* 0x04 */ u16 endFrame; -} CsCmdMusicChange; // size = 0x6 - -typedef struct { - /* 0x00 */ u16 type; - /* 0x02 */ u16 startFrame; - /* 0x04 */ u16 endFrame; -} CsCmdMusicFade; // size = 0x6 - -typedef struct { - /* 0x00 */ u16 unk_00; - /* 0x02 */ u16 startFrame; - /* 0x04 */ u16 endFrame; - /* 0x06 */ u8 unk_06; - /* 0x07 */ u8 unk_07; - /* 0x08 */ u8 unk_08; -} CsCmdUnknown9; // size = 0xA - -typedef struct { - /* 0x00 */ u16 unk_00; - /* 0x02 */ u16 startFrame; - /* 0x04 */ u16 endFrame; - /* 0x06 */ u8 hour; - /* 0x07 */ u8 minute; -} CsCmdDayTime; // size = 0x8 - -typedef struct { - /* 0x00 */ u16 base; - /* 0x02 */ u16 startFrame; - /* 0x04 */ u16 endFrame; - /* 0x06 */ u16 type; - /* 0x08 */ u16 textId1; - /* 0x0A */ u16 textId2; -} CsCmdTextbox; // size = 0xC - -typedef struct { - /* 0x00 */ u16 action; // "dousa" - /* 0x02 */ u16 startFrame; - /* 0x04 */ u16 endFrame; - union { - /* 0x06 */ Vec3s rot; - /* 0x06 */ Vec3us urot; - }; - /* 0x0C */ Vec3i startPos; - /* 0x18 */ Vec3i endPos; - /* 0x24 */ Vec3i normal; -} CsCmdActorAction; // size = 0x30 -#endif - -typedef enum { - CS_STATE_IDLE, - CS_STATE_SKIPPABLE_INIT, - CS_STATE_SKIPPABLE_EXEC, - CS_STATE_UNSKIPPABLE_INIT, - CS_STATE_UNSKIPPABLE_EXEC -} CutsceneState; - -typedef enum { - CS_CMD_00 = 0x0000, - CS_CMD_CAM_EYE = 0x0001, - CS_CMD_CAM_AT = 0x0002, - CS_CMD_MISC = 0x0003, - CS_CMD_SET_LIGHTING = 0x0004, - CS_CMD_CAM_EYE_REL_TO_PLAYER = 0x0005, - CS_CMD_CAM_AT_REL_TO_PLAYER = 0x0006, - CS_CMD_07 = 0x0007, - CS_CMD_08 = 0x0008, - CS_CMD_09 = 0x0009, - CS_CMD_TEXTBOX = 0x0013, - CS_CMD_SET_PLAYER_ACTION = 0x000A, - CS_CMD_SET_ACTOR_ACTION_1 = 0x000F, - CS_CMD_SET_ACTOR_ACTION_2 = 0x000E, - CS_CMD_SET_ACTOR_ACTION_3 = 0x0019, - CS_CMD_SET_ACTOR_ACTION_4 = 0x001D, - CS_CMD_SET_ACTOR_ACTION_5 = 0x001E, - CS_CMD_SET_ACTOR_ACTION_6 = 0x002C, - CS_CMD_SET_ACTOR_ACTION_7 = 0x001F, - CS_CMD_SET_ACTOR_ACTION_8 = 0x0031, - CS_CMD_SET_ACTOR_ACTION_9 = 0x003E, - CS_CMD_SET_ACTOR_ACTION_10 = 0x008F, - CS_CMD_SCENE_TRANS_FX = 0x002D, - CS_CMD_NOP = 0x000B, - CS_CMD_PLAYBGM = 0x0056, - CS_CMD_STOPBGM = 0x0057, - CS_CMD_FADEBGM = 0x007C, - CS_CMD_SETTIME = 0x008C, - CS_CMD_TERMINATOR = 0x03E8, - CS_CMD_END = 0xFFFF -} CutsceneCmd; - -/** - * Special type for blocks of cutscene data, asm-processor checks - * arrays for CutsceneData type and converts floats within the array - * to their IEEE-754 representation. The array must close with }; - * on its own line. - * - * Files that contain this type that are included in other C files - * must include an 'EARLY' qualifier to inform asm-processor that it - * must recursively process that include. - * - * Example: #include "file.c" EARLY - */ - - -typedef union CutsceneData { - int i; - float f; - short s[2]; - char b[4]; -} CutsceneData; - -#define CS_CMD_CONTINUE 0 -#define CS_CMD_STOP -1 - -// TODO confirm correctness, clarify names -typedef enum { - /* 0x00 */ INVALID_DESTINATION_0, - /* 0x01 */ CUTSCENE_MAP_GANON_HORSE, - /* 0x02 */ CUTSCENE_MAP_THREE_GODESSES_POST_DEKU_TREE, - /* 0x03 */ GERUDO_VALLEY_DIN, - /* 0x04 */ DEATH_MOUNTAIN_TRAIL_NAYRU, - /* 0x05 */ KOKIRI_FOREST_FARORE, - /* 0x06 */ CUTSCENE_MAP_TRIFORCE_CREATION, - /* 0x07 */ KOKIRI_FOREST_RECEIVE_KOKIRI_EMERALD, - /* 0x08 */ TEMPLE_OF_TIME_AFTER_USE_MS, - /* 0x09 */ GERUDO_VALLEY_DIN_2, - /* 0x0A */ LINKS_HOUSE_INTRO, - /* 0x0B */ KOKIRI_FOREST_INTRO, - /* 0x0C */ DEATH_MOUNTAIN_TRAIL_AFTER_GORON_RUBY, - /* 0x0D */ ZORAS_FOUNTAIN_AFTER_ZORAS_SAPPHIRE, - /* 0x0E */ KOKIRI_FOREST_AFTER_KOKIRI_EMERALD, - /* 0x0F */ TEMPLE_OF_TIME_KOKIRI_EMERALD, //unused - /* 0x10 */ TEMPLE_OF_TIME_GORON_RUBY, //unused - /* 0x11 */ TEMPLE_OF_TIME_ZORAS_SAPPHIRE, //unused - /* 0x12 */ TEMPLE_OF_TIME_AFTER_USE_MS_FIRST, - /* 0x13 */ DEATH_MOUNTAIN_TRAIL_AFTER_INTRO, - /* 0x14 */ INVALID_DESTINATION_14, - /* 0x15 */ LAKE_HYLIA_WATER_RISES, - /* 0x16 */ DESERT_COLOSSUS_REQUIEM, - /* 0x17 */ CUTSCENE_MAP_CURSE_YOU, - /* 0x18 */ JABU_JABU_INTRO, - /* 0x19 */ CHAMBER_OF_SAGES_LIGHT_MEDALLION, - /* 0x1A */ TEMPLE_OF_TIME_KOKIRI_EMERALD_2, //duplicate of 0x000F - /* 0x1B */ TEMPLE_OF_TIME_GORON_RUBY_2, //duplicate of 0x0010 - /* 0x1C */ TEMPLE_OF_TIME_ZORAS_SAPPHIRE_2, //duplicate of 0x0011 - /* 0x1D */ CHAMBER_OF_SAGES_FOREST_MEDALLION, - /* 0x1E */ CHAMBER_OF_SAGES_FIRE_MEDALLION, - /* 0x1F */ CHAMBER_OF_SAGES_WATER_MEDALLION, - /* 0x20 */ HYRULE_FIELD_FLASHBACK, //lacs part 4 - /* 0x21 */ HYRULE_FIELD_AFTER_LAKE_HYLIA_OWL, - /* 0x22 */ CUTSCENE_MAP_GANON_AFTER_USE_MS, - /* 0x23 */ HYRULE_FIELD_INTRO_ZELDA_ESCAPE, - /* 0x24 */ INVALID_DESTINATION_24, - /* 0x25 */ INVALID_DESTINATION_25, - /* 0x26 */ CUTSCENE_MAP_SHEIKAH_LEGEND, //lacs part 2 - /* 0x27 */ TEMPLE_OF_TIME_ZELDA_REVEAL, //lacs part 3 - /* 0x28 */ TEMPLE_OF_TIME_GET_LIGHT_ARROWS, //lacs part 5 - /* 0x29 */ LAKE_HYLIA_AFTER_BLUE_WARP, - /* 0x2A */ KAKARIKO_VILLAGE_DRAIN_WELL, - /* 0x2B */ WINDMILL_AFTER_DRAIN_WELL, - /* 0x2C */ TEMPLE_OF_TIME_AFTER_DOOR_OF_TIME_OPENS, - /* 0x2D */ INVALID_DESTINATION_2D, - /* 0x2E */ TEMPLE_OF_TIME_AFTER_USE_MS_FIRST_2, // duplicate of 0x0012 - /* 0x2F */ KAKARIKO_VILLAGE_NOCTURNE_PART_2, - /* 0x30 */ DESERT_COLOSSUS_AFTER_REQUIEM, - /* 0x31 */ TEMPLE_OF_TIME_AFTER_LIGHT_ARROWS, - /* 0x32 */ KAKARIKO_VILLAGE_AFTER_NOCTURNE, - /* 0x33 */ HYRULE_FIELD_IMPA_ESCORT_CS, - /* 0x34 */ TEMPLE_OF_TIME_SONG_OF_TIME, - /* 0x35 */ HYRULE_FIELD_AFTER_SONG_OF_TIME, - /* 0x36 */ GERUDO_VALLEY_CREDITS, - /* 0x37 */ GERUDO_FORTRESS_CREDITS, - /* 0x38 */ KAKARIKO_VILLAGE_CREDITS, - /* 0x39 */ DEATH_MOUNTAIN_TRAIL_CREDITS_1, - /* 0x3A */ GORON_CITY_CREDITS, // unused? - /* 0x3B */ LAKE_HYLIA_CREDITS, - /* 0x3C */ ZORAS_FOUNTAIN_CREDITS, // unused - /* 0x3D */ ZORAS_DOMAIN_CREDITS, - /* 0x3E */ KOKIRI_FOREST_CREDITS_1, - /* 0x3F */ KOKIRI_FOREST_CREDITS_2, - /* 0x40 */ HYRULE_FIELD_CREDITS, - /* 0x41 */ LON_LON_RANCH_CREDITS_1, - /* 0x42 */ KAKARIKO_VILLAGE_AFTER_TRAIL_OWL, - /* 0x43 */ HTRULE_FIELD_UNUSED_ENTRANCE, - /* 0x44 */ CUTSCENE_MAP_FIRE, - /* 0x45 */ KOKIRI_FOREST_POST_FOREST_MEDALLION, - /* 0x46 */ DEATH_MOUNTAIN_TRAIL_CREDITS_2, - /* 0x47 */ TEMPLE_OF_TIME_CREDITS, - /* 0x48 */ ZELDAS_COURTYARD_CREDITS, - /* 0x49 */ LON_LON_RANCH_CREDITS_1_2, // duplicate of 0x0041 - /* 0x4A */ LON_LON_RANCH_CREDITS_2, - /* 0x4B */ LON_LON_RANCH_CREDITS_3, - /* 0x4C */ LON_LON_RANCH_CREDITS_4, - /* 0x4D */ LON_LON_RANCH_CREDITS_5, - /* 0x4E */ LON_LON_RANCH_CREDITS_6, - /* 0x4F */ LON_LON_RANCH_NO_CS_1, - /* 0x50 */ LON_LON_RANCH_NO_CS_2, - /* 0x51 */ LON_LON_RANCH_NO_CS_3, - /* 0x52 */ LON_LON_RANCH_NO_CS_4, - /* 0x53 */ LON_LON_RANCH_NO_CS_5, - /* 0x54 */ LON_LON_RANCH_NO_CS_6, - /* 0x55 */ LON_LON_RANCH_NO_CS_7, - /* 0x56 */ LON_LON_RANCH_NO_CS_8, - /* 0x57 */ LON_LON_RANCH_NO_CS_9, - /* 0x58 */ LON_LON_RANCH_NO_CS_10, - /* 0x59 */ LON_LON_RANCH_NO_CS_11, - /* 0x5A */ LON_LON_RANCH_NO_CS_12, - /* 0x5B */ LON_LON_RANCH_NO_CS_13, - /* 0x5C */ LON_LON_RANCH_NO_CS_14, - /* 0x5D */ LON_LON_RANCH_NO_CS_15, - /* 0x5E */ LON_LON_RANCH_NO_CS_EPONAS_SONG, - /* 0x5F */ CONDITIONAL_DESTINATION, // TODO more descriptive name? - /* 0x60 */ DESERT_COLOSSUS_SPIRIT_BLUE_WARP, - /* 0x61 */ GRAVEYARD_AFTER_SHADOW_BLUE_WARP, - /* 0x62 */ DEATH_MOUNTAIN_CRATER_AFTER_FIRE_BLUE_WARP, - /* 0x63 */ SACRED_FOREST_MEADOW_AFTER_FOREST_BLUE_WARP, - /* 0x64 */ KOKIRI_FOREST_AFTER_FOREST_BLUE_WARP, - /* 0x65 */ DESERT_COLOSSUS_AFTER_SILVER_GAUNTLETS, - /* 0x66 */ TEMPLE_OF_TIME_FRONT_OF_PEDESTAL, - /* 0x67 */ HYRULE_FIELD_TITLE_SCREEN, - /* 0x68 */ SPIRIT_TEMPLE_BOSS_TITLE_SCREEN, - /* 0x69 */ GRAVEYARD_SUNS_SONG, - /* 0x6A */ ROYAL_FAMILYS_TOMB_SUNS_SONG, - /* 0x6B */ GANONS_CASTLE_AFTER_FOREST_TRIAL, - /* 0x6C */ GANONS_CASTLE_AFTER_WATER_TRIAL, - /* 0x6D */ GANONS_CASTLE_AFTER_SHADOW_TRIAL, - /* 0x6E */ GANONS_CASTLE_AFTER_FIRE_TRIAL, - /* 0x6F */ GANONS_CASTLE_AFTER_LIGHT_TRIAL, - /* 0x70 */ GANONS_CASTLE_AFTER_SPIRIT_TRIAL, - /* 0x71 */ GANONS_CASTLE_DISPEL_BARRIER_IF_CONDITIONS, - /* 0x72 */ HYRULE_FIELD_INTRO, - /* 0x73 */ HYRULE_FIELD_AFTER_IMPA_ESCORT, - /* 0x74 */ DESERT_COLOSSUS_SPIRIT_BLUE_WARP_2, - /* 0x75 */ HYRULE_FIELD_SKY, - /* 0x76 */ GANON_BATTLE_TOWER_COLLAPSE, - /* 0x77 */ ZELDAS_COURTYARD_RECEIVE_LETTER -} CutsceneTerminatorDestination; - -#endif \ No newline at end of file diff --git a/OTRExporter/OTRExporter/z64cutscene_commands.h b/OTRExporter/OTRExporter/z64cutscene_commands.h deleted file mode 100644 index 5d440cce9..000000000 --- a/OTRExporter/OTRExporter/z64cutscene_commands.h +++ /dev/null @@ -1,448 +0,0 @@ -#ifndef Z64CUTSCENE_COMMANDS_H -#define Z64CUTSCENE_COMMANDS_H - -#include "command_macros_base.h" -#include "z64cutscene.h" - -/** - * ARGS - * s32 totalEntries (e), s32 endFrame (n) - * FORMAT - * eeeeeeee nnnnnnnn - * size = 0x8 - */ -#define CS_BEGIN_CUTSCENE(totalEntries, endFrame) CMD_W(totalEntries), CMD_W(endFrame) - - /** - * ARGS - * s16 startFrame (s), s16 endFrame (e) - * FORMAT - * 00000001 0001ssss eeee0000 - * size = 0xC - */ -#define CS_CAM_POS_LIST CS_CAM_EYE_LIST -#define CS_CAM_EYE_LIST(startFrame, endFrame) \ - CS_CMD_CAM_EYE, CMD_HH(0x0001, startFrame), CMD_HH(endFrame, 0x0000) - - /** - * ARGS - * s8 continueFlag (c), s8 roll (r), s16 frame (f), f32 viewAngle (a), - * s16 xPos (x), s16 yPos (y), s16 zPos (z) - * FORMAT - * Capital U is Unused - * ccrrffff aaaaaaaa xxxxyyyy zzzzUUUU - * size = 0x10 - */ -#define CS_CAM_POS CS_CAM_EYE -#define CS_CAM_EYE(continueFlag, roll, frame, viewAngle, xPos, yPos, zPos, unused) \ - CMD_BBH(continueFlag, roll, frame), CMD_F(viewAngle), CMD_HH(xPos, yPos), CMD_HH(zPos, unused) - - /** - * ARGS - * s16 startFrame (s), s16 endFrame (e) - * FORMAT - * 00000002 0001ssss eeee0000 - * size = 0xC - */ -#define CS_CAM_FOCUS_POINT_LIST CS_CAM_AT_LIST -#define CS_CAM_AT_LIST(startFrame, endFrame) \ - CS_CMD_CAM_AT, CMD_HH(0x0001, startFrame), CMD_HH(endFrame, 0x0000) - - /** - * ARGS - * s8 continueFlag (c), s8 roll (r), s16 frame (f), f32 viewAngle (a), - * s16 xPos (x), s16 yPos (y), s16 zPos (z) - * FORMAT - * Capital U is Unused - * ccrrffff aaaaaaaa xxxxyyyy zzzzUUUU - * size = 0x10 - */ -#define CS_CAM_FOCUS_POINT CS_CAM_AT -#define CS_CAM_AT(continueFlag, roll, frame, viewAngle, xPos, yPos, zPos, unused) \ - CMD_BBH(continueFlag, roll, frame), CMD_F(viewAngle), CMD_HH(xPos, yPos), CMD_HH(zPos, unused) - - /** - * ARGS - * s32 entries (e) - * FORMAT - * 00000003 eeeeeeee - * size = 0x8 - */ -#define CS_MISC_LIST(entries) CS_CMD_MISC, CMD_W(entries) - - /** - * ARGS - * s16 unk (u), s16 startFrame (s), s16 endFrame (e) - * FORMAT - * Capital U is Unused - * uuuussss eeeeUUUU UUUUUUUU UUUUUUUU UUUUUUUU UUUUUUUU UUUUUUUU UUUUUUUU UUUUUUUU UUUUUUUU UUUUUUUU UUUUUUUU - * size = 0x30 - */ -#define CS_MISC(unk, startFrame, endFrame, unused0, unused1, unused2, unused3, unused4, unused5, unused6, unused7, unused8, unused9, unused10) \ - CMD_HH(unk, startFrame), CMD_HH(endFrame, unused0), \ - CMD_W(unused1), CMD_W(unused2), CMD_W(unused3), CMD_W(unused4), CMD_W(unused5), \ - CMD_W(unused6), CMD_W(unused7), CMD_W(unused8), CMD_W(unused9), CMD_W(unused10) - - /** - * ARGS - * s32 entries (e) - * FORMAT - * 00000004 eeeeeeee - * size = 0x8 - */ -#define CS_LIGHTING_LIST(entries) CS_CMD_SET_LIGHTING, CMD_W(entries) - - /** - * ARGS - * s16 setting (m), s16 startFrame (s), s16 endFrame (e) - * FORMAT - * Capital U is Unused - * mmmmssss eeeeUUUU UUUUUUUU UUUUUUUU UUUUUUUU UUUUUUUU UUUUUUUU UUUUUUUU UUUUUUUU 00000000 00000000 00000000 - * size = 0x30 - */ -#define CS_LIGHTING(setting, startFrame, endFrame, unused0, unused1, unused2, unused3, unused4, unused5, unused6, unused7) \ - CMD_HH(setting, startFrame), CMD_HH(endFrame, unused0), \ - CMD_W(unused1), CMD_W(unused2), CMD_W(unused3), CMD_W(unused4), CMD_W(unused5), \ - CMD_W(unused6), CMD_W(unused7), 0x00000000, 0x00000000, 0x00000000 - - /** - * ARGS - * s16 startFrame (s), s16 endFrame (e) - * FORMAT - * Capital U is Unused , may be consistently zero - * 00000005 0001ssss eeee0000 - * size = 0xC - */ -#define CS_CAM_POS_PLAYER_LIST CS_CAM_EYE_REL_TO_PLAYER_LIST -#define CS_CAM_EYE_REL_TO_PLAYER_LIST(startFrame, endFrame) \ - CS_CMD_CAM_EYE_REL_TO_PLAYER, CMD_HH(0x0001, startFrame), CMD_HH(endFrame, 0x0000) - - /** - * ARGS - * s8 continueFlag (c), s8 roll (r), s16 frame (f), f32 viewAngle (a), - * s16 xPos (x), s16 yPos (y), s16 zPos (z) - * FORMAT - * Capital U is Unused - * ccrrffff aaaaaaaa xxxxyyyy zzzzUUUU - * size = 0x10 - */ -#define CS_CAM_POS_PLAYER CS_CAM_EYE_REL_TO_PLAYER -#define CS_CAM_EYE_REL_TO_PLAYER(continueFlag, roll, frame, viewAngle, xPos, yPos, zPos, unused) \ - CMD_BBH(continueFlag, roll, frame), CMD_F(viewAngle), CMD_HH(xPos, yPos), CMD_HH(zPos, unused) - - /** - * ARGS - * s16 startFrame (s), s16 endFrame (e) - * FORMAT - * Capital U is Unused , may be consistently zero - * 00000006 0001ssss eeee0000 - * size = 0xC - */ -#define CS_CAM_FOCUS_POINT_PLAYER_LIST CS_CAM_AT_REL_TO_PLAYER_LIST -#define CS_CAM_AT_REL_TO_PLAYER_LIST(startFrame, endFrame) \ - CS_CMD_CAM_AT_REL_TO_PLAYER, CMD_HH(0x0001, startFrame), CMD_HH(endFrame, 0x0000) - /** - * ARGS - * s8 continueFlag (c), s8 roll (r), s16 frame (f), f32 viewAngle (a), - * s16 xPos (x), s16 yPos (y), s16 zPos (z) - * FORMAT - * Capital U is Unused - * ccrrffff aaaaaaaa xxxxyyyy zzzzUUUU - * size = 0x10 - */ -#define CS_CAM_FOCUS_POINT_PLAYER CS_CAM_AT_REL_TO_PLAYER -#define CS_CAM_AT_REL_TO_PLAYER(continueFlag, roll, frame, viewAngle, xPos, yPos, zPos, unused) \ - CMD_BBH(continueFlag, roll, frame), CMD_F(viewAngle), CMD_HH(xPos, yPos), CMD_HH(zPos, unused) - - /** - * ARGS - * s16 unk (u), s16 startFrame (s), s16 endFrame (e) - * FORMAT - * Capital U is Unused - * 00000007 uuuussss eeeeUUUU - * size = 0xC - */ -#define CS_CMD_07_LIST(unk, startFrame, endFrame, unused) \ - CS_CMD_07, CMD_HH(unk, startFrame), CMD_HH(endFrame, unused) - - /** - * ARGS - * s8 continueFlag (c), s8 roll (r), s16 frame (f), f32 viewAngle (a), - * s16 xPos (x), s16 yPos (y), s16 zPos (z) - * FORMAT - * Capital U is Unused - * ccrrffff aaaaaaaa xxxxyyyy zzzzUUUU - * size = 0x10 - */ -#define CS_CMD_07(continueFlag, roll, frame, viewAngle, xPos, yPos, zPos, unused) \ - CMD_BBH(continueFlag, roll, frame), CMD_F(viewAngle), CMD_HH(xPos, yPos), CMD_HH(zPos, unused) - - /** - * ARGS - * s16 unk (u), s16 startFrame (s), s16 endFrame (e) - * FORMAT - * Capital U is Unused - * 00000008 uuuussss eeeeUUUU - * size = 0xC - */ -#define CS_CMD_08_LIST(unk, startFrame, endFrame, unused) \ - CS_CMD_08, CMD_HH(unk, startFrame), CMD_HH(endFrame, unused) - - /** - * ARGS - * s8 continueFlag (c), s8 roll (r), s16 frame (f), f32 viewAngle (a), - * s16 xPos (x), s16 yPos (y), s16 zPos (z) - * FORMAT - * Capital U is Unused - * ccrrffff aaaaaaaa xxxxyyyy zzzzUUUU - * size = 0x10 - */ -#define CS_CMD_08(continueFlag, roll, frame, viewAngle, xPos, yPos, zPos, unused) \ - CMD_BBH(continueFlag, roll, frame), CMD_F(viewAngle), CMD_HH(xPos, yPos), CMD_HH(zPos, unused) - - /** - * ARGS - * s32 entries (e) - * FORMAT - * 00000009 eeeeeeee - * size = 0x8 - */ -#define CS_CMD_09_LIST(entries) CS_CMD_09, CMD_W(entries) - - /** - * ARGS - * s16 unk (u), s16 startFrame (s), s16 endFrame (e), s16 unk2 (v), s16 unk3 (w), s16 unk4 (x) - * FORMAT - * Capital U is Unused - * uuuussss eeeevvww xxUUUUUU - * size = 0xC - */ -#define CS_CMD_09(unk, startFrame, endFrame, unk2, unk3, unk4, unused0, unused1) \ - CMD_HH(unk, startFrame), CMD_HBB(endFrame, unk2, unk3), CMD_BBH(unk4, unused0, unused1) - - /** - * ARGS - * s32 cmdType (c), s32 entries (e) - * FORMAT - * cccccccc eeeeeeee - * size = 0x8 - */ -#define CS_UNK_DATA_LIST(cmdType, entries) CMD_W(cmdType), CMD_W(entries) - - /** - * ARGS - * s32 unk1 (a), s32 unk2 (b), s32 unk3 (c), s32 unk4 (d), s32 unk5 (e), s32 unk6 (f), - * s32 unk7 (g), s32 unk8 (h), s32 unk9 (i), s32 unk10 (j), s32 unk11 (k), s32 unk12 (l) - * FORMAT - * aaaaaaaa bbbbbbbb cccccccc dddddddd eeeeeeee ffffffff gggggggg hhhhhhhh iiiiiiii jjjjjjjj kkkkkkkk llllllll - * size = 0x30 - */ -#define CS_UNK_DATA(unk1, unk2, unk3, unk4, unk5, unk6, unk7, unk8, unk9, unk10, unk11, unk12) \ - CMD_W(unk1), CMD_W(unk2), CMD_W(unk3), CMD_W(unk4), CMD_W(unk5), CMD_W(unk6), \ - CMD_W(unk7), CMD_W(unk8), CMD_W(unk9), CMD_W(unk10), CMD_W(unk11), CMD_W(unk12) - - /** - * ARGS - * s32 cmdType (c), s32 entries (e) - * FORMAT - * cccccccc eeeeeeee - * size = 0x8 - */ -#define CS_NPC_ACTION_LIST(cmdType, entries) CMD_W(cmdType), CMD_W(entries) - - /** - * ARGS - * s16 npcAction (a), s16 startFrame (s), s16 endFrame (e), - * s16 rotX (u), s16 rotY (v), s16 rotZ (w), - * s32 startX (i), s32 startY (j), s32 startZ (k), - * s32 endX (l), s32 endY (m), s32 endZ (n), - * f32 normX (x), f32 normY (y), f32 normZ (z), - * FORMAT - * aaaassss eeeeuuuu vvvvwwww iiiiiiii jjjjjjjj kkkkkkkk llllllll mmmmmmmm nnnnnnnn xxxxxxxx yyyyyyyy zzzzzzzz - * size = 0x30 - */ -#define CS_NPC_ACTION(npcAction, startFrame, endFrame, rotX, rotY, rotZ, startX, startY, startZ, endX, endY, endZ, normX, normY, normZ) \ - CMD_HH(npcAction, startFrame), CMD_HH(endFrame, rotX), CMD_HH(rotY, rotZ), \ - CMD_W(startX), CMD_W(startY), CMD_W(startZ), \ - CMD_W(endX), CMD_W(endY), CMD_W(endZ), \ - CMD_F(normX), CMD_F(normY), CMD_F(normZ) - - /** - * ARGS - * s32 cmdType (c), s32 entries (e) - * FORMAT - * cccccccc eeeeeeee - * size = 0x8 - */ -#define CS_PLAYER_ACTION_LIST(entries) CS_CMD_SET_PLAYER_ACTION, CMD_W(entries) - - /** - * ARGS - * s16 linkAction (a), s16 startFrame (s), s16 endFrame (e), - * s16 rotX (u), s16 rotY (v), s16 rotZ (w), - * s32 startX (i), s32 startY (j), s32 startZ (k), - * s32 endX (l), s32 endY (m), s32 endZ (n), - * f32 normX (x), f32 normY (y), f32 normZ (z), - * FORMAT - * aaaassss eeeeuuuu vvvvwwww iiiiiiii jjjjjjjj kkkkkkkk llllllll mmmmmmmm nnnnnnnn xxxxxxxx yyyyyyyy zzzzzzzz - * size = 0x30 - */ -#define CS_PLAYER_ACTION(linkAction, startFrame, endFrame, rotX, rotY, rotZ, startX, startY, startZ, endX, endY, endZ, normX, normY, normZ) \ - CS_NPC_ACTION(linkAction, startFrame, endFrame, rotX, rotY, rotZ, startX, startY, startZ, endX, endY, endZ, normX, normY, normZ) - - /** - * ARGS - * s32 entries (e) - * FORMAT - * 00000013 eeeeeeee - * size = 0x8 - */ -#define CS_TEXT_LIST(entries) CS_CMD_TEXTBOX, CMD_W(entries) - - /** - * ARGS - * s16 messageId (i), s16 startFrame (s), s16 endFrame (e), s16 type (o), - * s16 topOptionBranch (y), s16 bottomOptionBranch (n) - * FORMAT - * iiiissss eeeeoooo yyyynnnn - * size = 0xC - */ -#define CS_TEXT_DISPLAY_TEXTBOX(messageId, startFrame, endFrame, type, topOptionBranch, bottomOptionBranch) \ - CMD_HH(messageId, startFrame), CMD_HH(endFrame, type), CMD_HH(topOptionBranch, bottomOptionBranch) - - /** - * ARGS - * s16 startFrame (s), s16 endFrame (e) - * FORMAT - * FFFFssss eeeeFFFF FFFFFFFF - * size = 0xC - */ -#define CS_TEXT_NONE(startFrame, endFrame) \ - CS_TEXT_DISPLAY_TEXTBOX(0xFFFF, startFrame, endFrame, 0xFFFF, 0xFFFF, 0xFFFF) - - /** - * ARGS - * s16 ocarinaSongAction (o), s16 startFrame (s), s16 endFrame (e), s16 topOptionBranch (i) - * FORMAT - * oooossss eeee0002 iiiiFFFF - * size = 0xC - */ -#define CS_TEXT_LEARN_SONG(ocarinaSongAction, startFrame, endFrame, messageId) \ - CS_TEXT_DISPLAY_TEXTBOX(ocarinaSongAction, startFrame, endFrame, 0x0002, messageId, 0xFFFF) - - /** - * ARGS - * s16 transitionType (t), s16 startFrame (s), s16 endFrame (e) - * FORMAT - * Capital U is Unused , endFrame duplicate - * 0000002D 00000001 ttttssss eeeeUUUU - * size = 0x10 - */ -#define CS_SCENE_TRANS_FX(transitionType, startFrame, endFrame) \ - CS_CMD_SCENE_TRANS_FX, 0x00000001, CMD_HH(transitionType, startFrame), CMD_HH(endFrame, endFrame) - - /** - * ARGS - * s32 entries (e) - * FORMAT - * 00000056 eeeeeeee - * size = 0x8 - */ -#define CS_PLAY_BGM_LIST(entries) CS_CMD_PLAYBGM, CMD_W(entries) - - /** - * ARGS - * s16 sequence (q), s16 startFrame (s), s16 endFrame (e) - * FORMAT - * Capital U is Unused - * qqqqssss eeeeUUUU UUUUUUUU UUUUUUUU UUUUUUUU UUUUUUUU UUUUUUUU UUUUUUUU UUUUUUUU 00000000 00000000 00000000 - * size = 0x30 - */ -#define CS_PLAY_BGM(sequence, startFrame, endFrame, unused0, unused1, unused2, unused3, unused4, unused5, unused6, unused7) \ - CMD_HH(sequence, startFrame), CMD_HH(endFrame, unused0), \ - CMD_W(unused1), CMD_W(unused2), CMD_W(unused3), CMD_W(unused4), CMD_W(unused5), \ - CMD_W(unused6), CMD_W(unused7), 0x00000000, 0x00000000, 0x00000000 - - /** - * ARGS - * s32 entries (e) - * FORMAT - * 00000057 eeeeeeee - * size = 0x8 - */ -#define CS_STOP_BGM_LIST(entries) CS_CMD_STOPBGM, CMD_W(entries) - - /** - * ARGS - * s16 sequence (q), s16 startFrame (s), s16 endFrame (e) - * FORMAT - * Capital U is Unused - * uuqqssss eeeeUUUU UUUUUUUU UUUUUUUU UUUUUUUU UUUUUUUU UUUUUUUU UUUUUUUU UUUUUUUU 00000000 00000000 00000000 - * size = 0x30 - */ -#define CS_STOP_BGM(sequence, startFrame, endFrame, unused0, unused1, unused2, unused3, unused4, unused5, unused6, unused7) \ - CMD_HH(sequence, startFrame), CMD_HH(endFrame, unused0), \ - CMD_W(unused1), CMD_W(unused2), CMD_W(unused3), CMD_W(unused4), CMD_W(unused5), \ - CMD_W(unused6), CMD_W(unused7), 0x00000000, 0x00000000, 0x00000000 - - /** - * ARGS - * s32 entries (e) - * FORMAT - * 0000007C eeeeeeee - * size = 0x8 - */ -#define CS_FADE_BGM_LIST(entries) CS_CMD_FADEBGM, CMD_W(entries) - - /** - * ARGS - * s16 fadeType (t), s16 startFrame (s), s16 endFrame (e) - * FORMAT - * Capital U is Unused - * ttttssss eeeeUUUU UUUUUUUU UUUUUUUU UUUUUUUU UUUUUUUU UUUUUUUU UUUUUUUU UUUUUUUU 00000000 00000000 00000000 - * size = 0x30 - */ -#define CS_FADE_BGM(fadeType, startFrame, endFrame, unused0, unused1, unused2, unused3, unused4, unused5, unused6, unused7) \ - CMD_HH(fadeType, startFrame), CMD_HH(endFrame, unused0), \ - CMD_W(unused1), CMD_W(unused2), CMD_W(unused3), CMD_W(unused4), CMD_W(unused5), \ - CMD_W(unused6), CMD_W(unused7), 0x00000000, 0x00000000, 0x00000000 - - /** - * ARGS - * s32 entries (e) - * FORMAT - * 0000008C eeeeeeee - * size = 0x8 - */ -#define CS_TIME_LIST(entries) CS_CMD_SETTIME, CMD_W(entries) - - /** - * ARGS - * s16 unk (u), s16 startFrame (s), s16 endFrame (e), s8 hour (h), s8 min (m) - * FORMAT - * Capital U is Unused - * uuuussss eeeehhmm UUUUUUUU - * size = 0xC - */ -#define CS_TIME(unk, startFrame, endFrame, hour, min, unused) \ - CMD_HH(unk, startFrame), \ - CMD_HBB(endFrame, hour, min), \ - CMD_W(unused) - - /** - * ARGS - * CutsceneTerminatorDestination dest (d), s16 startFrame (s), s16 endFrame (e) - * FORMAT - * Capital U is Unused , endFrame duplicate - * 000003E8 00000001 ddddssss eeeeUUUU - * size = 0x10 - */ -#define CS_TERMINATOR(dest, startFrame, endFrame) \ - CS_CMD_TERMINATOR, 0x00000001, CMD_HH(dest, startFrame), CMD_HH(endFrame, endFrame) - - /** - * Marks the end of a cutscene - */ -#define CS_END() 0xFFFFFFFF, 0x00000000 - -#endif \ No newline at end of file diff --git a/OTRExporter/extract_assets.py b/OTRExporter/extract_assets.py deleted file mode 100755 index c6d5282a4..000000000 --- a/OTRExporter/extract_assets.py +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/env python3 - -import os, sys, shutil -import shutil -from rom_info import Z64Rom -import rom_chooser -import struct -import subprocess -import argparse - -def BuildOTR(xmlPath, rom, zapd_exe=None, genHeaders=None): - shutil.copytree("assets", "Extract/assets") - - if not zapd_exe: - zapd_exe = "x64\\Release\\ZAPD.exe" if sys.platform == "win32" else "../ZAPDTR/ZAPD.out" - - exec_cmd = [zapd_exe, "ed", "-i", xmlPath, "-b", rom, "-fl", "CFG/filelists", - "-o", "placeholder", "-osf", "placeholder", "-rconf", "CFG/Config.xml"] - - # generate headers, but not otrs by excluding the otr exporter - if genHeaders: - exec_cmd.extend(["-gsf", "1"]) - else: - # generate otrs, but not headers - exec_cmd.extend(["-gsf", "0", "-se", "OTR", "--otrfile", - "oot-mq.otr" if Z64Rom.isMqRom(rom) else "oot.otr"]) - - print(exec_cmd) - exitValue = subprocess.call(exec_cmd) - if exitValue != 0: - print("\n") - print("Error when building the OTR file...", file=os.sys.stderr) - print("Aborting...", file=os.sys.stderr) - print("\n") - -def BuildSohOtr(zapd_exe=None): - shutil.copytree("assets", "Extract/assets") - - if not zapd_exe: - zapd_exe = "x64\\Release\\ZAPD.exe" if sys.platform == "win32" else "../ZAPDTR/ZAPD.out" - - exec_cmd = [zapd_exe, "botr", "-se", "OTR", "--norom"] - - print(exec_cmd) - exitValue = subprocess.call(exec_cmd) - if exitValue != 0: - print("\n") - print("Error when building soh.otr file...", file=os.sys.stderr) - print("Aborting...", file=os.sys.stderr) - print("\n") - -def main(): - parser = argparse.ArgumentParser() - parser.add_argument("-z", "--zapd", help="Path to ZAPD executable", dest="zapd_exe", type=str) - parser.add_argument("rom", help="Path to the rom", type=str, nargs="?") - parser.add_argument("--non-interactive", help="Runs the script non-interactively for use in build scripts.", dest="non_interactive", action="store_true") - parser.add_argument("-v", "--verbose", help="Display rom's header checksums and their corresponding xml folder", dest="verbose", action="store_true") - parser.add_argument("--gen-headers", help="Generate source headers to be checked in", dest="gen_headers", action="store_true") - parser.add_argument("--norom", help="Generate only soh.otr to be bundled to the game", dest="norom", action="store_true") - - args = parser.parse_args() - - if args.norom: - if (os.path.exists("Extract")): - shutil.rmtree("Extract") - - BuildSohOtr(args.zapd_exe) - return - - roms = [ Z64Rom(args.rom) ] if args.rom else rom_chooser.chooseROM(args.verbose, args.non_interactive) - for rom in roms: - if (os.path.exists("Extract")): - shutil.rmtree("Extract") - - BuildOTR("../soh/assets/xml/" + rom.version.xml_ver + "/", rom.file_path, zapd_exe=args.zapd_exe, genHeaders=args.gen_headers) - -if __name__ == "__main__": - main() diff --git a/OTRExporter/extract_baserom.py b/OTRExporter/extract_baserom.py deleted file mode 100644 index f387df57a..000000000 --- a/OTRExporter/extract_baserom.py +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/python3 - -import os -import sys -import struct -from multiprocessing import Pool, cpu_count -from rom_info import Z64Rom -import rom_chooser - - -rom = None - -def initialize_worker(input_rom): - global rom - rom = input_rom - -def ExtractFunc(i): - - dma_file = rom.getDmaEntryByIndex(i) - dma_data = rom.readDmaEntry(dma_file) - - filename = '../soh/baserom/' + rom.version.file_table[i] - print('extracting ' + filename + " (0x%08X, 0x%08X)" % (dma_file.virtStart, dma_file.virtEnd)) - - try: - with open(filename, 'wb') as f: - f.write(dma_data) - except IOError: - print('failed to write file ' + filename) - - # TODO: handle this better - if dma_file.compressed: - os.system('tools/yaz0 -d ' + filename + ' ' + filename) - -##################################################################### - -def main(): - try: - os.mkdir('../soh/baserom') - except: - pass - - rom_path = rom_chooser.chooseROM() - input_rom = Z64Rom(rom_path) - - # extract files - num_cores = cpu_count() - print("Extracting baserom with " + str(num_cores) + " CPU cores.") - with Pool(num_cores, initialize_worker, (input_rom,)) as p: - p.map(ExtractFunc, range(len(input_rom.version.file_table))) - -if __name__ == "__main__": - main() diff --git a/OTRExporter/offsets.json b/OTRExporter/offsets.json deleted file mode 100644 index e03311620..000000000 --- a/OTRExporter/offsets.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "MQDebug": { - "bankdefs": [1281424, 128], - "fontdefs": [1278576, 624], - "fontmaps": [1279200, 448], - "seqdefs": [1279648, 1776] - } -} \ No newline at end of file diff --git a/OTRExporter/rom_chooser.py b/OTRExporter/rom_chooser.py deleted file mode 100644 index fa5fcc281..000000000 --- a/OTRExporter/rom_chooser.py +++ /dev/null @@ -1,54 +0,0 @@ -import os, sys, glob - -from rom_info import Z64Rom - -def chooseROM(verbose=False, non_interactive=False): - roms = [] - - for file in glob.glob("*.z64"): - rom = Z64Rom(file) - if rom.is_valid: - roms.append(rom) - - if not (roms): - print("Error: No roms located, place one in the OTRExporter directory", file=os.sys.stderr) - sys.exit(1) - - if (len(roms) == 1): - return roms - - if non_interactive: - mq_rom = None - non_mq_rom = None - for rom in roms: - if rom.isMq and mq_rom is None: - mq_rom = rom - elif not rom.isMq and non_mq_rom is None: - non_mq_rom = rom - return [rom for rom in [non_mq_rom, mq_rom] if rom is not None] - - print(f"{len(roms)} roms found, please select one by pressing 1-{len(roms)}") - print() - - for i in range(len(roms)): - print(f"[{i+1:>2d}] {roms[i].file_path}") - if verbose: - print(f" Checksum: {roms[i].checksum.value}, Version XML: {roms[i].version.xml_ver}") - print() - - while(1): - try: - selection = int(input()) - except KeyboardInterrupt: - sys.exit(1) - except: - print("Bad input. Try again with the number keys.") - continue - - if (selection < 1 or selection > len(roms)): - print("Bad input. Try again.") - continue - - else: break - - return [ roms[selection - 1] ] diff --git a/OTRExporter/rom_info.py b/OTRExporter/rom_info.py deleted file mode 100644 index 897b145af..000000000 --- a/OTRExporter/rom_info.py +++ /dev/null @@ -1,100 +0,0 @@ -from enum import Enum -from tabnanny import check -import struct - -class Checksums(Enum): - OOT_NTSC_10 = "EC7011B7" - OOT_NTSC_11 = "D43DA81F" - OOT_NTSC_12 = "693BA2AE" - OOT_PAL_10 = "B044B569" - OOT_PAL_11 = "B2055FBD" - OOT_NTSC_JP_GC_CE = "F7F52DB8" - OOT_NTSC_JP_GC = "F611F4BA" - OOT_NTSC_US_GC = "F3DD35BA" - OOT_PAL_GC = "09465AC3" - OOT_NTSC_JP_MQ = "F43B45BA" - OOT_NTSC_US_MQ = "F034001A" - OOT_PAL_MQ = "1D4136F3" - OOT_PAL_GC_DBG1 = "871E1C92" - OOT_PAL_GC_DBG2 = "87121EFE" - OOT_PAL_GC_MQ_DBG = "917D18F6" - OOT_IQUE_TW = "3D81FB3E" - OOT_IQUE_CN = "B1E1E07B" - OOT_UNKNOWN = "FFFFFFFF" - - @classmethod - def has_value(self, value): - return value in self._value2member_map_ - -class RomVersion: - def __init__(self, file_table_path, file_table_off, xml_ver): - self.file_table_off = file_table_off - self.xml_ver = xml_ver - with open(file_table_path, 'r') as f: - self.file_table = [line.strip('\n') for line in f] - -ROM_INFO_TABLE = dict() -ROM_INFO_TABLE[Checksums.OOT_PAL_GC] = RomVersion("CFG/filelists/gamecube_pal.txt", 0x7170, "GC_NMQ_PAL_F") -ROM_INFO_TABLE[Checksums.OOT_PAL_MQ] = RomVersion("CFG/filelists/gamecube_pal.txt", 0x7170, "GC_MQ_PAL_F") -ROM_INFO_TABLE[Checksums.OOT_PAL_GC_DBG1] = RomVersion("CFG/filelists/dbg.txt", 0x12F70, "GC_NMQ_D") -ROM_INFO_TABLE[Checksums.OOT_PAL_GC_MQ_DBG] = RomVersion("CFG/filelists/dbg.txt", 0x12F70, "GC_MQ_D") -ROM_INFO_TABLE[Checksums.OOT_PAL_10] = RomVersion("CFG/filelists/pal_oot.txt", 0x7950, "N64_PAL_10") -ROM_INFO_TABLE[Checksums.OOT_PAL_11] = RomVersion("CFG/filelists/pal_oot.txt", 0x7950, "N64_PAL_11") - -class RomDmaEntry: - def __init__(self, rom, i): - - off = rom.version.file_table_off + 16 * i - - (self.virtStart, \ - self.virtEnd, \ - self.physStart, \ - self.physEnd) = struct.unpack('>IIII', rom.rom_data[off:off+4*4]) - - self.compressed = self.physEnd != 0 - self.size = self.physEnd - self.physStart \ - if self.compressed \ - else self.virtEnd - self.virtStart - self.name = rom.version.file_table[i] - - -class Z64Rom: - def __init__(self, file_path): - self.file_path = file_path - with open(file_path, 'rb') as f: - self.rom_data = f.read() - - self.is_valid = len(self.rom_data) > 20 * 1024 * 1024 - - if not self.is_valid: - return - - # get checkum - checksum_str = self.rom_data[16:16+4].hex().upper() - self.checksum = Checksums(checksum_str) if Checksums.has_value(checksum_str) else Checksums.OOT_UNKNOWN - - if self.checksum == Checksums.OOT_UNKNOWN: - self.is_valid = False - return - - if self.checksum in [Checksums.OOT_NTSC_JP_MQ, Checksums.OOT_NTSC_US_MQ, Checksums.OOT_PAL_GC_MQ_DBG, Checksums.OOT_PAL_MQ]: - self.isMq = True - else: - self.isMq = False - - # get rom version - self.version = ROM_INFO_TABLE[self.checksum] - - def getDmaEntryByIndex(self, i): - return RomDmaEntry(self, i) - - def readDmaEntry(self, entry): - return self.rom_data[entry.physStart:entry.physStart + entry.size] - - @staticmethod - def isValidRom(rom_path): - return Z64Rom(rom_path).is_valid - - @staticmethod - def isMqRom(rom_path): - return Z64Rom(rom_path).isMq diff --git a/ZAPDTR b/ZAPDTR new file mode 160000 index 000000000..9b8e224da --- /dev/null +++ b/ZAPDTR @@ -0,0 +1 @@ +Subproject commit 9b8e224dac83aa8e47a688884ad48725f18fc293 diff --git a/ZAPDTR/.clang-format b/ZAPDTR/.clang-format deleted file mode 100644 index 784e734e9..000000000 --- a/ZAPDTR/.clang-format +++ /dev/null @@ -1,84 +0,0 @@ ---- -AccessModifierOffset: -4 -AlignAfterOpenBracket: Align -AlignConsecutiveAssignments: false -AlignConsecutiveDeclarations: false -AlignEscapedNewlinesLeft: false -AlignOperands: true -AlignTrailingComments: true -AllowAllParametersOfDeclarationOnNextLine: true -AllowShortBlocksOnASingleLine: false -AllowShortCaseLabelsOnASingleLine: false -AllowShortFunctionsOnASingleLine: InlineOnly -AllowShortIfStatementsOnASingleLine: false -AllowShortLoopsOnASingleLine: false -AlwaysBreakAfterDefinitionReturnType: None -AlwaysBreakAfterReturnType: None -AlwaysBreakBeforeMultilineStrings: false -AlwaysBreakTemplateDeclarations: true -BinPackArguments: true -BinPackParameters: true -BraceWrapping: - AfterCaseLabel: true - AfterClass: true - AfterControlStatement: true - AfterEnum: true - AfterFunction: true - AfterNamespace: true - AfterStruct: true - AfterUnion: true - BeforeCatch: true - BeforeElse: true - IndentBraces: false -BreakBeforeBinaryOperators: None -BreakBeforeBraces: Custom -BreakBeforeTernaryOperators: false -BreakConstructorInitializersBeforeComma: false -ColumnLimit: 100 -CommentPragmas: '^ (IWYU pragma:|NOLINT)' -ConstructorInitializerAllOnOneLineOrOnePerLine: false -ConstructorInitializerIndentWidth: 4 -ContinuationIndentWidth: 4 -Cpp11BracedListStyle: true -DerivePointerAlignment: false -DisableFormat: false -ForEachMacros: [ ] -IncludeCategories: - - Regex: '^<[Ww]indows\.h>$' - Priority: 1 - - Regex: '^<' - Priority: 2 - - Regex: '^"' - Priority: 3 -IndentCaseLabels: false -IndentWidth: 4 -IndentWrappedFunctionNames: false -KeepEmptyLinesAtTheStartOfBlocks: false -MacroBlockBegin: '' -MacroBlockEnd: '' -MaxEmptyLinesToKeep: 1 -NamespaceIndentation: None -PenaltyBreakBeforeFirstCallParameter: 19 -PenaltyBreakComment: 300 -PenaltyBreakFirstLessLess: 120 -PenaltyBreakString: 1000 -PenaltyExcessCharacter: 1000000 -PenaltyReturnTypeOnItsOwnLine: 60 -PointerAlignment: Left -ReflowComments: true -SortIncludes: true -SpaceAfterCStyleCast: false -SpaceBeforeAssignmentOperators: true -SpaceBeforeParens: ControlStatements -SpaceInEmptyParentheses: false -SpacesBeforeTrailingComments: 2 -SpacesInAngles: false -SpacesInContainerLiterals: true -SpacesInCStyleCastParentheses: false -SpacesInParentheses: false -SpacesInSquareBrackets: false -Standard: Latest -TabWidth: 4 -UseTab: AlignWithSpaces -... - diff --git a/ZAPDTR/.gitignore b/ZAPDTR/.gitignore deleted file mode 100644 index 68c502e36..000000000 --- a/ZAPDTR/.gitignore +++ /dev/null @@ -1,341 +0,0 @@ -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. -## -## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore - -# User-specific files -*.suo -*.user -*.userosscache -*.sln.docstates - -# User-specific files (MonoDevelop/Xamarin Studio) -*.userprefs - -# Build results -[Dd]ebug/ -[Dd]ebugPublic/ -[Rr]elease/ -[Rr]eleases/ -x64/ -x86/ -bld/ -[Bb]in/ -[Oo]bj/ -[Ll]og/ - -# Visual Studio 2015/2017 cache/options directory -.vs/ -# Uncomment if you have tasks that create the project's static files in wwwroot -#wwwroot/ - -# Visual Studio 2017 auto generated files -Generated\ Files/ - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -# NUNIT -*.VisualState.xml -TestResult.xml - -# Build Results of an ATL Project -[Dd]ebugPS/ -[Rr]eleasePS/ -dlldata.c - -# Benchmark Results -BenchmarkDotNet.Artifacts/ - -# .NET Core -project.lock.json -project.fragment.lock.json -artifacts/ -**/Properties/launchSettings.json - -# StyleCop -StyleCopReport.xml - -# Files built by Visual Studio -*_i.c -*_p.c -*_i.h -*.ilk -*.meta -*.obj -*.iobj -*.pch -*.pdb -*.ipdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.svclog -*.scc - -# Chutzpah Test files -_Chutzpah* - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opendb -*.opensdf -*.sdf -*.cachefile -*.VC.db -*.VC.VC.opendb - -# Visual Studio profiler -*.psess -*.vsp -*.vspx -*.sap - -# Visual Studio Trace Files -*.e2e - -# TFS 2012 Local Workspace -$tf/ - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper -*.DotSettings.user - -# JustCode is a .NET coding add-in -.JustCode - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# AxoCover is a Code Coverage Tool -.axoCover/* -!.axoCover/settings.json - -# Visual Studio code coverage results -*.coverage -*.coveragexml - -# NCrunch -_NCrunch_* -.*crunch*.local.xml -nCrunchTemp_* - -# MightyMoose -*.mm.* -AutoTest.Net/ - -# Web workbench (sass) -.sass-cache/ - -# Installshield output folder -[Ee]xpress/ - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish/ - -# Publish Web Output -*.[Pp]ublish.xml -*.azurePubxml -# Note: Comment the next line if you want to checkin your web deploy settings, -# but database connection strings (with potential passwords) will be unencrypted -*.pubxml -*.publishproj - -# Microsoft Azure Web App publish settings. Comment the next line if you want to -# checkin your Azure Web App publish settings, but sensitive information contained -# in these scripts will be unencrypted -PublishScripts/ - -# NuGet Packages -*.nupkg -# The packages folder can be ignored because of Package Restore -**/[Pp]ackages/* -# except build/, which is used as an MSBuild target. -!**/[Pp]ackages/build/ -# Uncomment if necessary however generally it will be regenerated when needed -#!**/[Pp]ackages/repositories.config -# NuGet v3's project.json files produces more ignorable files -*.nuget.props -*.nuget.targets - -# Microsoft Azure Build Output -csx/ -*.build.csdef - -# Microsoft Azure Emulator -ecf/ -rcf/ - -# Windows Store app package directories and files -AppPackages/ -BundleArtifacts/ -Package.StoreAssociation.xml -_pkginfo.txt -*.appx - -# Visual Studio cache files -# files ending in .cache can be ignored -*.[Cc]ache -# but keep track of directories ending in .cache -!*.[Cc]ache/ - -# Others -ClientBin/ -~$* -*~ -*.dbmdl -*.dbproj.schemaview -*.jfm -*.pfx -*.publishsettings -orleans.codegen.cs - -# Including strong name files can present a security risk -# (https://github.com/github/gitignore/pull/2483#issue-259490424) -#*.snk - -# Since there are multiple workflows, uncomment next line to ignore bower_components -# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) -#bower_components/ - -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file -# to a newer Visual Studio version. Backup files are not needed, -# because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm -ServiceFabricBackup/ -*.rptproj.bak - -# SQL Server files -*.mdf -*.ldf -*.ndf - -# Business Intelligence projects -*.rdl.data -*.bim.layout -*.bim_*.settings -*.rptproj.rsuser - -# Microsoft Fakes -FakesAssemblies/ - -# GhostDoc plugin setting file -*.GhostDoc.xml - -# Node.js Tools for Visual Studio -.ntvs_analysis.dat -node_modules/ - -# Visual Studio 6 build log -*.plg - -# Visual Studio 6 workspace options file -*.opt - -# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) -*.vbw - -# Visual Studio LightSwitch build output -**/*.HTMLClient/GeneratedArtifacts -**/*.DesktopClient/GeneratedArtifacts -**/*.DesktopClient/ModelManifest.xml -**/*.Server/GeneratedArtifacts -**/*.Server/ModelManifest.xml -_Pvt_Extensions - -# Paket dependency manager -.paket/paket.exe -paket-files/ - -# FAKE - F# Make -.fake/ - -# JetBrains Rider -.idea/ -*.sln.iml - -# CodeRush -.cr/ - -# Python Tools for Visual Studio (PTVS) -__pycache__/ -*.pyc - -# Cake - Uncomment if you are using it -# tools/** -# !tools/packages.config - -# Tabs Studio -*.tss - -# Telerik's JustMock configuration file -*.jmconfig - -# BizTalk build output -*.btp.cs -*.btm.cs -*.odx.cs -*.xsd.cs - -# OpenCover UI analysis results -OpenCover/ - -# Azure Stream Analytics local run output -ASALocalRun/ - -# MSBuild Binary and Structured Log -*.binlog - -# NVidia Nsight GPU debugger configuration file -*.nvuser - -# MFractors (Xamarin productivity tool) working folder -.mfractor/ - -*.out -*.o -*.d -lib/libgfxd/libgfxd.a -ExporterTest/ExporterTest.a -ZAPDUtils/ZAPDUtils.a -.vscode/ -build/ -ZAPDUtils/build/ -ZAPD/BuildInfo.h diff --git a/ZAPDTR/.gitrepo b/ZAPDTR/.gitrepo deleted file mode 100644 index bf9a6491f..000000000 --- a/ZAPDTR/.gitrepo +++ /dev/null @@ -1,12 +0,0 @@ -; DO NOT EDIT (unless you know what you are doing) -; -; This subdirectory is a git "subrepo", and this file is maintained by the -; git-subrepo command. See https://github.com/git-commands/git-subrepo#readme -; -[subrepo] - remote = https://github.com/harbourmasters/ZAPDTR - branch = master - commit = d4c35b90aed66eeed61066b4b76e488bfab52b4d - parent = 9d17e19a1dcf2b5c6cef0d3c93816f98a280eb58 - method = rebase - cmdver = 0.4.3 diff --git a/ZAPDTR/ExporterTest/CollisionExporter.cpp b/ZAPDTR/ExporterTest/CollisionExporter.cpp deleted file mode 100644 index c2167180d..000000000 --- a/ZAPDTR/ExporterTest/CollisionExporter.cpp +++ /dev/null @@ -1,76 +0,0 @@ -#include "CollisionExporter.h" - -void ExporterExample_Collision::Save(ZResource* res, [[maybe_unused]] const fs::path& outPath, - BinaryWriter* writer) -{ - ZCollisionHeader* col = (ZCollisionHeader*)res; - - writer->Write(col->absMinX); - writer->Write(col->absMinY); - writer->Write(col->absMinZ); - - writer->Write(col->absMaxX); - writer->Write(col->absMaxY); - writer->Write(col->absMaxZ); - - writer->Write(col->numVerts); - writer->Write(col->vtxAddress); - - writer->Write(col->numPolygons); - writer->Write(col->polyAddress); - writer->Write(col->polyTypeDefAddress); - writer->Write(col->camDataAddress); - - writer->Write(col->numWaterBoxes); - writer->Write(col->waterBoxAddress); - - writer->Write(col->vtxSegmentOffset); - writer->Write(col->polySegmentOffset); - writer->Write(col->polyTypeDefSegmentOffset); - writer->Write(col->camDataSegmentOffset); - writer->Write(col->waterBoxSegmentOffset); - - uint32_t oldOffset = writer->GetBaseAddress(); - - writer->Seek(col->vtxSegmentOffset, SeekOffsetType::Start); - - for (uint16_t i = 0; i < col->vertices.size(); i++) - { - for (uint32_t j = 0; j < col->vertices[i].dimensions; j++) - { - writer->Write(col->vertices[i].scalars[j].scalarData.s16); - } - } - - writer->Seek(col->polySegmentOffset, SeekOffsetType::Start); - - for (uint16_t i = 0; i < col->polygons.size(); i++) - { - writer->Write(col->polygons[i].type); - writer->Write(col->polygons[i].vtxA); - writer->Write(col->polygons[i].vtxB); - writer->Write(col->polygons[i].vtxC); - writer->Write(col->polygons[i].normX); - writer->Write(col->polygons[i].normY); - writer->Write(col->polygons[i].normZ); - writer->Write(col->polygons[i].dist); - } - - writer->Seek(col->polyTypeDefSegmentOffset, SeekOffsetType::Start); - - for (const auto& poly : col->polygonTypes) - { - writer->Write(poly.data[0]); - writer->Write(poly.data[1]); - } - writer->Seek(col->camDataSegmentOffset, SeekOffsetType::Start); - - for (auto entry : col->camData->entries) - { - writer->Write(entry->cameraSType); - writer->Write(entry->numData); - writer->Write(entry->cameraPosDataSeg); - } - - writer->Seek(oldOffset, SeekOffsetType::Start); -} diff --git a/ZAPDTR/ExporterTest/CollisionExporter.h b/ZAPDTR/ExporterTest/CollisionExporter.h deleted file mode 100644 index 1dc50634e..000000000 --- a/ZAPDTR/ExporterTest/CollisionExporter.h +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once - -#include "ZCollision.h" -#include "ZResource.h" - -class ExporterExample_Collision : public ZResourceExporter -{ -public: - void Save(ZResource* res, const fs::path& outPath, BinaryWriter* writer) override; -}; \ No newline at end of file diff --git a/ZAPDTR/ExporterTest/ExporterTest.vcxproj b/ZAPDTR/ExporterTest/ExporterTest.vcxproj deleted file mode 100644 index 341f72ceb..000000000 --- a/ZAPDTR/ExporterTest/ExporterTest.vcxproj +++ /dev/null @@ -1,160 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - Win32Proj - {65608eb0-1a47-45ad-ab66-192fb64c762c} - ExporterTest - 10.0 - ExporterExample - - - - Application - true - v142 - Unicode - - - Application - false - v143 - true - Unicode - - - StaticLibrary - true - v142 - Unicode - - - Application - false - v143 - true - Unicode - - - - - - - - - - - - - - - - - - - - - true - - - false - - - true - $(ProjectDir)..\ZAPD\;$(ProjectDir)..\ZAPDUtils;$(ProjectDir)..\lib\tinyxml2;$(ProjectDir)..\lib\libgfxd;$(ProjectDir)..\lib\elfio;$(ProjectDir)..\lib\stb;$(ProjectDir);$(IncludePath) - - - false - - - - Level3 - true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - Level3 - true - _DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - true - stdcpp17 - stdc11 - MultiThreadedDebug - - - Console - true - - - - - Level3 - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/ZAPDTR/ExporterTest/ExporterTest.vcxproj.filters b/ZAPDTR/ExporterTest/ExporterTest.vcxproj.filters deleted file mode 100644 index 166f563a1..000000000 --- a/ZAPDTR/ExporterTest/ExporterTest.vcxproj.filters +++ /dev/null @@ -1,42 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Header Files - - - Header Files - - - Header Files - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - \ No newline at end of file diff --git a/ZAPDTR/ExporterTest/Main.cpp b/ZAPDTR/ExporterTest/Main.cpp deleted file mode 100644 index 07fdbeece..000000000 --- a/ZAPDTR/ExporterTest/Main.cpp +++ /dev/null @@ -1,79 +0,0 @@ -#include "CollisionExporter.h" -#include "Globals.h" -#include "RoomExporter.h" -#include "TextureExporter.h" - -enum class ExporterFileMode -{ - ModeExample1 = (int)ZFileMode::Custom + 1, - ModeExample2 = (int)ZFileMode::Custom + 2, - ModeExample3 = (int)ZFileMode::Custom + 3, -}; - -static void ExporterParseFileMode(const std::string& buildMode, ZFileMode& fileMode) -{ - if (buildMode == "me1") - fileMode = (ZFileMode)ExporterFileMode::ModeExample1; - else if (buildMode == "me2") - fileMode = (ZFileMode)ExporterFileMode::ModeExample2; - else if (buildMode == "me3") - fileMode = (ZFileMode)ExporterFileMode::ModeExample3; -} - -static void ExporterParseArgs([[maybe_unused]] int argc, char* argv[], int& i) -{ - std::string arg = argv[i]; - - if (arg == "--do-x") - { - } - else if (arg == "--do-y") - { - } -} - -static bool ExporterProcessFileMode(ZFileMode fileMode) -{ - // Do whatever work is associated with these custom file modes... - // Return true to indicate one of our own file modes is being processed - if (fileMode == (ZFileMode)ExporterFileMode::ModeExample1) - return true; - else if (fileMode == (ZFileMode)ExporterFileMode::ModeExample2) - return true; - else if (fileMode == (ZFileMode)ExporterFileMode::ModeExample3) - return true; - - return false; -} - -static void ExporterFileBegin(ZFile* file) -{ - printf("ExporterFileBegin() called on ZFile %s.\n", file->GetName().c_str()); -} - -static void ExporterFileEnd(ZFile* file) -{ - printf("ExporterFileEnd() called on ZFile %s.\n", file->GetName().c_str()); -} - -static void ImportExporters() -{ - // In this example we set up a new exporter called "EXAMPLE". - // By running ZAPD with the argument -se EXAMPLE, we tell it that we want to use this exporter - // for our resources. - ExporterSet* exporterSet = new ExporterSet(); - exporterSet->processFileModeFunc = ExporterProcessFileMode; - exporterSet->parseFileModeFunc = ExporterParseFileMode; - exporterSet->parseArgsFunc = ExporterParseArgs; - exporterSet->beginFileFunc = ExporterFileBegin; - exporterSet->endFileFunc = ExporterFileEnd; - exporterSet->exporters[ZResourceType::Texture] = new ExporterExample_Texture(); - exporterSet->exporters[ZResourceType::Room] = new ExporterExample_Room(); - exporterSet->exporters[ZResourceType::CollisionHeader] = new ExporterExample_Collision(); - - Globals::AddExporter("EXAMPLE", exporterSet); -} - -// When ZAPD starts up, it will automatically call the below function, which in turn sets up our -// exporters. -REGISTER_EXPORTER(ImportExporters); diff --git a/ZAPDTR/ExporterTest/Makefile b/ZAPDTR/ExporterTest/Makefile deleted file mode 100644 index 42033b7c0..000000000 --- a/ZAPDTR/ExporterTest/Makefile +++ /dev/null @@ -1,28 +0,0 @@ -# Only used for standalone compilation, usually inherits these from the main makefile -CXXFLAGS ?= -Wall -Wextra -O2 -g -std=c++17 - -SRC_DIRS := $(shell find . -type d -not -path "*build*") -CPP_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.cpp)) -H_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.h)) - -O_FILES := $(foreach f,$(CPP_FILES:.cpp=.o),build/$f) -LIB := ExporterTest.a - -# create build directories -$(shell mkdir -p $(foreach dir,$(SRC_DIRS),build/$(dir))) - -all: $(LIB) - -clean: - rm -rf build $(LIB) - -format: - clang-format-11 -i $(CPP_FILES) $(H_FILES) - -.PHONY: all clean format - -build/%.o: %.cpp - $(CXX) $(CXXFLAGS) $(OPTFLAGS) -I ./ -I ../ZAPD -I ../ZAPDUtils -I ../lib/tinyxml2 -c $(OUTPUT_OPTION) $< - -$(LIB): $(O_FILES) - $(AR) rcs $@ $^ diff --git a/ZAPDTR/ExporterTest/RoomExporter.cpp b/ZAPDTR/ExporterTest/RoomExporter.cpp deleted file mode 100644 index e77f26485..000000000 --- a/ZAPDTR/ExporterTest/RoomExporter.cpp +++ /dev/null @@ -1,372 +0,0 @@ -#include "RoomExporter.h" -#include "CollisionExporter.h" -#include "Utils/BinaryWriter.h" -#include -#include "Utils/MemoryStream.h" -#include "ZRoom/Commands/SetCameraSettings.h" -#include "ZRoom/Commands/SetCollisionHeader.h" -#include "ZRoom/Commands/SetCsCamera.h" -#include "ZRoom/Commands/SetEchoSettings.h" -#include "ZRoom/Commands/SetEntranceList.h" -#include "ZRoom/Commands/SetLightingSettings.h" -#include "ZRoom/Commands/SetMesh.h" -#include "ZRoom/Commands/SetRoomBehavior.h" -#include "ZRoom/Commands/SetRoomList.h" -#include "ZRoom/Commands/SetSkyboxModifier.h" -#include "ZRoom/Commands/SetSkyboxSettings.h" -#include "ZRoom/Commands/SetSoundSettings.h" -#include "ZRoom/Commands/SetSpecialObjects.h" -#include "ZRoom/Commands/SetStartPositionList.h" -#include "ZRoom/Commands/SetTimeSettings.h" -#include "ZRoom/Commands/SetWind.h" - -void ExporterExample_Room::Save(ZResource* res, const fs::path& outPath, BinaryWriter* writer) -{ - ZRoom* room = dynamic_cast(res); - - // MemoryStream* memStream = new MemoryStream(); - // BinaryWriter* writer = new BinaryWriter(memStream); - - for (size_t i = 0; i < room->commands.size() * 8; i++) - writer->Write((uint8_t)0); - - for (size_t i = 0; i < room->commands.size(); i++) - { - ZRoomCommand* cmd = room->commands[i]; - - writer->Seek(i * 8, SeekOffsetType::Start); - - writer->Write((uint8_t)cmd->cmdID); - - switch (cmd->cmdID) - { - case RoomCommand::SetWind: - { - SetWind* cmdSetWind = (SetWind*)cmd; - - writer->Write((uint8_t)0); // 0x01 - writer->Write((uint8_t)0); // 0x02 - writer->Write((uint8_t)0); // 0x03 - - writer->Write(cmdSetWind->windWest); // 0x04 - writer->Write(cmdSetWind->windVertical); // 0x05 - writer->Write(cmdSetWind->windSouth); // 0x06 - writer->Write(cmdSetWind->clothFlappingStrength); // 0x07 - } - break; - case RoomCommand::SetTimeSettings: - { - SetTimeSettings* cmdTime = (SetTimeSettings*)cmd; - - writer->Write((uint8_t)0); // 0x01 - writer->Write((uint8_t)0); // 0x02 - writer->Write((uint8_t)0); // 0x03 - - writer->Write(cmdTime->hour); // 0x04 - writer->Write(cmdTime->min); // 0x05 - writer->Write(cmdTime->unk); // 0x06 - writer->Write((uint8_t)0); // 0x07 - } - break; - case RoomCommand::SetSkyboxModifier: - { - SetSkyboxModifier* cmdSkybox = (SetSkyboxModifier*)cmd; - - writer->Write((uint8_t)0); // 0x01 - writer->Write((uint8_t)0); // 0x02 - writer->Write((uint8_t)0); // 0x03 - - writer->Write(cmdSkybox->disableSky); // 0x04 - writer->Write(cmdSkybox->disableSunMoon); // 0x05 - writer->Write((uint8_t)0); // 0x06 - writer->Write((uint8_t)0); // 0x07 - } - break; - case RoomCommand::SetEchoSettings: - { - SetEchoSettings* cmdEcho = (SetEchoSettings*)cmd; - - writer->Write((uint8_t)0); // 0x01 - writer->Write((uint8_t)0); // 0x02 - writer->Write((uint8_t)0); // 0x03 - writer->Write((uint8_t)0); // 0x04 - writer->Write((uint8_t)0); // 0x05 - writer->Write((uint8_t)0); // 0x06 - writer->Write((uint8_t)cmdEcho->echo); // 0x07 - } - break; - case RoomCommand::SetSoundSettings: - { - SetSoundSettings* cmdSound = (SetSoundSettings*)cmd; - - writer->Write((uint8_t)cmdSound->reverb); // 0x01 - writer->Write((uint8_t)0); // 0x02 - writer->Write((uint8_t)0); // 0x03 - writer->Write((uint8_t)0); // 0x04 - writer->Write((uint8_t)0); // 0x05 - - writer->Write(cmdSound->nightTimeSFX); // 0x06 - writer->Write(cmdSound->musicSequence); // 0x07 - } - break; - case RoomCommand::SetSkyboxSettings: - { - SetSkyboxSettings* cmdSkybox = (SetSkyboxSettings*)cmd; - - writer->Write((uint8_t)cmdSkybox->unk1); // 0x01 - writer->Write((uint8_t)0); // 0x02 - writer->Write((uint8_t)0); // 0x03 - writer->Write((uint8_t)cmdSkybox->skyboxNumber); // 0x04 - writer->Write((uint8_t)cmdSkybox->cloudsType); // 0x05 - writer->Write((uint8_t)cmdSkybox->isIndoors); // 0x06 - } - break; - case RoomCommand::SetRoomBehavior: - { - SetRoomBehavior* cmdRoom = (SetRoomBehavior*)cmd; - - writer->Write((uint8_t)cmdRoom->gameplayFlags); // 0x01 - writer->Write((uint8_t)0); // 0x02 - writer->Write((uint8_t)0); // 0x03 - writer->Write(cmdRoom->gameplayFlags2); // 0x04 - } - break; - case RoomCommand::SetCsCamera: - { - SetCsCamera* cmdCsCam = (SetCsCamera*)cmd; - - writer->Write((uint8_t)cmdCsCam->cameras.size()); // 0x01 - writer->Write((uint8_t)0); // 0x02 - writer->Write((uint8_t)0); // 0x03 - - writer->Write(cmdCsCam->segmentOffset); // 0x04 - } - break; - case RoomCommand::SetMesh: - { - SetMesh* cmdMesh = (SetMesh*)cmd; - - int baseStreamEnd = writer->GetStream().get()->GetLength(); - - writer->Write((uint8_t)cmdMesh->data); // 0x01 - writer->Write((uint8_t)0); // 0x02 - writer->Write((uint8_t)0); // 0x03 - - writer->Write(baseStreamEnd); // 0x04 - - uint32_t oldOffset = writer->GetBaseAddress(); - writer->Seek(baseStreamEnd, SeekOffsetType::Start); - - // TODO: NOT DONE - - writer->Write(cmdMesh->meshHeaderType); - - if (cmdMesh->meshHeaderType == 0) - { - // writer->Write(cmdMesh->) - } - else if (cmdMesh->meshHeaderType == 1) - { - } - else if (cmdMesh->meshHeaderType == 2) - { - } - - writer->Seek(oldOffset, SeekOffsetType::Start); - } - break; - case RoomCommand::SetCameraSettings: - { - SetCameraSettings* cmdCam = (SetCameraSettings*)cmd; - - writer->Write((uint8_t)cmdCam->cameraMovement); // 0x01 - writer->Write((uint8_t)0); // 0x02 - writer->Write((uint8_t)0); // 0x03 - writer->Write(cmdCam->mapHighlight); // 0x04 - } - break; - case RoomCommand::SetLightingSettings: - { - SetLightingSettings* cmdLight = (SetLightingSettings*)cmd; - - writer->Write((uint8_t)cmdLight->settings.size()); // 0x01 - writer->Write((uint8_t)0); // 0x02 - writer->Write((uint8_t)0); // 0x03 - writer->Write(cmdLight->segmentOffset); // 0x04 - - uint32_t oldOffset = writer->GetBaseAddress(); - writer->Seek(cmdLight->segmentOffset, SeekOffsetType::Start); - - for (LightingSettings setting : cmdLight->settings) - { - writer->Write(setting.ambientClrR); - writer->Write(setting.ambientClrG); - writer->Write(setting.ambientClrB); - - writer->Write(setting.diffuseClrA_R); - writer->Write(setting.diffuseClrA_G); - writer->Write(setting.diffuseClrA_B); - - writer->Write(setting.diffuseDirA_X); - writer->Write(setting.diffuseDirA_Y); - writer->Write(setting.diffuseDirA_Z); - - writer->Write(setting.diffuseClrB_R); - writer->Write(setting.diffuseClrB_G); - writer->Write(setting.diffuseClrB_B); - - writer->Write(setting.diffuseDirB_X); - writer->Write(setting.diffuseDirB_Y); - writer->Write(setting.diffuseDirB_Z); - - writer->Write(setting.fogClrR); - writer->Write(setting.fogClrG); - writer->Write(setting.fogClrB); - - writer->Write(setting.unk); - writer->Write(setting.drawDistance); - } - - writer->Seek(oldOffset, SeekOffsetType::Start); - } - break; - case RoomCommand::SetRoomList: - { - SetRoomList* cmdRoom = (SetRoomList*)cmd; - - writer->Write((uint8_t)cmdRoom->romfile->rooms.size()); // 0x01 - writer->Write((uint8_t)0); // 0x02 - writer->Write((uint8_t)0); // 0x03 - - auto baseStreamEnd = writer->GetLength(); - writer->Write(baseStreamEnd); // 0x04 - - uint32_t oldOffset = writer->GetBaseAddress(); - writer->Seek(baseStreamEnd, SeekOffsetType::Start); - - for (const auto& entry : cmdRoom->romfile->rooms) - { - writer->Write(entry.virtualAddressStart); - writer->Write(entry.virtualAddressEnd); - } - - writer->Seek(oldOffset, SeekOffsetType::Start); - } - break; - case RoomCommand::SetCollisionHeader: - { - SetCollisionHeader* cmdCollHeader = (SetCollisionHeader*)cmd; - - int streamEnd = writer->GetStream().get()->GetLength(); - - writer->Write((uint8_t)0); // 0x01 - writer->Write((uint8_t)0); // 0x02 - writer->Write((uint8_t)0); // 0x03 - writer->Write(streamEnd); // 0x04 - - // TODO: NOT DONE - - uint32_t oldOffset = writer->GetBaseAddress(); - writer->Seek(streamEnd, SeekOffsetType::Start); - - ExporterExample_Collision colExp = ExporterExample_Collision(); - - colExp.Save(cmdCollHeader->collisionHeader, outPath, writer); - - writer->Seek(oldOffset, SeekOffsetType::Start); - } - break; - case RoomCommand::SetEntranceList: - { - SetEntranceList* cmdEntrance = (SetEntranceList*)cmd; - - uint32_t baseStreamEnd = writer->GetStream().get()->GetLength(); - - writer->Write((uint8_t)0); // 0x01 - writer->Write((uint8_t)0); // 0x02 - writer->Write((uint8_t)0); // 0x03 - writer->Write(baseStreamEnd); // 0x04 - - uint32_t oldOffset = writer->GetBaseAddress(); - writer->Seek(baseStreamEnd, SeekOffsetType::Start); - - for (EntranceEntry entry : cmdEntrance->entrances) - { - writer->Write((uint8_t)entry.startPositionIndex); - writer->Write((uint8_t)entry.roomToLoad); - } - - writer->Seek(oldOffset, SeekOffsetType::Start); - } - break; - case RoomCommand::SetSpecialObjects: - { - SetSpecialObjects* cmdSpecObj = (SetSpecialObjects*)cmd; - - writer->Write((uint8_t)cmdSpecObj->elfMessage); // 0x01 - writer->Write((uint8_t)0); // 0x02 - writer->Write((uint8_t)0); // 0x03 - writer->Write((uint8_t)0); // 0x04 - writer->Write((uint8_t)0); // 0x05 - writer->Write((uint16_t)cmdSpecObj->globalObject); // 0x06 - } - break; - case RoomCommand::SetStartPositionList: - { - SetStartPositionList* cmdStartPos = (SetStartPositionList*)cmd; - - uint32_t baseStreamEnd = writer->GetStream().get()->GetLength(); - - writer->Write((uint8_t)cmdStartPos->actors.size()); // 0x01 - writer->Write((uint8_t)0); // 0x02 - writer->Write((uint8_t)0); // 0x03 - writer->Write(baseStreamEnd); // 0x04 - - uint32_t oldOffset = writer->GetBaseAddress(); - writer->Seek(baseStreamEnd, SeekOffsetType::Start); - - for (ActorSpawnEntry entry : cmdStartPos->actors) - { - writer->Write(entry.actorNum); - writer->Write(entry.posX); - writer->Write(entry.posY); - writer->Write(entry.posZ); - writer->Write(entry.rotX); - writer->Write(entry.rotY); - writer->Write(entry.rotZ); - writer->Write(entry.params); - } - - writer->Seek(oldOffset, SeekOffsetType::Start); - } - break; - case RoomCommand::EndMarker: - { - writer->Write((uint8_t)0); // 0x01 - writer->Write((uint8_t)0); // 0x02 - writer->Write((uint8_t)0); // 0x03 - writer->Write((uint8_t)0); // 0x04 - writer->Write((uint8_t)0); // 0x05 - writer->Write((uint8_t)0); // 0x06 - writer->Write((uint8_t)0); // 0x07 - } - break; - default: - printf("UNIMPLEMENTED COMMAND: %i\n", (int)cmd->cmdID); - - writer->Write((uint8_t)0); // 0x01 - writer->Write((uint8_t)0); // 0x02 - writer->Write((uint8_t)0); // 0x03 - writer->Write((uint8_t)0); // 0x04 - writer->Write((uint8_t)0); // 0x05 - writer->Write((uint8_t)0); // 0x06 - writer->Write((uint8_t)0); // 0x07 - - break; - } - } - - // writer->Close(); - // DiskFile::WriteAllBytes(StringHelper::Sprintf("%s", res->GetName().c_str()), - // memStream->ToVector()); -} diff --git a/ZAPDTR/ExporterTest/RoomExporter.h b/ZAPDTR/ExporterTest/RoomExporter.h deleted file mode 100644 index d8f7eae01..000000000 --- a/ZAPDTR/ExporterTest/RoomExporter.h +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once - -#include "ZResource.h" -#include "ZRoom/ZRoom.h" - -class ExporterExample_Room : public ZResourceExporter -{ -public: - void Save(ZResource* res, const fs::path& outPath, BinaryWriter* writer) override; -}; \ No newline at end of file diff --git a/ZAPDTR/ExporterTest/TextureExporter.cpp b/ZAPDTR/ExporterTest/TextureExporter.cpp deleted file mode 100644 index 58d0964d3..000000000 --- a/ZAPDTR/ExporterTest/TextureExporter.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "TextureExporter.h" -#include "../ZAPD/ZFile.h" - -void ExporterExample_Texture::Save(ZResource* res, [[maybe_unused]] const fs::path& outPath, - BinaryWriter* writer) -{ - ZTexture* tex = (ZTexture*)res; - - auto data = tex->parent->GetRawData(); - - for (offset_t i = tex->GetRawDataIndex(); i < tex->GetRawDataIndex() + tex->GetRawDataSize(); - i++) - writer->Write(data[i]); -} diff --git a/ZAPDTR/ExporterTest/TextureExporter.h b/ZAPDTR/ExporterTest/TextureExporter.h deleted file mode 100644 index f3922cac1..000000000 --- a/ZAPDTR/ExporterTest/TextureExporter.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -#include "Utils/BinaryWriter.h" -#include "ZResource.h" -#include "ZTexture.h" - -class ExporterExample_Texture : public ZResourceExporter -{ -public: - void Save(ZResource* res, const fs::path& outPath, BinaryWriter* writer) override; -}; \ No newline at end of file diff --git a/ZAPDTR/LICENSE b/ZAPDTR/LICENSE deleted file mode 100644 index 90b734bde..000000000 --- a/ZAPDTR/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2020 Zelda Reverse Engineering Team - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/ZAPDTR/Makefile b/ZAPDTR/Makefile deleted file mode 100644 index e725f94f8..000000000 --- a/ZAPDTR/Makefile +++ /dev/null @@ -1,134 +0,0 @@ -# use variables in submakes -export -OPTIMIZATION_ON ?= 1 -ASAN ?= 0 -DEPRECATION_ON ?= 1 -DEBUG ?= 0 -COPYCHECK_ARGS ?= -LLD ?= 0 -WERROR ?= 0 - -# Use clang++ if available, else use g++ -ifeq ($(shell command -v clang++ >/dev/null 2>&1; echo $$?),0) - CXX := clang++ -else - CXX := g++ -endif - -INC := -I ZAPD -I lib/libgfxd -I lib/tinyxml2 -I ZAPDUtils -CXXFLAGS := -fpic -std=c++17 -Wall -Wextra -fno-omit-frame-pointer -OPTFLAGS := - -ifneq ($(DEBUG),0) - OPTIMIZATION_ON = 0 - CXXFLAGS += -g3 -DDEVELOPMENT -D_DEBUG - COPYCHECK_ARGS += --devel - DEPRECATION_ON = 0 -endif - -ifneq ($(WERROR),0) - CXXFLAGS += -Werror -endif - -ifeq ($(OPTIMIZATION_ON),0) - OPTFLAGS := -O0 -else - OPTFLAGS := -O2 -endif - -ifneq ($(ASAN),0) - CXXFLAGS += -fsanitize=address -fsanitize=pointer-compare -fsanitize=pointer-subtract -fsanitize=undefined -endif -ifneq ($(DEPRECATION_ON),0) - CXXFLAGS += -DDEPRECATION_ON -endif -# CXXFLAGS += -DTEXTURE_DEBUG - -LDFLAGS := -lm -ldl -lpng - -# Use LLD if available. Set LLD=0 to not use it -ifeq ($(shell command -v ld.lld >/dev/null 2>&1; echo $$?),0) - LLD := 1 -endif - -ifneq ($(LLD),0) - LDFLAGS += -fuse-ld=lld -endif - -UNAME := $(shell uname) -UNAMEM := $(shell uname -m) -ifneq ($(UNAME), Darwin) - LDFLAGS += -Wl,-export-dynamic -lstdc++fs - EXPORTERS := -Wl,--whole-archive ExporterTest/ExporterTest.a -Wl,--no-whole-archive -else - EXPORTERS := -Wl,-force_load ExporterTest/ExporterTest.a - ifeq ($(UNAMEM),arm64) - ifeq ($(shell brew list libpng > /dev/null 2>&1; echo $$?),0) - LDFLAGS += -L $(shell brew --prefix)/lib - INC += -I $(shell brew --prefix)/include - else - $(error Please install libpng via Homebrew) - endif - endif -endif - - -ZAPD_SRC_DIRS := $(shell find ZAPD -type d) -SRC_DIRS = $(ZAPD_SRC_DIRS) lib/tinyxml2 - -ZAPD_CPP_FILES := $(foreach dir,$(ZAPD_SRC_DIRS),$(wildcard $(dir)/*.cpp)) -ZAPD_H_FILES := $(foreach dir,$(ZAPD_SRC_DIRS),$(wildcard $(dir)/*.h)) - -CPP_FILES += $(ZAPD_CPP_FILES) lib/tinyxml2/tinyxml2.cpp -O_FILES := $(foreach f,$(CPP_FILES:.cpp=.o),build/$f) -O_FILES += build/ZAPD/BuildInfo.o - -# create build directories -$(shell mkdir -p $(foreach dir,$(SRC_DIRS),build/$(dir))) - - -# Main targets -all: ZAPD.out copycheck - -build/ZAPD/BuildInfo.o: - python3 ZAPD/genbuildinfo.py $(COPYCHECK_ARGS) - $(CXX) $(CXXFLAGS) $(OPTFLAGS) $(INC) -c $(OUTPUT_OPTION) build/ZAPD/BuildInfo.cpp - -copycheck: ZAPD.out - python3 copycheck.py - -clean: - rm -rf build ZAPD.out - $(MAKE) -C lib/libgfxd clean - $(MAKE) -C ZAPDUtils clean - $(MAKE) -C ExporterTest clean - -rebuild: clean all - -format: - clang-format-11 -i $(ZAPD_CPP_FILES) $(ZAPD_H_FILES) - $(MAKE) -C ZAPDUtils format - $(MAKE) -C ExporterTest format - -.PHONY: all build/ZAPD/BuildInfo.o copycheck clean rebuild format - -build/%.o: %.cpp - $(CXX) $(CXXFLAGS) $(OPTFLAGS) $(INC) -c $(OUTPUT_OPTION) $< - - -# Submakes -lib/libgfxd/libgfxd.a: - $(MAKE) -C lib/libgfxd - -.PHONY: ExporterTest -ExporterTest: - $(MAKE) -C ExporterTest - -.PHONY: ZAPDUtils -ZAPDUtils: - $(MAKE) -C ZAPDUtils - - -# Linking -ZAPD.out: $(O_FILES) lib/libgfxd/libgfxd.a ExporterTest ZAPDUtils - $(CXX) $(CXXFLAGS) $(O_FILES) lib/libgfxd/libgfxd.a ZAPDUtils/ZAPDUtils.a $(EXPORTERS) $(LDFLAGS) $(OUTPUT_OPTION) diff --git a/ZAPDTR/README.md b/ZAPDTR/README.md deleted file mode 100644 index bb96bab1b..000000000 --- a/ZAPDTR/README.md +++ /dev/null @@ -1,163 +0,0 @@ -# ZAPD: Zelda Asset Processor for Decomp - -## Compiling - -### Dependencies - -ZAPD needs a compiler with C++17 support. - -ZAPD has the following library dependencies: - -- `libpng` - -In a Debian/Ubuntu based environment, those could be installed with the following command: - -```bash -sudo apt install libpng-dev -``` - -On a Mac, you will need to install libpng with Homebrew or MacPorts; we currently only support Homebrew. You can run - -```bash -brew install libpng -``` - -to install it via Homebrew. - -### Building - -#### Linux / *nix - -ZAPD uses the clasic `Makefile` approach. To build just run `make` (or even better `make -j` for faster compilations). - -You can configure a bit your ZAPD build with the following options: - -- `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_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_ON=0`: Disables deprecation warnings. -- `LLD=1`: builds with the LLVM linker `ld.lld` instead of the system default. - -As an example, if you want to build ZAPD with optimizations disabled and use the address sanitizer, you could use the following command: - -```bash -make -j OPTIMIZATION_ON=0 ASAN=1 -``` - -#### Windows - -This repository contains `vcxproj` files for compiling under Visual Studio environments. See `ZAPD/ZAPD.vcxproj`. - -## Invoking ZAPD - -ZAPD needs a _File parsing mode_ to be passed as first parameter. The options are: - -- `e`: "Extraction" mode. - - In this mode, ZAPD expects a XML file as input, a folder as ouput and a path to the baserom files. - - ZAPD will read the XML and use it as a guide to extract the contents of the specified asset file from the baserom folder. - - For more info of the format of those XMLs, see the [ZAPD extraction XML reference](docs/zapd_extraction_xml_reference.md). -- `bsf`: "Build source file" mode. - - This is an experimental mode. - - It was going to be used to let you have XMLs that aren't just for extraction. Might get used, might not. Still need to experiment on that. -- `btex`: "Build texture" mode. - - In this mode, ZAPD expects a PNG file as input, a filename as ouput and a texture type parameter (`-tt`). - - ZAPD will try to convert the given PNG into the contents of a `uint64_t` C array. -- `bren`: "Build (render) background" mode. - - In this mode, ZAPD expects a JPG file as input and a filename as ouput. - - ZAPD will try to convert the given JPG into the contents of a `uint64_t` C array. -- `blb`: "Build blob" mode. - - In this mode, ZAPD expects a BIN file as input and a filename as ouput. - - ZAPD will try to convert the given BIN into the contents of a `uint8_t` C array. - -ZAPD also accepts the following list of extra parameters: - -- `-i PATH` / `--inputpath PATH`: Set input path. -- `-o PATH` / `--outputpath PATH`: Set output path. -- `-b PATH` / `--baserompath`: Set baserom path. - - Can be used only in `e` or `bsf` modes. -- `-osf PATH`: Set source output path. This is the path where the `.c` and `.h` files will be extracted to. If omitted, it will use the value passed to `--outputpath` parameter. -- `-gsf MODE`: Generate source file during extraction. If `MODE` is `1`, C source files will be generated. - - Can be used only in `e` mode. -- `-crc` / `--output-crc`: Outputs a CRC file for each extracted texture. - - Can be used only in `e` or `bsf` modes. -- `-ulzdl MODE`: Use "Legacy ZDisplayList" instead of `libgfxd`. Set `MODE` to `1` to enable it. - - Can be used only in `e` or `bsf` modes. -- `-profile MODE`: Enable profiling. Set `MODE` to `1` to enable it. -- `-uer MODE`: Split resources into their individual components (enabled by default). Set `MODE` to non-`1` to disable it. -- `-tt TYPE`: Set texture type. - - Can be used only in mode `btex`. - - Valid values: - - `rgba32` - - `rgb5a1` - - `i4` - - `i8` - - `ia4` - - `ia8` - - `ia16` - - `ci4` - - `ci8` -- `-rconf PATH` Read Config File. -- `-eh`: Enable error handler. - - Only available in non-Windows environments. -- `-v MODE`: Enable verbosity. Currently there are 3 possible values: - - `0`: Default. Completely silent (except for warnings and errors). - - `1`: Information. - - `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`. -- `-se` / `--set-exporter` : Sets which exporter to use. -- `--gcc-compat` : Enables GCC compatibly mode. Slower. -- `-us` / `--unaccounted-static` : Mark unaccounted data as `static` -- `-s` / `--static` : Mark every asset as `static`. - - This behaviour can be overridden per asset using `Static=` in the respective XML node. -- `-W...`: warning flags, see below - -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. - -### Warning flags - -ZAPD contains a variety of warning types, with similar syntax to GCC or Clang's compiler warnings. Warnings can have three levels: - -- Off (does not display anything) -- Warn (print a warning but continue processing) -- Err (behave like an error, i.e. print and throw an exception to crash ZAPD when occurs) - -Each warning type uses one of these by default, but can be modified with flags, similarly to GCC or Clang: - -- `-Wfoo` enables warnings of type `foo` -- `-Wno-foo` disables warnings of type `foo` -- `-Werror=foo` escalates `foo` to behave like an error -- `-Weverything` enables all warnings (they may be turned off using `-Wno-` flags afterwards) -- `-Werror` escalates all enabled warnings to errors - -All warning types currently implemented, with their default levels: - -| Warning type | Default level | Description | -| --------------------------- | ------------- | ------------------------------------------------------------------------ | -| `-Wdeprecated` | Warn | Deprecated features | -| `-Whardcoded-pointer` | Warn | ZAPD lacks the info to make a symbol, so must output a hardcoded pointer | -| `-Wintersection` | Warn | Two assets intersect | -| `-Winvalid-attribute-value` | Err | Attribute declared in XML is wrong | -| `-Winvalid-extracted-data` | Err | Extracted data does not have correct form | -| `-Winvalid-jpeg` | Err | JPEG file does not conform to the game's format requirements | -| `-Winvalid-png` | Err | Issues arising when processing PNG data | -| `-Winvalid-xml` | Err | XML has syntax errors | -| `-Wmissing-attribute` | Warn | Required attribute missing in XML tag | -| `-Wmissing-offsets` | Warn | Offset attribute missing in XML tag | -| `-Wmissing-segment` | Warn | Segment not given in File tag in XML | -| `-Wnot-implemented` | Warn | ZAPD does not currently support this feature | -| `-Wunaccounted` | Off | Large blocks of unaccounted | -| `-Wunknown-attribute` | Warn | Unknown attribute in XML entry tag | - -There are also errors that do not have a type, and cannot be disabled. - -For example, here we have invoked ZAPD in the usual way to extract using a (rather badly-written) XML, but escalating `-Wintersection` to an error: - -![ZAPD warnings example](docs/zapd_warning_example.png?raw=true) diff --git a/ZAPDTR/ZAPD/CMakeLists.txt b/ZAPDTR/ZAPD/CMakeLists.txt deleted file mode 100644 index 96c42d00c..000000000 --- a/ZAPDTR/ZAPD/CMakeLists.txt +++ /dev/null @@ -1,497 +0,0 @@ -set(PROJECT_NAME ZAPDLib) - -set(CMAKE_CXX_STANDARD 20 CACHE STRING "The C++ standard to use") -#set(CMAKE_C_STANDARD 11 CACHE STRING "The C standard to use") -set(CMAKE_C_STANDARD 11) - -################################################################################ -# Source groups -################################################################################ -set(Header_Files - "../lib/tinyxml2/tinyxml2.h" - "CRC32.h" - "Declaration.h" - "FileWorker.h" - "GameConfig.h" - "Globals.h" - "ImageBackend.h" - "OutputFormatter.h" - "WarningHandler.h" - "CrashHandler.h" -) -source_group("Header Files" FILES ${Header_Files}) - -set(Header_Files__Libraries - "../../libultraship/extern/stb/stb_image.h" - "../../libultraship/extern/stb/stb_image_write.h" - "ctpl_stl.h" -) -source_group("Header Files\\Libraries" FILES ${Header_Files__Libraries}) - -set(Header_Files__Libraries__libgfxd - "../lib/libgfxd/gbi.h" - "../lib/libgfxd/gfxd.h" - "../lib/libgfxd/priv.h" -) -source_group("Header Files\\Libraries\\libgfxd" FILES ${Header_Files__Libraries__libgfxd}) - -set(Header_Files__Yaz0 - "yaz0/readwrite.h" - "yaz0/yaz0.h" -) -source_group("Header Files\\Yaz0" FILES ${Header_Files__Yaz0}) - -set(Header_Files__Z64 - "OtherStructs/SkinLimbStructs.h" - "OtherStructs/CutsceneMM_Commands.h" - "OtherStructs/Cutscene_Commands.h" - "ZAnimation.h" - "ZActorList.h" - "ZArray.h" - "ZAudio.h" - "ZBackground.h" - "ZBlob.h" - "ZCollision.h" - "ZCollisionPoly.h" - "ZCutscene.h" - "ZDisplayList.h" - "ZFile.h" - "ZLimb.h" - "ZMtx.h" - "ZPath.h" - "ZPlayerAnimationData.h" - "ZResource.h" - "ZRom.h" - "ZScalar.h" - "ZSkeleton.h" - "ZSurfaceType.h" - "ZString.h" - "ZSymbol.h" - "ZText.h" - "ZTexture.h" - "ZTextureAnimation.h" - "ZVector.h" - "ZVtx.h" -) -source_group("Header Files\\Z64" FILES ${Header_Files__Z64}) - -set(Header_Files__Z64__ZRoom - "ZRoom/ZRoom.h" - "ZRoom/ZRoomCommand.h" -) -source_group("Header Files\\Z64\\ZRoom" FILES ${Header_Files__Z64__ZRoom}) - -set(Header_Files__Z64__ZRoom__Commands - "ZRoom/Commands/EndMarker.h" - "ZRoom/Commands/SetActorCutsceneList.h" - "ZRoom/Commands/SetActorList.h" - "ZRoom/Commands/SetAlternateHeaders.h" - "ZRoom/Commands/SetAnimatedMaterialList.h" - "ZRoom/Commands/SetCameraSettings.h" - "ZRoom/Commands/SetCollisionHeader.h" - "ZRoom/Commands/SetCsCamera.h" - "ZRoom/Commands/SetCutscenes.h" - "ZRoom/Commands/SetEchoSettings.h" - "ZRoom/Commands/SetEntranceList.h" - "ZRoom/Commands/SetExitList.h" - "ZRoom/Commands/SetLightingSettings.h" - "ZRoom/Commands/SetLightList.h" - "ZRoom/Commands/SetMesh.h" - "ZRoom/Commands/SetMinimapChests.h" - "ZRoom/Commands/SetMinimapList.h" - "ZRoom/Commands/SetObjectList.h" - "ZRoom/Commands/SetPathways.h" - "ZRoom/Commands/SetRoomBehavior.h" - "ZRoom/Commands/SetRoomList.h" - "ZRoom/Commands/SetSkyboxModifier.h" - "ZRoom/Commands/SetSkyboxSettings.h" - "ZRoom/Commands/SetSoundSettings.h" - "ZRoom/Commands/SetSpecialObjects.h" - "ZRoom/Commands/SetStartPositionList.h" - "ZRoom/Commands/SetTimeSettings.h" - "ZRoom/Commands/SetTransitionActorList.h" - "ZRoom/Commands/SetWind.h" - "ZRoom/Commands/SetWorldMapVisited.h" - "ZRoom/Commands/Unused09.h" - "ZRoom/Commands/Unused1D.h" - "ZRoom/Commands/ZRoomCommandUnk.h" -) -source_group("Header Files\\Z64\\ZRoom\\Commands" FILES ${Header_Files__Z64__ZRoom__Commands}) - -set(Resource_Files - "../../OTRExporter/CFG/SymbolMap_OoTMqDbg.txt" -) -source_group("Resource Files" FILES ${Resource_Files}) - -set(Source_Files - "CrashHandler.cpp" - "Declaration.cpp" - "FileWorker.cpp" - "GameConfig.cpp" - "Globals.cpp" - "ImageBackend.cpp" - "Main.cpp" - "OutputFormatter.cpp" - "WarningHandler.cpp" -) -source_group("Source Files" FILES ${Source_Files}) - -set(Source_Files__Libraries__libgfxd - "../lib/libgfxd/gfxd.c" - "../lib/libgfxd/uc.c" - "../lib/libgfxd/uc_f3d.c" - "../lib/libgfxd/uc_f3db.c" - "../lib/libgfxd/uc_f3dex.c" - "../lib/libgfxd/uc_f3dex2.c" - "../lib/libgfxd/uc_f3dexb.c" -) -source_group("Source Files\\Libraries\\libgfxd" FILES ${Source_Files__Libraries__libgfxd}) - -set(Source_Files__Yaz0 - "yaz0/yaz0.cpp" -) -source_group("Source Files\\Yaz0" FILES ${Source_Files__Yaz0}) - -set(Source_Files__Z64 - "OtherStructs/SkinLimbStructs.cpp" - "OtherStructs/CutsceneMM_Commands.cpp" - "OtherStructs/Cutscene_Commands.cpp" - "ZAnimation.cpp" - "ZActorList.cpp" - "ZArray.cpp" - "ZAudio.cpp" - "ZAudioDecode.cpp" - "ZBackground.cpp" - "ZBlob.cpp" - "ZCollision.cpp" - "ZCollisionPoly.cpp" - "ZCutscene.cpp" - "ZDisplayList.cpp" - "ZFile.cpp" - "ZLimb.cpp" - "ZMtx.cpp" - "ZPath.cpp" - "ZPlayerAnimationData.cpp" - "ZResource.cpp" - "ZRom.cpp" - "ZScalar.cpp" - "ZSkeleton.cpp" - "ZSurfaceType.cpp" - "ZString.cpp" - "ZSymbol.cpp" - "ZText.cpp" - "ZTexture.cpp" - "ZTextureAnimation.cpp" - "ZVector.cpp" - "ZVtx.cpp" -) -source_group("Source Files\\Z64" FILES ${Source_Files__Z64}) - -set(Source_Files__Z64__ZRoom - "ZRoom/ZRoom.cpp" - "ZRoom/ZRoomCommand.cpp" -) -source_group("Source Files\\Z64\\ZRoom" FILES ${Source_Files__Z64__ZRoom}) - -set(Source_Files__Z64__ZRoom__Commands - "ZRoom/Commands/EndMarker.cpp" - "ZRoom/Commands/SetActorCutsceneList.cpp" - "ZRoom/Commands/SetActorList.cpp" - "ZRoom/Commands/SetAlternateHeaders.cpp" - "ZRoom/Commands/SetAnimatedMaterialList.cpp" - "ZRoom/Commands/SetCameraSettings.cpp" - "ZRoom/Commands/SetCollisionHeader.cpp" - "ZRoom/Commands/SetCsCamera.cpp" - "ZRoom/Commands/SetCutscenes.cpp" - "ZRoom/Commands/SetEchoSettings.cpp" - "ZRoom/Commands/SetEntranceList.cpp" - "ZRoom/Commands/SetExitList.cpp" - "ZRoom/Commands/SetLightingSettings.cpp" - "ZRoom/Commands/SetLightList.cpp" - "ZRoom/Commands/SetMesh.cpp" - "ZRoom/Commands/SetMinimapChests.cpp" - "ZRoom/Commands/SetMinimapList.cpp" - "ZRoom/Commands/SetObjectList.cpp" - "ZRoom/Commands/SetPathways.cpp" - "ZRoom/Commands/SetRoomBehavior.cpp" - "ZRoom/Commands/SetRoomList.cpp" - "ZRoom/Commands/SetSkyboxModifier.cpp" - "ZRoom/Commands/SetSkyboxSettings.cpp" - "ZRoom/Commands/SetSoundSettings.cpp" - "ZRoom/Commands/SetSpecialObjects.cpp" - "ZRoom/Commands/SetStartPositionList.cpp" - "ZRoom/Commands/SetTimeSettings.cpp" - "ZRoom/Commands/SetTransitionActorList.cpp" - "ZRoom/Commands/SetWind.cpp" - "ZRoom/Commands/SetWorldMapVisited.cpp" - "ZRoom/Commands/Unused09.cpp" - "ZRoom/Commands/Unused1D.cpp" - "ZRoom/Commands/ZRoomCommandUnk.cpp" -) -source_group("Source Files\\Z64\\ZRoom\\Commands" FILES ${Source_Files__Z64__ZRoom__Commands}) - -set(ALL_FILES - ${Header_Files} - ${Header_Files__Libraries} - ${Header_Files__Libraries__libgfxd} - ${Header_Files__Yaz0} - ${Header_Files__Z64} - ${Header_Files__Z64__ZRoom} - ${Header_Files__Z64__ZRoom__Commands} - ${Resource_Files} - ${Source_Files} - ${Source_Files__Libraries__libgfxd} - ${Source_Files__Yaz0} - ${Source_Files__Z64} - ${Source_Files__Z64__ZRoom} - ${Source_Files__Z64__ZRoom__Commands} - ${any__any} -) - -################################################################################ -# Target -################################################################################ - -add_library(${PROJECT_NAME} STATIC ${ALL_FILES}) - -add_executable(ZAPD ExecutableMain.cpp) -target_link_libraries(ZAPD ${PROJECT_NAME}) - - - -if (CMAKE_SYSTEM_NAME STREQUAL "Windows") -use_props(${PROJECT_NAME} "${CMAKE_CONFIGURATION_TYPES}" "${DEFAULT_CXX_PROPS}") -use_props(ZAPD "${CMAKE_CONFIGURATION_TYPES}" "${DEFAULT_CXX_PROPS}") -endif() -################################################################################ -# Includes for CMake from *.props -################################################################################ - -set(ROOT_NAMESPACE ZAPD) - -if (CMAKE_SYSTEM_NAME STREQUAL "Windows") - if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64") - set_target_properties(${PROJECT_NAME} PROPERTIES - INTERPROCEDURAL_OPTIMIZATION_RELEASE "TRUE" - ) - elseif("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x86") - set_target_properties(${PROJECT_NAME} PROPERTIES - INTERPROCEDURAL_OPTIMIZATION_RELEASE "TRUE" - ) - endif() -elseif (CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin") - set_target_properties(ZAPD PROPERTIES - OUTPUT_NAME "ZAPD.out" - ) -endif() -################################################################################ -# MSVC runtime library -################################################################################ -if (CMAKE_SYSTEM_NAME STREQUAL "Windows") -foreach(ZTarget ${PROJECT_NAME} ZAPD) - get_property(MSVC_RUNTIME_LIBRARY_DEFAULT TARGET ${ZTarget} PROPERTY MSVC_RUNTIME_LIBRARY) - if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64") - string(CONCAT "MSVC_RUNTIME_LIBRARY_STR" - $<$: - MultiThreadedDebug - > - $<$: - MultiThreaded - > - $<$,$>>:${MSVC_RUNTIME_LIBRARY_DEFAULT}> - ) - endif() - set_target_properties(${ZTarget} PROPERTIES MSVC_RUNTIME_LIBRARY ${MSVC_RUNTIME_LIBRARY_STR}) -endforeach() -endif() -################################################################################ -# Compile definitions -################################################################################ -if (CMAKE_SYSTEM_NAME STREQUAL "Windows") - if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64") - target_compile_definitions(${PROJECT_NAME} PRIVATE - "_CRT_SECURE_NO_WARNINGS;" - "_MBCS" - STORMLIB_NO_AUTO_LINK - ) - elseif("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x86") - target_compile_definitions(${PROJECT_NAME} PRIVATE - "$<$:" - "_CRT_SECURE_NO_WARNINGS" - ">" - "_MBCS" - STORMLIB_NO_AUTO_LINK - ) - endif() -endif() - -################################################################################ -# Compile and link options -################################################################################ - -if (CMAKE_SYSTEM_NAME STREQUAL "Darwin") - set(CMAKE_FIND_FRAMEWORK LAST) -endif() -find_package(PNG REQUIRED) - -target_include_directories(${PROJECT_NAME} PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/../../libultraship/extern/ZAPDUtils - ${CMAKE_CURRENT_SOURCE_DIR}/../../libultraship/src/resource - ${CMAKE_CURRENT_SOURCE_DIR}/../../libultraship/include - ${CMAKE_CURRENT_SOURCE_DIR}/../../ZAPDTR/lib/tinyxml2 - ${CMAKE_CURRENT_SOURCE_DIR}/../../ZAPDTR/lib/libgfxd - ${PNG_PNG_INCLUDE_DIR}/ - . - ) - -if(MSVC) - if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64") - target_compile_options(${PROJECT_NAME} PRIVATE - $<$: - /Od; - /RTC1 - > - $<$: - /Oi; - /Gy - > - /permissive-; - /sdl; - /W3; - ${DEFAULT_CXX_DEBUG_INFORMATION_FORMAT}; - ${DEFAULT_CXX_EXCEPTION_HANDLING} - ) - elseif("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x86") - target_compile_options(${PROJECT_NAME} PRIVATE - $<$: - /Od - > - $<$: - /O2; - /Oi; - /Gy - > - /permissive-; - /sdl; - /W3; - ${DEFAULT_CXX_DEBUG_INFORMATION_FORMAT}; - ${DEFAULT_CXX_EXCEPTION_HANDLING} - ) - endif() - if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64") - target_link_options(${PROJECT_NAME} PRIVATE - $<$: - /PROFILE - > - $<$: - /OPT:REF; - /OPT:ICF - > - /DEBUG:FULL - ) - elseif("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x86") - target_link_options(${PROJECT_NAME} PRIVATE - $<$: - /PROFILE - > - $<$: - /OPT:REF; - /OPT:ICF - > - /DEBUG:FULL - ) - endif() -endif() - -if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU|Clang|AppleClang") - target_compile_options(${PROJECT_NAME} PUBLIC - -Wall -Wextra -Wno-error - -Wno-unused-parameter - -Wno-unused-function - -Wno-unused-variable - -Wno-missing-field-initializers - -Wno-parentheses - -Wno-narrowing - $<$:-Wno-deprecated-enum-enum-conversion> - -pthread - ) - - if (CMAKE_SYSTEM_NAME STREQUAL "Darwin") - target_link_options(${PROJECT_NAME} PUBLIC - -pthread - ) - else() - target_link_options(${PROJECT_NAME} PUBLIC - -pthread - -Wl,-export-dynamic - ) - endif() - -endif() - -################################################################################ -# Dependencies -################################################################################ -add_dependencies(${PROJECT_NAME} - OTRExporter - ZAPDUtils - libultraship -) - -if (CMAKE_SYSTEM_NAME STREQUAL "Windows") - if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64") - set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) - set(ADDITIONAL_LIBRARY_DEPENDENCIES - "ZAPDUtils;" - "-WHOLEARCHIVE:$/$" - "libultraship;" - storm - PNG::PNG - ) - endif() -elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin") - set(THREADS_PREFER_PTHREAD_FLAG ON) - find_package(Threads REQUIRED) - set(ADDITIONAL_LIBRARY_DEPENDENCIES - "ZAPDUtils;" - -Wl,-force_load $/$ - "libultraship;" - PNG::PNG - ${CMAKE_DL_LIBS} - Threads::Threads - ) -elseif(CMAKE_SYSTEM_NAME STREQUAL "NintendoSwitch") - set(THREADS_PREFER_PTHREAD_FLAG ON) - find_package(Threads REQUIRED) - set(ADDITIONAL_LIBRARY_DEPENDENCIES - "ZAPDUtils;" - -Wl,--whole-archive $/$ -Wl,--no-whole-archive - "libultraship;" - PNG::PNG - Threads::Threads - ) -elseif(CMAKE_SYSTEM_NAME STREQUAL "CafeOS") - set(ADDITIONAL_LIBRARY_DEPENDENCIES - "ZAPDUtils;" - "libultraship;" - PNG::PNG - ) -else() - set(THREADS_PREFER_PTHREAD_FLAG ON) - find_package(Threads REQUIRED) - set(ADDITIONAL_LIBRARY_DEPENDENCIES - "ZAPDUtils;" - -Wl,--whole-archive $/$ -Wl,--no-whole-archive - "libultraship;" - PNG::PNG - ${CMAKE_DL_LIBS} - Threads::Threads - ) -endif() - -if(CMAKE_SYSTEM_NAME MATCHES "NintendoSwitch|CafeOS") -add_library(pathconf OBJECT pathconf.c) -target_link_libraries(${PROJECT_NAME} PUBLIC "${ADDITIONAL_LIBRARY_DEPENDENCIES}" $ ) -else() -target_link_libraries(${PROJECT_NAME} PUBLIC "${ADDITIONAL_LIBRARY_DEPENDENCIES}") -endif() diff --git a/ZAPDTR/ZAPD/CRC32.h b/ZAPDTR/ZAPD/CRC32.h deleted file mode 100644 index 1f82c75c5..000000000 --- a/ZAPDTR/ZAPD/CRC32.h +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once - -static uint32_t CRC32B(const unsigned char* message, int32_t size) -{ - int32_t byte, crc; - int32_t mask; - - crc = 0xFFFFFFFF; - - for (int32_t i = 0; i < size; i++) - { - byte = message[i]; - crc = crc ^ byte; - - for (int32_t j = 7; j >= 0; j--) - { - mask = -(crc & 1); - crc = (crc >> 1) ^ (0xEDB88320 & mask); - } - } - - return ~(uint32_t)(crc); -} \ No newline at end of file diff --git a/ZAPDTR/ZAPD/CrashHandler.cpp b/ZAPDTR/ZAPD/CrashHandler.cpp deleted file mode 100644 index 356866536..000000000 --- a/ZAPDTR/ZAPD/CrashHandler.cpp +++ /dev/null @@ -1,205 +0,0 @@ -#include "CrashHandler.h" -#include "Utils/StringHelper.h" - -#if __has_include() -#define HAS_POSIX 1 -#else -#define HAS_POSIX 0 -#endif - -#include -#include -#include -#include - -#if HAS_POSIX == 1 -#include -#include // for __cxa_demangle -#include // for dladdr -#include -#include -#elif defined(_MSC_VER) -#include -#include - -#include - -#pragma comment(lib, "Dbghelp.lib") -#endif - -// Feel free to add more crash messages. -static std::array 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!", - "\tZAPD has fallen and cannot get up.", - "\tIT'S A SECRET TO EVERYBODY. \n\tBut it shouldn't be, you'd better ask about it!", - "\tI AM ERROR.", - "\tGRUMBLE,GRUMBLE...", - "\tDODONGO DISLIKES SMOKE \n\tAnd ZAPD dislikes whatever you fed it.", - "\tMay the way of the Hero lead \n\tto the debugger.", - "\tTHE WIND FISH SLUMBERS LONG... \n\tTHE HERO'S LIFE GONE... ", - "\tSEA BEARS FOAM, SLEEP BEARS DREAMS. \n\tBOTH END IN THE SAME WAY CRASSSH!", - "\tYou've met with a terrible fate, haven't you?", - "\tMaster, I calculate a 100% probability that ZAPD has crashed. \n\tAdditionally, the " - "batteries in your Wii Remote are nearly depleted.", - "\t CONGRATURATIONS! \n" - "\tAll Pages are displayed.\n" - "\t THANK YOU! \n" - "\t You are great debugger!", - "\tRCP is HUNG UP!!\n" - "\tOh! MY GOD!!", -}; - -#if HAS_POSIX == 1 -void ErrorHandler(int sig) -{ - std::array arr; - constexpr size_t nMaxFrames = arr.size(); - size_t size = backtrace(arr.data(), nMaxFrames); - char** symbols = backtrace_symbols(arr.data(), nMaxFrames); - - fprintf(stderr, "\nZAPD crashed. (Signal: %i)\n", sig); - - srand(time(nullptr)); - auto easterIndex = rand() % crashEasterEgg.size(); - - fprintf(stderr, "\n%s\n\n", crashEasterEgg[easterIndex]); - - fprintf(stderr, "Traceback:\n"); - for (size_t i = 1; i < size; i++) - { - Dl_info info; - uint32_t gotAddress = dladdr(arr[i], &info); - std::string functionName(symbols[i]); - - if (gotAddress != 0 && info.dli_sname != nullptr) - { - int32_t status; - char* demangled = abi::__cxa_demangle(info.dli_sname, nullptr, nullptr, &status); - const char* nameFound = info.dli_sname; - - if (status == 0) - { - nameFound = demangled; - } - - functionName = StringHelper::Sprintf("%s (+0x%X)", nameFound, - (char*)arr[i] - (char*)info.dli_saddr); - free(demangled); - } - - fprintf(stderr, "%-3zd %s\n", i, functionName.c_str()); - } - - fprintf(stderr, "\n"); - - free(symbols); - exit(1); -} -#elif defined(_MSC_VER) - -void printStack(CONTEXT* ctx) -{ - BOOL result; - HANDLE process; - HANDLE thread; - HMODULE hModule; - ULONG frame; - DWORD64 displacement; - DWORD disp; - - srand(time(nullptr)); - auto easterIndex = rand() % crashEasterEgg.size(); - - fprintf(stderr, "\n%s\n\n", crashEasterEgg[easterIndex]); - -#if defined(_M_AMD64) - STACKFRAME64 stack; - memset(&stack, 0, sizeof(STACKFRAME64)); -#else - STACKFRAME stack; - memset(&stack, 0, sizeof(STACKFRAME)); -#endif - - char buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME + sizeof(TCHAR)]; - char module[512]; - - PSYMBOL_INFO symbol = (PSYMBOL_INFO)buffer; - - CONTEXT ctx2; - memcpy(&ctx2, ctx, sizeof(CONTEXT)); - - process = GetCurrentProcess(); - thread = GetCurrentThread(); - SymInitialize(process, nullptr, TRUE); - - constexpr DWORD machineType = -#if defined(_M_AMD64) - IMAGE_FILE_MACHINE_AMD64; -#else - IMAGE_FILE_MACHINE_I386; -#endif - - displacement = 0; - - for (frame = 0;; frame++) - { - result = StackWalk(machineType, process, thread, &stack, &ctx2, nullptr, - SymFunctionTableAccess, SymGetModuleBase, nullptr); - if (!result) - { - break; - } - symbol->SizeOfStruct = sizeof(SYMBOL_INFO); - symbol->MaxNameLen = MAX_SYM_NAME; - SymFromAddr(process, (ULONG64)stack.AddrPC.Offset, &displacement, symbol); -#if defined(_M_AMD64) - IMAGEHLP_LINE64 line; - line.SizeOfStruct = sizeof(IMAGEHLP_LINE64); -#else - IMAGEHLP_LINE line; - line.SizeOfStruct = sizeof(IMAGEHLP_LINE); -#endif - if (SymGetLineFromAddr(process, stack.AddrPC.Offset, &disp, &line)) - { - fprintf(stderr, "%u\t %s in %s: line: %lu: \n", frame, symbol->Name, line.FileName, - line.LineNumber); - } - - else - { - fprintf(stderr, "%u\tat % s\n", frame, symbol->Name); - hModule = nullptr; - GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | - GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, - (LPCTSTR)(stack.AddrPC.Offset), &hModule); - - if (hModule != nullptr) - { - GetModuleFileNameA(hModule, module, 512 - 1); - } - fprintf(stderr, "%u\tIn %s\n", frame, module); - } - } -} - -LONG seh_filter(_EXCEPTION_POINTERS* ex) -{ - fprintf(stderr, "EXCEPTION 0x%x occured\n", ex->ExceptionRecord->ExceptionCode); - printStack(ex->ContextRecord); - return EXCEPTION_EXECUTE_HANDLER; -} -#endif - -void CrashHandler_Init() -{ -#if HAS_POSIX == 1 - signal(SIGSEGV, ErrorHandler); - signal(SIGABRT, ErrorHandler); -#elif defined(_MSC_VER) - SetUnhandledExceptionFilter(seh_filter); -#else - HANDLE_WARNING(WarningType::Always, - "tried to set error handler, but this ZAPD build lacks support for one", ""); -#endif -} diff --git a/ZAPDTR/ZAPD/CrashHandler.h b/ZAPDTR/ZAPD/CrashHandler.h deleted file mode 100644 index 102778bec..000000000 --- a/ZAPDTR/ZAPD/CrashHandler.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef CRASH_HANDLER_H -#define CRASH_HANDLER_H - -void CrashHandler_Init(); - -#endif diff --git a/ZAPDTR/ZAPD/Declaration.cpp b/ZAPDTR/ZAPD/Declaration.cpp deleted file mode 100644 index 3f0c0ad93..000000000 --- a/ZAPDTR/ZAPD/Declaration.cpp +++ /dev/null @@ -1,236 +0,0 @@ -#include "Declaration.h" - -#include "Globals.h" -#include "ZVtx.h" -#include "Utils/StringHelper.h" - -Declaration::Declaration(offset_t nAddress, DeclarationAlignment nAlignment, size_t nSize, - const std::string& nText) -{ - address = nAddress; - alignment = nAlignment; - size = nSize; - text = nText; -} - -Declaration::Declaration(offset_t nAddress, DeclarationAlignment nAlignment, size_t nSize, - const std::string& nVarType, const std::string& nVarName, bool nIsArray, - const std::string& nText) - : Declaration(nAddress, nAlignment, nSize, nText) -{ - varType = nVarType; - varName = nVarName; - isArray = nIsArray; -} - -Declaration::Declaration(offset_t nAddress, DeclarationAlignment nAlignment, size_t nSize, - const std::string& nVarType, const std::string& nVarName, bool nIsArray, - size_t nArrayItemCnt, const std::string& nText) - : Declaration(nAddress, nAlignment, nSize, nText) -{ - varType = nVarType; - varName = nVarName; - isArray = nIsArray; - arrayItemCnt = nArrayItemCnt; -} - -Declaration::Declaration(offset_t nAddress, DeclarationAlignment nAlignment, size_t nSize, - const std::string& nVarType, const std::string& nVarName, bool nIsArray, - const std::string& nArrayItemCntStr, const std::string& nText) - : Declaration(nAddress, nAlignment, nSize, nText) -{ - varType = nVarType; - varName = nVarName; - isArray = nIsArray; - arrayItemCntStr = nArrayItemCntStr; -} - -Declaration::Declaration(offset_t nAddress, DeclarationAlignment nAlignment, size_t nSize, - const std::string& nVarType, const std::string& nVarName, bool nIsArray, - size_t nArrayItemCnt, const std::string& nText, bool nIsExternal) - : Declaration(nAddress, nAlignment, nSize, nVarType, nVarName, nIsArray, nArrayItemCnt, nText) -{ - isExternal = nIsExternal; -} - -Declaration::Declaration(offset_t nAddress, const std::string& nIncludePath, size_t nSize, - const std::string& nVarType, const std::string& nVarName) - : Declaration(nAddress, DeclarationAlignment::Align4, nSize, "") -{ - includePath = nIncludePath; - varType = nVarType; - varName = nVarName; -} - -Declaration::~Declaration() -{ - //for (auto item : vertexHack) - //delete item; -} - -bool Declaration::IsStatic() const -{ - switch (staticConf) - { - case StaticConfig::Off: - return false; - - case StaticConfig::Global: - return Globals::Instance->forceStatic; - - case StaticConfig::On: - return true; - } - - return false; -} - -std::string Declaration::GetNormalDeclarationStr() const -{ - std::string output; - - if (preText != "") - output += preText + "\n"; - - if (IsStatic()) - { - output += "static "; - } - - if (isArray) - { - if (arrayItemCntStr != "" && (IsStatic() || forceArrayCnt)) - { - output += StringHelper::Sprintf("%s %s[%s];\n", varType.c_str(), varName.c_str(), - arrayItemCntStr.c_str()); - } - else if (arrayItemCnt != 0 && (IsStatic() || forceArrayCnt)) - { - output += StringHelper::Sprintf("%s %s[%i] = {\n", varType.c_str(), varName.c_str(), - arrayItemCnt); - } - else - { - output += StringHelper::Sprintf("%s %s[] = {\n", varType.c_str(), varName.c_str()); - } - - output += text + "\n"; - } - else - { - output += StringHelper::Sprintf("%s %s = { ", varType.c_str(), varName.c_str()); - output += text; - } - - if (output.back() == '\n') - output += "};"; - else - output += " };"; - - if (rightText != "") - output += " " + rightText + ""; - - output += "\n"; - - if (postText != "") - output += postText + "\n"; - - output += "\n"; - - return output; -} - -std::string Declaration::GetExternalDeclarationStr() const -{ - std::string output; - - if (preText != "") - output += preText + "\n"; - - if (IsStatic()) - { - output += "static "; - } - - if (arrayItemCntStr != "" && (IsStatic() || forceArrayCnt)) - output += StringHelper::Sprintf("%s %s[%s] = ", varType.c_str(), varName.c_str(), - arrayItemCntStr.c_str()); - else if (arrayItemCnt != 0 && (IsStatic() || forceArrayCnt)) - output += - StringHelper::Sprintf("%s %s[%i] = ", varType.c_str(), varName.c_str(), arrayItemCnt); - else - output += StringHelper::Sprintf("%s %s[] = ", varType.c_str(), varName.c_str()); - - output += StringHelper::Sprintf("{\n#include \"%s\"\n};", includePath.c_str()); - - if (rightText != "") - output += " " + rightText + ""; - - output += "\n"; - - if (postText != "") - output += postText + "\n"; - - output += "\n"; - - return output; -} - -std::string Declaration::GetExternStr() const -{ - if (IsStatic() || varType == "" || isUnaccounted) - { - return ""; - } - - if (Globals::Instance->otrMode) /* && (varType == "Gfx" || varType == "u64" || varType == "AnimationHeader" || varType == "LinkAnimationHeader" || - varType == "StandardLimb" || varType == "JointIndex" || varType == "Vtx" || varType == "FlexSkeletonHeader" || varType == "SkeletonHeader") || - varType == "CollisionHeader") */ - return ""; - - if (isArray) - { - if (arrayItemCntStr != "" && (IsStatic() || forceArrayCnt)) - { - return StringHelper::Sprintf("extern %s %s[%s];\n", varType.c_str(), varName.c_str(), - arrayItemCntStr.c_str()); - } - else if (arrayItemCnt != 0 && (IsStatic() || forceArrayCnt)) - { - return StringHelper::Sprintf("extern %s %s[%i];\n", varType.c_str(), varName.c_str(), - arrayItemCnt); - } - else - return StringHelper::Sprintf("extern %s %s[];\n", varType.c_str(), varName.c_str()); - } - - return StringHelper::Sprintf("extern %s %s;\n", varType.c_str(), varName.c_str()); -} - -std::string Declaration::GetStaticForwardDeclarationStr() const -{ - if (!IsStatic() || isUnaccounted) - return ""; - - if (isArray) - { - if (arrayItemCntStr == "" && arrayItemCnt == 0) - { - // Forward declaring static arrays without specifying the size is not allowed. - return ""; - } - - if (arrayItemCntStr != "") - { - return StringHelper::Sprintf("static %s %s[%s];\n", varType.c_str(), varName.c_str(), - arrayItemCntStr.c_str()); - } - else - { - return StringHelper::Sprintf("static %s %s[%i];\n", varType.c_str(), varName.c_str(), - arrayItemCnt); - } - } - - return StringHelper::Sprintf("static %s %s;\n", varType.c_str(), varName.c_str()); -} diff --git a/ZAPDTR/ZAPD/Declaration.h b/ZAPDTR/ZAPD/Declaration.h deleted file mode 100644 index 64712d8c3..000000000 --- a/ZAPDTR/ZAPD/Declaration.h +++ /dev/null @@ -1,87 +0,0 @@ -#pragma once - -#include -#include -#include - -// TODO: should we drop the `_t` suffix because of UNIX compliance? -typedef uint32_t segptr_t; -typedef uint32_t offset_t; - -#define SEGMENTED_NULL ((segptr_t)0) - -enum class DeclarationAlignment -{ - Align4, - Align8 -}; - -enum class StaticConfig -{ - Off, - Global, - On -}; - -class ZVtx; - -class Declaration -{ -public: - offset_t address; - DeclarationAlignment alignment; - size_t size; - std::string preText; - std::string text; - std::string rightText; - std::string postText; - std::string preComment; - std::string postComment; - std::string varType; - std::string varName; - std::string includePath; - - std::vector vertexHack; - - bool isExternal = false; - bool isArray = false; - bool forceArrayCnt = false; - size_t arrayItemCnt = 0; - std::string arrayItemCntStr = ""; - std::vector references; - bool isUnaccounted = false; - bool isPlaceholder = false; - bool declaredInXml = false; - StaticConfig staticConf = StaticConfig::Global; - - Declaration(offset_t nAddress, DeclarationAlignment nAlignment, size_t nSize, - const std::string& nVarType, const std::string& nVarName, bool nIsArray, - const std::string& nText); - Declaration(offset_t nAddress, DeclarationAlignment nAlignment, size_t nSize, - const std::string& nVarType, const std::string& nVarName, bool nIsArray, - size_t nArrayItemCnt, const std::string& nText); - Declaration(offset_t nAddress, DeclarationAlignment nAlignment, size_t nSize, - const std::string& nVarType, const std::string& nVarName, bool nIsArray, - const std::string& nArrayItemCntStr, const std::string& nText); - Declaration(offset_t nAddress, DeclarationAlignment nAlignment, size_t nSize, - const std::string& nVarType, const std::string& nVarName, bool nIsArray, - size_t nArrayItemCnt, const std::string& nText, bool nIsExternal); - - Declaration(offset_t nAddress, const std::string& nIncludePath, size_t nSize, - const std::string& nVarType, const std::string& nVarName); - - ~Declaration(); - - bool IsStatic() const; - - std::string GetNormalDeclarationStr() const; - std::string GetExternalDeclarationStr() const; - - std::string GetExternStr() const; - - std::string GetStaticForwardDeclarationStr() const; - -protected: - Declaration(offset_t nAddress, DeclarationAlignment nAlignment, size_t nSize, - const std::string& nText); -}; diff --git a/ZAPDTR/ZAPD/ExecutableMain.cpp b/ZAPDTR/ZAPD/ExecutableMain.cpp deleted file mode 100644 index 303ea24ad..000000000 --- a/ZAPDTR/ZAPD/ExecutableMain.cpp +++ /dev/null @@ -1,5 +0,0 @@ -extern "C" int zapd_main(int argc, char* argv[]); - -int main(int argc, char* argv[]) { - return zapd_main(argc, argv); -} diff --git a/ZAPDTR/ZAPD/FileWorker.cpp b/ZAPDTR/ZAPD/FileWorker.cpp deleted file mode 100644 index e69de29bb..000000000 diff --git a/ZAPDTR/ZAPD/FileWorker.h b/ZAPDTR/ZAPD/FileWorker.h deleted file mode 100644 index 6ceae8076..000000000 --- a/ZAPDTR/ZAPD/FileWorker.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include -#include -#include -#include "ZFile.h" - -class FileWorker -{ -public: - std::vector files; - std::vector externalFiles; - std::vector segments; - std::map> segmentRefFiles; -}; \ No newline at end of file diff --git a/ZAPDTR/ZAPD/GameConfig.cpp b/ZAPDTR/ZAPD/GameConfig.cpp deleted file mode 100644 index 9a2e8898c..000000000 --- a/ZAPDTR/ZAPD/GameConfig.cpp +++ /dev/null @@ -1,207 +0,0 @@ -#include "GameConfig.h" - -#include -#include -#include - -#include "Utils/Directory.h" -#include -#include "Utils/Path.h" -#include "ZFile.h" -#include "tinyxml2.h" - -using ConfigFunc = void (GameConfig::*)(const tinyxml2::XMLElement&); - -GameConfig::~GameConfig() -{ - for (auto& declPair : segmentRefFiles) - { - for (auto& file : declPair.second) - { - delete file; - } - } -} - -void GameConfig::ReadTexturePool(const fs::path& texturePoolXmlPath) -{ - tinyxml2::XMLDocument doc; - tinyxml2::XMLError eResult = doc.LoadFile(texturePoolXmlPath.string().c_str()); - - if (eResult != tinyxml2::XML_SUCCESS) - { - fprintf(stderr, "Warning: Unable to read texture pool XML with error code %i\n", eResult); - return; - } - - tinyxml2::XMLNode* root = doc.FirstChild(); - - if (root == nullptr) - return; - - for (tinyxml2::XMLElement* child = root->FirstChildElement(); child != nullptr; - child = child->NextSiblingElement()) - { - if (std::string_view(child->Name()) == "Texture") - { - std::string crcStr = child->Attribute("CRC"); - fs::path texPath = child->Attribute("Path"); - std::string texName; - - uint32_t crc = strtoul(crcStr.c_str(), nullptr, 16); - - texturePool[crc].path = texPath; - } - } -} - -void GameConfig::GenSymbolMap(const fs::path& symbolMapPath) -{ - auto symbolLines = DiskFile::ReadAllLines(symbolMapPath); - - for (std::string& symbolLine : symbolLines) - { - auto split = StringHelper::Split(symbolLine, " "); - uint32_t addr = strtoul(split[0].c_str(), nullptr, 16); - std::string symbolName = split[1]; - - symbolMap[addr] = std::move(symbolName); - } -} - -void GameConfig::ConfigFunc_SymbolMap(const tinyxml2::XMLElement& element) -{ - std::string fileName = element.Attribute("File"); - GenSymbolMap(Path::GetDirectoryName(configFilePath) / fileName); -} - -void GameConfig::ConfigFunc_ActorList(const tinyxml2::XMLElement& element) -{ - std::string fileName = element.Attribute("File"); - std::vector lines = - DiskFile::ReadAllLines(Path::GetDirectoryName(configFilePath) / fileName); - - for (auto& line : lines) - actorList.emplace_back(std::move(line)); -} - -void GameConfig::ConfigFunc_ObjectList(const tinyxml2::XMLElement& element) -{ - std::string fileName = element.Attribute("File"); - std::vector lines = - DiskFile::ReadAllLines(Path::GetDirectoryName(configFilePath) / fileName); - - for (auto& line : lines) - objectList.emplace_back(std::move(line)); -} - -void GameConfig::ConfigFunc_EntranceList(const tinyxml2::XMLElement& element) -{ - std::string fileName = element.Attribute("File"); - std::vector lines = - DiskFile::ReadAllLines(Path::GetDirectoryName(configFilePath) / fileName); - - for (auto& line : lines) - entranceList.emplace_back(std::move(line)); -} - -void GameConfig::ConfigFunc_specialEntranceList(const tinyxml2::XMLElement& element) -{ - std::string fileName = element.Attribute("File"); - std::vector lines = - DiskFile::ReadAllLines(Path::GetDirectoryName(configFilePath) / fileName); - - for (auto& line : lines) - specialEntranceList.emplace_back(std::move(line)); -} - -void GameConfig::ConfigFunc_TexturePool(const tinyxml2::XMLElement& element) -{ - std::string fileName = element.Attribute("File"); - ReadTexturePool(Path::GetDirectoryName(configFilePath) / fileName); -} - -void GameConfig::ConfigFunc_BGConfig(const tinyxml2::XMLElement& element) -{ - bgScreenWidth = element.IntAttribute("ScreenWidth", 320); - bgScreenHeight = element.IntAttribute("ScreenHeight", 240); -} - -void GameConfig::ConfigFunc_ExternalXMLFolder(const tinyxml2::XMLElement& element) -{ - const char* pathValue = element.Attribute("Path"); - if (pathValue == nullptr) - { - throw std::runtime_error( - StringHelper::Sprintf("Parse: Fatal error in configuration file.\n" - "\t Missing 'Path' attribute in `ExternalXMLFolder` element.\n")); - } - if (externalXmlFolder != "") - { - throw std::runtime_error(StringHelper::Sprintf("Parse: Fatal error in configuration file.\n" - "\t `ExternalXMLFolder` is duplicated.\n")); - } - externalXmlFolder = pathValue; -} - -void GameConfig::ConfigFunc_ExternalFile(const tinyxml2::XMLElement& element) -{ - const char* xmlPathValue = element.Attribute("XmlPath"); - if (xmlPathValue == nullptr) - { - throw std::runtime_error( - StringHelper::Sprintf("Parse: Fatal error in configuration file.\n" - "\t Missing 'XmlPath' attribute in `ExternalFile` element.\n")); - } - const char* outPathValue = element.Attribute("OutPath"); - if (outPathValue == nullptr) - { - throw std::runtime_error( - StringHelper::Sprintf("Parse: Fatal error in configuration file.\n" - "\t Missing 'OutPath' attribute in `ExternalFile` element.\n")); - } - - externalFiles.push_back(ExternalFile(fs::path(xmlPathValue), fs::path(outPathValue))); -} - -void GameConfig::ReadConfigFile(const fs::path& argConfigFilePath) -{ - static const std::unordered_map ConfigFuncDictionary = { - {"SymbolMap", &GameConfig::ConfigFunc_SymbolMap}, - {"ActorList", &GameConfig::ConfigFunc_ActorList}, - {"ObjectList", &GameConfig::ConfigFunc_ObjectList}, - {"EntranceList", &GameConfig::ConfigFunc_EntranceList}, - {"SpecialEntranceList", &GameConfig::ConfigFunc_specialEntranceList}, - {"TexturePool", &GameConfig::ConfigFunc_TexturePool}, - {"BGConfig", &GameConfig::ConfigFunc_BGConfig}, - {"ExternalXMLFolder", &GameConfig::ConfigFunc_ExternalXMLFolder}, - {"ExternalFile", &GameConfig::ConfigFunc_ExternalFile}, - }; - - configFilePath = argConfigFilePath.string(); - tinyxml2::XMLDocument doc; - tinyxml2::XMLError eResult = doc.LoadFile(configFilePath.c_str()); - - if (eResult != tinyxml2::XML_SUCCESS) - { - throw std::runtime_error("Error: Unable to read config file."); - } - - tinyxml2::XMLNode* root = doc.FirstChild(); - - if (root == nullptr) - return; - - for (tinyxml2::XMLElement* child = root->FirstChildElement(); child != nullptr; - child = child->NextSiblingElement()) - { - auto it = ConfigFuncDictionary.find(child->Name()); - if (it == ConfigFuncDictionary.end()) - { - fprintf(stderr, "Unsupported configuration variable: %s\n", child->Name()); - continue; - } - - std::invoke(it->second, *this, *child); - } -} diff --git a/ZAPDTR/ZAPD/GameConfig.h b/ZAPDTR/ZAPD/GameConfig.h deleted file mode 100644 index 2a783d10a..000000000 --- a/ZAPDTR/ZAPD/GameConfig.h +++ /dev/null @@ -1,62 +0,0 @@ -#pragma once - -#include -#include -#include -#include - -#include "Utils/Directory.h" -#include "tinyxml2.h" - -struct TexturePoolEntry -{ - fs::path path = ""; // Path to Shared Texture -}; - -class ExternalFile -{ -public: - fs::path xmlPath, outPath; - - ExternalFile(fs::path nXmlPath, fs::path nOutPath); -}; - -class ZFile; - -class GameConfig -{ -public: - std::string configFilePath; - std::map> segmentRefFiles; - std::map symbolMap; - std::vector actorList; - std::vector objectList; - std::vector entranceList; - std::vector specialEntranceList; - std::map texturePool; // Key = CRC - - // ZBackground - uint32_t bgScreenWidth = 320, bgScreenHeight = 240; - - // ExternalFile - fs::path externalXmlFolder; - std::vector externalFiles; - - GameConfig() = default; - ~GameConfig(); - - void ReadTexturePool(const fs::path& texturePoolXmlPath); - void GenSymbolMap(const fs::path& symbolMapPath); - - void ConfigFunc_SymbolMap(const tinyxml2::XMLElement& element); - void ConfigFunc_ActorList(const tinyxml2::XMLElement& element); - void ConfigFunc_ObjectList(const tinyxml2::XMLElement& element); - void ConfigFunc_EntranceList(const tinyxml2::XMLElement& element); - void ConfigFunc_specialEntranceList(const tinyxml2::XMLElement& element); - void ConfigFunc_TexturePool(const tinyxml2::XMLElement& element); - void ConfigFunc_BGConfig(const tinyxml2::XMLElement& element); - void ConfigFunc_ExternalXMLFolder(const tinyxml2::XMLElement& element); - void ConfigFunc_ExternalFile(const tinyxml2::XMLElement& element); - - void ReadConfigFile(const fs::path& configFilePath); -}; diff --git a/ZAPDTR/ZAPD/Globals.cpp b/ZAPDTR/ZAPD/Globals.cpp deleted file mode 100644 index a6b22cfa2..000000000 --- a/ZAPDTR/ZAPD/Globals.cpp +++ /dev/null @@ -1,325 +0,0 @@ -#include "Globals.h" - -#include -#include - -#include -#include "Utils/Path.h" -#include "WarningHandler.h" -#include "tinyxml2.h" - -Globals* Globals::Instance; - -Globals::Globals() -{ - Instance = this; - - game = ZGame::OOT_RETAIL; - genSourceFile = true; - testMode = false; - profile = false; - useLegacyZDList = false; - useExternalResources = true; - singleThreaded = true; - verbosity = VerbosityLevel::VERBOSITY_SILENT; - outputPath = Directory::GetCurrentDirectory(); -} - -Globals::~Globals() -{ - for (const auto& w : workerData) - { - delete w.second; - } - - if (rom != nullptr) - { - delete rom; - } -} - -void Globals::AddSegment(int32_t segment, ZFile* file, int workerID) -{ - if (!Globals::Instance->singleThreaded) - { - auto worker = workerData[workerID]; - - if (std::find(worker->segments.begin(), worker->segments.end(), segment) == - worker->segments.end()) - worker->segments.push_back(segment); - if (worker->segmentRefFiles.find(segment) == worker->segmentRefFiles.end()) - worker->segmentRefFiles[segment] = std::vector(); - - worker->segmentRefFiles[segment].push_back(file); - } - else - { - if (std::find(segments.begin(), segments.end(), segment) == segments.end()) - segments.push_back(segment); - if (cfg.segmentRefFiles.find(segment) == cfg.segmentRefFiles.end()) - cfg.segmentRefFiles[segment] = std::vector(); - - cfg.segmentRefFiles[segment].push_back(file); - } -} - -bool Globals::HasSegment(int32_t segment, int workerID) -{ - if (!Globals::Instance->singleThreaded) - return std::find(workerData[workerID]->segments.begin(), - workerData[workerID]->segments.end(), segment) != workerData[workerID]->segments.end(); - else - return std::find(segments.begin(), segments.end(), segment) != segments.end(); -} - -ZFile* Globals::GetSegment(int32_t segment, int workerID) -{ - if (!Globals::Instance->singleThreaded) - { - if (HasSegment(segment, workerID)) - { - int idx = std::find(workerData[workerID]->segments.begin(), - workerData[workerID]->segments.end(), segment) - - workerData[workerID]->segments.begin(); - return workerData[workerID]->files[idx]; - } - else - return nullptr; - } - else - { - if (HasSegment(segment, workerID)) - { - int idx = std::find(segments.begin(), segments.end(), segment) - segments.begin(); - return files[idx]; - } - else - return nullptr; - } -} - -std::map> Globals::GetSegmentRefFiles(int workerID) -{ - if (!Globals::Instance->singleThreaded) - return workerData[workerID]->segmentRefFiles; - else - return cfg.segmentRefFiles; -} - -void Globals::AddFile(ZFile* file, int workerID) -{ - if (singleThreaded) - files.push_back(file); - else - workerData[workerID]->files.push_back(file); -} - -void Globals::AddExternalFile(ZFile* file, int workerID) -{ - if (singleThreaded) - externalFiles.push_back(file); - else - workerData[workerID]->externalFiles.push_back(file); -} - -void Globals::BuildAssetTexture(const fs::path& pngFilePath, TextureType texType, const fs::path& outPath) -{ - std::string name = outPath.stem().string(); - - ZTexture tex(nullptr); - - if (name.find("u32") != std::string::npos) - tex.dWordAligned = false; - - tex.FromPNG(pngFilePath.string(), texType); - std::string cfgPath = StringHelper::Split(pngFilePath.string(), ".")[0] + ".cfg"; - - if (DiskFile::Exists(cfgPath)) - name = DiskFile::ReadAllText(cfgPath); - - std::string src = tex.GetBodySourceCode(); - - DiskFile::WriteAllBytes(outPath.string(), src.c_str(), src.size()); -} - -std::map& Globals::GetExporterMap() -{ - static std::map exporters; - return exporters; -} - -void Globals::AddExporter(std::string exporterName, ExporterSet* exporterSet) -{ - auto& exporters = GetExporterMap(); - exporters[exporterName] = exporterSet; -} - -ZResourceExporter* Globals::GetExporter(ZResourceType resType) -{ - auto& exporters = GetExporterMap(); - - if (currentExporter != "" && exporters[currentExporter]->exporters.find(resType) != - exporters[currentExporter]->exporters.end()) - return exporters[currentExporter]->exporters[resType]; - else - return nullptr; -} - -ExporterSet* Globals::GetExporterSet() -{ - auto& exporters = GetExporterMap(); - - if (currentExporter != "") - return exporters[currentExporter]; - else - return nullptr; -} - -std::vector Globals::GetBaseromFile(std::string fileName) -{ - if (fileMode == ZFileMode::ExtractDirectory) - { - if (StringHelper::Contains(fileName, "baserom/")) - fileName = StringHelper::Split(fileName, "baserom/")[1]; - - return rom->GetFile(fileName); - - } - else - return DiskFile::ReadAllBytes(fileName); -} - -bool Globals::GetSegmentedPtrName(segptr_t segAddress, ZFile* currentFile, - const std::string& expectedType, std::string& declName, int workerID) -{ - if (segAddress == 0) - { - declName = "NULL"; - return true; - } - - uint8_t segment = GETSEGNUM(segAddress); - uint32_t offset = Seg2Filespace(segAddress, currentFile->baseAddress); - ZSymbol* sym; - - sym = currentFile->GetSymbolResource(offset); - if (sym != nullptr) - { - if (expectedType == "" || expectedType == sym->GetSourceTypeName()) - { - declName = sym->GetName(); - return true; - } - } - sym = currentFile->GetSymbolResource(segAddress); - if (sym != nullptr) - { - if (expectedType == "" || expectedType == sym->GetSourceTypeName()) - { - declName = sym->GetName(); - return true; - } - } - - if (currentFile->IsSegmentedInFilespaceRange(segAddress)) - { - if (currentFile->GetDeclarationPtrName(segAddress, expectedType, declName)) - return true; - } - else if (HasSegment(segment, workerID)) - { - // OTRTODO: Multithreading - auto segs = GetSegmentRefFiles(workerID); - for (auto file : segs[segment]) - { - offset = Seg2Filespace(segAddress, file->baseAddress); - - sym = file->GetSymbolResource(offset); - if (sym != nullptr) - { - if (expectedType == "" || expectedType == sym->GetSourceTypeName()) - { - declName = sym->GetName(); - return true; - } - } - sym = file->GetSymbolResource(segAddress); - if (sym != nullptr) - { - if (expectedType == "" || expectedType == sym->GetSourceTypeName()) - { - declName = sym->GetName(); - return true; - } - } - - if (file->IsSegmentedInFilespaceRange(segAddress)) - { - if (file->GetDeclarationPtrName(segAddress, expectedType, declName)) - return true; - } - } - } - - const auto& symbolFromMap = Globals::Instance->cfg.symbolMap.find(segAddress); - if (symbolFromMap != Globals::Instance->cfg.symbolMap.end()) - { - declName = "&" + symbolFromMap->second; - return true; - } - - declName = StringHelper::Sprintf("0x%08X", segAddress); - return false; -} - -bool Globals::GetSegmentedArrayIndexedName(segptr_t segAddress, size_t elementSize, - ZFile* currentFile, const std::string& expectedType, - std::string& declName, int workerID) -{ - if (segAddress == 0) - { - declName = "NULL"; - return true; - } - - uint8_t segment = GETSEGNUM(segAddress); - - if (currentFile->IsSegmentedInFilespaceRange(segAddress)) - { - bool addressFound = currentFile->GetDeclarationArrayIndexedName(segAddress, elementSize, - expectedType, declName); - if (addressFound) - return true; - } - else if (HasSegment(segment, workerID)) - { - // OTRTODO: Multithreading - auto segs = GetSegmentRefFiles(workerID); - for (auto file : segs[segment]) - { - if (file->IsSegmentedInFilespaceRange(segAddress)) - { - bool addressFound = file->GetDeclarationArrayIndexedName(segAddress, elementSize, - expectedType, declName); - if (addressFound) - return true; - } - } - } - - declName = StringHelper::Sprintf("0x%08X", segAddress); - return false; -} - -ExternalFile::ExternalFile(fs::path nXmlPath, fs::path nOutPath) - : xmlPath{nXmlPath}, outPath{nOutPath} -{ -} - -ExporterSet::~ExporterSet() -{ - for (auto& it : exporters) - { - delete it.second; - } -} diff --git a/ZAPDTR/ZAPD/Globals.h b/ZAPDTR/ZAPD/Globals.h deleted file mode 100644 index 0fe8e0545..000000000 --- a/ZAPDTR/ZAPD/Globals.h +++ /dev/null @@ -1,113 +0,0 @@ -#pragma once - -#include -#include -#include -#include "GameConfig.h" -#include "ZFile.h" -#include -#include - -class ZRoom; - -enum class VerbosityLevel -{ - VERBOSITY_SILENT, - VERBOSITY_INFO, - VERBOSITY_DEBUG -}; - -typedef void (*ExporterSetFunc)(ZFile*); -typedef bool (*ExporterSetFuncBool)(ZFileMode fileMode); -typedef void (*ExporterSetFuncVoid)(int argc, char* argv[], int& i); -typedef void (*ExporterSetFuncVoid2)(const std::string& buildMode, ZFileMode& fileMode); -typedef void (*ExporterSetFuncVoid3)(); -typedef void (*ExporterSetFuncVoid4)(tinyxml2::XMLElement* reader); -typedef void (*ExporterSetResSave)(ZResource* res, BinaryWriter& writer); - -class ExporterSet -{ -public: - ~ExporterSet(); - - std::map exporters; - ExporterSetFuncVoid parseArgsFunc = nullptr; - ExporterSetFuncVoid2 parseFileModeFunc = nullptr; - ExporterSetFuncBool processFileModeFunc = nullptr; - ExporterSetFunc beginFileFunc = nullptr; - ExporterSetFunc endFileFunc = nullptr; - ExporterSetFuncVoid3 beginXMLFunc = nullptr; - ExporterSetFuncVoid3 endXMLFunc = nullptr; - ExporterSetResSave resSaveFunc = nullptr; - ExporterSetFuncVoid3 endProgramFunc = nullptr; - - ExporterSetFuncVoid4 processCompilableFunc = nullptr; -}; - -class Globals -{ -public: - static Globals* Instance; - - bool genSourceFile; // Used for extraction - bool useExternalResources; - bool testMode; // Enables certain experimental features - bool outputCrc = false; - bool profile; // Measure performance of certain operations - bool useLegacyZDList; - bool singleThreaded; - VerbosityLevel verbosity; // ZAPD outputs additional information - ZFileMode fileMode = ZFileMode::Invalid; - fs::path baseRomPath, inputPath, outputPath, sourceOutputPath, cfgPath, fileListPath; - TextureType texType; - ZGame game; - GameConfig cfg; - bool verboseUnaccounted = false; - bool gccCompat = false; - bool forceStatic = false; - bool forceUnaccountedStatic = false; - bool otrMode = true; - bool buildRawTexture = false; - bool onlyGenSohOtr = false; - - ZRom* rom = nullptr; - std::vector files; - std::vector externalFiles; - std::vector segments; - - std::map workerData; - - std::string currentExporter; - static std::map& GetExporterMap(); - static void AddExporter(std::string exporterName, ExporterSet* exporterSet); - - Globals(); - ~Globals(); - - void AddSegment(int32_t segment, ZFile* file, int workerID); - bool HasSegment(int32_t segment, int workerID); - ZFile* GetSegment(int32_t segment, int workerID); - std::map> GetSegmentRefFiles(int workerID); - void AddFile(ZFile* file, int workerID); - void AddExternalFile(ZFile* file, int workerID); - void BuildAssetTexture(const fs::path& pngFilePath, TextureType texType, const fs::path& outPath); - - ZResourceExporter* GetExporter(ZResourceType resType); - ExporterSet* GetExporterSet(); - - std::vector GetBaseromFile(std::string fileName); - - /** - * Search in every file (and the symbol map) for the `segAddress` passed as parameter. - * If the segment of `currentFile` is the same segment of `segAddress`, then that file will be - * used only, otherwise, the search will be performed in every other file. - * The name of that variable will be stored in the `declName` parameter. - * Returns `true` if the address is found. `false` otherwise, - * in which case `declName` will be set to the address formatted as a pointer. - */ - bool GetSegmentedPtrName(segptr_t segAddress, ZFile* currentFile, - const std::string& expectedType, std::string& declName, int workerID); - - bool GetSegmentedArrayIndexedName(segptr_t segAddress, size_t elementSize, ZFile* currentFile, - const std::string& expectedType, std::string& declName, int workerID); -}; diff --git a/ZAPDTR/ZAPD/ImageBackend.cpp b/ZAPDTR/ZAPD/ImageBackend.cpp deleted file mode 100644 index 7ebb29121..000000000 --- a/ZAPDTR/ZAPD/ImageBackend.cpp +++ /dev/null @@ -1,506 +0,0 @@ -#include "ImageBackend.h" - -#include -#include -#include -#include - -#include "Utils/StringHelper.h" -#include "WarningHandler.h" - -/* ImageBackend */ - -ImageBackend::~ImageBackend() -{ - FreeImageData(); -} - -void ImageBackend::ReadPng(const char* filename) -{ - FreeImageData(); - - FILE* fp = fopen(filename, "rb"); - if (fp == nullptr) - { - std::string errorHeader = StringHelper::Sprintf("could not open file '%s'", filename); - HANDLE_ERROR(WarningType::InvalidPNG, errorHeader, ""); - } - - png_structp png = png_create_read_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr); - if (png == nullptr) - { - HANDLE_ERROR(WarningType::InvalidPNG, "could not create png struct", ""); - } - - png_infop info = png_create_info_struct(png); - if (info == nullptr) - { - HANDLE_ERROR(WarningType::InvalidPNG, "could not create png info", ""); - } - - if (setjmp(png_jmpbuf(png))) - { - // TODO: better warning explanation - HANDLE_ERROR(WarningType::InvalidPNG, "setjmp(png_jmpbuf(png))", ""); - } - - png_init_io(png, fp); - - png_read_info(png, info); - - width = png_get_image_width(png, info); - height = png_get_image_height(png, info); - colorType = png_get_color_type(png, info); - bitDepth = png_get_bit_depth(png, info); - -#ifdef TEXTURE_DEBUG - printf("Width: %u\n", width); - printf("Height: %u\n", height); - printf("ColorType: "); - switch (colorType) - { - case PNG_COLOR_TYPE_RGBA: - printf("PNG_COLOR_TYPE_RGBA\n"); - break; - - case PNG_COLOR_TYPE_RGB: - printf("PNG_COLOR_TYPE_RGB\n"); - break; - - case PNG_COLOR_TYPE_PALETTE: - printf("PNG_COLOR_TYPE_PALETTE\n"); - break; - - default: - printf("%u\n", colorType); - break; - } - printf("BitDepth: %u\n", bitDepth); - printf("\n"); -#endif - - // Read any color_type into 8bit depth, RGBA format. - // See http://www.libpng.org/pub/png/libpng-manual.txt - - if (bitDepth == 16) - png_set_strip_16(png); - - if (colorType == PNG_COLOR_TYPE_PALETTE) - { - // png_set_palette_to_rgb(png); - isColorIndexed = true; - } - - // PNG_COLOR_TYPE_GRAY_ALPHA is always 8 or 16bit depth. - if (colorType == PNG_COLOR_TYPE_GRAY && bitDepth < 8) - png_set_expand_gray_1_2_4_to_8(png); - - /*if (png_get_valid(png, info, PNG_INFO_tRNS)) - png_set_tRNS_to_alpha(png);*/ - - // These color_type don't have an alpha channel then fill it with 0xff. - /*if(*color_type == PNG_COLOR_TYPE_RGB || - *color_type == PNG_COLOR_TYPE_GRAY || - *color_type == PNG_COLOR_TYPE_PALETTE) - png_set_filler(png, 0xFF, PNG_FILLER_AFTER);*/ - - if (colorType == PNG_COLOR_TYPE_GRAY || colorType == PNG_COLOR_TYPE_GRAY_ALPHA) - png_set_gray_to_rgb(png); - - png_read_update_info(png, info); - - size_t rowBytes = png_get_rowbytes(png, info); - pixelMatrix = (uint8_t**)malloc(sizeof(uint8_t*) * height); - for (size_t y = 0; y < height; y++) - { - pixelMatrix[y] = (uint8_t*)malloc(rowBytes); - } - - png_read_image(png, pixelMatrix); - -#ifdef TEXTURE_DEBUG - printf("rowBytes: %zu\n", rowBytes); - - size_t bytePerPixel = GetBytesPerPixel(); - printf("imgData\n"); - for (size_t y = 0; y < height; y++) - { - for (size_t x = 0; x < width; x++) - { - for (size_t z = 0; z < bytePerPixel; z++) - { - printf("%02X ", pixelMatrix[y][x * bytePerPixel + z]); - } - printf(" "); - } - printf("\n"); - } - printf("\n"); -#endif - - fclose(fp); - - png_destroy_read_struct(&png, &info, nullptr); - - hasImageData = true; -} - -void ImageBackend::ReadPng(const fs::path& filename) -{ - ReadPng(filename.string().c_str()); -} - -void ImageBackend::WritePng(const char* filename) -{ - assert(hasImageData); - - FILE* fp = fopen(filename, "wb"); - if (fp == nullptr) - { - std::string errorHeader = - StringHelper::Sprintf("could not open file '%s' in write mode", filename); - HANDLE_ERROR(WarningType::InvalidPNG, errorHeader, ""); - } - - png_structp png = png_create_write_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr); - if (png == nullptr) - { - HANDLE_ERROR(WarningType::InvalidPNG, "could not create png struct", ""); - } - - png_infop info = png_create_info_struct(png); - if (info == nullptr) - { - HANDLE_ERROR(WarningType::InvalidPNG, "could not create png info", ""); - } - - if (setjmp(png_jmpbuf(png))) - { - // TODO: better warning description - HANDLE_ERROR(WarningType::InvalidPNG, "setjmp(png_jmpbuf(png))", ""); - } - - png_init_io(png, fp); - - png_set_IHDR(png, info, width, height, - bitDepth, // 8, - colorType, // PNG_COLOR_TYPE_RGBA, - PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); - - if (isColorIndexed) - { - png_set_PLTE(png, info, static_cast(colorPalette), paletteSize); - -#ifdef TEXTURE_DEBUG - printf("palette\n"); - png_color* aux = (png_color*)colorPalette; - for (size_t y = 0; y < paletteSize; y++) - { - printf("#%02X%02X%02X ", aux[y].red, aux[y].green, aux[y].blue); - if ((y + 1) % 8 == 0) - printf("\n"); - } - printf("\n"); -#endif - - png_set_tRNS(png, info, alphaPalette, paletteSize, nullptr); - } - - png_write_info(png, info); - - // To remove the alpha channel for PNG_COLOR_TYPE_RGB format, - // Use png_set_filler(). - // png_set_filler(png, 0, PNG_FILLER_AFTER); - -#ifdef TEXTURE_DEBUG - size_t bytePerPixel = GetBytesPerPixel(); - printf("imgData\n"); - for (size_t y = 0; y < height; y++) - { - for (size_t x = 0; x < width * bytePerPixel; x++) - { - printf("%02X ", pixelMatrix[y][x]); - } - printf("\n"); - } - printf("\n"); -#endif - - png_write_image(png, pixelMatrix); - png_write_end(png, nullptr); - - fclose(fp); - - png_destroy_write_struct(&png, &info); -} - -void ImageBackend::WritePng(const fs::path& filename) -{ - // Note: The .string() is necessary for MSVC, due to the implementation of std::filesystem - // differing from GCC. Do not remove! - WritePng(filename.string().c_str()); -} - -void ImageBackend::SetTextureData(const std::vector>& texData, - uint32_t nWidth, uint32_t nHeight, uint8_t nColorType, - uint8_t nBitDepth) -{ - FreeImageData(); - - width = nWidth; - height = nHeight; - colorType = nColorType; - bitDepth = nBitDepth; - - size_t bytePerPixel = GetBytesPerPixel(); - - pixelMatrix = static_cast(malloc(sizeof(uint8_t*) * height)); - for (size_t y = 0; y < height; y++) - { - pixelMatrix[y] = static_cast(malloc(sizeof(uint8_t*) * width * bytePerPixel)); - for (size_t x = 0; x < width; x++) - { - pixelMatrix[y][x * bytePerPixel + 0] = texData.at(y).at(x).r; - pixelMatrix[y][x * bytePerPixel + 1] = texData.at(y).at(x).g; - pixelMatrix[y][x * bytePerPixel + 2] = texData.at(y).at(x).b; - - if (colorType == PNG_COLOR_TYPE_RGBA) - pixelMatrix[y][x * bytePerPixel + 3] = texData.at(y).at(x).a; - } - } - hasImageData = true; -} - -void ImageBackend::InitEmptyRGBImage(uint32_t nWidth, uint32_t nHeight, bool alpha) -{ - FreeImageData(); - - width = nWidth; - height = nHeight; - colorType = PNG_COLOR_TYPE_RGB; - if (alpha) - colorType = PNG_COLOR_TYPE_RGBA; - bitDepth = 8; // nBitDepth; - - size_t bytePerPixel = GetBytesPerPixel(); - - pixelMatrix = static_cast(malloc(sizeof(uint8_t*) * height)); - for (size_t y = 0; y < height; y++) - { - pixelMatrix[y] = static_cast(calloc(width * bytePerPixel, sizeof(uint8_t*))); - } - - hasImageData = true; -} - -void ImageBackend::InitEmptyPaletteImage(uint32_t nWidth, uint32_t nHeight) -{ - FreeImageData(); - - width = nWidth; - height = nHeight; - colorType = PNG_COLOR_TYPE_PALETTE; - bitDepth = 8; - - size_t bytePerPixel = GetBytesPerPixel(); - - pixelMatrix = (uint8_t**)malloc(sizeof(uint8_t*) * height); - for (size_t y = 0; y < height; y++) - { - pixelMatrix[y] = static_cast(calloc(width * bytePerPixel, sizeof(uint8_t*))); - } - colorPalette = calloc(paletteSize, sizeof(png_color)); - alphaPalette = static_cast(calloc(paletteSize, sizeof(uint8_t))); - - hasImageData = true; - isColorIndexed = true; -} - -RGBAPixel ImageBackend::GetPixel(size_t y, size_t x) const -{ - assert(y < height); - assert(x < width); - assert(!isColorIndexed); - - RGBAPixel pixel; - size_t bytePerPixel = GetBytesPerPixel(); - pixel.r = pixelMatrix[y][x * bytePerPixel + 0]; - pixel.g = pixelMatrix[y][x * bytePerPixel + 1]; - pixel.b = pixelMatrix[y][x * bytePerPixel + 2]; - if (colorType == PNG_COLOR_TYPE_RGBA) - pixel.a = pixelMatrix[y][x * bytePerPixel + 3]; - return pixel; -} - -uint8_t ImageBackend::GetIndexedPixel(size_t y, size_t x) const -{ - assert(y < height); - assert(x < width); - assert(isColorIndexed); - - return pixelMatrix[y][x]; -} - -void ImageBackend::SetRGBPixel(size_t y, size_t x, uint8_t nR, uint8_t nG, uint8_t nB, uint8_t nA) -{ - assert(hasImageData); - assert(y < height); - assert(x < width); - - size_t bytePerPixel = GetBytesPerPixel(); - pixelMatrix[y][x * bytePerPixel + 0] = nR; - pixelMatrix[y][x * bytePerPixel + 1] = nG; - pixelMatrix[y][x * bytePerPixel + 2] = nB; - if (colorType == PNG_COLOR_TYPE_RGBA) - pixelMatrix[y][x * bytePerPixel + 3] = nA; -} - -void ImageBackend::SetGrayscalePixel(size_t y, size_t x, uint8_t grayscale, uint8_t alpha) -{ - assert(hasImageData); - assert(y < height); - assert(x < width); - - size_t bytePerPixel = GetBytesPerPixel(); - pixelMatrix[y][x * bytePerPixel + 0] = grayscale; - pixelMatrix[y][x * bytePerPixel + 1] = grayscale; - pixelMatrix[y][x * bytePerPixel + 2] = grayscale; - if (colorType == PNG_COLOR_TYPE_RGBA) - pixelMatrix[y][x * bytePerPixel + 3] = alpha; -} - -void ImageBackend::SetIndexedPixel(size_t y, size_t x, uint8_t index, uint8_t grayscale) -{ - assert(hasImageData); - assert(y < height); - assert(x < width); - - size_t bytePerPixel = GetBytesPerPixel(); - pixelMatrix[y][x * bytePerPixel + 0] = index; - - assert(index < paletteSize); - png_color* pal = static_cast(colorPalette); - pal[index].red = grayscale; - pal[index].green = grayscale; - pal[index].blue = grayscale; - alphaPalette[index] = 255; -} - -void ImageBackend::SetPaletteIndex(size_t index, uint8_t nR, uint8_t nG, uint8_t nB, uint8_t nA) -{ - assert(isColorIndexed); - assert(index < paletteSize); - - png_color* pal = static_cast(colorPalette); - pal[index].red = nR; - pal[index].green = nG; - pal[index].blue = nB; - alphaPalette[index] = nA; -} - -void ImageBackend::SetPalette(const ImageBackend& pal, uint32_t offset) -{ - assert(isColorIndexed); - size_t bytePerPixel = pal.GetBytesPerPixel(); - - for (size_t y = 0; y < pal.height; y++) - { - for (size_t x = 0; x < pal.width; x++) - { - size_t index = y * pal.width + x; - if (index >= paletteSize) - { - /* - * Some TLUTs are bigger than 256 colors. - * For those cases, we will only take the first 256 - * to colorize this CI texture. - */ - return; - } - - uint8_t r = pal.pixelMatrix[y][x * bytePerPixel + 0]; - uint8_t g = pal.pixelMatrix[y][x * bytePerPixel + 1]; - uint8_t b = pal.pixelMatrix[y][x * bytePerPixel + 2]; - uint8_t a = pal.pixelMatrix[y][x * bytePerPixel + 3]; - SetPaletteIndex(index + offset, r, g, b, a); - } - } -} - -uint32_t ImageBackend::GetWidth() const -{ - return width; -} - -uint32_t ImageBackend::GetHeight() const -{ - return height; -} - -uint8_t ImageBackend::GetColorType() const -{ - return colorType; -} - -uint8_t ImageBackend::GetBitDepth() const -{ - return bitDepth; -} - -double ImageBackend::GetBytesPerPixel() const -{ - switch (colorType) - { - case PNG_COLOR_TYPE_RGBA: - return 4 * bitDepth / 8; - - case PNG_COLOR_TYPE_RGB: - return 3 * bitDepth / 8; - - case PNG_COLOR_TYPE_PALETTE: - return 1 * bitDepth / 8; - - default: - HANDLE_ERROR(WarningType::InvalidPNG, "invalid color type", ""); - } -} - -void ImageBackend::FreeImageData() -{ - if (hasImageData) - { - for (size_t y = 0; y < height; y++) - free(pixelMatrix[y]); - free(pixelMatrix); - pixelMatrix = nullptr; - } - - if (isColorIndexed) - { - free(colorPalette); - free(alphaPalette); - colorPalette = nullptr; - alphaPalette = nullptr; - isColorIndexed = false; - } - - hasImageData = false; -} - -/* RGBAPixel */ - -void RGBAPixel::SetRGBA(uint8_t nR, uint8_t nG, uint8_t nB, uint8_t nA) -{ - r = nR; - g = nG; - b = nB; - a = nA; -} - -void RGBAPixel::SetGrayscale(uint8_t grayscale, uint8_t alpha) -{ - r = grayscale; - g = grayscale; - b = grayscale; - a = alpha; -} diff --git a/ZAPDTR/ZAPD/ImageBackend.h b/ZAPDTR/ZAPD/ImageBackend.h deleted file mode 100644 index 0b1f4806c..000000000 --- a/ZAPDTR/ZAPD/ImageBackend.h +++ /dev/null @@ -1,72 +0,0 @@ -#pragma once - -#include -#include - -#include "Utils/Directory.h" - -class RGBAPixel -{ -public: - RGBAPixel() = default; - - void SetRGBA(uint8_t nR, uint8_t nG, uint8_t nB, uint8_t nA); - void SetGrayscale(uint8_t grayscale, uint8_t alpha = 0); - - uint8_t r = 0; - uint8_t g = 0; - uint8_t b = 0; - uint8_t a = 0; -}; - -class ImageBackend -{ -public: - ImageBackend() = default; - ~ImageBackend(); - - void ReadPng(const char* filename); - void ReadPng(const fs::path& filename); - void WritePng(const char* filename); - void WritePng(const fs::path& filename); - - void SetTextureData(const std::vector>& texData, uint32_t nWidth, - uint32_t nHeight, uint8_t nColorType, uint8_t nBitDepth); - void InitEmptyRGBImage(uint32_t nWidth, uint32_t nHeight, bool alpha); - void InitEmptyPaletteImage(uint32_t nWidth, uint32_t nHeight); - - RGBAPixel GetPixel(size_t y, size_t x) const; - uint8_t GetIndexedPixel(size_t y, size_t x) const; - - void SetRGBPixel(size_t y, size_t x, uint8_t nR, uint8_t nG, uint8_t nB, uint8_t nA = 0); - void SetGrayscalePixel(size_t y, size_t x, uint8_t grayscale, uint8_t alpha = 0); - - void SetIndexedPixel(size_t y, size_t x, uint8_t index, uint8_t grayscale); - void SetIndexedPixel(size_t y, size_t x, uint8_t index, RGBAPixel pixel); - void SetPaletteIndex(size_t index, uint8_t nR, uint8_t nG, uint8_t nB, uint8_t nA); - void SetPalette(const ImageBackend& pal, uint32_t offset = 0); - - uint32_t GetWidth() const; - uint32_t GetHeight() const; - uint8_t GetColorType() const; - uint8_t GetBitDepth() const; - -protected: - uint8_t** pixelMatrix = nullptr; // height * [width * bytePerPixel] - - void* colorPalette = nullptr; - uint8_t* alphaPalette = nullptr; - size_t paletteSize = 16 * 16; - - uint32_t width = 0; - uint32_t height = 0; - uint8_t colorType = 0; - uint8_t bitDepth = 0; - - bool hasImageData = false; - bool isColorIndexed = false; - - double GetBytesPerPixel() const; - - void FreeImageData(); -}; diff --git a/ZAPDTR/ZAPD/Main.cpp b/ZAPDTR/ZAPD/Main.cpp deleted file mode 100644 index a2030aaa4..000000000 --- a/ZAPDTR/ZAPD/Main.cpp +++ /dev/null @@ -1,594 +0,0 @@ -#include "Globals.h" -#include "Utils/Directory.h" -#include -#include "Utils/Path.h" -#include "WarningHandler.h" - -#include "ZAnimation.h" -ZNormalAnimation nAnim(nullptr); -ZCurveAnimation cAnim(nullptr); -ZLinkAnimation lAnim(nullptr); -ZLegacyAnimation lAnim2(nullptr); - -#include "ZArray.h" -ZArray arr(nullptr); - -#include "ZAudio.h" -ZAudio audio(nullptr); - -#include "ZBackground.h" -ZBackground back(nullptr); - -#include "ZBlob.h" -ZBlob blob(nullptr); - -#include "ZCollision.h" -ZCollisionHeader colHeader(nullptr); - -#include "ZCutscene.h" -ZCutscene cs(nullptr); - -#include "ZLimb.h" -ZLimb limb(nullptr); - -#include "ZMtx.h" -ZMtx mtx(nullptr); - -#include "ZPath.h" -ZPath path(nullptr); - -#include "ZPlayerAnimationData.h" -ZPlayerAnimationData pAnimData(nullptr); - -#include "ZScalar.h" -ZScalar scalar(nullptr); - -#include "ZSkeleton.h" -ZLimbTable limbTbl(nullptr); -ZSkeleton skel(nullptr); - -#include "ZString.h" -ZString str(nullptr); - -#include "ZSymbol.h" -ZSymbol sym(nullptr); - -#include "ZText.h" -ZText txt(nullptr); - -#include "ZTexture.h" -ZTexture tex(nullptr); - -#include "ZVector.h" -ZVector vec(nullptr); - -#include "ZVtx.h" -ZVtx vtx(nullptr); - -#include "ZRoom/ZRoom.h" -ZRoom room(nullptr); - -#include "ZFile.h" -#include "ZTexture.h" - -#include "CrashHandler.h" - -#include -#include -#include "tinyxml2.h" -#include - -//extern const char gBuildHash[]; -const char gBuildHash[] = ""; - -bool Parse(const fs::path& xmlFilePath, const fs::path& basePath, const fs::path& outPath, - ZFileMode fileMode, int workerID); - -void BuildAssetTexture(const fs::path& pngFilePath, TextureType texType, const fs::path& outPath); -void BuildAssetBackground(const fs::path& imageFilePath, const fs::path& outPath); -void BuildAssetBlob(const fs::path& blobFilePath, const fs::path& outPath); -int ExtractFunc(int workerID, int fileListSize, std::string fileListItem, ZFileMode fileMode); - -volatile int numWorkersLeft = 0; - -extern void ImportExporters(); - -extern "C" int zapd_main(int argc, char* argv[]) -{ - // Syntax: ZAPD.out [mode (btex/bovl/e)] (Arbritrary Number of Arguments) - - if (argc < 2) - { - printf("ZAPD.out (%s) [mode (btex/bovl/bsf/bblb/bmdlintr/bamnintr/e)] ...\n", gBuildHash); - return 1; - } - - Globals* g = new Globals(); - WarningHandler::Init(argc, argv); - - 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"); - - WarningHandler::PrintHelp(); - return 0; - } - } - - // Parse other "commands" - for (int32_t i = 2; i < argc; i++) - { - std::string arg = argv[i]; - - if (arg == "-o" || arg == "--outputpath") // Set output path - { - Globals::Instance->outputPath = argv[++i]; - - if (Globals::Instance->sourceOutputPath == "") - Globals::Instance->sourceOutputPath = Globals::Instance->outputPath; - } - else if (arg == "-i" || arg == "--inputpath") // Set input path - { - Globals::Instance->inputPath = argv[++i]; - } - else if (arg == "-b" || arg == "--baserompath") // Set baserom path - { - Globals::Instance->baseRomPath = argv[++i]; - } - else if (arg == "-osf") // Set source output path - { - Globals::Instance->sourceOutputPath = argv[++i]; - } - else if (arg == "-gsf") // Generate source file during extraction - { - Globals::Instance->genSourceFile = std::string_view(argv[++i]) == "1"; - } - else if (arg == "-tm") // Test Mode (enables certain experimental features) - { - Globals::Instance->testMode = std::string_view(argv[++i]) == "1"; - } - else if (arg == "-crc" || - arg == "--output-crc") // Outputs a CRC file for each extracted texture. - { - Globals::Instance->testMode = std::string_view(argv[++i]) == "1"; - } - else if (arg == "-ulzdl") // Use Legacy ZDisplay List - { - Globals::Instance->useLegacyZDList = std::string_view(argv[++i]) == "1"; - } - else if (arg == "-profile") // Enable profiling - { - Globals::Instance->profile = std::string_view(argv[++i]) == "1"; - } - else if (arg == - "-uer") // Split resources into their individual components (enabled by default) - // TODO: We may wish to make this a part of the config file... - { - Globals::Instance->useExternalResources = std::string_view(argv[++i]) == "1"; - } - else if (arg == "-tt") // Set texture type - { - Globals::Instance->texType = ZTexture::GetTextureTypeFromString(argv[++i]); - } - else if (arg == "-fl") // Set baserom filelist path - { - Globals::Instance->fileListPath = argv[++i]; - } - else if (arg == "-rconf") // Read Config File - { - Globals::Instance->cfg.ReadConfigFile(argv[++i]); - } - else if (arg == "-eh") // Enable Error Handler - { - CrashHandler_Init(); - } - else if (arg == "-v") // Verbose - { - Globals::Instance->verbosity = static_cast(strtol(argv[++i], NULL, 16)); - } - else if (arg == "-vu" || arg == "--verbose-unaccounted") // Verbose unaccounted - { - Globals::Instance->verboseUnaccounted = true; - } - else if (arg == "-se" || arg == "--set-exporter") // Set Current Exporter - { - ImportExporters(); - Globals::Instance->currentExporter = argv[++i]; - } - else if (arg == "--gcc-compat") // GCC compatibility - { - Globals::Instance->gccCompat = true; - } - else if (arg == "-s" || arg == "--static") - { - Globals::Instance->forceStatic = true; - } - else if (arg == "-us" || arg == "--unaccounted-static") - { - Globals::Instance->forceUnaccountedStatic = true; - } - else if (arg == "-brt" || arg == "--build-raw-texture") - { - Globals::Instance->buildRawTexture = true; - } - else if (arg == "--norom") - { - Globals::Instance->onlyGenSohOtr = true; - } - } - - - // Parse File Mode - ExporterSet* exporterSet = Globals::Instance->GetExporterSet(); - - if(Globals::Instance->onlyGenSohOtr) { - exporterSet->endProgramFunc(); - - delete g; - return 0; - } - - std::string buildMode = argv[1]; - ZFileMode fileMode = ZFileMode::Invalid; - - if (buildMode == "btex") - fileMode = ZFileMode::BuildTexture; - else if (buildMode == "bren") - fileMode = ZFileMode::BuildBackground; - else if (buildMode == "bsf") - fileMode = ZFileMode::BuildSourceFile; - else if (buildMode == "bblb") - fileMode = ZFileMode::BuildBlob; - else if (buildMode == "e") - fileMode = ZFileMode::Extract; - else if (buildMode == "ed") - fileMode = ZFileMode::ExtractDirectory; - else if (exporterSet != nullptr && exporterSet->parseFileModeFunc != nullptr) - exporterSet->parseFileModeFunc(buildMode, fileMode); - - if (fileMode == ZFileMode::Invalid) - { - printf("Error: Invalid file mode '%s'\n", buildMode.c_str()); - return 1; - } - - Globals::Instance->fileMode = fileMode; - - if (fileMode == ZFileMode::ExtractDirectory) - Globals::Instance->rom = new ZRom(Globals::Instance->baseRomPath.string()); - - // We've parsed through our commands once. If an exporter exists, it's been set by now. - // Now we'll parse through them again but pass them on to our exporter if one is available. - - if (exporterSet != nullptr && exporterSet->parseArgsFunc != nullptr) - { - for (int32_t i = 2; i < argc; i++) - exporterSet->parseArgsFunc(argc, argv, i); - } - - if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_INFO) - printf("ZAPD: Zelda Asset Processor For Decomp: %s\n", gBuildHash); - - if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_DEBUG) - { - WarningHandler::PrintWarningsDebugInfo(); - } - - // TODO: switch - if (fileMode == ZFileMode::Extract || fileMode == ZFileMode::BuildSourceFile || fileMode == ZFileMode::ExtractDirectory) - { - bool procFileModeSuccess = false; - - if (exporterSet != nullptr && exporterSet->processFileModeFunc != nullptr) - procFileModeSuccess = exporterSet->processFileModeFunc(fileMode); - - if (!procFileModeSuccess) - { - if (fileMode == ZFileMode::ExtractDirectory) - { - std::vector fileList = - Directory::ListFiles(Globals::Instance->inputPath.string()); - - const int num_threads = std::thread::hardware_concurrency(); - ctpl::thread_pool pool(num_threads > 1 ? num_threads / 2 : 1); - - bool parseSuccessful; - - auto start = std::chrono::steady_clock::now(); - int fileListSize = fileList.size(); - Globals::Instance->singleThreaded = false; - - for (int i = 0; i < fileListSize; i++) - Globals::Instance->workerData[i] = new FileWorker(); - - numWorkersLeft = fileListSize; - - for (int i = 0; i < fileListSize; i++) - { - if (Globals::Instance->singleThreaded) - { - ExtractFunc(i, fileList.size(), fileList[i], fileMode); - } - else - { - std::string fileListItem = fileList[i]; - pool.push([i, fileListSize, fileListItem, fileMode](int) { - ExtractFunc(i, fileListSize, fileListItem, fileMode); - }); - } - } - - if (!Globals::Instance->singleThreaded) - { - while (true) - { - if (numWorkersLeft <= 0) - break; - - std::this_thread::sleep_for(std::chrono::milliseconds(250)); - } - } - - auto end = std::chrono::steady_clock::now(); - auto diff = - std::chrono::duration_cast(end - start).count(); - - printf("Generated OTR File Data in %i seconds\n", diff); - } - else - { - bool parseSuccessful; - - for (auto& extFile : Globals::Instance->cfg.externalFiles) - { - fs::path externalXmlFilePath = - Globals::Instance->cfg.externalXmlFolder / extFile.xmlPath; - - if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_INFO) - { - printf("Parsing external file from config: '%s'\n", - externalXmlFilePath.c_str()); - } - - parseSuccessful = Parse(externalXmlFilePath, Globals::Instance->baseRomPath, - extFile.outPath, ZFileMode::ExternalFile, 0); - - if (!parseSuccessful) - return 1; - } - - parseSuccessful = - Parse(Globals::Instance->inputPath, Globals::Instance->baseRomPath, - Globals::Instance->outputPath, fileMode, 0); - if (!parseSuccessful) - return 1; - } - } - } - else if (fileMode == ZFileMode::BuildTexture) - { - TextureType texType = Globals::Instance->texType; - BuildAssetTexture(Globals::Instance->inputPath, texType, Globals::Instance->outputPath); - } - else if (fileMode == ZFileMode::BuildBackground) - { - BuildAssetBackground(Globals::Instance->inputPath, Globals::Instance->outputPath); - } - else if (fileMode == ZFileMode::BuildBlob) - { - BuildAssetBlob(Globals::Instance->inputPath, Globals::Instance->outputPath); - } - - if (exporterSet != nullptr && exporterSet->endProgramFunc != nullptr) - exporterSet->endProgramFunc(); - -end: - delete exporterSet; - - //Globals::Instance->GetExporterSet() = nullptr; //TODO NULL this out. Compiler complains about lvalue assignment. - - delete g; - return 0; -} - -int ExtractFunc(int workerID, int fileListSize, std::string fileListItem, ZFileMode fileMode) -{ - bool parseSuccessful; - - printf("(%i / %i): %s\n", (workerID + 1), fileListSize, fileListItem.c_str()); - - for (auto& extFile : Globals::Instance->cfg.externalFiles) - { - fs::path externalXmlFilePath = Globals::Instance->cfg.externalXmlFolder / extFile.xmlPath; - - if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_INFO) - { - printf("Parsing external file from config: '%s'\n", externalXmlFilePath.c_str()); - } - - parseSuccessful = Parse(externalXmlFilePath, Globals::Instance->baseRomPath, - extFile.outPath, ZFileMode::ExternalFile, workerID); - - if (!parseSuccessful) - return 1; - } - - parseSuccessful = Parse(fileListItem, Globals::Instance->baseRomPath, - Globals::Instance->outputPath, fileMode, workerID); - - if (!parseSuccessful) - return 1; - - if (Globals::Instance->singleThreaded) - { - for (int i = 0; i < Globals::Instance->files.size(); i++) - { - delete Globals::Instance->files[i]; - Globals::Instance->files.erase(Globals::Instance->files.begin() + i); - i--; - } - - Globals::Instance->externalFiles.clear(); - Globals::Instance->segments.clear(); - Globals::Instance->cfg.segmentRefFiles.clear(); - } - else - { - for (int i = 0; i < Globals::Instance->workerData[workerID]->files.size(); i++) - { - delete Globals::Instance->workerData[workerID]->files[i]; - Globals::Instance->workerData[workerID]->files.erase( - Globals::Instance->workerData[workerID]->files.begin() + - i); - i--; - } - - Globals::Instance->workerData[workerID]->externalFiles.clear(); - Globals::Instance->workerData[workerID]->segments.clear(); - Globals::Instance->workerData[workerID]->segmentRefFiles.clear(); - - numWorkersLeft--; - } - return 0; -} - -bool Parse(const fs::path& xmlFilePath, const fs::path& basePath, const fs::path& outPath, - ZFileMode fileMode, int workerID) -{ - tinyxml2::XMLDocument doc; - tinyxml2::XMLError eResult = doc.LoadFile(xmlFilePath.string().c_str()); - - if (eResult != tinyxml2::XML_SUCCESS) - { - // TODO: use XMLDocument::ErrorIDToName to get more specific error messages here - HANDLE_ERROR(WarningType::InvalidXML, - StringHelper::Sprintf("invalid XML file: '%s'", xmlFilePath.c_str()), ""); - return false; - } - - tinyxml2::XMLNode* root = doc.FirstChild(); - - if (root == nullptr) - { - HANDLE_WARNING( - WarningType::InvalidXML, - StringHelper::Sprintf("missing Root tag in xml file: '%s'", xmlFilePath.c_str()), ""); - return false; - } - - for (tinyxml2::XMLElement* child = root->FirstChildElement(); child != NULL; - child = child->NextSiblingElement()) - { - if (std::string_view(child->Name()) == "File") - { - ZFile* file = new ZFile(fileMode, child, basePath, outPath, "", xmlFilePath, workerID); - Globals::Instance->AddFile(file, workerID); - if (fileMode == ZFileMode::ExternalFile) - { - Globals::Instance->AddExternalFile(file, workerID); - file->isExternalFile = true; - } - } - else if (std::string(child->Name()) == "ExternalFile") - { - const char* xmlPathValue = child->Attribute("XmlPath"); - if (xmlPathValue == nullptr) - { - throw std::runtime_error(StringHelper::Sprintf( - "Parse: Fatal error in '%s'.\n" - "\t Missing 'XmlPath' attribute in `ExternalFile` element.\n", - xmlFilePath.c_str())); - } - const char* outPathValue = child->Attribute("OutPath"); - if (outPathValue == nullptr) - { - throw std::runtime_error(StringHelper::Sprintf( - "Parse: Fatal error in '%s'.\n" - "\t Missing 'OutPath' attribute in `ExternalFile` element.\n", - xmlFilePath.c_str())); - } - - fs::path externalXmlFilePath = - Globals::Instance->cfg.externalXmlFolder / fs::path(xmlPathValue); - fs::path externalOutFilePath = fs::path(outPathValue); - - if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_INFO) - { - printf("Parsing external file: '%s'\n", externalXmlFilePath.c_str()); - } - - // Recursion. What can go wrong? - Parse(externalXmlFilePath, basePath, externalOutFilePath, ZFileMode::ExternalFile, workerID); - } - else - { - std::string errorHeader = - StringHelper::Sprintf("when parsing file '%s'", xmlFilePath.c_str()); - std::string errorBody = StringHelper::Sprintf( - "Found a resource outside a File element: '%s'", child->Name()); - HANDLE_ERROR(WarningType::InvalidXML, errorHeader, errorBody); - } - } - - if (fileMode != ZFileMode::ExternalFile) - { - ExporterSet* exporterSet = Globals::Instance->GetExporterSet(); - - if (exporterSet != nullptr && exporterSet->beginXMLFunc != nullptr) - exporterSet->beginXMLFunc(); - - std::vector files; - - if (Globals::Instance->singleThreaded) - files = Globals::Instance->files; - else - files = Globals::Instance->workerData[workerID]->files; - - for (ZFile* file : files) - { - if (fileMode == ZFileMode::BuildSourceFile) - file->BuildSourceFile(); - else - file->ExtractResources(); - } - - if (exporterSet != nullptr && exporterSet->endXMLFunc != nullptr) - exporterSet->endXMLFunc(); - } - - return true; -} - -void BuildAssetTexture(const fs::path& pngFilePath, TextureType texType, const fs::path& outPath) -{ - return Globals::Instance->BuildAssetTexture(pngFilePath, texType, outPath); -} - -void BuildAssetBackground(const fs::path& imageFilePath, const fs::path& outPath) -{ - ZBackground background(nullptr); - background.ParseBinaryFile(imageFilePath.string(), false); - - DiskFile::WriteAllText(outPath.string(), background.GetBodySourceCode()); -} - -void BuildAssetBlob(const fs::path& blobFilePath, const fs::path& outPath) -{ - ZBlob* blob = ZBlob::FromFile(blobFilePath.string()); - std::string name = outPath.stem().string(); // filename without extension - - std::string src = blob->GetBodySourceCode(); - - DiskFile::WriteAllText(outPath.string(), src); - - delete blob; -} diff --git a/ZAPDTR/ZAPD/NuGet/libpng.static.txt b/ZAPDTR/ZAPD/NuGet/libpng.static.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/ZAPDTR/ZAPD/OtherStructs/CutsceneMM_Commands.cpp b/ZAPDTR/ZAPD/OtherStructs/CutsceneMM_Commands.cpp deleted file mode 100644 index edefbc051..000000000 --- a/ZAPDTR/ZAPD/OtherStructs/CutsceneMM_Commands.cpp +++ /dev/null @@ -1,213 +0,0 @@ -#include "CutsceneMM_Commands.h" - -#include -#include - -#include "Utils/BitConverter.h" -#include "Utils/StringHelper.h" - -// Specific for command lists where each entry has size 8 bytes -const std::unordered_map csCommandsDescMM = { - {CutsceneMMCommands::CS_CMD_MISC, {"CS_MISC", "(0x%02X, %i, %i, %i)"}}, - {CutsceneMMCommands::CS_CMD_SET_LIGHTING, {"CS_LIGHTING", "(0x%02X, %i, %i)"}}, - {CutsceneMMCommands::CS_CMD_SCENE_TRANS_FX, {"CS_SCENE_TRANS_FX", "(%i, %i, %i)"}}, - {CutsceneMMCommands::CS_CMD_MOTIONBLUR, {"CS_MOTIONBLUR", "(%i, %i, %i)"}}, - {CutsceneMMCommands::CS_CMD_GIVETATL, {"CS_GIVETATL", "(%i, %i, %i)"}}, - {CutsceneMMCommands::CS_CMD_PLAYSEQ, {"CS_PLAYSEQ", "(0x%04X, %i, %i)"}}, - {CutsceneMMCommands::CS_CMD_130, {"CS_SCENE_UNK_130", "(0x%04X, %i, %i, %i)"}}, - {CutsceneMMCommands::CS_CMD_131, {"CS_SCENE_UNK_131", "(0x%04X, %i, %i, %i)"}}, - {CutsceneMMCommands::CS_CMD_132, {"CS_SCENE_UNK_132", "(%i, %i, %i)"}}, - {CutsceneMMCommands::CS_CMD_STOPSEQ, {"CS_STOPSEQ", "(0x%04X, %i, %i, %i)"}}, - {CutsceneMMCommands::CS_CMD_PLAYAMBIENCE, {"CS_PLAYAMBIENCE", "(0x%04X, %i, %i, %i)"}}, - {CutsceneMMCommands::CS_CMD_FADEAMBIENCE, {"CS_FADEAMBIENCE", "(0x%04X, %i, %i, %i)"}}, - {CutsceneMMCommands::CS_CMD_TERMINATOR, {"CS_TERMINATOR", "(%i, %i, %i)"}}, - {CutsceneMMCommands::CS_CMD_CHOOSE_CREDITS_SCENES, - {"CS_CHOOSE_CREDITS_SCENES", "(%i, %i, %i)"}}, -}; - -CutsceneSubCommandEntry_GenericMMCmd::CutsceneSubCommandEntry_GenericMMCmd( - const std::vector& rawData, offset_t rawDataIndex, CutsceneMMCommands cmdId) - : CutsceneSubCommandEntry(rawData, rawDataIndex), commandId(cmdId) -{ -} - -std::string CutsceneSubCommandEntry_GenericMMCmd::GetBodySourceCode() const -{ - const auto& element = csCommandsDescMM.find(commandId); - std::string entryFmt = "CS_UNK_DATA(0x%02X, %i, %i, %i)"; - - if (element != csCommandsDescMM.end()) - { - entryFmt = element->second.cmdMacro; - entryFmt += element->second.args; - } - - return StringHelper::Sprintf(entryFmt.c_str(), base, startFrame, endFrame, pad); -} - -CutsceneMMCommand_GenericCmd::CutsceneMMCommand_GenericCmd(const std::vector& rawData, - offset_t rawDataIndex, - CutsceneMMCommands cmdId) - : CutsceneCommand(rawData, rawDataIndex) -{ - rawDataIndex += 4; - - commandID = static_cast(cmdId); - - entries.reserve(numEntries); - for (size_t i = 0; i < numEntries; i++) - { - auto* entry = new CutsceneSubCommandEntry_GenericMMCmd(rawData, rawDataIndex, cmdId); - entries.push_back(entry); - rawDataIndex += entry->GetRawSize(); - } -} - -std::string CutsceneMMCommand_GenericCmd::GetCommandMacro() const -{ - const auto& element = csCommandsDescMM.find(static_cast(commandID)); - - if (element != csCommandsDescMM.end()) - { - return StringHelper::Sprintf("%s_LIST(%i)", element->second.cmdMacro, numEntries); - } - - return StringHelper::Sprintf("CS_UNK_DATA_LIST(0x%X, %i)", commandID, numEntries); -} - -CutsceneSubCommandEntry_Camera::CutsceneSubCommandEntry_Camera(const std::vector& rawData, - offset_t rawDataIndex) - : CutsceneSubCommandEntry(rawData, rawDataIndex) -{ -} - -std::string CutsceneSubCommandEntry_Camera::GetBodySourceCode() const -{ - return StringHelper::Sprintf("CMD_HH(0x%04X, 0x%04X)", base, startFrame); -} - -size_t CutsceneSubCommandEntry_Camera::GetRawSize() const -{ - return 0x04; -} - -CutsceneMMCommand_Camera::CutsceneMMCommand_Camera(const std::vector& rawData, - offset_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - rawDataIndex += 4; - - entries.reserve(numEntries); - for (size_t i = 0; i < numEntries / 4; i++) - { - auto* entry = new CutsceneSubCommandEntry_Camera(rawData, rawDataIndex); - entries.push_back(entry); - rawDataIndex += entry->GetRawSize(); - } -} - -std::string CutsceneMMCommand_Camera::GetCommandMacro() const -{ - return StringHelper::Sprintf("CS_CAMERA_LIST(%i)", numEntries); -} - -CutsceneSubCommandEntry_FadeScreen::CutsceneSubCommandEntry_FadeScreen( - const std::vector& rawData, offset_t rawDataIndex) - : CutsceneSubCommandEntry(rawData, rawDataIndex) -{ - unk_06 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x06); - unk_07 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x07); - unk_08 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x08); - unk_09 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x09); - unk_0A = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x0A); - unk_0B = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x0B); -} - -std::string CutsceneSubCommandEntry_FadeScreen::GetBodySourceCode() const -{ - return StringHelper::Sprintf("CS_FADESCREEN(0x%02X, %i, %i, %i, %i, %i)", base, startFrame, - endFrame, unk_06, unk_07, unk_08); -} - -size_t CutsceneSubCommandEntry_FadeScreen::GetRawSize() const -{ - return 0x0C; -} - -CutsceneMMCommand_FadeScreen::CutsceneMMCommand_FadeScreen(const std::vector& rawData, - offset_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - rawDataIndex += 4; - - entries.reserve(numEntries); - for (size_t i = 0; i < numEntries; i++) - { - auto* entry = new CutsceneSubCommandEntry_FadeScreen(rawData, rawDataIndex); - entries.push_back(entry); - rawDataIndex += entry->GetRawSize(); - } -} - -std::string CutsceneMMCommand_FadeScreen::GetCommandMacro() const -{ - return StringHelper::Sprintf("CS_FADESCREEN_LIST(%i)", numEntries); -} - -CutsceneSubCommandEntry_FadeSeq::CutsceneSubCommandEntry_FadeSeq( - const std::vector& rawData, offset_t rawDataIndex) - : CutsceneSubCommandEntry(rawData, rawDataIndex) -{ - unk_08 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 8); -} - -std::string CutsceneSubCommandEntry_FadeSeq::GetBodySourceCode() const -{ - return StringHelper::Sprintf("CS_FADESEQ(%i, %i, %i)", base, startFrame, endFrame); -} - -size_t CutsceneSubCommandEntry_FadeSeq::GetRawSize() const -{ - return 0x0C; -} - -CutsceneMMCommand_FadeSeq::CutsceneMMCommand_FadeSeq(const std::vector& rawData, - offset_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - rawDataIndex += 4; - - entries.reserve(numEntries); - for (size_t i = 0; i < numEntries; i++) - { - auto* entry = new CutsceneSubCommandEntry_FadeSeq(rawData, rawDataIndex); - entries.push_back(entry); - rawDataIndex += entry->GetRawSize(); - } -} - -std::string CutsceneMMCommand_FadeSeq::GetCommandMacro() const -{ - return StringHelper::Sprintf("CS_FADESEQ_LIST(%i)", numEntries); -} - -CutsceneSubCommandEntry_NonImplemented::CutsceneSubCommandEntry_NonImplemented( - const std::vector& rawData, offset_t rawDataIndex) - : CutsceneSubCommandEntry(rawData, rawDataIndex) -{ -} - -CutsceneMMCommand_NonImplemented::CutsceneMMCommand_NonImplemented( - const std::vector& rawData, offset_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - rawDataIndex += 4; - - entries.reserve(numEntries); - for (size_t i = 0; i < numEntries; i++) - { - auto* entry = new CutsceneSubCommandEntry_NonImplemented(rawData, rawDataIndex); - entries.push_back(entry); - rawDataIndex += entry->GetRawSize(); - } -} diff --git a/ZAPDTR/ZAPD/OtherStructs/CutsceneMM_Commands.h b/ZAPDTR/ZAPD/OtherStructs/CutsceneMM_Commands.h deleted file mode 100644 index c8ae4eb60..000000000 --- a/ZAPDTR/ZAPD/OtherStructs/CutsceneMM_Commands.h +++ /dev/null @@ -1,140 +0,0 @@ -#pragma once - -#include "Cutscene_Commands.h" - -enum class CutsceneMMCommands -{ - /* 0x00A */ CS_CMD_TEXTBOX = 0xA, - /* 0x05A */ CS_CMD_CAMERA = 0x5A, - /* 0x096 */ CS_CMD_MISC = 0x96, - /* 0x097 */ CS_CMD_SET_LIGHTING, - /* 0x098 */ CS_CMD_SCENE_TRANS_FX, - /* 0x099 */ CS_CMD_MOTIONBLUR, - /* 0x09A */ CS_CMD_GIVETATL, - /* 0x09B */ CS_CMD_FADESCREEN, - /* 0x09C */ CS_CMD_FADESEQ, - /* 0x09D */ CS_CMD_SETTIME, - /* 0x0C8 */ CS_CMD_SET_PLAYER_ACTION = 0xC8, - /* 0x0FA */ CS_CMD_UNK_FA = 0xFA, - /* 0x0FE */ CS_CMD_UNK_FE = 0xFE, - /* 0x0FF */ CS_CMD_UNK_FF, - /* 0x100 */ CS_CMD_UNK_100, - /* 0x101 */ CS_CMD_UNK_101, - /* 0x102 */ CS_CMD_UNK_102, - /* 0x103 */ CS_CMD_UNK_103, - /* 0x104 */ CS_CMD_UNK_104, - /* 0x105 */ CS_CMD_UNK_105, - /* 0x108 */ CS_CMD_UNK_108 = 0x108, - /* 0x109 */ CS_CMD_UNK_109, - /* 0x12C */ CS_CMD_PLAYSEQ = 0x12C, - /* 0x12D */ CS_CMD_UNK_12D, - /* 0x130 */ CS_CMD_130 = 0x130, - /* 0x131 */ CS_CMD_131 = 0x131, - /* 0x132 */ CS_CMD_132 = 0x132, - /* 0x133 */ CS_CMD_STOPSEQ, - /* 0x134 */ CS_CMD_PLAYAMBIENCE, - /* 0x135 */ CS_CMD_FADEAMBIENCE, - /* 0x15E */ CS_CMD_TERMINATOR = 0x15E, - /* 0x15F */ CS_CMD_CHOOSE_CREDITS_SCENES, - /* 0x190 */ CS_CMD_RUMBLE = 0x190, -}; - -class CutsceneSubCommandEntry_GenericMMCmd : public CutsceneSubCommandEntry -{ -public: - CutsceneMMCommands commandId; - - CutsceneSubCommandEntry_GenericMMCmd(const std::vector& rawData, offset_t rawDataIndex, - CutsceneMMCommands cmdId); - - std::string GetBodySourceCode() const override; -}; - -class CutsceneMMCommand_GenericCmd : public CutsceneCommand -{ -public: - CutsceneMMCommand_GenericCmd(const std::vector& rawData, offset_t rawDataIndex, - CutsceneMMCommands cmdId); - - std::string GetCommandMacro() const override; -}; - -// TODO: MM cutscene camera command is implemented as a placeholder until we better understand how -// it works -class CutsceneSubCommandEntry_Camera : public CutsceneSubCommandEntry -{ -public: - uint32_t unk_08; - - CutsceneSubCommandEntry_Camera(const std::vector& rawData, offset_t rawDataIndex); - - std::string GetBodySourceCode() const override; - - size_t GetRawSize() const override; -}; - -class CutsceneMMCommand_Camera : public CutsceneCommand -{ -public: - CutsceneMMCommand_Camera(const std::vector& rawData, offset_t rawDataIndex); - - std::string GetCommandMacro() const override; -}; - -class CutsceneSubCommandEntry_FadeScreen : public CutsceneSubCommandEntry -{ -public: - uint8_t unk_06; - uint8_t unk_07; - uint8_t unk_08; - uint8_t unk_09; - uint8_t unk_0A; - uint8_t unk_0B; - - CutsceneSubCommandEntry_FadeScreen(const std::vector& rawData, offset_t rawDataIndex); - - std::string GetBodySourceCode() const override; - - size_t GetRawSize() const override; -}; - -class CutsceneMMCommand_FadeScreen : public CutsceneCommand -{ -public: - CutsceneMMCommand_FadeScreen(const std::vector& rawData, offset_t rawDataIndex); - - std::string GetCommandMacro() const override; -}; - -class CutsceneSubCommandEntry_FadeSeq : public CutsceneSubCommandEntry -{ -public: - uint32_t unk_08; - - CutsceneSubCommandEntry_FadeSeq(const std::vector& rawData, offset_t rawDataIndex); - - std::string GetBodySourceCode() const override; - - size_t GetRawSize() const override; -}; - -class CutsceneMMCommand_FadeSeq : public CutsceneCommand -{ -public: - CutsceneMMCommand_FadeSeq(const std::vector& rawData, offset_t rawDataIndex); - - std::string GetCommandMacro() const override; -}; - -class CutsceneSubCommandEntry_NonImplemented : public CutsceneSubCommandEntry -{ -public: - CutsceneSubCommandEntry_NonImplemented(const std::vector& rawData, - offset_t rawDataIndex); -}; - -class CutsceneMMCommand_NonImplemented : public CutsceneCommand -{ -public: - CutsceneMMCommand_NonImplemented(const std::vector& rawData, offset_t rawDataIndex); -}; diff --git a/ZAPDTR/ZAPD/OtherStructs/Cutscene_Commands.cpp b/ZAPDTR/ZAPD/OtherStructs/Cutscene_Commands.cpp deleted file mode 100644 index 8ae4c69d7..000000000 --- a/ZAPDTR/ZAPD/OtherStructs/Cutscene_Commands.cpp +++ /dev/null @@ -1,596 +0,0 @@ -#include "Cutscene_Commands.h" - -#include -#include - -#include "CutsceneMM_Commands.h" -#include "Globals.h" -#include "Utils/BitConverter.h" -#include "Utils/StringHelper.h" - -/* CutsceneSubCommandEntry */ - -CutsceneSubCommandEntry::CutsceneSubCommandEntry(const std::vector& rawData, - offset_t rawDataIndex) -{ - base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); - pad = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); -} - -std::string CutsceneSubCommandEntry::GetBodySourceCode() const -{ - return StringHelper::Sprintf("CMD_HH(0x%04X, 0x%04X), CMD_HH(0x%04X, 0x%04X)", base, startFrame, - endFrame, pad); -} - -size_t CutsceneSubCommandEntry::GetRawSize() const -{ - return 0x08; -} - -/* CutsceneCommand */ - -CutsceneCommand::CutsceneCommand(const std::vector& rawData, offset_t rawDataIndex) -{ - numEntries = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0); -} - -CutsceneCommand::~CutsceneCommand() -{ - for (auto& entry : entries) - { - delete entry; - } -} - -std::string CutsceneCommand::GetCommandMacro() const -{ - return StringHelper::Sprintf("CMD_W(0x%08X), CMD_W(0x%08X)", commandID, numEntries); -} - -std::string CutsceneCommand::GenerateSourceCode() const -{ - std::string result; - - result += GetCommandMacro(); - result += ",\n"; - - for (auto& entry : entries) - { - result += " "; - result += entry->GetBodySourceCode(); - result += ",\n"; - } - - return result; -} - -size_t CutsceneCommand::GetCommandSize() const -{ - size_t size = 0; - if (entries.size() > 0) - { - size = entries.at(0)->GetRawSize() * entries.size(); - } - else - { - size = 0x08 * numEntries; - } - return 0x08 + size; -} - -void CutsceneCommand::SetCommandID(uint32_t nCommandID) -{ - commandID = nCommandID; - - for (auto& entry : entries) - { - entry->commandID = commandID; - } -} - -// Specific for command lists where each entry has size 0x30 bytes -const std::unordered_map csCommandsDesc = { - {CutsceneCommands::Misc, - {"CS_MISC", "(0x%04X, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i)"}}, - {CutsceneCommands::SetLighting, - {"CS_LIGHTING", "(0x%02X, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i)"}}, - {CutsceneCommands::PlayBGM, {"CS_PLAY_BGM", "(%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i)"}}, - {CutsceneCommands::StopBGM, {"CS_STOP_BGM", "(%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i)"}}, - {CutsceneCommands::FadeBGM, {"CS_FADE_BGM", "(%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i)"}}, -}; - -CutsceneSubCommandEntry_GenericCmd::CutsceneSubCommandEntry_GenericCmd( - const std::vector& rawData, offset_t rawDataIndex, CutsceneCommands cmdId) - : CutsceneSubCommandEntry(rawData, rawDataIndex), commandId(cmdId) -{ - word0 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x0); - word1 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x4); - - unused1 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x8); - unused2 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0xC); - unused3 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x10); - unused4 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x14); - unused5 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x18); - unused6 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x1C); - unused7 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x20); - unused8 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x24); - unused9 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x28); - unused10 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x2C); -} - -std::string CutsceneSubCommandEntry_GenericCmd::GetBodySourceCode() const -{ - const auto& element = csCommandsDesc.find(commandId); - - if (element != csCommandsDesc.end()) - { - std::string entryFmt = element->second.cmdMacro; - entryFmt += element->second.args; - - return StringHelper::Sprintf(entryFmt.c_str(), base, startFrame, endFrame, pad, unused1, - unused2, unused3, unused4, unused5, unused6, unused7, unused8, - unused9, unused10); - } - - return StringHelper::Sprintf("CS_UNK_DATA(0x%08X, 0x%08X, 0x%08X, 0x%08X, 0x%08X, 0x%08X, " - "0x%08X, 0x%08X, 0x%08X, 0x%08X, 0x%08X, 0x%08X)", - word0, word1, unused1, unused2, unused3, unused4, unused5, unused6, - unused7, unused8, unused9, unused10); -} - -size_t CutsceneSubCommandEntry_GenericCmd::GetRawSize() const -{ - return 0x30; -} - -CutsceneCommand_GenericCmd::CutsceneCommand_GenericCmd(const std::vector& rawData, - offset_t rawDataIndex, - CutsceneCommands cmdId) - : CutsceneCommand(rawData, rawDataIndex) -{ - rawDataIndex += 4; - - commandID = static_cast(cmdId); - entries.reserve(numEntries); - - for (size_t i = 0; i < numEntries; i++) - { - auto* entry = new CutsceneSubCommandEntry_GenericCmd(rawData, rawDataIndex, cmdId); - entries.push_back(entry); - rawDataIndex += entry->GetRawSize(); - } -} - -std::string CutsceneCommand_GenericCmd::GetCommandMacro() const -{ - const auto& element = csCommandsDesc.find(static_cast(commandID)); - - if (element != csCommandsDesc.end()) - { - return StringHelper::Sprintf("%s_LIST(%i)", element->second.cmdMacro, numEntries); - } - - return StringHelper::Sprintf("CS_UNK_DATA_LIST(0x%X, %i)", commandID, numEntries); -} - -CutsceneCameraPoint::CutsceneCameraPoint(const std::vector& rawData, offset_t rawDataIndex) - : CutsceneSubCommandEntry(rawData, rawDataIndex) -{ - continueFlag = BitConverter::ToInt8BE(rawData, rawDataIndex + 0); - cameraRoll = BitConverter::ToInt8BE(rawData, rawDataIndex + 1); - nextPointFrame = BitConverter::ToInt16BE(rawData, rawDataIndex + 2); - viewAngle = BitConverter::ToFloatBE(rawData, rawDataIndex + 4); - - posX = BitConverter::ToInt16BE(rawData, rawDataIndex + 8); - posY = BitConverter::ToInt16BE(rawData, rawDataIndex + 10); - posZ = BitConverter::ToInt16BE(rawData, rawDataIndex + 12); - - unused = BitConverter::ToInt16BE(rawData, rawDataIndex + 14); -} - -std::string CutsceneCameraPoint::GetBodySourceCode() const -{ - std::string result = ""; - - if (commandID == (int32_t)CutsceneCommands::SetCameraFocus) - { - result += "CS_CAM_FOCUS_POINT"; - } - else if (commandID == (int32_t)CutsceneCommands::SetCameraFocusLink) - { - result += "CS_CAM_FOCUS_POINT_PLAYER"; - } - else if (commandID == (int32_t)CutsceneCommands::SetCameraPosLink) - { - result += "CS_CAM_POS_PLAYER"; - } - else - { - result += "CS_CAM_POS"; - } - - std::string continueMacro = "CS_CMD_CONTINUE"; - if (continueFlag != 0) - continueMacro = "CS_CMD_STOP"; - - result += - StringHelper::Sprintf("(%s, 0x%02X, %i, %ff, %i, %i, %i, 0x%04X)", continueMacro.c_str(), - cameraRoll, nextPointFrame, viewAngle, posX, posY, posZ, unused); - return result; -} - -size_t CutsceneCameraPoint::GetRawSize() const -{ - return 0x10; -} - -CutsceneCommandSetCameraPos::CutsceneCommandSetCameraPos(const std::vector& rawData, - offset_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); - unused = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); - - bool shouldContinue = true; - - uint32_t currentPtr = rawDataIndex + 8; - - while (shouldContinue) - { - CutsceneCameraPoint* camPoint = new CutsceneCameraPoint(rawData, currentPtr); - entries.push_back(camPoint); - - if (camPoint->continueFlag == -1) - shouldContinue = false; - - currentPtr += camPoint->GetRawSize(); - } -} - -std::string CutsceneCommandSetCameraPos::GetCommandMacro() const -{ - std::string result; - - std::string listStr; - - if (commandID == (int32_t)CutsceneCommands::SetCameraFocus) - { - listStr = "CS_CAM_FOCUS_POINT_LIST"; - } - else if (commandID == (int32_t)CutsceneCommands::SetCameraFocusLink) - { - listStr = "CS_CAM_FOCUS_POINT_PLAYER_LIST"; - } - else if (commandID == (int32_t)CutsceneCommands::SetCameraPosLink) - { - listStr = "CS_CAM_POS_PLAYER_LIST"; - } - else - { - listStr = "CS_CAM_POS_LIST"; - } - - result += StringHelper::Sprintf("%s(%i, %i)", listStr.c_str(), startFrame, endFrame); - - return result; -} - -size_t CutsceneCommandSetCameraPos::GetCommandSize() const -{ - return 0x0C + entries.at(0)->GetRawSize() * entries.size(); -} - -CutsceneSubCommandEntry_Rumble::CutsceneSubCommandEntry_Rumble(const std::vector& rawData, - offset_t rawDataIndex) - : CutsceneSubCommandEntry(rawData, rawDataIndex) -{ - unk_06 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x06); - unk_07 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x07); - unk_08 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x08); - unk_09 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x09); - unk_0A = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x0A); - unk_0B = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x0B); -} - -std::string CutsceneSubCommandEntry_Rumble::GetBodySourceCode() const -{ - if (Globals::Instance->game == ZGame::MM_RETAIL) - { - return StringHelper::Sprintf("CS_RUMBLE(%i, %i, %i, 0x%02X, 0x%02X, 0x%02X)", base, - startFrame, endFrame, unk_06, unk_07, unk_08); - } - - return StringHelper::Sprintf("CS_CMD_09(%i, %i, %i, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X)", - base, startFrame, endFrame, unk_06, unk_07, unk_08, unk_09, unk_0A, - unk_0B); -} - -size_t CutsceneSubCommandEntry_Rumble::GetRawSize() const -{ - return 0x0C; -} - -CutsceneCommand_Rumble::CutsceneCommand_Rumble(const std::vector& rawData, - offset_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - rawDataIndex += 4; - - entries.reserve(numEntries); - for (size_t i = 0; i < numEntries; i++) - { - auto* entry = new CutsceneSubCommandEntry_Rumble(rawData, rawDataIndex); - entries.push_back(entry); - rawDataIndex += entry->GetRawSize(); - } -} - -std::string CutsceneCommand_Rumble::GetCommandMacro() const -{ - if (Globals::Instance->game == ZGame::MM_RETAIL) - { - return StringHelper::Sprintf("CS_RUMBLE_LIST(%i)", numEntries); - } - return StringHelper::Sprintf("CS_CMD_09_LIST(%i)", numEntries); -} - -CutsceneSubCommandEntry_SetTime::CutsceneSubCommandEntry_SetTime( - const std::vector& rawData, offset_t rawDataIndex) - : CutsceneSubCommandEntry(rawData, rawDataIndex) -{ - hour = BitConverter::ToUInt8BE(rawData, rawDataIndex + 6); - minute = BitConverter::ToUInt8BE(rawData, rawDataIndex + 7); - unk_08 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 8); -} - -std::string CutsceneSubCommandEntry_SetTime::GetBodySourceCode() const -{ - return StringHelper::Sprintf("CS_TIME(%i, %i, %i, %i, %i, %i)", base, startFrame, endFrame, - hour, minute, unk_08); -} - -size_t CutsceneSubCommandEntry_SetTime::GetRawSize() const -{ - return 0x0C; -} - -CutsceneCommand_SetTime::CutsceneCommand_SetTime(const std::vector& rawData, - offset_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - rawDataIndex += 4; - - entries.reserve(numEntries); - for (size_t i = 0; i < numEntries; i++) - { - auto* entry = new CutsceneSubCommandEntry_SetTime(rawData, rawDataIndex); - entries.push_back(entry); - rawDataIndex += entry->GetRawSize(); - } -} - -std::string CutsceneCommand_SetTime::GetCommandMacro() const -{ - return StringHelper::Sprintf("CS_TIME_LIST(%i)", numEntries); -} - -CutsceneSubCommandEntry_TextBox::CutsceneSubCommandEntry_TextBox( - const std::vector& rawData, offset_t rawDataIndex) - : CutsceneSubCommandEntry(rawData, rawDataIndex) -{ - type = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x6); - textId1 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x8); - textId2 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0xA); -} - -std::string CutsceneSubCommandEntry_TextBox::GetBodySourceCode() const -{ - if (type == 0xFFFF) - { - return StringHelper::Sprintf("CS_TEXT_NONE(%i, %i)", startFrame, endFrame); - } - if (type == 2) - { - return StringHelper::Sprintf("CS_TEXT_LEARN_SONG(%i, %i, %i, 0x%X)", base, startFrame, - endFrame, textId1); - } - - if (Globals::Instance->game == ZGame::MM_RETAIL) - { - switch (type) - { - case 0: - return StringHelper::Sprintf("CS_TEXT_DEFAULT(0x%X, %i, %i, 0x%X, 0x%X)", base, - startFrame, endFrame, textId1, textId2); - - case 1: - return StringHelper::Sprintf("CS_TEXT_TYPE_1(0x%X, %i, %i, 0x%X, 0x%X)", base, - startFrame, endFrame, textId1, textId2); - - case 3: - return StringHelper::Sprintf("CS_TEXT_TYPE_3(0x%X, %i, %i, 0x%X, 0x%X)", base, - startFrame, endFrame, textId1, textId2); - - case 4: - return StringHelper::Sprintf("CS_TEXT_BOSSES_REMAINS(0x%X, %i, %i, 0x%X)", base, - startFrame, endFrame, textId1); - - case 5: - return StringHelper::Sprintf("CS_TEXT_ALL_NORMAL_MASKS(0x%X, %i, %i, 0x%X)", base, - startFrame, endFrame, textId1); - } - } - - return StringHelper::Sprintf("CS_TEXT_DISPLAY_TEXTBOX(0x%X, %i, %i, %i, 0x%X, 0x%X)", base, - startFrame, endFrame, type, textId1, textId2); -} - -size_t CutsceneSubCommandEntry_TextBox::GetRawSize() const -{ - return 0x0C; -} - -CutsceneCommand_TextBox::CutsceneCommand_TextBox(const std::vector& rawData, - offset_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - rawDataIndex += 4; - - entries.reserve(numEntries); - for (size_t i = 0; i < numEntries; i++) - { - auto* entry = new CutsceneSubCommandEntry_TextBox(rawData, rawDataIndex); - entries.push_back(entry); - rawDataIndex += entry->GetRawSize(); - } -} - -std::string CutsceneCommand_TextBox::GetCommandMacro() const -{ - return StringHelper::Sprintf("CS_TEXT_LIST(%i)", numEntries); -} - -CutsceneSubCommandEntry_ActorAction::CutsceneSubCommandEntry_ActorAction( - const std::vector& rawData, offset_t rawDataIndex) - : CutsceneSubCommandEntry(rawData, rawDataIndex) -{ - rotX = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x6); - rotY = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x8); - rotZ = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0xA); - startPosX = BitConverter::ToInt32BE(rawData, rawDataIndex + 0xC); - startPosY = BitConverter::ToInt32BE(rawData, rawDataIndex + 0x10); - startPosZ = BitConverter::ToInt32BE(rawData, rawDataIndex + 0x14); - endPosX = BitConverter::ToInt32BE(rawData, rawDataIndex + 0x18); - endPosY = BitConverter::ToInt32BE(rawData, rawDataIndex + 0x1C); - endPosZ = BitConverter::ToInt32BE(rawData, rawDataIndex + 0x20); - normalX = BitConverter::ToFloatBE(rawData, rawDataIndex + 0x24); - normalY = BitConverter::ToFloatBE(rawData, rawDataIndex + 0x28); - normalZ = BitConverter::ToFloatBE(rawData, rawDataIndex + 0x2C); -} - -std::string CutsceneSubCommandEntry_ActorAction::GetBodySourceCode() const -{ - std::string result; - - if (Globals::Instance->game == ZGame::MM_RETAIL) - { - if (static_cast(commandID) == - CutsceneMMCommands::CS_CMD_SET_PLAYER_ACTION) - { - result = "CS_PLAYER_ACTION"; - } - else - { - result = "CS_ACTOR_ACTION"; - } - } - else - { - if (static_cast(commandID) == CutsceneCommands::SetPlayerAction) - { - result = "CS_PLAYER_ACTION"; - } - else - { - result = "CS_NPC_ACTION"; - } - } - - result += - StringHelper::Sprintf("(%i, %i, %i, 0x%04X, 0x%04X, 0x%04X, %i, %i, " - "%i, %i, %i, %i, %.11ef, %.11ef, %.11ef)", - base, startFrame, endFrame, rotX, rotY, rotZ, startPosX, startPosY, - startPosZ, endPosX, endPosY, endPosZ, normalX, normalY, normalZ); - return result; -} - -size_t CutsceneSubCommandEntry_ActorAction::GetRawSize() const -{ - return 0x30; -} - -CutsceneCommand_ActorAction::CutsceneCommand_ActorAction(const std::vector& rawData, - offset_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - rawDataIndex += 4; - - entries.reserve(numEntries); - for (size_t i = 0; i < numEntries; i++) - { - auto* entry = new CutsceneSubCommandEntry_ActorAction(rawData, rawDataIndex); - entries.push_back(entry); - rawDataIndex += entry->GetRawSize(); - } -} - -std::string CutsceneCommand_ActorAction::GetCommandMacro() const -{ - if (Globals::Instance->game == ZGame::MM_RETAIL) - { - if (static_cast(commandID) == - CutsceneMMCommands::CS_CMD_SET_PLAYER_ACTION) - { - return StringHelper::Sprintf("CS_PLAYER_ACTION_LIST(%i)", numEntries); - } - return StringHelper::Sprintf("CS_ACTOR_ACTION_LIST(0x%03X, %i)", commandID, numEntries); - } - - if (static_cast(commandID) == CutsceneCommands::SetPlayerAction) - { - return StringHelper::Sprintf("CS_PLAYER_ACTION_LIST(%i)", entries.size()); - } - return StringHelper::Sprintf("CS_NPC_ACTION_LIST(0x%03X, %i)", commandID, entries.size()); -} - -CutsceneCommand_Terminator::CutsceneCommand_Terminator(const std::vector& rawData, - offset_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - rawDataIndex += 4; - - base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); - unknown = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); // endFrame duplicate -} - -std::string CutsceneCommand_Terminator::GenerateSourceCode() const -{ - std::string result; - - result += StringHelper::Sprintf("CS_TERMINATOR(%i, %i, %i),\n", base, startFrame, endFrame); - - return result; -} - -size_t CutsceneCommand_Terminator::GetCommandSize() const -{ - return 0x10; -} - -CutsceneCommandSceneTransFX::CutsceneCommandSceneTransFX(const std::vector& rawData, - offset_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - rawDataIndex += 4; - - base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); -} - -std::string CutsceneCommandSceneTransFX::GenerateSourceCode() const -{ - return StringHelper::Sprintf("CS_SCENE_TRANS_FX(%i, %i, %i),\n", base, startFrame, endFrame); -} - -size_t CutsceneCommandSceneTransFX::GetCommandSize() const -{ - return 0x10; -} diff --git a/ZAPDTR/ZAPD/OtherStructs/Cutscene_Commands.h b/ZAPDTR/ZAPD/OtherStructs/Cutscene_Commands.h deleted file mode 100644 index c46273587..000000000 --- a/ZAPDTR/ZAPD/OtherStructs/Cutscene_Commands.h +++ /dev/null @@ -1,267 +0,0 @@ -#pragma once - -#include -#include -#include - -#include "Declaration.h" - -enum class CutsceneCommands -{ - SetCameraPos = 0x0001, - SetCameraFocus = 0x0002, - Misc = 0x0003, - SetLighting = 0x0004, - SetCameraPosLink = 0x0005, - SetCameraFocusLink = 0x0006, - Cmd07 = 0x0007, - Cmd08 = 0x0008, - Cmd09 = 0x0009, // Rumble - Textbox = 0x0013, - SetPlayerAction = 0x000A, - SetActorAction1 = 0x000F, - SetActorAction2 = 0x000E, - SetActorAction3 = 0x0019, - SetActorAction4 = 0x001D, - SetActorAction5 = 0x001E, - SetActorAction6 = 0x002C, - SetActorAction7 = 0x001F, - SetActorAction8 = 0x0031, - SetActorAction9 = 0x003E, - SetActorAction10 = 0x008F, - SetSceneTransFX = 0x002D, - PlayBGM = 0x0056, - StopBGM = 0x0057, - FadeBGM = 0x007C, - SetTime = 0x008C, - Terminator = 0x03E8, -}; - -typedef struct CsCommandListDescriptor -{ - const char* cmdMacro; - const char* args; -} CsCommandListDescriptor; - -class CutsceneSubCommandEntry -{ -public: - uint16_t base; - uint16_t startFrame; - uint16_t endFrame; - uint16_t pad; - - uint32_t commandID; - - CutsceneSubCommandEntry(const std::vector& rawData, offset_t rawDataIndex); - virtual ~CutsceneSubCommandEntry() = default; - - virtual std::string GetBodySourceCode() const; - - virtual size_t GetRawSize() const; -}; - -class CutsceneCommand -{ -public: - uint32_t commandID; - uint32_t commandIndex; - - uint32_t numEntries; - std::vector entries; - - CutsceneCommand(const std::vector& rawData, offset_t rawDataIndex); - virtual ~CutsceneCommand(); - - virtual std::string GetCommandMacro() const; - virtual std::string GenerateSourceCode() const; - virtual size_t GetCommandSize() const; - - virtual void SetCommandID(uint32_t nCommandID); -}; - -class CutsceneSubCommandEntry_GenericCmd : public CutsceneSubCommandEntry -{ -public: - CutsceneCommands commandId; - - uint32_t word0 = 0; - uint32_t word1 = 0; - - uint32_t unused1 = 0; - uint32_t unused2 = 0; - uint32_t unused3 = 0; - uint32_t unused4 = 0; - uint32_t unused5 = 0; - uint32_t unused6 = 0; - uint32_t unused7 = 0; - uint32_t unused8 = 0; - uint32_t unused9 = 0; - uint32_t unused10 = 0; - - CutsceneSubCommandEntry_GenericCmd(const std::vector& rawData, offset_t rawDataIndex, - CutsceneCommands cmdId); - - std::string GetBodySourceCode() const override; - - size_t GetRawSize() const override; -}; - -class CutsceneCommand_GenericCmd : public CutsceneCommand -{ -public: - CutsceneCommand_GenericCmd(const std::vector& rawData, offset_t rawDataIndex, - CutsceneCommands cmdId); - - std::string GetCommandMacro() const override; -}; - -class CutsceneCameraPoint : public CutsceneSubCommandEntry -{ -public: - int8_t continueFlag; - int8_t cameraRoll; - int16_t nextPointFrame; - float viewAngle; - int16_t posX, posY, posZ; - int16_t unused; - - CutsceneCameraPoint(const std::vector& rawData, offset_t rawDataIndex); - - std::string GetBodySourceCode() const override; - - size_t GetRawSize() const override; -}; - -class CutsceneCommandSetCameraPos : public CutsceneCommand -{ -public: - uint16_t base; - uint16_t startFrame; - uint16_t endFrame; - uint16_t unused; - - CutsceneCommandSetCameraPos(const std::vector& rawData, offset_t rawDataIndex); - - std::string GetCommandMacro() const override; - - size_t GetCommandSize() const override; -}; - -class CutsceneCommandSceneTransFX : public CutsceneCommand -{ -public: - uint16_t base; - uint16_t startFrame; - uint16_t endFrame; - - CutsceneCommandSceneTransFX(const std::vector& rawData, offset_t rawDataIndex); - - std::string GenerateSourceCode() const override; - size_t GetCommandSize() const override; -}; - -class CutsceneSubCommandEntry_Rumble : public CutsceneSubCommandEntry -{ -public: - uint8_t unk_06; - uint8_t unk_07; - uint8_t unk_08; - uint8_t unk_09; - uint8_t unk_0A; - uint8_t unk_0B; - - CutsceneSubCommandEntry_Rumble(const std::vector& rawData, offset_t rawDataIndex); - - std::string GetBodySourceCode() const override; - - size_t GetRawSize() const override; -}; - -class CutsceneCommand_Rumble : public CutsceneCommand -{ -public: - CutsceneCommand_Rumble(const std::vector& rawData, offset_t rawDataIndex); - - std::string GetCommandMacro() const override; -}; - -class CutsceneSubCommandEntry_SetTime : public CutsceneSubCommandEntry -{ -public: - uint8_t hour; - uint8_t minute; - uint32_t unk_08; - - CutsceneSubCommandEntry_SetTime(const std::vector& rawData, offset_t rawDataIndex); - - std::string GetBodySourceCode() const override; - - size_t GetRawSize() const override; -}; - -class CutsceneCommand_SetTime : public CutsceneCommand -{ -public: - CutsceneCommand_SetTime(const std::vector& rawData, offset_t rawDataIndex); - - std::string GetCommandMacro() const override; -}; - -class CutsceneSubCommandEntry_TextBox : public CutsceneSubCommandEntry -{ -public: - uint16_t type; - uint16_t textId1; - uint16_t textId2; - - CutsceneSubCommandEntry_TextBox(const std::vector& rawData, offset_t rawDataIndex); - - std::string GetBodySourceCode() const override; - - size_t GetRawSize() const override; -}; - -class CutsceneCommand_TextBox : public CutsceneCommand -{ -public: - CutsceneCommand_TextBox(const std::vector& rawData, offset_t rawDataIndex); - - std::string GetCommandMacro() const override; -}; - -class CutsceneSubCommandEntry_ActorAction : public CutsceneSubCommandEntry -{ -public: - uint16_t rotX, rotY, rotZ; - int32_t startPosX, startPosY, startPosZ; - int32_t endPosX, endPosY, endPosZ; - float normalX, normalY, normalZ; - - CutsceneSubCommandEntry_ActorAction(const std::vector& rawData, offset_t rawDataIndex); - std::string GetBodySourceCode() const override; - - size_t GetRawSize() const override; -}; - -class CutsceneCommand_ActorAction : public CutsceneCommand -{ -public: - CutsceneCommand_ActorAction(const std::vector& rawData, offset_t rawDataIndex); - - std::string GetCommandMacro() const override; -}; - -class CutsceneCommand_Terminator : public CutsceneCommand -{ -public: - uint16_t base; - uint16_t startFrame; - uint16_t endFrame; - uint16_t unknown; - - CutsceneCommand_Terminator(const std::vector& rawData, offset_t rawDataIndex); - - std::string GenerateSourceCode() const override; - size_t GetCommandSize() const override; -}; diff --git a/ZAPDTR/ZAPD/OtherStructs/SkinLimbStructs.cpp b/ZAPDTR/ZAPD/OtherStructs/SkinLimbStructs.cpp deleted file mode 100644 index 8a0e49cf3..000000000 --- a/ZAPDTR/ZAPD/OtherStructs/SkinLimbStructs.cpp +++ /dev/null @@ -1,352 +0,0 @@ -#include "SkinLimbStructs.h" - -#include "Globals.h" -#include "Utils/BitConverter.h" -#include "Utils/StringHelper.h" -#include "ZDisplayList.h" -#include "ZFile.h" - -/* Struct_800A57C0 */ - -Struct_800A57C0::Struct_800A57C0(ZFile* nParent) : ZResource(nParent) -{ -} - -void Struct_800A57C0::ParseRawData() -{ - const auto& rawData = parent->GetRawData(); - - unk_0 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x00); - unk_2 = BitConverter::ToInt16BE(rawData, rawDataIndex + 0x02); - unk_4 = BitConverter::ToInt16BE(rawData, rawDataIndex + 0x04); - unk_6 = BitConverter::ToInt8BE(rawData, rawDataIndex + 0x06); - unk_7 = BitConverter::ToInt8BE(rawData, rawDataIndex + 0x07); - unk_8 = BitConverter::ToInt8BE(rawData, rawDataIndex + 0x08); - unk_9 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x09); -} - -std::string Struct_800A57C0::GetBodySourceCode() const -{ - return StringHelper::Sprintf("0x%02X, %i, %i, %i, %i, %i, 0x%02X", unk_0, unk_2, unk_4, unk_6, - unk_7, unk_8, unk_9); -} - -std::string Struct_800A57C0::GetSourceTypeName() const -{ - return "Struct_800A57C0"; -} - -ZResourceType Struct_800A57C0::GetResourceType() const -{ - // TODO - return ZResourceType::Error; -} - -size_t Struct_800A57C0::GetRawDataSize() const -{ - return 0x0A; -} - -/* Struct_800A598C_2 */ - -Struct_800A598C_2::Struct_800A598C_2(ZFile* nParent) : ZResource(nParent) -{ -} - -void Struct_800A598C_2::ParseRawData() -{ - const auto& rawData = parent->GetRawData(); - - unk_0 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x00); - x = BitConverter::ToInt16BE(rawData, rawDataIndex + 0x02); - y = BitConverter::ToInt16BE(rawData, rawDataIndex + 0x04); - z = BitConverter::ToInt16BE(rawData, rawDataIndex + 0x06); - unk_8 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x08); -} - -std::string Struct_800A598C_2::GetBodySourceCode() const -{ - return StringHelper::Sprintf("0x%02X, %i, %i, %i, 0x%02X", unk_0, x, y, z, unk_8); -} - -std::string Struct_800A598C_2::GetSourceTypeName() const -{ - return "Struct_800A598C_2"; -} - -ZResourceType Struct_800A598C_2::GetResourceType() const -{ - // TODO - return ZResourceType::Error; -} - -size_t Struct_800A598C_2::GetRawDataSize() const -{ - return 0x0A; -} - -/* Struct_800A598C */ - -Struct_800A598C::Struct_800A598C(ZFile* nParent) : ZResource(nParent) -{ -} - -void Struct_800A598C::ParseRawData() -{ - const auto& rawData = parent->GetRawData(); - - unk_0 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x00); - unk_2 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x02); - unk_4 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x04); - unk_8 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x08); - unk_C = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x0C); - - if (unk_8 != 0 && GETSEGNUM(unk_8) == parent->segment) - { - uint32_t unk_8_Offset = Seg2Filespace(unk_8, parent->baseAddress); - - unk_8_arr.reserve(unk_0); - for (size_t i = 0; i < unk_0; i++) - { - Struct_800A57C0 unk8_data(parent); - unk8_data.ExtractFromFile(unk_8_Offset); - unk_8_arr.push_back(unk8_data); - - unk_8_Offset += unk8_data.GetRawDataSize(); - } - } - - if (unk_C != 0 && GETSEGNUM(unk_8) == parent->segment) - { - uint32_t unk_C_Offset = Seg2Filespace(unk_C, parent->baseAddress); - - unk_C_arr.reserve(unk_2); - for (size_t i = 0; i < unk_2; i++) - { - Struct_800A598C_2 unkC_data(parent); - unkC_data.ExtractFromFile(unk_C_Offset); - unk_C_arr.push_back(unkC_data); - - unk_C_Offset += unkC_data.GetRawDataSize(); - } - } -} - -void Struct_800A598C::DeclareReferences(const std::string& prefix) -{ - std::string varPrefix = prefix; - if (name != "") - varPrefix = name; - - if (unk_8 != 0 && GETSEGNUM(unk_8) == parent->segment) - { - const auto& res = unk_8_arr.at(0); - std::string unk_8_Str = res.GetDefaultName(varPrefix); - - size_t arrayItemCnt = unk_8_arr.size(); - std::string entryStr = ""; - - for (size_t i = 0; i < arrayItemCnt; i++) - { - auto& child = unk_8_arr[i]; - child.DeclareReferences(varPrefix); - entryStr += StringHelper::Sprintf("\t{ %s },", child.GetBodySourceCode().c_str()); - - if (i < arrayItemCnt - 1) - entryStr += "\n"; - } - - uint32_t unk_8_Offset = Seg2Filespace(unk_8, parent->baseAddress); - Declaration* decl = parent->GetDeclaration(unk_8_Offset); - if (decl == nullptr) - { - parent->AddDeclarationArray(unk_8_Offset, res.GetDeclarationAlignment(), - arrayItemCnt * res.GetRawDataSize(), - res.GetSourceTypeName(), unk_8_Str, arrayItemCnt, entryStr); - } - else - decl->text = entryStr; - } - - if (unk_C != 0 && GETSEGNUM(unk_C) == parent->segment) - { - const auto& res = unk_C_arr.at(0); - std::string unk_C_Str = res.GetDefaultName(varPrefix); - - size_t arrayItemCnt = unk_C_arr.size(); - std::string entryStr = ""; - - for (size_t i = 0; i < arrayItemCnt; i++) - { - auto& child = unk_C_arr[i]; - child.DeclareReferences(varPrefix); - entryStr += StringHelper::Sprintf("\t{ %s },", child.GetBodySourceCode().c_str()); - - if (i < arrayItemCnt - 1) - entryStr += "\n"; - } - - uint32_t unk_C_Offset = Seg2Filespace(unk_C, parent->baseAddress); - Declaration* decl = parent->GetDeclaration(unk_C_Offset); - if (decl == nullptr) - { - parent->AddDeclarationArray(unk_C_Offset, res.GetDeclarationAlignment(), - arrayItemCnt * res.GetRawDataSize(), - res.GetSourceTypeName(), unk_C_Str, arrayItemCnt, entryStr); - } - else - decl->text = entryStr; - } -} - -std::string Struct_800A598C::GetBodySourceCode() const -{ - std::string unk_8_Str; - std::string unk_C_Str; - Globals::Instance->GetSegmentedPtrName(unk_8, parent, "Struct_800A57C0", unk_8_Str, - parent->workerID); - Globals::Instance->GetSegmentedPtrName(unk_C, parent, "Struct_800A598C_2", unk_C_Str, - parent->workerID); - - std::string entryStr = StringHelper::Sprintf("\n\t\tARRAY_COUNTU(%s), ARRAY_COUNTU(%s),\n", - unk_8_Str.c_str(), unk_C_Str.c_str()); - entryStr += - StringHelper::Sprintf("\t\t%i, %s, %s\n\t", unk_4, unk_8_Str.c_str(), unk_C_Str.c_str()); - - return entryStr; -} - -std::string Struct_800A598C::GetSourceTypeName() const -{ - return "Struct_800A598C"; -} - -ZResourceType Struct_800A598C::GetResourceType() const -{ - // TODO - return ZResourceType::Error; -} - -size_t Struct_800A598C::GetRawDataSize() const -{ - return 0x10; -} - -/* Struct_800A5E28 */ - -Struct_800A5E28::Struct_800A5E28(ZFile* nParent) : ZResource(nParent) -{ -} - -void Struct_800A5E28::ParseRawData() -{ - const auto& rawData = parent->GetRawData(); - - unk_0 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x00); - unk_2 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x02); - unk_4 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x04); - unk_8 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x08); - - if (unk_4 != 0 && GETSEGNUM(unk_4) == parent->segment) - { - uint32_t unk_4_Offset = Seg2Filespace(unk_4, parent->baseAddress); - - unk_4_arr.reserve(unk_2); - for (size_t i = 0; i < unk_2; i++) - { - Struct_800A598C unk_4_data(parent); - unk_4_data.ExtractFromFile(unk_4_Offset); - unk_4_arr.push_back(unk_4_data); - - unk_4_Offset += unk_4_data.GetRawDataSize(); - } - } -} - -void Struct_800A5E28::DeclareReferences(const std::string& prefix) -{ - std::string varPrefix = prefix; - if (name != "") - varPrefix = name; - - ZResource::DeclareReferences(varPrefix); - - if (unk_4 != SEGMENTED_NULL && GETSEGNUM(unk_4) == parent->segment) - { - const auto& res = unk_4_arr.at(0); - std::string unk_4_Str = res.GetDefaultName(varPrefix); - - size_t arrayItemCnt = unk_4_arr.size(); - std::string entryStr = ""; - - for (size_t i = 0; i < arrayItemCnt; i++) - { - auto& child = unk_4_arr[i]; - child.DeclareReferences(varPrefix); - entryStr += StringHelper::Sprintf("\t{ %s },", child.GetBodySourceCode().c_str()); - - if (i < arrayItemCnt - 1) - entryStr += "\n"; - } - - uint32_t unk_4_Offset = Seg2Filespace(unk_4, parent->baseAddress); - Declaration* decl = parent->GetDeclaration(unk_4_Offset); - if (decl == nullptr) - { - parent->AddDeclarationArray(unk_4_Offset, res.GetDeclarationAlignment(), - arrayItemCnt * res.GetRawDataSize(), - res.GetSourceTypeName(), unk_4_Str, arrayItemCnt, entryStr); - } - else - decl->text = entryStr; - } - - if (unk_8 != SEGMENTED_NULL && GETSEGNUM(unk_8) == parent->segment) - { - uint32_t unk_8_Offset = Seg2Filespace(unk_8, parent->baseAddress); - - int32_t dlistLength = ZDisplayList::GetDListLength( - parent->GetRawData(), unk_8_Offset, - Globals::Instance->game == ZGame::OOT_SW97 ? DListType::F3DEX : DListType::F3DZEX); - unk_8_dlist = new ZDisplayList(parent); - unk_8_dlist->ExtractFromBinary(unk_8_Offset, dlistLength); - - std::string dListStr = - StringHelper::Sprintf("%sSkinLimbDL_%06X", varPrefix.c_str(), unk_8_Offset); - unk_8_dlist->SetName(dListStr); - unk_8_dlist->DeclareVar(varPrefix, ""); - unk_8_dlist->DeclareReferences(varPrefix); - parent->AddResource(unk_8_dlist); - } -} - -std::string Struct_800A5E28::GetBodySourceCode() const -{ - std::string unk_4_Str; - std::string unk_8_Str; - Globals::Instance->GetSegmentedPtrName(unk_4, parent, "Struct_800A598C", unk_4_Str, - parent->workerID); - Globals::Instance->GetSegmentedPtrName(unk_8, parent, "Gfx", unk_8_Str, parent->workerID); - - std::string entryStr = "\n"; - entryStr += StringHelper::Sprintf("\t%i, ARRAY_COUNTU(%s),\n", unk_0, unk_4_Str.c_str()); - entryStr += StringHelper::Sprintf("\t%s, %s\n", unk_4_Str.c_str(), unk_8_Str.c_str()); - - return entryStr; -} - -std::string Struct_800A5E28::GetSourceTypeName() const -{ - return "Struct_800A5E28"; -} - -ZResourceType Struct_800A5E28::GetResourceType() const -{ - // TODO - return ZResourceType::Error; -} - -size_t Struct_800A5E28::GetRawDataSize() const -{ - return 0x0C; -} diff --git a/ZAPDTR/ZAPD/OtherStructs/SkinLimbStructs.h b/ZAPDTR/ZAPD/OtherStructs/SkinLimbStructs.h deleted file mode 100644 index ce842aee3..000000000 --- a/ZAPDTR/ZAPD/OtherStructs/SkinLimbStructs.h +++ /dev/null @@ -1,114 +0,0 @@ -#pragma once - -#include -#include -#include - -#include "ZResource.h" -#include "ZDisplayList.h" - -// TODO: check if more types exists -enum class ZLimbSkinType -{ - SkinType_0, // Segment = 0 - SkinType_4 = 4, // Segment = segmented address // Struct_800A5E28 - SkinType_5 = 5, // Segment = 0 - SkinType_DList = 11, // Segment = DList address -}; - -class Struct_800A57C0 : public ZResource -{ -public: - Struct_800A57C0(ZFile* nParent); - - void ParseRawData() override; - - std::string GetBodySourceCode() const override; - - std::string GetSourceTypeName() const override; - ZResourceType GetResourceType() const override; - - size_t GetRawDataSize() const override; - -public: - uint16_t unk_0; - int16_t unk_2; - int16_t unk_4; - int8_t unk_6; - int8_t unk_7; - int8_t unk_8; - uint8_t unk_9; -}; - -class Struct_800A598C_2 : public ZResource -{ -public: - Struct_800A598C_2(ZFile* nParent); - - void ParseRawData() override; - - std::string GetBodySourceCode() const override; - - std::string GetSourceTypeName() const override; - ZResourceType GetResourceType() const override; - - size_t GetRawDataSize() const override; - -public: - uint8_t unk_0; - int16_t x; - int16_t y; - int16_t z; - uint8_t unk_8; -}; - -class Struct_800A598C : public ZResource -{ -public: - Struct_800A598C(ZFile* nParent); - - void ParseRawData() override; - void DeclareReferences(const std::string& prefix) override; - - std::string GetBodySourceCode() const override; - - std::string GetSourceTypeName() const override; - ZResourceType GetResourceType() const override; - - size_t GetRawDataSize() const override; - -public: - uint16_t unk_0; // Length of unk_8 - uint16_t unk_2; // Length of unk_C - uint16_t unk_4; // 0 or 1 // Used as an index for unk_C - segptr_t unk_8; // Struct_800A57C0* - segptr_t unk_C; // Struct_800A598C_2* - - std::vector unk_8_arr; - std::vector unk_C_arr; -}; - -class Struct_800A5E28 : public ZResource -{ -public: - Struct_800A5E28(ZFile* nParent); - - void ParseRawData() override; - void DeclareReferences(const std::string& prefix) override; - - std::string GetBodySourceCode() const override; - - std::string GetSourceTypeName() const override; - ZResourceType GetResourceType() const override; - - size_t GetRawDataSize() const override; - -public: - uint16_t unk_0; // Vtx count - uint16_t unk_2; // Length of unk_4 - segptr_t unk_4; // Struct_800A598C* - segptr_t unk_8; // Gfx* - - std::vector unk_4_arr; - ZDisplayList* unk_8_dlist = nullptr; -}; diff --git a/ZAPDTR/ZAPD/OutputFormatter.cpp b/ZAPDTR/ZAPD/OutputFormatter.cpp deleted file mode 100644 index 362ef98fc..000000000 --- a/ZAPDTR/ZAPD/OutputFormatter.cpp +++ /dev/null @@ -1,123 +0,0 @@ -#include "OutputFormatter.h" -#include - -void OutputFormatter::Flush() -{ - //if (!Globals::Instance->otrMode) // OTRTODO: MULTITHREADING - { - if (col > lineLimit && !Globals::Instance->otrMode) - { - str.append(1, '\n'); - str.append(currentIndent, ' '); - - uint32_t newCol = currentIndent + (wordP - word); - - for (uint32_t i = 0; i < wordNests; i++) - nestIndent[nest - i] -= col - newCol; - - col = newCol; - } - else - { - str.append(space, spaceP - space); - } - spaceP = space; - - str.append(word, wordP - word); - wordP = word; - wordNests = 0; - } -} - -int OutputFormatter::Write(const char* buf, int count) -{ - // OTRTODO - //if (!Globals::Instance->singleThreaded) - //return 0; - - for (int i = 0; i < count; i++) - { - char c = buf[i]; - - if (c == ' ' || c == '\t' || c == '\n') - { - if (wordP - word != 0) - { - Flush(); - } - - if (c == '\n') - { - col = 0; - *spaceP++ = c; - } - else if (c == '\t') - { - int n = tabSize - (col % tabSize); - col += n; - for (int j = 0; j < n; j++) - *spaceP++ = ' '; - } - else - { - col++; - *spaceP++ = c; - } - - currentIndent = nestIndent[nest]; - } - else - { - col++; - - if (c == '(') - { - nest++; - nestIndent[nest] = col; - wordNests++; - } - else if (c == ')') - { - if (nest > 0) - nest--; - if (wordNests > 0) - wordNests--; - } - - *wordP++ = c; - } - } - - return count; -} - -int OutputFormatter::Write(const std::string& buf) -{ - return Write(buf.data(), buf.size()); -} - -thread_local OutputFormatter* OutputFormatter::Instance; - -int OutputFormatter::WriteStatic(const char* buf, int count) -{ - return Instance->Write(buf, count); -} - -int (*OutputFormatter::StaticWriter())(const char* buf, int count) -{ - Instance = this; - return &WriteStatic; -} - -OutputFormatter::OutputFormatter(uint32_t tabSize, uint32_t indentation, uint32_t lineLimit) - : tabSize{tabSize}, lineLimit{lineLimit}, col{0}, nest{0}, nestIndent{indentation}, - currentIndent{indentation}, wordNests(0), wordP{word}, spaceP{space} -{ -} - -std::string OutputFormatter::GetOutput() -{ - Flush(); - - return std::move(str); -} diff --git a/ZAPDTR/ZAPD/OutputFormatter.h b/ZAPDTR/ZAPD/OutputFormatter.h deleted file mode 100644 index 391f41027..000000000 --- a/ZAPDTR/ZAPD/OutputFormatter.h +++ /dev/null @@ -1,41 +0,0 @@ -#pragma once - -#include -#include -#include -#include - -class OutputFormatter -{ -private: - const uint32_t tabSize; - const uint32_t lineLimit; - - uint32_t col; - uint32_t nest; - uint32_t nestIndent[8]; - uint32_t currentIndent; - uint32_t wordNests; - - char word[128]; - char space[128]; - char* wordP; - char* spaceP; - - std::string str; - - void Flush(); - - static thread_local OutputFormatter* Instance; - static int WriteStatic(const char* buf, int count); - -public: - OutputFormatter(uint32_t tabSize = 4, uint32_t indentation = 4, uint32_t lineLimit = 120); - - int (*StaticWriter())(const char* buf, int count); // Must be `int` due to libgfxd - - int Write(const char* buf, int count); - int Write(const std::string& buf); - - std::string GetOutput(); -}; diff --git a/ZAPDTR/ZAPD/Overlays/ZOverlay.cpp b/ZAPDTR/ZAPD/Overlays/ZOverlay.cpp deleted file mode 100644 index 168ed2374..000000000 --- a/ZAPDTR/ZAPD/Overlays/ZOverlay.cpp +++ /dev/null @@ -1,354 +0,0 @@ -#if 0 -#include "ZOverlay.h" - -#include -#include -#include "Globals.h" -#include "Utils/Directory.h" -#include -#include "Utils/Path.h" -#include "Utils/StringHelper.h" -#include "WarningHandler.h" - -using namespace ELFIO; - -const char* RelocationEntry::GetSectionName() const -{ - switch (sectionType) - { - case SectionType::Text: - return ".text"; - case SectionType::Data: - return ".data"; - case SectionType::RoData: - return ".rodata"; - case SectionType::Bss: - return ".bss"; - case SectionType::ERROR: - return ".ERROR"; - } - assert(!"Oh no :c"); -} - -const char* RelocationEntry::GetRelocTypeName() const -{ - switch (relocationType) - { - case RelocationType::R_MIPS_32: - return "R_MIPS_32"; - case RelocationType::R_MIPS_26: - return "R_MIPS_26"; - case RelocationType::R_MIPS_HI16: - return "R_MIPS_HI16"; - case RelocationType::R_MIPS_LO16: - return "R_MIPS_LO16"; - } - assert(!"Oh no :c"); -} - -ZOverlay::ZOverlay() -{ - name = ""; - entries = std::vector(); -} - -ZOverlay::ZOverlay(const std::string& nName) : ZOverlay() -{ - name = nName; -} - -ZOverlay::~ZOverlay() -{ - for (auto entry : entries) - if (entry) - delete entry; - entries.clear(); -} - -static const std::unordered_set sRelSections = { - ".rel.text", - ".rel.data", - ".rel.rodata", -}; -static const std::unordered_set sSections = { - ".text", ".data", ".symtab", ".rodata", ".rodata.str1.4", ".rodata.cst4", ".rodata.cst8", -}; - -ZOverlay* ZOverlay::FromBuild(fs::path buildPath, fs::path cfgFolderPath) -{ - std::string cfgText = DiskFile::ReadAllText(cfgFolderPath / "overlay.cfg"); - std::vector cfgLines = StringHelper::Split(cfgText, "\n"); - - ZOverlay* ovl = new ZOverlay(StringHelper::Strip(cfgLines[0], "\r")); - ovl->cfgLines = cfgLines; - - int32_t sectionOffs[5] = {0}; - std::vector textRelocs; - std::vector dataRelocs; - std::vector rodataRelocs; - - // get the elf files - std::vector readers; - for (size_t i = 1; i < cfgLines.size(); i++) - { - std::string elfPath = - (buildPath / (cfgLines[i].substr(0, cfgLines[i].size() - 2) + ".o")).string(); - elfio* reader = new elfio(); - - if (!reader->load(elfPath)) - { - // not all files were compiled - for (auto r : readers) - delete r; - readers.clear(); - - delete ovl; - return nullptr; - } - - readers.push_back(reader); - } - - for (size_t curReaderId = 0; curReaderId < readers.size(); curReaderId++) - { - auto& curReader = readers[curReaderId]; - - Elf_Half sec_num = curReader->sections.size(); - for (int32_t i = 0; i < sec_num; i++) - { - section* pSec = curReader->sections[i]; - - if (pSec->get_type() != SHT_REL || - sRelSections.find(pSec->get_name()) == sRelSections.end()) - { - continue; - } - - symbol_section_accessor currentSymbols(*curReader, - curReader->sections[(Elf_Half)pSec->get_link()]); - - SectionType sectionType = GetSectionTypeFromStr(pSec->get_name()); - - if (sectionType == SectionType::ERROR) - { - HANDLE_WARNING(WarningType::Always, "one of the section types returned ERROR", ""); - } - - relocation_section_accessor relocs(*curReader, pSec); - for (Elf_Xword j = 0; j < relocs.get_entries_num(); j++) - { - Elf64_Addr offset = 0; - Elf_Word symbol = 0; - Elf_Word type = 0; - { - Elf_Sxword addend = 0; - relocs.get_entry(j, offset, symbol, type, addend); - } - - std::string curSymName; - Elf_Half curSymShndx = SHN_UNDEF; - { - Elf64_Addr value; - Elf_Xword size; - unsigned char bind; - unsigned char type; - unsigned char other; - currentSymbols.get_symbol(symbol, curSymName, value, size, bind, type, - curSymShndx, other); - } - - // check symbols outside the elf but within the overlay - if (curSymShndx == SHN_UNDEF) - { - if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_DEBUG) - { - printf("Symbol '%s' doesn't exist in current .o file (%s). Searching...\n", - curSymName.c_str(), cfgLines[curReaderId + 1].c_str()); - } - - for (size_t readerId = 0; readerId < readers.size(); readerId++) - { - auto& reader = readers[readerId]; - - if (curSymShndx != SHN_UNDEF) - break; - - if (reader == curReader) - continue; - - auto sectionData = reader->sections[(Elf_Half)pSec->get_link()]; - curSymShndx = - ovl->FindSymbolInSection(curSymName, sectionData, *reader, readerId); - if (curSymShndx != SHN_UNDEF) - break; - - if (Globals::Instance->gccCompat) - { - // Symbol wasn't found, try checking every section - Elf_Half sec_num = reader->sections.size(); - for (int32_t otherSectionIdx = 0; otherSectionIdx < sec_num; - otherSectionIdx++) - { - if (curSymShndx != SHN_UNDEF) - { - break; - } - - auto sectionDataIter = reader->sections[otherSectionIdx]; - - curSymShndx = ovl->FindSymbolInSection(curSymName, sectionDataIter, - *reader, readerId); - } - } - } - } - - if (curSymShndx != SHN_UNDEF) - { - RelocationType typeConverted = (RelocationType)type; - offset += sectionOffs[static_cast(sectionType)]; - - RelocationEntry* reloc = - new RelocationEntry(sectionType, typeConverted, offset); - - if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_DEBUG) - { - printf(".word 0x%08X # %s %s 0x%04X\n", reloc->CalcRelocationWord(), - reloc->GetSectionName(), reloc->GetRelocTypeName(), reloc->offset); - } - - // this is to keep the correct reloc entry order - if (sectionType == SectionType::Text) - textRelocs.push_back(reloc); - if (sectionType == SectionType::Data) - dataRelocs.push_back(reloc); - if (sectionType == SectionType::RoData) - rodataRelocs.push_back(reloc); - } - } - } - - // increase section offsets - for (int32_t i = 0; i < sec_num; i++) - { - section* pSec = curReader->sections[i]; - if (pSec->get_type() == SHT_PROGBITS && - sSections.find(pSec->get_name()) != sSections.end()) - { - SectionType sectionType = GetSectionTypeFromStr(pSec->get_name()); - sectionOffs[static_cast(sectionType)] += pSec->get_size(); - } - } - } - - ovl->entries.reserve(textRelocs.size() + dataRelocs.size() + rodataRelocs.size()); - ovl->entries.insert(ovl->entries.end(), textRelocs.begin(), textRelocs.end()); - ovl->entries.insert(ovl->entries.end(), dataRelocs.begin(), dataRelocs.end()); - ovl->entries.insert(ovl->entries.end(), rodataRelocs.begin(), rodataRelocs.end()); - - for (auto r : readers) - delete r; - readers.clear(); - - return ovl; -} - -std::string ZOverlay::GetSourceOutputCode([[maybe_unused]] const std::string& prefix) -{ - std::string output; - - output += ".section .ovl\n"; - - output += StringHelper::Sprintf("# %sOverlayInfo\n", name.c_str()); - output += StringHelper::Sprintf(".word _%sSegmentTextSize\n", name.c_str()); - output += StringHelper::Sprintf(".word _%sSegmentDataSize\n", name.c_str()); - output += StringHelper::Sprintf(".word _%sSegmentRoDataSize\n", name.c_str()); - output += StringHelper::Sprintf(".word _%sSegmentBssSize\n", name.c_str()); - output += "\n"; - - output += StringHelper::Sprintf(".word %i # reloc_count\n", entries.size()); - - for (size_t i = 0; i < entries.size(); i++) - { - RelocationEntry* reloc = entries[i]; - output += StringHelper::Sprintf(".word 0x%08X # %s %s 0x%04X\n", - reloc->CalcRelocationWord(), reloc->GetSectionName(), - reloc->GetRelocTypeName(), reloc->offset); - } - - size_t offset = (entries.size() * 4) + 20; - - while (offset % 16 != 12) - { - output += ".word 0\n"; - offset += 4; - } - - output += "\n"; - output += - StringHelper::Sprintf(".word 0x%08X # %sOverlayInfoOffset\n", offset + 4, name.c_str()); - return output; -} - -SectionType ZOverlay::GetSectionTypeFromStr(const std::string& sectionName) -{ - if (sectionName == ".rel.text" || sectionName == ".text") - return SectionType::Text; - else if (sectionName == ".rel.data" || sectionName == ".data") - return SectionType::Data; - else if (sectionName == ".rel.rodata" || sectionName == ".rodata" || - sectionName == ".rodata.str1.4" || sectionName == ".rodata.cst4") - return SectionType::RoData; - else if (sectionName == ".rel.bss" || sectionName == ".bss") - return SectionType::Bss; - - return SectionType::ERROR; -} - -ELFIO::Elf_Half ZOverlay::FindSymbolInSection(const std::string& curSymName, - ELFIO::section* sectionData, ELFIO::elfio& reader, - size_t readerId) -{ - if (sectionData == nullptr) - return SHN_UNDEF; - - auto sectionDataName = sectionData->get_name(); - if (sSections.find(sectionDataName) == sSections.end()) - return SHN_UNDEF; - -#ifdef DEVELOPMENT - if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_DEBUG) - { - printf("\t File '%s' section: %s \n", cfgLines[readerId + 1].c_str(), - sectionDataName.c_str()); - } -#endif - - symbol_section_accessor symbols(reader, sectionData); - - Elf_Xword symbolNum = symbols.get_symbols_num(); - for (Elf_Xword symIdx = 0; symIdx < symbolNum; symIdx++) - { - Elf_Half shndx = SHN_UNDEF; - Elf64_Addr value; - std::string name; - Elf_Xword size; - unsigned char bind; - unsigned char type; - unsigned char other; - - symbols.get_symbol(symIdx, name, value, size, bind, type, shndx, other); - - if (name == curSymName) - { - if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_DEBUG) - { - printf("\t Symbol '%s' found in '%s' '%s' \n", curSymName.c_str(), - cfgLines[readerId + 1].c_str(), sectionDataName.c_str()); - } - return shndx; - } - } - return SHN_UNDEF; -} -#endif \ No newline at end of file diff --git a/ZAPDTR/ZAPD/Overlays/ZOverlay.h b/ZAPDTR/ZAPD/Overlays/ZOverlay.h deleted file mode 100644 index c1fadddca..000000000 --- a/ZAPDTR/ZAPD/Overlays/ZOverlay.h +++ /dev/null @@ -1,78 +0,0 @@ -#pragma once - -#if 0 - -#include "Utils/Directory.h" -#include "ZResource.h" -#include "elfio/elfio.hpp" -#include "tinyxml2.h" - -enum class SectionType -{ - Text = 1, - Data = 2, - RoData = 3, - Bss = 4, - ERROR = 255 -}; - -enum class RelocationType -{ - R_MIPS_32 = 2, - R_MIPS_26 = 4, - R_MIPS_HI16 = 5, - R_MIPS_LO16 = 6, -}; - -class RelocationEntry -{ -public: - SectionType sectionType; - RelocationType relocationType; - int32_t offset; - - RelocationEntry(SectionType nSecType, RelocationType nRelType, int32_t nOffset) - { - sectionType = nSecType; - relocationType = nRelType; - offset = nOffset; - } - - uint32_t CalcRelocationWord() - { - uint32_t relocationWord = 0; - - relocationWord |= static_cast(sectionType) << 30; - relocationWord |= static_cast(relocationType) << 24; - relocationWord |= offset; - - return relocationWord; - } - - const char* GetSectionName() const; - const char* GetRelocTypeName() const; -}; - -class ZOverlay -{ -public: - std::string name; - - ZOverlay(const std::string& nName); - ~ZOverlay(); - static ZOverlay* FromBuild(fs::path buildPath, fs::path cfgFolderPath); - std::string GetSourceOutputCode(const std::string& prefix); - -private: - std::vector entries; - std::vector cfgLines; - - ZOverlay(); - - static SectionType GetSectionTypeFromStr(const std::string& sectionName); - // static std::string GetOverlayNameFromElf(ELFIO::elfio& reader); - - ELFIO::Elf_Half FindSymbolInSection(const std::string& curSymName, ELFIO::section* sectionData, - ELFIO::elfio& reader, size_t readerId); -}; -#endif \ No newline at end of file diff --git a/ZAPDTR/ZAPD/WarningHandler.cpp b/ZAPDTR/ZAPD/WarningHandler.cpp deleted file mode 100644 index 163b028b5..000000000 --- a/ZAPDTR/ZAPD/WarningHandler.cpp +++ /dev/null @@ -1,451 +0,0 @@ -/** - * ZAPD Warning- and Error-handling system - * ======================================= - * - * This provides a common standard way to write ZAPD warnings/errors, which should be used for all - * such. It will pretty-print them in a uniform way, with styles defined in the header. - * - * Warnings/errors should be constructed using the macros given in the header; there are now plenty - * of examples in the codebase of how to do this. Their purposes are noted above each category in - * the header. Each warning has a type, one of the ones in warningStringToInitMap, or - * WarningType::Always, which is used for warnings that cannot be disabled and do not display a - * type. - * - * Currently there are three levels of alert a warning can have: - * - Off (does not display anything) - * - Warn (print a warning but continue processing) - * - Err (behave like an error, i.e. print and throw an exception to crash ZAPD when occurs) - * - * Flag use: - * - -Wfoo enables warnings of type foo - * - -Wno-foo disables warnings of type foo - * - -Werror=foo escalates foo to behave like an error - * - -Weverything enables all warnings - * - -Werror escalates all enabled warnings to errors - * - * Errors do not have types, and will always throw an exception; they cannot be disabled. - * - * Format - * === - * Each printed warning/error contains the same three sections: - * - Preamble: automatically generated; the content varies depending on category. It will print the - * file and function that the warning is from, and information about the files being processed - * or extracted. - * - Header: begins with 'warning: ' or 'error:', should contain essential information about the - * warning/error, ends with the warning type if applicable. Printed with emphasis to make it - * stand out. Does not start with a capital letter or end with a '.' - * - Body (optional): indented, should contain further diagnostic information useful for identifying - * and fixing the warning/error. Can be a sentence with captialisation and '.' on the end. - * - * Please think of what the end user will find most useful when writing the header and body, and try - * to keep it brief without sacrificing important information! Also remember that if the user is - * only looking at stderr, they will normally have no other context. - * - * Warning vs error - * === - * The principle that we have operated on so far is - * - issue a warning if ZAPD will still be able to produce a valid, compilable C file that will - * match - * - if this cannot happen, use an error. - * but at the end of the day, it is up to the programmer's discretion what it should be possible to - * disable. - * - * Documentation - * === - * Remember that all warnings also need to be documented in the README.md. The help is generated - * automatically. - */ -#include "WarningHandler.h" - -#include -#include "Globals.h" -#include "Utils/StringHelper.h" - -typedef struct -{ - WarningType type; - WarningLevel defaultLevel; - std::string description; -} WarningInfoInit; - -typedef struct -{ - WarningLevel level; - std::string name; - std::string description; -} WarningInfo; - -/** - * Master list of all default warning types and features - * - * To add a warning type, fill in a new row of this map. Think carefully about what its default - * level should be, and try and make the description both brief and informative: it is used in the - * help message, so again, think about what the end user needs to know. - */ -// clang-format off -static const std::unordered_map warningStringToInitMap = { - {"deprecated", {WarningType::Deprecated, -#ifdef DEPRECATION_ON - WarningLevel::Warn, -#else - WarningLevel::Off, -#endif - "Deprecated features"}}, - {"unaccounted", {WarningType::Unaccounted, WarningLevel::Off, "Large blocks of unaccounted"}}, - {"missing-offsets", {WarningType::MissingOffsets, WarningLevel::Warn, "Offset attribute missing in XML tag"}}, - {"intersection", {WarningType::Intersection, WarningLevel::Warn, "Two assets intersect"}}, - {"missing-attribute", {WarningType::MissingAttribute, WarningLevel::Warn, "Required attribute missing in XML tag"}}, - {"invalid-attribute-value", {WarningType::InvalidAttributeValue, WarningLevel::Err, "Attribute declared in XML is wrong"}}, - {"unknown-attribute", {WarningType::UnknownAttribute, WarningLevel::Warn, "Unknown attribute in XML entry tag"}}, - {"invalid-xml", {WarningType::InvalidXML, WarningLevel::Err, "XML has syntax errors"}}, - {"invalid-jpeg", {WarningType::InvalidJPEG, WarningLevel::Err, "JPEG file does not conform to the game's format requirements"}}, - {"invalid-png", {WarningType::InvalidPNG, WarningLevel::Err, "Issues arising when processing PNG data"}}, - {"invalid-extracted-data", {WarningType::InvalidExtractedData, WarningLevel::Err, "Extracted data does not have correct form"}}, - {"missing-segment", {WarningType::MissingSegment, WarningLevel::Warn, "Segment not given in File tag in XML"}}, - {"hardcoded-pointer", {WarningType::HardcodedPointer, WarningLevel::Warn, "ZAPD lacks the info to make a symbol, so must output a hardcoded pointer"}}, - {"not-implemented", {WarningType::NotImplemented, WarningLevel::Warn, "ZAPD does not currently support this feature"}}, -}; - -/** - * Map constructed at runtime to contain the warning features as set by the user using -W flags. - */ -static std::unordered_map warningTypeToInfoMap; - -void WarningHandler::ConstructTypeToInfoMap() { - for (auto& entry : warningStringToInitMap) { - warningTypeToInfoMap[entry.second.type] = {entry.second.defaultLevel, entry.first, entry.second.description}; - } - warningTypeToInfoMap[WarningType::Always] = {WarningLevel::Warn, "always", "you shouldn't be reading this"}; - assert(warningTypeToInfoMap.size() == static_cast(WarningType::Max)); -} - -/** - * Initialises the main warning type map and reads flags passed to set each warning type's level. - */ -void WarningHandler::Init(int argc, char* argv[]) { - ConstructTypeToInfoMap(); - - bool werror = false; - for (int i = 1; i < argc; i++) { - // If it doesn't start with "-W" skip it. - if (argv[i][0] != '-' || argv[i][1] != 'W' || argv[i][2] == '\0') { - continue; - } - - WarningLevel warningTypeOn = WarningLevel::Warn; - size_t startingIndex = 2; - - // "-Wno-" - if (argv[i][2] == 'n' && argv[i][3] == 'o' && argv[i][4] == '-' && argv[i][5] != '\0') { - warningTypeOn = WarningLevel::Off; - startingIndex = 5; - } - - // Read starting after the "-W" or "-Wno-" - std::string_view currentArgv = &argv[i][startingIndex]; - - if (currentArgv == "error") { - werror = warningTypeOn != WarningLevel::Off; - } else if (currentArgv == "everything") { - for (auto& it: warningTypeToInfoMap) { - if (it.second.level <= WarningLevel::Warn) { - it.second.level = warningTypeOn; - } - } - } else { - // "-Werror=" / "-Wno-error=" parser - if (currentArgv.rfind("error=", 0) == 0) { - // Read starting after the "error=" part - currentArgv = &argv[i][startingIndex + 6]; - warningTypeOn = warningTypeOn != WarningLevel::Off ? WarningLevel::Err : WarningLevel::Warn; - } - - auto it = warningStringToInitMap.find(std::string(currentArgv)); - if (it != warningStringToInitMap.end()) { - warningTypeToInfoMap[it->second.type].level = warningTypeOn; - } - else { - HANDLE_WARNING(WarningType::Always, StringHelper::Sprintf("unknown warning flag '%s'", argv[i]), ""); - } - } - } - - if (werror) { - for (auto& it: warningTypeToInfoMap) { - if (it.second.level >= WarningLevel::Warn) { - it.second.level = WarningLevel::Err; - } - } - } -} - -bool WarningHandler::IsWarningEnabled(WarningType warnType) { - assert(static_cast(warnType) >= 0 && warnType < WarningType::Max); - - return warningTypeToInfoMap.at(warnType).level != WarningLevel::Off; -} - -bool WarningHandler::WasElevatedToError(WarningType warnType) { - assert(static_cast(warnType) >= 0 && warnType < WarningType::Max); - - if (!IsWarningEnabled(warnType)) { - return false; - } - - return warningTypeToInfoMap.at(warnType).level >= WarningLevel::Err; -} - -/** - * Print file/line/function info for debugging - */ -void WarningHandler::FunctionPreamble(const char* filename, int32_t line, const char* function) { - bool forcePrint = false; - -#ifdef DEVELOPMENT - forcePrint = true; -#endif - - fprintf(stderr, "\n"); - - if (forcePrint || Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_DEBUG) { - fprintf(stderr, "%s:%i: in function <%s>:\n", filename, line, function); - } -} - -/** - * Print the information about the file(s) being processed (XML for extraction, png etc. for building) - */ -void WarningHandler::ProcessedFilePreamble() { - if (Globals::Instance->inputPath != "") { - fprintf(stderr, "When processing file %s: ", Globals::Instance->inputPath.c_str()); - } -} - -/** - * Print information about the binary file being extracted - */ -void WarningHandler::ExtractedFilePreamble(const ZFile *parent, const ZResource* res, const uint32_t offset) { - fprintf(stderr, "in input binary file %s, ", parent->GetName().c_str()); - if (res != nullptr) { - fprintf(stderr, "resource '%s' at ", res->GetName().c_str()); - } - fprintf(stderr, "offset 0x%06X: \n\t", offset); -} - -/** - * Construct the rest of the message, after warning:/error. The message is filled in one character at a time, with indents added after newlines - */ -std::string WarningHandler::ConstructMessage(std::string message, const std::string& header, const std::string& body) { - message.reserve(message.size() + header.size() + body.size() + 10 * (sizeof(HANG_INDT) - 1)); - message += StringHelper::Sprintf(HILITE("%s"), header.c_str()); - message += "\n"; - - if (body == "") { - return message; - } - - message += HANG_INDT; - for (const char* ptr = body.c_str(); *ptr != '\0'; ptr++) { - message += *ptr; - if (*ptr == '\n') { - message += HANG_INDT; - } - } - message += "\n"; - - return message; -} - -/* Error module functions */ - -void WarningHandler::PrintErrorAndThrow(const std::string& header, const std::string& body) { - std::string errorMsg = ERR_FMT("error: "); - throw std::runtime_error(ConstructMessage(errorMsg, header, body)); -} - -/* Error types, to be used via the macros */ - -void WarningHandler::ErrorType(WarningType warnType, const std::string& header, const std::string& body) { - std::string headerMsg = header; - - for (const auto& iter: warningStringToInitMap) { - if (iter.second.type == warnType) { - headerMsg += StringHelper::Sprintf(" [%s]", iter.first.c_str()); - } - } - - PrintErrorAndThrow(headerMsg, body); -} - -void WarningHandler::Error_Plain(const char* filename, int32_t line, const char* function, WarningType warnType, const std::string& header, const std::string& body) { - FunctionPreamble(filename, line, function); - - ErrorType(warnType, header, body); -} - -void WarningHandler::Error_Process(const char* filename, int32_t line, const char* function, WarningType warnType, const std::string& header, const std::string& body) { - FunctionPreamble(filename, line, function); - ProcessedFilePreamble(); - - ErrorType(warnType, header, body); -} - -void WarningHandler::Error_Resource(const char* filename, int32_t line, const char* function, WarningType warnType, const ZFile *parent, const ZResource* res, const uint32_t offset, const std::string& header, const std::string& body) { - assert(parent != nullptr); - - FunctionPreamble(filename, line, function); - ProcessedFilePreamble(); - ExtractedFilePreamble(parent, res, offset); - - ErrorType(warnType, header, body); -} - -/* Warning module functions */ - -void WarningHandler::PrintWarningBody(const std::string& header, const std::string& body) { - std::string errorMsg = WARN_FMT("warning: "); - fprintf(stderr, "%s", ConstructMessage(errorMsg, header, body).c_str()); -} - -void WarningHandler::WarningTypeAndChooseEscalate(WarningType warnType, const std::string& header, const std::string& body) { - std::string headerMsg = header; - - for (const auto& iter: warningStringToInitMap) { - if (iter.second.type == warnType) { - headerMsg += StringHelper::Sprintf(" [-W%s]", iter.first.c_str()); - } - } - - if (WasElevatedToError(warnType)) { - PrintErrorAndThrow(headerMsg, body); - } else { - PrintWarningBody(headerMsg, body); - } -} - - -/* Warning types, to be used via the macros */ - -void WarningHandler::Warning_Plain(const char* filename, int32_t line, const char* function, WarningType warnType, const std::string& header, const std::string& body) { - if (!IsWarningEnabled(warnType)) { - return; - } - - FunctionPreamble(filename, line, function); - - WarningTypeAndChooseEscalate(warnType, header, body); -} - -void WarningHandler::Warning_Process(const char* filename, int32_t line, const char* function, WarningType warnType, const std::string& header, const std::string& body) { - if (!IsWarningEnabled(warnType)) { - return; - } - - FunctionPreamble(filename, line, function); - ProcessedFilePreamble(); - - WarningTypeAndChooseEscalate(warnType, header, body); -} - -void WarningHandler::Warning_Resource(const char* filename, int32_t line, const char* function, WarningType warnType, const ZFile *parent, const ZResource* res, const uint32_t offset, const std::string& header, const std::string& body) { - assert(parent != nullptr); - - if (!IsWarningEnabled(warnType)) { - return; - } - - FunctionPreamble(filename, line, function); - ProcessedFilePreamble(); - ExtractedFilePreamble(parent, res, offset); - - WarningTypeAndChooseEscalate(warnType, header, body); -} - - -/* Help-related functions */ - -#include - -/** - * Print each warning name, default status, and description using the init map - */ -void WarningHandler::PrintHelp() { - std::set sortedKeys; - WarningInfoInit warningInfo; - uint32_t columnWidth = 25; - std::string dt; - - // Sort keys through the magic of `set`, to print in alphabetical order - for (auto& it : warningStringToInitMap) { - sortedKeys.insert(it.first); - } - - printf("\nWarning types ( * means enabled by default)\n"); - for (auto& key : sortedKeys) { - warningInfo = warningStringToInitMap.at(key); - if (warningInfo.defaultLevel <= WarningLevel::Warn) { - dt = "-W"; - dt += key; - if (warningInfo.defaultLevel == WarningLevel::Warn) { - dt += " *"; - } - printf(HELP_DT_INDT "%-*s", columnWidth, dt.c_str()); - - if (dt.length() + 2 > columnWidth) { - printf("\n" HELP_DT_INDT "%-*s", columnWidth, ""); - } - printf("%s\n", warningInfo.description.c_str()); - } - } - - printf("\nDefault errors\n"); - for (auto& key : sortedKeys) { - if (warningInfo.defaultLevel > WarningLevel::Warn) { - dt = "-W"; - dt += key; - printf(HELP_DT_INDT "%-*s", columnWidth, dt.c_str()); - - if (dt.length() + 2 > columnWidth) { - printf("\n" HELP_DT_INDT "%*s", columnWidth, ""); - } - printf("%s\n", warningInfo.description.c_str()); - } - } - - printf("\n"); - printf("Other\n" HELP_DT_INDT "-Weverything will enable all existing warnings.\n" HELP_DT_INDT "-Werror will promote all warnings to errors.\n"); - - printf("\n"); - printf("Warnings can be disabled using -Wno-... instead of -W...; -Weverything will override any -Wno-... flags passed before it.\n"); -} - -/** - * Print which warnings are currently enabled - */ -void WarningHandler::PrintWarningsDebugInfo() -{ - std::string dt; - - printf("Warnings status:\n"); - for (auto& it: warningTypeToInfoMap) { - dt = it.second.name; - dt += ": "; - - printf(HELP_DT_INDT "%-25s", dt.c_str()); - switch (it.second.level) - { - case WarningLevel::Off: - printf(VT_FGCOL(LIGHTGRAY) "Off" VT_RST); - break; - case WarningLevel::Warn: - printf(VT_FGCOL(YELLOW) "Warn" VT_RST); - break; - case WarningLevel::Err: - printf(VT_FGCOL(RED) "Err" VT_RST); - break; - - } - printf("\n"); - } - printf("\n"); -} diff --git a/ZAPDTR/ZAPD/WarningHandler.h b/ZAPDTR/ZAPD/WarningHandler.h deleted file mode 100644 index bb0360a81..000000000 --- a/ZAPDTR/ZAPD/WarningHandler.h +++ /dev/null @@ -1,145 +0,0 @@ -#pragma once - -#include -#include -#include -#include - -#include "Utils/vt.h" -#include "ZFile.h" - -#ifdef _MSC_VER -#define __PRETTY_FUNCTION__ __FUNCSIG__ -#elif not defined(__GNUC__) -#define __PRETTY_FUNCTION__ __func__ -#endif - -// ======================================= -/* Formatting macros */ - -// TODO: move this somewhere else so it can be used by other help -#define HELP_DT_INDT " " - -/* Macros for formatting warnings/errors */ -#define VT_HILITE VT_BOLD_FGCOL(WHITE) -#define VT_WARN VT_BOLD_FGCOL(PURPLE) -#define VT_ERR VT_BOLD_FGCOL(RED) - -#define HILITE(string) (VT_HILITE string VT_RST) -#define WARN_FMT(string) (VT_WARN string VT_RST) -#define ERR_FMT(string) (VT_ERR string VT_RST) - -// Maybe make WARN_LF instead -// Currently 8 spaces -#define WARN_INDT " " -// Currently 16 spaces -#define HANG_INDT " " - -// ======================================= -/* Warning and error macros */ -// TODO: better names - -// General-purpose, plain style (only prints function,file,line in the preamble) -#define HANDLE_ERROR(warningType, header, body) \ - WarningHandler::Error_Plain(__FILE__, __LINE__, __PRETTY_FUNCTION__, warningType, header, body) -#define HANDLE_WARNING(warningType, header, body) \ - WarningHandler::Warning_Plain(__FILE__, __LINE__, __PRETTY_FUNCTION__, warningType, header, \ - body) - -// For processing XMLs or textures/blobs (preamble contains function,file,line; processed file) -#define HANDLE_ERROR_PROCESS(warningType, header, body) \ - WarningHandler::Error_Process(__FILE__, __LINE__, __PRETTY_FUNCTION__, warningType, header, \ - body) -#define HANDLE_WARNING_PROCESS(warningType, header, body) \ - WarningHandler::Warning_Process(__FILE__, __LINE__, __PRETTY_FUNCTION__, warningType, header, \ - body) - -// For ZResource-related stuff (preamble contains function,file,line; processed file; extracted file -// and offset) -#define HANDLE_ERROR_RESOURCE(warningType, parent, resource, offset, header, body) \ - WarningHandler::Error_Resource(__FILE__, __LINE__, __PRETTY_FUNCTION__, warningType, parent, \ - resource, offset, header, body) -#define HANDLE_WARNING_RESOURCE(warningType, parent, resource, offset, header, body) \ - WarningHandler::Warning_Resource(__FILE__, __LINE__, __PRETTY_FUNCTION__, warningType, parent, \ - resource, offset, header, body) - -// ======================================= - -enum class WarningType -{ - Always, // Warnings of this type are always printed, cannot be disabled. - Deprecated, - Unaccounted, - MissingOffsets, - Intersection, - MissingAttribute, - InvalidAttributeValue, - UnknownAttribute, - InvalidXML, - InvalidJPEG, - InvalidPNG, - InvalidExtractedData, - MissingSegment, - HardcodedPointer, - NotImplemented, - Max, -}; - -enum class WarningLevel -{ - Off, - Warn, - Err, -}; - -class WarningHandler -{ -public: - static void ConstructTypeToInfoMap(); - - static void Init(int argc, char* argv[]); - - static bool IsWarningEnabled(WarningType warnType); - static bool WasElevatedToError(WarningType warnType); - - static void FunctionPreamble(const char* filename, int32_t line, const char* function); - static void ProcessedFilePreamble(); - static void ExtractedFilePreamble(const ZFile* parent, const ZResource* res, - const uint32_t offset); - static std::string ConstructMessage(std::string message, const std::string& header, - const std::string& body); - - [[noreturn]] static void PrintErrorAndThrow(const std::string& header, const std::string& body); - static void PrintWarningBody(const std::string& header, const std::string& body); - - [[noreturn]] static void ErrorType(WarningType warnType, const std::string& header, - const std::string& body); - [[noreturn]] static void Error_Plain(const char* filename, int32_t line, const char* function, - WarningType warnType, const std::string& header, - const std::string& body); - [[noreturn]] static void Error_Process(const char* filename, int32_t line, const char* function, - WarningType warnType, const std::string& header, - const std::string& body); - [[noreturn]] static void Error_Resource(const char* filename, int32_t line, - const char* function, WarningType warnType, - const ZFile* parent, const ZResource* res, - const uint32_t offset, const std::string& header, - const std::string& body); - - static void WarningTypeAndChooseEscalate(WarningType warnType, const std::string& header, - const std::string& body); - - static void Warning_Plain(const char* filename, int32_t line, const char* function, - WarningType warnType, const std::string& header, - const std::string& body); - static void Warning_Process(const char* filename, int32_t line, const char* function, - WarningType warnType, const std::string& header, - const std::string& body); - static void Warning_Resource(const char* filename, int32_t line, const char* function, - WarningType warnType, const ZFile* parent, const ZResource* res, - const uint32_t offset, const std::string& header, - const std::string& body); - - static void PrintHelp(); - static void PrintWarningsDebugInfo(); -}; diff --git a/ZAPDTR/ZAPD/ZAPD.vcxproj b/ZAPDTR/ZAPD/ZAPD.vcxproj deleted file mode 100644 index 505e41100..000000000 --- a/ZAPDTR/ZAPD/ZAPD.vcxproj +++ /dev/null @@ -1,372 +0,0 @@ - - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 15.0 - {B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36} - ZAPD - 10.0 - ZAPD - - - - Application - true - v142 - MultiByte - - - Application - false - v142 - true - MultiByte - - - Application - true - v142 - MultiByte - - - Application - false - v142 - true - MultiByte - - - - - - - - - - - - - - - - - - - - - $(OutDir);$(ProjectDir)..\lib\libgfxd;$(ProjectDir)..\packages\libpng-v142.1.6.37.2\build\native\lib\x64\v142\Debug\;$(LibraryPath) - $(ProjectDir)..\ZAPDUtils;$(ProjectDir)..\lib\tinyxml2;$(ProjectDir)..\lib\libgfxd;$(ProjectDir)..\lib\elfio;$(ProjectDir)..\lib\stb;$(ProjectDir);$(IncludePath) - - - $(IncludePath) - - - $(SolutionDir)ZAPD\lib\tinyxml2;$(SolutionDir)ZAPD\lib\libgfxd;$(SolutionDir)ZAPD\lib\elfio;$(SolutionDir)ZAPD\lib\stb;$(ProjectDir);$(IncludePath) - $(SolutionDir)ZAPD\lib\libgfxd;$(SolutionDir)x64\Debug;$(SolutionDir)packages\libpng.1.6.28.1\build\native\lib\x64\v140\dynamic\Debug;$(LibraryPath) - - - - Level3 - Disabled - true - true - stdcpp17 - stdc11 - _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - true - - - true - Console - - - cd .. -mkdir build\ZAPD - python ZAPD/genbuildinfo.py - - - - - Level3 - Disabled - true - true - stdcpp17 - _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - EnableFastChecks - stdc11 - MultiThreadedDebug - true - - - true - ZAPDUtils.lib;/WHOLEARCHIVE:ExporterExample.lib;%(AdditionalDependencies) - false - Console - - - cd .. -mkdir build\ZAPD - python ZAPD/genbuildinfo.py - - - - - Level3 - MaxSpeed - true - true - true - true - true - - - true - true - - - cd .. -mkdir build\ZAPD - python ZAPD/genbuildinfo.py - - - - - Level3 - MaxSpeed - true - true - true - true - stdcpplatest - _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - true - - - true - true - - - cd .. -mkdir build\ZAPD - python ZAPD/genbuildinfo.py - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - - - - - - - - - - - - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - - - - \ No newline at end of file diff --git a/ZAPDTR/ZAPD/ZAPD.vcxproj.filters b/ZAPDTR/ZAPD/ZAPD.vcxproj.filters deleted file mode 100644 index ce89882fe..000000000 --- a/ZAPDTR/ZAPD/ZAPD.vcxproj.filters +++ /dev/null @@ -1,572 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;ipp;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - {02148456-5068-4613-8478-f10addc58e70} - - - {bcab3136-95ba-4839-833c-43d78ad6e335} - - - {dc06ed84-f6fe-4277-80f3-d62bd5cdbb98} - - - {6049c045-bc38-4221-b29e-ca6d4d8af4aa} - - - {490e3a08-047b-48d3-ab53-3a860a3b92aa} - - - {26c06845-8e8e-4b79-ad18-07c4f9c0f801} - - - {d45c420d-2378-47ac-92c5-80db9475c195} - - - {03cc56a2-e0e8-4167-80a0-98fb900a959a} - - - {73db0879-6df8-4f6a-8cc2-a1f836e9e796} - - - {be9a5be0-ec6a-4200-8e39-bb58c7da7aa8} - - - {7ee79d97-c6a8-4e82-93ef-37981f4d7838} - - - {85600275-99fe-491d-8189-bcc3dc1a8903} - - - {ba9990b0-1082-48bb-874c-6108534b5455} - - - {ce9d91b0-ba20-4296-bc2d-8630965bb392} - - - {730beb67-6d59-4849-9d9b-702c4a565fc0} - - - - - Source Files - - - Source Files\Z64\ZRoom - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files - - - Source Files\Z64 - - - Source Files\Libraries\libgfxd - - - Source Files\Libraries\libgfxd - - - Source Files\Libraries\libgfxd - - - Source Files\Libraries\libgfxd - - - Source Files\Libraries\libgfxd - - - Source Files\Libraries\libgfxd - - - Source Files\Libraries\libgfxd - - - Source Files\Z64 - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64 - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64 - - - Source Files - - - Source Files - - - Source Files\Z64 - - - Source Files - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files - - - Source Files\Z64 - - - Source Files - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files - - - Source Files\Z64 - - - - - Header Files\Z64\ZRoom - - - Header Files\Z64\ZRoom - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Libraries\elfio - - - Header Files\Libraries\elfio - - - Header Files\Libraries\elfio - - - Header Files\Libraries\elfio - - - Header Files\Libraries\elfio - - - Header Files\Libraries\elfio - - - Header Files\Libraries\elfio - - - Header Files\Libraries\elfio - - - Header Files\Libraries\elfio - - - Header Files\Libraries\elfio - - - Header Files\Libraries\elfio - - - Header Files\Libraries\elfio - - - Header Files - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Libraries - - - Header Files\Libraries - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files - - - Header Files\Z64 - - - Header Files - - - Header Files\Z64 - - - Header Files\Libraries\libgfxd - - - Header Files\Libraries\libgfxd - - - Header Files\Libraries\libgfxd - - - Header Files\Z64 - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64 - - - Header Files\Z64\ZRoom\Commands - - - Header Files - - - Header Files\Z64 - - - Header Files - - - Header Files\Z64 - - - Header Files - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files - - - Header Files\Z64 - - - - - Resource Files - - - any\any - - - NuGet - - - - - - \ No newline at end of file diff --git a/ZAPDTR/ZAPD/ZActorList.cpp b/ZAPDTR/ZAPD/ZActorList.cpp deleted file mode 100644 index ee5cb4d44..000000000 --- a/ZAPDTR/ZAPD/ZActorList.cpp +++ /dev/null @@ -1,194 +0,0 @@ -#include "ZActorList.h" - -#include "Globals.h" -#include "Utils/BitConverter.h" -#include "WarningHandler.h" -#include "ZFile.h" -#include "ZRoom/ZNames.h" - -REGISTER_ZFILENODE(ActorList, ZActorList); - -ZActorList::ZActorList(ZFile* nParent) : ZResource(nParent) -{ - RegisterRequiredAttribute("Count"); -} - -void ZActorList::ExtractFromBinary(uint32_t nRawDataIndex, uint8_t nNumActors) -{ - rawDataIndex = nRawDataIndex; - numActors = nNumActors; - - // Don't parse raw data of external files - if (parent->GetMode() == ZFileMode::ExternalFile) - return; - - ParseRawData(); -} - -void ZActorList::ParseXML(tinyxml2::XMLElement* reader) -{ - ZResource::ParseXML(reader); - - numActors = StringHelper::StrToL(registeredAttributes.at("Count").value); - - if (numActors < 1) - { - HANDLE_ERROR_RESOURCE( - WarningType::InvalidAttributeValue, parent, this, rawDataIndex, - StringHelper::Sprintf("invalid value '%d' found for 'NumPaths' attribute", numActors), - "Should be at least '1'"); - } -} - -void ZActorList::ParseRawData() -{ - ZResource::ParseRawData(); - - offset_t currentPtr = rawDataIndex; - size_t largestlength = 0; - - for (size_t i = 0; i < numActors; i++) - { - ActorSpawnEntry entry(parent->GetRawData(), currentPtr); - - currentPtr += entry.GetRawDataSize(); - actors.push_back(entry); - - size_t actorNameLength = ZNames::GetActorName(entry.GetActorId()).size(); - if (actorNameLength > largestlength) - largestlength = actorNameLength; - } - - for (auto& entry : actors) - { - entry.SetLargestActorName(largestlength); - } -} - -Declaration* ZActorList::DeclareVar(const std::string& prefix, const std::string& bodyStr) -{ - std::string auxName = name; - - if (name == "") - auxName = GetDefaultName(prefix); - - Declaration* decl = - parent->AddDeclarationArray(rawDataIndex, GetDeclarationAlignment(), GetRawDataSize(), - GetSourceTypeName(), name, GetActorListArraySize(), bodyStr); - decl->staticConf = staticConf; - - return decl; -} - -std::string ZActorList::GetBodySourceCode() const -{ - std::string declaration; - - size_t index = 0; - for (auto& entry : actors) - { - declaration += StringHelper::Sprintf("\t{ %s },", entry.GetBodySourceCode().c_str()); - - if (index < actors.size() - 1) - declaration += "\n"; - - index++; - } - - return declaration; -} - -std::string ZActorList::GetSourceTypeName() const -{ - return actors.front().GetSourceTypeName(); -} - -ZResourceType ZActorList::GetResourceType() const -{ - return ZResourceType::ActorList; -} - -size_t ZActorList::GetRawDataSize() const -{ - return actors.size() * actors.front().GetRawDataSize(); -} - -size_t ZActorList::GetActorListArraySize() const -{ - size_t actorCount = 0; - - // Doing an else-if here so we only do the loop when the game is SW97. - // Actor 0x22 is removed from SW97, so we need to ensure that we don't increment the actor count - // for it. - if (Globals::Instance->game == ZGame::OOT_SW97) - { - actorCount = 0; - - for (const auto& entry : actors) - if (entry.GetActorId() != 0x22) - actorCount++; - } - else - { - actorCount = actors.size(); - } - - return actorCount; -} - -/* ActorSpawnEntry */ - -ActorSpawnEntry::ActorSpawnEntry(const std::vector& rawData, uint32_t rawDataIndex) -{ - actorNum = BitConverter::ToInt16BE(rawData, rawDataIndex + 0); - posX = BitConverter::ToInt16BE(rawData, rawDataIndex + 2); - posY = BitConverter::ToInt16BE(rawData, rawDataIndex + 4); - posZ = BitConverter::ToInt16BE(rawData, rawDataIndex + 6); - rotX = BitConverter::ToUInt16BE(rawData, rawDataIndex + 8); - rotY = BitConverter::ToUInt16BE(rawData, rawDataIndex + 10); - rotZ = BitConverter::ToUInt16BE(rawData, rawDataIndex + 12); - params = BitConverter::ToInt16BE(rawData, rawDataIndex + 14); -} - -std::string ActorSpawnEntry::GetBodySourceCode() const -{ - std::string body; - - std::string actorNameFmt = StringHelper::Sprintf("%%-%zus ", largestActorName + 1); - body = - StringHelper::Sprintf(actorNameFmt.c_str(), (ZNames::GetActorName(actorNum) + ",").c_str()); - - body += StringHelper::Sprintf("{ %6i, %6i, %6i }, ", posX, posY, posZ); - if (Globals::Instance->game == ZGame::MM_RETAIL) - body += StringHelper::Sprintf("{ SPAWN_ROT_FLAGS(%#5hX, 0x%04X)" - ", SPAWN_ROT_FLAGS(%#5hX, 0x%04X)" - ", SPAWN_ROT_FLAGS(%#5hX, 0x%04X) }, ", - (rotX >> 7) & 0b111111111, rotX & 0b1111111, - (rotY >> 7) & 0b111111111, rotY & 0b1111111, - (rotZ >> 7) & 0b111111111, rotZ & 0b1111111); - else - body += StringHelper::Sprintf("{ %#6hX, %#6hX, %#6hX }, ", rotX, rotY, rotZ); - body += StringHelper::Sprintf("0x%04X", params); - - return body; -} - -std::string ActorSpawnEntry::GetSourceTypeName() const -{ - return "ActorEntry"; -} - -size_t ActorSpawnEntry::GetRawDataSize() const -{ - return 16; -} - -uint16_t ActorSpawnEntry::GetActorId() const -{ - return actorNum; -} - -void ActorSpawnEntry::SetLargestActorName(size_t nameSize) -{ - largestActorName = nameSize; -} diff --git a/ZAPDTR/ZAPD/ZActorList.h b/ZAPDTR/ZAPD/ZActorList.h deleted file mode 100644 index 7cc63da2f..000000000 --- a/ZAPDTR/ZAPD/ZActorList.h +++ /dev/null @@ -1,52 +0,0 @@ -#pragma once - -#include "ZResource.h" - -class ActorSpawnEntry -{ -public: - uint16_t actorNum; - int16_t posX; - int16_t posY; - int16_t posZ; - uint16_t rotX; - uint16_t rotY; - uint16_t rotZ; - uint16_t params; - size_t largestActorName = 16; - - ActorSpawnEntry(const std::vector& rawData, uint32_t rawDataIndex); - - std::string GetBodySourceCode() const; - - std::string GetSourceTypeName() const; - size_t GetRawDataSize() const; - - uint16_t GetActorId() const; - void SetLargestActorName(size_t nameSize); -}; - -class ZActorList : public ZResource -{ -public: - std::vector actors; - uint32_t numActors = 0; - - ZActorList(ZFile* nParent); - - void ExtractFromBinary(offset_t nRawDataIndex, uint8_t nNumActors); - - void ParseXML(tinyxml2::XMLElement* reader) override; - void ParseRawData() override; - - Declaration* DeclareVar(const std::string& prefix, const std::string& bodyStr) override; - std::string GetBodySourceCode() const override; - - std::string GetSourceTypeName() const override; - ZResourceType GetResourceType() const override; - - size_t GetRawDataSize() const override; - -protected: - size_t GetActorListArraySize() const; -}; diff --git a/ZAPDTR/ZAPD/ZAnimation.cpp b/ZAPDTR/ZAPD/ZAnimation.cpp deleted file mode 100644 index 199851415..000000000 --- a/ZAPDTR/ZAPD/ZAnimation.cpp +++ /dev/null @@ -1,580 +0,0 @@ -#include "ZAnimation.h" - -#include - -#include "Globals.h" -#include "Utils/BitConverter.h" -#include -#include "Utils/StringHelper.h" -#include "WarningHandler.h" -#include "ZFile.h" - -REGISTER_ZFILENODE(Animation, ZNormalAnimation); -REGISTER_ZFILENODE(PlayerAnimation, ZLinkAnimation); -REGISTER_ZFILENODE(CurveAnimation, ZCurveAnimation); -REGISTER_ZFILENODE(LegacyAnimation, ZLegacyAnimation); - -ZAnimation::ZAnimation(ZFile* nParent) : ZResource(nParent) -{ - frameCount = 0; - genOTRDef = true; -} - -void ZAnimation::ParseRawData() -{ - ZResource::ParseRawData(); - - frameCount = BitConverter::ToInt16BE(parent->GetRawData(), rawDataIndex + 0); -} - -/* -std::string ZAnimation::GetSourceOutputHeader(const std::string& prefix) -{ - if (Globals::Instance->otrMode) - { - std::string str = ""; - str += StringHelper::Sprintf("#define %s \"__OTR__%s/%s\"", name.c_str(), parent->GetOutName().c_str(), name.c_str()); - - return str; - } - else - return ZResource::GetSourceOutputHeader(prefix); -} -*/ - -ZResourceType ZAnimation::GetResourceType() const -{ - return ZResourceType::Animation; -} - -/* ZNormalAnimation */ - -ZNormalAnimation::ZNormalAnimation(ZFile* nParent) : ZAnimation(nParent) -{ -} - -size_t ZNormalAnimation::GetRawDataSize() const -{ - return 16; -} - -std::string ZNormalAnimation::GetSourceTypeName() const -{ - return "AnimationHeader"; -} - -void ZNormalAnimation::ParseRawData() -{ - ZAnimation::ParseRawData(); - - auto& data = parent->GetRawData(); - - rotationValuesSeg = BitConverter::ToInt32BE(data, rawDataIndex + 4); - rotationIndicesSeg = BitConverter::ToInt32BE(data, rawDataIndex + 8); - limit = BitConverter::ToInt16BE(data, rawDataIndex + 12); - - rotationValuesOffset = Seg2Filespace(rotationValuesSeg, parent->baseAddress); - rotationIndicesOffset = Seg2Filespace(rotationIndicesSeg, parent->baseAddress); - - uint32_t currentPtr = rotationValuesOffset; - - // Read the Rotation Values - for (uint32_t i = 0; i < ((rotationIndicesOffset - rotationValuesOffset) / 2); i++) - { - rotationValues.push_back(BitConverter::ToInt16BE(data, currentPtr)); - currentPtr += 2; - } - - currentPtr = rotationIndicesOffset; - - // Read the Rotation Indices - for (uint32_t i = 0; i < ((rawDataIndex - rotationIndicesOffset) / 6); i++) - { - rotationIndices.push_back(RotationIndex(BitConverter::ToInt16BE(data, currentPtr), - BitConverter::ToInt16BE(data, currentPtr + 2), - BitConverter::ToInt16BE(data, currentPtr + 4))); - currentPtr += 6; - } -} - -void ZNormalAnimation::DeclareReferences(const std::string& prefix) -{ - std::string defaultPrefix = prefix.c_str(); - if (name != "") - defaultPrefix = name; - - // replace g prefix with s for local variables - if (defaultPrefix.at(0) == 'g') - defaultPrefix.replace(0, 1, "s"); - - std::string indicesStr = ""; - std::string valuesStr = " "; - const uint8_t lineLength = 14; - const uint8_t offset = 0; - - if (!Globals::Instance->otrMode) - { - for (size_t i = 0; i < rotationValues.size(); i++) - { - valuesStr += StringHelper::Sprintf("0x%04X, ", rotationValues[i]); - - if ((i - offset + 1) % lineLength == 0) - valuesStr += "\n "; - } - } - - parent->AddDeclarationArray(rotationValuesOffset, DeclarationAlignment::Align4, - rotationValues.size() * 2, "s16", - StringHelper::Sprintf("%sFrameData", defaultPrefix.c_str()), - rotationValues.size(), valuesStr); - - if (!Globals::Instance->otrMode) - { - for (size_t i = 0; i < rotationIndices.size(); i++) - { - indicesStr += - StringHelper::Sprintf(" { 0x%04X, 0x%04X, 0x%04X },", rotationIndices[i].x, - rotationIndices[i].y, rotationIndices[i].z); - - if (i != (rotationIndices.size() - 1)) - indicesStr += "\n"; - } - } - - parent->AddDeclarationArray(rotationIndicesOffset, DeclarationAlignment::Align4, - rotationIndices.size() * 6, "JointIndex", - StringHelper::Sprintf("%sJointIndices", defaultPrefix.c_str()), - rotationIndices.size(), indicesStr); -} - -std::string ZNormalAnimation::GetBodySourceCode() const -{ - std::string frameDataName; - Globals::Instance->GetSegmentedPtrName(rotationValuesSeg, parent, "s16", frameDataName, - parent->workerID); - std::string jointIndicesName; - Globals::Instance->GetSegmentedPtrName(rotationIndicesSeg, parent, "JointIndex", - jointIndicesName, parent->workerID); - - std::string headerStr = - StringHelper::Sprintf("\n\t{ %i }, %s,\n", frameCount, frameDataName.c_str()); - headerStr += StringHelper::Sprintf("\t%s, %i\n", jointIndicesName.c_str(), limit); - - return headerStr; -} - -/* ZLinkAnimation */ - -ZLinkAnimation::ZLinkAnimation(ZFile* nParent) : ZAnimation(nParent) -{ - segmentAddress = 0; -} - -size_t ZLinkAnimation::GetRawDataSize() const -{ - return 8; -} - -std::string ZLinkAnimation::GetSourceTypeName() const -{ - return "LinkAnimationHeader"; -} - -void ZLinkAnimation::ParseRawData() -{ - ZAnimation::ParseRawData(); - - const auto& rawData = parent->GetRawData(); - segmentAddress = BitConverter::ToInt32BE(rawData, rawDataIndex + 4); -} - -std::string ZLinkAnimation::GetBodySourceCode() const -{ - std::string segSymbol; - Globals::Instance->GetSegmentedPtrName(segmentAddress, parent, "", segSymbol, parent->workerID); - - return StringHelper::Sprintf("\n\t{ %i }, %s\n", frameCount, segSymbol.c_str()); -} - -/* ZCurveAnimation */ - -TransformData::TransformData(ZFile* parent, const std::vector& rawData, - uint32_t fileOffset) - : parent(parent) -{ - unk_00 = BitConverter::ToUInt16BE(rawData, fileOffset + 0); - unk_02 = BitConverter::ToUInt16BE(rawData, fileOffset + 2); - unk_04 = BitConverter::ToInt16BE(rawData, fileOffset + 4); - unk_06 = BitConverter::ToInt16BE(rawData, fileOffset + 6); - unk_08 = BitConverter::ToFloatBE(rawData, fileOffset + 8); -} - -TransformData::TransformData(ZFile* parent, const std::vector& rawData, - uint32_t fileOffset, size_t index) - : TransformData(parent, rawData, fileOffset + index * GetRawDataSize()) -{ -} - -std::string TransformData::GetBody([[maybe_unused]] const std::string& prefix) const -{ - return StringHelper::Sprintf("0x%04X, 0x%04X, %i, %i, %ff", unk_00, unk_02, unk_04, unk_06, - unk_08); -} - -size_t TransformData::GetRawDataSize() const -{ - return 0x0C; -} - -std::string TransformData::GetSourceTypeName() -{ - return "TransformData"; -} - -ZCurveAnimation::ZCurveAnimation(ZFile* nParent) : ZAnimation(nParent) -{ - RegisterOptionalAttribute("SkelOffset"); -} - -void ZCurveAnimation::ParseXML(tinyxml2::XMLElement* reader) -{ - ZAnimation::ParseXML(reader); - - std::string skelOffsetXml = registeredAttributes.at("SkelOffset").value; - if (skelOffsetXml == "") - { - HANDLE_ERROR_RESOURCE(WarningType::MissingAttribute, parent, this, rawDataIndex, - "missing 'SkelOffset' attribute in ", - "You need to provide the offset of the curve skeleton."); - } - skelOffset = StringHelper::StrToL(skelOffsetXml, 0); -} - -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); - unk_0C = BitConverter::ToInt16BE(rawData, rawDataIndex + 12); - unk_10 = BitConverter::ToInt16BE(rawData, rawDataIndex + 14); - - uint32_t limbCountAddress = Seg2Filespace(skelOffset, parent->baseAddress) + 4; - limbCount = BitConverter::ToUInt8BE(rawData, limbCountAddress); - - size_t transformDataSize = 0; - size_t copyValuesSize = 0; - if (refIndex != 0) - { - uint32_t refIndexOffset = Seg2Filespace(refIndex, parent->baseAddress); - for (size_t i = 0; i < 3 * 3 * limbCount; i++) - { - uint8_t ref = BitConverter::ToUInt8BE(rawData, refIndexOffset + i); - if (ref == 0) - copyValuesSize++; - else - transformDataSize += ref; - - refIndexArr.emplace_back(ref); - } - } - - if (transformData != 0) - { - uint32_t transformDataOffset = Seg2Filespace(transformData, parent->baseAddress); - - for (size_t i = 0; i < transformDataSize; i++) - transformDataArr.emplace_back(parent, rawData, transformDataOffset, i); - } - - if (copyValues != 0) - { - uint32_t copyValuesOffset = Seg2Filespace(copyValues, parent->baseAddress); - - for (size_t i = 0; i < copyValuesSize; i++) - copyValuesArr.emplace_back(BitConverter::ToInt16BE(rawData, copyValuesOffset + i * 2)); - } -} - -void ZCurveAnimation::DeclareReferences(const std::string& prefix) -{ - if (refIndex != 0) - { - uint32_t refIndexOffset = Seg2Filespace(refIndex, parent->baseAddress); - std::string refIndexStr = - StringHelper::Sprintf("%sCurveAnime_%s_%06X", prefix.c_str(), "Ref", refIndexOffset); - - std::string entryStr = " "; - uint16_t arrayItemCnt = refIndexArr.size(); - - size_t i = 0; - for (auto& child : refIndexArr) - { - entryStr += StringHelper::Sprintf("0x%02X, %s", child, (i++ % 8 == 7) ? "\n " : ""); - } - - Declaration* decl = parent->GetDeclaration(refIndexOffset); - if (decl == nullptr) - { - parent->AddDeclarationArray(refIndexOffset, DeclarationAlignment::Align4, - arrayItemCnt * 1, "u8", refIndexStr, arrayItemCnt, - entryStr); - } - else - { - decl->text = entryStr; - } - } - - if (transformData != 0) - { - uint32_t transformDataOffset = Seg2Filespace(transformData, parent->baseAddress); - std::string transformDataStr = StringHelper::Sprintf( - "%sCurveAnime_%s_%06X", prefix.c_str(), - transformDataArr.at(0).GetSourceTypeName().c_str(), transformDataOffset); - - std::string entryStr; - uint16_t arrayItemCnt = transformDataArr.size(); - - size_t i = 0; - for (auto& child : transformDataArr) - { - entryStr += StringHelper::Sprintf(" { %s },%s", child.GetBody(prefix).c_str(), - (++i < arrayItemCnt) ? "\n" : ""); - } - - Declaration* decl = parent->GetDeclaration(transformDataOffset); - if (decl == nullptr) - { - parent->AddDeclarationArray(transformDataOffset, DeclarationAlignment::Align4, - arrayItemCnt * transformDataArr.at(0).GetRawDataSize(), - transformDataArr.at(0).GetSourceTypeName(), - transformDataStr, arrayItemCnt, entryStr); - } - else - { - decl->text = entryStr; - } - } - - if (copyValues != 0) - { - uint32_t copyValuesOffset = Seg2Filespace(copyValues, parent->baseAddress); - std::string copyValuesStr = - StringHelper::Sprintf("%sCurveAnime_%s_%06X", prefix.c_str(), "Copy", copyValuesOffset); - - std::string entryStr = " "; - uint16_t arrayItemCnt = copyValuesArr.size(); - - size_t i = 0; - for (auto& child : copyValuesArr) - { - entryStr += StringHelper::Sprintf("% 6i, %s", child, (i++ % 8 == 7) ? "\n " : ""); - } - - Declaration* decl = parent->GetDeclaration(copyValuesOffset); - if (decl == nullptr) - { - parent->AddDeclarationArray(copyValuesOffset, DeclarationAlignment::Align4, - arrayItemCnt * 2, "s16", copyValuesStr, arrayItemCnt, - entryStr); - } - else - { - decl->text = entryStr; - } - } -} - -std::string ZCurveAnimation::GetBodySourceCode() const -{ - std::string refIndexStr; - Globals::Instance->GetSegmentedPtrName(refIndex, parent, "u8", refIndexStr, parent->workerID); - std::string transformDataStr; - Globals::Instance->GetSegmentedPtrName(transformData, parent, "TransformData", - transformDataStr, parent->workerID); - std::string copyValuesStr; - Globals::Instance->GetSegmentedPtrName(copyValues, parent, "s16", copyValuesStr, - parent->workerID); - - return StringHelper::Sprintf("\n\t%s,\n\t%s,\n\t%s,\n\t%i, %i\n", refIndexStr.c_str(), - transformDataStr.c_str(), copyValuesStr.c_str(), unk_0C, unk_10); -} - -size_t ZCurveAnimation::GetRawDataSize() const -{ - return 0x10; -} - -DeclarationAlignment ZCurveAnimation::GetDeclarationAlignment() const -{ - return DeclarationAlignment::Align4; -} - -std::string ZCurveAnimation::GetSourceTypeName() const -{ - return "TransformUpdateIndex"; -} - -/* ZLegacyAnimation */ - -ZLegacyAnimation::ZLegacyAnimation(ZFile* nParent) : ZAnimation(nParent) -{ -} - -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; - std::string jointKeyName; - Globals::Instance->GetSegmentedPtrName(frameData, parent, "s16", frameDataName, - parent->workerID); - Globals::Instance->GetSegmentedPtrName(jointKey, parent, "JointKey", jointKeyName, - parent->workerID); - - 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::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/ZAPDTR/ZAPD/ZAnimation.h b/ZAPDTR/ZAPD/ZAnimation.h deleted file mode 100644 index 956e7faee..000000000 --- a/ZAPDTR/ZAPD/ZAnimation.h +++ /dev/null @@ -1,180 +0,0 @@ -#pragma once - -#include -#include -#include -#include "Vec3s.h" -#include "ZResource.h" -#include "ZSkeleton.h" -#include "tinyxml2.h" - -struct RotationIndex -{ - // uint16_t transX, transY, transZ; - uint16_t x, y, z; - - RotationIndex(uint16_t nX, uint16_t nY, uint16_t nZ) : x(nX), y(nY), z(nZ) {} -}; - -class ZAnimation : public ZResource -{ -public: - int16_t frameCount; - - ZAnimation(ZFile* nParent); - - //std::string GetSourceOutputHeader(const std::string& prefix) override; - ZResourceType GetResourceType() const override; - -protected: - void ParseRawData() override; -}; - -class ZNormalAnimation : public ZAnimation -{ -public: - std::vector rotationValues; - std::vector rotationIndices; - segptr_t rotationValuesSeg = 0; - segptr_t rotationIndicesSeg = 0; - offset_t rotationValuesOffset = 0; - offset_t rotationIndicesOffset = 0; - int16_t limit = 0; - - ZNormalAnimation(ZFile* nParent); - - void DeclareReferences(const std::string& prefix) override; - - std::string GetBodySourceCode() const override; - - size_t GetRawDataSize() const override; - std::string GetSourceTypeName() const override; - - void ParseRawData() override; -}; - -class ZLinkAnimation : public ZAnimation -{ -public: - segptr_t segmentAddress; - - ZLinkAnimation(ZFile* nParent); - - std::string GetBodySourceCode() const override; - - size_t GetRawDataSize() const override; - std::string GetSourceTypeName() const override; - - void ParseRawData() override; -}; - -class TransformData -{ -public: - ZFile* parent; - - ///* 0x0000 */ u16 unk_00; // appears to be flags - uint16_t unk_00; - ///* 0x0002 */ s16 unk_02; - int16_t unk_02; - ///* 0x0004 */ s16 unk_04; - int16_t unk_04; - ///* 0x0006 */ s16 unk_06; - int16_t unk_06; - ///* 0x0008 */ f32 unk_08; - float unk_08; - -public: - TransformData() = default; - TransformData(ZFile* parent, const std::vector& rawData, uint32_t fileOffset); - TransformData(ZFile* parent, const std::vector& rawData, uint32_t fileOffset, - size_t index); - - [[nodiscard]] std::string GetBody(const std::string& prefix) const; - - size_t GetRawDataSize() const; - std::string GetSourceTypeName(); -}; - -class ZCurveAnimation : public ZAnimation -{ -public: - segptr_t skelOffset = 0; - - ///* 0x0000 */ u8* refIndex; - segptr_t refIndex = 0; - ///* 0x0004 */ TransformData* transformData; - segptr_t transformData = 0; - ///* 0x0008 */ s16* copyValues; - segptr_t copyValues = 0; - ///* 0x000C */ s16 unk_0C; - int16_t unk_0C; - ///* 0x000E */ s16 unk_10; - int16_t unk_10; - - uint8_t limbCount = 0; - - std::vector refIndexArr; - std::vector transformDataArr; - std::vector copyValuesArr; - -public: - ZCurveAnimation(ZFile* nParent); - - void ParseXML(tinyxml2::XMLElement* reader) override; - void ParseRawData() override; - - void DeclareReferences(const std::string& prefix) override; - - std::string GetBodySourceCode() const override; - - size_t GetRawDataSize() const override; - DeclarationAlignment GetDeclarationAlignment() const override; - - 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 ParseRawData() override; - void DeclareReferences(const std::string& prefix) override; - - std::string GetBodySourceCode() const 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/ZAPDTR/ZAPD/ZArray.cpp b/ZAPDTR/ZAPD/ZArray.cpp deleted file mode 100644 index 8725e28cc..000000000 --- a/ZAPDTR/ZAPD/ZArray.cpp +++ /dev/null @@ -1,153 +0,0 @@ -#include "ZArray.h" - -#include - -#include "Globals.h" -#include "Utils/StringHelper.h" -#include "WarningHandler.h" -#include "ZFile.h" - -REGISTER_ZFILENODE(Array, ZArray); - -ZArray::ZArray(ZFile* nParent) : ZResource(nParent) -{ - canHaveInner = true; - genOTRDef = true; - RegisterRequiredAttribute("Count"); -} - -ZArray::~ZArray() -{ - for (auto res : resList) - delete res; -} - -void ZArray::ParseXML(tinyxml2::XMLElement* reader) -{ - ZResource::ParseXML(reader); - - arrayCnt = reader->IntAttribute("Count", 0); - if (arrayCnt <= 0) - { - HANDLE_ERROR_RESOURCE(WarningType::InvalidAttributeValue, parent, this, rawDataIndex, - "invalid value found for 'Count' attribute", ""); - } - - tinyxml2::XMLElement* child = reader->FirstChildElement(); - if (child == nullptr) - { - HANDLE_ERROR_RESOURCE(WarningType::InvalidXML, parent, this, rawDataIndex, - " needs one sub-element", ""); - } - - childName = child->Name(); - - auto nodeMap = ZFile::GetNodeMap(); - size_t childIndex = rawDataIndex; - resList.reserve(arrayCnt); - for (size_t i = 0; i < arrayCnt; i++) - { - ZResource* res = nodeMap->at(childName)(parent); - if (!res->DoesSupportArray()) - { - std::string errorHeader = StringHelper::Sprintf( - "resource <%s> does not support being wrapped in an ", childName.c_str()); - HANDLE_ERROR_RESOURCE(WarningType::InvalidXML, parent, this, rawDataIndex, errorHeader, - ""); - } - res->parent = parent; - res->SetInnerNode(true); - res->ExtractFromXML(child, childIndex); - - childIndex += res->GetRawDataSize(); - resList.push_back(res); - } -} - -Declaration* ZArray::DeclareVar(const std::string& prefix, const std::string& bodyStr) -{ - std::string auxName = name; - - if (name == "") - auxName = GetDefaultName(prefix); - - ZResource* res = resList.at(0); - Declaration* decl; - if (res->IsExternalResource()) - { - auto filepath = Globals::Instance->outputPath / name; - std::string includePath = StringHelper::Sprintf("%s.%s.inc", filepath.c_str(), - res->GetExternalExtension().c_str()); - decl = parent->AddDeclarationIncludeArray(rawDataIndex, includePath, GetRawDataSize(), - GetSourceTypeName(), name, arrayCnt); - decl->text = bodyStr; - decl->isExternal = true; - } - else - { - decl = - parent->AddDeclarationArray(rawDataIndex, GetDeclarationAlignment(), GetRawDataSize(), - GetSourceTypeName(), name, arrayCnt, bodyStr); - } - - decl->staticConf = staticConf; - return decl; -} - -std::string ZArray::GetBodySourceCode() const -{ - std::string output; - - for (size_t i = 0; i < arrayCnt; i++) - { - const auto& res = resList[i]; - output += "\t"; - - switch (res->GetResourceType()) - { - case ZResourceType::Pointer: - case ZResourceType::Scalar: - case ZResourceType::Vertex: - case ZResourceType::CollisionPoly: - case ZResourceType::SurfaceType: - output += resList.at(i)->GetBodySourceCode(); - break; - - default: - output += StringHelper::Sprintf("{ %s }", resList.at(i)->GetBodySourceCode().c_str()); - break; - } - - if (i < arrayCnt - 1 || res->IsExternalResource()) - output += ",\n"; - } - - return output; -} - -size_t ZArray::GetRawDataSize() const -{ - size_t size = 0; - for (const auto res : resList) - size += res->GetRawDataSize(); - return size; -} - -std::string ZArray::GetSourceTypeName() const -{ - return resList.at(0)->GetSourceTypeName(); -} - -ZResourceType ZArray::GetResourceType() const -{ - return ZResourceType::Array; -} - -DeclarationAlignment ZArray::GetDeclarationAlignment() const -{ - if (resList.size() == 0) - { - return DeclarationAlignment::Align4; - } - return resList.at(0)->GetDeclarationAlignment(); -} diff --git a/ZAPDTR/ZAPD/ZArray.h b/ZAPDTR/ZAPD/ZArray.h deleted file mode 100644 index e6594fadc..000000000 --- a/ZAPDTR/ZAPD/ZArray.h +++ /dev/null @@ -1,31 +0,0 @@ -#pragma once - -#include -#include -#include -#include "ZResource.h" -#include "tinyxml2.h" - -class ZArray : public ZResource -{ -public: - ZArray(ZFile* nParent); - ~ZArray(); - - void ParseXML(tinyxml2::XMLElement* reader) override; - - Declaration* DeclareVar(const std::string& prefix, const std::string& bodyStr) override; - std::string GetBodySourceCode() const override; - - size_t GetRawDataSize() const override; - - std::string GetSourceTypeName() const override; - ZResourceType GetResourceType() const override; - - DeclarationAlignment GetDeclarationAlignment() const override; - - size_t arrayCnt; - std::vector resList; -protected: - std::string childName; -}; diff --git a/ZAPDTR/ZAPD/ZAudio.cpp b/ZAPDTR/ZAPD/ZAudio.cpp deleted file mode 100644 index 9f2059271..000000000 --- a/ZAPDTR/ZAPD/ZAudio.cpp +++ /dev/null @@ -1,415 +0,0 @@ -#include "ZAudio.h" - -#include "Globals.h" -#include "Utils/BitConverter.h" -#include -#include "Utils/Path.h" -#include "Utils/StringHelper.h" -#include "ZFile.h" - -REGISTER_ZFILENODE(Audio, ZAudio); - -ZAudio::ZAudio(ZFile* nParent) : ZResource(nParent) -{ - RegisterRequiredAttribute("SoundFontTableOffset"); - RegisterRequiredAttribute("SequenceTableOffset"); - RegisterRequiredAttribute("SampleBankTableOffset"); - RegisterRequiredAttribute("SequenceFontTableOffset"); -} - -void ZAudio::ParseXML(tinyxml2::XMLElement* reader) -{ - ZResource::ParseXML(reader); - - auto t = reader->Name(); - - auto child = reader->FirstChildElement(); - - while (child != nullptr) - { - if (std::string(child->Value()) == "Sequences") - { - auto seqChild = child->FirstChildElement(); - - while (seqChild != nullptr) - { - if (std::string(seqChild->Value()) == "Sequence") - { - seqNames.push_back(seqChild->Attribute("Name")); - } - - seqChild = seqChild->NextSiblingElement(); - } - } - - if (std::string(child->Value()) == "Samples") - { - int bankId = child->IntAttribute("Bank", 0); - auto sampChild = child->FirstChildElement(); - - while (sampChild != nullptr) - { - if (std::string(sampChild->Value()) == "Sample") - { - auto atStr = sampChild->FirstChildElement()->Attribute("At"); - auto loopStr = sampChild->FirstChildElement()->Attribute("LoopOffset"); - uint32_t loopOffset = 0xFFFFFFFF; - uint32_t atOffset = StringHelper::StrToL(atStr, 16); - - if (loopStr != NULL) - { - loopOffset = StringHelper::StrToL(loopStr, 16); - specialLoopSamples[loopOffset] = atOffset; - } - - sampleOffsets[bankId][loopOffset][atOffset] = sampChild->Attribute("Name"); - } - - sampChild = sampChild->NextSiblingElement(); - } - } - - if (std::string(child->Value()) == "Soundfont") - { - auto name = child->Attribute("Name"); - auto index = child->IntAttribute("Index", 0); - soundFontNames[index] = name; - } - - child = child->NextSiblingElement(); - } -} - -void ZAudio::DecodeADPCMSample(SampleEntry* sample) -{ - int16_t buffer[1024 * 128]; - - int16_t* out = &buffer[0]; -} - -std::vector ZAudio::ParseEnvelopeData(std::vector audioBank, std::vector audioTable, int envelopeOffset, int baseOffset) -{ - std::vector result; - - while (true) - { - AdsrEnvelope* env = new AdsrEnvelope(); - - env->delay = BitConverter::ToInt16BE(audioBank, envelopeOffset + 0); - env->arg = BitConverter::ToInt16BE(audioBank, envelopeOffset + 2); - - envelopeOffset += 4; - - result.push_back(env); - - if (env->delay < 0) - break; - } - - return result; -} - -SoundFontEntry* ZAudio::ParseSoundFontEntry(std::vector audioBank, - std::vector audioTable, - AudioTableEntry audioSampleBankEntry, int bankIndex, - int soundFontOffset, - int baseOffset) -{ - SoundFontEntry* soundFont = new SoundFontEntry(); - soundFont->sampleEntry = ParseSampleEntry( - audioBank, audioTable, audioSampleBankEntry, bankIndex, - BitConverter::ToInt32BE(audioBank, soundFontOffset + 0) + baseOffset, baseOffset); - soundFont->tuning = BitConverter::ToFloatBE(audioBank, soundFontOffset + 4); - - return soundFont; -} - -SampleEntry* ZAudio::ParseSampleEntry(std::vector audioBank, - std::vector audioTable, - AudioTableEntry audioSampleBankEntry, int bankIndex, - int sampleOffset, - int baseOffset) -{ - int sampleDataOffset = BitConverter::ToInt32BE(audioBank, sampleOffset + 4) + audioSampleBankEntry.ptr; - - if (samples.find(sampleOffset) == samples.end()) - { - SampleEntry* sample = new SampleEntry(); - - sample->bankId = bankIndex; - - int sampleSize = BitConverter::ToInt32BE(audioBank, sampleOffset + 0) & 0x00FFFFFF; - int loopOffset = BitConverter::ToInt32BE(audioBank, sampleOffset + 8) + baseOffset; - int bookOffset = BitConverter::ToInt32BE(audioBank, sampleOffset + 12) + baseOffset; - - char* sampleData = (char*)malloc(sampleSize); - memcpy(sampleData, audioTable.data() + sampleDataOffset, sampleSize); - sample->data = std::vector(sampleSize); - memcpy(sample->data.data(), sampleData, sampleSize); - - uint32_t origField = (BitConverter::ToUInt32BE(audioBank, sampleOffset + 0)); - sample->codec = (origField >> 28) & 0x0F; - sample->medium = (origField >> 24) & 0x03; - sample->unk_bit26 = (origField >> 22) & 0x01; - sample->unk_bit25 = (origField >> 21) & 0x01; - - sample->loop.start = BitConverter::ToInt32BE(audioBank, loopOffset + 0); - sample->loop.end = BitConverter::ToInt32BE(audioBank, loopOffset + 4); - sample->loop.count = BitConverter::ToInt32BE(audioBank, loopOffset + 8); - - if (sample->loop.count != 0) - { - for (int i = 0; i < 16; i++) - { - int16_t state = BitConverter::ToInt16BE(audioBank, loopOffset + 16 + (i * 2)); - sample->loop.states.push_back(state); - } - } - - sample->book.order = BitConverter::ToInt32BE(audioBank, bookOffset + 0); - sample->book.npredictors = BitConverter::ToInt32BE(audioBank, bookOffset + 4); - - for (int i = 0; i < sample->book.npredictors * sample->book.order * 8; i++) - { - sample->book.books.push_back( - BitConverter::ToInt16BE(audioBank, bookOffset + 8 + (i * 2))); - } - - sample->sampleDataOffset = sampleDataOffset; - - if (specialLoopSamples.find(loopOffset) != specialLoopSamples.end()) - sample->sampleLoopOffset = loopOffset; - - sample->fileName = StringHelper::Sprintf("audio/samples/sample_%08X", sampleOffset); - - samples[sampleOffset] = sample; - - return sample; - } - else - { - return samples[sampleOffset]; - } -} - -std::vector ZAudio::ParseAudioTable(std::vector codeData, int baseOffset) -{ - std::vector entries; - - int numEntries = BitConverter::ToInt16BE(codeData, baseOffset + 0); - int romAddr = BitConverter::ToInt16BE(codeData, baseOffset + 4); - - int currentOffset = baseOffset + 16; - - for (int i = 0; i < numEntries; i++) - { - AudioTableEntry entry; - - entry.ptr = BitConverter::ToInt32BE(codeData, currentOffset + 0); - entry.size = BitConverter::ToInt32BE(codeData, currentOffset + 4); - entry.medium = codeData[currentOffset + 8]; - entry.cachePolicy = codeData[currentOffset + 9]; - entry.data1 = BitConverter::ToInt16BE(codeData, currentOffset + 10); - entry.data2 = BitConverter::ToInt16BE(codeData, currentOffset + 12); - entry.data3 = BitConverter::ToInt16BE(codeData, currentOffset + 14); - - entries.push_back(entry); - - currentOffset += 16; - } - - return entries; -} - -void ZAudio::ParseSoundFont(std::vector codeData, std::vector audioTable, - std::vector audioSampleBank, - AudioTableEntry& entry) -{ - int ptr = entry.ptr; - int size = entry.size; - int sampleBankId1 = (entry.data1 >> 8) & 0xFF; - int sampleBankId2 = (entry.data1) & 0xFF; - int numInstruments = (entry.data2 >> 8) & 0xFF; - int numDrums = entry.data2 & 0xFF; - int numSfx = entry.data3; - - int currentOffset = BitConverter::ToInt32BE(codeData, ptr) + ptr; - for (int i = 0; i < numDrums; i++) - { - DrumEntry drum; - - int samplePtr = BitConverter::ToInt32BE(codeData, currentOffset); - - if (samplePtr != 0) - { - samplePtr += ptr; - - drum.sample = ParseSampleEntry(codeData, audioTable, audioSampleBank[sampleBankId1], sampleBankId1, - BitConverter::ToInt32BE(codeData, samplePtr + 4) + ptr, ptr); - - drum.releaseRate = codeData[samplePtr + 0]; - drum.pan = codeData[samplePtr + 1]; - drum.loaded = codeData[samplePtr + 2]; - drum.tuning = BitConverter::ToFloatBE(codeData, samplePtr + 8); - drum.env = ParseEnvelopeData(codeData, audioTable, BitConverter::ToInt32BE(codeData, samplePtr + 12) + ptr, ptr); - } - - entry.drums.push_back(drum); - - currentOffset += 4; - } - - currentOffset = BitConverter::ToInt32BE(codeData, ptr + 4) + ptr; - for (int i = 0; i < numSfx; i++) - { - SoundFontEntry* sfx; - sfx = ParseSoundFontEntry(codeData, audioTable, audioSampleBank[sampleBankId1], sampleBankId1, - currentOffset, ptr); - entry.soundEffects.push_back(sfx); - - currentOffset += 8; - } - - for (int i = 0; i < numInstruments; i++) - { - InstrumentEntry instrument; - - currentOffset = BitConverter::ToInt32BE(codeData, ptr + 8 + (i * 4)); - - instrument.isValidInstrument = currentOffset != 0; - - if (currentOffset != 0) - { - currentOffset += ptr; - - instrument.loaded = codeData[currentOffset + 0]; - instrument.normalRangeLo = codeData[currentOffset + 1]; - instrument.normalRangeHi = codeData[currentOffset + 2]; - instrument.releaseRate = codeData[currentOffset + 3]; - instrument.env = ParseEnvelopeData(codeData, audioTable, BitConverter::ToInt32BE(codeData, currentOffset + 4) + ptr, ptr); - - if (BitConverter::ToInt32BE(codeData, currentOffset + 8) != 0) - instrument.lowNotesSound = ParseSoundFontEntry( - codeData, audioTable, audioSampleBank[sampleBankId1], sampleBankId1, currentOffset + 8, ptr); - - if (BitConverter::ToInt32BE(codeData, currentOffset + 16) != 0) - instrument.normalNotesSound = ParseSoundFontEntry( - codeData, audioTable, audioSampleBank[sampleBankId1], sampleBankId1, currentOffset + 16, ptr); - - if (BitConverter::ToInt32BE(codeData, currentOffset + 24) != 0 && - instrument.normalRangeHi != 0x7F) - instrument.highNotesSound = ParseSoundFontEntry( - codeData, audioTable, audioSampleBank[sampleBankId1], sampleBankId1, currentOffset + 24, ptr); - } - - entry.instruments.push_back(instrument); - } -} - -void ZAudio::ParseRawData() -{ - ZResource::ParseRawData(); - - std::vector codeData; - std::vector audioTableData; - std::vector audioBankData; - std::vector audioSeqData; - - if (Globals::Instance->fileMode == ZFileMode::ExtractDirectory) - codeData = Globals::Instance->GetBaseromFile("code"); - else - codeData = Globals::Instance->GetBaseromFile(Globals::Instance->baseRomPath.string() + "code"); - - if (Globals::Instance->fileMode == ZFileMode::ExtractDirectory) - audioTableData = Globals::Instance->GetBaseromFile("Audiotable"); - else - audioTableData = Globals::Instance->GetBaseromFile(Globals::Instance->baseRomPath.string() + "Audiotable"); - - if (Globals::Instance->fileMode == ZFileMode::ExtractDirectory) - audioBankData = Globals::Instance->GetBaseromFile("Audiobank"); - else - audioBankData = Globals::Instance->GetBaseromFile(Globals::Instance->baseRomPath.string() + "Audiobank"); - - - if (Globals::Instance->fileMode == ZFileMode::ExtractDirectory) - audioSeqData = Globals::Instance->GetBaseromFile("Audioseq"); - else - audioSeqData = Globals::Instance->GetBaseromFile(Globals::Instance->baseRomPath.string() + - "Audioseq"); - - // TABLE PARSING - - // MQ DBG ROM - //int gSoundFontTableOffset = 0x138270; - //int gSequenceTableOffset = 0x1386A0; - //int gSampleBankTableOffset = 0x138D90; - //int gSequenceFontTableOffset = 0x1384E0; - - // NTSC 1.0 - //int gSoundFontTableOffset = 0x1026A0; - //int gSequenceTableOffset = 0x102AD0; - //int gSampleBankTableOffset = 0x1031C0; - //int gSequenceFontTableOffset = 0x102910; - - int gSoundFontTableOffset = StringHelper::StrToL(registeredAttributes.at("SoundFontTableOffset").value, 16); - int gSequenceTableOffset = StringHelper::StrToL(registeredAttributes.at("SequenceTableOffset").value, 16); - int gSampleBankTableOffset = StringHelper::StrToL(registeredAttributes.at("SampleBankTableOffset").value, 16); - int gSequenceFontTableOffset = StringHelper::StrToL(registeredAttributes.at("SequenceFontTableOffset").value, 16); - - soundFontTable = ParseAudioTable(codeData, gSoundFontTableOffset); - sequenceTable = ParseAudioTable(codeData, gSequenceTableOffset); - sampleBankTable = ParseAudioTable(codeData, gSampleBankTableOffset); - - // SEQEUNCE FONT TABLE PARSING - for (int i = 0; i < sequenceTable.size(); i++) - { - uint16_t idx = BitConverter::ToUInt16BE(codeData, gSequenceFontTableOffset + (i * 2)); - uint8_t numFonts = codeData[gSequenceFontTableOffset + (idx++)]; - std::vector fontIds; - - for (int j = 0; j < numFonts; j++) - { - uint8_t fontId = codeData[gSequenceFontTableOffset + (idx++)]; - fontIds.push_back(fontId); - } - - fontIndices.push_back(fontIds); - } - - - // SAMPLE/FONT PARSING - for (int i = 0; i < soundFontTable.size(); i++) - { - ParseSoundFont(audioBankData, audioTableData, sampleBankTable, soundFontTable[i]); - } - - // SEQUENCE PARSING - for (int i = 0; i < sequenceTable.size(); i++) - { - int seqDestIdx = i; - - if (sequenceTable[i].size == 0) - seqDestIdx = sequenceTable[i].ptr; - - std::vector seqVec = std::vector(sequenceTable[seqDestIdx].size); - memcpy(seqVec.data(), audioSeqData.data() + sequenceTable[seqDestIdx].ptr, - sequenceTable[seqDestIdx].size); - - sequences.push_back(seqVec); - } -} - -std::string ZAudio::GetSourceTypeName() const -{ - return "u8"; -} - -size_t ZAudio::GetRawDataSize() const -{ - return 1; -} - -ZResourceType ZAudio::GetResourceType() const -{ - return ZResourceType::Audio; -} diff --git a/ZAPDTR/ZAPD/ZAudio.h b/ZAPDTR/ZAPD/ZAudio.h deleted file mode 100644 index 286c75c11..000000000 --- a/ZAPDTR/ZAPD/ZAudio.h +++ /dev/null @@ -1,134 +0,0 @@ -#pragma once - -#include "ZResource.h" -#include "tinyxml2.h" - -struct AdsrEnvelope -{ - int16_t delay; - int16_t arg; -}; - -struct AdpcmBook -{ - /* 0x00 */ int32_t order; - /* 0x04 */ int32_t npredictors; - /* 0x08 */ std::vector books; // size 8 * order * npredictors. 8-byte aligned -}; - -struct AdpcmLoop -{ - /* 0x00 */ uint32_t start; - /* 0x04 */ uint32_t end; - /* 0x08 */ uint32_t count; - /* 0x10 */ std::vector states; -}; - -struct SampleEntry -{ - std::string fileName; - uint8_t bankId; - uint32_t sampleDataOffset; - uint32_t sampleLoopOffset = 0xFFFFFFFF; - uint8_t codec; - uint8_t medium; - uint8_t unk_bit26; - uint8_t unk_bit25; - - std::vector data; - AdpcmLoop loop; - AdpcmBook book; -}; - -struct SoundFontEntry -{ - SampleEntry* sampleEntry = nullptr; - float tuning; -}; - -struct DrumEntry -{ - uint8_t releaseRate; - uint8_t pan; - uint8_t loaded; - uint32_t offset; - float tuning; - std::vector env; - SampleEntry* sample = nullptr; -}; - -struct InstrumentEntry -{ - bool isValidInstrument; - uint8_t loaded; - uint8_t normalRangeLo; - uint8_t normalRangeHi; - uint8_t releaseRate; - std::vector env; - SoundFontEntry* lowNotesSound = nullptr; - SoundFontEntry* normalNotesSound = nullptr; - SoundFontEntry* highNotesSound = nullptr; -}; - -struct AudioTableEntry -{ - uint32_t ptr; - uint32_t size; - uint8_t medium; - uint8_t cachePolicy; - uint16_t data1; - uint16_t data2; - uint16_t data3; - - std::vector drums; - std::vector soundEffects; - std::vector instruments; -}; - -class ZAudio : public ZResource -{ -public: - std::vector soundFontTable; - std::vector sequenceTable; - std::vector sampleBankTable; - std::vector> sequences; - std::map samples; - std::vector> fontIndices; - std::vector seqNames; - std::map soundFontNames; - - // First Key = Bank ID, Sec Key = LoopDataOffset, Third Key = Sample Data Offset - std::map>> sampleOffsets; - - // Key = Loop Offset, Value = Sample Offset - std::map specialLoopSamples; - - ZAudio(ZFile* nParent); - - void ParseXML(tinyxml2::XMLElement* reader) override; - - void DecodeADPCMSample(SampleEntry* sample); - std::vector ParseEnvelopeData(std::vector audioBank, std::vector audioTable, - int envelopeOffset, int baseOffset); - - SoundFontEntry* ParseSoundFontEntry(std::vector audioBank, - std::vector audioTable, - AudioTableEntry audioSampleBankEntry, int bankIndex, - int soundFontOffset, - int baseOffset); - - SampleEntry* ParseSampleEntry(std::vector audioBank, std::vector audioTable, - AudioTableEntry audioSampleBankEntry, int bankIndex, - int sampleOffset, int baseOffset); - - std::vector ParseAudioTable(std::vector codeData, int baseOffset); - void ParseSoundFont(std::vector codeData, std::vector audioTable, - std::vector audioSampleBank, AudioTableEntry& entry); - - void ParseRawData() override; - - std::string GetSourceTypeName() const override; - ZResourceType GetResourceType() const override; - - size_t GetRawDataSize() const override; -}; diff --git a/ZAPDTR/ZAPD/ZAudioDecode.cpp b/ZAPDTR/ZAPD/ZAudioDecode.cpp deleted file mode 100644 index 90ecfe35c..000000000 --- a/ZAPDTR/ZAPD/ZAudioDecode.cpp +++ /dev/null @@ -1,669 +0,0 @@ -/** - * Bruteforcing decoder for converting ADPCM-encoded AIFC into AIFF, in a way - * that roundtrips with vadpcm_enc. - */ -#include -#include -#include -#include -#include -#include -//#include - -typedef signed char s8; -typedef short s16; -typedef int s32; -typedef long long s64; -typedef unsigned char u8; -typedef unsigned short u16; -typedef unsigned int u32; -typedef unsigned long long u64; -typedef float f32; -typedef double f64; - -#ifdef _MSC_VER -#define __builtin_bswap16 _byteswap_ushort -#define __builtin_bswap32 _byteswap_ulong -#endif - -#define bswap16(x) __builtin_bswap16(x) -#define bswap32(x) __builtin_bswap32(x) -#define BSWAP16(x) x = __builtin_bswap16(x) -#define BSWAP32(x) x = __builtin_bswap32(x) -#define BSWAP16_MANY(x, n) \ - for (s32 _i = 0; _i < n; _i++) \ - BSWAP16((x)[_i]) - -#define NORETURN __attribute__((noreturn)) -#define UNUSED __attribute__((unused)) - -typedef struct -{ - u32 ckID; - u32 ckSize; -} ChunkHeader; - -typedef struct -{ - u32 ckID; - u32 ckSize; - u32 formType; -} Chunk; - -typedef struct -{ - s16 numChannels; - u16 numFramesH; - u16 numFramesL; - s16 sampleSize; - s16 sampleRate[5]; // 80-bit float - u16 compressionTypeH; - u16 compressionTypeL; -} CommonChunk; - -typedef struct -{ - s16 MarkerID; - u16 positionH; - u16 positionL; -} Marker; - -typedef struct -{ - s16 playMode; - s16 beginLoop; - s16 endLoop; -} Loop; - -typedef struct -{ - s8 baseNote; - s8 detune; - s8 lowNote; - s8 highNote; - s8 lowVelocity; - s8 highVelocity; - s16 gain; - Loop sustainLoop; - Loop releaseLoop; -} InstrumentChunk; - -typedef struct -{ - s32 offset; - s32 blockSize; -} SoundDataChunk; - -typedef struct -{ - s16 version; - s16 order; - s16 nEntries; -} CodeChunk; - -typedef struct -{ - u32 start; - u32 end; - u32 count; - s16 state[16]; -} ALADPCMloop; - -static char usage[] = "input.aifc output.aiff"; -static const char *progname, *infilename; -static int framesize = 9; - -void fail_parse(const char* fmt, ...) -{ - char* formatted = NULL; - va_list ap; - va_start(ap, fmt); - int size = vsnprintf(NULL, 0, fmt, ap); - va_end(ap); - if (size >= 0) - { - size++; - formatted = (char*)malloc(size); - if (formatted != NULL) - { - va_start(ap, fmt); - size = vsnprintf(formatted, size, fmt, ap); - va_end(ap); - if (size < 0) - { - free(formatted); - formatted = NULL; - } - } - } - - if (formatted != NULL) - { - fprintf(stderr, "%s: %s [%s]\n", progname, formatted, infilename); - free(formatted); - } - exit(1); -} - - -s32 myrand() -{ - static u64 state = 1619236481962341ULL; - state *= 3123692312237ULL; - state += 1; - return state >> 33; -} - -s16 qsample(f32 x, s32 scale) -{ - if (x > 0.0f) - { - return (s16)((x / scale) + 0.4999999); - } - else - { - return (s16)((x / scale) - 0.4999999); - } -} - -void clamp_to_s16(f32* in, s32* out) -{ - f32 llevel = -0x8000; - f32 ulevel = 0x7fff; - - for (s32 i = 0; i < 16; i++) - { - if (in[i] > ulevel) - in[i] = ulevel; - if (in[i] < llevel) - in[i] = llevel; - - if (in[i] > 0.0f) - { - out[i] = (s32)(in[i] + 0.5); - } - else - { - out[i] = (s32)(in[i] - 0.5); - } - } -} - -s16 clamp_bits(s32 x, s32 bits) -{ - s32 lim = 1 << (bits - 1); - if (x < -lim) - return -lim; - if (x > lim - 1) - return lim - 1; - return x; -} - -s32 readaifccodebook(FILE* fhandle, s32**** table, s16* order, s16* npredictors) -{ - BSWAP16(*order); - BSWAP16(*npredictors); - *table = (s32***)malloc(*npredictors * sizeof(s32**)); - for (s32 i = 0; i < *npredictors; i++) - { - (*table)[i] = (s32**)malloc(8 * sizeof(s32*)); - for (s32 j = 0; j < 8; j++) - { - (*table)[i][j] = (s32*)malloc((*order + 8) * sizeof(s32)); - } - } - - for (s32 i = 0; i < *npredictors; i++) - { - s32** table_entry = (*table)[i]; - for (s32 j = 0; j < *order; j++) - { - for (s32 k = 0; k < 8; k++) - { - s16 ts = 0; - BSWAP16(ts); - table_entry[k][j] = ts; - } - } - - for (s32 k = 1; k < 8; k++) - { - table_entry[k][*order] = table_entry[k - 1][*order - 1]; - } - - table_entry[0][*order] = 1 << 11; - - for (s32 k = 1; k < 8; k++) - { - s32 j = 0; - for (; j < k; j++) - { - table_entry[j][k + *order] = 0; - } - - for (; j < 8; j++) - { - table_entry[j][k + *order] = table_entry[j - k][*order]; - } - } - } - return 0; -} - -ALADPCMloop* readlooppoints(FILE* ifile, s16* nloops) -{ - BSWAP16(*nloops); - ALADPCMloop* al = (ALADPCMloop*)malloc(*nloops * sizeof(ALADPCMloop)); - for (s32 i = 0; i < *nloops; i++) - { - BSWAP32(al[i].start); - BSWAP32(al[i].end); - BSWAP32(al[i].count); - BSWAP16_MANY(al[i].state, 16); - } - return al; -} - -s32 inner_product(s32 length, s32* v1, s32* v2) -{ - s32 out = 0; - for (s32 i = 0; i < length; i++) - { - out += v1[i] * v2[i]; - } - - // Compute "out / 2^11", rounded down. - s32 dout = out / (1 << 11); - s32 fiout = dout * (1 << 11); - return dout - (out - fiout < 0); -} - -void my_decodeframe(u8* frame, s32* decompressed, s32* state, s32 order, s32*** coefTable) -{ - s32 ix[16]; - - u8 header = frame[0]; - s32 scale = 1 << (header >> 4); - s32 optimalp = header & 0xf; - - if (framesize == 5) - { - for (s32 i = 0; i < 16; i += 4) - { - u8 c = frame[1 + i / 4]; - ix[i] = c >> 6; - ix[i + 1] = (c >> 4) & 0x3; - ix[i + 2] = (c >> 2) & 0x3; - ix[i + 3] = c & 0x3; - } - } - else - { - for (s32 i = 0; i < 16; i += 2) - { - u8 c = frame[1 + i / 2]; - ix[i] = c >> 4; - ix[i + 1] = c & 0xf; - } - } - - for (s32 i = 0; i < 16; i++) - { - if (framesize == 5) - { - if (ix[i] >= 2) - ix[i] -= 4; - } - else - { - if (ix[i] >= 8) - ix[i] -= 16; - } - decompressed[i] = ix[i]; - ix[i] *= scale; - } - - for (s32 j = 0; j < 2; j++) - { - s32 in_vec[16]; - if (j == 0) - { - for (s32 i = 0; i < order; i++) - { - in_vec[i] = state[16 - order + i]; - } - } - else - { - for (s32 i = 0; i < order; i++) - { - in_vec[i] = state[8 - order + i]; - } - } - - for (s32 i = 0; i < 8; i++) - { - s32 ind = j * 8 + i; - in_vec[order + i] = ix[ind]; - state[ind] = inner_product(order + i, coefTable[optimalp][i], in_vec) + ix[ind]; - } - } -} - -void get_bounds(s32* in, s32* decompressed, s32 scale, s32* minVals, s32* maxVals) -{ - s32 minv, maxv; - if (framesize == 9) - { - minv = -8; - maxv = 7; - } - else - { - minv = -2; - maxv = 1; - } - for (s32 i = 0; i < 16; i++) - { - s32 lo = in[i] - scale / 2; - s32 hi = in[i] + scale / 2; - lo -= scale; - hi += scale; - if (decompressed[i] == minv) - lo -= scale; - else if (decompressed[i] == maxv) - hi += scale; - minVals[i] = lo; - maxVals[i] = hi; - } -} - -void write_header(FILE* ofile, const char* id, s32 size) -{ - fwrite(id, 4, 1, ofile); - BSWAP32(size); - fwrite(&size, sizeof(s32), 1, ofile); -} - -char* OldMain(char* infilename) -{ - s16 order = -1; - s16 nloops = 0; - ALADPCMloop* aloops = NULL; - s16 npredictors = -1; - s32*** coefTable = NULL; - s32 state[16]; - s32 decompressed[16]; - s32 soundPointer = -1; - s32 currPos = 0; - s32 nSamples = 0; - Chunk FormChunk = Chunk(); - ChunkHeader Header = ChunkHeader(); - CommonChunk CommChunk = CommonChunk(); - InstrumentChunk InstChunk; - SoundDataChunk SndDChunk = SoundDataChunk(); - FILE* ifile = NULL; - FILE* ofile = NULL; - - if ((ifile = fopen(infilename, "rb")) == NULL) - { - fail_parse("AIFF-C file could not be opened"); - exit(1); - } - - memset(&InstChunk, 0, sizeof(InstChunk)); - - BSWAP32(FormChunk.ckID); - BSWAP32(FormChunk.formType); - if ((FormChunk.ckID != 0x464f524d) || (FormChunk.formType != 0x41494643)) - { // FORM, AIFC - fail_parse("not an AIFF-C file"); - } - - for (;;) - { - s32 num = fread(&Header, sizeof(Header), 1, ifile); - u32 ts = 0; - - if (num <= 0) - break; - - BSWAP32(Header.ckID); - BSWAP32(Header.ckSize); - - Header.ckSize++; - Header.ckSize &= ~1; - s32 offset = ftell(ifile); - - switch (Header.ckID) - { - case 0x434f4d4d: // COMM - { - BSWAP16(CommChunk.numChannels); - BSWAP16(CommChunk.numFramesH); - BSWAP16(CommChunk.numFramesL); - BSWAP16(CommChunk.sampleSize); - BSWAP16(CommChunk.compressionTypeH); - BSWAP16(CommChunk.compressionTypeL); - s32 cType = (CommChunk.compressionTypeH << 16) + CommChunk.compressionTypeL; - if (cType == 0x56415043 || cType == 0x41445039) - { // VAPC or ADP9 - framesize = 9; - } - else if (cType == 0x41445035) - { // ADP5 - framesize = 5; - } - else if (cType == 0x4850434d) - { // HPCM - framesize = 16; - } - else - { - char comprType[5] = { - static_cast(CommChunk.compressionTypeH >> 8), static_cast(CommChunk.compressionTypeH & 0xFF), - static_cast(CommChunk.compressionTypeL >> 8), static_cast(CommChunk.compressionTypeL & 0xFF), 0}; - fail_parse("file is of the wrong compression type [got %s (%08x)]", &comprType, - cType); - } - if (CommChunk.numChannels != 1) - { - fail_parse("file contains %d channels, only 1 channel supported", - CommChunk.numChannels); - } - if (CommChunk.sampleSize != 16) - { - fail_parse("file contains %d bit samples, only 16 bit samples supported", - CommChunk.sampleSize); - } - - nSamples = (CommChunk.numFramesH << 16) + CommChunk.numFramesL; - - // Allow broken input lengths - if (nSamples % 16) - { - nSamples -= (nSamples % 16); - } - - if (nSamples % 16 != 0) - { - fail_parse("number of chunks must be a multiple of 16, found %d with remainder %d", - nSamples, nSamples % 16); - } - } - break; - - case 0x53534e44: // SSND - BSWAP32(SndDChunk.offset); - BSWAP32(SndDChunk.blockSize); - assert(SndDChunk.offset == 0); - assert(SndDChunk.blockSize == 0); - soundPointer = ftell(ifile); - break; - - case 0x4150504c: // APPL - BSWAP32(ts); - if (ts == 0x73746f63) - { // stoc - u8 len = 0; - if (len == 11) - { - char ChunkName[12]; - s16 version; - ChunkName[11] = '\0'; - if (strcmp("VADPCMCODES", ChunkName) == 0) - { - BSWAP16(version); - if (version != 1) - { - fail_parse("Unknown codebook chunk version"); - } - readaifccodebook(ifile, &coefTable, &order, &npredictors); - } - else if (strcmp("VADPCMLOOPS", ChunkName) == 0) - { - BSWAP16(version); - if (version != 1) - { - fail_parse("Unknown loop chunk version"); - } - aloops = readlooppoints(ifile, &nloops); - if (nloops != 1) - { - fail_parse("Only a single loop supported"); - } - } - } - } - break; - } - - fseek(ifile, offset + Header.ckSize, SEEK_SET); - } - - if (coefTable == NULL) - { - fail_parse("Codebook missing from bitstream"); - } - - for (s32 i = 0; i < order; i++) - { - state[15 - i] = 0; - } - - u32 outputBytes = nSamples * sizeof(s16); - u8* outputBuf = (u8*)malloc(outputBytes); - - fseek(ifile, soundPointer, SEEK_SET); - s32 fails = 0; - while (currPos < nSamples) - { - u8 input[9]; - u8 encoded[9]; - s32 lastState[16]; - s32 decoded[16]; - s16 guess[16]; - s16 origGuess[16]; - - memcpy(lastState, state, sizeof(state)); - - // Decode for real - my_decodeframe(input, decompressed, state, order, coefTable); - memcpy(decoded, state, sizeof(state)); - - // Create a guess from that, by clamping to 16 bits - for (s32 i = 0; i < 16; i++) - { - origGuess[i] = clamp_bits(state[i], 16); - } - - memcpy(state, decoded, sizeof(state)); - memcpy(outputBuf + currPos * 2, decoded, sizeof(decoded)); - currPos += 16; - } - if (fails) - { - fprintf(stderr, "%s %d\n", infilename, fails); - } - - // Write an incomplete file header. We'll fill in the size later. - fwrite("FORM\0\0\0\0AIFF", 12, 1, ofile); - - // Subtract 4 from the COMM size to skip the compression field. - write_header(ofile, "COMM", sizeof(CommonChunk) - 4); - CommChunk.numFramesH = nSamples >> 16; - CommChunk.numFramesL = nSamples & 0xffff; - BSWAP16(CommChunk.numChannels); - BSWAP16(CommChunk.numFramesH); - BSWAP16(CommChunk.numFramesL); - BSWAP16(CommChunk.sampleSize); - fwrite(&CommChunk, sizeof(CommonChunk) - 4, 1, ofile); - - if (nloops > 0) - { - s32 startPos = aloops[0].start, endPos = aloops[0].end; - const char* markerNames[2] = {"start", "end"}; - Marker markers[2] = {{1, static_cast(startPos >> 16), static_cast(startPos & 0xffff)}, - {2, static_cast(endPos >> 16), static_cast(endPos & 0xffff)}}; - write_header(ofile, "MARK", 2 + 2 * sizeof(Marker) + 1 + 5 + 1 + 3); - s16 numMarkers = bswap16(2); - fwrite(&numMarkers, sizeof(s16), 1, ofile); - for (s32 i = 0; i < 2; i++) - { - u8 len = (u8)strlen(markerNames[i]); - BSWAP16(markers[i].MarkerID); - BSWAP16(markers[i].positionH); - BSWAP16(markers[i].positionL); - fwrite(&markers[i], sizeof(Marker), 1, ofile); - fwrite(&len, 1, 1, ofile); - fwrite(markerNames[i], len, 1, ofile); - } - - write_header(ofile, "INST", sizeof(InstrumentChunk)); - InstChunk.sustainLoop.playMode = bswap16(1); - InstChunk.sustainLoop.beginLoop = bswap16(1); - InstChunk.sustainLoop.endLoop = bswap16(2); - InstChunk.releaseLoop.playMode = 0; - InstChunk.releaseLoop.beginLoop = 0; - InstChunk.releaseLoop.endLoop = 0; - fwrite(&InstChunk, sizeof(InstrumentChunk), 1, ofile); - } - - // Save the coefficient table for use when encoding. Ideally this wouldn't - // be needed and "tabledesign -s 1" would generate the right table, but in - // practice it's difficult to adjust samples to make that happen. - write_header(ofile, "APPL", 4 + 12 + sizeof(CodeChunk) + npredictors * order * 8 * 2); - fwrite("stoc", 4, 1, ofile); - CodeChunk cChunk; - cChunk.version = bswap16(1); - cChunk.order = bswap16(order); - cChunk.nEntries = bswap16(npredictors); - fwrite("\x0bVADPCMCODES", 12, 1, ofile); - fwrite(&cChunk, sizeof(CodeChunk), 1, ofile); - for (s32 i = 0; i < npredictors; i++) - { - for (s32 j = 0; j < order; j++) - { - for (s32 k = 0; k < 8; k++) - { - s16 ts = bswap16(coefTable[i][k][j]); - fwrite(&ts, sizeof(s16), 1, ofile); - } - } - } - - write_header(ofile, "SSND", outputBytes + 8); - SndDChunk.offset = 0; - SndDChunk.blockSize = 0; - fwrite(&SndDChunk, sizeof(SoundDataChunk), 1, ofile); - fwrite(outputBuf, outputBytes, 1, ofile); - - // Fix the size in the header - s32 fileSize = bswap32(ftell(ofile) - 8); - fseek(ofile, 4, SEEK_SET); - fwrite(&fileSize, 4, 1, ofile); - - fclose(ifile); - fclose(ofile); - return 0; -} diff --git a/ZAPDTR/ZAPD/ZBackground.cpp b/ZAPDTR/ZAPD/ZBackground.cpp deleted file mode 100644 index 026002da1..000000000 --- a/ZAPDTR/ZAPD/ZBackground.cpp +++ /dev/null @@ -1,195 +0,0 @@ -#include "ZBackground.h" - -#include "Globals.h" -#include "Utils/BitConverter.h" -#include -#include "Utils/Path.h" -#include "Utils/StringHelper.h" -#include "WarningHandler.h" -#include "ZFile.h" - -REGISTER_ZFILENODE(Background, ZBackground); - -#define JPEG_MARKER 0xFFD8FFE0 -#define MARKER_DQT 0xFFDB -#define MARKER_EOI 0xFFD9 - -ZBackground::ZBackground(ZFile* nParent) : ZResource(nParent) -{ -} - -void ZBackground::ParseRawData() -{ - ZResource::ParseRawData(); - - const auto& rawData = parent->GetRawData(); - size_t i = 0; - while (true) - { - uint8_t val = rawData.at(rawDataIndex + i); - data.push_back(val); - - if (BitConverter::ToUInt16BE(rawData, rawDataIndex + i) == MARKER_EOI) - { - data.push_back(rawData.at(rawDataIndex + i + 1)); - break; - } - - i++; - } -} - -void ZBackground::ParseBinaryFile(const std::string& inFolder, bool appendOutName) -{ - fs::path filepath(inFolder); - - if (appendOutName) - filepath = filepath / (outName + "." + GetExternalExtension()); - - data = DiskFile::ReadAllBytes(filepath.string()); - - // Add padding. - data.insert(data.end(), GetRawDataSize() - data.size(), 0x00); - CheckValidJpeg(filepath.generic_string()); -} - -void ZBackground::CheckValidJpeg(const std::string& filepath) -{ - std::string filename = outName; - if (filepath != "") - { - filename = filepath; - } - - uint32_t jpegMarker = BitConverter::ToUInt32BE(data, 0); - if (jpegMarker != JPEG_MARKER) - { - HANDLE_WARNING_PROCESS( - WarningType::InvalidJPEG, - StringHelper::Sprintf("missing jpeg marker at beginning of file: '%s'", - filename.c_str()), - "The game will skip this jpeg."); - } - if (data.at(6) != 'J' || data.at(7) != 'F' || data.at(8) != 'I' || data.at(9) != 'F' || - data.at(10) != '\0') - { - std::string jfifIdentifier(data.begin() + 6, data.begin() + 6 + 5); - HANDLE_WARNING_PROCESS( - WarningType::InvalidJPEG, "missing 'JFIF' identifier", - StringHelper::Sprintf( - "This image may be corrupted, or not a jpeg. The identifier found was: '%s'", - jfifIdentifier.c_str())); - } - uint8_t majorVersion = data.at(11); - uint8_t minorVersion = data.at(12); - if (majorVersion != 0x01 || minorVersion != 0x01) - { - HANDLE_WARNING_PROCESS( - WarningType::InvalidJPEG, - StringHelper::Sprintf("wrong JFIF version '%i.%02i'", majorVersion, minorVersion), - "The expected version is '1.01'. The game may be unable to decode this image " - "correctly."); - } - if (BitConverter::ToUInt16BE(data, 20) != MARKER_DQT) - { - // This may happen when creating a custom image with Exif, XMP, thumbnail, progressive, etc. - // enabled. - HANDLE_WARNING_PROCESS(WarningType::InvalidJPEG, - "there seems to be extra data before the image data in this file", - "The game may not be able to decode this image correctly."); - } - if (data.size() > GetRawDataSize()) - { - HANDLE_WARNING_PROCESS( - WarningType::InvalidJPEG, "the image is bigger than the screen buffer", - StringHelper::Sprintf("Image size: %zu bytes\nScreen buffer size: %zu bytes", - data.size(), GetRawDataSize())); - } -} - -size_t ZBackground::GetRawDataSize() const -{ - // Jpgs use the whole sceen buffer, which is a u16 matrix. - return Globals::Instance->cfg.bgScreenHeight * Globals::Instance->cfg.bgScreenWidth * 2; -} - -Declaration* ZBackground::DeclareVar(const std::string& prefix, - [[maybe_unused]] const std::string& bodyStr) -{ - std::string auxName = name; - std::string auxOutName = outName; - - if (auxName == "") - auxName = GetDefaultName(prefix); - - if (auxOutName == "") - auxOutName = GetDefaultName(prefix); - - auto filepath = Globals::Instance->outputPath / fs::path(auxOutName).stem(); - - std::string incStr = - StringHelper::Sprintf("%s.%s.inc.c", filepath.c_str(), GetExternalExtension().c_str()); - - Declaration* decl = parent->AddDeclarationIncludeArray(rawDataIndex, incStr, GetRawDataSize(), - GetSourceTypeName(), auxName, 0); - decl->arrayItemCntStr = "SCREEN_WIDTH * SCREEN_HEIGHT / 4"; - decl->forceArrayCnt = true; - decl->staticConf = staticConf; - return decl; -} - -bool ZBackground::IsExternalResource() const -{ - return true; -} - -std::string ZBackground::GetExternalExtension() const -{ - return "jpg"; -} - -void ZBackground::Save(const fs::path& outFolder) -{ - if (!Globals::Instance->otrMode) - { - fs::path filepath = outFolder / (outName + "." + GetExternalExtension()); - DiskFile::WriteAllBytes(filepath.string(), data); - } -} - -std::string ZBackground::GetBodySourceCode() const -{ - std::string bodyStr = " "; - - for (size_t i = 0; i < data.size() / 8; ++i) - { - bodyStr += StringHelper::Sprintf("0x%016llX, ", BitConverter::ToUInt64BE(data, i * 8)); - - if (i % 8 == 7) - bodyStr += "\n "; - } - - bodyStr += "\n"; - - return bodyStr; -} - -std::string ZBackground::GetDefaultName(const std::string& prefix) const -{ - return StringHelper::Sprintf("%sBackground_%06X", prefix.c_str(), rawDataIndex); -} - -std::string ZBackground::GetSourceTypeName() const -{ - return "u64"; -} - -ZResourceType ZBackground::GetResourceType() const -{ - return ZResourceType::Background; -} - -DeclarationAlignment ZBackground::GetDeclarationAlignment() const -{ - return DeclarationAlignment::Align8; -} diff --git a/ZAPDTR/ZAPD/ZBackground.h b/ZAPDTR/ZAPD/ZBackground.h deleted file mode 100644 index e3728bd98..000000000 --- a/ZAPDTR/ZAPD/ZBackground.h +++ /dev/null @@ -1,34 +0,0 @@ -#pragma once - -#include -#include -#include "ZResource.h" - -class ZBackground : public ZResource -{ -protected: - std::vector data; - -public: - ZBackground(ZFile* nParent); - - void ParseBinaryFile(const std::string& inFolder, bool appendOutName); - - void ParseRawData() override; - - Declaration* DeclareVar(const std::string& prefix, const std::string& bodyStr) override; - std::string GetBodySourceCode() const override; - std::string GetDefaultName(const std::string& prefix) const override; - - void Save(const fs::path& outFolder) override; - - bool IsExternalResource() const override; - std::string GetSourceTypeName() const override; - ZResourceType GetResourceType() const override; - std::string GetExternalExtension() const override; - - size_t GetRawDataSize() const override; - DeclarationAlignment GetDeclarationAlignment() const override; - - void CheckValidJpeg(const std::string& filepath); -}; diff --git a/ZAPDTR/ZAPD/ZBlob.cpp b/ZAPDTR/ZAPD/ZBlob.cpp deleted file mode 100644 index 0965d7e4e..000000000 --- a/ZAPDTR/ZAPD/ZBlob.cpp +++ /dev/null @@ -1,116 +0,0 @@ -#include "ZBlob.h" - -#include "Globals.h" -#include "Utils/BitConverter.h" -#include -#include "Utils/Path.h" -#include "Utils/StringHelper.h" -#include "ZFile.h" - -REGISTER_ZFILENODE(Blob, ZBlob); - -ZBlob::ZBlob(ZFile* nParent) : ZResource(nParent) -{ - genOTRDef = true; - RegisterRequiredAttribute("Size"); -} - -ZBlob* ZBlob::FromFile(const std::string& filePath) -{ - ZBlob* blob = new ZBlob(nullptr); - blob->name = StringHelper::Split(Path::GetFileNameWithoutExtension(filePath), ".")[0]; - blob->blobData = DiskFile::ReadAllBytes(filePath); - - return blob; -} - -void ZBlob::ParseXML(tinyxml2::XMLElement* reader) -{ - ZResource::ParseXML(reader); - - blobSize = StringHelper::StrToL(registeredAttributes.at("Size").value, 16); -} - -void ZBlob::ParseRawData() -{ - blobData.assign(parent->GetRawData().begin() + rawDataIndex, - parent->GetRawData().begin() + rawDataIndex + blobSize); -} - -Declaration* ZBlob::DeclareVar(const std::string& prefix, - [[maybe_unused]] const std::string& bodyStr) -{ - std::string auxName = name; - std::string auxOutName = outName; - - if (auxName == "") - auxName = GetDefaultName(prefix); - - if (auxOutName == "") - auxOutName = GetDefaultName(prefix); - - std::string path = Path::GetFileNameWithoutExtension(auxOutName); - - std::string assetOutDir = - (Globals::Instance->outputPath / Path::GetFileNameWithoutExtension(GetOutName())).string(); - - std::string incStr = - StringHelper::Sprintf("%s.%s.inc.c", assetOutDir.c_str(), GetExternalExtension().c_str()); - - return parent->AddDeclarationIncludeArray(rawDataIndex, incStr, GetRawDataSize(), - GetSourceTypeName(), auxName, blobData.size()); -} - -std::string ZBlob::GetBodySourceCode() const -{ - std::string sourceOutput; - - for (size_t i = 0; i < blobData.size(); i += 1) - { - if (i % 16 == 0) - sourceOutput += "\t"; - - sourceOutput += StringHelper::Sprintf("0x%02X, ", blobData[i]); - - if (i % 16 == 15) - sourceOutput += "\n"; - } - - // Ensure there's always a trailing line feed to prevent dumb warnings. - // Please don't remove this line, unless you somehow made a way to prevent - // that warning when building the OoT repo. - sourceOutput += "\n"; - - return sourceOutput; -} - -void ZBlob::Save(const fs::path& outFolder) -{ - if (!Globals::Instance->otrMode) - DiskFile::WriteAllBytes((outFolder / (name + ".bin")).string(), blobData); -} - -bool ZBlob::IsExternalResource() const -{ - return true; -} - -std::string ZBlob::GetExternalExtension() const -{ - return "bin"; -} - -std::string ZBlob::GetSourceTypeName() const -{ - return "u8"; -} - -ZResourceType ZBlob::GetResourceType() const -{ - return ZResourceType::Blob; -} - -size_t ZBlob::GetRawDataSize() const -{ - return blobSize; -} diff --git a/ZAPDTR/ZAPD/ZBlob.h b/ZAPDTR/ZAPD/ZBlob.h deleted file mode 100644 index d7a7feff1..000000000 --- a/ZAPDTR/ZAPD/ZBlob.h +++ /dev/null @@ -1,31 +0,0 @@ -#pragma once - -#include "ZResource.h" -#include "tinyxml2.h" - -class ZBlob : public ZResource -{ -public: - ZBlob(ZFile* nParent); - - static ZBlob* FromFile(const std::string& filePath); - - void ParseXML(tinyxml2::XMLElement* reader) override; - void ParseRawData() override; - - Declaration* DeclareVar(const std::string& prefix, const std::string& bodyStr) override; - std::string GetBodySourceCode() const override; - - void Save(const fs::path& outFolder) override; - - bool IsExternalResource() const override; - std::string GetSourceTypeName() const override; - ZResourceType GetResourceType() const override; - std::string GetExternalExtension() const override; - - size_t GetRawDataSize() const override; - -protected: - std::vector blobData; - size_t blobSize = 0; -}; diff --git a/ZAPDTR/ZAPD/ZCollision.cpp b/ZAPDTR/ZAPD/ZCollision.cpp deleted file mode 100644 index e75cfe2aa..000000000 --- a/ZAPDTR/ZAPD/ZCollision.cpp +++ /dev/null @@ -1,400 +0,0 @@ -#include "ZCollision.h" - -#include -#include -#include - -#include "Globals.h" -#include "Utils/BitConverter.h" -#include "Utils/StringHelper.h" - -REGISTER_ZFILENODE(Collision, ZCollisionHeader); - -ZCollisionHeader::ZCollisionHeader(ZFile* nParent) : ZResource(nParent) -{ - genOTRDef = true; -} - -ZCollisionHeader::~ZCollisionHeader() -{ - delete camData; -} - -void ZCollisionHeader::ParseRawData() -{ - const auto& rawData = parent->GetRawData(); - - absMinX = BitConverter::ToInt16BE(rawData, rawDataIndex + 0); - absMinY = BitConverter::ToInt16BE(rawData, rawDataIndex + 2); - absMinZ = BitConverter::ToInt16BE(rawData, rawDataIndex + 4); - - absMaxX = BitConverter::ToInt16BE(rawData, rawDataIndex + 6); - absMaxY = BitConverter::ToInt16BE(rawData, rawDataIndex + 8); - absMaxZ = BitConverter::ToInt16BE(rawData, rawDataIndex + 10); - - numVerts = BitConverter::ToUInt16BE(rawData, rawDataIndex + 12); - vtxAddress = BitConverter::ToInt32BE(rawData, rawDataIndex + 16); - - 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(rawData, rawDataIndex + 36); - waterBoxAddress = BitConverter::ToInt32BE(rawData, rawDataIndex + 40); - - vtxSegmentOffset = Seg2Filespace(vtxAddress, parent->baseAddress); - polySegmentOffset = Seg2Filespace(polyAddress, parent->baseAddress); - polyTypeDefSegmentOffset = Seg2Filespace(polyTypeDefAddress, parent->baseAddress); - camDataSegmentOffset = Seg2Filespace(camDataAddress, parent->baseAddress); - waterBoxSegmentOffset = Seg2Filespace(waterBoxAddress, parent->baseAddress); - - vertices.reserve(numVerts); - polygons.reserve(numPolygons); - - offset_t currentPtr = vtxSegmentOffset; - - for (uint16_t i = 0; i < numVerts; i++) - { - ZVector vec(parent); - vec.ExtractFromBinary(currentPtr, ZScalarType::ZSCALAR_S16, 3); - - currentPtr += vec.GetRawDataSize(); - vertices.push_back(vec); - } - - for (uint16_t i = 0; i < numPolygons; i++) - { - ZCollisionPoly poly(parent); - poly.SetRawDataIndex(polySegmentOffset + (i * 16)); - poly.ParseRawData(); - polygons.push_back(poly); - } - - uint16_t highestPolyType = 0; - - for (const ZCollisionPoly& poly : polygons) - { - if (poly.type > highestPolyType) - highestPolyType = poly.type; - } - - for (uint16_t i = 0; i < highestPolyType + 1; i++) - { - ZSurfaceType surfaceType(parent); - surfaceType.SetRawDataIndex(polyTypeDefSegmentOffset + (i * 8)); - surfaceType.ParseRawData(); - PolygonTypes.push_back(surfaceType); - } - // polygonTypes.push_back( - // BitConverter::ToUInt64BE(rawData, polyTypeDefSegmentOffset + (i * 8))); - - if (camDataAddress != SEGMENTED_NULL) - { - // Try to guess how many elements the CamDataList array has. - // The "guessing algorithm" is basically a "best effort" one and it - // is error-prone. - // This is based mostly on observation of how CollisionHeader data is - // usually ordered. If for some reason the data was in some other funny - // order, this would probably break. - // The most common ordering is: - // - *CamData* - // - SurfaceType - // - CollisionPoly - // - Vertices - // - WaterBoxes - // - CollisionHeader - offset_t upperCameraBoundary = polyTypeDefSegmentOffset; - if (upperCameraBoundary == 0) - { - upperCameraBoundary = polySegmentOffset; - } - if (upperCameraBoundary == 0) - { - upperCameraBoundary = vtxSegmentOffset; - } - if (upperCameraBoundary == 0) - { - upperCameraBoundary = waterBoxSegmentOffset; - } - if (upperCameraBoundary == 0) - { - upperCameraBoundary = rawDataIndex; - } - - camData = - new CameraDataList(parent, name, rawData, camDataSegmentOffset, upperCameraBoundary); - } - - for (uint16_t i = 0; i < numWaterBoxes; i++) - waterBoxes.push_back(WaterBoxHeader( - rawData, - waterBoxSegmentOffset + (i * (Globals::Instance->game == ZGame::OOT_SW97 ? 12 : 16)))); -} - -void ZCollisionHeader::DeclareReferences(const std::string& prefix) -{ - std::string declaration = ""; - std::string auxName = name; - - if (name == "") - auxName = GetDefaultName(prefix); - - if (waterBoxes.size() > 0) - { - if (!Globals::Instance->otrMode) - { - for (size_t i = 0; i < waterBoxes.size(); i++) - { - declaration += - StringHelper::Sprintf("\t{ %s },", waterBoxes[i].GetBodySourceCode().c_str()); - if (i + 1 < waterBoxes.size()) - declaration += "\n"; - } - } - - parent->AddDeclarationArray( - waterBoxSegmentOffset, DeclarationAlignment::Align4, 16 * waterBoxes.size(), "WaterBox", - StringHelper::Sprintf("%sWaterBoxes", auxName.c_str()), waterBoxes.size(), declaration); - } - - if (polygons.size() > 0) - { - declaration.clear(); - - if (!Globals::Instance->otrMode) - { - for (size_t i = 0; i < polygons.size(); i++) - { - declaration += - StringHelper::Sprintf("\t%s,", polygons[i].GetBodySourceCode().c_str()); - if (i + 1 < polygons.size()) - declaration += "\n"; - } - } - - parent->AddDeclarationArray(polySegmentOffset, DeclarationAlignment::Align4, - polygons.size() * 16, polygons[0].GetSourceTypeName().c_str(), - StringHelper::Sprintf("%sPolygons", auxName.c_str()), - polygons.size(), declaration); - } - - declaration.clear(); - for (const auto& polyType : PolygonTypes) - { - declaration += StringHelper::Sprintf("\t%s,", polyType.GetBodySourceCode().c_str()); - } - - if (polyTypeDefAddress != SEGMENTED_NULL) - parent->AddDeclarationArray(polyTypeDefSegmentOffset, DeclarationAlignment::Align4, - PolygonTypes.size() * 8, - PolygonTypes[0].GetSourceTypeName().c_str(), - StringHelper::Sprintf("%sSurfaceType", auxName.c_str()), - PolygonTypes.size(), declaration); - - declaration.clear(); - - if (vertices.size() > 0) - { - declaration.clear(); - - if (!Globals::Instance->otrMode) - { - for (size_t i = 0; i < vertices.size(); i++) - { - declaration += - StringHelper::Sprintf("\t{ %s },", vertices[i].GetBodySourceCode().c_str()); - - if (i < vertices.size() - 1) - declaration += "\n"; - } - } - - const auto& first = vertices.front(); - if (vtxAddress != 0) - parent->AddDeclarationArray( - vtxSegmentOffset, first.GetDeclarationAlignment(), - vertices.size() * first.GetRawDataSize(), first.GetSourceTypeName(), - StringHelper::Sprintf("%sVertices", auxName.c_str()), vertices.size(), declaration); - } -} - -std::string ZCollisionHeader::GetBodySourceCode() const -{ - std::string declaration = ""; - - if (Globals::Instance->otrMode) - return declaration; - - declaration += "\n"; - - declaration += StringHelper::Sprintf("\t{ %i, %i, %i },\n", absMinX, absMinY, absMinZ); - declaration += StringHelper::Sprintf("\t{ %i, %i, %i },\n", absMaxX, absMaxY, absMaxZ); - - std::string vtxName; - Globals::Instance->GetSegmentedPtrName(vtxAddress, parent, "Vec3s", vtxName, parent->workerID); - declaration += StringHelper::Sprintf("\t%i,\n\t%s,\n", numVerts, vtxName.c_str()); - - std::string polyName; - Globals::Instance->GetSegmentedPtrName(polyAddress, parent, "CollisionPoly", polyName, - parent->workerID); - declaration += StringHelper::Sprintf("\t%i,\n\t%s,\n", numPolygons, polyName.c_str()); - - std::string surfaceName; - Globals::Instance->GetSegmentedPtrName(polyTypeDefAddress, parent, "SurfaceType", surfaceName, - parent->workerID); - declaration += StringHelper::Sprintf("\t%s,\n", surfaceName.c_str()); - - std::string camName; - Globals::Instance->GetSegmentedPtrName(camDataAddress, parent, "CamData", camName, - parent->workerID); - declaration += StringHelper::Sprintf("\t%s,\n", camName.c_str()); - - std::string waterBoxName; - Globals::Instance->GetSegmentedPtrName(waterBoxAddress, parent, "WaterBox", waterBoxName, - parent->workerID); - declaration += StringHelper::Sprintf("\t%i,\n\t%s\n", numWaterBoxes, waterBoxName.c_str()); - - return declaration; -} - -std::string ZCollisionHeader::GetDefaultName(const std::string& prefix) const -{ - return StringHelper::Sprintf("%sCol_%06X", prefix.c_str(), rawDataIndex); -} - -std::string ZCollisionHeader::GetSourceTypeName() const -{ - return "CollisionHeader"; -} - -ZResourceType ZCollisionHeader::GetResourceType() const -{ - return ZResourceType::CollisionHeader; -} - -size_t ZCollisionHeader::GetRawDataSize() const -{ - return 44; -} - -WaterBoxHeader::WaterBoxHeader(const std::vector& rawData, uint32_t rawDataIndex) -{ - xMin = BitConverter::ToInt16BE(rawData, rawDataIndex + 0); - ySurface = BitConverter::ToInt16BE(rawData, rawDataIndex + 2); - zMin = BitConverter::ToInt16BE(rawData, rawDataIndex + 4); - xLength = BitConverter::ToInt16BE(rawData, rawDataIndex + 6); - zLength = BitConverter::ToInt16BE(rawData, rawDataIndex + 8); - - if (Globals::Instance->game == ZGame::OOT_SW97) - properties = BitConverter::ToInt16BE(rawData, rawDataIndex + 10); - else - properties = BitConverter::ToInt32BE(rawData, rawDataIndex + 12); -} - -std::string WaterBoxHeader::GetBodySourceCode() const -{ - return StringHelper::Sprintf("%i, %i, %i, %i, %i, 0x%08X", xMin, ySurface, zMin, xLength, - zLength, properties); -} - -CameraDataList::CameraDataList(ZFile* parent, const std::string& prefix, - const std::vector& rawData, offset_t rawDataIndex, - offset_t upperCameraBoundary) -{ - std::string declaration; - - // Parse CameraDataEntries - size_t numElements = (upperCameraBoundary - rawDataIndex) / 8; - assert(numElements < 10000); - - offset_t cameraPosDataSeg = rawDataIndex; - for (size_t i = 0; i < numElements; i++) - { - CameraDataEntry* entry = new CameraDataEntry(); - - entry->cameraSType = - BitConverter::ToInt16BE(rawData, rawDataIndex + (entries.size() * 8) + 0); - entry->numData = BitConverter::ToInt16BE(rawData, rawDataIndex + (entries.size() * 8) + 2); - entry->cameraPosDataSeg = - BitConverter::ToInt32BE(rawData, rawDataIndex + (entries.size() * 8) + 4); - - if (entry->cameraPosDataSeg != 0 && GETSEGNUM(entry->cameraPosDataSeg) != SEGMENT_SCENE) - { - cameraPosDataSeg = rawDataIndex + (entries.size() * 8); - break; - } - - if (entry->cameraPosDataSeg != 0 && cameraPosDataSeg > (entry->cameraPosDataSeg & 0xFFFFFF)) - cameraPosDataSeg = (entry->cameraPosDataSeg & 0xFFFFFF); - - entries.push_back(entry); - } - - // Setting cameraPosDataAddr to rawDataIndex give a pos list length of 0 - uint32_t cameraPosDataOffset = cameraPosDataSeg & 0xFFFFFF; - for (size_t i = 0; i < entries.size(); i++) - { - char camSegLine[2048]; - - if (entries[i]->cameraPosDataSeg != 0) - { - int32_t index = - ((entries[i]->cameraPosDataSeg & 0x00FFFFFF) - cameraPosDataOffset) / 0x6; - sprintf(camSegLine, "&%sCamPosData[%i]", prefix.c_str(), index); - } - else - sprintf(camSegLine, "NULL"); - - declaration += - StringHelper::Sprintf(" { 0x%04X, %i, %s },", entries[i]->cameraSType, - entries[i]->numData, camSegLine, rawDataIndex + (i * 8)); - - if (i < entries.size() - 1) - declaration += "\n"; - } - - parent->AddDeclarationArray( - rawDataIndex, DeclarationAlignment::Align4, entries.size() * 8, "CamData", - StringHelper::Sprintf("%sCamDataList", prefix.c_str(), rawDataIndex), entries.size(), - declaration); - - uint32_t numDataTotal = (rawDataIndex - cameraPosDataOffset) / 0x6; - - if (numDataTotal > 0) - { - declaration.clear(); - for (uint32_t i = 0; i < numDataTotal; i++) - { - CameraPositionData* data = - new CameraPositionData(rawData, cameraPosDataOffset + (i * 6)); - cameraPositionData.push_back(data); - - declaration += StringHelper::Sprintf("\t{ %6i, %6i, %6i },", data->x, data->y, data->z); - if (i + 1 < numDataTotal) - declaration += "\n"; - } - - int32_t cameraPosDataIndex = GETSEGOFFSET(cameraPosDataSeg); - uint32_t entrySize = numDataTotal * 0x6; - parent->AddDeclarationArray(cameraPosDataIndex, DeclarationAlignment::Align4, entrySize, - "Vec3s", StringHelper::Sprintf("%sCamPosData", prefix.c_str()), - numDataTotal, declaration); - } -} - -CameraDataList::~CameraDataList() -{ - for (auto entry : entries) - delete entry; - - for (auto camPosData : cameraPositionData) - delete camPosData; -} - -CameraPositionData::CameraPositionData(const std::vector& rawData, uint32_t rawDataIndex) -{ - x = BitConverter::ToInt16BE(rawData, rawDataIndex + 0); - y = BitConverter::ToInt16BE(rawData, rawDataIndex + 2); - z = BitConverter::ToInt16BE(rawData, rawDataIndex + 4); -} diff --git a/ZAPDTR/ZAPD/ZCollision.h b/ZAPDTR/ZAPD/ZCollision.h deleted file mode 100644 index 7db03bf16..000000000 --- a/ZAPDTR/ZAPD/ZCollision.h +++ /dev/null @@ -1,90 +0,0 @@ -#pragma once - -#include "ZCollisionPoly.h" -#include "ZFile.h" -#include "ZResource.h" -#include "ZRoom/ZRoom.h" -#include "ZSurfaceType.h" -#include "ZVector.h" - -class WaterBoxHeader -{ -public: - int16_t xMin; - int16_t ySurface; - int16_t zMin; - int16_t xLength; - int16_t zLength; - int16_t pad; - int32_t properties; - - WaterBoxHeader(const std::vector& rawData, uint32_t rawDataIndex); - - std::string GetBodySourceCode() const; -}; - -class CameraPositionData -{ -public: - int16_t x, y, z; - - CameraPositionData(const std::vector& rawData, uint32_t rawDataIndex); -}; - -class CameraDataEntry -{ -public: - uint16_t cameraSType; - int16_t numData; - int32_t cameraPosDataSeg; -}; - -class CameraDataList -{ -public: - std::vector entries; - std::vector cameraPositionData; - - CameraDataList(ZFile* parent, const std::string& prefix, const std::vector& rawData, - offset_t rawDataIndex, offset_t upperCameraBoundary); - ~CameraDataList(); -}; - -class ZCollisionHeader : public ZResource -{ -public: - int16_t absMinX, absMinY, absMinZ; - int16_t absMaxX, absMaxY, absMaxZ; - uint16_t numVerts; - segptr_t vtxAddress; - uint16_t numPolygons; - segptr_t polyAddress; - segptr_t polyTypeDefAddress; - segptr_t camDataAddress; - - int32_t numWaterBoxes; - segptr_t waterBoxAddress; - - uint32_t vtxSegmentOffset, polySegmentOffset, polyTypeDefSegmentOffset, camDataSegmentOffset, - waterBoxSegmentOffset; - - std::vector vertices; - std::vector polygons; - std::vector PolygonTypes; - std::vector waterBoxes; - CameraDataList* camData = nullptr; - - ZCollisionHeader(ZFile* nParent); - ~ZCollisionHeader(); - - void ParseRawData() override; - void DeclareReferences(const std::string& prefix) override; - - std::string GetBodySourceCode() const override; - std::string GetDefaultName(const std::string& prefix) const override; - - std::string GetSourceTypeName() const override; - ZResourceType GetResourceType() const override; - - size_t GetRawDataSize() const override; -}; diff --git a/ZAPDTR/ZAPD/ZCollisionPoly.cpp b/ZAPDTR/ZAPD/ZCollisionPoly.cpp deleted file mode 100644 index c4eb2d461..000000000 --- a/ZAPDTR/ZAPD/ZCollisionPoly.cpp +++ /dev/null @@ -1,78 +0,0 @@ -#include "ZCollisionPoly.h" - -#include "Globals.h" -#include "Utils/BitConverter.h" -#include "Utils/StringHelper.h" - -REGISTER_ZFILENODE(CollisionPoly, ZCollisionPoly); - -ZCollisionPoly::ZCollisionPoly(ZFile* nParent) : ZResource(nParent) -{ -} - -ZCollisionPoly::~ZCollisionPoly() -{ -} - -void ZCollisionPoly::ParseRawData() -{ - const auto& rawData = parent->GetRawData(); - type = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - - vtxA = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - vtxB = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); - vtxC = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); - - normX = BitConverter::ToUInt16BE(rawData, rawDataIndex + 8); - normY = BitConverter::ToUInt16BE(rawData, rawDataIndex + 10); - normZ = BitConverter::ToUInt16BE(rawData, rawDataIndex + 12); - - dist = BitConverter::ToUInt16BE(rawData, rawDataIndex + 14); -} - -void ZCollisionPoly::DeclareReferences(const std::string& prefix) -{ - std::string declaration; - std::string auxName = name; - - if (name == "") - auxName = GetDefaultName(prefix); - - parent->AddDeclaration(rawDataIndex, DeclarationAlignment::Align4, GetRawDataSize(), - GetSourceTypeName(), name.c_str(), GetBodySourceCode()); -} - -std::string ZCollisionPoly::GetBodySourceCode() const -{ - std::string declaration; - - declaration += - StringHelper::Sprintf("{0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X}", - type, vtxA, vtxB, vtxC, normX, normY, normZ, dist); - return declaration; -} - -std::string ZCollisionPoly::GetDefaultName(const std::string& prefix) const -{ - return StringHelper::Sprintf("%sCollisionPoly_%06X", prefix.c_str(), rawDataIndex); -} - -ZResourceType ZCollisionPoly::GetResourceType() const -{ - return ZResourceType::CollisionPoly; -} - -size_t ZCollisionPoly::GetRawDataSize() const -{ - return 16; -} - -std::string ZCollisionPoly::GetSourceTypeName() const -{ - return "CollisionPoly"; -} - -bool ZCollisionPoly::DoesSupportArray() const -{ - return true; -} \ No newline at end of file diff --git a/ZAPDTR/ZAPD/ZCollisionPoly.h b/ZAPDTR/ZAPD/ZCollisionPoly.h deleted file mode 100644 index 64b98ba1d..000000000 --- a/ZAPDTR/ZAPD/ZCollisionPoly.h +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once - -#include "ZFile.h" -#include "ZResource.h" - -class ZCollisionPoly : public ZResource -{ -public: - uint16_t type; - uint16_t vtxA, vtxB, vtxC; - uint16_t normX, normY, normZ; - uint16_t dist; - - ZCollisionPoly(ZFile* nParent); - ~ZCollisionPoly(); - - void ParseRawData() override; - void DeclareReferences(const std::string& prefix) override; - - std::string GetBodySourceCode() const override; - std::string GetDefaultName(const std::string& prefix) const override; - - std::string GetSourceTypeName() const override; - ZResourceType GetResourceType() const override; - - bool DoesSupportArray() const override; - - size_t GetRawDataSize() const override; -}; \ No newline at end of file diff --git a/ZAPDTR/ZAPD/ZCutscene.cpp b/ZAPDTR/ZAPD/ZCutscene.cpp deleted file mode 100644 index 605894979..000000000 --- a/ZAPDTR/ZAPD/ZCutscene.cpp +++ /dev/null @@ -1,389 +0,0 @@ -#include "ZCutscene.h" - -#include - -#include "Globals.h" -#include "OtherStructs/CutsceneMM_Commands.h" -#include "Utils/BitConverter.h" -#include "Utils/StringHelper.h" -#include "WarningHandler.h" -#include "ZResource.h" - -REGISTER_ZFILENODE(Cutscene, ZCutscene); - -ZCutscene::ZCutscene(ZFile* nParent) : ZResource(nParent) -{ - genOTRDef = true; -} - -ZCutscene::~ZCutscene() -{ - for (CutsceneCommand* cmd : commands) - delete cmd; -} - -std::string ZCutscene::GetBodySourceCode() const -{ - std::string output = ""; - - output += StringHelper::Sprintf(" CS_BEGIN_CUTSCENE(%i, %i),\n", commands.size(), endFrame); - - for (size_t i = 0; i < commands.size(); i++) - { - CutsceneCommand* cmd = commands[i]; - output += " " + cmd->GenerateSourceCode(); - } - - output += StringHelper::Sprintf(" CS_END(),", commands.size(), endFrame); - - return output; -} - -size_t ZCutscene::GetRawDataSize() const -{ - size_t size = 0; - - // Beginning - size += 8; - - for (size_t i = 0; i < commands.size(); i++) - { - CutsceneCommand* cmd = commands[i]; - - size += cmd->GetCommandSize(); - } - - // End - if (Globals::Instance->game == ZGame::MM_RETAIL) - { - size += 4; - } - else - { - size += 8; - } - - return size; -} - -void ZCutscene::ParseRawData() -{ - ZResource::ParseRawData(); - - const auto& rawData = parent->GetRawData(); - - numCommands = BitConverter::ToInt32BE(rawData, rawDataIndex + 0); - commands = std::vector(); - - endFrame = BitConverter::ToInt32BE(rawData, rawDataIndex + 4); - offset_t currentPtr = rawDataIndex + 8; - commands.reserve(numCommands); - for (int32_t i = 0; i < numCommands; i++) - { - uint32_t id = BitConverter::ToUInt32BE(rawData, currentPtr); - - if (id == 0xFFFFFFFF) - break; - - if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_DEBUG) - { - printf("Cutscene Command: 0x%X (%i)\n", id, id); - } - - currentPtr += 4; - - CutsceneCommand* cmd = nullptr; - - if (Globals::Instance->game == ZGame::MM_RETAIL) - { - cmd = GetCommandMM(id, currentPtr); - } - else - { - cmd = GetCommandOoT(id, currentPtr); - } - - if (cmd == nullptr) - { - HANDLE_WARNING_RESOURCE( - WarningType::NotImplemented, parent, this, rawDataIndex, - StringHelper::Sprintf("Cutscene command not implemented"), - StringHelper::Sprintf("Command ID: 0x%X\nIndex: %d\ncurrentPtr-rawDataIndex: 0x%X", - id, i, currentPtr - rawDataIndex)); - cmd = new CutsceneMMCommand_NonImplemented(rawData, currentPtr); - } - - assert(cmd != nullptr); - - cmd->commandIndex = i; - cmd->SetCommandID(id); - size_t commmandSize = cmd->GetCommandSize(); - if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_DEBUG) - { - printf("\t Command size: 0x%zX (%zu)\n", commmandSize, commmandSize); - } - currentPtr += commmandSize - 4; - - commands.push_back(cmd); - } -} - -CutsceneCommand* ZCutscene::GetCommandOoT(uint32_t id, offset_t currentPtr) const -{ - CutsceneCommands cmdID = static_cast(id); - - const auto& rawData = parent->GetRawData(); - - switch (id) - { - case 10: // CutsceneCommands::SetPlayerAction - case 15: // CutsceneCommands::SetActorAction1 - case 17: - case 18: - case 23: - case 34: - case 39: - case 46: - case 76: - case 85: - case 93: - case 105: - case 107: - case 110: - case 119: - case 123: - case 138: - case 139: - case 144: - case 14: // CutsceneCommands::SetActorAction2 - case 16: - case 24: - case 35: - case 40: - case 48: - case 64: - case 68: - case 70: - case 78: - case 80: - case 94: - case 116: - case 118: - case 120: - case 125: - case 131: - case 141: - case 25: // CutsceneCommands::SetActorAction3 - case 36: - case 41: - case 50: - case 67: - case 69: - case 72: - case 81: - case 106: - case 117: - case 121: - case 126: - case 132: - case 29: // CutsceneCommands::SetActorAction4 - case 37: - case 42: - case 51: - case 53: - case 63: - case 65: - case 66: - case 75: - case 82: - case 108: - case 127: - case 133: - case 30: // CutsceneCommands::SetActorAction5 - case 38: - case 43: - case 47: - case 54: - case 79: - case 83: - case 128: - case 135: - case 44: // CutsceneCommands::SetActorAction6 - case 55: - case 77: - case 84: - case 90: - case 129: - case 136: - case 31: // CutsceneCommands::SetActorAction7 - case 52: - case 57: - case 58: - case 88: - case 115: - case 130: - case 137: - case 49: // CutsceneCommands::SetActorAction8 - case 60: - case 89: - case 111: - case 114: - case 134: - case 142: - case 62: // CutsceneCommands::SetActorAction9 - case 143: // CutsceneCommands::SetActorAction10 - return new CutsceneCommand_ActorAction(rawData, currentPtr); - - case 0x0B: - case 0x0D: - case 0x1A: - case 0x1B: - case 0x1C: - case 0x20: - case 0x21: - case 0x3B: - case 0x3D: - case 0x47: - case 0x49: - case 0x6D: - case 0x15: - case 0x16: - case 0x70: - case 0x71: - case 0x4A: - return new CutsceneCommand_GenericCmd(rawData, currentPtr, cmdID); - } - - switch (cmdID) - { - case CutsceneCommands::Misc: - case CutsceneCommands::SetLighting: - case CutsceneCommands::PlayBGM: - case CutsceneCommands::StopBGM: - case CutsceneCommands::FadeBGM: - return new CutsceneCommand_GenericCmd(rawData, currentPtr, cmdID); - - case CutsceneCommands::SetCameraPos: - case CutsceneCommands::SetCameraFocus: - case CutsceneCommands::SetCameraPosLink: - case CutsceneCommands::SetCameraFocusLink: - return new CutsceneCommandSetCameraPos(rawData, currentPtr); - - case CutsceneCommands::Cmd07: - break; - case CutsceneCommands::Cmd08: - break; - case CutsceneCommands::Cmd09: - return new CutsceneCommand_Rumble(rawData, currentPtr); - case CutsceneCommands::Textbox: - return new CutsceneCommand_TextBox(rawData, currentPtr); - - case CutsceneCommands::SetPlayerAction: - case CutsceneCommands::SetActorAction1: - case CutsceneCommands::SetActorAction2: - case CutsceneCommands::SetActorAction3: - case CutsceneCommands::SetActorAction4: - case CutsceneCommands::SetActorAction5: - case CutsceneCommands::SetActorAction6: - case CutsceneCommands::SetActorAction7: - case CutsceneCommands::SetActorAction8: - case CutsceneCommands::SetActorAction9: - case CutsceneCommands::SetActorAction10: - break; - - case CutsceneCommands::SetSceneTransFX: - return new CutsceneCommandSceneTransFX(rawData, currentPtr); - - case CutsceneCommands::SetTime: - return new CutsceneCommand_SetTime(rawData, currentPtr); - case CutsceneCommands::Terminator: - return new CutsceneCommand_Terminator(rawData, currentPtr); - } - - return nullptr; -} - -CutsceneCommand* ZCutscene::GetCommandMM(uint32_t id, offset_t currentPtr) const -{ - CutsceneMMCommands cmdID = static_cast(id); - - const auto& rawData = parent->GetRawData(); - - if (((id >= 100) && (id < 150)) || (id == 201) || ((id >= 450) && (id < 600))) - { - return new CutsceneCommand_ActorAction(rawData, currentPtr); - } - - switch (cmdID) - { - case CutsceneMMCommands::CS_CMD_MISC: - case CutsceneMMCommands::CS_CMD_SET_LIGHTING: - case CutsceneMMCommands::CS_CMD_SCENE_TRANS_FX: - case CutsceneMMCommands::CS_CMD_MOTIONBLUR: - case CutsceneMMCommands::CS_CMD_GIVETATL: - case CutsceneMMCommands::CS_CMD_PLAYSEQ: - case CutsceneMMCommands::CS_CMD_130: - case CutsceneMMCommands::CS_CMD_131: - case CutsceneMMCommands::CS_CMD_132: - case CutsceneMMCommands::CS_CMD_STOPSEQ: - case CutsceneMMCommands::CS_CMD_PLAYAMBIENCE: - case CutsceneMMCommands::CS_CMD_FADEAMBIENCE: - case CutsceneMMCommands::CS_CMD_TERMINATOR: - case CutsceneMMCommands::CS_CMD_CHOOSE_CREDITS_SCENES: - - case CutsceneMMCommands::CS_CMD_UNK_FA: - case CutsceneMMCommands::CS_CMD_UNK_FE: - case CutsceneMMCommands::CS_CMD_UNK_FF: - case CutsceneMMCommands::CS_CMD_UNK_100: - case CutsceneMMCommands::CS_CMD_UNK_101: - case CutsceneMMCommands::CS_CMD_UNK_102: - case CutsceneMMCommands::CS_CMD_UNK_103: - case CutsceneMMCommands::CS_CMD_UNK_104: - case CutsceneMMCommands::CS_CMD_UNK_105: - case CutsceneMMCommands::CS_CMD_UNK_108: - case CutsceneMMCommands::CS_CMD_UNK_109: - case CutsceneMMCommands::CS_CMD_UNK_12D: - return new CutsceneMMCommand_GenericCmd(rawData, currentPtr, cmdID); - - case CutsceneMMCommands::CS_CMD_TEXTBOX: - return new CutsceneCommand_TextBox(rawData, currentPtr); - case CutsceneMMCommands::CS_CMD_CAMERA: - return new CutsceneMMCommand_Camera(rawData, currentPtr); - case CutsceneMMCommands::CS_CMD_FADESCREEN: - return new CutsceneMMCommand_FadeScreen(rawData, currentPtr); - case CutsceneMMCommands::CS_CMD_FADESEQ: - return new CutsceneMMCommand_FadeSeq(rawData, currentPtr); - case CutsceneMMCommands::CS_CMD_SETTIME: - return new CutsceneCommand_SetTime(rawData, currentPtr); - case CutsceneMMCommands::CS_CMD_SET_PLAYER_ACTION: - return new CutsceneCommand_ActorAction(rawData, currentPtr); - case CutsceneMMCommands::CS_CMD_RUMBLE: - return new CutsceneCommand_Rumble(rawData, currentPtr); - } - - return nullptr; -} - -Declaration* ZCutscene::DeclareVar(const std::string& prefix, const std::string& bodyStr) -{ - std::string auxName = name; - - if (auxName == "") - auxName = GetDefaultName(prefix); - - Declaration* decl = - parent->AddDeclarationArray(rawDataIndex, GetDeclarationAlignment(), GetRawDataSize(), - GetSourceTypeName(), auxName, 0, bodyStr); - decl->staticConf = staticConf; - return decl; -} - -std::string ZCutscene::GetSourceTypeName() const -{ - return "CutsceneData"; -} - -ZResourceType ZCutscene::GetResourceType() const -{ - return ZResourceType::Cutscene; -} diff --git a/ZAPDTR/ZAPD/ZCutscene.h b/ZAPDTR/ZAPD/ZCutscene.h deleted file mode 100644 index 098f3ad86..000000000 --- a/ZAPDTR/ZAPD/ZCutscene.h +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once - -#include -#include -#include -#include "tinyxml2.h" - -#include "OtherStructs/Cutscene_Commands.h" -#include "ZFile.h" -#include "ZResource.h" - -class ZCutscene : public ZResource -{ -public: - ZCutscene(ZFile* nParent); - ~ZCutscene(); - - void ParseRawData() override; - - Declaration* DeclareVar(const std::string& prefix, const std::string& bodyStr) override; - - std::string GetBodySourceCode() const override; - - size_t GetRawDataSize() const override; - - std::string GetSourceTypeName() const override; - ZResourceType GetResourceType() const override; - - int32_t numCommands; - int32_t endFrame; - std::vector commands; - -protected: - CutsceneCommand* GetCommandOoT(uint32_t id, offset_t currentPtr) const; - CutsceneCommand* GetCommandMM(uint32_t id, offset_t currentPtr) const; -}; diff --git a/ZAPDTR/ZAPD/ZDisplayList.cpp b/ZAPDTR/ZAPD/ZDisplayList.cpp deleted file mode 100644 index 9a43a2a22..000000000 --- a/ZAPDTR/ZAPD/ZDisplayList.cpp +++ /dev/null @@ -1,2257 +0,0 @@ -#include "ZDisplayList.h" - -#include -#include -#include -#include -#include - -#include "Globals.h" -#include "OutputFormatter.h" -#include "Utils/BitConverter.h" -#include -#include "Utils/Path.h" -#include "Utils/StringHelper.h" -#include "WarningHandler.h" -#include "gfxd.h" - - -#define G_MDSFT_ALPHACOMPARE 0 -#define G_MDSFT_ZSRCSEL 2 -#define G_MDSFT_RENDERMODE 3 -#define G_MDSFT_BLENDER 16 - -#define G_RM_FOG_SHADE_A 0xC8000000 -#define G_RM_FOG_PRIM_A 0xC4000000 -#define G_RM_PASS 0x0C080000 -#define G_RM_AA_ZB_OPA_SURF 0x442078 -#define G_RM_AA_ZB_OPA_SURF2 0x112078 -#define G_RM_AA_ZB_XLU_SURF 0x4049D8 -#define G_RM_AA_ZB_XLU_SURF2 0x1049D8 -#define G_RM_AA_ZB_OPA_DECAL 0x442D58 -#define G_RM_AA_ZB_OPA_DECAL2 0x112D58 -#define G_RM_AA_ZB_XLU_DECAL 0x404DD8 -#define G_RM_AA_ZB_XLU_DECAL2 0x104DD8 -#define G_RM_AA_ZB_OPA_INTER 0x442478 -#define G_RM_AA_ZB_OPA_INTER2 0x112478 -#define G_RM_AA_ZB_XLU_INTER 0x4045D8 -#define G_RM_AA_ZB_XLU_INTER2 0x1045D8 -#define G_RM_AA_ZB_XLU_LINE 0x407858 -#define G_RM_AA_ZB_XLU_LINE2 0x107858 -#define G_RM_AA_ZB_DEC_LINE 0x407F58 -#define G_RM_AA_ZB_DEC_LINE2 0x107F58 -#define G_RM_AA_ZB_TEX_EDGE 0x443078 -#define G_RM_AA_ZB_TEX_EDGE2 0x113078 -#define G_RM_AA_ZB_TEX_INTER 0x443478 -#define G_RM_AA_ZB_TEX_INTER2 0x113478 -#define G_RM_AA_ZB_SUB_SURF 0x442878 -#define G_RM_AA_ZB_SUB_SURF2 0x112278 -#define G_RM_AA_ZB_PCL_SURF 0x40007B -#define G_RM_AA_ZB_PCL_SURF2 0x10007B -#define G_RM_AA_ZB_OPA_TERR 0x402078 -#define G_RM_AA_ZB_OPA_TERR2 0x102078 -#define G_RM_AA_ZB_TEX_TERR 0x403078 -#define G_RM_AA_ZB_TEX_TERR2 0x103078 -#define G_RM_AA_ZB_SUB_TERR 0x402278 -#define G_RM_AA_ZB_SUB_TERR2 0x102278 -#define G_RM_RA_ZB_OPA_SURF 0x442038 -#define G_RM_RA_ZB_OPA_SURF2 0x112038 -#define G_RM_RA_ZB_OPA_DECAL 0x442D18 -#define G_RM_RA_ZB_OPA_DECAL2 0x112D18 -#define G_RM_RA_ZB_OPA_INTER 0x442438 -#define G_RM_RA_ZB_OPA_INTER2 0x112438 -#define G_RM_AA_OPA_SURF 0x442048 -#define G_RM_AA_OPA_SURF2 0x112048 -#define G_RM_AA_XLU_SURF 0x4041C8 -#define G_RM_AA_XLU_SURF2 0x1041C8 -#define G_RM_AA_XLU_LINE 0x407048 -#define G_RM_AA_XLU_LINE2 0x107048 -#define G_RM_AA_DEC_LINE 0x407248 -#define G_RM_AA_DEC_LINE2 0x107248 -#define G_RM_AA_TEX_EDGE 0x443048 -#define G_RM_AA_TEX_EDGE2 0x113048 -#define G_RM_AA_SUB_SURF 0x442248 -#define G_RM_AA_SUB_SURF2 0x112248 -#define G_RM_AA_PCL_SURF 0x40004B -#define G_RM_AA_PCL_SURF2 0x10004B -#define G_RM_AA_OPA_TERR 0x402048 -#define G_RM_AA_OPA_TERR2 0x102048 -#define G_RM_AA_TEX_TERR 0x403048 -#define G_RM_AA_TEX_TERR2 0x103048 -#define G_RM_AA_SUB_TERR 0x402248 -#define G_RM_AA_SUB_TERR2 0x102248 -#define G_RM_RA_OPA_SURF 0x442008 -#define G_RM_RA_OPA_SURF2 0x112008 -#define G_RM_ZB_OPA_SURF 0x442230 -#define G_RM_ZB_OPA_SURF2 0x112230 -#define G_RM_ZB_XLU_SURF 0x404A50 -#define G_RM_ZB_XLU_SURF2 0x104A50 -#define G_RM_ZB_OPA_DECAL 0x442E10 -#define G_RM_ZB_OPA_DECAL2 0x112E10 -#define G_RM_ZB_XLU_DECAL 0x404E50 -#define G_RM_ZB_XLU_DECAL2 0x104E50 -#define G_RM_ZB_CLD_SURF 0x404B50 -#define G_RM_ZB_CLD_SURF2 0x104B50 -#define G_RM_ZB_OVL_SURF 0x404F50 -#define G_RM_ZB_OVL_SURF2 0x104F50 -#define G_RM_ZB_PCL_SURF 0x0C080233 -#define G_RM_ZB_PCL_SURF2 0x03020233 -#define G_RM_OPA_SURF 0x0C084000 -#define G_RM_OPA_SURF2 0x03024000 -#define G_RM_XLU_SURF 0x00404200 -#define G_RM_XLU_SURF2 0x00104240 -#define G_RM_CLD_SURF 0x00404340 -#define G_RM_CLD_SURF2 0x00104340 -#define G_RM_TEX_EDGE 0x0C087008 -#define G_RM_TEX_EDGE2 0x03027008 -#define G_RM_PCL_SURF 0x0C084203 -#define G_RM_PCL_SURF2 0x03024203 -#define G_RM_ADD 0x04484340 -#define G_RM_ADD2 0x01124340 -#define G_RM_NOOP 0x00000000 -#define G_RM_NOOP2 0x00000000 -#define G_RM_VISCVG 0x0C844040 -#define G_RM_VISCVG2 0x03214040 -#define G_RM_OPA_CI 0x0C080000 -#define G_RM_OPA_CI2 0x03020000 - -#define AA_EN 0x8 -#define Z_CMP 0x10 -#define Z_UPD 0x20 -#define IM_RD 0x40 -#define CLR_ON_CVG 0x80 -#define CVG_DST_CLAMP 0 -#define CVG_DST_WRAP 0x100 -#define CVG_DST_FULL 0x200 -#define CVG_DST_SAVE 0x300 -#define ZMODE_OPA 0 -#define ZMODE_INTER 0x400 -#define ZMODE_XLU 0x800 -#define ZMODE_DEC 0xc00 -#define CVG_X_ALPHA 0x1000 -#define ALPHA_CVG_SEL 0x2000 -#define FORCE_BL 0x4000 -#define TEX_EDGE 0x0000 - -REGISTER_ZFILENODE(DList, ZDisplayList); - -ZDisplayList::ZDisplayList(ZFile* nParent) : ZResource(nParent) -{ - lastTexWidth = 0; - lastTexHeight = 0; - lastTexAddr = 0; - lastTexFmt = F3DZEXTexFormats::G_IM_FMT_RGBA; - lastTexSiz = F3DZEXTexSizes::G_IM_SIZ_16b; - lastTexSizTest = F3DZEXTexSizes::G_IM_SIZ_16b; - lastTexLoaded = false; - lastTexIsPalette = false; - dListType = Globals::Instance->game == ZGame::OOT_SW97 ? DListType::F3DEX : DListType::F3DZEX; - genOTRDef = true; - RegisterOptionalAttribute("Ucode"); -} - -ZDisplayList::~ZDisplayList() -{ - for (auto o : otherDLists) - { - delete o; - } -} - -// EXTRACT MODE -void ZDisplayList::ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) -{ - rawDataIndex = nRawDataIndex; - ParseXML(reader); - // TODO add error handling here - bool ucodeSet = registeredAttributes.at("Ucode").wasSet; - std::string ucodeValue = registeredAttributes.at("Ucode").value; - if ((Globals::Instance->game == ZGame::OOT_SW97) || (ucodeValue == "f3dex")) - { - dListType = DListType::F3DEX; - } - else if (!ucodeSet || ucodeValue == "f3dex2") - { - dListType = DListType::F3DZEX; - } - else - { - HANDLE_ERROR_RESOURCE( - WarningType::InvalidAttributeValue, parent, this, rawDataIndex, - StringHelper::Sprintf("Invalid ucode type in node: %s\n", reader->Name()), ""); - } - - // Don't parse raw data of external files - if (parent->GetMode() != ZFileMode::ExternalFile) - { - int32_t rawDataSize = - ZDisplayList::GetDListLength(parent->GetRawData(), rawDataIndex, dListType); - numInstructions = rawDataSize / 8; - ParseRawData(); - } - - Declaration* decl = DeclareVar("", ""); - decl->declaredInXml = true; -} - -void ZDisplayList::ExtractFromBinary(uint32_t nRawDataIndex, int32_t rawDataSize) -{ - rawDataIndex = nRawDataIndex; - name = GetDefaultName(parent->GetName()); - numInstructions = rawDataSize / 8; - - // Don't parse raw data of external files - if (parent->GetMode() == ZFileMode::ExternalFile) - return; - - ParseRawData(); -} - -void ZDisplayList::ParseRawData() -{ - const auto& rawData = parent->GetRawData(); - instructions.reserve(numInstructions); - uint32_t ptr = rawDataIndex; - - instructions.reserve(numInstructions); - for (size_t i = 0; i < numInstructions; i++) - { - instructions.push_back(BitConverter::ToUInt64BE(rawData, ptr)); - ptr += 8; - } -} - -Declaration* ZDisplayList::DeclareVar([[maybe_unused]] const std::string& prefix, - const std::string& bodyStr) -{ - Declaration* decl = - parent->AddDeclarationArray(rawDataIndex, GetDeclarationAlignment(), GetRawDataSize(), - GetSourceTypeName(), name, numInstructions, bodyStr); - decl->isExternal = true; - decl->staticConf = staticConf; - return decl; -} - -std::string ZDisplayList::GetDefaultName(const std::string& prefix) const -{ - return StringHelper::Sprintf("%sDL_%06X", prefix.c_str(), rawDataIndex); -} - -void ZDisplayList::ParseF3DZEX(F3DZEXOpcode opcode, uint64_t data, int32_t i, - const std::string& prefix, char* line) -{ - switch (opcode) - { - case F3DZEXOpcode::G_NOOP: - sprintf(line, "gsDPNoOpTag(0x%08" PRIX64 "),", data & 0xFFFFFFFF); - break; - case F3DZEXOpcode::G_DL: - Opcode_G_DL(data, prefix, line); - break; - case F3DZEXOpcode::G_MODIFYVTX: - Opcode_G_MODIFYVTX(data, line); - break; - case F3DZEXOpcode::G_CULLDL: - Opcode_G_CULLDL(data, line); - break; - case F3DZEXOpcode::G_TRI1: - Opcode_G_TRI1(data, line); - break; - case F3DZEXOpcode::G_TRI2: - Opcode_G_TRI2(data, line); - break; - case F3DZEXOpcode::G_QUAD: - { - int32_t aa = ((data & 0x00FF000000000000ULL) >> 48) / 2; - int32_t bb = ((data & 0x0000FF0000000000ULL) >> 40) / 2; - int32_t cc = ((data & 0x000000FF00000000ULL) >> 32) / 2; - int32_t dd = ((data & 0x000000000000FFULL)) / 2; - sprintf(line, "gsSP1Quadrangle(%i, %i, %i, %i, 0),", aa, bb, cc, dd); - } - break; - case F3DZEXOpcode::G_VTX: - Opcode_G_VTX(data, line); - break; - case F3DZEXOpcode::G_SETTIMG: // HOTSPOT - Opcode_G_SETTIMG(data, prefix, line); - break; - case F3DZEXOpcode::G_GEOMETRYMODE: - { - int32_t cccccc = (data & 0x00FFFFFF00000000) >> 32; - int32_t ssssssss = (data & 0xFFFFFFFF); - std::string geoModeStr = "G_TEXTURE_ENABLE"; - - int32_t geoModeParam = ~cccccc; - - if (ssssssss != 0) - geoModeParam = ssssssss; - - if (geoModeParam & 0x00000001) - geoModeStr += " | G_ZBUFFER"; - - if (geoModeParam & 0x00000004) - geoModeStr += " | G_SHADE"; - - if (geoModeParam & 0x00000200) - geoModeStr += " | G_CULL_FRONT"; - - if (geoModeParam & 0x00000400) - geoModeStr += " | G_CULL_BACK"; - - if (geoModeParam & 0x00010000) - geoModeStr += " | G_FOG"; - - if (geoModeParam & 0x00020000) - geoModeStr += " | G_LIGHTING"; - - if (geoModeParam & 0x00040000) - geoModeStr += " | G_TEXTURE_GEN"; - - if (geoModeParam & 0x00080000) - geoModeStr += " | G_TEXTURE_GEN_LINEAR"; - - if (geoModeParam & 0x00200000) - geoModeStr += " | G_SHADING_SMOOTH"; - - if (geoModeParam & 0x00800000) - geoModeStr += " | G_CLIPPING"; - - if (ssssssss != 0) - { - if ((~cccccc & 0xFF000000) != 0) - sprintf(line, "gsSPSetGeometryMode(%s),", geoModeStr.c_str()); - else - sprintf(line, "gsSPLoadGeometryMode(%s),", geoModeStr.c_str()); - } - else - sprintf(line, "gsSPClearGeometryMode(%s),", geoModeStr.c_str()); - } - break; - case F3DZEXOpcode::G_SETPRIMCOLOR: - Opcode_G_SETPRIMCOLOR(data, line); - break; - case F3DZEXOpcode::G_SETOTHERMODE_L: - Opcode_G_SETOTHERMODE_L(data, line); - break; - case F3DZEXOpcode::G_SETOTHERMODE_H: - Opcode_G_SETOTHERMODE_H(data, line); - break; - case F3DZEXOpcode::G_SETTILE: - Opcode_G_SETTILE(data, line); - break; - case F3DZEXOpcode::G_SETTILESIZE: - Opcode_G_SETTILESIZE(data, prefix, line); - break; - case F3DZEXOpcode::G_LOADBLOCK: - Opcode_G_LOADBLOCK(data, line); - break; - case F3DZEXOpcode::G_TEXTURE: - Opcode_G_TEXTURE(data, line); - break; - case F3DZEXOpcode::G_RDPSETOTHERMODE: - { - int32_t hhhhhh = (data & 0x00FFFFFF00000000) >> 32; - int32_t llllllll = (data & 0x00000000FFFFFFFF); - - sprintf(line, "gsDPSetOtherMode(%i, %i),", hhhhhh, llllllll); - } - break; - case F3DZEXOpcode::G_POPMTX: - { - sprintf(line, "gsSPPopMatrix(%" PRIi64 "),", data); - } - break; - case F3DZEXOpcode::G_LOADTLUT: - Opcode_G_LOADTLUT(data, prefix, line); - break; - case F3DZEXOpcode::G_SETENVCOLOR: - { - uint8_t r = (uint8_t)((data & 0xFF000000) >> 24); - uint8_t g = (uint8_t)((data & 0x00FF0000) >> 16); - uint8_t b = (uint8_t)((data & 0xFF00FF00) >> 8); - uint8_t a = (uint8_t)((data & 0x000000FF) >> 0); - - sprintf(line, "gsDPSetEnvColor(%i, %i, %i, %i),", r, g, b, a); - } - break; - case F3DZEXOpcode::G_SETCOMBINE: - { - Opcode_G_SETCOMBINE(data, line); - } - break; - case F3DZEXOpcode::G_RDPLOADSYNC: - sprintf(line, "gsDPLoadSync(),"); - break; - case F3DZEXOpcode::G_RDPPIPESYNC: - sprintf(line, "gsDPPipeSync(),"); - break; - case F3DZEXOpcode::G_RDPTILESYNC: - sprintf(line, "gsDPTileSync(),"); - break; - case F3DZEXOpcode::G_RDPFULLSYNC: - sprintf(line, "gsDPFullSync(),"); - break; - case F3DZEXOpcode::G_ENDDL: - Opcode_G_ENDDL(prefix, line); - break; - case F3DZEXOpcode::G_RDPHALF_1: - { - uint64_t data2 = instructions[i + 1]; - uint32_t h = (data & 0xFFFFFFFF); - F3DZEXOpcode opcode2 = (F3DZEXOpcode)(instructions[i + 1] >> 56); - - if (opcode2 == F3DZEXOpcode::G_BRANCH_Z) - { - uint32_t a = (data2 & 0x00FFF00000000000) >> 44; - uint32_t b = (data2 & 0x00000FFF00000000) >> 32; - uint32_t z = (data2 & 0x00000000FFFFFFFF) >> 0; - - // sprintf(line, "gsDPWord(%i, 0),", h); - sprintf(line, "gsSPBranchLessZraw(%sDlist0x%06X, 0x%02X, 0x%02X),", prefix.c_str(), - h & 0x00FFFFFF, (a / 5) | (b / 2), z); - - ZDisplayList* nList = new ZDisplayList(parent); - nList->ExtractFromBinary( - h & 0x00FFFFFF, GetDListLength(parent->GetRawData(), h & 0x00FFFFFF, dListType)); - nList->SetName(nList->GetDefaultName(prefix)); - otherDLists.push_back(nList); - - i++; - } - } - break; - case F3DZEXOpcode::G_MTX: - Opcode_G_MTX(data, line); - break; - default: - sprintf(line, "// Opcode 0x%02X unimplemented!", (uint32_t)opcode); - break; - } -} - -void ZDisplayList::ParseF3DEX(F3DEXOpcode opcode, uint64_t data, const std::string& prefix, - char* line) -{ - switch (opcode) - { - case F3DEXOpcode::G_NOOP: - sprintf(line, "gsDPNoOpTag(0x%08" PRIX64 "),", data & 0xFFFFFFFF); - break; - case F3DEXOpcode::G_VTX: - Opcode_G_VTX(data, line); - break; - case F3DEXOpcode::G_DL: - Opcode_G_DL(data, prefix, line); - break; - case F3DEXOpcode::G_CULLDL: - Opcode_G_CULLDL(data, line); - break; - case F3DEXOpcode::G_MODIFYVTX: - Opcode_G_MODIFYVTX(data, line); - break; - case F3DEXOpcode::G_MTX: - Opcode_G_MTX(data, line); - break; - case F3DEXOpcode::G_TRI1: - Opcode_G_TRI1(data, line); - break; - case F3DEXOpcode::G_TRI2: - Opcode_G_TRI2(data, line); - break; - case F3DEXOpcode::G_ENDDL: - Opcode_G_ENDDL(prefix, line); - break; - case F3DEXOpcode::G_RDPLOADSYNC: - sprintf(line, "gsDPLoadSync(),"); - break; - case F3DEXOpcode::G_RDPPIPESYNC: - sprintf(line, "gsDPPipeSync(),"); - break; - case F3DEXOpcode::G_RDPTILESYNC: - sprintf(line, "gsDPTileSync(),"); - break; - case F3DEXOpcode::G_RDPFULLSYNC: - sprintf(line, "gsDPFullSync(),"); - break; - case F3DEXOpcode::G_TEXTURE: - Opcode_G_TEXTURE(data, line); - break; - case F3DEXOpcode::G_SETTIMG: - Opcode_G_SETTIMG(data, prefix, line); - break; - case F3DEXOpcode::G_SETTILE: - Opcode_G_SETTILE(data, line); - break; - case F3DEXOpcode::G_SETTILESIZE: - Opcode_G_SETTILESIZE(data, prefix, line); - break; - case F3DEXOpcode::G_LOADBLOCK: - Opcode_G_LOADBLOCK(data, line); - break; - case F3DEXOpcode::G_SETCOMBINE: - Opcode_G_SETCOMBINE(data, line); - break; - case F3DEXOpcode::G_SETPRIMCOLOR: - Opcode_G_SETPRIMCOLOR(data, line); - break; - case F3DEXOpcode::G_SETOTHERMODE_L: - Opcode_G_SETOTHERMODE_L(data, line); - break; - case F3DEXOpcode::G_SETOTHERMODE_H: - Opcode_G_SETOTHERMODE_H(data, line); - break; - case F3DEXOpcode::G_LOADTLUT: - Opcode_G_LOADTLUT(data, prefix, line); - break; - case F3DEXOpcode::G_CLEARGEOMETRYMODE: - case F3DEXOpcode::G_SETGEOMETRYMODE: - { - int32_t cccccc = (data & 0x00FFFFFF00000000) >> 32; - int32_t ssssssss = (data & 0xFFFFFFFF); - std::string geoModeStr = "G_TEXTURE_ENABLE"; - - int32_t geoModeParam = ~cccccc; - - if (ssssssss != 0) - geoModeParam = ssssssss; - - if (geoModeParam & 0x00000002) - geoModeStr += " | G_TEXTURE_ENABLE"; - - if (geoModeParam & 0x00000200) - geoModeStr += " | G_SHADING_SMOOTH"; - - if (geoModeParam & 0x00001000) - geoModeStr += " | G_CULL_FRONT"; - - if (geoModeParam & 0x00002000) - geoModeStr += " | G_CULL_BACK"; - - if (geoModeParam & 0x00000001) - geoModeStr += " | G_ZBUFFER"; - - if (geoModeParam & 0x00000004) - geoModeStr += " | G_SHADE"; - - if (geoModeParam & 0x00010000) - geoModeStr += " | G_FOG"; - - if (geoModeParam & 0x00020000) - geoModeStr += " | G_LIGHTING"; - - if (geoModeParam & 0x00040000) - geoModeStr += " | G_TEXTURE_GEN"; - - if (geoModeParam & 0x00080000) - geoModeStr += " | G_TEXTURE_GEN_LINEAR"; - - if (geoModeParam & 0x00800000) - geoModeStr += " | G_CLIPPING"; - - if (opcode == F3DEXOpcode::G_SETGEOMETRYMODE) - sprintf(line, "gsSPSetGeometryMode(%s),", geoModeStr.c_str()); - else - sprintf(line, "gsSPClearGeometryMode(%s),", geoModeStr.c_str()); - } - break; - default: - sprintf(line, "// Opcode 0x%02X unimplemented!", (uint32_t)opcode); - break; - } -} - -int32_t ZDisplayList::GetDListLength(const std::vector& rawData, uint32_t rawDataIndex, - DListType dListType) -{ - uint8_t endDLOpcode; - uint8_t branchListOpcode; - - if (dListType == DListType::F3DZEX) - { - endDLOpcode = static_cast(F3DZEXOpcode::G_ENDDL); - branchListOpcode = static_cast(F3DZEXOpcode::G_DL); - } - else - { - endDLOpcode = static_cast(F3DEXOpcode::G_ENDDL); - branchListOpcode = static_cast(F3DEXOpcode::G_DL); - } - - uint32_t ptr = rawDataIndex; - size_t rawDataSize = rawData.size(); - while (true) - { - if (ptr >= rawDataSize) - { - std::string errorHeader = - StringHelper::Sprintf("reached end of file when trying to find the end of the " - "DisplayList starting at offset 0x%X", - rawDataIndex); - std::string errorBody = StringHelper::Sprintf("Raw data size: 0x%zX.", rawDataSize); - HANDLE_ERROR_PROCESS(WarningType::Always, errorHeader, errorBody); - } - - uint8_t opcode = rawData.at(ptr); - bool dlNoPush = rawData.at(ptr + 1) == 1; - ptr += 8; - - if (opcode == endDLOpcode || (opcode == branchListOpcode && dlNoPush)) - { - return ptr - rawDataIndex; - } - } -} - -bool ZDisplayList::SequenceCheck(std::vector sequence, int32_t startIndex) -{ - bool success = true; - - for (size_t j = 0; j < sequence.size(); j++) - { - F3DZEXOpcode opcode = (F3DZEXOpcode)(instructions[startIndex + j] >> 56); - - if (sequence[j] != opcode) - { - success = false; - break; - } - } - - if (success) - return true; - - return false; -} - -int32_t ZDisplayList::OptimizationChecks(int32_t startIndex, std::string& output, - const std::string& prefix) -{ - int32_t result = -1; - - result = OptimizationCheck_LoadTextureBlock(startIndex, output, prefix); - - if (result != -1) - return result; - - return -1; -} - -int32_t ZDisplayList::OptimizationCheck_LoadTextureBlock(int32_t startIndex, std::string& output, - [[maybe_unused]] const std::string& prefix) -{ - std::vector sequence = {F3DZEXOpcode::G_SETTIMG, F3DZEXOpcode::G_SETTILE, - F3DZEXOpcode::G_RDPLOADSYNC, F3DZEXOpcode::G_LOADBLOCK, - F3DZEXOpcode::G_RDPPIPESYNC, F3DZEXOpcode::G_SETTILE, - F3DZEXOpcode::G_SETTILESIZE}; - - bool seqRes = SequenceCheck(sequence, startIndex); - - if (seqRes) - { - // gsDPLoadTextureBlock(texAddr, fmt, siz, width, height, pal, cms, cmt, masks, maskt, - // shifts, shiftt) gsDPLoadMultiBlock(texAddr, tmem, rtile, fmt, siz, width, height, pal, - // cms, cmt, masks, maskt, shifts, shiftt) gsDPLoadTextureBlock_4b(texAddr, fmt, width, - // height, pal, cms, cmt, masks, maskt, shifts, shiftt) gsDPLoadMultiBlock_4b(texAddr, tmem, - // rtile, fmt, width, height, pal, cms, cmt, masks, maskt, shifts, shiftt) - - uint32_t texAddr, tmem, rtile, fmt, siz, sizB, width, height, width2, height2, pal, cms, - cmt, masks, maskt, shifts, shiftt; - std::string texStr; - - // gsDPSetTextureImage - { - uint64_t data = instructions[startIndex + 0]; - - int32_t __ = (data & 0x00FF000000000000) >> 48; - // int32_t www = (data & 0x00000FFF00000000) >> 32; - - fmt = (__ & 0xE0) >> 5; - siz = (__ & 0x18) >> 3; - texAddr = Seg2Filespace(data, parent->baseAddress); - uint32_t segmentNumber = GETSEGNUM(data); - - lastTexSeg = segmentNumber; - - Globals::Instance->GetSegmentedPtrName(data & 0xFFFFFFFF, parent, "", texStr, - parent->workerID); - } - - // gsDPSetTile - { - uint64_t data = instructions[startIndex + 1]; - - tmem = - (data & 0b0000000000000000111111111111111100000000000000000000000000000000) >> 32; - - cmt = (data & 0b0000000000000000000000000000000000000000000011000000000000000000) >> 18; - maskt = - (data & 0b0000000000000000000000000000000000000000000000111100000000000000) >> 14; - shiftt = - (data & 0b0000000000000000000000000000000000000000000000000011110000000000) >> 10; - cms = (data & 0b0000000000000000000000000000000000000000000000000000001100000000) >> 8; - masks = - (data & 0b0000000000000000000000000000000000000000000000000000000011110000) >> 4; - shifts = (data & 0b0000000000000000000000000000000000000000000000000000000000001111); - - // sprintf(line, "gsDPSetTile(%s, %s, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i),", - // fmtTbl[fff].c_str(), sizTbl[ii].c_str(), nnnnnnnnn, mmmmmmmmm, ttt, pppp, cc, aaaa, - // ssss, dd, bbbb, uuuu); - } - - // gsDPLoadSync - - // gsDPLoadBlock - - // gsDPPipeSync - - // gsDPSetTile - { - uint64_t data = instructions[startIndex + 5]; - int32_t __ = (data & 0x00FF000000000000) >> 48; - pal = (data & 0b0000000000000000000000000000000000000000111100000000000000000000) >> 20; - // siz = (__ & 0x18) >> 3; - rtile = - (data & 0b0000000000000000000000000000000011111111000000000000000000000000) >> 24; - sizB = (__ & 0x18) >> 3; - } - - // gsDPSetTileSize - { - uint64_t data = instructions[startIndex + 6]; - int32_t uuu = (data & 0x0000000000FFF000) >> 12; - int32_t vvv = (data & 0x0000000000000FFF); - - int32_t shiftAmtW = 2; - int32_t shiftAmtH = 2; - - if (sizB == (int32_t)F3DZEXTexSizes::G_IM_SIZ_8b && - fmt == (int32_t)F3DZEXTexFormats::G_IM_FMT_IA) - shiftAmtW = 3; - - if (sizB == (int32_t)F3DZEXTexSizes::G_IM_SIZ_4b) - shiftAmtW = 3; - - if (sizB == (int32_t)F3DZEXTexSizes::G_IM_SIZ_4b && - fmt == (int32_t)F3DZEXTexFormats::G_IM_FMT_IA) - shiftAmtH = 3; - - width = (uuu >> shiftAmtW) + 1; - height = (vvv >> shiftAmtH) + 1; - - width2 = (uuu >> 2) + 1; - height2 = (vvv >> 2) + 1; - } - - const char* fmtTbl[] = {"G_IM_FMT_RGBA", "G_IM_FMT_YUV", "G_IM_FMT_CI", "G_IM_FMT_IA", - "G_IM_FMT_I"}; - const char* sizTbl[] = {"G_IM_SIZ_4b", "G_IM_SIZ_8b", "G_IM_SIZ_16b", "G_IM_SIZ_32b"}; - - // output += StringHelper::Sprintf("gsDPLoadTextureBlock(%s, %s, %s, %i, %i, %i, %i, %i, %i, - // %i, %i, %i),", texStr.c_str(), fmtTbl[fmt], sizTbl[siz].c_str(), width, height, - // pal, cms, cmt, masks, maskt, shifts, shiftt); - - if (siz == 2 && sizB == 0) - { - if (tmem != 0) - output += StringHelper::Sprintf( - "gsDPLoadMultiBlock_4b(%s, %i, %i, %s, %i, %i, %i, %i, %i, %i, %i, %i, %i),", - texStr.c_str(), tmem, rtile, fmtTbl[fmt], width2, height2, pal, cms, cmt, masks, - maskt, shifts, shiftt); - else - output += StringHelper::Sprintf( - "gsDPLoadTextureBlock_4b(%s, %s, %i, %i, %i, %i, %i, %i, %i, %i, %i),", - texStr.c_str(), fmtTbl[fmt], width2, height2, pal, cms, cmt, masks, maskt, - shifts, shiftt); - } - else if (siz == 2 && sizB != 0) - { - if (tmem != 0) - output += StringHelper::Sprintf( - "gsDPLoadMultiBlock(%s, %i, %i, %s, %s, %i, %i, %i, %i, %i, %i, %i, %i, %i),", - texStr.c_str(), tmem, rtile, fmtTbl[fmt], sizTbl[sizB], width2, height2, pal, - cms, cmt, masks, maskt, shifts, shiftt); - else - output += StringHelper::Sprintf( - "gsDPLoadTextureBlock(%s, %s, %s, %i, %i, %i, %i, %i, %i, %i, %i, %i),", - texStr.c_str(), fmtTbl[fmt], sizTbl[sizB], width2, height2, pal, cms, cmt, - masks, maskt, shifts, shiftt); - } - else - { - if (siz != sizB) - { - lastTexAddr = texAddr; - lastTexFmt = (F3DZEXTexFormats)fmt; - lastTexWidth = width; - lastTexHeight = height; - lastTexSiz = (F3DZEXTexSizes)siz; - lastTexLoaded = true; - - TextureGenCheck(); - - return -1; - } - - output += StringHelper::Sprintf( - "gsDPLoadMultiBlock(%s, %i, %i, %s, %s, %i, %i, %i, %i, %i, %i, %i, %i, %i),", - texStr.c_str(), tmem, rtile, fmtTbl[fmt], sizTbl[siz], width, height, pal, cms, cmt, - masks, maskt, shifts, shiftt); - } - - lastTexAddr = texAddr; - lastTexFmt = (F3DZEXTexFormats)fmt; - lastTexWidth = width; - lastTexHeight = height; - lastTexSiz = (F3DZEXTexSizes)siz; - lastTexLoaded = true; - - TextureGenCheck(); - - return (int32_t)sequence.size(); - } - - return -1; -} - -void ZDisplayList::Opcode_G_DL(uint64_t data, const std::string& prefix, char* line) -{ - int32_t pp = (data & 0x00FF000000000000) >> 56; - int32_t segNum = GETSEGNUM(data); - - Declaration* dListDecl = nullptr; - - if (parent != nullptr) - dListDecl = parent->GetDeclaration(GETSEGOFFSET(data)); - - if (pp != 0) - { - if (!Globals::Instance->HasSegment(segNum, parent->workerID)) - sprintf(line, "gsSPBranchList(0x%08" PRIX64 "),", data & 0xFFFFFFFF); - else if (dListDecl != nullptr) - sprintf(line, "gsSPBranchList(%s),", dListDecl->varName.c_str()); - else - sprintf(line, "gsSPBranchList(%sDlist0x%06" PRIX64 "),", prefix.c_str(), - GETSEGOFFSET(data)); - } - else - { - if (!Globals::Instance->HasSegment(segNum, parent->workerID)) - sprintf(line, "gsSPDisplayList(0x%08" PRIX64 "),", data & 0xFFFFFFFF); - else if (dListDecl != nullptr) - sprintf(line, "gsSPDisplayList(%s),", dListDecl->varName.c_str()); - else - sprintf(line, "gsSPDisplayList(%sDlist0x%06" PRIX64 "),", prefix.c_str(), - GETSEGOFFSET(data)); - } - - // if (segNum == 8 || segNum == 9 || segNum == 10 || segNum == 11 || segNum == 12 || segNum == - // 13) // Used for runtime-generated display lists - if (!Globals::Instance->HasSegment(segNum, parent->workerID)) - { - if (pp != 0) - sprintf(line, "gsSPBranchList(0x%08" PRIX64 "),", data & 0xFFFFFFFF); - else - sprintf(line, "gsSPDisplayList(0x%08" PRIX64 "),", data & 0xFFFFFFFF); - } - else - { - ZDisplayList* nList = new ZDisplayList(parent); - nList->ExtractFromBinary(GETSEGOFFSET(data), GetDListLength(parent->GetRawData(), - GETSEGOFFSET(data), dListType)); - nList->SetName(nList->GetDefaultName(prefix)); - - otherDLists.push_back(nList); - } -} - -void ZDisplayList::Opcode_G_MODIFYVTX(uint64_t data, char* line) -{ - int32_t ww = (data & 0x00FF000000000000ULL) >> 48; - int32_t nnnn = (data & 0x0000FFFF00000000ULL) >> 32; - int32_t vvvvvvvv = (data & 0x00000000FFFFFFFFULL); - - sprintf(line, "gsSPModifyVertex(%i, %i, %i),", nnnn / 2, ww, vvvvvvvv); -} - -void ZDisplayList::Opcode_G_CULLDL(uint64_t data, char* line) -{ - int32_t vvvv = (data & 0xFFFF00000000) >> 32; - int32_t wwww = (data & 0x0000FFFF); - - sprintf(line, "gsSPCullDisplayList(%i, %i),", vvvv / 2, wwww / 2); -} - -void ZDisplayList::Opcode_G_TRI1(uint64_t data, char* line) -{ - if (dListType == DListType::F3DZEX) - { - int32_t aa = ((data & 0x00FF000000000000ULL) >> 48) / 2; - int32_t bb = ((data & 0x0000FF0000000000ULL) >> 40) / 2; - int32_t cc = ((data & 0x000000FF00000000ULL) >> 32) / 2; - sprintf(line, "gsSP1Triangle(%i, %i, %i, 0),", aa, bb, cc); - } - else - { - int32_t aa = ((data & 0x0000000000FF0000ULL) >> 16) / 2; - int32_t bb = ((data & 0x000000000000FF00ULL) >> 8) / 2; - int32_t cc = ((data & 0x00000000000000FFULL) >> 0) / 2; - sprintf(line, "gsSP1Triangle(%i, %i, %i, 0),", aa, bb, cc); - } -} - -void ZDisplayList::Opcode_G_TRI2(uint64_t data, char* line) -{ - int32_t aa = ((data & 0x00FF000000000000ULL) >> 48) / 2; - int32_t bb = ((data & 0x0000FF0000000000ULL) >> 40) / 2; - int32_t cc = ((data & 0x000000FF00000000ULL) >> 32) / 2; - int32_t dd = ((data & 0x00000000FF0000ULL) >> 16) / 2; - int32_t ee = ((data & 0x0000000000FF00ULL) >> 8) / 2; - int32_t ff = ((data & 0x000000000000FFULL) >> 0) / 2; - sprintf(line, "gsSP2Triangles(%i, %i, %i, 0, %i, %i, %i, 0),", aa, bb, cc, dd, ee, ff); -} - -void ZDisplayList::Opcode_G_MTX(uint64_t data, char* line) -{ - uint32_t pp = 0; - uint32_t mm = (data & 0x00000000FFFFFFFF); - bool push = false; - bool load = false; - bool projection = false; - - if (dListType == DListType::F3DEX) - pp = (data & 0x00FF000000000000) >> 48; - else - pp = (data & 0x000000FF00000000) >> 32; - - std::string matrixRef; - - if (Globals::Instance->cfg.symbolMap.find(mm) != Globals::Instance->cfg.symbolMap.end()) - matrixRef = StringHelper::Sprintf("&%s", Globals::Instance->cfg.symbolMap[mm].c_str()); - else - matrixRef = StringHelper::Sprintf("0x%08X", mm); - - pp ^= 0x01; - - if (pp & 0x01) - push = true; - - if (pp & 0x02) - load = true; - - if (pp & 0x04) - projection = true; - - sprintf(line, "gsSPMatrix(%s, %s | %s | %s),", matrixRef.c_str(), - projection ? "G_MTX_PROJECTION" : "G_MTX_MODELVIEW", - push ? "G_MTX_PUSH" : "G_MTX_NOPUSH", load ? "G_MTX_LOAD" : "G_MTX_MUL"); -} - -void ZDisplayList::Opcode_G_VTX(uint64_t data, char* line) -{ - int32_t nn = (data & 0x000FF00000000000ULL) >> 44; - int32_t aa = (data & 0x000000FF00000000ULL) >> 32; - - uint32_t vtxAddr = Seg2Filespace(data, parent->baseAddress); - - if (dListType == DListType::F3DZEX) - sprintf(line, "gsSPVertex(@r, %i, %i),", nn, ((aa >> 1) - nn)); - else - { - uint32_t hi = data >> 32; - -#define _SHIFTR(v, s, w) (((uint32_t)v >> s) & ((0x01 << w) - 1)) - - nn = _SHIFTR(hi, 10, 6); - - sprintf(line, "gsSPVertex(@r, %i, %i),", nn, _SHIFTR(hi, 17, 7)); - } - - // Hack: Don't extract vertices from a unknown segment. - if (!Globals::Instance->HasSegment(GETSEGNUM(data), parent->workerID)) - { - segptr_t segmented = data & 0xFFFFFFFF; - references.push_back(segmented); - parent->AddDeclaration(segmented, DeclarationAlignment::Align8, 16, "Vtx", - StringHelper::Sprintf("0x%08X", segmented), ""); - return; - } - references.push_back(data); - - { - uint32_t currentPtr = Seg2Filespace(data, parent->baseAddress); - Declaration* decl; - - // Check for vertex intersections from other display lists - // TODO: These two could probably be condenced to one... - decl = parent->GetDeclarationRanged(vtxAddr + (nn * 16)); - if (decl != nullptr) - { - int32_t diff = decl->address - vtxAddr; - if (diff > 0) - nn = diff / 16; - else - nn = 0; - } - - decl = parent->GetDeclarationRanged(vtxAddr); - if (decl != nullptr) - { - int32_t diff = decl->address - vtxAddr; - if (diff > 0) - nn = diff / 16; - else - nn = 0; - } - - if (nn > 0) - { - std::vector vtxList; - vtxList.reserve(nn); - - for (int32_t i = 0; i < nn; i++) - { - ZVtx vtx(parent); - vtx.ExtractFromFile(currentPtr); - vtxList.push_back(vtx); - - currentPtr += 16; - } - - vertices[vtxAddr] = vtxList; - } - } -} - -void ZDisplayList::Opcode_G_TEXTURE(uint64_t data, char* line) -{ - int32_t ____ = (data & 0x0000FFFF00000000) >> 32; - int32_t ssss = (data & 0x00000000FFFF0000) >> 16; - int32_t tttt = (data & 0x000000000000FFFF); - int32_t lll = (____ & 0x3800) >> 11; - int32_t ddd = (____ & 0x700) >> 8; - int32_t nnnnnnn = 0; - - if (dListType == DListType::F3DEX) - nnnnnnn = (____ & 0xFF); - else - nnnnnnn = (____ & 0xFE) >> 1; - - sprintf(line, "gsSPTexture(%i, %i, %i, %i, %s),", ssss, tttt, lll, ddd, - nnnnnnn == 1 ? "G_ON" : "G_OFF"); -} - -void ZDisplayList::Opcode_G_SETTIMG(uint64_t data, const std::string& prefix, char* line) -{ - int32_t __ = (data & 0x00FF000000000000) >> 48; - int32_t www = (data & 0x00000FFF00000000) >> 32; - const char* fmtTbl[] = {"G_IM_FMT_RGBA", "G_IM_FMT_YUV", "G_IM_FMT_CI", "G_IM_FMT_IA", - "G_IM_FMT_I"}; - const char* sizTbl[] = {"G_IM_SIZ_4b", "G_IM_SIZ_8b", "G_IM_SIZ_16b", "G_IM_SIZ_32b"}; - - uint32_t fmt = (__ & 0xE0) >> 5; - uint32_t siz = (__ & 0x18) >> 3; - - if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_DEBUG) - printf("TextureGenCheck G_SETTIMG\n"); - - TextureGenCheck(); // HOTSPOT - - lastTexFmt = (F3DZEXTexFormats)fmt; - lastTexSiz = (F3DZEXTexSizes)siz; - lastTexSeg = data; - lastTexAddr = Seg2Filespace(data, parent->baseAddress); - - int32_t segmentNumber = GETSEGNUM(data); - - if (segmentNumber != 2) - { - char texStr[2048]; - int32_t texAddress = Seg2Filespace(data, parent->baseAddress); - Declaration* texDecl = nullptr; - - if (parent != nullptr) - { - if (Globals::Instance->HasSegment(segmentNumber, parent->workerID)) - texDecl = parent->GetDeclaration(texAddress); - else - texDecl = parent->GetDeclaration(data); - } - - if (texDecl != nullptr) - sprintf(texStr, "%s", texDecl->varName.c_str()); - else if (data != 0 && Globals::Instance->HasSegment(segmentNumber, parent->workerID)) - sprintf(texStr, "%sTex_%06X", prefix.c_str(), texAddress); - else - { - sprintf(texStr, "0x%08" PRIX64, data & 0xFFFFFFFF); - } - - sprintf(line, "gsDPSetTextureImage(%s, %s, %i, %s),", fmtTbl[fmt], sizTbl[siz], www + 1, - texStr); - } - else - { - std::string texName; - Globals::Instance->GetSegmentedPtrName(data, parent, "", texName, parent->workerID); - sprintf(line, "gsDPSetTextureImage(%s, %s, %i, %s),", fmtTbl[fmt], sizTbl[siz], www + 1, - texName.c_str()); - } -} - -void ZDisplayList::Opcode_G_SETTILE(uint64_t data, char* line) -{ - int32_t fff = (data & 0b0000000011100000000000000000000000000000000000000000000000000000) >> 53; - int32_t ii = (data & 0b0000000000011000000000000000000000000000000000000000000000000000) >> 51; - int32_t nnnnnnnnn = - (data & 0b0000000000000011111111100000000000000000000000000000000000000000) >> 41; - int32_t mmmmmmmmm = - (data & 0b0000000000000000000000011111111100000000000000000000000000000000) >> 32; - int32_t ttt = (data & 0b0000000000000000000000000000000000000111000000000000000000000000) >> 24; - int32_t pppp = - (data & 0b0000000000000000000000000000000000000000111100000000000000000000) >> 20; - int32_t cc = (data & 0b0000000000000000000000000000000000000000000011000000000000000000) >> 18; - int32_t aaaa = - (data & 0b0000000000000000000000000000000000000000000000111100000000000000) >> 14; - int32_t ssss = - (data & 0b0000000000000000000000000000000000000000000000000011110000000000) >> 10; - int32_t dd = (data & 0b0000000000000000000000000000000000000000000000000000001100000000) >> 8; - int32_t bbbb = (data & 0b0000000000000000000000000000000000000000000000000000000011110000) >> 4; - int32_t uuuu = (data & 0b0000000000000000000000000000000000000000000000000000000000001111); - - const char* fmtTbl[] = {"G_IM_FMT_RGBA", "G_IM_FMT_YUV", "G_IM_FMT_CI", "G_IM_FMT_IA", - "G_IM_FMT_I"}; - const char* sizTbl[] = {"G_IM_SIZ_4b", "G_IM_SIZ_8b", "G_IM_SIZ_16b", "G_IM_SIZ_32b"}; - - if (fff == (int32_t)F3DZEXTexFormats::G_IM_FMT_CI) - lastCISiz = (F3DZEXTexSizes)ii; - - lastTexSizTest = (F3DZEXTexSizes)ii; - - sprintf(line, "gsDPSetTile(%s, %s, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i),", fmtTbl[fff], - sizTbl[ii], nnnnnnnnn, mmmmmmmmm, ttt, pppp, cc, aaaa, ssss, dd, bbbb, uuuu); -} - -void ZDisplayList::Opcode_G_SETTILESIZE(uint64_t data, [[maybe_unused]] const std::string& prefix, - char* line) -{ - int32_t sss = (data & 0x00FFF00000000000) >> 44; - int32_t ttt = (data & 0x00000FFF00000000) >> 32; - int32_t uuu = (data & 0x0000000000FFF000) >> 12; - int32_t vvv = (data & 0x0000000000000FFF); - int32_t i = (data & 0x000000000F000000) >> 24; - - int32_t shiftAmtW = 2; - int32_t shiftAmtH = 2; - - if (lastTexSizTest == F3DZEXTexSizes::G_IM_SIZ_8b && - lastTexFmt == F3DZEXTexFormats::G_IM_FMT_IA) - shiftAmtW = 3; - - // if (lastTexFmt == F3DZEXTexFormats::G_IM_FMT_I || lastTexFmt == - // F3DZEXTexFormats::G_IM_FMT_CI) - if (lastTexSizTest == F3DZEXTexSizes::G_IM_SIZ_4b) - shiftAmtW = 3; - - if (lastTexSizTest == F3DZEXTexSizes::G_IM_SIZ_4b && - lastTexFmt == F3DZEXTexFormats::G_IM_FMT_IA) - shiftAmtH = 3; - - lastTexWidth = (uuu >> shiftAmtW) + 1; - lastTexHeight = (vvv >> shiftAmtH) + 1; - - if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_DEBUG) - printf("lastTexWidth: %i lastTexHeight: %i, lastTexSizTest: 0x%x, lastTexFmt: 0x%x\n", - lastTexWidth, lastTexHeight, (uint32_t)lastTexSizTest, (uint32_t)lastTexFmt); - - if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_DEBUG) - printf("TextureGenCheck G_SETTILESIZE\n"); - - TextureGenCheck(); - - sprintf(line, "gsDPSetTileSize(%i, %i, %i, %i, %i),", i, sss, ttt, uuu, vvv); -} - -void ZDisplayList::Opcode_G_LOADBLOCK(uint64_t data, char* line) -{ - int32_t sss = (data & 0x00FFF00000000000) >> 48; - int32_t ttt = (data & 0x00000FFF00000000) >> 36; - int32_t i = (data & 0x000000000F000000) >> 24; - int32_t xxx = (data & 0x0000000000FFF000) >> 12; - int32_t ddd = (data & 0x0000000000000FFF); - - lastTexLoaded = true; - - sprintf(line, "gsDPLoadBlock(%i, %i, %i, %i, %i),", i, sss, ttt, xxx, ddd); -} - -void ZDisplayList::Opcode_G_SETCOMBINE(uint64_t data, char* line) -{ - int32_t a0 = (data & 0b000000011110000000000000000000000000000000000000000000000000000) >> 52; - int32_t c0 = (data & 0b000000000001111100000000000000000000000000000000000000000000000) >> 47; - int32_t aa0 = (data & 0b00000000000000011100000000000000000000000000000000000000000000) >> 44; - int32_t ac0 = (data & 0b00000000000000000011100000000000000000000000000000000000000000) >> 41; - int32_t a1 = (data & 0b000000000000000000000011110000000000000000000000000000000000000) >> 37; - int32_t c1 = (data & 0b000000000000000000000000001111100000000000000000000000000000000) >> 32; - int32_t b0 = (data & 0b000000000000000000000000000000011110000000000000000000000000000) >> 28; - int32_t b1 = (data & 0b000000000000000000000000000000000001111000000000000000000000000) >> 24; - int32_t aa1 = (data & 0b00000000000000000000000000000000000000111000000000000000000000) >> 21; - int32_t ac1 = (data & 0b00000000000000000000000000000000000000000111000000000000000000) >> 18; - int32_t d0 = (data & 0b000000000000000000000000000000000000000000000111000000000000000) >> 15; - int32_t ab0 = (data & 0b00000000000000000000000000000000000000000000000111000000000000) >> 12; - int32_t ad0 = (data & 0b00000000000000000000000000000000000000000000000000111000000000) >> 9; - int32_t d1 = (data & 0b000000000000000000000000000000000000000000000000000000111000000) >> 6; - int32_t ab1 = (data & 0b00000000000000000000000000000000000000000000000000000000111000) >> 3; - int32_t ad1 = (data & 0b00000000000000000000000000000000000000000000000000000000000111) >> 0; - - const char* modesA[] = {"COMBINED", "TEXEL0", "TEXEL1", "PRIMITIVE", "SHADE", "ENVIRONMENT", - "1", "NOISE", "0", "9", "10", "11", - "12", "13", "14", "0"}; - const char* modesB[] = {"COMBINED", "TEXEL0", "TEXEL1", "PRIMITIVE", "SHADE", "ENVIRONMENT", - "CENTER", "K4", "8", "9", "10", "11", - "12", "13", "14", "0"}; - const char* modesC[] = {"COMBINED", - "TEXEL0", - "TEXEL1", - "PRIMITIVE", - "SHADE", - "ENVIRONMENT", - "1", - "COMBINED_ALPHA", - "TEXEL0_ALPHA", - "TEXEL1_ALPHA", - "PRIMITIVE_ALPHA", - "SHADE_ALPHA", - "ENV_ALPHA", - "LOD_FRACTION", - "PRIM_LOD_FRAC", - "K5", - "16", - "17", - "18", - "19", - "20", - "21", - "22", - "23", - "24", - "25", - "26", - "27", - "28", - "29", - "30", - "0"}; - const char* modesD[] = {"COMBINED", "TEXEL0", "TEXEL1", "PRIMITIVE", - "SHADE", "ENVIRONMENT", "1", "0"}; - - const char* modes2[] = {"COMBINED", "TEXEL0", "TEXEL1", "PRIMITIVE", - "SHADE", "ENVIRONMENT", "1", "0"}; - const char* modes2C[] = {"LOD_FRACTION", "TEXEL0", "TEXEL1", "PRIMITIVE", - "SHADE", "ENVIRONMENT", "PRIM_LOD_FRAC", "0"}; - - sprintf(line, - "gsDPSetCombineLERP(%s, %s, %s, %s, %s, %s, %s, %s,\n %s, %s, " - "%s, %s, %s, %s, %s, %s),", - modesA[a0], modesB[b0], modesC[c0], modesD[d0], modes2[aa0], modes2[ab0], modes2C[ac0], - modes2[ad0], modesA[a1], modesB[b1], modesC[c1], modesD[d1], modes2[aa1], modes2[ab1], - modes2C[ac1], modes2[ad1]); -} - -void ZDisplayList::Opcode_G_SETPRIMCOLOR(uint64_t data, char* line) -{ - int32_t mm = (data & 0x0000FF0000000000) >> 40; - int32_t ff = (data & 0x000000FF00000000) >> 32; - int32_t rr = (data & 0x00000000FF000000) >> 24; - int32_t gg = (data & 0x0000000000FF0000) >> 16; - int32_t bb = (data & 0x000000000000FF00) >> 8; - int32_t aa = (data & 0x00000000000000FF) >> 0; - sprintf(line, "gsDPSetPrimColor(%i, %i, %i, %i, %i, %i),", mm, ff, rr, gg, bb, aa); -} - -void ZDisplayList::Opcode_F3DEX_G_SETOTHERMODE_L(uint64_t data, char* line) -{ - int32_t sft = (data & 0x0000FF0000000000) >> 40; - int32_t len = (data & 0x000000FF00000000) >> 32; - int32_t dat = (data & 0xFFFFFFFF); - - // TODO: Output the correct render modes in data - - sprintf(line, "gsSPSetOtherMode(0xE2, %i, %i, 0x%08X),", sft, len, dat); -} - -void ZDisplayList::Opcode_G_SETOTHERMODE_L(uint64_t data, char* line) -{ - int32_t dd = (data & 0xFFFFFFFF); - int32_t sft = 0; - int32_t len = 0; - - if (dListType == DListType::F3DEX) - { - sft = (data & 0x0000FF0000000000) >> 40; - len = (data & 0x000000FF00000000) >> 32; - } - else - { - int32_t ss = (data & 0x0000FF0000000000) >> 40; - len = ((data & 0x000000FF00000000) >> 32) + 1; - sft = 32 - (len)-ss; - } - - if (sft == G_MDSFT_RENDERMODE) - { - uint32_t mode1 = (dd & 0xCCCC0000) >> 0; - uint32_t mode2 = (dd & 0x3333FFFF); - - // TODO: Jesus Christ This is Messy - - uint32_t tblA[] = {G_RM_FOG_SHADE_A, - G_RM_FOG_PRIM_A, - G_RM_PASS, - G_RM_AA_ZB_OPA_SURF, - G_RM_AA_ZB_XLU_SURF, - G_RM_AA_ZB_OPA_DECAL, - G_RM_AA_ZB_XLU_DECAL, - G_RM_AA_ZB_OPA_INTER, - G_RM_AA_ZB_XLU_INTER, - G_RM_AA_ZB_XLU_LINE, - G_RM_AA_ZB_DEC_LINE, - G_RM_AA_ZB_TEX_EDGE, - G_RM_AA_ZB_TEX_INTER, - G_RM_AA_ZB_SUB_SURF, - G_RM_AA_ZB_PCL_SURF, - G_RM_AA_ZB_OPA_TERR, - G_RM_AA_ZB_TEX_TERR, - G_RM_AA_ZB_SUB_TERR, - G_RM_RA_ZB_OPA_SURF, - G_RM_RA_ZB_OPA_DECAL, - G_RM_RA_ZB_OPA_INTER, - G_RM_AA_OPA_SURF, - G_RM_AA_XLU_SURF, - G_RM_AA_XLU_LINE, - G_RM_AA_DEC_LINE, - G_RM_AA_TEX_EDGE, - G_RM_AA_SUB_SURF, - G_RM_AA_PCL_SURF, - G_RM_AA_OPA_TERR, - G_RM_AA_TEX_TERR, - G_RM_AA_SUB_TERR, - G_RM_RA_OPA_SURF, - G_RM_ZB_OPA_SURF, - G_RM_ZB_XLU_SURF, - G_RM_ZB_OPA_DECAL, - G_RM_ZB_XLU_DECAL, - G_RM_ZB_CLD_SURF, - G_RM_ZB_OVL_SURF, - G_RM_ZB_PCL_SURF, - G_RM_OPA_SURF, - G_RM_XLU_SURF, - G_RM_CLD_SURF, - G_RM_TEX_EDGE, - G_RM_PCL_SURF, - G_RM_ADD, - G_RM_NOOP, - G_RM_VISCVG, - G_RM_OPA_CI}; - - uint32_t tblB[] = {G_RM_AA_ZB_OPA_SURF2, - G_RM_AA_ZB_XLU_SURF2, - G_RM_AA_ZB_OPA_DECAL2, - G_RM_AA_ZB_XLU_DECAL2, - G_RM_AA_ZB_OPA_INTER2, - G_RM_AA_ZB_XLU_INTER2, - G_RM_AA_ZB_XLU_LINE2, - G_RM_AA_ZB_DEC_LINE2, - G_RM_AA_ZB_TEX_EDGE2, - G_RM_AA_ZB_TEX_INTER2, - G_RM_AA_ZB_SUB_SURF2, - G_RM_AA_ZB_PCL_SURF2, - G_RM_AA_ZB_OPA_TERR2, - G_RM_AA_ZB_TEX_TERR2, - G_RM_AA_ZB_SUB_TERR2, - G_RM_RA_ZB_OPA_SURF2, - G_RM_RA_ZB_OPA_DECAL2, - G_RM_RA_ZB_OPA_INTER2, - G_RM_AA_OPA_SURF2, - G_RM_AA_XLU_SURF2, - G_RM_AA_XLU_LINE2, - G_RM_AA_DEC_LINE2, - G_RM_AA_TEX_EDGE2, - G_RM_AA_SUB_SURF2, - G_RM_AA_PCL_SURF2, - G_RM_AA_OPA_TERR2, - G_RM_AA_TEX_TERR2, - G_RM_AA_SUB_TERR2, - G_RM_RA_OPA_SURF2, - G_RM_ZB_OPA_SURF2, - G_RM_ZB_XLU_SURF2, - G_RM_ZB_OPA_DECAL2, - G_RM_ZB_XLU_DECAL2, - G_RM_ZB_CLD_SURF2, - G_RM_ZB_OVL_SURF2, - G_RM_ZB_PCL_SURF2, - G_RM_OPA_SURF2, - G_RM_XLU_SURF2, - G_RM_CLD_SURF2, - G_RM_TEX_EDGE2, - G_RM_PCL_SURF2, - G_RM_ADD2, - G_RM_NOOP2, - G_RM_VISCVG2, - G_RM_OPA_CI2}; - - std::map str = { - {G_RM_FOG_SHADE_A, "G_RM_FOG_SHADE_A"}, - {G_RM_FOG_PRIM_A, "G_RM_FOG_PRIM_A"}, - {G_RM_PASS, "G_RM_PASS"}, - {G_RM_AA_ZB_OPA_SURF, "G_RM_AA_ZB_OPA_SURF"}, - {G_RM_AA_ZB_OPA_SURF2, "G_RM_AA_ZB_OPA_SURF2"}, - {G_RM_AA_ZB_XLU_SURF, "G_RM_AA_ZB_XLU_SURF"}, - {G_RM_AA_ZB_XLU_SURF2, "G_RM_AA_ZB_XLU_SURF2"}, - {G_RM_AA_ZB_OPA_DECAL, "G_RM_AA_ZB_OPA_DECAL"}, - {G_RM_AA_ZB_OPA_DECAL2, "G_RM_AA_ZB_OPA_DECAL2"}, - {G_RM_AA_ZB_XLU_DECAL, "G_RM_AA_ZB_XLU_DECAL"}, - {G_RM_AA_ZB_XLU_DECAL2, "G_RM_AA_ZB_XLU_DECAL2"}, - {G_RM_AA_ZB_OPA_INTER, "G_RM_AA_ZB_OPA_INTER"}, - {G_RM_AA_ZB_OPA_INTER2, "G_RM_AA_ZB_OPA_INTER2"}, - {G_RM_AA_ZB_XLU_INTER, "G_RM_AA_ZB_XLU_INTER"}, - {G_RM_AA_ZB_XLU_INTER2, "G_RM_AA_ZB_XLU_INTER2"}, - {G_RM_AA_ZB_XLU_LINE, "G_RM_AA_ZB_XLU_LINE"}, - {G_RM_AA_ZB_XLU_LINE2, "G_RM_AA_ZB_XLU_LINE2"}, - {G_RM_AA_ZB_DEC_LINE, "G_RM_AA_ZB_DEC_LINE"}, - {G_RM_AA_ZB_DEC_LINE2, "G_RM_AA_ZB_DEC_LINE2"}, - {G_RM_AA_ZB_TEX_EDGE, "G_RM_AA_ZB_TEX_EDGE"}, - {G_RM_AA_ZB_TEX_EDGE2, "G_RM_AA_ZB_TEX_EDGE2"}, - {G_RM_AA_ZB_TEX_INTER, "G_RM_AA_ZB_TEX_INTER"}, - {G_RM_AA_ZB_TEX_INTER2, "G_RM_AA_ZB_TEX_INTER2"}, - {G_RM_AA_ZB_SUB_SURF, "G_RM_AA_ZB_SUB_SURF"}, - {G_RM_AA_ZB_SUB_SURF2, "G_RM_AA_ZB_SUB_SURF2"}, - {G_RM_AA_ZB_PCL_SURF, "G_RM_AA_ZB_PCL_SURF"}, - {G_RM_AA_ZB_PCL_SURF2, "G_RM_AA_ZB_PCL_SURF2"}, - {G_RM_AA_ZB_OPA_TERR, "G_RM_AA_ZB_OPA_TERR"}, - {G_RM_AA_ZB_OPA_TERR2, "G_RM_AA_ZB_OPA_TERR2"}, - {G_RM_AA_ZB_TEX_TERR, "G_RM_AA_ZB_TEX_TERR"}, - {G_RM_AA_ZB_TEX_TERR2, "G_RM_AA_ZB_TEX_TERR2"}, - {G_RM_AA_ZB_SUB_TERR, "G_RM_AA_ZB_SUB_TERR"}, - {G_RM_AA_ZB_SUB_TERR2, "G_RM_AA_ZB_SUB_TERR2"}, - {G_RM_RA_ZB_OPA_SURF, "G_RM_RA_ZB_OPA_SURF"}, - {G_RM_RA_ZB_OPA_SURF2, "G_RM_RA_ZB_OPA_SURF2"}, - {G_RM_RA_ZB_OPA_DECAL, "G_RM_RA_ZB_OPA_DECAL"}, - {G_RM_RA_ZB_OPA_DECAL2, "G_RM_RA_ZB_OPA_DECAL2"}, - {G_RM_RA_ZB_OPA_INTER, "G_RM_RA_ZB_OPA_INTER"}, - {G_RM_RA_ZB_OPA_INTER2, "G_RM_RA_ZB_OPA_INTER2"}, - {G_RM_AA_OPA_SURF, "G_RM_AA_OPA_SURF"}, - {G_RM_AA_OPA_SURF2, "G_RM_AA_OPA_SURF2"}, - {G_RM_AA_XLU_SURF, "G_RM_AA_XLU_SURF"}, - {G_RM_AA_XLU_SURF2, "G_RM_AA_XLU_SURF2"}, - {G_RM_AA_XLU_LINE, "G_RM_AA_XLU_LINE"}, - {G_RM_AA_XLU_LINE2, "G_RM_AA_XLU_LINE2"}, - {G_RM_AA_DEC_LINE, "G_RM_AA_DEC_LINE"}, - {G_RM_AA_DEC_LINE2, "G_RM_AA_DEC_LINE2"}, - {G_RM_AA_TEX_EDGE, "G_RM_AA_TEX_EDGE"}, - {G_RM_AA_TEX_EDGE2, "G_RM_AA_TEX_EDGE2"}, - {G_RM_AA_SUB_SURF, "G_RM_AA_SUB_SURF"}, - {G_RM_AA_SUB_SURF2, "G_RM_AA_SUB_SURF2"}, - {G_RM_AA_PCL_SURF, "G_RM_AA_PCL_SURF"}, - {G_RM_AA_PCL_SURF2, "G_RM_AA_PCL_SURF2"}, - {G_RM_AA_OPA_TERR, "G_RM_AA_OPA_TERR"}, - {G_RM_AA_OPA_TERR2, "G_RM_AA_OPA_TERR2"}, - {G_RM_AA_TEX_TERR, "G_RM_AA_TEX_TERR"}, - {G_RM_AA_TEX_TERR2, "G_RM_AA_TEX_TERR2"}, - {G_RM_AA_TEX_TERR, "G_RM_AA_TEX_TERR"}, - {G_RM_AA_TEX_TERR2, "G_RM_AA_TEX_TERR2"}, - {G_RM_AA_SUB_TERR, "G_RM_AA_SUB_TERR"}, - {G_RM_AA_SUB_TERR2, "G_RM_AA_SUB_TERR2"}, - {G_RM_RA_OPA_SURF, "G_RM_RA_OPA_SURF"}, - {G_RM_RA_OPA_SURF2, "G_RM_RA_OPA_SURF2"}, - {G_RM_ZB_OPA_SURF, "G_RM_ZB_OPA_SURF"}, - {G_RM_ZB_OPA_SURF2, "G_RM_ZB_OPA_SURF2"}, - {G_RM_ZB_XLU_SURF, "G_RM_ZB_XLU_SURF"}, - {G_RM_ZB_XLU_SURF2, "G_RM_ZB_XLU_SURF2"}, - {G_RM_ZB_OPA_DECAL, "G_RM_ZB_OPA_DECAL"}, - {G_RM_ZB_OPA_DECAL2, "G_RM_ZB_OPA_DECAL2"}, - {G_RM_ZB_XLU_DECAL, "G_RM_ZB_XLU_DECAL"}, - {G_RM_ZB_XLU_DECAL2, "G_RM_ZB_XLU_DECAL2"}, - {G_RM_ZB_CLD_SURF, "G_RM_ZB_CLD_SURF"}, - {G_RM_ZB_CLD_SURF2, "G_RM_ZB_CLD_SURF2"}, - {G_RM_ZB_OVL_SURF, "G_RM_ZB_OVL_SURF"}, - {G_RM_ZB_OVL_SURF2, "G_RM_ZB_OVL_SURF2"}, - {G_RM_ZB_PCL_SURF, "G_RM_ZB_PCL_SURF"}, - {G_RM_ZB_PCL_SURF2, "G_RM_ZB_PCL_SURF2"}, - {G_RM_OPA_SURF, "G_RM_OPA_SURF"}, - {G_RM_OPA_SURF2, "G_RM_OPA_SURF2"}, - {G_RM_XLU_SURF, "G_RM_XLU_SURF"}, - {G_RM_XLU_SURF2, "G_RM_XLU_SURF2"}, - {G_RM_CLD_SURF, "G_RM_CLD_SURF"}, - {G_RM_CLD_SURF2, "G_RM_CLD_SURF2"}, - {G_RM_TEX_EDGE, "G_RM_TEX_EDGE"}, - {G_RM_TEX_EDGE2, "G_RM_TEX_EDGE2"}, - {G_RM_PCL_SURF, "G_RM_PCL_SURF"}, - {G_RM_PCL_SURF2, "G_RM_PCL_SURF2"}, - {G_RM_ADD, "G_RM_ADD"}, - {G_RM_ADD2, "G_RM_ADD2"}, - {G_RM_NOOP, "G_RM_NOOP"}, - {G_RM_NOOP2, "G_RM_NOOP2"}, - {G_RM_VISCVG, "G_RM_VISCVG"}, - {G_RM_VISCVG2, "G_RM_VISCVG2"}, - {G_RM_OPA_CI, "G_RM_OPA_CI"}, - {G_RM_OPA_CI2, "G_RM_OPA_CI2"}, - }; - - for (uint32_t k = 0; k < sizeof(tblA) / 4; k++) - { - if ((dd & tblA[k]) == tblA[k]) - { - if (tblA[k] > mode1) - mode1 = tblA[k]; - } - } - - for (uint32_t k = 0; k < sizeof(tblB) / 4; k++) - { - if ((dd & tblB[k]) == tblB[k]) - { - if (tblB[k] > mode2) - mode2 = tblB[k]; - } - } - - std::string mode1Str = str[mode1]; - std::string mode2Str = str[mode2]; - - if (mode1Str == "") - { - mode1Str = StringHelper::Sprintf("0x%08X", mode1); - } - - if (mode2Str == "") - { - if (mode2 & AA_EN) - { - mode2Str += "AA_EN | "; - } - - if (mode2 & Z_CMP) - { - mode2Str += "Z_CMP | "; - } - - if (mode2 & Z_UPD) - { - mode2Str += "Z_UPD | "; - } - - if (mode2 & IM_RD) - { - mode2Str += "IM_RD | "; - } - - if (mode2 & CLR_ON_CVG) - { - mode2Str += "CLR_ON_CVG | "; - } - - if (mode2 & CVG_DST_CLAMP) - { - mode2Str += "CVG_DST_CLAMP | "; - } - - if (mode2 & CVG_DST_WRAP) - { - mode2Str += "CVG_DST_WRAP | "; - } - - if (mode2 & CVG_DST_FULL) - { - mode2Str += "CVG_DST_FULL | "; - } - - if (mode2 & CVG_DST_SAVE) - { - mode2Str += "CVG_DST_SAVE | "; - } - - int32_t zMode = mode2 & 0xC00; - - if (zMode == ZMODE_INTER) - { - mode2Str += "ZMODE_INTER | "; - } - else if (zMode == ZMODE_XLU) - { - mode2Str += "ZMODE_XLU | "; - } - else if (zMode == ZMODE_DEC) - { - mode2Str += "ZMODE_DEC | "; - } - - if (mode2 & CVG_X_ALPHA) - { - mode2Str += "CVG_X_ALPHA | "; - } - - if (mode2 & ALPHA_CVG_SEL) - { - mode2Str += "ALPHA_CVG_SEL | "; - } - - if (mode2 & FORCE_BL) - { - mode2Str += "FORCE_BL | "; - } - - int32_t bp = (mode2 >> 28) & 0b11; - int32_t ba = (mode2 >> 24) & 0b11; - int32_t bm = (mode2 >> 20) & 0b11; - int32_t bb = (mode2 >> 16) & 0b11; - - mode2Str += StringHelper::Sprintf("GBL_c2(%i, %i, %i, %i)", bp, ba, bm, bb); - // mode2Str = StringHelper::Sprintf("0x%08X", mode2); - } - - sprintf(line, "gsDPSetRenderMode(%s, %s),", mode1Str.c_str(), mode2Str.c_str()); - } - else - { - sprintf(line, "gsSPSetOtherMode(0xE2, %i, %i, 0x%08X),", sft, len, dd); - } -} - -void ZDisplayList::Opcode_G_SETOTHERMODE_H(uint64_t data, char* line) -{ - int32_t ss = (data & 0x0000FF0000000000) >> 40; - int32_t nn = (data & 0x000000FF00000000) >> 32; - int32_t dd = (data & 0xFFFFFFFF); - - int32_t sft = 32 - (nn + 1) - ss; - - if (sft == 14) // G_MDSFT_TEXTLUT - { - const char* types[] = {"G_TT_NONE", "G_TT_NONE", "G_TT_RGBA16", "G_TT_IA16"}; - sprintf(line, "gsDPSetTextureLUT(%s),", types[dd >> 14]); - } - else - sprintf(line, "gsSPSetOtherMode(0xE3, %i, %i, 0x%08X),", sft, nn + 1, dd); -} - -void ZDisplayList::Opcode_G_LOADTLUT(uint64_t data, [[maybe_unused]] const std::string& prefix, - char* line) -{ - int32_t t = (data & 0x0000000007000000) >> 24; - int32_t ccc = (data & 0x00000000003FF000) >> 14; - - lastTexWidth = sqrt(ccc + 1); - lastTexHeight = sqrt(ccc + 1); - - lastTexLoaded = true; - lastTexIsPalette = true; - - if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_DEBUG) - printf("TextureGenCheck G_LOADTLUT (lastCISiz: %i)\n", (uint32_t)lastCISiz); - - TextureGenCheck(); - - sprintf(line, "gsDPLoadTLUTCmd(%i, %i),", t, ccc); -} - -void ZDisplayList::Opcode_G_ENDDL([[maybe_unused]] const std::string& prefix, char* line) -{ - sprintf(line, "gsSPEndDisplayList(),"); - - if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_DEBUG) - printf("TextureGenCheck G_ENDDL\n"); - - TextureGenCheck(); -} - -static int32_t GfxdCallback_FormatSingleEntry() -{ - ZDisplayList* self = static_cast(gfxd_udata_get()); - gfxd_puts("\t"); - gfxd_macro_dflt(); - gfxd_puts(","); - - auto macroId = gfxd_macro_id(); - - switch (macroId) - { - case gfxd_SP1Triangle: - case gfxd_SP2Triangles: - if (self->lastTexture != nullptr && self->lastTexture->IsColorIndexed() && - !self->lastTexture->HasTlut()) - { - auto tex = self->lastTexture; - auto tlut = self->lastTlut; - - if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_DEBUG) - { - if (tlut != nullptr) - printf("CI texture '%s' (0x%X), TLUT: '%s' (0x%X)\n", tex->GetName().c_str(), - tex->GetRawDataIndex(), tlut->GetName().c_str(), - tlut->GetRawDataIndex()); - else - printf("CI texture '%s' (0x%X), TLUT: null\n", tex->GetName().c_str(), - tex->GetRawDataIndex()); - } - - if (tlut != nullptr && !tex->HasTlut()) - tex->SetTlut(tlut); - } - break; - } - - // dont print a new line after the last command - switch (macroId) - { - case gfxd_SPEndDisplayList: - case gfxd_SPBranchList: - break; - - default: - gfxd_puts("\n"); - break; - } - - return 0; -} - -static int32_t GfxdCallback_Vtx(uint32_t seg, int32_t count) -{ - ZDisplayList* self = static_cast(gfxd_udata_get()); - uint32_t vtxOffset = Seg2Filespace(seg, self->parent->baseAddress); - - if (GETSEGNUM(seg) == self->parent->segment) - { - Declaration* decl; - - // Check for vertex intersections from other display lists - // TODO: These two could probably be condenced to one... - decl = self->parent->GetDeclarationRanged(vtxOffset + (count * 16)); - if (decl != nullptr) - { - int32_t diff = decl->address - vtxOffset; - - if (diff > 0) - count = diff / 16; - else - count = 0; - } - - decl = self->parent->GetDeclarationRanged(vtxOffset); - if (decl != nullptr) - { - int32_t diff = decl->address - vtxOffset; - - if (diff > 0) - count = diff / 16; - else - count = 0; - } - - if (count > 0) - { - std::vector vtxList; - vtxList.reserve(count); - - uint32_t currentPtr = vtxOffset; - for (int32_t i = 0; i < count; i++) - { - ZVtx vtx(self->parent); - vtx.ExtractFromFile(currentPtr); - - vtxList.push_back(vtx); - currentPtr += 16; - } - self->vertices[vtxOffset] = vtxList; - } - } - - self->references.push_back(seg); - - if (!Globals::Instance->otrMode) - gfxd_puts("@r"); - - return 1; -} - -static int32_t GfxdCallback_Texture(segptr_t seg, int32_t fmt, int32_t siz, int32_t width, - int32_t height, [[maybe_unused]] int32_t pal) -{ - ZDisplayList* self = static_cast(gfxd_udata_get()); - uint32_t texOffset = Seg2Filespace(seg, self->parent->baseAddress); - - self->lastTexWidth = width; - self->lastTexHeight = height; - self->lastTexAddr = texOffset; - self->lastTexSeg = seg; - self->lastTexFmt = static_cast(fmt); - self->lastTexSiz = static_cast(siz); - self->lastTexLoaded = true; - self->lastTexIsPalette = false; - - self->TextureGenCheck(); - - std::string texName; - Globals::Instance->GetSegmentedPtrName(seg, self->parent, "", texName, self->parent->workerID); - - gfxd_puts(texName.c_str()); - - return 1; -} - -static int32_t GfxdCallback_Palette(uint32_t seg, [[maybe_unused]] int32_t idx, int32_t count) -{ - ZDisplayList* self = static_cast(gfxd_udata_get()); - uint32_t palOffset = Seg2Filespace(seg, self->parent->baseAddress); - - self->lastTexWidth = sqrt(count); - self->lastTexHeight = sqrt(count); - self->lastTexAddr = palOffset; - self->lastTexSeg = seg; - self->lastTexSiz = F3DZEXTexSizes::G_IM_SIZ_16b; - self->lastTexFmt = F3DZEXTexFormats::G_IM_FMT_RGBA; - self->lastTexLoaded = true; - self->lastTexIsPalette = true; - - self->TextureGenCheck(); - - std::string palName; - Globals::Instance->GetSegmentedPtrName(seg, self->parent, "", palName, self->parent->workerID); - - gfxd_puts(palName.c_str()); - - return 1; -} - -static int32_t GfxdCallback_DisplayList(uint32_t seg) -{ - ZDisplayList* self = static_cast(gfxd_udata_get()); - uint32_t dListOffset = GETSEGOFFSET(seg); - uint32_t dListSegNum = GETSEGNUM(seg); - - std::string dListName = ""; - bool addressFound = Globals::Instance->GetSegmentedPtrName(seg, self->parent, "Gfx", dListName, - self->parent->workerID); - - if (!addressFound && self->parent->segment == dListSegNum) - { - ZDisplayList* newDList = new ZDisplayList(self->parent); - newDList->ExtractFromBinary( - dListOffset, - self->GetDListLength(self->parent->GetRawData(), dListOffset, self->dListType)); - newDList->SetName(newDList->GetDefaultName(self->parent->GetName())); - self->otherDLists.push_back(newDList); - dListName = newDList->GetName(); - } - - gfxd_puts(dListName.c_str()); - - return 1; -} - -static int32_t GfxdCallback_Matrix(uint32_t seg) -{ - std::string mtxName; - ZDisplayList* self = static_cast(gfxd_udata_get()); - - bool addressFound = Globals::Instance->GetSegmentedPtrName(seg, self->parent, "Mtx", mtxName, - self->parent->workerID); - if (!addressFound && GETSEGNUM(seg) == self->parent->segment) - { - Declaration* decl = - self->parent->GetDeclaration(Seg2Filespace(seg, self->parent->baseAddress)); - if (decl == nullptr) - { - ZMtx* mtx = new ZMtx(self->parent); - mtx->SetName(mtx->GetDefaultName(self->GetName())); - mtx->ExtractFromFile(Seg2Filespace(seg, self->parent->baseAddress)); - mtx->DeclareVar(self->GetName(), ""); - - mtx->GetSourceOutputCode(self->GetName()); - self->mtxList.push_back(*mtx); - self->parent->resources.push_back(mtx); - mtxName = "&" + mtx->GetName(); - } - } - - gfxd_puts(mtxName.c_str()); - - return 1; -} - -void ZDisplayList::DeclareReferences(const std::string& prefix) -{ - std::string sourceOutput; - - if (Globals::Instance->useLegacyZDList) - sourceOutput += ProcessLegacy(prefix); - else - sourceOutput += ProcessGfxDis(prefix); - - // Iterate through our vertex lists, connect intersecting lists. - if (vertices.size() > 0) - { - std::vector>> verticesSorted(vertices.begin(), - vertices.end()); - - for (size_t i = 0; i < verticesSorted.size() - 1; i++) - { - size_t vtxSize = vertices[verticesSorted[i].first].size() * 16; - - if ((verticesSorted[i].first + vtxSize) > verticesSorted[i + 1].first) - { - int32_t intersectAmt = - (verticesSorted[i].first + vtxSize) - verticesSorted[i + 1].first; - int32_t intersectIndex = intersectAmt / 16; - - for (size_t j = intersectIndex; j < verticesSorted[i + 1].second.size(); j++) - vertices[verticesSorted[i].first].push_back(verticesSorted[i + 1].second[j]); - - vertices.erase(verticesSorted[i + 1].first); - verticesSorted.erase(verticesSorted.begin() + i + 1); - - i--; - } - } - - // Generate Vertex Declarations - for (auto& item : vertices) - { - std::string declaration = ""; - - offset_t curAddr = item.first; - auto& firstVtx = item.second.at(0); - - for (auto vtx : item.second) - declaration += StringHelper::Sprintf("\t%s,\n", vtx.GetBodySourceCode().c_str()); - - Declaration* decl = parent->AddDeclarationArray( - curAddr, firstVtx.GetDeclarationAlignment(), - item.second.size() * firstVtx.GetRawDataSize(), firstVtx.GetSourceTypeName(), - firstVtx.GetDefaultName(name), item.second.size(), declaration); - - /*for (auto vtx : item.second) - { - ZVtx* nVtx = new ZVtx(vtx.parent); - nVtx->x = vtx.x; - nVtx->y = vtx.y; - nVtx->z = vtx.z; - nVtx->flag = vtx.flag; - nVtx->s = vtx.s; - nVtx->t = vtx.t; - nVtx->r = vtx.r; - nVtx->g = vtx.g; - nVtx->b = vtx.b; - nVtx->a = vtx.a; - decl->vertexHack.push_back(nVtx); - }*/ - - decl->isExternal = true; - } - } - - Declaration* decl = DeclareVar("", sourceOutput); - decl->references = references; - - // Iterate through our vertex lists, connect intersecting lists. - if (vertices.size() > 0) - { - std::vector>> verticesSorted(vertices.begin(), - vertices.end()); - - for (size_t i = 0; i < verticesSorted.size() - 1; i++) - { - // int32_t vtxSize = verticesSorted[i].second.size() * 16; - size_t vtxSize = vertices[verticesSorted[i].first].size() * 16; - - if ((verticesSorted[i].first + vtxSize) > verticesSorted[i + 1].first) - { - int32_t intersectAmt = - (verticesSorted[i].first + vtxSize) - verticesSorted[i + 1].first; - int32_t intersectIndex = intersectAmt / 16; - - for (size_t j = intersectIndex; j < verticesSorted[i + 1].second.size(); j++) - vertices[verticesSorted[i].first].push_back(verticesSorted[i + 1].second[j]); - - vertices.erase(verticesSorted[i + 1].first); - verticesSorted.erase(verticesSorted.begin() + i + 1); - - i--; - } - } - - // Generate Vertex Declarations - std::vector vtxKeys; - vtxKeys.reserve(vertices.size()); - for (auto& item : vertices) - vtxKeys.push_back(item.first); - - // for (pair> item : vertices) - for (size_t i = 0; i < vtxKeys.size(); i++) - { - auto& item = vertices[vtxKeys[i]]; - - //std::string declaration; - - //for (auto& vtx : item) - //declaration += StringHelper::Sprintf("\t%s,\n", vtx.GetBodySourceCode().c_str()); - - // Ensure there's always a trailing line feed to prevent dumb warnings. - // Please don't remove this line, unless you somehow made a way to prevent - // that warning when building the OoT repo. - //declaration += "\n"; - - if (parent != nullptr) - { - std::string vtxName; - ZResource* vtxRes = parent->FindResource(vtxKeys[i]); - - if (vtxRes != nullptr) - vtxName = vtxRes->GetName(); - else - vtxName = StringHelper::Sprintf("%sVtx_%06X", prefix.c_str(), vtxKeys[i]); - - auto filepath = Globals::Instance->outputPath / vtxName; - std::string incStr = StringHelper::Sprintf("%s.%s.inc", filepath.string().c_str(), "vtx"); - - Declaration* vtxDecl = parent->AddDeclarationIncludeArray( - vtxKeys[i], incStr, item.size() * 16, "Vtx", vtxName, item.size()); - vtxDecl->isExternal = true; - } - } - } -} - -std::string ZDisplayList::ProcessLegacy(const std::string& prefix) -{ - char line[4096]; - std::string sourceOutput; - - for (size_t i = 0; i < instructions.size(); i++) - { - uint8_t opcode = (uint8_t)(instructions[i] >> 56); - uint64_t data = instructions[i]; - sourceOutput += " "; - - auto start = std::chrono::steady_clock::now(); - - int32_t optimizationResult = OptimizationChecks(i, sourceOutput, prefix); - - if (optimizationResult != -1) - { - i += optimizationResult - 1; - line[0] = '\0'; - } - else - { - if (dListType == DListType::F3DZEX) - ParseF3DZEX((F3DZEXOpcode)opcode, data, i, prefix, line); - else - ParseF3DEX((F3DEXOpcode)opcode, data, prefix, line); - } - - auto end = std::chrono::steady_clock::now(); - int64_t diff = std::chrono::duration_cast(end - start).count(); - - if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_DEBUG && diff > 5) - printf("F3DOP: 0x%02X, TIME: %" PRIi64 "ms\n", opcode, diff); - - sourceOutput += line; - - if (i < instructions.size() - 1) - sourceOutput += "\n"; - } - - return sourceOutput; -} - -std::string ZDisplayList::ProcessGfxDis([[maybe_unused]] const std::string& prefix) -{ - std::string sourceOutput; - - OutputFormatter outputformatter; - int32_t dListSize = instructions.size() * sizeof(instructions[0]); - - gfxd_input_buffer(instructions.data(), dListSize); - gfxd_endian(gfxd_endian_little, sizeof(uint64_t)); // tell gfxdis what format the data is - - gfxd_macro_fn(GfxdCallback_FormatSingleEntry); // format for each command entry - gfxd_vtx_callback(GfxdCallback_Vtx); // handle vertices - gfxd_timg_callback(GfxdCallback_Texture); // handle textures - gfxd_tlut_callback(GfxdCallback_Palette); // handle palettes - gfxd_dl_callback(GfxdCallback_DisplayList); // handle child display lists - gfxd_mtx_callback(GfxdCallback_Matrix); // handle matrices - gfxd_output_callback( - outputformatter.StaticWriter()); // convert tabs to 4 spaces and enforce 120 line limit - - gfxd_enable(gfxd_emit_dec_color); // use decimal for colors - - // set microcode. see gfxd.h for more options. - if (dListType == DListType::F3DZEX) - gfxd_target(gfxd_f3dex2); - else - gfxd_target(gfxd_f3dex); - - gfxd_udata_set(this); - gfxd_execute(); // generate display list - sourceOutput += outputformatter.GetOutput(); // write formatted display list - - return sourceOutput; -} - -void ZDisplayList::TextureGenCheck() -{ - if (TextureGenCheck(lastTexWidth, lastTexHeight, lastTexAddr, lastTexSeg, lastTexFmt, - lastTexSiz, lastTexLoaded, lastTexIsPalette, this)) - { - lastTexAddr = 0; - lastTexLoaded = false; - lastTexIsPalette = false; - } -} - -bool ZDisplayList::TextureGenCheck(int32_t texWidth, int32_t texHeight, uint32_t texAddr, - uint32_t texSeg, F3DZEXTexFormats texFmt, F3DZEXTexSizes texSiz, - bool texLoaded, bool texIsPalette, ZDisplayList* self) -{ - uint32_t segmentNumber = GETSEGNUM(texSeg); - - if (!texIsPalette) - self->lastTexture = nullptr; - else - self->lastTlut = nullptr; - - if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_DEBUG) - printf("TextureGenCheck seg=%i width=%i height=%i ispal=%i addr=0x%06X\n", segmentNumber, - texWidth, texHeight, texIsPalette, texAddr); - - if ((texSeg != 0 || texAddr != 0) && texWidth > 0 && texHeight > 0 && texLoaded && - Globals::Instance->HasSegment(segmentNumber, self->parent->workerID)) - { - ZFile* auxParent = nullptr; - if (segmentNumber == self->parent->segment) - { - auxParent = self->parent; - } - else - { - // Try to find a non-external file (i.e., one we are actually extracting) - // which has the same segment number we are looking for. - auto segs = Globals::Instance->GetSegmentRefFiles(self->parent->workerID); - for (auto& otherFile : segs[segmentNumber]) - { - if (!otherFile->isExternalFile) - { - auxParent = otherFile; - } - } - } - - if (auxParent == nullptr) - { - // We can't declare the texture in any of the files we are extracting. - return false; - } - - if (auxParent->IsOffsetInFileRange(texAddr)) - { - ZTexture* tex = auxParent->GetTextureResource(texAddr); - if (tex != nullptr) - tex->isPalette = texIsPalette; - else - { - tex = new ZTexture(auxParent); - tex->ExtractFromBinary(texAddr, texWidth, texHeight, - TexFormatToTexType(texFmt, texSiz), texIsPalette); - auxParent->AddTextureResource(texAddr, tex); - } - - if (!texIsPalette) - self->lastTexture = tex; - else - self->lastTlut = tex; - - if (auxParent->GetDeclaration(texAddr) == nullptr) - { - tex->DeclareVar(self->GetName(), ""); - } - - return true; - } - } - - return false; -} - -TextureType ZDisplayList::TexFormatToTexType(F3DZEXTexFormats fmt, F3DZEXTexSizes siz) -{ - if (fmt == F3DZEXTexFormats::G_IM_FMT_RGBA) - { - if (siz == F3DZEXTexSizes::G_IM_SIZ_16b) - return TextureType::RGBA16bpp; - else if (siz == F3DZEXTexSizes::G_IM_SIZ_32b) - return TextureType::RGBA32bpp; - } - else if (fmt == F3DZEXTexFormats::G_IM_FMT_CI) - { - if (Globals::Instance->useLegacyZDList) - return TextureType::Palette8bpp; - else - { - if (siz == F3DZEXTexSizes::G_IM_SIZ_4b) - return TextureType::Palette4bpp; - else if (siz == F3DZEXTexSizes::G_IM_SIZ_8b) - return TextureType::Palette8bpp; - } - } - else if (fmt == F3DZEXTexFormats::G_IM_FMT_IA) - { - if (siz == F3DZEXTexSizes::G_IM_SIZ_4b) - return TextureType::GrayscaleAlpha4bpp; - else if (siz == F3DZEXTexSizes::G_IM_SIZ_8b) - return TextureType::GrayscaleAlpha8bpp; - else if (siz == F3DZEXTexSizes::G_IM_SIZ_16b) - return TextureType::GrayscaleAlpha16bpp; - } - else if (fmt == F3DZEXTexFormats::G_IM_FMT_I) - { - if (siz == F3DZEXTexSizes::G_IM_SIZ_4b) - return TextureType::Grayscale4bpp; - else if (siz == F3DZEXTexSizes::G_IM_SIZ_8b) - return TextureType::Grayscale8bpp; - else if (siz == F3DZEXTexSizes::G_IM_SIZ_16b) - return TextureType::Grayscale8bpp; - } - - return TextureType::RGBA16bpp; -} - -bool ZDisplayList::IsExternalResource() const -{ - return false; -} - -std::string ZDisplayList::GetExternalExtension() const -{ - return "dlist"; -} - -std::string ZDisplayList::GetSourceTypeName() const -{ - return "Gfx"; -} - -ZResourceType ZDisplayList::GetResourceType() const -{ - return ZResourceType::DisplayList; -} - -size_t ZDisplayList::GetRawDataSize() const -{ - return instructions.size() * 8; -} - -DeclarationAlignment ZDisplayList::GetDeclarationAlignment() const -{ - return DeclarationAlignment::Align8; -} diff --git a/ZAPDTR/ZAPD/ZDisplayList.h b/ZAPDTR/ZAPD/ZDisplayList.h deleted file mode 100644 index f3828cc79..000000000 --- a/ZAPDTR/ZAPD/ZDisplayList.h +++ /dev/null @@ -1,262 +0,0 @@ -#pragma once - -#include "ZMtx.h" -#include "ZResource.h" -#include "ZRoom/ZRoom.h" -#include "ZTexture.h" -#include "ZVtx.h" -#include "tinyxml2.h" - -#include -#include -#include - -enum class F3DEXOpcode -{ - G_SPNOOP = 0x00, - G_MTX = 0x01, - G_MOVEMEM = 0x03, - G_VTX = 0x04, - G_DL = 0x06, - G_LOAD_UCODE = 0xAF, - G_BRANCH_Z = 0xB0, - G_TRI2 = 0xB1, - G_MODIFYVTX = 0xB2, - G_RDPHALF_2 = 0xB3, - G_RDPHALF_1 = 0xB4, - G_QUAD = 0xB5, - G_CLEARGEOMETRYMODE = 0xB6, - G_SETGEOMETRYMODE = 0xB7, - G_ENDDL = 0xB8, - G_SETOTHERMODE_L = 0xB9, - G_SETOTHERMODE_H = 0xBA, - G_TEXTURE = 0xBB, - G_MOVEWORD = 0xBC, - G_POPMTX = 0xBD, - G_CULLDL = 0xBE, - G_TRI1 = 0xBF, - G_NOOP = 0xC0, - G_TEXRECT = 0xE4, - G_TEXRECTFLIP = 0xE5, - G_RDPLOADSYNC = 0xE6, - G_RDPPIPESYNC = 0xE7, - G_RDPTILESYNC = 0xE8, - G_RDPFULLSYNC = 0xE9, - G_SETKEYGB = 0xEA, - G_SETKEYR = 0xEB, - G_SETCONVERT = 0xEC, - G_SETSCISSOR = 0xED, - G_SETPRIMDEPTH = 0xEE, - G_RDPSETOTHERMODE = 0xEF, - G_LOADTLUT = 0xF0, - G_SETTILESIZE = 0xF2, - G_LOADBLOCK = 0xF3, - G_LOADTILE = 0xF4, - G_SETTILE = 0xF5, - G_FILLRECT = 0xF6, - G_SETFILLCOLOR = 0xF7, - G_SETFOGCOLOR = 0xF8, - G_SETBLENDCOLOR = 0xF9, - G_SETPRIMCOLOR = 0xFA, - G_SETENVCOLOR = 0xFB, - G_SETCOMBINE = 0xFC, - G_SETTIMG = 0xFD, - G_SETZIMG = 0xFE, - G_SETCIMG = 0xFF -}; - -enum class F3DZEXOpcode -{ - G_NOOP = 0x00, - G_VTX = 0x01, - G_MODIFYVTX = 0x02, - G_CULLDL = 0x03, - G_BRANCH_Z = 0x04, - G_TRI1 = 0x05, - G_TRI2 = 0x06, - G_QUAD = 0x07, - G_SPECIAL_3 = 0xD3, - G_SPECIAL_2 = 0xD4, - G_SPECIAL_1 = 0xD5, - G_DMA_IO = 0xD6, - G_TEXTURE = 0xD7, - G_POPMTX = 0xD8, - G_GEOMETRYMODE = 0xD9, - G_MTX = 0xDA, - G_MOVEWORD = 0xDB, - G_MOVEMEM = 0xDC, - G_LOAD_UCODE = 0xDD, - G_DL = 0xDE, - G_ENDDL = 0xDF, - G_SPNOOP = 0xE0, - G_RDPHALF_1 = 0xE1, - G_SETOTHERMODE_L = 0xE2, - G_SETOTHERMODE_H = 0xE3, - G_TEXRECT = 0xE4, - G_TEXRECTFLIP = 0xE5, - G_RDPLOADSYNC = 0xE6, - G_RDPPIPESYNC = 0xE7, - G_RDPTILESYNC = 0xE8, - G_RDPFULLSYNC = 0xE9, - G_SETKEYGB = 0xEA, - G_SETKEYR = 0xEB, - G_SETCONVERT = 0xEC, - G_SETSCISSOR = 0xED, - G_SETPRIMDEPTH = 0xEE, - G_RDPSETOTHERMODE = 0xEF, - G_LOADTLUT = 0xF0, - G_RDPHALF_2 = 0xF1, - G_SETTILESIZE = 0xF2, - G_LOADBLOCK = 0xF3, - G_LOADTILE = 0xF4, - G_SETTILE = 0xF5, - G_FILLRECT = 0xF6, - G_SETFILLCOLOR = 0xF7, - G_SETFOGCOLOR = 0xF8, - G_SETBLENDCOLOR = 0xF9, - G_SETPRIMCOLOR = 0xFA, - G_SETENVCOLOR = 0xFB, - G_SETCOMBINE = 0xFC, - G_SETTIMG = 0xFD, - G_SETZIMG = 0xFE, - G_SETCIMG = 0xFF, -}; - -enum class F3DZEXTexFormats -{ - G_IM_FMT_RGBA, - G_IM_FMT_YUV, - G_IM_FMT_CI, - G_IM_FMT_IA, - G_IM_FMT_I -}; - -enum class F3DZEXTexSizes -{ - G_IM_SIZ_4b, - G_IM_SIZ_8b, - G_IM_SIZ_16b, - G_IM_SIZ_32b -}; - -enum class DListType -{ - F3DZEX, - F3DEX, -}; - -enum class OoTSegments -{ - DirectReference = 0, - TitleStatic = 1, - Scene = 2, - Room = 3, - GameplayKeep = 4, - FieldDungeonKeep = 5, - Object = 6, - LinkAnimation = 7, - IconItemStatic = 8, - IconItem24Static = 9, - Unknown10 = 10, - Unknown11 = 11, - Unknown12 = 12, - IconFieldDungeonStatic = 13, - IconItemLanguageStatic = 14, - ZBuffer = 15, - FrameBuffer = 16, -}; - - -class ZDisplayList : public ZResource -{ -protected: - static TextureType TexFormatToTexType(F3DZEXTexFormats fmt, F3DZEXTexSizes siz); - - void ParseF3DZEX(F3DZEXOpcode opcode, uint64_t data, int32_t i, const std::string& prefix, - char* line); - void ParseF3DEX(F3DEXOpcode opcode, uint64_t data, const std::string& prefix, char* line); - - // Various Instruction Optimizations - bool SequenceCheck(std::vector sequence, int32_t startIndex); - int32_t OptimizationChecks(int32_t startIndex, std::string& output, const std::string& prefix); - int32_t OptimizationCheck_LoadTextureBlock(int32_t startIndex, std::string& output, - const std::string& prefix); - // int32_t OptimizationCheck_LoadMultiBlock(int32_t startIndex, std::string& output, std::string - // prefix); - - // F3DEX Specific Opcode Values - void Opcode_F3DEX_G_SETOTHERMODE_L(uint64_t data, char* line); - - // Shared Opcodes between F3DZEX and F3DEX - void Opcode_G_DL(uint64_t data, const std::string& prefix, char* line); - void Opcode_G_MODIFYVTX(uint64_t data, char* line); - void Opcode_G_CULLDL(uint64_t data, char* line); - void Opcode_G_TRI1(uint64_t data, char* line); - void Opcode_G_TRI2(uint64_t data, char* line); - void Opcode_G_MTX(uint64_t data, char* line); - void Opcode_G_VTX(uint64_t data, char* line); - void Opcode_G_TEXTURE(uint64_t data, char* line); - void Opcode_G_SETTIMG(uint64_t data, const std::string& prefix, char* line); - void Opcode_G_SETTILE(uint64_t data, char* line); - void Opcode_G_SETTILESIZE(uint64_t data, const std::string& prefix, char* line); - void Opcode_G_LOADBLOCK(uint64_t data, char* line); - void Opcode_G_SETCOMBINE(uint64_t data, char* line); - void Opcode_G_SETPRIMCOLOR(uint64_t data, char* line); - void Opcode_G_SETOTHERMODE_L(uint64_t data, char* line); - void Opcode_G_SETOTHERMODE_H(uint64_t data, char* line); - void Opcode_G_LOADTLUT(uint64_t data, const std::string& prefix, char* line); - void Opcode_G_ENDDL(const std::string& prefix, char* line); - -public: - std::vector instructions; - - int32_t lastTexWidth, lastTexHeight, lastTexAddr, lastTexSeg; - F3DZEXTexFormats lastTexFmt; - F3DZEXTexSizes lastTexSiz, lastTexSizTest, lastCISiz; - bool lastTexLoaded; - bool lastTexIsPalette; - - DListType dListType; - - std::map> vertices; - std::vector otherDLists; - - ZTexture* lastTexture = nullptr; - ZTexture* lastTlut = nullptr; - - std::vector references; - std::vector mtxList; - - ZDisplayList(ZFile* nParent); - ~ZDisplayList(); - - void ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) override; - void ExtractFromBinary(uint32_t nRawDataIndex, int32_t rawDataSize); - - void ParseRawData() override; - - Declaration* DeclareVar(const std::string& prefix, const std::string& bodyStr) override; - std::string GetDefaultName(const std::string& prefix) const override; - - void TextureGenCheck(); - static bool TextureGenCheck(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; - DeclarationAlignment GetDeclarationAlignment() const override; - void DeclareReferences(const std::string& prefix) override; - std::string ProcessLegacy(const std::string& prefix); - std::string ProcessGfxDis(const std::string& prefix); - - bool IsExternalResource() const override; - std::string GetExternalExtension() const override; - std::string GetSourceTypeName() const override; - - ZResourceType GetResourceType() const override; - -protected: - size_t numInstructions; -}; diff --git a/ZAPDTR/ZAPD/ZFile.cpp b/ZAPDTR/ZAPD/ZFile.cpp deleted file mode 100644 index 04032e575..000000000 --- a/ZAPDTR/ZAPD/ZFile.cpp +++ /dev/null @@ -1,1429 +0,0 @@ -#include "ZFile.h" - -#include -#include -#include -#include - -#include "Globals.h" -#include "OutputFormatter.h" -#include "Utils/BinaryWriter.h" -#include "Utils/BitConverter.h" -#include "Utils/Directory.h" -#include -#include "Utils/MemoryStream.h" -#include "Utils/Path.h" -#include "Utils/StringHelper.h" -#include "WarningHandler.h" -#include "ZAnimation.h" -#include "ZArray.h" -#include "ZBackground.h" -#include "ZBlob.h" -#include "ZCollision.h" -#include "ZCutscene.h" -#include "ZDisplayList.h" -#include "ZLimb.h" -#include "ZMtx.h" -#include "ZRoom/ZRoom.h" -#include "ZScalar.h" -#include "ZSkeleton.h" -#include "ZSymbol.h" -#include "ZTexture.h" -#include "ZVector.h" -#include "ZVtx.h" - -ZFile::ZFile() -{ - resources = std::vector(); - basePath = ""; - declarations = std::map(); - defines = ""; - baseAddress = 0; - rangeStart = 0x000000000; - rangeEnd = 0xFFFFFFFF; - workerID = 0; -} - -ZFile::ZFile(const fs::path& nOutPath, const std::string& nName) : ZFile() -{ - name = nName; - outName = nName; - outputPath = nOutPath; -} - -ZFile::ZFile(ZFileMode nMode, tinyxml2::XMLElement* reader, const fs::path& nBasePath, - const fs::path& nOutPath, const std::string& filename, const fs::path& nXmlFilePath, int nWorkerID) - : ZFile() -{ - xmlFilePath = nXmlFilePath; - if (nBasePath == "") - basePath = Directory::GetCurrentDirectory(); - else - basePath = nBasePath; - - if (nOutPath == "") - outputPath = Directory::GetCurrentDirectory(); - else - outputPath = nOutPath; - - mode = nMode; - workerID = nWorkerID; - - ParseXML(reader, filename); - if (mode != ZFileMode::ExternalFile) - DeclareResourceSubReferences(); -} - -ZFile::~ZFile() -{ - for (ZResource* res : resources) - delete res; - - for (auto d : declarations) - delete d.second; - - for (auto sym : symbolResources) - delete sym.second; -} - -void ZFile::ParseXML(tinyxml2::XMLElement* reader, const std::string& filename) -{ - assert(mode != ZFileMode::Invalid); - - if (filename == "") - name = reader->Attribute("Name"); - 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"); - if (reader->Attribute("Game") != nullptr) - { - if (std::string_view(gameStr) == "MM") - Globals::Instance->game = ZGame::MM_RETAIL; - else if (std::string_view(gameStr) == "SW97" || std::string_view(gameStr) == "OOTSW97") - Globals::Instance->game = ZGame::OOT_SW97; - else if (std::string_view(gameStr) == "OOT") - Globals::Instance->game = ZGame::OOT_RETAIL; - else - { - std::string errorHeader = - StringHelper::Sprintf("'Game' type '%s' is not supported.", gameStr); - HANDLE_ERROR_PROCESS(WarningType::InvalidAttributeValue, errorHeader, ""); - } - } - - if (reader->Attribute("BaseAddress") != nullptr) - baseAddress = StringHelper::StrToL(reader->Attribute("BaseAddress"), 16); - - if (reader->Attribute("RangeStart") != nullptr) - rangeStart = StringHelper::StrToL(reader->Attribute("RangeStart"), 16); - - if (reader->Attribute("RangeEnd") != nullptr) - rangeEnd = StringHelper::StrToL(reader->Attribute("RangeEnd"), 16); - - if (reader->Attribute("Compilable") != nullptr) - isCompilable = true; - - if (rangeStart > rangeEnd) - HANDLE_ERROR_PROCESS( - WarningType::Always, - StringHelper::Sprintf("'RangeStart' 0x%06X must be before 'RangeEnd' 0x%06X", - rangeStart, rangeEnd), - ""); - - const char* segmentXml = reader->Attribute("Segment"); - if (segmentXml != nullptr) - { - if (!StringHelper::HasOnlyDigits(segmentXml)) - { - HANDLE_ERROR_PROCESS(WarningType::Always, - StringHelper::Sprintf("error: Invalid segment value '%s': must be " - "a decimal between 0 and 15 inclusive", - segmentXml), - ""); - } - - segment = StringHelper::StrToL(segmentXml, 10); - if (segment > 15) - { - if (segment == 128) - { -#ifdef DEPRECATION_ON - HANDLE_WARNING_PROCESS( - WarningType::Always, "warning: segment 128 is deprecated.", - "Remove 'Segment=\"128\"' from the xml to use virtual addresses\n"); -#endif - } - else - { - HANDLE_ERROR_PROCESS( - WarningType::Always, - StringHelper::Sprintf("error: invalid segment value '%s': must be a decimal " - "number between 0 and 15 inclusive", - segmentXml), - ""); - } - } - } - Globals::Instance->AddSegment(segment, this, workerID); - - if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_INFO) - { - if (segment == 0x80) - { - printf("File '%s' using virtual addresses.\n", GetName().c_str()); - } - else - { - printf("File '%s' using segment %X.\n", GetName().c_str(), segment); - } - } - - if (mode == ZFileMode::Extract || mode == ZFileMode::ExternalFile || mode == ZFileMode::ExtractDirectory) - { - if (Globals::Instance->fileMode != ZFileMode::ExtractDirectory) - { - if (!DiskFile::Exists((basePath / name).string())) - { - std::string errorHeader = StringHelper::Sprintf("binary file '%s' does not exist.", - (basePath / name).c_str()); - HANDLE_ERROR_PROCESS(WarningType::Always, errorHeader, ""); - } - } - - if (Globals::Instance->fileMode == ZFileMode::ExtractDirectory) - rawData = Globals::Instance->GetBaseromFile(name); - else - rawData = Globals::Instance->GetBaseromFile((basePath / name).string()); - - if (reader->Attribute("RangeEnd") == nullptr) - rangeEnd = rawData.size(); - } - - std::unordered_set nameSet; - std::unordered_set outNameSet; - std::unordered_set offsetSet; - - auto nodeMap = *GetNodeMap(); - uint32_t rawDataIndex = 0; - - for (tinyxml2::XMLElement* child = reader->FirstChildElement(); child != nullptr; - child = child->NextSiblingElement()) - { - const char* nameXml = child->Attribute("Name"); - const char* outNameXml = child->Attribute("OutName"); - const char* offsetXml = child->Attribute("Offset"); - - // Check for repeated attributes. - if (offsetXml != nullptr) - { - if (!StringHelper::IsValidOffset(std::string_view(offsetXml))) - { - HANDLE_ERROR(WarningType::InvalidXML, - StringHelper::Sprintf("Invalid offset %s entered", offsetXml), ""); - } - rawDataIndex = strtol(offsetXml, NULL, 16); - - if (offsetSet.find(offsetXml) != offsetSet.end()) - { - std::string errorHeader = - StringHelper::Sprintf("repeated 'Offset' attribute: %s", offsetXml); - HANDLE_ERROR_PROCESS(WarningType::InvalidXML, errorHeader, ""); - } - offsetSet.insert(offsetXml); - } - else - { - HANDLE_WARNING_RESOURCE(WarningType::MissingOffsets, this, nullptr, rawDataIndex, - StringHelper::Sprintf("no offset specified for %s.", nameXml), - ""); - } - - if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_INFO) - printf("%s: 0x%06X\n", nameXml, rawDataIndex); - - if (outNameXml != nullptr) - { - if (outNameSet.find(outNameXml) != outNameSet.end()) - { - std::string errorHeader = - StringHelper::Sprintf("repeated 'OutName' attribute: %s", outNameXml); - HANDLE_ERROR_PROCESS(WarningType::InvalidXML, errorHeader, ""); - } - outNameSet.insert(outNameXml); - } - if (nameXml != nullptr) - { - if (nameSet.find(nameXml) != nameSet.end()) - { - std::string errorHeader = - StringHelper::Sprintf("repeated 'Name' attribute: %s", nameXml); - HANDLE_ERROR_PROCESS(WarningType::InvalidXML, errorHeader, ""); - } - nameSet.insert(nameXml); - } - - std::string nodeName = std::string(child->Name()); - - if (nodeMap.find(nodeName) != nodeMap.end()) - { - ZResource* nRes = nodeMap[nodeName](this); - - if (mode == ZFileMode::Extract || mode == ZFileMode::ExternalFile || - mode == ZFileMode::ExtractDirectory) - { - if (!isCompilable) - nRes->ExtractFromXML(child, rawDataIndex); - } - switch (nRes->GetResourceType()) - { - case ZResourceType::Texture: - AddTextureResource(rawDataIndex, static_cast(nRes)); - break; - - case ZResourceType::Symbol: - AddSymbolResource(rawDataIndex, static_cast(nRes)); - break; - - default: - AddResource(nRes); - break; - } - - rawDataIndex += nRes->GetRawDataSize(); - } - else if (std::string_view(child->Name()) == "File") - { - std::string errorHeader = "Can't declare a inside a "; - HANDLE_ERROR_PROCESS(WarningType::InvalidXML, errorHeader, ""); - } - else - { - std::string errorHeader = StringHelper::Sprintf( - "Unknown element found inside a element: %s", nodeName.c_str()); - HANDLE_ERROR_PROCESS(WarningType::InvalidXML, errorHeader, ""); - } - } -} - -void ZFile::DeclareResourceSubReferences() -{ - for (size_t i = 0; i < resources.size(); i++) - { - resources.at(i)->DeclareReferences(name); - } -} - -void ZFile::BuildSourceFile() -{ - if (mode == ZFileMode::ExternalFile) - return; - - if (!Directory::Exists(outputPath)) - Directory::CreateDirectory(outputPath.string()); - - GenerateSourceFiles(); -} - -std::string ZFile::GetName() const -{ - return name; -} - -std::string ZFile::GetOutName() const -{ - return outName.string(); -} - -ZFileMode ZFile::GetMode() const -{ - return mode; -} - -const fs::path& ZFile::GetXmlFilePath() const -{ - return xmlFilePath; -} - -const std::vector& ZFile::GetRawData() const -{ - return rawData; -} - -void ZFile::ExtractResources() -{ - if (mode == ZFileMode::ExternalFile) - return; - - if (!Directory::Exists(outputPath)) - Directory::CreateDirectory(outputPath.string()); - - if (!Directory::Exists(GetSourceOutputFolderPath())) - Directory::CreateDirectory(GetSourceOutputFolderPath().string()); - - for (size_t i = 0; i < resources.size(); i++) - resources[i]->ParseRawDataLate(); - for (size_t i = 0; i < resources.size(); i++) - resources[i]->DeclareReferencesLate(name); - - if (Globals::Instance->genSourceFile) - GenerateSourceFiles(); - - auto memStreamFile = std::shared_ptr(new MemoryStream()); - BinaryWriter writerFile = BinaryWriter(memStreamFile); - - ExporterSet* exporterSet = Globals::Instance->GetExporterSet(); - - if (exporterSet != nullptr && exporterSet->beginFileFunc != nullptr) - exporterSet->beginFileFunc(this); - - int totalMs = 0; - - for (ZResource* res : resources) - { - auto start = std::chrono::steady_clock::now(); - - auto memStreamRes = std::shared_ptr(new MemoryStream()); - BinaryWriter writerRes = BinaryWriter(memStreamRes); - - if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_INFO) - printf("Saving resource %s\n", res->GetName().c_str()); - - res->Save(outputPath); - - // Check if we have an exporter "registered" for this resource type - ZResourceExporter* exporter = Globals::Instance->GetExporter(res->GetResourceType()); - if (exporter != nullptr) - { - // exporter->Save(res, Globals::Instance->outputPath.string(), &writerFile); - exporter->Save(res, Globals::Instance->outputPath.string(), &writerRes); - } - - if (exporterSet != nullptr && exporterSet->resSaveFunc != nullptr) - exporterSet->resSaveFunc(res, writerRes); - - auto end = std::chrono::steady_clock::now(); - auto diff = std::chrono::duration_cast(end - start).count(); - - totalMs += diff; - - //printf("Res %s in %lims\n", res->GetName().c_str(), diff); - } - - //printf("File %s in %lims\n", GetName().c_str(), totalMs); - - if (memStreamFile->GetLength() > 0) - { - DiskFile::WriteAllBytes(StringHelper::Sprintf("%s%s.bin", - Globals::Instance->outputPath.string().c_str(), - GetName().c_str()), - memStreamFile->ToVector()); - } - - writerFile.Close(); - - if (exporterSet != nullptr && exporterSet->endFileFunc != nullptr) - exporterSet->endFileFunc(this); -} - -void ZFile::AddResource(ZResource* res) -{ - resources.push_back(res); -} - -ZResource* ZFile::FindResource(offset_t rawDataIndex) -{ - for (ZResource* res : resources) - { - if (res->GetRawDataIndex() == rawDataIndex) - return res; - } - - return nullptr; -} - -std::vector ZFile::GetResourcesOfType(ZResourceType resType) -{ - std::vector resList; - resList.reserve(resources.size()); - - for (ZResource* res : resources) - { - if (res->GetResourceType() == resType) - resList.push_back(res); - } - - return resList; -} - -Declaration* ZFile::AddDeclaration(offset_t address, DeclarationAlignment alignment, size_t size, - const std::string& varType, const std::string& varName, - const std::string& body) -{ - bool validOffset = AddDeclarationChecks(address, varName); - if (!validOffset) - return nullptr; - - Declaration* decl = GetDeclaration(address); - if (decl == nullptr) - { - decl = new Declaration(address, alignment, size, varType, varName, false, body); - declarations[address] = decl; - } - else - { - decl->alignment = alignment; - decl->size = size; - decl->varType = varType; - decl->varName = varName; - decl->text = body; - } - return decl; -} - -Declaration* ZFile::AddDeclarationArray(offset_t address, DeclarationAlignment alignment, - size_t size, const std::string& varType, - const std::string& varName, size_t arrayItemCnt, - const std::string& body) -{ - bool validOffset = AddDeclarationChecks(address, varName); - if (!validOffset) - return nullptr; - - Declaration* decl = GetDeclaration(address); - if (decl == nullptr) - { - decl = - new Declaration(address, alignment, size, varType, varName, true, arrayItemCnt, body); - declarations[address] = decl; - } - else - { - if (decl->isPlaceholder) - decl->varName = varName; - decl->alignment = alignment; - decl->size = size; - decl->varType = varType; - decl->isArray = true; - decl->arrayItemCnt = arrayItemCnt; - decl->text = body; - } - - return decl; -} - -Declaration* ZFile::AddDeclarationArray(offset_t address, DeclarationAlignment alignment, - size_t size, const std::string& varType, - const std::string& varName, - const std::string& arrayItemCntStr, const std::string& body) -{ - bool validOffset = AddDeclarationChecks(address, varName); - if (!validOffset) - return nullptr; - - Declaration* decl = GetDeclaration(address); - if (decl == nullptr) - { - decl = new Declaration(address, alignment, size, varType, varName, true, arrayItemCntStr, - body); - declarations[address] = decl; - } - else - { - decl->alignment = alignment; - decl->size = size; - decl->varType = varType; - decl->varName = varName; - decl->isArray = true; - decl->arrayItemCntStr = arrayItemCntStr; - decl->text = body; - } - return decl; -} - -Declaration* ZFile::AddDeclarationPlaceholder(offset_t address, const std::string& varName) -{ - bool validOffset = AddDeclarationChecks(address, varName); - if (!validOffset) - return nullptr; - - Declaration* decl; - if (declarations.find(address) == declarations.end()) - { - decl = new Declaration(address, DeclarationAlignment::Align4, 0, "", varName, false, ""); - decl->isPlaceholder = true; - declarations[address] = decl; - } - else - decl = declarations[address]; - - return decl; -} - -Declaration* ZFile::AddDeclarationInclude(offset_t address, const std::string& includePath, - size_t size, const std::string& varType, - const std::string& varName) -{ - bool validOffset = AddDeclarationChecks(address, varName); - if (!validOffset) - return nullptr; - - Declaration* decl = GetDeclaration(address); - if (decl == nullptr) - { - decl = new Declaration(address, includePath, size, varType, varName); - declarations[address] = decl; - } - else - { - decl->includePath = includePath; - decl->size = size; - decl->varType = varType; - decl->varName = varName; - } - return decl; -} - -Declaration* ZFile::AddDeclarationIncludeArray(offset_t address, std::string& includePath, - size_t size, const std::string& varType, - const std::string& varName, size_t arrayItemCnt) -{ - bool validOffset = AddDeclarationChecks(address, varName); - if (!validOffset) - return nullptr; - - if (StringHelper::StartsWith(includePath, "assets/extracted/")) - includePath = "assets/" + StringHelper::Split(includePath, "assets/extracted/")[1]; - if (StringHelper::StartsWith(includePath, "assets/custom/")) - includePath = "assets/" + StringHelper::Split(includePath, "assets/custom/")[1]; - - Declaration* decl = GetDeclaration(address); - if (decl == nullptr) - { - decl = new Declaration(address, includePath, size, varType, varName); - - decl->isArray = true; - decl->arrayItemCnt = arrayItemCnt; - - declarations[address] = decl; - } - else - { - decl->includePath = includePath; - decl->varType = varType; - decl->varName = varName; - decl->size = size; - decl->isArray = true; - decl->arrayItemCnt = arrayItemCnt; - } - return decl; -} - -bool ZFile::AddDeclarationChecks(uint32_t address, const std::string& varName) -{ - assert(GETSEGNUM(address) == 0); - assert(varName != ""); -#ifdef DEVELOPMENT - if (address == 0x0000) - { - [[maybe_unused]] int32_t bp = 0; - } -#endif - - if (!IsOffsetInFileRange(address)) - { - fprintf(stderr, - "%s: Warning in %s\n" - "\t Tried to declare a variable outside of this file's range. Ignoring...\n" - "\t\t Variable's name: %s\n" - "\t\t Variable's offset: 0x%06X\n", - __PRETTY_FUNCTION__, name.c_str(), varName.c_str(), address); - return false; - } - - return true; -} - -bool ZFile::GetDeclarationPtrName(segptr_t segAddress, const std::string& expectedType, - std::string& declName) const -{ - if (segAddress == 0) - { - declName = "NULL"; - return true; - } - - uint32_t offset = Seg2Filespace(segAddress, baseAddress); - Declaration* decl = GetDeclaration(offset); - if (GETSEGNUM(segAddress) != segment || decl == nullptr) - { - declName = StringHelper::Sprintf("0x%08X", segAddress); - return false; - } - - if (expectedType != "" && expectedType != "void*") - { - if (expectedType != decl->varType && "static " + expectedType != decl->varType) - { - declName = StringHelper::Sprintf("0x%08X", segAddress); - return false; - } - } - - if (!decl->isArray) - declName = "&" + decl->varName; - else - declName = decl->varName; - return true; -} - -bool ZFile::GetDeclarationArrayIndexedName(segptr_t segAddress, size_t elementSize, - const std::string& expectedType, - std::string& declName) const -{ - if (segAddress == 0) - { - declName = "NULL"; - return true; - } - - uint32_t address = Seg2Filespace(segAddress, baseAddress); - Declaration* decl = GetDeclarationRanged(address); - if (GETSEGNUM(segAddress) != segment || decl == nullptr || !decl->isArray) - { - declName = StringHelper::Sprintf("0x%08X", segAddress); - return false; - } - - if (expectedType != "" && expectedType != "void*") - { - if (expectedType != decl->varType && "static " + expectedType != decl->varType) - { - declName = StringHelper::Sprintf("0x%08X", segAddress); - return false; - } - } - - if (decl->address == address) - { - declName = decl->varName; - return true; - } - - if ((address - decl->address) % elementSize != 0 || !(address < decl->address + decl->size)) - { - declName = StringHelper::Sprintf("0x%08X", segAddress); - return false; - } - - uint32_t index = (address - decl->address) / elementSize; - declName = StringHelper::Sprintf("&%s[%u]", decl->varName.c_str(), index); - return true; -} - -Declaration* ZFile::GetDeclaration(offset_t address) const -{ - if (declarations.find(address) != declarations.end()) - return declarations.at(address); - - return nullptr; -} - -Declaration* ZFile::GetDeclarationRanged(offset_t address) const -{ - for (const auto decl : declarations) - { - if (address >= decl.first && address < decl.first + decl.second->size) - return decl.second; - } - - return nullptr; -} - -bool ZFile::HasDeclaration(offset_t address) -{ - assert(GETSEGNUM(address) == 0); - return declarations.find(address) != declarations.end(); -} - -void ZFile::GenerateSourceFiles() -{ - std::string sourceOutput; - - sourceOutput += "#include \"ultra64.h\"\n"; - sourceOutput += "#include \"z64.h\"\n"; - sourceOutput += "#include \"macros.h\"\n"; - sourceOutput += GetHeaderInclude(); - - bool hasZRoom = false; - for (const auto& res : resources) - { - ZResourceType resType = res->GetResourceType(); - if (resType == ZResourceType::Room || resType == ZResourceType::Scene || - resType == ZResourceType::AltHeader) - { - hasZRoom = true; - break; - } - } - - if (hasZRoom) - { - sourceOutput += GetZRoomHeaderInclude(); - } - - sourceOutput += GetExternalFileHeaderInclude(); - - GeneratePlaceholderDeclarations(); - - // Generate Code - for (size_t i = 0; i < resources.size(); i++) - { - ZResource* res = resources.at(i); - res->GetSourceOutputCode(name); - } - - sourceOutput += ProcessDeclarations(); - - fs::path outPath = GetSourceOutputFolderPath() / outName.stem().concat(".c"); - - if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_INFO) - printf("Writing C file: %s\n", outPath.c_str()); - - if (!Globals::Instance->otrMode) - { - OutputFormatter formatter; - formatter.Write(sourceOutput); - - DiskFile::WriteAllText(outPath, formatter.GetOutput()); - } - - GenerateSourceHeaderFiles(); -} - -void ZFile::GenerateSourceHeaderFiles() -{ - OutputFormatter formatter; - // Use parent folder and output name as guard as some headers have the same output name - std::string guard = xmlFilePath.parent_path().stem().string() + "_" + outName.stem().string(); - - std::transform(guard.begin(), guard.end(), guard.begin(), ::toupper); - formatter.Write( - StringHelper::Sprintf("#ifndef %s_H\n#define %s_H 1\n\n", guard.c_str(), guard.c_str())); - formatter.Write("#include \"align_asset_macro.h\"\n"); - - std::set nameSet; - for (ZResource* res : resources) - { - std::string resSrc = res->GetSourceOutputHeader("", &nameSet); - if (!resSrc.empty()) - { - formatter.Write(resSrc.front() == '\n' ? resSrc : "\n" + resSrc); - formatter.Write(res == resources.back() ? "" : "\n"); - } - } - - for (auto& sym : symbolResources) - { - formatter.Write("\n\n"); - formatter.Write(sym.second->GetSourceOutputHeader("", &nameSet)); - } - - formatter.Write(ProcessExterns()); - - formatter.Write(StringHelper::Sprintf("\n#endif // %s_H\n", guard.c_str())); - - fs::path headerFilename = GetSourceOutputFolderPath() / outName.stem().concat(".h"); - - if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_INFO) - printf("Writing H file: %s\n", headerFilename.c_str()); - - std::string output = formatter.GetOutput(); - - if (Globals::Instance->fileMode != ZFileMode::ExtractDirectory) - DiskFile::WriteAllText(headerFilename, output); - else if (Globals::Instance->sourceOutputPath != "") - { - std::string xmlPath = xmlFilePath.string(); - xmlPath = StringHelper::Replace(xmlPath, "\\", "/"); - auto pathList = StringHelper::Split(xmlPath, "/"); - std::string outPath = ""; - - for (int i = 0; i < 3; i++) - outPath += pathList[i] + "/"; - - for (int i = 5; i < pathList.size(); i++) - { - if (i == pathList.size() - 1) - { - outPath += Path::GetFileNameWithoutExtension(pathList[i]) + "/"; - outPath += outName.string() + ".h"; - } - else - outPath += pathList[i]; - - if (i < pathList.size() - 1) - outPath += "/"; - } - - DiskFile::WriteAllText(outPath, output); - } -} - -std::string ZFile::GetHeaderInclude() const -{ - std::string headers = StringHelper::Sprintf("#include \"%s.h\"\n", - (outName.parent_path() / outName.stem()).string().c_str()); - - return headers; -} - -std::string ZFile::GetZRoomHeaderInclude() const -{ - std::string headers; - headers += "#include \"segment_symbols.h\"\n"; - headers += "#include \"command_macros_base.h\"\n"; - headers += "#include \"z64cutscene_commands.h\"\n"; - headers += "#include \"variables.h\"\n"; - return headers; -} - -std::string ZFile::GetExternalFileHeaderInclude() const -{ - std::string externalFilesIncludes = ""; - - for (ZFile* externalFile : Globals::Instance->files) - { - if (externalFile != this) - { - fs::path outputFolderPath = externalFile->GetSourceOutputFolderPath(); - if (outputFolderPath == this->GetSourceOutputFolderPath()) - { - outputFolderPath = externalFile->outName.stem(); - } - else - { - outputFolderPath /= externalFile->outName.stem(); - } - - externalFilesIncludes += - StringHelper::Sprintf("#include \"%s.h\"\n", outputFolderPath.string().c_str()); - } - } - - return externalFilesIncludes; -} - -void ZFile::GeneratePlaceholderDeclarations() -{ - // Generate placeholder declarations - for (ZResource* res : resources) - { - if (GetDeclaration(res->GetRawDataIndex()) != nullptr) - { - continue; - } - - Declaration* decl = res->DeclareVar(GetName(), ""); - - if (decl != nullptr) - { - decl->staticConf = res->GetStaticConf(); - if (res->GetResourceType() == ZResourceType::Symbol) - { - decl->staticConf = StaticConfig::Off; - } - } - } -} - -void ZFile::AddTextureResource(uint32_t offset, ZTexture* tex) -{ - for (auto res : resources) - assert(res->GetRawDataIndex() != offset); - - resources.push_back(tex); - texturesResources[offset] = tex; -} - -ZTexture* ZFile::GetTextureResource(uint32_t offset) const -{ - auto tex = texturesResources.find(offset); - if (tex != texturesResources.end()) - return tex->second; - - return nullptr; -} - -void ZFile::AddSymbolResource(uint32_t offset, ZSymbol* sym) -{ - symbolResources[offset] = sym; -} - -ZSymbol* ZFile::GetSymbolResource(uint32_t offset) const -{ - auto sym = symbolResources.find(offset); - if (sym != symbolResources.end()) - return sym->second; - - return nullptr; -} - -ZSymbol* ZFile::GetSymbolResourceRanged(uint32_t offset) const -{ - for (const auto decl : symbolResources) - { - if (offset >= decl.first && offset < decl.first + decl.second->GetRawDataSize()) - return decl.second; - } - - return nullptr; -} - -fs::path ZFile::GetSourceOutputFolderPath() const -{ - return outputPath / outName.parent_path(); -} - -bool ZFile::IsOffsetInFileRange(uint32_t offset) const -{ - if (!(offset < rawData.size())) - return false; - - return rangeStart <= offset && offset < rangeEnd; -} -bool ZFile::IsSegmentedInFilespaceRange(segptr_t segAddress) const -{ - uint8_t segnum = GETSEGNUM(segAddress); - uint32_t offset = Seg2Filespace(segAddress, baseAddress); - - if (segment != segnum) - return false; - - return IsOffsetInFileRange(offset); -} - -std::map* ZFile::GetNodeMap() -{ - static std::map nodeMap; - return &nodeMap; -} - -void ZFile::RegisterNode(std::string nodeName, ZResourceFactoryFunc* nodeFunc) -{ - std::map* nodeMap = GetNodeMap(); - (*nodeMap)[nodeName] = nodeFunc; -} - -std::string ZFile::ProcessDeclarations() -{ - std::string output; - - if (declarations.size() == 0) - return output; - - defines += ProcessTextureIntersections(name); - - // printf("RANGE START: 0x%06X - RANGE END: 0x%06X\n", rangeStart, rangeEnd); - - // Optimization: See if there are any arrays side by side that can be merged... - std::vector> declarationKeys(declarations.begin(), - declarations.end()); - - std::pair lastItem = declarationKeys.at(0); - - for (size_t i = 1; i < declarationKeys.size(); i++) - { - std::pair curItem = declarationKeys[i]; - - if (curItem.second->isArray && lastItem.second->isArray) - { - if (curItem.second->varType == lastItem.second->varType) - { - if (!curItem.second->declaredInXml && !lastItem.second->declaredInXml) - { - // TEST: For now just do Vtx declarations... - if (lastItem.second->varType == "Vtx") - { - int32_t sizeDiff = curItem.first - (lastItem.first + lastItem.second->size); - - // Make sure there isn't an unaccounted inbetween these two - if (sizeDiff == 0) - { - lastItem.second->size += curItem.second->size; - lastItem.second->arrayItemCnt += curItem.second->arrayItemCnt; - lastItem.second->text += "\n" + curItem.second->text; - - for (auto vtx : curItem.second->vertexHack) - lastItem.second->vertexHack.push_back(vtx); - - declarations.erase(curItem.first); - declarationKeys.erase(declarationKeys.begin() + i); - delete curItem.second; - i--; - continue; - } - } - } - } - } - - lastItem = curItem; - } - - for (std::pair item : declarations) - ProcessDeclarationText(item.second); - - for (std::pair item : declarations) - { - while (item.second->size % 4 != 0) - item.second->size++; - } - - HandleUnaccountedData(); - - // Go through include declarations - // First, handle the prototypes (static only for now) - for (std::pair item : declarations) - { - output += item.second->GetStaticForwardDeclarationStr(); - } - - output += "\n"; - - // Next, output the actual declarations - for (const auto& item : declarations) - { - if (!IsOffsetInFileRange(item.first)) - continue; - - if (item.second->includePath != "") - { - if (item.second->isExternal) - { - if (!Globals::Instance->otrMode) - { - // HACK - std::string extType; - - if (item.second->varType == "Gfx") - extType = "dlist"; - else if (item.second->varType == "Vtx") - extType = "vtx"; - - auto filepath = outputPath / item.second->varName; - DiskFile::WriteAllText( - StringHelper::Sprintf("%s.%s.inc", filepath.string().c_str(), extType.c_str()), - item.second->text); - } - } - - output += item.second->GetExternalDeclarationStr(); - } - else if (item.second->varType != "") - { - output += item.second->GetNormalDeclarationStr(); - } - } - - return output; -} - -void ZFile::ProcessDeclarationText(Declaration* decl) -{ - size_t refIndex = 0; - - if (!(decl->references.size() > 0)) - return; - - for (size_t i = 0; i < decl->text.size() - 1; i++) - { - char c = decl->text[i]; - char c2 = decl->text[i + 1]; - - if (c == '@' && c2 == 'r') - { - std::string vtxName; - Globals::Instance->GetSegmentedArrayIndexedName(decl->references[refIndex], 0x10, this, - "Vtx", vtxName, workerID); - decl->text.replace(i, 2, vtxName); - - refIndex++; - - if (refIndex >= decl->references.size()) - break; - } - } -} - -std::string ZFile::ProcessExterns() -{ - std::string output; - - for (const auto& item : declarations) - { - if (!IsOffsetInFileRange(item.first)) - { - continue; - } - - output += item.second->GetExternStr(); - } - - output += "\n"; - - output += defines; - - return output; -} - -std::string ZFile::ProcessTextureIntersections([[maybe_unused]] const std::string& prefix) -{ - if (texturesResources.empty()) - return ""; - - std::string defines; - std::vector> texturesSorted(texturesResources.begin(), - texturesResources.end()); - - for (size_t i = 0; i < texturesSorted.size() - 1; i++) - { - uint32_t currentOffset = texturesSorted[i].first; - uint32_t nextOffset = texturesSorted[i + 1].first; - auto& currentTex = texturesResources.at(currentOffset); - int texSize = currentTex->GetRawDataSize(); - - if (currentTex->WasDeclaredInXml()) - { - // We believe the user is right. - continue; - } - - if ((currentOffset + texSize) > nextOffset) - { - uint32_t offsetDiff = nextOffset - currentOffset; - if (currentTex->isPalette) - { - // Shrink palette so it doesn't overlap - currentTex->SetDimensions(offsetDiff / currentTex->GetPixelMultiplyer(), 1); - - if (declarations.find(currentOffset) != declarations.end()) - declarations.at(currentOffset)->size = currentTex->GetRawDataSize(); - - currentTex->DeclareVar(GetName(), ""); - } - else - { - std::string texName; - std::string texNextName; - GetDeclarationPtrName(currentOffset, "", texName); - - Declaration* nextDecl = GetDeclaration(nextOffset); - if (nextDecl == nullptr) - texNextName = texturesResources.at(nextOffset)->GetName(); - else - texNextName = nextDecl->varName; - -#if 0 - defines += StringHelper::Sprintf("#define %s ((u32)%s + 0x%06X)\n", - texNextName.c_str(), texName.c_str(), offsetDiff); -#endif - - delete declarations[nextOffset]; - declarations.erase(nextOffset); - texturesResources.erase(nextOffset); - texturesSorted.erase(texturesSorted.begin() + i + 1); - - i--; - } - } - } - - return defines; -} - -void ZFile::HandleUnaccountedData() -{ - uint32_t lastAddr = 0; - uint32_t lastSize = 0; - std::vector declsAddresses; - - if (Globals::Instance->otrMode) - return; - - declsAddresses.reserve(declarations.size()); - if (Globals::Instance->otrMode) - return; - - for (const auto& item : declarations) - { - declsAddresses.push_back(item.first); - } - - bool breakLoop = false; - for (offset_t currentAddress : declsAddresses) - { - if (currentAddress >= rangeEnd) - { - breakLoop = true; - break; - } - - if (currentAddress < rangeStart) - { - lastAddr = currentAddress; - continue; - } - - breakLoop = HandleUnaccountedAddress(currentAddress, lastAddr, lastSize); - if (breakLoop) - break; - - lastAddr = currentAddress; - } - - if (!breakLoop) - { - // TODO: change rawData.size() to rangeEnd - // HandleUnaccountedAddress(rangeEnd, lastAddr, lastSize); - HandleUnaccountedAddress(rawData.size(), lastAddr, lastSize); - } -} - -bool ZFile::HandleUnaccountedAddress(offset_t currentAddress, offset_t lastAddr, uint32_t& lastSize) -{ - if (currentAddress != lastAddr && declarations.find(lastAddr) != declarations.end()) - { - Declaration* lastDecl = declarations.at(lastAddr); - lastSize = lastDecl->size; - - if (lastAddr + lastSize > currentAddress) - { - Declaration* currentDecl = declarations.at(currentAddress); - - std::string intersectionInfo = StringHelper::Sprintf( - "Resource from 0x%06X:0x%06X (%s) conflicts with 0x%06X (%s).", lastAddr, - lastAddr + lastSize, lastDecl->varName.c_str(), currentAddress, - currentDecl->varName.c_str()); - HANDLE_WARNING_RESOURCE(WarningType::Intersection, this, nullptr, currentAddress, - "intersection detected", intersectionInfo); - } - } - - uint32_t unaccountedAddress = lastAddr + lastSize; - - if (unaccountedAddress != currentAddress && lastAddr >= rangeStart && - unaccountedAddress < rangeEnd) - { - int diff = currentAddress - unaccountedAddress; - bool nonZeroUnaccounted = false; - - std::string src = " "; - - if (currentAddress > rawData.size()) - { - throw std::runtime_error(StringHelper::Sprintf( - "ZFile::ProcessDeclarations(): Fatal error while processing XML '%s'.\n" - "\t Offset '0x%X' is outside of the limits of file '%s', which has a size of " - "'0x%X'.\n" - "\t Aborting...", - xmlFilePath.c_str(), currentAddress, name.c_str(), rawData.size())); - } - - // Handle Align8 - if (currentAddress % 8 == 0 && diff % 8 != 0) - { - Declaration* currentDecl = GetDeclaration(currentAddress); - - if (currentDecl != nullptr) - { - if (currentDecl->alignment == DeclarationAlignment::Align8) - { - // Check removed bytes are zeroes - if (BitConverter::ToUInt32BE(rawData, unaccountedAddress + diff - 4) == 0) - { - diff -= 4; - } - } - - if (diff == 0) - { - return false; - } - } - } - - for (int i = 0; i < diff; i++) - { - uint8_t val = rawData.at(unaccountedAddress + i); - src += StringHelper::Sprintf("0x%02X, ", val); - if (val != 0x00) - { - nonZeroUnaccounted = true; - } - - 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() && diff > 0) - { - std::string unaccountedPrefix = "unaccounted"; - - if (diff < 16 && !nonZeroUnaccounted) - { - unaccountedPrefix = "possiblePadding"; - - // Strip unnecessary padding at the end of the file. - if (unaccountedAddress + diff >= rawData.size()) - return true; - } - - Declaration* decl = AddDeclarationArray( - unaccountedAddress, DeclarationAlignment::Align4, diff, "u8", - StringHelper::Sprintf("%s_%s_%06X", name.c_str(), unaccountedPrefix.c_str(), - unaccountedAddress), - diff, src); - - decl->isUnaccounted = true; - if (Globals::Instance->forceUnaccountedStatic) - decl->staticConf = StaticConfig::On; - - if (nonZeroUnaccounted) - { - HANDLE_WARNING_RESOURCE(WarningType::Unaccounted, this, nullptr, unaccountedAddress, - "a non-zero unaccounted block was found", - StringHelper::Sprintf("Block size: '0x%X'", diff)); - } - else if (diff >= 16) - { - HANDLE_WARNING_RESOURCE(WarningType::Unaccounted, this, nullptr, unaccountedAddress, - "a big (size>=0x10) zero-only unaccounted block was found", - StringHelper::Sprintf("Block size: '0x%X'", diff)); - } - } - } - - return false; -} diff --git a/ZAPDTR/ZAPD/ZFile.h b/ZAPDTR/ZAPD/ZFile.h deleted file mode 100644 index 04334547c..000000000 --- a/ZAPDTR/ZAPD/ZFile.h +++ /dev/null @@ -1,141 +0,0 @@ -#pragma once - -#include -#include - -#include "ZSymbol.h" -#include "ZTexture.h" -#include "tinyxml2.h" - -enum class ZFileMode -{ - BuildTexture, - BuildOverlay, - BuildBlob, - BuildSourceFile, - BuildBackground, - Extract, - ExternalFile, - ExtractDirectory, - Invalid, - Custom = 1000, // Used for exporter file modes -}; - -enum class ZGame -{ - OOT_RETAIL, - OOT_SW97, - MM_RETAIL -}; - -class ZFile -{ -public: - std::map declarations; - std::vector resources; - std::string defines; - - int workerID; - bool isCompilable = false; - - // Default to using virtual addresses - uint32_t segment = 0x80; - uint32_t baseAddress, rangeStart, rangeEnd; - bool isExternalFile = false; - - ZFile(const fs::path& nOutPath, const std::string& nName); - ZFile(ZFileMode nMode, tinyxml2::XMLElement* reader, const fs::path& nBasePath, - const fs::path& nOutPath, const std::string& filename, const fs::path& nXmlFilePath, int nWorkerID); - ~ZFile(); - - std::string GetName() const; - std::string GetOutName() const; - ZFileMode GetMode() const; - const fs::path& GetXmlFilePath() const; - const std::vector& GetRawData() const; - void ExtractResources(); - void BuildSourceFile(); - void AddResource(ZResource* res); - ZResource* FindResource(offset_t rawDataIndex); - std::vector GetResourcesOfType(ZResourceType resType); - - Declaration* AddDeclaration(offset_t address, DeclarationAlignment alignment, size_t size, - const std::string& varType, const std::string& varName, - const std::string& body); - - Declaration* AddDeclarationArray(offset_t address, DeclarationAlignment alignment, size_t size, - const std::string& varType, const std::string& varName, - size_t arrayItemCnt, const std::string& body); - Declaration* AddDeclarationArray(offset_t address, DeclarationAlignment alignment, size_t size, - const std::string& varType, const std::string& varName, - const std::string& arrayItemCntStr, const std::string& body); - - Declaration* AddDeclarationPlaceholder(offset_t address, const std::string& varName); - - Declaration* AddDeclarationInclude(offset_t address, const std::string& includePath, - size_t size, const std::string& varType, - const std::string& varName); - Declaration* AddDeclarationIncludeArray(offset_t address, std::string& includePath, size_t size, - const std::string& varType, const std::string& varName, - size_t arrayItemCnt); - - bool GetDeclarationPtrName(segptr_t segAddress, const std::string& expectedType, - std::string& declName) const; - bool GetDeclarationArrayIndexedName(segptr_t segAddress, size_t elementSize, - const std::string& expectedType, - std::string& declName) const; - - Declaration* GetDeclaration(offset_t address) const; - Declaration* GetDeclarationRanged(offset_t address) const; - bool HasDeclaration(offset_t address); - - std::string GetHeaderInclude() const; - std::string GetZRoomHeaderInclude() const; - std::string GetExternalFileHeaderInclude() const; - - void GeneratePlaceholderDeclarations(); - - void AddTextureResource(uint32_t offset, ZTexture* tex); - ZTexture* GetTextureResource(uint32_t offset) const; - - void AddSymbolResource(uint32_t offset, ZSymbol* sym); - ZSymbol* GetSymbolResource(uint32_t offset) const; - ZSymbol* GetSymbolResourceRanged(uint32_t offset) const; - - fs::path GetSourceOutputFolderPath() const; - - bool IsOffsetInFileRange(uint32_t offset) const; - bool IsSegmentedInFilespaceRange(segptr_t segAddress) const; - - static std::map* GetNodeMap(); - static void RegisterNode(std::string nodeName, ZResourceFactoryFunc* nodeFunc); - -protected: - std::string name; - fs::path outName = ""; - fs::path basePath; - fs::path outputPath; - fs::path xmlFilePath; - std::vector rawData; - - // Keep track of every texture of this ZFile. - // The pointers declared here are "borrowed" (somebody else is the owner), - // so ZFile shouldn't delete/free those textures. - std::map texturesResources; - std::map symbolResources; - ZFileMode mode = ZFileMode::Invalid; - - ZFile(); - void ParseXML(tinyxml2::XMLElement* reader, const std::string& filename); - void DeclareResourceSubReferences(); - void GenerateSourceFiles(); - void GenerateSourceHeaderFiles(); - bool AddDeclarationChecks(uint32_t address, const std::string& varName); - std::string ProcessDeclarations(); - void ProcessDeclarationText(Declaration* decl); - std::string ProcessExterns(); - - std::string ProcessTextureIntersections(const std::string& prefix); - void HandleUnaccountedData(); - bool HandleUnaccountedAddress(offset_t currentAddress, offset_t lastAddr, uint32_t& lastSize); -}; diff --git a/ZAPDTR/ZAPD/ZLimb.cpp b/ZAPDTR/ZAPD/ZLimb.cpp deleted file mode 100644 index d0c3ffe3e..000000000 --- a/ZAPDTR/ZAPD/ZLimb.cpp +++ /dev/null @@ -1,420 +0,0 @@ -#include "ZLimb.h" - -#include - -#include "Globals.h" -#include "Utils/BitConverter.h" -#include "Utils/StringHelper.h" -#include "WarningHandler.h" -#include "ZSkeleton.h" - -REGISTER_ZFILENODE(Limb, ZLimb); - -ZLimb::ZLimb(ZFile* nParent) : ZResource(nParent), segmentStruct(nParent) -{ - RegisterOptionalAttribute("EnumName"); - RegisterOptionalAttribute("LimbType"); - RegisterOptionalAttribute("Type"); -} - -void ZLimb::ExtractFromBinary(uint32_t nRawDataIndex, ZLimbType nType) -{ - rawDataIndex = nRawDataIndex; - type = nType; - - // Don't parse raw data of external files - if (parent->GetMode() == ZFileMode::ExternalFile) - return; - - ParseRawData(); -} - -void ZLimb::ParseXML(tinyxml2::XMLElement* reader) -{ - ZResource::ParseXML(reader); - - auto& enumNameXml = registeredAttributes.at("EnumName").value; - if (enumNameXml != "") - { - enumName = enumNameXml; - } - - // Reading from a - std::string limbType = registeredAttributes.at("LimbType").value; - if (limbType == "") // Reading from a - limbType = registeredAttributes.at("Type").value; - - if (limbType == "") - { - HANDLE_ERROR_RESOURCE(WarningType::MissingAttribute, parent, this, rawDataIndex, - "missing 'LimbType' attribute in ", ""); - } - - type = GetTypeByAttributeName(limbType); - if (type == ZLimbType::Invalid) - { - HANDLE_ERROR_RESOURCE(WarningType::InvalidAttributeValue, parent, this, rawDataIndex, - "invalid value found for 'LimbType' attribute", ""); - } -} - -void ZLimb::ParseRawData() -{ - ZResource::ParseRawData(); - const auto& rawData = parent->GetRawData(); - - if (type == ZLimbType::Curve) - { - childIndex = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0); - siblingIndex = BitConverter::ToUInt8BE(rawData, rawDataIndex + 1); - - dListPtr = BitConverter::ToUInt32BE(rawData, rawDataIndex + 4); - 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); - transZ = BitConverter::ToInt16BE(rawData, rawDataIndex + 4); - - childIndex = rawData.at(rawDataIndex + 6); - siblingIndex = rawData.at(rawDataIndex + 7); - - switch (type) - { - case ZLimbType::LOD: - dList2Ptr = BitConverter::ToUInt32BE(rawData, rawDataIndex + 12); - [[fallthrough]]; - case ZLimbType::Standard: - dListPtr = BitConverter::ToUInt32BE(rawData, rawDataIndex + 8); - break; - - case ZLimbType::Skin: - skinSegmentType = - static_cast(BitConverter::ToInt32BE(rawData, rawDataIndex + 8)); - skinSegment = BitConverter::ToUInt32BE(rawData, rawDataIndex + 12); - if (skinSegmentType == ZLimbSkinType::SkinType_4) - { - if (skinSegment != 0 && GETSEGNUM(skinSegment) == parent->segment) - { - uint32_t skinSegmentOffset = Seg2Filespace(skinSegment, parent->baseAddress); - segmentStruct.ExtractFromFile(skinSegmentOffset); - } - } - break; - - case ZLimbType::Curve: - case ZLimbType::Legacy: - break; - - case ZLimbType::Invalid: - assert(!"whoops"); - break; - } -} - -void ZLimb::DeclareReferences(const std::string& prefix) -{ - std::string varPrefix = name; - if (varPrefix == "") - varPrefix = prefix; - - ZResource::DeclareReferences(varPrefix); - - std::string suffix; - 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(parent); - child->ExtractFromBinary(childOffset, ZLimbType::Legacy); - child->DeclareVar(varPrefix, ""); - child->DeclareReferences(varPrefix); - 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(parent); - sibling->ExtractFromBinary(siblingdOffset, ZLimbType::Legacy); - sibling->DeclareVar(varPrefix, ""); - sibling->DeclareReferences(varPrefix); - parent->AddResource(sibling); - } - } - break; - - case ZLimbType::Curve: - case ZLimbType::LOD: - suffix = "Far"; - if (type == ZLimbType::Curve) - suffix = "Curve2"; - DeclareDList(dList2Ptr, varPrefix, suffix); - [[fallthrough]]; - case ZLimbType::Standard: - suffix = ""; - if (type == ZLimbType::Curve) - suffix = "Curve"; - DeclareDList(dListPtr, varPrefix, suffix); - break; - - case ZLimbType::Skin: - switch (skinSegmentType) - { - case ZLimbSkinType::SkinType_4: - if (skinSegment != 0 && GETSEGNUM(skinSegment) == parent->segment) - { - segmentStruct.DeclareReferences(varPrefix); - segmentStruct.GetSourceOutputCode(varPrefix); - } - break; - - case ZLimbSkinType::SkinType_DList: - DeclareDList(skinSegment, varPrefix, ""); - break; - - default: - break; - } - break; - - case ZLimbType::Invalid: - break; - } -} - -size_t ZLimb::GetRawDataSize() const -{ - switch (type) - { - 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; -} - -std::string ZLimb::GetBodySourceCode() const -{ - if (Globals::Instance->otrMode) - return ""; - - std::string dListStr; - std::string dListStr2; - Globals::Instance->GetSegmentedArrayIndexedName(dListPtr, 8, parent, "Gfx", dListStr, - parent->workerID); - Globals::Instance->GetSegmentedArrayIndexedName(dList2Ptr, 8, parent, "Gfx", dListStr2, - parent->workerID); - - std::string entryStr = "\n\t"; - if (type == ZLimbType::Legacy) - { - std::string childName; - std::string siblingName; - Globals::Instance->GetSegmentedPtrName(childPtr, parent, "LegacyLimb", childName, - parent->workerID); - Globals::Instance->GetSegmentedPtrName(siblingPtr, parent, "LegacyLimb", siblingName, - parent->workerID); - - 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()); - } - else - { - std::string childStr; - std::string siblingStr; - if (limbsTable != nullptr) - { - childStr = limbsTable->GetLimbEnumName(childIndex); - siblingStr = limbsTable->GetLimbEnumName(siblingIndex); - } - else - { - childStr = StringHelper::Sprintf("0x%02X", childIndex); - siblingStr = StringHelper::Sprintf("0x%02X", siblingIndex); - } - - if (type != ZLimbType::Curve) - { - entryStr += StringHelper::Sprintf("{ %i, %i, %i }, ", transX, transY, transZ); - } - entryStr += StringHelper::Sprintf("%s, %s,\n", childStr.c_str(), siblingStr.c_str()); - - switch (type) - { - case ZLimbType::Standard: - entryStr += StringHelper::Sprintf("\t%s\n", dListStr.c_str()); - break; - - case ZLimbType::LOD: - case ZLimbType::Curve: - entryStr += - StringHelper::Sprintf("\t{ %s, %s }\n", dListStr.c_str(), dListStr2.c_str()); - break; - - case ZLimbType::Skin: - { - std::string skinSegmentStr; - Globals::Instance->GetSegmentedPtrName(skinSegment, parent, "", skinSegmentStr, - parent->workerID); - entryStr += - StringHelper::Sprintf("\t0x%02X, %s\n", skinSegmentType, skinSegmentStr.c_str()); - } - break; - - case ZLimbType::Legacy: - break; - - case ZLimbType::Invalid: - break; - } - } - - return entryStr; -} - -std::string ZLimb::GetDefaultName(const std::string& prefix) const -{ - return StringHelper::Sprintf("%sLimb_%06X", prefix.c_str(), rawDataIndex); -} - -std::string ZLimb::GetSourceTypeName() const -{ - return GetSourceTypeName(type); -} - -ZResourceType ZLimb::GetResourceType() const -{ - return ZResourceType::Limb; -} - -ZLimbType ZLimb::GetLimbType() -{ - return type; -} - -void ZLimb::SetLimbType(ZLimbType value) -{ - type = value; -} - -const char* ZLimb::GetSourceTypeName(ZLimbType limbType) -{ - switch (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; -} - -void ZLimb::SetLimbIndex(uint8_t nLimbIndex) -{ - limbIndex = nLimbIndex; -} - -void ZLimb::DeclareDList(segptr_t dListSegmentedPtr, const std::string& prefix, - const std::string& limbSuffix) -{ - if (dListSegmentedPtr == 0 || GETSEGNUM(dListSegmentedPtr) != parent->segment) - return; - - uint32_t dlistOffset = Seg2Filespace(dListSegmentedPtr, parent->baseAddress); - if (parent->HasDeclaration(dlistOffset)) - return; - - if (!parent->IsOffsetInFileRange(dlistOffset) || dlistOffset >= parent->GetRawData().size()) - return; - - std::string dlistName; - bool declFound = Globals::Instance->GetSegmentedArrayIndexedName(dListSegmentedPtr, 8, parent, - "Gfx", dlistName, parent->workerID); - if (declFound) - return; - - int32_t dlistLength = ZDisplayList::GetDListLength( - parent->GetRawData(), dlistOffset, - Globals::Instance->game == ZGame::OOT_SW97 ? DListType::F3DEX : DListType::F3DZEX); - ZDisplayList* dlist = new ZDisplayList(parent); - dlist->ExtractFromBinary(dlistOffset, dlistLength); - - std::string dListStr = - StringHelper::Sprintf("%s%sDL_%06X", prefix.c_str(), limbSuffix.c_str(), dlistOffset); - dlist->SetName(dListStr); - dlist->DeclareVar(prefix, ""); - parent->AddResource(dlist); -} diff --git a/ZAPDTR/ZAPD/ZLimb.h b/ZAPDTR/ZAPD/ZLimb.h deleted file mode 100644 index b75236f5e..000000000 --- a/ZAPDTR/ZAPD/ZLimb.h +++ /dev/null @@ -1,74 +0,0 @@ -#pragma once - -#include -#include -#include - -#include "OtherStructs/SkinLimbStructs.h" -#include "ZDisplayList.h" -#include "ZFile.h" - -enum class ZLimbType -{ - Invalid, - Standard, - LOD, - Skin, - Curve, - Legacy, -}; - -class ZLimbTable; - -class ZLimb : public ZResource -{ -public: - std::string enumName; - ZLimbTable* limbsTable = nullptr; // borrowed pointer, do not delete! - - ZLimbType type = ZLimbType::Standard; - - ZLimbSkinType skinSegmentType = ZLimbSkinType::SkinType_0; // Skin only - segptr_t skinSegment = 0; // Skin only - Struct_800A5E28 segmentStruct = {0}; // Skin only - - // Legacy only - float legTransX = 0, legTransY = 0, legTransZ = 0; // Vec3f - uint16_t rotX = 0, rotY = 0, rotZ = 0; // Vec3s - segptr_t childPtr = 0; // LegacyLimb* - segptr_t siblingPtr = 0; // LegacyLimb* - - segptr_t dListPtr = 0; - segptr_t dList2Ptr = 0; // LOD and Curve Only - - int16_t transX = 0, transY = 0, transZ = 0; - uint8_t childIndex = 0, siblingIndex = 0; - - uint8_t limbIndex = 0; - - ZLimb(ZFile* nParent); - - void ExtractFromBinary(uint32_t nRawDataIndex, ZLimbType nType); - - void ParseXML(tinyxml2::XMLElement* reader) override; - void ParseRawData() override; - void DeclareReferences(const std::string& prefix) override; - - std::string GetBodySourceCode() const override; - std::string GetDefaultName(const std::string& prefix) const override; - - size_t GetRawDataSize() const override; - std::string GetSourceTypeName() const override; - ZResourceType GetResourceType() const override; - - ZLimbType GetLimbType(); - void SetLimbType(ZLimbType value); - static const char* GetSourceTypeName(ZLimbType limbType); - static ZLimbType GetTypeByAttributeName(const std::string& attrName); - - void SetLimbIndex(uint8_t nLimbIndex); - -protected: - void DeclareDList(segptr_t dListSegmentedPtr, const std::string& prefix, - const std::string& limbSuffix); -}; diff --git a/ZAPDTR/ZAPD/ZMtx.cpp b/ZAPDTR/ZAPD/ZMtx.cpp deleted file mode 100644 index b9ca3f22d..000000000 --- a/ZAPDTR/ZAPD/ZMtx.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#include "ZMtx.h" - -#include "Utils/BitConverter.h" -#include "Utils/StringHelper.h" -#include "ZFile.h" - -REGISTER_ZFILENODE(Mtx, ZMtx); - -ZMtx::ZMtx(ZFile* nParent) : ZResource(nParent) -{ -} - -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); -} - -size_t ZMtx::GetRawDataSize() const -{ - return 64; -} - -std::string ZMtx::GetBodySourceCode() const -{ - std::string bodyStr = "\n"; - - for (const auto& row : mtx) - { - bodyStr += " "; - - for (int32_t val : row) - bodyStr += StringHelper::Sprintf("%-11i, ", val); - - bodyStr += "\n"; - } - - return bodyStr; -} - -std::string ZMtx::GetSourceTypeName() const -{ - return "Mtx"; -} - -ZResourceType ZMtx::GetResourceType() const -{ - return ZResourceType::Mtx; -} - -DeclarationAlignment ZMtx::GetDeclarationAlignment() const -{ - return DeclarationAlignment::Align8; -} diff --git a/ZAPDTR/ZAPD/ZMtx.h b/ZAPDTR/ZAPD/ZMtx.h deleted file mode 100644 index 1b5513cd4..000000000 --- a/ZAPDTR/ZAPD/ZMtx.h +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once - -#include -#include -#include "ZResource.h" - -class ZMtx : public ZResource -{ -public: - ZMtx(ZFile* nParent); - - void ParseRawData() override; - - std::string GetBodySourceCode() const override; - - std::string GetSourceTypeName() const override; - ZResourceType GetResourceType() const override; - - size_t GetRawDataSize() const override; - DeclarationAlignment GetDeclarationAlignment() const override; - -public: - std::array, 4> mtx; -}; diff --git a/ZAPDTR/ZAPD/ZPath.cpp b/ZAPDTR/ZAPD/ZPath.cpp deleted file mode 100644 index 849b4edfc..000000000 --- a/ZAPDTR/ZAPD/ZPath.cpp +++ /dev/null @@ -1,212 +0,0 @@ -#include "ZPath.h" - -#include "Globals.h" -#include "Utils/BitConverter.h" -#include "Utils/StringHelper.h" -#include "WarningHandler.h" -#include "ZFile.h" - -REGISTER_ZFILENODE(Path, ZPath); - -ZPath::ZPath(ZFile* nParent) : ZResource(nParent) -{ - numPaths = 1; - RegisterOptionalAttribute("NumPaths", "1"); -} - -void ZPath::ParseXML(tinyxml2::XMLElement* reader) -{ - ZResource::ParseXML(reader); - - numPaths = StringHelper::StrToL(registeredAttributes.at("NumPaths").value); - - if (numPaths < 1) - { - HANDLE_ERROR_RESOURCE( - WarningType::InvalidAttributeValue, parent, this, rawDataIndex, - StringHelper::Sprintf("invalid value '%d' found for 'NumPaths' attribute", numPaths), - "Should be at least '1'"); - } -} - -void ZPath::ParseRawData() -{ - ZResource::ParseRawData(); - - uint32_t currentPtr = rawDataIndex; - - pathways.reserve(numPaths); - for (size_t pathIndex = 0; pathIndex < numPaths; pathIndex++) - { - PathwayEntry path(parent); - path.ExtractFromFile(currentPtr); - - if (path.GetListAddress() == 0) - break; - - currentPtr += path.GetRawDataSize(); - pathways.push_back(path); - } -} - -void ZPath::DeclareReferences(const std::string& prefix) -{ - ZResource::DeclareReferences(prefix); - - for (auto& entry : pathways) - entry.DeclareReferences(prefix); -} - -Declaration* ZPath::DeclareVar(const std::string& prefix, const std::string& bodyStr) -{ - std::string auxName = name; - - if (name == "") - auxName = GetDefaultName(prefix); - - Declaration* decl = - parent->AddDeclarationArray(rawDataIndex, GetDeclarationAlignment(), GetRawDataSize(), - GetSourceTypeName(), name, pathways.size(), bodyStr); - decl->staticConf = staticConf; - return decl; -} - -std::string ZPath::GetBodySourceCode() const -{ - std::string declaration; - - size_t index = 0; - for (const auto& entry : pathways) - { - declaration += StringHelper::Sprintf("\t{ %s },", entry.GetBodySourceCode().c_str()); - - if (index < pathways.size() - 1) - declaration += "\n"; - - index++; - } - - return declaration; -} - -std::string ZPath::GetSourceTypeName() const -{ - return "Path"; -} - -ZResourceType ZPath::GetResourceType() const -{ - return ZResourceType::Path; -} - -size_t ZPath::GetRawDataSize() const -{ - return pathways.size() * pathways.at(0).GetRawDataSize(); -} - -void ZPath::SetNumPaths(uint32_t nNumPaths) -{ - numPaths = nNumPaths; -} - -/* PathwayEntry */ - -PathwayEntry::PathwayEntry(ZFile* nParent) : ZResource(nParent) -{ -} - -void PathwayEntry::ParseRawData() -{ - ZResource::ParseRawData(); - auto parentRawData = parent->GetRawData(); - numPoints = parentRawData.at(rawDataIndex + 0); - unk1 = parentRawData.at(rawDataIndex + 1); - unk2 = BitConverter::ToInt16BE(parentRawData, rawDataIndex + 2); - listSegmentAddress = BitConverter::ToInt32BE(parentRawData, rawDataIndex + 4); - - uint32_t currentPtr = GETSEGOFFSET(listSegmentAddress); - - points.reserve(numPoints); - for (int32_t i = 0; i < numPoints; i++) - { - ZVector vec(parent); - vec.ExtractFromBinary(currentPtr, ZScalarType::ZSCALAR_S16, 3); - - currentPtr += vec.GetRawDataSize(); - points.push_back(vec); - } -} - -void PathwayEntry::DeclareReferences(const std::string& prefix) -{ - ZResource::DeclareReferences(prefix); - if (points.empty()) - return; - - std::string pointsName; - bool addressFound = Globals::Instance->GetSegmentedPtrName(listSegmentAddress, parent, "Vec3s", - pointsName, parent->workerID); - if (addressFound) - return; - - std::string declaration = ""; - - size_t index = 0; - for (const auto& point : points) - { - declaration += StringHelper::Sprintf("\t{ %s },", point.GetBodySourceCode().c_str()); - - if (index < points.size() - 1) - declaration += "\n"; - - index++; - } - - uint32_t pointsOffset = Seg2Filespace(listSegmentAddress, parent->baseAddress); - Declaration* decl = parent->GetDeclaration(pointsOffset); - if (decl == nullptr) - { - pointsName = StringHelper::Sprintf("%sPathwayList_%06X", prefix.c_str(), pointsOffset); - parent->AddDeclarationArray(pointsOffset, points.at(0).GetDeclarationAlignment(), - points.size() * 6, points.at(0).GetSourceTypeName(), pointsName, - points.size(), declaration); - } - else - decl->text = declaration; -} - -std::string PathwayEntry::GetBodySourceCode() const -{ - std::string declaration; - std::string listName; - Globals::Instance->GetSegmentedPtrName(listSegmentAddress, parent, "Vec3s", listName, - parent->workerID); - - if (Globals::Instance->game == ZGame::MM_RETAIL) - declaration += - StringHelper::Sprintf("%i, %i, %i, %s", numPoints, unk1, unk2, listName.c_str()); - else - declaration += StringHelper::Sprintf("%i, %s", numPoints, listName.c_str()); - - return declaration; -} - -std::string PathwayEntry::GetSourceTypeName() const -{ - return "Path"; -} - -ZResourceType PathwayEntry::GetResourceType() const -{ - return ZResourceType::Path; -} - -size_t PathwayEntry::GetRawDataSize() const -{ - return 0x08; -} - -segptr_t PathwayEntry::GetListAddress() const -{ - return listSegmentAddress; -} diff --git a/ZAPDTR/ZAPD/ZPath.h b/ZAPDTR/ZAPD/ZPath.h deleted file mode 100644 index 722e84afe..000000000 --- a/ZAPDTR/ZAPD/ZPath.h +++ /dev/null @@ -1,51 +0,0 @@ -#pragma once - -#include "ZResource.h" -#include "ZVector.h" - -class PathwayEntry : public ZResource -{ -public: - PathwayEntry(ZFile* nParent); - - void ParseRawData() override; - void DeclareReferences(const std::string& prefix) override; - - std::string GetBodySourceCode() const override; - - std::string GetSourceTypeName() const override; - ZResourceType GetResourceType() const override; - - size_t GetRawDataSize() const override; - segptr_t GetListAddress() const; - -public: - int32_t numPoints; - int8_t unk1; // (MM Only) - int16_t unk2; // (MM Only) - segptr_t listSegmentAddress; - std::vector points; -}; - -class ZPath : public ZResource -{ -public: - ZPath(ZFile* nParent); - - void ParseXML(tinyxml2::XMLElement* reader) override; - void ParseRawData() override; - void DeclareReferences(const std::string& prefix) override; - - Declaration* DeclareVar(const std::string& prefix, const std::string& bodyStr) override; - std::string GetBodySourceCode() const override; - - std::string GetSourceTypeName() const override; - ZResourceType GetResourceType() const override; - - size_t GetRawDataSize() const override; - void SetNumPaths(uint32_t nNumPaths); - -public: - uint32_t numPaths; - std::vector pathways; -}; diff --git a/ZAPDTR/ZAPD/ZPlayerAnimationData.cpp b/ZAPDTR/ZAPD/ZPlayerAnimationData.cpp deleted file mode 100644 index ab633c129..000000000 --- a/ZAPDTR/ZAPD/ZPlayerAnimationData.cpp +++ /dev/null @@ -1,101 +0,0 @@ -#include "ZPlayerAnimationData.h" - -#include "Utils/BitConverter.h" -#include "Utils/StringHelper.h" -#include "ZFile.h" -#include - -REGISTER_ZFILENODE(PlayerAnimationData, ZPlayerAnimationData); - -ZPlayerAnimationData::ZPlayerAnimationData(ZFile* nParent) : ZResource(nParent) -{ - RegisterRequiredAttribute("FrameCount"); -} - -void ZPlayerAnimationData::ParseXML(tinyxml2::XMLElement* reader) -{ - ZResource::ParseXML(reader); - - std::string& frameCountXml = registeredAttributes.at("FrameCount").value; - - frameCount = StringHelper::StrToL(frameCountXml); -} - -void ZPlayerAnimationData::ParseRawData() -{ - ZResource::ParseRawData(); - - const auto& rawData = parent->GetRawData(); - - size_t totalSize = GetRawDataSize(); - // Divided by 2 because each value is an s16 - limbRotData.reserve(totalSize * frameCount / 2); - - for (size_t i = 0; i < totalSize; i += 2) - { - limbRotData.push_back(BitConverter::ToUInt16BE(rawData, rawDataIndex + i)); - } -} - -Declaration* ZPlayerAnimationData::DeclareVar(const std::string& prefix, const std::string& bodyStr) -{ - std::string auxName = name; - - if (auxName == "") - auxName = GetDefaultName(prefix); - - Declaration* decl = - parent->AddDeclarationArray(rawDataIndex, GetDeclarationAlignment(), GetRawDataSize(), - GetSourceTypeName(), name, limbRotData.size(), bodyStr); - decl->staticConf = staticConf; - return decl; -} - -std::string ZPlayerAnimationData::GetBodySourceCode() const -{ - std::string declaration = ""; - - if (Globals::Instance->otrMode) - return ""; - - size_t index = 0; - for (const auto& entry : limbRotData) - { - if (index % 8 == 0) - { - declaration += "\t"; - } - - declaration += StringHelper::Sprintf("0x%04X, ", entry); - - if ((index + 1) % 8 == 0) - { - declaration += "\n"; - } - - index++; - } - - return declaration; -} - -std::string ZPlayerAnimationData::GetDefaultName(const std::string& prefix) const -{ - return StringHelper::Sprintf("%sPlayerAnimationData_%06X", prefix.c_str(), rawDataIndex); -} - -std::string ZPlayerAnimationData::GetSourceTypeName() const -{ - return "s16"; -} - -ZResourceType ZPlayerAnimationData::GetResourceType() const -{ - return ZResourceType::PlayerAnimationData; -} - -size_t ZPlayerAnimationData::GetRawDataSize() const -{ - // (sizeof(Vec3s) * limbCount + 2) * frameCount - return (6 * 22 + 2) * frameCount; -} diff --git a/ZAPDTR/ZAPD/ZPlayerAnimationData.h b/ZAPDTR/ZAPD/ZPlayerAnimationData.h deleted file mode 100644 index 20835f236..000000000 --- a/ZAPDTR/ZAPD/ZPlayerAnimationData.h +++ /dev/null @@ -1,28 +0,0 @@ -#pragma once - -#include -#include - -#include "ZResource.h" - -class ZPlayerAnimationData : public ZResource -{ -public: - int16_t frameCount = 0; - std::vector limbRotData; - - ZPlayerAnimationData(ZFile* nParent); - - void ParseXML(tinyxml2::XMLElement* reader) override; - void ParseRawData() override; - - Declaration* DeclareVar(const std::string& prefix, const std::string& bodyStr) override; - - std::string GetBodySourceCode() const override; - std::string GetDefaultName(const std::string& prefix) const override; - - std::string GetSourceTypeName() const override; - ZResourceType GetResourceType() const override; - - size_t GetRawDataSize() const override; -}; diff --git a/ZAPDTR/ZAPD/ZPointer.cpp b/ZAPDTR/ZAPD/ZPointer.cpp deleted file mode 100644 index 6e6945cad..000000000 --- a/ZAPDTR/ZAPD/ZPointer.cpp +++ /dev/null @@ -1,57 +0,0 @@ -#include "ZPointer.h" - -#include "Globals.h" -#include "Utils/BitConverter.h" -#include "Utils/StringHelper.h" -#include "WarningHandler.h" -#include "ZFile.h" - -REGISTER_ZFILENODE(Pointer, ZPointer); - -ZPointer::ZPointer(ZFile* nParent) : ZResource(nParent) -{ - RegisterRequiredAttribute("Type"); -} - -void ZPointer::ParseXML(tinyxml2::XMLElement* reader) -{ - ZResource::ParseXML(reader); - - type = registeredAttributes.at("Type").value; -} - -void ZPointer::ParseRawData() -{ - auto& rawData = parent->GetRawData(); - - ptr = BitConverter::ToUInt32BE(rawData, rawDataIndex); -} - -std::string ZPointer::GetBodySourceCode() const -{ - std::string ptrName; - - Globals::Instance->GetSegmentedPtrName(ptr, parent, "", ptrName); - - return ptrName; -} - -bool ZPointer::DoesSupportArray() const -{ - return true; -} - -std::string ZPointer::GetSourceTypeName() const -{ - return type + "*"; -} - -ZResourceType ZPointer::GetResourceType() const -{ - return ZResourceType::Pointer; -} - -size_t ZPointer::GetRawDataSize() const -{ - return 0x04; -} diff --git a/ZAPDTR/ZAPD/ZPointer.h b/ZAPDTR/ZAPD/ZPointer.h deleted file mode 100644 index 8fb588933..000000000 --- a/ZAPDTR/ZAPD/ZPointer.h +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once - -#include "ZResource.h" - -class ZPointer : public ZResource -{ -public: - segptr_t ptr = SEGMENTED_NULL; - std::string type; - - ZPointer(ZFile* nParent); - - void ParseXML(tinyxml2::XMLElement* reader) override; - void ParseRawData() override; - std::string GetBodySourceCode() const override; - - bool DoesSupportArray() const override; - std::string GetSourceTypeName() const override; - ZResourceType GetResourceType() const override; - - size_t GetRawDataSize() const override; -}; diff --git a/ZAPDTR/ZAPD/ZResource.cpp b/ZAPDTR/ZAPD/ZResource.cpp deleted file mode 100644 index aacc7afdc..000000000 --- a/ZAPDTR/ZAPD/ZResource.cpp +++ /dev/null @@ -1,439 +0,0 @@ -#include "ZResource.h" - -#include -#include - -#include "Utils/StringHelper.h" -#include "WarningHandler.h" -#include "ZFile.h" -#include -#include -#include -#include - -ZResource::ZResource(ZFile* nParent) -{ - // assert(nParent != nullptr); - parent = nParent; - name = ""; - outName = ""; - sourceOutput = ""; - rawDataIndex = 0; - outputDeclaration = true; - hash = 0; - - RegisterRequiredAttribute("Name"); - RegisterOptionalAttribute("OutName"); - RegisterOptionalAttribute("Offset"); - RegisterOptionalAttribute("Custom"); - RegisterOptionalAttribute("Static", "Global"); -} - -void ZResource::ExtractFromXML(tinyxml2::XMLElement* reader, offset_t nRawDataIndex) -{ - rawDataIndex = nRawDataIndex; - declaredInXml = true; - - if (reader != nullptr) - ParseXML(reader); - - // Don't parse raw data of external files - if (parent->GetMode() != ZFileMode::ExternalFile) - { - ParseRawData(); - CalcHash(); - } - - if (!isInner) - { - Declaration* decl = DeclareVar(parent->GetName(), ""); - if (decl != nullptr) - { - decl->declaredInXml = true; - decl->staticConf = staticConf; - } - } -} - -void ZResource::ExtractFromFile(offset_t nRawDataIndex) -{ - rawDataIndex = nRawDataIndex; - - // Don't parse raw data of external files - if (parent->GetMode() == ZFileMode::ExternalFile) - return; - - ParseRawData(); - CalcHash(); -} - -void ZResource::ParseXML(tinyxml2::XMLElement* reader) -{ - if (reader != nullptr) - { - // If it is an inner node, then 'Name' isn't required - if (isInner) - { - registeredAttributes.at("Name").isRequired = false; - } - - auto attrs = reader->FirstAttribute(); - while (attrs != nullptr) - { - std::string attrName = attrs->Name(); - bool attrDeclared = false; - - if (registeredAttributes.find(attrName) != registeredAttributes.end()) - { - registeredAttributes[attrName].value = attrs->Value(); - registeredAttributes[attrName].wasSet = true; - attrDeclared = true; - } - - if (!attrDeclared) - { - HANDLE_WARNING_RESOURCE( - WarningType::UnknownAttribute, parent, this, rawDataIndex, - StringHelper::Sprintf("unexpected '%s' attribute in resource <%s>", - attrName.c_str(), reader->Name()), - ""); - } - attrs = attrs->Next(); - } - - if (!Globals::Instance->otrMode) - { - if (!canHaveInner && !reader->NoChildren()) - { - std::string errorHeader = StringHelper::Sprintf( - "resource '%s' with inner element/child detected", reader->Name()); - HANDLE_ERROR_PROCESS(WarningType::InvalidXML, errorHeader, ""); - } - } - - for (const auto& attr : registeredAttributes) - { - if (attr.second.isRequired && attr.second.value == "") - { - std::string headerMsg = - StringHelper::Sprintf("missing required attribute '%s' in resource <%s>", - attr.first.c_str(), reader->Name()); - HANDLE_ERROR_RESOURCE(WarningType::MissingAttribute, parent, this, rawDataIndex, - headerMsg, ""); - } - } - - name = registeredAttributes.at("Name").value; - - // Disable this check for OTR file generation for now since it takes up a considerable amount of CPU time - if (!Globals::Instance->otrMode) - { - static std::regex r("[a-zA-Z_]+[a-zA-Z0-9_]*", - std::regex::icase | std::regex::optimize); - - if (!isInner || (isInner && name != "")) - { - if (!std::regex_match(name, r)) - { - HANDLE_ERROR_RESOURCE(WarningType::InvalidAttributeValue, parent, this, - rawDataIndex, "invalid value found for 'Name' attribute", - ""); - } - } - } - - outName = registeredAttributes.at("OutName").value; - if (outName == "") - outName = name; - - isCustomAsset = registeredAttributes["Custom"].wasSet; - - std::string& staticXml = registeredAttributes["Static"].value; - if (staticXml == "Global") - { - staticConf = StaticConfig::Global; - } - else if (staticXml == "On") - { - staticConf = StaticConfig::On; - } - else if (staticXml == "Off") - { - staticConf = StaticConfig::Off; - } - else - { - HANDLE_ERROR_RESOURCE( - WarningType::InvalidAttributeValue, parent, this, rawDataIndex, - StringHelper::Sprintf("invalid value '%s' for 'Static' attribute", staticConf), ""); - } - - declaredInXml = true; - } -} - -void ZResource::ParseRawData() -{ -} - -void ZResource::DeclareReferences([[maybe_unused]] const std::string& prefix) -{ -} - -void ZResource::ParseRawDataLate() -{ -} - -void ZResource::DeclareReferencesLate([[maybe_unused]] const std::string& prefix) -{ -} - -Declaration* ZResource::DeclareVar(const std::string& prefix, const std::string& bodyStr) -{ - std::string auxName = name; - - if (name == "") - auxName = GetDefaultName(prefix); - - Declaration* decl = - parent->AddDeclaration(rawDataIndex, GetDeclarationAlignment(), GetRawDataSize(), - GetSourceTypeName(), auxName, bodyStr); - decl->staticConf = staticConf; - return decl; -} - -void ZResource::Save([[maybe_unused]] const fs::path& outFolder) -{ -} - -const std::string& ZResource::GetName() const -{ - return name; -} - -const std::string& ZResource::GetOutName() const -{ - return outName; -} - -void ZResource::SetOutName(const std::string& nName) -{ - outName = nName; -} - -void ZResource::SetName(const std::string& nName) -{ - name = nName; -} - -bool ZResource::IsExternalResource() const -{ - return false; -} - -bool ZResource::DoesSupportArray() const -{ - return false; -} - -std::string ZResource::GetExternalExtension() const -{ - return ""; -} - -DeclarationAlignment ZResource::GetDeclarationAlignment() const -{ - return DeclarationAlignment::Align4; -} - -bool ZResource::WasDeclaredInXml() const -{ - return declaredInXml; -} - -StaticConfig ZResource::GetStaticConf() const -{ - return staticConf; -} - -offset_t ZResource::GetRawDataIndex() const -{ - return rawDataIndex; -} - -void ZResource::SetRawDataIndex(offset_t nRawDataIndex) -{ - rawDataIndex = nRawDataIndex; -} - -std::string ZResource::GetBodySourceCode() const -{ - return "ERROR"; -} - -std::string ZResource::GetDefaultName(const std::string& prefix) const -{ - return StringHelper::Sprintf("%s%s_%06X", prefix.c_str(), GetSourceTypeName().c_str(), - rawDataIndex); -} - -void ZResource::GetSourceOutputCode([[maybe_unused]] const std::string& prefix) -{ - std::string bodyStr = GetBodySourceCode(); - - if (bodyStr != "ERROR") - { - Declaration* decl = parent->GetDeclaration(rawDataIndex); - - if (decl == nullptr || decl->isPlaceholder) - decl = DeclareVar(prefix, bodyStr); - else - decl->text = bodyStr; - - // OTRTODO: This is a hack and we need something more elegant in the future... - if (GetResourceType() == ZResourceType::Array) - { - ZArray* arr = (ZArray*)this; - if (arr->resList[0]->GetResourceType() == ZResourceType::Vertex) - { - for (int i = 0; i < arr->resList.size(); i++) - { - ZVtx* vtx = (ZVtx*)arr->resList[i]; - decl->vertexHack.push_back(vtx); - - } - } - } - - if (decl != nullptr) - decl->staticConf = staticConf; - } -} - -std::string ZResource::GetSourceOutputHeader([[maybe_unused]] const std::string& prefix, std::set *nameSet) -{ - if (Globals::Instance->otrMode && genOTRDef) - { - std::string str = ""; - std::string nameStr = StringHelper::Strip(StringHelper::Strip(name, "\n"), "\r"); - - std::string outName = parent->GetOutName(); - std::string prefix = ""; - - if (GetResourceType() == ZResourceType::DisplayList || GetResourceType() == ZResourceType::Texture) - { - //ZDisplayList* dList = (ZDisplayList*)this; - - if (StringHelper::Contains(outName, "_room_")) - { - outName = StringHelper::Split(outName, "_room")[0] + "_scene"; - } - } - - std::string xmlPath = StringHelper::Replace(parent->GetXmlFilePath().string(), "\\", "/"); - - if (StringHelper::Contains(outName, "_room_") || StringHelper::Contains(outName, "_scene")) - prefix = "scenes/nonmq"; - else if (StringHelper::Contains(xmlPath, "objects/")) - prefix = "objects"; - else if (StringHelper::Contains(xmlPath, "textures/")) - prefix = "textures"; - else if (StringHelper::Contains(xmlPath, "overlays/")) - prefix = "overlays"; - else if (StringHelper::Contains(xmlPath, "misc/")) - prefix = "misc"; - else if (StringHelper::Contains(xmlPath, "code/")) - prefix = "code"; - else if (StringHelper::Contains(xmlPath, "text/")) - prefix = "text"; - - if (prefix != "") { - str += StringHelper::Sprintf("#define d%s \"__OTR__%s/%s/%s\"", name.c_str(), prefix.c_str(), outName.c_str(), nameStr.c_str()); - } - else - str += StringHelper::Sprintf("#define d%s \"__OTR__%s/%s\"", name.c_str(), outName.c_str(), nameStr.c_str()); - - if (nameSet && nameSet->find(name) == nameSet->end()) { - str += StringHelper::Sprintf("\n"); - str += StringHelper::Sprintf(R"(static const ALIGN_ASSET(2) char %s[] = d%s;)", name.c_str(), name.c_str()); - - if (nameSet) { - nameSet->insert(name); - } - } - - if (name == "gTitleZeldaShieldLogoMQTex") - { - std::string addName = "gTitleZeldaShieldLogoTex"; - nameStr = StringHelper::Strip(StringHelper::Strip(addName, "\n"), "\r"); - str += StringHelper::Sprintf("\n\n#define d%s \"__OTR__%s/%s/%s\"", addName.c_str(), prefix.c_str(), outName.c_str(), nameStr.c_str()); - if (nameSet && nameSet->find(addName) == nameSet->end()) - { - str += StringHelper::Sprintf("\n"); - str += StringHelper::Sprintf(R"(static const ALIGN_ASSET(2) char %s[] = d%s;)", addName.c_str(), addName.c_str()); - - if (nameSet) - { - nameSet->insert(addName); - } - } - } - - return str; - } - else - return ""; -} - -ZResourceType ZResource::GetResourceType() const -{ - return ZResourceType::Error; -} - -void ZResource::CalcHash() -{ - hash = 0; -} - -void ZResource::SetInnerNode(bool inner) -{ - isInner = inner; -} - -void ZResource::RegisterRequiredAttribute(const std::string& attr) -{ - ResourceAttribute resAtrr; - resAtrr.key = attr; - resAtrr.isRequired = true; - registeredAttributes[attr] = resAtrr; -} - -void ZResource::RegisterOptionalAttribute(const std::string& attr, const std::string& defaultValue) -{ - ResourceAttribute resAtrr; - resAtrr.key = attr; - resAtrr.value = defaultValue; - registeredAttributes[attr] = resAtrr; -} - -offset_t Seg2Filespace(segptr_t segmentedAddress, uint32_t parentBaseAddress) -{ - offset_t currentPtr = GETSEGOFFSET(segmentedAddress); - - if (GETSEGNUM(segmentedAddress) == 0x80) // Is defined in code? - { - uint32_t parentBaseOffset = GETSEGOFFSET(parentBaseAddress); - if (parentBaseOffset > currentPtr) - { - HANDLE_ERROR(WarningType::Always, - StringHelper::Sprintf( - "resource address 0x%08X is smaller than 'BaseAddress' 0x%08X", - segmentedAddress, parentBaseAddress), - "Maybe your 'BaseAddress' is wrong?"); - } - - currentPtr -= parentBaseOffset; - } - - return currentPtr; -} diff --git a/ZAPDTR/ZAPD/ZResource.h b/ZAPDTR/ZAPD/ZResource.h deleted file mode 100644 index 05c35a26b..000000000 --- a/ZAPDTR/ZAPD/ZResource.h +++ /dev/null @@ -1,252 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include -#include -#include "Declaration.h" -#include -#include -#include "tinyxml2.h" - -#define SEGMENT_SCENE 2 -#define SEGMENT_ROOM 3 -#define SEGMENT_KEEP 4 -#define SEGMENT_FIELDDANGEON_KEEP 5 -#define SEGMENT_OBJECT 6 -#define SEGMENT_LINKANIMETION 7 - -#define GETSEGOFFSET(x) (x & 0x00FFFFFF) -#define GETSEGNUM(x) ((x >> 24) & 0xFF) - -class ZFile; - -enum class ZResourceType -{ - Error, - Animation, - Array, - AltHeader, - Background, - Blob, - CollisionHeader, - Cutscene, - DisplayList, - Limb, - LimbTable, - Mtx, - Path, - PlayerAnimationData, - Room, - RoomCommand, - Scalar, - Scene, - Skeleton, - String, - Symbol, - Texture, - TextureAnimation, - TextureAnimationParams, - Vector, - Vertex, - Text, - Audio, - ActorList, - CollisionPoly, - Pointer, - SurfaceType, -}; - -class ResourceAttribute -{ -public: - std::string key; - std::string value; - bool isRequired = false; - bool wasSet = false; -}; - -class ZResource -{ -public: - ZFile* parent; - bool outputDeclaration = true; - uint32_t hash = 0; - bool genOTRDef = false; - - /** - * Constructor. - * Child classes should not declare any other constructor besides this one - */ - ZResource(ZFile* nParent); - virtual ~ZResource() = default; - - // Parsing from File - virtual void ExtractFromXML(tinyxml2::XMLElement* reader, offset_t nRawDataIndex); - virtual void ExtractFromFile(offset_t nRawDataIndex); - - // Misc - /** - * Parses additional attributes of the XML node. - * Extra attritbutes have to be registered using `RegisterRequiredAttribute` or - * `RegisterOptionalAttribute` in the constructor of the ZResource - */ - virtual void ParseXML(tinyxml2::XMLElement* reader); - /** - * Extracts data from the binary file - */ - virtual void ParseRawData(); - /** - * Declares any data pointed by this resource that has not been declared already. - * For example, a Vtx referenced by a Dlist should be declared here if it wasn't - * declared previously by something else - */ - virtual void DeclareReferences(const std::string& prefix); - virtual void ParseRawDataLate(); - virtual void DeclareReferencesLate(const std::string& prefix); - - /** - * Adds this resource as a Declaration of its parent ZFile - */ - virtual Declaration* DeclareVar(const std::string& prefix, const std::string& bodyStr); - /** - * Returns the body of the variable of the extracted resource, without any side-effect - */ - [[nodiscard]] virtual std::string GetBodySourceCode() const; - /** - * Creates an automatically generated variable name for the current resource - */ - [[nodiscard]] virtual std::string GetDefaultName(const std::string& prefix) const; - - virtual void GetSourceOutputCode(const std::string& prefix); - virtual std::string GetSourceOutputHeader(const std::string& prefix, std::set *nameSet); - virtual void CalcHash(); - /** - * Exports the resource to binary format - */ - virtual void Save(const fs::path& outFolder); - - // Properties - /** - * Returns true if the resource will be externalized, and included back to the C file using - * `#include`s - */ - virtual bool IsExternalResource() const; - /** - * Can this type be wrapped in an node? - */ - virtual bool DoesSupportArray() const; - /** - * The type of the resource as a C struct - */ - [[nodiscard]] virtual std::string GetSourceTypeName() const = 0; - /** - * The type in the ZResource enum - */ - [[nodiscard]] virtual ZResourceType GetResourceType() const = 0; - /** - * The filename extension for assets extracted as standalone files - */ - [[nodiscard]] virtual std::string GetExternalExtension() const; - - // Getters/Setters - [[nodiscard]] const std::string& GetName() const; - void SetName(const std::string& nName); - [[nodiscard]] const std::string& GetOutName() const; - void SetOutName(const std::string& nName); - [[nodiscard]] offset_t GetRawDataIndex() const; - void SetRawDataIndex(offset_t nRawDataIndex); - - /** - * The size of the current struct being extracted, not counting data referenced by it - */ - [[nodiscard]] virtual size_t GetRawDataSize() const = 0; - /** - * The alignment of the extracted struct - */ - [[nodiscard]] virtual DeclarationAlignment GetDeclarationAlignment() const; - void SetInnerNode(bool inner); - /** - * Returns `true` if this ZResource was declared using an XML node, - * `false` otherwise (for example, a Vtx extracted indirectly by a DList) - */ - [[nodiscard]] bool WasDeclaredInXml() const; - [[nodiscard]] StaticConfig GetStaticConf() const; - -protected: - std::string name; - std::string outName; - offset_t rawDataIndex; - std::string sourceOutput; - - // Inner is used mostly for nodes - /** - * Is this resource an inner node of another resource? - * (namely inside an ) - */ - bool isInner = false; - /** - * Can this type have an inner node? - */ - bool canHaveInner = false; - - /** - * If set to true, create a reference for the asset in the file, but don't - * actually try to extract it from the file - */ - bool isCustomAsset; - bool declaredInXml = false; - StaticConfig staticConf = StaticConfig::Global; - - // Reading from this XMLs attributes should be performed in the overrided `ParseXML` method. - std::map registeredAttributes; - - // XML attributes registers. - // Registering XML attributes should be done in constructors. - - // The resource needs this attribute. If it is not provided, then the program will throw an - // exception. - void RegisterRequiredAttribute(const std::string& attr); - // Optional attribute. The resource has to do manual checks and manual warnings. It may or may - // not have a value. - void RegisterOptionalAttribute(const std::string& attr, const std::string& defaultValue = ""); -}; - -class ZResourceExporter -{ -public: - ZResourceExporter() = default; - virtual ~ZResourceExporter() = default; - - virtual void Save(ZResource* res, const fs::path& outPath, BinaryWriter* writer) = 0; -}; - -offset_t Seg2Filespace(segptr_t segmentedAddress, uint32_t parentBaseAddress); - -typedef ZResource*(ZResourceFactoryFunc)(ZFile* nParent); - -#define REGISTER_ZFILENODE(nodeName, zResClass) \ - static ZResource* ZResourceFactory_##zResClass_##nodeName(ZFile* nParent) \ - { \ - return static_cast(new zResClass(nParent)); \ - } \ - \ - class ZRes_##nodeName \ - { \ - public: \ - ZRes_##nodeName() \ - { \ - ZFile::RegisterNode(#nodeName, &ZResourceFactory_##zResClass_##nodeName); \ - } \ - }; \ - static ZRes_##nodeName inst_ZRes_##nodeName - -#define REGISTER_EXPORTER(expFunc) \ - class ZResExp_##expFunc \ - { \ - public: \ - ZResExp_##expFunc() { expFunc(); } \ - }; \ - static ZResExp_##expFunc inst_ZResExp_##expFunc diff --git a/ZAPDTR/ZAPD/ZRom.cpp b/ZAPDTR/ZAPD/ZRom.cpp deleted file mode 100644 index e9b583b26..000000000 --- a/ZAPDTR/ZAPD/ZRom.cpp +++ /dev/null @@ -1,234 +0,0 @@ -#include "ZRom.h" -#include "Utils/BitConverter.h" -#include -#include "Utils/Directory.h" -#include "yaz0/yaz0.h" - -#ifdef __linux__ -#include -#endif -#include - -namespace fs = std::filesystem; - -#define DMA_ENTRY_SIZE 16 - -#if defined(_MSC_VER) -#define __bswap_32 _byteswap_ulong -#define bswap_32 _byteswap_ulong -#endif -#if defined __APPLE__ -#define __bswap32 __builtin_bswap32 -#define bswap32 __builtin_bswap32 -#endif - -// ROM DMA Table Start -#define OOT_OFF_NTSC_10_RC 0x7430 -#define OOT_OFF_NTSC_10 0x7430 -#define OOT_OFF_NTSC_11 0x7430 -#define OOT_OFF_PAL_10 0x7950 -#define OOT_OFF_NTSC_12 0x7960 -#define OOT_OFF_PAL_11 0x7950 -#define OOT_OFF_JP_GC 0x7170 -#define OOT_OFF_JP_MQ 0x7170 -#define OOT_OFF_US_GC 0x7170 -#define OOT_OFF_US_MQ 0x7170 -#define OOT_OFF_PAL_GC_DBG1 0x12F70 -#define OOT_OFF_PAL_MQ_DBG 0x12F70 -#define OOT_OFF_PAL_GC_DBG2 0x12F70 -#define OOT_OFF_PAL_GC 0x7170 -#define OOT_OFF_PAL_MQ 0x7170 -#define OOT_OFF_JP_GC_CE 007170 -#define OOT_OFF_CN_IQUE 0xB7A0 -#define OOT_OFF_TW_IQUE 0xB240 - -#define MM_OFF_US_10 0x1A500 -#define MM_OFF_JP_10 0x1C110 -#define MM_OFF_JP_11 0x1C050 -#define MM_OFF_DBG 0x24F60 - -#define OOT_NTSC_10 0xEC7011B7 -#define OOT_NTSC_11 0xD43DA81F -#define OOT_NTSC_12 0x693BA2AE -#define OOT_PAL_10 0xB044B569 -#define OOT_PAL_11 0xB2055FBD -#define OOT_NTSC_JP_GC_CE 0xF7F52DB8 -#define OOT_NTSC_JP_GC 0xF611F4BA -#define OOT_NTSC_US_GC 0xF3DD35BA -#define OOT_PAL_GC 0x09465AC3 -#define OOT_NTSC_JP_MQ 0xF43B45BA -#define OOT_NTSC_US_MQ 0xF034001A -#define OOT_PAL_MQ 0x1D4136F3 -#define OOT_PAL_GC_DBG1 0x871E1C92 // 03-21-2002 build -#define OOT_PAL_GC_DBG2 0x87121EFE // 03-13-2002 build -#define OOT_PAL_GC_MQ_DBG 0x917D18F6 -#define OOT_IQUE_TW 0x3D81FB3E -#define OOT_IQUE_CN 0xB1E1E07B -#define UNKNOWN 0xFFFFFFFF - -bool ZRom::IsMQ() { - int crc = BitConverter::ToInt32BE(romData, 0x10); - switch (crc) { - case OOT_NTSC_10: - case OOT_NTSC_11: - case OOT_NTSC_12: - case OOT_PAL_10: - case OOT_PAL_11: - case OOT_NTSC_JP_GC: - case OOT_NTSC_JP_GC_CE: - case OOT_NTSC_US_GC: - case OOT_PAL_GC: - case OOT_PAL_GC_DBG1: - case OOT_PAL_GC_DBG2: - case OOT_IQUE_CN: - case OOT_IQUE_TW: - default: - return false; - case OOT_NTSC_JP_MQ: - case OOT_NTSC_US_MQ: - case OOT_PAL_MQ: - case OOT_PAL_GC_MQ_DBG: - return true; - } -} - -ZRom::ZRom(std::string romPath) -{ - RomVersion version; - romData = DiskFile::ReadAllBytes(romPath); - - BitConverter::RomToBigEndian(romData.data(), romData.size()); - - version.crc = BitConverter::ToInt32BE(romData, 0x10); - - switch (version.crc) - { - case OOT_NTSC_10: - version.version = "N64 NTSC 1.0"; - version.listPath = "ntsc_oot.txt"; - version.offset = OOT_OFF_NTSC_10; - break; - case OOT_NTSC_11: - version.version = "N64 NTSC 1.1"; - version.listPath = "ntsc_oot.txt"; - version.offset = OOT_OFF_NTSC_11; - break; - case OOT_NTSC_12: - version.version = "N64 NTSC 1.2"; - version.listPath = "ntsc_oot.txt"; - version.offset = OOT_OFF_NTSC_12; - break; - case OOT_PAL_10: - version.version = "N64 PAL 1.0"; - version.listPath = "pal_oot.txt"; - version.offset = OOT_OFF_PAL_10; - break; - case OOT_PAL_11: - version.version = "N64 PAL 1.1"; - version.listPath = "pal_oot.txt"; - version.offset = OOT_OFF_PAL_11; - break; - case OOT_NTSC_JP_GC: - version.version = "JP GameCube (MQ Disk)"; - version.listPath = "gamecube.txt"; - version.offset = OOT_OFF_JP_GC; - break; - case OOT_NTSC_JP_GC_CE: - version.version = "GameCube (Collectors Edition Disk)"; - version.listPath = "gamecube.txt"; - version.offset = OOT_OFF_JP_GC_CE; - break; - case OOT_NTSC_JP_MQ: - version.version = "JP Master Quest"; - version.listPath = "gamecube.txt"; - version.offset = OOT_OFF_JP_MQ; - break; - case OOT_NTSC_US_MQ: - version.version = "NTSC Master Quest"; - version.listPath = "gamecube.txt"; - version.offset = OOT_OFF_JP_MQ; - break; - case OOT_NTSC_US_GC: - version.version = "NTSC GameCube"; - version.listPath = "gamecube.txt"; - version.offset = OOT_OFF_US_MQ; - break; - case OOT_PAL_GC: - version.version = "PAL GameCube"; - version.listPath = "gamecube_pal.txt"; - version.offset = OOT_OFF_PAL_GC; - break; - case OOT_PAL_MQ: - version.version = "PAL Master Quest"; - version.listPath = "gamecube_pal.txt"; - version.offset = OOT_OFF_PAL_MQ; - break; - case OOT_PAL_GC_DBG1: - version.version = "GameCube Debug 1.0"; - version.listPath = "dbg.txt"; - version.offset = OOT_OFF_PAL_GC_DBG1; - break; - case OOT_PAL_GC_DBG2: - version.version = "GameCube Debug 2.0"; - version.listPath = "dbg.txt"; - version.offset = OOT_OFF_PAL_GC_DBG2; - break; - case OOT_PAL_GC_MQ_DBG: - version.version = "GameCube MQ-Debug"; - version.listPath = "dbg.txt"; - version.offset = OOT_OFF_PAL_MQ_DBG; - break; - case OOT_IQUE_CN: - version.version = "OoT IQue"; - version.listPath = "ique.txt"; - version.offset = OOT_OFF_CN_IQUE; - break; - case OOT_IQUE_TW: - version.version = "TW IQue"; - version.listPath = "ique.txt"; - version.offset = OOT_OFF_TW_IQUE; - break; - } - - auto path = StringHelper::Sprintf("%s/%s", Globals::Instance->fileListPath.string().c_str(), version.listPath.c_str()); - auto txt = DiskFile::ReadAllText(path); - std::vector lines = StringHelper::Split(txt, "\n"); - - std::vector decompressedData(1); - - for (int i = 0; i < lines.size(); i++) - { - lines[i] = StringHelper::Strip(lines[i], "\r"); - const int romOffset = version.offset + (DMA_ENTRY_SIZE * i); - - const int virtStart = BitConverter::ToInt32BE(romData, romOffset + 0); - const int virtEnd = BitConverter::ToInt32BE(romData, romOffset + 4); - const int physStart = BitConverter::ToInt32BE(romData, romOffset + 8); - const int physEnd = BitConverter::ToInt32BE(romData, romOffset + 12); - - const bool compressed = physEnd != 0; - int size = compressed ? physEnd - physStart : virtEnd - virtStart; - - auto outData = std::vector(); - outData.resize(size); - memcpy(outData.data(), romData.data() + physStart, size); - - if (compressed) - { - int decSize = virtEnd - virtStart; - decompressedData = std::vector(); - decompressedData.resize(decSize); - yaz0_decode(outData.data(), decompressedData.data(), decSize); - files[lines[i]] = decompressedData; - } - else - files[lines[i]] = outData; - - //DiskFile::WriteAllBytes(StringHelper::Sprintf("baserom/%s", lines[i].c_str()), files[lines[i]]); - } -} - -std::vector ZRom::GetFile(std::string fileName) -{ - return files[fileName]; -} diff --git a/ZAPDTR/ZAPD/ZRom.h b/ZAPDTR/ZAPD/ZRom.h deleted file mode 100644 index 6225a1ada..000000000 --- a/ZAPDTR/ZAPD/ZRom.h +++ /dev/null @@ -1,28 +0,0 @@ -#pragma once - -#include -#include -#include -#include - -class ZRom -{ -public: - ZRom(std::string romPath); - - std::vector GetFile(std::string fileName); - bool IsMQ(); - -protected: - std::vector romData; - std::map> files; -}; - -struct RomVersion -{ - std::string version = "None"; - std::string error = "None"; - std::string listPath = "None"; - int offset; - uint32_t crc; -}; \ No newline at end of file diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/EndMarker.cpp b/ZAPDTR/ZAPD/ZRoom/Commands/EndMarker.cpp deleted file mode 100644 index 3f64af168..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/EndMarker.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "EndMarker.h" - -EndMarker::EndMarker(ZFile* nParent) : ZRoomCommand(nParent) -{ -} - -std::string EndMarker::GetBodySourceCode() const -{ - return "SCENE_CMD_END()"; -} - -std::string EndMarker::GetCommandCName() const -{ - return "SCmdEndMarker"; -} - -RoomCommand EndMarker::GetRoomCommand() const -{ - return RoomCommand::EndMarker; -} diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/EndMarker.h b/ZAPDTR/ZAPD/ZRoom/Commands/EndMarker.h deleted file mode 100644 index daa477c94..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/EndMarker.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once - -#include "ZRoom/ZRoomCommand.h" - -class EndMarker : public ZRoomCommand -{ -public: - EndMarker(ZFile* nParent); - - std::string GetBodySourceCode() const override; - std::string GetCommandCName() const override; - RoomCommand GetRoomCommand() const override; -}; \ No newline at end of file diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetActorCutsceneList.cpp b/ZAPDTR/ZAPD/ZRoom/Commands/SetActorCutsceneList.cpp deleted file mode 100644 index ee0183706..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetActorCutsceneList.cpp +++ /dev/null @@ -1,95 +0,0 @@ -#include "SetActorCutsceneList.h" - -#include "Globals.h" -#include "Utils/BitConverter.h" -#include "Utils/StringHelper.h" -#include "ZFile.h" -#include "ZRoom/ZRoom.h" - -SetActorCutsceneList::SetActorCutsceneList(ZFile* nParent) : ZRoomCommand(nParent) -{ -} - -void SetActorCutsceneList::ParseRawData() -{ - ZRoomCommand::ParseRawData(); - int numCutscenes = cmdArg1; - offset_t currentPtr = segmentOffset; - - cutscenes.reserve(numCutscenes); - for (int32_t i = 0; i < numCutscenes; i++) - { - ActorCutsceneEntry entry(parent->GetRawData(), currentPtr); - cutscenes.push_back(entry); - - currentPtr += 16; - } -} - -void SetActorCutsceneList::DeclareReferences(const std::string& prefix) -{ - if (cutscenes.size() > 0) - { - std::string declaration; - - for (size_t i = 0; i < cutscenes.size(); i++) - { - const auto& entry = cutscenes.at(i); - declaration += StringHelper::Sprintf(" { %s },", entry.GetBodySourceCode().c_str()); - - if (i + 1 < cutscenes.size()) - { - declaration += "\n"; - } - } - - std::string typeName = cutscenes.at(0).GetSourceTypeName(); - - parent->AddDeclarationArray( - segmentOffset, GetDeclarationAlignment(), cutscenes.size() * 16, typeName, - StringHelper::Sprintf("%s%sList_%06X", prefix.c_str(), typeName.c_str(), segmentOffset), - cutscenes.size(), declaration); - } -} - -std::string SetActorCutsceneList::GetBodySourceCode() const -{ - std::string listName; - Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "ActorCutscene", listName, - parent->workerID); - return StringHelper::Sprintf("SCENE_CMD_ACTOR_CUTSCENE_LIST(%i, %s)", cutscenes.size(), - listName.c_str()); -} - -std::string SetActorCutsceneList::GetCommandCName() const -{ - return "SCmdCutsceneActorList"; -} - -RoomCommand SetActorCutsceneList::GetRoomCommand() const -{ - return RoomCommand::SetActorCutsceneList; -} - -ActorCutsceneEntry::ActorCutsceneEntry(const std::vector& rawData, uint32_t rawDataIndex) - : priority(BitConverter::ToInt16BE(rawData, rawDataIndex + 0)), - length(BitConverter::ToInt16BE(rawData, rawDataIndex + 2)), - unk4(BitConverter::ToInt16BE(rawData, rawDataIndex + 4)), - unk6(BitConverter::ToInt16BE(rawData, rawDataIndex + 6)), - additionalCutscene(BitConverter::ToInt16BE(rawData, rawDataIndex + 8)), - sound(rawData[rawDataIndex + 0xA]), unkB(rawData[rawDataIndex + 0xB]), - unkC(BitConverter::ToInt16BE(rawData, rawDataIndex + 0xC)), unkE(rawData[rawDataIndex + 0xE]), - letterboxSize(rawData[rawDataIndex + 0xF]) -{ -} - -std::string ActorCutsceneEntry::GetBodySourceCode() const -{ - return StringHelper::Sprintf("%i, %i, %i, %i, %i, %i, %i, %i, %i, %i", priority, length, unk4, - unk6, additionalCutscene, sound, unkB, unkC, unkE, letterboxSize); -} - -std::string ActorCutsceneEntry::GetSourceTypeName() const -{ - return "ActorCutscene"; -} diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetActorCutsceneList.h b/ZAPDTR/ZAPD/ZRoom/Commands/SetActorCutsceneList.h deleted file mode 100644 index 8fd48e425..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetActorCutsceneList.h +++ /dev/null @@ -1,42 +0,0 @@ -#pragma once - -#include "ZRoom/ZRoomCommand.h" - -class ActorCutsceneEntry -{ -protected: - int16_t priority; - int16_t length; - int16_t unk4; - int16_t unk6; - int16_t additionalCutscene; - uint8_t sound; - uint8_t unkB; - int16_t unkC; - uint8_t unkE; - uint8_t letterboxSize; - -public: - ActorCutsceneEntry(const std::vector& rawData, uint32_t rawDataIndex); - - std::string GetBodySourceCode() const; - std::string GetSourceTypeName() const; -}; - -class SetActorCutsceneList : public ZRoomCommand -{ -public: - std::vector cutscenes; - - SetActorCutsceneList(ZFile* nParent); - - void ParseRawData() override; - void DeclareReferences(const std::string& prefix) override; - - std::string GetBodySourceCode() const override; - - std::string GetCommandCName() const override; - RoomCommand GetRoomCommand() const override; - -private: -}; diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetActorList.cpp b/ZAPDTR/ZAPD/ZRoom/Commands/SetActorList.cpp deleted file mode 100644 index 0e667c058..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetActorList.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#include "SetActorList.h" - -#include - -#include "Globals.h" -#include "Utils/BitConverter.h" -#include "Utils/StringHelper.h" -#include "ZRoom/ZRoom.h" - -SetActorList::SetActorList(ZFile* nParent) : ZRoomCommand(nParent) -{ -} - -void SetActorList::ParseRawData() -{ - ZRoomCommand::ParseRawData(); - numActors = cmdArg1; - - actorList = new ZActorList(parent); - actorList->ExtractFromBinary(segmentOffset, numActors); -} - -void SetActorList::DeclareReferences(const std::string& prefix) -{ - if (parent->HasDeclaration(segmentOffset)) - { - delete actorList; - actorList = static_cast(parent->FindResource(segmentOffset)); - assert(actorList != nullptr); - assert(actorList->GetResourceType() == ZResourceType::ActorList); - return; - } - - if (actorList->GetName() == "") - { - actorList->SetName(actorList->GetDefaultName(prefix)); - } - actorList->DeclareVar(prefix, ""); - parent->AddResource(actorList); -} - -std::string SetActorList::GetBodySourceCode() const -{ - std::string listName; - Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "ActorEntry", listName, - parent->workerID); - - return StringHelper::Sprintf("SCENE_CMD_ACTOR_LIST(%i, %s)", numActors, listName.c_str()); -} - -std::string SetActorList::GetCommandCName() const -{ - return "SCmdActorList"; -} - -RoomCommand SetActorList::GetRoomCommand() const -{ - return RoomCommand::SetActorList; -} diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetActorList.h b/ZAPDTR/ZAPD/ZRoom/Commands/SetActorList.h deleted file mode 100644 index 9122c15bb..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetActorList.h +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once - -#include "ZActorList.h" -#include "ZRoom/ZRoomCommand.h" - -class SetActorList : public ZRoomCommand -{ -public: - uint32_t numActors; - ZActorList* actorList = nullptr; - - SetActorList(ZFile* nParent); - - void ParseRawData() override; - void DeclareReferences(const std::string& prefix) override; - - std::string GetBodySourceCode() const override; - - RoomCommand GetRoomCommand() const override; - std::string GetCommandCName() const override; - -protected: - size_t GetActorListArraySize() const; -}; diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetAlternateHeaders.cpp b/ZAPDTR/ZAPD/ZRoom/Commands/SetAlternateHeaders.cpp deleted file mode 100644 index 9e61c6a76..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetAlternateHeaders.cpp +++ /dev/null @@ -1,84 +0,0 @@ -#include "SetAlternateHeaders.h" - -#include "Globals.h" -#include "Utils/BitConverter.h" -#include "Utils/StringHelper.h" -#include "ZFile.h" - -SetAlternateHeaders::SetAlternateHeaders(ZFile* nParent) : ZRoomCommand(nParent) -{ -} - -void SetAlternateHeaders::DeclareReferences([[maybe_unused]] const std::string& prefix) -{ - if (cmdArg2 != 0) - { - std::string varName = - StringHelper::Sprintf("%sAlternateHeaders0x%06X", prefix.c_str(), segmentOffset); - parent->AddDeclarationPlaceholder(segmentOffset, varName); - } -} - -void SetAlternateHeaders::ParseRawDataLate() -{ - size_t numHeaders = zRoom->GetDeclarationSizeFromNeighbor(segmentOffset) / 4; - - headers.reserve(numHeaders); - for (uint32_t i = 0; i < numHeaders; i++) - { - int32_t address = BitConverter::ToInt32BE(parent->GetRawData(), segmentOffset + (i * 4)); - headers.push_back(address); - - if (address != 0 && parent->GetDeclaration(GETSEGOFFSET(address)) == nullptr) - { - ZRoom* altheader = new ZRoom(parent); - altheader->ExtractFromBinary(GETSEGOFFSET(address), zRoom->GetResourceType()); - altheader->DeclareReferences(parent->GetName()); - - parent->resources.push_back(altheader); - } - } -} - -void SetAlternateHeaders::DeclareReferencesLate(const std::string& prefix) -{ - if (!headers.empty()) - { - std::string declaration; - - for (size_t i = 0; i < headers.size(); i++) - { - std::string altHeaderName; - Globals::Instance->GetSegmentedPtrName(headers.at(i), parent, "", altHeaderName, - parent->workerID); - - declaration += StringHelper::Sprintf("\t%s,", altHeaderName.c_str()); - - if (i + 1 < headers.size()) - declaration += "\n"; - } - - std::string varName = - StringHelper::Sprintf("%sAlternateHeaders0x%06X", prefix.c_str(), segmentOffset); - parent->AddDeclarationArray(segmentOffset, GetDeclarationAlignment(), headers.size() * 4, - "SceneCmd*", varName, headers.size(), declaration); - } -} - -std::string SetAlternateHeaders::GetBodySourceCode() const -{ - std::string listName; - Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "SceneCmd*", listName, - parent->workerID); - return StringHelper::Sprintf("SCENE_CMD_ALTERNATE_HEADER_LIST(%s)", listName.c_str()); -} - -std::string SetAlternateHeaders::GetCommandCName() const -{ - return "SCmdAltHeaders"; -} - -RoomCommand SetAlternateHeaders::GetRoomCommand() const -{ - return RoomCommand::SetAlternateHeaders; -} diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetAlternateHeaders.h b/ZAPDTR/ZAPD/ZRoom/Commands/SetAlternateHeaders.h deleted file mode 100644 index e66df936d..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetAlternateHeaders.h +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once - -#include "ZRoom/ZRoom.h" -#include "ZRoom/ZRoomCommand.h" - -class SetAlternateHeaders : public ZRoomCommand -{ -public: - std::vector headers; - - SetAlternateHeaders(ZFile* nParent); - - void DeclareReferences(const std::string& prefix) override; - void ParseRawDataLate() override; - void DeclareReferencesLate(const std::string& prefix) override; - - std::string GetBodySourceCode() const override; - - RoomCommand GetRoomCommand() const override; - std::string GetCommandCName() const override; - -private: -}; diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetAnimatedMaterialList.cpp b/ZAPDTR/ZAPD/ZRoom/Commands/SetAnimatedMaterialList.cpp deleted file mode 100644 index 73f72136c..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetAnimatedMaterialList.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/** - * File: SetAnimatedMaterialList.cpp - * Description: Defines a class SetAnimatedMaterialList to enable ZRoom to declare - * ZTextureAnimations, using that ZResource to do the work. - */ -#include "SetAnimatedMaterialList.h" - -#include "Globals.h" -#include "Utils/BitConverter.h" -#include "Utils/StringHelper.h" -#include "ZFile.h" -#include "ZRoom/ZRoom.h" -#include "ZTextureAnimation.h" - -SetAnimatedMaterialList::SetAnimatedMaterialList(ZFile* nParent) - : ZRoomCommand(nParent), textureAnimation(nParent) -{ -} - -void SetAnimatedMaterialList::ParseRawData() -{ - ZRoomCommand::ParseRawData(); - textureAnimation.ExtractFromFile(segmentOffset); -} - -void SetAnimatedMaterialList::DeclareReferences(const std::string& prefix) -{ - textureAnimation.SetName(textureAnimation.GetDefaultName(prefix.c_str())); - textureAnimation.DeclareReferences(prefix); - textureAnimation.GetSourceOutputCode(prefix); -} - -std::string SetAnimatedMaterialList::GetBodySourceCode() const -{ - std::string listName; - Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "AnimatedMaterial", listName, - parent->workerID); - return StringHelper::Sprintf("SCENE_CMD_ANIMATED_MATERIAL_LIST(%s)", listName.c_str()); -} - -std::string SetAnimatedMaterialList::GetCommandCName() const -{ - return "SCmdTextureAnimations"; -} - -RoomCommand SetAnimatedMaterialList::GetRoomCommand() const -{ - return RoomCommand::SetAnimatedMaterialList; -} diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetAnimatedMaterialList.h b/ZAPDTR/ZAPD/ZRoom/Commands/SetAnimatedMaterialList.h deleted file mode 100644 index 3dbbf9684..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetAnimatedMaterialList.h +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once - -#include "ZRoom/ZRoomCommand.h" -#include "ZTextureAnimation.h" - -class SetAnimatedMaterialList : public ZRoomCommand -{ -public: - SetAnimatedMaterialList(ZFile* nParent); - - void ParseRawData() override; - void DeclareReferences(const std::string& prefix) override; - - std::string GetBodySourceCode() const override; - - RoomCommand GetRoomCommand() const override; - std::string GetCommandCName() const override; - -private: - ZTextureAnimation textureAnimation; -}; diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetCameraSettings.cpp b/ZAPDTR/ZAPD/ZRoom/Commands/SetCameraSettings.cpp deleted file mode 100644 index ae2d31c81..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetCameraSettings.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include "SetCameraSettings.h" - -#include "Utils/BitConverter.h" -#include "Utils/StringHelper.h" - -SetCameraSettings::SetCameraSettings(ZFile* nParent) : ZRoomCommand(nParent) -{ -} - -void SetCameraSettings::ParseRawData() -{ - ZRoomCommand::ParseRawData(); - cameraMovement = cmdArg1; - mapHighlight = BitConverter::ToUInt32BE(parent->GetRawData(), rawDataIndex + 4); -} - -std::string SetCameraSettings::GetBodySourceCode() const -{ - return StringHelper::Sprintf("SCENE_CMD_MISC_SETTINGS(0x%02X, 0x%08X)", cameraMovement, - mapHighlight); -} - -std::string SetCameraSettings::GetCommandCName() const -{ - return "SCmdMiscSettings"; -} - -RoomCommand SetCameraSettings::GetRoomCommand() const -{ - return RoomCommand::SetCameraSettings; -} diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetCameraSettings.h b/ZAPDTR/ZAPD/ZRoom/Commands/SetCameraSettings.h deleted file mode 100644 index a8fed44ec..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetCameraSettings.h +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once - -#include "ZRoom/ZRoomCommand.h" - -class SetCameraSettings : public ZRoomCommand -{ -public: - uint8_t cameraMovement; - uint32_t mapHighlight; - - SetCameraSettings(ZFile* nParent); - - void ParseRawData() override; - - std::string GetBodySourceCode() const override; - - std::string GetCommandCName() const override; - RoomCommand GetRoomCommand() const override; - -private: -}; diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetCollisionHeader.cpp b/ZAPDTR/ZAPD/ZRoom/Commands/SetCollisionHeader.cpp deleted file mode 100644 index 4aafb7c70..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetCollisionHeader.cpp +++ /dev/null @@ -1,45 +0,0 @@ -#include "SetCollisionHeader.h" - -#include "Globals.h" -#include "Utils/BitConverter.h" -#include "Utils/StringHelper.h" -#include "ZFile.h" -#include "ZRoom/ZRoom.h" - -SetCollisionHeader::SetCollisionHeader(ZFile* nParent) : ZRoomCommand(nParent) -{ -} - -void SetCollisionHeader::ParseRawData() -{ - ZRoomCommand::ParseRawData(); - - collisionHeader = new ZCollisionHeader(parent); - collisionHeader->SetName( - StringHelper::Sprintf("%sCollisionHeader_%06X", parent->GetName().c_str(), segmentOffset)); - collisionHeader->ExtractFromFile(segmentOffset); - parent->AddResource(collisionHeader); -} - -void SetCollisionHeader::DeclareReferences(const std::string& prefix) -{ - collisionHeader->DeclareVar(prefix, ""); -} - -std::string SetCollisionHeader::GetBodySourceCode() const -{ - std::string listName; - Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "CollisionHeader", listName, - parent->workerID); - return StringHelper::Sprintf("SCENE_CMD_COL_HEADER(%s)", listName.c_str()); -} - -std::string SetCollisionHeader::GetCommandCName() const -{ - return "SCmdColHeader"; -} - -RoomCommand SetCollisionHeader::GetRoomCommand() const -{ - return RoomCommand::SetCollisionHeader; -} diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetCollisionHeader.h b/ZAPDTR/ZAPD/ZRoom/Commands/SetCollisionHeader.h deleted file mode 100644 index f7d5ecf35..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetCollisionHeader.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once - -#include "ZCollision.h" -#include "ZRoom/ZRoomCommand.h" - -class SetCollisionHeader : public ZRoomCommand -{ -public: - ZCollisionHeader* collisionHeader; - - SetCollisionHeader(ZFile* nParent); - - void ParseRawData() override; - void DeclareReferences(const std::string& prefix) override; - - std::string GetBodySourceCode() const override; - - std::string GetCommandCName() const override; - RoomCommand GetRoomCommand() const override; -}; diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetCsCamera.cpp b/ZAPDTR/ZAPD/ZRoom/Commands/SetCsCamera.cpp deleted file mode 100644 index 5a9ae128e..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetCsCamera.cpp +++ /dev/null @@ -1,155 +0,0 @@ -#include "SetCsCamera.h" - -#include "Globals.h" -#include "Utils/BitConverter.h" -#include "Utils/StringHelper.h" -#include "ZFile.h" -#include "ZRoom/ZRoom.h" - -SetCsCamera::SetCsCamera(ZFile* nParent) : ZRoomCommand(nParent) -{ -} - -void SetCsCamera::ParseRawData() -{ - ZRoomCommand::ParseRawData(); - int numCameras = cmdArg1; - - uint32_t currentPtr = segmentOffset; - int32_t numPoints = 0; - - cameras.reserve(numCameras); - for (int32_t i = 0; i < numCameras; i++) - { - CsCameraEntry entry(parent->GetRawData(), currentPtr); - numPoints += entry.GetNumPoints(); - - currentPtr += entry.GetRawDataSize(); - cameras.push_back(entry); - } - - if (numPoints > 0) - { - uint32_t currentPtr = cameras.at(0).GetSegmentOffset(); - - points.reserve(numPoints); - for (int32_t i = 0; i < numPoints; i++) - { - ZVector vec(parent); - vec.ExtractFromBinary(currentPtr, ZScalarType::ZSCALAR_S16, 3); - - currentPtr += vec.GetRawDataSize(); - points.push_back(vec); - } - } -} - -void SetCsCamera::DeclareReferences(const std::string& prefix) -{ - if (points.size() > 0) - { - std::string declaration; - size_t index = 0; - for (auto& point : points) - { - declaration += StringHelper::Sprintf("\t{ %s },", point.GetBodySourceCode().c_str()); - - if (index < points.size() - 1) - declaration += "\n"; - - index++; - } - - uint32_t segOffset = cameras.at(0).GetSegmentOffset(); - - parent->AddDeclarationArray( - segOffset, DeclarationAlignment::Align4, points.size() * points.at(0).GetRawDataSize(), - points.at(0).GetSourceTypeName().c_str(), - StringHelper::Sprintf("%sCsCameraPoints_%06X", prefix.c_str(), segOffset), - points.size(), declaration); - } - - if (!cameras.empty()) - { - std::string camPointsName; - Globals::Instance->GetSegmentedPtrName(cameras.at(0).GetCamAddress(), parent, "Vec3s", - camPointsName, parent->workerID); - std::string declaration; - - size_t index = 0; - size_t pointsIndex = 0; - for (const auto& entry : cameras) - { - declaration += - StringHelper::Sprintf("\t{ %i, %i, &%s[%i] },", entry.type, entry.numPoints, - camPointsName.c_str(), pointsIndex); - - if (index < cameras.size() - 1) - declaration += "\n"; - - index++; - pointsIndex += entry.GetNumPoints(); - } - - const auto& entry = cameras.front(); - std::string camTypename = entry.GetSourceTypeName(); - - parent->AddDeclarationArray( - segmentOffset, DeclarationAlignment::Align4, cameras.size() * entry.GetRawDataSize(), - camTypename, - StringHelper::Sprintf("%s%s_%06X", prefix.c_str(), camTypename.c_str(), segmentOffset), - cameras.size(), declaration); - } -} - -std::string SetCsCamera::GetBodySourceCode() const -{ - std::string listName; - Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "CsCameraEntry", listName, - parent->workerID); - return StringHelper::Sprintf("SCENE_CMD_ACTOR_CUTSCENE_CAM_LIST(%i, %s)", cameras.size(), - listName.c_str()); -} - -std::string SetCsCamera::GetCommandCName() const -{ - return "SCmdCsCameraList"; -} - -RoomCommand SetCsCamera::GetRoomCommand() const -{ - return RoomCommand::SetCsCamera; -} - -CsCameraEntry::CsCameraEntry(const std::vector& rawData, uint32_t rawDataIndex) - : baseOffset(rawDataIndex), type(BitConverter::ToInt16BE(rawData, rawDataIndex + 0)), - numPoints(BitConverter::ToInt16BE(rawData, rawDataIndex + 2)) -{ - camAddress = BitConverter::ToInt32BE(rawData, rawDataIndex + 4); - segmentOffset = GETSEGOFFSET(camAddress); -} - -std::string CsCameraEntry::GetSourceTypeName() const -{ - return "CsCameraEntry"; -} - -int32_t CsCameraEntry::GetRawDataSize() const -{ - return 8; -} - -int16_t CsCameraEntry::GetNumPoints() const -{ - return numPoints; -} - -segptr_t CsCameraEntry::GetCamAddress() const -{ - return camAddress; -} - -uint32_t CsCameraEntry::GetSegmentOffset() const -{ - return segmentOffset; -} diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetCsCamera.h b/ZAPDTR/ZAPD/ZRoom/Commands/SetCsCamera.h deleted file mode 100644 index 5e0e3c825..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetCsCamera.h +++ /dev/null @@ -1,40 +0,0 @@ -#pragma once - -#include "ZRoom/ZRoomCommand.h" -#include "ZVector.h" - -class CsCameraEntry -{ -public: - CsCameraEntry(const std::vector& rawData, uint32_t rawDataIndex); - - std::string GetSourceTypeName() const; - int32_t GetRawDataSize() const; - - int16_t GetNumPoints() const; - segptr_t GetCamAddress() const; - uint32_t GetSegmentOffset() const; - - int baseOffset; - int16_t type; - int16_t numPoints; - segptr_t camAddress; - uint32_t segmentOffset; -}; - -class SetCsCamera : public ZRoomCommand -{ -public: - std::vector cameras; - std::vector points; - - SetCsCamera(ZFile* nParent); - - void ParseRawData() override; - void DeclareReferences(const std::string& prefix) override; - - std::string GetBodySourceCode() const override; - - RoomCommand GetRoomCommand() const override; - std::string GetCommandCName() const override; -}; diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetCutscenes.cpp b/ZAPDTR/ZAPD/ZRoom/Commands/SetCutscenes.cpp deleted file mode 100644 index 68ff58c19..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetCutscenes.cpp +++ /dev/null @@ -1,146 +0,0 @@ -#include "SetCutscenes.h" - -#include "Globals.h" -#include "Utils/BitConverter.h" -#include "Utils/StringHelper.h" -#include "ZFile.h" -#include "ZRoom/ZRoom.h" - -SetCutscenes::SetCutscenes(ZFile* nParent) : ZRoomCommand(nParent) -{ -} - -void SetCutscenes::ParseRawData() -{ - ZRoomCommand::ParseRawData(); - - numCutscenes = cmdArg1; - - if (Globals::Instance->game == ZGame::MM_RETAIL) - { - int32_t currentPtr = segmentOffset; - - cutsceneEntries.reserve(numCutscenes); - for (uint8_t i = 0; i < numCutscenes; i++) - { - CutsceneEntry entry(parent->GetRawData(), currentPtr); - cutsceneEntries.push_back(entry); - currentPtr += 8; - } - } - else if (Globals::Instance->game == ZGame::OOT_RETAIL || Globals::Instance->game == ZGame::OOT_SW97) - { - ZCutscene* cutscene = new ZCutscene(parent); - cutscene->ExtractFromFile(segmentOffset); - - auto decl = parent->GetDeclaration(segmentOffset); - if (decl == nullptr) - { - cutscene->DeclareVar(zRoom->GetName().c_str(), ""); - } - - cutscenes.push_back(cutscene); - } -} - -void SetCutscenes::DeclareReferences(const std::string& prefix) -{ - std::string varPrefix = name; - if (varPrefix == "") - varPrefix = prefix; - - if (Globals::Instance->game == ZGame::MM_RETAIL) - { - std::string declaration; - size_t i = 0; - - for (const auto& entry : cutsceneEntries) - { - if (entry.segmentPtr != SEGMENTED_NULL && - GETSEGNUM(entry.segmentPtr) == parent->segment) - { - offset_t csOffset = Seg2Filespace(entry.segmentPtr, parent->baseAddress); - if (!parent->HasDeclaration(csOffset)) - { - auto* cutscene = new ZCutscene(parent); - cutscene->ExtractFromFile(csOffset); - cutscene->SetName(cutscene->GetDefaultName(varPrefix)); - cutscene->DeclareVar(varPrefix, ""); - cutscene->DeclareReferences(varPrefix); - parent->AddResource(cutscene); - } - } - - std::string csName; - Globals::Instance->GetSegmentedPtrName(entry.segmentPtr, parent, "CutsceneData", - csName, parent->workerID); - - declaration += - StringHelper::Sprintf(" { %s, 0x%04X, 0x%02X, 0x%02X },", csName.c_str(), - entry.exit, entry.entrance, entry.flag); - - if (i + 1 < numCutscenes) - declaration += "\n"; - - i++; - } - - parent->AddDeclarationArray(segmentOffset, DeclarationAlignment::Align4, - cutsceneEntries.size() * 8, "CutsceneEntry", - StringHelper::Sprintf("%sCutsceneEntryList_%06X", - zRoom->GetName().c_str(), segmentOffset), - cutsceneEntries.size(), declaration); - } - else - { - if (cmdArg2 != SEGMENTED_NULL && GETSEGNUM(cmdArg2) == parent->segment) - { - offset_t csOffset = Seg2Filespace(cmdArg2, parent->baseAddress); - if (!parent->HasDeclaration(csOffset)) - { - auto* cutscene = new ZCutscene(parent); - cutscene->ExtractFromFile(csOffset); - cutscene->SetName(cutscene->GetDefaultName(varPrefix)); - cutscene->DeclareVar(varPrefix, ""); - cutscene->DeclareReferences(varPrefix); - parent->AddResource(cutscene); - } - } - } -} - -std::string SetCutscenes::GetBodySourceCode() const -{ - std::string listName; - Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "CutsceneData", listName, - parent->workerID); - - if (Globals::Instance->game == ZGame::MM_RETAIL) - { - Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "CutsceneEntry", listName, - parent->workerID); - return StringHelper::Sprintf("SCENE_CMD_CUTSCENE_LIST(%i, %s)", numCutscenes, - listName.c_str()); - } - - Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "CutsceneData", listName, - parent->workerID); - return StringHelper::Sprintf("SCENE_CMD_CUTSCENE_DATA(%s)", listName.c_str()); -} - -std::string SetCutscenes::GetCommandCName() const -{ - return "SCmdCutsceneData"; -} - -RoomCommand SetCutscenes::GetRoomCommand() const -{ - return RoomCommand::SetCutscenes; -} - -CutsceneEntry::CutsceneEntry(const std::vector& rawData, uint32_t rawDataIndex) - : segmentPtr(BitConverter::ToInt32BE(rawData, rawDataIndex + 0)), - exit(BitConverter::ToInt16BE(rawData, rawDataIndex + 4)), entrance(rawData[rawDataIndex + 6]), - flag(rawData[rawDataIndex + 7]) -{ -} diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetCutscenes.h b/ZAPDTR/ZAPD/ZRoom/Commands/SetCutscenes.h deleted file mode 100644 index b1d175fec..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetCutscenes.h +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once - -#include "ZCutscene.h" -#include "ZRoom/ZRoomCommand.h" - -class CutsceneEntry -{ -public: - CutsceneEntry(const std::vector& rawData, uint32_t rawDataIndex); - - segptr_t segmentPtr; - uint16_t exit; - uint8_t entrance; - uint8_t flag; -}; - -class SetCutscenes : public ZRoomCommand -{ -public: - std::vector cutscenes; - std::vector cutsceneEntries; // (MM Only) - uint8_t numCutscenes; // (MM Only) - - SetCutscenes(ZFile* nParent); - - void ParseRawData() override; - void DeclareReferences(const std::string& prefix) override; - - std::string GetBodySourceCode() const override; - - RoomCommand GetRoomCommand() const override; - std::string GetCommandCName() const override; -}; diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetEchoSettings.cpp b/ZAPDTR/ZAPD/ZRoom/Commands/SetEchoSettings.cpp deleted file mode 100644 index 79a278bc6..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetEchoSettings.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "SetEchoSettings.h" -#include "Utils/StringHelper.h" - -SetEchoSettings::SetEchoSettings(ZFile* nParent) : ZRoomCommand(nParent) -{ -} - -void SetEchoSettings::ParseRawData() -{ - ZRoomCommand::ParseRawData(); - echo = parent->GetRawData().at(rawDataIndex + 0x07); -} - -std::string SetEchoSettings::GetBodySourceCode() const -{ - return StringHelper::Sprintf("SCENE_CMD_ECHO_SETTINGS(%i)", echo); -} - -std::string SetEchoSettings::GetCommandCName() const -{ - return "SCmdEchoSettings"; -} - -RoomCommand SetEchoSettings::GetRoomCommand() const -{ - return RoomCommand::SetEchoSettings; -} diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetEchoSettings.h b/ZAPDTR/ZAPD/ZRoom/Commands/SetEchoSettings.h deleted file mode 100644 index 82b8c27db..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetEchoSettings.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once - -#include "ZRoom/ZRoomCommand.h" - -class SetEchoSettings : public ZRoomCommand -{ -public: - uint8_t echo; - - SetEchoSettings(ZFile* nParent); - - void ParseRawData() override; - - std::string GetBodySourceCode() const override; - - std::string GetCommandCName() const override; - RoomCommand GetRoomCommand() const override; -}; diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetEntranceList.cpp b/ZAPDTR/ZAPD/ZRoom/Commands/SetEntranceList.cpp deleted file mode 100644 index 6749e1770..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetEntranceList.cpp +++ /dev/null @@ -1,91 +0,0 @@ -#include "SetEntranceList.h" - -#include "Globals.h" -#include "SetStartPositionList.h" -#include "Utils/BitConverter.h" -#include "Utils/StringHelper.h" -#include "ZFile.h" -#include "ZRoom/ZRoom.h" - -SetEntranceList::SetEntranceList(ZFile* nParent) : ZRoomCommand(nParent) -{ -} - -void SetEntranceList::DeclareReferences([[maybe_unused]] const std::string& prefix) -{ - if (segmentOffset != 0) - { - std::string varName = - StringHelper::Sprintf("%sEntranceList0x%06X", prefix.c_str(), segmentOffset); - parent->AddDeclarationPlaceholder(segmentOffset, varName); - } -} - -void SetEntranceList::ParseRawDataLate() -{ - // Parse Entrances and Generate Declaration - uint32_t numEntrances = zRoom->GetDeclarationSizeFromNeighbor(segmentOffset) / 2; - uint32_t currentPtr = segmentOffset; - - entrances.reserve(numEntrances); - for (uint32_t i = 0; i < numEntrances; i++) - { - EntranceEntry entry(parent->GetRawData(), currentPtr); - entrances.push_back(entry); - - currentPtr += 2; - } -} - -void SetEntranceList::DeclareReferencesLate([[maybe_unused]] const std::string& prefix) -{ - if (!entrances.empty()) - { - std::string declaration; - - size_t index = 0; - for (const auto& entry : entrances) - { - declaration += StringHelper::Sprintf(" { %s },", entry.GetBodySourceCode().c_str()); - if (index + 1 < entrances.size()) - declaration += "\n"; - - index++; - } - - std::string varName = - StringHelper::Sprintf("%sEntranceList0x%06X", prefix.c_str(), segmentOffset); - parent->AddDeclarationArray(segmentOffset, DeclarationAlignment::Align4, - entrances.size() * 2, "EntranceEntry", varName, - entrances.size(), declaration); - } -} - -std::string SetEntranceList::GetBodySourceCode() const -{ - std::string listName; - Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "EntranceEntry", listName, - parent->workerID); - return StringHelper::Sprintf("SCENE_CMD_ENTRANCE_LIST(%s)", listName.c_str()); -} - -std::string SetEntranceList::GetCommandCName() const -{ - return "SCmdEntranceList"; -} - -RoomCommand SetEntranceList::GetRoomCommand() const -{ - return RoomCommand::SetEntranceList; -} - -EntranceEntry::EntranceEntry(const std::vector& rawData, uint32_t rawDataIndex) -{ - startPositionIndex = rawData.at(rawDataIndex + 0); - roomToLoad = rawData.at(rawDataIndex + 1); -} - -std::string EntranceEntry::GetBodySourceCode() const -{ - return StringHelper::Sprintf("0x%02X, 0x%02X", startPositionIndex, roomToLoad); -} diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetEntranceList.h b/ZAPDTR/ZAPD/ZRoom/Commands/SetEntranceList.h deleted file mode 100644 index e13e9a8ce..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetEntranceList.h +++ /dev/null @@ -1,31 +0,0 @@ -#pragma once - -#include "ZRoom/ZRoomCommand.h" - -class EntranceEntry -{ -public: - uint8_t startPositionIndex; - uint8_t roomToLoad; - - EntranceEntry(const std::vector& rawData, uint32_t rawDataIndex); - - std::string GetBodySourceCode() const; -}; - -class SetEntranceList : public ZRoomCommand -{ -public: - std::vector entrances; - - SetEntranceList(ZFile* nParent); - - void DeclareReferences(const std::string& prefix) override; - void ParseRawDataLate() override; - void DeclareReferencesLate(const std::string& prefix) override; - - std::string GetBodySourceCode() const override; - - RoomCommand GetRoomCommand() const override; - std::string GetCommandCName() const override; -}; diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetExitList.cpp b/ZAPDTR/ZAPD/ZRoom/Commands/SetExitList.cpp deleted file mode 100644 index 3b9ce2dfa..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetExitList.cpp +++ /dev/null @@ -1,76 +0,0 @@ -#include "SetExitList.h" - -#include "Globals.h" -#include "Utils/BitConverter.h" -#include "Utils/StringHelper.h" -#include "ZFile.h" -#include "ZRoom/ZNames.h" -#include "ZRoom/ZRoom.h" - -SetExitList::SetExitList(ZFile* nParent) : ZRoomCommand(nParent) -{ -} - -void SetExitList::DeclareReferences([[maybe_unused]] const std::string& prefix) -{ - if (segmentOffset != 0) - { - std::string varName = - StringHelper::Sprintf("%sExitList_%06X", prefix.c_str(), segmentOffset); - parent->AddDeclarationPlaceholder(segmentOffset, varName); - } -} - -void SetExitList::ParseRawDataLate() -{ - // Parse Entrances and Generate Declaration - uint32_t numEntrances = zRoom->GetDeclarationSizeFromNeighbor(segmentOffset) / 2; - uint32_t currentPtr = segmentOffset; - - exits.reserve(numEntrances); - for (uint32_t i = 0; i < numEntrances; i++) - { - uint16_t exit = BitConverter::ToUInt16BE(parent->GetRawData(), currentPtr); - exits.push_back(exit); - - currentPtr += 2; - } -} - -void SetExitList::DeclareReferencesLate([[maybe_unused]] const std::string& prefix) -{ - if (!exits.empty()) - { - std::string declaration; - - for (size_t i = 0; i < exits.size(); i++) - { - declaration += - StringHelper::Sprintf(" %s,", ZNames::GetEntranceName(exits[i]).c_str()); - if (i + 1 < exits.size()) - declaration += "\n"; - } - - std::string varName = - StringHelper::Sprintf("%sExitList_%06X", prefix.c_str(), segmentOffset); - parent->AddDeclarationArray(segmentOffset, DeclarationAlignment::Align4, exits.size() * 2, - "u16", varName, exits.size(), declaration); - } -} - -std::string SetExitList::GetBodySourceCode() const -{ - std::string listName; - Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "u16", listName, parent->workerID); - return StringHelper::Sprintf("SCENE_CMD_EXIT_LIST(%s)", listName.c_str()); -} - -std::string SetExitList::GetCommandCName() const -{ - return "SCmdExitList"; -} - -RoomCommand SetExitList::GetRoomCommand() const -{ - return RoomCommand::SetExitList; -} diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetExitList.h b/ZAPDTR/ZAPD/ZRoom/Commands/SetExitList.h deleted file mode 100644 index 9d2791a83..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetExitList.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once - -#include "ZRoom/ZRoomCommand.h" - -class SetExitList : public ZRoomCommand -{ -public: - std::vector exits; - - SetExitList(ZFile* nParent); - - void DeclareReferences(const std::string& prefix) override; - void ParseRawDataLate() override; - void DeclareReferencesLate(const std::string& prefix) override; - - std::string GetBodySourceCode() const override; - - RoomCommand GetRoomCommand() const override; - std::string GetCommandCName() const override; -}; diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetLightList.cpp b/ZAPDTR/ZAPD/ZRoom/Commands/SetLightList.cpp deleted file mode 100644 index 4c551be13..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetLightList.cpp +++ /dev/null @@ -1,100 +0,0 @@ -#include "SetLightList.h" - -#include "Globals.h" -#include "Utils/BitConverter.h" -#include "Utils/StringHelper.h" - -SetLightList::SetLightList(ZFile* nParent) : ZRoomCommand(nParent) -{ -} - -void SetLightList::ParseRawData() -{ - ZRoomCommand::ParseRawData(); - std::string declarations; - - numLights = cmdArg1; - int32_t currentPtr = segmentOffset; - - lights.reserve(this->numLights); - for (int i = 0; i < this->numLights; i++) - { - LightInfo light(parent->GetRawData(), currentPtr); - - currentPtr += light.GetRawDataSize(); - lights.push_back(light); - } -} - -void SetLightList::DeclareReferences(const std::string& prefix) -{ - if (!lights.empty()) - { - std::string declarations; - - for (size_t i = 0; i < lights.size(); i++) - { - declarations += - StringHelper::Sprintf("\t{ %s },", lights.at(i).GetBodySourceCode().c_str()); - - if (i < lights.size() - 1) - declarations += "\n"; - } - - const auto& light = lights.front(); - - parent->AddDeclarationArray( - segmentOffset, DeclarationAlignment::Align4, lights.size() * light.GetRawDataSize(), - light.GetSourceTypeName(), - StringHelper::Sprintf("%sLightInfo0x%06X", prefix.c_str(), segmentOffset), - lights.size(), declarations); - } -} - -std::string SetLightList::GetBodySourceCode() const -{ - std::string listName; - Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "LightInfo", listName, - parent->workerID); - return StringHelper::Sprintf("SCENE_CMD_LIGHT_LIST(%i, %s)", numLights, listName.c_str()); -} - -std::string SetLightList::GetCommandCName() const -{ - return "SCmdLightList"; -} - -RoomCommand SetLightList::GetRoomCommand() const -{ - return RoomCommand::SetLightList; -} - -LightInfo::LightInfo(const std::vector& rawData, uint32_t rawDataIndex) -{ - type = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0); - x = BitConverter::ToInt16BE(rawData, rawDataIndex + 2); - y = BitConverter::ToInt16BE(rawData, rawDataIndex + 4); - z = BitConverter::ToInt16BE(rawData, rawDataIndex + 6); - r = BitConverter::ToUInt8BE(rawData, rawDataIndex + 8); - g = BitConverter::ToUInt8BE(rawData, rawDataIndex + 9); - b = BitConverter::ToUInt8BE(rawData, rawDataIndex + 10); - drawGlow = BitConverter::ToUInt8BE(rawData, rawDataIndex + 11); - radius = BitConverter::ToInt16BE(rawData, rawDataIndex + 12); -} - -std::string LightInfo::GetBodySourceCode() const -{ - return StringHelper::Sprintf( - "0x%02X, { %i, %i, %i, { 0x%02X, 0x%02X, 0x%02X }, 0x%02X, 0x%04X }", type, x, y, z, r, g, - b, drawGlow, radius); -} - -std::string LightInfo::GetSourceTypeName() const -{ - return "LightInfo"; -} - -size_t LightInfo::GetRawDataSize() const -{ - return 0x0E; -} diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetLightList.h b/ZAPDTR/ZAPD/ZRoom/Commands/SetLightList.h deleted file mode 100644 index 894a21530..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetLightList.h +++ /dev/null @@ -1,42 +0,0 @@ -#pragma once - -#include - -#include "ZFile.h" -#include "ZRoom/ZRoom.h" -#include "ZRoom/ZRoomCommand.h" - -class LightInfo -{ -public: - LightInfo(const std::vector& rawData, uint32_t rawDataIndex); - - std::string GetBodySourceCode() const; - - std::string GetSourceTypeName() const; - size_t GetRawDataSize() const; - -public: - uint8_t type; - int16_t x, y, z; - uint8_t r, g, b; - uint8_t drawGlow; - int16_t radius; -}; - -class SetLightList : public ZRoomCommand -{ -public: - uint8_t numLights; - std::vector lights; - - SetLightList(ZFile* nParent); - - void ParseRawData() override; - void DeclareReferences(const std::string& prefix) override; - - std::string GetBodySourceCode() const override; - - RoomCommand GetRoomCommand() const override; - std::string GetCommandCName() const override; -}; diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetLightingSettings.cpp b/ZAPDTR/ZAPD/ZRoom/Commands/SetLightingSettings.cpp deleted file mode 100644 index 547862a52..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetLightingSettings.cpp +++ /dev/null @@ -1,107 +0,0 @@ -#include "SetLightingSettings.h" - -#include "Globals.h" -#include "Utils/BitConverter.h" -#include "Utils/StringHelper.h" -#include "ZFile.h" -#include "ZRoom/ZRoom.h" - -SetLightingSettings::SetLightingSettings(ZFile* nParent) : ZRoomCommand(nParent) -{ -} - -void SetLightingSettings::ParseRawData() -{ - ZRoomCommand::ParseRawData(); - uint8_t numLights = cmdArg1; - - settings.reserve(numLights); - for (int i = 0; i < numLights; i++) - settings.push_back(LightingSettings(parent->GetRawData(), segmentOffset + (i * 22))); -} - -void SetLightingSettings::DeclareReferences(const std::string& prefix) -{ - if (settings.size() > 0) - { - std::string declaration; - - for (size_t i = 0; i < settings.size(); i++) - { - declaration += - StringHelper::Sprintf("\t{ %s },", settings.at(i).GetBodySourceCode().c_str()); - if (i + 1 < settings.size()) - declaration += "\n"; - } - - parent->AddDeclarationArray( - segmentOffset, DeclarationAlignment::Align4, - settings.size() * settings.front().GetRawDataSize(), "LightSettings", - StringHelper::Sprintf("%sLightSettings0x%06X", prefix.c_str(), segmentOffset), - settings.size(), declaration); - } -} - -std::string SetLightingSettings::GetBodySourceCode() const -{ - std::string listName; - Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "LightSettings", listName, - parent->workerID); - return StringHelper::Sprintf("SCENE_CMD_ENV_LIGHT_SETTINGS(%i, %s)", settings.size(), - listName.c_str()); -} - -std::string SetLightingSettings::GetCommandCName() const -{ - return "SCmdLightSettingList"; -} - -RoomCommand SetLightingSettings::GetRoomCommand() const -{ - return RoomCommand::SetLightingSettings; -} - -LightingSettings::LightingSettings(const std::vector& rawData, uint32_t rawDataIndex) -{ - ambientClrR = rawData.at(rawDataIndex + 0); - ambientClrG = rawData.at(rawDataIndex + 1); - ambientClrB = rawData.at(rawDataIndex + 2); - - diffuseClrA_R = rawData.at(rawDataIndex + 3); - diffuseClrA_G = rawData.at(rawDataIndex + 4); - diffuseClrA_B = rawData.at(rawDataIndex + 5); - - diffuseDirA_X = rawData.at(rawDataIndex + 6); - diffuseDirA_Y = rawData.at(rawDataIndex + 7); - diffuseDirA_Z = rawData.at(rawDataIndex + 8); - - diffuseClrB_R = rawData.at(rawDataIndex + 9); - diffuseClrB_G = rawData.at(rawDataIndex + 10); - diffuseClrB_B = rawData.at(rawDataIndex + 11); - - diffuseDirB_X = rawData.at(rawDataIndex + 12); - diffuseDirB_Y = rawData.at(rawDataIndex + 13); - diffuseDirB_Z = rawData.at(rawDataIndex + 14); - - fogClrR = rawData.at(rawDataIndex + 15); - fogClrG = rawData.at(rawDataIndex + 16); - fogClrB = rawData.at(rawDataIndex + 17); - - unk = BitConverter::ToInt16BE(rawData, rawDataIndex + 18); - drawDistance = BitConverter::ToInt16BE(rawData, rawDataIndex + 20); -} - -std::string LightingSettings::GetBodySourceCode() const -{ - return StringHelper::Sprintf( - "0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, " - "0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%04X, 0x%04X", - ambientClrR, ambientClrG, ambientClrB, diffuseClrA_R, diffuseClrA_G, diffuseClrA_B, - diffuseDirA_X, diffuseDirA_Y, diffuseDirA_Z, diffuseClrB_R, diffuseClrB_G, diffuseClrB_B, - diffuseDirB_X, diffuseDirB_Y, diffuseDirB_Z, fogClrR, fogClrG, fogClrB, unk, drawDistance); -} - -size_t LightingSettings::GetRawDataSize() const -{ - return 0x16; -} diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetLightingSettings.h b/ZAPDTR/ZAPD/ZRoom/Commands/SetLightingSettings.h deleted file mode 100644 index 29caf4aa6..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetLightingSettings.h +++ /dev/null @@ -1,38 +0,0 @@ -#pragma once - -#include "ZRoom/ZRoomCommand.h" - -class LightingSettings -{ -public: - uint8_t ambientClrR, ambientClrG, ambientClrB; - uint8_t diffuseClrA_R, diffuseClrA_G, diffuseClrA_B; - uint8_t diffuseDirA_X, diffuseDirA_Y, diffuseDirA_Z; - uint8_t diffuseClrB_R, diffuseClrB_G, diffuseClrB_B; - uint8_t diffuseDirB_X, diffuseDirB_Y, diffuseDirB_Z; - uint8_t fogClrR, fogClrG, fogClrB; - uint16_t unk; - uint16_t drawDistance; - - LightingSettings(const std::vector& rawData, uint32_t rawDataIndex); - - std::string GetBodySourceCode() const; - - size_t GetRawDataSize() const; -}; - -class SetLightingSettings : public ZRoomCommand -{ -public: - std::vector settings; - - SetLightingSettings(ZFile* nParent); - - void ParseRawData() override; - void DeclareReferences(const std::string& prefix) override; - - std::string GetBodySourceCode() const override; - - RoomCommand GetRoomCommand() const override; - std::string GetCommandCName() const override; -}; diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetMesh.cpp b/ZAPDTR/ZAPD/ZRoom/Commands/SetMesh.cpp deleted file mode 100644 index c6f2d7dca..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetMesh.cpp +++ /dev/null @@ -1,616 +0,0 @@ -#include "SetMesh.h" - -#include "Globals.h" -#include "Utils/BitConverter.h" -#include "Utils/Path.h" -#include "Utils/StringHelper.h" -#include "WarningHandler.h" -#include "ZBackground.h" -#include "ZFile.h" -#include "ZRoom/ZRoom.h" - -void GenDListDeclarations(ZRoom* zRoom, ZFile* parent, ZDisplayList* dList); - -SetMesh::SetMesh(ZFile* nParent) : ZRoomCommand(nParent) -{ -} - -void SetMesh::ParseRawData() -{ - ZRoomCommand::ParseRawData(); - auto& parentRawData = parent->GetRawData(); - meshHeaderType = parentRawData.at(segmentOffset); - - switch (meshHeaderType) - { - case 0: - polyType = std::make_shared(parent, segmentOffset, zRoom); - break; - - case 1: - polyType = std::make_shared(parent, segmentOffset, zRoom); - break; - - case 2: - polyType = std::make_shared(parent, segmentOffset, zRoom); - break; - - default: - HANDLE_ERROR(WarningType::InvalidExtractedData, - StringHelper::Sprintf("unknown meshHeaderType: %i", meshHeaderType), ""); - } - - polyType->ParseRawData(); -} - -void SetMesh::DeclareReferences(const std::string& prefix) -{ - polyType->SetName(polyType->GetDefaultName(prefix)); - polyType->DeclareReferences(prefix); - polyType->DeclareAndGenerateOutputCode(prefix); -} - -// TODO: is this really needed? -void GenDListDeclarations(ZRoom* zRoom, ZFile* parent, ZDisplayList* dList) -{ - if (dList == nullptr) - return; - - dList->DeclareReferences(zRoom->GetName()); - - for (ZDisplayList* otherDList : dList->otherDLists) - GenDListDeclarations(zRoom, parent, otherDList); -} - -std::string SetMesh::GenDListExterns(ZDisplayList* dList) -{ - std::string sourceOutput; - - sourceOutput += StringHelper::Sprintf("extern Gfx %sDL_%06X[];\n", zRoom->GetName().c_str(), - dList->GetRawDataIndex()); - - for (ZDisplayList* otherDList : dList->otherDLists) - sourceOutput += GenDListExterns(otherDList); - - return sourceOutput; -} - -std::string SetMesh::GetBodySourceCode() const -{ - std::string list; - Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "", list, parent->workerID); - return StringHelper::Sprintf("SCENE_CMD_MESH(%s)", list.c_str()); -} - -std::string SetMesh::GetCommandCName() const -{ - return "SCmdMesh"; -} - -RoomCommand SetMesh::GetRoomCommand() const -{ - return RoomCommand::SetMesh; -} - -PolygonDlist::PolygonDlist(ZFile* nParent) : ZResource(nParent) -{ -} - -void PolygonDlist::ParseRawData() -{ - const auto& rawData = parent->GetRawData(); - switch (polyType) - { - case 2: - x = BitConverter::ToInt16BE(rawData, rawDataIndex + 0); - y = BitConverter::ToInt16BE(rawData, rawDataIndex + 2); - z = BitConverter::ToInt16BE(rawData, rawDataIndex + 4); - unk_06 = BitConverter::ToInt16BE(rawData, rawDataIndex + 6); - - opa = BitConverter::ToUInt32BE(rawData, rawDataIndex + 8); - xlu = BitConverter::ToUInt32BE(rawData, rawDataIndex + 12); - break; - - default: - opa = BitConverter::ToUInt32BE(rawData, rawDataIndex); - xlu = BitConverter::ToUInt32BE(rawData, rawDataIndex + 4); - break; - } -} - -void PolygonDlist::DeclareReferences(const std::string& prefix) -{ - opaDList = MakeDlist(opa, prefix); - xluDList = MakeDlist(xlu, prefix); -} - -std::string PolygonDlist::GetBodySourceCode() const -{ - std::string bodyStr; - std::string opaStr; - std::string xluStr; - Globals::Instance->GetSegmentedPtrName(opa, parent, "Gfx", opaStr, parent->workerID); - Globals::Instance->GetSegmentedPtrName(xlu, parent, "Gfx", xluStr, parent->workerID); - - if (polyType == 2) - { - bodyStr += StringHelper::Sprintf("{ %6i, %6i, %6i }, %6i, ", x, y, z, unk_06); - } - - bodyStr += StringHelper::Sprintf("%s, %s", opaStr.c_str(), xluStr.c_str()); - - return bodyStr; -} - -void PolygonDlist::GetSourceOutputCode(const std::string& prefix) -{ - std::string bodyStr = StringHelper::Sprintf("\n\t%s\n", GetBodySourceCode().c_str()); - - Declaration* decl = parent->GetDeclaration(rawDataIndex); - - if (decl == nullptr) - DeclareVar(prefix, bodyStr); - else - decl->text = bodyStr; -} - -std::string PolygonDlist::GetSourceTypeName() const -{ - switch (polyType) - { - case 2: - return "PolygonDlist2"; - - default: - return "PolygonDlist"; - } -} - -ZResourceType PolygonDlist::GetResourceType() const -{ - // TODO - return ZResourceType::Error; -} - -size_t PolygonDlist::GetRawDataSize() const -{ - switch (polyType) - { - case 2: - return 0x10; - - default: - return 0x08; - } -} - -void PolygonDlist::SetPolyType(uint8_t nPolyType) -{ - polyType = nPolyType; -} - -ZDisplayList* PolygonDlist::MakeDlist(segptr_t ptr, [[maybe_unused]] const std::string& prefix) -{ - if (ptr == 0) - { - return nullptr; - } - - uint32_t dlistAddress = Seg2Filespace(ptr, parent->baseAddress); - - int32_t dlistLength = ZDisplayList::GetDListLength( - parent->GetRawData(), dlistAddress, - Globals::Instance->game == ZGame::OOT_SW97 ? DListType::F3DEX : DListType::F3DZEX); - ZDisplayList* dlist = new ZDisplayList(parent); - parent->AddResource(dlist); - dlist->ExtractFromBinary(dlistAddress, dlistLength); - dlist->SetName(dlist->GetDefaultName(prefix)); - GenDListDeclarations(zRoom, parent, dlist); - - return dlist; -} - -/* BgImage */ - -BgImage::BgImage(ZFile* nParent) : ZResource(nParent) -{ -} - -BgImage::BgImage(bool nIsSubStruct, const std::string& prefix, uint32_t nRawDataIndex, - ZFile* nParent) - : BgImage(nParent) -{ - rawDataIndex = nRawDataIndex; - parent = nParent; - isSubStruct = nIsSubStruct; - - name = GetDefaultName(prefix); - - ParseRawData(); - sourceBackground = MakeBackground(source, prefix); -} - -void BgImage::ParseRawData() -{ - size_t pad = 0x00; - const auto& rawData = parent->GetRawData(); - if (!isSubStruct) - { - pad = 0x04; - - unk_00 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x00); - id = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x02); - } - source = BitConverter::ToUInt32BE(rawData, rawDataIndex + pad + 0x00); - unk_0C = BitConverter::ToUInt32BE(rawData, rawDataIndex + pad + 0x04); - tlut = BitConverter::ToUInt32BE(rawData, rawDataIndex + pad + 0x08); - width = BitConverter::ToUInt16BE(rawData, rawDataIndex + pad + 0x0C); - height = BitConverter::ToUInt16BE(rawData, rawDataIndex + pad + 0x0E); - fmt = BitConverter::ToUInt8BE(rawData, rawDataIndex + pad + 0x10); - siz = BitConverter::ToUInt8BE(rawData, rawDataIndex + pad + 0x11); - mode0 = BitConverter::ToUInt16BE(rawData, rawDataIndex + pad + 0x12); - tlutCount = BitConverter::ToUInt16BE(rawData, rawDataIndex + pad + 0x14); -} - -ZBackground* BgImage::MakeBackground(segptr_t ptr, const std::string& prefix) -{ - if (ptr == 0) - return nullptr; - - uint32_t backAddress = Seg2Filespace(ptr, parent->baseAddress); - - ZBackground* background = new ZBackground(parent); - background->ExtractFromFile(backAddress); - - std::string defaultName = background->GetDefaultName(prefix); - background->SetName(defaultName); - background->SetOutName(defaultName); - - background->DeclareVar(prefix, ""); - parent->resources.push_back(background); - - return background; -} - -size_t BgImage::GetRawDataSize() const -{ - return 0x1C; -} - -std::string BgImage::GetBodySourceCode() const -{ - std::string bodyStr = " "; - if (!isSubStruct) - { - bodyStr += "{ \n "; - } - - if (!isSubStruct) - { - bodyStr += StringHelper::Sprintf("0x%04X, ", unk_00); - bodyStr += StringHelper::Sprintf("%i, ", id); - bodyStr += "\n "; - bodyStr += " "; - } - - std::string backgroundName; - Globals::Instance->GetSegmentedPtrName(source, parent, "", backgroundName, parent->workerID); - bodyStr += StringHelper::Sprintf("%s, ", backgroundName.c_str()); - bodyStr += "\n "; - if (!isSubStruct) - { - bodyStr += " "; - } - - bodyStr += StringHelper::Sprintf("0x%08X, ", unk_0C); - bodyStr += StringHelper::Sprintf("0x%08X, ", tlut); - bodyStr += "\n "; - if (!isSubStruct) - { - bodyStr += " "; - } - - bodyStr += StringHelper::Sprintf("%i, ", width); - bodyStr += StringHelper::Sprintf("%i, ", height); - bodyStr += "\n "; - if (!isSubStruct) - { - bodyStr += " "; - } - - bodyStr += StringHelper::Sprintf("%i, ", fmt); - bodyStr += StringHelper::Sprintf("%i, ", siz); - bodyStr += "\n "; - if (!isSubStruct) - { - bodyStr += " "; - } - - bodyStr += StringHelper::Sprintf("0x%04X, ", mode0); - bodyStr += StringHelper::Sprintf("0x%04X, ", tlutCount); - if (!isSubStruct) - { - bodyStr += " \n }, "; - } - else - { - bodyStr += "\n"; - } - - return bodyStr; -} - -std::string BgImage::GetSourceTypeName() const -{ - return "BgImage"; -} - -ZResourceType BgImage::GetResourceType() const -{ - // TODO - return ZResourceType::Error; -} - -/* PolygonType section */ - -PolygonTypeBase::PolygonTypeBase(ZFile* nParent, uint32_t nRawDataIndex, ZRoom* nRoom) - : ZResource(nParent), zRoom{nRoom} -{ - rawDataIndex = nRawDataIndex; - type = BitConverter::ToUInt8BE(parent->GetRawData(), rawDataIndex); -} - -void PolygonTypeBase::DeclareAndGenerateOutputCode(const std::string& prefix) -{ - std::string bodyStr = GetBodySourceCode(); - - Declaration* decl = parent->GetDeclaration(rawDataIndex); - if (decl == nullptr) - { - DeclareVar(prefix, bodyStr); - } - else - { - decl->text = bodyStr; - } -} - -std::string PolygonTypeBase::GetSourceTypeName() const -{ - switch (type) - { - case 2: - return "PolygonType2"; - - case 1: - return "PolygonType1"; - - default: - return "PolygonType0"; - } -} - -ZResourceType PolygonTypeBase::GetResourceType() const -{ - // TODO - return ZResourceType::Error; -} - -PolygonType1::PolygonType1(ZFile* nParent, uint32_t nRawDataIndex, ZRoom* nRoom) - : PolygonTypeBase(nParent, nRawDataIndex, nRoom), single(nParent) -{ -} - -void PolygonType1::ParseRawData() -{ - const auto& rawData = parent->GetRawData(); - - format = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x01); - dlist = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x04); - - if (format == 2) - { - count = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x08); - list = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x0C); - } - - if (dlist != 0) - { - PolygonDlist polyGfxList(parent); - polyGfxList.zRoom = zRoom; - polyGfxList.SetPolyType(type); - polyGfxList.ExtractFromFile(Seg2Filespace(dlist, parent->baseAddress)); - polyGfxList.DeclareReferences(zRoom->GetName()); - polyDLists.push_back(polyGfxList); - } -} - -void PolygonType1::DeclareReferences(const std::string& prefix) -{ - polyDLists.at(0).GetSourceOutputCode(prefix); - - uint32_t listAddress; - std::string bgImageArrayBody; - switch (format) - { - case 1: - single = BgImage(true, prefix, rawDataIndex + 0x08, parent); - break; - - case 2: - if (list != 0) - { - listAddress = Seg2Filespace(list, parent->baseAddress); - uint32_t auxPtr = listAddress; - - multiList.reserve(count); - for (size_t i = 0; i < count; ++i) - { - BgImage bg(false, prefix, auxPtr, parent); - multiList.push_back(bg); - auxPtr += bg.GetRawDataSize(); - bgImageArrayBody += bg.GetBodySourceCode(); - if (i + 1 < count) - { - bgImageArrayBody += "\n"; - } - } - - Declaration* decl = parent->GetDeclaration(listAddress); - if (decl == nullptr) - { - parent->AddDeclarationArray( - listAddress, DeclarationAlignment::Align4, - count * multiList.at(0).GetRawDataSize(), multiList.at(0).GetSourceTypeName(), - multiList.at(0).GetName().c_str(), count, bgImageArrayBody); - } - } - break; - - default: - HANDLE_ERROR(WarningType::InvalidExtractedData, - StringHelper::Sprintf("unknown format: %i", format), ""); - break; - } -} - -size_t PolygonType1::GetRawDataSize() const -{ - switch (format) - { - case 1: - return 0x20; - - case 2: - return 0x10; - } - return 0x20; -} - -std::string PolygonType1::GetBodySourceCode() const -{ - std::string bodyStr = "\n "; - - bodyStr += "{ "; - bodyStr += StringHelper::Sprintf("%i, %i, ", type, format); - - std::string dlistStr; - Globals::Instance->GetSegmentedPtrName(dlist, parent, "", dlistStr, parent->workerID); - - bodyStr += StringHelper::Sprintf("%s, ", dlistStr.c_str()); - bodyStr += "}, \n"; - - std::string listStr = "NULL"; - switch (format) - { - case 1: - bodyStr += single.GetBodySourceCode(); - break; - case 2: - Globals::Instance->GetSegmentedPtrName(list, parent, "BgImage", listStr, parent->workerID); - bodyStr += StringHelper::Sprintf(" %i, %s, \n", count, listStr.c_str()); - break; - - default: - break; - } - - return bodyStr; -} - -std::string PolygonType1::GetSourceTypeName() const -{ - switch (format) - { - case 1: - return "MeshHeader1Single"; - - case 2: - return "MeshHeader1Multi"; - } - return "ERROR"; - // return "PolygonType1"; -} - -PolygonType2::PolygonType2(ZFile* nParent, uint32_t nRawDataIndex, ZRoom* nRoom) - : PolygonTypeBase(nParent, nRawDataIndex, nRoom) -{ -} - -void PolygonType2::ParseRawData() -{ - const auto& rawData = parent->GetRawData(); - - num = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x01); - - start = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x04); - end = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x08); - - uint32_t currentPtr = GETSEGOFFSET(start); - - polyDLists.reserve(num); - for (size_t i = 0; i < num; i++) - { - PolygonDlist entry(parent); - entry.zRoom = zRoom; - entry.SetPolyType(type); - entry.ExtractFromFile(currentPtr); - entry.DeclareReferences(zRoom->GetName()); - polyDLists.push_back(entry); - currentPtr += entry.GetRawDataSize(); - } -} - -void PolygonType2::DeclareReferences(const std::string& prefix) -{ - if (num > 0) - { - std::string declaration; - - for (size_t i = 0; i < polyDLists.size(); i++) - { - declaration += - StringHelper::Sprintf("\t{ %s },", polyDLists.at(i).GetBodySourceCode().c_str()); - if (i + 1 < polyDLists.size()) - declaration += "\n"; - } - - std::string polyDlistType = polyDLists.at(0).GetSourceTypeName(); - std::string polyDListName; - polyDListName = StringHelper::Sprintf("%s%s_%06X", prefix.c_str(), polyDlistType.c_str(), - GETSEGOFFSET(start)); - - Declaration* decl = parent->AddDeclarationArray( - GETSEGOFFSET(start), DeclarationAlignment::Align4, - polyDLists.size() * polyDLists.at(0).GetRawDataSize(), polyDlistType, polyDListName, - polyDLists.size(), declaration); - decl->forceArrayCnt = true; - } - - parent->AddDeclaration(GETSEGOFFSET(end), DeclarationAlignment::Align4, 4, "s32", - StringHelper::Sprintf("%s_terminatorMaybe_%06X", - parent->GetName().c_str(), GETSEGOFFSET(end)), - "0x01000000"); -} - -std::string PolygonType2::GetBodySourceCode() const -{ - std::string listName; - Globals::Instance->GetSegmentedPtrName(start, parent, "", listName, parent->workerID); - - std::string body = StringHelper::Sprintf("\n %i, %i,\n", type, polyDLists.size()); - body += StringHelper::Sprintf(" %s,\n", listName.c_str()); - body += - StringHelper::Sprintf(" %s + ARRAY_COUNTU(%s)\n", listName.c_str(), listName.c_str()); - return body; -} - -size_t PolygonType2::GetRawDataSize() const -{ - return 0x0C; -} - -DeclarationAlignment PolygonType2::GetDeclarationAlignment() const -{ - return DeclarationAlignment::Align4; -} diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetMesh.h b/ZAPDTR/ZAPD/ZRoom/Commands/SetMesh.h deleted file mode 100644 index 9d9037417..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetMesh.h +++ /dev/null @@ -1,159 +0,0 @@ -#pragma once - -#include -#include "ZBackground.h" -#include "ZDisplayList.h" -#include "ZRoom/ZRoomCommand.h" - -class PolygonDlist : public ZResource -{ -public: - ZRoom* zRoom; - - uint8_t polyType; - - int16_t x, y, z; // polyType == 2 - int16_t unk_06; // polyType == 2 - - segptr_t opa = 0; // Gfx* - segptr_t xlu = 0; // Gfx* - - ZDisplayList* opaDList = nullptr; // Gfx* - ZDisplayList* xluDList = nullptr; // Gfx* - - PolygonDlist(ZFile* nParent); - - void ParseRawData() override; - void DeclareReferences(const std::string& prefix) override; - - std::string GetBodySourceCode() const override; - - void GetSourceOutputCode(const std::string& prefix) override; - - std::string GetSourceTypeName() const override; - ZResourceType GetResourceType() const override; - - size_t GetRawDataSize() const override; - - void SetPolyType(uint8_t nPolyType); - -protected: - ZDisplayList* MakeDlist(segptr_t ptr, const std::string& prefix); -}; - -class BgImage : public ZResource -{ -public: - uint16_t unk_00; - uint8_t id; - segptr_t source; - uint32_t unk_0C; - uint32_t tlut; - uint16_t width; - uint16_t height; - uint8_t fmt; - uint8_t siz; - uint16_t mode0; - uint16_t tlutCount; - - ZBackground* sourceBackground; - - bool isSubStruct; - - BgImage(ZFile* nParent); - BgImage(bool nIsSubStruct, const std::string& prefix, uint32_t nRawDataIndex, 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: - ZBackground* MakeBackground(segptr_t ptr, const std::string& prefix); -}; - -class PolygonTypeBase : public ZResource -{ -public: - uint8_t type; - std::vector polyDLists; - - PolygonTypeBase(ZFile* nParent, uint32_t nRawDataIndex, ZRoom* nRoom); - - void DeclareAndGenerateOutputCode(const std::string& prefix); - - std::string GetSourceTypeName() const override; - ZResourceType GetResourceType() const override; - -protected: - ZRoom* zRoom; -}; - -class PolygonType1 : public PolygonTypeBase -{ -public: - uint8_t format; - segptr_t dlist; - - // single - BgImage single; - - // multi - uint8_t count; - segptr_t list; // BgImage* - std::vector multiList; - - PolygonType1(ZFile* nParent, uint32_t nRawDataIndex, ZRoom* nRoom); - - void ParseRawData() override; - void DeclareReferences(const std::string& prefix) override; - - std::string GetBodySourceCode() const override; - - std::string GetSourceTypeName() const override; - - size_t GetRawDataSize() const override; -}; - -class PolygonType2 : public PolygonTypeBase -{ -public: - uint8_t num; - segptr_t start; - segptr_t end; - - PolygonType2(ZFile* nParent, uint32_t nRawDataIndex, ZRoom* nRoom); - - void ParseRawData() override; - void DeclareReferences(const std::string& prefix) override; - - std::string GetBodySourceCode() const override; - - size_t GetRawDataSize() const override; - DeclarationAlignment GetDeclarationAlignment() const override; -}; - -class SetMesh : public ZRoomCommand -{ -public: - uint8_t data; - uint8_t meshHeaderType; - std::shared_ptr polyType; - - SetMesh(ZFile* nParent); - - void ParseRawData() override; - void DeclareReferences(const std::string& prefix) override; - - std::string GetBodySourceCode() const override; - - RoomCommand GetRoomCommand() const override; - std::string GetCommandCName() const override; - -private: - std::string GenDListExterns(ZDisplayList* dList); -}; diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetMinimapChests.cpp b/ZAPDTR/ZAPD/ZRoom/Commands/SetMinimapChests.cpp deleted file mode 100644 index 25bfae703..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetMinimapChests.cpp +++ /dev/null @@ -1,83 +0,0 @@ -#include "SetMinimapChests.h" - -#include "Globals.h" -#include "Utils/BitConverter.h" -#include "Utils/StringHelper.h" -#include "ZFile.h" -#include "ZRoom/ZRoom.h" - -SetMinimapChests::SetMinimapChests(ZFile* nParent) : ZRoomCommand(nParent) -{ -} - -void SetMinimapChests::ParseRawData() -{ - ZRoomCommand::ParseRawData(); - int numChests = cmdArg1; - - offset_t currentPtr = segmentOffset; - - chests.reserve(numChests); - for (int32_t i = 0; i < numChests; i++) - { - MinimapChest chest(parent->GetRawData(), currentPtr); - chests.push_back(chest); - - currentPtr += 10; - } -} - -void SetMinimapChests::DeclareReferences(const std::string& prefix) -{ - std::string declaration; - - size_t index = 0; - for (const auto& chest : chests) - { - declaration += StringHelper::Sprintf(" { %s },", chest.GetBodySourceCode().c_str()); - - if (index < chests.size() - 1) - declaration += "\n"; - - index++; - } - - parent->AddDeclarationArray( - segmentOffset, DeclarationAlignment::Align4, chests.size() * 10, "MinimapChest", - StringHelper::Sprintf("%sMinimapChests0x%06X", prefix.c_str(), segmentOffset), - chests.size(), declaration); -} - -std::string SetMinimapChests::GetBodySourceCode() const -{ - std::string listName; - Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "MinimapChest", listName, - parent->workerID); - return StringHelper::Sprintf("SCENE_CMD_MINIMAP_COMPASS_ICON_INFO(0x%02X, %s)", chests.size(), - listName.c_str()); -} - -std::string SetMinimapChests::GetCommandCName() const -{ - return "SCmdMinimapChests"; -} - -RoomCommand SetMinimapChests::GetRoomCommand() const -{ - return RoomCommand::SetMinimapChests; -} - -MinimapChest::MinimapChest(const std::vector& rawData, uint32_t rawDataIndex) - : unk0(BitConverter::ToUInt16BE(rawData, rawDataIndex + 0)), - unk2(BitConverter::ToUInt16BE(rawData, rawDataIndex + 2)), - unk4(BitConverter::ToUInt16BE(rawData, rawDataIndex + 4)), - unk6(BitConverter::ToUInt16BE(rawData, rawDataIndex + 6)), - unk8(BitConverter::ToUInt16BE(rawData, rawDataIndex + 8)) -{ -} - -std::string MinimapChest::GetBodySourceCode() const -{ - return StringHelper::Sprintf("0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X", unk0, unk2, unk4, unk6, - unk8); -} diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetMinimapChests.h b/ZAPDTR/ZAPD/ZRoom/Commands/SetMinimapChests.h deleted file mode 100644 index 0db09a8a2..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetMinimapChests.h +++ /dev/null @@ -1,34 +0,0 @@ -#pragma once - -#include "ZRoom/ZRoomCommand.h" - -class MinimapChest -{ -public: - MinimapChest(const std::vector& rawData, uint32_t rawDataIndex); - - std::string GetBodySourceCode() const; - -protected: - uint16_t unk0; - uint16_t unk2; - uint16_t unk4; - uint16_t unk6; - uint16_t unk8; -}; - -class SetMinimapChests : public ZRoomCommand -{ -public: - std::vector chests; - - SetMinimapChests(ZFile* nParent); - - void ParseRawData() override; - void DeclareReferences(const std::string& prefix) override; - - std::string GetBodySourceCode() const override; - - RoomCommand GetRoomCommand() const override; - std::string GetCommandCName() const override; -}; diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetMinimapList.cpp b/ZAPDTR/ZAPD/ZRoom/Commands/SetMinimapList.cpp deleted file mode 100644 index e02e1a92b..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetMinimapList.cpp +++ /dev/null @@ -1,98 +0,0 @@ -#include "SetMinimapList.h" - -#include "Globals.h" -#include "Utils/BitConverter.h" -#include "Utils/StringHelper.h" -#include "ZFile.h" -#include "ZRoom/ZRoom.h" - -SetMinimapList::SetMinimapList(ZFile* nParent) : ZRoomCommand(nParent) -{ -} - -void SetMinimapList::ParseRawData() -{ - ZRoomCommand::ParseRawData(); - listSegmentAddr = BitConverter::ToInt32BE(parent->GetRawData(), segmentOffset); - listSegmentOffset = GETSEGOFFSET(listSegmentAddr); - unk4 = BitConverter::ToInt32BE(parent->GetRawData(), segmentOffset + 4); - - uint32_t currentPtr = listSegmentOffset; - - minimaps.reserve(zRoom->roomCount); - for (int32_t i = 0; i < zRoom->roomCount; i++) - { - MinimapEntry entry(parent->GetRawData(), currentPtr); - minimaps.push_back(entry); - - currentPtr += 10; - } -} - -void SetMinimapList::DeclareReferences(const std::string& prefix) -{ - { - std::string declaration; - - size_t index = 0; - for (const auto& entry : minimaps) - { - declaration += StringHelper::Sprintf(" { %s },", entry.GetBodySourceCode().c_str()); - - if (index < minimaps.size() - 1) - declaration += "\n"; - - index++; - } - - parent->AddDeclarationArray( - listSegmentOffset, DeclarationAlignment::Align4, minimaps.size() * 10, "MinimapEntry", - StringHelper::Sprintf("%sMinimapEntryList0x%06X", prefix.c_str(), listSegmentOffset), - minimaps.size(), declaration); - } - - { - std::string listName; - Globals::Instance->GetSegmentedPtrName(listSegmentAddr, parent, "MinimapEntry", listName, - parent->workerID); - std::string declaration = StringHelper::Sprintf("\n\t%s, 0x%08X\n", listName.c_str(), unk4); - - parent->AddDeclaration( - segmentOffset, DeclarationAlignment::Align4, 8, "MinimapList", - StringHelper::Sprintf("%sMinimapList0x%06X", prefix.c_str(), segmentOffset), - declaration); - } -} - -std::string SetMinimapList::GetBodySourceCode() const -{ - std::string listName; - Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "MinimapList", listName, - parent->workerID); - return StringHelper::Sprintf("SCENE_CMD_MINIMAP_INFO(%s)", listName.c_str()); -} - -std::string SetMinimapList::GetCommandCName() const -{ - return "SCmdMinimapSettings"; -} - -RoomCommand SetMinimapList::GetRoomCommand() const -{ - return RoomCommand::SetMinimapList; -} - -MinimapEntry::MinimapEntry(const std::vector& rawData, uint32_t rawDataIndex) - : unk0(BitConverter::ToUInt16BE(rawData, rawDataIndex + 0)), - unk2(BitConverter::ToUInt16BE(rawData, rawDataIndex + 2)), - unk4(BitConverter::ToUInt16BE(rawData, rawDataIndex + 4)), - unk6(BitConverter::ToUInt16BE(rawData, rawDataIndex + 6)), - unk8(BitConverter::ToUInt16BE(rawData, rawDataIndex + 8)) -{ -} - -std::string MinimapEntry::GetBodySourceCode() const -{ - return StringHelper::Sprintf("0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X", unk0, unk2, unk4, unk6, - unk8); -} diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetMinimapList.h b/ZAPDTR/ZAPD/ZRoom/Commands/SetMinimapList.h deleted file mode 100644 index 5b18b3dd7..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetMinimapList.h +++ /dev/null @@ -1,39 +0,0 @@ -#pragma once - -#include "ZRoom/ZRoomCommand.h" - -class MinimapEntry -{ -public: - MinimapEntry(const std::vector& rawData, uint32_t rawDataIndex); - - std::string GetBodySourceCode() const; - -protected: - uint16_t unk0; - uint16_t unk2; - uint16_t unk4; - uint16_t unk6; - uint16_t unk8; -}; - -class SetMinimapList : public ZRoomCommand -{ -public: - std::vector minimaps; - - SetMinimapList(ZFile* nParent); - - void ParseRawData() override; - void DeclareReferences(const std::string& prefix) override; - - std::string GetBodySourceCode() const override; - - RoomCommand GetRoomCommand() const override; - std::string GetCommandCName() const override; - -private: - segptr_t listSegmentAddr; - uint32_t listSegmentOffset; - uint32_t unk4; -}; diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetObjectList.cpp b/ZAPDTR/ZAPD/ZRoom/Commands/SetObjectList.cpp deleted file mode 100644 index a8bb76a08..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetObjectList.cpp +++ /dev/null @@ -1,67 +0,0 @@ -#include "SetObjectList.h" - -#include "Globals.h" -#include "Utils/BitConverter.h" -#include "Utils/StringHelper.h" -#include "ZFile.h" -#include "ZRoom/ZNames.h" -#include "ZRoom/ZRoom.h" - -SetObjectList::SetObjectList(ZFile* nParent) : ZRoomCommand(nParent) -{ -} - -void SetObjectList::ParseRawData() -{ - ZRoomCommand::ParseRawData(); - uint8_t objectCnt = parent->GetRawData().at(rawDataIndex + 1); - uint32_t currentPtr = segmentOffset; - - objects.reserve(objectCnt); - for (uint8_t i = 0; i < objectCnt; i++) - { - uint16_t objectIndex = BitConverter::ToInt16BE(parent->GetRawData(), currentPtr); - objects.push_back(objectIndex); - currentPtr += 2; - } -} - -void SetObjectList::DeclareReferences(const std::string& prefix) -{ - if (!objects.empty()) - { - std::string declaration; - - for (size_t i = 0; i < objects.size(); i++) - { - uint16_t objectIndex = objects[i]; - declaration += - StringHelper::Sprintf(" %s,", ZNames::GetObjectName(objectIndex).c_str()); - - if (i < objects.size() - 1) - declaration += "\n"; - } - - parent->AddDeclarationArray( - segmentOffset, DeclarationAlignment::Align4, objects.size() * 2, "s16", - StringHelper::Sprintf("%sObjectList_%06X", prefix.c_str(), segmentOffset), - objects.size(), declaration); - } -} - -std::string SetObjectList::GetBodySourceCode() const -{ - std::string listName; - Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "s16", listName, parent->workerID); - return StringHelper::Sprintf("SCENE_CMD_OBJECT_LIST(%i, %s)", objects.size(), listName.c_str()); -} - -std::string SetObjectList::GetCommandCName() const -{ - return "SCmdObjectList"; -} - -RoomCommand SetObjectList::GetRoomCommand() const -{ - return RoomCommand::SetObjectList; -} diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetObjectList.h b/ZAPDTR/ZAPD/ZRoom/Commands/SetObjectList.h deleted file mode 100644 index 03c159483..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetObjectList.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once - -#include "ZRoom/ZRoomCommand.h" - -class SetObjectList : public ZRoomCommand -{ -public: - std::vector objects; - - SetObjectList(ZFile* nParent); - - void ParseRawData() override; - void DeclareReferences(const std::string& prefix) override; - - std::string GetBodySourceCode() const override; - - std::string GetCommandCName() const override; - RoomCommand GetRoomCommand() const override; -}; diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetPathways.cpp b/ZAPDTR/ZAPD/ZRoom/Commands/SetPathways.cpp deleted file mode 100644 index f3bdb0872..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetPathways.cpp +++ /dev/null @@ -1,65 +0,0 @@ -#include "SetPathways.h" - -#include "Globals.h" -#include "Utils/BitConverter.h" -#include "Utils/StringHelper.h" -#include "ZFile.h" -#include "ZRoom/ZRoom.h" - -SetPathways::SetPathways(ZFile* nParent) : ZRoomCommand(nParent), pathwayList(nParent) -{ -} - -void SetPathways::DeclareReferences([[maybe_unused]] const std::string& prefix) -{ - if (segmentOffset != 0) - { - std::string varName = - StringHelper::Sprintf("%sPathway_%06X", prefix.c_str(), segmentOffset); - parent->AddDeclarationPlaceholder(segmentOffset, varName); - } -} - -void SetPathways::ParseRawDataLate() -{ - if (Globals::Instance->game == ZGame::MM_RETAIL) - { - auto numPaths = zRoom->GetDeclarationSizeFromNeighbor(segmentOffset) / 8; - pathwayList.SetNumPaths(numPaths); - } - - if (Globals::Instance->otrMode) - { - auto zPath = (ZPath*)parent->FindResource(segmentOffset); - - if (zPath != nullptr) - pathwayList = *zPath; - } - - pathwayList.ExtractFromFile(segmentOffset); -} - -void SetPathways::DeclareReferencesLate(const std::string& prefix) -{ - std::string varName = StringHelper::Sprintf("%sPathway_%06X", prefix.c_str(), segmentOffset); - pathwayList.SetName(varName); - pathwayList.DeclareReferences(prefix); - pathwayList.GetSourceOutputCode(prefix); -} - -std::string SetPathways::GetBodySourceCode() const -{ - std::string listName; - Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "Path", listName, parent->workerID); - return StringHelper::Sprintf("SCENE_CMD_PATH_LIST(%s)", listName.c_str()); -} - -std::string SetPathways::GetCommandCName() const -{ - return "SCmdPathList"; -} - -RoomCommand SetPathways::GetRoomCommand() const -{ - return RoomCommand::SetPathways; -} diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetPathways.h b/ZAPDTR/ZAPD/ZRoom/Commands/SetPathways.h deleted file mode 100644 index 9abc93d32..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetPathways.h +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once - -#include "Vec3s.h" -#include "ZPath.h" -#include "ZResource.h" -#include "ZRoom/ZRoomCommand.h" - -class SetPathways : public ZRoomCommand -{ -public: - ZPath pathwayList; - - SetPathways(ZFile* nParent); - - void DeclareReferences(const std::string& prefix) override; - - void ParseRawDataLate() override; - void DeclareReferencesLate(const std::string& prefix) override; - - std::string GetBodySourceCode() const override; - - RoomCommand GetRoomCommand() const override; - std::string GetCommandCName() const override; -}; diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetRoomBehavior.cpp b/ZAPDTR/ZAPD/ZRoom/Commands/SetRoomBehavior.cpp deleted file mode 100644 index 8c6f4bf51..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetRoomBehavior.cpp +++ /dev/null @@ -1,50 +0,0 @@ -#include "SetRoomBehavior.h" - -#include "Globals.h" -#include "Utils/BitConverter.h" -#include "Utils/StringHelper.h" - -SetRoomBehavior::SetRoomBehavior(ZFile* nParent) : ZRoomCommand(nParent) -{ -} - -void SetRoomBehavior::ParseRawData() -{ - ZRoomCommand::ParseRawData(); - gameplayFlags = cmdArg1; - gameplayFlags2 = BitConverter::ToInt32BE(parent->GetRawData(), rawDataIndex + 0x04); - - currRoomUnk2 = gameplayFlags2 & 0xFF; - - currRoomUnk5 = showInvisActors = (gameplayFlags2 >> 8) & 1; - - msgCtxUnk = (gameplayFlags2 >> 10) & 1; - - enablePosLights = (gameplayFlags2 >> 11) & 1; - kankyoContextUnkE2 = (gameplayFlags2 >> 12) & 1; -} - -std::string SetRoomBehavior::GetBodySourceCode() const -{ - if (Globals::Instance->game == ZGame::MM_RETAIL) - { - std::string enableLights = StringHelper::BoolStr(enablePosLights); - return StringHelper::Sprintf("SCENE_CMD_ROOM_BEHAVIOR(0x%02X, 0x%02X, %i, %i, %s, %i)", - gameplayFlags, currRoomUnk2, currRoomUnk5, msgCtxUnk, - enableLights.c_str(), kankyoContextUnkE2); - } - std::string showInvisible = StringHelper::BoolStr(showInvisActors); - std::string disableWarps = StringHelper::BoolStr(msgCtxUnk); - return StringHelper::Sprintf("SCENE_CMD_ROOM_BEHAVIOR(0x%02X, 0x%02X, %s, %s)", gameplayFlags, - currRoomUnk2, showInvisible.c_str(), disableWarps.c_str()); -} - -std::string SetRoomBehavior::GetCommandCName() const -{ - return "SCmdRoomBehavior"; -} - -RoomCommand SetRoomBehavior::GetRoomCommand() const -{ - return RoomCommand::SetRoomBehavior; -} diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetRoomBehavior.h b/ZAPDTR/ZAPD/ZRoom/Commands/SetRoomBehavior.h deleted file mode 100644 index 47b772d77..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetRoomBehavior.h +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once - -#include "ZRoom/ZRoomCommand.h" - -class SetRoomBehavior : public ZRoomCommand -{ -public: - uint8_t gameplayFlags; - uint32_t gameplayFlags2; - - uint8_t currRoomUnk2; - - uint8_t showInvisActors; - uint8_t currRoomUnk5; - - uint8_t msgCtxUnk; - - uint8_t enablePosLights; - uint8_t kankyoContextUnkE2; - - SetRoomBehavior(ZFile* nParent); - - void ParseRawData() override; - - std::string GetBodySourceCode() const override; - - RoomCommand GetRoomCommand() const override; - std::string GetCommandCName() const override; -}; diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetRoomList.cpp b/ZAPDTR/ZAPD/ZRoom/Commands/SetRoomList.cpp deleted file mode 100644 index abb2b003c..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetRoomList.cpp +++ /dev/null @@ -1,155 +0,0 @@ -#include "SetRoomList.h" - -#include "Globals.h" -#include "Utils/BitConverter.h" -#include "Utils/StringHelper.h" -#include "ZFile.h" -#include "ZRoom/ZRoom.h" - -SetRoomList::SetRoomList(ZFile* nParent) : ZRoomCommand(nParent) -{ -} - -void SetRoomList::ParseRawData() -{ - ZRoomCommand::ParseRawData(); - int numRooms = cmdArg1; - - romfile = new RomFile(parent); - romfile->numRooms = numRooms; - romfile->ExtractFromFile(segmentOffset); - - parent->resources.push_back(romfile); - - zRoom->roomCount = numRooms; -} - -void SetRoomList::DeclareReferences(const std::string& prefix) -{ - ZRoomCommand::DeclareReferences(prefix); - - romfile->DeclareVar(prefix, ""); -} - -std::string SetRoomList::GetBodySourceCode() const -{ - std::string listName; - Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "RomFile", listName, parent->workerID); - return StringHelper::Sprintf("SCENE_CMD_ROOM_LIST(%i, %s)", romfile->rooms.size(), - listName.c_str()); -} - -std::string SetRoomList::GetCommandCName() const -{ - return "SCmdRoomList"; -} - -RoomCommand SetRoomList::GetRoomCommand() const -{ - return RoomCommand::SetRoomList; -} - -RomFile::RomFile(ZFile* nParent) : ZResource(nParent) -{ -} - -void RomFile::ParseXML(tinyxml2::XMLElement* reader) -{ - ZResource::ParseXML(reader); - - if (reader->Attribute("NumRooms") != nullptr) - { - numRooms = StringHelper::StrToL(std::string(reader->Attribute("NumRooms"))); - } -} - -void RomFile::ParseRawData() -{ - ZResource::ParseRawData(); - - uint32_t currentPtr = rawDataIndex; - - rooms.reserve(numRooms); - for (int32_t i = 0; i < numRooms; i++) - { - RoomEntry entry(parent->GetRawData(), currentPtr); - rooms.push_back(entry); - - currentPtr += 8; - } -} - -Declaration* RomFile::DeclareVar(const std::string& prefix, const std::string& body) -{ - std::string auxName = name; - if (name == "") - auxName = StringHelper::Sprintf("%sRoomList0x%06X", prefix.c_str(), rawDataIndex); - - return parent->AddDeclarationArray(rawDataIndex, DeclarationAlignment::Align4, - rooms.size() * rooms.at(0).GetRawDataSize(), - GetSourceTypeName(), auxName, rooms.size(), body); -} - -std::string RomFile::GetBodySourceCode() const -{ - std::string declaration; - bool isFirst = true; - - for (ZFile* file : Globals::Instance->files) - { - for (ZResource* res : file->resources) - { - if (res->GetResourceType() == ZResourceType::Room) - { - std::string roomName = res->GetName(); - if (!isFirst) - declaration += "\n"; - - declaration += StringHelper::Sprintf( - "\t{ (uintptr_t)_%sSegmentRomStart, (uintptr_t)_%sSegmentRomEnd },", - roomName.c_str(), roomName.c_str()); - isFirst = false; - } - } - } - - return declaration; -} - -void RomFile::GetSourceOutputCode(const std::string& prefix) -{ - DeclareVar(prefix, GetBodySourceCode()); -} - -std::string RomFile::GetSourceTypeName() const -{ - return "RomFile"; -} - -ZResourceType RomFile::GetResourceType() const -{ - // TODO - return ZResourceType::Error; -} - -size_t RomFile::GetRawDataSize() const -{ - return 8 * rooms.size(); -} - -RoomEntry::RoomEntry(uint32_t nVAS, uint32_t nVAE) -{ - virtualAddressStart = nVAS; - virtualAddressEnd = nVAE; -} - -RoomEntry::RoomEntry(const std::vector& rawData, uint32_t rawDataIndex) - : RoomEntry(BitConverter::ToInt32BE(rawData, rawDataIndex + 0), - BitConverter::ToInt32BE(rawData, rawDataIndex + 4)) -{ -} - -size_t RoomEntry::GetRawDataSize() const -{ - return 0x08; -} diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetRoomList.h b/ZAPDTR/ZAPD/ZRoom/Commands/SetRoomList.h deleted file mode 100644 index 2ae48b68d..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetRoomList.h +++ /dev/null @@ -1,53 +0,0 @@ -#pragma once - -#include "ZRoom/ZRoomCommand.h" - -class RoomEntry -{ -public: - int32_t virtualAddressStart; - int32_t virtualAddressEnd; - - RoomEntry(uint32_t nVAS, uint32_t nVAE); - RoomEntry(const std::vector& rawData, uint32_t rawDataIndex); - - size_t GetRawDataSize() const; -}; - -class RomFile : public ZResource -{ -public: - RomFile(ZFile* nParent); - - void ParseXML(tinyxml2::XMLElement* reader) override; - void ParseRawData() override; - - Declaration* DeclareVar(const std::string& prefix, const std::string& body) override; - std::string GetBodySourceCode() const override; - void GetSourceOutputCode(const std::string& prefix) override; - - std::string GetSourceTypeName() const override; - virtual ZResourceType GetResourceType() const override; - - virtual size_t GetRawDataSize() const override; - - uint8_t numRooms = 0; - std::vector rooms; -}; - -class SetRoomList : public ZRoomCommand -{ -public: - // Borrowed reference. Don't delete. - RomFile* romfile = nullptr; - - SetRoomList(ZFile* nParent); - - void ParseRawData() override; - void DeclareReferences(const std::string& prefix) override; - - std::string GetBodySourceCode() const override; - - RoomCommand GetRoomCommand() const override; - std::string GetCommandCName() const override; -}; diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetSkyboxModifier.cpp b/ZAPDTR/ZAPD/ZRoom/Commands/SetSkyboxModifier.cpp deleted file mode 100644 index b16f1355b..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetSkyboxModifier.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include "SetSkyboxModifier.h" - -#include "Utils/StringHelper.h" - -SetSkyboxModifier::SetSkyboxModifier(ZFile* nParent) : ZRoomCommand(nParent) -{ -} - -void SetSkyboxModifier::ParseRawData() -{ - ZRoomCommand::ParseRawData(); - disableSky = parent->GetRawData().at(rawDataIndex + 0x04); - disableSunMoon = parent->GetRawData().at(rawDataIndex + 0x05); -} - -std::string SetSkyboxModifier::GetBodySourceCode() const -{ - std::string sky = StringHelper::BoolStr(disableSky); - std::string soonMoon = StringHelper::BoolStr(disableSunMoon); - return StringHelper::Sprintf("SCENE_CMD_SKYBOX_DISABLES(%s, %s)", sky.c_str(), - soonMoon.c_str()); -} - -std::string SetSkyboxModifier::GetCommandCName() const -{ - return "SCmdSkyboxDisables"; -} - -RoomCommand SetSkyboxModifier::GetRoomCommand() const -{ - return RoomCommand::SetSkyboxModifier; -} diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetSkyboxModifier.h b/ZAPDTR/ZAPD/ZRoom/Commands/SetSkyboxModifier.h deleted file mode 100644 index 65935bf92..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetSkyboxModifier.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once - -#include "ZRoom/ZRoomCommand.h" - -class SetSkyboxModifier : public ZRoomCommand -{ -public: - uint8_t disableSky; - uint8_t disableSunMoon; - - SetSkyboxModifier(ZFile* nParent); - - void ParseRawData() override; - - std::string GetBodySourceCode() const override; - - std::string GetCommandCName() const override; - RoomCommand GetRoomCommand() const override; -}; diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetSkyboxSettings.cpp b/ZAPDTR/ZAPD/ZRoom/Commands/SetSkyboxSettings.cpp deleted file mode 100644 index d5ae7ef76..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetSkyboxSettings.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include "SetSkyboxSettings.h" -#include "Globals.h" -#include "Utils/StringHelper.h" - -SetSkyboxSettings::SetSkyboxSettings(ZFile* nParent) : ZRoomCommand(nParent) -{ -} - -void SetSkyboxSettings::ParseRawData() -{ - ZRoomCommand::ParseRawData(); - unk1 = cmdArg1; - skyboxNumber = parent->GetRawData().at(rawDataIndex + 0x04); - cloudsType = parent->GetRawData().at(rawDataIndex + 0x05); - isIndoors = parent->GetRawData().at(rawDataIndex + 0x06); -} - -std::string SetSkyboxSettings::GetBodySourceCode() const -{ - std::string indoors = StringHelper::BoolStr(isIndoors); - if (Globals::Instance->game == ZGame::MM_RETAIL) - return StringHelper::Sprintf("SCENE_CMD_SKYBOX_SETTINGS(0x%02X, %i, %i, %s)", unk1, - skyboxNumber, cloudsType, indoors.c_str()); - return StringHelper::Sprintf("SCENE_CMD_SKYBOX_SETTINGS(%i, %i, %s)", skyboxNumber, cloudsType, - indoors.c_str()); -} - -std::string SetSkyboxSettings::GetCommandCName() const -{ - return "SCmdSkyboxSettings"; -} - -RoomCommand SetSkyboxSettings::GetRoomCommand() const -{ - return RoomCommand::SetSkyboxSettings; -} diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetSkyboxSettings.h b/ZAPDTR/ZAPD/ZRoom/Commands/SetSkyboxSettings.h deleted file mode 100644 index 1c7e01ad4..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetSkyboxSettings.h +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once - -#include "ZRoom/ZRoomCommand.h" - -class SetSkyboxSettings : public ZRoomCommand -{ -public: - uint8_t unk1; // (MM Only) - uint8_t skyboxNumber; - uint8_t cloudsType; - uint8_t isIndoors; - - SetSkyboxSettings(ZFile* nParent); - - void ParseRawData() override; - - std::string GetBodySourceCode() const override; - - std::string GetCommandCName() const override; - RoomCommand GetRoomCommand() const override; -}; diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetSoundSettings.cpp b/ZAPDTR/ZAPD/ZRoom/Commands/SetSoundSettings.cpp deleted file mode 100644 index 54b91328f..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetSoundSettings.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "SetSoundSettings.h" -#include "Utils/StringHelper.h" - -SetSoundSettings::SetSoundSettings(ZFile* nParent) : ZRoomCommand(nParent) -{ -} - -void SetSoundSettings::ParseRawData() -{ - ZRoomCommand::ParseRawData(); - reverb = cmdArg1; - nightTimeSFX = parent->GetRawData().at(rawDataIndex + 0x06); - musicSequence = parent->GetRawData().at(rawDataIndex + 0x07); -} - -std::string SetSoundSettings::GetBodySourceCode() const -{ - return StringHelper::Sprintf("SCENE_CMD_SOUND_SETTINGS(%i, %i, %i)", reverb, nightTimeSFX, - musicSequence); -} - -std::string SetSoundSettings::GetCommandCName() const -{ - return "SCmdSoundSettings"; -} - -RoomCommand SetSoundSettings::GetRoomCommand() const -{ - return RoomCommand::SetSoundSettings; -} diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetSoundSettings.h b/ZAPDTR/ZAPD/ZRoom/Commands/SetSoundSettings.h deleted file mode 100644 index f378e5e4e..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetSoundSettings.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once - -#include "ZRoom/ZRoomCommand.h" - -class SetSoundSettings : public ZRoomCommand -{ -public: - uint8_t reverb; - uint8_t nightTimeSFX; - uint8_t musicSequence; - - SetSoundSettings(ZFile* nParent); - - void ParseRawData() override; - - std::string GetBodySourceCode() const override; - - RoomCommand GetRoomCommand() const override; - std::string GetCommandCName() const override; -}; diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetSpecialObjects.cpp b/ZAPDTR/ZAPD/ZRoom/Commands/SetSpecialObjects.cpp deleted file mode 100644 index 696a3de01..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetSpecialObjects.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include "SetSpecialObjects.h" - -#include "Utils/BitConverter.h" -#include "Utils/StringHelper.h" -#include "ZRoom/ZNames.h" - -SetSpecialObjects::SetSpecialObjects(ZFile* nParent) : ZRoomCommand(nParent) -{ -} - -void SetSpecialObjects::ParseRawData() -{ - ZRoomCommand::ParseRawData(); - elfMessage = cmdArg1; - globalObject = BitConverter::ToUInt16BE(parent->GetRawData(), rawDataIndex + 0x06); -} - -std::string SetSpecialObjects::GetBodySourceCode() const -{ - std::string objectName = ZNames::GetObjectName(globalObject); - - return StringHelper::Sprintf("SCENE_CMD_SPECIAL_FILES(0x%02X, %s)", elfMessage, - objectName.c_str()); -} - -std::string SetSpecialObjects::GetCommandCName() const -{ - return "SCmdSpecialFiles"; -} - -RoomCommand SetSpecialObjects::GetRoomCommand() const -{ - return RoomCommand::SetSpecialObjects; -} diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetSpecialObjects.h b/ZAPDTR/ZAPD/ZRoom/Commands/SetSpecialObjects.h deleted file mode 100644 index 3327d44c3..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetSpecialObjects.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once - -#include "ZRoom/ZRoomCommand.h" - -class SetSpecialObjects : public ZRoomCommand -{ -public: - uint8_t elfMessage; - uint16_t globalObject; - - SetSpecialObjects(ZFile* nParent); - - void ParseRawData() override; - - std::string GetBodySourceCode() const override; - - RoomCommand GetRoomCommand() const override; - std::string GetCommandCName() const override; -}; diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetStartPositionList.cpp b/ZAPDTR/ZAPD/ZRoom/Commands/SetStartPositionList.cpp deleted file mode 100644 index 03856d23b..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetStartPositionList.cpp +++ /dev/null @@ -1,68 +0,0 @@ -#include "SetStartPositionList.h" - -#include "Globals.h" -#include "Utils/BitConverter.h" -#include "Utils/StringHelper.h" -#include "ZFile.h" -#include "ZRoom/ZNames.h" -#include "ZRoom/ZRoom.h" - -SetStartPositionList::SetStartPositionList(ZFile* nParent) : ZRoomCommand(nParent) -{ -} - -void SetStartPositionList::ParseRawData() -{ - ZRoomCommand::ParseRawData(); - uint8_t numActors = cmdArg1; - - offset_t currentPtr = segmentOffset; - - actors.reserve(numActors); - for (uint32_t i = 0; i < numActors; i++) - { - actors.push_back(ActorSpawnEntry(parent->GetRawData(), currentPtr)); - currentPtr += 16; - } -} - -void SetStartPositionList::DeclareReferences(const std::string& prefix) -{ - if (!actors.empty()) - { - std::string declaration; - - size_t index = 0; - for (const auto& entry : actors) - { - declaration += StringHelper::Sprintf(" { %s },", entry.GetBodySourceCode().c_str()); - if (index + 1 < actors.size()) - declaration += "\n"; - - index++; - } - - parent->AddDeclarationArray( - segmentOffset, DeclarationAlignment::Align4, actors.size() * 16, "ActorEntry", - StringHelper::Sprintf("%sStartPositionList0x%06X", prefix.c_str(), segmentOffset), - actors.size(), declaration); - } -} - -std::string SetStartPositionList::GetBodySourceCode() const -{ - std::string listName; - Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "ActorEntry", listName, - parent->workerID); - return StringHelper::Sprintf("SCENE_CMD_SPAWN_LIST(%i, %s)", actors.size(), listName.c_str()); -} - -std::string SetStartPositionList::GetCommandCName() const -{ - return "SCmdSpawnList"; -} - -RoomCommand SetStartPositionList::GetRoomCommand() const -{ - return RoomCommand::SetStartPositionList; -} diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetStartPositionList.h b/ZAPDTR/ZAPD/ZRoom/Commands/SetStartPositionList.h deleted file mode 100644 index 10075adf3..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetStartPositionList.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once - -#include "SetActorList.h" -#include "ZRoom/ZRoomCommand.h" - -class SetStartPositionList : public ZRoomCommand -{ -public: - std::vector actors; - - SetStartPositionList(ZFile* nParent); - - void ParseRawData() override; - void DeclareReferences(const std::string& prefix) override; - - std::string GetBodySourceCode() const override; - - RoomCommand GetRoomCommand() const override; - std::string GetCommandCName() const override; -}; diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetTimeSettings.cpp b/ZAPDTR/ZAPD/ZRoom/Commands/SetTimeSettings.cpp deleted file mode 100644 index 9d4d356df..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetTimeSettings.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "SetTimeSettings.h" -#include "Utils/BitConverter.h" -#include "Utils/StringHelper.h" - -SetTimeSettings::SetTimeSettings(ZFile* nParent) : ZRoomCommand(nParent) -{ -} - -void SetTimeSettings::ParseRawData() -{ - ZRoomCommand::ParseRawData(); - hour = parent->GetRawData().at(rawDataIndex + 4); - min = parent->GetRawData().at(rawDataIndex + 5); - unk = parent->GetRawData().at(rawDataIndex + 6); -} - -std::string SetTimeSettings::GetBodySourceCode() const -{ - return StringHelper::Sprintf("SCENE_CMD_TIME_SETTINGS(%i, %i, %i)", hour, min, unk); -} - -std::string SetTimeSettings::GetCommandCName() const -{ - return "SCmdTimeSettings"; -} - -RoomCommand SetTimeSettings::GetRoomCommand() const -{ - return RoomCommand::SetTimeSettings; -} diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetTimeSettings.h b/ZAPDTR/ZAPD/ZRoom/Commands/SetTimeSettings.h deleted file mode 100644 index 7ff2711d4..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetTimeSettings.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once - -#include "ZRoom/ZRoomCommand.h" - -class SetTimeSettings : public ZRoomCommand -{ -public: - uint8_t hour; - uint8_t min; - uint8_t unk; - - SetTimeSettings(ZFile* nParent); - - void ParseRawData() override; - - std::string GetBodySourceCode() const override; - - std::string GetCommandCName() const override; - RoomCommand GetRoomCommand() const override; -}; diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetTransitionActorList.cpp b/ZAPDTR/ZAPD/ZRoom/Commands/SetTransitionActorList.cpp deleted file mode 100644 index 051ddd875..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetTransitionActorList.cpp +++ /dev/null @@ -1,93 +0,0 @@ -#include "SetTransitionActorList.h" - -#include "Globals.h" -#include "Utils/BitConverter.h" -#include "Utils/StringHelper.h" -#include "ZFile.h" -#include "ZRoom/ZNames.h" -#include "ZRoom/ZRoom.h" - -SetTransitionActorList::SetTransitionActorList(ZFile* nParent) : ZRoomCommand(nParent) -{ -} - -void SetTransitionActorList::ParseRawData() -{ - ZRoomCommand::ParseRawData(); - int numActors = cmdArg1; - uint32_t currentPtr = segmentOffset; - - transitionActors.reserve(numActors); - for (int32_t i = 0; i < numActors; i++) - { - TransitionActorEntry entry(parent->GetRawData(), currentPtr); - transitionActors.push_back(entry); - - currentPtr += 16; - } -} - -void SetTransitionActorList::DeclareReferences(const std::string& prefix) -{ - std::string declaration; - - size_t index = 0; - for (const auto& entry : transitionActors) - { - declaration += StringHelper::Sprintf(" { %s },", entry.GetBodySourceCode().c_str()); - if (index + 1 < transitionActors.size()) - { - declaration += "\n"; - } - - index++; - } - - parent->AddDeclarationArray( - segmentOffset, DeclarationAlignment::Align4, transitionActors.size() * 16, - "TransitionActorEntry", - StringHelper::Sprintf("%sTransitionActorList_%06X", prefix.c_str(), segmentOffset), - transitionActors.size(), declaration); -} - -std::string SetTransitionActorList::GetBodySourceCode() const -{ - std::string listName; - Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "TransitionActorEntry", listName, - parent->workerID); - return StringHelper::Sprintf("SCENE_CMD_TRANSITION_ACTOR_LIST(%i, %s)", transitionActors.size(), - listName.c_str()); -} - -std::string SetTransitionActorList::GetCommandCName() const -{ - return "SCmdTransiActorList"; -} - -RoomCommand SetTransitionActorList::GetRoomCommand() const -{ - return RoomCommand::SetTransitionActorList; -} - -TransitionActorEntry::TransitionActorEntry(const std::vector& rawData, int rawDataIndex) -{ - frontObjectRoom = rawData[rawDataIndex + 0]; - frontTransitionReaction = rawData[rawDataIndex + 1]; - backObjectRoom = rawData[rawDataIndex + 2]; - backTransitionReaction = rawData[rawDataIndex + 3]; - actorNum = BitConverter::ToInt16BE(rawData, rawDataIndex + 4); - posX = BitConverter::ToInt16BE(rawData, rawDataIndex + 6); - posY = BitConverter::ToInt16BE(rawData, rawDataIndex + 8); - posZ = BitConverter::ToInt16BE(rawData, rawDataIndex + 10); - rotY = BitConverter::ToInt16BE(rawData, rawDataIndex + 12); - initVar = BitConverter::ToInt16BE(rawData, rawDataIndex + 14); -} - -std::string TransitionActorEntry::GetBodySourceCode() const -{ - std::string actorStr = ZNames::GetActorName(actorNum); - - return StringHelper::Sprintf("%i, %i, %i, %i, %s, %i, %i, %i, %i, 0x%04X", frontObjectRoom, - frontTransitionReaction, backObjectRoom, backTransitionReaction, - actorStr.c_str(), posX, posY, posZ, rotY, initVar); -} diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetTransitionActorList.h b/ZAPDTR/ZAPD/ZRoom/Commands/SetTransitionActorList.h deleted file mode 100644 index a5ce2e66f..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetTransitionActorList.h +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once - -#include "ZRoom/ZRoomCommand.h" - -class TransitionActorEntry -{ -public: - uint8_t frontObjectRoom; - uint8_t frontTransitionReaction; - uint8_t backObjectRoom; - uint8_t backTransitionReaction; - uint16_t actorNum; - int16_t posX, posY, posZ; - int16_t rotY; - uint16_t initVar; - - TransitionActorEntry(const std::vector& rawData, int rawDataIndex); - - std::string GetBodySourceCode() const; -}; - -class SetTransitionActorList : public ZRoomCommand -{ -public: - std::vector transitionActors; - - SetTransitionActorList(ZFile* nParent); - - void ParseRawData() override; - void DeclareReferences(const std::string& prefix) override; - - std::string GetBodySourceCode() const override; - - RoomCommand GetRoomCommand() const override; - std::string GetCommandCName() const override; -}; diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetWind.cpp b/ZAPDTR/ZAPD/ZRoom/Commands/SetWind.cpp deleted file mode 100644 index 1893b5601..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetWind.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include "SetWind.h" -#include "Utils/StringHelper.h" - -SetWind::SetWind(ZFile* nParent) : ZRoomCommand(nParent) -{ -} - -void SetWind::ParseRawData() -{ - ZRoomCommand::ParseRawData(); - auto& parentRawData = parent->GetRawData(); - windWest = parentRawData.at(rawDataIndex + 0x04); - windVertical = parentRawData.at(rawDataIndex + 0x05); - windSouth = parentRawData.at(rawDataIndex + 0x06); - clothFlappingStrength = parentRawData.at(rawDataIndex + 0x07); -} - -std::string SetWind::GetBodySourceCode() const -{ - return StringHelper::Sprintf("SCENE_CMD_WIND_SETTINGS(%i, %i, %i, %i)", windWest, windVertical, - windSouth, clothFlappingStrength); -} - -std::string SetWind::GetCommandCName() const -{ - return "SCmdWindSettings"; -} - -RoomCommand SetWind::GetRoomCommand() const -{ - return RoomCommand::SetWind; -} diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetWind.h b/ZAPDTR/ZAPD/ZRoom/Commands/SetWind.h deleted file mode 100644 index 05eaafeda..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetWind.h +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once - -#include "ZRoom/ZRoomCommand.h" - -class SetWind : public ZRoomCommand -{ -public: - uint8_t windWest; - uint8_t windVertical; - uint8_t windSouth; - uint8_t clothFlappingStrength; - - SetWind(ZFile* nParent); - - void ParseRawData() override; - - std::string GetBodySourceCode() const override; - - std::string GetCommandCName() const override; - RoomCommand GetRoomCommand() const override; -}; diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetWorldMapVisited.cpp b/ZAPDTR/ZAPD/ZRoom/Commands/SetWorldMapVisited.cpp deleted file mode 100644 index d20e4a3e2..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetWorldMapVisited.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "SetWorldMapVisited.h" - -#include "Utils/StringHelper.h" - -SetWorldMapVisited::SetWorldMapVisited(ZFile* nParent) : ZRoomCommand(nParent) -{ -} - -std::string SetWorldMapVisited::GetBodySourceCode() const -{ - return "SCENE_CMD_MISC_SETTINGS()"; -} - -std::string SetWorldMapVisited::GetCommandCName() const -{ - return "SCmdWorldMapVisited"; -} - -RoomCommand SetWorldMapVisited::GetRoomCommand() const -{ - return RoomCommand::SetWorldMapVisited; -} diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetWorldMapVisited.h b/ZAPDTR/ZAPD/ZRoom/Commands/SetWorldMapVisited.h deleted file mode 100644 index a7ad93154..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetWorldMapVisited.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include "ZRoom/ZRoomCommand.h" - -class SetWorldMapVisited : public ZRoomCommand -{ -public: - SetWorldMapVisited(ZFile* nParent); - - std::string GetBodySourceCode() const override; - - RoomCommand GetRoomCommand() const override; - std::string GetCommandCName() const override; -}; diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/Unused09.cpp b/ZAPDTR/ZAPD/ZRoom/Commands/Unused09.cpp deleted file mode 100644 index 9dfcaa5c2..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/Unused09.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "Unused09.h" -#include "Utils/StringHelper.h" - -Unused09::Unused09(ZFile* nParent) : ZRoomCommand(nParent) -{ -} - -std::string Unused09::GetBodySourceCode() const -{ - return "SCENE_CMD_UNK_09()"; -} - -std::string Unused09::GetCommandCName() const -{ - return "SceneCmd"; -} - -RoomCommand Unused09::GetRoomCommand() const -{ - return RoomCommand::Unused09; -} diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/Unused09.h b/ZAPDTR/ZAPD/ZRoom/Commands/Unused09.h deleted file mode 100644 index a38985eea..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/Unused09.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include "ZRoom/ZRoomCommand.h" - -class Unused09 : public ZRoomCommand -{ -public: - Unused09(ZFile* nParent); - - std::string GetBodySourceCode() const override; - - RoomCommand GetRoomCommand() const override; - std::string GetCommandCName() const override; -}; diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/Unused1D.cpp b/ZAPDTR/ZAPD/ZRoom/Commands/Unused1D.cpp deleted file mode 100644 index b8ea13652..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/Unused1D.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "Unused1D.h" -#include "Utils/StringHelper.h" - -Unused1D::Unused1D(ZFile* nParent) : ZRoomCommand(nParent) -{ -} - -std::string Unused1D::GetBodySourceCode() const -{ - return StringHelper::Sprintf("{ %s, 0x00, 0x00 }", GetCommandHex().c_str()); -} - -std::string Unused1D::GetCommandCName() const -{ - return "SceneCmd"; -} - -RoomCommand Unused1D::GetRoomCommand() const -{ - return RoomCommand::Unused1D; -} diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/Unused1D.h b/ZAPDTR/ZAPD/ZRoom/Commands/Unused1D.h deleted file mode 100644 index dea0f98ee..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/Unused1D.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include "ZRoom/ZRoomCommand.h" - -class Unused1D : public ZRoomCommand -{ -public: - Unused1D(ZFile* nParent); - - std::string GetBodySourceCode() const override; - - RoomCommand GetRoomCommand() const override; - std::string GetCommandCName() const override; -}; diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/ZRoomCommandUnk.cpp b/ZAPDTR/ZAPD/ZRoom/Commands/ZRoomCommandUnk.cpp deleted file mode 100644 index a892086c2..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/ZRoomCommandUnk.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "ZRoomCommandUnk.h" -#include "Utils/BitConverter.h" -#include "Utils/StringHelper.h" -#include "ZRoom/ZRoom.h" - -ZRoomCommandUnk::ZRoomCommandUnk(ZFile* nParent) : ZRoomCommand(nParent) -{ -} - -std::string ZRoomCommandUnk::GetBodySourceCode() const -{ - return StringHelper::Sprintf("{ %s, 0x%02X, 0x%06X } /* WARNING: " - "UNIMPLEMENTED ROOM COMMAND */", - GetCommandHex().c_str(), cmdArg1, cmdArg2); -} - -RoomCommand ZRoomCommandUnk::GetRoomCommand() const -{ - return RoomCommand::Error; -} diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/ZRoomCommandUnk.h b/ZAPDTR/ZAPD/ZRoom/Commands/ZRoomCommandUnk.h deleted file mode 100644 index e381fe5a5..000000000 --- a/ZAPDTR/ZAPD/ZRoom/Commands/ZRoomCommandUnk.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once -#include "ZRoom/ZRoomCommand.h" - -class ZRoomCommandUnk : public ZRoomCommand -{ -public: - ZRoomCommandUnk(ZFile* nParent); - - std::string GetBodySourceCode() const override; - - RoomCommand GetRoomCommand() const override; -}; diff --git a/ZAPDTR/ZAPD/ZRoom/ZNames.h b/ZAPDTR/ZAPD/ZRoom/ZNames.h deleted file mode 100644 index 667407c36..000000000 --- a/ZAPDTR/ZAPD/ZRoom/ZNames.h +++ /dev/null @@ -1,64 +0,0 @@ -#pragma once - -#include - -#include "Globals.h" -#include "Utils/StringHelper.h" - -class ZNames -{ -public: - static std::string GetObjectName(size_t id) - { - if (id >= Globals::Instance->cfg.objectList.size()) - return StringHelper::Sprintf("0x%04X", id); - return Globals::Instance->cfg.objectList[id]; - } - - static std::string GetActorName(uint16_t id) - { - switch (Globals::Instance->game) - { - case ZGame::OOT_RETAIL: - case ZGame::OOT_SW97: - if (id < ZNames::GetNumActors()) - return Globals::Instance->cfg.actorList[id]; - else - return StringHelper::Sprintf("0x%04X", id); - case ZGame::MM_RETAIL: - { - int32_t flags = id & 0xF000; - id &= 0xFFF; - std::string name; - if (id < ZNames::GetNumActors()) - name = Globals::Instance->cfg.actorList[id]; - else - name = StringHelper::Sprintf("0x%04X", id); - - if (flags == 0) - return name; - else - return StringHelper::Sprintf("%s | 0x%04X", name.c_str(), flags); - } - } - - return ""; - } - - static std::string GetEntranceName(uint16_t id) - { - if (ZNames::GetNumEntrances() == 0 || ZNames::GetNumSpecialEntrances() == 0) - return StringHelper::Sprintf("0x%04X", id); - - if (id < ZNames::GetNumEntrances()) - return Globals::Instance->cfg.entranceList[id]; - else if ((id >= 0x7FF9 && id <= 0x7FFF) && !((id - 0x7FF9U) > GetNumSpecialEntrances())) // Special entrances - return Globals::Instance->cfg.specialEntranceList[id - 0x7FF9]; - else - return StringHelper::Sprintf("0x%04X", id); - } - - static size_t GetNumActors() { return Globals::Instance->cfg.actorList.size(); } - static size_t GetNumEntrances() { return Globals::Instance->cfg.entranceList.size(); } - static size_t GetNumSpecialEntrances() { return Globals::Instance->cfg.specialEntranceList.size(); } -}; diff --git a/ZAPDTR/ZAPD/ZRoom/ZRoom.cpp b/ZAPDTR/ZAPD/ZRoom/ZRoom.cpp deleted file mode 100644 index 11dd70687..000000000 --- a/ZAPDTR/ZAPD/ZRoom/ZRoom.cpp +++ /dev/null @@ -1,427 +0,0 @@ -#include "ZRoom.h" -#include -#include -#include -#include -#include - -#include "Commands/EndMarker.h" -#include "Commands/SetActorCutsceneList.h" -#include "Commands/SetActorList.h" -#include "Commands/SetAlternateHeaders.h" -#include "Commands/SetAnimatedMaterialList.h" -#include "Commands/SetCameraSettings.h" -#include "Commands/SetCollisionHeader.h" -#include "Commands/SetCsCamera.h" -#include "Commands/SetCutscenes.h" -#include "Commands/SetEchoSettings.h" -#include "Commands/SetEntranceList.h" -#include "Commands/SetExitList.h" -#include "Commands/SetLightList.h" -#include "Commands/SetLightingSettings.h" -#include "Commands/SetMesh.h" -#include "Commands/SetMinimapChests.h" -#include "Commands/SetMinimapList.h" -#include "Commands/SetObjectList.h" -#include "Commands/SetPathways.h" -#include "Commands/SetRoomBehavior.h" -#include "Commands/SetRoomList.h" -#include "Commands/SetSkyboxModifier.h" -#include "Commands/SetSkyboxSettings.h" -#include "Commands/SetSoundSettings.h" -#include "Commands/SetSpecialObjects.h" -#include "Commands/SetStartPositionList.h" -#include "Commands/SetTimeSettings.h" -#include "Commands/SetTransitionActorList.h" -#include "Commands/SetWind.h" -#include "Commands/SetWorldMapVisited.h" -#include "Commands/Unused09.h" -#include "Commands/Unused1D.h" -#include "Commands/ZRoomCommandUnk.h" -#include "Globals.h" -#include -#include "Utils/Path.h" -#include "Utils/StringHelper.h" -#include "WarningHandler.h" -#include "ZBlob.h" -#include "ZCutscene.h" -#include "ZFile.h" - -REGISTER_ZFILENODE(Room, ZRoom); -REGISTER_ZFILENODE(Scene, ZRoom); -REGISTER_ZFILENODE(AltHeader, ZRoom); - -ZRoom::ZRoom(ZFile* nParent) : ZResource(nParent) -{ - roomCount = -1; - canHaveInner = true; - RegisterOptionalAttribute("HackMode"); -} - -ZRoom::~ZRoom() -{ - for (ZRoomCommand* cmd : commands) - delete cmd; -} - -void ZRoom::ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) -{ - ZResource::ExtractFromXML(reader, nRawDataIndex); - - if (hackMode == "syotes_room") - { - SyotesRoomHack(); - } - else - { - DeclareVar(name, ""); - } -} - -void ZRoom::ExtractFromBinary(uint32_t nRawDataIndex, ZResourceType parentType) -{ - rawDataIndex = nRawDataIndex; - name = GetDefaultName(parent->GetName()); - - zroomType = ZResourceType::AltHeader; - switch (parentType) - { - case ZResourceType::Scene: - case ZResourceType::Room: - case ZResourceType::AltHeader: - parentZroomType = parentType; - break; - - default: - // TODO: error message or something - assert(false); - break; - } - - ParseRawData(); - DeclareVar(name, ""); -} - -void ZRoom::ParseXML(tinyxml2::XMLElement* reader) -{ - ZResource::ParseXML(reader); - - // TODO: HACK: remove this specific check when the repo uses the correct HackMode="syotes_room" - if (name == "syotes_room_0") - { - hackMode = "syotes_room"; - } - - std::string nodeName = std::string(reader->Name()); - if (nodeName == "Scene") - { - zroomType = ZResourceType::Scene; - } - else if (nodeName == "Room") - zroomType = ZResourceType::Room; - else if (nodeName == "AltHeader") - zroomType = ZResourceType::AltHeader; - - if (reader->Attribute("HackMode") != nullptr) - { - hackMode = std::string(reader->Attribute("HackMode")); - if (hackMode != "syotes_room") - { - std::string headerError = StringHelper::Sprintf( - "invalid value found for 'HackMode' attribute: '%s'", hackMode.c_str()); - HANDLE_ERROR_RESOURCE(WarningType::InvalidAttributeValue, parent, this, rawDataIndex, - headerError, ""); - } - } -} - -void ZRoom::ParseRawData() -{ - if (hackMode == "syotes_room") - return; - - bool shouldContinue = true; - uint32_t currentIndex = 0; - uint32_t currentPtr = rawDataIndex; - - const auto& rawData = parent->GetRawData(); - while (shouldContinue) - { - RoomCommand opcode = static_cast(rawData.at(currentPtr)); - - ZRoomCommand* cmd = nullptr; - - auto start = std::chrono::steady_clock::now(); - - switch (opcode) - { - case RoomCommand::SetStartPositionList: - cmd = new SetStartPositionList(parent); - break; // 0x00 - case RoomCommand::SetActorList: - cmd = new SetActorList(parent); - break; // 0x01 - case RoomCommand::SetCsCamera: - cmd = new SetCsCamera(parent); - break; // 0x02 (MM-ONLY) - case RoomCommand::SetCollisionHeader: - cmd = new SetCollisionHeader(parent); - break; // 0x03 - case RoomCommand::SetRoomList: - cmd = new SetRoomList(parent); - break; // 0x04 - case RoomCommand::SetWind: - cmd = new SetWind(parent); - break; // 0x05 - case RoomCommand::SetEntranceList: - cmd = new SetEntranceList(parent); - break; // 0x06 - case RoomCommand::SetSpecialObjects: - cmd = new SetSpecialObjects(parent); - break; // 0x07 - case RoomCommand::SetRoomBehavior: - cmd = new SetRoomBehavior(parent); - break; // 0x08 - case RoomCommand::Unused09: - cmd = new Unused09(parent); - break; // 0x09 - case RoomCommand::SetMesh: - cmd = new SetMesh(parent); - break; // 0x0A - case RoomCommand::SetObjectList: - cmd = new SetObjectList(parent); - break; // 0x0B - case RoomCommand::SetLightList: - cmd = new SetLightList(parent); - break; // 0x0C (MM-ONLY) - case RoomCommand::SetPathways: - cmd = new SetPathways(parent); - break; // 0x0D - case RoomCommand::SetTransitionActorList: - cmd = new SetTransitionActorList(parent); - break; // 0x0E - case RoomCommand::SetLightingSettings: - cmd = new SetLightingSettings(parent); - break; // 0x0F - case RoomCommand::SetTimeSettings: - cmd = new SetTimeSettings(parent); - break; // 0x10 - case RoomCommand::SetSkyboxSettings: - cmd = new SetSkyboxSettings(parent); - break; // 0x11 - case RoomCommand::SetSkyboxModifier: - cmd = new SetSkyboxModifier(parent); - break; // 0x12 - case RoomCommand::SetExitList: - cmd = new SetExitList(parent); - break; // 0x13 - case RoomCommand::EndMarker: - cmd = new EndMarker(parent); - break; // 0x14 - case RoomCommand::SetSoundSettings: - cmd = new SetSoundSettings(parent); - break; // 0x15 - case RoomCommand::SetEchoSettings: - cmd = new SetEchoSettings(parent); - break; // 0x16 - case RoomCommand::SetCutscenes: - cmd = new SetCutscenes(parent); - break; // 0x17 - case RoomCommand::SetAlternateHeaders: - cmd = new SetAlternateHeaders(parent); - break; // 0x18 - case RoomCommand::SetCameraSettings: - if (Globals::Instance->game == ZGame::MM_RETAIL) - cmd = new SetWorldMapVisited(parent); - else - cmd = new SetCameraSettings(parent); - break; // 0x19 - case RoomCommand::SetAnimatedMaterialList: - cmd = new SetAnimatedMaterialList(parent); - break; // 0x1A (MM-ONLY) - case RoomCommand::SetActorCutsceneList: - cmd = new SetActorCutsceneList(parent); - break; // 0x1B (MM-ONLY) - case RoomCommand::SetMinimapList: - cmd = new SetMinimapList(parent); - break; // 0x1C (MM-ONLY) - case RoomCommand::Unused1D: - cmd = new Unused1D(parent); - break; // 0x1D - case RoomCommand::SetMinimapChests: - cmd = new SetMinimapChests(parent); - break; // 0x1E (MM-ONLY) - default: - cmd = new ZRoomCommandUnk(parent); - } - - cmd->commandSet = rawDataIndex; - cmd->ExtractCommandFromRoom(this, currentPtr); - - if (Globals::Instance->profile) - { - auto end = std::chrono::steady_clock::now(); - int64_t diff = - std::chrono::duration_cast(end - start).count(); - if (diff > 50) - printf("OP: %s, TIME: %" PRIi64 "ms\n", cmd->GetCommandCName().c_str(), diff); - } - - cmd->cmdIndex = currentIndex; - - commands.push_back(cmd); - - if (opcode == RoomCommand::EndMarker) - shouldContinue = false; - - currentPtr += 8; - currentIndex++; - } -} - -void ZRoom::DeclareReferences(const std::string& prefix) -{ - for (auto& cmd : commands) - cmd->DeclareReferences(prefix); -} - -void ZRoom::ParseRawDataLate() -{ - for (auto& cmd : commands) - cmd->ParseRawDataLate(); -} - -void ZRoom::DeclareReferencesLate(const std::string& prefix) -{ - for (auto& cmd : commands) - cmd->DeclareReferencesLate(prefix); -} - -Declaration* ZRoom::DeclareVar(const std::string& prefix, const std::string& body) -{ - std::string auxName = name; - if (auxName == "") - auxName = GetDefaultName(prefix); - if (zroomType == ZResourceType::Scene || zroomType == ZResourceType::Room) - auxName = StringHelper::Sprintf("%sCommands", name.c_str()); - - Declaration* decl = - parent->AddDeclarationArray(rawDataIndex, GetDeclarationAlignment(), GetRawDataSize(), - GetSourceTypeName(), auxName, commands.size(), body); - decl->staticConf = staticConf; - return decl; -} - -std::string ZRoom::GetBodySourceCode() const -{ - std::string declaration; - - for (size_t i = 0; i < commands.size(); i++) - { - ZRoomCommand* cmd = commands[i]; - declaration += StringHelper::Sprintf("\t%s,", cmd->GetBodySourceCode().c_str()); - - if (i + 1 < commands.size()) - declaration += "\n"; - } - - return declaration; -} - -std::string ZRoom::GetDefaultName(const std::string& prefix) const -{ - return StringHelper::Sprintf("%sSet_%06X", prefix.c_str(), rawDataIndex); -} - -/* - * There is one room in Ocarina of Time that lacks a header. Room 120, "Syotes", dates - * back to very early in the game's development. Since this room is a special case, - * declare automatically the data its contains whitout the need of a header. - */ -void ZRoom::SyotesRoomHack() -{ - PolygonType2 poly(parent, 0, this); - - poly.ParseRawData(); - poly.DeclareReferences(GetName()); - parent->AddDeclaration(0, poly.GetDeclarationAlignment(), poly.GetRawDataSize(), - poly.GetSourceTypeName(), poly.GetDefaultName(GetName()), - poly.GetBodySourceCode()); -} - -ZRoomCommand* ZRoom::FindCommandOfType(RoomCommand cmdType) -{ - for (size_t i = 0; i < commands.size(); i++) - { - if (commands[i]->GetRoomCommand() == cmdType) - return commands[i]; - } - - return nullptr; -} - -size_t ZRoom::GetDeclarationSizeFromNeighbor(uint32_t declarationAddress) -{ - auto currentDecl = parent->declarations.find(declarationAddress); - if (currentDecl == parent->declarations.end()) - return 0; - - auto nextDecl = currentDecl; - std::advance(nextDecl, 1); - if (nextDecl == parent->declarations.end()) - return parent->GetRawData().size() - currentDecl->first; - - return nextDecl->first - currentDecl->first; -} - -size_t ZRoom::GetCommandSizeFromNeighbor(ZRoomCommand* cmd) -{ - int32_t cmdIndex = -1; - - for (size_t i = 0; i < commands.size(); i++) - { - if (commands[i] == cmd) - { - cmdIndex = i; - break; - } - } - - if (cmdIndex != -1) - { - if (cmdIndex + 1 < (int32_t)commands.size()) - return commands[cmdIndex + 1]->cmdAddress - commands[cmdIndex]->cmdAddress; - else - return parent->GetRawData().size() - commands[cmdIndex]->cmdAddress; - } - - return 0; -} - -void ZRoom::GetSourceOutputCode([[maybe_unused]] const std::string& prefix) -{ - if (hackMode != "syotes_room") - DeclareVar(prefix, GetBodySourceCode()); -} - -size_t ZRoom::GetRawDataSize() const -{ - size_t size = 0; - - for (ZRoomCommand* cmd : commands) - size += cmd->GetRawDataSize(); - - return size; -} - -std::string ZRoom::GetSourceTypeName() const -{ - return "SceneCmd"; -} - -ZResourceType ZRoom::GetResourceType() const -{ - assert(zroomType == ZResourceType::Scene || zroomType == ZResourceType::Room || - zroomType == ZResourceType::AltHeader); - return zroomType; -} diff --git a/ZAPDTR/ZAPD/ZRoom/ZRoom.h b/ZAPDTR/ZAPD/ZRoom/ZRoom.h deleted file mode 100644 index e837ec70a..000000000 --- a/ZAPDTR/ZAPD/ZRoom/ZRoom.h +++ /dev/null @@ -1,50 +0,0 @@ -#pragma once - -#include -#include -#include - -#include "ZResource.h" -#include "ZRoomCommand.h" -#include "tinyxml2.h" - -class ZRoom : public ZResource -{ -public: - std::vector commands; - int32_t roomCount; // Only valid for scenes - - std::string hackMode; - - ZResourceType zroomType = ZResourceType::Error; - ZResourceType parentZroomType = ZResourceType::Error; - - ZRoom(ZFile* nParent); - virtual ~ZRoom(); - - void ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) override; - void ExtractFromBinary(uint32_t nRawDataIndex, ZResourceType parentType); - - void ParseXML(tinyxml2::XMLElement* reader) override; - void ParseRawData() override; - void DeclareReferences(const std::string& prefix) override; - void ParseRawDataLate() override; - void DeclareReferencesLate(const std::string& prefix) override; - - Declaration* DeclareVar(const std::string& prefix, const std::string& body) override; - std::string GetBodySourceCode() const override; - - void GetSourceOutputCode(const std::string& prefix) override; - - std::string GetDefaultName(const std::string& prefix) const override; - size_t GetDeclarationSizeFromNeighbor(uint32_t declarationAddress); - size_t GetCommandSizeFromNeighbor(ZRoomCommand* cmd); - ZRoomCommand* FindCommandOfType(RoomCommand cmdType); - - size_t GetRawDataSize() const override; - std::string GetSourceTypeName() const override; - ZResourceType GetResourceType() const override; - -protected: - void SyotesRoomHack(); -}; diff --git a/ZAPDTR/ZAPD/ZRoom/ZRoomCommand.cpp b/ZAPDTR/ZAPD/ZRoom/ZRoomCommand.cpp deleted file mode 100644 index 711c86a40..000000000 --- a/ZAPDTR/ZAPD/ZRoom/ZRoomCommand.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#include "ZRoomCommand.h" - -#include "Utils/BitConverter.h" -#include "Utils/StringHelper.h" -#include "ZRoom.h" - -ZRoomCommand::ZRoomCommand(ZFile* nParent) : ZResource(nParent) -{ -} - -void ZRoomCommand::ExtractCommandFromRoom(ZRoom* nZRoom, uint32_t nRawDataIndex) -{ - zRoom = nZRoom; - rawDataIndex = nRawDataIndex; - - ParseRawData(); -} - -void ZRoomCommand::ParseRawData() -{ - auto& parentRawData = parent->GetRawData(); - cmdID = static_cast(parentRawData.at(rawDataIndex)); - cmdAddress = rawDataIndex; - - cmdArg1 = parentRawData.at(rawDataIndex + 1); - cmdArg2 = BitConverter::ToUInt32BE(parentRawData, rawDataIndex + 4); - segmentOffset = Seg2Filespace(cmdArg2, parent->baseAddress); -} - -RoomCommand ZRoomCommand::GetRoomCommand() const -{ - return RoomCommand::Error; -} - -size_t ZRoomCommand::GetRawDataSize() const -{ - return 0x08; -} - -std::string ZRoomCommand::GetSourceTypeName() const -{ - return GetCommandCName(); -} - -ZResourceType ZRoomCommand::GetResourceType() const -{ - return ZResourceType::RoomCommand; -} - -std::string ZRoomCommand::GetCommandCName() const -{ - return "SceneCmd"; -} - -std::string ZRoomCommand::GetCommandHex() const -{ - return StringHelper::Sprintf("0x%02X", static_cast(cmdID)); -} diff --git a/ZAPDTR/ZAPD/ZRoom/ZRoomCommand.h b/ZAPDTR/ZAPD/ZRoom/ZRoomCommand.h deleted file mode 100644 index 5e4d0bc54..000000000 --- a/ZAPDTR/ZAPD/ZRoom/ZRoomCommand.h +++ /dev/null @@ -1,84 +0,0 @@ -#pragma once - -#include "tinyxml2.h" - -#include -#include - -#include "ZFile.h" -#include "ZResource.h" - -class ZRoom; - -enum class RoomCommand : uint8_t -{ - SetStartPositionList = 0x00, - SetActorList = 0x01, - SetCsCamera = 0x02, - SetCollisionHeader = 0x03, - SetRoomList = 0x04, - SetWind = 0x05, - SetEntranceList = 0x06, - SetSpecialObjects = 0x07, - SetRoomBehavior = 0x08, - Unused09 = 0x09, - SetMesh = 0x0A, - SetObjectList = 0x0B, - SetLightList = 0x0C, - SetPathways = 0x0D, - SetTransitionActorList = 0x0E, - SetLightingSettings = 0x0F, - SetTimeSettings = 0x10, - SetSkyboxSettings = 0x11, - SetSkyboxModifier = 0x12, - SetExitList = 0x13, - EndMarker = 0x14, - SetSoundSettings = 0x15, - SetEchoSettings = 0x16, - SetCutscenes = 0x17, - SetAlternateHeaders = 0x18, - SetCameraSettings = 0x19, - - // MM Commands - SetWorldMapVisited = 0x19, - SetAnimatedMaterialList = 0x1A, - SetActorCutsceneList = 0x1B, - SetMinimapList = 0x1C, - Unused1D = 0x1D, - SetMinimapChests = 0x1E, - - Error = 0xFF -}; - -class ZRoomCommand : public ZResource -{ -public: - int32_t cmdAddress; - uint32_t cmdIndex; - uint32_t commandSet; - RoomCommand cmdID; - offset_t segmentOffset; - - ZRoomCommand(ZFile* nParent); - virtual ~ZRoomCommand() = default; - - virtual void ExtractCommandFromRoom(ZRoom* nZRoom, uint32_t nRawDataIndex); - - void ParseRawData() override; - - std::string GetSourceTypeName() const override; - ZResourceType GetResourceType() const override; - - // Getters/Setters - virtual RoomCommand GetRoomCommand() const = 0; - size_t GetRawDataSize() const final override; - virtual std::string GetCommandCName() const; - - virtual std::string GetCommandHex() const; - -public: - ZRoom* zRoom; - - uint8_t cmdArg1; - segptr_t cmdArg2; -}; diff --git a/ZAPDTR/ZAPD/ZScalar.cpp b/ZAPDTR/ZAPD/ZScalar.cpp deleted file mode 100644 index 6c4cf121a..000000000 --- a/ZAPDTR/ZAPD/ZScalar.cpp +++ /dev/null @@ -1,280 +0,0 @@ -#include "ZScalar.h" - -#include "Globals.h" -#include "Utils/BitConverter.h" -#include -#include "Utils/StringHelper.h" -#include "WarningHandler.h" -#include "ZFile.h" - -REGISTER_ZFILENODE(Scalar, ZScalar); - -ZScalar::ZScalar(ZFile* nParent) : ZResource(nParent) -{ - memset(&scalarData, 0, sizeof(ZScalarData)); - scalarType = ZScalarType::ZSCALAR_NONE; - RegisterRequiredAttribute("Type"); -} - -void ZScalar::ExtractFromBinary(uint32_t nRawDataIndex, ZScalarType nScalarType) -{ - rawDataIndex = nRawDataIndex; - scalarType = nScalarType; - - // Don't parse raw data of external files - if (parent->GetMode() == ZFileMode::ExternalFile) - return; - - ParseRawData(); -} - -void ZScalar::ParseXML(tinyxml2::XMLElement* reader) -{ - ZResource::ParseXML(reader); - - scalarType = ZScalar::MapOutputTypeToScalarType(registeredAttributes.at("Type").value); -} - -ZScalarType ZScalar::MapOutputTypeToScalarType(const std::string& type) -{ - if (type == "s8") - { - return ZScalarType::ZSCALAR_S8; - } - else if (type == "u8") - { - return ZScalarType::ZSCALAR_U8; - } - else if (type == "x8") - { - return ZScalarType::ZSCALAR_X8; - } - else if (type == "s16") - { - return ZScalarType::ZSCALAR_S16; - } - else if (type == "u16") - { - return ZScalarType::ZSCALAR_U16; - } - else if (type == "x16") - { - return ZScalarType::ZSCALAR_X16; - } - else if (type == "s32") - { - return ZScalarType::ZSCALAR_S32; - } - else if (type == "u32") - { - return ZScalarType::ZSCALAR_U32; - } - else if (type == "x32") - { - return ZScalarType::ZSCALAR_X32; - } - else if (type == "s64") - { - return ZScalarType::ZSCALAR_S64; - } - else if (type == "u64") - { - return ZScalarType::ZSCALAR_U64; - } - else if (type == "x64") - { - return ZScalarType::ZSCALAR_X64; - } - else if (type == "f32") - { - return ZScalarType::ZSCALAR_F32; - } - else if (type == "f64") - { - return ZScalarType::ZSCALAR_F64; - } - - return ZScalarType::ZSCALAR_NONE; -} - -std::string ZScalar::MapScalarTypeToOutputType(const ZScalarType scalarType) -{ - switch (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"; - case ZScalarType::ZSCALAR_F64: - return "f64"; - default: - return ""; - } -} - -size_t ZScalar::MapTypeToSize(const ZScalarType scalarType) -{ - switch (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); - case ZScalarType::ZSCALAR_F64: - return sizeof(scalarData.f64); - default: - return 0; - } -} - -size_t ZScalar::GetRawDataSize() const -{ - return ZScalar::MapTypeToSize(scalarType); -} - -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: - scalarData.f32 = BitConverter::ToFloatBE(rawData, rawDataIndex); - break; - case ZScalarType::ZSCALAR_F64: - scalarData.f64 = BitConverter::ToDoubleBE(rawData, rawDataIndex); - break; - case ZScalarType::ZSCALAR_NONE: - HANDLE_ERROR_RESOURCE(WarningType::InvalidAttributeValue, parent, this, rawDataIndex, - "invalid value found for 'Type' attribute", "Defaulting to ''"); - break; - } -} - -std::string ZScalar::GetSourceTypeName() const -{ - return ZScalar::MapScalarTypeToOutputType(scalarType); -} - -std::string ZScalar::GetBodySourceCode() const -{ - switch (scalarType) - { - case ZScalarType::ZSCALAR_S8: - 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: - return StringHelper::Sprintf("%lf", scalarData.f64); - default: - return "SCALAR_ERROR"; - } -} - -ZResourceType ZScalar::GetResourceType() const -{ - return ZResourceType::Scalar; -} - -bool ZScalar::DoesSupportArray() const -{ - return true; -} - -DeclarationAlignment ZScalar::GetDeclarationAlignment() const -{ - switch (scalarType) - { - case ZScalarType::ZSCALAR_S64: - case ZScalarType::ZSCALAR_U64: - case ZScalarType::ZSCALAR_F64: - return DeclarationAlignment::Align8; - default: - return DeclarationAlignment::Align4; - } -} diff --git a/ZAPDTR/ZAPD/ZScalar.h b/ZAPDTR/ZAPD/ZScalar.h deleted file mode 100644 index 8f98f261d..000000000 --- a/ZAPDTR/ZAPD/ZScalar.h +++ /dev/null @@ -1,68 +0,0 @@ -#pragma once - -#include -#include -#include -#include "ZResource.h" -#include "tinyxml2.h" - -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 -}; - -typedef union ZScalarData -{ - uint8_t u8; - int8_t s8; - uint16_t u16; - int16_t s16; - uint32_t u32; - int32_t s32; - uint64_t u64; - int64_t s64; - float f32; - double f64; -} ZScalarData; - -class ZScalar : public ZResource -{ - friend class ZVector; - -public: - ZScalarData scalarData; - ZScalarType scalarType; - - ZScalar(ZFile* nParent); - - void ExtractFromBinary(uint32_t nRawDataIndex, ZScalarType nScalarType); - - void ParseRawData() override; - void ParseXML(tinyxml2::XMLElement* reader) override; - std::string GetBodySourceCode() const override; - - bool DoesSupportArray() const override; - std::string GetSourceTypeName() const override; - ZResourceType GetResourceType() const override; - - size_t GetRawDataSize() const override; - DeclarationAlignment GetDeclarationAlignment() const override; - - static size_t MapTypeToSize(const ZScalarType scalarType); - static ZScalarType MapOutputTypeToScalarType(const std::string& type); - static std::string MapScalarTypeToOutputType(const ZScalarType scalarType); -}; diff --git a/ZAPDTR/ZAPD/ZSkeleton.cpp b/ZAPDTR/ZAPD/ZSkeleton.cpp deleted file mode 100644 index a071209bc..000000000 --- a/ZAPDTR/ZAPD/ZSkeleton.cpp +++ /dev/null @@ -1,478 +0,0 @@ -#include "ZSkeleton.h" - -#include - -#include "Globals.h" -#include "Utils/BitConverter.h" -#include "Utils/StringHelper.h" -#include "WarningHandler.h" - -REGISTER_ZFILENODE(Skeleton, ZSkeleton); -REGISTER_ZFILENODE(LimbTable, ZLimbTable); - -ZSkeleton::ZSkeleton(ZFile* nParent) : ZResource(nParent) -{ - RegisterRequiredAttribute("Type"); - RegisterRequiredAttribute("LimbType"); - genOTRDef = true; - - RegisterOptionalAttribute("EnumName"); - RegisterOptionalAttribute("LimbNone"); - RegisterOptionalAttribute("LimbMax"); - - genOTRDef = true; -} - -void ZSkeleton::ParseXML(tinyxml2::XMLElement* reader) -{ - ZResource::ParseXML(reader); - - std::string skelTypeXml = registeredAttributes.at("Type").value; - - if (skelTypeXml == "Flex") - type = ZSkeletonType::Flex; - else if (skelTypeXml == "Curve") - type = ZSkeletonType::Curve; - else if (skelTypeXml != "Normal") - { - HANDLE_ERROR_RESOURCE(WarningType::InvalidAttributeValue, parent, this, rawDataIndex, - "invalid value found for 'Type' attribute", ""); - } - - std::string limbTypeXml = registeredAttributes.at("LimbType").value; - limbType = ZLimb::GetTypeByAttributeName(limbTypeXml); - if (limbType == ZLimbType::Invalid) - { - HANDLE_ERROR_RESOURCE( - WarningType::InvalidAttributeValue, parent, this, rawDataIndex, - StringHelper::Sprintf("invalid value '%s' found for 'LimbType' attribute", - limbTypeXml.c_str()), - "Defaulting to 'Standard'."); - } - - enumName = registeredAttributes.at("EnumName").value; - limbNoneName = registeredAttributes.at("LimbNone").value; - limbMaxName = registeredAttributes.at("LimbMax").value; - - if (enumName != "") - { - if (limbNoneName == "" || limbMaxName == "") - { - HANDLE_ERROR_RESOURCE(WarningType::MissingAttribute, parent, this, rawDataIndex, - "'EnumName' attribute was used but either 'LimbNone' or " - "'LimbMax' attribute is missing", - ""); - } - } - - if (limbNoneName != "") - { - if (limbMaxName == "") - { - HANDLE_ERROR_RESOURCE( - WarningType::MissingAttribute, parent, this, rawDataIndex, - "'LimbNone' attribute was used but 'LimbMax' attribute is missing", ""); - } - } - - if (limbMaxName != "") - { - if (limbNoneName == "") - { - HANDLE_ERROR_RESOURCE( - WarningType::MissingAttribute, parent, this, rawDataIndex, - "'LimbMax' attribute was used but 'LimbNone' attribute is missing", ""); - } - } -} - -void ZSkeleton::ParseRawData() -{ - ZResource::ParseRawData(); - - const auto& rawData = parent->GetRawData(); - limbsArrayAddress = BitConverter::ToUInt32BE(rawData, rawDataIndex); - limbCount = BitConverter::ToUInt8BE(rawData, rawDataIndex + 4); - - if (type == ZSkeletonType::Flex) - { - dListCount = BitConverter::ToUInt8BE(rawData, rawDataIndex + 8); - } -} - -void ZSkeleton::DeclareReferences(const std::string& prefix) -{ - std::string defaultPrefix = name; - if (defaultPrefix == "") - defaultPrefix = prefix; - - ZResource::DeclareReferences(defaultPrefix); - - if (limbsArrayAddress != SEGMENTED_NULL && GETSEGNUM(limbsArrayAddress) == parent->segment) - { - offset_t ptr = Seg2Filespace(limbsArrayAddress, parent->baseAddress); - - if (!parent->HasDeclaration(ptr)) - { - limbsTable = new ZLimbTable(parent); - limbsTable->ExtractFromBinary(ptr, limbType, limbCount); - limbsTable->SetName(StringHelper::Sprintf("%sLimbs", defaultPrefix.c_str())); - parent->AddResource(limbsTable); - } - else - { - limbsTable = static_cast(parent->FindResource(ptr)); - } - - if (limbsTable->enumName == "") - { - limbsTable->enumName = enumName; - } - if (limbsTable->limbNoneName == "") - { - limbsTable->limbNoneName = limbNoneName; - } - if (limbsTable->limbMaxName == "") - { - limbsTable->limbMaxName = limbMaxName; - } - } -} - -std::string ZSkeleton::GetBodySourceCode() const -{ - std::string limbArrayName; - Globals::Instance->GetSegmentedPtrName(limbsArrayAddress, parent, "", limbArrayName, - parent->workerID); - - std::string countStr; - assert(limbsTable != nullptr); - // There are some Skeletons with the wrong limb count on them, so this check is necessary. - if (limbsTable->count == limbCount) - { - countStr = StringHelper::Sprintf("ARRAY_COUNT(%s)", limbArrayName.c_str()); - } - else - { - countStr = StringHelper::Sprintf("%i", limbCount); - } - - switch (type) - { - case ZSkeletonType::Normal: - case ZSkeletonType::Curve: - return StringHelper::Sprintf("\n\t%s, %s\n", limbArrayName.c_str(), countStr.c_str()); - - case ZSkeletonType::Flex: - return StringHelper::Sprintf("\n\t{ %s, %s }, %i\n", limbArrayName.c_str(), - countStr.c_str(), dListCount); - } - - // TODO: Throw exception? - return "ERROR"; -} - -size_t ZSkeleton::GetRawDataSize() const -{ - switch (type) - { - case ZSkeletonType::Flex: - return 0xC; - case ZSkeletonType::Normal: - case ZSkeletonType::Curve: - default: - return 0x8; - } -} - -std::string ZSkeleton::GetSourceTypeName() const -{ - switch (type) - { - case ZSkeletonType::Normal: - return "SkeletonHeader"; - case ZSkeletonType::Flex: - return "FlexSkeletonHeader"; - case ZSkeletonType::Curve: - return "SkelCurveLimbList"; - } - - return "SkeletonHeader"; -} - -ZResourceType ZSkeleton::GetResourceType() const -{ - return ZResourceType::Skeleton; -} - -DeclarationAlignment ZSkeleton::GetDeclarationAlignment() const -{ - return DeclarationAlignment::Align4; -} - -uint8_t ZSkeleton::GetLimbCount() -{ - return limbCount; -} - -/* ZLimbTable */ - -ZLimbTable::ZLimbTable(ZFile* nParent) : ZResource(nParent) -{ - RegisterRequiredAttribute("LimbType"); - RegisterRequiredAttribute("Count"); - RegisterOptionalAttribute("EnumName"); - RegisterOptionalAttribute("LimbNone"); - RegisterOptionalAttribute("LimbMax"); -} - -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) - { - HANDLE_WARNING_RESOURCE(WarningType::InvalidAttributeValue, parent, this, rawDataIndex, - "invalid value found for 'LimbType' attribute.", - "Defaulting to 'Standard'."); - limbType = ZLimbType::Standard; - } - - count = StringHelper::StrToL(registeredAttributes.at("Count").value); - - enumName = registeredAttributes.at("EnumName").value; - limbNoneName = registeredAttributes.at("LimbNone").value; - limbMaxName = registeredAttributes.at("LimbMax").value; - - if (enumName != "") - { - if (limbNoneName == "" || limbMaxName == "") - { - HANDLE_ERROR_RESOURCE( - WarningType::MissingAttribute, parent, this, rawDataIndex, - "'EnumName' attribute was used but 'LimbNone'/'LimbMax' attributes is missing", ""); - } - } - - if (limbNoneName != "") - { - if (limbMaxName == "") - { - HANDLE_ERROR_RESOURCE( - WarningType::MissingAttribute, parent, this, rawDataIndex, - "'LimbNone' attribute was used but 'LimbMax' attribute is missing", ""); - } - } - - if (limbMaxName != "") - { - if (limbNoneName == "") - { - HANDLE_ERROR_RESOURCE( - WarningType::MissingAttribute, parent, this, rawDataIndex, - "'LimbMax' attribute was used but 'LimbNone' attribute is missing", ""); - } - } -} - -void ZLimbTable::ParseRawData() -{ - ZResource::ParseRawData(); - - const auto& rawData = parent->GetRawData(); - uint32_t ptr = rawDataIndex; - - limbsAddresses.reserve(count); - 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 = name; - if (varPrefix == "") - varPrefix = prefix; - - ZResource::DeclareReferences(varPrefix); - limbsReferences.reserve(count); - 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); - ZLimb* limb; - - if (!parent->HasDeclaration(limbOffset)) - { - limb = new ZLimb(parent); - limb->ExtractFromBinary(limbOffset, limbType); - limb->SetName(limb->GetDefaultName(varPrefix)); - limb->DeclareVar(varPrefix, ""); - limb->DeclareReferences(varPrefix); - parent->AddResource(limb); - } - else - { - limb = static_cast(parent->FindResource(limbOffset)); - assert(limb != nullptr); - assert(limb->GetResourceType() == ZResourceType::Limb); - } - - limb->limbsTable = this; - limb->SetLimbIndex(i + 1); - - limbsReferences.push_back(limb); - } - } -} - -Declaration* ZLimbTable::DeclareVar(const std::string& prefix, const std::string& bodyStr) -{ - std::string auxName = name; - - if (name == "") - auxName = GetDefaultName(prefix); - - Declaration* decl = - parent->AddDeclarationArray(rawDataIndex, GetDeclarationAlignment(), GetRawDataSize(), - GetSourceTypeName(), auxName, limbsAddresses.size(), bodyStr); - decl->staticConf = staticConf; - return decl; -} - -std::string ZLimbTable::GetBodySourceCode() const -{ - std::string body; - - for (size_t i = 0; i < count; i++) - { - std::string limbName; - Globals::Instance->GetSegmentedPtrName(limbsAddresses[i], parent, "", limbName, - parent->workerID); - body += StringHelper::Sprintf("\t%s,", limbName.c_str()); - - auto& limb = limbsReferences.at(i); - std::string limbEnumName = limb->enumName; - if (limbEnumName != "") - { - body += StringHelper::Sprintf(" /* %s */", limbEnumName.c_str()); - } - - if (i + 1 < count) - body += "\n"; - } - - return body; -} - -std::string ZLimbTable::GetSourceOutputHeader([[maybe_unused]] const std::string& prefix) -{ - if (limbNoneName == "" || limbMaxName == "" || enumName == "") - { - // Don't produce a enum of any of those attributes is missing - return ""; - } - - std::string limbEnum = StringHelper::Sprintf("typedef enum %s {\n", enumName.c_str()); - - // This assumes there isn't any skeleton with more than 0x100 limbs - - limbEnum += StringHelper::Sprintf(" /* 0x00 */ %s,\n", limbNoneName.c_str()); - - size_t i = 0; - for (; i < count; i++) - { - auto& limb = limbsReferences.at(i); - std::string limbEnumName = limb->enumName; - - if (limbEnumName == "") - { - HANDLE_ERROR_RESOURCE( - WarningType::MissingAttribute, parent, this, rawDataIndex, - "Skeleton's enum attributes were used but at least one limb is missing its " - "'LimbName' attribute", - StringHelper::Sprintf("When processing limb %02i, named '%s' at offset '0x%X'", - i + 1, limb->GetName().c_str(), limb->GetRawDataIndex())); - } - - limbEnum += StringHelper::Sprintf(" /* 0x%02X */ %s,\n", i + 1, limbEnumName.c_str()); - } - - limbEnum += StringHelper::Sprintf(" /* 0x%02X */ %s\n", i + 1, limbMaxName.c_str()); - - limbEnum += StringHelper::Sprintf("} %s;\n", enumName.c_str()); - - return limbEnum; -} - -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: - // TODO: Proper error message or something. - assert("Invalid limb type.\n"); - } - - return "ERROR"; -} - -ZResourceType ZLimbTable::GetResourceType() const -{ - return ZResourceType::LimbTable; -} - -size_t ZLimbTable::GetRawDataSize() const -{ - return 4 * limbsAddresses.size(); -} - -std::string ZLimbTable::GetLimbEnumName(uint8_t limbIndex) const -{ - if (limbIndex == 0xFF) - { - return "LIMB_DONE"; - } - - if (limbIndex < count) - { - std::string limbEnumName = limbsReferences.at(limbIndex)->enumName; - if (limbEnumName != "") - { - return StringHelper::Sprintf("%s - 1", limbEnumName.c_str()); - } - } - else - { - HANDLE_WARNING_RESOURCE(WarningType::InvalidExtractedData, parent, this, rawDataIndex, - StringHelper::Sprintf("Limb index '%02i' out of range", limbIndex), - ""); - } - - return StringHelper::Sprintf("0x%02X", limbIndex); -} diff --git a/ZAPDTR/ZAPD/ZSkeleton.h b/ZAPDTR/ZAPD/ZSkeleton.h deleted file mode 100644 index 892d5de35..000000000 --- a/ZAPDTR/ZAPD/ZSkeleton.h +++ /dev/null @@ -1,85 +0,0 @@ -#pragma once - -#include -#include -#include - -#include "ZDisplayList.h" -#include "ZFile.h" -#include "ZLimb.h" - -enum class ZSkeletonType -{ - Normal, - Flex, - Curve, -}; - -class ZLimbTable : public ZResource -{ -public: - ZLimbType limbType = ZLimbType::Standard; - size_t count = 0; - - std::vector limbsAddresses; - std::vector limbsReferences; // borrowed pointers, do not delete! - - // XML attributes - std::string enumName; - std::string limbNoneName; - std::string limbMaxName; - - ZLimbTable(ZFile* nParent); - - 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; - - Declaration* DeclareVar(const std::string& prefix, const std::string& bodyStr) override; - - std::string GetBodySourceCode() const override; - - std::string GetSourceOutputHeader([[maybe_unused]] const std::string& prefix); - - std::string GetSourceTypeName() const override; - ZResourceType GetResourceType() const override; - - size_t GetRawDataSize() const override; - - std::string GetLimbEnumName(uint8_t limbIndex) const; -}; - -class ZSkeleton : public ZResource -{ -public: - ZSkeletonType type = ZSkeletonType::Normal; - ZLimbType limbType = ZLimbType::Standard; - std::string enumName; - std::string limbNoneName; - std::string limbMaxName; - - segptr_t limbsArrayAddress; - uint8_t limbCount = 0; - uint8_t dListCount = 0; // FLEX SKELETON ONLY - - ZSkeleton(ZFile* nParent); - - void ParseXML(tinyxml2::XMLElement* reader) override; - void ParseRawData() override; - void DeclareReferences(const std::string& prefix) override; - - std::string GetBodySourceCode() const override; - - std::string GetSourceTypeName() const override; - ZResourceType GetResourceType() const override; - - size_t GetRawDataSize() const override; - DeclarationAlignment GetDeclarationAlignment() const override; - - uint8_t GetLimbCount(); - - ZLimbTable* limbsTable = nullptr; // borrowed pointer, do not delete! - -}; diff --git a/ZAPDTR/ZAPD/ZString.cpp b/ZAPDTR/ZAPD/ZString.cpp deleted file mode 100644 index 4a9069496..000000000 --- a/ZAPDTR/ZAPD/ZString.cpp +++ /dev/null @@ -1,69 +0,0 @@ -#include "ZString.h" - -#include -#include "Utils/StringHelper.h" -#include "ZFile.h" - -REGISTER_ZFILENODE(String, ZString); - -ZString::ZString(ZFile* nParent) : ZResource(nParent) -{ -} - -void ZString::ParseRawData() -{ - size_t size = 0; - const auto& rawData = parent->GetRawData(); - const auto& rawDataArr = rawData.data(); - size_t rawDataSize = rawData.size(); - for (size_t i = rawDataIndex; i < rawDataSize; ++i) - { - ++size; - if (rawDataArr[i] == '\0') - { - break; - } - } - - auto dataStart = rawData.begin() + rawDataIndex; - strData.assign(dataStart, dataStart + size); -} - -Declaration* ZString::DeclareVar(const std::string& prefix, const std::string& bodyStr) -{ - std::string auxName = name; - - if (name == "") - auxName = GetDefaultName(prefix); - - Declaration* decl = - parent->AddDeclarationArray(rawDataIndex, GetDeclarationAlignment(), GetRawDataSize(), - GetSourceTypeName(), auxName, 0, bodyStr); - decl->staticConf = staticConf; - return decl; -} - -std::string ZString::GetBodySourceCode() const -{ - return StringHelper::Sprintf("\t\"%s\"", strData.data()); -} - -std::string ZString::GetSourceOutputHeader([[maybe_unused]] const std::string& prefix, std::set *nameSet) -{ - return StringHelper::Sprintf("#define %s_macro \"%s\"", name.c_str(), strData.data()); -} - -std::string ZString::GetSourceTypeName() const -{ - return "char"; -} - -ZResourceType ZString::GetResourceType() const -{ - return ZResourceType::String; -} - -size_t ZString::GetRawDataSize() const -{ - return strData.size(); -} diff --git a/ZAPDTR/ZAPD/ZString.h b/ZAPDTR/ZAPD/ZString.h deleted file mode 100644 index 19f615a90..000000000 --- a/ZAPDTR/ZAPD/ZString.h +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once - -#include "ZResource.h" -#include "tinyxml2.h" - -class ZString : public ZResource -{ -public: - ZString(ZFile* nParent); - - void ParseRawData() override; - - Declaration* DeclareVar(const std::string& prefix, const std::string& bodyStr) override; - std::string GetBodySourceCode() const override; - - std::string GetSourceOutputHeader(const std::string& prefix, std::set *nameSet) override; - std::string GetSourceTypeName() const override; - ZResourceType GetResourceType() const override; - - size_t GetRawDataSize() const override; - -protected: - std::vector strData; -}; diff --git a/ZAPDTR/ZAPD/ZSurfaceType.cpp b/ZAPDTR/ZAPD/ZSurfaceType.cpp deleted file mode 100644 index 27e73accc..000000000 --- a/ZAPDTR/ZAPD/ZSurfaceType.cpp +++ /dev/null @@ -1,65 +0,0 @@ -#include "ZSurfaceType.h" - -#include "Globals.h" -#include "Utils/BitConverter.h" -#include "Utils/StringHelper.h" - -REGISTER_ZFILENODE(SurfaceType, ZSurfaceType); - -ZSurfaceType::ZSurfaceType(ZFile* nParent) : ZResource(nParent) -{ -} - -ZSurfaceType::~ZSurfaceType() -{ -} - -void ZSurfaceType::ParseRawData() -{ - const auto& rawData = parent->GetRawData(); - - data[0] = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0); - data[1] = BitConverter::ToUInt32BE(rawData, rawDataIndex + 4); -} - -void ZSurfaceType::DeclareReferences(const std::string& prefix) -{ - std::string declaration; - std::string auxName = name; - - if (name == "") - auxName = GetDefaultName(prefix); - - parent->AddDeclaration(rawDataIndex, DeclarationAlignment::Align4, GetRawDataSize(), - GetSourceTypeName(), name.c_str(), GetBodySourceCode()); -} - -std::string ZSurfaceType::GetBodySourceCode() const -{ - return StringHelper::Sprintf("{0x%08X, 0x%08X}", data[0], data[1]); -} - -std::string ZSurfaceType::GetDefaultName(const std::string& prefix) const -{ - return StringHelper::Sprintf("%sSurfaceType_%06X", prefix.c_str(), rawDataIndex); -} - -ZResourceType ZSurfaceType::GetResourceType() const -{ - return ZResourceType::SurfaceType; -} - -size_t ZSurfaceType::GetRawDataSize() const -{ - return 8; -} - -std::string ZSurfaceType::GetSourceTypeName() const -{ - return "SurfaceType"; -} - -bool ZSurfaceType::DoesSupportArray() const -{ - return true; -} diff --git a/ZAPDTR/ZAPD/ZSurfaceType.h b/ZAPDTR/ZAPD/ZSurfaceType.h deleted file mode 100644 index 3bbddee8c..000000000 --- a/ZAPDTR/ZAPD/ZSurfaceType.h +++ /dev/null @@ -1,27 +0,0 @@ -#pragma once - -#include -#include "ZFile.h" -#include "ZResource.h" - -class ZSurfaceType : public ZResource -{ -public: - std::array data; - - ZSurfaceType(ZFile* nParent); - ~ZSurfaceType(); - - void ParseRawData() override; - void DeclareReferences(const std::string& prefix) override; - - std::string GetBodySourceCode() const override; - std::string GetDefaultName(const std::string& prefix) const override; - - std::string GetSourceTypeName() const override; - ZResourceType GetResourceType() const override; - - bool DoesSupportArray() const override; - - size_t GetRawDataSize() const override; -}; diff --git a/ZAPDTR/ZAPD/ZSymbol.cpp b/ZAPDTR/ZAPD/ZSymbol.cpp deleted file mode 100644 index b5df68669..000000000 --- a/ZAPDTR/ZAPD/ZSymbol.cpp +++ /dev/null @@ -1,98 +0,0 @@ -#include "ZSymbol.h" - -#include "Utils/StringHelper.h" -#include "WarningHandler.h" -#include "ZFile.h" - -REGISTER_ZFILENODE(Symbol, ZSymbol); - -ZSymbol::ZSymbol(ZFile* nParent) : ZResource(nParent) -{ - RegisterOptionalAttribute("Type"); - RegisterOptionalAttribute("TypeSize"); - RegisterOptionalAttribute("Count"); -} - -void ZSymbol::ParseXML(tinyxml2::XMLElement* reader) -{ - ZResource::ParseXML(reader); - - std::string typeXml = registeredAttributes.at("Type").value; - - if (typeXml == "") - { - HANDLE_WARNING_RESOURCE(WarningType::MissingAttribute, parent, this, rawDataIndex, - "missing 'Type' attribute in ", "Defaulting to 'void*'."); - type = "void*"; - } - else - { - type = typeXml; - } - - std::string typeSizeXml = registeredAttributes.at("TypeSize").value; - if (typeSizeXml == "") - { - HANDLE_WARNING_RESOURCE(WarningType::MissingAttribute, parent, this, rawDataIndex, - "missing 'TypeSize' attribute in ", "Defaulting to '4'."); - typeSize = 4; // Size of a word. - } - else - { - typeSize = StringHelper::StrToL(typeSizeXml, 0); - } - - if (registeredAttributes.at("Count").wasSet) - { - isArray = true; - - std::string countXml = registeredAttributes.at("Count").value; - if (countXml != "") - count = StringHelper::StrToL(countXml, 0); - } - - if (registeredAttributes.at("Static").value == "On") - { - HANDLE_WARNING_RESOURCE(WarningType::InvalidAttributeValue, parent, this, rawDataIndex, - "a cannot be marked as static", - "Disabling static for this resource."); - } - staticConf = StaticConfig::Off; -} - -Declaration* ZSymbol::DeclareVar([[maybe_unused]] const std::string& prefix, - [[maybe_unused]] const std::string& bodyStr) -{ - return nullptr; -} - -size_t ZSymbol::GetRawDataSize() const -{ - if (isArray) - return count * typeSize; - - return typeSize; -} - -std::string ZSymbol::GetSourceOutputHeader([[maybe_unused]] const std::string& prefix, std::set *nameSet) -{ - if (isArray) - { - if (count == 0) - return StringHelper::Sprintf("extern %s %s[];\n", type.c_str(), name.c_str()); - else - return StringHelper::Sprintf("extern %s %s[%i];\n", type.c_str(), name.c_str(), count); - } - - return StringHelper::Sprintf("extern %s %s;\n", type.c_str(), name.c_str()); -} - -std::string ZSymbol::GetSourceTypeName() const -{ - return type; -} - -ZResourceType ZSymbol::GetResourceType() const -{ - return ZResourceType::Symbol; -} diff --git a/ZAPDTR/ZAPD/ZSymbol.h b/ZAPDTR/ZAPD/ZSymbol.h deleted file mode 100644 index e00f14c6b..000000000 --- a/ZAPDTR/ZAPD/ZSymbol.h +++ /dev/null @@ -1,27 +0,0 @@ -#pragma once - -#include "ZResource.h" -#include "tinyxml2.h" - -class ZSymbol : public ZResource -{ -protected: - std::string type; - size_t typeSize; - bool isArray = false; - uint32_t count = 0; - -public: - ZSymbol(ZFile* nParent); - - void ParseXML(tinyxml2::XMLElement* reader) override; - - Declaration* DeclareVar(const std::string& prefix, const std::string& bodyStr) override; - - std::string GetSourceOutputHeader(const std::string& prefix, std::set *nameSet) override; - - std::string GetSourceTypeName() const override; - ZResourceType GetResourceType() const override; - - size_t GetRawDataSize() const override; -}; diff --git a/ZAPDTR/ZAPD/ZText.cpp b/ZAPDTR/ZAPD/ZText.cpp deleted file mode 100644 index 95e4b5236..000000000 --- a/ZAPDTR/ZAPD/ZText.cpp +++ /dev/null @@ -1,137 +0,0 @@ -#include "ZText.h" - -#include "Globals.h" -#include "Utils/BitConverter.h" -#include -#include "Utils/Path.h" -#include "Utils/StringHelper.h" -#include "ZFile.h" - -REGISTER_ZFILENODE(Text, ZText); - -ZText::ZText(ZFile* nParent) : ZResource(nParent) -{ - RegisterRequiredAttribute("CodeOffset"); - RegisterOptionalAttribute("LangOffset", "0"); -} - -void ZText::ParseRawData() -{ - ZResource::ParseRawData(); - - const auto& rawData = parent->GetRawData(); - uint32_t currentPtr = StringHelper::StrToL(registeredAttributes.at("CodeOffset").value, 16); - uint32_t langPtr = currentPtr; - bool isPalLang = false; - - if (StringHelper::StrToL(registeredAttributes.at("LangOffset").value, 16) != 0) - { - langPtr = StringHelper::StrToL(registeredAttributes.at("LangOffset").value, 16); - - if (langPtr != currentPtr) - isPalLang = true; - } - - std::vector codeData; - - if (Globals::Instance->fileMode == ZFileMode::ExtractDirectory) - codeData = Globals::Instance->GetBaseromFile("code"); - else - codeData = Globals::Instance->GetBaseromFile(Globals::Instance->baseRomPath.string() + "code"); - - while (true) - { - MessageEntry msgEntry; - msgEntry.id = BitConverter::ToInt16BE(codeData, currentPtr + 0); - msgEntry.textboxType = (codeData[currentPtr + 2] & 0xF0) >> 4; - msgEntry.textboxYPos = (codeData[currentPtr + 2] & 0x0F); - - if (isPalLang) - { - msgEntry.segmentId = (codeData[langPtr + 0]); - msgEntry.msgOffset = BitConverter::ToInt32BE(codeData, langPtr + 0) & 0x00FFFFFF; - } - else - { - msgEntry.segmentId = (codeData[langPtr + 4]); - msgEntry.msgOffset = BitConverter::ToInt32BE(codeData, langPtr + 4) & 0x00FFFFFF; - } - - uint32_t msgPtr = msgEntry.msgOffset; - - unsigned char c = rawData[msgPtr]; - unsigned int extra = 0; - bool stop = false; - - // Continue parsing until we are told to stop and all extra bytes are read - while ((c != '\0' && !stop) || extra > 0) - { - msgEntry.msg += c; - msgPtr++; - - // Some control codes require reading extra bytes - if (extra == 0) - { - // End marker, so stop this message and do not read anything else - if (c == 0x02) - { - stop = true; - } - else if (c == 0x05 || c == 0x13 || c == 0x0E || c == 0x0C || c == 0x1E || c == 0x06 || - c == 0x14) - { - extra = 1; - } - // "Continue to new text ID", so stop this message and read two more bytes for the text ID - else if (c == 0x07) - { - extra = 2; - stop = true; - } - else if (c == 0x12 || c == 0x11) - { - extra = 2; - } - else if (c == 0x15) - { - extra = 3; - } - } - else - { - extra--; - } - - c = rawData[msgPtr]; - } - - messages.push_back(msgEntry); - - if (msgEntry.id == 0xFFFC || msgEntry.id == 0xFFFF) - break; - - currentPtr += 8; - - if (isPalLang) - langPtr += 4; - else - langPtr += 8; - } - - int bp2 = 0; -} - -std::string ZText::GetSourceTypeName() const -{ - return "u8"; -} - -size_t ZText::GetRawDataSize() const -{ - return 1; -} - -ZResourceType ZText::GetResourceType() const -{ - return ZResourceType::Text; -} diff --git a/ZAPDTR/ZAPD/ZText.h b/ZAPDTR/ZAPD/ZText.h deleted file mode 100644 index 37b9c66a9..000000000 --- a/ZAPDTR/ZAPD/ZText.h +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once - -#include "ZResource.h" -#include "tinyxml2.h" - -class MessageEntry -{ -public: - uint16_t id; - uint8_t textboxType; - uint8_t textboxYPos; - uint32_t segmentId; - uint32_t msgOffset; - std::string msg; -}; - -class ZText : public ZResource -{ -public: - std::vector messages; - - ZText(ZFile* nParent); - - void ParseRawData() override; - - std::string GetSourceTypeName() const override; - ZResourceType GetResourceType() const override; - - size_t GetRawDataSize() const override; -}; diff --git a/ZAPDTR/ZAPD/ZTexture.cpp b/ZAPDTR/ZAPD/ZTexture.cpp deleted file mode 100644 index 5184b834b..000000000 --- a/ZAPDTR/ZAPD/ZTexture.cpp +++ /dev/null @@ -1,974 +0,0 @@ -#include "ZTexture.h" - -#include - -#include "CRC32.h" -#include "Globals.h" -#include "Utils/BitConverter.h" -#include "Utils/Directory.h" -#include -#include "Utils/Path.h" -#include "WarningHandler.h" - -REGISTER_ZFILENODE(Texture, ZTexture); - -ZTexture::ZTexture(ZFile* nParent) : ZResource(nParent) -{ - width = 0; - height = 0; - dWordAligned = true; - genOTRDef = true; - splitTlut = false; - - RegisterRequiredAttribute("Width"); - RegisterRequiredAttribute("Height"); - RegisterRequiredAttribute("Format"); - RegisterOptionalAttribute("TlutOffset"); - RegisterOptionalAttribute("ExternalTlut"); - RegisterOptionalAttribute("ExternalTlutOffset"); - RegisterOptionalAttribute("SplitTlut"); - - // Dummy property added by https://github.com/HarbourMasters/Shipwright/pull/3161 - // Used to indicate if a resource definition was added through a script - // and to enable easy removal/re-add of the definitions when introducing new rom support - // Can be removed once we feel it is no longer useful - // This is not used in ZAPD itself, the registration is to prevent missing attribute errors - RegisterOptionalAttribute("AddedByScript"); -} - -void ZTexture::ExtractFromBinary(uint32_t nRawDataIndex, int32_t nWidth, int32_t nHeight, - TextureType nType, bool nIsPalette) -{ - width = nWidth; - height = nHeight; - format = nType; - rawDataIndex = nRawDataIndex; - isPalette = nIsPalette; - name = GetDefaultName(parent->GetName()); - outName = name; - - // Don't parse raw data of external files - if (parent->GetMode() == ZFileMode::ExternalFile) - return; - - ParseRawData(); - CalcHash(); -} - -void ZTexture::FromPNG(const fs::path& pngFilePath, TextureType texType) -{ - format = texType; - name = StringHelper::Split(Path::GetFileNameWithoutExtension(pngFilePath.string()), ".")[0]; - PrepareRawDataFromFile(pngFilePath); -} - -void ZTexture::ParseXML(tinyxml2::XMLElement* reader) -{ - ZResource::ParseXML(reader); - - std::string widthXml = registeredAttributes.at("Width").value; - std::string heightXml = registeredAttributes.at("Height").value; - std::string SplitTlutXml = registeredAttributes.at("SplitTlut").value; - - if (!StringHelper::HasOnlyDigits(widthXml)) - { - std::string errorHeader = StringHelper::Sprintf( - "value of 'Width' attribute has non-decimal digits: '%s'", widthXml.c_str()); - HANDLE_ERROR_RESOURCE(WarningType::InvalidAttributeValue, parent, this, rawDataIndex, - errorHeader, ""); - } - if (!StringHelper::HasOnlyDigits(heightXml)) - { - std::string errorHeader = StringHelper::Sprintf( - "value of 'Height' attribute has non-decimal digits: '%s'", heightXml.c_str()); - HANDLE_ERROR_RESOURCE(WarningType::InvalidAttributeValue, parent, this, rawDataIndex, - errorHeader, ""); - } - - if (!registeredAttributes.at("ExternalTlut").wasSet && - registeredAttributes.at("SplitTlut").wasSet) - { - std::string errorHeader = - StringHelper::Sprintf("SplitTlut set without using an external tlut"); - HANDLE_WARNING_RESOURCE(WarningType::InvalidAttributeValue, parent, this, rawDataIndex, - errorHeader, ""); - } - - if (!SplitTlutXml.empty()) - { - if (!tinyxml2::XMLUtil::ToBool(SplitTlutXml.c_str(), &splitTlut)) - { - std::string errorHeader = StringHelper::Sprintf( - "Invalid value passed to SplitTlut: '%s'. Valid values are true, false, 1, 0", - SplitTlutXml.c_str()); - HANDLE_ERROR_RESOURCE(WarningType::InvalidAttributeValue, parent, this, rawDataIndex, - errorHeader, ""); - } - } - - width = StringHelper::StrToL(widthXml); - height = StringHelper::StrToL(heightXml); - - std::string formatStr = registeredAttributes.at("Format").value; - format = GetTextureTypeFromString(formatStr); - - if (format == TextureType::Error) - { - HANDLE_ERROR_RESOURCE(WarningType::InvalidAttributeValue, parent, this, rawDataIndex, - "invalid value found for 'Format' attribute", ""); - } - - const auto& tlutOffsetAttr = registeredAttributes.at("TlutOffset"); - if (tlutOffsetAttr.wasSet) - { - switch (format) - { - case TextureType::Palette4bpp: - case TextureType::Palette8bpp: - tlutOffset = StringHelper::StrToL(tlutOffsetAttr.value, 16); - break; - - default: - HANDLE_ERROR_RESOURCE(WarningType::InvalidXML, parent, this, rawDataIndex, - "'TlutOffset' declared in non color-indexed (ci4 or ci8) texture", - ""); - break; - } - } -} - -void ZTexture::ParseRawData() -{ - if (rawDataIndex % 8 != 0) - dWordAligned = false; - - switch (format) - { - case TextureType::RGBA16bpp: - PrepareBitmapRGBA16(); - break; - case TextureType::RGBA32bpp: - PrepareBitmapRGBA32(); - break; - case TextureType::Grayscale4bpp: - PrepareBitmapGrayscale4(); - break; - case TextureType::Grayscale8bpp: - PrepareBitmapGrayscale8(); - break; - case TextureType::GrayscaleAlpha4bpp: - PrepareBitmapGrayscaleAlpha4(); - break; - case TextureType::GrayscaleAlpha8bpp: - PrepareBitmapGrayscaleAlpha8(); - break; - case TextureType::GrayscaleAlpha16bpp: - PrepareBitmapGrayscaleAlpha16(); - break; - case TextureType::Palette4bpp: - PrepareBitmapPalette4(); - break; - case TextureType::Palette8bpp: - PrepareBitmapPalette8(); - break; - case TextureType::Error: - HANDLE_ERROR_RESOURCE(WarningType::InvalidAttributeValue, parent, this, rawDataIndex, - StringHelper::Sprintf("Invalid texture format", format), ""); - assert(!"TODO"); - break; - } -} - -void ZTexture::ParseRawDataLate() -{ - if (registeredAttributes["ExternalTlut"].wasSet) - { - const std::string externPalette = registeredAttributes["ExternalTlut"].value; - for (const auto& file : Globals::Instance->files) - { - if (file->GetName() == externPalette) - { - offset_t palOffset = 0; - if (registeredAttributes["ExternalTlutOffset"].wasSet) - { - palOffset = - StringHelper::StrToL(registeredAttributes["ExternalTlutOffset"].value, 16); - } - else - { - HANDLE_WARNING_RESOURCE( - WarningType::MissingOffsets, parent, this, rawDataIndex, - StringHelper::Sprintf( - "No ExternalTlutOffset Given. Assuming offset of 0x0"), - ""); - } - for (const auto& res : file->resources) - { - if (res->GetRawDataIndex() == palOffset) - { - ZTexture* palette = (ZTexture*)res; - ZTexture tlutTemp(file); - - tlut = &tlutTemp; - tlut->ExtractFromBinary(palOffset, palette->width, palette->height, - TextureType::RGBA16bpp, true); - SetTlut(tlut); - } - } - } - } - } -} - -void ZTexture::PrepareBitmapRGBA16() -{ - textureData.InitEmptyRGBImage(width, height, true); - auto parentRawData = parent->GetRawData(); - for (size_t y = 0; y < height; y++) - { - for (size_t x = 0; x < width; x++) - { - int32_t pos = rawDataIndex + ((y * width) + x) * 2; - uint16_t data = parentRawData.at(pos + 1) | (parentRawData.at(pos) << 8); - uint8_t r = (data & 0xF800) >> 11; - uint8_t g = (data & 0x07C0) >> 6; - uint8_t b = (data & 0x003E) >> 1; - uint8_t alpha = data & 0x01; - - textureData.SetRGBPixel(y, x, r * 8, g * 8, b * 8, alpha * 255); - } - } -} - -void ZTexture::PrepareBitmapRGBA32() -{ - textureData.InitEmptyRGBImage(width, height, true); - auto parentRawData = parent->GetRawData(); - for (size_t y = 0; y < height; y++) - { - for (size_t x = 0; x < width; x++) - { - size_t pos = rawDataIndex + ((y * width) + x) * 4; - uint8_t r = parentRawData.at(pos + 0); - uint8_t g = parentRawData.at(pos + 1); - uint8_t b = parentRawData.at(pos + 2); - uint8_t alpha = parentRawData.at(pos + 3); - - textureData.SetRGBPixel(y, x, r, g, b, alpha); - } - } -} - -void ZTexture::PrepareBitmapGrayscale4() -{ - textureData.InitEmptyRGBImage(width, height, false); - auto parentRawData = parent->GetRawData(); - for (size_t y = 0; y < height; y++) - { - for (size_t x = 0; x < width; x += 2) - { - for (uint8_t i = 0; i < 2; i++) - { - size_t pos = rawDataIndex + ((y * width) + x) / 2; - uint8_t grayscale = 0; - - if (i == 0) - grayscale = parentRawData.at(pos) & 0xF0; - else - grayscale = (parentRawData.at(pos) & 0x0F) << 4; - - textureData.SetGrayscalePixel(y, x + i, grayscale); - } - } - } -} - -void ZTexture::PrepareBitmapGrayscale8() -{ - textureData.InitEmptyRGBImage(width, height, false); - auto parentRawData = parent->GetRawData(); - for (size_t y = 0; y < height; y++) - { - for (size_t x = 0; x < width; x++) - { - size_t pos = rawDataIndex + ((y * width) + x) * 1; - - textureData.SetGrayscalePixel(y, x, parentRawData.at(pos)); - } - } -} - -void ZTexture::PrepareBitmapGrayscaleAlpha4() -{ - textureData.InitEmptyRGBImage(width, height, true); - auto parentRawData = parent->GetRawData(); - for (size_t y = 0; y < height; y++) - { - for (size_t x = 0; x < width; x += 2) - { - for (uint16_t i = 0; i < 2; i++) - { - size_t pos = rawDataIndex + ((y * width) + x) / 2; - uint8_t data = 0; - - if (i == 0) - data = (parentRawData.at(pos) & 0xF0) >> 4; - else - data = parentRawData.at(pos) & 0x0F; - - uint8_t grayscale = ((data & 0x0E) >> 1) * 32; - uint8_t alpha = (data & 0x01) * 255; - - textureData.SetGrayscalePixel(y, x + i, grayscale, alpha); - } - } - } -} - -void ZTexture::PrepareBitmapGrayscaleAlpha8() -{ - textureData.InitEmptyRGBImage(width, height, true); - auto parentRawData = parent->GetRawData(); - for (size_t y = 0; y < height; y++) - { - for (size_t x = 0; x < width; x++) - { - size_t pos = rawDataIndex + ((y * width) + x) * 1; - uint8_t grayscale = parentRawData.at(pos) & 0xF0; - uint8_t alpha = (parentRawData.at(pos) & 0x0F) << 4; - - textureData.SetGrayscalePixel(y, x, grayscale, alpha); - } - } -} - -void ZTexture::PrepareBitmapGrayscaleAlpha16() -{ - textureData.InitEmptyRGBImage(width, height, true); - auto parentRawData = parent->GetRawData(); - for (size_t y = 0; y < height; y++) - { - for (size_t x = 0; x < width; x++) - { - size_t pos = rawDataIndex + ((y * width) + x) * 2; - uint8_t grayscale = parentRawData.at(pos + 0); - uint8_t alpha = parentRawData.at(pos + 1); - - textureData.SetGrayscalePixel(y, x, grayscale, alpha); - } - } -} - -void ZTexture::PrepareBitmapPalette4() -{ - textureData.InitEmptyPaletteImage(width, height); - auto parentRawData = parent->GetRawData(); - for (size_t y = 0; y < height; y++) - { - for (size_t x = 0; x < width; x += 2) - { - for (uint16_t i = 0; i < 2; i++) - { - size_t pos = rawDataIndex + ((y * width) + x) / 2; - uint8_t paletteIndex = 0; - - if (i == 0) - paletteIndex = (parentRawData.at(pos) & 0xF0) >> 4; - else - paletteIndex = (parentRawData.at(pos) & 0x0F); - - textureData.SetIndexedPixel(y, x + i, paletteIndex, paletteIndex * 16); - } - } - } -} - -void ZTexture::PrepareBitmapPalette8() -{ - textureData.InitEmptyPaletteImage(width, height); - auto parentRawData = parent->GetRawData(); - for (size_t y = 0; y < height; y++) - { - for (size_t x = 0; x < width; x++) - { - size_t pos = rawDataIndex + ((y * width) + x) * 1; - uint8_t grayscale = parentRawData.at(pos); - - textureData.SetIndexedPixel(y, x, grayscale, grayscale); - } - } -} - -void ZTexture::DeclareReferences([[maybe_unused]] const std::string& prefix) -{ - if (tlutOffset != static_cast(-1)) - { - tlut = parent->GetTextureResource(tlutOffset); - if (tlut == nullptr) - { - int32_t tlutDim = 16; - if (format == TextureType::Palette4bpp) - tlutDim = 4; - - tlut = new ZTexture(parent); - tlut->ExtractFromBinary(tlutOffset, tlutDim, tlutDim, TextureType::RGBA16bpp, true); - parent->AddTextureResource(tlutOffset, tlut); - tlut->DeclareVar(prefix, ""); - } - else - { - tlut->isPalette = true; - } - SetTlut(tlut); - } -} - -void ZTexture::PrepareRawDataFromFile(const fs::path& pngFilePath) -{ - textureData.ReadPng(pngFilePath); - - width = textureData.GetWidth(); - height = textureData.GetHeight(); - - textureDataRaw.clear(); - textureDataRaw.resize(GetRawDataSize()); - - switch (format) - { - case TextureType::RGBA16bpp: - PrepareRawDataRGBA16(); - break; - case TextureType::RGBA32bpp: - PrepareRawDataRGBA32(); - break; - case TextureType::Grayscale4bpp: - PrepareRawDataGrayscale4(); - break; - case TextureType::Grayscale8bpp: - PrepareRawDataGrayscale8(); - break; - case TextureType::GrayscaleAlpha4bpp: - PrepareRawDataGrayscaleAlpha4(); - break; - case TextureType::GrayscaleAlpha8bpp: - PrepareRawDataGrayscaleAlpha8(); - break; - case TextureType::GrayscaleAlpha16bpp: - PrepareRawDataGrayscaleAlpha16(); - break; - case TextureType::Palette4bpp: - PrepareRawDataPalette4(); - break; - case TextureType::Palette8bpp: - PrepareRawDataPalette8(); - break; - case TextureType::Error: - HANDLE_ERROR_PROCESS(WarningType::InvalidPNG, "Input PNG file has invalid format type", ""); - break; - } -} - -void ZTexture::PrepareRawDataRGBA16() -{ - for (uint16_t y = 0; y < height; y++) - { - for (uint16_t x = 0; x < width; x++) - { - size_t pos = ((y * width) + x) * 2; - RGBAPixel pixel = textureData.GetPixel(y, x); - - uint8_t r = pixel.r / 8; - uint8_t g = pixel.g / 8; - uint8_t b = pixel.b / 8; - - uint8_t alphaBit = pixel.a != 0; - - uint16_t data = (r << 11) + (g << 6) + (b << 1) + alphaBit; - - textureDataRaw[pos + 0] = (data & 0xFF00) >> 8; - textureDataRaw[pos + 1] = (data & 0x00FF); - } - } -} - -void ZTexture::PrepareRawDataRGBA32() -{ - for (uint16_t y = 0; y < height; y++) - { - for (uint16_t x = 0; x < width; x++) - { - size_t pos = ((y * width) + x) * 4; - RGBAPixel pixel = textureData.GetPixel(y, x); - - textureDataRaw[pos + 0] = pixel.r; - textureDataRaw[pos + 1] = pixel.g; - textureDataRaw[pos + 2] = pixel.b; - textureDataRaw[pos + 3] = pixel.a; - } - } -} - -void ZTexture::PrepareRawDataGrayscale4() -{ - for (uint16_t y = 0; y < height; y++) - { - for (uint16_t x = 0; x < width; x += 2) - { - size_t pos = ((y * width) + x) / 2; - uint8_t r1 = textureData.GetPixel(y, x).r; - uint8_t r2 = textureData.GetPixel(y, x + 1).r; - - textureDataRaw[pos] = (uint8_t)(((r1 / 16) << 4) + (r2 / 16)); - } - } -} - -void ZTexture::PrepareRawDataGrayscale8() -{ - for (uint16_t y = 0; y < height; y++) - { - for (uint16_t x = 0; x < width; x++) - { - size_t pos = (y * width) + x; - RGBAPixel pixel = textureData.GetPixel(y, x); - textureDataRaw[pos] = pixel.r; - } - } -} - -void ZTexture::PrepareRawDataGrayscaleAlpha4() -{ - for (uint16_t y = 0; y < height; y++) - { - for (uint16_t x = 0; x < width; x += 2) - { - size_t pos = ((y * width) + x) / 2; - uint8_t data = 0; - - for (uint16_t i = 0; i < 2; i++) - { - RGBAPixel pixel = textureData.GetPixel(y, x + i); - uint8_t cR = pixel.r; - uint8_t alphaBit = pixel.a != 0; - - if (i == 0) - data |= (((cR / 32) << 1) + alphaBit) << 4; - else - data |= ((cR / 32) << 1) + alphaBit; - } - - textureDataRaw[pos] = data; - } - } -} - -void ZTexture::PrepareRawDataGrayscaleAlpha8() -{ - for (uint16_t y = 0; y < height; y++) - { - for (uint16_t x = 0; x < width; x++) - { - size_t pos = ((y * width) + x) * 1; - RGBAPixel pixel = textureData.GetPixel(y, x); - - uint8_t r = pixel.r; - uint8_t a = pixel.a; - - textureDataRaw[pos] = ((r / 16) << 4) + (a / 16); - } - } -} - -void ZTexture::PrepareRawDataGrayscaleAlpha16() -{ - for (uint16_t y = 0; y < height; y++) - { - for (uint16_t x = 0; x < width; x++) - { - size_t pos = ((y * width) + x) * 2; - RGBAPixel pixel = textureData.GetPixel(y, x); - - uint8_t cR = pixel.r; - uint8_t aR = pixel.a; - - textureDataRaw[pos + 0] = cR; - textureDataRaw[pos + 1] = aR; - } - } -} - -void ZTexture::PrepareRawDataPalette4() -{ - for (uint16_t y = 0; y < height; y++) - { - for (uint16_t x = 0; x < width; x += 2) - { - size_t pos = ((y * width) + x) / 2; - - uint8_t cR1 = textureData.GetIndexedPixel(y, x); - uint8_t cR2 = textureData.GetIndexedPixel(y, x + 1); - - textureDataRaw[pos] = (cR1 << 4) | (cR2); - } - } -} - -void ZTexture::PrepareRawDataPalette8() -{ - for (uint16_t y = 0; y < height; y++) - { - for (uint16_t x = 0; x < width; x++) - { - size_t pos = ((y * width) + x); - uint8_t cR = textureData.GetIndexedPixel(y, x); - - textureDataRaw[pos] = cR; - } - } -} - -float ZTexture::GetPixelMultiplyer() const -{ - switch (format) - { - case TextureType::Grayscale4bpp: - case TextureType::GrayscaleAlpha4bpp: - case TextureType::Palette4bpp: - return 0.5f; - case TextureType::Grayscale8bpp: - case TextureType::GrayscaleAlpha8bpp: - case TextureType::Palette8bpp: - return 1; - case TextureType::GrayscaleAlpha16bpp: - case TextureType::RGBA16bpp: - return 2; - case TextureType::RGBA32bpp: - return 4; - default: - return -1; - } -} - -size_t ZTexture::GetRawDataSize() const -{ - return (width * height * GetPixelMultiplyer()); -} - -std::string ZTexture::GetIMFmtFromType() -{ - switch (format) - { - case TextureType::RGBA32bpp: - case TextureType::RGBA16bpp: - return "G_IM_FMT_RGBA"; - case TextureType::Grayscale4bpp: - case TextureType::Grayscale8bpp: - return "G_IM_FMT_I"; - case TextureType::Palette4bpp: - case TextureType::Palette8bpp: - return "G_IM_FMT_CI"; - case TextureType::GrayscaleAlpha4bpp: - case TextureType::GrayscaleAlpha8bpp: - case TextureType::GrayscaleAlpha16bpp: - return "G_IM_FMT_IA"; - default: - return "ERROR"; - } -} - -std::string ZTexture::GetIMSizFromType() -{ - switch (format) - { - case TextureType::Grayscale4bpp: - case TextureType::Palette4bpp: - case TextureType::GrayscaleAlpha4bpp: - return "G_IM_SIZ_4b"; - case TextureType::Palette8bpp: - case TextureType::Grayscale8bpp: - return "G_IM_SIZ_8b"; - case TextureType::GrayscaleAlpha16bpp: - case TextureType::RGBA16bpp: - return "G_IM_SIZ_16b"; - case TextureType::RGBA32bpp: - return "G_IM_SIZ_32b"; - default: - return "ERROR"; - } -} - -std::string ZTexture::GetDefaultName(const std::string& prefix) const -{ - const char* suffix = "Tex"; - if (isPalette) - suffix = "TLUT"; - return StringHelper::Sprintf("%s%s_%06X", prefix.c_str(), suffix, rawDataIndex); -} - -uint32_t ZTexture::GetWidth() const -{ - return width; -} - -uint32_t ZTexture::GetHeight() const -{ - return height; -} - -void ZTexture::SetDimensions(uint32_t nWidth, uint32_t nHeight) -{ - width = nWidth; - height = nHeight; - ParseRawData(); -} - -TextureType ZTexture::GetTextureType() const -{ - return format; -} - - -void ZTexture::Save(const fs::path& outFolder) -{ - // Optionally generate text file containing CRC information. This is going to be a one time - // process for generating the Texture Pool XML. - if (Globals::Instance->outputCrc) - { - DiskFile::WriteAllText((Globals::Instance->outputPath / (outName + ".txt")).string(), - StringHelper::Sprintf("%08lX", hash)); - } - - // Do not save png files if we're making an OTR file. They're not needed... - if (Globals::Instance->otrMode) - return; - - auto outPath = GetPoolOutPath(outFolder); - - if (!Directory::Exists(outPath.string())) - Directory::CreateDirectory(outPath.string()); - - fs::path outFileName; - - if (!dWordAligned) - outFileName = outPath / (outName + ".u32" + "." + GetExternalExtension() + ".png"); - else - outFileName = outPath / (outName + +"." + GetExternalExtension() + ".png"); - -#ifdef TEXTURE_DEBUG - printf("Saving PNG: %s\n", outFileName.c_str()); - printf("\t Var name: %s\n", name.c_str()); - if (tlut != nullptr) - printf("\t TLUT name: %s\n", tlut->name.c_str()); -#endif - - textureData.WritePng(outFileName); - -#ifdef TEXTURE_DEBUG - printf("\n"); -#endif -} - -Declaration* ZTexture::DeclareVar(const std::string& prefix, - [[maybe_unused]] const std::string& bodyStr) -{ - std::string auxName = name; - std::string auxOutName = outName; - std::string incStr; - - //if (Globals::Instance->otrMode) - //return nullptr; - - if (auxName == "") - auxName = GetDefaultName(prefix); - - if (auxOutName == "") - auxOutName = GetDefaultName(prefix); - - auto filepath = Globals::Instance->outputPath / fs::path(auxOutName).stem(); - - if (dWordAligned) - incStr = - StringHelper::Sprintf("%s.%s.inc.c", filepath.c_str(), GetExternalExtension().c_str()); - else - incStr = StringHelper::Sprintf("%s.u32.%s.inc.c", filepath.c_str(), - GetExternalExtension().c_str()); - - if (!Globals::Instance->cfg.texturePool.empty()) - { - CalcHash(); - - // TEXTURE POOL CHECK - const auto& poolEntry = Globals::Instance->cfg.texturePool.find(hash); - if (poolEntry != Globals::Instance->cfg.texturePool.end()) - { - if (dWordAligned) - incStr = StringHelper::Sprintf("%s.%s.inc.c", poolEntry->second.path.c_str(), - GetExternalExtension().c_str()); - else - incStr = StringHelper::Sprintf("%s.u32.%s.inc.c", poolEntry->second.path.c_str(), - GetExternalExtension().c_str()); - } - } - size_t texSizeDivisor = (dWordAligned) ? 8 : 4; - - Declaration* decl = parent->AddDeclarationIncludeArray(rawDataIndex, incStr, GetRawDataSize(), - GetSourceTypeName(), auxName, - GetRawDataSize() / texSizeDivisor); - decl->staticConf = staticConf; - return decl; -} - -std::string ZTexture::GetBodySourceCode() const -{ - std::string sourceOutput; - - if (!Globals::Instance->otrMode) - { - size_t texSizeInc = (dWordAligned) ? 8 : 4; - for (size_t i = 0; i < textureDataRaw.size(); i += texSizeInc) - { - if (i % 32 == 0) - sourceOutput += " "; - if (dWordAligned) - sourceOutput += StringHelper::Sprintf("0x%016llX, ", - BitConverter::ToUInt64BE(textureDataRaw, i)); - else - sourceOutput += StringHelper::Sprintf("0x%08llX, ", - BitConverter::ToUInt32BE(textureDataRaw, i)); - if (i % 32 == 24) - sourceOutput += - StringHelper::Sprintf(" // 0x%06X \n", rawDataIndex + ((i / 32) * 32)); - } - - // Ensure there's always a trailing line feed to prevent dumb warnings. - // Please don't remove this line, unless you somehow made a way to prevent - // that warning when building the OoT repo. - sourceOutput += "\n"; - } else if (Globals::Instance->buildRawTexture) { - sourceOutput += std::string(textureDataRaw.begin(), textureDataRaw.end()); - } - - return sourceOutput; -} - -bool ZTexture::IsExternalResource() const -{ - return true; -} - -ZResourceType ZTexture::GetResourceType() const -{ - return ZResourceType::Texture; -} - -std::string ZTexture::GetSourceTypeName() const -{ - return dWordAligned ? "u64" : "u32"; -} - -void ZTexture::CalcHash() -{ - //if (hash == 0) - { - const auto& parentRawData = parent->GetRawData(); - hash = CRC32B(parentRawData.data() + rawDataIndex, GetRawDataSize()); - } -} - -std::string ZTexture::GetExternalExtension() const -{ - switch (format) - { - case TextureType::RGBA32bpp: - return "rgba32"; - case TextureType::RGBA16bpp: - return "rgba16"; - case TextureType::Grayscale4bpp: - return "i4"; - case TextureType::Grayscale8bpp: - return "i8"; - case TextureType::GrayscaleAlpha4bpp: - return "ia4"; - case TextureType::GrayscaleAlpha8bpp: - return "ia8"; - case TextureType::GrayscaleAlpha16bpp: - return "ia16"; - case TextureType::Palette4bpp: - return "ci4"; - case TextureType::Palette8bpp: - return "ci8"; - default: - return "ERROR"; - } -} - -fs::path ZTexture::GetPoolOutPath(const fs::path& defaultValue) -{ - if (Globals::Instance->cfg.texturePool.find(hash) != Globals::Instance->cfg.texturePool.end()) - return Path::GetDirectoryName(Globals::Instance->cfg.texturePool[hash].path.string()); - - return defaultValue; -} - -TextureType ZTexture::GetTextureTypeFromString(const std::string& str) -{ - TextureType texType = TextureType::Error; - - if (str == "rgba32") - texType = TextureType::RGBA32bpp; - else if (str == "rgba16") - texType = TextureType::RGBA16bpp; - else if (str == "rgb5a1") - { - texType = TextureType::RGBA16bpp; - HANDLE_WARNING(WarningType::Deprecated, - "the texture format 'rgb5a1' is currently deprecated", - "It will be removed in a future version. Use the format 'rgba16' instead."); - } - else if (str == "i4") - texType = TextureType::Grayscale4bpp; - else if (str == "i8") - texType = TextureType::Grayscale8bpp; - else if (str == "ia4") - texType = TextureType::GrayscaleAlpha4bpp; - else if (str == "ia8") - texType = TextureType::GrayscaleAlpha8bpp; - else if (str == "ia16") - texType = TextureType::GrayscaleAlpha16bpp; - else if (str == "ci4") - texType = TextureType::Palette4bpp; - else if (str == "ci8") - texType = TextureType::Palette8bpp; - else - // TODO: handle this case in a more coherent way - HANDLE_WARNING(WarningType::InvalidAttributeValue, - "invalid value found for 'Type' attribute", "Defaulting to ''."); - return texType; -} - -bool ZTexture::IsColorIndexed() const -{ - switch (format) - { - case TextureType::Palette4bpp: - case TextureType::Palette8bpp: - return true; - - default: - return false; - } -} - -void ZTexture::SetTlut(ZTexture* nTlut) -{ - assert(IsColorIndexed()); - assert(nTlut->isPalette); - tlut = nTlut; - - textureData.SetPalette(tlut->textureData, splitTlut ? 128 : 0); -} - -bool ZTexture::HasTlut() const -{ - return tlut != nullptr; -} diff --git a/ZAPDTR/ZAPD/ZTexture.h b/ZAPDTR/ZAPD/ZTexture.h deleted file mode 100644 index 8cece3ff2..000000000 --- a/ZAPDTR/ZAPD/ZTexture.h +++ /dev/null @@ -1,93 +0,0 @@ -#pragma once - -#include "ImageBackend.h" -#include "ZResource.h" -#include "tinyxml2.h" - -enum class TextureType -{ - Error, - RGBA32bpp, - RGBA16bpp, - Palette4bpp, - Palette8bpp, - Grayscale4bpp, - Grayscale8bpp, - GrayscaleAlpha4bpp, - GrayscaleAlpha8bpp, - GrayscaleAlpha16bpp, -}; - -class ZTexture : public ZResource -{ -protected: - TextureType format = TextureType::Error; - uint32_t width, height; - - ImageBackend textureData; - std::vector textureDataRaw; // When reading from a PNG file. - uint32_t tlutOffset = static_cast(-1); - ZTexture* tlut = nullptr; - bool splitTlut; - - void PrepareBitmapRGBA16(); - void PrepareBitmapRGBA32(); - void PrepareBitmapGrayscale8(); - void PrepareBitmapGrayscaleAlpha8(); - void PrepareBitmapGrayscale4(); - void PrepareBitmapGrayscaleAlpha4(); - void PrepareBitmapGrayscaleAlpha16(); - void PrepareBitmapPalette4(); - void PrepareBitmapPalette8(); - - void PrepareRawDataFromFile(const fs::path& inFolder); - void PrepareRawDataRGBA16(); - void PrepareRawDataRGBA32(); - void PrepareRawDataGrayscale4(); - void PrepareRawDataGrayscale8(); - void PrepareRawDataGrayscaleAlpha4(); - void PrepareRawDataGrayscaleAlpha8(); - void PrepareRawDataGrayscaleAlpha16(); - void PrepareRawDataPalette4(); - void PrepareRawDataPalette8(); - -public: - ZTexture(ZFile* nParent); - - bool isPalette = false; - bool dWordAligned = true; - - void ExtractFromBinary(uint32_t nRawDataIndex, int32_t nWidth, int32_t nHeight, - TextureType nType, bool nIsPalette); - void FromPNG(const fs::path& pngFilePath, TextureType texType); - static TextureType GetTextureTypeFromString(const std::string& str); - - void ParseXML(tinyxml2::XMLElement* reader) override; - void ParseRawData() override; - void DeclareReferences(const std::string& prefix) override; - - Declaration* DeclareVar(const std::string& prefix, const std::string& bodyStr) override; - std::string GetBodySourceCode() const override; - void CalcHash() override; - void Save(const fs::path& outFolder) override; - - bool IsExternalResource() const override; - std::string GetSourceTypeName() const override; - ZResourceType GetResourceType() const override; - std::string GetExternalExtension() const override; - - size_t GetRawDataSize() const override; - std::string GetIMFmtFromType(); - std::string GetIMSizFromType(); - std::string GetDefaultName(const std::string& prefix) const override; - uint32_t GetWidth() const; - uint32_t GetHeight() const; - void SetDimensions(uint32_t nWidth, uint32_t nHeight); - float GetPixelMultiplyer() const; - TextureType GetTextureType() const; - fs::path GetPoolOutPath(const fs::path& defaultValue); - bool IsColorIndexed() const; - void SetTlut(ZTexture* nTlut); - bool HasTlut() const; - void ParseRawDataLate() override; -}; diff --git a/ZAPDTR/ZAPD/ZTextureAnimation.cpp b/ZAPDTR/ZAPD/ZTextureAnimation.cpp deleted file mode 100644 index 233a54dbb..000000000 --- a/ZAPDTR/ZAPD/ZTextureAnimation.cpp +++ /dev/null @@ -1,670 +0,0 @@ -/** - * File: ZTextureAnimation.cpp - * ZResources defined: ZTextureAnimation, ZTextureAnimationParams (XML declaration not supported for - * the latter) - * Purpose: extracting texture animating structures from asset files - * Note: data type is exclusive to Majora's Mask - * - * Structure of data: - * A texture animation consists of a main array of data of the form - * `SS 00 00 0T PPPPPPPP`, - * where `S` is the segment that the functionality is sent to (and read by DLists), `T` is the - * "type" (see below), and `P` is a pointer to the type's subsidiary information, which is - * invariably just above this main array. Details of this subsidiary data are given below. - * - * Segment - * === - * The segment starts at 1 and is incremented in each entry; the final one is negated, which is used - * as the indication to stop reading. The actual segment the game will use to draw is S + 7. - * - * Types - * === - * There are 7 values that `T` can take: - * `0`: A single texture scroll (Implemented by Gfx_TexScroll): subsidiary params are given as - * an array with one entry, a struct `XX YY WW HH` containing xStep, yStep, width, height - * (all u8). - * - * `1`: A dual texture scroll (Implementated by Gfx_TwoTexScroll): same as type `0`, but with - * two entries in the params array. - * - * `2`: Color changing: Changes the primColor (with a LOD factor) and envColor - * `KKKK LLLL PPPPPPPP QQQQQQQQ RRRRRRRR` - * - `K` (u16) is the total length of the animation (and in this case, the total number of - * colors) - * - `L` (u16) is seemingly always 0 for this type, and not used in the code - * - `P` segmented pointer to array of augmented primColors - * - `Q` segmented pointer to array of envColors, and can be NULL - * - `R` segmented pointer to array of frameData (u8), which is also seemingly always NULL - * for this type. - * - * envColors take the form `RR GG BB AA` as usual, while primColors have an extra LODFrac - * element: RR GG BB AA LL - * - * `3`: Color changing (LERP): similar to type `2`, but uses linear interpolation. The structure - * is similar to `2`, but - * - `K` is now just the animation length, while - * - `L` is the total number of colors, and - * - the frameData is used to determine which colors to interpolate. - * - * `4`: Color changing (Lagrange interpolation): For extraction purposes identical to type 3. - * Uses a nonlinear interpolation formula to change the colours more smoothly. - * - * `5`: Texture cycle: functions like a gif. Subsidiary params: - * `FFFF 0000 PPPPPPPP QQQQQQQQ` - * where - * - `F` (u16) time between changes in frames - * - `P` pointer to array of segmented pointers to textures to cycle through - * - `Q` array of indices, indicating which texture to use next when a change frame is - * reached. The maximum indicates the number of textures in the texture array. - * - * `6`: This is used to indicate an empty/unimplemented params set. It is ignored by the game's - * function provided that the segment is 0. A generic empty one takes the form - * `00 00 00 06 00000000`, - * and has no extra data. - * - * Implementation - * === - * - ZTextureAnimation requires a declaration in the XML to extract anything. It handles the main - * array. It uses a POD struct for each entry, and declares references to the params structs. - * - * - ZTextureAnimationParams is not (currently) declarable in an XML. It is a parent class for the - * three classes that handle the various cases: - * - TextureScrollingParams for types `0` and `1` - * - TextureColorChangingParams for types `2`,`3`,`4` - * - TextureCyclingParams for type `5` - * Each of these will declare all its subsidiary arrays, using POD structs. - */ -#include "ZTextureAnimation.h" - -#include -#include -#include - -#include "Globals.h" -#include "Utils/BitConverter.h" -#include "WarningHandler.h" -#include "ZFile.h" -#include "ZResource.h" -#include "tinyxml2.h" - -REGISTER_ZFILENODE(TextureAnimation, ZTextureAnimation); - -/* Constructors */ -ZTextureAnimationParams::ZTextureAnimationParams(ZFile* parent) : ZResource::ZResource(parent) -{ -} -TextureScrollingParams::TextureScrollingParams(ZFile* parent) - : ZTextureAnimationParams::ZTextureAnimationParams(parent) -{ -} -TextureColorChangingParams::TextureColorChangingParams(ZFile* parent) - : ZTextureAnimationParams::ZTextureAnimationParams(parent) -{ -} -TextureCyclingParams::TextureCyclingParams(ZFile* parent) - : ZTextureAnimationParams::ZTextureAnimationParams(parent) -{ -} - -/* TextureAnimationParams */ -/* This class only implements the functions common to all or most its inheritors */ - -void ZTextureAnimationParams::ExtractFromBinary(uint32_t nRawDataIndex) -{ - rawDataIndex = nRawDataIndex; - - ParseRawData(); -} - -// Implemented by TextureScrollingParams only -void ZTextureAnimationParams::ExtractFromBinary([[maybe_unused]] uint32_t nRawDataIndex, - [[maybe_unused]] int count) -{ -} - -std::string -ZTextureAnimationParams::GetDefaultName([[maybe_unused]] const std::string& prefix) const -{ - return "ShouldNotBeVIsible"; -} - -ZResourceType ZTextureAnimationParams::GetResourceType() const -{ - return ZResourceType::TextureAnimationParams; -} - -/* TextureScrollingParams */ - -void TextureScrollingParams::ParseRawData() -{ - const auto& rawData = parent->GetRawData(); - - for (int i = 0; i < count; i++) - { - rows[i].xStep = BitConverter::ToUInt8BE(rawData, rawDataIndex + 4 * i); - rows[i].yStep = BitConverter::ToUInt8BE(rawData, rawDataIndex + 4 * i + 1); - rows[i].width = BitConverter::ToUInt8BE(rawData, rawDataIndex + 4 * i + 2); - rows[i].height = BitConverter::ToUInt8BE(rawData, rawDataIndex + 4 * i + 3); - } -} - -void TextureScrollingParams::ExtractFromBinary(uint32_t nRawDataIndex, int nCount) -{ - rawDataIndex = nRawDataIndex; - count = nCount; - - ParseRawData(); -} - -std::string TextureScrollingParams::GetSourceTypeName() const -{ - return "AnimatedMatTexScrollParams"; // TODO: Better name -} - -std::string TextureScrollingParams::GetDefaultName(const std::string& prefix) const -{ - return StringHelper::Sprintf("%sTexScrollParams_%06X", prefix.c_str(), rawDataIndex); -} - -size_t TextureScrollingParams::GetRawDataSize() const -{ - return 4 * count; -} - -/** - * Overrides the parent version to declare an array of the params rather than just one entry. - */ -Declaration* TextureScrollingParams::DeclareVar(const std::string& prefix, - const std::string& bodyStr) -{ - std::string auxName = name; - - if (name == "") - auxName = GetDefaultName(prefix); - - return parent->AddDeclarationArray(rawDataIndex, GetDeclarationAlignment(), GetRawDataSize(), - GetSourceTypeName(), auxName, count, bodyStr); -} - -std::string TextureScrollingParams::GetBodySourceCode() const -{ - std::string bodyStr; - - for (int i = 0; i < count; i++) - { - bodyStr += StringHelper::Sprintf("\t{ %d, %d, 0x%02X, 0x%02X },\n", rows[i].xStep, - rows[i].yStep, rows[i].width, rows[i].height); - } - - bodyStr.pop_back(); - - return bodyStr; -} - -/* TextureColorChangingParams */ - -/** - * Also parses the color and frameData arrays - */ -void TextureColorChangingParams::ParseRawData() -{ - const auto& rawData = parent->GetRawData(); - - animLength = BitConverter::ToUInt16BE(rawData, rawDataIndex); - colorListCount = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - - // Handle type 2 separately - uint16_t listLength = - ((type == TextureAnimationParamsType::ColorChange) ? animLength : colorListCount); - - if (listLength == 0) - HANDLE_ERROR_RESOURCE(WarningType::Always, parent, this, rawDataIndex, - "color list length cannot be 0", ""); - - primColorListAddress = BitConverter::ToUInt32BE(rawData, rawDataIndex + 4); - envColorListAddress = BitConverter::ToUInt32BE(rawData, rawDataIndex + 8); - frameDataListAddress = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0xC); - - uint32_t primColorListOffset = Seg2Filespace(primColorListAddress, parent->baseAddress); - uint32_t envColorListOffset = Seg2Filespace(envColorListAddress, parent->baseAddress); - uint32_t frameDataListOffset = Seg2Filespace(frameDataListAddress, parent->baseAddress); - - uint32_t currentPtr; - - F3DPrimColor currentPrimColor; - - for (currentPtr = primColorListOffset; currentPtr < primColorListOffset + 5 * listLength; - currentPtr += 5) - { - currentPrimColor = {BitConverter::ToUInt8BE(rawData, currentPtr), - BitConverter::ToUInt8BE(rawData, currentPtr + 1), - BitConverter::ToUInt8BE(rawData, currentPtr + 2), - BitConverter::ToUInt8BE(rawData, currentPtr + 3), - BitConverter::ToUInt8BE(rawData, currentPtr + 4)}; - primColorList.push_back(currentPrimColor); - } - - F3DEnvColor currentEnvColor; - - for (currentPtr = envColorListOffset; currentPtr < envColorListOffset + 4 * listLength; - currentPtr += 4) - { - currentEnvColor = {BitConverter::ToUInt8BE(rawData, currentPtr), - BitConverter::ToUInt8BE(rawData, currentPtr + 1), - BitConverter::ToUInt8BE(rawData, currentPtr + 2), - BitConverter::ToUInt8BE(rawData, currentPtr + 3)}; - envColorList.push_back(currentEnvColor); - } - - uint16_t currentFrameData; - - for (currentPtr = frameDataListOffset; currentPtr < frameDataListOffset + 2 * listLength; - currentPtr += 2) - { - currentFrameData = BitConverter::ToUInt16BE(rawData, currentPtr); - frameDataList.push_back(currentFrameData); - } -} - -std::string TextureColorChangingParams::GetSourceTypeName() const -{ - return "AnimatedMatColorParams"; // TODO: Better name -} - -std::string TextureColorChangingParams::GetDefaultName(const std::string& prefix) const -{ - return StringHelper::Sprintf("%sColorParams_%06X", prefix.c_str(), rawDataIndex); -} - -size_t TextureColorChangingParams::GetRawDataSize() const -{ - return 0x10; -} - -void TextureColorChangingParams::DeclareReferences([[maybe_unused]] const std::string& prefix) -{ - if (primColorListAddress != 0) // NULL - { - std::string primColorBodyStr; - - for (const auto& color : primColorList) - { - primColorBodyStr += StringHelper::Sprintf("\t{ %d, %d, %d, %d, %d },\n", color.r, - color.g, color.b, color.a, color.lodFrac); - } - - primColorBodyStr.pop_back(); - - parent->AddDeclarationArray( - Seg2Filespace(primColorListAddress, parent->baseAddress), DeclarationAlignment::Align4, - primColorList.size() * 5, "F3DPrimColor", - StringHelper::Sprintf("%sTexColorChangingPrimColors_%06X", parent->GetName().c_str(), - Seg2Filespace(primColorListAddress, parent->baseAddress)), - primColorList.size(), primColorBodyStr); - } - - if (envColorListAddress != 0) // NULL - { - std::string envColorBodyStr; - - for (const auto& color : envColorList) - { - envColorBodyStr += StringHelper::Sprintf("\t{ %d, %d, %d, %d },\n", color.r, color.g, - color.b, color.a); - } - - envColorBodyStr.pop_back(); - - parent->AddDeclarationArray( - Seg2Filespace(envColorListAddress, parent->baseAddress), DeclarationAlignment::Align4, - envColorList.size() * 4, "F3DEnvColor", - StringHelper::Sprintf("%sTexColorChangingEnvColors_%06X", parent->GetName().c_str(), - Seg2Filespace(envColorListAddress, parent->baseAddress)), - envColorList.size(), envColorBodyStr); - } - - if (frameDataListAddress != 0) // NULL - { - std::string frameDataBodyStr = "\t"; - - for (const auto& frame : frameDataList) - { - frameDataBodyStr += StringHelper::Sprintf("%d, ", frame); - } - - frameDataBodyStr.pop_back(); - - parent->AddDeclarationArray( - Seg2Filespace(frameDataListAddress, parent->baseAddress), DeclarationAlignment::Align4, - frameDataList.size() * 2, "u16", - StringHelper::Sprintf("%sTexColorChangingFrameData_%06X", parent->GetName().c_str(), - Seg2Filespace(frameDataListAddress, parent->baseAddress)), - frameDataList.size(), frameDataBodyStr); - } -} - -std::string TextureColorChangingParams::GetBodySourceCode() const -{ - std::string primColorListName; - std::string envColorListName; - std::string frameDataListName; - - Globals::Instance->GetSegmentedPtrName(primColorListAddress, parent, "", primColorListName, - parent->workerID); - Globals::Instance->GetSegmentedPtrName(envColorListAddress, parent, "", envColorListName, - parent->workerID); - Globals::Instance->GetSegmentedPtrName(frameDataListAddress, parent, "", frameDataListName, - parent->workerID); - - std::string bodyStr = StringHelper::Sprintf( - "\n %d, %d, %s, %s, %s,\n", animLength, colorListCount, primColorListName.c_str(), - envColorListName.c_str(), frameDataListName.c_str()); - - return bodyStr; -} - -/* TextureCyclingParams */ - -void TextureCyclingParams::ParseRawData() -{ - const auto& rawData = parent->GetRawData(); - - cycleLength = BitConverter::ToUInt16BE(rawData, rawDataIndex); - if (cycleLength == 0) - HANDLE_ERROR_RESOURCE(WarningType::Always, parent, this, rawDataIndex, - "cycle length cannot be 0", ""); - - textureListAddress = BitConverter::ToUInt32BE(rawData, rawDataIndex + 4); - textureIndexListAddress = BitConverter::ToUInt32BE(rawData, rawDataIndex + 8); - - uint32_t textureListOffset = Seg2Filespace(textureListAddress, parent->baseAddress); - uint32_t textureIndexListOffset = Seg2Filespace(textureIndexListAddress, parent->baseAddress); - - uint32_t currentPtr; - - uint8_t currentIndex; - uint8_t maxIndex = 0; // To find the length of the texture list - - for (currentPtr = textureIndexListOffset; currentPtr < textureIndexListOffset + cycleLength; - currentPtr++) - { - currentIndex = BitConverter::ToUInt8BE(rawData, currentPtr); - textureIndexList.push_back(currentIndex); - if (currentIndex > maxIndex) - maxIndex = currentIndex; - } - - for (currentPtr = textureListOffset; currentPtr <= textureListOffset + 4 * maxIndex; - currentPtr += 4) - { - textureList.push_back(BitConverter::ToUInt32BE(rawData, currentPtr)); - } -} - -std::string TextureCyclingParams::GetSourceTypeName() const -{ - return "AnimatedMatTexCycleParams"; // TODO: Better name -} - -std::string TextureCyclingParams::GetDefaultName(const std::string& prefix) const -{ - return StringHelper::Sprintf("%sTexCycleParams_%06X", prefix.c_str(), rawDataIndex); -} - -size_t TextureCyclingParams::GetRawDataSize() const -{ - return 0xC; -} - -void TextureCyclingParams::DeclareReferences([[maybe_unused]] const std::string& prefix) -{ - if (textureListAddress != 0) // NULL - { - std::string texturesBodyStr; - std::string texName; - std::string comment; - - for (const auto& tex : textureList) - { - bool texFound = - Globals::Instance->GetSegmentedPtrName(tex, parent, "", texName, parent->workerID); - - // texName is a raw segmented pointer. This occurs if the texture is not declared - // separately since we cannot read the format. In theory we could scan DLists for the - // format on the appropriate segments. - if (!texFound) - { - comment = " // Raw pointer, declare texture in XML to use proper symbol"; - - auto msgHeader = StringHelper::Sprintf( - "TexCycle texture array declared here points to unknown texture at address %s", - texName.c_str()); - HANDLE_WARNING_RESOURCE( - WarningType::HardcodedPointer, parent, this, rawDataIndex, msgHeader, - "Please declare the texture in the XML to use the proper symbol."); - } - texturesBodyStr += StringHelper::Sprintf("\t%s,%s\n", texName.c_str(), comment.c_str()); - } - - texturesBodyStr.pop_back(); - - parent->AddDeclarationArray( - Seg2Filespace(textureListAddress, parent->baseAddress), DeclarationAlignment::Align4, - textureList.size() * 4, "TexturePtr", - StringHelper::Sprintf("%sTexCycleTexPtrs_%06X", parent->GetName().c_str(), - Seg2Filespace(textureListAddress, parent->baseAddress)), - textureList.size(), texturesBodyStr); - } - - if (textureIndexListAddress != 0) // NULL - { - std::string indicesBodyStr = "\t"; - - for (uint8_t index : textureIndexList) - { - indicesBodyStr += StringHelper::Sprintf("%d, ", index); - } - - indicesBodyStr.pop_back(); - - parent->AddDeclarationArray( - Seg2Filespace(textureIndexListAddress, parent->baseAddress), - DeclarationAlignment::Align4, textureIndexList.size(), "u8", - StringHelper::Sprintf("%sTexCycleTexIndices_%06X", parent->GetName().c_str(), - Seg2Filespace(textureIndexListAddress, parent->baseAddress)), - textureIndexList.size(), indicesBodyStr); - } -} - -std::string TextureCyclingParams::GetBodySourceCode() const -{ - std::string textureListName; - std::string textureIndexListName; - - Globals::Instance->GetSegmentedPtrName(textureListAddress, parent, "", textureListName, - parent->workerID); - Globals::Instance->GetSegmentedPtrName(textureIndexListAddress, parent, "", - textureIndexListName, parent->workerID); - - std::string bodyStr = StringHelper::Sprintf( - "\n %d, %s, %s,\n", cycleLength, textureListName.c_str(), textureIndexListName.c_str()); - - return bodyStr; -} - -/* ZTextureAnimation */ - -ZTextureAnimation::ZTextureAnimation(ZFile* nParent) : ZResource(nParent) -{ -} - -/** - * Builds the array of params - */ -void ZTextureAnimation::ParseRawData() -{ - ZResource::ParseRawData(); - - TextureAnimationEntry currentEntry; - auto rawData = parent->GetRawData(); - int16_t type; - - for (uint32_t currentPtr = rawDataIndex;; currentPtr += 8) - { - type = BitConverter::ToInt16BE(rawData, currentPtr + 2); - - currentEntry.segment = BitConverter::ToInt8BE(rawData, currentPtr); - currentEntry.type = (TextureAnimationParamsType)type; - currentEntry.paramsPtr = BitConverter::ToUInt32BE(rawData, currentPtr + 4); - entries.push_back(currentEntry); - - if ((type < 0) || (type > 6)) - { - HANDLE_ERROR_RESOURCE( - WarningType::Always, parent, this, rawDataIndex, - StringHelper::Sprintf( - "unknown TextureAnimationParams type 0x%02X in TextureAnimation", type), - StringHelper::Sprintf( - "Entry reads { 0x%02X, 0x%02X, 0x%08X } , but type should be " - "between 0x00 and 0x06 inclusive.", - currentEntry.segment, type, currentEntry.paramsPtr)); - } - - if (currentEntry.segment <= 0) - break; - } -} - -#include -/** - * For each params entry, - */ -void ZTextureAnimation::DeclareReferences(const std::string& prefix) -{ - std::string varPrefix = name; - if (varPrefix == "") - varPrefix = prefix; - - ZResource::DeclareReferences(varPrefix); - - for (const auto& entry : entries) - { - if (entry.paramsPtr != 0 && GETSEGNUM(entry.paramsPtr) == parent->segment) - { - uint32_t paramsOffset = Seg2Filespace(entry.paramsPtr, parent->baseAddress); - if (!parent->HasDeclaration(paramsOffset)) - { - ZTextureAnimationParams* params; - int count; - switch (entry.type) - { - case TextureAnimationParamsType::SingleScroll: - if (true) - { - count = 1; - // The else now allows SingleScroll to fall through to params = ... without - // touching the code in the else block - } - else - { - // The contents of this block can only be run by jumping into it with the - // case label - [[fallthrough]]; - case TextureAnimationParamsType::DualScroll: - count = 2; - } - params = new TextureScrollingParams(parent); - params->ExtractFromBinary(paramsOffset, count); - break; - - case TextureAnimationParamsType::ColorChange: - case TextureAnimationParamsType::ColorChangeLERP: - case TextureAnimationParamsType::ColorChangeLagrange: - params = new TextureColorChangingParams(parent); - params->type = entry.type; - params->ExtractFromBinary(paramsOffset); - break; - - case TextureAnimationParamsType::TextureCycle: - params = new TextureCyclingParams(parent); - params->ExtractFromBinary(paramsOffset); - break; - - case TextureAnimationParamsType::Empty: - HANDLE_WARNING_RESOURCE( - WarningType::InvalidExtractedData, parent, this, rawDataIndex, - "TextureAnimationParams entry has empty type (6), but params pointer is " - "not NULL", - StringHelper::Sprintf("Params read { 0x%02X, 0x%02X, 0x%08X } .", - entry.segment, (int)entry.type, entry.paramsPtr)); - return; - default: - // Because GCC is worried this could happen - assert(entry.type < TextureAnimationParamsType::SingleScroll || - entry.type > TextureAnimationParamsType::Empty); - return; - } - - params->SetName(params->GetDefaultName(varPrefix)); - params->DeclareVar(varPrefix, ""); - parent->AddResource(params); - } - } - } -} - -std::string ZTextureAnimation::GetSourceTypeName() const -{ - return "AnimatedMaterial"; // TODO: Better name -} - -ZResourceType ZTextureAnimation::GetResourceType() const -{ - return ZResourceType::TextureAnimation; -} - -/** - * The size of the main array - */ -size_t ZTextureAnimation::GetRawDataSize() const -{ - return entries.size() * 8; -} - -std::string ZTextureAnimation::GetDefaultName(const std::string& prefix) const -{ - return StringHelper::Sprintf("%sTexAnim_%06X", prefix.c_str(), rawDataIndex); -} - -Declaration* ZTextureAnimation::DeclareVar(const std::string& prefix, const std::string& bodyStr) -{ - std::string auxName = name; - - if (name == "") - auxName = GetDefaultName(prefix); - - Declaration* decl = - parent->AddDeclarationArray(rawDataIndex, GetDeclarationAlignment(), GetRawDataSize(), - GetSourceTypeName(), auxName, entries.size(), bodyStr); - decl->staticConf = staticConf; - return decl; -} - -std::string ZTextureAnimation::GetBodySourceCode() const -{ - std::string bodyStr; - - for (const auto& entry : entries) - { - std::string paramName; - Globals::Instance->GetSegmentedPtrName(entry.paramsPtr, parent, "", paramName, - parent->workerID); - - bodyStr += StringHelper::Sprintf("\t{ %d, %d, %s },\n", entry.segment, entry.type, - paramName.c_str()); - } - - bodyStr.pop_back(); - - return bodyStr; -} diff --git a/ZAPDTR/ZAPD/ZTextureAnimation.h b/ZAPDTR/ZAPD/ZTextureAnimation.h deleted file mode 100644 index 6b03eb7cf..000000000 --- a/ZAPDTR/ZAPD/ZTextureAnimation.h +++ /dev/null @@ -1,151 +0,0 @@ -#pragma once - -#include -#include -#include -#include - -#include "ZResource.h" - -enum class TextureAnimationParamsType -{ - /* 0 */ SingleScroll, - /* 1 */ DualScroll, - /* 2 */ ColorChange, - /* 3 */ ColorChangeLERP, - /* 4 */ ColorChangeLagrange, - /* 5 */ TextureCycle, - /* 6 */ Empty // An empty TextureAnimation has the form 00 00 00 06 00000000 -}; - -class ZTextureAnimationParams : public ZResource -{ -public: - ZTextureAnimationParams(ZFile* parent); - - void ExtractFromBinary(uint32_t nRawDataIndex); - virtual void ExtractFromBinary(uint32_t nRawDataIndex, int count); - - virtual std::string GetDefaultName(const std::string& prefix) const; - ZResourceType GetResourceType() const; - - TextureAnimationParamsType type; -}; - -struct TextureScrollingParamsEntry -{ - int8_t xStep; - int8_t yStep; - uint8_t width; - uint8_t height; -}; - -class TextureScrollingParams : public ZTextureAnimationParams -{ -public: - TextureScrollingParams(ZFile* parent); - - void ParseRawData() override; - void ExtractFromBinary(uint32_t nRawDataIndex, int count) override; - - std::string GetSourceTypeName() const override; - std::string GetDefaultName(const std::string& prefix) const override; - size_t GetRawDataSize() const override; - - Declaration* DeclareVar(const std::string& prefix, const std::string& bodyStr) override; - std::string GetBodySourceCode() const override; - - int count; // 1 for Single, 2 for Dual - TextureScrollingParamsEntry rows[2]; // Too small to make a vector worth it -}; - -struct F3DPrimColor -{ - uint8_t r; - uint8_t g; - uint8_t b; - uint8_t a; - uint8_t lodFrac; -}; - -struct F3DEnvColor -{ - uint8_t r; - uint8_t g; - uint8_t b; - uint8_t a; -}; - -class TextureColorChangingParams : public ZTextureAnimationParams -{ -public: - TextureColorChangingParams(ZFile* parent); - - void ParseRawData() override; - - std::string GetSourceTypeName() const override; - std::string GetDefaultName(const std::string& prefix) const override; - size_t GetRawDataSize() const override; - - void DeclareReferences(const std::string& prefix) override; - - std::string GetBodySourceCode() const override; - - uint16_t animLength; // size of list for type 2 - uint16_t colorListCount; - segptr_t primColorListAddress; - segptr_t envColorListAddress; - segptr_t frameDataListAddress; - std::vector primColorList; - std::vector envColorList; - std::vector frameDataList; -}; - -class TextureCyclingParams : public ZTextureAnimationParams -{ -public: - TextureCyclingParams(ZFile* parent); - - void ParseRawData() override; - - std::string GetSourceTypeName() const override; - std::string GetDefaultName(const std::string& prefix) const override; - size_t GetRawDataSize() const override; - - void DeclareReferences(const std::string& prefix) override; - - std::string GetBodySourceCode() const override; - - uint16_t cycleLength; - segptr_t textureListAddress; - segptr_t textureIndexListAddress; - std::vector textureList; - std::vector textureIndexList; -}; - -struct TextureAnimationEntry -{ - int8_t segment; - TextureAnimationParamsType type; - segptr_t paramsPtr; -}; - -class ZTextureAnimation : public ZResource -{ -public: - ZTextureAnimation(ZFile* nParent); - - void ParseRawData() override; - void DeclareReferences(const std::string& prefix) override; - - std::string GetSourceTypeName() const override; - ZResourceType GetResourceType() const override; - size_t GetRawDataSize() const override; - std::string GetDefaultName(const std::string& prefix) const override; - - Declaration* DeclareVar(const std::string& prefix, const std::string& bodyStr) override; - std::string GetBodySourceCode() const override; - -private: - std::vector entries; -}; diff --git a/ZAPDTR/ZAPD/ZVector.cpp b/ZAPDTR/ZAPD/ZVector.cpp deleted file mode 100644 index 092b876d2..000000000 --- a/ZAPDTR/ZAPD/ZVector.cpp +++ /dev/null @@ -1,126 +0,0 @@ -#include "ZVector.h" - -#include - -#include "Globals.h" -#include "Utils/BitConverter.h" -#include -#include "Utils/StringHelper.h" -#include "WarningHandler.h" -#include "ZFile.h" - -REGISTER_ZFILENODE(Vector, ZVector); - -ZVector::ZVector(ZFile* nParent) : ZResource(nParent) -{ - scalarType = ZScalarType::ZSCALAR_NONE; - dimensions = 0; - - RegisterRequiredAttribute("Type"); - RegisterRequiredAttribute("Dimensions"); -} - -void ZVector::ExtractFromBinary(uint32_t nRawDataIndex, ZScalarType nScalarType, - uint32_t nDimensions) -{ - rawDataIndex = nRawDataIndex; - scalarType = nScalarType; - dimensions = nDimensions; - - // Don't parse raw data of external files - if (parent->GetMode() == ZFileMode::ExternalFile) - return; - - ParseRawData(); -} - -void ZVector::ParseXML(tinyxml2::XMLElement* reader) -{ - ZResource::ParseXML(reader); - - this->scalarType = ZScalar::MapOutputTypeToScalarType(registeredAttributes.at("Type").value); - - this->dimensions = StringHelper::StrToL(registeredAttributes.at("Dimensions").value, 16); -} - -void ZVector::ParseRawData() -{ - int32_t currentRawDataIndex = rawDataIndex; - // TODO: this shouldn't be necessary. - scalars.clear(); - scalars.reserve(dimensions); - for (uint32_t i = 0; i < dimensions; i++) - { - ZScalar scalar(parent); - scalar.ExtractFromBinary(currentRawDataIndex, scalarType); - currentRawDataIndex += scalar.GetRawDataSize(); - - scalars.push_back(scalar); - } - - // Ensure the scalars vector has the same number of elements as the vector dimension. - assert(scalars.size() == dimensions); -} - -size_t ZVector::GetRawDataSize() const -{ - size_t size = 0; - - for (size_t i = 0; i < this->scalars.size(); i++) - size += this->scalars[i].GetRawDataSize(); - - return size; -} - -bool ZVector::DoesSupportArray() const -{ - return true; -} - -std::string ZVector::GetSourceTypeName() const -{ - if (dimensions == 3 && scalarType == ZScalarType::ZSCALAR_F32) - return "Vec3f"; - else if (dimensions == 3 && scalarType == ZScalarType::ZSCALAR_S16) - return "Vec3s"; - else if (dimensions == 3 && scalarType == ZScalarType::ZSCALAR_S32) - return "Vec3i"; - else - { - std::string msgHeader = StringHelper::Sprintf( - "encountered unsupported vector type: %d dimensions, %s type", dimensions, - ZScalar::MapScalarTypeToOutputType(scalarType).c_str()); - - HANDLE_ERROR_RESOURCE(WarningType::NotImplemented, parent, this, rawDataIndex, msgHeader, - ""); - } -} - -std::string ZVector::GetBodySourceCode() const -{ - std::string body = ""; - - for (size_t i = 0; i < scalars.size(); i++) - { - body += StringHelper::Sprintf("%6s", scalars[i].GetBodySourceCode().c_str()); - - if (i + 1 < scalars.size()) - body += ", "; - } - - return body; -} - -ZResourceType ZVector::GetResourceType() const -{ - return ZResourceType::Vector; -} - -DeclarationAlignment ZVector::GetDeclarationAlignment() const -{ - if (scalars.size() == 0) - { - return DeclarationAlignment::Align4; - } - return scalars.at(0).GetDeclarationAlignment(); -} diff --git a/ZAPDTR/ZAPD/ZVector.h b/ZAPDTR/ZAPD/ZVector.h deleted file mode 100644 index a50d3e808..000000000 --- a/ZAPDTR/ZAPD/ZVector.h +++ /dev/null @@ -1,31 +0,0 @@ -#pragma once - -#include -#include -#include -#include "ZResource.h" -#include "ZScalar.h" -#include "tinyxml2.h" - -class ZVector : public ZResource -{ -public: - std::vector scalars; - ZScalarType scalarType; - uint32_t dimensions; - - ZVector(ZFile* nParent); - - void ExtractFromBinary(uint32_t nRawDataIndex, ZScalarType nScalarType, uint32_t nDimensions); - - void ParseXML(tinyxml2::XMLElement* reader) override; - void ParseRawData() override; - - std::string GetBodySourceCode() const override; - - bool DoesSupportArray() const override; - std::string GetSourceTypeName() const override; - ZResourceType GetResourceType() const override; - size_t GetRawDataSize() const override; - DeclarationAlignment GetDeclarationAlignment() const override; -}; diff --git a/ZAPDTR/ZAPD/ZVtx.cpp b/ZAPDTR/ZAPD/ZVtx.cpp deleted file mode 100644 index e4b3d9796..000000000 --- a/ZAPDTR/ZAPD/ZVtx.cpp +++ /dev/null @@ -1,86 +0,0 @@ -#include "ZVtx.h" - -#include "Utils/BitConverter.h" -#include "Utils/StringHelper.h" -#include "ZFile.h" - -REGISTER_ZFILENODE(Vtx, ZVtx); - -ZVtx::ZVtx(ZFile* nParent) : ZResource(nParent) -{ - x = 0; - y = 0; - z = 0; - flag = 0; - s = 0; - t = 0; - r = 0; - g = 0; - b = 0; - a = 0; -} - -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); - flag = BitConverter::ToInt16BE(rawData, rawDataIndex + 6); - s = BitConverter::ToInt16BE(rawData, rawDataIndex + 8); - t = BitConverter::ToInt16BE(rawData, rawDataIndex + 10); - r = rawData[rawDataIndex + 12]; - g = rawData[rawDataIndex + 13]; - b = rawData[rawDataIndex + 14]; - a = rawData[rawDataIndex + 15]; -} - -Declaration* ZVtx::DeclareVar(const std::string& prefix, const std::string& bodyStr) -{ - Declaration* decl = ZResource::DeclareVar(prefix, bodyStr); - decl->isExternal = true; - return decl; -} - -std::string ZVtx::GetBodySourceCode() const -{ - return StringHelper::Sprintf("VTX(%i, %i, %i, %i, %i, %i, %i, %i, %i)", x, y, z, s, t, r, g, b, - a); -} - -size_t ZVtx::GetRawDataSize() const -{ - return 16; -} - -bool ZVtx::DoesSupportArray() const -{ - return true; -} - -ZResourceType ZVtx::GetResourceType() const -{ - return ZResourceType::Vertex; -} - -bool ZVtx::IsExternalResource() const -{ - return true; -} - -std::string ZVtx::GetSourceTypeName() const -{ - return "Vtx"; -} - -std::string ZVtx::GetExternalExtension() const -{ - return "vtx"; -} - -DeclarationAlignment ZVtx::GetDeclarationAlignment() const -{ - return DeclarationAlignment::Align8; -} diff --git a/ZAPDTR/ZAPD/ZVtx.h b/ZAPDTR/ZAPD/ZVtx.h deleted file mode 100644 index 511048791..000000000 --- a/ZAPDTR/ZAPD/ZVtx.h +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once - -#include -#include -#include -#include "ZResource.h" -#include "ZScalar.h" -#include "tinyxml2.h" - -class ZVtx : public ZResource -{ -public: - int16_t x, y, z; - uint16_t flag; - int16_t s, t; - uint8_t r, g, b, a; - - ZVtx(ZFile* nParent); - - void ParseRawData() override; - - Declaration* DeclareVar(const std::string& prefix, const std::string& bodyStr) override; - std::string GetBodySourceCode() const override; - - bool IsExternalResource() const override; - bool DoesSupportArray() const override; - std::string GetSourceTypeName() const override; - ZResourceType GetResourceType() const override; - std::string GetExternalExtension() const override; - - size_t GetRawDataSize() const override; - DeclarationAlignment GetDeclarationAlignment() const override; -}; diff --git a/ZAPDTR/ZAPD/any/any/zlib.static.txt b/ZAPDTR/ZAPD/any/any/zlib.static.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/ZAPDTR/ZAPD/ctpl_stl.h b/ZAPDTR/ZAPD/ctpl_stl.h deleted file mode 100644 index 8e2d9c908..000000000 --- a/ZAPDTR/ZAPD/ctpl_stl.h +++ /dev/null @@ -1,251 +0,0 @@ -/********************************************************* -* -* Copyright (C) 2014 by Vitaliy Vitsentiy -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -*********************************************************/ - - -#ifndef __ctpl_stl_thread_pool_H__ -#define __ctpl_stl_thread_pool_H__ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - - - -// thread pool to run user's functors with signature -// ret func(int id, other_params) -// where id is the index of the thread that runs the functor -// ret is some return type - - -namespace ctpl { - - namespace detail { - template - class Queue { - public: - bool push(T const & value) { - std::unique_lock lock(this->mutex); - this->q.push(value); - return true; - } - // deletes the retrieved element, do not use for non integral types - bool pop(T & v) { - std::unique_lock lock(this->mutex); - if (this->q.empty()) - return false; - v = this->q.front(); - this->q.pop(); - return true; - } - bool empty() { - std::unique_lock lock(this->mutex); - return this->q.empty(); - } - private: - std::queue q; - std::mutex mutex; - }; - } - - class thread_pool { - - public: - - thread_pool() { this->init(); } - thread_pool(int nThreads) { this->init(); this->resize(nThreads); } - - // the destructor waits for all the functions in the queue to be finished - ~thread_pool() { - this->stop(true); - } - - // get the number of running threads in the pool - int size() { return static_cast(this->threads.size()); } - - // number of idle threads - int n_idle() { return this->nWaiting; } - std::thread & get_thread(int i) { return *this->threads[i]; } - - // change the number of threads in the pool - // should be called from one thread, otherwise be careful to not interleave, also with this->stop() - // nThreads must be >= 0 - void resize(int nThreads) { - if (!this->isStop && !this->isDone) { - int oldNThreads = static_cast(this->threads.size()); - if (oldNThreads <= nThreads) { // if the number of threads is increased - this->threads.resize(nThreads); - this->flags.resize(nThreads); - - for (int i = oldNThreads; i < nThreads; ++i) { - this->flags[i] = std::make_shared>(false); - this->set_thread(i); - } - } - else { // the number of threads is decreased - for (int i = oldNThreads - 1; i >= nThreads; --i) { - *this->flags[i] = true; // this thread will finish - this->threads[i]->detach(); - } - { - // stop the detached threads that were waiting - std::unique_lock lock(this->mutex); - this->cv.notify_all(); - } - this->threads.resize(nThreads); // safe to delete because the threads are detached - this->flags.resize(nThreads); // safe to delete because the threads have copies of shared_ptr of the flags, not originals - } - } - } - - // empty the queue - void clear_queue() { - std::function * _f; - while (this->q.pop(_f)) - delete _f; // empty the queue - } - - // pops a functional wrapper to the original function - std::function pop() { - std::function * _f = nullptr; - this->q.pop(_f); - std::unique_ptr> func(_f); // at return, delete the function even if an exception occurred - std::function f; - if (_f) - f = *_f; - return f; - } - - // wait for all computing threads to finish and stop all threads - // may be called asynchronously to not pause the calling thread while waiting - // if isWait == true, all the functions in the queue are run, otherwise the queue is cleared without running the functions - void stop(bool isWait = false) { - if (!isWait) { - if (this->isStop) - return; - this->isStop = true; - for (int i = 0, n = this->size(); i < n; ++i) { - *this->flags[i] = true; // command the threads to stop - } - this->clear_queue(); // empty the queue - } - else { - if (this->isDone || this->isStop) - return; - this->isDone = true; // give the waiting threads a command to finish - } - { - std::unique_lock lock(this->mutex); - this->cv.notify_all(); // stop all waiting threads - } - for (int i = 0; i < static_cast(this->threads.size()); ++i) { // wait for the computing threads to finish - if (this->threads[i]->joinable()) - this->threads[i]->join(); - } - // if there were no threads in the pool but some functors in the queue, the functors are not deleted by the threads - // therefore delete them here - this->clear_queue(); - this->threads.clear(); - this->flags.clear(); - } - - template - auto push(F && f, Rest&&... rest) ->std::future { - auto pck = std::make_shared>( - std::bind(std::forward(f), std::placeholders::_1, std::forward(rest)...) - ); - auto _f = new std::function([pck](int id) { - (*pck)(id); - }); - this->q.push(_f); - std::unique_lock lock(this->mutex); - this->cv.notify_one(); - return pck->get_future(); - } - - // run the user's function that excepts argument int - id of the running thread. returned value is templatized - // operator returns std::future, where the user can get the result and rethrow the catched exceptins - template - auto push(F && f) ->std::future { - auto pck = std::make_shared>(std::forward(f)); - auto _f = new std::function([pck](int id) { - (*pck)(id); - }); - this->q.push(_f); - std::unique_lock lock(this->mutex); - this->cv.notify_one(); - return pck->get_future(); - } - - - private: - - // deleted - thread_pool(const thread_pool &);// = delete; - thread_pool(thread_pool &&);// = delete; - thread_pool & operator=(const thread_pool &);// = delete; - thread_pool & operator=(thread_pool &&);// = delete; - - void set_thread(int i) { - std::shared_ptr> flag(this->flags[i]); // a copy of the shared ptr to the flag - auto f = [this, i, flag/* a copy of the shared ptr to the flag */]() { - std::atomic & _flag = *flag; - std::function * _f; - bool isPop = this->q.pop(_f); - while (true) { - while (isPop) { // if there is anything in the queue - std::unique_ptr> func(_f); // at return, delete the function even if an exception occurred - (*_f)(i); - if (_flag) - return; // the thread is wanted to stop, return even if the queue is not empty yet - else - isPop = this->q.pop(_f); - } - // the queue is empty here, wait for the next command - std::unique_lock lock(this->mutex); - ++this->nWaiting; - this->cv.wait(lock, [this, &_f, &isPop, &_flag](){ isPop = this->q.pop(_f); return isPop || this->isDone || _flag; }); - --this->nWaiting; - if (!isPop) - return; // if the queue is empty and this->isDone == true or *flag then return - } - }; - this->threads[i].reset(new std::thread(f)); // compiler may not support std::make_unique() - } - - void init() { this->nWaiting = 0; this->isStop = false; this->isDone = false; } - - std::vector> threads; - std::vector>> flags; - detail::Queue *> q; - std::atomic isDone; - std::atomic isStop; - std::atomic nWaiting; // how many threads are waiting - - std::mutex mutex; - std::condition_variable cv; - }; - -} - -#endif // __ctpl_stl_thread_pool_H__ \ No newline at end of file diff --git a/ZAPDTR/ZAPD/genbuildinfo.py b/ZAPDTR/ZAPD/genbuildinfo.py deleted file mode 100644 index 91a567d31..000000000 --- a/ZAPDTR/ZAPD/genbuildinfo.py +++ /dev/null @@ -1,18 +0,0 @@ -#!/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("build/ZAPD/BuildInfo.cpp", "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("extern const char gBuildHash[] = \"" + label + "\";\n") - #buildFile.write("extern const char gBuildDate[] = \"" + now.strftime("%Y-%m-%d %H:%M:%S") + "\";\n") diff --git a/ZAPDTR/ZAPD/packages.config b/ZAPDTR/ZAPD/packages.config deleted file mode 100644 index c387aaed7..000000000 --- a/ZAPDTR/ZAPD/packages.config +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/ZAPDTR/ZAPD/pathconf.c b/ZAPDTR/ZAPD/pathconf.c deleted file mode 100644 index 8ef448999..000000000 --- a/ZAPDTR/ZAPD/pathconf.c +++ /dev/null @@ -1,6 +0,0 @@ -#include - -long pathconf(const char *path, int name) { - return -1; -} - diff --git a/ZAPDTR/ZAPD/yaz0/readwrite.h b/ZAPDTR/ZAPD/yaz0/readwrite.h deleted file mode 100644 index af3471590..000000000 --- a/ZAPDTR/ZAPD/yaz0/readwrite.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef __READWRITE_H__ -#define __READWRITE_H__ - -#include - -/* variables */ -union { - uint32_t u; - float f; -} __u32_f32_union__; - -#define U32(x) \ - ((uint32_t)((((uint8_t*)(x))[0] << 24) | (((uint8_t*)(x))[1] << 16) | \ - (((uint8_t*)(x))[2] << 8) | ((uint8_t*)(x))[3])) -#define U16(x) ((uint16_t)(((*((uint8_t*)(x))) << 8) | ((uint8_t*)(x))[1])) -#define U8(x) ((uint8_t)((uint8_t*)(x))[0]) -#define S32(x) ((int32_t)(U32(x))) -#define S16(x) ((int16_t)(U16(x))) -#define F32(x) (((__u32_f32_union__.u = U32(x)) & 0) + __u32_f32_union__.f) - -#define W32(x, v) \ - { \ - *((uint8_t*)x + 3) = ((v)&0xFF); \ - *((uint8_t*)x + 2) = (((v) >> 8) & 0xFF); \ - *((uint8_t*)x + 1) = (((v) >> 16) & 0xFF); \ - *((uint8_t*)x + 0) = (((v) >> 24) & 0xFF); \ - } - -#endif \ No newline at end of file diff --git a/ZAPDTR/ZAPD/yaz0/yaz0.cpp b/ZAPDTR/ZAPD/yaz0/yaz0.cpp deleted file mode 100644 index 885f41d1d..000000000 --- a/ZAPDTR/ZAPD/yaz0/yaz0.cpp +++ /dev/null @@ -1,227 +0,0 @@ -#include -#include -#include -#include -#include -#include "readwrite.h" - -#include "yaz0.h" - -typedef uint8_t u8; -typedef uint16_t u16; -typedef uint32_t u32; - -/* internal declarations */ -int yaz0_encode_internal(const u8* src, int srcSize, u8* Data); - -int yaz0_get_size(u8* src) { return U32(src + 0x4); } - -u32 toDWORD(u32 d) { - u8 w1 = d & 0xFF; - u8 w2 = (d >> 8) & 0xFF; - u8 w3 = (d >> 16) & 0xFF; - u8 w4 = d >> 24; - return (w1 << 24) | (w2 << 16) | (w3 << 8) | w4; -} - -// simple and straight encoding scheme for Yaz0 -u32 longest_match_brute(const u8* src, int size, int pos, u32* pMatchPos) { - int startPos = pos - 0x1000; - int max_match_size = size - pos; - u32 best_match_size = 0; - u32 best_match_pos = 0; - - if (max_match_size < 3) return 0; - - if (startPos < 0) startPos = 0; - - if (max_match_size > 0x111) max_match_size = 0x111; - - for (int i = startPos; i < pos; i++) { - int current_size; - for (current_size = 0; current_size < max_match_size; current_size++) { - if (src[i + current_size] != src[pos + current_size]) { - break; - } - } - if (current_size > best_match_size) { - best_match_size = current_size; - best_match_pos = i; - if (best_match_size == 0x111) break; - } - } - *pMatchPos = best_match_pos; - return best_match_size; -} - -u32 longest_match_rabinkarp(const u8* src, int size, int pos, u32* match_pos) { - int startPos = pos - 0x1000; - int max_match_size = size - pos; - u32 best_match_size = 0; - u32 best_match_pos = 0; - - if (max_match_size < 3) return 0; - - if (startPos < 0) startPos = 0; - - if (max_match_size > 0x111) max_match_size = 0x111; - - int find_hash = src[pos] << 16 | src[pos + 1] << 8 | src[pos + 2]; - int current_hash = src[startPos] << 16 | src[startPos + 1] << 8 | src[startPos + 2]; - - for (int i = startPos; i < pos; i++) { - if(current_hash == find_hash) { - int current_size; - for (current_size = 3; current_size < max_match_size; current_size++) { - if (src[i + current_size] != src[pos + current_size]) { - break; - } - } - if (current_size > best_match_size) { - best_match_size = current_size; - best_match_pos = i; - if (best_match_size == 0x111) break; - } - } - current_hash = (current_hash << 8 | src[i + 3]) & 0xFFFFFF; - } - *match_pos = best_match_pos; - - return best_match_size; -} - -int yaz0_encode_internal(const u8* src, int srcSize, u8* Data) { - int srcPos = 0; - - int bitmask = 0x80; - u8 currCodeByte = 0; - int currCodeBytePos = 0; - int pos = currCodeBytePos + 1; - - while (srcPos < srcSize) { - u32 numBytes; - u32 matchPos; - - numBytes = longest_match_rabinkarp(src, srcSize, srcPos, &matchPos); - //fprintf(stderr, "pos %x len %x pos %x\n", srcPos, (int)numBytes, (int)matchPos); - if (numBytes < 3) { - //fprintf(stderr, "single byte %02x\n", src[srcPos]); - Data[pos++] = src[srcPos++]; - currCodeByte |= bitmask; - } else { - // RLE part - u32 dist = srcPos - matchPos - 1; - - if (numBytes >= 0x12) // 3 byte encoding - { - Data[pos++] = dist >> 8; // 0R - Data[pos++] = dist & 0xFF; // FF - if (numBytes > 0xFF + 0x12) numBytes = 0xFF + 0x12; - Data[pos++] = numBytes - 0x12; - } else // 2 byte encoding - { - Data[pos++] = ((numBytes - 2) << 4) | (dist >> 8); - Data[pos++] = dist & 0xFF; - } - srcPos += numBytes; - } - bitmask >>= 1; - // write eight codes - if (!bitmask) { - Data[currCodeBytePos] = currCodeByte; - currCodeBytePos = pos++; - - currCodeByte = 0; - bitmask = 0x80; - } - } - if (bitmask) { - Data[currCodeBytePos] = currCodeByte; - } - - return pos; -} - -std::vector yaz0_encode_fast(const u8* src, int src_size) { - std::vector buffer; - std::vector> lut; - lut.resize(0x1000000); - - for (int i = 0; i < src_size - 3; ++i) { - lut[src[i + 0] << 16 | src[i + 1] << 8 | src[i + 2]].push_back(i); - } - - return buffer; -} - -std::vector yaz0_encode(const u8* src, int src_size) { - std::vector buffer(src_size * 10 / 8 + 16); - u8* dst = buffer.data(); - - // write 4 bytes yaz0 header - memcpy(dst, "Yaz0", 4); - - // write 4 bytes uncompressed size - W32(dst + 4, src_size); - - // encode - int dst_size = yaz0_encode_internal(src, src_size, dst + 16); - int aligned_size = (dst_size + 31) & -16; - buffer.resize(aligned_size); - -#if 0 - std::vector decompressed(src_size); - yaz0_decode(buffer.data(), decompressed.data(), src_size); - if(memcmp(src, decompressed.data(), src_size)) { - fprintf(stderr, "Decompressed buffer is different from original\n"); - } -#endif - - return buffer; -} - -void yaz0_decode(const uint8_t* source, uint8_t* decomp, int32_t decompSize) { - uint32_t srcPlace = 0, dstPlace = 0; - uint32_t i, dist, copyPlace, numBytes; - uint8_t codeByte, byte1, byte2; - uint8_t bitCount = 0; - - source += 0x10; - while (dstPlace < decompSize) { - /* If there are no more bits to test, get a new byte */ - if (!bitCount) { - codeByte = source[srcPlace++]; - bitCount = 8; - } - - /* If bit 7 is a 1, just copy 1 byte from source to destination */ - /* Else do some decoding */ - if (codeByte & 0x80) { - decomp[dstPlace++] = source[srcPlace++]; - } else { - /* Get 2 bytes from source */ - byte1 = source[srcPlace++]; - byte2 = source[srcPlace++]; - - /* Calculate distance to move in destination */ - /* And the number of bytes to copy */ - dist = ((byte1 & 0xF) << 8) | byte2; - copyPlace = dstPlace - (dist + 1); - numBytes = byte1 >> 4; - - /* Do more calculations on the number of bytes to copy */ - if (!numBytes) - numBytes = source[srcPlace++] + 0x12; - else - numBytes += 2; - - /* Copy data from a previous point in destination */ - /* to current point in destination */ - for (i = 0; i < numBytes; i++) decomp[dstPlace++] = decomp[copyPlace++]; - } - - /* Set up for the next read cycle */ - codeByte = codeByte << 1; - bitCount--; - } -} \ No newline at end of file diff --git a/ZAPDTR/ZAPD/yaz0/yaz0.h b/ZAPDTR/ZAPD/yaz0/yaz0.h deleted file mode 100644 index 0d5cc3cfd..000000000 --- a/ZAPDTR/ZAPD/yaz0/yaz0.h +++ /dev/null @@ -1,6 +0,0 @@ -#pragma once - -#include - -void yaz0_decode(const uint8_t* src, uint8_t* dest, int32_t destsize); -std::vector yaz0_encode(const uint8_t* src, int src_size); \ No newline at end of file diff --git a/ZAPDTR/copycheck.py b/ZAPDTR/copycheck.py deleted file mode 100755 index 36288f685..000000000 --- a/ZAPDTR/copycheck.py +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env python3 - -import os -from shutil import copyfile - -if (os.environ.get('ZAPD_COPYDIR') != None): - print("Copying ZAPD.out to repo...") - #print(os.environ.get('ZAPD_COPYDIR')) - copyfile("ZAPD.out", os.environ.get('ZAPD_COPYDIR') + "/ZAPD.out") diff --git a/ZAPDTR/docs/zapd_extraction_xml_reference.md b/ZAPDTR/docs/zapd_extraction_xml_reference.md deleted file mode 100644 index 78817dc6e..000000000 --- a/ZAPDTR/docs/zapd_extraction_xml_reference.md +++ /dev/null @@ -1,680 +0,0 @@ -# ZAPD extraction XML reference - -This document aims to be a small reference of how to create a compatible xml file for ZAPD. - -## Table of contents - -- [ZAPD extraction XML reference](#zapd-extraction-xml-reference) - - [Table of contents](#table-of-contents) - - [Basic XML](#basic-xml) - - [Resources types](#resources-types) - - [File](#file) - - [ExternalFile](#externalfile) - - [Texture](#texture) - - [Background](#background) - - [Blob](#blob) - - [DList](#dlist) - - [TextureAnimation](#textureanimation) - - [Scene and Room](#scene-and-room) - - [AltHeader](#altheader) - - [Animation](#animation) - - [PlayerAnimation](#playeranimation) - - [CurveAnimation](#curveanimation) - - [LegacyAnimation](#legacyanimation) - - [Skeleton](#skeleton) - - [LimbTable](#limbtable) - - [Limb](#limb) - - [Symbol](#symbol) - - [Collision](#collision) - - [Scalar](#scalar) - - [Vector](#vector) - - [Vtx](#vtx) - - [Mtx](#mtx) - - [Cutscene](#cutscene) - - [Array](#array) - - [Path](#path) - - [PlayerAnimationData](#playeranimationdata) - - [Pointer](#pointer) - -## Basic XML - -An example of an object xml: - -```xml - - - - - - - - - - - - - - - - - - - -``` - -Every xml must have a `` tag. It must have at least one `` child. - -## Resources types - -The following is a list of the resources/tags supported by ZAPD, and the attributes needed by each one. - -For most resources inside a `` tag **you should also set an `Offset` attribute**. This is the offset (within the file) of the resource you are exporting. The `Offset` attribute is expected to be in hexadecimal, for example `Offset="0x41F0"`. - -It's worth noting that every tag expects a `Name="gNameOfTheAsset"`. This is will be the name of the extracted variable in the output C code. Every asset must be prefixed with `g` and the suffix should represent the type of the variable. - -Every tag can accept a `Static` attribute to specify if the asset should be marked as `static` or not. -There are 3 valid values (defaults to `Global`): - -- `Global`: Mark static if the flag `--static` was used. -- `On`: Override the global config and **always mark** as `static`. -- `Off`: Override the global config and **don't mark** as `static`. - -This table summarizes if the asset will be marked `static` (✅) or not (❌) -| `Static=""` attribute in XML | Without `--static` flag | With `--static` flag | -| ---------------------------- | ----------------------- | -------------------- | -| `On` | ✅ | ✅ | -| `Global` (default) | ❌ | ✅ | -| `Off` | ❌ | ❌ | - -------------------------- - -### File - -- Example of this tag: - -```xml - -``` - -- 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`: Optional. This is the segment number of the current file. Expects a decimal number between 0 and 15 inclusive, usually 6 if it is an object. If not specified, the file will use VRAM instead of segmented 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`. - - `RangeEnd`: Optional. File offset where the extraction will end. Hex. Default value: `0xFFFFFFFF`. - - `Game`: Optional. Valid values: `OOT`, `MM`, `SW97` and `OOTSW97`. Default value: `OOT`. - -------------------------- - -### ExternalFile - -Allows ZAPD to map segmented addresses to variables declared in other files by using its XML. - -It is useful for objects that use variables from `gameplay_keep`, `gameplay_dangeon_keep`, `gameplay_field_keep`, etc. - -This tag can be used in the global `config.xml` file. - -- Example of this tag: - -```xml - -``` - -- Attributes: - - - `XmlPath`: Required. The path of the XML, relative to the value set by `ExternalXMLFolder` in the configuration file. - - `OutPath`: Required. The path were the header for the corresponding external file is. It is used to `#include` it in the generated `.c` file. - -------------------------- - -### Texture - -Textures are extracted as `.png` files. - -- Example: - -```xml - -``` - -Will be defined as: - -```c -u64 gCraterSmokeConeTex[] = { -#include "assets/objects/object_spot17_obj/crater_smoke_cone.ia8.inc.c" -}; -``` - -- Attributes: - - - `Name`: Required. Suffixed 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`, `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. - - `ExternalTlut`: Optional. Specifies that the texture's tlut is in a different file. Takes the filename of the file that contains the tlut. - - `ExternalTlutOffset`: Optional. Specifies the offset in the `ExternalTlut` of the tlut for the given texture. - - `SplitTlut`: Optional. Specifies that the given texture should take from the upper half of the tlut. Takes a bool, i.e. one of `true`, `false`, `1`, `0`. - -The following is a list of the texture formats the Nintendo 64 supports, with their gfxdis names and ZAPD format names. - -| Format name | Typing in `gsDPLoadTextureBlock` | "Format" in xml | -| ----------------------------------------------- | -------------------------------- | --------------- | -| 4-bit intensity (I) | `G_IM_FMT_I, G_IM_SIZ_4b` | `i4` | -| 4-bit intensity with alpha (I/A) (3/1) | `G_IM_FMT_IA, G_IM_SIZ_4b` | `ia4` | -| 4-bit color index (CI) | `G_IM_FMT_CI, G_IM_SIZ_4b` | `ci4` | -| 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` | `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` | `rgba32` | - -If you want to know more about this formats, you can check [`gsDPLoadTextureBlock`](http://n64devkit.square7.ch/n64man/gdp/gDPLoadTextureBlock.htm) for most formats, or [`gDPLoadTextureBlock_4b`](http://n64devkit.square7.ch/n64man/gdp/gDPLoadTextureBlock_4b.htm) for the 4-bit formats. - -------------------------- - -### Background - -- Example: - -```xml - -``` - -- Attributes: - - - `Name`: Required. Suffixed by `Background`. - - `OutName`: Required. The filename of the extracted `.jpg` file. - -※ Explicit use of this tag isn't often necesary because it would probably be extracted automatically by another extracted element. You can use this to name them if you don't like the autogenerated name. - -------------------------- - -### Blob - -Blob are binary data that will be extracted as `.bin` files. - -- Example: - -```xml - -``` - -Will be defined as: - -```c - -u8 gFireTempleBlob_00CCC0[] = { -#include "assets/objects/object_hidan_objects/gFireTempleBlob_00CCC0.bin.inc.c" -}; -``` - -- Attributes: - - - `Name`: Required. Suffixed by `Blob`. - - `Size`: Required. Amount of bytes to extract. Hex. - -※ We usually use blobs when we can't figure out the content's type of chunk of data. - -------------------------- - -### DList - -A.k.a. Display list, or Gfx. - -- Example: - -```xml - -``` - -- Attributes: - - - `Name`: Required. Suffixed by `DL`. - -------------------------- - -### TextureAnimation - -A data type exclusive to Majora's Mask, that has scrolling, color changing, and texture changing capabilities. Declaring the main array will generate everything else; textures for the TextureCycle type must be declared manually in the XML to use symbols. (If it does reference any undeclared textures, ZAPD will warn and give the their offsets.) - -```xml - -``` - -- Attributes: - - - `Name`: Required. Suffixed by `TexAnim`. - -------------------------- - -### Scene and Room - -`Scene`s and `Room`s are a bit special, because `Room`s usually needs assets declared in their respective `Scene` (which is in a different file), so they need to be extracted together. - -To accomplish this, the scene and each of their rooms must be declared in the same XML. - -- Example: - -```xml - - - - - - - - - - - - - - -``` - -- Attributes: - - - `HackMode`: Optional. This is a simple non-hardcoded way to handle some edge cases. Valid values: `syotes_room`. - -------------------------- - -### AltHeader - -Like `Scene`s and `Room`s, `AltHeader`s is special too. It should always be declared in the same `File` as a `Scene` or a `Room`. - -- Example: - -```xml - - - - - - - - - - - - - - -``` - -- Attributes: - - - `Name`: Required. Suffixed by `AltHeader`. - -------------------------- - -### Animation - -- Example: - -```xml - -``` - -- Attributes: - - - `Name`: Required. Suffixed by `Anim`. - -------------------------- - -### PlayerAnimation - -- Example: - -```xml - -``` - -- Attributes: - - - `Name`: Required. Suffixed by `Anim`. - -------------------------- - -### CurveAnimation - -- Example: - -```xml - -``` - -- Attributes: - - - `Name`: Required. Suffixed by `Anim`. - - `SkelOffset`: Required. Offset of the `CurveSkeleton` (I.e. a [`Skeleton`](#skeleton) resource with `Type="Curve"`) related to this animation. - -------------------------- - -### LegacyAnimation - -Useful only for the unused `object_human`'s animation data. - -- Example: - -```xml - -``` - -- Attributes: - - - `Name`: Required. Suffixed by `Anim`. - -------------------------- - -### Skeleton - -- Example: - -```xml - -``` - -- Attributes: - - - `Name`: Required. Suffixed by `Skel`. - - `Type`: Required. Valid values: `Normal`, `Flex` and `Curve`. - - `LimbType`: Required. Valid values: `Standard`, `LOD`, `Skin`, `Curve` and `Legacy`. - - `EnumName`: Optional. The name of `typedef`'d limb enum. - - `LimbNone`: Optional. The name of the limb with index zero in the limb enum. - - `LimbMax`: Optional. The name of the max limb index in the limb enum. - -ZAPD is able to generate a limb enum by itself only if all the required data is provided. Providing some but not all the required data would trigger an error and the execution will halt. - -The required data is providing the `EnumName`, `LimbNone` and `LimbMax` attributes in the `Skeleton` or `LimbTable` node and the `EnumName` attribute in every `Limb` of this skeleton. - -※ 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. Suffixed by `Skel`. - - `LimbType`: Required. Valid values: `Standard`, `LOD`, `Skin`, `Curve` and `Legacy`. - - `Count`: Required. Amount of limbs. Integer. - - `EnumName`: Optional. The name of `typedef`'d limb enum. - - `LimbNone`: Optional. The name of the limb with index zero in the limb enum. - - `LimbMax`: Optional. The name of the max limb index in the limb enum. - -See [Skeleton](#skeleton) for info on the limb enum generation. - -------------------------- - -### Limb - -- Example: - -```xml - -``` - -- Attributes: - - - `Name`: Required. Suffixed by `Limb`. - - `LimbType`: Required. Valid values: `Standard`, `LOD`, `Skin`, `Curve` and `Legacy`. - - `EnumName`: Optional. The name used for this limb in the limbs enum. It must be either present in every limb or in none. - -See [Skeleton](#skeleton) for info on the limb enum generation. - -------------------------- - -### Symbol - -A special element that allows declaring a variable without actually extracting it from the current file. Useful when a resource references an element from another file. The symbol will be declared as `extern`. - -- Example: - -```xml - -``` - -Will be declared as: - -```c -extern u8 gJsjutanShadowTex[2048]; -``` - -- Attributes: - - - `Type`: The type of the declared variable. If missing, it will default to `void*`. - - `TypeSize`: The size in bytes of the type. If missing, it will default to `4` (the size of a word and a pointer). Integer or hex value. - - `Count`: Optional. If it is present, the variable will be declared as an array instead of a plain variable. The value of this attribute specifies the length of the array. If `Count` is present but it has no value (`Count=""`), then the length of the array will not be specified either in the declared variable. Integer or hex value. - - `Static`: This attribute can't be enabled on a Symbol node. A warning will be showed in this case. - -------------------------- - -### Collision - -- Example: - -```xml - -``` - -- Attributes: - - - `Name`: Required. Suffixed by `Col`. - -------------------------- - -### Scalar - -Allows the extraction of a single number. - -- Example: - -```xml - -``` - -Will be extracted as: - -```c -u64 pad34F8 = { 0 }; -``` - -- Attributes: - - - `Name`: Required. Suffixed by ~~`TBD`~~. - - `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. - -------------------------- - -### Vector - -Extracts a vector. - -Current supported types are `Vec3s`, `Vec3i` or `Vec3f`. - -- Example: - -```xml - - - -``` - -Will be extracted as: - -```c -Vec3s gLinkPauseChildDekuShieldJointTable[24] = { - { -37, 2346, 93 }, - { 0, 11995, 0 }, - { -16385, -305, -16333 }, - { 0, 51, 12 }, - { 3761, 2263, -384 }, - { 0, 0, 3786 }, - { 1594, 1384, -18344 }, - { -2288, -2428, -1562 }, - { 0, 0, 3219 }, - { -2148, -5, -16840 }, - { 15365, -1708, 15611 }, - { 1761, 8365, 17711 }, - { 0, 0, 18859 }, - { 0, 0, 0 }, - { -9392, -9579, 28686 }, - { 0, 0, -7093 }, - { -2748, 685, -14092 }, - { 213, 6553, -32212 }, - { 0, 0, -1877 }, - { 3267, 3309, -16090 }, - { -18101, 25946, -2670 }, - { -104, 0, 0 }, - { 0, 0, 0 }, - { 0, 0, 0 } -}; -``` - -- Attributes: - - - `Name`: Required. Suffixed by ~~`TBD`~~. - - `Type`: Required. Specifies the vector's type (`Vec3s`, `Vec3i` and `Vec3f`). Valid values: `s16`, `s32` and `f32`. - - `Dimensions`: Required. The amount of dimensions of the vector. Valid values: `3`. - -※ Can be wrapped in an [`Array`](#array) tag. - -------------------------- - -### Vtx - -- Example: - -```xml - - - -``` - -- Attributes: - - - `Name`: Required. Suffixed by `Vtx`. - -※ Can be wrapped in an [`Array`](#array) tag. - -------------------------- - -### Mtx - -- Example: - -```xml - -``` - -- Attributes: - - - `Name`: Required. Suffixed by `Mtx`. - -※ Explicit use of this tag isn't often necesary because it would probably be extracted automatically by another extracted element. - -------------------------- - -### Cutscene - -- Example: - -```xml - -``` - -- Attributes: - - - `Name`: Required. Suffixed by `Cs`. - -※ Explicit use of this tag isn't often necesary because it would probably be extracted automatically by another extracted element. - -------------------------- - -### Array - -The `Array` element is special, because it needs an inner element to work. It will declare an array of its inner element. - -Currently, only [`Pointer`](#pointer), [`Scalar`](#scalar), [`Vector`](#vector) and [`Vtx`](#vtx) support being wrapped in an array. - -- Example: - -```xml - - - -``` - -- Attributes: - - - `Name`: Required. How the variable will be named. By our convention it should be prefixed by `g`. The sufix is mandated by the element contained. - - `Count`: Required. Amount of elements. Integer. - -------------------------- - -### Path - -- Example: - -```xml - -``` - -- Attributes: - - - `Name`: Required. Suffixed by `Path`. - - `NumPaths`: Optional. The amount of paths contained in the array. It must be a positive integer. - -------------------------- - -### PlayerAnimationData - -Allows the extraction of the specific data of the player animations which are found in the `link_animetion` file. - -- Example: - -```xml - -``` - -- Attributes: - - - `Name`: Required. Suffixed by `AnimData`. - - `FrameCount`: Required. The length of the animation in frames. It must be a positive integer. - -------------------------- - -### Pointer - -Allows the extraction of a variable that contains a pointer - -- Example: - -```xml - - - -``` - -- Attributes: - - - `Name`: Required. - - `Type`: Required. The type of the extracted pointer. - -※ Can be wrapped in an [`Array`](#array) tag. - -------------------------- diff --git a/ZAPDTR/docs/zapd_warning_example.png b/ZAPDTR/docs/zapd_warning_example.png deleted file mode 100644 index a001c64d6..000000000 Binary files a/ZAPDTR/docs/zapd_warning_example.png and /dev/null differ diff --git a/ZAPDTR/docs/zapd_xml_spec.md b/ZAPDTR/docs/zapd_xml_spec.md deleted file mode 100644 index 9fcc0d4aa..000000000 --- a/ZAPDTR/docs/zapd_xml_spec.md +++ /dev/null @@ -1,55 +0,0 @@ -# ZAPD XML specification - -ZAPD XMLs use a restrictive subset of the XML standard: any ZAPD XML must be a valid XML (All elements starting with `` ending appropriately with ``, single "empty-element" tags with `/` at the end, etc.). - -Reminder that in - -```xml - - - - - - - - - -``` - -``, ``, `` are *children* of ``, but `` is not. `` is a *descendent* of `` and a child of ``. - -- Every XML's outermost element start/end tag is a single ``. -- The children of a `` must be ``s. -- A `` has *resources* as children. A resource is almost always single empty-element tag, and has one of the types - - `` - - `` - - `` - - `` - - `` - - `` - - `` - - `` - - `` - - `` - - `` - - `` - - `` - - `` - - `` - - `` - - `` - - `` - - `` - - `` - - `` - - `` - - `` - - `` - - `` - -- A `` cannot descend from a ``. -- All resources must be children of a ``. -- `` is the only paired resource tag enclosing an element; the element must be a single resource tag, one of - - `` - - `` - - `` diff --git a/ZAPDTR/lib/libgfxd/.gitrepo b/ZAPDTR/lib/libgfxd/.gitrepo deleted file mode 100644 index 4c8b7fe76..000000000 --- a/ZAPDTR/lib/libgfxd/.gitrepo +++ /dev/null @@ -1,12 +0,0 @@ -; DO NOT EDIT (unless you know what you are doing) -; -; This subdirectory is a git "subrepo", and this file is maintained by the -; git-subrepo command. See https://github.com/git-commands/git-subrepo#readme -; -[subrepo] - remote = git@github.com:glankk/libgfxd.git - branch = master - commit = 008f73dca8ebc9151b205959b17773a19c5bd0da - parent = c92cfda733aa740a53129a21f69c8abb08a465c7 - method = merge - cmdver = 0.4.3 diff --git a/ZAPDTR/lib/libgfxd/LICENSE b/ZAPDTR/lib/libgfxd/LICENSE deleted file mode 100644 index a7655f829..000000000 --- a/ZAPDTR/lib/libgfxd/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2016-2021 glank (glankk@github.com) - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/ZAPDTR/lib/libgfxd/Makefile b/ZAPDTR/lib/libgfxd/Makefile deleted file mode 100644 index 5c3edbef4..000000000 --- a/ZAPDTR/lib/libgfxd/Makefile +++ /dev/null @@ -1,26 +0,0 @@ -CC ?= gcc -CFLAGS = -Wall -O2 -g -UC_OBJ = uc_f3d.o uc_f3db.o uc_f3dex.o uc_f3dexb.o uc_f3dex2.o -OBJ = gfxd.o $(UC_OBJ) -LIB = libgfxd.a - -CPPFLAGS-$(MT) += -DCONFIG_MT -CPPFLAGS += $(CPPFLAGS-y) - -.PHONY: all -all: $(LIB) - -.PHONY: clean -clean: - rm -f $(OBJ) $(LIB) - -.INTERMEDIATE: $(OBJ) - -$(OBJ): gbi.h gfxd.h priv.h -$(UC_OBJ): uc.c uc_argfn.c uc_argtbl.c uc_macrofn.c uc_macrotbl.c - -$(LIB): $(OBJ) - $(AR) rcs $@ $^ - -%.o: %.c - $(COMPILE.c) $(OUTPUT_OPTION) $< diff --git a/ZAPDTR/lib/libgfxd/README.md b/ZAPDTR/lib/libgfxd/README.md deleted file mode 100644 index 2e8258943..000000000 --- a/ZAPDTR/lib/libgfxd/README.md +++ /dev/null @@ -1,478 +0,0 @@ -## Installing -Run `make` for a single-threaded build, or `make MT=y` for a multi-threaded -build. Copy `libgfxd.a` to your lib directory, and `gfxd.h` to your include -directory. - -## Example usage -Example source code: -``` -#include -#include - -static int macro_fn(void) -{ - /* Print a tab before each macro, and a comma and newline after each - macro */ - gfxd_puts("\t"); - gfxd_macro_dflt(); /* Execute the default macro handler */ - gfxd_puts(",\n"); - - return 0; -} - -int main() -{ - /* Read from stdin and write to stdout */ - gfxd_input_fd(fileno(stdin)); - gfxd_output_fd(fileno(stdout)); - - /* Override the default macro handler to make the output prettier */ - gfxd_macro_fn(macro_fn); - - /* Select F3DEX as the target microcode */ - gfxd_target(gfxd_f3dex); - - /* Set the input endianness to big endian, and the word size to 4 */ - gfxd_endian(gfxd_endian_big, 4); - - /* Print an opening brace */ - gfxd_puts("{\n"); - - /* Execute until the end of input, or until encountering an invalid - command */ - gfxd_execute(); - - /* Print a closing brace */ - gfxd_puts("}\n"); -} -``` - -Example input (binary): -``` -0xe7000000, 0x00000000, -0xfc127e03, 0xfffffdf8, -0xb900031d, 0xc8112078, -0xb6000000, 0x000e0000, -0xb7000000, 0x00012000, -0xfa000000, 0xffffffff, -0x040030bf, 0x000002e0, -0xb1000204, 0x00020604, -0xb1080a0c, 0x000a0e0c, -0xb10a1012, 0x000a120e, -0xb1140200, 0x00140016, -0xb8000000, 0x00000000, -``` - -Example output: -``` -{ - gsDPPipeSync(), - gsDPSetCombineLERP(TEXEL0, 0, SHADE, 0, 0, 0, 0, 1, COMBINED, 0, PRIMITIVE, 0, 0, 0, 0, COMBINED), - gsDPSetRenderMode(G_RM_FOG_SHADE_A, G_RM_AA_ZB_OPA_SURF2), - gsSPClearGeometryMode(G_LIGHTING | G_TEXTURE_GEN | G_TEXTURE_GEN_LINEAR), - gsSPSetGeometryMode(G_CULL_BACK | G_FOG), - gsDPSetPrimColor(0, 0, 0xFF, 0xFF, 0xFF, 0xFF), - gsSPVertex(0x000002E0, 12, 0), - gsSP2Triangles(0, 1, 2, 0, 1, 3, 2, 0), - gsSP2Triangles(4, 5, 6, 0, 5, 7, 6, 0), - gsSP1Quadrangle(5, 8, 9, 7, 0), - gsSP1Quadrangle(10, 1, 0, 11, 0), - gsSPEndDisplayList(), -} -``` - -## Input/output methods -The input consists of any number of `Gfx` packets, and the output is the -decompiled macros in plain-text. The endianness and microcode type of the input -can be set using `gfxd_endian` and `gfxd_target`. - -Several methods of doing I/O are available. No method is selected by default, -meaning there will be no input, and any output will be discarded. - ---- - -##### `void gfxd_input_buffer(const void *buf, int size)` -##### `void gfxd_output_buffer(char *buf, int size)` -Use the buffer pointed to by `buf`, of `size` bytes. - ---- - -##### `void gfxd_input_fd(int fd)` -##### `void gfxd_output_fd(int fd)` -Use `read()` / `write()` with the provided file descriptor, `fd`. - ---- - -##### `typedef int gfxd_input_fn_t(void *buf, int count)` -##### `typedef int gfxd_output_fn_t(const char *buf, int count)` -##### `void gfxd_input_callback(gfxd_input_fn_t *fn)` -##### `void gfxd_output_callback(gfxd_output_fn_t *fn)` -Use the provided callback function, `fn`. `fn` should copy at most `count` -bytes to/from `buf`, and return the number of bytes actually copied. The input -callback should return 0 to signal end of input. - -## Handlers -The macro handler function is responsible for writing the output of each -decompiled macro. The default macro handler is `gfxd_macro_dflt`, but this can -be changed with `gfxd_macro_fn`. The new handler can extend the default -function by calling `gfxd_macro_dflt` within it, or it can override it -completely. - ---- - -##### `int gfxd_macro_dflt()` -The default macro handler. Outputs the macro name, dynamic display list pointer -if one has been specified, and then each argument in order using the function -registered using `gfxd_arg_fn` (`gfxd_arg_dflt` by default), and returns zero. -Because it is designed to be extended, it only outputs the macro text, without -any whitespace or punctuation before or after. When this function is used as -the sole macro handler, it will output the entire display list on one line -without any separation between macros, which is probably not what you want. - ---- - -##### `void gfxd_macro_fn(gfxd_macro_fn_t *fn)` -Set `fn` to be the macro handler function. `fn` can be null, in which case the -handler is reset to the default. - ---- - -##### `void gfxd_arg_dflt(int arg_num)` -The default argument handler for `gfxd_macro_dflt`. For the argument with index -`arg_num`, calls `gfxd_arg_callbacks`, and prints the argument value if the -callback returns zero, or if there is no callback for the given argument. - ---- - -##### `void gfxd_arg_fn(gfxd_arg_fn_t *fn)` -Set `fn` to be the argument handler function, called by `gfxd_macro_dflt`, -for each argument in the current macro, not counting the dynamic display list -pointer if one has been specified. `fn` can be null, in which case the handler -is reset to the default. This only affects the output of `gfxd_macro_dflt`, and -has no observable effect if `gfxd_macro_dflt` is overridden (not extended). - -## Argument callbacks -Callbacks can be registered that will be executed when an argument of a certain -type is encountered. The default argument handler `gfxd_arg_dflt` will execute -callbacks as needed using `gfxd_arg_callbacks`. If a callback returns non-zero, -`gfxd_arg_dflt` will not output anything. This is to allow callbacks to -override the default argument output. Otherwise, `gfxd_arg_dflt` will output -the argument value after the callback function's output. - ---- - -##### `int gfxd_arg_callbacks(int arg_num)` -Examines the argument with index `arg_num` and executes the callback function -for that argument type, if such a callback is supported and has been -registered. This function returns the value that was returned by the callback -function. If no callback function has been registered for the argument type, -zero is returned. - -Most argument callbacks have some extra parameters containing information that -might be relevant to the argument that triggered the callback. The extra -information is extracted only from the current macro, as gfxd does not retain -any context information from previous or subsequent macros. If any of the extra -parameter values is not available in the current macro, the value for that -parameter is substituted with `-1` for signed parameters, and zero for unsigned -parameters. - ---- - -##### `typedef int gfxd_tlut_fn_t(uint32_t tlut, int32_t idx, int32_t count)` -##### `void gfxd_tlut_callback(gfxd_tlut_fn_t *fn)` -Set the callback function for palette arguments. The argument type is -`gfxd_Tlut`. The palette index is in `idx` and the number of colors in `count`. - ---- - -##### `typedef int gfxd_timg_fn_t(uint32_t timg, int32_t fmt, int32_t siz, int32_t width, int32_t height, int32_t pal)` -##### `void gfxd_timg_callback(gfxd_timg_fn_t *fn)` -Set the callback function for texture arguments. The argument type is -`gfxd_Timg`. The image format is in `fmt` and `siz`, the dimensions in `width` -and `height`, and the palette index in `pal`. - ---- - -##### `typedef int gfxd_cimg_fn_t(uint32_t cimg, int32_t fmt, int32_t siz, int32_t width)` -##### `void gfxd_cimg_callback(gfxd_cimg_fn_t *fn)` -Set the callback function for frame buffer arguments. The argument type is -`gfxd_Cimg`. The image format is in `fmt` and `siz`, and the horizontal -resolution in `width`. - ---- - -##### `typedef int gfxd_zimg_fn_t(uint32_t zimg)` -##### `void gfxd_zimg_callback(gfxd_zimg_fn_t *fn)` -Set the callback function for depth buffer arguments. The argument type is -`gfxd_Zimg`. - ---- - -##### `typedef int gfxd_dl_fn_t(uint32_t dl)` -##### `void gfxd_dl_callback(gfxd_dl_fn_t *fn)` -Set the callback function for display list arguments. The argument type is -`gfxd_Dl`. - ---- - -##### `typedef int gfxd_mtx_fn_t(uint32_t mtx)` -##### `void gfxd_mtx_callback(gfxd_mtx_fn_t *fn)` -Set the callback function for matrix arguments. The argument type is -`gfxd_Mtxptr`. - ---- - -##### `typedef int gfxd_lookat_fn_t(uint32_t lookat, int32_t count)` -##### `void gfxd_lookat_callback(gfxd_lookat_fn_t *fn)` -Set the callback function for lookat array arguments. The argument type is -`gfxd_Lookatptr`. The number of lookat structures (1 or 2) is in `count`. - ---- - -##### `typedef int gfxd_light_fn_t(uint32_t light, int32_t count)` -##### `void gfxd_light_callback(gfxd_light_fn_t *fn)` -Set the callback function for light array arguments. The argument type is -`gfxd_Lightptr`. The number of light structures is in `count`. - ---- - -##### `typedef int gfxd_seg_fn_t(uint32_t seg, int32_t num)` -##### `void gfxd_seg_callback(gfxd_seg_fn_t *fn)` -Set the callback function for segment base arguments. The argument type is -`gfxd_Segptr`. The segment number is in `num`. - ---- - -##### `typedef int gfxd_vtx_fn_t(uint32_t vtx, int32_t num)` -##### `void gfxd_vtx_callback(gfxd_vtx_fn_t *fn)` -Set the callback function for vertex array arguments. The argument type is -`gfxd_Vtxptr`. The number of vertex structures is in `num`. - ---- - -##### `typedef int gfxd_vp_fn_t(uint32_t vp)` -##### `void gfxd_vp_callback(gfxd_vp_fn_t *fn)` -Set the callback function for viewport arguments. The argument type is -`gfxd_Vp`. - ---- - -##### `typedef int gfxd_uctext_fn_t(uint32_t text, uint32_t size)` -##### `void gfxd_uctext_callback(gfxd_uctext_fn_t *fn)` -Set the callback function for microcode text arguments. The argument type is -`gfxd_Uctext`. The size of the text segment is in `size`. - ---- - -##### `typedef int gfxd_ucdata_fn_t(uint32_t data, uint32_t size)` -##### `void gfxd_ucdata_callback(gfxd_ucdata_fn_t *fn)` -Set the callback function for microcode data arguments. The argument type is -`gfxd_Ucdata`. The size of the data segment is in `size`. - ---- - -##### `typedef int gfxd_dram_fn_t(uint32_t dram, uint32_t size)` -##### `void gfxd_dram_callback(gfxd_dram_fn_t *fn)` -Set the callback function for generic pointer arguments. The argument type is -`gfxd_Dram`. The size of the data is in `size`. - -## General settings -These functions control general input and output settings. - ---- - -##### `void gfxd_target(gfxd_ucode_t ucode)` -Select `ucode` as the target microcode. `ucode` can be `gfxd_f3d`, `gfxd_f3db`, -`gfxd_f3dex`, `gfxd_f3dexb`, or `gfxd_f3dex2`. The microcode must be selected -before `gfxd_execute`, as no microcode is selected by default. - ---- - -##### `void gfxd_endian(int endian, int wordsize)` -Select `endian` as the endianness of the input, and `wordsize` as the size of -each word in number of bytes. `endian` can be `gfxd_endian_big`, -`gfxd_endian_little`, or `gfxd_endian_host` (the endianness of the host -machine). `wordsize` can be 1, 2, 4, or 8. Big endian is selected by default, -with a word size of 4. - ---- - -##### `void gfxd_dynamic(const char *arg)` -Enable or disable the use of dynamic `g` macros instead of static `gs` macros, -and select the dynamic display list pointer argument to be used. `arg` will be -used by `gfxd_macro_dflt` as the first argument to dynamic macros. If `arg` is -null, dynamic macros are disabled, and `gs` macros are used. Also affects the -result of `gfxd_macro_name`, as it will return either the dynamic or static -version of the macro name as selected by this setting. - ---- - -##### `void gfxd_enable(int cap)` -##### `void gfxd_disable(int cap)` -Enable or disable the feature specified by `cap`. Can be one of the following; -- `gfxd_stop_on_invalid`: Stop execution when encountering an invalid macro. -Enabled by default. -- `gfxd_stop_on_end`: Stop execution when encountering a `SPBranchList` or -`SPEndDisplayList`. Enabled by default. -- `gfxd_emit_dec_color`: Print color components as decimal instead of -hexadecimal. Disabled by default. -- `gfxd_emit_q_macro`: Print fixed-point conversion `q` macros for fixed-point -values. Disabled by default. -- `gfxd_emit_ext_macro`: Emit non-standard macros. Some commands are valid -(though possibly meaningless), but have no macros associated with them, such as -a standalone `G_RDPHALF_1`. When this feature is enabled, such a command will -produce a non-standard `gsDPHalf1` macro instead of a raw hexadecimal command. -Also enables some non-standard multi-packet texture loading macros. Disabled by -default. - ---- - -##### `void gfxd_udata_set(void *ptr)` -##### `void *gfxd_udata_get(void)` -Set or get a generic pointer that can be used to pass user-defined data in and -out of callback functions. - -## Execution -Decompilation is started using the `gfxd_execute` function. When gfxd is -executing (i.e. after `gfxd_execute` has been entered, and before it returns), -the general settings and the I/O settings should not be changed. - ---- - -##### `int gfxd_execute()` -Start executing gfxd with the current settings. For each macro, the macro -handler registered with `gfxd_macro_fn` is called. Execution ends when the -input ends, the macro handler returns non-zero, when an invalid macro is -encountered and `gfxd_stop_on_invalid` is enabled, or when `SPBranchList` or -`SPEndDisplayList` is encountered and `gfxd_stop_on_end` is enabled. If -execution ends due to an invalid macro, `-1` is returned. If execution ends -because the macro handler returns non-zero, the return value from the macro -handler is returned. Otherwise zero is returned. - -## Macro information -The following functions can be used to obtain information about the current -macro and its arguments. They should only be used in custom handlers and -callbacks from within `gfxd_execute`. If used elsewhere, their behavior is -undefined. - ---- - -##### `int gfxd_macro_offset()` -Returns the offset in the input data of the current macro. The offset starts -at zero when `gfxd_execute` is called. - ---- - -##### `int gfxd_macro_packets()` -Returns the number of `Gfx` packets within the current macro. - ---- - -##### `const void *gfxd_macro_data()` -Returns a pointer to the input data for the current macro. The data is not -byte-swapped. The data has a length of `sizeof(Gfx) * gfxd_macro_packets()`. - ---- - -##### `int gfxd_macro_id()` -Returns a number that uniquely identifies the current macro. The number will -be one of the constants in `gfxd.h`. - ---- - -##### `const char *gfxd_macro_name()` -Returns the name of the current macro. If the macro does not have a name (i.e. -it's invalid), null is returned. If a dynamic display list pointer has been -specified, the dynamic `g` version is returned. Otherwise the static `gs` -version is returned. The returned pointer is invalidated by a subsequent call -to `gfxd_macro_name`. - ---- - -##### `int gfxd_arg_count()` -Returns the number of arguments to the current macro, not including a dynamic -display list pointer if one has been specified. - ---- - -##### `int gfxd_arg_type(int arg_num)` -Returns a number that identifies the type of the argument with index `arg_num`. -The number will be one of the constants in `gfxd.h`. - ---- - -##### `const char *gfxd_arg_name(int arg_num)` -Returns the name of the argument with index `arg_num`. Argument names are not -canonical, nor are they needed for macro disassembly, but they can be useful -for informational and diagnostic purposes. - ---- - -##### `int gfxd_arg_fmt(int arg_num)` -Returns the data format of the argument with index `arg_num`. The return value -will be `gfxd_argfmt_i` for `int32_t`, `gfxd_argfmt_u` for `uint32_t`, or -`gfxd_argfmt_f` for `float`. When accessing the value of the argument with -`gfxd_arg_value`, the member with the corresponding type should be used. - ---- - -##### `const gfxd_value_t *gfxd_arg_value(int arg_num)` -Returns a pointer to the value of the argument with index `arg_num`. The value -is a union of type `gfxd_value_t` with the following layout; -``` -typedef union -{ - int32_t i; - uint32_t u; - float f; -} gfxd_value_t -``` - ---- - -##### `const gfxd_value_t *gfxd_value_by_type(int type, int idx)` -Returns a pointer to the value of the argument that is of `type`, and has order -`idx` in all arguments of that type. An `idx` of zero returns the first -argument that has the specified type. If there is no argument with the given -type and order, null is returned. - ---- - -##### `int gfxd_arg_valid(int arg_num)` -Returns non-zero if the argument with index `arg_num` is "valid", for some -definition of valid. An invalid argument generally means that the disassembler -found inconsistencies in the input data, or that the data can not be reproduced -by the current macro type. The argument still has a value that can be printed, -though the value is not guaranteed to make any sense. - -## Custom output -When the default handlers are overridden or extended, the custom handler -functions will want to do some output of their own. The following methods are -available for inserting custom text into the gfxd output. - ---- - -##### `int gfxd_write(const void *buf, int count)` -Insert `count` bytes from the buffer at `buf` into the output. The number of -characters written is returned. - ---- - -##### `int gfxd_puts(const char *str)` -Insert the null-terminated string at `str` into the output. The number of -characters written is returned. - ---- - -##### `int gfxd_printf(const char *fmt, ...)` -Insert the printf-formatted string described by `fmt` and additional arguments -into the output. Limited to 255 characters. The number of characters written is -returned. - ---- - -##### `int gfxd_print_value(int type, const gfxd_value_t *value)` -Insert the type-formatted value into the output. The type should be one of the -constants in `gfxd.h`. The number of characters written is returned. The -macro argument with index `n` can be printed with -`gfxd_print_value(gfxd_arg_type(n), gfxd_arg_value(n))`. diff --git a/ZAPDTR/lib/libgfxd/gbi.h b/ZAPDTR/lib/libgfxd/gbi.h deleted file mode 100644 index 69fa7f12e..000000000 --- a/ZAPDTR/lib/libgfxd/gbi.h +++ /dev/null @@ -1,3838 +0,0 @@ -/** - * gbi.h version 0.3.6 - * n64 graphics microcode interface library - * compatible with fast3d, f3dex, f3dex2, s2dex, and s2dex2 - * - * select a microcode with one of these preprocessor definitions; - * #define F3D_GBI - * for fast3d (selected automatically by default), or - * #define F3DEX_GBI - * for f3dex/s2dex, or - * #define F3DEX_GBI_2 - * for f3dex2/s2dex2 - * - * for early versions of fast3d and f3dex, also define the following; - * #define F3D_BETA - * - * ido incompatibilities; - * - use of c99 variadic macros - * - use of c99 fixed-width integer types - * - use of c99 designated initializers - * - use of c99 compound literals - * - use of c11 _Alignas - * - use of gnu c compound expressions - * - use of gnu c __typeof__ - * - * libultra incompatibilities; - * - many private, undocumented, or obsolete macros not commonly used by - * programmers are missing - * - many different implementation details that will produce matching gbi, - * but not matching code -**/ - -#ifndef N64_GBI_H -#define N64_GBI_H - -#include - -/* use fast3d by default */ -#if !defined(F3D_GBI) && !defined(F3DEX_GBI) && !defined(F3DEX_GBI_2) -# define F3D_GBI -#endif - -/* commands for fast3d and f3dex */ -#if defined(F3D_GBI) || defined(F3DEX_GBI) -# define G_SPNOOP 0x00 -# define G_MTX 0x01 -# define G_MOVEMEM 0x03 -# define G_VTX 0x04 -# define G_DL 0x06 -# if defined(F3D_BETA) -# define G_RDPHALF_2 0xB2 -# define G_RDPHALF_1 0xB3 -# define G_PERSPNORM 0xB4 -# else -# define G_RDPHALF_2 0xB3 -# define G_RDPHALF_1 0xB4 -# endif -# define G_LINE3D 0xB5 -# define G_CLEARGEOMETRYMODE 0xB6 -# define G_SETGEOMETRYMODE 0xB7 -# define G_ENDDL 0xB8 -# define G_SETOTHERMODE_L 0xB9 -# define G_SETOTHERMODE_H 0xBA -# define G_TEXTURE 0xBB -# define G_MOVEWORD 0xBC -# define G_POPMTX 0xBD -# define G_CULLDL 0xBE -# define G_TRI1 0xBF -# define G_NOOP 0xC0 -#endif - -/* commands for f3dex */ -#if defined(F3DEX_GBI) -# define G_LOAD_UCODE 0xAF -# define G_BRANCH_Z 0xB0 -# define G_TRI2 0xB1 -# if !defined(F3D_BETA) -# define G_MODIFYVTX 0xB2 -# endif -#endif - -/* commands for f3dex2 */ -#if defined(F3DEX_GBI_2) -# define G_NOOP 0x00 -# define G_VTX 0x01 -# define G_MODIFYVTX 0x02 -# define G_CULLDL 0x03 -# define G_BRANCH_Z 0x04 -# define G_TRI1 0x05 -# define G_TRI2 0x06 -# define G_QUAD 0x07 -# define G_LINE3D 0x08 -# define G_SPECIAL_3 0xD3 -# define G_SPECIAL_2 0xD4 -# define G_SPECIAL_1 0xD5 -# define G_DMA_IO 0xD6 -# define G_TEXTURE 0xD7 -# define G_POPMTX 0xD8 -# define G_GEOMETRYMODE 0xD9 -# define G_MTX 0xDA -# define G_MOVEWORD 0xDB -# define G_MOVEMEM 0xDC -# define G_LOAD_UCODE 0xDD -# define G_DL 0xDE -# define G_ENDDL 0xDF -# define G_SPNOOP 0xE0 -# define G_RDPHALF_1 0xE1 -# define G_SETOTHERMODE_L 0xE2 -# define G_SETOTHERMODE_H 0xE3 -# define G_RDPHALF_2 0xF1 -#endif - -/* rdp commands */ -#define G_TEXRECT 0xE4 -#define G_TEXRECTFLIP 0xE5 -#define G_RDPLOADSYNC 0xE6 -#define G_RDPPIPESYNC 0xE7 -#define G_RDPTILESYNC 0xE8 -#define G_RDPFULLSYNC 0xE9 -#define G_SETKEYGB 0xEA -#define G_SETKEYR 0xEB -#define G_SETCONVERT 0xEC -#define G_SETSCISSOR 0xED -#define G_SETPRIMDEPTH 0xEE -#define G_RDPSETOTHERMODE 0xEF -#define G_LOADTLUT 0xF0 -#define G_SETTILESIZE 0xF2 -#define G_LOADBLOCK 0xF3 -#define G_LOADTILE 0xF4 -#define G_SETTILE 0xF5 -#define G_FILLRECT 0xF6 -#define G_SETFILLCOLOR 0xF7 -#define G_SETFOGCOLOR 0xF8 -#define G_SETBLENDCOLOR 0xF9 -#define G_SETPRIMCOLOR 0xFA -#define G_SETENVCOLOR 0xFB -#define G_SETCOMBINE 0xFC -#define G_SETTIMG 0xFD -#define G_SETZIMG 0xFE -#define G_SETCIMG 0xFF - -/* commands for s2dex */ -#if defined(F3DEX_GBI) -# define G_BG_1CYC 0x01 -# define G_BG_COPY 0x02 -# define G_OBJ_RECTANGLE 0x03 -# define G_OBJ_SPRITE 0x04 -# define G_OBJ_MOVEMEM 0x05 -# define G_SELECT_DL 0xB0 -# define G_OBJ_RENDERMODE 0xB1 -# define G_OBJ_RECTANGLE_R 0xB2 -# define G_OBJ_LOADTXTR 0xC1 -# define G_OBJ_LDTX_SPRITE 0xC2 -# define G_OBJ_LDTX_RECT 0xC3 -# define G_OBJ_LDTX_RECT_R 0xC4 -#endif - -/* commands for s2dex2 */ -#if defined(F3DEX_GBI_2) -# define G_OBJ_RECTANGLE 0x01 -# define G_OBJ_SPRITE 0x02 -# define G_SELECT_DL 0x04 -# define G_OBJ_LOADTXTR 0x05 -# define G_OBJ_LDTX_SPRITE 0x06 -# define G_OBJ_LDTX_RECT 0x07 -# define G_OBJ_LDTX_RECT_R 0x08 -# define G_BG_1CYC 0x09 -# define G_BG_COPY 0x0A -# define G_OBJ_RENDERMODE 0x0B -# define G_OBJ_RECTANGLE_R 0xDA -# define G_OBJ_MOVEMEM 0xDC -#endif - -/* commands for s2dex and s2dex2 */ -#if defined(F3DEX_GBI) || defined(F3DEX_GBI_2) -# define G_RDPHALF_0 0xE4 -#endif - -/* image formats */ -#define G_IM_FMT_RGBA 0 -#define G_IM_FMT_YUV 1 -#define G_IM_FMT_CI 2 -#define G_IM_FMT_IA 3 -#define G_IM_FMT_I 4 -#define G_IM_SIZ_4b 0 -#define G_IM_SIZ_8b 1 -#define G_IM_SIZ_16b 2 -#define G_IM_SIZ_32b 3 - -/* texture settings */ -#define G_TX_NOMIRROR (gI_(0b0) << 0) -#define G_TX_MIRROR (gI_(0b1) << 0) -#define G_TX_WRAP (gI_(0b0) << 1) -#define G_TX_CLAMP (gI_(0b1) << 1) -#define G_TX_NOMASK gI_(0) -#define G_TX_NOLOD gI_(0) -#define G_OFF gI_(0) -#define G_ON gI_(1) - -/* tile indices */ -#define G_TX_LOADTILE 7 -#define G_TX_RENDERTILE 0 - -/* loadblock constants */ -#define G_TX_DXT_FRAC 11 -#define G_TX_LDBLK_MAX_TXL 2047 - -/* geometry mode */ -#define G_ZBUFFER (gI_(0b1) << 0) -#define G_SHADE (gI_(0b1) << 2) -#define G_CULL_BOTH (G_CULL_FRONT | G_CULL_BACK) -#define G_FOG (gI_(0b1) << 16) -#define G_LIGHTING (gI_(0b1) << 17) -#define G_TEXTURE_GEN (gI_(0b1) << 18) -#define G_TEXTURE_GEN_LINEAR (gI_(0b1) << 19) -#define G_LOD (gI_(0b1) << 20) - -/* geometry mode for fast3d */ -#if defined(F3D_GBI) -# define G_CLIPPING (gI_(0b0) << 0) -#endif - -/* geometry mode for fast3d and f3dex */ -#if defined(F3D_GBI) || defined(F3DEX_GBI) -# define G_TEXTURE_ENABLE (gI_(0b1) << 1) -# define G_SHADING_SMOOTH (gI_(0b1) << 9) -# define G_CULL_FRONT (gI_(0b1) << 12) -# define G_CULL_BACK (gI_(0b1) << 13) -#endif - -/* geometry mode for f3dex and f3dex2 */ -#if defined(F3DEX_GBI) || defined(F3DEX_GBI_2) -# define G_CLIPPING (gI_(0b1) << 23) -#endif - -/* geometry mode for f3dex2 */ -#if defined(F3DEX_GBI_2) -# define G_TEXTURE_ENABLE (gI_(0b0) << 0) -# define G_CULL_FRONT (gI_(0b1) << 9) -# define G_CULL_BACK (gI_(0b1) << 10) -# define G_SHADING_SMOOTH (gI_(0b1) << 21) -#endif - -/* othermode lo */ -#define G_MDSFT_ALPHACOMPARE 0 -#define G_MDSFT_ZSRCSEL 2 -#define G_MDSFT_RENDERMODE 3 -#define G_MDSFT_BLENDER 16 -#define G_MDSIZ_ALPHACOMPARE 2 -#define G_MDSIZ_ZSRCSEL 1 -#define G_MDSIZ_RENDERMODE 29 -#define G_MDSIZ_BLENDER 13 - -#define G_AC_NONE (gI_(0b00) << G_MDSFT_ALPHACOMPARE) -#define G_AC_THRESHOLD (gI_(0b01) << G_MDSFT_ALPHACOMPARE) -#define G_AC_DITHER (gI_(0b11) << G_MDSFT_ALPHACOMPARE) -#define G_ZS_PIXEL (gI_(0b0) << G_MDSFT_ZSRCSEL) -#define G_ZS_PRIM (gI_(0b1) << G_MDSFT_ZSRCSEL) -#define AA_EN (gI_(0b1) << (G_MDSFT_RENDERMODE + 0)) -#define Z_CMP (gI_(0b1) << (G_MDSFT_RENDERMODE + 1)) -#define Z_UPD (gI_(0b1) << (G_MDSFT_RENDERMODE + 2)) -#define IM_RD (gI_(0b1) << (G_MDSFT_RENDERMODE + 3)) -#define CLR_ON_CVG (gI_(0b1) << (G_MDSFT_RENDERMODE + 4)) -#define CVG_DST_CLAMP (gI_(0b00) << (G_MDSFT_RENDERMODE + 5)) -#define CVG_DST_WRAP (gI_(0b01) << (G_MDSFT_RENDERMODE + 5)) -#define CVG_DST_FULL (gI_(0b10) << (G_MDSFT_RENDERMODE + 5)) -#define CVG_DST_SAVE (gI_(0b11) << (G_MDSFT_RENDERMODE + 5)) -#define ZMODE_OPA (gI_(0b00) << (G_MDSFT_RENDERMODE + 7)) -#define ZMODE_INTER (gI_(0b01) << (G_MDSFT_RENDERMODE + 7)) -#define ZMODE_XLU (gI_(0b10) << (G_MDSFT_RENDERMODE + 7)) -#define ZMODE_DEC (gI_(0b11) << (G_MDSFT_RENDERMODE + 7)) -#define CVG_X_ALPHA (gI_(0b1) << (G_MDSFT_RENDERMODE + 9)) -#define ALPHA_CVG_SEL (gI_(0b1) << (G_MDSFT_RENDERMODE + 10)) -#define FORCE_BL (gI_(0b1) << (G_MDSFT_RENDERMODE + 11)) - -#define G_BL_1MA gI_(0b00) -#define G_BL_1 gI_(0b10) -#define G_BL_0 gI_(0b11) -#define G_BL_CLR_IN gI_(0b00) -#define G_BL_CLR_MEM gI_(0b01) -#define G_BL_CLR_BL gI_(0b10) -#define G_BL_CLR_FOG gI_(0b11) -#define G_BL_A_IN gI_(0b00) -#define G_BL_A_FOG gI_(0b01) -#define G_BL_A_MEM gI_(0b01) -#define G_BL_A_SHADE gI_(0b10) - -#define GBL_c1(p, a, m, b) \ - ( \ - gF_(p, 2, 30) | \ - gF_(a, 2, 26) | \ - gF_(m, 2, 22) | \ - gF_(b, 2, 18) \ - ) -#define GBL_c2(p, a, m, b) \ - ( \ - gF_(p, 2, 28) | \ - gF_(a, 2, 24) | \ - gF_(m, 2, 20) | \ - gF_(b, 2, 16) \ - ) - -/* render modes */ -#define G_RM_OPA_SURF \ - ( \ - CVG_DST_CLAMP | ZMODE_OPA | FORCE_BL | \ - GBL_c1(G_BL_CLR_IN, G_BL_0, G_BL_CLR_IN, G_BL_1) \ - ) -#define G_RM_OPA_SURF2 \ - ( \ - CVG_DST_CLAMP | ZMODE_OPA | FORCE_BL | \ - GBL_c2(G_BL_CLR_IN, G_BL_0, G_BL_CLR_IN, G_BL_1) \ - ) -#define G_RM_AA_OPA_SURF \ - ( \ - AA_EN | IM_RD | CVG_DST_CLAMP | ZMODE_OPA | ALPHA_CVG_SEL | \ - GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) \ - ) -#define G_RM_AA_OPA_SURF2 \ - ( \ - AA_EN | IM_RD | CVG_DST_CLAMP | ZMODE_OPA | ALPHA_CVG_SEL | \ - GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) \ - ) -#define G_RM_RA_OPA_SURF \ - ( \ - AA_EN | CVG_DST_CLAMP | ZMODE_OPA | ALPHA_CVG_SEL | \ - GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) \ - ) -#define G_RM_RA_OPA_SURF2 \ - ( \ - AA_EN | CVG_DST_CLAMP | ZMODE_OPA | ALPHA_CVG_SEL | \ - GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) \ - ) -#define G_RM_ZB_OPA_SURF \ - ( \ - Z_CMP | Z_UPD | CVG_DST_FULL | ZMODE_OPA | ALPHA_CVG_SEL | \ - GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) \ - ) -#define G_RM_ZB_OPA_SURF2 \ - ( \ - Z_CMP | Z_UPD | CVG_DST_FULL | ZMODE_OPA | ALPHA_CVG_SEL | \ - GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) \ - ) -#define G_RM_AA_ZB_OPA_SURF \ - ( \ - AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | ZMODE_OPA | \ - ALPHA_CVG_SEL | \ - GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) \ - ) -#define G_RM_AA_ZB_OPA_SURF2 \ - ( \ - AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | ZMODE_OPA | \ - ALPHA_CVG_SEL | \ - GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) \ - ) -#define G_RM_RA_ZB_OPA_SURF \ - ( \ - AA_EN | Z_CMP | Z_UPD | CVG_DST_CLAMP | ZMODE_OPA | \ - ALPHA_CVG_SEL | \ - GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) \ - ) -#define G_RM_RA_ZB_OPA_SURF2 \ - ( \ - AA_EN | Z_CMP | Z_UPD | CVG_DST_CLAMP | ZMODE_OPA | \ - ALPHA_CVG_SEL | \ - GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) \ - ) - -#define G_RM_XLU_SURF \ - ( \ - IM_RD | CVG_DST_FULL | ZMODE_OPA | FORCE_BL | \ - GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) \ - ) -#define G_RM_XLU_SURF2 \ - ( \ - IM_RD | CVG_DST_FULL | ZMODE_OPA | FORCE_BL | \ - GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) \ - ) -#define G_RM_AA_XLU_SURF \ - ( \ - AA_EN | IM_RD | CLR_ON_CVG | CVG_DST_WRAP | ZMODE_OPA | \ - FORCE_BL | \ - GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) \ - ) -#define G_RM_AA_XLU_SURF2 \ - ( \ - AA_EN | IM_RD | CLR_ON_CVG | CVG_DST_WRAP | ZMODE_OPA | \ - FORCE_BL | \ - GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) \ - ) -#define G_RM_ZB_XLU_SURF \ - ( \ - Z_CMP | IM_RD | CVG_DST_FULL | ZMODE_XLU | FORCE_BL | \ - GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) \ - ) -#define G_RM_ZB_XLU_SURF2 \ - ( \ - Z_CMP | IM_RD | CVG_DST_FULL | ZMODE_XLU | FORCE_BL | \ - GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) \ - ) -#define G_RM_AA_ZB_XLU_SURF \ - ( \ - AA_EN | Z_CMP | IM_RD | CLR_ON_CVG | CVG_DST_WRAP | \ - ZMODE_XLU | FORCE_BL | \ - GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) \ - ) -#define G_RM_AA_ZB_XLU_SURF2 \ - ( \ - AA_EN | Z_CMP | IM_RD | CLR_ON_CVG | CVG_DST_WRAP | \ - ZMODE_XLU | FORCE_BL | \ - GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) \ - ) - -#define G_RM_ZB_OPA_DECAL \ - ( \ - Z_CMP | CVG_DST_FULL | ZMODE_DEC | ALPHA_CVG_SEL | \ - GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) \ - ) -#define G_RM_ZB_OPA_DECAL2 \ - ( \ - Z_CMP | CVG_DST_FULL | ZMODE_DEC | ALPHA_CVG_SEL | \ - GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) \ - ) -#define G_RM_AA_ZB_OPA_DECAL \ - ( \ - AA_EN | Z_CMP | IM_RD | CVG_DST_WRAP | ZMODE_DEC | \ - ALPHA_CVG_SEL | \ - GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) \ - ) -#define G_RM_AA_ZB_OPA_DECAL2 \ - ( \ - AA_EN | Z_CMP | IM_RD | CVG_DST_WRAP | ZMODE_DEC | \ - ALPHA_CVG_SEL | \ - GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) \ - ) -#define G_RM_RA_ZB_OPA_DECAL \ - ( \ - AA_EN | Z_CMP | CVG_DST_WRAP | ZMODE_DEC | ALPHA_CVG_SEL | \ - GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) \ - ) -#define G_RM_RA_ZB_OPA_DECAL2 \ - ( \ - AA_EN | Z_CMP | CVG_DST_WRAP | ZMODE_DEC | ALPHA_CVG_SEL | \ - GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) \ - ) - -#define G_RM_ZB_XLU_DECAL \ - ( \ - Z_CMP | IM_RD | CVG_DST_FULL | ZMODE_DEC | FORCE_BL | \ - GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) \ - ) -#define G_RM_ZB_XLU_DECAL2 \ - ( \ - Z_CMP | IM_RD | CVG_DST_FULL | ZMODE_DEC | FORCE_BL | \ - GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) \ - ) -#define G_RM_AA_ZB_XLU_DECAL \ - ( \ - AA_EN | Z_CMP | IM_RD | CLR_ON_CVG | CVG_DST_WRAP | \ - ZMODE_DEC | FORCE_BL | \ - GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) \ - ) -#define G_RM_AA_ZB_XLU_DECAL2 \ - ( \ - AA_EN | Z_CMP | IM_RD | CLR_ON_CVG | CVG_DST_WRAP | \ - ZMODE_DEC | FORCE_BL | \ - GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) \ - ) - -#define G_RM_AA_ZB_OPA_INTER \ - ( \ - AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | ZMODE_INTER | \ - ALPHA_CVG_SEL | \ - GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) \ - ) -#define G_RM_AA_ZB_OPA_INTER2 \ - ( \ - AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | ZMODE_INTER | \ - ALPHA_CVG_SEL | \ - GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) \ - ) -#define G_RM_RA_ZB_OPA_INTER \ - ( \ - AA_EN | Z_CMP | Z_UPD | CVG_DST_CLAMP | ZMODE_INTER | \ - ALPHA_CVG_SEL | \ - GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) \ - ) -#define G_RM_RA_ZB_OPA_INTER2 \ - ( \ - AA_EN | Z_CMP | Z_UPD | CVG_DST_CLAMP | ZMODE_INTER | \ - ALPHA_CVG_SEL | \ - GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) \ - ) - -#define G_RM_AA_ZB_XLU_INTER \ - ( \ - AA_EN | Z_CMP | IM_RD | CLR_ON_CVG | CVG_DST_WRAP | \ - ZMODE_INTER | FORCE_BL | \ - GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) \ - ) -#define G_RM_AA_ZB_XLU_INTER2 \ - ( \ - AA_EN | Z_CMP | IM_RD | CLR_ON_CVG | CVG_DST_WRAP | \ - ZMODE_INTER | FORCE_BL | \ - GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) \ - ) - -#define G_RM_AA_XLU_LINE \ - ( \ - AA_EN | IM_RD | CVG_DST_CLAMP | ZMODE_OPA | CVG_X_ALPHA | \ - ALPHA_CVG_SEL | FORCE_BL | \ - GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) \ - ) -#define G_RM_AA_XLU_LINE2 \ - ( \ - AA_EN | IM_RD | CVG_DST_CLAMP | ZMODE_OPA | CVG_X_ALPHA | \ - ALPHA_CVG_SEL | FORCE_BL | \ - GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) \ - ) -#define G_RM_AA_ZB_XLU_LINE \ - ( \ - AA_EN | Z_CMP | IM_RD | CVG_DST_CLAMP | ZMODE_XLU | \ - CVG_X_ALPHA | ALPHA_CVG_SEL | FORCE_BL | \ - GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) \ - ) -#define G_RM_AA_ZB_XLU_LINE2 \ - ( \ - AA_EN | Z_CMP | IM_RD | CVG_DST_CLAMP | ZMODE_XLU | \ - CVG_X_ALPHA | ALPHA_CVG_SEL | FORCE_BL | \ - GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) \ - ) - -#define G_RM_AA_DEC_LINE \ - ( \ - AA_EN | IM_RD | CVG_DST_FULL | ZMODE_OPA | CVG_X_ALPHA | \ - ALPHA_CVG_SEL | FORCE_BL | \ - GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) \ - ) -#define G_RM_AA_DEC_LINE2 \ - ( \ - AA_EN | IM_RD | CVG_DST_FULL | ZMODE_OPA | CVG_X_ALPHA | \ - ALPHA_CVG_SEL | FORCE_BL | \ - GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) \ - ) -#define G_RM_AA_ZB_DEC_LINE \ - ( \ - AA_EN | Z_CMP | IM_RD | CVG_DST_SAVE | ZMODE_DEC | \ - CVG_X_ALPHA | ALPHA_CVG_SEL | FORCE_BL | \ - GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) \ - ) -#define G_RM_AA_ZB_DEC_LINE2 \ - ( \ - AA_EN | Z_CMP | IM_RD | CVG_DST_SAVE | ZMODE_DEC | \ - CVG_X_ALPHA | ALPHA_CVG_SEL | FORCE_BL | \ - GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) \ - ) - - -#define G_RM_TEX_EDGE \ - ( \ - AA_EN | CVG_DST_CLAMP | ZMODE_OPA | CVG_X_ALPHA | \ - ALPHA_CVG_SEL | FORCE_BL | \ - GBL_c1(G_BL_CLR_IN, G_BL_0, G_BL_CLR_IN, G_BL_1) \ - ) -#define G_RM_TEX_EDGE2 \ - ( \ - AA_EN | CVG_DST_CLAMP | ZMODE_OPA | CVG_X_ALPHA | \ - ALPHA_CVG_SEL | FORCE_BL | \ - GBL_c2(G_BL_CLR_IN, G_BL_0, G_BL_CLR_IN, G_BL_1) \ - ) -#define G_RM_AA_TEX_EDGE \ - ( \ - AA_EN | IM_RD | CVG_DST_CLAMP | ZMODE_OPA | CVG_X_ALPHA | \ - ALPHA_CVG_SEL | \ - GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) \ - ) -#define G_RM_AA_TEX_EDGE2 \ - ( \ - AA_EN | IM_RD | CVG_DST_CLAMP | ZMODE_OPA | CVG_X_ALPHA | \ - ALPHA_CVG_SEL | \ - GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) \ - ) -#define G_RM_AA_ZB_TEX_EDGE \ - ( \ - AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | ZMODE_OPA | \ - CVG_X_ALPHA | ALPHA_CVG_SEL | \ - GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) \ - ) -#define G_RM_AA_ZB_TEX_EDGE2 \ - ( \ - AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | ZMODE_OPA | \ - CVG_X_ALPHA | ALPHA_CVG_SEL | \ - GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) \ - ) - -#define G_RM_AA_ZB_TEX_INTER \ - ( \ - AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | ZMODE_INTER | \ - CVG_X_ALPHA | ALPHA_CVG_SEL | \ - GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) \ - ) -#define G_RM_AA_ZB_TEX_INTER2 \ - ( \ - AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | ZMODE_INTER | \ - CVG_X_ALPHA | ALPHA_CVG_SEL | \ - GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) \ - ) - -#define G_RM_AA_SUB_SURF \ - ( \ - AA_EN | IM_RD | CVG_DST_FULL | ZMODE_OPA | ALPHA_CVG_SEL | \ - GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) \ - ) -#define G_RM_AA_SUB_SURF2 \ - ( \ - AA_EN | IM_RD | CVG_DST_FULL | ZMODE_OPA | ALPHA_CVG_SEL | \ - GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) \ - ) -#define G_RM_AA_ZB_SUB_SURF \ - ( \ - AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_FULL | ZMODE_OPA | \ - ALPHA_CVG_SEL | \ - GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) \ - ) -#define G_RM_AA_ZB_SUB_SURF2 \ - ( \ - AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_FULL | ZMODE_OPA | \ - ALPHA_CVG_SEL | \ - GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) \ - ) - -#define G_RM_PCL_SURF \ - ( \ - G_AC_DITHER | CVG_DST_FULL | ZMODE_OPA | FORCE_BL | \ - GBL_c1(G_BL_CLR_IN, G_BL_0, G_BL_CLR_IN, G_BL_1) \ - ) -#define G_RM_PCL_SURF2 \ - ( \ - G_AC_DITHER | CVG_DST_FULL | ZMODE_OPA | FORCE_BL | \ - GBL_c2(G_BL_CLR_IN, G_BL_0, G_BL_CLR_IN, G_BL_1) \ - ) -#define G_RM_AA_PCL_SURF \ - ( \ - G_AC_DITHER | AA_EN | IM_RD | CVG_DST_CLAMP | ZMODE_OPA | \ - GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) \ - ) -#define G_RM_AA_PCL_SURF2 \ - ( \ - G_AC_DITHER | AA_EN | IM_RD | CVG_DST_CLAMP | ZMODE_OPA | \ - GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) \ - ) -#define G_RM_ZB_PCL_SURF \ - ( \ - G_AC_DITHER | Z_CMP | Z_UPD | CVG_DST_FULL | ZMODE_OPA | \ - GBL_c1(G_BL_CLR_IN, G_BL_0, G_BL_CLR_IN, G_BL_1) \ - ) -#define G_RM_ZB_PCL_SURF2 \ - ( \ - G_AC_DITHER | Z_CMP | Z_UPD | CVG_DST_FULL | ZMODE_OPA | \ - GBL_c2(G_BL_CLR_IN, G_BL_0, G_BL_CLR_IN, G_BL_1) \ - ) -#define G_RM_AA_ZB_PCL_SURF \ - ( \ - G_AC_DITHER | AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | \ - ZMODE_OPA | \ - GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) \ - ) -#define G_RM_AA_ZB_PCL_SURF2 \ - ( \ - G_AC_DITHER | AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | \ - ZMODE_OPA | \ - GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) \ - ) - -#define G_RM_AA_OPA_TERR \ - ( \ - AA_EN | IM_RD | CVG_DST_CLAMP | ZMODE_OPA | ALPHA_CVG_SEL | \ - GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) \ - ) -#define G_RM_AA_OPA_TERR2 \ - ( \ - AA_EN | IM_RD | CVG_DST_CLAMP | ZMODE_OPA | ALPHA_CVG_SEL | \ - GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) \ - ) -#define G_RM_AA_ZB_OPA_TERR \ - ( \ - AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | ZMODE_OPA | \ - ALPHA_CVG_SEL | \ - GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) \ - ) -#define G_RM_AA_ZB_OPA_TERR2 \ - ( \ - AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | ZMODE_OPA | \ - ALPHA_CVG_SEL | \ - GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) \ - ) - -#define G_RM_AA_TEX_TERR \ - ( \ - AA_EN | IM_RD | CVG_DST_CLAMP | ZMODE_OPA | CVG_X_ALPHA | \ - ALPHA_CVG_SEL | \ - GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) \ - ) -#define G_RM_AA_TEX_TERR2 \ - ( \ - AA_EN | IM_RD | CVG_DST_CLAMP | ZMODE_OPA | CVG_X_ALPHA | \ - ALPHA_CVG_SEL | \ - GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) \ - ) -#define G_RM_AA_ZB_TEX_TERR \ - ( \ - AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | ZMODE_OPA | \ - CVG_X_ALPHA | ALPHA_CVG_SEL | \ - GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) \ - ) -#define G_RM_AA_ZB_TEX_TERR2 \ - ( \ - AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | ZMODE_OPA | \ - CVG_X_ALPHA | ALPHA_CVG_SEL | \ - GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) \ - ) - -#define G_RM_AA_SUB_TERR \ - ( \ - AA_EN | IM_RD | CVG_DST_FULL | ZMODE_OPA | ALPHA_CVG_SEL | \ - GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) \ - ) -#define G_RM_AA_SUB_TERR2 \ - ( \ - AA_EN | IM_RD | CVG_DST_FULL | ZMODE_OPA | ALPHA_CVG_SEL | \ - GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) \ - ) -#define G_RM_AA_ZB_SUB_TERR \ - ( \ - AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_FULL | ZMODE_OPA | \ - ALPHA_CVG_SEL | \ - GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) \ - ) -#define G_RM_AA_ZB_SUB_TERR2 \ - ( \ - AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_FULL | ZMODE_OPA | \ - ALPHA_CVG_SEL | \ - GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) \ - ) - -#define G_RM_CLD_SURF \ - ( \ - IM_RD | CVG_DST_SAVE | ZMODE_OPA | FORCE_BL | \ - GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) \ - ) -#define G_RM_CLD_SURF2 \ - ( \ - IM_RD | CVG_DST_SAVE | ZMODE_OPA | FORCE_BL | \ - GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) \ - ) -#define G_RM_ZB_CLD_SURF \ - ( \ - Z_CMP | IM_RD | CVG_DST_SAVE | ZMODE_XLU | FORCE_BL | \ - GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) \ - ) -#define G_RM_ZB_CLD_SURF2 \ - ( \ - Z_CMP | IM_RD | CVG_DST_SAVE | ZMODE_XLU | FORCE_BL | \ - GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) \ - ) - -#define G_RM_ZB_OVL_SURF \ - ( \ - Z_CMP | IM_RD | CVG_DST_SAVE | ZMODE_DEC | FORCE_BL | \ - GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) \ - ) -#define G_RM_ZB_OVL_SURF2 \ - ( \ - Z_CMP | IM_RD | CVG_DST_SAVE | ZMODE_DEC | FORCE_BL | \ - GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) \ - ) - -#define G_RM_ADD \ - ( \ - IM_RD | CVG_DST_SAVE | ZMODE_OPA | FORCE_BL | \ - GBL_c1(G_BL_CLR_IN, G_BL_A_FOG, G_BL_CLR_MEM, G_BL_1) \ - ) -#define G_RM_ADD2 \ - ( \ - IM_RD | CVG_DST_SAVE | ZMODE_OPA | FORCE_BL | \ - GBL_c2(G_BL_CLR_IN, G_BL_A_FOG, G_BL_CLR_MEM, G_BL_1) \ - ) - -#define G_RM_FOG_SHADE_A \ - GBL_c1(G_BL_CLR_FOG, G_BL_A_SHADE, G_BL_CLR_IN, G_BL_1MA) - -#define G_RM_FOG_PRIM_A \ - GBL_c1(G_BL_CLR_FOG, G_BL_A_FOG, G_BL_CLR_IN, G_BL_1MA) - -#define G_RM_PASS \ - GBL_c1(G_BL_CLR_IN, G_BL_0, G_BL_CLR_IN, G_BL_1) - -#define G_RM_VISCVG \ - ( \ - IM_RD | FORCE_BL | \ - GBL_c1(G_BL_CLR_IN, G_BL_0, G_BL_CLR_BL, G_BL_A_MEM) \ - ) -#define G_RM_VISCVG2 \ - ( \ - IM_RD | FORCE_BL | \ - GBL_c2(G_BL_CLR_IN, G_BL_0, G_BL_CLR_BL, G_BL_A_MEM) \ - ) - -#define G_RM_OPA_CI \ - ( \ - CVG_DST_CLAMP | ZMODE_OPA | \ - GBL_c1(G_BL_CLR_IN, G_BL_0, G_BL_CLR_IN, G_BL_1) \ - ) -#define G_RM_OPA_CI2 \ - ( \ - CVG_DST_CLAMP | ZMODE_OPA | \ - GBL_c2(G_BL_CLR_IN, G_BL_0, G_BL_CLR_IN, G_BL_1) \ - ) - -#define G_RM_NOOP GBL_c1(0, 0, 0, 0) -#define G_RM_NOOP2 GBL_c2(0, 0, 0, 0) - -#define G_RM_SPRITE G_RM_OPA_SURF -#define G_RM_SPRITE2 G_RM_OPA_SURF2 -#define G_RM_RA_SPRITE \ - ( \ - AA_EN | CVG_DST_CLAMP | ZMODE_OPA | CVG_X_ALPHA | \ - ALPHA_CVG_SEL | \ - GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) \ - ) -#define G_RM_RA_SPRITE2 \ - ( \ - AA_EN | CVG_DST_CLAMP | ZMODE_OPA | CVG_X_ALPHA | \ - ALPHA_CVG_SEL | \ - GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) \ - ) -#define G_RM_AA_SPRITE G_RM_AA_TEX_TERR -#define G_RM_AA_SPRITE2 G_RM_AA_TEX_TERR2 -#define G_RM_XLU_SPRITE G_RM_XLU_SURF -#define G_RM_XLU_SPRITE2 G_RM_XLU_SURF2 -#define G_RM_AA_XLU_SPRITE G_RM_AA_XLU_SURF -#define G_RM_AA_XLU_SPRITE2 G_RM_AA_XLU_SURF2 - -#define G_OBJRM_NOTXCLAMP (gI_(0b1) << 0) -#define G_OBJRM_XLU (gI_(0b1) << 1) -#define G_OBJRM_ANTIALIAS (gI_(0b1) << 2) -#define G_OBJRM_BILERP (gI_(0b1) << 3) -#define G_OBJRM_SHRINKSIZE_1 (gI_(0b1) << 4) -#define G_OBJRM_SHRINKSIZE_2 (gI_(0b1) << 5) -#define G_OBJRM_WIDEN (gI_(0b1) << 6) - -/* othermode hi */ -#define G_MDSFT_ALPHADITHER 4 -#define G_MDSFT_RGBDITHER 6 -#define G_MDSFT_COMBKEY 8 -#define G_MDSFT_TEXTCONV 9 -#define G_MDSFT_TEXTFILT 12 -#define G_MDSFT_TEXTLUT 14 -#define G_MDSFT_TEXTLOD 16 -#define G_MDSFT_TEXTDETAIL 17 -#define G_MDSFT_TEXTPERSP 19 -#define G_MDSFT_CYCLETYPE 20 -#define G_MDSFT_PIPELINE 23 -#define G_MDSIZ_ALPHADITHER 2 -#define G_MDSIZ_RGBDITHER 2 -#define G_MDSIZ_COMBKEY 1 -#define G_MDSIZ_TEXTCONV 3 -#define G_MDSIZ_TEXTFILT 2 -#define G_MDSIZ_TEXTLUT 2 -#define G_MDSIZ_TEXTLOD 1 -#define G_MDSIZ_TEXTDETAIL 2 -#define G_MDSIZ_TEXTPERSP 1 -#define G_MDSIZ_CYCLETYPE 2 -#define G_MDSIZ_PIPELINE 1 - -#define G_AD_PATTERN (gI_(0b00) << G_MDSFT_ALPHADITHER) -#define G_AD_NOTPATTERN (gI_(0b01) << G_MDSFT_ALPHADITHER) -#define G_AD_NOISE (gI_(0b10) << G_MDSFT_ALPHADITHER) -#define G_AD_DISABLE (gI_(0b11) << G_MDSFT_ALPHADITHER) -#define G_CD_MAGICSQ (gI_(0b00) << G_MDSFT_RGBDITHER) -#define G_CD_BAYER (gI_(0b01) << G_MDSFT_RGBDITHER) -#define G_CD_NOISE (gI_(0b10) << G_MDSFT_RGBDITHER) -#define G_CD_DISABLE (gI_(0b11) << G_MDSFT_RGBDITHER) -#define G_CD_ENABLE (gI_(0b10) << G_MDSFT_RGBDITHER) -#define G_CK_NONE (gI_(0b0) << G_MDSFT_COMBKEY) -#define G_CK_KEY (gI_(0b1) << G_MDSFT_COMBKEY) -#define G_TC_CONV (gI_(0b000) << G_MDSFT_TEXTCONV) -#define G_TC_FILTCONV (gI_(0b101) << G_MDSFT_TEXTCONV) -#define G_TC_FILT (gI_(0b110) << G_MDSFT_TEXTCONV) -#define G_TF_POINT (gI_(0b00) << G_MDSFT_TEXTFILT) -#define G_TF_BILERP (gI_(0b10) << G_MDSFT_TEXTFILT) -#define G_TF_AVERAGE (gI_(0b11) << G_MDSFT_TEXTFILT) -#define G_TT_NONE (gI_(0b00) << G_MDSFT_TEXTLUT) -#define G_TT_RGBA16 (gI_(0b10) << G_MDSFT_TEXTLUT) -#define G_TT_IA16 (gI_(0b11) << G_MDSFT_TEXTLUT) -#define G_TL_TILE (gI_(0b0) << G_MDSFT_TEXTLOD) -#define G_TL_LOD (gI_(0b1) << G_MDSFT_TEXTLOD) -#define G_TD_CLAMP (gI_(0b00) << G_MDSFT_TEXTDETAIL) -#define G_TD_SHARPEN (gI_(0b01) << G_MDSFT_TEXTDETAIL) -#define G_TD_DETAIL (gI_(0b10) << G_MDSFT_TEXTDETAIL) -#define G_TP_NONE (gI_(0b0) << G_MDSFT_TEXTPERSP) -#define G_TP_PERSP (gI_(0b1) << G_MDSFT_TEXTPERSP) -#define G_CYC_1CYCLE (gI_(0b00) << G_MDSFT_CYCLETYPE) -#define G_CYC_2CYCLE (gI_(0b01) << G_MDSFT_CYCLETYPE) -#define G_CYC_COPY (gI_(0b10) << G_MDSFT_CYCLETYPE) -#define G_CYC_FILL (gI_(0b11) << G_MDSFT_CYCLETYPE) -#define G_PM_NPRIMITIVE (gI_(0b0) << G_MDSFT_PIPELINE) -#define G_PM_1PRIMITIVE (gI_(0b1) << G_MDSFT_PIPELINE) - -/* color conversion constants */ -#define G_CV_K0 (175) -#define G_CV_K1 (-43) -#define G_CV_K2 (-89) -#define G_CV_K3 (222) -#define G_CV_K4 (114) -#define G_CV_K5 (42) - -/* color combiner */ -#define G_CCMUX_COMBINED 0 -#define G_CCMUX_TEXEL0 1 -#define G_CCMUX_TEXEL1 2 -#define G_CCMUX_PRIMITIVE 3 -#define G_CCMUX_SHADE 4 -#define G_CCMUX_ENVIRONMENT 5 -#define G_CCMUX_1 6 -#define G_CCMUX_NOISE 7 -#define G_CCMUX_0 31 -#define G_CCMUX_CENTER 6 -#define G_CCMUX_K4 7 -#define G_CCMUX_SCALE 6 -#define G_CCMUX_COMBINED_ALPHA 7 -#define G_CCMUX_TEXEL0_ALPHA 8 -#define G_CCMUX_TEXEL1_ALPHA 9 -#define G_CCMUX_PRIMITIVE_ALPHA 10 -#define G_CCMUX_SHADE_ALPHA 11 -#define G_CCMUX_ENV_ALPHA 12 -#define G_CCMUX_LOD_FRACTION 13 -#define G_CCMUX_PRIM_LOD_FRAC 14 -#define G_CCMUX_K5 15 -#define G_ACMUX_COMBINED 0 -#define G_ACMUX_TEXEL0 1 -#define G_ACMUX_TEXEL1 2 -#define G_ACMUX_PRIMITIVE 3 -#define G_ACMUX_SHADE 4 -#define G_ACMUX_ENVIRONMENT 5 -#define G_ACMUX_1 6 -#define G_ACMUX_0 7 -#define G_ACMUX_LOD_FRACTION 0 -#define G_ACMUX_PRIM_LOD_FRAC 6 - -/* - * combine modes - * ( A - B ) * C + D -*/ -#define G_CC_MODULATEI \ - TEXEL0, 0, SHADE, 0, \ - 0, 0, 0, SHADE -#define G_CC_MODULATEIA \ - TEXEL0, 0, SHADE, 0, \ - TEXEL0, 0, SHADE, 0 -#define G_CC_MODULATEIDECALA \ - TEXEL0, 0, SHADE, 0, \ - 0, 0, 0, TEXEL0 -#define G_CC_MODULATERGB \ - G_CC_MODULATEI -#define G_CC_MODULATERGBA \ - G_CC_MODULATEIA -#define G_CC_MODULATERGBDECALA \ - G_CC_MODULATEIDECALA -#define G_CC_MODULATEI_PRIM \ - TEXEL0, 0, PRIMITIVE, 0, \ - 0, 0, 0, PRIMITIVE -#define G_CC_MODULATEIA_PRIM \ - TEXEL0, 0, PRIMITIVE, 0, \ - TEXEL0, 0, PRIMITIVE, 0 -#define G_CC_MODULATEIDECALA_PRIM \ - TEXEL0, 0, PRIMITIVE, 0, \ - 0, 0, 0, TEXEL0 -#define G_CC_MODULATERGB_PRIM \ - G_CC_MODULATEI_PRIM -#define G_CC_MODULATERGBA_PRIM \ - G_CC_MODULATEIA_PRIM -#define G_CC_MODULATERGBDECALA_PRIM \ - G_CC_MODULATEIDECALA_PRIM -#define G_CC_DECALRGB \ - 0, 0, 0, TEXEL0, \ - 0, 0, 0, SHADE -#define G_CC_DECALRGBA \ - 0, 0, 0, TEXEL0, \ - 0, 0, 0, TEXEL0 -#define G_CC_BLENDI \ - ENVIRONMENT, SHADE, TEXEL0, SHADE, \ - 0, 0, 0, SHADE -#define G_CC_BLENDIA \ - ENVIRONMENT, SHADE, TEXEL0, SHADE, \ - TEXEL0, 0, SHADE, 0 -#define G_CC_BLENDIDECALA \ - ENVIRONMENT, SHADE, TEXEL0, SHADE, \ - 0, 0, 0, TEXEL0 -#define G_CC_BLENDRGBA \ - TEXEL0, SHADE, TEXEL0_ALPHA, SHADE, \ - 0, 0, 0, SHADE -#define G_CC_BLENDRGBDECALA \ - TEXEL0, SHADE, TEXEL0_ALPHA, SHADE, \ - 0, 0, 0, TEXEL0 -#define G_CC_REFLECTRGB \ - ENVIRONMENT, 0, TEXEL0, SHADE, \ - 0, 0, 0, SHADE -#define G_CC_REFLECTRGBDECALA \ - ENVIRONMENT, 0, TEXEL0, SHADE, \ - 0, 0, 0, TEXEL0 -#define G_CC_HILITERGB \ - PRIMITIVE, SHADE, TEXEL0, SHADE, \ - 0, 0, 0, SHADE -#define G_CC_HILITERGBA \ - PRIMITIVE, SHADE, TEXEL0, SHADE, \ - PRIMITIVE, SHADE, TEXEL0, SHADE -#define G_CC_HILITERGBDECALA \ - PRIMITIVE, SHADE, TEXEL0, SHADE, \ - 0, 0, 0, TEXEL0 -#define G_CC_1CYUV2RGB \ - TEXEL0, K4, K5, TEXEL0, \ - 0, 0, 0, SHADE -#define G_CC_PRIMITIVE \ - 0, 0, 0, PRIMITIVE, \ - 0, 0, 0, PRIMITIVE -#define G_CC_SHADE \ - 0, 0, 0, SHADE, \ - 0, 0, 0, SHADE -#define G_CC_ADDRGB \ - 1, 0, TEXEL0, SHADE, \ - 0, 0, 0, SHADE -#define G_CC_ADDRGBDECALA \ - 1, 0, TEXEL0, SHADE, \ - 0, 0, 0, TEXEL0 -#define G_CC_SHADEDECALA \ - 0, 0, 0, SHADE, \ - 0, 0, 0, TEXEL0 -#define G_CC_BLENDPE \ - PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, \ - TEXEL0, 0, SHADE, 0 -#define G_CC_BLENDPEDECALA \ - PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, \ - 0, 0, 0, TEXEL0 -#define G_CC_TRILERP \ - TEXEL1, TEXEL0, LOD_FRACTION, TEXEL0, \ - TEXEL1, TEXEL0, LOD_FRACTION, TEXEL0 -#define G_CC_TEMPLERP \ - TEXEL1, TEXEL0, PRIM_LOD_FRAC, TEXEL0, \ - TEXEL1, TEXEL0, PRIM_LOD_FRAC, TEXEL0 -#define G_CC_INTERFERENCE \ - TEXEL0, 0, TEXEL1, 0, \ - TEXEL0, 0, TEXEL1, 0 -#define _G_CC_BLENDPE \ - ENVIRONMENT, PRIMITIVE, TEXEL0, PRIMITIVE, \ - TEXEL0, 0, SHADE, 0 -#define _G_CC_BLENDPEDECALA \ - ENVIRONMENT, PRIMITIVE, TEXEL0, PRIMITIVE, \ - 0, 0, 0, TEXEL0 -#define _G_CC_SPARSEST \ - PRIMITIVE, TEXEL0, LOD_FRACTION, TEXEL0, \ - PRIMITIVE, TEXEL0, LOD_FRACTION, TEXEL0 -#define _G_CC_TWOCOLORTEX \ - PRIMITIVE, SHADE, TEXEL0, SHADE, \ - 0, 0, 0, SHADE -#define G_CC_MODULATEI2 \ - COMBINED, 0, SHADE, 0, \ - 0, 0, 0, SHADE -#define G_CC_MODULATEIA2 \ - COMBINED, 0, SHADE, 0, \ - COMBINED, 0, SHADE, 0 -#define G_CC_MODULATERGB2 \ - G_CC_MODULATEI2 -#define G_CC_MODULATERGBA2 \ - G_CC_MODULATEIA2 -#define G_CC_MODULATEI_PRIM2 \ - COMBINED, 0, PRIMITIVE, 0, \ - 0, 0, 0, PRIMITIVE -#define G_CC_MODULATEIA_PRIM2 \ - COMBINED, 0, PRIMITIVE, 0, \ - COMBINED, 0, PRIMITIVE, 0 -#define G_CC_MODULATERGB_PRIM2 \ - G_CC_MODULATEI_PRIM2 -#define G_CC_MODULATERGBA_PRIM2 \ - G_CC_MODULATEIA_PRIM2 -#define G_CC_DECALRGB2 \ - 0, 0, 0, COMBINED, \ - 0, 0, 0, SHADE -#define G_CC_BLENDI2 \ - ENVIRONMENT, SHADE, COMBINED, SHADE, \ - 0, 0, 0, SHADE -#define G_CC_BLENDIA2 \ - ENVIRONMENT, SHADE, COMBINED, SHADE, \ - COMBINED, 0, SHADE, 0 -#define G_CC_HILITERGB2 \ - ENVIRONMENT, COMBINED, TEXEL0, COMBINED, \ - 0, 0, 0, SHADE -#define G_CC_HILITERGBA2 \ - ENVIRONMENT, COMBINED, TEXEL0, COMBINED, \ - ENVIRONMENT, COMBINED, TEXEL0, COMBINED -#define G_CC_HILITERGBDECALA2 \ - ENVIRONMENT, COMBINED, TEXEL0, COMBINED, \ - 0, 0, 0, TEXEL0 -#define G_CC_HILITERGBPASSA2 \ - ENVIRONMENT, COMBINED, TEXEL0, COMBINED, \ - 0, 0, 0, COMBINED -#define G_CC_CHROMA_KEY2 \ - TEXEL0, CENTER, SCALE, 0, \ - 0, 0, 0, 0 -#define G_CC_YUV2RGB \ - TEXEL1, K4, K5, TEXEL1, \ - 0, 0, 0, 0 -#define G_CC_PASS2 \ - 0, 0, 0, COMBINED, \ - 0, 0, 0, COMBINED -#define G_CC_LERP(a0, b0, c0, d0, Aa0, Ab0, Ac0, Ad0, \ - a1, b1, c1, d1, Aa1, Ab1, Ac1, Ad1) \ - ( \ - gFL_(G_CCMUX_##a0, 4, 52) | \ - gFL_(G_CCMUX_##c0, 5, 47) | \ - gFL_(G_ACMUX_##Aa0, 3, 44) | \ - gFL_(G_ACMUX_##Ac0, 3, 41) | \ - gFL_(G_CCMUX_##a1, 4, 37) | \ - gFL_(G_CCMUX_##c1, 5, 32) | \ - gFL_(G_CCMUX_##b0, 4, 28) | \ - gFL_(G_CCMUX_##b1, 4, 24) | \ - gFL_(G_ACMUX_##Aa1, 3, 21) | \ - gFL_(G_ACMUX_##Ac1, 3, 18) | \ - gFL_(G_CCMUX_##d0, 3, 15) | \ - gFL_(G_ACMUX_##Ab0, 3, 12) | \ - gFL_(G_ACMUX_##Ad0, 3, 9) | \ - gFL_(G_CCMUX_##d1, 3, 6) | \ - gFL_(G_ACMUX_##Ab1, 3, 3) | \ - gFL_(G_ACMUX_##Ad1, 3, 0) \ - ) -#define G_CC_MODE(mode1, mode2) G_CC_LERP(mode1, mode2) - -/* scissor modes */ -#define G_SC_NON_INTERLACE gI_(0b00) -#define G_SC_EVEN_INTERLACE gI_(0b10) -#define G_SC_ODD_INTERLACE gI_(0b11) - -/* display list branch flags */ -#define G_DL_PUSH gI_(0b0) -#define G_DL_NOPUSH gI_(0b1) - -/* conditional branching flags (f3dex and f3dex2) */ -#if defined(F3DEX_GBI) || defined(F3DEX_GBI_2) -# define G_BZ_PERSP 0 -# define G_BZ_ORTHO 1 -#endif - -/* matrix params */ -#define G_MTX_MUL (gI_(0b0) << 1) -#define G_MTX_LOAD (gI_(0b1) << 1) - -/* matrix params for fast3d and f3dex */ -#if defined(F3D_GBI) || defined(F3DEX_GBI) -# define G_MTX_MODELVIEW (gI_(0b0) << 0) -# define G_MTX_PROJECTION (gI_(0b1) << 0) -# define G_MTX_NOPUSH (gI_(0b0) << 2) -# define G_MTX_PUSH (gI_(0b1) << 2) -#endif - -/* matrix params for f3dex2 */ -#if defined(F3DEX_GBI_2) -# define G_MTX_NOPUSH (gI_(0b0) << 0) -# define G_MTX_PUSH (gI_(0b1) << 0) -# define G_MTX_MODELVIEW (gI_(0b0) << 2) -# define G_MTX_PROJECTION (gI_(0b1) << 2) -#endif - -/* moveword indices */ -#define G_MW_MATRIX 0 -#define G_MW_NUMLIGHT 2 -#define G_MW_CLIP 4 -#define G_MW_SEGMENT 6 -#define G_MW_FOG 8 -#define G_MW_GENSTAT 8 -#define G_MW_LIGHTCOL 10 -#define G_MW_PERSPNORM 14 - -/* moveword indices for fast3d and f3dex */ -#if defined(F3D_GBI) || defined(F3DEX_GBI) -# define G_MW_POINTS 12 -#endif - -/* moveword indices for f3dex2 */ -#if defined(F3DEX_GBI_2) -# define G_MW_FORCEMTX 12 -#endif - -/* moveword offsets */ -#define G_MWO_NUMLIGHT gI_(0x00) -#define G_MWO_CLIP_RNX gI_(0x04) -#define G_MWO_CLIP_RNY gI_(0x0C) -#define G_MWO_CLIP_RPX gI_(0x14) -#define G_MWO_CLIP_RPY gI_(0x1C) -#define G_MWO_SEGMENT_0 gI_(0x00) -#define G_MWO_SEGMENT_1 gI_(0x04) -#define G_MWO_SEGMENT_2 gI_(0x08) -#define G_MWO_SEGMENT_3 gI_(0x0C) -#define G_MWO_SEGMENT_4 gI_(0x10) -#define G_MWO_SEGMENT_5 gI_(0x14) -#define G_MWO_SEGMENT_6 gI_(0x18) -#define G_MWO_SEGMENT_7 gI_(0x1C) -#define G_MWO_SEGMENT_8 gI_(0x20) -#define G_MWO_SEGMENT_9 gI_(0x24) -#define G_MWO_SEGMENT_A gI_(0x28) -#define G_MWO_SEGMENT_B gI_(0x2C) -#define G_MWO_SEGMENT_C gI_(0x30) -#define G_MWO_SEGMENT_D gI_(0x34) -#define G_MWO_SEGMENT_E gI_(0x38) -#define G_MWO_SEGMENT_F gI_(0x3C) -#define G_MWO_FOG gI_(0x00) -#define G_MWO_aLIGHT_1 gI_(0x00) -#define G_MWO_bLIGHT_1 gI_(0x04) -#define G_MWO_MATRIX_XX_XY_I gI_(0x00) -#define G_MWO_MATRIX_XZ_XW_I gI_(0x04) -#define G_MWO_MATRIX_YX_YY_I gI_(0x08) -#define G_MWO_MATRIX_YZ_YW_I gI_(0x0C) -#define G_MWO_MATRIX_ZX_ZY_I gI_(0x10) -#define G_MWO_MATRIX_ZZ_ZW_I gI_(0x14) -#define G_MWO_MATRIX_WX_WY_I gI_(0x18) -#define G_MWO_MATRIX_WZ_WW_I gI_(0x1C) -#define G_MWO_MATRIX_XX_XY_F gI_(0x20) -#define G_MWO_MATRIX_XZ_XW_F gI_(0x24) -#define G_MWO_MATRIX_YX_YY_F gI_(0x28) -#define G_MWO_MATRIX_YZ_YW_F gI_(0x2C) -#define G_MWO_MATRIX_ZX_ZY_F gI_(0x30) -#define G_MWO_MATRIX_ZZ_ZW_F gI_(0x34) -#define G_MWO_MATRIX_WX_WY_F gI_(0x38) -#define G_MWO_MATRIX_WZ_WW_F gI_(0x3C) -#define G_MWO_POINT_RGBA gI_(0x10) -#define G_MWO_POINT_ST gI_(0x14) -#define G_MWO_POINT_XYSCREEN gI_(0x18) -#define G_MWO_POINT_ZSCREEN gI_(0x1C) - -/* moveword offsets for fast3d and f3dex */ -#if defined(F3D_GBI) || defined(F3DEX_GBI) -# define G_MWO_aLIGHT_2 gI_(0x20) -# define G_MWO_bLIGHT_2 gI_(0x24) -# define G_MWO_aLIGHT_3 gI_(0x40) -# define G_MWO_bLIGHT_3 gI_(0x44) -# define G_MWO_aLIGHT_4 gI_(0x60) -# define G_MWO_bLIGHT_4 gI_(0x64) -# define G_MWO_aLIGHT_5 gI_(0x80) -# define G_MWO_bLIGHT_5 gI_(0x84) -# define G_MWO_aLIGHT_6 gI_(0xA0) -# define G_MWO_bLIGHT_6 gI_(0xA4) -# define G_MWO_aLIGHT_7 gI_(0xC0) -# define G_MWO_bLIGHT_7 gI_(0xC4) -# define G_MWO_aLIGHT_8 gI_(0xE0) -# define G_MWO_bLIGHT_8 gI_(0xE4) -#endif - -/* moveword offsets for f3dex2 */ -#if defined(F3DEX_GBI_2) -# define G_MWO_aLIGHT_2 gI_(0x18) -# define G_MWO_bLIGHT_2 gI_(0x1C) -# define G_MWO_aLIGHT_3 gI_(0x30) -# define G_MWO_bLIGHT_3 gI_(0x34) -# define G_MWO_aLIGHT_4 gI_(0x48) -# define G_MWO_bLIGHT_4 gI_(0x4C) -# define G_MWO_aLIGHT_5 gI_(0x60) -# define G_MWO_bLIGHT_5 gI_(0x64) -# define G_MWO_aLIGHT_6 gI_(0x78) -# define G_MWO_bLIGHT_6 gI_(0x7C) -# define G_MWO_aLIGHT_7 gI_(0x90) -# define G_MWO_bLIGHT_7 gI_(0x94) -# define G_MWO_aLIGHT_8 gI_(0xA8) -# define G_MWO_bLIGHT_8 gI_(0xAC) -#endif - -/* movemem params for fast3d and f3dex */ -#if defined(F3D_GBI) || defined(F3DEX_GBI) -# define G_MV_VIEWPORT 128 -# define G_MV_LOOKATY 130 -# define G_MV_LOOKATX 132 -# define G_MV_L0 134 -# define G_MV_L1 136 -# define G_MV_L2 138 -# define G_MV_L3 140 -# define G_MV_L4 142 -# define G_MV_L5 144 -# define G_MV_L6 146 -# define G_MV_L7 148 -# define G_MV_TXTATT 150 -# define G_MV_MATRIX_2 152 -# define G_MV_MATRIX_3 154 -# define G_MV_MATRIX_4 156 -# define G_MV_MATRIX_1 158 -#endif - -/* movemem params for f3dex2 */ -#if defined(F3DEX_GBI_2) -# define G_MV_MMTX 2 -# define G_MV_PMTX 6 -# define G_MV_VIEWPORT 8 -# define G_MV_LIGHT 10 -# define G_MV_POINT 12 -# define G_MV_MATRIX 14 -# define G_MVO_LOOKATX gI_(0 * 0x18) -# define G_MVO_LOOKATY gI_(1 * 0x18) -# define G_MVO_L0 gI_(2 * 0x18) -# define G_MVO_L1 gI_(3 * 0x18) -# define G_MVO_L2 gI_(4 * 0x18) -# define G_MVO_L3 gI_(5 * 0x18) -# define G_MVO_L4 gI_(6 * 0x18) -# define G_MVO_L5 gI_(7 * 0x18) -# define G_MVO_L6 gI_(8 * 0x18) -# define G_MVO_L7 gI_(9 * 0x18) -#endif - -/* frustum ratios */ -#define FRUSTRATIO_1 gI_(1) -#define FRUSTRATIO_2 gI_(2) -#define FRUSTRATIO_3 gI_(3) -#define FRUSTRATIO_4 gI_(4) -#define FRUSTRATIO_5 gI_(5) -#define FRUSTRATIO_6 gI_(6) - -/* light params */ -#define NUMLIGHTS_0 1 -#define NUMLIGHTS_1 1 -#define NUMLIGHTS_2 2 -#define NUMLIGHTS_3 3 -#define NUMLIGHTS_4 4 -#define NUMLIGHTS_5 5 -#define NUMLIGHTS_6 6 -#define NUMLIGHTS_7 7 -#define LIGHT_1 1 -#define LIGHT_2 2 -#define LIGHT_3 3 -#define LIGHT_4 4 -#define LIGHT_5 5 -#define LIGHT_6 6 -#define LIGHT_7 7 -#define LIGHT_8 8 - -/* light params for fast3d and f3dex */ -#if defined(F3D_GBI) || defined(F3DEX_GBI) -# define NUML(n) (((n) + 1) * 32 + 0x80000000) -#endif - -/* light params for f3dex2 */ -#if defined(F3DEX_GBI_2) -# define NUML(n) ((n) * 0x18) -#endif - -/* background load types */ -#define G_BGLT_LOADBLOCK gI_(0x0033) -#define G_BGLT_LOADTILE gI_(0xFFF4) - -/* background flags */ -#define G_BG_FLAG_FLIPS (gI_(0b1) << 0) -#define G_BG_FLAG_FLIPT (gI_(0b1) << 1) - -/* object load types */ -#define G_OBJLT_TXTRBLOCK gI_(0x00001033) -#define G_OBJLT_TXTRTILE gI_(0x00FC1034) -#define G_OBJLT_TLUT gI_(0x00000030) - -/* object flags */ -#define G_OBJ_FLAG_FLIPS (gI_(0b1) << 0) -#define G_OBJ_FLAG_FLIPT (gI_(0b1) << 4) - -/* color macros */ -#define G_MAXZ 0x03FF -#define G_MAXFBZ 0x3FFF -#define GPACK_RGBA5551(r, g, b, a) \ - ( \ - gF_(r, 5, 11) | \ - gF_(g, 5, 6) | \ - gF_(b, 5, 1) | \ - gF_(a, 1, 0) \ - ) -#define GPACK_RGBA8888(r, g, b, a) \ - ( \ - gF_(r, 8, 24) | \ - gF_(g, 8, 16) | \ - gF_(b, 8, 8) | \ - gF_(a, 8, 0) \ - ) -#define GPACK_RGB24A8(rgb, a) (gF_(rgb, 24, 8) | gF_(a, 8, 0)) -#define GPACK_ZDZ(z, dz) (gF_(z, 14, 2) | gF_(dz, 2, 0)) - -/* structure definition macros */ -#define gdSPDefMtx(xx, xy, xz, xw, \ - yx, yy, yz, yw, \ - zx, zy, zz, zw, \ - wx, wy, wz, ww) \ - ( \ - (Mtx) \ - { \ - .i = \ - { \ - (qs1616(xx) >> 16) & 0xFFFF, \ - (qs1616(xy) >> 16) & 0xFFFF, \ - (qs1616(xz) >> 16) & 0xFFFF, \ - (qs1616(xw) >> 16) & 0xFFFF, \ - (qs1616(yx) >> 16) & 0xFFFF, \ - (qs1616(yy) >> 16) & 0xFFFF, \ - (qs1616(yz) >> 16) & 0xFFFF, \ - (qs1616(yw) >> 16) & 0xFFFF, \ - (qs1616(zx) >> 16) & 0xFFFF, \ - (qs1616(zy) >> 16) & 0xFFFF, \ - (qs1616(zz) >> 16) & 0xFFFF, \ - (qs1616(zw) >> 16) & 0xFFFF, \ - (qs1616(wx) >> 16) & 0xFFFF, \ - (qs1616(wy) >> 16) & 0xFFFF, \ - (qs1616(wz) >> 16) & 0xFFFF, \ - (qs1616(ww) >> 16) & 0xFFFF, \ - }, \ - .f = \ - { \ - qs1616(xx) & 0xFFFF, \ - qs1616(xy) & 0xFFFF, \ - qs1616(xz) & 0xFFFF, \ - qs1616(xw) & 0xFFFF, \ - qs1616(yx) & 0xFFFF, \ - qs1616(yy) & 0xFFFF, \ - qs1616(yz) & 0xFFFF, \ - qs1616(yw) & 0xFFFF, \ - qs1616(zx) & 0xFFFF, \ - qs1616(zy) & 0xFFFF, \ - qs1616(zz) & 0xFFFF, \ - qs1616(zw) & 0xFFFF, \ - qs1616(wx) & 0xFFFF, \ - qs1616(wy) & 0xFFFF, \ - qs1616(wz) & 0xFFFF, \ - qs1616(ww) & 0xFFFF, \ - } \ - } \ - ) -#define gdSPDefLookAt(rx, ry, rz, ux, uy, uz) \ - ( \ - (LookAt) \ - { \ - .l[0].l = \ - { \ - .col = {0, 0, 0}, \ - .colc = {0, 0, 0}, \ - .dir = {rx, ry, rz}, \ - }, \ - .l[1].l = \ - { \ - .col = {0, 0x80, 0}, \ - .colc = {0, 0x80, 0}, \ - .dir = {ux, uy, uz}, \ - }, \ - } \ - ) -#define gdSPDefLights0(ar, ag, ab) \ - ( \ - (Lights0) \ - { \ - .a.l = \ - { \ - .col = {ar, ag, ab}, \ - .colc = {ar, ag, ab}, \ - }, \ - .l[0].l = \ - { \ - } \ - } \ - ) -#define gdSPDefLights1(ar, ag, ab, \ - r1, g1, b1, x1, y1, z1) \ - ( \ - (Lights1) \ - { \ - .a.l = \ - { \ - .col = {ar, ag, ab}, \ - .colc = {ar, ag, ab}, \ - }, \ - .l[0].l = \ - { \ - .col = {r1, g1, b1}, \ - .colc = {r1, g1, b1}, \ - .dir = {x1, y1, z1}, \ - } \ - } \ - ) -#define gdSPDefLights2(ar, ag, ab, \ - r1, g1, b1, x1, y1, z1, \ - r2, g2, b2, x2, y2, z2) \ - ( \ - (Lights2) \ - { \ - .a.l = \ - { \ - .col = {ar, ag, ab}, \ - .colc = {ar, ag, ab}, \ - }, \ - .l[0].l = \ - { \ - .col = {r1, g1, b1}, \ - .colc = {r1, g1, b1}, \ - .dir = {x1, y1, z1}, \ - } \ - .l[1].l = \ - { \ - .col = {r2, g2, b2}, \ - .colc = {r2, g2, b2}, \ - .dir = {x2, y2, z2}, \ - } \ - } \ - ) -#define gdSPDefLights3(ar, ag, ab, \ - r1, g1, b1, x1, y1, z1, \ - r2, g2, b2, x2, y2, z2, \ - r3, g3, b3, x3, y3, z3) \ - ( \ - (Lights3) \ - { \ - .a.l = \ - { \ - .col = {ar, ag, ab}, \ - .colc = {ar, ag, ab}, \ - }, \ - .l[0].l = \ - { \ - .col = {r1, g1, b1}, \ - .colc = {r1, g1, b1}, \ - .dir = {x1, y1, z1}, \ - } \ - .l[1].l = \ - { \ - .col = {r2, g2, b2}, \ - .colc = {r2, g2, b2}, \ - .dir = {x2, y2, z2}, \ - } \ - .l[2].l = \ - { \ - .col = {r3, g3, b3}, \ - .colc = {r3, g3, b3}, \ - .dir = {x3, y3, z3}, \ - } \ - } \ - ) -#define gdSPDefLights4(ar, ag, ab, \ - r1, g1, b1, x1, y1, z1, \ - r2, g2, b2, x2, y2, z2, \ - r3, g3, b3, x3, y3, z3, \ - r4, g4, b4, x4, y4, z4) \ - ( \ - (Lights4) \ - { \ - .a.l = \ - { \ - .col = {ar, ag, ab}, \ - .colc = {ar, ag, ab}, \ - }, \ - .l[0].l = \ - { \ - .col = {r1, g1, b1}, \ - .colc = {r1, g1, b1}, \ - .dir = {x1, y1, z1}, \ - } \ - .l[1].l = \ - { \ - .col = {r2, g2, b2}, \ - .colc = {r2, g2, b2}, \ - .dir = {x2, y2, z2}, \ - } \ - .l[2].l = \ - { \ - .col = {r3, g3, b3}, \ - .colc = {r3, g3, b3}, \ - .dir = {x3, y3, z3}, \ - } \ - .l[3].l = \ - { \ - .col = {r4, g4, b4}, \ - .colc = {r4, g4, b4}, \ - .dir = {x4, y4, z4}, \ - } \ - } \ - ) -#define gdSPDefLights5(ar, ag, ab, \ - r1, g1, b1, x1, y1, z1, \ - r2, g2, b2, x2, y2, z2, \ - r3, g3, b3, x3, y3, z3, \ - r4, g4, b4, x4, y4, z4, \ - r5, g5, b5, x5, y5, z5) \ - ( \ - (Lights5) \ - { \ - .a.l = \ - { \ - .col = {ar, ag, ab}, \ - .colc = {ar, ag, ab}, \ - }, \ - .l[0].l = \ - { \ - .col = {r1, g1, b1}, \ - .colc = {r1, g1, b1}, \ - .dir = {x1, y1, z1}, \ - } \ - .l[1].l = \ - { \ - .col = {r2, g2, b2}, \ - .colc = {r2, g2, b2}, \ - .dir = {x2, y2, z2}, \ - } \ - .l[2].l = \ - { \ - .col = {r3, g3, b3}, \ - .colc = {r3, g3, b3}, \ - .dir = {x3, y3, z3}, \ - } \ - .l[3].l = \ - { \ - .col = {r4, g4, b4}, \ - .colc = {r4, g4, b4}, \ - .dir = {x4, y4, z4}, \ - } \ - .l[4].l = \ - { \ - .col = {r5, g5, b5}, \ - .colc = {r5, g5, b5}, \ - .dir = {x5, y5, z5}, \ - } \ - } \ - ) -#define gdSPDefLights6(ar, ag, ab, \ - r1, g1, b1, x1, y1, z1, \ - r2, g2, b2, x2, y2, z2, \ - r3, g3, b3, x3, y3, z3, \ - r4, g4, b4, x4, y4, z4, \ - r5, g5, b5, x5, y5, z5, \ - r6, g6, b6, x6, y6, z6)\ - ( \ - (Lights6) \ - { \ - .a.l = \ - { \ - .col = {ar, ag, ab}, \ - .colc = {ar, ag, ab}, \ - }, \ - .l[0].l = \ - { \ - .col = {r1, g1, b1}, \ - .colc = {r1, g1, b1}, \ - .dir = {x1, y1, z1}, \ - } \ - .l[1].l = \ - { \ - .col = {r2, g2, b2}, \ - .colc = {r2, g2, b2}, \ - .dir = {x2, y2, z2}, \ - } \ - .l[2].l = \ - { \ - .col = {r3, g3, b3}, \ - .colc = {r3, g3, b3}, \ - .dir = {x3, y3, z3}, \ - } \ - .l[3].l = \ - { \ - .col = {r4, g4, b4}, \ - .colc = {r4, g4, b4}, \ - .dir = {x4, y4, z4}, \ - } \ - .l[4].l = \ - { \ - .col = {r5, g5, b5}, \ - .colc = {r5, g5, b5}, \ - .dir = {x5, y5, z5}, \ - } \ - .l[5].l = \ - { \ - .col = {r6, g6, b6}, \ - .colc = {r6, g6, b6}, \ - .dir = {x6, y6, z6}, \ - } \ - } \ - ) -#define gdSPDefLights7(ar, ag, ab, \ - r1, g1, b1, x1, y1, z1, \ - r2, g2, b2, x2, y2, z2, \ - r3, g3, b3, x3, y3, z3, \ - r4, g4, b4, x4, y4, z4, \ - r5, g5, b5, x5, y5, z5, \ - r6, g6, b6, x6, y6, z6, \ - r7, g7, b7, x7, y7, z7) \ - ( \ - (Lights7) \ - { \ - .a.l = \ - { \ - .col = {ar, ag, ab}, \ - .colc = {ar, ag, ab}, \ - }, \ - .l[0].l = \ - { \ - .col = {r1, g1, b1}, \ - .colc = {r1, g1, b1}, \ - .dir = {x1, y1, z1}, \ - } \ - .l[1].l = \ - { \ - .col = {r2, g2, b2}, \ - .colc = {r2, g2, b2}, \ - .dir = {x2, y2, z2}, \ - } \ - .l[2].l = \ - { \ - .col = {r3, g3, b3}, \ - .colc = {r3, g3, b3}, \ - .dir = {x3, y3, z3}, \ - } \ - .l[3].l = \ - { \ - .col = {r4, g4, b4}, \ - .colc = {r4, g4, b4}, \ - .dir = {x4, y4, z4}, \ - } \ - .l[4].l = \ - { \ - .col = {r5, g5, b5}, \ - .colc = {r5, g5, b5}, \ - .dir = {x5, y5, z5}, \ - } \ - .l[5].l = \ - { \ - .col = {r6, g6, b6}, \ - .colc = {r6, g6, b6}, \ - .dir = {x6, y6, z6}, \ - } \ - .l[6].l = \ - { \ - .col = {r7, g7, b7}, \ - .colc = {r7, g7, b7}, \ - .dir = {x7, y7, z7}, \ - } \ - } \ - ) -#define gdSPDefVtx(x, y, z, s, t) \ - ( \ - (Vtx) \ - { \ - .v = \ - { \ - .ob = {x, y, z}, \ - .tc = {qs105(s), qs105(t)}, \ - } \ - } \ - ) -#define gdSPDefVtxC(x, y, z, s, t, cr, cg, cb, ca) \ - ( \ - (Vtx) \ - { \ - .v = \ - { \ - .ob = {x, y, z}, \ - .tc = {qs105(s), qs105(t)}, \ - .cn = {cr, cg, cb, ca}, \ - } \ - } \ - ) -#define gdSPDefVtxN(x, y, z, s, t, nx, ny, nz, ca) \ - ( \ - (Vtx) \ - { \ - .n = \ - { \ - .ob = {x, y, z}, \ - .tc = {qs105(s), qs105(t)}, \ - .n = {nx, ny, nz}, \ - .a = ca \ - } \ - } \ - ) - -/* instruction macros */ - -#define gsDPFillRectangle(ulx, uly, lrx, lry) \ - gO_( \ - G_FILLRECT, \ - gF_(lrx, 10, 14) | \ - gF_(lry, 10, 2), \ - gF_(ulx, 10, 14) | \ - gF_(uly, 10, 2)) - -#define gsDPScisFillRectangle(ulx, uly, lrx, lry) \ - gsDPFillRectangle(gScC_(ulx), gScC_(uly), gScC_(lrx), gScC_(lry)) - -#define gsDPFullSync() \ - gO_(G_RDPFULLSYNC, 0, 0) - -#define gsDPLoadSync() \ - gO_(G_RDPLOADSYNC, 0, 0) - -#define gsDPTileSync() \ - gO_(G_RDPTILESYNC, 0, 0) - -#define gsDPPipeSync() \ - gO_(G_RDPPIPESYNC, 0, 0) - -#define gsDPLoadTLUT_pal16(pal, dram) \ - gsDPLoadTLUT(16, 256 + (gI_(pal) & 0xF) * 16, dram) - -#define gsDPLoadTLUT_pal256(dram) \ - gsDPLoadTLUT(256, 256, dram) - -#define gLTB_(timg, fmt, siz, width, height, pal, \ - cms, cmt, masks, maskt, shifts, shiftt, \ - dxt, tmem, rt, line) \ - gsDPSetTextureImage(fmt, G_SIZ_LDSIZ(siz), 1, timg), \ - gsDPSetTile( \ - fmt, G_SIZ_LDSIZ(siz), 0, tmem, G_TX_LOADTILE, 0, \ - cmt, maskt, shiftt, \ - cms, masks, shifts), \ - gsDPLoadSync(), \ - gsDPLoadBlock( \ - G_TX_LOADTILE, 0, 0, \ - G_LTB_LRS(width, height, siz), \ - dxt), \ - gsDPPipeSync(), \ - gsDPSetTile( \ - fmt, siz, line, tmem, rt, pal, \ - cmt, maskt, shiftt, \ - cms, masks, shifts), \ - gsDPSetTileSize(rt, 0, 0, qu102((width) - 1), qu102((height) - 1)) - -#define gsDPLoadTextureBlock(timg, fmt, siz, width, height, pal, \ - cms, cmt, masks, maskt, shifts, shiftt) \ - gLTB_( \ - timg, fmt, siz, width, height, pal, \ - cms, cmt, masks, maskt, shifts, shiftt, \ - G_DXT(siz, width), 0x0, G_TX_RENDERTILE, \ - ((width) * G_SIZ_LDBITS(siz) + 63) / 64) - -#define gsDPLoadTextureBlockS(timg, fmt, siz, width, height, pal, \ - cms, cmt, masks, maskt, shifts, shiftt) \ - gLTB_( \ - timg, fmt, siz, width, height, pal, \ - cms, cmt, masks, maskt, shifts, shiftt, \ - 0, 0x0, G_TX_RENDERTILE, \ - ((width) * G_SIZ_LDBITS(siz) + 63) / 64) - -#define gsDPLoadTextureBlock_4b(timg, fmt, width, height, pal, \ - cms, cmt, masks, maskt, shifts, shiftt) \ - gLTB_( \ - timg, fmt, G_IM_SIZ_4b, width, height, pal, \ - cms, cmt, masks, maskt, shifts, shiftt, \ - G_DXT(G_IM_SIZ_4b, width), 0x0, G_TX_RENDERTILE, \ - ((width) * 4 + 63) / 64) - -#define gsDPLoadTextureBlock_4bS(timg, fmt, width, height, pal, \ - cms, cmt, masks, maskt, shifts, shiftt) \ - gLTB_( \ - timg, fmt, G_IM_SIZ_4b, width, height, pal, \ - cms, cmt, masks, maskt, shifts, shiftt, \ - 0, 0x0, G_TX_RENDERTILE, \ - ((width) * 4 + 63) / 64) - -#define gsDPLoadTextureBlockYuv(timg, fmt, siz, width, height, pal, \ - cms, cmt, masks, maskt, shifts, shiftt) \ - gLTB_( \ - timg, fmt, siz, width, height, pal, \ - cms, cmt, masks, maskt, shifts, shiftt, \ - G_DXT(siz, width), 0x0, G_TX_RENDERTILE, \ - ((width) + 7) / 8) - -#define gsDPLoadTextureBlockYuvS(timg, fmt, siz, width, height, pal, \ - cms, cmt, masks, maskt, shifts, shiftt) \ - gLTB_( \ - timg, fmt, siz, width, height, pal, \ - cms, cmt, masks, maskt, shifts, shiftt, \ - 0, 0x0, G_TX_RENDERTILE, \ - ((width) + 7) / 8) - -#define _gsDPLoadTextureBlock(timg, tmem, fmt, siz, width, height, pal, \ - cms, cmt, masks, maskt, shifts, shiftt) \ - gLTB_( \ - timg, fmt, siz, width, height, pal, \ - cms, cmt, masks, maskt, shifts, shiftt, \ - G_DXT(siz, width), tmem, G_TX_RENDERTILE, \ - ((width) * G_SIZ_LDBITS(siz) + 63) / 64) - -#define _gsDPLoadTextureBlockS(timg, tmem, fmt, siz, width, height, pal, \ - cms, cmt, masks, maskt, shifts, shiftt) \ - gLTB_( \ - timg, fmt, siz, width, height, pal, \ - cms, cmt, masks, maskt, shifts, shiftt, \ - 0, tmem, G_TX_RENDERTILE, \ - ((width) * G_SIZ_LDBITS(siz) + 63) / 64) - -#define _gsDPLoadTextureBlock_4b(timg, tmem, fmt, width, height, pal, \ - cms, cmt, masks, maskt, shifts, shiftt) \ - gLTB_( \ - timg, fmt, G_IM_SIZ_4b, width, height, pal, \ - cms, cmt, masks, maskt, shifts, shiftt, \ - G_DXT(G_IM_SIZ_4b, width), tmem, G_TX_RENDERTILE, \ - ((width) * 4 + 63) / 64) - -#define _gsDPLoadTextureBlock_4bS(timg, tmem, fmt, width, height, pal, \ - cms, cmt, masks, maskt, shifts, shiftt) \ - gLTB_( \ - timg, fmt, G_IM_SIZ_4b, width, height, pal, \ - cms, cmt, masks, maskt, shifts, shiftt, \ - 0, tmem, G_TX_RENDERTILE, \ - ((width) * 4 + 63) / 64) - -#define _gsDPLoadTextureBlockYuv(timg, tmem, fmt, siz, width, height, pal, \ - cms, cmt, masks, maskt, shifts, shiftt) \ - gLTB_( \ - timg, fmt, siz, width, height, pal, \ - cms, cmt, masks, maskt, shifts, shiftt, \ - G_DXT(siz, width), tmem, G_TX_RENDERTILE, \ - ((width) + 7) / 8) - -#define _gsDPLoadTextureBlockYuvS(timg, tmem, fmt, siz, width, height, pal, \ - cms, cmt, masks, maskt, shifts, shiftt) \ - gLTB_( \ - timg, fmt, siz, width, height, pal, \ - cms, cmt, masks, maskt, shifts, shiftt, \ - 0, tmem, G_TX_RENDERTILE, \ - ((width) + 7) / 8) - -#define gsDPLoadMultiBlock(timg, tmem, rt, fmt, siz, width, height, pal, \ - cms, cmt, masks, maskt, shifts, shiftt) \ - gLTB_( \ - timg, fmt, siz, width, height, pal, \ - cms, cmt, masks, maskt, shifts, shiftt, \ - G_DXT(siz, width), tmem, rt, \ - ((width) * G_SIZ_LDBITS(siz) + 63) / 64) - -#define gsDPLoadMultiBlockS(timg, tmem, rt, fmt, siz, width, height, pal, \ - cms, cmt, masks, maskt, shifts, shiftt) \ - gLTB_( \ - timg, fmt, siz, width, height, pal, \ - cms, cmt, masks, maskt, shifts, shiftt, \ - 0, tmem, rt, \ - ((width) * G_SIZ_LDBITS(siz) + 63) / 64) - -#define gsDPLoadMultiBlock_4b(timg, tmem, rt, fmt, width, height, pal, \ - cms, cmt, masks, maskt, shifts, shiftt) \ - gLTB_( \ - timg, fmt, G_IM_SIZ_4b, width, height, pal, \ - cms, cmt, masks, maskt, shifts, shiftt, \ - G_DXT(G_IM_SIZ_4b, width), tmem, rt, \ - ((width) * 4 + 63) / 64) - -#define gsDPLoadMultiBlock_4bS(timg, tmem, rt, fmt, width, height, pal, \ - cms, cmt, masks, maskt, shifts, shiftt) \ - gLTB_( \ - timg, fmt, G_IM_SIZ_4b, width, height, pal, \ - cms, cmt, masks, maskt, shifts, shiftt, \ - 0, tmem, rt, \ - ((width) * 4 + 63) / 64) - -#define gsDPLoadMultiBlockYuv(timg, tmem, rt, fmt, siz, width, height, pal, \ - cms, cmt, masks, maskt, shifts, shiftt) \ - gLTB_( \ - timg, fmt, siz, width, height, pal, \ - cms, cmt, masks, maskt, shifts, shiftt, \ - G_DXT(siz, width), tmem, rt, \ - ((width) + 7) / 8) - -#define gsDPLoadMultiBlockYuvS(timg, tmem, rt, fmt, siz, width, height, pal, \ - cms, cmt, masks, maskt, shifts, shiftt) \ - gLTB_( \ - timg, fmt, siz, width, height, pal, \ - cms, cmt, masks, maskt, shifts, shiftt, \ - 0, tmem, rt, \ - ((width) + 7) / 8) - -#define gLTT_(timg, fmt, siz, width, height, uls, ult, lrs, lrt, pal, \ - cms, cmt, masks, maskt, shifts, shiftt, \ - tmem, rt, line) \ - gsDPSetTextureImage(fmt, siz, width, timg), \ - gsDPSetTile( \ - fmt, siz, line, tmem, \ - G_TX_LOADTILE, 0, \ - cmt, maskt, shiftt, \ - cms, masks, shifts), \ - gsDPLoadSync(), \ - gsDPLoadTile( \ - G_TX_LOADTILE, \ - qu102(uls), qu102(ult), \ - qu102(lrs), qu102(lrt)), \ - gsDPPipeSync(), \ - gsDPSetTile( \ - fmt, siz, line, \ - tmem, rt, pal, \ - cmt, maskt, shiftt, \ - cms, masks, shifts), \ - gsDPSetTileSize( \ - rt, \ - qu102(uls), qu102(ult), \ - qu102(lrs), qu102(lrt)) - -#define gLTT4_(timg, fmt, width, height, uls, ult, lrs, lrt, pal, \ - cms, cmt, masks, maskt, shifts, shiftt, \ - tmem, rt) \ - gsDPSetTextureImage(fmt, G_IM_SIZ_8b, (width) / 2, timg), \ - gsDPSetTile( \ - fmt, G_IM_SIZ_8b, \ - (((lrs) - (uls) + 1) / 2 + 7) / 8, \ - tmem, G_TX_LOADTILE, 0, \ - cmt, maskt, shiftt, \ - cms, masks, shifts), \ - gsDPLoadSync(), \ - gsDPLoadTile( \ - G_TX_LOADTILE, \ - qu102(uls) / 2, qu102(ult), \ - qu102(lrs) / 2, qu102(lrt)), \ - gsDPPipeSync(), \ - gsDPSetTile( \ - fmt, G_IM_SIZ_4b, \ - (((lrs) - (uls) + 1) / 2 + 7) / 8, \ - tmem, rt, pal, \ - cmt, maskt, shiftt, \ - cms, masks, shifts), \ - gsDPSetTileSize( \ - rt, \ - qu102(uls), qu102(ult), \ - qu102(lrs), qu102(lrt)) - -#define gsDPLoadTextureTile(timg, fmt, siz, width, height, \ - uls, ult, lrs, lrt, pal, \ - cms, cmt, masks, maskt, shifts, shiftt) \ - gLTT_( \ - timg, fmt, siz, width, height, \ - uls, ult, lrs, lrt, pal, \ - cms, cmt, masks, maskt, shifts, shiftt, \ - 0x0, G_TX_RENDERTILE, \ - (((lrs) - (uls) + 1) * G_SIZ_LDBITS(siz) + 63) / 64) - -#define gsDPLoadTextureTile_4b(timg, fmt, width, height, \ - uls, ult, lrs, lrt, pal, \ - cms, cmt, masks, maskt, shifts, shiftt) \ - gLTT4_( \ - timg, fmt, width, height, \ - uls, ult, lrs, lrt, pal, \ - cms, cmt, masks, maskt, shifts, shiftt, \ - 0x0, G_TX_RENDERTILE) - -#define gsDPLoadTextureTileYuv(timg, fmt, siz, width, height, \ - uls, ult, lrs, lrt, pal, \ - cms, cmt, masks, maskt, shifts, shiftt) \ - gLTT_( \ - timg, fmt, siz, width, height, \ - uls, ult, lrs, lrt, pal, \ - cms, cmt, masks, maskt, shifts, shiftt, \ - 0x0, G_TX_RENDERTILE, \ - (((lrs) - (uls) + 1) + 7) / 8) - -#define _gsDPLoadTextureTile(timg, tmem, fmt, siz, width, height, \ - uls, ult, lrs, lrt, pal, \ - cms, cmt, masks, maskt, shifts, shiftt) \ - gLTT_( \ - timg, fmt, siz, width, height, \ - uls, ult, lrs, lrt, pal, \ - cms, cmt, masks, maskt, shifts, shiftt, \ - tmem, G_TX_RENDERTILE, \ - (((lrs) - (uls) + 1) * G_SIZ_LDBITS(siz) + 63) / 64) - -#define _gsDPLoadTextureTile_4b(timg, tmem, fmt, width, height, \ - uls, ult, lrs, lrt, pal, \ - cms, cmt, masks, maskt, shifts, shiftt) \ - gLTT4_( \ - timg, fmt, width, height, \ - uls, ult, lrs, lrt, pal, \ - cms, cmt, masks, maskt, shifts, shiftt, \ - tmem, G_TX_RENDERTILE) - -#define _gsDPLoadTextureTileYuv(timg, tmem, fmt, siz, width, height, \ - uls, ult, lrs, lrt, pal, cms, cmt, \ - masks, maskt, shifts, shiftt) \ - gLTT_( \ - timg, fmt, siz, width, height, \ - uls, ult, lrs, lrt, pal, \ - cms, cmt, masks, maskt, shifts, shiftt, \ - tmem, G_TX_RENDERTILE, \ - (((lrs) - (uls) + 1) + 7) / 8) - -#define gsDPLoadMultiTile(timg, tmem, rt, fmt, siz, width, height, \ - uls, ult, lrs, lrt, pal, \ - cms, cmt, masks, maskt, shifts, shiftt) \ - gLTT_( \ - timg, fmt, siz, width, height, \ - uls, ult, lrs, lrt, pal, \ - cms, cmt, masks, maskt, shifts, shiftt, \ - tmem, rt, \ - (((lrs) - (uls) + 1) * G_SIZ_LDBITS(siz) + 63) / 64) - -#define gsDPLoadMultiTile_4b(timg, tmem, rt, fmt, width, height, \ - uls, ult, lrs, lrt, pal, \ - cms, cmt, masks, maskt, shifts, shiftt) \ - gLTT4_( \ - timg, fmt, width, height, \ - uls, ult, lrs, lrt, pal, \ - cms, cmt, masks, maskt, shifts, shiftt, \ - tmem, rt) - -#define gsDPLoadMultiTileYuv(timg, tmem, rt, fmt, siz, width, height, \ - uls, ult, lrs, lrt, pal, \ - cms, cmt, masks, maskt, shifts, shiftt) \ - gLTT_( \ - timg, fmt, siz, width, height, \ - uls, ult, lrs, lrt, pal, \ - cms, cmt, masks, maskt, shifts, shiftt, \ - tmem, rt, \ - (((lrs) - (uls) + 1) + 7) / 8) - -#define gsDPLoadBlock(tile, uls, ult, lrs, dxt) \ - gO_( \ - G_LOADBLOCK, \ - gF_(uls, 12, 12) | \ - gF_(ult, 12, 0), \ - gF_(tile, 3, 24) | \ - gF_(G_LDBLK_TXL(lrs), 12, 12) | \ - gF_(dxt, 12, 0)) - -#define gsDPNoOp() \ - gsDPNoOpTag(0) - -#define gsDPNoOpTag(tag) \ - gO_(G_NOOP, 0, tag) - -#define gsDPPipelineMode(mode) \ - gsSPSetOtherModeHi(G_MDSFT_PIPELINE, G_MDSIZ_PIPELINE, mode) - -#define gsDPSetBlendColor(r, g, b, a) \ - gO_( \ - G_SETBLENDCOLOR, \ - 0, \ - gF_(r, 8, 24) | \ - gF_(g, 8, 16) | \ - gF_(b, 8, 8) | \ - gF_(a, 8, 0)) - -#define gsDPSetEnvColor(r, g, b, a) \ - gO_( \ - G_SETENVCOLOR, \ - 0, \ - gF_(r, 8, 24) | \ - gF_(g, 8, 16) | \ - gF_(b, 8, 8) | \ - gF_(a, 8, 0)) - -#define gsDPSetFillColor(c) \ - gO_(G_SETFILLCOLOR, 0, c) - -#define gsDPSetFogColor(r, g, b, a) \ - gO_( \ - G_SETFOGCOLOR, 0, \ - gF_(r, 8, 24) | \ - gF_(g, 8, 16) | \ - gF_(b, 8, 8) | \ - gF_(a, 8, 0)) - -#define gsDPSetPrimColor(m, l, r, g, b, a) \ - gO_( \ - G_SETPRIMCOLOR, \ - gF_(m, 8, 8) | \ - gF_(l, 8, 0), \ - gF_(r, 8, 24) | \ - gF_(g, 8, 16) | \ - gF_(b, 8, 8) | \ - gF_(a, 8, 0)) - -#define gsDPSetColorImage(fmt, siz, width, img) \ - gO_( \ - G_SETCIMG, \ - gF_(fmt, 3, 21) | \ - gF_(siz, 2, 19) | \ - gF_((width) - 1, 12, 0), \ - img) - -#define gsDPSetDepthImage(img) \ - gO_(G_SETZIMG, 0, img) - -#define gsDPSetTextureImage(fmt, siz, width, img) \ - gO_( \ - G_SETTIMG, \ - gF_(fmt, 3, 21) | \ - gF_(siz, 2, 19) | \ - gF_((width) - 1, 12, 0), \ - img) - -#define gsDPSetHilite1Tile(tile, hilite, width, height) \ - gsDPSetTileSize( \ - tile, \ - ((Hilite *)(hilite))->h.x1 & 0xFFF, \ - ((Hilite *)(hilite))->h.y1 & 0xFFF, \ - (((width) - 1) * 4 + ((Hilite *)(hilite))->h.x1) & 0xFFF, \ - (((height) - 1) * 4 + ((Hilite *)(hilite))->h.y1) & 0xFFF) - -#define gsDPSetHilite2Tile(tile, hilite, width, height) \ - gsDPSetTileSize( \ - tile, \ - ((Hilite *)(hilite))->h.x2 & 0xFFF, \ - ((Hilite *)(hilite))->h.y2 & 0xFFF, \ - (((width) - 1) * 4 + ((Hilite *)(hilite))->h.x2) & 0xFFF, \ - (((height) - 1) * 4 + ((Hilite *)(hilite))->h.y2) & 0xFFF) - -#define gsDPSetAlphaCompare(mode) \ - gsSPSetOtherModeLo(G_MDSFT_ALPHACOMPARE, G_MDSIZ_ALPHACOMPARE, mode) - -#define gsDPSetAlphaDither(type) \ - gsSPSetOtherModeHi(G_MDSFT_ALPHADITHER, G_MDSIZ_ALPHADITHER, type) - -#define gsDPSetColorDither(type) \ - gsSPSetOtherModeHi(G_MDSFT_RGBDITHER, G_MDSIZ_RGBDITHER, type) - -#define gsDPSetCombineMode(mode1, mode2) \ - gsDPSetCombineLERP(mode1, mode2) - -#define gsDPSetCombineLERP(a0, b0, c0, d0, Aa0, Ab0, Ac0, Ad0, \ - a1, b1, c1, d1, Aa1, Ab1, Ac1, Ad1) \ - gO_( \ - G_SETCOMBINE, \ - gF_(G_CCMUX_##a0, 4, 20) | \ - gF_(G_CCMUX_##c0, 5, 15) | \ - gF_(G_ACMUX_##Aa0, 3, 12) | \ - gF_(G_ACMUX_##Ac0, 3, 9) | \ - gF_(G_CCMUX_##a1, 4, 5) | \ - gF_(G_CCMUX_##c1, 5, 0), \ - gF_(G_CCMUX_##b0, 4, 28) | \ - gF_(G_CCMUX_##b1, 4, 24) | \ - gF_(G_ACMUX_##Aa1, 3, 21) | \ - gF_(G_ACMUX_##Ac1, 3, 18) | \ - gF_(G_CCMUX_##d0, 3, 15) | \ - gF_(G_ACMUX_##Ab0, 3, 12) | \ - gF_(G_ACMUX_##Ad0, 3, 9) | \ - gF_(G_CCMUX_##d1, 3, 6) | \ - gF_(G_ACMUX_##Ab1, 3, 3) | \ - gF_(G_ACMUX_##Ad1, 3, 0)) - -#define gsDPSetConvert(k0, k1, k2, k3, k4, k5) \ - gO_( \ - G_SETCONVERT, \ - gF_(k0, 9, 13) | \ - gF_(k1, 9, 4) | \ - gF_(gI_(k2) >> 5, 4, 0), \ - gF_(k2, 5, 27) | \ - gF_(k3, 9, 18) | \ - gF_(k4, 9, 9) | \ - gF_(k5, 9, 0)) - -#define gsDPSetTextureConvert(type) \ - gsSPSetOtherModeHi(G_MDSFT_TEXTCONV, G_MDSIZ_TEXTCONV, type) - -#define gsDPSetCycleType(type) \ - gsSPSetOtherModeHi(G_MDSFT_CYCLETYPE, G_MDSIZ_CYCLETYPE, type) - -#define gsDPSetDepthSource(source) \ - gsSPSetOtherModeLo(G_MDSFT_ZSRCSEL, G_MDSIZ_ZSRCSEL, source) - -#define gsDPSetCombineKey(type) \ - gsSPSetOtherModeHi(G_MDSFT_COMBKEY, G_MDSIZ_COMBKEY, type) - -#define gsDPSetKeyGB(cG, sG, wG, cB, sB, wB) \ - gO_( \ - G_SETKEYGB, \ - gF_(wG, 12, 12) | \ - gF_(wB, 12, 0), \ - gF_(cG, 8, 24) | \ - gF_(sG, 8, 16) | \ - gF_(cB, 8, 8) | \ - gF_(sB, 8, 0)) - -#define gsDPSetKeyR(cR, sR, wR) \ - gO_( \ - G_SETKEYR, 0, \ - gF_(wR, 12, 16) | \ - gF_(cR, 8, 8) | \ - gF_(sR, 8, 0)) - -#define gsDPSetPrimDepth(z, dz) \ - gO_( \ - G_SETPRIMDEPTH, \ - 0, \ - gF_(z, 16, 16) | \ - gF_(dz, 16, 0)) - -#define gsDPSetRenderMode(mode1, mode2) \ - gsSPSetOtherModeLo( \ - G_MDSFT_RENDERMODE, \ - G_MDSIZ_RENDERMODE, \ - gI_(mode1) | \ - gI_(mode2)) - -#define gsDPSetScissor(mode, ulx, uly, lrx, lry) \ - gsDPSetScissorFrac( \ - mode, \ - qu102(gI_(ulx)), \ - qu102(gI_(uly)), \ - qu102(gI_(lrx)), \ - qu102(gI_(lry))) - -#define gsDPSetScissorFrac(mode, ulx, uly, lrx, lry) \ - gO_( \ - G_SETSCISSOR, \ - gF_(ulx, 12, 12) | \ - gF_(uly, 12, 0), \ - gF_(mode, 2, 24) | \ - gF_(lrx, 12, 12) | \ - gF_(lry, 12, 0)) - -#define gsDPSetTextureDetail(type) \ - gsSPSetOtherModeHi(G_MDSFT_TEXTDETAIL, G_MDSIZ_TEXTDETAIL, type) - -#define gsDPSetTextureFilter(mode) \ - gsSPSetOtherModeHi(G_MDSFT_TEXTFILT, G_MDSIZ_TEXTFILT, mode) - -#define gsDPSetTextureLOD(mode) \ - gsSPSetOtherModeHi(G_MDSFT_TEXTLOD, G_MDSIZ_TEXTLOD, mode) - -#define gsDPSetTextureLUT(mode) \ - gsSPSetOtherModeHi(G_MDSFT_TEXTLUT, G_MDSIZ_TEXTLUT, mode) - -#define gsDPSetTexturePersp(enable) \ - gsSPSetOtherModeHi(G_MDSFT_TEXTPERSP, G_MDSIZ_TEXTPERSP, enable) - -#define gsDPSetTile(fmt, siz, line, tmem, tile, palette, \ - cmt, maskt, shiftt, cms, masks, shifts) \ - gO_( \ - G_SETTILE, \ - gF_(fmt, 3, 21) | \ - gF_(siz, 2, 19) | \ - gF_(line, 9, 9) | \ - gF_(tmem, 9, 0), \ - gF_(tile, 3, 24) | \ - gF_(palette, 4, 20) | \ - gF_(cmt, 2, 18) | \ - gF_(maskt, 4, 14) | \ - gF_(shiftt, 4, 10) | \ - gF_(cms, 2, 8) | \ - gF_(masks, 4, 4) | \ - gF_(shifts, 4, 0)) - -#define gsDPSetTileSize(tile, uls, ult, lrs, lrt) \ - gO_( \ - G_SETTILESIZE, \ - gF_(uls, 12, 12) | \ - gF_(ult, 12, 0), \ - gF_(tile, 3, 24) | \ - gF_(lrs, 12, 12) | \ - gF_(lrt, 12, 0)) - -#define gsSPBranchList(dl) \ - gsDisplayList(dl, 1) - -#define gsSPClipRatio(r) \ - gsMoveWd(G_MW_CLIP, G_MWO_CLIP_RNX, (uint16_t)(r)), \ - gsMoveWd(G_MW_CLIP, G_MWO_CLIP_RNY, (uint16_t)(r)), \ - gsMoveWd(G_MW_CLIP, G_MWO_CLIP_RPX, (uint16_t)-(r)), \ - gsMoveWd(G_MW_CLIP, G_MWO_CLIP_RPY, (uint16_t)-(r)) - -#define gsSPDisplayList(dl) \ - gsDisplayList(dl, 0) - -#define gsSPEndDisplayList() \ - gO_(G_ENDDL, 0, 0) - -#define gsSPFogFactor(fm, fo) \ - gsMoveWd( \ - G_MW_FOG, \ - G_MWO_FOG, \ - gF_(fm, 16, 16) | \ - gF_(fo, 16, 0)) - -#define gsSPFogPosition(min, max) \ - gsSPFogFactor( \ - (500 * 0x100) / ((max) - (min)), \ - (500 - (min)) * 0x100 / ((max) - (min))) - -#define gsSPLine3D(v0, v1, flag) \ - gsSPLineW3D(v0, v1, 0, flag) - -#define gsSPLookAt(l) \ - gsSPLookAtX(l), \ - gsSPLookAtY(gI_(l) + 0x10) - -#define gsSPSegment(seg, base) \ - gsMoveWd(G_MW_SEGMENT, (seg) * 4, base) - -#define gsSPSetLights0(lites) \ - gsSPNumLights(NUMLIGHTS_0), \ - gsSPLight(&(lites).l[0], 1), \ - gsSPLight(&(lites).a, 2) - -#define gsSPSetLights1(lites) \ - gsSPNumLights(NUMLIGHTS_1), \ - gsSPLight(&(lites).l[0], 1), \ - gsSPLight(&(lites).a, 2) - -#define gsSPSetLights2(lites) \ - gsSPNumLights(NUMLIGHTS_2), \ - gsSPLight(&(lites).l[0], 1), \ - gsSPLight(&(lites).l[1], 2), \ - gsSPLight(&(lites).a, 3) - -#define gsSPSetLights3(lites) \ - gsSPNumLights(NUMLIGHTS_3), \ - gsSPLight(&(lites).l[0], 1), \ - gsSPLight(&(lites).l[1], 2), \ - gsSPLight(&(lites).l[2], 3), \ - gsSPLight(&(lites).a, 4) - -#define gsSPSetLights4(lites) \ - gsSPNumLights(NUMLIGHTS_4), \ - gsSPLight(&(lites).l[0], 1), \ - gsSPLight(&(lites).l[1], 2), \ - gsSPLight(&(lites).l[2], 3), \ - gsSPLight(&(lites).l[3], 4), \ - gsSPLight(&(lites).a, 5) - -#define gsSPSetLights5(lites) \ - gsSPNumLights(NUMLIGHTS_5), \ - gsSPLight(&(lites).l[0], 1), \ - gsSPLight(&(lites).l[1], 2), \ - gsSPLight(&(lites).l[2], 3), \ - gsSPLight(&(lites).l[3], 4), \ - gsSPLight(&(lites).l[4], 5), \ - gsSPLight(&(lites).a, 6) - -#define gsSPSetLights6(lites) \ - gsSPNumLights(NUMLIGHTS_6), \ - gsSPLight(&(lites).l[0], 1), \ - gsSPLight(&(lites).l[1], 2), \ - gsSPLight(&(lites).l[2], 3), \ - gsSPLight(&(lites).l[3], 4), \ - gsSPLight(&(lites).l[4], 5), \ - gsSPLight(&(lites).l[5], 6), \ - gsSPLight(&(lites).a, 7) - -#define gsSPSetLights7(lites) \ - gsSPNumLights(NUMLIGHTS_7), \ - gsSPLight(&(lites).l[0], 1), \ - gsSPLight(&(lites).l[1], 2), \ - gsSPLight(&(lites).l[2], 3), \ - gsSPLight(&(lites).l[3], 4), \ - gsSPLight(&(lites).l[4], 5), \ - gsSPLight(&(lites).l[5], 6), \ - gsSPLight(&(lites).l[6], 7), \ - gsSPLight(&(lites).a, 8) - -#define gsSPSetStatus(sid, val) \ - gsMoveWd(G_MW_GENSTAT, sid, val) - -#define gsSPNumLights(n) \ - gsMoveWd(G_MW_NUMLIGHT, G_MWO_NUMLIGHT, NUML(n)) - -#define gsSPLightColor(Lightnum, packedcolor) \ - gsMoveWd(G_MW_LIGHTCOL, G_MWO_a##Lightnum, packedcolor), \ - gsMoveWd(G_MW_LIGHTCOL, G_MWO_b##Lightnum, packedcolor) - -#define gsSPTextureRectangle(ulx, uly, lrx, lry, tile, s, t, dsdx, dtdy) \ - gsTexRect(ulx, uly, lrx, lry, tile), \ - gsDPHalf1(gF_(s, 16, 16) | gF_(t, 16, 0)), \ - gsDPHalf2(gF_(dsdx, 16, 16) | gF_(dtdy, 16, 0)) - -#define gsSPScisTextureRectangle(ulx, uly, lrx, lry, tile, s, t, dsdx, dtdy) \ - gsTexRect(gScC_(ulx), gScC_(uly), gScC_(lrx), gScC_(lry), tile), \ - gsDPHalf1( \ - gF_(gScD_(s, ulx, dsdx), 16, 16) | \ - gF_(gScD_(t, uly, dtdy), 16, 0)), \ - gsDPHalf2(gF_(dsdx, 16, 16) | gF_(dtdy, 16, 0)) - -#define gsSPTextureRectangleFlip(ulx, uly, lrx, lry, tile, s, t, dsdx, dtdy) \ - gsTexRectFlip(ulx, uly, lrx, lry, tile), \ - gsDPHalf1(gF_(s, 16, 16) | gF_(t, 16, 0)), \ - gsDPHalf2(gF_(dsdx, 16, 16) | gF_(dtdy, 16, 0)) - -#define gsSPScisTextureRectangleFlip( \ - ulx, uly, lrx, lry, tile, s, t, dsdx, dtdy) \ - gsTexRectFlip(gScC_(ulx), gScC_(uly), gScC_(lrx), gScC_(lry), tile), \ - gsDPHalf1( \ - gF_(gScD_(s, ulx, dsdx), 16, 16) | \ - gF_(gScD_(t, uly, dtdy), 16, 0)), \ - gsDPHalf2(gF_(dsdx, 16, 16) | gF_(dtdy, 16, 0)) - -#define gsSPBgRectCopy(bg) \ - gO_(G_BG_COPY, 0, bg) - -#define gsSPBgRect1Cyc(bg) \ - gO_(G_BG_1CYC, 0, bg) - -#define gsSPObjRectangle(sp) \ - gO_(G_OBJ_RECTANGLE, 0, sp) - -#define gsSPObjRectangleR(sp) \ - gO_(G_OBJ_RECTANGLE_R, 0, sp) - -#define gsSPObjSprite(sp) \ - gO_(G_OBJ_SPRITE, 0, sp) - -#define gsSPObjMatrix(mtx) \ - gO_( \ - G_OBJ_MOVEMEM, \ - gF_(sizeof(uObjMtx) - 1, 8, 16), \ - mtx) - -#define gsSPObjSubMatrix(mtx) \ - gO_( \ - G_OBJ_MOVEMEM, \ - gF_(sizeof(uObjSubMtx) - 1, 8, 16) | \ - gF_(2, 16, 0), \ - mtx) - -#define gsSPObjRenderMode(mode) \ - gO_(G_OBJ_RENDERMODE, 0, mode) - -#define gsSPObjLoadTxtr(tx) \ - gO_(G_OBJ_LOADTXTR, 23, tx) - -#define gsSPObjLoadTxRect(txsp) \ - gO_(G_OBJ_LDTX_RECT, 47, txsp) - -#define gsSPObjLoadTxRectR(txsp) \ - gO_(G_OBJ_LDTX_RECT_R, 47, txsp) - -#define gsSPObjLoadTxSprite(txsp) \ - gO_(G_OBJ_LDTX_SPRITE, 47, txsp) - -#define gsSPSelectDL(ldl, sid, flag, mask) \ - gO_( \ - G_RDPHALF_0, \ - gF_(sid, 8, 16) | \ - gF_(ldl, 16, 0), \ - flag), \ - gO_( \ - G_SELECT_DL, \ - gF_(0x00, 8, 16) | \ - gF_(gI_(ldl) >> 16, 16, 0), \ - mask) - -#define gsSPSelectBranchDL(bdl, sid, flag, mask) \ - gO_( \ - G_RDPHALF_0, \ - gF_(sid, 8, 16) | \ - gF_(bdl, 16, 0), \ - flag), \ - gO_( \ - G_SELECT_DL, \ - gF_(0x01, 8, 16) | \ - gF_(gI_(bdl) >> 16, 16, 0), \ - mask) - -/* unlisted instructions */ - -#define gsDPLoadTLUTCmd(tile, count) \ - gO_( \ - G_LOADTLUT, \ - 0, \ - gF_(tile, 3, 24) | \ - gF_(count, 10, 14)) - -#define gsDPLoadTLUT(count, tmem, dram) \ - gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, dram), \ - gsDPTileSync(), \ - gsDPSetTile(0, 0, 0, tmem, G_TX_LOADTILE, 0, 0, 0, 0, 0, 0, 0), \ - gsDPLoadSync(), \ - gsDPLoadTLUTCmd(G_TX_LOADTILE, (count) - 1), \ - gsDPPipeSync() - -#define gsDisplayList(dl, branch) \ - gO_(G_DL, gF_(branch, 8, 16), dl) - -#define gsDPLoadTile(tile, uls, ult, lrs, lrt) \ - gO_( \ - G_LOADTILE, \ - gF_(uls, 12, 12) | \ - gF_(ult, 12, 0), \ - gF_(tile, 3, 24) | \ - gF_(lrs, 12, 12) | \ - gF_(lrt, 12, 0)) - -#define gsDPSetCombine(c) \ - gO_( \ - G_SETCOMBINE, \ - (gL_(c) >> 32) & 0xFFFFFFFF, \ - (gL_(c) >> 0) & 0xFFFFFFFF) - -#define gsSPSetOtherModeLo(shift, length, data) \ - gsSPSetOtherMode(G_SETOTHERMODE_L, shift, length, data) - -#define gsSPSetOtherModeHi(shift, length, data) \ - gsSPSetOtherMode(G_SETOTHERMODE_H, shift, length, data) - -#define gsDPSetOtherMode(mode0, mode1) \ - gO_(G_RDPSETOTHERMODE, gF_(mode0, 24, 0), mode1) - -#define gsTexRect(ulx, uly, lrx, lry, tile) \ - gO_( \ - G_TEXRECT, \ - gF_(lrx, 12, 12) | \ - gF_(lry, 12, 0), \ - gF_(tile, 3, 24) | \ - gF_(ulx, 12, 12) | \ - gF_(uly, 12, 0)) - -#define gsTexRectFlip(ulx, uly, lrx, lry, tile) \ - gO_( \ - G_TEXRECTFLIP, \ - gF_(lrx, 12, 12) | \ - gF_(lry, 12, 0), \ - gF_(tile, 3, 24) | \ - gF_(ulx, 12, 12) | \ - gF_(uly, 12, 0)) - -#define gsSPNoOp() \ - gO_(G_SPNOOP, 0, 0) - -#define gsDPHalf1(wordhi) \ - gO_(G_RDPHALF_1, 0, wordhi) - -#define gsDPHalf2(wordlo) \ - gO_(G_RDPHALF_2, 0, wordlo) - -#define gsDPWord(wordhi, wordlo) \ - gsDPHalf1(wordhi), \ - gsDPHalf2(wordlo) - -/* instruction macros for fast3d */ - -#if defined(F3D_GBI) - -# define gsSP1Triangle(v0, v1, v2, flag) \ - gO_( \ - G_TRI1, \ - 0, \ - gF_(flag, 8, 24) | \ - gF_(gI_(v0) * 10, 8, 16) | \ - gF_(gI_(v1) * 10, 8, 8) | \ - gF_(gI_(v2) * 10, 8, 0)) - -# define gsSPCullDisplayList(v0, vn) \ - gO_( \ - G_CULLDL, \ - (gI_(v0) & 0xF) * 40, \ - gI_((vn) + 1) & 0xF) * 40) - -# define gsSPLineW3D(v0, v1, wd, flag) \ - gO_( \ - G_LINE3D, \ - 0, \ - gF_(flag, 8, 24) | \ - gF_(gI_(v0) * 10, 8, 16) | \ - gF_(gI_(v1) * 10, 8, 8) | \ - gF_(wd, 8, 0)) - -# define gsSPVertex(v, n, v0) \ - gO_( \ - G_VTX, \ - gF_((n) - 1, 4, 20) | \ - gF_(v0, 4, 16) | \ - gF_(sizeof(Vtx) * (n), 16, 0), \ - v) - -#endif - -/* instruction macros for fast3d and beta f3dex */ -#if defined(F3D_GBI) || (defined(F3D_BETA) && defined(F3DEX_GBI)) - -# define gsSPModifyVertex(vtx, where, val) \ - gsMoveWd(G_MW_POINTS, (vtx) * 40 + (where), val) - -#endif - -/* instruction macros for fast3d and f3dex */ - -#if defined(F3D_GBI) || defined(F3DEX_GBI) - -# define gsSPForceMatrix(mptr) \ - gsMoveMem(16, G_MV_MATRIX_1, (char *)(mptr)), \ - gsMoveMem(16, G_MV_MATRIX_2, (char *)(mptr) + 16), \ - gsMoveMem(16, G_MV_MATRIX_3, (char *)(mptr) + 32), \ - gsMoveMem(16, G_MV_MATRIX_4, (char *)(mptr) + 48) - -# define gsSPSetGeometryMode(mode) \ - gO_(G_SETGEOMETRYMODE, 0, gI_(mode)) - -# define gsSPClearGeometryMode(mode) \ - gO_(G_CLEARGEOMETRYMODE, 0, gI_(mode)) - -# define gsSPLoadGeometryMode(mode) \ - gsSPClearGeometryMode(~gI_(0)), \ - gsSPSetGeometryMode(mode) - -# define gsSPInsertMatrix(where, num) \ - gsMoveWd(G_MW_MATRIX, where, num) - -# define gsSPLookAtX(l) \ - gsMoveMem(sizeof(Light), G_MV_LOOKATX, l) - -# define gsSPLookAtY(l) \ - gsMoveMem(sizeof(Light), G_MV_LOOKATY, l) - -# define gsSPMatrix(matrix, param) \ - gO_( \ - G_MTX, \ - gF_(param, 8, 16) | \ - gF_(sizeof(Mtx), 16, 0), \ - matrix) - -# define gsSPPopMatrix(param) \ - gO_(G_POPMTX, 0, param) - -# define gsSPLight(l, n) \ - gsMoveMem(sizeof(Light), G_MV_L0 + ((n) - 1) * 2, l) - -# define gsSPTexture(sc, tc, level, tile, on) \ - gO_( \ - G_TEXTURE, \ - gF_(level, 3, 11) | \ - gF_(tile, 3, 8) | \ - gF_(on, 8, 0), \ - gF_(sc, 16, 16) | \ - gF_(tc, 16, 0)) - -# define gsSPViewport(v) \ - gsMoveMem(sizeof(Vp), G_MV_VIEWPORT, v) - -# define gsSPSetOtherMode(opc, shift, length, data) \ - gO_( \ - opc, \ - gF_(shift, 8, 8) | \ - gF_(length, 8, 0), \ - data) - -# define gsMoveWd(index, offset, data) \ - gO_( \ - G_MOVEWORD, \ - gF_(offset, 16, 8) | \ - gF_(index, 8, 0), \ - data) - -# define gsMoveMem(size, index, address) \ - gO_( \ - G_MOVEMEM, \ - gF_(index, 8, 16) | \ - gF_(size, 16, 0), \ - address) - -#endif - -/* instruction macros for f3dex */ - -#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, \ - gF_(gV4_(v0, v1, v2, v3, flag) * 2, 8, 16) | \ - gF_(gV4_(v1, v2, v3, v0, flag) * 2, 8, 8) | \ - gF_(gV4_(v2, v3, v0, v1, flag) * 2, 8, 0), \ - gF_(gV4_(v0, v1, v2, v3, flag) * 2, 8, 16) | \ - gF_(gV4_(v2, v3, v0, v1, flag) * 2, 8, 8) | \ - gF_(gV4_(v3, v0, v1, v2, flag) * 2, 8, 0)) - -# define gsSPLineW3D(v0, v1, wd, flag) \ - gO_( \ - G_LINE3D, \ - 0, \ - gF_(gV2_(v0, v1, flag) * 2, 8, 16) | \ - gF_(gV2_(v1, v0, flag) * 2, 8, 8) | \ - gF_(wd, 8, 0)) - -# define gsSPVertex(v, n, v0) \ - gO_( \ - G_VTX, \ - gF_((v0) * 2, 8, 16) | \ - gF_(n, 6, 10) | \ - gF_(sizeof(Vtx) * (n) - 1, 10, 0), \ - v) - -#endif - -/* instruction macros for f3dex and f3dex2 */ - -#if defined(F3DEX_GBI) || defined(F3DEX_GBI_2) - -# define gsSP2Triangles(v00, v01, v02, flag0, v10, v11, v12, flag1) \ - gO_( \ - G_TRI2, \ - gF_(gV3_(v00, v01, v02, flag0) * 2, 8, 16) | \ - gF_(gV3_(v01, v02, v00, flag0) * 2, 8, 8) | \ - gF_(gV3_(v02, v00, v01, flag0) * 2, 8, 0), \ - gF_(gV3_(v10, v11, v12, flag1) * 2, 8, 16) | \ - gF_(gV3_(v11, v12, v10, flag1) * 2, 8, 8) | \ - gF_(gV3_(v12, v10, v11, flag1) * 2, 8, 0)) - -# define gsSPBranchLessZ(branchdl, vtx, zval, near, far, flag) \ - gsSPBranchLessZrg(branchdl, vtx, zval, near, far, flag, 0, G_MAXZ) - -# define gsSPBranchLessZrg(branchdl, vtx, zval, near, far, flag, zmin, zmax) \ - gsSPBranchLessZraw(branchdl, vtx, \ - G_DEPTOZSrg(zval, near, far, flag, zmin, zmax)) - -# define gsSPBranchLessZraw(branchdl, vtx, zval) \ - gsDPHalf1(branchdl), \ - gsBranchZ(vtx, zval) - -# define gsSPCullDisplayList(v0, vn) \ - gO_( \ - G_CULLDL, \ - gF_((v0) * 2, 16, 0), \ - gF_((vn) * 2, 16, 0)) - -# define gsSPLoadUcode(uc_start, uc_dstart) \ - gsSPLoadUcodeEx(uc_start, uc_dstart, 0x800) - -# define gsSPLoadUcodeL(ucode) \ - gsSPLoadUcode( \ - gI_(&ucode##TextStart) & 0x1FFFFFFF, \ - gI_(&ucode##DataStart) & 0x1FFFFFFF) - -# if !(defined(F3D_BETA) && defined(F3DEX_GBI)) -# define gsSPModifyVertex(vtx, where, val) \ - gO_( \ - G_MODIFYVTX, \ - gF_(where, 8, 16) | \ - gF_((vtx) * 2, 16, 0), \ - val) -# endif - -# define gsBranchZ(vtx, zval) \ - gO_( \ - G_BRANCH_Z, \ - gF_((vtx) * 5, 12, 12) | \ - gF_((vtx) * 2, 12, 0), \ - zval) - -# define gsLoadUcode(uc_start, uc_dsize) \ - gO_( \ - G_LOAD_UCODE, \ - gF_((uc_dsize) - 1, 16, 0), \ - uc_start) - -# define gsSPLoadUcodeEx(uc_start, uc_dstart, uc_dsize) \ - gsDPHalf1(uc_dstart), \ - gsLoadUcode(uc_start, uc_dsize) - -#endif - -/* instruction macros for f3dex2 */ - -#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, \ - gF_(gV4_(v0, v1, v2, v3, flag) * 2, 8, 16) | \ - gF_(gV4_(v1, v2, v3, v0, flag) * 2, 8, 8) | \ - gF_(gV4_(v2, v3, v0, v1, flag) * 2, 8, 0), \ - gF_(gV4_(v0, v1, v2, v3, flag) * 2, 8, 16) | \ - gF_(gV4_(v2, v3, v0, v1, flag) * 2, 8, 8) | \ - gF_(gV4_(v3, v0, v1, v2, flag) * 2, 8, 0)) - -# define gsSPForceMatrix(mptr) \ - gsMoveMem(sizeof(Mtx), G_MV_MATRIX, 0, mptr), \ - gsMoveWd(G_MW_FORCEMTX, 0, 0x10000) - -# define gsSPSetGeometryMode(mode) \ - gsSPGeometryMode(0, mode) - -# define gsSPClearGeometryMode(mode) \ - gsSPGeometryMode(mode, 0) - -# define gsSPLoadGeometryMode(mode) \ - gsSPGeometryMode(~gI_(0), mode) - -# define gsSPLineW3D(v0, v1, wd, flag) \ - gO_( \ - G_LINE3D, \ - gF_(gV2_(v0, v1, flag) * 2, 8, 16) | \ - gF_(gV2_(v1, v0, flag) * 2, 8, 8) | \ - gF_(wd, 8, 0), \ - 0) - -# define gsSPLookAtX(l) \ - gsMoveMem(sizeof(Light), G_MV_LIGHT, G_MVO_LOOKATX, l) - -# define gsSPLookAtY(l) \ - gsMoveMem(sizeof(Light), G_MV_LIGHT, G_MVO_LOOKATY, l) - -# define gsSPMatrix(matrix, param) \ - gO_( \ - G_MTX, \ - gF_((sizeof(Mtx) - 1) / 8, 5, 19) | \ - gF_(gI_(param) ^ G_MTX_PUSH, 8, 0), \ - matrix) - -# define gsSPPopMatrix(param) \ - gsSPPopMatrixN(param, 1) - -# define gsSPPopMatrixN(param, n) \ - gO_( \ - G_POPMTX, \ - gF_((sizeof(Mtx) - 1) / 8, 5, 19) | \ - gF_(2, 8, 0), \ - sizeof(Mtx) * (n)) - -# define gsSPLight(l, n) \ - gsMoveMem(sizeof(Light), G_MV_LIGHT, ((n) + 1) * 0x18, l) - -# define gsSPTexture(sc, tc, level, tile, on) \ - gO_( \ - G_TEXTURE, \ - gF_(level, 3, 11) | \ - gF_(tile, 3, 8) | \ - gF_(on, 7, 1), \ - gF_(sc, 16, 16) | \ - gF_(tc, 16, 0)) - -# define gsSPVertex(v, n, v0) \ - gO_( \ - G_VTX, \ - gF_(n, 8, 12) | \ - gF_((v0) + (n), 7, 1), \ - v) - -# define gsSPViewport(v) \ - gsMoveMem(sizeof(Vp), G_MV_VIEWPORT, 0, v) - -# define gsSPGeometryMode(clearbits, setbits) \ - gO_( \ - G_GEOMETRYMODE, \ - gF_(~gI_(clearbits), 24, 0), \ - setbits) - -# define gsSPSetOtherMode(opc, shift, length, data) \ - gO_( \ - opc, \ - gF_(32 - (shift) - (length), 8, 8) | \ - gF_((length) - 1, 8, 0), \ - data) - -# define gsMoveWd(index, offset, data) \ - gO_( \ - G_MOVEWORD, \ - gF_(index, 8, 16) | \ - gF_(offset, 16, 0), \ - data) - -# define gsMoveMem(size, index, offset, address) \ - gO_( \ - G_MOVEMEM, \ - gF_((size - 1) / 8, 5, 19) | \ - gF_((offset) / 8, 8, 8) | \ - gF_(index, 8, 0), \ - address) - -# define gsSPDma_io(flag, dmem, dram, size) \ - gO_( \ - G_DMA_IO, \ - gF_(flag, 1, 23) | \ - gF_((dmem) / 8, 10, 13) | \ - gF_((size) - 1, 12, 0), \ - dram) - -# define gsSPDmaRead(dmem, dram, size) \ - gsSPDma_io(0, dmem, dram, size) - -# define gsSPDmaWrite(dmem, dram, size) \ - gsSPDma_io(1, dmem, dram, size) - -# define gsSpecial3(hi, lo) \ - gO_(G_SPECIAL_3, hi, lo) - -# define gsSpecial2(hi, lo) \ - gO_(G_SPECIAL_2, hi, lo) - -# define gsSpecial1(hi, lo) \ - gO_(G_SPECIAL_1, hi, lo) - -#endif - -/* instruction macros for beta fast3d and f3dex */ - -#if defined(F3D_BETA) && (defined(F3D_GBI) || defined(F3DEX_GBI)) - -# define gsSPPerspNormalize(scale) \ - gO_(G_PERSPNORM, 0, scale) - -#else - -# define gsSPPerspNormalize(scale) \ - gsMoveWd(G_MW_PERSPNORM, 0, scale) - -#endif - -/* dynamic instruction macros */ - -#define gDisplayListPut(gdl, ...) \ - ({ \ - Gfx Gd_[] = {__VA_ARGS__}; \ - for(size_t Gi_ = 0; Gi_ < sizeof(Gd_) / sizeof(Gfx); Gi_++) \ - { \ - *(Gfx *)(gdl) = Gd_[Gi_]; \ - } \ - (void)0; \ - }) -#define gDisplayListAppend(pgdl, ...) \ - ({ \ - Gfx Gd_[] = {__VA_ARGS__}; \ - for(size_t Gi_ = 0; Gi_ < sizeof(Gd_) / sizeof(Gfx); Gi_++) \ - { \ - *(*(Gfx **)(pgdl))++ = Gd_[Gi_]; \ - } \ - (void)0; \ - }) -#define gDisplayListData(pgdl, d) \ - ({ \ - Gfx **Gp_ = (void *)(pgdl); \ - struct \ - { \ - __typeof__(d) v; \ - } *Gd_, *Gs_; \ - *Gp_ -= (sizeof(*Gd_) + sizeof(Gfx) - 1) / sizeof(Gfx); \ - Gd_ = (void *)*Gp_; \ - Gs_ = (void *)&(d); \ - *Gd_ = *Gs_; \ - &Gd_->v; \ - }) -#define gDisplayListAlloc(pgdl, s) \ - ({ \ - Gfx **Gp_ = (void *)(pgdl); \ - *Gp_ -= ((s) + sizeof(Gfx) - 1) / sizeof(Gfx); \ - (void *)*Gp_; \ - }) - -#define gDPFillRectangle(gdl, ...) \ - gD_(gdl, gsDPFillRectangle, __VA_ARGS__) -#define gDPScisFillRectangle(gdl, ...) \ - gD_(gdl, gsDPScisFillRectangle, __VA_ARGS__) -#define gDPFullSync(gdl) \ - gDisplayListPut(gdl, gsDPFullSync()) -#define gDPLoadSync(gdl) \ - gDisplayListPut(gdl, gsDPLoadSync()) -#define gDPTileSync(gdl) \ - gDisplayListPut(gdl, gsDPTileSync()) -#define gDPPipeSync(gdl) \ - gDisplayListPut(gdl, gsDPPipeSync()) -#define gDPLoadTLUT_pal16(gdl, ...) \ - gD_(gdl, gsDPLoadTLUT_pal16, __VA_ARGS__) -#define gDPLoadTLUT_pal256(gdl, ...) \ - gD_(gdl, gsDPLoadTLUT_pal256, __VA_ARGS__) -#define gDPLoadTextureBlock(gdl, ...) \ - gD_(gdl, gsDPLoadTextureBlock, __VA_ARGS__) -#define gDPLoadTextureBlockS(gdl, ...) \ - gD_(gdl, gsDPLoadTextureBlockS, __VA_ARGS__) -#define gDPLoadTextureBlock_4b(gdl, ...) \ - gD_(gdl, gsDPLoadTextureBlock_4b, __VA_ARGS__) -#define gDPLoadTextureBlock_4bS(gdl, ...) \ - gD_(gdl, gsDPLoadTextureBlock_4bS, __VA_ARGS__) -#define gDPLoadTextureBlockYuv(gdl, ...) \ - gD_(gdl, gsDPLoadTextureBlockYuv, __VA_ARGS__) -#define gDPLoadTextureBlockYuvS(gdl, ...) \ - gD_(gdl, gsDPLoadTextureBlockYuvS, __VA_ARGS__) -#define _gDPLoadTextureBlock(gdl, ...) \ - gD_(gdl, _gsDPLoadTextureBlock, __VA_ARGS__) -#define _gDPLoadTextureBlockS(gdl, ...) \ - gD_(gdl, _gsDPLoadTextureBlockS, __VA_ARGS__) -#define _gDPLoadTextureBlock_4b(gdl, ...) \ - gD_(gdl, _gsDPLoadTextureBlock_4b, __VA_ARGS__) -#define _gDPLoadTextureBlock_4bS(gdl, ...) \ - gD_(gdl, _gsDPLoadTextureBlock_4bS, __VA_ARGS__) -#define _gDPLoadTextureBlockYuv(gdl, ...) \ - gD_(gdl, _gsDPLoadTextureBlockYuv, __VA_ARGS__) -#define _gDPLoadTextureBlockYuvS(gdl, ...) \ - gD_(gdl, _gsDPLoadTextureBlockYuvS, __VA_ARGS__) -#define gDPLoadMultiBlock(gdl, ...) \ - gD_(gdl, gsDPLoadMultiBlock, __VA_ARGS__) -#define gDPLoadMultiBlockS(gdl, ...) \ - gD_(gdl, gsDPLoadMultiBlockS, __VA_ARGS__) -#define gDPLoadMultiBlock_4b(gdl, ...) \ - gD_(gdl, gsDPLoadMultiBlock_4b, __VA_ARGS__) -#define gDPLoadMultiBlock_4bS(gdl, ...) \ - gD_(gdl, gsDPLoadMultiBlock_4bS, __VA_ARGS__) -#define gDPLoadMultiBlockYuv(gdl, ...) \ - gD_(gdl, gsDPLoadMultiBlockYuv, __VA_ARGS__) -#define gDPLoadMultiBlockYuvS(gdl, ...) \ - gD_(gdl, gsDPLoadMultiBlockYuvS, __VA_ARGS__) -#define gDPLoadTextureTile(gdl, ...) \ - gD_(gdl, gsDPLoadTextureTile, __VA_ARGS__) -#define gDPLoadTextureTile_4b(gdl, ...) \ - gD_(gdl, gsDPLoadTextureTile_4b, __VA_ARGS__) -#define gDPLoadTextureTileYuv(gdl, ...) \ - gD_(gdl, gsDPLoadTextureTileYuv, __VA_ARGS__) -#define _gDPLoadTextureTile(gdl, ...) \ - gD_(gdl, _gsDPLoadTextureTile, __VA_ARGS__) -#define _gDPLoadTextureTile_4b(gdl, ...) \ - gD_(gdl, _gsDPLoadTextureTile_4b, __VA_ARGS__) -#define _gDPLoadTextureTileYuv(gdl, ...) \ - gD_(gdl, _gsDPLoadTextureTileYuv, __VA_ARGS__) -#define gDPLoadMultiTile(gdl, ...) \ - gD_(gdl, gsDPLoadMultiTile, __VA_ARGS__) -#define gDPLoadMultiTile_4b(gdl, ...) \ - gD_(gdl, gsDPLoadMultiTile_4b, __VA_ARGS__) -#define gDPLoadMultiTileYuv(gdl, ...) \ - gD_(gdl, gsDPLoadMultiTileYuv, __VA_ARGS__) -#define gDPLoadBlock(gdl, ...) \ - gD_(gdl, gsDPLoadBlock, __VA_ARGS__) -#define gDPNoOp(gdl) \ - gDisplayListPut(gdl, gsDPNoOp()) -#define gDPNoOpTag(gdl, ...) \ - gD_(gdl, gsDPNoOpTag, __VA_ARGS__) -#define gDPPipelineMode(gdl, ...) \ - gD_(gdl, gsDPPipelineMode, __VA_ARGS__) -#define gDPSetBlendColor(gdl, ...) \ - gD_(gdl, gsDPSetBlendColor, __VA_ARGS__) -#define gDPSetEnvColor(gdl, ...) \ - gD_(gdl, gsDPSetEnvColor, __VA_ARGS__) -#define gDPSetFillColor(gdl, ...) \ - gD_(gdl, gsDPSetFillColor, __VA_ARGS__) -#define gDPSetFogColor(gdl, ...) \ - gD_(gdl, gsDPSetFogColor, __VA_ARGS__) -#define gDPSetPrimColor(gdl, ...) \ - gD_(gdl, gsDPSetPrimColor, __VA_ARGS__) -#define gDPSetColorImage(gdl, ...) \ - gD_(gdl, gsDPSetColorImage, __VA_ARGS__) -#define gDPSetDepthImage(gdl, ...) \ - gD_(gdl, gsDPSetDepthImage, __VA_ARGS__) -#define gDPSetTextureImage(gdl, ...) \ - gD_(gdl, gsDPSetTextureImage, __VA_ARGS__) -#define gDPSetHilite1Tile(gdl, ...) \ - gD_(gdl, gsDPSetHilite1Tile, __VA_ARGS__) -#define gDPSetHilite2Tile(gdl, ...) \ - gD_(gdl, gsDPSetHilite2Tile, __VA_ARGS__) -#define gDPSetAlphaCompare(gdl, ...) \ - gD_(gdl, gsDPSetAlphaCompare, __VA_ARGS__) -#define gDPSetAlphaDither(gdl, ...) \ - gD_(gdl, gsDPSetAlphaDither, __VA_ARGS__) -#define gDPSetColorDither(gdl, ...) \ - gD_(gdl, gsDPSetColorDither, __VA_ARGS__) -#define gDPSetCombineMode(gdl, ...) \ - gD_(gdl, gsDPSetCombineLERP, __VA_ARGS__) -#define gDPSetCombineLERP(gdl, ...) \ - gD_(gdl, gsDPSetCombineLERP, __VA_ARGS__) -#define gDPSetConvert(gdl, ...) \ - gD_(gdl, gsDPSetConvert, __VA_ARGS__) -#define gDPSetTextureConvert(gdl, ...) \ - gD_(gdl, gsDPSetTextureConvert, __VA_ARGS__) -#define gDPSetCycleType(gdl, ...) \ - gD_(gdl, gsDPSetCycleType, __VA_ARGS__) -#define gDPSetDepthSource(gdl, ...) \ - gD_(gdl, gsDPSetDepthSource, __VA_ARGS__) -#define gDPSetCombineKey(gdl, ...) \ - gD_(gdl, gsDPSetCombineKey, __VA_ARGS__) -#define gDPSetKeyGB(gdl, ...) \ - gD_(gdl, gsDPSetKeyGB, __VA_ARGS__) -#define gDPSetKeyR(gdl, ...) \ - gD_(gdl, gsDPSetKeyR, __VA_ARGS__) -#define gDPSetPrimDepth(gdl, ...) \ - gD_(gdl, gsDPSetPrimDepth, __VA_ARGS__) -#define gDPSetRenderMode(gdl, ...) \ - gD_(gdl, gsDPSetRenderMode, __VA_ARGS__) -#define gDPSetScissor(gdl, ...) \ - gD_(gdl, gsDPSetScissor, __VA_ARGS__) -#define gDPSetScissorFrac(gdl, ...) \ - gD_(gdl, gsDPSetScissorFrac, __VA_ARGS__) -#define gDPSetTextureDetail(gdl, ...) \ - gD_(gdl, gsDPSetTextureDetail, __VA_ARGS__) -#define gDPSetTextureFilter(gdl, ...) \ - gD_(gdl, gsDPSetTextureFilter, __VA_ARGS__) -#define gDPSetTextureLOD(gdl, ...) \ - gD_(gdl, gsDPSetTextureLOD, __VA_ARGS__) -#define gDPSetTextureLUT(gdl, ...) \ - gD_(gdl, gsDPSetTextureLUT, __VA_ARGS__) -#define gDPSetTexturePersp(gdl, ...) \ - gD_(gdl, gsDPSetTexturePersp, __VA_ARGS__) -#define gDPSetTile(gdl, ...) \ - gD_(gdl, gsDPSetTile, __VA_ARGS__) -#define gDPSetTileSize(gdl, ...) \ - gD_(gdl, gsDPSetTileSize, __VA_ARGS__) -#define gSP1Triangle(gdl, ...) \ - gD_(gdl, gsSP1Triangle, __VA_ARGS__) -#if defined(F3DEX_GBI) || defined(F3DEX_GBI_2) -# define gSP2Triangles(gdl, ...) \ - gD_(gdl, gsSP2Triangles, __VA_ARGS__) -# define gSP1Quadrangle(gdl, ...) \ - gD_(gdl, gsSP1Quadrangle, __VA_ARGS__) -# define gSPBranchLessZ(gdl, ...) \ - gD_(gdl, gsSPBranchLessZ, __VA_ARGS__) -# define gSPBranchLessZrg(gdl, ...) \ - gD_(gdl, gsSPBranchLessZrg, __VA_ARGS__) -# define gSPBranchLessZraw(gdl, ...) \ - gD_(gdl, gsSPBranchLessZraw, __VA_ARGS__) -#endif -#define gSPBranchList(gdl, ...) \ - gD_(gdl, gsSPBranchList, __VA_ARGS__) -#define gSPClipRatio(gdl, ...) \ - gD_(gdl, gsSPClipRatio, __VA_ARGS__) -#define gSPCullDisplayList(gdl, ...) \ - gD_(gdl, gsSPCullDisplayList, __VA_ARGS__) -#define gSPDisplayList(gdl, ...) \ - gD_(gdl, gsSPDisplayList, __VA_ARGS__) -#define gSPEndDisplayList(gdl) \ - gDisplayListPut(gdl, gsSPEndDisplayList()) -#define gSPFogFactor(gdl, ...) \ - gD_(gdl, gsSPFogFactor, __VA_ARGS__) -#define gSPFogPosition(gdl, ...) \ - gD_(gdl, gsSPFogPosition, __VA_ARGS__) -#define gSPForceMatrix(gdl, ...) \ - gD_(gdl, gsSPForceMatrix, __VA_ARGS__) -#define gSPSetGeometryMode(gdl, ...) \ - gD_(gdl, gsSPSetGeometryMode, __VA_ARGS__) -#define gSPClearGeometryMode(gdl, ...) \ - gD_(gdl, gsSPClearGeometryMode, __VA_ARGS__) -#define gSPLoadGeometryMode(gdl, ...) \ - gD_(gdl, gsSPLoadGeometryMode, __VA_ARGS__) -#if defined(F3D_GBI) || defined(F3DEX_GBI) -# define gSPInsertMatrix(gdl, ...) \ - gD_(gdl, gsSPInsertMatrix, __VA_ARGS__) -#endif -#define gSPLine3D(gdl, ...) \ - gD_(gdl, gsSPLine3D, __VA_ARGS__) -#define gSPLineW3D(gdl, ...) \ - gD_(gdl, gsSPLineW3D, __VA_ARGS__) -#define gSPLoadUcode(gdl, ...) \ - gD_(gdl, gsSPLoadUcode, __VA_ARGS__) -#define gSPLoadUcodeL(gdl, ...) \ - gD_(gdl, gsSPLoadUcodeL, __VA_ARGS__) -#define gSPLookAtX(gdl, ...) \ - gD_(gdl, gsSPLookAtX, __VA_ARGS__) -#define gSPLookAtY(gdl, ...) \ - gD_(gdl, gsSPLookAtY, __VA_ARGS__) -#define gSPLookAt(gdl, ...) \ - gD_(gdl, gsSPLookAt, __VA_ARGS__) -#define gSPMatrix(gdl, ...) \ - gD_(gdl, gsSPMatrix, __VA_ARGS__) -#define gSPModifyVertex(gdl, ...) \ - gD_(gdl, gsSPModifyVertex, __VA_ARGS__) -#define gSPPerspNormalize(gdl, ...) \ - gD_(gdl, gsSPPerspNormalize, __VA_ARGS__) -#define gSPPopMatrix(gdl, ...) \ - gD_(gdl, gsSPPopMatrix, __VA_ARGS__) -#if defined(F3DEX_GBI_2) -# define gSPPopMatrixN(gdl, ...) \ - gD_(gdl, gsSPPopMatrixN, __VA_ARGS__) -#endif -#define gSPSegment(gdl, ...) \ - gD_(gdl, gsSPSegment, __VA_ARGS__) -#define gSPSetLights0(gdl, ...) \ - gD_(gdl, gsSPSetLights0, __VA_ARGS__) -#define gSPSetLights1(gdl, ...) \ - gD_(gdl, gsSPSetLights1, __VA_ARGS__) -#define gSPSetLights2(gdl, ...) \ - gD_(gdl, gsSPSetLights2, __VA_ARGS__) -#define gSPSetLights3(gdl, ...) \ - gD_(gdl, gsSPSetLights3, __VA_ARGS__) -#define gSPSetLights4(gdl, ...) \ - gD_(gdl, gsSPSetLights4, __VA_ARGS__) -#define gSPSetLights5(gdl, ...) \ - gD_(gdl, gsSPSetLights5, __VA_ARGS__) -#define gSPSetLights6(gdl, ...) \ - gD_(gdl, gsSPSetLights6, __VA_ARGS__) -#define gSPSetLights7(gdl, ...) \ - gD_(gdl, gsSPSetLights7, __VA_ARGS__) -#define gSPSetStatus(gdl, ...) \ - gD_(gdl, gsSPSetStatus, __VA_ARGS__) -#define gSPNumLights(gdl, ...) \ - gD_(gdl, gsSPNumLights, __VA_ARGS__) -#define gSPLight(gdl, ...) \ - gD_(gdl, gsSPLight, __VA_ARGS__) -#define gSPLightColor(gdl, ...) \ - gD_(gdl, gsSPLightColor, __VA_ARGS__) -#define gSPTexture(gdl, ...) \ - gD_(gdl, gsSPTexture, __VA_ARGS__) -#define gSPTextureRectangle(gdl, ...) \ - gD_(gdl, gsSPTextureRectangle, __VA_ARGS__) -#define gSPScisTextureRectangle(gdl, ...) \ - gD_(gdl, gsSPScisTextureRectangle, __VA_ARGS__) -#define gSPTextureRectangleFlip(gdl, ...) \ - gD_(gdl, gsSPTextureRectangleFlip, __VA_ARGS__) -#define gSPScisTextureRectangleFlip(gdl, ...) \ - gD_(gdl, gsSPScisTextureRectangleFlip, __VA_ARGS__) -#define gSPVertex(gdl, ...) \ - gD_(gdl, gsSPVertex, __VA_ARGS__) -#define gSPViewport(gdl, ...) \ - gD_(gdl, gsSPViewport, __VA_ARGS__) -#define gSPBgRectCopy(gdl, ...) \ - gD_(gdl, gsSPBgRectCopy, __VA_ARGS__) -#define gSPBgRect1Cyc(gdl, ...) \ - gD_(gdl, gsSPBgRect1Cyc, __VA_ARGS__) -#define gSPObjRectangle(gdl, ...) \ - gD_(gdl, gsSPObjRectangle, __VA_ARGS__) -#define gSPObjRectangleR(gdl, ...) \ - gD_(gdl, gsSPObjRectangleR, __VA_ARGS__) -#define gSPObjSprite(gdl, ...) \ - gD_(gdl, gsSPObjSprite, __VA_ARGS__) -#define gSPObjMatrix(gdl, ...) \ - gD_(gdl, gsSPObjMatrix, __VA_ARGS__) -#define gSPObjSubMatrix(gdl, ...) \ - gD_(gdl, gsSPObjSubMatrix, __VA_ARGS__) -#define gSPObjRenderMode(gdl, ...) \ - gD_(gdl, gsSPObjRenderMode, __VA_ARGS__) -#define gSPObjLoadTxtr(gdl, ...) \ - gD_(gdl, gsSPObjLoadTxtr, __VA_ARGS__) -#define gSPObjLoadTxRect(gdl, ...) \ - gD_(gdl, gsSPObjLoadTxRect, __VA_ARGS__) -#define gSPObjLoadTxRectR(gdl, ...) \ - gD_(gdl, gsSPObjLoadTxRectR, __VA_ARGS__) -#define gSPObjLoadTxSprite(gdl, ...) \ - gD_(gdl, gsSPObjLoadTxSprite, __VA_ARGS__) -#define gSPSelectDL(gdl, ...) \ - gD_(gdl, gsSPSelectDL, __VA_ARGS__) -#define gSPSelectBranchDL(gdl, ...) \ - gD_(gdl, gsSPSelectBranchDL, __VA_ARGS__) -#define gDPLoadTLUTCmd(gdl, ...) \ - gD_(gdl, gsDPLoadTLUTCmd, __VA_ARGS__) -#define gDPLoadTLUT(gdl, ...) \ - gD_(gdl, gsDPLoadTLUT, __VA_ARGS__) -#if defined(F3DEX_GBI) || defined(F3DEX_GBI_2) -# define gBranchZ(gdl, ...) \ - gD_(gdl, gsBranchZ, __VA_ARGS__) -#endif -#define gDisplayList(gdl, ...) \ - gD_(gdl, gsDisplayList, __VA_ARGS__) -#define gDPHalf1(gdl, ...) \ - gD_(gdl, gsDPHalf1, __VA_ARGS__) -#define gDPHalf2(gdl, ...) \ - gD_(gdl, gsDPHalf2, __VA_ARGS__) -#define gDPLoadTile(gdl, ...) \ - gD_(gdl, gsDPLoadTile, __VA_ARGS__) -#define gDPSetCombine(gdl, ...) \ - gD_(gdl, gsDPSetCombine, __VA_ARGS__) -#if defined(F3DEX_GBI_2) -# define gSPGeometryMode(gdl, ...) \ - gD_(gdl, gsSPGeometryMode, __VA_ARGS__) -#endif -#define gSPSetOtherMode(gdl, ...) \ - gD_(gdl, gsSPSetOtherMode, __VA_ARGS__) -#define gSPSetOtherModeLo(gdl, ...) \ - gD_(gdl, gsSPSetOtherModeLo, __VA_ARGS__) -#define gSPSetOtherModeHi(gdl, ...) \ - gD_(gdl, gsSPSetOtherModeHi, __VA_ARGS__) -#define gDPSetOtherMode(gdl, ...) \ - gD_(gdl, gsDPSetOtherMode, __VA_ARGS__) -#define gMoveWd(gdl, ...) \ - gD_(gdl, gsMoveWd, __VA_ARGS__) -#define gMoveMem(gdl, ...) \ - gD_(gdl, gsMoveMem, __VA_ARGS__) -#if defined(F3DEX_GBI_2) -# define gSPDma_io(gdl, ...) \ - gD_(gdl, gsSPDma_io, __VA_ARGS__) -# define gSPDmaRead(gdl, ...) \ - gD_(gdl, gsSPDmaRead, __VA_ARGS__) -# define gSPDmaWrite(gdl, ...) \ - gD_(gdl, gsSPDmaWrite, __VA_ARGS__) -#endif -#if defined(F3DEX_GBI) || defined(F3DEX_GBI_2) -# define gLoadUcode(gdl, ...) \ - gD_(gdl, gsLoadUcode, __VA_ARGS__) -# define gSPLoadUcodeEx(gdl, ...) \ - gD_(gdl, gsSPLoadUcodeEx, __VA_ARGS__) -#endif -#define gTexRect(gdl, ...) \ - gD_(gdl, gsTexRect, __VA_ARGS__) -#define gTexRectFlip(gdl, ...) \ - gD_(gdl, gsTexRectFlip, __VA_ARGS__) -#define gSPNoOp(gdl) \ - gDisplayListPut(gdl, gsSPNoOp()) -#define gDPWord(gdl, ...) \ - gD_(gdl, gsDPWord, __VA_ARGS__) -#if defined(F3DEX_GBI_2) -# define gSpecial3(gdl, ...) \ - gD_(gdl, gsSpecial3, __VA_ARGS__) -# define gSpecial2(gdl, ...) \ - gD_(gdl, gsSpecial2, __VA_ARGS__) -# define gSpecial1(gdl, ...) \ - gD_(gdl, gsSpecial1, __VA_ARGS__) -#endif - -/* data types and structures */ -typedef uint8_t qu08_t; -typedef uint16_t qu016_t; -typedef int16_t qs48_t; -typedef int16_t qs510_t; -typedef uint16_t qu510_t; -typedef int16_t qs102_t; -typedef uint16_t qu102_t; -typedef int16_t qs105_t; -typedef uint16_t qu105_t; -typedef int16_t qs132_t; -typedef int16_t qs142_t; -typedef int32_t qs1516_t; -typedef int32_t qs1616_t; -typedef int32_t qs205_t; - -typedef uint16_t g_bglt_t; -typedef uint8_t g_ifmt_t; -typedef uint8_t g_isiz_t; -typedef uint16_t g_bgf_t; -typedef uint8_t g_objf_t; -typedef uint32_t g_objlt_t; - -typedef struct -{ - _Alignas(8) - uint32_t hi; - uint32_t lo; -} Gfx; - -typedef struct -{ - int32_t x1; - int32_t y1; - int32_t x2; - int32_t y2; -} Hilite_t; - -typedef union -{ - _Alignas(8) - Hilite_t h; -} Hilite; - -typedef int32_t Mtx_t[4][4]; - -typedef union -{ - _Alignas(8) - Mtx_t m; - int32_t l[16]; - struct - { - int16_t i[16]; - uint16_t f[16]; - }; -} Mtx; - -typedef struct -{ - uint8_t col[3]; - char pad1; - uint8_t colc[3]; - char pad2; - int8_t dir[3]; - char pad3; -} Light_t; - -typedef union -{ - _Alignas(8) - Light_t l; -} Light; - -typedef struct -{ - Light l[2]; -} LookAt; - -typedef struct -{ - uint8_t col[3]; - char pad1; - uint8_t colc[3]; - char pad2; -} Ambient_t; - -typedef union -{ - _Alignas(8) - Ambient_t l; -} Ambient; - -typedef struct -{ - Ambient a; - Light l[1]; -} Lights0, Lights1; - -typedef struct -{ - Ambient a; - Light l[2]; -} Lights2; - -typedef struct -{ - Ambient a; - Light l[3]; -} Lights3; - -typedef struct -{ - Ambient a; - Light l[4]; -} Lights4; - -typedef struct -{ - Ambient a; - Light l[5]; -} Lights5; - -typedef struct -{ - Ambient a; - Light l[6]; -} Lights6; - -typedef struct -{ - Ambient a; - Light l[7]; -} Lightsn, Lights7; - -typedef struct -{ - int16_t ob[3]; - uint16_t flag; - qs105_t tc[2]; - uint8_t cn[4]; -} Vtx_t; - -typedef struct -{ - int16_t ob[3]; - uint16_t flag; - qs105_t tc[2]; - int8_t n[3]; - uint8_t a; -} Vtx_tn; - -typedef union -{ - _Alignas(8) - Vtx_t v; - Vtx_tn n; -} Vtx; - -typedef struct -{ - qs142_t vscale[4]; - qs142_t vtrans[4]; -} Vp_t; - -typedef union -{ - _Alignas(8) - Vp_t vp; -} Vp; - -typedef struct -{ - qs1516_t A; - qs1516_t B; - qs1516_t C; - qs1516_t D; - qs102_t X; - qs102_t Y; - qu510_t BaseScaleX; - qu510_t BaseScaleY; -} uObjMtx_t; - -typedef union -{ - _Alignas(8) - uObjMtx_t m; -} uObjMtx; - -typedef struct -{ - qs102_t X; - qs102_t Y; - qu510_t BaseScaleX; - qu510_t BaseScaleY; -} uObjSubMtx_t; - -typedef union -{ - _Alignas(8) - uObjSubMtx_t m; -} uObjSubMtx; - -typedef struct -{ - qu105_t imageX; - qu102_t imageW; - qs102_t frameX; - qu102_t frameW; - qu105_t imageY; - qu102_t imageH; - qs102_t frameY; - qu102_t frameH; - uint64_t * imagePtr; - g_bglt_t imageLoad; - g_ifmt_t imageFmt; - g_isiz_t imageSiz; - uint16_t imagePal; - g_bgf_t imageFlip; - uint16_t tmemW; - qs132_t tmemH; - uint16_t tmemLoadSH; - uint16_t tmemLoadTH; - uint16_t tmemSizeW; - uint16_t tmemSize; -} uObjBg_t; - -typedef struct -{ - qu105_t imageX; - qu102_t imageW; - qs102_t frameX; - qu102_t frameW; - qu105_t imageY; - qu102_t imageH; - qs102_t frameY; - qu102_t frameH; - uint64_t * imagePtr; - g_bglt_t imageLoad; - g_ifmt_t imageFmt; - g_isiz_t imageSiz; - uint16_t imagePal; - g_bgf_t imageFlip; - qu510_t scaleW; - qu510_t scaleH; - qs205_t imageYorig; - char padding[4]; -} uObjScaleBg_t; - -typedef union -{ - _Alignas(8) - uObjBg_t b; - uObjScaleBg_t s; -} uObjBg; - -typedef struct -{ - qs102_t objX; - qu510_t scaleW; - qu105_t imageW; - uint16_t paddingX; - qs102_t objY; - qu510_t scaleH; - qu105_t imageH; - uint16_t paddingY; - uint16_t imageStride; - uint16_t imageAdrs; - g_ifmt_t imageFmt; - g_isiz_t imageSiz; - uint16_t imagePal; - g_objf_t imageFlags; -} uObjSprite_t; - -typedef union -{ - _Alignas(8) - uObjSprite_t s; -} uObjSprite; - -typedef struct -{ - g_objlt_t type; - uint64_t * image; - uint16_t tmem; - uint16_t tsize; - uint16_t tline; - uint16_t sid; - uint32_t flag; - uint32_t mask; -} uObjTxtrBlock_t; - -typedef struct -{ - g_objlt_t type; - uint64_t * image; - uint16_t tmem; - uint16_t twidth; - uint16_t theight; - uint16_t sid; - uint32_t flag; - uint32_t mask; -} uObjTxtrTile_t; - -typedef struct -{ - g_objlt_t type; - uint64_t * image; - uint16_t phead; - uint16_t pnum; - uint16_t zero; - uint16_t sid; - uint32_t flag; - uint32_t mask; -} uObjTxtrTLUT_t; - -typedef union -{ - _Alignas(8) - uObjTxtrBlock_t block; - uObjTxtrTile_t tile; - uObjTxtrTLUT_t tlut; -} uObjTxtr; - -typedef struct -{ - uObjTxtr txtr; - uObjSprite sprite; -} uObjTxSprite; - -/* rectangle scissoring macros */ -#define gScC_(c) ((c) < 0 ? 0 : (c)) -#define gScD_(t, c, d) \ - ( \ - (c) < 0 ? \ - ( \ - (d) < 0 ? \ - (t) + (c) * (d) / 0x80 : \ - (t) - (c) * (d) / 0x80 \ - ) : \ - (t) \ - ) - -/* texture loading helper macros */ -#define G_SIZ_LDSIZ(siz) ((siz) < G_IM_SIZ_16b ? G_IM_SIZ_16b : (siz)) -#define G_SIZ_BITS(siz) (4 << gI_(siz)) -#define G_SIZ_LDBITS(siz) ((siz) < G_IM_SIZ_16b ? G_SIZ_BITS(siz) : 16) -#define G_DXT(siz, width) \ - ( \ - (width) * G_SIZ_BITS(siz) > 64 ? \ - ((1 << 11) + (width) * G_SIZ_BITS(siz) / 64 - 1) / \ - ((width) * G_SIZ_BITS(siz) / 64) : \ - (1 << 11) \ - ) -#define G_LTB_LRS(width, height, siz) \ - ( \ - (((width) * (height) + 1) * G_SIZ_BITS(siz) - 1) / \ - G_SIZ_BITS(G_SIZ_LDSIZ(siz)) - 1 \ - ) -#define G_LDBLK_TXL(txl) \ - ( \ - (txl) > G_TX_LDBLK_MAX_TXL ? \ - G_TX_LDBLK_MAX_TXL : \ - (txl) \ - ) - -/* depth value macros */ -#define gZp_(zval, near, far) \ - ( \ - (1.f - (float)(near) / (float)(zval)) / \ - (1.f - (float)(near) / (float)(far)) \ - ) -#define gZo_(zval, near, far) \ - ( \ - ((float)(zval) - (float)(near)) / \ - ((float)(far) - (float)(near)) \ - ) -#define gZf_(zval, near, far, flag) \ - qs1616 \ - ( \ - (flag) == G_BZ_PERSP ? \ - gZp_(zval, near, far) : \ - gZo_(zval, near, far) \ - ) -#define G_DEPTOZSrg(zval, near, far, flag, zmin, zmax) \ - ( \ - gZf_(zval, near, far, flag) * \ - ((int32_t)((zmax) - (zmin)) & ~(int32_t)1) + \ - qs1616(zmin) \ - ) -#define G_DEPTOZS(zval, near, far, flag) \ - G_DEPTOZSrg(zval, near, far, flag, 0, G_MAXZ) - -/* vertex ordering macros */ -#define gV2_(v0, v1, flag) \ - ( \ - (flag) == 0 ? gI_(v0) : \ - gI_(v1) \ - ) -#define gV3_(v0, v1, v2, flag) \ - ( \ - (flag) == 0 ? gI_(v0) : \ - (flag) == 1 ? gI_(v1) : \ - gI_(v2) \ - ) -#define gV4_(v0, v1, v2, v3, flag) \ - ( \ - (flag) == 0 ? gI_(v0) : \ - (flag) == 1 ? gI_(v1) : \ - (flag) == 2 ? gI_(v2) : \ - gI_(v3) \ - ) - -/* sprite texture parameter macros */ -#define GS_PIX2TMEM(pix, siz) ((pix) * G_SIZ_BITS(siz) / 64) -#define GS_TB_TSIZE(pix, siz) (GS_PIX2TMEM(pix, siz) - 1) -#define GS_TB_TLINE(pix, siz) (((1 << 11) - 1) / GS_PIX2TMEM(pix, siz) + 1) -#define GS_TT_TWIDTH(pix, siz) (GS_PIX2TMEM(pix, siz) * 4 - 1) -#define GS_TT_THEIGHT(pix, siz) ((pix) * 4 - 1) -#define GS_PAL_HEAD(head) ((head) + 256) -#define GS_PAL_NUM(num) ((num) - 1) - -/* fixed-point conversion macros */ -#define qu08(n) ((qu08_t)((n) * 0x100)) -#define qu016(n) ((qu016_t)((n) * 0x10000)) -#define qs48(n) ((qs48_t)((n) * 0x0100)) -#define qs510(n) ((qs510_t)((n) * 0x0400)) -#define qu510(n) ((qu510_t)((n) * 0x0400)) -#define qs102(n) ((qs102_t)((n) * 0x0004)) -#define qu102(n) ((qu102_t)((n) * 0x0004)) -#define qs105(n) ((qs105_t)((n) * 0x0020)) -#define qu105(n) ((qu105_t)((n) * 0x0020)) -#define qs132(n) ((qs132_t)((n) * 0x0004)) -#define qs142(n) ((qs142_t)((n) * 0x0004)) -#define qs1516(n) ((qs1516_t)((n) * 0x00010000)) -#define qs1616(n) ((qs1616_t)((n) * 0x00010000)) -#define qs205(n) ((qs205_t)((n) * 0x00000020)) - -/* private helper macros */ -#define gI_(i) ((uint32_t)(i)) -#define gL_(l) ((uint64_t)(l)) -#define gF_(i, n, s) ((gI_(i) & ((gI_(1) << (n)) - 1)) << (s)) -#define gFL_(l, n, s) ((gL_(l) & ((gL_(1) << (n)) - 1)) << (s)) -#define gO_(opc, hi, lo) ((Gfx){gF_(opc, 8, 24) | gI_(hi), gI_(lo)}) -#define gD_(gdl, m, ...) gDisplayListPut(gdl, m(__VA_ARGS__)) - -#endif diff --git a/ZAPDTR/lib/libgfxd/gfxd.c b/ZAPDTR/lib/libgfxd/gfxd.c deleted file mode 100644 index 76d7ded8a..000000000 --- a/ZAPDTR/lib/libgfxd/gfxd.c +++ /dev/null @@ -1,863 +0,0 @@ -#include -#include -#include -#include -#include -#ifdef _WIN32 -# include -# define read _read -# define write _write -#else -# include -#endif -#include "gbi.h" -#include "gfxd.h" -#include "priv.h" - -static TLOCAL struct gfxd_state state; - -static int buffer_input_fn(void *buf, int count) -{ - if (count > config.input_buf_size) - count = config.input_buf_size; - memcpy(buf, config.input_buf, count); - config.input_buf += count; - config.input_buf_size -= count; - return count; -} - -static int buffer_output_fn(const char *buf, int count) -{ - if (count > config.output_buf_size) - count = config.output_buf_size; - memcpy(config.output_buf, buf, count); - config.output_buf += count; - config.output_buf_size -= count; - return count; -} - -static int fd_input_fn(void *buf, int count) -{ - return read(config.input_fd, buf, count); -} - -static int fd_output_fn(const char *buf, int count) -{ - return write(config.output_fd, buf, count); -} - -static void swap_words(Gfx *gfx) -{ - uint8_t b[8]; - uint8_t *pw = (void *) gfx; - uint8_t *pb = b; - - int endian = config.endian; - int wordsize = config.wordsize; - - for (int i = 0; i < 8 / wordsize; i++) - { - if (endian == gfxd_endian_host) - { - switch (wordsize) - { - case 1: - { - uint8_t w = *(uint8_t *) pw; - *pb++ = w >> 0; - break; - } - case 2: - { - uint16_t w = *(uint16_t *) pw; - *pb++ = w >> 8; - *pb++ = w >> 0; - break; - } - case 4: - { - uint32_t w = *(uint32_t *) pw; - *pb++ = w >> 24; - *pb++ = w >> 16; - *pb++ = w >> 8; - *pb++ = w >> 0; - break; - } - case 8: - { - uint64_t w = *(uint64_t *) pw; - *pb++ = w >> 56; - *pb++ = w >> 48; - *pb++ = w >> 40; - *pb++ = w >> 32; - *pb++ = w >> 24; - *pb++ = w >> 16; - *pb++ = w >> 8; - *pb++ = w >> 0; - break; - } - } - } - else - { - for (int j = 0; j < wordsize; j++) - { - if (endian == gfxd_endian_little) - *pb++ = pw[wordsize - 1 - j]; - else - *pb++ = pw[j]; - } - } - pw += wordsize; - } - - gfx->hi = ((uint32_t) b[0] << 24) - | ((uint32_t) b[1] << 16) - | ((uint32_t) b[2] << 8) - | ((uint32_t) b[3] << 0); - gfx->lo = ((uint32_t) b[4] << 24) - | ((uint32_t) b[5] << 16) - | ((uint32_t) b[6] << 8) - | ((uint32_t) b[7] << 0); -} - -static void get_more_input(void) -{ - if (state.end_input != 0) - return; - - char *recv_buf = (void *) &state.gfx[0]; - - while (state.n_gfx < sizeof(state.gfx) / sizeof(state.gfx[0])) - { - int n_read = sizeof(state.gfx) - state.n_byte; - n_read = config.input_fn(&recv_buf[state.n_byte], n_read); - if (n_read == 0) - return; - state.n_byte += n_read; - - while (state.n_gfx < state.n_byte / sizeof(Gfx)) - { - Gfx gfx = state.gfx[state.n_gfx]; - gfxd_macro_t *m = &state.macro[state.n_gfx]; - - swap_words(&gfx); - - int ret = config.ucode->disas_fn(m, gfx.hi, gfx.lo); - if (ret != 0 && config.stop_on_invalid != 0) - { - state.end_input = 1; - state.ret = ret; - return; - } - - state.n_gfx++; - } - } -} - -static int32_t typed_arg_i(int type, int idx) -{ - const gfxd_value_t *v = gfxd_value_by_type(type, idx); - if (v != NULL) - return v->i; - else - return -1; -} - -static uint32_t typed_arg_u(int type, int idx) -{ - const gfxd_value_t *v = gfxd_value_by_type(type, idx); - if (v != NULL) - return v->u; - else - return 0; -} - - -TLOCAL struct gfxd_config config = -{ - .ucode = NULL, - .endian = gfxd_endian_big, - .wordsize = 4, - .arg = NULL, - - .stop_on_invalid = 1, - .stop_on_end = 1, - .emit_dec_color = 0, - .emit_q_macro = 0, - .emit_ext_macro = 0, - - .input_buf = NULL, - .input_buf_size = 0, - .input_fn = &buffer_input_fn, - - .output_buf = NULL, - .output_buf_size = 0, - .output_fn = &buffer_output_fn, - - .macro_fn = &gfxd_macro_dflt, - .arg_fn = &gfxd_arg_dflt, - - .tlut_fn = NULL, - .timg_fn = NULL, - .cimg_fn = NULL, - .zimg_fn = NULL, - .dl_fn = NULL, - .mtx_fn = NULL, - .lookat_fn = NULL, - .light_fn = NULL, - .seg_fn = NULL, - .vtx_fn = NULL, - .vp_fn = NULL, - .uctext_fn = NULL, - .ucdata_fn = NULL, - .dram_fn = NULL, -}; - -void gfxd_input_buffer(const void *buf, int size) -{ - config.input_buf = buf; - config.input_buf_size = size; - config.input_fn = &buffer_input_fn; -} - -void gfxd_output_buffer(char *buf, int size) -{ - config.output_buf = buf; - config.output_buf_size = size; - config.output_fn = &buffer_output_fn; -} - -void gfxd_input_fd(int fd) -{ - config.input_fd = fd; - config.input_fn = &fd_input_fn; -} - -void gfxd_output_fd(int fd) -{ - config.output_fd = fd; - config.output_fn = &fd_output_fn; -} - -void gfxd_input_callback(gfxd_input_fn_t *fn) -{ - if (fn != NULL) - config.input_fn = fn; - else - gfxd_input_buffer(NULL, 0); -} - -void gfxd_output_callback(gfxd_output_fn_t *fn) -{ - if (fn != NULL) - config.output_fn = fn; - else - gfxd_output_buffer(NULL, 0); -} - -void gfxd_macro_fn(gfxd_macro_fn_t *fn) -{ - if (fn != NULL) - config.macro_fn = fn; - else - config.macro_fn = gfxd_macro_dflt; -} - -void gfxd_arg_fn(gfxd_arg_fn_t *fn) -{ - if (fn != NULL) - config.arg_fn = fn; - else - config.arg_fn = gfxd_arg_dflt; -} - -int gfxd_write(const void *buf, int count) -{ - return config.output_fn(buf, count); -} - -int gfxd_puts(const char *str) -{ - return gfxd_write(str, strlen(str)); -} - -int gfxd_printf(const char *fmt, ...) -{ - char s[256]; - - va_list arg; - va_start(arg, fmt); - int n = vsnprintf(s, sizeof(s), fmt, arg); - va_end(arg); - - if (n > sizeof(s) - 1) - n = sizeof(s) - 1; - - return gfxd_write(s, n); -} - -int gfxd_print_value(int type, const gfxd_value_t *value) -{ - return config.ucode->arg_tbl[type].fn(value); -} - -int gfxd_macro_dflt(void) -{ - gfxd_macro_t *m = &state.macro[0]; - const gfxd_macro_type_t *t = &config.ucode->macro_tbl[m->id]; - - const char *name = gfxd_macro_name(); - if (name == NULL) - { - if (config.arg != NULL) - { - gfxd_puts(config.arg); - gfxd_puts(" = "); - } - - gfxd_puts("(Gfx){"); - } - else - { - gfxd_puts(name); - gfxd_puts("("); - - if (config.arg != NULL) - { - gfxd_puts(config.arg); - if (t->n_arg != 0) - gfxd_puts(", "); - } - } - - for (int i = 0; i < t->n_arg; i++) - { - if (i != 0) - gfxd_puts(", "); - - config.arg_fn(i); - } - - if (name == NULL) - gfxd_puts("}"); - else - gfxd_puts(")"); - - return 0; -} - -int gfxd_arg_callbacks(int arg_num) -{ - int id = gfxd_macro_id(); - - switch (gfxd_arg_type(arg_num)) - { - case gfxd_Tlut: - { - if (config.tlut_fn != NULL) - { - int32_t num; - if (id == gfxd_DPLoadTLUT_pal16) - num = 16; - else if (id == gfxd_DPLoadTLUT_pal256) - num = 256; - else - num = typed_arg_i(gfxd_Num, 0); - return config.tlut_fn( - typed_arg_u(gfxd_Tlut, 0), - typed_arg_i(gfxd_Pal, 0), - num); - } - break; - } - case gfxd_Timg: - { - if (config.timg_fn != NULL) - { - int32_t siz = typed_arg_i(gfxd_Siz, 0); - if (siz == -1) - siz = G_IM_SIZ_4b; - return config.timg_fn( - typed_arg_u(gfxd_Timg, 0), - typed_arg_i(gfxd_Fmt, 0), - siz, - typed_arg_i(gfxd_Dim, 0), - typed_arg_i(gfxd_Dim, 1), - typed_arg_i(gfxd_Pal, 0)); - } - break; - } - case gfxd_Cimg: - { - if (config.cimg_fn != NULL) - { - return config.cimg_fn( - typed_arg_u(gfxd_Cimg, 0), - typed_arg_i(gfxd_Fmt, 0), - typed_arg_i(gfxd_Siz, 0), - typed_arg_i(gfxd_Dim, 0)); - } - break; - } - case gfxd_Zimg: - { - if (config.zimg_fn != NULL) - { - return config.zimg_fn( - typed_arg_u(gfxd_Zimg, 0)); - } - break; - } - case gfxd_Dl: - { - if (config.dl_fn != NULL) - { - return config.dl_fn( - typed_arg_u(gfxd_Dl, 0)); - } - break; - } - case gfxd_Mtxptr: - { - if (config.mtx_fn != NULL) - { - return config.mtx_fn( - typed_arg_u(gfxd_Mtxptr, 0)); - } - break; - } - case gfxd_Lookatptr: - { - if (config.lookat_fn != NULL) - { - int32_t num; - if (id == gfxd_SPLookAt) - num = 2; - else - num = 1; - return config.lookat_fn( - typed_arg_u(gfxd_Lookatptr, 0), - num); - } - break; - } - case gfxd_Lightptr: - { - if (config.light_fn != NULL) - { - int32_t num; - if (id == gfxd_SPSetLights1) - num = 1; - else if (id == gfxd_SPSetLights2) - num = 2; - else if (id == gfxd_SPSetLights3) - num = 3; - else if (id == gfxd_SPSetLights4) - num = 4; - else if (id == gfxd_SPSetLights5) - num = 5; - else if (id == gfxd_SPSetLights6) - num = 6; - else if (id == gfxd_SPSetLights7) - num = 7; - else - num = 1; - return config.light_fn( - typed_arg_u(gfxd_Lightptr, 0), - num); - } - break; - - } - case gfxd_Segptr: - { - if (config.seg_fn != NULL) - { - return config.seg_fn( - typed_arg_u(gfxd_Segptr, 0), - typed_arg_i(gfxd_Seg, 0)); - } - break; - } - case gfxd_Vtxptr: - { - if (config.vtx_fn != NULL) - { - return config.vtx_fn( - typed_arg_u(gfxd_Vtxptr, 0), - typed_arg_i(gfxd_Num, 0)); - } - break; - } - case gfxd_Vpptr: - { - if (config.vp_fn != NULL) - { - return config.vp_fn( - typed_arg_u(gfxd_Vpptr, 0)); - } - break; - } - case gfxd_Uctext: - { - if (config.uctext_fn != NULL) - { - return config.uctext_fn( - typed_arg_u(gfxd_Uctext, 0), - 0x1000); - } - break; - } - case gfxd_Ucdata: - { - if (config.ucdata_fn != NULL) - { - uint32_t size; - if (id == gfxd_SPLoadUcodeEx) - size = typed_arg_u(gfxd_Size, 0); - else - size = 0x800; - return config.ucdata_fn( - typed_arg_u(gfxd_Ucdata, 0), - size); - } - break; - } - case gfxd_Dram: - { - if (config.dram_fn != NULL) - { - return config.dram_fn( - typed_arg_u(gfxd_Dram, 0), - typed_arg_u(gfxd_Size, 0)); - } - break; - } - } - - return 0; -} - -void gfxd_arg_dflt(int arg_num) -{ - if (gfxd_arg_callbacks(arg_num) == 0) - { - gfxd_arg_t *a = &state.macro[0].arg[arg_num]; - - gfxd_print_value(a->type, &a->value); - } -} - -void gfxd_tlut_callback(gfxd_tlut_fn_t *fn) -{ - config.tlut_fn = fn; -} - -void gfxd_timg_callback(gfxd_timg_fn_t *fn) -{ - config.timg_fn = fn; -} - -void gfxd_cimg_callback(gfxd_cimg_fn_t *fn) -{ - config.cimg_fn = fn; -} - -void gfxd_zimg_callback(gfxd_zimg_fn_t *fn) -{ - config.zimg_fn = fn; -} - -void gfxd_dl_callback(gfxd_dl_fn_t *fn) -{ - config.dl_fn = fn; -} - -void gfxd_mtx_callback(gfxd_mtx_fn_t *fn) -{ - config.mtx_fn = fn; -} - -void gfxd_lookat_callback(gfxd_lookat_fn_t *fn) -{ - config.lookat_fn = fn; -} - -void gfxd_light_callback(gfxd_light_fn_t *fn) -{ - config.light_fn = fn; -} - -void gfxd_seg_callback(gfxd_seg_fn_t *fn) -{ - config.seg_fn = fn; -} - -void gfxd_vtx_callback(gfxd_vtx_fn_t *fn) -{ - config.vtx_fn = fn; -} - -void gfxd_vp_callback(gfxd_vp_fn_t *fn) -{ - config.vp_fn = fn; -} - -void gfxd_uctext_callback(gfxd_uctext_fn_t *fn) -{ - config.uctext_fn = fn; -} - -void gfxd_ucdata_callback(gfxd_ucdata_fn_t *fn) -{ - config.ucdata_fn = fn; -} - -void gfxd_dram_callback(gfxd_dram_fn_t *fn) -{ - config.dram_fn = fn; -} - -void gfxd_target(gfxd_ucode_t ucode) -{ - config.ucode = ucode; -} - -void gfxd_endian(int endian, int wordsize) -{ - config.endian = endian; - config.wordsize = wordsize; -} - -void gfxd_dynamic(const char *arg) -{ - config.arg = arg; -} - -void gfxd_enable(int cap) -{ - switch (cap) - { - case gfxd_stop_on_invalid: - config.stop_on_invalid = 1; - break; - - case gfxd_stop_on_end: - config.stop_on_end = 1; - break; - - case gfxd_emit_dec_color: - config.emit_dec_color = 1; - break; - - case gfxd_emit_q_macro: - config.emit_q_macro = 1; - break; - - case gfxd_emit_ext_macro: - config.emit_ext_macro = 1; - break; - } -} - -void gfxd_disable(int cap) -{ - switch (cap) - { - case gfxd_stop_on_invalid: - config.stop_on_invalid = 0; - return; - - case gfxd_stop_on_end: - config.stop_on_end = 0; - return; - - case gfxd_emit_dec_color: - config.emit_dec_color = 0; - break; - - case gfxd_emit_q_macro: - config.emit_q_macro = 0; - break; - - case gfxd_emit_ext_macro: - config.emit_ext_macro = 0; - break; - } -} - -void gfxd_udata_set(void *ptr) -{ - config.udata = ptr; -} - -void *gfxd_udata_get(void) -{ - return config.udata; -} - -int gfxd_execute(void) -{ - state.macro_offset = 0; - state.n_byte = 0; - state.n_gfx = 0; - state.end_input = 0; - state.ret = 0; - - for (;;) - { - get_more_input(); - if (state.n_gfx == 0) - break; - - gfxd_macro_t *m = &state.macro[0]; - config.ucode->combine_fn(m, state.n_gfx); - - const gfxd_macro_type_t *t = &config.ucode->macro_tbl[m->id]; - if (t->ext != 0 && config.emit_ext_macro == 0) - { - Gfx gfx = state.gfx[0]; - swap_words(&gfx); - - t = &config.ucode->macro_tbl[gfxd_Invalid]; - t->disas_fn(m, gfx.hi, gfx.lo); - } - - int ret = config.macro_fn(); - if (ret != 0) - { - state.ret = ret; - break; - } - - if (config.stop_on_end != 0 - && (m->id == gfxd_SPBranchList - || m->id == gfxd_SPEndDisplayList)) - { - break; - } - - int n_pop = config.ucode->macro_tbl[m->id].n_gfx; - int n_rem = state.n_gfx - n_pop; - { - int n_byte = n_rem * sizeof(gfxd_macro_t); - memmove(&state.macro[0], &state.macro[n_pop], n_byte); - state.n_gfx = n_rem; - } - { - int n_byte = n_rem * sizeof(Gfx); - memmove(&state.gfx[0], &state.gfx[n_pop], n_byte); - state.n_byte = n_byte; - } - state.macro_offset += n_pop * sizeof(Gfx); - } - - return state.ret; -} - -int gfxd_macro_offset(void) -{ - return state.macro_offset; -} - -int gfxd_macro_packets(void) -{ - return config.ucode->macro_tbl[state.macro[0].id].n_gfx; -} - -const void *gfxd_macro_data(void) -{ - return state.gfx; -} - -int gfxd_macro_id(void) -{ - return state.macro[0].id; -} - -const char *gfxd_macro_name(void) -{ - int id = state.macro[0].id; - const gfxd_macro_type_t *t = &config.ucode->macro_tbl[id]; - - if (t->prefix == NULL && t->suffix == NULL) - { - return NULL; - } - else - { - static TLOCAL char buf[32]; - - char *p = buf; - if (t->prefix != NULL) - { - const char *s = t->prefix; - while (*s != '\0') - *p++ = *s++; - } - *p++ = 'g'; - if (config.arg == NULL) - *p++ = 's'; - if (t->suffix != NULL) - { - const char *s = t->suffix; - while (*s != '\0') - *p++ = *s++; - } - *p++ = '\0'; - - return buf; - } -} - -int gfxd_arg_count(void) -{ - return config.ucode->macro_tbl[state.macro[0].id].n_arg; -} - -int gfxd_arg_type(int arg_num) -{ - return state.macro[0].arg[arg_num].type; -} - -const char *gfxd_arg_name(int arg_num) -{ - return state.macro[0].arg[arg_num].name; -} - -int gfxd_arg_fmt(int arg_num) -{ - return config.ucode->arg_tbl[state.macro[0].arg[arg_num].type].fmt; -} - -const gfxd_value_t *gfxd_arg_value(int arg_num) -{ - return &state.macro[0].arg[arg_num].value; -} - -const gfxd_value_t *gfxd_value_by_type(int type, int idx) -{ - gfxd_macro_t *m = &state.macro[0]; - const gfxd_macro_type_t *t = &config.ucode->macro_tbl[m->id]; - - for (int i = 0; i < t->n_arg; i++) - { - gfxd_arg_t *a = &m->arg[i]; - if (a->type == type) - { - if (idx == 0) - return &a->value; - else - idx--; - } - } - - return NULL; -} - -int gfxd_arg_valid(int arg_num) -{ - return state.macro[0].arg[arg_num].bad == 0; -} diff --git a/ZAPDTR/lib/libgfxd/gfxd.h b/ZAPDTR/lib/libgfxd/gfxd.h deleted file mode 100644 index 268bbfa10..000000000 --- a/ZAPDTR/lib/libgfxd/gfxd.h +++ /dev/null @@ -1,387 +0,0 @@ -#ifndef GFXD_H -#define GFXD_H -#include - -#ifdef __cplusplus -extern "C" -{ -#endif - -enum -{ - gfxd_Word, /* generic word */ - gfxd_Opcode, /* command opcode (G_*) */ - gfxd_Coordi, /* integer coordinate */ - gfxd_Coordq, /* fractional (q10.2) coordinate */ - gfxd_Pal, /* palette index */ - gfxd_Tlut, /* tlut pointer */ - gfxd_Timg, /* texture image pointer */ - gfxd_Tmem, /* tmem address */ - gfxd_Tile, /* tile index */ - gfxd_Fmt, /* texture format */ - gfxd_Siz, /* texture pixel size */ - gfxd_Dim, /* integer dimension (width / height) */ - gfxd_Cm, /* clamp and mirror flags */ - gfxd_Tm, /* tile mask */ - gfxd_Ts, /* tile shift */ - gfxd_Dxt, /* texture dxt */ - gfxd_Tag, /* generic tag */ - gfxd_Pm, /* pipeline mode */ - gfxd_Colorpart, /* color component */ - gfxd_Color, /* color */ - gfxd_Lodfrac, /* lod fraction (q0.8) */ - gfxd_Cimg, /* color image pointer */ - gfxd_Zimg, /* depth image pointer */ - gfxd_Ac, /* alpha compare mode */ - gfxd_Ad, /* alpha dither mode */ - gfxd_Cd, /* color dither mode */ - gfxd_Ccpre, /* color combiner preset index */ - gfxd_Ccmuxa, /* color mux operand (a) */ - gfxd_Ccmuxb, /* color mux operand (b) */ - gfxd_Ccmuxc, /* color mux operand (c) */ - gfxd_Ccmuxd, /* color mux operand (d) */ - gfxd_Acmuxabd, /* alpha mux operand (a, b, or d) */ - gfxd_Acmuxc, /* alpha mux operand (c) */ - gfxd_Cv, /* color convert operand */ - gfxd_Tc, /* texture convert mode */ - gfxd_Cyc, /* cycle type */ - gfxd_Zs, /* depth source mode */ - gfxd_Ck, /* combine key mode */ - gfxd_Keyscale, /* combine key scale */ - gfxd_Keywidth, /* combine key width */ - gfxd_Zi, /* integer depth */ - gfxd_Rm1, /* cycle 1 render mode */ - gfxd_Rm2, /* cycle 2 render mode */ - gfxd_Sc, /* scissor mode */ - gfxd_Td, /* texture detail mode */ - gfxd_Tf, /* texture filter mode */ - gfxd_Tl, /* texture LOD mode */ - gfxd_Tt, /* textuure LUT mode */ - gfxd_Tp, /* texture perspective mode */ - gfxd_Line, /* texture line size */ - gfxd_Vtx, /* vertex index */ - gfxd_Vtxflag, /* vertex flag */ - gfxd_Dl, /* display list pointer */ - gfxd_Zraw, /* raw depth value (q16.16) */ - gfxd_Dlflag, /* display list flag */ - gfxd_Cr, /* clip ratio */ - gfxd_Num, /* element count */ - gfxd_Fogz, /* fog factor */ - gfxd_Fogp, /* fog position (0 - 1000) */ - gfxd_Mtxptr, /* matrix pointer */ - gfxd_Gm, /* geometry mode */ - gfxd_Mwo_matrix, /* matrix moveword offset */ - gfxd_Linewd, /* line width (1.5 + q7.1) */ - gfxd_Uctext, /* microcode text pointer */ - gfxd_Ucdata, /* microcode data pointer */ - gfxd_Size, /* data size */ - gfxd_Lookatptr, /* lookat pointer */ - gfxd_Mtxparam, /* matrix param */ - gfxd_Mtxstack, /* matrix param (stack select only) */ - gfxd_Mwo_point, /* vertex moveword offset */ - gfxd_Wscale, /* w-component scale (perspnorm) */ - gfxd_Seg, /* segment number */ - gfxd_Segptr, /* segment pointer */ - gfxd_Lightsn, /* dereferenced Lighstn pointer */ - gfxd_Numlights, /* light count (NUMLIGHTS_*) */ - gfxd_Lightnum, /* light number (LIGHT_*) */ - gfxd_Lightptr, /* light pointer */ - gfxd_Tcscale, /* texture coordinate scale */ - gfxd_Switch, /* on-off value */ - gfxd_St, /* vertex coordinate (q10.5) */ - gfxd_Stdelta, /* vertex coordinate delta (q5.10) */ - gfxd_Vtxptr, /* vertex pointer */ - gfxd_Vpptr, /* viewport pointer */ - gfxd_Dram, /* generic dram address */ - gfxd_Sftlo, /* othermode lo shift */ - gfxd_Othermodelo, /* othermode lo value */ - gfxd_Sfthi, /* othermode hi shift */ - gfxd_Othermodehi, /* othermode hi value */ - gfxd_Mw, /* moveword index */ - gfxd_Mwo, /* moveword offset */ - gfxd_Mwo_clip, /* clip ratio moveword offset */ - gfxd_Mwo_lightcol, /* light color moveword offset */ - gfxd_Mv, /* movemem index */ - gfxd_Mvo, /* movemem offset */ - gfxd_Dmem, /* dmem address */ - gfxd_Dmaflag, /* dma io flag */ -}; - -enum -{ - gfxd_Invalid, - gfxd_DPFillRectangle, - gfxd_DPFullSync, - gfxd_DPLoadSync, - gfxd_DPTileSync, - gfxd_DPPipeSync, - gfxd_DPLoadTLUT_pal16, - gfxd_DPLoadTLUT_pal256, - gfxd_DPLoadMultiBlockYuvS, - gfxd_DPLoadMultiBlockYuv, - gfxd_DPLoadMultiBlock_4bS, - gfxd_DPLoadMultiBlock_4b, - gfxd_DPLoadMultiBlockS, - gfxd_DPLoadMultiBlock, - gfxd__DPLoadTextureBlockYuvS, - gfxd__DPLoadTextureBlockYuv, - gfxd__DPLoadTextureBlock_4bS, - gfxd__DPLoadTextureBlock_4b, - gfxd__DPLoadTextureBlockS, - gfxd__DPLoadTextureBlock, - gfxd_DPLoadTextureBlockYuvS, - gfxd_DPLoadTextureBlockYuv, - gfxd_DPLoadTextureBlock_4bS, - gfxd_DPLoadTextureBlock_4b, - gfxd_DPLoadTextureBlockS, - gfxd_DPLoadTextureBlock, - gfxd_DPLoadMultiTileYuv, - gfxd_DPLoadMultiTile_4b, - gfxd_DPLoadMultiTile, - gfxd__DPLoadTextureTileYuv, - gfxd__DPLoadTextureTile_4b, - gfxd__DPLoadTextureTile, - gfxd_DPLoadTextureTileYuv, - gfxd_DPLoadTextureTile_4b, - gfxd_DPLoadTextureTile, - gfxd_DPLoadBlock, - gfxd_DPNoOp, - gfxd_DPNoOpTag, - gfxd_DPPipelineMode, - gfxd_DPSetBlendColor, - gfxd_DPSetEnvColor, - gfxd_DPSetFillColor, - gfxd_DPSetFogColor, - gfxd_DPSetPrimColor, - gfxd_DPSetColorImage, - gfxd_DPSetDepthImage, - gfxd_DPSetTextureImage, - gfxd_DPSetAlphaCompare, - gfxd_DPSetAlphaDither, - gfxd_DPSetColorDither, - gfxd_DPSetCombineMode, - gfxd_DPSetCombineLERP, - gfxd_DPSetConvert, - gfxd_DPSetTextureConvert, - gfxd_DPSetCycleType, - gfxd_DPSetDepthSource, - gfxd_DPSetCombineKey, - gfxd_DPSetKeyGB, - gfxd_DPSetKeyR, - gfxd_DPSetPrimDepth, - gfxd_DPSetRenderMode, - gfxd_DPSetScissor, - gfxd_DPSetScissorFrac, - gfxd_DPSetTextureDetail, - gfxd_DPSetTextureFilter, - gfxd_DPSetTextureLOD, - gfxd_DPSetTextureLUT, - gfxd_DPSetTexturePersp, - gfxd_DPSetTile, - gfxd_DPSetTileSize, - gfxd_SP1Triangle, - gfxd_SP2Triangles, - gfxd_SP1Quadrangle, - gfxd_SPBranchLessZraw, - gfxd_SPBranchList, - gfxd_SPClipRatio, - gfxd_SPCullDisplayList, - gfxd_SPDisplayList, - gfxd_SPEndDisplayList, - gfxd_SPFogFactor, - gfxd_SPFogPosition, - gfxd_SPForceMatrix, - gfxd_SPSetGeometryMode, - gfxd_SPClearGeometryMode, - gfxd_SPLoadGeometryMode, - gfxd_SPInsertMatrix, - gfxd_SPLine3D, - gfxd_SPLineW3D, - gfxd_SPLoadUcode, - gfxd_SPLookAtX, - gfxd_SPLookAtY, - gfxd_SPLookAt, - gfxd_SPMatrix, - gfxd_SPModifyVertex, - gfxd_SPPerspNormalize, - gfxd_SPPopMatrix, - gfxd_SPPopMatrixN, - gfxd_SPSegment, - gfxd_SPSetLights1, - gfxd_SPSetLights2, - gfxd_SPSetLights3, - gfxd_SPSetLights4, - gfxd_SPSetLights5, - gfxd_SPSetLights6, - gfxd_SPSetLights7, - gfxd_SPNumLights, - gfxd_SPLight, - gfxd_SPLightColor, - gfxd_SPTexture, - gfxd_SPTextureRectangle, - gfxd_SPTextureRectangleFlip, - gfxd_SPVertex, - gfxd_SPViewport, - gfxd_DPLoadTLUTCmd, - gfxd_DPLoadTLUT, - gfxd_BranchZ, - gfxd_DisplayList, - gfxd_DPHalf1, - gfxd_DPHalf2, - gfxd_DPWord, - gfxd_DPLoadTile, - gfxd_SPGeometryMode, - gfxd_SPSetOtherMode, - gfxd_SPSetOtherModeLo, - gfxd_SPSetOtherModeHi, - gfxd_DPSetOtherMode, - gfxd_MoveWd, - gfxd_MoveMem, - gfxd_SPDma_io, - gfxd_SPDmaRead, - gfxd_SPDmaWrite, - gfxd_LoadUcode, - gfxd_SPLoadUcodeEx, - gfxd_TexRect, - gfxd_TexRectFlip, - gfxd_SPNoOp, - gfxd_Special3, - gfxd_Special2, - gfxd_Special1, -}; - -enum -{ - gfxd_stop_on_invalid, - gfxd_stop_on_end, - gfxd_emit_dec_color, - gfxd_emit_q_macro, - gfxd_emit_ext_macro, -}; - -enum -{ - gfxd_endian_big, - gfxd_endian_little, - gfxd_endian_host, -}; - -enum -{ - gfxd_argfmt_i, - gfxd_argfmt_u, - gfxd_argfmt_f, -}; - -typedef union -{ - int32_t i; - uint32_t u; - float f; -} gfxd_value_t; - -typedef const struct gfxd_ucode *gfxd_ucode_t; - -typedef int gfxd_input_fn_t(void *buf, int count); -void gfxd_input_buffer(const void *buf, int size); -void gfxd_input_fd(int fd); -void gfxd_input_callback(gfxd_input_fn_t *fn); - -typedef int gfxd_output_fn_t(const char *buf, int count); -void gfxd_output_buffer(char *buf, int size); -void gfxd_output_fd(int fd); -void gfxd_output_callback(gfxd_output_fn_t *fn); - -typedef int gfxd_macro_fn_t(void); -void gfxd_macro_fn(gfxd_macro_fn_t *fn); -gfxd_macro_fn_t gfxd_macro_dflt; - -typedef void gfxd_arg_fn_t(int arg_num); -void gfxd_arg_fn(gfxd_arg_fn_t *fn); -gfxd_arg_fn_t gfxd_arg_dflt; - -typedef int gfxd_tlut_fn_t(uint32_t tlut, int32_t idx, int32_t count); -void gfxd_tlut_callback(gfxd_tlut_fn_t *fn); - -typedef int gfxd_timg_fn_t(uint32_t timg, int32_t fmt, int32_t siz, - int32_t width, int32_t height, int32_t pal); -void gfxd_timg_callback(gfxd_timg_fn_t *fn); - -typedef int gfxd_cimg_fn_t(uint32_t cimg, int32_t fmt, int32_t siz, - int32_t width); -void gfxd_cimg_callback(gfxd_cimg_fn_t *fn); - -typedef int gfxd_zimg_fn_t(uint32_t zimg); -void gfxd_zimg_callback(gfxd_zimg_fn_t *fn); - -typedef int gfxd_dl_fn_t(uint32_t dl); -void gfxd_dl_callback(gfxd_dl_fn_t *fn); - -typedef int gfxd_mtx_fn_t(uint32_t mtx); -void gfxd_mtx_callback(gfxd_mtx_fn_t *fn); - -typedef int gfxd_lookat_fn_t(uint32_t lookat, int32_t count); -void gfxd_lookat_callback(gfxd_lookat_fn_t *fn); - -typedef int gfxd_light_fn_t(uint32_t light, int32_t count); -void gfxd_light_callback(gfxd_light_fn_t *fn); - -typedef int gfxd_seg_fn_t(uint32_t seg, int32_t num); -void gfxd_seg_callback(gfxd_seg_fn_t *fn); - -typedef int gfxd_vtx_fn_t(uint32_t vtx, int32_t num); -void gfxd_vtx_callback(gfxd_vtx_fn_t *fn); - -typedef int gfxd_vp_fn_t(uint32_t vp); -void gfxd_vp_callback(gfxd_vp_fn_t *fn); - -typedef int gfxd_uctext_fn_t(uint32_t text, uint32_t size); -void gfxd_uctext_callback(gfxd_uctext_fn_t *fn); - -typedef int gfxd_ucdata_fn_t(uint32_t data, uint32_t size); -void gfxd_ucdata_callback(gfxd_ucdata_fn_t *fn); - -typedef int gfxd_dram_fn_t(uint32_t dram, uint32_t size); -void gfxd_dram_callback(gfxd_dram_fn_t *fn); - -int gfxd_write(const void *buf, int count); -int gfxd_puts(const char *str); -int gfxd_printf(const char *fmt, ...); -int gfxd_print_value(int type, const gfxd_value_t *value); - -void gfxd_target(gfxd_ucode_t ucode); -void gfxd_endian(int endian, int wordsize); -void gfxd_dynamic(const char *arg); -void gfxd_enable(int cap); -void gfxd_disable(int cap); -void gfxd_udata_set(void *ptr); -void *gfxd_udata_get(void); - -int gfxd_execute(void); - -int gfxd_macro_offset(void); -int gfxd_macro_packets(void); -const void *gfxd_macro_data(void); -int gfxd_macro_id(void); -const char *gfxd_macro_name(void); - -int gfxd_arg_count(void); -int gfxd_arg_type(int arg_num); -const char *gfxd_arg_name(int arg_num); -int gfxd_arg_fmt(int arg_num); -const gfxd_value_t *gfxd_arg_value(int arg_num); -const gfxd_value_t *gfxd_value_by_type(int type, int idx); -int gfxd_arg_valid(int arg_num); -int gfxd_arg_callbacks(int arg_num); - -extern const gfxd_ucode_t gfxd_f3d; -extern const gfxd_ucode_t gfxd_f3db; -extern const gfxd_ucode_t gfxd_f3dex; -extern const gfxd_ucode_t gfxd_f3dexb; -extern const gfxd_ucode_t gfxd_f3dex2; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/ZAPDTR/lib/libgfxd/priv.h b/ZAPDTR/lib/libgfxd/priv.h deleted file mode 100644 index 34d96f675..000000000 --- a/ZAPDTR/lib/libgfxd/priv.h +++ /dev/null @@ -1,125 +0,0 @@ -#ifndef GFXD_PRIV_H -#define GFXD_PRIV_H -#include "gfxd.h" - -#define CONFIG_MT - -#ifdef CONFIG_MT -# ifdef _MSC_VER -# define TLOCAL __declspec(thread) -# else -# define TLOCAL _Thread_local -# endif -#else -#define TLOCAL -#endif - -#define UCFUNC static inline - -#define config gfxd_config__ - -typedef int gfxd_argfn_t(const gfxd_value_t *v); - -typedef struct -{ - int fmt; - gfxd_argfn_t * fn; -} gfxd_arg_type_t; - -typedef struct -{ - int type; - const char * name; - gfxd_value_t value; - int bad; -} gfxd_arg_t; - -typedef struct -{ - int id; - gfxd_arg_t arg[18]; -} gfxd_macro_t; - -typedef int gfxd_disas_fn_t(gfxd_macro_t *macro, uint32_t hi, uint32_t lo); -typedef int gfxd_combine_fn_t(gfxd_macro_t *macro, int n_macro); - -typedef struct -{ - const char * prefix; - const char * suffix; - int opcode; - int n_arg; - int n_gfx; - gfxd_disas_fn_t * disas_fn; - gfxd_combine_fn_t * combine_fn; - int alias; - int ext; -} gfxd_macro_type_t; - -struct gfxd_ucode -{ - gfxd_disas_fn_t * disas_fn; - gfxd_combine_fn_t * combine_fn; - const gfxd_arg_type_t * arg_tbl; - const gfxd_macro_type_t * macro_tbl; -}; - -struct gfxd_state -{ - int macro_offset; - - Gfx gfx[9]; - int n_byte; - int n_gfx; - gfxd_macro_t macro[9]; - - int end_input; - int ret; -}; - -struct gfxd_config -{ - gfxd_ucode_t ucode; - int endian; - int wordsize; - const char * arg; - void * udata; - - int stop_on_invalid; - int stop_on_end; - int emit_dec_color; - int emit_q_macro; - int emit_ext_macro; - - const char * input_buf; - int input_buf_size; - int input_fd; - gfxd_input_fn_t * input_fn; - - char * output_buf; - int output_buf_size; - int output_fd; - gfxd_output_fn_t * output_fn; - - gfxd_macro_fn_t * macro_fn; - gfxd_arg_fn_t * arg_fn; - - gfxd_tlut_fn_t * tlut_fn; - gfxd_timg_fn_t * timg_fn; - gfxd_cimg_fn_t * cimg_fn; - gfxd_zimg_fn_t * zimg_fn; - gfxd_dl_fn_t * dl_fn; - gfxd_mtx_fn_t * mtx_fn; - gfxd_lookat_fn_t * lookat_fn; - gfxd_light_fn_t * light_fn; - gfxd_seg_fn_t * seg_fn; - gfxd_vtx_fn_t * vtx_fn; - gfxd_vp_fn_t * vp_fn; - gfxd_uctext_fn_t * uctext_fn; - gfxd_ucdata_fn_t * ucdata_fn; - gfxd_dram_fn_t * dram_fn; -}; - -extern TLOCAL struct gfxd_config gfxd_config__; - -#endif diff --git a/ZAPDTR/lib/libgfxd/uc.c b/ZAPDTR/lib/libgfxd/uc.c deleted file mode 100644 index 7efb09105..000000000 --- a/ZAPDTR/lib/libgfxd/uc.c +++ /dev/null @@ -1,54 +0,0 @@ -#include -#include -#include -#include "gbi.h" -#include "gfxd.h" -#include "priv.h" - -#include "uc_argfn.c" -#include "uc_argtbl.c" -#include "uc_macrofn.c" -#include "uc_macrotbl.c" - -UCFUNC int disas(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - int opcode = (hi >> 24) & 0xFF; - - for (int i = 0; i < sizeof(macro_tbl) / sizeof(macro_tbl[0]); i++) - { - const gfxd_macro_type_t *t = ¯o_tbl[i]; - if (t->disas_fn != NULL && t->opcode == opcode) - return t->disas_fn(m, hi, lo); - } - - return d_Invalid(m, hi, lo); -} - -UCFUNC int combine(gfxd_macro_t *m, int num) -{ - int opcode = macro_tbl[m->id].opcode; - - for (int i = 0; i < sizeof(macro_tbl) / sizeof(macro_tbl[0]); i++) - { - const gfxd_macro_type_t *t = ¯o_tbl[i]; - if (t->combine_fn != NULL - && t->opcode == opcode - && (t->ext == 0 || config.emit_ext_macro != 0)) - { - if (t->combine_fn(m, num) == 0) - return 0; - } - } - - return -1; -} - -static const struct gfxd_ucode uc = -{ - .disas_fn = disas, - .combine_fn = combine, - .arg_tbl = arg_tbl, - .macro_tbl = macro_tbl, -}; - -const gfxd_ucode_t uc_name = &uc; diff --git a/ZAPDTR/lib/libgfxd/uc_argfn.c b/ZAPDTR/lib/libgfxd/uc_argfn.c deleted file mode 100644 index f65feb60f..000000000 --- a/ZAPDTR/lib/libgfxd/uc_argfn.c +++ /dev/null @@ -1,1814 +0,0 @@ -#define MDMASK(md) ((((uint32_t)1 << G_MDSIZ_##md) - 1) << G_MDSFT_##md) -#define MDMASK_RM_C1 ((uint32_t)0xCCCC0000) -#define MDMASK_RM_C2 ((uint32_t)0x33330000) -#define MDMASK_RM_LO ((uint32_t)0x0000FFF8) - -UCFUNC int argfn_i(const gfxd_value_t *v) -{ - return gfxd_printf("%" PRIi32, v->i); -} - -UCFUNC int argfn_u(const gfxd_value_t *v) -{ - return gfxd_printf("%" PRIu32, v->u); -} - -UCFUNC int argfn_x8(const gfxd_value_t *v) -{ - return gfxd_printf("0x%02" PRIX32, v->u); -} - -UCFUNC int argfn_x16(const gfxd_value_t *v) -{ - return gfxd_printf("0x%04" PRIX32, v->u); -} - -UCFUNC int argfn_x32(const gfxd_value_t *v) -{ - return gfxd_printf("0x%08" PRIX32, v->u); -} - -UCFUNC int argfn_color(const gfxd_value_t *v) -{ - if (config.emit_dec_color) - return gfxd_printf("%" PRIu32, v->u); - else - return gfxd_printf("0x%02" PRIX32, v->u); -} - -UCFUNC int argfn_qu08(const gfxd_value_t *v) -{ - if (v->u == 0) - return gfxd_puts("0"); - else if (config.emit_q_macro) - return gfxd_printf("qu08(%.16g)", v->u / 256.f); - else - return gfxd_printf("0x%02" PRIX32, v->u); -} - -UCFUNC int argfn_qu016(const gfxd_value_t *v) -{ - if (v->u == 0) - return gfxd_puts("0"); - else if (config.emit_q_macro) - return gfxd_printf("qu016(%.16g)", v->u / 65536.f); - else - return gfxd_printf("0x%04" PRIX32, v->u); -} - -UCFUNC int argfn_qs48(const gfxd_value_t *v) -{ - if (v->i == 0) - return gfxd_puts("0"); - else if (config.emit_q_macro) - return gfxd_printf("qs48(%.16g)", v->i / 256.f); - else - { - if (v->i < 0) - return gfxd_printf("-0x%04" PRIX32, (uint32_t)-v->i); - else - return gfxd_printf("0x%04" PRIX32, (uint32_t)v->i); - } -} - -UCFUNC int argfn_qs510(const gfxd_value_t *v) -{ - if (v->i == 0) - return gfxd_puts("0"); - else if (config.emit_q_macro) - return gfxd_printf("qs510(%.16g)", v->i / 1024.f); - else - { - if (v->i < 0) - return gfxd_printf("-0x%04" PRIX32, (uint32_t)-v->i); - else - return gfxd_printf("0x%04" PRIX32, (uint32_t)v->i); - } -} - -UCFUNC int argfn_qu102(const gfxd_value_t *v) -{ - if (v->u == 0) - return gfxd_puts("0"); - else if (config.emit_q_macro) - return gfxd_printf("qu102(%.16g)", v->u / 4.f); - else - return gfxd_printf("0x%04" PRIX32, v->u); -} - -UCFUNC int argfn_qs105(const gfxd_value_t *v) -{ - if (v->i == 0) - return gfxd_puts("0"); - else if (config.emit_q_macro) - return gfxd_printf("qs105(%.16g)", v->i / 32.f); - else - { - if (v->i < 0) - return gfxd_printf("-0x%04" PRIX32, (uint32_t)-v->i); - else - return gfxd_printf("0x%04" PRIX32, (uint32_t)v->i); - } -} - -UCFUNC int argfn_qs1616(const gfxd_value_t *v) -{ - if (v->i == 0) - return gfxd_puts("0"); - else if (config.emit_q_macro) - return gfxd_printf("qs1616(%.16g)", v->i / 65536.f); - else - { - if (v->i < 0) - return gfxd_printf("-0x%08" PRIX32, (uint32_t)-v->i); - else - return gfxd_printf("0x%08" PRIX32, (uint32_t)v->i); - } -} - -UCFUNC int argfn_opc(const gfxd_value_t *v) -{ - switch (v->i) - { - case G_SPNOOP: - return gfxd_puts("G_SPNOOP"); - case G_MTX: - return gfxd_puts("G_MTX"); - case G_MOVEMEM: - return gfxd_puts("G_MOVEMEM"); - case G_VTX: - return gfxd_puts("G_VTX"); - case G_DL: - return gfxd_puts("G_DL"); - case G_RDPHALF_2: - return gfxd_puts("G_RDPHALF_2"); - case G_RDPHALF_1: - return gfxd_puts("G_RDPHALF_1"); -#if defined(F3D_BETA) && (defined(F3D_GBI) || defined(F3DEX_GBI)) - case G_PERSPNORM: - return gfxd_puts("G_PERSPNORM"); -#endif - case G_LINE3D: - return gfxd_puts("G_LINE3D"); -#if defined(F3D_GBI) || defined(F3DEX_GBI) - case G_CLEARGEOMETRYMODE: - return gfxd_puts("G_CLEARGEOMETRYMODE"); - case G_SETGEOMETRYMODE: - return gfxd_puts("G_SETGEOMETRYMODE"); -#endif - case G_ENDDL: - return gfxd_puts("G_ENDDL"); - case G_SETOTHERMODE_L: - return gfxd_puts("G_SETOTHERMODE_L"); - case G_SETOTHERMODE_H: - return gfxd_puts("G_SETOTHERMODE_H"); - case G_TEXTURE: - return gfxd_puts("G_TEXTURE"); - case G_MOVEWORD: - return gfxd_puts("G_MOVEWORD"); - case G_POPMTX: - return gfxd_puts("G_POPMTX"); - case G_CULLDL: - return gfxd_puts("G_CULLDL"); - case G_TRI1: - return gfxd_puts("G_TRI1"); - case G_NOOP: - return gfxd_puts("G_NOOP"); -#if defined(F3DEX_GBI) || defined(F3DEX_GBI_2) - case G_LOAD_UCODE: - return gfxd_puts("G_LOAD_UCODE"); - case G_BRANCH_Z: - return gfxd_puts("G_BRANCH_Z"); - case G_TRI2: - return gfxd_puts("G_TRI2"); -# if !(defined(F3D_BETA) && defined(F3DEX_GBI)) - case G_MODIFYVTX: - return gfxd_puts("G_MODIFYVTX"); -# endif -#endif -#if defined(F3DEX_GBI_2) - case G_QUAD: - return gfxd_puts("G_QUAD"); - case G_SPECIAL_3: - return gfxd_puts("G_SPECIAL_3"); - case G_SPECIAL_2: - return gfxd_puts("G_SPECIAL_2"); - case G_SPECIAL_1: - return gfxd_puts("G_SPECIAL_1"); - case G_DMA_IO: - return gfxd_puts("G_DMA_IO"); - case G_GEOMETRYMODE: - return gfxd_puts("G_GEOMETRYMODE"); -#endif - case G_TEXRECT: - return gfxd_puts("G_TEXRECT"); - case G_TEXRECTFLIP: - return gfxd_puts("G_TEXRECTFLIP"); - case G_RDPLOADSYNC: - return gfxd_puts("G_RDPLOADSYNC"); - case G_RDPPIPESYNC: - return gfxd_puts("G_RDPPIPESYNC"); - case G_RDPTILESYNC: - return gfxd_puts("G_RDPTILESYNC"); - case G_RDPFULLSYNC: - return gfxd_puts("G_RDPFULLSYNC"); - case G_SETKEYGB: - return gfxd_puts("G_SETKEYGB"); - case G_SETKEYR: - return gfxd_puts("G_SETKEYR"); - case G_SETCONVERT: - return gfxd_puts("G_SETCONVERT"); - case G_SETSCISSOR: - return gfxd_puts("G_SETSCISSOR"); - case G_SETPRIMDEPTH: - return gfxd_puts("G_SETPRIMDEPTH"); - case G_RDPSETOTHERMODE: - return gfxd_puts("G_RDPSETOTHERMODE"); - case G_LOADTLUT: - return gfxd_puts("G_LOADTLUT"); - case G_SETTILESIZE: - return gfxd_puts("G_SETTILESIZE"); - case G_LOADBLOCK: - return gfxd_puts("G_LOADBLOCK"); - case G_LOADTILE: - return gfxd_puts("G_LOADTILE"); - case G_SETTILE: - return gfxd_puts("G_SETTILE"); - case G_FILLRECT: - return gfxd_puts("G_FILLRECT"); - case G_SETFILLCOLOR: - return gfxd_puts("G_SETFILLCOLOR"); - case G_SETFOGCOLOR: - return gfxd_puts("G_SETFOGCOLOR"); - case G_SETBLENDCOLOR: - return gfxd_puts("G_SETBLENDCOLOR"); - case G_SETPRIMCOLOR: - return gfxd_puts("G_SETPRIMCOLOR"); - case G_SETENVCOLOR: - return gfxd_puts("G_SETENVCOLOR"); - case G_SETCOMBINE: - return gfxd_puts("G_SETCOMBINE"); - case G_SETTIMG: - return gfxd_puts("G_SETTIMG"); - case G_SETZIMG: - return gfxd_puts("G_SETZIMG"); - case G_SETCIMG: - return gfxd_puts("G_SETCIMG"); - default: - return gfxd_printf("0x%02" PRIX32, (uint32_t)v->i); - } -} - -UCFUNC int argfn_fmt(const gfxd_value_t *v) -{ - switch (v->i) - { - case G_IM_FMT_RGBA: - return gfxd_puts("G_IM_FMT_RGBA"); - case G_IM_FMT_YUV: - return gfxd_puts("G_IM_FMT_YUV"); - case G_IM_FMT_CI: - return gfxd_puts("G_IM_FMT_CI"); - case G_IM_FMT_IA: - return gfxd_puts("G_IM_FMT_IA"); - case G_IM_FMT_I: - return gfxd_puts("G_IM_FMT_I"); - default: - return gfxd_printf("%" PRIi32, v->i); - } -} - -UCFUNC int argfn_siz(const gfxd_value_t *v) -{ - switch (v->i) - { - case G_IM_SIZ_4b: - return gfxd_puts("G_IM_SIZ_4b"); - case G_IM_SIZ_8b: - return gfxd_puts("G_IM_SIZ_8b"); - case G_IM_SIZ_16b: - return gfxd_puts("G_IM_SIZ_16b"); - case G_IM_SIZ_32b: - return gfxd_puts("G_IM_SIZ_32b"); - default: - return gfxd_printf("%" PRIi32, v->i); - } -} - -UCFUNC int argfn_cm(const gfxd_value_t *v) -{ - int n = 0; - if (v->u & G_TX_MIRROR) - n += gfxd_puts("G_TX_MIRROR"); - else - n += gfxd_puts("G_TX_NOMIRROR"); - if (v->u & G_TX_CLAMP) - n += gfxd_puts(" | G_TX_CLAMP"); - else - n += gfxd_puts(" | G_TX_WRAP"); - return n; -} - -UCFUNC int argfn_tm(const gfxd_value_t *v) -{ - if (v->i == 0) - return gfxd_puts("G_TX_NOMASK"); - else - return gfxd_printf("%" PRIi32, v->i); -} - -UCFUNC int argfn_ts(const gfxd_value_t *v) -{ - if (v->i == 0) - return gfxd_puts("G_TX_NOLOD"); - else - return gfxd_printf("%" PRIi32, v->i); -} - -UCFUNC int argfn_switch(const gfxd_value_t *v) -{ - switch (v->i) - { - case G_ON: - return gfxd_puts("G_ON"); - case G_OFF: - return gfxd_puts("G_OFF"); - default: - return gfxd_printf("%" PRIi32, v->i); - } -} - -UCFUNC int argfn_tile(const gfxd_value_t *v) -{ - if (v->i == G_TX_LOADTILE) - return gfxd_puts("G_TX_LOADTILE"); - else if (v->i == G_TX_RENDERTILE) - return gfxd_puts("G_TX_RENDERTILE"); - else - return gfxd_printf("%" PRIi32, v->i); -} - -UCFUNC int argfn_gm(const gfxd_value_t *v) -{ - int n = 0; - uint32_t arg = v->u; - if (arg & G_ZBUFFER) - n += gfxd_puts("G_ZBUFFER"); - if (arg & G_TEXTURE_ENABLE) - { - if (n > 0) - n += gfxd_puts(" | "); - n += gfxd_puts("G_TEXTURE_ENABLE"); - } - if (arg & G_SHADE) - { - if (n > 0) - n += gfxd_puts(" | "); - n += gfxd_puts("G_SHADE"); - } - if ((arg & G_CULL_BOTH) == G_CULL_BOTH) - { - if (n > 0) - n += gfxd_puts(" | "); - n += gfxd_puts("G_CULL_BOTH"); - } - else - { - if (arg & G_CULL_FRONT) - { - if (n > 0) - n += gfxd_puts(" | "); - n += gfxd_puts("G_CULL_FRONT"); - } - if (arg & G_CULL_BACK) - { - if (n > 0) - n += gfxd_puts(" | "); - n += gfxd_puts("G_CULL_BACK"); - } - } - if (arg & G_FOG) - { - if (n > 0) - n += gfxd_puts(" | "); - n += gfxd_puts("G_FOG"); - } - if (arg & G_LIGHTING) - { - if (n > 0) - n += gfxd_puts(" | "); - n += gfxd_puts("G_LIGHTING"); - } - if (arg & G_TEXTURE_GEN) - { - if (n > 0) - n += gfxd_puts(" | "); - n += gfxd_puts("G_TEXTURE_GEN"); - } - if (arg & G_TEXTURE_GEN_LINEAR) - { - if (n > 0) - n += gfxd_puts(" | "); - n += gfxd_puts("G_TEXTURE_GEN_LINEAR"); - } - if (arg & G_LOD) - { - if (n > 0) - n += gfxd_puts(" | "); - n += gfxd_puts("G_LOD"); - } - if (arg & G_SHADING_SMOOTH) - { - if (n > 0) - n += gfxd_puts(" | "); - n += gfxd_puts("G_SHADING_SMOOTH"); - } - if (arg & G_CLIPPING) - { - if (n > 0) - n += gfxd_puts(" | "); - n += gfxd_puts("G_CLIPPING"); - } - arg = arg & ~(G_ZBUFFER | G_TEXTURE_ENABLE | G_SHADE | G_CULL_BOTH | - G_FOG | G_LIGHTING | G_TEXTURE_GEN | - G_TEXTURE_GEN_LINEAR | G_LOD | G_SHADING_SMOOTH | - G_CLIPPING); - if (arg) - { - if (n > 0) - n += gfxd_puts(" | "); - n += gfxd_printf("0x%08" PRIX32, arg); - } - return n; -} - -UCFUNC int argfn_sftlo(const gfxd_value_t *v) -{ - switch (v->i) - { - case G_MDSFT_ALPHACOMPARE: - return gfxd_puts("G_MDSFT_ALPHACOMPARE"); - case G_MDSFT_ZSRCSEL: - return gfxd_puts("G_MDSFT_ZSRCSEL"); - case G_MDSFT_RENDERMODE: - return gfxd_puts("G_MDSFT_RENDERMODE"); - case G_MDSFT_BLENDER: - return gfxd_puts("G_MDSFT_BLENDER"); - default: - return gfxd_printf("%" PRIi32, v->i); - } -} - -UCFUNC int rm_mode_str(uint32_t arg) -{ - int n = 0; - if (arg & AA_EN) - n += gfxd_puts("AA_EN"); - if (arg & Z_CMP) - { - if (n > 0) - n += gfxd_puts(" | "); - n += gfxd_puts("Z_CMP"); - } - if (arg & Z_UPD) - { - if (n > 0) - n += gfxd_puts(" | "); - n += gfxd_puts("Z_UPD"); - } - if (arg & IM_RD) - { - if (n > 0) - n += gfxd_puts(" | "); - n += gfxd_puts("IM_RD"); - } - if (arg & CLR_ON_CVG) - { - if (n > 0) - n += gfxd_puts(" | "); - n += gfxd_puts("CLR_ON_CVG"); - } - if (n > 0) - n += gfxd_puts(" | "); - int cvg = arg & 0x00000300; - switch (cvg) - { - case CVG_DST_CLAMP: - n += gfxd_puts("CVG_DST_CLAMP"); - break; - case CVG_DST_WRAP: - n += gfxd_puts("CVG_DST_WRAP"); - break; - case CVG_DST_FULL: - n += gfxd_puts("CVG_DST_FULL"); - break; - case CVG_DST_SAVE: - n += gfxd_puts("CVG_DST_SAVE"); - break; - } - int zmode = arg & 0x00000C00; - switch (zmode) - { - case ZMODE_OPA: - n += gfxd_puts(" | ZMODE_OPA"); - break; - case ZMODE_INTER: - n += gfxd_puts(" | ZMODE_INTER"); - break; - case ZMODE_XLU: - n += gfxd_puts(" | ZMODE_XLU"); - break; - case ZMODE_DEC: - n += gfxd_puts(" | ZMODE_DEC"); - break; - } - if (arg & CVG_X_ALPHA) - n += gfxd_puts(" | CVG_X_ALPHA"); - if (arg & ALPHA_CVG_SEL) - n += gfxd_puts(" | ALPHA_CVG_SEL"); - if (arg & FORCE_BL) - n += gfxd_puts(" | FORCE_BL"); - return n; -} - -UCFUNC int rm_cbl_str(uint32_t arg, int c) -{ - int n = 0; - if (c == 2) - arg <<= 2; - int bp = (arg >> 30) & 0b11; - switch (bp) - { - case G_BL_CLR_IN: - n += gfxd_printf("GBL_c%i(G_BL_CLR_IN", c); - break; - case G_BL_CLR_MEM: - n += gfxd_printf("GBL_c%i(G_BL_CLR_MEM", c); - break; - case G_BL_CLR_BL: - n += gfxd_printf("GBL_c%i(G_BL_CLR_BL", c); - break; - case G_BL_CLR_FOG: - n += gfxd_printf("GBL_c%i(G_BL_CLR_FOG", c); - break; - } - int ba = (arg >> 26) & 0b11; - switch (ba) - { - case G_BL_A_IN: - n += gfxd_puts(", G_BL_A_IN"); - break; - case G_BL_A_FOG: - n += gfxd_puts(", G_BL_A_FOG"); - break; - case G_BL_A_SHADE: - n += gfxd_puts(", G_BL_A_SHADE"); - break; - case G_BL_0: - n += gfxd_puts(", G_BL_0"); - break; - } - int bm = (arg >> 22) & 0b11; - switch (bm) - { - case G_BL_CLR_IN: - n += gfxd_puts(", G_BL_CLR_IN"); - break; - case G_BL_CLR_MEM: - n += gfxd_puts(", G_BL_CLR_MEM"); - break; - case G_BL_CLR_BL: - n += gfxd_puts(", G_BL_CLR_BL"); - break; - case G_BL_CLR_FOG: - n += gfxd_puts(", G_BL_CLR_FOG"); - break; - } - int bb = (arg >> 18) & 0b11; - switch (bb) - { - case G_BL_1MA: - n += gfxd_puts(", G_BL_1MA)"); - break; - case G_BL_A_MEM: - n += gfxd_puts(", G_BL_A_MEM)"); - break; - case G_BL_1: - n += gfxd_puts(", G_BL_1)"); - break; - case G_BL_0: - n += gfxd_puts(", G_BL_0)"); - break; - } - return n; -} - -struct rm_preset -{ - uint32_t rm; - const char * name; -}; - -static const struct rm_preset rm_presets[] = -{ - {G_RM_OPA_SURF, "G_RM_OPA_SURF"}, - {G_RM_OPA_SURF2, "G_RM_OPA_SURF2"}, - {G_RM_AA_OPA_SURF, "G_RM_AA_OPA_SURF"}, - {G_RM_AA_OPA_SURF2, "G_RM_AA_OPA_SURF2"}, - {G_RM_RA_OPA_SURF, "G_RM_RA_OPA_SURF"}, - {G_RM_RA_OPA_SURF2, "G_RM_RA_OPA_SURF2"}, - {G_RM_ZB_OPA_SURF, "G_RM_ZB_OPA_SURF"}, - {G_RM_ZB_OPA_SURF2, "G_RM_ZB_OPA_SURF2"}, - {G_RM_AA_ZB_OPA_SURF, "G_RM_AA_ZB_OPA_SURF"}, - {G_RM_AA_ZB_OPA_SURF2, "G_RM_AA_ZB_OPA_SURF2"}, - {G_RM_RA_ZB_OPA_SURF, "G_RM_RA_ZB_OPA_SURF"}, - {G_RM_RA_ZB_OPA_SURF2, "G_RM_RA_ZB_OPA_SURF2"}, - {G_RM_XLU_SURF, "G_RM_XLU_SURF"}, - {G_RM_XLU_SURF2, "G_RM_XLU_SURF2"}, - {G_RM_AA_XLU_SURF, "G_RM_AA_XLU_SURF"}, - {G_RM_AA_XLU_SURF2, "G_RM_AA_XLU_SURF2"}, - {G_RM_ZB_XLU_SURF, "G_RM_ZB_XLU_SURF"}, - {G_RM_ZB_XLU_SURF2, "G_RM_ZB_XLU_SURF2"}, - {G_RM_AA_ZB_XLU_SURF, "G_RM_AA_ZB_XLU_SURF"}, - {G_RM_AA_ZB_XLU_SURF2, "G_RM_AA_ZB_XLU_SURF2"}, - {G_RM_ZB_OPA_DECAL, "G_RM_ZB_OPA_DECAL"}, - {G_RM_ZB_OPA_DECAL2, "G_RM_ZB_OPA_DECAL2"}, - {G_RM_AA_ZB_OPA_DECAL, "G_RM_AA_ZB_OPA_DECAL"}, - {G_RM_AA_ZB_OPA_DECAL2, "G_RM_AA_ZB_OPA_DECAL2"}, - {G_RM_RA_ZB_OPA_DECAL, "G_RM_RA_ZB_OPA_DECAL"}, - {G_RM_RA_ZB_OPA_DECAL2, "G_RM_RA_ZB_OPA_DECAL2"}, - {G_RM_ZB_XLU_DECAL, "G_RM_ZB_XLU_DECAL"}, - {G_RM_ZB_XLU_DECAL2, "G_RM_ZB_XLU_DECAL2"}, - {G_RM_AA_ZB_XLU_DECAL, "G_RM_AA_ZB_XLU_DECAL"}, - {G_RM_AA_ZB_XLU_DECAL2, "G_RM_AA_ZB_XLU_DECAL2"}, - {G_RM_AA_ZB_OPA_INTER, "G_RM_AA_ZB_OPA_INTER"}, - {G_RM_AA_ZB_OPA_INTER2, "G_RM_AA_ZB_OPA_INTER2"}, - {G_RM_RA_ZB_OPA_INTER, "G_RM_RA_ZB_OPA_INTER"}, - {G_RM_RA_ZB_OPA_INTER2, "G_RM_RA_ZB_OPA_INTER2"}, - {G_RM_AA_ZB_XLU_INTER, "G_RM_AA_ZB_XLU_INTER"}, - {G_RM_AA_ZB_XLU_INTER2, "G_RM_AA_ZB_XLU_INTER2"}, - {G_RM_AA_XLU_LINE, "G_RM_AA_XLU_LINE"}, - {G_RM_AA_XLU_LINE2, "G_RM_AA_XLU_LINE2"}, - {G_RM_AA_ZB_XLU_LINE, "G_RM_AA_ZB_XLU_LINE"}, - {G_RM_AA_ZB_XLU_LINE2, "G_RM_AA_ZB_XLU_LINE2"}, - {G_RM_AA_DEC_LINE, "G_RM_AA_DEC_LINE"}, - {G_RM_AA_DEC_LINE2, "G_RM_AA_DEC_LINE2"}, - {G_RM_AA_ZB_DEC_LINE, "G_RM_AA_ZB_DEC_LINE"}, - {G_RM_AA_ZB_DEC_LINE2, "G_RM_AA_ZB_DEC_LINE2"}, - {G_RM_TEX_EDGE, "G_RM_TEX_EDGE"}, - {G_RM_TEX_EDGE2, "G_RM_TEX_EDGE2"}, - {G_RM_AA_TEX_EDGE, "G_RM_AA_TEX_EDGE"}, - {G_RM_AA_TEX_EDGE2, "G_RM_AA_TEX_EDGE2"}, - {G_RM_AA_ZB_TEX_EDGE, "G_RM_AA_ZB_TEX_EDGE"}, - {G_RM_AA_ZB_TEX_EDGE2, "G_RM_AA_ZB_TEX_EDGE2"}, - {G_RM_AA_ZB_TEX_INTER, "G_RM_AA_ZB_TEX_INTER"}, - {G_RM_AA_ZB_TEX_INTER2, "G_RM_AA_ZB_TEX_INTER2"}, - {G_RM_AA_SUB_SURF, "G_RM_AA_SUB_SURF"}, - {G_RM_AA_SUB_SURF2, "G_RM_AA_SUB_SURF2"}, - {G_RM_AA_ZB_SUB_SURF, "G_RM_AA_ZB_SUB_SURF"}, - {G_RM_AA_ZB_SUB_SURF2, "G_RM_AA_ZB_SUB_SURF2"}, - {G_RM_PCL_SURF, "G_RM_PCL_SURF"}, - {G_RM_PCL_SURF2, "G_RM_PCL_SURF2"}, - {G_RM_AA_PCL_SURF, "G_RM_AA_PCL_SURF"}, - {G_RM_AA_PCL_SURF2, "G_RM_AA_PCL_SURF2"}, - {G_RM_ZB_PCL_SURF, "G_RM_ZB_PCL_SURF"}, - {G_RM_ZB_PCL_SURF2, "G_RM_ZB_PCL_SURF2"}, - {G_RM_AA_ZB_PCL_SURF, "G_RM_AA_ZB_PCL_SURF"}, - {G_RM_AA_ZB_PCL_SURF2, "G_RM_AA_ZB_PCL_SURF2"}, - {G_RM_AA_OPA_TERR, "G_RM_AA_OPA_TERR"}, - {G_RM_AA_OPA_TERR2, "G_RM_AA_OPA_TERR2"}, - {G_RM_AA_ZB_OPA_TERR, "G_RM_AA_ZB_OPA_TERR"}, - {G_RM_AA_ZB_OPA_TERR2, "G_RM_AA_ZB_OPA_TERR2"}, - {G_RM_AA_TEX_TERR, "G_RM_AA_TEX_TERR"}, - {G_RM_AA_TEX_TERR2, "G_RM_AA_TEX_TERR2"}, - {G_RM_AA_ZB_TEX_TERR, "G_RM_AA_ZB_TEX_TERR"}, - {G_RM_AA_ZB_TEX_TERR2, "G_RM_AA_ZB_TEX_TERR2"}, - {G_RM_AA_SUB_TERR, "G_RM_AA_SUB_TERR"}, - {G_RM_AA_SUB_TERR2, "G_RM_AA_SUB_TERR2"}, - {G_RM_AA_ZB_SUB_TERR, "G_RM_AA_ZB_SUB_TERR"}, - {G_RM_AA_ZB_SUB_TERR2, "G_RM_AA_ZB_SUB_TERR2"}, - {G_RM_CLD_SURF, "G_RM_CLD_SURF"}, - {G_RM_CLD_SURF2, "G_RM_CLD_SURF2"}, - {G_RM_ZB_CLD_SURF, "G_RM_ZB_CLD_SURF"}, - {G_RM_ZB_CLD_SURF2, "G_RM_ZB_CLD_SURF2"}, - {G_RM_ZB_OVL_SURF, "G_RM_ZB_OVL_SURF"}, - {G_RM_ZB_OVL_SURF2, "G_RM_ZB_OVL_SURF2"}, - {G_RM_ADD, "G_RM_ADD"}, - {G_RM_ADD2, "G_RM_ADD2"}, - {G_RM_VISCVG, "G_RM_VISCVG"}, - {G_RM_VISCVG2, "G_RM_VISCVG2"}, - {G_RM_OPA_CI, "G_RM_OPA_CI"}, - {G_RM_OPA_CI2, "G_RM_OPA_CI2"}, - {G_RM_RA_SPRITE, "G_RM_RA_SPRITE"}, - {G_RM_RA_SPRITE2, "G_RM_RA_SPRITE2"}, -}; - -static const struct rm_preset bl1_presets[] = -{ - {G_RM_FOG_SHADE_A, "G_RM_FOG_SHADE_A"}, - {G_RM_FOG_PRIM_A, "G_RM_FOG_PRIM_A"}, - {G_RM_PASS, "G_RM_PASS"}, - {G_RM_NOOP, "G_RM_NOOP"}, -}; - -static const struct rm_preset bl2_presets[] = -{ - {G_RM_NOOP2, "G_RM_NOOP2"}, -}; - -UCFUNC int othermodelo_str(uint32_t arg, uint32_t which) -{ - int n = 0; - uint32_t rm_c1_mask = MDMASK_RM_C1; - uint32_t rm_c2_mask = MDMASK_RM_C2; - uint32_t rm_mode_lo = MDMASK_RM_LO; - uint32_t rm_mask = rm_c1_mask | rm_c2_mask | rm_mode_lo; - const struct rm_preset *pre_c1 = NULL; - const struct rm_preset *pre_c2 = NULL; - int n_rm_presets = sizeof(rm_presets) / sizeof(*rm_presets); - for (int i = 0; i < n_rm_presets; i++) - { - const struct rm_preset *pre = &rm_presets[i]; - uint32_t pre_extra = pre->rm & ~rm_mask; - uint32_t rm_c1 = arg & (rm_c1_mask | rm_mode_lo | pre_extra); - if (!pre_c1 && rm_c1 == pre->rm) - pre_c1 = pre; - uint32_t rm_c2 = arg & (rm_c2_mask | rm_mode_lo | pre_extra); - if (!pre_c2 && rm_c2 == pre->rm) - pre_c2 = pre; - } - if (!pre_c1 || !pre_c2 || pre_c1 + 1 != pre_c2) - { - int n_bl1_presets = sizeof(bl1_presets) / sizeof(*bl1_presets); - for (int i = 0; i < n_bl1_presets; i++) - { - const struct rm_preset *pre = &bl1_presets[i]; - uint32_t pre_extra = pre->rm & ~rm_mask; - uint32_t rm_c1 = arg & (rm_c1_mask | pre_extra); - if (rm_c1 == pre->rm) - { - pre_c1 = pre; - break; - } - } - int n_bl2_presets = sizeof(bl2_presets) / sizeof(*bl2_presets); - for (int i = 0; i < n_bl2_presets; i++) - { - const struct rm_preset *pre = &bl2_presets[i]; - uint32_t pre_extra = pre->rm & ~rm_mask; - uint32_t rm_c2 = arg & (rm_c2_mask | pre_extra); - if (rm_c2 == pre->rm) - { - pre_c2 = pre; - break; - } - } - } - uint32_t pre_rm = 0; - if (pre_c1) - pre_rm |= pre_c1->rm; - if (pre_c2) - pre_rm |= pre_c2->rm; - uint32_t ac_mask = MDMASK(ALPHACOMPARE); - if (((arg & ~pre_rm) | which) & ac_mask) - { - uint32_t ac = arg & ac_mask; - switch (ac) - { - case G_AC_NONE: - n += gfxd_puts("G_AC_NONE"); - break; - case G_AC_THRESHOLD: - n += gfxd_puts("G_AC_THRESHOLD"); - break; - case G_AC_DITHER: - n += gfxd_puts("G_AC_DITHER"); - break; - default: - n += gfxd_printf("0x%08" PRIX32, ac); - break; - } - } - uint32_t zs_mask = MDMASK(ZSRCSEL); - if (((arg & ~pre_rm) | which) & zs_mask) - { - if (n > 0) - n += gfxd_puts(" | "); - uint32_t zs = arg & zs_mask; - switch (zs) - { - case G_ZS_PIXEL: - n += gfxd_puts("G_ZS_PIXEL"); - break; - case G_ZS_PRIM: - n += gfxd_puts("G_ZS_PRIM"); - break; - default: - n += gfxd_printf("0x%08" PRIX32, zs); - break; - } - } - uint32_t rm = arg & (rm_mask | pre_rm); - if (((arg & ~pre_rm) | which) & rm_mode_lo) - { - if (n > 0) - n += gfxd_puts(" | "); - n += rm_mode_str(rm); - } - int c = 0; - if (which & rm_c1_mask) - c |= 1; - if (which & rm_c2_mask) - c |= 2; - if (c & 1 || (c == 0 && arg & rm_c1_mask)) - { - if (n > 0) - n += gfxd_puts(" | "); - if (pre_c1) - n += gfxd_printf("%s", pre_c1->name); - else - n += rm_cbl_str(rm, 1); - } - if (c & 2 || (c == 0 && arg & rm_c2_mask)) - { - if (n > 0) - n += gfxd_puts(" | "); - if (pre_c2) - n += gfxd_printf("%s", pre_c2->name); - else - n += rm_cbl_str(rm, 2); - } - uint32_t unk_mask = ~(rm_mask | ac_mask | zs_mask); - if (arg & unk_mask) - { - if (n > 0) - n += gfxd_puts(" | "); - uint32_t unk = arg & unk_mask; - n += gfxd_printf("0x%08" PRIX32, unk); - } - return n; -} - -UCFUNC int argfn_ac(const gfxd_value_t *v) -{ - return othermodelo_str(v->u, MDMASK(ALPHACOMPARE)); -} - -UCFUNC int argfn_zs(const gfxd_value_t *v) -{ - return othermodelo_str(v->u, MDMASK(ZSRCSEL)); -} - -UCFUNC int argfn_rm1(const gfxd_value_t *v) -{ - return othermodelo_str(v->u, MDMASK_RM_C1); -} - -UCFUNC int argfn_rm2(const gfxd_value_t *v) -{ - return othermodelo_str(v->u, MDMASK_RM_C2); -} - -UCFUNC int argfn_othermodelo(const gfxd_value_t *v) -{ - uint32_t mask = MDMASK(ALPHACOMPARE) | MDMASK(ZSRCSEL) | MDMASK_RM_C1 | - MDMASK_RM_C2; - return othermodelo_str(v->u, mask); -} - -UCFUNC int argfn_sfthi(const gfxd_value_t *v) -{ - switch (v->i) - { - case G_MDSFT_ALPHADITHER: - return gfxd_puts("G_MDSFT_ALPHADITHER"); - case G_MDSFT_RGBDITHER: - return gfxd_puts("G_MDSFT_RGBDITHER"); - case G_MDSFT_COMBKEY: - return gfxd_puts("G_MDSFT_COMBKEY"); - case G_MDSFT_TEXTCONV: - return gfxd_puts("G_MDSFT_TEXTCONV"); - case G_MDSFT_TEXTFILT: - return gfxd_puts("G_MDSFT_TEXTFILT"); - case G_MDSFT_TEXTLUT: - return gfxd_puts("G_MDSFT_TEXTLUT"); - case G_MDSFT_TEXTLOD: - return gfxd_puts("G_MDSFT_TEXTLOD"); - case G_MDSFT_TEXTDETAIL: - return gfxd_puts("G_MDSFT_TEXTDETAIL"); - case G_MDSFT_TEXTPERSP: - return gfxd_puts("G_MDSFT_TEXTPERSP"); - case G_MDSFT_CYCLETYPE: - return gfxd_puts("G_MDSFT_CYCLETYPE"); - case G_MDSFT_PIPELINE: - return gfxd_puts("G_MDSFT_PIPELINE"); - default: - return gfxd_printf("%" PRIi32, v->i); - } -} - -UCFUNC int othermodehi_str(uint32_t arg, uint32_t which) -{ - int n = 0; - uint32_t ad_mask = MDMASK(ALPHADITHER); - if ((arg | which) & ad_mask) - { - uint32_t ad = arg & ad_mask; - switch (ad) - { - case G_AD_PATTERN: - n += gfxd_puts("G_AD_PATTERN"); - break; - case G_AD_NOTPATTERN: - n += gfxd_puts("G_AD_NOTPATTERN"); - break; - case G_AD_NOISE: - n += gfxd_puts("G_AD_NOISE"); - break; - case G_AD_DISABLE: - n += gfxd_puts("G_AD_DISABLE"); - break; - default: - n += gfxd_printf("0x%08" PRIX32, ad); - break; - } - } - uint32_t cd_mask = MDMASK(RGBDITHER); - if ((arg | which) & cd_mask) - { - if (n > 0) - n += gfxd_puts(" | "); - uint32_t cd = arg & cd_mask; - switch (cd) - { - case G_CD_MAGICSQ: - n += gfxd_puts("G_CD_MAGICSQ"); - break; - case G_CD_BAYER: - n += gfxd_puts("G_CD_BAYER"); - break; - case G_CD_NOISE: - n += gfxd_puts("G_CD_NOISE"); - break; - case G_CD_DISABLE: - n += gfxd_puts("G_CD_DISABLE"); - break; - default: - n += gfxd_printf("0x%08" PRIX32, cd); - break; - } - } - uint32_t ck_mask = MDMASK(COMBKEY); - if ((arg | which) & ck_mask) - { - if (n > 0) - n += gfxd_puts(" | "); - uint32_t ck = arg & ck_mask; - switch (ck) - { - case G_CK_NONE: - n += gfxd_puts("G_CK_NONE"); - break; - case G_CK_KEY: - n += gfxd_puts("G_CK_KEY"); - break; - default: - n += gfxd_printf("0x%08" PRIX32, ck); - break; - } - } - uint32_t tc_mask = MDMASK(TEXTCONV); - if ((arg | which) & tc_mask) - { - if (n > 0) - n += gfxd_puts(" | "); - uint32_t tc = arg & tc_mask; - switch (tc) - { - case G_TC_CONV: - n += gfxd_puts("G_TC_CONV"); - break; - case G_TC_FILTCONV: - n += gfxd_puts("G_TC_FILTCONV"); - break; - case G_TC_FILT: - n += gfxd_puts("G_TC_FILT"); - break; - default: - n += gfxd_printf("0x%08" PRIX32, tc); - break; - } - } - uint32_t tf_mask = MDMASK(TEXTFILT); - if ((arg | which) & tf_mask) - { - if (n > 0) - n += gfxd_puts(" | "); - uint32_t tf = arg & tf_mask; - switch (tf) - { - case G_TF_POINT: - n += gfxd_puts("G_TF_POINT"); - break; - case G_TF_BILERP: - n += gfxd_puts("G_TF_BILERP"); - break; - case G_TF_AVERAGE: - n += gfxd_puts("G_TF_AVERAGE"); - break; - default: - n += gfxd_printf("0x%08" PRIX32, tf); - break; - } - } - uint32_t tt_mask = MDMASK(TEXTLUT); - if ((arg | which) & tt_mask) - { - if (n > 0) - n += gfxd_puts(" | "); - uint32_t tt = arg & tt_mask; - switch (tt) - { - case G_TT_NONE: - n += gfxd_puts("G_TT_NONE"); - break; - case G_TT_RGBA16: - n += gfxd_puts("G_TT_RGBA16"); - break; - case G_TT_IA16: - n += gfxd_puts("G_TT_IA16"); - break; - default: - n += gfxd_printf("0x%08" PRIX32, tt); - break; - } - } - uint32_t tl_mask = MDMASK(TEXTLOD); - if ((arg | which) & tl_mask) - { - if (n > 0) - n += gfxd_puts(" | "); - uint32_t tl = arg & tl_mask; - switch (tl) - { - case G_TL_TILE: - n += gfxd_puts("G_TL_TILE"); - break; - case G_TL_LOD: - n += gfxd_puts("G_TL_LOD"); - break; - default: - n += gfxd_printf("0x%08" PRIX32, tl); - break; - } - } - uint32_t td_mask = MDMASK(TEXTDETAIL); - if ((arg | which) & td_mask) - { - if (n > 0) - n += gfxd_puts(" | "); - uint32_t td = arg & td_mask; - switch (td) - { - case G_TD_CLAMP: - n += gfxd_puts("G_TD_CLAMP"); - break; - case G_TD_SHARPEN: - n += gfxd_puts("G_TD_SHARPEN"); - break; - case G_TD_DETAIL: - n += gfxd_puts("G_TD_DETAIL"); - break; - default: - n += gfxd_printf("0x%08" PRIX32, td); - break; - } - } - uint32_t tp_mask = MDMASK(TEXTPERSP); - if ((arg | which) & tp_mask) - { - if (n > 0) - n += gfxd_puts(" | "); - uint32_t tp = arg & tp_mask; - switch (tp) - { - case G_TP_NONE: - n += gfxd_puts("G_TP_NONE"); - break; - case G_TP_PERSP: - n += gfxd_puts("G_TP_PERSP"); - break; - default: - n += gfxd_printf("0x%08" PRIX32, tp); - break; - } - } - uint32_t cyc_mask = MDMASK(CYCLETYPE); - if ((arg | which) & cyc_mask) - { - if (n > 0) - n += gfxd_puts(" | "); - uint32_t cyc = arg & cyc_mask; - switch (cyc) - { - case G_CYC_1CYCLE: - n += gfxd_puts("G_CYC_1CYCLE"); - break; - case G_CYC_2CYCLE: - n += gfxd_puts("G_CYC_2CYCLE"); - break; - case G_CYC_COPY: - n += gfxd_puts("G_CYC_COPY"); - break; - case G_CYC_FILL: - n += gfxd_puts("G_CYC_FILL"); - break; - default: - n += gfxd_printf("0x%08" PRIX32, cyc); - break; - } - } - uint32_t pm_mask = MDMASK(PIPELINE); - if ((arg | which) & pm_mask) - { - if (n > 0) - n += gfxd_puts(" | "); - uint32_t pm = arg & pm_mask; - switch (pm) - { - case G_PM_NPRIMITIVE: - n += gfxd_puts("G_PM_NPRIMITIVE"); - break; - case G_PM_1PRIMITIVE: - n += gfxd_puts("G_PM_1PRIMITIVE"); - break; - default: - n += gfxd_printf("0x%08" PRIX32, pm); - break; - } - } - uint32_t unk_mask = ~(ad_mask | cd_mask | ck_mask | tc_mask | tf_mask | - tt_mask | tl_mask | td_mask | tp_mask | - cyc_mask | pm_mask); - if (arg & unk_mask) - { - if (n > 0) - n += gfxd_puts(" | "); - uint32_t unk = arg & unk_mask; - n += gfxd_printf("0x%08" PRIX32, unk); - } - return n; -} - -UCFUNC int argfn_ad(const gfxd_value_t *v) -{ - return othermodehi_str(v->u, MDMASK(ALPHADITHER)); -} - -UCFUNC int argfn_cd(const gfxd_value_t *v) -{ - return othermodehi_str(v->u, MDMASK(RGBDITHER)); -} - -UCFUNC int argfn_ck(const gfxd_value_t *v) -{ - return othermodehi_str(v->u, MDMASK(COMBKEY)); -} - -UCFUNC int argfn_tc(const gfxd_value_t *v) -{ - return othermodehi_str(v->u, MDMASK(TEXTCONV)); -} - -UCFUNC int argfn_tf(const gfxd_value_t *v) -{ - return othermodehi_str(v->u, MDMASK(TEXTFILT)); -} - -UCFUNC int argfn_tt(const gfxd_value_t *v) -{ - return othermodehi_str(v->u, MDMASK(TEXTLUT)); -} - -UCFUNC int argfn_tl(const gfxd_value_t *v) -{ - return othermodehi_str(v->u, MDMASK(TEXTLOD)); -} - -UCFUNC int argfn_td(const gfxd_value_t *v) -{ - return othermodehi_str(v->u, MDMASK(TEXTDETAIL)); -} - -UCFUNC int argfn_tp(const gfxd_value_t *v) -{ - return othermodehi_str(v->u, MDMASK(TEXTPERSP)); -} - -UCFUNC int argfn_cyc(const gfxd_value_t *v) -{ - return othermodehi_str(v->u, MDMASK(CYCLETYPE)); -} - -UCFUNC int argfn_pm(const gfxd_value_t *v) -{ - return othermodehi_str(v->u, MDMASK(PIPELINE)); -} - -UCFUNC int argfn_othermodehi(const gfxd_value_t *v) -{ - uint32_t mask = MDMASK(ALPHADITHER) | - MDMASK(RGBDITHER) | - MDMASK(COMBKEY) | - MDMASK(TEXTCONV) | - MDMASK(TEXTFILT) | - MDMASK(TEXTLUT) | - MDMASK(TEXTLOD) | - MDMASK(TEXTDETAIL) | - MDMASK(TEXTPERSP) | - MDMASK(CYCLETYPE) | - MDMASK(PIPELINE); - return othermodehi_str(v->u, mask); -} - -UCFUNC int argfn_cv(const gfxd_value_t *v) -{ - switch (v->i) - { - case G_CV_K0: - return gfxd_puts("G_CV_K0"); - case G_CV_K1: - return gfxd_puts("G_CV_K1"); - case G_CV_K2: - return gfxd_puts("G_CV_K2"); - case G_CV_K3: - return gfxd_puts("G_CV_K3"); - case G_CV_K4: - return gfxd_puts("G_CV_K4"); - case G_CV_K5: - return gfxd_puts("G_CV_K5"); - default: - return gfxd_printf("%" PRIi32, v->i); - } -} - -UCFUNC int argfn_ccmuxa(const gfxd_value_t *v) -{ - switch (v->i) - { - case G_CCMUX_COMBINED: - return gfxd_puts("COMBINED"); - case G_CCMUX_TEXEL0: - return gfxd_puts("TEXEL0"); - case G_CCMUX_TEXEL1: - return gfxd_puts("TEXEL1"); - case G_CCMUX_PRIMITIVE: - return gfxd_puts("PRIMITIVE"); - case G_CCMUX_SHADE: - return gfxd_puts("SHADE"); - case G_CCMUX_ENVIRONMENT: - return gfxd_puts("ENVIRONMENT"); - case G_CCMUX_1: - return gfxd_puts("1"); - case G_CCMUX_NOISE: - return gfxd_puts("NOISE"); - default: - return gfxd_puts("0"); - } -} - -UCFUNC int argfn_ccmuxb(const gfxd_value_t *v) -{ - switch (v->i) - { - case G_CCMUX_COMBINED: - return gfxd_puts("COMBINED"); - case G_CCMUX_TEXEL0: - return gfxd_puts("TEXEL0"); - case G_CCMUX_TEXEL1: - return gfxd_puts("TEXEL1"); - case G_CCMUX_PRIMITIVE: - return gfxd_puts("PRIMITIVE"); - case G_CCMUX_SHADE: - return gfxd_puts("SHADE"); - case G_CCMUX_ENVIRONMENT: - return gfxd_puts("ENVIRONMENT"); - case G_CCMUX_CENTER: - return gfxd_puts("CENTER"); - case G_CCMUX_K4: - return gfxd_puts("K4"); - default: - return gfxd_puts("0"); - } -} - -UCFUNC int argfn_ccmuxc(const gfxd_value_t *v) -{ - switch (v->i) - { - case G_CCMUX_COMBINED: - return gfxd_puts("COMBINED"); - case G_CCMUX_TEXEL0: - return gfxd_puts("TEXEL0"); - case G_CCMUX_TEXEL1: - return gfxd_puts("TEXEL1"); - case G_CCMUX_PRIMITIVE: - return gfxd_puts("PRIMITIVE"); - case G_CCMUX_SHADE: - return gfxd_puts("SHADE"); - case G_CCMUX_ENVIRONMENT: - return gfxd_puts("ENVIRONMENT"); - case G_CCMUX_SCALE: - return gfxd_puts("SCALE"); - case G_CCMUX_COMBINED_ALPHA: - return gfxd_puts("COMBINED_ALPHA"); - case G_CCMUX_TEXEL0_ALPHA: - return gfxd_puts("TEXEL0_ALPHA"); - case G_CCMUX_TEXEL1_ALPHA: - return gfxd_puts("TEXEL1_ALPHA"); - case G_CCMUX_PRIMITIVE_ALPHA: - return gfxd_puts("PRIMITIVE_ALPHA"); - case G_CCMUX_SHADE_ALPHA: - return gfxd_puts("SHADE_ALPHA"); - case G_CCMUX_ENV_ALPHA: - return gfxd_puts("ENV_ALPHA"); - case G_CCMUX_LOD_FRACTION: - return gfxd_puts("LOD_FRACTION"); - case G_CCMUX_PRIM_LOD_FRAC: - return gfxd_puts("PRIM_LOD_FRAC"); - case G_CCMUX_K5: - return gfxd_puts("K5"); - default: - return gfxd_puts("0"); - } -} - -UCFUNC int argfn_ccmuxd(const gfxd_value_t *v) -{ - switch (v->i) - { - case G_CCMUX_COMBINED: - return gfxd_puts("COMBINED"); - case G_CCMUX_TEXEL0: - return gfxd_puts("TEXEL0"); - case G_CCMUX_TEXEL1: - return gfxd_puts("TEXEL1"); - case G_CCMUX_PRIMITIVE: - return gfxd_puts("PRIMITIVE"); - case G_CCMUX_SHADE: - return gfxd_puts("SHADE"); - case G_CCMUX_ENVIRONMENT: - return gfxd_puts("ENVIRONMENT"); - case G_CCMUX_1: - return gfxd_puts("1"); - default: - return gfxd_puts("0"); - } -} - -UCFUNC int argfn_acmuxabd(const gfxd_value_t *v) -{ - switch (v->i) - { - case G_ACMUX_COMBINED: - return gfxd_puts("COMBINED"); - case G_ACMUX_TEXEL0: - return gfxd_puts("TEXEL0"); - case G_ACMUX_TEXEL1: - return gfxd_puts("TEXEL1"); - case G_ACMUX_PRIMITIVE: - return gfxd_puts("PRIMITIVE"); - case G_ACMUX_SHADE: - return gfxd_puts("SHADE"); - case G_ACMUX_ENVIRONMENT: - return gfxd_puts("ENVIRONMENT"); - case G_ACMUX_1: - return gfxd_puts("1"); - default: - return gfxd_puts("0"); - } -} - -UCFUNC int argfn_acmuxc(const gfxd_value_t *v) -{ - switch (v->i) - { - case G_ACMUX_LOD_FRACTION: - return gfxd_puts("LOD_FRACTION"); - case G_ACMUX_TEXEL0: - return gfxd_puts("TEXEL0"); - case G_ACMUX_TEXEL1: - return gfxd_puts("TEXEL1"); - case G_ACMUX_PRIMITIVE: - return gfxd_puts("PRIMITIVE"); - case G_ACMUX_SHADE: - return gfxd_puts("SHADE"); - case G_ACMUX_ENVIRONMENT: - return gfxd_puts("ENVIRONMENT"); - case G_ACMUX_PRIM_LOD_FRAC: - return gfxd_puts("PRIM_LOD_FRAC"); - default: - return gfxd_puts("0"); - } -} - -struct cc_mode -{ - int a; - int b; - int c; - int d; - int Aa; - int Ab; - int Ac; - int Ad; -}; - -struct cc_preset -{ - struct cc_mode mode; - const char * name; -}; - -#define CC_(a,b,c,d,Aa,Ab,Ac,Ad) \ - { \ - G_CCMUX_##a, G_CCMUX_##b, \ - G_CCMUX_##c, G_CCMUX_##d, \ - G_ACMUX_##Aa, G_ACMUX_##Ab, \ - G_ACMUX_##Ac, G_ACMUX_##Ad \ - } -#define CC(m) CC_(m) -static const struct cc_preset cc_presets[] = -{ - {CC(G_CC_MODULATEI), "G_CC_MODULATEI"}, - {CC(G_CC_MODULATEIA), "G_CC_MODULATEIA"}, - {CC(G_CC_MODULATEIDECALA), "G_CC_MODULATEIDECALA"}, - {CC(G_CC_MODULATERGB), "G_CC_MODULATERGB"}, - {CC(G_CC_MODULATERGBA), "G_CC_MODULATERGBA"}, - {CC(G_CC_MODULATERGBDECALA), "G_CC_MODULATERGBDECALA"}, - {CC(G_CC_MODULATEI_PRIM), "G_CC_MODULATEI_PRIM"}, - {CC(G_CC_MODULATEIA_PRIM), "G_CC_MODULATEIA_PRIM"}, - {CC(G_CC_MODULATEIDECALA_PRIM), "G_CC_MODULATEIDECALA_PRIM"}, - {CC(G_CC_MODULATERGB_PRIM), "G_CC_MODULATERGB_PRIM"}, - {CC(G_CC_MODULATERGBA_PRIM), "G_CC_MODULATERGBA_PRIM"}, - {CC(G_CC_MODULATERGBDECALA_PRIM), "G_CC_MODULATERGBDECALA_PRIM"}, - {CC(G_CC_DECALRGB), "G_CC_DECALRGB"}, - {CC(G_CC_DECALRGBA), "G_CC_DECALRGBA"}, - {CC(G_CC_BLENDI), "G_CC_BLENDI"}, - {CC(G_CC_BLENDIA), "G_CC_BLENDIA"}, - {CC(G_CC_BLENDIDECALA), "G_CC_BLENDIDECALA"}, - {CC(G_CC_BLENDRGBA), "G_CC_BLENDRGBA"}, - {CC(G_CC_BLENDRGBDECALA), "G_CC_BLENDRGBDECALA"}, - {CC(G_CC_REFLECTRGB), "G_CC_REFLECTRGB"}, - {CC(G_CC_REFLECTRGBDECALA), "G_CC_REFLECTRGBDECALA"}, - {CC(G_CC_HILITERGB), "G_CC_HILITERGB"}, - {CC(G_CC_HILITERGBA), "G_CC_HILITERGBA"}, - {CC(G_CC_HILITERGBDECALA), "G_CC_HILITERGBDECALA"}, - {CC(G_CC_1CYUV2RGB), "G_CC_1CYUV2RGB"}, - {CC(G_CC_PRIMITIVE), "G_CC_PRIMITIVE"}, - {CC(G_CC_SHADE), "G_CC_SHADE"}, - {CC(G_CC_ADDRGB), "G_CC_ADDRGB"}, - {CC(G_CC_ADDRGBDECALA), "G_CC_ADDRGBDECALA"}, - {CC(G_CC_SHADEDECALA), "G_CC_SHADEDECALA"}, - {CC(G_CC_BLENDPE), "G_CC_BLENDPE"}, - {CC(G_CC_BLENDPEDECALA), "G_CC_BLENDPEDECALA"}, - {CC(G_CC_TRILERP), "G_CC_TRILERP"}, - {CC(G_CC_TEMPLERP), "G_CC_TEMPLERP"}, - {CC(G_CC_INTERFERENCE), "G_CC_INTERFERENCE"}, - {CC(_G_CC_BLENDPE), "_G_CC_BLENDPE"}, - {CC(_G_CC_BLENDPEDECALA), "_G_CC_BLENDPEDECALA"}, - {CC(_G_CC_SPARSEST), "_G_CC_SPARSEST"}, - {CC(_G_CC_TWOCOLORTEX), "_G_CC_TWOCOLORTEX"}, - {CC(G_CC_MODULATEI2), "G_CC_MODULATEI2"}, - {CC(G_CC_MODULATEIA2), "G_CC_MODULATEIA2"}, - {CC(G_CC_MODULATERGB2), "G_CC_MODULATERGB2"}, - {CC(G_CC_MODULATERGBA2), "G_CC_MODULATERGBA2"}, - {CC(G_CC_MODULATEI_PRIM2), "G_CC_MODULATEI_PRIM2"}, - {CC(G_CC_MODULATEIA_PRIM2), "G_CC_MODULATEIA_PRIM2"}, - {CC(G_CC_MODULATERGB_PRIM2), "G_CC_MODULATERGB_PRIM2"}, - {CC(G_CC_MODULATERGBA_PRIM2), "G_CC_MODULATERGBA_PRIM2"}, - {CC(G_CC_DECALRGB2), "G_CC_DECALRGB2"}, - {CC(G_CC_BLENDI2), "G_CC_BLENDI2"}, - {CC(G_CC_BLENDIA2), "G_CC_BLENDIA2"}, - {CC(G_CC_HILITERGB2), "G_CC_HILITERGB2"}, - {CC(G_CC_HILITERGBA2), "G_CC_HILITERGBA2"}, - {CC(G_CC_HILITERGBDECALA2), "G_CC_HILITERGBDECALA2"}, - {CC(G_CC_HILITERGBPASSA2), "G_CC_HILITERGBPASSA2"}, - {CC(G_CC_CHROMA_KEY2), "G_CC_CHROMA_KEY2"}, - {CC(G_CC_YUV2RGB), "G_CC_YUV2RGB"}, - {CC(G_CC_PASS2), "G_CC_PASS2"}, -}; -#undef CC_ -#undef CC - -UCFUNC int argfn_ccpre(const gfxd_value_t *v) -{ - return gfxd_printf("%s", cc_presets[v->i].name); -} - -UCFUNC int argfn_sc(const gfxd_value_t *v) -{ - switch (v->i) - { - case G_SC_NON_INTERLACE: - return gfxd_puts("G_SC_NON_INTERLACE"); - case G_SC_EVEN_INTERLACE: - return gfxd_puts("G_SC_EVEN_INTERLACE"); - case G_SC_ODD_INTERLACE: - return gfxd_puts("G_SC_ODD_INTERLACE"); - default: - return gfxd_printf("%" PRIi32, v->i); - } -} - -#if defined(F3DEX_GBI) || defined(F3DEX_GBI_2) -UCFUNC int argfn_bz(const gfxd_value_t *v) -{ - switch (v->i) - { - case G_BZ_PERSP: - return gfxd_puts("G_BZ_PERSP"); - default: - return gfxd_puts("G_BZ_ORTHO"); - } -} -#endif - -UCFUNC int argfn_dlf(const gfxd_value_t *v) -{ - switch (v->i) - { - case G_DL_PUSH: - return gfxd_puts("G_DL_PUSH"); - case G_DL_NOPUSH: - return gfxd_puts("G_DL_NOPUSH"); - default: - return gfxd_printf("%" PRIi32, v->i);; - } -} - -UCFUNC int argfn_mp(const gfxd_value_t *v) -{ - int n = 0; - if (v->u & G_MTX_PUSH) - n += gfxd_puts("G_MTX_PUSH"); - else - n += gfxd_puts("G_MTX_NOPUSH"); - if (v->u & G_MTX_LOAD) - n += gfxd_puts(" | G_MTX_LOAD"); - else - n += gfxd_puts(" | G_MTX_MUL"); - if (v->u & G_MTX_PROJECTION) - n += gfxd_puts(" | G_MTX_PROJECTION"); - else - n += gfxd_puts(" | G_MTX_MODELVIEW"); - for (int i = 3; i < 8; i++) - if (v->u & (1 << i)) - n += gfxd_printf(" | 0x%02x", 1 << i); - return n; -} - -UCFUNC int argfn_ms(const gfxd_value_t *v) -{ - switch (v->i) - { - case G_MTX_MODELVIEW: - return gfxd_puts("G_MTX_MODELVIEW"); - case G_MTX_PROJECTION: - return gfxd_puts("G_MTX_PROJECTION"); - default: - return gfxd_printf("%" PRIi32, v->i); - } -} - -UCFUNC int argfn_mw(const gfxd_value_t *v) -{ - switch (v->i) - { - case G_MW_MATRIX: - return gfxd_puts("G_MW_MATRIX"); - case G_MW_NUMLIGHT: - return gfxd_puts("G_MW_NUMLIGHT"); - case G_MW_CLIP: - return gfxd_puts("G_MW_CLIP"); - case G_MW_SEGMENT: - return gfxd_puts("G_MW_SEGMENT"); - case G_MW_FOG: - return gfxd_puts("G_MW_FOG"); - case G_MW_LIGHTCOL: - return gfxd_puts("G_MW_LIGHTCOL"); - case G_MW_PERSPNORM: - return gfxd_puts("G_MW_PERSPNORM"); -#if defined(F3D_GBI) || defined(F3DEX_GBI) - case G_MW_POINTS: - return gfxd_puts("G_MW_POINTS"); -#endif -#if defined(F3DEX_GBI_2) - case G_MW_FORCEMTX: - return gfxd_puts("G_MW_FORCEMTX"); -#endif - default: - return gfxd_printf("%" PRIi32, v->i); - } -} - -UCFUNC int argfn_mwo_clip(const gfxd_value_t *v) -{ - switch (v->u) - { - case G_MWO_CLIP_RNX: - return gfxd_puts("G_MWO_CLIP_RNX"); - case G_MWO_CLIP_RNY: - return gfxd_puts("G_MWO_CLIP_RNY"); - case G_MWO_CLIP_RPX: - return gfxd_puts("G_MWO_CLIP_RPX"); - case G_MWO_CLIP_RPY: - return gfxd_puts("G_MWO_CLIP_RPY"); - default: - return gfxd_printf("0x%04" PRIX32, v->u); - } -} - -UCFUNC int argfn_mwo_lightcol(const gfxd_value_t *v) -{ - switch (v->u) - { - case G_MWO_aLIGHT_1: - return gfxd_puts("G_MWO_aLIGHT_1"); - case G_MWO_bLIGHT_1: - return gfxd_puts("G_MWO_bLIGHT_1"); - case G_MWO_aLIGHT_2: - return gfxd_puts("G_MWO_aLIGHT_2"); - case G_MWO_bLIGHT_2: - return gfxd_puts("G_MWO_bLIGHT_2"); - case G_MWO_aLIGHT_3: - return gfxd_puts("G_MWO_aLIGHT_3"); - case G_MWO_bLIGHT_3: - return gfxd_puts("G_MWO_bLIGHT_3"); - case G_MWO_aLIGHT_4: - return gfxd_puts("G_MWO_aLIGHT_4"); - case G_MWO_bLIGHT_4: - return gfxd_puts("G_MWO_bLIGHT_4"); - case G_MWO_aLIGHT_5: - return gfxd_puts("G_MWO_aLIGHT_5"); - case G_MWO_bLIGHT_5: - return gfxd_puts("G_MWO_bLIGHT_5"); - case G_MWO_aLIGHT_6: - return gfxd_puts("G_MWO_aLIGHT_6"); - case G_MWO_bLIGHT_6: - return gfxd_puts("G_MWO_bLIGHT_6"); - case G_MWO_aLIGHT_7: - return gfxd_puts("G_MWO_aLIGHT_7"); - case G_MWO_bLIGHT_7: - return gfxd_puts("G_MWO_bLIGHT_7"); - case G_MWO_aLIGHT_8: - return gfxd_puts("G_MWO_aLIGHT_8"); - case G_MWO_bLIGHT_8: - return gfxd_puts("G_MWO_bLIGHT_8"); - default: - return gfxd_printf("0x%04" PRIX32, v->u); - } -} - -UCFUNC int argfn_lightnum(const gfxd_value_t *v) -{ - return gfxd_printf("LIGHT_%" PRIi32, v->i); -} - -UCFUNC int argfn_lightsn(const gfxd_value_t *v) -{ - return gfxd_printf("*(Lightsn *)0x%08" PRIX32, v->u); -} - -UCFUNC int argfn_mwo_matrix(const gfxd_value_t *v) -{ - switch (v->u) - { - case G_MWO_MATRIX_XX_XY_I: - return gfxd_puts("G_MWO_MATRIX_XX_XY_I"); - case G_MWO_MATRIX_XZ_XW_I: - return gfxd_puts("G_MWO_MATRIX_XZ_XW_I"); - case G_MWO_MATRIX_YX_YY_I: - return gfxd_puts("G_MWO_MATRIX_YX_YY_I"); - case G_MWO_MATRIX_YZ_YW_I: - return gfxd_puts("G_MWO_MATRIX_YZ_YW_I"); - case G_MWO_MATRIX_ZX_ZY_I: - return gfxd_puts("G_MWO_MATRIX_ZX_ZY_I"); - case G_MWO_MATRIX_ZZ_ZW_I: - return gfxd_puts("G_MWO_MATRIX_ZZ_ZW_I"); - case G_MWO_MATRIX_WX_WY_I: - return gfxd_puts("G_MWO_MATRIX_WX_WY_I"); - case G_MWO_MATRIX_WZ_WW_I: - return gfxd_puts("G_MWO_MATRIX_WZ_WW_I"); - case G_MWO_MATRIX_XX_XY_F: - return gfxd_puts("G_MWO_MATRIX_XX_XY_F"); - case G_MWO_MATRIX_XZ_XW_F: - return gfxd_puts("G_MWO_MATRIX_XZ_XW_F"); - case G_MWO_MATRIX_YX_YY_F: - return gfxd_puts("G_MWO_MATRIX_YX_YY_F"); - case G_MWO_MATRIX_YZ_YW_F: - return gfxd_puts("G_MWO_MATRIX_YZ_YW_F"); - case G_MWO_MATRIX_ZX_ZY_F: - return gfxd_puts("G_MWO_MATRIX_ZX_ZY_F"); - case G_MWO_MATRIX_ZZ_ZW_F: - return gfxd_puts("G_MWO_MATRIX_ZZ_ZW_F"); - case G_MWO_MATRIX_WX_WY_F: - return gfxd_puts("G_MWO_MATRIX_WX_WY_F"); - case G_MWO_MATRIX_WZ_WW_F: - return gfxd_puts("G_MWO_MATRIX_WZ_WW_F"); - default: - return gfxd_printf("0x%04" PRIX32, v->u); - } -} - -UCFUNC int argfn_mwo_point(const gfxd_value_t *v) -{ - switch (v->u) - { - case G_MWO_POINT_RGBA: - return gfxd_puts("G_MWO_POINT_RGBA"); - case G_MWO_POINT_ST: - return gfxd_puts("G_MWO_POINT_ST"); - case G_MWO_POINT_XYSCREEN: - return gfxd_puts("G_MWO_POINT_XYSCREEN"); - case G_MWO_POINT_ZSCREEN: - return gfxd_puts("G_MWO_POINT_ZSCREEN"); - default: - return gfxd_printf("0x%04" PRIX32, v->u); - } -} - -UCFUNC int argfn_mv(const gfxd_value_t *v) -{ - switch (v->i) - { - case G_MV_VIEWPORT: - return gfxd_puts("G_MV_VIEWPORT"); -#if defined(F3D_GBI) || defined(F3DEX_GBI) - case G_MV_LOOKATY: - return gfxd_puts("G_MV_LOOKATY"); - case G_MV_LOOKATX: - return gfxd_puts("G_MV_LOOKATX"); - case G_MV_L0: - return gfxd_puts("G_MV_L0"); - case G_MV_L1: - return gfxd_puts("G_MV_L1"); - case G_MV_L2: - return gfxd_puts("G_MV_L2"); - case G_MV_L3: - return gfxd_puts("G_MV_L3"); - case G_MV_L4: - return gfxd_puts("G_MV_L4"); - case G_MV_L5: - return gfxd_puts("G_MV_L5"); - case G_MV_L6: - return gfxd_puts("G_MV_L6"); - case G_MV_L7: - return gfxd_puts("G_MV_L7"); - case G_MV_TXTATT: - return gfxd_puts("G_MV_TXTATT"); - case G_MV_MATRIX_2: - return gfxd_puts("G_MV_MATRIX_2"); - case G_MV_MATRIX_3: - return gfxd_puts("G_MV_MATRIX_3"); - case G_MV_MATRIX_4: - return gfxd_puts("G_MV_MATRIX_4"); - case G_MV_MATRIX_1: - return gfxd_puts("G_MV_MATRIX_1"); -#elif defined(F3DEX_GBI_2) - case G_MV_MMTX: - return gfxd_puts("G_MV_MMTX"); - case G_MV_PMTX: - return gfxd_puts("G_MV_PMTX"); - case G_MV_LIGHT: - return gfxd_puts("G_MV_LIGHT"); - case G_MV_POINT: - return gfxd_puts("G_MV_POINT"); - case G_MV_MATRIX: - return gfxd_puts("G_MV_MATRIX"); -#endif - default: - return gfxd_printf("%" PRIi32, v->i); - } -} - -UCFUNC int argfn_cr(const gfxd_value_t *v) -{ - switch (v->u) - { - case FRUSTRATIO_1: - return gfxd_puts("FRUSTRATIO_1"); - case FRUSTRATIO_2: - return gfxd_puts("FRUSTRATIO_2"); - case FRUSTRATIO_3: - return gfxd_puts("FRUSTRATIO_3"); - case FRUSTRATIO_4: - return gfxd_puts("FRUSTRATIO_4"); - case FRUSTRATIO_5: - return gfxd_puts("FRUSTRATIO_5"); - case FRUSTRATIO_6: - return gfxd_puts("FRUSTRATIO_6"); - default: - return gfxd_printf("%" PRIu32, v->u); - } -} diff --git a/ZAPDTR/lib/libgfxd/uc_argtbl.c b/ZAPDTR/lib/libgfxd/uc_argtbl.c deleted file mode 100644 index 22a0b6500..000000000 --- a/ZAPDTR/lib/libgfxd/uc_argtbl.c +++ /dev/null @@ -1,485 +0,0 @@ -static const gfxd_arg_type_t arg_tbl[] = -{ - [gfxd_Word] = - { - .fmt = gfxd_argfmt_u, - .fn = argfn_x32, - }, - [gfxd_Opcode] = - { - .fmt = gfxd_argfmt_i, - .fn = argfn_opc, - }, - [gfxd_Coordi] = - { - .fmt = gfxd_argfmt_u, - .fn = argfn_u, - }, - [gfxd_Coordq] = - { - .fmt = gfxd_argfmt_u, - .fn = argfn_qu102, - }, - [gfxd_Pal] = - { - .fmt = gfxd_argfmt_i, - .fn = argfn_i, - }, - [gfxd_Tlut] = - { - .fmt = gfxd_argfmt_u, - .fn = argfn_x32, - }, - [gfxd_Timg] = - { - .fmt = gfxd_argfmt_u, - .fn = argfn_x32, - }, - [gfxd_Tmem] = - { - .fmt = gfxd_argfmt_u, - .fn = argfn_x16, - }, - [gfxd_Tile] = - { - .fmt = gfxd_argfmt_i, - .fn = argfn_tile, - }, - [gfxd_Fmt] = - { - .fmt = gfxd_argfmt_i, - .fn = argfn_fmt, - }, - [gfxd_Siz] = - { - .fmt = gfxd_argfmt_i, - .fn = argfn_siz, - }, - [gfxd_Dim] = - { - .fmt = gfxd_argfmt_i, - .fn = argfn_i, - }, - [gfxd_Cm] = - { - .fmt = gfxd_argfmt_u, - .fn = argfn_cm, - }, - [gfxd_Tm] = - { - .fmt = gfxd_argfmt_i, - .fn = argfn_tm, - }, - [gfxd_Ts] = - { - .fmt = gfxd_argfmt_i, - .fn = argfn_ts, - }, - [gfxd_Dxt] = - { - .fmt = gfxd_argfmt_u, - .fn = argfn_u, - }, - [gfxd_Tag] = - { - .fmt = gfxd_argfmt_u, - .fn = argfn_x32, - }, - [gfxd_Pm] = - { - .fmt = gfxd_argfmt_u, - .fn = argfn_pm, - }, - [gfxd_Colorpart] = - { - .fmt = gfxd_argfmt_u, - .fn = argfn_color, - }, - [gfxd_Color] = - { - .fmt = gfxd_argfmt_u, - .fn = argfn_x32, - }, - [gfxd_Lodfrac] = - { - .fmt = gfxd_argfmt_u, - .fn = argfn_qu08, - }, - [gfxd_Cimg] = - { - .fmt = gfxd_argfmt_u, - .fn = argfn_x32, - }, - [gfxd_Zimg] = - { - .fmt = gfxd_argfmt_u, - .fn = argfn_x32, - }, - [gfxd_Ac] = - { - .fmt = gfxd_argfmt_u, - .fn = argfn_ac, - }, - [gfxd_Ad] = - { - .fmt = gfxd_argfmt_u, - .fn = argfn_ad, - }, - [gfxd_Cd] = - { - .fmt = gfxd_argfmt_u, - .fn = argfn_cd, - }, - [gfxd_Ccpre] = - { - .fmt = gfxd_argfmt_u, - .fn = argfn_ccpre, - }, - [gfxd_Ccmuxa] = - { - .fmt = gfxd_argfmt_i, - .fn = argfn_ccmuxa, - }, - [gfxd_Ccmuxb] = - { - .fmt = gfxd_argfmt_i, - .fn = argfn_ccmuxb, - }, - [gfxd_Ccmuxc] = - { - .fmt = gfxd_argfmt_i, - .fn = argfn_ccmuxc, - }, - [gfxd_Ccmuxd] = - { - .fmt = gfxd_argfmt_i, - .fn = argfn_ccmuxd, - }, - [gfxd_Acmuxabd] = - { - .fmt = gfxd_argfmt_i, - .fn = argfn_acmuxabd, - }, - [gfxd_Acmuxc] = - { - .fmt = gfxd_argfmt_i, - .fn = argfn_acmuxc, - }, - [gfxd_Cv] = - { - .fmt = gfxd_argfmt_i, - .fn = argfn_cv, - }, - [gfxd_Tc] = - { - .fmt = gfxd_argfmt_u, - .fn = argfn_tc, - }, - [gfxd_Cyc] = - { - .fmt = gfxd_argfmt_u, - .fn = argfn_cyc, - }, - [gfxd_Zs] = - { - .fmt = gfxd_argfmt_u, - .fn = argfn_zs, - }, - [gfxd_Ck] = - { - .fmt = gfxd_argfmt_u, - .fn = argfn_ck, - }, - [gfxd_Keyscale] = - { - .fmt = gfxd_argfmt_u, - .fn = argfn_color, - }, - [gfxd_Keywidth] = - { - .fmt = gfxd_argfmt_i, - .fn = argfn_qs48, - }, - [gfxd_Zi] = - { - .fmt = gfxd_argfmt_i, - .fn = argfn_i, - }, - [gfxd_Rm1] = - { - .fmt = gfxd_argfmt_u, - .fn = argfn_rm1, - }, - [gfxd_Rm2] = - { - .fmt = gfxd_argfmt_u, - .fn = argfn_rm2, - }, - [gfxd_Sc] = - { - .fmt = gfxd_argfmt_i, - .fn = argfn_sc, - }, - [gfxd_Td] = - { - .fmt = gfxd_argfmt_u, - .fn = argfn_td, - }, - [gfxd_Tf] = - { - .fmt = gfxd_argfmt_u, - .fn = argfn_tf, - }, - [gfxd_Tl] = - { - .fmt = gfxd_argfmt_u, - .fn = argfn_tl, - }, - [gfxd_Tt] = - { - .fmt = gfxd_argfmt_u, - .fn = argfn_tt, - }, - [gfxd_Tp] = - { - .fmt = gfxd_argfmt_u, - .fn = argfn_tp, - }, - [gfxd_Line] = - { - .fmt = gfxd_argfmt_i, - .fn = argfn_i, - }, - [gfxd_Vtx] = - { - .fmt = gfxd_argfmt_i, - .fn = argfn_i, - }, - [gfxd_Vtxflag] = - { - .fmt = gfxd_argfmt_i, - .fn = argfn_i, - }, - [gfxd_Dl] = - { - .fmt = gfxd_argfmt_u, - .fn = argfn_x32, - }, -#if defined(F3DEX_GBI) || defined(F3DEX_GBI_2) - [gfxd_Zraw] = - { - .fmt = gfxd_argfmt_i, - .fn = argfn_qs1616, - }, -#endif - [gfxd_Dlflag] = - { - .fmt = gfxd_argfmt_i, - .fn = argfn_dlf, - }, - [gfxd_Cr] = - { - .fmt = gfxd_argfmt_u, - .fn = argfn_cr, - }, - [gfxd_Num] = - { - .fmt = gfxd_argfmt_i, - .fn = argfn_i, - }, - [gfxd_Fogz] = - { - .fmt = gfxd_argfmt_i, - .fn = argfn_i, - }, - [gfxd_Fogp] = - { - .fmt = gfxd_argfmt_i, - .fn = argfn_i, - }, - [gfxd_Mtxptr] = - { - .fmt = gfxd_argfmt_u, - .fn = argfn_x32, - }, - [gfxd_Gm] = - { - .fmt = gfxd_argfmt_u, - .fn = argfn_gm, - }, - [gfxd_Mwo_matrix] = - { - .fmt = gfxd_argfmt_u, - .fn = argfn_mwo_matrix, - }, - [gfxd_Linewd] = - { - .fmt = gfxd_argfmt_i, - .fn = argfn_i, - }, - [gfxd_Uctext] = - { - .fmt = gfxd_argfmt_u, - .fn = argfn_x32, - }, - [gfxd_Ucdata] = - { - .fmt = gfxd_argfmt_u, - .fn = argfn_x32, - }, - [gfxd_Size] = - { - .fmt = gfxd_argfmt_u, - .fn = argfn_x16, - }, - [gfxd_Lookatptr] = - { - .fmt = gfxd_argfmt_u, - .fn = argfn_x32, - }, - [gfxd_Mtxparam] = - { - .fmt = gfxd_argfmt_i, - .fn = argfn_mp, - }, - [gfxd_Mtxstack] = - { - .fmt = gfxd_argfmt_i, - .fn = argfn_ms, - }, - [gfxd_Mwo_point] = - { - .fmt = gfxd_argfmt_u, - .fn = argfn_mwo_point, - }, - [gfxd_Wscale] = - { - .fmt = gfxd_argfmt_u, - .fn = argfn_qu016, - }, - [gfxd_Seg] = - { - .fmt = gfxd_argfmt_u, - .fn = argfn_x8, - }, - [gfxd_Segptr] = - { - .fmt = gfxd_argfmt_u, - .fn = argfn_x32, - }, - [gfxd_Lightsn] = - { - .fmt = gfxd_argfmt_u, - .fn = argfn_lightsn, - }, - [gfxd_Numlights] = - { - .fmt = gfxd_argfmt_i, - .fn = argfn_i, - }, - [gfxd_Lightnum] = - { - .fmt = gfxd_argfmt_i, - .fn = argfn_lightnum, - }, - [gfxd_Lightptr] = - { - .fmt = gfxd_argfmt_u, - .fn = argfn_x32, - }, - [gfxd_Tcscale] = - { - .fmt = gfxd_argfmt_u, - .fn = argfn_qu016, - }, - [gfxd_Switch] = - { - .fmt = gfxd_argfmt_i, - .fn = argfn_switch, - }, - [gfxd_St] = - { - .fmt = gfxd_argfmt_i, - .fn = argfn_qs105, - }, - [gfxd_Stdelta] = - { - .fmt = gfxd_argfmt_i, - .fn = argfn_qs510, - }, - [gfxd_Vtxptr] = - { - .fmt = gfxd_argfmt_u, - .fn = argfn_x32, - }, - [gfxd_Vpptr] = - { - .fmt = gfxd_argfmt_u, - .fn = argfn_x32, - }, - [gfxd_Dram] = - { - .fmt = gfxd_argfmt_u, - .fn = argfn_x32, - }, - [gfxd_Sftlo] = - { - .fmt = gfxd_argfmt_i, - .fn = argfn_sftlo, - }, - [gfxd_Othermodelo] = - { - .fmt = gfxd_argfmt_u, - .fn = argfn_othermodelo, - }, - [gfxd_Sfthi] = - { - .fmt = gfxd_argfmt_i, - .fn = argfn_sfthi, - }, - [gfxd_Othermodehi] = - { - .fmt = gfxd_argfmt_u, - .fn = argfn_othermodehi, - }, - [gfxd_Mw] = - { - .fmt = gfxd_argfmt_i, - .fn = argfn_mw, - }, - [gfxd_Mwo] = - { - .fmt = gfxd_argfmt_u, - .fn = argfn_x16, - }, - [gfxd_Mwo_clip] = - { - .fmt = gfxd_argfmt_u, - .fn = argfn_mwo_clip, - }, - [gfxd_Mwo_lightcol] = - { - .fmt = gfxd_argfmt_u, - .fn = argfn_mwo_lightcol, - }, - [gfxd_Mv] = - { - .fmt = gfxd_argfmt_i, - .fn = argfn_mv, - }, - [gfxd_Mvo] = - { - .fmt = gfxd_argfmt_u, - .fn = argfn_x16, - }, - [gfxd_Dmem] = - { - .fmt = gfxd_argfmt_u, - .fn = argfn_x16, - }, - [gfxd_Dmaflag] = - { - .fmt = gfxd_argfmt_i, - .fn = argfn_i, - }, -}; diff --git a/ZAPDTR/lib/libgfxd/uc_f3d.c b/ZAPDTR/lib/libgfxd/uc_f3d.c deleted file mode 100644 index 946551510..000000000 --- a/ZAPDTR/lib/libgfxd/uc_f3d.c +++ /dev/null @@ -1,4 +0,0 @@ -#define uc_name gfxd_f3d -#define F3D_GBI - -#include "uc.c" diff --git a/ZAPDTR/lib/libgfxd/uc_f3db.c b/ZAPDTR/lib/libgfxd/uc_f3db.c deleted file mode 100644 index cd4990412..000000000 --- a/ZAPDTR/lib/libgfxd/uc_f3db.c +++ /dev/null @@ -1,5 +0,0 @@ -#define uc_name gfxd_f3db -#define F3D_GBI -#define F3D_BETA - -#include "uc.c" diff --git a/ZAPDTR/lib/libgfxd/uc_f3dex.c b/ZAPDTR/lib/libgfxd/uc_f3dex.c deleted file mode 100644 index 2ec70d8ab..000000000 --- a/ZAPDTR/lib/libgfxd/uc_f3dex.c +++ /dev/null @@ -1,4 +0,0 @@ -#define uc_name gfxd_f3dex -#define F3DEX_GBI - -#include "uc.c" diff --git a/ZAPDTR/lib/libgfxd/uc_f3dex2.c b/ZAPDTR/lib/libgfxd/uc_f3dex2.c deleted file mode 100644 index 9a19c9903..000000000 --- a/ZAPDTR/lib/libgfxd/uc_f3dex2.c +++ /dev/null @@ -1,4 +0,0 @@ -#define uc_name gfxd_f3dex2 -#define F3DEX_GBI_2 - -#include "uc.c" diff --git a/ZAPDTR/lib/libgfxd/uc_f3dexb.c b/ZAPDTR/lib/libgfxd/uc_f3dexb.c deleted file mode 100644 index 2b5c30a4a..000000000 --- a/ZAPDTR/lib/libgfxd/uc_f3dexb.c +++ /dev/null @@ -1,5 +0,0 @@ -#define uc_name gfxd_f3dexb -#define F3DEX_GBI -#define F3D_BETA - -#include "uc.c" diff --git a/ZAPDTR/lib/libgfxd/uc_macrofn.c b/ZAPDTR/lib/libgfxd/uc_macrofn.c deleted file mode 100644 index 46d4b4ee8..000000000 --- a/ZAPDTR/lib/libgfxd/uc_macrofn.c +++ /dev/null @@ -1,2507 +0,0 @@ -static inline uint32_t getfield(uint32_t w, int n, int s) -{ - return (w >> s) & (((uint32_t)1 << n) - 1); -} - -static inline int32_t argvi(gfxd_macro_t *m, int idx) -{ - return m->arg[idx].value.i; -} - -static inline uint32_t argvu(gfxd_macro_t *m, int idx) -{ - return m->arg[idx].value.u; -} - -static inline float argvf(gfxd_macro_t *m, int idx) -{ - return m->arg[idx].value.f; -} - -static inline void argi(gfxd_macro_t *m, int idx, const char *name, - int32_t value, int type) -{ - m->arg[idx].type = type; - m->arg[idx].name = name; - m->arg[idx].value.i = value; - m->arg[idx].bad = 0; -} - -static inline void argu(gfxd_macro_t *m, int idx, const char *name, - uint32_t value, int type) -{ - m->arg[idx].type = type; - m->arg[idx].name = name; - m->arg[idx].value.u = value; - m->arg[idx].bad = 0; -} - -static inline void argf(gfxd_macro_t *m, int idx, const char *name, - float value, int type) -{ - m->arg[idx].type = type; - m->arg[idx].name = name; - m->arg[idx].value.f = value; - m->arg[idx].bad = 0; -} - -static inline void badarg(gfxd_macro_t *m, int idx) -{ - m->arg[idx].bad = 1; -} - -UCFUNC int32_t sx(uint32_t n, int bits) -{ - int32_t smin = (int32_t)1 << (bits - 1); - int32_t smax = (int32_t)1 << bits; - int32_t i = n; - if (i < smin) - return i; - else - return i - smax; -} - -UCFUNC int d_Invalid(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_Invalid; - argu(m, 0, "hi", hi, gfxd_Word); - argu(m, 1, "lo", lo, gfxd_Word); - return -1; -} - -UCFUNC int d_DPFillRectangle(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_DPFillRectangle; - argu(m, 0, "ulx", getfield(lo, 10, 14), gfxd_Coordi); - argu(m, 1, "uly", getfield(lo, 10, 2), gfxd_Coordi); - argu(m, 2, "lrx", getfield(hi, 10, 14), gfxd_Coordi); - argu(m, 3, "lry", getfield(hi, 10, 2), gfxd_Coordi); - return 0; -} - -UCFUNC int d_DPFullSync(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_DPFullSync; - return 0; -} - -UCFUNC int d_DPLoadSync(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_DPLoadSync; - return 0; -} - -UCFUNC int d_DPTileSync(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_DPTileSync; - return 0; -} - -UCFUNC int d_DPPipeSync(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_DPPipeSync; - return 0; -} - -UCFUNC int c_DPLoadTLUT_pal16(gfxd_macro_t *m, int n_macro) -{ - if (n_macro < 6) - return -1; - if (m[0].id != gfxd_DPSetTextureImage - || argvi(&m[0], 0) != G_IM_FMT_RGBA - || argvi(&m[0], 1) != G_IM_SIZ_16b - || argvi(&m[0], 2) != 1) - { - return -1; - } - uint32_t dram = argvu(&m[0], 3); - if (m[1].id != gfxd_DPTileSync) - return -1; - if (m[2].id != gfxd_DPSetTile - || argvi(&m[2], 0) != 0 - || argvi(&m[2], 1) != 0 - || argvi(&m[2], 2) != 0 - || argvu(&m[2], 3) < 0x100 - || argvu(&m[2], 3) % 0x10 != 0 - || argvi(&m[2], 4) != G_TX_LOADTILE - || argvi(&m[2], 5) != 0 - || argvu(&m[2], 6) != 0 - || argvi(&m[2], 7) != 0 - || argvi(&m[2], 8) != 0 - || argvu(&m[2], 9) != 0 - || argvi(&m[2], 10) != 0 - || argvi(&m[2], 11) != 0) - { - return -1; - } - int pal = (argvu(&m[2], 3) - 0x100) / 0x10; - if (m[3].id != gfxd_DPLoadSync) - return -1; - if (m[4].id != gfxd_DPLoadTLUTCmd - || argvi(&m[4], 0) != G_TX_LOADTILE - || argvi(&m[4], 1) != 15) - { - return -1; - } - if (m[5].id != gfxd_DPPipeSync) - return -1; - m->id = gfxd_DPLoadTLUT_pal16; - argi(m, 0, "pal", pal, gfxd_Pal); - argu(m, 1, "dram", dram, gfxd_Tlut); - return 0; -} - -UCFUNC int c_DPLoadTLUT_pal256(gfxd_macro_t *m, int n_macro) -{ - if (n_macro < 6) - return -1; - if (m[0].id != gfxd_DPSetTextureImage - || argvi(&m[0], 0) != G_IM_FMT_RGBA - || argvi(&m[0], 1) != G_IM_SIZ_16b - || argvi(&m[0], 2) != 1) - { - return -1; - } - uint32_t dram = argvu(&m[0], 3); - if (m[1].id != gfxd_DPTileSync) - return -1; - if (m[2].id != gfxd_DPSetTile - || argvi(&m[2], 0) != 0 - || argvi(&m[2], 1) != 0 - || argvi(&m[2], 2) != 0 - || argvu(&m[2], 3) != 0x100 - || argvi(&m[2], 4) != G_TX_LOADTILE - || argvi(&m[2], 5) != 0 - || argvu(&m[2], 6) != 0 - || argvi(&m[2], 7) != 0 - || argvi(&m[2], 8) != 0 - || argvu(&m[2], 9) != 0 - || argvi(&m[2], 10) != 0 - || argvi(&m[2], 11) != 0) - { - return -1; - } - if (m[3].id != gfxd_DPLoadSync) - return -1; - if (m[4].id != gfxd_DPLoadTLUTCmd - || argvi(&m[4], 0) != G_TX_LOADTILE - || argvi(&m[4], 1) != 255) - { - return -1; - } - if (m[5].id != gfxd_DPPipeSync) - return -1; - m->id = gfxd_DPLoadTLUT_pal256; - argu(m, 0, "dram", dram, gfxd_Tlut); - return 0; -} - -UCFUNC int c_ltb(gfxd_macro_t *m, int n_macro, int id, int mdxt, int mtmem, - int mrt, int myuv, int m4b) -{ - if (n_macro < 7) - return -1; - if (m[0].id != gfxd_DPSetTextureImage || argvi(&m[0], 2) != 1) - return -1; - g_ifmt_t fmt = argvi(&m[0], 0); - g_isiz_t ldsiz = argvi(&m[0], 1); - uint32_t timg = argvu(&m[0], 3); - if (myuv && fmt != G_IM_FMT_YUV) - return -1; - if (m[1].id != gfxd_DPSetTile - || argvi(&m[1], 0) != fmt - || argvi(&m[1], 1) != ldsiz - || argvi(&m[1], 2) != 0 - || argvi(&m[1], 4) != G_TX_LOADTILE - || argvi(&m[1], 5) != 0) - { - return -1; - } - uint32_t tmem = argvu(&m[1], 3); - unsigned cms = argvu(&m[1], 9); - unsigned cmt = argvu(&m[1], 6); - int masks = argvi(&m[1], 10); - int maskt = argvi(&m[1], 7); - int shifts = argvi(&m[1], 11); - int shiftt = argvi(&m[1], 8); - if (m[2].id != gfxd_DPLoadSync) - return -1; - if (m[3].id != gfxd_DPLoadBlock - || argvi(&m[3], 0) != G_TX_LOADTILE - || argvu(&m[3], 1) != 0 - || argvu(&m[3], 2) != 0) - { - return -1; - } - qu102_t ldlrs = argvu(&m[3], 3); - unsigned lddxt = argvu(&m[3], 4); - if (m[4].id != gfxd_DPPipeSync) - return -1; - if (m[5].id != gfxd_DPSetTile - || argvi(&m[5], 0) != fmt - || G_SIZ_LDSIZ(argvi(&m[5], 1)) != ldsiz - || argvu(&m[5], 3) != tmem - || argvu(&m[5], 6) != cmt - || argvi(&m[5], 7) != maskt - || argvi(&m[5], 8) != shiftt - || argvu(&m[5], 9) != cms - || argvi(&m[5], 10) != masks - || argvi(&m[5], 11) != shifts) - { - return -1; - } - int siz = argvi(&m[5], 1); - int rdline = argvi(&m[5], 2); - int rt = argvi(&m[5], 4); - int pal = argvi(&m[5], 5); - if (m4b && siz != G_IM_SIZ_4b) - return -1; - if (!(mrt && rt != G_TX_RENDERTILE && tmem == 0) - && (tmem != 0) != mtmem) - { - return -1; - } - if ((rt != G_TX_RENDERTILE) != mrt) - return -1; - if (m[6].id != gfxd_DPSetTileSize - || argvi(&m[6], 0) != rt - || argvu(&m[6], 1) != 0 - || argvu(&m[6], 2) != 0 - || (argvu(&m[6], 3) & 3) - || (argvu(&m[6], 4) & 3)) - { - return -1; - } - int width = (argvu(&m[6], 3) >> 2) + 1; - int height = (argvu(&m[6], 4) >> 2) + 1; - unsigned lrs = G_LDBLK_TXL(G_LTB_LRS(width, height, siz)); - unsigned dxt = 0; - if (!mdxt) - dxt = G_DXT(siz, width); - int line; - if (myuv) - line = (width + 7) / 8; - else - line = (width * G_SIZ_LDBITS(siz) + 63) / 64; - if (ldlrs != lrs || lddxt != dxt || rdline != line) - return -1; - m->id = id; - int i = 0; - argu(m, i++, "timg", timg, gfxd_Timg); - if (mtmem) - argu(m, i++, "tmem", tmem, gfxd_Tmem); - if (mrt) - argi(m, i++, "rtile", rt, gfxd_Tile); - argi(m, i++, "fmt", fmt, gfxd_Fmt); - if (!m4b) - argi(m, i++, "siz", siz, gfxd_Siz); - argi(m, i++, "width", width, gfxd_Dim); - argi(m, i++, "height", height, gfxd_Dim); - argi(m, i++, "pal", pal, gfxd_Pal); - argu(m, i++, "cms", cms, gfxd_Cm); - argu(m, i++, "cmt", cmt, gfxd_Cm); - argi(m, i++, "masks", masks, gfxd_Tm); - argi(m, i++, "maskt", maskt, gfxd_Tm); - argi(m, i++, "shifts", shifts, gfxd_Ts); - argi(m, i++, "shiftt", shiftt, gfxd_Ts); - return 0; -} - -UCFUNC int c_DPLoadMultiBlockYuvS(gfxd_macro_t *m, int n_macro) -{ - return c_ltb(m, n_macro, gfxd_DPLoadMultiBlockYuvS, 1, 1, 1, 1, 0); -} - -UCFUNC int c_DPLoadMultiBlockYuv(gfxd_macro_t *m, int n_macro) -{ - return c_ltb(m, n_macro, gfxd_DPLoadMultiBlockYuv, 0, 1, 1, 1, 0); -} - -UCFUNC int c_DPLoadMultiBlock_4bS(gfxd_macro_t *m, int n_macro) -{ - return c_ltb(m, n_macro, gfxd_DPLoadMultiBlock_4bS, 1, 1, 1, 0, 1); -} - -UCFUNC int c_DPLoadMultiBlock_4b(gfxd_macro_t *m, int n_macro) -{ - return c_ltb(m, n_macro, gfxd_DPLoadMultiBlock_4b, 0, 1, 1, 0, 1); -} - -UCFUNC int c_DPLoadMultiBlockS(gfxd_macro_t *m, int n_macro) -{ - return c_ltb(m, n_macro, gfxd_DPLoadMultiBlockS, 1, 1, 1, 0, 0); -} - -UCFUNC int c_DPLoadMultiBlock(gfxd_macro_t *m, int n_macro) -{ - return c_ltb(m, n_macro, gfxd_DPLoadMultiBlock, 0, 1, 1, 0, 0); -} - -UCFUNC int c__DPLoadTextureBlockYuvS(gfxd_macro_t *m, int n_macro) -{ - return c_ltb(m, n_macro, gfxd__DPLoadTextureBlockYuvS, 1, 1, 0, 1, 0); -} - -UCFUNC int c__DPLoadTextureBlockYuv(gfxd_macro_t *m, int n_macro) -{ - return c_ltb(m, n_macro, gfxd__DPLoadTextureBlockYuv, 0, 1, 0, 1, 0); -} - -UCFUNC int c__DPLoadTextureBlock_4bS(gfxd_macro_t *m, int n_macro) -{ - return c_ltb(m, n_macro, gfxd__DPLoadTextureBlock_4bS, 1, 1, 0, 0, 1); -} - -UCFUNC int c__DPLoadTextureBlock_4b(gfxd_macro_t *m, int n_macro) -{ - return c_ltb(m, n_macro, gfxd__DPLoadTextureBlock_4b, 0, 1, 0, 0, 1); -} - -UCFUNC int c__DPLoadTextureBlockS(gfxd_macro_t *m, int n_macro) -{ - return c_ltb(m, n_macro, gfxd__DPLoadTextureBlockS, 1, 1, 0, 0, 0); -} - -UCFUNC int c__DPLoadTextureBlock(gfxd_macro_t *m, int n_macro) -{ - return c_ltb(m, n_macro, gfxd__DPLoadTextureBlock, 0, 1, 0, 0, 0); -} - -UCFUNC int c_DPLoadTextureBlockYuvS(gfxd_macro_t *m, int n_macro) -{ - return c_ltb(m, n_macro, gfxd_DPLoadTextureBlockYuvS, 1, 0, 0, 1, 0); -} - -UCFUNC int c_DPLoadTextureBlockYuv(gfxd_macro_t *m, int n_macro) -{ - return c_ltb(m, n_macro, gfxd_DPLoadTextureBlockYuv, 0, 0, 0, 1, 0); -} - -UCFUNC int c_DPLoadTextureBlock_4bS(gfxd_macro_t *m, int n_macro) -{ - return c_ltb(m, n_macro, gfxd_DPLoadTextureBlock_4bS, 1, 0, 0, 0, 1); -} - -UCFUNC int c_DPLoadTextureBlock_4b(gfxd_macro_t *m, int n_macro) -{ - return c_ltb(m, n_macro, gfxd_DPLoadTextureBlock_4b, 0, 0, 0, 0, 1); -} - -UCFUNC int c_DPLoadTextureBlockS(gfxd_macro_t *m, int n_macro) -{ - return c_ltb(m, n_macro, gfxd_DPLoadTextureBlockS, 1, 0, 0, 0, 0); -} - -UCFUNC int c_DPLoadTextureBlock(gfxd_macro_t *m, int n_macro) -{ - return c_ltb(m, n_macro, gfxd_DPLoadTextureBlock, 0, 0, 0, 0, 0); -} - -UCFUNC int c_ltt(gfxd_macro_t *m, int n_macro, int id, int mtmem, int mrt, - int myuv, int m4b) -{ - if (n_macro < 7) - return -1; - if (m[0].id != gfxd_DPSetTextureImage) - return -1; - g_ifmt_t fmt = argvi(&m[0], 0); - g_isiz_t ldsiz = argvi(&m[0], 1); - int width = argvi(&m[0], 2); - if (m4b) - { - if (ldsiz != G_IM_SIZ_8b) - return -1; - width *= 2; - } - uint32_t timg = argvu(&m[0], 3); - if (myuv && fmt != G_IM_FMT_YUV) - return -1; - if (m[1].id != gfxd_DPSetTile - || argvi(&m[1], 0) != fmt - || argvi(&m[1], 1) != ldsiz - || argvi(&m[1], 4) != G_TX_LOADTILE - || argvi(&m[1], 5) != 0) - { - return -1; - } - int ldline = argvi(&m[1], 2); - uint32_t tmem = argvu(&m[1], 3); - unsigned cms = argvu(&m[1], 9); - unsigned cmt = argvu(&m[1], 6); - int masks = argvi(&m[1], 10); - int maskt = argvi(&m[1], 7); - int shifts = argvi(&m[1], 11); - int shiftt = argvi(&m[1], 8); - if (m[2].id != gfxd_DPLoadSync) - return -1; - if (m[3].id != gfxd_DPLoadTile - || argvi(&m[3], 0) != G_TX_LOADTILE - || (argvu(&m[3], 1) & 1) - || (argvu(&m[3], 2) & 3) - || (argvu(&m[3], 3) & 1) - || (argvu(&m[3], 4) & 3)) - { - return -1; - } - qu102_t lduls = argvu(&m[3], 1); - qu102_t ldult = argvu(&m[3], 2); - qu102_t ldlrs = argvu(&m[3], 3); - qu102_t ldlrt = argvu(&m[3], 4); - if (m[4].id != gfxd_DPPipeSync) - return -1; - if (m[5].id != gfxd_DPSetTile - || argvi(&m[5], 0) != fmt - || argvi(&m[5], 2) != ldline - || argvu(&m[5], 3) != tmem - || argvu(&m[5], 6) != cmt - || argvi(&m[5], 7) != maskt - || argvi(&m[5], 8) != shiftt - || argvu(&m[5], 9) != cms - || argvi(&m[5], 10) != masks - || argvi(&m[5], 11) != shifts) - { - return -1; - } - int siz = argvi(&m[5], 1); - int rt = argvi(&m[5], 4); - int pal = argvi(&m[5], 5); - if (m4b) - { - if (siz != G_IM_SIZ_4b) - return -1; - } - else if (siz != ldsiz) - return -1; - if (!(mrt && rt != G_TX_RENDERTILE && tmem == 0) - && (tmem != 0) != mtmem) - { - return -1; - } - if ((rt != G_TX_RENDERTILE) != mrt) - return -1; - if (m[6].id != gfxd_DPSetTileSize - || argvi(&m[6], 0) != rt - || (argvu(&m[6], 1) & 3) - || (argvu(&m[6], 2) & 3) - || (argvu(&m[6], 3) & 3) - || (argvu(&m[6], 4) & 3)) - { - return -1; - } - unsigned uls = argvu(&m[6], 1) >> 2; - unsigned ult = argvu(&m[6], 2) >> 2; - unsigned lrs = argvu(&m[6], 3) >> 2; - unsigned lrt = argvu(&m[6], 4) >> 2; - int line; - if (myuv) - line = ((lrs - uls + 1) + 7) / 8; - else if (m4b) - line = ((lrs - uls + 1) / 2 + 7) / 8; - else - line = ((lrs - uls + 1) * G_SIZ_LDBITS(siz) + 63) / 64; - if (m4b) - { - if (lduls != qu102(uls) / 2 || ldlrs != qu102(lrs) / 2) - return -1; - } - else if (lduls != qu102(uls) || ldlrs != qu102(lrs)) - return -1; - if (ldult != qu102(ult) || ldlrt != qu102(lrt) || ldline != line) - return -1; - m->id = id; - int i = 0; - argu(m, i++, "timg", timg, gfxd_Timg); - if (mtmem) - argu(m, i++, "tmem", tmem, gfxd_Tmem); - if (mrt) - argi(m, i++, "rtile", rt, gfxd_Tile); - argi(m, i++, "fmt", fmt, gfxd_Fmt); - if (!m4b) - argi(m, i++, "siz", siz, gfxd_Siz); - argi(m, i++, "width", width, gfxd_Dim); - argi(m, i++, "height", 0, gfxd_Dim); - argu(m, i++, "uls", uls, gfxd_Coordi); - argu(m, i++, "ult", ult, gfxd_Coordi); - argu(m, i++, "lrs", lrs, gfxd_Coordi); - argu(m, i++, "lrt", lrt, gfxd_Coordi); - argi(m, i++, "pal", pal, gfxd_Pal); - argu(m, i++, "cms", cms, gfxd_Cm); - argu(m, i++, "cmt", cmt, gfxd_Cm); - argi(m, i++, "masks", masks, gfxd_Tm); - argi(m, i++, "maskt", maskt, gfxd_Tm); - argi(m, i++, "shifts", shifts, gfxd_Ts); - argi(m, i++, "shiftt", shiftt, gfxd_Ts); - return 0; -} - -UCFUNC int c_DPLoadMultiTileYuv(gfxd_macro_t *m, int n_macro) -{ - return c_ltt(m, n_macro, gfxd_DPLoadMultiTileYuv, 1, 1, 1, 0); -} - -UCFUNC int c_DPLoadMultiTile_4b(gfxd_macro_t *m, int n_macro) -{ - return c_ltt(m, n_macro, gfxd_DPLoadMultiTile_4b, 1, 1, 0, 1); -} - -UCFUNC int c_DPLoadMultiTile(gfxd_macro_t *m, int n_macro) -{ - return c_ltt(m, n_macro, gfxd_DPLoadMultiTile, 1, 1, 0, 0); -} - -UCFUNC int c__DPLoadTextureTileYuv(gfxd_macro_t *m, int n_macro) -{ - return c_ltt(m, n_macro, gfxd__DPLoadTextureTileYuv, 1, 0, 1, 0); -} - -UCFUNC int c__DPLoadTextureTile_4b(gfxd_macro_t *m, int n_macro) -{ - return c_ltt(m, n_macro, gfxd__DPLoadTextureTile_4b, 1, 0, 0, 1); -} - -UCFUNC int c__DPLoadTextureTile(gfxd_macro_t *m, int n_macro) -{ - return c_ltt(m, n_macro, gfxd__DPLoadTextureTile, 1, 0, 0, 0); -} - -UCFUNC int c_DPLoadTextureTileYuv(gfxd_macro_t *m, int n_macro) -{ - return c_ltt(m, n_macro, gfxd_DPLoadTextureTileYuv, 0, 0, 1, 0); -} - -UCFUNC int c_DPLoadTextureTile_4b(gfxd_macro_t *m, int n_macro) -{ - return c_ltt(m, n_macro, gfxd_DPLoadTextureTile_4b, 0, 0, 0, 1); -} - -UCFUNC int c_DPLoadTextureTile(gfxd_macro_t *m, int n_macro) -{ - return c_ltt(m, n_macro, gfxd_DPLoadTextureTile, 0, 0, 0, 0); -} - -UCFUNC int d_DPLoadBlock(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_DPLoadBlock; - argi(m, 0, "tile", getfield(lo, 3, 24), gfxd_Tile); - argu(m, 1, "uls", getfield(hi, 12, 12), gfxd_Coordi); - argu(m, 2, "ult", getfield(hi, 12, 0), gfxd_Coordi); - argu(m, 3, "lrs", getfield(lo, 12, 12), gfxd_Coordi); - argu(m, 4, "dxt", getfield(lo, 12, 0), gfxd_Dxt); - if (argvu(m, 3) > G_TX_LDBLK_MAX_TXL) { - badarg(m, 3); - return -1; - } - else { - return 0; - } -} - -UCFUNC int d_DPNoOp(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_DPNoOp; - return 0; -} - -UCFUNC int d_DPNoOpTag(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - if (lo == 0) - return d_DPNoOp(m, hi, lo); - else - { - m->id = gfxd_DPNoOpTag; - argu(m, 0, "tag", lo, gfxd_Tag); - return 0; - } -} - -UCFUNC int d_DPPipelineMode(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_DPPipelineMode; - argu(m, 0, "mode", lo, gfxd_Pm); - return 0; -} - -UCFUNC int d_DPSetBlendColor(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_DPSetBlendColor; - argu(m, 0, "r", getfield(lo, 8, 24), gfxd_Colorpart); - argu(m, 1, "g", getfield(lo, 8, 16), gfxd_Colorpart); - argu(m, 2, "b", getfield(lo, 8, 8), gfxd_Colorpart); - argu(m, 3, "a", getfield(lo, 8, 0), gfxd_Colorpart); - return 0; -} - -UCFUNC int d_DPSetEnvColor(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_DPSetEnvColor; - argu(m, 0, "r", getfield(lo, 8, 24), gfxd_Colorpart); - argu(m, 1, "g", getfield(lo, 8, 16), gfxd_Colorpart); - argu(m, 2, "b", getfield(lo, 8, 8), gfxd_Colorpart); - argu(m, 3, "a", getfield(lo, 8, 0), gfxd_Colorpart); - return 0; -} - -UCFUNC int d_DPSetFillColor(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_DPSetFillColor; - argu(m, 0, "c", lo, gfxd_Color); - return 0; -} - -UCFUNC int d_DPSetFogColor(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_DPSetFogColor; - argu(m, 0, "r", getfield(lo, 8, 24), gfxd_Colorpart); - argu(m, 1, "g", getfield(lo, 8, 16), gfxd_Colorpart); - argu(m, 2, "b", getfield(lo, 8, 8), gfxd_Colorpart); - argu(m, 3, "a", getfield(lo, 8, 0), gfxd_Colorpart); - return 0; -} - -UCFUNC int d_DPSetPrimColor(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_DPSetPrimColor; - argu(m, 0, "m", getfield(hi, 8, 8), gfxd_Lodfrac); - argu(m, 1, "l", getfield(hi, 8, 0), gfxd_Lodfrac); - argu(m, 2, "r", getfield(lo, 8, 24), gfxd_Colorpart); - argu(m, 3, "g", getfield(lo, 8, 16), gfxd_Colorpart); - argu(m, 4, "b", getfield(lo, 8, 8), gfxd_Colorpart); - argu(m, 5, "a", getfield(lo, 8, 0), gfxd_Colorpart); - return 0; -} - -UCFUNC int d_DPSetColorImage(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_DPSetColorImage; - argi(m, 0, "fmt", getfield(hi, 3, 21), gfxd_Fmt); - argi(m, 1, "siz", getfield(hi, 2, 19), gfxd_Siz); - argi(m, 2, "width", getfield(hi, 12, 0) + 1, gfxd_Dim); - argu(m, 3, "cimg", lo, gfxd_Cimg); - return 0; -} - -UCFUNC int d_DPSetDepthImage(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_DPSetDepthImage; - argu(m, 0, "zimg", lo, gfxd_Zimg); - return 0; -} - -UCFUNC int d_DPSetTextureImage(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_DPSetTextureImage; - argi(m, 0, "fmt", getfield(hi, 3, 21), gfxd_Fmt); - argi(m, 1, "siz", getfield(hi, 2, 19), gfxd_Siz); - argi(m, 2, "width", getfield(hi, 12, 0) + 1, gfxd_Dim); - argu(m, 3, "timg", lo, gfxd_Timg); - return 0; -} - -UCFUNC int d_DPSetAlphaCompare(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_DPSetAlphaCompare; - argu(m, 0, "mode", lo, gfxd_Ac); - return 0; -} - -UCFUNC int d_DPSetAlphaDither(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_DPSetAlphaDither; - argu(m, 0, "mode", lo, gfxd_Ad); - return 0; -} - -UCFUNC int d_DPSetColorDither(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_DPSetColorDither; - argu(m, 0, "mode", lo, gfxd_Cd); - return 0; -} - -UCFUNC void cc_unpack(struct cc_mode *m0, struct cc_mode *m1, uint32_t hi, - uint32_t lo) -{ - m0->a = getfield(hi, 4, 20); - m0->b = getfield(lo, 4, 28); - m0->c = getfield(hi, 5, 15); - m0->d = getfield(lo, 3, 15); - m0->Aa = getfield(hi, 3, 12); - m0->Ab = getfield(lo, 3, 12); - m0->Ac = getfield(hi, 3, 9); - m0->Ad = getfield(lo, 3, 9); - m1->a = getfield(hi, 4, 5); - m1->b = getfield(lo, 4, 24); - m1->c = getfield(hi, 5, 0); - m1->d = getfield(lo, 3, 6); - m1->Aa = getfield(lo, 3, 21); - m1->Ab = getfield(lo, 3, 3); - m1->Ac = getfield(lo, 3, 18); - m1->Ad = getfield(lo, 3, 0); -} - -UCFUNC int cc_lookup(const struct cc_mode *m) -{ - struct cc_mode m_norm = *m; - if (m_norm.a > 0x7) m_norm.a = G_CCMUX_0; - if (m_norm.b > 0x7) m_norm.b = G_CCMUX_0; - if (m_norm.c > 0xF) m_norm.c = G_CCMUX_0; - if (m_norm.d > 0x6) m_norm.d = G_CCMUX_0; - m = &m_norm; - int n_presets = sizeof(cc_presets) / sizeof(*cc_presets); - for (int i = 0; i < n_presets; i++) - { - const struct cc_mode *p = &cc_presets[i].mode; - if (m->a == p->a - && m->b == p->b - && m->c == p->c - && m->d == p->d - && m->Aa == p->Aa - && m->Ab == p->Ab - && m->Ac == p->Ac - && m->Ad == p->Ad) - { - return i; - } - } - return -1; -} - -UCFUNC int d_DPSetCombineMode(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_DPSetCombineMode; - struct cc_mode m0; - struct cc_mode m1; - cc_unpack(&m0, &m1, hi, lo); - int p0 = cc_lookup(&m0); - int p1 = cc_lookup(&m1); - argi(m, 0, "mode1", p0, gfxd_Ccpre); - argi(m, 1, "mode2", p1, gfxd_Ccpre); - int ret = 0; - if (p0 == -1) - { - badarg(m, 0); - ret = -1; - } - if (p1 == -1) - { - badarg(m, 1); - ret = -1; - } - return ret; -} - -UCFUNC int d_DPSetCombineLERP(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - struct cc_mode m0; - struct cc_mode m1; - cc_unpack(&m0, &m1, hi, lo); - int p0 = cc_lookup(&m0); - int p1 = cc_lookup(&m1); - if (p0 != -1 && p1 != -1) - return d_DPSetCombineMode(m, hi, lo); - else - { - m->id = gfxd_DPSetCombineLERP; - argi(m, 0, "a0", m0.a, gfxd_Ccmuxa); - argi(m, 1, "b0", m0.b, gfxd_Ccmuxb); - argi(m, 2, "c0", m0.c, gfxd_Ccmuxc); - argi(m, 3, "d0", m0.d, gfxd_Ccmuxd); - argi(m, 4, "Aa0", m0.Aa, gfxd_Acmuxabd); - argi(m, 5, "Ab0", m0.Ab, gfxd_Acmuxabd); - argi(m, 6, "Ac0", m0.Ac, gfxd_Acmuxc); - argi(m, 7, "Ad0", m0.Ad, gfxd_Acmuxabd); - argi(m, 8, "a1", m1.a, gfxd_Ccmuxa); - argi(m, 9, "b1", m1.b, gfxd_Ccmuxb); - argi(m, 10, "c1", m1.c, gfxd_Ccmuxc); - argi(m, 11, "d1", m1.d, gfxd_Ccmuxd); - argi(m, 12, "Aa1", m1.Aa, gfxd_Acmuxabd); - argi(m, 13, "Ab1", m1.Ab, gfxd_Acmuxabd); - argi(m, 14, "Ac1", m1.Ac, gfxd_Acmuxc); - argi(m, 15, "Ad1", m1.Ad, gfxd_Acmuxabd); - return 0; - } -} - -UCFUNC int d_DPSetConvert(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_DPSetConvert; - argi(m, 0, "k0", sx(getfield(hi, 9, 13), 9), gfxd_Cv); - argi(m, 1, "k1", sx(getfield(hi, 9, 4), 9), gfxd_Cv); - argi(m, 2, "k2", sx((getfield(hi, 4, 0) << 5) | getfield(lo, 5, 27), 9), - gfxd_Cv); - argi(m, 3, "k3", sx(getfield(lo, 9, 18), 9), gfxd_Cv); - argi(m, 4, "k4", sx(getfield(lo, 9, 9), 9), gfxd_Cv); - argi(m, 5, "k5", sx(getfield(lo, 9, 0), 9), gfxd_Cv); - return 0; -} - -UCFUNC int d_DPSetTextureConvert(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_DPSetTextureConvert; - argu(m, 0, "mode", lo, gfxd_Tc); - return 0; -} - -UCFUNC int d_DPSetCycleType(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_DPSetCycleType; - argu(m, 0, "mode", lo, gfxd_Cyc); - return 0; -} - -UCFUNC int d_DPSetDepthSource(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_DPSetDepthSource; - argu(m, 0, "mode", lo, gfxd_Zs); - return 0; -} - -UCFUNC int d_DPSetCombineKey(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_DPSetCombineKey; - argu(m, 0, "mode", lo, gfxd_Ck); - return 0; -} - -UCFUNC int d_DPSetKeyGB(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_DPSetKeyGB; - argu(m, 0, "cG", getfield(lo, 8, 24), gfxd_Color); - argu(m, 1, "sG", getfield(lo, 8, 16), gfxd_Keyscale); - argi(m, 2, "wG", sx(getfield(hi, 12, 12), 12), gfxd_Keywidth); - argu(m, 3, "cB", getfield(lo, 8, 8), gfxd_Color); - argu(m, 4, "sB", getfield(lo, 8, 0), gfxd_Keyscale); - argi(m, 5, "wB", sx(getfield(hi, 12, 0), 12), gfxd_Keywidth); - return 0; -} - -UCFUNC int d_DPSetKeyR(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_DPSetKeyR; - argu(m, 0, "cR", getfield(lo, 8, 8), gfxd_Color); - argu(m, 1, "sR", getfield(lo, 8, 0), gfxd_Keyscale); - argi(m, 2, "wR", sx(getfield(lo, 12, 16), 12), gfxd_Keywidth); - return 0; -} - -UCFUNC int d_DPSetPrimDepth(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_DPSetPrimDepth; - argi(m, 0, "z", sx(getfield(lo, 16, 16), 16), gfxd_Zi); - argi(m, 1, "dz", sx(getfield(lo, 16, 0), 16), gfxd_Zi); - return 0; -} - -UCFUNC int d_DPSetRenderMode(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_DPSetRenderMode; - argu(m, 0, "mode1", lo, gfxd_Rm1); - argu(m, 1, "mode2", lo, gfxd_Rm2); - return 0; -} - -UCFUNC int d_DPSetScissor(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_DPSetScissor; - argi(m, 0, "mode", getfield(lo, 2, 24), gfxd_Sc); - argu(m, 1, "ulx", getfield(hi, 10, 14), gfxd_Coordi); - argu(m, 2, "uly", getfield(hi, 10, 2), gfxd_Coordi); - argu(m, 3, "lrx", getfield(lo, 10, 14), gfxd_Coordi); - argu(m, 4, "lry", getfield(lo, 10, 2), gfxd_Coordi); - return 0; -} - -UCFUNC int d_DPSetScissorFrac(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - qu102_t ulx = getfield(hi, 12, 12); - qu102_t uly = getfield(hi, 12, 0); - qu102_t lrx = getfield(lo, 12, 12); - qu102_t lry = getfield(lo, 12, 0); - if ((ulx & 3) || (uly & 3) || (lrx & 3) || (lry & 3)) - { - m->id = gfxd_DPSetScissorFrac; - argi(m, 0, "mode", getfield(lo, 2, 24), gfxd_Sc); - argu(m, 1, "ulx", ulx, gfxd_Coordq); - argu(m, 2, "uly", uly, gfxd_Coordq); - argu(m, 3, "lrx", lrx, gfxd_Coordq); - argu(m, 4, "lry", lry, gfxd_Coordq); - return 0; - } - else - return d_DPSetScissor(m, hi, lo); -} - -UCFUNC int d_DPSetTextureDetail(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_DPSetTextureDetail; - argu(m, 0, "mode", lo, gfxd_Td); - return 0; -} - -UCFUNC int d_DPSetTextureFilter(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_DPSetTextureFilter; - argu(m, 0, "mode", lo, gfxd_Tf); - return 0; -} - -UCFUNC int d_DPSetTextureLOD(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_DPSetTextureLOD; - argu(m, 0, "mode", lo, gfxd_Tl); - return 0; -} - -UCFUNC int d_DPSetTextureLUT(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_DPSetTextureLUT; - argu(m, 0, "mode", lo, gfxd_Tt); - return 0; -} - -UCFUNC int d_DPSetTexturePersp(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_DPSetTexturePersp; - argu(m, 0, "mode", lo, gfxd_Tp); - return 0; -} - -UCFUNC int d_DPSetTile(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_DPSetTile; - argi(m, 0, "fmt", getfield(hi, 3, 21), gfxd_Fmt); - argi(m, 1, "siz", getfield(hi, 2, 19), gfxd_Siz); - argi(m, 2, "line", getfield(hi, 9, 9), gfxd_Line); - argu(m, 3, "tmem", getfield(hi, 9, 0), gfxd_Tmem); - argi(m, 4, "tile", getfield(lo, 3, 24), gfxd_Tile); - argi(m, 5, "pal", getfield(lo, 4, 20), gfxd_Pal); - argu(m, 6, "cmt", getfield(lo, 2, 18), gfxd_Cm); - argi(m, 7, "maskt", getfield(lo, 4, 14), gfxd_Tm); - argi(m, 8, "shiftt", getfield(lo, 4, 10), gfxd_Ts); - argu(m, 9, "cms", getfield(lo, 2, 8), gfxd_Cm); - argi(m, 10, "masks", getfield(lo, 4, 4), gfxd_Tm); - argi(m, 11, "shifts", getfield(lo, 4, 0), gfxd_Ts); - return 0; -} - -UCFUNC int d_DPSetTileSize(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_DPSetTileSize; - argi(m, 0, "tile", getfield(lo, 3, 24), gfxd_Tile); - argu(m, 1, "uls", getfield(hi, 12, 12), gfxd_Coordq); - argu(m, 2, "ult", getfield(hi, 12, 0), gfxd_Coordq); - argu(m, 3, "lrs", getfield(lo, 12, 12), gfxd_Coordq); - argu(m, 4, "lrt", getfield(lo, 12, 0), gfxd_Coordq); - return 0; -} - -#if defined(F3D_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 / 10, gfxd_Vtx); - argi(m, 1, "v1", n1 / 10, gfxd_Vtx); - argi(m, 2, "v2", n2 / 10, gfxd_Vtx); - argi(m, 3, "flag", getfield(lo, 8, 24), gfxd_Vtxflag); - int ret = 0; - if (n0 % 10 != 0) - { - badarg(m, 0); - ret = -1; - } - if (n1 % 10 != 0) - { - badarg(m, 1); - ret = -1; - } - if (n2 % 10 != 0) - { - badarg(m, 2); - ret = -1; - } - return ret; -} -#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; - int n0 = getfield(hi, 8, 16); - int n1 = getfield(hi, 8, 8); - int n2 = getfield(hi, 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; -} -#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) -{ - int n00 = getfield(hi, 8, 16); - int n01 = getfield(hi, 8, 8); - int n02 = getfield(hi, 8, 0); - int n10 = getfield(lo, 8, 16); - int n11 = getfield(lo, 8, 8); - int n12 = getfield(lo, 8, 0); -#if defined(F3DEX_GBI) - if (n00 == n10 && n02 == n11) - return d_SP1Quadrangle(m, hi, lo); -#endif - m->id = gfxd_SP2Triangles; - argi(m, 0, "v00", n00 / 2, gfxd_Vtx); - argi(m, 1, "v01", n01 / 2, gfxd_Vtx); - argi(m, 2, "v02", n02 / 2, gfxd_Vtx); - argi(m, 3, "flag0", 0, gfxd_Vtxflag); - argi(m, 4, "v10", n10 / 2, gfxd_Vtx); - argi(m, 5, "v11", n11 / 2, gfxd_Vtx); - argi(m, 6, "v12", n12 / 2, gfxd_Vtx); - argi(m, 7, "flag1", 0, gfxd_Vtxflag); - int ret = 0; - if (n00 % 2 != 0) - { - badarg(m, 0); - ret = -1; - } - if (n01 % 2 != 0) - { - badarg(m, 1); - ret = -1; - } - if (n02 % 2 != 0) - { - badarg(m, 2); - ret = -1; - } - if (n10 % 2 != 0) - { - badarg(m, 4); - ret = -1; - } - if (n11 % 2 != 0) - { - badarg(m, 5); - ret = -1; - } - if (n12 % 2 != 0) - { - badarg(m, 6); - ret = -1; - } - return ret; -} - -UCFUNC int d_SP1Quadrangle(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_SP1Quadrangle; - int n00 = getfield(hi, 8, 16); - int n01 = getfield(hi, 8, 8); - int n02 = getfield(hi, 8, 0); - int n10 = getfield(lo, 8, 16); - int n11 = getfield(lo, 8, 8); - int n12 = getfield(lo, 8, 0); - int v00 = n00 / 2; - int v01 = n01 / 2; - int v02 = n02 / 2; - int v10 = n10 / 2; - int v11 = n11 / 2; - int v12 = n12 / 2; - argi(m, 0, "v0", v00, gfxd_Vtx); - argi(m, 1, "v1", v01, gfxd_Vtx); - argi(m, 2, "v2", v11, gfxd_Vtx); - argi(m, 3, "v3", v12, gfxd_Vtx); - argi(m, 4, "flag", 0, gfxd_Vtxflag); - int ret = 0; - if (v00 != v10 || n00 % 2 != 0 || n10 % 2 != 0) - { - badarg(m, 0); - ret = -1; - } - if (n01 % 2 != 0) - { - badarg(m, 1); - ret = -1; - } - if (v02 != v11 || n02 % 2 != 0 || n11 % 2 != 0) - { - badarg(m, 2); - ret = -1; - } - if (n12 % 2 != 0) - { - badarg(m, 3); - ret = -1; - } - return ret; -} - -UCFUNC int c_SPBranchLessZraw(gfxd_macro_t *m, int n_macro) -{ - if (n_macro < 2) - return -1; - if (m[0].id != gfxd_DPHalf1) - return -1; - uint32_t branchdl = argvu(&m[0], 0); - if (m[1].id != gfxd_BranchZ) - return -1; - int32_t vtx = argvi(&m[1], 0); - int32_t zval = argvi(&m[1], 1); - m->id = gfxd_SPBranchLessZraw; - argu(m, 0, "dl", branchdl, gfxd_Dl); - argi(m, 1, "vtx", vtx, gfxd_Vtx); - argi(m, 2, "zval", zval, gfxd_Zraw); - return 0; -} -#endif - -UCFUNC int d_SPBranchList(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_SPBranchList; - argu(m, 0, "dl", lo, gfxd_Dl); - return 0; -} - -UCFUNC int c_SPClipRatio(gfxd_macro_t *m, int n_macro) -{ - if (n_macro < 4) - return -1; - if (m[0].id != gfxd_MoveWd - || argvi(&m[0], 0) != G_MW_CLIP - || argvu(&m[0], 1) != G_MWO_CLIP_RNX) - { - return -1; - } - uint32_t r = argvu(&m[0], 2); - if (m[1].id != gfxd_MoveWd - || argvi(&m[1], 0) != G_MW_CLIP - || argvu(&m[1], 1) != G_MWO_CLIP_RNY - || argvu(&m[1], 2) != r) - { - return -1; - } - if (m[2].id != gfxd_MoveWd - || argvi(&m[2], 0) != G_MW_CLIP - || argvu(&m[2], 1) != G_MWO_CLIP_RPX - || ((uint32_t)1 << 16) - argvu(&m[2], 2) != r) - { - return -1; - } - if (m[3].id != gfxd_MoveWd - || argvi(&m[3], 0) != G_MW_CLIP - || argvu(&m[3], 1) != G_MWO_CLIP_RPY - || ((uint32_t)1 << 16) - argvu(&m[3], 2) != r) - { - return -1; - } - m->id = gfxd_SPClipRatio; - argi(m, 0, "r", r, gfxd_Cr); - return 0; -} - -#if defined(F3D_GBI) -UCFUNC int d_SPCullDisplayList(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_SPCullDisplayList; - int n0 = getfield(hi, 24, 0); - int nn = getfield(lo, 16, 0); - argi(m, 0, "v0", n0 / 40, gfxd_Vtx); - argi(m, 1, "vn", nn / 40 - 1, gfxd_Num); - int ret = 0; - if (n0 % 40 != 0) - { - badarg(m, 0); - ret = -1; - } - if (nn % 40 != 0) - { - badarg(m, 1); - ret = -1; - } - return ret; -} -#elif defined(F3DEX_GBI) || defined(F3DEX_GBI_2) -UCFUNC int d_SPCullDisplayList(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_SPCullDisplayList; - int n0 = getfield(hi, 16, 0); - int nn = getfield(lo, 16, 0); - argi(m, 0, "v0", n0 / 2, gfxd_Vtx); - argi(m, 1, "vn", nn / 2, gfxd_Num); - int ret = 0; - if (n0 % 2 != 0) - { - badarg(m, 0); - ret = -1; - } - if (nn % 2 != 0) - { - badarg(m, 1); - ret = -1; - } - return ret; -} -#endif - -UCFUNC int d_SPDisplayList(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_SPDisplayList; - argu(m, 0, "dl", lo, gfxd_Dl); - return 0; -} - -UCFUNC int d_SPEndDisplayList(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_SPEndDisplayList; - return 0; -} - -UCFUNC int d_SPFogFactor(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_SPFogFactor; - argi(m, 0, "fm", sx(getfield(lo, 16, 16), 16), gfxd_Fogz); - argi(m, 1, "fo", sx(getfield(lo, 16, 0), 16), gfxd_Fogz); - return 0; -} - -UCFUNC int d_SPFogPosition(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - int x = sx(getfield(lo, 16, 16), 16); - int y = sx(getfield(lo, 16, 0), 16); - if (x == 0) - return d_SPFogFactor(m, hi, lo); - else - { - int d = 128000 / x; - int yd = y * d; - if (yd > 0) - yd += 255; - else if (yd < 0) - yd -= 255; - int min = 500 - yd / 256; - int max = d + min; - - if (min >= 0 && min <= 1000 && max >= 0 && max <= 1000) - { - m->id = gfxd_SPFogPosition; - argi(m, 0, "min", min, gfxd_Fogp); - argi(m, 1, "max", max, gfxd_Fogp); - return 0; - } - else - return d_SPFogFactor(m, hi, lo); - } -} - -#if defined(F3D_GBI) || defined(F3DEX_GBI) -UCFUNC int c_SPForceMatrix(gfxd_macro_t *m, int n_macro) -{ - if (n_macro < 4) - return -1; - for (int i = 0; i < 4; i++) - if (m[i].id != gfxd_MoveMem - || argvu(&m[i], 0) != 16 - || argvu(&m[i], 2) != argvu(&m[0], 2) + i * 16) - { - return -1; - } - if (argvi(&m[0], 1) != G_MV_MATRIX_1 - || argvi(&m[1], 1) != G_MV_MATRIX_2 - || argvi(&m[2], 1) != G_MV_MATRIX_3 - || argvi(&m[3], 1) != G_MV_MATRIX_4) - { - return -1; - } - uint32_t mptr = argvu(&m[0], 2); - m->id = gfxd_SPForceMatrix; - argu(m, 0, "mptr", mptr, gfxd_Mtxptr); - return 0; -} -#elif defined(F3DEX_GBI_2) -UCFUNC int c_SPForceMatrix(gfxd_macro_t *m, int n_macro) -{ - if (n_macro < 2) - return -1; - if (m[0].id != gfxd_MoveMem - || argvu(&m[0], 0) != sizeof(Mtx) - || argvi(&m[0], 1) != G_MV_MATRIX - || argvu(&m[0], 2) != 0) - { - return -1; - } - uint32_t mptr = argvu(&m[0], 3); - if (m[1].id != gfxd_MoveWd - || argvi(&m[1], 0) != G_MW_FORCEMTX - || argvu(&m[1], 1) != 0 - || argvu(&m[1], 2) != 0x10000) - { - return -1; - } - m->id = gfxd_SPForceMatrix; - argu(m, 0, "mptr", mptr, gfxd_Mtxptr); - return 0; -} -#endif - -UCFUNC int d_SPSetGeometryMode(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_SPSetGeometryMode; - argu(m, 0, "mode", lo, gfxd_Gm); - return 0; -} - -UCFUNC int d_SPClearGeometryMode(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_SPClearGeometryMode; -#if defined(F3D_GBI) || defined(F3DEX_GBI) - argu(m, 0, "mode", lo, gfxd_Gm); -#elif defined(F3DEX_GBI_2) - argu(m, 0, "mode", getfield(~hi, 24, 0), gfxd_Gm); -#endif - return 0; -} - -#if defined(F3D_GBI) || defined(F3DEX_GBI) -UCFUNC int c_SPLoadGeometryMode(gfxd_macro_t *m, int n_macro) -{ - if (n_macro < 2) - return -1; - if (m[0].id != gfxd_SPClearGeometryMode - || argvu(&m[0], 0) != 0xFFFFFFFF - || m[1].id != gfxd_SPSetGeometryMode) - { - return -1; - } - uint32_t mode = argvu(&m[1], 0); - m->id = gfxd_SPLoadGeometryMode; - argu(m, 0, "mode", mode, gfxd_Gm); - return 0; -} -#elif defined(F3DEX_GBI_2) -UCFUNC int d_SPLoadGeometryMode(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_SPLoadGeometryMode; - argu(m, 0, "mode", lo, gfxd_Gm); - return 0; -} -#endif - -#if defined(F3D_GBI) || defined(F3DEX_GBI) -UCFUNC int d_SPInsertMatrix(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_SPInsertMatrix; - argu(m, 0, "where", getfield(hi, 16, 8), gfxd_Mwo_matrix); - argu(m, 1, "val", lo, gfxd_Word); - return 0; -} -#endif - -#if defined(F3D_GBI) -UCFUNC int d_SPLine3D(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_SPLine3D; - int n0 = getfield(lo, 8, 16); - int n1 = getfield(lo, 8, 8); - argi(m, 0, "v0", n0 / 10, gfxd_Vtx); - argi(m, 1, "v1", n1 / 10, gfxd_Vtx); - argi(m, 2, "flag", getfield(lo, 8, 24), gfxd_Vtxflag); - int ret = 0; - if (n0 % 10 != 0) - { - badarg(m, 0); - ret = -1; - } - if (n1 % 10 != 0) - { - badarg(m, 1); - ret = -1; - } - return ret; -} -#elif defined(F3DEX_GBI) -UCFUNC int d_SPLine3D(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_SPLine3D; - int n0 = getfield(lo, 8, 16); - int n1 = getfield(lo, 8, 8); - argi(m, 0, "v0", n0 / 2, gfxd_Vtx); - argi(m, 1, "v1", n1 / 2, gfxd_Vtx); - argi(m, 2, "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; - } - return ret; -} -#elif defined(F3DEX_GBI_2) -UCFUNC int d_SPLine3D(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_SPLine3D; - int n0 = getfield(hi, 8, 16); - int n1 = getfield(hi, 8, 8); - argi(m, 0, "v0", n0 / 2, gfxd_Vtx); - argi(m, 1, "v1", n1 / 2, gfxd_Vtx); - argi(m, 2, "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; - } - return ret; -} -#endif - -#if defined(F3D_GBI) -UCFUNC int d_SPLineW3D(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - int wd = getfield(lo, 8, 0); - if (wd == 0) - return d_SPLine3D(m, hi, lo); - else - { - m->id = gfxd_SPLineW3D; - int n0 = getfield(lo, 8, 16); - int n1 = getfield(lo, 8, 8); - argi(m, 0, "v0", n0 / 10, gfxd_Vtx); - argi(m, 1, "v1", n1 / 10, gfxd_Vtx); - argi(m, 2, "wd", wd, gfxd_Linewd); - argi(m, 3, "flag", getfield(lo, 8, 24), gfxd_Vtxflag); - int ret = 0; - if (n0 % 10 != 0) - { - badarg(m, 0); - ret = -1; - } - if (n1 % 10 != 0) - { - badarg(m, 1); - ret = -1; - } - return ret; - } -} -#elif defined(F3DEX_GBI) || defined(F3DEX_GBI_2) -UCFUNC int d_SPLineW3D(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - int wd = getfield(hi, 8, 0); - if (wd == 0) - return d_SPLine3D(m, hi, lo); - else - { - m->id = gfxd_SPLineW3D; - int n0 = getfield(hi, 8, 16); - int n1 = getfield(hi, 8, 8); - argi(m, 0, "v0", n0 / 2, gfxd_Vtx); - argi(m, 1, "v1", n1 / 2, gfxd_Vtx); - argi(m, 2, "wd", wd, gfxd_Linewd); - 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; - } - return ret; - } -} -#endif - -#if defined(F3DEX_GBI) || defined(F3DEX_GBI_2) -UCFUNC int c_SPLoadUcode(gfxd_macro_t *m, int n_macro) -{ - if (n_macro < 2) - return -1; - if (m[0].id != gfxd_DPHalf1) - return -1; - uint32_t uc_dstart = argvu(&m[0], 0); - if (m[1].id != gfxd_LoadUcode) - return -1; - uint32_t uc_start = argvu(&m[1], 0); - uint32_t uc_dsize = argvu(&m[1], 1); - if (uc_dsize != 0x800) - return -1; - m->id = gfxd_SPLoadUcode; - argu(m, 0, "uc_start", uc_start, gfxd_Uctext); - argu(m, 1, "uc_dstart", uc_dstart, gfxd_Ucdata); - return 0; -} -#endif - -UCFUNC int d_SPLookAtX(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_SPLookAtX; - argu(m, 0, "l", lo, gfxd_Lookatptr); - return 0; -} - -UCFUNC int d_SPLookAtY(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_SPLookAtY; - argu(m, 0, "l", lo, gfxd_Lookatptr); - return 0; -} - -UCFUNC int c_SPLookAt(gfxd_macro_t *m, int n_macro) -{ - if (n_macro < 2) - return -1; - if (m[0].id != gfxd_SPLookAtX) - return -1; - uint32_t l = argvu(&m[0], 0); - if (m[1].id != gfxd_SPLookAtY || argvu(&m[1], 0) != l + 0x10) - return -1; - m->id = gfxd_SPLookAt; - argu(m, 0, "l", l, gfxd_Lookatptr); - return 0; -} - -#if defined(F3D_GBI) || defined(F3DEX_GBI) -UCFUNC int d_SPMatrix(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_SPMatrix; - int x = getfield(hi, 16, 0); - argu(m, 0, "matrix", lo, gfxd_Mtxptr); - argi(m, 1, "param", getfield(hi, 8, 16), gfxd_Mtxparam); - if (x != sizeof(Mtx)) - return -1; - else - return 0; -} -#elif defined(F3DEX_GBI_2) -UCFUNC int d_SPMatrix(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_SPMatrix; - int x = getfield(hi, 5, 19); - argu(m, 0, "matrix", lo, gfxd_Mtxptr); - argi(m, 1, "param", getfield(hi, 8, 0) ^ G_MTX_PUSH, gfxd_Mtxparam); - if (x != (sizeof(Mtx) - 1) / 8) - return -1; - else - return 0; -} -#endif - -#if defined(F3D_GBI) || (defined(F3D_BETA) && defined(F3DEX_GBI)) -UCFUNC int d_SPModifyVertex(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_SPModifyVertex; - int offset = getfield(hi, 16, 8); - argi(m, 0, "vtx", offset / 40, gfxd_Vtx); - argu(m, 1, "where", offset % 40, gfxd_Mwo_point); - argu(m, 2, "val", lo, gfxd_Word); - return 0; -} -#elif defined(F3DEX_GBI) || defined(F3DEX_GBI_2) -UCFUNC int d_SPModifyVertex(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_SPModifyVertex; - int vtx = getfield(hi, 16, 0); - argi(m, 0, "vtx", vtx / 2, gfxd_Vtx); - argu(m, 1, "where", getfield(hi, 8, 16), gfxd_Mwo_point); - argu(m, 2, "val", lo, gfxd_Word); - int ret = 0; - if (vtx % 2 != 0) - { - badarg(m, 0); - ret = -1; - } - return ret; -} -#endif - -UCFUNC int d_SPPerspNormalize(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_SPPerspNormalize; - argu(m, 0, "scale", getfield(lo, 16, 0), gfxd_Wscale); - return 0; -} - -UCFUNC int d_SPPopMatrix(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_SPPopMatrix; -#if defined(F3D_GBI) || defined(F3DEX_GBI) - argi(m, 0, "param", lo, gfxd_Mtxstack); -#elif defined(F3DEX_GBI_2) - argi(m, 0, "param", G_MTX_MODELVIEW, gfxd_Mtxstack); -#endif - return 0; -} - -#if defined(F3DEX_GBI_2) -UCFUNC int d_SPPopMatrixN(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - int len = (getfield(hi, 5, 19) + 1) * 8; - int ofs = getfield(hi, 8, 8) * 8; - int idx = getfield(hi, 8, 0); - int n = lo / sizeof(Mtx); - if (lo % sizeof(Mtx) == 0 - && len == sizeof(Mtx) - && ofs == 0 - && idx == 2 - && n == 1) - { - return d_SPPopMatrix(m, hi, lo); - } - m->id = gfxd_SPPopMatrixN; - argi(m, 0, "param", G_MTX_MODELVIEW, gfxd_Mtxstack); - argi(m, 1, "num", n, gfxd_Num); - int ret = 0; - if (lo % sizeof(Mtx) != 0) - { - badarg(m, 1); - ret = -1; - } - if (len != sizeof(Mtx) || ofs != 0 || idx != 2) - ret = -1; - return ret; -} -#endif - -UCFUNC int d_SPSegment(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_SPSegment; -#if defined(F3D_GBI) || defined(F3DEX_GBI) - int offset = getfield(hi, 16, 8); -#elif defined(F3DEX_GBI_2) - int offset = getfield(hi, 16, 0); -#endif - argu(m, 0, "seg", offset / 4, gfxd_Seg); - argu(m, 1, "base", lo, gfxd_Segptr); - int ret = 0; - if (offset % 4 != 0) - { - badarg(m, 0); - ret = -1; - } - return ret; -} - -UCFUNC int c_SPSetLightsN(gfxd_macro_t *m, int n_macro, int id, int numlights) -{ - if (n_macro < 2 + numlights) - return -1; - if (m[0].id != gfxd_SPNumLights || argvi(&m[0], 0) != numlights) - return -1; - int a = 1 + numlights; - if (m[a].id != gfxd_SPLight || argvi(&m[a], 1) != a) - return -1; - uint32_t l = argvu(&m[a], 0); - for (int i = 1; i <= numlights; i++) - { - int offset = sizeof(Ambient) + sizeof(Light) * (i - 1); - if (m[i].id != gfxd_SPLight - || argvu(&m[i], 0) != l + offset - || argvi(&m[i], 1) != i) - { - return -1; - } - } - m->id = id; - argu(m, 0, "l", l, gfxd_Lightsn); - return 0; -} - -UCFUNC int c_SPSetLights1(gfxd_macro_t *m, int n_macro) -{ - return c_SPSetLightsN(m, n_macro, gfxd_SPSetLights1, NUMLIGHTS_1); -} - -UCFUNC int c_SPSetLights2(gfxd_macro_t *m, int n_macro) -{ - return c_SPSetLightsN(m, n_macro, gfxd_SPSetLights2, NUMLIGHTS_2); -} - -UCFUNC int c_SPSetLights3(gfxd_macro_t *m, int n_macro) -{ - return c_SPSetLightsN(m, n_macro, gfxd_SPSetLights3, NUMLIGHTS_3); -} - -UCFUNC int c_SPSetLights4(gfxd_macro_t *m, int n_macro) -{ - return c_SPSetLightsN(m, n_macro, gfxd_SPSetLights4, NUMLIGHTS_4); -} - -UCFUNC int c_SPSetLights5(gfxd_macro_t *m, int n_macro) -{ - return c_SPSetLightsN(m, n_macro, gfxd_SPSetLights5, NUMLIGHTS_5); -} - -UCFUNC int c_SPSetLights6(gfxd_macro_t *m, int n_macro) -{ - return c_SPSetLightsN(m, n_macro, gfxd_SPSetLights6, NUMLIGHTS_6); -} - -UCFUNC int c_SPSetLights7(gfxd_macro_t *m, int n_macro) -{ - return c_SPSetLightsN(m, n_macro, gfxd_SPSetLights7, NUMLIGHTS_7); -} - -#if defined(F3D_GBI) || defined(F3DEX_GBI) -UCFUNC int d_SPNumLights(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_SPNumLights; - argi(m, 0, "n", (lo - 0x80000000) / 32 - 1, gfxd_Numlights); - int ret = 0; - if (lo < 0x80000040 || lo % 32 != 0) - { - badarg(m, 0); - ret = -1; - } - return ret; -} -#elif defined(F3DEX_GBI_2) -UCFUNC int d_SPNumLights(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_SPNumLights; - argi(m, 0, "n", lo / 24, gfxd_Numlights); - int ret = 0; - if (lo < 24 || lo % 24 != 0) - { - badarg(m, 0); - ret = -1; - } - return ret; -} -#endif - -#if defined(F3D_GBI) || defined(F3DEX_GBI) -UCFUNC int d_SPLight(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - int n = (getfield(hi, 8, 16) - G_MV_L0) / 2 + 1; - m->id = gfxd_SPLight; - argu(m, 0, "l", lo, gfxd_Lightptr); - argi(m, 1, "n", n, gfxd_Num); - return 0; -} -#elif defined(F3DEX_GBI_2) -UCFUNC int d_SPLight(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - int n = (getfield(hi, 8, 8) * 8 / 24) - 1; - m->id = gfxd_SPLight; - argu(m, 0, "l", lo, gfxd_Lightptr); - argi(m, 1, "n", n, gfxd_Num); - return 0; -} -#endif - -UCFUNC int c_SPLightColor(gfxd_macro_t *m, int n_macro) -{ - if (n_macro < 2) - return -1; - if (m[0].id != gfxd_MoveWd - || argvi(&m[0], 0) != G_MW_LIGHTCOL - || argvu(&m[0], 1) % 0x18 != 0 - || argvu(&m[0], 1) > G_MWO_aLIGHT_8) - { - return -1; - } - uint32_t offset = argvu(&m[0], 1); - uint32_t packedcolor = argvu(&m[0], 2); - if (m[1].id != gfxd_MoveWd - || argvi(&m[1], 0) != G_MW_LIGHTCOL - || argvu(&m[1], 1) != offset + 4 - || argvu(&m[1], 2) != packedcolor) - { - return -1; - } - m->id = gfxd_SPLightColor; - argi(m, 0, "n", offset / 0x18 + 1, gfxd_Lightnum); - argu(m, 1, "c", packedcolor, gfxd_Color); - return 0; -} - -UCFUNC int d_SPTexture(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_SPTexture; - argu(m, 0, "sc", getfield(lo, 16, 16), gfxd_Tcscale); - argu(m, 1, "tc", getfield(lo, 16, 0), gfxd_Tcscale); - argi(m, 2, "level", getfield(hi, 3, 11), gfxd_Num); - argi(m, 3, "tile", getfield(hi, 3, 8), gfxd_Tile); -#if defined(F3D_GBI) || defined(F3DEX_GBI) - argi(m, 4, "on", getfield(hi, 8, 0), gfxd_Switch); -#elif defined(F3DEX_GBI_2) - argi(m, 4, "on", getfield(hi, 7, 1), gfxd_Switch); -#endif - return 0; -} - -UCFUNC int c_SPTextureRectangle(gfxd_macro_t *m, int n_macro) -{ - if (n_macro < 3) - return -1; - if (m[0].id != gfxd_TexRect) - return -1; - qu102_t ulx = argvu(&m[0], 0); - qu102_t uly = argvu(&m[0], 1); - qu102_t lrx = argvu(&m[0], 2); - qu102_t lry = argvu(&m[0], 3); - int tile = argvi(&m[0], 4); - if (m[1].id != gfxd_DPHalf1) - return -1; - qs105_t s = sx(getfield(argvu(&m[1], 0), 16, 16), 16); - qs105_t t = sx(getfield(argvu(&m[1], 0), 16, 0), 16); - if (m[2].id != gfxd_DPHalf2) - return -1; - qs510_t dsdx = sx(getfield(argvu(&m[2], 0), 16, 16), 16); - qs510_t dtdy = sx(getfield(argvu(&m[2], 0), 16, 0), 16); - m->id = gfxd_SPTextureRectangle; - argu(m, 0, "ulx", ulx, gfxd_Coordq); - argu(m, 1, "uly", uly, gfxd_Coordq); - argu(m, 2, "lrx", lrx, gfxd_Coordq); - argu(m, 3, "lry", lry, gfxd_Coordq); - argi(m, 4, "tile", tile, gfxd_Tile); - argi(m, 5, "s", s, gfxd_St); - argi(m, 6, "t", t, gfxd_St); - argi(m, 7, "dsdx", dsdx, gfxd_Stdelta); - argi(m, 8, "dtdy", dtdy, gfxd_Stdelta); - return 0; -} - -UCFUNC int c_SPTextureRectangleFlip(gfxd_macro_t *m, int n_macro) -{ - if (n_macro < 3) - return -1; - if (m[0].id != gfxd_TexRectFlip) - return -1; - qu102_t ulx = argvu(&m[0], 0); - qu102_t uly = argvu(&m[0], 1); - qu102_t lrx = argvu(&m[0], 2); - qu102_t lry = argvu(&m[0], 3); - int tile = argvi(&m[0], 4); - if (m[1].id != gfxd_DPHalf1) - return -1; - qs105_t s = sx(getfield(argvu(&m[1], 0), 16, 16), 16); - qs105_t t = sx(getfield(argvu(&m[1], 0), 16, 0), 16); - if (m[2].id != gfxd_DPHalf2) - return -1; - qs510_t dsdx = sx(getfield(argvu(&m[2], 0), 16, 16), 16); - qs510_t dtdy = sx(getfield(argvu(&m[2], 0), 16, 0), 16); - m->id = gfxd_SPTextureRectangleFlip; - argu(m, 0, "ulx", ulx, gfxd_Coordq); - argu(m, 1, "uly", uly, gfxd_Coordq); - argu(m, 2, "lrx", lrx, gfxd_Coordq); - argu(m, 3, "lry", lry, gfxd_Coordq); - argi(m, 4, "tile", tile, gfxd_Tile); - argi(m, 5, "s", s, gfxd_St); - argi(m, 6, "t", t, gfxd_St); - argi(m, 7, "dsdx", dsdx, gfxd_Stdelta); - argi(m, 8, "dtdy", dtdy, gfxd_Stdelta); - return 0; -} - -#if defined(F3D_GBI) -UCFUNC int d_SPVertex(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_SPVertex; - int n = getfield(hi, 4, 20) + 1; - int v0 = getfield(hi, 4, 16); - int size = getfield(hi, 16, 0); - argu(m, 0, "v", lo, gfxd_Vtxptr); - argi(m, 1, "n", n, gfxd_Num); - argi(m, 2, "v0", v0, gfxd_Vtx); - int ret = 0; - if (size != sizeof(Vtx) * n) - { - badarg(m, 1); - ret = -1; - } - return ret; -} -#elif defined(F3DEX_GBI) -UCFUNC int d_SPVertex(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_SPVertex; - int n = getfield(hi, 6, 10); - int v0 = getfield(hi, 8, 16); - int size = getfield(hi, 10, 0); - argu(m, 0, "v", lo, gfxd_Vtxptr); - argi(m, 1, "n", n, gfxd_Num); - argi(m, 2, "v0", v0 / 2, gfxd_Vtx); - int ret = 0; - if (size != sizeof(Vtx) * n - 1) - { - badarg(m, 1); - ret = -1; - } - if (v0 % 2 != 0) - { - badarg(m, 2); - ret = -1; - } - return ret; -} -#elif defined(F3DEX_GBI_2) -UCFUNC int d_SPVertex(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_SPVertex; - int n = getfield(hi, 8, 12); - int v0 = getfield(hi, 7, 1) - n; - argu(m, 0, "v", lo, gfxd_Vtxptr); - argi(m, 1, "n", n, gfxd_Num); - argi(m, 2, "v0", v0, gfxd_Vtx); - return 0; -} -#endif - -UCFUNC int d_SPViewport(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_SPViewport; - argu(m, 0, "v", lo, gfxd_Vpptr); - return 0; -} - -UCFUNC int d_DPLoadTLUTCmd(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_DPLoadTLUTCmd; - argi(m, 0, "tile", getfield(lo, 3, 24), gfxd_Tile); - argi(m, 1, "count", getfield(lo, 10, 14), gfxd_Num); - return 0; -} - -UCFUNC int c_DPLoadTLUT(gfxd_macro_t *m, int n_macro) -{ - if (n_macro < 6) - return -1; - if (m[0].id != gfxd_DPSetTextureImage - || argvi(&m[0], 0) != G_IM_FMT_RGBA - || argvi(&m[0], 1) != G_IM_SIZ_16b - || argvi(&m[0], 2) != 1) - { - return -1; - } - uint32_t dram = argvu(&m[0], 3); - if (m[1].id != gfxd_DPTileSync) - return -1; - if (m[2].id != gfxd_DPSetTile - || argvi(&m[2], 0) != 0 - || argvi(&m[2], 1) != 0 - || argvi(&m[2], 2) != 0 - || argvi(&m[2], 4) != G_TX_LOADTILE - || argvi(&m[2], 5) != 0 - || argvu(&m[2], 6) != 0 - || argvi(&m[2], 7) != 0 - || argvi(&m[2], 8) != 0 - || argvu(&m[2], 9) != 0 - || argvi(&m[2], 10) != 0 - || argvi(&m[2], 11) != 0) - { - return -1; - } - uint32_t tmem = argvu(&m[2], 3); - if (m[3].id != gfxd_DPLoadSync) - return -1; - if (m[4].id != gfxd_DPLoadTLUTCmd || argvi(&m[4], 0) != G_TX_LOADTILE) - return -1; - int count = argvi(&m[4], 1) + 1; - if (m[5].id != gfxd_DPPipeSync) - return -1; - m->id = gfxd_DPLoadTLUT; - argi(m, 0, "count", count, gfxd_Num); - argu(m, 1, "tmem", tmem, gfxd_Tmem); - argu(m, 2, "dram", dram, gfxd_Tlut); - return 0; -} - -#if defined(F3DEX_GBI) || defined(F3DEX_GBI_2) -UCFUNC int d_BranchZ(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_BranchZ; - int na = getfield(hi, 12, 12); - int nb = getfield(hi, 12, 0); - int32_t zval; - if (lo > 0x7FFFFFFF) - zval = INT32_MIN + (int32_t)(lo & 0x7FFFFFFF); - else - zval = lo; - argi(m, 0, "vtx", nb / 2, gfxd_Vtx); - argi(m, 1, "zval", zval, gfxd_Zraw); - int ret = 0; - if (nb % 2 != 0 || na / 5 != nb / 2 || na % 5 != 0) - { - badarg(m, 0); - ret = -1; - } - return ret; -} -#endif - -UCFUNC int d_DisplayList(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - int flag = getfield(hi, 8, 16); - if (flag == 0) - return d_SPDisplayList(m, hi, lo); - else if (flag == 1) - return d_SPBranchList(m, hi, lo); - else - { - m->id = gfxd_DisplayList; - argu(m, 0, "dl", lo, gfxd_Dl); - argi(m, 1, "flag", flag, gfxd_Dlflag); - return 0; - } -} - -UCFUNC int d_DPHalf1(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_DPHalf1; - argu(m, 0, "hi", lo, gfxd_Word); - return 0; -} - -UCFUNC int d_DPHalf2(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_DPHalf2; - argu(m, 0, "lo", lo, gfxd_Word); - return 0; -} - -UCFUNC int c_DPWord(gfxd_macro_t *m, int n_macro) -{ - if (n_macro < 2) - return -1; - if (m[0].id != gfxd_DPHalf1 || m[1].id != gfxd_DPHalf2) - return -1; - uint32_t wordhi = argvu(&m[0], 0); - uint32_t wordlo = argvu(&m[1], 0); - m->id = gfxd_DPWord; - argu(m, 0, "wordhi", wordhi, gfxd_Word); - argu(m, 1, "wordlo", wordlo, gfxd_Word); - return 0; -} - -UCFUNC int d_DPLoadTile(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_DPLoadTile; - argi(m, 0, "tile", getfield(lo, 3, 24), gfxd_Tile); - argu(m, 1, "uls", getfield(hi, 12, 12), gfxd_Coordq); - argu(m, 2, "ult", getfield(hi, 12, 0), gfxd_Coordq); - argu(m, 3, "lrs", getfield(lo, 12, 12), gfxd_Coordq); - argu(m, 4, "lrt", getfield(lo, 12, 0), gfxd_Coordq); - return 0; -} - -#if defined(F3DEX_GBI_2) -UCFUNC int d_SPGeometryMode(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - uint32_t clearbits = getfield(~hi, 24, 0); - uint32_t setbits = lo; - if (clearbits == 0 && setbits != 0) - return d_SPSetGeometryMode(m, hi, lo); - else if (clearbits != 0 && setbits == 0) - return d_SPClearGeometryMode(m, hi, lo); - else if (clearbits == 0x00FFFFFF) - return d_SPLoadGeometryMode(m, hi, lo); - else - { - m->id = gfxd_SPGeometryMode; - argu(m, 0, "c", clearbits, gfxd_Gm); - argu(m, 1, "s", setbits, gfxd_Gm); - return 0; - } -} -#endif - -UCFUNC int d_SPSetOtherMode(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_SPSetOtherMode; - int opc = getfield(hi, 8, 24); -#if defined(F3D_GBI) || defined(F3DEX_GBI) - int length = getfield(hi, 8, 0); - int shift = getfield(hi, 8, 8); -#elif defined(F3DEX_GBI_2) - int length = getfield(hi, 8, 0) + 1; - int shift = 32 - (getfield(hi, 8, 8) + length); -#endif - argi(m, 0, "opc", opc, gfxd_Opcode); - argi(m, 1, "sft", shift, gfxd_Sftlo); - argi(m, 2, "len", length, gfxd_Num); - if (opc == G_SETOTHERMODE_H) - argu(m, 3, "mode", lo, gfxd_Othermodehi); - else if (opc == G_SETOTHERMODE_L) - argu(m, 3, "mode", lo, gfxd_Othermodelo); - else - argu(m, 3, "mode", lo, gfxd_Word); - return 0; -} - -UCFUNC int d_SPSetOtherModeLo(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ -#if defined(F3D_GBI) || defined(F3DEX_GBI) - int length = getfield(hi, 8, 0); - int shift = getfield(hi, 8, 8); -#elif defined(F3DEX_GBI_2) - int length = getfield(hi, 8, 0) + 1; - int shift = 32 - (getfield(hi, 8, 8) + length); -#endif - if (shift == G_MDSFT_ALPHACOMPARE && length == G_MDSIZ_ALPHACOMPARE) - return d_DPSetAlphaCompare(m, hi, lo); - else if (shift == G_MDSFT_ZSRCSEL && length == G_MDSIZ_ZSRCSEL) - return d_DPSetDepthSource(m, hi, lo); - else if (shift == G_MDSFT_RENDERMODE && length == G_MDSIZ_RENDERMODE) - return d_DPSetRenderMode(m, hi, lo); - else if (config.emit_ext_macro) - { - m->id = gfxd_SPSetOtherModeLo; - argi(m, 0, "sft", shift, gfxd_Sftlo); - argi(m, 1, "len", length, gfxd_Num); - argu(m, 2, "mode", lo, gfxd_Othermodelo); - return 0; - } - else - return d_SPSetOtherMode(m, hi, lo); -} - -UCFUNC int d_SPSetOtherModeHi(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ -#if defined(F3D_GBI) || defined(F3DEX_GBI) - int length = getfield(hi, 8, 0); - int shift = getfield(hi, 8, 8); -#elif defined(F3DEX_GBI_2) - int length = getfield(hi, 8, 0) + 1; - int shift = 32 - (getfield(hi, 8, 8) + length); -#endif - if (shift == G_MDSFT_ALPHADITHER && length == G_MDSIZ_ALPHADITHER) - return d_DPSetAlphaDither(m, hi, lo); - else if (shift == G_MDSFT_RGBDITHER && length == G_MDSIZ_RGBDITHER) - return d_DPSetColorDither(m, hi, lo); - else if (shift == G_MDSFT_COMBKEY && length == G_MDSIZ_COMBKEY) - return d_DPSetCombineKey(m, hi, lo); - else if (shift == G_MDSFT_TEXTCONV && length == G_MDSIZ_TEXTCONV) - return d_DPSetTextureConvert(m, hi, lo); - else if (shift == G_MDSFT_TEXTFILT && length == G_MDSIZ_TEXTFILT) - return d_DPSetTextureFilter(m, hi, lo); - else if (shift == G_MDSFT_TEXTLUT && length == G_MDSIZ_TEXTLUT) - return d_DPSetTextureLUT(m, hi, lo); - else if (shift == G_MDSFT_TEXTLOD && length == G_MDSIZ_TEXTLOD) - return d_DPSetTextureLOD(m, hi, lo); - else if (shift == G_MDSFT_TEXTDETAIL && length == G_MDSIZ_TEXTDETAIL) - return d_DPSetTextureDetail(m, hi, lo); - else if (shift == G_MDSFT_TEXTPERSP && length == G_MDSIZ_TEXTPERSP) - return d_DPSetTexturePersp(m, hi, lo); - else if (shift == G_MDSFT_CYCLETYPE && length == G_MDSIZ_CYCLETYPE) - return d_DPSetCycleType(m, hi, lo); - else if (shift == G_MDSFT_PIPELINE && length == G_MDSIZ_PIPELINE) - return d_DPPipelineMode(m, hi, lo); - else if (config.emit_ext_macro) - { - m->id = gfxd_SPSetOtherModeHi; - argi(m, 0, "sft", shift, gfxd_Sfthi); - argi(m, 1, "len", length, gfxd_Num); - argu(m, 2, "mode", lo, gfxd_Othermodehi); - return 0; - } - else - return d_SPSetOtherMode(m, hi, lo); -} - -UCFUNC int d_DPSetOtherMode(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_DPSetOtherMode; - argu(m, 0, "hi", getfield(hi, 24, 0), gfxd_Othermodehi); - argu(m, 1, "lo", lo, gfxd_Othermodelo); - return 0; -} - -UCFUNC int d_MoveWd(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ -#if defined(F3D_GBI) || defined(F3DEX_GBI) - int index = getfield(hi, 8, 0); - int offset = getfield(hi, 16, 8); -#elif defined(F3DEX_GBI_2) - int index = getfield(hi, 8, 16); - int offset = getfield(hi, 16, 0); -#endif - if (index == G_MW_FOG && offset == G_MWO_FOG) - return d_SPFogPosition(m, hi, lo); -#if !(defined(F3D_BETA) && (defined(F3D_GBI) || defined(F3DEX_GBI))) - else if (index == G_MW_PERSPNORM && offset == 0) - return d_SPPerspNormalize(m, hi, lo); -#endif - else if (index == G_MW_SEGMENT) - return d_SPSegment(m, hi, lo); - else if (index == G_MW_NUMLIGHT && offset == G_MWO_NUMLIGHT) - return d_SPNumLights(m, hi, lo); -#if defined(F3D_GBI) || (defined(F3D_BETA) && defined(F3DEX_GBI)) - else if (index == G_MW_POINTS) - return d_SPModifyVertex(m, hi, lo); -#endif -#if defined(F3D_GBI) || defined(F3DEX_GBI) - else if (index == G_MW_MATRIX) - return d_SPInsertMatrix(m, hi, lo); -#endif - else - { - m->id = gfxd_MoveWd; - argi(m, 0, "index", index, gfxd_Mw); - if (index == G_MW_MATRIX) - argu(m, 1, "offset", offset, gfxd_Mwo_matrix); - else if (index == G_MW_CLIP) - argu(m, 1, "offset", offset, gfxd_Mwo_clip); - else if (index == G_MW_LIGHTCOL) - argu(m, 1, "offset", offset, gfxd_Mwo_lightcol); - else - argu(m, 1, "offset", offset, gfxd_Mwo); - argu(m, 2, "value", lo, gfxd_Word); - } - return 0; -} - -#if defined(F3D_GBI) || defined(F3DEX_GBI) -UCFUNC int d_MoveMem(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - int size = getfield(hi, 16, 0); - int index = getfield(hi, 8, 16); - if (size == sizeof(Light) - && index >= G_MV_L0 - && index <= G_MV_L7 - && index % 2 == 0) - { - return d_SPLight(m, hi, lo); - } - else if (size == sizeof(Light) && index == G_MV_LOOKATX) - return d_SPLookAtX(m, hi, lo); - else if (size == sizeof(Light) && index == G_MV_LOOKATY) - return d_SPLookAtY(m, hi, lo); - else if (size == sizeof(Vp) && index == G_MV_VIEWPORT) - return d_SPViewport(m, hi, lo); - else - { - m->id = gfxd_MoveMem; - argu(m, 0, "size", size, gfxd_Size); - argi(m, 1, "index", index, gfxd_Mv); - argu(m, 2, "dram", lo, gfxd_Dram); - return 0; - } -} -#elif defined(F3DEX_GBI_2) -UCFUNC int d_MoveMem(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - int size = (getfield(hi, 5, 19) + 1) * 8; - int index = getfield(hi, 8, 0); - int offset = getfield(hi, 8, 8) * 8; - if (size == sizeof(Light) - && index == G_MV_LIGHT - && offset >= G_MVO_L0 - && offset <= G_MVO_L7 - && offset % 0x18 == 0) - { - return d_SPLight(m, hi, lo); - } - else if (size == sizeof(Light) - && index == G_MV_LIGHT - && offset == G_MVO_LOOKATX) - { - return d_SPLookAtX(m, hi, lo); - } - else if (size == sizeof(Light) - && index == G_MV_LIGHT - && offset == G_MVO_LOOKATY) - { - return d_SPLookAtY(m, hi, lo); - } - else if (size == sizeof(Vp) - && index == G_MV_VIEWPORT - && offset == 0) - { - return d_SPViewport(m, hi, lo); - } - else - { - m->id = gfxd_MoveMem; - argu(m, 0, "size", size, gfxd_Size); - argi(m, 1, "index", index, gfxd_Mv); - argu(m, 2, "offset", offset, gfxd_Size); - argu(m, 3, "dram", lo, gfxd_Dram); - return 0; - } -} -#endif - -#if defined(F3DEX_GBI_2) -UCFUNC int d_SPDmaRead(gfxd_macro_t *m, uint32_t hi, uint32_t lo); -UCFUNC int d_SPDmaWrite(gfxd_macro_t *m, uint32_t hi, uint32_t lo); -UCFUNC int d_SPDma_io(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - int flag = getfield(hi, 1, 23); - if (flag == 0) - return d_SPDmaRead(m, hi, lo); - else if (flag == 1) - return d_SPDmaWrite(m, hi, lo); - else - { - m->id = gfxd_SPDma_io; - argi(m, 0, "flag", flag, gfxd_Dmaflag); - argu(m, 1, "dmem", getfield(hi, 10, 13) * 8, gfxd_Dmem); - argu(m, 2, "dram", lo, gfxd_Dram); - argu(m, 3, "size", getfield(hi, 12, 10) + 1, gfxd_Size); - return 0; - } -} - -UCFUNC int d_SPDmaRead(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_SPDmaRead; - argu(m, 0, "dmem", getfield(hi, 10, 13) * 8, gfxd_Dmem); - argu(m, 1, "dram", lo, gfxd_Dram); - argu(m, 2, "size", getfield(hi, 12, 10) + 1, gfxd_Size); - return 0; -} - -UCFUNC int d_SPDmaWrite(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_SPDmaWrite; - argu(m, 0, "dmem", getfield(hi, 10, 13) * 8, gfxd_Dmem); - argu(m, 1, "dram", lo, gfxd_Dram); - argu(m, 2, "size", getfield(hi, 12, 10) + 1, gfxd_Size); - return 0; -} -#endif - -#if defined(F3DEX_GBI) || defined(F3DEX_GBI_2) -UCFUNC int d_LoadUcode(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_LoadUcode; - argu(m, 0, "uc_start", lo, gfxd_Uctext); - argu(m, 1, "uc_dsize", getfield(hi, 16, 0) + 1, gfxd_Size); - return 0; -} - -UCFUNC int c_SPLoadUcodeEx(gfxd_macro_t *m, int n_macro) -{ - if (n_macro < 2) - return -1; - if (m[0].id != gfxd_DPHalf1) - return -1; - uint32_t uc_dstart = argvu(&m[0], 0); - if (m[1].id != gfxd_LoadUcode) - return -1; - uint32_t uc_start = argvu(&m[1], 0); - uint32_t uc_dsize = argvu(&m[1], 1); - m->id = gfxd_SPLoadUcodeEx; - argu(m, 0, "uc_start", uc_start, gfxd_Uctext); - argu(m, 1, "uc_dstart", uc_dstart, gfxd_Ucdata); - argu(m, 2, "uc_dsize", uc_dsize, gfxd_Size); - return 0; -} -#endif - -UCFUNC int d_TexRect(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_TexRect; - argu(m, 0, "ulx", getfield(lo, 12, 12), gfxd_Coordq); - argu(m, 1, "uly", getfield(lo, 12, 0), gfxd_Coordq); - argu(m, 2, "lrx", getfield(hi, 12, 12), gfxd_Coordq); - argu(m, 3, "lry", getfield(hi, 12, 0), gfxd_Coordq); - argi(m, 4, "tile", getfield(lo, 3, 24), gfxd_Tile); - return 0; -} - -UCFUNC int d_TexRectFlip(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_TexRectFlip; - argu(m, 0, "ulx", getfield(lo, 12, 12), gfxd_Coordq); - argu(m, 1, "uly", getfield(lo, 12, 0), gfxd_Coordq); - argu(m, 2, "lrx", getfield(hi, 12, 12), gfxd_Coordq); - argu(m, 3, "lry", getfield(hi, 12, 0), gfxd_Coordq); - argi(m, 4, "tile", getfield(lo, 3, 24), gfxd_Tile); - return 0; -} - -UCFUNC int d_SPNoOp(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_SPNoOp; - return 0; -} - -#if defined(F3DEX_GBI_2) -UCFUNC int d_Special3(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_Special3; - argu(m, 0, "hi", getfield(hi, 24, 0), gfxd_Word); - argu(m, 1, "lo", lo, gfxd_Word); - return 0; -} - -UCFUNC int d_Special2(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_Special2; - argu(m, 0, "hi", getfield(hi, 24, 0), gfxd_Word); - argu(m, 1, "lo", lo, gfxd_Word); - return 0; -} - -UCFUNC int d_Special1(gfxd_macro_t *m, uint32_t hi, uint32_t lo) -{ - m->id = gfxd_Special1; - argu(m, 0, "hi", getfield(hi, 24, 0), gfxd_Word); - argu(m, 1, "lo", lo, gfxd_Word); - return 0; -} -#endif diff --git a/ZAPDTR/lib/libgfxd/uc_macrotbl.c b/ZAPDTR/lib/libgfxd/uc_macrotbl.c deleted file mode 100644 index a8939cede..000000000 --- a/ZAPDTR/lib/libgfxd/uc_macrotbl.c +++ /dev/null @@ -1,1397 +0,0 @@ -static const gfxd_macro_type_t macro_tbl[] = -{ - [gfxd_Invalid] = - { - .prefix = NULL, - .suffix = NULL, - .opcode = -1, - .n_gfx = 1, - .n_arg = 2, - .disas_fn = d_Invalid, - }, - [gfxd_DPFillRectangle] = - { - .prefix = NULL, - .suffix = "DPFillRectangle", - .opcode = G_FILLRECT, - .n_gfx = 1, - .n_arg = 4, - .disas_fn = d_DPFillRectangle, - }, - [gfxd_DPFullSync] = - { - .prefix = NULL, - .suffix = "DPFullSync", - .opcode = G_RDPFULLSYNC, - .n_gfx = 1, - .n_arg = 0, - .disas_fn = d_DPFullSync, - }, - [gfxd_DPLoadSync] = - { - .prefix = NULL, - .suffix = "DPLoadSync", - .opcode = G_RDPLOADSYNC, - .n_gfx = 1, - .n_arg = 0, - .disas_fn = d_DPLoadSync, - }, - [gfxd_DPTileSync] = - { - .prefix = NULL, - .suffix = "DPTileSync", - .opcode = G_RDPTILESYNC, - .n_gfx = 1, - .n_arg = 0, - .disas_fn = d_DPTileSync, - }, - [gfxd_DPPipeSync] = - { - .prefix = NULL, - .suffix = "DPPipeSync", - .opcode = G_RDPPIPESYNC, - .n_gfx = 1, - .n_arg = 0, - .disas_fn = d_DPPipeSync, - }, - [gfxd_DPLoadTLUT_pal16] = - { - .prefix = NULL, - .suffix = "DPLoadTLUT_pal16", - .opcode = G_SETTIMG, - .n_gfx = 6, - .n_arg = 2, - .combine_fn = c_DPLoadTLUT_pal16, - }, - [gfxd_DPLoadTLUT_pal256] = - { - .prefix = NULL, - .suffix = "DPLoadTLUT_pal256", - .opcode = G_SETTIMG, - .n_gfx = 6, - .n_arg = 1, - .combine_fn = c_DPLoadTLUT_pal256, - }, - [gfxd_DPLoadMultiBlockYuvS] = - { - .prefix = NULL, - .suffix = "DPLoadMultiBlockYuvS", - .opcode = G_SETTIMG, - .n_gfx = 7, - .n_arg = 14, - .combine_fn = c_DPLoadMultiBlockYuvS, - .ext = 1, - }, - [gfxd_DPLoadMultiBlockYuv] = - { - .prefix = NULL, - .suffix = "DPLoadMultiBlockYuv", - .opcode = G_SETTIMG, - .n_gfx = 7, - .n_arg = 14, - .combine_fn = c_DPLoadMultiBlockYuv, - .ext = 1, - }, - [gfxd_DPLoadMultiBlock_4bS] = - { - .prefix = NULL, - .suffix = "DPLoadMultiBlock_4bS", - .opcode = G_SETTIMG, - .n_gfx = 7, - .n_arg = 13, - .combine_fn = c_DPLoadMultiBlock_4bS, - }, - [gfxd_DPLoadMultiBlock_4b] = - { - .prefix = NULL, - .suffix = "DPLoadMultiBlock_4b", - .opcode = G_SETTIMG, - .n_gfx = 7, - .n_arg = 13, - .combine_fn = c_DPLoadMultiBlock_4b, - }, - [gfxd_DPLoadMultiBlockS] = - { - .prefix = NULL, - .suffix = "DPLoadMultiBlockS", - .opcode = G_SETTIMG, - .n_gfx = 7, - .n_arg = 14, - .combine_fn = c_DPLoadMultiBlockS, - }, - [gfxd_DPLoadMultiBlock] = - { - .prefix = NULL, - .suffix = "DPLoadMultiBlock", - .opcode = G_SETTIMG, - .n_gfx = 7, - .n_arg = 14, - .combine_fn = c_DPLoadMultiBlock, - }, - [gfxd__DPLoadTextureBlockYuvS] = - { - .prefix = "_", - .suffix = "DPLoadTextureBlockYuvS", - .opcode = G_SETTIMG, - .n_gfx = 7, - .n_arg = 13, - .combine_fn = c__DPLoadTextureBlockYuvS, - .ext = 1, - }, - [gfxd__DPLoadTextureBlockYuv] = - { - .prefix = "_", - .suffix = "DPLoadTextureBlockYuv", - .opcode = G_SETTIMG, - .n_gfx = 7, - .n_arg = 13, - .combine_fn = c__DPLoadTextureBlockYuv, - .ext = 1, - }, - [gfxd__DPLoadTextureBlock_4bS] = - { - .prefix = "_", - .suffix = "DPLoadTextureBlock_4bS", - .opcode = G_SETTIMG, - .n_gfx = 7, - .n_arg = 12, - .combine_fn = c__DPLoadTextureBlock_4bS, - .ext = 1, - }, - [gfxd__DPLoadTextureBlock_4b] = - { - .prefix = "_", - .suffix = "DPLoadTextureBlock_4b", - .opcode = G_SETTIMG, - .n_gfx = 7, - .n_arg = 12, - .combine_fn = c__DPLoadTextureBlock_4b, - }, - [gfxd__DPLoadTextureBlockS] = - { - .prefix = "_", - .suffix = "DPLoadTextureBlockS", - .opcode = G_SETTIMG, - .n_gfx = 7, - .n_arg = 13, - .combine_fn = c__DPLoadTextureBlockS, - .ext = 1, - }, - [gfxd__DPLoadTextureBlock] = - { - .prefix = "_", - .suffix = "DPLoadTextureBlock", - .opcode = G_SETTIMG, - .n_gfx = 7, - .n_arg = 13, - .combine_fn = c__DPLoadTextureBlock, - }, - [gfxd_DPLoadTextureBlockYuvS] = - { - .prefix = NULL, - .suffix = "DPLoadTextureBlockYuvS", - .opcode = G_SETTIMG, - .n_gfx = 7, - .n_arg = 12, - .combine_fn = c_DPLoadTextureBlockYuvS, - .ext = 1, - }, - [gfxd_DPLoadTextureBlockYuv] = - { - .prefix = NULL, - .suffix = "DPLoadTextureBlockYuv", - .opcode = G_SETTIMG, - .n_gfx = 7, - .n_arg = 12, - .combine_fn = c_DPLoadTextureBlockYuv, - .ext = 1, - }, - [gfxd_DPLoadTextureBlock_4bS] = - { - .prefix = NULL, - .suffix = "DPLoadTextureBlock_4bS", - .opcode = G_SETTIMG, - .n_gfx = 7, - .n_arg = 11, - .combine_fn = c_DPLoadTextureBlock_4bS, - }, - [gfxd_DPLoadTextureBlock_4b] = - { - .prefix = NULL, - .suffix = "DPLoadTextureBlock_4b", - .opcode = G_SETTIMG, - .n_gfx = 7, - .n_arg = 11, - .combine_fn = c_DPLoadTextureBlock_4b, - }, - [gfxd_DPLoadTextureBlockS] = - { - .prefix = NULL, - .suffix = "DPLoadTextureBlockS", - .opcode = G_SETTIMG, - .n_gfx = 7, - .n_arg = 12, - .combine_fn = c_DPLoadTextureBlockS, - }, - [gfxd_DPLoadTextureBlock] = - { - .prefix = NULL, - .suffix = "DPLoadTextureBlock", - .opcode = G_SETTIMG, - .n_gfx = 7, - .n_arg = 12, - .combine_fn = c_DPLoadTextureBlock, - }, - [gfxd_DPLoadMultiTileYuv] = - { - .prefix = NULL, - .suffix = "DPLoadMultiTileYuv", - .opcode = G_SETTIMG, - .n_gfx = 7, - .n_arg = 18, - .combine_fn = c_DPLoadMultiTileYuv, - .ext = 1, - }, - [gfxd_DPLoadMultiTile_4b] = - { - .prefix = NULL, - .suffix = "DPLoadMultiTile_4b", - .opcode = G_SETTIMG, - .n_gfx = 7, - .n_arg = 17, - .combine_fn = c_DPLoadMultiTile_4b, - }, - [gfxd_DPLoadMultiTile] = - { - .prefix = NULL, - .suffix = "DPLoadMultiTile", - .opcode = G_SETTIMG, - .n_gfx = 7, - .n_arg = 18, - .combine_fn = c_DPLoadMultiTile, - }, - [gfxd__DPLoadTextureTileYuv] = - { - .prefix = "_", - .suffix = "DPLoadTextureTileYuv", - .opcode = G_SETTIMG, - .n_gfx = 7, - .n_arg = 17, - .combine_fn = c__DPLoadTextureTileYuv, - .ext = 1, - }, - [gfxd__DPLoadTextureTile_4b] = - { - .prefix = "_", - .suffix = "DPLoadTextureTile_4b", - .opcode = G_SETTIMG, - .n_gfx = 7, - .n_arg = 16, - .combine_fn = c__DPLoadTextureTile_4b, - .ext = 1, - }, - [gfxd__DPLoadTextureTile] = - { - .prefix = "_", - .suffix = "DPLoadTextureTile", - .opcode = G_SETTIMG, - .n_gfx = 7, - .n_arg = 17, - .combine_fn = c__DPLoadTextureTile, - .ext = 1, - }, - [gfxd_DPLoadTextureTileYuv] = - { - .prefix = NULL, - .suffix = "DPLoadTextureTileYuv", - .opcode = G_SETTIMG, - .n_gfx = 7, - .n_arg = 16, - .combine_fn = c_DPLoadTextureTileYuv, - .ext = 1, - }, - [gfxd_DPLoadTextureTile_4b] = - { - .prefix = NULL, - .suffix = "DPLoadTextureTile_4b", - .opcode = G_SETTIMG, - .n_gfx = 7, - .n_arg = 15, - .combine_fn = c_DPLoadTextureTile_4b, - }, - [gfxd_DPLoadTextureTile] = - { - .prefix = NULL, - .suffix = "DPLoadTextureTile", - .opcode = G_SETTIMG, - .n_gfx = 7, - .n_arg = 16, - .combine_fn = c_DPLoadTextureTile, - }, - [gfxd_DPLoadBlock] = - { - .prefix = NULL, - .suffix = "DPLoadBlock", - .opcode = G_LOADBLOCK, - .n_gfx = 1, - .n_arg = 5, - .disas_fn = d_DPLoadBlock, - }, - [gfxd_DPNoOp] = - { - .prefix = NULL, - .suffix = "DPNoOp", - .opcode = G_NOOP, - .n_gfx = 1, - .n_arg = 0, - .alias = gfxd_DPNoOpTag, - }, - [gfxd_DPNoOpTag] = - { - .prefix = NULL, - .suffix = "DPNoOpTag", - .opcode = G_NOOP, - .n_gfx = 1, - .n_arg = 1, - .disas_fn = d_DPNoOpTag, - }, - [gfxd_DPPipelineMode] = - { - .prefix = NULL, - .suffix = "DPPipelineMode", - .opcode = G_SETOTHERMODE_H, - .n_gfx = 1, - .n_arg = 1, - .alias = gfxd_SPSetOtherModeHi, - }, - [gfxd_DPSetBlendColor] = - { - .prefix = NULL, - .suffix = "DPSetBlendColor", - .opcode = G_SETBLENDCOLOR, - .n_gfx = 1, - .n_arg = 4, - .disas_fn = d_DPSetBlendColor, - }, - [gfxd_DPSetEnvColor] = - { - .prefix = NULL, - .suffix = "DPSetEnvColor", - .opcode = G_SETENVCOLOR, - .n_gfx = 1, - .n_arg = 4, - .disas_fn = d_DPSetEnvColor, - }, - [gfxd_DPSetFillColor] = - { - .prefix = NULL, - .suffix = "DPSetFillColor", - .opcode = G_SETFILLCOLOR, - .n_gfx = 1, - .n_arg = 1, - .disas_fn = d_DPSetFillColor, - }, - [gfxd_DPSetFogColor] = - { - .prefix = NULL, - .suffix = "DPSetFogColor", - .opcode = G_SETFOGCOLOR, - .n_gfx = 1, - .n_arg = 4, - .disas_fn = d_DPSetFogColor, - }, - [gfxd_DPSetPrimColor] = - { - .prefix = NULL, - .suffix = "DPSetPrimColor", - .opcode = G_SETPRIMCOLOR, - .n_gfx = 1, - .n_arg = 6, - .disas_fn = d_DPSetPrimColor, - }, - [gfxd_DPSetColorImage] = - { - .prefix = NULL, - .suffix = "DPSetColorImage", - .opcode = G_SETCIMG, - .n_gfx = 1, - .n_arg = 4, - .disas_fn = d_DPSetColorImage, - }, - [gfxd_DPSetDepthImage] = - { - .prefix = NULL, - .suffix = "DPSetDepthImage", - .opcode = G_SETZIMG, - .n_gfx = 1, - .n_arg = 1, - .disas_fn = d_DPSetDepthImage, - }, - [gfxd_DPSetTextureImage] = - { - .prefix = NULL, - .suffix = "DPSetTextureImage", - .opcode = G_SETTIMG, - .n_gfx = 1, - .n_arg = 4, - .disas_fn = d_DPSetTextureImage, - }, - [gfxd_DPSetAlphaCompare] = - { - .prefix = NULL, - .suffix = "DPSetAlphaCompare", - .opcode = G_SETOTHERMODE_L, - .n_gfx = 1, - .n_arg = 1, - .alias = gfxd_SPSetOtherModeLo, - }, - [gfxd_DPSetAlphaDither] = - { - .prefix = NULL, - .suffix = "DPSetAlphaDither", - .opcode = G_SETOTHERMODE_H, - .n_gfx = 1, - .n_arg = 1, - .alias = gfxd_SPSetOtherModeHi, - }, - [gfxd_DPSetColorDither] = - { - .prefix = NULL, - .suffix = "DPSetColorDither", - .opcode = G_SETOTHERMODE_H, - .n_gfx = 1, - .n_arg = 1, - .alias = gfxd_SPSetOtherModeHi, - }, - [gfxd_DPSetCombineMode] = - { - .prefix = NULL, - .suffix = "DPSetCombineMode", - .opcode = G_SETCOMBINE, - .n_gfx = 1, - .n_arg = 2, - .alias = gfxd_DPSetCombineLERP, - }, - [gfxd_DPSetCombineLERP] = - { - .prefix = NULL, - .suffix = "DPSetCombineLERP", - .opcode = G_SETCOMBINE, - .n_gfx = 1, - .n_arg = 16, - .disas_fn = d_DPSetCombineLERP, - }, - [gfxd_DPSetConvert] = - { - .prefix = NULL, - .suffix = "DPSetConvert", - .opcode = G_SETCONVERT, - .n_gfx = 1, - .n_arg = 6, - .disas_fn = d_DPSetConvert, - }, - [gfxd_DPSetTextureConvert] = - { - .prefix = NULL, - .suffix = "DPSetTextureConvert", - .opcode = G_SETOTHERMODE_H, - .n_gfx = 1, - .n_arg = 1, - .alias = gfxd_SPSetOtherModeHi, - }, - [gfxd_DPSetCycleType] = - { - .prefix = NULL, - .suffix = "DPSetCycleType", - .opcode = G_SETOTHERMODE_H, - .n_gfx = 1, - .n_arg = 1, - .alias = gfxd_SPSetOtherModeHi, - }, - [gfxd_DPSetDepthSource] = - { - .prefix = NULL, - .suffix = "DPSetDepthSource", - .opcode = G_SETOTHERMODE_L, - .n_gfx = 1, - .n_arg = 1, - .alias = gfxd_SPSetOtherModeLo, - }, - [gfxd_DPSetCombineKey] = - { - .prefix = NULL, - .suffix = "DPSetCombineKey", - .opcode = G_SETOTHERMODE_H, - .n_gfx = 1, - .n_arg = 1, - .alias = gfxd_SPSetOtherModeHi, - }, - [gfxd_DPSetKeyGB] = - { - .prefix = NULL, - .suffix = "DPSetKeyGB", - .opcode = G_SETKEYGB, - .n_gfx = 1, - .n_arg = 6, - .disas_fn = d_DPSetKeyGB, - }, - [gfxd_DPSetKeyR] = - { - .prefix = NULL, - .suffix = "DPSetKeyR", - .opcode = G_SETKEYR, - .n_gfx = 1, - .n_arg = 3, - .disas_fn = d_DPSetKeyR, - }, - [gfxd_DPSetPrimDepth] = - { - .prefix = NULL, - .suffix = "DPSetPrimDepth", - .opcode = G_SETPRIMDEPTH, - .n_gfx = 1, - .n_arg = 2, - .disas_fn = d_DPSetPrimDepth, - }, - [gfxd_DPSetRenderMode] = - { - .prefix = NULL, - .suffix = "DPSetRenderMode", - .opcode = G_SETOTHERMODE_L, - .n_gfx = 1, - .n_arg = 2, - .alias = gfxd_SPSetOtherModeLo, - }, - [gfxd_DPSetScissor] = - { - .prefix = NULL, - .suffix = "DPSetScissor", - .opcode = G_SETSCISSOR, - .n_gfx = 1, - .n_arg = 5, - .alias = gfxd_DPSetScissorFrac, - }, - [gfxd_DPSetScissorFrac] = - { - .prefix = NULL, - .suffix = "DPSetScissorFrac", - .opcode = G_SETSCISSOR, - .n_gfx = 1, - .n_arg = 5, - .disas_fn = d_DPSetScissorFrac, - }, - [gfxd_DPSetTextureDetail] = - { - .prefix = NULL, - .suffix = "DPSetTextureDetail", - .opcode = G_SETOTHERMODE_H, - .n_gfx = 1, - .n_arg = 1, - .alias = gfxd_SPSetOtherModeHi, - }, - [gfxd_DPSetTextureFilter] = - { - .prefix = NULL, - .suffix = "DPSetTextureFilter", - .opcode = G_SETOTHERMODE_H, - .n_gfx = 1, - .n_arg = 1, - .alias = gfxd_SPSetOtherModeHi, - }, - [gfxd_DPSetTextureLOD] = - { - .prefix = NULL, - .suffix = "DPSetTextureLOD", - .opcode = G_SETOTHERMODE_H, - .n_gfx = 1, - .n_arg = 1, - .alias = gfxd_SPSetOtherModeHi, - }, - [gfxd_DPSetTextureLUT] = - { - .prefix = NULL, - .suffix = "DPSetTextureLUT", - .opcode = G_SETOTHERMODE_H, - .n_gfx = 1, - .n_arg = 1, - .alias = gfxd_SPSetOtherModeHi, - }, - [gfxd_DPSetTexturePersp] = - { - .prefix = NULL, - .suffix = "DPSetTexturePersp", - .opcode = G_SETOTHERMODE_H, - .n_gfx = 1, - .n_arg = 1, - .alias = gfxd_SPSetOtherModeHi, - }, - [gfxd_DPSetTile] = - { - .prefix = NULL, - .suffix = "DPSetTile", - .opcode = G_SETTILE, - .n_gfx = 1, - .n_arg = 12, - .disas_fn = d_DPSetTile, - }, - [gfxd_DPSetTileSize] = - { - .prefix = NULL, - .suffix = "DPSetTileSize", - .opcode = G_SETTILESIZE, - .n_gfx = 1, - .n_arg = 5, - .disas_fn = d_DPSetTileSize, - }, - [gfxd_SP1Triangle] = - { - .prefix = NULL, - .suffix = "SP1Triangle", - .opcode = G_TRI1, - .n_gfx = 1, - .n_arg = 4, - .disas_fn = d_SP1Triangle, - }, -#if defined(F3DEX_GBI) || defined(F3DEX_GBI_2) - [gfxd_SP2Triangles] = - { - .prefix = NULL, - .suffix = "SP2Triangles", - .opcode = G_TRI2, - .n_gfx = 1, - .n_arg = 8, - .disas_fn = d_SP2Triangles, - }, -#endif -#if defined(F3DEX_GBI) - [gfxd_SP1Quadrangle] = - { - .prefix = NULL, - .suffix = "SP1Quadrangle", - .opcode = G_TRI2, - .n_gfx = 1, - .n_arg = 5, - .alias = gfxd_SP2Triangles, - }, -#elif defined(F3DEX_GBI_2) - [gfxd_SP1Quadrangle] = - { - .prefix = NULL, - .suffix = "SP1Quadrangle", - .opcode = G_QUAD, - .n_gfx = 1, - .n_arg = 5, - .disas_fn = d_SP1Quadrangle, - }, -#endif -#if defined(F3DEX_GBI) || defined(F3DEX_GBI_2) - [gfxd_SPBranchLessZraw] = - { - .prefix = NULL, - .suffix = "SPBranchLessZraw", - .opcode = G_RDPHALF_1, - .n_gfx = 2, - .n_arg = 3, - .combine_fn = c_SPBranchLessZraw, - }, -#endif - [gfxd_SPBranchList] = - { - .prefix = NULL, - .suffix = "SPBranchList", - .opcode = G_DL, - .n_gfx = 1, - .n_arg = 1, - .alias = gfxd_DisplayList, - }, - [gfxd_SPClipRatio] = - { - .prefix = NULL, - .suffix = "SPClipRatio", - .opcode = G_MOVEWORD, - .n_gfx = 4, - .n_arg = 1, - .combine_fn = c_SPClipRatio, - }, - [gfxd_SPCullDisplayList] = - { - .prefix = NULL, - .suffix = "SPCullDisplayList", - .opcode = G_CULLDL, - .n_gfx = 1, - .n_arg = 2, - .disas_fn = d_SPCullDisplayList, - }, - [gfxd_SPDisplayList] = - { - .prefix = NULL, - .suffix = "SPDisplayList", - .opcode = G_DL, - .n_gfx = 1, - .n_arg = 1, - .alias = gfxd_DisplayList, - }, - [gfxd_SPEndDisplayList] = - { - .prefix = NULL, - .suffix = "SPEndDisplayList", - .opcode = G_ENDDL, - .n_gfx = 1, - .n_arg = 0, - .disas_fn = d_SPEndDisplayList, - }, - [gfxd_SPFogFactor] = - { - .prefix = NULL, - .suffix = "SPFogFactor", - .opcode = G_MOVEWORD, - .n_gfx = 1, - .n_arg = 2, - .alias = gfxd_SPFogPosition, - }, - [gfxd_SPFogPosition] = - { - .prefix = NULL, - .suffix = "SPFogPosition", - .opcode = G_MOVEWORD, - .n_gfx = 1, - .n_arg = 2, - .alias = gfxd_MoveWd, - }, -#if defined(F3D_GBI) || defined(F3DEX_GBI) - [gfxd_SPForceMatrix] = - { - .prefix = NULL, - .suffix = "SPForceMatrix", - .opcode = G_MOVEMEM, - .n_gfx = 4, - .n_arg = 1, - .combine_fn = c_SPForceMatrix, - }, - [gfxd_SPSetGeometryMode] = - { - .prefix = NULL, - .suffix = "SPSetGeometryMode", - .opcode = G_SETGEOMETRYMODE, - .n_gfx = 1, - .n_arg = 1, - .disas_fn = d_SPSetGeometryMode, - }, - [gfxd_SPClearGeometryMode] = - { - .prefix = NULL, - .suffix = "SPClearGeometryMode", - .opcode = G_CLEARGEOMETRYMODE, - .n_gfx = 1, - .n_arg = 1, - .disas_fn = d_SPClearGeometryMode, - }, - [gfxd_SPLoadGeometryMode] = - { - .prefix = NULL, - .suffix = "SPLoadGeometryMode", - .opcode = G_CLEARGEOMETRYMODE, - .n_gfx = 2, - .n_arg = 1, - .combine_fn = c_SPLoadGeometryMode, - }, -#elif defined(F3DEX_GBI_2) - [gfxd_SPForceMatrix] = - { - .prefix = NULL, - .suffix = "SPForceMatrix", - .opcode = G_MOVEMEM, - .n_gfx = 2, - .n_arg = 1, - .combine_fn = c_SPForceMatrix, - }, - [gfxd_SPSetGeometryMode] = - { - .prefix = NULL, - .suffix = "SPSetGeometryMode", - .opcode = G_GEOMETRYMODE, - .n_gfx = 1, - .n_arg = 1, - .alias = gfxd_SPGeometryMode, - }, - [gfxd_SPClearGeometryMode] = - { - .prefix = NULL, - .suffix = "SPClearGeometryMode", - .opcode = G_GEOMETRYMODE, - .n_gfx = 1, - .n_arg = 1, - .alias = gfxd_SPGeometryMode, - }, - [gfxd_SPLoadGeometryMode] = - { - .prefix = NULL, - .suffix = "SPLoadGeometryMode", - .opcode = G_GEOMETRYMODE, - .n_gfx = 1, - .n_arg = 1, - .alias = gfxd_SPGeometryMode, - }, -#endif -#if defined(F3D_GBI) || defined(F3DEX_GBI) - [gfxd_SPInsertMatrix] = - { - .prefix = NULL, - .suffix = "SPInsertMatrix", - .opcode = G_MOVEWORD, - .n_gfx = 1, - .n_arg = 2, - .alias = gfxd_MoveWd, - }, -#endif - [gfxd_SPLine3D] = - { - .prefix = NULL, - .suffix = "SPLine3D", - .opcode = G_LINE3D, - .n_gfx = 1, - .n_arg = 3, - .alias = gfxd_SPLineW3D, - }, - [gfxd_SPLineW3D] = - { - .prefix = NULL, - .suffix = "SPLineW3D", - .opcode = G_LINE3D, - .n_gfx = 1, - .n_arg = 4, - .disas_fn = d_SPLineW3D, - }, -#if defined(F3DEX_GBI) || defined(F3DEX_GBI_2) - [gfxd_SPLoadUcode] = - { - .prefix = NULL, - .suffix = "SPLoadUcode", - .opcode = G_RDPHALF_1, - .n_gfx = 2, - .n_arg = 2, - .combine_fn = c_SPLoadUcode, - }, -#endif - [gfxd_SPLookAtX] = - { - .prefix = NULL, - .suffix = "SPLookAtX", - .opcode = G_MOVEMEM, - .n_gfx = 1, - .n_arg = 1, - .alias = gfxd_MoveMem, - }, - [gfxd_SPLookAtY] = - { - .prefix = NULL, - .suffix = "SPLookAtY", - .opcode = G_MOVEMEM, - .n_gfx = 1, - .n_arg = 1, - .alias = gfxd_MoveMem, - }, - [gfxd_SPLookAt] = - { - .prefix = NULL, - .suffix = "SPLookAt", - .opcode = G_MOVEMEM, - .n_gfx = 2, - .n_arg = 1, - .combine_fn = c_SPLookAt, - }, - [gfxd_SPMatrix] = - { - .prefix = NULL, - .suffix = "SPMatrix", - .opcode = G_MTX, - .n_gfx = 1, - .n_arg = 2, - .disas_fn = d_SPMatrix, - }, -#if defined(F3D_GBI) || (defined(F3D_BETA) && defined(F3DEX_GBI)) - [gfxd_SPModifyVertex] = - { - .prefix = NULL, - .suffix = "SPModifyVertex", - .opcode = G_MOVEWORD, - .n_gfx = 1, - .n_arg = 3, - .alias = gfxd_MoveWd, - }, -#elif defined(F3DEX_GBI) || defined(F3DEX_GBI_2) - [gfxd_SPModifyVertex] = - { - .prefix = NULL, - .suffix = "SPModifyVertex", - .opcode = G_MODIFYVTX, - .n_gfx = 1, - .n_arg = 3, - .disas_fn = d_SPModifyVertex, - }, -#endif -#if defined(F3D_BETA) && (defined(F3D_GBI) || defined(F3DEX_GBI)) - [gfxd_SPPerspNormalize] = - { - .prefix = NULL, - .suffix = "SPPerspNormalize", - .opcode = G_PERSPNORM, - .n_gfx = 1, - .n_arg = 1, - .disas_fn = d_SPPerspNormalize, - }, -#else - [gfxd_SPPerspNormalize] = - { - .prefix = NULL, - .suffix = "SPPerspNormalize", - .opcode = G_MOVEWORD, - .n_gfx = 1, - .n_arg = 1, - .alias = gfxd_MoveWd, - }, -#endif -#if defined(F3D_GBI) || defined(F3DEX_GBI) - [gfxd_SPPopMatrix] = - { - .prefix = NULL, - .suffix = "SPPopMatrix", - .opcode = G_POPMTX, - .n_gfx = 1, - .n_arg = 1, - .disas_fn = d_SPPopMatrix, - }, -#elif defined(F3DEX_GBI_2) - [gfxd_SPPopMatrix] = - { - .prefix = NULL, - .suffix = "SPPopMatrix", - .opcode = G_POPMTX, - .n_gfx = 1, - .n_arg = 1, - .alias = gfxd_SPPopMatrixN, - }, - [gfxd_SPPopMatrixN] = - { - .prefix = NULL, - .suffix = "SPPopMatrixN", - .opcode = G_POPMTX, - .n_gfx = 1, - .n_arg = 2, - .disas_fn = d_SPPopMatrixN, - }, -#endif - [gfxd_SPSegment] = - { - .prefix = NULL, - .suffix = "SPSegment", - .opcode = G_MOVEWORD, - .n_gfx = 1, - .n_arg = 2, - .alias = gfxd_MoveWd, - }, - [gfxd_SPSetLights1] = - { - .prefix = NULL, - .suffix = "SPSetLights1", - .opcode = G_MOVEWORD, - .n_gfx = 3, - .n_arg = 1, - .combine_fn = c_SPSetLights1, - }, - [gfxd_SPSetLights2] = - { - .prefix = NULL, - .suffix = "SPSetLights2", - .opcode = G_MOVEWORD, - .n_gfx = 4, - .n_arg = 1, - .combine_fn = c_SPSetLights2, - }, - [gfxd_SPSetLights3] = - { - .prefix = NULL, - .suffix = "SPSetLights3", - .opcode = G_MOVEWORD, - .n_gfx = 5, - .n_arg = 1, - .combine_fn = c_SPSetLights3, - }, - [gfxd_SPSetLights4] = - { - .prefix = NULL, - .suffix = "SPSetLights4", - .opcode = G_MOVEWORD, - .n_gfx = 6, - .n_arg = 1, - .combine_fn = c_SPSetLights4, - }, - [gfxd_SPSetLights5] = - { - .prefix = NULL, - .suffix = "SPSetLights5", - .opcode = G_MOVEWORD, - .n_gfx = 7, - .n_arg = 1, - .combine_fn = c_SPSetLights5, - }, - [gfxd_SPSetLights6] = - { - .prefix = NULL, - .suffix = "SPSetLights6", - .opcode = G_MOVEWORD, - .n_gfx = 8, - .n_arg = 1, - .combine_fn = c_SPSetLights6, - }, - [gfxd_SPSetLights7] = - { - .prefix = NULL, - .suffix = "SPSetLights7", - .opcode = G_MOVEWORD, - .n_gfx = 9, - .n_arg = 1, - .combine_fn = c_SPSetLights7, - }, - [gfxd_SPNumLights] = - { - .prefix = NULL, - .suffix = "SPNumLights", - .opcode = G_MOVEWORD, - .n_gfx = 1, - .n_arg = 1, - .alias = gfxd_MoveWd, - }, - [gfxd_SPLight] = - { - .prefix = NULL, - .suffix = "SPLight", - .opcode = G_MOVEMEM, - .n_gfx = 1, - .n_arg = 2, - .alias = gfxd_MoveMem, - }, - [gfxd_SPLightColor] = - { - .prefix = NULL, - .suffix = "SPLightColor", - .opcode = G_MOVEWORD, - .n_gfx = 2, - .n_arg = 2, - .combine_fn = c_SPLightColor, - }, - [gfxd_SPTexture] = - { - .prefix = NULL, - .suffix = "SPTexture", - .opcode = G_TEXTURE, - .n_gfx = 1, - .n_arg = 5, - .disas_fn = d_SPTexture, - }, - [gfxd_SPTextureRectangle] = - { - .prefix = NULL, - .suffix = "SPTextureRectangle", - .opcode = G_TEXRECT, - .n_gfx = 3, - .n_arg = 9, - .combine_fn = c_SPTextureRectangle, - }, - [gfxd_SPTextureRectangleFlip] = - { - .prefix = NULL, - .suffix = "SPTextureRectangleFlip", - .opcode = G_TEXRECTFLIP, - .n_gfx = 3, - .n_arg = 9, - .combine_fn = c_SPTextureRectangleFlip, - }, - [gfxd_SPVertex] = - { - .prefix = NULL, - .suffix = "SPVertex", - .opcode = G_VTX, - .n_gfx = 1, - .n_arg = 3, - .disas_fn = d_SPVertex, - }, - [gfxd_SPViewport] = - { - .prefix = NULL, - .suffix = "SPViewport", - .opcode = G_MOVEMEM, - .n_gfx = 1, - .n_arg = 1, - .alias = gfxd_MoveMem, - }, - [gfxd_DPLoadTLUTCmd] = - { - .prefix = NULL, - .suffix = "DPLoadTLUTCmd", - .opcode = G_LOADTLUT, - .n_gfx = 1, - .n_arg = 2, - .disas_fn = d_DPLoadTLUTCmd, - }, - [gfxd_DPLoadTLUT] = - { - .prefix = NULL, - .suffix = "DPLoadTLUT", - .opcode = G_SETTIMG, - .n_gfx = 6, - .n_arg = 3, - .combine_fn = c_DPLoadTLUT, - }, -#if defined(F3DEX_GBI) || defined(F3DEX_GBI_2) - [gfxd_BranchZ] = - { - .prefix = NULL, - .suffix = "BranchZ", - .opcode = G_BRANCH_Z, - .n_gfx = 1, - .n_arg = 2, - .disas_fn = d_BranchZ, - .ext = 1, - }, -#endif - [gfxd_DisplayList] = - { - .prefix = NULL, - .suffix = "DisplayList", - .opcode = G_DL, - .n_gfx = 1, - .n_arg = 2, - .disas_fn = d_DisplayList, - .ext = 1, - }, - [gfxd_DPHalf1] = - { - .prefix = NULL, - .suffix = "DPHalf1", - .opcode = G_RDPHALF_1, - .n_gfx = 1, - .n_arg = 1, - .disas_fn = d_DPHalf1, - .ext = 1, - }, - [gfxd_DPHalf2] = - { - .prefix = NULL, - .suffix = "DPHalf2", - .opcode = G_RDPHALF_2, - .n_gfx = 1, - .n_arg = 1, - .disas_fn = d_DPHalf2, - .ext = 1, - }, - [gfxd_DPWord] = - { - .prefix = NULL, - .suffix = "DPWord", - .opcode = G_RDPHALF_1, - .n_gfx = 2, - .n_arg = 2, - .combine_fn = c_DPWord, - }, - [gfxd_DPLoadTile] = - { - .prefix = NULL, - .suffix = "DPLoadTile", - .opcode = G_LOADTILE, - .n_gfx = 1, - .n_arg = 5, - .disas_fn = d_DPLoadTile, - }, -#if defined(F3DEX_GBI_2) - [gfxd_SPGeometryMode] = - { - .prefix = NULL, - .suffix = "SPGeometryMode", - .opcode = G_GEOMETRYMODE, - .n_gfx = 1, - .n_arg = 2, - .disas_fn = d_SPGeometryMode, - }, -#endif - [gfxd_SPSetOtherMode] = - { - .prefix = NULL, - .suffix = "SPSetOtherMode", - .opcode = -1, - .n_gfx = 1, - .n_arg = 4, - .disas_fn = d_SPSetOtherMode, - }, - [gfxd_SPSetOtherModeLo] = - { - .prefix = NULL, - .suffix = "SPSetOtherModeLo", - .opcode = G_SETOTHERMODE_L, - .n_gfx = 1, - .n_arg = 3, - .disas_fn = d_SPSetOtherModeLo, - .ext = 1, - }, - [gfxd_SPSetOtherModeHi] = - { - .prefix = NULL, - .suffix = "SPSetOtherModeHi", - .opcode = G_SETOTHERMODE_H, - .n_gfx = 1, - .n_arg = 3, - .disas_fn = d_SPSetOtherModeHi, - .ext = 1, - }, - [gfxd_DPSetOtherMode] = - { - .prefix = NULL, - .suffix = "DPSetOtherMode", - .opcode = G_RDPSETOTHERMODE, - .n_gfx = 1, - .n_arg = 2, - .disas_fn = d_DPSetOtherMode, - }, - [gfxd_MoveWd] = - { - .prefix = NULL, - .suffix = "MoveWd", - .opcode = G_MOVEWORD, - .n_gfx = 1, - .n_arg = 3, - .disas_fn = d_MoveWd, - }, -#if defined(F3D_GBI) || defined(F3DEX_GBI) - [gfxd_MoveMem] = - { - .prefix = NULL, - .suffix = "MoveMem", - .opcode = G_MOVEMEM, - .n_gfx = 1, - .n_arg = 3, - .disas_fn = d_MoveMem, - .ext = 1, - }, -#elif defined(F3DEX_GBI_2) - [gfxd_MoveMem] = - { - .prefix = NULL, - .suffix = "MoveMem", - .opcode = G_MOVEMEM, - .n_gfx = 1, - .n_arg = 4, - .disas_fn = d_MoveMem, - .ext = 1, - }, -#endif -#if defined(F3DEX_GBI_2) - [gfxd_SPDma_io] = - { - .prefix = NULL, - .suffix = "SPDma_io", - .opcode = G_DMA_IO, - .n_gfx = 1, - .n_arg = 4, - .disas_fn = d_SPDma_io, - }, - [gfxd_SPDmaRead] = - { - .prefix = NULL, - .suffix = "SPDmaRead", - .opcode = G_DMA_IO, - .n_gfx = 1, - .n_arg = 3, - .alias = gfxd_SPDma_io, - }, - [gfxd_SPDmaWrite] = - { - .prefix = NULL, - .suffix = "SPDmaWrite", - .opcode = G_DMA_IO, - .n_gfx = 1, - .n_arg = 3, - .alias = gfxd_SPDma_io, - }, -#endif -#if defined(F3DEX_GBI) || defined(F3DEX_GBI_2) - [gfxd_LoadUcode] = - { - .prefix = NULL, - .suffix = "LoadUcode", - .opcode = G_LOAD_UCODE, - .n_gfx = 1, - .n_arg = 2, - .disas_fn = d_LoadUcode, - }, - [gfxd_SPLoadUcodeEx] = - { - .prefix = NULL, - .suffix = "SPLoadUcodeEx", - .opcode = G_RDPHALF_1, - .n_gfx = 2, - .n_arg = 3, - .combine_fn = c_SPLoadUcodeEx, - }, -#endif - [gfxd_TexRect] = - { - .prefix = NULL, - .suffix = "TexRect", - .opcode = G_TEXRECT, - .n_gfx = 1, - .n_arg = 5, - .disas_fn = d_TexRect, - .ext = 1, - }, - [gfxd_TexRectFlip] = - { - .prefix = NULL, - .suffix = "TexRectFlip", - .opcode = G_TEXRECTFLIP, - .n_gfx = 1, - .n_arg = 5, - .disas_fn = d_TexRectFlip, - .ext = 1, - }, - [gfxd_SPNoOp] = - { - .prefix = NULL, - .suffix = "SPNoOp", - .opcode = G_SPNOOP, - .n_gfx = 1, - .n_arg = 0, - .disas_fn = d_SPNoOp, - }, -#if defined(F3DEX_GBI_2) - [gfxd_Special3] = - { - .prefix = NULL, - .suffix = "Special3", - .opcode = G_SPECIAL_3, - .n_gfx = 1, - .n_arg = 2, - .disas_fn = d_Special3, - .ext = 1, - }, - [gfxd_Special2] = - { - .prefix = NULL, - .suffix = "Special2", - .opcode = G_SPECIAL_2, - .n_gfx = 1, - .n_arg = 2, - .disas_fn = d_Special2, - .ext = 1, - }, - [gfxd_Special1] = - { - .prefix = NULL, - .suffix = "Special1", - .opcode = G_SPECIAL_1, - .n_gfx = 1, - .n_arg = 2, - .disas_fn = d_Special1, - .ext = 1, - }, -#endif -}; diff --git a/ZAPDTR/lib/tinyxml2/tinyxml2.cpp b/ZAPDTR/lib/tinyxml2/tinyxml2.cpp deleted file mode 100644 index 23a3a6ce4..000000000 --- a/ZAPDTR/lib/tinyxml2/tinyxml2.cpp +++ /dev/null @@ -1,2837 +0,0 @@ -/* -Original code by Lee Thomason (www.grinninglizard.com) - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any -damages arising from the use of this software. - -Permission is granted to anyone to use this software for any -purpose, including commercial applications, and to alter it and -redistribute it freely, subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must -not claim that you wrote the original software. If you use this -software in a product, an acknowledgment in the product documentation -would be appreciated but is not required. - -2. Altered source versions must be plainly marked as such, and -must not be misrepresented as being the original software. - -3. This notice may not be removed or altered from any source -distribution. -*/ - -#include "tinyxml2.h" - -#include // yes, this one new style header, is in the Android SDK. -#if defined(ANDROID_NDK) || defined(__BORLANDC__) || defined(__QNXNTO__) -# include -# include -#else -# include -# include -#endif - -#if defined(_MSC_VER) && (_MSC_VER >= 1400 ) && (!defined WINCE) - // Microsoft Visual Studio, version 2005 and higher. Not WinCE. - /*int _snprintf_s( - char *buffer, - size_t sizeOfBuffer, - size_t count, - const char *format [, - argument] ... - );*/ - static inline int TIXML_SNPRINTF( char* buffer, size_t size, const char* format, ... ) - { - va_list va; - va_start( va, format ); - int result = vsnprintf_s( buffer, size, _TRUNCATE, format, va ); - va_end( va ); - return result; - } - - static inline int TIXML_VSNPRINTF( char* buffer, size_t size, const char* format, va_list va ) - { - int result = vsnprintf_s( buffer, size, _TRUNCATE, format, va ); - return result; - } - - #define TIXML_VSCPRINTF _vscprintf - #define TIXML_SSCANF sscanf_s -#elif defined _MSC_VER - // Microsoft Visual Studio 2003 and earlier or WinCE - #define TIXML_SNPRINTF _snprintf - #define TIXML_VSNPRINTF _vsnprintf - #define TIXML_SSCANF sscanf - #if (_MSC_VER < 1400 ) && (!defined WINCE) - // Microsoft Visual Studio 2003 and not WinCE. - #define TIXML_VSCPRINTF _vscprintf // VS2003's C runtime has this, but VC6 C runtime or WinCE SDK doesn't have. - #else - // Microsoft Visual Studio 2003 and earlier or WinCE. - static inline int TIXML_VSCPRINTF( const char* format, va_list va ) - { - int len = 512; - for (;;) { - len = len*2; - char* str = new char[len](); - const int required = _vsnprintf(str, len, format, va); - delete[] str; - if ( required != -1 ) { - TIXMLASSERT( required >= 0 ); - len = required; - break; - } - } - TIXMLASSERT( len >= 0 ); - return len; - } - #endif -#else - // GCC version 3 and higher - //#warning( "Using sn* functions." ) - #define TIXML_SNPRINTF snprintf - #define TIXML_VSNPRINTF vsnprintf - static inline int TIXML_VSCPRINTF( const char* format, va_list va ) - { - int len = vsnprintf( 0, 0, format, va ); - TIXMLASSERT( len >= 0 ); - return len; - } - #define TIXML_SSCANF sscanf -#endif - - -static const char LINE_FEED = (char)0x0a; // all line endings are normalized to LF -static const char LF = LINE_FEED; -static const char CARRIAGE_RETURN = (char)0x0d; // CR gets filtered out -static const char CR = CARRIAGE_RETURN; -static const char SINGLE_QUOTE = '\''; -static const char DOUBLE_QUOTE = '\"'; - -// Bunch of unicode info at: -// http://www.unicode.org/faq/utf_bom.html -// ef bb bf (Microsoft "lead bytes") - designates UTF-8 - -static const unsigned char TIXML_UTF_LEAD_0 = 0xefU; -static const unsigned char TIXML_UTF_LEAD_1 = 0xbbU; -static const unsigned char TIXML_UTF_LEAD_2 = 0xbfU; - -namespace tinyxml2 -{ - -struct Entity { - const char* pattern; - int length; - char value; -}; - -static const int NUM_ENTITIES = 5; -static const Entity entities[NUM_ENTITIES] = { - { "quot", 4, DOUBLE_QUOTE }, - { "amp", 3, '&' }, - { "apos", 4, SINGLE_QUOTE }, - { "lt", 2, '<' }, - { "gt", 2, '>' } -}; - - -StrPair::~StrPair() -{ - Reset(); -} - - -void StrPair::TransferTo( StrPair* other ) -{ - if ( this == other ) { - return; - } - // This in effect implements the assignment operator by "moving" - // ownership (as in auto_ptr). - - TIXMLASSERT( other != 0 ); - TIXMLASSERT( other->_flags == 0 ); - TIXMLASSERT( other->_start == 0 ); - TIXMLASSERT( other->_end == 0 ); - - other->Reset(); - - other->_flags = _flags; - other->_start = _start; - other->_end = _end; - - _flags = 0; - _start = 0; - _end = 0; -} - - -void StrPair::Reset() -{ - if ( _flags & NEEDS_DELETE ) { - delete [] _start; - } - _flags = 0; - _start = 0; - _end = 0; -} - - -void StrPair::SetStr( const char* str, int flags ) -{ - TIXMLASSERT( str ); - Reset(); - size_t len = strlen( str ); - TIXMLASSERT( _start == 0 ); - _start = new char[ len+1 ]; - memcpy( _start, str, len+1 ); - _end = _start + len; - _flags = flags | NEEDS_DELETE; -} - - -char* StrPair::ParseText( char* p, const char* endTag, int strFlags, int* curLineNumPtr ) -{ - TIXMLASSERT( p ); - TIXMLASSERT( endTag && *endTag ); - TIXMLASSERT(curLineNumPtr); - - char* start = p; - char endChar = *endTag; - size_t length = strlen( endTag ); - - // Inner loop of text parsing. - while ( *p ) { - if ( *p == endChar && strncmp( p, endTag, length ) == 0 ) { - Set( start, p, strFlags ); - return p + length; - } else if (*p == '\n') { - ++(*curLineNumPtr); - } - ++p; - TIXMLASSERT( p ); - } - return 0; -} - - -char* StrPair::ParseName( char* p ) -{ - if ( !p || !(*p) ) { - return 0; - } - if ( !XMLUtil::IsNameStartChar( *p ) ) { - return 0; - } - - char* const start = p; - ++p; - while ( *p && XMLUtil::IsNameChar( *p ) ) { - ++p; - } - - Set( start, p, 0 ); - return p; -} - - -void StrPair::CollapseWhitespace() -{ - // Adjusting _start would cause undefined behavior on delete[] - TIXMLASSERT( ( _flags & NEEDS_DELETE ) == 0 ); - // Trim leading space. - _start = XMLUtil::SkipWhiteSpace( _start, 0 ); - - if ( *_start ) { - const char* p = _start; // the read pointer - char* q = _start; // the write pointer - - while( *p ) { - if ( XMLUtil::IsWhiteSpace( *p )) { - p = XMLUtil::SkipWhiteSpace( p, 0 ); - if ( *p == 0 ) { - break; // don't write to q; this trims the trailing space. - } - *q = ' '; - ++q; - } - *q = *p; - ++q; - ++p; - } - *q = 0; - } -} - - -const char* StrPair::GetStr() -{ - TIXMLASSERT( _start ); - TIXMLASSERT( _end ); - if ( _flags & NEEDS_FLUSH ) { - *_end = 0; - _flags ^= NEEDS_FLUSH; - - if ( _flags ) { - const char* p = _start; // the read pointer - char* q = _start; // the write pointer - - while( p < _end ) { - if ( (_flags & NEEDS_NEWLINE_NORMALIZATION) && *p == CR ) { - // CR-LF pair becomes LF - // CR alone becomes LF - // LF-CR becomes LF - if ( *(p+1) == LF ) { - p += 2; - } - else { - ++p; - } - *q = LF; - ++q; - } - else if ( (_flags & NEEDS_NEWLINE_NORMALIZATION) && *p == LF ) { - if ( *(p+1) == CR ) { - p += 2; - } - else { - ++p; - } - *q = LF; - ++q; - } - else if ( (_flags & NEEDS_ENTITY_PROCESSING) && *p == '&' ) { - // Entities handled by tinyXML2: - // - special entities in the entity table [in/out] - // - numeric character reference [in] - // 中 or 中 - - if ( *(p+1) == '#' ) { - const int buflen = 10; - char buf[buflen] = { 0 }; - int len = 0; - char* adjusted = const_cast( XMLUtil::GetCharacterRef( p, buf, &len ) ); - if ( adjusted == 0 ) { - *q = *p; - ++p; - ++q; - } - else { - TIXMLASSERT( 0 <= len && len <= buflen ); - TIXMLASSERT( q + len <= adjusted ); - p = adjusted; - memcpy( q, buf, len ); - q += len; - } - } - else { - bool entityFound = false; - for( int i = 0; i < NUM_ENTITIES; ++i ) { - const Entity& entity = entities[i]; - if ( strncmp( p + 1, entity.pattern, entity.length ) == 0 - && *( p + entity.length + 1 ) == ';' ) { - // Found an entity - convert. - *q = entity.value; - ++q; - p += entity.length + 2; - entityFound = true; - break; - } - } - if ( !entityFound ) { - // fixme: treat as error? - ++p; - ++q; - } - } - } - else { - *q = *p; - ++p; - ++q; - } - } - *q = 0; - } - // The loop below has plenty going on, and this - // is a less useful mode. Break it out. - if ( _flags & NEEDS_WHITESPACE_COLLAPSING ) { - CollapseWhitespace(); - } - _flags = (_flags & NEEDS_DELETE); - } - TIXMLASSERT( _start ); - return _start; -} - - - - -// --------- XMLUtil ----------- // - -const char* XMLUtil::writeBoolTrue = "true"; -const char* XMLUtil::writeBoolFalse = "false"; - -void XMLUtil::SetBoolSerialization(const char* writeTrue, const char* writeFalse) -{ - static const char* defTrue = "true"; - static const char* defFalse = "false"; - - writeBoolTrue = (writeTrue) ? writeTrue : defTrue; - writeBoolFalse = (writeFalse) ? writeFalse : defFalse; -} - - -const char* XMLUtil::ReadBOM( const char* p, bool* bom ) -{ - TIXMLASSERT( p ); - TIXMLASSERT( bom ); - *bom = false; - const unsigned char* pu = reinterpret_cast(p); - // Check for BOM: - if ( *(pu+0) == TIXML_UTF_LEAD_0 - && *(pu+1) == TIXML_UTF_LEAD_1 - && *(pu+2) == TIXML_UTF_LEAD_2 ) { - *bom = true; - p += 3; - } - TIXMLASSERT( p ); - return p; -} - - -void XMLUtil::ConvertUTF32ToUTF8( unsigned long input, char* output, int* length ) -{ - const unsigned long BYTE_MASK = 0xBF; - const unsigned long BYTE_MARK = 0x80; - const unsigned long FIRST_BYTE_MARK[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }; - - if (input < 0x80) { - *length = 1; - } - else if ( input < 0x800 ) { - *length = 2; - } - else if ( input < 0x10000 ) { - *length = 3; - } - else if ( input < 0x200000 ) { - *length = 4; - } - else { - *length = 0; // This code won't convert this correctly anyway. - return; - } - - output += *length; - - // Scary scary fall throughs are annotated with carefully designed comments - // to suppress compiler warnings such as -Wimplicit-fallthrough in gcc - switch (*length) { - case 4: - --output; - *output = (char)((input | BYTE_MARK) & BYTE_MASK); - input >>= 6; - //fall through - case 3: - --output; - *output = (char)((input | BYTE_MARK) & BYTE_MASK); - input >>= 6; - //fall through - case 2: - --output; - *output = (char)((input | BYTE_MARK) & BYTE_MASK); - input >>= 6; - //fall through - case 1: - --output; - *output = (char)(input | FIRST_BYTE_MARK[*length]); - break; - default: - TIXMLASSERT( false ); - } -} - - -const char* XMLUtil::GetCharacterRef( const char* p, char* value, int* length ) -{ - // Presume an entity, and pull it out. - *length = 0; - - if ( *(p+1) == '#' && *(p+2) ) { - unsigned long ucs = 0; - TIXMLASSERT( sizeof( ucs ) >= 4 ); - ptrdiff_t delta = 0; - unsigned mult = 1; - static const char SEMICOLON = ';'; - - if ( *(p+2) == 'x' ) { - // Hexadecimal. - const char* q = p+3; - if ( !(*q) ) { - return 0; - } - - q = strchr( q, SEMICOLON ); - - if ( !q ) { - return 0; - } - TIXMLASSERT( *q == SEMICOLON ); - - delta = q-p; - --q; - - while ( *q != 'x' ) { - unsigned int digit = 0; - - if ( *q >= '0' && *q <= '9' ) { - digit = *q - '0'; - } - else if ( *q >= 'a' && *q <= 'f' ) { - digit = *q - 'a' + 10; - } - else if ( *q >= 'A' && *q <= 'F' ) { - digit = *q - 'A' + 10; - } - else { - return 0; - } - TIXMLASSERT( digit < 16 ); - TIXMLASSERT( digit == 0 || mult <= UINT_MAX / digit ); - const unsigned int digitScaled = mult * digit; - TIXMLASSERT( ucs <= ULONG_MAX - digitScaled ); - ucs += digitScaled; - TIXMLASSERT( mult <= UINT_MAX / 16 ); - mult *= 16; - --q; - } - } - else { - // Decimal. - const char* q = p+2; - if ( !(*q) ) { - return 0; - } - - q = strchr( q, SEMICOLON ); - - if ( !q ) { - return 0; - } - TIXMLASSERT( *q == SEMICOLON ); - - delta = q-p; - --q; - - while ( *q != '#' ) { - if ( *q >= '0' && *q <= '9' ) { - const unsigned int digit = *q - '0'; - TIXMLASSERT( digit < 10 ); - TIXMLASSERT( digit == 0 || mult <= UINT_MAX / digit ); - const unsigned int digitScaled = mult * digit; - TIXMLASSERT( ucs <= ULONG_MAX - digitScaled ); - ucs += digitScaled; - } - else { - return 0; - } - TIXMLASSERT( mult <= UINT_MAX / 10 ); - mult *= 10; - --q; - } - } - // convert the UCS to UTF-8 - ConvertUTF32ToUTF8( ucs, value, length ); - return p + delta + 1; - } - return p+1; -} - - -void XMLUtil::ToStr( int v, char* buffer, int bufferSize ) -{ - TIXML_SNPRINTF( buffer, bufferSize, "%d", v ); -} - - -void XMLUtil::ToStr( unsigned v, char* buffer, int bufferSize ) -{ - TIXML_SNPRINTF( buffer, bufferSize, "%u", v ); -} - - -void XMLUtil::ToStr( bool v, char* buffer, int bufferSize ) -{ - TIXML_SNPRINTF( buffer, bufferSize, "%s", v ? writeBoolTrue : writeBoolFalse); -} - -/* - ToStr() of a number is a very tricky topic. - https://github.com/leethomason/tinyxml2/issues/106 -*/ -void XMLUtil::ToStr( float v, char* buffer, int bufferSize ) -{ - TIXML_SNPRINTF( buffer, bufferSize, "%.8g", v ); -} - - -void XMLUtil::ToStr( double v, char* buffer, int bufferSize ) -{ - TIXML_SNPRINTF( buffer, bufferSize, "%.17g", v ); -} - - -void XMLUtil::ToStr(int64_t v, char* buffer, int bufferSize) -{ - // horrible syntax trick to make the compiler happy about %lld - TIXML_SNPRINTF(buffer, bufferSize, "%lld", (long long)v); -} - - -bool XMLUtil::ToInt( const char* str, int* value ) -{ - if ( TIXML_SSCANF( str, "%d", value ) == 1 ) { - return true; - } - return false; -} - -bool XMLUtil::ToUnsigned( const char* str, unsigned *value ) -{ - if ( TIXML_SSCANF( str, "%u", value ) == 1 ) { - return true; - } - return false; -} - -bool XMLUtil::ToBool( const char* str, bool* value ) -{ - int ival = 0; - if ( ToInt( str, &ival )) { - *value = (ival==0) ? false : true; - return true; - } - if ( StringEqual( str, "true" ) ) { - *value = true; - return true; - } - else if ( StringEqual( str, "false" ) ) { - *value = false; - return true; - } - return false; -} - - -bool XMLUtil::ToFloat( const char* str, float* value ) -{ - if ( TIXML_SSCANF( str, "%f", value ) == 1 ) { - return true; - } - return false; -} - - -bool XMLUtil::ToDouble( const char* str, double* value ) -{ - if ( TIXML_SSCANF( str, "%lf", value ) == 1 ) { - return true; - } - return false; -} - - -bool XMLUtil::ToInt64(const char* str, int64_t* value) -{ - long long v = 0; // horrible syntax trick to make the compiler happy about %lld - if (TIXML_SSCANF(str, "%lld", &v) == 1) { - *value = (int64_t)v; - return true; - } - return false; -} - - -char* XMLDocument::Identify( char* p, XMLNode** node ) -{ - TIXMLASSERT( node ); - TIXMLASSERT( p ); - char* const start = p; - int const startLine = _parseCurLineNum; - p = XMLUtil::SkipWhiteSpace( p, &_parseCurLineNum ); - if( !*p ) { - *node = 0; - TIXMLASSERT( p ); - return p; - } - - // These strings define the matching patterns: - static const char* xmlHeader = { "( _commentPool ); - returnNode->_parseLineNum = _parseCurLineNum; - p += xmlHeaderLen; - } - else if ( XMLUtil::StringEqual( p, commentHeader, commentHeaderLen ) ) { - returnNode = CreateUnlinkedNode( _commentPool ); - returnNode->_parseLineNum = _parseCurLineNum; - p += commentHeaderLen; - } - else if ( XMLUtil::StringEqual( p, cdataHeader, cdataHeaderLen ) ) { - XMLText* text = CreateUnlinkedNode( _textPool ); - returnNode = text; - returnNode->_parseLineNum = _parseCurLineNum; - p += cdataHeaderLen; - text->SetCData( true ); - } - else if ( XMLUtil::StringEqual( p, dtdHeader, dtdHeaderLen ) ) { - returnNode = CreateUnlinkedNode( _commentPool ); - returnNode->_parseLineNum = _parseCurLineNum; - p += dtdHeaderLen; - } - else if ( XMLUtil::StringEqual( p, elementHeader, elementHeaderLen ) ) { - returnNode = CreateUnlinkedNode( _elementPool ); - returnNode->_parseLineNum = _parseCurLineNum; - p += elementHeaderLen; - } - else { - returnNode = CreateUnlinkedNode( _textPool ); - returnNode->_parseLineNum = _parseCurLineNum; // Report line of first non-whitespace character - p = start; // Back it up, all the text counts. - _parseCurLineNum = startLine; - } - - TIXMLASSERT( returnNode ); - TIXMLASSERT( p ); - *node = returnNode; - return p; -} - - -bool XMLDocument::Accept( XMLVisitor* visitor ) const -{ - TIXMLASSERT( visitor ); - if ( visitor->VisitEnter( *this ) ) { - for ( const XMLNode* node=FirstChild(); node; node=node->NextSibling() ) { - if ( !node->Accept( visitor ) ) { - break; - } - } - } - return visitor->VisitExit( *this ); -} - - -// --------- XMLNode ----------- // - -XMLNode::XMLNode( XMLDocument* doc ) : - _document( doc ), - _parent( 0 ), - _value(), - _parseLineNum( 0 ), - _firstChild( 0 ), _lastChild( 0 ), - _prev( 0 ), _next( 0 ), - _userData( 0 ), - _memPool( 0 ) -{ -} - - -XMLNode::~XMLNode() -{ - DeleteChildren(); - if ( _parent ) { - _parent->Unlink( this ); - } -} - -const char* XMLNode::Value() const -{ - // Edge case: XMLDocuments don't have a Value. Return null. - if ( this->ToDocument() ) - return 0; - return _value.GetStr(); -} - -void XMLNode::SetValue( const char* str, bool staticMem ) -{ - if ( staticMem ) { - _value.SetInternedStr( str ); - } - else { - _value.SetStr( str ); - } -} - -XMLNode* XMLNode::DeepClone(XMLDocument* target) const -{ - XMLNode* clone = this->ShallowClone(target); - if (!clone) return 0; - - for (const XMLNode* child = this->FirstChild(); child; child = child->NextSibling()) { - XMLNode* childClone = child->DeepClone(target); - TIXMLASSERT(childClone); - clone->InsertEndChild(childClone); - } - return clone; -} - -void XMLNode::DeleteChildren() -{ - while( _firstChild ) { - TIXMLASSERT( _lastChild ); - DeleteChild( _firstChild ); - } - _firstChild = _lastChild = 0; -} - - -void XMLNode::Unlink( XMLNode* child ) -{ - TIXMLASSERT( child ); - TIXMLASSERT( child->_document == _document ); - TIXMLASSERT( child->_parent == this ); - if ( child == _firstChild ) { - _firstChild = _firstChild->_next; - } - if ( child == _lastChild ) { - _lastChild = _lastChild->_prev; - } - - if ( child->_prev ) { - child->_prev->_next = child->_next; - } - if ( child->_next ) { - child->_next->_prev = child->_prev; - } - child->_next = 0; - child->_prev = 0; - child->_parent = 0; -} - - -void XMLNode::DeleteChild( XMLNode* node ) -{ - TIXMLASSERT( node ); - TIXMLASSERT( node->_document == _document ); - TIXMLASSERT( node->_parent == this ); - Unlink( node ); - TIXMLASSERT(node->_prev == 0); - TIXMLASSERT(node->_next == 0); - TIXMLASSERT(node->_parent == 0); - DeleteNode( node ); -} - - -XMLNode* XMLNode::InsertEndChild( XMLNode* addThis ) -{ - TIXMLASSERT( addThis ); - if ( addThis->_document != _document ) { - TIXMLASSERT( false ); - return 0; - } - InsertChildPreamble( addThis ); - - if ( _lastChild ) { - TIXMLASSERT( _firstChild ); - TIXMLASSERT( _lastChild->_next == 0 ); - _lastChild->_next = addThis; - addThis->_prev = _lastChild; - _lastChild = addThis; - - addThis->_next = 0; - } - else { - TIXMLASSERT( _firstChild == 0 ); - _firstChild = _lastChild = addThis; - - addThis->_prev = 0; - addThis->_next = 0; - } - addThis->_parent = this; - return addThis; -} - - -XMLNode* XMLNode::InsertFirstChild( XMLNode* addThis ) -{ - TIXMLASSERT( addThis ); - if ( addThis->_document != _document ) { - TIXMLASSERT( false ); - return 0; - } - InsertChildPreamble( addThis ); - - if ( _firstChild ) { - TIXMLASSERT( _lastChild ); - TIXMLASSERT( _firstChild->_prev == 0 ); - - _firstChild->_prev = addThis; - addThis->_next = _firstChild; - _firstChild = addThis; - - addThis->_prev = 0; - } - else { - TIXMLASSERT( _lastChild == 0 ); - _firstChild = _lastChild = addThis; - - addThis->_prev = 0; - addThis->_next = 0; - } - addThis->_parent = this; - return addThis; -} - - -XMLNode* XMLNode::InsertAfterChild( XMLNode* afterThis, XMLNode* addThis ) -{ - TIXMLASSERT( addThis ); - if ( addThis->_document != _document ) { - TIXMLASSERT( false ); - return 0; - } - - TIXMLASSERT( afterThis ); - - if ( afterThis->_parent != this ) { - TIXMLASSERT( false ); - return 0; - } - if ( afterThis == addThis ) { - // Current state: BeforeThis -> AddThis -> OneAfterAddThis - // Now AddThis must disappear from it's location and then - // reappear between BeforeThis and OneAfterAddThis. - // So just leave it where it is. - return addThis; - } - - if ( afterThis->_next == 0 ) { - // The last node or the only node. - return InsertEndChild( addThis ); - } - InsertChildPreamble( addThis ); - addThis->_prev = afterThis; - addThis->_next = afterThis->_next; - afterThis->_next->_prev = addThis; - afterThis->_next = addThis; - addThis->_parent = this; - return addThis; -} - - - - -const XMLElement* XMLNode::FirstChildElement( const char* name ) const -{ - for( const XMLNode* node = _firstChild; node; node = node->_next ) { - const XMLElement* element = node->ToElementWithName( name ); - if ( element ) { - return element; - } - } - return 0; -} - - -const XMLElement* XMLNode::LastChildElement( const char* name ) const -{ - for( const XMLNode* node = _lastChild; node; node = node->_prev ) { - const XMLElement* element = node->ToElementWithName( name ); - if ( element ) { - return element; - } - } - return 0; -} - - -const XMLElement* XMLNode::NextSiblingElement( const char* name ) const -{ - for( const XMLNode* node = _next; node; node = node->_next ) { - const XMLElement* element = node->ToElementWithName( name ); - if ( element ) { - return element; - } - } - return 0; -} - - -const XMLElement* XMLNode::PreviousSiblingElement( const char* name ) const -{ - for( const XMLNode* node = _prev; node; node = node->_prev ) { - const XMLElement* element = node->ToElementWithName( name ); - if ( element ) { - return element; - } - } - return 0; -} - - -char* XMLNode::ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr ) -{ - // This is a recursive method, but thinking about it "at the current level" - // it is a pretty simple flat list: - // - // - // - // With a special case: - // - // - // - // - // Where the closing element (/foo) *must* be the next thing after the opening - // element, and the names must match. BUT the tricky bit is that the closing - // element will be read by the child. - // - // 'endTag' is the end tag for this node, it is returned by a call to a child. - // 'parentEnd' is the end tag for the parent, which is filled in and returned. - - XMLDocument::DepthTracker tracker(_document); - if (_document->Error()) - return 0; - - while( p && *p ) { - XMLNode* node = 0; - - p = _document->Identify( p, &node ); - TIXMLASSERT( p ); - if ( node == 0 ) { - break; - } - - int initialLineNum = node->_parseLineNum; - - StrPair endTag; - p = node->ParseDeep( p, &endTag, curLineNumPtr ); - if ( !p ) { - DeleteNode( node ); - if ( !_document->Error() ) { - _document->SetError( XML_ERROR_PARSING, initialLineNum, 0); - } - break; - } - - XMLDeclaration* decl = node->ToDeclaration(); - if ( decl ) { - // Declarations are only allowed at document level - // - // Multiple declarations are allowed but all declarations - // must occur before anything else. - // - // Optimized due to a security test case. If the first node is - // a declaration, and the last node is a declaration, then only - // declarations have so far been addded. - bool wellLocated = false; - - if (ToDocument()) { - if (FirstChild()) { - wellLocated = - FirstChild() && - FirstChild()->ToDeclaration() && - LastChild() && - LastChild()->ToDeclaration(); - } - else { - wellLocated = true; - } - } - if ( !wellLocated ) { - _document->SetError( XML_ERROR_PARSING_DECLARATION, initialLineNum, "XMLDeclaration value=%s", decl->Value()); - DeleteNode( node ); - break; - } - } - - XMLElement* ele = node->ToElement(); - if ( ele ) { - // We read the end tag. Return it to the parent. - if ( ele->ClosingType() == XMLElement::CLOSING ) { - if ( parentEndTag ) { - ele->_value.TransferTo( parentEndTag ); - } - node->_memPool->SetTracked(); // created and then immediately deleted. - DeleteNode( node ); - return p; - } - - // Handle an end tag returned to this level. - // And handle a bunch of annoying errors. - bool mismatch = false; - if ( endTag.Empty() ) { - if ( ele->ClosingType() == XMLElement::OPEN ) { - mismatch = true; - } - } - else { - if ( ele->ClosingType() != XMLElement::OPEN ) { - mismatch = true; - } - else if ( !XMLUtil::StringEqual( endTag.GetStr(), ele->Name() ) ) { - mismatch = true; - } - } - if ( mismatch ) { - _document->SetError( XML_ERROR_MISMATCHED_ELEMENT, initialLineNum, "XMLElement name=%s", ele->Name()); - DeleteNode( node ); - break; - } - } - InsertEndChild( node ); - } - return 0; -} - -/*static*/ void XMLNode::DeleteNode( XMLNode* node ) -{ - if ( node == 0 ) { - return; - } - TIXMLASSERT(node->_document); - if (!node->ToDocument()) { - node->_document->MarkInUse(node); - } - - MemPool* pool = node->_memPool; - node->~XMLNode(); - pool->Free( node ); -} - -void XMLNode::InsertChildPreamble( XMLNode* insertThis ) const -{ - TIXMLASSERT( insertThis ); - TIXMLASSERT( insertThis->_document == _document ); - - if (insertThis->_parent) { - insertThis->_parent->Unlink( insertThis ); - } - else { - insertThis->_document->MarkInUse(insertThis); - insertThis->_memPool->SetTracked(); - } -} - -const XMLElement* XMLNode::ToElementWithName( const char* name ) const -{ - const XMLElement* element = this->ToElement(); - if ( element == 0 ) { - return 0; - } - if ( name == 0 ) { - return element; - } - if ( XMLUtil::StringEqual( element->Name(), name ) ) { - return element; - } - return 0; -} - -// --------- XMLText ---------- // -char* XMLText::ParseDeep( char* p, StrPair*, int* curLineNumPtr ) -{ - if ( this->CData() ) { - p = _value.ParseText( p, "]]>", StrPair::NEEDS_NEWLINE_NORMALIZATION, curLineNumPtr ); - if ( !p ) { - _document->SetError( XML_ERROR_PARSING_CDATA, _parseLineNum, 0 ); - } - return p; - } - else { - int flags = _document->ProcessEntities() ? StrPair::TEXT_ELEMENT : StrPair::TEXT_ELEMENT_LEAVE_ENTITIES; - if ( _document->WhitespaceMode() == COLLAPSE_WHITESPACE ) { - flags |= StrPair::NEEDS_WHITESPACE_COLLAPSING; - } - - p = _value.ParseText( p, "<", flags, curLineNumPtr ); - if ( p && *p ) { - return p-1; - } - if ( !p ) { - _document->SetError( XML_ERROR_PARSING_TEXT, _parseLineNum, 0 ); - } - } - return 0; -} - - -XMLNode* XMLText::ShallowClone( XMLDocument* doc ) const -{ - if ( !doc ) { - doc = _document; - } - XMLText* text = doc->NewText( Value() ); // fixme: this will always allocate memory. Intern? - text->SetCData( this->CData() ); - return text; -} - - -bool XMLText::ShallowEqual( const XMLNode* compare ) const -{ - TIXMLASSERT( compare ); - const XMLText* text = compare->ToText(); - return ( text && XMLUtil::StringEqual( text->Value(), Value() ) ); -} - - -bool XMLText::Accept( XMLVisitor* visitor ) const -{ - TIXMLASSERT( visitor ); - return visitor->Visit( *this ); -} - - -// --------- XMLComment ---------- // - -XMLComment::XMLComment( XMLDocument* doc ) : XMLNode( doc ) -{ -} - - -XMLComment::~XMLComment() -{ -} - - -char* XMLComment::ParseDeep( char* p, StrPair*, int* curLineNumPtr ) -{ - // Comment parses as text. - p = _value.ParseText( p, "-->", StrPair::COMMENT, curLineNumPtr ); - if ( p == 0 ) { - _document->SetError( XML_ERROR_PARSING_COMMENT, _parseLineNum, 0 ); - } - return p; -} - - -XMLNode* XMLComment::ShallowClone( XMLDocument* doc ) const -{ - if ( !doc ) { - doc = _document; - } - XMLComment* comment = doc->NewComment( Value() ); // fixme: this will always allocate memory. Intern? - return comment; -} - - -bool XMLComment::ShallowEqual( const XMLNode* compare ) const -{ - TIXMLASSERT( compare ); - const XMLComment* comment = compare->ToComment(); - return ( comment && XMLUtil::StringEqual( comment->Value(), Value() )); -} - - -bool XMLComment::Accept( XMLVisitor* visitor ) const -{ - TIXMLASSERT( visitor ); - return visitor->Visit( *this ); -} - - -// --------- XMLDeclaration ---------- // - -XMLDeclaration::XMLDeclaration( XMLDocument* doc ) : XMLNode( doc ) -{ -} - - -XMLDeclaration::~XMLDeclaration() -{ - //printf( "~XMLDeclaration\n" ); -} - - -char* XMLDeclaration::ParseDeep( char* p, StrPair*, int* curLineNumPtr ) -{ - // Declaration parses as text. - p = _value.ParseText( p, "?>", StrPair::NEEDS_NEWLINE_NORMALIZATION, curLineNumPtr ); - if ( p == 0 ) { - _document->SetError( XML_ERROR_PARSING_DECLARATION, _parseLineNum, 0 ); - } - return p; -} - - -XMLNode* XMLDeclaration::ShallowClone( XMLDocument* doc ) const -{ - if ( !doc ) { - doc = _document; - } - XMLDeclaration* dec = doc->NewDeclaration( Value() ); // fixme: this will always allocate memory. Intern? - return dec; -} - - -bool XMLDeclaration::ShallowEqual( const XMLNode* compare ) const -{ - TIXMLASSERT( compare ); - const XMLDeclaration* declaration = compare->ToDeclaration(); - return ( declaration && XMLUtil::StringEqual( declaration->Value(), Value() )); -} - - - -bool XMLDeclaration::Accept( XMLVisitor* visitor ) const -{ - TIXMLASSERT( visitor ); - return visitor->Visit( *this ); -} - -// --------- XMLUnknown ---------- // - -XMLUnknown::XMLUnknown( XMLDocument* doc ) : XMLNode( doc ) -{ -} - - -XMLUnknown::~XMLUnknown() -{ -} - - -char* XMLUnknown::ParseDeep( char* p, StrPair*, int* curLineNumPtr ) -{ - // Unknown parses as text. - p = _value.ParseText( p, ">", StrPair::NEEDS_NEWLINE_NORMALIZATION, curLineNumPtr ); - if ( !p ) { - _document->SetError( XML_ERROR_PARSING_UNKNOWN, _parseLineNum, 0 ); - } - return p; -} - - -XMLNode* XMLUnknown::ShallowClone( XMLDocument* doc ) const -{ - if ( !doc ) { - doc = _document; - } - XMLUnknown* text = doc->NewUnknown( Value() ); // fixme: this will always allocate memory. Intern? - return text; -} - - -bool XMLUnknown::ShallowEqual( const XMLNode* compare ) const -{ - TIXMLASSERT( compare ); - const XMLUnknown* unknown = compare->ToUnknown(); - return ( unknown && XMLUtil::StringEqual( unknown->Value(), Value() )); -} - - -bool XMLUnknown::Accept( XMLVisitor* visitor ) const -{ - TIXMLASSERT( visitor ); - return visitor->Visit( *this ); -} - -// --------- XMLAttribute ---------- // - -const char* XMLAttribute::Name() const -{ - return _name.GetStr(); -} - -const char* XMLAttribute::Value() const -{ - return _value.GetStr(); -} - -char* XMLAttribute::ParseDeep( char* p, bool processEntities, int* curLineNumPtr ) -{ - // Parse using the name rules: bug fix, was using ParseText before - p = _name.ParseName( p ); - if ( !p || !*p ) { - return 0; - } - - // Skip white space before = - p = XMLUtil::SkipWhiteSpace( p, curLineNumPtr ); - if ( *p != '=' ) { - return 0; - } - - ++p; // move up to opening quote - p = XMLUtil::SkipWhiteSpace( p, curLineNumPtr ); - if ( *p != '\"' && *p != '\'' ) { - return 0; - } - - char endTag[2] = { *p, 0 }; - ++p; // move past opening quote - - p = _value.ParseText( p, endTag, processEntities ? StrPair::ATTRIBUTE_VALUE : StrPair::ATTRIBUTE_VALUE_LEAVE_ENTITIES, curLineNumPtr ); - return p; -} - - -void XMLAttribute::SetName( const char* n ) -{ - _name.SetStr( n ); -} - - -XMLError XMLAttribute::QueryIntValue( int* value ) const -{ - if ( XMLUtil::ToInt( Value(), value )) { - return XML_SUCCESS; - } - return XML_WRONG_ATTRIBUTE_TYPE; -} - - -XMLError XMLAttribute::QueryUnsignedValue( unsigned int* value ) const -{ - if ( XMLUtil::ToUnsigned( Value(), value )) { - return XML_SUCCESS; - } - return XML_WRONG_ATTRIBUTE_TYPE; -} - - -XMLError XMLAttribute::QueryInt64Value(int64_t* value) const -{ - if (XMLUtil::ToInt64(Value(), value)) { - return XML_SUCCESS; - } - return XML_WRONG_ATTRIBUTE_TYPE; -} - - -XMLError XMLAttribute::QueryBoolValue( bool* value ) const -{ - if ( XMLUtil::ToBool( Value(), value )) { - return XML_SUCCESS; - } - return XML_WRONG_ATTRIBUTE_TYPE; -} - - -XMLError XMLAttribute::QueryFloatValue( float* value ) const -{ - if ( XMLUtil::ToFloat( Value(), value )) { - return XML_SUCCESS; - } - return XML_WRONG_ATTRIBUTE_TYPE; -} - - -XMLError XMLAttribute::QueryDoubleValue( double* value ) const -{ - if ( XMLUtil::ToDouble( Value(), value )) { - return XML_SUCCESS; - } - return XML_WRONG_ATTRIBUTE_TYPE; -} - - -void XMLAttribute::SetAttribute( const char* v ) -{ - _value.SetStr( v ); -} - - -void XMLAttribute::SetAttribute( int v ) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr( v, buf, BUF_SIZE ); - _value.SetStr( buf ); -} - - -void XMLAttribute::SetAttribute( unsigned v ) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr( v, buf, BUF_SIZE ); - _value.SetStr( buf ); -} - - -void XMLAttribute::SetAttribute(int64_t v) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr(v, buf, BUF_SIZE); - _value.SetStr(buf); -} - - - -void XMLAttribute::SetAttribute( bool v ) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr( v, buf, BUF_SIZE ); - _value.SetStr( buf ); -} - -void XMLAttribute::SetAttribute( double v ) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr( v, buf, BUF_SIZE ); - _value.SetStr( buf ); -} - -void XMLAttribute::SetAttribute( float v ) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr( v, buf, BUF_SIZE ); - _value.SetStr( buf ); -} - - -// --------- XMLElement ---------- // -XMLElement::XMLElement( XMLDocument* doc ) : XMLNode( doc ), - _closingType( OPEN ), - _rootAttribute( 0 ) -{ -} - - -XMLElement::~XMLElement() -{ - while( _rootAttribute ) { - XMLAttribute* next = _rootAttribute->_next; - DeleteAttribute( _rootAttribute ); - _rootAttribute = next; - } -} - - -const XMLAttribute* XMLElement::FindAttribute( const char* name ) const -{ - for( XMLAttribute* a = _rootAttribute; a; a = a->_next ) { - if ( XMLUtil::StringEqual( a->Name(), name ) ) { - return a; - } - } - return 0; -} - - -const char* XMLElement::Attribute( const char* name, const char* value ) const -{ - const XMLAttribute* a = FindAttribute( name ); - if ( !a ) { - return 0; - } - if ( !value || XMLUtil::StringEqual( a->Value(), value )) { - return a->Value(); - } - return 0; -} - -int XMLElement::IntAttribute(const char* name, int defaultValue) const -{ - int i = defaultValue; - QueryIntAttribute(name, &i); - return i; -} - -unsigned XMLElement::UnsignedAttribute(const char* name, unsigned defaultValue) const -{ - unsigned i = defaultValue; - QueryUnsignedAttribute(name, &i); - return i; -} - -int64_t XMLElement::Int64Attribute(const char* name, int64_t defaultValue) const -{ - int64_t i = defaultValue; - QueryInt64Attribute(name, &i); - return i; -} - -bool XMLElement::BoolAttribute(const char* name, bool defaultValue) const -{ - bool b = defaultValue; - QueryBoolAttribute(name, &b); - return b; -} - -double XMLElement::DoubleAttribute(const char* name, double defaultValue) const -{ - double d = defaultValue; - QueryDoubleAttribute(name, &d); - return d; -} - -float XMLElement::FloatAttribute(const char* name, float defaultValue) const -{ - float f = defaultValue; - QueryFloatAttribute(name, &f); - return f; -} - -const char* XMLElement::GetText() const -{ - if ( FirstChild() && FirstChild()->ToText() ) { - return FirstChild()->Value(); - } - return 0; -} - - -void XMLElement::SetText( const char* inText ) -{ - if ( FirstChild() && FirstChild()->ToText() ) - FirstChild()->SetValue( inText ); - else { - XMLText* theText = GetDocument()->NewText( inText ); - InsertFirstChild( theText ); - } -} - - -void XMLElement::SetText( int v ) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr( v, buf, BUF_SIZE ); - SetText( buf ); -} - - -void XMLElement::SetText( unsigned v ) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr( v, buf, BUF_SIZE ); - SetText( buf ); -} - - -void XMLElement::SetText(int64_t v) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr(v, buf, BUF_SIZE); - SetText(buf); -} - - -void XMLElement::SetText( bool v ) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr( v, buf, BUF_SIZE ); - SetText( buf ); -} - - -void XMLElement::SetText( float v ) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr( v, buf, BUF_SIZE ); - SetText( buf ); -} - - -void XMLElement::SetText( double v ) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr( v, buf, BUF_SIZE ); - SetText( buf ); -} - - -XMLError XMLElement::QueryIntText( int* ival ) const -{ - if ( FirstChild() && FirstChild()->ToText() ) { - const char* t = FirstChild()->Value(); - if ( XMLUtil::ToInt( t, ival ) ) { - return XML_SUCCESS; - } - return XML_CAN_NOT_CONVERT_TEXT; - } - return XML_NO_TEXT_NODE; -} - - -XMLError XMLElement::QueryUnsignedText( unsigned* uval ) const -{ - if ( FirstChild() && FirstChild()->ToText() ) { - const char* t = FirstChild()->Value(); - if ( XMLUtil::ToUnsigned( t, uval ) ) { - return XML_SUCCESS; - } - return XML_CAN_NOT_CONVERT_TEXT; - } - return XML_NO_TEXT_NODE; -} - - -XMLError XMLElement::QueryInt64Text(int64_t* ival) const -{ - if (FirstChild() && FirstChild()->ToText()) { - const char* t = FirstChild()->Value(); - if (XMLUtil::ToInt64(t, ival)) { - return XML_SUCCESS; - } - return XML_CAN_NOT_CONVERT_TEXT; - } - return XML_NO_TEXT_NODE; -} - - -XMLError XMLElement::QueryBoolText( bool* bval ) const -{ - if ( FirstChild() && FirstChild()->ToText() ) { - const char* t = FirstChild()->Value(); - if ( XMLUtil::ToBool( t, bval ) ) { - return XML_SUCCESS; - } - return XML_CAN_NOT_CONVERT_TEXT; - } - return XML_NO_TEXT_NODE; -} - - -XMLError XMLElement::QueryDoubleText( double* dval ) const -{ - if ( FirstChild() && FirstChild()->ToText() ) { - const char* t = FirstChild()->Value(); - if ( XMLUtil::ToDouble( t, dval ) ) { - return XML_SUCCESS; - } - return XML_CAN_NOT_CONVERT_TEXT; - } - return XML_NO_TEXT_NODE; -} - - -XMLError XMLElement::QueryFloatText( float* fval ) const -{ - if ( FirstChild() && FirstChild()->ToText() ) { - const char* t = FirstChild()->Value(); - if ( XMLUtil::ToFloat( t, fval ) ) { - return XML_SUCCESS; - } - return XML_CAN_NOT_CONVERT_TEXT; - } - return XML_NO_TEXT_NODE; -} - -int XMLElement::IntText(int defaultValue) const -{ - int i = defaultValue; - QueryIntText(&i); - return i; -} - -unsigned XMLElement::UnsignedText(unsigned defaultValue) const -{ - unsigned i = defaultValue; - QueryUnsignedText(&i); - return i; -} - -int64_t XMLElement::Int64Text(int64_t defaultValue) const -{ - int64_t i = defaultValue; - QueryInt64Text(&i); - return i; -} - -bool XMLElement::BoolText(bool defaultValue) const -{ - bool b = defaultValue; - QueryBoolText(&b); - return b; -} - -double XMLElement::DoubleText(double defaultValue) const -{ - double d = defaultValue; - QueryDoubleText(&d); - return d; -} - -float XMLElement::FloatText(float defaultValue) const -{ - float f = defaultValue; - QueryFloatText(&f); - return f; -} - - -XMLAttribute* XMLElement::FindOrCreateAttribute( const char* name ) -{ - XMLAttribute* last = 0; - XMLAttribute* attrib = 0; - for( attrib = _rootAttribute; - attrib; - last = attrib, attrib = attrib->_next ) { - if ( XMLUtil::StringEqual( attrib->Name(), name ) ) { - break; - } - } - if ( !attrib ) { - attrib = CreateAttribute(); - TIXMLASSERT( attrib ); - if ( last ) { - TIXMLASSERT( last->_next == 0 ); - last->_next = attrib; - } - else { - TIXMLASSERT( _rootAttribute == 0 ); - _rootAttribute = attrib; - } - attrib->SetName( name ); - } - return attrib; -} - - -void XMLElement::DeleteAttribute( const char* name ) -{ - XMLAttribute* prev = 0; - for( XMLAttribute* a=_rootAttribute; a; a=a->_next ) { - if ( XMLUtil::StringEqual( name, a->Name() ) ) { - if ( prev ) { - prev->_next = a->_next; - } - else { - _rootAttribute = a->_next; - } - DeleteAttribute( a ); - break; - } - prev = a; - } -} - - -char* XMLElement::ParseAttributes( char* p, int* curLineNumPtr ) -{ - XMLAttribute* prevAttribute = 0; - - // Read the attributes. - while( p ) { - p = XMLUtil::SkipWhiteSpace( p, curLineNumPtr ); - if ( !(*p) ) { - _document->SetError( XML_ERROR_PARSING_ELEMENT, _parseLineNum, "XMLElement name=%s", Name() ); - return 0; - } - - // attribute. - if (XMLUtil::IsNameStartChar( *p ) ) { - XMLAttribute* attrib = CreateAttribute(); - TIXMLASSERT( attrib ); - attrib->_parseLineNum = _document->_parseCurLineNum; - - int attrLineNum = attrib->_parseLineNum; - - p = attrib->ParseDeep( p, _document->ProcessEntities(), curLineNumPtr ); - if ( !p || Attribute( attrib->Name() ) ) { - DeleteAttribute( attrib ); - _document->SetError( XML_ERROR_PARSING_ATTRIBUTE, attrLineNum, "XMLElement name=%s", Name() ); - return 0; - } - // There is a minor bug here: if the attribute in the source xml - // document is duplicated, it will not be detected and the - // attribute will be doubly added. However, tracking the 'prevAttribute' - // avoids re-scanning the attribute list. Preferring performance for - // now, may reconsider in the future. - if ( prevAttribute ) { - TIXMLASSERT( prevAttribute->_next == 0 ); - prevAttribute->_next = attrib; - } - else { - TIXMLASSERT( _rootAttribute == 0 ); - _rootAttribute = attrib; - } - prevAttribute = attrib; - } - // end of the tag - else if ( *p == '>' ) { - ++p; - break; - } - // end of the tag - else if ( *p == '/' && *(p+1) == '>' ) { - _closingType = CLOSED; - return p+2; // done; sealed element. - } - else { - _document->SetError( XML_ERROR_PARSING_ELEMENT, _parseLineNum, 0 ); - return 0; - } - } - return p; -} - -void XMLElement::DeleteAttribute( XMLAttribute* attribute ) -{ - if ( attribute == 0 ) { - return; - } - MemPool* pool = attribute->_memPool; - attribute->~XMLAttribute(); - pool->Free( attribute ); -} - -XMLAttribute* XMLElement::CreateAttribute() -{ - TIXMLASSERT( sizeof( XMLAttribute ) == _document->_attributePool.ItemSize() ); - XMLAttribute* attrib = new (_document->_attributePool.Alloc() ) XMLAttribute(); - TIXMLASSERT( attrib ); - attrib->_memPool = &_document->_attributePool; - attrib->_memPool->SetTracked(); - return attrib; -} - -// -// -// foobar -// -char* XMLElement::ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr ) -{ - // Read the element name. - p = XMLUtil::SkipWhiteSpace( p, curLineNumPtr ); - - // The closing element is the form. It is - // parsed just like a regular element then deleted from - // the DOM. - if ( *p == '/' ) { - _closingType = CLOSING; - ++p; - } - - p = _value.ParseName( p ); - if ( _value.Empty() ) { - return 0; - } - - p = ParseAttributes( p, curLineNumPtr ); - if ( !p || !*p || _closingType != OPEN ) { - return p; - } - - p = XMLNode::ParseDeep( p, parentEndTag, curLineNumPtr ); - return p; -} - - - -XMLNode* XMLElement::ShallowClone( XMLDocument* doc ) const -{ - if ( !doc ) { - doc = _document; - } - XMLElement* element = doc->NewElement( Value() ); // fixme: this will always allocate memory. Intern? - for( const XMLAttribute* a=FirstAttribute(); a; a=a->Next() ) { - element->SetAttribute( a->Name(), a->Value() ); // fixme: this will always allocate memory. Intern? - } - return element; -} - - -bool XMLElement::ShallowEqual( const XMLNode* compare ) const -{ - TIXMLASSERT( compare ); - const XMLElement* other = compare->ToElement(); - if ( other && XMLUtil::StringEqual( other->Name(), Name() )) { - - const XMLAttribute* a=FirstAttribute(); - const XMLAttribute* b=other->FirstAttribute(); - - while ( a && b ) { - if ( !XMLUtil::StringEqual( a->Value(), b->Value() ) ) { - return false; - } - a = a->Next(); - b = b->Next(); - } - if ( a || b ) { - // different count - return false; - } - return true; - } - return false; -} - - -bool XMLElement::Accept( XMLVisitor* visitor ) const -{ - TIXMLASSERT( visitor ); - if ( visitor->VisitEnter( *this, _rootAttribute ) ) { - for ( const XMLNode* node=FirstChild(); node; node=node->NextSibling() ) { - if ( !node->Accept( visitor ) ) { - break; - } - } - } - return visitor->VisitExit( *this ); -} - - -// --------- XMLDocument ----------- // - -// Warning: List must match 'enum XMLError' -const char* XMLDocument::_errorNames[XML_ERROR_COUNT] = { - "XML_SUCCESS", - "XML_NO_ATTRIBUTE", - "XML_WRONG_ATTRIBUTE_TYPE", - "XML_ERROR_FILE_NOT_FOUND", - "XML_ERROR_FILE_COULD_NOT_BE_OPENED", - "XML_ERROR_FILE_READ_ERROR", - "XML_ERROR_PARSING_ELEMENT", - "XML_ERROR_PARSING_ATTRIBUTE", - "XML_ERROR_PARSING_TEXT", - "XML_ERROR_PARSING_CDATA", - "XML_ERROR_PARSING_COMMENT", - "XML_ERROR_PARSING_DECLARATION", - "XML_ERROR_PARSING_UNKNOWN", - "XML_ERROR_EMPTY_DOCUMENT", - "XML_ERROR_MISMATCHED_ELEMENT", - "XML_ERROR_PARSING", - "XML_CAN_NOT_CONVERT_TEXT", - "XML_NO_TEXT_NODE", - "XML_ELEMENT_DEPTH_EXCEEDED" -}; - - -XMLDocument::XMLDocument( bool processEntities, Whitespace whitespaceMode ) : - XMLNode( 0 ), - _writeBOM( false ), - _processEntities( processEntities ), - _errorID(XML_SUCCESS), - _whitespaceMode( whitespaceMode ), - _errorStr(), - _errorLineNum( 0 ), - _charBuffer( 0 ), - _parseCurLineNum( 0 ), - _parsingDepth(0), - _unlinked(), - _elementPool(), - _attributePool(), - _textPool(), - _commentPool() -{ - // avoid VC++ C4355 warning about 'this' in initializer list (C4355 is off by default in VS2012+) - _document = this; -} - - -XMLDocument::~XMLDocument() -{ - Clear(); -} - - -void XMLDocument::MarkInUse(XMLNode* node) -{ - TIXMLASSERT(node); - TIXMLASSERT(node->_parent == 0); - - for (int i = 0; i < _unlinked.Size(); ++i) { - if (node == _unlinked[i]) { - _unlinked.SwapRemove(i); - break; - } - } -} - -void XMLDocument::Clear() -{ - DeleteChildren(); - while( _unlinked.Size()) { - DeleteNode(_unlinked[0]); // Will remove from _unlinked as part of delete. - } - -#ifdef TINYXML2_DEBUG - const bool hadError = Error(); -#endif - ClearError(); - - delete [] _charBuffer; - _charBuffer = 0; - _parsingDepth = 0; - -#if 0 - _textPool.Trace( "text" ); - _elementPool.Trace( "element" ); - _commentPool.Trace( "comment" ); - _attributePool.Trace( "attribute" ); -#endif - -#ifdef TINYXML2_DEBUG - if ( !hadError ) { - TIXMLASSERT( _elementPool.CurrentAllocs() == _elementPool.Untracked() ); - TIXMLASSERT( _attributePool.CurrentAllocs() == _attributePool.Untracked() ); - TIXMLASSERT( _textPool.CurrentAllocs() == _textPool.Untracked() ); - TIXMLASSERT( _commentPool.CurrentAllocs() == _commentPool.Untracked() ); - } -#endif -} - - -void XMLDocument::DeepCopy(XMLDocument* target) const -{ - TIXMLASSERT(target); - if (target == this) { - return; // technically success - a no-op. - } - - target->Clear(); - for (const XMLNode* node = this->FirstChild(); node; node = node->NextSibling()) { - target->InsertEndChild(node->DeepClone(target)); - } -} - -XMLElement* XMLDocument::NewElement( const char* name ) -{ - XMLElement* ele = CreateUnlinkedNode( _elementPool ); - ele->SetName( name ); - return ele; -} - - -XMLComment* XMLDocument::NewComment( const char* str ) -{ - XMLComment* comment = CreateUnlinkedNode( _commentPool ); - comment->SetValue( str ); - return comment; -} - - -XMLText* XMLDocument::NewText( const char* str ) -{ - XMLText* text = CreateUnlinkedNode( _textPool ); - text->SetValue( str ); - return text; -} - - -XMLDeclaration* XMLDocument::NewDeclaration( const char* str ) -{ - XMLDeclaration* dec = CreateUnlinkedNode( _commentPool ); - dec->SetValue( str ? str : "xml version=\"1.0\" encoding=\"UTF-8\"" ); - return dec; -} - - -XMLUnknown* XMLDocument::NewUnknown( const char* str ) -{ - XMLUnknown* unk = CreateUnlinkedNode( _commentPool ); - unk->SetValue( str ); - return unk; -} - -static FILE* callfopen( const char* filepath, const char* mode ) -{ - TIXMLASSERT( filepath ); - TIXMLASSERT( mode ); -#if defined(_MSC_VER) && (_MSC_VER >= 1400 ) && (!defined WINCE) - FILE* fp = 0; - errno_t err = fopen_s( &fp, filepath, mode ); - if ( err ) { - return 0; - } -#else - FILE* fp = fopen( filepath, mode ); -#endif - return fp; -} - -void XMLDocument::DeleteNode( XMLNode* node ) { - TIXMLASSERT( node ); - TIXMLASSERT(node->_document == this ); - if (node->_parent) { - node->_parent->DeleteChild( node ); - } - else { - // Isn't in the tree. - // Use the parent delete. - // Also, we need to mark it tracked: we 'know' - // it was never used. - node->_memPool->SetTracked(); - // Call the static XMLNode version: - XMLNode::DeleteNode(node); - } -} - - -XMLError XMLDocument::LoadFile( const char* filename ) -{ - if ( !filename ) { - TIXMLASSERT( false ); - SetError( XML_ERROR_FILE_COULD_NOT_BE_OPENED, 0, "filename=" ); - return _errorID; - } - - Clear(); - FILE* fp = callfopen( filename, "rb" ); - if ( !fp ) { - SetError( XML_ERROR_FILE_NOT_FOUND, 0, "filename=%s", filename ); - return _errorID; - } - LoadFile( fp ); - fclose( fp ); - return _errorID; -} - -// This is likely overengineered template art to have a check that unsigned long value incremented -// by one still fits into size_t. If size_t type is larger than unsigned long type -// (x86_64-w64-mingw32 target) then the check is redundant and gcc and clang emit -// -Wtype-limits warning. This piece makes the compiler select code with a check when a check -// is useful and code with no check when a check is redundant depending on how size_t and unsigned long -// types sizes relate to each other. -template -= sizeof(size_t))> -struct LongFitsIntoSizeTMinusOne { - static bool Fits( unsigned long value ) - { - return value < (size_t)-1; - } -}; - -template <> -struct LongFitsIntoSizeTMinusOne { - static bool Fits( unsigned long ) - { - return true; - } -}; - -XMLError XMLDocument::LoadFile( FILE* fp ) -{ - Clear(); - - fseek( fp, 0, SEEK_SET ); - if ( fgetc( fp ) == EOF && ferror( fp ) != 0 ) { - SetError( XML_ERROR_FILE_READ_ERROR, 0, 0 ); - return _errorID; - } - - fseek( fp, 0, SEEK_END ); - const long filelength = ftell( fp ); - fseek( fp, 0, SEEK_SET ); - if ( filelength == -1L ) { - SetError( XML_ERROR_FILE_READ_ERROR, 0, 0 ); - return _errorID; - } - TIXMLASSERT( filelength >= 0 ); - - if ( !LongFitsIntoSizeTMinusOne<>::Fits( filelength ) ) { - // Cannot handle files which won't fit in buffer together with null terminator - SetError( XML_ERROR_FILE_READ_ERROR, 0, 0 ); - return _errorID; - } - - if ( filelength == 0 ) { - SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 ); - return _errorID; - } - - const size_t size = filelength; - TIXMLASSERT( _charBuffer == 0 ); - _charBuffer = new char[size+1]; - size_t read = fread( _charBuffer, 1, size, fp ); - if ( read != size ) { - SetError( XML_ERROR_FILE_READ_ERROR, 0, 0 ); - return _errorID; - } - - _charBuffer[size] = 0; - - Parse(); - return _errorID; -} - - -XMLError XMLDocument::SaveFile( const char* filename, bool compact ) -{ - if ( !filename ) { - TIXMLASSERT( false ); - SetError( XML_ERROR_FILE_COULD_NOT_BE_OPENED, 0, "filename=" ); - return _errorID; - } - - FILE* fp = callfopen( filename, "w" ); - if ( !fp ) { - SetError( XML_ERROR_FILE_COULD_NOT_BE_OPENED, 0, "filename=%s", filename ); - return _errorID; - } - SaveFile(fp, compact); - fclose( fp ); - return _errorID; -} - - -XMLError XMLDocument::SaveFile( FILE* fp, bool compact ) -{ - // Clear any error from the last save, otherwise it will get reported - // for *this* call. - ClearError(); - XMLPrinter stream( fp, compact ); - Print( &stream ); - return _errorID; -} - - -XMLError XMLDocument::Parse( const char* p, size_t len ) -{ - Clear(); - - if ( len == 0 || !p || !*p ) { - SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 ); - return _errorID; - } - if ( len == (size_t)(-1) ) { - len = strlen( p ); - } - TIXMLASSERT( _charBuffer == 0 ); - _charBuffer = new char[ len+1 ]; - memcpy( _charBuffer, p, len ); - _charBuffer[len] = 0; - - Parse(); - if ( Error() ) { - // clean up now essentially dangling memory. - // and the parse fail can put objects in the - // pools that are dead and inaccessible. - DeleteChildren(); - _elementPool.Clear(); - _attributePool.Clear(); - _textPool.Clear(); - _commentPool.Clear(); - } - return _errorID; -} - - -void XMLDocument::Print( XMLPrinter* streamer ) const -{ - if ( streamer ) { - Accept( streamer ); - } - else { - XMLPrinter stdoutStreamer( stdout ); - Accept( &stdoutStreamer ); - } -} - - -void XMLDocument::SetError( XMLError error, int lineNum, const char* format, ... ) -{ - TIXMLASSERT( error >= 0 && error < XML_ERROR_COUNT ); - _errorID = error; - _errorLineNum = lineNum; - _errorStr.Reset(); - - size_t BUFFER_SIZE = 1000; - char* buffer = new char[BUFFER_SIZE]; - - TIXMLASSERT(sizeof(error) <= sizeof(int)); - TIXML_SNPRINTF(buffer, BUFFER_SIZE, "Error=%s ErrorID=%d (0x%x) Line number=%d", ErrorIDToName(error), int(error), int(error), lineNum); - - if (format) { - size_t len = strlen(buffer); - TIXML_SNPRINTF(buffer + len, BUFFER_SIZE - len, ": "); - len = strlen(buffer); - - va_list va; - va_start(va, format); - TIXML_VSNPRINTF(buffer + len, BUFFER_SIZE - len, format, va); - va_end(va); - } - _errorStr.SetStr(buffer); - delete[] buffer; -} - - -/*static*/ const char* XMLDocument::ErrorIDToName(XMLError errorID) -{ - TIXMLASSERT( errorID >= 0 && errorID < XML_ERROR_COUNT ); - const char* errorName = _errorNames[errorID]; - TIXMLASSERT( errorName && errorName[0] ); - return errorName; -} - -const char* XMLDocument::ErrorStr() const -{ - return _errorStr.Empty() ? "" : _errorStr.GetStr(); -} - - -void XMLDocument::PrintError() const -{ - printf("%s\n", ErrorStr()); -} - -const char* XMLDocument::ErrorName() const -{ - return ErrorIDToName(_errorID); -} - -void XMLDocument::Parse() -{ - TIXMLASSERT( NoChildren() ); // Clear() must have been called previously - TIXMLASSERT( _charBuffer ); - _parseCurLineNum = 1; - _parseLineNum = 1; - char* p = _charBuffer; - p = XMLUtil::SkipWhiteSpace( p, &_parseCurLineNum ); - p = const_cast( XMLUtil::ReadBOM( p, &_writeBOM ) ); - if ( !*p ) { - SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 ); - return; - } - ParseDeep(p, 0, &_parseCurLineNum ); -} - -void XMLDocument::PushDepth() -{ - _parsingDepth++; - if (_parsingDepth == TINYXML2_MAX_ELEMENT_DEPTH) { - SetError(XML_ELEMENT_DEPTH_EXCEEDED, _parseCurLineNum, "Element nesting is too deep." ); - } -} - -void XMLDocument::PopDepth() -{ - TIXMLASSERT(_parsingDepth > 0); - --_parsingDepth; -} - -XMLPrinter::XMLPrinter( FILE* file, bool compact, int depth ) : - _elementJustOpened( false ), - _stack(), - _firstElement( true ), - _fp( file ), - _depth( depth ), - _textDepth( -1 ), - _processEntities( true ), - _compactMode( compact ), - _buffer() -{ - for( int i=0; i'] = true; // not required, but consistency is nice - _buffer.Push( 0 ); -} - - -void XMLPrinter::Print( const char* format, ... ) -{ - va_list va; - va_start( va, format ); - - if ( _fp ) { - vfprintf( _fp, format, va ); - } - else { - const int len = TIXML_VSCPRINTF( format, va ); - // Close out and re-start the va-args - va_end( va ); - TIXMLASSERT( len >= 0 ); - va_start( va, format ); - TIXMLASSERT( _buffer.Size() > 0 && _buffer[_buffer.Size() - 1] == 0 ); - char* p = _buffer.PushArr( len ) - 1; // back up over the null terminator. - TIXML_VSNPRINTF( p, len+1, format, va ); - } - va_end( va ); -} - - -void XMLPrinter::Write( const char* data, size_t size ) -{ - if ( _fp ) { - fwrite ( data , sizeof(char), size, _fp); - } - else { - char* p = _buffer.PushArr( static_cast(size) ) - 1; // back up over the null terminator. - memcpy( p, data, size ); - p[size] = 0; - } -} - - -void XMLPrinter::Putc( char ch ) -{ - if ( _fp ) { - fputc ( ch, _fp); - } - else { - char* p = _buffer.PushArr( sizeof(char) ) - 1; // back up over the null terminator. - p[0] = ch; - p[1] = 0; - } -} - - -void XMLPrinter::PrintSpace( int depth ) -{ - for( int i=0; i 0 && *q < ENTITY_RANGE ) { - // Check for entities. If one is found, flush - // the stream up until the entity, write the - // entity, and keep looking. - if ( flag[(unsigned char)(*q)] ) { - while ( p < q ) { - const size_t delta = q - p; - const int toPrint = ( INT_MAX < delta ) ? INT_MAX : (int)delta; - Write( p, toPrint ); - p += toPrint; - } - bool entityPatternPrinted = false; - for( int i=0; i( bom ) ); - } - if ( writeDec ) { - PushDeclaration( "xml version=\"1.0\"" ); - } -} - - -void XMLPrinter::OpenElement( const char* name, bool compactMode ) -{ - SealElementIfJustOpened(); - _stack.Push( name ); - - if ( _textDepth < 0 && !_firstElement && !compactMode ) { - Putc( '\n' ); - } - if ( !compactMode ) { - PrintSpace( _depth ); - } - - Write ( "<" ); - Write ( name ); - - _elementJustOpened = true; - _firstElement = false; - ++_depth; -} - - -void XMLPrinter::PushAttribute( const char* name, const char* value ) -{ - TIXMLASSERT( _elementJustOpened ); - Putc ( ' ' ); - Write( name ); - Write( "=\"" ); - PrintString( value, false ); - Putc ( '\"' ); -} - - -void XMLPrinter::PushAttribute( const char* name, int v ) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr( v, buf, BUF_SIZE ); - PushAttribute( name, buf ); -} - - -void XMLPrinter::PushAttribute( const char* name, unsigned v ) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr( v, buf, BUF_SIZE ); - PushAttribute( name, buf ); -} - - -void XMLPrinter::PushAttribute(const char* name, int64_t v) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr(v, buf, BUF_SIZE); - PushAttribute(name, buf); -} - - -void XMLPrinter::PushAttribute( const char* name, bool v ) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr( v, buf, BUF_SIZE ); - PushAttribute( name, buf ); -} - - -void XMLPrinter::PushAttribute( const char* name, double v ) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr( v, buf, BUF_SIZE ); - PushAttribute( name, buf ); -} - - -void XMLPrinter::CloseElement( bool compactMode ) -{ - --_depth; - const char* name = _stack.Pop(); - - if ( _elementJustOpened ) { - Write( "/>" ); - } - else { - if ( _textDepth < 0 && !compactMode) { - Putc( '\n' ); - PrintSpace( _depth ); - } - Write ( "" ); - } - - if ( _textDepth == _depth ) { - _textDepth = -1; - } - if ( _depth == 0 && !compactMode) { - Putc( '\n' ); - } - _elementJustOpened = false; -} - - -void XMLPrinter::SealElementIfJustOpened() -{ - if ( !_elementJustOpened ) { - return; - } - _elementJustOpened = false; - Putc( '>' ); -} - - -void XMLPrinter::PushText( const char* text, bool cdata ) -{ - _textDepth = _depth-1; - - SealElementIfJustOpened(); - if ( cdata ) { - Write( "" ); - } - else { - PrintString( text, true ); - } -} - -void XMLPrinter::PushText( int64_t value ) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr( value, buf, BUF_SIZE ); - PushText( buf, false ); -} - -void XMLPrinter::PushText( int value ) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr( value, buf, BUF_SIZE ); - PushText( buf, false ); -} - - -void XMLPrinter::PushText( unsigned value ) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr( value, buf, BUF_SIZE ); - PushText( buf, false ); -} - - -void XMLPrinter::PushText( bool value ) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr( value, buf, BUF_SIZE ); - PushText( buf, false ); -} - - -void XMLPrinter::PushText( float value ) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr( value, buf, BUF_SIZE ); - PushText( buf, false ); -} - - -void XMLPrinter::PushText( double value ) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr( value, buf, BUF_SIZE ); - PushText( buf, false ); -} - - -void XMLPrinter::PushComment( const char* comment ) -{ - SealElementIfJustOpened(); - if ( _textDepth < 0 && !_firstElement && !_compactMode) { - Putc( '\n' ); - PrintSpace( _depth ); - } - _firstElement = false; - - Write( "" ); -} - - -void XMLPrinter::PushDeclaration( const char* value ) -{ - SealElementIfJustOpened(); - if ( _textDepth < 0 && !_firstElement && !_compactMode) { - Putc( '\n' ); - PrintSpace( _depth ); - } - _firstElement = false; - - Write( "" ); -} - - -void XMLPrinter::PushUnknown( const char* value ) -{ - SealElementIfJustOpened(); - if ( _textDepth < 0 && !_firstElement && !_compactMode) { - Putc( '\n' ); - PrintSpace( _depth ); - } - _firstElement = false; - - Write( "' ); -} - - -bool XMLPrinter::VisitEnter( const XMLDocument& doc ) -{ - _processEntities = doc.ProcessEntities(); - if ( doc.HasBOM() ) { - PushHeader( true, false ); - } - return true; -} - - -bool XMLPrinter::VisitEnter( const XMLElement& element, const XMLAttribute* attribute ) -{ - const XMLElement* parentElem = 0; - if ( element.Parent() ) { - parentElem = element.Parent()->ToElement(); - } - const bool compactMode = parentElem ? CompactMode( *parentElem ) : _compactMode; - OpenElement( element.Name(), compactMode ); - while ( attribute ) { - PushAttribute( attribute->Name(), attribute->Value() ); - attribute = attribute->Next(); - } - return true; -} - - -bool XMLPrinter::VisitExit( const XMLElement& element ) -{ - CloseElement( CompactMode(element) ); - return true; -} - - -bool XMLPrinter::Visit( const XMLText& text ) -{ - PushText( text.Value(), text.CData() ); - return true; -} - - -bool XMLPrinter::Visit( const XMLComment& comment ) -{ - PushComment( comment.Value() ); - return true; -} - -bool XMLPrinter::Visit( const XMLDeclaration& declaration ) -{ - PushDeclaration( declaration.Value() ); - return true; -} - - -bool XMLPrinter::Visit( const XMLUnknown& unknown ) -{ - PushUnknown( unknown.Value() ); - return true; -} - -} // namespace tinyxml2 diff --git a/ZAPDTR/lib/tinyxml2/tinyxml2.h b/ZAPDTR/lib/tinyxml2/tinyxml2.h deleted file mode 100644 index 7cd312736..000000000 --- a/ZAPDTR/lib/tinyxml2/tinyxml2.h +++ /dev/null @@ -1,2309 +0,0 @@ -/* -Original code by Lee Thomason (www.grinninglizard.com) - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any -damages arising from the use of this software. - -Permission is granted to anyone to use this software for any -purpose, including commercial applications, and to alter it and -redistribute it freely, subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must -not claim that you wrote the original software. If you use this -software in a product, an acknowledgment in the product documentation -would be appreciated but is not required. - -2. Altered source versions must be plainly marked as such, and -must not be misrepresented as being the original software. - -3. This notice may not be removed or altered from any source -distribution. -*/ - -#ifndef TINYXML2_INCLUDED -#define TINYXML2_INCLUDED - -#if defined(ANDROID_NDK) || defined(__BORLANDC__) || defined(__QNXNTO__) -# include -# include -# include -# include -# include -# if defined(__PS3__) -# include -# endif -#else -# include -# include -# include -# include -# include -#endif -#include - -/* - TODO: intern strings instead of allocation. -*/ -/* - gcc: - g++ -Wall -DTINYXML2_DEBUG tinyxml2.cpp xmltest.cpp -o gccxmltest.exe - - Formatting, Artistic Style: - AStyle.exe --style=1tbs --indent-switches --break-closing-brackets --indent-preprocessor tinyxml2.cpp tinyxml2.h -*/ - -#if defined( _DEBUG ) || defined (__DEBUG__) -# ifndef TINYXML2_DEBUG -# define TINYXML2_DEBUG -# endif -#endif - -#ifdef _MSC_VER -# pragma warning(push) -# pragma warning(disable: 4251) -#endif - -#ifdef _WIN32 -# ifdef TINYXML2_EXPORT -# define TINYXML2_LIB __declspec(dllexport) -# elif defined(TINYXML2_IMPORT) -# define TINYXML2_LIB __declspec(dllimport) -# else -# define TINYXML2_LIB -# endif -#elif __GNUC__ >= 4 -# define TINYXML2_LIB __attribute__((visibility("default"))) -#else -# define TINYXML2_LIB -#endif - - -#if defined(TINYXML2_DEBUG) -# if defined(_MSC_VER) -# // "(void)0," is for suppressing C4127 warning in "assert(false)", "assert(true)" and the like -# define TIXMLASSERT( x ) if ( !((void)0,(x))) { __debugbreak(); } -# elif defined (ANDROID_NDK) -# include -# define TIXMLASSERT( x ) if ( !(x)) { __android_log_assert( "assert", "grinliz", "ASSERT in '%s' at %d.", __FILE__, __LINE__ ); } -# else -# include -# define TIXMLASSERT assert -# endif -#else -# define TIXMLASSERT( x ) {} -#endif - - -/* Versioning, past 1.0.14: - http://semver.org/ -*/ -static const int TIXML2_MAJOR_VERSION = 7; -static const int TIXML2_MINOR_VERSION = 0; -static const int TIXML2_PATCH_VERSION = 1; - -#define TINYXML2_MAJOR_VERSION 7 -#define TINYXML2_MINOR_VERSION 0 -#define TINYXML2_PATCH_VERSION 1 - -// A fixed element depth limit is problematic. There needs to be a -// limit to avoid a stack overflow. However, that limit varies per -// system, and the capacity of the stack. On the other hand, it's a trivial -// attack that can result from ill, malicious, or even correctly formed XML, -// so there needs to be a limit in place. -static const int TINYXML2_MAX_ELEMENT_DEPTH = 100; - -namespace tinyxml2 -{ -class XMLDocument; -class XMLElement; -class XMLAttribute; -class XMLComment; -class XMLText; -class XMLDeclaration; -class XMLUnknown; -class XMLPrinter; - -/* - A class that wraps strings. Normally stores the start and end - pointers into the XML file itself, and will apply normalization - and entity translation if actually read. Can also store (and memory - manage) a traditional char[] - - Isn't clear why TINYXML2_LIB is needed; but seems to fix #719 -*/ -class TINYXML2_LIB StrPair -{ -public: - enum { - NEEDS_ENTITY_PROCESSING = 0x01, - NEEDS_NEWLINE_NORMALIZATION = 0x02, - NEEDS_WHITESPACE_COLLAPSING = 0x04, - - TEXT_ELEMENT = NEEDS_ENTITY_PROCESSING | NEEDS_NEWLINE_NORMALIZATION, - TEXT_ELEMENT_LEAVE_ENTITIES = NEEDS_NEWLINE_NORMALIZATION, - ATTRIBUTE_NAME = 0, - ATTRIBUTE_VALUE = NEEDS_ENTITY_PROCESSING | NEEDS_NEWLINE_NORMALIZATION, - ATTRIBUTE_VALUE_LEAVE_ENTITIES = NEEDS_NEWLINE_NORMALIZATION, - COMMENT = NEEDS_NEWLINE_NORMALIZATION - }; - - StrPair() : _flags( 0 ), _start( 0 ), _end( 0 ) {} - ~StrPair(); - - void Set( char* start, char* end, int flags ) { - TIXMLASSERT( start ); - TIXMLASSERT( end ); - Reset(); - _start = start; - _end = end; - _flags = flags | NEEDS_FLUSH; - } - - const char* GetStr(); - - bool Empty() const { - return _start == _end; - } - - void SetInternedStr( const char* str ) { - Reset(); - _start = const_cast(str); - } - - void SetStr( const char* str, int flags=0 ); - - char* ParseText( char* in, const char* endTag, int strFlags, int* curLineNumPtr ); - char* ParseName( char* in ); - - void TransferTo( StrPair* other ); - void Reset(); - -private: - void CollapseWhitespace(); - - enum { - NEEDS_FLUSH = 0x100, - NEEDS_DELETE = 0x200 - }; - - int _flags; - char* _start; - char* _end; - - StrPair( const StrPair& other ); // not supported - void operator=( const StrPair& other ); // not supported, use TransferTo() -}; - - -/* - A dynamic array of Plain Old Data. Doesn't support constructors, etc. - Has a small initial memory pool, so that low or no usage will not - cause a call to new/delete -*/ -template -class DynArray -{ -public: - DynArray() : - _mem( _pool ), - _allocated( INITIAL_SIZE ), - _size( 0 ) - { - } - - ~DynArray() { - if ( _mem != _pool ) { - delete [] _mem; - } - } - - void Clear() { - _size = 0; - } - - void Push( T t ) { - TIXMLASSERT( _size < INT_MAX ); - EnsureCapacity( _size+1 ); - _mem[_size] = t; - ++_size; - } - - T* PushArr( int count ) { - TIXMLASSERT( count >= 0 ); - TIXMLASSERT( _size <= INT_MAX - count ); - EnsureCapacity( _size+count ); - T* ret = &_mem[_size]; - _size += count; - return ret; - } - - T Pop() { - TIXMLASSERT( _size > 0 ); - --_size; - return _mem[_size]; - } - - void PopArr( int count ) { - TIXMLASSERT( _size >= count ); - _size -= count; - } - - bool Empty() const { - return _size == 0; - } - - T& operator[](int i) { - TIXMLASSERT( i>= 0 && i < _size ); - return _mem[i]; - } - - const T& operator[](int i) const { - TIXMLASSERT( i>= 0 && i < _size ); - return _mem[i]; - } - - const T& PeekTop() const { - TIXMLASSERT( _size > 0 ); - return _mem[ _size - 1]; - } - - int Size() const { - TIXMLASSERT( _size >= 0 ); - return _size; - } - - int Capacity() const { - TIXMLASSERT( _allocated >= INITIAL_SIZE ); - return _allocated; - } - - void SwapRemove(int i) { - TIXMLASSERT(i >= 0 && i < _size); - TIXMLASSERT(_size > 0); - _mem[i] = _mem[_size - 1]; - --_size; - } - - const T* Mem() const { - TIXMLASSERT( _mem ); - return _mem; - } - - T* Mem() { - TIXMLASSERT( _mem ); - return _mem; - } - -private: - DynArray( const DynArray& ); // not supported - void operator=( const DynArray& ); // not supported - - void EnsureCapacity( int cap ) { - TIXMLASSERT( cap > 0 ); - if ( cap > _allocated ) { - TIXMLASSERT( cap <= INT_MAX / 2 ); - int newAllocated = cap * 2; - T* newMem = new T[newAllocated]; - TIXMLASSERT( newAllocated >= _size ); - memcpy( newMem, _mem, sizeof(T)*_size ); // warning: not using constructors, only works for PODs - if ( _mem != _pool ) { - delete [] _mem; - } - _mem = newMem; - _allocated = newAllocated; - } - } - - T* _mem; - T _pool[INITIAL_SIZE]; - int _allocated; // objects allocated - int _size; // number objects in use -}; - - -/* - Parent virtual class of a pool for fast allocation - and deallocation of objects. -*/ -class MemPool -{ -public: - MemPool() {} - virtual ~MemPool() {} - - virtual int ItemSize() const = 0; - virtual void* Alloc() = 0; - virtual void Free( void* ) = 0; - virtual void SetTracked() = 0; -}; - - -/* - Template child class to create pools of the correct type. -*/ -template< int ITEM_SIZE > -class MemPoolT : public MemPool -{ -public: - MemPoolT() : _blockPtrs(), _root(0), _currentAllocs(0), _nAllocs(0), _maxAllocs(0), _nUntracked(0) {} - ~MemPoolT() { - MemPoolT< ITEM_SIZE >::Clear(); - } - - void Clear() { - // Delete the blocks. - while( !_blockPtrs.Empty()) { - Block* lastBlock = _blockPtrs.Pop(); - delete lastBlock; - } - _root = 0; - _currentAllocs = 0; - _nAllocs = 0; - _maxAllocs = 0; - _nUntracked = 0; - } - - virtual int ItemSize() const { - return ITEM_SIZE; - } - int CurrentAllocs() const { - return _currentAllocs; - } - - virtual void* Alloc() { - if ( !_root ) { - // Need a new block. - Block* block = new Block(); - _blockPtrs.Push( block ); - - Item* blockItems = block->items; - for( int i = 0; i < ITEMS_PER_BLOCK - 1; ++i ) { - blockItems[i].next = &(blockItems[i + 1]); - } - blockItems[ITEMS_PER_BLOCK - 1].next = 0; - _root = blockItems; - } - Item* const result = _root; - TIXMLASSERT( result != 0 ); - _root = _root->next; - - ++_currentAllocs; - if ( _currentAllocs > _maxAllocs ) { - _maxAllocs = _currentAllocs; - } - ++_nAllocs; - ++_nUntracked; - return result; - } - - virtual void Free( void* mem ) { - if ( !mem ) { - return; - } - --_currentAllocs; - Item* item = static_cast( mem ); -#ifdef TINYXML2_DEBUG - memset( item, 0xfe, sizeof( *item ) ); -#endif - item->next = _root; - _root = item; - } - void Trace( const char* name ) { - printf( "Mempool %s watermark=%d [%dk] current=%d size=%d nAlloc=%d blocks=%d\n", - name, _maxAllocs, _maxAllocs * ITEM_SIZE / 1024, _currentAllocs, - ITEM_SIZE, _nAllocs, _blockPtrs.Size() ); - } - - void SetTracked() { - --_nUntracked; - } - - int Untracked() const { - return _nUntracked; - } - - // This number is perf sensitive. 4k seems like a good tradeoff on my machine. - // The test file is large, 170k. - // Release: VS2010 gcc(no opt) - // 1k: 4000 - // 2k: 4000 - // 4k: 3900 21000 - // 16k: 5200 - // 32k: 4300 - // 64k: 4000 21000 - // Declared public because some compilers do not accept to use ITEMS_PER_BLOCK - // in private part if ITEMS_PER_BLOCK is private - enum { ITEMS_PER_BLOCK = (4 * 1024) / ITEM_SIZE }; - -private: - MemPoolT( const MemPoolT& ); // not supported - void operator=( const MemPoolT& ); // not supported - - union Item { - Item* next; - char itemData[ITEM_SIZE]; - }; - struct Block { - Item items[ITEMS_PER_BLOCK]; - }; - DynArray< Block*, 10 > _blockPtrs; - Item* _root; - - int _currentAllocs; - int _nAllocs; - int _maxAllocs; - int _nUntracked; -}; - - - -/** - Implements the interface to the "Visitor pattern" (see the Accept() method.) - If you call the Accept() method, it requires being passed a XMLVisitor - class to handle callbacks. For nodes that contain other nodes (Document, Element) - you will get called with a VisitEnter/VisitExit pair. Nodes that are always leafs - are simply called with Visit(). - - If you return 'true' from a Visit method, recursive parsing will continue. If you return - false, no children of this node or its siblings will be visited. - - All flavors of Visit methods have a default implementation that returns 'true' (continue - visiting). You need to only override methods that are interesting to you. - - Generally Accept() is called on the XMLDocument, although all nodes support visiting. - - You should never change the document from a callback. - - @sa XMLNode::Accept() -*/ -class TINYXML2_LIB XMLVisitor -{ -public: - virtual ~XMLVisitor() {} - - /// Visit a document. - virtual bool VisitEnter( const XMLDocument& /*doc*/ ) { - return true; - } - /// Visit a document. - virtual bool VisitExit( const XMLDocument& /*doc*/ ) { - return true; - } - - /// Visit an element. - virtual bool VisitEnter( const XMLElement& /*element*/, const XMLAttribute* /*firstAttribute*/ ) { - return true; - } - /// Visit an element. - virtual bool VisitExit( const XMLElement& /*element*/ ) { - return true; - } - - /// Visit a declaration. - virtual bool Visit( const XMLDeclaration& /*declaration*/ ) { - return true; - } - /// Visit a text node. - virtual bool Visit( const XMLText& /*text*/ ) { - return true; - } - /// Visit a comment node. - virtual bool Visit( const XMLComment& /*comment*/ ) { - return true; - } - /// Visit an unknown node. - virtual bool Visit( const XMLUnknown& /*unknown*/ ) { - return true; - } -}; - -// WARNING: must match XMLDocument::_errorNames[] -enum XMLError { - XML_SUCCESS = 0, - XML_NO_ATTRIBUTE, - XML_WRONG_ATTRIBUTE_TYPE, - XML_ERROR_FILE_NOT_FOUND, - XML_ERROR_FILE_COULD_NOT_BE_OPENED, - XML_ERROR_FILE_READ_ERROR, - XML_ERROR_PARSING_ELEMENT, - XML_ERROR_PARSING_ATTRIBUTE, - XML_ERROR_PARSING_TEXT, - XML_ERROR_PARSING_CDATA, - XML_ERROR_PARSING_COMMENT, - XML_ERROR_PARSING_DECLARATION, - XML_ERROR_PARSING_UNKNOWN, - XML_ERROR_EMPTY_DOCUMENT, - XML_ERROR_MISMATCHED_ELEMENT, - XML_ERROR_PARSING, - XML_CAN_NOT_CONVERT_TEXT, - XML_NO_TEXT_NODE, - XML_ELEMENT_DEPTH_EXCEEDED, - - XML_ERROR_COUNT -}; - - -/* - Utility functionality. -*/ -class TINYXML2_LIB XMLUtil -{ -public: - static const char* SkipWhiteSpace( const char* p, int* curLineNumPtr ) { - TIXMLASSERT( p ); - - while( IsWhiteSpace(*p) ) { - if (curLineNumPtr && *p == '\n') { - ++(*curLineNumPtr); - } - ++p; - } - TIXMLASSERT( p ); - return p; - } - static char* SkipWhiteSpace( char* p, int* curLineNumPtr ) { - return const_cast( SkipWhiteSpace( const_cast(p), curLineNumPtr ) ); - } - - // Anything in the high order range of UTF-8 is assumed to not be whitespace. This isn't - // correct, but simple, and usually works. - static bool IsWhiteSpace( char p ) { - return !IsUTF8Continuation(p) && isspace( static_cast(p) ); - } - - inline static bool IsNameStartChar( unsigned char ch ) { - if ( ch >= 128 ) { - // This is a heuristic guess in attempt to not implement Unicode-aware isalpha() - return true; - } - if ( isalpha( ch ) ) { - return true; - } - return ch == ':' || ch == '_'; - } - - inline static bool IsNameChar( unsigned char ch ) { - return IsNameStartChar( ch ) - || isdigit( ch ) - || ch == '.' - || ch == '-'; - } - - inline static bool StringEqual( const char* p, const char* q, int nChar=INT_MAX ) { - if ( p == q ) { - return true; - } - TIXMLASSERT( p ); - TIXMLASSERT( q ); - TIXMLASSERT( nChar >= 0 ); - return strncmp( p, q, nChar ) == 0; - } - - inline static bool IsUTF8Continuation( char p ) { - return ( p & 0x80 ) != 0; - } - - static const char* ReadBOM( const char* p, bool* hasBOM ); - // p is the starting location, - // the UTF-8 value of the entity will be placed in value, and length filled in. - static const char* GetCharacterRef( const char* p, char* value, int* length ); - static void ConvertUTF32ToUTF8( unsigned long input, char* output, int* length ); - - // converts primitive types to strings - static void ToStr( int v, char* buffer, int bufferSize ); - static void ToStr( unsigned v, char* buffer, int bufferSize ); - static void ToStr( bool v, char* buffer, int bufferSize ); - static void ToStr( float v, char* buffer, int bufferSize ); - static void ToStr( double v, char* buffer, int bufferSize ); - static void ToStr(int64_t v, char* buffer, int bufferSize); - - // converts strings to primitive types - static bool ToInt( const char* str, int* value ); - static bool ToUnsigned( const char* str, unsigned* value ); - static bool ToBool( const char* str, bool* value ); - static bool ToFloat( const char* str, float* value ); - static bool ToDouble( const char* str, double* value ); - static bool ToInt64(const char* str, int64_t* value); - - // Changes what is serialized for a boolean value. - // Default to "true" and "false". Shouldn't be changed - // unless you have a special testing or compatibility need. - // Be careful: static, global, & not thread safe. - // Be sure to set static const memory as parameters. - static void SetBoolSerialization(const char* writeTrue, const char* writeFalse); - -private: - static const char* writeBoolTrue; - static const char* writeBoolFalse; -}; - - -/** XMLNode is a base class for every object that is in the - XML Document Object Model (DOM), except XMLAttributes. - Nodes have siblings, a parent, and children which can - be navigated. A node is always in a XMLDocument. - The type of a XMLNode can be queried, and it can - be cast to its more defined type. - - A XMLDocument allocates memory for all its Nodes. - When the XMLDocument gets deleted, all its Nodes - will also be deleted. - - @verbatim - A Document can contain: Element (container or leaf) - Comment (leaf) - Unknown (leaf) - Declaration( leaf ) - - An Element can contain: Element (container or leaf) - Text (leaf) - Attributes (not on tree) - Comment (leaf) - Unknown (leaf) - - @endverbatim -*/ -class TINYXML2_LIB XMLNode -{ - friend class XMLDocument; - friend class XMLElement; -public: - - /// Get the XMLDocument that owns this XMLNode. - const XMLDocument* GetDocument() const { - TIXMLASSERT( _document ); - return _document; - } - /// Get the XMLDocument that owns this XMLNode. - XMLDocument* GetDocument() { - TIXMLASSERT( _document ); - return _document; - } - - /// Safely cast to an Element, or null. - virtual XMLElement* ToElement() { - return 0; - } - /// Safely cast to Text, or null. - virtual XMLText* ToText() { - return 0; - } - /// Safely cast to a Comment, or null. - virtual XMLComment* ToComment() { - return 0; - } - /// Safely cast to a Document, or null. - virtual XMLDocument* ToDocument() { - return 0; - } - /// Safely cast to a Declaration, or null. - virtual XMLDeclaration* ToDeclaration() { - return 0; - } - /// Safely cast to an Unknown, or null. - virtual XMLUnknown* ToUnknown() { - return 0; - } - - virtual const XMLElement* ToElement() const { - return 0; - } - virtual const XMLText* ToText() const { - return 0; - } - virtual const XMLComment* ToComment() const { - return 0; - } - virtual const XMLDocument* ToDocument() const { - return 0; - } - virtual const XMLDeclaration* ToDeclaration() const { - return 0; - } - virtual const XMLUnknown* ToUnknown() const { - return 0; - } - - /** The meaning of 'value' changes for the specific type. - @verbatim - Document: empty (NULL is returned, not an empty string) - Element: name of the element - Comment: the comment text - Unknown: the tag contents - Text: the text string - @endverbatim - */ - const char* Value() const; - - /** Set the Value of an XML node. - @sa Value() - */ - void SetValue( const char* val, bool staticMem=false ); - - /// Gets the line number the node is in, if the document was parsed from a file. - int GetLineNum() const { return _parseLineNum; } - - /// Get the parent of this node on the DOM. - const XMLNode* Parent() const { - return _parent; - } - - XMLNode* Parent() { - return _parent; - } - - /// Returns true if this node has no children. - bool NoChildren() const { - return !_firstChild; - } - - /// Get the first child node, or null if none exists. - const XMLNode* FirstChild() const { - return _firstChild; - } - - XMLNode* FirstChild() { - return _firstChild; - } - - /** Get the first child element, or optionally the first child - element with the specified name. - */ - const XMLElement* FirstChildElement( const char* name = 0 ) const; - - XMLElement* FirstChildElement( const char* name = 0 ) { - return const_cast(const_cast(this)->FirstChildElement( name )); - } - - /// Get the last child node, or null if none exists. - const XMLNode* LastChild() const { - return _lastChild; - } - - XMLNode* LastChild() { - return _lastChild; - } - - /** Get the last child element or optionally the last child - element with the specified name. - */ - const XMLElement* LastChildElement( const char* name = 0 ) const; - - XMLElement* LastChildElement( const char* name = 0 ) { - return const_cast(const_cast(this)->LastChildElement(name) ); - } - - /// Get the previous (left) sibling node of this node. - const XMLNode* PreviousSibling() const { - return _prev; - } - - XMLNode* PreviousSibling() { - return _prev; - } - - /// Get the previous (left) sibling element of this node, with an optionally supplied name. - const XMLElement* PreviousSiblingElement( const char* name = 0 ) const ; - - XMLElement* PreviousSiblingElement( const char* name = 0 ) { - return const_cast(const_cast(this)->PreviousSiblingElement( name ) ); - } - - /// Get the next (right) sibling node of this node. - const XMLNode* NextSibling() const { - return _next; - } - - XMLNode* NextSibling() { - return _next; - } - - /// Get the next (right) sibling element of this node, with an optionally supplied name. - const XMLElement* NextSiblingElement( const char* name = 0 ) const; - - XMLElement* NextSiblingElement( const char* name = 0 ) { - return const_cast(const_cast(this)->NextSiblingElement( name ) ); - } - - /** - Add a child node as the last (right) child. - If the child node is already part of the document, - it is moved from its old location to the new location. - Returns the addThis argument or 0 if the node does not - belong to the same document. - */ - XMLNode* InsertEndChild( XMLNode* addThis ); - - XMLNode* LinkEndChild( XMLNode* addThis ) { - return InsertEndChild( addThis ); - } - /** - Add a child node as the first (left) child. - If the child node is already part of the document, - it is moved from its old location to the new location. - Returns the addThis argument or 0 if the node does not - belong to the same document. - */ - XMLNode* InsertFirstChild( XMLNode* addThis ); - /** - Add a node after the specified child node. - If the child node is already part of the document, - it is moved from its old location to the new location. - Returns the addThis argument or 0 if the afterThis node - is not a child of this node, or if the node does not - belong to the same document. - */ - XMLNode* InsertAfterChild( XMLNode* afterThis, XMLNode* addThis ); - - /** - Delete all the children of this node. - */ - void DeleteChildren(); - - /** - Delete a child of this node. - */ - void DeleteChild( XMLNode* node ); - - /** - Make a copy of this node, but not its children. - You may pass in a Document pointer that will be - the owner of the new Node. If the 'document' is - null, then the node returned will be allocated - from the current Document. (this->GetDocument()) - - Note: if called on a XMLDocument, this will return null. - */ - virtual XMLNode* ShallowClone( XMLDocument* document ) const = 0; - - /** - Make a copy of this node and all its children. - - If the 'target' is null, then the nodes will - be allocated in the current document. If 'target' - is specified, the memory will be allocated is the - specified XMLDocument. - - NOTE: This is probably not the correct tool to - copy a document, since XMLDocuments can have multiple - top level XMLNodes. You probably want to use - XMLDocument::DeepCopy() - */ - XMLNode* DeepClone( XMLDocument* target ) const; - - /** - Test if 2 nodes are the same, but don't test children. - The 2 nodes do not need to be in the same Document. - - Note: if called on a XMLDocument, this will return false. - */ - virtual bool ShallowEqual( const XMLNode* compare ) const = 0; - - /** Accept a hierarchical visit of the nodes in the TinyXML-2 DOM. Every node in the - XML tree will be conditionally visited and the host will be called back - via the XMLVisitor interface. - - This is essentially a SAX interface for TinyXML-2. (Note however it doesn't re-parse - the XML for the callbacks, so the performance of TinyXML-2 is unchanged by using this - interface versus any other.) - - The interface has been based on ideas from: - - - http://www.saxproject.org/ - - http://c2.com/cgi/wiki?HierarchicalVisitorPattern - - Which are both good references for "visiting". - - An example of using Accept(): - @verbatim - XMLPrinter printer; - tinyxmlDoc.Accept( &printer ); - const char* xmlcstr = printer.CStr(); - @endverbatim - */ - virtual bool Accept( XMLVisitor* visitor ) const = 0; - - /** - Set user data into the XMLNode. TinyXML-2 in - no way processes or interprets user data. - It is initially 0. - */ - void SetUserData(void* userData) { _userData = userData; } - - /** - Get user data set into the XMLNode. TinyXML-2 in - no way processes or interprets user data. - It is initially 0. - */ - void* GetUserData() const { return _userData; } - -protected: - explicit XMLNode( XMLDocument* ); - virtual ~XMLNode(); - - virtual char* ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr); - - XMLDocument* _document; - XMLNode* _parent; - mutable StrPair _value; - int _parseLineNum; - - XMLNode* _firstChild; - XMLNode* _lastChild; - - XMLNode* _prev; - XMLNode* _next; - - void* _userData; - -private: - MemPool* _memPool; - void Unlink( XMLNode* child ); - static void DeleteNode( XMLNode* node ); - void InsertChildPreamble( XMLNode* insertThis ) const; - const XMLElement* ToElementWithName( const char* name ) const; - - XMLNode( const XMLNode& ); // not supported - XMLNode& operator=( const XMLNode& ); // not supported -}; - - -/** XML text. - - Note that a text node can have child element nodes, for example: - @verbatim - This is bold - @endverbatim - - A text node can have 2 ways to output the next. "normal" output - and CDATA. It will default to the mode it was parsed from the XML file and - you generally want to leave it alone, but you can change the output mode with - SetCData() and query it with CData(). -*/ -class TINYXML2_LIB XMLText : public XMLNode -{ - friend class XMLDocument; -public: - virtual bool Accept( XMLVisitor* visitor ) const; - - virtual XMLText* ToText() { - return this; - } - virtual const XMLText* ToText() const { - return this; - } - - /// Declare whether this should be CDATA or standard text. - void SetCData( bool isCData ) { - _isCData = isCData; - } - /// Returns true if this is a CDATA text element. - bool CData() const { - return _isCData; - } - - virtual XMLNode* ShallowClone( XMLDocument* document ) const; - virtual bool ShallowEqual( const XMLNode* compare ) const; - -protected: - explicit XMLText( XMLDocument* doc ) : XMLNode( doc ), _isCData( false ) {} - virtual ~XMLText() {} - - char* ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr ); - -private: - bool _isCData; - - XMLText( const XMLText& ); // not supported - XMLText& operator=( const XMLText& ); // not supported -}; - - -/** An XML Comment. */ -class TINYXML2_LIB XMLComment : public XMLNode -{ - friend class XMLDocument; -public: - virtual XMLComment* ToComment() { - return this; - } - virtual const XMLComment* ToComment() const { - return this; - } - - virtual bool Accept( XMLVisitor* visitor ) const; - - virtual XMLNode* ShallowClone( XMLDocument* document ) const; - virtual bool ShallowEqual( const XMLNode* compare ) const; - -protected: - explicit XMLComment( XMLDocument* doc ); - virtual ~XMLComment(); - - char* ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr); - -private: - XMLComment( const XMLComment& ); // not supported - XMLComment& operator=( const XMLComment& ); // not supported -}; - - -/** In correct XML the declaration is the first entry in the file. - @verbatim - - @endverbatim - - TinyXML-2 will happily read or write files without a declaration, - however. - - The text of the declaration isn't interpreted. It is parsed - and written as a string. -*/ -class TINYXML2_LIB XMLDeclaration : public XMLNode -{ - friend class XMLDocument; -public: - virtual XMLDeclaration* ToDeclaration() { - return this; - } - virtual const XMLDeclaration* ToDeclaration() const { - return this; - } - - virtual bool Accept( XMLVisitor* visitor ) const; - - virtual XMLNode* ShallowClone( XMLDocument* document ) const; - virtual bool ShallowEqual( const XMLNode* compare ) const; - -protected: - explicit XMLDeclaration( XMLDocument* doc ); - virtual ~XMLDeclaration(); - - char* ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr ); - -private: - XMLDeclaration( const XMLDeclaration& ); // not supported - XMLDeclaration& operator=( const XMLDeclaration& ); // not supported -}; - - -/** Any tag that TinyXML-2 doesn't recognize is saved as an - unknown. It is a tag of text, but should not be modified. - It will be written back to the XML, unchanged, when the file - is saved. - - DTD tags get thrown into XMLUnknowns. -*/ -class TINYXML2_LIB XMLUnknown : public XMLNode -{ - friend class XMLDocument; -public: - virtual XMLUnknown* ToUnknown() { - return this; - } - virtual const XMLUnknown* ToUnknown() const { - return this; - } - - virtual bool Accept( XMLVisitor* visitor ) const; - - virtual XMLNode* ShallowClone( XMLDocument* document ) const; - virtual bool ShallowEqual( const XMLNode* compare ) const; - -protected: - explicit XMLUnknown( XMLDocument* doc ); - virtual ~XMLUnknown(); - - char* ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr ); - -private: - XMLUnknown( const XMLUnknown& ); // not supported - XMLUnknown& operator=( const XMLUnknown& ); // not supported -}; - - - -/** An attribute is a name-value pair. Elements have an arbitrary - number of attributes, each with a unique name. - - @note The attributes are not XMLNodes. You may only query the - Next() attribute in a list. -*/ -class TINYXML2_LIB XMLAttribute -{ - friend class XMLElement; -public: - /// The name of the attribute. - const char* Name() const; - - /// The value of the attribute. - const char* Value() const; - - /// Gets the line number the attribute is in, if the document was parsed from a file. - int GetLineNum() const { return _parseLineNum; } - - /// The next attribute in the list. - const XMLAttribute* Next() const { - return _next; - } - - /** IntValue interprets the attribute as an integer, and returns the value. - If the value isn't an integer, 0 will be returned. There is no error checking; - use QueryIntValue() if you need error checking. - */ - int IntValue() const { - int i = 0; - QueryIntValue(&i); - return i; - } - - int64_t Int64Value() const { - int64_t i = 0; - QueryInt64Value(&i); - return i; - } - - /// Query as an unsigned integer. See IntValue() - unsigned UnsignedValue() const { - unsigned i=0; - QueryUnsignedValue( &i ); - return i; - } - /// Query as a boolean. See IntValue() - bool BoolValue() const { - bool b=false; - QueryBoolValue( &b ); - return b; - } - /// Query as a double. See IntValue() - double DoubleValue() const { - double d=0; - QueryDoubleValue( &d ); - return d; - } - /// Query as a float. See IntValue() - float FloatValue() const { - float f=0; - QueryFloatValue( &f ); - return f; - } - - /** QueryIntValue interprets the attribute as an integer, and returns the value - in the provided parameter. The function will return XML_SUCCESS on success, - and XML_WRONG_ATTRIBUTE_TYPE if the conversion is not successful. - */ - XMLError QueryIntValue( int* value ) const; - /// See QueryIntValue - XMLError QueryUnsignedValue( unsigned int* value ) const; - /// See QueryIntValue - XMLError QueryInt64Value(int64_t* value) const; - /// See QueryIntValue - XMLError QueryBoolValue( bool* value ) const; - /// See QueryIntValue - XMLError QueryDoubleValue( double* value ) const; - /// See QueryIntValue - XMLError QueryFloatValue( float* value ) const; - - /// Set the attribute to a string value. - void SetAttribute( const char* value ); - /// Set the attribute to value. - void SetAttribute( int value ); - /// Set the attribute to value. - void SetAttribute( unsigned value ); - /// Set the attribute to value. - void SetAttribute(int64_t value); - /// Set the attribute to value. - void SetAttribute( bool value ); - /// Set the attribute to value. - void SetAttribute( double value ); - /// Set the attribute to value. - void SetAttribute( float value ); - -private: - enum { BUF_SIZE = 200 }; - - XMLAttribute() : _name(), _value(),_parseLineNum( 0 ), _next( 0 ), _memPool( 0 ) {} - virtual ~XMLAttribute() {} - - XMLAttribute( const XMLAttribute& ); // not supported - void operator=( const XMLAttribute& ); // not supported - void SetName( const char* name ); - - char* ParseDeep( char* p, bool processEntities, int* curLineNumPtr ); - - mutable StrPair _name; - mutable StrPair _value; - int _parseLineNum; - XMLAttribute* _next; - MemPool* _memPool; -}; - - -/** The element is a container class. It has a value, the element name, - and can contain other elements, text, comments, and unknowns. - Elements also contain an arbitrary number of attributes. -*/ -class TINYXML2_LIB XMLElement : public XMLNode -{ - friend class XMLDocument; -public: - /// Get the name of an element (which is the Value() of the node.) - const char* Name() const { - return Value(); - } - /// Set the name of the element. - void SetName( const char* str, bool staticMem=false ) { - SetValue( str, staticMem ); - } - - virtual XMLElement* ToElement() { - return this; - } - virtual const XMLElement* ToElement() const { - return this; - } - virtual bool Accept( XMLVisitor* visitor ) const; - - /** Given an attribute name, Attribute() returns the value - for the attribute of that name, or null if none - exists. For example: - - @verbatim - const char* value = ele->Attribute( "foo" ); - @endverbatim - - The 'value' parameter is normally null. However, if specified, - the attribute will only be returned if the 'name' and 'value' - match. This allow you to write code: - - @verbatim - if ( ele->Attribute( "foo", "bar" ) ) callFooIsBar(); - @endverbatim - - rather than: - @verbatim - if ( ele->Attribute( "foo" ) ) { - if ( strcmp( ele->Attribute( "foo" ), "bar" ) == 0 ) callFooIsBar(); - } - @endverbatim - */ - const char* Attribute( const char* name, const char* value=0 ) const; - - /** Given an attribute name, IntAttribute() returns the value - of the attribute interpreted as an integer. The default - value will be returned if the attribute isn't present, - or if there is an error. (For a method with error - checking, see QueryIntAttribute()). - */ - int IntAttribute(const char* name, int defaultValue = 0) const; - /// See IntAttribute() - unsigned UnsignedAttribute(const char* name, unsigned defaultValue = 0) const; - /// See IntAttribute() - int64_t Int64Attribute(const char* name, int64_t defaultValue = 0) const; - /// See IntAttribute() - bool BoolAttribute(const char* name, bool defaultValue = false) const; - /// See IntAttribute() - double DoubleAttribute(const char* name, double defaultValue = 0) const; - /// See IntAttribute() - float FloatAttribute(const char* name, float defaultValue = 0) const; - - /** Given an attribute name, QueryIntAttribute() returns - XML_SUCCESS, XML_WRONG_ATTRIBUTE_TYPE if the conversion - can't be performed, or XML_NO_ATTRIBUTE if the attribute - doesn't exist. If successful, the result of the conversion - will be written to 'value'. If not successful, nothing will - be written to 'value'. This allows you to provide default - value: - - @verbatim - int value = 10; - QueryIntAttribute( "foo", &value ); // if "foo" isn't found, value will still be 10 - @endverbatim - */ - XMLError QueryIntAttribute( const char* name, int* value ) const { - const XMLAttribute* a = FindAttribute( name ); - if ( !a ) { - return XML_NO_ATTRIBUTE; - } - return a->QueryIntValue( value ); - } - - /// See QueryIntAttribute() - XMLError QueryUnsignedAttribute( const char* name, unsigned int* value ) const { - const XMLAttribute* a = FindAttribute( name ); - if ( !a ) { - return XML_NO_ATTRIBUTE; - } - return a->QueryUnsignedValue( value ); - } - - /// See QueryIntAttribute() - XMLError QueryInt64Attribute(const char* name, int64_t* value) const { - const XMLAttribute* a = FindAttribute(name); - if (!a) { - return XML_NO_ATTRIBUTE; - } - return a->QueryInt64Value(value); - } - - /// See QueryIntAttribute() - XMLError QueryBoolAttribute( const char* name, bool* value ) const { - const XMLAttribute* a = FindAttribute( name ); - if ( !a ) { - return XML_NO_ATTRIBUTE; - } - return a->QueryBoolValue( value ); - } - /// See QueryIntAttribute() - XMLError QueryDoubleAttribute( const char* name, double* value ) const { - const XMLAttribute* a = FindAttribute( name ); - if ( !a ) { - return XML_NO_ATTRIBUTE; - } - return a->QueryDoubleValue( value ); - } - /// See QueryIntAttribute() - XMLError QueryFloatAttribute( const char* name, float* value ) const { - const XMLAttribute* a = FindAttribute( name ); - if ( !a ) { - return XML_NO_ATTRIBUTE; - } - return a->QueryFloatValue( value ); - } - - /// See QueryIntAttribute() - XMLError QueryStringAttribute(const char* name, const char** value) const { - const XMLAttribute* a = FindAttribute(name); - if (!a) { - return XML_NO_ATTRIBUTE; - } - *value = a->Value(); - return XML_SUCCESS; - } - - - - /** Given an attribute name, QueryAttribute() returns - XML_SUCCESS, XML_WRONG_ATTRIBUTE_TYPE if the conversion - can't be performed, or XML_NO_ATTRIBUTE if the attribute - doesn't exist. It is overloaded for the primitive types, - and is a generally more convenient replacement of - QueryIntAttribute() and related functions. - - If successful, the result of the conversion - will be written to 'value'. If not successful, nothing will - be written to 'value'. This allows you to provide default - value: - - @verbatim - int value = 10; - QueryAttribute( "foo", &value ); // if "foo" isn't found, value will still be 10 - @endverbatim - */ - XMLError QueryAttribute( const char* name, int* value ) const { - return QueryIntAttribute( name, value ); - } - - XMLError QueryAttribute( const char* name, unsigned int* value ) const { - return QueryUnsignedAttribute( name, value ); - } - - XMLError QueryAttribute(const char* name, int64_t* value) const { - return QueryInt64Attribute(name, value); - } - - XMLError QueryAttribute( const char* name, bool* value ) const { - return QueryBoolAttribute( name, value ); - } - - XMLError QueryAttribute( const char* name, double* value ) const { - return QueryDoubleAttribute( name, value ); - } - - XMLError QueryAttribute( const char* name, float* value ) const { - return QueryFloatAttribute( name, value ); - } - - /// Sets the named attribute to value. - void SetAttribute( const char* name, const char* value ) { - XMLAttribute* a = FindOrCreateAttribute( name ); - a->SetAttribute( value ); - } - /// Sets the named attribute to value. - void SetAttribute( const char* name, int value ) { - XMLAttribute* a = FindOrCreateAttribute( name ); - a->SetAttribute( value ); - } - /// Sets the named attribute to value. - void SetAttribute( const char* name, unsigned value ) { - XMLAttribute* a = FindOrCreateAttribute( name ); - a->SetAttribute( value ); - } - - /// Sets the named attribute to value. - void SetAttribute(const char* name, int64_t value) { - XMLAttribute* a = FindOrCreateAttribute(name); - a->SetAttribute(value); - } - - /// Sets the named attribute to value. - void SetAttribute( const char* name, bool value ) { - XMLAttribute* a = FindOrCreateAttribute( name ); - a->SetAttribute( value ); - } - /// Sets the named attribute to value. - void SetAttribute( const char* name, double value ) { - XMLAttribute* a = FindOrCreateAttribute( name ); - a->SetAttribute( value ); - } - /// Sets the named attribute to value. - void SetAttribute( const char* name, float value ) { - XMLAttribute* a = FindOrCreateAttribute( name ); - a->SetAttribute( value ); - } - - /** - Delete an attribute. - */ - void DeleteAttribute( const char* name ); - - /// Return the first attribute in the list. - const XMLAttribute* FirstAttribute() const { - return _rootAttribute; - } - /// Query a specific attribute in the list. - const XMLAttribute* FindAttribute( const char* name ) const; - - /** Convenience function for easy access to the text inside an element. Although easy - and concise, GetText() is limited compared to getting the XMLText child - and accessing it directly. - - If the first child of 'this' is a XMLText, the GetText() - returns the character string of the Text node, else null is returned. - - This is a convenient method for getting the text of simple contained text: - @verbatim - This is text - const char* str = fooElement->GetText(); - @endverbatim - - 'str' will be a pointer to "This is text". - - Note that this function can be misleading. If the element foo was created from - this XML: - @verbatim - This is text - @endverbatim - - then the value of str would be null. The first child node isn't a text node, it is - another element. From this XML: - @verbatim - This is text - @endverbatim - GetText() will return "This is ". - */ - const char* GetText() const; - - /** Convenience function for easy access to the text inside an element. Although easy - and concise, SetText() is limited compared to creating an XMLText child - and mutating it directly. - - If the first child of 'this' is a XMLText, SetText() sets its value to - the given string, otherwise it will create a first child that is an XMLText. - - This is a convenient method for setting the text of simple contained text: - @verbatim - This is text - fooElement->SetText( "Hullaballoo!" ); - Hullaballoo! - @endverbatim - - Note that this function can be misleading. If the element foo was created from - this XML: - @verbatim - This is text - @endverbatim - - then it will not change "This is text", but rather prefix it with a text element: - @verbatim - Hullaballoo!This is text - @endverbatim - - For this XML: - @verbatim - - @endverbatim - SetText() will generate - @verbatim - Hullaballoo! - @endverbatim - */ - void SetText( const char* inText ); - /// Convenience method for setting text inside an element. See SetText() for important limitations. - void SetText( int value ); - /// Convenience method for setting text inside an element. See SetText() for important limitations. - void SetText( unsigned value ); - /// Convenience method for setting text inside an element. See SetText() for important limitations. - void SetText(int64_t value); - /// Convenience method for setting text inside an element. See SetText() for important limitations. - void SetText( bool value ); - /// Convenience method for setting text inside an element. See SetText() for important limitations. - void SetText( double value ); - /// Convenience method for setting text inside an element. See SetText() for important limitations. - void SetText( float value ); - - /** - Convenience method to query the value of a child text node. This is probably best - shown by example. Given you have a document is this form: - @verbatim - - 1 - 1.4 - - @endverbatim - - The QueryIntText() and similar functions provide a safe and easier way to get to the - "value" of x and y. - - @verbatim - int x = 0; - float y = 0; // types of x and y are contrived for example - const XMLElement* xElement = pointElement->FirstChildElement( "x" ); - const XMLElement* yElement = pointElement->FirstChildElement( "y" ); - xElement->QueryIntText( &x ); - yElement->QueryFloatText( &y ); - @endverbatim - - @returns XML_SUCCESS (0) on success, XML_CAN_NOT_CONVERT_TEXT if the text cannot be converted - to the requested type, and XML_NO_TEXT_NODE if there is no child text to query. - - */ - XMLError QueryIntText( int* ival ) const; - /// See QueryIntText() - XMLError QueryUnsignedText( unsigned* uval ) const; - /// See QueryIntText() - XMLError QueryInt64Text(int64_t* uval) const; - /// See QueryIntText() - XMLError QueryBoolText( bool* bval ) const; - /// See QueryIntText() - XMLError QueryDoubleText( double* dval ) const; - /// See QueryIntText() - XMLError QueryFloatText( float* fval ) const; - - int IntText(int defaultValue = 0) const; - - /// See QueryIntText() - unsigned UnsignedText(unsigned defaultValue = 0) const; - /// See QueryIntText() - int64_t Int64Text(int64_t defaultValue = 0) const; - /// See QueryIntText() - bool BoolText(bool defaultValue = false) const; - /// See QueryIntText() - double DoubleText(double defaultValue = 0) const; - /// See QueryIntText() - float FloatText(float defaultValue = 0) const; - - // internal: - enum ElementClosingType { - OPEN, // - CLOSED, // - CLOSING // - }; - ElementClosingType ClosingType() const { - return _closingType; - } - virtual XMLNode* ShallowClone( XMLDocument* document ) const; - virtual bool ShallowEqual( const XMLNode* compare ) const; - -protected: - char* ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr ); - -private: - XMLElement( XMLDocument* doc ); - virtual ~XMLElement(); - XMLElement( const XMLElement& ); // not supported - void operator=( const XMLElement& ); // not supported - - XMLAttribute* FindOrCreateAttribute( const char* name ); - char* ParseAttributes( char* p, int* curLineNumPtr ); - static void DeleteAttribute( XMLAttribute* attribute ); - XMLAttribute* CreateAttribute(); - - enum { BUF_SIZE = 200 }; - ElementClosingType _closingType; - // The attribute list is ordered; there is no 'lastAttribute' - // because the list needs to be scanned for dupes before adding - // a new attribute. - XMLAttribute* _rootAttribute; -}; - - -enum Whitespace { - PRESERVE_WHITESPACE, - COLLAPSE_WHITESPACE -}; - - -/** A Document binds together all the functionality. - It can be saved, loaded, and printed to the screen. - All Nodes are connected and allocated to a Document. - If the Document is deleted, all its Nodes are also deleted. -*/ -class TINYXML2_LIB XMLDocument : public XMLNode -{ - friend class XMLElement; - // Gives access to SetError and Push/PopDepth, but over-access for everything else. - // Wishing C++ had "internal" scope. - friend class XMLNode; - friend class XMLText; - friend class XMLComment; - friend class XMLDeclaration; - friend class XMLUnknown; -public: - /// constructor - XMLDocument( bool processEntities = true, Whitespace whitespaceMode = PRESERVE_WHITESPACE ); - ~XMLDocument(); - - virtual XMLDocument* ToDocument() { - TIXMLASSERT( this == _document ); - return this; - } - virtual const XMLDocument* ToDocument() const { - TIXMLASSERT( this == _document ); - return this; - } - - /** - Parse an XML file from a character string. - Returns XML_SUCCESS (0) on success, or - an errorID. - - You may optionally pass in the 'nBytes', which is - the number of bytes which will be parsed. If not - specified, TinyXML-2 will assume 'xml' points to a - null terminated string. - */ - XMLError Parse( const char* xml, size_t nBytes=(size_t)(-1) ); - - /** - Load an XML file from disk. - Returns XML_SUCCESS (0) on success, or - an errorID. - */ - XMLError LoadFile( const char* filename ); - - /** - Load an XML file from disk. You are responsible - for providing and closing the FILE*. - - NOTE: The file should be opened as binary ("rb") - not text in order for TinyXML-2 to correctly - do newline normalization. - - Returns XML_SUCCESS (0) on success, or - an errorID. - */ - XMLError LoadFile( FILE* ); - - /** - Save the XML file to disk. - Returns XML_SUCCESS (0) on success, or - an errorID. - */ - XMLError SaveFile( const char* filename, bool compact = false ); - - /** - Save the XML file to disk. You are responsible - for providing and closing the FILE*. - - Returns XML_SUCCESS (0) on success, or - an errorID. - */ - XMLError SaveFile( FILE* fp, bool compact = false ); - - bool ProcessEntities() const { - return _processEntities; - } - Whitespace WhitespaceMode() const { - return _whitespaceMode; - } - - /** - Returns true if this document has a leading Byte Order Mark of UTF8. - */ - bool HasBOM() const { - return _writeBOM; - } - /** Sets whether to write the BOM when writing the file. - */ - void SetBOM( bool useBOM ) { - _writeBOM = useBOM; - } - - /** Return the root element of DOM. Equivalent to FirstChildElement(). - To get the first node, use FirstChild(). - */ - XMLElement* RootElement() { - return FirstChildElement(); - } - const XMLElement* RootElement() const { - return FirstChildElement(); - } - - /** Print the Document. If the Printer is not provided, it will - print to stdout. If you provide Printer, this can print to a file: - @verbatim - XMLPrinter printer( fp ); - doc.Print( &printer ); - @endverbatim - - Or you can use a printer to print to memory: - @verbatim - XMLPrinter printer; - doc.Print( &printer ); - // printer.CStr() has a const char* to the XML - @endverbatim - */ - void Print( XMLPrinter* streamer=0 ) const; - virtual bool Accept( XMLVisitor* visitor ) const; - - /** - Create a new Element associated with - this Document. The memory for the Element - is managed by the Document. - */ - XMLElement* NewElement( const char* name ); - /** - Create a new Comment associated with - this Document. The memory for the Comment - is managed by the Document. - */ - XMLComment* NewComment( const char* comment ); - /** - Create a new Text associated with - this Document. The memory for the Text - is managed by the Document. - */ - XMLText* NewText( const char* text ); - /** - Create a new Declaration associated with - this Document. The memory for the object - is managed by the Document. - - If the 'text' param is null, the standard - declaration is used.: - @verbatim - - @endverbatim - */ - XMLDeclaration* NewDeclaration( const char* text=0 ); - /** - Create a new Unknown associated with - this Document. The memory for the object - is managed by the Document. - */ - XMLUnknown* NewUnknown( const char* text ); - - /** - Delete a node associated with this document. - It will be unlinked from the DOM. - */ - void DeleteNode( XMLNode* node ); - - void ClearError() { - SetError(XML_SUCCESS, 0, 0); - } - - /// Return true if there was an error parsing the document. - bool Error() const { - return _errorID != XML_SUCCESS; - } - /// Return the errorID. - XMLError ErrorID() const { - return _errorID; - } - const char* ErrorName() const; - static const char* ErrorIDToName(XMLError errorID); - - /** Returns a "long form" error description. A hopefully helpful - diagnostic with location, line number, and/or additional info. - */ - const char* ErrorStr() const; - - /// A (trivial) utility function that prints the ErrorStr() to stdout. - void PrintError() const; - - /// Return the line where the error occurred, or zero if unknown. - int ErrorLineNum() const - { - return _errorLineNum; - } - - /// Clear the document, resetting it to the initial state. - void Clear(); - - /** - Copies this document to a target document. - The target will be completely cleared before the copy. - If you want to copy a sub-tree, see XMLNode::DeepClone(). - - NOTE: that the 'target' must be non-null. - */ - void DeepCopy(XMLDocument* target) const; - - // internal - char* Identify( char* p, XMLNode** node ); - - // internal - void MarkInUse(XMLNode*); - - virtual XMLNode* ShallowClone( XMLDocument* /*document*/ ) const { - return 0; - } - virtual bool ShallowEqual( const XMLNode* /*compare*/ ) const { - return false; - } - -private: - XMLDocument( const XMLDocument& ); // not supported - void operator=( const XMLDocument& ); // not supported - - bool _writeBOM; - bool _processEntities; - XMLError _errorID; - Whitespace _whitespaceMode; - mutable StrPair _errorStr; - int _errorLineNum; - char* _charBuffer; - int _parseCurLineNum; - int _parsingDepth; - // Memory tracking does add some overhead. - // However, the code assumes that you don't - // have a bunch of unlinked nodes around. - // Therefore it takes less memory to track - // in the document vs. a linked list in the XMLNode, - // and the performance is the same. - DynArray _unlinked; - - MemPoolT< sizeof(XMLElement) > _elementPool; - MemPoolT< sizeof(XMLAttribute) > _attributePool; - MemPoolT< sizeof(XMLText) > _textPool; - MemPoolT< sizeof(XMLComment) > _commentPool; - - static const char* _errorNames[XML_ERROR_COUNT]; - - void Parse(); - - void SetError( XMLError error, int lineNum, const char* format, ... ); - - // Something of an obvious security hole, once it was discovered. - // Either an ill-formed XML or an excessively deep one can overflow - // the stack. Track stack depth, and error out if needed. - class DepthTracker { - public: - explicit DepthTracker(XMLDocument * document) { - this->_document = document; - document->PushDepth(); - } - ~DepthTracker() { - _document->PopDepth(); - } - private: - XMLDocument * _document; - }; - void PushDepth(); - void PopDepth(); - - template - NodeType* CreateUnlinkedNode( MemPoolT& pool ); -}; - -template -inline NodeType* XMLDocument::CreateUnlinkedNode( MemPoolT& pool ) -{ - TIXMLASSERT( sizeof( NodeType ) == PoolElementSize ); - TIXMLASSERT( sizeof( NodeType ) == pool.ItemSize() ); - NodeType* returnNode = new (pool.Alloc()) NodeType( this ); - TIXMLASSERT( returnNode ); - returnNode->_memPool = &pool; - - _unlinked.Push(returnNode); - return returnNode; -} - -/** - A XMLHandle is a class that wraps a node pointer with null checks; this is - an incredibly useful thing. Note that XMLHandle is not part of the TinyXML-2 - DOM structure. It is a separate utility class. - - Take an example: - @verbatim - - - - - - - @endverbatim - - Assuming you want the value of "attributeB" in the 2nd "Child" element, it's very - easy to write a *lot* of code that looks like: - - @verbatim - XMLElement* root = document.FirstChildElement( "Document" ); - if ( root ) - { - XMLElement* element = root->FirstChildElement( "Element" ); - if ( element ) - { - XMLElement* child = element->FirstChildElement( "Child" ); - if ( child ) - { - XMLElement* child2 = child->NextSiblingElement( "Child" ); - if ( child2 ) - { - // Finally do something useful. - @endverbatim - - And that doesn't even cover "else" cases. XMLHandle addresses the verbosity - of such code. A XMLHandle checks for null pointers so it is perfectly safe - and correct to use: - - @verbatim - XMLHandle docHandle( &document ); - XMLElement* child2 = docHandle.FirstChildElement( "Document" ).FirstChildElement( "Element" ).FirstChildElement().NextSiblingElement(); - if ( child2 ) - { - // do something useful - @endverbatim - - Which is MUCH more concise and useful. - - It is also safe to copy handles - internally they are nothing more than node pointers. - @verbatim - XMLHandle handleCopy = handle; - @endverbatim - - See also XMLConstHandle, which is the same as XMLHandle, but operates on const objects. -*/ -class TINYXML2_LIB XMLHandle -{ -public: - /// Create a handle from any node (at any depth of the tree.) This can be a null pointer. - explicit XMLHandle( XMLNode* node ) : _node( node ) { - } - /// Create a handle from a node. - explicit XMLHandle( XMLNode& node ) : _node( &node ) { - } - /// Copy constructor - XMLHandle( const XMLHandle& ref ) : _node( ref._node ) { - } - /// Assignment - XMLHandle& operator=( const XMLHandle& ref ) { - _node = ref._node; - return *this; - } - - /// Get the first child of this handle. - XMLHandle FirstChild() { - return XMLHandle( _node ? _node->FirstChild() : 0 ); - } - /// Get the first child element of this handle. - XMLHandle FirstChildElement( const char* name = 0 ) { - return XMLHandle( _node ? _node->FirstChildElement( name ) : 0 ); - } - /// Get the last child of this handle. - XMLHandle LastChild() { - return XMLHandle( _node ? _node->LastChild() : 0 ); - } - /// Get the last child element of this handle. - XMLHandle LastChildElement( const char* name = 0 ) { - return XMLHandle( _node ? _node->LastChildElement( name ) : 0 ); - } - /// Get the previous sibling of this handle. - XMLHandle PreviousSibling() { - return XMLHandle( _node ? _node->PreviousSibling() : 0 ); - } - /// Get the previous sibling element of this handle. - XMLHandle PreviousSiblingElement( const char* name = 0 ) { - return XMLHandle( _node ? _node->PreviousSiblingElement( name ) : 0 ); - } - /// Get the next sibling of this handle. - XMLHandle NextSibling() { - return XMLHandle( _node ? _node->NextSibling() : 0 ); - } - /// Get the next sibling element of this handle. - XMLHandle NextSiblingElement( const char* name = 0 ) { - return XMLHandle( _node ? _node->NextSiblingElement( name ) : 0 ); - } - - /// Safe cast to XMLNode. This can return null. - XMLNode* ToNode() { - return _node; - } - /// Safe cast to XMLElement. This can return null. - XMLElement* ToElement() { - return ( _node ? _node->ToElement() : 0 ); - } - /// Safe cast to XMLText. This can return null. - XMLText* ToText() { - return ( _node ? _node->ToText() : 0 ); - } - /// Safe cast to XMLUnknown. This can return null. - XMLUnknown* ToUnknown() { - return ( _node ? _node->ToUnknown() : 0 ); - } - /// Safe cast to XMLDeclaration. This can return null. - XMLDeclaration* ToDeclaration() { - return ( _node ? _node->ToDeclaration() : 0 ); - } - -private: - XMLNode* _node; -}; - - -/** - A variant of the XMLHandle class for working with const XMLNodes and Documents. It is the - same in all regards, except for the 'const' qualifiers. See XMLHandle for API. -*/ -class TINYXML2_LIB XMLConstHandle -{ -public: - explicit XMLConstHandle( const XMLNode* node ) : _node( node ) { - } - explicit XMLConstHandle( const XMLNode& node ) : _node( &node ) { - } - XMLConstHandle( const XMLConstHandle& ref ) : _node( ref._node ) { - } - - XMLConstHandle& operator=( const XMLConstHandle& ref ) { - _node = ref._node; - return *this; - } - - const XMLConstHandle FirstChild() const { - return XMLConstHandle( _node ? _node->FirstChild() : 0 ); - } - const XMLConstHandle FirstChildElement( const char* name = 0 ) const { - return XMLConstHandle( _node ? _node->FirstChildElement( name ) : 0 ); - } - const XMLConstHandle LastChild() const { - return XMLConstHandle( _node ? _node->LastChild() : 0 ); - } - const XMLConstHandle LastChildElement( const char* name = 0 ) const { - return XMLConstHandle( _node ? _node->LastChildElement( name ) : 0 ); - } - const XMLConstHandle PreviousSibling() const { - return XMLConstHandle( _node ? _node->PreviousSibling() : 0 ); - } - const XMLConstHandle PreviousSiblingElement( const char* name = 0 ) const { - return XMLConstHandle( _node ? _node->PreviousSiblingElement( name ) : 0 ); - } - const XMLConstHandle NextSibling() const { - return XMLConstHandle( _node ? _node->NextSibling() : 0 ); - } - const XMLConstHandle NextSiblingElement( const char* name = 0 ) const { - return XMLConstHandle( _node ? _node->NextSiblingElement( name ) : 0 ); - } - - - const XMLNode* ToNode() const { - return _node; - } - const XMLElement* ToElement() const { - return ( _node ? _node->ToElement() : 0 ); - } - const XMLText* ToText() const { - return ( _node ? _node->ToText() : 0 ); - } - const XMLUnknown* ToUnknown() const { - return ( _node ? _node->ToUnknown() : 0 ); - } - const XMLDeclaration* ToDeclaration() const { - return ( _node ? _node->ToDeclaration() : 0 ); - } - -private: - const XMLNode* _node; -}; - - -/** - Printing functionality. The XMLPrinter gives you more - options than the XMLDocument::Print() method. - - It can: - -# Print to memory. - -# Print to a file you provide. - -# Print XML without a XMLDocument. - - Print to Memory - - @verbatim - XMLPrinter printer; - doc.Print( &printer ); - SomeFunction( printer.CStr() ); - @endverbatim - - Print to a File - - You provide the file pointer. - @verbatim - XMLPrinter printer( fp ); - doc.Print( &printer ); - @endverbatim - - Print without a XMLDocument - - When loading, an XML parser is very useful. However, sometimes - when saving, it just gets in the way. The code is often set up - for streaming, and constructing the DOM is just overhead. - - The Printer supports the streaming case. The following code - prints out a trivially simple XML file without ever creating - an XML document. - - @verbatim - XMLPrinter printer( fp ); - printer.OpenElement( "foo" ); - printer.PushAttribute( "foo", "bar" ); - printer.CloseElement(); - @endverbatim -*/ -class TINYXML2_LIB XMLPrinter : public XMLVisitor -{ -public: - /** Construct the printer. If the FILE* is specified, - this will print to the FILE. Else it will print - to memory, and the result is available in CStr(). - If 'compact' is set to true, then output is created - with only required whitespace and newlines. - */ - XMLPrinter( FILE* file=0, bool compact = false, int depth = 0 ); - virtual ~XMLPrinter() {} - - /** If streaming, write the BOM and declaration. */ - void PushHeader( bool writeBOM, bool writeDeclaration ); - /** If streaming, start writing an element. - The element must be closed with CloseElement() - */ - void OpenElement( const char* name, bool compactMode=false ); - /// If streaming, add an attribute to an open element. - void PushAttribute( const char* name, const char* value ); - void PushAttribute( const char* name, int value ); - void PushAttribute( const char* name, unsigned value ); - void PushAttribute(const char* name, int64_t value); - void PushAttribute( const char* name, bool value ); - void PushAttribute( const char* name, double value ); - /// If streaming, close the Element. - virtual void CloseElement( bool compactMode=false ); - - /// Add a text node. - void PushText( const char* text, bool cdata=false ); - /// Add a text node from an integer. - void PushText( int value ); - /// Add a text node from an unsigned. - void PushText( unsigned value ); - /// Add a text node from an unsigned. - void PushText(int64_t value); - /// Add a text node from a bool. - void PushText( bool value ); - /// Add a text node from a float. - void PushText( float value ); - /// Add a text node from a double. - void PushText( double value ); - - /// Add a comment - void PushComment( const char* comment ); - - void PushDeclaration( const char* value ); - void PushUnknown( const char* value ); - - virtual bool VisitEnter( const XMLDocument& /*doc*/ ); - virtual bool VisitExit( const XMLDocument& /*doc*/ ) { - return true; - } - - virtual bool VisitEnter( const XMLElement& element, const XMLAttribute* attribute ); - virtual bool VisitExit( const XMLElement& element ); - - virtual bool Visit( const XMLText& text ); - virtual bool Visit( const XMLComment& comment ); - virtual bool Visit( const XMLDeclaration& declaration ); - virtual bool Visit( const XMLUnknown& unknown ); - - /** - If in print to memory mode, return a pointer to - the XML file in memory. - */ - const char* CStr() const { - return _buffer.Mem(); - } - /** - If in print to memory mode, return the size - of the XML file in memory. (Note the size returned - includes the terminating null.) - */ - int CStrSize() const { - return _buffer.Size(); - } - /** - If in print to memory mode, reset the buffer to the - beginning. - */ - void ClearBuffer() { - _buffer.Clear(); - _buffer.Push(0); - _firstElement = true; - } - -protected: - virtual bool CompactMode( const XMLElement& ) { return _compactMode; } - - /** Prints out the space before an element. You may override to change - the space and tabs used. A PrintSpace() override should call Print(). - */ - virtual void PrintSpace( int depth ); - void Print( const char* format, ... ); - void Write( const char* data, size_t size ); - inline void Write( const char* data ) { Write( data, strlen( data ) ); } - void Putc( char ch ); - - void SealElementIfJustOpened(); - bool _elementJustOpened; - DynArray< const char*, 10 > _stack; - -private: - void PrintString( const char*, bool restrictedEntitySet ); // prints out, after detecting entities. - - bool _firstElement; - FILE* _fp; - int _depth; - int _textDepth; - bool _processEntities; - bool _compactMode; - - enum { - ENTITY_RANGE = 64, - BUF_SIZE = 200 - }; - bool _entityFlag[ENTITY_RANGE]; - bool _restrictedEntityFlag[ENTITY_RANGE]; - - DynArray< char, 20 > _buffer; - - // Prohibit cloning, intentionally not implemented - XMLPrinter( const XMLPrinter& ); - XMLPrinter& operator=( const XMLPrinter& ); -}; - - -} // tinyxml2 - -#if defined(_MSC_VER) -# pragma warning(pop) -#endif - -#endif // TINYXML2_INCLUDED diff --git a/scripts/linux/appimage/soh.sh b/scripts/linux/appimage/soh.sh index 063fcf79c..0e8414ac0 100644 --- a/scripts/linux/appimage/soh.sh +++ b/scripts/linux/appimage/soh.sh @@ -26,7 +26,6 @@ while [[ (! -e "$SHIP_HOME"/oot.otr) || (! -e "$SHIP_HOME"/oot-mq.otr) ]]; do ln -s "$HERE"/usr/bin/{assets,soh.elf,ZAPD} "$ASSETDIR" export OLDPWD="$PWD" mkdir -p "$ASSETDIR"/tmp - mkdir -p "$ASSETDIR"/Extract ln -s "$romfile" "$ASSETDIR"/tmp/rom.z64 cd "$ASSETDIR" ROMHASH=$(sha1sum -b "$ASSETDIR"/tmp/rom.z64 | awk '{ print $1 }') @@ -166,7 +165,6 @@ while [[ (! -e "$SHIP_HOME"/oot.otr) || (! -e "$SHIP_HOME"/oot-mq.otr) ]]; do continue;; esac if [[ ! -e "$SHIP_HOME"/"$OTRNAME" ]]; then - cp -r "$ASSETDIR"/assets/game "$ASSETDIR"/Extract/assets if [ -n "$ZENITY" ]; then (echo "# 25%"; echo "25"; sleep 2; echo "# 50%"; echo "50"; sleep 3; echo "# 75%"; echo "75"; sleep 2; echo "# 100%"; echo "100"; sleep 3) | zenity --progress --title="OTR Generating..." --timeout=10 --percentage=0 --icon-name=soh --window-icon=soh.png --height=80 --width=400 & diff --git a/OTRExporter/assets/accessibility/texts/filechoose_eng.json b/soh/assets/custom/accessibility/texts/filechoose_eng.json similarity index 100% rename from OTRExporter/assets/accessibility/texts/filechoose_eng.json rename to soh/assets/custom/accessibility/texts/filechoose_eng.json diff --git a/OTRExporter/assets/accessibility/texts/filechoose_fra.json b/soh/assets/custom/accessibility/texts/filechoose_fra.json similarity index 100% rename from OTRExporter/assets/accessibility/texts/filechoose_fra.json rename to soh/assets/custom/accessibility/texts/filechoose_fra.json diff --git a/OTRExporter/assets/accessibility/texts/filechoose_ger.json b/soh/assets/custom/accessibility/texts/filechoose_ger.json similarity index 100% rename from OTRExporter/assets/accessibility/texts/filechoose_ger.json rename to soh/assets/custom/accessibility/texts/filechoose_ger.json diff --git a/OTRExporter/assets/accessibility/texts/kaleidoscope_eng.json b/soh/assets/custom/accessibility/texts/kaleidoscope_eng.json similarity index 100% rename from OTRExporter/assets/accessibility/texts/kaleidoscope_eng.json rename to soh/assets/custom/accessibility/texts/kaleidoscope_eng.json diff --git a/OTRExporter/assets/accessibility/texts/kaleidoscope_fra.json b/soh/assets/custom/accessibility/texts/kaleidoscope_fra.json similarity index 100% rename from OTRExporter/assets/accessibility/texts/kaleidoscope_fra.json rename to soh/assets/custom/accessibility/texts/kaleidoscope_fra.json diff --git a/OTRExporter/assets/accessibility/texts/kaleidoscope_ger.json b/soh/assets/custom/accessibility/texts/kaleidoscope_ger.json similarity index 100% rename from OTRExporter/assets/accessibility/texts/kaleidoscope_ger.json rename to soh/assets/custom/accessibility/texts/kaleidoscope_ger.json diff --git a/OTRExporter/assets/accessibility/texts/misc_eng.json b/soh/assets/custom/accessibility/texts/misc_eng.json similarity index 100% rename from OTRExporter/assets/accessibility/texts/misc_eng.json rename to soh/assets/custom/accessibility/texts/misc_eng.json diff --git a/OTRExporter/assets/accessibility/texts/misc_fra.json b/soh/assets/custom/accessibility/texts/misc_fra.json similarity index 100% rename from OTRExporter/assets/accessibility/texts/misc_fra.json rename to soh/assets/custom/accessibility/texts/misc_fra.json diff --git a/OTRExporter/assets/accessibility/texts/misc_ger.json b/soh/assets/custom/accessibility/texts/misc_ger.json similarity index 100% rename from OTRExporter/assets/accessibility/texts/misc_ger.json rename to soh/assets/custom/accessibility/texts/misc_ger.json diff --git a/OTRExporter/assets/accessibility/texts/scenes_eng.json b/soh/assets/custom/accessibility/texts/scenes_eng.json similarity index 100% rename from OTRExporter/assets/accessibility/texts/scenes_eng.json rename to soh/assets/custom/accessibility/texts/scenes_eng.json diff --git a/OTRExporter/assets/accessibility/texts/scenes_fra.json b/soh/assets/custom/accessibility/texts/scenes_fra.json similarity index 100% rename from OTRExporter/assets/accessibility/texts/scenes_fra.json rename to soh/assets/custom/accessibility/texts/scenes_fra.json diff --git a/OTRExporter/assets/accessibility/texts/scenes_ger.json b/soh/assets/custom/accessibility/texts/scenes_ger.json similarity index 100% rename from OTRExporter/assets/accessibility/texts/scenes_ger.json rename to soh/assets/custom/accessibility/texts/scenes_ger.json diff --git a/OTRExporter/assets/fonts/Fipps-Regular.otf b/soh/assets/custom/fonts/Fipps-Regular.otf similarity index 100% rename from OTRExporter/assets/fonts/Fipps-Regular.otf rename to soh/assets/custom/fonts/Fipps-Regular.otf diff --git a/OTRExporter/assets/fonts/PressStart2P-Regular.ttf b/soh/assets/custom/fonts/PressStart2P-Regular.ttf similarity index 100% rename from OTRExporter/assets/fonts/PressStart2P-Regular.ttf rename to soh/assets/custom/fonts/PressStart2P-Regular.ttf diff --git a/OTRExporter/assets/helpers/cosmetics/gEndGrayscaleAndEndDlistDL b/soh/assets/custom/helpers/cosmetics/gEndGrayscaleAndEndDlistDL similarity index 100% rename from OTRExporter/assets/helpers/cosmetics/gEndGrayscaleAndEndDlistDL rename to soh/assets/custom/helpers/cosmetics/gEndGrayscaleAndEndDlistDL diff --git a/OTRExporter/assets/objects/object_box/gChristmasGreenTreasureChestFrontTex.rgb5a1.png b/soh/assets/custom/objects/object_box/gChristmasGreenTreasureChestFrontTex.rgb5a1.png similarity index 100% rename from OTRExporter/assets/objects/object_box/gChristmasGreenTreasureChestFrontTex.rgb5a1.png rename to soh/assets/custom/objects/object_box/gChristmasGreenTreasureChestFrontTex.rgb5a1.png diff --git a/OTRExporter/assets/objects/object_box/gChristmasGreenTreasureChestSideAndTopTex.rgb5a1.png b/soh/assets/custom/objects/object_box/gChristmasGreenTreasureChestSideAndTopTex.rgb5a1.png similarity index 100% rename from OTRExporter/assets/objects/object_box/gChristmasGreenTreasureChestSideAndTopTex.rgb5a1.png rename to soh/assets/custom/objects/object_box/gChristmasGreenTreasureChestSideAndTopTex.rgb5a1.png diff --git a/OTRExporter/assets/objects/object_box/gChristmasRedTreasureChestFrontTex.rgb5a1.png b/soh/assets/custom/objects/object_box/gChristmasRedTreasureChestFrontTex.rgb5a1.png similarity index 100% rename from OTRExporter/assets/objects/object_box/gChristmasRedTreasureChestFrontTex.rgb5a1.png rename to soh/assets/custom/objects/object_box/gChristmasRedTreasureChestFrontTex.rgb5a1.png diff --git a/OTRExporter/assets/objects/object_box/gChristmasRedTreasureChestSideAndTopTex.rgb5a1.png b/soh/assets/custom/objects/object_box/gChristmasRedTreasureChestSideAndTopTex.rgb5a1.png similarity index 100% rename from OTRExporter/assets/objects/object_box/gChristmasRedTreasureChestSideAndTopTex.rgb5a1.png rename to soh/assets/custom/objects/object_box/gChristmasRedTreasureChestSideAndTopTex.rgb5a1.png diff --git a/OTRExporter/assets/objects/object_box/gGoldTreasureChestFrontTex.rgb5a1.png b/soh/assets/custom/objects/object_box/gGoldTreasureChestFrontTex.rgb5a1.png similarity index 100% rename from OTRExporter/assets/objects/object_box/gGoldTreasureChestFrontTex.rgb5a1.png rename to soh/assets/custom/objects/object_box/gGoldTreasureChestFrontTex.rgb5a1.png diff --git a/OTRExporter/assets/objects/object_box/gGoldTreasureChestSideAndTopTex.rgb5a1.png b/soh/assets/custom/objects/object_box/gGoldTreasureChestSideAndTopTex.rgb5a1.png similarity index 100% rename from OTRExporter/assets/objects/object_box/gGoldTreasureChestSideAndTopTex.rgb5a1.png rename to soh/assets/custom/objects/object_box/gGoldTreasureChestSideAndTopTex.rgb5a1.png diff --git a/OTRExporter/assets/objects/object_box/gKeyTreasureChestFrontTex.rgb5a1.png b/soh/assets/custom/objects/object_box/gKeyTreasureChestFrontTex.rgb5a1.png similarity index 100% rename from OTRExporter/assets/objects/object_box/gKeyTreasureChestFrontTex.rgb5a1.png rename to soh/assets/custom/objects/object_box/gKeyTreasureChestFrontTex.rgb5a1.png diff --git a/OTRExporter/assets/objects/object_box/gKeyTreasureChestSideAndTopTex.rgb5a1.png b/soh/assets/custom/objects/object_box/gKeyTreasureChestSideAndTopTex.rgb5a1.png similarity index 100% rename from OTRExporter/assets/objects/object_box/gKeyTreasureChestSideAndTopTex.rgb5a1.png rename to soh/assets/custom/objects/object_box/gKeyTreasureChestSideAndTopTex.rgb5a1.png diff --git a/OTRExporter/assets/objects/object_box/gSkullTreasureChestFrontTex.rgb5a1.png b/soh/assets/custom/objects/object_box/gSkullTreasureChestFrontTex.rgb5a1.png similarity index 100% rename from OTRExporter/assets/objects/object_box/gSkullTreasureChestFrontTex.rgb5a1.png rename to soh/assets/custom/objects/object_box/gSkullTreasureChestFrontTex.rgb5a1.png diff --git a/OTRExporter/assets/objects/object_box/gSkullTreasureChestSideAndTopTex.rgb5a1.png b/soh/assets/custom/objects/object_box/gSkullTreasureChestSideAndTopTex.rgb5a1.png similarity index 100% rename from OTRExporter/assets/objects/object_box/gSkullTreasureChestSideAndTopTex.rgb5a1.png rename to soh/assets/custom/objects/object_box/gSkullTreasureChestSideAndTopTex.rgb5a1.png diff --git a/OTRExporter/assets/objects/object_mag/gTitleBossRushSubtitleTex.rgba32.png b/soh/assets/custom/objects/object_mag/gTitleBossRushSubtitleTex.rgba32.png similarity index 100% rename from OTRExporter/assets/objects/object_mag/gTitleBossRushSubtitleTex.rgba32.png rename to soh/assets/custom/objects/object_mag/gTitleBossRushSubtitleTex.rgba32.png diff --git a/OTRExporter/assets/objects/object_mag/gTitleRandomizerSubtitleTex.rgba32.png b/soh/assets/custom/objects/object_mag/gTitleRandomizerSubtitleTex.rgba32.png similarity index 100% rename from OTRExporter/assets/objects/object_mag/gTitleRandomizerSubtitleTex.rgba32.png rename to soh/assets/custom/objects/object_mag/gTitleRandomizerSubtitleTex.rgba32.png diff --git a/OTRExporter/assets/objects/object_triforce_completed/gTriforcePieceCompletedDL b/soh/assets/custom/objects/object_triforce_completed/gTriforcePieceCompletedDL similarity index 100% rename from OTRExporter/assets/objects/object_triforce_completed/gTriforcePieceCompletedDL rename to soh/assets/custom/objects/object_triforce_completed/gTriforcePieceCompletedDL diff --git a/OTRExporter/assets/objects/object_triforce_completed/gTriforcePieceCompletedDL_tri_0 b/soh/assets/custom/objects/object_triforce_completed/gTriforcePieceCompletedDL_tri_0 similarity index 100% rename from OTRExporter/assets/objects/object_triforce_completed/gTriforcePieceCompletedDL_tri_0 rename to soh/assets/custom/objects/object_triforce_completed/gTriforcePieceCompletedDL_tri_0 diff --git a/OTRExporter/assets/objects/object_triforce_completed/gTriforcePieceCompletedDL_tri_1 b/soh/assets/custom/objects/object_triforce_completed/gTriforcePieceCompletedDL_tri_1 similarity index 100% rename from OTRExporter/assets/objects/object_triforce_completed/gTriforcePieceCompletedDL_tri_1 rename to soh/assets/custom/objects/object_triforce_completed/gTriforcePieceCompletedDL_tri_1 diff --git a/OTRExporter/assets/objects/object_triforce_completed/gTriforcePieceCompletedDL_vtx_0 b/soh/assets/custom/objects/object_triforce_completed/gTriforcePieceCompletedDL_vtx_0 similarity index 100% rename from OTRExporter/assets/objects/object_triforce_completed/gTriforcePieceCompletedDL_vtx_0 rename to soh/assets/custom/objects/object_triforce_completed/gTriforcePieceCompletedDL_vtx_0 diff --git a/OTRExporter/assets/objects/object_triforce_completed/gTriforcePieceCompletedDL_vtx_1 b/soh/assets/custom/objects/object_triforce_completed/gTriforcePieceCompletedDL_vtx_1 similarity index 100% rename from OTRExporter/assets/objects/object_triforce_completed/gTriforcePieceCompletedDL_vtx_1 rename to soh/assets/custom/objects/object_triforce_completed/gTriforcePieceCompletedDL_vtx_1 diff --git a/OTRExporter/assets/objects/object_triforce_completed/mat_gTriforcePieceCompletedDL_f3dlite_triforce_edges b/soh/assets/custom/objects/object_triforce_completed/mat_gTriforcePieceCompletedDL_f3dlite_triforce_edges similarity index 100% rename from OTRExporter/assets/objects/object_triforce_completed/mat_gTriforcePieceCompletedDL_f3dlite_triforce_edges rename to soh/assets/custom/objects/object_triforce_completed/mat_gTriforcePieceCompletedDL_f3dlite_triforce_edges diff --git a/OTRExporter/assets/objects/object_triforce_completed/mat_gTriforcePieceCompletedDL_f3dlite_triforce_surface b/soh/assets/custom/objects/object_triforce_completed/mat_gTriforcePieceCompletedDL_f3dlite_triforce_surface similarity index 100% rename from OTRExporter/assets/objects/object_triforce_completed/mat_gTriforcePieceCompletedDL_f3dlite_triforce_surface rename to soh/assets/custom/objects/object_triforce_completed/mat_gTriforcePieceCompletedDL_f3dlite_triforce_surface diff --git a/OTRExporter/assets/objects/object_triforce_completed/noise_tex b/soh/assets/custom/objects/object_triforce_completed/noise_tex similarity index 100% rename from OTRExporter/assets/objects/object_triforce_completed/noise_tex rename to soh/assets/custom/objects/object_triforce_completed/noise_tex diff --git a/OTRExporter/assets/objects/object_triforce_piece_0/gTriforcePiece0DL b/soh/assets/custom/objects/object_triforce_piece_0/gTriforcePiece0DL similarity index 100% rename from OTRExporter/assets/objects/object_triforce_piece_0/gTriforcePiece0DL rename to soh/assets/custom/objects/object_triforce_piece_0/gTriforcePiece0DL diff --git a/OTRExporter/assets/objects/object_triforce_piece_0/gTriforcePiece0DL_tri_0 b/soh/assets/custom/objects/object_triforce_piece_0/gTriforcePiece0DL_tri_0 similarity index 100% rename from OTRExporter/assets/objects/object_triforce_piece_0/gTriforcePiece0DL_tri_0 rename to soh/assets/custom/objects/object_triforce_piece_0/gTriforcePiece0DL_tri_0 diff --git a/OTRExporter/assets/objects/object_triforce_piece_0/gTriforcePiece0DL_tri_1 b/soh/assets/custom/objects/object_triforce_piece_0/gTriforcePiece0DL_tri_1 similarity index 100% rename from OTRExporter/assets/objects/object_triforce_piece_0/gTriforcePiece0DL_tri_1 rename to soh/assets/custom/objects/object_triforce_piece_0/gTriforcePiece0DL_tri_1 diff --git a/OTRExporter/assets/objects/object_triforce_piece_0/gTriforcePiece0DL_tri_2 b/soh/assets/custom/objects/object_triforce_piece_0/gTriforcePiece0DL_tri_2 similarity index 100% rename from OTRExporter/assets/objects/object_triforce_piece_0/gTriforcePiece0DL_tri_2 rename to soh/assets/custom/objects/object_triforce_piece_0/gTriforcePiece0DL_tri_2 diff --git a/OTRExporter/assets/objects/object_triforce_piece_0/gTriforcePiece0DL_vtx_0 b/soh/assets/custom/objects/object_triforce_piece_0/gTriforcePiece0DL_vtx_0 similarity index 100% rename from OTRExporter/assets/objects/object_triforce_piece_0/gTriforcePiece0DL_vtx_0 rename to soh/assets/custom/objects/object_triforce_piece_0/gTriforcePiece0DL_vtx_0 diff --git a/OTRExporter/assets/objects/object_triforce_piece_0/gTriforcePiece0DL_vtx_1 b/soh/assets/custom/objects/object_triforce_piece_0/gTriforcePiece0DL_vtx_1 similarity index 100% rename from OTRExporter/assets/objects/object_triforce_piece_0/gTriforcePiece0DL_vtx_1 rename to soh/assets/custom/objects/object_triforce_piece_0/gTriforcePiece0DL_vtx_1 diff --git a/OTRExporter/assets/objects/object_triforce_piece_0/gTriforcePiece0DL_vtx_2 b/soh/assets/custom/objects/object_triforce_piece_0/gTriforcePiece0DL_vtx_2 similarity index 100% rename from OTRExporter/assets/objects/object_triforce_piece_0/gTriforcePiece0DL_vtx_2 rename to soh/assets/custom/objects/object_triforce_piece_0/gTriforcePiece0DL_vtx_2 diff --git a/OTRExporter/assets/objects/object_triforce_piece_0/mat_gTriforcePiece0DL_f3dlite_shard_edge b/soh/assets/custom/objects/object_triforce_piece_0/mat_gTriforcePiece0DL_f3dlite_shard_edge similarity index 100% rename from OTRExporter/assets/objects/object_triforce_piece_0/mat_gTriforcePiece0DL_f3dlite_shard_edge rename to soh/assets/custom/objects/object_triforce_piece_0/mat_gTriforcePiece0DL_f3dlite_shard_edge diff --git a/OTRExporter/assets/objects/object_triforce_piece_0/mat_gTriforcePiece0DL_f3dlite_triforce_edges b/soh/assets/custom/objects/object_triforce_piece_0/mat_gTriforcePiece0DL_f3dlite_triforce_edges similarity index 100% rename from OTRExporter/assets/objects/object_triforce_piece_0/mat_gTriforcePiece0DL_f3dlite_triforce_edges rename to soh/assets/custom/objects/object_triforce_piece_0/mat_gTriforcePiece0DL_f3dlite_triforce_edges diff --git a/OTRExporter/assets/objects/object_triforce_piece_0/mat_gTriforcePiece0DL_f3dlite_triforce_surface b/soh/assets/custom/objects/object_triforce_piece_0/mat_gTriforcePiece0DL_f3dlite_triforce_surface similarity index 100% rename from OTRExporter/assets/objects/object_triforce_piece_0/mat_gTriforcePiece0DL_f3dlite_triforce_surface rename to soh/assets/custom/objects/object_triforce_piece_0/mat_gTriforcePiece0DL_f3dlite_triforce_surface diff --git a/OTRExporter/assets/objects/object_triforce_piece_0/noise_tex b/soh/assets/custom/objects/object_triforce_piece_0/noise_tex similarity index 100% rename from OTRExporter/assets/objects/object_triforce_piece_0/noise_tex rename to soh/assets/custom/objects/object_triforce_piece_0/noise_tex diff --git a/OTRExporter/assets/objects/object_triforce_piece_1/gTriforcePiece1DL b/soh/assets/custom/objects/object_triforce_piece_1/gTriforcePiece1DL similarity index 100% rename from OTRExporter/assets/objects/object_triforce_piece_1/gTriforcePiece1DL rename to soh/assets/custom/objects/object_triforce_piece_1/gTriforcePiece1DL diff --git a/OTRExporter/assets/objects/object_triforce_piece_1/gTriforcePiece1DL_tri_0 b/soh/assets/custom/objects/object_triforce_piece_1/gTriforcePiece1DL_tri_0 similarity index 100% rename from OTRExporter/assets/objects/object_triforce_piece_1/gTriforcePiece1DL_tri_0 rename to soh/assets/custom/objects/object_triforce_piece_1/gTriforcePiece1DL_tri_0 diff --git a/OTRExporter/assets/objects/object_triforce_piece_1/gTriforcePiece1DL_tri_1 b/soh/assets/custom/objects/object_triforce_piece_1/gTriforcePiece1DL_tri_1 similarity index 100% rename from OTRExporter/assets/objects/object_triforce_piece_1/gTriforcePiece1DL_tri_1 rename to soh/assets/custom/objects/object_triforce_piece_1/gTriforcePiece1DL_tri_1 diff --git a/OTRExporter/assets/objects/object_triforce_piece_1/gTriforcePiece1DL_vtx_0 b/soh/assets/custom/objects/object_triforce_piece_1/gTriforcePiece1DL_vtx_0 similarity index 100% rename from OTRExporter/assets/objects/object_triforce_piece_1/gTriforcePiece1DL_vtx_0 rename to soh/assets/custom/objects/object_triforce_piece_1/gTriforcePiece1DL_vtx_0 diff --git a/OTRExporter/assets/objects/object_triforce_piece_1/gTriforcePiece1DL_vtx_1 b/soh/assets/custom/objects/object_triforce_piece_1/gTriforcePiece1DL_vtx_1 similarity index 100% rename from OTRExporter/assets/objects/object_triforce_piece_1/gTriforcePiece1DL_vtx_1 rename to soh/assets/custom/objects/object_triforce_piece_1/gTriforcePiece1DL_vtx_1 diff --git a/OTRExporter/assets/objects/object_triforce_piece_1/mat_gTriforcePiece1DL_f3dlite_shard_edge b/soh/assets/custom/objects/object_triforce_piece_1/mat_gTriforcePiece1DL_f3dlite_shard_edge similarity index 100% rename from OTRExporter/assets/objects/object_triforce_piece_1/mat_gTriforcePiece1DL_f3dlite_shard_edge rename to soh/assets/custom/objects/object_triforce_piece_1/mat_gTriforcePiece1DL_f3dlite_shard_edge diff --git a/OTRExporter/assets/objects/object_triforce_piece_1/mat_gTriforcePiece1DL_f3dlite_triforce_surface b/soh/assets/custom/objects/object_triforce_piece_1/mat_gTriforcePiece1DL_f3dlite_triforce_surface similarity index 100% rename from OTRExporter/assets/objects/object_triforce_piece_1/mat_gTriforcePiece1DL_f3dlite_triforce_surface rename to soh/assets/custom/objects/object_triforce_piece_1/mat_gTriforcePiece1DL_f3dlite_triforce_surface diff --git a/OTRExporter/assets/objects/object_triforce_piece_1/noise_tex b/soh/assets/custom/objects/object_triforce_piece_1/noise_tex similarity index 100% rename from OTRExporter/assets/objects/object_triforce_piece_1/noise_tex rename to soh/assets/custom/objects/object_triforce_piece_1/noise_tex diff --git a/OTRExporter/assets/objects/object_triforce_piece_2/gTriforcePiece2DL b/soh/assets/custom/objects/object_triforce_piece_2/gTriforcePiece2DL similarity index 100% rename from OTRExporter/assets/objects/object_triforce_piece_2/gTriforcePiece2DL rename to soh/assets/custom/objects/object_triforce_piece_2/gTriforcePiece2DL diff --git a/OTRExporter/assets/objects/object_triforce_piece_2/gTriforcePiece2DL_tri_0 b/soh/assets/custom/objects/object_triforce_piece_2/gTriforcePiece2DL_tri_0 similarity index 100% rename from OTRExporter/assets/objects/object_triforce_piece_2/gTriforcePiece2DL_tri_0 rename to soh/assets/custom/objects/object_triforce_piece_2/gTriforcePiece2DL_tri_0 diff --git a/OTRExporter/assets/objects/object_triforce_piece_2/gTriforcePiece2DL_tri_1 b/soh/assets/custom/objects/object_triforce_piece_2/gTriforcePiece2DL_tri_1 similarity index 100% rename from OTRExporter/assets/objects/object_triforce_piece_2/gTriforcePiece2DL_tri_1 rename to soh/assets/custom/objects/object_triforce_piece_2/gTriforcePiece2DL_tri_1 diff --git a/OTRExporter/assets/objects/object_triforce_piece_2/gTriforcePiece2DL_tri_2 b/soh/assets/custom/objects/object_triforce_piece_2/gTriforcePiece2DL_tri_2 similarity index 100% rename from OTRExporter/assets/objects/object_triforce_piece_2/gTriforcePiece2DL_tri_2 rename to soh/assets/custom/objects/object_triforce_piece_2/gTriforcePiece2DL_tri_2 diff --git a/OTRExporter/assets/objects/object_triforce_piece_2/gTriforcePiece2DL_vtx_0 b/soh/assets/custom/objects/object_triforce_piece_2/gTriforcePiece2DL_vtx_0 similarity index 100% rename from OTRExporter/assets/objects/object_triforce_piece_2/gTriforcePiece2DL_vtx_0 rename to soh/assets/custom/objects/object_triforce_piece_2/gTriforcePiece2DL_vtx_0 diff --git a/OTRExporter/assets/objects/object_triforce_piece_2/gTriforcePiece2DL_vtx_1 b/soh/assets/custom/objects/object_triforce_piece_2/gTriforcePiece2DL_vtx_1 similarity index 100% rename from OTRExporter/assets/objects/object_triforce_piece_2/gTriforcePiece2DL_vtx_1 rename to soh/assets/custom/objects/object_triforce_piece_2/gTriforcePiece2DL_vtx_1 diff --git a/OTRExporter/assets/objects/object_triforce_piece_2/gTriforcePiece2DL_vtx_2 b/soh/assets/custom/objects/object_triforce_piece_2/gTriforcePiece2DL_vtx_2 similarity index 100% rename from OTRExporter/assets/objects/object_triforce_piece_2/gTriforcePiece2DL_vtx_2 rename to soh/assets/custom/objects/object_triforce_piece_2/gTriforcePiece2DL_vtx_2 diff --git a/OTRExporter/assets/objects/object_triforce_piece_2/mat_gTriforcePiece2DL_f3dlite_shard_edge b/soh/assets/custom/objects/object_triforce_piece_2/mat_gTriforcePiece2DL_f3dlite_shard_edge similarity index 100% rename from OTRExporter/assets/objects/object_triforce_piece_2/mat_gTriforcePiece2DL_f3dlite_shard_edge rename to soh/assets/custom/objects/object_triforce_piece_2/mat_gTriforcePiece2DL_f3dlite_shard_edge diff --git a/OTRExporter/assets/objects/object_triforce_piece_2/mat_gTriforcePiece2DL_f3dlite_triforce_edges b/soh/assets/custom/objects/object_triforce_piece_2/mat_gTriforcePiece2DL_f3dlite_triforce_edges similarity index 100% rename from OTRExporter/assets/objects/object_triforce_piece_2/mat_gTriforcePiece2DL_f3dlite_triforce_edges rename to soh/assets/custom/objects/object_triforce_piece_2/mat_gTriforcePiece2DL_f3dlite_triforce_edges diff --git a/OTRExporter/assets/objects/object_triforce_piece_2/mat_gTriforcePiece2DL_f3dlite_triforce_surface b/soh/assets/custom/objects/object_triforce_piece_2/mat_gTriforcePiece2DL_f3dlite_triforce_surface similarity index 100% rename from OTRExporter/assets/objects/object_triforce_piece_2/mat_gTriforcePiece2DL_f3dlite_triforce_surface rename to soh/assets/custom/objects/object_triforce_piece_2/mat_gTriforcePiece2DL_f3dlite_triforce_surface diff --git a/OTRExporter/assets/objects/object_triforce_piece_2/noise_tex b/soh/assets/custom/objects/object_triforce_piece_2/noise_tex similarity index 100% rename from OTRExporter/assets/objects/object_triforce_piece_2/noise_tex rename to soh/assets/custom/objects/object_triforce_piece_2/noise_tex diff --git a/OTRExporter/assets/scenes/nonmq/syotes_scene/syotes_room_0 b/soh/assets/custom/scenes/nonmq/syotes_scene/syotes_room_0 similarity index 100% rename from OTRExporter/assets/scenes/nonmq/syotes_scene/syotes_room_0 rename to soh/assets/custom/scenes/nonmq/syotes_scene/syotes_room_0 diff --git a/OTRExporter/assets/textures/buttons/ABtn.png b/soh/assets/custom/textures/buttons/ABtn.png similarity index 100% rename from OTRExporter/assets/textures/buttons/ABtn.png rename to soh/assets/custom/textures/buttons/ABtn.png diff --git a/OTRExporter/assets/textures/buttons/BBtn.png b/soh/assets/custom/textures/buttons/BBtn.png similarity index 100% rename from OTRExporter/assets/textures/buttons/BBtn.png rename to soh/assets/custom/textures/buttons/BBtn.png diff --git a/OTRExporter/assets/textures/buttons/CDown.png b/soh/assets/custom/textures/buttons/CDown.png similarity index 100% rename from OTRExporter/assets/textures/buttons/CDown.png rename to soh/assets/custom/textures/buttons/CDown.png diff --git a/OTRExporter/assets/textures/buttons/CLeft.png b/soh/assets/custom/textures/buttons/CLeft.png similarity index 100% rename from OTRExporter/assets/textures/buttons/CLeft.png rename to soh/assets/custom/textures/buttons/CLeft.png diff --git a/OTRExporter/assets/textures/buttons/CRight.png b/soh/assets/custom/textures/buttons/CRight.png similarity index 100% rename from OTRExporter/assets/textures/buttons/CRight.png rename to soh/assets/custom/textures/buttons/CRight.png diff --git a/OTRExporter/assets/textures/buttons/CUp.png b/soh/assets/custom/textures/buttons/CUp.png similarity index 100% rename from OTRExporter/assets/textures/buttons/CUp.png rename to soh/assets/custom/textures/buttons/CUp.png diff --git a/OTRExporter/assets/textures/buttons/LBtn.png b/soh/assets/custom/textures/buttons/LBtn.png similarity index 100% rename from OTRExporter/assets/textures/buttons/LBtn.png rename to soh/assets/custom/textures/buttons/LBtn.png diff --git a/OTRExporter/assets/textures/buttons/RBtn.png b/soh/assets/custom/textures/buttons/RBtn.png similarity index 100% rename from OTRExporter/assets/textures/buttons/RBtn.png rename to soh/assets/custom/textures/buttons/RBtn.png diff --git a/OTRExporter/assets/textures/buttons/StartBtn.png b/soh/assets/custom/textures/buttons/StartBtn.png similarity index 100% rename from OTRExporter/assets/textures/buttons/StartBtn.png rename to soh/assets/custom/textures/buttons/StartBtn.png diff --git a/OTRExporter/assets/textures/buttons/ZBtn.png b/soh/assets/custom/textures/buttons/ZBtn.png similarity index 100% rename from OTRExporter/assets/textures/buttons/ZBtn.png rename to soh/assets/custom/textures/buttons/ZBtn.png diff --git a/OTRExporter/assets/textures/icons/gIcon.png b/soh/assets/custom/textures/icons/gIcon.png similarity index 100% rename from OTRExporter/assets/textures/icons/gIcon.png rename to soh/assets/custom/textures/icons/gIcon.png diff --git a/OTRExporter/assets/textures/nintendo_rogo_static/SoHShiny b/soh/assets/custom/textures/nintendo_rogo_static/SoHShiny similarity index 100% rename from OTRExporter/assets/textures/nintendo_rogo_static/SoHShiny rename to soh/assets/custom/textures/nintendo_rogo_static/SoHShiny diff --git a/OTRExporter/assets/textures/nintendo_rogo_static/gShipLogoDL b/soh/assets/custom/textures/nintendo_rogo_static/gShipLogoDL similarity index 100% rename from OTRExporter/assets/textures/nintendo_rogo_static/gShipLogoDL rename to soh/assets/custom/textures/nintendo_rogo_static/gShipLogoDL diff --git a/OTRExporter/assets/textures/nintendo_rogo_static/gShipLogoDL_tri_0 b/soh/assets/custom/textures/nintendo_rogo_static/gShipLogoDL_tri_0 similarity index 100% rename from OTRExporter/assets/textures/nintendo_rogo_static/gShipLogoDL_tri_0 rename to soh/assets/custom/textures/nintendo_rogo_static/gShipLogoDL_tri_0 diff --git a/OTRExporter/assets/textures/nintendo_rogo_static/gShipLogoDL_tri_1 b/soh/assets/custom/textures/nintendo_rogo_static/gShipLogoDL_tri_1 similarity index 100% rename from OTRExporter/assets/textures/nintendo_rogo_static/gShipLogoDL_tri_1 rename to soh/assets/custom/textures/nintendo_rogo_static/gShipLogoDL_tri_1 diff --git a/OTRExporter/assets/textures/nintendo_rogo_static/gShipLogoDL_tri_2 b/soh/assets/custom/textures/nintendo_rogo_static/gShipLogoDL_tri_2 similarity index 100% rename from OTRExporter/assets/textures/nintendo_rogo_static/gShipLogoDL_tri_2 rename to soh/assets/custom/textures/nintendo_rogo_static/gShipLogoDL_tri_2 diff --git a/OTRExporter/assets/textures/nintendo_rogo_static/gShipLogoDL_tri_3 b/soh/assets/custom/textures/nintendo_rogo_static/gShipLogoDL_tri_3 similarity index 100% rename from OTRExporter/assets/textures/nintendo_rogo_static/gShipLogoDL_tri_3 rename to soh/assets/custom/textures/nintendo_rogo_static/gShipLogoDL_tri_3 diff --git a/OTRExporter/assets/textures/nintendo_rogo_static/gShipLogoDL_vtx_0 b/soh/assets/custom/textures/nintendo_rogo_static/gShipLogoDL_vtx_0 similarity index 100% rename from OTRExporter/assets/textures/nintendo_rogo_static/gShipLogoDL_vtx_0 rename to soh/assets/custom/textures/nintendo_rogo_static/gShipLogoDL_vtx_0 diff --git a/OTRExporter/assets/textures/nintendo_rogo_static/gShipLogoDL_vtx_1 b/soh/assets/custom/textures/nintendo_rogo_static/gShipLogoDL_vtx_1 similarity index 100% rename from OTRExporter/assets/textures/nintendo_rogo_static/gShipLogoDL_vtx_1 rename to soh/assets/custom/textures/nintendo_rogo_static/gShipLogoDL_vtx_1 diff --git a/OTRExporter/assets/textures/nintendo_rogo_static/gShipLogoDL_vtx_2 b/soh/assets/custom/textures/nintendo_rogo_static/gShipLogoDL_vtx_2 similarity index 100% rename from OTRExporter/assets/textures/nintendo_rogo_static/gShipLogoDL_vtx_2 rename to soh/assets/custom/textures/nintendo_rogo_static/gShipLogoDL_vtx_2 diff --git a/OTRExporter/assets/textures/nintendo_rogo_static/gShipLogoDL_vtx_3 b/soh/assets/custom/textures/nintendo_rogo_static/gShipLogoDL_vtx_3 similarity index 100% rename from OTRExporter/assets/textures/nintendo_rogo_static/gShipLogoDL_vtx_3 rename to soh/assets/custom/textures/nintendo_rogo_static/gShipLogoDL_vtx_3 diff --git a/OTRExporter/assets/textures/nintendo_rogo_static/mat_gShipLogoDL_f3d_material b/soh/assets/custom/textures/nintendo_rogo_static/mat_gShipLogoDL_f3d_material similarity index 100% rename from OTRExporter/assets/textures/nintendo_rogo_static/mat_gShipLogoDL_f3d_material rename to soh/assets/custom/textures/nintendo_rogo_static/mat_gShipLogoDL_f3d_material diff --git a/OTRExporter/assets/textures/nintendo_rogo_static/mat_gShipLogoDL_f3d_material_001 b/soh/assets/custom/textures/nintendo_rogo_static/mat_gShipLogoDL_f3d_material_001 similarity index 100% rename from OTRExporter/assets/textures/nintendo_rogo_static/mat_gShipLogoDL_f3d_material_001 rename to soh/assets/custom/textures/nintendo_rogo_static/mat_gShipLogoDL_f3d_material_001 diff --git a/OTRExporter/assets/textures/nintendo_rogo_static/mat_gShipLogoDL_f3d_material_002 b/soh/assets/custom/textures/nintendo_rogo_static/mat_gShipLogoDL_f3d_material_002 similarity index 100% rename from OTRExporter/assets/textures/nintendo_rogo_static/mat_gShipLogoDL_f3d_material_002 rename to soh/assets/custom/textures/nintendo_rogo_static/mat_gShipLogoDL_f3d_material_002 diff --git a/OTRExporter/assets/textures/nintendo_rogo_static/mat_gShipLogoDL_f3d_material_003 b/soh/assets/custom/textures/nintendo_rogo_static/mat_gShipLogoDL_f3d_material_003 similarity index 100% rename from OTRExporter/assets/textures/nintendo_rogo_static/mat_gShipLogoDL_f3d_material_003 rename to soh/assets/custom/textures/nintendo_rogo_static/mat_gShipLogoDL_f3d_material_003 diff --git a/OTRExporter/assets/textures/nintendo_rogo_static/mat_revert_gShipLogoDL_f3d_material b/soh/assets/custom/textures/nintendo_rogo_static/mat_revert_gShipLogoDL_f3d_material similarity index 100% rename from OTRExporter/assets/textures/nintendo_rogo_static/mat_revert_gShipLogoDL_f3d_material rename to soh/assets/custom/textures/nintendo_rogo_static/mat_revert_gShipLogoDL_f3d_material diff --git a/OTRExporter/assets/textures/nintendo_rogo_static/mat_revert_gShipLogoDL_f3d_material_001 b/soh/assets/custom/textures/nintendo_rogo_static/mat_revert_gShipLogoDL_f3d_material_001 similarity index 100% rename from OTRExporter/assets/textures/nintendo_rogo_static/mat_revert_gShipLogoDL_f3d_material_001 rename to soh/assets/custom/textures/nintendo_rogo_static/mat_revert_gShipLogoDL_f3d_material_001 diff --git a/OTRExporter/assets/textures/nintendo_rogo_static/mat_revert_gShipLogoDL_f3d_material_002 b/soh/assets/custom/textures/nintendo_rogo_static/mat_revert_gShipLogoDL_f3d_material_002 similarity index 100% rename from OTRExporter/assets/textures/nintendo_rogo_static/mat_revert_gShipLogoDL_f3d_material_002 rename to soh/assets/custom/textures/nintendo_rogo_static/mat_revert_gShipLogoDL_f3d_material_002 diff --git a/OTRExporter/assets/textures/nintendo_rogo_static/mat_revert_gShipLogoDL_f3d_material_003 b/soh/assets/custom/textures/nintendo_rogo_static/mat_revert_gShipLogoDL_f3d_material_003 similarity index 100% rename from OTRExporter/assets/textures/nintendo_rogo_static/mat_revert_gShipLogoDL_f3d_material_003 rename to soh/assets/custom/textures/nintendo_rogo_static/mat_revert_gShipLogoDL_f3d_material_003 diff --git a/OTRExporter/assets/textures/nintendo_rogo_static/nintendo_rogo_static_Tex_LUS_000000 b/soh/assets/custom/textures/nintendo_rogo_static/nintendo_rogo_static_Tex_LUS_000000 similarity index 100% rename from OTRExporter/assets/textures/nintendo_rogo_static/nintendo_rogo_static_Tex_LUS_000000 rename to soh/assets/custom/textures/nintendo_rogo_static/nintendo_rogo_static_Tex_LUS_000000 diff --git a/OTRExporter/assets/textures/parameter_static/gArrowDown.ia16.png b/soh/assets/custom/textures/parameter_static/gArrowDown.ia16.png similarity index 100% rename from OTRExporter/assets/textures/parameter_static/gArrowDown.ia16.png rename to soh/assets/custom/textures/parameter_static/gArrowDown.ia16.png diff --git a/OTRExporter/assets/textures/parameter_static/gArrowUp.ia16.png b/soh/assets/custom/textures/parameter_static/gArrowUp.ia16.png similarity index 100% rename from OTRExporter/assets/textures/parameter_static/gArrowUp.ia16.png rename to soh/assets/custom/textures/parameter_static/gArrowUp.ia16.png diff --git a/OTRExporter/assets/textures/parameter_static/gDPad.ia16.png b/soh/assets/custom/textures/parameter_static/gDPad.ia16.png similarity index 100% rename from OTRExporter/assets/textures/parameter_static/gDPad.ia16.png rename to soh/assets/custom/textures/parameter_static/gDPad.ia16.png diff --git a/OTRExporter/assets/textures/parameter_static/gTriforcePiece.rgba32.png b/soh/assets/custom/textures/parameter_static/gTriforcePiece.rgba32.png similarity index 100% rename from OTRExporter/assets/textures/parameter_static/gTriforcePiece.rgba32.png rename to soh/assets/custom/textures/parameter_static/gTriforcePiece.rgba32.png diff --git a/OTRExporter/assets/textures/title_static/gFileSelBossRushSettingsENGTex.ia8.png b/soh/assets/custom/textures/title_static/gFileSelBossRushSettingsENGTex.ia8.png similarity index 100% rename from OTRExporter/assets/textures/title_static/gFileSelBossRushSettingsENGTex.ia8.png rename to soh/assets/custom/textures/title_static/gFileSelBossRushSettingsENGTex.ia8.png diff --git a/OTRExporter/assets/textures/title_static/gFileSelBossRushSettingsFRATex.ia8.png b/soh/assets/custom/textures/title_static/gFileSelBossRushSettingsFRATex.ia8.png similarity index 100% rename from OTRExporter/assets/textures/title_static/gFileSelBossRushSettingsFRATex.ia8.png rename to soh/assets/custom/textures/title_static/gFileSelBossRushSettingsFRATex.ia8.png diff --git a/OTRExporter/assets/textures/title_static/gFileSelBossRushSettingsGERTex.ia8.png b/soh/assets/custom/textures/title_static/gFileSelBossRushSettingsGERTex.ia8.png similarity index 100% rename from OTRExporter/assets/textures/title_static/gFileSelBossRushSettingsGERTex.ia8.png rename to soh/assets/custom/textures/title_static/gFileSelBossRushSettingsGERTex.ia8.png diff --git a/OTRExporter/assets/textures/title_static/gFileSelMQButtonTex.ia16.png b/soh/assets/custom/textures/title_static/gFileSelMQButtonTex.ia16.png similarity index 100% rename from OTRExporter/assets/textures/title_static/gFileSelMQButtonTex.ia16.png rename to soh/assets/custom/textures/title_static/gFileSelMQButtonTex.ia16.png diff --git a/OTRExporter/assets/textures/title_static/gFileSelPleaseChooseAQuestENGTex.ia8.png b/soh/assets/custom/textures/title_static/gFileSelPleaseChooseAQuestENGTex.ia8.png similarity index 100% rename from OTRExporter/assets/textures/title_static/gFileSelPleaseChooseAQuestENGTex.ia8.png rename to soh/assets/custom/textures/title_static/gFileSelPleaseChooseAQuestENGTex.ia8.png diff --git a/OTRExporter/assets/textures/title_static/gFileSelPleaseChooseAQuestFRATex.ia8.png b/soh/assets/custom/textures/title_static/gFileSelPleaseChooseAQuestFRATex.ia8.png similarity index 100% rename from OTRExporter/assets/textures/title_static/gFileSelPleaseChooseAQuestFRATex.ia8.png rename to soh/assets/custom/textures/title_static/gFileSelPleaseChooseAQuestFRATex.ia8.png diff --git a/OTRExporter/assets/textures/title_static/gFileSelPleaseChooseAQuestGERTex.ia8.png b/soh/assets/custom/textures/title_static/gFileSelPleaseChooseAQuestGERTex.ia8.png similarity index 100% rename from OTRExporter/assets/textures/title_static/gFileSelPleaseChooseAQuestGERTex.ia8.png rename to soh/assets/custom/textures/title_static/gFileSelPleaseChooseAQuestGERTex.ia8.png diff --git a/OTRExporter/assets/textures/title_static/gFileSelRANDButtonTex.ia16.png b/soh/assets/custom/textures/title_static/gFileSelRANDButtonTex.ia16.png similarity index 100% rename from OTRExporter/assets/textures/title_static/gFileSelRANDButtonTex.ia16.png rename to soh/assets/custom/textures/title_static/gFileSelRANDButtonTex.ia16.png diff --git a/OTRExporter/assets/textures/virtual/gEmptyTexture.rgba32.png b/soh/assets/custom/textures/virtual/gEmptyTexture.rgba32.png similarity index 100% rename from OTRExporter/assets/textures/virtual/gEmptyTexture.rgba32.png rename to soh/assets/custom/textures/virtual/gEmptyTexture.rgba32.png diff --git a/soh/assets/xml/GC_NMQ_D/code/fbdemo_triforce.xml b/soh/assets/xml/GC_NMQ_D/code/fbdemo_triforce.xml index a20e07075..9f39f4df9 100644 --- a/soh/assets/xml/GC_NMQ_D/code/fbdemo_triforce.xml +++ b/soh/assets/xml/GC_NMQ_D/code/fbdemo_triforce.xml @@ -1,7 +1,7 @@ - - - + + + diff --git a/soh/include/functions.h b/soh/include/functions.h index 6b7732ae9..3a1aa8ae2 100644 --- a/soh/include/functions.h +++ b/soh/include/functions.h @@ -1090,8 +1090,8 @@ s32 Health_ChangeBy(PlayState* play, s16 healthChange); void Rupees_ChangeBy(s16 rupeeChange); void Inventory_ChangeAmmo(s16 item, s16 ammoChange); void Magic_Fill(PlayState* play); -void func_800876C8(PlayState* play); -s32 func_80087708(PlayState* play, s16 arg1, s16 arg2); +void Magic_Reset(PlayState* play); +s32 Magic_RequestChange(PlayState* play, s16 amount, s16 type); void func_80088AA0(s16 seconds); void func_80088AF0(PlayState* play); void func_80088B34(s16 arg0); @@ -2449,13 +2449,18 @@ void Heaps_Free(void); CollisionHeader* BgCheck_GetCollisionHeader(CollisionContext* colCtx, s32 bgId); -void Interface_CreateQuadVertexGroup(Vtx* vtxList, s32 xStart, s32 yStart, s32 width, s32 height, u8 flippedH); - // Exposing these methods to leverage them from the file select screen to render messages void Message_OpenText(PlayState* play, u16 textId); void Message_Decode(PlayState* play); void Message_DrawText(PlayState* play, Gfx** gfxP); +// #region SOH [General] + +void Interface_CreateQuadVertexGroup(Vtx* vtxList, s32 xStart, s32 yStart, s32 width, s32 height, u8 flippedH); +void Interface_RandoRestoreSwordless(void); + +// #endregion + #ifdef __cplusplus #undef this }; diff --git a/soh/include/macros.h b/soh/include/macros.h index 5157315ac..93f7e17c6 100644 --- a/soh/include/macros.h +++ b/soh/include/macros.h @@ -292,11 +292,6 @@ extern GraphicsContext* __gfxCtx; #define SEG_ADDR(seg, addr) (addr | (seg << 24) | 1) // #endregion -// #region SOH [Enhancements] -#define CHECK_EQUIPMENT_AGE(i, j) (CVarGetInteger("gTimelessEquipment", 0) || (gEquipAgeReqs[i][j] == 9) || (gEquipAgeReqs[i][j] == ((void)0, gSaveContext.linkAge))) -#define CHECK_SLOT_AGE(slotIndex) (CVarGetInteger("gTimelessEquipment", 0) || (gSlotAgeReqs[slotIndex] == 9) || gSlotAgeReqs[slotIndex] == ((void)0, gSaveContext.linkAge)) -#define CHECK_ITEM_AGE(itemIndex) (CVarGetInteger("gTimelessEquipment", 0) || (gItemAgeReqs[itemIndex] == 9) || (gItemAgeReqs[itemIndex] == gSaveContext.linkAge)) - #define DPAD_ITEM(button) ((gSaveContext.buttonStatus[(button) + 5] != BTN_DISABLED) \ ? gSaveContext.equips.buttonItems[(button) + 4] \ : ITEM_NONE) diff --git a/soh/include/variables.h b/soh/include/variables.h index ee73d003b..200080bfa 100644 --- a/soh/include/variables.h +++ b/soh/include/variables.h @@ -82,7 +82,7 @@ extern "C" extern s16 gSpoilingItems[3]; extern s16 gSpoilingItemReverts[3]; extern FlexSkeletonHeader* gPlayerSkelHeaders[2]; - extern u8 gPlayerModelTypes[][5]; + extern u8 gPlayerModelTypes[PLAYER_MODELGROUP_MAX][PLAYER_MODELGROUPENTRY_MAX]; extern Gfx* gPlayerLeftHandBgsDLs[]; extern Gfx* gPlayerLeftHandOpenDLs[]; extern Gfx* gPlayerLeftHandClosedDLs[]; diff --git a/soh/include/z64.h b/soh/include/z64.h index 2172dcb74..23ffcfb17 100644 --- a/soh/include/z64.h +++ b/soh/include/z64.h @@ -2245,6 +2245,8 @@ typedef enum { LED_SOURCE_TUNIC_ORIGINAL, LED_SOURCE_TUNIC_COSMETICS, LED_SOURCE_HEALTH, + LED_SOURCE_NAVI_ORIGINAL, + LED_SOURCE_NAVI_COSMETICS, LED_SOURCE_CUSTOM } LEDColorSource; diff --git a/soh/include/z64item.h b/soh/include/z64item.h index 2f0038872..1fc919a45 100644 --- a/soh/include/z64item.h +++ b/soh/include/z64item.h @@ -2,12 +2,74 @@ #define Z64ITEM_H typedef enum { - /* 0x00 */ EQUIP_SWORD, - /* 0x01 */ EQUIP_SHIELD, - /* 0x02 */ EQUIP_TUNIC, - /* 0x03 */ EQUIP_BOOTS + /* 0 */ EQUIP_TYPE_SWORD, + /* 1 */ EQUIP_TYPE_SHIELD, + /* 2 */ EQUIP_TYPE_TUNIC, + /* 3 */ EQUIP_TYPE_BOOTS, + /* 4 */ EQUIP_TYPE_MAX } EquipmentType; +// `EquipInv*` enums are for Inventory.equipment (for example used in the `CHECK_OWNED_EQUIP` macro) + +typedef enum { + /* 0 */ EQUIP_INV_SWORD_KOKIRI, + /* 1 */ EQUIP_INV_SWORD_MASTER, + /* 2 */ EQUIP_INV_SWORD_BIGGORON, + /* 3 */ EQUIP_INV_SWORD_BROKENGIANTKNIFE +} EquipInvSword; + +typedef enum { + /* 0 */ EQUIP_INV_SHIELD_DEKU, + /* 1 */ EQUIP_INV_SHIELD_HYLIAN, + /* 2 */ EQUIP_INV_SHIELD_MIRROR +} EquipInvShield; + +typedef enum { + /* 0 */ EQUIP_INV_TUNIC_KOKIRI, + /* 1 */ EQUIP_INV_TUNIC_GORON, + /* 2 */ EQUIP_INV_TUNIC_ZORA +} EquipInvTunic; + +typedef enum { + /* 0 */ EQUIP_INV_BOOTS_KOKIRI, + /* 1 */ EQUIP_INV_BOOTS_IRON, + /* 2 */ EQUIP_INV_BOOTS_HOVER +} EquipInvBoots; + +// `EquipValue*` enums are for ItemEquips.equipment (for example used in the `CUR_EQUIP_VALUE` macro) + +typedef enum { + /* 0 */ EQUIP_VALUE_SWORD_NONE, + /* 1 */ EQUIP_VALUE_SWORD_KOKIRI, + /* 2 */ EQUIP_VALUE_SWORD_MASTER, + /* 3 */ EQUIP_VALUE_SWORD_BIGGORON, + /* 4 */ EQUIP_VALUE_SWORD_MAX +} EquipValueSword; + +typedef enum { + /* 0 */ EQUIP_VALUE_SHIELD_NONE, + /* 1 */ EQUIP_VALUE_SHIELD_DEKU, + /* 2 */ EQUIP_VALUE_SHIELD_HYLIAN, + /* 3 */ EQUIP_VALUE_SHIELD_MIRROR, + /* 4 */ EQUIP_VALUE_SHIELD_MAX +} EquipValueShield; + +typedef enum { + /* 0 */ EQUIP_VALUE_TUNIC_NONE, + /* 1 */ EQUIP_VALUE_TUNIC_KOKIRI, + /* 2 */ EQUIP_VALUE_TUNIC_GORON, + /* 3 */ EQUIP_VALUE_TUNIC_ZORA, + /* 4 */ EQUIP_VALUE_TUNIC_MAX +} EquipValueTunic; + +typedef enum { + /* 0 */ EQUIP_VALUE_BOOTS_NONE, + /* 1 */ EQUIP_VALUE_BOOTS_KOKIRI, + /* 2 */ EQUIP_VALUE_BOOTS_IRON, + /* 3 */ EQUIP_VALUE_BOOTS_HOVER, + /* 4 */ EQUIP_VALUE_BOOTS_MAX +} EquipValueBoots; + typedef enum { /* 0x00 */ UPG_QUIVER, /* 0x01 */ UPG_BOMB_BAG, diff --git a/soh/include/z64save.h b/soh/include/z64save.h index 4b87a179a..9458f28c7 100644 --- a/soh/include/z64save.h +++ b/soh/include/z64save.h @@ -289,7 +289,6 @@ typedef struct { /* */ u8 mqDungeonCount; /* */ u8 pendingIceTrapCount; /* */ SohStats sohStats; - /* */ u8 temporaryWeapon; /* */ FaroresWindData backupFW; /* */ RandomizerCheckTrackerData checkTrackerData[RC_MAX]; // #endregion @@ -302,11 +301,11 @@ typedef struct { /* */ char childAltarText[250]; /* */ char adultAltarText[750]; /* */ RandomizerCheck rewardCheck[9]; - /* */ char ganonHintText[150]; + /* */ char ganonHintText[300]; /* */ char gregHintText[250]; /* */ char ganonText[250]; /* */ char dampeText[150]; - /* */ char sheikText[150]; + /* */ char sheikText[200]; /* */ char sariaText[150]; /* */ char warpMinuetText[100]; /* */ char warpBoleroText[100]; @@ -314,6 +313,7 @@ typedef struct { /* */ char warpRequiemText[100]; /* */ char warpNocturneText[100]; /* */ char warpPreludeText[100]; + /* */ RandomizerCheck masterSwordHintCheck; /* */ RandomizerCheck lightArrowHintCheck; /* */ RandomizerCheck sariaCheck; /* */ RandomizerCheck gregCheck; diff --git a/soh/macosx/soh-macos.sh b/soh/macosx/soh-macos.sh index f32fb6363..4b5871892 100755 --- a/soh/macosx/soh-macos.sh +++ b/soh/macosx/soh-macos.sh @@ -180,9 +180,7 @@ if [ ! -e "$SHIP_HOME"/oot.otr ] || [ ! -e "$SHIP_HOME"/oot-mq.otr ]; then export ASSETDIR cp -r "$RESPATH/assets" "$ASSETDIR" mkdir -p "$ASSETDIR"/tmp - mkdir -p "$ASSETDIR"/Extract cp "$ROMPATH" "$ASSETDIR"/tmp/rom.z64 - cp -r "$ASSETDIR"/assets/game "$ASSETDIR"/Extract/assets/ cd "$ASSETDIR" || return # If an invalid rom was detected, let the user know diff --git a/soh/soh/Enhancements/audio/AudioCollection.cpp b/soh/soh/Enhancements/audio/AudioCollection.cpp index 960627b34..63456f748 100644 --- a/soh/soh/Enhancements/audio/AudioCollection.cpp +++ b/soh/soh/Enhancements/audio/AudioCollection.cpp @@ -8,301 +8,323 @@ #include #include -#define SEQUENCE_MAP_ENTRY(sequenceId, label, sfxKey, category) \ - { sequenceId, { sequenceId, label, sfxKey, category } } +#define SEQUENCE_MAP_ENTRY(sequenceId, label, sfxKey, category, canBeReplaced, canBeUsedAsReplacement) \ + { sequenceId, { sequenceId, label, sfxKey, category, canBeReplaced, canBeUsedAsReplacement } } AudioCollection::AudioCollection() { - // (originalSequenceId, label, sfxKey, category), + // (originalSequenceId, label, sfxKey, category, canBeReplaced, canBeUsedAsReplacement), sequenceMap = { - SEQUENCE_MAP_ENTRY(NA_BGM_FIELD_LOGIC, "Hyrule Field", "NA_BGM_FIELD_LOGIC", SEQ_BGM_WORLD), - SEQUENCE_MAP_ENTRY(NA_BGM_DUNGEON, "Dodongo's Cavern", "NA_BGM_DUNGEON", SEQ_BGM_WORLD), - SEQUENCE_MAP_ENTRY(NA_BGM_KAKARIKO_ADULT, "Kakariko Village (Adult)", "NA_BGM_KAKARIKO_ADULT", SEQ_BGM_WORLD), - SEQUENCE_MAP_ENTRY(NA_BGM_ENEMY, "Battle", "NA_BGM_ENEMY", SEQ_BGM_BATTLE), - SEQUENCE_MAP_ENTRY(NA_BGM_BOSS, "Boss Battle", "NA_BGM_BOSS", SEQ_BGM_BATTLE), - SEQUENCE_MAP_ENTRY(NA_BGM_INSIDE_DEKU_TREE, "Inside the Deku Tree", "NA_BGM_INSIDE_DEKU_TREE", SEQ_BGM_WORLD), - SEQUENCE_MAP_ENTRY(NA_BGM_MARKET, "Market", "NA_BGM_MARKET", SEQ_BGM_WORLD), - SEQUENCE_MAP_ENTRY(NA_BGM_TITLE, "Title Theme", "NA_BGM_TITLE", SEQ_BGM_WORLD), - SEQUENCE_MAP_ENTRY(NA_BGM_LINK_HOUSE, "House", "NA_BGM_LINK_HOUSE", SEQ_BGM_WORLD), - SEQUENCE_MAP_ENTRY(NA_BGM_GAME_OVER, "Game Over", "NA_BGM_GAME_OVER", SEQ_FANFARE), - SEQUENCE_MAP_ENTRY(NA_BGM_BOSS_CLEAR, "Boss Clear", "NA_BGM_BOSS_CLEAR", SEQ_FANFARE), - SEQUENCE_MAP_ENTRY(NA_BGM_ITEM_GET, "Obtain Item", "NA_BGM_ITEM_GET", SEQ_FANFARE), - SEQUENCE_MAP_ENTRY(NA_BGM_OPENING_GANON, "Enter Ganondorf", "NA_BGM_OPENING_GANON", SEQ_FANFARE), - SEQUENCE_MAP_ENTRY(NA_BGM_HEART_GET, "Obtain Heart Container", "NA_BGM_HEART_GET", SEQ_FANFARE), - SEQUENCE_MAP_ENTRY(NA_BGM_OCA_LIGHT, "Prelude of Light", "NA_BGM_OCA_LIGHT", SEQ_OCARINA), - SEQUENCE_MAP_ENTRY(NA_BGM_JABU_JABU, "Inside Jabu-Jabu's Belly", "NA_BGM_JABU_JABU", SEQ_BGM_WORLD), - SEQUENCE_MAP_ENTRY(NA_BGM_KAKARIKO_KID, "Kakariko Village (Child)", "NA_BGM_KAKARIKO_KID", SEQ_BGM_WORLD), - SEQUENCE_MAP_ENTRY(NA_BGM_GREAT_FAIRY, "Great Fairy's Fountain", "NA_BGM_GREAT_FAIRY", SEQ_BGM_EVENT), - SEQUENCE_MAP_ENTRY(NA_BGM_ZELDA_THEME, "Zelda's Theme", "NA_BGM_ZELDA_THEME", SEQ_BGM_EVENT), - SEQUENCE_MAP_ENTRY(NA_BGM_FIRE_TEMPLE, "Fire Temple", "NA_BGM_FIRE_TEMPLE", SEQ_BGM_WORLD), - SEQUENCE_MAP_ENTRY(NA_BGM_OPEN_TRE_BOX, "Open Treasure Chest", "NA_BGM_OPEN_TRE_BOX", SEQ_FANFARE), - SEQUENCE_MAP_ENTRY(NA_BGM_FOREST_TEMPLE, "Forest Temple", "NA_BGM_FOREST_TEMPLE", SEQ_BGM_WORLD), - SEQUENCE_MAP_ENTRY(NA_BGM_COURTYARD, "Hyrule Castle Courtyard", "NA_BGM_COURTYARD", SEQ_BGM_WORLD), - SEQUENCE_MAP_ENTRY(NA_BGM_GANON_TOWER, "Ganondorf's Theme", "NA_BGM_GANON_TOWER", SEQ_BGM_WORLD), - SEQUENCE_MAP_ENTRY(NA_BGM_LONLON, "Lon Lon Ranch", "NA_BGM_LONLON", SEQ_BGM_WORLD), - SEQUENCE_MAP_ENTRY(NA_BGM_GORON_CITY, "Goron City", "NA_BGM_GORON_CITY", SEQ_BGM_WORLD), - SEQUENCE_MAP_ENTRY(NA_BGM_FIELD_MORNING, "Hyrule Field Morning Theme", "NA_BGM_FIELD_MORNING", SEQ_NOSHUFFLE), - SEQUENCE_MAP_ENTRY(NA_BGM_SPIRITUAL_STONE, "Spiritual Stone Get", "NA_BGM_SPIRITUAL_STONE", SEQ_FANFARE), - SEQUENCE_MAP_ENTRY(NA_BGM_OCA_BOLERO, "Bolero of Fire", "NA_BGM_OCA_BOLERO", SEQ_OCARINA), - SEQUENCE_MAP_ENTRY(NA_BGM_OCA_MINUET, "Minuet of Forest", "NA_BGM_OCA_MINUET", SEQ_OCARINA), - SEQUENCE_MAP_ENTRY(NA_BGM_OCA_SERENADE, "Serenade of Water", "NA_BGM_OCA_SERENADE", SEQ_OCARINA), - SEQUENCE_MAP_ENTRY(NA_BGM_OCA_REQUIEM, "Requiem of Spirit", "NA_BGM_OCA_REQUIEM", SEQ_OCARINA), - SEQUENCE_MAP_ENTRY(NA_BGM_OCA_NOCTURNE, "Nocturne of Shadow", "NA_BGM_OCA_NOCTURNE", SEQ_OCARINA), - SEQUENCE_MAP_ENTRY(NA_BGM_MINI_BOSS, "Mini-Boss Battle", "NA_BGM_MINI_BOSS", SEQ_BGM_BATTLE), - SEQUENCE_MAP_ENTRY(NA_BGM_SMALL_ITEM_GET, "Obtain Small Item", "NA_BGM_SMALL_ITEM_GET", SEQ_FANFARE), - SEQUENCE_MAP_ENTRY(NA_BGM_TEMPLE_OF_TIME, "Temple of Time", "NA_BGM_TEMPLE_OF_TIME", SEQ_BGM_WORLD), - SEQUENCE_MAP_ENTRY(NA_BGM_EVENT_CLEAR, "Escape from Lon Lon Ranch", "NA_BGM_EVENT_CLEAR", SEQ_FANFARE), - SEQUENCE_MAP_ENTRY(NA_BGM_KOKIRI, "Kokiri Forest", "NA_BGM_KOKIRI", SEQ_BGM_WORLD), - SEQUENCE_MAP_ENTRY(NA_BGM_OCA_FAIRY_GET, "Obtain Fairy Ocarina", "NA_BGM_OCA_FAIRY_GET", SEQ_FANFARE), - SEQUENCE_MAP_ENTRY(NA_BGM_SARIA_THEME, "Lost Woods", "NA_BGM_SARIA_THEME", SEQ_BGM_WORLD), - SEQUENCE_MAP_ENTRY(NA_BGM_SPIRIT_TEMPLE, "Spirit Temple", "NA_BGM_SPIRIT_TEMPLE", SEQ_BGM_WORLD), - SEQUENCE_MAP_ENTRY(NA_BGM_HORSE, "Horse Race", "NA_BGM_HORSE", SEQ_BGM_EVENT), - SEQUENCE_MAP_ENTRY(NA_BGM_HORSE_GOAL, "Horse Race Goal", "NA_BGM_HORSE_GOAL", SEQ_FANFARE), - SEQUENCE_MAP_ENTRY(NA_BGM_INGO, "Ingo's Theme", "NA_BGM_INGO", SEQ_BGM_WORLD), - SEQUENCE_MAP_ENTRY(NA_BGM_MEDALLION_GET, "Obtain Medallion", "NA_BGM_MEDALLION_GET", SEQ_FANFARE), - SEQUENCE_MAP_ENTRY(NA_BGM_OCA_SARIA, "Ocarina Saria's Song", "NA_BGM_OCA_SARIA", SEQ_OCARINA), - SEQUENCE_MAP_ENTRY(NA_BGM_OCA_EPONA, "Ocarina Epona's Song", "NA_BGM_OCA_EPONA", SEQ_OCARINA), - SEQUENCE_MAP_ENTRY(NA_BGM_OCA_ZELDA, "Ocarina Zelda's Lullaby", "NA_BGM_OCA_ZELDA", SEQ_OCARINA), - SEQUENCE_MAP_ENTRY(NA_BGM_OCA_SUNS, "Ocarina Sun's Song", "NA_BGM_OCA_SUNS", SEQ_OCARINA), - SEQUENCE_MAP_ENTRY(NA_BGM_OCA_TIME, "Ocarina Song of Time", "NA_BGM_OCA_TIME", SEQ_OCARINA), - SEQUENCE_MAP_ENTRY(NA_BGM_OCA_STORM, "Ocarina Song of Storms", "NA_BGM_OCA_STORM", SEQ_OCARINA), - SEQUENCE_MAP_ENTRY(NA_BGM_NAVI_OPENING, "Fairy Flying", "NA_BGM_NAVI_OPENING", SEQ_BGM_EVENT), - SEQUENCE_MAP_ENTRY(NA_BGM_DEKU_TREE_CS, "Deku Tree", "NA_BGM_DEKU_TREE_CS", SEQ_BGM_EVENT), - SEQUENCE_MAP_ENTRY(NA_BGM_WINDMILL, "Windmill Hut", "NA_BGM_WINDMILL", SEQ_BGM_WORLD), - SEQUENCE_MAP_ENTRY(NA_BGM_HYRULE_CS, "Legend of Hyrule", "NA_BGM_HYRULE_CS", SEQ_BGM_EVENT), - SEQUENCE_MAP_ENTRY(NA_BGM_MINI_GAME, "Shooting Gallery", "NA_BGM_MINI_GAME", SEQ_BGM_EVENT), - SEQUENCE_MAP_ENTRY(NA_BGM_SHEIK, "Sheik's Theme", "NA_BGM_SHEIK", SEQ_BGM_EVENT), - SEQUENCE_MAP_ENTRY(NA_BGM_ZORA_DOMAIN, "Zora's Domain", "NA_BGM_ZORA_DOMAIN", SEQ_BGM_WORLD), - SEQUENCE_MAP_ENTRY(NA_BGM_APPEAR, "Enter Zelda", "NA_BGM_APPEAR", SEQ_FANFARE), - SEQUENCE_MAP_ENTRY(NA_BGM_ADULT_LINK, "Goodbye to Zelda", "NA_BGM_ADULT_LINK", SEQ_BGM_EVENT), - SEQUENCE_MAP_ENTRY(NA_BGM_MASTER_SWORD, "Master Sword", "NA_BGM_MASTER_SWORD", SEQ_FANFARE), - SEQUENCE_MAP_ENTRY(NA_BGM_INTRO_GANON, "Ganon Intro", "NA_BGM_INTRO_GANON", SEQ_BGM_EVENT), - SEQUENCE_MAP_ENTRY(NA_BGM_SHOP, "Shop", "NA_BGM_SHOP", SEQ_BGM_WORLD), - SEQUENCE_MAP_ENTRY(NA_BGM_CHAMBER_OF_SAGES, "Chamber of the Sages", "NA_BGM_CHAMBER_OF_SAGES", SEQ_BGM_EVENT), - SEQUENCE_MAP_ENTRY(NA_BGM_FILE_SELECT, "File Select", "NA_BGM_FILE_SELECT", SEQ_BGM_WORLD), - SEQUENCE_MAP_ENTRY(NA_BGM_ICE_CAVERN, "Ice Cavern", "NA_BGM_ICE_CAVERN", SEQ_BGM_WORLD), - SEQUENCE_MAP_ENTRY(NA_BGM_DOOR_OF_TIME, "Open Door of Temple of Time", "NA_BGM_DOOR_OF_TIME", SEQ_BGM_EVENT), - SEQUENCE_MAP_ENTRY(NA_BGM_OWL, "Kaepora Gaebora's Theme", "NA_BGM_OWL", SEQ_BGM_EVENT), - SEQUENCE_MAP_ENTRY(NA_BGM_SHADOW_TEMPLE, "Shadow Temple", "NA_BGM_SHADOW_TEMPLE", SEQ_BGM_WORLD), - SEQUENCE_MAP_ENTRY(NA_BGM_WATER_TEMPLE, "Water Temple", "NA_BGM_WATER_TEMPLE", SEQ_BGM_WORLD), - SEQUENCE_MAP_ENTRY(NA_BGM_BRIDGE_TO_GANONS, "Ganon's Castle Bridge", "NA_BGM_BRIDGE_TO_GANONS", SEQ_BGM_EVENT), - SEQUENCE_MAP_ENTRY(NA_BGM_OCARINA_OF_TIME, "Ocarina of Time", "NA_BGM_OCARINA_OF_TIME", SEQ_FANFARE), - SEQUENCE_MAP_ENTRY(NA_BGM_GERUDO_VALLEY, "Gerudo Valley", "NA_BGM_GERUDO_VALLEY", SEQ_BGM_WORLD), - SEQUENCE_MAP_ENTRY(NA_BGM_POTION_SHOP, "Potion Shop", "NA_BGM_POTION_SHOP", SEQ_BGM_WORLD), - SEQUENCE_MAP_ENTRY(NA_BGM_KOTAKE_KOUME, "Kotake & Koume's Theme", "NA_BGM_KOTAKE_KOUME", SEQ_BGM_EVENT), - SEQUENCE_MAP_ENTRY(NA_BGM_ESCAPE, "Escape from Ganon's Castle", "NA_BGM_ESCAPE", SEQ_BGM_EVENT), - SEQUENCE_MAP_ENTRY(NA_BGM_UNDERGROUND, "Ganon's Castle Under Ground", "NA_BGM_UNDERGROUND", SEQ_BGM_WORLD), - SEQUENCE_MAP_ENTRY(NA_BGM_GANONDORF_BOSS, "Ganondorf Battle", "NA_BGM_GANONDORF_BOSS", SEQ_BGM_BATTLE), - SEQUENCE_MAP_ENTRY(NA_BGM_GANON_BOSS, "Ganon Battle", "NA_BGM_GANON_BOSS", SEQ_BGM_BATTLE), - SEQUENCE_MAP_ENTRY(NA_BGM_END_DEMO, "Seal of Six Sages", "NA_BGM_END_DEMO", SEQ_NOSHUFFLE), - SEQUENCE_MAP_ENTRY(NA_BGM_STAFF_1, "End Credits I", "NA_BGM_STAFF_1", SEQ_NOSHUFFLE), - SEQUENCE_MAP_ENTRY(NA_BGM_STAFF_2, "End Credits II", "NA_BGM_STAFF_2", SEQ_NOSHUFFLE), - SEQUENCE_MAP_ENTRY(NA_BGM_STAFF_3, "End Credits III", "NA_BGM_STAFF_3", SEQ_NOSHUFFLE), - SEQUENCE_MAP_ENTRY(NA_BGM_STAFF_4, "End Credits IV", "NA_BGM_STAFF_4", SEQ_NOSHUFFLE), - SEQUENCE_MAP_ENTRY(NA_BGM_FIRE_BOSS, "King Dodongo & Volvagia Boss Battle", "NA_BGM_FIRE_BOSS", SEQ_BGM_BATTLE), - SEQUENCE_MAP_ENTRY(NA_BGM_TIMED_MINI_GAME, "Mini-Game", "NA_BGM_TIMED_MINI_GAME", SEQ_BGM_EVENT), - SEQUENCE_MAP_ENTRY(INSTRUMENT_OFFSET + 1, "Ocarina", "OCARINA_INSTRUMENT_DEFAULT", SEQ_INSTRUMENT), - SEQUENCE_MAP_ENTRY(INSTRUMENT_OFFSET + 2, "Malon", "OCARINA_INSTRUMENT_MALON", SEQ_INSTRUMENT), - SEQUENCE_MAP_ENTRY(INSTRUMENT_OFFSET + 3, "Whistle", "OCARINA_INSTRUMENT_WHISTLE", SEQ_INSTRUMENT), - SEQUENCE_MAP_ENTRY(INSTRUMENT_OFFSET + 4, "Harp", "OCARINA_INSTRUMENT_HARP", SEQ_INSTRUMENT), - SEQUENCE_MAP_ENTRY(INSTRUMENT_OFFSET + 5, "Organ", "OCARINA_INSTRUMENT_GRIND_ORGAN", SEQ_INSTRUMENT), - SEQUENCE_MAP_ENTRY(INSTRUMENT_OFFSET + 6, "Flute", "OCARINA_INSTRUMENT_FLUTE", SEQ_INSTRUMENT), - SEQUENCE_MAP_ENTRY(NA_SE_EV_SMALL_DOG_BARK, "Bark", "NA_SE_EV_SMALL_DOG_BARK", SEQ_SFX), - SEQUENCE_MAP_ENTRY(NA_SE_EN_AWA_BOUND, "Bomb Bounce", "NA_SE_EN_AWA_BOUND", SEQ_SFX), - SEQUENCE_MAP_ENTRY(NA_SE_EN_SHADEST_TAIKO_LOW, "Bongo Bongo Low", "NA_SE_EN_SHADEST_TAIKO_LOW", SEQ_SFX), - SEQUENCE_MAP_ENTRY(NA_SE_EN_NUTS_FAINT, "Business Scrub", "NA_SE_EN_NUTS_FAINT", SEQ_SFX), - SEQUENCE_MAP_ENTRY(NA_SE_SY_CARROT_RECOVER, "Carrot Refill", "NA_SE_SY_CARROT_RECOVER", SEQ_SFX), - SEQUENCE_MAP_ENTRY(NA_SE_EV_CHICKEN_CRY_N, "Cluck", "NA_SE_EV_CHICKEN_CRY_N", SEQ_SFX), - SEQUENCE_MAP_ENTRY(NA_SE_EV_BRIDGE_OPEN_STOP, "Drawbridge Set", "NA_SE_EV_BRIDGE_OPEN_STOP", SEQ_SFX), - SEQUENCE_MAP_ENTRY(NA_SE_EN_KAICHO_CRY, "Guay", "NA_SE_EN_KAICHO_CRY", SEQ_SFX), - SEQUENCE_MAP_ENTRY(NA_SE_SY_HITPOINT_ALARM, "Low HP Beep", "NA_SE_SY_HITPOINT_ALARM", SEQ_SFX), - SEQUENCE_MAP_ENTRY(NA_SE_SY_HP_RECOVER, "HP Recover", "NA_SE_SY_HP_RECOVER", SEQ_SFX), - SEQUENCE_MAP_ENTRY(NA_SE_EV_HORSE_RUN, "Horse Trot", "NA_SE_EV_HORSE_RUN", SEQ_SFX), - SEQUENCE_MAP_ENTRY(NA_SE_PL_WALK_HEAVYBOOTS, "Iron Boots", "NA_SE_PL_WALK_HEAVYBOOTS", SEQ_SFX), - //SEQUENCE_MAP_ENTRY(NA_SE_PL_HOBBERBOOTS_LV, "Hover Boots", "NA_SE_PL_HOBBERBOOTS_LV", SEQ_SFX), // Doesn't work due to SFX_FLAG - SEQUENCE_MAP_ENTRY(NA_SE_EV_COW_CRY, "Moo", "NA_SE_EV_COW_CRY", SEQ_SFX), - SEQUENCE_MAP_ENTRY(NA_SE_EV_POT_BROKEN, "Pot Shattering", "NA_SE_EV_POT_BROKEN", SEQ_SFX), - SEQUENCE_MAP_ENTRY(NA_SE_EV_FROG_CRY_0, "Ribbit", "NA_SE_EV_FROG_CRY_0", SEQ_SFX), - SEQUENCE_MAP_ENTRY(NA_SE_EV_FIVE_COUNT_LUPY, "Rupee (Silver)", "NA_SE_EV_FIVE_COUNT_LUPY", SEQ_SFX), - SEQUENCE_MAP_ENTRY(NA_SE_EV_FOOT_SWITCH, "Switch", "NA_SE_EV_FOOT_SWITCH", SEQ_SFX), - SEQUENCE_MAP_ENTRY(NA_SE_IT_WALL_HIT_SOFT, "Sword Bonk", "NA_SE_IT_WALL_HIT_SOFT", SEQ_SFX), - SEQUENCE_MAP_ENTRY(NA_SE_SY_METRONOME, "Tambourine", "NA_SE_SY_METRONOME", SEQ_SFX), - SEQUENCE_MAP_ENTRY(NA_SE_EN_AMOS_VOICE, "Armos", "NA_SE_EN_AMOS_VOICE", SEQ_SFX), - SEQUENCE_MAP_ENTRY(NA_SE_EN_REDEAD_AIM, "Redead Scream", "NA_SE_EN_REDEAD_AIM", SEQ_SFX), - SEQUENCE_MAP_ENTRY(NA_SE_EN_STALKID_ATTACK, "Stalchild Attack", "NA_SE_EN_STALKID_ATTACK", SEQ_SFX), - SEQUENCE_MAP_ENTRY(NA_SE_EV_CHICKEN_CRY_M, "Cockadoodiedoo", "NA_SE_EV_CHICKEN_CRY_M", SEQ_SFX), - SEQUENCE_MAP_ENTRY(NA_SE_SY_KINSTA_MARK_APPEAR, "Gold Skulltula Token", "NA_SE_SY_KINSTA_MARK_APPEAR", SEQ_SFX), - SEQUENCE_MAP_ENTRY(NA_SE_EN_REDEAD_CRY, "Redead Moan", "NA_SE_EN_REDEAD_CRY", SEQ_SFX), - SEQUENCE_MAP_ENTRY(NA_SE_EV_LIGHTNING, "Thunder", "NA_SE_EV_LIGHTNING", SEQ_SFX), - SEQUENCE_MAP_ENTRY(NA_SE_OC_ABYSS, "Cartoon Fall", "NA_SE_OC_ABYSS", SEQ_SFX), - SEQUENCE_MAP_ENTRY(NA_SE_EN_FLAME_LAUGH, "Flare Dancer Laugh", "NA_SE_EN_FLAME_LAUGH", SEQ_SFX), - SEQUENCE_MAP_ENTRY(NA_SE_EN_AWA_BREAK, "Shabom Pop", "NA_SE_EN_AWA_BREAK", SEQ_SFX), - SEQUENCE_MAP_ENTRY(NA_SE_EN_SHADEST_TAIKO_HIGH, "Bongo Bongo High", "NA_SE_EN_SHADEST_TAIKO_HIGH", SEQ_SFX), - SEQUENCE_MAP_ENTRY(NA_SE_EV_BOTTLE_CAP_OPEN, "Bottle Cork", "NA_SE_EV_BOTTLE_CAP_OPEN", SEQ_SFX), - SEQUENCE_MAP_ENTRY(NA_SE_IT_BOW_FLICK, "Bow Twang", "NA_SE_IT_BOW_FLICK", SEQ_SFX), - SEQUENCE_MAP_ENTRY(NA_SE_EN_BUBLE_LAUGH, "Bubble Laugh", "NA_SE_EN_BUBLE_LAUGH", SEQ_SFX), - SEQUENCE_MAP_ENTRY(NA_SE_EN_DEKU_JR_MOUTH, "Deku Baba", "NA_SE_EN_DEKU_JR_MOUTH", SEQ_SFX), - SEQUENCE_MAP_ENTRY(NA_SE_EV_DOG_CRY_EVENING, "Dusk Howl", "NA_SE_EV_DOG_CRY_EVENING", SEQ_SFX), - SEQUENCE_MAP_ENTRY(NA_SE_EN_FLAME_DAMAGE, "Flare Dancer Startled", "NA_SE_EN_FLAME_DAMAGE", SEQ_SFX), - SEQUENCE_MAP_ENTRY(NA_SE_EN_GANON_AT_RETURN, "Ganondorf Teh!", "NA_SE_EN_GANON_AT_RETURN", SEQ_SFX), - SEQUENCE_MAP_ENTRY(NA_SE_EN_GOMA_JR_CRY, "Gohma Larva Croak", "NA_SE_EN_GOMA_JR_CRY", SEQ_SFX), - SEQUENCE_MAP_ENTRY(NA_SE_EN_GOLON_WAKE_UP, "Goron Wake", "NA_SE_EN_GOLON_WAKE_UP", SEQ_SFX), - SEQUENCE_MAP_ENTRY(NA_SE_SY_START_SHOT, "Gunshot", "NA_SE_SY_START_SHOT", SEQ_SFX), - SEQUENCE_MAP_ENTRY(NA_SE_IT_HAMMER_HIT, "Hammer Bonk", "NA_SE_IT_HAMMER_HIT", SEQ_SFX), - SEQUENCE_MAP_ENTRY(NA_SE_EN_IRONNACK_SWING_AXE, "Iron Knuckle", "NA_SE_EN_IRONNACK_SWING_AXE", SEQ_SFX), - SEQUENCE_MAP_ENTRY(NA_SE_EN_FANTOM_ST_LAUGH, "Phantom Ganon Laugh", "NA_SE_EN_FANTOM_ST_LAUGH", SEQ_SFX), - SEQUENCE_MAP_ENTRY(NA_SE_EV_PLANT_BROKEN, "Plant Explode", "NA_SE_EV_PLANT_BROKEN", SEQ_SFX), - SEQUENCE_MAP_ENTRY(NA_SE_SY_GET_RUPY, "Rupee", "NA_SE_SY_GET_RUPY", SEQ_SFX), - SEQUENCE_MAP_ENTRY(NA_SE_EN_NUTS_UP, "Scrub Emerge", "NA_SE_EN_NUTS_UP", SEQ_SFX), - SEQUENCE_MAP_ENTRY(NA_SE_EN_AWA_BOUND, "Shabom Bounce", "NA_SE_EN_AWA_BOUND", SEQ_SFX), - SEQUENCE_MAP_ENTRY(NA_SE_EN_SHELL_MOUTH, "Shellblade", "NA_SE_EN_SHELL_MOUTH", SEQ_SFX), - SEQUENCE_MAP_ENTRY(NA_SE_EN_STALTU_DAMAGE, "Skulltula Damage", "NA_SE_EN_STALTU_DAMAGE", SEQ_SFX), - SEQUENCE_MAP_ENTRY(NA_SE_EN_NUTS_THROW, "Spit Nut", "NA_SE_EN_NUTS_THROW", SEQ_SFX), - SEQUENCE_MAP_ENTRY(NA_SE_SY_LOCK_ON, "Target Enemy", "NA_SE_SY_LOCK_ON", SEQ_SFX), - SEQUENCE_MAP_ENTRY(NA_SE_SY_LOCK_ON_HUMAN, "Target Neutral", "NA_SE_SY_LOCK_ON_HUMAN", SEQ_SFX), - SEQUENCE_MAP_ENTRY(NA_SE_SY_FSEL_CURSOR, "File Select Cursor", "NA_SE_SY_FSEL_CURSOR", SEQ_SFX), - SEQUENCE_MAP_ENTRY(NA_SE_SY_FSEL_DECIDE_L, "File Select Choose", "NA_SE_SY_FSEL_DECIDE_L", SEQ_SFX), - SEQUENCE_MAP_ENTRY(NA_SE_SY_FSEL_CLOSE, "File Select Back", "NA_SE_SY_FSEL_CLOSE", SEQ_SFX), - SEQUENCE_MAP_ENTRY(NA_SE_IT_BOMB_EXPLOSION, "Bomb Explosion", "NA_SE_IT_BOMB_EXPLOSION", SEQ_SFX), - SEQUENCE_MAP_ENTRY(NA_SE_EV_CHICKEN_CRY_A, "Chicken Cry", "NA_SE_EV_CHICKEN_CRY_A", SEQ_SFX), - SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_SWORD_N, "Adult Link - Slash", "NA_SE_VO_LI_SWORD_N", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_SWORD_L, "Adult Link - Big Slash", "NA_SE_VO_LI_SWORD_L", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_LASH, "Adult Link - Hookshot Latch Yell", "NA_SE_VO_LI_LASH", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_HANG, "Adult Link - Dangling Gasp", "NA_SE_VO_LI_HANG", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_CLIMB_END, "Adult Link - Climb Edge", "NA_SE_VO_LI_CLIMB_END", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_DAMAGE_S, "Adult Link - Small Damage", "NA_SE_VO_LI_DAMAGE_S", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_FREEZE, "Adult Link - Freeze", "NA_SE_VO_LI_FREEZE", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_FALL_S, "Adult Link - Fall Gasp", "NA_SE_VO_LI_FALL_S", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_FALL_L, "Adult Link - Fall Scream", "NA_SE_VO_LI_FALL_L", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_BREATH_REST, "Adult Link - Low Health Sigh", "NA_SE_VO_LI_BREATH_REST", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_BREATH_DRINK, "Adult Link - Bottle Sigh", "NA_SE_VO_LI_BREATH_DRINK", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_DOWN, "Adult Link - Death", "NA_SE_VO_LI_DOWN", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_TAKEN_AWAY, "Adult Link - Taken away by Wallmaster","NA_SE_VO_LI_TAKEN_AWAY", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_HELD, "Adult Link - Grabbed by Wallmaster", "NA_SE_VO_LI_HELD", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_SNEEZE, "Adult Link - Sneeze", "NA_SE_VO_LI_SNEEZE", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_SWEAT, "Adult Link - Gasp (Hot Room)", "NA_SE_VO_LI_SWEAT", SEQ_VOICE), - //SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_DRINK, "Adult Link - Drinking", "NA_SE_VO_LI_DRINK", SEQ_VOICE), // Doesn't work due to SFX_FLAG - SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_RELAX, "Adult Link - Yawn", "NA_SE_VO_LI_RELAX", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_SWORD_PUTAWAY, "Adult Link - Yell (Sword Putaway)", "NA_SE_VO_LI_SWORD_PUTAWAY", SEQ_VOICE), - //SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_GROAN, "Adult Link - Groan (Unused)", "NA_SE_VO_LI_GROAN", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_AUTO_JUMP, "Adult Link - Jump/Swing Bottle", "NA_SE_VO_LI_AUTOd_JUMP", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_MAGIC_NALE, "Adult Link - Use Nayru's Love", "NA_SE_VO_LI_MAGIC_NALE", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_SURPRISE, "Adult Link - Suprised Gasp", "NA_SE_VO_LI_SURPRISE", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_MAGIC_FROL, "Adult Link - Use Farore's Wind", "NA_SE_VO_LI_MAGIC_FROL", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_PUSH, "Adult Link - Push", "NA_SE_VO_LI_PUSH", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_HOOKSHOT_HANG, "Adult Link - Hookshot hang", "NA_SE_VO_LI_HOOKSHOT_HANG", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_LAND_DAMAGE_S, "Adult Link - Fall damage", "NA_SE_VO_LI_LAND_DAMAGE_S", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_NULL_0x1b, "Adult Link - Small grunt (unused?)", "NA_SE_VO_LI_NULL_0x1b", SEQ_VOICE), // Unused? But unique so keeping it - SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_MAGIC_ATTACK, "Adult Link - Din's Fire", "NA_SE_VO_LI_MAGIC_ATTACK", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_BL_DOWN, "Adult Link - Scream (Nocturne?)", "NA_SE_VO_BL_DOWN", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_DEMO_DAMAGE, "Adult Link - Pained Land (Nocturne?)","NA_SE_VO_LI_DEMO_DAMAGE", SEQ_VOICE), - //SEQUENCE_MAP_ENTRY("Adult Link - Unused Sound 1?","NA_SE_VO_LI_ELECTRIC_SHOCK_LV", "NA_SE_VO_LI_ELECTRIC_SHOCK_LV", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_SWORD_N_KID, "Child Link - Slash", "NA_SE_VO_LI_SWORD_N_KID", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_ROLLING_CUT_KID, "Child Link - Big Slash", "NA_SE_VO_LI_ROLLING_CUT_KID", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_LASH_KID, "Child Link - Hootshot Latch", "NA_SE_VO_LI_LASH_KID", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_HANG_KID, "Child Link - Dangling Gasp", "NA_SE_VO_LI_HANG_KID", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_CLIMB_END_KID, "Child Link - Climb Edge", "NA_SE_VO_LI_CLIMB_END_KID", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_DAMAGE_S_KID, "Child Link - Small Damage", "NA_SE_VO_LI_DAMAGE_S_KID", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_FREEZE_KID, "Child Link - Freeze", "NA_SE_VO_LI_FREEZE_KID", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_FALL_S_KID, "Child Link - Fall Gasp", "NA_SE_VO_LI_FALL_S_KID", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_FALL_L_KID, "Child Link - Fall Scream", "NA_SE_VO_LI_FALL_L_KID", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_BREATH_REST_KID, "Child Link - Low Health Sigh", "NA_SE_VO_LI_BREATH_REST_KID", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_BREATH_DRINK_KID, "Child Link - Bottle Sigh", "NA_SE_VO_LI_BREATH_DRINK_KID", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_DOWN_KID, "Child Link - Death", "NA_SE_VO_LI_DOWN_KID", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_TAKEN_AWAY_KID, "Child Link - Taken away by Wallmaster","NA_SE_VO_LI_TAKEN_AWAY_KID", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_HELD_KID, "Child Link - Grabbed by Wallmaster", "NA_SE_VO_LI_HELD_KID", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_SNEEZE_KID, "Child Link - Sneeze", "NA_SE_VO_LI_SNEEZE_KID", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_SWEAT_KID, "Child Link - Gasp (Hot Room)", "NA_SE_VO_LI_SWEAT_KID", SEQ_VOICE), - //SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_DRINK_KID, "Child Link - Drinking", "NA_SE_VO_LI_DRINK_KID", SEQ_VOICE), // Doesn't work due to SFX_FLAG - SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_RELAX_KID, "Child Link - Yawn", "NA_SE_VO_LI_RELAX_KID", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_SWORD_PUTAWAY_KID,"Child Link - Yell (Sword Putaway)", "NA_SE_VO_LI_SWORD_PUTAWAY_KID", SEQ_VOICE), - //SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_GROAN_KID, "Child Link - Groan (Unused)", "NA_SE_VO_LI_GROAN_KID", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_AUTO_JUMP_KID, "Child Link - Jump/Swing Bottle", "NA_SE_VO_LI_AUTO_JUMP_KID", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_MAGIC_NALE_KID, "Child Link - Use Nayru's Love", "NA_SE_VO_LI_MAGIC_NALE_KID", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_SURPRISE_KID, "Child Link - Surprised Gasp", "NA_SE_VO_LI_SURPRISE_KID", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_MAGIC_FROL_KID, "Child Link - Use Farore's Wind", "NA_SE_VO_LI_MAGIC_FROL_KID", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_PUSH_KID, "Child Link - Push", "NA_SE_VO_LI_PUSH_KID", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_HOOKSHOT_HANG_KID,"Child Link - Hookshot Hang", "NA_SE_VO_LI_HOOKSHOT_HANG_KID", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_LAND_DAMAGE_S_KID,"Child Link - Fall Damage", "NA_SE_VO_LI_LAND_DAMAGE_S_KID", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_NULL_0x1b_KID, "Child Link - Small Gasp (unused?)", "NA_SE_VO_LI_NULL_0x1b_KID", SEQ_VOICE), // Unused? But unique so keeping it - SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_MAGIC_ATTACK_KID, "Child Link - Din's Fire", "NA_SE_VO_LI_MAGIC_ATTACK_KID", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_BL_DOWN_KID, "Child Link - Scream (Nocturne?)", "NA_SE_VO_BL_DOWN_KID", SEQ_VOICE), // ... - SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_DEMO_DAMAGE_KID, "Child Link - Scream 2 (Nocturne?)", "NA_SE_VO_LI_DEMO_DAMAGE_KID", SEQ_VOICE), // Unused, matches with adult nocturne stuff - //SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_ELECTRIC_SHOCK_LV_KID, "Child Link - Unused Sound 1?", "NA_SE_VO_LI_ELECTRIC_SHOCK_LV_KID", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_NAVY_ENEMY, "Navi - Unused Enemy Target", "NA_SE_VO_NAVY_ENEMY", SEQ_VOICE), // Has no sound but is played when targetting enemies, unsure to keep or not - SEQUENCE_MAP_ENTRY(NA_SE_VO_NAVY_HELLO, "Navi - Unused NPC Hello", "NA_SE_VO_NAVY_HELLO", SEQ_VOICE), // Has no sound but is played when targetting npcs, unsure to keep or not - SEQUENCE_MAP_ENTRY(NA_SE_VO_NAVY_HEAR, "Navi - Unused Other Target", "NA_SE_VO_NAVY_HEAR", SEQ_VOICE), // Has no sound but is played when targetting npcs, unsure to keep or not - SEQUENCE_MAP_ENTRY(NA_SE_VO_NAVY_CALL, "Navi - Look/Hey/Watchout (Target Enemy)","NA_SE_VO_NAVY_CALL", SEQ_VOICE), // Has no sound but is played when targetting signs and other things, unsure to keep or not - SEQUENCE_MAP_ENTRY(NA_SE_VO_NA_HELLO_3, "Navi - Hello", "NA_SE_VO_NA_HELLO_3", SEQ_VOICE), + + // SEQ_BGM_WORLD + SEQUENCE_MAP_ENTRY(NA_BGM_FIELD_LOGIC, "Hyrule Field", "NA_BGM_FIELD_LOGIC", SEQ_BGM_WORLD, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_DUNGEON, "Dodongo's Cavern", "NA_BGM_DUNGEON", SEQ_BGM_WORLD, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_KAKARIKO_ADULT, "Kakariko Village (Adult)", "NA_BGM_KAKARIKO_ADULT", SEQ_BGM_WORLD, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_INSIDE_DEKU_TREE, "Inside the Deku Tree", "NA_BGM_INSIDE_DEKU_TREE", SEQ_BGM_WORLD, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_MARKET, "Market", "NA_BGM_MARKET", SEQ_BGM_WORLD, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_TITLE, "Title Theme", "NA_BGM_TITLE", SEQ_BGM_WORLD, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_LINK_HOUSE, "House", "NA_BGM_LINK_HOUSE", SEQ_BGM_WORLD, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_JABU_JABU, "Inside Jabu-Jabu's Belly", "NA_BGM_JABU_JABU", SEQ_BGM_WORLD, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_KAKARIKO_KID, "Kakariko Village (Child)", "NA_BGM_KAKARIKO_KID", SEQ_BGM_WORLD, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_FIRE_TEMPLE, "Fire Temple", "NA_BGM_FIRE_TEMPLE", SEQ_BGM_WORLD, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_FOREST_TEMPLE, "Forest Temple", "NA_BGM_FOREST_TEMPLE", SEQ_BGM_WORLD, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_COURTYARD, "Hyrule Castle Courtyard", "NA_BGM_COURTYARD", SEQ_BGM_WORLD, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_GANON_TOWER, "Ganondorf's Theme", "NA_BGM_GANON_TOWER", SEQ_BGM_WORLD, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_LONLON, "Lon Lon Ranch", "NA_BGM_LONLON", SEQ_BGM_WORLD, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_GORON_CITY, "Goron City", "NA_BGM_GORON_CITY", SEQ_BGM_WORLD, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_SARIA_THEME, "Lost Woods", "NA_BGM_SARIA_THEME", SEQ_BGM_WORLD, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_SPIRIT_TEMPLE, "Spirit Temple", "NA_BGM_SPIRIT_TEMPLE", SEQ_BGM_WORLD, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_INGO, "Ingo's Theme", "NA_BGM_INGO", SEQ_BGM_WORLD, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_KOKIRI, "Kokiri Forest", "NA_BGM_KOKIRI", SEQ_BGM_WORLD, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_TEMPLE_OF_TIME, "Temple of Time", "NA_BGM_TEMPLE_OF_TIME", SEQ_BGM_WORLD, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_WINDMILL, "Windmill Hut", "NA_BGM_WINDMILL", SEQ_BGM_WORLD, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_FILE_SELECT, "File Select", "NA_BGM_FILE_SELECT", SEQ_BGM_WORLD, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_ICE_CAVERN, "Ice Cavern", "NA_BGM_ICE_CAVERN", SEQ_BGM_WORLD, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_ZORA_DOMAIN, "Zora's Domain", "NA_BGM_ZORA_DOMAIN", SEQ_BGM_WORLD, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_SHOP, "Shop", "NA_BGM_SHOP", SEQ_BGM_WORLD, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_SHADOW_TEMPLE, "Shadow Temple", "NA_BGM_SHADOW_TEMPLE", SEQ_BGM_WORLD, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_WATER_TEMPLE, "Water Temple", "NA_BGM_WATER_TEMPLE", SEQ_BGM_WORLD, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_UNDERGROUND, "Ganon's Castle Under Ground", "NA_BGM_UNDERGROUND", SEQ_BGM_WORLD, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_GERUDO_VALLEY, "Gerudo Valley", "NA_BGM_GERUDO_VALLEY", SEQ_BGM_WORLD, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_POTION_SHOP, "Potion Shop", "NA_BGM_POTION_SHOP", SEQ_BGM_WORLD, true, true), + + // SEQ_BGM_BATTLE + SEQUENCE_MAP_ENTRY(NA_BGM_ENEMY, "Battle", "NA_BGM_ENEMY", SEQ_BGM_BATTLE, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_BOSS, "Boss Battle", "NA_BGM_BOSS", SEQ_BGM_BATTLE, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_MINI_BOSS, "Mini-Boss Battle", "NA_BGM_MINI_BOSS", SEQ_BGM_BATTLE, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_GANONDORF_BOSS, "Ganondorf Battle", "NA_BGM_GANONDORF_BOSS", SEQ_BGM_BATTLE, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_GANON_BOSS, "Ganon Battle", "NA_BGM_GANON_BOSS", SEQ_BGM_BATTLE, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_FIRE_BOSS, "King Dodongo & Volvagia Boss Battle", "NA_BGM_FIRE_BOSS", SEQ_BGM_BATTLE, true, true), + + // SEQ_BGM_FANFARE + SEQUENCE_MAP_ENTRY(NA_BGM_GAME_OVER, "Game Over", "NA_BGM_GAME_OVER", SEQ_FANFARE, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_BOSS_CLEAR, "Boss Clear", "NA_BGM_BOSS_CLEAR", SEQ_FANFARE, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_ITEM_GET, "Obtain Item", "NA_BGM_ITEM_GET", SEQ_FANFARE, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_OPENING_GANON, "Enter Ganondorf", "NA_BGM_OPENING_GANON", SEQ_FANFARE, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_HEART_GET, "Obtain Heart Container", "NA_BGM_HEART_GET", SEQ_FANFARE, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_OPEN_TRE_BOX, "Open Treasure Chest", "NA_BGM_OPEN_TRE_BOX", SEQ_FANFARE, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_SPIRITUAL_STONE, "Spiritual Stone Get", "NA_BGM_SPIRITUAL_STONE", SEQ_FANFARE, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_SMALL_ITEM_GET, "Obtain Small Item", "NA_BGM_SMALL_ITEM_GET", SEQ_FANFARE, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_EVENT_CLEAR, "Escape from Lon Lon Ranch", "NA_BGM_EVENT_CLEAR", SEQ_FANFARE, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_OCA_FAIRY_GET, "Obtain Fairy Ocarina", "NA_BGM_OCA_FAIRY_GET", SEQ_FANFARE, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_HORSE_GOAL, "Horse Race Goal", "NA_BGM_HORSE_GOAL", SEQ_FANFARE, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_MEDALLION_GET, "Obtain Medallion", "NA_BGM_MEDALLION_GET", SEQ_FANFARE, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_APPEAR, "Enter Zelda", "NA_BGM_APPEAR", SEQ_FANFARE, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_MASTER_SWORD, "Master Sword", "NA_BGM_MASTER_SWORD", SEQ_FANFARE, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_OCARINA_OF_TIME, "Ocarina of Time", "NA_BGM_OCARINA_OF_TIME", SEQ_FANFARE, true, true), + + // SEQ_OCARINA + SEQUENCE_MAP_ENTRY(NA_BGM_OCA_LIGHT, "Prelude of Light", "NA_BGM_OCA_LIGHT", SEQ_OCARINA, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_OCA_BOLERO, "Bolero of Fire", "NA_BGM_OCA_BOLERO", SEQ_OCARINA, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_OCA_MINUET, "Minuet of Forest", "NA_BGM_OCA_MINUET", SEQ_OCARINA, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_OCA_SERENADE, "Serenade of Water", "NA_BGM_OCA_SERENADE", SEQ_OCARINA, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_OCA_REQUIEM, "Requiem of Spirit", "NA_BGM_OCA_REQUIEM", SEQ_OCARINA, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_OCA_NOCTURNE, "Nocturne of Shadow", "NA_BGM_OCA_NOCTURNE", SEQ_OCARINA, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_OCA_SARIA, "Ocarina Saria's Song", "NA_BGM_OCA_SARIA", SEQ_OCARINA, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_OCA_EPONA, "Ocarina Epona's Song", "NA_BGM_OCA_EPONA", SEQ_OCARINA, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_OCA_ZELDA, "Ocarina Zelda's Lullaby", "NA_BGM_OCA_ZELDA", SEQ_OCARINA, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_OCA_SUNS, "Ocarina Sun's Song", "NA_BGM_OCA_SUNS", SEQ_OCARINA, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_OCA_TIME, "Ocarina Song of Time", "NA_BGM_OCA_TIME", SEQ_OCARINA, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_OCA_STORM, "Ocarina Song of Storms", "NA_BGM_OCA_STORM", SEQ_OCARINA, true, true), + + // SEQ_BGM_EVENT + SEQUENCE_MAP_ENTRY(NA_BGM_GREAT_FAIRY, "Great Fairy's Fountain", "NA_BGM_GREAT_FAIRY", SEQ_BGM_EVENT, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_ZELDA_THEME, "Zelda's Theme", "NA_BGM_ZELDA_THEME", SEQ_BGM_EVENT, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_HORSE, "Horse Race", "NA_BGM_HORSE", SEQ_BGM_EVENT, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_NAVI_OPENING, "Fairy Flying", "NA_BGM_NAVI_OPENING", SEQ_BGM_EVENT, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_DEKU_TREE_CS, "Deku Tree", "NA_BGM_DEKU_TREE_CS", SEQ_BGM_EVENT, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_HYRULE_CS, "Legend of Hyrule", "NA_BGM_HYRULE_CS", SEQ_BGM_EVENT, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_MINI_GAME, "Shooting Gallery", "NA_BGM_MINI_GAME", SEQ_BGM_EVENT, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_SHEIK, "Sheik's Theme", "NA_BGM_SHEIK", SEQ_BGM_EVENT, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_ADULT_LINK, "Goodbye to Zelda", "NA_BGM_ADULT_LINK", SEQ_BGM_EVENT, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_INTRO_GANON, "Ganon Intro", "NA_BGM_INTRO_GANON", SEQ_BGM_EVENT, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_CHAMBER_OF_SAGES, "Chamber of the Sages", "NA_BGM_CHAMBER_OF_SAGES", SEQ_BGM_EVENT, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_DOOR_OF_TIME, "Open Door of Temple of Time", "NA_BGM_DOOR_OF_TIME", SEQ_BGM_EVENT, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_OWL, "Kaepora Gaebora's Theme", "NA_BGM_OWL", SEQ_BGM_EVENT, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_BRIDGE_TO_GANONS, "Ganon's Castle Bridge", "NA_BGM_BRIDGE_TO_GANONS", SEQ_BGM_EVENT, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_KOTAKE_KOUME, "Kotake & Koume's Theme", "NA_BGM_KOTAKE_KOUME", SEQ_BGM_EVENT, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_ESCAPE, "Escape from Ganon's Castle", "NA_BGM_ESCAPE", SEQ_BGM_EVENT, true, true), + SEQUENCE_MAP_ENTRY(NA_BGM_TIMED_MINI_GAME, "Mini-Game", "NA_BGM_TIMED_MINI_GAME", SEQ_BGM_EVENT, true, true), + + // Previously SEQ_NOSHUFFLE + SEQUENCE_MAP_ENTRY(NA_BGM_FIELD_MORNING, "Hyrule Field Morning Theme", "NA_BGM_FIELD_MORNING", SEQ_BGM_EVENT, false, false), // Previously SEQ_UNUSED, so not shown anywhere? + SEQUENCE_MAP_ENTRY(NA_BGM_END_DEMO, "Seal of Six Sages", "NA_BGM_END_DEMO", SEQ_BGM_EVENT, false, false), // Previously SEQ_UNUSED, so not shown anywhere? + SEQUENCE_MAP_ENTRY(NA_BGM_STAFF_1, "End Credits I", "NA_BGM_STAFF_1", SEQ_BGM_EVENT, false, false), // Previously SEQ_UNUSED, so not shown anywhere? + SEQUENCE_MAP_ENTRY(NA_BGM_STAFF_2, "End Credits II", "NA_BGM_STAFF_2", SEQ_BGM_EVENT, false, false), // Previously SEQ_UNUSED, so not shown anywhere? + SEQUENCE_MAP_ENTRY(NA_BGM_STAFF_3, "End Credits III", "NA_BGM_STAFF_3", SEQ_BGM_EVENT, false, false), // Previously SEQ_UNUSED, so not shown anywhere? + SEQUENCE_MAP_ENTRY(NA_BGM_STAFF_4, "End Credits IV", "NA_BGM_STAFF_4", SEQ_BGM_EVENT, false, false), // Previously SEQ_UNUSED, so not shown anywhere? + + // SEQ_INSTRUMENT + SEQUENCE_MAP_ENTRY(INSTRUMENT_OFFSET + 1, "Ocarina", "OCARINA_INSTRUMENT_DEFAULT", SEQ_INSTRUMENT, true, false), + SEQUENCE_MAP_ENTRY(INSTRUMENT_OFFSET + 2, "Malon", "OCARINA_INSTRUMENT_MALON", SEQ_INSTRUMENT, true, false), + SEQUENCE_MAP_ENTRY(INSTRUMENT_OFFSET + 3, "Whistle", "OCARINA_INSTRUMENT_WHISTLE", SEQ_INSTRUMENT, true, false), + SEQUENCE_MAP_ENTRY(INSTRUMENT_OFFSET + 4, "Harp", "OCARINA_INSTRUMENT_HARP", SEQ_INSTRUMENT, true, false), + SEQUENCE_MAP_ENTRY(INSTRUMENT_OFFSET + 5, "Organ", "OCARINA_INSTRUMENT_GRIND_ORGAN", SEQ_INSTRUMENT, true, false), + SEQUENCE_MAP_ENTRY(INSTRUMENT_OFFSET + 6, "Flute", "OCARINA_INSTRUMENT_FLUTE", SEQ_INSTRUMENT, true, false), + + // SEQ_SFX + SEQUENCE_MAP_ENTRY(NA_SE_EV_SMALL_DOG_BARK, "Bark", "NA_SE_EV_SMALL_DOG_BARK", SEQ_SFX, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_EN_AWA_BOUND, "Bomb Bounce", "NA_SE_EN_AWA_BOUND", SEQ_SFX, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_EN_SHADEST_TAIKO_LOW, "Bongo Bongo Low", "NA_SE_EN_SHADEST_TAIKO_LOW", SEQ_SFX, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_EN_NUTS_FAINT, "Business Scrub", "NA_SE_EN_NUTS_FAINT", SEQ_SFX, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_SY_CARROT_RECOVER, "Carrot Refill", "NA_SE_SY_CARROT_RECOVER", SEQ_SFX, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_EV_CHICKEN_CRY_N, "Cluck", "NA_SE_EV_CHICKEN_CRY_N", SEQ_SFX, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_EV_BRIDGE_OPEN_STOP, "Drawbridge Set", "NA_SE_EV_BRIDGE_OPEN_STOP", SEQ_SFX, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_EN_KAICHO_CRY, "Guay", "NA_SE_EN_KAICHO_CRY", SEQ_SFX, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_SY_HITPOINT_ALARM, "Low HP Beep", "NA_SE_SY_HITPOINT_ALARM", SEQ_SFX, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_SY_HP_RECOVER, "HP Recover", "NA_SE_SY_HP_RECOVER", SEQ_SFX, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_EV_HORSE_RUN, "Horse Trot", "NA_SE_EV_HORSE_RUN", SEQ_SFX, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_PL_WALK_HEAVYBOOTS, "Iron Boots", "NA_SE_PL_WALK_HEAVYBOOTS", SEQ_SFX, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_PL_HOBBERBOOTS_LV - SFX_FLAG, "Hover Boots", "NA_SE_PL_HOBBERBOOTS_LV", SEQ_SFX, true, false), + SEQUENCE_MAP_ENTRY(NA_SE_EV_COW_CRY, "Moo", "NA_SE_EV_COW_CRY", SEQ_SFX, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_EV_POT_BROKEN, "Pot Shattering", "NA_SE_EV_POT_BROKEN", SEQ_SFX, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_EV_FROG_CRY_0, "Ribbit", "NA_SE_EV_FROG_CRY_0", SEQ_SFX, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_EV_FIVE_COUNT_LUPY, "Rupee (Silver)", "NA_SE_EV_FIVE_COUNT_LUPY", SEQ_SFX, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_EV_FOOT_SWITCH, "Switch", "NA_SE_EV_FOOT_SWITCH", SEQ_SFX, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_IT_WALL_HIT_SOFT, "Sword Bonk", "NA_SE_IT_WALL_HIT_SOFT", SEQ_SFX, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_SY_METRONOME, "Tambourine", "NA_SE_SY_METRONOME", SEQ_SFX, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_EN_AMOS_VOICE, "Armos", "NA_SE_EN_AMOS_VOICE", SEQ_SFX, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_EN_REDEAD_AIM, "Redead Scream", "NA_SE_EN_REDEAD_AIM", SEQ_SFX, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_EN_STALKID_ATTACK, "Stalchild Attack", "NA_SE_EN_STALKID_ATTACK", SEQ_SFX, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_EV_CHICKEN_CRY_M, "Cockadoodiedoo", "NA_SE_EV_CHICKEN_CRY_M", SEQ_SFX, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_SY_KINSTA_MARK_APPEAR, "Gold Skulltula Token", "NA_SE_SY_KINSTA_MARK_APPEAR", SEQ_SFX, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_EN_REDEAD_CRY, "Redead Moan", "NA_SE_EN_REDEAD_CRY", SEQ_SFX, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_EV_LIGHTNING, "Thunder", "NA_SE_EV_LIGHTNING", SEQ_SFX, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_OC_ABYSS, "Cartoon Fall", "NA_SE_OC_ABYSS", SEQ_SFX, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_EN_FLAME_LAUGH, "Flare Dancer Laugh", "NA_SE_EN_FLAME_LAUGH", SEQ_SFX, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_EN_AWA_BREAK, "Shabom Pop", "NA_SE_EN_AWA_BREAK", SEQ_SFX, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_EN_SHADEST_TAIKO_HIGH, "Bongo Bongo High", "NA_SE_EN_SHADEST_TAIKO_HIGH", SEQ_SFX, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_EV_BOTTLE_CAP_OPEN, "Bottle Cork", "NA_SE_EV_BOTTLE_CAP_OPEN", SEQ_SFX, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_IT_BOW_FLICK, "Bow Twang", "NA_SE_IT_BOW_FLICK", SEQ_SFX, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_EN_BUBLE_LAUGH, "Bubble Laugh", "NA_SE_EN_BUBLE_LAUGH", SEQ_SFX, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_EN_DEKU_JR_MOUTH, "Deku Baba", "NA_SE_EN_DEKU_JR_MOUTH", SEQ_SFX, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_EV_DOG_CRY_EVENING, "Dusk Howl", "NA_SE_EV_DOG_CRY_EVENING", SEQ_SFX, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_EN_FLAME_DAMAGE, "Flare Dancer Startled", "NA_SE_EN_FLAME_DAMAGE", SEQ_SFX, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_EN_GANON_AT_RETURN, "Ganondorf Teh!", "NA_SE_EN_GANON_AT_RETURN", SEQ_SFX, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_EN_GOMA_JR_CRY, "Gohma Larva Croak", "NA_SE_EN_GOMA_JR_CRY", SEQ_SFX, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_EN_GOLON_WAKE_UP, "Goron Wake", "NA_SE_EN_GOLON_WAKE_UP", SEQ_SFX, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_SY_START_SHOT, "Gunshot", "NA_SE_SY_START_SHOT", SEQ_SFX, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_IT_HAMMER_HIT, "Hammer Bonk", "NA_SE_IT_HAMMER_HIT", SEQ_SFX, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_EN_IRONNACK_SWING_AXE, "Iron Knuckle", "NA_SE_EN_IRONNACK_SWING_AXE", SEQ_SFX, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_EN_FANTOM_ST_LAUGH, "Phantom Ganon Laugh", "NA_SE_EN_FANTOM_ST_LAUGH", SEQ_SFX, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_EV_PLANT_BROKEN, "Plant Explode", "NA_SE_EV_PLANT_BROKEN", SEQ_SFX, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_SY_GET_RUPY, "Rupee", "NA_SE_SY_GET_RUPY", SEQ_SFX, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_EN_NUTS_UP, "Scrub Emerge", "NA_SE_EN_NUTS_UP", SEQ_SFX, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_EN_AWA_BOUND, "Shabom Bounce", "NA_SE_EN_AWA_BOUND", SEQ_SFX, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_EN_SHELL_MOUTH, "Shellblade", "NA_SE_EN_SHELL_MOUTH", SEQ_SFX, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_EN_STALTU_DAMAGE, "Skulltula Damage", "NA_SE_EN_STALTU_DAMAGE", SEQ_SFX, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_EN_NUTS_THROW, "Spit Nut", "NA_SE_EN_NUTS_THROW", SEQ_SFX, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_SY_LOCK_ON, "Target Enemy", "NA_SE_SY_LOCK_ON", SEQ_SFX, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_SY_LOCK_ON_HUMAN, "Target Neutral", "NA_SE_SY_LOCK_ON_HUMAN", SEQ_SFX, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_SY_FSEL_CURSOR, "File Select Cursor", "NA_SE_SY_FSEL_CURSOR", SEQ_SFX, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_SY_FSEL_DECIDE_L, "File Select Choose", "NA_SE_SY_FSEL_DECIDE_L", SEQ_SFX, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_SY_FSEL_CLOSE, "File Select Back", "NA_SE_SY_FSEL_CLOSE", SEQ_SFX, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_IT_BOMB_EXPLOSION, "Bomb Explosion", "NA_SE_IT_BOMB_EXPLOSION", SEQ_SFX, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_EV_CHICKEN_CRY_A, "Chicken Cry", "NA_SE_EV_CHICKEN_CRY_A", SEQ_SFX, true, true), + + // SEQ_VOICE + SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_SWORD_N, "Adult Link - Slash", "NA_SE_VO_LI_SWORD_N", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_SWORD_L, "Adult Link - Big Slash", "NA_SE_VO_LI_SWORD_L", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_LASH, "Adult Link - Hookshot Latch Yell", "NA_SE_VO_LI_LASH", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_HANG, "Adult Link - Dangling Gasp", "NA_SE_VO_LI_HANG", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_CLIMB_END, "Adult Link - Climb Edge", "NA_SE_VO_LI_CLIMB_END", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_DAMAGE_S, "Adult Link - Small Damage", "NA_SE_VO_LI_DAMAGE_S", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_FREEZE, "Adult Link - Freeze", "NA_SE_VO_LI_FREEZE", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_FALL_S, "Adult Link - Fall Gasp", "NA_SE_VO_LI_FALL_S", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_FALL_L, "Adult Link - Fall Scream", "NA_SE_VO_LI_FALL_L", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_BREATH_REST, "Adult Link - Low Health Sigh", "NA_SE_VO_LI_BREATH_REST", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_BREATH_DRINK, "Adult Link - Bottle Sigh", "NA_SE_VO_LI_BREATH_DRINK", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_DOWN, "Adult Link - Death", "NA_SE_VO_LI_DOWN", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_TAKEN_AWAY, "Adult Link - Taken away by Wallmaster", "NA_SE_VO_LI_TAKEN_AWAY", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_HELD, "Adult Link - Grabbed by Wallmaster", "NA_SE_VO_LI_HELD", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_SNEEZE, "Adult Link - Sneeze", "NA_SE_VO_LI_SNEEZE", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_SWEAT, "Adult Link - Gasp (Hot Room)", "NA_SE_VO_LI_SWEAT", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_RELAX, "Adult Link - Yawn", "NA_SE_VO_LI_RELAX", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_SWORD_PUTAWAY, "Adult Link - Yell (Sword Putaway)", "NA_SE_VO_LI_SWORD_PUTAWAY", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_AUTO_JUMP, "Adult Link - Jump/Swing Bottle", "NA_SE_VO_LI_AUTOd_JUMP", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_MAGIC_NALE, "Adult Link - Use Nayru's Love", "NA_SE_VO_LI_MAGIC_NALE", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_SURPRISE, "Adult Link - Suprised Gasp", "NA_SE_VO_LI_SURPRISE", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_MAGIC_FROL, "Adult Link - Use Farore's Wind", "NA_SE_VO_LI_MAGIC_FROL", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_PUSH, "Adult Link - Push", "NA_SE_VO_LI_PUSH", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_HOOKSHOT_HANG, "Adult Link - Hookshot hang", "NA_SE_VO_LI_HOOKSHOT_HANG", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_LAND_DAMAGE_S, "Adult Link - Fall damage", "NA_SE_VO_LI_LAND_DAMAGE_S", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_NULL_0x1b, "Adult Link - Small grunt (unused?)", "NA_SE_VO_LI_NULL_0x1b", SEQ_VOICE, true, true), // Unused? But unique so keeping it + SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_MAGIC_ATTACK, "Adult Link - Din's Fire", "NA_SE_VO_LI_MAGIC_ATTACK", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_BL_DOWN, "Adult Link - Scream (Nocturne?)", "NA_SE_VO_BL_DOWN", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_DEMO_DAMAGE, "Adult Link - Pained Land (Nocturne?)", "NA_SE_VO_LI_DEMO_DAMAGE", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_SWORD_N_KID, "Child Link - Slash", "NA_SE_VO_LI_SWORD_N_KID", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_ROLLING_CUT_KID, "Child Link - Big Slash", "NA_SE_VO_LI_ROLLING_CUT_KID", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_LASH_KID, "Child Link - Hootshot Latch", "NA_SE_VO_LI_LASH_KID", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_HANG_KID, "Child Link - Dangling Gasp", "NA_SE_VO_LI_HANG_KID", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_CLIMB_END_KID, "Child Link - Climb Edge", "NA_SE_VO_LI_CLIMB_END_KID", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_DAMAGE_S_KID, "Child Link - Small Damage", "NA_SE_VO_LI_DAMAGE_S_KID", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_FREEZE_KID, "Child Link - Freeze", "NA_SE_VO_LI_FREEZE_KID", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_FALL_S_KID, "Child Link - Fall Gasp", "NA_SE_VO_LI_FALL_S_KID", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_FALL_L_KID, "Child Link - Fall Scream", "NA_SE_VO_LI_FALL_L_KID", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_BREATH_REST_KID, "Child Link - Low Health Sigh", "NA_SE_VO_LI_BREATH_REST_KID", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_BREATH_DRINK_KID, "Child Link - Bottle Sigh", "NA_SE_VO_LI_BREATH_DRINK_KID", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_DOWN_KID, "Child Link - Death", "NA_SE_VO_LI_DOWN_KID", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_TAKEN_AWAY_KID, "Child Link - Taken away by Wallmaster", "NA_SE_VO_LI_TAKEN_AWAY_KID", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_HELD_KID, "Child Link - Grabbed by Wallmaster", "NA_SE_VO_LI_HELD_KID", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_SNEEZE_KID, "Child Link - Sneeze", "NA_SE_VO_LI_SNEEZE_KID", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_SWEAT_KID, "Child Link - Gasp (Hot Room)", "NA_SE_VO_LI_SWEAT_KID", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_RELAX_KID, "Child Link - Yawn", "NA_SE_VO_LI_RELAX_KID", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_SWORD_PUTAWAY_KID, "Child Link - Yell (Sword Putaway)", "NA_SE_VO_LI_SWORD_PUTAWAY_KID", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_AUTO_JUMP_KID, "Child Link - Jump/Swing Bottle", "NA_SE_VO_LI_AUTO_JUMP_KID", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_MAGIC_NALE_KID, "Child Link - Use Nayru's Love", "NA_SE_VO_LI_MAGIC_NALE_KID", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_SURPRISE_KID, "Child Link - Surprised Gasp", "NA_SE_VO_LI_SURPRISE_KID", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_MAGIC_FROL_KID, "Child Link - Use Farore's Wind", "NA_SE_VO_LI_MAGIC_FROL_KID", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_PUSH_KID, "Child Link - Push", "NA_SE_VO_LI_PUSH_KID", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_HOOKSHOT_HANG_KID, "Child Link - Hookshot Hang", "NA_SE_VO_LI_HOOKSHOT_HANG_KID", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_LAND_DAMAGE_S_KID, "Child Link - Fall Damage", "NA_SE_VO_LI_LAND_DAMAGE_S_KID", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_NULL_0x1b_KID, "Child Link - Small Gasp (unused?)", "NA_SE_VO_LI_NULL_0x1b_KID", SEQ_VOICE, true, true), // Unused? But unique so keeping it + SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_MAGIC_ATTACK_KID, "Child Link - Din's Fire", "NA_SE_VO_LI_MAGIC_ATTACK_KID", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_BL_DOWN_KID, "Child Link - Scream (Nocturne?)", "NA_SE_VO_BL_DOWN_KID", SEQ_VOICE, true, true), // ... + SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_DEMO_DAMAGE_KID, "Child Link - Scream 2 (Nocturne?)", "NA_SE_VO_LI_DEMO_DAMAGE_KID", SEQ_VOICE, true, true), // Unused, matches with adult nocturne stuff + SEQUENCE_MAP_ENTRY(NA_SE_VO_NAVY_ENEMY, "Navi - Unused Enemy Target", "NA_SE_VO_NAVY_ENEMY", SEQ_VOICE, true, true), // Has no sound but is played when targetting enemies, unsure to keep or not + SEQUENCE_MAP_ENTRY(NA_SE_VO_NAVY_HELLO, "Navi - Unused NPC Hello", "NA_SE_VO_NAVY_HELLO", SEQ_VOICE, true, true), // Has no sound but is played when targetting npcs, unsure to keep or not + SEQUENCE_MAP_ENTRY(NA_SE_VO_NAVY_HEAR, "Navi - Unused Other Target", "NA_SE_VO_NAVY_HEAR", SEQ_VOICE, true, true), // Has no sound but is played when targetting npcs, unsure to keep or not + SEQUENCE_MAP_ENTRY(NA_SE_VO_NAVY_CALL, "Navi - Look/Hey/Watchout (Target Enemy)", "NA_SE_VO_NAVY_CALL", SEQ_VOICE, true, true), // Has no sound but is played when targetting signs and other things, unsure to keep or not + SEQUENCE_MAP_ENTRY(NA_SE_VO_NA_HELLO_3, "Navi - Hello", "NA_SE_VO_NA_HELLO_3", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_TA_SLEEP, "Talon - Snore", "NA_SE_VO_TA_SLEEP", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_TA_SURPRISE, "Talon - Surprised", "NA_SE_VO_TA_SURPRISE", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_TA_CRY_0, "Talon - Hmm", "NA_SE_VO_TA_CRY_0", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_TA_CRY_1, "Talon - Scream", "NA_SE_VO_TA_CRY_1", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_IN_CRY_0, "Ingo - WAAAH!", "NA_SE_VO_IN_CRY_0", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_IN_LOST, "Ingo - KAAAAH! (Lost)", "NA_SE_VO_IN_LOST", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_IN_LASH_0, "Ingo - Heyeah (Horse 1)", "NA_SE_VO_IN_LASH_0", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_IN_LASH_1, "Ingo - Ha (Horse 2)", "NA_SE_VO_IN_LASH_1", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_FR_LAUGH_0, "Great Fairy - Big Laugh", "NA_SE_VO_FR_LAUGH_0", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_FR_SMILE_0, "Great Fairy - Small Laugh", "NA_SE_VO_FR_SMILE_0", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_NB_AGONY, "Nabooru - Pained Gasp", "NA_SE_VO_NB_AGONY", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_NB_CRY_0, "Nabooru - Scream", "NA_SE_VO_NB_CRY_0", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_NB_NOTICE, "Nabooru - Hmm?", "NA_SE_VO_NB_NOTICE", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_NA_HELLO_0, "Navi - Watchout!", "NA_SE_VO_NA_HELLO_0", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_NA_HELLO_1, "Navi - Look!", "NA_SE_VO_NA_HELLO_1", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_NA_HELLO_2, "Navi - Hey! (C-up Sound)", "NA_SE_VO_NA_HELLO_2", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_RT_CRASH, "Ruto - Crash", "NA_SE_VO_RT_CRASH", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_RT_DISCOVER, "Ruto - Found", "NA_SE_VO_RT_DISCOVER", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_RT_FALL, "Ruto - Fall", "NA_SE_VO_RT_FALL", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_RT_LAUGH_0, "Ruto - Giggle", "NA_SE_VO_RT_LAUGH_0", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_RT_LIFT, "Ruto - Lifted/Navi - Intro Bonk", "NA_SE_VO_RT_LIFT", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_RT_THROW, "Ruto - Thrown", "NA_SE_VO_RT_THROW", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_RT_UNBALLANCE, "Ruto - Held Tantrum", "NA_SE_VO_RT_UNBALLANCE", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_ST_DAMAGE, "Cursed Man - Scream", "NA_SE_VO_ST_DAMAGE", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_ST_ATTACK, "Cursed Man - Gasp", "NA_SE_VO_ST_ATTACK", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_Z0_HURRY, "Child Zelda - Hurry", "NA_SE_VO_Z0_HURRY", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_Z0_MEET, "Child Zelda - Meeting Link Gasp", "NA_SE_VO_Z0_MEET", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_Z0_QUESTION, "Child Zelda - Question", "NA_SE_VO_Z0_QUESTION", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_Z0_SIGH_0, "Child Zelda - Sigh", "NA_SE_VO_Z0_SIGH_0", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_Z0_SMILE_0, "Child Zelda - Laugh", "NA_SE_VO_Z0_SMILE_0", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_Z0_SURPRISE, "Child Zelda - Sees Ganon Gasp", "NA_SE_VO_Z0_SURPRISE", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_Z0_THROW, "Child Zelda - Throws Ocarina", "NA_SE_VO_Z0_THROW", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_SK_CRY_0, "Sheik - Pained Gasp (Nocturne)", "NA_SE_VO_SK_CRY_0", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_SK_CRY_1, "Sheik - Pained Scream (Nocturne)", "NA_SE_VO_SK_CRY_1", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_SK_CRASH, "Sheik - Pained Landing (Nocturne)", "NA_SE_VO_SK_CRASH", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_SK_LAUGH, "Navi - Listen!", "NA_SE_VO_SK_LAUGH", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_SK_SHOUT, "Sheik - Shout (Throwing Deku Nut)", "NA_SE_VO_SK_SHOUT", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_Z1_CRY_0, "Adult Zelda - Scream 1", "NA_SE_VO_Z1_CRY_0", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_Z1_CRY_1, "Adult Zelda - Scream 2", "NA_SE_VO_Z1_CRY_1", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_Z1_OPENDOOR, "Adult Zelda - Open Seseme Magic Gasp", "NA_SE_VO_Z1_OPENDOOR", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_Z1_SURPRISE, "Adult Zelda - Gasp", "NA_SE_VO_Z1_SURPRISE", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_Z1_PAIN, "Adult Zelda - Pained Gasp", "NA_SE_VO_Z1_PAIN", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_KZ_MOVE, "King Zora - Mweep!", "NA_SE_VO_KZ_MOVE", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_NB_LAUGH, "Navi - Hello!", "NA_SE_VO_NB_LAUGH", SEQ_VOICE, true, true), + SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_DRINK - SFX_FLAG, "Adult Link - Drinking", "NA_SE_VO_LI_DRINK", SEQ_VOICE, true, false), + + //SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_DRINK, "Adult Link - Drinking", "NA_SE_VO_LI_DRINK", SEQ_VOICE, true, false), // Doesn't work due to SFX_FLAG + //SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_DRINK_KID, "Child Link - Drinking", "NA_SE_VO_LI_DRINK_KID", SEQ_VOICE, true, false), // Doesn't work due to SFX_FLAG + //SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_GROAN, "Adult Link - Groan (Unused)", "NA_SE_VO_LI_GROAN", SEQ_VOICE, true, false), + //SEQUENCE_MAP_ENTRY("Adult Link - Unused Sound 1?","NA_SE_VO_LI_ELECTRIC_SHOCK_LV", "NA_SE_VO_LI_ELECTRIC_SHOCK_LV", SEQ_VOICE, true, false), + //SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_GROAN_KID, "Child Link - Groan (Unused)", "NA_SE_VO_LI_GROAN_KID", SEQ_VOICE, true, false), + //SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_ELECTRIC_SHOCK_LV_KID, "Child Link - Unused Sound 1?", "NA_SE_VO_LI_ELECTRIC_SHOCK_LV_KID", SEQ_VOICE, true, false), + // Following group of Dummies are all duplicate entries for Navi saying Look/Hey/Watchout - //SEQUENCE_MAP_ENTRY(NA_SE_VO_DUMMY_0x45, "NA_SE_VO_DUMMY_0x45", "NA_SE_VO_DUMMY_0x45", SEQ_VOICE), - //SEQUENCE_MAP_ENTRY(NA_SE_VO_DUMMY_0x46, "NA_SE_VO_DUMMY_0x46", "NA_SE_VO_DUMMY_0x46", SEQ_VOICE), - //SEQUENCE_MAP_ENTRY(NA_SE_VO_DUMMY_0x47, "NA_SE_VO_DUMMY_0x47", "NA_SE_VO_DUMMY_0x47", SEQ_VOICE), - //SEQUENCE_MAP_ENTRY(NA_SE_VO_DUMMY_0x48, "NA_SE_VO_DUMMY_0x48", "NA_SE_VO_DUMMY_0x48", SEQ_VOICE), - //SEQUENCE_MAP_ENTRY(NA_SE_VO_DUMMY_0x49, "NA_SE_VO_DUMMY_0x49", "NA_SE_VO_DUMMY_0x49", SEQ_VOICE), - //SEQUENCE_MAP_ENTRY(NA_SE_VO_DUMMY_0x4a "NA_SE_VO_DUMMY_0x4a", "NA_SE_VO_DUMMY_0x4a", SEQ_VOICE), - //SEQUENCE_MAP_ENTRY(NA_SE_VO_DUMMY_0x4b, "NA_SE_VO_DUMMY_0x4b", "NA_SE_VO_DUMMY_0x4b", SEQ_VOICE), - //SEQUENCE_MAP_ENTRY(NA_SE_VO_DUMMY_0x4c, "NA_SE_VO_DUMMY_0x4c", "NA_SE_VO_DUMMY_0x4c", SEQ_VOICE), - //SEQUENCE_MAP_ENTRY(NA_SE_VO_DUMMY_0x4d, "NA_SE_VO_DUMMY_0x4d", "NA_SE_VO_DUMMY_0x4d", SEQ_VOICE), - //SEQUENCE_MAP_ENTRY(NA_SE_VO_DUMMY_0x4e, "NA_SE_VO_DUMMY_0x4e", "NA_SE_VO_DUMMY_0x4e", SEQ_VOICE), - //SEQUENCE_MAP_ENTRY(NA_SE_VO_DUMMY_0x4f, "NA_SE_VO_DUMMY_0x4f", "NA_SE_VO_DUMMY_0x4f", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_TA_SLEEP, "Talon - Snore", "NA_SE_VO_TA_SLEEP", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_TA_SURPRISE, "Talon - Surprised", "NA_SE_VO_TA_SURPRISE", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_TA_CRY_0, "Talon - Hmm", "NA_SE_VO_TA_CRY_0", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_TA_CRY_1, "Talon - Scream", "NA_SE_VO_TA_CRY_1", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_IN_CRY_0, "Ingo - WAAAH!", "NA_SE_VO_IN_CRY_0", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_IN_LOST, "Ingo - KAAAAH! (Lost)", "NA_SE_VO_IN_LOST", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_IN_LASH_0, "Ingo - Heyeah (Horse 1)", "NA_SE_VO_IN_LASH_0", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_IN_LASH_1, "Ingo - Ha (Horse 2)", "NA_SE_VO_IN_LASH_1", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_FR_LAUGH_0, "Great Fairy - Big Laugh", "NA_SE_VO_FR_LAUGH_0", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_FR_SMILE_0, "Great Fairy - Small Laugh", "NA_SE_VO_FR_SMILE_0", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_NB_AGONY, "Nabooru - Pained Gasp", "NA_SE_VO_NB_AGONY", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_NB_CRY_0, "Nabooru - Scream", "NA_SE_VO_NB_CRY_0", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_NB_NOTICE, "Nabooru - Hmm?", "NA_SE_VO_NB_NOTICE", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_NA_HELLO_0, "Navi - Watchout!", "NA_SE_VO_NA_HELLO_0", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_NA_HELLO_1, "Navi - Look!", "NA_SE_VO_NA_HELLO_1", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_NA_HELLO_2, "Navi - Hey! (C-up Sound)", "NA_SE_VO_NA_HELLO_2", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_RT_CRASH, "Ruto - Crash", "NA_SE_VO_RT_CRASH", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_RT_DISCOVER, "Ruto - Found", "NA_SE_VO_RT_DISCOVER", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_RT_FALL, "Ruto - Fall", "NA_SE_VO_RT_FALL", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_RT_LAUGH_0, "Ruto - Giggle", "NA_SE_VO_RT_LAUGH_0", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_RT_LIFT, "Ruto - Lifted/Navi - Intro Bonk", "NA_SE_VO_RT_LIFT", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_RT_THROW, "Ruto - Thrown", "NA_SE_VO_RT_THROW", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_RT_UNBALLANCE, "Ruto - Held Tantrum", "NA_SE_VO_RT_UNBALLANCE", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_ST_DAMAGE, "Cursed Man - Scream", "NA_SE_VO_ST_DAMAGE", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_ST_ATTACK, "Cursed Man - Gasp", "NA_SE_VO_ST_ATTACK", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_Z0_HURRY, "Child Zelda - Hurry", "NA_SE_VO_Z0_HURRY", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_Z0_MEET, "Child Zelda - Meeting Link Gasp", "NA_SE_VO_Z0_MEET", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_Z0_QUESTION, "Child Zelda - Question", "NA_SE_VO_Z0_QUESTION", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_Z0_SIGH_0, "Child Zelda - Sigh", "NA_SE_VO_Z0_SIGH_0", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_Z0_SMILE_0, "Child Zelda - Laugh", "NA_SE_VO_Z0_SMILE_0", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_Z0_SURPRISE, "Child Zelda - Sees Ganon Gasp", "NA_SE_VO_Z0_SURPRISE", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_Z0_THROW, "Child Zelda - Throws Ocarina", "NA_SE_VO_Z0_THROW", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_SK_CRY_0, "Sheik - Pained Gasp (Nocturne)", "NA_SE_VO_SK_CRY_0", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_SK_CRY_1, "Sheik - Pained Scream (Nocturne)", "NA_SE_VO_SK_CRY_1", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_SK_CRASH, "Sheik - Pained Landing (Nocturne)", "NA_SE_VO_SK_CRASH", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_SK_LAUGH, "Navi - Listen!", "NA_SE_VO_SK_LAUGH", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_SK_SHOUT, "Sheik - Shout (Throwing Deku Nut)", "NA_SE_VO_SK_SHOUT", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_Z1_CRY_0, "Adult Zelda - Scream 1", "NA_SE_VO_Z1_CRY_0", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_Z1_CRY_1, "Adult Zelda - Scream 2", "NA_SE_VO_Z1_CRY_1", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_Z1_OPENDOOR, "Adult Zelda - Open Seseme Magic Gasp","NA_SE_VO_Z1_OPENDOOR", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_Z1_SURPRISE, "Adult Zelda - Gasp", "NA_SE_VO_Z1_SURPRISE", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_Z1_PAIN, "Adult Zelda - Pained Gasp", "NA_SE_VO_Z1_PAIN", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_KZ_MOVE, "King Zora - Mweep!", "NA_SE_VO_KZ_MOVE", SEQ_VOICE), - SEQUENCE_MAP_ENTRY(NA_SE_VO_NB_LAUGH, "Navi - Hello!", "NA_SE_VO_NB_LAUGH", SEQ_VOICE), - //SEQUENCE_MAP_ENTRY(NA_SE_VO_IN_LAUGH, "NA_SE_VO_IN_LAUGH", "NA_SE_VO_IN_LAUGH", SEQ_VOICE), // Crashes - //SEQUENCE_MAP_ENTRY(NA_SE_VO_DUMMY_0x7d, "NA_SE_VO_DUMMY_0x7d", "NA_SE_VO_DUMMY_0x7d", SEQ_VOICE), // Unused weird Child Link sound - //SEQUENCE_MAP_ENTRY(NA_SE_VO_DUMMY_0x7e, "NA_SE_VO_DUMMY_0x7e", "NA_SE_VO_DUMMY_0x7e", SEQ_VOICE), // Unused weird Child Link sound - //SEQUENCE_MAP_ENTRY(NA_SE_VO_DUMMY_0x7f, "NA_SE_VO_DUMMY_0x7f", "NA_SE_VO_DUMMY_0x7f", SEQ_VOICE), // Unused weird Child Link sound - //SEQUENCE_MAP_ENTRY(NA_SE_VO_DUMMY_0x80, "NA_SE_VO_DUMMY_0x80", "NA_SE_VO_DUMMY_0x80", SEQ_VOICE), // Unused and empty - //SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_AUTO_JUMP_DARKLINK,"NA_SE_VO_LI_AUTO_JUMP_DARKLINK", "NA_SE_VO_LI_AUTO_JUMP_DARKLINK", SEQ_VOICE), // Implies Dark Link but isn't used in anything - //SEQUENCE_MAP_ENTRY(NA_SE_VO_DUMMY_0x82_YOBI, "NA_SE_VO_DUMMY_0x82_YOBI", "NA_SE_VO_DUMMY_0x82_YOBI", SEQ_VOICE), // Rest are unused and empty - //SEQUENCE_MAP_ENTRY(NA_SE_VO_DUMMY_0x83_YOBI, "NA_SE_VO_DUMMY_0x83_YOBI", "NA_SE_VO_DUMMY_0x83_YOBI", SEQ_VOICE), // .. - //SEQUENCE_MAP_ENTRY(NA_SE_VO_DUMMY_0x84_YOBI, "NA_SE_VO_DUMMY_0x84_YOBI", "NA_SE_VO_DUMMY_0x84_YOBI", SEQ_VOICE), // .. - //SEQUENCE_MAP_ENTRY(NA_SE_VO_DUMMY_0x85_YOBI, "NA_SE_VO_DUMMY_0x85_YOBI", "NA_SE_VO_DUMMY_0x85_YOBI", SEQ_VOICE), // .. - //SEQUENCE_MAP_ENTRY(NA_SE_VO_DUMMY_0x86_YOBI, "NA_SE_VO_DUMMY_0x86_YOBI", "NA_SE_VO_DUMMY_0x86_YOBI", SEQ_VOICE), // .. - //SEQUENCE_MAP_ENTRY(NA_SE_VO_DUMMY_0x87_YOBI, "NA_SE_VO_DUMMY_0x87_YOBI", "NA_SE_VO_DUMMY_0x87_YOBI", SEQ_VOICE), // .. - //SEQUENCE_MAP_ENTRY(NA_SE_VO_DUMMY_0x88_YOBI, "NA_SE_VO_DUMMY_0x88_YOBI", "NA_SE_VO_DUMMY_0x88_YOBI", SEQ_VOICE), // .. - //SEQUENCE_MAP_ENTRY(NA_SE_VO_DUMMY_0x89_YOBI, "NA_SE_VO_DUMMY_0x89_YOBI", "NA_SE_VO_DUMMY_0x89_YOBI", SEQ_VOICE), // .. + //SEQUENCE_MAP_ENTRY(NA_SE_VO_DUMMY_0x45, "NA_SE_VO_DUMMY_0x45", "NA_SE_VO_DUMMY_0x45", SEQ_VOICE, true, false), + //SEQUENCE_MAP_ENTRY(NA_SE_VO_DUMMY_0x46, "NA_SE_VO_DUMMY_0x46", "NA_SE_VO_DUMMY_0x46", SEQ_VOICE, true, false), + //SEQUENCE_MAP_ENTRY(NA_SE_VO_DUMMY_0x47, "NA_SE_VO_DUMMY_0x47", "NA_SE_VO_DUMMY_0x47", SEQ_VOICE, true, false), + //SEQUENCE_MAP_ENTRY(NA_SE_VO_DUMMY_0x48, "NA_SE_VO_DUMMY_0x48", "NA_SE_VO_DUMMY_0x48", SEQ_VOICE, true, false), + //SEQUENCE_MAP_ENTRY(NA_SE_VO_DUMMY_0x49, "NA_SE_VO_DUMMY_0x49", "NA_SE_VO_DUMMY_0x49", SEQ_VOICE, true, false), + //SEQUENCE_MAP_ENTRY(NA_SE_VO_DUMMY_0x4a "NA_SE_VO_DUMMY_0x4a", "NA_SE_VO_DUMMY_0x4a", SEQ_VOICE, true, false), + //SEQUENCE_MAP_ENTRY(NA_SE_VO_DUMMY_0x4b, "NA_SE_VO_DUMMY_0x4b", "NA_SE_VO_DUMMY_0x4b", SEQ_VOICE, true, false), + //SEQUENCE_MAP_ENTRY(NA_SE_VO_DUMMY_0x4c, "NA_SE_VO_DUMMY_0x4c", "NA_SE_VO_DUMMY_0x4c", SEQ_VOICE, true, false), + //SEQUENCE_MAP_ENTRY(NA_SE_VO_DUMMY_0x4d, "NA_SE_VO_DUMMY_0x4d", "NA_SE_VO_DUMMY_0x4d", SEQ_VOICE, true, false), + //SEQUENCE_MAP_ENTRY(NA_SE_VO_DUMMY_0x4e, "NA_SE_VO_DUMMY_0x4e", "NA_SE_VO_DUMMY_0x4e", SEQ_VOICE, true, false), + //SEQUENCE_MAP_ENTRY(NA_SE_VO_DUMMY_0x4f, "NA_SE_VO_DUMMY_0x4f", "NA_SE_VO_DUMMY_0x4f", SEQ_VOICE, true, false), + + //SEQUENCE_MAP_ENTRY(NA_SE_VO_IN_LAUGH, "NA_SE_VO_IN_LAUGH", "NA_SE_VO_IN_LAUGH", SEQ_VOICE, true, false), // Crashes + //SEQUENCE_MAP_ENTRY(NA_SE_VO_DUMMY_0x7d, "NA_SE_VO_DUMMY_0x7d", "NA_SE_VO_DUMMY_0x7d", SEQ_VOICE, true, false), // Unused weird Child Link sound + //SEQUENCE_MAP_ENTRY(NA_SE_VO_DUMMY_0x7e, "NA_SE_VO_DUMMY_0x7e", "NA_SE_VO_DUMMY_0x7e", SEQ_VOICE, true, false), // Unused weird Child Link sound + //SEQUENCE_MAP_ENTRY(NA_SE_VO_DUMMY_0x7f, "NA_SE_VO_DUMMY_0x7f", "NA_SE_VO_DUMMY_0x7f", SEQ_VOICE, true, false), // Unused weird Child Link sound + //SEQUENCE_MAP_ENTRY(NA_SE_VO_DUMMY_0x80, "NA_SE_VO_DUMMY_0x80", "NA_SE_VO_DUMMY_0x80", SEQ_VOICE, true, false), // Unused and empty + //SEQUENCE_MAP_ENTRY(NA_SE_VO_LI_AUTO_JUMP_DARKLINK,"NA_SE_VO_LI_AUTO_JUMP_DARKLINK", "NA_SE_VO_LI_AUTO_JUMP_DARKLINK", SEQ_VOICE, true, false), // Implies Dark Link but isn't used in anything + //SEQUENCE_MAP_ENTRY(NA_SE_VO_DUMMY_0x82_YOBI, "NA_SE_VO_DUMMY_0x82_YOBI", "NA_SE_VO_DUMMY_0x82_YOBI", SEQ_VOICE, true, false), // Rest are unused and empty + //SEQUENCE_MAP_ENTRY(NA_SE_VO_DUMMY_0x83_YOBI, "NA_SE_VO_DUMMY_0x83_YOBI", "NA_SE_VO_DUMMY_0x83_YOBI", SEQ_VOICE, true, false), // .. + //SEQUENCE_MAP_ENTRY(NA_SE_VO_DUMMY_0x84_YOBI, "NA_SE_VO_DUMMY_0x84_YOBI", "NA_SE_VO_DUMMY_0x84_YOBI", SEQ_VOICE, true, false), // .. + //SEQUENCE_MAP_ENTRY(NA_SE_VO_DUMMY_0x85_YOBI, "NA_SE_VO_DUMMY_0x85_YOBI", "NA_SE_VO_DUMMY_0x85_YOBI", SEQ_VOICE, true, false), // .. + //SEQUENCE_MAP_ENTRY(NA_SE_VO_DUMMY_0x86_YOBI, "NA_SE_VO_DUMMY_0x86_YOBI", "NA_SE_VO_DUMMY_0x86_YOBI", SEQ_VOICE, true, false), // .. + //SEQUENCE_MAP_ENTRY(NA_SE_VO_DUMMY_0x87_YOBI, "NA_SE_VO_DUMMY_0x87_YOBI", "NA_SE_VO_DUMMY_0x87_YOBI", SEQ_VOICE, true, false), // .. + //SEQUENCE_MAP_ENTRY(NA_SE_VO_DUMMY_0x88_YOBI, "NA_SE_VO_DUMMY_0x88_YOBI", "NA_SE_VO_DUMMY_0x88_YOBI", SEQ_VOICE, true, false), // .. + //SEQUENCE_MAP_ENTRY(NA_SE_VO_DUMMY_0x89_YOBI, "NA_SE_VO_DUMMY_0x89_YOBI", "NA_SE_VO_DUMMY_0x89_YOBI", SEQ_VOICE, true, false), // .. }; } @@ -331,7 +353,7 @@ void AudioCollection::AddToCollection(char* otrPath, uint16_t seqNum) { SequenceInfo info = {seqNum, sequenceName, StringHelper::Replace(StringHelper::Replace(StringHelper::Replace(sequenceName, " ", "_"), "~", "-"),".", ""), - type}; + type, false, true}; sequenceMap.emplace(seqNum, info); } @@ -379,12 +401,10 @@ void AudioCollection::InitializeShufflePool() { for (auto& [seqId, seqInfo] : sequenceMap) { const std::string cvarKey = "gAudioEditor.Excluded." + seqInfo.sfxKey; - if (CVarGetInteger(cvarKey.c_str(), 0)) { + if (CVarGetInteger(cvarKey.c_str(), 0) && !seqInfo.canBeUsedAsReplacement) { excludedSequences.insert(&seqInfo); } else { - if (seqInfo.category != SEQ_NOSHUFFLE) { - includedSequences.insert(&seqInfo); - } + includedSequences.insert(&seqInfo); } } diff --git a/soh/soh/Enhancements/audio/AudioCollection.h b/soh/soh/Enhancements/audio/AudioCollection.h index c60a7e739..1d53777e7 100644 --- a/soh/soh/Enhancements/audio/AudioCollection.h +++ b/soh/soh/Enhancements/audio/AudioCollection.h @@ -25,6 +25,8 @@ struct SequenceInfo { std::string label; std::string sfxKey; SeqType category; + bool canBeReplaced; + bool canBeUsedAsReplacement; }; class AudioCollection { diff --git a/soh/soh/Enhancements/audio/AudioEditor.cpp b/soh/soh/Enhancements/audio/AudioEditor.cpp index ce33a0560..8b0615a83 100644 --- a/soh/soh/Enhancements/audio/AudioEditor.cpp +++ b/soh/soh/Enhancements/audio/AudioEditor.cpp @@ -27,7 +27,7 @@ s8 reverbAdd = 0; #define SEQ_COUNT_BGM_EVENT 17 #define SEQ_COUNT_INSTRUMENT 6 #define SEQ_COUNT_SFX 57 -#define SEQ_COUNT_VOICE 107 +#define SEQ_COUNT_VOICE 108 size_t AuthenticCountBySequenceType(SeqType type) { switch (type) { @@ -82,7 +82,7 @@ void RandomizeGroup(SeqType type) { // use a while loop to add duplicates if we don't have enough included sequences while (values.size() < AuthenticCountBySequenceType(type)) { for (const auto& seqData : AudioCollection::Instance->GetIncludedSequences()) { - if (seqData->category & type) { + if (seqData->category & type && seqData->canBeUsedAsReplacement) { values.push_back(seqData->sequenceId); } } @@ -97,7 +97,7 @@ void RandomizeGroup(SeqType type) { // don't randomize locked entries if ((seqData.category & type) && CVarGetInteger(cvarLockKey.c_str(), 0) == 0) { // Only save authentic sequence CVars - if (((seqData.category & SEQ_BGM_CUSTOM) || seqData.category == SEQ_FANFARE) && seqData.sequenceId >= MAX_AUTHENTIC_SEQID) { + if ((((seqData.category & SEQ_BGM_CUSTOM) || seqData.category == SEQ_FANFARE) && seqData.sequenceId >= MAX_AUTHENTIC_SEQID) || seqData.canBeReplaced == false) { continue; } const int randomValue = values.back(); @@ -194,10 +194,11 @@ void Draw_SfxTab(const std::string& tabId, SeqType type) { continue; } // Do not display custom sequences in the list - if (((seqData.category & SEQ_BGM_CUSTOM) || seqData.category == SEQ_FANFARE) && defaultValue >= MAX_AUTHENTIC_SEQID) { + if ((((seqData.category & SEQ_BGM_CUSTOM) || seqData.category == SEQ_FANFARE) && defaultValue >= MAX_AUTHENTIC_SEQID) || seqData.canBeReplaced == false) { continue; } + const std::string initialSfxKey = seqData.sfxKey; const std::string cvarKey = AudioCollection::Instance->GetCvarKey(seqData.sfxKey); const std::string cvarLockKey = AudioCollection::Instance->GetCvarLockKey(seqData.sfxKey); const std::string hiddenKey = "##" + cvarKey; @@ -215,7 +216,8 @@ void Draw_SfxTab(const std::string& tabId, SeqType type) { const int initialValue = map.contains(currentValue) ? currentValue : defaultValue; if (ImGui::BeginCombo(hiddenKey.c_str(), map.at(initialValue).label.c_str())) { for (const auto& [value, seqData] : map) { - if (~(seqData.category) & type) { + // If excluded as a replacement sequence, don't show in other dropdowns except the effect's own dropdown. + if (~(seqData.category) & type || (!seqData.canBeUsedAsReplacement && initialSfxKey != seqData.sfxKey)) { continue; } diff --git a/soh/soh/Enhancements/boss-rush/BossRush.cpp b/soh/soh/Enhancements/boss-rush/BossRush.cpp index d35b8825e..9c5311922 100644 --- a/soh/soh/Enhancements/boss-rush/BossRush.cpp +++ b/soh/soh/Enhancements/boss-rush/BossRush.cpp @@ -462,8 +462,8 @@ void BossRush_SetEquipment(uint8_t linkAge) { brCButtonSlots = { SLOT_STICK, SLOT_NUT, SLOT_BOMB, SLOT_NONE, SLOT_NONE, SLOT_NONE, SLOT_NONE }; - Inventory_ChangeEquipment(EQUIP_SWORD, PLAYER_SWORD_KOKIRI); - Inventory_ChangeEquipment(EQUIP_SHIELD, PLAYER_SHIELD_DEKU); + Inventory_ChangeEquipment(EQUIP_TYPE_SWORD, EQUIP_VALUE_SWORD_KOKIRI); + Inventory_ChangeEquipment(EQUIP_TYPE_SHIELD, EQUIP_VALUE_SHIELD_DEKU); // Set Adult equipment. } else { brButtonItems = { ITEM_SWORD_MASTER, ITEM_BOW, ITEM_HAMMER, ITEM_BOMB, @@ -471,9 +471,9 @@ void BossRush_SetEquipment(uint8_t linkAge) { brCButtonSlots = { SLOT_BOW, SLOT_HAMMER, SLOT_BOMB, SLOT_NONE, SLOT_NONE, SLOT_NONE, SLOT_NONE }; - Inventory_ChangeEquipment(EQUIP_SWORD, PLAYER_SWORD_MASTER); - Inventory_ChangeEquipment(EQUIP_SHIELD, PLAYER_SHIELD_MIRROR); - Inventory_ChangeEquipment(EQUIP_TUNIC, PLAYER_TUNIC_GORON + 1); // Game expects tunic + 1, don't ask me why. + Inventory_ChangeEquipment(EQUIP_TYPE_SWORD, EQUIP_VALUE_SWORD_MASTER); + Inventory_ChangeEquipment(EQUIP_TYPE_SHIELD, EQUIP_VALUE_SHIELD_MIRROR); + Inventory_ChangeEquipment(EQUIP_TYPE_TUNIC, EQUIP_VALUE_TUNIC_GORON); } // Button Items diff --git a/soh/soh/Enhancements/controls/GameControlEditor.cpp b/soh/soh/Enhancements/controls/GameControlEditor.cpp index 3bd650637..935935c48 100644 --- a/soh/soh/Enhancements/controls/GameControlEditor.cpp +++ b/soh/soh/Enhancements/controls/GameControlEditor.cpp @@ -331,13 +331,14 @@ namespace GameControlEditor { void DrawLEDControlPanel(GameControlEditorWindow* window) { window->BeginGroupPanelPublic("LED Colors", ImGui::GetContentRegionAvail()); - static const char* ledSources[4] = { "Original Tunic Colors", "Cosmetics Tunic Colors", "Health Colors", "Custom" }; + static const char* ledSources[] = { "Original Tunic Colors", "Cosmetics Tunic Colors", "Health Colors", + "Original Navi Targeting Colors", "Cosmetics Navi Targeting Colors", "Custom" }; UIWidgets::PaddedText("Source"); UIWidgets::EnhancementCombobox("gLedColorSource", ledSources, LED_SOURCE_TUNIC_ORIGINAL); DrawHelpIcon("Health\n- Red when health critical (13-20% depending on max health)\n- Yellow when health < 40%. Green otherwise.\n\n" \ "Tunics: colors will mirror currently equipped tunic, whether original or the current values in Cosmetics Editor.\n\n" \ "Custom: single, solid color"); - if (CVarGetInteger("gLedColorSource", 1) == 3) { + if (CVarGetInteger("gLedColorSource", 1) == LED_SOURCE_CUSTOM) { UIWidgets::Spacer(3); auto port1Color = CVarGetColor24("gLedPort1Color", { 255, 255, 255 }); ImVec4 colorVec = { port1Color.r / 255.0f, port1Color.g / 255.0f, port1Color.b / 255.0f, 1.0f }; diff --git a/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp b/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp index 548ffa60c..8c2707453 100644 --- a/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp +++ b/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp @@ -1535,7 +1535,7 @@ void DrawSillyTab() { CVarClear("gCosmetics.BunnyHood_EarSpread"); LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } - UIWidgets::EnhancementSliderFloat("Goron Neck Length: %f", "##Goron_NeckLength", "gCosmetics.Goron_NeckLength", 0.0f, 1000.0f, "", 0.0f, false); + UIWidgets::EnhancementSliderFloat("Goron Neck Length: %f", "##Goron_NeckLength", "gCosmetics.Goron_NeckLength", 0.0f, 5000.0f, "", 0.0f, false); ImGui::SameLine(); if (ImGui::Button("Reset##Goron_NeckLength")) { CVarClear("gCosmetics.Goron_NeckLength"); diff --git a/soh/soh/Enhancements/debugconsole.cpp b/soh/soh/Enhancements/debugconsole.cpp index c94d5f806..3e61505b2 100644 --- a/soh/soh/Enhancements/debugconsole.cpp +++ b/soh/soh/Enhancements/debugconsole.cpp @@ -1102,9 +1102,9 @@ static bool SpeedModifierHandler(std::shared_ptr Console, const st } const static std::map boots { - { "kokiri", PLAYER_BOOTS_KOKIRI }, - { "iron", PLAYER_BOOTS_IRON }, - { "hover", PLAYER_BOOTS_HOVER }, + { "kokiri", EQUIP_VALUE_BOOTS_KOKIRI }, + { "iron", EQUIP_VALUE_BOOTS_IRON }, + { "hover", EQUIP_VALUE_BOOTS_HOVER }, }; static bool BootsHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { diff --git a/soh/soh/Enhancements/debugger/debugSaveEditor.cpp b/soh/soh/Enhancements/debugger/debugSaveEditor.cpp index cb16a9915..9af4eadb7 100644 --- a/soh/soh/Enhancements/debugger/debugSaveEditor.cpp +++ b/soh/soh/Enhancements/debugger/debugSaveEditor.cpp @@ -1602,17 +1602,17 @@ void DrawPlayerTab() { if (ImGui::Selectable("None")) { player->currentSwordItemId = ITEM_NONE; gSaveContext.equips.buttonItems[0] = ITEM_NONE; - Inventory_ChangeEquipment(EQUIP_SWORD, PLAYER_SWORD_NONE); + Inventory_ChangeEquipment(EQUIP_TYPE_SWORD, EQUIP_VALUE_SWORD_NONE); } if (ImGui::Selectable("Kokiri Sword")) { player->currentSwordItemId = ITEM_SWORD_KOKIRI; gSaveContext.equips.buttonItems[0] = ITEM_SWORD_KOKIRI; - Inventory_ChangeEquipment(EQUIP_SWORD, PLAYER_SWORD_KOKIRI); + Inventory_ChangeEquipment(EQUIP_TYPE_SWORD, EQUIP_VALUE_SWORD_KOKIRI); } if (ImGui::Selectable("Master Sword")) { player->currentSwordItemId = ITEM_SWORD_MASTER; gSaveContext.equips.buttonItems[0] = ITEM_SWORD_MASTER; - Inventory_ChangeEquipment(EQUIP_SWORD, PLAYER_SWORD_MASTER); + Inventory_ChangeEquipment(EQUIP_TYPE_SWORD, EQUIP_VALUE_SWORD_MASTER); } if (ImGui::Selectable("Biggoron's Sword")) { if (gSaveContext.bgsFlag) { @@ -1629,12 +1629,12 @@ void DrawPlayerTab() { gSaveContext.equips.buttonItems[0] = ITEM_SWORD_KNIFE; } - Inventory_ChangeEquipment(EQUIP_SWORD, PLAYER_SWORD_BIGGORON); + Inventory_ChangeEquipment(EQUIP_TYPE_SWORD, EQUIP_VALUE_SWORD_BIGGORON); } if (ImGui::Selectable("Fishing Pole")) { player->currentSwordItemId = ITEM_FISHING_POLE; gSaveContext.equips.buttonItems[0] = ITEM_FISHING_POLE; - Inventory_ChangeEquipment(EQUIP_SWORD, PLAYER_SWORD_MASTER); + Inventory_ChangeEquipment(EQUIP_TYPE_SWORD, EQUIP_VALUE_SWORD_MASTER); } ImGui::EndCombo(); @@ -1642,19 +1642,19 @@ void DrawPlayerTab() { if (ImGui::BeginCombo("Shield", curShield)) { if (ImGui::Selectable("None")) { player->currentShield = PLAYER_SHIELD_NONE; - Inventory_ChangeEquipment(EQUIP_SHIELD, PLAYER_SHIELD_NONE); + Inventory_ChangeEquipment(EQUIP_TYPE_SHIELD, EQUIP_VALUE_SHIELD_NONE); } if (ImGui::Selectable("Deku Shield")) { player->currentShield = PLAYER_SHIELD_DEKU; - Inventory_ChangeEquipment(EQUIP_SHIELD, PLAYER_SHIELD_DEKU); + Inventory_ChangeEquipment(EQUIP_TYPE_SHIELD, EQUIP_VALUE_SHIELD_DEKU); } if (ImGui::Selectable("Hylian Shield")) { player->currentShield = PLAYER_SHIELD_HYLIAN; - Inventory_ChangeEquipment(EQUIP_SHIELD, PLAYER_SHIELD_HYLIAN); + Inventory_ChangeEquipment(EQUIP_TYPE_SHIELD, EQUIP_VALUE_SHIELD_HYLIAN); } if (ImGui::Selectable("Mirror Shield")) { player->currentShield = PLAYER_SHIELD_MIRROR; - Inventory_ChangeEquipment(EQUIP_SHIELD, PLAYER_SHIELD_MIRROR); + Inventory_ChangeEquipment(EQUIP_TYPE_SHIELD, EQUIP_VALUE_SHIELD_MIRROR); } ImGui::EndCombo(); } @@ -1662,15 +1662,15 @@ void DrawPlayerTab() { if (ImGui::BeginCombo("Tunic", curTunic)) { if (ImGui::Selectable("Kokiri Tunic")) { player->currentTunic = PLAYER_TUNIC_KOKIRI; - Inventory_ChangeEquipment(EQUIP_TUNIC, PLAYER_TUNIC_KOKIRI + 1); + Inventory_ChangeEquipment(EQUIP_TYPE_TUNIC, EQUIP_VALUE_TUNIC_KOKIRI); } if (ImGui::Selectable("Goron Tunic")) { player->currentTunic = PLAYER_TUNIC_GORON; - Inventory_ChangeEquipment(EQUIP_TUNIC, PLAYER_TUNIC_GORON + 1); + Inventory_ChangeEquipment(EQUIP_TYPE_TUNIC, EQUIP_VALUE_TUNIC_GORON); } if (ImGui::Selectable("Zora Tunic")) { player->currentTunic = PLAYER_TUNIC_ZORA; - Inventory_ChangeEquipment(EQUIP_TUNIC, PLAYER_TUNIC_ZORA + 1); + Inventory_ChangeEquipment(EQUIP_TYPE_TUNIC, EQUIP_VALUE_TUNIC_ZORA); } ImGui::EndCombo(); } @@ -1678,15 +1678,15 @@ void DrawPlayerTab() { if (ImGui::BeginCombo("Boots", curBoots)) { if (ImGui::Selectable("Kokiri Boots")) { player->currentBoots = PLAYER_BOOTS_KOKIRI; - Inventory_ChangeEquipment(EQUIP_BOOTS, PLAYER_BOOTS_KOKIRI + 1); + Inventory_ChangeEquipment(EQUIP_TYPE_BOOTS, EQUIP_VALUE_BOOTS_KOKIRI); } if (ImGui::Selectable("Iron Boots")) { player->currentBoots = PLAYER_BOOTS_IRON; - Inventory_ChangeEquipment(EQUIP_BOOTS, PLAYER_BOOTS_IRON + 1); + Inventory_ChangeEquipment(EQUIP_TYPE_BOOTS, EQUIP_VALUE_BOOTS_IRON); } if (ImGui::Selectable("Hover Boots")) { player->currentBoots = PLAYER_BOOTS_HOVER; - Inventory_ChangeEquipment(EQUIP_BOOTS, PLAYER_BOOTS_HOVER + 1); + Inventory_ChangeEquipment(EQUIP_TYPE_BOOTS, EQUIP_VALUE_BOOTS_HOVER); } ImGui::EndCombo(); } diff --git a/soh/soh/Enhancements/debugger/debugSaveEditor.h b/soh/soh/Enhancements/debugger/debugSaveEditor.h index 96af28375..1daddbf17 100644 --- a/soh/soh/Enhancements/debugger/debugSaveEditor.h +++ b/soh/soh/Enhancements/debugger/debugSaveEditor.h @@ -500,6 +500,8 @@ const std::vector flagTables = { { RAND_INF_KAK_100_GOLD_SKULLTULA_REWARD, "KAK_100_GOLD_SKULLTULA_REWARD" }, { RAND_INF_GREG_FOUND, "RAND_INF_GREG_FOUND" }, + + { RAND_INF_TOT_MASTER_SWORD, "RAND_INF_TOT_MASTER_SWORD"}, { RAND_INF_CHILD_FISHING, "RAND_INF_CHILD_FISHING" }, { RAND_INF_ADULT_FISHING, "RAND_INF_ADULT_FISHING" }, { RAND_INF_10_BIG_POES, "RAND_INF_10_BIG_POES" }, diff --git a/soh/soh/Enhancements/game-interactor/GameInteractionEffect.cpp b/soh/soh/Enhancements/game-interactor/GameInteractionEffect.cpp index 8a8120e70..206b26426 100644 --- a/soh/soh/Enhancements/game-interactor/GameInteractionEffect.cpp +++ b/soh/soh/Enhancements/game-interactor/GameInteractionEffect.cpp @@ -373,7 +373,7 @@ namespace GameInteractionEffect { GameInteractor::RawAction::ForceEquipBoots(parameters[0]); } void ForceEquipBoots::_Remove() { - GameInteractor::RawAction::ForceEquipBoots(PLAYER_BOOTS_KOKIRI); + GameInteractor::RawAction::ForceEquipBoots(EQUIP_VALUE_BOOTS_KOKIRI); } // MARK: - ModifyRunSpeedModifier @@ -425,9 +425,9 @@ namespace GameInteractionEffect { GameInteractionEffectQueryResult GiveOrTakeShield::CanBeApplied() { if (!GameInteractor::IsSaveLoaded() || GameInteractor::IsGameplayPaused()) { return GameInteractionEffectQueryResult::TemporarilyNotPossible; - } else if ((parameters[0] > 0 && ((gBitFlags[parameters[0] - ITEM_SHIELD_DEKU] << gEquipShifts[EQUIP_SHIELD]) & + } else if ((parameters[0] > 0 && ((gBitFlags[parameters[0] - ITEM_SHIELD_DEKU] << gEquipShifts[EQUIP_TYPE_SHIELD]) & gSaveContext.inventory.equipment)) || - (parameters[0] < 0 && !((gBitFlags[(parameters[0] * -1) - ITEM_SHIELD_DEKU] << gEquipShifts[EQUIP_SHIELD]) & + (parameters[0] < 0 && !((gBitFlags[(parameters[0] * -1) - ITEM_SHIELD_DEKU] << gEquipShifts[EQUIP_TYPE_SHIELD]) & gSaveContext.inventory.equipment))) { return GameInteractionEffectQueryResult::NotPossible; } else { diff --git a/soh/soh/Enhancements/game-interactor/GameInteractor_RawAction.cpp b/soh/soh/Enhancements/game-interactor/GameInteractor_RawAction.cpp index 1dedc3fa1..54a3b8e7b 100644 --- a/soh/soh/Enhancements/game-interactor/GameInteractor_RawAction.cpp +++ b/soh/soh/Enhancements/game-interactor/GameInteractor_RawAction.cpp @@ -97,8 +97,8 @@ void GameInteractor::RawAction::SetWeatherStorm(bool active) { void GameInteractor::RawAction::ForceEquipBoots(int8_t boots) { Player* player = GET_PLAYER(gPlayState); - player->currentBoots = boots; - Inventory_ChangeEquipment(EQUIP_BOOTS, boots + 1); + player->currentBoots = BOOTS_EQUIP_TO_PLAYER(boots); + Inventory_ChangeEquipment(EQUIP_TYPE_BOOTS, boots); Player_SetBootData(gPlayState, player); } @@ -274,24 +274,24 @@ void GameInteractor::RawAction::GiveOrTakeShield(int32_t shield) { break; } - gSaveContext.inventory.equipment &= ~(gBitFlags[shield - ITEM_SHIELD_DEKU] << gEquipShifts[EQUIP_SHIELD]); + gSaveContext.inventory.equipment &= ~(gBitFlags[shield - ITEM_SHIELD_DEKU] << gEquipShifts[EQUIP_TYPE_SHIELD]); if (player->currentShield == shieldToCheck) { player->currentShield = PLAYER_SHIELD_NONE; - Inventory_ChangeEquipment(EQUIP_SHIELD, PLAYER_SHIELD_NONE); + Inventory_ChangeEquipment(EQUIP_TYPE_SHIELD, EQUIP_VALUE_SHIELD_NONE); } } else { Item_Give(gPlayState, shield); if (player->currentShield == PLAYER_SHIELD_NONE) { if (LINK_IS_CHILD && shield == ITEM_SHIELD_DEKU) { player->currentShield = PLAYER_SHIELD_DEKU; - Inventory_ChangeEquipment(EQUIP_SHIELD, PLAYER_SHIELD_DEKU); + Inventory_ChangeEquipment(EQUIP_TYPE_SHIELD, EQUIP_VALUE_SHIELD_DEKU); } else if (LINK_IS_ADULT && shield == ITEM_SHIELD_MIRROR) { player->currentShield = PLAYER_SHIELD_MIRROR; - Inventory_ChangeEquipment(EQUIP_SHIELD, PLAYER_SHIELD_MIRROR); + Inventory_ChangeEquipment(EQUIP_TYPE_SHIELD, EQUIP_VALUE_SHIELD_MIRROR); } else if (shield == ITEM_SHIELD_HYLIAN) { player->currentShield = PLAYER_SHIELD_HYLIAN; - Inventory_ChangeEquipment(EQUIP_SHIELD, PLAYER_SHIELD_HYLIAN); + Inventory_ChangeEquipment(EQUIP_TYPE_SHIELD, EQUIP_VALUE_SHIELD_HYLIAN); } } } diff --git a/soh/soh/Enhancements/gameplaystats.cpp b/soh/soh/Enhancements/gameplaystats.cpp index 31bf36d3c..a6e5a47e8 100644 --- a/soh/soh/Enhancements/gameplaystats.cpp +++ b/soh/soh/Enhancements/gameplaystats.cpp @@ -7,6 +7,7 @@ extern "C" { #include "functions.h" #include "macros.h" #include "../UIWidgets.hpp" +#include "soh/util.h" #include #include @@ -286,10 +287,8 @@ extern "C" char* GameplayStats_GetCurrentTime() { } void LoadStatsVersion1() { - std::string buildVersion; - SaveManager::Instance->LoadData("buildVersion", buildVersion); - strncpy(gSaveContext.sohStats.buildVersion, buildVersion.c_str(), ARRAY_COUNT(gSaveContext.sohStats.buildVersion) - 1); - gSaveContext.sohStats.buildVersion[ARRAY_COUNT(gSaveContext.sohStats.buildVersion) - 1] = 0; + SaveManager::Instance->LoadCharArray("buildVersion", gSaveContext.sohStats.buildVersion, + ARRAY_COUNT(gSaveContext.sohStats.buildVersion)); SaveManager::Instance->LoadData("buildVersionMajor", gSaveContext.sohStats.buildVersionMajor); SaveManager::Instance->LoadData("buildVersionMinor", gSaveContext.sohStats.buildVersionMinor); SaveManager::Instance->LoadData("buildVersionPatch", gSaveContext.sohStats.buildVersionPatch); @@ -683,8 +682,8 @@ void InitStats(bool isDebug) { gSaveContext.sohStats.entrancesDiscovered[entrancesIdx] = 0; } - strncpy(gSaveContext.sohStats.buildVersion, (const char*) gBuildVersion, sizeof(gSaveContext.sohStats.buildVersion) - 1); - gSaveContext.sohStats.buildVersion[sizeof(gSaveContext.sohStats.buildVersion) - 1] = 0; + SohUtils::CopyStringToCharArray(gSaveContext.sohStats.buildVersion, std::string((char*)gBuildVersion), + ARRAY_COUNT(gSaveContext.sohStats.buildVersion)); gSaveContext.sohStats.buildVersionMajor = gBuildVersionMajor; gSaveContext.sohStats.buildVersionMinor = gBuildVersionMinor; gSaveContext.sohStats.buildVersionPatch = gBuildVersionPatch; diff --git a/soh/soh/Enhancements/mods.cpp b/soh/soh/Enhancements/mods.cpp index aa731e687..687f697c2 100644 --- a/soh/soh/Enhancements/mods.cpp +++ b/soh/soh/Enhancements/mods.cpp @@ -147,6 +147,19 @@ void RegisterInfiniteISG() { }); } +//Permanent quick put away (QPA) glitched damage value +void RegisterEzQPA() { + GameInteractor::Instance->RegisterGameHook([]() { + if (!gPlayState) return; + + if (CVarGetInteger("gEzQPA", 0) != 0) { + Player* player = GET_PLAYER(gPlayState); + player->meleeWeaponQuads[0].info.toucher.dmgFlags = 0x16171617; + player->meleeWeaponQuads[1].info.toucher.dmgFlags = 0x16171617; + } + }); +} + void RegisterUnrestrictedItems() { GameInteractor::Instance->RegisterGameHook([]() { if (!gPlayState) return; @@ -223,7 +236,7 @@ void RegisterOcarinaTimeTravel() { Actor* nearbyOcarinaSpot = Actor_FindNearby(gPlayState, player, ACTOR_EN_OKARINA_TAG, ACTORCAT_PROP, 120.0f); Actor* nearbyDoorOfTime = Actor_FindNearby(gPlayState, player, ACTOR_DOOR_TOKI, ACTORCAT_BG, 500.0f); Actor* nearbyFrogs = Actor_FindNearby(gPlayState, player, ACTOR_EN_FR, ACTORCAT_NPC, 300.0f); - uint8_t hasMasterSword = (gBitFlags[ITEM_SWORD_MASTER - ITEM_SWORD_KOKIRI] << gEquipShifts[EQUIP_SWORD]) & gSaveContext.inventory.equipment; + uint8_t hasMasterSword = CHECK_OWNED_EQUIP(EQUIP_TYPE_SWORD, EQUIP_INV_SWORD_MASTER); uint8_t hasOcarinaOfTime = (INV_CONTENT(ITEM_OCARINA_TIME) == ITEM_OCARINA_TIME); // If TimeTravel + Player have the Ocarina of Time + Have Master Sword + is in proper range // TODO: Once Swordless Adult is fixed: Remove the Master Sword check @@ -248,6 +261,8 @@ void AutoSave(GetItemEntry itemEntry) { // Don't autosave immediately after buying items from shops to prevent getting them for free! // Don't autosave in the Chamber of Sages since resuming from that map breaks the game // Don't autosave during the Ganon fight when picking up the Master Sword + // Don't autosave in the fishing pond to prevent getting rod on B outside of the pond + // Don't autosave in the bombchu bowling alley to prevent having chus on B outside of the minigame // Don't autosave in grottos since resuming from grottos breaks the game. if ((CVarGetInteger("gAutosave", AUTOSAVE_OFF) != AUTOSAVE_OFF) && (gPlayState != NULL) && (gSaveContext.pendingSale == ITEM_NONE) && (gPlayState->gameplayFrames > 60 && gSaveContext.cutsceneIndex < 0xFFF0) && (gPlayState->sceneNum != SCENE_GANON_BOSS)) { @@ -311,8 +326,9 @@ void AutoSave(GetItemEntry itemEntry) { CVarGetInteger("gAutosave", AUTOSAVE_OFF) == AUTOSAVE_LOCATION) { performSave = true; } - if ((gPlayState->sceneNum == SCENE_FAIRYS_FOUNTAIN) || (gPlayState->sceneNum == SCENE_GROTTOS) || - (gPlayState->sceneNum == SCENE_CHAMBER_OF_THE_SAGES)) { + if (gPlayState->sceneNum == SCENE_FAIRYS_FOUNTAIN || gPlayState->sceneNum == SCENE_GROTTOS || + gPlayState->sceneNum == SCENE_CHAMBER_OF_THE_SAGES || gPlayState->sceneNum == SCENE_FISHING_POND || + gPlayState->sceneNum == SCENE_BOMBCHU_BOWLING_ALLEY) { if (CVarGetInteger("gAutosave", AUTOSAVE_OFF) == AUTOSAVE_LOCATION_AND_MAJOR_ITEMS || CVarGetInteger("gAutosave", AUTOSAVE_OFF) == AUTOSAVE_LOCATION_AND_ALL_ITEMS || CVarGetInteger("gAutosave", AUTOSAVE_OFF) == AUTOSAVE_LOCATION) { @@ -371,11 +387,18 @@ void RegisterShadowTag() { if (!CVarGetInteger("gShadowTag", 0)) { return; } - if (shouldSpawn && (delayTimer <= 0)) { - Actor_Spawn(&gPlayState->actorCtx, gPlayState, ACTOR_EN_WALLMAS, 0, 0, 0, 0, 0, 0, 3, false); - shouldSpawn = false; + if (gPlayState->sceneNum == SCENE_FOREST_TEMPLE && // Forest Temple Scene + gPlayState->roomCtx.curRoom.num == 16 || // Green Poe Room + gPlayState->roomCtx.curRoom.num == 13 || // Blue Poe Room + gPlayState->roomCtx.curRoom.num == 12) { // Red Poe Room + return; } else { - delayTimer--; + if (shouldSpawn && (delayTimer <= 0)) { + Actor_Spawn(&gPlayState->actorCtx, gPlayState, ACTOR_EN_WALLMAS, 0, 0, 0, 0, 0, 0, 3, false); + shouldSpawn = false; + } else { + delayTimer--; + } } }); GameInteractor::Instance->RegisterGameHook([]() { @@ -996,7 +1019,7 @@ void RegisterAltTrapTypes() { void RegisterRandomizerSheikSpawn() { GameInteractor::Instance->RegisterGameHook([]() { if (!gPlayState) return; - bool canSheik = (OTRGlobals::Instance->gRandomizer->GetRandoSettingValue(RSK_TRIAL_COUNT) != RO_GANONS_TRIALS_SKIP && + bool canSheik = (OTRGlobals::Instance->gRandomizer->GetRandoSettingValue(RSK_TRIAL_COUNT) != 0 && OTRGlobals::Instance->gRandomizer->GetRandoSettingValue(RSK_LIGHT_ARROWS_HINT)); if (!IS_RANDO || !LINK_IS_ADULT || !canSheik) return; switch (gPlayState->sceneNum) { @@ -1082,6 +1105,7 @@ void InitMods() { RegisterInfiniteNayrusLove(); RegisterMoonJumpOnL(); RegisterInfiniteISG(); + RegisterEzQPA(); RegisterUnrestrictedItems(); RegisterFreezeTime(); RegisterSwitchAge(); diff --git a/soh/soh/Enhancements/presets.h b/soh/soh/Enhancements/presets.h index 8847f61f1..b113c705a 100644 --- a/soh/soh/Enhancements/presets.h +++ b/soh/soh/Enhancements/presets.h @@ -167,6 +167,7 @@ const std::vector enhancementsCvars = { "gBombchusOOB", "gQuickPutaway", "gGsCutscene", + "gRestoreRBAValues", "gSkipSaveConfirmation", "gAutosave", "gDisableCritWiggle", @@ -215,6 +216,7 @@ const std::vector enhancementsCvars = { "gBowReticle", "gFixTexturesOOB", "gIvanCoopModeEnabled", + "gEnemySpawnsOverWaterboxes", }; const std::vector cheatCvars = { @@ -245,6 +247,7 @@ const std::vector cheatCvars = { "gMoonJumpOnL", "gSuperTunic", "gEzISG", + "gEzQPA", "gTimelessEquipment", "gCheatEasyPauseBufferEnabled", "gCheatEasyInputBufferingEnabled", @@ -521,6 +524,8 @@ const std::vector enhancedPresetEntries = { PRESET_ENTRY_S32("gNaviTextFix", 1), // Extend Silver Rupee Jingle PRESET_ENTRY_S32("gSilverRupeeJingleExtend", 1), + // Fix enemies not spawning on ground over water + PRESET_ENTRY_S32("gEnemySpawnsOverWaterboxes", 1), // Red Ganon blood PRESET_ENTRY_S32("gRedGanonBlood", 1), diff --git a/soh/soh/Enhancements/randomizer/3drando/fill.cpp b/soh/soh/Enhancements/randomizer/3drando/fill.cpp index b0a99d85d..a3db898b3 100644 --- a/soh/soh/Enhancements/randomizer/3drando/fill.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/fill.cpp @@ -1098,21 +1098,13 @@ int Fill() { printf("Done"); ctx->CreateItemOverrides(); CreateEntranceOverrides(); - if (GossipStoneHints.IsNot(HINTS_NO_HINTS)) { - printf("\x1b[10;10HCreating Hints..."); - CreateAllHints(); - printf("Done"); - } - if (ShuffleMerchants.Is(SHUFFLEMERCHANTS_HINTS)) { - CreateMerchantsHints(); - } - //Always execute ganon hint generation for the funny line - CreateGanonText(); - CreateAltarText(); - CreateDampesDiaryText(); - CreateGregRupeeHint(); - CreateSheikText(); - CreateSariaText(); + + //funny ganon line + Text ganonText = RandomElement(GetHintCategory(HintCategory::GanonLine)).GetText(); + CreateMessageFromTextObject(0x70CB, 0, 2, 3, AddColorsAndFormat(ganonText)); + SetGanonText(ganonText); + + CreateAllHints(); CreateWarpSongTexts(); return 1; } diff --git a/soh/soh/Enhancements/randomizer/3drando/fill.hpp b/soh/soh/Enhancements/randomizer/3drando/fill.hpp index 0b0ab59d8..0a9f1fab2 100644 --- a/soh/soh/Enhancements/randomizer/3drando/fill.hpp +++ b/soh/soh/Enhancements/randomizer/3drando/fill.hpp @@ -21,7 +21,9 @@ void ClearProgress(); void VanillaFill(); int Fill(); +std::vector GetEmptyLocations(std::vector allowedLocations); + std::vector GetAccessibleLocations(const std::vector& allowedLocations, SearchMode mode = SearchMode::ReachabilitySearch, std::string ignore = "", bool checkPoeCollectorAccess = false, - bool checkOtherEntranceAccess = false); + bool checkOtherEntranceAccess = false); \ No newline at end of file diff --git a/soh/soh/Enhancements/randomizer/3drando/hint_list.cpp b/soh/soh/Enhancements/randomizer/3drando/hint_list.cpp index fc47069fe..51764763e 100644 --- a/soh/soh/Enhancements/randomizer/3drando/hint_list.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/hint_list.cpp @@ -48,22 +48,6 @@ void HintTable_Init() { | ALWAYS HINT TEXT | ---------------------------*/ - hintTable[RHT_ZR_FROGS_OCARINA_GAME] = HintText::Always( - { - // obscure text - Text{ "an #amphibian feast# yields", /*french*/ "un #festin d'amphibiens# donne", - /*spanish*/ "una #fiesta anfibia# brinda" }, - Text{ "the #croaking choir's magnum opus# awards", /*french*/ "la #chorale coassante# donne", - /*spanish*/ "un #coro maestro de ancas# premia" }, - Text{ "the #froggy finale# yields", /*french*/ "la #finale amphibienne# donne", - /*spanish*/ "el #gran final batracio# brinda" }, - }, - {}, - // clear text - Text{ "the final reward from the #Frogs of Zora's River# is", - /*french*/ "la dernière récompense des #grenouilles de la Rivière Zora# est", - /*spanish*/ "la recompensa final de las #ranas del Río Zora# premia" }); - hintTable[RHT_KF_LINKS_HOUSE_COW] = HintText::Always( { // obscure text @@ -488,6 +472,22 @@ void HintTable_Init() { Text{ "a #cow behind webs# in a grotto gifts", /*french*/ "la #vache derrière les toiles# d'une grotte donne", /*spanish*/ "una #vaca tras la telaraña# de una cueva brinda" }); + hintTable[RHT_ZR_FROGS_OCARINA_GAME] = HintText::Sometimes( + { + // obscure text + Text{ "an #amphibian feast# yields", /*french*/ "un #festin d'amphibiens# donne", + /*spanish*/ "una #fiesta anfibia# brinda" }, + Text{ "the #croaking choir's magnum opus# awards", /*french*/ "la #chorale coassante# donne", + /*spanish*/ "un #coro maestro de ancas# premia" }, + Text{ "the #froggy finale# yields", /*french*/ "la #finale amphibienne# donne", + /*spanish*/ "el #gran final batracio# brinda" }, + }, + {}, + // clear text + Text{ "the final reward from the #Frogs of Zora's River# is", + /*french*/ "la dernière récompense des #grenouilles de la Rivière Zora# est", + /*spanish*/ "la recompensa final de las #ranas del Río Zora# premia" }); + hintTable[RHT_ZF_GS_HIDDEN_CAVE] = HintText::Sometimes({ // obscure text Text{ "a spider high #above the icy waters# holds", /*french*/ "l'araignée #en haut des eaux glacées# donne", @@ -1047,6 +1047,11 @@ void HintTable_Init() { Text{ "Temple of Time", /*french*/ "le Temple du Temps", /*spanish*/ "el Templo del Tiempo" }, }); + hintTable[RHT_CASTLE_GROUNDS] = HintText::Exclude({ + // obscure text + Text{ "the Castle Grounds", /*french*/ "le Château d'Hyrule", /*spanish*/ "" }, + }); + hintTable[RHT_HYRULE_CASTLE] = HintText::Exclude({ // obscure text Text{ "Hyrule Castle", /*french*/ "le Château d'Hyrule", /*spanish*/ "el Castillo de Hyrule" }, @@ -2949,7 +2954,7 @@ void HintTable_Init() { | LIGHT ARROW LOCATION TEXT| ---------------------------*/ - hintTable[RHT_LIGHT_ARROW_LOCATION_HINT] = HintText::LightArrow({ + hintTable[RHT_LIGHT_ARROW_LOCATION_HINT] = HintText::OtherHint({ // obscure text Text{ "Ha ha ha... You'll never beat me by reflecting my lightning bolts and unleashing the arrows from ", @@ -2959,11 +2964,107 @@ void HintTable_Init() { "Ja, ja, ja... Nunca me derrotarás reflejando mis esferas de energía y desplegando la flecha de luz de " }, }); + hintTable[RHT_SHEIK_LIGHT_ARROW_HINT] = HintText::SheikLine({ + // obscure text + Text{ + "I overheard Ganondorf say that he misplaced the %yLight Arrows%w in %r", + /*french*/ + "J'ai entendu dire que Ganondorf aurait caché les %yFlèches de Lumière%w dans %r", + /*spanish*/ + ""}, + }); + + /*-------------------------- + |MASTER SWORD LOCATION TEXT| + ---------------------------*/ + + hintTable[RHT_MASTER_SWORD_LOCATION_HINT] = HintText::MasterSword({ + // obscure text + Text{"And even if you do, you'll never find the legendary blade hidden in ", + /*french*/ + "Et même si tu les trouves, tu ne touveras jamais l'épée de légende cachée dans ", + /*spanish*/ + "E incluso si lo haces, nunca encontrarás la espada legendaria escondida en " }, + }); + + hintTable[RHT_SHEIK_MASTER_SWORD_LOCATION_HINT] = HintText::SheikLine({ + // obscure text + Text{"He also stole %gthe Master Sword%w and hid it in %r", + /*french*/ + "Il aurait aussi volé %gl'épée de légende%w, qu'il aurait caché dans %r", + /*spanish*/ + "Él también robó %gla Espada Maestra%w y la escondió en %r" }, + }); + hintTable[RHT_YOUR_POCKET] = HintText::Exclude({ // obscure text Text{ "your pocket", /*french*/ "tes poches", /*spanish*/ "tu bolsillo" }, }); + /*-------------------------- + | OTHER HINT TEXT | + ---------------------------*/ + + hintTable[RHT_DAMPE_DIARY01] = HintText::OtherHint({ + // obscure text + Text{ + "Whoever reads this, please enter %r", + /*french*/ + "Toi qui lit ce journal, rends-toi dans %r", + /*german?*/ + "Wer immer dies liest, der möge folgenden Ort aufsuchen: %r"}, + }); + + hintTable[RHT_DAMPE_DIARY02] = HintText::OtherHint({ + // obscure text + Text{ + "%w. I will let you have my stretching, shrinking keepsake.^I'm waiting for you.&--Dampé", + /*french*/ + "%w. Et peut-être auras-tu droit à mon précieux %rtrésor%w.^Je t'attends...&--Igor", + /*german?*/ + "%w. Ihm gebe ich meinen langen, kurzen Schatz.^Ich warte!&Boris"}, + }); + + hintTable[RHT_GREG_HINT01] = HintText::OtherHint({ + // obscure text + Text{ + "By the way, if you're interested, I saw the shiniest %gGreen Rupee%w somewhere in%g ", + /*french*/ + "Au fait, si ça t'intéresse, j'ai aperçu le plus éclatant des %gRubis Verts%w quelque part à %g", + /*spanish*/ + ""}, + }); + + hintTable[RHT_GREG_HINT02] = HintText::OtherHint({ + // obscure text + Text{ + "%w.^It's said to have %rmysterious powers%w...^But then, it could just be another regular rupee.&Oh well.", + /*french*/ + "%w. On dit qu'il possède des pouvoirs mystérieux... Mais bon, ça pourrait juste être un autre rubis ordinaire.", + /*spanish*/ + ""}, + }); + + hintTable[RHT_SARIA_TEXT01] = HintText::OtherHint({ + // obscure text + Text{ + "Did you feel the %gsurge of magic%w recently? A mysterious bird told me it came from %g", + /*french*/ + "As-tu récemment ressenti une vague de %gpuissance magique%w? Un mystérieux hibou m'a dit qu'elle provenait du %g", + /*spanish*/ + ""}, + }); + + hintTable[RHT_SARIA_TEXT02] = HintText::OtherHint({ + // obscure text + Text{ + "%w.^You should check that place out, @!$C", + /*french*/ + "%w. Tu devrais aller y jeter un coup d'oeil, @!$C", + /*spanish*/ + "%w.$C"}, + }); + /*-------------------------- | GANON LINE TEXT | ---------------------------*/ @@ -3193,7 +3294,7 @@ int32_t TokensRequiredBySettings() { return tokens; } -std::array conditionalAlwaysHints = { +std::array conditionalAlwaysHints = { std::make_pair(RC_MARKET_10_BIG_POES, []() { return Settings::BigPoeTargetCount.Value() >= 3; @@ -3203,9 +3304,10 @@ std::array conditionalAlwaysHints = { std::make_pair(RC_HF_OCARINA_OF_TIME_ITEM, []() { return StonesRequiredBySettings() < 2; }), std::make_pair(RC_SHEIK_IN_KAKARIKO, []() { return MedallionsRequiredBySettings() < 5; }), std::make_pair(RC_DMT_TRADE_CLAIM_CHECK, []() { return false; }), - std::make_pair(RC_KAK_30_GOLD_SKULLTULA_REWARD, []() { return TokensRequiredBySettings() < 30; }), - std::make_pair(RC_KAK_40_GOLD_SKULLTULA_REWARD, []() { return TokensRequiredBySettings() < 40; }), - std::make_pair(RC_KAK_50_GOLD_SKULLTULA_REWARD, []() { return TokensRequiredBySettings() < 50; }) + std::make_pair(RC_KAK_30_GOLD_SKULLTULA_REWARD, []() { return TokensRequiredBySettings() < 30 && !Settings::Kak30GSHintText; }), + std::make_pair(RC_KAK_40_GOLD_SKULLTULA_REWARD, []() { return TokensRequiredBySettings() < 40 && !Settings::Kak40GSHintText; }), + std::make_pair(RC_KAK_50_GOLD_SKULLTULA_REWARD, []() { return TokensRequiredBySettings() < 50 && !Settings::Kak50GSHintText; }), + std::make_pair(RC_ZR_FROGS_OCARINA_GAME, []() { return !Settings::FrogsHintText; }), }; const HintText& Hint(const RandomizerHintTextKey hintKey) { diff --git a/soh/soh/Enhancements/randomizer/3drando/hint_list/hint_list_exclude_overworld.cpp b/soh/soh/Enhancements/randomizer/3drando/hint_list/hint_list_exclude_overworld.cpp index 6e46c522a..5e5a003ec 100644 --- a/soh/soh/Enhancements/randomizer/3drando/hint_list/hint_list_exclude_overworld.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/hint_list/hint_list_exclude_overworld.cpp @@ -131,6 +131,10 @@ void HintTable_Init_Exclude_Overworld() { Text{"a #hole in a volcano# holds", /*french*/"la #grotte dans le volcan# contient", /*spanish*/"bajo el #hoyo de un volcán# yace"}, }); + hintTable[RHT_TOT_MASTER_SWORD] = HintText::Exclude({ + //obscure text + Text{"a #pedestal in a temple# holds", /*french*/"un #piédestal dans un temple# contient", /*spanish*/"un #pedestal en un templo# sostiene"}, + }); hintTable[RHT_TOT_LIGHT_ARROWS_CUTSCENE] = HintText::Exclude({ //obscure text diff --git a/soh/soh/Enhancements/randomizer/3drando/hints.cpp b/soh/soh/Enhancements/randomizer/3drando/hints.cpp index e0ae47dd0..dc57a5b71 100644 --- a/soh/soh/Enhancements/randomizer/3drando/hints.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/hints.cpp @@ -20,20 +20,20 @@ using namespace Logic; using namespace Settings; using namespace Trial; -std::unordered_map hintTypeNames = { - { HINT_TYPE_TRIAL, "Trial" }, - { HINT_TYPE_ALWAYS, "Always" }, - { HINT_TYPE_WOTH, "WotH" }, - { HINT_TYPE_BARREN, "Barren" }, - { HINT_TYPE_ENTRANCE, "Entrance" }, - { HINT_TYPE_SOMETIMES, "Sometimes" }, - { HINT_TYPE_RANDOM, "Random"}, - { HINT_TYPE_ITEM, "Item" }, - { HINT_TYPE_SONG, "Song" }, - { HINT_TYPE_OVERWORLD, "Overworld" }, - { HINT_TYPE_DUNGEON, "Dungeon" }, - { HINT_TYPE_JUNK, "Junk" }, - { HINT_TYPE_NAMED_ITEM, "NamedItem" }, +std::array hintTypeNames = { + "Static", + "Trial", + "WotH", + "Barren", + "Entrance", + "Always", + "Sometimes", + "Song", + "Overworld", + "Dungeon", + "Named Item", + "Random", + "Junk" }; constexpr std::array hintSettingTable{{ @@ -43,19 +43,19 @@ constexpr std::array hintSettingTable{{ .dungeonsBarrenLimit = 1, .namedItemsRequired = false, .distTable = {{ - {.type = HINT_TYPE_TRIAL, .order = 1, .weight = 0, .fixed = 0, .copies = 0}, - {.type = HINT_TYPE_ALWAYS, .order = 2, .weight = 0, .fixed = 0, .copies = 0}, - {.type = HINT_TYPE_WOTH, .order = 3, .weight = 0, .fixed = 0, .copies = 0}, - {.type = HINT_TYPE_BARREN, .order = 4, .weight = 0, .fixed = 0, .copies = 0}, - {.type = HINT_TYPE_ENTRANCE, .order = 5, .weight = 0, .fixed = 0, .copies = 0}, - {.type = HINT_TYPE_SOMETIMES, .order = 6, .weight = 0, .fixed = 0, .copies = 0}, - {.type = HINT_TYPE_RANDOM, .order = 7, .weight = 0, .fixed = 0, .copies = 0}, - {.type = HINT_TYPE_ITEM, .order = 8, .weight = 0, .fixed = 0, .copies = 0}, - {.type = HINT_TYPE_SONG, .order = 9, .weight = 0, .fixed = 0, .copies = 0}, - {.type = HINT_TYPE_OVERWORLD, .order = 10, .weight = 0, .fixed = 0, .copies = 0}, - {.type = HINT_TYPE_DUNGEON, .order = 11, .weight = 0, .fixed = 0, .copies = 0}, - {.type = HINT_TYPE_JUNK, .order = 12, .weight = 99, .fixed = 0, .copies = 0}, - {.type = HINT_TYPE_NAMED_ITEM, .order = 13, .weight = 0, .fixed = 0, .copies = 0}, + {.type = HINT_TYPE_STATIC, .weight = 0, .fixed = 0, .copies = 0}, + {.type = HINT_TYPE_TRIAL, .weight = 0, .fixed = 0, .copies = 0}, + {.type = HINT_TYPE_WOTH, .weight = 0, .fixed = 0, .copies = 0}, + {.type = HINT_TYPE_BARREN, .weight = 0, .fixed = 0, .copies = 0}, + {.type = HINT_TYPE_ENTRANCE, .weight = 0, .fixed = 0, .copies = 0}, + {.type = HINT_TYPE_ALWAYS, .weight = 0, .fixed = 0, .copies = 0}, + {.type = HINT_TYPE_SOMETIMES, .weight = 0, .fixed = 0, .copies = 0}, + {.type = HINT_TYPE_SONG, .weight = 0, .fixed = 0, .copies = 0}, + {.type = HINT_TYPE_OVERWORLD, .weight = 0, .fixed = 0, .copies = 0}, + {.type = HINT_TYPE_DUNGEON, .weight = 0, .fixed = 0, .copies = 0}, + {.type = HINT_TYPE_NAMED_ITEM,.weight = 0, .fixed = 0, .copies = 0}, + {.type = HINT_TYPE_RANDOM, .weight = 0, .fixed = 0, .copies = 0}, + {.type = HINT_TYPE_JUNK, .weight = 1, .fixed = 0, .copies = 1}, }}, }, @@ -65,19 +65,19 @@ constexpr std::array hintSettingTable{{ .dungeonsBarrenLimit = 1, .namedItemsRequired = true, .distTable = {{ - {.type = HINT_TYPE_TRIAL, .order = 1, .weight = 0, .fixed = 0, .copies = 1}, - {.type = HINT_TYPE_ALWAYS, .order = 2, .weight = 0, .fixed = 0, .copies = 1}, - {.type = HINT_TYPE_WOTH, .order = 3, .weight = 7, .fixed = 0, .copies = 1}, - {.type = HINT_TYPE_BARREN, .order = 4, .weight = 4, .fixed = 0, .copies = 1}, - {.type = HINT_TYPE_ENTRANCE, .order = 5, .weight = 6, .fixed = 0, .copies = 1}, - {.type = HINT_TYPE_SOMETIMES, .order = 6, .weight = 0, .fixed = 0, .copies = 1}, - {.type = HINT_TYPE_RANDOM, .order = 7, .weight = 12, .fixed = 0, .copies = 1}, - {.type = HINT_TYPE_ITEM, .order = 8, .weight = 10, .fixed = 0, .copies = 1}, - {.type = HINT_TYPE_SONG, .order = 9, .weight = 2, .fixed = 0, .copies = 1}, - {.type = HINT_TYPE_OVERWORLD, .order = 10, .weight = 4, .fixed = 0, .copies = 1}, - {.type = HINT_TYPE_DUNGEON, .order = 11, .weight = 3, .fixed = 0, .copies = 1}, - {.type = HINT_TYPE_JUNK, .order = 12, .weight = 6, .fixed = 0, .copies = 1}, - {.type = HINT_TYPE_NAMED_ITEM, .order = 13, .weight = 0, .fixed = 0, .copies = 1}, + {.type = HINT_TYPE_STATIC, .weight = 0, .fixed = 0, .copies = 0}, + {.type = HINT_TYPE_TRIAL, .weight = 0, .fixed = 0, .copies = 1}, + {.type = HINT_TYPE_WOTH, .weight = 7, .fixed = 0, .copies = 1}, + {.type = HINT_TYPE_BARREN, .weight = 4, .fixed = 0, .copies = 1}, + {.type = HINT_TYPE_ENTRANCE, .weight = 0, .fixed = 0, .copies = 1}, //not yet implemented, should be 6 weight + {.type = HINT_TYPE_ALWAYS, .weight = 0, .fixed = 0, .copies = 1}, + {.type = HINT_TYPE_SOMETIMES, .weight = 0, .fixed = 0, .copies = 1}, + {.type = HINT_TYPE_SONG, .weight = 2, .fixed = 0, .copies = 1}, + {.type = HINT_TYPE_OVERWORLD, .weight = 4, .fixed = 0, .copies = 1}, + {.type = HINT_TYPE_DUNGEON, .weight = 3, .fixed = 0, .copies = 1}, + {.type = HINT_TYPE_NAMED_ITEM,.weight = 10, .fixed = 0, .copies = 1}, + {.type = HINT_TYPE_RANDOM, .weight = 12, .fixed = 0, .copies = 1}, + {.type = HINT_TYPE_JUNK, .weight = 6, .fixed = 0, .copies = 1}, //Junk is hardcoded to 1 copy to avoid fill in issues, this setting is ignored }}, }, @@ -87,19 +87,19 @@ constexpr std::array hintSettingTable{{ .dungeonsBarrenLimit = 1, .namedItemsRequired = true, .distTable = {{ - {.type = HINT_TYPE_TRIAL, .order = 1, .weight = 0, .fixed = 0, .copies = 1}, - {.type = HINT_TYPE_ALWAYS, .order = 2, .weight = 0, .fixed = 0, .copies = 2}, - {.type = HINT_TYPE_WOTH, .order = 3, .weight = 12, .fixed = 0, .copies = 2}, - {.type = HINT_TYPE_BARREN, .order = 4, .weight = 12, .fixed = 0, .copies = 1}, - {.type = HINT_TYPE_ENTRANCE, .order = 5, .weight = 4, .fixed = 0, .copies = 1}, - {.type = HINT_TYPE_SOMETIMES, .order = 6, .weight = 0, .fixed = 0, .copies = 1}, - {.type = HINT_TYPE_RANDOM, .order = 7, .weight = 8, .fixed = 0, .copies = 1}, - {.type = HINT_TYPE_ITEM, .order = 8, .weight = 8, .fixed = 0, .copies = 1}, - {.type = HINT_TYPE_SONG, .order = 9, .weight = 4, .fixed = 0, .copies = 1}, - {.type = HINT_TYPE_OVERWORLD, .order = 10, .weight = 6, .fixed = 0, .copies = 1}, - {.type = HINT_TYPE_DUNGEON, .order = 11, .weight = 6, .fixed = 0, .copies = 1}, - {.type = HINT_TYPE_JUNK, .order = 12, .weight = 0, .fixed = 0, .copies = 1}, - {.type = HINT_TYPE_NAMED_ITEM, .order = 13, .weight = 0, .fixed = 0, .copies = 1}, + {.type = HINT_TYPE_STATIC, .weight = 0, .fixed = 0, .copies = 0}, + {.type = HINT_TYPE_TRIAL, .weight = 0, .fixed = 0, .copies = 1}, + {.type = HINT_TYPE_WOTH, .weight = 12, .fixed = 0, .copies = 2}, + {.type = HINT_TYPE_BARREN, .weight = 12, .fixed = 0, .copies = 1}, + {.type = HINT_TYPE_ENTRANCE, .weight = 0, .fixed = 0, .copies = 1}, //not yet implemented, should be 4 weight + {.type = HINT_TYPE_ALWAYS, .weight = 0, .fixed = 0, .copies = 2}, + {.type = HINT_TYPE_SOMETIMES, .weight = 0, .fixed = 0, .copies = 1}, + {.type = HINT_TYPE_SONG, .weight = 4, .fixed = 0, .copies = 1}, + {.type = HINT_TYPE_OVERWORLD, .weight = 6, .fixed = 0, .copies = 1}, + {.type = HINT_TYPE_DUNGEON, .weight = 6, .fixed = 0, .copies = 1}, + {.type = HINT_TYPE_NAMED_ITEM,.weight = 8, .fixed = 0, .copies = 1}, + {.type = HINT_TYPE_RANDOM, .weight = 8, .fixed = 0, .copies = 1}, + {.type = HINT_TYPE_JUNK, .weight = 0, .fixed = 0, .copies = 1}, }}, }, @@ -109,25 +109,23 @@ constexpr std::array hintSettingTable{{ .dungeonsBarrenLimit = 40, .namedItemsRequired = true, .distTable = {{ - {.type = HINT_TYPE_TRIAL, .order = 1, .weight = 0, .fixed = 0, .copies = 1}, - {.type = HINT_TYPE_ALWAYS, .order = 2, .weight = 0, .fixed = 0, .copies = 2}, - {.type = HINT_TYPE_WOTH, .order = 3, .weight = 15, .fixed = 0, .copies = 2}, - {.type = HINT_TYPE_BARREN, .order = 4, .weight = 15, .fixed = 0, .copies = 1}, - {.type = HINT_TYPE_ENTRANCE, .order = 5, .weight = 10, .fixed = 0, .copies = 1}, - {.type = HINT_TYPE_SOMETIMES, .order = 6, .weight = 0, .fixed = 0, .copies = 1}, - {.type = HINT_TYPE_RANDOM, .order = 7, .weight = 0, .fixed = 0, .copies = 1}, - {.type = HINT_TYPE_ITEM, .order = 8, .weight = 5, .fixed = 0, .copies = 1}, - {.type = HINT_TYPE_SONG, .order = 9, .weight = 2, .fixed = 0, .copies = 1}, - {.type = HINT_TYPE_OVERWORLD, .order = 10, .weight = 7, .fixed = 0, .copies = 1}, - {.type = HINT_TYPE_DUNGEON, .order = 11, .weight = 7, .fixed = 0, .copies = 1}, - {.type = HINT_TYPE_JUNK, .order = 12, .weight = 0, .fixed = 0, .copies = 1}, - {.type = HINT_TYPE_NAMED_ITEM, .order = 13, .weight = 0, .fixed = 0, .copies = 1}, + {.type = HINT_TYPE_STATIC, .weight = 0, .fixed = 0, .copies = 0}, + {.type = HINT_TYPE_TRIAL, .weight = 0, .fixed = 0, .copies = 1}, + {.type = HINT_TYPE_WOTH, .weight = 15, .fixed = 0, .copies = 2}, + {.type = HINT_TYPE_BARREN, .weight = 15, .fixed = 0, .copies = 1}, + {.type = HINT_TYPE_ENTRANCE, .weight = 0, .fixed = 0, .copies = 1}, //not yet implemented, should be 10 weight + {.type = HINT_TYPE_ALWAYS, .weight = 0, .fixed = 0, .copies = 2}, + {.type = HINT_TYPE_SOMETIMES, .weight = 0, .fixed = 0, .copies = 1}, + {.type = HINT_TYPE_SONG, .weight = 2, .fixed = 0, .copies = 1}, + {.type = HINT_TYPE_OVERWORLD, .weight = 7, .fixed = 0, .copies = 1}, + {.type = HINT_TYPE_DUNGEON, .weight = 7, .fixed = 0, .copies = 1}, + {.type = HINT_TYPE_NAMED_ITEM,.weight = 5, .fixed = 0, .copies = 1}, + {.type = HINT_TYPE_RANDOM, .weight = 0, .fixed = 0, .copies = 1}, + {.type = HINT_TYPE_JUNK, .weight = 0, .fixed = 0, .copies = 1}, }}, }, }}; -std::array dungeonInfoData; - Text childAltarText; Text adultAltarText; Text ganonText; @@ -143,9 +141,12 @@ Text warpRequiemText; Text warpNocturneText; Text warpPreludeText; +std::string masterSwordHintLoc; std::string lightArrowHintLoc; -std::string sariaHintLoc; std::string dampeHintLoc; +std::string gregHintLoc; +std::string sariaHintLoc; + Text& GetChildAltarText() { return childAltarText; @@ -155,6 +156,10 @@ Text& GetAdultAltarText() { return adultAltarText; } +void SetGanonText(Text text){ + ganonText = text; +} + Text& GetGanonText() { return ganonText; } @@ -203,6 +208,10 @@ Text& GetWarpPreludeText() { return warpPreludeText; } +std::string GetMasterSwordHintLoc() { + return masterSwordHintLoc; +} + std::string GetLightArrowHintLoc() { return lightArrowHintLoc; } @@ -211,6 +220,10 @@ std::string GetDampeHintLoc() { return dampeHintLoc; } +std::string GetGregHintLoc() { + return gregHintLoc; +} + std::string GetSariaHintLoc() { return sariaHintLoc; } @@ -260,6 +273,11 @@ uint32_t GetLocationRegionuint32_t(const RandomizerCheck location) { return GetHintRegion(Rando::Context::GetInstance()->GetItemLocation(location)->GetParentRegionKey())->hintKey; } +static std::vector GetEmptyGossipStones() { + auto emptyGossipStones = GetEmptyLocations(Rando::StaticData::gossipStoneLocations); + return emptyGossipStones; +} + static std::vector GetAccessibleGossipStones(const RandomizerCheck hintedLocation = RC_GANON) { auto ctx = Rando::Context::GetInstance(); //temporarily remove the hinted location's item, and then perform a @@ -275,7 +293,36 @@ static std::vector GetAccessibleGossipStones(const RandomizerCh return accessibleGossipStones; } -static void AddHint(Text hint, const RandomizerCheck gossipStone, const std::vector& colors = {}, HintType hintType = HINT_TYPE_ITEM, const RandomizerCheck hintedLocation = RC_UNKNOWN_CHECK) { +bool IsReachableWithout(std::vector locsToCheck, RandomizerCheck excludedCheck, bool resetAfter = true){ + //temporarily remove the hinted location's item, and then perform a + //reachability search for this check + auto ctx = Rando::Context::GetInstance(); + RandomizerGet originalItem = ctx->GetItemLocation(excludedCheck)->GetPlacedRandomizerGet(); + ctx->GetItemLocation(excludedCheck)->SetPlacedItem(RG_NONE); + LogicReset(); + const auto rechableWithout = GetAccessibleLocations(locsToCheck); + ctx->GetItemLocation(excludedCheck)->SetPlacedItem(originalItem); + if (resetAfter){ + //if resetAfter is on, reset logic we are done + LogicReset(); + } + if (rechableWithout.empty()) { + return false; + } + return true; +} + +static void SetAllInRegionAsHinted(RandomizerHintTextKey region, std::vector locations){ + auto ctx = Rando::Context::GetInstance(); + std::vector locsInRegion = FilterFromPool(locations, [region, ctx](const RandomizerCheck loc){ + return GetHintRegion(ctx->GetItemLocation(loc)->GetParentRegionKey())->hintKey == region; + }); + for(RandomizerCheck loc: locsInRegion){ + ctx->GetItemLocation(loc)->SetAsHinted(); + } +} + +static void AddHint(Text hint, const RandomizerCheck gossipStone, const std::vector& colors = {}, HintType hintType = HINT_TYPE_NAMED_ITEM, const RandomizerCheck hintedLocation = RC_UNKNOWN_CHECK) { //save hints as dummy items for writing to the spoiler log //NewItem(gossipStone, Item{RG_HINT, hint, ITEMTYPE_EVENT, GI_RUPEE_BLUE_LOSE, false, &noVariable, NONE}); //GetLocation(gossipStone)->SetPlacedItem(gossipStone); @@ -285,68 +332,104 @@ static void AddHint(Text hint, const RandomizerCheck gossipStone, const std::vec ctx->GetItemLocation(gossipStone)->SetPlacedItem(RG_HINT); } -static void CreateLocationHint(const std::vector& possibleHintLocations) { - auto ctx = Rando::Context::GetInstance(); - //return if there aren't any hintable locations or gossip stones available - if (possibleHintLocations.empty()) { - SPDLOG_DEBUG("\tNO LOCATIONS TO HINT\n\n"); - return; +static void AddHintCopies(uint8_t copies, Text hint, std::vector colours, HintType type, RandomizerCheck location = RC_UNKNOWN_CHECK, RandomizerCheck firstStone = RC_UNKNOWN_CHECK){ + if (firstStone != RC_UNKNOWN_CHECK && copies > 0){ + AddHint(hint, firstStone, colours, type, location); + copies -= 1; } - - RandomizerCheck hintedLocation = RandomElement(possibleHintLocations); - const std::vector accessibleGossipStones = GetAccessibleGossipStones(hintedLocation); - - SPDLOG_DEBUG("\tLocation: "); - SPDLOG_DEBUG(Rando::StaticData::GetLocation(hintedLocation)->GetName()); - SPDLOG_DEBUG("\n"); - - SPDLOG_DEBUG("\tItem: "); - SPDLOG_DEBUG(ctx->GetItemLocation(hintedLocation)->GetPlacedItemName().GetEnglish()); - SPDLOG_DEBUG("\n"); - - if (accessibleGossipStones.empty()) { + for(int c=0; c gossipStoneLocations; + gossipStoneLocations = GetAccessibleGossipStones(hintedLocation); + + if (gossipStoneLocations.empty()) { + SPDLOG_DEBUG("\tNO IN LOGIC GOSSIP STONE\n\n"); + return false; } - RandomizerCheck gossipStone = RandomElement(accessibleGossipStones); - ctx->GetItemLocation(hintedLocation)->SetAsHinted(); + RandomizerCheck gossipStone = RandomElement(gossipStoneLocations); //make hint text - Text locationHintText = Rando::StaticData::GetLocation(hintedLocation)->GetHint()->GetText(); - Text itemHintText = ctx->GetItemLocation(hintedLocation)->GetPlacedItem().GetHint().GetText(); + Text finalHint; Text prefix = Hint(RHT_PREFIX).GetText(); + std::vector colours = {QM_GREEN, QM_RED}; + if (type == HINT_TYPE_WOTH){ + Text regionText = GetHintRegion(ctx->GetItemLocation(hintedLocation)->GetParentRegionKey())->GetHint().GetText(); + finalHint = prefix + "%r#" + regionText + "#%w" + Hint(RHT_WAY_OF_THE_HERO).GetText(); + colours = {QM_LBLUE}; + } + else if(type == HINT_TYPE_BARREN){ + Text regionText = GetHintRegion(ctx->GetItemLocation(hintedLocation)->GetParentRegionKey())->GetHint().GetText(); + finalHint = prefix + Hint(RHT_PLUNDERING).GetText() + "%r#" + regionText + "#%w" + Hint(RHT_FOOLISH).GetText(); + colours = {QM_PINK}; + } + else { + Text itemText = ctx->GetItemLocation(hintedLocation)->GetPlacedItem().GetHint().GetText(); + if (type >= HINT_TYPE_ALWAYS && type < HINT_TYPE_NAMED_ITEM){ + Text locationText = Rando::StaticData::GetLocation(hintedLocation)->GetHint()->GetText(); + finalHint = prefix + locationText + " #"+itemText+"#."; + } + else if (type == HINT_TYPE_NAMED_ITEM || type == HINT_TYPE_RANDOM){ + Text regionText = GetHintRegion(ctx->GetItemLocation(hintedLocation)->GetParentRegionKey())->GetHint().GetText(); + // RANDOTODO: reconsider dungeon vs non-dungeon item location hints when boss shuffle mixed pools happens + if (Rando::StaticData::GetLocation(hintedLocation)->IsDungeon()) { + finalHint = prefix+"%r#"+regionText+"#%w "+Hint(RHT_HOARDS).GetText()+" %g#"+itemText+"#%w."; + } else { + finalHint = prefix+"%r#"+itemText+"#%w "+Hint(RHT_CAN_BE_FOUND_AT).GetText()+" %g#"+regionText+"#%w."; + colours = {QM_RED, QM_GREEN}; + } + } + else{ + SPDLOG_DEBUG("\tINVALID HINT TYPE\n\n"); + return false; + } + } - Text finalHint = prefix + "%r" + locationHintText + " #%g" + itemHintText + "#%w."; + ctx->GetItemLocation(hintedLocation)->SetAsHinted(); + SPDLOG_DEBUG("\tMessage: "); SPDLOG_DEBUG(finalHint.english); SPDLOG_DEBUG("\n\n"); - AddHint(finalHint, gossipStone, {QM_GREEN, QM_RED}, HINT_TYPE_ITEM, hintedLocation); + AddHintCopies(copies, finalHint, colours, type, hintedLocation, gossipStone); + + return true; } -static void CreateWothHint(uint8_t* remainingDungeonWothHints) { - auto ctx = Rando::Context::GetInstance(); - // get locations that are in the current playthrough - std::vector possibleHintLocations = {}; - // iterate through playthrough locations by sphere - std::vector wothHintLocations = - FilterFromPool(ctx->wothLocations, [remainingDungeonWothHints, ctx](RandomizerCheck loc) { - return ctx->GetItemLocation(loc)->IsHintable() && // only filter hintable locations - !(ctx->GetItemLocation(loc)->IsHintedAt()) && // only filter locations that haven't been hinted at - (Rando::StaticData::GetLocation(loc)->IsOverworld() || - (Rando::StaticData::GetLocation(loc)->IsDungeon() && - (*remainingDungeonWothHints) > 0)); // make sure we haven't surpassed the woth dungeon limit - }); - AddElementsToPool(possibleHintLocations, wothHintLocations); - // If no more locations can be hinted at for woth, then just try to get another hint +static RandomizerCheck CreateRandomHint(std::vector& possibleHintLocations, uint8_t copies, HintType type) { + auto ctx = Rando::Context::GetInstance(); + + //return if there aren't any hintable locations or gossip stones available + if (GetEmptyGossipStones().size() < copies) { + SPDLOG_DEBUG("\tNOT ENOUGH GOSSIP STONES TO PLACE HINTS\n\n"); + return RC_UNKNOWN_CHECK; + } + + RandomizerCheck hintedLocation; + bool placed = false; + while (!placed){ if (possibleHintLocations.empty()) { SPDLOG_DEBUG("\tNO LOCATIONS TO HINT\n\n"); - return; + return RC_UNKNOWN_CHECK; } - RandomizerCheck hintedLocation = RandomElement(possibleHintLocations); - + hintedLocation = RandomElement(possibleHintLocations, true); //removing the location to avoid it being hinted again on fail + SPDLOG_DEBUG("\tLocation: "); SPDLOG_DEBUG(Rando::StaticData::GetLocation(hintedLocation)->GetName()); SPDLOG_DEBUG("\n"); @@ -355,151 +438,32 @@ static void CreateWothHint(uint8_t* remainingDungeonWothHints) { SPDLOG_DEBUG(ctx->GetItemLocation(hintedLocation)->GetPlacedItemName().GetEnglish()); SPDLOG_DEBUG("\n"); - // get an accessible gossip stone - const std::vector gossipStoneLocations = GetAccessibleGossipStones(hintedLocation); - - if (gossipStoneLocations.empty()) { - SPDLOG_DEBUG("\tNO GOSSIP STONES TO PLACE HINT\n\n"); - return; - } - ctx->GetItemLocation(hintedLocation)->SetAsHinted(); - RandomizerCheck gossipStone = RandomElement(gossipStoneLocations); - - if (Rando::StaticData::GetLocation(hintedLocation)->IsDungeon()) { - *remainingDungeonWothHints -= 1; - } - - // form hint text - Text locationText = GetHintRegion(ctx->GetItemLocation(hintedLocation)->GetParentRegionKey())->GetHint().GetText(); - Text finalWothHint = Hint(RHT_PREFIX).GetText() + "%r#" + locationText + "#%w" + Hint(RHT_WAY_OF_THE_HERO).GetText(); - SPDLOG_DEBUG("\tMessage: "); - SPDLOG_DEBUG(finalWothHint.english); - SPDLOG_DEBUG("\n\n"); - AddHint(finalWothHint, gossipStone, { QM_LBLUE }, HINT_TYPE_WOTH, hintedLocation); + placed = CreateHint(hintedLocation, copies, type); + } + if (type == HINT_TYPE_BARREN){ + SetAllInRegionAsHinted(GetHintRegion(ctx->GetItemLocation(hintedLocation)->GetParentRegionKey())->hintKey, possibleHintLocations); + } + return hintedLocation; } -static void CreateBarrenHint(uint8_t* remainingDungeonBarrenHints, std::vector& barrenLocations) { - auto ctx = Rando::Context::GetInstance(); - // remove dungeon locations if necessary - if (*remainingDungeonBarrenHints < 1) { - barrenLocations = - FilterFromPool(barrenLocations, [](const RandomizerCheck loc) { - return !(Rando::StaticData::GetLocation(loc)->IsDungeon()); - }); - } - - if (barrenLocations.empty()) { - return; - } - - RandomizerCheck hintedLocation = RandomElement(barrenLocations, true); - - SPDLOG_DEBUG("\tLocation: "); - SPDLOG_DEBUG(Rando::StaticData::GetLocation(hintedLocation)->GetName()); - SPDLOG_DEBUG("\n"); - - SPDLOG_DEBUG("\tItem: "); - SPDLOG_DEBUG(ctx->GetItemLocation(hintedLocation)->GetPlacedItemName().GetEnglish()); - SPDLOG_DEBUG("\n"); - - // get an accessible gossip stone - const std::vector gossipStoneLocations = GetAccessibleGossipStones(hintedLocation); - if (gossipStoneLocations.empty()) { - SPDLOG_DEBUG("\tNO GOSSIP STONES TO PLACE HINT\n\n"); - return; - } - ctx->GetItemLocation(hintedLocation)->SetAsHinted(); - RandomizerCheck gossipStone = RandomElement(gossipStoneLocations); - - if (Rando::StaticData::GetLocation(hintedLocation)->IsDungeon()) { - *remainingDungeonBarrenHints -= 1; - } - - // form hint text - Text locationText = GetHintRegion(ctx->GetItemLocation(hintedLocation)->GetParentRegionKey())->GetHint().GetText(); - Text finalBarrenHint = - Hint(RHT_PREFIX).GetText() + Hint(RHT_PLUNDERING).GetText() + "%r#" + locationText + "#%w" + Hint(RHT_FOOLISH).GetText(); - SPDLOG_DEBUG("\tMessage: "); - SPDLOG_DEBUG(finalBarrenHint.english); - SPDLOG_DEBUG("\n\n"); - AddHint(finalBarrenHint, gossipStone, { QM_PINK }, HINT_TYPE_BARREN, hintedLocation); - - // get rid of all other locations in this same barren region - barrenLocations = FilterFromPool(barrenLocations, [hintedLocation, ctx](RandomizerCheck loc) { - return GetHintRegion(ctx->GetItemLocation(loc)->GetParentRegionKey())->hintKey != - GetHintRegion(ctx->GetItemLocation(hintedLocation)->GetParentRegionKey())->hintKey; - }); -} - -static void CreateRandomLocationHint(const bool goodItem = false) { +static std::vector FilterHintability(std::vector& locations, const bool goodItemsOnly = false, const bool dungeonsOK = true){ auto ctx = Rando::Context::GetInstance(); - const std::vector possibleHintLocations = FilterFromPool(ctx->allLocations, [goodItem, ctx](const RandomizerCheck loc) { - return ctx->GetItemLocation(loc)->IsHintable() && !(ctx->GetItemLocation(loc)->IsHintedAt()) && (!goodItem || ctx->GetItemLocation(loc)->GetPlacedItem().IsMajorItem()); + return FilterFromPool(locations, [goodItemsOnly, dungeonsOK, ctx](const RandomizerCheck loc) { + return ctx->GetItemLocation(loc)->IsHintable() && !(ctx->GetItemLocation(loc)->IsHintedAt()) && + (!goodItemsOnly || ctx->GetItemLocation(loc)->GetPlacedItem().IsMajorItem()) && (dungeonsOK || Rando::StaticData::GetLocation(loc)->IsOverworld()); }); - //If no more locations can be hinted at, then just try to get another hint - if (possibleHintLocations.empty()) { - SPDLOG_DEBUG("\tNO LOCATIONS TO HINT\n\n"); - return; - } - RandomizerCheck hintedLocation = RandomElement(possibleHintLocations); - - SPDLOG_DEBUG("\tLocation: "); - SPDLOG_DEBUG(Rando::StaticData::GetLocation(hintedLocation)->GetName()); - SPDLOG_DEBUG("\n"); - - SPDLOG_DEBUG("\tItem: "); - SPDLOG_DEBUG(ctx->GetItemLocation(hintedLocation)->GetPlacedItemName().GetEnglish()); - SPDLOG_DEBUG("\n"); - - //get an acessible gossip stone - const std::vector gossipStoneLocations = GetAccessibleGossipStones(hintedLocation); - if (gossipStoneLocations.empty()) { - SPDLOG_DEBUG("\tNO GOSSIP STONES TO PLACE HINT\n\n"); - return; - } - ctx->GetItemLocation(hintedLocation)->SetAsHinted(); - RandomizerCheck gossipStone = RandomElement(gossipStoneLocations); - - //form hint text - Text itemText = ctx->GetItemLocation(hintedLocation)->GetPlacedItem().GetHint().GetText(); - Text locationText = GetHintRegion(ctx->GetItemLocation(hintedLocation)->GetParentRegionKey())->GetHint().GetText(); - // RANDOTODO: reconsider dungeon vs non-dungeon item location hints when boss shuffle mixed pools happens - if (Rando::StaticData::GetLocation(hintedLocation)->IsDungeon()) { - Text finalHint = Hint(RHT_PREFIX).GetText()+"%r#"+locationText+"#%w "+Hint(RHT_HOARDS).GetText()+" %g#"+itemText+"#%w."; - SPDLOG_DEBUG("\tMessage: "); - SPDLOG_DEBUG(finalHint.english); - SPDLOG_DEBUG("\n\n"); - AddHint(finalHint, gossipStone, {QM_GREEN, QM_RED}, HINT_TYPE_NAMED_ITEM, hintedLocation); - } else { - Text finalHint = Hint(RHT_PREFIX).GetText()+"%r#"+itemText+"#%w "+Hint(RHT_CAN_BE_FOUND_AT).GetText()+" %g#"+locationText+"#%w."; - SPDLOG_DEBUG("\tMessage: "); - SPDLOG_DEBUG(finalHint.english); - SPDLOG_DEBUG("\n\n"); - AddHint(finalHint, gossipStone, { QM_RED, QM_GREEN }, HINT_TYPE_NAMED_ITEM, hintedLocation); - } -} - -static void CreateGoodItemHint() { - CreateRandomLocationHint(true); } static void CreateJunkHint() { //duplicate junk hints are possible for now const HintText junkHint = RandomElement(GetHintCategory(HintCategory::Junk)); - LogicReset(); - const std::vector gossipStones = GetAccessibleLocations(Rando::StaticData::gossipStoneLocations); - if (gossipStones.empty()) { - SPDLOG_DEBUG("\tNO GOSSIP STONES TO PLACE HINT\n\n"); - return; - } - RandomizerCheck gossipStone = RandomElement(gossipStones); Text hint = junkHint.GetText(); SPDLOG_DEBUG("\tMessage: "); SPDLOG_DEBUG(hint.english); SPDLOG_DEBUG("\n\n"); - AddHint(hint, gossipStone, { QM_PINK }, HINT_TYPE_JUNK); + AddHintCopies(1, hint, {QM_PINK}, HINT_TYPE_JUNK); } static std::vector CalculateBarrenRegions() { @@ -535,32 +499,16 @@ static std::vector CalculateBarrenRegions() { return finalBarrenLocations; } -static void CreateTrialHints() { +static void CreateTrialHints(uint8_t copies) { + Text prefix = Hint(RHT_PREFIX).GetText(); //six trials if (RandomGanonsTrials && GanonsTrialsCount.Is(6)) { - - //get a random gossip stone - auto gossipStones = GetAccessibleGossipStones(); - auto gossipStone = RandomElement(gossipStones, false); - - //make hint - auto hint = Hint(RHT_PREFIX).GetText() + Hint(RHT_SIX_TRIALS).GetText(); - AddHint(hint, gossipStone, { QM_PINK }, HINT_TYPE_TRIAL); - + AddHintCopies(copies, prefix + Hint(RHT_SIX_TRIALS).GetText(), {QM_PINK}, HINT_TYPE_TRIAL); //zero trials } else if (RandomGanonsTrials && GanonsTrialsCount.Is(0)) { - - //get a random gossip stone - auto gossipStones = GetAccessibleGossipStones(); - auto gossipStone = RandomElement(gossipStones, false); - - //make hint - auto hint = Hint(RHT_PREFIX).GetText() + Hint(RHT_ZERO_TRIALS).GetText(); - AddHint(hint, gossipStone, { QM_YELLOW }, HINT_TYPE_TRIAL); - + AddHintCopies(copies, prefix + Hint(RHT_ZERO_TRIALS).GetText(), {QM_YELLOW}, HINT_TYPE_TRIAL); //4 or 5 required trials } else if (GanonsTrialsCount.Is(5) || GanonsTrialsCount.Is(4)) { - //get skipped trials std::vector trials = {}; trials.assign(trialList.begin(), trialList.end()); @@ -568,13 +516,9 @@ static void CreateTrialHints() { //create a hint for each skipped trial for (auto& trial : skippedTrials) { - //get a random gossip stone - auto gossipStones = GetAccessibleGossipStones(); - auto gossipStone = RandomElement(gossipStones, false); - //make hint - auto hint = Hint(RHT_PREFIX).GetText()+"#"+trial->GetName()+"#"+Hint(RHT_FOUR_TO_FIVE_TRIALS).GetText(); - AddHint(hint, gossipStone, { QM_YELLOW }, HINT_TYPE_TRIAL); + auto hint = prefix+"#"+trial->GetName()+"#"+Hint(RHT_FOUR_TO_FIVE_TRIALS).GetText(); + AddHintCopies(copies, hint, {QM_YELLOW}, HINT_TYPE_TRIAL); } //1 to 3 trials } else if (GanonsTrialsCount.Value() >= 1 && GanonsTrialsCount.Value() <= 3) { @@ -585,52 +529,90 @@ static void CreateTrialHints() { //create a hint for each required trial for (auto& trial : requiredTrials) { - //get a random gossip stone - auto gossipStones = GetAccessibleGossipStones(); - auto gossipStone = RandomElement(gossipStones, false); - //make hint - auto hint = Hint(RHT_PREFIX).GetText()+"#"+trial->GetName()+"#"+Hint(RHT_ONE_TO_THREE_TRIALS).GetText(); - AddHint(hint, gossipStone, { QM_PINK }, HINT_TYPE_TRIAL); + auto hint = prefix+"#"+trial->GetName()+"#"+Hint(RHT_ONE_TO_THREE_TRIALS).GetText(); + AddHintCopies(copies, hint, {QM_PINK}, HINT_TYPE_TRIAL); } } } -void CreateGanonText() { +//RANDOTODO clean this mess up once starting items are expanded +void CreateGanonAndSheikText() { auto ctx = Rando::Context::GetInstance(); - //funny ganon line - ganonText = RandomElement(GetHintCategory(HintCategory::GanonLine)).GetText(); - CreateMessageFromTextObject(0x70CB, 0, 2, 3, AddColorsAndFormat(ganonText)); - - //Get the location of the light arrows - auto lightArrowLocation = FilterFromPool(ctx->allLocations, [ctx](const RandomizerCheck loc) { + if(Settings::LightArrowHintText){ + //Get the location of the light arrows + auto lightArrowLocation = FilterFromPool(ctx->allLocations, [ctx](const RandomizerCheck loc) { return ctx->GetItemLocation(loc)->GetPlacedRandomizerGet() == RG_LIGHT_ARROWS; - }); + }); + Text lightArrowArea = GetHintRegion(ctx->GetItemLocation(lightArrowLocation[0])->GetParentRegionKey())->GetHint().GetText(); + std::vector locsToCheck = {RC_GANONDORF_HINT}; - //If there is no light arrow location, it was in the player's inventory at the start - auto hint = Hint(RHT_LIGHT_ARROW_LOCATION_HINT); - if (lightArrowLocation.empty()) { - ganonHintText = hint.GetText()+Hint(RHT_YOUR_POCKET).GetText(); - lightArrowHintLoc = "Link's Pocket"; - } else { - ganonHintText = - hint.GetText() + "%r" + - GetHintRegion(ctx->GetItemLocation(lightArrowLocation[0])->GetParentRegionKey())->GetHint().GetText(); + //If there is no light arrow location, it was in the player's inventory at the start + auto hint = Hint(RHT_LIGHT_ARROW_LOCATION_HINT); + if (lightArrowLocation.empty()) { + ganonHintText = hint.GetText()+Hint(RHT_YOUR_POCKET).GetText(); + lightArrowHintLoc = "Link's Pocket"; + } else { + ganonHintText = hint.GetText() + "%r" + lightArrowArea + "%w"; lightArrowHintLoc = Rando::StaticData::GetLocation(lightArrowLocation[0])->GetName(); - } - ganonHintText = ganonHintText + "!"; + } + ganonHintText = ganonHintText + "!"; - CreateMessageFromTextObject(0x70CC, 0, 2, 3, AddColorsAndFormat(ganonHintText)); - ctx->AddHint(RH_GANONDORF_HINT, ganonHintText, lightArrowLocation[0], HINT_TYPE_STATIC, GetHintRegion(ctx->GetItemLocation(lightArrowLocation[0])->GetParentRegionKey())->GetHint().GetText()); + //Get the location of the master sword + auto masterSwordLocation = FilterFromPool(ctx->allLocations, [ctx](const RandomizerCheck loc) { + return ctx->GetItemLocation(loc)->GetPlacedRandomizerGet() == RG_MASTER_SWORD; + }); + Text masterSwordArea = GetHintRegion(ctx->GetItemLocation(masterSwordLocation[0])->GetParentRegionKey())->GetHint().GetText(); + + if (ShuffleMasterSword) { + // Add second text box + ganonHintText = ganonHintText + "^"; + if (masterSwordLocation.empty()) { + ganonHintText = ganonHintText + Hint(RHT_MASTER_SWORD_LOCATION_HINT).GetText() + "%r" + Hint(RHT_YOUR_POCKET).GetText() + "%w"; + masterSwordHintLoc = "Link's Pocket"; + } else { + ganonHintText = ganonHintText + Hint(RHT_MASTER_SWORD_LOCATION_HINT).GetText() + "%r" + masterSwordArea + "%w"; + masterSwordHintLoc = Rando::StaticData::GetLocation(masterSwordLocation[0])->GetName(); + } + ganonHintText = ganonHintText + "!"; + } + + CreateMessageFromTextObject(0x70CC, 0, 2, 3, AddColorsAndFormat(ganonHintText)); + ctx->AddHint(RH_GANONDORF_HINT, ganonHintText, lightArrowLocation[0], HINT_TYPE_STATIC, GetHintRegion(ctx->GetItemLocation(lightArrowLocation[0])->GetParentRegionKey())->GetHint().GetText()); + + if (!Settings::GanonsTrialsCount.Is(0)) { + sheikText = Hint(RHT_SHEIK_LIGHT_ARROW_HINT).GetText() + lightArrowArea + "%w."; + locsToCheck = {RC_GANONDORF_HINT, RC_SHEIK_HINT_GC, RC_SHEIK_HINT_MQ_GC}; + + if (ShuffleMasterSword) { + sheikText = sheikText + "^" + Hint(RHT_SHEIK_MASTER_SWORD_LOCATION_HINT).GetText() + masterSwordArea + "%w."; + } + } + + if (IsReachableWithout(locsToCheck, lightArrowLocation[0], true)) { + ctx->GetItemLocation(lightArrowLocation[0])->SetAsHinted(); + } + + if (ShuffleMasterSword) { + if (IsReachableWithout(locsToCheck, masterSwordLocation[0], true)) { + ctx->GetItemLocation(masterSwordLocation[0])->SetHintKey(RH_GANONDORF_HINT); + ctx->GetItemLocation(masterSwordLocation[0])->SetAsHinted(); + } + } + } } //Find the location which has the given itemKey and create the generic altar text for the reward -static Text BuildDungeonRewardText(const RandomizerGet itemKey) { +static Text BuildDungeonRewardText(const RandomizerGet itemKey, bool isChild) { auto ctx = Rando::Context::GetInstance(); + RandomizerCheck altarLoc = RC_ALTAR_HINT_ADULT; + if(isChild){altarLoc = RC_ALTAR_HINT_CHILD;} RandomizerCheck location = FilterFromPool(ctx->allLocations, [itemKey, ctx](const RandomizerCheck loc) { return ctx->GetItemLocation(loc)->GetPlacedRandomizerGet() == itemKey; })[0]; - ctx->GetItemLocation(location)->SetAsHinted(); + if (IsReachableWithout({altarLoc}, location, true) || ShuffleRewards.Is(REWARDSHUFFLE_END_OF_DUNGEON)){ //RANDOTODO check if works properly + ctx->GetItemLocation(location)->SetAsHinted(); + } std::string rewardString = "$" + std::to_string(itemKey - RG_KOKIRI_EMERALD); @@ -760,11 +742,11 @@ void CreateAltarText() { childAltarText = Hint(RHT_SPIRITUAL_STONE_TEXT_START).GetText()+"^"+ //Spiritual Stones (StartingKokiriEmerald.Value() ? Text{ "##", "##", "##" } - : BuildDungeonRewardText(RG_KOKIRI_EMERALD)) + + : BuildDungeonRewardText(RG_KOKIRI_EMERALD, true)) + (StartingGoronRuby.Value() ? Text{ "##", "##", "##" } - : BuildDungeonRewardText(RG_GORON_RUBY)) + + : BuildDungeonRewardText(RG_GORON_RUBY, true)) + (StartingZoraSapphire.Value() ? Text{ "##", "##", "##" } - : BuildDungeonRewardText(RG_ZORA_SAPPHIRE)) + + : BuildDungeonRewardText(RG_ZORA_SAPPHIRE, true)) + //How to open Door of Time, the event trigger is necessary to read the altar multiple times BuildDoorOfTimeText(); } else { @@ -780,17 +762,17 @@ void CreateAltarText() { adultAltarText = adultAltarText + //Medallion Areas (StartingLightMedallion.Value() ? Text{ "##", "##", "##" } - : BuildDungeonRewardText(RG_LIGHT_MEDALLION)) + + : BuildDungeonRewardText(RG_LIGHT_MEDALLION, false)) + (StartingForestMedallion.Value() ? Text{ "##", "##", "##" } - : BuildDungeonRewardText(RG_FOREST_MEDALLION)) + + : BuildDungeonRewardText(RG_FOREST_MEDALLION, false)) + (StartingFireMedallion.Value() ? Text{ "##", "##", "##" } - : BuildDungeonRewardText(RG_FIRE_MEDALLION)) + + : BuildDungeonRewardText(RG_FIRE_MEDALLION, false)) + (StartingWaterMedallion.Value() ? Text{ "##", "##", "##" } - : BuildDungeonRewardText(RG_WATER_MEDALLION)) + + : BuildDungeonRewardText(RG_WATER_MEDALLION, false)) + (StartingSpiritMedallion.Value() ? Text{ "##", "##", "##" } - : BuildDungeonRewardText(RG_SPIRIT_MEDALLION)) + + : BuildDungeonRewardText(RG_SPIRIT_MEDALLION, false)) + (StartingShadowMedallion.Value() ? Text{ "##", "##", "##" } - : BuildDungeonRewardText(RG_SHADOW_MEDALLION)); + : BuildDungeonRewardText(RG_SHADOW_MEDALLION, false)); } adultAltarText = adultAltarText + //Bridge requirement @@ -808,17 +790,16 @@ void CreateAltarText() { void CreateMerchantsHints() { auto ctx = Rando::Context::GetInstance(); Text medigoronItemText = ctx->GetItemLocation(RC_GC_MEDIGORON)->GetPlacedItem().GetHint().GetText(); - Text grannyItemText = ctx->GetItemLocation(RC_KAK_GRANNYS_SHOP)->GetPlacedItem().GetHint().GetText(); + Text grannyItemText = ctx->GetItemLocation(RC_KAK_GRANNYS_SHOP)->GetPlacedItem().GetHint().GetText().Capitalize(); Text carpetSalesmanItemText = ctx->GetItemLocation(RC_WASTELAND_BOMBCHU_SALESMAN)->GetPlacedItem().GetHint().GetText(); Text carpetSalesmanItemClearText = ctx->GetItemLocation(RC_WASTELAND_BOMBCHU_SALESMAN)->GetPlacedItem().GetHint().GetClear(); - Text grannyCapitalItemText = grannyItemText.Capitalize(); Text medigoronText = Hint(RHT_MEDIGORON_DIALOG_FIRST).GetText() + medigoronItemText + Hint(RHT_MEDIGORON_DIALOG_SECOND).GetText(); - Text grannyText = grannyCapitalItemText + Hint(RHT_GRANNY_DIALOG).GetText(); + Text grannyText = grannyItemText + Hint(RHT_GRANNY_DIALOG).GetText(); Text carpetSalesmanTextOne = Hint(RHT_CARPET_SALESMAN_DIALOG_FIRST).GetText() + carpetSalesmanItemText + Hint(RHT_CARPET_SALESMAN_DIALOG_SECOND).GetText(); Text carpetSalesmanTextTwo = Hint(RHT_CARPET_SALESMAN_DIALOG_THIRD).GetText() + carpetSalesmanItemClearText + @@ -834,96 +815,25 @@ void CreateMerchantsHints() { ctx->AddHint(RH_WASTELAND_BOMBCHU_SALESMAN, carpetSalesmanTextOne, RC_WASTELAND_BOMBCHU_SALESMAN, HINT_TYPE_STATIC, GetHintRegion(RR_HAUNTED_WASTELAND)->GetHint().GetText()); } -void CreateDampesDiaryText() { +//RANDOTODO add Better Links Pocket and starting item handling once more starting items are added +void CreateSpecialItemHint(uint32_t item, std::vector hints, RandomizerHintTextKey text1, RandomizerHintTextKey text2, Text& textLoc, std::string& nameLoc, bool condition, bool yourpocket = false) { auto ctx = Rando::Context::GetInstance(); - if (!DampeHintText) { - dampesText = Text(); - dampeHintLoc = ""; - return; - } - - RandomizerGet item = RG_PROGRESSIVE_HOOKSHOT; - RandomizerCheck location = FilterFromPool(ctx->allLocations, [item, ctx](const RandomizerCheck loc) { + if(condition){ + RandomizerCheck location = FilterFromPool(ctx->allLocations, [item, ctx](const RandomizerCheck loc) { return ctx->GetItemLocation(loc)->GetPlacedRandomizerGet() == item; })[0]; - Text area = GetHintRegion(ctx->GetItemLocation(location)->GetParentRegionKey())->GetHint().GetText(); - Text temp1 = Text{ - "Whoever reads this, please enter %r", - "Toi qui lit ce journal, rends-toi dans %r", - "Wer immer dies liest, der möge folgenden Ort aufsuchen: %r" - }; - Text temp2 = { - "%w. I will let you have my stretching, shrinking keepsake.^I'm waiting for you.&--Dampé", - "%w. Et peut-être auras-tu droit à mon précieux %rtrésor%w.^Je t'attends...&--Igor", - "%w. Ihm gebe ich meinen langen, kurzen Schatz.^Ich warte!&Boris" - }; - - dampesText = temp1 + area + temp2; - dampeHintLoc = Rando::StaticData::GetLocation(location)->GetName(); - ctx->AddHint(RH_DAMPES_DIARY, dampesText, location, HINT_TYPE_STATIC, area); -} - -void CreateGregRupeeHint() { - auto ctx = Rando::Context::GetInstance(); - if (!GregHintText) { - gregText = Text(); - return; + if (IsReachableWithout(hints,location,true)){ + ctx->GetItemLocation(location)->SetAsHinted(); + } + + Text area = GetHintRegion(ctx->GetItemLocation(location)->GetParentRegionKey())->GetHint().GetText(); + textLoc = Hint(text1).GetText() + area + Hint(text2).GetText(); + nameLoc = Rando::StaticData::GetLocation(location)->GetName(); + } else { + textLoc = Text(); + nameLoc = ""; } - - RandomizerCheck location = FilterFromPool(ctx->allLocations, [ctx](const RandomizerCheck loc) { - return ctx->GetItemLocation(loc)->GetPlacedRandomizerGet() == RG_GREG_RUPEE; - })[0]; - Text area = GetHintRegion(ctx->GetItemLocation(location)->GetParentRegionKey())->GetHint().GetText(); - - Text temp1 = Text{ - "By the way, if you're interested, I saw the shiniest %gGreen Rupee%w somewhere in%r ", - "Au fait, si ça t'intéresse, j'ai aperçu le plus éclatant des %gRubis Verts%w quelque part à %r", - "" - }; - - Text temp2 = { - "%w.^It's said to have %cmysterious powers%w...^But then, it could just be another regular rupee.&Oh well.", - "%w. On dit qu'il possède des pouvoirs mystérieux... Mais bon, ça pourrait juste être un autre rubis ordinaire.", - "" - }; - - gregText = temp1 + area + temp2; - ctx->AddHint(RH_GREG_RUPEE, gregText, location, HINT_TYPE_STATIC, area); -} - -void CreateSheikText() { - auto ctx = Rando::Context::GetInstance(); - //Get the location of the light arrows - auto lightArrowLocation = FilterFromPool(ctx->allLocations, [ctx](const RandomizerCheck loc){return ctx->GetItemLocation(loc)->GetPlacedRandomizerGet() == RG_LIGHT_ARROWS;}); - lightArrowHintLoc = Rando::StaticData::GetLocation(lightArrowLocation[0])->GetName(); - Text area = GetHintRegion(ctx->GetItemLocation(lightArrowLocation[0])->GetParentRegionKey())->GetHint().GetText(); - Text temp1 = Text{ - "I overheard Ganondorf say that he misplaced the %yLight Arrows%w in&%r", - "J'ai entendu dire que Ganondorf aurait caché les %yFlèches de Lumière%w dans %r", - "" - }; - Text temp2 = Text{"%w.", "%w.", "%w."}; - sheikText = temp1 + area + temp2; -} - -void CreateSariaText() { - auto ctx = Rando::Context::GetInstance(); - //Get the location of a magic upgrade - auto magicLocation = FilterFromPool(ctx->allLocations, [ctx](const RandomizerCheck loc){return ctx->GetItemLocation(loc)->GetPlacedRandomizerGet() == RG_PROGRESSIVE_MAGIC_METER;}); - sariaHintLoc = Rando::StaticData::GetLocation(magicLocation[0])->GetName(); - Text area = GetHintRegion(ctx->GetItemLocation(magicLocation[0])->GetParentRegionKey())->GetHint().GetText(); - Text temp1 = Text{ - "Did you feel the %gsurge of magic%w recently? A mysterious bird told me it came from %r", - "As-tu récemment ressenti une vague de %gpuissance magique%w? Un mystérieux hibou m'a dit qu'elle provenait du %r", - "" - }; - Text temp2 = Text{ - "%w.^You should check that place out, @!$C", - "%w. Tu devrais aller y jeter un coup d'oeil, @!$C", - "%w.$C" - }; - sariaText = temp1 + area + temp2; } @@ -975,178 +885,219 @@ void CreateWarpSongTexts() { } } -void CreateAllHints() { + +int32_t getRandomWeight(int32_t totalWeight){ + if (totalWeight <= 1){ + return 1; + } + return Random(1,totalWeight); +} + + +static void DistrabuteHints(std::array& selected, uint8_t stoneCount, std::array distTable, bool addFixed = true){ + int32_t totalWeight = 0; + + distTable[HINT_TYPE_JUNK].copies = 1; //Junk is hardcoded to 1 copy to avoid fill in issues + + for (HintDistributionSetting setting: distTable){ + totalWeight += setting.weight; + if (addFixed){ + selected[setting.type] += setting.fixed; + stoneCount -= setting.fixed * setting.copies; + } + } + + int32_t currentWeight = getRandomWeight(totalWeight); + while(stoneCount > 0 && totalWeight > 0){ + for (uint8_t hintType = 0; hintType < HINT_TYPE_MAX; hintType++){ + currentWeight -= distTable[hintType].weight; + if (currentWeight <= 0){ + if (stoneCount >= distTable[hintType].copies){ + selected[hintType] += 1; + stoneCount -= distTable[hintType].copies; + break; + } + else { + totalWeight -= distTable[hintType].weight; + distTable[hintType].weight = 0; + break; + } + } + } + currentWeight = getRandomWeight(totalWeight); + } + //if stones are left, assign junk + if (stoneCount > 0){ + selected[HINT_TYPE_JUNK] += stoneCount; + } +} + + +uint8_t PlaceHints(std::array& selectedHints, + std::array& distTable, + uint8_t* remainingDungeonWothHints, + uint8_t* remainingDungeonBarrenHints){ + + std::vector blankList = {}; + auto ctx = Rando::Context::GetInstance(); + + std::array, HINT_TYPE_MAX> hintTypePools = { + blankList, //static, should not happen + blankList, //trial, should not happen + ctx->wothLocations, //woth + CalculateBarrenRegions(), //Barren + blankList, //enternce, not yet implemented + blankList, // always, should not happen + FilterFromPool(ctx->allLocations, [](const RandomizerCheck loc){return Rando::StaticData::GetLocation(loc)->GetHint()->GetType() == HintCategory::Sometimes;}), //sometimes + FilterFromPool(ctx->allLocations, [](const RandomizerCheck loc){return Rando::StaticData::GetLocation(loc)->IsCategory(Category::cSong);}), //songs + FilterFromPool(ctx->allLocations, [](const RandomizerCheck loc){return Rando::StaticData::GetLocation(loc)->IsOverworld();}), //overworld + FilterFromPool(ctx->allLocations, [](const RandomizerCheck loc){return Rando::StaticData::GetLocation(loc)->IsDungeon();}), //dungeon + ctx->allLocations, //Named item + ctx->allLocations, //random + blankList //junk, irrelevent + }; + + for (uint8_t hintType = 0; hintType < HINT_TYPE_MAX; hintType++){ + for (uint8_t numHint = 0; numHint < selectedHints[hintType]; numHint++){ + + SPDLOG_DEBUG("Attempting to make hint of type: "); + SPDLOG_DEBUG(hintTypeNames[hintType]); + SPDLOG_DEBUG("\n"); + + RandomizerCheck hintedLocation = RC_UNKNOWN_CHECK; + + //create the appropriate hint for the type + if (hintType == HINT_TYPE_JUNK){ + CreateJunkHint(); + } + else{ + hintTypePools[hintType] = FilterHintability(hintTypePools[hintType], (hintType == HINT_TYPE_NAMED_ITEM)); + hintedLocation = CreateRandomHint(hintTypePools[hintType], distTable[hintType].copies, (HintType)hintType); + if (hintedLocation == RC_UNKNOWN_CHECK){ //if hint failed to place + uint8_t hintsToRemove = (selectedHints[hintType] - numHint) * distTable[hintType].copies; + selectedHints[hintType] = 0; //RANDOTODO is there a better way to filter out things hinted between hintTypePools creation and now + distTable[hintType].weight = 0; + return hintsToRemove; + } + } + + switch(hintType){ + case HINT_TYPE_WOTH: + if (Rando::StaticData::GetLocation(hintedLocation)->IsDungeon()){ + *remainingDungeonWothHints -= 1; + if (*remainingDungeonWothHints <= 0){ + hintTypePools[hintType] = FilterHintability(hintTypePools[hintType], false, false); + } + } + break; + case HINT_TYPE_BARREN: + if (Rando::StaticData::GetLocation(hintedLocation)->IsDungeon()){ + *remainingDungeonBarrenHints -= 1; + if (*remainingDungeonBarrenHints <= 0){ + hintTypePools[hintType] = FilterHintability(hintTypePools[hintType], false, false); + } + } + break; + } + } + selectedHints[hintType] = 0; + } + return 0; +} + +void CreateStoneHints() { auto ctx = Rando::Context::GetInstance(); SPDLOG_DEBUG("\nNOW CREATING HINTS\n"); const HintSetting& hintSetting = hintSettingTable[Settings::HintDistribution.Value()]; + std::array distTable = hintSetting.distTable; - uint8_t remainingDungeonWothHints = hintSetting.dungeonsWothLimit; - uint8_t remainingDungeonBarrenHints = hintSetting.dungeonsBarrenLimit; + uint8_t* remainingDungeonWothHints = new uint8_t(hintSetting.dungeonsWothLimit); + uint8_t* remainingDungeonBarrenHints = new uint8_t(hintSetting.dungeonsBarrenLimit); + + // Apply Special hint exclusions with no requirements + if (Settings::Kak10GSHintText){ + ctx->GetItemLocation(RC_KAK_10_GOLD_SKULLTULA_REWARD)->SetAsHinted(); + } + if (Settings::Kak20GSHintText){ + ctx->GetItemLocation(RC_KAK_20_GOLD_SKULLTULA_REWARD)->SetAsHinted(); + } + if (Settings::Kak30GSHintText){ + ctx->GetItemLocation(RC_KAK_30_GOLD_SKULLTULA_REWARD)->SetAsHinted(); + } + if (Settings::Kak40GSHintText){ + ctx->GetItemLocation(RC_KAK_40_GOLD_SKULLTULA_REWARD)->SetAsHinted(); + } + if (Settings::Kak50GSHintText){ + ctx->GetItemLocation(RC_KAK_50_GOLD_SKULLTULA_REWARD)->SetAsHinted(); + } + if (Settings::FrogsHintText){ + ctx->GetItemLocation(RC_ZR_FROGS_OCARINA_GAME)->SetAsHinted(); + } + if (Settings::skipChildZelda){ + ctx->GetItemLocation(RC_SONG_FROM_IMPA)->SetAsHinted(); + } // Add 'always' location hints - if (hintSetting.distTable[static_cast(HINT_TYPE_ALWAYS)].copies > 0) { + auto alwaysCopies = distTable[static_cast(HINT_TYPE_ALWAYS)].copies; + if (alwaysCopies > 0) { // Only filter locations that had a random item placed at them (e.g. don't get cow locations if shuffle cows is // off) auto alwaysHintLocations = FilterFromPool(ctx->allLocations, [ctx](const RandomizerCheck loc) { return ((Rando::StaticData::GetLocation(loc)->GetHint()->GetType() == HintCategory::Always) || // If we have Rainbow Bridge set to Greg, add a hint for where Greg is - (Bridge.Is(RAINBOWBRIDGE_GREG) && !GregHintText && + (Bridge.Is(RAINBOWBRIDGE_GREG) && ctx->GetItemLocation(loc)->GetPlacedRandomizerGet() == RG_GREG_RUPEE)) && ctx->GetItemLocation(loc)->IsHintable() && !(ctx->GetItemLocation(loc)->IsHintedAt()); }); for (auto& hint : conditionalAlwaysHints) { RandomizerCheck loc = hint.first; - if (hint.second() && ctx->GetItemLocation(loc)->IsHintable() && !ctx->GetItemLocation(loc)->IsHintedAt()) { + if (hint.second() && ctx->GetItemLocation(loc)->IsHintable()) { alwaysHintLocations.push_back(loc); } } - for (RandomizerCheck location : alwaysHintLocations) { - CreateLocationHint({ location }); - } + for (RandomizerCheck location : alwaysHintLocations) { + CreateHint(location, alwaysCopies, HINT_TYPE_ALWAYS); + } } //Add 'trial' location hints - if (hintSetting.distTable[static_cast(HINT_TYPE_TRIAL)].copies > 0) { - CreateTrialHints(); + auto trialCopies = distTable[static_cast(HINT_TYPE_TRIAL)].copies; + if (trialCopies > 0) { + CreateTrialHints(trialCopies); } - //create a vector with each hint type proportional to it's weight in the distribution setting. - //ootr uses a weighted probability function to decide hint types, but selecting randomly from - //this vector will do for now - std::vector remainingHintTypes = {}; - for (HintDistributionSetting hds : hintSetting.distTable) { - remainingHintTypes.insert(remainingHintTypes.end(), hds.weight, hds.type); - } - Shuffle(remainingHintTypes); + uint8_t totalStones = GetEmptyGossipStones().size(); + std::array selectedHints = {}; + DistrabuteHints(selectedHints, totalStones, distTable); - //get barren regions - auto barrenLocations = CalculateBarrenRegions(); - - //Calculate dungeon woth/barren info - - std::vector dungeonNames = {"Deku Tree", "Dodongos Cavern", "Jabu Jabus Belly", "Forest Temple", "Fire Temple", - "Water Temple", "Spirit Temple", "Shadow Temple", "Bottom of the Well", "Ice Cavern"}; - //Get list of all barren dungeons - std::vector barrenDungeons; - for (RandomizerCheck barrenLocation : barrenLocations) { - std::string barrenRegion = GetHintRegion(ctx->GetItemLocation(barrenLocation)->GetParentRegionKey())->scene; - bool isDungeon = std::find(dungeonNames.begin(), dungeonNames.end(), barrenRegion) != dungeonNames.end(); - //If it hasn't already been added to the list and is a dungeon, add to list - if (isDungeon && std::find(barrenDungeons.begin(), barrenDungeons.end(), barrenRegion) == barrenDungeons.end()) { - barrenDungeons.push_back(barrenRegion); + while(totalStones != 0){ + totalStones = PlaceHints(selectedHints, distTable, remainingDungeonWothHints, remainingDungeonBarrenHints); + if (totalStones != 0){ + DistrabuteHints(selectedHints, totalStones, distTable, false); } } - SPDLOG_DEBUG("\nBarren Dungeons:\n"); - for (std::string barrenDungeon : barrenDungeons) { - SPDLOG_DEBUG(barrenDungeon + "\n"); - } - - //Get list of all woth dungeons - std::vector wothDungeons; - for (RandomizerCheck wothLocation : ctx->wothLocations) { - std::string wothRegion = GetHintRegion(ctx->GetItemLocation(wothLocation)->GetParentRegionKey())->scene; - bool isDungeon = std::find(dungeonNames.begin(), dungeonNames.end(), wothRegion) != dungeonNames.end(); - //If it hasn't already been added to the list and is a dungeon, add to list - if (isDungeon && std::find(wothDungeons.begin(), wothDungeons.end(), wothRegion) == wothDungeons.end()) { - wothDungeons.push_back(wothRegion); - } - } - SPDLOG_DEBUG("\nWoth Dungeons:\n"); - for (std::string wothDungeon : wothDungeons) { - SPDLOG_DEBUG(wothDungeon + "\n"); - } - - //Set DungeonInfo array for each dungeon - for (uint32_t i = 0; i < dungeonInfoData.size(); i++) { - std::string dungeonName = dungeonNames[i]; - if (std::find(barrenDungeons.begin(), barrenDungeons.end(), dungeonName) != barrenDungeons.end()) { - dungeonInfoData[i] = DungeonInfo::DUNGEON_BARREN; - } else if (std::find(wothDungeons.begin(), wothDungeons.end(), dungeonName) != wothDungeons.end()) { - dungeonInfoData[i] = DungeonInfo::DUNGEON_WOTH; - } else { - dungeonInfoData[i] = DungeonInfo::DUNGEON_NEITHER; - } - } - - //while there are still gossip stones remaining - while (FilterFromPool(Rando::StaticData::gossipStoneLocations, [ctx](const RandomizerCheck loc) { - return ctx->GetItemLocation(loc)->GetPlacedRandomizerGet() == RG_NONE; - }).size() != 0) { - // TODO: fixed hint types - - if (remainingHintTypes.empty()) { - break; - } - - // get a random hint type from the remaining hints - HintType type = RandomElement(remainingHintTypes, true); - - SPDLOG_DEBUG("Attempting to make hint of type: "); - SPDLOG_DEBUG(hintTypeNames.find(type)->second); - SPDLOG_DEBUG("\n"); - - // create the appropriate hint for the type - if (type == HINT_TYPE_WOTH) { - CreateWothHint(&remainingDungeonWothHints); - - } else if (type == HINT_TYPE_BARREN) { - CreateBarrenHint(&remainingDungeonBarrenHints, barrenLocations); - - } else if (type == HINT_TYPE_SOMETIMES) { - std::vector sometimesHintLocations = - FilterFromPool(ctx->allLocations, [ctx](const RandomizerCheck loc) { - return ctx->GetHint(ctx->GetItemLocation(loc)->GetHintKey())->GetHintType() == HINT_TYPE_SOMETIMES && - ctx->GetItemLocation(loc)->IsHintable() && !(ctx->GetItemLocation(loc)->IsHintedAt()); - }); - CreateLocationHint(sometimesHintLocations); - - } else if (type == HINT_TYPE_RANDOM) { - CreateRandomLocationHint(); - - } else if (type == HINT_TYPE_ITEM) { - CreateGoodItemHint(); - - } else if (type == HINT_TYPE_SONG) { - std::vector songHintLocations = - FilterFromPool(ctx->allLocations, [ctx](const RandomizerCheck loc) { - return Rando::StaticData::GetLocation(loc)->IsCategory(Category::cSong) && - ctx->GetItemLocation(loc)->IsHintable() && !(ctx->GetItemLocation(loc)->IsHintedAt()); - }); - CreateLocationHint(songHintLocations); - - } else if (type == HINT_TYPE_OVERWORLD) { - std::vector overworldHintLocations = - FilterFromPool(ctx->allLocations, [ctx](const RandomizerCheck loc) { - return Rando::StaticData::GetLocation(loc)->IsOverworld() && ctx->GetItemLocation(loc)->IsHintable() && - !(ctx->GetItemLocation(loc)->IsHintedAt()); - }); - CreateLocationHint(overworldHintLocations); - - } else if (type == HINT_TYPE_DUNGEON) { - std::vector dungeonHintLocations = - FilterFromPool(ctx->allLocations, [ctx](const RandomizerCheck loc) { - return Rando::StaticData::GetLocation(loc)->IsDungeon() && ctx->GetItemLocation(loc)->IsHintable() && - !(ctx->GetItemLocation(loc)->IsHintedAt()); - }); - CreateLocationHint(dungeonHintLocations); - - } else if (type == HINT_TYPE_JUNK) { - CreateJunkHint(); - } - } - - //If any gossip stones failed to have a hint placed on them for some reason, place a junk hint as a failsafe. - for (RandomizerCheck gossipStone : FilterFromPool(Rando::StaticData::gossipStoneLocations, [ctx](const RandomizerCheck loc) { - return ctx->GetItemLocation(loc)->GetPlacedRandomizerGet() == RG_NONE; - })) { - const HintText junkHint = RandomElement(GetHintCategory(HintCategory::Junk)); - AddHint(junkHint.GetText(), gossipStone, { QM_PINK }); - } //Getting gossip stone locations temporarily sets one location to not be reachable. //Call the function one last time to get rid of false positives on locations not //being reachable. GetAccessibleLocations({}); } + +void CreateAllHints(){ + CreateGanonAndSheikText(); + CreateAltarText(); + CreateSpecialItemHint(RG_PROGRESSIVE_HOOKSHOT, {RC_DAMPE_HINT}, RHT_DAMPE_DIARY01, RHT_DAMPE_DIARY02, dampesText, dampeHintLoc, (bool)DampeHintText); + CreateSpecialItemHint(RG_GREG_RUPEE, {RC_GREG_HINT}, RHT_GREG_HINT01, RHT_GREG_HINT02, gregText, gregHintLoc, (bool)GregHintText); + CreateSpecialItemHint(RG_PROGRESSIVE_MAGIC_METER, {RC_SARIA_SONG_HINT, RC_SONG_FROM_SARIA}, RHT_SARIA_TEXT01, RHT_SARIA_TEXT02, sariaText, sariaHintLoc, (bool)SariaHintText); + + if (ShuffleMerchants.Is(SHUFFLEMERCHANTS_HINTS)) { + CreateMerchantsHints(); + } + if (GossipStoneHints.IsNot(HINTS_NO_HINTS)) { + printf("\x1b[10;10HCreating Hints..."); + CreateStoneHints(); + printf("Done"); + } +} diff --git a/soh/soh/Enhancements/randomizer/3drando/hints.hpp b/soh/soh/Enhancements/randomizer/3drando/hints.hpp index ea942909c..501f0b36a 100644 --- a/soh/soh/Enhancements/randomizer/3drando/hints.hpp +++ b/soh/soh/Enhancements/randomizer/3drando/hints.hpp @@ -12,7 +12,6 @@ struct HintDistributionSetting { HintType type; - uint8_t order; size_t weight; uint8_t fixed; uint8_t copies; @@ -42,8 +41,10 @@ enum class HintCategory { LACS, Altar, Validation, - LightArrow, + OtherHint, + MasterSword, GanonLine, + SheikLine, MerchantsDialogs, }; @@ -112,14 +113,22 @@ public: return HintText{std::move(obscureText), std::move(ambiguousText), std::move(clearText), HintCategory::Validation}; } - static auto LightArrow(std::vector&& obscureText, std::vector&& ambiguousText = {}, Text&& clearText = {}) { - return HintText{std::move(obscureText), std::move(ambiguousText), std::move(clearText), HintCategory::LightArrow}; + static auto OtherHint(std::vector&& obscureText, std::vector&& ambiguousText = {}, Text&& clearText = {}) { + return HintText{std::move(obscureText), std::move(ambiguousText), std::move(clearText), HintCategory::OtherHint}; + } + + static auto MasterSword(std::vector&& obscureText, std::vector&& ambiguousText = {}, Text&& clearText = {}) { + return HintText{std::move(obscureText), std::move(ambiguousText), std::move(clearText), HintCategory::MasterSword}; } static auto GanonLine(std::vector&& obscureText, std::vector&& ambiguousText = {}, Text&& clearText = {}) { return HintText{std::move(obscureText), std::move(ambiguousText), std::move(clearText), HintCategory::GanonLine}; } + static auto SheikLine(std::vector&& obscureText, std::vector&& ambiguousText = {}, Text&& clearText = {}) { + return HintText{std::move(obscureText), std::move(ambiguousText), std::move(clearText), HintCategory::SheikLine}; + } + static auto MerchantsDialogs(std::vector&& obscureText, std::vector&& ambiguousText = {}, Text&& clearText = {}) { return HintText{std::move(obscureText), std::move(ambiguousText), std::move(clearText), HintCategory::MerchantsDialogs}; } @@ -197,23 +206,17 @@ using ConditionalAlwaysHint = std::pair>; //10 dungeons as GTG and GC are excluded extern std::array dungeonInfoData; - -extern std::array conditionalAlwaysHints; +extern std::array conditionalAlwaysHints; extern RandomizerHintTextKey GetHintRegionHintKey(const RandomizerRegion area); extern void CreateAllHints(); -extern void CreateMerchantsHints(); extern void CreateWarpSongTexts(); -extern void CreateDampesDiaryText(); -extern void CreateGregRupeeHint(); -extern void CreateSheikText(); -extern void CreateSariaText(); -extern void CreateGanonText(); -extern void CreateAltarText(); + Text& GetChildAltarText(); Text& GetAdultAltarText(); Text& GetGanonText(); +void SetGanonText(Text text); Text& GetGanonHintText(); Text& GetDampeHintText(); Text& GetGregHintText(); @@ -227,6 +230,8 @@ Text& GetWarpRequiemText(); Text& GetWarpNocturneText(); Text& GetWarpPreludeText(); -std::string GetDampeHintLoc(); +std::string GetMasterSwordHintLoc(); std::string GetLightArrowHintLoc(); +std::string GetDampeHintLoc(); +std::string GetGregHintLoc(); std::string GetSariaHintLoc(); diff --git a/soh/soh/Enhancements/randomizer/3drando/item_pool.cpp b/soh/soh/Enhancements/randomizer/3drando/item_pool.cpp index 09bdbff98..939bc4ff1 100644 --- a/soh/soh/Enhancements/randomizer/3drando/item_pool.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/item_pool.cpp @@ -108,9 +108,10 @@ const std::array alwaysItems = { RG_ARROWS_10, RG_TREASURE_GAME_HEART, }; -const std::array easyItems = { +const std::array easyItems = { RG_BIGGORON_SWORD, RG_KOKIRI_SWORD, + RG_MASTER_SWORD, RG_BOOMERANG, RG_LENS_OF_TRUTH, RG_MEGATON_HAMMER, @@ -686,6 +687,13 @@ void GenerateItemPool() { ctx->PlaceItemInLocation(RC_KF_KOKIRI_SWORD_CHEST, RG_KOKIRI_SWORD, false, true); } + if (ShuffleMasterSword) { + AddItemToMainPool(RG_MASTER_SWORD); + IceTrapModels.push_back(0xE0); //Master Sword without the GI enum + } else { + ctx->PlaceItemInLocation(RC_TOT_MASTER_SWORD, RG_MASTER_SWORD, false, true); + } + if (ShuffleWeirdEgg) { AddItemToMainPool(RG_WEIRD_EGG); IceTrapModels.push_back(GI_WEIRD_EGG); @@ -1190,6 +1198,10 @@ void GenerateItemPool() { ReplaceMaxItem(RG_KOKIRI_SWORD, 0); } + if (!ShuffleMasterSword) { + ReplaceMaxItem(RG_MASTER_SWORD, 0); + } + if (ProgressiveGoronSword) { ReplaceMaxItem(RG_BIGGORON_SWORD, 0); AddItemToMainPool(RG_PROGRESSIVE_GORONSWORD, 2); diff --git a/soh/soh/Enhancements/randomizer/3drando/location_access.cpp b/soh/soh/Enhancements/randomizer/3drando/location_access.cpp index b04bf8207..f2e227324 100644 --- a/soh/soh/Enhancements/randomizer/3drando/location_access.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/location_access.cpp @@ -258,8 +258,9 @@ void AreaTable_Init() { //name, scene, hint text, events, locations, exits areaTable[RR_ROOT] = Area("Root", "", RHT_LINKS_POCKET, NO_DAY_NIGHT_CYCLE, {}, { //Locations - LocationAccess(RC_LINKS_POCKET, {[]{return true;}}), - LocationAccess(RC_TRIFORCE_COMPLETED, { [] { return CanCompleteTriforce;}}), + LocationAccess(RC_LINKS_POCKET, {[]{return true;}}), + LocationAccess(RC_TRIFORCE_COMPLETED, {[]{return CanCompleteTriforce;}}), + LocationAccess(RC_SARIA_SONG_HINT, {[]{return CanPlay(SariasSong);}}), }, { //Exits Entrance(RR_ROOT_EXITS, {[]{return true;}}) diff --git a/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_castle_town.cpp b/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_castle_town.cpp index b69787769..edcf795ad 100644 --- a/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_castle_town.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_castle_town.cpp @@ -53,6 +53,8 @@ void AreaTable_Init_CastleTown() { areaTable[RR_TEMPLE_OF_TIME] = Area("Temple of Time", "Temple of Time", RHT_TEMPLE_OF_TIME, NO_DAY_NIGHT_CYCLE, {}, { //Locations LocationAccess(RC_TOT_LIGHT_ARROWS_CUTSCENE, {[]{return IsAdult && CanTriggerLACS;}}), + LocationAccess(RC_ALTAR_HINT_CHILD, {[]{return IsChild;}}), + LocationAccess(RC_ALTAR_HINT_ADULT, {[]{return IsAdult;}}), }, { //Exits Entrance(RR_TOT_ENTRANCE, {[]{return true;}}), @@ -64,13 +66,14 @@ void AreaTable_Init_CastleTown() { //EventAccess(&TimeTravel, {[]{return true;}}), }, { //Locations + LocationAccess(RC_TOT_MASTER_SWORD, {[]{return IsAdult;}}), LocationAccess(RC_SHEIK_AT_TEMPLE, {[]{return ForestMedallion && IsAdult;}}), }, { //Exits Entrance(RR_TEMPLE_OF_TIME, {[]{return true;}}), }); - areaTable[RR_CASTLE_GROUNDS] = Area("Castle Grounds", "Castle Grounds", RHT_NONE, NO_DAY_NIGHT_CYCLE, {}, {}, { + areaTable[RR_CASTLE_GROUNDS] = Area("Castle Grounds", "Castle Grounds", RHT_CASTLE_GROUNDS, NO_DAY_NIGHT_CYCLE, {}, {}, { //Exits Entrance(RR_THE_MARKET, {[]{return true;}}), Entrance(RR_HYRULE_CASTLE_GROUNDS, {[]{return IsChild;}}), @@ -156,7 +159,7 @@ void AreaTable_Init_CastleTown() { Entrance(RR_GANONS_CASTLE_LEDGE, { [] { return IsAdult; }}), }); - areaTable[RR_GANONS_CASTLE_LEDGE] = Area("Ganon's Castle Ledge", "OGC Ganon's Castle Ledge", RHT_NONE, NO_DAY_NIGHT_CYCLE, + areaTable[RR_GANONS_CASTLE_LEDGE] = Area("Ganon's Castle Ledge", "OGC Ganon's Castle Ledge", RHT_OUTSIDE_GANONS_CASTLE, NO_DAY_NIGHT_CYCLE, {}, {}, { // Exits Entrance(RR_GANONS_CASTLE_GROUNDS, {[]{return BuiltRainbowBridge;}}), @@ -231,6 +234,7 @@ void AreaTable_Init_CastleTown() { areaTable[RR_MARKET_TREASURE_CHEST_GAME] = Area("Market Treasure Chest Game", "Market Treasure Chest Game", RHT_NONE, NO_DAY_NIGHT_CYCLE, {}, { //Locations + LocationAccess(RC_GREG_HINT, {[]{return true;}}), LocationAccess(RC_MARKET_TREASURE_CHEST_GAME_REWARD, {[]{return (CanUse(RG_LENS_OF_TRUTH) && !ShuffleChestMinigame) || (ShuffleChestMinigame.Is(SHUFFLECHESTMINIGAME_SINGLE_KEYS) && SmallKeys(RR_MARKET_TREASURE_CHEST_GAME, 6)) || (ShuffleChestMinigame.Is(SHUFFLECHESTMINIGAME_PACK) && SmallKeys(RR_MARKET_TREASURE_CHEST_GAME, 1));}}), LocationAccess(RC_MARKET_TREASURE_CHEST_GAME_ITEM_1, {[]{return (ShuffleChestMinigame.Is(SHUFFLECHESTMINIGAME_SINGLE_KEYS) && SmallKeys(RR_MARKET_TREASURE_CHEST_GAME, 1)) || (ShuffleChestMinigame.Is(SHUFFLECHESTMINIGAME_PACK) && SmallKeys(RR_MARKET_TREASURE_CHEST_GAME, 1)) || (CanUse(RG_LENS_OF_TRUTH) && !ShuffleChestMinigame);}}), LocationAccess(RC_MARKET_TREASURE_CHEST_GAME_ITEM_2, {[]{return (ShuffleChestMinigame.Is(SHUFFLECHESTMINIGAME_SINGLE_KEYS) && SmallKeys(RR_MARKET_TREASURE_CHEST_GAME, 2)) || (ShuffleChestMinigame.Is(SHUFFLECHESTMINIGAME_PACK) && SmallKeys(RR_MARKET_TREASURE_CHEST_GAME, 1)) || (CanUse(RG_LENS_OF_TRUTH) && !ShuffleChestMinigame);}}), diff --git a/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_death_mountain.cpp b/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_death_mountain.cpp index 19556e07b..65c6a4c2c 100644 --- a/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_death_mountain.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_death_mountain.cpp @@ -46,7 +46,7 @@ void AreaTable_Init_DeathMountain() { Entrance(RR_DMT_GREAT_FAIRY_FOUNTAIN, {[]{return Here(RR_DEATH_MOUNTAIN_SUMMIT, []{return CanBlastOrSmash;});}}), }); - areaTable[RR_DMT_OWL_FLIGHT] = Area("DMT Owl Flight", "Death Mountain", RHT_NONE, NO_DAY_NIGHT_CYCLE, {}, {}, { + areaTable[RR_DMT_OWL_FLIGHT] = Area("DMT Owl Flight", "Death Mountain", RHT_DEATH_MOUNTAIN_TRAIL, NO_DAY_NIGHT_CYCLE, {}, {}, { //Exits Entrance(RR_KAK_IMPAS_ROOFTOP, {[]{return true;}}), }); @@ -95,7 +95,7 @@ void AreaTable_Init_DeathMountain() { LocationAccess(RC_GC_ROLLING_GORON_AS_CHILD, {[]{return IsChild && (HasExplosives || (GoronBracelet && LogicChildRollingWithStrength));}}), LocationAccess(RC_GC_ROLLING_GORON_AS_ADULT, {[]{return StopGCRollingGoronAsAdult;}}), LocationAccess(RC_GC_GS_BOULDER_MAZE, {[]{return IsChild && CanBlastOrSmash;}}), - LocationAccess(RC_GC_GS_CENTER_PLATFORM, {[]{return IsAdult;}}), + LocationAccess(RC_GC_GS_CENTER_PLATFORM, {[]{return CanAdultAttack;}}), LocationAccess(RC_GC_MEDIGORON, {[]{return IsAdult && AdultsWallet && (CanBlastOrSmash || GoronBracelet);}}), LocationAccess(RC_GC_MAZE_GOSSIP_STONE, {[]{return CanBlastOrSmash || CanUse(RG_SILVER_GAUNTLETS);}}), LocationAccess(RC_GC_MEDIGORON_GOSSIP_STONE, {[]{return CanBlastOrSmash || GoronBracelet;}}), @@ -108,7 +108,7 @@ void AreaTable_Init_DeathMountain() { Entrance(RR_GC_GROTTO_PLATFORM, {[]{return IsAdult && ((CanPlay(SongOfTime) && ((EffectiveHealth > 2) || CanUse(RG_GORON_TUNIC) || CanUse(RG_LONGSHOT) || CanUse(RG_NAYRUS_LOVE))) || (EffectiveHealth > 1 && CanUse(RG_GORON_TUNIC) && CanUse(RG_HOOKSHOT)) || (CanUse(RG_NAYRUS_LOVE) && CanUse(RG_HOOKSHOT)) || (EffectiveHealth > 2 && CanUse(RG_HOOKSHOT) && LogicGoronCityGrotto));}}), }); - areaTable[RR_GC_WOODS_WARP] = Area("GC Woods Warp", "Goron City", RHT_NONE, NO_DAY_NIGHT_CYCLE, { + areaTable[RR_GC_WOODS_WARP] = Area("GC Woods Warp", "Goron City", RHT_GORON_CITY, NO_DAY_NIGHT_CYCLE, { //Events EventAccess(&GCWoodsWarpOpen, {[]{return GCWoodsWarpOpen || (CanBlastOrSmash || CanUse(RG_DINS_FIRE));}}), }, {}, { diff --git a/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_deku_tree.cpp b/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_deku_tree.cpp index 5186a2b43..cba524f62 100644 --- a/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_deku_tree.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_deku_tree.cpp @@ -23,8 +23,8 @@ void AreaTable_Init_DekuTree() { if (Dungeon::DekuTree.IsVanilla()) { areaTable[RR_DEKU_TREE_LOBBY] = Area("Deku Tree Lobby", "Deku Tree", RHT_DEKU_TREE, NO_DAY_NIGHT_CYCLE, { //Events - EventAccess(&DekuBabaSticks, {[]{return DekuBabaSticks || (IsAdult || KokiriSword || Boomerang);}}), - EventAccess(&DekuBabaNuts, {[]{return DekuBabaNuts || (IsAdult || KokiriSword || Slingshot || Sticks || HasExplosives || CanUse(RG_DINS_FIRE));}}), + EventAccess(&DekuBabaSticks, {[]{return DekuBabaSticks || (CanUse(RG_KOKIRI_SWORD) || CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD) || CanUse(RG_BOOMERANG));}}), + EventAccess(&DekuBabaNuts, {[]{return DekuBabaNuts || (CanJumpslash || CanUse(RG_FAIRY_SLINGSHOT) || CanUse(RG_FAIRY_BOW) || CanUse(RG_MEGATON_HAMMER) || HasExplosives || CanUse(RG_DINS_FIRE));}}), }, { //Locations LocationAccess(RC_DEKU_TREE_MAP_CHEST, {[]{return true;}}), @@ -33,7 +33,7 @@ void AreaTable_Init_DekuTree() { Entrance(RR_DEKU_TREE_ENTRYWAY, {[]{return true;}}), Entrance(RR_DEKU_TREE_2F_MIDDLE_ROOM, {[]{return true;}}), Entrance(RR_DEKU_TREE_COMPASS_ROOM, {[]{return true;}}), - Entrance(RR_DEKU_TREE_BASEMENT_LOWER, {[]{return Here(RR_DEKU_TREE_LOBBY, []{return IsAdult || CanChildAttack || Nuts;});}}), + Entrance(RR_DEKU_TREE_BASEMENT_LOWER, {[]{return Here(RR_DEKU_TREE_LOBBY, []{return CanAdultAttack || CanChildAttack || Nuts;});}}), Entrance(RR_DEKU_TREE_OUTSIDE_BOSS_ROOM, {[]{return false;}}), Entrance(RR_DEKU_TREE_BOSS_ENTRYWAY, {[]{return false;}}), }); @@ -55,13 +55,13 @@ void AreaTable_Init_DekuTree() { areaTable[RR_DEKU_TREE_COMPASS_ROOM] = Area("Deku Tree Compass Room", "Deku Tree", RHT_DEKU_TREE, NO_DAY_NIGHT_CYCLE, { //Events - EventAccess(&DekuBabaSticks, {[]{return DekuBabaSticks || (IsAdult || KokiriSword || Boomerang);}}), - EventAccess(&DekuBabaNuts, {[]{return DekuBabaNuts || (IsAdult || KokiriSword || Slingshot || Sticks || HasExplosives || CanUse(RG_DINS_FIRE));}}), + EventAccess(&DekuBabaSticks, {[]{return DekuBabaSticks || (CanUse(RG_KOKIRI_SWORD) || CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD) || CanUse(RG_BOOMERANG));}}), + EventAccess(&DekuBabaNuts, {[]{return DekuBabaNuts || (CanJumpslash || CanUse(RG_FAIRY_SLINGSHOT) || CanUse(RG_FAIRY_BOW) || CanUse(RG_MEGATON_HAMMER) || HasExplosives || CanUse(RG_DINS_FIRE));}}), }, { //Locations LocationAccess(RC_DEKU_TREE_COMPASS_CHEST, {[]{return true;}}), LocationAccess(RC_DEKU_TREE_COMPASS_ROOM_SIDE_CHEST, {[]{return true;}}), - LocationAccess(RC_DEKU_TREE_GS_COMPASS_ROOM, {[]{return IsAdult || CanChildAttack;}}), + LocationAccess(RC_DEKU_TREE_GS_COMPASS_ROOM, {[]{return CanAdultAttack || CanChildAttack;}}), }, { //Exits Entrance(RR_DEKU_TREE_LOBBY, {[]{return HasFireSourceWithTorch || CanUse(RG_FAIRY_BOW);}}), @@ -70,14 +70,14 @@ void AreaTable_Init_DekuTree() { areaTable[RR_DEKU_TREE_BASEMENT_LOWER] = Area("Deku Tree Basement Lower", "Deku Tree", RHT_DEKU_TREE, NO_DAY_NIGHT_CYCLE, { //Events - EventAccess(&DekuBabaSticks, {[]{return DekuBabaSticks || (IsAdult || KokiriSword || Boomerang);}}), - EventAccess(&DekuBabaNuts, {[]{return DekuBabaNuts || (IsAdult || KokiriSword || Slingshot || Sticks || HasExplosives || CanUse(RG_DINS_FIRE));}, + EventAccess(&DekuBabaSticks, {[]{return DekuBabaSticks || (CanUse(RG_KOKIRI_SWORD) || CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD) || Boomerang);}}), + EventAccess(&DekuBabaNuts, {[]{return DekuBabaNuts || (CanJumpslash || CanUse(RG_FAIRY_SLINGSHOT) || CanUse(RG_FAIRY_BOW) || CanUse(RG_MEGATON_HAMMER) || HasExplosives || CanUse(RG_DINS_FIRE));}, /*Glitched*/[]{return CanUse(RG_MEGATON_HAMMER);}}), }, { //Locations LocationAccess(RC_DEKU_TREE_BASEMENT_CHEST, {[]{return true;}}), - LocationAccess(RC_DEKU_TREE_GS_BASEMENT_GATE, {[]{return IsAdult || CanChildAttack;}}), - LocationAccess(RC_DEKU_TREE_GS_BASEMENT_VINES, {[]{return CanUseProjectile || CanUse(RG_DINS_FIRE) || (LogicDekuBasementGS && (IsAdult || Sticks || KokiriSword));}}), + LocationAccess(RC_DEKU_TREE_GS_BASEMENT_GATE, {[]{return CanJumpslash || CanUse(RG_FAIRY_SLINGSHOT) || CanUse(RG_BOOMERANG) || HasExplosives || CanUse(RG_FAIRY_BOW) || CanUse(RG_HOOKSHOT) || CanUse(RG_DINS_FIRE);}}), + LocationAccess(RC_DEKU_TREE_GS_BASEMENT_VINES, {[]{return CanUseProjectile || CanUse(RG_DINS_FIRE) || (LogicDekuBasementGS && CanJumpslash);}}), }, { //Exits Entrance(RR_DEKU_TREE_LOBBY, {[]{return true;}}), @@ -100,8 +100,8 @@ void AreaTable_Init_DekuTree() { areaTable[RR_DEKU_TREE_BASEMENT_TORCH_ROOM] = Area("Deku Tree Basement Torch Room", "Deku Tree", RHT_DEKU_TREE, NO_DAY_NIGHT_CYCLE, { //Events - EventAccess(&DekuBabaSticks, {[]{return DekuBabaSticks || (IsAdult || KokiriSword || Boomerang);}}), - EventAccess(&DekuBabaNuts, {[]{return DekuBabaNuts || (IsAdult || KokiriSword || Slingshot || Sticks || HasExplosives || CanUse(RG_DINS_FIRE));}}), + EventAccess(&DekuBabaSticks, {[]{return DekuBabaSticks || (CanUse(RG_KOKIRI_SWORD) || CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD) || CanUse(RG_BOOMERANG));}}), + EventAccess(&DekuBabaNuts, {[]{return DekuBabaNuts || (CanJumpslash || CanUse(RG_FAIRY_SLINGSHOT) || CanUse(RG_FAIRY_BOW) || CanUse(RG_MEGATON_HAMMER) || HasExplosives || CanUse(RG_DINS_FIRE));}}), }, {}, { //Exits Entrance(RR_DEKU_TREE_BASEMENT_WATER_ROOM, {[]{return true;}}), @@ -110,9 +110,9 @@ void AreaTable_Init_DekuTree() { areaTable[RR_DEKU_TREE_BASEMENT_BACK_LOBBY] = Area("Deku Tree Basement Back Lobby", "Deku Tree", RHT_DEKU_TREE, NO_DAY_NIGHT_CYCLE, { //Events - EventAccess(&DekuBabaSticks, {[]{return DekuBabaSticks || (IsAdult || KokiriSword || Boomerang);}}), + EventAccess(&DekuBabaSticks, {[]{return DekuBabaSticks || (CanUse(RG_KOKIRI_SWORD) || CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD) || CanUse(RG_BOOMERANG));}}), EventAccess(&DekuBabaNuts, {[]{return DekuBabaNuts || (Here(RR_DEKU_TREE_BASEMENT_BACK_LOBBY, []{return HasFireSourceWithTorch || CanUse(RG_FAIRY_BOW);}) && - (IsAdult || KokiriSword || Slingshot || Sticks || HasExplosives || CanUse(RG_DINS_FIRE)));}}), + (CanJumpslash || CanUse(RG_FAIRY_SLINGSHOT) || CanUse(RG_FAIRY_BOW) || CanUse(RG_MEGATON_HAMMER) || HasExplosives || CanUse(RG_DINS_FIRE)));}}), }, {}, { //Exits Entrance(RR_DEKU_TREE_BASEMENT_TORCH_ROOM, {[]{return true;}}), @@ -131,8 +131,8 @@ void AreaTable_Init_DekuTree() { areaTable[RR_DEKU_TREE_BASEMENT_UPPER] = Area("Deku Tree Basement Upper", "Deku Tree", RHT_DEKU_TREE, NO_DAY_NIGHT_CYCLE, { //Events - EventAccess(&DekuBabaSticks, {[]{return DekuBabaSticks || (IsAdult || KokiriSword || Boomerang);}}), - EventAccess(&DekuBabaNuts, {[]{return DekuBabaNuts || (IsAdult || KokiriSword || Slingshot || Sticks || HasExplosives || CanUse(RG_DINS_FIRE));}}), + EventAccess(&DekuBabaSticks, {[]{return DekuBabaSticks || (CanUse(RG_KOKIRI_SWORD) || CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD) || CanUse(RG_BOOMERANG));}}), + EventAccess(&DekuBabaNuts, {[]{return DekuBabaNuts || (CanJumpslash || CanUse(RG_FAIRY_SLINGSHOT) || CanUse(RG_FAIRY_BOW) || CanUse(RG_MEGATON_HAMMER) || HasExplosives || CanUse(RG_DINS_FIRE));}}), }, {}, { //Exits Entrance(RR_DEKU_TREE_BASEMENT_LOWER, {[]{return true;}}), @@ -153,15 +153,15 @@ void AreaTable_Init_DekuTree() { if (Dungeon::DekuTree.IsMQ()) { areaTable[RR_DEKU_TREE_MQ_LOBBY] = Area("Deku Tree MQ Lobby", "Deku Tree", RHT_DEKU_TREE, NO_DAY_NIGHT_CYCLE, { //Events - EventAccess(&DekuBabaSticks, {[]{return DekuBabaSticks || (IsAdult || KokiriSword || Boomerang);}}), - EventAccess(&DekuBabaNuts, {[]{return DekuBabaNuts || (IsAdult || KokiriSword || Slingshot || Sticks || HasExplosives || CanUse(RG_DINS_FIRE));}}), + EventAccess(&DekuBabaSticks, {[]{return DekuBabaSticks || (CanUse(RG_KOKIRI_SWORD) || CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD) || CanUse(RG_BOOMERANG));}}), + EventAccess(&DekuBabaNuts, {[]{return DekuBabaNuts || (CanJumpslash || CanUse(RG_FAIRY_SLINGSHOT) || CanUse(RG_FAIRY_BOW) || CanUse(RG_MEGATON_HAMMER) || HasExplosives || CanUse(RG_DINS_FIRE));}}), }, { //Locations LocationAccess(RC_DEKU_TREE_MQ_MAP_CHEST, {[]{return true;}}), - LocationAccess(RC_DEKU_TREE_MQ_SLINGSHOT_CHEST, {[]{return IsAdult || CanChildAttack;}}), + LocationAccess(RC_DEKU_TREE_MQ_SLINGSHOT_CHEST, {[]{return CanAdultAttack || CanChildAttack;}}), LocationAccess(RC_DEKU_TREE_MQ_SLINGSHOT_ROOM_BACK_CHEST, {[]{return HasFireSourceWithTorch || (IsAdult && CanUse(RG_FAIRY_BOW));}}), LocationAccess(RC_DEKU_TREE_MQ_BASEMENT_CHEST, {[]{return HasFireSourceWithTorch || (IsAdult && CanUse(RG_FAIRY_BOW));}}), - LocationAccess(RC_DEKU_TREE_MQ_GS_LOBBY, {[]{return IsAdult || CanChildAttack;}}), + LocationAccess(RC_DEKU_TREE_MQ_GS_LOBBY, {[]{return CanAdultAttack || CanChildAttack;}}), }, { //Exits Entrance(RR_DEKU_TREE_ENTRYWAY, {[]{return true;}}), @@ -201,7 +201,8 @@ void AreaTable_Init_DekuTree() { //Exits Entrance(RR_DEKU_TREE_MQ_BASEMENT_BACK_ROOM, {[]{return Here(RR_DEKU_TREE_MQ_BASEMENT_WATER_ROOM_BACK, []{return (IsChild && CanUse(RG_STICKS)) || CanUse(RG_DINS_FIRE) || Here(RR_DEKU_TREE_MQ_BASEMENT_WATER_ROOM_FRONT, []{return IsAdult && CanUse(RG_FIRE_ARROWS);});}) && - Here(RR_DEKU_TREE_MQ_BASEMENT_WATER_ROOM_BACK, []{return IsAdult || KokiriSword || CanUseProjectile || (Nuts && Sticks);});}}), + Here(RR_DEKU_TREE_MQ_BASEMENT_WATER_ROOM_BACK, []{return CanUse(RG_KOKIRI_SWORD) || CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD) || + CanUseProjectile || (Nuts && CanUse(RG_STICKS));});}}), Entrance(RR_DEKU_TREE_MQ_BASEMENT_WATER_ROOM_FRONT, {[]{return true;}}), }); diff --git a/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_dodongos_cavern.cpp b/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_dodongos_cavern.cpp index 4f704b08b..74881c406 100644 --- a/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_dodongos_cavern.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_dodongos_cavern.cpp @@ -54,17 +54,17 @@ void AreaTable_Init_DodongosCavern() { areaTable[RR_DODONGOS_CAVERN_SE_CORRIDOR] = Area("Dodongos Cavern SE Corridor", "Dodongos Cavern", RHT_DODONGOS_CAVERN, NO_DAY_NIGHT_CYCLE, {}, { //Locations - LocationAccess(RC_DODONGOS_CAVERN_GS_SCARECROW, {[]{return CanUse(RG_SCARECROW) || (IsAdult && CanUse(RG_LONGSHOT)) || (LogicDCScarecrowGS && (IsAdult || CanChildAttack));}}), + LocationAccess(RC_DODONGOS_CAVERN_GS_SCARECROW, {[]{return CanUse(RG_SCARECROW) || (IsAdult && CanUse(RG_LONGSHOT)) || (LogicDCScarecrowGS && (CanAdultAttack || CanChildAttack));}}), }, { //Exits Entrance(RR_DODONGOS_CAVERN_LOBBY, {[]{return true;}}), - Entrance(RR_DODONGOS_CAVERN_SE_ROOM, {[]{return Here(RR_DODONGOS_CAVERN_SE_CORRIDOR, []{return CanBlastOrSmash || IsAdult || CanChildAttack || (CanTakeDamage && CanShield);});}}), + Entrance(RR_DODONGOS_CAVERN_SE_ROOM, {[]{return Here(RR_DODONGOS_CAVERN_SE_CORRIDOR, []{return CanBlastOrSmash || CanAdultAttack || CanChildAttack || (CanTakeDamage && CanShield);});}}), Entrance(RR_DODONGOS_CAVERN_NEAR_LOWER_LIZALFOS, {[]{return true;}}), }); areaTable[RR_DODONGOS_CAVERN_SE_ROOM] = Area("Dodongos Cavern SE Room", "Dodongos Cavern", RHT_DODONGOS_CAVERN, NO_DAY_NIGHT_CYCLE, {}, { //Locations - LocationAccess(RC_DODONGOS_CAVERN_GS_SIDE_ROOM_NEAR_LOWER_LIZALFOS, {[]{return IsAdult || CanChildAttack;}}), + LocationAccess(RC_DODONGOS_CAVERN_GS_SIDE_ROOM_NEAR_LOWER_LIZALFOS, {[]{return CanAdultAttack || CanChildAttack;}}), }, { //Exits Entrance(RR_DODONGOS_CAVERN_SE_CORRIDOR, {[]{return true;}}), @@ -78,8 +78,10 @@ void AreaTable_Init_DodongosCavern() { areaTable[RR_DODONGOS_CAVERN_LOWER_LIZALFOS] = Area("Dodongos Cavern Lower Lizalfos", "Dodongos Cavern", RHT_DODONGOS_CAVERN, NO_DAY_NIGHT_CYCLE, {}, {}, { //Exits - Entrance(RR_DODONGOS_CAVERN_NEAR_LOWER_LIZALFOS, {[]{return Here(RR_DODONGOS_CAVERN_LOWER_LIZALFOS, []{return IsAdult || Slingshot || Sticks || KokiriSword || HasExplosives;});}}), - Entrance(RR_DODONGOS_CAVERN_DODONGO_ROOM, {[]{return Here(RR_DODONGOS_CAVERN_LOWER_LIZALFOS, []{return IsAdult || Slingshot || Sticks || KokiriSword || HasExplosives;});}}), + Entrance(RR_DODONGOS_CAVERN_NEAR_LOWER_LIZALFOS, {[]{return Here(RR_DODONGOS_CAVERN_LOWER_LIZALFOS, []{return CanUse(RG_FAIRY_BOW) || CanUse(RG_FAIRY_SLINGSHOT) || CanUse(RG_STICKS) || CanUse(RG_KOKIRI_SWORD) || + CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD) || CanUse(RG_MEGATON_HAMMER) || HasExplosives;});}}), + Entrance(RR_DODONGOS_CAVERN_DODONGO_ROOM, {[]{return Here(RR_DODONGOS_CAVERN_LOWER_LIZALFOS, []{return CanUse(RG_FAIRY_BOW) || CanUse(RG_FAIRY_SLINGSHOT) || CanUse(RG_STICKS) || CanUse(RG_KOKIRI_SWORD) || + CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD) || CanUse(RG_MEGATON_HAMMER) || HasExplosives;});}}), }); areaTable[RR_DODONGOS_CAVERN_DODONGO_ROOM] = Area("Dodongos Cavern Dodongo Room", "Dodongos Cavern", RHT_DODONGOS_CAVERN, NO_DAY_NIGHT_CYCLE, {}, {}, { @@ -119,7 +121,7 @@ void AreaTable_Init_DodongosCavern() { LocationAccess(RC_DODONGOS_CAVERN_COMPASS_CHEST, {[]{return true;}}), }, { //Exits - Entrance(RR_DODONGOS_CAVERN_STAIRS_LOWER, {[]{return IsAdult || HasExplosives || GoronBracelet;}}), + Entrance(RR_DODONGOS_CAVERN_STAIRS_LOWER, {[]{return CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD) || CanUse(RG_MEGATON_HAMMER) || HasExplosives || GoronBracelet;}}), }); areaTable[RR_DODONGOS_CAVERN_ARMOS_ROOM] = Area("Dodongos Cavern Armos Room", "Dodongos Cavern", RHT_DODONGOS_CAVERN, NO_DAY_NIGHT_CYCLE, {}, {}, { @@ -156,8 +158,10 @@ void AreaTable_Init_DodongosCavern() { areaTable[RR_DODONGOS_CAVERN_UPPER_LIZALFOS] = Area("Dodongos Cavern Upper Lizalfos", "Dodongos Cavern", RHT_DODONGOS_CAVERN, NO_DAY_NIGHT_CYCLE, {}, {}, { //Exits Entrance(RR_DODONGOS_CAVERN_LOWER_LIZALFOS, {[]{return true;}}), - Entrance(RR_DODONGOS_CAVERN_FIRST_SLINGSHOT_ROOM, {[]{return Here(RR_DODONGOS_CAVERN_LOWER_LIZALFOS, []{return IsAdult || Slingshot || Sticks || KokiriSword || HasExplosives;});}}), - Entrance(RR_DODONGOS_CAVERN_SECOND_SLINGSHOT_ROOM, {[]{return Here(RR_DODONGOS_CAVERN_LOWER_LIZALFOS, []{return IsAdult || Slingshot || Sticks || KokiriSword || HasExplosives;});}}), + Entrance(RR_DODONGOS_CAVERN_FIRST_SLINGSHOT_ROOM, {[]{return Here(RR_DODONGOS_CAVERN_LOWER_LIZALFOS, []{return CanUse(RG_FAIRY_BOW) || CanUse(RG_FAIRY_SLINGSHOT) || CanUse(RG_STICKS) || CanUse(RG_KOKIRI_SWORD) || + CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD) || CanUse(RG_MEGATON_HAMMER) || HasExplosives;});}}), + Entrance(RR_DODONGOS_CAVERN_SECOND_SLINGSHOT_ROOM, {[]{return Here(RR_DODONGOS_CAVERN_LOWER_LIZALFOS, []{return CanUse(RG_FAIRY_BOW) || CanUse(RG_FAIRY_SLINGSHOT) || CanUse(RG_STICKS) || CanUse(RG_KOKIRI_SWORD) || + CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD) || CanUse(RG_MEGATON_HAMMER) || HasExplosives;});}}), }); areaTable[RR_DODONGOS_CAVERN_SECOND_SLINGSHOT_ROOM] = Area("Dodongos Cavern Second Slingshot Room", "Dodongos Cavern", RHT_DODONGOS_CAVERN, NO_DAY_NIGHT_CYCLE, {}, {}, { @@ -197,7 +201,7 @@ void AreaTable_Init_DodongosCavern() { areaTable[RR_DODONGOS_CAVERN_BACK_ROOM] = Area("Dodongos Cavern Back Room", "Dodongos Cavern", RHT_DODONGOS_CAVERN, NO_DAY_NIGHT_CYCLE, {}, { //Locations - LocationAccess(RC_DODONGOS_CAVERN_GS_BACK_ROOM, {[]{return IsAdult || CanChildAttack;}}), + LocationAccess(RC_DODONGOS_CAVERN_GS_BACK_ROOM, {[]{return CanAdultAttack || CanChildAttack;}}), }, { //Exits Entrance(RR_DODONGOS_CAVERN_BOSS_AREA, {[]{return true;}}), @@ -221,10 +225,10 @@ void AreaTable_Init_DodongosCavern() { }, { //Locations LocationAccess(RC_DODONGOS_CAVERN_MQ_MAP_CHEST, {[]{return true;}}), - LocationAccess(RC_DODONGOS_CAVERN_MQ_COMPASS_CHEST, {[]{return IsAdult || CanChildAttack || Nuts;}}), + LocationAccess(RC_DODONGOS_CAVERN_MQ_COMPASS_CHEST, {[]{return CanAdultAttack || CanChildAttack || Nuts;}}), LocationAccess(RC_DODONGOS_CAVERN_MQ_LARVAE_ROOM_CHEST, {[]{return (IsChild && CanUse(RG_STICKS)) || HasFireSource;}}), LocationAccess(RC_DODONGOS_CAVERN_MQ_TORCH_PUZZLE_ROOM_CHEST, {[]{return CanBlastOrSmash || (IsChild && CanUse(RG_STICKS)) || CanUse(RG_DINS_FIRE) || (IsAdult && (LogicDCJump || HoverBoots || Hookshot));}}), - LocationAccess(RC_DODONGOS_CAVERN_MQ_GS_SONG_OF_TIME_BLOCK_ROOM, {[]{return CanPlay(SongOfTime) && (CanChildAttack || IsAdult);}}), + LocationAccess(RC_DODONGOS_CAVERN_MQ_GS_SONG_OF_TIME_BLOCK_ROOM, {[]{return CanPlay(SongOfTime) && (CanChildAttack || CanAdultAttack);}}), LocationAccess(RC_DODONGOS_CAVERN_MQ_GS_LARVAE_ROOM, {[]{return (IsChild && CanUse(RG_STICKS)) || HasFireSource;}}), LocationAccess(RC_DODONGOS_CAVERN_MQ_GS_LIZALFOS_ROOM, {[]{return CanBlastOrSmash;}}), LocationAccess(RC_DODONGOS_CAVERN_MQ_DEKU_SCRUB_LOBBY_REAR, {[]{return CanStunDeku;}}), diff --git a/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_fire_temple.cpp b/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_fire_temple.cpp index f08d75e14..6c8f1c17c 100644 --- a/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_fire_temple.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_fire_temple.cpp @@ -46,12 +46,12 @@ void AreaTable_Init_FireTemple() { areaTable[RR_FIRE_TEMPLE_LOOP_ENEMIES] = Area("Fire Temple Loop Enemies", "Fire Temple", RHT_FIRE_TEMPLE, NO_DAY_NIGHT_CYCLE, {}, {}, { //Exits Entrance(RR_FIRE_TEMPLE_FIRST_ROOM, {[]{return SmallKeys(RR_FIRE_TEMPLE, 8) || !IsKeysanity;}}), - Entrance(RR_FIRE_TEMPLE_LOOP_TILES, {[]{return Here(RR_FIRE_TEMPLE_LOOP_ENEMIES, []{return IsAdult || KokiriSword;});}}), + Entrance(RR_FIRE_TEMPLE_LOOP_TILES, {[]{return Here(RR_FIRE_TEMPLE_LOOP_ENEMIES, []{return CanUse(RG_KOKIRI_SWORD) || CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD) || CanUse(RG_MEGATON_HAMMER);});}}), }); areaTable[RR_FIRE_TEMPLE_LOOP_TILES] = Area("Fire Temple Loop Tiles", "Fire Temple", RHT_FIRE_TEMPLE, NO_DAY_NIGHT_CYCLE, {}, { //Locations - LocationAccess(RC_FIRE_TEMPLE_GS_BOSS_KEY_LOOP, {[]{return IsAdult || CanChildAttack;}}), + LocationAccess(RC_FIRE_TEMPLE_GS_BOSS_KEY_LOOP, {[]{return CanAdultAttack || CanChildAttack;}}), }, { //Exits Entrance(RR_FIRE_TEMPLE_LOOP_ENEMIES, {[]{return true;}}), @@ -64,7 +64,8 @@ void AreaTable_Init_FireTemple() { }, { //Exits Entrance(RR_FIRE_TEMPLE_LOOP_TILES, {[]{return true;}}), - Entrance(RR_FIRE_TEMPLE_LOOP_HAMMER_SWITCH, {[]{return Here(RR_FIRE_TEMPLE_LOOP_FLARE_DANCER, []{return (HasExplosives || CanUse(RG_MEGATON_HAMMER) || CanUse(RG_HOOKSHOT)) && (IsAdult || KokiriSword || Slingshot || Boomerang);});}}), + Entrance(RR_FIRE_TEMPLE_LOOP_HAMMER_SWITCH, {[]{return Here(RR_FIRE_TEMPLE_LOOP_FLARE_DANCER, []{return CanUse(RG_MEGATON_HAMMER) || CanUse(RG_HOOKSHOT) || (HasExplosives && (CanUse(RG_KOKIRI_SWORD) || CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD) || + CanUse(RG_FAIRY_SLINGSHOT) || CanUse(RG_FAIRY_BOW) || CanUse(RG_BOOMERANG)));});}}), }); areaTable[RR_FIRE_TEMPLE_LOOP_HAMMER_SWITCH] = Area("Fire Temple Loop Hammer Switch", "Fire Temple", RHT_FIRE_TEMPLE, NO_DAY_NIGHT_CYCLE, { @@ -110,7 +111,7 @@ void AreaTable_Init_FireTemple() { areaTable[RR_FIRE_TEMPLE_BIG_LAVA_ROOM_NORTH_TILES] = Area("Fire Temple Big Lava Room North Tiles", "Fire Temple", RHT_FIRE_TEMPLE, NO_DAY_NIGHT_CYCLE, {}, { //Locations - LocationAccess(RC_FIRE_TEMPLE_GS_SONG_OF_TIME_ROOM, {[]{return IsAdult;}}), + LocationAccess(RC_FIRE_TEMPLE_GS_SONG_OF_TIME_ROOM, {[]{return CanAdultAttack || HookshotOrBoomerang;}}), }, { //Exits Entrance(RR_FIRE_TEMPLE_BIG_LAVA_ROOM, {[]{return true;}}), @@ -137,7 +138,7 @@ void AreaTable_Init_FireTemple() { //Exits Entrance(RR_FIRE_TEMPLE_FIRE_PILLAR_ROOM, {[]{return SmallKeys(RR_FIRE_TEMPLE, 4);}}), Entrance(RR_FIRE_TEMPLE_SHORTCUT_CLIMB, {[]{return Here(RR_FIRE_TEMPLE_SHORTCUT_CLIMB, []{return true;});}}), - Entrance(RR_FIRE_TEMPLE_BOULDER_MAZE_LOWER, {[]{return (GoronBracelet || (IsAdult && LogicFireStrength)) && (HasExplosives || (IsAdult && (CanUse(RG_FAIRY_BOW) || CanUse(RG_HOOKSHOT) || CanUse(RG_FAIRY_SLINGSHOT))));}}), + Entrance(RR_FIRE_TEMPLE_BOULDER_MAZE_LOWER, {[]{return IsAdult && (GoronBracelet || LogicFireStrength) && (HasExplosives || CanUse(RG_FAIRY_BOW) || CanUse(RG_HOOKSHOT) || CanUse(RG_FAIRY_SLINGSHOT));}}), }); areaTable[RR_FIRE_TEMPLE_SHORTCUT_CLIMB] = Area("Fire Temple Shortcut Climb", "Fire Temple", RHT_FIRE_TEMPLE, NO_DAY_NIGHT_CYCLE, {}, {}, { @@ -149,7 +150,7 @@ void AreaTable_Init_FireTemple() { areaTable[RR_FIRE_TEMPLE_BOULDER_MAZE_LOWER] = Area("Fire Temple Boulder Maze Lower", "Fire Temple", RHT_FIRE_TEMPLE, NO_DAY_NIGHT_CYCLE, {}, { //Locations LocationAccess(RC_FIRE_TEMPLE_BOULDER_MAZE_LOWER_CHEST, {[]{return true;}}), - LocationAccess(RC_FIRE_TEMPLE_GS_BOULDER_MAZE, {[]{return HasExplosives && (IsAdult || Boomerang || CanUse(RG_HOOKSHOT));}}), + LocationAccess(RC_FIRE_TEMPLE_GS_BOULDER_MAZE, {[]{return HasExplosives && (IsAdult || HookshotOrBoomerang);}}), }, { //Exits Entrance(RR_FIRE_TEMPLE_SHORTCUT_ROOM, {[]{return true;}}), @@ -203,7 +204,7 @@ void AreaTable_Init_FireTemple() { areaTable[RR_FIRE_TEMPLE_SCARECROW_ROOM] = Area("Fire Temple Scarecrow Room", "Fire Temple", RHT_FIRE_TEMPLE, NO_DAY_NIGHT_CYCLE, {}, { //Locations - LocationAccess(RC_FIRE_TEMPLE_GS_SCARECROW_CLIMB, {[]{return IsAdult || CanChildAttack;}}), + LocationAccess(RC_FIRE_TEMPLE_GS_SCARECROW_CLIMB, {[]{return CanJumpslash || CanUse(RG_FAIRY_SLINGSHOT) || CanUse(RG_BOOMERANG) || HasExplosives || CanUse(RG_FAIRY_BOW) || CanUse(RG_HOOKSHOT) || CanUse(RG_DINS_FIRE);}}), }, { //Exits Entrance(RR_FIRE_TEMPLE_BOULDER_MAZE_UPPER, {[]{return true;}}), @@ -276,8 +277,10 @@ void AreaTable_Init_FireTemple() { areaTable[RR_FIRE_TEMPLE_UPPER_FLARE_DANCER] = Area("Fire Temple Upper Flare Dancer", "Fire Temple", RHT_FIRE_TEMPLE, NO_DAY_NIGHT_CYCLE, {}, {}, { //Exits - Entrance(RR_FIRE_TEMPLE_LATE_FIRE_MAZE, {[]{return Here(RR_FIRE_TEMPLE_UPPER_FLARE_DANCER, []{return (HasExplosives || CanUse(RG_MEGATON_HAMMER) || CanUse(RG_HOOKSHOT)) && (IsAdult || KokiriSword || Slingshot || Boomerang);});}}), - Entrance(RR_FIRE_TEMPLE_WEST_CLIMB, {[]{return Here(RR_FIRE_TEMPLE_UPPER_FLARE_DANCER, []{return (HasExplosives || CanUse(RG_MEGATON_HAMMER) || CanUse(RG_HOOKSHOT)) && (IsAdult || KokiriSword || Slingshot || Boomerang);});}}), + Entrance(RR_FIRE_TEMPLE_LATE_FIRE_MAZE, {[]{return Here(RR_FIRE_TEMPLE_UPPER_FLARE_DANCER, []{return CanUse(RG_MEGATON_HAMMER) || CanUse(RG_HOOKSHOT) || (HasExplosives && ((CanUse(RG_KOKIRI_SWORD)) || CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD) || + CanUse(RG_FAIRY_SLINGSHOT) || CanUse(RG_FAIRY_BOW) || CanUse(RG_BOOMERANG)));});}}), + Entrance(RR_FIRE_TEMPLE_WEST_CLIMB, {[]{return Here(RR_FIRE_TEMPLE_UPPER_FLARE_DANCER, []{return CanUse(RG_MEGATON_HAMMER) || CanUse(RG_HOOKSHOT) || (HasExplosives && ((CanUse(RG_KOKIRI_SWORD)) || CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD) || + CanUse(RG_FAIRY_SLINGSHOT) || CanUse(RG_BOOMERANG)));});}}), }); areaTable[RR_FIRE_TEMPLE_WEST_CLIMB] = Area("Fire Temple West Climb", "Fire Temple", RHT_FIRE_TEMPLE, NO_DAY_NIGHT_CYCLE, {}, {}, { @@ -314,14 +317,14 @@ void AreaTable_Init_FireTemple() { if (Dungeon::FireTemple.IsMQ()) { areaTable[RR_FIRE_TEMPLE_MQ_LOWER] = Area("Fire Temple MQ Lower", "Fire Temple", RHT_FIRE_TEMPLE, NO_DAY_NIGHT_CYCLE, {}, { //Locations - LocationAccess(RC_FIRE_TEMPLE_MQ_MAP_ROOM_SIDE_CHEST, {[]{return IsAdult || KokiriSword || Sticks || Slingshot || Bombs || CanUse(RG_DINS_FIRE);}}), + LocationAccess(RC_FIRE_TEMPLE_MQ_MAP_ROOM_SIDE_CHEST, {[]{return CanJumpslash || CanUse(RG_FAIRY_SLINGSHOT) || CanUse(RG_FAIRY_BOW) || Bombs || CanUse(RG_DINS_FIRE);}}), LocationAccess(RC_FIRE_TEMPLE_MQ_NEAR_BOSS_CHEST, {[]{return IsAdult && (LogicFewerTunicRequirements || CanUse(RG_GORON_TUNIC)) && (((CanUse(RG_HOVER_BOOTS) || (LogicFireMQNearBoss && CanUse(RG_FAIRY_BOW))) && HasFireSource) || (CanUse(RG_HOOKSHOT) && CanUse(RG_FIRE_ARROWS) || (CanUse(RG_DINS_FIRE) && ((DamageMultiplier.IsNot(DAMAGEMULTIPLIER_OHKO) && DamageMultiplier.IsNot(DAMAGEMULTIPLIER_QUADRUPLE) && DamageMultiplier.IsNot(DAMAGEMULTIPLIER_OCTUPLE) && DamageMultiplier.IsNot(DAMAGEMULTIPLIER_SEXDECUPLE)) || CanUse(RG_GORON_TUNIC) || CanUse(RG_FAIRY_BOW) || CanUse(RG_LONGSHOT)))));}}), //Trick: IsAdult && (LogicFewerTunicRequirements || CanUse(RG_GORON_TUNIC)) && (((CanUse(RG_HOVER_BOOTS) || (LogicFireMQNearBoss && CanUse(RG_FAIRY_BOW))) && HasFireSource) || (CanUse(RG_HOOKSHOT) && CanUse(RG_FIRE_ARROWS) || (CanUse(RG_DINS_FIRE) && ((DamageMultiplier.IsNot(DAMAGEMULTIPLIER_OHKO) && DamageMultiplier.IsNot(DAMAGEMULTIPLIER_QUADRUPLE) && DamageMultiplier.IsNot(DAMAGEMULTIPLIER_OCTUPLE) && DamageMultiplier.IsNot(DAMAGEMULTIPLIER_SEXDECUPLE)) || CanUse(RG_GORON_TUNIC) || CanUse(RG_FAIRY_BOW) || CanUse(RG_LONGSHOT))))) }, { //Exits Entrance(RR_FIRE_TEMPLE_ENTRYWAY, {[]{return true;}}), Entrance(RR_FIRE_TEMPLE_BOSS_ENTRYWAY, {[]{return IsAdult && CanUse(RG_GORON_TUNIC) && CanUse(RG_MEGATON_HAMMER) && BossKeyFireTemple && ((HasFireSource && (LogicFireBossDoorJump || HoverBoots)) || HasAccessTo(RR_FIRE_TEMPLE_MQ_UPPER));}}), - Entrance(RR_FIRE_TEMPLE_MQ_LOWER_LOCKED_DOOR, {[]{return SmallKeys(RR_FIRE_TEMPLE, 5) && (IsAdult || KokiriSword);}}), + Entrance(RR_FIRE_TEMPLE_MQ_LOWER_LOCKED_DOOR, {[]{return SmallKeys(RR_FIRE_TEMPLE, 5) && (CanUse(RG_KOKIRI_SWORD) || CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD));}}), Entrance(RR_FIRE_TEMPLE_MQ_BIG_LAVA_ROOM, {[]{return IsAdult && FireTimer >= 24 && CanUse(RG_MEGATON_HAMMER);}}), }); @@ -330,7 +333,7 @@ void AreaTable_Init_FireTemple() { EventAccess(&FairyPot, {[]{return true;}}), }, { //Locations - LocationAccess(RC_FIRE_TEMPLE_MQ_MEGATON_HAMMER_CHEST, {[]{return IsAdult && (HasExplosives || Hammer || Hookshot);}}), + LocationAccess(RC_FIRE_TEMPLE_MQ_MEGATON_HAMMER_CHEST, {[]{return IsAdult && (CanUse(RG_MEGATON_HAMMER) || CanUse(RG_HOOKSHOT) || (HasExplosives && (CanUse(RG_MASTER_SWORD) || CanUse(RG_KOKIRI_SWORD) || CanUse(RG_BIGGORON_SWORD) || CanUse(RG_FAIRY_BOW) || CanUse(RG_FAIRY_SLINGSHOT) || CanUse(RG_BOOMERANG))));}}), LocationAccess(RC_FIRE_TEMPLE_MQ_MAP_CHEST, {[]{return IsAdult && CanUse(RG_MEGATON_HAMMER);}}), }, {}); @@ -353,7 +356,7 @@ void AreaTable_Init_FireTemple() { areaTable[RR_FIRE_TEMPLE_MQ_LOWER_MAZE] = Area("Fire Temple MQ Lower Maze", "Fire Temple", RHT_FIRE_TEMPLE, NO_DAY_NIGHT_CYCLE, {}, { //Locations - LocationAccess(RC_FIRE_TEMPLE_MQ_LIZALFOS_MAZE_LOWER_CHEST, {[]{return true;}}), + LocationAccess(RC_FIRE_TEMPLE_MQ_LIZALFOS_MAZE_LOWER_CHEST, {[]{return CanUse(RG_MASTER_SWORD) || CanUse(RG_KOKIRI_SWORD) || CanUse(RG_BIGGORON_SWORD);}}), LocationAccess(RC_FIRE_TEMPLE_MQ_LIZALFOS_MAZE_SIDE_ROOM_CHEST, {[]{return HasExplosives && (LogicFireMQMazeSideRoom || HasAccessTo(RR_FIRE_TEMPLE_MQ_UPPER_MAZE));}}), //Trick: HasExplosives && (LogicFireMQMazeSideRoom || FIRE_TEMPLE_MQ_UPPER_MAZE.Adult()) }, { @@ -378,7 +381,7 @@ void AreaTable_Init_FireTemple() { areaTable[RR_FIRE_TEMPLE_MQ_UPPER] = Area("Fire Temple MQ Upper", "Fire Temple", RHT_FIRE_TEMPLE, NO_DAY_NIGHT_CYCLE, {}, { //Locations - LocationAccess(RC_FIRE_TEMPLE_MQ_FREESTANDING_KEY, {[]{return (IsAdult && CanUse(RG_HOOKSHOT)) || LogicFireMQFlameMaze;}}), + LocationAccess(RC_FIRE_TEMPLE_MQ_FREESTANDING_KEY, {[]{return ((CanUse(RG_KOKIRI_SWORD) || CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD) || CanUse(RG_FAIRY_SLINGSHOT) || CanUse(RG_BOOMERANG)) && CanUse(RG_HOOKSHOT)) || LogicFireMQFlameMaze;}}), //Trick: (IsAdult && CanUse(RG_HOOKSHOT)) || LogicFireMQFlameMaze LocationAccess(RC_FIRE_TEMPLE_MQ_CHEST_ON_FIRE, {[]{return ((IsAdult && CanUse(RG_HOOKSHOT)) || LogicFireMQFlameMaze) && SmallKeys(RR_FIRE_TEMPLE, 4);}}), //Trick: ((IsAdult && CanUse(RG_HOOKSHOT)) || LogicFireMQFlameMaze) && SmallKeys(RR_FIRE_TEMPLE, 4) diff --git a/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_forest_temple.cpp b/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_forest_temple.cpp index 0558b710c..240c35e67 100644 --- a/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_forest_temple.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_forest_temple.cpp @@ -34,7 +34,7 @@ void AreaTable_Init_ForestTemple() { areaTable[RR_FOREST_TEMPLE_SOUTH_CORRIDOR] = Area("Forest Temple South Corridor", "Forest Temple", RHT_FOREST_TEMPLE, NO_DAY_NIGHT_CYCLE, {}, {}, { //Exits Entrance(RR_FOREST_TEMPLE_FIRST_ROOM, {[]{return true;}}), - Entrance(RR_FOREST_TEMPLE_LOBBY, {[]{return IsAdult || CanChildAttack || Nuts;}}), + Entrance(RR_FOREST_TEMPLE_LOBBY, {[]{return CanAdultAttack || CanChildAttack || Nuts;}}), }); areaTable[RR_FOREST_TEMPLE_LOBBY] = Area("Forest Temple Lobby", "Forest Temple", RHT_FOREST_TEMPLE, NO_DAY_NIGHT_CYCLE, { @@ -66,7 +66,7 @@ void AreaTable_Init_ForestTemple() { EventAccess(&FairyPot, {[]{return true;}}), }, { //Locations - LocationAccess(RC_FOREST_TEMPLE_FIRST_STALFOS_CHEST, {[]{return IsAdult || KokiriSword;}}), + LocationAccess(RC_FOREST_TEMPLE_FIRST_STALFOS_CHEST, {[]{return CanUse(RG_KOKIRI_SWORD) || CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD) || CanUse(RG_MEGATON_HAMMER);}}), }, { //Exits Entrance(RR_FOREST_TEMPLE_NORTH_CORRIDOR, {[]{return true;}}), @@ -74,8 +74,8 @@ void AreaTable_Init_ForestTemple() { areaTable[RR_FOREST_TEMPLE_NW_OUTDOORS_LOWER] = Area("Forest Temple NW Outdoors Lower", "Forest Temple", RHT_FOREST_TEMPLE, NO_DAY_NIGHT_CYCLE, { //Events - EventAccess(&DekuBabaSticks, {[]{return DekuBabaSticks || (IsAdult || KokiriSword || Boomerang);}}), - EventAccess(&DekuBabaNuts, {[]{return DekuBabaNuts || (IsAdult || KokiriSword || Slingshot || Sticks || HasExplosives || CanUse(RG_DINS_FIRE));}}), + EventAccess(&DekuBabaSticks, {[]{return DekuBabaSticks || (CanUse(RG_KOKIRI_SWORD) || CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD) || CanUse(RG_BOOMERANG));}}), + EventAccess(&DekuBabaNuts, {[]{return DekuBabaNuts || (CanJumpslash || CanUse(RG_FAIRY_SLINGSHOT) || CanUse(RG_FAIRY_BOW) || CanUse(RG_MEGATON_HAMMER) || HasExplosives || CanUse(RG_DINS_FIRE));}}), }, { //Locations LocationAccess(RC_FOREST_TEMPLE_GS_LEVEL_ISLAND_COURTYARD, {[]{return CanUse(RG_LONGSHOT) || Here(RR_FOREST_TEMPLE_NW_OUTDOORS_UPPER, []{return HookshotOrBoomerang;});}}), @@ -90,8 +90,8 @@ void AreaTable_Init_ForestTemple() { areaTable[RR_FOREST_TEMPLE_NW_OUTDOORS_UPPER] = Area("Forest Temple NW Outdoors Upper", "Forest Temple", RHT_FOREST_TEMPLE, NO_DAY_NIGHT_CYCLE, { //Events - EventAccess(&DekuBabaSticks, {[]{return DekuBabaSticks || (IsAdult || KokiriSword || Boomerang);}}), - EventAccess(&DekuBabaNuts, {[]{return DekuBabaNuts || (IsAdult || KokiriSword || Slingshot || Sticks || HasExplosives || CanUse(RG_DINS_FIRE));}}), + EventAccess(&DekuBabaSticks, {[]{return DekuBabaSticks || (CanUse(RG_KOKIRI_SWORD) || CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD) || CanUse(RG_BOOMERANG));}}), + EventAccess(&DekuBabaNuts, {[]{return DekuBabaNuts || (CanJumpslash || CanUse(RG_FAIRY_SLINGSHOT) || CanUse(RG_FAIRY_BOW) || CanUse(RG_MEGATON_HAMMER) || HasExplosives || CanUse(RG_DINS_FIRE));}}), }, {}, { //Exits Entrance(RR_FOREST_TEMPLE_NW_OUTDOORS_LOWER, {[]{return true;}}), @@ -102,8 +102,8 @@ void AreaTable_Init_ForestTemple() { areaTable[RR_FOREST_TEMPLE_NE_OUTDOORS_LOWER] = Area("Forest Temple NE Outdoors Lower", "Forest Temple", RHT_FOREST_TEMPLE, NO_DAY_NIGHT_CYCLE, { //Events - EventAccess(&DekuBabaSticks, {[]{return DekuBabaSticks || (IsAdult || KokiriSword || Boomerang);}}), - EventAccess(&DekuBabaNuts, {[]{return DekuBabaNuts || (IsAdult || KokiriSword || Slingshot || Sticks || HasExplosives || CanUse(RG_DINS_FIRE));}}), + EventAccess(&DekuBabaSticks, {[]{return DekuBabaSticks || (CanUse(RG_KOKIRI_SWORD) || CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD) || CanUse(RG_BOOMERANG));}}), + EventAccess(&DekuBabaNuts, {[]{return DekuBabaNuts || (CanJumpslash || CanUse(RG_FAIRY_SLINGSHOT) || CanUse(RG_FAIRY_BOW) || CanUse(RG_MEGATON_HAMMER) || HasExplosives || CanUse(RG_DINS_FIRE));}}), }, { //Locations LocationAccess(RC_FOREST_TEMPLE_RAISED_ISLAND_COURTYARD_CHEST, {[]{return CanUse(RG_HOOKSHOT) || HasAccessTo(RR_FOREST_TEMPLE_FALLING_ROOM) || (HasAccessTo(RR_FOREST_TEMPLE_NE_OUTDOORS_UPPER) && IsAdult && LogicForestOutdoorsLedge && HoverBoots);}}), @@ -118,22 +118,22 @@ void AreaTable_Init_ForestTemple() { areaTable[RR_FOREST_TEMPLE_NE_OUTDOORS_UPPER] = Area("Forest Temple NE Outdoors Upper", "Forest Temple", RHT_FOREST_TEMPLE, NO_DAY_NIGHT_CYCLE, { //Events - EventAccess(&DekuBabaSticks, {[]{return DekuBabaSticks || (IsAdult || KokiriSword || Boomerang);}}), - EventAccess(&DekuBabaNuts, {[]{return DekuBabaNuts || (IsAdult || KokiriSword || Slingshot || Sticks || HasExplosives || CanUse(RG_DINS_FIRE));}}), + EventAccess(&DekuBabaSticks, {[]{return DekuBabaSticks || (CanUse(RG_KOKIRI_SWORD) || CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD) || CanUse(RG_BOOMERANG));}}), + EventAccess(&DekuBabaNuts, {[]{return DekuBabaNuts || (CanJumpslash || CanUse(RG_FAIRY_SLINGSHOT) || CanUse(RG_FAIRY_BOW) || CanUse(RG_MEGATON_HAMMER) || HasExplosives || CanUse(RG_DINS_FIRE));}}), }, {}, { //Exits Entrance(RR_FOREST_TEMPLE_NE_OUTDOORS_LOWER, {[]{return true;}}), Entrance(RR_FOREST_TEMPLE_MAP_ROOM, {[]{return true;}}), - Entrance(RR_FOREST_TEMPLE_FALLING_ROOM, {[]{return LogicForestDoorFrame && CanUse(RG_HOVER_BOOTS) && CanUse(RG_SCARECROW);}}), + Entrance(RR_FOREST_TEMPLE_FALLING_ROOM, {[]{return LogicForestDoorFrame && CanJumpslash && CanUse(RG_HOVER_BOOTS) && CanUse(RG_SCARECROW);}}), }); areaTable[RR_FOREST_TEMPLE_MAP_ROOM] = Area("Forest Temple Map Room", "Forest Temple", RHT_FOREST_TEMPLE, NO_DAY_NIGHT_CYCLE, {}, { //Locations - LocationAccess(RC_FOREST_TEMPLE_MAP_CHEST, {[]{return Here(RR_FOREST_TEMPLE_MAP_ROOM, []{return HasExplosives || CanUse(RG_MEGATON_HAMMER) || CanUse(RG_FAIRY_BOW) || ((IsAdult || Sticks || KokiriSword || Slingshot) && (Nuts || HookshotOrBoomerang || CanShield));});}}), + LocationAccess(RC_FOREST_TEMPLE_MAP_CHEST, {[]{return Here(RR_FOREST_TEMPLE_MAP_ROOM, []{return HasExplosives || CanUse(RG_MEGATON_HAMMER) || CanUse(RG_FAIRY_BOW) || ((CanJumpslash || CanUse(RG_FAIRY_SLINGSHOT)) && (Nuts || HookshotOrBoomerang || CanShield));});}}), }, { //Exits - Entrance(RR_FOREST_TEMPLE_NW_OUTDOORS_LOWER, {[]{return Here(RR_FOREST_TEMPLE_MAP_ROOM, []{return HasExplosives || CanUse(RG_MEGATON_HAMMER) || CanUse(RG_FAIRY_BOW) || ((IsAdult || Sticks || KokiriSword || Slingshot) && (Nuts || HookshotOrBoomerang || CanShield));});}}), - Entrance(RR_FOREST_TEMPLE_NE_OUTDOORS_UPPER, {[]{return Here(RR_FOREST_TEMPLE_MAP_ROOM, []{return HasExplosives || CanUse(RG_MEGATON_HAMMER) || CanUse(RG_FAIRY_BOW) || ((IsAdult || Sticks || KokiriSword || Slingshot) && (Nuts || HookshotOrBoomerang || CanShield));});}}), + Entrance(RR_FOREST_TEMPLE_NW_OUTDOORS_LOWER, {[]{return Here(RR_FOREST_TEMPLE_MAP_ROOM, []{return HasExplosives || CanUse(RG_MEGATON_HAMMER) || CanUse(RG_FAIRY_BOW) || ((CanJumpslash || CanUse(RG_FAIRY_SLINGSHOT)) && (Nuts || HookshotOrBoomerang || CanShield));});}}), + Entrance(RR_FOREST_TEMPLE_NE_OUTDOORS_UPPER, {[]{return Here(RR_FOREST_TEMPLE_MAP_ROOM, []{return HasExplosives || CanUse(RG_MEGATON_HAMMER) || CanUse(RG_FAIRY_BOW) || ((CanJumpslash || CanUse(RG_FAIRY_SLINGSHOT)) && (Nuts || HookshotOrBoomerang || CanShield));});}}), }); areaTable[RR_FOREST_TEMPLE_SEWER] = Area("Forest Temple Sewer", "Forest Temple", RHT_FOREST_TEMPLE, NO_DAY_NIGHT_CYCLE, {}, { @@ -147,12 +147,12 @@ void AreaTable_Init_ForestTemple() { areaTable[RR_FOREST_TEMPLE_BELOW_BOSS_KEY_CHEST] = Area("Forest Temple Below Boss Key Chest", "Forest Temple", RHT_FOREST_TEMPLE, NO_DAY_NIGHT_CYCLE, {}, {}, { //Exits - Entrance(RR_FOREST_TEMPLE_NW_OUTDOORS_UPPER, {[]{return Here(RR_FOREST_TEMPLE_BELOW_BOSS_KEY_CHEST, []{return HasExplosives || CanUse(RG_MEGATON_HAMMER) || CanUse(RG_FAIRY_BOW) || ((IsAdult || Sticks || KokiriSword || Slingshot) && (Nuts || HookshotOrBoomerang || CanShield));});}}), + Entrance(RR_FOREST_TEMPLE_NW_OUTDOORS_UPPER, {[]{return Here(RR_FOREST_TEMPLE_BELOW_BOSS_KEY_CHEST, []{return HasExplosives || CanUse(RG_MEGATON_HAMMER) || CanUse(RG_FAIRY_BOW) || ((CanJumpslash || CanUse(RG_FAIRY_SLINGSHOT)) && (Nuts || HookshotOrBoomerang || CanShield));});}}), }); areaTable[RR_FOREST_TEMPLE_FLOORMASTER_ROOM] = Area("Forest Temple Floormaster Room", "Forest Temple", RHT_FOREST_TEMPLE, NO_DAY_NIGHT_CYCLE, {}, { //Locations - LocationAccess(RC_FOREST_TEMPLE_FLOORMASTER_CHEST, {[]{return IsAdult || CanChildDamage;}}), + LocationAccess(RC_FOREST_TEMPLE_FLOORMASTER_CHEST, {[]{return CanAdultDamage || CanChildDamage;}}), }, { //Exits Entrance(RR_FOREST_TEMPLE_NW_OUTDOORS_UPPER, {[]{return true;}}), @@ -161,7 +161,7 @@ void AreaTable_Init_ForestTemple() { areaTable[RR_FOREST_TEMPLE_WEST_CORRIDOR] = Area("Forest Temple West Corridor", "Forest Temple", RHT_FOREST_TEMPLE, NO_DAY_NIGHT_CYCLE, {}, {}, { //Exits Entrance(RR_FOREST_TEMPLE_LOBBY, {[]{return SmallKeys(RR_FOREST_TEMPLE, 1, 5);}}), - Entrance(RR_FOREST_TEMPLE_BLOCK_PUSH_ROOM, {[]{return IsAdult || CanChildAttack || Nuts;}}), + Entrance(RR_FOREST_TEMPLE_BLOCK_PUSH_ROOM, {[]{return CanAdultAttack || CanChildAttack || Nuts;}}), }); areaTable[RR_FOREST_TEMPLE_BLOCK_PUSH_ROOM] = Area("Forest Temple Block Push Room", "Forest Temple", RHT_FOREST_TEMPLE, NO_DAY_NIGHT_CYCLE, {}, { @@ -172,7 +172,7 @@ void AreaTable_Init_ForestTemple() { Entrance(RR_FOREST_TEMPLE_WEST_CORRIDOR, {[]{return true;}}), Entrance(RR_FOREST_TEMPLE_NW_OUTDOORS_UPPER, {[]{return CanUse(RG_HOVER_BOOTS) || (LogicForestOutsideBackdoor && CanJumpslash && GoronBracelet);}}), Entrance(RR_FOREST_TEMPLE_NW_CORRIDOR_TWISTED, {[]{return IsAdult && GoronBracelet && SmallKeys(RR_FOREST_TEMPLE, 2);}}), - Entrance(RR_FOREST_TEMPLE_NW_CORRIDOR_STRAIGHTENED, {[]{return CanUse(RG_FAIRY_BOW) && GoronBracelet && SmallKeys(RR_FOREST_TEMPLE, 2);}}), + Entrance(RR_FOREST_TEMPLE_NW_CORRIDOR_STRAIGHTENED, {[]{return (CanUse(RG_FAIRY_BOW) || CanUse(RG_FAIRY_SLINGSHOT)) && GoronBracelet && SmallKeys(RR_FOREST_TEMPLE, 2);}}), }); areaTable[RR_FOREST_TEMPLE_NW_CORRIDOR_TWISTED] = Area("Forest Temple NW Corridor Twisted", "Forest Temple", RHT_FOREST_TEMPLE, NO_DAY_NIGHT_CYCLE, {}, {}, { @@ -204,11 +204,11 @@ void AreaTable_Init_ForestTemple() { areaTable[RR_FOREST_TEMPLE_UPPER_STALFOS] = Area("Forest Temple Upper Stalfos", "Forest Temple", RHT_FOREST_TEMPLE, NO_DAY_NIGHT_CYCLE, {}, { //Locations - LocationAccess(RC_FOREST_TEMPLE_BOW_CHEST, {[]{return IsAdult || KokiriSword;}}), + LocationAccess(RC_FOREST_TEMPLE_BOW_CHEST, {[]{return CanUse(RG_KOKIRI_SWORD) || CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD) || CanUse(RG_MEGATON_HAMMER);}}), }, { //Exits - Entrance(RR_FOREST_TEMPLE_RED_POE_ROOM, {[]{return IsAdult || KokiriSword;}}), - Entrance(RR_FOREST_TEMPLE_BLUE_POE_ROOM, {[]{return IsAdult || KokiriSword;}}), + Entrance(RR_FOREST_TEMPLE_RED_POE_ROOM, {[]{return CanUse(RG_KOKIRI_SWORD) || CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD) || CanUse(RG_MEGATON_HAMMER);}}), + Entrance(RR_FOREST_TEMPLE_BLUE_POE_ROOM, {[]{return CanUse(RG_KOKIRI_SWORD) || CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD) || CanUse(RG_MEGATON_HAMMER);}}), }); areaTable[RR_FOREST_TEMPLE_BLUE_POE_ROOM] = Area("Forest Temple Blue Poe Room", "Forest Temple", RHT_FOREST_TEMPLE, NO_DAY_NIGHT_CYCLE, { @@ -261,8 +261,8 @@ void AreaTable_Init_ForestTemple() { areaTable[RR_FOREST_TEMPLE_EAST_CORRIDOR] = Area("Forest Temple East Corridor", "Forest Temple", RHT_FOREST_TEMPLE, NO_DAY_NIGHT_CYCLE, {}, {}, { //Exits - Entrance(RR_FOREST_TEMPLE_LOBBY, {[]{return IsAdult || CanChildAttack || Nuts;}}), - Entrance(RR_FOREST_TEMPLE_GREEN_POE_ROOM, {[]{return IsAdult || CanChildAttack || Nuts;}}), + Entrance(RR_FOREST_TEMPLE_LOBBY, {[]{return CanAdultAttack || CanChildAttack || Nuts;}}), + Entrance(RR_FOREST_TEMPLE_GREEN_POE_ROOM, {[]{return CanAdultAttack || CanChildAttack || Nuts;}}), }); areaTable[RR_FOREST_TEMPLE_BOSS_REGION] = Area("Forest Temple Boss Region", "Forest Temple", RHT_FOREST_TEMPLE, NO_DAY_NIGHT_CYCLE, {}, { @@ -282,12 +282,12 @@ void AreaTable_Init_ForestTemple() { if (Dungeon::ForestTemple.IsMQ()) { areaTable[RR_FOREST_TEMPLE_MQ_LOBBY] = Area("Forest Temple MQ Lobby", "Forest Temple", RHT_FOREST_TEMPLE, NO_DAY_NIGHT_CYCLE, {}, { //Locations - LocationAccess(RC_FOREST_TEMPLE_MQ_FIRST_ROOM_CHEST, {[]{return IsAdult || Bombs || CanUse(RG_STICKS) || Nuts || CanUse(RG_BOOMERANG) || CanUse(RG_DINS_FIRE) || KokiriSword || CanUse(RG_FAIRY_SLINGSHOT);}}), + LocationAccess(RC_FOREST_TEMPLE_MQ_FIRST_ROOM_CHEST, {[]{return CanJumpslash || Bombs || CanUse(RG_STICKS) || Nuts || HookshotOrBoomerang || CanUse(RG_DINS_FIRE) || KokiriSword || CanUse(RG_FAIRY_SLINGSHOT) || CanUse(RG_FAIRY_BOW) || CanUse(RG_HOVER_BOOTS);}}), LocationAccess(RC_FOREST_TEMPLE_MQ_GS_FIRST_HALLWAY, {[]{return HookshotOrBoomerang;}}), }, { //Exits Entrance(RR_FOREST_TEMPLE_ENTRYWAY, {[]{return true;}}), - Entrance(RR_FOREST_TEMPLE_MQ_CENTRAL_AREA, {[]{return SmallKeys(RR_FOREST_TEMPLE, 1) && (IsAdult || CanChildAttack || Nuts);}}), + Entrance(RR_FOREST_TEMPLE_MQ_CENTRAL_AREA, {[]{return SmallKeys(RR_FOREST_TEMPLE, 1) && (CanAdultAttack || CanChildAttack || Nuts);}}), }); areaTable[RR_FOREST_TEMPLE_MQ_CENTRAL_AREA] = Area("Forest Temple MQ Central Area", "Forest Temple", RHT_FOREST_TEMPLE, NO_DAY_NIGHT_CYCLE, { @@ -295,12 +295,12 @@ void AreaTable_Init_ForestTemple() { EventAccess(&FairyPot, {[]{return true;}}), }, { //Locations - LocationAccess(RC_FOREST_TEMPLE_MQ_WOLFOS_CHEST, {[]{return (CanPlay(SongOfTime) || IsChild) && (IsAdult || CanUse(RG_DINS_FIRE) || CanUse(RG_STICKS) || CanUse(RG_FAIRY_SLINGSHOT) || KokiriSword);}}), - LocationAccess(RC_FOREST_TEMPLE_MQ_GS_BLOCK_PUSH_ROOM, {[]{return IsAdult || KokiriSword;}}), + LocationAccess(RC_FOREST_TEMPLE_MQ_WOLFOS_CHEST, {[]{return (CanPlay(SongOfTime) || IsChild) && (CanJumpslash || CanUse(RG_DINS_FIRE) || CanUse(RG_STICKS) || CanUse(RG_FAIRY_SLINGSHOT) || KokiriSword);}}), + LocationAccess(RC_FOREST_TEMPLE_MQ_GS_BLOCK_PUSH_ROOM, {[]{return CanUse(RG_KOKIRI_SWORD) || CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD) || CanUse(RG_MEGATON_HAMMER);}}), }, { //Exits - Entrance(RR_FOREST_TEMPLE_MQ_NW_OUTDOORS, {[]{return (IsAdult && CanUse(RG_FAIRY_BOW)) || (IsChild && CanUse(RG_FAIRY_SLINGSHOT));}}), - Entrance(RR_FOREST_TEMPLE_MQ_NE_OUTDOORS, {[]{return (IsAdult && CanUse(RG_FAIRY_BOW)) || (IsChild && CanUse(RG_FAIRY_SLINGSHOT));}}), //This is as far as child can get + Entrance(RR_FOREST_TEMPLE_MQ_NW_OUTDOORS, {[]{return CanUse(RG_FAIRY_BOW) || CanUse(RG_FAIRY_SLINGSHOT);}}), + Entrance(RR_FOREST_TEMPLE_MQ_NE_OUTDOORS, {[]{return CanUse(RG_FAIRY_BOW) || CanUse(RG_FAIRY_SLINGSHOT);}}), //This is as far as child can get Entrance(RR_FOREST_TEMPLE_MQ_AFTER_BLOCK_PUZZLE, {[]{return IsAdult && (GoronBracelet || (LogicForestMQBlockPuzzle && HasBombchus && IsAdult && CanUse(RG_HOOKSHOT)));}}), //Trick: IsAdult && (GoronBracelet || (LogicForestMQBlockPuzzle && HasBombchus && IsAdult && CanUse(RG_HOOKSHOT))) Entrance(RR_FOREST_TEMPLE_MQ_OUTDOOR_LEDGE, {[]{return (LogicForestMQHallwaySwitchJS && IsAdult && CanUse(RG_HOVER_BOOTS)) || (LogicForestMQHallwaySwitchBoomerang && CanUse(RG_BOOMERANG)) || (LogicForestMQHallwaySwitchHookshot && IsAdult && CanUse(RG_HOOKSHOT));}}), @@ -321,7 +321,7 @@ void AreaTable_Init_ForestTemple() { areaTable[RR_FOREST_TEMPLE_MQ_OUTDOOR_LEDGE] = Area("Forest Temple MQ Outdoor Ledge", "Forest Temple", RHT_FOREST_TEMPLE, NO_DAY_NIGHT_CYCLE, {}, { //Locations - LocationAccess(RC_FOREST_TEMPLE_MQ_REDEAD_CHEST, {[]{return true;}}), + LocationAccess(RC_FOREST_TEMPLE_MQ_REDEAD_CHEST, {[]{return CanJumpslash;}}), }, { //Exits Entrance(RR_FOREST_TEMPLE_MQ_NW_OUTDOORS, {[]{return true;}}), @@ -329,7 +329,7 @@ void AreaTable_Init_ForestTemple() { areaTable[RR_FOREST_TEMPLE_MQ_NW_OUTDOORS] = Area("Forest Temple MQ NW Outdoors", "Forest Temple", RHT_FOREST_TEMPLE, NO_DAY_NIGHT_CYCLE, {}, { //Locations - LocationAccess(RC_FOREST_TEMPLE_MQ_GS_LEVEL_ISLAND_COURTYARD, {[]{return true;}}), + LocationAccess(RC_FOREST_TEMPLE_MQ_GS_LEVEL_ISLAND_COURTYARD, {[]{return CanAdultAttack || CanChildAttack;}}), }, { //Exits Entrance(RR_FOREST_TEMPLE_MQ_NE_OUTDOORS, {[]{return (IsAdult && (CanUse(RG_IRON_BOOTS) || CanUse(RG_LONGSHOT) || (LogicForestMQWellSwim && CanUse(RG_HOOKSHOT)))) || ProgressiveScale >= 2;}}), @@ -339,8 +339,8 @@ void AreaTable_Init_ForestTemple() { areaTable[RR_FOREST_TEMPLE_MQ_NE_OUTDOORS] = Area("Forest Temple MQ NE Outdoors", "Forest Temple", RHT_FOREST_TEMPLE, NO_DAY_NIGHT_CYCLE, { //Events - EventAccess(&DekuBabaSticks, {[]{return DekuBabaSticks || (IsAdult || KokiriSword || Boomerang);}}), - EventAccess(&DekuBabaNuts, {[]{return DekuBabaNuts || (IsAdult || KokiriSword || Slingshot || Sticks || HasExplosives || CanUse(RG_DINS_FIRE));}}), + EventAccess(&DekuBabaSticks, {[]{return DekuBabaSticks || (CanUse(RG_KOKIRI_SWORD) || CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD) || CanUse(RG_BOOMERANG));}}), + EventAccess(&DekuBabaNuts, {[]{return DekuBabaNuts || (CanJumpslash || CanUse(RG_FAIRY_SLINGSHOT) || CanUse(RG_FAIRY_BOW) || CanUse(RG_MEGATON_HAMMER) || HasExplosives || CanUse(RG_DINS_FIRE));}}), }, { //Locations LocationAccess(RC_FOREST_TEMPLE_MQ_WELL_CHEST, {[]{return (IsAdult && CanUse(RG_FAIRY_BOW)) || (IsChild && CanUse(RG_FAIRY_SLINGSHOT));}}), @@ -376,7 +376,7 @@ void AreaTable_Init_ForestTemple() { EventAccess(&ForestTempleJoAndBeth, {[]{return ForestTempleJoAndBeth || (IsAdult && CanUse(RG_FAIRY_BOW));}}), }, { //Locations - LocationAccess(RC_FOREST_TEMPLE_MQ_BOW_CHEST, {[]{return true;}}), + LocationAccess(RC_FOREST_TEMPLE_MQ_BOW_CHEST, {[]{return CanUse(RG_KOKIRI_SWORD) || CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD) || CanUse(RG_MEGATON_HAMMER);}}), LocationAccess(RC_FOREST_TEMPLE_MQ_MAP_CHEST, {[]{return IsAdult && CanUse(RG_FAIRY_BOW);}}), LocationAccess(RC_FOREST_TEMPLE_MQ_COMPASS_CHEST, {[]{return IsAdult && CanUse(RG_FAIRY_BOW);}}), }, { diff --git a/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_ganons_castle.cpp b/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_ganons_castle.cpp index f0c2219fd..c47bf63ba 100644 --- a/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_ganons_castle.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_ganons_castle.cpp @@ -22,7 +22,10 @@ void AreaTable_Init_GanonsCastle() { | VANILLA DUNGEON | ---------------------------*/ if (Dungeon::GanonsCastle.IsVanilla()) { - areaTable[RR_GANONS_CASTLE_LOBBY] = Area("Ganon's Castle Lobby", "Ganon's Castle", RHT_GANONS_CASTLE, NO_DAY_NIGHT_CYCLE, {}, {}, { + areaTable[RR_GANONS_CASTLE_LOBBY] = Area("Ganon's Castle Lobby", "Ganon's Castle", RHT_GANONS_CASTLE, NO_DAY_NIGHT_CYCLE, {}, { + //Locations + LocationAccess(RC_SHEIK_HINT_GC, {[]{return true;}}), + }, { //Exits Entrance(RR_GANONS_CASTLE_ENTRYWAY, {[]{return true;}}), Entrance(RR_GANONS_CASTLE_FOREST_TRIAL, {[]{return true;}}), @@ -56,7 +59,7 @@ void AreaTable_Init_GanonsCastle() { EventAccess(&ForestTrialClear, {[]{return CanUse(RG_LIGHT_ARROWS) && (FireArrows || DinsFire);}}), }, { //Locations - LocationAccess(RC_GANONS_CASTLE_FOREST_TRIAL_CHEST, {[]{return IsAdult || CanChildDamage;}}), + LocationAccess(RC_GANONS_CASTLE_FOREST_TRIAL_CHEST, {[]{return CanAdultDamage || CanChildDamage;}}), }, {}); areaTable[RR_GANONS_CASTLE_FIRE_TRIAL] = Area("Ganon's Castle Fire Trial", "Ganon's Castle", RHT_GANONS_CASTLE, NO_DAY_NIGHT_CYCLE, { @@ -68,7 +71,7 @@ void AreaTable_Init_GanonsCastle() { //Events EventAccess(&BlueFireAccess, {[]{return BlueFireAccess || HasBottle;}}), EventAccess(&FairyPot, {[]{return FairyPot || BlueFire;}}), - EventAccess(&WaterTrialClear, {[]{return BlueFire && Hammer && CanUse(RG_LIGHT_ARROWS);}}), + EventAccess(&WaterTrialClear, {[]{return BlueFire && IsAdult && CanUse(RG_MEGATON_HAMMER) && CanUse(RG_LIGHT_ARROWS);}}), }, { //Locations LocationAccess(RC_GANONS_CASTLE_WATER_TRIAL_LEFT_CHEST, {[]{return true;}}), @@ -77,7 +80,7 @@ void AreaTable_Init_GanonsCastle() { areaTable[RR_GANONS_CASTLE_SHADOW_TRIAL] = Area("Ganon's Castle Shadow Trial", "Ganon's Castle", RHT_GANONS_CASTLE, NO_DAY_NIGHT_CYCLE, { //Events - EventAccess(&ShadowTrialClear, {[]{return CanUse(RG_LIGHT_ARROWS) && Hammer && ((FireArrows && (LogicLensCastle || CanUse(RG_LENS_OF_TRUTH))) || (CanUse(RG_LONGSHOT) && (CanUse(RG_HOVER_BOOTS) || (DinsFire && (LogicLensCastle || CanUse(RG_LENS_OF_TRUTH))))));}}), + EventAccess(&ShadowTrialClear, {[]{return CanUse(RG_LIGHT_ARROWS) && CanUse(RG_MEGATON_HAMMER) && ((FireArrows && (LogicLensCastle || CanUse(RG_LENS_OF_TRUTH))) || (CanUse(RG_LONGSHOT) && (CanUse(RG_HOVER_BOOTS) || (DinsFire && (LogicLensCastle || CanUse(RG_LENS_OF_TRUTH))))));}}), }, { //Locations LocationAccess(RC_GANONS_CASTLE_SHADOW_TRIAL_FRONT_CHEST, {[]{return CanUse(RG_FIRE_ARROWS) || CanUse(RG_HOOKSHOT) || CanUse(RG_HOVER_BOOTS) || CanPlay(SongOfTime) || IsChild;}}), @@ -86,11 +89,11 @@ void AreaTable_Init_GanonsCastle() { areaTable[RR_GANONS_CASTLE_SPIRIT_TRIAL] = Area("Ganon's Castle Spirit Trial", "Ganon's Castle", RHT_GANONS_CASTLE, NO_DAY_NIGHT_CYCLE, { //Events - EventAccess(&NutPot, {[]{return NutPot || ((LogicSpiritTrialHookshot || CanUse(RG_HOOKSHOT)) && HasBombchus && Bow && (MirrorShield || (SunlightArrows && CanUse(RG_LIGHT_ARROWS))) && IsAdult);}}), - EventAccess(&SpiritTrialClear, {[]{return CanUse(RG_LIGHT_ARROWS) && (MirrorShield || SunlightArrows) && HasBombchus && (LogicSpiritTrialHookshot || CanUse(RG_HOOKSHOT));}}), + EventAccess(&NutPot, {[]{return NutPot || (((LogicSpiritTrialHookshot && CanJumpslash) || CanUse(RG_HOOKSHOT)) && HasBombchus && CanUse(RG_FAIRY_BOW) && (CanUse(RG_MIRROR_SHIELD) || (SunlightArrows && CanUse(RG_LIGHT_ARROWS))));}}), + EventAccess(&SpiritTrialClear, {[]{return CanUse(RG_LIGHT_ARROWS) && (CanUse(RG_MIRROR_SHIELD) || SunlightArrows) && HasBombchus && ((LogicSpiritTrialHookshot && CanJumpslash) || CanUse(RG_HOOKSHOT));}}), }, { //Locations - LocationAccess(RC_GANONS_CASTLE_SPIRIT_TRIAL_CRYSTAL_SWITCH_CHEST, {[]{return LogicSpiritTrialHookshot || CanUse(RG_HOOKSHOT);}}), + LocationAccess(RC_GANONS_CASTLE_SPIRIT_TRIAL_CRYSTAL_SWITCH_CHEST, {[]{return (LogicSpiritTrialHookshot || CanUse(RG_HOOKSHOT)) && CanJumpslash;}}), LocationAccess(RC_GANONS_CASTLE_SPIRIT_TRIAL_INVISIBLE_CHEST, {[]{return (LogicSpiritTrialHookshot || CanUse(RG_HOOKSHOT)) && HasBombchus && (LogicLensCastle || CanUse(RG_LENS_OF_TRUTH));}}), }, {}); @@ -112,18 +115,21 @@ void AreaTable_Init_GanonsCastle() { areaTable[RR_GANONS_CASTLE_TOWER] = Area("Ganon's Castle Tower", "Ganons Castle", RHT_GANONS_CASTLE, NO_DAY_NIGHT_CYCLE, {}, { //Locations - LocationAccess(RC_GANONS_TOWER_BOSS_KEY_CHEST, {[]{return true;}}), - LocationAccess(RC_GANONDORF_HINT, {[]{return BossKeyGanonsCastle;}}), - LocationAccess(RC_GANON, {[]{return HasBossSoul(RG_GANON_SOUL) && BossKeyGanonsCastle && CanUse(RG_LIGHT_ARROWS);}}), + LocationAccess(RC_GANONS_TOWER_BOSS_KEY_CHEST, {[]{return CanUse(RG_KOKIRI_SWORD) || CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD);}}), + LocationAccess(RC_GANONDORF_HINT, {[]{return BossKeyGanonsCastle && (CanUse(RG_KOKIRI_SWORD) || CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD));}}), + LocationAccess(RC_GANON, {[]{return HasBossSoul(RG_GANON_SOUL) && BossKeyGanonsCastle && CanUse(RG_LIGHT_ARROWS) && CanUse(RG_MASTER_SWORD);}}), }, {}); /*--------------------------- | MASTER QUEST DUNGEON | ---------------------------*/ if (Dungeon::GanonsCastle.IsMQ()) { - areaTable[RR_GANONS_CASTLE_MQ_LOBBY] = Area("Ganon's Castle MQ Lobby", "Ganons Castle", RHT_GANONS_CASTLE, NO_DAY_NIGHT_CYCLE, {}, {}, { + areaTable[RR_GANONS_CASTLE_MQ_LOBBY] = Area("Ganon's Castle MQ Lobby", "Ganons Castle", RHT_GANONS_CASTLE, NO_DAY_NIGHT_CYCLE, {}, { + //Locations + LocationAccess(RC_SHEIK_HINT_MQ_GC, {[]{return true;}}), + }, { //Exits - Entrance(RR_GANONS_CASTLE_ENTRYWAY, {[]{return (IsAdult || (HasExplosives || ((Nuts || Boomerang) && (Sticks || KokiriSword))));}}), + Entrance(RR_GANONS_CASTLE_ENTRYWAY, {[]{return (CanUse(RG_MASTER_SWORD) || (HasExplosives || ((Nuts || Boomerang) && (Sticks || KokiriSword))));}}), Entrance(RR_GANONS_CASTLE_MQ_FOREST_TRIAL, {[]{return true;}}), Entrance(RR_GANONS_CASTLE_MQ_FIRE_TRIAL, {[]{return true;}}), Entrance(RR_GANONS_CASTLE_MQ_WATER_TRIAL, {[]{return true;}}), @@ -153,12 +159,12 @@ void AreaTable_Init_GanonsCastle() { areaTable[RR_GANONS_CASTLE_MQ_FOREST_TRIAL] = Area("Ganon's Castle MQ Forest Trial", "Ganons Castle", RHT_GANONS_CASTLE, NO_DAY_NIGHT_CYCLE, { //Events - EventAccess(&ForestTrialClear, {[]{return IsAdult && CanUse(RG_LIGHT_ARROWS) && CanPlay(SongOfTime);}}), + EventAccess(&ForestTrialClear, {[]{return IsAdult && CanUse(RG_LIGHT_ARROWS) && (CanUse(RG_KOKIRI_SWORD) || CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD)) && CanPlay(SongOfTime);}}), }, { //Locations - LocationAccess(RC_GANONS_CASTLE_MQ_FOREST_TRIAL_EYE_SWITCH_CHEST, {[]{return (IsAdult && CanUse(RG_FAIRY_BOW)) || (IsChild && CanUse(RG_FAIRY_SLINGSHOT));}}), - LocationAccess(RC_GANONS_CASTLE_MQ_FOREST_TRIAL_FROZEN_EYE_SWITCH_CHEST, {[]{return HasFireSource;}}), - LocationAccess(RC_GANONS_CASTLE_MQ_FOREST_TRIAL_FREESTANDING_KEY, {[]{return HookshotOrBoomerang;}}), + LocationAccess(RC_GANONS_CASTLE_MQ_FOREST_TRIAL_EYE_SWITCH_CHEST, {[]{return (CanUse(RG_KOKIRI_SWORD) || CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD)) && (CanUse(RG_FAIRY_BOW) || CanUse(RG_FAIRY_SLINGSHOT));}}), + LocationAccess(RC_GANONS_CASTLE_MQ_FOREST_TRIAL_FROZEN_EYE_SWITCH_CHEST, {[]{return (CanUse(RG_KOKIRI_SWORD) || CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD)) && HasFireSource;}}), + LocationAccess(RC_GANONS_CASTLE_MQ_FOREST_TRIAL_FREESTANDING_KEY, {[]{return (CanUse(RG_KOKIRI_SWORD) || CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD)) && HookshotOrBoomerang;}}), }, {}); areaTable[RR_GANONS_CASTLE_MQ_FIRE_TRIAL] = Area("Ganon's Castle MQ Fire Trial", "Ganons Castle", RHT_GANONS_CASTLE, NO_DAY_NIGHT_CYCLE, { @@ -170,10 +176,10 @@ void AreaTable_Init_GanonsCastle() { areaTable[RR_GANONS_CASTLE_MQ_WATER_TRIAL] = Area("Ganon's Castle MQ Water Trial", "Ganons Castle", RHT_GANONS_CASTLE, NO_DAY_NIGHT_CYCLE, { //Events EventAccess(&WaterTrialClear, {[]{return BlueFire && IsAdult && CanUse(RG_LIGHT_ARROWS) && SmallKeys(RR_GANONS_CASTLE, 3);}}), - EventAccess(&BlueFireAccess, {[]{return BlueFireAccess || HasBottle;}}), + EventAccess(&BlueFireAccess, {[]{return BlueFireAccess || (HasBottle && CanJumpslash);}}), }, { //Locations - LocationAccess(RC_GANONS_CASTLE_MQ_WATER_TRIAL_CHEST, {[]{return BlueFire && (IsAdult || CanUse(RG_STICKS) || KokiriSword || CanUseProjectile);}}), + LocationAccess(RC_GANONS_CASTLE_MQ_WATER_TRIAL_CHEST, {[]{return BlueFire;}}), }, {}); areaTable[RR_GANONS_CASTLE_MQ_SHADOW_TRIAL] = Area("Ganon's Castle MQ Shadow Trial", "Ganons Castle", RHT_GANONS_CASTLE, NO_DAY_NIGHT_CYCLE, { @@ -203,11 +209,11 @@ void AreaTable_Init_GanonsCastle() { areaTable[RR_GANONS_CASTLE_MQ_LIGHT_TRIAL] = Area("Ganon's Castle MQ Light Trial", "Ganons Castle", RHT_GANONS_CASTLE, NO_DAY_NIGHT_CYCLE, { //Events - EventAccess(&LightTrialClear, {[]{return IsAdult && CanUse(RG_LIGHT_ARROWS) && SmallKeys(RR_GANONS_CASTLE, 3) && (LogicLensCastleMQ || CanUse(RG_LENS_OF_TRUTH)) && (Hookshot || LogicLightTrialMQ);}}), + EventAccess(&LightTrialClear, {[]{return IsAdult && (CanUse(RG_MASTER_SWORD) || CanUse(RG_KOKIRI_SWORD) || CanUse(RG_BIGGORON_SWORD)) && CanUse(RG_LIGHT_ARROWS) && SmallKeys(RR_GANONS_CASTLE, 3) && (LogicLensCastleMQ || CanUse(RG_LENS_OF_TRUTH)) && (Hookshot || LogicLightTrialMQ);}}), //Trick: IsAdult && CanUse(RG_LIGHT_ARROWS) && SmallKeys(RR_GANONS_CASTLE, 3) && (LogicLensCastleMQ || CanUse(RG_LENS_OF_TRUTH)) && (Hookshot || LogicLightTrialMQ) }, { //Locations - LocationAccess(RC_GANONS_CASTLE_MQ_LIGHT_TRIAL_LULLABY_CHEST, {[]{return CanPlay(ZeldasLullaby);}}), + LocationAccess(RC_GANONS_CASTLE_MQ_LIGHT_TRIAL_LULLABY_CHEST, {[]{return (CanUse(RG_MASTER_SWORD) || CanUse(RG_KOKIRI_SWORD) || CanUse(RG_BIGGORON_SWORD)) && CanPlay(ZeldasLullaby);}}), }, {}); } } diff --git a/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_gerudo_training_grounds.cpp b/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_gerudo_training_grounds.cpp index 8dc601b5c..7316baf3c 100644 --- a/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_gerudo_training_grounds.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_gerudo_training_grounds.cpp @@ -25,13 +25,13 @@ void AreaTable_Init_GerudoTrainingGrounds() { //Locations LocationAccess(RC_GERUDO_TRAINING_GROUND_LOBBY_LEFT_CHEST, {[]{return CanUse(RG_FAIRY_BOW) || CanUse(RG_FAIRY_SLINGSHOT);}}), LocationAccess(RC_GERUDO_TRAINING_GROUND_LOBBY_RIGHT_CHEST, {[]{return CanUse(RG_FAIRY_BOW) || CanUse(RG_FAIRY_SLINGSHOT);}}), - LocationAccess(RC_GERUDO_TRAINING_GROUND_STALFOS_CHEST, {[]{return IsAdult || KokiriSword;}}), - LocationAccess(RC_GERUDO_TRAINING_GROUND_BEAMOS_CHEST, {[]{return HasExplosives && (IsAdult || KokiriSword);}}), + LocationAccess(RC_GERUDO_TRAINING_GROUND_STALFOS_CHEST, {[]{return CanUse(RG_KOKIRI_SWORD) || CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD);}}), + LocationAccess(RC_GERUDO_TRAINING_GROUND_BEAMOS_CHEST, {[]{return HasExplosives && (CanUse(RG_KOKIRI_SWORD) || CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD));}}), }, { //Exits Entrance(RR_GERUDO_TRAINING_GROUNDS_ENTRYWAY, {[]{return true;}}), - Entrance(RR_GERUDO_TRAINING_GROUNDS_HEAVY_BLOCK_ROOM, {[]{return (IsAdult || KokiriSword) && (CanUse(RG_HOOKSHOT) || LogicGtgWithoutHookshot);}}), - Entrance(RR_GERUDO_TRAINING_GROUNDS_LAVA_ROOM, {[]{return Here(RR_GERUDO_TRAINING_GROUNDS_LOBBY, []{return (IsAdult || KokiriSword) && HasExplosives;});}}), + Entrance(RR_GERUDO_TRAINING_GROUNDS_HEAVY_BLOCK_ROOM, {[]{return (CanUse(RG_KOKIRI_SWORD) || CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD)) && (CanUse(RG_HOOKSHOT) || LogicGtgWithoutHookshot);}}), + Entrance(RR_GERUDO_TRAINING_GROUNDS_LAVA_ROOM, {[]{return Here(RR_GERUDO_TRAINING_GROUNDS_LOBBY, []{return (CanUse(RG_KOKIRI_SWORD) || CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD)) && HasExplosives;});}}), Entrance(RR_GERUDO_TRAINING_GROUNDS_CENTRAL_MAZE, {[]{return true;}}), }); @@ -69,11 +69,11 @@ void AreaTable_Init_GerudoTrainingGrounds() { areaTable[RR_GERUDO_TRAINING_GROUNDS_HAMMER_ROOM] = Area("Gerudo Training Grounds Hammer Room", "Gerudo Training Grounds", RHT_GERUDO_TRAINING_GROUND, NO_DAY_NIGHT_CYCLE, {}, { //Locations - LocationAccess(RC_GERUDO_TRAINING_GROUND_HAMMER_ROOM_CLEAR_CHEST, {[]{return true;}}), + LocationAccess(RC_GERUDO_TRAINING_GROUND_HAMMER_ROOM_CLEAR_CHEST, {[]{return CanAdultAttack || CanChildAttack;}}), LocationAccess(RC_GERUDO_TRAINING_GROUND_HAMMER_ROOM_SWITCH_CHEST, {[]{return CanUse(RG_MEGATON_HAMMER) || (CanTakeDamage && LogicFlamingChests);}}), }, { //Exits - Entrance(RR_GERUDO_TRAINING_GROUNDS_EYE_STATUE_LOWER, {[]{return CanUse(RG_MEGATON_HAMMER) && Bow;}}), + Entrance(RR_GERUDO_TRAINING_GROUNDS_EYE_STATUE_LOWER, {[]{return CanUse(RG_MEGATON_HAMMER) && CanUse(RG_FAIRY_BOW);}}), Entrance(RR_GERUDO_TRAINING_GROUNDS_LAVA_ROOM, {[]{return true;}}), }); @@ -95,7 +95,7 @@ void AreaTable_Init_GerudoTrainingGrounds() { areaTable[RR_GERUDO_TRAINING_GROUNDS_HEAVY_BLOCK_ROOM] = Area("Gerudo Training Grounds Heavy Block Room", "Gerudo Training Grounds", RHT_GERUDO_TRAINING_GROUND, NO_DAY_NIGHT_CYCLE, {}, { //Locations - LocationAccess(RC_GERUDO_TRAINING_GROUND_BEFORE_HEAVY_BLOCK_CHEST, {[]{return true;}}), + LocationAccess(RC_GERUDO_TRAINING_GROUND_BEFORE_HEAVY_BLOCK_CHEST, {[]{return CanJumpslash;}}), }, { //Exits Entrance(RR_GERUDO_TRAINING_GROUNDS_EYE_STATUE_UPPER, {[]{return (LogicLensGtg || CanUse(RG_LENS_OF_TRUTH)) && (CanUse(RG_HOOKSHOT) || (LogicGtgFakeWall && CanUse(RG_HOVER_BOOTS)));}}), @@ -104,10 +104,10 @@ void AreaTable_Init_GerudoTrainingGrounds() { areaTable[RR_GERUDO_TRAINING_GROUNDS_LIKE_LIKE_ROOM] = Area("Gerudo Training Grounds Like Like Room", "Gerudo Training Grounds", RHT_GERUDO_TRAINING_GROUND, NO_DAY_NIGHT_CYCLE, {}, { //Locations - LocationAccess(RC_GERUDO_TRAINING_GROUND_HEAVY_BLOCK_FIRST_CHEST, {[]{return true;}}), - LocationAccess(RC_GERUDO_TRAINING_GROUND_HEAVY_BLOCK_SECOND_CHEST, {[]{return true;}}), - LocationAccess(RC_GERUDO_TRAINING_GROUND_HEAVY_BLOCK_THIRD_CHEST, {[]{return true;}}), - LocationAccess(RC_GERUDO_TRAINING_GROUND_HEAVY_BLOCK_FOURTH_CHEST, {[]{return true;}}), + LocationAccess(RC_GERUDO_TRAINING_GROUND_HEAVY_BLOCK_FIRST_CHEST, {[]{return CanJumpslash;}}), + LocationAccess(RC_GERUDO_TRAINING_GROUND_HEAVY_BLOCK_SECOND_CHEST, {[]{return CanJumpslash;}}), + LocationAccess(RC_GERUDO_TRAINING_GROUND_HEAVY_BLOCK_THIRD_CHEST, {[]{return CanJumpslash;}}), + LocationAccess(RC_GERUDO_TRAINING_GROUND_HEAVY_BLOCK_FOURTH_CHEST, {[]{return CanJumpslash;}}), }, {}); } @@ -135,10 +135,10 @@ void AreaTable_Init_GerudoTrainingGrounds() { //EventAccess(&WallFairy, {[]{return WallFairy || (IsAdult && CanUse(RG_FAIRY_BOW));}}), }, { //Locations - LocationAccess(RC_GERUDO_TRAINING_GROUND_MQ_DINOLFOS_CHEST, {[]{return IsAdult;}}), + LocationAccess(RC_GERUDO_TRAINING_GROUND_MQ_DINOLFOS_CHEST, {[]{return IsAdult && (CanUse(RG_MASTER_SWORD) || CanUse(RG_KOKIRI_SWORD) || CanUse(RG_BIGGORON_SWORD));}}), }, { //Exits - Entrance(RR_GERUDO_TRAINING_GROUNDS_MQ_UNDERWATER, {[]{return (Bow || CanUse(RG_LONGSHOT)) && CanUse(RG_HOVER_BOOTS) && IsAdult;}}), + Entrance(RR_GERUDO_TRAINING_GROUNDS_MQ_UNDERWATER, {[]{return (Bow || (CanUse(RG_LONGSHOT) && HasFireSource)) && CanUse(RG_HOVER_BOOTS) && IsAdult && (CanUse(RG_MASTER_SWORD) || CanUse(RG_KOKIRI_SWORD) || CanUse(RG_BIGGORON_SWORD));}}), }); areaTable[RR_GERUDO_TRAINING_GROUNDS_MQ_UNDERWATER] = Area("Gerudo Training Grounds MQ Underwater", "Gerudo Training Grounds", RHT_GERUDO_TRAINING_GROUND, NO_DAY_NIGHT_CYCLE, {}, { @@ -148,7 +148,7 @@ void AreaTable_Init_GerudoTrainingGrounds() { areaTable[RR_GERUDO_TRAINING_GROUNDS_MQ_LEFT_SIDE] = Area("Gerudo Training Grounds MQ Left Side", "Gerudo Training Grounds", RHT_GERUDO_TRAINING_GROUND, NO_DAY_NIGHT_CYCLE, {}, { //Locations - LocationAccess(RC_GERUDO_TRAINING_GROUND_MQ_FIRST_IRON_KNUCKLE_CHEST, {[]{return IsAdult || KokiriSword || HasExplosives;}}), + LocationAccess(RC_GERUDO_TRAINING_GROUND_MQ_FIRST_IRON_KNUCKLE_CHEST, {[]{return CanUse(RG_KOKIRI_SWORD) || CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD) || HasExplosives;}}), }, { //Exits Entrance(RR_GERUDO_TRAINING_GROUNDS_MQ_STALFOS_ROOM, {[]{return (IsAdult && CanUse(RG_LONGSHOT)) || LogicGtgMQWithoutHookshot || (LogicGtgMQWithHookshot && IsAdult && CanUse(RG_HOOKSHOT));}}), @@ -160,22 +160,22 @@ void AreaTable_Init_GerudoTrainingGrounds() { EventAccess(&BlueFireAccess, {[]{return BlueFireAccess || HasBottle;}}), }, { //Locations - LocationAccess(RC_GERUDO_TRAINING_GROUND_MQ_BEFORE_HEAVY_BLOCK_CHEST, {[]{return IsAdult;}}), - LocationAccess(RC_GERUDO_TRAINING_GROUND_MQ_HEAVY_BLOCK_CHEST, {[]{return CanUse(RG_SILVER_GAUNTLETS);}}), + LocationAccess(RC_GERUDO_TRAINING_GROUND_MQ_BEFORE_HEAVY_BLOCK_CHEST, {[]{return IsAdult && (CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD));}}), + LocationAccess(RC_GERUDO_TRAINING_GROUND_MQ_HEAVY_BLOCK_CHEST, {[]{return CanUse(RG_SILVER_GAUNTLETS) && (CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD));}}), }, { //Exits - Entrance(RR_GERUDO_TRAINING_GROUNDS_MQ_BACK_AREAS, {[]{return IsAdult && (LogicLensGtgMQ || CanUse(RG_LENS_OF_TRUTH)) && BlueFire && (CanPlay(SongOfTime) || (LogicGtgFakeWall && IsAdult && CanUse(RG_HOVER_BOOTS)));}}), + Entrance(RR_GERUDO_TRAINING_GROUNDS_MQ_BACK_AREAS, {[]{return IsAdult && (CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD)) && (LogicLensGtgMQ || CanUse(RG_LENS_OF_TRUTH)) && BlueFire && (CanPlay(SongOfTime) || (LogicGtgFakeWall && IsAdult && CanUse(RG_HOVER_BOOTS)));}}), //Trick: IsAdult && (LogicLensGtgMQ || CanUse(RG_LENS_OF_TRUTH)) && BlueFire && (CanPlay(SongOfTime) || (LogicGtgFakeWall && IsAdult && CanUse(RG_HOVER_BOOTS))) }); areaTable[RR_GERUDO_TRAINING_GROUNDS_MQ_BACK_AREAS] = Area("Gerudo Training Grounds MQ Back Areas", "Gerudo Training Grounds", RHT_GERUDO_TRAINING_GROUND, NO_DAY_NIGHT_CYCLE, {}, { //Locations - LocationAccess(RC_GERUDO_TRAINING_GROUND_MQ_EYE_STATUE_CHEST, {[]{return Bow;}}), - LocationAccess(RC_GERUDO_TRAINING_GROUND_MQ_SECOND_IRON_KNUCKLE_CHEST, {[]{return true;}}), - LocationAccess(RC_GERUDO_TRAINING_GROUND_MQ_FLAME_CIRCLE_CHEST, {[]{return CanUse(RG_HOOKSHOT) || Bow || HasExplosives;}}), + LocationAccess(RC_GERUDO_TRAINING_GROUND_MQ_EYE_STATUE_CHEST, {[]{return CanUse(RG_FAIRY_BOW);}}), + LocationAccess(RC_GERUDO_TRAINING_GROUND_MQ_SECOND_IRON_KNUCKLE_CHEST, {[]{return CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD);}}), + LocationAccess(RC_GERUDO_TRAINING_GROUND_MQ_FLAME_CIRCLE_CHEST, {[]{return CanUse(RG_HOOKSHOT) || CanUse(RG_FAIRY_BOW) || HasExplosives;}}), }, { //Exits - Entrance(RR_GERUDO_TRAINING_GROUNDS_MQ_CENTRAL_MAZE_RIGHT, {[]{return Hammer;}}), + Entrance(RR_GERUDO_TRAINING_GROUNDS_MQ_CENTRAL_MAZE_RIGHT, {[]{return CanUse(RG_MEGATON_HAMMER);}}), Entrance(RR_GERUDO_TRAINING_GROUNDS_MQ_RIGHT_SIDE, {[]{return CanUse(RG_LONGSHOT);}}), }); diff --git a/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_gerudo_valley.cpp b/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_gerudo_valley.cpp index 7dbf7ad15..3ec4d52d7 100644 --- a/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_gerudo_valley.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_gerudo_valley.cpp @@ -104,13 +104,13 @@ void AreaTable_Init_GerudoValley() { LocationAccess(RC_GF_CHEST, {[]{return CanUse(RG_HOVER_BOOTS) || (IsAdult && CanUse(RG_SCARECROW)) || CanUse(RG_LONGSHOT);}}), LocationAccess(RC_GF_HBA_1000_POINTS, {[]{return GerudoToken && CanRideEpona && Bow && AtDay;}}), LocationAccess(RC_GF_HBA_1500_POINTS, {[]{return GerudoToken && CanRideEpona && Bow && AtDay;}}), - LocationAccess(RC_GF_NORTH_F1_CARPENTER, {[]{return IsAdult || KokiriSword || CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD);}}), - LocationAccess(RC_GF_NORTH_F2_CARPENTER, {[]{return (IsAdult || KokiriSword || CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD)) && (GerudoToken || CanUse(RG_FAIRY_BOW) || CanUse(RG_HOOKSHOT) || CanUse(RG_HOVER_BOOTS) || LogicGerudoKitchen);}}), - LocationAccess(RC_GF_SOUTH_F1_CARPENTER, {[]{return IsAdult || KokiriSword || CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD);}}), - LocationAccess(RC_GF_SOUTH_F2_CARPENTER, {[]{return IsAdult || KokiriSword || CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD);}}), + LocationAccess(RC_GF_NORTH_F1_CARPENTER, {[]{return CanUse(RG_KOKIRI_SWORD) || CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD);}}), + LocationAccess(RC_GF_NORTH_F2_CARPENTER, {[]{return (CanUse(RG_KOKIRI_SWORD) || CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD)) && (GerudoToken || CanUse(RG_FAIRY_BOW) || CanUse(RG_HOOKSHOT) || CanUse(RG_HOVER_BOOTS) || LogicGerudoKitchen);}}), + LocationAccess(RC_GF_SOUTH_F1_CARPENTER, {[]{return CanUse(RG_KOKIRI_SWORD) || CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD);}}), + LocationAccess(RC_GF_SOUTH_F2_CARPENTER, {[]{return CanUse(RG_KOKIRI_SWORD) || CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD);}}), LocationAccess(RC_GF_GERUDO_MEMBERSHIP_CARD, {[]{return CanFinishGerudoFortress;}}), LocationAccess(RC_GF_GS_ARCHERY_RANGE, {[]{return IsAdult && HookshotOrBoomerang && GerudoToken && AtNight && CanGetNightTimeGS;}}), - LocationAccess(RC_GF_GS_TOP_FLOOR, {[]{return IsAdult && AtNight && (GerudoToken || CanUse(RG_FAIRY_BOW) || CanUse(RG_HOOKSHOT) || CanUse(RG_HOVER_BOOTS) || LogicGerudoKitchen || LogicGFJump) && CanGetNightTimeGS;}}), + LocationAccess(RC_GF_GS_TOP_FLOOR, {[]{return IsAdult && AtNight && (CanJumpslash || CanUse(RG_FAIRY_SLINGSHOT) || CanUse(RG_BOOMERANG) || HasExplosives || CanUse(RG_FAIRY_BOW) || CanUse(RG_HOOKSHOT) || CanUse(RG_DINS_FIRE)) && (GerudoToken || CanUse(RG_FAIRY_BOW) || CanUse(RG_HOOKSHOT) || CanUse(RG_HOVER_BOOTS) || LogicGerudoKitchen || LogicGFJump) && CanGetNightTimeGS;}}), }, { //Exits Entrance(RR_GV_FORTRESS_SIDE, {[]{return true;}}), @@ -119,7 +119,7 @@ void AreaTable_Init_GerudoValley() { Entrance(RR_GF_STORMS_GROTTO, {[]{return IsAdult && CanOpenStormGrotto;}}), }); - areaTable[RR_GF_OUTSIDE_GATE] = Area("GF Outside Gate", "Gerudo Fortress", RHT_NONE, NO_DAY_NIGHT_CYCLE, { + areaTable[RR_GF_OUTSIDE_GATE] = Area("GF Outside Gate", "Gerudo Fortress", RHT_GERUDO_FORTRESS, NO_DAY_NIGHT_CYCLE, { //Events EventAccess(&GF_GateOpen, {[]{return IsAdult && GerudoToken && (ShuffleGerudoToken || ShuffleOverworldEntrances /*|| ShuffleSpecialIndoorEntrances*/);}}), }, {}, { @@ -149,7 +149,7 @@ void AreaTable_Init_GerudoValley() { }, { //Locations LocationAccess(RC_WASTELAND_CHEST, {[]{return HasFireSource;}}), - LocationAccess(RC_WASTELAND_BOMBCHU_SALESMAN, {[]{return AdultsWallet && (IsAdult || Sticks || KokiriSword);}}), + LocationAccess(RC_WASTELAND_BOMBCHU_SALESMAN, {[]{return AdultsWallet && (CanJumpslash || CanUse(RG_HOVER_BOOTS)) ;}}), LocationAccess(RC_WASTELAND_GS, {[]{return HookshotOrBoomerang;}}), }, { //Exits @@ -157,7 +157,7 @@ void AreaTable_Init_GerudoValley() { Entrance(RR_WASTELAND_NEAR_FORTRESS, {[]{return CanUse(RG_HOVER_BOOTS) || CanUse(RG_LONGSHOT) || LogicWastelandCrossing;}}), }); - areaTable[RR_WASTELAND_NEAR_COLOSSUS] = Area("Wasteland Near Colossus", "Haunted Wasteland", RHT_NONE, NO_DAY_NIGHT_CYCLE, {}, {}, { + areaTable[RR_WASTELAND_NEAR_COLOSSUS] = Area("Wasteland Near Colossus", "Haunted Wasteland", RHT_HAUNTED_WASTELAND, NO_DAY_NIGHT_CYCLE, {}, {}, { //Exits Entrance(RR_DESERT_COLOSSUS, {[]{return true;}}), Entrance(RR_HAUNTED_WASTELAND, {[]{return LogicReverseWasteland || false;}}), @@ -172,7 +172,7 @@ void AreaTable_Init_GerudoValley() { LocationAccess(RC_COLOSSUS_FREESTANDING_POH, {[]{return IsAdult && CanPlantBean(RR_DESERT_COLOSSUS);}}), LocationAccess(RC_COLOSSUS_GS_BEAN_PATCH, {[]{return CanPlantBugs && CanChildAttack;}}), LocationAccess(RC_COLOSSUS_GS_TREE, {[]{return IsAdult && HookshotOrBoomerang && AtNight && CanGetNightTimeGS;}}), - LocationAccess(RC_COLOSSUS_GS_HILL, {[]{return IsAdult && AtNight && (CanPlantBean(RR_DESERT_COLOSSUS) || CanUse(RG_LONGSHOT) || (LogicColossusGS && CanUse(RG_HOOKSHOT))) && CanGetNightTimeGS;}}), + LocationAccess(RC_COLOSSUS_GS_HILL, {[]{return IsAdult && AtNight && ((CanPlantBean(RR_DESERT_COLOSSUS) && CanAdultAttack) || CanUse(RG_LONGSHOT) || (LogicColossusGS && CanUse(RG_HOOKSHOT))) && CanGetNightTimeGS;}}), LocationAccess(RC_COLOSSUS_GOSSIP_STONE, {[]{return true;}}), }, { //Exits diff --git a/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_hyrule_field.cpp b/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_hyrule_field.cpp index d807c9570..1e4e15807 100644 --- a/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_hyrule_field.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_hyrule_field.cpp @@ -115,7 +115,7 @@ void AreaTable_Init_HyruleField() { LocationAccess(RC_LH_SUN, {[]{return IsAdult && WaterTempleClear && CanUse(RG_FAIRY_BOW);}}), LocationAccess(RC_LH_FREESTANDING_POH, {[]{return IsAdult && (CanUse(RG_SCARECROW) || CanPlantBean(RR_LAKE_HYLIA));}}), LocationAccess(RC_LH_GS_BEAN_PATCH, {[]{return CanPlantBugs && CanChildAttack;}}), - LocationAccess(RC_LH_GS_LAB_WALL, {[]{return IsChild && (HookshotOrBoomerang || (LogicLabWallGS && (Sticks || KokiriSword || CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD)))) && AtNight && CanGetNightTimeGS;}}), + LocationAccess(RC_LH_GS_LAB_WALL, {[]{return IsChild && (HookshotOrBoomerang || (LogicLabWallGS && CanJumpslash)) && AtNight && CanGetNightTimeGS;}}), LocationAccess(RC_LH_GS_SMALL_ISLAND, {[]{return IsChild && CanChildAttack && AtNight && CanGetNightTimeGS;}}), LocationAccess(RC_LH_GS_TREE, {[]{return IsAdult && CanUse(RG_LONGSHOT) && AtNight && CanGetNightTimeGS;}}), LocationAccess(RC_LH_LAB_GOSSIP_STONE, {[]{return true;}}), @@ -138,7 +138,7 @@ void AreaTable_Init_HyruleField() { Entrance(RR_LH_FISHING_HOLE, {[]{return true;}}), }); - areaTable[RR_LH_OWL_FLIGHT] = Area("LH Owl Flight", "Lake Hylia", RHT_NONE, NO_DAY_NIGHT_CYCLE, {}, {}, { + areaTable[RR_LH_OWL_FLIGHT] = Area("LH Owl Flight", "Lake Hylia", RHT_LAKE_HYLIA, NO_DAY_NIGHT_CYCLE, {}, {}, { //Exits Entrance(RR_HYRULE_FIELD, {[]{return true;}}), }); diff --git a/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_ice_cavern.cpp b/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_ice_cavern.cpp index 5d561043a..4386b97ae 100644 --- a/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_ice_cavern.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_ice_cavern.cpp @@ -13,7 +13,7 @@ void AreaTable_Init_IceCavern() { areaTable[RR_ICE_CAVERN_ENTRYWAY] = Area("Ice Cavern Entryway", "Ice Cavern", RHT_ICE_CAVERN, NO_DAY_NIGHT_CYCLE, {}, {}, { //Exits Entrance(RR_ICE_CAVERN_BEGINNING, {[]{return Dungeon::IceCavern.IsVanilla();}}), - Entrance(RR_ICE_CAVERN_MQ_BEGINNING, {[]{return Dungeon::IceCavern.IsMQ();}}), + Entrance(RR_ICE_CAVERN_MQ_BEGINNING, {[]{return Dungeon::IceCavern.IsMQ() && CanUseProjectile;}}), Entrance(RR_ZORAS_FOUNTAIN, {[]{return true;}}), }); @@ -24,7 +24,7 @@ void AreaTable_Init_IceCavern() { areaTable[RR_ICE_CAVERN_BEGINNING] = Area("Ice Cavern Beginning", "Ice Cavern", RHT_ICE_CAVERN, NO_DAY_NIGHT_CYCLE, {}, {}, { //Exits Entrance(RR_ICE_CAVERN_ENTRYWAY, {[]{return true;}}), - Entrance(RR_ICE_CAVERN_MAIN, {[]{return Here(RR_ICE_CAVERN_BEGINNING, []{return IsAdult || HasExplosives || CanUse(RG_DINS_FIRE);});}}), + Entrance(RR_ICE_CAVERN_MAIN, {[]{return Here(RR_ICE_CAVERN_BEGINNING, []{return (CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD)) || CanUse(RG_MEGATON_HAMMER) || HasExplosives || CanUse(RG_HOOKSHOT) || CanUse(RG_DINS_FIRE);});}}), }); areaTable[RR_ICE_CAVERN_MAIN] = Area("Ice Cavern", "Ice Cavern", RHT_ICE_CAVERN, NO_DAY_NIGHT_CYCLE, { @@ -34,8 +34,8 @@ void AreaTable_Init_IceCavern() { //Locations LocationAccess(RC_ICE_CAVERN_MAP_CHEST, {[]{return BlueFire && IsAdult;}}), LocationAccess(RC_ICE_CAVERN_COMPASS_CHEST, {[]{return BlueFire;}}), - LocationAccess(RC_ICE_CAVERN_IRON_BOOTS_CHEST, {[]{return BlueFire && (IsAdult || Slingshot || Sticks || KokiriSword || CanUse(RG_DINS_FIRE));}}), - LocationAccess(RC_SHEIK_IN_ICE_CAVERN, {[]{return BlueFire && IsAdult;}}), + LocationAccess(RC_ICE_CAVERN_IRON_BOOTS_CHEST, {[]{return BlueFire && (CanJumpslash || CanUse(RG_FAIRY_SLINGSHOT) || CanUse(RG_FAIRY_BOW) || CanUse(RG_MEGATON_HAMMER) || CanUse(RG_DINS_FIRE));}}), + LocationAccess(RC_SHEIK_IN_ICE_CAVERN, {[]{return BlueFire && (CanJumpslash || CanUse(RG_FAIRY_SLINGSHOT) || CanUse(RG_FAIRY_BOW) || CanUse(RG_MEGATON_HAMMER) || CanUse(RG_DINS_FIRE)) && IsAdult;}}), LocationAccess(RC_ICE_CAVERN_FREESTANDING_POH, {[]{return BlueFire;}}), LocationAccess(RC_ICE_CAVERN_GS_SPINNING_SCYTHE_ROOM, {[]{return HookshotOrBoomerang;}}), LocationAccess(RC_ICE_CAVERN_GS_HEART_PIECE_ROOM, {[]{return BlueFire && HookshotOrBoomerang;}}), @@ -53,25 +53,25 @@ void AreaTable_Init_IceCavern() { }, {}, { //Exits Entrance(RR_ICE_CAVERN_ENTRYWAY, {[]{return true;}}), - Entrance(RR_ICE_CAVERN_MQ_MAP_ROOM, {[]{return IsAdult || CanUse(RG_DINS_FIRE) || (HasExplosives && (CanUse(RG_STICKS) || CanUse(RG_FAIRY_SLINGSHOT) || KokiriSword));}}), + Entrance(RR_ICE_CAVERN_MQ_MAP_ROOM, {[]{return CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD) || CanUse(RG_MEGATON_HAMMER) || CanUse(RG_DINS_FIRE) || (HasExplosives && (CanUse(RG_KOKIRI_SWORD) || CanUse(RG_STICKS) || CanUse(RG_FAIRY_SLINGSHOT) || CanUse(RG_FAIRY_BOW)));}}), Entrance(RR_ICE_CAVERN_MQ_COMPASS_ROOM, {[]{return IsAdult && BlueFire;}}), Entrance(RR_ICE_CAVERN_MQ_IRON_BOOTS_REGION, {[]{return BlueFire;}}), }); areaTable[RR_ICE_CAVERN_MQ_MAP_ROOM] = Area("Ice Cavern MQ Map Room", "Ice Cavern", RHT_ICE_CAVERN, NO_DAY_NIGHT_CYCLE, { //Events - EventAccess(&BlueFireAccess, {[]{return BlueFireAccess || HasBottle;}}), + EventAccess(&BlueFireAccess, {[]{return BlueFireAccess || (HasBottle && CanJumpslash);}}), }, { //Locations - LocationAccess(RC_ICE_CAVERN_MQ_MAP_CHEST, {[]{return BlueFire && (IsAdult || CanUse(RG_STICKS) || KokiriSword || CanUseProjectile);}}), + LocationAccess(RC_ICE_CAVERN_MQ_MAP_CHEST, {[]{return BlueFire && (CanJumpslash || CanUse(RG_MEGATON_HAMMER) || HasExplosives || CanUseProjectile);}}), }, {}); areaTable[RR_ICE_CAVERN_MQ_IRON_BOOTS_REGION] = Area("Ice Cavern MQ Iron Boots Region", "Ice Cavern", RHT_ICE_CAVERN, NO_DAY_NIGHT_CYCLE, {}, { //Locations - LocationAccess(RC_ICE_CAVERN_MQ_IRON_BOOTS_CHEST, {[]{return IsAdult;}}), - LocationAccess(RC_SHEIK_IN_ICE_CAVERN, {[]{return IsAdult;}}), - LocationAccess(RC_ICE_CAVERN_MQ_GS_ICE_BLOCK, {[]{return IsAdult || CanUseProjectile;}}), - LocationAccess(RC_ICE_CAVERN_MQ_GS_SCARECROW, {[]{return (CanUse(RG_SCARECROW) || (HoverBoots && CanUse(RG_LONGSHOT)) || LogicIceMQScarecrow) && IsAdult;}}), + LocationAccess(RC_ICE_CAVERN_MQ_IRON_BOOTS_CHEST, {[]{return IsAdult && (CanJumpslash || CanUse(RG_MEGATON_HAMMER));}}), + LocationAccess(RC_SHEIK_IN_ICE_CAVERN, {[]{return IsAdult && (CanJumpslash || CanUse(RG_MEGATON_HAMMER));}}), + LocationAccess(RC_ICE_CAVERN_MQ_GS_ICE_BLOCK, {[]{return CanAdultAttack || CanChildAttack;}}), + LocationAccess(RC_ICE_CAVERN_MQ_GS_SCARECROW, {[]{return CanUse(RG_SCARECROW) || (HoverBoots && CanUse(RG_LONGSHOT)) || (LogicIceMQScarecrow && IsAdult);}}), //Tricks: (CanUse(RG_SCARECROW) || (HoverBoots && CanUse(RG_LONGSHOT)) || LogicIceMQScarecrow) && IsAdult }, {}); diff --git a/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_jabujabus_belly.cpp b/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_jabujabus_belly.cpp index 8bfecf9cc..4c634135a 100644 --- a/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_jabujabus_belly.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_jabujabus_belly.cpp @@ -111,7 +111,7 @@ void AreaTable_Init_JabuJabusBelly() { areaTable[RR_JABU_JABUS_BELLY_COMPASS_ROOM] = Area("Jabu Jabus Belly Compass Room", "Jabu Jabus Belly", RHT_JABU_JABUS_BELLY, NO_DAY_NIGHT_CYCLE, {}, { //Locations - LocationAccess(RC_JABU_JABUS_BELLY_COMPASS_CHEST, {[]{return IsAdult || CanChildAttack;}}), + LocationAccess(RC_JABU_JABUS_BELLY_COMPASS_CHEST, {[]{return CanAdultAttack || CanChildAttack;}}), }, { //Exits Entrance(RR_JABU_JABUS_BELLY_FORKED_CORRIDOR, {[]{return true;}}), @@ -150,7 +150,7 @@ void AreaTable_Init_JabuJabusBelly() { areaTable[RR_JABU_JABUS_BELLY_NEAR_BOSS_ROOM] = Area("Jabu Jabus Belly Near Boss Room", "Jabu Jabus Belly", RHT_JABU_JABUS_BELLY, NO_DAY_NIGHT_CYCLE, {}, { //Locations - LocationAccess(RC_JABU_JABUS_BELLY_GS_NEAR_BOSS, {[]{return IsAdult || CanChildAttack;}}), + LocationAccess(RC_JABU_JABUS_BELLY_GS_NEAR_BOSS, {[]{return CanAdultAttack || CanChildAttack;}}), }, { //Exits Entrance(RR_JABU_JABUS_BELLY_LIFT_MIDDLE, {[]{return true;}}), diff --git a/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_kakariko.cpp b/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_kakariko.cpp index 0c4dd31fc..786bd19cc 100644 --- a/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_kakariko.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_kakariko.cpp @@ -190,7 +190,7 @@ void AreaTable_Init_Kakariko() { areaTable[RR_KAK_REDEAD_GROTTO] = Area("Kak Redead Grotto", "Kak Redead Grotto", RHT_NONE, NO_DAY_NIGHT_CYCLE, {}, { //Locations - LocationAccess(RC_KAK_REDEAD_GROTTO_CHEST, {[]{return IsAdult || (Sticks || KokiriSword || CanUse(RG_DINS_FIRE) || CanUse(RG_MEGATON_HAMMER) || CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD));}}), + LocationAccess(RC_KAK_REDEAD_GROTTO_CHEST, {[]{return CanUse(RG_STICKS) || CanUse(RG_KOKIRI_SWORD) || CanUse(RG_DINS_FIRE) || CanUse(RG_MEGATON_HAMMER) || CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD);}}), }, { //Exits Entrance(RR_KAKARIKO_VILLAGE, {[]{return true;}}), @@ -247,7 +247,7 @@ void AreaTable_Init_Kakariko() { areaTable[RR_GRAVEYARD_COMPOSERS_GRAVE] = Area("Graveyard Composers Grave", "Graveyard Composers Grave", RHT_NONE, NO_DAY_NIGHT_CYCLE, {}, { //Locations LocationAccess(RC_GRAVEYARD_ROYAL_FAMILYS_TOMB_CHEST, {[]{return HasFireSource;}}), - LocationAccess(RC_SONG_FROM_ROYAL_FAMILYS_TOMB, {[]{return IsAdult || (Slingshot || Boomerang || Sticks || HasExplosives || KokiriSword || CanUse(RG_MEGATON_HAMMER) || CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD) || CanUse(RG_FAIRY_BOW) || CanUse(RG_HOOKSHOT));}}), + LocationAccess(RC_SONG_FROM_ROYAL_FAMILYS_TOMB, {[]{return CanUseProjectile || CanJumpslash || CanUse(RG_MEGATON_HAMMER);}}), }, { //Exits Entrance(RR_THE_GRAVEYARD, {[]{return true;}}), @@ -267,7 +267,10 @@ void AreaTable_Init_Kakariko() { Entrance(RR_KAK_WINDMILL, {[]{return IsAdult && CanPlay(SongOfTime);}}), }); - areaTable[RR_GRAVEYARD_DAMPES_HOUSE] = Area("Graveyard Dampes House", "Graveyard Dampes House", RHT_NONE, NO_DAY_NIGHT_CYCLE, {}, {}, { + areaTable[RR_GRAVEYARD_DAMPES_HOUSE] = Area("Graveyard Dampes House", "Graveyard Dampes House", RHT_NONE, NO_DAY_NIGHT_CYCLE, {}, { + //Locations + LocationAccess(RC_DAMPE_HINT, {[]{return IsAdult;}}), + }, { //Exits Entrance(RR_THE_GRAVEYARD, {[]{return true;}}), }); @@ -284,7 +287,7 @@ void AreaTable_Init_Kakariko() { Entrance(RR_SHADOW_TEMPLE_ENTRYWAY, {[]{return CanUse(RG_DINS_FIRE) || (LogicShadowFireArrowEntry && IsAdult && CanUse(RG_FIRE_ARROWS));}}), }); - areaTable[RR_KAK_BEHIND_GATE] = Area("Kak Behind Gate", "Kakariko Village", RHT_NONE, NO_DAY_NIGHT_CYCLE, {}, {}, { + areaTable[RR_KAK_BEHIND_GATE] = Area("Kak Behind Gate", "Kakariko Village", RHT_KAKARIKO_VILLAGE, NO_DAY_NIGHT_CYCLE, {}, {}, { //Exits Entrance(RR_KAKARIKO_VILLAGE, {[]{return IsAdult || LogicVisibleCollision || KakarikoVillageGateOpen || OpenKakariko.Is(OPENKAKARIKO_OPEN);}}), Entrance(RR_DEATH_MOUNTAIN_TRAIL, {[]{return true;}}), diff --git a/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_lost_woods.cpp b/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_lost_woods.cpp index e3b073ba4..833c8eebf 100644 --- a/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_lost_woods.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_lost_woods.cpp @@ -34,8 +34,8 @@ void AreaTable_Init_LostWoods() { areaTable[RR_KF_OUTSIDE_DEKU_TREE] = Area("KF Outside Deku Tree", "Kokiri Forest", RHT_KOKIRI_FOREST, NO_DAY_NIGHT_CYCLE, { //Events - EventAccess(&DekuBabaSticks, {[]{return DekuBabaSticks || ((IsAdult && ShuffleDungeonEntrances.Is(SHUFFLEDUNGEONS_OFF)) || KokiriSword || Boomerang);}}), - EventAccess(&DekuBabaNuts, {[]{return DekuBabaNuts || ((IsAdult && ShuffleDungeonEntrances.Is(SHUFFLEDUNGEONS_OFF)) || KokiriSword || Slingshot || Sticks || HasExplosives || CanUse(RG_DINS_FIRE));}}), + EventAccess(&DekuBabaSticks, {[]{return DekuBabaSticks || ((IsAdult && (CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD) || CanUse(RG_KOKIRI_SWORD)) && !ShuffleEntrances) || (IsChild && (CanUse(RG_KOKIRI_SWORD) || CanUse(RG_BIGGORON_SWORD) || CanUse(RG_MASTER_SWORD) || CanUse(RG_BOOMERANG))));}}), + EventAccess(&DekuBabaNuts, {[]{return DekuBabaNuts || ((IsAdult && (CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD) || CanUse(RG_KOKIRI_SWORD)) && !ShuffleEntrances) || (IsChild && (CanJumpslash || CanUse(RG_FAIRY_SLINGSHOT) || HasExplosives || CanUse(RG_DINS_FIRE))));}}), EventAccess(&ShowedMidoSwordAndShield, {[]{return ShowedMidoSwordAndShield || (IsChild && KokiriSword && DekuShield);}}), }, { //Locations @@ -105,7 +105,7 @@ void AreaTable_Init_LostWoods() { Entrance(RR_KOKIRI_FOREST, {[]{return true;}}) }); - areaTable[RR_LW_FOREST_EXIT] = Area("LW Forest Exit", "Lost Woods", RHT_NONE, NO_DAY_NIGHT_CYCLE, {}, {}, { + areaTable[RR_LW_FOREST_EXIT] = Area("LW Forest Exit", "Lost Woods", RHT_THE_LOST_WOODS, NO_DAY_NIGHT_CYCLE, {}, {}, { //Exits Entrance(RR_KOKIRI_FOREST, {[]{return true;}}) }); @@ -144,7 +144,7 @@ void AreaTable_Init_LostWoods() { //Locations LocationAccess(RC_LW_DEKU_SCRUB_NEAR_DEKU_THEATER_RIGHT, {[]{return IsChild && CanStunDeku;}}), LocationAccess(RC_LW_DEKU_SCRUB_NEAR_DEKU_THEATER_LEFT, {[]{return IsChild && CanStunDeku;}}), - LocationAccess(RC_LW_GS_ABOVE_THEATER, {[]{return IsAdult && AtNight && (CanPlantBean(RR_LW_BEYOND_MIDO) || (LogicLostWoodsGSBean && CanUse(RG_HOOKSHOT) && (CanUse(RG_LONGSHOT) || CanUse(RG_FAIRY_BOW) || CanUse(RG_FAIRY_SLINGSHOT) || HasBombchus || CanUse(RG_DINS_FIRE)))) && CanGetNightTimeGS;}}), + LocationAccess(RC_LW_GS_ABOVE_THEATER, {[]{return IsAdult && AtNight && ((CanPlantBean(RR_LW_BEYOND_MIDO) && CanAdultAttack) || (LogicLostWoodsGSBean && CanUse(RG_HOOKSHOT) && (CanUse(RG_LONGSHOT) || CanUse(RG_FAIRY_BOW) || CanUse(RG_FAIRY_SLINGSHOT) || HasBombchus || CanUse(RG_DINS_FIRE)))) && CanGetNightTimeGS;}}), LocationAccess(RC_LW_GS_BEAN_PATCH_NEAR_THEATER, {[]{return CanPlantBugs && (CanChildAttack || (Scrubsanity.Is(SCRUBSANITY_OFF) && DekuShield));}}), }, { //Exits @@ -185,7 +185,7 @@ void AreaTable_Init_LostWoods() { areaTable[RR_SFM_ENTRYWAY] = Area("SFM Entryway", "Sacred Forest Meadow", RHT_SACRED_FOREST_MEADOW, NO_DAY_NIGHT_CYCLE, {}, {}, { //Exits Entrance(RR_LW_BEYOND_MIDO, {[]{return true;}}), - Entrance(RR_SACRED_FOREST_MEADOW, {[]{return IsAdult || Slingshot || Sticks || KokiriSword || CanUse(RG_DINS_FIRE) || CanUse(RG_MEGATON_HAMMER) || CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD);}}), + Entrance(RR_SACRED_FOREST_MEADOW, {[]{return CanJumpslash || CanUse(RG_FAIRY_SLINGSHOT) || CanUse(RG_FAIRY_BOW) || CanUse(RG_DINS_FIRE) || CanUse(RG_MEGATON_HAMMER);}}), Entrance(RR_SFM_WOLFOS_GROTTO, {[]{return CanOpenBombGrotto;}}), }); diff --git a/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_shadow_temple.cpp b/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_shadow_temple.cpp index 36d85897b..94aded196 100644 --- a/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_shadow_temple.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_shadow_temple.cpp @@ -26,12 +26,12 @@ void AreaTable_Init_ShadowTemple() { EventAccess(&NutPot, {[]{return true;}}), }, { //Locations - LocationAccess(RC_SHADOW_TEMPLE_MAP_CHEST, {[]{return true;}}), - LocationAccess(RC_SHADOW_TEMPLE_HOVER_BOOTS_CHEST, {[]{return true;}}), + LocationAccess(RC_SHADOW_TEMPLE_MAP_CHEST, {[]{return CanJumpslash;}}), + LocationAccess(RC_SHADOW_TEMPLE_HOVER_BOOTS_CHEST, {[]{return (CanUse(RG_KOKIRI_SWORD) || CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD));}}), }, { //Exits Entrance(RR_SHADOW_TEMPLE_ENTRYWAY, {[]{return true;}}), - Entrance(RR_SHADOW_TEMPLE_FIRST_BEAMOS, {[]{return HoverBoots;}}), + Entrance(RR_SHADOW_TEMPLE_FIRST_BEAMOS, {[]{return CanUse(RG_HOVER_BOOTS);}}), }); areaTable[RR_SHADOW_TEMPLE_FIRST_BEAMOS] = Area("Shadow Temple First Beamos", "Shadow Temple", RHT_SHADOW_TEMPLE, NO_DAY_NIGHT_CYCLE, { @@ -39,7 +39,7 @@ void AreaTable_Init_ShadowTemple() { EventAccess(&FairyPot, {[]{return true;}}), //This fairy pot is only on 3DS }, { //Locations - LocationAccess(RC_SHADOW_TEMPLE_COMPASS_CHEST, {[]{return IsAdult || KokiriSword || Sticks;}}), + LocationAccess(RC_SHADOW_TEMPLE_COMPASS_CHEST, {[]{return CanJumpslash;}}), LocationAccess(RC_SHADOW_TEMPLE_EARLY_SILVER_RUPEE_CHEST, {[]{return CanUse(RG_HOVER_BOOTS) || CanUse(RG_HOOKSHOT);}}), LocationAccess(RC_SHADOW_TEMPLE_GS_NEAR_SHIP, {[]{return false;}}), }, { @@ -50,14 +50,14 @@ void AreaTable_Init_ShadowTemple() { areaTable[RR_SHADOW_TEMPLE_HUGE_PIT] = Area("Shadow Temple Huge Pit", "Shadow Temple", RHT_SHADOW_TEMPLE, NO_DAY_NIGHT_CYCLE, {}, { //Locations - LocationAccess(RC_SHADOW_TEMPLE_INVISIBLE_BLADES_VISIBLE_CHEST, {[]{return true;}}), - LocationAccess(RC_SHADOW_TEMPLE_INVISIBLE_BLADES_INVISIBLE_CHEST, {[]{return true;}}), + LocationAccess(RC_SHADOW_TEMPLE_INVISIBLE_BLADES_VISIBLE_CHEST, {[]{return CanJumpslash;}}), + LocationAccess(RC_SHADOW_TEMPLE_INVISIBLE_BLADES_INVISIBLE_CHEST, {[]{return CanJumpslash;}}), LocationAccess(RC_SHADOW_TEMPLE_FALLING_SPIKES_LOWER_CHEST, {[]{return true;}}), LocationAccess(RC_SHADOW_TEMPLE_FALLING_SPIKES_UPPER_CHEST, {[]{return (LogicShadowUmbrella && HoverBoots) || GoronBracelet;}}), LocationAccess(RC_SHADOW_TEMPLE_FALLING_SPIKES_SWITCH_CHEST, {[]{return (LogicShadowUmbrella && HoverBoots) || GoronBracelet;}}), LocationAccess(RC_SHADOW_TEMPLE_INVISIBLE_SPIKES_CHEST, {[]{return SmallKeys(RR_SHADOW_TEMPLE, 2, 3) && ((LogicLensShadowPlatform && LogicLensShadow) || CanUse(RG_LENS_OF_TRUTH));}}), LocationAccess(RC_SHADOW_TEMPLE_FREESTANDING_KEY, {[]{return SmallKeys(RR_SHADOW_TEMPLE, 2, 3) && ((LogicLensShadowPlatform && LogicLensShadow) || CanUse(RG_LENS_OF_TRUTH)) && Hookshot && (Bombs || GoronBracelet || (LogicShadowFreestandingKey && HasBombchus));}}), - LocationAccess(RC_SHADOW_TEMPLE_GS_LIKE_LIKE_ROOM, {[]{return true;}}), + LocationAccess(RC_SHADOW_TEMPLE_GS_LIKE_LIKE_ROOM, {[]{return CanJumpslash;}}), LocationAccess(RC_SHADOW_TEMPLE_GS_FALLING_SPIKES_ROOM, {[]{return Hookshot || (LogicShadowUmbrellaGS && HoverBoots);}}), LocationAccess(RC_SHADOW_TEMPLE_GS_SINGLE_GIANT_POT, {[]{return SmallKeys(RR_SHADOW_TEMPLE, 2, 3) && ((LogicLensShadowPlatform && LogicLensShadow) || CanUse(RG_LENS_OF_TRUTH)) && Hookshot;}}), }, { @@ -68,20 +68,20 @@ void AreaTable_Init_ShadowTemple() { areaTable[RR_SHADOW_TEMPLE_WIND_TUNNEL] = Area("Shadow Temple Wind Tunnel", "Shadow Temple", RHT_SHADOW_TEMPLE, NO_DAY_NIGHT_CYCLE, {}, { //Locations LocationAccess(RC_SHADOW_TEMPLE_WIND_HINT_CHEST, {[]{return true;}}), - LocationAccess(RC_SHADOW_TEMPLE_AFTER_WIND_ENEMY_CHEST, {[]{return true;}}), + LocationAccess(RC_SHADOW_TEMPLE_AFTER_WIND_ENEMY_CHEST, {[]{return CanJumpslash;}}), LocationAccess(RC_SHADOW_TEMPLE_AFTER_WIND_HIDDEN_CHEST, {[]{return true;}}), LocationAccess(RC_SHADOW_TEMPLE_GS_NEAR_SHIP, {[]{return CanUse(RG_LONGSHOT) && SmallKeys(RR_SHADOW_TEMPLE, 4, 5);}}), }, { //Exits - Entrance(RR_SHADOW_TEMPLE_BEYOND_BOAT, {[]{return CanPlay(ZeldasLullaby) && SmallKeys(RR_SHADOW_TEMPLE, 4, 5);}}), + Entrance(RR_SHADOW_TEMPLE_BEYOND_BOAT, {[]{return CanJumpslash && CanPlay(ZeldasLullaby) && SmallKeys(RR_SHADOW_TEMPLE, 4, 5);}}), }); areaTable[RR_SHADOW_TEMPLE_BEYOND_BOAT] = Area("Shadow Temple Beyond Boat", "Shadow Temple", RHT_SHADOW_TEMPLE, NO_DAY_NIGHT_CYCLE, {}, { //Locations LocationAccess(RC_SHADOW_TEMPLE_SPIKE_WALLS_LEFT_CHEST, {[]{return CanUse(RG_DINS_FIRE);}}), LocationAccess(RC_SHADOW_TEMPLE_BOSS_KEY_CHEST, {[]{return CanUse(RG_DINS_FIRE);}}), - LocationAccess(RC_SHADOW_TEMPLE_INVISIBLE_FLOORMASTER_CHEST, {[]{return true;}}), - LocationAccess(RC_SHADOW_TEMPLE_GS_TRIPLE_GIANT_POT, {[]{return true;}}), + LocationAccess(RC_SHADOW_TEMPLE_INVISIBLE_FLOORMASTER_CHEST, {[]{return CanJumpslash;}}), + LocationAccess(RC_SHADOW_TEMPLE_GS_TRIPLE_GIANT_POT, {[]{return CanAdultAttack;}}), }, { //Exits Entrance(RR_SHADOW_TEMPLE_BOSS_ENTRYWAY, {[]{return (CanUse(RG_FAIRY_BOW) || CanUse(RG_DISTANT_SCARECROW) || (LogicShadowStatue && HasBombchus)) && SmallKeys(RR_SHADOW_TEMPLE, 5) && CanUse(RG_HOVER_BOOTS) && BossKeyShadowTemple;}}) @@ -102,15 +102,15 @@ void AreaTable_Init_ShadowTemple() { areaTable[RR_SHADOW_TEMPLE_MQ_DEAD_HAND_AREA] = Area("Shadow Temple MQ Dead Hand Area", "Shadow Temple", RHT_SHADOW_TEMPLE, NO_DAY_NIGHT_CYCLE, {}, { //Locations - LocationAccess(RC_SHADOW_TEMPLE_MQ_COMPASS_CHEST, {[]{return true;}}), - LocationAccess(RC_SHADOW_TEMPLE_MQ_HOVER_BOOTS_CHEST, {[]{return CanPlay(SongOfTime) && IsAdult && CanUse(RG_FAIRY_BOW);}}), + LocationAccess(RC_SHADOW_TEMPLE_MQ_COMPASS_CHEST, {[]{return CanJumpslash;}}), + LocationAccess(RC_SHADOW_TEMPLE_MQ_HOVER_BOOTS_CHEST, {[]{return CanJumpslash && CanPlay(SongOfTime) && IsAdult && CanUse(RG_FAIRY_BOW);}}), }, {}); areaTable[RR_SHADOW_TEMPLE_MQ_FIRST_BEAMOS] = Area("Shadow Temple MQ First Beamos", "Shadow Temple", RHT_SHADOW_TEMPLE, NO_DAY_NIGHT_CYCLE, {}, { //Locations - LocationAccess(RC_SHADOW_TEMPLE_MQ_MAP_CHEST, {[]{return true;}}), - LocationAccess(RC_SHADOW_TEMPLE_MQ_EARLY_GIBDOS_CHEST, {[]{return true;}}), - LocationAccess(RC_SHADOW_TEMPLE_MQ_NEAR_SHIP_INVISIBLE_CHEST, {[]{return true;}}), + LocationAccess(RC_SHADOW_TEMPLE_MQ_MAP_CHEST, {[]{return CanAdultAttack || Nuts;}}), + LocationAccess(RC_SHADOW_TEMPLE_MQ_EARLY_GIBDOS_CHEST, {[]{return CanJumpslash;}}), + LocationAccess(RC_SHADOW_TEMPLE_MQ_NEAR_SHIP_INVISIBLE_CHEST, {[]{return CanAdultAttack || Nuts;}}), }, { //Exits Entrance(RR_SHADOW_TEMPLE_MQ_UPPER_HUGE_PIT, {[]{return HasExplosives && SmallKeys(RR_SHADOW_TEMPLE, 2);}}), @@ -134,8 +134,9 @@ void AreaTable_Init_ShadowTemple() { LocationAccess(RC_SHADOW_TEMPLE_MQ_FALLING_SPIKES_LOWER_CHEST, {[]{return true;}}), LocationAccess(RC_SHADOW_TEMPLE_MQ_FALLING_SPIKES_UPPER_CHEST, {[]{return (LogicShadowUmbrella && HoverBoots) || GoronBracelet;}}), LocationAccess(RC_SHADOW_TEMPLE_MQ_FALLING_SPIKES_SWITCH_CHEST, {[]{return (LogicShadowUmbrella && HoverBoots) || GoronBracelet;}}), - LocationAccess(RC_SHADOW_TEMPLE_MQ_INVISIBLE_SPIKES_CHEST, {[]{return HoverBoots && SmallKeys(RR_SHADOW_TEMPLE, 3) && ((LogicLensShadowMQ && LogicLensShadowMQPlatform) || CanUse(RG_LENS_OF_TRUTH));}}), - LocationAccess(RC_SHADOW_TEMPLE_MQ_STALFOS_ROOM_CHEST, {[]{return HoverBoots && SmallKeys(RR_SHADOW_TEMPLE, 3) && Hookshot && ((LogicLensShadowMQ && LogicLensShadowMQInvisibleBlades && LogicLensShadowMQPlatform) || CanUse(RG_LENS_OF_TRUTH));}}), + LocationAccess(RC_SHADOW_TEMPLE_MQ_INVISIBLE_SPIKES_CHEST, {[]{return CanJumpslash && HoverBoots && SmallKeys(RR_SHADOW_TEMPLE, 3) && ((LogicLensShadowMQ && LogicLensShadowMQPlatform) || CanUse(RG_LENS_OF_TRUTH));}}), + LocationAccess(RC_SHADOW_TEMPLE_MQ_STALFOS_ROOM_CHEST, {[]{return (CanUse(RG_KOKIRI_SWORD) || CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD)) && HoverBoots && SmallKeys(RR_SHADOW_TEMPLE, 3) && Hookshot && ((LogicLensShadowMQ && + LogicLensShadowMQInvisibleBlades && LogicLensShadowMQPlatform) || CanUse(RG_LENS_OF_TRUTH));}}), LocationAccess(RC_SHADOW_TEMPLE_MQ_GS_FALLING_SPIKES_ROOM, {[]{return Hookshot || (LogicShadowUmbrellaGS && HoverBoots);}}), }, { //Exits @@ -148,7 +149,7 @@ void AreaTable_Init_ShadowTemple() { }, { //Locations LocationAccess(RC_SHADOW_TEMPLE_MQ_WIND_HINT_CHEST, {[]{return true;}}), - LocationAccess(RC_SHADOW_TEMPLE_MQ_AFTER_WIND_ENEMY_CHEST, {[]{return true;}}), + LocationAccess(RC_SHADOW_TEMPLE_MQ_AFTER_WIND_ENEMY_CHEST, {[]{return CanJumpslash;}}), LocationAccess(RC_SHADOW_TEMPLE_MQ_AFTER_WIND_HIDDEN_CHEST, {[]{return true;}}), LocationAccess(RC_SHADOW_TEMPLE_MQ_GS_WIND_HINT_ROOM, {[]{return true;}}), LocationAccess(RC_SHADOW_TEMPLE_MQ_GS_AFTER_WIND, {[]{return true;}}), diff --git a/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_spirit_temple.cpp b/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_spirit_temple.cpp index c1a361992..b0991705f 100644 --- a/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_spirit_temple.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_spirit_temple.cpp @@ -46,9 +46,9 @@ void AreaTable_Init_SpiritTemple() { LocationAccess(RC_SPIRIT_TEMPLE_CHILD_CLIMB_NORTH_CHEST, {[]{return HasProjectile(HasProjectileAge::Both) || ((SmallKeys(RR_SPIRIT_TEMPLE, 3) || (SmallKeys(RR_SPIRIT_TEMPLE, 2) && BombchusInLogic && ShuffleDungeonEntrances.Is(SHUFFLEDUNGEONS_OFF))) && CanUse(RG_SILVER_GAUNTLETS) && HasProjectile(HasProjectileAge::Adult)) || (SmallKeys(RR_SPIRIT_TEMPLE, 5) && IsChild && HasProjectile(HasProjectileAge::Child));}}), LocationAccess(RC_SPIRIT_TEMPLE_CHILD_CLIMB_EAST_CHEST, {[]{return HasProjectile(HasProjectileAge::Both) || ((SmallKeys(RR_SPIRIT_TEMPLE, 3) || (SmallKeys(RR_SPIRIT_TEMPLE, 2) && BombchusInLogic && ShuffleDungeonEntrances.Is(SHUFFLEDUNGEONS_OFF))) && CanUse(RG_SILVER_GAUNTLETS) && HasProjectile(HasProjectileAge::Adult)) || (SmallKeys(RR_SPIRIT_TEMPLE, 5) && IsChild && HasProjectile(HasProjectileAge::Child));}}), LocationAccess(RC_SPIRIT_TEMPLE_GS_SUN_ON_FLOOR_ROOM, {[]{return HasProjectile(HasProjectileAge::Both) || CanUse(RG_DINS_FIRE) || - (CanTakeDamage && (Sticks || KokiriSword || HasProjectile(HasProjectileAge::Child))) || + (CanTakeDamage && (CanJumpslash || HasProjectile(HasProjectileAge::Child))) || (IsChild && SmallKeys(RR_SPIRIT_TEMPLE, 5) && HasProjectile(HasProjectileAge::Child)) || - ((SmallKeys(RR_SPIRIT_TEMPLE, 3) || (SmallKeys(RR_SPIRIT_TEMPLE, 2) && BombchusInLogic && ShuffleDungeonEntrances.Is(SHUFFLEDUNGEONS_OFF))) && CanUse(RG_SILVER_GAUNTLETS) && (HasProjectile(HasProjectileAge::Adult) || CanTakeDamage));}}), + ((SmallKeys(RR_SPIRIT_TEMPLE, 3) || (SmallKeys(RR_SPIRIT_TEMPLE, 2) && BombchusInLogic && ShuffleDungeonEntrances.Is(SHUFFLEDUNGEONS_OFF))) && CanUse(RG_SILVER_GAUNTLETS) && (HasProjectile(HasProjectileAge::Adult) || (CanTakeDamage && CanJumpslash)));}}), }, { //Exits Entrance(RR_SPIRIT_TEMPLE_CENTRAL_CHAMBER, {[]{return HasExplosives || (SunlightArrows && CanUse(RG_LIGHT_ARROWS));}}), @@ -57,7 +57,7 @@ void AreaTable_Init_SpiritTemple() { areaTable[RR_SPIRIT_TEMPLE_EARLY_ADULT] = Area("Early Adult Spirit Temple", "Spirit Temple", RHT_SPIRIT_TEMPLE, NO_DAY_NIGHT_CYCLE, {}, { //Locations LocationAccess(RC_SPIRIT_TEMPLE_COMPASS_CHEST, {[]{return CanUse(RG_HOOKSHOT) && CanPlay(ZeldasLullaby);}}), - LocationAccess(RC_SPIRIT_TEMPLE_EARLY_ADULT_RIGHT_CHEST, {[]{return Bow || Hookshot || HasBombchus || (Bombs && LogicSpiritLowerAdultSwitch);}}), + LocationAccess(RC_SPIRIT_TEMPLE_EARLY_ADULT_RIGHT_CHEST, {[]{return (CanUse(RG_FAIRY_BOW) || CanUse(RG_HOOKSHOT) || CanUse(RG_FAIRY_SLINGSHOT) || CanUse(RG_BOOMERANG) || HasBombchus || (Bombs && IsAdult && LogicSpiritLowerAdultSwitch)) && (CanUse(RG_HOVER_BOOTS) || CanJumpslash);}}), LocationAccess(RC_SPIRIT_TEMPLE_FIRST_MIRROR_LEFT_CHEST, {[]{return SmallKeys(RR_SPIRIT_TEMPLE, 3);}}), LocationAccess(RC_SPIRIT_TEMPLE_FIRST_MIRROR_RIGHT_CHEST, {[]{return SmallKeys(RR_SPIRIT_TEMPLE, 3);}}), LocationAccess(RC_SPIRIT_TEMPLE_GS_BOULDER_ROOM, {[]{return CanPlay(SongOfTime) && (Bow || Hookshot || HasBombchus || (Bombs && LogicSpiritLowerAdultSwitch));}}), @@ -98,7 +98,7 @@ void AreaTable_Init_SpiritTemple() { (SmallKeys(RR_SPIRIT_TEMPLE, 3) && CanUse(RG_SILVER_GAUNTLETS) && (Hookshot || HoverBoots || LogicSpiritLobbyJump));}}), }, { //Exits - Entrance(RR_SPIRIT_TEMPLE_OUTDOOR_HANDS, {[]{return true;}}), + Entrance(RR_SPIRIT_TEMPLE_OUTDOOR_HANDS, {[]{return CanJumpslash || HasExplosives;}}), Entrance(RR_SPIRIT_TEMPLE_BEYOND_CENTRAL_LOCKED_DOOR, {[]{return SmallKeys(RR_SPIRIT_TEMPLE, 4) && CanUse(RG_SILVER_GAUNTLETS);}}), Entrance(RR_SPIRIT_TEMPLE_CHILD_CLIMB, {[]{return true;}}), }); @@ -125,7 +125,7 @@ void AreaTable_Init_SpiritTemple() { areaTable[RR_SPIRIT_TEMPLE_BEYOND_FINAL_LOCKED_DOOR] = Area("Spirit Temple Beyond Final Locked Door", "Spirit Temple", RHT_SPIRIT_TEMPLE, NO_DAY_NIGHT_CYCLE, {}, { //Locations LocationAccess(RC_SPIRIT_TEMPLE_BOSS_KEY_CHEST, {[]{return CanPlay(ZeldasLullaby) && ((CanTakeDamage && LogicFlamingChests) || (Bow && Hookshot));}}), - LocationAccess(RC_SPIRIT_TEMPLE_TOPMOST_CHEST, {[]{return MirrorShield || (SunlightArrows && CanUse(RG_LIGHT_ARROWS));}}), + LocationAccess(RC_SPIRIT_TEMPLE_TOPMOST_CHEST, {[]{return (MirrorShield && CanAdultAttack) || (SunlightArrows && CanUse(RG_LIGHT_ARROWS));}}), }, { //Exits Entrance(RR_SPIRIT_TEMPLE_INSIDE_STATUE_HEAD, {[]{return MirrorShield && HasExplosives && Hookshot;}}), @@ -174,7 +174,7 @@ void AreaTable_Init_SpiritTemple() { areaTable[RR_SPIRIT_TEMPLE_MQ_ADULT] = Area("Spirit Temple MQ Adult", "Spirit Temple", RHT_SPIRIT_TEMPLE, NO_DAY_NIGHT_CYCLE, {}, { //Locations LocationAccess(RC_SPIRIT_TEMPLE_MQ_CHILD_CLIMB_SOUTH_CHEST, {[]{return SmallKeys(RR_SPIRIT_TEMPLE, 7);}}), - LocationAccess(RC_SPIRIT_TEMPLE_MQ_STATUE_ROOM_LULLABY_CHEST, {[]{return CanPlay(ZeldasLullaby);}}), + LocationAccess(RC_SPIRIT_TEMPLE_MQ_STATUE_ROOM_LULLABY_CHEST, {[]{return CanPlay(ZeldasLullaby) && (CanJumpslash || CanUse(RG_HOVER_BOOTS));}}), LocationAccess(RC_SPIRIT_TEMPLE_MQ_STATUE_ROOM_INVISIBLE_CHEST, {[]{return (LogicLensSpiritMQ || CanUse(RG_LENS_OF_TRUTH));}}), LocationAccess(RC_SPIRIT_TEMPLE_MQ_BEAMOS_ROOM_CHEST, {[]{return SmallKeys(RR_SPIRIT_TEMPLE, 5);}}), LocationAccess(RC_SPIRIT_TEMPLE_MQ_CHEST_SWITCH_CHEST, {[]{return SmallKeys(RR_SPIRIT_TEMPLE, 5) && CanPlay(SongOfTime);}}), @@ -187,7 +187,7 @@ void AreaTable_Init_SpiritTemple() { //Trick: MirrorShield && IsAdult && (CanUse(RG_FIRE_ARROWS) || (LogicSpiritMQLowerAdult && CanUse(RG_DINS_FIRE) && Bow)) Entrance(RR_SPIRIT_TEMPLE_MQ_SHARED, {[]{return true;}}), Entrance(RR_SPIRIT_TEMPLE_MQ_BOSS_AREA, {[]{return SmallKeys(RR_SPIRIT_TEMPLE, 6) && CanPlay(ZeldasLullaby) && Hammer;}}), - Entrance(RR_SPIRIT_TEMPLE_MQ_MIRROR_SHIELD_HAND, {[]{return SmallKeys(RR_SPIRIT_TEMPLE, 5) && CanPlay(SongOfTime) && (LogicLensSpiritMQ || CanUse(RG_LENS_OF_TRUTH));}}), + Entrance(RR_SPIRIT_TEMPLE_MQ_MIRROR_SHIELD_HAND, {[]{return SmallKeys(RR_SPIRIT_TEMPLE, 5) && CanPlay(SongOfTime) && CanJumpslash && (LogicLensSpiritMQ || CanUse(RG_LENS_OF_TRUTH));}}), }); areaTable[RR_SPIRIT_TEMPLE_MQ_SHARED] = Area("Spirit Temple MQ Shared", "Spirit Temple", RHT_SPIRIT_TEMPLE, NO_DAY_NIGHT_CYCLE, {}, { @@ -200,9 +200,9 @@ void AreaTable_Init_SpiritTemple() { //Trick: (LogicSpiritMQSunBlockGS && Boomerang && (CanPlay(SongOfTime) || LogicSpiritMQSunBlockSoT)) || IsAdult }, { //Exits - Entrance(RR_SPIRIT_TEMPLE_MQ_SILVER_GAUNTLETS_HAND, {[]{return (SmallKeys(RR_SPIRIT_TEMPLE, 7) && (CanPlay(SongOfTime) || LogicSpiritMQSunBlockSoT || IsAdult)) || (SmallKeys(RR_SPIRIT_TEMPLE, 4) && CanPlay(SongOfTime) && (LogicLensSpiritMQ || CanUse(RG_LENS_OF_TRUTH)));}}), + Entrance(RR_SPIRIT_TEMPLE_MQ_SILVER_GAUNTLETS_HAND, {[]{return (SmallKeys(RR_SPIRIT_TEMPLE, 7) && (CanPlay(SongOfTime) || LogicSpiritMQSunBlockSoT || IsAdult)) || (SmallKeys(RR_SPIRIT_TEMPLE, 4) && CanPlay(SongOfTime) && CanJumpslash && (LogicLensSpiritMQ || CanUse(RG_LENS_OF_TRUTH)));}}), //Trick: (SmallKeys(RR_SPIRIT_TEMPLE, 7) && (CanPlay(SongOfTime) || LogicSpiritMQSunBlockSoT || IsAdult)) || (SmallKeys(RR_SPIRIT_TEMPLE, 4) && CanPlay(SongOfTime) && (LogicLensSpiritMQ || CanUse(RG_LENS_OF_TRUTH))) - Entrance(RR_DESERT_COLOSSUS, {[]{return (SmallKeys(RR_SPIRIT_TEMPLE, 7) && (CanPlay(SongOfTime) || LogicSpiritMQSunBlockSoT || IsAdult)) || (SmallKeys(RR_SPIRIT_TEMPLE, 4) && CanPlay(SongOfTime) && (LogicLensSpiritMQ || CanUse(RG_LENS_OF_TRUTH)) && IsAdult);}}), + Entrance(RR_DESERT_COLOSSUS, {[]{return (SmallKeys(RR_SPIRIT_TEMPLE, 7) && (CanPlay(SongOfTime) || LogicSpiritMQSunBlockSoT || IsAdult)) || (SmallKeys(RR_SPIRIT_TEMPLE, 4) && CanPlay(SongOfTime) && CanJumpslash && (LogicLensSpiritMQ || CanUse(RG_LENS_OF_TRUTH)) && IsAdult);}}), //Trick: (SmallKeys(RR_SPIRIT_TEMPLE, 7) && (CanPlay(SongOfTime) || LogicSpiritMQSunBlockSoT || IsAdult)) || (SmallKeys(RR_SPIRIT_TEMPLE, 4) && CanPlay(SongOfTime) && (LogicLensSpiritMQ || CanUse(RG_LENS_OF_TRUTH)) && IsAdult) }); diff --git a/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_water_temple.cpp b/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_water_temple.cpp index 6a4ea6c8d..d41dc64c9 100644 --- a/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_water_temple.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_water_temple.cpp @@ -122,7 +122,7 @@ void AreaTable_Init_WaterTemple() { areaTable[RR_WATER_TEMPLE_SOUTH_LOWER] = Area("Water Temple South Lower", "Water Temple", RHT_WATER_TEMPLE, NO_DAY_NIGHT_CYCLE, {}, { //Locations - LocationAccess(RC_WATER_TEMPLE_GS_BEHIND_GATE, {[]{return CanUse(RG_HOOKSHOT) || (IsAdult && CanUse(RG_HOVER_BOOTS));}}), + LocationAccess(RC_WATER_TEMPLE_GS_BEHIND_GATE, {[]{return (CanJumpslash || CanUse(RG_MEGATON_HAMMER)) && (CanUse(RG_HOOKSHOT) || (IsAdult && CanUse(RG_HOVER_BOOTS)));}}), }, { //Exits Entrance(RR_WATER_TEMPLE_LOBBY, {[]{return CanUse(RG_IRON_BOOTS);}}), @@ -131,7 +131,7 @@ void AreaTable_Init_WaterTemple() { areaTable[RR_WATER_TEMPLE_WEST_LOWER] = Area("Water Temple West Lower", "Water Temple", RHT_WATER_TEMPLE, NO_DAY_NIGHT_CYCLE, {}, {}, { //Exits Entrance(RR_WATER_TEMPLE_LOBBY, {[]{return CanUse(RG_HOOKSHOT) && CanUse(RG_IRON_BOOTS) && GoronBracelet;}}), - Entrance(RR_WATER_TEMPLE_DRAGON_ROOM, {[]{return IsAdult || CanChildAttack;}}), + Entrance(RR_WATER_TEMPLE_DRAGON_ROOM, {[]{return CanJumpslash || CanUseProjectile;}}), }); areaTable[RR_WATER_TEMPLE_DRAGON_ROOM] = Area("Water Temple Dragon Room", "Water Temple", RHT_WATER_TEMPLE, NO_DAY_NIGHT_CYCLE, {}, { @@ -257,8 +257,8 @@ void AreaTable_Init_WaterTemple() { //Exits Entrance(RR_WATER_TEMPLE_ENTRYWAY, {[]{return true;}}), Entrance(RR_WATER_TEMPLE_MQ_DIVE, {[]{return IsAdult && WaterTimer >= 24 && CanUse(RG_IRON_BOOTS);}}), - Entrance(RR_WATER_TEMPLE_MQ_DARK_LINK_REGION, {[]{return SmallKeys(RR_WATER_TEMPLE, 1) && IsAdult && CanUse(RG_LONGSHOT);}}), - Entrance(RR_WATER_TEMPLE_BOSS_ENTRYWAY, {[]{return BossKeyWaterTemple && IsAdult && CanUse(RG_LONGSHOT);}}), + Entrance(RR_WATER_TEMPLE_MQ_DARK_LINK_REGION, {[]{return SmallKeys(RR_WATER_TEMPLE, 1) && IsAdult && CanUse(RG_LONGSHOT) && CanJumpslash && Hearts > 0;}}), + Entrance(RR_WATER_TEMPLE_BOSS_ENTRYWAY, {[]{return BossKeyWaterTemple && IsAdult && CanJumpslash && CanUse(RG_LONGSHOT);}}), }); areaTable[RR_WATER_TEMPLE_MQ_DIVE] = Area("Water Temple MQ Dive", "Water Temple", RHT_WATER_TEMPLE, NO_DAY_NIGHT_CYCLE, {}, { @@ -273,7 +273,8 @@ void AreaTable_Init_WaterTemple() { areaTable[RR_WATER_TEMPLE_MQ_LOWERED_WATER_LEVELS] = Area("Water Temple MQ Lowered Water Levels", "Water Temple", RHT_WATER_TEMPLE, NO_DAY_NIGHT_CYCLE, {}, { //Locations - LocationAccess(RC_WATER_TEMPLE_MQ_COMPASS_CHEST, {[]{return (IsAdult && CanUse(RG_FAIRY_BOW)) || CanUse(RG_DINS_FIRE) || Here(RR_WATER_TEMPLE_MQ_LOBBY, []{return IsChild && CanUse(RG_STICKS) && HasExplosives;});}}), + LocationAccess(RC_WATER_TEMPLE_MQ_COMPASS_CHEST, {[]{return ((IsAdult && CanUse(RG_FAIRY_BOW)) || CanUse(RG_DINS_FIRE) || Here(RR_WATER_TEMPLE_MQ_LOBBY, []{return IsChild && CanUse(RG_STICKS) && HasExplosives;})) && + (CanJumpslash || CanUseProjectile);}}), LocationAccess(RC_WATER_TEMPLE_MQ_LONGSHOT_CHEST, {[]{return IsAdult && CanUse(RG_HOOKSHOT);}}), LocationAccess(RC_WATER_TEMPLE_MQ_GS_LIZALFOS_HALLWAY, {[]{return CanUse(RG_DINS_FIRE);}}), LocationAccess(RC_WATER_TEMPLE_MQ_GS_BEFORE_UPPER_WATER_SWITCH, {[]{return IsAdult && CanUse(RG_LONGSHOT);}}), @@ -296,7 +297,7 @@ void AreaTable_Init_WaterTemple() { //Locations LocationAccess(RC_WATER_TEMPLE_MQ_FREESTANDING_KEY, {[]{return HoverBoots || CanUse(RG_SCARECROW) || LogicWaterNorthBasementLedgeJump;}}), LocationAccess(RC_WATER_TEMPLE_MQ_GS_TRIPLE_WALL_TORCH, {[]{return CanUse(RG_FIRE_ARROWS) && (HoverBoots || CanUse(RG_SCARECROW));}}), - LocationAccess(RC_WATER_TEMPLE_MQ_GS_FREESTANDING_KEY_AREA, {[]{return LogicWaterMQLockedGS || (SmallKeys(RR_WATER_TEMPLE, 2) && (HoverBoots || CanUse(RG_SCARECROW) || LogicWaterNorthBasementLedgeJump));}}), + LocationAccess(RC_WATER_TEMPLE_MQ_GS_FREESTANDING_KEY_AREA, {[]{return LogicWaterMQLockedGS || (SmallKeys(RR_WATER_TEMPLE, 2) && (HoverBoots || CanUse(RG_SCARECROW) || LogicWaterNorthBasementLedgeJump) && CanJumpslash);}}), //Trick: LogicWaterMQLockedGS || (SmallKeys(RR_WATER_TEMPLE, 2) && (HoverBoots || CanUse(RG_SCARECROW) || LogicWaterNorthBasementLedgeJump)) }, {}); } diff --git a/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_zoras_domain.cpp b/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_zoras_domain.cpp index 4fcb7bcef..346186255 100644 --- a/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_zoras_domain.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_zoras_domain.cpp @@ -48,7 +48,7 @@ void AreaTable_Init_ZorasDomain() { Entrance(RR_ZR_BEHIND_WATERFALL, {[]{return CanPlay(ZeldasLullaby) || (IsChild && LogicZoraWithCucco) || (IsAdult && CanUse(RG_HOVER_BOOTS) && LogicZoraWithHovers);}}), }); - areaTable[RR_ZR_BEHIND_WATERFALL] = Area("ZR Behind Waterfall", "Zora River", RHT_NONE, DAY_NIGHT_CYCLE, {}, {}, { + areaTable[RR_ZR_BEHIND_WATERFALL] = Area("ZR Behind Waterfall", "Zora River", RHT_ZORAS_RIVER, DAY_NIGHT_CYCLE, {}, {}, { //Exits Entrance(RR_ZORAS_RIVER, {[]{return true;}}), Entrance(RR_ZORAS_DOMAIN, {[]{return true;}}), @@ -95,7 +95,7 @@ void AreaTable_Init_ZorasDomain() { LocationAccess(RC_ZD_CHEST, {[]{return IsChild && CanUse(RG_STICKS);}}), LocationAccess(RC_ZD_KING_ZORA_THAWED, {[]{return KingZoraThawed;}}), LocationAccess(RC_ZD_TRADE_PRESCRIPTION, {[]{return KingZoraThawed && Prescription;}}), - LocationAccess(RC_ZD_GS_FROZEN_WATERFALL, {[]{return IsAdult && AtNight && (HookshotOrBoomerang || CanUse(RG_FAIRY_SLINGSHOT) || Bow || MagicMeter || LogicDomainGS) && CanGetNightTimeGS;}}), + LocationAccess(RC_ZD_GS_FROZEN_WATERFALL, {[]{return IsAdult && AtNight && (HookshotOrBoomerang || CanUse(RG_FAIRY_SLINGSHOT) || Bow || (MagicMeter && (CanUse(RG_MASTER_SWORD) || CanUse(RG_KOKIRI_SWORD) || CanUse(RG_BIGGORON_SWORD))) || (LogicDomainGS && CanJumpslash)) && CanGetNightTimeGS;}}), LocationAccess(RC_ZD_GOSSIP_STONE, {[]{return true;}}), }, { //Exits @@ -106,7 +106,7 @@ void AreaTable_Init_ZorasDomain() { Entrance(RR_ZD_STORMS_GROTTO, {[]{return CanOpenStormGrotto;}}), }); - areaTable[RR_ZD_BEHIND_KING_ZORA] = Area("ZD Behind King Zora", "Zoras Domain", RHT_NONE, NO_DAY_NIGHT_CYCLE, {}, {}, { + areaTable[RR_ZD_BEHIND_KING_ZORA] = Area("ZD Behind King Zora", "Zoras Domain", RHT_ZORAS_DOMAIN, NO_DAY_NIGHT_CYCLE, {}, {}, { //Exits Entrance(RR_ZORAS_DOMAIN, {[]{return DeliverLetter || ZorasFountain.Is(ZORASFOUNTAIN_OPEN) || (ZorasFountain.Is(ZORASFOUNTAIN_ADULT) && IsAdult);}}), Entrance(RR_ZORAS_FOUNTAIN, {[]{return true;}}), diff --git a/soh/soh/Enhancements/randomizer/3drando/logic.cpp b/soh/soh/Enhancements/randomizer/3drando/logic.cpp index 949d4433f..04b8e71bc 100644 --- a/soh/soh/Enhancements/randomizer/3drando/logic.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/logic.cpp @@ -121,7 +121,8 @@ namespace Logic { //Greg bool Greg = false; - bool GregInLogic = false; + bool GregInBridgeLogic = false; + bool GregInLacsLogic = false; //Progressive Items uint8_t ProgressiveBulletBag = 0; @@ -255,6 +256,8 @@ namespace Logic { bool CanBlastOrSmash = false; bool CanChildAttack = false; bool CanChildDamage = false; + bool CanAdultAttack = false; + bool CanAdultDamage = false; bool CanCutShrubs = false; bool CanDive = false; bool CanLeaveForest = false; @@ -548,7 +551,6 @@ namespace Logic { SilverScale = ProgressiveScale >= 1; GoldScale = ProgressiveScale >= 2; AdultsWallet = ProgressiveWallet >= 1; - MasterSword = MasterSword || IsAdult; BiggoronSword = BiggoronSword || ProgressiveGiantKnife >= 2; ScarecrowSong = ScarecrowSong || FreeScarecrow || (ChildScarecrow && AdultScarecrow); @@ -597,8 +599,10 @@ namespace Logic { CanBlastOrSmash = HasExplosives || CanUse(RG_MEGATON_HAMMER); CanChildAttack = IsChild && (Slingshot || Boomerang || Sticks || KokiriSword || HasExplosives || CanUse(RG_DINS_FIRE) || CanUse(RG_MASTER_SWORD) || CanUse(RG_MEGATON_HAMMER) || CanUse(RG_BIGGORON_SWORD)); CanChildDamage = IsChild && (Slingshot || Sticks || KokiriSword || HasExplosives || CanUse(RG_DINS_FIRE) || CanUse(RG_MASTER_SWORD) || CanUse(RG_MEGATON_HAMMER) || CanUse(RG_BIGGORON_SWORD)); - CanStunDeku = IsAdult || CanChildAttack || Nuts || HasShield; - CanCutShrubs = IsAdult /*|| Sticks*/ || KokiriSword || Boomerang || HasExplosives || CanUse(RG_MASTER_SWORD) || CanUse(RG_MEGATON_HAMMER) || CanUse(RG_BIGGORON_SWORD); + CanAdultAttack = IsAdult && (CanUse(RG_FAIRY_BOW) || CanUse(RG_BOOMERANG) || CanUse(RG_STICKS) || CanUse(RG_KOKIRI_SWORD) || HasExplosives || CanUse(RG_DINS_FIRE) || MasterSword || Hammer || BiggoronSword || Hookshot); + CanAdultDamage = IsAdult && (CanUse(RG_FAIRY_BOW) || CanUse(RG_STICKS) || CanUse(RG_KOKIRI_SWORD) || HasExplosives || CanUse(RG_DINS_FIRE) || MasterSword || Hammer || BiggoronSword); + CanStunDeku = CanAdultAttack || CanChildAttack || Nuts || HasShield; + CanCutShrubs = CanUse(RG_KOKIRI_SWORD) || CanUse(RG_BOOMERANG) || HasExplosives || CanUse(RG_MASTER_SWORD) || CanUse(RG_MEGATON_HAMMER) || CanUse(RG_BIGGORON_SWORD); CanDive = ProgressiveScale >= 1; CanLeaveForest = OpenForest.IsNot(OPENFOREST_CLOSED) || IsAdult || DekuTreeClear || ShuffleInteriorEntrances || ShuffleOverworldEntrances; CanPlantBugs = IsChild && Bugs; @@ -625,8 +629,8 @@ namespace Logic { HasFireSourceWithTorch = HasFireSource || CanUse(RG_STICKS); //Gerudo Fortress - CanFinishGerudoFortress = (GerudoFortress.Is(GERUDOFORTRESS_NORMAL) && GerudoFortressKeys >= 4 && (IsAdult || KokiriSword || CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD)) && (GerudoToken || CanUse(RG_FAIRY_BOW) || CanUse(RG_HOOKSHOT) || CanUse(RG_HOVER_BOOTS) || LogicGerudoKitchen)) || - (GerudoFortress.Is(GERUDOFORTRESS_FAST) && GerudoFortressKeys >= 1 && (IsAdult || KokiriSword || CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD))) || + CanFinishGerudoFortress = (GerudoFortress.Is(GERUDOFORTRESS_NORMAL) && GerudoFortressKeys >= 4 && (CanUse(RG_KOKIRI_SWORD) || CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD)) && (GerudoToken || CanUse(RG_FAIRY_BOW) || CanUse(RG_HOOKSHOT) || CanUse(RG_HOVER_BOOTS) || LogicGerudoKitchen)) || + (GerudoFortress.Is(GERUDOFORTRESS_FAST) && GerudoFortressKeys >= 1 && (CanUse(RG_KOKIRI_SWORD) || CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD))) || (GerudoFortress.IsNot(GERUDOFORTRESS_NORMAL) && GerudoFortress.IsNot(GERUDOFORTRESS_FAST)); HasShield = CanUse(RG_HYLIAN_SHIELD) || CanUse(RG_DEKU_SHIELD); //Mirror shield can't reflect attacks @@ -635,7 +639,7 @@ namespace Logic { AdultReflectShield = IsAdult && CanUse(RG_HYLIAN_SHIELD); //Mirror shield can't reflect attacks AdultShield = IsAdult && (CanUse(RG_HYLIAN_SHIELD) || CanUse(RG_MIRROR_SHIELD)); CanShieldFlick = ChildShield || AdultShield; - CanJumpslash = IsAdult || Sticks || KokiriSword; + CanJumpslash = CanUse(RG_STICKS) || CanUse(RG_KOKIRI_SWORD) || CanUse(RG_MASTER_SWORD) || CanUse(RG_BIGGORON_SWORD); // Not including hammer as hammer jump attacks can be weird CanUseProjectile = HasExplosives || CanUse(RG_FAIRY_BOW) || CanUse(RG_HOOKSHOT) || CanUse(RG_FAIRY_SLINGSHOT) || CanUse(RG_BOOMERANG); CanUseMagicArrow = CanUse(RG_FIRE_ARROWS) || CanUse(RG_ICE_ARROWS) || CanUse(RG_LIGHT_ARROWS); @@ -645,22 +649,23 @@ namespace Logic { DungeonCount = (DekuTreeClear ? 1:0) + (DodongosCavernClear ? 1:0) + (JabuJabusBellyClear ? 1:0) + (ForestTempleClear ? 1:0) + (FireTempleClear ? 1:0) + (WaterTempleClear ? 1:0) + (SpiritTempleClear ? 1:0) + (ShadowTempleClear ? 1:0); HasAllStones = StoneCount == 3; HasAllMedallions = MedallionCount == 6; - GregInLogic = BridgeRewardOptions.Is(BRIDGE_OPTION_GREG) || LACSRewardOptions.Is(LACS_OPTION_GREG); + GregInBridgeLogic = BridgeRewardOptions.Is(BRIDGE_OPTION_GREG); + GregInLacsLogic = LACSRewardOptions.Is(LACS_OPTION_GREG); CanBuildRainbowBridge = Bridge.Is(RAINBOWBRIDGE_OPEN) || (Bridge.Is(RAINBOWBRIDGE_VANILLA) && ShadowMedallion && SpiritMedallion && LightArrows) || - (Bridge.Is(RAINBOWBRIDGE_STONES) && StoneCount + (Greg && GregInLogic ? 1 : 0) >= BridgeStoneCount.Value()) || - (Bridge.Is(RAINBOWBRIDGE_MEDALLIONS) && MedallionCount + (Greg && GregInLogic ? 1 : 0) >= BridgeMedallionCount.Value()) || - (Bridge.Is(RAINBOWBRIDGE_REWARDS) && StoneCount + MedallionCount + (Greg && GregInLogic ? 1 : 0) >= BridgeRewardCount.Value()) || - (Bridge.Is(RAINBOWBRIDGE_DUNGEONS) && DungeonCount + (Greg && GregInLogic ? 1 : 0) >= BridgeDungeonCount.Value()) || + (Bridge.Is(RAINBOWBRIDGE_STONES) && StoneCount + (Greg && GregInBridgeLogic ? 1 : 0) >= BridgeStoneCount.Value()) || + (Bridge.Is(RAINBOWBRIDGE_MEDALLIONS) && MedallionCount + (Greg && GregInBridgeLogic ? 1 : 0) >= BridgeMedallionCount.Value()) || + (Bridge.Is(RAINBOWBRIDGE_REWARDS) && StoneCount + MedallionCount + (Greg && GregInBridgeLogic ? 1 : 0) >= BridgeRewardCount.Value()) || + (Bridge.Is(RAINBOWBRIDGE_DUNGEONS) && DungeonCount + (Greg && GregInBridgeLogic ? 1 : 0) >= BridgeDungeonCount.Value()) || (Bridge.Is(RAINBOWBRIDGE_TOKENS) && GoldSkulltulaTokens >= BridgeTokenCount.Value()) || (Bridge.Is(RAINBOWBRIDGE_GREG) && Greg); CanTriggerLACS = (LACSCondition == LACSCONDITION_VANILLA && ShadowMedallion && SpiritMedallion) || - (LACSCondition == LACSCONDITION_STONES && StoneCount + (Greg && GregInLogic ? 1 : 0) >= LACSStoneCount.Value()) || - (LACSCondition == LACSCONDITION_MEDALLIONS && MedallionCount + (Greg && GregInLogic ? 1 : 0) >= LACSMedallionCount.Value()) || - (LACSCondition == LACSCONDITION_REWARDS && StoneCount + MedallionCount + (Greg && GregInLogic ? 1 : 0) >= LACSRewardCount.Value()) || - (LACSCondition == LACSCONDITION_DUNGEONS && DungeonCount + (Greg && GregInLogic ? 1 : 0) >= LACSDungeonCount.Value()) || + (LACSCondition == LACSCONDITION_STONES && StoneCount + (Greg && GregInLacsLogic ? 1 : 0) >= LACSStoneCount.Value()) || + (LACSCondition == LACSCONDITION_MEDALLIONS && MedallionCount + (Greg && GregInLacsLogic ? 1 : 0) >= LACSMedallionCount.Value()) || + (LACSCondition == LACSCONDITION_REWARDS && StoneCount + MedallionCount + (Greg && GregInLacsLogic ? 1 : 0) >= LACSRewardCount.Value()) || + (LACSCondition == LACSCONDITION_DUNGEONS && DungeonCount + (Greg && GregInLacsLogic ? 1 : 0) >= LACSDungeonCount.Value()) || (LACSCondition == LACSCONDITION_TOKENS && GoldSkulltulaTokens >= LACSTokenCount.Value()); CanCompleteTriforce = TriforcePieces >= TriforceHuntRequired.Value(); @@ -874,6 +879,8 @@ namespace Logic { //Greg Greg = false; + GregInBridgeLogic = false; + GregInLacsLogic = false; //Progressive Items ProgressiveBulletBag = 0; diff --git a/soh/soh/Enhancements/randomizer/3drando/logic.hpp b/soh/soh/Enhancements/randomizer/3drando/logic.hpp index fc934ddd5..4452b3715 100644 --- a/soh/soh/Enhancements/randomizer/3drando/logic.hpp +++ b/soh/soh/Enhancements/randomizer/3drando/logic.hpp @@ -115,6 +115,8 @@ extern bool LightTrialClear; //Greg extern bool Greg; +extern bool GregInBridgeLogic; +extern bool GregInLacsLogic; // Progression Items extern uint8_t ProgressiveBulletBag; @@ -245,6 +247,8 @@ extern bool IsGlitched; extern bool CanBlastOrSmash; extern bool CanChildAttack; extern bool CanChildDamage; +extern bool CanAdultAttack; +extern bool CanAdultDamage; extern bool CanCutShrubs; extern bool CanDive; extern bool CanLeaveForest; diff --git a/soh/soh/Enhancements/randomizer/3drando/settings.cpp b/soh/soh/Enhancements/randomizer/3drando/settings.cpp index 3c1968ffd..8bb1f8a3f 100644 --- a/soh/soh/Enhancements/randomizer/3drando/settings.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/settings.cpp @@ -176,27 +176,28 @@ namespace Settings { }; //Shuffle Settings - Option RandomizeShuffle = Option::Bool("Randomize Settings", {"No","Yes"}, OptionCategory::Toggle); - Option ShuffleRewards = Option::U8 ("Shuffle Dungeon Rewards",{"End of dungeons", "Any dungeon", "Overworld", "Anywhere"}); - Option LinksPocketItem = Option::U8 ("Link's Pocket", {"Dungeon Reward", "Advancement", "Anything", "Nothing"}); - Option ShuffleSongs = Option::U8 ("Shuffle Songs", {"Song locations", "Dungeon rewards", "Anywhere"}); - Option Shopsanity = Option::U8 ("Shopsanity", {"Off","0 Items","1 Item","2 Items","3 Items","4 Items","Random"}); - Option ShopsanityPrices = Option::U8 ("Shopsanity Prices", {"Balanced", "Starting Wallet", "Adult Wallet", "Giant's Wallet", "Tycoon's Wallet" }); - Option ShopsanityPricesAffordable = Option::Bool("Affordable Prices", {"Off", "On"}); - Option Tokensanity = Option::U8 ("Tokensanity", {"Off", "Dungeons", "Overworld", "All Tokens"}); - Option Scrubsanity = Option::U8 ("Scrub Shuffle", {"Off", "Affordable", "Expensive", "Random Prices"}); - Option ShuffleCows = Option::Bool("Shuffle Cows", {"Off", "On"}); - Option ShuffleKokiriSword = Option::Bool("Shuffle Kokiri Sword", {"Off", "On"}); - Option ShuffleOcarinas = Option::Bool("Shuffle Ocarinas", {"Off", "On"}); - Option ShuffleWeirdEgg = Option::Bool("Shuffle Weird Egg", {"Off", "On"}); - Option ShuffleGerudoToken = Option::Bool("Shuffle Gerudo Card", {"Off", "On"}); - Option ShuffleMagicBeans = Option::Bool("Shuffle Magic Beans", {"Off", "On"}); - Option ShuffleMerchants = Option::U8 ("Shuffle Merchants", {"Off", "On (No Hints)", "On (With Hints)"}); - Option ShuffleFrogSongRupees = Option::Bool("Shuffle Frog Song Rupees",{"Off", "On"}); - Option ShuffleAdultTradeQuest = Option::Bool("Shuffle Adult Trade", {"Off", "On"}); - Option ShuffleChestMinigame = Option::U8 ("Shuffle Chest Minigame", {"Off", "On (Separate)", "On (Pack)"}); - Option Shuffle100GSReward = Option::Bool("Shuffle 100 GS Reward", {"Off", "On"}); - Option ShuffleBossSouls = Option::U8 ("Shuffle Boss Souls", {"Off", "On", "On + Ganon"}); + Option RandomizeShuffle = Option::Bool("Randomize Settings", {"No","Yes"}, OptionCategory::Toggle); + Option ShuffleRewards = Option::U8 ("Shuffle Dungeon Rewards",{"End of dungeons", "Any dungeon", "Overworld", "Anywhere"}); + Option LinksPocketItem = Option::U8 ("Link's Pocket", {"Dungeon Reward", "Advancement", "Anything", "Nothing"}); + Option ShuffleSongs = Option::U8 ("Shuffle Songs", {"Song locations", "Dungeon rewards", "Anywhere"}); + Option Shopsanity = Option::U8 ("Shopsanity", {"Off","0 Items","1 Item","2 Items","3 Items","4 Items","Random"}); + Option ShopsanityPrices = Option::U8 ("Shopsanity Prices", {"Balanced", "Starting Wallet", "Adult Wallet", "Giant's Wallet", "Tycoon's Wallet" }); + Option ShopsanityPricesAffordable = Option::Bool("Affordable Prices", {"Off", "On"}); + Option Tokensanity = Option::U8 ("Tokensanity", {"Off", "Dungeons", "Overworld", "All Tokens"}); + Option Scrubsanity = Option::U8 ("Scrub Shuffle", {"Off", "Affordable", "Expensive", "Random Prices"}); + Option ShuffleCows = Option::Bool("Shuffle Cows", {"Off", "On"}); + Option ShuffleKokiriSword = Option::Bool("Shuffle Kokiri Sword", {"Off", "On"}); + Option ShuffleMasterSword = Option::Bool("Shuffle Master Sword", {"Off", "On"}); + Option ShuffleOcarinas = Option::Bool("Shuffle Ocarinas", {"Off", "On"}); + Option ShuffleWeirdEgg = Option::Bool("Shuffle Weird Egg", {"Off", "On"}); + Option ShuffleGerudoToken = Option::Bool("Shuffle Gerudo Card", {"Off", "On"}); + Option ShuffleMagicBeans = Option::Bool("Shuffle Magic Beans", {"Off", "On"}); + Option ShuffleMerchants = Option::U8 ("Shuffle Merchants", {"Off", "On (No Hints)", "On (With Hints)"}); + Option ShuffleFrogSongRupees = Option::Bool("Shuffle Frog Song Rupees",{"Off", "On"}); + Option ShuffleAdultTradeQuest = Option::Bool("Shuffle Adult Trade", {"Off", "On"}); + Option ShuffleChestMinigame = Option::U8 ("Shuffle Chest Minigame", {"Off", "On (Separate)", "On (Pack)"}); + Option Shuffle100GSReward = Option::Bool("Shuffle 100 GS Reward", {"Off", "On"}); + Option ShuffleBossSouls = Option::U8 ("Shuffle Boss Souls", {"Off", "On", "On + Ganon"}); std::vector