home *** CD-ROM | disk | FTP | other *** search
- u
-
- GRAPHICS AND MUSIC
- with DotBASIC Plus
- by Dave Moorman
-
-
- We made some last minute changes
- in this issue, and I put some classy
- classic music up from Henry "Corky"
- Cochran. But as I listened to the
- William Tell Overature, I (like anyone
- over the age of 45) saw two images in
- my mind: Lark cigarettes and The Lone
- Ranger.
-
- A quick Google got me an image of
- the latter. I massaged it with Adobe
- Photo Delux and GoDotted it into the
- LOADSTAR .SHP format. It was midnight,
- but what the heck. This was clearly a
- job for DotBASIC Plus!
-
- When you get to the fifth part of
- the DB+ documentation, you will find
- that we have included bitmap graphics
- and Enhanced SIDPlayer capabilities.
- Unlike most BASIC extensions, these
- only occupy memory when you need them.
- The necessary ML code files are copied
- to your work disk and automatically
- bloaded by your program's boot
- program. You will need to pay some
- attention to memory management -- but
- not much.
-
- So here is how I put together this
- simple program. Note, it didn't happen
- all in this order. But as with BASIC,
- you have a convenient place to "thrash
- and crash" as you tweak your program
- to perfection.
-
-
- I copied the music and graphics
- files to the work disk, then booted
- B.DOTBASIC from side 4 of this issue.
- I named the project "GRAFMUS", and in
- a moment, the template program was
- ready.
-
- To load and display the graphic, I
- would need .BMP. For the music, we
- have .SID. But the music file was 35
- blocks/pages long, too long for the
- normal space made available by DB+.
- The simple answer was to pull down the
- Top of BASIC to page 93 -- which would
- give 35 pages of room before the
- beginning of the graphic at page 128.
-
- 4 POKE56,93:CLR
- 5 D=PEEK(186):DD=56*256:MM=16*256
-
- I also knew I would need the .BL
- command to load the music file. I also
- guessed I would want .PC (Print
- Center) and .MENU (Regular Menu) for
- user choice at the end.
-
- So I put these commands in REM
- statements before the REM.ENDLIST
- line.
-
- 10 REM BEGIN LIST
- 11 REM.BMP,.SID
- 12 REM.BL
- 13 REM.PC
- 14 REM.MENU
- 20 REM.ENDLIST
-
- With these commands "included," I
- saved the file with GOTO60000, then
-
- LOAD"B.DEV",db (the DB+ drive)
-
- and
-
- RUN
-
- The commands and ML code is linked to
- the program, and the program is
- automatically loaded and run again.
-
- 30 SYSDD: REM TURNS ON DB+
-
- I later figured out that I wanted
- the mouse arrow to not be available.
- .QS is IRQ Suspend, and turns off the
- mouse nicely, thanks.
-
- 35 .QS
-
- On the following two lines, I just
- changed the background and border
- colors to black.
-
- 40 .TX,1:PRINT"";:.BG,0:.BR,00
- 41 POKEMV+1,45
-
- .BMP loads a .SHP file and puts it
- into memory, ready to bring it to the
- screen. For DB+, you [must] set the
- parameters to 160,128,156.
-
- 100 .BMP,"LONERANG.SHP",D,
- 160,128,156
-
- As I said, the music would need to
- be bloaded to page 93, which is easy
- to do with the .BL command.
-
- 150 .BL,"WILL TELL 2.MUS",D,93*256
-
- (Note how 93*256 points to the same
- page as the Top of BASIC. I like to
- think in terms of pages. It just makes
- life easier.)
-
- Then all that was needed was to
- turn on the screen and music.
-
- 205 .BMPSCR,1
- 210 .SID,93*256
-
- Really, the hard work is done! Now
- we just have to wait around for the
- music to end (or someone to press a
- key). This is something DB+ does very
- well with the Do-Loop.
-
- 300 .DO
- 301 .UN PEEK(198) OR PEEK(49152)=0
- 302 POKE198,0
- 303 .QR
-
- Note that the .UN (UNtil) waits
- for either a key stroke (PEEK(198)<>0)
- or a 0 in SIDPlayer's register at
- 49152. When either is true, the loop
- falls through. I clean things up with
- a 0 poked to 198, and turn the mouse
- arrow back on (.QR -- IRQ Restore).
-
- That done, all that is needed is
- to turn off the music and go back to
- the text screen.
-
- 304 .SIDOFF
- 305 .BG,0
- 310 .BMPSCR,0
-
- The final touch was to add a mini-
- menu to the end, allowing Play Again,
- Return to LOADSTAR, or Drop to Basic.
- For this, I used the .PC command
- (Print Center).
-
- 400 .PC,11,"PLAY AGAIN"
- 402 .PC,12,"RETURN TO LOADSTAR"
- 403 .PC,13,"TO BASIC"
-
- Figuring out where to put the menu
- was partly "try and see." I found that
- setting the upper left corner of the
- menu area at X=10, Y=11 was right, and
- a Width of 20 covered all the text on
- all lines. There are three items, and
- I used white (1) and yellow (7) for
- the unhighlight/highlight colors. The
- hotkeys are "prb".
-
- 404 .MENU,10,11,20,3,1,7,"PRB"
- 405 PRINT""
-
- .MENU returns the item number in
- SL%.
-
- 410 IFSL%=1THEN205
-
- So we loop back up to where the
- bitmap screen and music is turned on.
-
- 420 IFSL%=2THEN:.TX,0:.OF:GOTO40000
-
- Set the text color to black, turn
- off DB+, and GOTO40000
-
- 430 .BG,6:.BR,14:.TX,1:.OF:END
-
- 440 POKE44,8:POKE8*256,0
- 450 POKE56,160:CLR:NEW
-
- Line 430 resets background,
- border, and text colors, turns off DB+
- and ENDs the program. I have included,
- in the next two lines, what is needed
- to return the C-64 to its default
- configuration -- lowering the Bottom
- of BASIC to page 8, lifting the Top of
- BASIC to page 160, doing a CLR and a
- NEW. Just remove the END command on
- line 430 to put ALL your toys away.
-
- 40000 goto430
-
- Line 40000 is the beginning of the
- CONNECTOR routine, included on this
- disk in a file called CONNECTOR. Save
- your DB+ program with GOTO60000, then
- LOAD"CONNECTOR",dv and LIST. Then
- reLOAD the .DBS file (GRAFMUS.DBS in
- this case), move the cursor to the top
- of the screen and press <RETURN> on
- each line of the CONNECTOR code. This
- returns the user to LOADSTAR, if
- available, or drops though to BASIC.
-
-
- 60000 gosub60008:n$=n$+".dbs"
- 60001 d=peek(186):sys14339
- 60002 open1,d,15,"s0:"+n$:
- close1:saven$,d:end
- 60008 n$="grafmus"
- 60009 return
-
- This last routine is the Scratch
- and Save routine, already in your DB+
- program.
-
- I am sure this walk-through went
- fairly fast. But it shows how simple
- DB+ makes bitmap graphics (High Res
- AND Multi-color). You can repeat lines
- 150-302 to load and present other .SHP
- graphics and SIDSongs. Or, you can get
- clever and use string arrays and a
- FOR-NEXT loop to move through your
- program.
-
- In other words, this is a first
- draft for a slide/music show. As Ricky
- Derocher, Tim Vlk, and others have
- found, back issues of LOADSTAR are
- full of graphics and music just
- waiting to become the backbone for
- your own work.
-
- So get to it!
-
- DMM
-
-
-