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 */
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;
}
}
}