Skip to content

Commit 54f6ecd

Browse files
committed
Added example font file and smarter Makefile font processing
1 parent 3f17668 commit 54f6ecd

File tree

4 files changed

+1038
-110
lines changed

4 files changed

+1038
-110
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
_gen_
2+
_build_
3+
eeprom.bin
4+
*~

Makefile

+19-21
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ BIN_DIR := ../../bin
1010

1111
UZEM_RUN_OPTS := -f
1212

13+
# This is a smart option that will determine what to do based on file type:
14+
# - *.png: run the Python tile generator
15+
# - *.s: use an assembly font file (eg, data/font.s)
16+
# - (blank): don't do anything special for fonts
17+
FONT_FILE := $(DATA_DIR)/font.png
18+
1319
AUX_TARGETS := $(GAME).hex # $(GAME).uze $(GAME).lss $(GAME).eep
1420
AUX_DEPS := Makefile $(wildcard $(DATA_DIR)/*)
1521

@@ -27,15 +33,21 @@ FILES_H := $(shell find . -type f -iname '*.h')
2733
FILE_S_VMODE_ASM_SOURCE := video.s # the file included into uzeboxVideoEngineCore.s as VMODE_ASM_SOURCE
2834
FILES_S := library.s tiles.s # any other assembly files to be linked in
2935

30-
FONT_PNG := font.png
31-
32-
# --------------------------------
36+
# -------------------------------- option processing
3337
FILES_C := $(patsubst ./%,%,$(FILES_C))
3438
FILES_S := $(patsubst ./%,%,$(FILES_S))
3539
AUX_TARGETS := $(patsubst %,$(BUILD_DIR)/%,$(AUX_TARGETS))
3640
DEP_DIR := $(BUILD_DIR)/dep
3741

38-
FONT_S := $(GEN_DIR)/$(patsubst %.png,%.s,$(FONT_PNG))
42+
ifeq ($(suffix $(FONT_FILE)),.png)
43+
FONT_PNG := $(FONT_FILE)
44+
FONT_S := $(GEN_DIR)/$(patsubst %.png,%.s,$(notdir $(FONT_PNG)))
45+
else ifeq ($(suffix $(FONT_FILE)),.s)
46+
FONT_S := $(FONT_FILE)
47+
else ifneq ($(FONT_FILE),)
48+
$(error Unrecognized font file type)
49+
endif
50+
3951
FONT_O := $(subst /,_,$(FONT_S))
4052
FONT_O := $(patsubst %.s,%.o,$(FONT_O))
4153

@@ -89,7 +101,7 @@ FILES_KERNEL := $(patsubst %,$(KERNEL)/%,$(FILES_KERNEL))
89101
OBJECTS := $(notdir $(FILES_KERNEL)) $(FILES_C) $(FILES_S)
90102
OBJECTS := $(patsubst %.c,%.o,$(OBJECTS))
91103
OBJECTS := $(patsubst %.s,%.o,$(OBJECTS))
92-
ifneq ($(FONT_PNG),)
104+
ifneq ($(FONT_FILE),)
93105
OBJECTS += $(FONT_O)
94106
endif
95107
OBJECTS := $(patsubst %,$(BUILD_DIR)/%,$(OBJECTS))
@@ -103,7 +115,7 @@ all: $(TARGET) $(AUX_TARGETS)
103115
$(BUILD_DIR):
104116
mkdir $(BUILD_DIR)
105117
mkdir $(DEP_DIR)
106-
mkdir $(GEN_DIR)
118+
mkdir -p $(GEN_DIR)
107119

108120
# order-only prerequisite; OBJECTS don't depend on modification date anymore
109121
$(OBJECTS): $(AUX_DEPS) | $(BUILD_DIR)
@@ -140,26 +152,12 @@ $(BUILD_DIR)/$(FONT_O): $(FONT_S)
140152
$(BUILD_DIR)/uzeboxVideoEngineCore.o: $(FILE_S_VMODE_ASM_SOURCE) $(FILES_H)
141153

142154
ifneq ($(FONT_PNG),)
143-
$(FONT_S): $(DATA_DIR)/$(FONT_PNG)
155+
$(FONT_S): $(FONT_PNG)
144156
python3 tile_generator.py $< $(GEN_DIR)
145157
endif
146158

147-
# # TODO: figure out how to get just the C files that actually depend on the inc/h files to have rules
148-
# # depending on them
149-
# $(GEN_DIR): $(patsubst $(DATA_DIR)/%.png,$(GEN_DIR)/%.inc, \
150-
# $(shell find $(DATA_DIR) -type f -iname '*.png'))
151159
$(GEN_DIR): $(FONT_S)
152160

153-
# # $(DATA_DIR)/%.png: $(DATA_DIR)/%.map.json
154-
# # $(GEN_DIR)/%.inc $(GEN_DIR)/%.h: $(DATA_DIR)/%.png # $(DATA_DIR)/%.map.json
155-
# # $(BIN_DIR)/tile_converter.py $< $(GEN_DIR)
156-
# $(GEN_DIR)/%.inc: $(DATA_DIR)/%.png
157-
# gconvert $(DATA_DIR)/font.gconvert.xml
158-
# @echo "*** Gconvert finished ***"
159-
# # remove warning about only using video mode 9
160-
# @sed -ni '/^#if/,/^#endif/ d; p' $@
161-
# @echo
162-
163161
# -------------------------------- final targets
164162
$(TARGET): $(OBJECTS)
165163
@echo "LINK"

0 commit comments

Comments
 (0)