Understanding the language, error messages, etc.
by noah » Sat Oct 08, 2016 5:28 pm
Hi,
How would I save data to the SD card, I want to save a score variable to be shown in the next game... I looked through some of the examples but didn't really understand what was going on. What is the easiest way?
Thanks in advance, Noah
-
noah
-
- Posts: 25
- Joined: Mon Jul 25, 2016 8:32 am
- Location: Spiffin' Britain
-
by Sorunome » Mon Oct 10, 2016 5:19 am
For simple highscore storage stuff you use the EEPROM, the loader automatically handles saving that to sd card and loading from it
-
Sorunome
-
- Posts: 629
- Joined: Sun Mar 01, 2015 1:58 pm
-
by noah » Mon Oct 10, 2016 5:58 am
How do you write to eeprom? It doesn't appear to have anything about it in the reference.
-
noah
-
- Posts: 25
- Joined: Mon Jul 25, 2016 8:32 am
- Location: Spiffin' Britain
-
by rodot » Mon Oct 10, 2016 9:09 am
That's because the EEPROM library is part of Arduino, not Gamebuino
See the
Arduino EEPROM library reference.
-
rodot
- Site Admin
-
- Posts: 1290
- Joined: Mon Nov 19, 2012 11:54 pm
- Location: France
-
by wuuff » Tue Oct 11, 2016 6:29 am
I think it would be really helpful if the reference had a brief discussion of the way that the loader deals with the eeprom, because I had to look through the source of the loader to be sure I understood how it worked.
If I recall, the loader automatically saves the eeprom of a program whenever it starts if any byte in the eeprom is not zero, and the eeprom contents are saved in a .SAV file on the SD card with the same name as the game. Otherwise, it will not bother to save it. Then, right before flashing a game, it checks whether a save file exists for that game and, if so, populates the eeprom with the contents of that save file. I wanted to check this when I was adding highscores to a game because it was not clear to me at first whether I needed to do anything special besides just writing to eeprom.
Is it welcomed here for anyone to make additions to the wiki? I think it would be helpful to have a simple explanation about this, and I would be happy to do it myself if nobody objects to the idea. I just don't want to upset anyone if somebody objects and thinks it isn't needed.
-
wuuff
-
- Posts: 61
- Joined: Sun Aug 28, 2016 6:05 am
by Sorunome » Tue Oct 11, 2016 7:04 am
What you just said about the eeeprom is correct, it would be great if you could add it to the wiki for others!
-
Sorunome
-
- Posts: 629
- Joined: Sun Mar 01, 2015 1:58 pm
-
Return to Programming Questions
Who is online
Users browsing this forum: No registered users and 45 guests