Download Advancing Computer Knowledge

Transcript
SHAPE DEFINER
INPU T W IDTH OF SHAPE77
INPUT LENGTH OF SHAPE?15
IN PU T SHAPE PLOT C0DE70
BEG IN SHAPE D E F IN IT IO N
1.
2.
3.
A.
5.
6 .
COLOR
COLOR
COLOR
COLOR
COLOR
COLOR
C0DE70
C0DE70
C0DE70
C0DE70
C0DE71
CODE?
R 0W 700111 0 0
R0W7010 1 0 1 0
R0W7010 1 0 1 0
R 0W 700111 0 0
ROW7 0 0 0 1 0 0 0
ETC.
Figure 2: Sample run of Shape Definer.
graphics) for the game's name, scoring,
extra men, etc.
A pplesoft: To draw a shape on the
screen, the shape's X coordinate should
be POKEd into location 2302, the Y
coordinate into location 2301, and the
shape number into location 2303. If
you POKE a shape number that does
not have a shape defined for it, a ran­
dom mess will be drawn on the screen.
Similar problems arise when you POKE
a Y coordinate, which causes any part
of the shape to be drawn off the screen.
Try to avoid these situations. Calling
2048 draws your shape, exclusive-OR
style. This type of drawing is much like
the Applesoft X-Draw command. Call­
ing 2048 twice in succession with the
same X and Y coordinate draws the
shape first in full color and then erased
to black, leaving any original back­
ground intact. An important feature of
the graphics routine is its collision in­
dicator. If a shape is drawn and a colli­
sion with any other non-black dot is
detected, a value greater than 0 is
stored in lo c a tio n
2 2 9 8 . If
P = PEEK(2298] and P takes on a value
greater than 0, then a collision has oc­
curred. This value should be PEEKed
only after drawing a shape, not erasing
a shape.
The graphics routine presented here
is completely compatible with Apple­
soft and Applesoft graphics. However,
there is one problem — the graphics
routine resides in memory beginning at
hexadecimal location $800. As one ac­
quainted with Murphy's Law might ex­
pect, this is exactly where Applesoft
stores its variables and source code for
BASIC programs. Happily, this colli­
sion of data can be circumvented. Run
the program in listing 5 (Move It) and
pointers will be set to locate Applesoft
programs and variables above the hi-res
screen area. This insures that the
graphics routine, hi-res screen, and
Applesoft never meet. In Applesoft,
Move It must always be run before
loading a program, writing a program,
What’s Where in the Apple
A Complete Guide to the Apple Computer
This Revised Edition of the famous
Apple Atlas provides Apple
computerists with a framework for
understanding both the overall
structure of the Apple system and
programming techniques that
exploit that knowledge.
For owners of the original edition,
MICRO is offering a companion book,
THE GUIDE to What’s Where in the
Apple, for only $9.95 (plus $2.00 s/h).
THE GUIDE contains all new material
that explains and demonstrates how to
use the Atlas and Gazetteer published
in the original volume of W h a t’s
W hat’s Where in the Apple contains
the most complete memory map
ever published as well as detailed
information needed for actual
programming.
W here in the A p p le ?
All for only $24.95
For Fast Service
Call our toll free number:
1-800-354-8112
(plus $5.00 s/h)
M IC R O m a ke s it e a sy to order.
S end c h e c k (p a ya b le to MICRO) to:
(In PA 1-800-662-2444)
MICRO
P.O. Box 6502, Chelmsford, MA 01824
MA residents add 5% sales tax.
VISA and MasterCard accepted.
80
MICRO
No. 58 - M arch 1983