mirror of
https://github.com/zeldaret/oot.git
synced 2024-11-23 05:49:50 +00:00
Remove submodule and use subrepo for ZAPD (#591)
* remove zap * git subrepo clone https://github.com/zeldaret/ZAPD.git tools/ZAPD subrepo: subdir: "tools/ZAPD" merged: "cd4a8760b" upstream: origin: "https://github.com/zeldaret/ZAPD.git" branch: "master" commit: "cd4a8760b" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "2f68596" * remove thanks.md * zap2 -> zapd and spec changes * remove submodule init
This commit is contained in:
parent
ae5a8f2700
commit
ba0c6965ca
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -1,3 +0,0 @@
|
||||
[submodule "tools/ZAP2"]
|
||||
path = tools/ZAP2
|
||||
url = https://github.com/zeldaret/ZAPD.git
|
29
Makefile
29
Makefile
@ -70,7 +70,7 @@ CC_CHECK := gcc -fno-builtin -fsyntax-only -fsigned-char -std=gnu90 -D _LANGUA
|
||||
CPP := cpp
|
||||
MKLDSCRIPT := tools/mkldscript
|
||||
ELF2ROM := tools/elf2rom
|
||||
ZAP2 := tools/ZAP2/ZAP2.out
|
||||
ZAPD := tools/ZAPD/ZAPD.out
|
||||
|
||||
OPTFLAGS := -O2
|
||||
ASFLAGS := -march=vr4300 -32 -Iinclude
|
||||
@ -194,7 +194,6 @@ clean:
|
||||
$(RM) -r $(ROM) $(ELF) build
|
||||
|
||||
setup:
|
||||
git submodule update --init --recursive
|
||||
$(MAKE) -C tools -j
|
||||
python3 fixbaserom.py
|
||||
python3 extract_baserom.py
|
||||
@ -224,7 +223,7 @@ build/assets/%.o: assets/%.c
|
||||
build/src/overlays/%.o: src/overlays/%.c
|
||||
$(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $^
|
||||
$(CC_CHECK) $^
|
||||
$(ZAP2) bovl -i $@ -cfg $^ --outputpath $(@D)/$(notdir $(@D))_reloc.s
|
||||
$(ZAPD) bovl -i $@ -cfg $^ --outputpath $(@D)/$(notdir $(@D))_reloc.s
|
||||
-test -f $(@D)/$(notdir $(@D))_reloc.s && $(AS) $(ASFLAGS) $(@D)/$(notdir $(@D))_reloc.s -o $(@D)/$(notdir $(@D))_reloc.o
|
||||
@$(OBJDUMP) -d $@ > $(@:.o=.s)
|
||||
|
||||
@ -240,46 +239,46 @@ build/src/libultra_code_O1/llcvt.o: src/libultra_code_O1/llcvt.c
|
||||
@$(OBJDUMP) -d $@ > $(@:.o=.s)
|
||||
|
||||
assets/%.c: assets/%.xml
|
||||
# $(ZAP2) bsf -i $< -o $(dir $@)
|
||||
$(ZAP2) bsf -eh -i $< -o $(dir $<)
|
||||
# $(ZAPD) bsf -i $< -o $(dir $@)
|
||||
$(ZAPD) bsf -eh -i $< -o $(dir $<)
|
||||
$(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o build/$(@:.c=.o) $@
|
||||
|
||||
build/%.rgba32.inc.c: %.rgba32.png
|
||||
python3 tools/touchasset.py $(addsuffix basefile.txt, $(dir $@))
|
||||
$(ZAP2) btex -tt rgba32 -i $< -o $@
|
||||
$(ZAPD) btex -tt rgba32 -i $< -o $@
|
||||
|
||||
build/%.rgb5a1.inc.c: %.rgb5a1.png
|
||||
python3 tools/touchasset.py $(addsuffix basefile.txt, $(dir $@))
|
||||
$(ZAP2) btex -tt rgb5a1 -i $< -o $@
|
||||
$(ZAPD) btex -tt rgb5a1 -i $< -o $@
|
||||
|
||||
build/%.i4.inc.c: %.i4.png
|
||||
python3 tools/touchasset.py $(addsuffix basefile.txt, $(dir $@))
|
||||
$(ZAP2) btex -tt i4 -i $< -o $@
|
||||
$(ZAPD) btex -tt i4 -i $< -o $@
|
||||
|
||||
build/%.i8.inc.c: %.i8.png
|
||||
python3 tools/touchasset.py $(addsuffix basefile.txt, $(dir $@))
|
||||
$(ZAP2) btex -tt i8 -i $< -o $@
|
||||
$(ZAPD) btex -tt i8 -i $< -o $@
|
||||
|
||||
build/%.ia4.inc.c: %.ia4.png
|
||||
python3 tools/touchasset.py $(addsuffix basefile.txt, $(dir $@))
|
||||
$(ZAP2) btex -tt ia4 -i $< -o $@
|
||||
$(ZAPD) btex -tt ia4 -i $< -o $@
|
||||
|
||||
build/%.ia8.inc.c: %.ia8.png
|
||||
python3 tools/touchasset.py $(addsuffix basefile.txt, $(dir $@))
|
||||
$(ZAP2) btex -tt ia8 -i $< -o $@
|
||||
$(ZAPD) btex -tt ia8 -i $< -o $@
|
||||
|
||||
build/%.ia16.inc.c: %.ia16.png
|
||||
python3 tools/touchasset.py $(addsuffix basefile.txt, $(dir $@))
|
||||
$(ZAP2) btex -tt ia16 -i $< -o $@
|
||||
$(ZAPD) btex -tt ia16 -i $< -o $@
|
||||
|
||||
build/assets/%.ci4.inc.c: assets/%.ci4.png
|
||||
python3 tools/touchasset.py $(addsuffix basefile.txt, $(dir $@))
|
||||
$(ZAP2) btex -tt ci4 -i $< -o $@
|
||||
$(ZAPD) btex -tt ci4 -i $< -o $@
|
||||
|
||||
build/%.ci8.inc.c: %.ci8.png
|
||||
python3 tools/touchasset.py $(addsuffix basefile.txt, $(dir $@))
|
||||
$(ZAP2) btex -tt ci8 -i $< -o $@
|
||||
$(ZAPD) btex -tt ci8 -i $< -o $@
|
||||
|
||||
build/assets/%.bin.inc.c: assets/%.bin
|
||||
python3 tools/touchasset.py $(addsuffix basefile.txt, $(dir $@))
|
||||
$(ZAP2) bblb -i $< -o $@
|
||||
$(ZAPD) bblb -i $< -o $@
|
||||
|
@ -1 +0,0 @@
|
||||
Thanks to z64me and CrookedPoe for their actor documentation. <https://github.com/CrookedPoe/z64-rw>
|
@ -13,7 +13,7 @@
|
||||
<Texture Name="Tex_Graveyard_Flower_Leaf" Format="rgb5a1" Width="32" Height="32"/>
|
||||
<DList Name="Gfx_Grotto_Hole" Offset="0x1390"/>
|
||||
<Texture Name="Tex_Grotto_Hole" Format="ia16" Width="32" Height="64"/>
|
||||
<!--<Hierarchy Name="Hier_Butterfly" Offset="0x2474" Type="Standard"/>-->
|
||||
<!--<Skeleton Name="Hier_Butterfly" Offset="0x2474" Type="Standard"/>-->
|
||||
<DList Name="Gfx_Butterfly_Wing_R" Offset="0x2480"/>
|
||||
<DList Name="Gfx_Butterfly_Wing_R_Ref" Offset="0x2520"/>
|
||||
<DList Name="Gfx_Butterfly_Wing_R_Ref_Ref" Offset="0x2530"/>
|
||||
@ -21,7 +21,7 @@
|
||||
<DList Name="Gfx_Butterfly_Wing_L_Ref" Offset="0x2620"/>
|
||||
<DList Name="Gfx_Butterfly_Wing_L_Ref_Ref" Offset="0x2630"/>
|
||||
<!--<Texture Name="Tex_Butterfly_Wing" Format="rgb5a1" Width="32" Height="64"/>-->
|
||||
<!--<Hierarchy Name="Hier_Bombable_Wall" Offset="0x36EC"/>-->
|
||||
<!--<Skeleton Name="Hier_Bombable_Wall" Offset="0x36EC"/>-->
|
||||
<!--<Palette Name="Pal_Bombable_Wall" Format="rgb5a1" Offset="0x3700" Width="16" Height="16"/>-->
|
||||
<!--<Texture Name="Tex_Bombable_Wall" Format="ci4" Palette="Pal_Bombable_Wall" Width="32" Height="64"/>-->
|
||||
<!--<Texture Name="Tex_Bombable_Wall_Broken" Format="ci4" Palette="Pal_Bombable_Wall" Width="32" Height="64"/>-->
|
||||
@ -42,7 +42,7 @@
|
||||
<DList Name="Gfx_Orange_Fish_Tail_Ref_Ref" Offset="0x6458"/>
|
||||
<Texture Name="Tex_Orange_Fish_Body" Format="rgb5a1" Width="64" Height="64"/>
|
||||
<Texture Name="Tex_Orange_Body_Tail" Format="rgb5a1" Width="32" Height="16"/>
|
||||
<!--<Hierarchy Name="Hier_Fish" Offset="0x88F4"/>-->
|
||||
<!--<Skeleton Name="Hier_Fish" Offset="0x88F4"/>-->
|
||||
<Texture Name="Tex_Beehive" Format="rgb5a1" Width="32" Height="32" Offset="0x8900"/>
|
||||
<Gfx Name="Gfx_Beehive" Offset="0x95B0"/>
|
||||
<Texture Name="Tex_Beehive_Fragment" Format="rgb5a1" Width="16" Height="16" Offset="0x9710"/>
|
||||
|
@ -29,7 +29,7 @@
|
||||
<Limb Name="gStalfosJawLimb" Type="Standard" Offset="0x78D4"/>
|
||||
<Limb Name="gStalfosHeadLimb" Type="Standard" Offset="0x78E0"/>
|
||||
<Limb Name="gStalfosEntryFirstVertebLimb" Type="Standard" Offset="0x78EC"/>
|
||||
<Hierarchy Name="gStalfosSkel" Type="Normal" LimbType="Standard" Offset="0x7C28"/>
|
||||
<Skeleton Name="gStalfosSkel" Type="Normal" LimbType="Standard" Offset="0x7C28"/>
|
||||
<Animation Name="gStalfosBackDamageAnim" Offset="0x444"/>
|
||||
<Animation Name="gStalfosBackDownAnim" Offset="0x1420"/>
|
||||
<Animation Name="gStalfosBackJumpAnim" Offset="0x1978"/>
|
||||
|
@ -11,7 +11,7 @@ def ExtractScene(xmlPath, outputPath):
|
||||
ExtractFile(xmlPath, outputPath, 1, 1)
|
||||
|
||||
def ExtractFile(xmlPath, outputPath, genSrcFile, incFilePrefix):
|
||||
execStr = "tools/ZAP2/ZAP2.out e -eh -i %s -b baserom/ -o %s -gsf %i -ifp %i -sm tools/ZAP2/SymbolMap_OoTMqDbg.txt" % (xmlPath, outputPath, genSrcFile, incFilePrefix)
|
||||
execStr = "tools/ZAPD/ZAPD.out e -eh -i %s -b baserom/ -o %s -gsf %i -ifp %i -sm tools/ZAPD/SymbolMap_OoTMqDbg.txt" % (xmlPath, outputPath, genSrcFile, incFilePrefix)
|
||||
|
||||
print(execStr)
|
||||
os.system(execStr)
|
||||
|
@ -1,14 +1,14 @@
|
||||
CC := gcc
|
||||
CFLAGS := -Wall -Wextra -pedantic -std=c99 -g -O2
|
||||
PROGRAMS := yaz0 makeromfs elf2rom mkldscript vtxdis
|
||||
ZAP2 := ZAP2/ZAP2.out
|
||||
ZAPD := ZAPD/ZAPD.out
|
||||
|
||||
all: $(PROGRAMS)
|
||||
cd ZAP2 && $(MAKE)
|
||||
cd ZAPD && $(MAKE)
|
||||
|
||||
clean:
|
||||
$(RM) $(PROGRAMS)
|
||||
$(RM) ZAP2/ZAP2.out
|
||||
$(RM) ZAPD/ZAPD.out
|
||||
# Need to clean the above line later...
|
||||
|
||||
mkldscript_SOURCES := mkldscript.c util.c
|
||||
@ -17,8 +17,8 @@ yaz0_SOURCES := yaz0tool.c yaz0.c util.c
|
||||
makeromfs_SOURCES := makeromfs.c n64chksum.c util.c
|
||||
vtxdis_SOURCES := vtxdis.c
|
||||
|
||||
#$(ZAP2):
|
||||
# cd ZAP2 && $(MAKE)
|
||||
#$(ZAPD):
|
||||
# cd ZAPD && $(MAKE)
|
||||
|
||||
define COMPILE =
|
||||
$(1): $($1_SOURCES)
|
||||
|
@ -1 +0,0 @@
|
||||
Subproject commit 73dcb0371a4d47acdc5151119f8af9596a803587
|
335
tools/ZAPD/.gitignore
vendored
Normal file
335
tools/ZAPD/.gitignore
vendored
Normal file
@ -0,0 +1,335 @@
|
||||
## 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
|
||||
.vscode/
|
12
tools/ZAPD/.gitrepo
Normal file
12
tools/ZAPD/.gitrepo
Normal file
@ -0,0 +1,12 @@
|
||||
; 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/zeldaret/ZAPD.git
|
||||
branch = master
|
||||
commit = cd4a8760b64474a2603c2d164ab7fb7bcd88385c
|
||||
parent = 9b82d8ffae16a4b6c5a7ff86019eae84ce4638fc
|
||||
method = merge
|
||||
cmdver = 0.4.3
|
21
tools/ZAPD/LICENSE
Normal file
21
tools/ZAPD/LICENSE
Normal file
@ -0,0 +1,21 @@
|
||||
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.
|
25
tools/ZAPD/Makefile
Normal file
25
tools/ZAPD/Makefile
Normal file
@ -0,0 +1,25 @@
|
||||
CC := g++
|
||||
|
||||
ifneq (, $(shell which ccache))
|
||||
CC := ccache $(CC)
|
||||
endif
|
||||
|
||||
CFLAGS := -g -std=c++17 -I ZAPD -I ZAPD/sqlite -O2 -rdynamic
|
||||
|
||||
SRC_DIRS := ZAPD ZAPD/ZRoom ZAPD/ZRoom/Commands ZAPD/Overlays ZAPD/HighLevel ZAPD/OpenFBX
|
||||
|
||||
CPP_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.cpp))
|
||||
O_FILES := $(CPP_FILES:.cpp=.o)
|
||||
|
||||
all: ZAPD.out
|
||||
|
||||
clean:
|
||||
rm -f $(O_FILES) ZAPD.out
|
||||
|
||||
rebuild: clean all
|
||||
|
||||
%.o: %.cpp
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
ZAPD.out: $(O_FILES)
|
||||
$(CC) $(CFLAGS) $(O_FILES) -o $@ -lstdc++fs
|
1
tools/ZAPD/SymbolMap_OoTMqDbg.txt
Normal file
1
tools/ZAPD/SymbolMap_OoTMqDbg.txt
Normal file
@ -0,0 +1 @@
|
||||
8012DB20 gMtxClear
|
46
tools/ZAPD/ZAPD.sln
Normal file
46
tools/ZAPD/ZAPD.sln
Normal file
@ -0,0 +1,46 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.30320.27
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZAPD", "ZAPD\ZAPD.vcxproj", "{B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
MinSizeRel|x64 = MinSizeRel|x64
|
||||
MinSizeRel|x86 = MinSizeRel|x86
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
RelWithDebInfo|x64 = RelWithDebInfo|x64
|
||||
RelWithDebInfo|x86 = RelWithDebInfo|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36}.Debug|x64.Build.0 = Debug|x64
|
||||
{B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36}.Debug|x86.Build.0 = Debug|Win32
|
||||
{B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36}.MinSizeRel|x64.ActiveCfg = Release|x64
|
||||
{B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36}.MinSizeRel|x64.Build.0 = Release|x64
|
||||
{B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36}.MinSizeRel|x86.ActiveCfg = Release|Win32
|
||||
{B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36}.MinSizeRel|x86.Build.0 = Release|Win32
|
||||
{B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36}.Release|x64.ActiveCfg = Release|x64
|
||||
{B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36}.Release|x64.Build.0 = Release|x64
|
||||
{B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36}.Release|x86.ActiveCfg = Release|Win32
|
||||
{B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36}.Release|x86.Build.0 = Release|Win32
|
||||
{B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36}.RelWithDebInfo|x64.ActiveCfg = Release|x64
|
||||
{B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36}.RelWithDebInfo|x64.Build.0 = Release|x64
|
||||
{B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36}.RelWithDebInfo|x86.ActiveCfg = Release|Win32
|
||||
{B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36}.RelWithDebInfo|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {C2E1CC72-7A50-3249-AFD5-DFF6FE25CDCA}
|
||||
EndGlobalSection
|
||||
GlobalSection(Performance) = preSolution
|
||||
HasPerformanceSessions = true
|
||||
EndGlobalSection
|
||||
EndGlobal
|
43
tools/ZAPD/ZAPD/BitConverter.h
Normal file
43
tools/ZAPD/ZAPD/BitConverter.h
Normal file
@ -0,0 +1,43 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <vector>
|
||||
|
||||
class BitConverter
|
||||
{
|
||||
public:
|
||||
static inline int16_t ToInt16BE(uint8_t* data, int offset)
|
||||
{
|
||||
return (data[offset + 0] << 8) + data[offset + 1];
|
||||
}
|
||||
|
||||
static inline int16_t ToInt16BE(std::vector<uint8_t> data, int offset)
|
||||
{
|
||||
return (data[offset + 0] << 8) + data[offset + 1];
|
||||
}
|
||||
|
||||
static inline int32_t ToInt32BE(std::uint8_t* data, int offset)
|
||||
{
|
||||
return (data[offset + 0] << 24) + (data[offset + 1] << 16) + (data[offset + 2] << 8) + data[offset + 3];
|
||||
}
|
||||
|
||||
static inline int32_t ToInt32BE(std::vector<uint8_t> data, int offset)
|
||||
{
|
||||
return (data[offset + 0] << 24) + (data[offset + 1] << 16) + (data[offset + 2] << 8) + data[offset + 3];
|
||||
}
|
||||
|
||||
static inline uint64_t ToInt64BE(uint8_t* data, int offset)
|
||||
{
|
||||
return ((uint64_t)data[offset + 0] << 56) + ((uint64_t)data[offset + 1] << 48) + ((uint64_t)data[offset + 2] << 40) + ((uint64_t)data[offset + 3] << 32) + ((uint64_t)data[offset + 4] << 24) + ((uint64_t)data[offset + 5] << 16) + ((uint64_t)data[offset + 6] << 8) + ((uint64_t)data[offset + 7]);
|
||||
}
|
||||
|
||||
static inline uint64_t ToInt64BE(std::vector<uint8_t> data, int offset)
|
||||
{
|
||||
return ((uint64_t)data[offset + 0] << 56) + ((uint64_t)data[offset + 1] << 48) + ((uint64_t)data[offset + 2] << 40) + ((uint64_t)data[offset + 3] << 32) + ((uint64_t)data[offset + 4] << 24) + ((uint64_t)data[offset + 5] << 16) + ((uint64_t)data[offset + 6] << 8) + ((uint64_t)data[offset + 7]);
|
||||
}
|
||||
|
||||
static inline float ToFloatBE(std::vector<uint8_t> data, int offset)
|
||||
{
|
||||
return (float)(data[offset + 0] << 24) + (data[offset + 1] << 16) + (data[offset + 2] << 8) + data[offset + 3];
|
||||
}
|
||||
};
|
31
tools/ZAPD/ZAPD/Directory.h
Normal file
31
tools/ZAPD/ZAPD/Directory.h
Normal file
@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
#if defined(_MSC_VER) || defined(__clang__)
|
||||
#include <filesystem>
|
||||
namespace fs = std::filesystem;
|
||||
#else
|
||||
#include <experimental/filesystem>
|
||||
namespace fs = std::experimental::filesystem;
|
||||
#endif
|
||||
|
||||
class Directory
|
||||
{
|
||||
public:
|
||||
static std::string GetCurrentDirectory()
|
||||
{
|
||||
return fs::current_path().u8string();
|
||||
}
|
||||
|
||||
static bool Exists(std::string path)
|
||||
{
|
||||
return fs::exists(fs::path(path));
|
||||
}
|
||||
|
||||
static void CreateDirectory(std::string path)
|
||||
{
|
||||
fs::create_directory(path);
|
||||
}
|
||||
};
|
60
tools/ZAPD/ZAPD/File.h
Normal file
60
tools/ZAPD/ZAPD/File.h
Normal file
@ -0,0 +1,60 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "StringHelper.h"
|
||||
|
||||
class File
|
||||
{
|
||||
public:
|
||||
static bool Exists(std::string filePath)
|
||||
{
|
||||
std::ifstream file(filePath, std::ios::in | std::ios::binary | std::ios::ate);
|
||||
return file.good();
|
||||
}
|
||||
|
||||
static std::vector<uint8_t> ReadAllBytes(std::string filePath)
|
||||
{
|
||||
std::ifstream file(filePath, std::ios::in | std::ios::binary | std::ios::ate);
|
||||
int fileSize = (int)file.tellg();
|
||||
file.seekg(0);
|
||||
char* data = new char[fileSize];
|
||||
file.read(data, fileSize);
|
||||
return std::vector<uint8_t>(data, data + fileSize);
|
||||
};
|
||||
|
||||
static std::string ReadAllText(std::string filePath)
|
||||
{
|
||||
std::ifstream file(filePath, std::ios::in | std::ios::binary | std::ios::ate);
|
||||
int fileSize = (int)file.tellg();
|
||||
file.seekg(0);
|
||||
char* data = new char[fileSize+1];
|
||||
memset(data, 0, fileSize + 1);
|
||||
file.read(data, fileSize);
|
||||
return std::string((const char*)data);
|
||||
};
|
||||
|
||||
static std::vector<std::string> ReadAllLines(std::string filePath)
|
||||
{
|
||||
std::string text = ReadAllText(filePath);
|
||||
std::vector<std::string> lines = StringHelper::Split(text, "\n");
|
||||
|
||||
return lines;
|
||||
};
|
||||
|
||||
static void WriteAllBytes(std::string filePath, std::vector<uint8_t> data)
|
||||
{
|
||||
std::ofstream file(filePath, std::ios::binary);
|
||||
file.write((char*)data.data(), data.size());
|
||||
};
|
||||
|
||||
static void WriteAllText(std::string filePath, std::string text)
|
||||
{
|
||||
std::ofstream file(filePath, std::ios::out);
|
||||
file.write(text.c_str(), text.size());
|
||||
}
|
||||
};
|
119
tools/ZAPD/ZAPD/Globals.cpp
Normal file
119
tools/ZAPD/ZAPD/Globals.cpp
Normal file
@ -0,0 +1,119 @@
|
||||
#include "Globals.h"
|
||||
#include "File.h"
|
||||
#include "tinyxml2.h"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace tinyxml2;
|
||||
using namespace std;
|
||||
|
||||
Globals* Globals::Instance;
|
||||
|
||||
Globals::Globals()
|
||||
{
|
||||
Instance = this;
|
||||
|
||||
files = std::vector<ZFile*>();
|
||||
segments = std::vector<int>();
|
||||
symbolMap = std::map <uint32_t, std::string>();
|
||||
segmentRefs = map<int, string>();
|
||||
segmentRefFiles = map<int, ZFile*>();
|
||||
genSourceFile = true;
|
||||
testMode = false;
|
||||
debugMessages = false;
|
||||
profile = false;
|
||||
includeFilePrefix = false;
|
||||
useExternalResources = true;
|
||||
lastScene = nullptr;
|
||||
}
|
||||
|
||||
string Globals::FindSymbolSegRef(int segNumber, uint32_t symbolAddress)
|
||||
{
|
||||
if (segmentRefs.find(segNumber) != segmentRefs.end())
|
||||
{
|
||||
if (segmentRefFiles.find(segNumber) == segmentRefFiles.end())
|
||||
{
|
||||
XMLDocument doc;
|
||||
string filePath = segmentRefs[segNumber];
|
||||
XMLError eResult = doc.LoadFile(filePath.c_str());
|
||||
|
||||
if (eResult != tinyxml2::XML_SUCCESS)
|
||||
return "ERROR";
|
||||
|
||||
XMLNode* root = doc.FirstChild();
|
||||
|
||||
if (root == nullptr)
|
||||
return "ERROR";
|
||||
|
||||
//vector<ZFile*> files = vector<ZFile*>();
|
||||
|
||||
for (XMLElement* child = root->FirstChildElement(); child != NULL; child = child->NextSiblingElement())
|
||||
{
|
||||
if (string(child->Name()) == "File")
|
||||
{
|
||||
ZFile* file = new ZFile(fileMode, child, "", "", true);
|
||||
file->GeneratePlaceholderDeclarations();
|
||||
segmentRefFiles[segNumber] = file;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return segmentRefFiles[segNumber]->GetDeclarationName(symbolAddress, "ERROR");
|
||||
}
|
||||
|
||||
return "ERROR";
|
||||
}
|
||||
|
||||
void Globals::ReadConfigFile(string configFilePath)
|
||||
{
|
||||
XMLDocument doc;
|
||||
XMLError eResult = doc.LoadFile(configFilePath.c_str());
|
||||
|
||||
if (eResult != tinyxml2::XML_SUCCESS)
|
||||
return;
|
||||
|
||||
XMLNode* root = doc.FirstChild();
|
||||
|
||||
if (root == nullptr)
|
||||
return;
|
||||
|
||||
for (XMLElement* child = root->FirstChildElement(); child != NULL; child = child->NextSiblingElement())
|
||||
{
|
||||
if (string(child->Name()) == "SymbolMap")
|
||||
{
|
||||
string fileName = string(child->Attribute("File"));
|
||||
GenSymbolMap(fileName);
|
||||
}
|
||||
else if (string(child->Name()) == "Segment")
|
||||
{
|
||||
string fileName = string(child->Attribute("File"));
|
||||
int segNumber = child->IntAttribute("Number");
|
||||
segmentRefs[segNumber] = fileName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Globals::GenSymbolMap(string symbolMapPath)
|
||||
{
|
||||
auto symbolLines = File::ReadAllLines(symbolMapPath);
|
||||
|
||||
for (std::string symbolLine : symbolLines)
|
||||
{
|
||||
auto split = StringHelper::Split(symbolLine, " ");
|
||||
uint32_t addr = strtoul(split[0].c_str(), NULL, 16);
|
||||
std::string symbolName = split[1];
|
||||
|
||||
symbolMap[addr] = symbolName;
|
||||
}
|
||||
}
|
||||
|
||||
void Globals::AddSegment(int segment)
|
||||
{
|
||||
if (std::find(segments.begin(), segments.end(), segment) == segments.end())
|
||||
segments.push_back(segment);
|
||||
}
|
||||
|
||||
bool Globals::HasSegment(int segment)
|
||||
{
|
||||
return std::find(segments.begin(), segments.end(), segment) != segments.end();
|
||||
}
|
52
tools/ZAPD/ZAPD/Globals.h
Normal file
52
tools/ZAPD/ZAPD/Globals.h
Normal file
@ -0,0 +1,52 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "ZFile.h"
|
||||
#include "ZTexture.h"
|
||||
#include "ZRoom/ZRoom.h"
|
||||
|
||||
class Globals
|
||||
{
|
||||
public:
|
||||
static Globals* Instance;
|
||||
|
||||
bool genSourceFile; // Used for extraction
|
||||
bool useExternalResources;
|
||||
bool testMode; // Enables certain experimental features
|
||||
bool debugMessages; // Enables certain printfs
|
||||
bool profile; // Measure performance of certain operations
|
||||
bool includeFilePrefix; // Include the file prefix in symbols
|
||||
ZFileMode fileMode;
|
||||
std::string baseRomPath, inputPath, outputPath, cfgPath;
|
||||
TextureType texType;
|
||||
|
||||
std::vector<ZFile*> files;
|
||||
std::vector<int> segments;
|
||||
std::map<int, std::string> segmentRefs;
|
||||
std::map<int, ZFile*> segmentRefFiles;
|
||||
ZRoom* lastScene;
|
||||
std::map<uint32_t, std::string> symbolMap;
|
||||
|
||||
Globals();
|
||||
std::string FindSymbolSegRef(int segNumber, uint32_t symbolAddress);
|
||||
void ReadConfigFile(std::string configFilePath);
|
||||
void GenSymbolMap(std::string symbolMapPath);
|
||||
void AddSegment(int segment);
|
||||
bool HasSegment(int segment);
|
||||
};
|
||||
|
||||
/*
|
||||
* Note: In being able to track references across files, there are a few major files that make use of segments...
|
||||
* Segment 1: nintendo_rogo_static/title_static
|
||||
* Segment 2: parameter_static
|
||||
* Segment 4: gameplay_keep
|
||||
* Segment 5: gameplay_field_keep, gameplay_dangeon_keep
|
||||
* Segment 7: link_animetion
|
||||
* Segment 8: icon_item_static
|
||||
* Segment 9: icon_item_24_static
|
||||
* Segment 12: icon_item_field_static, icon_item_dungeon_static
|
||||
* Segment 13: icon_item_nes_static
|
||||
*
|
||||
* I'm thinking a config file could be usable, but I'll have to experiment...
|
||||
*/
|
13
tools/ZAPD/ZAPD/HighLevel/HLAnimation.h
Normal file
13
tools/ZAPD/ZAPD/HighLevel/HLAnimation.h
Normal file
@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/*
|
||||
* The high level format for animations.
|
||||
*/
|
||||
|
||||
class HLAnimation
|
||||
{
|
||||
public:
|
||||
|
||||
};
|
125
tools/ZAPD/ZAPD/HighLevel/HLAnimationIntermediette.cpp
Normal file
125
tools/ZAPD/ZAPD/HighLevel/HLAnimationIntermediette.cpp
Normal file
@ -0,0 +1,125 @@
|
||||
#include "HLAnimationIntermediette.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace tinyxml2;
|
||||
|
||||
HLAnimationIntermediette::HLAnimationIntermediette()
|
||||
{
|
||||
limit = 0;
|
||||
limbCount = 0;
|
||||
frameCount = 0;
|
||||
rotationValues = vector<uint16_t>();
|
||||
rotationIndices = vector<RotationIndex>();
|
||||
}
|
||||
|
||||
HLAnimationIntermediette::~HLAnimationIntermediette()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
HLAnimationIntermediette* HLAnimationIntermediette::FromXML(std::string xmlPath)
|
||||
{
|
||||
HLAnimationIntermediette* anim = new HLAnimationIntermediette();
|
||||
XMLDocument doc;
|
||||
|
||||
doc.LoadFile(xmlPath.c_str());
|
||||
|
||||
XMLElement* root = doc.RootElement();
|
||||
|
||||
anim->limit = root->IntAttribute("Limit");
|
||||
anim->limbCount = root->IntAttribute("LimbCount");
|
||||
anim->frameCount = root->IntAttribute("FrameCount");
|
||||
|
||||
for (XMLElement* child = root->FirstChildElement(); child != NULL; child = child->NextSiblingElement())
|
||||
{
|
||||
if (string(child->Name()) == "RotationValues")
|
||||
{
|
||||
for (XMLElement* child2 = child->FirstChildElement(); child2 != NULL; child2 = child2->NextSiblingElement())
|
||||
{
|
||||
string value = child2->GetText();
|
||||
anim->rotationValues.push_back(atoi(value.c_str()));
|
||||
}
|
||||
}
|
||||
else if (string(child->Name()) == "RotationIndices")
|
||||
{
|
||||
for (XMLElement* child2 = child->FirstChildElement(); child2 != NULL; child2 = child2->NextSiblingElement())
|
||||
anim->rotationIndices.push_back(RotationIndex(child2->IntAttribute("X"), child2->IntAttribute("Y"), child2->IntAttribute("Z")));
|
||||
}
|
||||
}
|
||||
|
||||
return anim;
|
||||
}
|
||||
|
||||
HLAnimationIntermediette* HLAnimationIntermediette::FromZAnimation(ZAnimation* zAnim)
|
||||
{
|
||||
HLAnimationIntermediette* anim = new HLAnimationIntermediette();
|
||||
|
||||
/*anim->limit = zAnim->limit;
|
||||
anim->frameCount = zAnim->frameCount;
|
||||
|
||||
for (uint16_t item : zAnim->rotationValues)
|
||||
anim->rotationValues.push_back(item);
|
||||
|
||||
for (RotationIndex item : zAnim->rotationIndices)
|
||||
anim->rotationIndices.push_back(item);*/
|
||||
|
||||
return anim;
|
||||
}
|
||||
|
||||
ZAnimation* HLAnimationIntermediette::ToZAnimation()
|
||||
{
|
||||
ZAnimation* zAnim = new ZAnimation();
|
||||
|
||||
/*zAnim->limit = limit;
|
||||
zAnim->frameCount = frameCount;
|
||||
|
||||
for (uint16_t item : rotationValues)
|
||||
zAnim->rotationValues.push_back(item);
|
||||
|
||||
for (RotationIndex item : rotationIndices)
|
||||
zAnim->rotationIndices.push_back(item);*/
|
||||
|
||||
return zAnim;
|
||||
}
|
||||
|
||||
string HLAnimationIntermediette::OutputXML()
|
||||
{
|
||||
string output = "";
|
||||
XMLDocument doc;
|
||||
|
||||
XMLElement* root = doc.NewElement("HLAnimationIntermediette");
|
||||
root->SetAttribute("Limit", limit);
|
||||
root->SetAttribute("LimbCount", limbCount);
|
||||
root->SetAttribute("FrameCount", frameCount);
|
||||
|
||||
doc.InsertFirstChild(root);
|
||||
|
||||
XMLElement* rotValues = doc.NewElement("RotationValues");
|
||||
|
||||
for (int i = 0; i < rotationValues.size(); i++)
|
||||
{
|
||||
XMLElement* rotValue = doc.NewElement("Value");
|
||||
rotValue->SetText(rotationValues[i]);
|
||||
rotValues->InsertEndChild(rotValue);
|
||||
}
|
||||
|
||||
root->InsertEndChild(rotValues);
|
||||
|
||||
XMLElement* rotIndices = doc.NewElement("RotationIndices");
|
||||
|
||||
for (int i = 0; i < rotationIndices.size(); i++)
|
||||
{
|
||||
XMLElement* rotIndex = doc.NewElement("Value");
|
||||
rotIndex->SetAttribute("X", rotationIndices[i].x);
|
||||
rotIndex->SetAttribute("Y", rotationIndices[i].y);
|
||||
rotIndex->SetAttribute("Z", rotationIndices[i].z);
|
||||
rotIndices->InsertEndChild(rotIndex);
|
||||
}
|
||||
|
||||
root->InsertEndChild(rotIndices);
|
||||
|
||||
XMLPrinter printer;
|
||||
|
||||
doc.Accept(&printer);
|
||||
return printer.CStr();
|
||||
}
|
32
tools/ZAPD/ZAPD/HighLevel/HLAnimationIntermediette.h
Normal file
32
tools/ZAPD/ZAPD/HighLevel/HLAnimationIntermediette.h
Normal file
@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include "../ZAnimation.h"
|
||||
#include "../tinyxml2.h"
|
||||
#include "HLFileIntermediette.h"
|
||||
|
||||
/*
|
||||
* An intermediette format for animations. Going to use XML.
|
||||
* Goes from FBX->XML->C
|
||||
* Note: At the moment this is a very direct representation of the output format.
|
||||
* Optimally we can determine where the keyframes are and remove redundant information.
|
||||
*/
|
||||
|
||||
class HLAnimationIntermediette
|
||||
{
|
||||
public:
|
||||
int16_t frameCount;
|
||||
int16_t limit;
|
||||
int16_t limbCount;
|
||||
std::vector<uint16_t> rotationValues;
|
||||
std::vector<RotationIndex> rotationIndices;
|
||||
|
||||
HLAnimationIntermediette();
|
||||
~HLAnimationIntermediette();
|
||||
|
||||
std::string OutputXML();
|
||||
ZAnimation* ToZAnimation();
|
||||
|
||||
static HLAnimationIntermediette* FromXML(std::string xmlPath);
|
||||
static HLAnimationIntermediette* FromZAnimation(ZAnimation* zAnim);
|
||||
};
|
6
tools/ZAPD/ZAPD/HighLevel/HLFileIntermediette.h
Normal file
6
tools/ZAPD/ZAPD/HighLevel/HLFileIntermediette.h
Normal file
@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
class HLFileIntermediette
|
||||
{
|
||||
|
||||
};
|
1152
tools/ZAPD/ZAPD/HighLevel/HLModelIntermediette.cpp
Normal file
1152
tools/ZAPD/ZAPD/HighLevel/HLModelIntermediette.cpp
Normal file
File diff suppressed because it is too large
Load Diff
282
tools/ZAPD/ZAPD/HighLevel/HLModelIntermediette.h
Normal file
282
tools/ZAPD/ZAPD/HighLevel/HLModelIntermediette.h
Normal file
@ -0,0 +1,282 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "HLTexture.h"
|
||||
#include "HLFileIntermediette.h"
|
||||
#include "../ZDisplayList.h"
|
||||
#include "../ZSkeleton.h"
|
||||
#include "../tinyxml2.h"
|
||||
#include "../assimp/scene.h"
|
||||
|
||||
/*
|
||||
* An intermediette format for models. Goes from FBX<-->Intermediette<-->Display List C Code.
|
||||
*/
|
||||
|
||||
class HLModelIntermediette;
|
||||
|
||||
class HLIntermediette
|
||||
{
|
||||
public:
|
||||
std::string name;
|
||||
HLModelIntermediette* parent;
|
||||
|
||||
HLIntermediette();
|
||||
~HLIntermediette();
|
||||
|
||||
virtual std::string OutputCode();
|
||||
virtual std::string OutputOBJ();
|
||||
virtual void OutputAssimp(aiScene* scene, std::vector<aiVector3D>* verts);
|
||||
virtual void OutputXML(tinyxml2::XMLDocument* doc, tinyxml2::XMLElement* root);
|
||||
virtual void InitFromXML(tinyxml2::XMLElement* xmlElement);
|
||||
};
|
||||
|
||||
class HLModelIntermediette : public HLFileIntermediette
|
||||
{
|
||||
public:
|
||||
std::vector<HLIntermediette*> blocks;
|
||||
|
||||
bool hasSkeleton;
|
||||
|
||||
bool startsWithPipeSync;
|
||||
bool startsWithClearGeometryMode;
|
||||
bool lerpBeforeTextureBlock;
|
||||
|
||||
int startIndex;
|
||||
int meshStartIndex;
|
||||
|
||||
HLModelIntermediette();
|
||||
~HLModelIntermediette();
|
||||
|
||||
static HLModelIntermediette* FromXML(tinyxml2::XMLElement* root);
|
||||
static void FromZDisplayList(HLModelIntermediette* model, ZDisplayList* zDisplayList);
|
||||
static void FromZSkeleton(HLModelIntermediette* model, ZSkeleton* zSkeleton);
|
||||
std::string ToOBJFile();
|
||||
std::string ToFBXFile();
|
||||
|
||||
std::string OutputCode();
|
||||
std::string OutputXML();
|
||||
|
||||
template <typename T>
|
||||
T* FindByName(std::string name);
|
||||
|
||||
template <typename T>
|
||||
T* FindByType();
|
||||
};
|
||||
|
||||
class HLTextureIntermediette : public HLIntermediette
|
||||
{
|
||||
public:
|
||||
ZTexture* tex;
|
||||
std::string fileName;
|
||||
|
||||
HLTextureIntermediette();
|
||||
|
||||
virtual void InitFromXML(tinyxml2::XMLElement* xmlElement);
|
||||
virtual std::string OutputCode();
|
||||
virtual void OutputXML(tinyxml2::XMLDocument* doc, tinyxml2::XMLElement* root);
|
||||
};
|
||||
|
||||
class HLTerminator : public HLIntermediette
|
||||
{
|
||||
public:
|
||||
HLTerminator();
|
||||
~HLTerminator();
|
||||
|
||||
virtual void OutputAssimp(aiScene* scene, std::vector<aiVector3D>* verts);
|
||||
};
|
||||
|
||||
enum class HLMaterialCmt
|
||||
{
|
||||
Wrap,
|
||||
Mirror,
|
||||
Clamp
|
||||
};
|
||||
|
||||
class HLMaterialIntermediette : public HLIntermediette
|
||||
{
|
||||
public:
|
||||
std::string textureName;
|
||||
//int32_t repeatH, repeatV;
|
||||
uint8_t clrR, clrG, clrB, clrA, clrM, clrL;
|
||||
//bool clampH, clampV;
|
||||
//bool mirrorH, mirrorV;
|
||||
HLMaterialCmt cmtH, cmtV;
|
||||
|
||||
// TODO: Remember to add lerp params here...
|
||||
|
||||
HLMaterialIntermediette();
|
||||
|
||||
virtual std::string OutputCode();
|
||||
virtual void OutputXML(tinyxml2::XMLDocument* doc, tinyxml2::XMLElement* parent);
|
||||
virtual void InitFromXML(tinyxml2::XMLElement* xmlElement);
|
||||
};
|
||||
|
||||
class HLMeshCommand
|
||||
{
|
||||
public:
|
||||
virtual void InitFromXML(tinyxml2::XMLElement* xmlElement);
|
||||
virtual std::string OutputCode(HLModelIntermediette* parent);
|
||||
virtual std::string OutputOBJ(HLModelIntermediette* parent);
|
||||
virtual void OutputAssimp(HLModelIntermediette* parent, aiScene* scene, aiMesh* mesh);
|
||||
|
||||
virtual void OutputXML(tinyxml2::XMLElement* parent);
|
||||
};
|
||||
|
||||
class HLVerticesIntermediette : public HLIntermediette
|
||||
{
|
||||
public:
|
||||
std::vector<Vertex> vertices;
|
||||
|
||||
HLVerticesIntermediette();
|
||||
|
||||
virtual void InitFromXML(tinyxml2::XMLElement* verticesElement);
|
||||
void InitFromVertices(std::vector<Vertex> dispListVertices);
|
||||
virtual std::string OutputCode(HLModelIntermediette* parent);
|
||||
virtual std::string OutputOBJ();
|
||||
virtual void OutputAssimp(aiScene* scene, std::vector<aiVector3D>* verts);
|
||||
virtual void OutputXML(tinyxml2::XMLDocument* doc, tinyxml2::XMLElement* root);
|
||||
};
|
||||
|
||||
class HLMeshCmdTriangle1 : public HLMeshCommand
|
||||
{
|
||||
public:
|
||||
int32_t v0, v1, v2, flag;
|
||||
|
||||
HLMeshCmdTriangle1();
|
||||
HLMeshCmdTriangle1(int32_t nV0, int32_t nV1, int32_t nV2, int32_t nFlag);
|
||||
|
||||
virtual void InitFromXML(tinyxml2::XMLElement* xmlElement);
|
||||
virtual std::string OutputCode(HLModelIntermediette* parent);
|
||||
virtual void OutputAssimp(HLModelIntermediette* parent, aiScene* scene, aiMesh* mesh);
|
||||
virtual void OutputXML(tinyxml2::XMLElement* parent);
|
||||
};
|
||||
|
||||
class HLMeshCmdTriangle2 : public HLMeshCommand
|
||||
{
|
||||
public:
|
||||
int32_t v0, v1, v2, flag0, v10, v11, v12, flag1;
|
||||
|
||||
HLMeshCmdTriangle2();
|
||||
HLMeshCmdTriangle2(int32_t nV0, int32_t nV1, int32_t nV2, int32_t nFlag0, int32_t nV10, int32_t nV11, int32_t nV12, int32_t nFlag1);
|
||||
|
||||
virtual void InitFromXML(tinyxml2::XMLElement* xmlElement);
|
||||
virtual std::string OutputCode(HLModelIntermediette* parent);
|
||||
virtual std::string OutputOBJ(HLModelIntermediette* parent);
|
||||
virtual void OutputAssimp(HLModelIntermediette* parent, aiScene* scene, aiMesh* mesh);
|
||||
virtual void OutputXML(tinyxml2::XMLElement* parent);
|
||||
};
|
||||
|
||||
class HLMeshCmdLoadVertices : public HLMeshCommand
|
||||
{
|
||||
public:
|
||||
uint8_t numVerts;
|
||||
uint8_t startIndex;
|
||||
|
||||
HLMeshCmdLoadVertices();
|
||||
HLMeshCmdLoadVertices(uint8_t nNumVerts, uint8_t nStartIndex);
|
||||
|
||||
virtual void OutputXML(tinyxml2::XMLElement* parent);
|
||||
virtual void InitFromXML(tinyxml2::XMLElement* xmlElement);
|
||||
virtual std::string OutputOBJ(HLModelIntermediette* parent);
|
||||
virtual void OutputAssimp(HLModelIntermediette* parent, aiScene* scene, aiMesh* mesh);
|
||||
virtual std::string OutputCode(HLModelIntermediette* parent);
|
||||
};
|
||||
|
||||
class HLMeshCmdCull : public HLMeshCommand
|
||||
{
|
||||
public:
|
||||
uint8_t indexStart;
|
||||
uint8_t indexEnd;
|
||||
|
||||
HLMeshCmdCull();
|
||||
|
||||
virtual void InitFromXML(tinyxml2::XMLElement* xmlElement);
|
||||
virtual std::string OutputCode(HLModelIntermediette* parent);
|
||||
};
|
||||
|
||||
class HLMeshCmdGeoSettings : public HLMeshCommand
|
||||
{
|
||||
public:
|
||||
std::string on, off;
|
||||
|
||||
HLMeshCmdGeoSettings();
|
||||
|
||||
virtual void InitFromXML(tinyxml2::XMLElement* xmlElement);
|
||||
virtual std::string OutputCode(HLModelIntermediette* parent);
|
||||
};
|
||||
|
||||
class HLMeshIntermediette : public HLIntermediette
|
||||
{
|
||||
public:
|
||||
std::vector<HLMeshCommand*> commands;
|
||||
|
||||
HLMeshIntermediette();
|
||||
|
||||
void InitFromXML(tinyxml2::XMLElement* xmlElement);
|
||||
std::string OutputCode(std::string materialName);
|
||||
virtual std::string OutputOBJ();
|
||||
virtual void OutputAssimp(aiScene* scene, std::vector<aiVector3D>* verts);
|
||||
virtual void OutputXML(tinyxml2::XMLDocument* doc, tinyxml2::XMLElement* root);
|
||||
};
|
||||
|
||||
class HLDisplayListCommand
|
||||
{
|
||||
public:
|
||||
virtual void InitFromXML(tinyxml2::XMLElement* xmlElement);
|
||||
virtual std::string OutputCode();
|
||||
};
|
||||
|
||||
class HLDisplayListCmdDrawMesh : public HLDisplayListCommand
|
||||
{
|
||||
public:
|
||||
std::string meshName, materialName;
|
||||
|
||||
virtual void InitFromXML(tinyxml2::XMLElement* xmlElement);
|
||||
virtual std::string OutputCode();
|
||||
};
|
||||
|
||||
class HLDisplayListCmdPipeSync : public HLDisplayListCommand
|
||||
{
|
||||
public:
|
||||
virtual void InitFromXML(tinyxml2::XMLElement* xmlElement);
|
||||
virtual std::string OutputCode();
|
||||
};
|
||||
|
||||
class HLDisplayListIntermediette : public HLIntermediette
|
||||
{
|
||||
public:
|
||||
std::vector<HLDisplayListCommand*> commands;
|
||||
int address;
|
||||
|
||||
HLDisplayListIntermediette();
|
||||
|
||||
virtual std::string OutputCode();
|
||||
virtual void InitFromXML(tinyxml2::XMLElement* xmlElement);
|
||||
};
|
||||
|
||||
class HLLimbCommand
|
||||
{
|
||||
public:
|
||||
std::string meshName, materialName;
|
||||
|
||||
HLLimbCommand();
|
||||
HLLimbCommand(std::string nMeshName, std::string nMaterialName);
|
||||
|
||||
virtual void InitFromXML(tinyxml2::XMLElement* xmlElement);
|
||||
virtual void OutputXML(tinyxml2::XMLElement* parent);
|
||||
virtual std::string OutputCode(HLModelIntermediette* parent);
|
||||
};
|
||||
|
||||
class HLLimbIntermediette : public HLIntermediette
|
||||
{
|
||||
public:
|
||||
std::vector<HLLimbCommand*> commands;
|
||||
|
||||
HLLimbIntermediette();
|
||||
|
||||
void InitFromXML(tinyxml2::XMLElement* xmlElement);
|
||||
std::string OutputCode();
|
||||
virtual void OutputXML(tinyxml2::XMLDocument* doc, tinyxml2::XMLElement* root);
|
||||
};
|
15
tools/ZAPD/ZAPD/HighLevel/HLTexture.cpp
Normal file
15
tools/ZAPD/ZAPD/HighLevel/HLTexture.cpp
Normal file
@ -0,0 +1,15 @@
|
||||
#include "HLTexture.h"
|
||||
#include "../StringHelper.h"
|
||||
#include "../stb_image.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
HLTexture* HLTexture::FromPNG(std::string pngFilePath, HLTextureType texType)
|
||||
{
|
||||
int comp;
|
||||
HLTexture* tex = new HLTexture();
|
||||
tex->type = texType;
|
||||
tex->bmpRgba = (uint8_t*)stbi_load((pngFilePath).c_str(), (int*)&tex->width, (int*)&tex->height, &comp, STBI_rgb_alpha);
|
||||
|
||||
return tex;
|
||||
}
|
31
tools/ZAPD/ZAPD/HighLevel/HLTexture.h
Normal file
31
tools/ZAPD/ZAPD/HighLevel/HLTexture.h
Normal file
@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
// TODO: This was duplicated from ZTexture. It's probably going to be modified to differentiate from ZTexture but if not, we're going to need to have the two share an enum.
|
||||
enum class HLTextureType
|
||||
{
|
||||
RGBA32bpp,
|
||||
RGBA16bpp,
|
||||
Palette4bpp,
|
||||
Palette8bpp,
|
||||
Grayscale4bpp,
|
||||
Grayscale8bpp,
|
||||
GrayscaleAlpha4bpp,
|
||||
GrayscaleAlpha8bpp,
|
||||
GrayscaleAlpha16bpp,
|
||||
Error
|
||||
};
|
||||
|
||||
|
||||
class HLTexture
|
||||
{
|
||||
public:
|
||||
static HLTexture* FromPNG(std::string pngFilePath, HLTextureType texType);
|
||||
|
||||
HLTextureType type;
|
||||
uint32_t width, height;
|
||||
uint8_t* bmpRgba;
|
||||
};
|
BIN
tools/ZAPD/ZAPD/Libs/assimp-vc142-mt.dll
Normal file
BIN
tools/ZAPD/ZAPD/Libs/assimp-vc142-mt.dll
Normal file
Binary file not shown.
BIN
tools/ZAPD/ZAPD/Libs/assimp-vc142-mt.lib
Normal file
BIN
tools/ZAPD/ZAPD/Libs/assimp-vc142-mt.lib
Normal file
Binary file not shown.
332
tools/ZAPD/ZAPD/Main.cpp
Normal file
332
tools/ZAPD/ZAPD/Main.cpp
Normal file
@ -0,0 +1,332 @@
|
||||
#include "ZFile.h"
|
||||
#include "ZTexture.h"
|
||||
#include "ZBlob.h"
|
||||
#include "ZAnimation.h"
|
||||
#include "HighLevel/HLModelIntermediette.h"
|
||||
#include "HighLevel/HLAnimationIntermediette.h"
|
||||
#include "Overlays/ZOverlay.h"
|
||||
#include "Path.h"
|
||||
#include "File.h"
|
||||
#include "Globals.h"
|
||||
|
||||
#if !defined(_MSC_VER) && !defined(__CYGWIN__)
|
||||
#include <execinfo.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
#include "tinyxml2.h"
|
||||
|
||||
using namespace tinyxml2;
|
||||
using namespace std;
|
||||
|
||||
bool Parse(string xmlFilePath, string basePath, string outPath, ZFileMode fileMode);
|
||||
|
||||
void BuildAssetTexture(string pngFilePath, TextureType texType, string outPath);
|
||||
void BuildAssetBlob(string blobFilePath, string outPath);
|
||||
void BuildAssetModelIntermediette(string mdlPath, string outPath);
|
||||
void BuildAssetAnimationIntermediette(string animPath, string outPath);
|
||||
|
||||
int NewMain(int argc, char* argv[]);
|
||||
|
||||
#if !defined(_MSC_VER) && !defined(__CYGWIN__)
|
||||
void ErrorHandler(int sig)
|
||||
{
|
||||
void* array[4096];
|
||||
char** symbols;
|
||||
size_t size;
|
||||
size = backtrace(array, 4096);
|
||||
symbols = backtrace_symbols(array, 4096);
|
||||
|
||||
for (int i = 1; i < size; i++)
|
||||
{
|
||||
size_t len = strlen(symbols[i]);
|
||||
cout << symbols[i] << "\n";
|
||||
}
|
||||
|
||||
//cout << "Error: signal " << sig << ":\n";
|
||||
backtrace_symbols_fd(array, size, STDERR_FILENO);
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
Globals* g = new Globals();
|
||||
return NewMain(argc, argv);
|
||||
}
|
||||
|
||||
int NewMain(int argc, char* argv[])
|
||||
{
|
||||
// Syntax: ZAPD.exe [mode (b/btex/bovl/e)] (Arbritrary Number of Arguments)
|
||||
printf("ZAPD: Zelda Asset Processor For Decomp\n");
|
||||
|
||||
if (argc < 2)
|
||||
{
|
||||
printf("ZAPD.exe [mode (b/btex/bovl/bsf/bblb/bmdlintr/bamnintr/e)] ...\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Parse File Mode
|
||||
string buildMode = argv[1];
|
||||
ZFileMode fileMode = ZFileMode::Invalid;
|
||||
|
||||
if (buildMode == "b")
|
||||
fileMode = ZFileMode::Build;
|
||||
else if (buildMode == "btex")
|
||||
fileMode = ZFileMode::BuildTexture;
|
||||
else if (buildMode == "bovl")
|
||||
fileMode = ZFileMode::BuildOverlay;
|
||||
else if (buildMode == "bsf")
|
||||
fileMode = ZFileMode::BuildSourceFile;
|
||||
else if (buildMode == "bblb")
|
||||
fileMode = ZFileMode::BuildBlob;
|
||||
else if (buildMode == "bmdlintr")
|
||||
fileMode = ZFileMode::BuildModelIntermediette;
|
||||
else if (buildMode == "bamnintr")
|
||||
fileMode = ZFileMode::BuildAnimationIntermediette;
|
||||
else if (buildMode == "e")
|
||||
fileMode = ZFileMode::Extract;
|
||||
|
||||
if (fileMode == ZFileMode::Invalid)
|
||||
{
|
||||
printf("Error: Invalid file mode '%s'\n", buildMode.c_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Parse other "commands"
|
||||
for (int i = 2; i < argc; i++)
|
||||
{
|
||||
string arg = argv[i];
|
||||
|
||||
if (arg == "-o" || arg == "--outputpath") // Set output path
|
||||
{
|
||||
Globals::Instance->outputPath = argv[i + 1];
|
||||
i++;
|
||||
}
|
||||
else if (arg == "-i" || arg == "--inputpath") // Set input path
|
||||
{
|
||||
Globals::Instance->inputPath = argv[i + 1];
|
||||
i++;
|
||||
}
|
||||
else if (arg == "-b" || arg == "--baserompath") // Set baserom path
|
||||
{
|
||||
Globals::Instance->baseRomPath = argv[i + 1];
|
||||
i++;
|
||||
}
|
||||
else if (arg == "-gsf") // Generate source file during extraction
|
||||
{
|
||||
Globals::Instance->genSourceFile = string(argv[i + 1]) == "1";
|
||||
i++;
|
||||
}
|
||||
else if (arg == "-ifp") // Include file prefix in generated symbols
|
||||
{
|
||||
Globals::Instance->includeFilePrefix = string(argv[i + 1]) == "1";
|
||||
i++;
|
||||
}
|
||||
else if (arg == "-tm") // Test Mode
|
||||
{
|
||||
Globals::Instance->testMode = string(argv[i + 1]) == "1";
|
||||
i++;
|
||||
}
|
||||
else if (arg == "-dm") // Debug Messages
|
||||
{
|
||||
Globals::Instance->debugMessages = string(argv[i + 1]) == "1";
|
||||
i++;
|
||||
}
|
||||
else if (arg == "-profile") // Profile
|
||||
{
|
||||
Globals::Instance->profile = string(argv[i + 1]) == "1";
|
||||
i++;
|
||||
}
|
||||
else if (arg == "-uer") // Split resources into their individual components (enabled by default)
|
||||
{
|
||||
Globals::Instance->useExternalResources = string(argv[i + 1]) == "1";
|
||||
i++;
|
||||
}
|
||||
else if (arg == "-tt") // Set texture type
|
||||
{
|
||||
Globals::Instance->texType = ZTexture::GetTextureTypeFromString(argv[i + 1]);
|
||||
i++;
|
||||
}
|
||||
else if (arg == "-cfg") // Set cfg path
|
||||
{
|
||||
Globals::Instance->cfgPath = argv[i + 1];
|
||||
i++;
|
||||
}
|
||||
else if (arg == "-sm") // Set symbol map path
|
||||
{
|
||||
Globals::Instance->GenSymbolMap(argv[i + 1]);
|
||||
i++;
|
||||
}
|
||||
else if (arg == "-rconf") // Read Config File
|
||||
{
|
||||
Globals::Instance->ReadConfigFile(argv[i + 1]);
|
||||
i++;
|
||||
}
|
||||
else if (arg == "-al") // Set actor list
|
||||
{
|
||||
i++;
|
||||
}
|
||||
else if (arg == "-ol") // Set object list
|
||||
{
|
||||
i++;
|
||||
}
|
||||
else if (arg == "-eh") // Enable Error Handler
|
||||
{
|
||||
#if !defined(_MSC_VER) && !defined(__CYGWIN__)
|
||||
signal(SIGSEGV, ErrorHandler);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if (fileMode == ZFileMode::Build || fileMode == ZFileMode::Extract || fileMode == ZFileMode::BuildSourceFile)
|
||||
{
|
||||
Parse(Globals::Instance->inputPath, Globals::Instance->baseRomPath, Globals::Instance->outputPath, fileMode);
|
||||
}
|
||||
else if (fileMode == ZFileMode::BuildTexture)
|
||||
{
|
||||
TextureType texType = Globals::Instance->texType;
|
||||
string pngFilePath = Globals::Instance->inputPath;
|
||||
string outFilePath = Globals::Instance->outputPath;
|
||||
|
||||
BuildAssetTexture(pngFilePath, texType, outFilePath);
|
||||
}
|
||||
else if (fileMode == ZFileMode::BuildBlob)
|
||||
{
|
||||
string blobFilePath = Globals::Instance->inputPath;
|
||||
string outFilePath = Globals::Instance->outputPath;
|
||||
|
||||
BuildAssetBlob(blobFilePath, outFilePath);
|
||||
}
|
||||
else if (fileMode == ZFileMode::BuildModelIntermediette)
|
||||
{
|
||||
BuildAssetModelIntermediette(Globals::Instance->inputPath, Globals::Instance->outputPath);
|
||||
}
|
||||
else if (fileMode == ZFileMode::BuildAnimationIntermediette)
|
||||
{
|
||||
BuildAssetAnimationIntermediette(Globals::Instance->inputPath, Globals::Instance->outputPath);
|
||||
}
|
||||
else if (fileMode == ZFileMode::BuildOverlay)
|
||||
{
|
||||
ZOverlay* overlay = ZOverlay::FromBuild(Path::GetDirectoryName(Globals::Instance->inputPath), Path::GetDirectoryName(Globals::Instance->cfgPath));
|
||||
|
||||
if (overlay)
|
||||
File::WriteAllText(Globals::Instance->outputPath, overlay->GetSourceOutputCode(""));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Parse(string xmlFilePath, string basePath, string outPath, ZFileMode fileMode)
|
||||
{
|
||||
XMLDocument doc;
|
||||
XMLError eResult = doc.LoadFile(xmlFilePath.c_str());
|
||||
|
||||
if (eResult != tinyxml2::XML_SUCCESS)
|
||||
return false;
|
||||
|
||||
XMLNode* root = doc.FirstChild();
|
||||
|
||||
if (root == nullptr)
|
||||
return false;
|
||||
|
||||
//vector<ZFile*> files = vector<ZFile*>();
|
||||
|
||||
for (XMLElement* child = root->FirstChildElement(); child != NULL; child = child->NextSiblingElement())
|
||||
{
|
||||
if (string(child->Name()) == "File")
|
||||
{
|
||||
ZFile* file = new ZFile(fileMode, child, basePath, outPath, false);
|
||||
Globals::Instance->files.push_back(file);
|
||||
}
|
||||
}
|
||||
|
||||
for (ZFile* file : Globals::Instance->files)
|
||||
{
|
||||
if (fileMode == ZFileMode::Build)
|
||||
file->BuildResources();
|
||||
else if (fileMode == ZFileMode::BuildSourceFile)
|
||||
file->BuildSourceFile(outPath);
|
||||
else
|
||||
file->ExtractResources(outPath);
|
||||
}
|
||||
|
||||
XMLElement* element = root->FirstChildElement("File");
|
||||
|
||||
if (element == nullptr)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void BuildAssetTexture(string pngFilePath, TextureType texType, string outPath)
|
||||
{
|
||||
vector<string> split = StringHelper::Split(outPath, "/");
|
||||
string name = StringHelper::Split(split[split.size() - 1], ".")[0];
|
||||
ZTexture* tex = ZTexture::FromPNG(pngFilePath, texType);
|
||||
string cfgPath = StringHelper::Split(pngFilePath, ".")[0] + ".cfg";
|
||||
|
||||
if (File::Exists(cfgPath))
|
||||
name = File::ReadAllText(cfgPath);
|
||||
|
||||
//string src = StringHelper::Sprintf("u64 %s[] = \n{\n", name.c_str()) + tex->GetSourceOutputCode(name) + "};\n";
|
||||
string src = tex->GetSourceOutputCode(name);
|
||||
|
||||
File::WriteAllText(outPath, src);
|
||||
|
||||
delete tex;
|
||||
}
|
||||
|
||||
void BuildAssetBlob(string blobFilePath, string outPath)
|
||||
{
|
||||
vector<string> split = StringHelper::Split(outPath, "/");
|
||||
ZBlob* blob = ZBlob::FromFile(blobFilePath);
|
||||
string name = StringHelper::Split(split[split.size() - 1], ".")[0];
|
||||
|
||||
//string src = StringHelper::Sprintf("u8 %s[] = \n{\n", name.c_str()) + blob->GetSourceOutputCode(name) + "};\n";
|
||||
string src = blob->GetSourceOutputCode(name);
|
||||
|
||||
File::WriteAllText(outPath, src);
|
||||
|
||||
delete blob;
|
||||
}
|
||||
|
||||
void BuildAssetModelIntermediette(string mdlPath, string outPath)
|
||||
{
|
||||
XMLDocument doc;
|
||||
XMLError eResult = doc.LoadFile(mdlPath.c_str());
|
||||
|
||||
vector<string> split = StringHelper::Split(outPath, "/");
|
||||
HLModelIntermediette* mdl = HLModelIntermediette::FromXML(doc.RootElement());
|
||||
string output = mdl->OutputCode();
|
||||
|
||||
File::WriteAllText(outPath, output);
|
||||
|
||||
delete mdl;
|
||||
}
|
||||
|
||||
void BuildAssetAnimationIntermediette(string animPath, string outPath)
|
||||
{
|
||||
vector<string> split = StringHelper::Split(outPath, "/");
|
||||
ZFile* file = new ZFile("", split[split.size() - 2]);
|
||||
HLAnimationIntermediette* anim = HLAnimationIntermediette::FromXML(animPath);
|
||||
ZAnimation* zAnim = anim->ToZAnimation();
|
||||
zAnim->SetName(Path::GetFileNameWithoutExtension(split[split.size() - 1]));
|
||||
zAnim->parent = file;
|
||||
//zAnim->rotationIndicesSeg = 1;
|
||||
//zAnim->rotationValuesSeg = 2;
|
||||
|
||||
zAnim->GetSourceOutputCode(split[split.size() - 2]);
|
||||
string output = "";
|
||||
|
||||
output += file->declarations[2]->text + "\n";
|
||||
output += file->declarations[1]->text + "\n";
|
||||
output += file->declarations[0]->text + "\n";
|
||||
|
||||
File::WriteAllText(outPath, output);
|
||||
|
||||
delete zAnim;
|
||||
delete file;
|
||||
}
|
231
tools/ZAPD/ZAPD/Overlays/ZOverlay.cpp
Normal file
231
tools/ZAPD/ZAPD/Overlays/ZOverlay.cpp
Normal file
@ -0,0 +1,231 @@
|
||||
#include "ZOverlay.h"
|
||||
#include "../File.h"
|
||||
#include "../Path.h"
|
||||
#include "../Directory.h"
|
||||
#include "../StringHelper.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace ELFIO;
|
||||
|
||||
ZOverlay::ZOverlay()
|
||||
{
|
||||
name = "";
|
||||
entries = vector<RelocationEntry*>();
|
||||
}
|
||||
|
||||
ZOverlay::ZOverlay(string nName) : ZOverlay()
|
||||
{
|
||||
name = nName;
|
||||
}
|
||||
|
||||
ZOverlay::~ZOverlay()
|
||||
{
|
||||
for (auto entry: entries)
|
||||
if (entry)
|
||||
delete entry;
|
||||
entries.clear();
|
||||
}
|
||||
|
||||
ZOverlay* ZOverlay::FromBuild(string buildPath, string cfgFolderPath)
|
||||
{
|
||||
string cfgText = File::ReadAllText(cfgFolderPath + "/overlay.cfg");
|
||||
vector<string> cfgLines = StringHelper::Split(cfgText, "\n");
|
||||
|
||||
ZOverlay* ovl = new ZOverlay(StringHelper::Strip(cfgLines[0], "\r"));
|
||||
|
||||
vector<string> relSections = {".rel.text", ".rel.data" , ".rel.rodata"};
|
||||
vector<string> sections = {".text", ".data" , ".rodata"};
|
||||
|
||||
int sectionOffs[5] = {0};
|
||||
vector<RelocationEntry*> textRelocs;
|
||||
vector<RelocationEntry*> dataRelocs;
|
||||
vector<RelocationEntry*> rodataRelocs;
|
||||
|
||||
|
||||
// get the elf files
|
||||
vector<elfio*> readers;
|
||||
for (int i = 1; i < cfgLines.size(); i++)
|
||||
{
|
||||
string elfPath = buildPath + "/" + cfgLines[i].substr(0, cfgLines[i].size()-2) + ".o";
|
||||
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 (auto curReader : readers)
|
||||
{
|
||||
Elf_Half sec_num = curReader->sections.size();
|
||||
for(int i = 0; i < sec_num; i++)
|
||||
{
|
||||
section* pSec = curReader->sections[i];
|
||||
|
||||
if (pSec->get_type() == SHT_REL && std::find(relSections.begin(), relSections.end(), pSec->get_name()) != relSections.end())
|
||||
{
|
||||
SectionType sectionType = GetSectionTypeFromStr(pSec->get_name());
|
||||
|
||||
if (sectionType == SectionType::ERROR)
|
||||
printf("WARNING: One of the section types returned ERROR\n");
|
||||
|
||||
relocation_section_accessor relocs(*curReader, pSec);
|
||||
for (Elf_Xword j = 0; j < relocs.get_entries_num(); j++)
|
||||
{
|
||||
Elf64_Addr offset;
|
||||
Elf_Word symbol;
|
||||
Elf_Word type;
|
||||
{
|
||||
Elf_Sxword addend;
|
||||
relocs.get_entry(j, offset, symbol, type, addend);
|
||||
}
|
||||
|
||||
string curSymName;
|
||||
Elf_Half curSymShndx = SHN_UNDEF;
|
||||
{
|
||||
symbol_section_accessor symbols(*curReader, curReader->sections[(Elf_Half)pSec->get_link()]);
|
||||
Elf64_Addr value;
|
||||
Elf_Xword size;
|
||||
unsigned char bind;
|
||||
unsigned char type;
|
||||
unsigned char other;
|
||||
symbols.get_symbol(symbol, curSymName, value, size, bind, type, curSymShndx, other);
|
||||
}
|
||||
|
||||
|
||||
// check symbols outside the elf but within the overlay
|
||||
if (curSymShndx == SHN_UNDEF)
|
||||
{
|
||||
for (auto reader : readers)
|
||||
{
|
||||
if (curSymShndx != SHN_UNDEF)
|
||||
break;
|
||||
|
||||
if (reader == curReader)
|
||||
continue;
|
||||
|
||||
auto sectionData = reader->sections[(Elf_Half)pSec->get_link()];
|
||||
|
||||
if (sectionData == nullptr)
|
||||
continue;
|
||||
|
||||
symbol_section_accessor symbols(*reader, sectionData);
|
||||
|
||||
for (Elf_Xword symIdx = 0; symIdx < symbols.get_symbols_num(); symIdx++)
|
||||
{
|
||||
Elf_Half shndx = SHN_UNDEF;
|
||||
Elf64_Addr value;
|
||||
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)
|
||||
{
|
||||
curSymShndx = shndx;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (curSymShndx != SHN_UNDEF)
|
||||
{
|
||||
RelocationType typeConverted = (RelocationType)type;
|
||||
offset += sectionOffs[sectionType];
|
||||
|
||||
RelocationEntry* reloc = new RelocationEntry(sectionType, typeConverted, 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 (int i = 0; i < sec_num; i++)
|
||||
{
|
||||
section* pSec = curReader->sections[i];
|
||||
if (pSec->get_type() == SHT_PROGBITS && std::find(sections.begin(), sections.end(), pSec->get_name()) != sections.end())
|
||||
{
|
||||
SectionType sectionType = GetSectionTypeFromStr(pSec->get_name());
|
||||
sectionOffs[sectionType] += pSec->get_size();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (auto reloc : textRelocs)
|
||||
ovl->entries.push_back(reloc);
|
||||
for (auto reloc : dataRelocs)
|
||||
ovl->entries.push_back(reloc);
|
||||
for (auto reloc : rodataRelocs)
|
||||
ovl->entries.push_back(reloc);
|
||||
|
||||
for (auto r: readers)
|
||||
delete r;
|
||||
readers.clear();
|
||||
|
||||
return ovl;
|
||||
}
|
||||
|
||||
string ZOverlay::GetSourceOutputCode(std::string prefix)
|
||||
{
|
||||
string output = "";
|
||||
|
||||
output += ".section .ovl\n";
|
||||
|
||||
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 += StringHelper::Sprintf(".word %i\n", entries.size());
|
||||
|
||||
for (int i = 0; i < entries.size(); i++)
|
||||
{
|
||||
RelocationEntry* reloc = entries[i];
|
||||
output += StringHelper::Sprintf(".word 0x%08X\n", reloc->CalcRelocationWord());
|
||||
}
|
||||
|
||||
int offset = ((int)entries.size() * 4) + 20;
|
||||
|
||||
while (offset % 16 != 12)
|
||||
{
|
||||
output += ".word 0\n";
|
||||
offset += 4;
|
||||
}
|
||||
|
||||
output += StringHelper::Sprintf(".word 0x%08X\n", offset + 4);
|
||||
return output;
|
||||
}
|
||||
|
||||
SectionType ZOverlay::GetSectionTypeFromStr(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;
|
||||
}
|
67
tools/ZAPD/ZAPD/Overlays/ZOverlay.h
Normal file
67
tools/ZAPD/ZAPD/Overlays/ZOverlay.h
Normal file
@ -0,0 +1,67 @@
|
||||
#pragma once
|
||||
|
||||
#include "../ZResource.h"
|
||||
#include "../tinyxml2.h"
|
||||
#include <elfio/elfio.hpp>
|
||||
|
||||
enum SectionType
|
||||
{
|
||||
Text = 1,
|
||||
Data = 2,
|
||||
RoData = 3,
|
||||
Bss = 4,
|
||||
ERROR = 255
|
||||
};
|
||||
|
||||
enum 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 |= sectionType << 30;
|
||||
relocationWord |= relocationType << 24;
|
||||
relocationWord |= offset;
|
||||
|
||||
return relocationWord;
|
||||
}
|
||||
};
|
||||
|
||||
class ZOverlay : public ZResource
|
||||
{
|
||||
public:
|
||||
std::string name;
|
||||
|
||||
ZOverlay(std::string nName);
|
||||
~ZOverlay();
|
||||
static ZOverlay* FromBuild(std::string buildPath, std::string cfgFolderPath);
|
||||
std::string GetSourceOutputCode(std::string prefix);
|
||||
|
||||
private:
|
||||
std::vector<RelocationEntry*> entries;
|
||||
|
||||
ZOverlay();
|
||||
|
||||
static SectionType GetSectionTypeFromStr(std::string sectionName);
|
||||
//static std::string GetOverlayNameFromElf(ELFIO::elfio& reader);
|
||||
};
|
47
tools/ZAPD/ZAPD/Path.h
Normal file
47
tools/ZAPD/ZAPD/Path.h
Normal file
@ -0,0 +1,47 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include "StringHelper.h"
|
||||
|
||||
#if defined(_MSC_VER) || defined(__clang__)
|
||||
#include <filesystem>
|
||||
namespace fs = std::filesystem;
|
||||
#else
|
||||
#include <experimental/filesystem>
|
||||
namespace fs = std::experimental::filesystem;
|
||||
#endif
|
||||
|
||||
class Path
|
||||
{
|
||||
public:
|
||||
static std::string GetFileNameWithoutExtension(std::string input)
|
||||
{
|
||||
std::vector<std::string> split = StringHelper::Split(input, "/");
|
||||
return split[split.size() - 1].substr(0, input.find_last_of("."));
|
||||
};
|
||||
|
||||
static std::string GetFileNameExtension(std::string input)
|
||||
{
|
||||
return input.substr(input.find_last_of("."), input.length());
|
||||
};
|
||||
|
||||
static std::string GetPath(std::string input)
|
||||
{
|
||||
std::vector<std::string> split = StringHelper::Split(input, "/");
|
||||
std::string output = "";
|
||||
|
||||
for (std::string str : split)
|
||||
{
|
||||
if (str.find_last_of(".") == std::string::npos)
|
||||
output += str + "/";
|
||||
}
|
||||
|
||||
return output;
|
||||
};
|
||||
|
||||
static std::string GetDirectoryName(std::string path)
|
||||
{
|
||||
return fs::path(path).parent_path().u8string();
|
||||
};
|
||||
};
|
75
tools/ZAPD/ZAPD/StringHelper.h
Normal file
75
tools/ZAPD/ZAPD/StringHelper.h
Normal file
@ -0,0 +1,75 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
|
||||
class StringHelper
|
||||
{
|
||||
public:
|
||||
static std::vector<std::string> Split(std::string s, std::string delimiter)
|
||||
{
|
||||
std::vector<std::string> result;
|
||||
|
||||
size_t pos = 0;
|
||||
std::string token;
|
||||
|
||||
while ((pos = s.find(delimiter)) != std::string::npos)
|
||||
{
|
||||
token = s.substr(0, pos);
|
||||
result.push_back(token);
|
||||
s.erase(0, pos + delimiter.length());
|
||||
}
|
||||
|
||||
if (s.length() != 0)
|
||||
result.push_back(s);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static std::string Strip(std::string s, std::string delimiter)
|
||||
{
|
||||
size_t pos = 0;
|
||||
std::string token;
|
||||
|
||||
while ((pos = s.find(delimiter)) != std::string::npos)
|
||||
{
|
||||
token = s.substr(0, pos);
|
||||
s.erase(pos, pos + delimiter.length());
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
static bool StartsWith(std::string s, std::string input)
|
||||
{
|
||||
return s.rfind(input, 0) == 0;
|
||||
}
|
||||
|
||||
static bool Contains(std::string s, std::string input)
|
||||
{
|
||||
return s.find(input) != std::string::npos;
|
||||
}
|
||||
|
||||
static bool EndsWith(std::string s, std::string input)
|
||||
{
|
||||
int inputLen = strlen(input.c_str());
|
||||
return s.rfind(input) == (s.size() - inputLen);
|
||||
}
|
||||
|
||||
static std::string Sprintf(const char* format, ...)
|
||||
{
|
||||
char buffer[32768];
|
||||
//char buffer[2048];
|
||||
std::string output = "";
|
||||
va_list va;
|
||||
|
||||
va_start(va, format);
|
||||
vsprintf(buffer, format, va);
|
||||
va_end(va);
|
||||
|
||||
output = buffer;
|
||||
return output;
|
||||
}
|
||||
};
|
10
tools/ZAPD/ZAPD/Vec3s.h
Normal file
10
tools/ZAPD/ZAPD/Vec3s.h
Normal file
@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
struct Vec3s
|
||||
{
|
||||
int16_t x, y, z;
|
||||
|
||||
Vec3s(int16_t nX, int16_t nY, int16_t nZ) { x = nX; y = nY; z = nZ; };
|
||||
};
|
269
tools/ZAPD/ZAPD/ZAPD.vcxproj
Normal file
269
tools/ZAPD/ZAPD/ZAPD.vcxproj
Normal file
@ -0,0 +1,269 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>15.0</VCProjectVersion>
|
||||
<ProjectGuid>{B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36}</ProjectGuid>
|
||||
<RootNamespace>ZAPD</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
<ProjectName>ZAPD</ProjectName>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<IncludePath>$(ProjectDir)sqlite;$(ProjectDir);$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(ProjectDir)Libs;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<IncludePath>$(IncludePath)</IncludePath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<Profile>true</Profile>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;USE_ASSIMP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<Profile>true</Profile>
|
||||
<AdditionalDependencies>assimp-vc142-mt.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpplatest</LanguageStandard>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Globals.cpp" />
|
||||
<ClCompile Include="HighLevel\HLAnimationIntermediette.cpp" />
|
||||
<ClCompile Include="HighLevel\HLModelIntermediette.cpp" />
|
||||
<ClCompile Include="HighLevel\HLTexture.cpp" />
|
||||
<ClCompile Include="Main.cpp" />
|
||||
<ClCompile Include="Overlays\ZOverlay.cpp" />
|
||||
<ClCompile Include="tinyxml2.cpp" />
|
||||
<ClCompile Include="ZAnimation.cpp" />
|
||||
<ClCompile Include="ZBlob.cpp" />
|
||||
<ClCompile Include="ZCollision.cpp" />
|
||||
<ClCompile Include="ZCutscene.cpp" />
|
||||
<ClCompile Include="ZDisplayList.cpp" />
|
||||
<ClCompile Include="ZFile.cpp" />
|
||||
<ClCompile Include="ZSkeleton.cpp" />
|
||||
<ClCompile Include="ZResource.cpp" />
|
||||
<ClCompile Include="ZRoom\Commands\EndMarker.cpp" />
|
||||
<ClCompile Include="ZRoom\Commands\SetActorList.cpp" />
|
||||
<ClCompile Include="ZRoom\Commands\SetAlternateHeaders.cpp" />
|
||||
<ClCompile Include="ZRoom\Commands\SetCameraSettings.cpp" />
|
||||
<ClCompile Include="ZRoom\Commands\SetCollisionHeader.cpp" />
|
||||
<ClCompile Include="ZRoom\Commands\SetCutscenes.cpp" />
|
||||
<ClCompile Include="ZRoom\Commands\SetEchoSettings.cpp" />
|
||||
<ClCompile Include="ZRoom\Commands\SetEntranceList.cpp" />
|
||||
<ClCompile Include="ZRoom\Commands\SetExitList.cpp" />
|
||||
<ClCompile Include="ZRoom\Commands\SetLightingSettings.cpp" />
|
||||
<ClCompile Include="ZRoom\Commands\SetLightList.cpp" />
|
||||
<ClCompile Include="ZRoom\Commands\SetMesh.cpp" />
|
||||
<ClCompile Include="ZRoom\Commands\SetObjectList.cpp" />
|
||||
<ClCompile Include="ZRoom\Commands\SetPathways.cpp" />
|
||||
<ClCompile Include="ZRoom\Commands\SetRoomBehavior.cpp" />
|
||||
<ClCompile Include="ZRoom\Commands\SetRoomList.cpp" />
|
||||
<ClCompile Include="ZRoom\Commands\SetSkyboxModifier.cpp" />
|
||||
<ClCompile Include="ZRoom\Commands\SetSkyboxSettings.cpp" />
|
||||
<ClCompile Include="ZRoom\Commands\SetSoundSettings.cpp" />
|
||||
<ClCompile Include="ZRoom\Commands\SetSpecialObjects.cpp" />
|
||||
<ClCompile Include="ZRoom\Commands\SetStartPositionList.cpp" />
|
||||
<ClCompile Include="ZRoom\Commands\SetTimeSettings.cpp" />
|
||||
<ClCompile Include="ZRoom\Commands\SetTransitionActorList.cpp" />
|
||||
<ClCompile Include="ZRoom\Commands\SetWind.cpp" />
|
||||
<ClCompile Include="ZRoom\Commands\Unused09.cpp" />
|
||||
<ClCompile Include="ZRoom\Commands\ZRoomCommandUnk.cpp" />
|
||||
<ClCompile Include="ZRoom\ZRoom.cpp" />
|
||||
<ClCompile Include="ZRoom\ZRoomCommand.cpp" />
|
||||
<ClCompile Include="ZTexture.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="BitConverter.h" />
|
||||
<ClInclude Include="Directory.h" />
|
||||
<ClInclude Include="elfio\elfio.hpp" />
|
||||
<ClInclude Include="elfio\elfio_dump.hpp" />
|
||||
<ClInclude Include="elfio\elfio_dynamic.hpp" />
|
||||
<ClInclude Include="elfio\elfio_header.hpp" />
|
||||
<ClInclude Include="elfio\elfio_note.hpp" />
|
||||
<ClInclude Include="elfio\elfio_relocation.hpp" />
|
||||
<ClInclude Include="elfio\elfio_section.hpp" />
|
||||
<ClInclude Include="elfio\elfio_segment.hpp" />
|
||||
<ClInclude Include="elfio\elfio_strings.hpp" />
|
||||
<ClInclude Include="elfio\elfio_symbols.hpp" />
|
||||
<ClInclude Include="elfio\elfio_utils.hpp" />
|
||||
<ClInclude Include="elfio\elf_types.hpp" />
|
||||
<ClInclude Include="File.h" />
|
||||
<ClInclude Include="Globals.h" />
|
||||
<ClInclude Include="HighLevel\HLAnimation.h" />
|
||||
<ClInclude Include="HighLevel\HLAnimationIntermediette.h" />
|
||||
<ClInclude Include="HighLevel\HLFileIntermediette.h" />
|
||||
<ClInclude Include="HighLevel\HLModelIntermediette.h" />
|
||||
<ClInclude Include="HighLevel\HLTexture.h" />
|
||||
<ClInclude Include="json.hpp" />
|
||||
<ClInclude Include="OpenFBX\miniz.h" />
|
||||
<ClInclude Include="OpenFBX\ofbx.h" />
|
||||
<ClInclude Include="Overlays\ZOverlay.h" />
|
||||
<ClInclude Include="Path.h" />
|
||||
<ClInclude Include="sqlite_orm.h" />
|
||||
<ClInclude Include="stb_image.h" />
|
||||
<ClInclude Include="stb_image_write.h" />
|
||||
<ClInclude Include="StringHelper.h" />
|
||||
<ClInclude Include="tinyxml2.h" />
|
||||
<ClInclude Include="tiny_gltf.h" />
|
||||
<ClInclude Include="Vec3s.h" />
|
||||
<ClInclude Include="ZAnimation.h" />
|
||||
<ClInclude Include="ZBlob.h" />
|
||||
<ClInclude Include="ZCollision.h" />
|
||||
<ClInclude Include="ZCutscene.h" />
|
||||
<ClInclude Include="ZDisplayList.h" />
|
||||
<ClInclude Include="ZFile.h" />
|
||||
<ClInclude Include="ZSkeleton.h" />
|
||||
<ClInclude Include="ZResource.h" />
|
||||
<ClInclude Include="ZRoom\ActorList.h" />
|
||||
<ClInclude Include="ZRoom\Commands\EndMarker.h" />
|
||||
<ClInclude Include="ZRoom\Commands\SetActorList.h" />
|
||||
<ClInclude Include="ZRoom\Commands\SetAlternateHeaders.h" />
|
||||
<ClInclude Include="ZRoom\Commands\SetCameraSettings.h" />
|
||||
<ClInclude Include="ZRoom\Commands\SetCollisionHeader.h" />
|
||||
<ClInclude Include="ZRoom\Commands\SetCutscenes.h" />
|
||||
<ClInclude Include="ZRoom\Commands\SetEchoSettings.h" />
|
||||
<ClInclude Include="ZRoom\Commands\SetEntranceList.h" />
|
||||
<ClInclude Include="ZRoom\Commands\SetExitList.h" />
|
||||
<ClInclude Include="ZRoom\Commands\SetLightingSettings.h" />
|
||||
<ClInclude Include="ZRoom\Commands\SetLightList.h" />
|
||||
<ClInclude Include="ZRoom\Commands\SetMesh.h" />
|
||||
<ClInclude Include="ZRoom\Commands\SetObjectList.h" />
|
||||
<ClInclude Include="ZRoom\Commands\SetPathways.h" />
|
||||
<ClInclude Include="ZRoom\Commands\SetRoomBehavior.h" />
|
||||
<ClInclude Include="ZRoom\Commands\SetRoomList.h" />
|
||||
<ClInclude Include="ZRoom\Commands\SetSkyboxModifier.h" />
|
||||
<ClInclude Include="ZRoom\Commands\SetSkyboxSettings.h" />
|
||||
<ClInclude Include="ZRoom\Commands\SetSoundSettings.h" />
|
||||
<ClInclude Include="ZRoom\Commands\SetSpecialObjects.h" />
|
||||
<ClInclude Include="ZRoom\Commands\SetStartPositionList.h" />
|
||||
<ClInclude Include="ZRoom\Commands\SetTimeSettings.h" />
|
||||
<ClInclude Include="ZRoom\Commands\SetTransitionActorList.h" />
|
||||
<ClInclude Include="ZRoom\Commands\SetWind.h" />
|
||||
<ClInclude Include="ZRoom\Commands\Unused09.h" />
|
||||
<ClInclude Include="ZRoom\Commands\ZRoomCommandUnk.h" />
|
||||
<ClInclude Include="ZRoom\ObjectList.h" />
|
||||
<ClInclude Include="ZRoom\ZRoom.h" />
|
||||
<ClInclude Include="ZRoom\ZRoomCommand.h" />
|
||||
<ClInclude Include="ZTexture.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Text Include="..\SymbolMap_OoTMqDbg.txt">
|
||||
<DeploymentContent>true</DeploymentContent>
|
||||
</Text>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CopyFileToFolders Include="Libs\assimp-vc142-mt.dll">
|
||||
<FileType>Document</FileType>
|
||||
</CopyFileToFolders>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets" />
|
||||
</Project>
|
424
tools/ZAPD/ZAPD/ZAPD.vcxproj.filters
Normal file
424
tools/ZAPD/ZAPD/ZAPD.vcxproj.filters
Normal file
@ -0,0 +1,424 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\OpenFBX">
|
||||
<UniqueIdentifier>{c5d86b0a-fff0-47cf-83af-807dd8267ad1}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\Libraries">
|
||||
<UniqueIdentifier>{02148456-5068-4613-8478-f10addc58e70}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\Libraries">
|
||||
<UniqueIdentifier>{bcab3136-95ba-4839-833c-43d78ad6e335}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\Libraries\elfio">
|
||||
<UniqueIdentifier>{dc06ed84-f6fe-4277-80f3-d62bd5cdbb98}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\Z64">
|
||||
<UniqueIdentifier>{6049c045-bc38-4221-b29e-ca6d4d8af4aa}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\Z64\ZRoom">
|
||||
<UniqueIdentifier>{490e3a08-047b-48d3-ab53-3a860a3b92aa}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\Z64\ZRoom\Commands">
|
||||
<UniqueIdentifier>{26c06845-8e8e-4b79-ad18-07c4f9c0f801}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\Z64">
|
||||
<UniqueIdentifier>{d45c420d-2378-47ac-92c5-80db9475c195}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\Z64\ZRoom">
|
||||
<UniqueIdentifier>{03cc56a2-e0e8-4167-80a0-98fb900a959a}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\Z64\ZRoom\Commands">
|
||||
<UniqueIdentifier>{73db0879-6df8-4f6a-8cc2-a1f836e9e796}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\HighLevel">
|
||||
<UniqueIdentifier>{9464ff21-96af-4b7d-a57b-f62bd9b7389a}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\HighLevel\Model">
|
||||
<UniqueIdentifier>{e9865c34-fd69-413c-8cce-3f51331c3503}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\HighLevel">
|
||||
<UniqueIdentifier>{0f9980bb-ae46-4891-a39e-275bf255f010}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\HighLevel\Room">
|
||||
<UniqueIdentifier>{11dbd8e6-d97a-42a5-b40c-e1350389544d}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\Libraries\fbx">
|
||||
<UniqueIdentifier>{be9a5be0-ec6a-4200-8e39-bb58c7da7aa8}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Main.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ZRoom\ZRoom.cpp">
|
||||
<Filter>Source Files\Z64\ZRoom</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ZRoom\Commands\SetEchoSettings.cpp">
|
||||
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ZRoom\ZRoomCommand.cpp">
|
||||
<Filter>Source Files\Z64\ZRoom</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ZRoom\Commands\SetSoundSettings.cpp">
|
||||
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ZRoom\Commands\SetWind.cpp">
|
||||
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ZRoom\Commands\SetTimeSettings.cpp">
|
||||
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ZRoom\Commands\SetSpecialObjects.cpp">
|
||||
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ZRoom\Commands\SetRoomBehavior.cpp">
|
||||
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ZRoom\Commands\SetSkyboxSettings.cpp">
|
||||
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ZRoom\Commands\SetCameraSettings.cpp">
|
||||
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ZRoom\Commands\SetSkyboxModifier.cpp">
|
||||
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ZRoom\Commands\SetActorList.cpp">
|
||||
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ZRoom\Commands\SetEntranceList.cpp">
|
||||
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ZRoom\Commands\SetStartPositionList.cpp">
|
||||
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Globals.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ZRoom\Commands\SetAlternateHeaders.cpp">
|
||||
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ZRoom\Commands\SetExitList.cpp">
|
||||
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ZRoom\Commands\EndMarker.cpp">
|
||||
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ZRoom\Commands\SetCollisionHeader.cpp">
|
||||
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ZRoom\Commands\SetRoomList.cpp">
|
||||
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ZRoom\Commands\SetObjectList.cpp">
|
||||
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ZRoom\Commands\SetMesh.cpp">
|
||||
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ZRoom\Commands\Unused09.cpp">
|
||||
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ZRoom\Commands\SetLightingSettings.cpp">
|
||||
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ZRoom\Commands\SetTransitionActorList.cpp">
|
||||
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ZRoom\Commands\SetPathways.cpp">
|
||||
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ZRoom\Commands\SetCutscenes.cpp">
|
||||
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="tinyxml2.cpp">
|
||||
<Filter>Source Files\Libraries</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ZAnimation.cpp">
|
||||
<Filter>Source Files\Z64</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ZBlob.cpp">
|
||||
<Filter>Source Files\Z64</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ZCutscene.cpp">
|
||||
<Filter>Source Files\Z64</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ZDisplayList.cpp">
|
||||
<Filter>Source Files\Z64</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ZFile.cpp">
|
||||
<Filter>Source Files\Z64</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ZResource.cpp">
|
||||
<Filter>Source Files\Z64</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ZTexture.cpp">
|
||||
<Filter>Source Files\Z64</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Overlays\ZOverlay.cpp">
|
||||
<Filter>Source Files\Z64</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="HighLevel\HLAnimationIntermediette.cpp">
|
||||
<Filter>Source Files\HighLevel</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="HighLevel\HLModelIntermediette.cpp">
|
||||
<Filter>Source Files\HighLevel</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="HighLevel\HLTexture.cpp">
|
||||
<Filter>Source Files\HighLevel</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ZSkeleton.cpp">
|
||||
<Filter>Source Files\Z64</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ZRoom\Commands\SetLightList.cpp">
|
||||
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ZRoom\Commands\ZRoomCommandUnk.cpp">
|
||||
<Filter>Source Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ZCollision.cpp">
|
||||
<Filter>Source Files\Z64</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Path.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="File.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Directory.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ZRoom\ZRoom.h">
|
||||
<Filter>Header Files\Z64\ZRoom</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ZRoom\ZRoomCommand.h">
|
||||
<Filter>Header Files\Z64\ZRoom</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ZRoom\Commands\SetEchoSettings.h">
|
||||
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ZRoom\Commands\SetSoundSettings.h">
|
||||
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ZRoom\Commands\SetWind.h">
|
||||
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ZRoom\Commands\SetTimeSettings.h">
|
||||
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="BitConverter.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ZRoom\Commands\SetSpecialObjects.h">
|
||||
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ZRoom\Commands\SetRoomBehavior.h">
|
||||
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ZRoom\Commands\SetSkyboxSettings.h">
|
||||
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ZRoom\Commands\SetCameraSettings.h">
|
||||
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ZRoom\Commands\SetSkyboxModifier.h">
|
||||
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ZRoom\Commands\SetActorList.h">
|
||||
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ZRoom\Commands\SetEntranceList.h">
|
||||
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ZRoom\Commands\SetStartPositionList.h">
|
||||
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="elfio\elf_types.hpp">
|
||||
<Filter>Header Files\Libraries\elfio</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="elfio\elfio.hpp">
|
||||
<Filter>Header Files\Libraries\elfio</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="elfio\elfio_dump.hpp">
|
||||
<Filter>Header Files\Libraries\elfio</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="elfio\elfio_dynamic.hpp">
|
||||
<Filter>Header Files\Libraries\elfio</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="elfio\elfio_header.hpp">
|
||||
<Filter>Header Files\Libraries\elfio</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="elfio\elfio_note.hpp">
|
||||
<Filter>Header Files\Libraries\elfio</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="elfio\elfio_relocation.hpp">
|
||||
<Filter>Header Files\Libraries\elfio</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="elfio\elfio_section.hpp">
|
||||
<Filter>Header Files\Libraries\elfio</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="elfio\elfio_segment.hpp">
|
||||
<Filter>Header Files\Libraries\elfio</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="elfio\elfio_strings.hpp">
|
||||
<Filter>Header Files\Libraries\elfio</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="elfio\elfio_symbols.hpp">
|
||||
<Filter>Header Files\Libraries\elfio</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="elfio\elfio_utils.hpp">
|
||||
<Filter>Header Files\Libraries\elfio</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="StringHelper.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Globals.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ZRoom\Commands\SetAlternateHeaders.h">
|
||||
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ZRoom\Commands\SetExitList.h">
|
||||
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ZRoom\Commands\EndMarker.h">
|
||||
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ZRoom\Commands\SetCollisionHeader.h">
|
||||
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ZRoom\Commands\SetRoomList.h">
|
||||
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ZRoom\Commands\SetObjectList.h">
|
||||
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ZRoom\Commands\SetMesh.h">
|
||||
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ZRoom\Commands\Unused09.h">
|
||||
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ZRoom\ObjectList.h">
|
||||
<Filter>Header Files\Z64\ZRoom</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ZRoom\ActorList.h">
|
||||
<Filter>Header Files\Z64\ZRoom</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ZRoom\Commands\SetLightingSettings.h">
|
||||
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ZRoom\Commands\SetTransitionActorList.h">
|
||||
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ZRoom\Commands\SetPathways.h">
|
||||
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ZRoom\Commands\SetCutscenes.h">
|
||||
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Vec3s.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="OpenFBX\ofbx.h">
|
||||
<Filter>Header Files\OpenFBX</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="OpenFBX\miniz.h">
|
||||
<Filter>Header Files\OpenFBX</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="json.hpp">
|
||||
<Filter>Header Files\Libraries</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="stb_image.h">
|
||||
<Filter>Header Files\Libraries</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="stb_image_write.h">
|
||||
<Filter>Header Files\Libraries</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="tiny_gltf.h">
|
||||
<Filter>Header Files\Libraries</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="tinyxml2.h">
|
||||
<Filter>Header Files\Libraries</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Overlays\ZOverlay.h">
|
||||
<Filter>Header Files\Z64</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ZTexture.h">
|
||||
<Filter>Header Files\Z64</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ZAnimation.h">
|
||||
<Filter>Header Files\Z64</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ZBlob.h">
|
||||
<Filter>Header Files\Z64</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ZCutscene.h">
|
||||
<Filter>Header Files\Z64</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ZDisplayList.h">
|
||||
<Filter>Header Files\Z64</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ZFile.h">
|
||||
<Filter>Header Files\Z64</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ZResource.h">
|
||||
<Filter>Header Files\Z64</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="HighLevel\HLTexture.h">
|
||||
<Filter>Header Files\HighLevel</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="HighLevel\HLAnimation.h">
|
||||
<Filter>Header Files\HighLevel</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="HighLevel\HLAnimationIntermediette.h">
|
||||
<Filter>Header Files\HighLevel</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="HighLevel\HLModelIntermediette.h">
|
||||
<Filter>Header Files\HighLevel</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ZSkeleton.h">
|
||||
<Filter>Header Files\Z64</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="HighLevel\HLFileIntermediette.h">
|
||||
<Filter>Header Files\HighLevel</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ZRoom\Commands\SetLightList.h">
|
||||
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ZRoom\Commands\ZRoomCommandUnk.h">
|
||||
<Filter>Header Files\Z64\ZRoom\Commands</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="sqlite_orm.h">
|
||||
<Filter>Header Files\Libraries</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ZCollision.h">
|
||||
<Filter>Header Files\Z64</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Text Include="..\SymbolMap_OoTMqDbg.txt">
|
||||
<Filter>Resource Files</Filter>
|
||||
</Text>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CopyFileToFolders Include="Libs\assimp-vc142-mt.dll">
|
||||
<Filter>Resource Files</Filter>
|
||||
</CopyFileToFolders>
|
||||
</ItemGroup>
|
||||
</Project>
|
184
tools/ZAPD/ZAPD/ZAnimation.cpp
Normal file
184
tools/ZAPD/ZAPD/ZAnimation.cpp
Normal file
@ -0,0 +1,184 @@
|
||||
#include "ZAnimation.h"
|
||||
#include "ZFile.h"
|
||||
#include "BitConverter.h"
|
||||
#include "StringHelper.h"
|
||||
#include "File.h"
|
||||
#include "HighLevel/HLAnimationIntermediette.h"
|
||||
#include "Globals.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
ZAnimation::ZAnimation() : ZResource()
|
||||
{
|
||||
frameCount = 0;
|
||||
}
|
||||
|
||||
void ZAnimation::ParseRawData()
|
||||
{
|
||||
uint8_t* data = rawData.data();
|
||||
|
||||
// Read the header
|
||||
frameCount = BitConverter::ToInt16BE(data, rawDataIndex + 0);
|
||||
}
|
||||
|
||||
void ZAnimation::Save(string outFolder)
|
||||
{
|
||||
if (Globals::Instance->testMode)
|
||||
{
|
||||
HLAnimationIntermediette* anim = HLAnimationIntermediette::FromZAnimation(this);
|
||||
string xml = anim->OutputXML();
|
||||
File::WriteAllText(outFolder + "/" + name + ".anmi", xml);
|
||||
|
||||
delete anim;
|
||||
}
|
||||
}
|
||||
|
||||
void ZAnimation::ParseXML(tinyxml2::XMLElement* reader)
|
||||
{
|
||||
ZResource::ParseXML(reader);
|
||||
|
||||
name = reader->Attribute("Name");
|
||||
}
|
||||
|
||||
string ZAnimation::GetSourceOutputCode(string prefix)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
ZNormalAnimation::ZNormalAnimation() : ZAnimation()
|
||||
{
|
||||
rotationValues = vector<uint16_t>();
|
||||
rotationIndices = vector<RotationIndex>();
|
||||
limit = 0;
|
||||
}
|
||||
|
||||
std::string ZNormalAnimation::GetSourceOutputCode(std::string prefix)
|
||||
{
|
||||
if (parent != nullptr)
|
||||
{
|
||||
string defaultPrefix = name.c_str();
|
||||
defaultPrefix.replace(0, 1, "s"); // replace g prefix with s for local variables
|
||||
|
||||
string headerStr = StringHelper::Sprintf("{ %i }, %sFrameData, %sJointIndices, %i",
|
||||
frameCount, defaultPrefix.c_str(), defaultPrefix.c_str(), limit);
|
||||
parent->declarations[rawDataIndex] = new Declaration(DeclarationAlignment::None, 16, "AnimationHeader", StringHelper::Sprintf("%s", name.c_str()), false, headerStr);
|
||||
|
||||
string indicesStr = "";
|
||||
string valuesStr = " ";
|
||||
const int lineLength = 14;
|
||||
const int offset = 0;
|
||||
|
||||
for (int i = 0; i < rotationValues.size(); i++)
|
||||
{
|
||||
valuesStr += StringHelper::Sprintf("0x%04X, ", rotationValues[i]);
|
||||
|
||||
if ((i - offset + 1) % lineLength == 0)
|
||||
valuesStr += "\n ";
|
||||
}
|
||||
|
||||
for (int 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(rotationValuesSeg, DeclarationAlignment::Align16, (int)rotationValues.size() * 2, "static s16",
|
||||
StringHelper::Sprintf("%sFrameData", defaultPrefix.c_str()), rotationValues.size(), valuesStr);
|
||||
|
||||
parent->AddDeclarationArray(rotationIndicesSeg, DeclarationAlignment::Align16, (int)rotationIndices.size() * 6, "static JointIndex",
|
||||
StringHelper::Sprintf("%sJointIndices", defaultPrefix.c_str()), rotationIndices.size(), indicesStr);
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
int ZNormalAnimation::GetRawDataSize()
|
||||
{
|
||||
return 16;
|
||||
}
|
||||
|
||||
ZNormalAnimation* ZNormalAnimation::ExtractFromXML(tinyxml2::XMLElement* reader, std::vector<uint8_t> nRawData, int rawDataIndex, std::string nRelPath)
|
||||
{
|
||||
ZNormalAnimation* anim = new ZNormalAnimation();
|
||||
anim->rawData = nRawData;
|
||||
anim->rawDataIndex = rawDataIndex;
|
||||
anim->ParseXML(reader);
|
||||
anim->ParseRawData();
|
||||
|
||||
return anim;
|
||||
}
|
||||
|
||||
void ZNormalAnimation::ParseRawData()
|
||||
{
|
||||
ZAnimation::ParseRawData();
|
||||
|
||||
uint8_t* data = rawData.data();
|
||||
|
||||
rotationValuesSeg = BitConverter::ToInt32BE(data, rawDataIndex + 4) & 0x00FFFFFF;
|
||||
rotationIndicesSeg = BitConverter::ToInt32BE(data, rawDataIndex + 8) & 0x00FFFFFF;
|
||||
limit = BitConverter::ToInt16BE(data, rawDataIndex + 12);
|
||||
|
||||
uint32_t currentPtr = rotationValuesSeg;
|
||||
|
||||
// Read the Rotation Values
|
||||
for (int i = 0; i < ((rotationIndicesSeg - rotationValuesSeg) / 2); i++)
|
||||
{
|
||||
rotationValues.push_back(BitConverter::ToInt16BE(data, currentPtr));
|
||||
currentPtr += 2;
|
||||
}
|
||||
|
||||
currentPtr = rotationIndicesSeg;
|
||||
|
||||
// Read the Rotation Indices
|
||||
for (int i = 0; i < ((rawDataIndex - rotationIndicesSeg) / 6); i++)
|
||||
{
|
||||
rotationIndices.push_back(RotationIndex(BitConverter::ToInt16BE(data, currentPtr), BitConverter::ToInt16BE(data, currentPtr + 2), BitConverter::ToInt16BE(data, currentPtr + 4)));
|
||||
currentPtr += 6;
|
||||
}
|
||||
}
|
||||
|
||||
ZLinkAnimation::ZLinkAnimation() : ZAnimation()
|
||||
{
|
||||
segmentAddress = 0;
|
||||
}
|
||||
|
||||
std::string ZLinkAnimation::GetSourceOutputCode(std::string prefix)
|
||||
{
|
||||
if (parent != nullptr)
|
||||
{
|
||||
string segSymbol = segmentAddress == 0 ? "NULL" : parent->GetDeclarationName(segmentAddress, StringHelper::Sprintf("%sSeg%06X", name.c_str(), segmentAddress));
|
||||
string headerStr = StringHelper::Sprintf("{ %i }, 0x%08X",
|
||||
frameCount, segmentAddress);
|
||||
parent->declarations[rawDataIndex] = new Declaration(DeclarationAlignment::None, 16, "LinkAnimationHeader", StringHelper::Sprintf("%s", name.c_str()), false, headerStr);
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
int ZLinkAnimation::GetRawDataSize()
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
|
||||
ZLinkAnimation* ZLinkAnimation::ExtractFromXML(tinyxml2::XMLElement* reader, std::vector<uint8_t> nRawData, int rawDataIndex, std::string nRelPath)
|
||||
{
|
||||
ZLinkAnimation* anim = new ZLinkAnimation();
|
||||
anim->rawData = nRawData;
|
||||
anim->rawDataIndex = rawDataIndex;
|
||||
anim->ParseXML(reader);
|
||||
anim->ParseRawData();
|
||||
|
||||
return anim;
|
||||
}
|
||||
|
||||
void ZLinkAnimation::ParseRawData()
|
||||
{
|
||||
ZAnimation::ParseRawData();
|
||||
|
||||
uint8_t* data = rawData.data();
|
||||
|
||||
//segmentAddress = SEG2FILESPACE(BitConverter::ToInt32BE(data, rawDataIndex + 4));
|
||||
segmentAddress = (BitConverter::ToInt32BE(data, rawDataIndex + 4));
|
||||
}
|
68
tools/ZAPD/ZAPD/ZAnimation.h
Normal file
68
tools/ZAPD/ZAPD/ZAnimation.h
Normal file
@ -0,0 +1,68 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <stdint.h>
|
||||
#include "ZResource.h"
|
||||
#include "Vec3s.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();
|
||||
|
||||
std::string GetSourceOutputCode(std::string prefix);
|
||||
protected:
|
||||
|
||||
virtual void ParseRawData();
|
||||
void Save(std::string outFolder);
|
||||
void ParseXML(tinyxml2::XMLElement* reader);
|
||||
};
|
||||
|
||||
class ZNormalAnimation : public ZAnimation
|
||||
{
|
||||
public:
|
||||
std::vector<uint16_t> rotationValues;
|
||||
std::vector<RotationIndex> rotationIndices;
|
||||
uint32_t rotationValuesSeg;
|
||||
uint32_t rotationIndicesSeg;
|
||||
int16_t limit;
|
||||
|
||||
ZNormalAnimation();
|
||||
|
||||
std::string GetSourceOutputCode(std::string prefix);
|
||||
virtual int GetRawDataSize();
|
||||
|
||||
static ZNormalAnimation* ExtractFromXML(tinyxml2::XMLElement* reader, std::vector<uint8_t> nRawData, int rawDataIndex, std::string nRelPath);
|
||||
|
||||
protected:
|
||||
virtual void ParseRawData();
|
||||
};
|
||||
|
||||
class ZLinkAnimation : public ZAnimation
|
||||
{
|
||||
public:
|
||||
uint32_t segmentAddress;
|
||||
|
||||
ZLinkAnimation();
|
||||
|
||||
std::string GetSourceOutputCode(std::string prefix);
|
||||
virtual int GetRawDataSize();
|
||||
|
||||
static ZLinkAnimation* ExtractFromXML(tinyxml2::XMLElement* reader, std::vector<uint8_t> nRawData, int rawDataIndex, std::string nRelPath);
|
||||
|
||||
protected:
|
||||
virtual void ParseRawData();
|
||||
};
|
104
tools/ZAPD/ZAPD/ZBlob.cpp
Normal file
104
tools/ZAPD/ZAPD/ZBlob.cpp
Normal file
@ -0,0 +1,104 @@
|
||||
#include "ZBlob.h"
|
||||
#include "File.h"
|
||||
#include "ZFile.h"
|
||||
#include "BitConverter.h"
|
||||
#include "Path.h"
|
||||
#include "StringHelper.h"
|
||||
|
||||
using namespace tinyxml2;
|
||||
using namespace std;
|
||||
|
||||
ZBlob::ZBlob() : ZResource()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
ZBlob::ZBlob(std::vector<uint8_t> nRawData, int nRawDataIndex, int size, std::string nName) : ZBlob()
|
||||
{
|
||||
rawDataIndex = nRawDataIndex;
|
||||
rawData = vector<uint8_t>(nRawData.data() + rawDataIndex, nRawData.data() + rawDataIndex + size);
|
||||
name = nName;
|
||||
}
|
||||
|
||||
ZBlob* ZBlob::ExtractFromXML(XMLElement* reader, vector<uint8_t> nRawData, int nRawDataIndex, string nRelPath)
|
||||
{
|
||||
ZBlob* blob = new ZBlob();
|
||||
|
||||
blob->rawDataIndex = nRawDataIndex;
|
||||
|
||||
blob->ParseXML(reader);
|
||||
int size = strtol(reader->Attribute("Size"), NULL, 16);
|
||||
blob->rawData = vector<uint8_t>(nRawData.data() + blob->rawDataIndex, nRawData.data() + blob->rawDataIndex + size);
|
||||
blob->relativePath = nRelPath;
|
||||
|
||||
return blob;
|
||||
}
|
||||
|
||||
ZBlob* ZBlob::BuildFromXML(XMLElement* reader, string inFolder, bool readFile)
|
||||
{
|
||||
ZBlob* blob = new ZBlob();
|
||||
|
||||
blob->ParseXML(reader);
|
||||
|
||||
if (readFile)
|
||||
blob->rawData = File::ReadAllBytes(inFolder + "/" + blob->name + ".bin");
|
||||
|
||||
return blob;
|
||||
}
|
||||
|
||||
ZBlob* ZBlob::FromFile(string filePath)
|
||||
{
|
||||
int comp;
|
||||
ZBlob* blob = new ZBlob();
|
||||
blob->name = StringHelper::Split(Path::GetFileNameWithoutExtension(filePath), ".")[0];
|
||||
blob->rawData = File::ReadAllBytes(filePath);
|
||||
|
||||
return blob;
|
||||
}
|
||||
|
||||
string ZBlob::GetSourceOutputCode(std::string prefix)
|
||||
{
|
||||
sourceOutput = "";
|
||||
//sourceOutput += StringHelper::Sprintf("u8 %s_%s[] = \n{\n", prefix.c_str(), name.c_str());
|
||||
|
||||
for (int i = 0; i < rawData.size(); i += 1)
|
||||
{
|
||||
if (i % 16 == 0)
|
||||
sourceOutput += "\t";
|
||||
|
||||
sourceOutput += StringHelper::Sprintf("0x%02X, ", rawData[i]);
|
||||
|
||||
if (i % 16 == 15)
|
||||
sourceOutput += "\n";
|
||||
}
|
||||
|
||||
//sourceOutput += "};\n";
|
||||
|
||||
return sourceOutput;
|
||||
}
|
||||
|
||||
string ZBlob::GetSourceOutputHeader(std::string prefix)
|
||||
{
|
||||
return StringHelper::Sprintf("extern u8 %s[];\n", name.c_str());
|
||||
}
|
||||
|
||||
void ZBlob::Save(string outFolder)
|
||||
{
|
||||
//printf("NAME = %s\n", name.c_str());
|
||||
File::WriteAllBytes(outFolder + "/" + name + ".bin", rawData);
|
||||
}
|
||||
|
||||
bool ZBlob::IsExternalResource()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
string ZBlob::GetExternalExtension()
|
||||
{
|
||||
return "bin";
|
||||
}
|
||||
|
||||
ZResourceType ZBlob::GetResourceType()
|
||||
{
|
||||
return ZResourceType::Blob;
|
||||
}
|
23
tools/ZAPD/ZAPD/ZBlob.h
Normal file
23
tools/ZAPD/ZAPD/ZBlob.h
Normal file
@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#include "ZResource.h"
|
||||
#include "tinyxml2.h"
|
||||
|
||||
class ZBlob : public ZResource
|
||||
{
|
||||
public:
|
||||
ZBlob(std::vector<uint8_t> nRawData, int rawDataIndex, int size, std::string nName);
|
||||
|
||||
static ZBlob* ExtractFromXML(tinyxml2::XMLElement* reader, std::vector<uint8_t> nRawData, int rawDataIndex, std::string nRelPath);
|
||||
static ZBlob* BuildFromXML(tinyxml2::XMLElement* reader, std::string inFolder, bool readFile);
|
||||
static ZBlob* FromFile(std::string filePath);
|
||||
std::string GetSourceOutputCode(std::string prefix);
|
||||
std::string GetSourceOutputHeader(std::string prefix);
|
||||
void Save(std::string outFolder);
|
||||
bool IsExternalResource();
|
||||
std::string GetExternalExtension();
|
||||
ZResourceType GetResourceType();
|
||||
|
||||
private:
|
||||
ZBlob();
|
||||
};
|
275
tools/ZAPD/ZAPD/ZCollision.cpp
Normal file
275
tools/ZAPD/ZAPD/ZCollision.cpp
Normal file
@ -0,0 +1,275 @@
|
||||
#include "ZCollision.h"
|
||||
#include "BitConverter.h"
|
||||
#include "StringHelper.h"
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
|
||||
using namespace std;
|
||||
|
||||
ZCollisionHeader::ZCollisionHeader()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
ZCollisionHeader::ZCollisionHeader(ZFile* parent, std::string prefix, std::vector<uint8_t> rawData, int rawDataIndex)
|
||||
{
|
||||
uint8_t* data = rawData.data();
|
||||
|
||||
absMinX = BitConverter::ToInt16BE(data, rawDataIndex + 0);
|
||||
absMinY = BitConverter::ToInt16BE(data, rawDataIndex + 2);
|
||||
absMinZ = BitConverter::ToInt16BE(data, rawDataIndex + 4);
|
||||
|
||||
absMaxX = BitConverter::ToInt16BE(data, rawDataIndex + 6);
|
||||
absMaxY = BitConverter::ToInt16BE(data, rawDataIndex + 8);
|
||||
absMaxZ = BitConverter::ToInt16BE(data, rawDataIndex + 10);
|
||||
|
||||
numVerts = BitConverter::ToInt16BE(data, rawDataIndex + 12);
|
||||
vtxSegmentOffset = BitConverter::ToInt32BE(data, rawDataIndex + 16) & 0x00FFFFFF;
|
||||
|
||||
numPolygons = BitConverter::ToInt16BE(data, rawDataIndex + 20);
|
||||
polySegmentOffset = BitConverter::ToInt32BE(data, rawDataIndex + 24) & 0x00FFFFFF;
|
||||
polyTypeDefSegmentOffset = BitConverter::ToInt32BE(data, rawDataIndex + 28) & 0x00FFFFFF;
|
||||
camDataSegmentOffset = BitConverter::ToInt32BE(data, rawDataIndex + 32) & 0x00FFFFFF;
|
||||
|
||||
numWaterBoxes = BitConverter::ToInt16BE(data, rawDataIndex + 36);
|
||||
waterBoxSegmentOffset = BitConverter::ToInt32BE(data, rawDataIndex + 40) & 0x00FFFFFF;
|
||||
|
||||
// HOTSPOT
|
||||
for (int i = 0; i < numVerts; i++)
|
||||
vertices.push_back(new VertexEntry(rawData, vtxSegmentOffset + (i * 6)));
|
||||
|
||||
// HOTSPOT
|
||||
for (int i = 0; i < numPolygons; i++)
|
||||
polygons.push_back(new PolygonEntry(rawData, polySegmentOffset + (i * 16)));
|
||||
|
||||
int highestPolyType = 0;
|
||||
|
||||
for (PolygonEntry* poly : polygons)
|
||||
{
|
||||
if (poly->type > highestPolyType)
|
||||
highestPolyType = poly->type;
|
||||
}
|
||||
|
||||
//if (highestPolyType > 0)
|
||||
{
|
||||
for (int i = 0; i < highestPolyType + 1; i++)
|
||||
polygonTypes.push_back(BitConverter::ToInt64BE(data, polyTypeDefSegmentOffset + (i * 8)));
|
||||
}
|
||||
//else
|
||||
//{
|
||||
//int polyTypesSize = abs(polyTypeDefSegmentOffset - camDataSegmentOffset) / 8;
|
||||
|
||||
//for (int i = 0; i < polyTypesSize; i++)
|
||||
//polygonTypes.push_back(BitConverter::ToInt64BE(data, polyTypeDefSegmentOffset + (i * 8)));
|
||||
//}
|
||||
|
||||
if (camDataSegmentOffset != 0)
|
||||
camData = new CameraDataList(parent, prefix, rawData, camDataSegmentOffset, polyTypeDefSegmentOffset, polygonTypes.size());
|
||||
|
||||
for (int i = 0; i < numWaterBoxes; i++)
|
||||
waterBoxes.push_back(new WaterBoxHeader(rawData, waterBoxSegmentOffset + (i * 16)));
|
||||
|
||||
string declaration = "";
|
||||
char line[2048];
|
||||
|
||||
if (waterBoxes.size() > 0)
|
||||
{
|
||||
for (int i = 0; i < waterBoxes.size(); i++)
|
||||
{
|
||||
sprintf(line, "\t{ %i, %i, %i, %i, %i, 0x%08X },\n", waterBoxes[i]->xMin, waterBoxes[i]->ySurface, waterBoxes[i]->zMin, waterBoxes[i]->xLength, waterBoxes[i]->zLength, waterBoxes[i]->properties);
|
||||
declaration += line;
|
||||
}
|
||||
}
|
||||
|
||||
if (waterBoxSegmentOffset != 0)
|
||||
parent->declarations[waterBoxSegmentOffset] = new Declaration(DeclarationAlignment::None, 16 * waterBoxes.size(), "WaterBox",
|
||||
StringHelper::Sprintf("%s_waterBoxes_%08X", prefix.c_str(), waterBoxSegmentOffset), true, declaration);
|
||||
|
||||
if (polygons.size() > 0)
|
||||
{
|
||||
declaration = "";
|
||||
|
||||
for (int i = 0; i < polygons.size(); i++)
|
||||
{
|
||||
sprintf(line, "\t{ 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X }, // 0x%08X\n",
|
||||
(uint16_t)polygons[i]->type, (uint16_t)polygons[i]->vtxA, (uint16_t)polygons[i]->vtxB, (uint16_t)polygons[i]->vtxC,
|
||||
(uint16_t)polygons[i]->a, (uint16_t)polygons[i]->b, (uint16_t)polygons[i]->c, (uint16_t)polygons[i]->d, polySegmentOffset + (i * 16));
|
||||
declaration += line;
|
||||
}
|
||||
|
||||
if (polySegmentOffset != 0) {
|
||||
parent->declarations[polySegmentOffset] = new Declaration(DeclarationAlignment::None, polygons.size() * 16, "RoomPoly", // TODO: Change this to CollisionPoly once the struct has been updated
|
||||
StringHelper::Sprintf("%s_polygons_%08X", prefix.c_str(), polySegmentOffset), true, declaration);
|
||||
}
|
||||
}
|
||||
|
||||
declaration = "";
|
||||
for (int i = 0; i < polygonTypes.size(); i++)
|
||||
{
|
||||
sprintf(line, "\t 0x%08lX, 0x%08lX, \n", polygonTypes[i] >> 32, polygonTypes[i] & 0xFFFFFFFF);
|
||||
declaration += line;
|
||||
}
|
||||
|
||||
if (polyTypeDefSegmentOffset != 0)
|
||||
parent->declarations[polyTypeDefSegmentOffset] = new Declaration(DeclarationAlignment::None, polygonTypes.size() * 8,
|
||||
"u32", StringHelper::Sprintf("%s_polygonTypes_%08X", prefix.c_str(), polyTypeDefSegmentOffset), true, declaration);
|
||||
|
||||
declaration = "";
|
||||
|
||||
if (vertices.size() > 0)
|
||||
{
|
||||
declaration = "";
|
||||
|
||||
for (int i = 0; i < vertices.size(); i++)
|
||||
{
|
||||
|
||||
sprintf(line, "{ %i, %i, %i }, // 0x%08X\n", vertices[i]->x, vertices[i]->y, vertices[i]->z, vtxSegmentOffset + (i * 6));
|
||||
declaration += line;
|
||||
}
|
||||
|
||||
if (vtxSegmentOffset != 0)
|
||||
parent->declarations[vtxSegmentOffset] = new Declaration(DeclarationAlignment::None, vertices.size() * 6,
|
||||
"Vec3s", StringHelper::Sprintf("%s_vtx_%08X", prefix.c_str(), vtxSegmentOffset), true, declaration);
|
||||
|
||||
declaration = "";
|
||||
}
|
||||
|
||||
declaration = "";
|
||||
char waterBoxStr[2048];
|
||||
|
||||
if (waterBoxSegmentOffset != 0)
|
||||
sprintf(waterBoxStr, "%s_waterBoxes_%08X", prefix.c_str(), waterBoxSegmentOffset);
|
||||
else
|
||||
sprintf(waterBoxStr, "0");
|
||||
|
||||
declaration += StringHelper::Sprintf("%i, %i, %i, %i, %i, %i, %i, %s_vtx_%08X, %i, %s_polygons_%08X, %s_polygonTypes_%08X, &%s_camDataList_%08X, %i, %s",
|
||||
absMinX, absMinY, absMinZ,
|
||||
absMaxX, absMaxY, absMaxZ,
|
||||
numVerts, prefix.c_str(), vtxSegmentOffset, numPolygons,
|
||||
prefix.c_str(), polySegmentOffset, prefix.c_str(), polyTypeDefSegmentOffset,
|
||||
prefix.c_str(), camDataSegmentOffset, numWaterBoxes, waterBoxStr);
|
||||
|
||||
|
||||
/*parent->AddDeclaration(rawDataIndex, DeclarationAlignment::None, DeclarationPadding::Pad16, 44, "CollisionHeader",
|
||||
StringHelper::Sprintf("%s_collisionHeader_%08X", prefix.c_str(), rawDataIndex), declaration);*/
|
||||
|
||||
parent->AddDeclaration(rawDataIndex, DeclarationAlignment::None, DeclarationPadding::Pad16, 44, "CollisionHeader",
|
||||
StringHelper::Sprintf("%s", prefix.c_str(), rawDataIndex), declaration);
|
||||
}
|
||||
|
||||
ZCollisionHeader* ZCollisionHeader::ExtractFromXML(tinyxml2::XMLElement* reader, vector<uint8_t> nRawData, int rawDataIndex)
|
||||
{
|
||||
ZCollisionHeader* col = new ZCollisionHeader();
|
||||
|
||||
|
||||
|
||||
return col;
|
||||
}
|
||||
|
||||
PolygonEntry::PolygonEntry(std::vector<uint8_t> rawData, int rawDataIndex)
|
||||
{
|
||||
uint8_t* data = rawData.data();
|
||||
|
||||
type = BitConverter::ToInt16BE(data, rawDataIndex + 0);
|
||||
vtxA = BitConverter::ToInt16BE(data, rawDataIndex + 2);
|
||||
vtxB = BitConverter::ToInt16BE(data, rawDataIndex + 4);
|
||||
vtxC = BitConverter::ToInt16BE(data, rawDataIndex + 6);
|
||||
a = BitConverter::ToInt16BE(data, rawDataIndex + 8);
|
||||
b = BitConverter::ToInt16BE(data, rawDataIndex + 10);
|
||||
c = BitConverter::ToInt16BE(data, rawDataIndex + 12);
|
||||
d = BitConverter::ToInt16BE(data, rawDataIndex + 14);
|
||||
}
|
||||
|
||||
VertexEntry::VertexEntry(std::vector<uint8_t> rawData, int rawDataIndex)
|
||||
{
|
||||
uint8_t* data = rawData.data();
|
||||
|
||||
x = BitConverter::ToInt16BE(data, rawDataIndex + 0);
|
||||
y = BitConverter::ToInt16BE(data, rawDataIndex + 2);
|
||||
z = BitConverter::ToInt16BE(data, rawDataIndex + 4);
|
||||
}
|
||||
|
||||
WaterBoxHeader::WaterBoxHeader(std::vector<uint8_t> rawData, int rawDataIndex)
|
||||
{
|
||||
uint8_t* data = rawData.data();
|
||||
|
||||
xMin = BitConverter::ToInt16BE(data, rawDataIndex + 0);
|
||||
ySurface = BitConverter::ToInt16BE(data, rawDataIndex + 2);
|
||||
zMin = BitConverter::ToInt16BE(data, rawDataIndex + 4);
|
||||
xLength = BitConverter::ToInt16BE(data, rawDataIndex + 6);
|
||||
zLength = BitConverter::ToInt16BE(data, rawDataIndex + 8);
|
||||
properties = BitConverter::ToInt32BE(data, rawDataIndex + 12);
|
||||
}
|
||||
|
||||
CameraDataList::CameraDataList(ZFile* parent, std::string prefix, std::vector<uint8_t> rawData, int rawDataIndex, int polyTypeDefSegmentOffset, int polygonTypesCnt)
|
||||
{
|
||||
string declaration = "";
|
||||
|
||||
// Parse CameraDataEntries
|
||||
int numElements = abs(polyTypeDefSegmentOffset - (rawDataIndex)) / 8;
|
||||
//int numElements = polygonTypesCnt;
|
||||
uint32_t cameraPosDataSeg = rawDataIndex;
|
||||
for (int 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) != 2)
|
||||
{
|
||||
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 (int i = 0; i < entries.size(); i++)
|
||||
{
|
||||
char camSegLine[2048];
|
||||
|
||||
if (entries[i]->cameraPosDataSeg != 0)
|
||||
{
|
||||
int index = ((entries[i]->cameraPosDataSeg & 0x00FFFFFF) - cameraPosDataOffset) / 0x6;
|
||||
sprintf(camSegLine, "&%s_camPosData_%08X[%i]", prefix.c_str(), cameraPosDataOffset, index);
|
||||
}
|
||||
else
|
||||
sprintf(camSegLine, "0x%08X", entries[i]->cameraPosDataSeg);
|
||||
|
||||
declaration += StringHelper::Sprintf("\t{ 0x%04X, %i, %s }, // 0x%08X\n", entries[i]->cameraSType, entries[i]->numData, camSegLine, rawDataIndex + (i * 8));
|
||||
}
|
||||
|
||||
parent->AddDeclarationArray(rawDataIndex, DeclarationAlignment::None, entries.size() * 8, "CamData", StringHelper::Sprintf("%s_camDataList_%08X", prefix.c_str(), rawDataIndex), entries.size(), declaration);
|
||||
|
||||
int numDataTotal = abs(rawDataIndex - (int)cameraPosDataOffset) / 0x6;
|
||||
|
||||
if (numDataTotal > 0)
|
||||
{
|
||||
declaration = "";
|
||||
for (int i = 0; i < numDataTotal; i++)
|
||||
{
|
||||
CameraPositionData* data = new CameraPositionData(rawData, cameraPosDataOffset + (i * 6));
|
||||
cameraPositionData.push_back(data);
|
||||
|
||||
declaration += StringHelper::Sprintf("\t{ %6i, %6i, %6i }, // 0x%08X\n", data->x, data->y, data->z, cameraPosDataSeg + (i * 0x6));;
|
||||
}
|
||||
|
||||
int cameraPosDataIndex = cameraPosDataSeg & 0x00FFFFFF;
|
||||
int entrySize = numDataTotal * 0x6;
|
||||
parent->AddDeclarationArray(cameraPosDataIndex, DeclarationAlignment::None, entrySize, "Vec3s", StringHelper::Sprintf("%s_camPosData_%08X", prefix.c_str(), cameraPosDataIndex), numDataTotal, declaration);
|
||||
}
|
||||
}
|
||||
|
||||
CameraPositionData::CameraPositionData(std::vector<uint8_t> rawData, int rawDataIndex)
|
||||
{
|
||||
x = BitConverter::ToInt16BE(rawData, rawDataIndex + 0);
|
||||
y = BitConverter::ToInt16BE(rawData, rawDataIndex + 2);
|
||||
z = BitConverter::ToInt16BE(rawData, rawDataIndex + 4);
|
||||
}
|
90
tools/ZAPD/ZAPD/ZCollision.h
Normal file
90
tools/ZAPD/ZAPD/ZCollision.h
Normal file
@ -0,0 +1,90 @@
|
||||
#pragma once
|
||||
|
||||
#include "ZResource.h"
|
||||
#include "ZFile.h"
|
||||
#include "ZRoom/ZRoom.h"
|
||||
|
||||
class PolygonEntry
|
||||
{
|
||||
public:
|
||||
int16_t type;
|
||||
int16_t vtxA, vtxB, vtxC;
|
||||
int16_t a, b, c, d;
|
||||
|
||||
PolygonEntry(std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
};
|
||||
|
||||
class VertexEntry
|
||||
{
|
||||
public:
|
||||
int16_t x, y, z;
|
||||
|
||||
VertexEntry(std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
};
|
||||
|
||||
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(std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
};
|
||||
|
||||
class CameraPositionData
|
||||
{
|
||||
public:
|
||||
int16_t x, y, z;
|
||||
|
||||
CameraPositionData(std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
};
|
||||
|
||||
class CameraDataEntry
|
||||
{
|
||||
public:
|
||||
int16_t cameraSType;
|
||||
int16_t numData;
|
||||
int32_t cameraPosDataSeg;
|
||||
};
|
||||
|
||||
class CameraDataList
|
||||
{
|
||||
public:
|
||||
std::vector<CameraDataEntry*> entries;
|
||||
std::vector<CameraPositionData*> cameraPositionData;
|
||||
|
||||
CameraDataList(ZFile* parent, std::string prefix, std::vector<uint8_t> rawData, int rawDataIndex, int polyTypeDefSegmentOffset, int polygonTypesCnt);
|
||||
};
|
||||
|
||||
class ZCollisionHeader : public ZResource
|
||||
{
|
||||
public:
|
||||
int16_t absMinX, absMinY, absMinZ;
|
||||
int16_t absMaxX, absMaxY, absMaxZ;
|
||||
int16_t numVerts;
|
||||
int32_t vtxSegmentOffset;
|
||||
int16_t numPolygons;
|
||||
int32_t polySegmentOffset;
|
||||
int32_t polyTypeDefSegmentOffset;
|
||||
int32_t camDataSegmentOffset;
|
||||
|
||||
int32_t numWaterBoxes;
|
||||
int32_t waterBoxSegmentOffset;
|
||||
|
||||
std::vector<VertexEntry*> vertices;
|
||||
std::vector<PolygonEntry*> polygons;
|
||||
std::vector<uint64_t> polygonTypes;
|
||||
std::vector<WaterBoxHeader*> waterBoxes;
|
||||
CameraDataList* camData;
|
||||
|
||||
ZCollisionHeader();
|
||||
//ZCollisionHeader(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
ZCollisionHeader(ZFile* parent, std::string prefix, std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
|
||||
static ZCollisionHeader* ExtractFromXML(tinyxml2::XMLElement* reader, std::vector<uint8_t> nRawData, int rawDataIndex);
|
||||
};
|
901
tools/ZAPD/ZAPD/ZCutscene.cpp
Normal file
901
tools/ZAPD/ZAPD/ZCutscene.cpp
Normal file
@ -0,0 +1,901 @@
|
||||
#include "ZCutscene.h"
|
||||
#include "BitConverter.h"
|
||||
#include "StringHelper.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
ZCutscene::ZCutscene(std::vector<uint8_t> nRawData, int rawDataIndex, int rawDataSize)
|
||||
{
|
||||
rawData = nRawData;
|
||||
segmentOffset = rawDataIndex;
|
||||
|
||||
numCommands = BitConverter::ToInt32BE(rawData, rawDataIndex + 0);
|
||||
commands = vector<CutsceneCommand*>();
|
||||
|
||||
endFrame = BitConverter::ToInt32BE(rawData, rawDataIndex + 4);
|
||||
uint32_t currentPtr = rawDataIndex + 8;
|
||||
|
||||
for (int i = 0; i < numCommands; i++)
|
||||
{
|
||||
int id = BitConverter::ToInt32BE(rawData, currentPtr);
|
||||
|
||||
if (id == -1)
|
||||
break;
|
||||
|
||||
CutsceneCommands cmdID = (CutsceneCommands)GetCommandFromID(id);
|
||||
currentPtr += 4;
|
||||
|
||||
int numEntries = 1;
|
||||
|
||||
/*if (cmdID != CutsceneCommands::SetCameraPos && cmdID != CutsceneCommands::SetCameraFocus && cmdID != CutsceneCommands::SetCameraFocusLink && cmdID != CutsceneCommands::SetCameraPosLink)
|
||||
{
|
||||
numEntries = BitConverter::ToInt32BE(rawData, currentPtr);
|
||||
currentPtr += 4;
|
||||
}*/
|
||||
|
||||
for (int j = 0; j < numEntries; j++)
|
||||
{
|
||||
CutsceneCommand* cmd = nullptr;
|
||||
|
||||
switch (cmdID)
|
||||
{
|
||||
case CutsceneCommands::SetCameraPos: cmd = new CutsceneCommandSetCameraPos(rawData, currentPtr); break;
|
||||
case CutsceneCommands::SetCameraFocus: cmd = new CutsceneCommandSetCameraPos(rawData, currentPtr); break;
|
||||
case CutsceneCommands::SpecialAction: cmd = new CutsceneCommandSpecialAction(rawData, currentPtr); break;
|
||||
case CutsceneCommands::SetLighting: cmd = new CutsceneCommandEnvLighting(rawData, currentPtr); break;
|
||||
case CutsceneCommands::SetCameraPosLink: cmd = new CutsceneCommandSetCameraPos(rawData, currentPtr); break;
|
||||
case CutsceneCommands::SetCameraFocusLink: cmd = new CutsceneCommandSetCameraPos(rawData, currentPtr); break;
|
||||
case CutsceneCommands::Textbox: cmd = new CutsceneCommandTextbox(rawData, currentPtr); break;
|
||||
case CutsceneCommands::Cmd09: cmd = new CutsceneCommandUnknown9(rawData, currentPtr); break;
|
||||
case CutsceneCommands::Unknown: cmd = new CutsceneCommandUnknown(rawData, currentPtr); break;
|
||||
case CutsceneCommands::SetActorAction0:
|
||||
case CutsceneCommands::SetActorAction1:
|
||||
case CutsceneCommands::SetActorAction2:
|
||||
case CutsceneCommands::SetActorAction3:
|
||||
case CutsceneCommands::SetActorAction4:
|
||||
case CutsceneCommands::SetActorAction5:
|
||||
case CutsceneCommands::SetActorAction6:
|
||||
case CutsceneCommands::SetActorAction7:
|
||||
case CutsceneCommands::SetActorAction8:
|
||||
case CutsceneCommands::SetActorAction9:
|
||||
case CutsceneCommands::SetActorAction10: cmd = new CutsceneCommandActorAction(rawData, currentPtr); break;
|
||||
case CutsceneCommands::SetSceneTransFX: cmd = new CutsceneCommandSceneTransFX(rawData, currentPtr); break;
|
||||
case CutsceneCommands::Nop: cmd = new CutsceneCommandNop(rawData, currentPtr); break;
|
||||
case CutsceneCommands::PlayBGM: cmd = new CutsceneCommandPlayBGM(rawData, currentPtr); break;
|
||||
case CutsceneCommands::StopBGM: cmd = new CutsceneCommandStopBGM(rawData, currentPtr); break;
|
||||
case CutsceneCommands::FadeBGM: cmd = new CutsceneCommandFadeBGM(rawData, currentPtr); break;
|
||||
case CutsceneCommands::SetTime: cmd = new CutsceneCommandDayTime(rawData, currentPtr); break;
|
||||
case CutsceneCommands::Terminator: cmd = new CutsceneCommandTerminator(rawData, currentPtr); break;
|
||||
case CutsceneCommands::End: cmd = new CutsceneCommandEnd(rawData, currentPtr); break;
|
||||
}
|
||||
|
||||
cmd->commandIndex = i;
|
||||
cmd->commandID = (uint32_t)id;
|
||||
currentPtr += (uint32_t)cmd->GetCommandSize();
|
||||
|
||||
commands.push_back(cmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string ZCutscene::GetSourceOutputCode(string prefix)
|
||||
{
|
||||
string output = "";
|
||||
int size = 0;
|
||||
int32_t curPtr = 0;
|
||||
|
||||
//output += StringHelper::Sprintf("// SIZE = 0x%04X\n", GetRawDataSize());
|
||||
output += StringHelper::Sprintf("\tCS_BEGIN_CUTSCENE(%i, %i),\n", commands.size(), endFrame);
|
||||
|
||||
for (int i = 0; i < commands.size(); i++)
|
||||
{
|
||||
CutsceneCommand* cmd = commands[i];
|
||||
output += "\t" + cmd->GenerateSourceCode(prefix, curPtr);
|
||||
curPtr += (uint32_t)cmd->GetCommandSize();
|
||||
size += (int)cmd->GetCommandSize();
|
||||
}
|
||||
|
||||
output += StringHelper::Sprintf("\tCS_END(),\n", commands.size(), endFrame);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
int ZCutscene::GetRawDataSize()
|
||||
{
|
||||
int size = 0;
|
||||
|
||||
// Beginning
|
||||
size += 8;
|
||||
|
||||
for (int i = 0; i < commands.size(); i++)
|
||||
{
|
||||
CutsceneCommand* cmd = commands[i];
|
||||
size += (int)cmd->GetCommandSize();
|
||||
size += 4;
|
||||
}
|
||||
|
||||
// End
|
||||
size += 8;
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
CutsceneCommands ZCutscene::GetCommandFromID(int id)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case 0x0003: return CutsceneCommands::SpecialAction;
|
||||
case 0x0004: return CutsceneCommands::SetLighting;
|
||||
case 0x0056: return CutsceneCommands::PlayBGM;
|
||||
case 0x0057: return CutsceneCommands::StopBGM;
|
||||
case 0x007C: return CutsceneCommands::FadeBGM;
|
||||
case 0x0009: return CutsceneCommands::Cmd09;
|
||||
case 0x0013: return CutsceneCommands::Textbox;
|
||||
case 0x008C: return CutsceneCommands::SetTime;
|
||||
case 0x0001: return CutsceneCommands::SetCameraPos;
|
||||
case 0x0002: return CutsceneCommands::SetCameraFocus;
|
||||
case 0x0005: return CutsceneCommands::SetCameraPosLink;
|
||||
case 0x0006: return CutsceneCommands::SetCameraFocusLink;
|
||||
case 0x0007: return CutsceneCommands::Cmd07;
|
||||
case 0x0008: return CutsceneCommands::Cmd08;
|
||||
case 0x03E8: return CutsceneCommands::Terminator;
|
||||
case 0xFFFF: return CutsceneCommands::End;
|
||||
case 0x002D: return CutsceneCommands::SetSceneTransFX;
|
||||
case 10: return CutsceneCommands::SetActorAction0;
|
||||
case 15: case 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: return CutsceneCommands::SetActorAction1;
|
||||
case 14: 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: return CutsceneCommands::SetActorAction2;
|
||||
case 25: case 36: case 41: case 50: case 67: case 69: case 72: case 81: case 106: case 117: case 121: case 126: case 132: return CutsceneCommands::SetActorAction3;
|
||||
case 29: case 37: case 42: case 51: case 53: case 63: case 65: case 66: case 75: case 82: case 108: case 127: case 133: return CutsceneCommands::SetActorAction4;
|
||||
case 30: case 38: case 43: case 47: case 54: case 79: case 83: case 128: case 135: return CutsceneCommands::SetActorAction5;
|
||||
case 44: case 55: case 77: case 84: case 90: case 129: case 136: return CutsceneCommands::SetActorAction6;
|
||||
case 31: case 52: case 57: case 58: case 88: case 115: case 130: case 137: return CutsceneCommands::SetActorAction7;
|
||||
case 49: case 60: case 89: case 111: case 114: case 134: case 142: return CutsceneCommands::SetActorAction8;
|
||||
case 62: return CutsceneCommands::SetActorAction9;
|
||||
case 143: return CutsceneCommands::SetActorAction10;
|
||||
case 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 CutsceneCommands::Unknown;
|
||||
}
|
||||
|
||||
printf("WARNING: Could not identify cutscene command ID 0x%04X\n", id);
|
||||
|
||||
return CutsceneCommands::Error;
|
||||
}
|
||||
|
||||
CutsceneCommand::CutsceneCommand(vector<uint8_t> rawData, int rawDataIndex)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
string CutsceneCommand::GetCName(string prefix)
|
||||
{
|
||||
return "SCmdCutsceneData";
|
||||
}
|
||||
|
||||
string CutsceneCommand::GenerateSourceCode(string roomName, int baseAddress)
|
||||
{
|
||||
return StringHelper::Sprintf("%s %sCutsceneData%04XCmd%02X = { 0x%02X,", GetCName(roomName).c_str(), roomName.c_str(), baseAddress, commandIndex, commandID);
|
||||
}
|
||||
|
||||
size_t CutsceneCommand::GetCommandSize()
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
CutsceneCameraPoint::CutsceneCameraPoint(vector<uint8_t> rawData, int rawDataIndex)
|
||||
{
|
||||
uint8_t* data = rawData.data();
|
||||
|
||||
continueFlag = data[rawDataIndex + 0];
|
||||
cameraRoll = data[rawDataIndex + 1];
|
||||
nextPointFrame = BitConverter::ToInt16BE(data, rawDataIndex + 2);
|
||||
viewAngle = BitConverter::ToInt32BE(data, rawDataIndex + 4);
|
||||
|
||||
posX = BitConverter::ToInt16BE(data, rawDataIndex + 8);
|
||||
posY = BitConverter::ToInt16BE(data, rawDataIndex + 10);
|
||||
posZ = BitConverter::ToInt16BE(data, rawDataIndex + 12);
|
||||
|
||||
unused = BitConverter::ToInt16BE(data, rawDataIndex + 14);
|
||||
}
|
||||
|
||||
CutsceneCommandSetCameraPos::CutsceneCommandSetCameraPos(vector<uint8_t> rawData, int rawDataIndex) : CutsceneCommand(rawData, rawDataIndex)
|
||||
{
|
||||
uint8_t* data = rawData.data();
|
||||
|
||||
base = (uint16_t)BitConverter::ToInt16BE(data, rawDataIndex + 0);
|
||||
startFrame = (uint16_t)BitConverter::ToInt16BE(data, rawDataIndex + 2);
|
||||
endFrame = (uint16_t)BitConverter::ToInt16BE(data, rawDataIndex + 4);
|
||||
unused = (uint16_t)BitConverter::ToInt16BE(data, rawDataIndex + 6);
|
||||
|
||||
entries = vector<CutsceneCameraPoint*>();
|
||||
|
||||
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 += 16;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO
|
||||
string CutsceneCommandSetCameraPos::GetCName(string prefix)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
string CutsceneCommandSetCameraPos::GenerateSourceCode(string roomName, int baseAddress)
|
||||
{
|
||||
string result = "";
|
||||
|
||||
string listStr = "";
|
||||
string posStr = "";
|
||||
|
||||
if (commandID == (int)CutsceneCommands::SetCameraFocus)
|
||||
{
|
||||
listStr = "CS_CAM_FOCUS_POINT_LIST";
|
||||
posStr = "CS_CAM_FOCUS_POINT";
|
||||
}
|
||||
else if (commandID == (int)CutsceneCommands::SetCameraFocusLink)
|
||||
{
|
||||
listStr = "CS_CAM_FOCUS_POINT_PLAYER_LIST";
|
||||
posStr = "CS_CAM_FOCUS_POINT_PLAYER";
|
||||
}
|
||||
else if (commandID == (int)CutsceneCommands::SetCameraPosLink)
|
||||
{
|
||||
listStr = "CS_CAM_POS_PLAYER_LIST";
|
||||
posStr = "CS_CAM_POS_PLAYER";
|
||||
}
|
||||
else
|
||||
{
|
||||
listStr = "CS_CAM_POS_LIST";
|
||||
posStr = "CS_CAM_POS";
|
||||
}
|
||||
|
||||
result += StringHelper::Sprintf("%s(%i, %i),\n", listStr.c_str(), startFrame, endFrame);
|
||||
|
||||
for (int i = 0; i < entries.size(); i++)
|
||||
{
|
||||
result += StringHelper::Sprintf("\t\t%s(%i, %i, %i, 0x%06X, %i, %i, %i, %i),\n", posStr.c_str(), entries[i]->continueFlag, entries[i]->cameraRoll, entries[i]->nextPointFrame,
|
||||
*(uint32_t*)&entries[i]->viewAngle, entries[i]->posX, entries[i]->posY, entries[i]->posZ, entries[i]->unused);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
size_t CutsceneCommandSetCameraPos::GetCommandSize()
|
||||
{
|
||||
return 8 + (entries.size() * 16);
|
||||
}
|
||||
|
||||
MusicFadeEntry::MusicFadeEntry(vector<uint8_t> rawData, int rawDataIndex)
|
||||
{
|
||||
base = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 0);
|
||||
startFrame = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 2);
|
||||
endFrame = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 4);
|
||||
unknown0 = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 6);
|
||||
unknown1 = (uint32_t)BitConverter::ToInt32BE(rawData, rawDataIndex + 8);
|
||||
unknown2 = (uint32_t)BitConverter::ToInt32BE(rawData, rawDataIndex + 12);
|
||||
unknown3 = (uint32_t)BitConverter::ToInt32BE(rawData, rawDataIndex + 16);
|
||||
unknown4 = (uint32_t)BitConverter::ToInt32BE(rawData, rawDataIndex + 20);
|
||||
unknown5 = (uint32_t)BitConverter::ToInt32BE(rawData, rawDataIndex + 24);
|
||||
unknown6 = (uint32_t)BitConverter::ToInt32BE(rawData, rawDataIndex + 28);
|
||||
unknown7 = (uint32_t)BitConverter::ToInt32BE(rawData, rawDataIndex + 32);
|
||||
unknown8 = (uint32_t)BitConverter::ToInt32BE(rawData, rawDataIndex + 36);
|
||||
unknown9 = (uint32_t)BitConverter::ToInt32BE(rawData, rawDataIndex + 40);
|
||||
unknown10 = (uint32_t)BitConverter::ToInt32BE(rawData, rawDataIndex + 44);
|
||||
}
|
||||
|
||||
CutsceneCommandFadeBGM::CutsceneCommandFadeBGM(vector<uint8_t> rawData, int rawDataIndex) : CutsceneCommand(rawData, rawDataIndex)
|
||||
{
|
||||
int numEntries = BitConverter::ToInt32BE(rawData, rawDataIndex + 0);
|
||||
|
||||
rawDataIndex += 4;
|
||||
|
||||
for (int i = 0; i < numEntries; i++)
|
||||
{
|
||||
entries.push_back(new MusicFadeEntry(rawData, rawDataIndex));
|
||||
rawDataIndex += 0x30;
|
||||
}
|
||||
}
|
||||
|
||||
string CutsceneCommandFadeBGM::GetCName(string prefix)
|
||||
{
|
||||
return "CsCmdMusicFade";
|
||||
}
|
||||
|
||||
string CutsceneCommandFadeBGM::GenerateSourceCode(string roomName, int baseAddress)
|
||||
{
|
||||
string result = "";
|
||||
|
||||
result += StringHelper::Sprintf("CS_FADE_BGM_LIST(%i),\n", entries.size());
|
||||
|
||||
for (int i = 0; i < entries.size(); i++)
|
||||
{
|
||||
result += StringHelper::Sprintf("\t\tCS_FADE_BGM(%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i),\n", entries[i]->base, entries[i]->startFrame, entries[i]->endFrame,
|
||||
entries[i]->unknown0, entries[i]->unknown1, entries[i]->unknown2, entries[i]->unknown3, entries[i]->unknown4, entries[i]->unknown5, entries[i]->unknown6, entries[i]->unknown7,
|
||||
entries[i]->unknown8, entries[i]->unknown9, entries[i]->unknown10);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
size_t CutsceneCommandFadeBGM::GetCommandSize()
|
||||
{
|
||||
return CutsceneCommand::GetCommandSize() + 0x30;
|
||||
}
|
||||
|
||||
MusicChangeEntry::MusicChangeEntry(vector<uint8_t> rawData, int rawDataIndex)
|
||||
{
|
||||
sequence = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 0);
|
||||
startFrame = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 2);
|
||||
endFrame = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 4);
|
||||
unknown0 = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 6);
|
||||
unknown1 = (uint32_t)BitConverter::ToInt32BE(rawData, rawDataIndex + 8);
|
||||
unknown2 = (uint32_t)BitConverter::ToInt32BE(rawData, rawDataIndex + 12);
|
||||
unknown3 = (uint32_t)BitConverter::ToInt32BE(rawData, rawDataIndex + 16);
|
||||
unknown4 = (uint32_t)BitConverter::ToInt32BE(rawData, rawDataIndex + 20);
|
||||
unknown5 = (uint32_t)BitConverter::ToInt32BE(rawData, rawDataIndex + 24);
|
||||
unknown6 = (uint32_t)BitConverter::ToInt32BE(rawData, rawDataIndex + 28);
|
||||
unknown7 = (uint32_t)BitConverter::ToInt32BE(rawData, rawDataIndex + 32);
|
||||
}
|
||||
|
||||
CutsceneCommandPlayBGM::CutsceneCommandPlayBGM(vector<uint8_t> rawData, int rawDataIndex) : CutsceneCommand(rawData, rawDataIndex)
|
||||
{
|
||||
int numEntries = BitConverter::ToInt32BE(rawData, rawDataIndex + 0);
|
||||
|
||||
rawDataIndex += 4;
|
||||
|
||||
for (int i = 0; i < numEntries; i++)
|
||||
{
|
||||
entries.push_back(new MusicChangeEntry(rawData, rawDataIndex));
|
||||
rawDataIndex += 0x30;
|
||||
}
|
||||
}
|
||||
|
||||
string CutsceneCommandPlayBGM::GenerateSourceCode(string roomName, int baseAddress)
|
||||
{
|
||||
string result = "";
|
||||
|
||||
result += StringHelper::Sprintf("CS_PLAY_BGM_LIST(%i),\n", entries.size());
|
||||
|
||||
for (int i = 0; i < entries.size(); i++)
|
||||
{
|
||||
result += StringHelper::Sprintf("\t\tCS_PLAY_BGM(%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i),\n", entries[i]->sequence, entries[i]->startFrame,
|
||||
entries[i]->endFrame, entries[i]->unknown0, entries[i]->unknown1, entries[i]->unknown2, entries[i]->unknown3, entries[i]->unknown4, entries[i]->unknown5,
|
||||
entries[i]->unknown6, entries[i]->unknown7);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
string CutsceneCommandPlayBGM::GetCName(string prefix)
|
||||
{
|
||||
return "CsCmdMusicChange";
|
||||
}
|
||||
|
||||
size_t CutsceneCommandPlayBGM::GetCommandSize()
|
||||
{
|
||||
return CutsceneCommand::GetCommandSize() + 0x30;
|
||||
}
|
||||
|
||||
CutsceneCommandStopBGM::CutsceneCommandStopBGM(vector<uint8_t> rawData, int rawDataIndex) : CutsceneCommand(rawData, rawDataIndex)
|
||||
{
|
||||
int numEntries = BitConverter::ToInt32BE(rawData, rawDataIndex + 0);
|
||||
|
||||
rawDataIndex += 4;
|
||||
|
||||
for (int i = 0; i < numEntries; i++)
|
||||
{
|
||||
entries.push_back(new MusicChangeEntry(rawData, rawDataIndex));
|
||||
rawDataIndex += 0x30;
|
||||
}
|
||||
}
|
||||
|
||||
string CutsceneCommandStopBGM::GenerateSourceCode(string roomName, int baseAddress)
|
||||
{
|
||||
string result = "";
|
||||
|
||||
result += StringHelper::Sprintf("CS_STOP_BGM_LIST(%i),\n", entries.size());
|
||||
|
||||
for (int i = 0; i < entries.size(); i++)
|
||||
{
|
||||
result += StringHelper::Sprintf("CS_STOP_BGM(%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i),\n", entries[i]->sequence, entries[i]->startFrame,
|
||||
entries[i]->endFrame, entries[i]->unknown0, entries[i]->unknown1, entries[i]->unknown2, entries[i]->unknown3, entries[i]->unknown4, entries[i]->unknown5,
|
||||
entries[i]->unknown6, entries[i]->unknown7);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
string CutsceneCommandStopBGM::GetCName(string prefix)
|
||||
{
|
||||
return "CsCmdMusicChange";
|
||||
}
|
||||
|
||||
size_t CutsceneCommandStopBGM::GetCommandSize()
|
||||
{
|
||||
return CutsceneCommand::GetCommandSize() + 0x30;
|
||||
}
|
||||
|
||||
EnvLightingEntry::EnvLightingEntry(vector<uint8_t> rawData, int rawDataIndex)
|
||||
{
|
||||
setting = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 0);
|
||||
startFrame = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 2);
|
||||
endFrame = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 4);
|
||||
unused0 = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 6);
|
||||
unused1 = (uint32_t)BitConverter::ToInt32BE(rawData, rawDataIndex + 8);
|
||||
unused2 = (uint32_t)BitConverter::ToInt32BE(rawData, rawDataIndex + 12);
|
||||
unused3 = (uint32_t)BitConverter::ToInt32BE(rawData, rawDataIndex + 16);
|
||||
unused4 = (uint32_t)BitConverter::ToInt32BE(rawData, rawDataIndex + 20);
|
||||
unused5 = (uint32_t)BitConverter::ToInt32BE(rawData, rawDataIndex + 24);
|
||||
unused6 = (uint32_t)BitConverter::ToInt32BE(rawData, rawDataIndex + 28);
|
||||
unused7 = (uint32_t)BitConverter::ToInt32BE(rawData, rawDataIndex + 32);
|
||||
}
|
||||
|
||||
CutsceneCommandEnvLighting::CutsceneCommandEnvLighting(vector<uint8_t> rawData, int rawDataIndex) : CutsceneCommand(rawData, rawDataIndex)
|
||||
{
|
||||
int numEntries = BitConverter::ToInt32BE(rawData, rawDataIndex + 0);
|
||||
|
||||
rawDataIndex += 4;
|
||||
|
||||
for (int i = 0; i < numEntries; i++)
|
||||
{
|
||||
entries.push_back(new EnvLightingEntry(rawData, rawDataIndex));
|
||||
rawDataIndex += 0x30;
|
||||
}
|
||||
}
|
||||
|
||||
string CutsceneCommandEnvLighting::GenerateSourceCode(string roomName, int baseAddress)
|
||||
{
|
||||
string result = "";
|
||||
|
||||
result += StringHelper::Sprintf("CS_LIGHTING_LIST(%i),\n", entries.size());
|
||||
|
||||
for (int i = 0; i < entries.size(); i++)
|
||||
{
|
||||
result += StringHelper::Sprintf("CS_LIGHTING(%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i),\n", entries[i]->setting, entries[i]->startFrame,
|
||||
entries[i]->endFrame, entries[i]->unused0, entries[i]->unused1, entries[i]->unused2, entries[i]->unused3, entries[i]->unused4, entries[i]->unused5,
|
||||
entries[i]->unused6, entries[i]->unused7);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
string CutsceneCommandEnvLighting::GetCName(string prefix)
|
||||
{
|
||||
return "CsCmdEnvLighting";
|
||||
}
|
||||
|
||||
size_t CutsceneCommandEnvLighting::GetCommandSize()
|
||||
{
|
||||
return CutsceneCommand::GetCommandSize() + (0x30 * entries.size());
|
||||
}
|
||||
|
||||
Unknown9Entry::Unknown9Entry(vector<uint8_t> rawData, int rawDataIndex)
|
||||
{
|
||||
base = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 0);
|
||||
startFrame = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 2);
|
||||
endFrame = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 4);
|
||||
unk2 = rawData[rawDataIndex + 6];
|
||||
unk3 = rawData[rawDataIndex + 7];
|
||||
unk4 = rawData[rawDataIndex + 8];
|
||||
unused0 = rawData[rawDataIndex + 10];
|
||||
unused1 = rawData[rawDataIndex + 11];;
|
||||
}
|
||||
|
||||
CutsceneCommandUnknown9::CutsceneCommandUnknown9(vector<uint8_t> rawData, int rawDataIndex) : CutsceneCommand(rawData, rawDataIndex)
|
||||
{
|
||||
int numEntries = BitConverter::ToInt32BE(rawData, rawDataIndex);
|
||||
|
||||
rawDataIndex += 4;
|
||||
|
||||
for (int i = 0; i < numEntries; i++)
|
||||
{
|
||||
entries.push_back(new Unknown9Entry(rawData, rawDataIndex));
|
||||
rawDataIndex += 0x0C;
|
||||
}
|
||||
}
|
||||
|
||||
string CutsceneCommandUnknown9::GenerateSourceCode(string roomName, int baseAddress)
|
||||
{
|
||||
string result = "";
|
||||
|
||||
result += StringHelper::Sprintf("CS_CMD_09_LIST(%i),\n", entries.size());
|
||||
|
||||
for (int i = 0; i < entries.size(); i++)
|
||||
{
|
||||
result += StringHelper::Sprintf("CS_CMD_09(%i, %i, %i, %i, %i, %i, %i, %i),\n", entries[i]->base, entries[i]->startFrame, entries[i]->endFrame, entries[i]->unk2,
|
||||
entries[i]->unk3, entries[i]->unk4, entries[i]->unused0, entries[i]->unused1);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
string CutsceneCommandUnknown9::GetCName(string prefix)
|
||||
{
|
||||
return "CsCmdUnknown9";
|
||||
}
|
||||
|
||||
size_t CutsceneCommandUnknown9::GetCommandSize()
|
||||
{
|
||||
return CutsceneCommand::GetCommandSize() + (entries.size() * 12);
|
||||
}
|
||||
|
||||
UnkEntry::UnkEntry(vector<uint8_t> rawData, int rawDataIndex)
|
||||
{
|
||||
unused0 = (uint32_t)BitConverter::ToInt32BE(rawData, rawDataIndex + 0);
|
||||
unused1 = (uint32_t)BitConverter::ToInt32BE(rawData, rawDataIndex + 4);
|
||||
unused2 = (uint32_t)BitConverter::ToInt32BE(rawData, rawDataIndex + 8);
|
||||
unused3 = (uint32_t)BitConverter::ToInt32BE(rawData, rawDataIndex + 12);
|
||||
unused4 = (uint32_t)BitConverter::ToInt32BE(rawData, rawDataIndex + 16);
|
||||
unused5 = (uint32_t)BitConverter::ToInt32BE(rawData, rawDataIndex + 20);
|
||||
unused6 = (uint32_t)BitConverter::ToInt32BE(rawData, rawDataIndex + 24);
|
||||
unused7 = (uint32_t)BitConverter::ToInt32BE(rawData, rawDataIndex + 28);
|
||||
unused8 = (uint32_t)BitConverter::ToInt32BE(rawData, rawDataIndex + 32);
|
||||
unused9 = (uint32_t)BitConverter::ToInt32BE(rawData, rawDataIndex + 36);
|
||||
unused10 = (uint32_t)BitConverter::ToInt32BE(rawData, rawDataIndex + 40);
|
||||
unused11 = (uint32_t)BitConverter::ToInt32BE(rawData, rawDataIndex + 44);
|
||||
}
|
||||
|
||||
CutsceneCommandUnknown::CutsceneCommandUnknown(vector<uint8_t> rawData, int rawDataIndex) : CutsceneCommand(rawData, rawDataIndex)
|
||||
{
|
||||
int numEntries = BitConverter::ToInt32BE(rawData, rawDataIndex);
|
||||
|
||||
rawDataIndex += 4;
|
||||
|
||||
for (int i = 0; i < numEntries; i++)
|
||||
{
|
||||
entries.push_back(new UnkEntry(rawData, rawDataIndex));
|
||||
rawDataIndex += 0x30;
|
||||
}
|
||||
}
|
||||
|
||||
string CutsceneCommandUnknown::GenerateSourceCode(string roomName, int baseAddress)
|
||||
{
|
||||
string result = "";
|
||||
|
||||
result += StringHelper::Sprintf("CS_UNK_DATA_LIST(0x%02X, %i),\n", commandID, entries.size());
|
||||
|
||||
for (int i = 0; i < entries.size(); i++)
|
||||
{
|
||||
result += StringHelper::Sprintf("\tCS_UNK_DATA(%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i),\n", entries[i]->unused0, entries[i]->unused1, entries[i]->unused2,
|
||||
entries[i]->unused3, entries[i]->unused4, entries[i]->unused5, entries[i]->unused6,
|
||||
entries[i]->unused7, entries[i]->unused8, entries[i]->unused9, entries[i]->unused10, entries[i]->unused11);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
string CutsceneCommandUnknown::GetCName(string prefix)
|
||||
{
|
||||
return "CsCmdUnknown1A";
|
||||
}
|
||||
|
||||
size_t CutsceneCommandUnknown::GetCommandSize()
|
||||
{
|
||||
return CutsceneCommand::GetCommandSize() + (entries.size() * 0x30);
|
||||
}
|
||||
|
||||
DayTimeEntry::DayTimeEntry(vector<uint8_t> rawData, int rawDataIndex)
|
||||
{
|
||||
base = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 0);
|
||||
startFrame = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 2);
|
||||
endFrame = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 4);
|
||||
hour = rawData[rawDataIndex + 6];
|
||||
minute = rawData[rawDataIndex + 7];
|
||||
unused = rawData[rawDataIndex + 8];
|
||||
}
|
||||
|
||||
CutsceneCommandDayTime::CutsceneCommandDayTime(vector<uint8_t> rawData, int rawDataIndex) : CutsceneCommand(rawData, rawDataIndex)
|
||||
{
|
||||
int numEntries = BitConverter::ToInt32BE(rawData, rawDataIndex);
|
||||
|
||||
rawDataIndex += 4;
|
||||
|
||||
for (int i = 0; i < numEntries; i++)
|
||||
{
|
||||
entries.push_back(new DayTimeEntry(rawData, rawDataIndex));
|
||||
rawDataIndex += 12;
|
||||
}
|
||||
}
|
||||
|
||||
string CutsceneCommandDayTime::GetCName(string prefix)
|
||||
{
|
||||
return "CsCmdDayTime";
|
||||
}
|
||||
|
||||
string CutsceneCommandDayTime::GenerateSourceCode(string roomName, int baseAddress)
|
||||
{
|
||||
string result = "";
|
||||
|
||||
result += StringHelper::Sprintf("CS_TIME_LIST(%i),\n", entries.size());
|
||||
|
||||
for (int i = 0; i < entries.size(); i++)
|
||||
{
|
||||
result += StringHelper::Sprintf("\t\tCS_TIME(%i, %i, %i, %i, %i, %i),\n", entries[i]->base, entries[i]->startFrame, entries[i]->endFrame,
|
||||
entries[i]->hour, entries[i]->minute, entries[i]->unused);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
size_t CutsceneCommandDayTime::GetCommandSize()
|
||||
{
|
||||
return CutsceneCommand::GetCommandSize() + (entries.size() * 12);
|
||||
}
|
||||
|
||||
TextboxEntry::TextboxEntry(vector<uint8_t> rawData, int rawDataIndex)
|
||||
{
|
||||
base = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 0);
|
||||
startFrame = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 2);
|
||||
endFrame = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 4);
|
||||
type = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 6);
|
||||
textID1 = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 8);
|
||||
textID2 = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 10);
|
||||
}
|
||||
|
||||
CutsceneCommandTextbox::CutsceneCommandTextbox(vector<uint8_t> rawData, int rawDataIndex) : CutsceneCommand(rawData, rawDataIndex)
|
||||
{
|
||||
int numEntries = BitConverter::ToInt32BE(rawData, rawDataIndex);
|
||||
|
||||
rawDataIndex += 4;
|
||||
|
||||
for (int i = 0; i < numEntries; i++)
|
||||
{
|
||||
entries.push_back(new TextboxEntry(rawData, rawDataIndex));
|
||||
rawDataIndex += 12;
|
||||
}
|
||||
}
|
||||
|
||||
string CutsceneCommandTextbox::GetCName(string prefix)
|
||||
{
|
||||
return "CsCmdTextbox";
|
||||
}
|
||||
|
||||
string CutsceneCommandTextbox::GenerateSourceCode(string roomName, int baseAddress)
|
||||
{
|
||||
string result = "";
|
||||
|
||||
result += StringHelper::Sprintf("CS_TEXT_LIST(%i),\n", entries.size());
|
||||
|
||||
for (int i = 0; i < entries.size(); i++)
|
||||
{
|
||||
if (entries[i]->base == 0xFFFF)
|
||||
{
|
||||
result += StringHelper::Sprintf("\t\tCS_TEXT_NONE(%i, %i),\n", entries[i]->startFrame, entries[i]->endFrame);
|
||||
}
|
||||
else
|
||||
{
|
||||
result += StringHelper::Sprintf("\t\tCS_TEXT_DISPLAY_TEXTBOX(%i, %i, %i, %i, %i, %i),\n", entries[i]->base, entries[i]->startFrame, entries[i]->endFrame, entries[i]->type,
|
||||
entries[i]->textID1, entries[i]->textID2);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
size_t CutsceneCommandTextbox::GetCommandSize()
|
||||
{
|
||||
return CutsceneCommand::GetCommandSize() + (entries.size() * 12);
|
||||
}
|
||||
|
||||
ActorAction::ActorAction(vector<uint8_t> rawData, int rawDataIndex)
|
||||
{
|
||||
uint8_t* data = rawData.data();
|
||||
|
||||
action = (uint16_t)BitConverter::ToInt16BE(data, rawDataIndex + 0);
|
||||
startFrame = (uint16_t)BitConverter::ToInt16BE(data, rawDataIndex + 2);
|
||||
endFrame = (uint16_t)BitConverter::ToInt16BE(data, rawDataIndex + 4);
|
||||
rotX = (uint16_t)BitConverter::ToInt16BE(data, rawDataIndex + 6);
|
||||
rotY = (uint16_t)BitConverter::ToInt16BE(data, rawDataIndex + 8);
|
||||
rotZ = (uint16_t)BitConverter::ToInt16BE(data, rawDataIndex + 10);
|
||||
startPosX = BitConverter::ToInt32BE(data, rawDataIndex + 12);
|
||||
startPosY = BitConverter::ToInt32BE(data, rawDataIndex + 16);
|
||||
startPosZ = BitConverter::ToInt32BE(data, rawDataIndex + 20);
|
||||
endPosX = BitConverter::ToInt32BE(data, rawDataIndex + 24);
|
||||
endPosY = BitConverter::ToInt32BE(data, rawDataIndex + 28);
|
||||
endPosZ = BitConverter::ToInt32BE(data, rawDataIndex + 32);
|
||||
normalX = BitConverter::ToInt32BE(data, rawDataIndex + 36);
|
||||
normalY = BitConverter::ToInt32BE(data, rawDataIndex + 40);
|
||||
normalZ = BitConverter::ToInt32BE(data, rawDataIndex + 44);
|
||||
}
|
||||
|
||||
CutsceneCommandActorAction::CutsceneCommandActorAction(vector<uint8_t> rawData, int rawDataIndex) : CutsceneCommand(rawData, rawDataIndex)
|
||||
{
|
||||
int numEntries = BitConverter::ToInt32BE(rawData, rawDataIndex);
|
||||
|
||||
rawDataIndex += 4;
|
||||
|
||||
for (int i = 0; i < numEntries; i++)
|
||||
{
|
||||
entries.push_back(new ActorAction(rawData, rawDataIndex));
|
||||
rawDataIndex += 0x30;
|
||||
}
|
||||
}
|
||||
|
||||
string CutsceneCommandActorAction::GenerateSourceCode(string roomName, int baseAddress)
|
||||
{
|
||||
string result = "";
|
||||
|
||||
result += StringHelper::Sprintf("CS_NPC_ACTION_LIST(%i, %i),\n", commandID, entries.size());
|
||||
|
||||
for (int i = 0; i < entries.size(); i++)
|
||||
{
|
||||
result += StringHelper::Sprintf("\tCS_NPC_ACTION(0x%04X, %i, %i, 0x%04X, 0x%04X, 0x%04X, %i, %i, %i, %i, %i, %i, %i, %i, %i),\n", entries[i]->action, entries[i]->startFrame, entries[i]->endFrame,
|
||||
entries[i]->rotX, entries[i]->rotY, entries[i]->rotZ, entries[i]->startPosX, entries[i]->startPosY, entries[i]->startPosZ, entries[i]->endPosX, entries[i]->endPosY, entries[i]->endPosZ,
|
||||
*(int32_t*)&entries[i]->normalX, *(int32_t*)&entries[i]->normalY, *(int32_t*)&entries[i]->normalZ);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
string CutsceneCommandActorAction::GetCName(string prefix)
|
||||
{
|
||||
return "CsCmdBase";
|
||||
}
|
||||
|
||||
size_t CutsceneCommandActorAction::GetCommandSize()
|
||||
{
|
||||
return CutsceneCommand::GetCommandSize() + (entries.size() * 0x30);
|
||||
}
|
||||
|
||||
CutsceneCommandTerminator::CutsceneCommandTerminator(vector<uint8_t> rawData, int rawDataIndex) : CutsceneCommand(rawData, rawDataIndex)
|
||||
{
|
||||
rawDataIndex += 4;
|
||||
|
||||
base = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 0);
|
||||
startFrame = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 2);
|
||||
endFrame = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 4);
|
||||
unknown = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 6);
|
||||
}
|
||||
|
||||
string CutsceneCommandTerminator::GetCName(string prefix)
|
||||
{
|
||||
return "CsCmdBase";
|
||||
}
|
||||
|
||||
string CutsceneCommandTerminator::GenerateSourceCode(string roomName, int baseAddress)
|
||||
{
|
||||
string result = "";
|
||||
|
||||
result += StringHelper::Sprintf("CS_TERMINATOR(0x%04X, %i, %i, 0x%04X),\n", base, startFrame, endFrame, unknown);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
size_t CutsceneCommandTerminator::GetCommandSize()
|
||||
{
|
||||
return CutsceneCommand::GetCommandSize() + 8;
|
||||
}
|
||||
|
||||
CutsceneCommandEnd::CutsceneCommandEnd(vector<uint8_t> rawData, int rawDataIndex) : CutsceneCommand(rawData, rawDataIndex)
|
||||
{
|
||||
base = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 0);
|
||||
startFrame = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 2);
|
||||
endFrame = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 4);
|
||||
}
|
||||
|
||||
string CutsceneCommandEnd::GenerateSourceCode(string roomName, int baseAddress)
|
||||
{
|
||||
string result = "";
|
||||
|
||||
result += StringHelper::Sprintf("CS_END(),\n");
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
string CutsceneCommandEnd::GetCName(string prefix)
|
||||
{
|
||||
return "CsCmdBase";
|
||||
}
|
||||
|
||||
size_t CutsceneCommandEnd::GetCommandSize()
|
||||
{
|
||||
return CutsceneCommand::GetCommandSize() + 6;
|
||||
}
|
||||
|
||||
SpecialActionEntry::SpecialActionEntry(vector<uint8_t> rawData, int rawDataIndex)
|
||||
{
|
||||
uint8_t* data = rawData.data();
|
||||
|
||||
base = (uint16_t)BitConverter::ToInt16BE(data, rawDataIndex + 0);
|
||||
startFrame = (uint16_t)BitConverter::ToInt16BE(data, rawDataIndex + 2);
|
||||
endFrame = (uint16_t)BitConverter::ToInt16BE(data, rawDataIndex + 4);
|
||||
unused0 = (uint16_t)BitConverter::ToInt16BE(data, rawDataIndex + 6);
|
||||
unused1 = (uint32_t)BitConverter::ToInt32BE(data, rawDataIndex + 8);
|
||||
unused2 = (uint32_t)BitConverter::ToInt32BE(data, rawDataIndex + 12);
|
||||
unused3 = (uint32_t)BitConverter::ToInt32BE(data, rawDataIndex + 16);
|
||||
unused4 = (uint32_t)BitConverter::ToInt32BE(data, rawDataIndex + 20);
|
||||
unused5 = (uint32_t)BitConverter::ToInt32BE(data, rawDataIndex + 24);
|
||||
unused6 = (uint32_t)BitConverter::ToInt32BE(data, rawDataIndex + 28);
|
||||
unused7 = (uint32_t)BitConverter::ToInt32BE(data, rawDataIndex + 32);
|
||||
unused8 = (uint32_t)BitConverter::ToInt32BE(data, rawDataIndex + 36);
|
||||
unused9 = (uint32_t)BitConverter::ToInt32BE(data, rawDataIndex + 40);
|
||||
unused10 = (uint32_t)BitConverter::ToInt32BE(data, rawDataIndex + 44);
|
||||
}
|
||||
|
||||
CutsceneCommandSpecialAction::CutsceneCommandSpecialAction(vector<uint8_t> rawData, int rawDataIndex) : CutsceneCommand(rawData, rawDataIndex)
|
||||
{
|
||||
int numEntries = BitConverter::ToInt32BE(rawData, rawDataIndex + 0);
|
||||
|
||||
rawDataIndex += 4;
|
||||
|
||||
for (int i = 0; i < numEntries; i++)
|
||||
{
|
||||
entries.push_back(new SpecialActionEntry(rawData, rawDataIndex));
|
||||
rawDataIndex += 0x30;
|
||||
}
|
||||
}
|
||||
|
||||
string CutsceneCommandSpecialAction::GenerateSourceCode(string roomName, int baseAddress)
|
||||
{
|
||||
string result = "";
|
||||
|
||||
result += StringHelper::Sprintf("CS_MISC_LIST(%i),\n", entries.size());
|
||||
|
||||
for (int i = 0; i < entries.size(); i++)
|
||||
{
|
||||
result += StringHelper::Sprintf("\t\tCS_MISC(0x%04X, %i, %i, 0x%04X, 0x%04X, 0x%04X, %i, %i, %i, %i, %i, %i, %i, %i),\n", entries[i]->base, entries[i]->startFrame, entries[i]->endFrame,
|
||||
entries[i]->unused0, entries[i]->unused1, entries[i]->unused2, entries[i]->unused3, entries[i]->unused4, entries[i]->unused5, entries[i]->unused6,
|
||||
entries[i]->unused7, entries[i]->unused8, entries[i]->unused9, entries[i]->unused10);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
string CutsceneCommandSpecialAction::GetCName(string prefix)
|
||||
{
|
||||
return "CsCmdBase";
|
||||
}
|
||||
|
||||
size_t CutsceneCommandSpecialAction::GetCommandSize()
|
||||
{
|
||||
return CutsceneCommand::GetCommandSize() + (0x30 * entries.size());
|
||||
}
|
||||
|
||||
CutsceneCommandNop::CutsceneCommandNop(vector<uint8_t> rawData, int rawDataIndex) : CutsceneCommand(rawData, rawDataIndex)
|
||||
{
|
||||
base = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 0);
|
||||
startFrame = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 2);
|
||||
endFrame = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 4);
|
||||
}
|
||||
|
||||
string CutsceneCommandNop::GetCName(string prefix)
|
||||
{
|
||||
return "CsCmdBase";
|
||||
}
|
||||
|
||||
size_t CutsceneCommandNop::GetCommandSize()
|
||||
{
|
||||
return CutsceneCommand::GetCommandSize() + 6;
|
||||
}
|
||||
|
||||
CutsceneCommandSceneTransFX::CutsceneCommandSceneTransFX(vector<uint8_t> rawData, int rawDataIndex) : CutsceneCommand(rawData, rawDataIndex)
|
||||
{
|
||||
rawDataIndex += 4;
|
||||
|
||||
base = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 0);
|
||||
startFrame = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 2);
|
||||
endFrame = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 4);
|
||||
}
|
||||
|
||||
string CutsceneCommandSceneTransFX::GenerateSourceCode(string roomName, int baseAddress)
|
||||
{
|
||||
return StringHelper::Sprintf("CS_SCENE_TRANS_FX(%i, %i, %i, %i),\n", base, startFrame, endFrame);
|
||||
}
|
||||
|
||||
string CutsceneCommandSceneTransFX::GetCName(string prefix)
|
||||
{
|
||||
return "CsCmdBase";
|
||||
}
|
||||
|
||||
size_t CutsceneCommandSceneTransFX::GetCommandSize()
|
||||
{
|
||||
return CutsceneCommand::GetCommandSize() + 8;
|
||||
}
|
414
tools/ZAPD/ZAPD/ZCutscene.h
Normal file
414
tools/ZAPD/ZAPD/ZCutscene.h
Normal file
@ -0,0 +1,414 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <stdint.h>
|
||||
#include "ZResource.h"
|
||||
#include "tinyxml2.h"
|
||||
|
||||
enum class CutsceneCommands
|
||||
{
|
||||
Cmd00 = 0x0000,
|
||||
SetCameraPos = 0x0001,
|
||||
SetCameraFocus = 0x0002,
|
||||
SpecialAction = 0x0003,
|
||||
SetLighting = 0x0004,
|
||||
SetCameraPosLink = 0x0005,
|
||||
SetCameraFocusLink = 0x0006,
|
||||
Cmd07 = 0x0007,
|
||||
Cmd08 = 0x0008,
|
||||
Cmd09 = 0x0009,
|
||||
Unknown = 0x001A,
|
||||
Textbox = 0x0013,
|
||||
SetActorAction0 = 0x000A,
|
||||
SetActorAction1 = 0x000F,
|
||||
SetActorAction2 = 0x000E,
|
||||
SetActorAction3 = 0x0019,
|
||||
SetActorAction4 = 0x001D,
|
||||
SetActorAction5 = 0x001E,
|
||||
SetActorAction6 = 0x002C,
|
||||
SetActorAction7 = 0x001F,
|
||||
SetActorAction8 = 0x0031,
|
||||
SetActorAction9 = 0x003E,
|
||||
SetActorAction10 = 0x008F,
|
||||
SetSceneTransFX = 0x002D,
|
||||
Nop = 0x000B,
|
||||
PlayBGM = 0x0056,
|
||||
StopBGM = 0x0057,
|
||||
FadeBGM = 0x007C,
|
||||
SetTime = 0x008C,
|
||||
Terminator = 0x03E8,
|
||||
End = 0xFFFF,
|
||||
Error = 0xFEAF,
|
||||
};
|
||||
|
||||
class CutsceneCameraPoint
|
||||
{
|
||||
public:
|
||||
int8_t continueFlag;
|
||||
int8_t cameraRoll;
|
||||
int16_t nextPointFrame;
|
||||
uint32_t viewAngle;
|
||||
int16_t posX, posY, posZ;
|
||||
int16_t unused;
|
||||
|
||||
CutsceneCameraPoint(std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
};
|
||||
|
||||
class CutsceneCommand
|
||||
{
|
||||
public:
|
||||
uint32_t commandID;
|
||||
uint32_t commandIndex;
|
||||
|
||||
CutsceneCommand(std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
virtual std::string GetCName(std::string prefix);
|
||||
virtual std::string GenerateSourceCode(std::string roomName, int baseAddress);
|
||||
virtual size_t GetCommandSize();
|
||||
};
|
||||
|
||||
class CutsceneCommandSetCameraPos : public CutsceneCommand
|
||||
{
|
||||
public:
|
||||
uint16_t base;
|
||||
uint16_t startFrame;
|
||||
uint16_t endFrame;
|
||||
uint16_t unused;
|
||||
|
||||
std::vector<CutsceneCameraPoint*> entries;
|
||||
|
||||
CutsceneCommandSetCameraPos(std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
std::string GetCName(std::string prefix);
|
||||
std::string GenerateSourceCode(std::string roomName, int baseAddress);
|
||||
size_t GetCommandSize();
|
||||
};
|
||||
|
||||
class SpecialActionEntry
|
||||
{
|
||||
public:
|
||||
uint16_t base;
|
||||
uint16_t startFrame;
|
||||
uint16_t endFrame;
|
||||
uint16_t unused0;
|
||||
uint32_t unused1;
|
||||
uint32_t unused2;
|
||||
uint32_t unused3;
|
||||
uint32_t unused4;
|
||||
uint32_t unused5;
|
||||
uint32_t unused6;
|
||||
uint32_t unused7;
|
||||
uint32_t unused8;
|
||||
uint32_t unused9;
|
||||
uint32_t unused10;
|
||||
|
||||
SpecialActionEntry(std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
};
|
||||
|
||||
class CutsceneCommandSpecialAction : public CutsceneCommand
|
||||
{
|
||||
public:
|
||||
std::vector<SpecialActionEntry*> entries;
|
||||
|
||||
CutsceneCommandSpecialAction(std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
std::string GetCName(std::string prefix);
|
||||
std::string GenerateSourceCode(std::string roomName, int baseAddress);
|
||||
size_t GetCommandSize();
|
||||
};
|
||||
|
||||
class MusicFadeEntry
|
||||
{
|
||||
public:
|
||||
uint16_t base;
|
||||
uint16_t startFrame;
|
||||
uint16_t endFrame;
|
||||
uint16_t unknown0;
|
||||
uint32_t unknown1;
|
||||
uint32_t unknown2;
|
||||
uint32_t unknown3;
|
||||
uint32_t unknown4;
|
||||
uint32_t unknown5;
|
||||
uint32_t unknown6;
|
||||
uint32_t unknown7;
|
||||
uint32_t unknown8;
|
||||
uint32_t unknown9;
|
||||
uint32_t unknown10;
|
||||
|
||||
MusicFadeEntry(std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
};
|
||||
|
||||
class CutsceneCommandFadeBGM : public CutsceneCommand
|
||||
{
|
||||
public:
|
||||
std::vector<MusicFadeEntry*> entries;
|
||||
|
||||
CutsceneCommandFadeBGM( std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
std::string GetCName(std::string prefix);
|
||||
std::string GenerateSourceCode(std::string roomName, int baseAddress);
|
||||
size_t GetCommandSize();
|
||||
};
|
||||
|
||||
class MusicChangeEntry
|
||||
{
|
||||
public:
|
||||
uint16_t sequence;
|
||||
uint16_t startFrame;
|
||||
uint16_t endFrame;
|
||||
uint16_t unknown0;
|
||||
uint32_t unknown1;
|
||||
uint32_t unknown2;
|
||||
uint32_t unknown3;
|
||||
uint32_t unknown4;
|
||||
uint32_t unknown5;
|
||||
uint32_t unknown6;
|
||||
uint32_t unknown7;
|
||||
|
||||
MusicChangeEntry(std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
};
|
||||
|
||||
class CutsceneCommandPlayBGM : public CutsceneCommand
|
||||
{
|
||||
public:
|
||||
std::vector<MusicChangeEntry*> entries;
|
||||
|
||||
CutsceneCommandPlayBGM(std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
std::string GetCName(std::string prefix);
|
||||
std::string GenerateSourceCode(std::string roomName, int baseAddress);
|
||||
size_t GetCommandSize();
|
||||
};
|
||||
|
||||
class CutsceneCommandStopBGM : public CutsceneCommand
|
||||
{
|
||||
public:
|
||||
std::vector<MusicChangeEntry*> entries;
|
||||
|
||||
CutsceneCommandStopBGM(std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
std::string GetCName(std::string prefix);
|
||||
std::string GenerateSourceCode(std::string roomName, int baseAddress);
|
||||
size_t GetCommandSize();
|
||||
};
|
||||
|
||||
class EnvLightingEntry
|
||||
{
|
||||
public:
|
||||
uint16_t setting;
|
||||
uint16_t startFrame;
|
||||
uint16_t endFrame;
|
||||
uint16_t unused0;
|
||||
uint32_t unused1;
|
||||
uint32_t unused2;
|
||||
uint32_t unused3;
|
||||
uint32_t unused4;
|
||||
uint32_t unused5;
|
||||
uint32_t unused6;
|
||||
uint32_t unused7;
|
||||
|
||||
EnvLightingEntry(std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
};
|
||||
|
||||
class CutsceneCommandEnvLighting : public CutsceneCommand
|
||||
{
|
||||
public:
|
||||
std::vector<EnvLightingEntry*> entries;
|
||||
|
||||
CutsceneCommandEnvLighting(std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
std::string GetCName(std::string prefix);
|
||||
std::string GenerateSourceCode(std::string roomName, int baseAddress);
|
||||
size_t GetCommandSize();
|
||||
};
|
||||
|
||||
class CutsceneCommandSceneTransFX : public CutsceneCommand
|
||||
{
|
||||
public:
|
||||
uint16_t base;
|
||||
uint16_t startFrame;
|
||||
uint16_t endFrame;
|
||||
|
||||
CutsceneCommandSceneTransFX(std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
std::string GetCName(std::string prefix);
|
||||
std::string GenerateSourceCode(std::string roomName, int baseAddress);
|
||||
size_t GetCommandSize();
|
||||
};
|
||||
|
||||
class Unknown9Entry
|
||||
{
|
||||
public:
|
||||
uint16_t base;
|
||||
uint16_t startFrame;
|
||||
uint16_t endFrame;
|
||||
uint16_t unk2;
|
||||
uint16_t unk3;
|
||||
uint16_t unk4;
|
||||
uint8_t unused0;
|
||||
uint8_t unused1;
|
||||
|
||||
Unknown9Entry(std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
};
|
||||
|
||||
class CutsceneCommandUnknown9 : public CutsceneCommand
|
||||
{
|
||||
public:
|
||||
std::vector<Unknown9Entry*> entries;
|
||||
|
||||
CutsceneCommandUnknown9(std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
std::string GetCName(std::string prefix);
|
||||
std::string GenerateSourceCode(std::string roomName, int baseAddress);
|
||||
size_t GetCommandSize();
|
||||
};
|
||||
|
||||
class UnkEntry
|
||||
{
|
||||
public:
|
||||
uint32_t unused0;
|
||||
uint32_t unused1;
|
||||
uint32_t unused2;
|
||||
uint32_t unused3;
|
||||
uint32_t unused4;
|
||||
uint32_t unused5;
|
||||
uint32_t unused6;
|
||||
uint32_t unused7;
|
||||
uint32_t unused8;
|
||||
uint32_t unused9;
|
||||
uint32_t unused10;
|
||||
uint32_t unused11;
|
||||
|
||||
UnkEntry(std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
};
|
||||
|
||||
class CutsceneCommandUnknown : public CutsceneCommand
|
||||
{
|
||||
public:
|
||||
std::vector<UnkEntry*> entries;
|
||||
|
||||
CutsceneCommandUnknown(std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
std::string GetCName(std::string prefix);
|
||||
std::string GenerateSourceCode(std::string roomName, int baseAddress);
|
||||
size_t GetCommandSize();
|
||||
};
|
||||
|
||||
class DayTimeEntry
|
||||
{
|
||||
public:
|
||||
uint16_t base;
|
||||
uint16_t startFrame;
|
||||
uint16_t endFrame;
|
||||
uint8_t hour;
|
||||
uint8_t minute;
|
||||
uint8_t unused;
|
||||
|
||||
DayTimeEntry(std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
};
|
||||
|
||||
class CutsceneCommandDayTime : public CutsceneCommand
|
||||
{
|
||||
public:
|
||||
std::vector<DayTimeEntry*> entries;
|
||||
|
||||
CutsceneCommandDayTime(std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
std::string GetCName(std::string prefix);
|
||||
std::string GenerateSourceCode(std::string roomName, int baseAddress);
|
||||
size_t GetCommandSize();
|
||||
};
|
||||
|
||||
class TextboxEntry
|
||||
{
|
||||
public:
|
||||
uint16_t base;
|
||||
uint16_t startFrame;
|
||||
uint16_t endFrame;
|
||||
uint16_t type;
|
||||
uint16_t textID1;
|
||||
uint16_t textID2;
|
||||
|
||||
TextboxEntry(std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
};
|
||||
|
||||
class CutsceneCommandTextbox : public CutsceneCommand
|
||||
{
|
||||
public:
|
||||
std::vector<TextboxEntry*> entries;
|
||||
|
||||
CutsceneCommandTextbox(std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
std::string GetCName(std::string prefix);
|
||||
std::string GenerateSourceCode(std::string roomName, int baseAddress);
|
||||
size_t GetCommandSize();
|
||||
};
|
||||
|
||||
class ActorAction
|
||||
{
|
||||
public:
|
||||
uint16_t action;
|
||||
uint16_t startFrame;
|
||||
uint16_t endFrame;
|
||||
int16_t rotX, rotY, rotZ;
|
||||
int32_t startPosX, startPosY, startPosZ;
|
||||
int32_t endPosX, endPosY, endPosZ;
|
||||
int32_t normalX, normalY, normalZ;
|
||||
|
||||
ActorAction(std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
};
|
||||
|
||||
class CutsceneCommandActorAction : public CutsceneCommand
|
||||
{
|
||||
public:
|
||||
std::vector<ActorAction*> entries;
|
||||
|
||||
CutsceneCommandActorAction(std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
std::string GetCName(std::string prefix);
|
||||
std::string GenerateSourceCode(std::string roomName, int baseAddress);
|
||||
size_t GetCommandSize();
|
||||
};
|
||||
|
||||
class CutsceneCommandTerminator : public CutsceneCommand
|
||||
{
|
||||
public:
|
||||
uint16_t base;
|
||||
uint16_t startFrame;
|
||||
uint16_t endFrame;
|
||||
uint16_t unknown;
|
||||
|
||||
CutsceneCommandTerminator(std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
std::string GetCName(std::string prefix);
|
||||
std::string GenerateSourceCode(std::string roomName, int baseAddress);
|
||||
size_t GetCommandSize();
|
||||
};
|
||||
|
||||
class CutsceneCommandEnd : public CutsceneCommand
|
||||
{
|
||||
public:
|
||||
uint16_t base;
|
||||
uint16_t startFrame;
|
||||
uint16_t endFrame;
|
||||
|
||||
CutsceneCommandEnd(std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
std::string GetCName(std::string prefix);
|
||||
std::string GenerateSourceCode(std::string roomName, int baseAddress);
|
||||
size_t GetCommandSize();
|
||||
};
|
||||
|
||||
class CutsceneCommandNop : public CutsceneCommand
|
||||
{
|
||||
public:
|
||||
uint16_t base;
|
||||
uint16_t startFrame;
|
||||
uint16_t endFrame;
|
||||
|
||||
CutsceneCommandNop(std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
std::string GetCName(std::string prefix);
|
||||
size_t GetCommandSize();
|
||||
};
|
||||
|
||||
class ZCutscene : public ZResource
|
||||
{
|
||||
public:
|
||||
uint32_t segmentOffset;
|
||||
|
||||
CutsceneCommands GetCommandFromID(int id);
|
||||
ZCutscene(std::vector<uint8_t> nRawData, int rawDataIndex, int rawDataSize);
|
||||
|
||||
std::string GetSourceOutputCode(std::string prefix);
|
||||
int GetRawDataSize();
|
||||
private:
|
||||
int numCommands;
|
||||
int endFrame;
|
||||
std::vector<CutsceneCommand*> commands;
|
||||
};
|
1397
tools/ZAPD/ZAPD/ZDisplayList.cpp
Normal file
1397
tools/ZAPD/ZAPD/ZDisplayList.cpp
Normal file
File diff suppressed because it is too large
Load Diff
265
tools/ZAPD/ZAPD/ZDisplayList.h
Normal file
265
tools/ZAPD/ZAPD/ZDisplayList.h
Normal file
@ -0,0 +1,265 @@
|
||||
#pragma once
|
||||
|
||||
#include "ZResource.h"
|
||||
#include "ZTexture.h"
|
||||
#include "ZRoom/ZRoom.h"
|
||||
#include "tinyxml2.h"
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
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 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,
|
||||
};
|
||||
|
||||
#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
|
||||
|
||||
class Vertex
|
||||
{
|
||||
public:
|
||||
int16_t x, y, z;
|
||||
uint16_t flag;
|
||||
int16_t s, t;
|
||||
uint8_t r, g, b, a;
|
||||
|
||||
Vertex();
|
||||
Vertex(int16_t nX, int16_t nY, int16_t nZ, uint16_t nFlag, int16_t nS, int16_t nT, uint8_t nR, uint8_t nG, uint8_t nB, uint8_t nA);
|
||||
Vertex(std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
};
|
||||
|
||||
class ZDisplayList : public ZResource
|
||||
{
|
||||
protected:
|
||||
// Test
|
||||
uint32_t lastTexWidth, lastTexHeight, lastTexAddr, lastTexSeg;
|
||||
F3DZEXTexFormats lastTexFmt;
|
||||
F3DZEXTexSizes lastTexSiz, lastTexSizTest, lastCISiz;
|
||||
bool lastTexLoaded;
|
||||
|
||||
//void ParseXML(tinyxml2::XMLElement* reader);
|
||||
static TextureType TexFormatToTexType(F3DZEXTexFormats fmt, F3DZEXTexSizes siz);
|
||||
void ParseRawData();
|
||||
|
||||
// Various Instruction Optimizations
|
||||
bool SequenceCheck(std::vector<F3DZEXOpcode> sequence, int startIndex);
|
||||
int OptimizationChecks(int startIndex, std::string& output, std::string prefix);
|
||||
int OptimizationCheck_LoadTextureBlock(int startIndex, std::string& output, std::string prefix);
|
||||
int OptimizationCheck_LoadMultiBlock(int startIndex, std::string& output, std::string prefix);
|
||||
public:
|
||||
std::string sceneSegName;
|
||||
ZRoom* scene;
|
||||
std::vector<uint64_t> instructions;
|
||||
|
||||
//int dListAddress;
|
||||
|
||||
std::map<uint32_t, std::vector<Vertex>> vertices;
|
||||
std::map<uint32_t, std::string> vtxDeclarations;
|
||||
std::vector<ZDisplayList*> otherDLists;
|
||||
|
||||
std::map<uint32_t, ZTexture*> textures;
|
||||
std::map<uint32_t, std::string> texDeclarations;
|
||||
|
||||
std::string defines; // Hack for special cases where vertex arrays intersect...
|
||||
std::vector<uint8_t> fileData;
|
||||
|
||||
ZDisplayList();
|
||||
ZDisplayList(std::vector<uint8_t> nRawData, int rawDataIndex, int rawDataSize);
|
||||
|
||||
static ZDisplayList* ExtractFromXML(tinyxml2::XMLElement* reader, std::vector<uint8_t> nRawData, int rawDataIndex, int rawDataSize, std::string nRelPath);
|
||||
static ZDisplayList* BuildFromXML(tinyxml2::XMLElement* reader, std::string inFolder, bool readFile);
|
||||
|
||||
void TextureGenCheck(std::string prefix);
|
||||
static bool TextureGenCheck(std::vector<uint8_t> fileData, std::map<uint32_t, ZTexture*>& textures, ZRoom* scene, ZFile* parent, std::string prefix, uint32_t texWidth, uint32_t texHeight, uint32_t texAddr, uint32_t texSeg, F3DZEXTexFormats texFmt, F3DZEXTexSizes texSiz, bool texLoaded);
|
||||
static int GetDListLength(std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
|
||||
std::vector<uint8_t> GetRawData();
|
||||
int GetRawDataSize();
|
||||
std::string GetSourceOutputHeader(std::string prefix);
|
||||
std::string GetSourceOutputCode(std::string prefix);
|
||||
void Save(std::string outFolder);
|
||||
virtual void GenerateHLIntermediette(HLFileIntermediette& hlFile);
|
||||
};
|
859
tools/ZAPD/ZAPD/ZFile.cpp
Normal file
859
tools/ZAPD/ZAPD/ZFile.cpp
Normal file
@ -0,0 +1,859 @@
|
||||
#include "ZFile.h"
|
||||
#include "ZBlob.h"
|
||||
#include "ZDisplayList.h"
|
||||
#include "ZRoom/ZRoom.h"
|
||||
#include "ZTexture.h"
|
||||
#include "ZAnimation.h"
|
||||
#include "ZSkeleton.h"
|
||||
#include "ZCollision.h"
|
||||
#include "Path.h"
|
||||
#include "File.h"
|
||||
#include "Directory.h"
|
||||
#include "Globals.h"
|
||||
#include "HighLevel/HLModelIntermediette.h"
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
using namespace tinyxml2;
|
||||
using namespace std;
|
||||
|
||||
ZFile::ZFile()
|
||||
{
|
||||
resources = vector<ZResource*>();
|
||||
basePath = "";
|
||||
outputPath = Directory::GetCurrentDirectory();
|
||||
declarations = map<int32_t, Declaration*>();
|
||||
defines = "";
|
||||
baseAddress = 0;
|
||||
rangeStart = 0x000000000;
|
||||
rangeEnd = 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
ZFile::ZFile(string nOutPath, string nName) : ZFile()
|
||||
{
|
||||
outputPath = nOutPath;
|
||||
name = nName;
|
||||
}
|
||||
|
||||
ZFile::ZFile(ZFileMode mode, XMLElement* reader, string nBasePath, string nOutPath, bool placeholderMode) : ZFile()
|
||||
{
|
||||
if (nBasePath == "")
|
||||
basePath = Directory::GetCurrentDirectory();
|
||||
else
|
||||
basePath = nBasePath;
|
||||
|
||||
if (nOutPath == "")
|
||||
outputPath = Directory::GetCurrentDirectory();
|
||||
else
|
||||
outputPath = nOutPath;
|
||||
|
||||
ParseXML(mode, reader, placeholderMode);
|
||||
}
|
||||
|
||||
void ZFile::ParseXML(ZFileMode mode, XMLElement* reader, bool placeholderMode)
|
||||
{
|
||||
name = reader->Attribute("Name");
|
||||
int segment = -1;
|
||||
|
||||
if (reader->Attribute("BaseAddress") != NULL)
|
||||
baseAddress = (uint32_t)strtoul(StringHelper::Split(reader->Attribute("BaseAddress"), "0x")[1].c_str(), NULL, 16);
|
||||
|
||||
if (reader->Attribute("RangeStart") != NULL)
|
||||
rangeStart = (uint32_t)strtoul(StringHelper::Split(reader->Attribute("RangeStart"), "0x")[1].c_str(), NULL, 16);
|
||||
|
||||
if (reader->Attribute("RangeEnd") != NULL)
|
||||
rangeEnd = (uint32_t)strtoul(StringHelper::Split(reader->Attribute("RangeEnd"), "0x")[1].c_str(), NULL, 16);
|
||||
|
||||
if (reader->Attribute("Segment") != NULL)
|
||||
segment = strtol(reader->Attribute("Segment"), NULL, 10);
|
||||
|
||||
if (segment != -1)
|
||||
{
|
||||
//printf("Adding Segment %i\n", segment);
|
||||
Globals::Instance->AddSegment(segment);
|
||||
}
|
||||
|
||||
string folderName = basePath + "/" + Path::GetFileNameWithoutExtension(name);
|
||||
|
||||
if (mode == ZFileMode::Extract)
|
||||
{
|
||||
if (!File::Exists(basePath + "/" + name))
|
||||
throw StringHelper::Sprintf("Error! File %s does not exist.", (basePath + "/" + name).c_str());
|
||||
|
||||
rawData = File::ReadAllBytes(basePath + "/" + name);
|
||||
}
|
||||
|
||||
int rawDataIndex = 0;
|
||||
|
||||
for (XMLElement* child = reader->FirstChildElement(); child != NULL; child = child->NextSiblingElement())
|
||||
{
|
||||
if (child->Attribute("Offset") != NULL)
|
||||
rawDataIndex = strtol(StringHelper::Split(child->Attribute("Offset"), "0x")[1].c_str(), NULL, 16);
|
||||
|
||||
printf("%s: 0x%06X\n", child->Attribute("Name"), rawDataIndex);
|
||||
|
||||
if (string(child->Name()) == "Texture")
|
||||
{
|
||||
ZTexture* tex = nullptr;
|
||||
|
||||
if (mode == ZFileMode::Extract)
|
||||
tex = ZTexture::ExtractFromXML(child, rawData, rawDataIndex, folderName);
|
||||
else
|
||||
tex = ZTexture::BuildFromXML(child, folderName, mode == ZFileMode::Build);
|
||||
|
||||
tex->SetRawDataIndex(rawDataIndex);
|
||||
|
||||
tex->parent = this;
|
||||
|
||||
resources.push_back(tex);
|
||||
rawDataIndex += tex->GetRawDataSize();
|
||||
}
|
||||
else if (string(child->Name()) == "Blob")
|
||||
{
|
||||
ZBlob* blob = nullptr;
|
||||
|
||||
if (mode == ZFileMode::Extract)
|
||||
blob = ZBlob::ExtractFromXML(child, rawData, rawDataIndex, folderName);
|
||||
else
|
||||
blob = ZBlob::BuildFromXML(child, folderName, mode == ZFileMode::Build);
|
||||
|
||||
blob->parent = this;
|
||||
|
||||
resources.push_back(blob);
|
||||
|
||||
rawDataIndex += blob->GetRawDataSize();
|
||||
}
|
||||
else if (string(child->Name()) == "DList")
|
||||
{
|
||||
ZResource* dList = nullptr;
|
||||
|
||||
if (mode == ZFileMode::Extract)
|
||||
dList = ZDisplayList::ExtractFromXML(child, rawData, rawDataIndex, ZDisplayList::GetDListLength(rawData, rawDataIndex), folderName);
|
||||
//else
|
||||
//dList = ZDisplayList::BuildFromXML(child, folderName, mode == ZFileMode::Build);
|
||||
else
|
||||
dList = ZBlob::BuildFromXML(child, folderName, mode == ZFileMode::Build);
|
||||
|
||||
dList->parent = this;
|
||||
|
||||
resources.push_back(dList);
|
||||
|
||||
rawDataIndex += dList->GetRawDataSize();
|
||||
}
|
||||
else if (string(child->Name()) == "Scene" || string(child->Name()) == "Room")
|
||||
{
|
||||
ZRoom* room = nullptr;
|
||||
|
||||
if (mode == ZFileMode::Extract)
|
||||
room = ZRoom::ExtractFromXML(child, rawData, rawDataIndex, folderName, this, Globals::Instance->lastScene);
|
||||
|
||||
if (string(child->Name()) == "Scene")
|
||||
{
|
||||
Globals::Instance->lastScene = room;
|
||||
|
||||
if (segment == -1)
|
||||
segment = SEGMENT_SCENE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (segment == -1)
|
||||
segment = SEGMENT_ROOM;
|
||||
}
|
||||
|
||||
if (segment != -1)
|
||||
Globals::Instance->AddSegment(segment);
|
||||
|
||||
resources.push_back(room);
|
||||
|
||||
rawDataIndex += room->GetRawDataSize();
|
||||
}
|
||||
else if (string(child->Name()) == "Animation")
|
||||
{
|
||||
ZAnimation* anim = nullptr;
|
||||
|
||||
if (mode == ZFileMode::Extract)
|
||||
anim = ZNormalAnimation::ExtractFromXML(child, rawData, rawDataIndex, folderName);
|
||||
|
||||
anim->parent = this;
|
||||
resources.push_back(anim);
|
||||
|
||||
rawDataIndex += anim->GetRawDataSize();
|
||||
}
|
||||
else if (string(child->Name()) == "PlayerAnimation")
|
||||
{
|
||||
ZLinkAnimation* anim = nullptr;
|
||||
|
||||
if (mode == ZFileMode::Extract)
|
||||
anim = ZLinkAnimation::ExtractFromXML(child, rawData, rawDataIndex, folderName);
|
||||
|
||||
anim->parent = this;
|
||||
resources.push_back(anim);
|
||||
|
||||
rawDataIndex += anim->GetRawDataSize();
|
||||
}
|
||||
else if (string(child->Name()) == "Skeleton")
|
||||
{
|
||||
ZSkeleton* skeleton = nullptr;
|
||||
|
||||
if (mode == ZFileMode::Extract)
|
||||
skeleton = ZSkeleton::FromXML(child, rawData, rawDataIndex, folderName, this);
|
||||
|
||||
resources.push_back(skeleton);
|
||||
rawDataIndex += skeleton->GetRawDataSize();
|
||||
}
|
||||
else if (string(child->Name()) == "Limb")
|
||||
{
|
||||
ZLimbStandard* limb = nullptr;
|
||||
|
||||
if (mode == ZFileMode::Extract)
|
||||
limb = ZLimbStandard::FromXML(child, rawData, rawDataIndex, folderName, this);
|
||||
|
||||
resources.push_back(limb);
|
||||
|
||||
rawDataIndex += limb->GetRawDataSize();
|
||||
}
|
||||
else if (string(child->Name()) == "Symbol")
|
||||
{
|
||||
ZResource* res = nullptr;
|
||||
|
||||
if (mode == ZFileMode::Extract)
|
||||
{
|
||||
res = new ZResource();
|
||||
res->SetName(child->Attribute("Name"));
|
||||
res->SetRawDataIndex(rawDataIndex);
|
||||
res->outputDeclaration = false;
|
||||
}
|
||||
|
||||
resources.push_back(res);
|
||||
}
|
||||
else if (string(child->Name()) == "Collision")
|
||||
{
|
||||
ZCollisionHeader* res = nullptr;
|
||||
|
||||
if (mode == ZFileMode::Extract)
|
||||
{
|
||||
res = new ZCollisionHeader(this, child->Attribute("Name"), rawData, rawDataIndex);
|
||||
res->SetName(child->Attribute("Name"));
|
||||
res->SetRawDataIndex(rawDataIndex);
|
||||
}
|
||||
|
||||
resources.push_back(res);
|
||||
}
|
||||
else if (string(child->Name()) == "Vec3s")
|
||||
{
|
||||
|
||||
}
|
||||
else if (string(child->Name()) == "Vec3f")
|
||||
{
|
||||
|
||||
}
|
||||
else if (string(child->Name()) == "Vec3i")
|
||||
{
|
||||
|
||||
}
|
||||
else if (string(child->Name()) == "String")
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ZFile::BuildResources()
|
||||
{
|
||||
cout << "Building resources " << name << "\n";
|
||||
|
||||
int size = 0;
|
||||
|
||||
for (ZResource* res : resources)
|
||||
size += res->GetRawDataSize();
|
||||
|
||||
// Make sure size is 16 byte aligned
|
||||
if (size % 16 != 0)
|
||||
size = ((size / 16) + 1) * 16;
|
||||
|
||||
vector<uint8_t> file = vector<uint8_t>(size);
|
||||
int fileIndex = 0;
|
||||
|
||||
for (ZResource* res : resources)
|
||||
{
|
||||
//Console.WriteLine("Building resource " + res.GetName());
|
||||
memcpy(file.data() + fileIndex, res->GetRawData().data(), res->GetRawData().size());
|
||||
//Array.Copy(res.GetRawData(), 0, file, fileIndex, res.GetRawData().Length);
|
||||
fileIndex += res->GetRawData().size();
|
||||
}
|
||||
|
||||
File::WriteAllBytes(basePath + "/" + name, file);
|
||||
}
|
||||
|
||||
void ZFile::BuildSourceFile(string outputDir)
|
||||
{
|
||||
string folderName = Path::GetFileNameWithoutExtension(outputPath);
|
||||
|
||||
if (!Directory::Exists(outputPath))
|
||||
Directory::CreateDirectory(outputPath);
|
||||
|
||||
GenerateSourceFiles(outputDir);
|
||||
}
|
||||
|
||||
std::string ZFile::GetVarName(int address)
|
||||
{
|
||||
for (pair<int32_t, Declaration*> pair : declarations)
|
||||
{
|
||||
if (pair.first == address)
|
||||
return pair.second->varName;
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
void ZFile::ExtractResources(string outputDir)
|
||||
{
|
||||
string folderName = Path::GetFileNameWithoutExtension(outputPath);
|
||||
|
||||
//printf("DIR CHECK: %s\n", folderName.c_str());
|
||||
//printf("OUT CHECK: %s\n", outputDir.c_str());
|
||||
|
||||
if (!Directory::Exists(outputPath))
|
||||
Directory::CreateDirectory(outputPath);
|
||||
|
||||
for (ZResource* res : resources)
|
||||
res->PreGenSourceFiles();
|
||||
|
||||
if (Globals::Instance->genSourceFile)
|
||||
GenerateSourceFiles(outputDir);
|
||||
|
||||
for (ZResource* res : resources)
|
||||
{
|
||||
printf("Saving resource %s\n", res->GetName().c_str());
|
||||
res->CalcHash(); // TEST
|
||||
res->Save(outputPath);
|
||||
}
|
||||
|
||||
if (Globals::Instance->testMode)
|
||||
GenerateHLIntermediette();
|
||||
}
|
||||
|
||||
void ZFile::AddResource(ZResource* res)
|
||||
{
|
||||
resources.push_back(res);
|
||||
}
|
||||
|
||||
Declaration* ZFile::AddDeclaration(uint32_t address, DeclarationAlignment alignment, uint32_t size, std::string varType, std::string varName, std::string body)
|
||||
{
|
||||
#if _DEBUG
|
||||
if (declarations.find(address) != declarations.end())
|
||||
{
|
||||
int bp = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
AddDeclarationDebugChecks(address);
|
||||
|
||||
Declaration* decl = new Declaration(alignment, size, varType, varName, false, body);
|
||||
declarations[address] = decl;
|
||||
return decl;
|
||||
}
|
||||
|
||||
void ZFile::AddDeclaration(uint32_t address, DeclarationAlignment alignment, DeclarationPadding padding, uint32_t size, string varType, string varName, std::string body)
|
||||
{
|
||||
#if _DEBUG
|
||||
if (declarations.find(address) != declarations.end())
|
||||
{
|
||||
int bp = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
AddDeclarationDebugChecks(address);
|
||||
|
||||
declarations[address] = new Declaration(alignment, padding, size, varType, varName, false, body);
|
||||
}
|
||||
|
||||
void ZFile::AddDeclarationArray(uint32_t address, DeclarationAlignment alignment, uint32_t size, std::string varType, std::string varName, int arrayItemCnt, std::string body)
|
||||
{
|
||||
#if _DEBUG
|
||||
if (declarations.find(address) != declarations.end())
|
||||
{
|
||||
int bp = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
AddDeclarationDebugChecks(address);
|
||||
|
||||
declarations[address] = new Declaration(alignment, size, varType, varName, true, arrayItemCnt, body);
|
||||
}
|
||||
|
||||
|
||||
void ZFile::AddDeclarationArray(uint32_t address, DeclarationAlignment alignment, DeclarationPadding padding, uint32_t size, string varType, string varName, int arrayItemCnt, std::string body)
|
||||
{
|
||||
#if _DEBUG
|
||||
if (declarations.find(address) != declarations.end())
|
||||
{
|
||||
int bp = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
AddDeclarationDebugChecks(address);
|
||||
|
||||
declarations[address] = new Declaration(alignment, padding, size, varType, varName, true, arrayItemCnt, body);
|
||||
}
|
||||
|
||||
|
||||
void ZFile::AddDeclarationPlaceholder(uint32_t address)
|
||||
{
|
||||
AddDeclarationDebugChecks(address);
|
||||
|
||||
if (declarations.find(address) == declarations.end())
|
||||
declarations[address] = new Declaration(DeclarationAlignment::None, 0, "", "", false, "");
|
||||
}
|
||||
|
||||
void ZFile::AddDeclarationPlaceholder(uint32_t address, string varName)
|
||||
{
|
||||
AddDeclarationDebugChecks(address);
|
||||
|
||||
if (declarations.find(address) == declarations.end())
|
||||
declarations[address] = new Declaration(DeclarationAlignment::None, 0, "", varName, false, "");
|
||||
}
|
||||
|
||||
void ZFile::AddDeclarationInclude(uint32_t address, string includePath, uint32_t size, string varType, string varName)
|
||||
{
|
||||
AddDeclarationDebugChecks(address);
|
||||
|
||||
if (declarations.find(address) == declarations.end())
|
||||
declarations[address] = new Declaration(includePath, size, varType, varName);
|
||||
}
|
||||
|
||||
void ZFile::AddDeclarationIncludeArray(uint32_t address, std::string includePath, uint32_t size, std::string varType, std::string varName, int arrayItemCnt)
|
||||
{
|
||||
#if _DEBUG
|
||||
if (declarations.find(address) != declarations.end())
|
||||
{
|
||||
int bp = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
AddDeclarationDebugChecks(address);
|
||||
|
||||
Declaration* decl = new Declaration(includePath, size, varType, varName);
|
||||
|
||||
decl->isArray = true;
|
||||
decl->arrayItemCnt = arrayItemCnt;
|
||||
|
||||
declarations[address] = decl;
|
||||
}
|
||||
|
||||
void ZFile::AddDeclarationDebugChecks(uint32_t address)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
if (address == 0xB888E0)
|
||||
{
|
||||
int bp = 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string ZFile::GetDeclarationName(uint32_t address)
|
||||
{
|
||||
return GetDeclarationName(address, "ERROR_COULD_NOT_FIND_DECLARATION"); // Note: For now that default message is just for testing
|
||||
}
|
||||
|
||||
std::string ZFile::GetDeclarationName(uint32_t address, std::string defaultResult)
|
||||
{
|
||||
if (declarations.find(address) != declarations.end())
|
||||
return declarations[address]->varName;
|
||||
|
||||
return defaultResult;
|
||||
}
|
||||
|
||||
Declaration* ZFile::GetDeclaration(uint32_t address)
|
||||
{
|
||||
if (declarations.find(address) != declarations.end())
|
||||
return declarations[address];
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Declaration* ZFile::GetDeclarationRanged(uint32_t address)
|
||||
{
|
||||
for (const auto decl : declarations)
|
||||
{
|
||||
if (address >= decl.first && address <= decl.first + decl.second->size)
|
||||
{
|
||||
return decl.second;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool ZFile::HasDeclaration(uint32_t address)
|
||||
{
|
||||
return (declarations.find(address) != declarations.end());
|
||||
}
|
||||
|
||||
void ZFile::GenerateSourceFiles(string outputDir)
|
||||
{
|
||||
sourceOutput = "";
|
||||
|
||||
sourceOutput += "#include \"ultra64.h\"\n";
|
||||
sourceOutput += "#include \"z64.h\"\n";
|
||||
sourceOutput += "#include \"macros.h\"\n";
|
||||
sourceOutput += GetHeaderInclude();
|
||||
|
||||
GeneratePlaceholderDeclarations();
|
||||
|
||||
// Generate Code
|
||||
for (ZResource* res : resources)
|
||||
{
|
||||
string resSrc = res->GetSourceOutputCode(name);
|
||||
|
||||
if (res->IsExternalResource())
|
||||
{
|
||||
//cout << "EXTERN\n";
|
||||
string path = Path::GetFileNameWithoutExtension(res->GetName()).c_str();
|
||||
|
||||
while (StringHelper::EndsWith(outputDir, "/"))
|
||||
outputDir = outputDir.substr(0, outputDir.length() - 1);
|
||||
|
||||
// HACK
|
||||
string declType = "u64";
|
||||
|
||||
if (res->GetResourceType() != ZResourceType::Texture)
|
||||
declType = "u8";
|
||||
|
||||
AddDeclarationIncludeArray(res->GetRawDataIndex(), StringHelper::Sprintf("%s/%s.%s.inc.c",
|
||||
outputDir.c_str(), Path::GetFileNameWithoutExtension(res->GetOutName()).c_str(), res->GetExternalExtension().c_str()), res->GetRawDataSize(),
|
||||
declType, res->GetName(), 0);
|
||||
|
||||
|
||||
//File::WriteAllText("build/" + outputDir + "/" + Path::GetFileNameWithoutExtension(res->GetName()) + ".inc.c", resSrc);
|
||||
}
|
||||
else
|
||||
{
|
||||
//cout << "NOT EXTERN\n";
|
||||
sourceOutput += resSrc;
|
||||
}
|
||||
|
||||
if (resSrc != "" && !res->IsExternalResource())
|
||||
sourceOutput += "\n";
|
||||
}
|
||||
|
||||
sourceOutput += ProcessDeclarations();
|
||||
|
||||
while (StringHelper::EndsWith(outputDir, "/"))
|
||||
outputDir = outputDir.substr(0, outputDir.length() - 1);
|
||||
|
||||
//string buildPath = "build/" + outputDir + "/" + "basefile.txt";
|
||||
string outPath = outputDir + "/" + Path::GetFileNameWithoutExtension(name) + ".c";
|
||||
//printf("WRITING %s\n", buildPath.c_str());
|
||||
|
||||
//if (!Directory::Exists(Path::GetPath(outPath)))
|
||||
//Directory::CreateDirectory(Path::GetPath(outPath));
|
||||
|
||||
//if (!Directory::Exists(Path::GetPath(buildPath)))
|
||||
//Directory::CreateDirectory(Path::GetPath(buildPath));
|
||||
|
||||
File::WriteAllText(outPath, sourceOutput);
|
||||
//File::WriteAllText(buildPath, outPath);
|
||||
|
||||
// Generate Header
|
||||
sourceOutput = "";
|
||||
|
||||
for (ZResource* res : resources)
|
||||
{
|
||||
string resSrc = res->GetSourceOutputHeader("");
|
||||
sourceOutput += resSrc;
|
||||
|
||||
if (resSrc != "")
|
||||
sourceOutput += "\n";
|
||||
}
|
||||
|
||||
sourceOutput += ProcessExterns();
|
||||
|
||||
File::WriteAllText(outputDir + "/" + Path::GetFileNameWithoutExtension(name) + ".h", sourceOutput);
|
||||
}
|
||||
|
||||
void ZFile::GenerateHLIntermediette()
|
||||
{
|
||||
// This is kinda hacky but it gets the job done for now...
|
||||
HLModelIntermediette* mdl = new HLModelIntermediette();
|
||||
|
||||
for (ZResource* res : resources)
|
||||
{
|
||||
if (typeid(ZDisplayList) == typeid(*res) || typeid(ZSkeleton) == typeid(*res))
|
||||
res->GenerateHLIntermediette(*mdl);
|
||||
}
|
||||
|
||||
std::string test = mdl->ToOBJFile();
|
||||
std::string test2 = mdl->ToFBXFile();
|
||||
}
|
||||
|
||||
std::string ZFile::GetHeaderInclude()
|
||||
{
|
||||
return StringHelper::Sprintf("#include \"%s\"\n\n", (Path::GetFileNameWithoutExtension(name) + ".h").c_str());
|
||||
}
|
||||
|
||||
void ZFile::GeneratePlaceholderDeclarations()
|
||||
{
|
||||
// Generate placeholder declarations
|
||||
for (ZResource* res : resources)
|
||||
{
|
||||
if (GetDeclaration(res->GetRawDataIndex()) == nullptr)
|
||||
AddDeclarationPlaceholder(res->GetRawDataIndex(), res->GetName());
|
||||
}
|
||||
}
|
||||
|
||||
string ZFile::ProcessDeclarations()
|
||||
{
|
||||
string output = "";
|
||||
|
||||
if (declarations.size() == 0)
|
||||
return output;
|
||||
|
||||
auto declarationKeysSorted = vector<pair<int32_t, Declaration*>>(declarations.begin(), declarations.end());
|
||||
sort(declarationKeysSorted.begin(), declarationKeysSorted.end(), [](const auto& lhs, const auto& rhs)
|
||||
{
|
||||
return lhs.first < rhs.first;
|
||||
});
|
||||
|
||||
// Account for padding/alignment
|
||||
int lastAddr = 0;
|
||||
|
||||
//printf("RANGE START: 0x%06X - RANGE END: 0x%06X\n", rangeStart, rangeEnd);
|
||||
|
||||
for (pair<int32_t, Declaration*> item : declarationKeysSorted)
|
||||
{
|
||||
while (declarations[item.first]->size % 4 != 0)
|
||||
{
|
||||
declarations[item.first]->size++;
|
||||
}
|
||||
|
||||
if (lastAddr != 0)
|
||||
{
|
||||
if (item.second->alignment == DeclarationAlignment::Align16)
|
||||
{
|
||||
int lastAddrSizeTest = declarations[lastAddr]->size;
|
||||
int curPtr = lastAddr + declarations[lastAddr]->size;
|
||||
|
||||
while (curPtr % 4 != 0)
|
||||
{
|
||||
declarations[lastAddr]->size++;
|
||||
//declarations[item.first]->size++;
|
||||
curPtr++;
|
||||
}
|
||||
|
||||
/*while (curPtr % 16 != 0)
|
||||
{
|
||||
char buffer[2048];
|
||||
|
||||
sprintf(buffer, "static u32 align%02X = 0;\n", curPtr);
|
||||
declarations[item.first]->text = buffer + declarations[item.first]->text;
|
||||
|
||||
declarations[lastAddr]->size += 4;
|
||||
curPtr += 4;
|
||||
}*/
|
||||
}
|
||||
else if (item.second->alignment == DeclarationAlignment::Align8)
|
||||
{
|
||||
int curPtr = lastAddr + declarations[lastAddr]->size;
|
||||
|
||||
while (curPtr % 4 != 0)
|
||||
{
|
||||
declarations[lastAddr]->size++;
|
||||
//item.second->size++;
|
||||
//declarations[item.first]->size++;
|
||||
curPtr++;
|
||||
}
|
||||
|
||||
while (curPtr % 8 != 0)
|
||||
{
|
||||
char buffer[2048];
|
||||
|
||||
sprintf(buffer, "static u32 align%02X = 0;\n", curPtr);
|
||||
declarations[item.first]->preText = buffer + declarations[item.first]->preText;
|
||||
|
||||
declarations[lastAddr]->size += 4;
|
||||
//item.second->size += 4;
|
||||
//declarations[item.first]->size += 4;
|
||||
curPtr += 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (item.second->padding == DeclarationPadding::Pad16)
|
||||
{
|
||||
int curPtr = item.first + item.second->size;
|
||||
|
||||
while (curPtr % 4 != 0)
|
||||
{
|
||||
item.second->size++;
|
||||
curPtr++;
|
||||
}
|
||||
|
||||
while (curPtr % 16 != 0)
|
||||
{
|
||||
declarations[item.first]->postText += StringHelper::Sprintf("static u32 pad%02X = 0;\n", curPtr);
|
||||
|
||||
item.second->size += 4;
|
||||
curPtr += 4;
|
||||
}
|
||||
}
|
||||
|
||||
lastAddr = item.first;
|
||||
}
|
||||
|
||||
// Handle unaccounted data
|
||||
lastAddr = 0;
|
||||
for (pair<int32_t, Declaration*> item : declarationKeysSorted)
|
||||
{
|
||||
if (lastAddr != 0 && item.first >= rangeStart && item.first < rangeEnd)
|
||||
{
|
||||
if (lastAddr + declarations[lastAddr]->size > item.first)
|
||||
{
|
||||
// UH OH!
|
||||
int bp = 0;
|
||||
}
|
||||
|
||||
uint8_t* rawDataArr = rawData.data();
|
||||
|
||||
if (lastAddr + declarations[lastAddr]->size != item.first)
|
||||
{
|
||||
int diff = item.first - (lastAddr + declarations[lastAddr]->size);
|
||||
|
||||
string src = " ";
|
||||
|
||||
|
||||
for (int i = 0; i < diff; i++)
|
||||
{
|
||||
src += StringHelper::Sprintf("0x%02X, ", rawDataArr[lastAddr + declarations[lastAddr]->size + i]);
|
||||
|
||||
if ((i % 16 == 15) && (i != (diff - 1)))
|
||||
src += "\n ";
|
||||
}
|
||||
|
||||
if (declarations.find(lastAddr + declarations[lastAddr]->size) == declarations.end())
|
||||
{
|
||||
if (diff > 0)
|
||||
{
|
||||
AddDeclarationArray(lastAddr + declarations[lastAddr]->size, DeclarationAlignment::None, diff, "static u8", StringHelper::Sprintf("unaccounted_%06X", lastAddr + declarations[lastAddr]->size),
|
||||
diff, src);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lastAddr = item.first;
|
||||
}
|
||||
|
||||
// TODO: THIS CONTAINS REDUNDANCIES. CLEAN THIS UP!
|
||||
if (lastAddr + declarations[lastAddr]->size < rawData.size() && lastAddr + declarations[lastAddr]->size >= rangeStart && lastAddr + declarations[lastAddr]->size < rangeEnd)
|
||||
{
|
||||
int diff = (int)(rawData.size() - (lastAddr + declarations[lastAddr]->size));
|
||||
|
||||
string src = " ";
|
||||
|
||||
for (int i = 0; i < diff; i++)
|
||||
{
|
||||
src += StringHelper::Sprintf("0x%02X, ", rawData[lastAddr + declarations[lastAddr]->size + i]);
|
||||
|
||||
if (i % 16 == 15)
|
||||
src += "\n ";
|
||||
}
|
||||
|
||||
if (declarations.find(lastAddr + declarations[lastAddr]->size) == declarations.end())
|
||||
{
|
||||
if (diff > 0)
|
||||
{
|
||||
AddDeclarationArray(lastAddr + declarations[lastAddr]->size, DeclarationAlignment::None, diff, "static u8", StringHelper::Sprintf("unaccounted_%06X", lastAddr + declarations[lastAddr]->size),
|
||||
diff, src);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Go through include declarations
|
||||
declarationKeysSorted = vector<pair<int32_t, Declaration*>>(declarations.begin(), declarations.end());
|
||||
sort(declarationKeysSorted.begin(), declarationKeysSorted.end(), [](const auto& lhs, const auto& rhs)
|
||||
{
|
||||
return lhs.first < rhs.first;
|
||||
});
|
||||
|
||||
for (pair<int32_t, Declaration*> item : declarationKeysSorted)
|
||||
{
|
||||
if (item.second->includePath != "")
|
||||
{
|
||||
//output += StringHelper::Sprintf("#include \"%s\"\n", item.second->includePath.c_str());
|
||||
output += StringHelper::Sprintf("%s %s[] = {\n#include \"%s\"\n};\n\n", item.second->varType.c_str(), item.second->varName.c_str(), item.second->includePath.c_str());
|
||||
}
|
||||
else if (item.second->varType != "")
|
||||
{
|
||||
if (item.second->preText != "")
|
||||
output += item.second->preText + "\n";
|
||||
|
||||
if (item.second->isArray)
|
||||
{
|
||||
if (item.second->arrayItemCnt == 0)
|
||||
output += StringHelper::Sprintf("%s %s[] = {\n", item.second->varType.c_str(), item.second->varName.c_str());
|
||||
else
|
||||
output += StringHelper::Sprintf("%s %s[%i] = {\n", item.second->varType.c_str(), item.second->varName.c_str(), item.second->arrayItemCnt);
|
||||
|
||||
output += item.second->text + "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
output += StringHelper::Sprintf("%s %s = { ", item.second->varType.c_str(), item.second->varName.c_str());
|
||||
output += item.second->text;
|
||||
}
|
||||
|
||||
if (output.back() == '\n')
|
||||
output += "};";
|
||||
else
|
||||
output += " };";
|
||||
|
||||
output += " " + item.second->rightText + "\n\n";
|
||||
|
||||
if (item.second->postText != "")
|
||||
output += item.second->postText + "\n";
|
||||
}
|
||||
}
|
||||
|
||||
output += "\n";
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
string ZFile::ProcessExterns()
|
||||
{
|
||||
string output = "";
|
||||
|
||||
auto declarationKeysSorted = vector<pair<int32_t, Declaration*>>(declarations.begin(), declarations.end());
|
||||
sort(declarationKeysSorted.begin(), declarationKeysSorted.end(), [](const auto& lhs, const auto& rhs)
|
||||
{
|
||||
return lhs.first < rhs.first;
|
||||
});
|
||||
|
||||
for (pair<int32_t, Declaration*> item : declarationKeysSorted)
|
||||
{
|
||||
if (!StringHelper::StartsWith(item.second->varType, "static ") && item.second->varType != "")// && item.second->includePath == "")
|
||||
{
|
||||
if (item.second->isArray)
|
||||
{
|
||||
if (item.second->arrayItemCnt == 0)
|
||||
output += StringHelper::Sprintf("extern %s %s[];\n", item.second->varType.c_str(), item.second->varName.c_str());
|
||||
else
|
||||
output += StringHelper::Sprintf("extern %s %s[%i];\n", item.second->varType.c_str(), item.second->varName.c_str(), item.second->arrayItemCnt);
|
||||
}
|
||||
else
|
||||
output += StringHelper::Sprintf("extern %s %s;\n", item.second->varType.c_str(), item.second->varName.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
output += "\n";
|
||||
|
||||
output += defines;
|
||||
|
||||
return output;
|
||||
}
|
68
tools/ZAPD/ZAPD/ZFile.h
Normal file
68
tools/ZAPD/ZAPD/ZFile.h
Normal file
@ -0,0 +1,68 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "tinyxml2.h"
|
||||
#include "ZResource.h"
|
||||
|
||||
enum class ZFileMode
|
||||
{
|
||||
Build,
|
||||
BuildTexture,
|
||||
BuildOverlay,
|
||||
BuildModelIntermediette,
|
||||
BuildAnimationIntermediette,
|
||||
BuildBlob,
|
||||
BuildSourceFile,
|
||||
Extract,
|
||||
Invalid
|
||||
};
|
||||
|
||||
class ZFile
|
||||
{
|
||||
public:
|
||||
std::map<int32_t, Declaration*> declarations;
|
||||
std::string defines;
|
||||
std::vector<ZResource*> resources;
|
||||
uint32_t baseAddress, rangeStart, rangeEnd;
|
||||
|
||||
ZFile(std::string nOutPath, std::string nName);
|
||||
ZFile(ZFileMode mode, tinyxml2::XMLElement* reader, std::string nBasePath, std::string nOutPath, bool placeholderMode);
|
||||
|
||||
std::string GetVarName(int address);
|
||||
void ExtractResources(std::string outputDir);
|
||||
void BuildResources();
|
||||
void BuildSourceFile(std::string outputDir);
|
||||
void AddResource(ZResource* res);
|
||||
|
||||
Declaration* AddDeclaration(uint32_t address, DeclarationAlignment alignment, uint32_t size, std::string varType, std::string varName, std::string body);
|
||||
void AddDeclaration(uint32_t address, DeclarationAlignment alignment, DeclarationPadding padding, uint32_t size, std::string varType, std::string varName, std::string body);
|
||||
void AddDeclarationArray(uint32_t address, DeclarationAlignment alignment, uint32_t size, std::string varType, std::string varName, int arrayItemCnt, std::string body);
|
||||
void AddDeclarationArray(uint32_t address, DeclarationAlignment alignment, DeclarationPadding padding, uint32_t size, std::string varType, std::string varName, int arrayItemCnt, std::string body);
|
||||
void AddDeclarationPlaceholder(uint32_t address);
|
||||
void AddDeclarationPlaceholder(uint32_t address, std::string varName);
|
||||
void AddDeclarationInclude(uint32_t address, std::string includePath, uint32_t size, std::string varType, std::string varName);
|
||||
void AddDeclarationIncludeArray(uint32_t address, std::string includePath, uint32_t size, std::string varType, std::string varName, int arrayItemCnt);
|
||||
std::string GetDeclarationName(uint32_t address);
|
||||
std::string GetDeclarationName(uint32_t address, std::string defaultResult);
|
||||
Declaration* GetDeclaration(uint32_t address);
|
||||
Declaration* GetDeclarationRanged(uint32_t address);
|
||||
bool HasDeclaration(uint32_t address);
|
||||
std::string GetHeaderInclude();
|
||||
void GeneratePlaceholderDeclarations();
|
||||
|
||||
protected:
|
||||
std::vector<uint8_t> rawData;
|
||||
std::string name;
|
||||
std::string basePath;
|
||||
std::string outputPath;
|
||||
std::string sourceOutput;
|
||||
|
||||
ZFile();
|
||||
void ParseXML(ZFileMode mode, tinyxml2::XMLElement* reader, bool placeholderMode);
|
||||
void GenerateSourceFiles(std::string outputDir);
|
||||
void GenerateHLIntermediette();
|
||||
void AddDeclarationDebugChecks(uint32_t address);
|
||||
std::string ProcessDeclarations();
|
||||
std::string ProcessExterns();
|
||||
};
|
110
tools/ZAPD/ZAPD/ZResource.cpp
Normal file
110
tools/ZAPD/ZAPD/ZResource.cpp
Normal file
@ -0,0 +1,110 @@
|
||||
#include "ZResource.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
ZResource::ZResource()
|
||||
{
|
||||
parent = nullptr;
|
||||
name = "";
|
||||
outName = "";
|
||||
relativePath = "";
|
||||
sourceOutput = "";
|
||||
rawData = vector<uint8_t>();
|
||||
rawDataIndex = 0;
|
||||
outputDeclaration = true;
|
||||
arrayCnt = -1;
|
||||
}
|
||||
|
||||
void ZResource::ParseXML(tinyxml2::XMLElement* reader)
|
||||
{
|
||||
name = reader->Attribute("Name");
|
||||
|
||||
if (reader->Attribute("OutName") != nullptr)
|
||||
outName = reader->Attribute("OutName");
|
||||
else
|
||||
outName = name;
|
||||
}
|
||||
|
||||
void ZResource::Save(string outFolder)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ZResource::PreGenSourceFiles()
|
||||
{
|
||||
}
|
||||
|
||||
string ZResource::GetName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
std::string ZResource::GetOutName()
|
||||
{
|
||||
return outName;
|
||||
}
|
||||
|
||||
void ZResource::SetName(string nName)
|
||||
{
|
||||
name = nName;
|
||||
}
|
||||
|
||||
bool ZResource::IsExternalResource()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string ZResource::GetExternalExtension()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
string ZResource::GetRelativePath()
|
||||
{
|
||||
return relativePath;
|
||||
}
|
||||
|
||||
vector<uint8_t> ZResource::GetRawData()
|
||||
{
|
||||
return rawData;
|
||||
}
|
||||
|
||||
int ZResource::GetRawDataIndex()
|
||||
{
|
||||
return rawDataIndex;
|
||||
}
|
||||
|
||||
int ZResource::GetRawDataSize()
|
||||
{
|
||||
return rawData.size();
|
||||
}
|
||||
|
||||
void ZResource::SetRawDataIndex(int value)
|
||||
{
|
||||
rawDataIndex = value;
|
||||
}
|
||||
|
||||
string ZResource::GetSourceOutputCode(std::string prefix)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
string ZResource::GetSourceOutputHeader(std::string prefix)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
void ZResource::GenerateHLIntermediette(HLFileIntermediette& hlFile)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
ZResourceType ZResource::GetResourceType()
|
||||
{
|
||||
return ZResourceType::Error;
|
||||
}
|
||||
|
||||
void ZResource::CalcHash()
|
||||
{
|
||||
hash = 0;
|
||||
}
|
118
tools/ZAPD/ZAPD/ZResource.h
Normal file
118
tools/ZAPD/ZAPD/ZResource.h
Normal file
@ -0,0 +1,118 @@
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <stdint.h>
|
||||
#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 SEG2FILESPACE(x) (x & 0x00FFFFFF)
|
||||
#define GETSEGNUM(x) ((x >> 24) & 0xFF)
|
||||
|
||||
class ZFile;
|
||||
class HLFileIntermediette;
|
||||
|
||||
class Declaration;
|
||||
struct CommandSet;
|
||||
|
||||
enum class ZResourceType
|
||||
{
|
||||
Error,
|
||||
Texture,
|
||||
DisplayList,
|
||||
Room,
|
||||
Overlay,
|
||||
Animation,
|
||||
Cutscene,
|
||||
Blob,
|
||||
Limb,
|
||||
Skeleton
|
||||
};
|
||||
|
||||
class ZResource
|
||||
{
|
||||
public:
|
||||
ZFile* parent;
|
||||
bool outputDeclaration;
|
||||
int arrayCnt;
|
||||
|
||||
ZResource();
|
||||
virtual void ParseXML(tinyxml2::XMLElement* reader);
|
||||
virtual void Save(std::string outFolder);
|
||||
virtual void PreGenSourceFiles();
|
||||
std::string GetName();
|
||||
std::string GetOutName();
|
||||
void SetName(std::string nName);
|
||||
std::string GetRelativePath();
|
||||
virtual std::vector<uint8_t> GetRawData();
|
||||
virtual bool IsExternalResource();
|
||||
virtual std::string GetExternalExtension();
|
||||
virtual int GetRawDataIndex();
|
||||
virtual int GetRawDataSize();
|
||||
virtual void SetRawDataIndex(int value);
|
||||
virtual std::string GetSourceOutputCode(std::string prefix);
|
||||
virtual std::string GetSourceOutputHeader(std::string prefix);
|
||||
virtual void GenerateHLIntermediette(HLFileIntermediette& hlFile);
|
||||
virtual ZResourceType GetResourceType();
|
||||
virtual void CalcHash();
|
||||
|
||||
protected:
|
||||
std::string name;
|
||||
std::string outName;
|
||||
std::string relativePath;
|
||||
std::vector<uint8_t> rawData;
|
||||
int rawDataIndex;
|
||||
std::string sourceOutput;
|
||||
uint64_t hash;
|
||||
};
|
||||
|
||||
enum class DeclarationAlignment
|
||||
{
|
||||
None,
|
||||
Align4,
|
||||
Align8,
|
||||
Align16
|
||||
};
|
||||
|
||||
enum class DeclarationPadding
|
||||
{
|
||||
None,
|
||||
Pad4,
|
||||
Pad8,
|
||||
Pad16
|
||||
};
|
||||
|
||||
class Declaration
|
||||
{
|
||||
public:
|
||||
DeclarationAlignment alignment;
|
||||
DeclarationPadding padding;
|
||||
uint32_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;
|
||||
bool isArray;
|
||||
int arrayItemCnt;
|
||||
|
||||
Declaration(DeclarationAlignment nAlignment, uint32_t nSize, std::string nVarType, std::string nVarName, bool nIsArray, std::string nText);
|
||||
Declaration(DeclarationAlignment nAlignment, DeclarationPadding nPadding, uint32_t nSize, std::string nVarType, std::string nVarName, bool nIsArray, std::string nText);
|
||||
Declaration(DeclarationAlignment nAlignment, uint32_t nSize, std::string nVarType, std::string nVarName, bool nIsArray, int nArrayItemCnt, std::string nText);
|
||||
Declaration(DeclarationAlignment nAlignment, DeclarationPadding nPadding, uint32_t nSize, std::string nVarType, std::string nVarName, bool nIsArray, int nArrayItemCnt, std::string nText);
|
||||
Declaration(std::string nIncludePath, uint32_t nSize, std::string nVarType, std::string nVarName);
|
||||
|
||||
protected:
|
||||
Declaration(DeclarationAlignment nAlignment, DeclarationPadding nPadding, uint32_t nSize, std::string nText);
|
||||
};
|
478
tools/ZAPD/ZAPD/ZRoom/ActorList.h
Normal file
478
tools/ZAPD/ZAPD/ZRoom/ActorList.h
Normal file
@ -0,0 +1,478 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
static const std::string ActorList[] =
|
||||
{
|
||||
"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_0109",
|
||||
"ACTOR_ARROW_FIRE",
|
||||
"ACTOR_ARROW_ICE",
|
||||
"ACTOR_ARROW_LIGHT",
|
||||
"ACTOR_UNSET_010D",
|
||||
"ACTOR_UNSET_010E",
|
||||
"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_0128",
|
||||
"ACTOR_UNSET_0129",
|
||||
"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_0134",
|
||||
"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_0154",
|
||||
"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_015D",
|
||||
"ACTOR_EN_GANON_ORGAN",
|
||||
"ACTOR_EN_SIOFUKI",
|
||||
"ACTOR_EN_STREAM",
|
||||
"ACTOR_UNSET_0161",
|
||||
"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_0180",
|
||||
"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_01A9",
|
||||
"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",
|
||||
};
|
23
tools/ZAPD/ZAPD/ZRoom/Commands/EndMarker.cpp
Normal file
23
tools/ZAPD/ZAPD/ZRoom/Commands/EndMarker.cpp
Normal file
@ -0,0 +1,23 @@
|
||||
#include "EndMarker.h"
|
||||
#include "../../StringHelper.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
EndMarker::EndMarker(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex) : ZRoomCommand(nZRoom, rawData, rawDataIndex)
|
||||
{
|
||||
}
|
||||
|
||||
string EndMarker::GenerateSourceCodePass1(string roomName, int baseAddress)
|
||||
{
|
||||
return StringHelper::Sprintf("%s 0x00, 0x00", ZRoomCommand::GenerateSourceCodePass1(roomName, baseAddress).c_str());
|
||||
}
|
||||
|
||||
string EndMarker::GetCommandCName()
|
||||
{
|
||||
return "SCmdEndMarker";
|
||||
}
|
||||
|
||||
RoomCommand EndMarker::GetRoomCommand()
|
||||
{
|
||||
return RoomCommand::EndMarker;
|
||||
}
|
15
tools/ZAPD/ZAPD/ZRoom/Commands/EndMarker.h
Normal file
15
tools/ZAPD/ZAPD/ZRoom/Commands/EndMarker.h
Normal file
@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include "../ZRoomCommand.h"
|
||||
|
||||
class EndMarker : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
EndMarker(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, int baseAddress);
|
||||
virtual std::string GetCommandCName();
|
||||
virtual RoomCommand GetRoomCommand();
|
||||
|
||||
private:
|
||||
};
|
107
tools/ZAPD/ZAPD/ZRoom/Commands/SetActorList.cpp
Normal file
107
tools/ZAPD/ZAPD/ZRoom/Commands/SetActorList.cpp
Normal file
@ -0,0 +1,107 @@
|
||||
#include "SetActorList.h"
|
||||
#include "../../ZFile.h"
|
||||
#include "../ZRoom.h"
|
||||
#include "../ActorList.h"
|
||||
#include "../../BitConverter.h"
|
||||
#include "../../StringHelper.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
SetActorList::SetActorList(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex) : ZRoomCommand(nZRoom, rawData, rawDataIndex)
|
||||
{
|
||||
numActors = rawData[rawDataIndex + 1];
|
||||
segmentOffset = SEG2FILESPACE(BitConverter::ToInt32BE(rawData, rawDataIndex + 4));
|
||||
|
||||
_rawData = rawData;
|
||||
_rawDataIndex = rawDataIndex;
|
||||
|
||||
if (segmentOffset != 0)
|
||||
zRoom->parent->AddDeclarationPlaceholder(segmentOffset);
|
||||
}
|
||||
|
||||
string SetActorList::GetSourceOutputCode(std::string prefix)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
string SetActorList::GenerateSourceCodePass1(string roomName, int baseAddress)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
string SetActorList::GenerateSourceCodePass2(string roomName, int baseAddress)
|
||||
{
|
||||
string sourceOutput = "";
|
||||
int numActorsReal = zRoom->GetDeclarationSizeFromNeighbor(segmentOffset) / 16;
|
||||
actors = vector<ActorSpawnEntry*>();
|
||||
uint32_t currentPtr = segmentOffset;
|
||||
|
||||
for (int i = 0; i < numActorsReal; i++)
|
||||
{
|
||||
ActorSpawnEntry* entry = new ActorSpawnEntry(_rawData, currentPtr);
|
||||
actors.push_back(entry);
|
||||
|
||||
currentPtr += 16;
|
||||
}
|
||||
|
||||
sourceOutput += StringHelper::Sprintf("%s 0x%02X, (u32)%sActorList0x%06X };", ZRoomCommand::GenerateSourceCodePass1(roomName, baseAddress).c_str(), numActors, roomName.c_str(), segmentOffset);
|
||||
|
||||
//zRoom->parent->AddDeclaration(segmentOffset, DeclarationAlignment::None, DeclarationPadding::None, GetRawDataSize(),
|
||||
//"SCmdActorList", ZRoomCommand::GenerateSourceCodePass1(roomName, baseAddress), sourceOutput);
|
||||
|
||||
string declaration = "";
|
||||
|
||||
int index = 0;
|
||||
for (ActorSpawnEntry* entry : actors)
|
||||
{
|
||||
if (entry->actorNum < sizeof(ActorList) / sizeof(ActorList[0]))
|
||||
declaration += StringHelper::Sprintf("\t{ %s, %i, %i, %i, %i, %i, %i, 0x%04X }, //0x%06X", ActorList[entry->actorNum].c_str(), entry->posX, entry->posY, entry->posZ, entry->rotX, entry->rotY, entry->rotZ, (uint16_t)entry->initVar, segmentOffset + (index * 16));
|
||||
else
|
||||
declaration += StringHelper::Sprintf("\t{ 0x%04X, %i, %i, %i, %i, %i, %i, 0x%04X }, //0x%06X", entry->actorNum, entry->posX, entry->posY, entry->posZ, entry->rotX, entry->rotY, entry->rotZ, (uint16_t)entry->initVar, segmentOffset + (index * 16));
|
||||
|
||||
if (index < actors.size() - 1)
|
||||
declaration += "\n";
|
||||
|
||||
index++;
|
||||
}
|
||||
|
||||
zRoom->parent->AddDeclarationArray(segmentOffset, DeclarationAlignment::None, DeclarationPadding::Pad16, actors.size() * 16,
|
||||
"ActorEntry", StringHelper::Sprintf("%sActorList0x%06X", roomName.c_str(), segmentOffset), actors.size(), declaration);
|
||||
|
||||
return sourceOutput;
|
||||
}
|
||||
|
||||
int32_t SetActorList::GetRawDataSize()
|
||||
{
|
||||
return ZRoomCommand::GetRawDataSize() + ((int)actors.size() * 16);
|
||||
}
|
||||
|
||||
string SetActorList::GenerateExterns()
|
||||
{
|
||||
return StringHelper::Sprintf("extern ActorEntry %sActorList0x%06X[%i];\n", zRoom->GetName().c_str(), segmentOffset, (int)actors.size());
|
||||
}
|
||||
|
||||
string SetActorList::GetCommandCName()
|
||||
{
|
||||
return "SCmdActorList";
|
||||
}
|
||||
|
||||
RoomCommand SetActorList::GetRoomCommand()
|
||||
{
|
||||
return RoomCommand::SetActorList;
|
||||
}
|
||||
|
||||
ActorSpawnEntry::ActorSpawnEntry(std::vector<uint8_t> rawData, int rawDataIndex)
|
||||
{
|
||||
uint8_t* data = rawData.data();
|
||||
|
||||
actorNum = BitConverter::ToInt16BE(data, rawDataIndex + 0);
|
||||
posX = BitConverter::ToInt16BE(data, rawDataIndex + 2);
|
||||
posY = BitConverter::ToInt16BE(data, rawDataIndex + 4);
|
||||
posZ = BitConverter::ToInt16BE(data, rawDataIndex + 6);
|
||||
rotX = BitConverter::ToInt16BE(data, rawDataIndex + 8);
|
||||
rotY = BitConverter::ToInt16BE(data, rawDataIndex + 10);
|
||||
rotZ = BitConverter::ToInt16BE(data, rawDataIndex + 12);
|
||||
initVar = BitConverter::ToInt16BE(data, rawDataIndex + 14);
|
||||
}
|
39
tools/ZAPD/ZAPD/ZRoom/Commands/SetActorList.h
Normal file
39
tools/ZAPD/ZAPD/ZRoom/Commands/SetActorList.h
Normal file
@ -0,0 +1,39 @@
|
||||
#pragma once
|
||||
|
||||
#include "../ZRoomCommand.h"
|
||||
|
||||
class ActorSpawnEntry
|
||||
{
|
||||
public:
|
||||
uint16_t actorNum;
|
||||
int16_t posX;
|
||||
int16_t posY;
|
||||
int16_t posZ;
|
||||
int16_t rotX;
|
||||
int16_t rotY;
|
||||
int16_t rotZ;
|
||||
uint16_t initVar;
|
||||
|
||||
ActorSpawnEntry(std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
};
|
||||
|
||||
class SetActorList : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
SetActorList(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
|
||||
std::string GetSourceOutputCode(std::string prefix);
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, int baseAddress);
|
||||
virtual std::string GenerateSourceCodePass2(std::string roomName, int baseAddress);
|
||||
virtual RoomCommand GetRoomCommand();
|
||||
virtual int32_t GetRawDataSize();
|
||||
virtual std::string GetCommandCName();
|
||||
virtual std::string GenerateExterns();
|
||||
|
||||
private:
|
||||
int numActors;
|
||||
std::vector<ActorSpawnEntry*> actors;
|
||||
uint32_t segmentOffset;
|
||||
std::vector<uint8_t> _rawData;
|
||||
int _rawDataIndex;
|
||||
};
|
66
tools/ZAPD/ZAPD/ZRoom/Commands/SetAlternateHeaders.cpp
Normal file
66
tools/ZAPD/ZAPD/ZRoom/Commands/SetAlternateHeaders.cpp
Normal file
@ -0,0 +1,66 @@
|
||||
#include "SetAlternateHeaders.h"
|
||||
#include "../../ZFile.h"
|
||||
#include "../../BitConverter.h"
|
||||
#include "../../StringHelper.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
SetAlternateHeaders::SetAlternateHeaders(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex) : ZRoomCommand(nZRoom, rawData, rawDataIndex)
|
||||
{
|
||||
segmentOffset = SEG2FILESPACE(BitConverter::ToInt32BE(rawData, rawDataIndex + 4));
|
||||
|
||||
if (segmentOffset != 0)
|
||||
zRoom->parent->AddDeclarationPlaceholder(segmentOffset);
|
||||
|
||||
_rawData = rawData;
|
||||
_rawDataIndex = rawDataIndex;
|
||||
}
|
||||
|
||||
string SetAlternateHeaders::GenerateSourceCodePass1(string roomName, int baseAddress)
|
||||
{
|
||||
string sourceOutput = "";
|
||||
int numHeaders = zRoom->GetDeclarationSizeFromNeighbor(segmentOffset) / 4;
|
||||
|
||||
for (int i = 0; i < numHeaders; i++)
|
||||
{
|
||||
int32_t address = BitConverter::ToInt32BE(_rawData, segmentOffset + (i * 4));
|
||||
headers.push_back(address);
|
||||
|
||||
if (address != 0)
|
||||
zRoom->commandSets.push_back(CommandSet(address));
|
||||
}
|
||||
|
||||
sourceOutput += StringHelper::Sprintf("%s 0, (u32)&%sAlternateHeaders0x%06X", ZRoomCommand::GenerateSourceCodePass1(roomName, baseAddress).c_str(), roomName.c_str(), segmentOffset);
|
||||
|
||||
string declaration = "";
|
||||
|
||||
for (int i = 0; i < numHeaders; i++)
|
||||
{
|
||||
//sprintf(line, "\t0x%06X,\n", headers[i]);
|
||||
|
||||
if (headers[i] == 0)
|
||||
declaration += StringHelper::Sprintf("\t0,\n");
|
||||
else
|
||||
declaration += StringHelper::Sprintf("\t(u32)&%sSet%04XCmd00,\n", roomName.c_str(), headers[i] & 0x00FFFFFF);
|
||||
}
|
||||
|
||||
zRoom->parent->declarations[segmentOffset] = new Declaration(DeclarationAlignment::None, headers.size() * 4,
|
||||
"u32", StringHelper::Sprintf("%sAlternateHeaders0x%06X", roomName.c_str(), segmentOffset), true, declaration);
|
||||
|
||||
return sourceOutput;
|
||||
}
|
||||
|
||||
int32_t SetAlternateHeaders::GetRawDataSize()
|
||||
{
|
||||
return ZRoomCommand::GetRawDataSize() + 0;
|
||||
}
|
||||
|
||||
string SetAlternateHeaders::GetCommandCName()
|
||||
{
|
||||
return "SCmdAltHeaders";
|
||||
}
|
||||
|
||||
RoomCommand SetAlternateHeaders::GetRoomCommand()
|
||||
{
|
||||
return RoomCommand::SetAlternateHeaders;
|
||||
}
|
21
tools/ZAPD/ZAPD/ZRoom/Commands/SetAlternateHeaders.h
Normal file
21
tools/ZAPD/ZAPD/ZRoom/Commands/SetAlternateHeaders.h
Normal file
@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include "../ZRoomCommand.h"
|
||||
#include "../ZRoom.h"
|
||||
|
||||
class SetAlternateHeaders : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
SetAlternateHeaders(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, int baseAddress);
|
||||
virtual int32_t GetRawDataSize();
|
||||
virtual std::string GetCommandCName();
|
||||
virtual RoomCommand GetRoomCommand();
|
||||
|
||||
private:
|
||||
int32_t segmentOffset;
|
||||
std::vector<uint32_t> headers;
|
||||
std::vector<uint8_t> _rawData;
|
||||
int _rawDataIndex;
|
||||
};
|
26
tools/ZAPD/ZAPD/ZRoom/Commands/SetCameraSettings.cpp
Normal file
26
tools/ZAPD/ZAPD/ZRoom/Commands/SetCameraSettings.cpp
Normal file
@ -0,0 +1,26 @@
|
||||
#include "SetCameraSettings.h"
|
||||
#include "../../BitConverter.h"
|
||||
#include "../../StringHelper.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
SetCameraSettings::SetCameraSettings(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex) : ZRoomCommand(nZRoom, rawData, rawDataIndex)
|
||||
{
|
||||
cameraMovement = rawData[rawDataIndex + 0x01];
|
||||
mapHighlight = BitConverter::ToInt32BE(rawData, rawDataIndex + 4);
|
||||
}
|
||||
|
||||
string SetCameraSettings::GenerateSourceCodePass1(string roomName, int baseAddress)
|
||||
{
|
||||
return StringHelper::Sprintf("%s 0x%02X, 0x%08X", ZRoomCommand::GenerateSourceCodePass1(roomName, baseAddress).c_str(), cameraMovement, mapHighlight);
|
||||
}
|
||||
|
||||
string SetCameraSettings::GetCommandCName()
|
||||
{
|
||||
return "SCmdMiscSettings";
|
||||
}
|
||||
|
||||
RoomCommand SetCameraSettings::GetRoomCommand()
|
||||
{
|
||||
return RoomCommand::SetCameraSettings;
|
||||
}
|
17
tools/ZAPD/ZAPD/ZRoom/Commands/SetCameraSettings.h
Normal file
17
tools/ZAPD/ZAPD/ZRoom/Commands/SetCameraSettings.h
Normal file
@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include "../ZRoomCommand.h"
|
||||
|
||||
class SetCameraSettings : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
SetCameraSettings(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, int baseAddress);
|
||||
virtual std::string GetCommandCName();
|
||||
virtual RoomCommand GetRoomCommand();
|
||||
|
||||
private:
|
||||
uint8_t cameraMovement;
|
||||
uint32_t mapHighlight;
|
||||
};
|
38
tools/ZAPD/ZAPD/ZRoom/Commands/SetCollisionHeader.cpp
Normal file
38
tools/ZAPD/ZAPD/ZRoom/Commands/SetCollisionHeader.cpp
Normal file
@ -0,0 +1,38 @@
|
||||
#include "SetCollisionHeader.h"
|
||||
#include "../ZRoom.h"
|
||||
#include "../../ZFile.h"
|
||||
#include "../../BitConverter.h"
|
||||
#include "../../StringHelper.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
SetCollisionHeader::SetCollisionHeader(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex) : ZRoomCommand(nZRoom, rawData, rawDataIndex)
|
||||
{
|
||||
segmentOffset = SEG2FILESPACE(BitConverter::ToInt32BE(rawData, rawDataIndex + 4));
|
||||
collisionHeader = ZCollisionHeader(nZRoom->parent, StringHelper::Sprintf("%sCollisionHeader0x%06X", nZRoom->GetName().c_str(), segmentOffset), rawData, segmentOffset);
|
||||
}
|
||||
|
||||
string SetCollisionHeader::GenerateSourceCodePass1(string roomName, int baseAddress)
|
||||
{
|
||||
return StringHelper::Sprintf("%s 0x00, (u32)&%sCollisionHeader0x%06X", ZRoomCommand::GenerateSourceCodePass1(roomName, baseAddress).c_str(), zRoom->GetName().c_str(), segmentOffset);
|
||||
}
|
||||
|
||||
string SetCollisionHeader::GenerateSourceCodePass2(string roomName, int baseAddress)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
string SetCollisionHeader::GetCommandCName()
|
||||
{
|
||||
return "SCmdColHeader";
|
||||
}
|
||||
|
||||
string SetCollisionHeader::GenerateExterns()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
RoomCommand SetCollisionHeader::GetRoomCommand()
|
||||
{
|
||||
return RoomCommand::SetCollisionHeader;
|
||||
}
|
20
tools/ZAPD/ZAPD/ZRoom/Commands/SetCollisionHeader.h
Normal file
20
tools/ZAPD/ZAPD/ZRoom/Commands/SetCollisionHeader.h
Normal file
@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include "../ZRoomCommand.h"
|
||||
#include "../../ZCollision.h"
|
||||
|
||||
class SetCollisionHeader : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
SetCollisionHeader(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, int baseAddress);
|
||||
virtual std::string GenerateSourceCodePass2(std::string roomName, int baseAddress);
|
||||
virtual std::string GetCommandCName();
|
||||
virtual std::string GenerateExterns();
|
||||
virtual RoomCommand GetRoomCommand();
|
||||
|
||||
private:
|
||||
ZCollisionHeader collisionHeader;
|
||||
uint32_t segmentOffset;
|
||||
};
|
53
tools/ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.cpp
Normal file
53
tools/ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.cpp
Normal file
@ -0,0 +1,53 @@
|
||||
#include "SetCutscenes.h"
|
||||
#include "../ZRoom.h"
|
||||
#include "../../ZFile.h"
|
||||
#include "../../BitConverter.h"
|
||||
#include "../../StringHelper.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
SetCutscenes::SetCutscenes(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex) : ZRoomCommand(nZRoom, rawData, rawDataIndex)
|
||||
{
|
||||
segmentOffset = BitConverter::ToInt32BE(rawData, rawDataIndex + 4) & 0x00FFFFFF;
|
||||
|
||||
uint32_t curPtr = segmentOffset;
|
||||
string output = "";
|
||||
|
||||
cutscene = new ZCutscene(rawData, segmentOffset, 9999);
|
||||
|
||||
output += cutscene->GetSourceOutputCode(zRoom->GetName());
|
||||
|
||||
if (segmentOffset != 0)
|
||||
zRoom->parent->AddDeclarationArray(segmentOffset, DeclarationAlignment::None, DeclarationPadding::Pad16, cutscene->GetRawDataSize(), "s32",
|
||||
StringHelper::Sprintf("%sCutsceneData0x%06X", zRoom->GetName().c_str(), segmentOffset), 0, output);
|
||||
}
|
||||
|
||||
string SetCutscenes::GenerateSourceCodePass1(string roomName, int baseAddress)
|
||||
{
|
||||
return StringHelper::Sprintf("%s 0, (u32)%sCutsceneData0x%06X", ZRoomCommand::GenerateSourceCodePass1(roomName, baseAddress).c_str(), zRoom->GetName().c_str(), segmentOffset);
|
||||
}
|
||||
|
||||
int32_t SetCutscenes::GetRawDataSize()
|
||||
{
|
||||
return ZRoomCommand::GetRawDataSize() + (0);
|
||||
}
|
||||
|
||||
string SetCutscenes::GenerateExterns()
|
||||
{
|
||||
return StringHelper::Sprintf("extern s32 %sCutsceneData0x%06X[];\n", zRoom->GetName().c_str(), segmentOffset);
|
||||
}
|
||||
|
||||
string SetCutscenes::GetCommandCName()
|
||||
{
|
||||
return "SCmdCutsceneData";
|
||||
}
|
||||
|
||||
RoomCommand SetCutscenes::GetRoomCommand()
|
||||
{
|
||||
return RoomCommand::SetCutscenes;
|
||||
}
|
||||
|
||||
string SetCutscenes::GetSourceOutputCode(std::string prefix)
|
||||
{
|
||||
return "";
|
||||
}
|
23
tools/ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.h
Normal file
23
tools/ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.h
Normal file
@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#include "../ZRoomCommand.h"
|
||||
#include "../../ZCutscene.h"
|
||||
|
||||
class SetCutscenes : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
SetCutscenes(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
|
||||
std::string GetSourceOutputCode(std::string prefix);
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, int baseAddress);
|
||||
virtual RoomCommand GetRoomCommand();
|
||||
virtual int32_t GetRawDataSize();
|
||||
virtual std::string GetCommandCName();
|
||||
virtual std::string GenerateExterns();
|
||||
|
||||
private:
|
||||
ZCutscene* cutscene;
|
||||
uint32_t segmentOffset;
|
||||
std::vector<uint8_t> _rawData;
|
||||
int _rawDataIndex;
|
||||
};
|
24
tools/ZAPD/ZAPD/ZRoom/Commands/SetEchoSettings.cpp
Normal file
24
tools/ZAPD/ZAPD/ZRoom/Commands/SetEchoSettings.cpp
Normal file
@ -0,0 +1,24 @@
|
||||
#include "SetEchoSettings.h"
|
||||
#include "../../StringHelper.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
SetEchoSettings::SetEchoSettings(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex) : ZRoomCommand(nZRoom, rawData, rawDataIndex)
|
||||
{
|
||||
echo = rawData[rawDataIndex + 0x07];
|
||||
}
|
||||
|
||||
string SetEchoSettings::GenerateSourceCodePass1(string roomName, int baseAddress)
|
||||
{
|
||||
return StringHelper::Sprintf("%s 0, { 0 }, 0x%02X", ZRoomCommand::GenerateSourceCodePass1(roomName, baseAddress).c_str(), echo);
|
||||
}
|
||||
|
||||
string SetEchoSettings::GetCommandCName()
|
||||
{
|
||||
return "SCmdEchoSettings";
|
||||
}
|
||||
|
||||
RoomCommand SetEchoSettings::GetRoomCommand()
|
||||
{
|
||||
return RoomCommand::SetEchoSettings;
|
||||
}
|
16
tools/ZAPD/ZAPD/ZRoom/Commands/SetEchoSettings.h
Normal file
16
tools/ZAPD/ZAPD/ZRoom/Commands/SetEchoSettings.h
Normal file
@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include "../ZRoomCommand.h"
|
||||
|
||||
class SetEchoSettings : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
SetEchoSettings(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, int baseAddress);
|
||||
virtual std::string GetCommandCName();
|
||||
virtual RoomCommand GetRoomCommand();
|
||||
|
||||
private:
|
||||
uint8_t echo;
|
||||
};
|
71
tools/ZAPD/ZAPD/ZRoom/Commands/SetEntranceList.cpp
Normal file
71
tools/ZAPD/ZAPD/ZRoom/Commands/SetEntranceList.cpp
Normal file
@ -0,0 +1,71 @@
|
||||
#include "SetEntranceList.h"
|
||||
#include "SetStartPositionList.h"
|
||||
#include "../../ZFile.h"
|
||||
#include "../ZRoom.h"
|
||||
#include "../../BitConverter.h"
|
||||
#include "../../StringHelper.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
SetEntranceList::SetEntranceList(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex) : ZRoomCommand(nZRoom, rawData, rawDataIndex)
|
||||
{
|
||||
segmentOffset = BitConverter::ToInt32BE(rawData, rawDataIndex + 4) & 0x00FFFFFF;
|
||||
entrances = vector<EntranceEntry*>();
|
||||
|
||||
_rawData = rawData;
|
||||
_rawDataIndex = rawDataIndex;
|
||||
}
|
||||
|
||||
string SetEntranceList::GenerateSourceCodePass1(string roomName, int baseAddress)
|
||||
{
|
||||
string sourceOutput = StringHelper::Sprintf("%s 0x00, (u32)&%sEntranceList0x%06X", ZRoomCommand::GenerateSourceCodePass1(roomName, baseAddress).c_str(), zRoom->GetName().c_str(), segmentOffset);
|
||||
|
||||
// Parse Entrances and Generate Declaration
|
||||
zRoom->parent->AddDeclarationPlaceholder(segmentOffset); // Make sure this segment is defined
|
||||
int numEntrances = zRoom->GetDeclarationSizeFromNeighbor(segmentOffset) / 2;
|
||||
uint32_t currentPtr = segmentOffset;
|
||||
|
||||
for (int i = 0; i < numEntrances; i++)
|
||||
{
|
||||
EntranceEntry* entry = new EntranceEntry(_rawData, currentPtr);
|
||||
entrances.push_back(entry);
|
||||
|
||||
currentPtr += 2;
|
||||
}
|
||||
|
||||
string declaration = "";
|
||||
|
||||
int index = 0;
|
||||
|
||||
for (EntranceEntry* entry : entrances)
|
||||
{
|
||||
declaration += StringHelper::Sprintf("\t{ 0x%02X, 0x%02X }, //0x%06X \n", entry->startPositionIndex, entry->roomToLoad, segmentOffset + (index * 2));
|
||||
index++;
|
||||
}
|
||||
|
||||
zRoom->parent->AddDeclarationArray(segmentOffset, DeclarationAlignment::None, entrances.size() * 2, "EntranceEntry",
|
||||
StringHelper::Sprintf("%sEntranceList0x%06X", zRoom->GetName().c_str(), segmentOffset), entrances.size(), declaration);
|
||||
|
||||
return sourceOutput;
|
||||
}
|
||||
|
||||
string SetEntranceList::GenerateExterns()
|
||||
{
|
||||
return StringHelper::Sprintf("extern EntranceEntry %sEntranceList0x%06X[];\n", zRoom->GetName().c_str(), segmentOffset);
|
||||
}
|
||||
|
||||
string SetEntranceList::GetCommandCName()
|
||||
{
|
||||
return "SCmdEntranceList";
|
||||
}
|
||||
|
||||
RoomCommand SetEntranceList::GetRoomCommand()
|
||||
{
|
||||
return RoomCommand::SetEntranceList;
|
||||
}
|
||||
|
||||
EntranceEntry::EntranceEntry(std::vector<uint8_t> rawData, int rawDataIndex)
|
||||
{
|
||||
startPositionIndex = rawData[rawDataIndex + 0];
|
||||
roomToLoad = rawData[rawDataIndex + 1];
|
||||
}
|
29
tools/ZAPD/ZAPD/ZRoom/Commands/SetEntranceList.h
Normal file
29
tools/ZAPD/ZAPD/ZRoom/Commands/SetEntranceList.h
Normal file
@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include "../ZRoomCommand.h"
|
||||
|
||||
class EntranceEntry
|
||||
{
|
||||
public:
|
||||
uint8_t startPositionIndex;
|
||||
uint8_t roomToLoad;
|
||||
|
||||
EntranceEntry(std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
};
|
||||
|
||||
class SetEntranceList : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
SetEntranceList(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, int baseAddress);
|
||||
virtual std::string GenerateExterns();
|
||||
virtual std::string GetCommandCName();
|
||||
virtual RoomCommand GetRoomCommand();
|
||||
|
||||
private:
|
||||
std::vector<EntranceEntry*> entrances;
|
||||
uint32_t segmentOffset;
|
||||
std::vector<uint8_t> _rawData;
|
||||
int32_t _rawDataIndex;
|
||||
};
|
62
tools/ZAPD/ZAPD/ZRoom/Commands/SetExitList.cpp
Normal file
62
tools/ZAPD/ZAPD/ZRoom/Commands/SetExitList.cpp
Normal file
@ -0,0 +1,62 @@
|
||||
#include "SetExitList.h"
|
||||
#include "../ZRoom.h"
|
||||
#include "../../ZFile.h"
|
||||
#include "../../BitConverter.h"
|
||||
#include "../../StringHelper.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
SetExitList::SetExitList(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex) : ZRoomCommand(nZRoom, rawData, rawDataIndex)
|
||||
{
|
||||
segmentOffset = SEG2FILESPACE(BitConverter::ToInt32BE(rawData, rawDataIndex + 4));
|
||||
exits = vector<uint16_t>();
|
||||
|
||||
if (segmentOffset != 0)
|
||||
zRoom->parent->AddDeclarationPlaceholder(segmentOffset);
|
||||
|
||||
_rawData = rawData;
|
||||
_rawDataIndex = rawDataIndex;
|
||||
}
|
||||
|
||||
string SetExitList::GenerateSourceCodePass1(string roomName, int baseAddress)
|
||||
{
|
||||
string sourceOutput = StringHelper::Sprintf("%s 0x00, (u32)&%sExitList0x%06X", ZRoomCommand::GenerateSourceCodePass1(roomName, baseAddress).c_str(), zRoom->GetName().c_str(), segmentOffset);
|
||||
|
||||
// Parse Entrances and Generate Declaration
|
||||
zRoom->parent->AddDeclarationPlaceholder(segmentOffset); // Make sure this segment is defined
|
||||
int numEntrances = zRoom->GetDeclarationSizeFromNeighbor(segmentOffset) / 2;
|
||||
uint32_t currentPtr = segmentOffset;
|
||||
|
||||
for (int i = 0; i < numEntrances; i++)
|
||||
{
|
||||
uint16_t exit = BitConverter::ToInt16BE(_rawData, currentPtr);
|
||||
exits.push_back(exit);
|
||||
|
||||
currentPtr += 2;
|
||||
}
|
||||
|
||||
string declaration = "";
|
||||
|
||||
for (uint16_t exit : exits)
|
||||
declaration += StringHelper::Sprintf("\t0x%04X,\n", exit);;
|
||||
|
||||
zRoom->parent->AddDeclarationArray(segmentOffset, DeclarationAlignment::None, exits.size() * 2, "u16", StringHelper::Sprintf("%sExitList0x%06X", zRoom->GetName().c_str(), segmentOffset),
|
||||
exits.size(), declaration);
|
||||
|
||||
return sourceOutput;
|
||||
}
|
||||
|
||||
string SetExitList::GenerateExterns()
|
||||
{
|
||||
return StringHelper::Sprintf("extern u16 %sExitList0x%06X[];\n", zRoom->GetName().c_str(), segmentOffset);;
|
||||
}
|
||||
|
||||
string SetExitList::GetCommandCName()
|
||||
{
|
||||
return "SCmdExitList";
|
||||
}
|
||||
|
||||
RoomCommand SetExitList::GetRoomCommand()
|
||||
{
|
||||
return RoomCommand::SetExitList;
|
||||
}
|
20
tools/ZAPD/ZAPD/ZRoom/Commands/SetExitList.h
Normal file
20
tools/ZAPD/ZAPD/ZRoom/Commands/SetExitList.h
Normal file
@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include "../ZRoomCommand.h"
|
||||
|
||||
class SetExitList : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
SetExitList(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, int baseAddress);
|
||||
virtual std::string GenerateExterns();
|
||||
virtual std::string GetCommandCName();
|
||||
virtual RoomCommand GetRoomCommand();
|
||||
|
||||
private:
|
||||
std::vector<uint16_t> exits;
|
||||
uint32_t segmentOffset;
|
||||
std::vector<uint8_t> _rawData;
|
||||
int32_t _rawDataIndex;
|
||||
};
|
53
tools/ZAPD/ZAPD/ZRoom/Commands/SetLightList.cpp
Normal file
53
tools/ZAPD/ZAPD/ZRoom/Commands/SetLightList.cpp
Normal file
@ -0,0 +1,53 @@
|
||||
#include "SetLightList.h"
|
||||
#include "../../BitConverter.h"
|
||||
#include "../../StringHelper.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
SetLightList::SetLightList(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex) : ZRoomCommand(nZRoom, rawData, rawDataIndex)
|
||||
{
|
||||
this->ptrRoom = nZRoom;
|
||||
this->numLights = rawData[rawDataIndex + 1];
|
||||
this->segment = BitConverter::ToInt32BE(rawData, rawDataIndex + 4) & 0x00FFFFFF;
|
||||
|
||||
//std::string declarations = StringHelper::Sprintf("LightInfo %sLightInfo0x%06X[] =\n{\n", this->ptrRoom->GetName().c_str(), this->segment);
|
||||
string declarations = "";
|
||||
|
||||
for (int i = 0; i < this->numLights; i++)
|
||||
{
|
||||
uint8_t type = rawData[this->segment + ((0xE * i) + 0)];
|
||||
std::vector<uint16_t> params;
|
||||
|
||||
for (int y = 0; y < 6; y++)
|
||||
{
|
||||
params.push_back(BitConverter::ToInt16BE(rawData, this->segment + ((0xE * i) + 2 + (y * 2))));
|
||||
}
|
||||
|
||||
declarations += StringHelper::Sprintf("\t{ 0x%02X, { 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X } },\n", type, params[0], params[1], params[2], params[3], params[4], params[5]);
|
||||
}
|
||||
|
||||
declarations += "};\n";
|
||||
|
||||
this->ptrRoom->parent->AddDeclarationArray(this->segment, DeclarationAlignment::None, this->numLights * 0xE, "LightInfo",
|
||||
StringHelper::Sprintf("%sLightInfo0x%06X", this->ptrRoom->GetName().c_str(), this->segment), this->numLights, declarations);
|
||||
}
|
||||
|
||||
string SetLightList::GenerateSourceCodePass1(string roomName, int baseAddress)
|
||||
{
|
||||
return StringHelper::Sprintf("%s %i, &%sLightInfo0x%06X};", ZRoomCommand::GenerateSourceCodePass1(roomName, baseAddress).c_str(), this->numLights, this->ptrRoom->GetName().c_str(), this->segment);
|
||||
}
|
||||
|
||||
string SetLightList::GetCommandCName()
|
||||
{
|
||||
return "SCmdLightList";
|
||||
}
|
||||
|
||||
string SetLightList::GenerateExterns()
|
||||
{
|
||||
return StringHelper::Sprintf("extern LightInfo %sLightInfo0x%06X[];\n", this->ptrRoom->GetName().c_str(), this->segment);
|
||||
}
|
||||
|
||||
RoomCommand SetLightList::GetRoomCommand()
|
||||
{
|
||||
return RoomCommand::SetLightList;
|
||||
}
|
25
tools/ZAPD/ZAPD/ZRoom/Commands/SetLightList.h
Normal file
25
tools/ZAPD/ZAPD/ZRoom/Commands/SetLightList.h
Normal file
@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "ZFile.h"
|
||||
#include "../ZRoom.h"
|
||||
#include "../ZRoomCommand.h"
|
||||
|
||||
class SetLightList : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
SetLightList(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, int baseAddress);
|
||||
virtual std::string GetCommandCName();
|
||||
virtual RoomCommand GetRoomCommand();
|
||||
virtual std::string GenerateExterns();
|
||||
|
||||
private:
|
||||
uint8_t code;
|
||||
uint8_t numLights;
|
||||
uint32_t segment;
|
||||
|
||||
ZRoom* ptrRoom;
|
||||
};
|
93
tools/ZAPD/ZAPD/ZRoom/Commands/SetLightingSettings.cpp
Normal file
93
tools/ZAPD/ZAPD/ZRoom/Commands/SetLightingSettings.cpp
Normal file
@ -0,0 +1,93 @@
|
||||
#include "SetLightingSettings.h"
|
||||
#include "../ZRoom.h"
|
||||
#include "../../ZFile.h"
|
||||
#include "../../BitConverter.h"
|
||||
#include "../../StringHelper.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
SetLightingSettings::SetLightingSettings(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex) : ZRoomCommand(nZRoom, rawData, rawDataIndex)
|
||||
{
|
||||
uint8_t numLights = rawData[rawDataIndex + 1];
|
||||
segmentOffset = SEG2FILESPACE(BitConverter::ToInt32BE(rawData, rawDataIndex + 4));
|
||||
|
||||
for (int i = 0; i < numLights; i++)
|
||||
settings.push_back(new LightingSettings(rawData, segmentOffset + (i * 22)));
|
||||
|
||||
if (numLights > 0)
|
||||
{
|
||||
string declaration = "";
|
||||
|
||||
for (int i = 0; i < numLights; i++)
|
||||
{
|
||||
declaration += StringHelper::Sprintf("\t{ 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 }, // 0x%06X \n",
|
||||
settings[i]->ambientClrR, settings[i]->ambientClrG, settings[i]->ambientClrB,
|
||||
settings[i]->diffuseClrA_R, settings[i]->diffuseClrA_G, settings[i]->diffuseClrA_B,
|
||||
settings[i]->diffuseDirA_X, settings[i]->diffuseDirA_Y, settings[i]->diffuseDirA_Z,
|
||||
settings[i]->diffuseClrB_R, settings[i]->diffuseClrB_G, settings[i]->diffuseClrB_B,
|
||||
settings[i]->diffuseDirB_X, settings[i]->diffuseDirB_Y, settings[i]->diffuseDirB_Z,
|
||||
settings[i]->fogClrR, settings[i]->fogClrG, settings[i]->fogClrB,
|
||||
settings[i]->unk, settings[i]->drawDistance, segmentOffset + (i * 22));
|
||||
}
|
||||
|
||||
zRoom->parent->AddDeclarationArray(segmentOffset, DeclarationAlignment::None, DeclarationPadding::None, numLights * 22, "LightSettings",
|
||||
StringHelper::Sprintf("%sLightSettings0x%06X", zRoom->GetName().c_str(), segmentOffset), numLights, declaration);
|
||||
}
|
||||
}
|
||||
|
||||
string SetLightingSettings::GenerateSourceCodePass1(string roomName, int baseAddress)
|
||||
{
|
||||
return StringHelper::Sprintf("%s %i, (u32)&%sLightSettings0x%06X", ZRoomCommand::GenerateSourceCodePass1(roomName, baseAddress).c_str(), settings.size(), zRoom->GetName().c_str(), segmentOffset);
|
||||
}
|
||||
|
||||
string SetLightingSettings::GenerateSourceCodePass2(string roomName, int baseAddress)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
string SetLightingSettings::GetCommandCName()
|
||||
{
|
||||
return "SCmdLightSettingList";
|
||||
}
|
||||
|
||||
string SetLightingSettings::GenerateExterns()
|
||||
{
|
||||
return StringHelper::Sprintf("extern LightSettings %sLightSettings0x%06X[];\n", zRoom->GetName().c_str(), segmentOffset);
|
||||
}
|
||||
|
||||
RoomCommand SetLightingSettings::GetRoomCommand()
|
||||
{
|
||||
return RoomCommand::SetLightingSettings;
|
||||
}
|
||||
|
||||
LightingSettings::LightingSettings(vector<uint8_t> rawData, int rawDataIndex)
|
||||
{
|
||||
uint8_t* data = rawData.data();
|
||||
|
||||
ambientClrR = data[rawDataIndex + 0];
|
||||
ambientClrG = data[rawDataIndex + 1];
|
||||
ambientClrB = data[rawDataIndex + 2];
|
||||
|
||||
diffuseClrA_R = data[rawDataIndex + 3];
|
||||
diffuseClrA_G = data[rawDataIndex + 4];
|
||||
diffuseClrA_B = data[rawDataIndex + 5];
|
||||
|
||||
diffuseDirA_X = data[rawDataIndex + 6];
|
||||
diffuseDirA_Y = data[rawDataIndex + 7];
|
||||
diffuseDirA_Z = data[rawDataIndex + 8];
|
||||
|
||||
diffuseClrB_R = data[rawDataIndex + 9];
|
||||
diffuseClrB_G = data[rawDataIndex + 10];
|
||||
diffuseClrB_B = data[rawDataIndex + 11];
|
||||
|
||||
diffuseDirB_X = data[rawDataIndex + 12];
|
||||
diffuseDirB_Y = data[rawDataIndex + 13];
|
||||
diffuseDirB_Z = data[rawDataIndex + 14];
|
||||
|
||||
fogClrR = data[rawDataIndex + 15];
|
||||
fogClrG = data[rawDataIndex + 16];
|
||||
fogClrB = data[rawDataIndex + 17];
|
||||
|
||||
unk = BitConverter::ToInt16BE(data, rawDataIndex + 18);
|
||||
drawDistance = BitConverter::ToInt16BE(data, rawDataIndex + 20);
|
||||
}
|
34
tools/ZAPD/ZAPD/ZRoom/Commands/SetLightingSettings.h
Normal file
34
tools/ZAPD/ZAPD/ZRoom/Commands/SetLightingSettings.h
Normal file
@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
|
||||
#include "../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(std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
};
|
||||
|
||||
class SetLightingSettings : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
SetLightingSettings(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, int baseAddress);
|
||||
virtual std::string GenerateSourceCodePass2(std::string roomName, int baseAddress);
|
||||
virtual std::string GetCommandCName();
|
||||
virtual std::string GenerateExterns();
|
||||
virtual RoomCommand GetRoomCommand();
|
||||
|
||||
private:
|
||||
uint32_t segmentOffset;
|
||||
std::vector<LightingSettings*> settings;
|
||||
};
|
443
tools/ZAPD/ZAPD/ZRoom/Commands/SetMesh.cpp
Normal file
443
tools/ZAPD/ZAPD/ZRoom/Commands/SetMesh.cpp
Normal file
@ -0,0 +1,443 @@
|
||||
#include "SetMesh.h"
|
||||
#include "../../ZFile.h"
|
||||
#include "../ZRoom.h"
|
||||
#include "../../BitConverter.h"
|
||||
#include "../../StringHelper.h"
|
||||
#include <Path.h>
|
||||
#include <Globals.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
SetMesh::SetMesh(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex, int segAddressOffset) : ZRoomCommand(nZRoom, rawData, rawDataIndex)
|
||||
{
|
||||
data = rawData[rawDataIndex + 1];
|
||||
segmentOffset = SEG2FILESPACE(BitConverter::ToInt32BE(rawData, rawDataIndex + 4));
|
||||
|
||||
string declaration = "";
|
||||
char line[2048];
|
||||
|
||||
int8_t meshHeaderType = rawData[segmentOffset + 0];
|
||||
|
||||
if (meshHeaderType == 0)
|
||||
{
|
||||
MeshHeader0* meshHeader0 = new MeshHeader0();
|
||||
meshHeader0->headerType = 0;
|
||||
meshHeader0->entries = vector<MeshEntry0*>();
|
||||
|
||||
meshHeader0->dListStart = BitConverter::ToInt32BE(rawData, segmentOffset + 4) & 0x00FFFFFF;
|
||||
meshHeader0->dListEnd = BitConverter::ToInt32BE(rawData, segmentOffset + 8) & 0x00FFFFFF;
|
||||
|
||||
int8_t numEntries = rawData[segmentOffset + 1];
|
||||
uint32_t currentPtr = meshHeader0->dListStart;
|
||||
|
||||
// Hack for Syotes
|
||||
for (int i = 0; i < abs(segAddressOffset); i++)
|
||||
{
|
||||
rawData.erase(rawData.begin());
|
||||
segmentOffset--;
|
||||
}
|
||||
|
||||
for (int i = 0; i < numEntries; i++)
|
||||
{
|
||||
MeshEntry0* entry = new MeshEntry0();
|
||||
entry->opaqueDListAddr = BitConverter::ToInt32BE(rawData, currentPtr + 0) & 0x00FFFFFF;
|
||||
entry->translucentDListAddr = BitConverter::ToInt32BE(rawData, currentPtr + 4) & 0x00FFFFFF;
|
||||
|
||||
if (entry->opaqueDListAddr != 0)
|
||||
{
|
||||
entry->opaqueDList = new ZDisplayList(rawData, entry->opaqueDListAddr, ZDisplayList::GetDListLength(rawData, entry->opaqueDListAddr));
|
||||
entry->opaqueDList->scene = zRoom->scene;
|
||||
GenDListDeclarations(rawData, entry->opaqueDList);
|
||||
}
|
||||
|
||||
if (entry->translucentDListAddr != 0)
|
||||
{
|
||||
entry->translucentDList = new ZDisplayList(rawData, entry->translucentDListAddr, ZDisplayList::GetDListLength(rawData, entry->translucentDListAddr));
|
||||
entry->translucentDList->scene = zRoom->scene;
|
||||
GenDListDeclarations(rawData, entry->translucentDList);
|
||||
}
|
||||
|
||||
meshHeader0->entries.push_back(entry);
|
||||
|
||||
currentPtr += 8;
|
||||
}
|
||||
|
||||
//declaration += StringHelper::Sprintf("MeshHeader0 %sMeshHeade0x%06X = { { 0 }, 0x%02X, ", zRoom->GetName().c_str(), segmentOffset, meshHeader0->entries.size());
|
||||
declaration += StringHelper::Sprintf("{ 0 }, 0x%02X, ", meshHeader0->entries.size());
|
||||
|
||||
if (meshHeader0->dListStart != 0)
|
||||
sprintf(line, "(u32)&%sMeshDListEntry0x%06X, ", zRoom->GetName().c_str(), meshHeader0->dListStart);
|
||||
else
|
||||
sprintf(line, "0, ");
|
||||
|
||||
declaration += line;
|
||||
|
||||
if (meshHeader0->dListEnd != 0)
|
||||
sprintf(line, "(u32)&(%sMeshDListEntry0x%06X) + sizeof(%sMeshDListEntry0x%06X)", zRoom->GetName().c_str(), meshHeader0->dListStart, zRoom->GetName().c_str(), meshHeader0->dListStart);
|
||||
else
|
||||
sprintf(line, "0");
|
||||
|
||||
declaration += line;
|
||||
|
||||
zRoom->parent->AddDeclaration(segmentOffset, DeclarationAlignment::Align16, 12, "MeshHeader0", StringHelper::Sprintf("%sMeshHeader0x%06X", zRoom->GetName().c_str(), segmentOffset),
|
||||
declaration);
|
||||
|
||||
declaration = "";
|
||||
|
||||
for (int i = 0; i < meshHeader0->entries.size(); i++)
|
||||
{
|
||||
if (meshHeader0->entries[i]->opaqueDListAddr != 0)
|
||||
sprintf(line, "\t{ (u32)%sDlist0x%06X, ", zRoom->GetName().c_str(), meshHeader0->entries[i]->opaqueDListAddr);
|
||||
else
|
||||
sprintf(line, "\t{ 0, ");
|
||||
|
||||
declaration += line;
|
||||
|
||||
if (meshHeader0->entries[i]->translucentDListAddr != 0)
|
||||
sprintf(line, "(u32)%sDlist0x%06X },\n", zRoom->GetName().c_str(), meshHeader0->entries[i]->translucentDListAddr);
|
||||
else
|
||||
sprintf(line, "0 },\n");
|
||||
|
||||
declaration += line;
|
||||
}
|
||||
|
||||
//declaration += "static u32 terminatorMaybe = 0x01000000; // This always appears after the mesh entries. Its purpose is not clear.\n";
|
||||
|
||||
zRoom->parent->AddDeclarationArray(meshHeader0->dListStart, DeclarationAlignment::None, DeclarationPadding::None, (meshHeader0->entries.size() * 8) + 0, "MeshEntry0",
|
||||
StringHelper::Sprintf("%sMeshDListEntry0x%06X", zRoom->GetName().c_str(), meshHeader0->dListStart), meshHeader0->entries.size(), declaration);
|
||||
|
||||
zRoom->parent->AddDeclaration(meshHeader0->dListStart + (meshHeader0->entries.size() * 8) + 0, DeclarationAlignment::None, DeclarationPadding::Pad16, 4, "static s32",
|
||||
"terminatorMaybe", " 0x01000000 ");
|
||||
|
||||
//zRoom->parent->declarations[meshHeader0->dListStart] = new Declaration(DeclarationAlignment::None, DeclarationPadding::Pad16, (meshHeader0->entries.size() * 8) + 4, declaration);
|
||||
|
||||
meshHeader = meshHeader0;
|
||||
}
|
||||
else if (meshHeaderType == 1)
|
||||
{
|
||||
MeshHeader1Base* meshHeader1 = nullptr;
|
||||
|
||||
uint8_t fmt = rawData[segmentOffset + 1];
|
||||
|
||||
if (fmt == 1) // Single Format
|
||||
{
|
||||
MeshHeader1Single* headerSingle = new MeshHeader1Single();
|
||||
|
||||
headerSingle->headerType = 1;
|
||||
headerSingle->format = fmt;
|
||||
headerSingle->entryRecord = BitConverter::ToInt32BE(rawData, segmentOffset + 4);// &0x00FFFFFF;
|
||||
|
||||
headerSingle->imagePtr = BitConverter::ToInt32BE(rawData, segmentOffset + 8);// &0x00FFFFFF;
|
||||
headerSingle->unknown = BitConverter::ToInt32BE(rawData, segmentOffset + 12);
|
||||
headerSingle->unknown2 = BitConverter::ToInt32BE(rawData, segmentOffset + 16);
|
||||
headerSingle->bgWidth = BitConverter::ToInt16BE(rawData, segmentOffset + 20);
|
||||
headerSingle->bgHeight = BitConverter::ToInt16BE(rawData, segmentOffset + 22);
|
||||
headerSingle->imageFormat = rawData[segmentOffset + 24];
|
||||
headerSingle->imageSize = rawData[segmentOffset + 25];
|
||||
headerSingle->imagePal = BitConverter::ToInt16BE(rawData, segmentOffset + 26);
|
||||
headerSingle->imageFlip = BitConverter::ToInt16BE(rawData, segmentOffset + 28);
|
||||
|
||||
declaration += StringHelper::Sprintf("{ { 1 }, 1, 0x%06X }, 0x%06X, ",
|
||||
headerSingle->entryRecord, headerSingle->imagePtr);
|
||||
|
||||
declaration += StringHelper::Sprintf("0x%06X, 0x%06X, %i, %i, %i, %i, %i, %i\n",
|
||||
headerSingle->unknown, headerSingle->unknown2, headerSingle->bgWidth, headerSingle->bgHeight, headerSingle->imageFormat, headerSingle->imageSize, headerSingle->imagePal, headerSingle->imageFlip);
|
||||
|
||||
zRoom->parent->AddDeclaration(segmentOffset, DeclarationAlignment::None, DeclarationPadding::Pad16, 0x1E, "MeshHeader1Single",
|
||||
StringHelper::Sprintf("%sMeshHeader0x%06X", zRoom->GetName().c_str(), segmentOffset), declaration);
|
||||
|
||||
//if (headerSingle->imagePtr != 0)
|
||||
//{
|
||||
//zRoom->declarations[headerSingle->imagePtr] = new Declaration(DeclarationAlignment::None, DeclarationPadding::Pad16, 0x1E, declaration);
|
||||
//}
|
||||
|
||||
meshHeader1 = headerSingle;
|
||||
; }
|
||||
else if (fmt == 2) // Multi-Format
|
||||
{
|
||||
MeshHeader1Multi* headerMulti = new MeshHeader1Multi();
|
||||
|
||||
headerMulti->headerType = 1;
|
||||
headerMulti->format = fmt;
|
||||
headerMulti->entryRecord = BitConverter::ToInt32BE(rawData, segmentOffset + 4);// &0x00FFFFFF;
|
||||
|
||||
headerMulti->bgCnt = rawData[segmentOffset + 8];
|
||||
headerMulti->bgRecordPtr = BitConverter::ToInt32BE(rawData, segmentOffset + 12);
|
||||
|
||||
//zRoom->declarations[segmentOffset] = new Declaration(DeclarationAlignment::None, DeclarationPadding::Pad16, 12, "");
|
||||
|
||||
declaration += StringHelper::Sprintf("{ { 1 }, 2, 0x%06X }, 0x%06X, 0x%06X",
|
||||
headerMulti->entryRecord, headerMulti->bgCnt, headerMulti->bgRecordPtr);
|
||||
|
||||
zRoom->parent->AddDeclaration(segmentOffset, DeclarationAlignment::None, DeclarationPadding::Pad16, 16, "MeshHeader1Multi",
|
||||
StringHelper::Sprintf("%sMeshHeader0x%06X", zRoom->GetName().c_str(), segmentOffset), declaration);
|
||||
|
||||
//zRoom->parent->declarations[segmentOffset] = new Declaration(DeclarationAlignment::None, DeclarationPadding::Pad16, 16, declaration);
|
||||
|
||||
meshHeader1 = headerMulti;
|
||||
}
|
||||
else // UH OH
|
||||
{
|
||||
int bp = 0;
|
||||
}
|
||||
|
||||
meshHeader1->headerType = 1;
|
||||
meshHeader1->format = fmt;
|
||||
meshHeader1->entryRecord = BitConverter::ToInt32BE(rawData, segmentOffset + 4) & 0x00FFFFFF;
|
||||
|
||||
|
||||
meshHeader = meshHeader1;
|
||||
}
|
||||
else if (meshHeaderType == 2)
|
||||
{
|
||||
MeshHeader2* meshHeader2 = new MeshHeader2();
|
||||
meshHeader2->headerType = 2;
|
||||
|
||||
meshHeader2->entries = vector<MeshEntry2*>();
|
||||
meshHeader2->dListStart = BitConverter::ToInt32BE(rawData, segmentOffset + 4) & 0x00FFFFFF;
|
||||
meshHeader2->dListEnd = BitConverter::ToInt32BE(rawData, segmentOffset + 8) & 0x00FFFFFF;
|
||||
|
||||
int8_t numEntries = rawData[segmentOffset + 1];
|
||||
uint32_t currentPtr = meshHeader2->dListStart;
|
||||
|
||||
// HOTSPOT
|
||||
for (int i = 0; i < numEntries; i++)
|
||||
{
|
||||
MeshEntry2* entry = new MeshEntry2();
|
||||
entry->playerXMax = BitConverter::ToInt16BE(rawData, currentPtr + 0);
|
||||
entry->playerZMax = BitConverter::ToInt16BE(rawData, currentPtr + 2);
|
||||
entry->playerXMin = BitConverter::ToInt16BE(rawData, currentPtr + 4);
|
||||
entry->playerZMin = BitConverter::ToInt16BE(rawData, currentPtr + 6);
|
||||
|
||||
entry->opaqueDListAddr = BitConverter::ToInt32BE(rawData, currentPtr + 8) & 0x00FFFFFF;
|
||||
entry->translucentDListAddr = BitConverter::ToInt32BE(rawData, currentPtr + 12) & 0x00FFFFFF;
|
||||
|
||||
if (entry->opaqueDListAddr != 0)
|
||||
{
|
||||
entry->opaqueDList = new ZDisplayList(rawData, entry->opaqueDListAddr, ZDisplayList::GetDListLength(rawData, entry->opaqueDListAddr));
|
||||
entry->opaqueDList->scene = zRoom->scene;
|
||||
GenDListDeclarations(rawData, entry->opaqueDList); // HOTSPOT
|
||||
}
|
||||
|
||||
if (entry->translucentDListAddr != 0)
|
||||
{
|
||||
entry->translucentDList = new ZDisplayList(rawData, entry->translucentDListAddr, ZDisplayList::GetDListLength(rawData, entry->translucentDListAddr));
|
||||
entry->translucentDList->scene = zRoom->scene;
|
||||
GenDListDeclarations(rawData, entry->translucentDList); // HOTSPOT
|
||||
}
|
||||
|
||||
meshHeader2->entries.push_back(entry);
|
||||
|
||||
currentPtr += 16;
|
||||
}
|
||||
|
||||
sprintf(line, "{ 2 }, 0x%02lX, ", meshHeader2->entries.size());
|
||||
declaration += line;
|
||||
|
||||
if (meshHeader2->dListStart != 0)
|
||||
sprintf(line, "(u32)&%sMeshDListEntry0x%06X, ", zRoom->GetName().c_str(), meshHeader2->dListStart);
|
||||
else
|
||||
sprintf(line, "0, ");
|
||||
|
||||
declaration += line;
|
||||
|
||||
if (meshHeader2->dListEnd != 0)
|
||||
sprintf(line, "(u32)&(%sMeshDListEntry0x%06X) + sizeof(%sMeshDListEntry0x%06X)", zRoom->GetName().c_str(), meshHeader2->dListStart, zRoom->GetName().c_str(), meshHeader2->dListStart);
|
||||
else
|
||||
sprintf(line, "0");
|
||||
|
||||
declaration += line;
|
||||
|
||||
zRoom->parent->AddDeclaration(segmentOffset, DeclarationAlignment::None, 12, "MeshHeader2",
|
||||
StringHelper::Sprintf("%sMeshHeader0x%06X", zRoom->GetName().c_str(), segmentOffset), declaration);
|
||||
|
||||
declaration = "";
|
||||
|
||||
//sprintf(line, "MeshEntry2 %sMeshDListEntry0x%06X[%i] = \n{\n", zRoom->GetName().c_str(), meshHeader2->dListStart, meshHeader2->entries.size());
|
||||
//declaration += line;
|
||||
|
||||
for (int i = 0; i < meshHeader2->entries.size(); i++)
|
||||
{
|
||||
sprintf(line, "\t{ %i, %i, %i, %i, ", meshHeader2->entries[i]->playerXMax, meshHeader2->entries[i]->playerZMax, meshHeader2->entries[i]->playerXMin, meshHeader2->entries[i]->playerZMin);
|
||||
|
||||
declaration += line;
|
||||
|
||||
if (meshHeader2->entries[i]->opaqueDListAddr != 0)
|
||||
sprintf(line, "(u32)%sDlist0x%06X, ", zRoom->GetName().c_str(), meshHeader2->entries[i]->opaqueDListAddr);
|
||||
else
|
||||
sprintf(line, "0, ");
|
||||
|
||||
declaration += line;
|
||||
|
||||
if (meshHeader2->entries[i]->translucentDListAddr != 0)
|
||||
sprintf(line, "(u32)%sDlist0x%06X },\n", zRoom->GetName().c_str(), meshHeader2->entries[i]->translucentDListAddr);
|
||||
else
|
||||
sprintf(line, "0 },\n");
|
||||
|
||||
declaration += line;
|
||||
}
|
||||
|
||||
//declaration += "};\n\n";
|
||||
//declaration += "static u32 terminatorMaybe = 0x01000000; // This always appears after the mesh entries. Its purpose is not clear.\n";
|
||||
|
||||
zRoom->parent->AddDeclarationArray(meshHeader2->dListStart, DeclarationAlignment::None, DeclarationPadding::None, (meshHeader2->entries.size() * 16) + 0,
|
||||
"MeshEntry2", StringHelper::Sprintf("%sMeshDListEntry0x%06X", zRoom->GetName().c_str(), meshHeader2->dListStart, meshHeader2->entries.size()), meshHeader2->entries.size(), declaration);
|
||||
|
||||
zRoom->parent->AddDeclaration(meshHeader2->dListStart + (meshHeader2->entries.size() * 16), DeclarationAlignment::None, DeclarationPadding::Pad16, 4, "static s32",
|
||||
"terminatorMaybe", "0x01000000");
|
||||
|
||||
meshHeader = meshHeader2;
|
||||
}
|
||||
}
|
||||
|
||||
void SetMesh::GenDListDeclarations(std::vector<uint8_t> rawData, ZDisplayList* dList)
|
||||
{
|
||||
string sourceOutput = dList->GetSourceOutputCode(zRoom->GetName()); // HOTSPOT
|
||||
|
||||
string srcVarName = "";
|
||||
|
||||
if (Globals::Instance->includeFilePrefix)
|
||||
srcVarName = StringHelper::Sprintf("%s%s", zRoom->GetName().c_str(), dList->GetName().c_str());
|
||||
else
|
||||
srcVarName = StringHelper::Sprintf("%s", dList->GetName().c_str());
|
||||
|
||||
zRoom->parent->AddDeclarationArray(dList->GetRawDataIndex(), DeclarationAlignment::None, dList->GetRawDataSize(), "Gfx", srcVarName, 0, sourceOutput);
|
||||
|
||||
for (ZDisplayList* otherDList : dList->otherDLists)
|
||||
GenDListDeclarations(rawData, otherDList);
|
||||
|
||||
for (pair<uint32_t, string> vtxEntry : dList->vtxDeclarations)
|
||||
{
|
||||
zRoom->parent->AddDeclarationArray(vtxEntry.first, DeclarationAlignment::Align8, dList->vertices[vtxEntry.first].size() * 16, "Vtx",
|
||||
StringHelper::Sprintf("%sVtx_%06X", zRoom->GetName().c_str(), vtxEntry.first), 0, vtxEntry.second);
|
||||
|
||||
//zRoom->parent->declarations[vtxEntry.first] = new Declaration(DeclarationAlignment::Align8, dList->vertices[vtxEntry.first].size() * 16, vtxEntry.second);
|
||||
}
|
||||
|
||||
for (pair<uint32_t, string> texEntry : dList->texDeclarations)
|
||||
{
|
||||
zRoom->textures[texEntry.first] = dList->textures[texEntry.first];
|
||||
|
||||
//zRoom->parent->AddDeclarationArray(texEntry.first, DeclarationAlignment::None, dList->textures[texEntry.first]->GetRawDataSize(), "u64",
|
||||
//zRoom->textures[texEntry.first]->GetName(), 0, texEntry.second);
|
||||
|
||||
if (Globals::Instance->debugMessages)
|
||||
printf("SAVING IMAGE TO %s\n", Globals::Instance->outputPath.c_str());
|
||||
|
||||
zRoom->textures[texEntry.first]->Save(Globals::Instance->outputPath);
|
||||
|
||||
zRoom->parent->AddDeclarationIncludeArray(texEntry.first, StringHelper::Sprintf("%s/%s.%s.inc.c",
|
||||
Globals::Instance->outputPath.c_str(), Path::GetFileNameWithoutExtension(zRoom->textures[texEntry.first]->GetName()).c_str(), zRoom->textures[texEntry.first]->GetExternalExtension().c_str()),
|
||||
zRoom->textures[texEntry.first]->GetRawDataSize(), "u64", StringHelper::Sprintf("%sTex_%06X", zRoom->textures[texEntry.first]->GetName().c_str(), texEntry.first), 0);
|
||||
}
|
||||
}
|
||||
|
||||
std::string SetMesh::GenDListExterns(ZDisplayList* dList)
|
||||
{
|
||||
string sourceOutput = "";
|
||||
|
||||
if (Globals::Instance->includeFilePrefix)
|
||||
sourceOutput += StringHelper::Sprintf("extern Gfx %sDlist0x%06X[];\n", zRoom->GetName().c_str(), dList->GetRawDataIndex());
|
||||
else
|
||||
sourceOutput += StringHelper::Sprintf("extern Gfx dlist0x%06X[];\n", dList->GetRawDataIndex());
|
||||
|
||||
for (ZDisplayList* otherDList : dList->otherDLists)
|
||||
sourceOutput += GenDListExterns(otherDList);
|
||||
|
||||
for (pair<uint32_t, string> vtxEntry : dList->vtxDeclarations)
|
||||
sourceOutput += StringHelper::Sprintf("extern Vtx %sVtx_%06X[%i];\n", zRoom->GetName().c_str(), vtxEntry.first, dList->vertices[vtxEntry.first].size());
|
||||
|
||||
for (pair<uint32_t, string> texEntry : dList->texDeclarations)
|
||||
sourceOutput += StringHelper::Sprintf("extern u64 %sTex_%06X[];\n", zRoom->GetName().c_str(), texEntry.first);
|
||||
|
||||
sourceOutput += dList->defines;
|
||||
|
||||
return sourceOutput;
|
||||
}
|
||||
|
||||
string SetMesh::GenerateSourceCodePass1(string roomName, int baseAddress)
|
||||
{
|
||||
string sourceOutput = "";
|
||||
|
||||
sourceOutput += StringHelper::Sprintf("%s %i, (u32)&%sMeshHeader0x%06X", ZRoomCommand::GenerateSourceCodePass1(roomName, baseAddress).c_str(), data, zRoom->GetName().c_str(), segmentOffset);
|
||||
|
||||
/*if (meshHeader->headerType == 0)
|
||||
{
|
||||
MeshHeader0* meshHeader0 = (MeshHeader0*)meshHeader;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
sourceOutput += "// SetMesh UNIMPLEMENTED HEADER TYPE!\n";
|
||||
}
|
||||
*/
|
||||
return sourceOutput;
|
||||
}
|
||||
|
||||
string SetMesh::GenerateExterns()
|
||||
{
|
||||
string sourceOutput = "";
|
||||
|
||||
if (meshHeader->headerType == 0)
|
||||
{
|
||||
MeshHeader0* meshHeader0 = (MeshHeader0*)meshHeader;
|
||||
|
||||
sourceOutput += StringHelper::Sprintf("extern MeshHeader0 %sMeshHeader0x%06X;\n", zRoom->GetName().c_str(), segmentOffset);
|
||||
sourceOutput += StringHelper::Sprintf("extern MeshEntry0 %sMeshDListEntry0x%06X[%i];\n", zRoom->GetName().c_str(), meshHeader0->dListStart, meshHeader0->entries.size());
|
||||
|
||||
for (MeshEntry0* entry : meshHeader0->entries)
|
||||
{
|
||||
if (entry->opaqueDList != nullptr)
|
||||
sourceOutput += GenDListExterns(entry->opaqueDList);
|
||||
|
||||
if (entry->translucentDList != nullptr)
|
||||
sourceOutput += GenDListExterns(entry->translucentDList);
|
||||
}
|
||||
}
|
||||
else if (meshHeader->headerType == 1)
|
||||
{
|
||||
MeshHeader1Base* meshHeader1 = (MeshHeader1Base*)meshHeader;
|
||||
|
||||
if (meshHeader1->format == 1)
|
||||
sourceOutput += StringHelper::Sprintf("extern MeshHeader1Single %sMeshHeader0x%06X;\n", zRoom->GetName().c_str(), segmentOffset);
|
||||
else if (meshHeader1->format == 2)
|
||||
sourceOutput += StringHelper::Sprintf("extern MeshHeader1Multi %sMeshHeader0x%06X;\n", zRoom->GetName().c_str(), segmentOffset);
|
||||
}
|
||||
else if (meshHeader->headerType == 2)
|
||||
{
|
||||
MeshHeader2* meshHeader2 = (MeshHeader2*)meshHeader;
|
||||
|
||||
sourceOutput += StringHelper::Sprintf("extern MeshHeader2 %sMeshHeader0x%06X;\n", zRoom->GetName().c_str(), segmentOffset);
|
||||
sourceOutput += StringHelper::Sprintf("extern MeshEntry2 %sMeshDListEntry0x%06X[%i];\n", zRoom->GetName().c_str(), meshHeader2->dListStart, meshHeader2->entries.size());
|
||||
|
||||
for (MeshEntry2* entry : meshHeader2->entries)
|
||||
{
|
||||
if (entry->opaqueDList != nullptr)
|
||||
sourceOutput += GenDListExterns(entry->opaqueDList);
|
||||
|
||||
if (entry->translucentDList != nullptr)
|
||||
sourceOutput += GenDListExterns(entry->translucentDList);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//sourceOutput += "// SetMesh UNIMPLEMENTED HEADER TYPE!\n";
|
||||
}
|
||||
|
||||
return sourceOutput;
|
||||
}
|
||||
|
||||
int32_t SetMesh::GetRawDataSize()
|
||||
{
|
||||
return ZRoomCommand::GetRawDataSize();
|
||||
}
|
||||
|
||||
string SetMesh::GetCommandCName()
|
||||
{
|
||||
return "SCmdMesh";
|
||||
}
|
||||
|
||||
RoomCommand SetMesh::GetRoomCommand()
|
||||
{
|
||||
return RoomCommand::SetMesh;
|
||||
}
|
121
tools/ZAPD/ZAPD/ZRoom/Commands/SetMesh.h
Normal file
121
tools/ZAPD/ZAPD/ZRoom/Commands/SetMesh.h
Normal file
@ -0,0 +1,121 @@
|
||||
#pragma once
|
||||
|
||||
#include "../ZRoomCommand.h"
|
||||
#include "../../ZDisplayList.h"
|
||||
|
||||
class MeshHeaderBase
|
||||
{
|
||||
public:
|
||||
int8_t headerType; // 0x00
|
||||
};
|
||||
|
||||
class MeshEntry0
|
||||
{
|
||||
public:
|
||||
int32_t opaqueDListAddr;
|
||||
int32_t translucentDListAddr;
|
||||
|
||||
ZDisplayList* opaqueDList;
|
||||
ZDisplayList* translucentDList;
|
||||
};
|
||||
|
||||
class MeshHeader0 : public MeshHeaderBase
|
||||
{
|
||||
public:
|
||||
std::vector<MeshEntry0*> entries;
|
||||
uint32_t dListStart;
|
||||
uint32_t dListEnd;
|
||||
};
|
||||
|
||||
class MeshHeader1Base : public MeshHeaderBase
|
||||
{
|
||||
public:
|
||||
int8_t format; // 0x01
|
||||
uint32_t entryRecord; // 0x04
|
||||
};
|
||||
|
||||
class MeshHeader1Single : public MeshHeader1Base
|
||||
{
|
||||
public:
|
||||
uint32_t imagePtr; // 0x08
|
||||
|
||||
uint32_t unknown; // 0x0C
|
||||
uint32_t unknown2; // 0x10
|
||||
|
||||
uint16_t bgWidth; // 0x14
|
||||
uint16_t bgHeight; // 0x16
|
||||
|
||||
uint8_t imageFormat; // 0x18
|
||||
uint8_t imageSize; // 0x19
|
||||
uint16_t imagePal; // 0x1A
|
||||
uint16_t imageFlip; // 0x1C
|
||||
};
|
||||
|
||||
class MeshHeader1Multi : public MeshHeader1Base
|
||||
{
|
||||
public:
|
||||
uint8_t bgCnt; // 0x08
|
||||
uint32_t bgRecordPtr; // 0x0C
|
||||
};
|
||||
|
||||
class BackgroundRecord
|
||||
{
|
||||
public:
|
||||
uint16_t unknown; // 0x00
|
||||
int8_t bgID; // 0x02
|
||||
|
||||
uint32_t imagePtr; // 0x04
|
||||
uint32_t unknown2; // 0x08
|
||||
uint32_t unknown3; // 0x0C
|
||||
|
||||
uint16_t bgWidth; // 0x10
|
||||
uint16_t bgHeight; // 0x12
|
||||
|
||||
uint8_t imageFmt; // 0x14
|
||||
uint8_t imageSize; // 0x15
|
||||
uint16_t imagePal; // 0x16
|
||||
uint16_t imageFlip; // 0x18
|
||||
};
|
||||
|
||||
class MeshEntry2
|
||||
{
|
||||
public:
|
||||
int16_t playerXMax, playerZMax;
|
||||
int16_t playerXMin, playerZMin;
|
||||
|
||||
int32_t opaqueDListAddr;
|
||||
int32_t translucentDListAddr;
|
||||
|
||||
ZDisplayList* opaqueDList;
|
||||
ZDisplayList* translucentDList;
|
||||
};
|
||||
|
||||
class MeshHeader2 : public MeshHeaderBase
|
||||
{
|
||||
public:
|
||||
std::vector<MeshEntry2*> entries;
|
||||
uint32_t dListStart;
|
||||
uint32_t dListEnd;
|
||||
};
|
||||
|
||||
class SetMesh : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
SetMesh(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex, int segAddressOffset);
|
||||
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, int baseAddress);
|
||||
//virtual std::string GenerateSourceCodePass2(std::string roomName, int baseAddress);
|
||||
//virtual std::string GenerateSourceCodePass3(std::string roomName);
|
||||
virtual std::string GenerateExterns();
|
||||
virtual std::string GetCommandCName();
|
||||
virtual RoomCommand GetRoomCommand();
|
||||
virtual int32_t GetRawDataSize();
|
||||
|
||||
private:
|
||||
MeshHeaderBase* meshHeader;
|
||||
uint32_t segmentOffset;
|
||||
uint8_t data;
|
||||
|
||||
void GenDListDeclarations(std::vector<uint8_t> rawData, ZDisplayList* dList);
|
||||
std::string GenDListExterns(ZDisplayList* dList);
|
||||
};
|
69
tools/ZAPD/ZAPD/ZRoom/Commands/SetObjectList.cpp
Normal file
69
tools/ZAPD/ZAPD/ZRoom/Commands/SetObjectList.cpp
Normal file
@ -0,0 +1,69 @@
|
||||
#include "SetObjectList.h"
|
||||
#include "../ZRoom.h"
|
||||
#include "../ObjectList.h"
|
||||
#include "../../ZFile.h"
|
||||
#include "../../BitConverter.h"
|
||||
#include "../../StringHelper.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
SetObjectList::SetObjectList(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex) : ZRoomCommand(nZRoom, rawData, rawDataIndex)
|
||||
{
|
||||
objects = vector<uint16_t>();
|
||||
uint8_t objectCnt = rawData[rawDataIndex + 1];
|
||||
segmentOffset = SEG2FILESPACE(BitConverter::ToInt32BE(rawData, rawDataIndex + 4));
|
||||
uint32_t currentPtr = segmentOffset;
|
||||
|
||||
for (int i = 0; i < objectCnt; i++)
|
||||
{
|
||||
uint16_t objectIndex = BitConverter::ToInt16BE(rawData, currentPtr);
|
||||
objects.push_back(objectIndex);
|
||||
currentPtr += 2;
|
||||
}
|
||||
|
||||
if (segmentOffset != 0)
|
||||
zRoom->parent->AddDeclarationPlaceholder(segmentOffset);
|
||||
}
|
||||
|
||||
string SetObjectList::GenerateExterns()
|
||||
{
|
||||
return StringHelper::Sprintf("s16 %sObjectList0x%06X[];\n", zRoom->GetName().c_str(), segmentOffset);
|
||||
}
|
||||
|
||||
string SetObjectList::GenerateSourceCodePass1(string roomName, int baseAddress)
|
||||
{
|
||||
string sourceOutput = "";
|
||||
|
||||
sourceOutput += StringHelper::Sprintf("%s 0x%02X, (u32)%sObjectList0x%06X", ZRoomCommand::GenerateSourceCodePass1(roomName, baseAddress).c_str(), objects.size(), zRoom->GetName().c_str(), segmentOffset);
|
||||
|
||||
string declaration = "";
|
||||
|
||||
for (int i = 0; i < objects.size(); i++)
|
||||
{
|
||||
uint16_t objectIndex = objects[i];
|
||||
declaration += StringHelper::Sprintf("\t%s,", ObjectList[objectIndex].c_str());
|
||||
|
||||
if (i < objects.size() - 1)
|
||||
declaration += "\n";
|
||||
}
|
||||
|
||||
zRoom->parent->AddDeclarationArray(segmentOffset, DeclarationAlignment::None, objects.size() * 2, "s16",
|
||||
StringHelper::Sprintf("%sObjectList0x%06X", zRoom->GetName().c_str(), segmentOffset), objects.size(), declaration);
|
||||
|
||||
return sourceOutput;
|
||||
}
|
||||
|
||||
int32_t SetObjectList::GetRawDataSize()
|
||||
{
|
||||
return ZRoomCommand::GetRawDataSize() + (objects.size() * 2);
|
||||
}
|
||||
|
||||
string SetObjectList::GetCommandCName()
|
||||
{
|
||||
return "SCmdObjectList";
|
||||
}
|
||||
|
||||
RoomCommand SetObjectList::GetRoomCommand()
|
||||
{
|
||||
return RoomCommand::SetObjectList;
|
||||
}
|
19
tools/ZAPD/ZAPD/ZRoom/Commands/SetObjectList.h
Normal file
19
tools/ZAPD/ZAPD/ZRoom/Commands/SetObjectList.h
Normal file
@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#include "../ZRoomCommand.h"
|
||||
|
||||
class SetObjectList : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
SetObjectList(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, int baseAddress);
|
||||
virtual std::string GetCommandCName();
|
||||
virtual RoomCommand GetRoomCommand();
|
||||
virtual int32_t GetRawDataSize();
|
||||
virtual std::string GenerateExterns();
|
||||
|
||||
private:
|
||||
std::vector<uint16_t> objects;
|
||||
uint32_t segmentOffset;
|
||||
};
|
111
tools/ZAPD/ZAPD/ZRoom/Commands/SetPathways.cpp
Normal file
111
tools/ZAPD/ZAPD/ZRoom/Commands/SetPathways.cpp
Normal file
@ -0,0 +1,111 @@
|
||||
#include "SetPathways.h"
|
||||
#include "../ZRoom.h"
|
||||
#include "../../ZFile.h"
|
||||
#include "../../BitConverter.h"
|
||||
#include "../../StringHelper.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
SetPathways::SetPathways(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex) : ZRoomCommand(nZRoom, rawData, rawDataIndex)
|
||||
{
|
||||
_rawData = rawData;
|
||||
_rawDataIndex = rawDataIndex;
|
||||
|
||||
segmentOffset = 0;
|
||||
listSegmentOffset = 0;
|
||||
|
||||
InitList(SEG2FILESPACE(BitConverter::ToInt32BE(rawData, rawDataIndex + 4)));
|
||||
|
||||
uint32_t currentPtr = listSegmentOffset;
|
||||
|
||||
if (segmentOffset != 0)
|
||||
zRoom->parent->declarations[segmentOffset] = new Declaration(DeclarationAlignment::None, 0, "", "", false, "");
|
||||
|
||||
//if (listSegmentOffset != 0)
|
||||
//zRoom->declarations[listSegmentOffset] = new Declaration(DeclarationAlignment::None, 0, "");
|
||||
}
|
||||
|
||||
void SetPathways::InitList(uint32_t address)
|
||||
{
|
||||
segmentOffset = address;
|
||||
listSegmentOffset = SEG2FILESPACE(BitConverter::ToInt32BE(_rawData, address + 4));
|
||||
numPoints = _rawData[address + 0];
|
||||
}
|
||||
|
||||
string SetPathways::GetSourceOutputCode(std::string prefix)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
string SetPathways::GenerateSourceCodePass1(string roomName, int baseAddress)
|
||||
{
|
||||
//int numPathsReal = zRoom->GetDeclarationSizeFromNeighbor(listSegmentOffset) / 6;
|
||||
uint32_t currentPtr = listSegmentOffset;
|
||||
|
||||
uint8_t* data = _rawData.data();
|
||||
|
||||
for (int i = 0; i < numPoints; i++)
|
||||
{
|
||||
PathwayEntry* entry = new PathwayEntry();
|
||||
entry->x = BitConverter::ToInt16BE(data, currentPtr + 0);
|
||||
entry->y = BitConverter::ToInt16BE(data, currentPtr + 2);
|
||||
entry->z = BitConverter::ToInt16BE(data, currentPtr + 4);
|
||||
|
||||
pathways.push_back(entry);
|
||||
|
||||
currentPtr += 6;
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
string SetPathways::GenerateSourceCodePass2(string roomName, int baseAddress)
|
||||
{
|
||||
string sourceOutput = "";
|
||||
|
||||
sourceOutput += StringHelper::Sprintf("%s 0, (u32)&%sPathway0x%06X };", ZRoomCommand::GenerateSourceCodePass1(roomName, baseAddress).c_str(), roomName.c_str(), segmentOffset);
|
||||
|
||||
{
|
||||
string declaration = StringHelper::Sprintf("%i, (u32)%sPathwayList0x%06X", numPoints, roomName.c_str(), listSegmentOffset);
|
||||
|
||||
zRoom->parent->AddDeclaration(segmentOffset, DeclarationAlignment::None, DeclarationPadding::None, 8, "Path",
|
||||
StringHelper::Sprintf("%sPathway0x%06X", roomName.c_str(), segmentOffset), declaration);
|
||||
}
|
||||
|
||||
{
|
||||
string declaration = "";
|
||||
|
||||
int index = 0;
|
||||
for (PathwayEntry* entry : pathways)
|
||||
{
|
||||
declaration += StringHelper::Sprintf("{ %i, %i, %i }, //0x%06X \n", entry->x, entry->y, entry->z, listSegmentOffset + (index * 6));
|
||||
index++;
|
||||
}
|
||||
|
||||
zRoom->parent->AddDeclarationArray(listSegmentOffset, DeclarationAlignment::None, DeclarationPadding::None, pathways.size() * 6,
|
||||
"Vec3s", StringHelper::Sprintf("%sPathwayList0x%06X", roomName.c_str(), listSegmentOffset), pathways.size(), declaration);
|
||||
}
|
||||
|
||||
return sourceOutput;
|
||||
}
|
||||
|
||||
int32_t SetPathways::GetRawDataSize()
|
||||
{
|
||||
return ZRoomCommand::GetRawDataSize() + (pathways.size() * 6);
|
||||
}
|
||||
|
||||
string SetPathways::GenerateExterns()
|
||||
{
|
||||
return StringHelper::Sprintf("extern Vec3s %sPathwayList0x%06X[];\n", zRoom->GetName().c_str(), segmentOffset);
|
||||
}
|
||||
|
||||
string SetPathways::GetCommandCName()
|
||||
{
|
||||
return "SCmdPathList";
|
||||
}
|
||||
|
||||
RoomCommand SetPathways::GetRoomCommand()
|
||||
{
|
||||
return RoomCommand::SetPathways;
|
||||
}
|
33
tools/ZAPD/ZAPD/ZRoom/Commands/SetPathways.h
Normal file
33
tools/ZAPD/ZAPD/ZRoom/Commands/SetPathways.h
Normal file
@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
|
||||
#include "../ZRoomCommand.h"
|
||||
#include "../../Vec3s.h"
|
||||
|
||||
class PathwayEntry
|
||||
{
|
||||
public:
|
||||
int16_t x, y, z;
|
||||
};
|
||||
|
||||
class SetPathways : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
SetPathways(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
|
||||
std::string GetSourceOutputCode(std::string prefix);
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, int baseAddress);
|
||||
virtual std::string GenerateSourceCodePass2(std::string roomName, int baseAddress);
|
||||
virtual RoomCommand GetRoomCommand();
|
||||
virtual int32_t GetRawDataSize();
|
||||
virtual std::string GetCommandCName();
|
||||
virtual std::string GenerateExterns();
|
||||
void InitList(uint32_t address);
|
||||
|
||||
private:
|
||||
uint32_t segmentOffset;
|
||||
uint32_t listSegmentOffset;
|
||||
int numPoints;
|
||||
std::vector<PathwayEntry*> pathways;
|
||||
std::vector<uint8_t> _rawData;
|
||||
int _rawDataIndex;
|
||||
};
|
26
tools/ZAPD/ZAPD/ZRoom/Commands/SetRoomBehavior.cpp
Normal file
26
tools/ZAPD/ZAPD/ZRoom/Commands/SetRoomBehavior.cpp
Normal file
@ -0,0 +1,26 @@
|
||||
#include "SetRoomBehavior.h"
|
||||
#include "../../BitConverter.h"
|
||||
#include "../../StringHelper.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
SetRoomBehavior::SetRoomBehavior(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex) : ZRoomCommand(nZRoom, rawData, rawDataIndex)
|
||||
{
|
||||
gameplayFlags = rawData[rawDataIndex + 0x01];
|
||||
gameplayFlags2 = BitConverter::ToInt32BE(rawData, rawDataIndex + 0x04);
|
||||
}
|
||||
|
||||
string SetRoomBehavior::GenerateSourceCodePass1(string roomName, int baseAddress)
|
||||
{
|
||||
return StringHelper::Sprintf("%s 0x%02X, 0x%08X", ZRoomCommand::GenerateSourceCodePass1(roomName, baseAddress).c_str(), gameplayFlags, gameplayFlags2);;
|
||||
}
|
||||
|
||||
string SetRoomBehavior::GetCommandCName()
|
||||
{
|
||||
return "SCmdRoomBehavior";
|
||||
}
|
||||
|
||||
RoomCommand SetRoomBehavior::GetRoomCommand()
|
||||
{
|
||||
return RoomCommand::SetRoomBehavior;
|
||||
}
|
17
tools/ZAPD/ZAPD/ZRoom/Commands/SetRoomBehavior.h
Normal file
17
tools/ZAPD/ZAPD/ZRoom/Commands/SetRoomBehavior.h
Normal file
@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include "../ZRoomCommand.h"
|
||||
|
||||
class SetRoomBehavior : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
SetRoomBehavior(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, int baseAddress);
|
||||
virtual std::string GetCommandCName();
|
||||
virtual RoomCommand GetRoomCommand();
|
||||
|
||||
private:
|
||||
uint8_t gameplayFlags;
|
||||
uint32_t gameplayFlags2;
|
||||
};
|
101
tools/ZAPD/ZAPD/ZRoom/Commands/SetRoomList.cpp
Normal file
101
tools/ZAPD/ZAPD/ZRoom/Commands/SetRoomList.cpp
Normal file
@ -0,0 +1,101 @@
|
||||
#include "SetRoomList.h"
|
||||
#include "../ZRoom.h"
|
||||
#include "../../ZFile.h"
|
||||
#include "../../Globals.h"
|
||||
#include "../../BitConverter.h"
|
||||
#include "../../StringHelper.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
SetRoomList::SetRoomList(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex) : ZRoomCommand(nZRoom, rawData, rawDataIndex)
|
||||
{
|
||||
int numRooms = rawData[rawDataIndex + 1];
|
||||
segmentOffset = BitConverter::ToInt32BE(rawData, rawDataIndex + 4) & 0x00FFFFFF;
|
||||
|
||||
rooms = vector<RoomEntry*>();
|
||||
|
||||
int32_t currentPtr = segmentOffset;
|
||||
|
||||
for (int i = 0; i < numRooms; i++)
|
||||
{
|
||||
RoomEntry* entry = new RoomEntry(rawData, currentPtr);
|
||||
rooms.push_back(entry);
|
||||
|
||||
currentPtr += 8;
|
||||
}
|
||||
|
||||
//string declaration = "";
|
||||
|
||||
/*for (int i = 0; i < rooms.size(); i++)
|
||||
{
|
||||
RoomEntry* entry = rooms[i];
|
||||
|
||||
string roomName = StringHelper::Sprintf("%sRoom%i", StringHelper::Split(zRoom->GetName(), "_scene")[0].c_str(), i);
|
||||
declaration += StringHelper::Sprintf("\t{ (u32)%sSegmentRomStart, (u32)%sSegmentRomEnd },\n", roomName.c_str(), roomName.c_str());
|
||||
}*/
|
||||
|
||||
//zRoom->parent->declarations[segmentOffset] = new Declaration(DeclarationAlignment::None, rooms.size() * 8,
|
||||
//"RomFile", StringHelper::Sprintf("%sRoomList0x%06X", zRoom->GetName().c_str(), segmentOffset), true, declaration);
|
||||
}
|
||||
|
||||
string SetRoomList::GenerateSourceCodePass1(string roomName, int baseAddress)
|
||||
{
|
||||
return StringHelper::Sprintf("%s 0x%02X, (u32)&%sRoomList0x%06X", ZRoomCommand::GenerateSourceCodePass1(roomName, baseAddress).c_str(), rooms.size(), zRoom->GetName().c_str(), segmentOffset);
|
||||
}
|
||||
|
||||
string SetRoomList::GenerateSourceCodePass2(string roomName, int baseAddress)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
string SetRoomList::GenerateExterns()
|
||||
{
|
||||
return StringHelper::Sprintf("extern RomFile %sRoomList0x%06X[];\n", zRoom->GetName().c_str(), segmentOffset);
|
||||
}
|
||||
|
||||
string SetRoomList::GetCommandCName()
|
||||
{
|
||||
return "SCmdRoomList";
|
||||
}
|
||||
|
||||
RoomCommand SetRoomList::GetRoomCommand()
|
||||
{
|
||||
return RoomCommand::SetRoomList;
|
||||
}
|
||||
|
||||
std::string SetRoomList::PreGenSourceFiles()
|
||||
{
|
||||
string declaration = "";
|
||||
|
||||
for (ZFile* file : Globals::Instance->files)
|
||||
{
|
||||
for (ZResource* res : file->resources)
|
||||
{
|
||||
if (res->GetResourceType() == ZResourceType::Room && res != zRoom)
|
||||
{
|
||||
string roomName = res->GetName();
|
||||
declaration += StringHelper::Sprintf("\t{ (u32)_%sSegmentRomStart, (u32)_%sSegmentRomEnd },\n", roomName.c_str(), roomName.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
zRoom->parent->declarations[segmentOffset] = new Declaration(DeclarationAlignment::None, rooms.size() * 8,
|
||||
"RomFile", StringHelper::Sprintf("%sRoomList0x%06X", zRoom->GetName().c_str(), segmentOffset), true, declaration);
|
||||
|
||||
return std::string();
|
||||
}
|
||||
|
||||
std::string SetRoomList::Save()
|
||||
{
|
||||
return std::string();
|
||||
}
|
||||
|
||||
RoomEntry::RoomEntry(int32_t nVAS, int32_t nVAE)
|
||||
{
|
||||
virtualAddressStart = nVAS;
|
||||
virtualAddressEnd = nVAE;
|
||||
}
|
||||
|
||||
RoomEntry::RoomEntry(std::vector<uint8_t> rawData, int rawDataIndex) : RoomEntry(BitConverter::ToInt32BE(rawData, rawDataIndex + 0), BitConverter::ToInt32BE(rawData, rawDataIndex + 4))
|
||||
{
|
||||
}
|
31
tools/ZAPD/ZAPD/ZRoom/Commands/SetRoomList.h
Normal file
31
tools/ZAPD/ZAPD/ZRoom/Commands/SetRoomList.h
Normal file
@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
|
||||
#include "../ZRoomCommand.h"
|
||||
|
||||
class RoomEntry
|
||||
{
|
||||
public:
|
||||
int32_t virtualAddressStart;
|
||||
int32_t virtualAddressEnd;
|
||||
|
||||
RoomEntry(int32_t nVAS, int32_t nVAE);
|
||||
RoomEntry(std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
};
|
||||
|
||||
class SetRoomList : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
SetRoomList(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, int baseAddress);
|
||||
virtual std::string GenerateSourceCodePass2(std::string roomName, int baseAddress);
|
||||
virtual std::string GetCommandCName();
|
||||
virtual std::string GenerateExterns();
|
||||
virtual RoomCommand GetRoomCommand();
|
||||
virtual std::string PreGenSourceFiles();
|
||||
virtual std::string Save();
|
||||
|
||||
private:
|
||||
std::vector<RoomEntry*> rooms;
|
||||
uint32_t segmentOffset;
|
||||
};
|
25
tools/ZAPD/ZAPD/ZRoom/Commands/SetSkyboxModifier.cpp
Normal file
25
tools/ZAPD/ZAPD/ZRoom/Commands/SetSkyboxModifier.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
#include "SetSkyboxModifier.h"
|
||||
#include "../../StringHelper.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
SetSkyboxModifier::SetSkyboxModifier(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex) : ZRoomCommand(nZRoom, rawData, rawDataIndex)
|
||||
{
|
||||
disableSky = rawData[rawDataIndex + 0x04];
|
||||
disableSunMoon = rawData[rawDataIndex + 0x05];
|
||||
}
|
||||
|
||||
string SetSkyboxModifier::GenerateSourceCodePass1(string roomName, int baseAddress)
|
||||
{
|
||||
return StringHelper::Sprintf("%s 0, 0, 0, 0x%02X, 0x%02X", ZRoomCommand::GenerateSourceCodePass1(roomName, baseAddress).c_str(), disableSky, disableSunMoon);;
|
||||
}
|
||||
|
||||
string SetSkyboxModifier::GetCommandCName()
|
||||
{
|
||||
return "SCmdSkyboxDisables";
|
||||
}
|
||||
|
||||
RoomCommand SetSkyboxModifier::GetRoomCommand()
|
||||
{
|
||||
return RoomCommand::SetSkyboxModifier;
|
||||
}
|
17
tools/ZAPD/ZAPD/ZRoom/Commands/SetSkyboxModifier.h
Normal file
17
tools/ZAPD/ZAPD/ZRoom/Commands/SetSkyboxModifier.h
Normal file
@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include "../ZRoomCommand.h"
|
||||
|
||||
class SetSkyboxModifier : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
SetSkyboxModifier(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, int baseAddress);
|
||||
virtual std::string GetCommandCName();
|
||||
virtual RoomCommand GetRoomCommand();
|
||||
|
||||
private:
|
||||
uint8_t disableSky;
|
||||
uint8_t disableSunMoon;
|
||||
};
|
27
tools/ZAPD/ZAPD/ZRoom/Commands/SetSkyboxSettings.cpp
Normal file
27
tools/ZAPD/ZAPD/ZRoom/Commands/SetSkyboxSettings.cpp
Normal file
@ -0,0 +1,27 @@
|
||||
#include "SetSkyboxSettings.h"
|
||||
#include "../../StringHelper.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
SetSkyboxSettings::SetSkyboxSettings(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex) : ZRoomCommand(nZRoom, rawData, rawDataIndex)
|
||||
{
|
||||
skyboxNumber = rawData[rawDataIndex + 0x04];
|
||||
cloudsType = rawData[rawDataIndex + 0x05];
|
||||
lightingSettingsControl = rawData[rawDataIndex + 0x06];
|
||||
}
|
||||
|
||||
string SetSkyboxSettings::GenerateSourceCodePass1(string roomName, int baseAddress)
|
||||
{
|
||||
return StringHelper::Sprintf("%s 0x00, 0x00, 0x00, 0x%02X, 0x%02X, 0x%02X",
|
||||
ZRoomCommand::GenerateSourceCodePass1(roomName, baseAddress).c_str(), skyboxNumber, cloudsType, lightingSettingsControl);
|
||||
}
|
||||
|
||||
string SetSkyboxSettings::GetCommandCName()
|
||||
{
|
||||
return "SCmdSkyboxSettings";
|
||||
}
|
||||
|
||||
RoomCommand SetSkyboxSettings::GetRoomCommand()
|
||||
{
|
||||
return RoomCommand::SetSkyboxSettings;
|
||||
}
|
18
tools/ZAPD/ZAPD/ZRoom/Commands/SetSkyboxSettings.h
Normal file
18
tools/ZAPD/ZAPD/ZRoom/Commands/SetSkyboxSettings.h
Normal file
@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include "../ZRoomCommand.h"
|
||||
|
||||
class SetSkyboxSettings : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
SetSkyboxSettings(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, int baseAddress);
|
||||
virtual std::string GetCommandCName();
|
||||
virtual RoomCommand GetRoomCommand();
|
||||
|
||||
private:
|
||||
uint8_t skyboxNumber;
|
||||
uint8_t cloudsType;
|
||||
uint8_t lightingSettingsControl;
|
||||
};
|
26
tools/ZAPD/ZAPD/ZRoom/Commands/SetSoundSettings.cpp
Normal file
26
tools/ZAPD/ZAPD/ZRoom/Commands/SetSoundSettings.cpp
Normal file
@ -0,0 +1,26 @@
|
||||
#include "SetSoundSettings.h"
|
||||
#include "../../StringHelper.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
SetSoundSettings::SetSoundSettings(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex) : ZRoomCommand(nZRoom, rawData, rawDataIndex)
|
||||
{
|
||||
reverb = rawData[rawDataIndex + 0x01];
|
||||
nightTimeSFX = rawData[rawDataIndex + 0x06];
|
||||
musicSequence = rawData[rawDataIndex + 0x07];
|
||||
}
|
||||
|
||||
string SetSoundSettings::GenerateSourceCodePass1(string roomName, int baseAddress)
|
||||
{
|
||||
return StringHelper::Sprintf("%s 0x%02X, 0x00, 0x00, 0x00, 0x00, 0x%02X, 0x%02X", ZRoomCommand::GenerateSourceCodePass1(roomName, baseAddress).c_str(), reverb, nightTimeSFX, musicSequence);
|
||||
}
|
||||
|
||||
string SetSoundSettings::GetCommandCName()
|
||||
{
|
||||
return "SCmdSoundSettings";
|
||||
}
|
||||
|
||||
RoomCommand SetSoundSettings::GetRoomCommand()
|
||||
{
|
||||
return RoomCommand::SetSoundSettings;
|
||||
}
|
18
tools/ZAPD/ZAPD/ZRoom/Commands/SetSoundSettings.h
Normal file
18
tools/ZAPD/ZAPD/ZRoom/Commands/SetSoundSettings.h
Normal file
@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include "../ZRoomCommand.h"
|
||||
|
||||
class SetSoundSettings : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
SetSoundSettings(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, int baseAddress);
|
||||
virtual std::string GetCommandCName();
|
||||
virtual RoomCommand GetRoomCommand();
|
||||
|
||||
private:
|
||||
uint8_t reverb;
|
||||
uint8_t nightTimeSFX;
|
||||
uint8_t musicSequence;
|
||||
};
|
26
tools/ZAPD/ZAPD/ZRoom/Commands/SetSpecialObjects.cpp
Normal file
26
tools/ZAPD/ZAPD/ZRoom/Commands/SetSpecialObjects.cpp
Normal file
@ -0,0 +1,26 @@
|
||||
#include "SetSpecialObjects.h"
|
||||
#include "../../BitConverter.h"
|
||||
#include "../../StringHelper.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
SetSpecialObjects::SetSpecialObjects(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex) : ZRoomCommand(nZRoom, rawData, rawDataIndex)
|
||||
{
|
||||
elfMessage = rawData[rawDataIndex + 0x01];
|
||||
globalObject = BitConverter::ToInt16BE(rawData, rawDataIndex + 6);
|
||||
}
|
||||
|
||||
string SetSpecialObjects::GenerateSourceCodePass1(string roomName, int baseAddress)
|
||||
{
|
||||
return StringHelper::Sprintf("%s 0x%02X, 0x%04X", ZRoomCommand::GenerateSourceCodePass1(roomName, baseAddress).c_str(), elfMessage, globalObject);
|
||||
}
|
||||
|
||||
string SetSpecialObjects::GetCommandCName()
|
||||
{
|
||||
return "SCmdSpecialFiles";
|
||||
}
|
||||
|
||||
RoomCommand SetSpecialObjects::GetRoomCommand()
|
||||
{
|
||||
return RoomCommand::SetSpecialObjects;
|
||||
}
|
17
tools/ZAPD/ZAPD/ZRoom/Commands/SetSpecialObjects.h
Normal file
17
tools/ZAPD/ZAPD/ZRoom/Commands/SetSpecialObjects.h
Normal file
@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include "../ZRoomCommand.h"
|
||||
|
||||
class SetSpecialObjects : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
SetSpecialObjects(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, int baseAddress);
|
||||
virtual std::string GetCommandCName();
|
||||
virtual RoomCommand GetRoomCommand();
|
||||
|
||||
private:
|
||||
uint8_t elfMessage;
|
||||
uint16_t globalObject;
|
||||
};
|
68
tools/ZAPD/ZAPD/ZRoom/Commands/SetStartPositionList.cpp
Normal file
68
tools/ZAPD/ZAPD/ZRoom/Commands/SetStartPositionList.cpp
Normal file
@ -0,0 +1,68 @@
|
||||
#include "SetStartPositionList.h"
|
||||
#include "../ZRoom.h"
|
||||
#include "../ActorList.h"
|
||||
#include "../../ZFile.h"
|
||||
#include "../../BitConverter.h"
|
||||
#include "../../StringHelper.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
SetStartPositionList::SetStartPositionList(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex) : ZRoomCommand(nZRoom, rawData, rawDataIndex)
|
||||
{
|
||||
int numActors = rawData[rawDataIndex + 1];
|
||||
segmentOffset = SEG2FILESPACE(BitConverter::ToInt32BE(rawData, rawDataIndex + 4));
|
||||
|
||||
if (segmentOffset != 0)
|
||||
zRoom->parent->AddDeclarationPlaceholder(segmentOffset);
|
||||
|
||||
actors = vector<ActorSpawnEntry*>();
|
||||
|
||||
uint32_t currentPtr = segmentOffset;
|
||||
|
||||
for (int i = 0; i < numActors; i++)
|
||||
{
|
||||
actors.push_back(new ActorSpawnEntry(rawData, currentPtr));
|
||||
currentPtr += 16;
|
||||
}
|
||||
}
|
||||
|
||||
string SetStartPositionList::GenerateSourceCodePass1(string roomName, int baseAddress)
|
||||
{
|
||||
string sourceOutput = "";
|
||||
char line[2048];
|
||||
|
||||
sourceOutput += StringHelper::Sprintf("%s 0x%02X, (u32)&%sStartPositionList0x%06X", ZRoomCommand::GenerateSourceCodePass1(roomName, baseAddress).c_str(), actors.size(), zRoom->GetName().c_str(), segmentOffset);
|
||||
|
||||
string declaration = "";
|
||||
|
||||
for (ActorSpawnEntry* entry : actors)
|
||||
{
|
||||
declaration += StringHelper::Sprintf("\t{ %s, %i, %i, %i, %i, %i, %i, 0x%04X },\n", ActorList[entry->actorNum].c_str(), entry->posX, entry->posY, entry->posZ,
|
||||
entry->rotX, entry->rotY, entry->rotZ, entry->initVar);
|
||||
}
|
||||
|
||||
zRoom->parent->AddDeclarationArray(segmentOffset, DeclarationAlignment::None, actors.size() * 16, "ActorEntry",
|
||||
StringHelper::Sprintf("%sStartPositionList0x%06X", zRoom->GetName().c_str(), segmentOffset), 0, declaration);
|
||||
|
||||
return sourceOutput;
|
||||
}
|
||||
|
||||
string SetStartPositionList::GenerateSourceCodePass2(string roomName, int baseAddress)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
string SetStartPositionList::GenerateExterns()
|
||||
{
|
||||
return StringHelper::Sprintf("extern ActorEntry %sStartPositionList0x%06X[];\n", zRoom->GetName().c_str(), segmentOffset);
|
||||
}
|
||||
|
||||
string SetStartPositionList::GetCommandCName()
|
||||
{
|
||||
return "SCmdSpawnList";
|
||||
}
|
||||
|
||||
RoomCommand SetStartPositionList::GetRoomCommand()
|
||||
{
|
||||
return RoomCommand::SetStartPositionList;
|
||||
}
|
22
tools/ZAPD/ZAPD/ZRoom/Commands/SetStartPositionList.h
Normal file
22
tools/ZAPD/ZAPD/ZRoom/Commands/SetStartPositionList.h
Normal file
@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include "../ZRoomCommand.h"
|
||||
#include "SetActorList.h"
|
||||
|
||||
|
||||
class SetStartPositionList : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
std::vector<ActorSpawnEntry*> actors;
|
||||
|
||||
SetStartPositionList(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, int baseAddress);
|
||||
virtual std::string GenerateSourceCodePass2(std::string roomName, int baseAddress);
|
||||
virtual std::string GetCommandCName();
|
||||
virtual std::string GenerateExterns();
|
||||
virtual RoomCommand GetRoomCommand();
|
||||
private:
|
||||
|
||||
uint32_t segmentOffset;
|
||||
};
|
27
tools/ZAPD/ZAPD/ZRoom/Commands/SetTimeSettings.cpp
Normal file
27
tools/ZAPD/ZAPD/ZRoom/Commands/SetTimeSettings.cpp
Normal file
@ -0,0 +1,27 @@
|
||||
#include "SetTimeSettings.h"
|
||||
#include "../../BitConverter.h"
|
||||
#include "../../StringHelper.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
SetTimeSettings::SetTimeSettings(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex) : ZRoomCommand(nZRoom, rawData, rawDataIndex)
|
||||
{
|
||||
hour = rawData[rawDataIndex + 4];
|
||||
min = rawData[rawDataIndex + 5];
|
||||
unk = rawData[rawDataIndex + 6];
|
||||
}
|
||||
|
||||
string SetTimeSettings::GenerateSourceCodePass1(string roomName, int baseAddress)
|
||||
{
|
||||
return StringHelper::Sprintf("%s 0x00, 0x00, 0x00, 0x%02X, 0x%02X, 0x%02X", ZRoomCommand::GenerateSourceCodePass1(roomName, baseAddress).c_str(), hour, min, unk);
|
||||
}
|
||||
|
||||
string SetTimeSettings::GetCommandCName()
|
||||
{
|
||||
return "SCmdTimeSettings";
|
||||
}
|
||||
|
||||
RoomCommand SetTimeSettings::GetRoomCommand()
|
||||
{
|
||||
return RoomCommand::SetTimeSettings;
|
||||
}
|
21
tools/ZAPD/ZAPD/ZRoom/Commands/SetTimeSettings.h
Normal file
21
tools/ZAPD/ZAPD/ZRoom/Commands/SetTimeSettings.h
Normal file
@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include "../ZRoomCommand.h"
|
||||
|
||||
class SetTimeSettings : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
SetTimeSettings(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, int baseAddress);
|
||||
virtual std::string GetCommandCName();
|
||||
virtual RoomCommand GetRoomCommand();
|
||||
|
||||
private:
|
||||
//uint16_t time;
|
||||
//int8_t speed;
|
||||
|
||||
uint8_t hour;
|
||||
uint8_t min;
|
||||
uint8_t unk;
|
||||
};
|
85
tools/ZAPD/ZAPD/ZRoom/Commands/SetTransitionActorList.cpp
Normal file
85
tools/ZAPD/ZAPD/ZRoom/Commands/SetTransitionActorList.cpp
Normal file
@ -0,0 +1,85 @@
|
||||
#include "SetTransitionActorList.h"
|
||||
#include "../ZRoom.h"
|
||||
#include "../ActorList.h"
|
||||
#include "../../ZFile.h"
|
||||
#include "../../BitConverter.h"
|
||||
#include "../../StringHelper.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
SetTransitionActorList::SetTransitionActorList(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex) : ZRoomCommand(nZRoom, rawData, rawDataIndex)
|
||||
{
|
||||
int numActors = rawData[rawDataIndex + 1];
|
||||
segmentOffset = BitConverter::ToInt32BE(rawData, rawDataIndex + 4) & 0x00FFFFFF;
|
||||
|
||||
transitionActors = vector<TransitionActorEntry*>();
|
||||
|
||||
uint32_t currentPtr = segmentOffset;
|
||||
|
||||
for (int i = 0; i < numActors; i++)
|
||||
{
|
||||
TransitionActorEntry* entry = new TransitionActorEntry(rawData, currentPtr);
|
||||
transitionActors.push_back(entry);
|
||||
|
||||
currentPtr += 16;
|
||||
}
|
||||
}
|
||||
|
||||
string SetTransitionActorList::GetSourceOutputCode(std::string prefix)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
string SetTransitionActorList::GenerateSourceCodePass1(string roomName, int baseAddress)
|
||||
{
|
||||
string sourceOutput = StringHelper::Sprintf("%s 0x%02X, (u32)%sTransitionActorList0x%06X", ZRoomCommand::GenerateSourceCodePass1(roomName, baseAddress).c_str(), transitionActors.size(), roomName.c_str(), segmentOffset);
|
||||
string declaration = "";
|
||||
|
||||
for (TransitionActorEntry* entry : transitionActors)
|
||||
declaration += StringHelper::Sprintf("\t{ %i, %i, %i, %i, %s, %i, %i, %i, %i, 0x%04X }, \n", entry->frontObjectRoom, entry->frontTransitionReaction, entry->backObjectRoom, entry->backTransitionReaction, ActorList[entry->actorNum].c_str(), entry->posX, entry->posY, entry->posZ, entry->rotY, (uint16_t)entry->initVar);
|
||||
|
||||
zRoom->parent->declarations[segmentOffset] = new Declaration(DeclarationAlignment::None, transitionActors.size() * 16, "TransitionActorEntry",
|
||||
StringHelper::Sprintf("%sTransitionActorList0x%06X", roomName.c_str(), segmentOffset), true, declaration);
|
||||
|
||||
return sourceOutput;
|
||||
}
|
||||
|
||||
|
||||
string SetTransitionActorList::GenerateSourceCodePass2(string roomName, int baseAddress)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
int32_t SetTransitionActorList::GetRawDataSize()
|
||||
{
|
||||
return ZRoomCommand::GetRawDataSize() + (transitionActors.size() * 16);
|
||||
}
|
||||
|
||||
string SetTransitionActorList::GenerateExterns()
|
||||
{
|
||||
return StringHelper::Sprintf("extern TransitionActorEntry %sTransitionActorList0x%06X[];\n", zRoom->GetName().c_str(), segmentOffset);
|
||||
}
|
||||
|
||||
string SetTransitionActorList::GetCommandCName()
|
||||
{
|
||||
return "SCmdTransiActorList";
|
||||
}
|
||||
|
||||
RoomCommand SetTransitionActorList::GetRoomCommand()
|
||||
{
|
||||
return RoomCommand::SetTransitionActorList;
|
||||
}
|
||||
|
||||
TransitionActorEntry::TransitionActorEntry(std::vector<uint8_t> 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);
|
||||
}
|
36
tools/ZAPD/ZAPD/ZRoom/Commands/SetTransitionActorList.h
Normal file
36
tools/ZAPD/ZAPD/ZRoom/Commands/SetTransitionActorList.h
Normal file
@ -0,0 +1,36 @@
|
||||
#pragma once
|
||||
|
||||
#include "../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(std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
};
|
||||
|
||||
class SetTransitionActorList : public ZRoomCommand
|
||||
{
|
||||
public:
|
||||
SetTransitionActorList(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex);
|
||||
|
||||
std::string GetSourceOutputCode(std::string prefix);
|
||||
virtual std::string GenerateSourceCodePass1(std::string roomName, int baseAddress);
|
||||
virtual std::string GenerateSourceCodePass2(std::string roomName, int baseAddress);
|
||||
virtual RoomCommand GetRoomCommand();
|
||||
virtual int32_t GetRawDataSize();
|
||||
virtual std::string GetCommandCName();
|
||||
virtual std::string GenerateExterns();
|
||||
|
||||
private:
|
||||
std::vector<TransitionActorEntry*> transitionActors;
|
||||
uint32_t segmentOffset;
|
||||
};
|
27
tools/ZAPD/ZAPD/ZRoom/Commands/SetWind.cpp
Normal file
27
tools/ZAPD/ZAPD/ZRoom/Commands/SetWind.cpp
Normal file
@ -0,0 +1,27 @@
|
||||
#include "SetWind.h"
|
||||
#include "../../StringHelper.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
SetWind::SetWind(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex) : ZRoomCommand(nZRoom, rawData, rawDataIndex)
|
||||
{
|
||||
windWest = rawData[rawDataIndex + 0x04];
|
||||
windVertical = rawData[rawDataIndex + 0x05];
|
||||
windSouth = rawData[rawDataIndex + 0x06];
|
||||
clothFlappingStrength = rawData[rawDataIndex + 0x07];
|
||||
}
|
||||
|
||||
string SetWind::GenerateSourceCodePass1(string roomName, int baseAddress)
|
||||
{
|
||||
return StringHelper::Sprintf("%s 0x00, 0x00, 0x00, 0x%02X, 0x%02X, 0x%02X, 0x%02X", ZRoomCommand::GenerateSourceCodePass1(roomName, baseAddress).c_str(), windWest, windVertical, windSouth, clothFlappingStrength);
|
||||
}
|
||||
|
||||
string SetWind::GetCommandCName()
|
||||
{
|
||||
return "SCmdWindSettings";
|
||||
}
|
||||
|
||||
RoomCommand SetWind::GetRoomCommand()
|
||||
{
|
||||
return RoomCommand::SetWind;
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user