JMarlin / nesii

0 stars 0 forks source link

[NES II] Run NES game image from DOS filesystem #8

Closed JMarlin closed 3 months ago

JMarlin commented 3 months ago

Description

With the read-only filesystem basically working and an ability to load and run large binaries from disk, the next logical step is to slap some NES cart payloads onto the disk along with a little loader binary that can do the loading and jump into the cart -- just like we were doing with raw disk NES games, but pulling from the FS instead (so ostensibly we should be able to put multiple games on the disk)

My general idea is to extract the binary file loading from the run command and into its own os function that the loader can also use. Then we can have the loader, two 16k PRG files, and an 8k CHR file on the disk. The PRG files we can just make self loading so that the loader stub literally just has to effectively do a "load mario_a.prg" and it'll put itself into the right area.

A tricky thing here is that we have to use 100% of the cart SRAM to store the game code, so this is also going to need to involve making sure we can load all of NOS and the loader stub into the RAM available in the NES. Which is like 768 bytes or so. (2k - 0.25k ZP - 0.25k stack - 0.25k sector buffer - 0.25k twos buffer - 0.25k text buffer = 2k - 5(0.25k) = 2k - 1.25k = 0.75k). Might be able to get away with stealing the text buffer to get a full 1k.

Acceptance Criteria

JMarlin commented 3 months ago

Ideas for moving around NOS to fit this scheme:

JMarlin commented 3 months ago

Moved the floppy.asm stuff, tested with the nos_romemu mode and it appears to work okay so far. Still over by 300-something bytes, but I have hope that we can get rid of that by ditching the command processor.

JMarlin commented 3 months ago

Move NOS load position to just above the text buffer, make sure it can fit into ~3 sectors and run properly

Moved it, made sure it fits, haven't tested though so I can't mark this complete yet until I can test with the shell binary.

JMarlin commented 3 months ago

NOS has been split into the system and the shell and is confirmed to run properly from disk