Skip to content

Commit

Permalink
build/assets & moved .gbapal
Browse files Browse the repository at this point in the history
  • Loading branch information
Icedude907 committed Nov 12, 2023
1 parent 4b2054c commit 7b94e1d
Show file tree
Hide file tree
Showing 100 changed files with 3,433 additions and 3,406 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
*.sa1
*.ss[0-9]
*.sg1

*.1bpp
*.4bpp
*.8bpp
*.gbapal
*.lz
*.rl

*.latfont
*.hwjpnfont
*.fwjpnfont
Expand Down
20 changes: 7 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ OBJ_DIR_NAME := $(BUILD_DIR)/emerald
MODERN_ROM_NAME := $(FILE_NAME)_modern.gba
MODERN_OBJ_DIR_NAME := $(BUILD_DIR)/modern

# Shared dir for build independent assets.
ASSETS_OBJ_DIR := $(BUILD_DIR)/assets

ELF_NAME := $(ROM_NAME:.gba=.elf)
MAP_NAME := $(ROM_NAME:.gba=.map)
MODERN_ELF_NAME := $(MODERN_ROM_NAME:.gba=.elf)
Expand Down Expand Up @@ -239,11 +242,12 @@ clean: tidy clean-tools clean-generated clean-assets
@$(MAKE) clean -C libagbsyscall

clean-assets:
rm -rf $(ASSETS_OBJ_DIR)
rm -f $(MID_SUBDIR)/*.s
rm -f $(DATA_ASM_SUBDIR)/layouts/layouts.inc $(DATA_ASM_SUBDIR)/layouts/layouts_table.inc
rm -f $(DATA_ASM_SUBDIR)/maps/connections.inc $(DATA_ASM_SUBDIR)/maps/events.inc $(DATA_ASM_SUBDIR)/maps/groups.inc $(DATA_ASM_SUBDIR)/maps/headers.inc
find sound -iname '*.bin' -exec rm {} +
find . \( -iname '*.1bpp' -o -iname '*.4bpp' -o -iname '*.8bpp' -o -iname '*.gbapal' -o -iname '*.lz' -o -iname '*.rl' -o -iname '*.latfont' -o -iname '*.hwjpnfont' -o -iname '*.fwjpnfont' \) -exec rm {} +
find . \( -iname '*.latfont' -o -iname '*.hwjpnfont' -o -iname '*.fwjpnfont' \) -exec rm {} +
find $(DATA_ASM_SUBDIR)/maps \( -iname 'connections.inc' -o -iname 'events.inc' -o -iname 'header.inc' \) -exec rm {} +

tidy: tidynonmodern tidymodern
Expand All @@ -263,18 +267,8 @@ include spritesheet_rules.mk
include json_data_rules.mk
include songs.mk

%.s: ;
%.png: ;
%.pal: ;
%.aif: ;

%.1bpp: %.png ; $(GFX) $< $@
%.4bpp: %.png ; $(GFX) $< $@
%.8bpp: %.png ; $(GFX) $< $@
%.gbapal: %.pal ; $(GFX) $< $@
%.gbapal: %.png ; $(GFX) $< $@
%.lz: % ; $(GFX) $< $@
%.rl: % ; $(GFX) $< $@
include assets.mk

$(CRY_SUBDIR)/%.bin: $(CRY_SUBDIR)/%.aif ; $(AIF) $< $@ --compress
sound/%.bin: sound/%.aif ; $(AIF) $< $@

Expand Down
40 changes: 40 additions & 0 deletions assets.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# These rules catch most assets - some exceptions (see graphics_file_rules.mk)

%.s: ;
%.png: ;
%.pal: ;
%.aif: ;

# FIXME: Lots of mkdir - we need to copy the directory structure
%.1bpp: %.png
@mkdir -p $(@D)
$(GFX) $< $@
%.4bpp: %.png
@mkdir -p $(@D)
$(GFX) $< $@
%.8bpp: %.png
@mkdir -p $(@D)
$(GFX) $< $@
$(ASSETS_OBJ_DIR)/%.gbapal: %.pal
@mkdir -p $(@D)
$(GFX) $< $@
# Derives the palette from the image in the absence of a .pal file
$(ASSETS_OBJ_DIR)/%.gbapal: %.png
@mkdir -p $(@D)
$(GFX) $< $@

# If you put `.lz` on the end of a filename when using INCBIN it'll be automatically compressed.
$(ASSETS_OBJ_DIR)/%.lz: $(ASSETS_OBJ_DIR)/%
$(GFX) $< $@
$(ASSETS_OBJ_DIR)/%.rl: $(ASSETS_OBJ_DIR)/%
$(GFX) $< $@
%.lz: %
$(GFX) $< $@
%.rl: %
$(GFX) $< $@
# $(ASSETS_OBJ_DIR)/%.lz: %
# @mkdir -p $(@D)
# $(GFX) $< $@
# $(ASSETS_OBJ_DIR)/%.rl: %
# @mkdir -p $(@D)
# $(GFX) $< $@
70 changes: 31 additions & 39 deletions graphics_file_rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -25,40 +25,35 @@ SPINDAGFXDIR := graphics/spinda_spots

types := normal fight flying poison ground rock bug ghost steel mystery fire water grass electric psychic ice dragon dark
contest_types := cool beauty cute smart tough
castform_types := normal sunny rainy snowy

# Output folders
CASTFORM_OUTDIR := $(ASSETS_OBJ_DIR)/$(CASTFORMGFXDIR)
UNUSED_OUTDIR := $(ASSETS_OBJ_DIR)/$(UNUSEDGFXDIR)
BATINT_OUTDIR := $(ASSETS_OBJ_DIR)/$(BATINTGFXDIR)
TYPES_OUTDIR := $(ASSETS_OBJ_DIR)/$(TYPESGFXDIR)

# TODO: A better way to create the directory tree
SPECIAL_OUTDIRS := $(CASTFORM_OUTDIR) $(patsubst %,$(CASTFORM_OUTDIR)/%,$(castform_types)) \
$(UNUSED_OUTDIR) $(BATINT_OUTDIR) $(TYPES_OUTDIR)
$(shell mkdir -p $(SPECIAL_OUTDIRS))

### Castform ###
### Castform has all 4 of its forms joined together before compression

$(CASTFORMGFXDIR)/front.4bpp: $(CASTFORMGFXDIR)/normal/front.4bpp \
$(CASTFORMGFXDIR)/sunny/front.4bpp \
$(CASTFORMGFXDIR)/rainy/front.4bpp \
$(CASTFORMGFXDIR)/snowy/front.4bpp
$(CASTFORMGFXDIR)/front.4bpp: $(patsubst %,$(CASTFORMGFXDIR)/%/front.4bpp,$(castform_types))
@cat $^ >$@

$(CASTFORMGFXDIR)/back.4bpp: $(CASTFORMGFXDIR)/normal/back.4bpp \
$(CASTFORMGFXDIR)/sunny/back.4bpp \
$(CASTFORMGFXDIR)/rainy/back.4bpp \
$(CASTFORMGFXDIR)/snowy/back.4bpp
$(CASTFORMGFXDIR)/back.4bpp: $(patsubst %,$(CASTFORMGFXDIR)/%/back.4bpp,$(castform_types))
@cat $^ >$@

$(CASTFORMGFXDIR)/anim_front.4bpp: $(CASTFORMGFXDIR)/normal/anim_front.4bpp \
$(CASTFORMGFXDIR)/sunny/anim_front.4bpp \
$(CASTFORMGFXDIR)/rainy/anim_front.4bpp \
$(CASTFORMGFXDIR)/snowy/anim_front.4bpp
$(CASTFORMGFXDIR)/anim_front.4bpp: $(patsubst %,$(CASTFORMGFXDIR)/%/anim_front.4bpp,$(castform_types))
@cat $^ >$@

$(CASTFORMGFXDIR)/normal.gbapal: $(CASTFORMGFXDIR)/normal/normal.gbapal \
$(CASTFORMGFXDIR)/sunny/normal.gbapal \
$(CASTFORMGFXDIR)/rainy/normal.gbapal \
$(CASTFORMGFXDIR)/snowy/normal.gbapal
@cat $^ >$@
$(CASTFORM_OUTDIR)/normal.gbapal: $(patsubst %,$(CASTFORM_OUTDIR)/%/normal.gbapal,$(castform_types))
cat $^ >$@

$(CASTFORMGFXDIR)/shiny.gbapal: $(CASTFORMGFXDIR)/normal/shiny.gbapal \
$(CASTFORMGFXDIR)/sunny/shiny.gbapal \
$(CASTFORMGFXDIR)/rainy/shiny.gbapal \
$(CASTFORMGFXDIR)/snowy/shiny.gbapal
@cat $^ >$@
$(CASTFORM_OUTDIR)/shiny.gbapal: $(patsubst %,$(CASTFORM_OUTDIR)/%/shiny.gbapal,$(castform_types))
cat $^ >$@



Expand Down Expand Up @@ -298,7 +293,8 @@ $(FONTGFXDIR)/frlg_female.fwjpnfont: $(FONTGFXDIR)/japanese_frlg_female_font.png


### Miscellaneous ###
graphics/title_screen/pokemon_logo.gbapal: %.gbapal: %.pal
$(ASSETS_OBJ_DIR)/graphics/title_screen/pokemon_logo.gbapal: graphics/title_screen/pokemon_logo.pal
mkdir -p $(@D)
$(GFX) $< $@ -num_colors 224

graphics/pokemon_jump/bg.4bpp: %.4bpp: %.png
Expand All @@ -310,25 +306,21 @@ graphics/pokenav/region_map/map.8bpp: %.8bpp: %.png
$(MISCGFXDIR)/japanese_hof.4bpp: %.4bpp: %.png
$(GFX) $< $@ -num_tiles 29 -Wnum_tiles

$(BATINTGFXDIR)/textbox.gbapal: $(BATINTGFXDIR)/textbox_0.gbapal \
$(BATINTGFXDIR)/textbox_1.gbapal
@cat $^ >$@
$(BATINT_OUTDIR)/textbox.gbapal: $(BATINT_OUTDIR)/textbox_0.gbapal \
$(BATINT_OUTDIR)/textbox_1.gbapal
cat $^ >$@

$(BTLANMSPRGFXDIR)/ice_cube.4bpp: $(BTLANMSPRGFXDIR)/ice_cube_0.4bpp \
$(BTLANMSPRGFXDIR)/ice_cube_1.4bpp \
$(BTLANMSPRGFXDIR)/ice_cube_2.4bpp \
$(BTLANMSPRGFXDIR)/ice_cube_3.4bpp
@cat $^ >$@

$(UNUSEDGFXDIR)/obi_palpak1.gbapal: $(UNUSEDGFXDIR)/old_pal1.gbapal \
$(UNUSEDGFXDIR)/old_pal2.gbapal \
$(UNUSEDGFXDIR)/old_pal3.gbapal
@cat $^ >$@
$(UNUSED_OUTDIR)/obi_palpak1.gbapal: $(patsubst %,$(UNUSED_OUTDIR)/old_pal%.gbapal,1 2 3)
cat $^ >$@

$(UNUSEDGFXDIR)/obi_palpak3.gbapal: $(UNUSEDGFXDIR)/old_pal5.gbapal \
$(UNUSEDGFXDIR)/old_pal6.gbapal \
$(UNUSEDGFXDIR)/old_pal7.gbapal
@cat $^ >$@
$(UNUSED_OUTDIR)/obi_palpak3.gbapal: $(patsubst %,$(UNUSED_OUTDIR)/old_pal%.gbapal,5 6 7)
cat $^ >$@

$(UNUSEDGFXDIR)/obi1.4bpp: $(UNUSEDGFXDIR)/old_bulbasaur.4bpp \
$(UNUSEDGFXDIR)/old_charizard.4bpp
Expand Down Expand Up @@ -404,10 +396,10 @@ graphics/party_menu/bg.4bpp: %.4bpp: %.png
$(TYPESGFXDIR)/move_types.4bpp: $(types:%=$(TYPESGFXDIR)/%.4bpp) $(contest_types:%=$(TYPESGFXDIR)/contest_%.4bpp)
@cat $^ >$@

$(TYPESGFXDIR)/move_types.gbapal: $(TYPESGFXDIR)/move_types_1.gbapal \
$(TYPESGFXDIR)/move_types_2.gbapal \
$(TYPESGFXDIR)/move_types_3.gbapal
@cat $^ >$@
$(TYPES_OUTDIR)/move_types.gbapal: $(TYPES_OUTDIR)/move_types_1.gbapal \
$(TYPES_OUTDIR)/move_types_2.gbapal \
$(TYPES_OUTDIR)/move_types_3.gbapal
cat $^ >$@

graphics/bag/menu.4bpp: %.4bpp: %.png
$(GFX) $< $@ -num_tiles 53 -Wnum_tiles
Expand Down
2 changes: 1 addition & 1 deletion src/battle_anim_effects_3.c
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ const struct SpriteTemplate gSweetScentPetalSpriteTemplate =
.callback = AnimSweetScentPetal,
};

static const u16 sUnusedPalette[] = INCBIN_U16("graphics/battle_anims/unused/unknown.gbapal");
static const u16 sUnusedPalette[] = INCBIN_U16("build/assets/graphics/battle_anims/unused/unknown.gbapal");

const union AnimCmd gPainSplitAnimCmds[] =
{
Expand Down
12 changes: 6 additions & 6 deletions src/battle_factory_screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,9 @@ static struct FactorySwapScreen *sFactorySwapScreen;

u8 (*gFactorySelect_CurrentOptionFunc)(void);

static const u16 sPokeballGray_Pal[] = INCBIN_U16("graphics/battle_frontier/factory_screen/pokeball_gray.gbapal");
static const u16 sPokeballSelected_Pal[] = INCBIN_U16("graphics/battle_frontier/factory_screen/pokeball_selected.gbapal");
static const u16 sInterface_Pal[] = INCBIN_U16("graphics/battle_frontier/factory_screen/interface.gbapal"); // Arrow, menu/action highlights, action box, etc
static const u16 sPokeballGray_Pal[] = INCBIN_U16("build/assets/graphics/battle_frontier/factory_screen/pokeball_gray.gbapal");
static const u16 sPokeballSelected_Pal[] = INCBIN_U16("build/assets/graphics/battle_frontier/factory_screen/pokeball_selected.gbapal");
static const u16 sInterface_Pal[] = INCBIN_U16("build/assets/graphics/battle_frontier/factory_screen/interface.gbapal"); // Arrow, menu/action highlights, action box, etc
static const u8 sPokeball_Gfx[] = INCBIN_U8( "graphics/battle_frontier/factory_screen/pokeball.4bpp"); // Unused, gPokeballSelection_Gfx used instead
static const u8 sArrow_Gfx[] = INCBIN_U8( "graphics/battle_frontier/factory_screen/arrow.4bpp");
static const u8 sMenuHighlightLeft_Gfx[] = INCBIN_U8( "graphics/battle_frontier/factory_screen/menu_highlight_left.4bpp");
Expand All @@ -273,7 +273,7 @@ static const u8 sActionHighlightRight_Gfx[] = INCBIN_U8( "graphics/battle_front
static const u8 sMonPicBgAnim_Gfx[] = INCBIN_U8( "graphics/battle_frontier/factory_screen/mon_pic_bg_anim.4bpp");
static const u8 sMonPicBg_Tilemap[] = INCBIN_U8( "graphics/battle_frontier/factory_screen/mon_pic_bg.bin");
static const u16 sMonPicBg_Gfx[] = INCBIN_U16("graphics/battle_frontier/factory_screen/mon_pic_bg.4bpp");
static const u16 sMonPicBg_Pal[] = INCBIN_U16("graphics/battle_frontier/factory_screen/mon_pic_bg.gbapal");
static const u16 sMonPicBg_Pal[] = INCBIN_U16("build/assets/graphics/battle_frontier/factory_screen/mon_pic_bg.gbapal");

static const struct SpriteSheet sSelect_SpriteSheets[] =
{
Expand Down Expand Up @@ -405,7 +405,7 @@ static const struct WindowTemplate sSelect_WindowTemplates[] =
DUMMY_WIN_TEMPLATE,
};

static const u16 sSelectText_Pal[] = INCBIN_U16("graphics/battle_frontier/factory_screen/text.gbapal");
static const u16 sSelectText_Pal[] = INCBIN_U16("build/assets/graphics/battle_frontier/factory_screen/text.gbapal");
static const u8 sMenuOptionTextColors[] = {TEXT_COLOR_TRANSPARENT, TEXT_COLOR_DARK_GRAY, TEXT_COLOR_TRANSPARENT};
static const u8 sSpeciesNameTextColors[] = {TEXT_COLOR_TRANSPARENT, TEXT_COLOR_RED, TEXT_COLOR_TRANSPARENT};

Expand Down Expand Up @@ -1031,7 +1031,7 @@ static const struct WindowTemplate sSwap_WindowTemplates[] =
DUMMY_WIN_TEMPLATE,
};

static const u16 sSwapText_Pal[] = INCBIN_U16("graphics/battle_frontier/factory_screen/text.gbapal"); // Identical to sSelectText_Pal
static const u16 sSwapText_Pal[] = INCBIN_U16("build/assets/graphics/battle_frontier/factory_screen/text.gbapal"); // Identical to sSelectText_Pal
static const u8 sSwapMenuOptionsTextColors[] = {TEXT_COLOR_TRANSPARENT, TEXT_COLOR_DARK_GRAY, TEXT_COLOR_TRANSPARENT};
static const u8 sSwapSpeciesNameTextColors[] = {TEXT_COLOR_TRANSPARENT, TEXT_COLOR_RED, TEXT_COLOR_TRANSPARENT};

Expand Down
2 changes: 1 addition & 1 deletion src/battle_records.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ EWRAM_DATA u8 gRecordsWindowId = 0;
EWRAM_DATA static u8 *sTilemapBuffer = NULL;

static const u32 sTrainerHillWindowTileset[] = INCBIN_U32("graphics/trainer_hill/records_window.4bpp");
static const u16 sTrainerHillWindowPalette[] = INCBIN_U16("graphics/trainer_hill/records_window.gbapal");
static const u16 sTrainerHillWindowPalette[] = INCBIN_U16("build/assets/graphics/trainer_hill/records_window.gbapal");
static const u32 sTrainerHillWindowTilemap[] = INCBIN_U32("graphics/trainer_hill/records_window.bin");

static const struct BgTemplate sTrainerHillRecordsBgTemplates[] =
Expand Down
2 changes: 1 addition & 1 deletion src/battle_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ static const struct WindowTemplate sUnusedWinTemplate =
.baseBlock = 0x3F
};

static const u16 sLevelUpBanner_Pal[] = INCBIN_U16("graphics/battle_interface/level_up_banner.gbapal");
static const u16 sLevelUpBanner_Pal[] = INCBIN_U16("build/assets/graphics/battle_interface/level_up_banner.gbapal");
static const u32 sLevelUpBanner_Gfx[] = INCBIN_U32("graphics/battle_interface/level_up_banner.4bpp.lz");

// unused
Expand Down
Loading

0 comments on commit 7b94e1d

Please sign in to comment.