You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you precompute the 565 colour palette in the Display constructor.
palette_entry p;
for (int i = 0; i < 32; i++) {
get_palette(p, i);
for (int j = 0; j < 4; j++) {
colour &c = p.colours[j];
_palette565[i][j] = c.get();
}
}
Introduce a new Display class private to hold this data
uint16_t _palette565[32][4]; // color palette
You can make the tile and sprite drawing faster instead of computing it on a per tile basis.
Remove the palette computation logic and replace with a lookup.
void Display::draw_tile(uint16_t t, int x, int y) {
const uint8_t pindex = _tp[t + 0x0400] & 0x1f;
const uint8_t *cdata = tiles + _tp[t] * 64;
for (int n = x; n < x + 8; n++)
for (int m = y; m < y + 8; m++) {
drawPixel(n, m, _palette565[pindex][pgm_read_byte(cdata)]);
cdata++;
}
}
Equivalent change in the sprite drawing. This speeds things up a little more.
The text was updated successfully, but these errors were encountered: