EasyManua.ls Logo

Commodore Plus 4 - Page 389

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...
The
Printer
377
Using
a
Printer
from
Machine
Language
All
of
the
printer
commands
and
the
functions
they
perform
in
BASIC
are
the
same
for
machine
language.
Again,
the
manual
relating
to
the
specific
printer
in
use
should be
referred
to
for the
interpretation
of
secondary
addresses
and
control
codes.
The
function
of
the
BASIC
commands
described
previously
to
open
and
send
data
to
printer
files
can
be
accomplished
in
machine
code
by
using
the
appropriate
operating
system
subroutines.
In
general
terms,
you
can
choose
one
of
two
levels
of
communication
when
you
use
the
printer.
The
higher
level
allows
the
maintenance
of
multiple
open
files
similar to
using
OPEN
commands
in
BASIC.
At
the
lower
level,
it
is
possible
to
send
data
to
the
printer
directly
through
the
serial
bus
subroutines.
Both
of
these
levels
are
explored
and
example
programs
are
given
in
this
section.
The
complete
descriptions
of
the
operating
system
subroutines
used
can
be
found
in
Chapter
5.
Using
the
File
Structure
This
section
outlines
the
machine-language
equiva
lents
for
the
BASIC
statements
OPEN,
CLOSE,
and
PRINT#.
They
can
be
used
for
all
the
purposes
outlined
in
the
preceding
BASIC
sections.
The
key
subrou
tines
are
OPEN
($FFC0),
CLOSE
($FFC3),
CHOUT
($FFC9),
CLRCH
($FFCC),
and
BSOUT
($FFD2).
Any
messages
printed
to
the
screen
during
these
operations
are
controlled
by
the
message
flag
set
with
SETMSG
($FF90).
Open
The
OPEN
subroutine
performs
the
same
function
for
the
printer
in
machine
code
as
the
OPEN
command
does
in
BASIC.
A
secondary
address
may
be
sent
to
control
printer
functions.
The
following
outlines
the
operations
required:
1.
Load
.A
with
the
logical
file
number
to
use
for
the
file,
.X
with
the
device
number
of
the
printer,
and
.Y
with
the
secondary
address.
Call
SETLFS
(SFFBA).
2.
Load
.A
with
$00
(the
length
of
the
file
name).
Call
SETNAM
($FFBD).
3.
Call
OPEN
($FFC0).
4.
Check
for errors
by examining
the
carry
bit
and
status
byte.
Close
Files
can
be
closed
individually
by
using
the
CLOSE
($FFC3)
routine:
1.
Load
.A
with
the
logical
file
number
of
the
file
to
be
closed.
Call
CLOSE
($FFC3).