From: Justin Wind Date: Sun, 22 Apr 2012 18:25:57 +0000 (-0700) Subject: tile rendering for chargen now working correctly X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=a9191ba0a5fc210884f9cbcb7174b5dec09d2db6;p=dcpu16 tile rendering for chargen now working correctly resolved small bugs in rendering textmode cells to display buffer --- diff --git a/chargen-4x8.h b/chargen-4x8.h index f29cb04..2c8a98e 100644 --- a/chargen-4x8.h +++ b/chargen-4x8.h @@ -5,13 +5,13 @@ const char chargen_4x8_glyphs[][4] = { /* 00 */ - { 0x10, 0x10, 0xf0, 0x00 }, + { 0x00, 0xf0, 0x10, 0x10 }, /* 01 */ - { 0x10, 0x10, 0xf0, 0x10 }, + { 0x10, 0xf0, 0x10, 0x10 }, /* 02 */ - { 0x10, 0x10, 0x1f, 0x10 }, + { 0x10, 0x1f, 0x10, 0x10 }, /* 03 */ - { 0x10, 0x10, 0xff, 0x10 }, + { 0x00, 0xff, 0x10, 0x10 }, /* 04 */ { 0x10, 0x10, 0x10, 0x10 }, /* 05 */ @@ -78,13 +78,13 @@ const char chargen_4x8_glyphs[][4] = { /* 22 '"' "*/ { 0xb0, 0x00, 0xb0, 0x00 }, /* 23 '#' */ - { 0x7b, 0x28, 0x7b, 0x00 }, + { 0x7c, 0x28, 0x7c, 0x00 }, /* 24 '$' */ - { 0x64, 0xd6, 0x4b, 0x00 }, + { 0x64, 0xd6, 0x4c, 0x00 }, /* 25 '%' */ - { 0x86, 0x38, 0xb2, 0x00 }, + { 0x86, 0x38, 0xc2, 0x00 }, /* 26 '&' */ - { 0x6b, 0x94, 0x6e, 0x0a }, + { 0x6c, 0x94, 0x6e, 0x0a }, /* 27 ''' */ { 0x00, 0x40, 0x80, 0x00 }, /* 28 '(' */ @@ -167,7 +167,7 @@ const char chargen_4x8_glyphs[][4] = { /* 4d 'M' */ { 0xfe, 0x60, 0xfe, 0x00 }, /* 4e 'N' */ - { 0xfe, 0x80, 0x8e, 0x00 }, + { 0xfe, 0x80, 0x7e, 0x00 }, /* 4f 'O' */ { 0x7c, 0x82, 0x7c, 0x00 }, /* 50 'P' */ @@ -181,7 +181,7 @@ const char chargen_4x8_glyphs[][4] = { /* 54 'T' */ { 0x80, 0xfe, 0x80, 0x00 }, /* 55 'U' */ - { 0xfe, 0x02, 0xfe, 0x02 }, + { 0xfe, 0x02, 0xfe, 0x00 }, /* 56 'V' */ { 0xf8, 0x06, 0xf8, 0x00 }, /* 57 'W' */ @@ -218,9 +218,9 @@ const char chargen_4x8_glyphs[][4] = { /* 65 'e' */ { 0x1c, 0x2a, 0x1a, 0x00 }, /* 66 'f' */ - { 0x10, 0x77, 0x90, 0x00 }, + { 0x10, 0x7e, 0x90, 0x00 }, /* 67 'g' */ - { 0x12, 0x2a, 0x3a, 0x00 }, + { 0x12, 0x2a, 0x3c, 0x00 }, /* 68 'h' */ { 0xfe, 0x20, 0x1e, 0x00 }, /* 69 'i' */ @@ -248,7 +248,7 @@ const char chargen_4x8_glyphs[][4] = { /* 74 't' */ { 0x20, 0x7c, 0x22, 0x00 }, /* 75 'u' */ - { 0x3c, 0x02, 0x37, 0x00 }, + { 0x3c, 0x02, 0x3e, 0x00 }, /* 76 'v' */ { 0x38, 0x06, 0x38, 0x00 }, /* 77 'w' */ diff --git a/display.c b/display.c index 37db1d9..c1e6c20 100644 --- a/display.c +++ b/display.c @@ -93,14 +93,14 @@ static inline void display_draw_cell(DPIX *pixbuf, DCPU16_WORD *cell_map, DCPU16_WORD index, int cell_x, int cell_y, DPIX fg, DPIX bg) { DPIX *cellstart = pixbuf; /* start of display */ unsigned int pix_x, pix_y; - unsigned char *cell_bitmap = (unsigned char *)(cell_map + index); + unsigned char *cell_bitmap = (unsigned char *)(cell_map + (index * sizeof index)); assert(cell_x < CELL_X); assert(cell_y < CELL_Y); cellstart += (PIX_X * PIX_BORDER); /* skip top border */ - cellstart += (CELL_Y_SZ) * cell_y; /* skip down to row */ + cellstart += (CELL_Y_SZ * PIX_X) * cell_y; /* skip down to row */ cellstart += PIX_BORDER; /* skip side border */ @@ -109,9 +109,9 @@ void display_draw_cell(DPIX *pixbuf, DCPU16_WORD *cell_map, DCPU16_WORD index, i for (pix_x = 0; pix_x < CELL_X_SZ; pix_x++) { for (pix_y = 0; pix_y < CELL_Y_SZ; pix_y++) { if ((cell_bitmap[pix_x] >> pix_y) & 0x01) - cellstart[(pix_y * PIX_X) + pix_x] = fg; + cellstart[((CELL_Y_SZ - pix_y - 1) * PIX_X) + pix_x] = fg; else - cellstart[(pix_y * PIX_X) + pix_x] = bg; + cellstart[((CELL_Y_SZ - pix_y - 1) * PIX_X) + pix_x] = bg; } } }