Home » CEEFAX disks » telesoftware6.adl » 28-03-88/T\OSB19

28-03-88/T\OSB19

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 » telesoftware6.adl
Filename: 28-03-88/T\OSB19
Read OK:
File size: 3F29 bytes
Load address: 0000
Exec address: FFFFFFFF
File contents
OSBITS - An Exploration of the BBC Micro at Machine Level

By Programmer

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


Part 19: Interrupts II  -  Palette Switching using Timers


In the last module we looked at interrupts and I explained
how the OS sets up the registers and memory when it detects
an interrupt.

There are two things to bear in mind about writing interrupt
handling code.  Firstly it must be short, or else some of
the OS housekeeping stops, and it must not re-enable
interrupts.  In fact if you are able to write what is called
re-entrant code, which means your code can be called from
within itself without crashing, then you could enable
interrupts.  This would be achieved by using the stack for
all your storage instead of fixed memory locations. 
Personally I can't make that work during interrupts, so I
always work with interrupts disabled, which is how the OS
sets things up.

One side effect of this is that OS calls that enable
interrupts can not be used during interrupt routines.  This
pretty well means everything except maybe OSBYTE and OSWORD. 
You certainly couldn't use OSWRCH or OSRDCH.

OSWORD 12 (&C) writes to the palette.  This controls the
relationship between the logical colour (the colour number)
and the actual colour (the colour displayed).  You may
remember that from 'BASIC' you use VDU 19 to do this, but
VDU 19 can not be used during an interrupt because VDU
statements use OSWRCH.

What I intend to do in this module is to use OSWORD 12 to
switch the palette for colour 1 in mode 3 so fast that we
can have areas of the screen with different colours in an
otherwise monochromatic mode.

We can detect the field sync pulse using an event and
that will be used to load a timer that waits until the beam 
is at the top of frame before generating an interrupt.  That
interrupt sets the first colour change and loads the timer
for the width of that colour band (in microseconds) and so
the process repeats down the screen.  This whole process is
repeated 50 times every second as a background task.

Okay, so first an explanation of field sync.  Any television
signal has to contain synchronisation pulses along with the
picture information.  That allows the display in the
receiver to be in step with the scanning in the camera, or
in our case, the computer.  In 625 line 50 hertz TV systems
(like PAL, SECAM and their RGB versions) there is a pulse
every 64 microseconds which marks the space between lines,
and is called the line sync pulse.

Every 20 milliseconds there is a second pulse called the
field sync pulse (again these figures only apply to PAL and
SECAM TV signals by the way, not the American/Japanese
standard called NTSC)  This synchronises the fields of the
source and monitor together.  A field is the display of
312.5 lines (in a 625 line signal) and two fields, slightly
displaced vertically, make up a frame.  So there are 50
fields per second, 25 frames per second.  The reasons for
this field/frame business are related to how little flicker
you can see in a picture without refreshing (re-scanning)
the picture so often that your signal bandwidth (the amount
of information carried per unit of time) becomes too big.

All you need to know for computing is that a BBC Micro
refreshes the screen 25 times per second in two fields, each
of a 50th of a second duration.  The field sync pulse starts
when the scanning of the electron beam has reached the
bottom of one field and starts to 'fly back' to the top of
the screen ready for the next field to begin.  This flyback
is also known as the vertical blanking interval (VBI) or
just the vertical interval.  (The term 'blanking' is used
because the beam is turned off during this flyback to stop
you seeing slanted lines across the screen.  If you do see
them then your monitor is not set up correctly!)

You are probably familiar with *FX 19.  This call (OSBYTE
19) forces program execution to wait for the start of the
next vertical interval.  Event number 4 occurs at this point
and we can use event 4 to synchronise the palette switching
that we are going to do here.

Since this event occurs at the start of the VBI we have to
add a delay so that the beam can reach the top of the next
frame before the routine proper can start.

So what do we use to do all this timing?  The VIA includes a
couple of timers, known as T1 and T2.  Essentially the
difference between the two timers is that T1 can be used to
generate pulses or a square wave from a pin of the VIA (and
hence of the user port) while T2 can count down under the
influence of pulses being fed to a pin of the VIA (and user
port).  Both timers can be used to generate an interrupt
after a specified delay.  These timings are done as counts
at 1 MHz, i.e. in microseconds.  That makes these timers
much more accurate that the BASIC TIME function, which in
any case stops during interrupts.

I'll briefly describe the modes of T1 and T2.

T1 - One shot mode

A duration is loaded into the registers, low byte first then
high byte.  When the high order byte is loaded the counter
starts to count down.  On reaching zero an interrupt is
generated.  Loading the high byte also resets the interrupt
flag.

T1 - Free running

In this case whenever the timer hits zero and generates the
interrupt the timer reloads itself with the value held in
what are called its latches.  It was in fact one of these
latches that was written to when you thought you were
writing to the low byte counter.  (You think you're
confused?) You can generate a rectangular wave form from PB7
of the VIA (which appears as a pin on the user port) if you
want to.  If you write to the latches while the counter is
counting down your value will be transferred across at the
next interrupt.  This allows you to pre-set the duration of
the next pulse and it is possible to emulate infra-red
control signals in this way to control your video.

T2 - One shot

Pretty well the same as for T1

T2 -  Pulse counting

T2 can count a preset number of pulses and then generate an
interrupt.

A data sheet for the 6522 VIA will explain this all more
fully, or an Advanced User Guide.  I shall only explain in
detail the operation we will use in this module.

Using a VIA timer as an interval timer involves two
operations.  First we must set up the timer and load it with
the interval (in microseconds) that we wish to count off. 
Then we must monitor the interrupts until we detect one
generated by our timer.

Loading the timer is done by writing to addresses within the
area of memory known as Sheila.  Sheila is a page of memory
running from &FE00 to &FEFF and in it live such pieces of
hardware as the CRTC video controller chip, the Tube, serial
and video ULA chips, the AtoD converter and others.  There
are 11 different devices on Sheila.  We are here interested
in the User VIA which lives from &FE60 to &FE6F.  The base
address for the VIA registers is &FE60 and in the program in
this module, B/osb19, that address is given a variable name
'via'.  [In fact, 32 bytes are allocated for the VIA
although it only uses 16 of them so that register X of the
VIA can be found at &FE6X and &FE7X identically.  You can
prove this by changing the value of 'via' in the program to
&FE70 and you will find no difference in the result.]

As explained in the last module speed is important while
using interrupts and so we will read and write direct rather
than use the OSBYTE calls (numbers 150 and 151) that are
available.

The VIA registers we need for this operation are as follows:

Register 11 - The auxiliary control register

With this register we select the mode of operation of the
timers and shift register.  To put T1 into its 'one shot'
mode we have to make sure that the top two bits of the
register are either both clear or just bit 7 is set.  In the
latter case the voltage on pin PB7 of the VIA will go low
when the timer is started and go back high when it times
out.  This produces a pulse of programmable width.  It
doesn't actually matter whether we set off a pulse on PB7 or
not in this application, but it is probably tidier not to,
so we must clear bits 6 and 7. Lines 540-560 in B/osb19 are
where this is done.

Register 14 - The interrupt enable register

To enable an interrupt we must write to bit 7 of this
register and also to the bit controlling the interrupt we
want to enable.  In the case of T1 it is bit 6.  In lines
570 and 580 we write &C0 to this register and so set T1
interrupts.  (To disable an interrupt you leave bit 7 clear
and write a 1 to the relevant bit or bits.)

Register 4 - Timer 1 low order counter
Register 5 - Timer 1 high order counter

Register 4 is loaded with the lower byte of the two byte
timing value first.  At this time you are actually loading a
latch which holds the value.  When you load the higher byte
of the timer value into register 5 the value in the lower
latch is transferred into the lower counter and the timer
starts counting down.  This loading operation is carried out
in lines 830-860 and 1380-1410.

Register 13 - The interrupt flag register

On receiving an interrupt we can quickly check bit 6 of this
register (using BIT in line 1220) to see if a T1 interrupt
has occurred.  This flag is cleared either by writing a 1
into it, or by reloading the timer.  In this program the
latter method is used since we have to reload the timer
anyway.

Let's go through the program.  B/osb19 takes logical colour
1 and changes its actual colour depending on where,
vertically on the screen, you are.  The width of the
horizontal bands of colour and the colours used are held in
a block of memory and can be modified.  The effect will be
visible in any mode except Mode 7 as graphics and text are
drawn in colour 1.

Since we are making an interrupt routine the code has to
live in the I/O processor and the program checks to make
sure that a second processor is not in use.  I have used
OSBYTE 234 for that this time.  On exit X is 0 if no second
processor is being used and &FF if one is.  There should not
be another result.  This method should be more fool-proof
than simply checking the value of PAGE.

The IRQ and Event vectors are saved and the new intercept
addresses loaded.  You will notice that interrupts are
disabled during the latter operation.  I am using IRQ1
because intercepts of IRQ2 are a little too variable for the
kind of operation here.  You should change the address in
line 110 from &204 to &206 to see the effect I mean.

The bands will flicker rather violently, or at least they do
on my machine.  I suspect that this is due to the time taken
for the OS to finish servicing whatever interrupt occurred
just prior to our timer interrupt.  Our interrupt is
'stored' until interrupts are enabled again, because the
interrupt flags on the VIA remain set, and then it is
serviced by our routine.  This delay, which would be very
variable, leads to delays in implimenting our palette
switching routine and hence causes the flickering.  [The
bands will also 'bounce' when a disc is accessed, this is
due to the NMI routines servicing the disc drive.]

Line 650 to line 970 is the code that lies in the event
vector.  We are waiting for event 4, which will be activated
later.  When we have confirmed that it is indeed event 4,
the vertical sync pulse event, we save registers, force
binary mode and re-set a colour counter flag to zero.  This
flag, called 'colours' is counting the number of the band we
are going to draw on the screen so that the correct colour
can be allocated.

I could have coloured the first band from here but I have
decided to switch the top band in just above the top of
screen.  The time delay between the sync and the top of
screen is found by trial and error and I found it to be &560
microseconds on my machine.  The counter is loaded with this
value and started (lines 830 to 860) and the event intercept
is now over and we exit.

Next I have put the block of memory in which parameters and
flags are stored.  You can actually put this kind of block
anywhere you like within your code, as long as it lies out
of the way of program execution.

A block of 5 bytes at 'para_block' is the parameter block
for the OSWORD call.  I have pre-loaded the first byte with
a '1' which is the logical colour we will be switching. 
Should you want to switch another colour then change this
byte.

You will see that at 'colours' I have put the counter flag
and that after it comes a list of 6 bytes, each containing
the number of a colour.  You can modify this list if you
want to change the colours of the bands.  This code draws up
to six bands but could be easily modified to draw more just
by adding more lines of 'colours' in this section of memory
and adding equivalent 'coltimes' below.  The 'coltimes'
bytes are the length of the bands in units of 256
microseconds.  However, since the interrupt code takes a
finite time to execute you can not shrink a band to nothing
by entering zero.  Try that and see the effect.  Note also
that the final time in the list is &FF or 255.  This is to
make sure that the bottom of the final band is not reached
before the vertical sync.  The last number in the 'coltimes'
block should always be &FF.

Then we have the interrupt code, from line 1170 to line
1610.  First it quickly checks to see if this is a timer 1
interrupt.  Since the accumulator value is safely held in
&FC we can corrupt the accumulator.  This means that this
fast check can be made without saving and restoring
registers.  As this code is sitting as top priority in the
interrupt vector we must very quickly pass on any interrupts
we do not want.  By using BIT we put the value of bit six
straight into the overflow flag and can do a quick branch on
overflow set (BVS) if T1 has timed out and this is indeed
our interrupt.

At line 1280 registers are saved and binary mode is forced. 
Then we take the current value of the colours counter and
transfer it into the X register.  We can now use this to
count along the block of colours and of 'coltimes' to load
the timer and change the colour.  The timer is loaded first,
and restarted (lines 1380 to 1410).  Then OSWORD 12 (&C) is
used to reset the palette for colour 1.

Finally the colour counter is incremented, registers are
restored and we exit with an RTI.

There is no need to check that we have reached the final
band of colour.  This is set to be so wide (255*256
microseconds, which is about 65 milliseconds) that it could
never be finished before the sync event resets everything
ready for the next field.  These sync pulses are only 20
milliseconds apart.

As a useful routine this is obviously incomplete.  You would
have to have some control over the colours and width of the
bands.  Obviously you can write to the values of 'colours'
and 'coltimes' with appropriate offsets.  After running the
assembly just enter 'PRINT colours' and 'PRINT coltimes' to
find those values.  To write to those locations across the
tube, from a second processor, use OSWORD 6.  Here, at the
block of memory pointed to by X and Y (XY) you should put
the 32 bit address of the memory to be written.  As it is in
the I/O processor the top 16 bits should be set.  In XY+4
you will put the byte to be written.

The bit of BASIC at the end of the program in this module
enables the event (*FX 14 4) and prints up some coloured
text in Mode 3 to show you what it looks like.  It's
switching of this kind that enables you to mix several modes
on the screen at once, as in 'Elite'.

I should also mention that there is another way of dealing
with external hardware besides letting the hardware
interrupt the processor.  The OS can poll the hardware at
intervals, probably using an interrupt routine.  By polling
we mean the OS effectively asks for information, rather than
being told it.  You might use this method to get replies
from a device connected via the RS423 for example.

So there you have a couple of forays into interrupts. 
They're not particularly fearsome.  The only thing to
remember is that it is easy to crash the machine and so have
your BREAK key handy.  Next time we head off into more
mathematics as numbers with a decimal point appear.
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 2e 0d 0d 0d 50  61 72 74 20 31 39 3a 20  |.......Part 19: |
00000090  49 6e 74 65 72 72 75 70  74 73 20 49 49 20 20 2d  |Interrupts II  -|
000000a0  20 20 50 61 6c 65 74 74  65 20 53 77 69 74 63 68  |  Palette Switch|
000000b0  69 6e 67 20 75 73 69 6e  67 20 54 69 6d 65 72 73  |ing using Timers|
000000c0  0d 0d 0d 49 6e 20 74 68  65 20 6c 61 73 74 20 6d  |...In the last m|
000000d0  6f 64 75 6c 65 20 77 65  20 6c 6f 6f 6b 65 64 20  |odule we looked |
000000e0  61 74 20 69 6e 74 65 72  72 75 70 74 73 20 61 6e  |at interrupts an|
000000f0  64 20 49 20 65 78 70 6c  61 69 6e 65 64 0d 68 6f  |d I explained.ho|
00000100  77 20 74 68 65 20 4f 53  20 73 65 74 73 20 75 70  |w the OS sets up|
00000110  20 74 68 65 20 72 65 67  69 73 74 65 72 73 20 61  | the registers a|
00000120  6e 64 20 6d 65 6d 6f 72  79 20 77 68 65 6e 20 69  |nd memory when i|
00000130  74 20 64 65 74 65 63 74  73 0d 61 6e 20 69 6e 74  |t detects.an int|
00000140  65 72 72 75 70 74 2e 0d  0d 54 68 65 72 65 20 61  |errupt...There a|
00000150  72 65 20 74 77 6f 20 74  68 69 6e 67 73 20 74 6f  |re two things to|
00000160  20 62 65 61 72 20 69 6e  20 6d 69 6e 64 20 61 62  | bear in mind ab|
00000170  6f 75 74 20 77 72 69 74  69 6e 67 20 69 6e 74 65  |out writing inte|
00000180  72 72 75 70 74 0d 68 61  6e 64 6c 69 6e 67 20 63  |rrupt.handling c|
00000190  6f 64 65 2e 20 20 46 69  72 73 74 6c 79 20 69 74  |ode.  Firstly it|
000001a0  20 6d 75 73 74 20 62 65  20 73 68 6f 72 74 2c 20  | must be short, |
000001b0  6f 72 20 65 6c 73 65 20  73 6f 6d 65 20 6f 66 0d  |or else some of.|
000001c0  74 68 65 20 4f 53 20 68  6f 75 73 65 6b 65 65 70  |the OS housekeep|
000001d0  69 6e 67 20 73 74 6f 70  73 2c 20 61 6e 64 20 69  |ing stops, and i|
000001e0  74 20 6d 75 73 74 20 6e  6f 74 20 72 65 2d 65 6e  |t must not re-en|
000001f0  61 62 6c 65 0d 69 6e 74  65 72 72 75 70 74 73 2e  |able.interrupts.|
00000200  20 20 49 6e 20 66 61 63  74 20 69 66 20 79 6f 75  |  In fact if you|
00000210  20 61 72 65 20 61 62 6c  65 20 74 6f 20 77 72 69  | are able to wri|
00000220  74 65 20 77 68 61 74 20  69 73 20 63 61 6c 6c 65  |te what is calle|
00000230  64 0d 72 65 2d 65 6e 74  72 61 6e 74 20 63 6f 64  |d.re-entrant cod|
00000240  65 2c 20 77 68 69 63 68  20 6d 65 61 6e 73 20 79  |e, which means y|
00000250  6f 75 72 20 63 6f 64 65  20 63 61 6e 20 62 65 20  |our code can be |
00000260  63 61 6c 6c 65 64 20 66  72 6f 6d 0d 77 69 74 68  |called from.with|
00000270  69 6e 20 69 74 73 65 6c  66 20 77 69 74 68 6f 75  |in itself withou|
00000280  74 20 63 72 61 73 68 69  6e 67 2c 20 74 68 65 6e  |t crashing, then|
00000290  20 79 6f 75 20 63 6f 75  6c 64 20 65 6e 61 62 6c  | you could enabl|
000002a0  65 0d 69 6e 74 65 72 72  75 70 74 73 2e 20 20 54  |e.interrupts.  T|
000002b0  68 69 73 20 77 6f 75 6c  64 20 62 65 20 61 63 68  |his would be ach|
000002c0  69 65 76 65 64 20 62 79  20 75 73 69 6e 67 20 74  |ieved by using t|
000002d0  68 65 20 73 74 61 63 6b  20 66 6f 72 0d 61 6c 6c  |he stack for.all|
000002e0  20 79 6f 75 72 20 73 74  6f 72 61 67 65 20 69 6e  | your storage in|
000002f0  73 74 65 61 64 20 6f 66  20 66 69 78 65 64 20 6d  |stead of fixed m|
00000300  65 6d 6f 72 79 20 6c 6f  63 61 74 69 6f 6e 73 2e  |emory locations.|
00000310  20 0d 50 65 72 73 6f 6e  61 6c 6c 79 20 49 20 63  | .Personally I c|
00000320  61 6e 27 74 20 6d 61 6b  65 20 74 68 61 74 20 77  |an't make that w|
00000330  6f 72 6b 20 64 75 72 69  6e 67 20 69 6e 74 65 72  |ork during inter|
00000340  72 75 70 74 73 2c 20 73  6f 20 49 0d 61 6c 77 61  |rupts, so I.alwa|
00000350  79 73 20 77 6f 72 6b 20  77 69 74 68 20 69 6e 74  |ys work with int|
00000360  65 72 72 75 70 74 73 20  64 69 73 61 62 6c 65 64  |errupts disabled|
00000370  2c 20 77 68 69 63 68 20  69 73 20 68 6f 77 20 74  |, which is how t|
00000380  68 65 20 4f 53 0d 73 65  74 73 20 74 68 69 6e 67  |he OS.sets thing|
00000390  73 20 75 70 2e 0d 0d 4f  6e 65 20 73 69 64 65 20  |s up...One side |
000003a0  65 66 66 65 63 74 20 6f  66 20 74 68 69 73 20 69  |effect of this i|
000003b0  73 20 74 68 61 74 20 4f  53 20 63 61 6c 6c 73 20  |s that OS calls |
000003c0  74 68 61 74 20 65 6e 61  62 6c 65 0d 69 6e 74 65  |that enable.inte|
000003d0  72 72 75 70 74 73 20 63  61 6e 20 6e 6f 74 20 62  |rrupts can not b|
000003e0  65 20 75 73 65 64 20 64  75 72 69 6e 67 20 69 6e  |e used during in|
000003f0  74 65 72 72 75 70 74 20  72 6f 75 74 69 6e 65 73  |terrupt routines|
00000400  2e 20 20 54 68 69 73 0d  70 72 65 74 74 79 20 77  |.  This.pretty w|
00000410  65 6c 6c 20 6d 65 61 6e  73 20 65 76 65 72 79 74  |ell means everyt|
00000420  68 69 6e 67 20 65 78 63  65 70 74 20 6d 61 79 62  |hing except mayb|
00000430  65 20 4f 53 42 59 54 45  20 61 6e 64 20 4f 53 57  |e OSBYTE and OSW|
00000440  4f 52 44 2e 20 0d 59 6f  75 20 63 65 72 74 61 69  |ORD. .You certai|
00000450  6e 6c 79 20 63 6f 75 6c  64 6e 27 74 20 75 73 65  |nly couldn't use|
00000460  20 4f 53 57 52 43 48 20  6f 72 20 4f 53 52 44 43  | OSWRCH or OSRDC|
00000470  48 2e 0d 0d 4f 53 57 4f  52 44 20 31 32 20 28 26  |H...OSWORD 12 (&|
00000480  43 29 20 77 72 69 74 65  73 20 74 6f 20 74 68 65  |C) writes to the|
00000490  20 70 61 6c 65 74 74 65  2e 20 20 54 68 69 73 20  | palette.  This |
000004a0  63 6f 6e 74 72 6f 6c 73  20 74 68 65 0d 72 65 6c  |controls the.rel|
000004b0  61 74 69 6f 6e 73 68 69  70 20 62 65 74 77 65 65  |ationship betwee|
000004c0  6e 20 74 68 65 20 6c 6f  67 69 63 61 6c 20 63 6f  |n the logical co|
000004d0  6c 6f 75 72 20 28 74 68  65 20 63 6f 6c 6f 75 72  |lour (the colour|
000004e0  20 6e 75 6d 62 65 72 29  0d 61 6e 64 20 74 68 65  | number).and the|
000004f0  20 61 63 74 75 61 6c 20  63 6f 6c 6f 75 72 20 28  | actual colour (|
00000500  74 68 65 20 63 6f 6c 6f  75 72 20 64 69 73 70 6c  |the colour displ|
00000510  61 79 65 64 29 2e 20 20  59 6f 75 20 6d 61 79 0d  |ayed).  You may.|
00000520  72 65 6d 65 6d 62 65 72  20 74 68 61 74 20 66 72  |remember that fr|
00000530  6f 6d 20 27 42 41 53 49  43 27 20 79 6f 75 20 75  |om 'BASIC' you u|
00000540  73 65 20 56 44 55 20 31  39 20 74 6f 20 64 6f 20  |se VDU 19 to do |
00000550  74 68 69 73 2c 20 62 75  74 0d 56 44 55 20 31 39  |this, but.VDU 19|
00000560  20 63 61 6e 20 6e 6f 74  20 62 65 20 75 73 65 64  | can not be used|
00000570  20 64 75 72 69 6e 67 20  61 6e 20 69 6e 74 65 72  | during an inter|
00000580  72 75 70 74 20 62 65 63  61 75 73 65 20 56 44 55  |rupt because VDU|
00000590  0d 73 74 61 74 65 6d 65  6e 74 73 20 75 73 65 20  |.statements use |
000005a0  4f 53 57 52 43 48 2e 0d  0d 57 68 61 74 20 49 20  |OSWRCH...What I |
000005b0  69 6e 74 65 6e 64 20 74  6f 20 64 6f 20 69 6e 20  |intend to do in |
000005c0  74 68 69 73 20 6d 6f 64  75 6c 65 20 69 73 20 74  |this module is t|
000005d0  6f 20 75 73 65 20 4f 53  57 4f 52 44 20 31 32 20  |o use OSWORD 12 |
000005e0  74 6f 0d 73 77 69 74 63  68 20 74 68 65 20 70 61  |to.switch the pa|
000005f0  6c 65 74 74 65 20 66 6f  72 20 63 6f 6c 6f 75 72  |lette for colour|
00000600  20 31 20 69 6e 20 6d 6f  64 65 20 33 20 73 6f 20  | 1 in mode 3 so |
00000610  66 61 73 74 20 74 68 61  74 20 77 65 0d 63 61 6e  |fast that we.can|
00000620  20 68 61 76 65 20 61 72  65 61 73 20 6f 66 20 74  | have areas of t|
00000630  68 65 20 73 63 72 65 65  6e 20 77 69 74 68 20 64  |he screen with d|
00000640  69 66 66 65 72 65 6e 74  20 63 6f 6c 6f 75 72 73  |ifferent colours|
00000650  20 69 6e 20 61 6e 0d 6f  74 68 65 72 77 69 73 65  | in an.otherwise|
00000660  20 6d 6f 6e 6f 63 68 72  6f 6d 61 74 69 63 20 6d  | monochromatic m|
00000670  6f 64 65 2e 0d 0d 57 65  20 63 61 6e 20 64 65 74  |ode...We can det|
00000680  65 63 74 20 74 68 65 20  66 69 65 6c 64 20 73 79  |ect the field sy|
00000690  6e 63 20 70 75 6c 73 65  20 75 73 69 6e 67 20 61  |nc pulse using a|
000006a0  6e 20 65 76 65 6e 74 20  61 6e 64 0d 74 68 61 74  |n event and.that|
000006b0  20 77 69 6c 6c 20 62 65  20 75 73 65 64 20 74 6f  | will be used to|
000006c0  20 6c 6f 61 64 20 61 20  74 69 6d 65 72 20 74 68  | load a timer th|
000006d0  61 74 20 77 61 69 74 73  20 75 6e 74 69 6c 20 74  |at waits until t|
000006e0  68 65 20 62 65 61 6d 20  0d 69 73 20 61 74 20 74  |he beam .is at t|
000006f0  68 65 20 74 6f 70 20 6f  66 20 66 72 61 6d 65 20  |he top of frame |
00000700  62 65 66 6f 72 65 20 67  65 6e 65 72 61 74 69 6e  |before generatin|
00000710  67 20 61 6e 20 69 6e 74  65 72 72 75 70 74 2e 20  |g an interrupt. |
00000720  20 54 68 61 74 0d 69 6e  74 65 72 72 75 70 74 20  | That.interrupt |
00000730  73 65 74 73 20 74 68 65  20 66 69 72 73 74 20 63  |sets the first c|
00000740  6f 6c 6f 75 72 20 63 68  61 6e 67 65 20 61 6e 64  |olour change and|
00000750  20 6c 6f 61 64 73 20 74  68 65 20 74 69 6d 65 72  | loads the timer|
00000760  0d 66 6f 72 20 74 68 65  20 77 69 64 74 68 20 6f  |.for the width o|
00000770  66 20 74 68 61 74 20 63  6f 6c 6f 75 72 20 62 61  |f that colour ba|
00000780  6e 64 20 28 69 6e 20 6d  69 63 72 6f 73 65 63 6f  |nd (in microseco|
00000790  6e 64 73 29 20 61 6e 64  20 73 6f 0d 74 68 65 20  |nds) and so.the |
000007a0  70 72 6f 63 65 73 73 20  72 65 70 65 61 74 73 20  |process repeats |
000007b0  64 6f 77 6e 20 74 68 65  20 73 63 72 65 65 6e 2e  |down the screen.|
000007c0  20 20 54 68 69 73 20 77  68 6f 6c 65 20 70 72 6f  |  This whole pro|
000007d0  63 65 73 73 20 69 73 0d  72 65 70 65 61 74 65 64  |cess is.repeated|
000007e0  20 35 30 20 74 69 6d 65  73 20 65 76 65 72 79 20  | 50 times every |
000007f0  73 65 63 6f 6e 64 20 61  73 20 61 20 62 61 63 6b  |second as a back|
00000800  67 72 6f 75 6e 64 20 74  61 73 6b 2e 0d 0d 4f 6b  |ground task...Ok|
00000810  61 79 2c 20 73 6f 20 66  69 72 73 74 20 61 6e 20  |ay, so first an |
00000820  65 78 70 6c 61 6e 61 74  69 6f 6e 20 6f 66 20 66  |explanation of f|
00000830  69 65 6c 64 20 73 79 6e  63 2e 20 20 41 6e 79 20  |ield sync.  Any |
00000840  74 65 6c 65 76 69 73 69  6f 6e 0d 73 69 67 6e 61  |television.signa|
00000850  6c 20 68 61 73 20 74 6f  20 63 6f 6e 74 61 69 6e  |l has to contain|
00000860  20 73 79 6e 63 68 72 6f  6e 69 73 61 74 69 6f 6e  | synchronisation|
00000870  20 70 75 6c 73 65 73 20  61 6c 6f 6e 67 20 77 69  | pulses along wi|
00000880  74 68 20 74 68 65 0d 70  69 63 74 75 72 65 20 69  |th the.picture i|
00000890  6e 66 6f 72 6d 61 74 69  6f 6e 2e 20 20 54 68 61  |nformation.  Tha|
000008a0  74 20 61 6c 6c 6f 77 73  20 74 68 65 20 64 69 73  |t allows the dis|
000008b0  70 6c 61 79 20 69 6e 20  74 68 65 0d 72 65 63 65  |play in the.rece|
000008c0  69 76 65 72 20 74 6f 20  62 65 20 69 6e 20 73 74  |iver to be in st|
000008d0  65 70 20 77 69 74 68 20  74 68 65 20 73 63 61 6e  |ep with the scan|
000008e0  6e 69 6e 67 20 69 6e 20  74 68 65 20 63 61 6d 65  |ning in the came|
000008f0  72 61 2c 20 6f 72 0d 69  6e 20 6f 75 72 20 63 61  |ra, or.in our ca|
00000900  73 65 2c 20 74 68 65 20  63 6f 6d 70 75 74 65 72  |se, the computer|
00000910  2e 20 20 49 6e 20 36 32  35 20 6c 69 6e 65 20 35  |.  In 625 line 5|
00000920  30 20 68 65 72 74 7a 20  54 56 20 73 79 73 74 65  |0 hertz TV syste|
00000930  6d 73 0d 28 6c 69 6b 65  20 50 41 4c 2c 20 53 45  |ms.(like PAL, SE|
00000940  43 41 4d 20 61 6e 64 20  74 68 65 69 72 20 52 47  |CAM and their RG|
00000950  42 20 76 65 72 73 69 6f  6e 73 29 20 74 68 65 72  |B versions) ther|
00000960  65 20 69 73 20 61 20 70  75 6c 73 65 0d 65 76 65  |e is a pulse.eve|
00000970  72 79 20 36 34 20 6d 69  63 72 6f 73 65 63 6f 6e  |ry 64 microsecon|
00000980  64 73 20 77 68 69 63 68  20 6d 61 72 6b 73 20 74  |ds which marks t|
00000990  68 65 20 73 70 61 63 65  20 62 65 74 77 65 65 6e  |he space between|
000009a0  20 6c 69 6e 65 73 2c 0d  61 6e 64 20 69 73 20 63  | lines,.and is c|
000009b0  61 6c 6c 65 64 20 74 68  65 20 6c 69 6e 65 20 73  |alled the line s|
000009c0  79 6e 63 20 70 75 6c 73  65 2e 0d 0d 45 76 65 72  |ync pulse...Ever|
000009d0  79 20 32 30 20 6d 69 6c  6c 69 73 65 63 6f 6e 64  |y 20 millisecond|
000009e0  73 20 74 68 65 72 65 20  69 73 20 61 20 73 65 63  |s there is a sec|
000009f0  6f 6e 64 20 70 75 6c 73  65 20 63 61 6c 6c 65 64  |ond pulse called|
00000a00  20 74 68 65 0d 66 69 65  6c 64 20 73 79 6e 63 20  | the.field sync |
00000a10  70 75 6c 73 65 20 28 61  67 61 69 6e 20 74 68 65  |pulse (again the|
00000a20  73 65 20 66 69 67 75 72  65 73 20 6f 6e 6c 79 20  |se figures only |
00000a30  61 70 70 6c 79 20 74 6f  20 50 41 4c 20 61 6e 64  |apply to PAL and|
00000a40  0d 53 45 43 41 4d 20 54  56 20 73 69 67 6e 61 6c  |.SECAM TV signal|
00000a50  73 20 62 79 20 74 68 65  20 77 61 79 2c 20 6e 6f  |s by the way, no|
00000a60  74 20 74 68 65 20 41 6d  65 72 69 63 61 6e 2f 4a  |t the American/J|
00000a70  61 70 61 6e 65 73 65 0d  73 74 61 6e 64 61 72 64  |apanese.standard|
00000a80  20 63 61 6c 6c 65 64 20  4e 54 53 43 29 20 20 54  | called NTSC)  T|
00000a90  68 69 73 20 73 79 6e 63  68 72 6f 6e 69 73 65 73  |his synchronises|
00000aa0  20 74 68 65 20 66 69 65  6c 64 73 20 6f 66 20 74  | the fields of t|
00000ab0  68 65 0d 73 6f 75 72 63  65 20 61 6e 64 20 6d 6f  |he.source and mo|
00000ac0  6e 69 74 6f 72 20 74 6f  67 65 74 68 65 72 2e 20  |nitor together. |
00000ad0  20 41 20 66 69 65 6c 64  20 69 73 20 74 68 65 20  | A field is the |
00000ae0  64 69 73 70 6c 61 79 20  6f 66 0d 33 31 32 2e 35  |display of.312.5|
00000af0  20 6c 69 6e 65 73 20 28  69 6e 20 61 20 36 32 35  | lines (in a 625|
00000b00  20 6c 69 6e 65 20 73 69  67 6e 61 6c 29 20 61 6e  | line signal) an|
00000b10  64 20 74 77 6f 20 66 69  65 6c 64 73 2c 20 73 6c  |d two fields, sl|
00000b20  69 67 68 74 6c 79 0d 64  69 73 70 6c 61 63 65 64  |ightly.displaced|
00000b30  20 76 65 72 74 69 63 61  6c 6c 79 2c 20 6d 61 6b  | vertically, mak|
00000b40  65 20 75 70 20 61 20 66  72 61 6d 65 2e 20 20 53  |e up a frame.  S|
00000b50  6f 20 74 68 65 72 65 20  61 72 65 20 35 30 0d 66  |o there are 50.f|
00000b60  69 65 6c 64 73 20 70 65  72 20 73 65 63 6f 6e 64  |ields per second|
00000b70  2c 20 32 35 20 66 72 61  6d 65 73 20 70 65 72 20  |, 25 frames per |
00000b80  73 65 63 6f 6e 64 2e 20  20 54 68 65 20 72 65 61  |second.  The rea|
00000b90  73 6f 6e 73 20 66 6f 72  0d 74 68 69 73 20 66 69  |sons for.this fi|
00000ba0  65 6c 64 2f 66 72 61 6d  65 20 62 75 73 69 6e 65  |eld/frame busine|
00000bb0  73 73 20 61 72 65 20 72  65 6c 61 74 65 64 20 74  |ss are related t|
00000bc0  6f 20 68 6f 77 20 6c 69  74 74 6c 65 20 66 6c 69  |o how little fli|
00000bd0  63 6b 65 72 0d 79 6f 75  20 63 61 6e 20 73 65 65  |cker.you can see|
00000be0  20 69 6e 20 61 20 70 69  63 74 75 72 65 20 77 69  | in a picture wi|
00000bf0  74 68 6f 75 74 20 72 65  66 72 65 73 68 69 6e 67  |thout refreshing|
00000c00  20 28 72 65 2d 73 63 61  6e 6e 69 6e 67 29 0d 74  | (re-scanning).t|
00000c10  68 65 20 70 69 63 74 75  72 65 20 73 6f 20 6f 66  |he picture so of|
00000c20  74 65 6e 20 74 68 61 74  20 79 6f 75 72 20 73 69  |ten that your si|
00000c30  67 6e 61 6c 20 62 61 6e  64 77 69 64 74 68 20 28  |gnal bandwidth (|
00000c40  74 68 65 20 61 6d 6f 75  6e 74 0d 6f 66 20 69 6e  |the amount.of in|
00000c50  66 6f 72 6d 61 74 69 6f  6e 20 63 61 72 72 69 65  |formation carrie|
00000c60  64 20 70 65 72 20 75 6e  69 74 20 6f 66 20 74 69  |d per unit of ti|
00000c70  6d 65 29 20 62 65 63 6f  6d 65 73 20 74 6f 6f 20  |me) becomes too |
00000c80  62 69 67 2e 0d 0d 41 6c  6c 20 79 6f 75 20 6e 65  |big...All you ne|
00000c90  65 64 20 74 6f 20 6b 6e  6f 77 20 66 6f 72 20 63  |ed to know for c|
00000ca0  6f 6d 70 75 74 69 6e 67  20 69 73 20 74 68 61 74  |omputing is that|
00000cb0  20 61 20 42 42 43 20 4d  69 63 72 6f 0d 72 65 66  | a BBC Micro.ref|
00000cc0  72 65 73 68 65 73 20 74  68 65 20 73 63 72 65 65  |reshes the scree|
00000cd0  6e 20 32 35 20 74 69 6d  65 73 20 70 65 72 20 73  |n 25 times per s|
00000ce0  65 63 6f 6e 64 20 69 6e  20 74 77 6f 20 66 69 65  |econd in two fie|
00000cf0  6c 64 73 2c 20 65 61 63  68 0d 6f 66 20 61 20 35  |lds, each.of a 5|
00000d00  30 74 68 20 6f 66 20 61  20 73 65 63 6f 6e 64 20  |0th of a second |
00000d10  64 75 72 61 74 69 6f 6e  2e 20 20 54 68 65 20 66  |duration.  The f|
00000d20  69 65 6c 64 20 73 79 6e  63 20 70 75 6c 73 65 20  |ield sync pulse |
00000d30  73 74 61 72 74 73 0d 77  68 65 6e 20 74 68 65 20  |starts.when the |
00000d40  73 63 61 6e 6e 69 6e 67  20 6f 66 20 74 68 65 20  |scanning of the |
00000d50  65 6c 65 63 74 72 6f 6e  20 62 65 61 6d 20 68 61  |electron beam ha|
00000d60  73 20 72 65 61 63 68 65  64 20 74 68 65 0d 62 6f  |s reached the.bo|
00000d70  74 74 6f 6d 20 6f 66 20  6f 6e 65 20 66 69 65 6c  |ttom of one fiel|
00000d80  64 20 61 6e 64 20 73 74  61 72 74 73 20 74 6f 20  |d and starts to |
00000d90  27 66 6c 79 20 62 61 63  6b 27 20 74 6f 20 74 68  |'fly back' to th|
00000da0  65 20 74 6f 70 20 6f 66  0d 74 68 65 20 73 63 72  |e top of.the scr|
00000db0  65 65 6e 20 72 65 61 64  79 20 66 6f 72 20 74 68  |een ready for th|
00000dc0  65 20 6e 65 78 74 20 66  69 65 6c 64 20 74 6f 20  |e next field to |
00000dd0  62 65 67 69 6e 2e 20 20  54 68 69 73 20 66 6c 79  |begin.  This fly|
00000de0  62 61 63 6b 0d 69 73 20  61 6c 73 6f 20 6b 6e 6f  |back.is also kno|
00000df0  77 6e 20 61 73 20 74 68  65 20 76 65 72 74 69 63  |wn as the vertic|
00000e00  61 6c 20 62 6c 61 6e 6b  69 6e 67 20 69 6e 74 65  |al blanking inte|
00000e10  72 76 61 6c 20 28 56 42  49 29 20 6f 72 0d 6a 75  |rval (VBI) or.ju|
00000e20  73 74 20 74 68 65 20 76  65 72 74 69 63 61 6c 20  |st the vertical |
00000e30  69 6e 74 65 72 76 61 6c  2e 20 20 28 54 68 65 20  |interval.  (The |
00000e40  74 65 72 6d 20 27 62 6c  61 6e 6b 69 6e 67 27 20  |term 'blanking' |
00000e50  69 73 20 75 73 65 64 0d  62 65 63 61 75 73 65 20  |is used.because |
00000e60  74 68 65 20 62 65 61 6d  20 69 73 20 74 75 72 6e  |the beam is turn|
00000e70  65 64 20 6f 66 66 20 64  75 72 69 6e 67 20 74 68  |ed off during th|
00000e80  69 73 20 66 6c 79 62 61  63 6b 20 74 6f 20 73 74  |is flyback to st|
00000e90  6f 70 0d 79 6f 75 20 73  65 65 69 6e 67 20 73 6c  |op.you seeing sl|
00000ea0  61 6e 74 65 64 20 6c 69  6e 65 73 20 61 63 72 6f  |anted lines acro|
00000eb0  73 73 20 74 68 65 20 73  63 72 65 65 6e 2e 20 20  |ss the screen.  |
00000ec0  49 66 20 79 6f 75 20 64  6f 20 73 65 65 0d 74 68  |If you do see.th|
00000ed0  65 6d 20 74 68 65 6e 20  79 6f 75 72 20 6d 6f 6e  |em then your mon|
00000ee0  69 74 6f 72 20 69 73 20  6e 6f 74 20 73 65 74 20  |itor is not set |
00000ef0  75 70 20 63 6f 72 72 65  63 74 6c 79 21 29 0d 0d  |up correctly!)..|
00000f00  59 6f 75 20 61 72 65 20  70 72 6f 62 61 62 6c 79  |You are probably|
00000f10  20 66 61 6d 69 6c 69 61  72 20 77 69 74 68 20 2a  | familiar with *|
00000f20  46 58 20 31 39 2e 20 20  54 68 69 73 20 63 61 6c  |FX 19.  This cal|
00000f30  6c 20 28 4f 53 42 59 54  45 0d 31 39 29 20 66 6f  |l (OSBYTE.19) fo|
00000f40  72 63 65 73 20 70 72 6f  67 72 61 6d 20 65 78 65  |rces program exe|
00000f50  63 75 74 69 6f 6e 20 74  6f 20 77 61 69 74 20 66  |cution to wait f|
00000f60  6f 72 20 74 68 65 20 73  74 61 72 74 20 6f 66 20  |or the start of |
00000f70  74 68 65 0d 6e 65 78 74  20 76 65 72 74 69 63 61  |the.next vertica|
00000f80  6c 20 69 6e 74 65 72 76  61 6c 2e 20 20 45 76 65  |l interval.  Eve|
00000f90  6e 74 20 6e 75 6d 62 65  72 20 34 20 6f 63 63 75  |nt number 4 occu|
00000fa0  72 73 20 61 74 20 74 68  69 73 20 70 6f 69 6e 74  |rs at this point|
00000fb0  0d 61 6e 64 20 77 65 20  63 61 6e 20 75 73 65 20  |.and we can use |
00000fc0  65 76 65 6e 74 20 34 20  74 6f 20 73 79 6e 63 68  |event 4 to synch|
00000fd0  72 6f 6e 69 73 65 20 74  68 65 20 70 61 6c 65 74  |ronise the palet|
00000fe0  74 65 20 73 77 69 74 63  68 69 6e 67 0d 74 68 61  |te switching.tha|
00000ff0  74 20 77 65 20 61 72 65  20 67 6f 69 6e 67 20 74  |t we are going t|
00001000  6f 20 64 6f 20 68 65 72  65 2e 0d 0d 53 69 6e 63  |o do here...Sinc|
00001010  65 20 74 68 69 73 20 65  76 65 6e 74 20 6f 63 63  |e this event occ|
00001020  75 72 73 20 61 74 20 74  68 65 20 73 74 61 72 74  |urs at the start|
00001030  20 6f 66 20 74 68 65 20  56 42 49 20 77 65 20 68  | of the VBI we h|
00001040  61 76 65 20 74 6f 0d 61  64 64 20 61 20 64 65 6c  |ave to.add a del|
00001050  61 79 20 73 6f 20 74 68  61 74 20 74 68 65 20 62  |ay so that the b|
00001060  65 61 6d 20 63 61 6e 20  72 65 61 63 68 20 74 68  |eam can reach th|
00001070  65 20 74 6f 70 20 6f 66  20 74 68 65 20 6e 65 78  |e top of the nex|
00001080  74 0d 66 72 61 6d 65 20  62 65 66 6f 72 65 20 74  |t.frame before t|
00001090  68 65 20 72 6f 75 74 69  6e 65 20 70 72 6f 70 65  |he routine prope|
000010a0  72 20 63 61 6e 20 73 74  61 72 74 2e 0d 0d 53 6f  |r can start...So|
000010b0  20 77 68 61 74 20 64 6f  20 77 65 20 75 73 65 20  | what do we use |
000010c0  74 6f 20 64 6f 20 61 6c  6c 20 74 68 69 73 20 74  |to do all this t|
000010d0  69 6d 69 6e 67 3f 20 20  54 68 65 20 56 49 41 20  |iming?  The VIA |
000010e0  69 6e 63 6c 75 64 65 73  20 61 0d 63 6f 75 70 6c  |includes a.coupl|
000010f0  65 20 6f 66 20 74 69 6d  65 72 73 2c 20 6b 6e 6f  |e of timers, kno|
00001100  77 6e 20 61 73 20 54 31  20 61 6e 64 20 54 32 2e  |wn as T1 and T2.|
00001110  20 20 45 73 73 65 6e 74  69 61 6c 6c 79 20 74 68  |  Essentially th|
00001120  65 0d 64 69 66 66 65 72  65 6e 63 65 20 62 65 74  |e.difference bet|
00001130  77 65 65 6e 20 74 68 65  20 74 77 6f 20 74 69 6d  |ween the two tim|
00001140  65 72 73 20 69 73 20 74  68 61 74 20 54 31 20 63  |ers is that T1 c|
00001150  61 6e 20 62 65 20 75 73  65 64 20 74 6f 0d 67 65  |an be used to.ge|
00001160  6e 65 72 61 74 65 20 70  75 6c 73 65 73 20 6f 72  |nerate pulses or|
00001170  20 61 20 73 71 75 61 72  65 20 77 61 76 65 20 66  | a square wave f|
00001180  72 6f 6d 20 61 20 70 69  6e 20 6f 66 20 74 68 65  |rom a pin of the|
00001190  20 56 49 41 20 28 61 6e  64 0d 68 65 6e 63 65 20  | VIA (and.hence |
000011a0  6f 66 20 74 68 65 20 75  73 65 72 20 70 6f 72 74  |of the user port|
000011b0  29 20 77 68 69 6c 65 20  54 32 20 63 61 6e 20 63  |) while T2 can c|
000011c0  6f 75 6e 74 20 64 6f 77  6e 20 75 6e 64 65 72 20  |ount down under |
000011d0  74 68 65 0d 69 6e 66 6c  75 65 6e 63 65 20 6f 66  |the.influence of|
000011e0  20 70 75 6c 73 65 73 20  62 65 69 6e 67 20 66 65  | pulses being fe|
000011f0  64 20 74 6f 20 61 20 70  69 6e 20 6f 66 20 74 68  |d to a pin of th|
00001200  65 20 56 49 41 20 28 61  6e 64 20 75 73 65 72 0d  |e VIA (and user.|
00001210  70 6f 72 74 29 2e 20 20  42 6f 74 68 20 74 69 6d  |port).  Both tim|
00001220  65 72 73 20 63 61 6e 20  62 65 20 75 73 65 64 20  |ers can be used |
00001230  74 6f 20 67 65 6e 65 72  61 74 65 20 61 6e 20 69  |to generate an i|
00001240  6e 74 65 72 72 75 70 74  0d 61 66 74 65 72 20 61  |nterrupt.after a|
00001250  20 73 70 65 63 69 66 69  65 64 20 64 65 6c 61 79  | specified delay|
00001260  2e 20 20 54 68 65 73 65  20 74 69 6d 69 6e 67 73  |.  These timings|
00001270  20 61 72 65 20 64 6f 6e  65 20 61 73 20 63 6f 75  | are done as cou|
00001280  6e 74 73 0d 61 74 20 31  20 4d 48 7a 2c 20 69 2e  |nts.at 1 MHz, i.|
00001290  65 2e 20 69 6e 20 6d 69  63 72 6f 73 65 63 6f 6e  |e. in microsecon|
000012a0  64 73 2e 20 20 54 68 61  74 20 6d 61 6b 65 73 20  |ds.  That makes |
000012b0  74 68 65 73 65 20 74 69  6d 65 72 73 0d 6d 75 63  |these timers.muc|
000012c0  68 20 6d 6f 72 65 20 61  63 63 75 72 61 74 65 20  |h more accurate |
000012d0  74 68 61 74 20 74 68 65  20 42 41 53 49 43 20 54  |that the BASIC T|
000012e0  49 4d 45 20 66 75 6e 63  74 69 6f 6e 2c 20 77 68  |IME function, wh|
000012f0  69 63 68 20 69 6e 0d 61  6e 79 20 63 61 73 65 20  |ich in.any case |
00001300  73 74 6f 70 73 20 64 75  72 69 6e 67 20 69 6e 74  |stops during int|
00001310  65 72 72 75 70 74 73 2e  0d 0d 49 27 6c 6c 20 62  |errupts...I'll b|
00001320  72 69 65 66 6c 79 20 64  65 73 63 72 69 62 65 20  |riefly describe |
00001330  74 68 65 20 6d 6f 64 65  73 20 6f 66 20 54 31 20  |the modes of T1 |
00001340  61 6e 64 20 54 32 2e 0d  0d 54 31 20 2d 20 4f 6e  |and T2...T1 - On|
00001350  65 20 73 68 6f 74 20 6d  6f 64 65 0d 0d 41 20 64  |e shot mode..A d|
00001360  75 72 61 74 69 6f 6e 20  69 73 20 6c 6f 61 64 65  |uration is loade|
00001370  64 20 69 6e 74 6f 20 74  68 65 20 72 65 67 69 73  |d into the regis|
00001380  74 65 72 73 2c 20 6c 6f  77 20 62 79 74 65 20 66  |ters, low byte f|
00001390  69 72 73 74 20 74 68 65  6e 0d 68 69 67 68 20 62  |irst then.high b|
000013a0  79 74 65 2e 20 20 57 68  65 6e 20 74 68 65 20 68  |yte.  When the h|
000013b0  69 67 68 20 6f 72 64 65  72 20 62 79 74 65 20 69  |igh order byte i|
000013c0  73 20 6c 6f 61 64 65 64  20 74 68 65 20 63 6f 75  |s loaded the cou|
000013d0  6e 74 65 72 0d 73 74 61  72 74 73 20 74 6f 20 63  |nter.starts to c|
000013e0  6f 75 6e 74 20 64 6f 77  6e 2e 20 20 4f 6e 20 72  |ount down.  On r|
000013f0  65 61 63 68 69 6e 67 20  7a 65 72 6f 20 61 6e 20  |eaching zero an |
00001400  69 6e 74 65 72 72 75 70  74 20 69 73 0d 67 65 6e  |interrupt is.gen|
00001410  65 72 61 74 65 64 2e 20  20 4c 6f 61 64 69 6e 67  |erated.  Loading|
00001420  20 74 68 65 20 68 69 67  68 20 62 79 74 65 20 61  | the high byte a|
00001430  6c 73 6f 20 72 65 73 65  74 73 20 74 68 65 20 69  |lso resets the i|
00001440  6e 74 65 72 72 75 70 74  0d 66 6c 61 67 2e 0d 0d  |nterrupt.flag...|
00001450  54 31 20 2d 20 46 72 65  65 20 72 75 6e 6e 69 6e  |T1 - Free runnin|
00001460  67 0d 0d 49 6e 20 74 68  69 73 20 63 61 73 65 20  |g..In this case |
00001470  77 68 65 6e 65 76 65 72  20 74 68 65 20 74 69 6d  |whenever the tim|
00001480  65 72 20 68 69 74 73 20  7a 65 72 6f 20 61 6e 64  |er hits zero and|
00001490  20 67 65 6e 65 72 61 74  65 73 20 74 68 65 0d 69  | generates the.i|
000014a0  6e 74 65 72 72 75 70 74  20 74 68 65 20 74 69 6d  |nterrupt the tim|
000014b0  65 72 20 72 65 6c 6f 61  64 73 20 69 74 73 65 6c  |er reloads itsel|
000014c0  66 20 77 69 74 68 20 74  68 65 20 76 61 6c 75 65  |f with the value|
000014d0  20 68 65 6c 64 20 69 6e  0d 77 68 61 74 20 61 72  | held in.what ar|
000014e0  65 20 63 61 6c 6c 65 64  20 69 74 73 20 6c 61 74  |e called its lat|
000014f0  63 68 65 73 2e 20 20 49  74 20 77 61 73 20 69 6e  |ches.  It was in|
00001500  20 66 61 63 74 20 6f 6e  65 20 6f 66 20 74 68 65  | fact one of the|
00001510  73 65 0d 6c 61 74 63 68  65 73 20 74 68 61 74 20  |se.latches that |
00001520  77 61 73 20 77 72 69 74  74 65 6e 20 74 6f 20 77  |was written to w|
00001530  68 65 6e 20 79 6f 75 20  74 68 6f 75 67 68 74 20  |hen you thought |
00001540  79 6f 75 20 77 65 72 65  0d 77 72 69 74 69 6e 67  |you were.writing|
00001550  20 74 6f 20 74 68 65 20  6c 6f 77 20 62 79 74 65  | to the low byte|
00001560  20 63 6f 75 6e 74 65 72  2e 20 20 28 59 6f 75 20  | counter.  (You |
00001570  74 68 69 6e 6b 20 79 6f  75 27 72 65 0d 63 6f 6e  |think you're.con|
00001580  66 75 73 65 64 3f 29 20  59 6f 75 20 63 61 6e 20  |fused?) You can |
00001590  67 65 6e 65 72 61 74 65  20 61 20 72 65 63 74 61  |generate a recta|
000015a0  6e 67 75 6c 61 72 20 77  61 76 65 20 66 6f 72 6d  |ngular wave form|
000015b0  20 66 72 6f 6d 20 50 42  37 0d 6f 66 20 74 68 65  | from PB7.of the|
000015c0  20 56 49 41 20 28 77 68  69 63 68 20 61 70 70 65  | VIA (which appe|
000015d0  61 72 73 20 61 73 20 61  20 70 69 6e 20 6f 6e 20  |ars as a pin on |
000015e0  74 68 65 20 75 73 65 72  20 70 6f 72 74 29 20 69  |the user port) i|
000015f0  66 20 79 6f 75 0d 77 61  6e 74 20 74 6f 2e 20 20  |f you.want to.  |
00001600  49 66 20 79 6f 75 20 77  72 69 74 65 20 74 6f 20  |If you write to |
00001610  74 68 65 20 6c 61 74 63  68 65 73 20 77 68 69 6c  |the latches whil|
00001620  65 20 74 68 65 20 63 6f  75 6e 74 65 72 20 69 73  |e the counter is|
00001630  0d 63 6f 75 6e 74 69 6e  67 20 64 6f 77 6e 20 79  |.counting down y|
00001640  6f 75 72 20 76 61 6c 75  65 20 77 69 6c 6c 20 62  |our value will b|
00001650  65 20 74 72 61 6e 73 66  65 72 72 65 64 20 61 63  |e transferred ac|
00001660  72 6f 73 73 20 61 74 20  74 68 65 0d 6e 65 78 74  |ross at the.next|
00001670  20 69 6e 74 65 72 72 75  70 74 2e 20 20 54 68 69  | interrupt.  Thi|
00001680  73 20 61 6c 6c 6f 77 73  20 79 6f 75 20 74 6f 20  |s allows you to |
00001690  70 72 65 2d 73 65 74 20  74 68 65 20 64 75 72 61  |pre-set the dura|
000016a0  74 69 6f 6e 20 6f 66 0d  74 68 65 20 6e 65 78 74  |tion of.the next|
000016b0  20 70 75 6c 73 65 20 61  6e 64 20 69 74 20 69 73  | pulse and it is|
000016c0  20 70 6f 73 73 69 62 6c  65 20 74 6f 20 65 6d 75  | possible to emu|
000016d0  6c 61 74 65 20 69 6e 66  72 61 2d 72 65 64 0d 63  |late infra-red.c|
000016e0  6f 6e 74 72 6f 6c 20 73  69 67 6e 61 6c 73 20 69  |ontrol signals i|
000016f0  6e 20 74 68 69 73 20 77  61 79 20 74 6f 20 63 6f  |n this way to co|
00001700  6e 74 72 6f 6c 20 79 6f  75 72 20 76 69 64 65 6f  |ntrol your video|
00001710  2e 0d 0d 54 32 20 2d 20  4f 6e 65 20 73 68 6f 74  |...T2 - One shot|
00001720  0d 0d 50 72 65 74 74 79  20 77 65 6c 6c 20 74 68  |..Pretty well th|
00001730  65 20 73 61 6d 65 20 61  73 20 66 6f 72 20 54 31  |e same as for T1|
00001740  0d 0d 54 32 20 2d 20 20  50 75 6c 73 65 20 63 6f  |..T2 -  Pulse co|
00001750  75 6e 74 69 6e 67 0d 0d  54 32 20 63 61 6e 20 63  |unting..T2 can c|
00001760  6f 75 6e 74 20 61 20 70  72 65 73 65 74 20 6e 75  |ount a preset nu|
00001770  6d 62 65 72 20 6f 66 20  70 75 6c 73 65 73 20 61  |mber of pulses a|
00001780  6e 64 20 74 68 65 6e 20  67 65 6e 65 72 61 74 65  |nd then generate|
00001790  20 61 6e 0d 69 6e 74 65  72 72 75 70 74 2e 0d 0d  | an.interrupt...|
000017a0  41 20 64 61 74 61 20 73  68 65 65 74 20 66 6f 72  |A data sheet for|
000017b0  20 74 68 65 20 36 35 32  32 20 56 49 41 20 77 69  | the 6522 VIA wi|
000017c0  6c 6c 20 65 78 70 6c 61  69 6e 20 74 68 69 73 20  |ll explain this |
000017d0  61 6c 6c 20 6d 6f 72 65  0d 66 75 6c 6c 79 2c 20  |all more.fully, |
000017e0  6f 72 20 61 6e 20 41 64  76 61 6e 63 65 64 20 55  |or an Advanced U|
000017f0  73 65 72 20 47 75 69 64  65 2e 20 20 49 20 73 68  |ser Guide.  I sh|
00001800  61 6c 6c 20 6f 6e 6c 79  20 65 78 70 6c 61 69 6e  |all only explain|
00001810  20 69 6e 0d 64 65 74 61  69 6c 20 74 68 65 20 6f  | in.detail the o|
00001820  70 65 72 61 74 69 6f 6e  20 77 65 20 77 69 6c 6c  |peration we will|
00001830  20 75 73 65 20 69 6e 20  74 68 69 73 20 6d 6f 64  | use in this mod|
00001840  75 6c 65 2e 0d 0d 55 73  69 6e 67 20 61 20 56 49  |ule...Using a VI|
00001850  41 20 74 69 6d 65 72 20  61 73 20 61 6e 20 69 6e  |A timer as an in|
00001860  74 65 72 76 61 6c 20 74  69 6d 65 72 20 69 6e 76  |terval timer inv|
00001870  6f 6c 76 65 73 20 74 77  6f 0d 6f 70 65 72 61 74  |olves two.operat|
00001880  69 6f 6e 73 2e 20 20 46  69 72 73 74 20 77 65 20  |ions.  First we |
00001890  6d 75 73 74 20 73 65 74  20 75 70 20 74 68 65 20  |must set up the |
000018a0  74 69 6d 65 72 20 61 6e  64 20 6c 6f 61 64 20 69  |timer and load i|
000018b0  74 20 77 69 74 68 0d 74  68 65 20 69 6e 74 65 72  |t with.the inter|
000018c0  76 61 6c 20 28 69 6e 20  6d 69 63 72 6f 73 65 63  |val (in microsec|
000018d0  6f 6e 64 73 29 20 74 68  61 74 20 77 65 20 77 69  |onds) that we wi|
000018e0  73 68 20 74 6f 20 63 6f  75 6e 74 20 6f 66 66 2e  |sh to count off.|
000018f0  20 0d 54 68 65 6e 20 77  65 20 6d 75 73 74 20 6d  | .Then we must m|
00001900  6f 6e 69 74 6f 72 20 74  68 65 20 69 6e 74 65 72  |onitor the inter|
00001910  72 75 70 74 73 20 75 6e  74 69 6c 20 77 65 20 64  |rupts until we d|
00001920  65 74 65 63 74 20 6f 6e  65 0d 67 65 6e 65 72 61  |etect one.genera|
00001930  74 65 64 20 62 79 20 6f  75 72 20 74 69 6d 65 72  |ted by our timer|
00001940  2e 0d 0d 4c 6f 61 64 69  6e 67 20 74 68 65 20 74  |...Loading the t|
00001950  69 6d 65 72 20 69 73 20  64 6f 6e 65 20 62 79 20  |imer is done by |
00001960  77 72 69 74 69 6e 67 20  74 6f 20 61 64 64 72 65  |writing to addre|
00001970  73 73 65 73 20 77 69 74  68 69 6e 20 74 68 65 0d  |sses within the.|
00001980  61 72 65 61 20 6f 66 20  6d 65 6d 6f 72 79 20 6b  |area of memory k|
00001990  6e 6f 77 6e 20 61 73 20  53 68 65 69 6c 61 2e 20  |nown as Sheila. |
000019a0  20 53 68 65 69 6c 61 20  69 73 20 61 20 70 61 67  | Sheila is a pag|
000019b0  65 20 6f 66 20 6d 65 6d  6f 72 79 0d 72 75 6e 6e  |e of memory.runn|
000019c0  69 6e 67 20 66 72 6f 6d  20 26 46 45 30 30 20 74  |ing from &FE00 t|
000019d0  6f 20 26 46 45 46 46 20  61 6e 64 20 69 6e 20 69  |o &FEFF and in i|
000019e0  74 20 6c 69 76 65 20 73  75 63 68 20 70 69 65 63  |t live such piec|
000019f0  65 73 20 6f 66 0d 68 61  72 64 77 61 72 65 20 61  |es of.hardware a|
00001a00  73 20 74 68 65 20 43 52  54 43 20 76 69 64 65 6f  |s the CRTC video|
00001a10  20 63 6f 6e 74 72 6f 6c  6c 65 72 20 63 68 69 70  | controller chip|
00001a20  2c 20 74 68 65 20 54 75  62 65 2c 20 73 65 72 69  |, the Tube, seri|
00001a30  61 6c 0d 61 6e 64 20 76  69 64 65 6f 20 55 4c 41  |al.and video ULA|
00001a40  20 63 68 69 70 73 2c 20  74 68 65 20 41 74 6f 44  | chips, the AtoD|
00001a50  20 63 6f 6e 76 65 72 74  65 72 20 61 6e 64 20 6f  | converter and o|
00001a60  74 68 65 72 73 2e 20 20  54 68 65 72 65 0d 61 72  |thers.  There.ar|
00001a70  65 20 31 31 20 64 69 66  66 65 72 65 6e 74 20 64  |e 11 different d|
00001a80  65 76 69 63 65 73 20 6f  6e 20 53 68 65 69 6c 61  |evices on Sheila|
00001a90  2e 20 20 57 65 20 61 72  65 20 68 65 72 65 20 69  |.  We are here i|
00001aa0  6e 74 65 72 65 73 74 65  64 0d 69 6e 20 74 68 65  |nterested.in the|
00001ab0  20 55 73 65 72 20 56 49  41 20 77 68 69 63 68 20  | User VIA which |
00001ac0  6c 69 76 65 73 20 66 72  6f 6d 20 26 46 45 36 30  |lives from &FE60|
00001ad0  20 74 6f 20 26 46 45 36  46 2e 20 20 54 68 65 20  | to &FE6F.  The |
00001ae0  62 61 73 65 0d 61 64 64  72 65 73 73 20 66 6f 72  |base.address for|
00001af0  20 74 68 65 20 56 49 41  20 72 65 67 69 73 74 65  | the VIA registe|
00001b00  72 73 20 69 73 20 26 46  45 36 30 20 61 6e 64 20  |rs is &FE60 and |
00001b10  69 6e 20 74 68 65 20 70  72 6f 67 72 61 6d 20 69  |in the program i|
00001b20  6e 0d 74 68 69 73 20 6d  6f 64 75 6c 65 2c 20 42  |n.this module, B|
00001b30  2f 6f 73 62 31 39 2c 20  74 68 61 74 20 61 64 64  |/osb19, that add|
00001b40  72 65 73 73 20 69 73 20  67 69 76 65 6e 20 61 20  |ress is given a |
00001b50  76 61 72 69 61 62 6c 65  20 6e 61 6d 65 0d 27 76  |variable name.'v|
00001b60  69 61 27 2e 20 20 5b 49  6e 20 66 61 63 74 2c 20  |ia'.  [In fact, |
00001b70  33 32 20 62 79 74 65 73  20 61 72 65 20 61 6c 6c  |32 bytes are all|
00001b80  6f 63 61 74 65 64 20 66  6f 72 20 74 68 65 20 56  |ocated for the V|
00001b90  49 41 0d 61 6c 74 68 6f  75 67 68 20 69 74 20 6f  |IA.although it o|
00001ba0  6e 6c 79 20 75 73 65 73  20 31 36 20 6f 66 20 74  |nly uses 16 of t|
00001bb0  68 65 6d 20 73 6f 20 74  68 61 74 20 72 65 67 69  |hem so that regi|
00001bc0  73 74 65 72 20 58 20 6f  66 20 74 68 65 0d 56 49  |ster X of the.VI|
00001bd0  41 20 63 61 6e 20 62 65  20 66 6f 75 6e 64 20 61  |A can be found a|
00001be0  74 20 26 46 45 36 58 20  61 6e 64 20 26 46 45 37  |t &FE6X and &FE7|
00001bf0  58 20 69 64 65 6e 74 69  63 61 6c 6c 79 2e 20 20  |X identically.  |
00001c00  59 6f 75 20 63 61 6e 0d  70 72 6f 76 65 20 74 68  |You can.prove th|
00001c10  69 73 20 62 79 20 63 68  61 6e 67 69 6e 67 20 74  |is by changing t|
00001c20  68 65 20 76 61 6c 75 65  20 6f 66 20 27 76 69 61  |he value of 'via|
00001c30  27 20 69 6e 20 74 68 65  20 70 72 6f 67 72 61 6d  |' in the program|
00001c40  20 74 6f 0d 26 46 45 37  30 20 61 6e 64 20 79 6f  | to.&FE70 and yo|
00001c50  75 20 77 69 6c 6c 20 66  69 6e 64 20 6e 6f 20 64  |u will find no d|
00001c60  69 66 66 65 72 65 6e 63  65 20 69 6e 20 74 68 65  |ifference in the|
00001c70  20 72 65 73 75 6c 74 2e  5d 0d 0d 41 73 20 65 78  | result.]..As ex|
00001c80  70 6c 61 69 6e 65 64 20  69 6e 20 74 68 65 20 6c  |plained in the l|
00001c90  61 73 74 20 6d 6f 64 75  6c 65 20 73 70 65 65 64  |ast module speed|
00001ca0  20 69 73 20 69 6d 70 6f  72 74 61 6e 74 20 77 68  | is important wh|
00001cb0  69 6c 65 0d 75 73 69 6e  67 20 69 6e 74 65 72 72  |ile.using interr|
00001cc0  75 70 74 73 20 61 6e 64  20 73 6f 20 77 65 20 77  |upts and so we w|
00001cd0  69 6c 6c 20 72 65 61 64  20 61 6e 64 20 77 72 69  |ill read and wri|
00001ce0  74 65 20 64 69 72 65 63  74 20 72 61 74 68 65 72  |te direct rather|
00001cf0  0d 74 68 61 6e 20 75 73  65 20 74 68 65 20 4f 53  |.than use the OS|
00001d00  42 59 54 45 20 63 61 6c  6c 73 20 28 6e 75 6d 62  |BYTE calls (numb|
00001d10  65 72 73 20 31 35 30 20  61 6e 64 20 31 35 31 29  |ers 150 and 151)|
00001d20  20 74 68 61 74 20 61 72  65 0d 61 76 61 69 6c 61  | that are.availa|
00001d30  62 6c 65 2e 0d 0d 54 68  65 20 56 49 41 20 72 65  |ble...The VIA re|
00001d40  67 69 73 74 65 72 73 20  77 65 20 6e 65 65 64 20  |gisters we need |
00001d50  66 6f 72 20 74 68 69 73  20 6f 70 65 72 61 74 69  |for this operati|
00001d60  6f 6e 20 61 72 65 20 61  73 20 66 6f 6c 6c 6f 77  |on are as follow|
00001d70  73 3a 0d 0d 52 65 67 69  73 74 65 72 20 31 31 20  |s:..Register 11 |
00001d80  2d 20 54 68 65 20 61 75  78 69 6c 69 61 72 79 20  |- The auxiliary |
00001d90  63 6f 6e 74 72 6f 6c 20  72 65 67 69 73 74 65 72  |control register|
00001da0  0d 0d 57 69 74 68 20 74  68 69 73 20 72 65 67 69  |..With this regi|
00001db0  73 74 65 72 20 77 65 20  73 65 6c 65 63 74 20 74  |ster we select t|
00001dc0  68 65 20 6d 6f 64 65 20  6f 66 20 6f 70 65 72 61  |he mode of opera|
00001dd0  74 69 6f 6e 20 6f 66 20  74 68 65 0d 74 69 6d 65  |tion of the.time|
00001de0  72 73 20 61 6e 64 20 73  68 69 66 74 20 72 65 67  |rs and shift reg|
00001df0  69 73 74 65 72 2e 20 20  54 6f 20 70 75 74 20 54  |ister.  To put T|
00001e00  31 20 69 6e 74 6f 20 69  74 73 20 27 6f 6e 65 20  |1 into its 'one |
00001e10  73 68 6f 74 27 0d 6d 6f  64 65 20 77 65 20 68 61  |shot'.mode we ha|
00001e20  76 65 20 74 6f 20 6d 61  6b 65 20 73 75 72 65 20  |ve to make sure |
00001e30  74 68 61 74 20 74 68 65  20 74 6f 70 20 74 77 6f  |that the top two|
00001e40  20 62 69 74 73 20 6f 66  20 74 68 65 0d 72 65 67  | bits of the.reg|
00001e50  69 73 74 65 72 20 61 72  65 20 65 69 74 68 65 72  |ister are either|
00001e60  20 62 6f 74 68 20 63 6c  65 61 72 20 6f 72 20 6a  | both clear or j|
00001e70  75 73 74 20 62 69 74 20  37 20 69 73 20 73 65 74  |ust bit 7 is set|
00001e80  2e 20 20 49 6e 20 74 68  65 0d 6c 61 74 74 65 72  |.  In the.latter|
00001e90  20 63 61 73 65 20 74 68  65 20 76 6f 6c 74 61 67  | case the voltag|
00001ea0  65 20 6f 6e 20 70 69 6e  20 50 42 37 20 6f 66 20  |e on pin PB7 of |
00001eb0  74 68 65 20 56 49 41 20  77 69 6c 6c 20 67 6f 20  |the VIA will go |
00001ec0  6c 6f 77 0d 77 68 65 6e  20 74 68 65 20 74 69 6d  |low.when the tim|
00001ed0  65 72 20 69 73 20 73 74  61 72 74 65 64 20 61 6e  |er is started an|
00001ee0  64 20 67 6f 20 62 61 63  6b 20 68 69 67 68 20 77  |d go back high w|
00001ef0  68 65 6e 20 69 74 20 74  69 6d 65 73 0d 6f 75 74  |hen it times.out|
00001f00  2e 20 20 54 68 69 73 20  70 72 6f 64 75 63 65 73  |.  This produces|
00001f10  20 61 20 70 75 6c 73 65  20 6f 66 20 70 72 6f 67  | a pulse of prog|
00001f20  72 61 6d 6d 61 62 6c 65  20 77 69 64 74 68 2e 20  |rammable width. |
00001f30  20 49 74 0d 64 6f 65 73  6e 27 74 20 61 63 74 75  | It.doesn't actu|
00001f40  61 6c 6c 79 20 6d 61 74  74 65 72 20 77 68 65 74  |ally matter whet|
00001f50  68 65 72 20 77 65 20 73  65 74 20 6f 66 66 20 61  |her we set off a|
00001f60  20 70 75 6c 73 65 20 6f  6e 20 50 42 37 20 6f 72  | pulse on PB7 or|
00001f70  0d 6e 6f 74 20 69 6e 20  74 68 69 73 20 61 70 70  |.not in this app|
00001f80  6c 69 63 61 74 69 6f 6e  2c 20 62 75 74 20 69 74  |lication, but it|
00001f90  20 69 73 20 70 72 6f 62  61 62 6c 79 20 74 69 64  | is probably tid|
00001fa0  69 65 72 20 6e 6f 74 20  74 6f 2c 0d 73 6f 20 77  |ier not to,.so w|
00001fb0  65 20 6d 75 73 74 20 63  6c 65 61 72 20 62 69 74  |e must clear bit|
00001fc0  73 20 36 20 61 6e 64 20  37 2e 20 4c 69 6e 65 73  |s 6 and 7. Lines|
00001fd0  20 35 34 30 2d 35 36 30  20 69 6e 20 42 2f 6f 73  | 540-560 in B/os|
00001fe0  62 31 39 20 61 72 65 0d  77 68 65 72 65 20 74 68  |b19 are.where th|
00001ff0  69 73 20 69 73 20 64 6f  6e 65 2e 0d 0d 52 65 67  |is is done...Reg|
00002000  69 73 74 65 72 20 31 34  20 2d 20 54 68 65 20 69  |ister 14 - The i|
00002010  6e 74 65 72 72 75 70 74  20 65 6e 61 62 6c 65 20  |nterrupt enable |
00002020  72 65 67 69 73 74 65 72  0d 0d 54 6f 20 65 6e 61  |register..To ena|
00002030  62 6c 65 20 61 6e 20 69  6e 74 65 72 72 75 70 74  |ble an interrupt|
00002040  20 77 65 20 6d 75 73 74  20 77 72 69 74 65 20 74  | we must write t|
00002050  6f 20 62 69 74 20 37 20  6f 66 20 74 68 69 73 0d  |o bit 7 of this.|
00002060  72 65 67 69 73 74 65 72  20 61 6e 64 20 61 6c 73  |register and als|
00002070  6f 20 74 6f 20 74 68 65  20 62 69 74 20 63 6f 6e  |o to the bit con|
00002080  74 72 6f 6c 6c 69 6e 67  20 74 68 65 20 69 6e 74  |trolling the int|
00002090  65 72 72 75 70 74 20 77  65 0d 77 61 6e 74 20 74  |errupt we.want t|
000020a0  6f 20 65 6e 61 62 6c 65  2e 20 20 49 6e 20 74 68  |o enable.  In th|
000020b0  65 20 63 61 73 65 20 6f  66 20 54 31 20 69 74 20  |e case of T1 it |
000020c0  69 73 20 62 69 74 20 36  2e 20 20 49 6e 20 6c 69  |is bit 6.  In li|
000020d0  6e 65 73 0d 35 37 30 20  61 6e 64 20 35 38 30 20  |nes.570 and 580 |
000020e0  77 65 20 77 72 69 74 65  20 26 43 30 20 74 6f 20  |we write &C0 to |
000020f0  74 68 69 73 20 72 65 67  69 73 74 65 72 20 61 6e  |this register an|
00002100  64 20 73 6f 20 73 65 74  20 54 31 0d 69 6e 74 65  |d so set T1.inte|
00002110  72 72 75 70 74 73 2e 20  20 28 54 6f 20 64 69 73  |rrupts.  (To dis|
00002120  61 62 6c 65 20 61 6e 20  69 6e 74 65 72 72 75 70  |able an interrup|
00002130  74 20 79 6f 75 20 6c 65  61 76 65 20 62 69 74 20  |t you leave bit |
00002140  37 20 63 6c 65 61 72 0d  61 6e 64 20 77 72 69 74  |7 clear.and writ|
00002150  65 20 61 20 31 20 74 6f  20 74 68 65 20 72 65 6c  |e a 1 to the rel|
00002160  65 76 61 6e 74 20 62 69  74 20 6f 72 20 62 69 74  |evant bit or bit|
00002170  73 2e 29 0d 0d 52 65 67  69 73 74 65 72 20 34 20  |s.)..Register 4 |
00002180  2d 20 54 69 6d 65 72 20  31 20 6c 6f 77 20 6f 72  |- Timer 1 low or|
00002190  64 65 72 20 63 6f 75 6e  74 65 72 0d 52 65 67 69  |der counter.Regi|
000021a0  73 74 65 72 20 35 20 2d  20 54 69 6d 65 72 20 31  |ster 5 - Timer 1|
000021b0  20 68 69 67 68 20 6f 72  64 65 72 20 63 6f 75 6e  | high order coun|
000021c0  74 65 72 0d 0d 52 65 67  69 73 74 65 72 20 34 20  |ter..Register 4 |
000021d0  69 73 20 6c 6f 61 64 65  64 20 77 69 74 68 20 74  |is loaded with t|
000021e0  68 65 20 6c 6f 77 65 72  20 62 79 74 65 20 6f 66  |he lower byte of|
000021f0  20 74 68 65 20 74 77 6f  20 62 79 74 65 0d 74 69  | the two byte.ti|
00002200  6d 69 6e 67 20 76 61 6c  75 65 20 66 69 72 73 74  |ming value first|
00002210  2e 20 20 41 74 20 74 68  69 73 20 74 69 6d 65 20  |.  At this time |
00002220  79 6f 75 20 61 72 65 20  61 63 74 75 61 6c 6c 79  |you are actually|
00002230  20 6c 6f 61 64 69 6e 67  20 61 0d 6c 61 74 63 68  | loading a.latch|
00002240  20 77 68 69 63 68 20 68  6f 6c 64 73 20 74 68 65  | which holds the|
00002250  20 76 61 6c 75 65 2e 20  20 57 68 65 6e 20 79 6f  | value.  When yo|
00002260  75 20 6c 6f 61 64 20 74  68 65 20 68 69 67 68 65  |u load the highe|
00002270  72 20 62 79 74 65 0d 6f  66 20 74 68 65 20 74 69  |r byte.of the ti|
00002280  6d 65 72 20 76 61 6c 75  65 20 69 6e 74 6f 20 72  |mer value into r|
00002290  65 67 69 73 74 65 72 20  35 20 74 68 65 20 76 61  |egister 5 the va|
000022a0  6c 75 65 20 69 6e 20 74  68 65 20 6c 6f 77 65 72  |lue in the lower|
000022b0  0d 6c 61 74 63 68 20 69  73 20 74 72 61 6e 73 66  |.latch is transf|
000022c0  65 72 72 65 64 20 69 6e  74 6f 20 74 68 65 20 6c  |erred into the l|
000022d0  6f 77 65 72 20 63 6f 75  6e 74 65 72 20 61 6e 64  |ower counter and|
000022e0  20 74 68 65 20 74 69 6d  65 72 0d 73 74 61 72 74  | the timer.start|
000022f0  73 20 63 6f 75 6e 74 69  6e 67 20 64 6f 77 6e 2e  |s counting down.|
00002300  20 20 54 68 69 73 20 6c  6f 61 64 69 6e 67 20 6f  |  This loading o|
00002310  70 65 72 61 74 69 6f 6e  20 69 73 20 63 61 72 72  |peration is carr|
00002320  69 65 64 20 6f 75 74 0d  69 6e 20 6c 69 6e 65 73  |ied out.in lines|
00002330  20 38 33 30 2d 38 36 30  20 61 6e 64 20 31 33 38  | 830-860 and 138|
00002340  30 2d 31 34 31 30 2e 0d  0d 52 65 67 69 73 74 65  |0-1410...Registe|
00002350  72 20 31 33 20 2d 20 54  68 65 20 69 6e 74 65 72  |r 13 - The inter|
00002360  72 75 70 74 20 66 6c 61  67 20 72 65 67 69 73 74  |rupt flag regist|
00002370  65 72 0d 0d 4f 6e 20 72  65 63 65 69 76 69 6e 67  |er..On receiving|
00002380  20 61 6e 20 69 6e 74 65  72 72 75 70 74 20 77 65  | an interrupt we|
00002390  20 63 61 6e 20 71 75 69  63 6b 6c 79 20 63 68 65  | can quickly che|
000023a0  63 6b 20 62 69 74 20 36  20 6f 66 20 74 68 69 73  |ck bit 6 of this|
000023b0  0d 72 65 67 69 73 74 65  72 20 28 75 73 69 6e 67  |.register (using|
000023c0  20 42 49 54 20 69 6e 20  6c 69 6e 65 20 31 32 32  | BIT in line 122|
000023d0  30 29 20 74 6f 20 73 65  65 20 69 66 20 61 20 54  |0) to see if a T|
000023e0  31 20 69 6e 74 65 72 72  75 70 74 0d 68 61 73 20  |1 interrupt.has |
000023f0  6f 63 63 75 72 72 65 64  2e 20 20 54 68 69 73 20  |occurred.  This |
00002400  66 6c 61 67 20 69 73 20  63 6c 65 61 72 65 64 20  |flag is cleared |
00002410  65 69 74 68 65 72 20 62  79 20 77 72 69 74 69 6e  |either by writin|
00002420  67 20 61 20 31 0d 69 6e  74 6f 20 69 74 2c 20 6f  |g a 1.into it, o|
00002430  72 20 62 79 20 72 65 6c  6f 61 64 69 6e 67 20 74  |r by reloading t|
00002440  68 65 20 74 69 6d 65 72  2e 20 20 49 6e 20 74 68  |he timer.  In th|
00002450  69 73 20 70 72 6f 67 72  61 6d 20 74 68 65 0d 6c  |is program the.l|
00002460  61 74 74 65 72 20 6d 65  74 68 6f 64 20 69 73 20  |atter method is |
00002470  75 73 65 64 20 73 69 6e  63 65 20 77 65 20 68 61  |used since we ha|
00002480  76 65 20 74 6f 20 72 65  6c 6f 61 64 20 74 68 65  |ve to reload the|
00002490  20 74 69 6d 65 72 0d 61  6e 79 77 61 79 2e 0d 0d  | timer.anyway...|
000024a0  4c 65 74 27 73 20 67 6f  20 74 68 72 6f 75 67 68  |Let's go through|
000024b0  20 74 68 65 20 70 72 6f  67 72 61 6d 2e 20 20 42  | the program.  B|
000024c0  2f 6f 73 62 31 39 20 74  61 6b 65 73 20 6c 6f 67  |/osb19 takes log|
000024d0  69 63 61 6c 20 63 6f 6c  6f 75 72 0d 31 20 61 6e  |ical colour.1 an|
000024e0  64 20 63 68 61 6e 67 65  73 20 69 74 73 20 61 63  |d changes its ac|
000024f0  74 75 61 6c 20 63 6f 6c  6f 75 72 20 64 65 70 65  |tual colour depe|
00002500  6e 64 69 6e 67 20 6f 6e  20 77 68 65 72 65 2c 0d  |nding on where,.|
00002510  76 65 72 74 69 63 61 6c  6c 79 20 6f 6e 20 74 68  |vertically on th|
00002520  65 20 73 63 72 65 65 6e  2c 20 79 6f 75 20 61 72  |e screen, you ar|
00002530  65 2e 20 20 54 68 65 20  77 69 64 74 68 20 6f 66  |e.  The width of|
00002540  20 74 68 65 0d 68 6f 72  69 7a 6f 6e 74 61 6c 20  | the.horizontal |
00002550  62 61 6e 64 73 20 6f 66  20 63 6f 6c 6f 75 72 20  |bands of colour |
00002560  61 6e 64 20 74 68 65 20  63 6f 6c 6f 75 72 73 20  |and the colours |
00002570  75 73 65 64 20 61 72 65  20 68 65 6c 64 20 69 6e  |used are held in|
00002580  0d 61 20 62 6c 6f 63 6b  20 6f 66 20 6d 65 6d 6f  |.a block of memo|
00002590  72 79 20 61 6e 64 20 63  61 6e 20 62 65 20 6d 6f  |ry and can be mo|
000025a0  64 69 66 69 65 64 2e 20  20 54 68 65 20 65 66 66  |dified.  The eff|
000025b0  65 63 74 20 77 69 6c 6c  20 62 65 0d 76 69 73 69  |ect will be.visi|
000025c0  62 6c 65 20 69 6e 20 61  6e 79 20 6d 6f 64 65 20  |ble in any mode |
000025d0  65 78 63 65 70 74 20 4d  6f 64 65 20 37 20 61 73  |except Mode 7 as|
000025e0  20 67 72 61 70 68 69 63  73 20 61 6e 64 20 74 65  | graphics and te|
000025f0  78 74 20 61 72 65 0d 64  72 61 77 6e 20 69 6e 20  |xt are.drawn in |
00002600  63 6f 6c 6f 75 72 20 31  2e 0d 0d 53 69 6e 63 65  |colour 1...Since|
00002610  20 77 65 20 61 72 65 20  6d 61 6b 69 6e 67 20 61  | we are making a|
00002620  6e 20 69 6e 74 65 72 72  75 70 74 20 72 6f 75 74  |n interrupt rout|
00002630  69 6e 65 20 74 68 65 20  63 6f 64 65 20 68 61 73  |ine the code has|
00002640  20 74 6f 0d 6c 69 76 65  20 69 6e 20 74 68 65 20  | to.live in the |
00002650  49 2f 4f 20 70 72 6f 63  65 73 73 6f 72 20 61 6e  |I/O processor an|
00002660  64 20 74 68 65 20 70 72  6f 67 72 61 6d 20 63 68  |d the program ch|
00002670  65 63 6b 73 20 74 6f 20  6d 61 6b 65 0d 73 75 72  |ecks to make.sur|
00002680  65 20 74 68 61 74 20 61  20 73 65 63 6f 6e 64 20  |e that a second |
00002690  70 72 6f 63 65 73 73 6f  72 20 69 73 20 6e 6f 74  |processor is not|
000026a0  20 69 6e 20 75 73 65 2e  20 20 49 20 68 61 76 65  | in use.  I have|
000026b0  20 75 73 65 64 0d 4f 53  42 59 54 45 20 32 33 34  | used.OSBYTE 234|
000026c0  20 66 6f 72 20 74 68 61  74 20 74 68 69 73 20 74  | for that this t|
000026d0  69 6d 65 2e 20 20 4f 6e  20 65 78 69 74 20 58 20  |ime.  On exit X |
000026e0  69 73 20 30 20 69 66 20  6e 6f 20 73 65 63 6f 6e  |is 0 if no secon|
000026f0  64 0d 70 72 6f 63 65 73  73 6f 72 20 69 73 20 62  |d.processor is b|
00002700  65 69 6e 67 20 75 73 65  64 20 61 6e 64 20 26 46  |eing used and &F|
00002710  46 20 69 66 20 6f 6e 65  20 69 73 2e 20 20 54 68  |F if one is.  Th|
00002720  65 72 65 20 73 68 6f 75  6c 64 20 6e 6f 74 0d 62  |ere should not.b|
00002730  65 20 61 6e 6f 74 68 65  72 20 72 65 73 75 6c 74  |e another result|
00002740  2e 20 20 54 68 69 73 20  6d 65 74 68 6f 64 20 73  |.  This method s|
00002750  68 6f 75 6c 64 20 62 65  20 6d 6f 72 65 20 66 6f  |hould be more fo|
00002760  6f 6c 2d 70 72 6f 6f 66  0d 74 68 61 6e 20 73 69  |ol-proof.than si|
00002770  6d 70 6c 79 20 63 68 65  63 6b 69 6e 67 20 74 68  |mply checking th|
00002780  65 20 76 61 6c 75 65 20  6f 66 20 50 41 47 45 2e  |e value of PAGE.|
00002790  0d 0d 54 68 65 20 49 52  51 20 61 6e 64 20 45 76  |..The IRQ and Ev|
000027a0  65 6e 74 20 76 65 63 74  6f 72 73 20 61 72 65 20  |ent vectors are |
000027b0  73 61 76 65 64 20 61 6e  64 20 74 68 65 20 6e 65  |saved and the ne|
000027c0  77 20 69 6e 74 65 72 63  65 70 74 0d 61 64 64 72  |w intercept.addr|
000027d0  65 73 73 65 73 20 6c 6f  61 64 65 64 2e 20 20 59  |esses loaded.  Y|
000027e0  6f 75 20 77 69 6c 6c 20  6e 6f 74 69 63 65 20 74  |ou will notice t|
000027f0  68 61 74 20 69 6e 74 65  72 72 75 70 74 73 20 61  |hat interrupts a|
00002800  72 65 0d 64 69 73 61 62  6c 65 64 20 64 75 72 69  |re.disabled duri|
00002810  6e 67 20 74 68 65 20 6c  61 74 74 65 72 20 6f 70  |ng the latter op|
00002820  65 72 61 74 69 6f 6e 2e  20 20 49 20 61 6d 20 75  |eration.  I am u|
00002830  73 69 6e 67 20 49 52 51  31 0d 62 65 63 61 75 73  |sing IRQ1.becaus|
00002840  65 20 69 6e 74 65 72 63  65 70 74 73 20 6f 66 20  |e intercepts of |
00002850  49 52 51 32 20 61 72 65  20 61 20 6c 69 74 74 6c  |IRQ2 are a littl|
00002860  65 20 74 6f 6f 20 76 61  72 69 61 62 6c 65 20 66  |e too variable f|
00002870  6f 72 20 74 68 65 0d 6b  69 6e 64 20 6f 66 20 6f  |or the.kind of o|
00002880  70 65 72 61 74 69 6f 6e  20 68 65 72 65 2e 20 20  |peration here.  |
00002890  59 6f 75 20 73 68 6f 75  6c 64 20 63 68 61 6e 67  |You should chang|
000028a0  65 20 74 68 65 20 61 64  64 72 65 73 73 20 69 6e  |e the address in|
000028b0  0d 6c 69 6e 65 20 31 31  30 20 66 72 6f 6d 20 26  |.line 110 from &|
000028c0  32 30 34 20 74 6f 20 26  32 30 36 20 74 6f 20 73  |204 to &206 to s|
000028d0  65 65 20 74 68 65 20 65  66 66 65 63 74 20 49 20  |ee the effect I |
000028e0  6d 65 61 6e 2e 0d 0d 54  68 65 20 62 61 6e 64 73  |mean...The bands|
000028f0  20 77 69 6c 6c 20 66 6c  69 63 6b 65 72 20 72 61  | will flicker ra|
00002900  74 68 65 72 20 76 69 6f  6c 65 6e 74 6c 79 2c 20  |ther violently, |
00002910  6f 72 20 61 74 20 6c 65  61 73 74 20 74 68 65 79  |or at least they|
00002920  20 64 6f 0d 6f 6e 20 6d  79 20 6d 61 63 68 69 6e  | do.on my machin|
00002930  65 2e 20 20 49 20 73 75  73 70 65 63 74 20 74 68  |e.  I suspect th|
00002940  61 74 20 74 68 69 73 20  69 73 20 64 75 65 20 74  |at this is due t|
00002950  6f 20 74 68 65 20 74 69  6d 65 20 74 61 6b 65 6e  |o the time taken|
00002960  0d 66 6f 72 20 74 68 65  20 4f 53 20 74 6f 20 66  |.for the OS to f|
00002970  69 6e 69 73 68 20 73 65  72 76 69 63 69 6e 67 20  |inish servicing |
00002980  77 68 61 74 65 76 65 72  20 69 6e 74 65 72 72 75  |whatever interru|
00002990  70 74 20 6f 63 63 75 72  72 65 64 0d 6a 75 73 74  |pt occurred.just|
000029a0  20 70 72 69 6f 72 20 74  6f 20 6f 75 72 20 74 69  | prior to our ti|
000029b0  6d 65 72 20 69 6e 74 65  72 72 75 70 74 2e 20 20  |mer interrupt.  |
000029c0  4f 75 72 20 69 6e 74 65  72 72 75 70 74 20 69 73  |Our interrupt is|
000029d0  0d 27 73 74 6f 72 65 64  27 20 75 6e 74 69 6c 20  |.'stored' until |
000029e0  69 6e 74 65 72 72 75 70  74 73 20 61 72 65 20 65  |interrupts are e|
000029f0  6e 61 62 6c 65 64 20 61  67 61 69 6e 2c 20 62 65  |nabled again, be|
00002a00  63 61 75 73 65 20 74 68  65 0d 69 6e 74 65 72 72  |cause the.interr|
00002a10  75 70 74 20 66 6c 61 67  73 20 6f 6e 20 74 68 65  |upt flags on the|
00002a20  20 56 49 41 20 72 65 6d  61 69 6e 20 73 65 74 2c  | VIA remain set,|
00002a30  20 61 6e 64 20 74 68 65  6e 20 69 74 20 69 73 0d  | and then it is.|
00002a40  73 65 72 76 69 63 65 64  20 62 79 20 6f 75 72 20  |serviced by our |
00002a50  72 6f 75 74 69 6e 65 2e  20 20 54 68 69 73 20 64  |routine.  This d|
00002a60  65 6c 61 79 2c 20 77 68  69 63 68 20 77 6f 75 6c  |elay, which woul|
00002a70  64 20 62 65 20 76 65 72  79 0d 76 61 72 69 61 62  |d be very.variab|
00002a80  6c 65 2c 20 6c 65 61 64  73 20 74 6f 20 64 65 6c  |le, leads to del|
00002a90  61 79 73 20 69 6e 20 69  6d 70 6c 69 6d 65 6e 74  |ays in impliment|
00002aa0  69 6e 67 20 6f 75 72 20  70 61 6c 65 74 74 65 0d  |ing our palette.|
00002ab0  73 77 69 74 63 68 69 6e  67 20 72 6f 75 74 69 6e  |switching routin|
00002ac0  65 20 61 6e 64 20 68 65  6e 63 65 20 63 61 75 73  |e and hence caus|
00002ad0  65 73 20 74 68 65 20 66  6c 69 63 6b 65 72 69 6e  |es the flickerin|
00002ae0  67 2e 20 20 5b 54 68 65  0d 62 61 6e 64 73 20 77  |g.  [The.bands w|
00002af0  69 6c 6c 20 61 6c 73 6f  20 27 62 6f 75 6e 63 65  |ill also 'bounce|
00002b00  27 20 77 68 65 6e 20 61  20 64 69 73 63 20 69 73  |' when a disc is|
00002b10  20 61 63 63 65 73 73 65  64 2c 20 74 68 69 73 20  | accessed, this |
00002b20  69 73 0d 64 75 65 20 74  6f 20 74 68 65 20 4e 4d  |is.due to the NM|
00002b30  49 20 72 6f 75 74 69 6e  65 73 20 73 65 72 76 69  |I routines servi|
00002b40  63 69 6e 67 20 74 68 65  20 64 69 73 63 20 64 72  |cing the disc dr|
00002b50  69 76 65 2e 5d 0d 0d 4c  69 6e 65 20 36 35 30 20  |ive.]..Line 650 |
00002b60  74 6f 20 6c 69 6e 65 20  39 37 30 20 69 73 20 74  |to line 970 is t|
00002b70  68 65 20 63 6f 64 65 20  74 68 61 74 20 6c 69 65  |he code that lie|
00002b80  73 20 69 6e 20 74 68 65  20 65 76 65 6e 74 0d 76  |s in the event.v|
00002b90  65 63 74 6f 72 2e 20 20  57 65 20 61 72 65 20 77  |ector.  We are w|
00002ba0  61 69 74 69 6e 67 20 66  6f 72 20 65 76 65 6e 74  |aiting for event|
00002bb0  20 34 2c 20 77 68 69 63  68 20 77 69 6c 6c 20 62  | 4, which will b|
00002bc0  65 20 61 63 74 69 76 61  74 65 64 0d 6c 61 74 65  |e activated.late|
00002bd0  72 2e 20 20 57 68 65 6e  20 77 65 20 68 61 76 65  |r.  When we have|
00002be0  20 63 6f 6e 66 69 72 6d  65 64 20 74 68 61 74 20  | confirmed that |
00002bf0  69 74 20 69 73 20 69 6e  64 65 65 64 20 65 76 65  |it is indeed eve|
00002c00  6e 74 20 34 2c 0d 74 68  65 20 76 65 72 74 69 63  |nt 4,.the vertic|
00002c10  61 6c 20 73 79 6e 63 20  70 75 6c 73 65 20 65 76  |al sync pulse ev|
00002c20  65 6e 74 2c 20 77 65 20  73 61 76 65 20 72 65 67  |ent, we save reg|
00002c30  69 73 74 65 72 73 2c 20  66 6f 72 63 65 0d 62 69  |isters, force.bi|
00002c40  6e 61 72 79 20 6d 6f 64  65 20 61 6e 64 20 72 65  |nary mode and re|
00002c50  2d 73 65 74 20 61 20 63  6f 6c 6f 75 72 20 63 6f  |-set a colour co|
00002c60  75 6e 74 65 72 20 66 6c  61 67 20 74 6f 20 7a 65  |unter flag to ze|
00002c70  72 6f 2e 20 20 54 68 69  73 0d 66 6c 61 67 2c 20  |ro.  This.flag, |
00002c80  63 61 6c 6c 65 64 20 27  63 6f 6c 6f 75 72 73 27  |called 'colours'|
00002c90  20 69 73 20 63 6f 75 6e  74 69 6e 67 20 74 68 65  | is counting the|
00002ca0  20 6e 75 6d 62 65 72 20  6f 66 20 74 68 65 20 62  | number of the b|
00002cb0  61 6e 64 20 77 65 0d 61  72 65 20 67 6f 69 6e 67  |and we.are going|
00002cc0  20 74 6f 20 64 72 61 77  20 6f 6e 20 74 68 65 20  | to draw on the |
00002cd0  73 63 72 65 65 6e 20 73  6f 20 74 68 61 74 20 74  |screen so that t|
00002ce0  68 65 20 63 6f 72 72 65  63 74 20 63 6f 6c 6f 75  |he correct colou|
00002cf0  72 0d 63 61 6e 20 62 65  20 61 6c 6c 6f 63 61 74  |r.can be allocat|
00002d00  65 64 2e 0d 0d 49 20 63  6f 75 6c 64 20 68 61 76  |ed...I could hav|
00002d10  65 20 63 6f 6c 6f 75 72  65 64 20 74 68 65 20 66  |e coloured the f|
00002d20  69 72 73 74 20 62 61 6e  64 20 66 72 6f 6d 20 68  |irst band from h|
00002d30  65 72 65 20 62 75 74 20  49 20 68 61 76 65 0d 64  |ere but I have.d|
00002d40  65 63 69 64 65 64 20 74  6f 20 73 77 69 74 63 68  |ecided to switch|
00002d50  20 74 68 65 20 74 6f 70  20 62 61 6e 64 20 69 6e  | the top band in|
00002d60  20 6a 75 73 74 20 61 62  6f 76 65 20 74 68 65 20  | just above the |
00002d70  74 6f 70 20 6f 66 0d 73  63 72 65 65 6e 2e 20 20  |top of.screen.  |
00002d80  54 68 65 20 74 69 6d 65  20 64 65 6c 61 79 20 62  |The time delay b|
00002d90  65 74 77 65 65 6e 20 74  68 65 20 73 79 6e 63 20  |etween the sync |
00002da0  61 6e 64 20 74 68 65 20  74 6f 70 20 6f 66 0d 73  |and the top of.s|
00002db0  63 72 65 65 6e 20 69 73  20 66 6f 75 6e 64 20 62  |creen is found b|
00002dc0  79 20 74 72 69 61 6c 20  61 6e 64 20 65 72 72 6f  |y trial and erro|
00002dd0  72 20 61 6e 64 20 49 20  66 6f 75 6e 64 20 69 74  |r and I found it|
00002de0  20 74 6f 20 62 65 20 26  35 36 30 0d 6d 69 63 72  | to be &560.micr|
00002df0  6f 73 65 63 6f 6e 64 73  20 6f 6e 20 6d 79 20 6d  |oseconds on my m|
00002e00  61 63 68 69 6e 65 2e 20  20 54 68 65 20 63 6f 75  |achine.  The cou|
00002e10  6e 74 65 72 20 69 73 20  6c 6f 61 64 65 64 20 77  |nter is loaded w|
00002e20  69 74 68 20 74 68 69 73  0d 76 61 6c 75 65 20 61  |ith this.value a|
00002e30  6e 64 20 73 74 61 72 74  65 64 20 28 6c 69 6e 65  |nd started (line|
00002e40  73 20 38 33 30 20 74 6f  20 38 36 30 29 20 61 6e  |s 830 to 860) an|
00002e50  64 20 74 68 65 20 65 76  65 6e 74 20 69 6e 74 65  |d the event inte|
00002e60  72 63 65 70 74 0d 69 73  20 6e 6f 77 20 6f 76 65  |rcept.is now ove|
00002e70  72 20 61 6e 64 20 77 65  20 65 78 69 74 2e 0d 0d  |r and we exit...|
00002e80  4e 65 78 74 20 49 20 68  61 76 65 20 70 75 74 20  |Next I have put |
00002e90  74 68 65 20 62 6c 6f 63  6b 20 6f 66 20 6d 65 6d  |the block of mem|
00002ea0  6f 72 79 20 69 6e 20 77  68 69 63 68 20 70 61 72  |ory in which par|
00002eb0  61 6d 65 74 65 72 73 20  61 6e 64 0d 66 6c 61 67  |ameters and.flag|
00002ec0  73 20 61 72 65 20 73 74  6f 72 65 64 2e 20 20 59  |s are stored.  Y|
00002ed0  6f 75 20 63 61 6e 20 61  63 74 75 61 6c 6c 79 20  |ou can actually |
00002ee0  70 75 74 20 74 68 69 73  20 6b 69 6e 64 20 6f 66  |put this kind of|
00002ef0  20 62 6c 6f 63 6b 0d 61  6e 79 77 68 65 72 65 20  | block.anywhere |
00002f00  79 6f 75 20 6c 69 6b 65  20 77 69 74 68 69 6e 20  |you like within |
00002f10  79 6f 75 72 20 63 6f 64  65 2c 20 61 73 20 6c 6f  |your code, as lo|
00002f20  6e 67 20 61 73 20 69 74  20 6c 69 65 73 20 6f 75  |ng as it lies ou|
00002f30  74 0d 6f 66 20 74 68 65  20 77 61 79 20 6f 66 20  |t.of the way of |
00002f40  70 72 6f 67 72 61 6d 20  65 78 65 63 75 74 69 6f  |program executio|
00002f50  6e 2e 0d 0d 41 20 62 6c  6f 63 6b 20 6f 66 20 35  |n...A block of 5|
00002f60  20 62 79 74 65 73 20 61  74 20 27 70 61 72 61 5f  | bytes at 'para_|
00002f70  62 6c 6f 63 6b 27 20 69  73 20 74 68 65 20 70 61  |block' is the pa|
00002f80  72 61 6d 65 74 65 72 20  62 6c 6f 63 6b 0d 66 6f  |rameter block.fo|
00002f90  72 20 74 68 65 20 4f 53  57 4f 52 44 20 63 61 6c  |r the OSWORD cal|
00002fa0  6c 2e 20 20 49 20 68 61  76 65 20 70 72 65 2d 6c  |l.  I have pre-l|
00002fb0  6f 61 64 65 64 20 74 68  65 20 66 69 72 73 74 20  |oaded the first |
00002fc0  62 79 74 65 20 77 69 74  68 0d 61 20 27 31 27 20  |byte with.a '1' |
00002fd0  77 68 69 63 68 20 69 73  20 74 68 65 20 6c 6f 67  |which is the log|
00002fe0  69 63 61 6c 20 63 6f 6c  6f 75 72 20 77 65 20 77  |ical colour we w|
00002ff0  69 6c 6c 20 62 65 20 73  77 69 74 63 68 69 6e 67  |ill be switching|
00003000  2e 20 0d 53 68 6f 75 6c  64 20 79 6f 75 20 77 61  |. .Should you wa|
00003010  6e 74 20 74 6f 20 73 77  69 74 63 68 20 61 6e 6f  |nt to switch ano|
00003020  74 68 65 72 20 63 6f 6c  6f 75 72 20 74 68 65 6e  |ther colour then|
00003030  20 63 68 61 6e 67 65 20  74 68 69 73 0d 62 79 74  | change this.byt|
00003040  65 2e 0d 0d 59 6f 75 20  77 69 6c 6c 20 73 65 65  |e...You will see|
00003050  20 74 68 61 74 20 61 74  20 27 63 6f 6c 6f 75 72  | that at 'colour|
00003060  73 27 20 49 20 68 61 76  65 20 70 75 74 20 74 68  |s' I have put th|
00003070  65 20 63 6f 75 6e 74 65  72 20 66 6c 61 67 0d 61  |e counter flag.a|
00003080  6e 64 20 74 68 61 74 20  61 66 74 65 72 20 69 74  |nd that after it|
00003090  20 63 6f 6d 65 73 20 61  20 6c 69 73 74 20 6f 66  | comes a list of|
000030a0  20 36 20 62 79 74 65 73  2c 20 65 61 63 68 20 63  | 6 bytes, each c|
000030b0  6f 6e 74 61 69 6e 69 6e  67 0d 74 68 65 20 6e 75  |ontaining.the nu|
000030c0  6d 62 65 72 20 6f 66 20  61 20 63 6f 6c 6f 75 72  |mber of a colour|
000030d0  2e 20 20 59 6f 75 20 63  61 6e 20 6d 6f 64 69 66  |.  You can modif|
000030e0  79 20 74 68 69 73 20 6c  69 73 74 20 69 66 20 79  |y this list if y|
000030f0  6f 75 0d 77 61 6e 74 20  74 6f 20 63 68 61 6e 67  |ou.want to chang|
00003100  65 20 74 68 65 20 63 6f  6c 6f 75 72 73 20 6f 66  |e the colours of|
00003110  20 74 68 65 20 62 61 6e  64 73 2e 20 20 54 68 69  | the bands.  Thi|
00003120  73 20 63 6f 64 65 20 64  72 61 77 73 20 75 70 0d  |s code draws up.|
00003130  74 6f 20 73 69 78 20 62  61 6e 64 73 20 62 75 74  |to six bands but|
00003140  20 63 6f 75 6c 64 20 62  65 20 65 61 73 69 6c 79  | could be easily|
00003150  20 6d 6f 64 69 66 69 65  64 20 74 6f 20 64 72 61  | modified to dra|
00003160  77 20 6d 6f 72 65 20 6a  75 73 74 0d 62 79 20 61  |w more just.by a|
00003170  64 64 69 6e 67 20 6d 6f  72 65 20 6c 69 6e 65 73  |dding more lines|
00003180  20 6f 66 20 27 63 6f 6c  6f 75 72 73 27 20 69 6e  | of 'colours' in|
00003190  20 74 68 69 73 20 73 65  63 74 69 6f 6e 20 6f 66  | this section of|
000031a0  20 6d 65 6d 6f 72 79 0d  61 6e 64 20 61 64 64 69  | memory.and addi|
000031b0  6e 67 20 65 71 75 69 76  61 6c 65 6e 74 20 27 63  |ng equivalent 'c|
000031c0  6f 6c 74 69 6d 65 73 27  20 62 65 6c 6f 77 2e 20  |oltimes' below. |
000031d0  20 54 68 65 20 27 63 6f  6c 74 69 6d 65 73 27 0d  | The 'coltimes'.|
000031e0  62 79 74 65 73 20 61 72  65 20 74 68 65 20 6c 65  |bytes are the le|
000031f0  6e 67 74 68 20 6f 66 20  74 68 65 20 62 61 6e 64  |ngth of the band|
00003200  73 20 69 6e 20 75 6e 69  74 73 20 6f 66 20 32 35  |s in units of 25|
00003210  36 0d 6d 69 63 72 6f 73  65 63 6f 6e 64 73 2e 20  |6.microseconds. |
00003220  20 48 6f 77 65 76 65 72  2c 20 73 69 6e 63 65 20  | However, since |
00003230  74 68 65 20 69 6e 74 65  72 72 75 70 74 20 63 6f  |the interrupt co|
00003240  64 65 20 74 61 6b 65 73  20 61 0d 66 69 6e 69 74  |de takes a.finit|
00003250  65 20 74 69 6d 65 20 74  6f 20 65 78 65 63 75 74  |e time to execut|
00003260  65 20 79 6f 75 20 63 61  6e 20 6e 6f 74 20 73 68  |e you can not sh|
00003270  72 69 6e 6b 20 61 20 62  61 6e 64 20 74 6f 20 6e  |rink a band to n|
00003280  6f 74 68 69 6e 67 0d 62  79 20 65 6e 74 65 72 69  |othing.by enteri|
00003290  6e 67 20 7a 65 72 6f 2e  20 20 54 72 79 20 74 68  |ng zero.  Try th|
000032a0  61 74 20 61 6e 64 20 73  65 65 20 74 68 65 20 65  |at and see the e|
000032b0  66 66 65 63 74 2e 20 20  4e 6f 74 65 20 61 6c 73  |ffect.  Note als|
000032c0  6f 0d 74 68 61 74 20 74  68 65 20 66 69 6e 61 6c  |o.that the final|
000032d0  20 74 69 6d 65 20 69 6e  20 74 68 65 20 6c 69 73  | time in the lis|
000032e0  74 20 69 73 20 26 46 46  20 6f 72 20 32 35 35 2e  |t is &FF or 255.|
000032f0  20 20 54 68 69 73 20 69  73 20 74 6f 0d 6d 61 6b  |  This is to.mak|
00003300  65 20 73 75 72 65 20 74  68 61 74 20 74 68 65 20  |e sure that the |
00003310  62 6f 74 74 6f 6d 20 6f  66 20 74 68 65 20 66 69  |bottom of the fi|
00003320  6e 61 6c 20 62 61 6e 64  20 69 73 20 6e 6f 74 20  |nal band is not |
00003330  72 65 61 63 68 65 64 0d  62 65 66 6f 72 65 20 74  |reached.before t|
00003340  68 65 20 76 65 72 74 69  63 61 6c 20 73 79 6e 63  |he vertical sync|
00003350  2e 20 20 54 68 65 20 6c  61 73 74 20 6e 75 6d 62  |.  The last numb|
00003360  65 72 20 69 6e 20 74 68  65 20 27 63 6f 6c 74 69  |er in the 'colti|
00003370  6d 65 73 27 0d 62 6c 6f  63 6b 20 73 68 6f 75 6c  |mes'.block shoul|
00003380  64 20 61 6c 77 61 79 73  20 62 65 20 26 46 46 2e  |d always be &FF.|
00003390  0d 0d 54 68 65 6e 20 77  65 20 68 61 76 65 20 74  |..Then we have t|
000033a0  68 65 20 69 6e 74 65 72  72 75 70 74 20 63 6f 64  |he interrupt cod|
000033b0  65 2c 20 66 72 6f 6d 20  6c 69 6e 65 20 31 31 37  |e, from line 117|
000033c0  30 20 74 6f 20 6c 69 6e  65 0d 31 36 31 30 2e 20  |0 to line.1610. |
000033d0  20 46 69 72 73 74 20 69  74 20 71 75 69 63 6b 6c  | First it quickl|
000033e0  79 20 63 68 65 63 6b 73  20 74 6f 20 73 65 65 20  |y checks to see |
000033f0  69 66 20 74 68 69 73 20  69 73 20 61 20 74 69 6d  |if this is a tim|
00003400  65 72 20 31 0d 69 6e 74  65 72 72 75 70 74 2e 20  |er 1.interrupt. |
00003410  20 53 69 6e 63 65 20 74  68 65 20 61 63 63 75 6d  | Since the accum|
00003420  75 6c 61 74 6f 72 20 76  61 6c 75 65 20 69 73 20  |ulator value is |
00003430  73 61 66 65 6c 79 20 68  65 6c 64 20 69 6e 0d 26  |safely held in.&|
00003440  46 43 20 77 65 20 63 61  6e 20 63 6f 72 72 75 70  |FC we can corrup|
00003450  74 20 74 68 65 20 61 63  63 75 6d 75 6c 61 74 6f  |t the accumulato|
00003460  72 2e 20 20 54 68 69 73  20 6d 65 61 6e 73 20 74  |r.  This means t|
00003470  68 61 74 20 74 68 69 73  0d 66 61 73 74 20 63 68  |hat this.fast ch|
00003480  65 63 6b 20 63 61 6e 20  62 65 20 6d 61 64 65 20  |eck can be made |
00003490  77 69 74 68 6f 75 74 20  73 61 76 69 6e 67 20 61  |without saving a|
000034a0  6e 64 20 72 65 73 74 6f  72 69 6e 67 0d 72 65 67  |nd restoring.reg|
000034b0  69 73 74 65 72 73 2e 20  20 41 73 20 74 68 69 73  |isters.  As this|
000034c0  20 63 6f 64 65 20 69 73  20 73 69 74 74 69 6e 67  | code is sitting|
000034d0  20 61 73 20 74 6f 70 20  70 72 69 6f 72 69 74 79  | as top priority|
000034e0  20 69 6e 20 74 68 65 0d  69 6e 74 65 72 72 75 70  | in the.interrup|
000034f0  74 20 76 65 63 74 6f 72  20 77 65 20 6d 75 73 74  |t vector we must|
00003500  20 76 65 72 79 20 71 75  69 63 6b 6c 79 20 70 61  | very quickly pa|
00003510  73 73 20 6f 6e 20 61 6e  79 20 69 6e 74 65 72 72  |ss on any interr|
00003520  75 70 74 73 0d 77 65 20  64 6f 20 6e 6f 74 20 77  |upts.we do not w|
00003530  61 6e 74 2e 20 20 42 79  20 75 73 69 6e 67 20 42  |ant.  By using B|
00003540  49 54 20 77 65 20 70 75  74 20 74 68 65 20 76 61  |IT we put the va|
00003550  6c 75 65 20 6f 66 20 62  69 74 20 73 69 78 0d 73  |lue of bit six.s|
00003560  74 72 61 69 67 68 74 20  69 6e 74 6f 20 74 68 65  |traight into the|
00003570  20 6f 76 65 72 66 6c 6f  77 20 66 6c 61 67 20 61  | overflow flag a|
00003580  6e 64 20 63 61 6e 20 64  6f 20 61 20 71 75 69 63  |nd can do a quic|
00003590  6b 20 62 72 61 6e 63 68  20 6f 6e 0d 6f 76 65 72  |k branch on.over|
000035a0  66 6c 6f 77 20 73 65 74  20 28 42 56 53 29 20 69  |flow set (BVS) i|
000035b0  66 20 54 31 20 68 61 73  20 74 69 6d 65 64 20 6f  |f T1 has timed o|
000035c0  75 74 20 61 6e 64 20 74  68 69 73 20 69 73 20 69  |ut and this is i|
000035d0  6e 64 65 65 64 0d 6f 75  72 20 69 6e 74 65 72 72  |ndeed.our interr|
000035e0  75 70 74 2e 0d 0d 41 74  20 6c 69 6e 65 20 31 32  |upt...At line 12|
000035f0  38 30 20 72 65 67 69 73  74 65 72 73 20 61 72 65  |80 registers are|
00003600  20 73 61 76 65 64 20 61  6e 64 20 62 69 6e 61 72  | saved and binar|
00003610  79 20 6d 6f 64 65 20 69  73 20 66 6f 72 63 65 64  |y mode is forced|
00003620  2e 20 0d 54 68 65 6e 20  77 65 20 74 61 6b 65 20  |. .Then we take |
00003630  74 68 65 20 63 75 72 72  65 6e 74 20 76 61 6c 75  |the current valu|
00003640  65 20 6f 66 20 74 68 65  20 63 6f 6c 6f 75 72 73  |e of the colours|
00003650  20 63 6f 75 6e 74 65 72  20 61 6e 64 0d 74 72 61  | counter and.tra|
00003660  6e 73 66 65 72 20 69 74  20 69 6e 74 6f 20 74 68  |nsfer it into th|
00003670  65 20 58 20 72 65 67 69  73 74 65 72 2e 20 20 57  |e X register.  W|
00003680  65 20 63 61 6e 20 6e 6f  77 20 75 73 65 20 74 68  |e can now use th|
00003690  69 73 20 74 6f 0d 63 6f  75 6e 74 20 61 6c 6f 6e  |is to.count alon|
000036a0  67 20 74 68 65 20 62 6c  6f 63 6b 20 6f 66 20 63  |g the block of c|
000036b0  6f 6c 6f 75 72 73 20 61  6e 64 20 6f 66 20 27 63  |olours and of 'c|
000036c0  6f 6c 74 69 6d 65 73 27  20 74 6f 20 6c 6f 61 64  |oltimes' to load|
000036d0  0d 74 68 65 20 74 69 6d  65 72 20 61 6e 64 20 63  |.the timer and c|
000036e0  68 61 6e 67 65 20 74 68  65 20 63 6f 6c 6f 75 72  |hange the colour|
000036f0  2e 20 20 54 68 65 20 74  69 6d 65 72 20 69 73 20  |.  The timer is |
00003700  6c 6f 61 64 65 64 20 66  69 72 73 74 2c 0d 61 6e  |loaded first,.an|
00003710  64 20 72 65 73 74 61 72  74 65 64 20 28 6c 69 6e  |d restarted (lin|
00003720  65 73 20 31 33 38 30 20  74 6f 20 31 34 31 30 29  |es 1380 to 1410)|
00003730  2e 20 20 54 68 65 6e 20  4f 53 57 4f 52 44 20 31  |.  Then OSWORD 1|
00003740  32 20 28 26 43 29 20 69  73 0d 75 73 65 64 20 74  |2 (&C) is.used t|
00003750  6f 20 72 65 73 65 74 20  74 68 65 20 70 61 6c 65  |o reset the pale|
00003760  74 74 65 20 66 6f 72 20  63 6f 6c 6f 75 72 20 31  |tte for colour 1|
00003770  2e 0d 0d 46 69 6e 61 6c  6c 79 20 74 68 65 20 63  |...Finally the c|
00003780  6f 6c 6f 75 72 20 63 6f  75 6e 74 65 72 20 69 73  |olour counter is|
00003790  20 69 6e 63 72 65 6d 65  6e 74 65 64 2c 20 72 65  | incremented, re|
000037a0  67 69 73 74 65 72 73 20  61 72 65 0d 72 65 73 74  |gisters are.rest|
000037b0  6f 72 65 64 20 61 6e 64  20 77 65 20 65 78 69 74  |ored and we exit|
000037c0  20 77 69 74 68 20 61 6e  20 52 54 49 2e 0d 0d 54  | with an RTI...T|
000037d0  68 65 72 65 20 69 73 20  6e 6f 20 6e 65 65 64 20  |here is no need |
000037e0  74 6f 20 63 68 65 63 6b  20 74 68 61 74 20 77 65  |to check that we|
000037f0  20 68 61 76 65 20 72 65  61 63 68 65 64 20 74 68  | have reached th|
00003800  65 20 66 69 6e 61 6c 0d  62 61 6e 64 20 6f 66 20  |e final.band of |
00003810  63 6f 6c 6f 75 72 2e 20  20 54 68 69 73 20 69 73  |colour.  This is|
00003820  20 73 65 74 20 74 6f 20  62 65 20 73 6f 20 77 69  | set to be so wi|
00003830  64 65 20 28 32 35 35 2a  32 35 36 0d 6d 69 63 72  |de (255*256.micr|
00003840  6f 73 65 63 6f 6e 64 73  2c 20 77 68 69 63 68 20  |oseconds, which |
00003850  69 73 20 61 62 6f 75 74  20 36 35 20 6d 69 6c 6c  |is about 65 mill|
00003860  69 73 65 63 6f 6e 64 73  29 20 74 68 61 74 20 69  |iseconds) that i|
00003870  74 20 63 6f 75 6c 64 0d  6e 65 76 65 72 20 62 65  |t could.never be|
00003880  20 66 69 6e 69 73 68 65  64 20 62 65 66 6f 72 65  | finished before|
00003890  20 74 68 65 20 73 79 6e  63 20 65 76 65 6e 74 20  | the sync event |
000038a0  72 65 73 65 74 73 20 65  76 65 72 79 74 68 69 6e  |resets everythin|
000038b0  67 0d 72 65 61 64 79 20  66 6f 72 20 74 68 65 20  |g.ready for the |
000038c0  6e 65 78 74 20 66 69 65  6c 64 2e 20 20 54 68 65  |next field.  The|
000038d0  73 65 20 73 79 6e 63 20  70 75 6c 73 65 73 20 61  |se sync pulses a|
000038e0  72 65 20 6f 6e 6c 79 20  32 30 0d 6d 69 6c 6c 69  |re only 20.milli|
000038f0  73 65 63 6f 6e 64 73 20  61 70 61 72 74 2e 0d 0d  |seconds apart...|
00003900  41 73 20 61 20 75 73 65  66 75 6c 20 72 6f 75 74  |As a useful rout|
00003910  69 6e 65 20 74 68 69 73  20 69 73 20 6f 62 76 69  |ine this is obvi|
00003920  6f 75 73 6c 79 20 69 6e  63 6f 6d 70 6c 65 74 65  |ously incomplete|
00003930  2e 20 20 59 6f 75 20 77  6f 75 6c 64 0d 68 61 76  |.  You would.hav|
00003940  65 20 74 6f 20 68 61 76  65 20 73 6f 6d 65 20 63  |e to have some c|
00003950  6f 6e 74 72 6f 6c 20 6f  76 65 72 20 74 68 65 20  |ontrol over the |
00003960  63 6f 6c 6f 75 72 73 20  61 6e 64 20 77 69 64 74  |colours and widt|
00003970  68 20 6f 66 20 74 68 65  0d 62 61 6e 64 73 2e 20  |h of the.bands. |
00003980  20 4f 62 76 69 6f 75 73  6c 79 20 79 6f 75 20 63  | Obviously you c|
00003990  61 6e 20 77 72 69 74 65  20 74 6f 20 74 68 65 20  |an write to the |
000039a0  76 61 6c 75 65 73 20 6f  66 20 27 63 6f 6c 6f 75  |values of 'colou|
000039b0  72 73 27 0d 61 6e 64 20  27 63 6f 6c 74 69 6d 65  |rs'.and 'coltime|
000039c0  73 27 20 77 69 74 68 20  61 70 70 72 6f 70 72 69  |s' with appropri|
000039d0  61 74 65 20 6f 66 66 73  65 74 73 2e 20 20 41 66  |ate offsets.  Af|
000039e0  74 65 72 20 72 75 6e 6e  69 6e 67 20 74 68 65 0d  |ter running the.|
000039f0  61 73 73 65 6d 62 6c 79  20 6a 75 73 74 20 65 6e  |assembly just en|
00003a00  74 65 72 20 27 50 52 49  4e 54 20 63 6f 6c 6f 75  |ter 'PRINT colou|
00003a10  72 73 27 20 61 6e 64 20  27 50 52 49 4e 54 20 63  |rs' and 'PRINT c|
00003a20  6f 6c 74 69 6d 65 73 27  20 74 6f 0d 66 69 6e 64  |oltimes' to.find|
00003a30  20 74 68 6f 73 65 20 76  61 6c 75 65 73 2e 20 20  | those values.  |
00003a40  54 6f 20 77 72 69 74 65  20 74 6f 20 74 68 6f 73  |To write to thos|
00003a50  65 20 6c 6f 63 61 74 69  6f 6e 73 20 61 63 72 6f  |e locations acro|
00003a60  73 73 20 74 68 65 0d 74  75 62 65 2c 20 66 72 6f  |ss the.tube, fro|
00003a70  6d 20 61 20 73 65 63 6f  6e 64 20 70 72 6f 63 65  |m a second proce|
00003a80  73 73 6f 72 2c 20 75 73  65 20 4f 53 57 4f 52 44  |ssor, use OSWORD|
00003a90  20 36 2e 20 20 48 65 72  65 2c 20 61 74 20 74 68  | 6.  Here, at th|
00003aa0  65 0d 62 6c 6f 63 6b 20  6f 66 20 6d 65 6d 6f 72  |e.block of memor|
00003ab0  79 20 70 6f 69 6e 74 65  64 20 74 6f 20 62 79 20  |y pointed to by |
00003ac0  58 20 61 6e 64 20 59 20  28 58 59 29 20 79 6f 75  |X and Y (XY) you|
00003ad0  20 73 68 6f 75 6c 64 20  70 75 74 0d 74 68 65 20  | should put.the |
00003ae0  33 32 20 62 69 74 20 61  64 64 72 65 73 73 20 6f  |32 bit address o|
00003af0  66 20 74 68 65 20 6d 65  6d 6f 72 79 20 74 6f 20  |f the memory to |
00003b00  62 65 20 77 72 69 74 74  65 6e 2e 20 20 41 73 20  |be written.  As |
00003b10  69 74 20 69 73 20 69 6e  0d 74 68 65 20 49 2f 4f  |it is in.the I/O|
00003b20  20 70 72 6f 63 65 73 73  6f 72 20 74 68 65 20 74  | processor the t|
00003b30  6f 70 20 31 36 20 62 69  74 73 20 73 68 6f 75 6c  |op 16 bits shoul|
00003b40  64 20 62 65 20 73 65 74  2e 20 20 49 6e 20 58 59  |d be set.  In XY|
00003b50  2b 34 0d 79 6f 75 20 77  69 6c 6c 20 70 75 74 20  |+4.you will put |
00003b60  74 68 65 20 62 79 74 65  20 74 6f 20 62 65 20 77  |the byte to be w|
00003b70  72 69 74 74 65 6e 2e 0d  0d 54 68 65 20 62 69 74  |ritten...The bit|
00003b80  20 6f 66 20 42 41 53 49  43 20 61 74 20 74 68 65  | of BASIC at the|
00003b90  20 65 6e 64 20 6f 66 20  74 68 65 20 70 72 6f 67  | end of the prog|
00003ba0  72 61 6d 20 69 6e 20 74  68 69 73 20 6d 6f 64 75  |ram in this modu|
00003bb0  6c 65 0d 65 6e 61 62 6c  65 73 20 74 68 65 20 65  |le.enables the e|
00003bc0  76 65 6e 74 20 28 2a 46  58 20 31 34 20 34 29 20  |vent (*FX 14 4) |
00003bd0  61 6e 64 20 70 72 69 6e  74 73 20 75 70 20 73 6f  |and prints up so|
00003be0  6d 65 20 63 6f 6c 6f 75  72 65 64 0d 74 65 78 74  |me coloured.text|
00003bf0  20 69 6e 20 4d 6f 64 65  20 33 20 74 6f 20 73 68  | in Mode 3 to sh|
00003c00  6f 77 20 79 6f 75 20 77  68 61 74 20 69 74 20 6c  |ow you what it l|
00003c10  6f 6f 6b 73 20 6c 69 6b  65 2e 20 20 49 74 27 73  |ooks like.  It's|
00003c20  0d 73 77 69 74 63 68 69  6e 67 20 6f 66 20 74 68  |.switching of th|
00003c30  69 73 20 6b 69 6e 64 20  74 68 61 74 20 65 6e 61  |is kind that ena|
00003c40  62 6c 65 73 20 79 6f 75  20 74 6f 20 6d 69 78 20  |bles you to mix |
00003c50  73 65 76 65 72 61 6c 20  6d 6f 64 65 73 0d 6f 6e  |several modes.on|
00003c60  20 74 68 65 20 73 63 72  65 65 6e 20 61 74 20 6f  | the screen at o|
00003c70  6e 63 65 2c 20 61 73 20  69 6e 20 27 45 6c 69 74  |nce, as in 'Elit|
00003c80  65 27 2e 0d 0d 49 20 73  68 6f 75 6c 64 20 61 6c  |e'...I should al|
00003c90  73 6f 20 6d 65 6e 74 69  6f 6e 20 74 68 61 74 20  |so mention that |
00003ca0  74 68 65 72 65 20 69 73  20 61 6e 6f 74 68 65 72  |there is another|
00003cb0  20 77 61 79 20 6f 66 20  64 65 61 6c 69 6e 67 0d  | way of dealing.|
00003cc0  77 69 74 68 20 65 78 74  65 72 6e 61 6c 20 68 61  |with external ha|
00003cd0  72 64 77 61 72 65 20 62  65 73 69 64 65 73 20 6c  |rdware besides l|
00003ce0  65 74 74 69 6e 67 20 74  68 65 20 68 61 72 64 77  |etting the hardw|
00003cf0  61 72 65 0d 69 6e 74 65  72 72 75 70 74 20 74 68  |are.interrupt th|
00003d00  65 20 70 72 6f 63 65 73  73 6f 72 2e 20 20 54 68  |e processor.  Th|
00003d10  65 20 4f 53 20 63 61 6e  20 70 6f 6c 6c 20 74 68  |e OS can poll th|
00003d20  65 20 68 61 72 64 77 61  72 65 20 61 74 0d 69 6e  |e hardware at.in|
00003d30  74 65 72 76 61 6c 73 2c  20 70 72 6f 62 61 62 6c  |tervals, probabl|
00003d40  79 20 75 73 69 6e 67 20  61 6e 20 69 6e 74 65 72  |y using an inter|
00003d50  72 75 70 74 20 72 6f 75  74 69 6e 65 2e 20 20 42  |rupt routine.  B|
00003d60  79 20 70 6f 6c 6c 69 6e  67 0d 77 65 20 6d 65 61  |y polling.we mea|
00003d70  6e 20 74 68 65 20 4f 53  20 65 66 66 65 63 74 69  |n the OS effecti|
00003d80  76 65 6c 79 20 61 73 6b  73 20 66 6f 72 20 69 6e  |vely asks for in|
00003d90  66 6f 72 6d 61 74 69 6f  6e 2c 20 72 61 74 68 65  |formation, rathe|
00003da0  72 20 74 68 61 6e 0d 62  65 69 6e 67 20 74 6f 6c  |r than.being tol|
00003db0  64 20 69 74 2e 20 20 59  6f 75 20 6d 69 67 68 74  |d it.  You might|
00003dc0  20 75 73 65 20 74 68 69  73 20 6d 65 74 68 6f 64  | use this method|
00003dd0  20 74 6f 20 67 65 74 20  72 65 70 6c 69 65 73 0d  | to get replies.|
00003de0  66 72 6f 6d 20 61 20 64  65 76 69 63 65 20 63 6f  |from a device co|
00003df0  6e 6e 65 63 74 65 64 20  76 69 61 20 74 68 65 20  |nnected via the |
00003e00  52 53 34 32 33 20 66 6f  72 20 65 78 61 6d 70 6c  |RS423 for exampl|
00003e10  65 2e 0d 0d 53 6f 20 74  68 65 72 65 20 79 6f 75  |e...So there you|
00003e20  20 68 61 76 65 20 61 20  63 6f 75 70 6c 65 20 6f  | have a couple o|
00003e30  66 20 66 6f 72 61 79 73  20 69 6e 74 6f 20 69 6e  |f forays into in|
00003e40  74 65 72 72 75 70 74 73  2e 20 0d 54 68 65 79 27  |terrupts. .They'|
00003e50  72 65 20 6e 6f 74 20 70  61 72 74 69 63 75 6c 61  |re not particula|
00003e60  72 6c 79 20 66 65 61 72  73 6f 6d 65 2e 20 20 54  |rly fearsome.  T|
00003e70  68 65 20 6f 6e 6c 79 20  74 68 69 6e 67 20 74 6f  |he only thing to|
00003e80  0d 72 65 6d 65 6d 62 65  72 20 69 73 20 74 68 61  |.remember is tha|
00003e90  74 20 69 74 20 69 73 20  65 61 73 79 20 74 6f 20  |t it is easy to |
00003ea0  63 72 61 73 68 20 74 68  65 20 6d 61 63 68 69 6e  |crash the machin|
00003eb0  65 20 61 6e 64 20 73 6f  20 68 61 76 65 0d 79 6f  |e and so have.yo|
00003ec0  75 72 20 42 52 45 41 4b  20 6b 65 79 20 68 61 6e  |ur BREAK key han|
00003ed0  64 79 2e 20 20 4e 65 78  74 20 74 69 6d 65 20 77  |dy.  Next time w|
00003ee0  65 20 68 65 61 64 20 6f  66 66 20 69 6e 74 6f 20  |e head off into |
00003ef0  6d 6f 72 65 0d 6d 61 74  68 65 6d 61 74 69 63 73  |more.mathematics|
00003f00  20 61 73 20 6e 75 6d 62  65 72 73 20 77 69 74 68  | as numbers with|
00003f10  20 61 20 64 65 63 69 6d  61 6c 20 70 6f 69 6e 74  | a decimal point|
00003f20  20 61 70 70 65 61 72 2e  0d                       | appear..|
00003f29
28-03-88/T\OSB19.m0
28-03-88/T\OSB19.m1
28-03-88/T\OSB19.m2
28-03-88/T\OSB19.m4
28-03-88/T\OSB19.m5