mirror of
https://github.com/izzy2lost/2ship2harkinian-Android.git
synced 2026-06-19 01:20:08 -07:00
Convert every submodule into subrepo (#170)
* remove ZAPD submodule * git subrepo clone https://github.com/zeldaret/ZAPD.git tools/ZAPD subrepo: subdir: "tools/ZAPD" merged: "ca229f19" upstream: origin: "https://github.com/zeldaret/ZAPD.git" branch: "master" commit: "ca229f19" git-subrepo: version: "0.4.3" origin: "???" commit: "???" * git subrepo clone https://github.com/simonlindholm/decomp-permuter.git tools/decomp-permuter subrepo: subdir: "tools/decomp-permuter" merged: "1e4b85a7" upstream: origin: "https://github.com/simonlindholm/decomp-permuter.git" branch: "main" commit: "1e4b85a7" git-subrepo: version: "0.4.3" origin: "???" commit: "???" * Remove asm-differ * git subrepo clone https://github.com/simonlindholm/asm-differ.git tools/asm-differ subrepo: subdir: "tools/asm-differ" merged: "eaf72269" upstream: origin: "https://github.com/simonlindholm/asm-differ.git" branch: "master" commit: "eaf72269" git-subrepo: version: "0.4.3" origin: "???" commit: "???" * remove asm-processor * git subrepo clone https://github.com/simonlindholm/asm-processor.git tools/asm-processor subrepo: subdir: "tools/asm-processor" merged: "85288fcd" upstream: origin: "https://github.com/simonlindholm/asm-processor.git" branch: "master" commit: "85288fcd" git-subrepo: version: "0.4.3" origin: "???" commit: "???" * remove .gitmodules file * Update REAMDE * Update warnings
This commit is contained in:
-13
@@ -1,13 +0,0 @@
|
||||
[submodule "tools/asm-processor"]
|
||||
path = tools/asm-processor
|
||||
url = https://github.com/simonlindholm/asm-processor.git
|
||||
[submodule "tools/asm-differ"]
|
||||
path = tools/asm-differ
|
||||
url = https://github.com/simonlindholm/asm-differ.git
|
||||
[submodule "tools/decomp-permuter"]
|
||||
path = tools/decomp-permuter
|
||||
url = https://github.com/simonlindholm/decomp-permuter
|
||||
branch = main
|
||||
[submodule "ZAPD"]
|
||||
path = tools/ZAPD
|
||||
url = https://github.com/zeldaret/ZAPD.git
|
||||
@@ -215,11 +215,6 @@ distclean: assetclean clean
|
||||
|
||||
## Extraction step
|
||||
setup:
|
||||
# Initialize submodules, fetching commit in case it is not on the default branch
|
||||
-git submodule update --init --recursive
|
||||
git submodule foreach --recursive 'git fetch origin $$sha1'
|
||||
git submodule update --recursive
|
||||
python3 -m pip install -r requirements.txt
|
||||
$(MAKE) -C tools
|
||||
./tools/extract_rom.py $(MM_BASEROM)
|
||||
python3 extract_assets.py
|
||||
|
||||
@@ -56,12 +56,19 @@ The build process has the following package requirements:
|
||||
* binutils-mips-linux-gnu
|
||||
* python3
|
||||
* pip3
|
||||
* libpng-dev
|
||||
|
||||
Under Debian / Ubuntu (which we recommend using), you can install them with the following commands:
|
||||
|
||||
```bash
|
||||
sudo apt update
|
||||
sudo apt install make git build-essential binutils-mips-linux-gnu python3 python3-pip
|
||||
sudo apt install make git build-essential binutils-mips-linux-gnu python3 python3-pip libpng-dev
|
||||
```
|
||||
|
||||
To install the Python dependencies simply run in a terminal:
|
||||
|
||||
```bash
|
||||
python3 -m pip install -r requirements.txt
|
||||
```
|
||||
|
||||
#### 2. Fork the repository
|
||||
|
||||
-1
Submodule tools/ZAPD deleted from ca229f19b9
@@ -0,0 +1,84 @@
|
||||
---
|
||||
AccessModifierOffset: -4
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignConsecutiveAssignments: false
|
||||
AlignConsecutiveDeclarations: false
|
||||
AlignEscapedNewlinesLeft: false
|
||||
AlignOperands: true
|
||||
AlignTrailingComments: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: true
|
||||
AllowShortBlocksOnASingleLine: false
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: InlineOnly
|
||||
AllowShortIfStatementsOnASingleLine: false
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
AlwaysBreakAfterDefinitionReturnType: None
|
||||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakBeforeMultilineStrings: false
|
||||
AlwaysBreakTemplateDeclarations: true
|
||||
BinPackArguments: true
|
||||
BinPackParameters: true
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: true
|
||||
AfterClass: true
|
||||
AfterControlStatement: true
|
||||
AfterEnum: true
|
||||
AfterFunction: true
|
||||
AfterNamespace: true
|
||||
AfterStruct: true
|
||||
AfterUnion: true
|
||||
BeforeCatch: true
|
||||
BeforeElse: true
|
||||
IndentBraces: false
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakBeforeBraces: Custom
|
||||
BreakBeforeTernaryOperators: false
|
||||
BreakConstructorInitializersBeforeComma: false
|
||||
ColumnLimit: 100
|
||||
CommentPragmas: '^ (IWYU pragma:|NOLINT)'
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
||||
ConstructorInitializerIndentWidth: 4
|
||||
ContinuationIndentWidth: 4
|
||||
Cpp11BracedListStyle: true
|
||||
DerivePointerAlignment: false
|
||||
DisableFormat: false
|
||||
ForEachMacros: [ ]
|
||||
IncludeCategories:
|
||||
- Regex: '^<[Ww]indows\.h>$'
|
||||
Priority: 1
|
||||
- Regex: '^<'
|
||||
Priority: 2
|
||||
- Regex: '^"'
|
||||
Priority: 3
|
||||
IndentCaseLabels: false
|
||||
IndentWidth: 4
|
||||
IndentWrappedFunctionNames: false
|
||||
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||
MacroBlockBegin: ''
|
||||
MacroBlockEnd: ''
|
||||
MaxEmptyLinesToKeep: 1
|
||||
NamespaceIndentation: None
|
||||
PenaltyBreakBeforeFirstCallParameter: 19
|
||||
PenaltyBreakComment: 300
|
||||
PenaltyBreakFirstLessLess: 120
|
||||
PenaltyBreakString: 1000
|
||||
PenaltyExcessCharacter: 1000000
|
||||
PenaltyReturnTypeOnItsOwnLine: 60
|
||||
PointerAlignment: Left
|
||||
ReflowComments: true
|
||||
SortIncludes: true
|
||||
SpaceAfterCStyleCast: false
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 2
|
||||
SpacesInAngles: false
|
||||
SpacesInContainerLiterals: true
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
Standard: Latest
|
||||
TabWidth: 4
|
||||
UseTab: AlignWithSpaces
|
||||
...
|
||||
|
||||
@@ -0,0 +1,337 @@
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
##
|
||||
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
||||
|
||||
# User-specific files
|
||||
*.suo
|
||||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
*.userprefs
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
[Dd]ebugPublic/
|
||||
[Rr]elease/
|
||||
[Rr]eleases/
|
||||
x64/
|
||||
x86/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
[Ll]og/
|
||||
|
||||
# Visual Studio 2015/2017 cache/options directory
|
||||
.vs/
|
||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||
#wwwroot/
|
||||
|
||||
# Visual Studio 2017 auto generated files
|
||||
Generated\ Files/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
# NUNIT
|
||||
*.VisualState.xml
|
||||
TestResult.xml
|
||||
|
||||
# Build Results of an ATL Project
|
||||
[Dd]ebugPS/
|
||||
[Rr]eleasePS/
|
||||
dlldata.c
|
||||
|
||||
# Benchmark Results
|
||||
BenchmarkDotNet.Artifacts/
|
||||
|
||||
# .NET Core
|
||||
project.lock.json
|
||||
project.fragment.lock.json
|
||||
artifacts/
|
||||
**/Properties/launchSettings.json
|
||||
|
||||
# StyleCop
|
||||
StyleCopReport.xml
|
||||
|
||||
# Files built by Visual Studio
|
||||
*_i.c
|
||||
*_p.c
|
||||
*_i.h
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.iobj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.ipdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*.log
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.svclog
|
||||
*.scc
|
||||
|
||||
# Chutzpah Test files
|
||||
_Chutzpah*
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opendb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
*.VC.db
|
||||
*.VC.VC.opendb
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
*.sap
|
||||
|
||||
# Visual Studio Trace Files
|
||||
*.e2e
|
||||
|
||||
# TFS 2012 Local Workspace
|
||||
$tf/
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
*.DotSettings.user
|
||||
|
||||
# JustCode is a .NET coding add-in
|
||||
.JustCode
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# AxoCover is a Code Coverage Tool
|
||||
.axoCover/*
|
||||
!.axoCover/settings.json
|
||||
|
||||
# Visual Studio code coverage results
|
||||
*.coverage
|
||||
*.coveragexml
|
||||
|
||||
# NCrunch
|
||||
_NCrunch_*
|
||||
.*crunch*.local.xml
|
||||
nCrunchTemp_*
|
||||
|
||||
# MightyMoose
|
||||
*.mm.*
|
||||
AutoTest.Net/
|
||||
|
||||
# Web workbench (sass)
|
||||
.sass-cache/
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish/
|
||||
|
||||
# Publish Web Output
|
||||
*.[Pp]ublish.xml
|
||||
*.azurePubxml
|
||||
# Note: Comment the next line if you want to checkin your web deploy settings,
|
||||
# but database connection strings (with potential passwords) will be unencrypted
|
||||
*.pubxml
|
||||
*.publishproj
|
||||
|
||||
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||
# in these scripts will be unencrypted
|
||||
PublishScripts/
|
||||
|
||||
# NuGet Packages
|
||||
*.nupkg
|
||||
# The packages folder can be ignored because of Package Restore
|
||||
**/[Pp]ackages/*
|
||||
# except build/, which is used as an MSBuild target.
|
||||
!**/[Pp]ackages/build/
|
||||
# Uncomment if necessary however generally it will be regenerated when needed
|
||||
#!**/[Pp]ackages/repositories.config
|
||||
# NuGet v3's project.json files produces more ignorable files
|
||||
*.nuget.props
|
||||
*.nuget.targets
|
||||
|
||||
# Microsoft Azure Build Output
|
||||
csx/
|
||||
*.build.csdef
|
||||
|
||||
# Microsoft Azure Emulator
|
||||
ecf/
|
||||
rcf/
|
||||
|
||||
# Windows Store app package directories and files
|
||||
AppPackages/
|
||||
BundleArtifacts/
|
||||
Package.StoreAssociation.xml
|
||||
_pkginfo.txt
|
||||
*.appx
|
||||
|
||||
# Visual Studio cache files
|
||||
# files ending in .cache can be ignored
|
||||
*.[Cc]ache
|
||||
# but keep track of directories ending in .cache
|
||||
!*.[Cc]ache/
|
||||
|
||||
# Others
|
||||
ClientBin/
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.dbproj.schemaview
|
||||
*.jfm
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
orleans.codegen.cs
|
||||
|
||||
# Including strong name files can present a security risk
|
||||
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
||||
#*.snk
|
||||
|
||||
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||
#bower_components/
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
# Backup & report files from converting an old project file
|
||||
# to a newer Visual Studio version. Backup files are not needed,
|
||||
# because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
ServiceFabricBackup/
|
||||
*.rptproj.bak
|
||||
|
||||
# SQL Server files
|
||||
*.mdf
|
||||
*.ldf
|
||||
*.ndf
|
||||
|
||||
# Business Intelligence projects
|
||||
*.rdl.data
|
||||
*.bim.layout
|
||||
*.bim_*.settings
|
||||
*.rptproj.rsuser
|
||||
|
||||
# Microsoft Fakes
|
||||
FakesAssemblies/
|
||||
|
||||
# GhostDoc plugin setting file
|
||||
*.GhostDoc.xml
|
||||
|
||||
# Node.js Tools for Visual Studio
|
||||
.ntvs_analysis.dat
|
||||
node_modules/
|
||||
|
||||
# Visual Studio 6 build log
|
||||
*.plg
|
||||
|
||||
# Visual Studio 6 workspace options file
|
||||
*.opt
|
||||
|
||||
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||
*.vbw
|
||||
|
||||
# Visual Studio LightSwitch build output
|
||||
**/*.HTMLClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/ModelManifest.xml
|
||||
**/*.Server/GeneratedArtifacts
|
||||
**/*.Server/ModelManifest.xml
|
||||
_Pvt_Extensions
|
||||
|
||||
# Paket dependency manager
|
||||
.paket/paket.exe
|
||||
paket-files/
|
||||
|
||||
# FAKE - F# Make
|
||||
.fake/
|
||||
|
||||
# JetBrains Rider
|
||||
.idea/
|
||||
*.sln.iml
|
||||
|
||||
# CodeRush
|
||||
.cr/
|
||||
|
||||
# Python Tools for Visual Studio (PTVS)
|
||||
__pycache__/
|
||||
*.pyc
|
||||
|
||||
# Cake - Uncomment if you are using it
|
||||
# tools/**
|
||||
# !tools/packages.config
|
||||
|
||||
# Tabs Studio
|
||||
*.tss
|
||||
|
||||
# Telerik's JustMock configuration file
|
||||
*.jmconfig
|
||||
|
||||
# BizTalk build output
|
||||
*.btp.cs
|
||||
*.btm.cs
|
||||
*.odx.cs
|
||||
*.xsd.cs
|
||||
|
||||
# OpenCover UI analysis results
|
||||
OpenCover/
|
||||
|
||||
# Azure Stream Analytics local run output
|
||||
ASALocalRun/
|
||||
|
||||
# MSBuild Binary and Structured Log
|
||||
*.binlog
|
||||
|
||||
# NVidia Nsight GPU debugger configuration file
|
||||
*.nvuser
|
||||
|
||||
# MFractors (Xamarin productivity tool) working folder
|
||||
.mfractor/
|
||||
|
||||
*.out
|
||||
*.o
|
||||
*.d
|
||||
lib/libgfxd/libgfxd.a
|
||||
.vscode/
|
||||
ZAPD/BuildInfo.h
|
||||
@@ -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 = ca229f19b991c613c29afade3d70b100522cece1
|
||||
parent = 6ab539cda1870420d07e38e25db09208fd7b21a8
|
||||
method = merge
|
||||
cmdver = 0.4.3
|
||||
Vendored
+47
@@ -0,0 +1,47 @@
|
||||
pipeline {
|
||||
agent {
|
||||
label "ZAPD"
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('Build ZAPD') {
|
||||
steps {
|
||||
sh 'make -j'
|
||||
}
|
||||
}
|
||||
stage('Checkout oot') {
|
||||
steps {
|
||||
dir('oot') {
|
||||
git url: 'https://github.com/zeldaret/oot.git'
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Set up oot') {
|
||||
steps {
|
||||
dir('oot') {
|
||||
sh 'cp /usr/local/etc/roms/baserom_oot.z64 baserom_original.z64'
|
||||
|
||||
// Identical to `make setup` except for copying our newer ZAPD.out into oot
|
||||
sh 'git submodule update --init --recursive'
|
||||
sh 'make -C tools'
|
||||
sh 'cp ../ZAPD.out tools/ZAPD/'
|
||||
sh 'python3 fixbaserom.py'
|
||||
sh 'python3 extract_baserom.py'
|
||||
sh 'python3 extract_assets.py'
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Build oot') {
|
||||
steps {
|
||||
dir('oot') {
|
||||
sh 'make -j'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
cleanWs()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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.
|
||||
@@ -0,0 +1,78 @@
|
||||
OPTIMIZATION_ON ?= 1
|
||||
ASAN ?= 0
|
||||
DEPRECATION_OFF ?= 0
|
||||
DEBUG ?= 0
|
||||
CFLAGS ?=
|
||||
COPYCHECK_ARGS ?=
|
||||
|
||||
CC := g++
|
||||
INC := -I ZAPD -I lib/assimp/include -I lib/elfio -I lib/json/include -I lib/stb -I lib/tinygltf -I lib/libgfxd -I lib/tinyxml2
|
||||
CFLAGS += -fpic -std=c++17 -rdynamic -Wall -fno-omit-frame-pointer
|
||||
|
||||
ifneq ($(DEBUG),0)
|
||||
OPTIMIZATION_ON = 0
|
||||
DEPRECATION_OFF = 1
|
||||
CFLAGS += -g3 -DDEVELOPMENT
|
||||
COPYCHECK_ARGS += --devel
|
||||
endif
|
||||
|
||||
ifeq ($(OPTIMIZATION_ON),0)
|
||||
CFLAGS += -O0
|
||||
else
|
||||
CFLAGS += -O2
|
||||
endif
|
||||
ifneq ($(ASAN),0)
|
||||
CFLAGS += -fsanitize=address
|
||||
endif
|
||||
ifneq ($(DEPRECATION_OFF),0)
|
||||
CFLAGS += -DDEPRECATION_OFF
|
||||
endif
|
||||
# CFLAGS += -DTEXTURE_DEBUG
|
||||
|
||||
LDFLAGS := -ldl -lpng
|
||||
UNAME := $(shell uname)
|
||||
|
||||
FS_INC ?=
|
||||
ifneq ($(UNAME), Darwin)
|
||||
FS_INC += -lstdc++fs
|
||||
CFLAGS += -Wl,-export-dynamic
|
||||
endif
|
||||
|
||||
SRC_DIRS := ZAPD ZAPD/ZRoom ZAPD/ZRoom/Commands ZAPD/Overlays ZAPD/HighLevel
|
||||
|
||||
ZAPD_CPP_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.cpp))
|
||||
ZAPD_H_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.h))
|
||||
|
||||
CPP_FILES += $(ZAPD_CPP_FILES) lib/tinyxml2/tinyxml2.cpp
|
||||
O_FILES := $(CPP_FILES:.cpp=.o)
|
||||
|
||||
all: ZAPD.out copycheck
|
||||
|
||||
genbuildinfo:
|
||||
python3 ZAPD/genbuildinfo.py $(COPYCHECK_ARGS)
|
||||
|
||||
copycheck: ZAPD.out
|
||||
python3 copycheck.py
|
||||
|
||||
clean:
|
||||
rm -f $(O_FILES) ZAPD.out
|
||||
$(MAKE) -C lib/libgfxd clean
|
||||
|
||||
rebuild: clean all
|
||||
|
||||
format:
|
||||
clang-format-11 -i $(ZAPD_CPP_FILES) $(ZAPD_H_FILES)
|
||||
|
||||
.PHONY: all genbuildinfo copycheck clean rebuild format
|
||||
|
||||
%.o: %.cpp
|
||||
$(CC) $(CFLAGS) $(INC) -c $< -o $@ $(LDFLAGS)
|
||||
|
||||
ZAPD/Main.o: genbuildinfo ZAPD/Main.cpp
|
||||
$(CC) $(CFLAGS) $(INC) -c ZAPD/Main.cpp -o $@ $(LDFLAGS)
|
||||
|
||||
lib/libgfxd/libgfxd.a:
|
||||
$(MAKE) -C lib/libgfxd
|
||||
|
||||
ZAPD.out: $(O_FILES) lib/libgfxd/libgfxd.a
|
||||
$(CC) $(CFLAGS) $(INC) $(O_FILES) lib/libgfxd/libgfxd.a -o $@ $(FS_INC) $(LDFLAGS)
|
||||
@@ -0,0 +1,109 @@
|
||||
# ZAPD: Zelda Asset Processor for Decomp
|
||||
|
||||
## Compiling
|
||||
|
||||
### Dependencies
|
||||
|
||||
ZAPD needs a compiler with C++17 support.
|
||||
|
||||
ZAPD has the following library dependencies:
|
||||
|
||||
- `libpng`
|
||||
|
||||
In a Debian/Ubuntu based environment, those could be installed with the following command:
|
||||
|
||||
```bash
|
||||
sudo apt install libpng-dev
|
||||
```
|
||||
|
||||
### Building
|
||||
|
||||
#### Linux / *nix
|
||||
|
||||
ZAPD uses the clasic `Makefile` approach. To build just run `make` (or even better `make -j` for faster compilations).
|
||||
|
||||
You can configure a bit your ZAPD build with the following options:
|
||||
|
||||
- `OPTIMIZATION_ON`: If set to `0` optimizations will be disabled (compile with `-O0`). Any other value compiles with `-O2`. Defaults to `1`.
|
||||
- `ASAN`: If it is set to a non-zero then ZAPD will be compiled with Address Sanitizer enabled (`-fsanitize=address`). Defaults to `0`.
|
||||
- `DEPRECATION_OFF`: If it is set to a non-zero then deprecation warnings will be disabled. Defaults to `0`.
|
||||
- `DEBUG`: If non-zero, ZAPD will be compiled in _development mode_. This implies the following:
|
||||
- Debugging symbols enabled (`-g3`). They are disabled by default.
|
||||
- `OPTIMIZATION_ON=0`: Disables optimizations (`-O0`).
|
||||
- `DEPRECATION_OFF=1`: Disables deprecation warnings.
|
||||
|
||||
As an example, if you want to build ZAPD with optimizations disabled and use the address sanitizer, you could use the following command:
|
||||
|
||||
```bash
|
||||
make -j OPTIMIZATION_ON=0 ASAN=1
|
||||
```
|
||||
|
||||
#### Windows
|
||||
|
||||
This repository contains `vcxproj` files for compiling under Visual Studio environments. See `ZAPD/ZAPD.vcxproj`.
|
||||
|
||||
## Invoking ZAPD
|
||||
|
||||
ZAPD needs a _File parsing mode_ to be passed as first parameter. The options are:
|
||||
|
||||
- `e`: "Extraction" mode.
|
||||
- In this mode, ZAPD expects a XML file as input, a folder as ouput and a path to the baserom files.
|
||||
- ZAPD will read the XML and use it as a guide to extract the contents of the specified asset file from the baserom folder.
|
||||
- For more info of the format of those XMLs, see the [ZAPD extraction XML reference](docs/zapd_extraction_xml_reference.md).
|
||||
- `bsf`: "Build source file" mode.
|
||||
- This is an experimental mode.
|
||||
- It was going to be used to let you have XMLs that aren't just for extraction. Might get used, might not. Still need to experiment on that.
|
||||
- `btex`: "Build texture" mode.
|
||||
- In this mode, ZAPD expects a PNG file as input, a filename as ouput and a texture type parameter (`-tt`).
|
||||
- ZAPD will try to convert the given PNG into the contents of a `uint64_t` C array.
|
||||
- `bren`: "Build (render) background" mode.
|
||||
- In this mode, ZAPD expects a JPG file as input and a filename as ouput.
|
||||
- ZAPD will try to convert the given JPG into the contents of a `uint64_t` C array.
|
||||
- `blb`: "Build blob" mode.
|
||||
- In this mode, ZAPD expects a BIN file as input and a filename as ouput.
|
||||
- ZAPD will try to convert the given BIN into the contents of a `uint8_t` C array.
|
||||
- `bovl`: "Build overlay" mode.
|
||||
- In this mode, ZAPD expects an overlay C file as input, a filename as ouput and an overlay configuration path (`-cfg`).
|
||||
- ZAPD will generate a reloc `.s` file.
|
||||
|
||||
ZAPD also accepts the following list of extra parameters:
|
||||
|
||||
- `-i PATH` / `--inputpath PATH`: Set input path.
|
||||
- `-o PATH` / `--outputpath PATH`: Set output path.
|
||||
- `-b PATH` / `--baserompath`: Set baserom path.
|
||||
- Can be used only in `e` or `bsf` modes.
|
||||
- `-osf PATH`: Set source output path. This is the path where the `.c` and `.h` files will be extracted to. If omitted, it will use the value passed to `--outputpath` parameter.
|
||||
- `-gsf MODE`: Generate source file during extraction. If `MODE` is `1`, C source files will be generated.
|
||||
- Can be used only in `e` mode.
|
||||
- `-crc` / `--output-crc`: Outputs a CRC file for each extracted texture.
|
||||
- Can be used only in `e` or `bsf` modes.
|
||||
- `-ulzdl MODE`: Use "Legacy ZDisplayList" instead of `libgfxd`. Set `MODE` to `1` to enable it.
|
||||
- Can be used only in `e` or `bsf` modes.
|
||||
- `-profile MODE`: Enable profiling. Set `MODE` to `1` to enable it.
|
||||
- `-uer MODE`: Split resources into their individual components (enabled by default). Set `MODE` to non-`1` to disable it.
|
||||
- `-tt TYPE`: Set texture type.
|
||||
- Can be used only in mode `btex`.
|
||||
- Valid values:
|
||||
- `rgba32`
|
||||
- `rgb5a1`
|
||||
- `i4`
|
||||
- `i8`
|
||||
- `ia4`
|
||||
- `ia8`
|
||||
- `ia16`
|
||||
- `ci4`
|
||||
- `ci8`
|
||||
- `-cfg PATH`: Set cfg path (for overlays).
|
||||
- Can be used only in `bovl` mode.
|
||||
- `-rconf PATH` Read Config File.
|
||||
- `-eh`: Enable error handler.
|
||||
- Only available in non-Windows environments.
|
||||
- `-v MODE`: Enable verbosity. Currently there are 3 possible values:
|
||||
- `0`: Default. Completely silent (except for warnings and errors).
|
||||
- `1`: Information.
|
||||
- `2` (and higher): Debug.
|
||||
- `-wu` / `--warn-unaccounted`: Enable warnings for each unaccounted block of data found.
|
||||
- Can be used only in `e` or `bsf` modes.
|
||||
- `-tm MODE`: Test Mode (enables certain experimental features). To enable it, set `MODE` to `1`.
|
||||
|
||||
Additionally, you can pass the flag `--version` to see the current ZAPD version. If that flag is passed, ZAPD will ignore any other parameter passed.
|
||||
@@ -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
|
||||
@@ -0,0 +1,159 @@
|
||||
#pragma once
|
||||
|
||||
#include <limits>
|
||||
#include <stdint.h>
|
||||
#include <vector>
|
||||
|
||||
class BitConverter
|
||||
{
|
||||
public:
|
||||
static inline int8_t ToInt8BE(const uint8_t* data, int32_t offset)
|
||||
{
|
||||
return (uint8_t)data[offset + 0];
|
||||
}
|
||||
|
||||
static inline int8_t ToInt8BE(const std::vector<uint8_t>& data, int32_t offset)
|
||||
{
|
||||
return (uint8_t)data[offset + 0];
|
||||
}
|
||||
|
||||
static inline uint8_t ToUInt8BE(const uint8_t* data, int32_t offset)
|
||||
{
|
||||
return (uint8_t)data[offset + 0];
|
||||
}
|
||||
|
||||
static inline uint8_t ToUInt8BE(const std::vector<uint8_t>& data, int32_t offset)
|
||||
{
|
||||
return (uint8_t)data[offset + 0];
|
||||
}
|
||||
|
||||
static inline int16_t ToInt16BE(const uint8_t* data, int32_t offset)
|
||||
{
|
||||
return ((uint16_t)data[offset + 0] << 8) + (uint16_t)data[offset + 1];
|
||||
}
|
||||
|
||||
static inline int16_t ToInt16BE(const std::vector<uint8_t>& data, int32_t offset)
|
||||
{
|
||||
return ((uint16_t)data[offset + 0] << 8) + (uint16_t)data[offset + 1];
|
||||
}
|
||||
|
||||
static inline uint16_t ToUInt16BE(const uint8_t* data, int32_t offset)
|
||||
{
|
||||
return ((uint16_t)data[offset + 0] << 8) + (uint16_t)data[offset + 1];
|
||||
}
|
||||
|
||||
static inline uint16_t ToUInt16BE(const std::vector<uint8_t>& data, int32_t offset)
|
||||
{
|
||||
return ((uint16_t)data[offset + 0] << 8) + (uint16_t)data[offset + 1];
|
||||
}
|
||||
|
||||
static inline int32_t ToInt32BE(const uint8_t* data, int32_t offset)
|
||||
{
|
||||
return ((uint32_t)data[offset + 0] << 24) + ((uint32_t)data[offset + 1] << 16) +
|
||||
((uint32_t)data[offset + 2] << 8) + (uint32_t)data[offset + 3];
|
||||
}
|
||||
|
||||
static inline int32_t ToInt32BE(const std::vector<uint8_t>& data, int32_t offset)
|
||||
{
|
||||
return ((uint32_t)data[offset + 0] << 24) + ((uint32_t)data[offset + 1] << 16) +
|
||||
((uint32_t)data[offset + 2] << 8) + (uint32_t)data[offset + 3];
|
||||
}
|
||||
|
||||
static inline uint32_t ToUInt32BE(const uint8_t* data, int32_t offset)
|
||||
{
|
||||
return ((uint32_t)data[offset + 0] << 24) + ((uint32_t)data[offset + 1] << 16) +
|
||||
((uint32_t)data[offset + 2] << 8) + (uint32_t)data[offset + 3];
|
||||
}
|
||||
|
||||
static inline uint32_t ToUInt32BE(const std::vector<uint8_t>& data, int32_t offset)
|
||||
{
|
||||
return ((uint32_t)data[offset + 0] << 24) + ((uint32_t)data[offset + 1] << 16) +
|
||||
((uint32_t)data[offset + 2] << 8) + (uint32_t)data[offset + 3];
|
||||
}
|
||||
|
||||
static inline int64_t ToInt64BE(const uint8_t* data, int32_t 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 int64_t ToInt64BE(const std::vector<uint8_t>& data, int32_t 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 ToUInt64BE(const uint8_t* data, int32_t 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 ToUInt64BE(const std::vector<uint8_t>& data, int32_t 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(const uint8_t* data, int32_t offset)
|
||||
{
|
||||
float value;
|
||||
uint32_t floatData = ((uint32_t)data[offset + 0] << 24) +
|
||||
((uint32_t)data[offset + 1] << 16) +
|
||||
((uint32_t)data[offset + 2] << 8) + (uint32_t)data[offset + 3];
|
||||
static_assert(sizeof(uint32_t) == sizeof(float));
|
||||
std::memcpy(&value, &floatData, sizeof(value));
|
||||
return value;
|
||||
}
|
||||
|
||||
static inline float ToFloatBE(const std::vector<uint8_t>& data, int32_t offset)
|
||||
{
|
||||
float value;
|
||||
uint32_t floatData = ((uint32_t)data[offset + 0] << 24) +
|
||||
((uint32_t)data[offset + 1] << 16) +
|
||||
((uint32_t)data[offset + 2] << 8) + (uint32_t)data[offset + 3];
|
||||
static_assert(sizeof(uint32_t) == sizeof(float));
|
||||
std::memcpy(&value, &floatData, sizeof(value));
|
||||
return value;
|
||||
}
|
||||
|
||||
static inline double ToDoubleBE(const uint8_t* data, int32_t offset)
|
||||
{
|
||||
double value;
|
||||
uint64_t floatData =
|
||||
((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_assert(sizeof(uint64_t) == sizeof(double));
|
||||
// Checks if the float format on the platform the ZAPD binary is running on supports the
|
||||
// same float format as the object file.
|
||||
static_assert(std::numeric_limits<float>::is_iec559);
|
||||
std::memcpy(&value, &floatData, sizeof(value));
|
||||
return value;
|
||||
}
|
||||
|
||||
static inline double ToDoubleBE(const std::vector<uint8_t>& data, int32_t offset)
|
||||
{
|
||||
double value;
|
||||
uint64_t floatData =
|
||||
((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_assert(sizeof(uint64_t) == sizeof(double));
|
||||
// Checks if the float format on the platform the ZAPD binary is running on supports the
|
||||
// same float format as the object file.
|
||||
static_assert(std::numeric_limits<double>::is_iec559);
|
||||
std::memcpy(&value, &floatData, sizeof(value));
|
||||
return value;
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
static uint32_t CRC32B(unsigned char* message, int32_t size)
|
||||
{
|
||||
int32_t byte, crc;
|
||||
int32_t mask;
|
||||
|
||||
crc = 0xFFFFFFFF;
|
||||
|
||||
for (int32_t i = 0; i < size; i++)
|
||||
{
|
||||
byte = message[i];
|
||||
crc = crc ^ byte;
|
||||
|
||||
for (int32_t j = 7; j >= 0; j--)
|
||||
{
|
||||
mask = -(crc & 1);
|
||||
crc = (crc >> 1) ^ (0xEDB88320 & mask);
|
||||
}
|
||||
}
|
||||
|
||||
return ~(uint32_t)(crc);
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
#include "Declaration.h"
|
||||
|
||||
Declaration::Declaration(DeclarationAlignment nAlignment, DeclarationPadding nPadding, size_t nSize,
|
||||
std::string nText)
|
||||
{
|
||||
alignment = nAlignment;
|
||||
padding = nPadding;
|
||||
size = nSize;
|
||||
text = nText;
|
||||
}
|
||||
|
||||
Declaration::Declaration(DeclarationAlignment nAlignment, size_t nSize, std::string nVarType,
|
||||
std::string nVarName, bool nIsArray, std::string nText)
|
||||
: Declaration(nAlignment, DeclarationPadding::None, nSize, nText)
|
||||
{
|
||||
varType = nVarType;
|
||||
varName = nVarName;
|
||||
isArray = nIsArray;
|
||||
}
|
||||
|
||||
Declaration::Declaration(DeclarationAlignment nAlignment, DeclarationPadding nPadding, size_t nSize,
|
||||
std::string nVarType, std::string nVarName, bool nIsArray,
|
||||
std::string nText)
|
||||
: Declaration(nAlignment, nPadding, nSize, nText)
|
||||
{
|
||||
varType = nVarType;
|
||||
varName = nVarName;
|
||||
isArray = nIsArray;
|
||||
}
|
||||
|
||||
Declaration::Declaration(DeclarationAlignment nAlignment, size_t nSize, std::string nVarType,
|
||||
std::string nVarName, bool nIsArray, size_t nArrayItemCnt,
|
||||
std::string nText)
|
||||
: Declaration(nAlignment, DeclarationPadding::None, nSize, nText)
|
||||
{
|
||||
varType = nVarType;
|
||||
varName = nVarName;
|
||||
isArray = nIsArray;
|
||||
arrayItemCnt = nArrayItemCnt;
|
||||
}
|
||||
|
||||
Declaration::Declaration(DeclarationAlignment nAlignment, size_t nSize, std::string nVarType,
|
||||
std::string nVarName, bool nIsArray, std::string nArrayItemCntStr,
|
||||
std::string nText)
|
||||
: Declaration(nAlignment, DeclarationPadding::None, nSize, nText)
|
||||
{
|
||||
varType = nVarType;
|
||||
varName = nVarName;
|
||||
isArray = nIsArray;
|
||||
arrayItemCntStr = nArrayItemCntStr;
|
||||
}
|
||||
|
||||
Declaration::Declaration(DeclarationAlignment nAlignment, size_t nSize, std::string nVarType,
|
||||
std::string nVarName, bool nIsArray, size_t nArrayItemCnt,
|
||||
std::string nText, bool nIsExternal)
|
||||
: Declaration(nAlignment, nSize, nVarType, nVarName, nIsArray, nArrayItemCnt, nText)
|
||||
{
|
||||
isExternal = nIsExternal;
|
||||
}
|
||||
|
||||
Declaration::Declaration(DeclarationAlignment nAlignment, DeclarationPadding nPadding, size_t nSize,
|
||||
std::string nVarType, std::string nVarName, bool nIsArray,
|
||||
size_t nArrayItemCnt, std::string nText)
|
||||
: Declaration(nAlignment, nPadding, nSize, nText)
|
||||
{
|
||||
varType = nVarType;
|
||||
varName = nVarName;
|
||||
isArray = nIsArray;
|
||||
arrayItemCnt = nArrayItemCnt;
|
||||
}
|
||||
|
||||
Declaration::Declaration(std::string nIncludePath, size_t nSize, std::string nVarType,
|
||||
std::string nVarName)
|
||||
: Declaration(DeclarationAlignment::None, DeclarationPadding::None, nSize, "")
|
||||
{
|
||||
includePath = nIncludePath;
|
||||
varType = nVarType;
|
||||
varName = nVarName;
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
enum class DeclarationAlignment
|
||||
{
|
||||
None,
|
||||
Align4,
|
||||
Align8,
|
||||
Align16
|
||||
};
|
||||
|
||||
enum class DeclarationPadding
|
||||
{
|
||||
None,
|
||||
Pad4,
|
||||
Pad8,
|
||||
Pad16
|
||||
};
|
||||
|
||||
class Declaration
|
||||
{
|
||||
public:
|
||||
DeclarationAlignment alignment;
|
||||
DeclarationPadding padding;
|
||||
size_t size = 0;
|
||||
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 isExternal = false;
|
||||
bool isArray = false;
|
||||
size_t arrayItemCnt = 0;
|
||||
std::string arrayItemCntStr;
|
||||
std::vector<uint32_t> references;
|
||||
bool isUnaccounted = false;
|
||||
bool isPlaceholder = false;
|
||||
|
||||
Declaration(DeclarationAlignment nAlignment, size_t nSize, std::string nVarType,
|
||||
std::string nVarName, bool nIsArray, std::string nText);
|
||||
Declaration(DeclarationAlignment nAlignment, DeclarationPadding nPadding, size_t nSize,
|
||||
std::string nVarType, std::string nVarName, bool nIsArray, std::string nText);
|
||||
Declaration(DeclarationAlignment nAlignment, size_t nSize, std::string nVarType,
|
||||
std::string nVarName, bool nIsArray, size_t nArrayItemCnt, std::string nText);
|
||||
Declaration(DeclarationAlignment nAlignment, size_t nSize, std::string nVarType,
|
||||
std::string nVarName, bool nIsArray, std::string nArrayItemCntStr,
|
||||
std::string nText);
|
||||
Declaration(DeclarationAlignment nAlignment, size_t nSize, std::string nVarType,
|
||||
std::string nVarName, bool nIsArray, size_t nArrayItemCnt, std::string nText,
|
||||
bool nIsExternal);
|
||||
Declaration(DeclarationAlignment nAlignment, DeclarationPadding nPadding, size_t nSize,
|
||||
std::string nVarType, std::string nVarName, bool nIsArray, size_t nArrayItemCnt,
|
||||
std::string nText);
|
||||
Declaration(std::string nIncludePath, size_t nSize, std::string nVarType, std::string nVarName);
|
||||
|
||||
protected:
|
||||
Declaration(DeclarationAlignment nAlignment, DeclarationPadding nPadding, size_t nSize,
|
||||
std::string nText);
|
||||
};
|
||||
@@ -0,0 +1,39 @@
|
||||
#pragma once
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#if __has_include(<filesystem>)
|
||||
#include <filesystem>
|
||||
namespace fs = std::filesystem;
|
||||
#else
|
||||
#include <experimental/filesystem>
|
||||
namespace fs = std::experimental::filesystem;
|
||||
#endif
|
||||
|
||||
#include "StringHelper.h"
|
||||
|
||||
class Directory
|
||||
{
|
||||
public:
|
||||
static std::string GetCurrentDirectory() { return fs::current_path().u8string(); }
|
||||
|
||||
static bool Exists(const std::string& path) { return fs::exists(fs::path(path)); }
|
||||
|
||||
static void CreateDirectory(const std::string& path)
|
||||
{
|
||||
std::string curPath = "";
|
||||
std::vector<std::string> split = StringHelper::Split(path, "/");
|
||||
|
||||
for (std::string s : split)
|
||||
{
|
||||
curPath += s + "/";
|
||||
|
||||
if (!Exists(curPath))
|
||||
fs::create_directory(curPath);
|
||||
}
|
||||
|
||||
// fs::create_directory(path);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,65 @@
|
||||
#pragma once
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "StringHelper.h"
|
||||
|
||||
class File
|
||||
{
|
||||
public:
|
||||
static bool Exists(const 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(const std::string& filePath)
|
||||
{
|
||||
std::ifstream file(filePath, std::ios::in | std::ios::binary | std::ios::ate);
|
||||
int32_t fileSize = (int32_t)file.tellg();
|
||||
file.seekg(0);
|
||||
char* data = new char[fileSize];
|
||||
file.read(data, fileSize);
|
||||
std::vector<uint8_t> result = std::vector<uint8_t>(data, data + fileSize);
|
||||
delete[] data;
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
static std::string ReadAllText(const std::string& filePath)
|
||||
{
|
||||
std::ifstream file(filePath, std::ios::in | std::ios::binary | std::ios::ate);
|
||||
int32_t fileSize = (int32_t)file.tellg();
|
||||
file.seekg(0);
|
||||
char* data = new char[fileSize + 1];
|
||||
memset(data, 0, fileSize + 1);
|
||||
file.read(data, fileSize);
|
||||
std::string str = std::string((const char*)data);
|
||||
delete[] data;
|
||||
|
||||
return str;
|
||||
};
|
||||
|
||||
static std::vector<std::string> ReadAllLines(const std::string& filePath)
|
||||
{
|
||||
std::string text = ReadAllText(filePath);
|
||||
std::vector<std::string> lines = StringHelper::Split(text, "\n");
|
||||
|
||||
return lines;
|
||||
};
|
||||
|
||||
static void WriteAllBytes(const std::string& filePath, const std::vector<uint8_t>& data)
|
||||
{
|
||||
std::ofstream file(filePath, std::ios::binary);
|
||||
file.write((char*)data.data(), data.size());
|
||||
};
|
||||
|
||||
static void WriteAllText(const std::string& filePath, const std::string& text)
|
||||
{
|
||||
std::ofstream file(filePath, std::ios::out);
|
||||
file.write(text.c_str(), text.size());
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,186 @@
|
||||
#include "Globals.h"
|
||||
#include <algorithm>
|
||||
#include "File.h"
|
||||
#include "Path.h"
|
||||
#include "tinyxml2.h"
|
||||
|
||||
using namespace tinyxml2;
|
||||
|
||||
Globals* Globals::Instance;
|
||||
|
||||
Globals::Globals()
|
||||
{
|
||||
Instance = this;
|
||||
|
||||
files = std::vector<ZFile*>();
|
||||
segments = std::vector<int32_t>();
|
||||
symbolMap = std::map<uint32_t, std::string>();
|
||||
segmentRefs = std::map<int32_t, std::string>();
|
||||
segmentRefFiles = std::map<int32_t, ZFile*>();
|
||||
game = ZGame::OOT_RETAIL;
|
||||
genSourceFile = true;
|
||||
testMode = false;
|
||||
profile = false;
|
||||
useLegacyZDList = false;
|
||||
useExternalResources = true;
|
||||
lastScene = nullptr;
|
||||
verbosity = VerbosityLevel::VERBOSITY_SILENT;
|
||||
}
|
||||
|
||||
std::string Globals::FindSymbolSegRef(int32_t segNumber, uint32_t symbolAddress)
|
||||
{
|
||||
if (segmentRefs.find(segNumber) != segmentRefs.end())
|
||||
{
|
||||
if (segmentRefFiles.find(segNumber) == segmentRefFiles.end())
|
||||
{
|
||||
XMLDocument doc;
|
||||
std::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";
|
||||
|
||||
for (XMLElement* child = root->FirstChildElement(); child != NULL;
|
||||
child = child->NextSiblingElement())
|
||||
{
|
||||
if (std::string(child->Name()) == "File")
|
||||
{
|
||||
ZFile* file = new ZFile(fileMode, child, "", "", "", filePath, true);
|
||||
file->GeneratePlaceholderDeclarations();
|
||||
segmentRefFiles[segNumber] = file;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return segmentRefFiles[segNumber]->GetDeclarationName(symbolAddress, "ERROR");
|
||||
}
|
||||
|
||||
return "ERROR";
|
||||
}
|
||||
|
||||
void Globals::ReadConfigFile(const std::string& configFilePath)
|
||||
{
|
||||
XMLDocument doc;
|
||||
XMLError eResult = doc.LoadFile(configFilePath.c_str());
|
||||
|
||||
if (eResult != tinyxml2::XML_SUCCESS)
|
||||
{
|
||||
throw std::runtime_error("Error: Unable to read config file.");
|
||||
return;
|
||||
}
|
||||
|
||||
XMLNode* root = doc.FirstChild();
|
||||
|
||||
if (root == nullptr)
|
||||
return;
|
||||
|
||||
for (XMLElement* child = root->FirstChildElement(); child != NULL;
|
||||
child = child->NextSiblingElement())
|
||||
{
|
||||
if (std::string(child->Name()) == "SymbolMap")
|
||||
{
|
||||
std::string fileName = std::string(child->Attribute("File"));
|
||||
GenSymbolMap(Path::GetDirectoryName(configFilePath) + "/" + fileName);
|
||||
}
|
||||
else if (std::string(child->Name()) == "Segment")
|
||||
{
|
||||
std::string fileName = std::string(child->Attribute("File"));
|
||||
int32_t segNumber = child->IntAttribute("Number");
|
||||
segmentRefs[segNumber] = fileName;
|
||||
}
|
||||
else if (std::string(child->Name()) == "ActorList")
|
||||
{
|
||||
std::string fileName = std::string(child->Attribute("File"));
|
||||
std::vector<std::string> lines =
|
||||
File::ReadAllLines(Path::GetDirectoryName(configFilePath) + "/" + fileName);
|
||||
|
||||
for (std::string line : lines)
|
||||
cfg.actorList.push_back(StringHelper::Strip(line, "\r"));
|
||||
}
|
||||
else if (std::string(child->Name()) == "ObjectList")
|
||||
{
|
||||
std::string fileName = std::string(child->Attribute("File"));
|
||||
std::vector<std::string> lines =
|
||||
File::ReadAllLines(Path::GetDirectoryName(configFilePath) + "/" + fileName);
|
||||
|
||||
for (std::string line : lines)
|
||||
cfg.objectList.push_back(StringHelper::Strip(line, "\r"));
|
||||
}
|
||||
else if (std::string(child->Name()) == "TexturePool")
|
||||
{
|
||||
std::string fileName = std::string(child->Attribute("File"));
|
||||
ReadTexturePool(Path::GetDirectoryName(configFilePath) + "/" + fileName);
|
||||
}
|
||||
else if (std::string(child->Name()) == "BGConfig")
|
||||
{
|
||||
cfg.bgScreenWidth = child->IntAttribute("ScreenWidth", 320);
|
||||
cfg.bgScreenHeight = child->IntAttribute("ScreenHeight", 240);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Globals::ReadTexturePool(const std::string& texturePoolXmlPath)
|
||||
{
|
||||
XMLDocument doc;
|
||||
XMLError eResult = doc.LoadFile(texturePoolXmlPath.c_str());
|
||||
|
||||
if (eResult != tinyxml2::XML_SUCCESS)
|
||||
{
|
||||
fprintf(stderr, "Warning: Unable to read texture pool XML with error code %i\n", eResult);
|
||||
return;
|
||||
}
|
||||
|
||||
XMLNode* root = doc.FirstChild();
|
||||
|
||||
if (root == nullptr)
|
||||
return;
|
||||
|
||||
for (XMLElement* child = root->FirstChildElement(); child != NULL;
|
||||
child = child->NextSiblingElement())
|
||||
{
|
||||
if (std::string(child->Name()) == "Texture")
|
||||
{
|
||||
std::string crcStr = std::string(child->Attribute("CRC"));
|
||||
fs::path texPath = std::string(child->Attribute("Path"));
|
||||
std::string texName = "";
|
||||
|
||||
uint32_t crc = strtoul(crcStr.c_str(), NULL, 16);
|
||||
|
||||
cfg.texturePool[crc].path = texPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Globals::GenSymbolMap(const std::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(int32_t segment, ZFile* file)
|
||||
{
|
||||
if (std::find(segments.begin(), segments.end(), segment) == segments.end())
|
||||
segments.push_back(segment);
|
||||
|
||||
segmentRefs[segment] = file->GetXmlFilePath();
|
||||
segmentRefFiles[segment] = file;
|
||||
}
|
||||
|
||||
bool Globals::HasSegment(int32_t segment)
|
||||
{
|
||||
return std::find(segments.begin(), segments.end(), segment) != segments.end();
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "ZFile.h"
|
||||
#include "ZRoom/ZRoom.h"
|
||||
#include "ZTexture.h"
|
||||
|
||||
enum class VerbosityLevel
|
||||
{
|
||||
VERBOSITY_SILENT,
|
||||
VERBOSITY_INFO,
|
||||
VERBOSITY_DEBUG
|
||||
};
|
||||
|
||||
struct TexturePoolEntry
|
||||
{
|
||||
fs::path path = ""; // Path to Shared Texture
|
||||
};
|
||||
|
||||
class GameConfig
|
||||
{
|
||||
public:
|
||||
std::map<int32_t, std::string> segmentRefs;
|
||||
std::map<int32_t, ZFile*> segmentRefFiles;
|
||||
std::map<uint32_t, std::string> symbolMap;
|
||||
std::vector<std::string> actorList;
|
||||
std::vector<std::string> objectList;
|
||||
std::map<uint32_t, TexturePoolEntry> texturePool; // Key = CRC
|
||||
|
||||
// ZBackground
|
||||
uint32_t bgScreenWidth = 320, bgScreenHeight = 240;
|
||||
|
||||
GameConfig() = default;
|
||||
};
|
||||
|
||||
class Globals
|
||||
{
|
||||
public:
|
||||
static Globals* Instance;
|
||||
|
||||
bool genSourceFile; // Used for extraction
|
||||
bool useExternalResources;
|
||||
bool testMode; // Enables certain experimental features
|
||||
bool outputCrc = false;
|
||||
bool profile; // Measure performance of certain operations
|
||||
bool useLegacyZDList;
|
||||
VerbosityLevel verbosity; // ZAPD outputs additional information
|
||||
ZFileMode fileMode;
|
||||
fs::path baseRomPath, inputPath, outputPath, sourceOutputPath, cfgPath;
|
||||
TextureType texType;
|
||||
ZGame game;
|
||||
GameConfig cfg;
|
||||
bool warnUnaccounted = false;
|
||||
|
||||
std::vector<ZFile*> files;
|
||||
std::vector<int32_t> segments;
|
||||
std::map<int32_t, std::string> segmentRefs;
|
||||
std::map<int32_t, ZFile*> segmentRefFiles;
|
||||
ZRoom* lastScene;
|
||||
std::map<uint32_t, std::string> symbolMap;
|
||||
|
||||
Globals();
|
||||
std::string FindSymbolSegRef(int32_t segNumber, uint32_t symbolAddress);
|
||||
void ReadConfigFile(const std::string& configFilePath);
|
||||
void ReadTexturePool(const std::string& texturePoolXmlPath);
|
||||
void GenSymbolMap(const std::string& symbolMapPath);
|
||||
void AddSegment(int32_t segment, ZFile* file);
|
||||
bool HasSegment(int32_t 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
Reference in New Issue
Block a user