diff options
Diffstat (limited to 'src/lib/libkogata')
-rw-r--r-- | src/lib/libkogata/draw.c | 9 | ||||
-rw-r--r-- | src/lib/libkogata/keyboard.c | 9 |
2 files changed, 7 insertions, 11 deletions
diff --git a/src/lib/libkogata/draw.c b/src/lib/libkogata/draw.c index 2db0d1d..f11903d 100644 --- a/src/lib/libkogata/draw.c +++ b/src/lib/libkogata/draw.c @@ -101,9 +101,9 @@ void g_decref_fb(fb_t *fb) { color_t g_color_rgb(fb_t *f, uint8_t r, uint8_t g, uint8_t b) { int m = f->geom.memory_model; - if (m == FB_MM_RGB24 || m == FB_MM_RGB32) return (r << 16) | (g << 8) | b; + if (m == FB_MM_RGB24 || m == FB_MM_RGB32 || m == FB_MM_RGBA32) return (r << 16) | (g << 8) | b; if (m == FB_MM_BGR24 || m == FB_MM_BGR32) return (b << 16) | (g << 8) | r; - if (m == FB_MM_GREY8) return ((r + g + b) / 3) & 0xFF; + if (m == FB_MM_GREY8 || m == FB_MM_GA16) return ((r + g + b) / 3) & 0xFF; if (m == FB_MM_RGB16 || m == FB_MM_RGB15) return ((r >> 3) << 10) | ((g >> 3) << 5) | (b >> 3); if (m == FB_MM_BGR16 || m == FB_MM_BGR15) return ((b >> 3) << 10) | ((g >> 3) << 5) | (r >> 3); return 0; // unknown? @@ -254,9 +254,6 @@ void g_blit_region(fb_t *dst, int x, int y, fb_t *src, fb_region_t reg) { if (y + reg.h > dst->geom.height) reg.h = dst->geom.height - y; if (reg.w <= 0 || reg.h <= 0) return; - dbg_printf("Src: 0x%p, dst: 0x%p, x: %d, y: %d, rx: %d, ry: %d, rw: %d, rh: %d\n", - src->data, dst->data, x, y, reg.x, reg.y, reg.w, reg.h); - if (src->geom.memory_model == dst->geom.memory_model && src->geom.memory_model != FB_MM_RGBA32 && src->geom.memory_model != FB_MM_GA16) { @@ -416,7 +413,9 @@ void g_write(fb_t *fb, int x, int y, const char* text, font_t *font, color_t c) if (id < font->ascii_bitmap.nchars) { uint8_t *d = font->ascii_bitmap.data + (id * font->ascii_bitmap.ch); for (int r = 0; r < font->ascii_bitmap.ch; r++) { + if (y + r >= fb->geom.height) continue; for (int j = 0; j < 8; j++) { + if (x + j >= fb->geom.width) continue; if (d[r] & (0x80 >> j)) { g_plot(fb, x + j, y + r, c); } diff --git a/src/lib/libkogata/keyboard.c b/src/lib/libkogata/keyboard.c index 64569ed..4f59d5d 100644 --- a/src/lib/libkogata/keyboard.c +++ b/src/lib/libkogata/keyboard.c @@ -41,7 +41,7 @@ keyboard_t *init_keyboard() { keyboard_t *kb = (keyboard_t*)malloc(sizeof(keyboard_t)); if (kb == 0) return 0; - if (!load_keymap(kb, "default")) { + if (!load_keymap(kb, "sys:/keymaps/default.km")) { free(kb); return 0; } @@ -54,12 +54,9 @@ void free_keyboard(keyboard_t *t) { } bool load_keymap(keyboard_t *kb, const char* kmname) { - char buf[128]; - snprintf(buf, 128, "sys:/keymaps/%s.km", kmname); - - fd_t f = sc_open(buf, FM_READ); + fd_t f = sc_open(kmname, FM_READ); if (f == 0) { - dbg_printf("Failed to open keymap %s\n", buf); + dbg_printf("Failed to open keymap %s\n", kmname); return false; } |