BMOW title
Floppy Emu banner

Archive for May, 2015

Apple IIc ROM Upgrade

20150528_155647_resized copy

The more I learn about the Apple II world, the stranger it seems. Who knew the Apple IIc went through four different ROM versions, each with different capabilities, but mentioned nowhere in the model number or product label? I recently bought a IIc system, and discovered it had the oldest of these ROM versions, meaning it lacked support for external Smartport disks. Experimenting with a Smartport hard drive was the main reason I wanted the IIc, so that was a problem! After a bit of research, I did what any self-respecting hacker would do, and replaced the IIc ROM myself with a simple logic board modification. Fortunately I learned a few interesting things along the way.

Finding an Apple IIc

20150528_154918_resized copy

The IIc that I bought was a fairly nice one, with minimal yellowing, and the external power adapter included. If you’re searching for a IIc system on eBay, you’ll quickly notice that 80% of them don’t include the power adapter. And to make matters worse, the power adapter uses an uncommon DIN plug, so you can’t just substitute a modern laptop power supply with a standard barrel plug. What happened to all the original Apple power adapters? Did everyone carefully pack away their IIc system in the attic in 1990, but throw the power adapter in the trash? Did they all stop working? Is some guy in Kansas hoarding a stockpile of 10,000 power adapters for the Apple IIc?

Fortunately, someone in New Mexico has a large quantity of new laptop power supplies with an appropriate DIN plug for the IIc, and is selling them on eBay for $18 each. They’re probably more efficient than the original, too.

My IIc system suffered a mishap during shipping. I understand that accidents sometimes happen, but I’ve received too many vintage computers that were minimally packaged, as if expecting the post office to handle them with tender loving care. In reality these packages take a lot of abuse – imagine the box being thrown down a flight of stairs. In my case, the single layer of bubble wrap (with most bubbles popped) surrounding a 10 pound machine didn’t offer much protection. One of the corners got whacked hard, breaking the case surrounding the power switch, and leaving many small pieces rattling around inside.


The system still worked, and I was eventually able to fish out the missing pieces. The seller gave me a partial refund for the damage, and I was able to make a rough repair with a liberal helping of super glue. Onward!

IIc ROM Versions

For the curious, you can type PRINT PEEK (64447) at the BASIC prompt to find what ROM version is present in an Apple IIc. There are four versions:

  • 255 – The original Apple IIc ROM, size 16K. No support for Smartport disks. However, it has a nifty “PR#7” feature that allows for booting from an external floppy drive configured as drive #2, something that’s not normally possible. This was the ROM installed in my IIc. In my tests, PR#7 worked to begin booting from the external drive, but most software seemed to be hard-coded to expect to boot from drive #1. The disks would start the boot process, but then the empty drive #1 would begin seeking in vain. The only disks I found that booted successfully from drive #2 were ProDOS and the game Moon Patrol.
  • 0 – With version 0, the ROM doubled in size to 32K. This ROM version eliminated the option for booting from drive #2, but added support for Smartport disks. The most common of these was the Unidisk 3.5, an intelligent external 800K floppy drive. But the Smartport protocol could also be used to communicate with other types of external disks, including hard disks up to 32MB in size.
  • 3 – Version 3 accompanied a logic board change, making it possible to expand the IIc’s memory.
  • 4 – Version 4 corrected some bugs present in version 3.


You can download binary images of all four versions of the Apple IIc ROM from As far as I can tell, the first 256 bytes of the ROM aren’t actually used, and attempting to read these locations on a running IIc system will modify various hardware switches instead.

ROM Upgrade

Since my IIc system lacked the memory expansion connector, there was no reason to upgrade to ROM version 3 or 4. Version 0 would give me the Smartport support I wanted, so I set that as my goal. But wait! ROM version 255 was a 16K ROM, while ROM version 0 was a 32K ROM. Obviously this wasn’t going to be a simple chip swap.

Looking at the schematics of an Apple IIc, it’s clear there’s some funny business happening with the ROM:


It’s labeled as a 27256, which is a 32K EPROM. But pin 27, which should be the highest address bit (A14), is instead connected to some strange components labeled W1 and W2. Huh? After a bit of poking around, it became obvious that W2 was a solder bridge jumper (normally open), while W1 was a track designed to be cut (normally closed). You can see them both here:


It looks like Apple designed the IIc from the start to support 32K ROMs, but initially shipped ROM version 255 as a 16K ROM, perhaps as a cost-saving measure. This would have allowed them to use 27128 ROMs, which hold only 16K instead of 32K. With the 27128, pin 27 is the /P or “program” pin, which must be kept high during normal operation. W1 (normally closed) connects pin 27 to the supply voltage to keep it high, while W2 is open and therefore disconnected. 16K ROM operation works.

In order to upgrade to a 27256 ROM with 32K, W1 must be cut, and W2 must be bridged. This disconnects pin 27 from the supply voltage, and connects it through W2 to the address bus, A14. Now 32K ROM operation works. It’s not the most user-friendly upgrade path, as it involves making permanent modifications to the logic board, but it’s better than nothing. You can see my cut at W1 and bridge at W2 here:

20150529_102855_resized copy

20150529_102840_resized copy

But say, where can you find a replacement ROM chip in the year 2015? Those old 27256 UV-erasable EPROMs are ancient, and I don’t own a UV eraser anyway. I looked into using a 28C256, an electrically-erasable EEPROM with an almost identical pinout, but “almost” isn’t quite enough. With some creative cutting and jumpering it could probably work, but I wanted a cleaner solution.

Jameco sells a one-time programmable 27C256 that might work. The pinout is the same, and since it can only be programmed once, there’s no need for UV erasing. But what if I made a mistake while programming the chip – I’d be left with a brick. And this particular OTP chip also has a fairly slow access time of 250ns. I wasn’t sure what speed was needed, but the RAM appeared to be 150ns, and I guessed the ROM may have the same speed requirements.

Also at Jameco is a standard UV-erasable 27C256, with a 150ns access time. This looked good, except it was labeled as a refurb product. If it were already programmed with somebody’s old data, I wouldn’t have any way to erase the chip except to leave it in the sun for a week or two, and I’m not that patient.

In the end, I bought one of each. Fortunately, the UV-erasable 27C256 proved to be already erased. After programming the version 0 image to the ROM, and making the necessary logic board mods at W1 and W2, it worked!

20150529_103053_resized copy

A Final Mystery

While I had the logic board exposed, I noticed a few mysterious modifications already present. Just next to the 1.8432 MHz oscillator, a narrow purple wire connected two vias. And nearby, a resistor connected pin 19 of the TMG chip to another via. The purple wire looked very cleanly done, but the resistor was much uglier. Were these older repairs from another hobbyist, or perhaps factory changes made by Apple for some earlier logic board revisions? What are these changes for?

20150528_160826_resized copy

Read 26 comments and join the conversation 

Apple II Firmware and Mods


Judging from the Apple II questions I’ve received, my commentary has left a lot of people confused. Sorry everyone! Here’s a recap of Apple II disk support for Floppy Emu. I’ll try to clarify the current status of Floppy Emu disk emulation, and the plans for the future.

As of today, there are two separate firmwares available. One supports the Macintosh and Lisa (floppy and hard disk), and the other supports the Apple II. Both will work on any Floppy Emu board, and can be downloaded from the product description page. Installing new firmware only takes a few minutes – just copy two files to the SD card, and press a few buttons. You can switch between the two firmwares as often as you’d like.

The Apple II firmware will eventually emulate three kinds of disks:

  • 5 1/4 inch (140K) disks, for any Apple II machine
  • 3 1/2 inch (800K) disks, primarily for the Apple IIGS
  • Smartport hard disks (32MB), primarily for the Apple IIGS and some models of Apple IIc

5 1/4 and 3 1/2 inch disk emulation is finished and working in the current Apple II firmware. Download it now and go crazy! Work on Smartport hard disk emulation hasn’t started yet, but it’s next on my “to do” list.

Hardware Connections

The Floppy Emu board can be connected to an Apple II system in two different ways, depending on your needs. Most people will use the 19-pin disk port. The Apple IIGS and IIc have built-in disk controller circuitry, with a 19-pin disk port on the back of the machine. The Apple 5.25 Drive controller card has the same 19-pin disk port, and will fit in any model of Apple II with slots. The Floppy Emu board can connect to this 19-pin disk port. If you have the Emu with built-in floppy connector, then the board will plug directly into the disk port, and hang off the back of the machine. Or if you have the Emu with convertible extension cable, the adapter at the end of the cable will plug into the 19-pin disk port.

If you have an older Apple II with the Disk II controller card instead of a 19-pin disk port, you can also connect the Emu to one of the 20-pin headers on the Disk II controller card. Use the ribbon cable that came with the Emu convertible extension cable, or borrow a ribbon cable from a Disk II drive. All Emu boards have a 20-pin shrouded header where the cable will plug in. Be careful to orient the other end of the cable correctly, since the controller card’s 20-pin header isn’t keyed or shrouded, so it’s easy to accidentally connect the cable offset or backwards. The red stripe on the cable should go to the pin marked “1” on the 20-pin header.

Hardware Mods

During development of the firmware for 5 1/4 inch and 3 1/2 inch Apple II disk emulation, I discovered that some Apple II setups can’t be supported through firmware changes alone. In addition to new firmware, these setups also require some external hardware modifications for the Floppy Emu board. The easiest way to handle this is with an Apple II adapter board that connects inline between the Floppy Emu and the Apple II computer. Something that looks roughly like this:


I plan to offer an Apple II adapter board as a new product, probably beginning this summer. I’m intentionally going slowly, postponing manufacturing of the adapter boards until the Smartport hard disk work is finished, and I’ve done enough testing to be confident there are no other issues that require hardware modifications. Once it’s ready, the Apple II adapter will be available as a separate item, or bundled with an Emu board for new customers.

As pictured above, the Apple II adapter board is a 19-pin to 20-pin adapter. This will be fine for most Apple II customers, but will be useless for customers using the Disk II controller card, since it doesn’t have a 19-pin disk port. I’m undecided whether to add a second 20-pin header to the existing adapter board design (increasing the size and cost for everyone), or make a different version of the adapter board (more product fragmentation), or something else.

Not every Apple II user needs an adapter board – only the “some setups” that I mentioned. But for those who want a simple and fool-proof path to Apple II disk emulation, the adapter board will be the way to go. For power users willing to read the fine print, they may find that an adapter board isn’t necessary for them. The current landscape looks like this:

5 1/4 disk emulation – Reading from a disk image works without the adapter. Writing to the disk image also works without the adapter on the IIGS and IIc with built-in disk controller. The adapter is required when writing to the disk image using a separate disk controller card, like the Disk 5.25 or Disk II controller cards.

3 1/2 disk emulation – Reading and writing to a disk image works without the adapter, on the IIGS ROM version 1 (the most common version), when the computer is booted from the emulated disk. The adapter is required for the IIGS ROM version 3, or for any Apple II model when the computer is booted from a different floppy or hard disk.


Rather than wait for an adapter board, some people may want to make hardware modifications themselves. There are two separate modifications: one for 5 1/4 disk emulation and one for 3 1/2. The 5 1/4 inch modification is relatively easy for anyone who’s comfortable with a soldering iron, but the 3 1/2 modification is a bigger challenge.

The 5 1/4 inch modification requires only a single 10K ohm pull-up resistor, connected between /WRREQ and +5V. This won’t interfere with 3 1/2 disk emulation, or Mac/Lisa disk emulation, so it’s fine to leave permanently installed. You can make this connection anywhere on the board that’s convenient. The easiest spot is on the bottom of the board, near the disk connector. But a resistor added here will add a little bump that prevents the board from fitting properly in the standard case. If that’s a concern, the pull-up resistor can also be added on the top of the board, using 30 AWG patch wire to reach the finely-spaced pins of the CPLD chip. Using these photos as a guide, connect a 10K resistor between any pair of /WRREQ and +5V pads:



The 3 1/2 inch modification requires adding additional chips, inserted inline between the Floppy Emu board and the Apple II. A schematic is shown here. Unlike the 5 1/4 inch modification, this change is only appropriate for emulation of 3 1/2 inch Apple II disks. You’ll probably want to add a switch to disable the additional circuitry when emulating other types of Apple II disks, or Macintosh/Lisa disks.

Don’t Forget to RTFM

Remember, many Apple II setups don’t require any hardware modifications at the Emu board – they’re just plug and go. Before you heat up your soldering iron, or cry over the wait for an Apple II adapter board, read the details above and see if you actually need one. If in doubt, try it first and see. You won’t hurt anything, and the worst case is that it simply won’t work. If 5 1/4 inch writes cause the Emu to freeze, or 3 1/2 inch I/O causes the Apple II to freeze while booting or report strange boot-up errors, then you’ll know it didn’t work. Everyone should at least be able to do 5 1/4 inch disk read emulation, which means you can boot up your favorite games like Castle Wolfenstein straight from the SD card. Have fun!

Be the first to comment! 

Missing Pull-up, Sad Trombone


Wah wah wah waaaaaaah. In the battle for 5.25 inch Apple II disk write emulation, it seems I declared victory too soon. While write support works great in many situations, it doesn’t work at all in others. The problem is with the /WRREQ signal from the Apple II, which goes low to indicate when a write is occurring. On old-school disk controller cards, like the Disk 5.25 Controller Card, or the even older Disk II Controller Card, this signal is generated by a 74LS05 hex inverter chip with open collector outputs. It can actively pull the signal low, but it needs an external pull-up resistor to pull the signal high. And Floppy Emu doesn’t have one. On the Apple IIgs (and probably also the IIc), the circuitry can actively drive /WRREQ high, so this isn’t a problem. And on other Apple II models, it’s also not a problem if there’s another real drive connected in the daisy chain, because that drive will have a pull-up, and /WRREQ is shared among all drives. But if Floppy Emu is the only disk drive connected to a Disk 5.25 or Disk II Controller Card, writes won’t work. Ouch.

The logic analyzer trace above shows what happens. /WRREQ is connected directly to an input pin on the Xilinx XC9572XL CPLD. The input has a very weak pull-up that’s active at initialization time, as well as a keeper circuit that actively maintains the input at the last externally-driven level. At power-up, the weak pull-up pulls /WRREQ high, and the keeper circuit keeps it there. Then when a write occurs, the disk controller card actively drives /WRREQ low. At the end of the write operation it releases /WRREQ, but with nothing to pull it high again, the keeper circuit maintains the low value forever. To the Floppy Emu, it looks like a write operation that never ends. You can see the result in the trace. /WRREQ stays low forever, even after the drive enable signal is de-asserted.

Unfortunately, I don’t think there’s any way to fix this other than to add a pull-up resistor. The XC9572XL CPLD chip doesn’t have configurable built-in pull-ups that I can turn on in firmware, as far as I can tell. 5.25 inch read emulation will still work fine, as well as 5.25 write emulation on a IIgs or on any Apple II with another drive present. But for a single-drive Floppy Emu setup on an Apple IIe, write emulation won’t work without a hardware fix.

I already designed an adapter board, which I described in this earlier post. I had hoped that the adapter board would only be needed for certain situations of 3.5 inch Apple II disk emulation, but now it seems certain situations of 5.25 inch emulation will need it too. There’s too much “certain situations” about the whole thing for my comfort, and I’m sure it confuses everyone else just as much. So I’ll probably just rechristen the adapter board as a general purpose “Apple II adapter”, even though it’s not strictly needed for all circumstances of Apple II emulation. That will be easy to understand, and won’t steer anybody wrong. Power users can read the footnotes and discover which Apple II setups can work without the adapter board, if they wish.

Adding a pull-up resistor to the adapter board will be easy, but it does mean I’ll need to have new PCBs made. The only good thing in all of this is that it justifies my decision to postpone manufacturing large numbers of the adapter boards until after the Apple II 5.25 inch and Smartport disk emulation is working. If I had built lots of adapter boards three weeks ago when I thought they were only needed for 3.5 inch Apple II disks, I would now have a lot of angry people who’d bought them, and a pile of additional boards I couldn’t use.

Read 5 comments and join the conversation 

5.25 Inch Disk Write Support


Whew! Floppy Emu write emulation for 5.25 inch Apple II disks is finally working. That was a painful issue to resolve, because writes to the 5.25 inch emulated disk were working fine in my controlled tests, but things went haywire when I tried a simple DOS write operation. Argh! I went a little crazy jotting down notes about possible causes, theories, and doodles – my standard way of organizing my thoughts for problems like these. Not that it seemed to help.

I finally hit upon the idea of starting from a reference DOS disk image, and performing the same file save operation in two different settings: once on a regular Apple II system with Floppy Emu, and once in the AppleWin machine emulator. Then I could use a binary diff tool to compare the resulting modified disk images from each case, and see how they differed.

What I found was that a single byte differed between the two disk images, after performing what should have been an identical file save operation. Oddly, the byte was in a sector that wasn’t even supposed to be modified by the save operation. The diagnostic info I collected from Floppy Emu said that the Apple II never modified that sector, but there it was anyway. In a sector that should have been all zeroes, the second byte was a 1. And the effected sector was immediately after another sector that was modified by the Apple II. Hmm.

You can probably guess what the issue was: buffer overflow. Whenever a sector was written, the first two bytes of the next sector in memory would also get overwritten. This problem was invisible unless the effected sector happened to lie inside a range of two non-contiguous dirty sectors on the same track, in which case the whole range of sectors would get written back to the SD card as a performance optimization. This never happened during my simple single-sector write tests, which is why I could never find a problem there. The issue only occurred during a more complex write operation involving non-contiguous writes on multiple tracks of the disk.

In truth, the buffer overflow was only the last of three separate problems that prevented 5.25 inch writes from working correctly, but it was the largest bug and the others aren’t interesting enough to describe. So now it works – yay! I tested booting from an emulated DOS disk and saving some BASIC programs to it. I also tried booting GS/OS on the IIgs, and using it to delete the contests of an emulated ProDOS 5.25 inch disk, copy a new program file onto it, and run the program.

Try It

Like the Mac and Lisa firmware, this new Apple II firmware supports writing to the data portion of each sector, as occurs during standard file I/O operations. Writing new address headers for the sector is not supported, which means it’s not possible to format the emulated disk or do bit-copy writes with tools like Copy II+. If you find yourself wanting to format the disk to get a new blank image to work with, I’ve included a few different blank disk images with the latest firmware.

Download the new Apple-II-0.1D-F3 firmware, and try it for yourself! As with the earlier Apple II firmware versions, use this firmware only when connected to an Apple II computer. If a Floppy Emu board running the Apple II firmware is connected to a Mac or Lisa, it may cause damage.

Please let me know what Apple systems and disk images you’ve tried, especially if you run into problems. Have fun!

Read 11 comments and join the conversation 

5.25 Inch Disk Firmware


The updated Apple II firmware for Floppy Emu is now available! This update adds 5.25 inch 140K disk image support, and is compatible with any Apple II model, using the standard Floppy Emu hardware. Download apple-II-0.1C-F3 and try it out! I also included a few sample disk images, so you can be running Oregon Trail and a few other classics right away. The firmware supports standard Apple II 140K disk images in .PO, .DO, .DSK, .NIB, or .2MG formats, as well as Apple II 800K (3.5 inch) disk images in .2MG or Disk Copy 4.2 formats. Press the SELECT button from the Emu title screen to switch between 5.25 inch and 3.5 inch disk emulation modes.

Some important notes:

  • I’m having difficulty with 5.25 inch disk write emulation, so this firmware treats 5.25 disk images as read-only. I hope to add full read/write support for 5.25 inch disks in another firmware release soon.
  • The Floppy Emu board can be connected directly to the 19-pin floppy connector on the Apple IIgs or Apple IIc. For the Apple II, II+, and IIe, the Emu board should be connected to your disk controller card: either the Disk 5.25 Controller Card with 19-pin connector, or the classic Disk II Controller Card with two 20-pin connectors. If using the Disk II Controller Card, be careful to orient the cable correctly, since the card’s connector is not keyed and it’s easy to accidentally connect the cable offset or backwards. The red stripe on the cable should go to the pin marked “1” on the Disk II Controller Card.
  • This firmware includes support for 5.25 inch and 3.5 inch Apple II disk emulation. 5.25 inch disk emulation works on a stock Emu board, and does not require any adapter. Full emulation of 3.5 inch disks requires an adapter board that I plan to release soon. Without the adapter board, 3.5 inch disk emulation works on a ROM 01 Apple IIgs when booting from the Floppy Emu, but not on a ROM 03 IIgs or when the Emu is not the boot disk.
  • As with the earlier Apple II firmware versions, use this firmware only when connected to an Apple II computer. If a Floppy Emu board running the Apple II firmware is connected to a Mac or Lisa, it could cause damage.

NIB Images

This firmware introduces support for NIB images, which contain the raw disk bytes stored on a physical floppy disk, instead of the high-level sector data contained in other types of disk images. With NIB images it’s possible to store and emulate many types of copy-protected disks, including disks with non-standard sector headers, custom sector sizes and encoding, and all sorts of other crazy schemes. This is important for the Apple II world, because the use of disk-based copy protection was common among Apple II software. A disk emulator that didn’t support NIB would be limited to only using “cracked” versions of the software in which the copy protection had been removed.

Implementing robust NIB support is challenging. I’m not sure if other Apple II disk emulators also support NIB format, but at least one that I checked does not, so I’m happy that I was able to make it work for Floppy Emu. After digging into the details, I can understand why some designers may have chosen to skip NIB. The NIB format represents a track as 6656 disk bytes, but this is insufficient to represent the full structure of a real floppy disk track. On a real floppy, most disk bytes contain 8 bits, but some disk bytes called sync bytes are actually 10 bits long. Of course a 10-bit quantity isn’t a true byte, but the term “sync byte” is used regardless. The sync bytes are FF (hex) followed by two zero bits, so in binary they look like 1111111100. The problem is that sync bytes are stored in the NIB file as plain 8-bit FF bytes, and the knowledge that a particular FF is a sync byte instead of a standard FF data byte is lost.

I believe the NIB format was developed mainly for use with PC-based Apple II emulators, and not for use with real Apple II hardware. While I’ve never investigated how emulators like AppleWin are designed, I would guess it’s impossible for the emulated disk controller to get out of sync with the emulated disk, so the absence of proper sync bytes in the NIB data is unimportant. But when running on real Apple II hardware, such as with the latest Floppy Emu firmware, the absence of sync bytes is fatal. To solve this problem, I’ve designed the firmware to make an educated guess as to which FF bytes in the NIB are actually sync bytes, and which are just plain data bytes. In practice, this seems to work great most of the time, but copy protection schemes are often designed to intentionally thwart exactly this kind of analysis. In my tests, all the copy-protected NIB images that I tried worked, save for one intermittent problem with Moon Patrol on the Apple IIgs. Yet the Moon Patrol NIB worked fine on my Apple IIe, so maybe it’s some kind of IIgs incompatibility rather than a NIB issue.

Write Support

Support for writing to emulated 5.25 inch disks has proven to be much more troublesome than I’d expected. Single-sector writes appear to be working fine: I can use a sector editor tool to view and modify individual sectors on the emulated disk, and the data gets modified correctly. That means there aren’t any low-level problems involving timing or checksums, which is great. Yet when I try a higher-level write operation, such as copying a file, everything blows up. The exact nature of “blows up” is hard to identify – if I could explain it, I could probably understand how to fix it. In practice it means that the software complains about “write error”, or the Emu displays a buffering-related error.

On the Macintosh, all floppy disk write operations are verified by reading back the newly-written data, unless verification is explicitly disabled. From the point of view of a disk emulator designer, that’s a very nice feature, because any mistakes that occur during writing are caught and reported right away. But for Apple II software, verification of writes doesn’t appear to be the norm. At least in the GS/OS Finder, you can duplicate a file on a floppy disk, and GS/OS will show that everything succeeded regardless of what was actually written to the disk. If there was a problem, you’ll only find out about it later when you try to use the new file.

A second wrinkle is that some Apple II copy software like Copy II+ does something more akin to a single-track format operation than a standard write. The sectors on a disk consist of an address header followed by a data chunk. Normally the address headers are written once when the disk is formatted, and then never touched again – only the data chunks are modified. My experiments show that Copy II+ violates this rule, though, and writes new address headers. Floppy Emu isn’t designed to handle this, so the write operation fails. This isn’t an Apple II issue, but is also true of the Mac and Lisa firmware, and has been the case since the earliest days of Floppy Emu. There may be a way to configure Copy II+ so it doesn’t rewrite the address headers, but if so I haven’t found it yet.

I found more unexpected results when snooping on ProDOS disk writes. ProDOS works in units of 512 byte blocks, which are stored as two separate 256 byte sectors on the floppy disk. Every ProDOS write should therefore look like two successive sector writes, to two different physical sectors. But what I observed was that the same physical sector was written twice in a row. This must be a bug somewhere in my layers and layers of abstractions, but I haven’t been able to locate it. Or maybe the way I’m tracking the write activity is flawed.

In short, write support is a pain. I can see when something went wrong by observing error messages, but I only have a limited ability to look inside and examine each step of the write process to find the cause. I may need to invest some time in creating better debugging tools, before I can get to the bottom of it all.


As always, I welcome your feedback. If you’ve tried this new 5.25 inch disk emulation on your Apple II system, leave me a note in the comments! Even if you have nothing to say beyond “works on my IIc”, that’s still helpful to know. Thanks!

Read 9 comments and join the conversation 

Floppy Emu Has Cholera

20150507_095207_Richtone(HDR)_resized copy

Achievement unlocked! 5.25 inch 140K disk emulation for Apple II is now working for Floppy Emu. I booted up my Apple IIe with an Oregon Trail disk image, lost some oxen, got cholera, and died. The 5.25 inch disk emulation has been tested on a IIgs with the built-in floppy port, on a IIe with the 19-pin Disk 5.25 controller card, and on a IIe with the classic Disk II controller card. Awesome!

This brings the total number of disk formats that Floppy Emu can emulate to eight: Mac 400K, Mac 800K, Mac 1.44MB, Mac hard drive (HD20 compatible), Lisa 400K, Lisa 800K, Apple II 800K (3.5 inch), and Apple II 140K (5.25 inch).

These are early days for the 5.25 inch Apple II disk emulation, so I won’t be posting the new firmware quite yet. There are still a number of issues remaining that I hope to resolve soon. The big one is write support: the current firmware doesn’t yet implement 5.25 inch write emulation, so disks are read-only. The disk image format support also isn’t complete, and raw DOS 3.3 order images (.do files) are the only format that works. I expect to add ProDOS order (.po files) and 140K 2MG images soon – or is 2MG only used for 800K disk images? I’ll have to check.

In my previous post, I mentioned that the raw disk bytes weren’t always being received correctly by the Apple II. It turned out that the width of my “1” pulse was too narrow, and sometimes a 1 would be detected as a 0. Data arrives from the disk at a rate of 4 microseconds per bit, where a logical 0 is sent as 4 microseconds of 0 volts, and a logical 1 is sent as a short pulse to 5V and back within a 4 microsecond window that’s otherwise 0 volts. Initially the width of my pulse was 0.25 microseconds. When I widened it to 0.75 microseconds, it started working reliably. That’s curious – is the disk controller actually doing polling, instead of edge triggering? Why didn’t the narrower pulse work?

It was a headache getting the checksum algorithm working correctly. The checksum is described in the book Beneath Apple DOS, but even after re-reading it several times, I was still confused. The algorithm is tightly coupled to the method the Apple II uses to read and write disk data, where it performs a process called “pre-nibbilization” before writing each sector, separating the upper and lower bits of each data byte and storing them in two different buffers. Floppy Emu works differently, performing nibbilization on the fly, so it was somewhat awkward to transmit data and checksums the same way.

Interleave and Sector Ordering

The other question that I struggled with was sector ordering. If you’ve been around the Apple II emulation world for a while, you’ve probably heard the terms “DOS order” and “ProDOS order” when referring to disk images. You may have also seen some discussion of sector interleaving within a track. The meaning of these terms and the interplay between them took me quite a while to understand.

Some background: each sector on the disk is prefaced with a sector header. The header is not part of the sector itself, and doesn’t count as “data” when you’re totalling up how much data a disk contains. A crucial piece of information contained in the header is the sector number, used by the operating system to identify which sector is which. Typically the sectors aren’t actually stored consecutively on the floppy disk, but are interleaved. A Macintosh 800K floppy track has the sectors interleaved like this:

0 6 1 7 2 8 3 9 4 10 5 11

This is a performance optimization. The floppy disk is always spinning, and without interleaving, a vintage computer would be too slow to finish processing the data from sector 0 before sector 1 spun under the head. By the time it was ready to begin reading sector 1, that sector would have already spun past, so the computer would have to wait for it to spin all the way around again. By staggering the sectors on the floppy disk, the computer gains some extra breathing room and avoids needing a full rotation for the next sector.

Things begin to get confusing when we talk about physical sectors vs logical sectors. Physical sector numbers are the numbers contained in the sector headers on the disk. Logical sector numbers are determined by the OS, and define the data contained in each sector. If you stored a large text file on a floppy disk, the first few sentences would be stored in logical sector 0, the next few in logical sector 1, then logical sector 2, etc.

On the Mac, physical and logical sector numbers are the same. The sector number in the sector header is the same as the number assigned by the Mac OS. If we use A[B] to describe a sector whose sector header number is A and whose data contents are the operating system’s sector number B, then the Mac has a 1:1 relationship:

0[0] 6[6] 1[1] 7[7] 2[2] 8[8] 3[3] 9[9] 4[4] 10[10] 5[5] 11[11]

The Apple II handles interleaving differently. Physical sector numbers aren’t interleaved, and instead they’re just numbered consecutively 1 to N along the track. But the operating system uses so-called “software skewing”, where logical sector N is not necessarily stored in physical sector N. For DOS 3.3, the relationship looks like this:

0[0] 1[7] 2[15] 3[6] 4[14] 5[5] 6[12] 7[4] 8[11] 9[3] 10[10] 11[2] 12[9] 13[1] 14[8] 15[15]

So when a DOS 3.3 Apple II program wants sector 4, it actually fetches physical sector 7 from the floppy disk. For all practical purposes, physical sector 7 is sector 4. My head hurts already.

With ProDOS, logical data is stored in 512 byte blocks instead of 256 byte sectors. Each 512 byte ProDOS block N is stored in two separate 256 byte physical sectors, NA and NB:

0[0A] 1[4A] 2[0B] 3[4B] 4[1A] 5[5A] 6[1B] 7[5B] 8[2A] 9[6A] 10[2B] 11[6B] 12[3A] 13[7A] 14[3B] 15[7B]

Confused yet? A DOS ordered disk image is one in which the physical sectors are stored in ascending order by DOS 3.3 logical sector number. A ProDOS ordered disk image is one in which the physical sectors are stored in ascending order by ProDOS logical block number. While the two orderings are obviously derived from the two different operating systems, they are ultimately just arbitrary ways of grouping data into 256 byte chunks. DOS 3.3 software can be stored in ProDOS ordered disk images, and vice-versa.

20150507_111136_resized copy 20150507_111003_resized copy

Read 11 comments and join the conversation 

Older Posts »