<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Don Barber on Medium]]></title>
        <description><![CDATA[Stories by Don Barber on Medium]]></description>
        <link>https://medium.com/@barberd?source=rss-4e870e133dd4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dmbNkD5D-u45r44go_cf0g.png</url>
            <title>Stories by Don Barber on Medium</title>
            <link>https://medium.com/@barberd?source=rss-4e870e133dd4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 01:38:02 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@barberd/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Floppy-only PC with only blank floppies? No problem.]]></title>
            <link>https://barberd.medium.com/floppy-only-pc-with-no-floppies-no-problem-40a8b9e7aa4f?source=rss-4e870e133dd4------2</link>
            <guid isPermaLink="false">https://medium.com/p/40a8b9e7aa4f</guid>
            <category><![CDATA[assembly-language]]></category>
            <category><![CDATA[retrocomputing]]></category>
            <category><![CDATA[vintage-computing]]></category>
            <category><![CDATA[bootloader]]></category>
            <category><![CDATA[basic-language]]></category>
            <dc:creator><![CDATA[Don Barber]]></dc:creator>
            <pubDate>Mon, 29 Aug 2022 14:16:52 GMT</pubDate>
            <atom:updated>2022-08-29T15:53:47.783Z</atom:updated>
            <content:encoded><![CDATA[<p>Recently I picked up an original IBM PC off of Facebook marketplace. This was an IBM Model 5150: the PC that started it all. It came with a Model F keyboard, a CGA video card, and two 5.25&quot; 360k floppy drives. It did not have a hard drive; this came later with the IBM PC XT 5160. The fact it came with double sided drives and had later ROM versions suggest a ship date in 1983 or so.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e9pzydyj_W_CQP8BtV4UbQ.jpeg" /><figcaption>My new acquisition: an IBM PC 5150 and Model F Keyboard. The monitor came separately. Here one can see it booted into its IBM Cassette Basic ROM.</figcaption></figure><p>Only problem: it did not come with any software, such as an operating system. And while I had some blank floppies (the same kind is used on my Tandy Color Computer 3), and one can find copies of IBM PC DOS online, I did not have another computer available to write such an image to a disk; motherboards with the appropriate floppy controller chips to write to 5.25&quot; disks were largely phased out after the Pentium 3.</p><p>I considered a few options. One was to finangle a way to write PC-formatted sectors and data onto a disk from my Tandy Color Computer 3, which I probably could have done with some creative programming writing directly to the Western Digital 1793 floppy controller chip. Another was to simply have someone mail a disk to me; there are some services to do such for a nominal fee or I’m sure I could have found someone in the retro community.</p><p>But then I noticed: much like other home computers in the era, the 5150 PC would boot to a BASIC ROM if no boot floppy was present, in this case IBM Cassette BASIC, a licensed version of Microsoft BASIC. Like other BASIC implementations, IBM Cassette BASIC could write data into specific memory locations (using the POKE command), and could instruct the machine to jump to specific memory locations (using the CALL or USRn commands). Normally this mechanism is for BASIC programmers to implement machine language to gain performance beyond what the BASIC interpreter could perform. But really it could be anything the processor can execute…and it became my way in.</p><p>Readers of my past posts may recall I soldered an Altair 8800 together from scratch, and a normal part of operating that machine was to key in a bootloader on the front panel switches. This bootloader would then read a larger program (or operating system) into memory over a serial port. So I thought: why not use BASIC to poke a bootloader into memory that does the same thing on the IBM PC? Even better, could I also write that bootloader to the boot sector of a floppy disk?</p><p>It turns out that yes, this is totally doable. And it would be a fun project. So I did it.</p><p>The first step was re-learning Intel x86 assembly. I’d learned it during my Computer Science undergrad work, and it wasn’t a huge stretch to pick it up again, especially as I’d recently learned its ancestor chip for my Altair, the Intel 8080. Then I needed an assembly program to read data from the serial port (an 8250 UART chip) and then jump to that code:</p><pre>org 0x7C00<br><br>    mov ah,0x0E         ; use BIOS call for simple character output<br>    mov al,0x42         ; to output &#39;B&#39; on the screen<br>    int 0x10            ; to show it booted<br><br>    xor ax,ax           ; initialize data segment to 0 so code<br>    mov ds,ax           ; writes to correct location<br><br>    ; init UART here<br>    ; The 8250 chip used on the IBM PC used 5 different ports<br>    ; for various IO, including the data buffers and<br>    ; command/control/status registers. The x86 uses the dx register<br>    ; to address IO ports above 255, hence all the manipulation<br>    ; of the dx register in the following code segment...the code is<br>    ; writing to different registers on the 8250 chip.</pre><pre>    mov dx,0x2f9        ; COM2<br>    ;mov dx,0x3f9       ; COM1, switch comments if needed<br>    out dx,al           ; turn off all UART interrupts<br>    mov al,0x80<br>    add dx,2<br>    out dx,al           ; set UART chip to receive new baud rate<br>    mov al,0x0c<br>    sub dx,3<br>    out dx,al           ; set low byte divisor to 0xc (9600 baud)<br>    xor al,al<br>    inc dx<br>    out dx,al           ; set high byte divisor to 0<br>    mov al,0x03        <br>    add dx,2<br>    out dx,al           ; disable baud rate config and set 8N1<br>    mov ah,0x03<br>    inc dx<br>    out dx,al           ; turn on DTR and RTS<br><br>    mov bx,0x7eff       ; assign BX pointer to memory address 0x7eff<br>    inc dx<br><br>rdloop:<br>    in al,dx            ; read serial status<br>    and al,0x1          ; check if byte is available to read<br>    jz rdloop           ; loop if byte not available<br>    sub dx,5<br>    in al,dx            ; read byte from serial<br>    add dx,5<br>    mov [bx],al         ; store byte to BX pointer<br>    dec bl              ; decrement pointer<br>    jnz rdloop          ; loop until reached 0x7e00<br>    jmp 0x7E00          ; once done, jump to 0x7e00</pre><p>Assembled, this code is 65 bytes. I’d have to type those bytes into BASIC, so I wanted to keep it as short as possible. Note over half the code is just initializing the 8250 serial port chip.</p><p>I didn’t want to execute those 65 bytes directly from BASIC; I wanted to write them out to the boot sector of a floppy disk so I could easily execute this code without keying it in every time. So I needed code to write a memory segment to the floppy. And this code did need to execute from BASIC, so I included the appropriate register save and return code for such:</p><pre>org 0x1100<br><br>    push es            ; save ES and BP registers so return to BASIC<br>    push bp            ; works<br>    mov bp,sp<br>    xor dx,dx          ; set dx to 0: write to drive 0 head 0<br>    mov es,dx          ; also set extra segment to 0 as the bios<br>                       ; call for writing a disk sector looks for<br>                       ; data at es:bx<br>    mov bx,01200h      ; write starting memory address 0x1200<br>    mov ax,0301h       ; write command 0x03, write 1 sector<br>    mov cx,0001h       ; write to track 0, sector 1<br>    int 13h<br>    mov di,[bp+8]      ; save the BIOS call return status in the<br>    mov [di],ax        ;    passed BASIC variable<br>    pop bp             ; restore the ES and BP registers<br>    pop es<br>    retf 2             ; return to BASIC cleanly</pre><p>This works out to 29 bytes, which I’d also have to type into BASIC. So next was to write the BASIC program that would load both code blocks into memory, then execute the second block that would write the first block to a floppy disk. Dusting off my BASIC skills, I wrote the following program (note the data segment defined on line 100 matches up with the ‘org’ statement in the second assembly code segment):</p><pre>10 CLEAR ,&amp;H1000<br>20 DEF SEG=&amp;H120<br>30 FOR I=0 TO 64<br>40 READ J<br>50 POKE I,J<br>60 NEXT<br>70 POKE 510,&amp;H55<br>80 POKE 511,&amp;HAA<br>100 DEF SEG=&amp;H110<br>110 FOR I=0 TO 28<br>120 READ J<br>130 POKE I,J<br>140 PRINT J<br>150 NEXT<br>160 SUBRT=0<br>170 RET=0<br>180 CALL SUBRT(RET)<br>200 PRINT RET<br>210 END<br><br>1000 DATA 180,14,176,66,205,16,49,192,142,216,186,249,2,238,176<br>1010 DATA 128,131,194,2,238,176,12,131,234,3,238,48,192,66,238<br>1020 DATA 176,3,131,194,2,238,180,3,66,238,187,255,126,66,236,36<br>1030 DATA 1,116,251,131,234,5,236,131,194,5,136,7,254,203,117<br>1040 DATA 238,233,191,1<br><br>1080 DATA 6,85,137,229,49,210,142,194,187,0,18,184,1,3,185,1,0<br>1090 DATA 205,19,139,126,8,137,5,93,7,202,2,0</pre><p>Its a bit to type in, but only takes a few minutes. First, the code tells the BASIC interpreter to not to use any memory above 0x1000 (so BASIC won’t overwrite the later pokes). The code then pokes 65 bytes of code block one into 0x1200. Note the code then pokes 0x55AA into the end of the 512 byte block, as we need those bytes in that place on the floppy for it to be recognized as a boot record by the BIOS. Then the code pokes the 29 bytes of code block two into 0x1100. Then the code executes that code at 0x1100 via a CALL function, and prints the return code, which should be ‘1,’ BASIC’s decimal interpretation for 0x0001, or “00 No Error” followed by “01 Sectors Written.”</p><p>Fingers crossed, I typed ‘run.’ I got the red light on the floppy drive and a good return code. It seemed to have worked. Upon rebooting, I expected ‘B’ showing that my code was running and was waiting for more code to arrive over the serial ports. Here goes nothing:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GFXnnT89GiXzb30YR2zgxw.jpeg" /><figcaption>Success!</figcaption></figure><p>Note all the above code is what I came up with after a few iterations to get it correct. I had a few mistakes at first. For example, I was naively writing the data from the serial point to the start of memory at location 0 (a habit I’d picked up from programming the Altair 8800), but then found I’d get very unexpected behavior after reading only 140 or so bytes. It took longer than it should have for me to realize I was overwriting the x86’s interrupt vector table, so an interrupt (like the new incoming serial data I was receiving) would put my machine into a broken state. Once I moved the destination target to 0x7e00 instead, my approach clicked into place. My first test program displayed the letter ‘K’ over and over again, which worked great:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nF5WX-iys8cG3sxwIgXaww.jpeg" /><figcaption>My daughter’s first initial is K; she was curious as to what I was doing so I tried to include her in the experiment.</figcaption></figure><p>From here, having proven I could load a program over the serial port, I could conceptually load any software I could write over the serial port, and bypass the need for floppies altogether. But I wanted to use the plethora of software out there coded for use on disk and with an operating system. So back to fixing my chicken-and-egg problem: I needed to write a program that would read a disk image in over serial, and write it out to the physical disk.</p><p>So I wrote out this program, and an accompanying python script that would send this program and the subsequent required disk data over to the IBM PC. Since I didn’t have to poke the data for these programs into memory by hand, I could do little extras like error checking and status reporting. These programs, and the above assembly and basic code, are available for others to use at <a href="https://github.com/barberd/pc-serial-bootstrap">https://github.com/barberd/pc-serial-bootstrap</a>. Look for lwdisk.asm and senddisk.py specifically. This code would first output ‘K’ to show it had started, read the head, track, and sector, repeat them to the screen (the three digits on each line in the screenshot below), read the 512 data bytes to write, write the sector to disk, then loop to do it again.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HAvNYmBccDEcnofpbmNLvg.jpeg" /><figcaption>B for Boot, K for the serial kernel load, then three digits for head, track, and sector. Here were can see all sectors up to head 0, track 1, and sector 7 have written successfully, and the PC continues to read data.</figcaption></figure><p>It took some time for the transfer (running at only 9600 baud), but it worked great. I was able to transfer an IBM PC DOS disk image to a real disk. Voila: I now had a working operating system floppy to boot the 5150 PC.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CwPBsp6AjdZ_nFA6Y2VfDQ.jpeg" /><figcaption>Success! PC DOS written to floppy disk.</figcaption></figure><p>This only warranted a minor celebration: having just the OS doesn’t give me much else to do other than look at the A&gt; prompt. I needed software (apps, games, whatever) to do anything useful or fun. I could keep writing disk images the same way, but its a bit cumbersome and inefficient if I just want a single file. An easier method would be to get some communications software installed so I could just download software directly over the serial port. Most communications packages I found were too big to run on my PC, until I found an <a href="http://www.columbia.edu/kermit/archivefiles/bin-mskermit.html">old version of PC Kermit (v1.20)</a> that was only 16k. Bingo! I wrote this to disk using the same method, got it configured, installed <a href="https://www.kermitproject.org/gkermit.html">g-kermit</a> on my attached Linux workstation, and now can download software just like an old school dial-up BBS.</p><p>I loved this project. I got to relearn x86 assembly, apply lessons learned from the Altair project on bootstrapping via the serial port, learn the 8250 UART chip, learn how tracks are formatted into sectors on a floppy, and learn the IBM PC BIOS calls. It was so much more rewarding than just buying a pre-loaded floppy disk. And at the end, my daughter and I also got to play some old school PC games too. A great project!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TPKgCta6U6lXte50B_Pcnw.jpeg" /><figcaption>Sopwith (released 1984) is a fun little side-scroller airplane game for the early IBM PC, fun for kids then and now!</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=40a8b9e7aa4f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Patching An Old OS for the New Altair]]></title>
            <link>https://barberd.medium.com/patching-an-old-os-for-the-new-altair-7121a74b7da8?source=rss-4e870e133dd4------2</link>
            <guid isPermaLink="false">https://medium.com/p/7121a74b7da8</guid>
            <category><![CDATA[assembly]]></category>
            <category><![CDATA[retrocomputing]]></category>
            <category><![CDATA[cpm]]></category>
            <category><![CDATA[altair]]></category>
            <dc:creator><![CDATA[Don Barber]]></dc:creator>
            <pubDate>Tue, 05 Jul 2022 20:59:14 GMT</pubDate>
            <atom:updated>2022-07-05T23:56:38.997Z</atom:updated>
            <content:encoded><![CDATA[<p>I’ve really been enjoying the newly built Altair I described building from scratch in my recent posts. Many technologists can claim to have built their own computer, but for most that involved assembling components. It felt awesome to write and execute software on a computer I soldered together myself. Of course, this is nothing compared to those who design their own computer circuits, but I did get a small taste of that by modifying the memory card to work on the Altair’s front panel design.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E2_XyYoYlWcD3BtasvfX-g.jpeg" /><figcaption>All soldered up and working great. With lens-flare bonus.</figcaption></figure><p>Once I got the hardware together, its up to software to make the machine useful. I picked up programming the Intel 8080 instruction set well enough, and it wasn’t too hard to load software into the machine via the serial port with a bootstrap loader. But I found myself wanting read-write storage and an operating system to make it easier to load and save programs.</p><p>As demonstrated in my past posts, one didn’t have to use an operating system to use this computer; software could always talk directly to the hardware. For example, Microsoft’s original Altair Basic was coded to use the Altair’s original serial IO port address. If other IO cards were used, the software needed to be patched. This quickly got out of hand once other vendors came on the scene; the I/O options for the Altair might not match the I/O options for the Osborne or the Cromemco. The problems extended to other hardware devices too: all the new floppy drives on the market had different numbers of tracks, sectors sizes, and drive controllers. Software vendors couldn’t keep up with producing new versions for all the options out there. There was an entire cottage industry of people patching software for new models.</p><p>So the market was ripe for an operating system that would abstract away the hardware and allow software to run on all the machines out there using the same OS. Enter the Control Program/Monitor, or CP/M, later renamed to Control Program for Microprocessors, the original OS for the personal computer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*Kh9p7XzA6dNnLaduEU-6Cw.png" /><figcaption>1978 Advertisement for CPM, courtesy: <a href="https://commons.wikimedia.org/wiki/File:CP%E2%81%84M_Ad,_Dec_11,_1978.png">https://commons.wikimedia.org/wiki/File:CP%E2%81%84M_Ad,_Dec_11,_1978.png</a></figcaption></figure><p>CP/M was written for the Intel 8080 processor, which also worked for the Z80 processor (purposely designed to be backwards-compatible with the 8080), covering the majority of the PC market in the late 70s and early 80s. Written by Gary Kildall of Digital Research, it made it easy for software developers to do IO to the console, printers, and tape punchers, but also abstracted away the floppy drive with a file system so programmers could use system calls to read and write files instead of knowing everything about the underlying hardware. Hundreds of thousands of microcomputers ran CP/M.</p><p>The business model was pretty straightforward: Digital Research would license CP/M to the hardware manufacturer, who would modify it to abstract away the specific hardware in use, and the hardware manufacturer would sell it with their system. But it was also common for third parties to license CP/M and then modify it for specific machines as well.</p><p>CP/M gave us many modern PC concepts, some of which are still used by Microsoft Windows today, such as naming drives after letters (A:, C:, etc). When Digital Research was delayed in making a version of CP/M for the 8086 processor, Seattle Computer Products made 86-DOS, built with all-new code but also cloning the CP/M programming interface. This OS was later bought by Microsoft and renamed MS-DOS.</p><p>A quick aside here: much has been made about Bill Gates offering to sell IBM an OS that Microsoft didn’t even have…but its important to remember that this was completely normal at the time. Microsoft was just offering to license Seattle Computer Product’s 86-DOS and modify it specifically for the IBM PC’s hardware, just as other companies did with CP/M all the time. The only difference here is that the IBM ended up being so big that Microsoft bought the rights to 86-DOS outright, renamed it MS-DOS, and the rest is, as we say, history.</p><p>But back to my Altair: the same reasons everyone else wanted an OS in the 70s also applied to my situation. I wanted an easier execution environment where I could program without having to worry about low-level IO and storage access. I also wanted to run many of the software programs available from that time. So I needed to get CP/M running on my Altair.</p><p>The problem: CP/M needs a floppy drive, and I didn’t have one. The original Altairs use 8&quot; floppies, though 5.25&quot; “mini” floppies were used later as well. Finding drives and floppy disks in good working condition is an issue, but with enough money and patience can be done. But I questioned the need for a floppy drive in the first place.</p><p>Other retro computing platforms have virtual floppy options, emulating floppy drives either in hardware or software, backed by either SD cards or by connecting to a modern PC over serial with software that serves up the chosen disk images. I’d used both with my Tandy Color Computer 3 with the <a href="https://cocosdc.blogspot.com/">CocoSDC</a> and with <a href="https://sourceforge.net/projects/drivewireserver/">DriveWire</a>. Similar solutions are available for vintage Apple IIs, Macintosh, Commodores, Ataris, and the like. Its also been done for the Altair before as well, with the <a href="https://deramp.com/fdc_plus.html">FDC+</a> and <a href="http://ape.classiccmp.org/">APE</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U4_oOBnIQvBnIrmRjFTu2Q.jpeg" /><figcaption>My Color Computer 3 setup, including the CocoSDC with SD Flash card to emulate a floppy drive</figcaption></figure><p>The FDC+ is a hardware device, and a great option for Altair owners. But I was proud of soldering all the cards in my Altair myself, and the FDC+ comes pre-built. It also uses closed-source Windows software. APE looked like it hadn’t been updated for 5 years, required two serial devices, and was also closed-source. So I decided to write my own.</p><p>To do this I’d have to modify CP/M, replace its disk read-and-write routines to instead fetch and send sectors over the serial port with an invented protocol, and write software to sit on the other side of the serial connection and serve the requests against disk image files. As a bonus, I thought I could also modify the standard IO routines of CP/M to play nicely with the modified disk routines, allowing both the terminal and the disk access to share the same serial connection.</p><p>I designed a simple protocol wherein a python script running on a Linux machine would listen to the serial connection from the Altair. Normally the serial traffic is sent straight to the console, just like a normal terminal to the Altair. But if it received a control code (0xFF), the control routines would then take over the connection and listen for the next code to know if the Altair was requesting a disk read or disk write. Then it would listen for the track number, sector number, and write data (if writing), and then process the request, returning the requested data (if reading). The protocol is easily extendable to also carry other IO streams, such as that for the printer port. I then modified CP/M’s BOOT.ASM and BIOS.ASM, stripped out all the floppy drive controller code, and replaced it with code to make these requests out the serial connection. I compiled it, and with the help of some helper scripts I wrote, embedded the new code into the disk image.</p><p>Most often, a disk controller, or sometimes another card in the Altair, would have a boot-up ROM that contained code to load the first few sectors of the drive. After loading, this code would then bootstrap the rest of the OS. But I didn’t have such hardware handy. But no matter; I would just do what they did back in the day as well: key in small bootstrap code that would load the equivalent ROM code directly from the serial port. I reverse-engineered and modified the DBLv4–5.TAP file found at <a href="https://deramp.com/downloads/altair/software/8_inch_floppy/BASIC/">https://deramp.com/downloads/altair/software/8_inch_floppy/BASIC/</a> for this.</p><p>Put it all together, and the Altair should boot up CPM, all console access would go over the serial connection like normal, but would also share this serial connection for all disk access using disk image files stored on the hosting Linux machine.</p><p>After debugging another bad 74LS244 chip and a few minor mistakes in my assembly code, CP/M started up, and I got the familiar A&gt; prompt. It worked!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/824/1*p34aH3ZVowfFCvKCK8Kd2A.png" /><figcaption>It’s alive!</figcaption></figure><p>Using this setup, I could easily swap in and out virtual disk images, giving me quick access to all kinds of software written in the 70s and 80s, such as Wordstar, Supercalc, and of course, Zork (an immensely popular text-based RPG). Of course, for the latter, I was soon eaten by a <a href="https://zork.fandom.com/wiki/Grue">grue</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/824/1*efIetliuTrJj1oIbX3H2BA.png" /><figcaption>Forgot my grue repellent.</figcaption></figure><p>Getting an OS on the Altair has also made it much easier to develop software for it.</p><p>I extended the serial protocol and modified some <a href="https://en.wikipedia.org/wiki/XMODEM">XMODEM</a> utility programs to trigger protocol file transfers. This makes it easy to get files back and forth from the Altair. That accelerated my development cycle, giving me a chance to develop some nifty (to me) 8080 routines for converting between strings and 16-bit integers (think C’s atoi() or strtoul() functions) and doing shift-and-add software multiplication (there is no hardware multiply on the Intel 8080). None of this is ground-breaking or anything, just some hobbyist fun.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/824/1*GQBq_Augg90PCRmZ19EQfw.png" /><figcaption>Codito, Ergo Sum. I code, therefore I am.</figcaption></figure><p>I will add this though: after coding against both early Intel and early Motorola chips, I totally get why there were flame wars between the Intel versus Motorola camps back in the day. I found the Motorola instruction set to be much more intuitive and elegant. But Intel was first, and that counts for a lot.</p><p>If you’re interested in trying out CP/M with a virtual floppy drive, I’ve made my code available for others to use here: <a href="https://github.com/barberd/altair-cpm-serialdisk">https://github.com/barberd/altair-cpm-serialdisk</a>.</p><p>This brings my series on building a new Altair from scratch to a close. It was a great learning experience, and really helped me to understand a critical time period in our society’s (and my chosen industry’s) history. This machine was simple enough that one person could build and understand the entire thing, and one can see how modern computers are just the same thing with layers upon layers of improvement. There is a straight line from this machine soldered by hobbyists to today’s efficiencies-through-scale cloud computing industry. It makes me wonder: what will be the next big thing that allows individual hobbyists to shape the future so directly?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7121a74b7da8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a new Altair: hardware debugging, bootstrapping, and success!]]></title>
            <link>https://barberd.medium.com/building-a-new-altair-hardware-debugging-bootstrapping-and-success-7585c0acb4e0?source=rss-4e870e133dd4------2</link>
            <guid isPermaLink="false">https://medium.com/p/7585c0acb4e0</guid>
            <dc:creator><![CDATA[Don Barber]]></dc:creator>
            <pubDate>Sat, 30 Apr 2022 01:55:23 GMT</pubDate>
            <atom:updated>2022-12-21T21:53:25.015Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1012/1*9eEG3YyzqbcZS3Re2ku4FQ.jpeg" /><figcaption>It’s alive!</figcaption></figure><p>One may have seen my <a href="https://barberd.medium.com/building-a-new-altair-1975-style-5df2cd266d68">earlier article</a> about deciding to build up a 1975-style Altair 8800 from components. I left off saying parts were arriving and I was soldering away. What seems to always happen to me is that I forget something or order the wrong thing, so I end up needing to place another order and wait around for that to arrive…and end up spending a lot more on shipping than one would think. But finally I got everything I needed (except the power switch, which is still back-ordered).</p><p>In building this Altair, I created a few problems for myself that an original builder in 1975 wouldn’t have faced. First off, just having a kit with all the right parts and correct number of parts in it would have made it much easier. I kept finding I’d ordered the wrong part (the difference in part number between a 6-pin and 5-pin connector is one character in a 30 character string!) or just forgot something altogether.</p><p>But still, I can say that the hobbyists of 1975 had it rough. Building and debugging things involved several tools, all of which I’d collected over the years, but for someone just starting out would represent quite the investment: a soldering station, an oscilloscope, a signal generator, a logic probe, and a multimeter. One could probably get away with just a regular 10 watt soldering iron and a multimeter, but then one needs a little bit of extra luck that all the components are good (I had three bad chips myself)…otherwise one needs to find a friend with an oscilloscope. But come to think of it, maybe that would have been easier in 1975; TV and electronics repair shops and local vocational schools were more common and they had those tools. Still, it did require more support equipment than today’s projects of hooking the right sensors up to a Raspberry Pi; I wonder how many of the original Altair kits ended up just being tossed after their owners gave up on getting them working.</p><p>For me, my first challenge came once I’d gotten enough parts to put together the power supply, backplane, and CPU card. I thought I’d hook up my oscilloscope and check the clock signals for the CPU, as its common for the clock circuit to need a bit of tuning. But oh no! I wasn’t getting *any* clock signal. I poured over the schematic, did some research, and learned way more about oscillating circuits than I thought I ever would. At first, I thought I just had a bad crystal, but then I noticed that the line the crystal feeds was showing 5 volts, when the math on the two resistors involved said it should be 1.25 volts (my electrical engineering professor would be so proud). Tracing where the 5 volts was coming from, I identified that one of the integrated circuits was bad and back-feeding on one of its input pins! It took some time to get the replacement IC — fortunately the replacement chip solved the problem and my CPU started up!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1012/1*U1wI7HDAd7hxZC6dXumfWQ.jpeg" /><figcaption>The completed and working system. The card in the foreground is the CPU, the front panel interface behind it, then the memory card. In the back is the serial card on top of an extender board (so I can reach things to test with a oscilloscope or logic probe). Everything soldered up by yours truly.</figcaption></figure><p>Next, while looking over the schematic for the <a href="http://s100computers.com/My%20System%20Pages/RAM+ROM%20Board/RAM+PROM%20Board.htm">memory card</a> I was building, I noticed the bus line the front panel uses to instruct a memory write wasn’t even connected. Uh oh!</p><p>This comes down to a bit of a silly decision on MITS (the builder of the Altair)’s part. The Altair actually has two bus lines for writing memory: the one used by the CPU and the one used by the front panel. The original memory cards just OR’d the two signals together for the ‘write enable’ pin on the memory chips. As front panels fell out of use as soon as boot ROMs became common, later memory card designs (including the one I was building) simply ignore the front panel bus line. But since I did want to use the front panel, I’d have to modify the logic on the memory card to accommodate.</p><p>Fortunately the memory card design had one spare OR gate and another one used for driving a LED that I could live without, so I bent up some pins on a few chips and soldered some bodge wires to recreate the same OR logic as on the original Altair cards. See <a href="https://groups.google.com/g/s100computers/c/2B9kKdZc8Oc/m/jWPC8_7mBwAJ">this post</a> for more details on my modifications.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/758/1*YEOyY5vEkWdOdOx6EO2xTw.jpeg" /><figcaption>Modified memory card, complete with bodge lines to support the front panel and simulate some bus lines used in later S-100 systems.</figcaption></figure><p>So, I finally had the processor card working, the memory card working, and the front panel working. Conceptually at this point I had a Turing-complete finite state machine, aka a computer. It was time for the big test! I used the front panel to store a few bytes into memory, then examined those addresses to see if they were the same. Success! The next step was to put in a very simple program:</p><pre>         org    0<br>start    mvi    a,0<br>         jmp    start</pre><p>This compiles to only 5 bytes to enter via the front panel, and just loops over and over. But it proved the CPU could read from memory and execute instructions!</p><p>Next, I entered two programs that only require the front panel. The first was ‘<a href="https://www.youtube.com/watch?v=ZKeiQ8e18QY">Kill the Bit</a>’ (a simple game using the front panel lights and switches). Fun! The next was something I’ve wanted to do for years. There is a semi-famous (in geek circles anyway) anecdote of Steven Dompier presenting a program at the 3rd meeting of the Homebrew Computer Club (the same club where Jobs &amp; Wozniak first presented the Apple 1) of a program using the Altair’s switching noise that could be picked up as music on an AM radio player. The 1996 documentary “<a href="https://en.wikipedia.org/wiki/Triumph_of_the_Nerds">Triumph of the Nerds</a>” mentions it at one point. A while back I had run across <a href="https://archive.org/details/1975-05-peoples-computer-company/page/8/">Dompier’s article about it on archive.org</a> (see page 8), and I had to try it. It took a few minutes to key in, and I had to put the AM radio right next to the Altair to pick it up, but was soon able to get a small taste of that night in 1975. Magic.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FNucgMqQugy4%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DNucgMqQugy4&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FNucgMqQugy4%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/e30416d946d50051f857a6b944b187b8/href">https://medium.com/media/e30416d946d50051f857a6b944b187b8/href</a></iframe><p>So I had a working computer, with switches for input, and LEDs and radio interference for output. If thats all the Altair ever did, it probably would have been a footnote in history. But a few things happened: other manufacturers started to clone the Altair so it became a defacto standard…and a new company called Micro-Soft released an interpreter for Basic, allowing the Altair to be programmed using a simple high-level language over a serial connection. My next goal was to load Basic 1.0 onto the Altair.</p><p>Back in the day it was common to use a teletype or video terminal like an ADM-3, but I could just use a terminal emulator from a modern computer. But first I needed to make sure the <a href="http://s100computers.com/My%20System%20Pages/Serial%20IO%20Board/Serial%20IO%20Board.htm">serial card I built</a> was working. To test it, I wrote another simple program:</p><pre>org 0</pre><pre>start <br> in 0AAh             &#39; check status register<br> ani 080h            &#39; ignore everything but the byte ready bit<br> jnz start           &#39; loop if that bit is not 0<br> in 0ACh             &#39; input byte<br> out 0ACh            &#39; write same byte back out<br> jmp start           &#39; loop to beginning</pre><p>This checks to see if a byte is available (looping until one is), then reads from the serial port (configured via dip switch on my serial card to be at address 0xAC), writes whatever it received right back out to the serial port, then loops. This way, I was able to confirm the serial card was working in both directions. But I noticed something odd. This code would echo back whatever I typed in just fine…but when I tried sending a file, bytes would be dropped. Basically, when I sent things fast enough, some of those bytes would be lost. Sending “I am a test” would result in something like “amatst.”</p><p>I eventually hooked up an oscilloscope, and found this dirty signal coming into the ‘read’ pin of the USB module:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1012/1*FLElf2EvoVHc5jRtYpEpow.jpeg" /></figure><p>That extra spike was just enough to trigger the module to send a second byte from the module’s buffer, losing data. I traced this dirty signal back to a 74LS244 chip that was somehow picking up a stray signal. Replacing that chip fixed the problem…and with that, my machine now had a decent input/output capability.</p><p>At this point, I’d probably coded a few kilobytes of data into the front panel while testing and debugging everything. While the ability to inspect individual bytes and step through individual instructions is certainly very nice, toggling large programs into memory manually gets very old very quickly. As such, I next needed to visit bootloading for the Altair in order to load longer programs.</p><p>A bootloader is just a bit of code that loads more code. The saying comes from the phrase “pull yourself up by your bootstraps” and directly led to the modern terminology of “booting-up” or “reboot.”</p><p>The original bootloader for Altair Basic— written on the airplane by Paul Allen while on the way to meet with MITS to pitch the product — was very simple. It just loaded from the serial device (originally a paper tape reader) into memory starting at address 0, looping while data was being read. When the tape ran out, the bootloader went into a loop waiting for more data that never came, so it was up to the user to stop execution of the bootloader manually, and then restart execution at the loaded location.</p><p>I had to modify the bootloader code and basic code to use my serial card’s addresses and status bits instead of the original Altair SIO card. This was a common activity needed back in the day as well with a variety of hardware manufacturers selling slightly different competing products.</p><p>So time for the big test: I hooked my laptop (running Linux) up to the Altair’s serial card and keyed the 20 bytes of the bootloader into the front panel. Then I dumped the tape file to the serial device and started the terminal software:</p><pre>cat basic1.0-usb.tap &gt; /dev/ttyUSB0<br>miniterm /dev/ttyUSB0</pre><p>This is the modern equivalent of running the paper tape reader and then hooking up a teletype or video terminal.</p><p>I waited a second for the Altair to load everything from the serial buffer. Holding my breath, I reset the Altair and toggled the switch for ‘run.’</p><p>And here is what I got back (along with my first test):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/735/1*FuHCneMRzQpnRG0f7u__QQ.png" /><figcaption>Altair Basic 1.0 running…along with a one-liner BASIC program</figcaption></figure><p>Words cannot describe how excited I was. I’d done it. I soldered a working computer together component by component, and got a working machine out of it, complete with a high level interpreter for easy programming.</p><p>Even if I wasn’t around to invent the future with folks in the Homebrew Computer Club in 1975, I like to think that maybe, just maybe, I would have fit in at one of their meetings, and maybe even been invited to tag along to the bar afterwards.</p><p>In my next writeup, I’ll discuss getting CPM (the original home PC operating system) running on the Altair…without the help of a floppy drive.</p><p>Next story <a href="https://barberd.medium.com/patching-an-old-os-for-the-new-altair-7121a74b7da8">here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7585c0acb4e0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a New Altair, 1975-style]]></title>
            <link>https://barberd.medium.com/building-a-new-altair-1975-style-5df2cd266d68?source=rss-4e870e133dd4------2</link>
            <guid isPermaLink="false">https://medium.com/p/5df2cd266d68</guid>
            <category><![CDATA[altair]]></category>
            <category><![CDATA[vintage-computing]]></category>
            <category><![CDATA[makers]]></category>
            <category><![CDATA[retrocomputing]]></category>
            <category><![CDATA[homebrew-computer]]></category>
            <dc:creator><![CDATA[Don Barber]]></dc:creator>
            <pubDate>Tue, 15 Mar 2022 14:49:59 GMT</pubDate>
            <atom:updated>2022-04-30T01:56:24.820Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Original Altair 8800 and Teletype ASR 33" src="https://cdn-images-1.medium.com/max/800/0*oKfdGkgMtet603-I" /><figcaption>Original Altair 8800 and Teletype ASR 33. Image provided under <a href="https://en.wikipedia.org/wiki/en:Creative_Commons">Creative Commons</a> <a href="https://creativecommons.org/licenses/by-sa/4.0/deed.en">Attribution-Share Alike 4.0 International</a>; original at <a href="https://commons.wikimedia.org/wiki/File:Altair_8800_and_Model_33_ASR_Teletype_.jpg">https://commons.wikimedia.org/wiki/File:Altair_8800_and_Model_33_ASR_Teletype_.jpg</a></figcaption></figure><p>Back in 1975, the release of the Altair 8800 in Popular Mechanics heralded the arrival of the personal computer. Built around the Intel 8080 microprocessor, this Altair could be bought as a kit for $439. The kit had the case, power supply, front panel with LEDs for output and switches for input, CPU card, memory card, and all the components (chips, resistors, capacitors, etc) needed to assemble it. It had no keyboard or monitor (at first). But it did relatively well: it outsold all projections, inspired the first computer clone, and set the industry standard for bus design for the next 10 years. The community that sprung up around this computer is the stuff of legends: the Homebrew Computer Club (which regularly discussed the Altair) is where Steve Wozniak and Steve Jobs presented the Apple. And Microsoft’s first product was a Basic interpreter for the Altair, pirate copies of which triggered Bill Gate’s famous <a href="https://en.wikipedia.org/wiki/Open_Letter_to_Hobbyists">open letter to hobbyists</a>.</p><p>This period of time must have been so exciting. Today, assembling your own computer means buying pre-fab parts and plugging them together. Get a motherboard, video card, CPU, RAM, and hard drive, stick ’em all in a case, turn it on and install the OS. But back in 1975, it meant getting out a soldering iron. It meant understanding TTL logic chips and address lines. Maybe even finding someone with an oscilloscope so you could put the right resistor into the oscillator circuit for the CPU to function correctly because each crystal is slightly different. It meant literally flipping switches to load the opcodes directly into the memory. To use it, one had to understand it.</p><p>Could I, almost 50 years later, match the skill of these pioneers?</p><p>Altair emulators are available — even some in a web browser. Some choose to build an Arduino or Raspberry-Pi based emulator with a simulated front panel. But I didn’t want an emulator — I wanted a real machine. Original Altairs do come up for sale every so often, but they are quite expensive; $5000 is not unusual for good condition. But part of the point was to see if I could match up to those home hobbyists of 1975, and that included building it from components.</p><p>So I decided to build one from scratch.</p><figure><img alt="Altair 8800c case and bare circuit boards on a workbench." src="https://cdn-images-1.medium.com/max/1024/1*rDqVRF6atign9kqCXEMBcw.jpeg" /><figcaption>Case and Bare Boards</figcaption></figure><p>No one is making Altair kits anymore (it seems there was a replica kit available in 2017, but sadly no updates nor responses to email inquiries). However, I did find a good starting point at <a href="https://deramp.com/altair_8800c.html">https://deramp.com/altair_8800c.html</a>, wherein Mike Douglas sells a replica case, front panel board, and interface board. Its up to the builder to procure all the components to finish the boards, and also acquire power supplies, a backplane, a CPU card, and a memory card.</p><p>At this point, I had to pause and set some scope for myself. Mike Douglas’s front panel and interface board are not identical replicas to the Altair’s original board; it implements some additional minor functionality using a PIC controller that wasn’t available at the time. I could have ordered an exact replica front panel board from a <a href="http://jmprecision.co.uk/">supplier in the UK</a>, but after a bit of reflection, I decided that 1) the effort involved matched that of the original and 2) having the functionality (specifically the run-on-boot feature) of the PIC would give me more extensibility for future projects with the Altair. So I decided: I need not be dogmatic on building an exact museum-quality replica of the Altair, but I did want to build it all myself from components. Since the additional functionality is disabled by default, I could still prove to myself that I had the 1975 spirit, while giving myself the ability to make it slightly easier to use the computer later on.</p><p>Happy with my decision to use the new front panel design, I set out to source the other parts necessary for a working computer: the CPU board, the memory board, and the backplane board that connects the other cards to each other. There are several folks in <a href="https://groups.google.com/g/s100computers">the community</a> still designing and building new S-100 (the Altair’s bus design) boards; many designs with purchase contact information are listed on <a href="https://www.retrobrewcomputers.org/doku.php?id=boardinventory">https://www.retrobrewcomputers.org/doku.php?id=boardinventory</a>. <a href="http://s100computers.com/Cards%20For%20Sale.htm">S100computers.com’s “Boards for Sale” page </a>is also a great resource for card designs.</p><p>The CPU board was relatively easy to source; I ordered a replica Altair CPU board from Gary Kaufman available on <a href="http://the-planet.org/">http://the-planet.org/</a>. I could have chosen one of the Z80 board designs available elsewhere, which arguably would have given me better software choice (the Z80 is backwards compatible with the Intel 8080), but I decided that being limited to the original Intel 8080 instruction set matched with the experience I was trying to replicate. I can always swap it out with a Z80 board later.</p><p>The memory board was a bit tougher to decide upon. One can source a replica of the original boards from a <a href="http://jmprecision.co.uk/">supplier in the UK</a>, but the original designs used memory chips that are quite hard to find today, and expensive (one source I found was $10 each, and one needs 32 of them) when one can find them. One can find used boards on ebay for anywhere between $75 and $1000, but in keeping with the intent of the project, I really wanted to build my own.</p><p>So I decided upon the <a href="http://s100computers.com/My%20System%20Pages/RAM+ROM%20Board/RAM+PROM%20Board.htm">ROM+RAM</a> board described on S100computers.com, ordering a bare board (just the printed circuit board with no components on it) from Todd Goodman. This card will max out the memory the Intel 8080 processor can address (64k) with a $5 chip, and also allow me to add ROMs later. Programming a ROM with bootup firmware code saves one from needing to ‘bootstrap’ the computer by entering code into the front panel every time the computer starts up (modern computers call this firmware the UEFI — the Unified Extensible Firmware Interface; one may also remember the BIOS firmware from earlier x86 machines). This memory board is also very extensible, allowing for a variety of ROM and RAM chips, so it might prove useful for future S-100 projects as well. I also ordered a bare backplane card (aka a motherboard) from Todd Goodman. That takes care of the core ‘stuff’ that makes up a computer.</p><p>But to really make a computer useful, one needs easier I/O than switches and blinkenlights. Most folks back in the day added a serial interface to their Altair; this would either hook up to a <a href="https://en.wikipedia.org/wiki/Teletype_Model_33">Teletype printer</a> or a serial terminal. Mike Douglas makes a pre-fab serial card, but in keeping with the intent of my endeavor, I wanted to build my own. Not able to find a source for a reproduction board using the original Motorola 6850 chip, I ultimately decided upon the <a href="http://s100computers.com/My%20System%20Pages/Serial%20IO%20Board/Serial%20IO%20Board.htm">S100computers.com Serial-IO card</a>. This uses a new faster Zilog chip, but also adds a real time clock interrupt generator, and amazingly, a USB module. The challenge with choosing this board: while the IO address can be configured to match the original Altair serial boards, the status registers on the Zilog and Motorola chips use different bits to signal “ready to transmit” and “ready to receive” to software. This will require slight patches in the original Altair software. However, this can be seen as a kind of a bonus: this was a very common problem back in the day as well, and many hardware and software manuals contained instructions for similar patches…so yet another chance to prove I could have rolled with the 70s home computer community. I also ordered this bare board from Todd Goodman.</p><p>So, I had the bare cards for the front panel, interface card, CPU card, memory card, and serial card. I also got a bare extender board — just a board that one can use to raise another board above the rest of the boards in the backplane, useful for debugging during build. Then came sourcing all the parts: I poured over all the assembly instructions, and ended up with a spreadsheet of over 200 line items I needed to order. I ended up placing most of my orders with the big component supply houses: Jameco, Mouser, Digikey, and All Electronics, making choices mostly upon price and who had components in stock. Most components were easily available; my choices for a more modern memory and serial card design really helped out here. I only needed to resort to ebay for 3 ICs, one of which was the Intel 8080 processor itself. The other two ICs were just out of stock at the main supply houses, and I didn’t want to wait.</p><p>So remember that kit in 1975 cost $439? In today (2022)’s dollars, that’s roughly $2300. After final tally, this entire endeavor is working out to about $1000. Note that the original kit had only 4k of memory and didn’t come with a serial card either.</p><figure><img alt="Partially assembled circuit boards" src="https://cdn-images-1.medium.com/max/1024/1*7iNAjCKMt3xwjmjuCM3o0g.jpeg" /><figcaption>Roughly half the components have been soldered in. This represents probably about 10 hours of work — over 900 solder points on the backplane alone!</figcaption></figure><p>The parts have started to arrive and I’m soldering away.</p><p>My next post will be about the assembly process and (fingers crossed!) first bootup. I’ll also touch on patching standard Altair software such as Altair Basic to work with the new serial card.</p><p>After that, I’ll have another followup on modifying <a href="https://en.wikipedia.org/wiki/CP/M">CPM</a> (an early OS commonly used on the Altair) to work with the new serial card — but for more than just standard keyboard and display IO. I’ll be modifying CPM to instead access virtual 8&quot; floppy disk images hosted on a modern PC over a serial connection.</p><p>Update: Follow-up story <a href="https://barberd.medium.com/building-a-new-altair-hardware-debugging-bootstrapping-and-success-7585c0acb4e0">here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5df2cd266d68" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reverse Engineering MacWars]]></title>
            <link>https://barberd.medium.com/reverse-engineering-macwars-816e7a563141?source=rss-4e870e133dd4------2</link>
            <guid isPermaLink="false">https://medium.com/p/816e7a563141</guid>
            <category><![CDATA[reverse-engineering]]></category>
            <category><![CDATA[macintosh]]></category>
            <category><![CDATA[anti-piracy]]></category>
            <category><![CDATA[vintage-computing]]></category>
            <dc:creator><![CDATA[Don Barber]]></dc:creator>
            <pubDate>Mon, 17 May 2021 18:29:47 GMT</pubDate>
            <atom:updated>2022-08-25T07:08:46.552Z</atom:updated>
            <content:encoded><![CDATA[<p>One may have seen my prior post on <a href="https://barberd.medium.com/cracking-a-35-year-old-macintosh-game-2a079a3a2422">Cracking a 35 Year-Old Macintosh Game</a>, wherein I describe cracking Star Trek: The Kobayashi Alternative, only to “find out it was absolute garbage” as one friend and colleague put it. Still, it was a fun little challenge, and it whetted my appetite for the next challenge.</p><p>So I decided to look into the other abandonware for 68k Macs that remained uncracked, and hopefully required a bit more reverse engineering than just narrowing down the section of code to replace with no-operation instructions.</p><p>Soon I ran across what may have been considered the holy grail of early Macintosh copy-protected software: <a href="https://macintoshgarden.org/games/macwars">MacWars</a>. If you haven’t heard of Macwars, <a href="https://www.youtube.com/watch?v=NIOBkaEPS8Y">this Youtube video</a> by gruz gives a good overview. This was a clone of the popular Star Wars arcade game, which would not have its own Macintosh port for a few more years. It featured vector graphics, a 3d environment, digitized voice audio, … and a very sophisticated anti-piracy code that encrypted the entire game, literally decrypting chunks of the application as needed right before execution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/511/1*yoviFqtdMqnGPt7Pg2VC-Q.png" /><figcaption>MacWar’s title screen. The icons were actually stored as custom font characters in the system file.</figcaption></figure><p>The encryption and anti-piracy routines were likely done by PACE Anti-Piracy, Inc, which was formed in 1985, the same year MacWars came out. It is still active, known for its Interlok system from the dongle-based anti-piracy era and today’s Internet-based iLok license system.</p><p>Cracking MacWars would certainly be a proper exercise in reverse engineering, and as it appears theses early PACE-protected titles had never been cracked before, would make for some interesting security research.</p><p>A quick aside for those wanting a quick primer of reverse engineering through disassembly: its reading the assembly language directly from the machine code, usually without any hints like variables or function names, and trying to figure out what the code does. Half the battle is just figuring out if you’re even looking in the correct section of code. Sometimes the variables and function names are sometimes included in so-called ‘debugging symbols’ and can help with that immensely, but these are usually not included in production code as they take up time and memory. However, sometimes those symbols are left in, as was famously (and likely accidentally) done in the Grand Theft Auto 3 for PS2 and Android…but not so for MacWars. Anyhow, for a simple example, try to figure out what the following simplified assembly code does…and note that disassembled machine code doesn’t have the commented hints:</p><blockquote>0: movq.b 0, d0 #set register d0 to 0<br>16: movq.b $20,d1 #set register d1 to 32<br>32: cmp.b d0,d1 #compare registers d0 and d1 <br>48: bgt pc+$40 #if d0&gt;d1, then skip 64 bytes ahead<br>64: _sysbeep #call the system trap to make a beep<br>80: addq.b 1,d0 #add 1 to register d0<br>96: jmp pc-$40 #jump back 64 bytes<br>112:</blockquote><p>Figured it out? It basically does the same as this C-like code:</p><blockquote>i=0;<br>while (i≤32) { <br> beep();<br> i = i + 1;<br>}</blockquote><p>Now, imagine doing this for a couple thousands of lines of code, and this is what I took on for reverse engineering MacWars. For those researchers wanting to follow along at home, I’ve published my code on github at <a href="https://github.com/barberd/depace/">https://github.com/barberd/depace</a>/. The line numbers I refer to later in this article refer to specifically <a href="https://github.com/barberd/depace/blob/main/decrypt/macwars-D-decrypt.py">https://github.com/barberd/depace/blob/main/decrypt/macwars-D-decrypt.py</a>. Researchers may want to note that the hexadecimal addresses in the comments of that file are the corresponding location in the original file’s resource fork. Also note I don’t provide a copy of the MacWars software; to use my scripts, one will need to obtain it and then extract a copy of the application files into MacBinary format.</p><p>I didn’t start out knowing the application was encrypted. Stepping through the assembly, I first noticed the code that made sense was only at the beginning, and the rest was gibberish — just completely (seemingly) random data. This is unusual; programmers don’t tend to waste space, especially in the mid-80s when memory and disk space was limited. Even today such waste would be considered inelegant. It was a safe bet that this bad code might be encrypted good code — after all, something actually had to make up the game.</p><p>Focusing on the readable code, I noticed it grabbed a pointer to the beginning of the seemingly-random data. Further along, I spotted an EOR instruction. EOR (“exclusive or,” also termed XOR in other CPUs and languages), is one of the most basic digital instructions, basically saying: given two inputs, output true if only <em>one</em> of the inputs is true. The nice thing about this is that by EORing data with a key, the output is scrambled, but by EORing it again with the same key, one then gets the original data back. This makes it a <em>symmetric</em> operation, and its very commonly found in encryption algorithms. As such, I had a big hint this subroutine would decrypt the data.</p><p>But I still had a big problem: even if this did decrypt the later code block, the program didn’t actually seem to do anything with it. It just set up some registers like it was about to call another subroutine, but then just returned. Huh?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*S_FvruSMMwEjUsVWllzguA.png" /><figcaption>Just fly around randomly; eventually one will find the enemy space station… or decrypted code routine, whatever.</figcaption></figure><p>It took me a few minutes, but I finally figured it out: at the very beginning of the code, almost the very first thing it does, a pointer to the random data (decrypted later) is pushed onto the stack. And tracing further down, I could not find a corresponding pop from the stack.</p><p>This had to be on purpose; no compiler would output code that corrupted the stack so directly. But this was actually a clever hack: on the 68k processor, a JSR (Jump to SubRoutine) instruction pushes the current execution location onto the stack before executing the subroutine, and the RTS instruction (ReTurn from Subroutine), located at the end of every subroutine, pops the top 4 bytes off the stack and continues execution there, redirecting the computer back to the same place it had started from before the jump. But the PACE code pushes a new address onto the stack at the beginning of the subroutine without a corresponding removal from the stack at the end. Instead of returning to the true caller, the RTS instruction ‘returns’ to the wrong place, and starts executing code at the now-decrypted code block. Neat, with a minor side of stack corruption (wasting 4 bytes each time).</p><p>So, now that I’d figured out the general flow, the first order of business was to reverse engineer the decryption code, which ended up being two challenges: determine both the encryption key and encryption algorithm used. Both were tedious but straightforward, and I was able to recreate both using python.</p><p>For the key, the program read all the bytes of code making up the entire code segment, adding the value of each to a ‘seed’ number into a 32-bit register, ignoring any overflow. This became the key for later decryption. This is an artful method, as modifying the code at all, perhaps to add inspection breakpoints, would result in an incorrect key and stop most would-be crackers. This is the ‘getkey1’ call on line 139 of my code. Note that the initial seed number translates to “PACE” in ascii, the first hint that PACE Anti-piracy Inc provided this code.</p><p>For the decryption algorithm, its basically a key stream algorithm where the key was used to EOR a chunk of code, and then the key was rotated in some way for the next round— somewhat akin (though much simpler) to the way the RC4 encryption algorithm works. It was slightly tedious to get all the bitwise operations correct in python (python3 basically allows for infinite bits in its bitwise functions, so one has to code in 32 bit boundaries to simulate the 68k processor’s behavior), but quite doable, so a few dozen lines of code later (initiated by the write_decrypt1 call on line 141 of my code), I had another big section of Macwar’s code in readable form.</p><p>Then another layer of PACE’s sophistication was revealed: even after decryption, a good amount of the code was still encrypted, and this round used different algorithms both for key generation and decryption…and both were much more sophisticated. I reversed both of these as well, becoming the getkey2() and write_decrypt2() functions in my python code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/510/1*Vg-_Q6ZQXH1z5-SO2XL5HA.png" /><figcaption>Prepare to enter the tunnels…of encryption!</figcaption></figure><p>In total, it turns out there were 4 layers of encryption. Each round undertook several steps to prevent tampering: the system’s error jump tables were modified and then later examined to eliminate the ability to redirect execution outside of the program (and therefore give crackers an avenue), and it would even check to see if more than 3 seconds had passed since the last decryption round, and would corrupt the key in memory by EORing it with “POOP” if so (I guess programmers’ humor hasn’t changed much). If anything seemed out of place, the system would reboot. Additionally, each layer wiped the prior layers from memory when no longer needed, so anyone somehow bypassing all the lockouts still wouldn’t have access to the data if done a millisecond too late.</p><p>The third round was where the bad-block disk check took place, and would also check certain things like the timestamps of the application file and the disk volume, which it passed to the fourth round for later use. This underlines why its so important to get a good disk image when doing research; sometimes archivists accidentally modify the volume in such a way that loses important data, such as the ‘last modified’ timestamp.</p><p>The fourth and final round was finally where the ‘real’ application decryption took place, which involved two activities. The first was decrypt the program’s jump table found in the first code segment, and the second was to set up the OS to decrypt the rest of the application’s code segments. And both implementations were glorious, from a computer science perspective.</p><p>For full appreciation of the beauty of how PACE designed their solution, one needs to understand how the original Macintosh did memory management. The original 1984 Macintosh had only 128 kilobytes of memory, so entire programs often couldn’t be loaded into memory — and instead only sections (called segments) would be loaded, one at a time. Programmers would compile their code into these different segments (some development suites would break up the code automatically), use a linker to assemble them with control passing through a ‘jump table,’ and store them as different entries within the application’s file. There could be up to 256 of these “CODE” segments, allowing for large programs to operate in only 128k of memory, largely seamlessly to the user. The jump table, combined with the Macintosh’s memory management ROM calls, acted like a traffic cop to pull in the right code segments when needed. And PACE developed their system to integrate with all this.</p><p>When a user starts an application in the Macintosh, the operating system (really, the ROM calls) first loads and executes the first code segment, which on most programs contains the jump table. As such, a processor entering a new application normally involves executing the very first jump in the table. In the case of MacWars, PACE encrypted the original jump table, replaced the first 8 bytes with a jump to its own code, and saved the original (but encrypted) 8 bytes into its own code segment (CODE4). The fourth round of encryption copied these bytes back, and then decrypted the entire jump table, allowing the application’s normal behavior. This is replicated in line 164 and 166 of my script.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/511/1*v-qyYf-m37bj_CxYwtgKQA.png" /><figcaption>The enemy space station. Maybe the final encryption key is somewhere inside?</figcaption></figure><p>Next, the key was incremented by a certain amount to derive the final key used for decrypting the rest of the application. The exact number was determined in round three, but is calculated in some very complex code that I couldn’t get my head around after 2–3 days of tracing assembly. While I’m certain I could grok it with a little more effort, it turned out to not be necessary. I figured out that there is a fatal flaw in PACE’s decryption algorithm: it only really uses the last 8 bits of the 32-bit key, as the algorithm only operates one byte at a time. This means there are only 256 possible keys, not 4.3 billion. Additionally, the first two bytes of a code segment is the offset of that code segment’s first entry in the jump table. Since the jump table was less than 256 bytes long, the offset would always entirely fit into just the second byte, meaning I was certain the first byte must decrypt to 0. Once I’d deduced these facts, it became trivial to bruteforce the correct key (as one can see in lines 177–187 of my script).</p><p>The fourth round then took this derived key and tied itself to the Macintosh’s memory ROM routines. PACE’s code replaced the CPU’s custom trap handler for “_LoadSegment” with its own routine that would first call the original “_LoadSegment” routine, then decrypt the code just loaded from disk, and then return to the application. This allowed for decryption on-the-fly, and must have required a very deep understanding of the Macintosh…and some Linked-In sleuthing suggests the founder of PACE had indeed worked at Apple.</p><p>Fully appreciating the elegance of the solution, but armed with the final key and the reverse-engineered algorithm, I was able to decrypt the entire application (lines 193–196 in my script). The original application code was revealed, and the PACE code had been bypassed.</p><p>Yay!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/513/1*qvIiwzCxhxDjADYLkkLxRA.png" /><figcaption>The application was decrypted, revealing the ‘core’ of the anti-piracy routines.</figcaption></figure><p>The challenge wasn’t completely over: the application is split into four different executable files, and I needed to repeat the whole exercise for one of the other files. I also had to bypass some additional anti-piracy code (patches found in <a href="https://github.com/barberd/depace/tree/main/patch">https://github.com/barberd/depace/tree/main/patch</a>) within the application segments, but these were pretty straightforward to locate and bypass. Now, 35 years after release, the game is now playable on emulators, and one can write new floppies to replace the aged original ones. And unlike my last article, I can say this game was actually a lot of fun, and is very exciting to play even today.</p><p>In the few weeks since, I’ve discovered a few other games that were protected by PACE. I’m assuming PACE must have had different package offerings available to client software publishing houses, as several games (<a href="https://macintoshgarden.org/games/sword-of-kadash">Sword of Kadash</a>, <a href="https://macintoshgarden.org/games/shanghai">Shanghai </a>(version 1), and <a href="https://macintoshgarden.org/games/star-trek-the-kobayashi-alternative">Star Trek: The Kobayashi Alternative</a>) did have the same self-decrypting anti-piracy routines, but did not encrypt the rest of the application. These used the same encryption algorithm as rounds 2–4 in MacWars, but the keys were hard-coded instead of being generated dynamically. The only other game I’ve found (so far) that encrypted the entire application similar to MacWars is <a href="https://macintoshgarden.org/games/the-seven-cities-of-gold">Seven Cities of Gold</a>. This doesn’t mean others won’t turn up though!</p><p>PACE should be very proud; their anti-piracy system lasted 35+ years, and was full of methods that would still be considered best-practice today, and were absolutely ground-breaking back then. It was an amazing piece of work, and one gets a sense of how exciting it must have been to help develop it, even 35 years disconnected. But…maybe next time use the full 32 bits of the key, not just the last 8? I’m betting someone got a little rushed and didn’t want to figure out how to handle cases where the code size didn’t line up to an exact multiple of 32 bits.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/513/1*LXunamK7RTtPQiTC5SzlBw.png" /><figcaption>Enemy space station go boom. The galaxy is now safe for vintage gamers.</figcaption></figure><p>I’m proud to have solved this challenge, and must give kudos to PACE for developing such a strong system that lasted 35+ years. I hope by sharing my code and these techniques, other researchers can continue to work on other applications and games no longer available to vintage computing enthusiasts.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=816e7a563141" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cracking a 35 year old Macintosh Game]]></title>
            <link>https://barberd.medium.com/cracking-a-35-year-old-macintosh-game-2a079a3a2422?source=rss-4e870e133dd4------2</link>
            <guid isPermaLink="false">https://medium.com/p/2a079a3a2422</guid>
            <category><![CDATA[star-trek]]></category>
            <category><![CDATA[cracking]]></category>
            <category><![CDATA[vintage-computing]]></category>
            <category><![CDATA[assembly]]></category>
            <category><![CDATA[macintosh]]></category>
            <dc:creator><![CDATA[Don Barber]]></dc:creator>
            <pubDate>Sun, 02 May 2021 14:40:23 GMT</pubDate>
            <atom:updated>2021-05-02T18:32:08.267Z</atom:updated>
            <content:encoded><![CDATA[<p>One may recall my last post on <a href="https://barberd.medium.com/reviving-a-dead-macintosh-classic-a90d2072c24c">Reviving a Dead Mac Classic</a>, wherein I repair a damaged Mac Classic. After getting it running again, I wanted to find software for it, and soon ran across the fine folks at macintoshgarden.org. This is one of the main <em>abandonware</em> sites on the net for Macintosh, where vintage computing enthusiasts can still find old software years after society has moved on to other platforms. There is a strong ethical framework: software must be at least 10 years old and no longer for sale by the publisher. This way, creators aren’t harmed by the collection (often theses companies no longer exist), and the software is preserved. It reminds me of a niche focus of the digital archivists at archive.org or reddit’s /r/datahoarder. Equivalent sites exist for many other vintage platforms .</p><p>Because I’m such a geek, I first searched for old Star Trek games. <a href="https://en.wikipedia.org/wiki/List_of_Star_Trek_games#Video_games">The history of Star Trek video games</a> is interesting on its own (after all, the Venn diagrams between Star Trek fans and computer programmers have a lot of overlap) and even predates the concept of selling software a bit. As I was a fan of the original series from a very young age, finding these titles on old platforms is a good way for me to get a good hit of double nostalgia.</p><p>Searching for ‘Star Trek’ on macintoshgarden.org revealed a few games, but the one that caught my interest was <a href="https://macintoshgarden.org/games/star-trek-the-kobayashi-alternative">Star Trek: The Kobayashi Alternative</a> as it also appeared in a thread asking for help with cracking the software so it can be played without the original disk. Looking into it, this was a very early game with a story written by Diane Duane — who had written a few episodes and several Star Trek novels that I’d devoured as a preteen. Wow, exactly what I was looking for! But back to the problem: it had a sophisticated anti-piracy mechanism that hadn’t been cracked, so no one could play it unless they had an original disk that had somehow survived since 1986.</p><p>So I decided to crack it.</p><p>Reverse engineering can be a lot of fun. I’d done small bits of x86 disassembly and tweaking to get some old DOS programs working in a modern Windows shell, adjusted the behavior of Android applications by modifying its compiled java bytecode, and reverse engineered a DRM solution from its ARM-compiled library and recreated it in python so I could watch movies outside of the walled garden of a well-known streaming television service’s application. So, much like those, I figured this would be a challenge, but doable.</p><p>I had to first figure out how the original Macintosh programs worked, and then the tooling for inspecting and modifying such software. The original Macs used the Motorola 68000 (or 68k) processor series, and my favorite tools (like <a href="https://www.hopperapp.com/">Hopper</a>) don’t support that architecture. But there are other tools I’m reasonably comfortable with, like <a href="https://www.hex-rays.com/IDA-pro/">Ida Pro</a> and GNU’s objdump (cross-compiled for m68k support) that do support it, so I was able to cobble something together.</p><p>Getting my head wrapped around the way early Macs were programmed was actually a lot more involved than I’d anticipated, but this also gave me a huge appreciation for the technological wonder the Macintosh was for its time. Concepts that annoyed young sysadmin me — like each file possibly having two sets of data (the data and resource forks)— revealed themselves as being very elegant computer science and user experience solutions (if one doesn’t expect to interface with non-Macintosh systems). The memory management routines allowed for very sophisticated applications to run in <em>only 128k of memory</em> with elegant ROM routines that enabled swapping out segments of code from disk as needed, and the fact that most of what would be made part of the OS or a supporting graphics library today was <em>burned to ROM </em>(<a href="https://www.folklore.org/StoryView.py?project=Macintosh&amp;story=Real_Artists_Ship.txt">and at the last minute</a>!) affirmed what we’re always told: the Macintosh team did something really, really special.</p><p>But back to the goal: there are several anti-piracy methods, but a common one during this time period was for manufacturers to start with a brand new, never-formatted disk, and to clone from their golden copy to the disk, but <em>not</em> writing one block located in a locked and hidden file. Because this block never had 1s or 0s written to it and therefore was not magnetized in either direction, the drive head would basically get confused and respond with random data for each read of that block. Anti-piracy routines would read this block a few times, and if it got the same data every time, that meant the disk had been copied.</p><p>Narrowing down the anti-piracy code in Star Trek: The Kobayashi Alternative was somewhat tedious and time-consuming, but wasn’t difficult. I’d pour through the assembly code, teaching myself 68000 assembly as I went, look up Macintosh ROM calls in <a href="https://en.wikipedia.org/wiki/Inside_Macintosh"><em>Inside Macintosh</em></a> as needed, and narrow my focus down to an area of the code I thought might be related to the anti-piracy code. I’d then use a hex editor (such as ghex or hexedit on Linux before transferring the binary over, or ResEdit directly on the Mac) to replace the instructions before or after those points with $A9FF. This custom instruction trap instructs the Macintosh to fire up the debugger (either MacsBug or TMON, depending on which one decides to install). If the anti-piracy code stopped execution before the debugger fired up, the code I was trying to locate was before that point. If I found myself in the debugger, it was after that point. Its not elegant, but it works, and I have to start somewhere when learning a new system. From there it was just a matter of time and iterations before I was able to narrow it down to the exact jump and test instructions that ran the anti-piracy code. I then replaced those with $4E71 (a ‘no operation’ instruction) in the hexadecimal editor, giving me a working game with the piracy protection disabled.</p><p>And it turned out the game is horrible! <a href="https://www.filfre.net/2014/12/simon-schusters-treks-to-nowhere/">This review</a> says it might actually be the contender for the <em>worst adventure game of all-time</em>…and I think I agree. Its a horrible mishmash of free-text ‘speaking’ to give orders to crew members, clicking through menus to move your own character, weird bugs, and lawn-mowering across empty kilometers of coordinates on away missions hoping to randomly come across the <a href="https://en.wikipedia.org/wiki/MacGuffin">MacGuffin</a> for that planet. If you imagine what kind of game a bunch of creative-types at a publishing company in the 80s would make for the then-brand-new medium of home computer video games, it kind of makes sense from a failed artistic endeavor perspective. Its too bad too, as the overall plot from Diane Duane has some legs to it. But I couldn’t put myself through playing it for more than an hour.</p><p>So I might have failed in my mission to locate the missing Captain Sulu on the USS Heinlein, but I did succeed in my mission to bring back a classic Star Trek game to both Star Trek and early Macintosh fans. Check it out on <a href="https://macintoshgarden.org/games/star-trek-the-kobayashi-alternative">macintoshgarden.org</a>. It only took a few days, and most of that time was just getting my head wrapped around the way Macintosh works.</p><p>I suspect many coders will scoff at the relatively brute-force technique I used for cracking Star Trek: The Kobayashi Alternative. But hey, it worked, and I promise I will make up for any lack of technique or elegance with my next post, where I will discuss restoring <a href="https://www.youtube.com/watch?v=NIOBkaEPS8Y">MacWars</a> to the vintage Macintosh community. This may have been considered the holy grail of early Macintosh copy-protected software, and cracking it was certainly not as simple as locating a chunk of code and replacing it with no-operation instructions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2a079a3a2422" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reviving a Dead Macintosh Classic]]></title>
            <link>https://barberd.medium.com/reviving-a-dead-macintosh-classic-a90d2072c24c?source=rss-4e870e133dd4------2</link>
            <guid isPermaLink="false">https://medium.com/p/a90d2072c24c</guid>
            <category><![CDATA[mac]]></category>
            <category><![CDATA[macintosh]]></category>
            <category><![CDATA[pcb-circuit-board-repair]]></category>
            <dc:creator><![CDATA[Don Barber]]></dc:creator>
            <pubDate>Wed, 17 Feb 2021 03:31:45 GMT</pubDate>
            <atom:updated>2021-02-17T04:07:49.834Z</atom:updated>
            <content:encoded><![CDATA[<p>For the past few years, I’ve had an empty Macintosh Classic shell on a table behind me in my home office, the result of a Macquarium project of mine from 2000. And people love it! During video calls it always made for a good topic of conversation.</p><p>But people were always disappointed it wasn’t a real working Macintosh…and truth be told, so was I. So what to do? Get a working vintage Macintosh of course!</p><p>It turns out there is a lively market for vintage Macs, with working capacitor-refurbished models commanding a few hundred dollars, some complete with SD card hard drive replacements to give silent mega-capacity. There are also plenty of stories of folks coming into them for free from friends or family, but no such luck for me. Like many collectibles, people either know what they have and try to get top dollar for it, or don’t know what they have and therefore don’t offer them for sale in the first place. I focused on Macintosh Classics as I already had a mouse and keyboard for one (from the Macquarium project), and they’re one of the most recognizable since they were so popular in education due to their lower (sub $1000) price point. I decided to take a risk and purchase a non-working one and see what I could do with it. A very common issue is bad capacitors, and since I’m familiar with replacing those, I hoped it would be that simple. Spoiler: it wasn’t.</p><p>It arrived, in good external shape, and the date on the case stated production was in April 1991. Wonderful! But the first problem: there was clearly something rattling around inside the case. I hooked it up and the screen showed a checkerboard pattern. Some research indicated this happens when the processor can’t load the ROM into RAM, so its often due to bad memory…so first order of business is to pull the memory-expansion daughterboard to see if that might be the cause. Upon opening the case to do so, I discover what had been rattling around: the battery and the battery holder. And they looked horrible. This was the aftermath of the ‘Maxwell bomb,’ wherein the Maxell-brand PRAM battery exploded, spreading battery acid on everything and generally eating through the logic board. The metal railings of the chassis showed the corrosion of the battery acid as well. Removing the memory daughterboard changed the checkerboard pattern to have thicker boxes but was otherwise very similar; some online forum postings suggest the checkerboard is the video chip is looping through all the RAM, so this display change is explainable by the change in the amount of memory available.</p><figure><img alt="Old leaking battery, battery holder, and old capacitors." src="https://cdn-images-1.medium.com/max/576/1*r-Bd_O0pnHQDDWjKMxAIEA.jpeg" /><figcaption>The leaking battery, battery holder, and some of the capacitors later replaced from the logic and analog boards.</figcaption></figure><p>Examining the logic board, the battery left a lot of gunk the color of rust on the board. I cleaned it up as best I could, unfortunately not remembering to take a picture beforehand. The traces looked okay, but some of the vias (the solder points through the 4-layer board) near the ex-battery looked suspect. Before doing anything drastic, I decide to replace the electrolytic capacitors on the logic board and the analog board as Occam’s Razor says they’ve likely failed and were the source of the problem (Spoiler: they weren’t…at least not solely). Along with the capacitors, I also ordered a new PRAM battery and battery holder.</p><p>A few days later, I had the new capacitors in, the power supply on the analog board was testing at a good full +5v/+12v, but the screen was still showing a checkerboard. I got a little forceful with one capacitor and pulled up a pad, a reminder to never rush these things, but a quick jumper to the connecting pin on the sound chip took care of it. As the board was still pretty dirty, and the added flux for my capacitor work just made it worse, I put it in an overnight vinegar soak and then ran it through the dishwasher. But afterwards, the screen still had the same checkerboard.</p><figure><img alt="Mac Classic showing a checkerboard screen." src="https://cdn-images-1.medium.com/max/576/1*GzBBa8A2ZaG2Zxeql22iog.jpeg" /><figcaption>Checkerboard pattern upon startup. This is the pattern after pulling the daughterboard showing only the onboard memory.</figcaption></figure><p>At this point all the easy stuff was ruled out, and normally I would have given it up as another failed project…but my mind kept going back to those suspect vias. So I downloaded <a href="https://archive.org/details/Macintosh68kSchematics">the Bomarc schematics</a> from archive.org and set about the painstaking task of testing individual traces. I also thought perhaps the clock circuit might have been broken, so I hooked up a frequency counter to the Y1 crystal — which promptly fell off the board. I suspect the battery acid had weakened the connection, but it was a quick fix to reconnect it.</p><p>Checking traces ended up being exactly the right move. It turned out one of the address lines between the processor and the ROM was broken. I soldered in a bodge wire (a thin jumper wire to repair a broke trace) using some 30 AWG wire and gave it another try. Yay, the screen was different! Instead of the checkerboard, it was the standard Mac “raster screen” background. This indicated the processor was able to load the ROM and start executing code. But still, there was no startup bong or mouse.</p><figure><img alt="Close up of the Macintosh Classic logic board showing damage." src="https://cdn-images-1.medium.com/max/576/1*GW7ancfI1M2lGzuWrtV7Tw.jpeg" /><figcaption>The area of the board the battery acid leaked from the battery. One can see how poorly some of the vias are looking; it turns out a total of 9 were bad; the whitish one in the center to the left of the ‘BT1’ label, two in the center-top near the ‘B’ label, and the 6 in 2 rows just north of the UA2 chip in the picture. Also note the disconnected Y1 crystal to the far right, which fell off during my testing.</figcaption></figure><p>Some more research indicated that the ROM code does the bong sound very soon after initializing the screen, so my next thought was that something was wrong with the sound chip. All traces tested fine there. As the sound chip is accessed through the 65C22 VIA chip, I concentrated further circuit testing there. Sure enough, the read-write line and one of the data lines between the VIA chip and processor were bad, the product of two more failed vias. Two more bodge lines, and voila! She booted!</p><figure><img alt="Mac Classic showing the “Welcome to Macintosh” system 7.1 startup screen." src="https://cdn-images-1.medium.com/max/432/1*6bnNHWx-5gvHdbbIM9KuGw.jpeg" /><figcaption>Behold!</figcaption></figure><p>FYI— the Bomarc schematic has the wrong pin numbers for the ROM’s data lines; fortunately it was fairly easy to determine the pattern from the other working lines.</p><p>It turns out this Mac Classic had System 7.1 installed. From the files on it, was a lab computer from Bowling Green State University in Ohio, and taken out of service sometime around Fall of 2000. I can totally believe this machine was on almost everyday for 10 years, and then in storage for twenty years since then. It has a smattering of half-complete Word 4.0 documents for various undergrad western civ, french, and sociology papers, so its a fun peek at late-90s/early 2000s academia.</p><figure><img alt="Mac Classic logic board with several repair lines added." src="https://cdn-images-1.medium.com/max/432/1*H2uCl_nvaduQQlkXLveczQ.jpeg" /><figcaption>The now-working logic board, complete with replacement lines. The blue bodge wires were needed to get it to boot, the yellow ones were added later to get the serial port to work.</figcaption></figure><p>Trying to actually use the machine revealed the floppy drive was filthy; something in it was destroying disks (and these are a finite resource now) so I ended up taking the floppy drive apart to deep clean it using <a href="https://www.youtube.com/watch?v=a3Vc3SdZJ2Y">this video</a> as a guide. Seeking to avoid “sneakernetting” with floppies over the long term, I tried to “network” the Mac Classic to a Linux box using a null model cable. So I grabbed a terminal software package from <a href="https://macintoshgarden.org/">macintoshgarden.org</a>, used Linux’s hfsutils and a USB floppy drive, and copied it onto the Mac Classic. I then soldered together a null model cable and configured the Linux box provide a login on the serial port with agetty.</p><p>At this point I discovered the circuits for powering some of the serial port pins also had their vias destroyed by the leaking battery. A few more bodge lines later, serial is working, and now I have my very own little BBS-like setup for the Mac Classic. I’m able to transfer software packages directly using the old school sx, sb, and sz UNIX commands, and can even simulate dial-up Internet via pppd or slirp if desired.</p><p>Its been fun getting this old workhorse up and running again, and it definitely feels good saving one from the trash heap. I’m now tempted to find other non-working vintage Macs to work on — perhaps a SE/30 or a Color Classic. I’d also love to get my first computer again — a Tandy Color Computer 3 — though I doubt it would garner the same reaction in the background of my video conference calls. Nothing else has quite the same place in our collective tech hearts than an old school Macintosh.</p><figure><img alt="Mac Classic showing the Afterdark Flying Toasters Screensaver" src="https://cdn-images-1.medium.com/max/432/1*DDNriQ1CYB3PZ0UjFDJNLg.jpeg" /><figcaption>Totally worth it for the flying toasters alone.</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a90d2072c24c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>