Understanding the language, error messages, etc.
Post a reply

Re: How does the bootloader know where to save the SAV file?

Fri Dec 11, 2015 4:15 pm

Well explained. How is that file called?

Re: How does the bootloader know where to save the SAV file?

Fri Dec 11, 2015 8:38 pm

Zvoc47 wrote:Well explained. How is that file called?

Which file? The loader? That's your LOADER.HEX

Re: How does the bootloader know where to save the SAV file?

Sat Dec 12, 2015 6:05 am

No no. The file with the filepath.

Re: How does the bootloader know where to save the SAV file?

Sat Dec 12, 2015 10:00 am

Oh, that's not a file, it's a dedicated place in FLASH, somewhere close to where your default settings (Screen contrast, backlight, default name etc.) are stored.
Here's the relevant code for reading the game name: https://github.com/Rodot/Gamebuino/blob ... er.ino#L88

Re: How does the bootloader know where to save the SAV file?

Sat Dec 12, 2015 11:59 pm

I am seriously confused now. Is there an emulator??? I need a block diagram to understand this.

How can it be fixed in Flash if for example I have declared a PROGMEM constant somewhere before I have declared the placeholder for the filename? Then everything will be offsetted and corrupted! Right? So that means it's not in the game flash, but probably in the boot section. Am I finally correct?

Re: How does the bootloader know where to save the SAV file?

Sun Dec 13, 2015 9:12 am

Zvoc47 wrote:I am seriously confused now. Is there an emulator??? I need a block diagram to understand this.

How can it be fixed in Flash if for example I have declared a PROGMEM constant somewhere before I have declared the placeholder for the filename? Then everything will be offsetted and corrupted! Right? So that means it's not in the game flash, but probably in the boot section. Am I finally correct?

Well, that is correct, everything would get corrupted if you don't do some trickery stuff.
Note how the Arduino Nano has 32KB of flash while you only get to use about 30KB - that is because first of all ALL at the end of the flash the bootloader is located ( https://github.com/Rodot/Gamebuino/tree ... buino_boot ).
All the way in the back of the flash are also the reserved spaces for default settings and, withunder, filename. So you basically have
<~30KB space for program><~2KB of settings/bootloader, positions all fixed throughout all games>

I hope I could make that a bit clearer now :)

Re: How does the bootloader know where to save the SAV file?

Tue Dec 15, 2015 10:43 pm

Oh. I understand. So those bytes are always at exactly that position, right? Like, at the end of the boot section so that there's more space for the bootloader code when it updates without messing with the settings. Every game knows that it's on that position, right?

Now that I know that, can games use SPM for the boot section? It'd be horrible if the games can use SPM. I suppose that then those variables are only in RAM. Upon reset, they're saved into the boot section by having the bootloader read from the game's RAM leftovers. That explains why registers are used. To not mess with the RAM. But then, this means that those settings have to be at a specified place in RAM. Every game must have that. Now, how does that work?

Re: How does the bootloader know where to save the SAV file?

Thu Dec 17, 2015 3:12 am

Zvoc47 wrote:Oh. I understand. So those bytes are always at exactly that position, right? Like, at the end of the boot section so that there's more space for the bootloader code when it updates without messing with the settings. Every game knows that it's on that position, right?
Exectly, everybody knows where those settings are located at
Now that I know that, can games use SPM for the boot section? It'd be horrible if the games can use SPM. I suppose that then those variables are only in RAM. Upon reset, they're saved into the boot section by having the bootloader read from the game's RAM leftovers. That explains why registers are used. To not mess with the RAM. But then, this means that those settings have to be at a specified place in RAM. Every game must have that. Now, how does that work?

What is SPM? Self-Programming Mode?

LOADER.HEX itself cannot flash a game, it merely tells the bootload which game in the root directry of the sd-card to flash. Any gamebuino game can do that with load_game("MYGAME"). The LOADER.HEX file only provides an easy way to look through games and also provides a way of handling EEPROM storage.

Upon resetting the gamebuino (turning it off and then on) the whole RAM will be wiped, meaning there will be 0s everywhere.

Re: How does the bootloader know where to save the SAV file?

Thu Dec 17, 2015 10:29 pm

SPM is the assembly opcode for Storing into Program Memory. That's why I thought that maybe games use it. Now I see that it's only used in the bootloader. But how do the settings get changed by the game or LOADER.HEX if they are in the boot section and the only way to change them is to use the bootloader? Do they always access the bootloader for that? I think that might wear out the Flash memory fast.

Re: How does the bootloader know where to save the SAV file?

Fri Dec 18, 2015 6:35 pm

First off, flash is only worn out by write cycles, not by read cycles.
Second, iirc it is something like this:

<space for games> <settings> <bootloader>

While you can easily re-write the space for games and the settings the bootloader doesn't allow overwriting itself (duh). There is an additional soft-coded limit which only exists in load_game which prevents a game from over-writing settings.
Post a reply