EWM Update: Lo-Res Graphics

I’m slightly surprised that I am still hacking on this side project. Usually life and actual work get in the way or drain the energy to levels where I don’t want to write much code at home.

But here we are .. I now have an Apple ][+ with 48 K RAM, disk controller, text and lo-res graphics pretty much implemented. See two screenshots of the COLOR DEMOSOFT app from the DOS 3.3 System Master disk. I think the colors are pretty decent, but they should probably be a little more bland.

LoRes Colors 1 LoRes Colors 2

My goal was to run Lemonade Stand, and I am getting close. The game actually works but it runs so fast that the interstitials take like 200 milliseconds. I did not spend much time on speed accurate emulation yet.

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

EWM Update: Parsing the original Character ROM

So far I’ve been using the Apple2Forever TrueType Font to render text modes. These look nice but are not really original for an emulator.

So I wrote some code to parse the original Apple ][+ Character ROM and turn those characters into SDL compatible bitmaps. The ROM format is very simple, one line of the character bitmap per byte. Seven bytes per character.

Later I will add color variation, scanlines and maybe a blurr effect to make it look more like a classic CRT.

TrueType Fonts Character ROM

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

EWM Update: Disk Progress

Here is some Disk ][ progress I made. The code that I finished on the weekend frustratingly did not work. It had just one weird bug in it, which truncated ‘raw’ tracks by 16 bytes. I think this threw off the disk firmware because it could not correctly synchronize. One line fix after I correctly diagnosed it this evening.

Big inspiration for this code is the Open Source Apple2JS Project project combined with reading Beneath Apple DOS.

This is not finished yet, but I think it works well enough for now.

Switching focus now to some more basics like supporting both text modes and low res graphics. My next goal is to be able to play Lemonade Stand in ‘full’ color.

(Lemonade Stand because I used to play it when I was a kid and it is a nice simple game with just Lo-Res graphics and text.)

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

EWM Update: BASIC Prompt

Here we go. The font rendering is a bit weird. Not sure what happened there. But it boots, it tries to beep (no speaker emulation though) and then it is mostly usable. What is next? A Disk ][ implementation?

BASIC Prompt

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

EWM Update: It Boots!

Ok that escalated quickly. I have a ‘game loop’ in SDL now and some basic rendering of text page 1. It boots! With a BASIC prompt! And I can type random stuff that results in a ?SYNTAX ERROR so something good must be happening.

It Boots!

For some reason it thinks that the forward slash is being typed continuously. Not sure what is happening there. I am probably not understanding correctly how KBD ($C000) and STROBE ($C010) should work. That will be a good task for the weekend.

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

EWM Update: ][ELPPA

May not seem like much, but here is a little milestone for my emulator. It is booting up as an Apple ][+, printing APPLE ][ (in reverse) and then printing ABCDEF? and OUT OF MEMORY ERROR followed by a ] prompt.

Apple II Booting up

I have a lot of work to do, but this is promising. I hope to have a decent SDL-based (OS X, Linux, Windows) version done by the end of the year that can boot a DOS 3.3 disk.

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

EWM Update: Apple 1 Progress & Booting the Apple ][+ ROM

Here is some more progress with my 6502 / Apple1 emulator.

Lots of fixes and features .. I forgot to implement some instructions, SEC, SED, SEI. Oopsie. Now I can load ROMs from disk, detect invalid instructions. I implemented APIs to register memory (RAM, ROM, IO) regions. There is now basic interrupt support, although the Apple 1 does not use those at all.

The screenshot shows the emulator with the KRUSADER ROM loaded. (Which is an assembler for the Apple 1 / Replica 1).

KRUSADER

And big news, I booted up an Apple ][+ ROM succesfully! I have no display emulation yet, but in a CPU trace I can see it boot and then correctly poll the keyboard in a loop. So that is a start of something.

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

EWM Update: Hello World

Made some good progress with my 6502 / Apple I emulator. It now runs the WOZ Monitor succesfully.

Here is a screenshot of the virtual Apple I booting up, and me entering and running a little Hello World program. (In a terminal window with the Apple2Forever Font).

It is not entirely clear what happens after the final RTS of an entered program though. So the emulator simply stops.

Apple I Hello World

(Also note the low number of instructions executed. Right now my PIA, the chip that connects the keyboard and display to the CPU, implementation blocks on keyboard input. That is fine because the Apple I is so simple that this really makes no difference. But in reality the WOZ Monitor keyboard subroutine would loop to poll if a key was been pressed. And thus generate millions of instructions being executed. Something to worry about later.)

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

Emulated Woz Machine

Two years ago in 2014 I put together a half complete barely functioning emulator for the Apple 1. I called this project Emulated Woz Machine, an ode to the brilliant Steve Wozniak.

I found some new energy to continue working on this project. To kick it off I wrote a small patch and also started filing issues for things that need to happen to turn this project into something bigger than just a Christmas break hack.

My plan is to emulate the following:

  • The Apple 1, as sold in 1976 with an original 6502, 8KB RAM and just the Woz ROM.
  • The Replica 1, which is a modern re-implementation of the Apple 1 with 48KB memory, a 65C02 CPU and a ROM that runs either Applesoft Lite or KRUSADER
  • The Apple II family of computers, starting with the Apple ][+

And here are some initial thoughts about how to get there:

  • Cross platform (macOS, Linux, Window) code in plain C
  • Based on SDL 2.0
  • Fully Open Source

I specially think there is a strong need for a good Open Source Apple II emulator. There are some available, but then only for Windows, or not maintained, or half complete. I intend to change that with the Emulated Woz Machine.

Christmas Break Project

Over the Christmas break I put together a small side project to emulate an Apple 1. I grew up with an Apple ][+, which has the same CPU. It was fun to look back at 6502 assembly language.

Hello, world!

The Apple 1 is a remarkable machine. Open source did not formally exist in 1976, but in the true hacker spirit, everything about the Apple 1 was well documented and publicly available. It came with instructions on how to modify the computer, it’s schematics and also the source code for it’s Monitor, which was really just a minimal way to enter programs by typing hexadecimal codes.

Using this information about the hardware design and the software, it was fairly trivial to implement an emulator.

Wikipedia has a great Apple 1 entry with lots of detail. You can find a scan of the original Operation Manual (PDF) at the Computer History Museum.

My emulator contains a straightforward implementation of the 6502 CPU, which is a very simple 8-bit processor with just three registers and about sixty instructions. Originally it runs at 1.023 MHz, or about 2500 times slower than a modern laptop. I have made no attempts to optimize the code in any way and it seems to run at about 80 MHz. There is also no speed throttle, so the Apple 1 is really going crazy fast.

There also is a minimal implementation of the 6821 Peripheral Interface Adapter (PIA), the second major component in the Apple 1. This chip was responsible for moving data to the screen buffer and taking data from the keyboard.

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