nesbox / TIC-80

TIC-80 is a fantasy computer for making, playing and sharing tiny games.
https://tic80.com
MIT License
4.87k stars 471 forks source link

Is it possible to read/write the virtual ram in Tic80? #1866

Open another-m00 opened 2 years ago

another-m00 commented 2 years ago

Hi, I was wondering if it is possible for an external program to read or write the cartridge ram (not the rom) in Tic80.

I'm asking this because I had an idea to use some of the reserved future use ram space to communicate with an external program that is specifically made for this, like a plugin.

If this was possible, libretro wouldn't need to use pram for communication, and other plugins could be created for example for a file accessing tool.

This actually fits into the fantasy computer perspective too, since all atari, commodore, sinclair, etc computers had an expansion slot which wrote to a custom memory adress.

nesbox commented 2 years ago

Hi, At the moment it is possible only with a pmem(), I do not see any other variants, also, we have about 12K reserved RAM for the future, and we could give part of it for such purposes.

joshgoebel commented 2 years ago

You can write to the cartridge with sync, no?

nesbox commented 2 years ago

Yes, in theory you could even write your data to the sprites area for example and then use sync() to copy that data to the cart :)

NPO-197 commented 1 year ago

I would also be interested in having a few bytes of reserved memory dedicated for IO with external programs. Or at least some method of receiving input from an external program other then on startup. (by passing the log output to a .txt file on startup you can get pretty good output using trace()) It would be fun to be able to use the TIC-80 as a programmable plugin for other programs! Or to be able to connect multiple instances of the TIC-80 for multiplayer games.

I will have too look into using sync() and pmem(), they might be enough for some of the things I'd like to try out for now, awesome work by the way!