Jump to content
Sign in to follow this  
Captain Spazer

I can't figure out how to trigger musical score

Recommended Posts

I managed to compose a small victory tune, but I can't seem to trigger it correctly, I only get a buzzing noise, any thoughts?

 

techdemo.bin

 rem Generated 04-02-2019 16:06:57 by Visual bB Version 1.0.0.568

rem **********************************
rem *<filename> *
rem *<description> *
rem *<author> *
rem *<contact info> *
rem *<license> *
rem **********************************
set smartbranching on
dim duration=y
dim rand16=z
player1x = 100 : player1y = 80
missile1x = 134 : missile1y = 80
player0x = 10 : player0y = 80
ballx = 109 : bally = 79
ballheight = 2
dim _P0_Left_Right = player0x.c
dim _P0_Up_Down = player0y.d
const pfscore = 1
pfscore1 = 21
rem * Volume off
AUDV0=0
AUDV1=0
rem * Initialize duration and set up music
duration = 1
goto MusicSetup
dragonlevel
pfscorecolor = $0E
COLUPF = $DC
COLUP0 = $1C
scorecolor = $0E
if g = 0 then playfield:
................................
................................
................................
........................X.X.X...
.......................X.X.X.X..
......................X.......X.
................................
................................
XX..............................
X...............................
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
end
rem little caveman walk animation
if b = 5 then player0:
%01000000
%00100000
%00011110
%00011000
%00111110
%01000000
%00011000
%00011000
end
if b = 10 then player0:
%00000100
%00001000
%01111000
%00011110
%00011000
%01100000
%00011000
%00011000
end
rem dino idle
if a = 0 then player1:
%00011111
%00001010
%00001010
%00001010
%00001010
%00001010
%00001010
%00001100
%00001000
%00001100
%00111110
%00111010
%00001110
%00000000
%00000000
%00000000
end
rem dino eat
if a = 1 then player1:
%00011111
%00001010
%00001010
%00001010
%00001010
%10101010
%10101010
%10101100
%11111000
%10110000
%11100000
%00000000
%00000000
%00000000
%00000000
%00000000
end
rem dino looks away
if a = 2 then player1:
%00011111
%00001010
%00001010
%00001010
%00001010
%00001010
%00001010
%00001100
%00001000
%00011000
%00111110
%00101110
%00111000
%00000000
%00000000
%00000000
end
rem dizzy dino
if h = 1 then player1:
%00011111
%00001010
%00001010
%00001010
%00001010
%00001010
%00001010
%00001100
%00001000
%00011000
%00111110
%00101110
%00111000
%00000000
%00101000
%00010000
end
f = f+ 1
if f = 60 then a = (rand&3)
if f > 60 then f = 0
NUSIZ1 = $37
if b > 10 then b = 0
drawscreen
rem little caveman move
if e = 0 && k = 0 && j < 2 && joy0right then _P0_Left_Right = _P0_Left_Right + 0.50 : b = b + 1 : d = 0
if e = 0 && k = 0 && j < 2 && joy0left then _P0_Left_Right = _P0_Left_Right - 0.50 : b = b + 1 : d = 1
if d = 0 then REFP0 = 0
if d = 1 then REFP0 = 8
rem throw axe
if d = 0 && e = 0 && i = 0 && k = 0 && pfscore1 > 0 && joy0fire then e = 1 : pfscore1 = pfscore1/4
if e = 1 then missile0x = player0x : missile0y = player0y : e = 2
if e = 2 then missile0x = missile0x + 2 : missile0y = missile0y - 2
if missile0y < 20 then missile0x = 200 : missile0y = 200 : e = 0 : d = 0
if missile0x > 140 then missile0x = 200 : missile0y = 200 : e = 0 : d = 0
rem dino is stunned if hit
if collision(missile0,player1) then h = 1 : missile0x = 200 : missile0y = 200 : score = score + 30
if h = 1 then i = i + 1
if i = 60 then h = 0 : i = 0
if h = 1 then COLUP1 = rand
if h = 0 then COLUP1 = $C2
rem steal the egg
if collision(player0,ball) then j = 1
if j = 1 then ballx = player0x : bally = player0y - 4
if j = 1 && collision(ball,playfield) then j = 2
if j = 2 then goto GetMusic
GotMusic
rem dino eats player
if a = 1 && collision(player0,player1) then k = 1
if k = 1 then player0x = 119
goto dragonlevel
rem *****************************************************
rem * Music
rem *****************************************************
GetMusic
rem * Check for end of current note
duration = duration - 1
if duration>0 then GotMusic
rem * Retrieve channel 0 data
temp4 = sread(musicData)
temp5 = sread(musicData)
temp6 = sread(musicData)
rem * Check for end of data
if temp4=255 then duration = 1 : goto MusicSetup
rem * Play channel 0
AUDV0 = temp4
AUDC0 = temp5
AUDF0 = temp6
rem * Retrieve channel 1 data
temp4 = sread(musicData)
temp5 = sread(musicData)
temp6 = sread(musicData)
rem * Play channel 1
AUDV1 = temp4
AUDC1 = temp5
AUDF1 = temp6
rem * Set duration
duration = sread(musicData)
goto GotMusic
rem *****************************************************
rem * Music Data Block
rem *****************************************************
rem * Format:
rem * v,c,f (channel 0)
rem * v,c,f (channel 1)
rem * d
rem *
rem * Explanation:
rem * v - volume (0 to 15)
rem * c - control [a.k.a. tone, voice, and distortion] (0 to 15)
rem * f - frequency (0 to 31)
rem * d - duration
MusicSetup
sdata musicData = x
8,4,27
0,0,0
15
2,4,27
0,0,0
8
8,4,24
0,0,0
9
2,4,24
0,0,0
8
8,4,20
0,0,0
9
2,4,20
0,0,0
8
8,4,18
0,0,0
9
2,4,18
0,0,0
8
8,4,20
0,0,0
11
8,4,18
0,0,0
38
2,4,18
0,0,0
8
255
end
goto GotMusic
Edited by Captain Spazer

Share this post


Link to post
Share on other sites

"sdata" requires two adjacent variables. You only declare the first, but it also uses the one after it. In your case, you declared it as using "x", so it used x and y. You are also using y for your duration variable, so the pointer got corrupted. I changed it to use "w", and your tune played fine.

   sdata musicData = w

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...