arduino-boy
arduino-boy copied to clipboard
EEPROM Initialization
No way given, aside from normal use, to initialize EEPROM.
This is true. What I did the first time is comment out some code so the data is read from FLASH. Then I forgot about it.
https://github.com/pepijndevos/arduino-boy/blob/master/gameboy.ino#L167
How about this
//This sketch is a way of initializing the EEPEROM for Bill's Arduino (https://github.com/pepijndevos/arduino-boy)
//By Alex McPhail
//I don't care how you use this
#include <EEPROM.h>
#include "output.h"
void setup()
{
for(int i=0;i<=PLAYER_LENGTH;i++)
EEPROM.write(i,DATA_BLOCK[i]);
}
void loop() {}//nothing to do
That would work. How would you suggest to include it in the project? Maybe the init could check if the EEPROM contains valid data and fill it in otherwise. PR welcome.
Actualy, it's a bit more subtle. Since I only store one Pokemon, the layout in EEPROM is different from the one in FLASH.
So what's the difference in the layouts? And you could include it as a separate .ino
If you'll look at output.h
you'll see there are 6 Pokemon, 6 trainer names, and 6 nicknames. Just the first of those are stored in EEPROM. You can see the code in the main loop. The indices start at 0, 44 and 55.
So I've made a fork, and it mirrors your data, thus doesn't need initialization, because it's your save, "copied". All I did was remove all instances of Serial, and changed three 44's to 48's (lines 78, 86, 93). No idea why it's done what it's done :P