But wait, there’s more.
I wanted to say, “thank you” to all my Patreon patrons. You are the ones who make this blog possible for all of us. By way of thanks, I was inspired to revisit my last blog post and update things a bit. This is a free mini-article for everyone, just to let you know how much I appreciate all the patronage. If you’d like to be as cool as those people, follow this link and sign up to be a Patreon Patron of Blondihacks:
Now, on with the show!
After my recent adventure in regaining control of the accelerator on the Apple IIc Plus, I was pretty pleased with myself. I had made it so that the machine defaulted to 1Mhz, but could still be sped up to 4MHz by holding Option. This is clearly how the retrogods intended things to be, and they were pleased.
My intrepid readers wouldn’t let me leave it at that, however. My ultimate goal, as you may recall, was to reverse the meaning of the ESC key in the machine’s normal speed selection process. I couldn’t quite achieve that, because the keyboard circuitry is not yet readable at that point in the boot. I could only check keys like Option that bypass the keyboard hardware. However, readers Chris Torrence and Jason Clark pointed out that perhaps I could read the current state of the accelerator and simply reverse it, rather than checking a key. That elegant idea somehow escaped me while I was heads-down in my travails. Sometimes when you’re laser-focused on a problem, you can’t see the forest for the cart before your eggs are hatched. I think that’s how that proverb goes. Anyway, you know what I mean.
I set out to do what Chris & Jason suggested, and I learned a little bit more about the accelerator along the way. The CGGA has a 16-bit status register that can be queried:
So, it should be a simple matter of checking bit three in the lower byte of that register, and acting accordingly. Here’s the modification to my previous patch that I came up with to do that:
You might look at that code and think it’s strangely… inefficient. Why all the duplication of locking and unlocking the accelerator on the two code paths? Well, it seems there are some kind of constraints on the CGGA’s Unlock/Modify/Lock cycle. Any sort of branching or excessive delay between the Lock/Unlock appears to cause the accelerator to ignore commands. Perhaps the CGGA has an internal command buffer that is processing these in a time-sensitive way. In any case, I found through extensive experimentation that anything more complex than the shortest-possible unlock-modify-lock code doesn’t work. Weirdly, there is sample code in the documentation that branches to reuse code, but it doesn’t appear to work either. That’s why my patch “unrolls” the process on each of the two possible code paths for reversing the state. The downside is that this makes the code much larger, and there was a chance that, at a portly 80 bytes, it might no longer fit in the hole in ROM that I had found for it. Remarkably, it fits with one byte to spare. Truly, the retrogods are smiling upon us, fare readers.
There you have it. Now the machine defaults to 1MHz, but can still be booted or reset to 4MHz using the ESC key. I think I finally feel comfortable putting the top back on my IIc Plus.
Thanks again to all my readers, and especially my Patreon patrons. This blog would not exist without you! Now is a great time to become a Patron, because there some awesome hacks coming soon to a blog near you. And by that I mean this blog. This one you are reading. Not sure if that was clear. Please keep reading this blog that you are reading right now. Um.. that’s all.