Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugs #1

Open
1 of 4 tasks
jscrane opened this issue Nov 15, 2018 · 2 comments
Open
1 of 4 tasks

Bugs #1

jscrane opened this issue Nov 15, 2018 · 2 comments

Comments

@jscrane
Copy link
Owner

jscrane commented Nov 15, 2018

  • drawing tiles behind sprites
  • sprite-drawing artifacts
  • speed: it's too slow!
  • not displaying "HIGH SCORE" or "CREDIT xx"
@jscrane
Copy link
Owner Author

jscrane commented Nov 17, 2018

Speed is OK on ESP8266 with TFT_eSPI.

@dbzoo
Copy link

dbzoo commented Jan 1, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants