4 ms·
I love pico-8, but it’s never really seemed like a VM to me—at least in the sense that there are virtual instructions running in the background. It feels more l
by tmountain 4y ago
I love pico-8, but it’s never really seemed like a VM to me—at least in the sense that there are virtual instructions running in the background. It feels more like the constraints and memory mapping are integrated into an event loop with a Lua API to interact with the “machine”. Does anyone know precisely how the internals work?
- lexaloffle 4y agoThat is exactly how it works -- the implementation doesn't look much like an emulator for real hardware. Although there is a VM running underneath (a lightly modified Lua 5.2 VM), it is not exposed to the user except for the purpose of counting cpu cycles (around 2 per vm instruction). Operations like drawing sprites subtract cycles from the same pool using over-simplistic rules e.g. 1 cycle per non-clipped pixel. There is a limit on Lua memory (2MB) which is similarly silly -- every time it is exceeded, an emergency garbage collection is issued to find out if an OUT OF MEMORY error is needed. PICO-8 is driven more by the design goal of giving a strong impression of a machine rather than being a well-formed definition of one. It certainly takes liberties with what should be plausible when it suits, but most interactions with the lower level (e.g. poking pixels to video ram) are plausible enough that the fourth wall is not broken. There are machines that go all the way down to the metal though, which gives them their own kind of allure: uxn has its own tiny instruction set: https://100r.co/site/uxn.html https://100r.co/site/uxn.html Mega68k runs on a Motorola 68000: https://twitter.com/Enichan/status/1463687787782324224 https://twitter.com/Enichan/status/1463687787782324224 CHIP-8 has its own vm & display format: https://en.wikipedia.org/wiki/CHIP-8 https://en.wikipedia.org/wiki/CHIP-8 OK Computer: MOS 6502 processor + SID + gfx: https://lemonspawn.com/ok64/ https://lemonspawn.com/ok64/
- tmountain 4y agoWow! I am honored that you took the time to provide such a comprehensive response. Thanks for all the work you’ve done with pico-8. It has brought a lot of people (myself included) a lot of joy!
- codeflo 4y agoI think Pico-8 tries to capture the spirit of 8-bit computing more than the reality. The most popular 8-bit computers came with a BASIC, and many home users (me at the time included) programmed that to move some sprites around, and never really went into assembly language. Lua seems more inspired by BASIC than most modern languages, so Pico-8 feels like coding for a very friendly 8-bit computer with an ultra-high-powered BASIC. But it doesn't really simulate an actual CPU that this BASIC interpreter would run on.
- AstralStorm 4y agoInterestingly enough the machines PICO-8 is inspired by can pull of way amazing things that are miles beyond what it offers. (See demoscene.) PICO-8 is on par with the old Tiger Electronics game.com "console" or even a bit worse, quite a lot inferior to NES. Even then, with cleverness you can do a lot with it. Including proper raycasting. Picostein 3D. :) Or rather POOM. Even with their quirky hardware choices and slow CPUs. The style was mostly due to speed wotg which the games were cranked out, plus lack of knowledge and skill of particular authors. Pooling knowledge leads to some amazing results.