Home » Personal collection » Acorn ADFS disks » Electron » EUG_submission.ADF » PT3/+P3

PT3/+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 » EUG_submission.ADF
Filename: PT3/+P3
Read OK:
File size: 1F11 bytes
Load address: D6576
Exec address: 2400
Duplicates

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

File contents
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.

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!

Now that you can locate a the memory occupied by a character in screen
memory, you need to know how the bytes within this block are laid out, so that
you can have pixel by pixel control over your monitor screen. This is also
required if you are to be able to calculate the amount of memory taken up
by each character's definition in a particular mode.

The graphics modes can be divided into three categories: monochrome modes
(ie. two colours), four colour modes, and sixteen colour modes. All of the
Elk's modes fall into these three groupings. Which of these colours each
pixel of the screen is depends upon the status of a number of binary bits.
These have two states, 0 or 1. Now, in a monochrome mode, one bit is
sufficient to define the colour of one pixel (bits have two states, 0 or 1,
and the pixels have two states, colour 0 or colour 1). In a four colour mode,
on the other hand, one bit will not be sufficient, as four different states
are required. Two bits will be enough to store the colour of one pixel,
however:

Bit 1 state     Bit 2 state     Colour
  0               0               0
  0               1               1
  1               0               2
  1               1               3

Those familiar with binary will spot the pattern straight away - simply
convert the binary value of the two bits into decimal, and you have the
logical colour number. A very similar pattern applies to MODE 2 - the Elk's
16 colour mode. Each pixel requires 4 bits to store its colour (2^4=16).
Once again, the colour of the pixel is the logical colour whose number is
given when four bits are put together to form a binary value:

Bit 1 state  Bit 2 state  Bit 3 state  Bit 4 state  Colour  Default
  0            0            0            0            0       BLK
  1            0            0            0            1       RED
  0            1            0            0            2       GRN
  1            1            0            0            3       YEL
  0            0            1            0            4       BLE
  1            0            1            0            5       MGN
  0            1            1            0            6       CYN
  1            1            1            0            7       WHT
  0            0            0            1            8     BLK/WHT
  1            0            0            1            9     RED/CYN
  0            1            0            1           10     GRN/MGN
  1            1            0            1           11     YEL/BLE
  0            0            1            1           12     BLE/YEL
  1            0            1            1           13     MGN/GRN
  0            1            1            1           14     CYN/RED
  1            1            1            1           15     WHT/BLK

[Default: Default setting of this logical colour when MODE 2 is first
entered]
00000000  49 66 20 79 6f 75 20 61  72 65 20 6e 6f 74 20 66  |If you are not f|
00000010  61 6d 69 6c 69 61 72 20  77 69 74 68 20 6d 61 63  |amiliar with mac|
00000020  68 69 6e 65 20 63 6f 64  65 2c 20 74 68 65 6e 20  |hine code, then |
00000030  79 6f 75 20 63 61 6e 20  70 72 6f 62 61 62 6c 79  |you can probably|
00000040  20 73 6b 69 70 20 74 68  65 20 6e 65 78 74 0d 73  | skip the next.s|
00000050  65 63 74 69 6f 6e 20 6f  6e 20 68 6f 77 20 74 6f  |ection on how to|
00000060  20 64 69 72 65 63 74 6c  79 20 61 63 63 65 73 73  | directly access|
00000070  20 73 63 72 65 65 6e 20  6d 65 6d 6f 72 79 2c 20  | screen memory, |
00000080  61 73 20 69 74 20 69 73  20 69 6d 70 6f 73 73 69  |as it is impossi|
00000090  62 6c 65 0d 74 6f 20 61  63 68 69 65 76 65 20 61  |ble.to achieve a|
000000a0  6e 79 20 73 70 65 65 64  20 62 79 20 61 63 63 65  |ny speed by acce|
000000b0  73 73 69 6e 67 20 73 63  72 65 65 6e 20 6d 65 6d  |ssing screen mem|
000000c0  6f 72 79 20 64 69 72 65  63 74 6c 79 20 69 6e 20  |ory directly in |
000000d0  42 41 53 49 43 20 2d 20  79 6f 75 72 0d 70 72 6f  |BASIC - your.pro|
000000e0  67 72 61 6d 20 77 69 6c  6c 20 63 72 61 77 6c 20  |gram will crawl |
000000f0  61 6c 6f 6e 67 20 69 6e  63 72 65 64 69 62 6c 79  |along incredibly|
00000100  20 73 6c 6f 77 6c 79 2e  20 59 6f 75 20 63 6f 75  | slowly. You cou|
00000110  6c 64 20 73 74 69 6c 6c  20 75 73 65 20 73 75 63  |ld still use suc|
00000120  68 20 61 0d 74 65 63 68  6e 69 71 75 65 20 69 6e  |h a.technique in|
00000130  20 70 72 65 70 61 72 69  6e 67 20 61 20 73 63 72  | preparing a scr|
00000140  65 65 6e 20 77 68 69 63  68 20 79 6f 75 20 69 6e  |een which you in|
00000150  74 65 6e 64 20 74 6f 20  73 61 76 65 20 74 6f 20  |tend to save to |
00000160  66 6c 6f 70 70 79 20 75  73 69 6e 67 0d 74 68 65  |floppy using.the|
00000170  20 74 65 63 68 6e 69 71  75 65 20 64 65 73 63 72  | technique descr|
00000180  69 62 65 64 20 62 65 66  6f 72 65 20 77 69 74 68  |ibed before with|
00000190  20 2a 53 41 56 45 20 61  6e 64 20 2a 4c 4f 41 44  | *SAVE and *LOAD|
000001a0  2e 0d 0d 46 69 72 73 74  6c 79 2c 20 69 74 20 69  |...Firstly, it i|
000001b0  73 20 69 6d 70 6f 72 74  61 6e 74 20 74 6f 20 6b  |s important to k|
000001c0  6e 6f 77 20 68 6f 77 20  73 63 72 65 65 6e 20 6d  |now how screen m|
000001d0  65 6d 6f 72 79 20 69 73  20 6c 61 69 64 20 6f 75  |emory is laid ou|
000001e0  74 20 69 6e 20 6d 65 6d  6f 72 79 2e 0d 54 68 65  |t in memory..The|
000001f0  20 65 78 61 63 74 20 70  6f 73 69 74 69 6f 6e 20  | exact position |
00000200  6f 66 20 65 61 63 68 20  63 68 61 72 61 63 74 65  |of each characte|
00000210  72 20 77 69 74 68 69 6e  20 74 68 65 20 6d 65 6d  |r within the mem|
00000220  6f 72 79 20 6f 66 20 79  6f 75 72 20 63 6f 6d 70  |ory of your comp|
00000230  75 74 65 72 0d 76 61 72  69 65 73 20 66 72 6f 6d  |uter.varies from|
00000240  20 6f 6e 65 20 67 72 61  70 68 69 63 73 20 6d 6f  | one graphics mo|
00000250  64 65 20 74 6f 20 61 6e  6f 74 68 65 72 2c 20 62  |de to another, b|
00000260  75 74 20 74 68 65 20 62  61 73 69 63 20 70 72 69  |ut the basic pri|
00000270  6e 63 69 70 61 6c 73 20  61 72 65 20 74 68 65 0d  |ncipals are the.|
00000280  73 61 6d 65 3a 0d 0d 2d  20 54 68 65 20 73 63 72  |same:..- The scr|
00000290  65 65 6e 20 61 72 65 61  20 69 73 20 64 69 76 69  |een area is divi|
000002a0  64 65 64 20 75 70 20 69  6e 74 6f 20 63 68 61 72  |ded up into char|
000002b0  61 63 74 65 72 73 2e 20  54 68 65 73 65 20 61 72  |acters. These ar|
000002c0  65 20 62 6c 6f 63 6b 73  20 6f 66 20 65 69 67 68  |e blocks of eigh|
000002d0  74 20 0d 20 20 70 69 78  65 6c 73 20 62 79 20 65  |t .  pixels by e|
000002e0  69 67 68 74 20 70 69 78  65 6c 73 2c 20 61 6e 64  |ight pixels, and|
000002f0  20 61 72 65 20 74 68 65  20 73 61 6d 65 20 73 69  | are the same si|
00000300  7a 65 20 61 73 20 74 68  65 20 72 65 63 74 61 6e  |ze as the rectan|
00000310  67 75 6c 61 72 20 62 6c  6f 63 6b 0d 20 20 6f 66  |gular block.  of|
00000320  20 73 70 61 63 65 20 74  61 6b 65 6e 20 75 70 20  | space taken up |
00000330  62 79 20 6f 6e 65 20 6c  65 74 74 65 72 20 77 68  |by one letter wh|
00000340  65 6e 20 79 6f 75 20 70  72 69 6e 74 20 74 65 78  |en you print tex|
00000350  74 20 74 6f 20 74 68 65  20 73 63 72 65 65 6e 2e  |t to the screen.|
00000360  20 53 63 72 65 65 6e 0d  20 20 6d 65 6d 6f 72 79  | Screen.  memory|
00000370  20 69 73 20 64 69 76 69  64 65 64 20 75 70 20 69  | is divided up i|
00000380  6e 74 6f 20 62 6c 6f 63  6b 73 2c 20 77 69 74 68  |nto blocks, with|
00000390  20 65 61 63 68 20 74 68  65 20 63 68 61 72 61 63  | each the charac|
000003a0  74 65 72 73 20 62 65 69  6e 67 20 64 65 66 69 6e  |ters being defin|
000003b0  65 64 0d 20 20 62 79 20  6f 6e 65 20 6f 66 20 74  |ed.  by one of t|
000003c0  68 65 73 65 20 62 6c 6f  63 6b 73 2e 0d 2d 20 54  |hese blocks..- T|
000003d0  68 65 20 73 63 72 65 65  6e 20 69 73 20 73 74 6f  |he screen is sto|
000003e0  72 65 64 20 72 6f 77 20  62 79 20 72 6f 77 2c 20  |red row by row, |
000003f0  77 69 74 68 20 74 68 65  20 74 6f 70 20 72 6f 77  |with the top row|
00000400  20 66 69 72 73 74 20 61  6e 64 20 74 68 65 20 62  | first and the b|
00000410  6f 74 74 6f 6d 0d 20 20  72 6f 77 20 6c 61 73 74  |ottom.  row last|
00000420  2e 0d 2d 20 57 69 74 68  69 6e 20 65 61 63 68 20  |..- Within each |
00000430  6f 66 20 74 68 65 73 65  20 72 6f 77 73 2c 20 63  |of these rows, c|
00000440  68 61 72 61 63 74 65 72  73 20 61 72 65 20 73 74  |haracters are st|
00000450  6f 72 65 64 20 6f 6e 65  20 62 79 20 6f 6e 65 2c  |ored one by one,|
00000460  20 66 72 6f 6d 20 6c 65  66 74 20 74 6f 0d 20 20  | from left to.  |
00000470  72 69 67 68 74 2e 0d 2d  20 49 6e 20 61 6c 6c 20  |right..- In all |
00000480  6d 6f 64 65 73 2c 20 73  63 72 65 65 6e 20 6d 65  |modes, screen me|
00000490  6d 6f 72 79 20 65 6e 64  73 20 61 74 20 26 37 46  |mory ends at &7F|
000004a0  46 46 20 28 69 65 2e 20  61 74 20 74 68 65 20 65  |FF (ie. at the e|
000004b0  6e 64 20 6f 66 20 52 41  4d 29 0d 0d 46 6f 6f 74  |nd of RAM)..Foot|
000004c0  6e 6f 74 65 3a 20 42 79  20 63 6f 6e 76 65 6e 74  |note: By convent|
000004d0  69 6f 6e 2c 20 6d 65 6d  6f 72 79 20 61 64 64 72  |ion, memory addr|
000004e0  65 73 73 65 73 20 61 72  65 20 73 70 65 63 69 66  |esses are specif|
000004f0  69 65 64 20 69 6e 20 68  65 78 69 64 65 63 69 6d  |ied in hexidecim|
00000500  61 6c 2e 20 49 0d 20 20  20 20 20 20 20 20 20 20  |al. I.          |
00000510  75 73 65 20 74 68 65 20  73 74 61 6e 64 61 72 64  |use the standard|
00000520  20 41 63 6f 72 6e 20 27  26 27 20 70 72 65 66 69  | Acorn '&' prefi|
00000530  78 20 74 6f 20 69 6e 64  69 63 61 74 65 20 68 65  |x to indicate he|
00000540  78 69 64 65 63 69 6d 61  6c 20 76 61 6c 75 65 73  |xidecimal values|
00000550  2e 0d 20 20 20 20 20 20  20 20 20 20 54 68 6f 73  |..          Thos|
00000560  65 20 75 73 65 64 20 74  6f 20 64 65 61 6c 69 6e  |e used to dealin|
00000570  67 20 77 69 74 68 20 50  43 73 20 61 72 65 20 61  |g with PCs are a|
00000580  6e 79 20 6f 74 68 65 72  20 63 6f 6d 70 75 74 65  |ny other compute|
00000590  72 73 20 6d 61 79 20 62  65 20 75 73 65 64 0d 20  |rs may be used. |
000005a0  20 20 20 20 20 20 20 20  20 74 6f 20 74 68 65 20  |         to the |
000005b0  41 6d 65 72 69 63 61 6e  20 63 6f 6e 76 65 6e 74  |American convent|
000005c0  69 6f 6e 20 6f 66 20 75  73 69 6e 67 20 61 20 64  |ion of using a d|
000005d0  6f 6c 6c 61 72 20 70 72  65 66 69 78 20 69 6e 20  |ollar prefix in |
000005e0  69 74 73 20 70 6c 61 63  65 2e 0d 20 20 20 20 20  |its place..     |
000005f0  20 20 20 20 20 49 74 20  73 68 6f 75 6c 64 20 62  |     It should b|
00000600  65 20 6e 6f 74 65 64 20  74 68 61 74 20 74 68 65  |e noted that the|
00000610  20 45 6c 6b 20 65 78 70  65 63 74 73 20 26 20 61  | Elk expects & a|
00000620  6e 64 20 77 69 6c 6c 20  6e 6f 74 20 61 63 63 65  |nd will not acce|
00000630  70 74 20 24 2e 0d 0d 45  78 61 6d 70 6c 65 3a 0d  |pt $...Example:.|
00000640  0d 53 75 70 70 6f 73 65  20 49 20 77 61 6e 74 20  |.Suppose I want |
00000650  74 6f 20 64 72 61 77 20  61 20 62 6c 6f 62 20 69  |to draw a blob i|
00000660  6e 20 63 68 61 72 61 63  74 65 72 20 73 71 75 61  |n character squa|
00000670  72 65 20 28 36 2c 37 29  2c 20 69 6e 20 6d 6f 64  |re (6,7), in mod|
00000680  65 20 31 2e 20 57 68 61  74 20 69 73 20 0d 74 68  |e 1. What is .th|
00000690  65 20 61 64 64 72 65 73  73 20 6f 66 20 74 68 69  |e address of thi|
000006a0  73 20 73 71 75 61 72 65  3f 20 28 67 69 76 65 6e  |s square? (given|
000006b0  20 74 68 61 74 20 65 61  63 68 20 63 68 61 72 61  | that each chara|
000006c0  63 74 65 72 20 74 61 6b  65 73 20 31 36 20 62 79  |cter takes 16 by|
000006d0  74 65 73 20 6f 66 0d 73  63 72 65 65 6e 20 6d 65  |tes of.screen me|
000006e0  6d 6f 72 79 20 74 6f 20  64 65 66 69 6e 65 20 69  |mory to define i|
000006f0  6e 20 6d 6f 64 65 20 31  20 2d 20 77 65 27 6c 6c  |n mode 1 - we'll|
00000700  20 63 6f 6d 65 20 74 6f  20 68 6f 77 20 74 6f 20  | come to how to |
00000710  63 61 6c 63 75 6c 61 74  65 20 74 68 69 73 20 69  |calculate this i|
00000720  6e 0d 61 20 6d 69 6e 75  74 65 29 2e 0d 0d 57 65  |n.a minute)...We|
00000730  6c 6c 20 2d 20 6c 6f 6f  6b 69 6e 67 20 61 74 20  |ll - looking at |
00000740  74 68 65 20 74 61 62 6c  65 20 65 61 72 6c 69 65  |the table earlie|
00000750  72 2c 20 73 63 72 65 65  6e 20 6d 65 6d 6f 72 79  |r, screen memory|
00000760  20 73 74 61 72 74 73 20  61 74 20 26 33 30 30 30  | starts at &3000|
00000770  20 69 6e 20 6d 6f 64 65  20 31 2e 0d 57 65 20 77  | in mode 1..We w|
00000780  61 6e 74 20 74 6f 20 66  69 6e 64 20 74 68 65 20  |ant to find the |
00000790  73 74 61 72 74 20 6f 66  20 72 6f 77 20 37 20 69  |start of row 7 i|
000007a0  6e 20 73 63 72 65 65 6e  20 6d 65 6d 6f 72 79 2e  |n screen memory.|
000007b0  20 54 68 69 73 20 72 6f  77 20 68 61 73 20 37 20  | This row has 7 |
000007c0  72 6f 77 73 20 6f 66 0d  63 68 61 72 61 63 74 65  |rows of.characte|
000007d0  72 73 20 61 62 6f 76 65  20 69 74 2c 20 61 6e 64  |rs above it, and|
000007e0  20 77 68 69 63 68 20 77  69 6c 6c 20 62 65 20 73  | which will be s|
000007f0  74 6f 72 65 64 20 62 65  66 6f 72 65 20 69 74 2e  |tored before it.|
00000800  20 45 61 63 68 20 6f 66  20 74 68 65 73 65 20 72  | Each of these r|
00000810  6f 77 73 0d 63 6f 6e 73  69 73 74 73 20 6f 66 20  |ows.consists of |
00000820  34 30 20 63 68 61 72 61  63 74 65 72 73 2c 20 77  |40 characters, w|
00000830  68 69 63 68 20 74 61 6b  65 20 75 70 20 31 36 20  |hich take up 16 |
00000840  62 79 74 65 73 20 65 61  63 68 2e 20 54 68 65 72  |bytes each. Ther|
00000850  65 66 6f 72 65 20 74 68  65 20 74 6f 74 61 6c 0d  |efore the total.|
00000860  6d 65 6d 6f 72 79 20 74  61 6b 65 6e 20 75 70 20  |memory taken up |
00000870  62 79 20 74 68 65 73 65  20 72 6f 77 73 20 69 73  |by these rows is|
00000880  20 37 20 2a 20 34 30 20  2a 20 31 36 20 3d 20 34  | 7 * 40 * 16 = 4|
00000890  34 38 30 20 62 79 74 65  73 2e 20 5b 45 61 63 68  |480 bytes. [Each|
000008a0  20 63 68 61 72 61 63 74  65 72 0d 69 73 20 31 36  | character.is 16|
000008b0  20 62 79 74 65 73 2c 20  65 61 63 68 20 72 6f 77  | bytes, each row|
000008c0  20 63 6f 6e 73 69 73 74  73 20 6f 66 20 34 30 20  | consists of 40 |
000008d0  6f 66 20 74 68 65 73 65  20 63 68 61 72 61 63 74  |of these charact|
000008e0  65 72 73 2c 20 74 68 65  72 65 66 6f 72 65 20 77  |ers, therefore w|
000008f0  65 0d 6d 75 6c 74 69 70  6c 79 20 62 79 20 34 30  |e.multiply by 40|
00000900  2c 20 61 6e 64 20 61 73  20 74 68 65 72 65 20 61  |, and as there a|
00000910  72 65 20 37 20 6f 66 20  74 68 65 73 65 20 63 6f  |re 7 of these co|
00000920  6d 70 6c 65 74 65 20 72  6f 77 73 2c 20 77 65 20  |mplete rows, we |
00000930  6d 75 6c 74 69 70 6c 79  20 62 79 0d 37 20 74 6f  |multiply by.7 to|
00000940  20 67 65 74 20 74 68 65  20 76 61 6c 75 65 20 66  | get the value f|
00000950  6f 72 20 73 65 76 65 6e  20 6f 66 20 74 68 65 73  |or seven of thes|
00000960  65 20 72 6f 77 73 5d 0d  0d 4e 6f 77 20 77 65 20  |e rows]..Now we |
00000970  68 61 76 65 20 74 68 61  74 20 74 68 65 20 73 74  |have that the st|
00000980  61 72 74 69 6e 67 20 61  64 64 72 65 73 73 20 6f  |arting address o|
00000990  66 20 72 6f 77 20 37 20  69 73 20 61 74 3a 0d 0d  |f row 7 is at:..|
000009a0  26 33 30 30 30 20 2b 20  34 34 38 30 20 3d 20 26  |&3000 + 4480 = &|
000009b0  34 31 38 30 0d 0d 4e 6f  77 20 74 68 61 74 20 77  |4180..Now that w|
000009c0  65 20 68 61 76 65 20 66  6f 75 6e 64 20 77 68 65  |e have found whe|
000009d0  72 65 20 61 62 6f 75 74  73 20 69 6e 20 6d 65 6d  |re abouts in mem|
000009e0  6f 72 79 20 74 68 69 73  20 72 6f 77 20 73 74 61  |ory this row sta|
000009f0  72 74 73 2c 20 77 65 20  6e 65 65 64 20 74 6f 0d  |rts, we need to.|
00000a00  6c 6f 63 61 74 65 20 63  68 61 72 61 63 74 65 72  |locate character|
00000a10  20 36 2e 20 54 68 69 73  20 73 68 6f 75 6c 64 20  | 6. This should |
00000a20  62 65 20 66 61 69 72 6c  79 20 65 61 73 79 20 2d  |be fairly easy -|
00000a30  20 77 65 20 6b 6e 6f 77  20 74 68 61 74 20 63 68  | we know that ch|
00000a40  61 72 61 63 74 65 72 73  20 61 72 65 0d 73 74 6f  |aracters are.sto|
00000a50  72 65 64 20 66 72 6f 6d  20 6c 65 66 74 20 74 6f  |red from left to|
00000a60  20 72 69 67 68 74 2c 20  73 6f 20 6a 75 73 74 20  | right, so just |
00000a70  61 64 64 20 6f 6e 20 74  68 65 20 6d 65 6d 6f 72  |add on the memor|
00000a80  79 20 72 65 71 75 69 72  65 64 20 74 6f 20 73 74  |y required to st|
00000a90  6f 72 65 20 73 69 78 0d  63 68 61 72 61 63 74 65  |ore six.characte|
00000aa0  72 73 20 74 6f 20 74 68  65 20 6c 65 66 74 20 6f  |rs to the left o|
00000ab0  66 20 74 68 65 20 6f 6e  65 20 77 65 20 77 61 6e  |f the one we wan|
00000ac0  74 2c 20 69 2e 65 2e 20  31 36 20 2a 20 36 20 3d  |t, i.e. 16 * 6 =|
00000ad0  20 39 36 20 62 79 74 65  73 20 5b 53 69 78 0d 63  | 96 bytes [Six.c|
00000ae0  68 61 72 61 63 74 65 72  73 2c 20 65 61 63 68 20  |haracters, each |
00000af0  74 61 6b 69 6e 67 20 31  36 20 62 79 74 65 73 20  |taking 16 bytes |
00000b00  74 6f 20 73 74 6f 72 65  5d 2e 0d 0d 54 68 65 72  |to store]...Ther|
00000b10  65 66 6f 72 65 20 74 68  65 20 61 64 64 72 65 73  |efore the addres|
00000b20  73 20 6f 66 20 63 68 61  72 61 63 74 65 72 20 28  |s of character (|
00000b30  36 2c 37 29 20 77 69 6c  6c 20 62 65 3a 0d 0d 26  |6,7) will be:..&|
00000b40  34 31 38 30 20 2b 20 39  36 20 3d 20 26 34 31 45  |4180 + 96 = &41E|
00000b50  30 0d 0d 41 6e 73 77 65  72 3a 20 43 68 61 72 61  |0..Answer: Chara|
00000b60  63 74 65 72 20 28 36 2c  37 29 20 69 73 20 73 74  |cter (6,7) is st|
00000b70  6f 72 65 64 20 66 72 6f  6d 20 26 34 31 45 30 20  |ored from &41E0 |
00000b80  74 6f 20 26 34 31 45 46  0d 0d 4a 75 73 74 20 74  |to &41EF..Just t|
00000b90  6f 20 63 68 65 63 6b 20  74 68 65 20 61 6e 73 77  |o check the answ|
00000ba0  65 72 20 69 73 20 63 6f  72 72 65 63 74 2c 20 74  |er is correct, t|
00000bb0  79 70 65 20 74 68 69 73  20 73 69 6d 70 6c 65 20  |ype this simple |
00000bc0  6c 6f 6f 70 3a 0d 0d 31  30 20 4d 4f 44 45 20 31  |loop:..10 MODE 1|
00000bd0  0d 32 30 20 46 4f 52 20  61 64 3d 26 34 31 45 30  |.20 FOR ad=&41E0|
00000be0  20 54 4f 20 26 34 31 45  46 0d 33 30 20 3f 61 64  | TO &41EF.30 ?ad|
00000bf0  3d 32 35 35 0d 34 30 20  4e 45 58 54 0d 0d 41 6e  |=255.40 NEXT..An|
00000c00  64 20 79 65 73 2c 20 61  20 77 68 69 74 65 20 73  |d yes, a white s|
00000c10  70 6c 6f 64 67 65 20 64  6f 65 73 20 61 70 70 65  |plodge does appe|
00000c20  61 72 20 69 6e 20 73 71  75 61 72 65 20 28 36 2c  |ar in square (6,|
00000c30  37 29 2e 0d 0d 54 68 69  73 20 77 68 6f 6c 65 20  |7)...This whole |
00000c40  70 72 6f 63 65 64 75 72  65 20 63 61 6e 20 61 63  |procedure can ac|
00000c50  74 75 61 6c 6c 79 20 62  65 20 72 65 66 69 6e 65  |tually be refine|
00000c60  64 20 64 6f 77 6e 2c 20  61 6e 64 20 65 78 70 72  |d down, and expr|
00000c70  65 73 73 65 64 20 61 73  20 61 20 73 69 6d 70 6c  |essed as a simpl|
00000c80  65 0d 66 6f 72 6d 75 6c  61 3a 0d 0d 41 64 64 72  |e.formula:..Addr|
00000c90  65 73 73 20 3d 20 42 61  73 65 20 2b 20 28 20 79  |ess = Base + ( y|
00000ca0  20 2a 20 4e 6f 2e 20 63  68 61 72 61 63 74 65 72  | * No. character|
00000cb0  73 20 70 65 72 20 6c 69  6e 65 20 2b 20 78 20 29  |s per line + x )|
00000cc0  20 2a 20 4d 65 6d 6f 72  79 20 70 65 72 20 63 68  | * Memory per ch|
00000cd0  61 72 61 63 74 65 72 0d  0d 57 68 65 72 65 3a 20  |aracter..Where: |
00000ce0  41 64 64 72 65 73 73 3d  20 54 68 65 20 6d 65 6d  |Address= The mem|
00000cf0  6f 72 79 20 6c 6f 63 61  74 69 6f 6e 20 6f 66 20  |ory location of |
00000d00  74 68 65 20 73 74 61 72  74 20 6f 66 20 74 68 65  |the start of the|
00000d10  20 63 68 61 72 61 63 74  65 72 20 79 6f 75 20 77  | character you w|
00000d20  61 6e 74 2e 0d 20 20 20  20 20 20 20 42 61 73 65  |ant..       Base|
00000d30  20 20 20 3d 20 53 74 61  72 74 20 6f 66 20 73 63  |   = Start of sc|
00000d40  72 65 65 6e 20 6d 65 6d  6f 72 79 20 69 6e 20 63  |reen memory in c|
00000d50  75 72 72 65 6e 74 20 67  72 61 70 68 69 63 73 20  |urrent graphics |
00000d60  6d 6f 64 65 2e 0d 20 20  20 20 20 20 20 28 78 2c  |mode..       (x,|
00000d70  79 29 20 20 3d 20 43 6f  2d 6f 72 64 69 6e 61 74  |y)  = Co-ordinat|
00000d80  65 20 6f 66 20 73 71 75  61 72 65 20 79 6f 75 20  |e of square you |
00000d90  77 61 6e 74 20 74 6f 20  61 63 63 65 73 73 20 28  |want to access (|
00000da0  73 61 6d 65 20 61 73 20  50 52 49 4e 54 20 54 41  |same as PRINT TA|
00000db0  42 29 0d 0d 53 69 6e 63  65 20 74 68 65 20 6e 75  |B)..Since the nu|
00000dc0  6d 62 65 72 20 6f 66 20  63 68 61 72 61 63 74 65  |mber of characte|
00000dd0  72 73 20 70 65 72 20 6c  69 6e 65 2c 20 74 68 65  |rs per line, the|
00000de0  20 6e 75 6d 62 65 72 20  6f 66 20 62 79 74 65 73  | number of bytes|
00000df0  20 70 65 72 20 63 68 61  72 61 63 74 65 72 2c 0d  | per character,.|
00000e00  61 6e 64 20 74 68 65 20  62 61 73 65 20 61 64 64  |and the base add|
00000e10  72 65 73 73 20 6f 66 20  73 63 72 65 65 6e 20 6d  |ress of screen m|
00000e20  65 6d 6f 72 79 20 61 72  65 20 61 6c 6c 20 63 6f  |emory are all co|
00000e30  6e 73 74 61 6e 74 20 66  6f 72 20 61 6e 79 20 70  |nstant for any p|
00000e40  61 72 74 69 63 75 6c 61  72 0d 67 72 61 70 68 69  |articular.graphi|
00000e50  63 73 20 6d 6f 64 65 2c  20 74 68 65 20 76 61 6c  |cs mode, the val|
00000e60  75 65 73 20 66 6f 72 20  74 68 65 20 67 72 61 70  |ues for the grap|
00000e70  68 69 63 73 20 6d 6f 64  65 20 79 6f 75 20 61 72  |hics mode you ar|
00000e80  65 20 75 73 69 6e 67 20  63 61 6e 20 62 65 0d 73  |e using can be.s|
00000e90  75 62 73 74 69 74 75 74  65 64 20 69 6e 74 6f 20  |ubstituted into |
00000ea0  74 68 65 20 65 71 75 61  74 69 6f 6e 20 69 6e 20  |the equation in |
00000eb0  79 6f 75 72 20 70 72 6f  67 72 61 6d 2e 20 46 6f  |your program. Fo|
00000ec0  72 20 6d 6f 64 65 20 31  2c 20 66 6f 72 20 65 78  |r mode 1, for ex|
00000ed0  61 6d 70 6c 65 2c 20 79  6f 75 0d 77 6f 75 6c 64  |ample, you.would|
00000ee0  20 75 73 65 3a 0d 0d 41  64 64 72 65 73 73 20 3d  | use:..Address =|
00000ef0  20 26 33 30 30 30 20 2b  20 28 34 30 20 2a 20 79  | &3000 + (40 * y|
00000f00  20 2b 20 78 29 20 2a 20  31 36 0d 0d 42 65 66 6f  | + x) * 16..Befo|
00000f10  72 65 20 63 6f 6e 74 69  6e 75 69 6e 67 2c 20 6f  |re continuing, o|
00000f20  6e 65 20 6e 6f 74 65 20  73 68 6f 75 6c 64 20 62  |ne note should b|
00000f30  65 20 62 6f 72 6e 65 20  69 6e 20 6d 69 6e 64 2e  |e borne in mind.|
00000f40  20 59 6f 75 20 6d 61 79  20 72 65 6d 65 6d 62 65  | You may remembe|
00000f50  72 20 74 68 61 74 0d 61  20 77 68 69 6c 65 20 62  |r that.a while b|
00000f60  61 63 6b 20 49 20 6d 65  6e 74 69 6f 6e 65 64 20  |ack I mentioned |
00000f70  74 68 61 74 20 77 68 65  6e 20 79 6f 75 20 74 79  |that when you ty|
00000f80  70 65 20 74 65 78 74 20  77 68 69 63 68 20 6f 76  |pe text which ov|
00000f90  65 72 66 6c 6f 77 73 20  6f 66 66 20 74 68 65 0d  |erflows off the.|
00000fa0  62 6f 74 74 6f 6d 20 6f  66 20 74 68 65 20 73 63  |bottom of the sc|
00000fb0  72 65 65 6e 2c 20 74 68  65 20 63 6f 6d 70 75 74  |reen, the comput|
00000fc0  65 72 20 6d 61 6b 65 73  20 61 20 6e 6f 74 65 20  |er makes a note |
00000fd0  74 68 61 74 20 65 61 63  68 20 6c 69 6e 65 20 69  |that each line i|
00000fe0  73 20 73 74 6f 72 65 64  0d 69 6e 20 6d 65 6d 6f  |s stored.in memo|
00000ff0  72 79 20 6f 6e 65 20 6c  69 6e 65 20 6c 6f 77 65  |ry one line lowe|
00001000  72 20 74 68 61 6e 20 69  74 20 73 68 6f 75 6c 64  |r than it should|
00001010  20 62 65 2c 20 62 75 74  20 64 6f 65 73 20 6e 6f  | be, but does no|
00001020  74 20 61 63 74 75 61 6c  6c 79 20 6d 6f 76 65 0d  |t actually move.|
00001030  61 6e 79 74 68 69 6e 67  20 61 72 6f 75 6e 64 20  |anything around |
00001040  69 6e 20 73 63 72 65 65  6e 20 6d 65 6d 6f 72 79  |in screen memory|
00001050  2e 20 54 68 65 20 73 61  6d 65 20 65 66 66 65 63  |. The same effec|
00001060  74 20 63 61 6e 20 63 61  75 73 65 20 70 72 6f 62  |t can cause prob|
00001070  6c 65 6d 73 20 77 69 74  68 0d 64 69 72 65 63 74  |lems with.direct|
00001080  20 61 63 63 65 73 73 20  74 6f 20 73 63 72 65 65  | access to scree|
00001090  6e 20 6d 65 6d 6f 72 79  20 61 73 20 77 65 6c 6c  |n memory as well|
000010a0  2e 20 54 68 65 20 73 69  6d 70 6c 65 20 72 75 6c  |. The simple rul|
000010b0  65 20 66 6f 72 20 62 65  67 69 6e 6e 65 72 73 20  |e for beginners |
000010c0  69 73 2c 0d 4e 45 56 45  52 20 61 74 74 65 6d 70  |is,.NEVER attemp|
000010d0  74 20 74 6f 20 75 73 65  20 64 69 72 65 63 74 20  |t to use direct |
000010e0  73 63 72 65 65 6e 20 6d  65 6d 6f 72 79 20 61 63  |screen memory ac|
000010f0  63 65 73 73 20 77 68 65  6e 20 74 68 65 72 65 20  |cess when there |
00001100  69 73 20 65 76 65 6e 20  74 68 65 0d 73 6c 69 67  |is even the.slig|
00001110  68 74 65 73 74 20 70 6f  73 73 69 62 69 6c 69 74  |htest possibilit|
00001120  79 20 74 68 61 74 20 74  68 65 20 73 63 72 65 65  |y that the scree|
00001130  6e 20 6d 69 67 68 74 20  68 61 76 65 20 62 65 65  |n might have bee|
00001140  6e 20 61 6c 6c 6f 77 65  64 20 74 6f 20 73 63 72  |n allowed to scr|
00001150  6f 6c 6c 20 75 70 0d 61  74 20 61 6c 6c 20 28 65  |oll up.at all (e|
00001160  2e 67 2e 20 61 66 74 65  72 20 75 73 69 6e 67 20  |.g. after using |
00001170  49 4e 50 55 54 20 74 6f  20 67 65 74 20 69 6e 70  |INPUT to get inp|
00001180  75 74 20 66 72 6f 6d 20  74 68 65 20 75 73 65 72  |ut from the user|
00001190  20 2d 20 68 6f 77 20 64  6f 20 79 6f 75 0d 6b 6e  | - how do you.kn|
000011a0  6f 77 20 74 68 61 74 20  74 68 65 79 20 64 69 64  |ow that they did|
000011b0  6e 27 74 20 74 79 70 65  20 73 6f 20 6d 75 63 68  |n't type so much|
000011c0  20 74 68 61 74 20 69 74  20 77 65 6e 74 20 6f 66  | that it went of|
000011d0  20 74 68 65 20 62 6f 74  74 6f 6d 20 6f 66 20 74  | the bottom of t|
000011e0  68 65 20 73 63 72 65 65  6e 3f 29 0d 49 66 20 79  |he screen?).If y|
000011f0  6f 75 20 6b 6e 6f 77 20  77 68 61 74 20 79 6f 75  |ou know what you|
00001200  20 61 72 65 20 64 6f 69  6e 67 2c 20 74 68 69 73  | are doing, this|
00001210  20 72 75 6c 65 20 63 61  6e 20 62 65 20 69 67 6e  | rule can be ign|
00001220  6f 72 65 64 2c 20 61 6e  64 20 68 69 67 68 2d 73  |ored, and high-s|
00001230  70 65 65 64 0d 73 63 72  6f 6c 6c 69 6e 67 20 63  |peed.scrolling c|
00001240  61 6e 20 62 65 20 61 63  68 69 65 76 65 64 20 61  |an be achieved a|
00001250  73 20 61 20 72 65 73 75  6c 74 2c 20 62 75 74 20  |s a result, but |
00001260  74 68 61 74 20 69 73 20  6e 6f 74 20 66 6f 72 20  |that is not for |
00001270  74 68 65 20 62 65 67 69  6e 6e 65 72 21 20 49 0d  |the beginner! I.|
00001280  63 61 6e 20 74 65 6c 6c  20 79 6f 75 20 66 72 6f  |can tell you fro|
00001290  6d 20 66 69 72 73 74 20  68 61 6e 64 20 65 78 70  |m first hand exp|
000012a0  65 72 69 65 6e 63 65 2c  20 74 68 61 74 20 63 72  |erience, that cr|
000012b0  65 61 74 69 6e 67 20 73  63 72 6f 6c 6c 69 6e 67  |eating scrolling|
000012c0  20 69 6e 20 4a 75 70 69  74 65 72 0d 33 20 62 79  | in Jupiter.3 by|
000012d0  20 74 68 69 73 20 74 65  63 68 6e 69 71 75 65 20  | this technique |
000012e0  77 61 73 20 61 20 6e 69  67 68 74 6d 61 72 65 20  |was a nightmare |
000012f0  2d 20 65 73 70 65 63 69  61 6c 6c 79 20 77 68 65  |- especially whe|
00001300  6e 20 74 68 65 20 6f 70  65 72 61 74 69 6e 67 20  |n the operating |
00001310  73 79 73 74 65 6d 0d 63  61 6c 6c 73 20 79 6f 75  |system.calls you|
00001320  20 6e 65 65 64 20 74 6f  20 6d 61 6b 65 20 74 6f  | need to make to|
00001330  20 61 63 68 69 65 76 65  20 74 68 69 73 20 61 72  | achieve this ar|
00001340  65 20 63 6f 6d 70 6c 65  74 65 6c 79 20 64 69 66  |e completely dif|
00001350  66 65 72 65 6e 74 20 6f  6e 20 74 68 65 20 42 42  |ferent on the BB|
00001360  43 0d 74 6f 20 74 68 65  20 45 6c 6b 2c 20 73 6f  |C.to the Elk, so|
00001370  20 79 6f 75 20 6e 65 65  64 20 74 6f 20 66 69 6e  | you need to fin|
00001380  64 20 6f 75 74 20 77 68  69 63 68 20 70 6c 61 74  |d out which plat|
00001390  66 6f 72 6d 20 79 6f 75  20 61 72 65 20 6f 70 65  |form you are ope|
000013a0  72 61 74 69 6e 67 20 6f  6e 2c 0d 61 6e 64 20 74  |rating on,.and t|
000013b0  68 65 6e 20 6d 61 6b 65  20 74 68 65 20 72 65 6c  |hen make the rel|
000013c0  61 76 61 6e 74 20 63 61  6c 6c 73 20 66 6f 72 20  |avant calls for |
000013d0  74 68 61 74 20 70 6c 61  74 66 6f 72 6d 21 0d 0d  |that platform!..|
000013e0  4e 6f 77 20 74 68 61 74  20 79 6f 75 20 63 61 6e  |Now that you can|
000013f0  20 6c 6f 63 61 74 65 20  61 20 74 68 65 20 6d 65  | locate a the me|
00001400  6d 6f 72 79 20 6f 63 63  75 70 69 65 64 20 62 79  |mory occupied by|
00001410  20 61 20 63 68 61 72 61  63 74 65 72 20 69 6e 20  | a character in |
00001420  73 63 72 65 65 6e 0d 6d  65 6d 6f 72 79 2c 20 79  |screen.memory, y|
00001430  6f 75 20 6e 65 65 64 20  74 6f 20 6b 6e 6f 77 20  |ou need to know |
00001440  68 6f 77 20 74 68 65 20  62 79 74 65 73 20 77 69  |how the bytes wi|
00001450  74 68 69 6e 20 74 68 69  73 20 62 6c 6f 63 6b 20  |thin this block |
00001460  61 72 65 20 6c 61 69 64  20 6f 75 74 2c 20 73 6f  |are laid out, so|
00001470  20 74 68 61 74 0d 79 6f  75 20 63 61 6e 20 68 61  | that.you can ha|
00001480  76 65 20 70 69 78 65 6c  20 62 79 20 70 69 78 65  |ve pixel by pixe|
00001490  6c 20 63 6f 6e 74 72 6f  6c 20 6f 76 65 72 20 79  |l control over y|
000014a0  6f 75 72 20 6d 6f 6e 69  74 6f 72 20 73 63 72 65  |our monitor scre|
000014b0  65 6e 2e 20 54 68 69 73  20 69 73 20 61 6c 73 6f  |en. This is also|
000014c0  0d 72 65 71 75 69 72 65  64 20 69 66 20 79 6f 75  |.required if you|
000014d0  20 61 72 65 20 74 6f 20  62 65 20 61 62 6c 65 20  | are to be able |
000014e0  74 6f 20 63 61 6c 63 75  6c 61 74 65 20 74 68 65  |to calculate the|
000014f0  20 61 6d 6f 75 6e 74 20  6f 66 20 6d 65 6d 6f 72  | amount of memor|
00001500  79 20 74 61 6b 65 6e 20  75 70 0d 62 79 20 65 61  |y taken up.by ea|
00001510  63 68 20 63 68 61 72 61  63 74 65 72 27 73 20 64  |ch character's d|
00001520  65 66 69 6e 69 74 69 6f  6e 20 69 6e 20 61 20 70  |efinition in a p|
00001530  61 72 74 69 63 75 6c 61  72 20 6d 6f 64 65 2e 0d  |articular mode..|
00001540  0d 54 68 65 20 67 72 61  70 68 69 63 73 20 6d 6f  |.The graphics mo|
00001550  64 65 73 20 63 61 6e 20  62 65 20 64 69 76 69 64  |des can be divid|
00001560  65 64 20 69 6e 74 6f 20  74 68 72 65 65 20 63 61  |ed into three ca|
00001570  74 65 67 6f 72 69 65 73  3a 20 6d 6f 6e 6f 63 68  |tegories: monoch|
00001580  72 6f 6d 65 20 6d 6f 64  65 73 0d 28 69 65 2e 20  |rome modes.(ie. |
00001590  74 77 6f 20 63 6f 6c 6f  75 72 73 29 2c 20 66 6f  |two colours), fo|
000015a0  75 72 20 63 6f 6c 6f 75  72 20 6d 6f 64 65 73 2c  |ur colour modes,|
000015b0  20 61 6e 64 20 73 69 78  74 65 65 6e 20 63 6f 6c  | and sixteen col|
000015c0  6f 75 72 20 6d 6f 64 65  73 2e 20 41 6c 6c 20 6f  |our modes. All o|
000015d0  66 20 74 68 65 0d 45 6c  6b 27 73 20 6d 6f 64 65  |f the.Elk's mode|
000015e0  73 20 66 61 6c 6c 20 69  6e 74 6f 20 74 68 65 73  |s fall into thes|
000015f0  65 20 74 68 72 65 65 20  67 72 6f 75 70 69 6e 67  |e three grouping|
00001600  73 2e 20 57 68 69 63 68  20 6f 66 20 74 68 65 73  |s. Which of thes|
00001610  65 20 63 6f 6c 6f 75 72  73 20 65 61 63 68 0d 70  |e colours each.p|
00001620  69 78 65 6c 20 6f 66 20  74 68 65 20 73 63 72 65  |ixel of the scre|
00001630  65 6e 20 69 73 20 64 65  70 65 6e 64 73 20 75 70  |en is depends up|
00001640  6f 6e 20 74 68 65 20 73  74 61 74 75 73 20 6f 66  |on the status of|
00001650  20 61 20 6e 75 6d 62 65  72 20 6f 66 20 62 69 6e  | a number of bin|
00001660  61 72 79 20 62 69 74 73  2e 0d 54 68 65 73 65 20  |ary bits..These |
00001670  68 61 76 65 20 74 77 6f  20 73 74 61 74 65 73 2c  |have two states,|
00001680  20 30 20 6f 72 20 31 2e  20 4e 6f 77 2c 20 69 6e  | 0 or 1. Now, in|
00001690  20 61 20 6d 6f 6e 6f 63  68 72 6f 6d 65 20 6d 6f  | a monochrome mo|
000016a0  64 65 2c 20 6f 6e 65 20  62 69 74 20 69 73 0d 73  |de, one bit is.s|
000016b0  75 66 66 69 63 69 65 6e  74 20 74 6f 20 64 65 66  |ufficient to def|
000016c0  69 6e 65 20 74 68 65 20  63 6f 6c 6f 75 72 20 6f  |ine the colour o|
000016d0  66 20 6f 6e 65 20 70 69  78 65 6c 20 28 62 69 74  |f one pixel (bit|
000016e0  73 20 68 61 76 65 20 74  77 6f 20 73 74 61 74 65  |s have two state|
000016f0  73 2c 20 30 20 6f 72 20  31 2c 0d 61 6e 64 20 74  |s, 0 or 1,.and t|
00001700  68 65 20 70 69 78 65 6c  73 20 68 61 76 65 20 74  |he pixels have t|
00001710  77 6f 20 73 74 61 74 65  73 2c 20 63 6f 6c 6f 75  |wo states, colou|
00001720  72 20 30 20 6f 72 20 63  6f 6c 6f 75 72 20 31 29  |r 0 or colour 1)|
00001730  2e 20 49 6e 20 61 20 66  6f 75 72 20 63 6f 6c 6f  |. In a four colo|
00001740  75 72 20 6d 6f 64 65 2c  0d 6f 6e 20 74 68 65 20  |ur mode,.on the |
00001750  6f 74 68 65 72 20 68 61  6e 64 2c 20 6f 6e 65 20  |other hand, one |
00001760  62 69 74 20 77 69 6c 6c  20 6e 6f 74 20 62 65 20  |bit will not be |
00001770  73 75 66 66 69 63 69 65  6e 74 2c 20 61 73 20 66  |sufficient, as f|
00001780  6f 75 72 20 64 69 66 66  65 72 65 6e 74 20 73 74  |our different st|
00001790  61 74 65 73 0d 61 72 65  20 72 65 71 75 69 72 65  |ates.are require|
000017a0  64 2e 20 54 77 6f 20 62  69 74 73 20 77 69 6c 6c  |d. Two bits will|
000017b0  20 62 65 20 65 6e 6f 75  67 68 20 74 6f 20 73 74  | be enough to st|
000017c0  6f 72 65 20 74 68 65 20  63 6f 6c 6f 75 72 20 6f  |ore the colour o|
000017d0  66 20 6f 6e 65 20 70 69  78 65 6c 2c 0d 68 6f 77  |f one pixel,.how|
000017e0  65 76 65 72 3a 0d 0d 42  69 74 20 31 20 73 74 61  |ever:..Bit 1 sta|
000017f0  74 65 20 20 20 20 20 42  69 74 20 32 20 73 74 61  |te     Bit 2 sta|
00001800  74 65 20 20 20 20 20 43  6f 6c 6f 75 72 0d 20 20  |te     Colour.  |
00001810  30 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |0               |
*
00001830  30 0d 20 20 30 20 20 20  20 20 20 20 20 20 20 20  |0.  0           |
00001840  20 20 20 20 31 20 20 20  20 20 20 20 20 20 20 20  |    1           |
00001850  20 20 20 20 31 0d 20 20  31 20 20 20 20 20 20 20  |    1.  1       |
00001860  20 20 20 20 20 20 20 20  30 20 20 20 20 20 20 20  |        0       |
00001870  20 20 20 20 20 20 20 20  32 0d 20 20 31 20 20 20  |        2.  1   |
00001880  20 20 20 20 20 20 20 20  20 20 20 20 31 20 20 20  |            1   |
00001890  20 20 20 20 20 20 20 20  20 20 20 20 33 0d 0d 54  |            3..T|
000018a0  68 6f 73 65 20 66 61 6d  69 6c 69 61 72 20 77 69  |hose familiar wi|
000018b0  74 68 20 62 69 6e 61 72  79 20 77 69 6c 6c 20 73  |th binary will s|
000018c0  70 6f 74 20 74 68 65 20  70 61 74 74 65 72 6e 20  |pot the pattern |
000018d0  73 74 72 61 69 67 68 74  20 61 77 61 79 20 2d 20  |straight away - |
000018e0  73 69 6d 70 6c 79 0d 63  6f 6e 76 65 72 74 20 74  |simply.convert t|
000018f0  68 65 20 62 69 6e 61 72  79 20 76 61 6c 75 65 20  |he binary value |
00001900  6f 66 20 74 68 65 20 74  77 6f 20 62 69 74 73 20  |of the two bits |
00001910  69 6e 74 6f 20 64 65 63  69 6d 61 6c 2c 20 61 6e  |into decimal, an|
00001920  64 20 79 6f 75 20 68 61  76 65 20 74 68 65 0d 6c  |d you have the.l|
00001930  6f 67 69 63 61 6c 20 63  6f 6c 6f 75 72 20 6e 75  |ogical colour nu|
00001940  6d 62 65 72 2e 20 41 20  76 65 72 79 20 73 69 6d  |mber. A very sim|
00001950  69 6c 61 72 20 70 61 74  74 65 72 6e 20 61 70 70  |ilar pattern app|
00001960  6c 69 65 73 20 74 6f 20  4d 4f 44 45 20 32 20 2d  |lies to MODE 2 -|
00001970  20 74 68 65 20 45 6c 6b  27 73 0d 31 36 20 63 6f  | the Elk's.16 co|
00001980  6c 6f 75 72 20 6d 6f 64  65 2e 20 45 61 63 68 20  |lour mode. Each |
00001990  70 69 78 65 6c 20 72 65  71 75 69 72 65 73 20 34  |pixel requires 4|
000019a0  20 62 69 74 73 20 74 6f  20 73 74 6f 72 65 20 69  | bits to store i|
000019b0  74 73 20 63 6f 6c 6f 75  72 20 28 32 5e 34 3d 31  |ts colour (2^4=1|
000019c0  36 29 2e 0d 4f 6e 63 65  20 61 67 61 69 6e 2c 20  |6)..Once again, |
000019d0  74 68 65 20 63 6f 6c 6f  75 72 20 6f 66 20 74 68  |the colour of th|
000019e0  65 20 70 69 78 65 6c 20  69 73 20 74 68 65 20 6c  |e pixel is the l|
000019f0  6f 67 69 63 61 6c 20 63  6f 6c 6f 75 72 20 77 68  |ogical colour wh|
00001a00  6f 73 65 20 6e 75 6d 62  65 72 20 69 73 0d 67 69  |ose number is.gi|
00001a10  76 65 6e 20 77 68 65 6e  20 66 6f 75 72 20 62 69  |ven when four bi|
00001a20  74 73 20 61 72 65 20 70  75 74 20 74 6f 67 65 74  |ts are put toget|
00001a30  68 65 72 20 74 6f 20 66  6f 72 6d 20 61 20 62 69  |her to form a bi|
00001a40  6e 61 72 79 20 76 61 6c  75 65 3a 0d 0d 42 69 74  |nary value:..Bit|
00001a50  20 31 20 73 74 61 74 65  20 20 42 69 74 20 32 20  | 1 state  Bit 2 |
00001a60  73 74 61 74 65 20 20 42  69 74 20 33 20 73 74 61  |state  Bit 3 sta|
00001a70  74 65 20 20 42 69 74 20  34 20 73 74 61 74 65 20  |te  Bit 4 state |
00001a80  20 43 6f 6c 6f 75 72 20  20 44 65 66 61 75 6c 74  | Colour  Default|
00001a90  0d 20 20 30 20 20 20 20  20 20 20 20 20 20 20 20  |.  0            |
00001aa0  30 20 20 20 20 20 20 20  20 20 20 20 20 30 20 20  |0            0  |
00001ab0  20 20 20 20 20 20 20 20  20 20 30 20 20 20 20 20  |          0     |
00001ac0  20 20 20 20 20 20 20 30  20 20 20 20 20 20 20 42  |       0       B|
00001ad0  4c 4b 0d 20 20 31 20 20  20 20 20 20 20 20 20 20  |LK.  1          |
00001ae0  20 20 30 20 20 20 20 20  20 20 20 20 20 20 20 30  |  0            0|
00001af0  20 20 20 20 20 20 20 20  20 20 20 20 30 20 20 20  |            0   |
00001b00  20 20 20 20 20 20 20 20  20 31 20 20 20 20 20 20  |         1      |
00001b10  20 52 45 44 0d 20 20 30  20 20 20 20 20 20 20 20  | RED.  0        |
00001b20  20 20 20 20 31 20 20 20  20 20 20 20 20 20 20 20  |    1           |
00001b30  20 30 20 20 20 20 20 20  20 20 20 20 20 20 30 20  | 0            0 |
00001b40  20 20 20 20 20 20 20 20  20 20 20 32 20 20 20 20  |           2    |
00001b50  20 20 20 47 52 4e 0d 20  20 31 20 20 20 20 20 20  |   GRN.  1      |
00001b60  20 20 20 20 20 20 31 20  20 20 20 20 20 20 20 20  |      1         |
00001b70  20 20 20 30 20 20 20 20  20 20 20 20 20 20 20 20  |   0            |
00001b80  30 20 20 20 20 20 20 20  20 20 20 20 20 33 20 20  |0            3  |
00001b90  20 20 20 20 20 59 45 4c  0d 20 20 30 20 20 20 20  |     YEL.  0    |
00001ba0  20 20 20 20 20 20 20 20  30 20 20 20 20 20 20 20  |        0       |
00001bb0  20 20 20 20 20 31 20 20  20 20 20 20 20 20 20 20  |     1          |
00001bc0  20 20 30 20 20 20 20 20  20 20 20 20 20 20 20 34  |  0            4|
00001bd0  20 20 20 20 20 20 20 42  4c 45 0d 20 20 31 20 20  |       BLE.  1  |
00001be0  20 20 20 20 20 20 20 20  20 20 30 20 20 20 20 20  |          0     |
00001bf0  20 20 20 20 20 20 20 31  20 20 20 20 20 20 20 20  |       1        |
00001c00  20 20 20 20 30 20 20 20  20 20 20 20 20 20 20 20  |    0           |
00001c10  20 35 20 20 20 20 20 20  20 4d 47 4e 0d 20 20 30  | 5       MGN.  0|
00001c20  20 20 20 20 20 20 20 20  20 20 20 20 31 20 20 20  |            1   |
00001c30  20 20 20 20 20 20 20 20  20 31 20 20 20 20 20 20  |         1      |
00001c40  20 20 20 20 20 20 30 20  20 20 20 20 20 20 20 20  |      0         |
00001c50  20 20 20 36 20 20 20 20  20 20 20 43 59 4e 0d 20  |   6       CYN. |
00001c60  20 31 20 20 20 20 20 20  20 20 20 20 20 20 31 20  | 1            1 |
00001c70  20 20 20 20 20 20 20 20  20 20 20 31 20 20 20 20  |           1    |
00001c80  20 20 20 20 20 20 20 20  30 20 20 20 20 20 20 20  |        0       |
00001c90  20 20 20 20 20 37 20 20  20 20 20 20 20 57 48 54  |     7       WHT|
00001ca0  0d 20 20 30 20 20 20 20  20 20 20 20 20 20 20 20  |.  0            |
00001cb0  30 20 20 20 20 20 20 20  20 20 20 20 20 30 20 20  |0            0  |
00001cc0  20 20 20 20 20 20 20 20  20 20 31 20 20 20 20 20  |          1     |
00001cd0  20 20 20 20 20 20 20 38  20 20 20 20 20 42 4c 4b  |       8     BLK|
00001ce0  2f 57 48 54 0d 20 20 31  20 20 20 20 20 20 20 20  |/WHT.  1        |
00001cf0  20 20 20 20 30 20 20 20  20 20 20 20 20 20 20 20  |    0           |
00001d00  20 30 20 20 20 20 20 20  20 20 20 20 20 20 31 20  | 0            1 |
00001d10  20 20 20 20 20 20 20 20  20 20 20 39 20 20 20 20  |           9    |
00001d20  20 52 45 44 2f 43 59 4e  0d 20 20 30 20 20 20 20  | RED/CYN.  0    |
00001d30  20 20 20 20 20 20 20 20  31 20 20 20 20 20 20 20  |        1       |
00001d40  20 20 20 20 20 30 20 20  20 20 20 20 20 20 20 20  |     0          |
00001d50  20 20 31 20 20 20 20 20  20 20 20 20 20 20 31 30  |  1           10|
00001d60  20 20 20 20 20 47 52 4e  2f 4d 47 4e 0d 20 20 31  |     GRN/MGN.  1|
00001d70  20 20 20 20 20 20 20 20  20 20 20 20 31 20 20 20  |            1   |
00001d80  20 20 20 20 20 20 20 20  20 30 20 20 20 20 20 20  |         0      |
00001d90  20 20 20 20 20 20 31 20  20 20 20 20 20 20 20 20  |      1         |
00001da0  20 20 31 31 20 20 20 20  20 59 45 4c 2f 42 4c 45  |  11     YEL/BLE|
00001db0  0d 20 20 30 20 20 20 20  20 20 20 20 20 20 20 20  |.  0            |
00001dc0  30 20 20 20 20 20 20 20  20 20 20 20 20 31 20 20  |0            1  |
00001dd0  20 20 20 20 20 20 20 20  20 20 31 20 20 20 20 20  |          1     |
00001de0  20 20 20 20 20 20 31 32  20 20 20 20 20 42 4c 45  |      12     BLE|
00001df0  2f 59 45 4c 0d 20 20 31  20 20 20 20 20 20 20 20  |/YEL.  1        |
00001e00  20 20 20 20 30 20 20 20  20 20 20 20 20 20 20 20  |    0           |
00001e10  20 31 20 20 20 20 20 20  20 20 20 20 20 20 31 20  | 1            1 |
00001e20  20 20 20 20 20 20 20 20  20 20 31 33 20 20 20 20  |          13    |
00001e30  20 4d 47 4e 2f 47 52 4e  0d 20 20 30 20 20 20 20  | MGN/GRN.  0    |
00001e40  20 20 20 20 20 20 20 20  31 20 20 20 20 20 20 20  |        1       |
00001e50  20 20 20 20 20 31 20 20  20 20 20 20 20 20 20 20  |     1          |
00001e60  20 20 31 20 20 20 20 20  20 20 20 20 20 20 31 34  |  1           14|
00001e70  20 20 20 20 20 43 59 4e  2f 52 45 44 0d 20 20 31  |     CYN/RED.  1|
00001e80  20 20 20 20 20 20 20 20  20 20 20 20 31 20 20 20  |            1   |
00001e90  20 20 20 20 20 20 20 20  20 31 20 20 20 20 20 20  |         1      |
00001ea0  20 20 20 20 20 20 31 20  20 20 20 20 20 20 20 20  |      1         |
00001eb0  20 20 31 35 20 20 20 20  20 57 48 54 2f 42 4c 4b  |  15     WHT/BLK|
00001ec0  0d 0d 5b 44 65 66 61 75  6c 74 3a 20 44 65 66 61  |..[Default: Defa|
00001ed0  75 6c 74 20 73 65 74 74  69 6e 67 20 6f 66 20 74  |ult setting of t|
00001ee0  68 69 73 20 6c 6f 67 69  63 61 6c 20 63 6f 6c 6f  |his logical colo|
00001ef0  75 72 20 77 68 65 6e 20  4d 4f 44 45 20 32 20 69  |ur when MODE 2 i|
00001f00  73 20 66 69 72 73 74 0d  65 6e 74 65 72 65 64 5d  |s first.entered]|
00001f10  0d                                                |.|
00001f11
PT3/+P3.m0
PT3/+P3.m1
PT3/+P3.m2
PT3/+P3.m4
PT3/+P3.m5