diff --git a/Makefile b/Makefile index 0a4678d..e61601a 100644 --- a/Makefile +++ b/Makefile @@ -37,7 +37,6 @@ SOURCES := source DATA := data INCLUDES := include GRAPHICS := gfx -#GFXBUILD := $(BUILD) ROMFS := romfs GFXBUILD := $(ROMFS)/gfx @@ -88,6 +87,7 @@ SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica))) SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist))) GFXFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.t3s))) +FONTFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.ttf))) BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) #--------------------------------------------------------------------------------- @@ -108,10 +108,12 @@ endif ifeq ($(GFXBUILD),$(BUILD)) #--------------------------------------------------------------------------------- export T3XFILES := $(GFXFILES:.t3s=.t3x) +export EFONTFILES := $(FONTFILES:.ttf=.bcfnt) #--------------------------------------------------------------------------------- else #--------------------------------------------------------------------------------- export ROMFS_T3XFILES := $(patsubst %.t3s, $(GFXBUILD)/%.t3x, $(GFXFILES)) +export ROMFS_FONTFILES := $(patsubst %.ttf, $(GFXBUILD)/%.bcfnt, $(FONTFILES)) export T3XHFILES := $(patsubst %.t3s, $(BUILD)/%.h, $(GFXFILES)) #--------------------------------------------------------------------------------- endif @@ -121,7 +123,7 @@ export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) export OFILES_BIN := $(addsuffix .o,$(BINFILES)) \ $(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.o) \ - $(addsuffix .o,$(T3XFILES)) + $(addsuffix .o,$(T3XFILES)) $(addsuffix .o,$(EFONTFILES)) export OFILES := $(OFILES_BIN) $(OFILES_SOURCES) @@ -161,7 +163,7 @@ endif .PHONY: all clean #--------------------------------------------------------------------------------- -all: $(BUILD) $(GFXBUILD) $(DEPSDIR) $(ROMFS_T3XFILES) $(T3XHFILES) +all: $(BUILD) $(GFXBUILD) $(DEPSDIR) $(ROMFS_T3XFILES) $(ROMFS_FONTFILES) $(T3XHFILES) @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile $(BUILD): @@ -188,6 +190,12 @@ $(GFXBUILD)/%.t3x $(BUILD)/%.h : %.t3s @echo $(notdir $<) @tex3ds -i $< -H $(BUILD)/$*.h -d $(DEPSDIR)/$*.d -o $(GFXBUILD)/$*.t3x +#--------------------------------------------------------------------------------- +$(GFXBUILD)/%.bcfnt : %.ttf +#--------------------------------------------------------------------------------- + @echo $(notdir $<) + @mkbcfnt -o $(GFXBUILD)/$*.bcfnt $< + #--------------------------------------------------------------------------------- else @@ -209,13 +217,19 @@ $(OUTPUT).elf : $(OFILES) @$(bin2o) #--------------------------------------------------------------------------------- -.PRECIOUS : %.t3x +.PRECIOUS : %.t3x %.bcfnt #--------------------------------------------------------------------------------- %.t3x.o %_t3x.h : %.t3x #--------------------------------------------------------------------------------- @echo $(notdir $<) @$(bin2o) +#--------------------------------------------------------------------------------- +%.bcfnt.o %_bcfnt.h : %.bcfnt +#--------------------------------------------------------------------------------- + @echo $(notdir $<) + @$(bin2o) + #--------------------------------------------------------------------------------- # rules for assembling GPU shaders #--------------------------------------------------------------------------------- @@ -248,6 +262,12 @@ endef @echo $(notdir $<) @tex3ds -i $< -H $*.h -d $*.d -o $*.t3x +#--------------------------------------------------------------------------------- +%.bcfnt : %.ttf +#--------------------------------------------------------------------------------- + @echo $(notdir $<) + @mkbcfnt -o $*.bcfnt $< + -include $(DEPSDIR)/*.d #--------------------------------------------------------------------------------------- diff --git a/gfx/big0.png b/gfx/big0.png deleted file mode 100644 index d1b6f3f..0000000 Binary files a/gfx/big0.png and /dev/null differ diff --git a/gfx/big1.png b/gfx/big1.png deleted file mode 100644 index 14ab374..0000000 Binary files a/gfx/big1.png and /dev/null differ diff --git a/gfx/big2.png b/gfx/big2.png deleted file mode 100644 index 5a61a1b..0000000 Binary files a/gfx/big2.png and /dev/null differ diff --git a/gfx/big3.png b/gfx/big3.png deleted file mode 100644 index 1073404..0000000 Binary files a/gfx/big3.png and /dev/null differ diff --git a/gfx/big4.png b/gfx/big4.png deleted file mode 100644 index 3a6d408..0000000 Binary files a/gfx/big4.png and /dev/null differ diff --git a/gfx/big5.png b/gfx/big5.png deleted file mode 100644 index bbf0a72..0000000 Binary files a/gfx/big5.png and /dev/null differ diff --git a/gfx/big6.png b/gfx/big6.png deleted file mode 100644 index 2bcb61f..0000000 Binary files a/gfx/big6.png and /dev/null differ diff --git a/gfx/big7.png b/gfx/big7.png deleted file mode 100644 index 05a9a5b..0000000 Binary files a/gfx/big7.png and /dev/null differ diff --git a/gfx/big8.png b/gfx/big8.png deleted file mode 100644 index 9a8edc8..0000000 Binary files a/gfx/big8.png and /dev/null differ diff --git a/gfx/big9.png b/gfx/big9.png deleted file mode 100644 index ce9888d..0000000 Binary files a/gfx/big9.png and /dev/null differ diff --git a/gfx/fbfont.ttf b/gfx/fbfont.ttf new file mode 100644 index 0000000..6338c19 Binary files /dev/null and b/gfx/fbfont.ttf differ diff --git a/gfx/sprites.t3s b/gfx/sprites.t3s index 11e0b47..0b0469d 100644 --- a/gfx/sprites.t3s +++ b/gfx/sprites.t3s @@ -1,15 +1,5 @@ --atlas -f rgba8888 -z auto bird.png -big0.png -big1.png -big2.png -big3.png -big4.png -big5.png -big6.png -big7.png -big8.png -big9.png bg.png floor.png logo.png diff --git a/romfs/fbfont.bcfnt b/romfs/fbfont.bcfnt new file mode 100644 index 0000000..e26c7ef Binary files /dev/null and b/romfs/fbfont.bcfnt differ diff --git a/romfs/sprites.t3x b/romfs/sprites.t3x new file mode 100644 index 0000000..9a17805 Binary files /dev/null and b/romfs/sprites.t3x differ diff --git a/source/main.c b/source/main.c index aeb3876..7ea00ad 100644 --- a/source/main.c +++ b/source/main.c @@ -19,7 +19,7 @@ #define SCREEN_WIDTH 400 #define SCREEN_HEIGHT 240 -// Simple sprite struct + typedef struct { C2D_Sprite spr; float x, y; // pos @@ -47,11 +47,6 @@ static void initSprites() { // set bird consts C2D_SpriteSetPos(&sprites[SPR_BIRD].spr, SCREEN_WIDTH / 4, SCREEN_HEIGHT / 3); - // big number positions - for (size_t i = 1; i < 10; i++) { - C2D_SpriteSetPos(&sprites[i].spr, 260, 100); // a guess - } - // set bottom screen scorecard C2D_SpriteSetCenter(&sprites[SPR_SCORECARD].spr, 0.0, 0.0); C2D_SpriteSetPos(&sprites[SPR_SCORECARD].spr, 2, 40); @@ -93,8 +88,9 @@ int main(int argc, char* argv[]) { C2D_Font font; g_staticBuf = C2D_TextBufNew(4096); - font = C2D_FontLoadSystem(CFG_REGION_EUR); + font = C2D_FontLoad("romfs:/fbfont.bcfnt"); C2D_TextFontParse(&scoreText, font, g_staticBuf, "0"); + C2D_TextOptimize(&scoreText); // Load graphics spriteSheet = C2D_SpriteSheetLoad("romfs:/gfx/sprites.t3x"); @@ -141,6 +137,7 @@ int main(int argc, char* argv[]) { char scoreString[(((sizeof score) * CHAR_BIT) + 2)/3 + 2]; sprintf(scoreString, "%d", score); C2D_TextFontParse(&scoreText, font, g_staticBuf, scoreString); + C2D_TextOptimize(&scoreText); // Render the scene @@ -156,13 +153,16 @@ int main(int argc, char* argv[]) { // C2D_DrawSprite(&scoreSprite->spr); - C2D_DrawText(&scoreText, 0, 260, 100, 0.0f, 1, 1); + C2D_DrawText(&scoreText, 0, 255, 90, 0.0f, 1.0f, 1.0f); C3D_FrameEnd(0); + } // Delete graphics C2D_SpriteSheetFree(spriteSheet); + C2D_TextBufDelete(g_staticBuf); + C2D_FontFree(font); // Deinit libs C2D_Fini(); diff --git a/source/sprites.h b/source/sprites.h index 26e0438..aec0959 100644 --- a/source/sprites.h +++ b/source/sprites.h @@ -4,21 +4,13 @@ #define SPRITES_H #define SPR_BIRD 0 -#define SPR_BIG0 1 -#define SPR_BIG1 2 -#define SPR_BIG2 3 -#define SPR_BIG3 4 -#define SPR_BIG5 6 -#define SPR_BIG7 8 -#define SPR_BIG8 9 -#define SPR_BIG9 10 -#define SPR_BG 11 -#define SPR_FLOOR 12 -#define SPR_LOGO 13 -#define SPR_PIPEBOTTOM 14 -#define SPR_PIPETOP 15 +#define SPR_BG 1 +#define SPR_FLOOR 2 +#define SPR_LOGO 3 +#define SPR_PIPEBOTTOM 4 +#define SPR_PIPETOP 5 -#define SPR_SCORECARD 16 +#define SPR_SCORECARD 6 #endif \ No newline at end of file