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

+P4

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: +P4
Read OK:
File size: 123D bytes
Load address: 2B204556
Exec address: D3450
Duplicates

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

File contents
Firstly, it is important to know how screen memory is laid out in memory.
The exact position of each character within the memory of your computer
varies from one graphics mode to another, but the basic principals are the
same:

- The screen area is divided up into characters. These are blocks of eight 
  pixels by eight pixels, and are the same size as the rectangular block
  of space taken up by one letter when you print text to the screen. Screen
  memory is divided up into blocks, with each the characters being defined
  by one of these blocks.
- The screen is stored row by row, with the top row first and the bottom
  row last.
- Within each of these rows, characters are stored one by one, from left to
  right.
- In all modes, screen memory ends at &7FFF (ie. at the end of RAM)

Footnote: By convention, memory addresses are specified in hexidecimal. I
          use the standard Acorn '&' prefix to indicate hexidecimal values.
          Those used to dealing with PCs are any other computers may be used
          to the American convention of using a dollar prefix in its place.
          It should be noted that the Elk expects & and will not accept $.

Example:

Suppose I want to draw a blob in character square (6,7), in mode 1. What
is the address of this square? (given that each character takes 16 bytes
of screen memory to define in mode 1 - we'll come to how to calculate this
in a minute).

Well - looking at the table earlier, screen memory starts at &3000 in mode
1. We want to find the start of row 7 in screen memory. This row has 7
rows of characters above it, and which will be stored before it. Each of
these rows consists of 40 characters, which take up 16 bytes each.
Therefore the total memory taken up by these rows is 7 * 40 * 16 = 4480
bytes. [Each character is 16 bytes, each row consists of 40 of these
characters, therefore we multiply by 40, and as there are 7 of these
complete rows, we multiply by 7 to get the value for seven of these rows]

Now we have that the starting address of row 7 is at:

&3000 + 4480 = &4180

Now that we have found where abouts in memory this row starts, we need to
locate character 6. This should be fairly easy - we know that characters are
stored from left to right, so just add on the memory required to store six
characters to the left of the one we want, i.e. 16 * 6 = 96 bytes [Six
characters, each taking 16 bytes to store].

Therefore the address of character (6,7) will be:

&4180 + 96 = &41E0

Answer: Character (6,7) is stored from &41E0 to &41EF

Just to check the answer is correct, type this simple loop:

10 MODE 1
20 FOR ad=&41E0 TO &41EF
30 ?ad=255
40 NEXT

And yes, a white splodge does appear in square (6,7).

This whole procedure can actually be refined down, and expressed as a simple
formula:

Address = Base + ( y * No. characters per line + x ) * Memory per character

Where: Address= The memory location of the start of the character you want.
       Base   = Start of screen memory in current graphics mode.
       (x,y)  = Co-ordinate of square you want to access (same as PRINT TAB)

Since the number of characters per line, the number of bytes per character,
and the base address of screen memory are all constant for any particular
graphics mode, the values for the graphics mode you are using can be
substituted into the equation in your program. For mode 1, for example, you
would use:

Address = &3000 + (40 * y + x) * 16

Before continuing, one note should be borne in mind. You may remember that
a while back I mentioned that when you type text which overflows off the
bottom of the screen, the computer makes a note that each line is stored
in memory one line lower than it should be, but does not actually move
anything around in screen memory. The same effect can cause problems with
direct access to screen memory as well. The simple rule for beginners is,
NEVER attempt to use direct screen memory access when there is even the
slightest possibility that the screen might have been allowed to scroll up
at all (e.g. after using INPUT to get input from the user - how do you
know that they didn't type so much that it went of the bottom of the
screen?) If you know what you are doing, this rule can be ignored, and
high-speed scrolling can be achieved as a result, but that is not for the
beginner! I can tell you from first hand experience, that creating
scrolling in Jupiter 3 by this technique was a nightmare - especially when
the operating system calls you need to make to achieve this are completely
different on the BBC to the Elk, so you need to find out which platform
you are operating on, and then make the relavant calls for that platform!

00000000  0d 46 69 72 73 74 6c 79  2c 20 69 74 20 69 73 20  |.Firstly, it is |
00000010  69 6d 70 6f 72 74 61 6e  74 20 74 6f 20 6b 6e 6f  |important to kno|
00000020  77 20 68 6f 77 20 73 63  72 65 65 6e 20 6d 65 6d  |w how screen mem|
00000030  6f 72 79 20 69 73 20 6c  61 69 64 20 6f 75 74 20  |ory is laid out |
00000040  69 6e 20 6d 65 6d 6f 72  79 2e 0d 54 68 65 20 65  |in memory..The e|
00000050  78 61 63 74 20 70 6f 73  69 74 69 6f 6e 20 6f 66  |xact position of|
00000060  20 65 61 63 68 20 63 68  61 72 61 63 74 65 72 20  | each character |
00000070  77 69 74 68 69 6e 20 74  68 65 20 6d 65 6d 6f 72  |within the memor|
00000080  79 20 6f 66 20 79 6f 75  72 20 63 6f 6d 70 75 74  |y of your comput|
00000090  65 72 0d 76 61 72 69 65  73 20 66 72 6f 6d 20 6f  |er.varies from o|
000000a0  6e 65 20 67 72 61 70 68  69 63 73 20 6d 6f 64 65  |ne graphics mode|
000000b0  20 74 6f 20 61 6e 6f 74  68 65 72 2c 20 62 75 74  | to another, but|
000000c0  20 74 68 65 20 62 61 73  69 63 20 70 72 69 6e 63  | the basic princ|
000000d0  69 70 61 6c 73 20 61 72  65 20 74 68 65 0d 73 61  |ipals are the.sa|
000000e0  6d 65 3a 0d 0d 2d 20 54  68 65 20 73 63 72 65 65  |me:..- The scree|
000000f0  6e 20 61 72 65 61 20 69  73 20 64 69 76 69 64 65  |n area is divide|
00000100  64 20 75 70 20 69 6e 74  6f 20 63 68 61 72 61 63  |d up into charac|
00000110  74 65 72 73 2e 20 54 68  65 73 65 20 61 72 65 20  |ters. These are |
00000120  62 6c 6f 63 6b 73 20 6f  66 20 65 69 67 68 74 20  |blocks of eight |
00000130  0d 20 20 70 69 78 65 6c  73 20 62 79 20 65 69 67  |.  pixels by eig|
00000140  68 74 20 70 69 78 65 6c  73 2c 20 61 6e 64 20 61  |ht pixels, and a|
00000150  72 65 20 74 68 65 20 73  61 6d 65 20 73 69 7a 65  |re the same size|
00000160  20 61 73 20 74 68 65 20  72 65 63 74 61 6e 67 75  | as the rectangu|
00000170  6c 61 72 20 62 6c 6f 63  6b 0d 20 20 6f 66 20 73  |lar block.  of s|
00000180  70 61 63 65 20 74 61 6b  65 6e 20 75 70 20 62 79  |pace taken up by|
00000190  20 6f 6e 65 20 6c 65 74  74 65 72 20 77 68 65 6e  | one letter when|
000001a0  20 79 6f 75 20 70 72 69  6e 74 20 74 65 78 74 20  | you print text |
000001b0  74 6f 20 74 68 65 20 73  63 72 65 65 6e 2e 20 53  |to the screen. S|
000001c0  63 72 65 65 6e 0d 20 20  6d 65 6d 6f 72 79 20 69  |creen.  memory i|
000001d0  73 20 64 69 76 69 64 65  64 20 75 70 20 69 6e 74  |s divided up int|
000001e0  6f 20 62 6c 6f 63 6b 73  2c 20 77 69 74 68 20 65  |o blocks, with e|
000001f0  61 63 68 20 74 68 65 20  63 68 61 72 61 63 74 65  |ach the characte|
00000200  72 73 20 62 65 69 6e 67  20 64 65 66 69 6e 65 64  |rs being defined|
00000210  0d 20 20 62 79 20 6f 6e  65 20 6f 66 20 74 68 65  |.  by one of the|
00000220  73 65 20 62 6c 6f 63 6b  73 2e 0d 2d 20 54 68 65  |se blocks..- The|
00000230  20 73 63 72 65 65 6e 20  69 73 20 73 74 6f 72 65  | screen is store|
00000240  64 20 72 6f 77 20 62 79  20 72 6f 77 2c 20 77 69  |d row by row, wi|
00000250  74 68 20 74 68 65 20 74  6f 70 20 72 6f 77 20 66  |th the top row f|
00000260  69 72 73 74 20 61 6e 64  20 74 68 65 20 62 6f 74  |irst and the bot|
00000270  74 6f 6d 0d 20 20 72 6f  77 20 6c 61 73 74 2e 0d  |tom.  row last..|
00000280  2d 20 57 69 74 68 69 6e  20 65 61 63 68 20 6f 66  |- Within each of|
00000290  20 74 68 65 73 65 20 72  6f 77 73 2c 20 63 68 61  | these rows, cha|
000002a0  72 61 63 74 65 72 73 20  61 72 65 20 73 74 6f 72  |racters are stor|
000002b0  65 64 20 6f 6e 65 20 62  79 20 6f 6e 65 2c 20 66  |ed one by one, f|
000002c0  72 6f 6d 20 6c 65 66 74  20 74 6f 0d 20 20 72 69  |rom left to.  ri|
000002d0  67 68 74 2e 0d 2d 20 49  6e 20 61 6c 6c 20 6d 6f  |ght..- In all mo|
000002e0  64 65 73 2c 20 73 63 72  65 65 6e 20 6d 65 6d 6f  |des, screen memo|
000002f0  72 79 20 65 6e 64 73 20  61 74 20 26 37 46 46 46  |ry ends at &7FFF|
00000300  20 28 69 65 2e 20 61 74  20 74 68 65 20 65 6e 64  | (ie. at the end|
00000310  20 6f 66 20 52 41 4d 29  0d 0d 46 6f 6f 74 6e 6f  | of RAM)..Footno|
00000320  74 65 3a 20 42 79 20 63  6f 6e 76 65 6e 74 69 6f  |te: By conventio|
00000330  6e 2c 20 6d 65 6d 6f 72  79 20 61 64 64 72 65 73  |n, memory addres|
00000340  73 65 73 20 61 72 65 20  73 70 65 63 69 66 69 65  |ses are specifie|
00000350  64 20 69 6e 20 68 65 78  69 64 65 63 69 6d 61 6c  |d in hexidecimal|
00000360  2e 20 49 0d 20 20 20 20  20 20 20 20 20 20 75 73  |. I.          us|
00000370  65 20 74 68 65 20 73 74  61 6e 64 61 72 64 20 41  |e the standard A|
00000380  63 6f 72 6e 20 27 26 27  20 70 72 65 66 69 78 20  |corn '&' prefix |
00000390  74 6f 20 69 6e 64 69 63  61 74 65 20 68 65 78 69  |to indicate hexi|
000003a0  64 65 63 69 6d 61 6c 20  76 61 6c 75 65 73 2e 0d  |decimal values..|
000003b0  20 20 20 20 20 20 20 20  20 20 54 68 6f 73 65 20  |          Those |
000003c0  75 73 65 64 20 74 6f 20  64 65 61 6c 69 6e 67 20  |used to dealing |
000003d0  77 69 74 68 20 50 43 73  20 61 72 65 20 61 6e 79  |with PCs are any|
000003e0  20 6f 74 68 65 72 20 63  6f 6d 70 75 74 65 72 73  | other computers|
000003f0  20 6d 61 79 20 62 65 20  75 73 65 64 0d 20 20 20  | may be used.   |
00000400  20 20 20 20 20 20 20 74  6f 20 74 68 65 20 41 6d  |       to the Am|
00000410  65 72 69 63 61 6e 20 63  6f 6e 76 65 6e 74 69 6f  |erican conventio|
00000420  6e 20 6f 66 20 75 73 69  6e 67 20 61 20 64 6f 6c  |n of using a dol|
00000430  6c 61 72 20 70 72 65 66  69 78 20 69 6e 20 69 74  |lar prefix in it|
00000440  73 20 70 6c 61 63 65 2e  0d 20 20 20 20 20 20 20  |s place..       |
00000450  20 20 20 49 74 20 73 68  6f 75 6c 64 20 62 65 20  |   It should be |
00000460  6e 6f 74 65 64 20 74 68  61 74 20 74 68 65 20 45  |noted that the E|
00000470  6c 6b 20 65 78 70 65 63  74 73 20 26 20 61 6e 64  |lk expects & and|
00000480  20 77 69 6c 6c 20 6e 6f  74 20 61 63 63 65 70 74  | will not accept|
00000490  20 24 2e 0d 0d 45 78 61  6d 70 6c 65 3a 0d 0d 53  | $...Example:..S|
000004a0  75 70 70 6f 73 65 20 49  20 77 61 6e 74 20 74 6f  |uppose I want to|
000004b0  20 64 72 61 77 20 61 20  62 6c 6f 62 20 69 6e 20  | draw a blob in |
000004c0  63 68 61 72 61 63 74 65  72 20 73 71 75 61 72 65  |character square|
000004d0  20 28 36 2c 37 29 2c 20  69 6e 20 6d 6f 64 65 20  | (6,7), in mode |
000004e0  31 2e 20 57 68 61 74 0d  69 73 20 74 68 65 20 61  |1. What.is the a|
000004f0  64 64 72 65 73 73 20 6f  66 20 74 68 69 73 20 73  |ddress of this s|
00000500  71 75 61 72 65 3f 20 28  67 69 76 65 6e 20 74 68  |quare? (given th|
00000510  61 74 20 65 61 63 68 20  63 68 61 72 61 63 74 65  |at each characte|
00000520  72 20 74 61 6b 65 73 20  31 36 20 62 79 74 65 73  |r takes 16 bytes|
00000530  0d 6f 66 20 73 63 72 65  65 6e 20 6d 65 6d 6f 72  |.of screen memor|
00000540  79 20 74 6f 20 64 65 66  69 6e 65 20 69 6e 20 6d  |y to define in m|
00000550  6f 64 65 20 31 20 2d 20  77 65 27 6c 6c 20 63 6f  |ode 1 - we'll co|
00000560  6d 65 20 74 6f 20 68 6f  77 20 74 6f 20 63 61 6c  |me to how to cal|
00000570  63 75 6c 61 74 65 20 74  68 69 73 0d 69 6e 20 61  |culate this.in a|
00000580  20 6d 69 6e 75 74 65 29  2e 0d 0d 57 65 6c 6c 20  | minute)...Well |
00000590  2d 20 6c 6f 6f 6b 69 6e  67 20 61 74 20 74 68 65  |- looking at the|
000005a0  20 74 61 62 6c 65 20 65  61 72 6c 69 65 72 2c 20  | table earlier, |
000005b0  73 63 72 65 65 6e 20 6d  65 6d 6f 72 79 20 73 74  |screen memory st|
000005c0  61 72 74 73 20 61 74 20  26 33 30 30 30 20 69 6e  |arts at &3000 in|
000005d0  20 6d 6f 64 65 0d 31 2e  20 57 65 20 77 61 6e 74  | mode.1. We want|
000005e0  20 74 6f 20 66 69 6e 64  20 74 68 65 20 73 74 61  | to find the sta|
000005f0  72 74 20 6f 66 20 72 6f  77 20 37 20 69 6e 20 73  |rt of row 7 in s|
00000600  63 72 65 65 6e 20 6d 65  6d 6f 72 79 2e 20 54 68  |creen memory. Th|
00000610  69 73 20 72 6f 77 20 68  61 73 20 37 0d 72 6f 77  |is row has 7.row|
00000620  73 20 6f 66 20 63 68 61  72 61 63 74 65 72 73 20  |s of characters |
00000630  61 62 6f 76 65 20 69 74  2c 20 61 6e 64 20 77 68  |above it, and wh|
00000640  69 63 68 20 77 69 6c 6c  20 62 65 20 73 74 6f 72  |ich will be stor|
00000650  65 64 20 62 65 66 6f 72  65 20 69 74 2e 20 45 61  |ed before it. Ea|
00000660  63 68 20 6f 66 0d 74 68  65 73 65 20 72 6f 77 73  |ch of.these rows|
00000670  20 63 6f 6e 73 69 73 74  73 20 6f 66 20 34 30 20  | consists of 40 |
00000680  63 68 61 72 61 63 74 65  72 73 2c 20 77 68 69 63  |characters, whic|
00000690  68 20 74 61 6b 65 20 75  70 20 31 36 20 62 79 74  |h take up 16 byt|
000006a0  65 73 20 65 61 63 68 2e  0d 54 68 65 72 65 66 6f  |es each..Therefo|
000006b0  72 65 20 74 68 65 20 74  6f 74 61 6c 20 6d 65 6d  |re the total mem|
000006c0  6f 72 79 20 74 61 6b 65  6e 20 75 70 20 62 79 20  |ory taken up by |
000006d0  74 68 65 73 65 20 72 6f  77 73 20 69 73 20 37 20  |these rows is 7 |
000006e0  2a 20 34 30 20 2a 20 31  36 20 3d 20 34 34 38 30  |* 40 * 16 = 4480|
000006f0  0d 62 79 74 65 73 2e 20  5b 45 61 63 68 20 63 68  |.bytes. [Each ch|
00000700  61 72 61 63 74 65 72 20  69 73 20 31 36 20 62 79  |aracter is 16 by|
00000710  74 65 73 2c 20 65 61 63  68 20 72 6f 77 20 63 6f  |tes, each row co|
00000720  6e 73 69 73 74 73 20 6f  66 20 34 30 20 6f 66 20  |nsists of 40 of |
00000730  74 68 65 73 65 0d 63 68  61 72 61 63 74 65 72 73  |these.characters|
00000740  2c 20 74 68 65 72 65 66  6f 72 65 20 77 65 20 6d  |, therefore we m|
00000750  75 6c 74 69 70 6c 79 20  62 79 20 34 30 2c 20 61  |ultiply by 40, a|
00000760  6e 64 20 61 73 20 74 68  65 72 65 20 61 72 65 20  |nd as there are |
00000770  37 20 6f 66 20 74 68 65  73 65 0d 63 6f 6d 70 6c  |7 of these.compl|
00000780  65 74 65 20 72 6f 77 73  2c 20 77 65 20 6d 75 6c  |ete rows, we mul|
00000790  74 69 70 6c 79 20 62 79  20 37 20 74 6f 20 67 65  |tiply by 7 to ge|
000007a0  74 20 74 68 65 20 76 61  6c 75 65 20 66 6f 72 20  |t the value for |
000007b0  73 65 76 65 6e 20 6f 66  20 74 68 65 73 65 20 72  |seven of these r|
000007c0  6f 77 73 5d 0d 0d 4e 6f  77 20 77 65 20 68 61 76  |ows]..Now we hav|
000007d0  65 20 74 68 61 74 20 74  68 65 20 73 74 61 72 74  |e that the start|
000007e0  69 6e 67 20 61 64 64 72  65 73 73 20 6f 66 20 72  |ing address of r|
000007f0  6f 77 20 37 20 69 73 20  61 74 3a 0d 0d 26 33 30  |ow 7 is at:..&30|
00000800  30 30 20 2b 20 34 34 38  30 20 3d 20 26 34 31 38  |00 + 4480 = &418|
00000810  30 0d 0d 4e 6f 77 20 74  68 61 74 20 77 65 20 68  |0..Now that we h|
00000820  61 76 65 20 66 6f 75 6e  64 20 77 68 65 72 65 20  |ave found where |
00000830  61 62 6f 75 74 73 20 69  6e 20 6d 65 6d 6f 72 79  |abouts in memory|
00000840  20 74 68 69 73 20 72 6f  77 20 73 74 61 72 74 73  | this row starts|
00000850  2c 20 77 65 20 6e 65 65  64 20 74 6f 0d 6c 6f 63  |, we need to.loc|
00000860  61 74 65 20 63 68 61 72  61 63 74 65 72 20 36 2e  |ate character 6.|
00000870  20 54 68 69 73 20 73 68  6f 75 6c 64 20 62 65 20  | This should be |
00000880  66 61 69 72 6c 79 20 65  61 73 79 20 2d 20 77 65  |fairly easy - we|
00000890  20 6b 6e 6f 77 20 74 68  61 74 20 63 68 61 72 61  | know that chara|
000008a0  63 74 65 72 73 20 61 72  65 0d 73 74 6f 72 65 64  |cters are.stored|
000008b0  20 66 72 6f 6d 20 6c 65  66 74 20 74 6f 20 72 69  | from left to ri|
000008c0  67 68 74 2c 20 73 6f 20  6a 75 73 74 20 61 64 64  |ght, so just add|
000008d0  20 6f 6e 20 74 68 65 20  6d 65 6d 6f 72 79 20 72  | on the memory r|
000008e0  65 71 75 69 72 65 64 20  74 6f 20 73 74 6f 72 65  |equired to store|
000008f0  20 73 69 78 0d 63 68 61  72 61 63 74 65 72 73 20  | six.characters |
00000900  74 6f 20 74 68 65 20 6c  65 66 74 20 6f 66 20 74  |to the left of t|
00000910  68 65 20 6f 6e 65 20 77  65 20 77 61 6e 74 2c 20  |he one we want, |
00000920  69 2e 65 2e 20 31 36 20  2a 20 36 20 3d 20 39 36  |i.e. 16 * 6 = 96|
00000930  20 62 79 74 65 73 20 5b  53 69 78 0d 63 68 61 72  | bytes [Six.char|
00000940  61 63 74 65 72 73 2c 20  65 61 63 68 20 74 61 6b  |acters, each tak|
00000950  69 6e 67 20 31 36 20 62  79 74 65 73 20 74 6f 20  |ing 16 bytes to |
00000960  73 74 6f 72 65 5d 2e 0d  0d 54 68 65 72 65 66 6f  |store]...Therefo|
00000970  72 65 20 74 68 65 20 61  64 64 72 65 73 73 20 6f  |re the address o|
00000980  66 20 63 68 61 72 61 63  74 65 72 20 28 36 2c 37  |f character (6,7|
00000990  29 20 77 69 6c 6c 20 62  65 3a 0d 0d 26 34 31 38  |) will be:..&418|
000009a0  30 20 2b 20 39 36 20 3d  20 26 34 31 45 30 0d 0d  |0 + 96 = &41E0..|
000009b0  41 6e 73 77 65 72 3a 20  43 68 61 72 61 63 74 65  |Answer: Characte|
000009c0  72 20 28 36 2c 37 29 20  69 73 20 73 74 6f 72 65  |r (6,7) is store|
000009d0  64 20 66 72 6f 6d 20 26  34 31 45 30 20 74 6f 20  |d from &41E0 to |
000009e0  26 34 31 45 46 0d 0d 4a  75 73 74 20 74 6f 20 63  |&41EF..Just to c|
000009f0  68 65 63 6b 20 74 68 65  20 61 6e 73 77 65 72 20  |heck the answer |
00000a00  69 73 20 63 6f 72 72 65  63 74 2c 20 74 79 70 65  |is correct, type|
00000a10  20 74 68 69 73 20 73 69  6d 70 6c 65 20 6c 6f 6f  | this simple loo|
00000a20  70 3a 0d 0d 31 30 20 4d  4f 44 45 20 31 0d 32 30  |p:..10 MODE 1.20|
00000a30  20 46 4f 52 20 61 64 3d  26 34 31 45 30 20 54 4f  | FOR ad=&41E0 TO|
00000a40  20 26 34 31 45 46 0d 33  30 20 3f 61 64 3d 32 35  | &41EF.30 ?ad=25|
00000a50  35 0d 34 30 20 4e 45 58  54 0d 0d 41 6e 64 20 79  |5.40 NEXT..And y|
00000a60  65 73 2c 20 61 20 77 68  69 74 65 20 73 70 6c 6f  |es, a white splo|
00000a70  64 67 65 20 64 6f 65 73  20 61 70 70 65 61 72 20  |dge does appear |
00000a80  69 6e 20 73 71 75 61 72  65 20 28 36 2c 37 29 2e  |in square (6,7).|
00000a90  0d 0d 54 68 69 73 20 77  68 6f 6c 65 20 70 72 6f  |..This whole pro|
00000aa0  63 65 64 75 72 65 20 63  61 6e 20 61 63 74 75 61  |cedure can actua|
00000ab0  6c 6c 79 20 62 65 20 72  65 66 69 6e 65 64 20 64  |lly be refined d|
00000ac0  6f 77 6e 2c 20 61 6e 64  20 65 78 70 72 65 73 73  |own, and express|
00000ad0  65 64 20 61 73 20 61 20  73 69 6d 70 6c 65 0d 66  |ed as a simple.f|
00000ae0  6f 72 6d 75 6c 61 3a 0d  0d 41 64 64 72 65 73 73  |ormula:..Address|
00000af0  20 3d 20 42 61 73 65 20  2b 20 28 20 79 20 2a 20  | = Base + ( y * |
00000b00  4e 6f 2e 20 63 68 61 72  61 63 74 65 72 73 20 70  |No. characters p|
00000b10  65 72 20 6c 69 6e 65 20  2b 20 78 20 29 20 2a 20  |er line + x ) * |
00000b20  4d 65 6d 6f 72 79 20 70  65 72 20 63 68 61 72 61  |Memory per chara|
00000b30  63 74 65 72 0d 0d 57 68  65 72 65 3a 20 41 64 64  |cter..Where: Add|
00000b40  72 65 73 73 3d 20 54 68  65 20 6d 65 6d 6f 72 79  |ress= The memory|
00000b50  20 6c 6f 63 61 74 69 6f  6e 20 6f 66 20 74 68 65  | location of the|
00000b60  20 73 74 61 72 74 20 6f  66 20 74 68 65 20 63 68  | start of the ch|
00000b70  61 72 61 63 74 65 72 20  79 6f 75 20 77 61 6e 74  |aracter you want|
00000b80  2e 0d 20 20 20 20 20 20  20 42 61 73 65 20 20 20  |..       Base   |
00000b90  3d 20 53 74 61 72 74 20  6f 66 20 73 63 72 65 65  |= Start of scree|
00000ba0  6e 20 6d 65 6d 6f 72 79  20 69 6e 20 63 75 72 72  |n memory in curr|
00000bb0  65 6e 74 20 67 72 61 70  68 69 63 73 20 6d 6f 64  |ent graphics mod|
00000bc0  65 2e 0d 20 20 20 20 20  20 20 28 78 2c 79 29 20  |e..       (x,y) |
00000bd0  20 3d 20 43 6f 2d 6f 72  64 69 6e 61 74 65 20 6f  | = Co-ordinate o|
00000be0  66 20 73 71 75 61 72 65  20 79 6f 75 20 77 61 6e  |f square you wan|
00000bf0  74 20 74 6f 20 61 63 63  65 73 73 20 28 73 61 6d  |t to access (sam|
00000c00  65 20 61 73 20 50 52 49  4e 54 20 54 41 42 29 0d  |e as PRINT TAB).|
00000c10  0d 53 69 6e 63 65 20 74  68 65 20 6e 75 6d 62 65  |.Since the numbe|
00000c20  72 20 6f 66 20 63 68 61  72 61 63 74 65 72 73 20  |r of characters |
00000c30  70 65 72 20 6c 69 6e 65  2c 20 74 68 65 20 6e 75  |per line, the nu|
00000c40  6d 62 65 72 20 6f 66 20  62 79 74 65 73 20 70 65  |mber of bytes pe|
00000c50  72 20 63 68 61 72 61 63  74 65 72 2c 0d 61 6e 64  |r character,.and|
00000c60  20 74 68 65 20 62 61 73  65 20 61 64 64 72 65 73  | the base addres|
00000c70  73 20 6f 66 20 73 63 72  65 65 6e 20 6d 65 6d 6f  |s of screen memo|
00000c80  72 79 20 61 72 65 20 61  6c 6c 20 63 6f 6e 73 74  |ry are all const|
00000c90  61 6e 74 20 66 6f 72 20  61 6e 79 20 70 61 72 74  |ant for any part|
00000ca0  69 63 75 6c 61 72 0d 67  72 61 70 68 69 63 73 20  |icular.graphics |
00000cb0  6d 6f 64 65 2c 20 74 68  65 20 76 61 6c 75 65 73  |mode, the values|
00000cc0  20 66 6f 72 20 74 68 65  20 67 72 61 70 68 69 63  | for the graphic|
00000cd0  73 20 6d 6f 64 65 20 79  6f 75 20 61 72 65 20 75  |s mode you are u|
00000ce0  73 69 6e 67 20 63 61 6e  20 62 65 0d 73 75 62 73  |sing can be.subs|
00000cf0  74 69 74 75 74 65 64 20  69 6e 74 6f 20 74 68 65  |tituted into the|
00000d00  20 65 71 75 61 74 69 6f  6e 20 69 6e 20 79 6f 75  | equation in you|
00000d10  72 20 70 72 6f 67 72 61  6d 2e 20 46 6f 72 20 6d  |r program. For m|
00000d20  6f 64 65 20 31 2c 20 66  6f 72 20 65 78 61 6d 70  |ode 1, for examp|
00000d30  6c 65 2c 20 79 6f 75 0d  77 6f 75 6c 64 20 75 73  |le, you.would us|
00000d40  65 3a 0d 0d 41 64 64 72  65 73 73 20 3d 20 26 33  |e:..Address = &3|
00000d50  30 30 30 20 2b 20 28 34  30 20 2a 20 79 20 2b 20  |000 + (40 * y + |
00000d60  78 29 20 2a 20 31 36 0d  0d 42 65 66 6f 72 65 20  |x) * 16..Before |
00000d70  63 6f 6e 74 69 6e 75 69  6e 67 2c 20 6f 6e 65 20  |continuing, one |
00000d80  6e 6f 74 65 20 73 68 6f  75 6c 64 20 62 65 20 62  |note should be b|
00000d90  6f 72 6e 65 20 69 6e 20  6d 69 6e 64 2e 20 59 6f  |orne in mind. Yo|
00000da0  75 20 6d 61 79 20 72 65  6d 65 6d 62 65 72 20 74  |u may remember t|
00000db0  68 61 74 0d 61 20 77 68  69 6c 65 20 62 61 63 6b  |hat.a while back|
00000dc0  20 49 20 6d 65 6e 74 69  6f 6e 65 64 20 74 68 61  | I mentioned tha|
00000dd0  74 20 77 68 65 6e 20 79  6f 75 20 74 79 70 65 20  |t when you type |
00000de0  74 65 78 74 20 77 68 69  63 68 20 6f 76 65 72 66  |text which overf|
00000df0  6c 6f 77 73 20 6f 66 66  20 74 68 65 0d 62 6f 74  |lows off the.bot|
00000e00  74 6f 6d 20 6f 66 20 74  68 65 20 73 63 72 65 65  |tom of the scree|
00000e10  6e 2c 20 74 68 65 20 63  6f 6d 70 75 74 65 72 20  |n, the computer |
00000e20  6d 61 6b 65 73 20 61 20  6e 6f 74 65 20 74 68 61  |makes a note tha|
00000e30  74 20 65 61 63 68 20 6c  69 6e 65 20 69 73 20 73  |t each line is s|
00000e40  74 6f 72 65 64 0d 69 6e  20 6d 65 6d 6f 72 79 20  |tored.in memory |
00000e50  6f 6e 65 20 6c 69 6e 65  20 6c 6f 77 65 72 20 74  |one line lower t|
00000e60  68 61 6e 20 69 74 20 73  68 6f 75 6c 64 20 62 65  |han it should be|
00000e70  2c 20 62 75 74 20 64 6f  65 73 20 6e 6f 74 20 61  |, but does not a|
00000e80  63 74 75 61 6c 6c 79 20  6d 6f 76 65 0d 61 6e 79  |ctually move.any|
00000e90  74 68 69 6e 67 20 61 72  6f 75 6e 64 20 69 6e 20  |thing around in |
00000ea0  73 63 72 65 65 6e 20 6d  65 6d 6f 72 79 2e 20 54  |screen memory. T|
00000eb0  68 65 20 73 61 6d 65 20  65 66 66 65 63 74 20 63  |he same effect c|
00000ec0  61 6e 20 63 61 75 73 65  20 70 72 6f 62 6c 65 6d  |an cause problem|
00000ed0  73 20 77 69 74 68 0d 64  69 72 65 63 74 20 61 63  |s with.direct ac|
00000ee0  63 65 73 73 20 74 6f 20  73 63 72 65 65 6e 20 6d  |cess to screen m|
00000ef0  65 6d 6f 72 79 20 61 73  20 77 65 6c 6c 2e 20 54  |emory as well. T|
00000f00  68 65 20 73 69 6d 70 6c  65 20 72 75 6c 65 20 66  |he simple rule f|
00000f10  6f 72 20 62 65 67 69 6e  6e 65 72 73 20 69 73 2c  |or beginners is,|
00000f20  0d 4e 45 56 45 52 20 61  74 74 65 6d 70 74 20 74  |.NEVER attempt t|
00000f30  6f 20 75 73 65 20 64 69  72 65 63 74 20 73 63 72  |o use direct scr|
00000f40  65 65 6e 20 6d 65 6d 6f  72 79 20 61 63 63 65 73  |een memory acces|
00000f50  73 20 77 68 65 6e 20 74  68 65 72 65 20 69 73 20  |s when there is |
00000f60  65 76 65 6e 20 74 68 65  0d 73 6c 69 67 68 74 65  |even the.slighte|
00000f70  73 74 20 70 6f 73 73 69  62 69 6c 69 74 79 20 74  |st possibility t|
00000f80  68 61 74 20 74 68 65 20  73 63 72 65 65 6e 20 6d  |hat the screen m|
00000f90  69 67 68 74 20 68 61 76  65 20 62 65 65 6e 20 61  |ight have been a|
00000fa0  6c 6c 6f 77 65 64 20 74  6f 20 73 63 72 6f 6c 6c  |llowed to scroll|
00000fb0  20 75 70 0d 61 74 20 61  6c 6c 20 28 65 2e 67 2e  | up.at all (e.g.|
00000fc0  20 61 66 74 65 72 20 75  73 69 6e 67 20 49 4e 50  | after using INP|
00000fd0  55 54 20 74 6f 20 67 65  74 20 69 6e 70 75 74 20  |UT to get input |
00000fe0  66 72 6f 6d 20 74 68 65  20 75 73 65 72 20 2d 20  |from the user - |
00000ff0  68 6f 77 20 64 6f 20 79  6f 75 0d 6b 6e 6f 77 20  |how do you.know |
00001000  74 68 61 74 20 74 68 65  79 20 64 69 64 6e 27 74  |that they didn't|
00001010  20 74 79 70 65 20 73 6f  20 6d 75 63 68 20 74 68  | type so much th|
00001020  61 74 20 69 74 20 77 65  6e 74 20 6f 66 20 74 68  |at it went of th|
00001030  65 20 62 6f 74 74 6f 6d  20 6f 66 20 74 68 65 0d  |e bottom of the.|
00001040  73 63 72 65 65 6e 3f 29  20 49 66 20 79 6f 75 20  |screen?) If you |
00001050  6b 6e 6f 77 20 77 68 61  74 20 79 6f 75 20 61 72  |know what you ar|
00001060  65 20 64 6f 69 6e 67 2c  20 74 68 69 73 20 72 75  |e doing, this ru|
00001070  6c 65 20 63 61 6e 20 62  65 20 69 67 6e 6f 72 65  |le can be ignore|
00001080  64 2c 20 61 6e 64 0d 68  69 67 68 2d 73 70 65 65  |d, and.high-spee|
00001090  64 20 73 63 72 6f 6c 6c  69 6e 67 20 63 61 6e 20  |d scrolling can |
000010a0  62 65 20 61 63 68 69 65  76 65 64 20 61 73 20 61  |be achieved as a|
000010b0  20 72 65 73 75 6c 74 2c  20 62 75 74 20 74 68 61  | result, but tha|
000010c0  74 20 69 73 20 6e 6f 74  20 66 6f 72 20 74 68 65  |t is not for the|
000010d0  0d 62 65 67 69 6e 6e 65  72 21 20 49 20 63 61 6e  |.beginner! I can|
000010e0  20 74 65 6c 6c 20 79 6f  75 20 66 72 6f 6d 20 66  | tell you from f|
000010f0  69 72 73 74 20 68 61 6e  64 20 65 78 70 65 72 69  |irst hand experi|
00001100  65 6e 63 65 2c 20 74 68  61 74 20 63 72 65 61 74  |ence, that creat|
00001110  69 6e 67 0d 73 63 72 6f  6c 6c 69 6e 67 20 69 6e  |ing.scrolling in|
00001120  20 4a 75 70 69 74 65 72  20 33 20 62 79 20 74 68  | Jupiter 3 by th|
00001130  69 73 20 74 65 63 68 6e  69 71 75 65 20 77 61 73  |is technique was|
00001140  20 61 20 6e 69 67 68 74  6d 61 72 65 20 2d 20 65  | a nightmare - e|
00001150  73 70 65 63 69 61 6c 6c  79 20 77 68 65 6e 0d 74  |specially when.t|
00001160  68 65 20 6f 70 65 72 61  74 69 6e 67 20 73 79 73  |he operating sys|
00001170  74 65 6d 20 63 61 6c 6c  73 20 79 6f 75 20 6e 65  |tem calls you ne|
00001180  65 64 20 74 6f 20 6d 61  6b 65 20 74 6f 20 61 63  |ed to make to ac|
00001190  68 69 65 76 65 20 74 68  69 73 20 61 72 65 20 63  |hieve this are c|
000011a0  6f 6d 70 6c 65 74 65 6c  79 0d 64 69 66 66 65 72  |ompletely.differ|
000011b0  65 6e 74 20 6f 6e 20 74  68 65 20 42 42 43 20 74  |ent on the BBC t|
000011c0  6f 20 74 68 65 20 45 6c  6b 2c 20 73 6f 20 79 6f  |o the Elk, so yo|
000011d0  75 20 6e 65 65 64 20 74  6f 20 66 69 6e 64 20 6f  |u need to find o|
000011e0  75 74 20 77 68 69 63 68  20 70 6c 61 74 66 6f 72  |ut which platfor|
000011f0  6d 0d 79 6f 75 20 61 72  65 20 6f 70 65 72 61 74  |m.you are operat|
00001200  69 6e 67 20 6f 6e 2c 20  61 6e 64 20 74 68 65 6e  |ing on, and then|
00001210  20 6d 61 6b 65 20 74 68  65 20 72 65 6c 61 76 61  | make the relava|
00001220  6e 74 20 63 61 6c 6c 73  20 66 6f 72 20 74 68 61  |nt calls for tha|
00001230  74 20 70 6c 61 74 66 6f  72 6d 21 0d 0d           |t platform!..|
0000123d
+P4.m0
+P4.m1
+P4.m2
+P4.m4
+P4.m5