Hi folks!
I am working on a project for the ATtiny85, so flash memory is always a problem.
I have some bitmaps defined in a separate header file, defined like this:
const unsigned char joey [] PROGMEM = { 0x00, 0x00, 0x00, 0x00, ........, 0xf0, 0x98, 0x9c };
Then I have a table to access all these bitmaps by a key value (defined in the same header file):
// list of possible non wall objects (i.e. monsters, doors, ...) (11 bytes per object)
const NON_WALL_OBJECT objectList [] PROGMEM = {
// itemType , width, verticalOffsetBits, heightBits, lineOffset, maxView, scalingThreshold, bitmapData
{ SKELETON , 28, 2 * 8, 5 * 8, 56, 3, { 1, 2, 99 }, joey },
...
{ RAT , 20, 5 * 8, 2 * 8, 40, 2, { 1, 2, 99 }, rat },
};
My problem occurs if I'm accessing this table (or a single bitmap, e.g. joey) in two methods of a class (e.g. Dungeon).
This appears to make the linker include the bitmaps (if a bitmap joey was accessed)
or all bitmaps in the table (when objectList was accessed) a second time.
I'm quite sure, because my flash size increases by sizeof(joey) or sizeof(all bitmaps).
I don't understand this behaviour...
I'm sure that all bitmaps are already in the flash, because I'm using them all the time.
The code is working fine on a larger MCU and compiles without warnings.
I can reproduce the problem with Arduino 1.8.16 (avr-gcc) and Arduino 2.0.0rc3 (clang), so this will most probably be a problem with my code.
Any ideas? I can provide more code if necessary.
Thanks in advance,
Sven