diff --git a/.gitignore b/.gitignore index c6f838da..71b1fa29 100644 --- a/.gitignore +++ b/.gitignore @@ -65,5 +65,4 @@ _Deparsed_XSubs.pm *.py *.sna __pycache__ -.vscode/settings.json -assets/ \ No newline at end of file +.vscode/settings.json \ No newline at end of file diff --git a/Makefile b/Makefile index 86b63986..89775d5a 100644 --- a/Makefile +++ b/Makefile @@ -65,7 +65,7 @@ SONG_BUILDDIR = $(OBJ_DIR)/$(SONG_SUBDIR) MID_BUILDDIR = $(OBJ_DIR)/$(MID_SUBDIR) ASSET_BUILDDIR = $(OBJ_DIR)/$(ASSET_SUBDIR) -ASFLAGS := -mcpu=arm7tdmi --defsym $(GAME_VERSION)=1 --defsym REVISION=$(REVISION) --defsym $(GAME_LANGUAGE)=1 -I $(ASSET_BUILDDIR) +ASFLAGS := -mcpu=arm7tdmi --defsym $(GAME_VERSION)=1 --defsym REVISION=$(REVISION) --defsym $(GAME_LANGUAGE)=1 -I $(ASSET_SUBDIR) -I $(ASSET_BUILDDIR) CC1 := tools/agbcc/bin/agbcc override CFLAGS += -O2 -Wimplicit -Wparentheses -Werror -Wno-multichar diff --git a/assets/.gitignore b/assets/.gitignore new file mode 100644 index 00000000..d6b7ef32 --- /dev/null +++ b/assets/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/tools/asset_extractor/asset_extractor.py b/tools/asset_extractor/asset_extractor.py index db3de8e0..350b8e7e 100644 --- a/tools/asset_extractor/asset_extractor.py +++ b/tools/asset_extractor/asset_extractor.py @@ -42,7 +42,8 @@ def extract_assets(variant, assets_folder): if verbose: print(f'{path} already extracted.') else: - print(f'Extracting {path}...') + if verbose: + print(f'Extracting {path}...') start = 0 if 'start' in asset: @@ -64,6 +65,10 @@ def extract_assets(variant, assets_folder): output.write(baserom[start:start+size]) if mode == 'tileset': extract_tileset(path) + elif mode == 'palette': + extract_palette(path) + elif mode == 'graphic': + extract_graphic(path, asset['options'] if 'options' in asset else []) @@ -73,12 +78,25 @@ def run_gbagfx(path_in, path_out, options): def extract_tileset(path): assert(path.endswith('.4bpp.lz')) base = path[0:-8] - subprocess.call(['cp', path, path+'.bkp']) + # subprocess.call(['cp', path, path+'.bkp']) run_gbagfx(path, base+'.4bpp', []) # decompress run_gbagfx(base+'.4bpp', base+'.png', ['-mwidth', '32']) # convert to png # TODO automatically generate tileset entries from tileset_headers.s # TODO Possible to set the correct palette? Or not, because there is a set of palettes that can be chosen and the correct palette is only defined by the metatile? +def extract_palette(path): + assert(path.endswith('.gbapal')) + base = path[0:-7] + run_gbagfx(path, base+'.pal', []) + +def extract_graphic(path, options): + assert(path.endswith('.4bpp')) + base = path[0:-5] + params = [] + for key in options: + params.append('-'+key) + params.append(str(options[key])) + run_gbagfx(path, base+'.png', params) def main(): if len(sys.argv) == 1: