Home » CEEFAX disks » telesoftware7.adl » 06-05-88/T\OSB25

06-05-88/T\OSB25

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 » CEEFAX disks » telesoftware7.adl
Filename: 06-05-88/T\OSB25
Read OK:
File size: 148C bytes
Load address: 0000
Exec address: FFFFFFFF
File contents
OSBITS - An Exploration of the BBC Micro at Machine Level

By Programmer

.........................................................


Part 25: Legal and Illegal Code


You often read about programming techniques with the BBC
Micro family that Acorn describe as 'illegal'.  What does
this mean?  Will the Bill be round to check on your code?

In fact the concept of legality in the BBC Micro OS relates
to using the OS in a certain way.  The classic example is
writing to the screen.  You can either use PLOT commands,
from machine code or from a high level language like BASIC,
or you can actually poke numbers into the screen memory to
light up individual pixels.

The main advantage of poking the screen is speed.  The PLOT
routines are slow (at least when compared to poking the
screen).  The disadvantages are three fold.  Firstly the
address space in which the screen sits is not linear.  You
don't start at the top left at address &3000 for a Mode 1
screen and progress across and down the screen evenly, like
a TV camera scans a picture.  This non-linearity is caused
by the need to refresh the dynamic RAM in the micro.

To relate a pixel to its screen address you need a simple
formula, but one which includes much multiplying by &280. 
So writing a program to poke the screen is not very
straightforward.

More importantly, and this might sound a little silly, but
you can not be sure where the screen will be in future
machines.  Future-proofing your machine code is the
strongest argument for legal code and, in all cases except
arcade games, is pretty unchallengeable.

For example, in a BBC Model A the screen addresses are &4000
lower (where the modes exist) than on a Model B.  When you
introduce shadow RAM in a B+ or a Master you find that you
might well be sure of the address but you will not know
whether it lies in the same bank of RAM in which your code
is being executed.  This also means that you can not
directly poke the screen from a second processor without
using an OS call to cross the Tube.  Future 32 bit BBC
Micros may well have the screen somewhere totally new again.

The third disadvantage to directly addressing the screen is
that changing your screen mode means you have to completely
rewrite your screen accessing code since the relation ship
between bytes and pixels is different for each mode.

As a general rule you should not poke the screen, or indeed
any other part of the OS or BASIC workspace memory.  But if
your code could be considered to be an extension of the OS
(such as a mouse pointer implimentation) you could claim to
have the right to do so.  In this case you would have to
produce a different version of your code for each possible
machine used by your users.  If you are just writing for
yourself then all these arguments are spurious anyway.

One interestingly blurred area of illegality (as defined by
Acorn) is VDU variables.  The Master Reference Manual
(published by Acorn) actually gives you information to
enable you to access the VDU variables directly.  These are
the bytes in memory which control mode definition, amongst
other things.  However you are told to use OSBYTE calls to
read the variables and to read the memory address where they
start and then offset your writes from that.  If, in future
machines, the table moves then your code should still work
if you used the relevant OSBYTE calls.

The BBC Micro operating system provides a wide range of
calls to help your programming.  Acorn's micros do not have
a closed and undocumented OS like some home machines, and
even some mainframes.  So, if you can, use the relevant OS
call.

One of the top programmers at Acorn, and the man who wrote
BBC BASIC, often says that the best test of legality is if
the code will run in a 6502 second processor and do its job
correctly.  Although there are some legal tricks that work
only in the main micro this is a good rule of thumb.

The program in this module is a screen fill routine that
addresses the screen directly.  To use it you must be
running in the micro itself, not a second processor, and you
must not have shadow mode engaged.  It's not a particularly
elegant piece of code since most of it is taken up with
calculations to find the screen address that relates to a
graphics coordinate.  It winds up being half the speed of
the CLG command in BASIC but much faster than using PLOTs to
do the same job, pixel by pixel.

When you have run the program, in whatever mode, you press
function key 4 and the routine will fill the screen in mode
1.  The BASIC TIME facility will give a rough timing for the
procedure, which is about 1.1 seconds.  Line 740 of the code
sets the byte to be poked to the screen.  &00 will produce
black, &0F produces red, &F0 produces yellow and &FF
produces white.  In mode 1 (as we have here) there are 2
bits per pixel to set colour and they group 4 pixels to a
byte like this:

          Colour of pixel 1 - bits 7 and 3
          Colour of pixel 2 - bits 6 and 2
          Colour of pixel 3 - bits 5 and 1
          Colour of pixel 4 - bits 4 and 0

That just about brings us to the end of this meander through
machine code on the BBC.  The final module will offer some
suggestions for using a word processor (such as VIEW) to
edit your source code.
00000000  4f 53 42 49 54 53 20 2d  20 41 6e 20 45 78 70 6c  |OSBITS - An Expl|
00000010  6f 72 61 74 69 6f 6e 20  6f 66 20 74 68 65 20 42  |oration of the B|
00000020  42 43 20 4d 69 63 72 6f  20 61 74 20 4d 61 63 68  |BC Micro at Mach|
00000030  69 6e 65 20 4c 65 76 65  6c 0d 0d 42 79 20 50 72  |ine Level..By Pr|
00000040  6f 67 72 61 6d 6d 65 72  0d 0d 2e 2e 2e 2e 2e 2e  |ogrammer........|
00000050  2e 2e 2e 2e 2e 2e 2e 2e  2e 2e 2e 2e 2e 2e 2e 2e  |................|
*
00000080  2e 2e 2e 0d 0d 0d 50 61  72 74 20 32 35 3a 20 4c  |......Part 25: L|
00000090  65 67 61 6c 20 61 6e 64  20 49 6c 6c 65 67 61 6c  |egal and Illegal|
000000a0  20 43 6f 64 65 0d 0d 0d  59 6f 75 20 6f 66 74 65  | Code...You ofte|
000000b0  6e 20 72 65 61 64 20 61  62 6f 75 74 20 70 72 6f  |n read about pro|
000000c0  67 72 61 6d 6d 69 6e 67  20 74 65 63 68 6e 69 71  |gramming techniq|
000000d0  75 65 73 20 77 69 74 68  20 74 68 65 20 42 42 43  |ues with the BBC|
000000e0  0d 4d 69 63 72 6f 20 66  61 6d 69 6c 79 20 74 68  |.Micro family th|
000000f0  61 74 20 41 63 6f 72 6e  20 64 65 73 63 72 69 62  |at Acorn describ|
00000100  65 20 61 73 20 27 69 6c  6c 65 67 61 6c 27 2e 20  |e as 'illegal'. |
00000110  20 57 68 61 74 20 64 6f  65 73 0d 74 68 69 73 20  | What does.this |
00000120  6d 65 61 6e 3f 20 20 57  69 6c 6c 20 74 68 65 20  |mean?  Will the |
00000130  42 69 6c 6c 20 62 65 20  72 6f 75 6e 64 20 74 6f  |Bill be round to|
00000140  20 63 68 65 63 6b 20 6f  6e 20 79 6f 75 72 20 63  | check on your c|
00000150  6f 64 65 3f 0d 0d 49 6e  20 66 61 63 74 20 74 68  |ode?..In fact th|
00000160  65 20 63 6f 6e 63 65 70  74 20 6f 66 20 6c 65 67  |e concept of leg|
00000170  61 6c 69 74 79 20 69 6e  20 74 68 65 20 42 42 43  |ality in the BBC|
00000180  20 4d 69 63 72 6f 20 4f  53 20 72 65 6c 61 74 65  | Micro OS relate|
00000190  73 0d 74 6f 20 75 73 69  6e 67 20 74 68 65 20 4f  |s.to using the O|
000001a0  53 20 69 6e 20 61 20 63  65 72 74 61 69 6e 20 77  |S in a certain w|
000001b0  61 79 2e 20 20 54 68 65  20 63 6c 61 73 73 69 63  |ay.  The classic|
000001c0  20 65 78 61 6d 70 6c 65  20 69 73 0d 77 72 69 74  | example is.writ|
000001d0  69 6e 67 20 74 6f 20 74  68 65 20 73 63 72 65 65  |ing to the scree|
000001e0  6e 2e 20 20 59 6f 75 20  63 61 6e 20 65 69 74 68  |n.  You can eith|
000001f0  65 72 20 75 73 65 20 50  4c 4f 54 20 63 6f 6d 6d  |er use PLOT comm|
00000200  61 6e 64 73 2c 0d 66 72  6f 6d 20 6d 61 63 68 69  |ands,.from machi|
00000210  6e 65 20 63 6f 64 65 20  6f 72 20 66 72 6f 6d 20  |ne code or from |
00000220  61 20 68 69 67 68 20 6c  65 76 65 6c 20 6c 61 6e  |a high level lan|
00000230  67 75 61 67 65 20 6c 69  6b 65 20 42 41 53 49 43  |guage like BASIC|
00000240  2c 0d 6f 72 20 79 6f 75  20 63 61 6e 20 61 63 74  |,.or you can act|
00000250  75 61 6c 6c 79 20 70 6f  6b 65 20 6e 75 6d 62 65  |ually poke numbe|
00000260  72 73 20 69 6e 74 6f 20  74 68 65 20 73 63 72 65  |rs into the scre|
00000270  65 6e 20 6d 65 6d 6f 72  79 20 74 6f 0d 6c 69 67  |en memory to.lig|
00000280  68 74 20 75 70 20 69 6e  64 69 76 69 64 75 61 6c  |ht up individual|
00000290  20 70 69 78 65 6c 73 2e  0d 0d 54 68 65 20 6d 61  | pixels...The ma|
000002a0  69 6e 20 61 64 76 61 6e  74 61 67 65 20 6f 66 20  |in advantage of |
000002b0  70 6f 6b 69 6e 67 20 74  68 65 20 73 63 72 65 65  |poking the scree|
000002c0  6e 20 69 73 20 73 70 65  65 64 2e 20 20 54 68 65  |n is speed.  The|
000002d0  20 50 4c 4f 54 0d 72 6f  75 74 69 6e 65 73 20 61  | PLOT.routines a|
000002e0  72 65 20 73 6c 6f 77 20  28 61 74 20 6c 65 61 73  |re slow (at leas|
000002f0  74 20 77 68 65 6e 20 63  6f 6d 70 61 72 65 64 20  |t when compared |
00000300  74 6f 20 70 6f 6b 69 6e  67 20 74 68 65 0d 73 63  |to poking the.sc|
00000310  72 65 65 6e 29 2e 20 20  54 68 65 20 64 69 73 61  |reen).  The disa|
00000320  64 76 61 6e 74 61 67 65  73 20 61 72 65 20 74 68  |dvantages are th|
00000330  72 65 65 20 66 6f 6c 64  2e 20 20 46 69 72 73 74  |ree fold.  First|
00000340  6c 79 20 74 68 65 0d 61  64 64 72 65 73 73 20 73  |ly the.address s|
00000350  70 61 63 65 20 69 6e 20  77 68 69 63 68 20 74 68  |pace in which th|
00000360  65 20 73 63 72 65 65 6e  20 73 69 74 73 20 69 73  |e screen sits is|
00000370  20 6e 6f 74 20 6c 69 6e  65 61 72 2e 20 20 59 6f  | not linear.  Yo|
00000380  75 0d 64 6f 6e 27 74 20  73 74 61 72 74 20 61 74  |u.don't start at|
00000390  20 74 68 65 20 74 6f 70  20 6c 65 66 74 20 61 74  | the top left at|
000003a0  20 61 64 64 72 65 73 73  20 26 33 30 30 30 20 66  | address &3000 f|
000003b0  6f 72 20 61 20 4d 6f 64  65 20 31 0d 73 63 72 65  |or a Mode 1.scre|
000003c0  65 6e 20 61 6e 64 20 70  72 6f 67 72 65 73 73 20  |en and progress |
000003d0  61 63 72 6f 73 73 20 61  6e 64 20 64 6f 77 6e 20  |across and down |
000003e0  74 68 65 20 73 63 72 65  65 6e 20 65 76 65 6e 6c  |the screen evenl|
000003f0  79 2c 20 6c 69 6b 65 0d  61 20 54 56 20 63 61 6d  |y, like.a TV cam|
00000400  65 72 61 20 73 63 61 6e  73 20 61 20 70 69 63 74  |era scans a pict|
00000410  75 72 65 2e 20 20 54 68  69 73 20 6e 6f 6e 2d 6c  |ure.  This non-l|
00000420  69 6e 65 61 72 69 74 79  20 69 73 20 63 61 75 73  |inearity is caus|
00000430  65 64 0d 62 79 20 74 68  65 20 6e 65 65 64 20 74  |ed.by the need t|
00000440  6f 20 72 65 66 72 65 73  68 20 74 68 65 20 64 79  |o refresh the dy|
00000450  6e 61 6d 69 63 20 52 41  4d 20 69 6e 20 74 68 65  |namic RAM in the|
00000460  20 6d 69 63 72 6f 2e 0d  0d 54 6f 20 72 65 6c 61  | micro...To rela|
00000470  74 65 20 61 20 70 69 78  65 6c 20 74 6f 20 69 74  |te a pixel to it|
00000480  73 20 73 63 72 65 65 6e  20 61 64 64 72 65 73 73  |s screen address|
00000490  20 79 6f 75 20 6e 65 65  64 20 61 20 73 69 6d 70  | you need a simp|
000004a0  6c 65 0d 66 6f 72 6d 75  6c 61 2c 20 62 75 74 20  |le.formula, but |
000004b0  6f 6e 65 20 77 68 69 63  68 20 69 6e 63 6c 75 64  |one which includ|
000004c0  65 73 20 6d 75 63 68 20  6d 75 6c 74 69 70 6c 79  |es much multiply|
000004d0  69 6e 67 20 62 79 20 26  32 38 30 2e 20 0d 53 6f  |ing by &280. .So|
000004e0  20 77 72 69 74 69 6e 67  20 61 20 70 72 6f 67 72  | writing a progr|
000004f0  61 6d 20 74 6f 20 70 6f  6b 65 20 74 68 65 20 73  |am to poke the s|
00000500  63 72 65 65 6e 20 69 73  20 6e 6f 74 20 76 65 72  |creen is not ver|
00000510  79 0d 73 74 72 61 69 67  68 74 66 6f 72 77 61 72  |y.straightforwar|
00000520  64 2e 0d 0d 4d 6f 72 65  20 69 6d 70 6f 72 74 61  |d...More importa|
00000530  6e 74 6c 79 2c 20 61 6e  64 20 74 68 69 73 20 6d  |ntly, and this m|
00000540  69 67 68 74 20 73 6f 75  6e 64 20 61 20 6c 69 74  |ight sound a lit|
00000550  74 6c 65 20 73 69 6c 6c  79 2c 20 62 75 74 0d 79  |tle silly, but.y|
00000560  6f 75 20 63 61 6e 20 6e  6f 74 20 62 65 20 73 75  |ou can not be su|
00000570  72 65 20 77 68 65 72 65  20 74 68 65 20 73 63 72  |re where the scr|
00000580  65 65 6e 20 77 69 6c 6c  20 62 65 20 69 6e 20 66  |een will be in f|
00000590  75 74 75 72 65 0d 6d 61  63 68 69 6e 65 73 2e 20  |uture.machines. |
000005a0  20 46 75 74 75 72 65 2d  70 72 6f 6f 66 69 6e 67  | Future-proofing|
000005b0  20 79 6f 75 72 20 6d 61  63 68 69 6e 65 20 63 6f  | your machine co|
000005c0  64 65 20 69 73 20 74 68  65 0d 73 74 72 6f 6e 67  |de is the.strong|
000005d0  65 73 74 20 61 72 67 75  6d 65 6e 74 20 66 6f 72  |est argument for|
000005e0  20 6c 65 67 61 6c 20 63  6f 64 65 20 61 6e 64 2c  | legal code and,|
000005f0  20 69 6e 20 61 6c 6c 20  63 61 73 65 73 20 65 78  | in all cases ex|
00000600  63 65 70 74 0d 61 72 63  61 64 65 20 67 61 6d 65  |cept.arcade game|
00000610  73 2c 20 69 73 20 70 72  65 74 74 79 20 75 6e 63  |s, is pretty unc|
00000620  68 61 6c 6c 65 6e 67 65  61 62 6c 65 2e 0d 0d 46  |hallengeable...F|
00000630  6f 72 20 65 78 61 6d 70  6c 65 2c 20 69 6e 20 61  |or example, in a|
00000640  20 42 42 43 20 4d 6f 64  65 6c 20 41 20 74 68 65  | BBC Model A the|
00000650  20 73 63 72 65 65 6e 20  61 64 64 72 65 73 73 65  | screen addresse|
00000660  73 20 61 72 65 20 26 34  30 30 30 0d 6c 6f 77 65  |s are &4000.lowe|
00000670  72 20 28 77 68 65 72 65  20 74 68 65 20 6d 6f 64  |r (where the mod|
00000680  65 73 20 65 78 69 73 74  29 20 74 68 61 6e 20 6f  |es exist) than o|
00000690  6e 20 61 20 4d 6f 64 65  6c 20 42 2e 20 20 57 68  |n a Model B.  Wh|
000006a0  65 6e 20 79 6f 75 0d 69  6e 74 72 6f 64 75 63 65  |en you.introduce|
000006b0  20 73 68 61 64 6f 77 20  52 41 4d 20 69 6e 20 61  | shadow RAM in a|
000006c0  20 42 2b 20 6f 72 20 61  20 4d 61 73 74 65 72 20  | B+ or a Master |
000006d0  79 6f 75 20 66 69 6e 64  20 74 68 61 74 20 79 6f  |you find that yo|
000006e0  75 0d 6d 69 67 68 74 20  77 65 6c 6c 20 62 65 20  |u.might well be |
000006f0  73 75 72 65 20 6f 66 20  74 68 65 20 61 64 64 72  |sure of the addr|
00000700  65 73 73 20 62 75 74 20  79 6f 75 20 77 69 6c 6c  |ess but you will|
00000710  20 6e 6f 74 20 6b 6e 6f  77 0d 77 68 65 74 68 65  | not know.whethe|
00000720  72 20 69 74 20 6c 69 65  73 20 69 6e 20 74 68 65  |r it lies in the|
00000730  20 73 61 6d 65 20 62 61  6e 6b 20 6f 66 20 52 41  | same bank of RA|
00000740  4d 20 69 6e 20 77 68 69  63 68 20 79 6f 75 72 20  |M in which your |
00000750  63 6f 64 65 0d 69 73 20  62 65 69 6e 67 20 65 78  |code.is being ex|
00000760  65 63 75 74 65 64 2e 20  20 54 68 69 73 20 61 6c  |ecuted.  This al|
00000770  73 6f 20 6d 65 61 6e 73  20 74 68 61 74 20 79 6f  |so means that yo|
00000780  75 20 63 61 6e 20 6e 6f  74 0d 64 69 72 65 63 74  |u can not.direct|
00000790  6c 79 20 70 6f 6b 65 20  74 68 65 20 73 63 72 65  |ly poke the scre|
000007a0  65 6e 20 66 72 6f 6d 20  61 20 73 65 63 6f 6e 64  |en from a second|
000007b0  20 70 72 6f 63 65 73 73  6f 72 20 77 69 74 68 6f  | processor witho|
000007c0  75 74 0d 75 73 69 6e 67  20 61 6e 20 4f 53 20 63  |ut.using an OS c|
000007d0  61 6c 6c 20 74 6f 20 63  72 6f 73 73 20 74 68 65  |all to cross the|
000007e0  20 54 75 62 65 2e 20 20  46 75 74 75 72 65 20 33  | Tube.  Future 3|
000007f0  32 20 62 69 74 20 42 42  43 0d 4d 69 63 72 6f 73  |2 bit BBC.Micros|
00000800  20 6d 61 79 20 77 65 6c  6c 20 68 61 76 65 20 74  | may well have t|
00000810  68 65 20 73 63 72 65 65  6e 20 73 6f 6d 65 77 68  |he screen somewh|
00000820  65 72 65 20 74 6f 74 61  6c 6c 79 20 6e 65 77 20  |ere totally new |
00000830  61 67 61 69 6e 2e 0d 0d  54 68 65 20 74 68 69 72  |again...The thir|
00000840  64 20 64 69 73 61 64 76  61 6e 74 61 67 65 20 74  |d disadvantage t|
00000850  6f 20 64 69 72 65 63 74  6c 79 20 61 64 64 72 65  |o directly addre|
00000860  73 73 69 6e 67 20 74 68  65 20 73 63 72 65 65 6e  |ssing the screen|
00000870  20 69 73 0d 74 68 61 74  20 63 68 61 6e 67 69 6e  | is.that changin|
00000880  67 20 79 6f 75 72 20 73  63 72 65 65 6e 20 6d 6f  |g your screen mo|
00000890  64 65 20 6d 65 61 6e 73  20 79 6f 75 20 68 61 76  |de means you hav|
000008a0  65 20 74 6f 20 63 6f 6d  70 6c 65 74 65 6c 79 0d  |e to completely.|
000008b0  72 65 77 72 69 74 65 20  79 6f 75 72 20 73 63 72  |rewrite your scr|
000008c0  65 65 6e 20 61 63 63 65  73 73 69 6e 67 20 63 6f  |een accessing co|
000008d0  64 65 20 73 69 6e 63 65  20 74 68 65 20 72 65 6c  |de since the rel|
000008e0  61 74 69 6f 6e 20 73 68  69 70 0d 62 65 74 77 65  |ation ship.betwe|
000008f0  65 6e 20 62 79 74 65 73  20 61 6e 64 20 70 69 78  |en bytes and pix|
00000900  65 6c 73 20 69 73 20 64  69 66 66 65 72 65 6e 74  |els is different|
00000910  20 66 6f 72 20 65 61 63  68 20 6d 6f 64 65 2e 0d  | for each mode..|
00000920  0d 41 73 20 61 20 67 65  6e 65 72 61 6c 20 72 75  |.As a general ru|
00000930  6c 65 20 79 6f 75 20 73  68 6f 75 6c 64 20 6e 6f  |le you should no|
00000940  74 20 70 6f 6b 65 20 74  68 65 20 73 63 72 65 65  |t poke the scree|
00000950  6e 2c 20 6f 72 20 69 6e  64 65 65 64 0d 61 6e 79  |n, or indeed.any|
00000960  20 6f 74 68 65 72 20 70  61 72 74 20 6f 66 20 74  | other part of t|
00000970  68 65 20 4f 53 20 6f 72  20 42 41 53 49 43 20 77  |he OS or BASIC w|
00000980  6f 72 6b 73 70 61 63 65  20 6d 65 6d 6f 72 79 2e  |orkspace memory.|
00000990  20 20 42 75 74 20 69 66  0d 79 6f 75 72 20 63 6f  |  But if.your co|
000009a0  64 65 20 63 6f 75 6c 64  20 62 65 20 63 6f 6e 73  |de could be cons|
000009b0  69 64 65 72 65 64 20 74  6f 20 62 65 20 61 6e 20  |idered to be an |
000009c0  65 78 74 65 6e 73 69 6f  6e 20 6f 66 20 74 68 65  |extension of the|
000009d0  20 4f 53 0d 28 73 75 63  68 20 61 73 20 61 20 6d  | OS.(such as a m|
000009e0  6f 75 73 65 20 70 6f 69  6e 74 65 72 20 69 6d 70  |ouse pointer imp|
000009f0  6c 69 6d 65 6e 74 61 74  69 6f 6e 29 20 79 6f 75  |limentation) you|
00000a00  20 63 6f 75 6c 64 20 63  6c 61 69 6d 20 74 6f 0d  | could claim to.|
00000a10  68 61 76 65 20 74 68 65  20 72 69 67 68 74 20 74  |have the right t|
00000a20  6f 20 64 6f 20 73 6f 2e  20 20 49 6e 20 74 68 69  |o do so.  In thi|
00000a30  73 20 63 61 73 65 20 79  6f 75 20 77 6f 75 6c 64  |s case you would|
00000a40  20 68 61 76 65 20 74 6f  0d 70 72 6f 64 75 63 65  | have to.produce|
00000a50  20 61 20 64 69 66 66 65  72 65 6e 74 20 76 65 72  | a different ver|
00000a60  73 69 6f 6e 20 6f 66 20  79 6f 75 72 20 63 6f 64  |sion of your cod|
00000a70  65 20 66 6f 72 20 65 61  63 68 20 70 6f 73 73 69  |e for each possi|
00000a80  62 6c 65 0d 6d 61 63 68  69 6e 65 20 75 73 65 64  |ble.machine used|
00000a90  20 62 79 20 79 6f 75 72  20 75 73 65 72 73 2e 20  | by your users. |
00000aa0  20 49 66 20 79 6f 75 20  61 72 65 20 6a 75 73 74  | If you are just|
00000ab0  20 77 72 69 74 69 6e 67  20 66 6f 72 0d 79 6f 75  | writing for.you|
00000ac0  72 73 65 6c 66 20 74 68  65 6e 20 61 6c 6c 20 74  |rself then all t|
00000ad0  68 65 73 65 20 61 72 67  75 6d 65 6e 74 73 20 61  |hese arguments a|
00000ae0  72 65 20 73 70 75 72 69  6f 75 73 20 61 6e 79 77  |re spurious anyw|
00000af0  61 79 2e 0d 0d 4f 6e 65  20 69 6e 74 65 72 65 73  |ay...One interes|
00000b00  74 69 6e 67 6c 79 20 62  6c 75 72 72 65 64 20 61  |tingly blurred a|
00000b10  72 65 61 20 6f 66 20 69  6c 6c 65 67 61 6c 69 74  |rea of illegalit|
00000b20  79 20 28 61 73 20 64 65  66 69 6e 65 64 20 62 79  |y (as defined by|
00000b30  0d 41 63 6f 72 6e 29 20  69 73 20 56 44 55 20 76  |.Acorn) is VDU v|
00000b40  61 72 69 61 62 6c 65 73  2e 20 20 54 68 65 20 4d  |ariables.  The M|
00000b50  61 73 74 65 72 20 52 65  66 65 72 65 6e 63 65 20  |aster Reference |
00000b60  4d 61 6e 75 61 6c 0d 28  70 75 62 6c 69 73 68 65  |Manual.(publishe|
00000b70  64 20 62 79 20 41 63 6f  72 6e 29 20 61 63 74 75  |d by Acorn) actu|
00000b80  61 6c 6c 79 20 67 69 76  65 73 20 79 6f 75 20 69  |ally gives you i|
00000b90  6e 66 6f 72 6d 61 74 69  6f 6e 20 74 6f 0d 65 6e  |nformation to.en|
00000ba0  61 62 6c 65 20 79 6f 75  20 74 6f 20 61 63 63 65  |able you to acce|
00000bb0  73 73 20 74 68 65 20 56  44 55 20 76 61 72 69 61  |ss the VDU varia|
00000bc0  62 6c 65 73 20 64 69 72  65 63 74 6c 79 2e 20 20  |bles directly.  |
00000bd0  54 68 65 73 65 20 61 72  65 0d 74 68 65 20 62 79  |These are.the by|
00000be0  74 65 73 20 69 6e 20 6d  65 6d 6f 72 79 20 77 68  |tes in memory wh|
00000bf0  69 63 68 20 63 6f 6e 74  72 6f 6c 20 6d 6f 64 65  |ich control mode|
00000c00  20 64 65 66 69 6e 69 74  69 6f 6e 2c 20 61 6d 6f  | definition, amo|
00000c10  6e 67 73 74 0d 6f 74 68  65 72 20 74 68 69 6e 67  |ngst.other thing|
00000c20  73 2e 20 20 48 6f 77 65  76 65 72 20 79 6f 75 20  |s.  However you |
00000c30  61 72 65 20 74 6f 6c 64  20 74 6f 20 75 73 65 20  |are told to use |
00000c40  4f 53 42 59 54 45 20 63  61 6c 6c 73 20 74 6f 0d  |OSBYTE calls to.|
00000c50  72 65 61 64 20 74 68 65  20 76 61 72 69 61 62 6c  |read the variabl|
00000c60  65 73 20 61 6e 64 20 74  6f 20 72 65 61 64 20 74  |es and to read t|
00000c70  68 65 20 6d 65 6d 6f 72  79 20 61 64 64 72 65 73  |he memory addres|
00000c80  73 20 77 68 65 72 65 20  74 68 65 79 0d 73 74 61  |s where they.sta|
00000c90  72 74 20 61 6e 64 20 74  68 65 6e 20 6f 66 66 73  |rt and then offs|
00000ca0  65 74 20 79 6f 75 72 20  77 72 69 74 65 73 20 66  |et your writes f|
00000cb0  72 6f 6d 20 74 68 61 74  2e 20 20 49 66 2c 20 69  |rom that.  If, i|
00000cc0  6e 20 66 75 74 75 72 65  0d 6d 61 63 68 69 6e 65  |n future.machine|
00000cd0  73 2c 20 74 68 65 20 74  61 62 6c 65 20 6d 6f 76  |s, the table mov|
00000ce0  65 73 20 74 68 65 6e 20  79 6f 75 72 20 63 6f 64  |es then your cod|
00000cf0  65 20 73 68 6f 75 6c 64  20 73 74 69 6c 6c 20 77  |e should still w|
00000d00  6f 72 6b 0d 69 66 20 79  6f 75 20 75 73 65 64 20  |ork.if you used |
00000d10  74 68 65 20 72 65 6c 65  76 61 6e 74 20 4f 53 42  |the relevant OSB|
00000d20  59 54 45 20 63 61 6c 6c  73 2e 0d 0d 54 68 65 20  |YTE calls...The |
00000d30  42 42 43 20 4d 69 63 72  6f 20 6f 70 65 72 61 74  |BBC Micro operat|
00000d40  69 6e 67 20 73 79 73 74  65 6d 20 70 72 6f 76 69  |ing system provi|
00000d50  64 65 73 20 61 20 77 69  64 65 20 72 61 6e 67 65  |des a wide range|
00000d60  20 6f 66 0d 63 61 6c 6c  73 20 74 6f 20 68 65 6c  | of.calls to hel|
00000d70  70 20 79 6f 75 72 20 70  72 6f 67 72 61 6d 6d 69  |p your programmi|
00000d80  6e 67 2e 20 20 41 63 6f  72 6e 27 73 20 6d 69 63  |ng.  Acorn's mic|
00000d90  72 6f 73 20 64 6f 20 6e  6f 74 20 68 61 76 65 0d  |ros do not have.|
00000da0  61 20 63 6c 6f 73 65 64  20 61 6e 64 20 75 6e 64  |a closed and und|
00000db0  6f 63 75 6d 65 6e 74 65  64 20 4f 53 20 6c 69 6b  |ocumented OS lik|
00000dc0  65 20 73 6f 6d 65 20 68  6f 6d 65 20 6d 61 63 68  |e some home mach|
00000dd0  69 6e 65 73 2c 20 61 6e  64 0d 65 76 65 6e 20 73  |ines, and.even s|
00000de0  6f 6d 65 20 6d 61 69 6e  66 72 61 6d 65 73 2e 20  |ome mainframes. |
00000df0  20 53 6f 2c 20 69 66 20  79 6f 75 20 63 61 6e 2c  | So, if you can,|
00000e00  20 75 73 65 20 74 68 65  20 72 65 6c 65 76 61 6e  | use the relevan|
00000e10  74 20 4f 53 0d 63 61 6c  6c 2e 0d 0d 4f 6e 65 20  |t OS.call...One |
00000e20  6f 66 20 74 68 65 20 74  6f 70 20 70 72 6f 67 72  |of the top progr|
00000e30  61 6d 6d 65 72 73 20 61  74 20 41 63 6f 72 6e 2c  |ammers at Acorn,|
00000e40  20 61 6e 64 20 74 68 65  20 6d 61 6e 20 77 68 6f  | and the man who|
00000e50  20 77 72 6f 74 65 0d 42  42 43 20 42 41 53 49 43  | wrote.BBC BASIC|
00000e60  2c 20 6f 66 74 65 6e 20  73 61 79 73 20 74 68 61  |, often says tha|
00000e70  74 20 74 68 65 20 62 65  73 74 20 74 65 73 74 20  |t the best test |
00000e80  6f 66 20 6c 65 67 61 6c  69 74 79 20 69 73 20 69  |of legality is i|
00000e90  66 0d 74 68 65 20 63 6f  64 65 20 77 69 6c 6c 20  |f.the code will |
00000ea0  72 75 6e 20 69 6e 20 61  20 36 35 30 32 20 73 65  |run in a 6502 se|
00000eb0  63 6f 6e 64 20 70 72 6f  63 65 73 73 6f 72 20 61  |cond processor a|
00000ec0  6e 64 20 64 6f 20 69 74  73 20 6a 6f 62 0d 63 6f  |nd do its job.co|
00000ed0  72 72 65 63 74 6c 79 2e  20 20 41 6c 74 68 6f 75  |rrectly.  Althou|
00000ee0  67 68 20 74 68 65 72 65  20 61 72 65 20 73 6f 6d  |gh there are som|
00000ef0  65 20 6c 65 67 61 6c 20  74 72 69 63 6b 73 20 74  |e legal tricks t|
00000f00  68 61 74 20 77 6f 72 6b  0d 6f 6e 6c 79 20 69 6e  |hat work.only in|
00000f10  20 74 68 65 20 6d 61 69  6e 20 6d 69 63 72 6f 20  | the main micro |
00000f20  74 68 69 73 20 69 73 20  61 20 67 6f 6f 64 20 72  |this is a good r|
00000f30  75 6c 65 20 6f 66 20 74  68 75 6d 62 2e 0d 0d 54  |ule of thumb...T|
00000f40  68 65 20 70 72 6f 67 72  61 6d 20 69 6e 20 74 68  |he program in th|
00000f50  69 73 20 6d 6f 64 75 6c  65 20 69 73 20 61 20 73  |is module is a s|
00000f60  63 72 65 65 6e 20 66 69  6c 6c 20 72 6f 75 74 69  |creen fill routi|
00000f70  6e 65 20 74 68 61 74 0d  61 64 64 72 65 73 73 65  |ne that.addresse|
00000f80  73 20 74 68 65 20 73 63  72 65 65 6e 20 64 69 72  |s the screen dir|
00000f90  65 63 74 6c 79 2e 20 20  54 6f 20 75 73 65 20 69  |ectly.  To use i|
00000fa0  74 20 79 6f 75 20 6d 75  73 74 20 62 65 0d 72 75  |t you must be.ru|
00000fb0  6e 6e 69 6e 67 20 69 6e  20 74 68 65 20 6d 69 63  |nning in the mic|
00000fc0  72 6f 20 69 74 73 65 6c  66 2c 20 6e 6f 74 20 61  |ro itself, not a|
00000fd0  20 73 65 63 6f 6e 64 20  70 72 6f 63 65 73 73 6f  | second processo|
00000fe0  72 2c 20 61 6e 64 20 79  6f 75 0d 6d 75 73 74 20  |r, and you.must |
00000ff0  6e 6f 74 20 68 61 76 65  20 73 68 61 64 6f 77 20  |not have shadow |
00001000  6d 6f 64 65 20 65 6e 67  61 67 65 64 2e 20 20 49  |mode engaged.  I|
00001010  74 27 73 20 6e 6f 74 20  61 20 70 61 72 74 69 63  |t's not a partic|
00001020  75 6c 61 72 6c 79 0d 65  6c 65 67 61 6e 74 20 70  |ularly.elegant p|
00001030  69 65 63 65 20 6f 66 20  63 6f 64 65 20 73 69 6e  |iece of code sin|
00001040  63 65 20 6d 6f 73 74 20  6f 66 20 69 74 20 69 73  |ce most of it is|
00001050  20 74 61 6b 65 6e 20 75  70 20 77 69 74 68 0d 63  | taken up with.c|
00001060  61 6c 63 75 6c 61 74 69  6f 6e 73 20 74 6f 20 66  |alculations to f|
00001070  69 6e 64 20 74 68 65 20  73 63 72 65 65 6e 20 61  |ind the screen a|
00001080  64 64 72 65 73 73 20 74  68 61 74 20 72 65 6c 61  |ddress that rela|
00001090  74 65 73 20 74 6f 20 61  0d 67 72 61 70 68 69 63  |tes to a.graphic|
000010a0  73 20 63 6f 6f 72 64 69  6e 61 74 65 2e 20 20 49  |s coordinate.  I|
000010b0  74 20 77 69 6e 64 73 20  75 70 20 62 65 69 6e 67  |t winds up being|
000010c0  20 68 61 6c 66 20 74 68  65 20 73 70 65 65 64 20  | half the speed |
000010d0  6f 66 0d 74 68 65 20 43  4c 47 20 63 6f 6d 6d 61  |of.the CLG comma|
000010e0  6e 64 20 69 6e 20 42 41  53 49 43 20 62 75 74 20  |nd in BASIC but |
000010f0  6d 75 63 68 20 66 61 73  74 65 72 20 74 68 61 6e  |much faster than|
00001100  20 75 73 69 6e 67 20 50  4c 4f 54 73 20 74 6f 0d  | using PLOTs to.|
00001110  64 6f 20 74 68 65 20 73  61 6d 65 20 6a 6f 62 2c  |do the same job,|
00001120  20 70 69 78 65 6c 20 62  79 20 70 69 78 65 6c 2e  | pixel by pixel.|
00001130  0d 0d 57 68 65 6e 20 79  6f 75 20 68 61 76 65 20  |..When you have |
00001140  72 75 6e 20 74 68 65 20  70 72 6f 67 72 61 6d 2c  |run the program,|
00001150  20 69 6e 20 77 68 61 74  65 76 65 72 20 6d 6f 64  | in whatever mod|
00001160  65 2c 20 79 6f 75 20 70  72 65 73 73 0d 66 75 6e  |e, you press.fun|
00001170  63 74 69 6f 6e 20 6b 65  79 20 34 20 61 6e 64 20  |ction key 4 and |
00001180  74 68 65 20 72 6f 75 74  69 6e 65 20 77 69 6c 6c  |the routine will|
00001190  20 66 69 6c 6c 20 74 68  65 20 73 63 72 65 65 6e  | fill the screen|
000011a0  20 69 6e 20 6d 6f 64 65  0d 31 2e 20 20 54 68 65  | in mode.1.  The|
000011b0  20 42 41 53 49 43 20 54  49 4d 45 20 66 61 63 69  | BASIC TIME faci|
000011c0  6c 69 74 79 20 77 69 6c  6c 20 67 69 76 65 20 61  |lity will give a|
000011d0  20 72 6f 75 67 68 20 74  69 6d 69 6e 67 20 66 6f  | rough timing fo|
000011e0  72 20 74 68 65 0d 70 72  6f 63 65 64 75 72 65 2c  |r the.procedure,|
000011f0  20 77 68 69 63 68 20 69  73 20 61 62 6f 75 74 20  | which is about |
00001200  31 2e 31 20 73 65 63 6f  6e 64 73 2e 20 20 4c 69  |1.1 seconds.  Li|
00001210  6e 65 20 37 34 30 20 6f  66 20 74 68 65 20 63 6f  |ne 740 of the co|
00001220  64 65 0d 73 65 74 73 20  74 68 65 20 62 79 74 65  |de.sets the byte|
00001230  20 74 6f 20 62 65 20 70  6f 6b 65 64 20 74 6f 20  | to be poked to |
00001240  74 68 65 20 73 63 72 65  65 6e 2e 20 20 26 30 30  |the screen.  &00|
00001250  20 77 69 6c 6c 20 70 72  6f 64 75 63 65 0d 62 6c  | will produce.bl|
00001260  61 63 6b 2c 20 26 30 46  20 70 72 6f 64 75 63 65  |ack, &0F produce|
00001270  73 20 72 65 64 2c 20 26  46 30 20 70 72 6f 64 75  |s red, &F0 produ|
00001280  63 65 73 20 79 65 6c 6c  6f 77 20 61 6e 64 20 26  |ces yellow and &|
00001290  46 46 0d 70 72 6f 64 75  63 65 73 20 77 68 69 74  |FF.produces whit|
000012a0  65 2e 20 20 49 6e 20 6d  6f 64 65 20 31 20 28 61  |e.  In mode 1 (a|
000012b0  73 20 77 65 20 68 61 76  65 20 68 65 72 65 29 20  |s we have here) |
000012c0  74 68 65 72 65 20 61 72  65 20 32 0d 62 69 74 73  |there are 2.bits|
000012d0  20 70 65 72 20 70 69 78  65 6c 20 74 6f 20 73 65  | per pixel to se|
000012e0  74 20 63 6f 6c 6f 75 72  20 61 6e 64 20 74 68 65  |t colour and the|
000012f0  79 20 67 72 6f 75 70 20  34 20 70 69 78 65 6c 73  |y group 4 pixels|
00001300  20 74 6f 20 61 0d 62 79  74 65 20 6c 69 6b 65 20  | to a.byte like |
00001310  74 68 69 73 3a 0d 0d 20  20 20 20 20 20 20 20 20  |this:..         |
00001320  20 43 6f 6c 6f 75 72 20  6f 66 20 70 69 78 65 6c  | Colour of pixel|
00001330  20 31 20 2d 20 62 69 74  73 20 37 20 61 6e 64 20  | 1 - bits 7 and |
00001340  33 0d 20 20 20 20 20 20  20 20 20 20 43 6f 6c 6f  |3.          Colo|
00001350  75 72 20 6f 66 20 70 69  78 65 6c 20 32 20 2d 20  |ur of pixel 2 - |
00001360  62 69 74 73 20 36 20 61  6e 64 20 32 0d 20 20 20  |bits 6 and 2.   |
00001370  20 20 20 20 20 20 20 43  6f 6c 6f 75 72 20 6f 66  |       Colour of|
00001380  20 70 69 78 65 6c 20 33  20 2d 20 62 69 74 73 20  | pixel 3 - bits |
00001390  35 20 61 6e 64 20 31 0d  20 20 20 20 20 20 20 20  |5 and 1.        |
000013a0  20 20 43 6f 6c 6f 75 72  20 6f 66 20 70 69 78 65  |  Colour of pixe|
000013b0  6c 20 34 20 2d 20 62 69  74 73 20 34 20 61 6e 64  |l 4 - bits 4 and|
000013c0  20 30 0d 0d 54 68 61 74  20 6a 75 73 74 20 61 62  | 0..That just ab|
000013d0  6f 75 74 20 62 72 69 6e  67 73 20 75 73 20 74 6f  |out brings us to|
000013e0  20 74 68 65 20 65 6e 64  20 6f 66 20 74 68 69 73  | the end of this|
000013f0  20 6d 65 61 6e 64 65 72  20 74 68 72 6f 75 67 68  | meander through|
00001400  0d 6d 61 63 68 69 6e 65  20 63 6f 64 65 20 6f 6e  |.machine code on|
00001410  20 74 68 65 20 42 42 43  2e 20 20 54 68 65 20 66  | the BBC.  The f|
00001420  69 6e 61 6c 20 6d 6f 64  75 6c 65 20 77 69 6c 6c  |inal module will|
00001430  20 6f 66 66 65 72 20 73  6f 6d 65 0d 73 75 67 67  | offer some.sugg|
00001440  65 73 74 69 6f 6e 73 20  66 6f 72 20 75 73 69 6e  |estions for usin|
00001450  67 20 61 20 77 6f 72 64  20 70 72 6f 63 65 73 73  |g a word process|
00001460  6f 72 20 28 73 75 63 68  20 61 73 20 56 49 45 57  |or (such as VIEW|
00001470  29 20 74 6f 0d 65 64 69  74 20 79 6f 75 72 20 73  |) to.edit your s|
00001480  6f 75 72 63 65 20 63 6f  64 65 2e 0d              |ource code..|
0000148c
06-05-88/T\OSB25.m0
06-05-88/T\OSB25.m1
06-05-88/T\OSB25.m2
06-05-88/T\OSB25.m4
06-05-88/T\OSB25.m5