"Feature
The fifth in a series of tutorials for the beginner
to intermediate machine lan,
guage programmer
Machine Language Made BASIC
Part V: Get the Point
Vhis month’s programs change the
color of various screen locations.
Now, color information is stored
in several locations in the Color Com-
puter. Locations used in this article are
as follows:
Loe: Start-up
$B2 foreground color °
SB3 background color (0)
SB4 current color 0)
SBS $B4x(#855) 0
SC2_PSET= I; PRESET =0
As shown in Figure 1, colors depend on
the PYODE and color set used.
‘The computer colors zero to three
correspond to the Basic colors one to
four and five to eight. Three is the
Figure 1:
ke Number Set 0
MODE 3/1 0 green
1 yellow
2 “blue
3 red
prove 4/2@ «0 lack
3 green
highest number used for color because
4x(/#855) would be greater than 255 and
‘would not fit into Location SBS. With
machine language, we can control and
change the contents of the color loca-
tions throughout the program.
At start-up, the computer will store
(0 in $B3 (for the background color) and
3 in $B2 (for the foreground color).
Using the PCLS routine at $9542 will
clear the screen to the background
color. If you want a different back-
ground color, either load the desired
color number into $B3 and JSR 9542,
80
THE RAINBOW November 1983
By William P. Nee
or load the desired color number into
Register B and JSR $9536. (The latter
will nor change the background color in
SB3.)
Location $C2 can be used as a toggle
for PSET (if itis set to one) or to PRESET
(if itis set to zero). However, the PSET
routine we will use starts after the ROM
routine has checked Location SC2, so
we should use either the subroutine at
$959A, which multiplies the color
number by #855 and stores this total at
Location $B5, or PHODE 4/270, which
will store a random 0 or -1 (RND(Q):
2) in $BS and then PSET or PRESET the
point. (Remember, -1 is the same
number as #SFF.) PHODE 371 will use a
random (0 - 3)x(#855) to PSET three
colors or PRESET the background color.
Set
buff #800
cyan 1855
magenta #$AA.
orange SEF
black #800
buff aSFF
‘You may also use the PPOINT routine
at $933C to check the color of a bit at
bit in Location $BE) and any vertical
location (by storing it in $CO). The
result of the PPOINT routine is stored in
FPI. JSR $83€0 will return the color
number to Register B. In PHODE 371 the
result will be colors one to four (if you
are using color set to 0), or colors five
to eight (if you are using color set to 1).
In PHODE 4/270, the result will be zero
cor one with color set to 0, and zero or
five with color set to 1. Your program
may have different branches if Register
B was equal/not equal to one of these
colors. Ifa point has been PRESET, the
PPOINT routine will make it the back-
ground color. (Note: You always lose
registers A, B, and X, so be sure to save
them first.)
‘The PSET routine is at Address $9374,
and, as with most machine language
programs, requires some additional set-
up. The routine uses the following
locations:
Bo bytes per line
SBD/BE horizontal coordinate — XI
SBF/CO vertical coordinate — YI
The coordinate locations are two bytes
so that you could, for example, either
STX $80 or STA SBE. XI cannot be
greater than 255; YI cannot be greater
than 191; and neither can be less than
zet0.
A scaling routine at $931D is also
required. Since we will pick up the PSET
routine after ROM has scaled the coor-
dinates, we must add this to our pro-
gram prior to the PSET. Scaling adjusts
X1 and YI to compensate for the
ferent bytes per line (in SB9) assigned to
the individual PMODES. Without this
scaling routine, most graphic com-
mands (PSET, LINE, CIRCLE, etc.)
would be accurate only in PMODE 4. (The
PPOINT routine we've already discussed
includes the scaling subroutine.)
Bill Nee bucked the “snowbird” trend
by retiring to Wisconsin from a banking
career in Florida. He spends the long,
cold winters writing programs for his
CoCo.Listing 1: POINTSAS
PMODE 4,1:PCLS:SCREEN 1,1
FOR N=f TO 32
FOR NN=31 TO N STEP
B=RND (2)
FOR H=9 T0 192 STEP 64
FOR V=f TO 128 STEP 64
ON B GOSUB 199,159
NEXT V,H,NN,N
99 GOTO 29
1pg PSET(H+NN, V+NN-N) : PSET (H+NN-
N, V#NN)
11g PSET(H+62-NN, V+NN-N) :PSET (H+
62-NN+N, V+NN)
1
129 PSET(H+62-NN, V+62-NN+N) : PSET
(H462-NN4N, V+62-NN)
139 PSET(H+NN, V+62-NNN,
NN-N, V+62-NN)
14g RETURN
159 PRESET (H+NN,V+NN-N) : PRESET (H
+NN-N, V#NN)
169 PRESET (H+62-NN, V+NN-N) : PRESE
‘T(H+62-NN+N, V+NN)
179 PRESET (H+62-NN, V+62-NN4N)
ESET (H+62-NN+N, V+62-NN)
189 PRESET (H+NN, V+62-NN4N) : PRESE
T (HHNN-N,V+62-NN)
199 RETURN
SET (Ht
R
the machine language program is eight
‘The PSET routine in ROM uses reg-
isters A and B, so be sure to save any
information in them first. Before run-
ning the program, set Location SFF,
100 to #82000. Since the program starts
with PHODE, type “GPMODE” or “6300”
(or lack of it). Next, run the machine
language program. (Note: The machine
language program does not run on the
CoCo 3.) If you run the machine lan-
guage program from BASIC, clear
enough memory with the command,
times longer, it runs much more quickly.
(Questions or comments concerning
this tutorial may be addressed to the
author at Route 2, Box 216C, Mason,
WI 54856-9302. Please enclose an
SASE when requesting a reply.) 0
CLEAR 200, £43000-1. Even though
toexecuteit. Pressing any key will break
the program, but you must hold the key
down for several seconds because the
program does a lot before getting to the
Listing 2: POINTBIN
break location. In the ‘A’ mode you can 9958 * SEF/II Ses 299g
read the program and symbos tom | 7%” gin gee, Oe 0
$2200 to $2B65. ggRE gp129 x1 EQU $BE
Meencr esata Gus ee
feel for the design and program speed
Burke & Burke
P.O. Box 1283. Palatine, {L_ 60076-4203
G12) 30
Alpha Software Technologies _ ranean
Real BASIC for OS9!
inelinast
There is nothing wrong with your Color Computer.
Dornot attempt to adjust fe wes
ome er snot Dick Exened Esl BASICS Were aed
leh ‘on siple grephee, sound, piste, and dia 10. The BASIC
{Jou know ond lve la new running under Level 2 0S0 window
73. ond and soon to ung Os he amet to Hae
mid BASIC dha. Of coutoe, you et toe F
ISngunge programe, end sr
Sak Mee ah aa
Sepa
FSB, requires a CoCo 3 with at lost 128% RAM, 8 oppy contr wih
siner Tandy ak Extended Color BASIE wr DISTO Cate’ 9 COOR OM,
paeed Picee
UNGIS RESIDENTS EASE ADD Ty SALES TAK. COD m0 Shona tiie
aN gtaS" Paste mona ror ‘eigen be see
ous ae
81
November 1988 THE RAINBOWSubmitting
Material
To Rainbow
Contributions to THE RaiNsow
are welcome from everyone, We
like to run a variety of programs
that are useful/nelpful/fun for
other CoCo owners.
WHAT TO WRITE: We are inter-
ested in what you may wish to tell
our readers. We accept for consid-
eration anything that is well-
written and has a practical appli-
cation for the Tandy Color Com-
puter. If it interests you, it will
probably interest lots of others.
However, we vastly prefer articles
with accompanying programs
which can be entered and run. The
more unique the idea, the more the
appeal. We havea continuing need
for short articles with short list-
ings. These are especially appeal-
ing to our many beginners.
FORMAT: Program submis-
slons must be on tape or disk, and
itis best to make several saves, at
least one of them in ASCII format.
We're sorry, but we do not have
time to key in programs and debug
our typing errors. All programs
should be supported by some ed-
itorial commentary explaining
how the program works. We also
prefer that editorial copy be in-
cluded on the tape or disk using
any of the word processors cur-
rently available for the Color Com-
puter. Also, please include a
double-spaced printout of your
editorial material and program
listing. Do not send text in all
capital letters; use upper- and
lowercase.
COMPENSATION: We do pay
for submissions, based on a
number of criteria. Those wishing
remuneration should so state
when making submissions.
For the benefit of those who
wish more detailed information on
making submissions, please send
a self-addressed, stamped enve-
lope (SASE) to: Submission
Guidelines, THe RaiNaow, The Fal-
soft Building, P.O. Box 385, Pros-
pect, KY 40059. We will send you
comprehensive guidelines.
Please do not submit material
currently submitted to another
Publication.
3099
392
305
3897
3398
sag
ape
saz
Ba
37
spi
apis
sap
apap
3p22
325,
p28
p28
2p2E
3538
3633
3636
3939
apie
303F
p02
p43
agua
3948
ap4e.
aps.
ps4
ps6
3939
apse
3a5F
3962
apes
pea
pea
sasp
3p7g
2973
276
3979
ape
ape
spa.
p08
spas.
389
380
sper
3982
3938
3987
394
p90
293F
3pa2
3pA5
39n8
spas
Spaz
spss
383
Ba
389)
apse
398F
3gc2
‘pcs
3pc7
3pca
300
82 THERAINBOW November 1988
308
BFF
34
9628
a
9653
9542
a
5A
a
9682
3187
3188
2
Bo7G
BLE
B2ED
992
as
3188
3189
3188
3187
318A
seg
3188
3187
a1a9
aise
318A
399
3B
a1e8
3ia9
5188
3187
aia
gaa
3B
suse
3187
3189
318s.
318A
9576
3
suse
3189
3B
3188
3187
5184
969
bias
3187
aug
auea
548
388
aug
3.
aie
3187
318A
936
3188
3187
318s
3108
318A
22
3188
gpig
gp1sp
5169
9179
gpiag
9139
5209
pp218
99229
90239
pn243
e258
o268
po27p
goes
99298
0309
posip
9932p
9339
goseg
9358
59360
99378
9388
99398
a90a9
spas
go02p
99039
906g
ga65p
sa66g
9478
g9cay
3498
39389
9519
99509
go5g
9549
99359
0569
90578
gases
59598
co
posis
gosag
pep
speug
spes9
ape69
opere
socep
secon
99799
sorig
99728
e738
gp7ag
99759
so76p
99778
goveg
59799
seegp
pep
pp82p
0835
poeap
pass
posep
pep
posep
peop
e989
ap.
PHODE
LoorL
Loor2
RANDOM
a
ean
@
eae
a
23
ry
oat
FINisi
‘susp
STB
STA
TA.
SUBA
sm
Bsr,
STA
ws
st
BSR
sUBA
STA
1A
SUBA
STA
ESR
SUBA
ADDA
STA.
st
LBsR
suBA
STA
1A
SUBA
ADDA,
STA
ase,
DA.
SuBA
ADDA
sta
a.
SUBA,
sta
asa,
wa
st
1A.
‘ADDA
STA.
BSR
SUBA
STA.
a
SUBA
STA.
LBSR
1s
SBFLF
59628
$9659
39542
a
5954a
39682
ean
2
spo7e
END.
$B3ED
35
How.
sHOwL
suo
62
aw
PAGE 1
Peis
GRAPHICS SCREEN
coLok se 1
REGISTER B 70 FPL
GET RANDOM(2)
FPL 70 REGISTER D
GET -1 OR g
[-sSEFAPSET; S-PRESET
POINT 1
Pornr 2
Pornt 3
POINT 4
POINT 5
Porn 6
Pornt 7
Porsr 8303
3904,
307
303.
apoE.
spor
Spe
ayes.
5p
Sep
Spee
apr
3pr2
385
apr?
3pr9
spre
Sper
spt
31g3
3185
3p
ag.
31p0
SUF
sun
sue
a7
aug
aus
mp
na
aa
3125.
3127
3129
size
Sur
3132
a4
3136
3139
suse
a3F
na
3ua
316
249
buse
Suse.
ausg
3133
3156
3138
asa
aise
asF
nie
nies
ne?
sis
aise
3L6F
372
3174
3176
3179
3170
SUF
31a1
51aa
pias
aie?
nee
3189
318a
3187
BRAD
3187
2p
F33
oF Ags
FF2A
3189
oa
9374
3189
og
BE,
oa
9374
3189
a8
BE,
oo
9374
3189
oo
BE
oa
9374
3189
og
BE
ow
9376
3189
apg
BE
oo
937%
3189
apg
BE
o
9374
3189
cpap
a
937%
3189
ag
3
oo
9374
3183
‘pep
BE
6
3374
s188
apep
35
a
9376
3188
pep
BE
o
9376
3099
sps1g
99929
99939
9043
90958
9969
99979
99985
199995
one
pigip
pig2p
pip9p suow.
pigap
pigse
pigeg
178 suow2
pipes
wisp
ngs
pug
giz suows
mise
pila
usp
plies
SLL7B sHows
pisp
ot
niga
mig
1229 snows
pag
pi20p
pase
pizeg
L278 sHows
gizag
pi2sp
wi3e9
misig
1s2p sow
pi33g
gag
9135p
sites
9137p SHOWS
prise
pissp
nage
pag
9142p sous
pag
sites
piesg
pice
BLETB SHOW
uses
pass
puspe
psig
piseg sHowia
pusap
mise
p153p
prises
gis7g suow2
prises
piseg
pleas
pieig
preg
pissp w
hess x
pLe3p
piseg vy
wis79
DECB
cure
BE
INCA
one
B10
JSR
1BEQ
Cres
ISR
Sur
wo
st
STB
ase
io
ADDA,
sta
STB.
ask
ADDA,
STA
ste
sa
ADA,
st
STB
ask
sta
STB
ISR
‘app
STA
STB
sR
ip
‘apo
STA.
STB
ISR
i
‘sp0D
sta.
STB
ISR
DDB
sta
ose
io
DDD
STA.
STB
ISR.
ip.
DDD
sto
Is
ip
ADDD
STA.
STB
ats
RMB
2.
2s.
END
y
L00P2
N
#82
Loot
[saga] any repute
START
$950a,
x
By
1
PsEr
x
#549
x
a
PSET
x
asep
x
n
POET
x
#309
x
n
PSer
sag
m
cat
PSEr
x
as4gag
x
1
PsEr
xx
sepa
x
ML
PSET
x
#scpag
xL
n
PSEr
x
co
x
u
SET
x
sapeg
x
ML
PSET
x
wsene
x
ce
PSET
xx
sone
x
a
1
1
i
a
p
MODE
SET FOR TEXT SCREEN
Rts IF
SQUARE.
SQUARE
SQUARE
SQUARE
SQUARE
SQUARE
SQUARE
Square
SQUARE
SQUARE
Square
SQUARE,
a Baste
1
w
a
2
Hin.
Cursor Controls
Memory location 63372 con-
trols the blink rate of the cursor
on the CoCo 3s 40- and 80-
column text screens. Simply poke
this location with any value from
0 to 255 to change the rate. The
default value is 11. Lower values
increase the blink rate while larger
values make the cursor blink
slower. If you want to stop the Hi-
Res cursor from blinking alto-
gether, enter POKE63361,0. To
restart the blinking, enter POKE
63361,1,
Ken Ostrer
Vancouver, Washingron
Hint
HPRINT Shortened
When entering BASIC pro-
grams, | like to use the shorthand
version of the PRINT command
(typing a question mark instead of
typing out PRINT). Unfortu-
nately, if you try entering 4? on
the CoCo 3 (instead of HPRINT),
you will get a syntax error upon
running the program, To solve
this problem, enter the entire
listing using 42. Then save the
listing in ASCH format and re-
load it. All H? commands will be
changed to HPRINT.
Carl England
Calhoun, Georgia
Hint.
BASICally a Setup
In order to make using my
CoCo a little easier, I saved a
program on my utilities disk that
sets the printer baud rate, drive
selection and other parameters.
To make things even simpler, I
named the program *.Bas. Now
when I want to start working, 1
just enter RUN"* and let the com-
puter set itself up, much in the way
an AUTOEXEC file works on MS
DOS systems.
Harold Grumann
Auanta, Georgia
November 1988 THERAINBOW 83