From 73f97e0d9dc83cad4aa7b53d900ea28390afed4f Mon Sep 17 00:00:00 2001 From: John Tsiombikas Date: Thu, 19 Dec 2019 04:54:07 +0200 Subject: [PATCH] fixed 16bpp offsets in csprite generator (hardcoded for now) --- GNUmakefile | 2 +- src/demo.c | 12 ++++++++++++ src/demo.h | 6 ++++++ src/screen.c | 8 +++++++- tools/csprite/src/main.c | 12 ++++++++++-- 5 files changed, 36 insertions(+), 4 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index 1ee0a1e..d2dbc8b 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -55,4 +55,4 @@ tools/csprite/csprite: $(MAKE) -C tools/csprite font.asm: data/font.png tools/csprite/csprite - tools/csprite/csprite -n font -s 16x16 -r 288x32+32+17 -conv565 -nasm $< >$@ + tools/csprite/csprite -n cs_font -s 16x16 -r 288x32+32+17 -conv565 -nasm $< >$@ diff --git a/src/demo.c b/src/demo.c index a990d5f..fee1e7a 100644 --- a/src/demo.c +++ b/src/demo.c @@ -164,6 +164,18 @@ void draw_mouse_pointer(uint16_t *fb) } } +void cs_puts(void *fb, int x, int y, const char *str) +{ + while(*str) { + int c = *str++; + + if(isalpha(c)) { + cs_font(fb, x, y, toupper(c) - 'A'); + } + x += 14; + } +} + static void change_screen(int idx) { printf("change screen %d\n", idx); diff --git a/src/demo.h b/src/demo.h index b55ad4d..a3cc66a 100644 --- a/src/demo.h +++ b/src/demo.h @@ -40,4 +40,10 @@ void mouse_orbit_update(float *theta, float *phi, float *dist); void draw_mouse_pointer(uint16_t *fb); +/* compiled sprites available */ +void cs_font(void *fb, int x, int y, int idx); + +/* helper to print text with cs_font */ +void cs_puts(void *fb, int x, int y, const char *str); + #endif /* DEMO_H_ */ diff --git a/src/screen.c b/src/screen.c index b39778d..68a8c7f 100644 --- a/src/screen.c +++ b/src/screen.c @@ -96,9 +96,15 @@ void scr_update(void) } } + void scr_draw(void) { - if(cur) cur->draw(); + if(cur) { + cur->draw(); + + /* print screen name */ + cs_puts(fb_pixels, 0, 0, cur->name); + } } void scr_keypress(int key) diff --git a/tools/csprite/src/main.c b/tools/csprite/src/main.c index 5bece2d..d1f024b 100644 --- a/tools/csprite/src/main.c +++ b/tools/csprite/src/main.c @@ -126,11 +126,19 @@ const char *prefixfmt[] = { "tiletab:\n", /* NASM template */ + /* TODO hardcoding the 16bpp changes for now, generalize later + * and while we're at it, let's get rid of the mul too ... + */ "\tglobal %s\n" "%s:\n" "\tmov eax, [esp + 12]\n" - "\tmov ecx, %d\n" - "\tmul ecx\n" + ";\tmov ecx, %d\n" + ";\tmul ecx\n" + "\tmov ecx, eax\n" + "\tshl eax, 9\n" + "\tshl ecx, 7\n" + "\tadd eax, ecx\n" + "\tadd eax, [esp + 8]\n" "\tadd eax, [esp + 8]\n" "\tadd eax, [esp + 4]\n" "\tmov edx, eax\n" -- 1.7.10.4