X-Git-Url: http://git.squeep.com/?p=dcpu16;a=blobdiff_plain;f=display.c;h=c1e6c20aa650b1404b9b51baf308fe28b7b6fc60;hp=37db1d94e0b55c442eaed0bb3d69914a27db56f4;hb=a9191ba0a5fc210884f9cbcb7174b5dec09d2db6;hpb=bca632cc1c329a45dde32f476b0ef9f6ef5db05a 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; } } }