| MediaWiki:Sitenotice |
|---|
| 2026-03-12: Cocopedia.com is now using a new caching system that should make things faster. Please let me know if you encounter any new issues.
2026-03-15: MediaWiki has been reinstalled and the old database and files restored. It was pretty clogged up from being upgraded so many times since 2004. I am also testing out Cloudflare to see if it can prevent the 'bot assaults that took the site down last year. 2026-03-16: Special thanks to Don Barber for hosting a backup mirror of CoCopedia: https://cocopedia.dgb3.net |
PIA: Difference between revisions
m →Keyboard: These are columns, not rows. |
Expand details on connections. |
||
| Line 1: | Line 1: | ||
The '''Peripheral Interface Adapter''', formally the Motorola 6821, is a chip that provides two ports of parallel input and output plus control lines and interrupts. There are two in your CoCo, usually referred to as PIA0 and PIA1, and they're responsible for keyboard and joystick input, sound output and video mode selection and interrupt generation, amongst other tasks. | The '''Peripheral Interface Adapter''', formally the Motorola 6821, is a chip that provides two ports of parallel input and output plus control lines and interrupts. There are two in your CoCo, usually referred to as PIA0 and PIA1, and they're responsible for keyboard and joystick input, sound output and video mode selection and interrupt generation, amongst other tasks. | ||
== Connections == | |||
=== PIA0 === | |||
Port A: | |||
* b7: joystick comparison input; | |||
* b0–b6: keyboard rows (b0 = row 0); | |||
* b0 and b2: right joystick buttons (b0 = primary); | |||
* b1 and b3: left joystick buttons (b1 = primary) | |||
* CA1: the 6847's horizontal sync output; | |||
* CA2: LSB of the MUX selection. | |||
Since both keyboard rows and joystick buttons are connected to the low four bits, pressing joystick buttons can interfere with keyboard input. | |||
Port B: | |||
* b0–b7: keyboard column; | |||
* CB1: the 6847's field sync output; | |||
* CB2: MSB of the MUX selection. | |||
PIA0's interrupt output is connected to the 6847's IRQ input. | |||
=== PIA1 === | |||
Port A: | |||
* b2–b7: DAC output level; | |||
* b1: RS232 data output; | |||
* b0: tape input; | |||
* CA1: RS232 data carrier detect; | |||
* CA2: tape motor control. | |||
Port B: | |||
* b7: 6847 alpha/graphics selection (0 = alphanumeric); | |||
* b4–b6: 6847 graphics mode selection; | |||
* b3: 6847 colour set selection; | |||
* b2: RAM size; | |||
* b1: 1-bit sound output; | |||
* b0: RS232 data input; | |||
* CB1: cartridge interrupt input; | |||
* CB2: sound enable. | |||
Cartridges short one of the clock pins onto their interrupt pin, which feeds into CB1 and therefore pulses every clock cycle; this is used by the machine to detect cartridge presence. | |||
=== The MUX === | |||
The multiplexer selects both which joystick axis is enabled for comparison with the current DAC value and which source is currently selected for audio generation (if audio is enabled). | |||
=== Keyboard === | === Keyboard === | ||
The keyboard can be scanned through PIA0 via addresses $FF00 and $FF02. The first address ($FF00) represents keyboard rows as well as joystick buttons, and the second address ($FF02) keyboard columns; programs will normally set one of these as output and one of these as inputs, most normatively configuring $FF02 as output and using it to select which columns to scan and then reading $FF00 as input to very which rows on those selected columns had keys pressed. [[Color Basic]], when running a prompt, converts these to ASCII values to be printed to the screen at cursor position. | The keyboard can be scanned through PIA0 via addresses $FF00 (PIA0 port A data) and $FF02 (port B data). The first address ($FF00) represents keyboard rows as well as joystick buttons, and the second address ($FF02) keyboard columns; programs will normally set one of these as output and one of these as inputs, most normatively configuring $FF02 as output and using it to select which columns to scan and then reading $FF00 as input to very which rows on those selected columns had keys pressed. [[Color Basic]], when running a prompt, converts these to ASCII values to be printed to the screen at cursor position. | ||
These two value correspond to ASCII values according to the following table: | These two value correspond to ASCII values according to the following table: | ||
Latest revision as of 11:25, 18 May 2026
The Peripheral Interface Adapter, formally the Motorola 6821, is a chip that provides two ports of parallel input and output plus control lines and interrupts. There are two in your CoCo, usually referred to as PIA0 and PIA1, and they're responsible for keyboard and joystick input, sound output and video mode selection and interrupt generation, amongst other tasks.
Connections
PIA0
Port A:
- b7: joystick comparison input;
- b0–b6: keyboard rows (b0 = row 0);
- b0 and b2: right joystick buttons (b0 = primary);
- b1 and b3: left joystick buttons (b1 = primary)
- CA1: the 6847's horizontal sync output;
- CA2: LSB of the MUX selection.
Since both keyboard rows and joystick buttons are connected to the low four bits, pressing joystick buttons can interfere with keyboard input.
Port B:
- b0–b7: keyboard column;
- CB1: the 6847's field sync output;
- CB2: MSB of the MUX selection.
PIA0's interrupt output is connected to the 6847's IRQ input.
PIA1
Port A:
- b2–b7: DAC output level;
- b1: RS232 data output;
- b0: tape input;
- CA1: RS232 data carrier detect;
- CA2: tape motor control.
Port B:
- b7: 6847 alpha/graphics selection (0 = alphanumeric);
- b4–b6: 6847 graphics mode selection;
- b3: 6847 colour set selection;
- b2: RAM size;
- b1: 1-bit sound output;
- b0: RS232 data input;
- CB1: cartridge interrupt input;
- CB2: sound enable.
Cartridges short one of the clock pins onto their interrupt pin, which feeds into CB1 and therefore pulses every clock cycle; this is used by the machine to detect cartridge presence.
The MUX
The multiplexer selects both which joystick axis is enabled for comparison with the current DAC value and which source is currently selected for audio generation (if audio is enabled).
Keyboard
The keyboard can be scanned through PIA0 via addresses $FF00 (PIA0 port A data) and $FF02 (port B data). The first address ($FF00) represents keyboard rows as well as joystick buttons, and the second address ($FF02) keyboard columns; programs will normally set one of these as output and one of these as inputs, most normatively configuring $FF02 as output and using it to select which columns to scan and then reading $FF00 as input to very which rows on those selected columns had keys pressed. Color Basic, when running a prompt, converts these to ASCII values to be printed to the screen at cursor position.
These two value correspond to ASCII values according to the following table:
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | |
| 0 | @ | H | P | X | 0 | 8 | Enter | |
| 1 | A | I | Q | Y | 1 | 9 | Clear | |
| 2 | B | J | R | Z | 2 | : | Break | |
| 3 | C | K | S | Up | 3 | ; | ||
| 4 | D | L | T | Down | 4 | , | ||
| 5 | E | M | U | Left | 5 | - | ||
| 6 | F | N | V | Right | 6 | . | ||
| 7 | G | O | W | Space | 7 | / | Shift |
Keyboard layout is one of the few areas of hardware difference between a CoCo and a Dragon, other than video standard; the Dragon has the same physical layout as the CoCo but changes the column numbering — columns 6 and 7 are the same as the CoCo but everything else is off by 2. E.g. the CoCo's column 0 is the Dragon's column 2, the Coco's column 4 is the Dragon's column 6 and the CoCo's column 5 is the Dragon's column 0.
(under construction)