Sunday, October 3, 2021

RC2021/10 - The Beginning


This is my first post for RC2021/10.  Throughout the month I will be documenting the development of an Apple //e expansion card that I started working on in July.  I will also be working on the development of that card.  Lastly I will be finding a few previous RetroChallenge projects from the past and posting them on github.

Around 15 years ago I found an Apple //e on craigslist and bought it.  I had grown up with Apple ][ computers in my schools, and at one time even know how to use them, but all that knowledge was gone.  I booted it, and started up the one disk that came with the computer, was confused and put it all away after a few weeks or less.  Hoping to do something with the computer, I bought a bunch of books of of alibris.com for cheap.  One of them was "Hardware Interfacing with the Apple II Plus.


I've dabbled as a hobbyist in electronics for most of my life, and made a few simple PCBs, but I always wanted to work on a real hardware project for a computer and never had.  I looked at this book often enough, thinking it was my best shot at breaking through but I didn't really know how or where to start.  Then last July I found this...


The Apple II Breadboard Adapter.  I have breadboards, and logic probes, surely this would be a great way to start.  Then, the same day, while asking around about the breadboard adapter card, I found someone who was willing to send me one for free!  I waited for it to arrive in the mail and I started reading the Uffenbeck book in earnest.  To be honest I didn't make it past chapter four.  Once I learned about the DEVICE SELECT line (~DEVSEL which I'll discuss more about in a bit) I was too excited to keep reading and spent all of my time daydreaming about the endless possibilities of fulfilling my Apple ][ expansion card dreams.  A quick aside about having an Apple ][ enthusiast, who had never talked to me before, send me this card for free... Had I bought this card, I bet it'd be sitting in a drawer unused.  The fact that someone took the time to mail it to me, at their cost, really compelled me to make use of it and not waste their effort.  It was incredibly generous.

The Apple ][, ][+ and //e have 7 or 8 card slots.  Each slot has 50 pins.  Well Uffenbeck calls them pins.  It's a card edge connector, so what are they, pads?  Doesn't matter; sometimes I'll call them lines, sometimes pins, and even sometimes bits.  There are 16 address lines and 8 data lines.  It would be completely unreasonable for a card to watch 16 address lines in order to know that data is being written to or read from the address space reserved for that card.  And that's where the DEVICE SELECT line comes into play.

Just to take a step back: the idea of "writing to" and "reading from" the "address space" "reserved for the card" are each independent concepts that I really didn't know anything about going into this project.  I didn't know how an Apple ][ and an expansion card communicated.  Turns out, for most cards, there's really not much to it.  Each card has two little spaces in the memory map just for it to use.  One is 16 bytes and the other is 256 bytes.  The Apple ][ can peek (read) and poke (write) bytes of data into those addresses, and the card, if it's listening, can respond accordingly.  The fact that cards can be "talked to" using PEEK and POKE was important to me.  That meant I could use BASIC.  I had assumed I'd need to do assembly language.  I already felt like I was having to learn everything from first principles, so I was happy to avoid that hurdle for the time being.

So lets talk about the card's address space and that DEVICE SELECT line.  A card in slot 2 has 16 bytes that are reserved for it at address spaces 49312 to 49312+15.  In hex that's 0xc0a0 to 0xc0aF.  So of the 16 address bits, only the last four address bits are changing (0 to F).  But in order for a card to be aware that the Apple ][ is reading or writing to the card's 16 bytes, the card has to watch the higher 12 bits (0xc0a).  The DEVICE SELECT line is a single line that lets a card in slot 2 know that the current address is an address that starts with 0xc0a.  Voila!  Your card can watch DEVICE SELECT, and when it goes low, it knows that the Apple ][ is reading or writing to the card.

If you just wanted to toggle an LED, you could do it by connecting to only the DEVICE SELECT line and nothing else.  Any time a basic program PEEKED or POKED any of the card's address space, the DEVICE SELECT line would go low and you could toggle a flip flop.  Or, if you wanted to turn on or off 16 devices, you can watch the DEVICE SELECT line _and_ the lowest 4 address lines to get a 4 bit value for the thing you wanted to turn on or off.

Well that's it for now.  Next time the card arrives in the mail and I have to figure out what I'm going to do with it.

Friday, September 3, 2021

 

I am intending to participate in RetroChallenge 2021/10.  In order to register I need to submit a URL to a picture.  So I am posting this picture for that purpose.  While I am here, I guess I can mention that it is a photo of my current development setup.  I write ESP32 code on the black laptop.  I write AppleSoft BASIC code on the //e and //c using Beagle Bros "Program Writer".  The //e has the apple2idiot expansion card I designed in (slot 2, this is where the ESP32 lives).  I prefer the keyboard of the //c, so, I do big bouts of code writing and file management stuff on the on the //c and then swap the code over (via floppy disk) to the //e and run the software and fix bugs.  Ta!