Applesauce

From The ReActiveMicro Apple II Wiki
Jump to navigation Jump to search
AppleSauce by John K Morris

The Applesauce project was started in March 2017 by John K Morris of EvolutionInteractive.com. John is a well know programmer in his own right, however this is his most important contribution to the Apple II Community to date.


Background

In early 2017 John and Henry S. Courbis from ReActiveMicro were discussing project ideas mostly based around the Raspberry Pi. Henry sent John some hardware and after a few weeks of tinkering and discussing different projects John mentioned an idea he had involving floppy drives and backing up software. John knew Henry had worked on the EDD project and fixed several issue as a consultant for UltimateApple2 and they started to discuss how horrible and unreliable at best the EDD was in its attempt to capture the data which represents "the floppy". John started to talk about what if we attacked the problem of copying protected disks directly from the drive rather than trying to intercept the data stream from the drive under use like the EDD did. This was the start of what would become the Applesauce project.

John discovered it would not be possible to copy disks on-platform as the Apple II is too slow and too dependent on the Disk II Controller card. There would be no way to capture the timing data coming from the drive which occurs every 4 microseconds. In order to fully read a floppy disk as "raw data", also know as the flux patterns, he would need to take the drive off-platform and control it directly. The flux patterns are literally the way the magnetic particles are magnetized on the floppy medium. They are NOT bits of or among themselves. They contain timing information as well as program data.

After some research about how the Apple II encodes floppy disks John found the only one to get things right is Jim Sather in his book Understanding the Apple II. All the other books and resources seem to have major flaws in their interpretation of how things work and plagiarized from one another. It is quite possible that John may be one of the few people besides Wozniak and Sather to actually understand how the whole floppy subsystems actually work.

By March 2017 John had started to look in to how to control the Disk II Drive and its power requirements. After some research he found the drive should be able to be controlled by a microcontroller. However most microcontrollers are not 5v tolerant and would need active and bidirectional level shifting. A proper speed microcontroller would also be needed in order to provide enough resolution to handle all the data being read from the floppy disk and allow enough time to control the drive.

A major issue would also be how to determine where the disk is in relation to the drive. This is called synchronization. IBM PC drives use a sensor to track synchronization which allows for less floppy controller processing requirements and simpler controller design to navigate tracks and sectors. The Disk II drive however does not have any synchronization mechanism which some copy protections relied on and would make copying these protected disks impossible on-platform. In order to over come this issue John designed a sync sensor with the help from Henry and added it to the arbor of the Disk II drive.

The Disk II drive's power requirements also posed some issues as the power supply would need to support universal AC input to allow for international use, and also be tri-output in order to power the Disk II drive and its logic board. John initially used a prebuilt solution (as pictured) in order to reduce prototyping time. Later revisions of the project will use a custom power supply integrated on to the project's PCB.

In April John started in earnest to create the Applesauce User Interface. This will be a GUI based program for the Mac and ported to X86 and Raspberry Pi (ARM). Javier A. Rivera is assisting John with icons and other relates program art work. John has also been looking for programmers to help with different parts of the project so he can better concentrate on the analysis engine which is the heart of Applesauce.

Henry's involvement has been rather limited as John has wanted to get hands on with CAD and circuit design. Henry has advised on several aspects of the project however John has managed to do all the labor and design work in the Proof of Concept and Alpha designs. ReActiveMicro will probably have a hand in a final design review and audit as well as overseeing assembly and distribution.

Applesauce Alpha units have been sent to several test users who have evaluated the hardware and different aspects of the software and file format.

There have been other similar projects such as Kryoflux and Catwheesel, however these projects have fallen short in several areas especially where Apple II is concerned.

What Is Applesauce?

Applesauce comprises two parts - hardware and software.

The hardware component of the project is a "Controller Interface" that allows an Apple Disk II 5.25" disk drive to be connected via USB to a modern computer. Only Mac is currently supported, however plans to port the project to X86 and Raspberry Pi (ARM) are in the plans. An expansion port has also been added for upgrades to the hardware for things like 3.5" disk imaging support in the future.

The software component runs on the modern computer and controls the Disk II Drive and captures the raw flux patterns from the inserted disk. Once this data stream is captured, the Applesauce software then process the data for saving as disk image files.

Because Applesauce captures the data on the disk at the flux level, it is able to capture Apple II copy-protection schemes "in place". In most cases the resultant disk image could be written back to a physical disk by the Applesauce software with protection in place. Or (subject to emulation hardware or software support) it can be used with copy protection left in place on Apple II emulators or solid state Apple II disk drive emulators.

For non-protected (or previously cracked disks), Applesauce is able to capture a .dsk disk image in approximately 11s.

Applesauce will be a defining project for the Apple II Community which will allow users to simply crate exact images of their floppy media.

Flux Patterns

Magnetic media flux patterns, or just flux for short, are an inherent physical property of all magnetic media. The pattern refers to how each region of the media is magnetized. These patters are used to store track and sector information, as well as program data unrelated to the disk operation.

All magnetic media is coated with a ferrous material. This allows small regions in the magnetic to be used as individual magnets. The smaller the region the more "bit dense" the material is said to be. The media is then able to be used to store data. This is the basis of how all such media is created and used.

Floppy disks use a track and sector coordinate system to store information. Each track holds a set amount of sectors, and these can vary due to OS and drive design. The flux patterns are created when the head of the disk drive writes to the disk. These patterns are permanent unless damaged or overwritten. Damage can occur in several ways but is most likely due to age or scratching of the media.

Individual fluxes are always in a North or South polarity as with all magnets.

Weak Bits, Bubble Bits, Fake Bits, And The MC3470

There has been some odd terms thrown around by different people about individual fluxes and their behavior. One such term used most commonly is "weak bit" which can mean two possible things.

Weak can refer to the state of the individual or group of flux patterns that have physically become damaged and are unable to be reliably read. This can be physically caused by damage to the media such as oxidation, mold, or the magnetic coating flaking off and becoming lodged under the drive head. As debris accumulates under the drive head scratching of the media becomes more likely. Once this kind of damage happens there is no way to repair it. Damage can also happen in the form of magnetic erasure which affects the levels of north or south saturation for a given area making it appear neutral or degaussed. If a disk is mishandled or brought too close to a magnetic source then parts of the disk can be changed randomly. This kind of issue can be repaired by rewriting the affected area and does not change location on the disk.

The other form of weak bits not caused by damage are more correctly called "bubble bits" or "fake bits". These flux patterns appear randomly when read and constantly change location. This can be caused by several factors such as RFI however the majority of random flux patterns are caused by the MC3470 amplifier IC.

The MC3470 takes the raw flux pattern signals from the drive head and amplifies it to the 5v TTL logic standard needed for the Disk II Analog card to process and send to the Apple Disk II Controller card. This amplifier IC however is far from perfect in its task. When a disk is being read the amplifier starts out waiting for a change in flux signals under the drive head. If it does not detect a change for a set period it will automatically turn up the sign gain and the process starts again. This will repeat until the MC3470 has turned the signal gain up so much all that is produced is random noise being sent from the IC. This is inherent to the design of the MC3470 and Motorola had redesigned the IC multiple times the ICs active life to address this noise issue. Some early date codes of the IC are very noisy. Later date codes tend to be less noisy. This is most evident in image file created using the EDD card. The actual noise is also captured during reads and encoded in to the image files. When two EDD files are compared they are never the same, and this is due to the amplifier noise.

This "noise issue" was taken in to account when producing copy protection schemes for the Apple II as the noise would always be dynamic and change locations. A check could be incorporated in to a copy protection scheme to read a "blank", unformatted, or specially formatted track to see if the flux patterns would change. If they did the disk was original. If however this flux bits did not change location and were static this could only happen if the disk was a copy. Can you copy a "blank" track? No, it is impossible on-platform to reproduce a sector or track on a disk which is all north, south, or a degaussed (equal parts north and south) fluxes.

There has been rumor over the years that it is impossible to have two zero bits in a row when writing to the Disk II drive. This is incorrect, however the way the design of the controller and driver are means the amount of noise detected is going to be

Considering how noisy the MC3470 can be it's amazing how resilient the Disk II Controller design is and how few issues Apple II users actually experience.

Teensy

Info on exactly what is the Teensy and what it does.

How it will be updated. make sure that users can painlessly update the firmware on the board so that they won't be left behind as new features are added.

Sync Sensor

What it is and why we need it.


Notes

I have been doing all kinds of crazy analysis R&D work that has been really paying off. I'm currently working on a disk analysis/editor that is similar to the old nibble editors, but will show you the nibbles after the analysis tools have annotated the data. So, you get color-coded hex views that show you the function of every nibble. Every hidden sync bit. It will also point out where things like the copy protection exists and the techniques they are using to accomplish it. It gives you the ability to go "digital spelunking" through the disk. It will also allow you to repair a disk image. Do you have a flawed sector? Open up a different disk image (A2R, EDD, NIB, etc) of the same software and use it to patch the bad data.


One of the main things that Applesauce is bringing to the table is new disk image formats. The formats are completed and work has started with emulator developers to start integrating support for the new formats. The new image formats have been well received by folks as it addresses all of the shortcomings of current disk image formats like DSK and NIB. Talks have also started with some hardware developers to support the new formats within their virtual floppy drive projects. This will allow still copy protected disk images to run on real hardware.

EDD Is Dead

As quoted by Antwion, and why.