Oldskooler Ramblings

the unlikely child born of the home computer wars

Back to the Future

Posted by Trixter on January 25, 2008

I couldn’t save my old XT keyboard (enter key died, and that’s pretty much the #1 most important key on the damn thing) so it has been tossed into the spare parts bin. My remaining keyboard, however, survived my pokings and I have a functional XT keyboard again. My last, but beggars can’t be choosers.

Thanks to a functional keyboard, I started working on MONOTONE again, starting with the interface (the design docs are done — yes, design docs — hey, stop laughing!) except that I was immediately sidelined by my custom keyboard handler.

A keyboard handler, for the uninitiated, is a little routine that “replaces” the “hold-key-down-and-watch-it-repeat-after-a-short-delay” behavior with “hold-key-down-and-it-stays-down-without-beeping-incessantly” behavior. This is good behavior, if you want to make your keyboard act like a piano. But my trusted old handler code locked up the machine after the first keypress.

Here is the code in question, which I had been using since 1994:

Procedure New9handler; Interrupt;
  b: Byte;
  port [$20] := $20; {send end-of-interrupt to PIC}
  b := port [$60];   {read scancode from keyboard}
  If b < 128
    Then kbd [b] := True
    Else kbd [b And 127] := False;

On keyboard interrupt, grab a friggin’ character and stuff it in a bitmask array. Easy as pie. Yet the XT locked up, so I am clearly doing something that the XT is allergic to (or, more likely, forgetting to do something). So now I get to research early XT keyboards/signals and try to figure out what I’m doing wrong. Luckily, I have a lot of programming books to consult; here are the ones I’m going to take to bed:

  • Compute’s Mapping the IBM PC and PCjr by Russ Davies
  • The Undocumented PC by Frank Van Gilluwe (founder of V Communications — thanks for Sourcer, Frank!)
  • Sam’s IBM PCjr Assembler Language by David C. Willen (why a PCjr-only book? Because eventually monotone will support PCjr — ssh, keep it a secret!)
  • Compute’s Beginner’s Guide to Machine Language on the IBM PC and PCjr by Christopher D. Metcalf and Marc. B. Sugiyama
  • Assembly Language Primer for the IBM PC & XT by Robert Lafore

Overkill, but I want to check them all so that I can get all the info on handling a keyboard interrupt and then pick out what I need.

I know all this seems stupid and unnecessary, and makes me seem like a freak, but honestly it is the reason over the years I have gravitated towards older and slower platforms to code for fun on. It’s the same reason people still code demos on the Commodore 64 and other legacy platforms: They are fixed in nature, which means you can truly discover the absolute fastest way to accomplish a particular task on them. It’s impossible to do this on a modern winbox, because winboxen are moving targets. It also explains perfectly why modern demos have evolved in the last decade the way they have, but that’s a topic for another day.

PS: The last book by Robert Lafore is the best book you can read to learn assembler on an IBM PC. It teaches you the basics by making you assemble, by hand, in DEBUG. It sounds incredibly scary and hardcore, but it’s actually very fun!

6 Responses to “Back to the Future”

  1. qkumba said

    When I started on the PC platform, all I had was DEBUG to write code. No assembler or compiler. It’s amazing that I got anything done. However, mentioning that to less devoted people elicits comments along the lines of “when I was younger, we didn’t have , we had tree bark”.
    I like the old days, and I still code sometimes for the Apple II.

  2. Matt Hite said

    Turbo Pascal… wow… that’s awesome you can still remember how to program in that. I can barely remember it now.

  3. Trixter said

    Turbo Pascal is the perfect environment to code on for an old machine. It produces efficient code, has a built-in debugger, a responsive editor… it’s really top notch. Turbo C is pretty good, but not as refined as Turbo Pascal.

  4. Matt Hite said

    Absolutely… I loved their IDE. And Pascal was kind of fun to program in…

  5. Some random guest not really named "Per" said

    what version of turbo pascal are you using?

    The very first IBM port of Tetris and a lot of other good programs where written in Turbo Pascal. (I have to learn it sometime :P)

  6. Trixter said

    Turbo Pascal 7.0 with a few enhancements (ie. I patched the CRT unit in the system.tpu that I use to not have the divide-by-zero bug)

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: