17

If you pressed one of the joystick buttons on the TRS-80 Color Computer while running BASIC, it would act as if @ABCDEFG were typed. Pressing the other joystick button would similarly type out HIJKLMNO. Why did the CoCo exhibit this behavior?

  • 5
    The C64 showed similar behaviour (for joystick in port 1 and for some directions only, IIRC). – dr01 Jun 20 at 11:53
30

On the Color Computer, I/O address &FF00 is used for both the joysticks and the keyboard row input. Bits 0/1 are toggled by the two joystick port buttons, and these bits are the same as rows 1/2 for the keyboard.

BASIC continually scans for keyboard input by looking at &FF00 (for the row) and &FF02 (for the column). Since &FF02 will not indicate a keypress, BASIC interprets the toggling of rows 1/2, caused by the joystick button, as pressing all 8 of the keys for all 8 columns.

7

The fewer kinds of input a computer has to deal with, the easier its life is. This applies equally to physical ports and to the provisions for input in the BIOS and operating system generally. Abolishing “joystick button input” as a separate category makes everything much simpler.

The same applies to function keys on keyboards (such as the arrow keys). Rather than sending unique, presumably non-ASCII characters of their own, they can send escape sequences just as if they had been typed.

There are two possible approaches. One is to make the buttons send a sequence of keystrokes which the user is unlikely to type, or unlikely to type that fast. The other is to make them programmable so that they send whatever they have been programmed to send. I don’t know which way your particular joystick was designed.

  • 5
    There's also a third approach, which is that taken by machines such as the ZX Spectrum: just give the joystick inputs a fixed mapping to existing keys and don't worry about it. Many was a time I would play games on my brother's +2 in joystick mode because then I definitely knew it was 6, 7, 8, 9 and 0 for controls, rather than bothering to try to guess what that game had picked. – Tommy Jun 19 at 19:41
  • 2
    This answer doesn't really make sense, as it stands. Yes, fewer kinds of input make for easier design – but this is actually an argument for keeping to a simple protocol where each key sends just one character, done. Having to interpret a couple of otherwise unassigned bytes in the input is easy, compared to parsing escape codes or even long key sequences (not to speak of the complexity of making keys programmable for output). The reason for resorting to escape-code hacks is usually backwards-compatibility with another system that made some assumption on what characters sent. – leftaroundabout Jun 21 at 13:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.