nesbox / TIC-80

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

Request: an equivalent to stat(6) on the Pico-8 #1698

Open aebrer opened 2 years ago

aebrer commented 2 years ago

the stat() function on the Pico-8 allows you to view a lot of system information, like memory or cpu usage, in real time, from within your cart. In particular, stat(6) simply returns a string that can be passed in via the command-line argument -p. This can be incredibly useful for defining a unique random seed from the javascript that runs the emulator.

I've been reading through the issues, so I can understand if this isn't something that you want to implement, but I wanted to mention it anyway, as I would greatly enjoy it if I could use it.

Related: Would it be possible to emulate this somehow using memory banks? Maybe save a txt file, load it, store any variables it saves in a memory bank, then load the "real" cart and have access to the data that was written in the other cart?

thanks :)

joshgoebel commented 2 years ago

First we'd need to track memory and CPU usage. :)

aebrer commented 2 years ago

Well... those are definitely useful features, but not really what I'm asking about here.

Not trying to replicate the entire stat() function, just the stat(6)

joshgoebel commented 2 years ago

Would it be possible to emulate this somehow using memory banks? Maybe save a txt file, load it, store any variables it saves in a memory bank, then load the "real" cart and have access to the data that was written in the other cart?

No, carts can't read the filesystem (or other carts)... but outside of tic you could do all this with scripting, just open up the cart, write to it's own actual persistent memory block... then access that data inside TIC either with peek or pmem...

joshgoebel commented 2 years ago

from the javascript that runs the emulator.

If all you care about is the browser environ you could probably look into hacking it's pmem directly, assuming it's just stored in LocalStorage of some such, etc...

aebrer commented 2 years ago

thanks :) that's awesome! I will poke around with that when I get some time!