Sunday, January 10, 2016

MC-10 Familiarization

Programming retro computers is not rocket science. After all, it wasn't that long ago that teenagers and grade-schoolers regularly produced commercial-quality programs on these very machines! Nevertheless, a new machine always has some new idiosyncrasies and a few tricks to learn to make them useful. The MC-10 is no exception, and much of my time spent with that machine in the past week has been devoted to learning a few such tips and tricks...


Time Well Spent

I like to make use of "real time" sources to control events in my games. Hand-coded loops and cycle counting can be an effective soure of "real time" information, but they are fragile. Small changes in the game code can produce large timing differences than can be difficult to predict and painful to recode again and again. On the CoCo, I often use the vertical and horizontal sync signals as reliable sources of timing information. Unfortunately, the MC-10 makes no provision for accessing either sync source.

Fortunately, the Motorola 6803 CPU in the MC-10 has a little "secret" -- an internal timer! The timer functionality is based on counting elapsed CPU clock pulses, which amounts to a source of "real time" information. Using this timer I was able to replace the hand-coded timing loop in my screen flashing example program, unlocking the ability to accurately time game events.


Key Exercises

Moving along from timing, it should be obvious that a game needs some form of input to indicate what the player wants to do in the game. A joystick would seem like an obvious choice, but the MC-10 has no joystick ports. It does, however, have a keyboard. The MC-10 keyboard employs a reasonably standard switch matrix that the CPU controls by outputing a value at one location and reading back a value from another location. This is similar to how the keyboard is read on the CoCo and on any number of other systems.

Conversely, a game needs some form of output. Graphics are obvious, but a little audio can be a big plus. The MC-10 has no sound chip, and it does not even have the CoCo's DAC. However, it does have a 1-bit digital output for producing audio, similar to the Apple II or the ZX Spectrum. Producing audio on the MC-10 is reasonably simple, particularly with control of the timer. There is even a ROM call available for producing simple tones. One might be surprised at how much is possible with 1-bit audio, but simple tones will be more than enough for porting Xmas Rush.


Practice Porting

So with a few exercises under my belt, it is time to start porting. Since the MC-10 has the same Motorola 6847 video chip as the CoCo and can support all of the video modes used by Xmas Rush, there is practically no need to generate new graphic data for anything. I started by reproducing the "intro" and "tally" screens using the same data used in the CoCo version. I did change some of the text to reflect the use of the MC-10 keyboard rather than the (non-existent) joystick port. Incidentally, the Christmas tree graphic was produced using Simon Jonassen's web-based sgedit utility -- very handy!

Well, that is my little recap of this week's progress. I am pleased with my results so far! The biggest challenge has been figuring-out how to port 6809 code to it's poorer cousin, the 6803. Most of the Xmas Rush graphics data should remain intact, and most algorithms will be virtually the same (albeit written for the register-poor 6803). The biggest problem I forsee right now will be dealing with the single, fixed video buffer on the MC-10. I don't think that problem will be too tough, but there could be problems.  If you want to see how that goes, then you will just have to stay tuned!

No comments:

Post a Comment