When compiled to HTML, it was surprisingly easy to inject data inside a PICO-8 cart.
Module.getValue(0x10DA1C); Module.setValue(0x10DA1C, 3);
Then read it or set in PICO-8 like this:
peek(0x4300) poke(0x4300, 3)
I'm using it for a multiplayer game where I want to allow several players selection only when there is an internet connection (I haven't worked on the multiplayer communication yet though).
The user data section is 6912 bytes long, so that's a lot of data for PICO-8.
Potentially this technique can be used to do all sort of really cool things like leaderboard inside the cart, downloadable levels or players, syncing several players together (chat, collaboration games, multiplayer games...).
- Not sure if the index in the heap will remain stable across releases. Is it even stable across carts? It must be decided by some internal logic in Emscripten.
- It works only in web mode of course.
- It works only when embedded in a particular web page.
Thats really interesting. I've been looking how to do networking but with small luck. This might lead the way to a lot of interesting stuff.
Regarding the heap position: surely it might be changing.
BUT you can add a magic number in memory and scan the memory for it.
EDIT: I wonder if there will be an external (C?) API to access the gpio ports, without needing to hack into PICO-8's RAM?
This could prove VERY interesting... Good work finding it. :3
EDIT: And you can also see a SMALL bit of information about the GPIO ports documented on the manual. Just Ctrl-F for "gpio"
Speaking of which, I tried named pipes with the cartridge to do some I/O and it totally did not work the way I expected. The cart gets written to every time a dset is called., but is read once and never read again, so meh.
On the other hand, 128 bytes worth of GPIO is enough to do some good IO for networking, with a websocket-enabling bookmarklet and some vigorous handshaking protocol :)
Do you know when 0.1.7 is coming out?
[Please log in to post a comment]