Dragon Stop Press - Issue 3

Dragon Stop Press - Issue 3
Issue Number 3 -
July 1983
sit,1
1 '
Plll~SS
AGON
I/I
EDITORIAL
Welcome to the third edition
of Stop Press which , like
its predecessors , has been
sent to all those Dragon
owners who returned their
guarantee card . Those who
have not (and there are
many) are not as yet
registered members of
Dragon Users Club and will
not be on the mailing list . If
you know of anybody in
this category, gently prod
them to return their card
so that future issues of Stop
Press may be directed to
them .
Though not (as yet) a fully­
fledged magazine, Stop
Press continues , in this and
future issues, to offer
Dragon owners pages of
program-oriented material.
Programs which (a) do
something interesting
(b) illustrate programming
techniques and (c) can be
typed into Dragon in a short
time , are ideal for
inclusion in Stop Press.
Most of the material
presented falls into at least
two of these categories!
Two features in the last
issue have their
counterparts within. Indeed
we hope that Machine
Code Corner and the Young
User Pages will be regular
features . In the belief that
there are many Dragon
users who will appreciate a
gentle introduction to
machine code, MCC
(nothing to do with
cricket!) continues the
series by showing how the
commands introduced last
time can be harnessed to
perform high-speed, high­
resolution graphics. As
each issue is published ,
readers will be able to
accumulate sufficient
expertise to make modest
use of machine code in their
programs.
This does not deny the fact
that Dragon 's BASIC
interpreter offers a rich
vocabulary of commands
for constructing programs ,
whether they be games or
whatever. Two of the
commands , SOUND and
PLAY, are explored in the
YOUNG USER PAGES
which also includes a puzzle
and a competition.
Mr W Harrold sent a
contribution (Patterns)
which exploits LINE. He and
others will be interested in
'Take 1000 lines ' where other
intriguing aspects of the
L.INE command are
investigated . Incidentally
the pictures in this and the .
previous issue were not
produced by ruler and pencil
but by Dragon and a
Hewlett Packard graph
plotter.
Another contribution , this
time from a young user in
Cardiff, is a game of skill
called 'Chicane '. Full
marks to Gareth Rowlands
for a superbly designed
game and a compact
program. We look forward
to many other such
contributions from young
and old alike.
The summer months may
see a lull in programmers '
activities as they take
advantage of the hot
weather! But don't forget to
send your entries for the
'Draw a Dragon Logo'
competition (see Issue 2)
by the end of July please, to
the editorial address.
Moss Cathy Hyde.
Drag on Data Ltd . Kent1g Industrial Estate.
Margam Port Talbot . We st Glamorgan
As for Dragon Data, every
month , hot weather or
otherwise, is a month of
intense activity in
preparing for the launching
of new ventures and the
consolidation of software
for Dragon 32. Stop Press
will play an increasing role
in providing up to date
information in the months
ahead.
PRICE CHANGE
On the 23 May the retail
price of Dragon 32 was
reduced to £175 including
V.A.T. At the same time the
following reduct ions were
made: Joysticks selection
2, Graphic Animator,
examples from the
manual , Dragon Mountain
and Dragon Selection 1
down from £7.95 to £4.95;
Ghost Attack cartridge
down from £24.95 to £19.95.
These price adjustments are
to be enhanced by the
release of approximately 25
new titles over the next few
weeks with many more to
follow shortly there after.
Also note that the Dragon
disc drive and operating
system was launched at the
recent Computer Fair at
Earls Court , and disc-based
software will be released
shortly.
1
MACHINE CODE CORNER An area of programming in which the effect of
machine code is particularly striking is the
animat ion of graphics. To see the lim itat ions of
BASIC in this respect , try keying in this short
program:
11
28
38
48
51
68
PMODE4.1:PCLS1 :SCREEN1.l:COLOR8,1
CIRCLE(11,28),9
DIMAl11)
GET(8,11) - 128.38),A,G
FORI = 1T0235:PUTll.18l - 11 +28 .38).A,PSET:NEXTI
GOT068
A small c ircle is drawn on the left of the screen,
and moved, by the finest poss ible increments,
to the right. The " an imat ion " takes about 15
seconds. Our more artist ic readers may like to
convert the circle into a snail! (By the way, note
how small the array dimension is - it needs to
be about a fortieth of the area of the " GET" in
pixels, whi ch is 21x21 = 441.)
Well , how much can this be improved by using
mach ine code? Try this one:
18 DATA 18.8E.7.48.86,8,38.A4.C6,15,66,84,66.1.
66,2,66,3
28 DATA 38.88.28,5A.26.F2,4A,26,EB ,31,21 ,18, SC.7.50,26.El ,39
38 FORI =IT035:REAOX$:POKEI +32888.VALl"&H" + X$):
NEXT
48 PMODE4.1:PCLS1 :SCREEN1 ,l :COLOR9.1
58 CIRCLE(18,28).9
68 EXEC32888
78 GOT078
Th is, of course, is really two short programs.
Lines 10- 30 POKE in the mach ine code, and lines
40- 70 execut e it. Even w ith the READ-POKE loop
the program is finished in one second . The
action itself takes one fifth of a second. After the
first RUN , the machine code w ill be in pos ition ,
so RUN40 will give you an act ion replay .
This is obviously faster than you will need for
most purposes, and can be slowed by the use
of delay loops. As with the BASIC program, every
intermed iate position is occupied , so a
completely smooth movement is possible at any
speed . The BASIC can be speeded up by leaving
out some of the intermediate pos itions, but this
results in a jerky movement.
Before we look in detail at animat ions of th is sort ,
we must invest igate the means by which Dragon
stores graphic information . We shall concentrate
on PMODE4 ,1. This makes use of memories $600
to $1DFF (or 1536 to 7679), i.e. a total of 6144 bytes.
In this mode, each of the 256x192 pixels is either
'on ' (green or buff) or 'off' (black). If it is 'on ' it has
value 1, if it is 'off' it has value 0. Pixels are
2
grouped together in sets of eight , so the top line
of the screen is made up of 32 sets of 8 pixels,
and each set is represented by one byte of memory.
For example, if the first eight pixels are ·on , on ,
off, off, on, on , off , off', then $600 will contain the
binary number 11001100 (dec imal
204). This can be seen by running
18 PMODE4:SCREENU:PCLS1 :POKE&H688.214
28 GOT028
(PCLS1 turns the whole graphics screen on i.e. it
places binary 11111111, or decimal 255, in each
memory, $600 to $7DFF.) So the rows of the screen
are contained in memories $600- $61 F, $620­
$63F, $640- $65F etc .
From this discussion, you may have concluded
that it is easier to move things up and down
than sideways - and you would be right. The byte
configuration remains the same In vertical
movement. So let 's see if we can make the balloon
go up, in a controlled sort of way.
Let's start in BASIC:
18 PMODE4.1:PCLS1 :SCREENU:COLOR8,1
29 CIRCLEl128,1781,7:PAINTl128,178)
38 LINEl121 .178l - l128.1861.
PSET:LINE(135,178) - (128.1861.PSET
48 LINEl124,186) - (132.1981,PSET.B
58 DIMAl12):GET(128.1621-l136,191l.A.G
68 FORI =1T0162:PUT(129.162- ll
- 1136,191- 11.A.PSET:NEXT
78 GOT078
Our balloon drawing is (conven iently) confined
to the 16th and 17th bytes in rows 163 to 191 .
As with GET and PUT it is useful to include the
bottom blank ro.w to avoid the problem of
" rubbing out" the bottom row of the picture as it
moves up. Row 163 starts at byte $600 + 32· 153
= $1A60, so the top of the picture is $1A6F
and $1A70, then $1A8F and $1A90 etc .
The following assembly language routine will do
the job:
1
2 LOOP1
3 LOOP2
4
5
6
7
B
9
11
11
LOY
LEAX
LOO
STD
LEAX
CMPD
BNE
LEAY
CMPY
BNE
RTS
# $1A6F
,Y
.x
- 32.X
32,X
# $FFFF
LOOP2
- 32.Y
# $68F
LOOP1
Machine Code
11BE1A 6F
38 A4
EC 84
ED 88 El
388828
1183 FF FF
26 F2
31 AB El
11SC86 IF
26 E7
39
One command you may not have met before is
Load Effective Address (LEA). The statement
LEAX ,Y may be compared with LOX ,Y but instead
of loading into X the data indexed by Y, the
actual address (the " value " of Y) is loaded into X.
The opcodes for LEAX and LEA Y are,
respectively, hex 30 and hex 31.
The numbers in the operand field , prior to the
comma, in lines 4, 5 and 8 are called offsets.
They cause the command to be applied to the
register value + offset. In other words, line 4
stores the value of D in the memory whose address
is 32 less than the value in X, line 5 increments
X by 32, line 8 decrements Y by 32.
The byte following an opcode which requires a
register as part of its operand is called a
postbyte. We met one in the last edition : ,X + is
represented by postbyte $80. For our present
program, we need to know that ,X and ,Y are
respectively $84 and $A4 (with no offset) and
with offsets in the range 16 to 127 or -128 to -17
the postbytes are $88 and $A8 (for X and Y),
followed by another byte - the offset. Negative
offsets are FF= - 1, FE = - 2, etc .
Our BASIC program , incorporating the machine
code, is:
18 DATA 18,8E,1A,6F,38,A4.EC ,84,ED.88.E8.
38.88,28.18.83.FF,FF 28 DATA 26,F2.31 .A8,E8,18.8C,6.F.26.E7,39 38 FORI =8T029:REAOX$:POKE32988 +1,VAL("&H" +X$l:NEXT 48 PMODE4,1:PCLS1 :SCREEN1 .8:COLOR8.1 58 CIRCLE(128,1781.7:PAINT(128,1781 68 LINE(121.1781 - (128.186).PSET: LINE(135.1781 - 1128.186).PSET
78 LINE(124.1861 - (132,1981,PSET.B 118 EXEC32888 118 GOT0118 Finally, to control the speed , we insert between
lines 7 and 8 the following delay loop:
Machine Code
LOOPJ
LOX
LEAX
BNE
$7FFE
- 1,X
LOOPJ
BE 7F FE
38 1F
26 FC
The postbyte of LEAX - 1,X requires explanation.
When the offset lies between - 16 and 15, the
postbyte represents the offset. For offsets of 0 to
15, postbyte = offset. For offsets of -16 to
- 1, postbyte = offset + $20.
The only other modification to the machine code
is to the relative address of line 10. 26 E7
becomes 26 E0. The following program gives a
controlled movement :
18 DATA 18,8E.1A.6F.38,A4,EC.84.E0 ,88,E8. 38.88.28.18,83,FF,FF 28 DATA 26,F2,BE,7F,FE.30,1F,26,FC,31 ,A8. E8.18.8C.6.F,26,E9,39 38 FORI =9TOJ6:READX$ :POKE32888 + I.VAL("& H" + X$l:NEXT 48 PMOOE4.1:PCLS1 :SCREEN1.9:COLOR8,1 58 CIRCLE1128,1781.7:PAINTl128,1711 68 LINE(121 .178l - (128.1861.PSET: LINE1135,178) - (128.1861,PSET 79 LINE(124,1861 - 1132.1981.PSET,8 89 POKE&H7FFE,5:POKE&H7FFF,255 118 EXEC32888 119 GOT0118 Line 80 puts the value 5 • 256 + 255 = 1535 into
memory $7FFE/$7FFF. Smaller values give a
faster movement ; larger ones give a slower
movement. The result - a very fine control over
the speed of the balloon .
PCOPY with Care!
When we write BASIC programs on DRAGON 32
we are well protected by a sophisticated error
trap which prevents us from giving commands that
cannot be carried out. As an example of th is,
turn on your Dragon and type PMODE4 ,5. The
answer is FC ERROR - you can ' t address page
5 in PMODE4 until you have PCLEARed 8 pages
(the default is 4). So type PCLEAR8 and then
PMODE4 ,5. This is accepted .
Now type PCLEAR4 . Back comes the answer: FC
ERROR. You can ' t PCLEAR down to 4 pages
while you are addressing page 5. So type
PMODE4 , 1 and then PCLEAR4 . Th is is accepted .
Most commands are protected in this way. The
obvious exception is the POKE com mand - if
you POKE addresses ca rel essly you are likely to
lose control - try typing POKE136,0 (136 and 137
control the cursor position).
A less obvious problem is the PCOPY command .
You might expect this to be prot ec ted in the
same way as PMODE and PCLEAR - but it isn't. If
you type a program in, and then (without
PCLEARING) type PCOPY 1 TO 5, your program
will disappear. This is because graphics page 1
has been copied to the location which held your
program . Admittedly this would be a silly thing
to do but the problem is more likely to arise with
programs containing statements like PCOPY I
TO J , when it is quite easy to get the value of J
wrong . So PCOPY w i th care!
PATTERNS
Thanks to Mr William Harrold of Cambridge for
this short program. He suggests using densities
of between 3 and 6. It is a program that we have
seen around in various forms - the intereference
patterns caused by the discrete nature of the
screen pixels are generally referred to as MOIRE
patterns. They will occur when lines are plotted
close together.
19 ' PATTERNS 28 ' WILLIAM HARROLD 1983 38 CLS:INPUT"ENTER DENSITY";S 48 PMODE4,1:SCREEN1 ,1:PCLS 58 FOR I =9 TO 255 STEP S 68 LINEll.81-1255 - 1,1911.PSET 78 IF I< 192 THEN LINE(9,IH255.191 - ll ,PSET 89 NEXTI 98 A$ =1NKEY$:1FA$ ="" THEN 98 ELSE 38 3
ARTIAL
RESTORE
i
0-9)
111
>.
When a program runs on a large number of DATA
statements which may have to be accessed in
any order, the most convenient method to adopt
is to read the whole dataset into an array and
use an indexing variable to access it. This takes
up a fair amoun t of room in the machine ,
however, and an al ternati ve is to read th rough the
who le dataset every time access is required ,
using the RESTORE command to return to the
beginning of the list. This is undoubtedly the
most eff ic ient method of conserving memory, but
is a rather cumbersom e procedure. A partial
RESTORE can be achieved using th e DATA
memory pointer, in addresses $33 and $34
(decimal 51 /52). By PEEKing these addresses at
suitable points the first time the data are read ,
we can store relevant values so that the pointer
can be reset to those poin ts by PO KEing at a
later time. The prin ci ple is illustrated by this small
program .
11
28
39
48
58
68
78
88
911
198
FOAi =1T03:XOl = PEEK l51 l:YOl = PEEK152) REAOX$:NEXT CLS:PR INT@7.''WHICH STATEMENT?" X$=1NKEY$:1FVALIX$) =80RVALIX$I > 3THEN48 X= VALIX$l:PO KE51.XIXl:POKE52.YIXI REAOX$:PR INT@71 ,X$ FOAi =IT01 91111:NEXT:GOT038 DATA "FI RST STATEM ENT" DATA "SECOND STATEMENT" DATA "THIRD STATEMENT"
JOYSTICK
GAM E
This game is for two players (one on each joystick).
The left joystick controls the " L" and the right
joystick controls the " R". The idea is to manoeuvre
your letter about the screen " running down " as
many of the numbers as possible, before your
opponent ge ts to them . You score the value of
the number and your score is shown at the top of
the screen . If you disappear off one edge of the
screen, you will reappear immediately at the
opposite edge. The numbers are 1- 9 (so if you
see an '87' , it is just an eight and a seven toge ther).
New numbers appear from time to time to keep
you busy. The time limi t is co nt ro lled by the 499
in line 80.
18 REM JOYSTICK GAME 29 REM A.O. MAYER 1983 39 CLS4:GOSUB211 41 Lil l=12:GOSUB239:J l1l =J + 1855: POKEJ(1l. Ll1 1 51 Liii =18:GOSUB239:J l8l =J + 1855: POKEJ!ll.Llll 61 PRINT"LEFT =l ";: PRINT@18," RIGHT =I ";:PRINT@21 ,"TIME =8"; 71 Siii = 8:Sl1I=8:S =1 4
,, Programs
Ill
)}.
81 FORT= 1T0499 91 IFINTtT/1811'181 =T ORSl81 + Sll l=S•45 THENGOSUB218 181 JV = RNDl21- 1:GOSUB241 111 JV =1- JY:GOSUB241 129 PRINT@5.S(1);: PRINT@16.S(81;: PRINT@26.T; 139 NEXTI 141 IFSll l > S(1)THENPR INT@263," RIGHT IS THE WINNER";:GOT0178 158 IFSl11> Sl81THENPRINT@263, "LEFT IS THE WINNER ";:GOT0178 168 PRINT@268."THE RESULT IS A DRAW"; 178 PRINT@324," DO YOU WANT ANOTHER GAME7"; 188 X$ = INKEY$:1FX$ = ""THEN188 1911 IFX$ = "Y"THEN39 2811 IFX$ = "N"THENSTOPELSEGOT0188 218 FOAi =1T09:GOSUB239 228 POKE1855 + J.I + 112:NEXT:S = S + 1:RETURN 239 J = RNDl248)•RNDl2l:IFPEEK 11855 +J I> < 191THEN239ELSERETURN 248 H=8:R=JOYSTK(2•JY):IFR < 15THENH = - 1 258 IFR .,. 48THENH =1 268 V=8:R=JOYSTKl2•JY +1): IFR < 15THENV = - 32 278 IFR > 48THENV =32 288 X=J IJ Y)+ H+ V:IFX> 1535THENX = X- 488 298 IFX < 1956THENX = X+488 398 IFX = J l1- JYlORX =J IJY ITHENRETURN 318 IFPEEKIXl > < 191THENSIJY) = SIJY) + PEEKIXl- 112 328 POKEJ IJYl.191 :POKEX.LIJY):J IJY)= X: RETURN The program uses the JOYSTK function to check the positions of the joysticks. Some versions of the Dragon primer give the JOYSTK values the wrong way round . The correct version is JOYSTK lll Right Horizontal JOYSTK ll l Right Vertical JOYSTKl2l Left Horizonta l JOYSTKl3) Left Vertical If yo u wan t to use th e joysti cks in a machine code prog ram, the proced ure is as follo ws. Use the JSR instruc t ion to exec ute th e ROM subro uti ne whic h begins at address $801 2 (deci mal 32786), then th e releva nt values, for th e momen t the subroutine was execu ted, will appear in add resses $15A, $15 B, $15C and $15D (decimal 346- 349). This method can , of co urse, be used from BAS IC, using EXEC. Th ese t wo programs are equ ivalent: try t hem wit h you r joysticks. (a) 11 PRINT JOYSTK!l);JOYSTKl1l;JOYSTK l2); JOYSTK(3):GOT011 (b) 18 EXEC32786:PRINTPEEK1346l;PEEKl3471; PEEKl348l; PEEK(349):GOT011 foryour32
~,
111
The machine code (li ne s 250 to 300) controls the
down-scroll. The following lis t ing may be useful :
1>1
LOOP
CHICANE
LOOP2
This driving game was sent to us by Gareth
Rowlands of Cardiff . A width of road between 2
and 7 may be se lected (we suggest you start at 7!)
and the idea is to stay on the road for as long
as possible, using the left and right arrow keys to
steer. Those of us who were brought up in a
more sedentary age may benefit by editing line
180, to adjust the upper limit from 7 to 9. Th e
benefits of selecting easy options do not last long ­
the road narrows as you progress .
8 REM ••chicane.. G. ROWLANDS 18 CLS:CLEAR298,29999:GOSUB 238 28 AUDIOOFF:MOTOROFF:M1$ = " T601CEGECCCEDEGEC ": GOTO 178
38 FOR I = 31968 TO P-LD :POKE l,255:NEXT
48 FOR I = P + 1-LD TO P + RD :POKE 1.175:NEXT
58 FOR I = P + 1 + RD TO 31999:POKE l,255:NEXT:RETURN
68 FORI =1 TO 16:S OUND1•19 + 25.1:EXEC32951 :NEXT:TIMER =8
79 FOR 0 = 1TO18
88 FOR I = 1 TO 16:R = RNDl21:1F R= 1 THEN LC = 175:RC = 255
ELSE LC = 255:RC = 175 98 CP = CP + IPEEK13431= 2231- IPEEK13441 = 2231 : POKEP - LD .LC :POKEP + RD .RC :P =P + I P ~ 31974 AND R =
11 - IP < 31993 AND R = 21:EXEC32951 :1F PEEKICPI = 255 THEN
158 ELSE POKECP.38:NEXT
188 IF P < 31984 THEN D =25 ELSE D =8
119 PRINT@D.INT(ITI MER + 1881/ 188)•5:
:PRINT@D + 32 ." MILES "; :SCREEN 9.1:NEXT
128 A = A + {A > 21 :SOUND298,1
138 PRINT@D + 64 ," ROAD " ;: PRINT@D + 96,"NARROWS";
148 LD = 9:RD = 9:B = A:GOSUB 218:GOSUB 38 :GOTO 79
158T = TIMER :FORI = 1TO17:EXEC32951 :
POKECP + RNDl31 - 2.239:POKECP + RND{31- 2.287:
POKECP + RNDl31 - 2.96:POKECP + RNDl31- 2.159:NEXT
155 IFT < 9THENT = 9
168 PLAY M1$:PRINT@196," YOU
SURVIVE D" INTIT/ 188)•5" MILES" ;
178 PRINT@238,"WIDTH OF ROAD ?";: SCREEN8.1
188 A$ = INKEY$:1F VALIA$1< 2 OR VAL IA$ ) > 7 THEN 188
199 CLS8 :LD = 8:RD = 9:A = VAL{A$ l: B = A:
GOSUB 218
298 P =31982 :CP =1519:GOSUB 38:GOTO 68
219 B = B - 1:LD = LO + 1:1F B < 1 THEN RETURN
228 B= B - 1:RD = RD + 1:1F B < 1 THEN RETURN ELSE 219
238 P= P+ 1:READ R$ :1F R$= " END " THEN RETURN
248 POKE P+ 32858.VALl " &H " + R$ l: GOTO 238
259 DATA 8E .85.E8.19.8E
268 DATA 86.88 .EC.83.ED
279 DATA A3,8C .94.88.2E
288 DATA F7,8E.7D .88.EC
299 DATA 83.ED.A3,19,8C
388 DATA 94.88.2E.F6.39
318 DATA" END "
_J
LOX
LOY
LOO
STD
CMPX
BGT
LOX
LOO
STD
CMPY
BGT
RTS
··-• S5EI
.. .x
,. .y
LOOP
# S70ll
.. .x
....
,. .y
LOOP2
Machine Code
IE 16 El
11BE1611
EC 83
ED A3
8Cl411
2E F7
8E 10 II
EC 83
ED AJ
118Cl411
2Efii
39
CODEBREAKER
Th is is a short program to further illust rate the
power of Dragon 's st rin g handling capa bilities .
It translates a typed message into a code which
is constructed by randomly permuting the
allowed letters. Because the random permutation
has been generated using AND( - 1) to initialise
the random sequence . th e code can be deciphered
using the same program providing the
transmission code is known .
Of cou rse, given ti me al l such codes can be
·cracked' and one of the ways to do that is to
use the knowledge gained from ' Letter Count'
concerning the frequencies of each of the letters
of the alphabet. For a literary reference read 'THE
GOLD BUG ' i n Edgar Alan Poe ' s 'Tales of
Myste ry and Suspense '.
1 REM CODEBREAKER A.M .SYKES MAY83 18 CLS :CLEAR1988:CH$ = " ABCDEFGHIJKLMNOPQRSTUVWXYZ.. ? " 28 CC$ = CHR${131 + CHR$181 38 INPUT"1 FOR CODING . 2 FOR DECODING "; C 48 ON C GOSUB 58.118:STOP 58 R = RNDl1881 :PRINT"YOUR TRANSMISSION CODE IS"; R
68 GOSUB138
79 PRINT@128,"NOW KEY IN YOUR MESSAGE"
88 PRINT"{ < = 255 CHARACTERS LONG AND ENDING
WITH < ENTER > I"
99 GOSUB248:GOSUB168:CLS
189 PRINT@1 ," YOUR MESSAGE READS ":
GOSUB248:PRINT@128.CM$:RETURN
119 INPUT" ENTER TRANSMISSION CODE " ;R
128 GOTO 68
138 Z =RNDl - 1l:FOR I = 1 TO R:Z =RNDl381 :NEXTI
148 CD$ = CH$ :FOR I = 38 TO 1 STEP - 1
158 Z =RNDOl :CD$ =LEFT$ICD$,Z - 11 + RIGHT$ICD$,38 - ZI
+ Ml0${C0$,Z,11:NEXTl :RETURN
168 M$ ="" :CM$ = ""
179 K$ = INKEY$:1F K$ = .... THEN 178
188 CH = INSTRl1.CH$.K$l :CC = INSTRl1 .CC$ ,K$l :IF CH = 8 AND
CC = I THEN 179
199 IF CC = 1 THEN RETURN
298 IF CC = 2 THEN L= LENIM $l:M$ = LEFT$IM$,L- 11:
CM$ = LEFT$ICM$ ,L - 1l:PRINT@1 .M$:GOT0179
218 M$ = M$ + K$ :PRINT@1 ,M$:0N C GOSUB228.238:GOT0179
K =INSTR{1 .CH$,K$l :CM$ = CM$ + MID$ICD$,K,1l:RETURN
K =INSTRl1.CD$.K$l:CM$ = CM$ + MID$ICH$,K,11:RETURN
FOR J = 1 TO 2988:NEXTJ :CLS :RETURN
5
LETTER COUNT This program counts the number of occurrences
of letters in writing . Just type in the words and
watch the bar chart build up. There is no backspace
so type carefully. The program stops when any
bar reaches the top. Then you can press ENTER
for a table of the number of occurrences of each
letter. You can press ENTER for the table at any
time during a run but the program is then
terminated .
1
11
2t
31
41
REM LETTER COUNT M.PEARSON MAY 83
CLSl :DIMBl251
PRINT@483."ABCDEFGHIJKLMNOPQRSTUVWXYZ";
PRINT@384.'' 5- ": :PRINT@224,"15 - ";:PRINT@64,"25 - ":
PRINT@1 ,A$;: K$ =1NKEY$:1F K$ ='"' 0R K$ = CHR$181 THEN
40 51 IF A < > - 52 THEN 70 61 CLS:FOR I= I T025:PRINT TABl51:CHR$(1 +661:Blll.:NEXT:END 71 A$ =A$ + K$:A = ASC(K$1 - 66 Bl L= LENIA$l:IF L> 29 THEN A$ =MID$IA$.L - 28l 91 IF A< IORA > 66 THEN41 ELSE BIA) = BIAI + 1 1• l =INTIB1Al /2l:IF BIAl/2=1THEN C=223:1=1- 1: ELSE
C=211
111 C = C + J2•(A /2- INTIA /2ll
129 PRINT@A + 3 + J2•(14 - 11.CHR$ICI:
131 IF BIAI < 28 OR INKEY$ =CHR$113l THEN 40 ELSE 130
Another way to display the bar chart ·requires the
following changed lines, with line 110 deleted
11 CLS:DIMBl25l
1• l= INTIB1Al /21:1F BIAl /2=1 THEN C=58:1=1- 1: ELSE C=46
TAKE 1000
LINES
1
11
2t
31
41
51
REM TRIANGLES M.PEARSON MAY 83
PMODE3:SCREEN1.l:PCLS
FOR C = 2 TO. 4: COLOR C.1
XA = RNDl2561 :XB = RNDl2561:XC = RN0(2561
YA = RNDl1911:YB = RNDl1911 :YC = RNDl1911
GOSUB71:PAINTllXA +XB + XCl /3
,(YA +YB +YCl /31.C.C:NEXT
61 GOT061
71 LINEIXA.YAHXB .YBl.PSET
Bl LINE- IXC. YCl.PSET:LINE - IXA.YAI.
PSET:RETURN
~,
Ill
J)J
The LINE command can draw lines on the screen
in any direction . Unlike the DRAW command it
is not limited to eight directions. The command
requires the co-ordinates of the end points of
6
the line. It is very useful to have the high-resolution
grid for reference . Once the end points have
been established the LINE command takes another
parameter, PSET or PRESET. PSET draws the
line in the foreground colour whereas PRESET
draws it in the background colour. The colours
can be chosen using the COLOR command . This
has two parameters FG , the foreground colour
and BG, the background. The colours must be
chosen with respect to the SCREEN in use. If
the COLOR command is omitted the foreground
colour will be the highest number available on
that screen and the background the lowest. There
is another form of the command LINE-(XB,YB)
which draws a line between the new point
and the last one used in a LINE command . If
the first LINE command in the program is of this
form , a line is drawn from the centre of the
screen to the point. Using PRESET, the first time
round might be one way of removing this line.
In addition to PSET and PRESET there is another
parameter: by adding B to the LINE command a
box is drawn instead of the line, the diagonal of
the box being the original line. If BF is added
the box is filled in the foreground colour.
The following program shows a triangle
subroutine in use. The co-ordinates of the three
points are chosen at random and the colours are
rotated . To colour the triangles in , a point inside
the triangle must be found for the PAINT command.
In this case the points of the triangle are chosen
at random. So which point lies inside the triangle?
The point whose co-ordinates are the average
of the X values, (XA + XB + XC)/3 and the average
of the Y values (YA+ YB+ YC)/3 will certainly lie
inside.
Writing a lot of LINE commands can be tedious.
One way out is to write the command as a
subroutine and change the values of the end points
either by defining them directly in the program
e.g. XA 100, or, by reading them from DATA
statements.
=
The following demonstration program shows
how DATA statements can be used with a LINE
subroutine to make a picture out of filled boxes.
The COLOR command allows the boxes to be
different colours . Only when a variable is changed
does it 's new value have to be READ . The
program draws ten boxes and then RUN should
reveal one very familiar 'box'.
1REM BOX M.PEARSON MAY 83
18 PMODE3:SCREEN1 ,1:PCLS :C1 =7:C2 = S:CO = C1
28 DEF FNCICI = - IC = c11·c2 - 1c = C21'C1
38FORI =1 TO 5:READ XA .YA.XB .YB .C:GOSUB1888:NEXT
48 FOR I= 1 TO 2:READ YA .YB:GOSUB11188:NEXT
58 READ XA.XB :GOSUB11188
68 FOR I=1 TO 2:READ YA .YB:GOSUB11188:NEXT
128 GOT0128
111811 COLOR C,5:LINEIXA .YAl - IXB .YBl.PSET.BF:RETURN
2881 DATA 29.48.188,178.8.48.68.135.138.
6.68.158.1&4.144.7
2111 DATA 148,111.178.156.7.148.68.155.78.7
2928 DATA 75.85.98.118,163,178,75,85,68.78
Another way to change the co·ordinates is in a
FOR. .. NEXT loop. This works well when the
coordinates change in a regular way . The next few
lines use this method to shad e the top and sides
of the ' box'. Five LINE commands , together with
PAINT could have been us ed but by drawing
lines very close together in alt ernating colours,
new colours , not readily available on Dragon ,
appear. These are creat ed as quirks o f the way the
eye combin es c olour and the Dragon sets points .
The colours are defined in line 10 so that you can
experiment with different ones . You can c hang e
the st ep length in lin e s 70 and 100 and try altering
the SCREEN .
Add these lines to the previous program .
78 FOR I=1 TO 38 STEP2:COLOR CO:LINEl188+1 ,48 - 11 - 1188
+1.171 - 11.PSET
88 CO = FNCICOl :NEXT
118 FOR I=1 TO 38:COLOR CO :LINE 128 + 1.48-11 ­
1188 +1.48 - 11.PSET
118 CO = FNCICOl:NEXT
There is another sort of shading available with
a LINE command . Thi s involves joining points
along two lines . Each line is divided into many
equal intervals and the points are joined as in
peg and silk designs . The eff ect is of a moulded
shape . The following program shows this
beautifully.
1
18
28
38
48
58
68
78
88
911
REM CONCORDE A.M.SYKES
PMODE4,1:COLOR8.5:SCREEN1 .1:PCLS5
FOR J = 1 TO 3
READ N.A.B.C.D.AA ,BB.CC.DD :FOR I = 8 TO N
Z =l/N :X=A + IC - Al'Z:Y=B +ID - Bl'Z:U = AA
+ ICC - AAl'Z:V = BB + IDD - BBl'Z
LINEIX .YI - (U ,Vl.PSET:NEXTl.J
GOT068
DATA 25.12.12.188.158.188.158,58.188
DATA 15.12.12.188.158,188.158.248.138
DATA 25.128.188.188.158.188.158.188.118
7
NINE-NINE-NINE
Does anyone know what sound a dragon makes?
Dogs bark, cows moo, and E.T. says 'goohm',
but what do dragons do? The sort of dragons that
live in lairs and terrorise villagers by burn ing
down houses whenever they cough , that is. Of
course the sort that live in houses near the
television only terrify the old folks (Over
30' s). We know these Dragons sing , make crunch
noises and bullet whines. But you haven 't really
got a well-trained Dragon until it makes noises that
you want it to make. You can use the SOUND
command to tell your Dragon to make noises. Type
in SOUND 89, 16 followed by ENTER. You should
hear a middle C lasting about a second . If you
don ' t then try turning up the sound or adjusting
the tuning on your TV.!
Try using di fferent numbers . The first determines
the pitch and can be from 1 to 255. The second
number controls the length of the note and must
be greater than 0.
If you want to hear all possible pitches you can
put the SOUND command into a loop .
Going up :­
11 FOR P=1 TO 255
2t SOUND P,1
31 NEXT
RUN
The loop takes P through all the values from 1
to 255 increas ing one at a time. We can change
the loop to take P through all values from 255 to 1
decreasing 1 at a time. Just change line 10.
Coming down:­
21 SOUND 171,6:SOUND 151.6
Run this. Does it remind you of anything? Now add these lines to give you the famil iar drop in pitch. 41
51
61
71
SOUND 169,6:SOUND 149.6
FOR J = 1TO3
SOUND 168.6:SOUND 148,6
NEXT
You can make very small changes in pitch using
the SOUND command , but you need a very good
ear to decide which number gives which note.
However with the PLAY command you use
letters CDEFGAB for a scale together with sharps
(•)and flats( - ), or alternatively, numbers separated
by semi -colons 1;2;3;4;... 11 ;12 to play successive
semitones . Th is is the way to make your Dragon
tuneful. There are lots of instructions available and
page 113 of the Dragon Primer lists them all.
To make the siren sound using the PLAY
command I decided to use B and B flat above
middle C (03) played very rapidly (T250) to g ive the
chord effect . I played them 15 times to get the
right length of note. For the lower note I used F
and Ff , but you can change the notes to suit
yourself. I wanted the siren to start qu ietly and
come nearer so the volume had to be increased .
I could write lots if strings:
PLA Y"V1 " + ... ,PLA Y"V2" + . . . and so on. That's
tedious so the changing numbers are in a loop.
For example lines 10, 30 and 90 in the following
program are:
11 FOR l =1TO11
31 PLAY"V'' + STR$(ll
91 NEXT l
(L for loudness).
11 FOR P= 255 TO 1 STEP - 1
Perhaps you want to play the same note over
and over again. Try:­
11 FOR J = 1 TO 5
2t SOUND 171.6
31 NEXT
This loop takes J through values 1 to 5 but J
!sn't mentioned inside the loop so the program
iust does the same th ing five times. How dull!
Let's change line 20 to
8
When you use several loops in a program it's
w ise to state which variable you want when you
end the loop with NEXT. Hence NEXT L.
Here is the program for a siren getting nearer.
11 FOR l = 1TO11
2t FOR 1=1TO15
31 PLAY "V" +STR$(ll
41 PLAY"T251:0388 - "
51 NEXT I
61FOR1 = 1TO15
71 PLAY"FFI "
81 NEXT I
91 NEXT l
If you want to carry on and make the siren go past
use
111 FOR L=21TO1 STEP -1
and a drop in pitch say A and B flat with F and E.
Now a challenge! Can your Dragon ring like a
telephone? If it can , send your program to us
and will reward the best entry with free Dragon
software! For details, see Young Users
Competition .
Now follows a tiny program to develop weird
sounds by changing one line.
11 P$ = "T21ABBCA" 21 PLAY P$:GO TO 21 You must use the BREAK key to stop this program .
Here are some other ideas for line 10.
DRAGON
PUZZLE 2
This program plays a tune but first you must get
the lines in the correct order. On the right are
clues to the missing line numbers. Put the answers
in the spaces left for them and type RUN . I'm
sure you will recognise the tune .
1 'DRAGON PUZZLE 2
....PLAY"l8EEDL4.CL8C"
..PLAY C$FOR I = 1T02
....PLAY"L4GECEL4... D"
..H$ = "L4...G":F$ = "L4... F"
....PLAY"L8EFL4GECDL4... C"
11
11
11
11
11
11
11
11
11
11
So
P$ = "T211 ABBCA" P$ = "T211 ABBP1 " P$ = "T2llO 1ABBP1P1" P$ = "T1llO 1ABBP1P1 " P$ = "T1ll05 ABBP1P1 " P$ = ''T111DGCCDEFGFGCCDEFG2" (spacecraft soundI P$ ="T1llEDCCEDCCGFEEGFEE " (mice running fastl P$ = "T11EDCCEDCCGFEEGFEE" (slower miceI P$ ="T2EDCCEDCCGFEEGFEE " (sedate micel P$ = "T111GFEDC" (spaceship hit soundI PLAY
AWAY!
WIN 4 SOFTWARE CASSETTES (COMPETITION)
If you are twelve years old or under and would like
to win some Dragon Software then devise a program
on your Dragon 32 that uses the computer's SOUND
or PLAY commands to mimic a telephone ringing .
The program should not be more than twenty lines
long.
The young programmer judged to have devised the
neatest program will win 4 cassettes of their choice
from the software listed on the back page and some
posters illustrating some popular Dragon games.
Send your entries to The Editor of the Newsletter at
Dragon Data, by 31st August 1983. The editorial
decision is final.
The editor, The Newsletter, c/o Dragon Data Ltd ,
Kenfig Industrial Estate, Margam, Port Talbot , West
Glamorgan.
....PLAY"L4EGL8G" + F$
.. .. PLAY H$+C$:NEXT
..Y$ ="L4GECD ": C$ ="L8CEF"
... . saw the start of World
War 1
. . is quite a score
. . . . is the year Columbus
discovered the Bahamas
. . is a baker's dozen
. . . . is the year of the
Dragon
.... and World War 1 ended
... .• the year Harold saw no
more
... ,coming of age
SOLUTION TO DRAGON
PUZZLE 1
11 CLS:PRINT" DRAGON PUZZLE "
21 PRINT@294,"FIRE"
31 PRINT@263,"GAMES"
41 PRINT@132.''PIGLET"
51 PRINT@196," FOOTBALL"
61 PRINT@167.''PYTHON "
71 PRINT@325.''PANDA"
• PRINT@231.''GEORGE" 91 PRINT@111 .''BRAKE " 96 FOR I = 1 TO 3111:NEXT 111FOR1 = 3 TO 11:P= PEEKl1032 + 32•1) 111 PRINT@32•1 + 8.CHR$IP + 321; :NEXT:PRINT@351.'"' (See YOUNG USERS PAGE in previous issue)
9
Here are 24 new titles in the official Dragon Data Software range that should be appearing in the shops
about now . Watch out for further Software news in STOP PRESS.
M30528 STALAG ENO
No joysticks. Two adventure
games. In stalag , your goal
is to escape, alive, from a
prisoner of war camp
before it is bombed . In Eno,
you are searching for the
money left by your late aunt .
To prove that you deserve
the fortune that has been left
to you , your aunt has
hidden the cash .
M30523 FINAL COUNTDOWN
No joysticks. Final
Countdown is an adventure
game in which your mission
is to prevent a nuclear
missile from being launched
and starting world war Ill.
You begin the game outside
a missile base which has
been evacuated after a
berserk General has started
the countdown on a missile.
M30524 MANSION OF DOOM
No joysticks. Mansion of
doom is an adventure game
in which you have been
chosen to reunite the crown
princess Marlena with the
townspeople of her village
in Transylvania. You must
rescue the princess from
the mysterious Count van
Steinoff . His mansion , on
the edge of the village, is
replete with legend . The
count himself has never been
seen in daylight.
M30530 TIMSCRIPT
No joysticks. Printer
required . A speed writer
which will enable you to use
your Dragon to produce
continuous text, such as
business letters, quickly
and easily. Timscript allows
frequently used words and
phrases to be replaced by
two letter codes,
considerably reducing the
number of keystrokes
required . The codes are
automatically expanded
when they are typed .
M30522 POSEIDON ADVENTURE
No joysticks. Poseidon
Adventure is an adventure
game in which you are
aboard the luxury liner S.S.
Poseidon . A huge undersea
earthquake has caused a
tidal wave which has
capsized the ship. It is
floating , bottom -up on the
surface and taking on
water. Your goal is simply to
get out alive.
M30533 DREAMBUG
No joysticks. Dreambug is a
monitor (debugger) and
disassembler for the Dragon
32 which is designed to be
used in conjunction with
dream (editor/assembler
cassette for the Dragon 32).
10
L30518 DREAM
No joysticks. A professional
quality screen editor and
assembler for use in the
production of assembly
language programs and
subroutines.
120001 ALLDREAM
EDITORI ASSEMBLER
No joysticks. A screen editor,
assembler, disassembler
and monitor together on a
cartridge. The package will
enable the user to create and
debug assembly language
programs or assembly
language subroutines to be
called from within basic
programs.
L30520 PIXEL EDITOR
No joysticks. This program
will enable quick and easy
creation and editing of
graphics shapes . Each
individual pixel can be
accessed in order to
produce detailed pictures
and character sets.
L30521 HIDE AND SEEK
No joysticks. Hide and seek
is a program designed by
experts to aid short term
memory and develop early
reading skills. The program
has a range of difficulty
levels to suit children
between the ages of four
and eleven , and , as well as
being educational , is a
program which children will
enjoy using .
L30519 NUMBER PUZZLER
No joysticks. Number puzzler
is a program designed by
experts to develop childrens
powers of mental
arithmetic . The program has
a range of difficulty levels
to suit children between the
ages of four and eleven
and , as well as being
educational is a program
which children will enjoy.
L30517 NUMBER GULPER
Joysticks optional. As for
number puzzler.
M30528 CIRCUS ADVENTURE
No joysticks. Circus
adventure is an adventure
game designed especially for
children between the ages
of 4 and 8. The program
incorporates a number of
user inputs to encourage
keyboard familiarity and
presents the child with a
series of choices to be
made to encourage decision
making skills. The program
is designed to be non­
frustrating and children will
enjoy using it.
M30529 SCHOOL MAZE
No joysticks. As for circus
adventure.
M30510 D RAGON SELECTION 3
Joysticks required for aliens.
Dragon selection 3 is a
collection of four games
programs:- Money,
Detective, Aliens, Hangram .
N30511 DRAGON SELECTION 4
No joysticks. Dragon
selection 4 is a collection
of three party games for
children . Password, Lucky
Dip, Composer.
J20111 RAIL RUNNER
No joysticks. A fast moving
video game, rail runner is a
race against time to cross a
series of tracks. avoiding
trains and handcars to
rescue Herman Hobo.
M30518 EL DIABLEAO
No joysticks . El Diablero is
an adult adventure game.
You are wandering in the
desert trying to regain your
lost magic powers before
confronting El Diablero.
M30527 STORM ARROWS
Joysticks required . Storm
arrows is a fast moving ,
multi-screen maze game.
Your task is to defend
yourself against hostile
arrows while maintaining
your energy supply .
K30112 GALAX ATTACK
Joysticks required. As wave
after wave of enemy ships
attack, you must defend your
ground base against them .
The enemy craft fly in convoy
formation but they will
disband in order to attack.
K30532 SHAAK TREASURE
Joysticks required . You have
discovered the lost wreck
of a ship which sank many
years ago with a cargo of
gold bars. The only thing
between you and a forfune
is a swarm of huge sharks.
Shark treasure is graphic
video game.
J20110 DOODLE BUG
Joysticks required . Doodle
bug is a colourful , fast
action maze game . An
increasing number of
enemies have to be avoided
together with a number of
dangerous obstacles.
K30535 SHUTTLEZAP
Joysticks required . Orbitting
the earth your task is to
grab as many satellites as
you can, before landing
safely back at base . This
program has great graphics
and what's more - it talks to
you .
K30114 WHIRLYBIRD AUN
Joysticks required.
Whirlybird run is a fast
moving arcade type game,
with multiple screens,
different types of attacker
and a maze to be
negot iated in the final
stages.
11
DRAGON SOFTWARE I/I
SOFTWARE AVAILABLE
FOR THE DRAGON 32
N.31JiOO DRAGON
SELECTION ONE
Four games for the younger
user . Wrillen 1n BASIC . they can
be listed and edited .
N.30501 DRAGON
SELECTION TWO
Collection of uhhhes Create
your own data base. write your
own tunes .
M.Di02 QUEST
Adventure game in amedieval
setting. Defeat Moorlock . master
of the dark castle .
M.30503 .MADNESS AND
THE MINOTAUR
M.Di18 EL DIABLERO
An adventure game set on the
desert.
J.20100 BERSERK
A challenging shooting game.
based on the popular arcade
game. one or two players. A high
resolution game in black and
white . Joysticks required .
J.20101 MITTOROIDS
Guide your ship through
treacherous asteroid belt. A
game requiring skill . fast
reactions and concentration . A
high resolution game in black
and white. Joystic~s optional.
A real·time adult adventure
game .
N.30504 PERSONAL FINANCE Keep track of family finances .
N.:llmi GRAPHIC
ANIMATOR
M.30606 COMPUTAVOICE
Your Dragon will talk with this
voice synthesizer .
N.30507 EXAMPLES FROM
THE MANUAL
30 examples from the
programming manual.
M.30608 CALIXTO ISLAND
An adventure game . Return the
hidden treasure to its rightful
place.
M.30609 BLACK SANCTUM
An adventure game. Overcome
the forces of blach magic.
M.Di12 TYPING TUTOR
Improve your speech and
accuracy.
N.Di13 DRAGON
MOUNTAIN
An adventure game. Defeat the
guardians of the treasure hidden
in the mountain .
M.Di14 FLAG
12
Create simple cartoons on the
screen and animate them by
flipping through the pages .
Joysticks required .
Race your opponent through a
constantly changing maze to the
final flag . Joysticks required .
J.20102 COSMIC INVADERS Dragon version of the famous
arcade game.
J.20103 GHOST ATTACK
Maze game for one player.
Joysticks required .
J.20104 CAVE HUNTER
Descend into the maze of caves
in search of gold. Joysticks
required .
J.20106 STARSHIP
CHAMELEON
Protect your planet from the
attacks of the Gabulators. High
quality arcade game with superb
graphics and sound . Joysticks
required .
J.20107 ASTROBLAST
Defend your ship against waves
of attackers. A high resolution
game in black and white .
Joysticks required .
1.20108 CHESS
Nine levels of play. from
beginner to master.
J.20111 RAIL RUNNER
Move Bill Switchman across the
tracks . avoiding trains . to rescue
Herman Hobo.
Published by: Welbeck Public Relations, 2 Endell Street. London WC2. Printed by: Df)'dens Printers Ltd.. Brent Crescent , North Circular Road. London NW10.
Was this manual useful for you? yes no
Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Download PDF

advertising