Week of the 06/16/2025 - #25
Contents
tech
- Update on my Arduino Disk Drive for my Apple //c
- Other Apple II Resources
- Game console architecture
Update on my Arduino Drive for my Apple //c
I finally have a working version for my Apple //c! I can now boot standard disks which are stored in dsk
or po
file format. Even though the Arduino Nano has only 2k of RAM I managed to hook it to my Apple //c, simulate a Disk II drive, connect an SD card with Fat32 to store as many images as I can fit and even connected a SSD1306 based LCD display and buttons to select the active drive. It has several limitaions:
- Disk images have to be in
nib
format (with so little memory I can’t convert it on the fly from.dsk
o.po
format) - The name can not be larger than 32 characters
- Write is not working (yet)
- If the disk has any type of copy protection it will probably not work.
For what I’m interested in doing this is good enough. My main interest it to write assembler or basic programs (on an emulator) and be able to load it to my Apple //c and see them run there. I also needed to be able to boot a memory tester (which I did and found out my AUX memory is busted) and calibrate my disk drives (which I also noticed are completely off which is probably the reason I can’t boot anything off them).
The code is based off a couple of existing projects. I will eventually create a nice Github repo with it and acknowledge the original authors of the projects. I’m also starting to do two things: 1. work on creating a more permanent circuit for everything and 2. think about adding write support. While I was thinking about 2. I came across this project: AppleIIDiskIIStm32F411. This is yet another drive that uses a different microcontoller: an STM32F411. This chip, like the ESP32 used in the Fujinet project is much more powerful than our Arduino Nano. None the less, I like the way he solves the timing issues needed to communicate with the Apple II. Here are my notes on what I learned from the code:
- Another way to send/receive data at a consistant rate: configure a timer to trigger every 4us.
- All the relevant code is in this file: Core/src/emul_diskii.c
- The code has interrupt handlers for:
- change in WRREQ line (write request line) (
DiskIIWrReqIRQ
) - change in SEEKPH0-SEEKPH3
- read timer (when reading from disk) is triggered once every 4us (
DiskIISendDataIRQ
) - write timer (when writing to disk) is triggered once every 4us (
DiskIIReceiveDataIRQ
) - the device is selected (MotorOn / MotorOff) (
DiskIIDeviceEnableIRQ
)
- change in WRREQ line (write request line) (
To use the timer trick we would probably need to use the Timer1 of the Atmega328. Here’s some documentation:
- Generate Time Delay - Using The Atmega328 Timer1 in Normal Mode (YouTube). - This video describes how to use the Atmega328 Timer1 in Normal Mode to generate a time delay. We need something similar but using an IRQ routine that will get triggered every 4us.
Resources
-
Apple II DISK Emulator using STM32 - Applrftitter post - Initial thread talking about the AppleIIDiskIIStm32F411 project. A lot of interesting comments. Wish I knew about this a long time ago! Some interesting bits:
July 22, 2024 - 11:42am On the WRITE SIDE: I remove as well the LS123 and the Counter the LS393, I changed TIM4 to TIM2 (due to pin occupation issue), ETR_TIM2 is connected to /WRDATA and triggers TIM2 that is a 2Mhz timer (2 uS pulse, 4 uS period) auto reload timer, (trigger and reset), without ETR_TIM2 pulse (TIM2 continues and get resync every pulse). August 12, 2024 - 9:34am VIBR realizes he can’t use SPI which is a problem I also faced. The reason is that SPI transfers in bytes and the gaps between transfers screws the timing. He will use timers and “bit banging” which I something I might implement on mine. - IWM reverse engineering - Huge thread on reverse engineering the IWM used in the Apple //c
- How important are the IWM features for the Apple IIc ? - A huge thread about IWM used in the Apple //c
- Uncle Bernie’s “Replica 2e” (WW Prototype of an Apple IIe replica) - “Replica 2e project which aims to produce a substitute for all Apple II from the early ones to the Apple IIe and the Apple IIc without using any of Apple’s proprietary custom ICs, like the MMU, IOU and the IWM.”
Other Apple II Resources
- Passport - a verification and copy program for 5.25-inch Apple II floppy disks. An awesome tool to automagically remove copy protection from a disk.
- Million Perfect Letters - A very well programmed Apple II game. Has nice graphics and pretty fast. Will study a bit the source code. The music is pretty nice for a game that uses the built in speaker. It uses
electric.duet.a
which I talked about a long time ago.
- Glider for Apple II - Another very neat game. Will look at the source code. Github repo: the source is in the directory
src/glider
. I need to see what other goodies are in that repo. - Yes, the Apple II MouseCard IRQ is synced to the VBL - A recent article about the sync between the mouse IRQ and VBL.
- Wozamp – an Apple II music and video player - Wozamp is a simple network music player for the Apple II. It can Browse a network share (FTP only) and play sound media files (almost any format).
- Reverse engineering of Lode Runner - Reverse engineering of Lode Runner for the Apple II series is an incredible project. The author produced the
.asm
file for Loderunner and in the meantime documented all the source code a la Knuth! Here is the PDF - Reverse engineering of Zork 1 z-machine - Another awesome project this time for the Zork I z-machine.
Game console architecture
Here are two vwery complete guides on the architecture for game consoles I own: