Home » Personal collection » Acorn ADFS disks » Electron_User_Group » EUG_38.ADF » +P3

+P3

This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.

Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.

Tape/disk: Home » Personal collection » Acorn ADFS disks » Electron_User_Group » EUG_38.ADF
Filename: +P3
Read OK:
File size: 157D bytes
Load address: 2B204556
Exec address: D3350
Duplicates

There is 1 duplicate copy of this file in the archive:

File contents
Earlier in the article, I mentioned several examples of screens which I have
done for EUG using saved screens using this technique. These included the
title screens for both Shipwrecked games, and also several EUG title
screens. You may have noticed that these were actually animated (see the
starfield in Jupiter 3 and the EUG 35 title). This was achieved by palette
switching as used in the previous article. If you look again at the
programming technique demonstration from this article (on EUG 36), and
select option 5, the same effect will appear on your screen. The same
principal was applied in both animated screens mentioned above - the only
difference is that in these title screens the pattern on screen which is
being palette switched is rather more complex. Shipwreck's title screen
(with the animated water scene) was also created in this way, except that
for this screen there was also a machine code program altering the contents
of screen memory as well, to enhance the effect.

So, we have a technique which allows us to store a small number of very
detailed screens on floppy, and recall then at very great speed. But what if
we want to use this method for a large number of screens? And what if we
want a situation like a game, where the user can move sprites on the screen
around. This can also be done by altering the values in screen memory
directly, but in a different way...

2. Editing screen memory

The basic idea is this: in any program, you only usually require a
certain, small number of little 'blocks' to make up a whole picture. In a
word processor, for example, you only need the letters of the alphabet to
appear on the screen. These letters are small blocks of graphics which
appear on your screen (called characters). Because only these 26 blocks
are required, the word processor does not need to store every letter as
all of the pixels which make it up (ie. as a bitmap), but just as a code
for that particular letter. When the word processor wants to display a
letter on the screen, it looks up the letter code, and then copies the
graphic data for what that letter looks like onto the screen. Therefore,
the graphic data for what colour all of the pixels should be for that
particular letter (which might take several bytes) need only be stored
once, and that letter can be stored in your script in just one byte, for
the letter code. Thus, the memory taken up by your script is reduced
dramatically.

The same principal can be used in graphics. Look at two brick walls in an
arcade adventure such as Shipwrecked - can you see the difference between
them? If they are the same, surely you only need to store the graphic data
for a brick wall once, and then copy it onto the screen whenever you want
a brick wall. In Shipwrecked, for example, the graphic data to describe
what a brick wall looks like took 128 bytes. Yet every time I wanted that
brick wall (which was over a hundred times) I could simply use one byte to
say "Put a brick wall here!".

The easiest way to use this block idea, as you may already have realised,
is using user defined characters. You redefine the letters of the alphabet
as different pictures, and then use the standard BASIC PRINT command to
output these pictures to the screen, as and when they are required. But,
as we already realised in the last article, this only allows you to use
one colour in each character. Even so, this is a reasonable technique if
you don't mind the lack of colour. Many commercial games actually never
addressed this problem, and had graphics which lacked colour somewhat.
Even Dizzy (for those who have never heard of it, a great arcade adventure
of the 1980s, which caused quite a cult following at the time on the
Spectrum and C64, but never quite reached the Elk) did not have more than
one colour (other than black) per block. Different blocks were, however,
different colours - trees were green and the ground was red - but there
was never any overlap between the two colour areas.

There is, however, a way of creating an effect just like user defined
characters, but in full colour, and the principal is very similar to that
used before in saving screen memory. Basically, you design you small block
on the screen, using whatever technique you like to draw it, and then save
the small part of screen memory which contains your design. This time,
however, you will not save it to floppy disc, but to another area of
memory. You can then copy this block back to screen memory whenever and
wherever you want it. If you want it, say, in the fifth row down, and
twelve characters along, you can calculate where abouts this corresponds
to in screen memory, and copy the block to this location. As the block is
stored in your computer's RAM, as opposed to on floppy, this transfer can
be done by machine code at very great speed (taking only a small fraction
of a second). For those programmers who are not familiar with machine
code, a module is included with this tutorial allowing you to do this. The
program code for this module is actually taken directly from Shipwrecked.

If you are not familiar with machine code, then you can probably skip the
next section on how to directly access screen memory, as it is impossible
to achieve any speed by accessing screen memory directly in BASIC - your
program will crawl along incredibly slowly. You could still use such a
technique in preparing a screen which you intend to save to floppy using
the technique described before with *SAVE and *LOAD.

00000000  0d 45 61 72 6c 69 65 72  20 69 6e 20 74 68 65 20  |.Earlier in the |
00000010  61 72 74 69 63 6c 65 2c  20 49 20 6d 65 6e 74 69  |article, I menti|
00000020  6f 6e 65 64 20 73 65 76  65 72 61 6c 20 65 78 61  |oned several exa|
00000030  6d 70 6c 65 73 20 6f 66  20 73 63 72 65 65 6e 73  |mples of screens|
00000040  20 77 68 69 63 68 20 49  20 68 61 76 65 0d 64 6f  | which I have.do|
00000050  6e 65 20 66 6f 72 20 45  55 47 20 75 73 69 6e 67  |ne for EUG using|
00000060  20 73 61 76 65 64 20 73  63 72 65 65 6e 73 20 75  | saved screens u|
00000070  73 69 6e 67 20 74 68 69  73 20 74 65 63 68 6e 69  |sing this techni|
00000080  71 75 65 2e 20 54 68 65  73 65 20 69 6e 63 6c 75  |que. These inclu|
00000090  64 65 64 20 74 68 65 0d  74 69 74 6c 65 20 73 63  |ded the.title sc|
000000a0  72 65 65 6e 73 20 66 6f  72 20 62 6f 74 68 20 53  |reens for both S|
000000b0  68 69 70 77 72 65 63 6b  65 64 20 67 61 6d 65 73  |hipwrecked games|
000000c0  2c 20 61 6e 64 20 61 6c  73 6f 20 73 65 76 65 72  |, and also sever|
000000d0  61 6c 20 45 55 47 20 74  69 74 6c 65 0d 73 63 72  |al EUG title.scr|
000000e0  65 65 6e 73 2e 20 59 6f  75 20 6d 61 79 20 68 61  |eens. You may ha|
000000f0  76 65 20 6e 6f 74 69 63  65 64 20 74 68 61 74 20  |ve noticed that |
00000100  74 68 65 73 65 20 77 65  72 65 20 61 63 74 75 61  |these were actua|
00000110  6c 6c 79 20 61 6e 69 6d  61 74 65 64 20 28 73 65  |lly animated (se|
00000120  65 20 74 68 65 0d 73 74  61 72 66 69 65 6c 64 20  |e the.starfield |
00000130  69 6e 20 4a 75 70 69 74  65 72 20 33 20 61 6e 64  |in Jupiter 3 and|
00000140  20 74 68 65 20 45 55 47  20 33 35 20 74 69 74 6c  | the EUG 35 titl|
00000150  65 29 2e 20 54 68 69 73  20 77 61 73 20 61 63 68  |e). This was ach|
00000160  69 65 76 65 64 20 62 79  20 70 61 6c 65 74 74 65  |ieved by palette|
00000170  0d 73 77 69 74 63 68 69  6e 67 20 61 73 20 75 73  |.switching as us|
00000180  65 64 20 69 6e 20 74 68  65 20 70 72 65 76 69 6f  |ed in the previo|
00000190  75 73 20 61 72 74 69 63  6c 65 2e 20 49 66 20 79  |us article. If y|
000001a0  6f 75 20 6c 6f 6f 6b 20  61 67 61 69 6e 20 61 74  |ou look again at|
000001b0  20 74 68 65 0d 70 72 6f  67 72 61 6d 6d 69 6e 67  | the.programming|
000001c0  20 74 65 63 68 6e 69 71  75 65 20 64 65 6d 6f 6e  | technique demon|
000001d0  73 74 72 61 74 69 6f 6e  20 66 72 6f 6d 20 74 68  |stration from th|
000001e0  69 73 20 61 72 74 69 63  6c 65 20 28 6f 6e 20 45  |is article (on E|
000001f0  55 47 20 33 36 29 2c 20  61 6e 64 0d 73 65 6c 65  |UG 36), and.sele|
00000200  63 74 20 6f 70 74 69 6f  6e 20 35 2c 20 74 68 65  |ct option 5, the|
00000210  20 73 61 6d 65 20 65 66  66 65 63 74 20 77 69 6c  | same effect wil|
00000220  6c 20 61 70 70 65 61 72  20 6f 6e 20 79 6f 75 72  |l appear on your|
00000230  20 73 63 72 65 65 6e 2e  20 54 68 65 20 73 61 6d  | screen. The sam|
00000240  65 0d 70 72 69 6e 63 69  70 61 6c 20 77 61 73 20  |e.principal was |
00000250  61 70 70 6c 69 65 64 20  69 6e 20 62 6f 74 68 20  |applied in both |
00000260  61 6e 69 6d 61 74 65 64  20 73 63 72 65 65 6e 73  |animated screens|
00000270  20 6d 65 6e 74 69 6f 6e  65 64 20 61 62 6f 76 65  | mentioned above|
00000280  20 2d 20 74 68 65 20 6f  6e 6c 79 0d 64 69 66 66  | - the only.diff|
00000290  65 72 65 6e 63 65 20 69  73 20 74 68 61 74 20 69  |erence is that i|
000002a0  6e 20 74 68 65 73 65 20  74 69 74 6c 65 20 73 63  |n these title sc|
000002b0  72 65 65 6e 73 20 74 68  65 20 70 61 74 74 65 72  |reens the patter|
000002c0  6e 20 6f 6e 20 73 63 72  65 65 6e 20 77 68 69 63  |n on screen whic|
000002d0  68 20 69 73 0d 62 65 69  6e 67 20 70 61 6c 65 74  |h is.being palet|
000002e0  74 65 20 73 77 69 74 63  68 65 64 20 69 73 20 72  |te switched is r|
000002f0  61 74 68 65 72 20 6d 6f  72 65 20 63 6f 6d 70 6c  |ather more compl|
00000300  65 78 2e 20 53 68 69 70  77 72 65 63 6b 27 73 20  |ex. Shipwreck's |
00000310  74 69 74 6c 65 20 73 63  72 65 65 6e 0d 28 77 69  |title screen.(wi|
00000320  74 68 20 74 68 65 20 61  6e 69 6d 61 74 65 64 20  |th the animated |
00000330  77 61 74 65 72 20 73 63  65 6e 65 29 20 77 61 73  |water scene) was|
00000340  20 61 6c 73 6f 20 63 72  65 61 74 65 64 20 69 6e  | also created in|
00000350  20 74 68 69 73 20 77 61  79 2c 20 65 78 63 65 70  | this way, excep|
00000360  74 20 74 68 61 74 0d 66  6f 72 20 74 68 69 73 20  |t that.for this |
00000370  73 63 72 65 65 6e 20 74  68 65 72 65 20 77 61 73  |screen there was|
00000380  20 61 6c 73 6f 20 61 20  6d 61 63 68 69 6e 65 20  | also a machine |
00000390  63 6f 64 65 20 70 72 6f  67 72 61 6d 20 61 6c 74  |code program alt|
000003a0  65 72 69 6e 67 20 74 68  65 20 63 6f 6e 74 65 6e  |ering the conten|
000003b0  74 73 0d 6f 66 20 73 63  72 65 65 6e 20 6d 65 6d  |ts.of screen mem|
000003c0  6f 72 79 20 61 73 20 77  65 6c 6c 2c 20 74 6f 20  |ory as well, to |
000003d0  65 6e 68 61 6e 63 65 20  74 68 65 20 65 66 66 65  |enhance the effe|
000003e0  63 74 2e 0d 0d 53 6f 2c  20 77 65 20 68 61 76 65  |ct...So, we have|
000003f0  20 61 20 74 65 63 68 6e  69 71 75 65 20 77 68 69  | a technique whi|
00000400  63 68 20 61 6c 6c 6f 77  73 20 75 73 20 74 6f 20  |ch allows us to |
00000410  73 74 6f 72 65 20 61 20  73 6d 61 6c 6c 20 6e 75  |store a small nu|
00000420  6d 62 65 72 20 6f 66 20  76 65 72 79 0d 64 65 74  |mber of very.det|
00000430  61 69 6c 65 64 20 73 63  72 65 65 6e 73 20 6f 6e  |ailed screens on|
00000440  20 66 6c 6f 70 70 79 2c  20 61 6e 64 20 72 65 63  | floppy, and rec|
00000450  61 6c 6c 20 74 68 65 6e  20 61 74 20 76 65 72 79  |all then at very|
00000460  20 67 72 65 61 74 20 73  70 65 65 64 2e 20 42 75  | great speed. Bu|
00000470  74 20 77 68 61 74 20 69  66 0d 77 65 20 77 61 6e  |t what if.we wan|
00000480  74 20 74 6f 20 75 73 65  20 74 68 69 73 20 6d 65  |t to use this me|
00000490  74 68 6f 64 20 66 6f 72  20 61 20 6c 61 72 67 65  |thod for a large|
000004a0  20 6e 75 6d 62 65 72 20  6f 66 20 73 63 72 65 65  | number of scree|
000004b0  6e 73 3f 20 41 6e 64 20  77 68 61 74 20 69 66 20  |ns? And what if |
000004c0  77 65 0d 77 61 6e 74 20  61 20 73 69 74 75 61 74  |we.want a situat|
000004d0  69 6f 6e 20 6c 69 6b 65  20 61 20 67 61 6d 65 2c  |ion like a game,|
000004e0  20 77 68 65 72 65 20 74  68 65 20 75 73 65 72 20  | where the user |
000004f0  63 61 6e 20 6d 6f 76 65  20 73 70 72 69 74 65 73  |can move sprites|
00000500  20 6f 6e 20 74 68 65 20  73 63 72 65 65 6e 0d 61  | on the screen.a|
00000510  72 6f 75 6e 64 2e 20 54  68 69 73 20 63 61 6e 20  |round. This can |
00000520  61 6c 73 6f 20 62 65 20  64 6f 6e 65 20 62 79 20  |also be done by |
00000530  61 6c 74 65 72 69 6e 67  20 74 68 65 20 76 61 6c  |altering the val|
00000540  75 65 73 20 69 6e 20 73  63 72 65 65 6e 20 6d 65  |ues in screen me|
00000550  6d 6f 72 79 0d 64 69 72  65 63 74 6c 79 2c 20 62  |mory.directly, b|
00000560  75 74 20 69 6e 20 61 20  64 69 66 66 65 72 65 6e  |ut in a differen|
00000570  74 20 77 61 79 2e 2e 2e  0d 0d 32 2e 20 45 64 69  |t way.....2. Edi|
00000580  74 69 6e 67 20 73 63 72  65 65 6e 20 6d 65 6d 6f  |ting screen memo|
00000590  72 79 0d 0d 54 68 65 20  62 61 73 69 63 20 69 64  |ry..The basic id|
000005a0  65 61 20 69 73 20 74 68  69 73 3a 20 69 6e 20 61  |ea is this: in a|
000005b0  6e 79 20 70 72 6f 67 72  61 6d 2c 20 79 6f 75 20  |ny program, you |
000005c0  6f 6e 6c 79 20 75 73 75  61 6c 6c 79 20 72 65 71  |only usually req|
000005d0  75 69 72 65 20 61 0d 63  65 72 74 61 69 6e 2c 20  |uire a.certain, |
000005e0  73 6d 61 6c 6c 20 6e 75  6d 62 65 72 20 6f 66 20  |small number of |
000005f0  6c 69 74 74 6c 65 20 27  62 6c 6f 63 6b 73 27 20  |little 'blocks' |
00000600  74 6f 20 6d 61 6b 65 20  75 70 20 61 20 77 68 6f  |to make up a who|
00000610  6c 65 20 70 69 63 74 75  72 65 2e 20 49 6e 20 61  |le picture. In a|
00000620  0d 77 6f 72 64 20 70 72  6f 63 65 73 73 6f 72 2c  |.word processor,|
00000630  20 66 6f 72 20 65 78 61  6d 70 6c 65 2c 20 79 6f  | for example, yo|
00000640  75 20 6f 6e 6c 79 20 6e  65 65 64 20 74 68 65 20  |u only need the |
00000650  6c 65 74 74 65 72 73 20  6f 66 20 74 68 65 20 61  |letters of the a|
00000660  6c 70 68 61 62 65 74 20  74 6f 0d 61 70 70 65 61  |lphabet to.appea|
00000670  72 20 6f 6e 20 74 68 65  20 73 63 72 65 65 6e 2e  |r on the screen.|
00000680  20 54 68 65 73 65 20 6c  65 74 74 65 72 73 20 61  | These letters a|
00000690  72 65 20 73 6d 61 6c 6c  20 62 6c 6f 63 6b 73 20  |re small blocks |
000006a0  6f 66 20 67 72 61 70 68  69 63 73 20 77 68 69 63  |of graphics whic|
000006b0  68 0d 61 70 70 65 61 72  20 6f 6e 20 79 6f 75 72  |h.appear on your|
000006c0  20 73 63 72 65 65 6e 20  28 63 61 6c 6c 65 64 20  | screen (called |
000006d0  63 68 61 72 61 63 74 65  72 73 29 2e 20 42 65 63  |characters). Bec|
000006e0  61 75 73 65 20 6f 6e 6c  79 20 74 68 65 73 65 20  |ause only these |
000006f0  32 36 20 62 6c 6f 63 6b  73 0d 61 72 65 20 72 65  |26 blocks.are re|
00000700  71 75 69 72 65 64 2c 20  74 68 65 20 77 6f 72 64  |quired, the word|
00000710  20 70 72 6f 63 65 73 73  6f 72 20 64 6f 65 73 20  | processor does |
00000720  6e 6f 74 20 6e 65 65 64  20 74 6f 20 73 74 6f 72  |not need to stor|
00000730  65 20 65 76 65 72 79 20  6c 65 74 74 65 72 20 61  |e every letter a|
00000740  73 0d 61 6c 6c 20 6f 66  20 74 68 65 20 70 69 78  |s.all of the pix|
00000750  65 6c 73 20 77 68 69 63  68 20 6d 61 6b 65 20 69  |els which make i|
00000760  74 20 75 70 20 28 69 65  2e 20 61 73 20 61 20 62  |t up (ie. as a b|
00000770  69 74 6d 61 70 29 2c 20  62 75 74 20 6a 75 73 74  |itmap), but just|
00000780  20 61 73 20 61 20 63 6f  64 65 0d 66 6f 72 20 74  | as a code.for t|
00000790  68 61 74 20 70 61 72 74  69 63 75 6c 61 72 20 6c  |hat particular l|
000007a0  65 74 74 65 72 2e 20 57  68 65 6e 20 74 68 65 20  |etter. When the |
000007b0  77 6f 72 64 20 70 72 6f  63 65 73 73 6f 72 20 77  |word processor w|
000007c0  61 6e 74 73 20 74 6f 20  64 69 73 70 6c 61 79 20  |ants to display |
000007d0  61 0d 6c 65 74 74 65 72  20 6f 6e 20 74 68 65 20  |a.letter on the |
000007e0  73 63 72 65 65 6e 2c 20  69 74 20 6c 6f 6f 6b 73  |screen, it looks|
000007f0  20 75 70 20 74 68 65 20  6c 65 74 74 65 72 20 63  | up the letter c|
00000800  6f 64 65 2c 20 61 6e 64  20 74 68 65 6e 20 63 6f  |ode, and then co|
00000810  70 69 65 73 20 74 68 65  0d 67 72 61 70 68 69 63  |pies the.graphic|
00000820  20 64 61 74 61 20 66 6f  72 20 77 68 61 74 20 74  | data for what t|
00000830  68 61 74 20 6c 65 74 74  65 72 20 6c 6f 6f 6b 73  |hat letter looks|
00000840  20 6c 69 6b 65 20 6f 6e  74 6f 20 74 68 65 20 73  | like onto the s|
00000850  63 72 65 65 6e 2e 20 54  68 65 72 65 66 6f 72 65  |creen. Therefore|
00000860  2c 0d 74 68 65 20 67 72  61 70 68 69 63 20 64 61  |,.the graphic da|
00000870  74 61 20 66 6f 72 20 77  68 61 74 20 63 6f 6c 6f  |ta for what colo|
00000880  75 72 20 61 6c 6c 20 6f  66 20 74 68 65 20 70 69  |ur all of the pi|
00000890  78 65 6c 73 20 73 68 6f  75 6c 64 20 62 65 20 66  |xels should be f|
000008a0  6f 72 20 74 68 61 74 0d  70 61 72 74 69 63 75 6c  |or that.particul|
000008b0  61 72 20 6c 65 74 74 65  72 20 28 77 68 69 63 68  |ar letter (which|
000008c0  20 6d 69 67 68 74 20 74  61 6b 65 20 73 65 76 65  | might take seve|
000008d0  72 61 6c 20 62 79 74 65  73 29 20 6e 65 65 64 20  |ral bytes) need |
000008e0  6f 6e 6c 79 20 62 65 20  73 74 6f 72 65 64 0d 6f  |only be stored.o|
000008f0  6e 63 65 2c 20 61 6e 64  20 74 68 61 74 20 6c 65  |nce, and that le|
00000900  74 74 65 72 20 63 61 6e  20 62 65 20 73 74 6f 72  |tter can be stor|
00000910  65 64 20 69 6e 20 79 6f  75 72 20 73 63 72 69 70  |ed in your scrip|
00000920  74 20 69 6e 20 6a 75 73  74 20 6f 6e 65 20 62 79  |t in just one by|
00000930  74 65 2c 20 66 6f 72 0d  74 68 65 20 6c 65 74 74  |te, for.the lett|
00000940  65 72 20 63 6f 64 65 2e  20 54 68 75 73 2c 20 74  |er code. Thus, t|
00000950  68 65 20 6d 65 6d 6f 72  79 20 74 61 6b 65 6e 20  |he memory taken |
00000960  75 70 20 62 79 20 79 6f  75 72 20 73 63 72 69 70  |up by your scrip|
00000970  74 20 69 73 20 72 65 64  75 63 65 64 0d 64 72 61  |t is reduced.dra|
00000980  6d 61 74 69 63 61 6c 6c  79 2e 0d 0d 54 68 65 20  |matically...The |
00000990  73 61 6d 65 20 70 72 69  6e 63 69 70 61 6c 20 63  |same principal c|
000009a0  61 6e 20 62 65 20 75 73  65 64 20 69 6e 20 67 72  |an be used in gr|
000009b0  61 70 68 69 63 73 2e 20  4c 6f 6f 6b 20 61 74 20  |aphics. Look at |
000009c0  74 77 6f 20 62 72 69 63  6b 20 77 61 6c 6c 73 20  |two brick walls |
000009d0  69 6e 20 61 6e 0d 61 72  63 61 64 65 20 61 64 76  |in an.arcade adv|
000009e0  65 6e 74 75 72 65 20 73  75 63 68 20 61 73 20 53  |enture such as S|
000009f0  68 69 70 77 72 65 63 6b  65 64 20 2d 20 63 61 6e  |hipwrecked - can|
00000a00  20 79 6f 75 20 73 65 65  20 74 68 65 20 64 69 66  | you see the dif|
00000a10  66 65 72 65 6e 63 65 20  62 65 74 77 65 65 6e 0d  |ference between.|
00000a20  74 68 65 6d 3f 20 49 66  20 74 68 65 79 20 61 72  |them? If they ar|
00000a30  65 20 74 68 65 20 73 61  6d 65 2c 20 73 75 72 65  |e the same, sure|
00000a40  6c 79 20 79 6f 75 20 6f  6e 6c 79 20 6e 65 65 64  |ly you only need|
00000a50  20 74 6f 20 73 74 6f 72  65 20 74 68 65 20 67 72  | to store the gr|
00000a60  61 70 68 69 63 20 64 61  74 61 0d 66 6f 72 20 61  |aphic data.for a|
00000a70  20 62 72 69 63 6b 20 77  61 6c 6c 20 6f 6e 63 65  | brick wall once|
00000a80  2c 20 61 6e 64 20 74 68  65 6e 20 63 6f 70 79 20  |, and then copy |
00000a90  69 74 20 6f 6e 74 6f 20  74 68 65 20 73 63 72 65  |it onto the scre|
00000aa0  65 6e 20 77 68 65 6e 65  76 65 72 20 79 6f 75 20  |en whenever you |
00000ab0  77 61 6e 74 0d 61 20 62  72 69 63 6b 20 77 61 6c  |want.a brick wal|
00000ac0  6c 2e 20 49 6e 20 53 68  69 70 77 72 65 63 6b 65  |l. In Shipwrecke|
00000ad0  64 2c 20 66 6f 72 20 65  78 61 6d 70 6c 65 2c 20  |d, for example, |
00000ae0  74 68 65 20 67 72 61 70  68 69 63 20 64 61 74 61  |the graphic data|
00000af0  20 74 6f 20 64 65 73 63  72 69 62 65 0d 77 68 61  | to describe.wha|
00000b00  74 20 61 20 62 72 69 63  6b 20 77 61 6c 6c 20 6c  |t a brick wall l|
00000b10  6f 6f 6b 73 20 6c 69 6b  65 20 74 6f 6f 6b 20 31  |ooks like took 1|
00000b20  32 38 20 62 79 74 65 73  2e 20 59 65 74 20 65 76  |28 bytes. Yet ev|
00000b30  65 72 79 20 74 69 6d 65  20 49 20 77 61 6e 74 65  |ery time I wante|
00000b40  64 20 74 68 61 74 0d 62  72 69 63 6b 20 77 61 6c  |d that.brick wal|
00000b50  6c 20 28 77 68 69 63 68  20 77 61 73 20 6f 76 65  |l (which was ove|
00000b60  72 20 61 20 68 75 6e 64  72 65 64 20 74 69 6d 65  |r a hundred time|
00000b70  73 29 20 49 20 63 6f 75  6c 64 20 73 69 6d 70 6c  |s) I could simpl|
00000b80  79 20 75 73 65 20 6f 6e  65 20 62 79 74 65 20 74  |y use one byte t|
00000b90  6f 0d 73 61 79 20 22 50  75 74 20 61 20 62 72 69  |o.say "Put a bri|
00000ba0  63 6b 20 77 61 6c 6c 20  68 65 72 65 21 22 2e 0d  |ck wall here!"..|
00000bb0  0d 54 68 65 20 65 61 73  69 65 73 74 20 77 61 79  |.The easiest way|
00000bc0  20 74 6f 20 75 73 65 20  74 68 69 73 20 62 6c 6f  | to use this blo|
00000bd0  63 6b 20 69 64 65 61 2c  20 61 73 20 79 6f 75 20  |ck idea, as you |
00000be0  6d 61 79 20 61 6c 72 65  61 64 79 20 68 61 76 65  |may already have|
00000bf0  20 72 65 61 6c 69 73 65  64 2c 0d 69 73 20 75 73  | realised,.is us|
00000c00  69 6e 67 20 75 73 65 72  20 64 65 66 69 6e 65 64  |ing user defined|
00000c10  20 63 68 61 72 61 63 74  65 72 73 2e 20 59 6f 75  | characters. You|
00000c20  20 72 65 64 65 66 69 6e  65 20 74 68 65 20 6c 65  | redefine the le|
00000c30  74 74 65 72 73 20 6f 66  20 74 68 65 20 61 6c 70  |tters of the alp|
00000c40  68 61 62 65 74 0d 61 73  20 64 69 66 66 65 72 65  |habet.as differe|
00000c50  6e 74 20 70 69 63 74 75  72 65 73 2c 20 61 6e 64  |nt pictures, and|
00000c60  20 74 68 65 6e 20 75 73  65 20 74 68 65 20 73 74  | then use the st|
00000c70  61 6e 64 61 72 64 20 42  41 53 49 43 20 50 52 49  |andard BASIC PRI|
00000c80  4e 54 20 63 6f 6d 6d 61  6e 64 20 74 6f 0d 6f 75  |NT command to.ou|
00000c90  74 70 75 74 20 74 68 65  73 65 20 70 69 63 74 75  |tput these pictu|
00000ca0  72 65 73 20 74 6f 20 74  68 65 20 73 63 72 65 65  |res to the scree|
00000cb0  6e 2c 20 61 73 20 61 6e  64 20 77 68 65 6e 20 74  |n, as and when t|
00000cc0  68 65 79 20 61 72 65 20  72 65 71 75 69 72 65 64  |hey are required|
00000cd0  2e 20 42 75 74 2c 0d 61  73 20 77 65 20 61 6c 72  |. But,.as we alr|
00000ce0  65 61 64 79 20 72 65 61  6c 69 73 65 64 20 69 6e  |eady realised in|
00000cf0  20 74 68 65 20 6c 61 73  74 20 61 72 74 69 63 6c  | the last articl|
00000d00  65 2c 20 74 68 69 73 20  6f 6e 6c 79 20 61 6c 6c  |e, this only all|
00000d10  6f 77 73 20 79 6f 75 20  74 6f 20 75 73 65 0d 6f  |ows you to use.o|
00000d20  6e 65 20 63 6f 6c 6f 75  72 20 69 6e 20 65 61 63  |ne colour in eac|
00000d30  68 20 63 68 61 72 61 63  74 65 72 2e 20 45 76 65  |h character. Eve|
00000d40  6e 20 73 6f 2c 20 74 68  69 73 20 69 73 20 61 20  |n so, this is a |
00000d50  72 65 61 73 6f 6e 61 62  6c 65 20 74 65 63 68 6e  |reasonable techn|
00000d60  69 71 75 65 20 69 66 0d  79 6f 75 20 64 6f 6e 27  |ique if.you don'|
00000d70  74 20 6d 69 6e 64 20 74  68 65 20 6c 61 63 6b 20  |t mind the lack |
00000d80  6f 66 20 63 6f 6c 6f 75  72 2e 20 4d 61 6e 79 20  |of colour. Many |
00000d90  63 6f 6d 6d 65 72 63 69  61 6c 20 67 61 6d 65 73  |commercial games|
00000da0  20 61 63 74 75 61 6c 6c  79 20 6e 65 76 65 72 0d  | actually never.|
00000db0  61 64 64 72 65 73 73 65  64 20 74 68 69 73 20 70  |addressed this p|
00000dc0  72 6f 62 6c 65 6d 2c 20  61 6e 64 20 68 61 64 20  |roblem, and had |
00000dd0  67 72 61 70 68 69 63 73  20 77 68 69 63 68 20 6c  |graphics which l|
00000de0  61 63 6b 65 64 20 63 6f  6c 6f 75 72 20 73 6f 6d  |acked colour som|
00000df0  65 77 68 61 74 2e 0d 45  76 65 6e 20 44 69 7a 7a  |ewhat..Even Dizz|
00000e00  79 20 28 66 6f 72 20 74  68 6f 73 65 20 77 68 6f  |y (for those who|
00000e10  20 68 61 76 65 20 6e 65  76 65 72 20 68 65 61 72  | have never hear|
00000e20  64 20 6f 66 20 69 74 2c  20 61 20 67 72 65 61 74  |d of it, a great|
00000e30  20 61 72 63 61 64 65 20  61 64 76 65 6e 74 75 72  | arcade adventur|
00000e40  65 0d 6f 66 20 74 68 65  20 31 39 38 30 73 2c 20  |e.of the 1980s, |
00000e50  77 68 69 63 68 20 63 61  75 73 65 64 20 71 75 69  |which caused qui|
00000e60  74 65 20 61 20 63 75 6c  74 20 66 6f 6c 6c 6f 77  |te a cult follow|
00000e70  69 6e 67 20 61 74 20 74  68 65 20 74 69 6d 65 20  |ing at the time |
00000e80  6f 6e 20 74 68 65 0d 53  70 65 63 74 72 75 6d 20  |on the.Spectrum |
00000e90  61 6e 64 20 43 36 34 2c  20 62 75 74 20 6e 65 76  |and C64, but nev|
00000ea0  65 72 20 71 75 69 74 65  20 72 65 61 63 68 65 64  |er quite reached|
00000eb0  20 74 68 65 20 45 6c 6b  29 20 64 69 64 20 6e 6f  | the Elk) did no|
00000ec0  74 20 68 61 76 65 20 6d  6f 72 65 20 74 68 61 6e  |t have more than|
00000ed0  0d 6f 6e 65 20 63 6f 6c  6f 75 72 20 28 6f 74 68  |.one colour (oth|
00000ee0  65 72 20 74 68 61 6e 20  62 6c 61 63 6b 29 20 70  |er than black) p|
00000ef0  65 72 20 62 6c 6f 63 6b  2e 20 44 69 66 66 65 72  |er block. Differ|
00000f00  65 6e 74 20 62 6c 6f 63  6b 73 20 77 65 72 65 2c  |ent blocks were,|
00000f10  20 68 6f 77 65 76 65 72  2c 0d 64 69 66 66 65 72  | however,.differ|
00000f20  65 6e 74 20 63 6f 6c 6f  75 72 73 20 2d 20 74 72  |ent colours - tr|
00000f30  65 65 73 20 77 65 72 65  20 67 72 65 65 6e 20 61  |ees were green a|
00000f40  6e 64 20 74 68 65 20 67  72 6f 75 6e 64 20 77 61  |nd the ground wa|
00000f50  73 20 72 65 64 20 2d 20  62 75 74 20 74 68 65 72  |s red - but ther|
00000f60  65 0d 77 61 73 20 6e 65  76 65 72 20 61 6e 79 20  |e.was never any |
00000f70  6f 76 65 72 6c 61 70 20  62 65 74 77 65 65 6e 20  |overlap between |
00000f80  74 68 65 20 74 77 6f 20  63 6f 6c 6f 75 72 20 61  |the two colour a|
00000f90  72 65 61 73 2e 0d 0d 54  68 65 72 65 20 69 73 2c  |reas...There is,|
00000fa0  20 68 6f 77 65 76 65 72  2c 20 61 20 77 61 79 20  | however, a way |
00000fb0  6f 66 20 63 72 65 61 74  69 6e 67 20 61 6e 20 65  |of creating an e|
00000fc0  66 66 65 63 74 20 6a 75  73 74 20 6c 69 6b 65 20  |ffect just like |
00000fd0  75 73 65 72 20 64 65 66  69 6e 65 64 0d 63 68 61  |user defined.cha|
00000fe0  72 61 63 74 65 72 73 2c  20 62 75 74 20 69 6e 20  |racters, but in |
00000ff0  66 75 6c 6c 20 63 6f 6c  6f 75 72 2c 20 61 6e 64  |full colour, and|
00001000  20 74 68 65 20 70 72 69  6e 63 69 70 61 6c 20 69  | the principal i|
00001010  73 20 76 65 72 79 20 73  69 6d 69 6c 61 72 20 74  |s very similar t|
00001020  6f 20 74 68 61 74 0d 75  73 65 64 20 62 65 66 6f  |o that.used befo|
00001030  72 65 20 69 6e 20 73 61  76 69 6e 67 20 73 63 72  |re in saving scr|
00001040  65 65 6e 20 6d 65 6d 6f  72 79 2e 20 42 61 73 69  |een memory. Basi|
00001050  63 61 6c 6c 79 2c 20 79  6f 75 20 64 65 73 69 67  |cally, you desig|
00001060  6e 20 79 6f 75 20 73 6d  61 6c 6c 20 62 6c 6f 63  |n you small bloc|
00001070  6b 0d 6f 6e 20 74 68 65  20 73 63 72 65 65 6e 2c  |k.on the screen,|
00001080  20 75 73 69 6e 67 20 77  68 61 74 65 76 65 72 20  | using whatever |
00001090  74 65 63 68 6e 69 71 75  65 20 79 6f 75 20 6c 69  |technique you li|
000010a0  6b 65 20 74 6f 20 64 72  61 77 20 69 74 2c 20 61  |ke to draw it, a|
000010b0  6e 64 20 74 68 65 6e 20  73 61 76 65 0d 74 68 65  |nd then save.the|
000010c0  20 73 6d 61 6c 6c 20 70  61 72 74 20 6f 66 20 73  | small part of s|
000010d0  63 72 65 65 6e 20 6d 65  6d 6f 72 79 20 77 68 69  |creen memory whi|
000010e0  63 68 20 63 6f 6e 74 61  69 6e 73 20 79 6f 75 72  |ch contains your|
000010f0  20 64 65 73 69 67 6e 2e  20 54 68 69 73 20 74 69  | design. This ti|
00001100  6d 65 2c 0d 68 6f 77 65  76 65 72 2c 20 79 6f 75  |me,.however, you|
00001110  20 77 69 6c 6c 20 6e 6f  74 20 73 61 76 65 20 69  | will not save i|
00001120  74 20 74 6f 20 66 6c 6f  70 70 79 20 64 69 73 63  |t to floppy disc|
00001130  2c 20 62 75 74 20 74 6f  20 61 6e 6f 74 68 65 72  |, but to another|
00001140  20 61 72 65 61 20 6f 66  0d 6d 65 6d 6f 72 79 2e  | area of.memory.|
00001150  20 59 6f 75 20 63 61 6e  20 74 68 65 6e 20 63 6f  | You can then co|
00001160  70 79 20 74 68 69 73 20  62 6c 6f 63 6b 20 62 61  |py this block ba|
00001170  63 6b 20 74 6f 20 73 63  72 65 65 6e 20 6d 65 6d  |ck to screen mem|
00001180  6f 72 79 20 77 68 65 6e  65 76 65 72 20 61 6e 64  |ory whenever and|
00001190  0d 77 68 65 72 65 76 65  72 20 79 6f 75 20 77 61  |.wherever you wa|
000011a0  6e 74 20 69 74 2e 20 49  66 20 79 6f 75 20 77 61  |nt it. If you wa|
000011b0  6e 74 20 69 74 2c 20 73  61 79 2c 20 69 6e 20 74  |nt it, say, in t|
000011c0  68 65 20 66 69 66 74 68  20 72 6f 77 20 64 6f 77  |he fifth row dow|
000011d0  6e 2c 20 61 6e 64 0d 74  77 65 6c 76 65 20 63 68  |n, and.twelve ch|
000011e0  61 72 61 63 74 65 72 73  20 61 6c 6f 6e 67 2c 20  |aracters along, |
000011f0  79 6f 75 20 63 61 6e 20  63 61 6c 63 75 6c 61 74  |you can calculat|
00001200  65 20 77 68 65 72 65 20  61 62 6f 75 74 73 20 74  |e where abouts t|
00001210  68 69 73 20 63 6f 72 72  65 73 70 6f 6e 64 73 0d  |his corresponds.|
00001220  74 6f 20 69 6e 20 73 63  72 65 65 6e 20 6d 65 6d  |to in screen mem|
00001230  6f 72 79 2c 20 61 6e 64  20 63 6f 70 79 20 74 68  |ory, and copy th|
00001240  65 20 62 6c 6f 63 6b 20  74 6f 20 74 68 69 73 20  |e block to this |
00001250  6c 6f 63 61 74 69 6f 6e  2e 20 41 73 20 74 68 65  |location. As the|
00001260  20 62 6c 6f 63 6b 20 69  73 0d 73 74 6f 72 65 64  | block is.stored|
00001270  20 69 6e 20 79 6f 75 72  20 63 6f 6d 70 75 74 65  | in your compute|
00001280  72 27 73 20 52 41 4d 2c  20 61 73 20 6f 70 70 6f  |r's RAM, as oppo|
00001290  73 65 64 20 74 6f 20 6f  6e 20 66 6c 6f 70 70 79  |sed to on floppy|
000012a0  2c 20 74 68 69 73 20 74  72 61 6e 73 66 65 72 20  |, this transfer |
000012b0  63 61 6e 0d 62 65 20 64  6f 6e 65 20 62 79 20 6d  |can.be done by m|
000012c0  61 63 68 69 6e 65 20 63  6f 64 65 20 61 74 20 76  |achine code at v|
000012d0  65 72 79 20 67 72 65 61  74 20 73 70 65 65 64 20  |ery great speed |
000012e0  28 74 61 6b 69 6e 67 20  6f 6e 6c 79 20 61 20 73  |(taking only a s|
000012f0  6d 61 6c 6c 20 66 72 61  63 74 69 6f 6e 0d 6f 66  |mall fraction.of|
00001300  20 61 20 73 65 63 6f 6e  64 29 2e 20 46 6f 72 20  | a second). For |
00001310  74 68 6f 73 65 20 70 72  6f 67 72 61 6d 6d 65 72  |those programmer|
00001320  73 20 77 68 6f 20 61 72  65 20 6e 6f 74 20 66 61  |s who are not fa|
00001330  6d 69 6c 69 61 72 20 77  69 74 68 20 6d 61 63 68  |miliar with mach|
00001340  69 6e 65 0d 63 6f 64 65  2c 20 61 20 6d 6f 64 75  |ine.code, a modu|
00001350  6c 65 20 69 73 20 69 6e  63 6c 75 64 65 64 20 77  |le is included w|
00001360  69 74 68 20 74 68 69 73  20 74 75 74 6f 72 69 61  |ith this tutoria|
00001370  6c 20 61 6c 6c 6f 77 69  6e 67 20 79 6f 75 20 74  |l allowing you t|
00001380  6f 20 64 6f 20 74 68 69  73 2e 20 54 68 65 0d 70  |o do this. The.p|
00001390  72 6f 67 72 61 6d 20 63  6f 64 65 20 66 6f 72 20  |rogram code for |
000013a0  74 68 69 73 20 6d 6f 64  75 6c 65 20 69 73 20 61  |this module is a|
000013b0  63 74 75 61 6c 6c 79 20  74 61 6b 65 6e 20 64 69  |ctually taken di|
000013c0  72 65 63 74 6c 79 20 66  72 6f 6d 20 53 68 69 70  |rectly from Ship|
000013d0  77 72 65 63 6b 65 64 2e  0d 0d 49 66 20 79 6f 75  |wrecked...If you|
000013e0  20 61 72 65 20 6e 6f 74  20 66 61 6d 69 6c 69 61  | are not familia|
000013f0  72 20 77 69 74 68 20 6d  61 63 68 69 6e 65 20 63  |r with machine c|
00001400  6f 64 65 2c 20 74 68 65  6e 20 79 6f 75 20 63 61  |ode, then you ca|
00001410  6e 20 70 72 6f 62 61 62  6c 79 20 73 6b 69 70 20  |n probably skip |
00001420  74 68 65 0d 6e 65 78 74  20 73 65 63 74 69 6f 6e  |the.next section|
00001430  20 6f 6e 20 68 6f 77 20  74 6f 20 64 69 72 65 63  | on how to direc|
00001440  74 6c 79 20 61 63 63 65  73 73 20 73 63 72 65 65  |tly access scree|
00001450  6e 20 6d 65 6d 6f 72 79  2c 20 61 73 20 69 74 20  |n memory, as it |
00001460  69 73 20 69 6d 70 6f 73  73 69 62 6c 65 0d 74 6f  |is impossible.to|
00001470  20 61 63 68 69 65 76 65  20 61 6e 79 20 73 70 65  | achieve any spe|
00001480  65 64 20 62 79 20 61 63  63 65 73 73 69 6e 67 20  |ed by accessing |
00001490  73 63 72 65 65 6e 20 6d  65 6d 6f 72 79 20 64 69  |screen memory di|
000014a0  72 65 63 74 6c 79 20 69  6e 20 42 41 53 49 43 20  |rectly in BASIC |
000014b0  2d 20 79 6f 75 72 0d 70  72 6f 67 72 61 6d 20 77  |- your.program w|
000014c0  69 6c 6c 20 63 72 61 77  6c 20 61 6c 6f 6e 67 20  |ill crawl along |
000014d0  69 6e 63 72 65 64 69 62  6c 79 20 73 6c 6f 77 6c  |incredibly slowl|
000014e0  79 2e 20 59 6f 75 20 63  6f 75 6c 64 20 73 74 69  |y. You could sti|
000014f0  6c 6c 20 75 73 65 20 73  75 63 68 20 61 0d 74 65  |ll use such a.te|
00001500  63 68 6e 69 71 75 65 20  69 6e 20 70 72 65 70 61  |chnique in prepa|
00001510  72 69 6e 67 20 61 20 73  63 72 65 65 6e 20 77 68  |ring a screen wh|
00001520  69 63 68 20 79 6f 75 20  69 6e 74 65 6e 64 20 74  |ich you intend t|
00001530  6f 20 73 61 76 65 20 74  6f 20 66 6c 6f 70 70 79  |o save to floppy|
00001540  20 75 73 69 6e 67 0d 74  68 65 20 74 65 63 68 6e  | using.the techn|
00001550  69 71 75 65 20 64 65 73  63 72 69 62 65 64 20 62  |ique described b|
00001560  65 66 6f 72 65 20 77 69  74 68 20 2a 53 41 56 45  |efore with *SAVE|
00001570  20 61 6e 64 20 2a 4c 4f  41 44 2e 0d 0d           | and *LOAD...|
0000157d
+P3.m0
+P3.m1
+P3.m2
+P3.m4
+P3.m5