Skip to content

Instantly share code, notes, and snippets.

@ao-kenji
Created August 12, 2014 14:23
Show Gist options
  • Save ao-kenji/f8965bef78737f65947d to your computer and use it in GitHub Desktop.
Save ao-kenji/f8965bef78737f65947d to your computer and use it in GitHub Desktop.
yaft ( http://uobikiemukot.github.io/yaft/ ) on OpenBSD/luna88k, sixel drawing diff.
diff --git a/draw.h b/draw.h
index 9871ba3..ad594f8 100644
--- a/draw.h
+++ b/draw.h
@@ -3,29 +3,68 @@ static inline void draw_sixel(struct framebuffer *fb, int line, int col, uint8_t
{
int h, w, src_offset, dst_offset;
uint32_t pixel, color = 0;
+ int x, y, i;
+ uint32_t *p0, *p;
for (h = 0; h < CELL_HEIGHT; h++) {
for (w = 0; w < CELL_WIDTH; w++) {
src_offset = BYTES_PER_PIXEL * (h * CELL_WIDTH + w);
memcpy(&color, bitmap + src_offset, BYTES_PER_PIXEL);
+#if 0
dst_offset = (line * CELL_HEIGHT + h) * fb->line_length + (col * CELL_WIDTH + w) * fb->bytes_per_pixel;
pixel = color2pixel(&fb->vinfo, color);
memcpy(fb->buf + dst_offset, &pixel, fb->bytes_per_pixel);
+#else
+ pixel = color2pixel(&fb->vinfo, color);
+
+ x = CELL_WIDTH * col + w;
+ y = CELL_HEIGHT * line + h;
+ p0 = (uint32_t *)((uint8_t *)fb->buf
+ + y * fb->line_length + ((x / 32) * 4));
+ x %= 32;
+
+ for (i = 0; i < DEPTH; i++) {
+ p = (uint32_t *)((uint8_t *)p0 + 0x40000 * i);
+ if (pixel & (0x01 << i))
+ /* set */
+ *p |= (0x00000001 << (31 - x));
+ else
+ /* reset */
+ *p &= ~(0x00000001 << (31 - x));
+ }
+#endif
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment