Skip to content

Commit f2b6045

Browse files
committed
fix #3 (store tiles and sprites in flash)
1 parent 828b400 commit f2b6045

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

display.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ void Display::draw_tile(uint16_t t, int x, int y) {
3939
for (int m = 0; m < 8; m++) {
4040
unsigned px = x+n, py = y+m;
4141
if (_dx > px && _dy > py) {
42-
colour &c = p.colours[*cdata];
42+
colour &c = p.colours[pgm_read_byte(cdata)];
4343
drawPixel(px, py, c.get());
4444
}
4545
cdata++;
@@ -85,7 +85,7 @@ void Display::set_sprite(uint16_t off, uint8_t sx, uint8_t sy) {
8585
for (int m = 0; m < 16; m++) {
8686
unsigned px = fx? x+15-n: x+n, py = fy? y+15-m: y+m;
8787
if (_dx > px && _dy > py) {
88-
colour &c = p.colours[*cdata];
88+
colour &c = p.colours[pgm_read_byte(cdata)];
8989
drawPixel(px, py, c.get());
9090
}
9191
cdata++;

util/tiles_sprites.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
static const unsigned char tiles[] = {
1+
static const uint8_t tiles[] PROGMEM = {
22
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33
0x00, 0x00, 0x00, 0x03, 0x03, 0x03, 0x00, 0x00,
44
0x00, 0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x00,
@@ -2048,7 +2048,7 @@ static const unsigned char tiles[] = {
20482048
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20492049
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20502050
};
2051-
static const unsigned char sprites[] = {
2051+
static const uint8_t sprites[] PROGMEM = {
20522052
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20532053
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20542054
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0 commit comments

Comments
 (0)