Jump to content
IGNORED

batari Basic sound help


STGraves

Recommended Posts

Hello I've been creating a simple game for the atari 2600, and I want to add background music, I've done it and I have the code, but i cannot get it to play when i wnat it, what can i do?

 rem **********************************
 rem *<STGraves world>               *
 rem *<Mata a cuernotrayamon  *
 rem *antes que el a ti.>                      *
 rem *<agpkkck@gmail.com>           *
 rem *<www.stgravesof.zz.vc>             *
 rem **********************************




 rem Create the title screen
opening

 playfield:
 .XX.XXX.XX..XXX...XX..X.X.XXX.XX
 X....X.X....X..X.X..X.X.X.X..X..
 .X...X.X.XX.XXX..XXXX.X.X.XX..X.
 ..X..X.X..X.X.X..X..X.X.X.X....X
 XX...X..XX..X..X.X..X..X..XXX.XX
 ................................
 ....X...X.XXXX.XXX..X...XXX.....
 ....X...X.X..X.X..X.X...X..X....
 ....X...X.X..X.XX...X...X..X....
 ....X.X.X.X..X.X.X..X...X..X....
 ....XX.XX.XXXX.X..X.XXX.XXX.....
end



 rem Loop the screen until the spacebar is pressed
title
 COLUBK = $00
 COLUPF = $0E
 drawscreen
 if joy0fire || joy1fire then goto skiptitle
 goto title

 rem This function displays after the title is skipped
skiptitle

 rem Colors
 COLUPF = $40
 COLUBK = $C0
 COLUP0 = 222
 COLUP1 = $40

 rem Player location
 player0x = 50 : player0y = 50
 player1x = 20 : player1y = 20

 rem Score setting and color
 score = 0 : scorecolor = $F8

 rem Missle size and location
 missile1height=6:missile1y=255
 NUSIZ0 = 25

 rem Create a variable to keep up with lives
 a = 5

 rem Create the playfield



 playfield:
 ..XX..XX..XX..XX..XX..XX..XX..XX
 XX..XX..XX..XX..XX..XX..XX..XX..
 ..XX..XX..XX..XX..XX..XX..XX..XX
 XX..XX..XX..XX..XX..XX..XX..XX..
 ..XX..XX..XX..XX..XX..XX..XX..XX
 XX..XX..XX..XX..XX..XX..XX..XX..
 ..XX..XX..XX..XX..XX..XX..XX..XX
 XX..XX..XX..XX..XX..XX..XX..XX..
 ..XX..XX..XX..XX..XX..XX..XX..XX
 XX..XX..XX..XX..XX..XX..XX..XX..
 ..XX..XX..XX..XX..XX..XX..XX..XX
end





 rem This main function is what loops constantly
main

 rem This is the animation function
animate
 rem This frame variable slows down the animation
 v = v + 1 
 
 rem This code animates the sprites
 if v = 7 && w = 0 then ax
 if v = 7 && w = 1 then bx
 if v = 7 && w = 2 then cx
 if v = 7 && w = 3 then dx

 goto nextstep
 
 rem These four sprites are different stages of the animation
ax
 v = 0
 w = 1

 player1:
 %00011000
 %01111110
 %01111110
 %01111110
 %00100100
 %11000011
 %01000010
 %11000011
end


 goto nextstep
 
bx
 v = 0
 w = 2

 player1:
 %00011000
 %01111110
 %01111110
 %01111110
 %00100100
 %11000011
 %01000010
 %11000011
end



 goto nextstep

cx
 v = 0
 w = 3

 player1:
 %00011000
 %01111110
 %01011010
 %01111110
 %00100100
 %11000011
 %01000010
 %11000011
end

 goto nextstep
 
dx
 v = 0
 w = 0
 player1:
 %00011000
 %01111110
 %01011010
 %01111110
 %00100100
 %11000011
 %01000010
 %11000011
end

 goto nextstep

 rem Create acorn sprite
nextstep



 player0:
 %01111110
 %01000010
 %01011010
 %11000010
 %01100111
 %11111110
 %01010101
 %10010010
end


 rem check to see if a missile has already been fired
checkfire
 if missile1y>100 then goto skip
 missile1y = missile1y - 2 : goto draw

 rem if a missile hasn't been fired, then fire missile
skip
 if joy0fire then missile1y=player0y-2:missile1x=player0x+4

 rem Draw output to screen
draw
 drawscreen

 rem Fix player wraparound bug
 if player0x < 8 then player0x = 8
 if player0x > 150 then player0x = 150
 if player0y < 8 then player0y = 8
 if player0y > 84 then player0y = 84

 rem Have player 1 chase player 2
 if player1y < player0y then player1y = player1y + 1
 if player1y > player0y then player1y = player1y - 1
 if player1x < player0x then player1x = player1x + 1
 if player1x > player0x then player1x = player1x - 1
 player1x = player1x : player1y = player1y


 rem Detect missile collision with squirrel
 if collision(missile1,player1) then score=score+1:player1x=rand/2:player1y=0:missile1y=255:goto pointsound
 rem Detect squirrel collision with the acorn
 if collision(player0,player1) then score=score-1:player1x=rand/2:player1y=0:missile1y=255:a=a-1:goto deadsound


 rem joystick movements
 if joy0up then player0y = player0y-1 : goto skipmove
 if joy0down then player0y = player0y+1 : goto skipmove
 if joy0left then player0x = player0x-1 : goto skipmove
 if joy0right then player0x = player0x +1 : goto skipmove

 rem refresh the screen
skipmove
 goto main

 rem Play point sound
pointsound
 AUDV0 = 5 : AUDC0 = 8 : AUDF0 = 10
 p = p + 1
 drawscreen
 if p < 2 then pointsound
 p = 0
 AUDV0 = 0 : AUDC0 = 0 : AUDF0 = 0
 goto main

 rem Play dead sound
deadsound
 AUDV1 = 8
 AUDC1 = 6
 AUDF1 = 12
 p = p + 1
 drawscreen
 if p < 5 then deadsound
 p = 0
 AUDV1 = 0 : AUDC1 = 0 : AUDF1 = 0
 if a = 0 then goto deadscreen
 goto main




 rem Create the dead screen
deadscreen


 playfield:
 .................X..............
 ................XXX.............
 .................X..............
 .........XXXXXXXXXXXXXXXXX......
 ........XX...............XX.....
 ........XX.X.X..XX..X..X.XX.....
 ........XX.X.X.X..X.X..X.XX.....
 ........XX..X..X..X.X..X.XX.....
 ........XX..X...XX...XX..XX.....
 ........XX...............XX.....
 ........XX...............XX.....
end




 rem Loop the screen until the spacebar is pressed
dead
 COLUBK = $40
 COLUPF = $9A
 drawscreen
 if joy0down || joy1down then goto opening
 goto dead

 rem Create deadscreen sound
deadssound

dim musicPointer=a
 dim musicTimer=b
 dim beatPointer=c
 dim beatTimer=d
 dim tempaudv=t

 rem VOLUME DOWN AND SET CHANNELS
 AUDV0=0
 AUDC0=10
 AUDV1=0
 AUDC1=8

 rem INITIALIZE POINTERS AND TIMERS
 musicPointer=$FF
 musicTimer=0
 beatPointer=$FF
 beatTimer=0

startLoop

 rem TIME TO UPDATE NOTE?
 if musicTimer = 0 then gosub changeMusicNote
 musicTimer = musicTimer - 1

 if beatTimer = 0 then gosub changeBeatNote
 beatTimer = beatTimer - 1


 drawscreen
 goto startLoop

changeMusicNote
  musicPointer = musicPointer + 1
  AUDF0 = musicData[musicPointer]

  tempaudv = 8
  if musicData[musicPointer] = $FF then tempaudv = 0
  AUDV0 = tempaudv

  musicPointer = musicPointer + 1
  musicTimer = musicData[musicPointer]
  rem value is (2 * #_OF_NOTES) - 1
  if musicPointer > 31 then musicPointer = #-1

 return

changeBeatNote
  beatPointer = beatPointer + 1
  AUDF1 = beatData[beatPointer]

  tempaudv = 8
  if beatData[beatPointer] = $FF then tempaudv = 0
  AUDV1 = tempaudv

  beatPointer = beatPointer + 1
  beatTimer = beatData[beatPointer]
  rem value is (2 * #_OF_NOTES) - 1
  if beatPointer > 23 then beatPointer = #-1

 return

 data musicData
  18,26,-1,10,18,20,-1,40,15,26,-1,10,15,20,-1,40
  16,26,-1,10,16,20,-1,40,17,26,-1,10,17,20,-1,40
end

 data beatData
  120,2,-1,22,40,2,-1,10,120,2,-1,22,120,2,-1,10,40,2,-1,4,120,2,-1,16
end
Link to comment
Share on other sites

There are a lot of little things wrong with that program. You might want to look over the whole thing, step by step. For example, you never jump to startLoop, so the code in that section never runs. The code there should be in the main loop anyway, without an extra drawscreen. You also don't seem to set AUDC0 and AUDC1 for that section, so you're not going to hear much of anything, even if the code runs.

 

You might want to put your DIMs near the beginning of the program so they can be found more easily and make sure that they are all indented.

Link to comment
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.
Note: Your post will require moderator approval before it will be visible.

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...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...