$(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 $< >$@
}
}
+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);
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_ */
}
}
+
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)
"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"