![]() |
#FILE: hardware.html
#REV: 1.1
#DATE: 01/06/95
#AUTHOR: Paul D. Burgin
#DISCLAIMER: All information provided as is etc.
#HISTORY: 1.0 22/02/94, 1.1 01/06/95
#XREF:
#SOURCE:
Dragon/Tandy Keyboard Map
=========================
This section describes how to read the Dragon or Tandy CoCo keyboard
at the hardware level. Using this technique simultaneous and continuous
keypresses can be detected.
Begin by writing a byte to $FF02 to specify which 'rows' of keys you want
to enable. A '0' in the specified bits means enabled, '1' means disabled.
Now read from $FF00 to check which 'columns' any pressed keys are in.
Each '0' bit means that the key specified in the table is currently
pressed, and '1' indicates keys not pressed.
| Tandy $FF00 Read
| B0 B1 B2 B3 B4 B5 B6
---+----------------------------
B0 | @ H P X 0 8 ENT
B1 | A I Q Y 1 9 CLR
B2 | B J R Z 2 : BRK
$FF02 Write B3 | C K S ^ 3 ;
B4 | D L T v 4 ,
B5 | E M U < 5 -
B6 | F N V > 6 .
B7 | G O W SPC 7 / SHF
---+----------------------------
| B2 B3 B4 B5 B0 B1 B6
| Dragon $FF00 Read
Notice that the 'columns' are swapped for the Tandy in comparison to the
the Dragon - hence if a Tandy game running on a Dragon asks you to press
the '1' key, you should press the 'Q' key!
The joystick file buttons are also connected to IO address $FF00, and are
always enabled. The right joystick button clears bit 0 if pressed, and
the left button clears bit 1. Bit 7 of $FF00 is also used by the joystick
hardware, for the comparator feedback.
Graphics Modes
==============
Excluding text and semi-graphics modes, there are a total of 56 graphics
modes available on the Dragon and Tandy CoCo!
Of these a sample of only 10 are available from BASIC, but by addressing the
SAM and VDG register directly access may be gained to all of the modes.
The table below lists the charactistics of the graphics modes. Each mode
is available in both colour (4 colour) and black/white (2 colour) variants,
as well as a choice of 2 palette options. To avoid clutter the table lists
only the distinct classes, and therefore contains 14 entries. These are
divided again into wide (chunky) variants and narrow (higher resolution)
variants.
++==============================================================++
|| VDG REGISTER ||
++------------------------------++------------------------------++
|| Wide Variant || Narrow Variant ||
++------------------------------++------------------------------++
|| Colour Mode: $80 || Colour Mode: $A0, $C0 or $E0 ||
|| B/W Mode: $90, $B0 or $D0 || B/W Mode: $F0 ||
++=======++=======+======+======+========++=======+======+======+========++
|| Video || Bytes | Line | Num. | Total || Bytes | Line | Num. | Total ||
|| Mode || Per | To | Of | Bytes || Per | To | Of | Bytes ||
|| Num. || Scan | Line | Horz | Video || Scan | Line | Horz | Video ||
|| || Line | Inc. | Line | Memory || Line | Inc. | Line | Memory ||
++-------++-------+------+------+--------++-------+------+------+--------++
|| 0 || 16 | 32 | 16 | 512 || 32 | 32 | 16 | 512 ||
++-------++-------+------+------+--------++-------+------+------+--------++
|| 1 || 16 | 16 | 64 | 1024 || 32 | 16 | 192 | 3072 ||
++-------++-------+------+------+--------++-------+------+------+--------++
|| 2 || 16 | 32 | 64 | 2048 || 32 | 32 | 64 | 2048 ||
++-------++-------+------+------+--------++-------+------+------+--------++
|| 3 || 16 | 16 | 96 | 1536 || 32 | * | 192 | 4608 ||
++-------++-------+------+------+--------++-------+------+------+--------++
|| 4 || 16 | 32 | 96 | 3072 || 32 | 32 | 96 | 3072 ||
++-------++-------+------+------+--------++-------+------+------+--------++
|| 5 & 7 || 16 | 16 | 192 | 3072 || 32 | 48 | 192 | 9216 ||
++-------++-------+------+------+--------++-------+------+------+--------++
|| 6 || 16 | 32 | 192 | 6144 || 32 | 32 | 192 | 6144 ||
++=======++=======+======+======+========++=======+======+======+========++
*Repeating pattern lasts two scan lines.
Even lines: (Increment 16)
Odd lines: (Increment 32)
In most cases,
'Line To Line Increment'
X
'Number Of Horizontal Lines'
=
'Total Bytes Video Memory'
Where the number of bytes per scan line is less than the line to line
address increment, video memory is skipped once the right hand screen edge
is reached. Where the bytes per scan line is greater, video memory is
actually repeated side-by-side on the screen to fill the necessary width.
Dragon/Tandy CoCo BASIC's PMODEs 3 and 4 are respectively the colour and B/W
variants of narrow video mode 6. PMODE 2 is the B/W wide variant of mode 5,
PMODE 1 is the colour narrow variant of mode 4, and PMODE 0 is the B/W wide
variant of mode 3.
Not many programs use the anonymous modes, especially those near the top of
the table, but some do. Defense, for instance, uses a B/W variant of mode 4,
the PMODE 1 mode, whilst Scarfman is happy to use a chunky colour variant of
mode 1! The mode numbers given on the info screen of PC-Dragon are the same
as those given in the above table, except with 8 added to the mode number
for narrow modes.
To set a given mode, use the table to determine the required mode number and
VDG register value. Add 8 to the VDG value if the second colour palette is
required. The VDG value should then be written to $FF22 (beware that you
should avoid altering bits 0 to 2 of this address).
The required mode number must now be presented to the SAM. Do this by
writing 8 bit values to addresses in the range $FFC0 to $FFC5. The actual
instruction used to do this is not important, but it is the addresses used
which determines the mode setting. The addresses are interpreted as follows:
$FFC0 Clear bit 0 of mode number.
$FFC1 Set bit 0 of mode number.
$FFC2 Clear bit 1 of mode number.
$FFC3 Set bit 1 of mode number.
$FFC4 Clear bit 2 of mode number.
$FFC5 Set bit 2 of mode number.
To set the screen base address, divide your required address by $200 and
then write to addresses in the range $FFC6 to $FFD3, building up the bits
to specify your value in same manner as above. There are 14 locations (7
bits) and therefore a base address up to $FE00 may be specified, however
some Dragons will not display any memory above $3FFF correctly.
The following is a short program to browse through all of the modes in the
table. A number of shapes with different characteristics are first drawn
onto the screen to allow for easier comparison.
10 'VIEW ALL 14 VDG MODE CLASSES
20 PMODE3: SCREEN1,0: PCLS: COLOR2
30 LINE(0,0)-(255,191),PSET,B
40 CIRCLE(127,96),60: PAINT(99,99),2,2
50 COLOR4: LINE(0,0)-(255,191),PSET
60 LINE(2,1)-(253,190),PSET,B
70 COLOR3: LINE(127,0)-(0,191),PSET
80 CLS: PRINT@194,"PRESS ANY KEY TO CHANGE MODE";
90 IFINKEY$="" THEN 90
100 POKE&HFFC7,0: FORI=0 TO 6
110 IF (I AND 1) THEN POKE&HFFC1,0 ELSE POKE&HFFC0,0
120 IF (I AND 2) THEN POKE&HFFC3,0 ELSE POKE&HFFC2,0
130 IF (I AND 4) THEN POKE&HFFC5,0 ELSE POKE&HFFC4,0
140 POKE&HFF22,&H80
150 IFINKEY$=""THEN 150
160 POKE&HFF22,&HA0
170 IFINKEY$=""THEN 170 ELSE NEXT