home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 247 / 247.d81 / t.sidplayer < prev    next >
Text File  |  2022-08-26  |  6KB  |  260 lines

  1. u
  2.      S I D P L A Y E R   P L U S
  3.  
  4.     SIDPlayer by Craig Chamberlain
  5.          Plus by Dave Moorman
  6.  
  7.  
  8.     Adding music to a program is not
  9. all that hard. Craig Chamberlain
  10. created SIDPlayer way back in the
  11. earliest days of the C-64. The code
  12. (in a file called SID.OBJ.64) is solid
  13. and has never failed me.
  14.  
  15.     The only problem I have had is
  16. remembering how to turn the bloody
  17. thing ON! The BASIC code is not that
  18. hard, just hard to remember. I often
  19. have to fine a BASIC program where
  20. SIDPlayer was used and dig out the
  21. code. I have now put it on the
  22. Encyclopedia Commodorea (on this
  23. issue), so you (and I) can easily find
  24. it.
  25.  
  26.     But my goodness! We are in the
  27. 21st Century. We shouldn't have to
  28. work that hard. Wouldn't it be neat to
  29. have a SIDPlayer Starter, where all
  30. you have to do is SYSaddr,loc?
  31.  
  32.     Well, I did it -- and the code is
  33. now a modulette in the MARM library. I
  34. will tell you about MARM later. For
  35. now, I have included M1.SID.ML on this
  36. issue. And it is truly sweet!
  37.  
  38.     You need to bload SID.OBJ.64 (to
  39. page 192) and your .MUS music file, of
  40. course. The bload M1.SID.ML to [any]
  41. safe open memory. The module is
  42. self-relocating, so you don't have to
  43. worry about using ML MOVE.
  44.  
  45.     In the accompanying demo, I moved
  46. the Top of BASIC down to page 128,
  47. then bloaded SID.OBJ.64 (to page 192),
  48. ZUKE1.MUS (to page 128), and M1.SID.ML
  49. (to page 140).
  50.  
  51.     M1.SID.ML must be initialized with
  52.  
  53.         SYS 140*256
  54.  
  55. This SYS literally finds where the
  56. code is in memory, and creates a jump
  57. table beginning at 832. You can see a
  58. list of available commands with
  59.  
  60.         SYS 140*256+3
  61.  
  62. Yep! The module is self-documented.
  63. That is the beauty of MARM.
  64.  
  65.     You will see
  66.  
  67.  +0 GETINT: LO>.A HI>.X
  68.  +3 GETSTR: LEN>.A LO>.X HI>.Y
  69.  +6 PUTINT: .A<LO .X<HI 251/2<VAR
  70.  +9 PUTFLP: 251/2<.VAR ACCUM<VAL
  71.  +12 PUTSTR:251/2<.VAR .A<LEN .X<LO
  72.         .Y<HI
  73.  +15 TIMES40:.A<LO .A>LO .X>HI
  74.  
  75.     These are ML routines to be used
  76. by any and all modulettes included in
  77. the package -- and not important
  78. unless you are creating a modulette.
  79. Then comes
  80.  
  81.  +18 STSID,LOC
  82.  +21 ENDSIDONLY
  83.  +24 KILLIRQ
  84.  +27 FTSRE,PG
  85.  
  86.     These are the commands available
  87. to BASIC in this module. Note that
  88. each includes parameters, if any. To
  89. call the command, add the offset (+xx)
  90. to 832.
  91.  
  92.  
  93.  Start SID
  94.  ---------
  95.  
  96.     SYS 832+18,LOC
  97.  
  98.  where LOC is the location of the .MUS
  99.     music data.
  100.  
  101.     In our demo, the music is at page
  102. 128, so the command to start the music
  103. is simply
  104.  
  105.         SYS832+18,128*256
  106.  
  107. And [voila!] the music starts.
  108.  
  109.  
  110.  End SID Only
  111.  ------------
  112.  
  113.     SYS 832+21
  114.  
  115.     When you use STARTSID, the current
  116. IRQ vector is tucked away in memory
  117. (828/829) and a flag is put at 830 --
  118. before the SID is started. When you
  119. call this command, it checks for the
  120. flag, the replaces the previous
  121. vector. This will be useful if you are
  122. using SIDPlayer with another
  123. IRQ-driven routine (such as Mr.Mouse),
  124. and want to stop the music without
  125. killing the mouse.
  126.  
  127.  
  128.  KILLIRQ
  129.  -------
  130.  
  131.     SYS 832+24
  132.  
  133.     Then again, you might want to kill
  134. the mouse, and everything being driven
  135. by the IRQ. This will do it rather
  136. unceremoniously. Particularly good
  137. when the program is ended.
  138.  
  139.  
  140.  FTSRE
  141.  -----
  142.  
  143.     SYS 832+27,PAGE
  144.  
  145.  where PAGE is the page where an FTS
  146.        screen image file has been
  147.        loaded.
  148.  
  149.     This is kind of a freebee. If you
  150. are using an FTS screen image file
  151. (created by Mr.MICK or SCRN2FONT),
  152. this call will put it on the screen
  153. exactly the way you designed it,
  154. including background and border color
  155. and text font and mode. This command
  156. assumes that you are using the default
  157. screen at page 4, and that your font
  158. is at page 8.
  159.  
  160.  
  161.                  MARM
  162.  
  163.               Moorman's
  164.               ---------
  165.      Adaptable Relocatable Module
  166.      --------- ----------- ------
  167.  
  168.     As mentioned often on this issue,
  169. the C-64 does not do relocatable ML
  170. code very easily. So, of course, my
  171. challenge was to make a module system
  172. where the code could be loaded to any
  173. open memory location and used
  174. immediately.
  175.  
  176.     We [can] write relocatable code in
  177. ML. The only restriction is that the
  178. coder must remember that the routine
  179. might be anywhere in memory.
  180. Therefore, we cannot use any JMP, JSR,
  181. Load, or Store to locations within the
  182. routine. These are all absolute
  183. addresses.
  184.  
  185.     But we can use relative branches
  186. and indirect addressing. And it is
  187. quite permissable to JMP or JSR to
  188. addresses outside the routine -- such
  189. as a JSR to the SIDPlayer.
  190.  
  191.     I wanted to use relocatable code
  192. to allow a programmer -- even a BASIC
  193. programmer -- to build a module
  194. containing only those command routines
  195. that would benefit the particular
  196. project at hand. The idea was to have
  197. a MARM Maker that would allow the
  198. programmer to custom build a module.
  199. That is the Adaptable part of the
  200. name.
  201.  
  202.     And, since each such module would
  203. have its own commands, it needed a way
  204. to display which commands are
  205. available and their places on the jump
  206. table. That is the Self-Documenting
  207. feature.
  208.  
  209.     The trick was to get the resulting
  210. module to figure out for itself where
  211. it was in memory, and create the jump
  212. table in a nice, fairly safe place. I
  213. chose the cassette buffer, beginning
  214. at 832 for the table.
  215.  
  216.     To ascertain the module's
  217. location, the initialization code puts
  218. an RTS (96) at a Zero Page address,
  219. the does a JSR to that address. The
  220. processor stack holds the location
  221. from which the JSR jumped -- and can
  222. be found and massaged to find the
  223. beginning address of the module. From
  224. that, the jump table is created.
  225.  
  226.     [I] think it is clever. For the
  227. Self-Documenting feature, the writer
  228. of the modulette must use a particular
  229. protocol:
  230.  
  231.     BEGIN
  232.         CLC
  233.         BCC CODE
  234.         BYTE"NAME,P,A,R,A,M,S",0
  235.     CODE
  236.  
  237. The PRINT DOC routine finds the
  238. documentation (jump address + 3) and
  239. prints until the 0 is encountered.
  240.  
  241.     You can get a print-out with:
  242.  
  243.        OPEN4,4,7:CMD4:SYSaddr+3
  244.        PRINT#4:CLOSE4
  245.  
  246.     All you really have to remember is
  247. to SYS the load address, then SYS
  248. addr+3 (to see the documentation --
  249. not necessary in your program). All
  250. the commands are at 832+offset.
  251.  
  252.     You can get MARModule, with Maker
  253. and a full list of modulettes and
  254. protocol documentation at
  255.  
  256.  http://c64.eloadstar.com/ssocc/
  257.  
  258.  DMM
  259.  
  260.  
  261.