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:
fig02
2021-01-01 23:24:29 -05:00
committed by GitHub
parent ae5a8f2700
commit ba0c6965ca
220 changed files with 85641 additions and 554 deletions

3
.gitmodules vendored
View File

@@ -1,3 +0,0 @@
[submodule "tools/ZAP2"]
path = tools/ZAP2
url = https://github.com/zeldaret/ZAPD.git

View File

@@ -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 $@

View File

@@ -1 +0,0 @@
Thanks to z64me and CrookedPoe for their actor documentation. <https://github.com/CrookedPoe/z64-rw>

View File

@@ -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"/>

View File

@@ -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"/>

View File

@@ -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)

1042
spec

File diff suppressed because it is too large Load Diff

View File

@@ -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)

Submodule tools/ZAP2 deleted from 73dcb0371a

335
tools/ZAPD/.gitignore vendored Normal file
View 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
View 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
View 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
View 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

View File

@@ -0,0 +1 @@
8012DB20 gMtxClear

46
tools/ZAPD/ZAPD.sln Normal file
View 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

View 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];
}
};

View 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
View 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
View 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
View 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...
*/

Some files were not shown because too many files have changed in this diff Show More