EasyManua.ls Logo

Commodore Plus 4 - Page 311

Commodore Plus 4
464 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Using
Interrupts
on
the
Plus/4
899
Raster
Interrupts
The
Plus/4
is
capable
of
interrupting
the
processor
in
response
to
the
vertical
position
of
the
raster
beam
on
the
TV
or
monitor.
This
capability
can
be
used,
for
example,
to
update
information
for
the
screen
display
while
it
is
not
seen,
thus
eliminating
flicker.
To
enable
raster
interrupts,
bit
1
of
the
interrupt
enable
register
($FF0A)
must
be
set
to
1.
The
low
8
bits
of
the
raster
value
at
which
the
interrupt
is
to
occur
(a
9-bit
number)
must
be
placed
in
the
raster
compare
register
($FF0B).
The
high
bit
is
the
low
bit
of
the
interrupt
enable
register
($FF0A)
and
can
be
set
to
the
appropriate
value
at
the
same
time
as
the
enabling.
The
raster
is
on
the
usable
screen
(not
the
border)
from
about
$04
through
$CB.
When
a
raster
interrupt
occurs,
bit
1
of
the
raster
interrupt
status
register
($FF09)
is
set
to
1.
Also,
bit
7
of
this
register
is
set
to
indicate
that
an
interrupt
occurred.
Example:
In
this
example
program,
raster
interrupts
are
used
to
create
a
band
of
changed
background
color
on
the
screen.
First,
an
interrupt
occurs
near
the
top
of
the
screen.
The
processing
of
this
interrupt
includes
decrementing
the
background
color
and
setting
up
the
next
interrupt.
The
second
interrupt
occurs
a
few
lines
lower.
The
processing
of
this
interrupt
includes
incrementing
the
background
color
back
to
its
original
value
and
setting
up
the
first
interrupt
again.
This
process
is
repeated
forever.
Disable
interrupts
for
set
up.
Low
byte
of
address
of
service
routine.
Store
in
low
byte
of IRQ
vector.
High
byte
of
address
of
service
routine.
Store
in
high
byte
of
IRQ
vector.
Bit
1
set to
1,
bit
0
cleared
to
0.
Enable
raster
interrupts
and
clear
high
bit
of
compare
value.
Compare
value
is
$30.
Store
in
low
bits
of
compare
value.
Start
interrupts
going.
Infinite
loop.
Get interrupt
status
register.
Clear
all
bits
that
were
set.
Get
raster
compare
value.
Compare
to
$50
(the
bottom
interrupt).
If
less
than
$50
(the
top
interrupt),
branch.
Cortpare
value
for
top
interrupt.
Store
in
compare
value.
Increment
the
screen
color.
2000
2001
2003
2006
2008
200B
200D
2010
2012
2015
2016
2019
201C
201F
2022
2024
2026
2028
202B
78
A9
8D
A9
8D
A9
8D
A9
8D
58
4C
AD
8D
AD
C9
90
A9
8D
EE
19
14
20
15
02
0A
30
0B
16
09
09
0B
50
0B
30
0B
15
03
03
FF
FF
20
FF
FF
FF
FF
FF
SEI
LDA
STA
LDA
STA
LDA
STA
LDA
STA
CLI
JMP
LDA
STA
LDA
CMP
BCC
LDA
STA
INC
#$19
$0314
#$20
$0315
#$02
$FF0A
#$30
$FF0B
$2016
$FF09
$FF09
$FF0B
#$50
$2031
#$30
$FF0B
$FF15