mirror of https://github.com/zeldaret/tmc.git
Merge branch 'fix-offset-calculation' of github.com:octorock/tmc into refactorTools
This commit is contained in:
commit
48aa1d7720
11
Makefile
11
Makefile
|
@ -149,7 +149,7 @@ SUBDIRS := $(sort $(dir $(OBJS)))
|
||||||
|
|
||||||
$(shell mkdir -p $(SUBDIRS))
|
$(shell mkdir -p $(SUBDIRS))
|
||||||
|
|
||||||
.PHONY: all setup clean-tools mostlyclean clean tidy tools extractassets
|
.PHONY: all setup clean-tools mostlyclean clean tidy tools extractassets buildassets custom
|
||||||
|
|
||||||
MAKEFLAGS += --no-print-directory
|
MAKEFLAGS += --no-print-directory
|
||||||
|
|
||||||
|
@ -162,6 +162,9 @@ all: build/extracted_assets_$(GAME_VERSION)
|
||||||
target: $(ROM)
|
target: $(ROM)
|
||||||
@$(SHA1) $(BUILD_NAME).sha1
|
@$(SHA1) $(BUILD_NAME).sha1
|
||||||
|
|
||||||
|
custom: buildassets
|
||||||
|
@$(MAKE) target GAME_VERSION=$(GAME_VERSION)
|
||||||
|
|
||||||
# kept for backwards compat
|
# kept for backwards compat
|
||||||
compare: $(ROM)
|
compare: $(ROM)
|
||||||
@$(SHA1) $(BUILD_NAME).sha1
|
@$(SHA1) $(BUILD_NAME).sha1
|
||||||
|
@ -173,7 +176,7 @@ setup: tools
|
||||||
tools: $(GFX)
|
tools: $(GFX)
|
||||||
|
|
||||||
$(GFX) $(AIF) $(MID) $(SCANINC) $(PREPROC) $(FIX) $(ASSET_PROCESSOR) tools/bin/agb2mid tools/bin/tmc_strings tools/bin/bin2c &:
|
$(GFX) $(AIF) $(MID) $(SCANINC) $(PREPROC) $(FIX) $(ASSET_PROCESSOR) tools/bin/agb2mid tools/bin/tmc_strings tools/bin/bin2c &:
|
||||||
mkdir tools/cmake-build
|
mkdir -p tools/cmake-build
|
||||||
unset CC CXX AS LD && cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=tools -S tools -B tools/cmake-build
|
unset CC CXX AS LD && cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=tools -S tools -B tools/cmake-build
|
||||||
cmake --build tools/cmake-build -j
|
cmake --build tools/cmake-build -j
|
||||||
cmake --install tools/cmake-build
|
cmake --install tools/cmake-build
|
||||||
|
@ -187,6 +190,10 @@ build/extracted_assets_%: $(ASSET_CONFIGS) $(TRANSLATIONS)
|
||||||
extractassets:
|
extractassets:
|
||||||
$(ASSET_PROCESSOR) convert $(GAME_VERSION) $(ASSET_BUILDDIR)
|
$(ASSET_PROCESSOR) convert $(GAME_VERSION) $(ASSET_BUILDDIR)
|
||||||
|
|
||||||
|
# Build the assets from the human readable form
|
||||||
|
buildassets:
|
||||||
|
$(ASSET_PROCESSOR) build $(GAME_VERSION) $(ASSET_BUILDDIR)
|
||||||
|
|
||||||
mostlyclean: tidy
|
mostlyclean: tidy
|
||||||
rm -f sound/direct_sound_samples/*.bin
|
rm -f sound/direct_sound_samples/*.bin
|
||||||
rm -f $(SONG_OBJS) $(MID_SUBDIR)/*.s
|
rm -f $(SONG_OBJS) $(MID_SUBDIR)/*.s
|
||||||
|
|
|
@ -51750,28 +51750,19 @@
|
||||||
"path": "sprites/gSprite_Link.4bpp",
|
"path": "sprites/gSprite_Link.4bpp",
|
||||||
"start": 1289748,
|
"start": 1289748,
|
||||||
"size": 581216,
|
"size": 581216,
|
||||||
"type": "gfx",
|
"type": "gfx"
|
||||||
"options": {
|
|
||||||
"width": 4
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "sprites/gSprite_081C8C74.4bpp",
|
"path": "sprites/gSprite_081C8C74.4bpp",
|
||||||
"start": 1870964,
|
"start": 1870964,
|
||||||
"size": 59904,
|
"size": 59904,
|
||||||
"type": "gfx",
|
"type": "gfx"
|
||||||
"options": {
|
|
||||||
"width": 4
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "sprites/gSprite_081D7674.4bpp",
|
"path": "sprites/gSprite_081D7674.4bpp",
|
||||||
"start": 1930868,
|
"start": 1930868,
|
||||||
"size": 33216,
|
"size": 33216,
|
||||||
"type": "gfx",
|
"type": "gfx"
|
||||||
"options": {
|
|
||||||
"width": 4
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "sprites/gSprite_081DF834/unk_0.4bpp",
|
"path": "sprites/gSprite_081DF834/unk_0.4bpp",
|
||||||
|
@ -52015,18 +52006,18 @@
|
||||||
{
|
{
|
||||||
"path": "sprites/gSprite_081FF1B4/unk_3_1.4bpp",
|
"path": "sprites/gSprite_081FF1B4/unk_3_1.4bpp",
|
||||||
"start": 2243508,
|
"start": 2243508,
|
||||||
"size": 4986,
|
"size": 4960,
|
||||||
"type": "gfx"
|
"type": "gfx"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "sprites/gSprite_081FF1B4/config_1.txt",
|
"path": "sprites/gSprite_081FF1B4/config_1.txt",
|
||||||
"start": 2248494,
|
"start": 2248468,
|
||||||
"size": 1024
|
"size": 1024
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "sprites/gSprite_081FF1B4/unk_3_2.4bpp",
|
"path": "sprites/gSprite_081FF1B4/unk_3_2.4bpp",
|
||||||
"start": 2249518,
|
"start": 2249492,
|
||||||
"size": 4198,
|
"size": 4224,
|
||||||
"type": "gfx"
|
"type": "gfx"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -52515,116 +52506,6 @@
|
||||||
"JP": -864
|
"JP": -864
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"path": "data_08132B30/gUnk_086926A0.bin",
|
|
||||||
"start": 6891168,
|
|
||||||
"size": 224
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "data_08132B30/gUnk_08692780.bin",
|
|
||||||
"start": 6891392,
|
|
||||||
"size": 224
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "data_08132B30/gUnk_08692860.bin",
|
|
||||||
"start": 6891616,
|
|
||||||
"size": 224
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "data_08132B30/gUnk_08692940.bin",
|
|
||||||
"start": 6891840,
|
|
||||||
"size": 224
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "data_08132B30/gUnk_08692A20.bin",
|
|
||||||
"start": 6892064,
|
|
||||||
"size": 224
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "data_08132B30/gUnk_08692B00.bin",
|
|
||||||
"start": 6892288,
|
|
||||||
"size": 224
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "data_08132B30/gUnk_08692BE0.bin",
|
|
||||||
"start": 6892512,
|
|
||||||
"size": 224
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "data_08132B30/gUnk_08692CC0.bin",
|
|
||||||
"start": 6892736,
|
|
||||||
"size": 224
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "data_08132B30/gUnk_08692DA0.bin",
|
|
||||||
"start": 6892960,
|
|
||||||
"size": 224
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "data_08132B30/gUnk_08692E80.bin",
|
|
||||||
"start": 6893184,
|
|
||||||
"size": 224
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "data_08132B30/gUnk_08692F60.bin",
|
|
||||||
"start": 6893408,
|
|
||||||
"size": 64
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "data_08132B30/gUnk_08692F60_1.bin",
|
|
||||||
"start": 6893472,
|
|
||||||
"size": 16320
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "data_08132B30/gUnk_08696F60.bin",
|
|
||||||
"start": 6909792,
|
|
||||||
"size": 2432
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "data_08132B30/gUnk_086978E0.bin",
|
|
||||||
"start": 6912224,
|
|
||||||
"size": 8192
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "data_08132B30/gUnk_086998E0.bin",
|
|
||||||
"start": 6920416,
|
|
||||||
"size": 32768
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "data_08132B30/gUnk_086A18E0.bin",
|
|
||||||
"start": 6953184,
|
|
||||||
"size": 4448
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "data_08132B30/gUnk_086A18E0_1.bin",
|
|
||||||
"start": 6957632,
|
|
||||||
"size": 32
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "data_08132B30/gUnk_086A2A60.bin",
|
|
||||||
"start": 6957664,
|
|
||||||
"size": 1152
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "data_08132B30/gUnk_086A2EE0.bin",
|
|
||||||
"start": 6958816,
|
|
||||||
"size": 32768
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "data_08132B30/gUnk_086AAEE0.bin",
|
|
||||||
"start": 6991584,
|
|
||||||
"size": 169344
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "data_08132B30/gUnk_086D4460.bin",
|
|
||||||
"start": 7160928,
|
|
||||||
"size": 81920
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "data_08132B30/gUnk_086E8460.bin",
|
|
||||||
"start": 7242848,
|
|
||||||
"size": 161088
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"path": "strings/translation_DEMO_JP.bin",
|
"path": "strings/translation_DEMO_JP.bin",
|
||||||
"variants": [
|
"variants": [
|
||||||
|
|
116
assets/gfx.json
116
assets/gfx.json
|
@ -16484,6 +16484,116 @@
|
||||||
"size": 12288,
|
"size": 12288,
|
||||||
"type": "gfx"
|
"type": "gfx"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"path": "gfx/gUnk_086926A0.bin",
|
||||||
|
"start": 6891168,
|
||||||
|
"size": 224
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "gfx/gUnk_08692780.bin",
|
||||||
|
"start": 6891392,
|
||||||
|
"size": 224
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "gfx/gUnk_08692860.bin",
|
||||||
|
"start": 6891616,
|
||||||
|
"size": 224
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "gfx/gUnk_08692940.bin",
|
||||||
|
"start": 6891840,
|
||||||
|
"size": 224
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "gfx/gUnk_08692A20.bin",
|
||||||
|
"start": 6892064,
|
||||||
|
"size": 224
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "gfx/gUnk_08692B00.bin",
|
||||||
|
"start": 6892288,
|
||||||
|
"size": 224
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "gfx/gUnk_08692BE0.bin",
|
||||||
|
"start": 6892512,
|
||||||
|
"size": 224
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "gfx/gUnk_08692CC0.bin",
|
||||||
|
"start": 6892736,
|
||||||
|
"size": 224
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "gfx/gUnk_08692DA0.bin",
|
||||||
|
"start": 6892960,
|
||||||
|
"size": 224
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "gfx/gUnk_08692E80.bin",
|
||||||
|
"start": 6893184,
|
||||||
|
"size": 224
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "gfx/gUnk_08692F60.bin",
|
||||||
|
"start": 6893408,
|
||||||
|
"size": 64
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "gfx/gUnk_08692F60_1.bin",
|
||||||
|
"start": 6893472,
|
||||||
|
"size": 16320
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "gfx/gUnk_08696F60.bin",
|
||||||
|
"start": 6909792,
|
||||||
|
"size": 2432
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "gfx/gUnk_086978E0.bin",
|
||||||
|
"start": 6912224,
|
||||||
|
"size": 8192
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "gfx/gUnk_086998E0.bin",
|
||||||
|
"start": 6920416,
|
||||||
|
"size": 32768
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "gfx/gUnk_086A18E0.bin",
|
||||||
|
"start": 6953184,
|
||||||
|
"size": 4448
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "gfx/gUnk_086A18E0_1.bin",
|
||||||
|
"start": 6957632,
|
||||||
|
"size": 32
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "gfx/gUnk_086A2A60.bin",
|
||||||
|
"start": 6957664,
|
||||||
|
"size": 1152
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "gfx/gUnk_086A2EE0.bin",
|
||||||
|
"start": 6958816,
|
||||||
|
"size": 32768
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "gfx/gUnk_086AAEE0.bin",
|
||||||
|
"start": 6991584,
|
||||||
|
"size": 169344
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "gfx/gUnk_086D4460.bin",
|
||||||
|
"start": 7160928,
|
||||||
|
"size": 81920
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "gfx/gUnk_086E8460.bin",
|
||||||
|
"start": 7242848,
|
||||||
|
"size": 161088
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"path": "gfx/gGfx_38_0.4bpp",
|
"path": "gfx/gGfx_38_0.4bpp",
|
||||||
"start": 7403936,
|
"start": 7403936,
|
||||||
|
@ -19326,13 +19436,13 @@
|
||||||
{
|
{
|
||||||
"path": "gfx/fixedTypeGfx_214.4bpp.lz",
|
"path": "gfx/fixedTypeGfx_214.4bpp.lz",
|
||||||
"start": 10163804,
|
"start": 10163804,
|
||||||
"size": 1024,
|
"size": 628,
|
||||||
"type": "gfx"
|
"type": "gfx"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "assets/gfx_unknown_49.bin",
|
"path": "assets/gfx_unknown_49.bin",
|
||||||
"start": 10164828,
|
"start": 10164432,
|
||||||
"size": 820,
|
"size": 1216,
|
||||||
"type": "unknown"
|
"type": "unknown"
|
||||||
}
|
}
|
||||||
]
|
]
|
696
assets/map.json
696
assets/map.json
File diff suppressed because it is too large
Load Diff
|
@ -5487,69 +5487,68 @@ fixedTypeGfx_197::
|
||||||
fixedTypeGfx_198::
|
fixedTypeGfx_198::
|
||||||
.incbin "gfx/fixedTypeGfx_198.4bpp"
|
.incbin "gfx/fixedTypeGfx_198.4bpp"
|
||||||
gfx_unknown_20::
|
gfx_unknown_20::
|
||||||
@ TODO move those imports to gfx.json and assets/folder?
|
|
||||||
gUnk_086926A0:: @ 086926A0
|
gUnk_086926A0:: @ 086926A0
|
||||||
.incbin "data_08132B30/gUnk_086926A0.bin"
|
.incbin "gfx/gUnk_086926A0.bin"
|
||||||
|
|
||||||
gUnk_08692780:: @ 08692780
|
gUnk_08692780:: @ 08692780
|
||||||
.incbin "data_08132B30/gUnk_08692780.bin"
|
.incbin "gfx/gUnk_08692780.bin"
|
||||||
|
|
||||||
gUnk_08692860:: @ 08692860
|
gUnk_08692860:: @ 08692860
|
||||||
.incbin "data_08132B30/gUnk_08692860.bin"
|
.incbin "gfx/gUnk_08692860.bin"
|
||||||
|
|
||||||
gUnk_08692940:: @ 08692940
|
gUnk_08692940:: @ 08692940
|
||||||
.incbin "data_08132B30/gUnk_08692940.bin"
|
.incbin "gfx/gUnk_08692940.bin"
|
||||||
|
|
||||||
gUnk_08692A20:: @ 08692A20
|
gUnk_08692A20:: @ 08692A20
|
||||||
.incbin "data_08132B30/gUnk_08692A20.bin"
|
.incbin "gfx/gUnk_08692A20.bin"
|
||||||
|
|
||||||
gUnk_08692B00:: @ 08692B00
|
gUnk_08692B00:: @ 08692B00
|
||||||
.incbin "data_08132B30/gUnk_08692B00.bin"
|
.incbin "gfx/gUnk_08692B00.bin"
|
||||||
|
|
||||||
gUnk_08692BE0:: @ 08692BE0
|
gUnk_08692BE0:: @ 08692BE0
|
||||||
.incbin "data_08132B30/gUnk_08692BE0.bin"
|
.incbin "gfx/gUnk_08692BE0.bin"
|
||||||
|
|
||||||
gUnk_08692CC0:: @ 08692CC0
|
gUnk_08692CC0:: @ 08692CC0
|
||||||
.incbin "data_08132B30/gUnk_08692CC0.bin"
|
.incbin "gfx/gUnk_08692CC0.bin"
|
||||||
|
|
||||||
gUnk_08692DA0:: @ 08692DA0
|
gUnk_08692DA0:: @ 08692DA0
|
||||||
.incbin "data_08132B30/gUnk_08692DA0.bin"
|
.incbin "gfx/gUnk_08692DA0.bin"
|
||||||
|
|
||||||
gUnk_08692E80:: @ 08692E80
|
gUnk_08692E80:: @ 08692E80
|
||||||
.incbin "data_08132B30/gUnk_08692E80.bin"
|
.incbin "gfx/gUnk_08692E80.bin"
|
||||||
|
|
||||||
gUnk_08692F60:: @ 08692F60
|
gUnk_08692F60:: @ 08692F60
|
||||||
.incbin "data_08132B30/gUnk_08692F60.bin"
|
.incbin "gfx/gUnk_08692F60.bin"
|
||||||
@ TODO 08692FA0 to 086A2A3F is .incbin "graphics/font.4bpp"
|
@ TODO 08692FA0 to 086A2A3F is .incbin "graphics/font.4bpp"
|
||||||
.incbin "data_08132B30/gUnk_08692F60_1.bin"
|
.incbin "gfx/gUnk_08692F60_1.bin"
|
||||||
gUnk_08696F60:: @ 08696F60
|
gUnk_08696F60:: @ 08696F60
|
||||||
.incbin "data_08132B30/gUnk_08696F60.bin"
|
.incbin "gfx/gUnk_08696F60.bin"
|
||||||
gUnk_086978E0:: @ 086978E0
|
gUnk_086978E0:: @ 086978E0
|
||||||
.incbin "data_08132B30/gUnk_086978E0.bin"
|
.incbin "gfx/gUnk_086978E0.bin"
|
||||||
gUnk_086998E0:: @ 086998E0
|
gUnk_086998E0:: @ 086998E0
|
||||||
.incbin "data_08132B30/gUnk_086998E0.bin"
|
.incbin "gfx/gUnk_086998E0.bin"
|
||||||
gUnk_086A18E0:: @ 086A18E0
|
gUnk_086A18E0:: @ 086A18E0
|
||||||
.incbin "data_08132B30/gUnk_086A18E0.bin"
|
.incbin "gfx/gUnk_086A18E0.bin"
|
||||||
|
|
||||||
.incbin "data_08132B30/gUnk_086A18E0_1.bin"
|
.incbin "gfx/gUnk_086A18E0_1.bin"
|
||||||
gUnk_086A2A60:: @ 086A2A60
|
gUnk_086A2A60:: @ 086A2A60
|
||||||
.incbin "data_08132B30/gUnk_086A2A60.bin"
|
.incbin "gfx/gUnk_086A2A60.bin"
|
||||||
|
|
||||||
gUnk_086A2EE0:: @ 086A2EE0
|
gUnk_086A2EE0:: @ 086A2EE0
|
||||||
.incbin "data_08132B30/gUnk_086A2EE0.bin"
|
.incbin "gfx/gUnk_086A2EE0.bin"
|
||||||
|
|
||||||
gUnk_086AAEE0:: @ 086AAEE0
|
gUnk_086AAEE0:: @ 086AAEE0
|
||||||
.incbin "data_08132B30/gUnk_086AAEE0.bin"
|
.incbin "gfx/gUnk_086AAEE0.bin"
|
||||||
|
|
||||||
@ TODO background graphics?
|
@ TODO background graphics?
|
||||||
@ TODO check http://kylehalladay.com/blog/tutorial/gba/2017/04/11/GBA-By-Example-3.html
|
@ TODO check http://kylehalladay.com/blog/tutorial/gba/2017/04/11/GBA-By-Example-3.html
|
||||||
@ TODO contains credits images?
|
@ TODO contains credits images?
|
||||||
gUnk_086D4460:: @ 086D4460
|
gUnk_086D4460:: @ 086D4460
|
||||||
.incbin "data_08132B30/gUnk_086D4460.bin"
|
.incbin "gfx/gUnk_086D4460.bin"
|
||||||
|
|
||||||
@ TODO 0x800 of this might be backgrond?
|
@ TODO 0x800 of this might be background?
|
||||||
gUnk_086E8460:: @ 086E8460
|
gUnk_086E8460:: @ 086E8460
|
||||||
.incbin "data_08132B30/gUnk_086E8460.bin"
|
.incbin "gfx/gUnk_086E8460.bin"
|
||||||
gGfx_38_0::
|
gGfx_38_0::
|
||||||
.incbin "gfx/gGfx_38_0.4bpp"
|
.incbin "gfx/gGfx_38_0.4bpp"
|
||||||
gGfx_36_0::
|
gGfx_36_0::
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -149,10 +149,16 @@ int main(int argc, char** argv) {
|
||||||
currentOffset = asset["offsets"][gVariant];
|
currentOffset = asset["offsets"][gVariant];
|
||||||
}
|
}
|
||||||
} else if (asset.contains("calculateOffsets")) { // Start offset calculation
|
} else if (asset.contains("calculateOffsets")) { // Start offset calculation
|
||||||
|
if (gMode == EXTRACT || gMode == BUILD) {
|
||||||
std::filesystem::path path = gAssetsFolder;
|
std::filesystem::path path = gAssetsFolder;
|
||||||
path = path / asset["calculateOffsets"];
|
path = path / asset["calculateOffsets"];
|
||||||
int baseOffset = asset["start"].get<int>() + currentOffset;
|
int baseOffset = 0;
|
||||||
|
// During build mode the offsets are calculated directly instead of from a base address.
|
||||||
|
if (gMode == EXTRACT) {
|
||||||
|
baseOffset = asset["start"].get<int>() + currentOffset;
|
||||||
|
}
|
||||||
offsetCalculator = std::make_unique<OffsetCalculator>(path, baseOffset);
|
offsetCalculator = std::make_unique<OffsetCalculator>(path, baseOffset);
|
||||||
|
}
|
||||||
} else if (asset.contains("path")) { // Asset definition
|
} else if (asset.contains("path")) { // Asset definition
|
||||||
|
|
||||||
if (asset.contains("variants")) {
|
if (asset.contains("variants")) {
|
||||||
|
@ -182,6 +188,10 @@ int main(int argc, char** argv) {
|
||||||
}
|
}
|
||||||
case CONVERT: {
|
case CONVERT: {
|
||||||
std::unique_ptr<BaseAsset> assetHandler = getAssetHandlerByType(path, asset, currentOffset);
|
std::unique_ptr<BaseAsset> assetHandler = getAssetHandlerByType(path, asset, currentOffset);
|
||||||
|
if (!std::filesystem::exists(assetHandler->getBuildPath())) {
|
||||||
|
std::cerr << "Error: Extracted binary file " << assetHandler->getBuildPath() << " does not exist. Run `make` first." << std::endl;
|
||||||
|
std::exit(1);
|
||||||
|
}
|
||||||
if (shouldConvertAsset(assetHandler)) {
|
if (shouldConvertAsset(assetHandler)) {
|
||||||
if (gVerbose) {
|
if (gVerbose) {
|
||||||
std::cout << "Converting " << assetHandler->getAssetPath() << "..." << std::endl;
|
std::cout << "Converting " << assetHandler->getAssetPath() << "..." << std::endl;
|
||||||
|
@ -192,12 +202,28 @@ int main(int argc, char** argv) {
|
||||||
}
|
}
|
||||||
case BUILD: {
|
case BUILD: {
|
||||||
std::unique_ptr<BaseAsset> assetHandler = getAssetHandlerByType(path, asset, currentOffset);
|
std::unique_ptr<BaseAsset> assetHandler = getAssetHandlerByType(path, asset, currentOffset);
|
||||||
|
if (!std::filesystem::exists(assetHandler->getAssetPath())) {
|
||||||
|
std::cerr << "Error: Extracted asset file " << assetHandler->getAssetPath() << " does not exist. Run `make extractassets` first." << std::endl;
|
||||||
|
std::exit(1);
|
||||||
|
}
|
||||||
if (shouldBuildAsset(assetHandler)) {
|
if (shouldBuildAsset(assetHandler)) {
|
||||||
if (gVerbose) {
|
if (gVerbose) {
|
||||||
std::cout << "Building " << assetHandler->getAssetPath() << "..." << std::endl;
|
std::cout << "Building " << assetHandler->getAssetPath() << "..." << std::endl;
|
||||||
}
|
}
|
||||||
buildAsset(assetHandler);
|
buildAsset(assetHandler);
|
||||||
}
|
}
|
||||||
|
if (offsetCalculator != nullptr) {
|
||||||
|
// New start is the end of the previous asset.
|
||||||
|
int start = offsetCalculator->getLastEnd();
|
||||||
|
// Get the size of the current asset and calculate the end position.
|
||||||
|
int filesize = static_cast<int>(std::filesystem::file_size(assetHandler->getBuildPath()));
|
||||||
|
// Align by four bytes.
|
||||||
|
if (filesize % 4 != 0) {
|
||||||
|
filesize += 4 - (filesize % 4);
|
||||||
|
}
|
||||||
|
offsetCalculator->setLastEnd(start + filesize);
|
||||||
|
offsetCalculator->addAsset(start, assetHandler->getSymbol());
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "offsets.h"
|
#include "offsets.h"
|
||||||
|
|
||||||
OffsetCalculator::OffsetCalculator(const std::filesystem::path& outputFile, int baseOffset_)
|
OffsetCalculator::OffsetCalculator(const std::filesystem::path& outputFile, int baseOffset_)
|
||||||
: output(outputFile), baseOffset(baseOffset_) {
|
: output(outputFile), baseOffset(baseOffset_), lastEnd(0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void OffsetCalculator::addAsset(int start, const std::string& symbol) {
|
void OffsetCalculator::addAsset(int start, const std::string& symbol) {
|
||||||
|
|
|
@ -9,10 +9,17 @@ class OffsetCalculator {
|
||||||
public:
|
public:
|
||||||
OffsetCalculator(const std::filesystem::path& offsetsFile, int baseOffset_);
|
OffsetCalculator(const std::filesystem::path& offsetsFile, int baseOffset_);
|
||||||
void addAsset(int start, const std::string& symbol);
|
void addAsset(int start, const std::string& symbol);
|
||||||
|
int getLastEnd() const {
|
||||||
|
return lastEnd;
|
||||||
|
}
|
||||||
|
void setLastEnd(int lastEnd_) {
|
||||||
|
this->lastEnd = lastEnd_;
|
||||||
|
}
|
||||||
private:
|
private:
|
||||||
std::ofstream output;
|
std::ofstream output;
|
||||||
int baseOffset;
|
int baseOffset;
|
||||||
|
// Store the end of the previously added asset
|
||||||
|
int lastEnd;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
Loading…
Reference in New Issue