SD reader question

Topics related to the API, programming discussions & questions, coding tips, bugs, etc. should go here.
Post Reply
User avatar
HiperDoo
Posts: 3
Joined: Tue Oct 27, 2020 7:39 am

SD reader question

Post by HiperDoo »

I think someone else already commented on it, but I can't find the thread, so here's the question.

The SD card has the game code and the ATmega644 reads it in real time while it runs? Or to play several games is it necessary to load one at a time to play it?

How can you execute code saved in an SD on the ATmega644?
User avatar
D3thAdd3r
Posts: 3170
Joined: Wed Apr 29, 2009 10:00 am
Location: Minneapolis, United States

Re: SD reader question

Post by D3thAdd3r »

The ATmega can only run code from flash, not from ram or SD directly. Code/data must be read from the SD and written to flash first.

You could run programs directly from ram or SD, but it will not be native ATmega machine code. Instead you could implement a virtual machine to operate from any source you want. There will be a performance penalty of course, and the development tools for the virtualized program could be limited. Personally I think emulating a 6502 from SPI ram could be interesting, and there is already a host of existing 6502 machines and code out there.

EDIT: yes traditional games must be loaded one at a time, since they use flash code. You might be able to squeeze multiple smaller games into a single actual program of course, like 65536-in-1. To further complicate, it may be possible to do partial flashes, perhaps to swap in and out graphics and level data, but no one has demonstrated it yet that I know of.
User avatar
HiperDoo
Posts: 3
Joined: Tue Oct 27, 2020 7:39 am

Re: SD reader question

Post by HiperDoo »

Yes, it is what I imagined, so how Uzebox managed to save games on the SD card and then read them on the ATmega644, or does it not work like that? Just flash all possible games?
User avatar
D3thAdd3r
Posts: 3170
Joined: Wed Apr 29, 2009 10:00 am
Location: Minneapolis, United States

Re: SD reader question

Post by D3thAdd3r »

Just flash all possible games using a PC. A game can write to SD however. Most games that store progress, write to EEPROM. Toorum's Quest was an early example of writing to an existing file on SD to store progress. More could be done here, you could probably make an Uzebox Office Suite with word processor, etc if you really wanted to.

Hypothetically, it would be possible to use the ESP8266 to download ROMs from the Internet, and write them to SD. Maybe someone will make that program, so we don't need a PC anymore.
User avatar
HiperDoo
Posts: 3
Joined: Tue Oct 27, 2020 7:39 am

Re: SD reader question

Post by HiperDoo »

Ok, thanks for the information, it was useful to me.
Post Reply