READING AND SAVING SCREENS
Welcome back to First Steps. After last issue's
break from the trials and tribulations of programming your Atari,
it's time to get back to some programming. You'll never learn if we
keep chatting about other things!
In previous issues I have covered several graphics
topics and by now you should have had ample time to try your hand at
the graphic modes and maybe have even tried a little bit of
animation. Your program will draw a picture with its own
routines (PLOT, DRAWTO), but quite often you may wish to save the
picture for use elsewhere, or perhaps you wish to keep the same
program routines and load in different backgrounds. So how is it
done?
SLOW BUT SURE
First we need to find out what is on the screen.
If we were to set up a GRAPHICS 0 screen with some text on it, we
could look at every point on the screen (GRAPHICS 0, 24 lines and 40
columns = 960 points) and obtain the ASCII value of the character
using LOCATE. For example,
The number given is the memory location that
stores the value of the top left hand corner of the screen. Each
point on the screen is stored sequentially in memory from that
memory location.
So why use a pointer? Well, when different modes
are used the RAM is increased or decreased according to the amount
needed for that mode. The computer will shift the start of screen
RAM to compensate for this and as it varies so much, you need to
store the start of screen RAM somewhere so that you can keep track
of where the screen starts. The technique of pointers is used quite
a lot in the ATARI architecture.
Location 88 is equivalent to the units in
decimal counting and location 89 can be compared to the tens.
For instance, 21 in decimal is 1 +(10*2), so location 88 would store
the 1 (units) and location 89 would store the 2 (tens). In the case
of computers though groups of 256 are used instead of 10's, so a 1
in location 88 and a 2 in location 89 would equal 513. The reason
for the magic figure of 256 is simple. The memory chips have eight
read/write lines and each line has two states either ON or OFF
(just like a light switch). With two states and any combination of
eight lines the mathematicians amongst the readers will deduce that
you will have two to the power of eight possibilities 256!
Directly reading the screen RAM means that we can
do away with LOCATE and speed up the program. This can be
demonstrated by listing 2. This program is slightly faster due to
the reduced amount of program commands, but it is still very slow.
|
|
|
NOW HOW TO SAVE IT
So now that we have read our screen, where and how
can we store it?
Storage in memory can be in two forms, either as a
string or as a variable, both are temporary. The string can be held
until filled then transmitted to disk or tape all at once but the
variable must be transmitted at once otherwise the FOR/NEXT loop
will overwrite it on the next pass.
Using PUT/GET commands with a variable, the data
has to be passed to disk or tape one byte at a time. This may seem
to be slow but it allows the use of a device called the Input Output
Control Block (IOCB). This block is the socket you plug the tape or
drive into. It is controlled by certain locations in memory and, if
these locations are POKEd correctly then some great things can be
achieved.
When you connect the tape or disk lead into the
input/output socket of your computer you have given yourself a
choice of eight communication channels, 0 7 (remember OPEN #1,
etc?). Each channel has sixteen bytes of memory reserved for it in
RAM, from locations 832 to 959. You will be told by various
handbooks that you can use them all for your own use, all except
channel 0 that is, because it is reserved for the screen display.
This is not true, you can use the screen display, and to prove it I
will introduce you to the ATARI 'Forced Read Mode'. I must confess
though, this has been mentioned before in PAGE 6 by myself and
others, but can you have enough of a good thing?
In this mode the program will stop running (the
STOP command) and place information on the screen (using PRINT).
Then it will reposition the cursor above the new program lines and
enter the lines, directly from the screen, as if you had pressed
RETURN. The CONT command will start the program where it left off,
any new lines being run. LIST will show the modified program.
A self-modifying ATARI! LISTING 3 will demonstrate
this effect.
|
|
|
That's it for this issue. Next time we'll take a
closer look at those IOCB's. Meanwhile, don't forget that you can
write with your problems or to suggest further topics for the
column. Write to MARK HUTCHINSON, 1. HOLLYMOUNT, ERINVALE,
FINAGHY, BELFAST, BT1O OGL
_____
THE FIRST STEPS COMPUTER DICTIONARY continued
Chip A piece of semiconductor material
containing a microscopic integrated circuit.
Integrated circuit A tiny circuit in which
the electrical components are made of chemical elements diffused
into a piece of semiconductive material.
Character a single letter, number or symbol.
Daisy wheel A plastic disk with spokes used as the print
mechanism in letter quality printers.
Data information to be processed by a computer.
Database The entire collection of information available to
a computer. A structured collection of information, or a collection
of related files, considered as an entity.
Data set A modem. A collection of data
records with a logical relation to one another.
Device Handler A collection of routines that connect the
operating system and the user program with the input/output devices.
There is one handler for each type of peripheral device in the
hardware configuration.
Direct Memory Access Transfer of data between a peripheral
and main memory without intervention of the CPU.
More definitions next issue!