EasyManua.ls Logo

Commodore Plus 4 - Page 370

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...
358
Using
Peripheral
Devices
Programming
the
Serial
Bus
Occasionally
it
is
desirable
to
program
directly
to
the
serial
bus.
The
family of
operating
subroutines
used
for
this
purpose
consists
of
LISTN
($FFB1),
SECND
($FF93),
CIOUT
(SFFA8),
UNLSN
($FFAE),
TALK
($FFB4),
TKSA
($FF96),
ACPTR
($FFA5),
and
UNTLK
(SFFAB).
Programming
at
this
level
eliminates
the
file
structure
used
with
OPEN
and
CLOSE.
Instead
of
thinking
in
terms
of
logical
file
numbers,
think
in
terms
of
the
channels
of
the
disk
drive.
A
channel
may
be
opened
and
told
to
send
data
to
the
computer
(to
talk)
or
to
receive
data
from
the
computer
(to
listen).
The
error
checking
must
be
done
using
the
status
variable
for
device
not
present,
end-of-file,
and
such,
and
by
reading
the
error
channel.
When
these
operations
are
done
depends
to
a
large
extent
on
what
assumptions
the
particular
application
allows.
When
in
doubt,
check
for
an
error.
Opening
a
File
Here
is
an
outline
of
a
procedure:
1.
Set
the
status
variable
($90)
to
zero.
2.
Load
.A
with
the
device
number
of
the
disk
drive
(and
store
in
the
current
device
number
at
$AE
if
this
has
not
already
been
done).
Call
LISTN
($FFB1).
Check
for
a
device
not
present
error
in
the
status
variable.
3.
Load
.A
with
the
disk
drive
channel
number
you
want
to
use
ORed
with
$F0
(to
indicate
open
up
this
channel).
Call
SECND
($FF93).
4.
Send
the
file
name
(if
any)
through
.A
to
the
drive
using
CIOUT
($FFA8).
5.
Call
UNLSN
($FFAE).
The
channel
specified
is
now
opened
to
the
file
specified.
Getting
Data
from
an
Open
Channel
1.
Load
.A
with
the
device
number
of
the disk
drive
and
call
TALK
($FFB4).
2.
Load
.A
with
the
channel
number
ORed
with
$60
(to
tell
the
drive
this
is
a
secondary
address).
Call
TKSA
($FF96).
3.
Call
ACPTR
($FFA5)
to
receive
bytes
in
.A.
When
bit
6
of
the
status
variable
is
set,
the
end-of-file
has
been
reached.
4.
Call
UNTLK
(SFFAB).
Sending
Data
to
an
Open
Channel
1.
Load
.A
with
the
device
number
of
the
disk
drive
and
call
LISTN
(SFFB1).
2.
Load
.A
with
the
channel
number
ORed
with
$60
(to
tell
the
drive
this
is
a
secondary
address).
Call
SECND
($FF93).