EWM Update: Raspberry Pi Zero

It has been difficult to find the time to hack on EWM since I went back to work. Busy busy. But I did manage to make some small improvements to better support the Raspberry Pi Zero.

Raspberry Pi Zero on an Apple IIe

The Raspberry Pi Zero is a tiny single board computer with a 1 GHz single-core ARMv6 CPU, 512MB RAM and HDMI and USB connections. They are cheap, around $7 CAD plus shipping, and are capable of running Linux.

Sounds ideal for an emulator. But how fast are they?

To find out, I modified the cpu_test program included with EWM to output the raw CPU speed:

pi@raspberrypi:~/Projects/ewm/src $ ./cpu_test
TEST Running 6502 tests
TEST   Success; executed 88957316 cycles in 8.7700 at 10.1434 MHz
TEST Running 65C02 tests
TEST   Success; executed 65094140 cycles in 6.2140 at 10.4754 MHz

So about 10x the speed of an Apple ][+. Not bad, considering I have spent zero time optimizing the CPU emulation so far. And it is all written in simple portable C without crazy tricks.

Graphics is more interesting. The Pi Zero has no hardware accelerated graphics, at least not supported in Linux, so I have been working on a pure software renderer for text, lores and hires screen. It does not depend on OpenGL and just blits pixels to screen buffers.

This is what the performance looks like when I run the scr_test program:

pi@raspberrypi:~/Projects/ewm/src $ ./scr_test
txt_full_refresh      green      95.103/refresh
txt_full_refresh      color      24.554/refresh
lgr_full_refresh      green      17.619/refresh
lgr_full_refresh      color      17.648/refresh
hgr_full_refresh      green      19.561/refresh
hgr_full_refresh      color      35.250/refresh

(Green is monochrome mode, and it is slower for text because the way I let SDL change the color of the default white text characters. Probably easy to fix.)

The default scheduler in EWM is set to 30 FPS, which means one timeslot in the ‘scheduler’ is 33 milliseconds.

Of those we will need about 5 milliseconds for executing enough CPU instructions and another 5 for random stuff that happens in the event loop.

That leaves just about enough time for a full screen refresh. But it is a bit tight and I’ll be working on getting those numbers down. It will be better if all modes render in at most 20 milliseconds or so.

Work in progress at github.com/st3fan/ewm/issues/120

If you are interested in playing around with my emulator, you can find the project at github.com/st3fan/ewm.

Most of my professional and personal work is Open Source. You can find many projects at github.com/st3fan - feel free to leave a bug report or open a feature request.