System Status #1

zero_page
7 min readApr 2, 2022

--

Now that Australia has returned to some semblance of normalcy, work has been progressing steadily. Since the last update a lot of effort has gone into getting the game into a state where playtesting can occur and real art and story can come online. But playtesting has uncovered one big problem: BASIC.

Not the language itself, or the challenges of programming in general, but just the exact version of BASIC that I’ve been using. It is after all over 40+ years old. It’s not that it has bugs, the nice thing about emulation is that bugs aren’t my fault for a change! Instead the problem lies in trying to use a text editor from the ancient past, after becoming accustomed to decades of progress in the field. Those old machines didn’t really agree on what the “backspace” key did, much less the arrow keys or anything else.

Watching people attempt to use the in-game computer was an exercise in frustration as they tried to use shortcuts and muscle memory trained on UI conventions that have been common for a long time — just not as long as this program has been around.

Add to this that there are a handful of nuances in the version of BASIC I’m using that make life difficult even if you can type what you want into it. Older programming used a lot of hexadecimal numbers. They’re great! Once you adapt to the few extra digits, you get a cleaner representation of how numbers are stored in base-two systems. Numbers like $C000 are easy to remember, unlike its decimal equivalent of 49,152.

If only this worked…

This version of BASIC however, doesn’t understand hexadecimal at all. So you’re constantly needing to remember numbers in the tens of thousands. This slows down what would otherwise be a pretty straightforward exercise and becomes and chore of looking back and forth between your notes and your terminal screen.

Another disadvantage of the older BASIC is in how it warns about errors in your code. Mistakes are always going to happen, even more so when you’re learning a new language from scratch! So when you make a mistake you need clear guidance on what went wrong and how to make it right.

BASIC’s answer?

Can you spot the error? It all seems reasonable enough…

Yes, but where? And what?

Upgrading History

The great part about emulation is that you get a bunch of work for free. I didn’t need to write BASIC or DOS in the beginning, I just needed to emulate the machine those programs ran on. If there were bugs within those pieces of ancient software, well that wasn’t my fault — it’s part of their character, hardened and documented over decades of use.

The bad part about emulation is that you can’t easily change that free work. If I want to make a bug fix it’s a fairly complex affair and I would probably introduce a host of new bugs that I couldn’t even be sure weren’t there before my meddling.

Other Considerations (i.e. Lawyers)

From the beginning I knew I was walking on dangerous grounds with an emulator. Though emulation itself is protected, using copyrighted software (even if it’s very old) was never going to fly in a commercial product. The ROM images used to emulate the old Apple II+ weren’t mine to do as I pleased with, and though I had been in direct communication with Apple’s lawyers, no one there was very interested in figuring out how to properly license those relics. That’s fair enough, Apple is one of the biggest companies in the world and their lawyers have been quite busy with more pressing matters lately.

But even if BASIC and those old pieces of software had been perfect and free they still wouldn’t be well suited to my needs anymore. The game is mature enough to need something better so that players can get on with the business of programming their way to survival, not trying to figure out what Error #4 means.

Bad Ways To Do Good Things

How then do we modify a dusty piece of assembly language to make it behave as if it were privy to the last 40 years of computer advancements? At first I thought I could surgically make alterations within the code itself, in its native tongue. However, a BASIC interpreter running in machine code had to fit within about 8k of memory (between $D000-$F800 in this machine’s case). That’s a tall order even today with better technology. I could perhaps make that work, but I’d be spending far too much time in the endeavor and I probably would only get a handful of concessions from doing it that way, with some things on my wish list just too difficult to pull off. Not to mention, if I didn’t change enough I was still in legal peril.

Another approach would be to take some freeware solutions and try to cram those into the machine’s ROM instead. These versions, while free from copyright issues, were less tested and not made for where I wanted to place them. Again, I’d spend a lot of time trying to cram them into shape without necessarily getting everything I wanted.

So what’s left to me? Perhaps it’s time to cheat a little.

Guiding Principles

Throughout the course of the project I’ve wanted to keep it purely emulation. No shortcuts, no tricks, just real software running on a decent emulation of the real hardware. I’ve made a lot of choices and decisions to keep that goal possible, sometimes even painfully so. But the secret is that I knew, all along, that there would come a point where this had to end. I hewed to the goal as long as possible to get as close as possible, but dogged adherence was ultimately not going to serve the game well.

So it’s time to change tacks a bit.

How We’ll Cheat

If I want to get all the features I’d like, I’m going to have to do it myself. But that doesn’t mean I have to do it the way Woz did it all those decades ago. In computer terms, that’s eons! Now we have greatly superior technology for creating programs, technology I’ve cut my teeth and honed my skills on for quite some time. Let’s bring those to bear on this problem.

The only hitch is: they don’t know anything about this old machine and how to talk to it. Much like getting Unreal to talk to the emulator, I’ll need to find a way to bridge those two distinct periods of technological time. With Unreal I used methods that maintained the emulation, but now I’m going to bend the rules a little more.

Digital Zombie

I want the output of my programs to look like they’re running on the old computer, but I want the work to be done on a computer from this millennium. The simplest way to do this is to put the emulator into “zombie mode”. In this mode I render the video memory like normal, but I turn off the processor and stop it doing any work. I can then fool around with the video memory from the emulator and you’ll never know the difference. The nice thing about this approach is that I can also stuff values into other places in memory and then “resurrect” the machine and have it run again under its own volition. This means I can let the BASIC interpreter on the physical computer setup the virtual computer in any way it needs to, then pass control back to that virtual computer and return to the authentic world of 8-bit assembly language.

What About the Hardcore Among You?

Do you like it when backspace adds a garbage character instead of its namesake functionality?

Do you yearn for typing and retyping commands when typos occur?

Is hexadecimal conversion something that comes naturally to you?

Or perhaps you just want all the authentic, nostalgic pain that came with these old machines?

Never fear, I’m allowing it to stay (if you choose).

The emulator has been built from day one to allow arbitrary data injections into its ROM. These are specified in a script file that’s freely accessible in the content folder. So if you fancy blasting old ROM images or in fact any random data into the emulator’s ROM when it starts up, you’re free to do so.

“desc”: “Apple II+”,
“bellAddress”: “0xFBDD”,
“slots”:[{
“slot”: 6,
“bios”: “diskio.bin”
}],
“images”: [{
“bios”: “d000.bin”,
“address”: “0xd000”
},
{
“bios”: “d800.bin”,
“address”: “0xd800”
}]
...

If you wanted to capture the ROM from the Apple II sitting on your desk and place that into the emulator’s memory, it’ll function exactly like the hardware on your desk. But of course, you’ll need make sure you do it all legally…

Thoughts?

Anything to add? Be sure to write and let me know what you think. We’re nearly at 1,000 Steam Wishlist additions and growing every day!

--

--