How to Build a Portable, Eco-Friendly, Interactive 2D Graphics Demo out of Spare Parts*
How do you make an emulator cross-platform without tying it to a bunch of OS-specific display and user input subsystems? And how do you avoid wasting CPU (and draining the user's battery) while idle? I'll tell you how I did it for my own emulator, and help you make your own interactive graphics demo.
When you use a virtual machine or emulator, the guest OS provides the window system, and all you need from the host is access to a framebuffer and user input devices. But is every emulator codebase supposed to include code for every host display API and keycode translation? And should we just accept that input polling and screen updates will chew up CPU (and battery) as long as the emulator is running?
In this talk, we’ll explore the solution I came up with. For input, a simple stream protocol transmits pointer and keyboard input (possibly across a network). For display, a memory-mapped file stores the image bits, format description metadata, and a process-shared condition variable for zero-CPU idling.
I’ll show you how I use this combination to make a familiar GIF animation interactive and to power a 68K Mac emulator. Then it’s your turn — download the developer kit from GitHub, try out the sample apps, and then make your own portable interactive graphics applications. (Recommended: bring a laptop with a POSIX operating system and a C/C++ toolchain. GNU/Linux and Mac OS X are known to work.)
emulators, portability, graphics, IPC (inter-process communication)
I've spoken numerous times at hackerspaces, including Noisebridge, Unallocated Space, and Sudo Room. I don't just talk about a subject; I invariably find a way to use it as part of the talk itself.
I gave a shorter version of this talk earlier this year at Unallocated Space's minicon.
Josh Juran is, in all likelihood, the last person in the world to learn 68K assembly language for use in Mac applications. He’s currently developing a Mac OS emulator and a programming language.
- Title: How to Build a Portable, Eco-Friendly, Interactive 2D Graphics Demo out of Spare Parts
- Track: Hacks
- Room: B301
- Time: 10:00 – 11:45am
How do you make an emulator cross-platform without tying it to a bunch of OS-specific display and user input subsystems? And how do you avoid wasting CPU (and draining the user’s battery) while idle? I’ll tell you how I did it for my own emulator, and help you make your own interactive graphics demo.
- Speakers: Josh Juran