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

  1. u
  2.  
  3.           GRAPHICS AND MUSIC
  4.           with DotBASIC Plus
  5.            by Dave Moorman
  6.  
  7.  
  8.     We made some last minute changes
  9. in this issue, and I put some classy
  10. classic music up from Henry "Corky"
  11. Cochran. But as I listened to the
  12. William Tell Overature, I (like anyone
  13. over the age of 45) saw two images in
  14. my mind: Lark cigarettes and The Lone
  15. Ranger.
  16.  
  17.     A quick Google got me an image of
  18. the latter. I massaged it with Adobe
  19. Photo Delux and GoDotted it into the
  20. LOADSTAR .SHP format. It was midnight,
  21. but what the heck. This was clearly a
  22. job for DotBASIC Plus!
  23.  
  24.     When you get to the fifth part of
  25. the DB+ documentation, you will find
  26. that we have included bitmap graphics
  27. and Enhanced SIDPlayer capabilities.
  28. Unlike most BASIC extensions, these
  29. only occupy memory when you need them.
  30. The necessary ML code files are copied
  31. to your work disk and automatically
  32. bloaded by your program's boot
  33. program. You will need to pay some
  34. attention to memory management -- but
  35. not much.
  36.  
  37.     So here is how I put together this
  38. simple program. Note, it didn't happen
  39. all in this order. But as with BASIC,
  40. you have a convenient place to "thrash
  41. and crash" as you tweak your program
  42. to perfection.
  43.  
  44.  
  45.     I copied the music and graphics
  46. files to the work disk, then booted
  47. B.DOTBASIC from side 4 of this issue.
  48. I named the project "GRAFMUS", and in
  49. a moment, the template program was
  50. ready.
  51.  
  52.     To load and display the graphic, I
  53. would need .BMP. For the music, we
  54. have .SID. But the music file was 35
  55. blocks/pages long, too long for the
  56. normal space made available by DB+.
  57. The simple answer was to pull down the
  58. Top of BASIC to page 93 -- which would
  59. give 35 pages of room before the
  60. beginning of the graphic at page 128.
  61.  
  62.  4 POKE56,93:CLR
  63.  5 D=PEEK(186):DD=56*256:MM=16*256
  64.  
  65.     I also knew I would need the .BL
  66. command to load the music file. I also
  67. guessed I would want .PC (Print
  68. Center) and .MENU (Regular Menu) for
  69. user choice at the end.
  70.  
  71.     So I put these commands in REM
  72. statements before the REM.ENDLIST
  73. line.
  74.  
  75.  10 REM BEGIN LIST
  76.  11 REM.BMP,.SID
  77.  12 REM.BL
  78.  13 REM.PC
  79.  14 REM.MENU
  80.  20 REM.ENDLIST
  81.  
  82.     With these commands "included," I
  83. saved the file with GOTO60000, then
  84.  
  85.  LOAD"B.DEV",db (the DB+ drive)
  86.  
  87. and
  88.  
  89.  RUN
  90.  
  91. The commands and ML code is linked to
  92. the program, and the program is
  93. automatically loaded and run again.
  94.  
  95.  30 SYSDD: REM TURNS ON DB+
  96.  
  97.     I later figured out that I wanted
  98. the mouse arrow to not be available.
  99. .QS is IRQ Suspend, and turns off the
  100. mouse nicely, thanks.
  101.  
  102.  35 .QS
  103.  
  104.     On the following two lines, I just
  105. changed the background and border
  106. colors to black.
  107.  
  108.  40 .TX,1:PRINT"";:.BG,0:.BR,00
  109.  41 POKEMV+1,45
  110.  
  111.     .BMP loads a .SHP file and puts it
  112. into memory, ready to bring it to the
  113. screen. For DB+, you [must] set the
  114. parameters to 160,128,156.
  115.  
  116.  100 .BMP,"LONERANG.SHP",D,
  117.      160,128,156
  118.  
  119.     As I said, the music would need to
  120. be bloaded to page 93, which is easy
  121. to do with the .BL command.
  122.  
  123.  150 .BL,"WILL TELL 2.MUS",D,93*256
  124.  
  125. (Note how 93*256 points to the same
  126. page as the Top of BASIC. I like to
  127. think in terms of pages. It just makes
  128. life easier.)
  129.  
  130.     Then all that was needed was to
  131. turn on the screen and music.
  132.  
  133.  205 .BMPSCR,1
  134.  210 .SID,93*256
  135.  
  136.     Really, the hard work is done! Now
  137. we just have to wait around for the
  138. music to end (or someone to press a
  139. key). This is something DB+ does very
  140. well with the Do-Loop.
  141.  
  142.  300 .DO
  143.  301 .UN PEEK(198) OR PEEK(49152)=0
  144.  302 POKE198,0
  145.  303 .QR
  146.  
  147.     Note that the .UN (UNtil) waits
  148. for either a key stroke (PEEK(198)<>0)
  149. or a 0 in SIDPlayer's register at
  150. 49152. When either is true, the loop
  151. falls through. I clean things up with
  152. a 0 poked to 198, and turn the mouse
  153. arrow back on (.QR -- IRQ Restore).
  154.  
  155.     That done, all that is needed is
  156. to turn off the music and go back to
  157. the text screen.
  158.  
  159.  304 .SIDOFF
  160.  305 .BG,0
  161.  310 .BMPSCR,0
  162.  
  163.     The final touch was to add a mini-
  164. menu to the end, allowing Play Again,
  165. Return to LOADSTAR, or Drop to Basic.
  166. For this, I used the .PC command
  167. (Print Center).
  168.  
  169.  400 .PC,11,"PLAY AGAIN"
  170.  402 .PC,12,"RETURN TO LOADSTAR"
  171.  403 .PC,13,"TO BASIC"
  172.  
  173.     Figuring out where to put the menu
  174. was partly "try and see." I found that
  175. setting the upper left corner of the
  176. menu area at X=10, Y=11 was right, and
  177. a Width of 20 covered all the text on
  178. all lines. There are three items, and
  179. I used white (1) and yellow (7) for
  180. the unhighlight/highlight colors. The
  181. hotkeys are "prb".
  182.  
  183.  404 .MENU,10,11,20,3,1,7,"PRB"
  184.  405 PRINT""
  185.  
  186.     .MENU returns the item number in
  187. SL%.
  188.  
  189.  410 IFSL%=1THEN205
  190.  
  191.     So we loop back up to where the
  192. bitmap screen and music is turned on.
  193.  
  194.  420 IFSL%=2THEN:.TX,0:.OF:GOTO40000
  195.  
  196.     Set the text color to black, turn
  197. off DB+, and GOTO40000
  198.  
  199.  430 .BG,6:.BR,14:.TX,1:.OF:END
  200.  
  201.  440 POKE44,8:POKE8*256,0
  202.  450 POKE56,160:CLR:NEW
  203.  
  204.     Line 430 resets background,
  205. border, and text colors, turns off DB+
  206. and ENDs the program. I have included,
  207. in the next two lines, what is needed
  208. to return the C-64 to its default
  209. configuration -- lowering the Bottom
  210. of BASIC to page 8, lifting the Top of
  211. BASIC to page 160, doing a CLR and a
  212. NEW. Just remove the END command on
  213. line 430 to put ALL your toys away.
  214.  
  215.  40000 goto430
  216.  
  217.     Line 40000 is the beginning of the
  218. CONNECTOR routine, included on this
  219. disk in a file called CONNECTOR. Save
  220. your DB+ program with GOTO60000, then
  221. LOAD"CONNECTOR",dv and LIST. Then
  222. reLOAD the .DBS file (GRAFMUS.DBS in
  223. this case), move the cursor to the top
  224. of the screen and press <RETURN> on
  225. each line of the CONNECTOR code. This
  226. returns the user to LOADSTAR, if
  227. available, or drops though to BASIC.
  228.  
  229.  
  230.  60000 gosub60008:n$=n$+".dbs"
  231.  60001 d=peek(186):sys14339
  232.  60002 open1,d,15,"s0:"+n$:
  233.        close1:saven$,d:end
  234.  60008 n$="grafmus"
  235.  60009 return
  236.  
  237.     This last routine is the Scratch
  238. and Save routine, already in your DB+
  239. program.
  240.  
  241.     I am sure this walk-through went
  242. fairly fast. But it shows how simple
  243. DB+ makes bitmap graphics (High Res
  244. AND Multi-color). You can repeat lines
  245. 150-302 to load and present other .SHP
  246. graphics and SIDSongs. Or, you can get
  247. clever and use string arrays and a
  248. FOR-NEXT loop to move through your
  249. program.
  250.  
  251.     In other words, this is a first
  252. draft for a slide/music show. As Ricky
  253. Derocher, Tim Vlk, and others have
  254. found, back issues of LOADSTAR are
  255. full of graphics and music just
  256. waiting to become the backbone for
  257. your own work.
  258.  
  259.     So get to it!
  260.  
  261.  DMM
  262.  
  263.  
  264.