Colourflow in issue 11 provided a great
effect for introductions to your programs but was limited as it did
not allow a branch out of the routine. Here are a couple of routines
which will give the same effect but which will allow you to exit them
when the START key is pressed. Both routines are given as BASIC DATA
statements and can be used as shown but for those who may like to know
how they work I will explain.
In the Atari there is a location $D40A
(WSYNC) which when written to halts the processor just before the next
TV line is drawn. A second location next to it $D40B (VCOUNT) counts,
in multiples of two, how many lines down the TV the line being
generated is. The Atari has 128 colours so if we wait for horizontal
synchronisation and change the colour we can have a different colour
on every line of the screen
LDA
RANDOM
STA
WSYNC
STA
COLREG
and round again
Note the hardware colour registers
should be used ($D016 to $D01A) and not the shadow registers.
This tends to look rather messy. If we
instead load the contents of VCOUNT first into WSYNC to synchronise
the screen and then into the colour register before jumping back again
half of the 128 colours will be put on the screen.
START
LDA VCOUNT ;So as VCOUNT
STA WSYNC ;INCREMENTS
STA $DO1A ;so does the
JMP START ;colour register
Now to move the colours up (or down)
the screen we need to add or subtract something that is continually
changing. Fortunately we have the real time clock ($14) which
increments every 50th of a second. Adding this to the number of VCOUNT
will make the colours appear to move up the screen.
START
LDA VCOUNT
ADC $14 ; Real time clock
STA WSYNC
STA $DO1A
JMP START
As VCOUNT counts every two lines down
the screen we could multiply the number obtained from VCOUNT by two
each time a number was put into the colour register and it would
change the colour and narrow the band as shown in program 2. The
easiest way to multiply by two in machine code is to shift everything
left. So now we have
START
LDA $D40B
ADC $14
ASL A
STA $D40A
STA $DO1A ; Border OS col. reg.
JMP START
Finally we need to load the
contents of $D01F(CONSOL) to check if the START key has been pressed.
If the value here is 6 (START key pressed) we branch to OUT (Return
from Subroutine) otherwise we jump back to the beginning of our
routine.
START
LDA$D40B
ADC $14
ASL A
STA $D4OA
STA $DO1A
LDA $DO1F
CMP #6
BEQ OUT
JMP $601
OUT RTS
You can use the BASIC programs to start
your own programs. The number 22 in line 50 can be changed to any
number between 22 and 26 to affect different colour registers. Owners
of Attack of the Mutant Camels might very well recognise the effect!
|
|
|
|
|
|
top