Dragon Notebook

From The Dragon Archive
Jump to: navigation, search

Contents

INTRODUCTION

This Notebook is dedicated to 6809 programmers past, present and future and in particular to those whose work has contributed so much to unravelling the secrets of the DRAGON'S ROM.

The contents have been gleaned from many different sources over the years and to all contributors, known and unknown, we offer out heartfelt thanks.

The Editor's gnarled fingers were responsible for the typing of all the pages in this book using what he considers to be the best word processor for the 6809 computers, namely 'STYLOGRAPH' operating under OS9. The major drawback to using this method is that it is not possible to test any of the routines after they have been typed. Consequently, although dozens of mistakes have been spotted and corrected, it is inevitable that a goodly number will have been overlooked.

While every effort has been made to check the routines contained in the Notebook it has not been possible in every case. Should you become aware of mistakes in any of these subroutines, please write and let the Editor know, especially if you are able to put matters right. By the same token, if you know of any subroutine which would be of interest to your fellow members, please drop the Editor a line, and he will include it in any future edition. Of special interest would be short source code routines from DREAM or other assembler, because nothing teaches you better to program in machine code than examining experts routines.

The intention of this small publication was to give all our members as much information as possible about the Dragon and to a lesser extent the Tandy Coco. There are many members, new to computing, who have recently acquired a Dragon who are struggling to find information with which to augment the Basic Manual. We hope this Notebook will help them produce worthwhile programs, which they can share with us all through the pages of DRAGON UPDATE & UP2DATE.


Ray Smith, THE EDITOR

PEEKs, POKES and EXECs

WAIT for Keyboard input
DRAGON EXEC 34091 (COCO EXEC 44539)
Same as Q$=INKEY$:IF Q$="" THEN 10

HIGH SPEED POKE
POKE 65495,0
Doubles the processing speed from .89mhz to 1.7mhz - useful
for data processing and arithmetical functions, but
POTENTIALLY can be dangerous for your computer as it can
shorten the life of the chips.

POKE 65494,0
Returns computer to normal speed.
Use this poke before inputting or outputting any information
to tape or disk, if you are using the high speed poke.

POKE 65497,0
An even faster speed. Screen image is lost and should be
used with extreme caution with involved arithmetic
calculations only.

POKE 65496,0
Turns off above speed poke.

COLD START
POKE113,0
Produces a cold start whenever the RESET button is pressed.

WARM START
EXEC 40999 (COCO 46004)
Produces a warm start, but if used after the above poke,
will then produce an immediate cold start.

DISABLE LIST COMMAND
POKE 383,158
List command will produce garbage.
Also disables DIR command for disk
POKE&H180,PEEK(114):POKE&H180, PEEK(115)
Disables the List command when using disks only.

TRON/TROFF
POKE175,79
Turns on Trace flag - same as TRON
POKE175,0
Turns it off again - same as TROFF

GRAPHICS MODE
PEEK(182)
Returns present PMODE number.
Returns 0 if graphics not in use.

LOWER CASE CHARACTERS
Coco POKE 282,0. Dragon POKE 329,0
Text will be printed to screen in inverse video and to
printer in lower case.

UPPER CASE CHARACTERS
DRAGON POKE 329,255 (COCO POKE 282,255)
Turns off lower case flag and all text will be in Capitals.

PRINT DISK DIRECTORY
POKE 111,254:DIR
DEVN routine. Decides which device the text output is
directed to.
0=Screen. 255=tape. 254=printer.

TIMER VALUE
PEEK(274)*256+PEEK(275)
Gives the value of the timer.
POKE274,0 and POKE275,0 to return value of Timer to 0.

LAST KEY PRESSED
PEEK(135)
Gives the ASCII code of last key pressed in program.

LAST VARIABLE USED
PEEK(55) + PEEK(56)
Gives ASCII code of last variable used. Print CHR$ in front
of the command to get the STRING value of last variable
used.

PCLEAR0 for DISK
POKE25,PEEK(188):NEW
Will give you an SN error, but PCLEAR0 will have been
accomplished. Or alternatively:-
POWER UP:POKE25,14:POKE26,0:NEW
for the same thing.

PCLEAR0 for TAPE systems
POKE 25,6:NEW

MOTOR ON / MOTOR OFF
POKE 65313,4 for motor on.
POKE 65313,52 for motor off.

MACHINE CODE PROGRAM ADDRESSES
(a) For tape:
START: PEEK(487) * 256 + PEEK(488)
END: PEEK(126) * 256 + PEEK(127)-1
EXEC: PEEK(157) * 256 + PEEK(158)
(b) For disk: (Dragon only)
FOR X=1618 TO 1623 STEP 2: PRINT
PEEK(X) * 256 + PEEK(X+1);:NEXT
The resulting numbers will be:
START, LENGTH and EXEC.
To find END address, add START and LENGTH together and
deduct 1.

BASIC PROGRAM ADDRESSES
PEEK(25)*256+PEEK(26) - START
PEEK(31)*256+PEEK(32) - END

TEXT SCREEN - CURSOR POSITION
PEEK(136)*256+PEEK(137)
Shows a position somewhere between 1024(Start of screen) &
1535(end)

MAXIMUM MEMORY POINTER
PEEK(116)*256+PEEK(117)
Shows end of RAM

HIMEM
PEEK(39)*256+PEEK(40)
Shows place of protected memory, and is highest address for
basic.

CHARACTER TO TEXT SCREEN
POKE (1024-1535),(33-255)
Pokes a character or graphics block to the text screen.

CHARACTER/COLOR BLOCK to GRAPHIC
Applies to PMODE 1 and 2 only.
POKE (1536-4607),(33-255) for tape or POKE
(3072-6143),(33-255) disk.

DISKS
PEEK(235) for DRIVE number.
PEEK(236) for TRACK number.
PEEK(237) for SECTOR number.

TAPE FILENAME of file last loaded

FORX=474TO481:PRINTCHR$(PEEK(X));: NEXT
Prints filename of the last tape file loaded in string form.

TEXT TO SCREEN DISABLE

POKE359,255
After you use this Poke, nothing you type on the keyboard
appears on the screen. Whatever statement you type will be
executed, provided it does not require any text to be
printed on screen. In consequence you can type for example
SCREEN1,1 or PCLS or SOUND100,1 and these will be executed.
The DIR command will not work however, as it requires the
list of files to be printed on the screen. The LIST command
is also disabled.
Do not use this poke in your program if you require
statements to be printed on the screen.
POKE359,126 
Although this will not itself appear on the screen, it will
restore the text etc on screen to normal.

ORANGE TEXT SCREEN

POKE359,57
Lets you use any graphic screen or the text screen
(SCREEN0,1) without alternating back to the default text
screen. Consequently SCREEN0,1 will give you an orange
screen without switching back to the normal green screen.
Using SCREEN0,1 after this POKE will make your title screens
have more impact.
POKE359,126 to recover from above.

DRIVE NUMBER FOR DRAGONDOS

Although you can use the command DRIVE 1 (or 2,3 or 4) in
your program. You cannot use a variable (in Dragondos) and
so DRIVE X will produce an error.
You can however use POKE1546,DR where DR is the variable for
any Drive number in the range 1 to 4.

CURRENT LINE NUMBER

PEEK(104)*256+PEEK(105)

CURRENT DATA LINE NUMBER

PEEK(49)*256+PEEK(50)

DISK/TAPE CHECK

PEEK(188)
This returns a 6 if no disk  drive is installed for both Dragon
& the Coco. If a disk drive  is installed then a 14 is returned
for the Coco and a 12 for the Dragon.

Sound and graphics

SOUND - OCTAVE

PEEK(222)+1
Returns the current Octave in use.

SOUND - NOTE LENGTH

PEEK(225)
Notes can be any length from 1 to 255.

SOUND - CURRENT TEMPO

PEEK(226)
Tempo can be from 1 to 255.

GRAPHICS - COLORSET

PEEK(193)
Returns 8 if using Colorset 1 or 0 if using Colorset 0.

GRAPHICS - START BYTE

PEEK(186)*256+PEEK(187)
Returns start address at top of current Hi-res screen.

GRAPHICS - END BYTE

PEEK(183)*256+PEEK(184)
Returns end address  at  the  bottom  right  of  current hi-res
screen.

GRAPHICS - CIRCLE RADIUS

PEEK(207)*256+PEEK(208)
Returns the radius of a circle if drawn in PMODE4. Multiply the
number by 2 to get the radius of a circle in PMODE1 and 3.

GRAPHICS - CIRCLE CENTRE

(a) PEEK(203)*256+PEEK(204)
Returns the  centre  X  co-ordinate  of  a  circle  in  PMODE4,
Multiply by 2 for PMODES1 and 3.
(continued over)

(b) PEEK(205)*256+PEEK(206)
Returns the centre  Y  (vertical)  co-ordinate  of  a circle in
PMODE4, multiply by 2 for PMODES 1 and 3.

GRAPHICS - DRAW

(a) ANGLE PEEK(232)
Returns Draw angle from 0 to3.
(b) SCALE PEEK(233)
Returns scale number from 1 to 62

Other

CONTINUE after BREAK

PEEK(41)*256+PEEK(42)
Gives the line number at  which continuation should begin after
Break.

DISK DIRECTORY

COCO EXEC 52175
DRAGON EXEC 55868
Prints disk directory on screen, same as command DIR.

JOYSTICK - FIRE BUTTON

PEEK(65280)
COCO: Returns 253 or  125  for  LEFT  joystick  fire button and
254/126 if RIGHT joystick  button   pressed.  255  if no button
pressed and 257 if BOTH are pressed.
DRAGON:  returns  253/125   for   LEFT  joystick,254/126  Right
joystick, 255/127 if no button pressed and 252 for both.

TAPE: LOADING A HEADERLESS PROGRAM

MOTORON: EXEC &HB714
This should  load  in  a  program  which  has  been  saved, for
example, when the motor did not get  up to speed in time and so
you've got a program saved without a header.

TAPE: SLOW STARTING AUTOMATICS

If your tape recorder is  slow  to  start  when it receives the
signal, remove the remote jack and switch the motor on from the
program,   or   in   direct    mode   with   MOTORON:SOUND1,20:
CSAVE"PROGRAM". This is the method used  by Harvey Grey, and as
he says it never fails.

TAPE: MERGING TWO PROGRAMS

Have the two programs ready,  by  renumbering Program B so that
its line numbers start after those of Program A.
CLOAD"PROGRAMA":POKE25,PEEK(27):POKE26,PEEK(28)-2:
CLOAD"PROGRAMB":POKE25,30:POKE26,1
They should then have merged.

ERASE - ANY PROGRAM IN MEMORY

DRAGON EXEC 33815      COCO EXEC 44313
Erases any program - same as the NEW command

CUMANA DOS POKES

Addresses of the READ/WRITE routines in ROM.

00EB    Number of the active drive
00EE/F  Buffer address (for sector read/write)
00F6    If non-zero decrement 0605 in each IRQ
0605    When reaches zero turns off disk motor
0609    Verify flag: 0=Off else is On
060A    Drive number
0697/8  Auto current line number
0699/A  Auto increment
069B    Auto flag: 0=Off else is on
069C/D  Error GOTO - line number
069E    Error GOTO flag: 0=off else is on
069F/A0 ERL
06A1    ERR
E56D    Sector READ routine
E643    Sector WRITE routine

HELPFUL ROUTINES

RIGHT JUSTIFICATION ROUTINE

Where LL is the line length, and string to be justified is A$.

10 LL=51:P=51
20 DF=LL-LEN(A$):IF INSTR(A$,"")=0 THEN80
30 IF DF=0 THEN80
40 FOR J=P  TO1STEP-1:IF  MID$(A$,J,1)=""  THEN A$=LEFT$(A$,J)+
MID$(A$,J):DF=DF-1:GOTO60
50 NEXT
60 P=J-1:IF P<1 THEN P=LEN(A$)
70 GOTO30
80 RETURN

AND ANOTHER EXAMPLE

10 A$="This is just an example of a string"
20 A$=A$+""
30 LL=32:F=0:S=0:N=0:P=1:L=LEN(A$):B$=""
40 GOSUB180:GOSUB190:IF F=0 THEN70
50 S=S-P+F:P=F
60 IF P>=L THEN N=N+1:GOTO40
70 IF N=1 THEN210
80 P=1:GOSUB180
90 SP=LL-S-P-N+2
100 B$=B$+STRING$(P-1,32)
110 DS=INT(SP/(N-1)):MS=SP-(N-1)*DS:PA=1
120 GOSUB190:IF F=0 THEN200
130 B$=B$+MID$(A$,P,F-P):P=F
140 GOSUB180
150 IF SP=0 THEN B$=B$+" ":GOTO120
160 IF  PA>=MS  THEN B$=B$-STRING$(DS+2,32):SP=SP-DS-1:PA=PA+1:
GOTO120
170 B$=B$+STRING$(DS+1,32):SP=SP-DS:GOTO200
180 IF MID$(A$,P,1)=" " THEN P=P+1:GOTO180:ELSE
RETURN
190 F=INSTR(P,A$," "):RETURN
200 B$=LEFT$(B$,LL)
210 A$=B$:PRINT A$

DISK DRIVE NUMBERS IN PROGRAMS

You can use specified drive numbers in programs, using the command DRIVE n, where n is a number from 1 to 4; but you cannot specify a variable with this command. You can input a variable and use it as part of the READ/WRITE commands, as follows:

100 INPUT"drive number";D
110 FWRITE CHR$(48+D)+":FILENAME.DAT";variable list

Alternatively you can set the default drive to whatever number from 1 to 4 you specify, with a poke: eg POKE 235,D or POKE1546,D personally I always use the latter.

SELECTING MENU OPTIONS

Suppose the option required is in A$ and they are sequential, A, B, C etc, then:- ON ASC(A$-64) GOTO 100,200,300,etc. If they are NOT sequentioal, ie A,L,M,S,X etc

10 A$=INKEY$:IF A$="" THEN 10
20 ON INSTR(A$,"ALMSX etc")GOTO100,200,300 etc
30 PRINT"INVALID OPTION":GOTO10

INVERSE VIDEO

(A) Changing text screen to green on black. (D32 AND D64)

10 CLEAR200,32539
20 FORX=32540 TO 32635:READ A$
30 POKEX,VAL("&H"+A$):NEXT
40 FOR X=0TO127:PRINT@0,CHR$(X):POKEX+32627,PEEK(1024):NEXT
50
POKE359,126:POKE360,127:POKE361,28:POKE416,126:POKE417,127:POKE
418,109:CLS
60 DATA32,62,34,36,9E,88,81,8,26,D,8C,4,0,27,35,86,20,A7,84,A7,
82,26,15,81,D,26,4,8D,29,20,D,4D,2B,8,10,8E,7F,7D,A6,A6,88,40,
A7,80,9F,88,8C,5
70 DATA FF,23,11,8E,4,0,EC,88,20,ED,81,8C,5,E0,25,F6,9F,88,8D,
2,35,B6,86,20,A7,80,1F,10,C4,1F,26,F6,39,2F,1,39,35,10,8C,BA,62
,26,F8,C6,20,7E,BA,79

CLS WILL WORK OKAY, BUT CLEAR OR RESET WILL RESULT IN THE SCREEN REVERTING TO BLACK ON GREEN

(B) Green or orange on black for D64 only.

Enter 64 mode & run following basic program: This caters for CLS and RESET and sets to an orange screen if you enter SCREEN 0,1

10 POKE 59735,15
20 POKE 62659,32
30 POKE 63992,32
40 POKE 64423,32
50 POKE 64447,32
60 POKE 64470,8
70 POKE 64474,2
80 POKE 64475,128
90 POKE 64476,96
100 POKE 283,105
110 POKE 284,253

AUTO REPEAT ON THE D32

Although the D64 has autorepeat in the 64 mode, the D32 keyboard will auto repeat with the following subroutine:

10 POKE &HFF04,(PEEK(&HFF03)AND &HFE)
20 POKE &H10D,&HBF:POKE &H10E,&H20
30 POKE &HFF03,(PEEK(&HFF03)OR 1)

DREAM

To make it easier to save source code to tape, as the header used in Dream is too short for some recorders which have trouble getting up to speed in time.

POKE 29788,215:POKE 29789,145

This lengthens the header tone, but slows up the recording slightly.

IF THIS STILL DOES NOT WORK, TRY THE FOLLOWING: EXIT from Dream with BREAK/Q and when in Basic type the following:

CSAVEM"FILENAME",PEEK(&H5F8A)*256+PEEK(&H5F8B),&H6000,&H6080

Press PLAY & RECORD on Cassette recorder and then PRESS ENTER. To RELOAD into Dream:

a) Load Dream but don't EXEC.
b) CLOAD"FILENAME"
c) EXEC
d) Reply 'Y' to 'Old text?' prompt.

STRINGS

When you use temporary variables in programs, such as X$=INKEY$, use the same variables over and over again, otherwise you can get an OS (out of string space error). You can force a Garbage collection by using EXEC36055. This makes the computer sort out the string space.

FILEMASTER

When you wish to update a file and save it with the same name, the program justs tags the updated file on the end of the old file, rather than killing the old file first. You can get over this problem by changing the following lines in OLDFILE.

3640 MN$+NM$+"DAT":KILL MN$:FWRITE NM$;RL
8005 GOTO 3640

By adding the following line, the number of each record can be printed:

5587 PRINT#DV,R(LN)+1

LLISTINGS

To printout listings in the same width as the Dragon screen (ie 32 characters per line) - POKE &H148,0:POKE &H9B,32:LLIST

BASIC ADDRESSES

START ADDRESS: STADR=PEEK(25)*256+PEEK(26) END ADDRESS: ENADR=PEEK(27)*256+PEEK(28)-1

,CE 1

DISK FILES

ASCII TEXT FILES
Last byte is always "1A".

BASIC FILES
DRAGON - Start with a 9 byte header
        1) 55(hex)
        2) File type 01 Basic etc, 02 M/code
        3/4) Load Address
        5/6)Length of program ie length of file less 9 header bytes.
        7/8) Exec address  -put  into  &H9D/9E  to tell basic where to start execution
        9) AA(hex)
        Bytes 1 & 9 are used by Basic to identify the header, otherwise the DOS assumes its a DATA file.
        End with 3 NULL bytes - 00,00,00

NON-SEGMENTED M/L FILES
DRAGON - as for basic above.
COCO - Start with a 5 byte header.
        a) Null byte 00
        b) 2 bytes  which  specify  number  of  data bytes in program -ie length in Hex
        c) 2 bytes which specify start (LOAD) address
 - End with a 5 byte tail sequence.
        a) FF byte
        b) 2 null bytes 00,00
        c) 2 bytes which specify EXEC address
- Note - the End  address  is  not  stored, but is calculated
from LOAD address plus file length minus 1.

SEGMENTED M/L FILES
COCO - Same as for  non-segmented  files,  but  at the end of
every segment they have ANOTHER  header  and so on. They only
have one END sequence and ONE EXEC address.

TO SAVE GRAPHICS TO TAPE OR DISK

If you do not know the address of the page in use you can save the currently displayed graphic page in any PMODE with the following:-

(C)SAVE(M)"FILENAME",PEEK(186) *
256+PEEK(187),PEEK(183) * 256 + PEEK(184),33649

AUTOREPEATING KEYS FOR THE D32

FOR X=337 TO 345: POKE X,255: NEXT: X$=INKEY$

COLD START

A Cold Start can be forced by POKE 113,0 and pressing RESET

PAUSE

EXEC 41194 can be used on the D32 and the D64 in 32 mode to pause a program, eg following a page of instructions. Pressing any key restarts the program.

INVERTING GRAPHICS PAGES

This short machine code subroutine will invert the first four pages of the graphic screens. That is change the foreground colour to the background colour and vice versa. To operate EXEC&H6000 or EXEC 24576.

110 FOR X=24576 to 24595
120 READ A$:POKE X,VAL("&H"+A$): NEXT X
130 DATA 8E, 06,00,A6,84,88,FF,A7,84,30,01,8C,1E,00,27,03,7E,
60,03,39

The Data underlined refer to the addresses of the start and end of the first four graphic pages, when using cassette. If you are using DISKS then replace with 0C,00 and 24,00.

RESCUE OPERATION

Sometimes when using a mixture of BASIC and M/code routines you can cause a crash when the Dragon freezes. The only option being to press RESET. On occasions after pressing RESET and typing LIST, all you get are the first few lines of the BASIC program followed by garbled lines. To get your program back simply type RENUM. You will be unable to RUN it, but you can SAVE it and reload after a COLD START.

THREE COLOUR PMODE4

10 PMODE3,1:SCREEN1,1:POKE 65314,248 This line tells BASIC that the four colour mode is required, but the POKE tells the VIDEO chip that 2 colour high resolution is wanted. The new colour set has 0 = WHITE, 1 = BLACK and 2 = LIGHT PURPLE

DISABLE BREAK KEY

Enter the following Pokes in DIRECT mode: POKE 411,228: POKE412,203: POKE 413,4: POKE 414,237: POKE 415,228 THEN to DISABLE POKE 410,236 And to ENABLE POKE 410,57

SLOW DOWN LIST

POKE 359,60 - This effects everything that is OUTPUT including PRINTING. POKE 359,57 for NORMAL SPEED.

EASY MOVING GRAPHICS

First DRAW the shape you want and put it in a STRING variable, eg C$. Then assign a couple of variables re the LOCATION and DRAW your shape at the desired location.

10 PMODE4,1:SCREEN1,1:PCLS
20 C$="D6F4H4G4E4U3R3L6R3U3R1D1L2U1R1"
30 X=128:Y=96
40 DRAW"BM"+STR$(X)+","+STR$(Y)+C$
and to move the man, change line 30 as follows
30 FOR X=10 TO 250 STEP 4: Y=96
50 PCLS:NEXT X
60 EXEC34091        (to hold graphics in view)

CLEAR SCREEN IN M/CODE

(A) by using existing ROM routine:
    LDB #$60
    JSR 47737
    RTS
(b) this is the faster way:
     LDX #$0400
     LDU #$0600
LOOP STU ,X++
     BNE LOOP
     RTS

PRINTER LINE FEED

If your Printer does not give an automatic line feed, or if its been turned off for OS9, STYLO etc. POKE330,2 and POKE 330,1 to turn it off again.

PRINTER FIELD WIDTH

To alter the comma field width (default 16), POKE 153, with the new field and POKE 154 with the last field. Eg: For 6 fields of length 10, POKE 153,10: POKE154,50 Useful for printing columns, but dont use the value 0,which makes the Printer hang!

GRAPHICS - HIDING SCREENS

You can hide Graphics Screens behind Loading Screens, providing you DIM correctly.

PMODE 0     DIM 307 per screen
PMODE 1 & 2 DIM 614 per screen
PMODE 3 & 4 DIM 1228 per screen

GET(0,0)-(255,191),A,B,C etc and PUT back when required.

TEXT IN M/CODE PROGRAMS

To check for text in long machine code programs, eg Adventures etc, to look for clues? FOR X=0 TO &H7FFF:PRINT CHR$(PEEK(X));: NEXT

INCREASE MEMORY AVAILABLE

To increase memory available to the maximum when using DISKS, ie to perform a PCLEAR 0 - No graphic pages. COCO: POKE 25,14: POKE 3584,0: NEW DRAGON: POKE 25,12:POKE3072,0: NEW This gives 28967 available bytes of memory

To increase memory when not using disks - POKE 25,6: NEW before loading cassette

GRAPHICS PAGES - ADDRESSES

To find START and END addresses of Graphic Pages in use:-

PRINT PEEK(186)*256+PEEK(187) - for the START
PRINT PEEK(183)*256+PEEK(184) - for the END

PRINTER - TO AVOID HANG UPS

Insert the following line in your program to ensure that your printer is on line, so that the program will not 'hang'. P=PEEK(65314) AND 1: IF P=1 THEN PRINT"PRINTER NOT ON LINE"

PRINTER - PARAMETER SETTING

Characters per line PEEK(155) - Default 132 To alter to 80 or even 40 etc POKE 328,0: POKE 155,80 or whatever.

DRIVE NUMBER

Some Dragons will allow you to use DRIVE and the number in programs, but if you get an error, use POKE&H60,2 or number.

BAUD RATE CODE

This short subroutine will fill in the array with the baud rate associated with the array index:

DIM BD(15)
FOR X=1 to 15: READ BD(X):NEXT
DATA
50,75,110,135,150,300,600,1200,1800,2400,3600,4800,7200,9600

DATA TROUBLE

When using HEX loaders etc, to find the line number of the last DATA statement loaded: PRINT PEEK(49)*256+PEEK(50)

AWAIT KEYPRESS

If two keypresses are required then EXEC41184 (otherwise EXEC34091)

KEYBOARD DISABLE

(A) POKE 65281,50 (B) POKE 65301,0 AND POKE 65301,20 TO ENABLE AGAIN (from the program!)

RESET - TO DISABLE - POKE 113,85

GRAPHICS (Colour)

(a) Striped effects -
    Poke 178,N:LINE(X,Y)-(X1,Y1),PSET,BF
(b) Foreground colour - PEEK (178)
(c) Background colour - PEEK (179)
(d) Active colour     - PEEK (180)
(e) Graphic Mode      - PEEK (181/2)

TEXT SCREEN

(a) Move to lower half of screen - POKE 136,5
(b) Move to upper half of screen - POKE 136,4
(c) Cursor position in Low-res   - PEEK (136/7)
(d) ASCII code of last keypress  - PEEK (135)

CURSOR - TO REDEFINE

POKE 363,(ASCII code of required character):
POKE 364,167:
POKE 365,159: POKE 366,0: POKE 367,136

To ACTIVATE above - POKE 362,134 and to DEACTIVATE POKE362,57

CASSETTE - HIGH SPEED MODE RESCUE

If you accidentally CSAVE a program while in the High Speed mode then load it back at normal speed then: POKE 146,8: POKE 147,4: POKE 148,8

BREAK - TO DISABLE

To turn the BREAK key on and off within a program, use this subroutine:

10 CLEAR 300, 32735
20 FOR X = 32736 TO 32756
30 READ A$: A=VAL("&H"+A$)
40 POKE X,A: NEXT
50 POKE 411,127: POKE 412,224
60 PRINT"BREAK DISABLED": POKE 410,126
70 FOR DL=1 TO 2500:NEXT
80 CLS: PRINT "BREAK ENABLED": POKE 410,57
90 FOR DL=1 TO 2500: NEXT: GOTO60
100 DATA
32,62,1C,AF,BD,80,06,26,07,81,13,26,03,7E,85,2B,
97,87,7E,84,A6

OR AN EVEN SHORTER ROUTINE:

10 FOR X=&HF8 TO &HFE: READ A: POKE X,A:NEXT
20 FOR X=&H19A TO &H19C: READ A: POKE X,A: NEXT
30 DATA 50,98,28,175,126,173,165
40 DATA 126,0,248

NOTE: These routines do not work during INPUT lines.

BREAK - TO DISABLE INCLUDING INPUT LINES

This short M/code subroutine will disable the BREAK key, including during INPUT lines.

10 CLEAR 200, 32550
20 FOR X-0 TO 55: READ A$: POKE32551+X,VAL("&H"+A$): NEXT
30 DATA 8E,7F,3C,BF,01,6B,8E,7F,54,BF,01,9B,86,7E,B7,01
        6A,B7,01,9A,39,0D,6F,27,01,39,32,62,34,14,BD,80
        09,BD,80,06,27,F8,81,03,27,F4,7E,B5,42,9F,DF,35
        10,30,04,34,10,9E,DF,39
40 EXEC 32551

TELEWRITER

For those who have the Cassette version, you can change the colour set and have a green on black screen by POKE &H2FDF,240 before loading.

PRINT - VARY OUTPUT TO SCREEN OR PRINTER

100 INPUT"OUTPUT TO GO TO SCREEN OR PRINTER"; A$
110 A$=LEFT$(A$,1)
120 IF A$="S" THEN P=0:GOTO(Screen Print routine at 150 etc
using PRINT#P)
130 IF A$="P" THEN P= -2 ELSE GOTO100
140 PRINT#P,(Your Printer routine)

CONVERT HEX/DECIMAL/HEX

Let the DRAGON (a) work it out: DECIMAL/HEX  ? HEX$(n)

      HEX/DECIMAL   ? VAL(&Hetc)
              (b) add them for you ? HEX$(&H0A+&HFF)

DISPLAY

To change the TEXT screen from GREEN to ORANGE, in order to highlight instructions etc - POKE 65314,13

LOOPS

Use FOR/NEXT loops in preference to GOTO for Speed and Efficiency.

CENTERING A TITLE

CLS: PRINT TAB((X-LEN(A$))/2)A$ Where A$ is the Title and X is the number of characters per screen line/printer line.

CASSETTES

To load a headerless program - MOTORON: EXEC 46868

WAIT FOR KEYPRESS

If you use EXEC 34091, The Key pressed can be read from the A Register. EXEC 34091: X$= INKEY$: PRINT X$ or get value of X$ with Y=ASC(X$)-48 (for numbers 1 to 9)

CASSETTE LOADING

To resurrect programs accidentally saved at the faster speed (POKE 65495,0). Load the program back using the double speed poke. AUDIO ON: POKE65497,0: CLOAD You lose video at this speed and so the Audio is on to tell you when the tape has finished loading. Press RESET and try listing program. If the DRAGON does not return to normal mode POKE 65495,126 and then list. The program sometimes unfortunately is not recoverable.

DISKS AND THE DRAGON 64

(A) DETACH DOS

Unplug your DOS using Software instead of manually unplugging the cartridge and risking damaging the connections.

1 CLS7:PCLEAR4
2 POKE1541,2
3 FOR X=0 TO 146:POKE3073+X,PEEK(46010+X):NEXT
4 POKE 3072,18:POKE3197,0
5 FOR X=1 TO 3: READ S,F:  FOR J=S TO F: READ A$
6 POKE 3072+J,VAL("&H"+A$)
7 NEXT J,X
8 DATA 148,156,8E,0C,9C,BD,90,E5,7E,83,71,157,188
9 DATA 44,4F,53,20,44,45,54,41,43,48,20,28,43,29,20,31,
       39,38,35,20,44,52,41,47,4F,4E,20,55,53,45,52,00
10 DATA 13,17,8E,7F,FE,20,0E
11 POKE 114,12:POKE 115,0
12 PRINT@224,STRING$(32,236);
13 PRINT@256,"  PRESS RESET TO DETACH DOS  "
14 PRINT@288,STRING$(32,227);
15 SCREEN 0,1
16 GOTO16

TO 'UNPLUG' DOS, RUN PROGRAM and press RESET on cue. TO REGAIN DOS, POKE 113,0 and press RESET.

(B) MOVING BASIC AND DOS TO HIGH MEMORY

Enabling DISKS to be used in the D64 mode and giving a further 8k available for program storage from 57344 onwards. M/code source - assemble in DREAM etc.

        ORCC    #255    Disable IRQ's
        LDX     #32768  Start of Basic
LOOP    STA     $FFDE   ROM mode
        LDA     ,X      Get byte from ROM
        STA     $FFDF   RAM mode
        STA     ,X+     Store in RAM
        CMPX    #57344  All copied
        BLO     LOOP    No Branch again
        ANDCC   #255-16 Enable IRQ's
        RTS             Return to Basic in 64k mode

This produces through DREAM the following Data:

1 CLEAR 600
2 FOR A=1 to 18
3 SREAD 1,16,A,A$,B$
4 SWRITE 1,20,A,A$,B$
5 NEXT

If that doesn't accomplish it, which means that Track 16 was also corrupted, then hard luck! You'll either have to reformat the disk or rebuild the Directory Track, using a DISK FIXIT type program. Try Pam D'Arcy's program 'DISKFIX' from the NDUG.

(D) CARTRIDGE INTERFACE

ODD number lines are on the UPPER side and are all GROUND. EVEN numbered lines are on the LOWER side. Looking down on the Cartridge Edge connector the pins run from 2 to 34, from right to left.

        2
        4
        6
        8   INDEX
        10  DRIVE 0
        12  DRIVE 1
        14
        16  MOTOR
        18  DIRECTION
        20 STEP
        22  WRITE DATA
        24  WRITE GATE
        26  TRACK 0
        28  WRITE PROTECT
        30  READ DATA
        32  SIDE 1
        34  READY - Not connected in Dragondos

(E) DISK - TO PRINT DIRECTORY

POKE 111,254:DIR

(F) DISK - DELTADOS

This POKE allows long BASIC programs to be run without OM errors. LOAD program and if it does not contain a CLEAR statement, insert at the beginning of the program:- POKE 377,57: CLEAR 200, &H7FFF Otherwise just insert the POKE on its own. NOW SAVE TO DISK and then RUN. If the DOS space was not overwritten when the program was run, then the DOS can be RE-ENABLED with POKE 377,126:CLEAR 200,&H78FF.

GRAPHICS - FINDING CO-ORDINATES

To convert PMODE4 co-ordinates (X,Y) to PRINT ` positions on the TEXT screen: P=INT(X/8)+32*INT(Y/12): PRINT P: PRINT@P,"*";

LIST

(A) TO SLOW DOWN

The more common method but NOT TO BE USED WITH DOS OR ANY CARTRIDGE in place. POKE 359,19 and if still too fast POKE 360,19 also. RESET by poking a value of 57 to both locations.

(B) TO DISABLE

POKE 383,157: POKE 383,158 To re-enable POKE 383,126

Program loading tricks

FINDING ADDRESS OF M/CODE PROGRAM

PRINT PEEK(487)*256+PEEK(458)  ......(A)
PRINT PEEK(126)*256+PEEK(127)-1 .....(B)
PRINT PEEK(157)*256+PEEK(158)  ......(C)
SAVE OR CSAVEM"PROGRAM", A, B, C

TO DISABLE AUTORUN PROGRAMS

CLOADM"PROGRAM", 1298 CSAVEM"PROGRAM", A+1298, B+1298, C+1298

TO RELOCATE MACHINE CODE PROGRAMS

(A) ON DISK - LOAD "PROGRAM.BIN", n (B) ON TAPE - CLOADM"PROGRAM", n Where 'n' is the offset, found by subtracting the old address from the new address, providing the new address is higher than the original address. If the new address is below the original address than the value of 'n' = 65536 plus new address less original address.

TAPE LOADING DIFFICULTIES

Before saving to cassette:

        POKE &H745B,255: POKE144,1   To  raise  output signal level
        POKE144,3: POKE 144,0 to return to default setting.
        POKE &H746b,128 for a longer header.
               (or try values between 1 & 255)
        POKE 65313,8   Motor on
        POKE 65313,247 Motor off
        EXEC &H8015    Turns on Cassette relay
        EXEC &H8018    Turns it off

ARROW KEYS

Checking that one of the four arrow keys has been used:

10 IF INKEY$=CHR$(8) OR CHR$(21) THEN GOTO...(LEFT ARROW)
20 IF INKEY$=CHR$(9) OR CHR$(93) THEN GOTO...(RIGHT ARROW)
30 IF INKEY$=CHR$(10)OR CHR$(91) THEN GOTO...(DOWN ARROW)
40 IF INKEY$=CHR$(94)OR CHR$(95) THEN GOTO...(UP ARROW)

The second CHR$ character is SHIFT plus the ARROW key.

GRAPHICS - HINTS and ROUTINES

OVERLAYING ONE SCREEN ON ANOTHER

The basic method is to PCLEAR8 and load one screen into Page 1 and the other into Page 5 (using Hi-res screens, then GET the picture and PUT it over the Page 1 screen.

10 PCLEAR8 20 PMODE4,1:SCREEN1,1:PCLS 30 LOAD "PICTURE1.EXT" 'for disk 35 CLOADM"PICTURE1" 'for tape 40 PMODE4,5:SCREEN1,1:PCLS 50 LOAD"PICTURE2.EXT",9216 'or 55 CLOADM"PICTURE2",6144 'tape 60 DIM A(160):GET(0,0) - (255,191),A,G 70 PMODE4,1:PUT(0,0)-(255,191),A,AND 80 GOTO80

(FOR PMODE3 SCREENS USE 'OR' IN LINE 70 INSTEAD OF 'AND'.)


EXTRA PAGES ON DRAGON 32

These extra pages are Pages 17 to 20 and work on the D32, but not apparently on the D64. On the latter machine pages can be stored in high memory. PCLEAR8 PMODE4,1:SCREEn1,1 (C)LOAD(M)"PICTURE1"(.EXT") FORX=1TO4:PCOPY X TO X+4:NEXT (I.E.) Put it into Page 5 on. (C)LOAD(M)"PICTURE2"(.EXT") FORX=1TO4:PCOPY X TO X+16:NEXT (C)LOAD(M)"PICTURE3"(.EXT") You should now have 3 pictures in memory and to see them .... EXEC41194 'Picture 3 visible FORX=1TO4:PCOPY X+16 TO X:NEXT EXEC41194 'Picture 2 on screen FORX=1TO4:PCOPY X+4 TO X:NEXT EXEC41194 'Picture 1 is back!

DRAW COMMAND

The Draw command always starts by fixing a point on screen from which to draw and this point can be defined by variables. This command usually reads: DRAW"BM"+STR$(X)+","+STR$(Y) etc and most people tend to leave out that comma. The DRAGON will perform the same function using the simpler: DRAW"BM=X;=Y;" etc Where X is the horizontal and Y is the vertical co-ordinate in pixels.

You can MOVE your graphic by simply putting the co-ordinates in a loop.

HI-RES SCREEN FLIPPER

This Basic sub-routine will flip the screen upside down. 10 DIM A(10),B(10) 20 PMODE4,1:SCREEN1,1 30 FORX=0TO95:GET(0,X)-(255,X),A ,G:GET(0,191-X)-(255,191-X),B,G 40 PUT(0,X)-(255,X),B,PSET: PUT (0,191-X)-(255,191-X),A,PSET 50 NEXT 60 EXEC41194

GET/PUT: SIZE OF DIM REQUIRED

Count the number of bytes used in your graphics. There are 1536 per graphics page, or 6144 in a PMODE3 or PMODE4 4 page screen, but only 3072 in PMODEs 1 and 2. So take this number and divide by 20 for the odd PMODEs (1 & 3) and divide by 40 for the even modes (2 & 4) then subtract one. The result is the length of the one dimensional array required to store the picture. The same applies to portions of a screen. For example half the entire PMODE4 screen (3072 pixels) would require a DIM of : (3072/40)-1 or 76


SCREEN ADDRESSES (GRAPHICS)

These depend whether you are using a disk operating system, as most DOS use the first page of graphics and so with DOS in place graphics start one page higher.

Page Tape Disk 1 &H0600-&H0BFF &H0C00-&H11FF 2 &H0C00-&H11FF &H1200-&H17FF 3 &H1200-&H17FF &H1800-&H1DFF 4 &H1800-&H1DFF &H1E00-&H23FF 5 &H1E00-&H23FF &H2400-&H29FF 6 &H2300-&H29FF &H2A00-&H2FFF 7 &H2A00-&H2FFF &H3000-&H35FF 8 &H3000-&H35FF &H3600-&H3BFF

To save and load screens to tape use the above scale as follows for PMODE4 for example: CSAVEM"FILE",&H600,&H1DFF,&H0600 or in decimal this would be: CSAVEM"FILE",1536,7679,1536 CLOADM"PIX"

But to save screens to disk you need to save one more byte, else the byte in the bottom right hand cormer of the screen will not be saved. Eg:- SAVE"FILE",&HC00,&H2400,&HC00 which will save it to the default extension ".BIN", but if you wish to distinguish your graphic screens from machine code programs save them with an extension such as ".PIX". In decimal this would be: SAVE"FILE.PIX",3072,9216,3072. (Superdos 9215)

DEBUGGING HINTS

FC (Function Call) errors

These usually occur in the GET, PUT, DRAW, PLAY and LINE commands. An FC error usually means that you are asking one of these commands to do something they cannot do, and the most likely causes are: (a) Co-ordinates out of range. For example horizontal and vertical must be positive with horizontal less than 256 and vertical less than 192. (b) Dimensions of PUT command may be more than the GET statement. (c) Execution of a string with an illegal character in it. For example DRAW"BM100,100;XL$(2);" - where there is nothing wrong with the DRAW command as such - but on looking back at XL$(2) you find this = "D2L2P2" - in other words it contains an illegal character in it, ie "P2". (d) The most common causes of this error are not necessarily found in the line in question, but you should look back at the definition of the individual components.

OD (Out of data) errors

These occur as a rule when you:- (a) repeat or omit data statements (b) or you write or copy hexloader addresses wrongly.

PRINT PEEK(49)*256+PEEK(50) will give you the line number of the current DATA statement. PRINT PEEK(51)*256+PEEK(52) will give you the address of the next item in the current Data statement.

PAINT errors

Paint errors can be catastrophic in graphics, when the paint spreads everywhere and while an error is NOT reported, it figures that you will not be too happy with the mess it causes! If you don't know which particular PAINT command is the trouble, find where the previous SCREEN command is situated (say line 100) and put a GOTO100 before each PAINT command until you locate the one at fault. Then check the co-ordinates and colour codes for validity, the co-ordinates must be INSIDE the area you wish to paint. If this should fail then check the lines where that particular graphic shape was formulated and ensure that the outline is completely closed off. Check for a one pixel gap in the outline somewhere.

USR Routines

A well known bug in the ROM of the Dragon 32 means that the USR command must contain a zero before each numbered USR function, but this was corrected in the Dragon 64 and the zero in that machine causes an error. No zero in the 32, or a zero in the 64, both show an error. The following routine inserted in your programs will circumvent this and will ensure the program should run on both machines.

5 VS$=CHR$(PEEK(49052) + PEEK(49053)) 'TO TEST WHETHER
DRAGON 32 OR 64
6 IF VS$="64" THEN DEF USR1=30000 ELSE DEF USR01=30000

where 30000 can be any address...... and then later in the program...

IF VS$="64" THEN X=USR1(A) ELSE X=USR01(A)

BS Bad Subscript errors

These usually occur when the subscripts in an array are out of range. Use a DIM statement to dimension the array. For example, if you have X$(12) in your program but you have not informed the computer of the 12 elements by the use of the DIM command. Remember you are not required to use the DIM command UNLESS you plan to use more than 10 subscripts. When you use DIM(11) you are planning on using 12 subscripts as the DIM count starts with zero.

DD Attempt to redimension an array.

Be careful where you put the DIM statement in your program, because if the program returns to the line in which you have placed the DIM statement, you will get this error. Make sure in planning your program that the initialisation process, of which the DIM statement may be an essential part, occurs at the beginning and the program does not regress.

DS Direct statement

Can occur because there is a direct statement in a data file, perhaps by loading an ASCII file which has 'lost' a line number. Files loaded off Bulletin Boards were prone to this error.

FM Bad file mode

If you have both double and single drives you may be prone to this error, or use a mix of single and double sided disks on your drives. The reason is that if you use a single sided disk in a double sided drive, the DOS reads the disk on startup or reset and expects the same type of disk in that drive, so when you put a double sided disk in the drive it is reading from Sector 18 to Sector 1 and doesn't recognise that the program continues on Sector 19 etc. The solution is to press the RESET button. Of course if you've got single sided drives and you're attempting to read a double sided disk, you'll get this error and there's nothing you can do about it!

NE File non-existent

The Computer can't find the file you want. If you've got more than one drive you may have omitted to prefix the filename with the drive number and a colon. or in the case of the Coco placed these AFTER the filename. e.g. Dragon - LOAD"2:FILENAME

    Coco   - LOAD"FILENAME:1

Although the numbers are different, in both cases you are loading the file from Drive 2. This error also occurs if you are using the COPY, KILL or RENAME commands and omit the extension.

NF NEXT without FOR

This occurs when the command NEXT is used without a matching FOR. Sometimes occurs through bad programming practice such as jumping into loops. Often occurs when the NEXT commands are reversed in nested loops. As programs are increased in speed by NOT using the variable with NEXT (ie NEXT X), the variable is unnecessary; the computer knows which variable to use, even if you've forgotten!

TF Too many open

Files that is. One of the easiest errors to fall into, when you go from using Coco disk drives to the Dragon. The Coco keeps track of its files differently to the Dragon reserving buffer space etc. You dont have to keep closing Coco files, but it is good practice to do so on the Dragon. There are 19 fonts in the DESKTOP program and in order to copy these to another disk, I often wrote a short little program to copy from 1 to 19 fonts. This would grind to a halt with this error after copying 10 fonts, if a CLOSE command was not included.

UL Undefined line

Occurs when a GOTO or a GOSUB is used with a line number that is not in the program. When you are using hybrid programs which are a mix of Basic and machine code routines, this error may be the first indication that your program has crashed. The program is possibly trying to jump to a line near the end of the program, but when you list it you find you've lost the end of your program. You can sometimes RESCUE it by using the RENUM command and although it won't Run, you can save it and when reloaded it will probably run.

DATA

Most mistakes occur when you type in programs from magazines etc, through the misreading of 8 and B in machine code, or by using an O in Hex notation instead of an 0. An the reverse is the case in music notation using an 0 in mistake for the O for the octave. Programmers who use an I or an O for a variable are asking you to fall in the trap and type a 1 or an 0. They are so difficult to spot if you go wrong. Especially if you get an FC error which refers to a string some lines back.

Remember Murphy's Law, "If you don't want it to happen it probably will". I remember one program of Pam D'Arcy's that I had on tape in the days when I first purchased a disk drive. It was called TAPESCAN or SCANTAPE and as its name implies, used to scan through a tape and tell you what was on the tape and if the program was in machine code, what the relevent addresses were. In those days, I was always leaving a disk in the drive (a bad practice which I don't recommend to anyone). Anyway, every time I used TAPESCAN it did a grand job on my tape, but it wiped the disk directory and replaced it with gobbledegook. It used to drive me mad, but it taught me to never leave disks in the drive.

GRAPHIC MODES of the DRAGON and COCO

NOTE - Modes 3 to 9 are not supported by Basic, but can be poked and used in your programs. One such program was called 'Semigraphics 24' and was written by A C Daniel, it appeared in Dragon User magazine August 1985.

MODE 1 Standard text screen 32 x 16 bytes (512)

MODE 2 Semigraphic 4 SET/RESET as above screen.
       Same as Alphanumeric screen above and is
       supported by basic. Element size 64 x 32.

MODE 3 (not supported by Basic)

       Semigraphic 6  Element size 64 x 48
       512 bytes - 4 colours per colour set.
       SELECT with the following:-
       A=PEEK(65314):POKE65314,AAND7+16+C
       Where C=0 or C=8 for Colorset 0 or 1.
       POKE65476,0:POKE65474,0:POKE65472,0

MODE 4 (not supported by Basic

       Semigraphics 8 - Element size 64 X 64
       2048 bytes - 8 colours - Border black
       SELECT with the following:-
       A=PEEK(65314):POKE65314,(A AND 7)
       POKE65475,0:POKE65475,1:POKE65472,0

MODE 5 (not supported by Basic)

       Semigraphics 12 - Element size 64 x 96
       3072 bytes - 8 colours - Black border
       SELECT with the following:-
       A=PEEK(65314):POKE65314,(A AND 7)
       POKE65477,1:POKE65474,0:POKE65472,0

MODE 6 not supported by Basic)

       Semigraphics 24 - Element size 64 x 192
       6144 bytes - 8 colours - Black border
       SELECT with the following:-
       A=PEEK65314):POKE65314,(A AND 7)
       POKE65477,1:POKE65475,1:POKE65472,0

NOTE - In the Semigraphic 8 colour modes, the colours are set with the MSB which ALWAYS has bit 7 set (1) and the rest of the MSB (ie bits 6,5 &4) are set for the colours as follows:

       000 GREEN        001 YELLOW
       010 BLUE         011 RED
       100 BUFF         101 CYAN
       110 MAGENTA      111 RED

MODE 7 (not supported by Basic)

       64 X 64 GRAPHICS - FOUR COLOUR
       Select with -
       A=PEEK(65314):POKE65314,(AAND7)+128+C
       Where C=0 for Colour set 0
             c=8 for Colour set 1
       POKE65473,1:POKE65474,0:POKE65476,0
       Uses 1024 bytes. To START see end of section.

MODE 8 (not supported by Basic)

       128 x 64 TWO COLOURS
       Select with -
       A=PEEK(65314):POKE65314,(AAND7)+128+16+C
       WHERE C=0 OR C=8 FOR COLOUR SETS 0 OR 1.
       POKE65473,1:POKE65474,0:POKE65476,0
       AGAIN USES 1024 BYTES. TO START SEE END.

MODE 9 (AGAIN NOT SUPPORTED)

       128 X 64 FOUR COLOURS
       Select with -
       A=PEEK(65314):POKE65314,(AAND7)+128+32+C
       WHERE C=0 OF C=8 FOR COLOUR SETS 0 OR 1.
       POKE65472,0:POKE65475,0:POKE65476,1
       Uses 2048 bytes.

MODE10 is PMODE0 - 1536 bytes - 2 colour

MODE11 is PMODE1 - 3072 bytes - 4 colour

MODE12 is PMODE2 - 3072 bytes - 2 colour

MODE13 is PMODE3 - 6144 bytes - 4 colour

MODE14 is PMODE4 - 6144 bytes - 2 colour

BIBLIOGRAPHY

The Major work regarding Graphics is William Barden's COLOR COMPUTER GRAPHICS published by TANDY (now out of print in this country). He describes bit mapping for all the non supported modes. Although intended for the TANDY COCO, it also applies to the Dragon, which uses the same SAM chip.

Other books, if you can find them, are:

ADVANCED SOUND AND GRAPHICS by Keith and Steven Brain - published by SUNSHINE Books.

PROGRAMMING THE DRAGON for GAMES & GRAPHICS by Geoff Phillips - published by McGRAW-HILL

INSIDE THE DRAGON by Duncan Smeed & Ian Sommerville - published by ADDISON-WESLEY. Chapter 7 applies.

DRAGON 32 PROGRAMMER'S REFERENCE GUIDE by John Vander Reydon - published by MELBOURNE HOUSE.

MEMORY MAP

DRAGON 32 and 64 in 32 mode

    0 -  1023  0000 - 03FF      SYSTEM USE
 1024 -  1535  0400 - 05FF      TEXT SCREEN
 1536 -  3071  0600 - 0BFF      GRAPHICS: PAGE 1
 3072 -  4607  0C00 - 11FF                PAGE 2
 4608 -  6143  1200 - 17FF                PAGE 3
 6144 -  7679  1800 - 1DFF                PAGE 4
 7680 -  9215  1E00 - 23FF                PAGE 5
 9216 - 10751  2400 - 29FF                PAGE 6
10752 - 12287  2A00 - 2FFF                PAGE 7
12288 - 13823  3000 - 35FF                PAGE 8
13824 - 32767  3600 - 7FFF      PROGRAM USE
32768 - 49151  8000 - BFFF      BASIC ROM
49152 - 65279  C000 - FEFF      CARTRIDGE USE
65280 - 65535  FF00 - FFFF      INPUT/OUTPUT

PLEASE NOTE: With disks in use, the Disk work space occupies the first page of graphics (1536 to 3071) and in consequence Graphics screens are moved up one page, starting at 3072 (&H0C00) and ending at 15359 (&H3BFF). On start up the Dragon does a PCLEAR4 and in consequence the memory available for program use starts at 7680, or 9216 with the DOS Controller in place.

DRAGON 64 in 64 MODE.

Same as above, except the BASIC ROM is moved from 32768 (&H8000) to 49152 (&HC000), which gives a substantial increase in memory available for program use, but means that disks cannot be used as the ROM overlays the Cartridge area. Programs exist to overcome this problem however.

13824 - 49151  3600 - BFFF      PROGRAM USE
49152 - 65279  C000 - FEFF      BASIC ROM
65280 - 65375  FF00 - FF5F      INPUT/OUTPUT
65376 - 65503  FF60 - FFDF      SAM CONTROL BITS
65504 - 65535  FFE0 - FFFF      MPU VECTORS


NOTE

The following pages contain details of the Dragon's memory, both the Basic work pages and the Basic ROM. While every effort has been made to ensure the accuracy of these details, the Editor has had to rely on a number of sources and it has not been possible to check them all. Where possible details have also been given of the Tandy Coco2 equivalent, making it possible for the conversion of programs from American sources. In so doing you are reminded that the Coco disk system differs greatly from Dragondos and is closer to the cassette system in the way that it handles data files. One other major difference is the way that graphic binary files are stored, they are usually 512 bytes higher in memory than Dragon graphics.

MEMORY MAP DETAILS

0       0       BREAK message flag
1       1       STRING delimiting character
2       2       Another delimiting character
3       3       General counter
4       4       Count of IF's seen looking for ELSE
5       5       DIM flag
6       6       VARIABLE type flag 0=numeric 255=string
7       7       Garbage collection flag
8       8       Subscript allowed flag
9       9       INPUT/READ flag
10      A       Arithmetic use
11)     B)      String pointer - first free temporary
12)     C)
13)     D)      String pointer - last used temporory
15-24   E-18    Temporary results
25/26   19/1A   Start address of Basic program
27/28   1B/1C   Start address of simple variables table
                see D User 1/86 p38 for details of
                variables.
29/30   1D/1E   Start address of ARRAY table
31/32   1F/20   End of storage (last byte used by Basic)
33/34   21/22   Top of Stack. ((Stack grows down)
35/36   23/24   Top of free STRING space. By subtracting the
                contents of 33/34 you get free string space
37/38   25/26   Pointer to STRING in string space
39/40   27/28   Top of RAM available to Basic
41/42   29/2A   Line number used in 'CONT' command
43/44   2B/2C   Temp G.P. line number store
45/46   2D/2E   Pointer to statement to be executed
47/48   2F/30   Direct mode command text pointer
49/50   31/32   Current DATA statement line number
51/52   33/34   Address of next item in current data sta'nt
53/54   35/36   Address of keyboard input buffer
55/56   37/38   Pointer to VARIABLE last in use
57/58   39/3A   VARPTR address of variable last in use
59/78   3B/4E   Evaluation variables
65/66   41/42   High end destination address for block move
67/68   43/44   High end origin address
69/70   45/46   Low end destination address
71/72   47/48   Low end origin address
79/84   4F/54   Floating Point Accumulator: No 1
79      4F      Exponent )
80/83   50/53   Mantissa ) Details of FPA
84      54      Sign     )
85      55      Temporary sign of FAC
86      56      String variable length
92/97   5C/61   Floating Pt Acc No 2: details as before
98      62      Sign comparison
99      63      Extended precision byte-Coco
104/105 68/69   Current line number (65535 in direct mode)
106     6A      VDU Comma field width (default 16)
107     6B      VDU Last Comma field (screen width - above)
108     6C      VDU Current column number (0 - 31)
109     6D      VDU Line width. No of characters per line
110     6E      Cassette I/O flag. Set FF on input incurring
111     6F      DEVN: re text output: 0=VDU 255=tape 254=prt
112     70      Cassette EOF flag: EOF reached if non zero
113     71      Restart flag. If<>$55 - cold start on reset
114/115 72/73   Restart vector. If flag=$55 & vector points
                points to a NOP then warm start else
                a cold start.
116/117 74/75   Physical end of RAM
120     78      Cassette status:0=closed 1=input 2=output
121     79      I/O buffer size
122/3   7A/B    Header buffer address:where f'name block is
124     7C      Cassette block type:
                0=f'name block 1=data block 255=EOF marker b
125     7D      BLKLEN:Cass Block length:Bytes to read/write
126/7   7E/F    Cassette I/O buffer address
128     80      Used internally to calculate the checksum
129     81      I/O error code 1=CRC 2=attempt load into RAM
130/2   82/4    Temp store used by COS
133     85      Last sine value
134     86      Data for Lo-res SET/RESET routine
135     87      ASCII code of last key pressed
136/7   88/89   Current VDU cursor address (ie screen pos)
138/9   8A/B    G.P. (16 bit) scratch pad
140     8C      Sound pitch value (frequency)
141/2   8D/E    GP Countdown facility (?duration of sound)
143     8F      Cursor Flash Counter
144/5   90/1    Cassette leader byte count (number of &H55s)
146     92      Min Cycle width of 1200HZ - Init=12
147     93      Min Pulse width of 1200HZ - Init=0A
148     94      Max pulse width of 1200HZ - Init=12
149/50  95/6    Dragon - Motor on delay
                Coco - Serial printer Baud rate constant
                HEX    Msb  Lsb (decimal) Baud
                       149  150
                02EB     2  235             75
                01CA     1  202            120
                0173     1  115            150
                00BE     0  180            300
                0057     0   87            600 (default)
                0028     0   41           1200
                0012     0   18           2400
                0006     0    6           4800
                0001     0    1           9600
151/2   97/8    Keyboard Scan Delay constant: Init=&H045E
153     99      Printer Comma Field Width: Default 16
154     9A      Printer Last Comma Field
155     9B      Printer Line Width: Set this to width 80?
156     9C      Printer Head Column:same as POS(-2) in basic
157/8   9D/E    Exec Entry address
159/170 9F/AA   Self modifying routine which reads next char
166/7   A6/7    Address of current sig byte - next char pntr
171/4   AB/E    Used by RND command
175     AF      TRON/TROFF flag: Non zero - trace on
176/7   B0/1    Address os start of USR address table
178     B2      Current foreground colour
179     B3      Current Background colour
180     B4      Temp colour in use
181     B5      Byte value for current colour: ie bits set
182     B6      Graphics PMODE number in use.
183/4   B7/8    Address of LAST byte of current graphics
185     B9      Number of bytes per line in current PMODE
186/7   BA/B    Address of FIRST byte: current graphics disp
188     BC      Start of graphics pages (MSB) defaults to 06
                Changed to 0C by Dragondos
189/90  BD/E    Current X Cursor position (not available
191/2   BF/C0   Current Y Cursor position (n.a.)
193     C1      Colour Set currently in use
194     C2      Plot/Unplot flag:0=Reset, Non-zero=Set
195/96  C3/4    Current Horizontal Pixel number
197/8   C5/6    Current Vertical Pixel number
199/200 C7/C8   Current X cursor co-ordinate
201/2   C9/CA   Current Y cursor co-ordinate
203/4   CB/CC   Circle command X co-ordinate
205/6   CD/CE   Circle command Y co-ordinate
207/8   CF/D0   RENUMber increment value
209/10  D1/2    RENUMber Start line (original number)
211/2   D3/4    CLOADM: 2's complement load offset value
213/4   D5/6    RENUMber New Start line (new number)
215     D7      Editor line length - not user available
216/221 D8/DD   Graphics use
222     DE      Current octave in use (0 - 4)
223/4   DF/E0   Volume data for volume setting in PLAY
225     E1      Current note length in PLAY
226     E2      Current TEMPO for PLAY command
227/8   E3/4    Music duration count
229     E5      Music dotted note flag
230     E6      Coco - Baud rate constant
231     E7      Coco - Input timeout constant
232     E8      Current ANGLE used in DRAW routine
233     E9      Current SCALE used in DRAW routine
234     EA      Disk operation code-what operation specified
235     EB      Disk Drive number(1 - 4) Coco(1 - 3)
236     EC      Disk read/write TRACK number
237     ED      Disk read/write SECTOR number
238/9   EE/F    Disk read/write Sector Buffer address
240     F0      Disk Error Status byte (Convt to DDOS code)
241     F1      Disk File Control Block number (1 - 10)
242     F2      Number of bytes in Disk buffer area
243     F3      No of bytes to transfer to/from buffer
244     F4      Number of SIDES/TRACKS for current drive
                00=1 side 40 tracks     01=2 sides 40 tracks
                FF=1 side 80 tracks     FE=2 sides 80 tracks
                The FORMAT of a disk is taken from the last
                few bytes of Sector 1 of Track 20 in Drogon
                DOS, on first access of disk after switch on
                or RESET.
245     F5      File Read/write flag
                0=read, 1=write & FF=verify
246     F6      Disk I/O in progress flag
256/8   100/2   SWI3 JUMP VECTOR - called from &HFFF2
                Execution of a SWI3 instruction of &H113F
                will stack Registers and jump here
259/61  103/5   SWI2 JUMP VECTOR - called from &HFFF4
                Execution of a SWI2 instruction of &H103F
                will stack registers and jump here
262/4   106/8   SWI1 JUMP  VECTOR - called from &HFFFA -&H3F
                will stack registers and jump here
265/7   109/B   NMI JUMP VECTOR -non-maskable interrupt
                called from &HFFFC, set to &H7ED7AE JUMPD7AE
                by initialisation of disk operating system
                in the Coco. Okay for Dragon?
268/70  10C/E   IRQ JUMP SECTOR - Interrupt request called
                from &HFFF8. Set to &H7EA9B3 to initialise
                Basic, Set to &H7E894C for initialisation of
                extended Basic or set to &H7ED7BC for the
                initialisation of DOS in the Coco.
271/3   10F/111 FIRQ JUMP VECTOR - Fast interrupt request
                called from &HFFF6, set to &H7EA0F6 by the
                initialisation of Basic and causes a jump to
                the Cartridge Port in the Coco.
274/6   112/4   In Coco this is EXEC of USR basic function
274/5   112/3   Timer - current value of system timer
                In both Dragon and Coco (double function)
277/81  115/9   Random number seeds used in RND function
282/7   11A/F   Unused in Dragon
282     11A     Coco - Caps lock 1=lock 0=unlock (lower case
283/4   11B/C   Coco - keyboard delay constant
285/7   11D/F   Coco - Vector to 45509 (JUMP $8489)
288     120     Number of Basic commands (reserved words)
289/90  121/2   Address of list of Basic commands
291/2   123/4   Address of Command Despatch Table
293     125     Number of Basic functions
294/5   126/7   Address of list of Basic functions
296/7   128/9   Address of Function Despatch Table
298/307 12A/133 As for 288 to 297, but in Dragon refers to
                Disk commands and functions, but in the Coco
                to Extended Basic commands and functions.
308/317 134/13D These addresses as above re COCO disks.
308/327 134/147 DRAGON - USR Table (20 bytes 2 each USR)
                This USR table is switched to 1667 to 1686,
                or Hex 683 to 696 when DOS is connected and
                is replaced with Disk Stub3 which acts as a
                terminator.
328     148     PRINTER AUTO LF/CR Flag
329     149     Dragon - Caps Lock flag:non zero=upper case
330     14A     Number of chars in end of line sequence(1-4)
331/4   14B/E   End of Line Characters: Set to CR/LF/NUL/NUL
                This sequence is sent to printer when a
                carriage return is output.
336/45  150/9   Dragon Keyboard 'Roll-over' table
338/45  152/9   Coco Keyboard 'Roll-over' table

DRAGON/COCO KEYBOARD ROLLOVER TABLE

                        Response:
 Address    191    223   239   247   251   253   254
Dec  Hex   D   C   D  C  D  C  D  C  D  C  D  C  D  C
338  152  ENT ENT  X  8  P  0  H  X  @  P  8  H  0  @
339  153  CLR CLR  Y  9  Q  1  I  Y  A  Q  8  I  1  A
340  154  BRK BRK  Z  :  R  2  J  Z  B  R  :  J  2  B
341  155              ;  S  3  K     C  S  ;  K  3  C
342  156              ,  T  4  L     D  T  ,  L  4  D
343  157              -  U  5  M     E  U  -  M  5  E
344  158              .  V  6  N     F  V  .  N  6  F
345  159          SPC /  W  7  O SPC G  W  /  O  7  G

RESPONSE IS 255 OR &HFF IF NO KEY IS PRESSED

346     15A     Right Joystick(0) - X value
347     15B     Right Joystick(1) - Y value
348     15C     Left Joystick (2) - X value
349     15D     Left Joystick (3) - Y value

350 to 424 15E to 1A8   RAM HOOKS (each 3 bytes)
350/2   15E/160 Device Open- called just before OPEN command
353/5   161/3   Device Number-called when a DEVN is verified
356/8   164/6   Device Initialisation- called before setting
                up the Device parameters in Loctn 106 to 109
359/61  167/9   OUTPUT CHAR TO DEVN:called just before out-
                putting char in A Reg to DEVN
362/4   16A/C   INPUT CHAR FROM DEVN: called just before
                inputting a char from DEVN into A Register
365/7   16D/F   INPUT FILE: called just before inputting a
                file using INPUT
368/70  170/2   OUTPUT FILE: called just before outputting
                to a file using PRINT
371/3   173/5   CLOSE ALL FILES: called before all files are
                closed, action only taken if Cassette open
374/6   176/8   CLOSE FILE: called before device is CLOSED
                action only taken if DEVN is -1 (tape)
377/9   179/B   COMMAND INTERPRETER: called before interpret
                of token in A Reg as command, used by Delta
380/2   17C/E   RE-REQUEST INPUT. Called before requesting
                more data from keyboard- ie before ?? prompt
383/5   17F/181 CHECK KEYS. Called before keyboard scanned
                for BREAK and SHIFT/@. Keyboard not scanned
                if DEVN is -1.
386/8   182/4   LINE INPUT FILE. Called before Line Input is
                executed on current DEVN
389/91  185/7   CLOSE FILE & COMMAND. Called before closing
                an ASCII file just read in as a Basic prog'm
                by CLOAD & returning to COMMAND mode.
392/4   188/A   CHECK EOF. Called before checking for EOF
                for current DEVN
395/7   18B/D   EVALUATE EXPRESSION. (obvious)
398/400 18E/190 USER ERROR TRAP. Can be patched by the user,
                that is in Basic, to trap error messages.
401/3   191/3   SYSTEM ERROR TRAP. Can be patched by the
                'system', ie Basic extension ROMs to trap
                errors (used by Dragondos)
404/6   194/6   RUN LINK. Called when RUN command is about
                to be executed. Patched by DDOS to allow a
                disk filename to be specified.
407/9   197/9   RESET BASIC MEMORY. Called from two routines
                in ROM before Basic Memory vectors are
                changed, ie by entering or editing lines,
                running programs etc.
410/2   19A/C   GET NEXT COMMAND. Called before reading in
                the next Basic command to be executed while
                program is running.
413/5   19D/F   ASSIGN STRING VARIABLE. (obvious)
416/8   1A0/2   SCREEN ACCESS. Called before the CLS,GET and
                PUT commands are executed.
419/21  1A3/5   TOKENISE LINE. Called before an ASCII line
                is tokenised in internal Basic format
422/4   1A6/8   DETOKENISE LINE. Called before a Tokenised
                line is converted to ASCII characters
425/464 or 1A9/1D0  STRING BUFFER AREA
465     1D1     Cassette filename length
466/73  1D2/9   Cassette filename to search for/or write out
474/728 or 1DA/2D8  CASSETTE FILE DATA BUFFER
                Area of memory used to load filename block &
                ASCII data blocks - if this contains a file-
                name block then this can be peeked (474-488)
474/81  1DA/1E1 Cassette filename (in buffer)
482     1E2     File type: 0=token basic 1=ASCII 2=binary
483     1E3     ASCII flag: 0=binary, non-zero=ASCII files.
484     1E4     Gap flag: 1=continuous, 255(FF)=gapped files
485/6   1E5/6   Execution address of machine code file
487/8   1E7/8   Load address of ungapped machine code file
729/33  2D9/C   Basic line input buffer preamble
734/984 2DD/3D8 Basic line input buffer
985/1002 3D9/EA BUFFER space
1003/20 3EB/3FC Unused
1021/2  3FD/E   End of line delay - RS 232 port on D64
1023    3FF     D64 RS 232 port Baud rate controller port
1024)   400)    TEXT SCREEN
1535)   5FF)         Default area.

The Coco Buffer areas are slightly different: 733/988 2DD/3DC 255 byte Keyboard buffer 737/827 2E1/33B 90 byte Screen buffer

The Disk Work area is from 1536 to 3071, or &H0600 to &H0BFF Otherwise if disks are not installed these addresses are in respect of the first of the Graphic pages, but with the DOS installed the Graphics page 1 starts at 3072 (&H0C00).

DRAGONDOS WORK SPACE

1536    0600    Start of Disk work space or Graphics Page 1
                when Disk cartridge not installed
1541    0605    Countdown to Disk motor off: Off when zero
1544    0608    Auto Verify ON/OFF: 0=off else checks sector
1546    060A    Current Default drive No. Used when no Drive
                number is specified in the command
1549/50 060D/E  Auto command line number in use
1551/2  060F/10 Auto command increment value
1553    0611    Program LOAD/RUN flag: 0=Load else Load/RUN
1555    0613    Auto command ON/OFF flag: 0=off else Auto on
1556    0614    Error command ON/OFF flag: 0=off else ERR on
1557/8  0615/6  ERROR trap line number: Basic line error rtn
1559/60 0617/8  ERL: line number of last error
1561    0619    ERR: Error code of last basic error
1562/3  061A/B  Address of start of statement in error
1564/9  061C/21 Drive 1 details
1570/5  0622/7  Drive 2 details
1576/81 0628/D  Drive 3 details
1582/7  062E/33 Drive 4 details
1588)   0634)   Disk Buffers 1 to 4 details, 7 bytes each
1615)   064F)
1616/66 0650/82 Current Drive information
1618/9  0652/3  Start address of program loaded
1620/1  1654/5  Length of program loaded
1622/3  1656/7  Entry (EXEC) address of M/code program
1667/86 1683/96 USR Vector table: relocated from 308-327(dec
1687 to 1706)   Disk Drive Parameter table
0697 to 06AA)   4 bytes per parameter - 1 for each drive
1687/90 0697/A  On Line Flag: Non zero means dive on line
1691/4  069B/E  Current Track, if Drive on line
1695/8  069F/A2 Head Stepping rate: This should only be
                changed if slower drives are used.
1699/702
        06A3/6  Disk Tracks on each drive
1703/6  06A7/A  Disk Sectors per track on each drive
1707/24 06AB/BC Directory Sector status
1725/2034       File Control Blocks: 10 in all: One for each
        6BD/7F2 open file: Each FCB 32 bytes long
2035/47 7F3/F   Temporary variables
2048/3071      )Disk Buffers: 4 in all, each 256 bytes long
        800/BFF)

3072    0C00    Start of Graphic Page 1 when disks in place
                otherwise start of Graphic Page 2 for tapes.

BASIC INTERPRETER CODES

32768   8000    Hardware initialisation
32771   8003    Software initialisation
32774   8006    POLCAT:Keyboard input:put into Register A
32777   8009    Cursor Blink
32780   800C    CHROUT:Write character in Reg A to screen
32783   800F    Writes out character in Reg A to printer
32786   8012    Joystick input:stored in addresses 346/9 dec
32789   8015    Cassette on
32792   8018    Cassette off
32795   801B    Write leader to cassette (or A00C)
32798   801E    Output byte from Reg A to cassette
32801   8021    CSRDON:Cassette on, prepare for reading
32804   8024    Input one byte from cassette to Register A
32807   8027    Gets one bit in from cassette into carry
32810   802A    Reads in a byte from another computer
32813   802D    Sends a byte to another computer
32816   8030    Select Baud rate of communications line

From here on the Coco equivalents are given in brackets and only a few Hex addresses will be given

33604  (44102)  SYSERR: Generates appropriate action for
                Error code in B Reg
33649  (44147)  CMDMODE: prints OK prompt & returns to the
                command mode
33773  (44271)  BASVECT2: complete initialisation process
                after Basic program loaded
33815  (44313)  NEW Basic:removes current Basic program from
                memory, resets stack & clears variables
33823  (44321)  BASVECT1: Sets up various necessary vectors,
                once a Basic program has been loaded
33844  (44339)  RESETS STACK: Resets stack to initial pos'tn
                all entries are lost
33951  (44446)  RUN BASIC: runs a basic program in memory,
                used to AUTORUN programs
34091   851B    (44539) WAIT KEY: waits for a key press, and
                when key pressed puts it in A Register
34935  (45382)  GET EXPR: routine will evaluate & put VARPTR
                address of following expression into 82/83
34951  (45398)  GET STRG: compiles a string and puts it into
                free string space
35236  (45671)  CKCLBRAK: as for CKCOMA, but checks for a
                closed bracket
35239  (45674)  CKOPBRAK: as for above, but checks for an
                open bracket
35242  (45677)  CKCOMA: Checks to see next significant char
                in command line is a comma, and if not it
                produces a SYNTAX error
35244  (45679)  CKCHAR: as for CKCOMA, but checks for char
                in B Register
35476  (45911)  GETVAR: Get VARPTR address of the follwing
                variable's name
35625  (46057)  GETUSR: Returns value of the argument in the
                USR function as 16 bit number in D register
35632           INTCNV: pass parameters to M/code routine
35641           GIVABF:used to pass values from M/C to Basic
35893  (46322)  ASSIGN-16-BIT:assigns value in D Register to
                a numeric variable
35894  (46323)  ASSIGN-8-BIT:assigns value in B register to
                a numeric variable
36055  (46481)  GARBAGE COLLECT: forces a controlled garbage
                collection of string space
36255  (46681)  DELVAR: frees space taken by a variable
36433  (46859)  GET-8-BIT: returns value of the following
                number in B Register
36483  (46909)  GET-16-BIT: returns value of the following
                number in X register
36522  (46948)  LIST BASIC: lists basic program in memory to
                to DEVN (device specified)
37025   90A1    (47448) PRINT CR/LE: moves cursor position
                to start of a new line
37093   90E5    (47516) OUT STRING:Outputs a text string to
                device number in DEVN
38266   957A    (48588) PRINT NUMBER:outputs 16 bit number
                in D Reg to DEVN
38798   978E    RANDOM NUMBER: Generates an 8 bit random
                number and puts it in location 278
39998  (34830)  ASSIGN-16-BITB:alternative to 35893, assigns
                value in Locs 82/83 to a variable
41194   A0EA    (36038) WAIT WITH CURSOR:scans keyboard for
                a keypress, flashing cursor at print pos.
43207  (38201)  CLEAR GRAPHICS:clears current graphics
                screen to data in B Register on entry
43304  (38298)  SET COLOURS: sets up locations 180 & 181
43320  (38314)  SELECT DISPLAY: Selects text or graphics
                depending on Z condition code, if Z=1 text
43322   95AC    (38316) RESET VDU: resets default VDU mode
43401  (38395)  SET VDG MODE:sets VDG in mode given in A Reg
43421  (38415)  SET VDG OFFSET: sets display offset for the
                graphics mode
43428  (38422)  SELECT VDG COL: selects required VDG colour
                set from the data in location 193
43489  (38483)  SELECT PAGE: on entry B reg contains page no
43536  (38530)  SELECT COL SET: selects colour set 0 or 1,
                according to data in B reg
43555  (38549)  RESERVE HRG RAM: reserves RAM for graphics
                and moves basic if necessary
44698  (39639)  PLAY NOTE: A Reg contains ASC code of note,
                other parameters should be set up
45137  (40118)  DRAW:allows access to all facilities of DRAW
46004  (40999)  RESET:resets whole works, as if reset button
                has been pressed
46080  (41142)  BOOT BASIC: restarts the Basic interpreter
                as if on power up or reset
46410   B54A    (41602) OUTCHAR:outputs character in A Reg
                to device number in DEVN (location 111)
46687  (42029)  CLOSE FILES: closes any open tape stream and
                flushes buffer
46757  (42089)  WRITE BASIC: writes current basic program to
                cassette
46920  (42257)  READ BINARY: reads in BIN file from tape
47283  (42625)  FIND FILE: searches tape for matching f'name
47411  (42753)  READ 1ST BLOCK:gets filename block into tape
                buffer
47422   B93E    (42763) BLKIN: reads a block of data into
                cassette buffer
47505  (42981)  WRITE 1ST BLOCK: (obvious)
47513   B999    (42996) BLKOUT: write block of data to tape
47583  (43149)  SET LRG LEVEL:on entry the X Reg contains
                Lo-res screen address, B Reg colour & loc184
                the OR data
47623  (43189)  RESET LRG PIXEL:as above but B Reg ignored,
                Pixel reset to Black
47656  (43225)  CALC PIXEL POS:on entry the top of stack
                must contain Lo-res vertical co-ordinate,
                preceded by horizontal co-ordinate
47735   BA77    (43304) CLEAR SCREEN: clears screen to space
                and 'homes' cursor
47737   BA79    (43306) CLEAR SCREEN to CHR: clears screen
                to character in B Reg
47776  (43345)  BEEP:sound Beep for length held in B Reg and
                pitch set by location 140
47811  (43380)  AUDIO OFF: disables sound:clears bit 3 65315
47813  (43382)  ENABLE SOUND: enables 6 bit sound by setting
                Bit 3 of 65315
47828  (43397)  RESET D/A: Puts value $7E into D/A converter
                address
47830  (43399)  WRITE D/A: puts contents of A Reg into D/A C
47852  (43421)  AUDIO ON:on entry the B Reg must be zero
48000   BB80    BOOT BASIC64K: Boots 64 mode
48053   BBB5    (41369) UPDATE CURSOR: flashes cursor
48101   BBE5    (41409) POLCAT: scans keyboard and puts the
                character in A Register
48288   BCA0    (41763) CLEAR VDU LINE: clears current VDU
                line from the cursor position
48299   BCAB    (41738) VDU OUT: prints char in A Reg to VDU
48373   BCF5    PRINTER DIR OUT: char in A Reg sent printer
48394   BD0A    PCRLF:moves print head to start of next line
48410   BD1A    (41663) PRINTER OUT:Char in Reg A to printer
48449  (43426)  SELECT JSK:selects joystick sources (ports -
                0 - 3) from A Register
48466   BD52    (43486) READ JSKS: Updates all joystick data
                locations (346/9)
48549   BDA5    (42837) BIT IN:reads a single bit(see below)
48557   BDAD    (42825) BYTE IN:reads a byte into A Reg(tape
48591  (42954)  MOTOR ON: tape - sets bit 3 of $FF21
48604  (42987)  MOTOR OFF: tape - clears bit 3 of $FF21
48615  (42876)  READ LEADER: motor on & prepares COS to read
48658  (43050)  BYTE OUT: writes byte in A Reg to tape
48746   BE6A    WRTLDR:turns cassette on and writes a leader

THE FOLLOWING ARE DRAGONDOS ROUTINES

49166   C00E    LENFIL: Report file length
49168   C010    CLOSAL: Close all files
49176   C018    GETFRE: Get free space
49178   C01A    DELETE: Delete a file
49180   C01C    PROTECT/UNPROTECT a file
49182   C01E    RENAME a file
49184   C020    GETDIR: Get directory entry
49406   C0FC    WRITE SECTOR: Writes 256 bytes to disk
49412   C104    READ SECTOR: reads 256 bytes from disk
49509   C165    DRIVE INIT: initialises DOS hardware
49513   C169    HARDWARE I/O: low level command to hardware
50108   C3BC    FORMAT DISK: in the DEFD drive
53581   D14D    GET FREE SPACE: free bytes on current drive
54033   D311    CONVERT SECTOR:converts LSN(Logical sect no)
                in Y Reg to Track/Sector
55868   DA3C    DIR DSK: directory of disk in DEFD drive to
                DEVN
56229   DBA5    BEEP: on entry B Reg should contain number
                of beeps
56267   DBCB    WAIT TIME:on entry X Reg should contain the
                number of milliseconds to wait
56330   DC0A    BOOT DSK: boots an OS off disk in DEFD drive

INPUT/OUTPUT ROUTINES

These refer to DRAGONDOS.

65280   FF00    Bits 0 to 6 Keyboard row input
                Bit 7 koystick comparator input
                Decimal value 255/127 if no fire but pressed
                Dec value 254 or 126 if right joystick
                button pressed
                Dec value 253 or 125 if left joystick fire
                button pressed
65282   FF02    Bits 0 to 7 keyboard column output
65312   FF20    Bit 0 - cassette data input
                    1 - RS232 data output
                    2/7 - 6 bit D/A(.25 to 4.75 volts out)
65313   FF21    Bit 0 - control of CD
                0=FIRQ to CPU disabled, 1=enabled
                Bit 1 - RS 232 status input
                0=set flag falling edge CD, 1=rising edge
                Bit 2 - normal Data Direction Register addsd
                0=change FF20 to DDR
                Bit 3 - Cass Motor control, 0=off, 1=on
                    4 - always 1
                    5 - always 1
                    6 - not used
                    7 - CD interrupt flag
65314   FF22    Bit 0 - RS 232 data input
                    1 - single bit cound output
                    2 - RAM size input
                    3 - VDG Control Output CSS(color set ct)
                    4 - VDG Control Output GM0&NOT(INT)/EXT
                    5 - VDG Cont Output GM1
                    6 - VDG Cont Output GM2
                    7 - VDG Cont Output NOT(A)/G
65315   FF23    (Coco) POKE 54 to disable auto exec of cartr
                POKE 55 to enable auto execute of cartridge
                Not certain re above for Dragon
                Bit 0 - control of cartridge
                0=FIRQ to CPU disabled, 1= enabled
                Bit 1 - Interrupt input
                0=sets flag on falling edge of cartridge
                1=sets flag on rising edge of cartridge
                Bit 2 - Normally 1, 0=changes FF22 to DDReg
                    3 - 6 bit sound enable
                    4 - always 1
                    5 - always 1
                    6 - not used
                    7 - Cartridge Interrupt Flag

SAM CONTROL BITS

65472/7 FFC0/5  VDG Control Registers for 6883 SAM
                Contains 3 pairs of addresses (V0-V2), and
                poking any value to EVEN addresses sets Bit
                Off(0) in VDG circuitry. Poking value to ODD
                addresses set Bit ON(1) in 6847 VDG circuit
65472/3 FFC0/1  Control of Bit 0 (V0)
65474/5 FFC2/3                 1 (V1)
65476/7 FFC4/5                 2 (V2)
65478/91        Page Select Register contains 7 pairs of
        FFC6/D3 (F0-F6) control Display Start address (Bin)
                Address os upper left most display element=
                0000+1/2*OFFSET. Poking any value to even
                addresses sets Bit OFF (0) in Page select.
                Poking any value to ODD addresses sets Bit
                ON(1) in Page Select Circuitry.
                Also BASEPAGE is set by converting binary
                value of F  (Bits F0 to F6) to decimal and
                multiplying this decimal number by 512.
65478/9 FFC6/7  Control of Bit 0 (F0)
65480/1 FFC8/9                 1 (F1)
65482/3 FFCA/B                 2 (F2)
65484/5 FFCC/D                 3 (F3)
65486/7 FFCE/F                 4 (F4)
65488/9 FFD0/1                 5 (F5)
65490/1 FFD2/3                 6 (F6)

65492/3 FFD4/5  Page #1 P1 control of Bit 7: (F7) 0=Normal
65494/7 FFD6/9  Clock Speed (R0-R1) Poking any value to even
                addresses sets Bit OFF (0). Poking any value
                to ODD addresses sets bit ON (1).
65494/5 FFD6/7  Control of Bit R0
65496/7 FFD8/9  Control of Bit R1
                R0=0, R1=0 (slow mode defa

MPU VECTORS

65522/3 FFF2/3  SWI 3 Vector mapped to 49138/9 BFF2/3
65524/5 FFF4/5  SWI 2 vector           49140/1 BFF4/5
65526/7 FFF6/7  FIRQ  vector           49142/3 BFF6/7
65528/9 FFF8/9  IRQ   vector           49144/5 BFF8/9
65530/1 FFFA/B  SWI 1 vector           49146/7 BFFA/B
65532/3 FFFC/D  NMI   vector           49148/9 BFFC/D
65534/5 FFFE/F  RESET vector           49150/1 BFFE/F

ERROR MESSAGES AND CODES

0       NF      NEXT without FOR
2       SN      Syntax error
4       RG      RETURN without GOSUB
6       OD      Out of Data in READ
8       FC      Illegal Function call
10      OV      Overflow
12      OM      Out of Memory
14      UL      Undefined Line
16      BS      Bad subscript
18      DD      Redimension array
20      /0      Division by Zero
22      ID      Illegal Direct Statement
24      TM      Type mismatch
26      OS      Out of String space
28      LS      String too long
30      ST      String too complex
32      CN      Can't continue
34      UF
36      FD      Faulty data
38      AO      File already open
40      DN      Drive number
42      IO      Input/Output error
44      FM      Wrong file mode
46      NO      File not open
48      IE      Input past EOF (ER on the Coco)
50      DS      Direct statement
128  *  NR      Not ready
130  *  SK      Seek
132     WP      Write protect
134  *  RT      Record Type
136  *  RF      Record not found
138  *  CC      Cyclic redundancy
140  *  LD      Lost data
142  *  BT      Boot error
144  *  IV      Invalid Directory
146  *  FD      Directory full
148     DF      Disk full
150     FS      File Spec
152  *  PT      Protection on
154  *  PE      READ past EOF
156  *  FF      File not found
158  *  FE      File exists  (AE on the Coco)
160     NE      Non-existent
162  *  TF      Too many open
164  *  PR      Parameter error
*    * These error messages are not on the Coco,
       but the following are and are not on the Dragon.
        BR      Bad record number (in data)
        FN      Bad file name
        FO      Field overflow re data files
        OB      Out of Buffer space
        SE      Set to non-fielded string (data)
        VF      Verification error