EasyManua.ls Logo

Commodore Plus 4 - Page 333

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...
Interfacing
with
BASIC
381
Adding
a
BASIC
Wedge
Example:
BASIC
retrieves
each
character
from
RAM
by
calling
a
routine
referred
to
as
CHRGET,
which
is
located
at
$0473.
Because
this
is
in
RAM
(initialized
on
power
up),
it
can
be
altered
to
recognize
and
process
symbols
as
desired
by
the
programmer.
It
is
possible
to
add
BASIC
commands
in
this
way.
This
example
shows
one
way
to
add
a
direct-mode-only
command
to
BASIC.
The
command
is
the
English
pound
symbol
(£),
and
it
increments
the
border
color.
The
first
step
is
to
enter
the
machine-language
wedge
through
the
machine-
language
monitor.
2000
48
2001
A5
9A
S003
10
OB
S005
68
2006
C9
5C
PHA
LDA
$9A
BPL
$2010
PLA
CMP
#$5C
.
2008
DO
07
BNE
$2011
200A
EE
19
PP
IKrC
$FP19
200D
4C
73
04
JMP
$0473
2010
68
PIA
2011
8D
3E
PP
STA
$PP3E
2014
4C
84
04
JMP
$0484
Save
the
character
on
the
stack.
Look
at
the
message
flag.
If
positive,
then
this
is
not
direct
mode
so
leave.
Get
the
character.
Compare
with
the
English
pound
symbol.
Not
one,
so
leave.
Increment
the
border
color.
Go
to
get
the
next
character.
Get
the
character.
Back
to
ROM.
Go
back
to
the
operating
system
routine.
After
the
wedge
code
is
in
place,
change
the
statement
at
$0481
from
STA
$FF3E
to
JMP
$2000.
Then
exit
to
BASIC.
When
in
direct
mode,
you
can
input
the
English
pound
symbol
to
increment
the
border
color.
Everything
else
works
normally.
Relocating
BASIC
RAM
BASIC
keeps
track
of
the
RAM
it
is
permitted
to
use
in
a
series
of
pointers,
$2B-$38.
Some
care
must
be
taken
when
you
change
these
pointers.
The
main
reason
for
moving
BASIC
is
to
reserve
some
of
the
RAM
usually
used
by
BASIC
for
a
machine-language
routine.
Moving
the
top
of
BASIC
down
is
the
easiest
way
to
restrict
the
RAM
available
to
BASIC.
This
can
be
done
with
the
following
sequence
of
commands: