home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 247
/
247.d81
/
t.sidplayer
< prev
next >
Wrap
Text File
|
2022-08-26
|
6KB
|
260 lines
u
S I D P L A Y E R P L U S
SIDPlayer by Craig Chamberlain
Plus by Dave Moorman
Adding music to a program is not
all that hard. Craig Chamberlain
created SIDPlayer way back in the
earliest days of the C-64. The code
(in a file called SID.OBJ.64) is solid
and has never failed me.
The only problem I have had is
remembering how to turn the bloody
thing ON! The BASIC code is not that
hard, just hard to remember. I often
have to fine a BASIC program where
SIDPlayer was used and dig out the
code. I have now put it on the
Encyclopedia Commodorea (on this
issue), so you (and I) can easily find
it.
But my goodness! We are in the
21st Century. We shouldn't have to
work that hard. Wouldn't it be neat to
have a SIDPlayer Starter, where all
you have to do is SYSaddr,loc?
Well, I did it -- and the code is
now a modulette in the MARM library. I
will tell you about MARM later. For
now, I have included M1.SID.ML on this
issue. And it is truly sweet!
You need to bload SID.OBJ.64 (to
page 192) and your .MUS music file, of
course. The bload M1.SID.ML to [any]
safe open memory. The module is
self-relocating, so you don't have to
worry about using ML MOVE.
In the accompanying demo, I moved
the Top of BASIC down to page 128,
then bloaded SID.OBJ.64 (to page 192),
ZUKE1.MUS (to page 128), and M1.SID.ML
(to page 140).
M1.SID.ML must be initialized with
SYS 140*256
This SYS literally finds where the
code is in memory, and creates a jump
table beginning at 832. You can see a
list of available commands with
SYS 140*256+3
Yep! The module is self-documented.
That is the beauty of MARM.
You will see
+0 GETINT: LO>.A HI>.X
+3 GETSTR: LEN>.A LO>.X HI>.Y
+6 PUTINT: .A<LO .X<HI 251/2<VAR
+9 PUTFLP: 251/2<.VAR ACCUM<VAL
+12 PUTSTR:251/2<.VAR .A<LEN .X<LO
.Y<HI
+15 TIMES40:.A<LO .A>LO .X>HI
These are ML routines to be used
by any and all modulettes included in
the package -- and not important
unless you are creating a modulette.
Then comes
+18 STSID,LOC
+21 ENDSIDONLY
+24 KILLIRQ
+27 FTSRE,PG
These are the commands available
to BASIC in this module. Note that
each includes parameters, if any. To
call the command, add the offset (+xx)
to 832.
Start SID
---------
SYS 832+18,LOC
where LOC is the location of the .MUS
music data.
In our demo, the music is at page
128, so the command to start the music
is simply
SYS832+18,128*256
And [voila!] the music starts.
End SID Only
------------
SYS 832+21
When you use STARTSID, the current
IRQ vector is tucked away in memory
(828/829) and a flag is put at 830 --
before the SID is started. When you
call this command, it checks for the
flag, the replaces the previous
vector. This will be useful if you are
using SIDPlayer with another
IRQ-driven routine (such as Mr.Mouse),
and want to stop the music without
killing the mouse.
KILLIRQ
-------
SYS 832+24
Then again, you might want to kill
the mouse, and everything being driven
by the IRQ. This will do it rather
unceremoniously. Particularly good
when the program is ended.
FTSRE
-----
SYS 832+27,PAGE
where PAGE is the page where an FTS
screen image file has been
loaded.
This is kind of a freebee. If you
are using an FTS screen image file
(created by Mr.MICK or SCRN2FONT),
this call will put it on the screen
exactly the way you designed it,
including background and border color
and text font and mode. This command
assumes that you are using the default
screen at page 4, and that your font
is at page 8.
MARM
Moorman's
---------
Adaptable Relocatable Module
--------- ----------- ------
As mentioned often on this issue,
the C-64 does not do relocatable ML
code very easily. So, of course, my
challenge was to make a module system
where the code could be loaded to any
open memory location and used
immediately.
We [can] write relocatable code in
ML. The only restriction is that the
coder must remember that the routine
might be anywhere in memory.
Therefore, we cannot use any JMP, JSR,
Load, or Store to locations within the
routine. These are all absolute
addresses.
But we can use relative branches
and indirect addressing. And it is
quite permissable to JMP or JSR to
addresses outside the routine -- such
as a JSR to the SIDPlayer.
I wanted to use relocatable code
to allow a programmer -- even a BASIC
programmer -- to build a module
containing only those command routines
that would benefit the particular
project at hand. The idea was to have
a MARM Maker that would allow the
programmer to custom build a module.
That is the Adaptable part of the
name.
And, since each such module would
have its own commands, it needed a way
to display which commands are
available and their places on the jump
table. That is the Self-Documenting
feature.
The trick was to get the resulting
module to figure out for itself where
it was in memory, and create the jump
table in a nice, fairly safe place. I
chose the cassette buffer, beginning
at 832 for the table.
To ascertain the module's
location, the initialization code puts
an RTS (96) at a Zero Page address,
the does a JSR to that address. The
processor stack holds the location
from which the JSR jumped -- and can
be found and massaged to find the
beginning address of the module. From
that, the jump table is created.
[I] think it is clever. For the
Self-Documenting feature, the writer
of the modulette must use a particular
protocol:
BEGIN
CLC
BCC CODE
BYTE"NAME,P,A,R,A,M,S",0
CODE
The PRINT DOC routine finds the
documentation (jump address + 3) and
prints until the 0 is encountered.
You can get a print-out with:
OPEN4,4,7:CMD4:SYSaddr+3
PRINT#4:CLOSE4
All you really have to remember is
to SYS the load address, then SYS
addr+3 (to see the documentation --
not necessary in your program). All
the commands are at 832+offset.
You can get MARModule, with Maker
and a full list of modulettes and
protocol documentation at
http://c64.eloadstar.com/ssocc/
DMM