Open jscrane opened 5 years ago
Speed is OK on ESP8266 with TFT_eSPI.
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.