Thu May 25, 2017 8:36 pm
Thu May 25, 2017 10:13 pm
Fri May 26, 2017 7:27 am
Fri May 26, 2017 2:54 pm
write_flash_page((const char*)ADDRESS_IN_FLASH, rambuffer);
uint8_t b = pgm_read_byte(ADDRESS_IN_FLASH);
Tue May 30, 2017 3:40 am
rodot wrote:Wow, I never thought of using the SD card for paging RAM like this. Impressive work!
Sorunome wrote:Reading the wikipedia article about CHIP-8 it seems like the 4K is not all ram, so you could maybe load the program to flash and then use the ram only for the dynamic stuff?
EDIT: since CHIP-8 is interpreted that would actually be really simple, except if CHIP-8 allowed self-modifying code. But if it doesn't, just load the program into flash and fetch the bytes from there to read from.
Sorunome wrote:Also, your loading code seems very....sub-optimal.
https://github.com/wuuff/chip-8-gamebuino/blob/master/memory.ino#L90-L97
You only load memory stuff 20 times a second, to greatly increase that just do that updating still inside of the while-loop but outside of the gb.update() if-condition!
Sun Jun 04, 2017 8:43 am
Mon Jun 05, 2017 7:43 am
Myndale wrote:This is terrific work!
I had a play with the code myself today and managed to find a few easy to implement optimizations. As others have noted the game loading doesn't have to be that slow, it's actually waiting for a complete screen refresh (1/60th of a second) for every byte. I had to remove that loop for other reasons, but doing so caused games to load almost instantaneously.
Gamebuino uses 504 bytes for its backbuffer but chip8 needs only 256. I modified the Gamebuino library to accept a ptr to the backbuffer at runtime and I modified the display and flip routines to work with a 256-byte buffer...that's bought you another 248 precious bytes of working space.
The main performance issue, as far as I can tell, is due to chip8_execute() only being run twice per game loop. That's a huge amount of overhead per instruction. Increasing it to something higher (I used 16) gets you pretty-much up to full speed.
The other main change I made was combining all the buffers (display, cache, rom table etc) into a single block. That seems to let you push the overall size a bit higher, probably because of reduced memory fragmentation.
I did have a go at implementing a basic 2-way set associative cache like what you see on things like the PSP/MIPS platforms etc but it added significant complexity for not very much gain. My guess is the 512-byte buffer in the SD card library is effectively caching memory to begin with.
I've committed my changes to a fork at https://github.com/Myndale/chip-8-gamebuino, they're in the "optimizations" branch. I've also added a pull request to make it easier if you want to take a look.
Mon Jun 05, 2017 8:34 am
while (true) {
cip8_execute();
gb.update(); // make sure that the screen gets updated at 20FPS or whatever you set it to
delay(20); // pause for 20 milliseconds
}
Wed Jun 14, 2017 9:13 am
Tue Jun 20, 2017 12:14 am
Sorunome wrote:Also, when you feel this is ready, don't forget to add it to the Games Library! ^.^