diff --git a/assets-fx/fonts/uf5x7/README.md b/assets-fx/fonts/uf5x7/README.md new file mode 100644 index 0000000..8af6835 --- /dev/null +++ b/assets-fx/fonts/uf5x7/README.md @@ -0,0 +1,3 @@ +These are some of the Unicode blocks supported by uf5x7. Please see the +repository at https://gitea.planet-casio.com/Lephenixnoir/uf5x7 for the full +set. diff --git a/assets-fx/fonts/uf5x7/U+0020.png b/assets-fx/fonts/uf5x7/U+0020.png new file mode 100644 index 0000000..45168db Binary files /dev/null and b/assets-fx/fonts/uf5x7/U+0020.png differ diff --git a/assets-fx/fonts/uf5x7/U+00A0.png b/assets-fx/fonts/uf5x7/U+00A0.png new file mode 100644 index 0000000..7c962fc Binary files /dev/null and b/assets-fx/fonts/uf5x7/U+00A0.png differ diff --git a/assets-fx/fonts/uf5x7/U+0370.png b/assets-fx/fonts/uf5x7/U+0370.png new file mode 100644 index 0000000..68a59a1 Binary files /dev/null and b/assets-fx/fonts/uf5x7/U+0370.png differ diff --git a/assets-fx/fonts/uf5x7/U+2190.png b/assets-fx/fonts/uf5x7/U+2190.png new file mode 100644 index 0000000..c9b3406 Binary files /dev/null and b/assets-fx/fonts/uf5x7/U+2190.png differ diff --git a/assets-fx/fonts/uf5x7/U+2200.png b/assets-fx/fonts/uf5x7/U+2200.png new file mode 100644 index 0000000..759ddb4 Binary files /dev/null and b/assets-fx/fonts/uf5x7/U+2200.png differ diff --git a/include/gintctl/gint.h b/include/gintctl/gint.h index 72887f1..c9b37e4 100644 --- a/include/gintctl/gint.h +++ b/include/gintctl/gint.h @@ -32,6 +32,9 @@ void gintctl_gint_timer_callbacks(void); /* gintctl_gint_bopti(): Test image rendering */ void gintctl_gint_bopti(void); +/* gintctl_gint_topti(): Test text rendering */ +void gintctl_gint_topti(void); + #ifdef FXCG50 /* gintctl_gint_dma(): Test the Direct Access Memory Controller */ diff --git a/include/gintctl/util.h b/include/gintctl/util.h index 840bc89..a4e80c2 100644 --- a/include/gintctl/util.h +++ b/include/gintctl/util.h @@ -6,6 +6,7 @@ #define GINTCTL_UTIL #include +#include //--- // Platform disambiguation functions @@ -68,4 +69,12 @@ void fkey_menu(int position, char const *text); #endif /* FXCG50 */ +//--- +// Screenshot saving +//--- + +/* screen_mono(): Take a screenshot of the mono VRAM + @path File path (will be overwritten) */ +void screen_mono(uint16_t const *filepath); + #endif /* GINTCTL_UTIL */ diff --git a/project.cfg b/project.cfg index 0d2dd15..e289705 100644 --- a/project.cfg +++ b/project.cfg @@ -83,6 +83,7 @@ LDFLAGS_CG += -Wl,-Map=build-cg/map FONT.hexa.png = charset:print grid.size:3x5 grid.padding:1 FONT.font8x9_bold.png = charset:print grid.size:8x11 grid.padding:1 \ grid.border:0 proportional:true +FONT.uf5x7 = charset:unicode grid.size:5x7 grid.padding:1 IMG.swift.png = profile:p4 IMG.swords.png = profile:p8 diff --git a/src/gint/topti.c b/src/gint/topti.c new file mode 100644 index 0000000..4fb6425 --- /dev/null +++ b/src/gint/topti.c @@ -0,0 +1,46 @@ +#include +#include + +#include +#include + +/* gintctl_gint_topti(): Test text rendering */ +void gintctl_gint_topti(void) +{ + int key = 0; + + /* Text position parameters */ + int x = _(1,6), y=_(0,22); + int dy = _(8,15); + + char const *strings[] = { + "Text rendering", + "Eurêka! UTF-8!", + #ifdef FX9860G + "∀Δ, ∀f : P(Δ)→Δ,", + "∃(A,B)⊆Δ, f(A)=f(B)", + #else + "∀Δ, ∀f : P(Δ)→Δ, ∃(A,B)⊆Δ, f(A)=f(B)", + #endif + "2 = Λα.λf.λn.f (f n)", + NULL, + }; + + int total = 0; + while(strings[total]) total++; + + while(key != KEY_EXIT) + { + dclear(C_WHITE); + for(int i = 0; strings[i]; i++) + dtext(x, y + i * dy, C_BLACK, strings[i]); + dupdate(); + + key = getkey().key; + if(key == KEY_LEFT && x >= -DWIDTH) x--; + if(key == KEY_RIGHT && x <= DWIDTH) x++; + if(key == KEY_UP && y >= -DHEIGHT) y--; + if(key == KEY_DOWN && y <= DHEIGHT) y++; + if(key == KEY_F6) screen_mono(u"\\\\fls0\\topti.bin"); + } +} diff --git a/src/gintctl.c b/src/gintctl.c index 6dc609c..41a5d32 100644 --- a/src/gintctl.c +++ b/src/gintctl.c @@ -48,7 +48,7 @@ struct menu menu_gint = { #endif { "Real-time clock", NULL }, { "Image rendering", gintctl_gint_bopti }, - { "Text rendering", NULL }, + { "Text rendering", gintctl_gint_topti }, #ifdef FX9860G { "Gray engine", gintctl_gint_gray }, { "Gray rendering", gintctl_gint_grayrender }, @@ -126,6 +126,12 @@ int main(GUNUSED int isappli, GUNUSED int optnum) /* Start the profiling library */ prof_init(PROFCTX_COUNT); + #ifdef FX9860G + /* Use the Unicode font uf5x7 on fx-9860G */ + extern font_t font_uf5x7; + dfont(&font_uf5x7); + #endif + int key = 0; struct menu *menu = NULL; diff --git a/src/util.c b/src/util.c index 9bd98f3..4e61b09 100644 --- a/src/util.c +++ b/src/util.c @@ -1,5 +1,7 @@ #include #include +#include +#include #include @@ -179,3 +181,28 @@ void fkey_menu(int position, char const *text) } #endif /* FXCG50 */ + +//--- +// Screenshot saving +//--- + +static uint16_t const *path; + +void switch_screen_mono(void) +{ + int size = 1024; + + BFile_Remove(path); + BFile_Create(path, BFile_File, &size); + + int fd = BFile_Open(path, BFile_WriteOnly); + BFile_Write(fd, gint_vram, 1024); + BFile_Close(fd); +} + +/* screen_mono(): Take a screenshot of the mono VRAM */ +void screen_mono(uint16_t const *filepath) +{ + path = filepath; + gint_switch(switch_screen_mono); +}