I thought you’d realised that wouldn’t work because the vectors are in volatile memory (RAM)?
Anyway, the most obvious solution seems to be to just have separate ‘in development’ and ‘release’ versions of the functions that retrieve the addresses, with the ‘in development’ version storing the addresses in progmem and the ‘release’ version fetching it from the interrupt vectors.
The only problem I see with that is that the Arduino IDE likes to precompile libraries, which means you couldn’t do something like:
#define DEBUG
#include <Arduboy2.h>
But it could be done with template magic:
enum class LibraryMode
{
Debug, Release,
};
template< LibraryMode mode >
uint16_t getDataAddress();
template<>
uint16_t getDataAddress<LibraryMode::Debug>()
{
// Read from progmem
}
template<>
uint16_t getDataAddress<LibraryMode::Release>()
{
// Read from interrupt vector
}
And then the programmer would just have to remember to switch the call when they go into release mode.
Don’t you end up having to do that in the development approach as well?
Just make the PC manager switch the slots?
You’d have to use the PC manager to put the game onto the FX chip anyway.
The PC manager ought to be able to juggle the slot orders, 16MB will easily fit in a computer’s RAM.
In this case, all it would have to do is:
- retrieve the contents of the last slot
- overwrite the last slot with the new game
- append the retrieved slot to the end (adjusting the addresses as it goes)
Spoiler, PROGMEM
is actually defined as:
#define PROGMEM __attribute__((progmem));
So you could (I think) shorten that to:
const uint16_t data_page __attribute__((address(0x00133), used, progmem));