Zig implementation of the Eternal Software Initiative VM
- Zig 100%
| .forgejo/workflows | ||
| src | ||
| .gitignore | ||
| build.zig | ||
| build.zig.zon | ||
| README.md | ||
Eternal Software Zig VM
This is a Zig implementation of the Eternal Software Initiative VM.
To make it more "flexible", and to learn, input and display are provided through a dynamically loaded library. There are currently only two possible implementation
stdio: input is provided through stdio (Windows not supported), and output through stdout, each frame provided as a PPM image. It can be piped to ffplay with the following command:LD_LIBRARY_PATH=./zig-out/lib ./eternal-vm vmlinux.bootimage | ffplay -autoexit -f image2pipe -framerate 30 -probesize 32 -vf "scale=800:522:flags=neighbor" -hide_banner -loglevel error -i -fensterl: keyboard input is about 80% supported. Should work on Linux (X11), Windows, and MacOS. Only works on Linux so far.
Build and use
The build.zig file will build the main executable, the dynamic libraries, and the original (console only) code.
# Build a small executable, it is roughly as fast as ReleaseFast. Use the fensterl module.
zig build -Doptimize=ReleaseSmall
# Run the mandelbrot program
LD_LIBRARY_PATH=./zig-out/lib ./zig-out/bin/eternal-vm mandelbrot.bootimage
Implement an IO module
You can implement your own module, it should implement the following methods:
*void init();
void deinit(ctx: *void);
void setDisplay(ctx: *void, data: *uint32_t);
int32_t getInput(ctx: *void);
Then build it and name it libevmio.so or evmio.dll depending on your OS, put it along the executable and launch your capsule.