Apple Pi

A bare-metal Apple II emulator for the Raspberry Pi

Similar projects worth following
Apple Pi is a bare-metal Apple II emulator for the Raspberry Pi. At the current state, no physical modifications are required to the Raspberry Pi. The goal is to have an emulator that will offer all software capabilities of a real Apple II.

It is currently at a very early stage, but the source will eventually be open and released under the GNU General Public License.

The emulator is the product of playing around with "bare metal" coding on the Raspberry Pi.

It's written in C and assembly and boots in less than one second, which is pretty close to the real deal.  No USB keyboard support yet, to interact you need to connect a serial terminal to the UART pins on the GPIO header.

Current screen modes supported are text, HGR and HGR2 in monochrome and paging support.  It loads a DSK image embedded in the kernel, next up is SD card support to access floppy images on the fly.

  • 1 × Raspberry Pi

  • Disk emulator demo

    Stian Soreng06/03/2014 at 21:48 0 comments

    Just a quick video to show the disk emulator in action. SD card support is still in the works, so I'm just switching between three images embedded in the kernel.

  • Disk drive emulated, works

    Stian Soreng06/02/2014 at 06:46 0 comments

    The disk emulation is finally implemented! It was a nightmare to emulate everything from stepper motor magnets to the byte encoding, but now it loads .DSK images without problems and runs games and demos.

  • Apple Pi runs its first demo

    Stian Soreng04/04/2014 at 06:47 0 comments

    The disk controller emulation is not yet in place, but I cheated a little and injected a program into the Apple Pi's memory anyway and got an old cracktro running.  I also compared the results with another commercial emulator named Virtual ][, and the results were more or less identical.

    The next goal is to finish the disk controller emulation, and then start playing with libcsud to see if I can get an USB keyboard working.

  • Speaker support, menu added

    Stian Soreng03/13/2014 at 22:07 0 comments

    A speaker has been implemented and now plays the square waves generated by the CPU.   I can tell by the sound and the pitch of it that it's not perfect, but it's something I'll work on.  The speaker is controlled by the CPU toggling one GPIO pin via the $c030 register.  Think of it as manual PWM.

    I also added an on-screen menu display.  Not all menu items are implemented yet, but F1, F3 and F12 works.  Disk support is still in the works.

    Just for fun, I tested the emulator with an Apple ][+ ROM today.  No compatibility issues, works like a dream.

View all 4 project logs

Enjoy this project?



johnhomes wrote 03/04/2015 at 10:47 point

For USB serial port users and non-Raspberry Pi owners: This isn't
actually tied to the Raspberry Pi in any way, except for the default
serial port used to connect the Pi to the Apple II. On most up-to-date
Linux distributions, you should be able to build all the files. To run
the daemon on a specific serial port, just add it as a command line
option i.e. a2pid --daemon /dev/ttyUSB0

Reboot the Apple II with the newly created floppy in the start-up
drive. If everything is configured correctly, you should be able to
login to the Raspberry Pi with your Apple II keyboard. If you have an
Apple II Mouse, that should control the cursor in X, or in the console
if you have gdm installed.

Using a2pi: The Apple //c and //e keyboards are pretty minimal
compared to modern keyboards, and the Apple II Mouse only has one
button. In order to provide most of the funcitonality required of
modern OSes, the Open-Apple and Closed-Apple keys are used as modifiers
to enhance the keyboard and mouse. On the keyboard, Open-Apple acts
just like the Alt key. The Closed-Apple key acts like a Fn key,
changing the actual key codes. Currently, the Closed-Apple key will
modify the number keys 1-0 as funciton keys F1-F10 and the arrow keys as
Left-Arrow=Home, Right-Arrow=End, Up-Arrow=PgUp, Down-Arrow=PgDn. For
the mouse, when you click the mouse button by itself, that is the
left(default)-click. Open-Apple along with the mouse button will return
the right-click, and Closed-Apple along with the mouse button will
return the middle-click. a2pid can be run directly (not as a daemon) by
leaving off the '--daemon' option. Enabling printf's in the code
allows one to watch the packets arrive and get processed when run from a
network ssh session.

Theory of operation: Apple II Pi works by running code on the Apple
II and the Raspberry Pi, talking to each other with a simple protocol.
The Apple II basically appears to the Raspberry Pi as an external
peripheral, not unlike a USB keyboard and mouse. The Apple II floppy
boots into ProDOS and runs a simple machine language program that scans
the keyboard, and mouse if present, sending the events out the serial
port to the Raspberry Pi. It is a very simple protocol and the serial
port is running at 115.2K baud, so it is fast and low overhead. On the
Raspberry Pi, a little daemon runs, waiting for packets on the serial
port, converts the Apple II events into Linux compatible events, and
inserts them into the input subsystem. This daemon also has a socket
interface (port 6551) that can be used to access the Apple II memory and
execute arbitrary code. Look at a2lib.c for implementation.



  Are you sure? yes | no

Stian Soreng wrote 05/26/2015 at 07:50 point

Hi JohnHomes, this project is not related to the "Apple II Pi" at all. Your comment is a copypasta from and I kindly ask that you remove it.

  Are you sure? yes | no


[this comment has been deleted]

Stian Soreng wrote 10/16/2014 at 10:38 point
antonizoon: Absolutely! I'm already considering a daughterboard for the Pi with keyboard and diskdrive connectors.

  Are you sure? yes | no

Stian Soreng wrote 09/29/2014 at 08:52 point
Absolutely! I have already released an early preview (on my blog) but will release images here as well as soon as I get the SD card driver and keyboard support up and running. They are crucial to the user experience.

  Are you sure? yes | no

Henry Wait wrote 09/27/2014 at 15:58 point
Awesome man! Will you upload a SD img somewhere sometime?

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates