Browse Source

Add textdefs support

master
Marrub 5 years ago
parent
commit
64c1a9a8ab
  1. 1
      .gitignore
  2. 31
      Makefile
  3. 14
      src/m_str.c
  4. 1
      src/m_str.h
  5. 4
      src/r_draw.c
  6. 5
      text/gui-eng.nts
  7. 5
      text/gui-jpn.nts

1
.gitignore vendored

@ -8,4 +8,5 @@ data*/maps
data*/music
data*/sounds
data*/sprites
data*/textdefs
data*/textures

31
Makefile

@ -15,6 +15,7 @@ SRC=src
INC=inc
BIN=bin
IR=ir
TEXT=text
MAPSRC=maps
DATA_MAIN=data
@ -22,8 +23,9 @@ DATA_MFED=data_mfed
MAPBIN =$(DATA_MAIN)/maps
CODEDEFS =$(DATA_MAIN)/codedefs
CODEDEFS_MFED=$(DATA_MFED)/codedefs
TEXTDEFS =$(DATA_MAIN)/textdefs
FOLDERS=$(CODEDEFS) $(CODEDEFS_MFED) $(BIN) $(IR) $(MAPBIN)
FOLDERS=$(CODEDEFS) $(CODEDEFS_MFED) $(TEXTDEFS) $(BIN) $(IR) $(MAPBIN)
define tgt_template =
$(1)_SOURCES=$(SRC)/$(2)
@ -52,24 +54,30 @@ $(eval $(call exe_template,GOL5,golan5.c,$(BIN)/golan5))
$(eval $(call lib_template,GAME,g_,eikyo-game.bin))
$(eval $(call lib_template,INTR,i_,eikyo-interface.bin))
$(eval $(call lib_template,RNDR,r_,eikyo-render.bin))
$(eval $(call lib_template,MISC,m_,eikyo-misc.bin))
$(eval $(call lib_template,RNDR,r_,eikyo-render.bin))
MISC_LIBOUTS=$(MISC_SOURCES:$(SRC)/%.c=$(BIN)/%.o)
CDEF_SOURCES=$(SRC)/extmem.nts
CDEF_BINARYS=$(CODEDEFS)/eikyo-extmem.bin
LIBC_OUTPUTS=$(IR)/libc.ir $(IR)/libGDCC.ir
LIBC_BINARYS=$(CODEDEFS)/stdlib.bin
MAPS_SOURCES=$(wildcard $(MAPSRC)/*.gmf9)
MAPS_OUTPUTS=$(MAPS_SOURCES:$(MAPSRC)/%.gmf9=$(MAPBIN)/%.gmf0)
NTSC_SOURCES=$(SRC)/extmem.nts
NTSC_BINARYS=$(CODEDEFS)/eikyo-extmem.bin
TENG_SOURCES=$(wildcard $(TEXT)/*-eng.nts)
TENG_BINARYS=$(TEXTDEFS)/eikyo-eng.text
LIBC_OUTPUTS=$(IR)/libc.ir $(IR)/libGDCC.ir
LIBC_BINARYS=$(CODEDEFS)/stdlib.bin
TJPN_SOURCES=$(wildcard $(TEXT)/*-jpn.nts)
TJPN_BINARYS=$(TEXTDEFS)/eikyo-jpn.text
.PHONY: clean
.SECONDARY: $(MISC_LIBOUTS)
all: $(FOLDERS) $(GAME_BINARYS) $(INTR_BINARYS) $(MAIN_BINARYS) $(MFED_BINARYS) $(MISC_BINARYS) $(RNDR_BINARYS) $(LIBC_BINARYS) $(MAPS_OUTPUTS) $(NTSC_BINARYS)
all: $(FOLDERS) $(GAME_BINARYS) $(INTR_BINARYS) $(MAIN_BINARYS) $(MFED_BINARYS) $(MISC_BINARYS) $(RNDR_BINARYS) $(LIBC_BINARYS) $(MAPS_OUTPUTS) $(CDEF_BINARYS) $(TENG_BINARYS) $(TJPN_BINARYS)
$(GAME_BINARYS): $(GAME_OUTPUTS)
$(GOL5_BINARYS): $(GOL5_OUTPUTS)
@ -80,6 +88,8 @@ $(MFED_BINARYS): $(MFED_OUTPUTS)
$(MISC_BINARYS): $(MISC_OUTPUTS)
$(RNDR_BINARYS): $(RNDR_OUTPUTS)
$(STRH_BINARYS): $(STRH_OUTPUTS)
$(TENG_BINARYS): $(TENG_SOURCES)
$(TJPN_BINARYS): $(TJPN_SOURCES)
$(FOLDERS):
mkdir -p $@
@ -99,8 +109,8 @@ $(BIN)/%.o: $(SRC)/%.c $(MISC_HEADERS)
%.bin:
$(GDCC_LD) $(GDCC_LFLAGS) -o $@ $^
$(NTSC_BINARYS): $(NTSC_SOURCES)
$(GDCC_NTSC) -t CODEDEFS -o $@ $^
%.text:
$(GDCC_NTSC) -t TEXTDEFS -o $@ $^
$(IR)/%.ir: $(SRC)/%.c $(GAME_HEADERS) $(INTR_HEADERS) $(MISC_HEADERS) $(RNDR_HEADERS) $(STRH_BINARYS)
$(GDCC_CC) $(GDCC_CFLAGS) -DM_fileHash=$(shell bin/strh $<) -o $@ $<
@ -108,4 +118,7 @@ $(IR)/%.ir: $(SRC)/%.c $(GAME_HEADERS) $(INTR_HEADERS) $(MISC_HEADERS) $(RNDR_HE
$(LIBC_OUTPUTS):
$(GDCC_MAKELIB) $(GDCC_CFLAGS) -o $@ $(basename $(@F))
$(CDEF_BINARYS): $(CDEF_SOURCES)
$(GDCC_NTSC) -t CODEDEFS -o $@ $^
## EOF

14
src/m_str.c

@ -10,6 +10,7 @@
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <stdlib.h>
// Extern Functions ----------------------------------------------------------|
@ -54,6 +55,19 @@ __str M_StrCreate(char const *s)
{
return DGE_String_Create(s, strlen(s));
}
//
// M_StrGet
//
char *M_StrGet(__str name)
{
[[__no_init]]
static char bufs[3][0x2800];
static int idx;
if(++idx == M_countof(bufs)) idx = 0;
DGE_Text_Read(name, bufs[idx], sizeof(bufs[idx]));
return bufs[idx];
}
#endif
// EOF

1
src/m_str.h

@ -13,6 +13,7 @@ mword M_StrHash(char const *s);
#if __GDCC__
__str M_StrCreate(char const *s);
char *M_StrGet(__str name);
#endif
#endif

4
src/r_draw.c

@ -61,7 +61,7 @@ void R_DrawPost(ulfra delta)
DGE_Draw_Text(760, 20, G_Place);
DGE_Draw_SetTextAlign(DGE_Align_Left);
DGE_Draw_Text(585, 70, u8"ハイスコア");
DGE_Draw_Text(585, 70, M_StrGet(s"gui/highscore"));
DGE_Draw_SetTextAlign(DGE_Align_Right);
DGE_Draw_Text(945, 70, M_StrFmt("%.15i", 0));
@ -69,7 +69,7 @@ void R_DrawPost(ulfra delta)
{
DGE_Draw_SetTextAlign(DGE_Align_Left);
DGE_Draw_Text(585, 120 + i * 20,
M_StrFmt(u8"PLAYER %i\nスコア\n残り再試行回", i + 1));
M_StrFmt(M_StrGet(s"gui/player"), i + 1));
DGE_Draw_SetTextAlign(DGE_Align_Right);
DGE_Draw_Text(945, 140 + i * 20, M_StrFmt("%.15i\n%i", 0, 5));
}

5
text/gui-eng.nts

@ -0,0 +1,5 @@
language eng
{
gui/highscore = "High Score";
gui/player = "Player %i\nScore\nReboots";
}

5
text/gui-jpn.nts

@ -0,0 +1,5 @@
language jpn
{
gui/highscore = "ハイスコア";
gui/player = "PLAYER %i\nスコア\n残り再試行回";
}
Loading…
Cancel
Save