When it comes to writing your own programs, a lot more can be done
by using POKE statements than can be achieved using Basic. POKEs can
save memory, enable you to write faster and let your programs run a
bit faster. Following this introduction there is a list of locations
that you can experiment with, many of which are not in the Basic
Reference Manual. The experts amongst us can skip the introduction and
look at the list to see if they can spot any new ones. I make no
apologies if you do not, this article is mainly to help beginners.
What exactly is a memory location? It is the numeric position of a
Register - a piece of hardware, that holds a bit (no pun intended) of
information. Your Atari is what is termed an eight-bit machine which
means that each register can hold eight bits (0 to 7) of information
stored in BINARY (0 or 1). As all mathematical geniuses know, this is
equal to 2 to the power of 8, or 256. This collection of bits is known
as a BYTE and each Byte can hold a number up to 255 (0 is included).
Now the complications. A register can be used as a switch or a
store. As a store it will hold information in the form 0 to 255, 0
being used for the empty or switch off state. As a switch, you will
need to know the output lead that you want to switch. Binary is a
representation of decimal numbers in the form 0 or 1 (termed BINARY
CODED DECIMAL). This representation starts at 1. The next number is
1*2, or 2, and the next is 2*2, or 4, and so on up to 128. If you look
at figure 1, you will see a register with eight leads (1 to 8). If you
wish to turn on output 8, you need to make the register hold 128. This
is done by POKEing [Register No],128. Similarly, if you wish to turn
output 8 off then POKE with 0. You can turn any of the other outputs
on by POKEing with the appropriate number but what do you do if you
want to turn more than one lead on? Simple, you add together the
numbers of the leads you want on. For instance to turn on leads 4 and
6 POKE with 80. Try the short program listing to see how numbers
affect the byte.
Why is lead 1 in figure 1 equal to BIT 0? Well, mathematically, the
number stored is equal to 2 to the power of the bit. Any number to the
power of 0 is equal to 1 incidentally.
|
|
|
Let's now take a quick look at appendix 1 of the Basic Manual. In
some instances, a number greater than 255 needs to be stored and this
is done by assigning two memory locations. The first location (LEAST
SIGNIFICANT BYTE) will hold a number from 0 to 255 and when 256 is
reached, the second location (MOST SIGNIFICANT BYTE) holds 1 and the
first location returns to 0. How do you find out what is stored? Easy.
NUMBER STORED = 1st LOCATION +
2nd LOCATION * 256
Right, that's enough of the introductions, let's get down to some
real locations to PEEK and POKE
16
|
POKE 16,64 to
disable BREAK key. Complete keyboard disable is 0. Normal is
192. POKE these numbers into 53774 as well.
|
65
|
Input/Output noise flag. Tired of
listening to the noise of all those bytes being transferred?
Then POKE 65,0. |
87
|
Graphics Mode
register. Try 10 GR.18:POKE 87,0 followed by RUN and LIST. The
number you poke here refers to the Graphics mode required. It
does however depend on DISPLAY LIST pointers and POSITION
statements to operate it properly.
|
106
|
This location
gives the top of RAM in pages. By reducing this amount you can
store anything above the new RAMTOP. Basic won't know it's there
unless you tell it.
|
559
|
Use P=PEEK(559):
POKE 559,0 to turn off the screen. POKE 559,P to switch it back
on again. This is really Direct Memory Access Control (DMACTL)
and is used in PM Graphics. The screen can draw up to 30% faster
with the display off.
|
580
|
One of the nasties
used to protect programs. When you power up, everything in
memory is cleared. This is called COLDSTART. Hitting SYSTEM
RESET is called WARMSTART and keeps everything in RAM. POKE
580,1 turns SYSTEM RESET into COLDSTART and when you press
SYSTEM RESET, goodbye program. Normal is 0.
|
632-635
|
Instead of using
S=STICK(O), try PEEKing 632-635 for STICK(0-3).
|
644-647
|
Try the same for
STRIG(0-3).
|
656
|
Text window
cursor. POKE with 0 to 3 for placing text on a row.
|
657
|
Text window
cursor. POKE with 0 to 39 for placing text on a column. POSITION
statements relate only to the upper area and not the text
window.
|
842 |
Lets you write lines into a program
without stopping, e.g. 10 POKE 842,13:POS.2,13:? "100
SE.2,2,2":? "CONT": POS.0,0: STOP: POKE 842,12.
Now RUN it and LIST it. |
53279 |
Console switch register. 7=no key
pressed. 3=OPTION. 5=SELECT. 6=START. 4=SELECT and START.
2=OPTION and START. 1 =OPTION and SELECT. 0=all three pressed.
Also controls keyboard speaker by POKEing with 0-7 e.g. 10 FOR
P=1 TO 50:POKE 53279,0:FOR T=1 TO 40: NEXT T: NEXT P. |
53770 |
Random number generator e.g. 10 ?
INT(PEEK(53770)*100). |
54273 |
Character control hardware register.
Changes every 50th of a second. Use shadow location 755. Try
this 10 POKE 54273,4: FOR T= 1 TO 5: NEXT T: GOTO 10. |
You may have noticed a couple of words above which are worth
explaining further.
PAGE. When talking about RAM, it means 256 bytes.
256*6=1536, the location of free RAM that you can write to for your
own use (just like this magazine). Would you believe that's why they
are both called PAGE 6? Page 6 RAM is for storing your own data. It is
supposed to be a safe area but this is not 100% correct so be careful.
SHADOW LOCATION. Hardware registers are updated every screen
cycle (every 50th of a second). If you were to POKE these registers
directly the-information would change after just one cycle. The answer
is to write to a location which will store data and pass it to the
Hardware register on every pass. This is called the SHADOW. 54273 is a
hardware register and if you run the program above you will see it
being updated. The FOR . . NEXT loop slows it down for your benefit.
If you study these locations and the locations given in your Basic
Manual, then begin to experiment, you should end up with some pretty
good programs. Remember, the professionals use these tricks of the
trade. One final tip, if you RUN a program and you can BREAK it and
LIST it, then do so and study the PEEKs and POKEs that are used. If
the writer has used a form such as POKE HM,UO then just go to a free
area on your screen and ask your computer to work it out, e.g. ? HM,UO
and your ever friendly Atari will tell you what these variables are.
POKE a new number into the location, RUN it again and see what
happens. You can't damage the computer, at worst you may 'lock-up' and
will have to switch off and on again but for this small price you may
learn a lot.
top