include $(JABY_ENGINE_DIR)/mkfile/common/ExportPath.mk
include $(JABY_ENGINE_DIR)/mkfile/common/RebuildTarget.mk

OUTPUT_DIR = bin
CLUT_4_COLOR_TRANS_FLAGS = simple-tim clut4 --color-trans

# Ressources to convert
## Music tracks
INPUT += $(OUTPUT_DIR)/Evacuation_cdda.xa 
INPUT += $(OUTPUT_DIR)/OnMyOwn_BailBonds.xa
INPUT += $(OUTPUT_DIR)/apple.vag
INPUT += $(OUTPUT_DIR)/blubb-mono.vag
INPUT += $(OUTPUT_DIR)/Friendship_samp.vag

## Images
INPUT            += $(OUTPUT_DIR)/TexturePage.img
TexturePage_FLAGS = simple-tim clut4

INPUT            += $(OUTPUT_DIR)/IconTexture.img
IconTexture_FLAGS = simple-tim clut4 --semi-trans --color-trans

INPUT     += $(OUTPUT_DIR)/Paco.img
Paco_FLAGS = $(CLUT_4_COLOR_TRANS_FLAGS)

INPUT            += $(OUTPUT_DIR)/Controller.img
Controller_FLAGS  = $(CLUT_4_COLOR_TRANS_FLAGS)

INPUT            += $(OUTPUT_DIR)/doener_fish.img
doener_fish_FLAGS = $(CLUT_4_COLOR_TRANS_FLAGS)

INPUT         += $(OUTPUT_DIR)/JabyStar.img
JabyStar_FLAGS = $(CLUT_4_COLOR_TRANS_FLAGS)

INPUT          += $(OUTPUT_DIR)/JabyTails.img 
JabyTails_FLAGS = $(CLUT_4_COLOR_TRANS_FLAGS)

INPUT             += $(OUTPUT_DIR)/IMG_6921.tim
IMG_6921_TIM_FLAGS = tim full16 --clut-pos {384,255} --tex-pos {384,256}

INPUT               += $(OUTPUT_DIR)/AllTheJaby.tim
AllTheJaby_TIM_FLAGS = tim full16 --tex-pos {0,0}

$(OUTPUT_DIR)/%.vag: audio/%.wav
	@mkdir -p $(OUTPUT_DIR)
	psxfileconv --lz4 $< -o $@ vag

$(OUTPUT_DIR)/OnMyOwn_BailBonds.xa: audio/OnMyOwn_BailBonds.mp3
	@mkdir -p $(OUTPUT_DIR)
	psxfileconv $< -o $@ xa

$(OUTPUT_DIR)/%.xa: audio/%.wav
	@mkdir -p $(OUTPUT_DIR)
	psxfileconv $< -o $@ xa

$(OUTPUT_DIR)/%.img: %.png
	@mkdir -p $(OUTPUT_DIR)
	psxfileconv --lz4 $< -o $@ $($*_FLAGS)

$(OUTPUT_DIR)/%.tim: %.png
	@mkdir -p $(OUTPUT_DIR)
	psxfileconv --lz4 $< -o $@ $($*_TIM_FLAGS)

all: $(INPUT)

clean:
	rm -fr $(OUTPUT_DIR)