AtariAge Forums: Code Snippets & Samples for bB Beginners - AtariAge Forums

Jump to content

  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

Code Snippets & Samples for bB Beginners

User is offline Mordekai Icon
Posted Sat Jul 18, 2009 7:50 PM


  • Icon
  • Combat Commando
  • PM this member
  • Posts: 9
  • Joined: 15-May 09
  • Location: So. Cal
These samples are fantastic! Thanks for making these available.

M.
0

User is offline CurtisP Icon
Posted Thu Jul 23, 2009 4:46 PM


  • Icon
  • Chopper Commander
  • PM this member
  • Posts: 200
  • Joined: 29-March 07

View PostAniman, on Tue Jun 30, 2009 10:46 AM, said:

Can anyone show me how to make a scrolling playfield?

Horizontal or Vertical Scroll?
0

User is offline Animan Icon
Posted Sat Jul 25, 2009 9:48 AM

    • Devo+2600+Dr. Pepper=AWESOME!!!


  • Icon
  • Moonsweeper
  • PM this member
  • View blog
  • Posts: 277
  • Joined: 21-April 09

View PostCurtisP, on Thu Jul 23, 2009 4:46 PM, said:

View PostAniman, on Tue Jun 30, 2009 10:46 AM, said:

Can anyone show me how to make a scrolling playfield?

Horizontal or Vertical Scroll?

Nevermind, i know how it's done.
0

User is offline disjaukifa Icon
Posted Fri Sep 18, 2009 9:56 PM

    • I'm somewhere . . . I sure of it


  • Icon
  • Dragonstomper
  • PM this member
  • Posts: 696
  • Joined: 16-September 09
  • Location: Southwest Virginia
I know this is probably going to be complicated, but I am making a Galxian/Space Invaders game called Earth Invaders, and I have my ship, I have the play field, I have the missile . . . well I don't have the missile working yet but hope to soon.

Here is what I have yet to figure out, how exactly do I make the enemys??? Also if someone could send me a link that explains frames that would be helpful!!!!

Thanks
Disjaukifa

This post has been edited by disjaukifa: Fri Sep 18, 2009 9:56 PM

0

User is offline endrien Icon
Posted Sat Oct 3, 2009 5:34 AM


  • Icon
  • Space Invader
  • PM this member
  • Posts: 15
  • Joined: 02-October 09
This might sound a fair bit "Noobish" but how can you combine these codes? Any time I try add missiles to movement it doesn't work..
0

User is offline Atarius Maximus Icon
Posted Wed Mar 10, 2010 8:22 AM

    • Load "Atari2600",8,1: SYS32777


  • Icon
  • Stargunner
  • PM this member
  • Posts: 1,029
  • Joined: 21-August 02
  • Location: St. Louis, Missouri USA

View Postendrien, on Sat Oct 3, 2009 5:34 AM, said:

This might sound a fair bit "Noobish" but how can you combine these codes? Any time I try add missiles to movement it doesn't work..


I know your post was 5 months ago, but I can work on combining a few of the samples, yes. I just posted another sample that demonstrates how to use bankswitching.

Steve
0

User is offline Atarius Maximus Icon
Posted Wed Mar 10, 2010 2:23 PM

    • Load "Atari2600",8,1: SYS32777


  • Icon
  • Stargunner
  • PM this member
  • Posts: 1,029
  • Joined: 21-August 02
  • Location: St. Louis, Missouri USA

View PostAtarius Maximus, on Wed Mar 10, 2010 8:22 AM, said:

View Postendrien, on Sat Oct 3, 2009 5:34 AM, said:

This might sound a fair bit "Noobish" but how can you combine these codes? Any time I try add missiles to movement it doesn't work..


I know your post was 5 months ago, but I can work on combining a few of the samples, yes. I just posted another sample that demonstrates how to use bankswitching.

Steve



As requested, I added another demo file (#14 in the first post) that shows how to combine a moving animated player sprite with the ability to fire in any direction, including diagonally.

Steve
0

User is offline Atarius Maximus Icon
Posted Fri Mar 12, 2010 6:01 PM

    • Load "Atari2600",8,1: SYS32777


  • Icon
  • Stargunner
  • PM this member
  • Posts: 1,029
  • Joined: 21-August 02
  • Location: St. Louis, Missouri USA
I added another sample to the first post (#15). This one demostrates collision detection for a player sprite inside of a room from all directions. It's really simple and efficient. The code was actually pulled from the old "move around rooms" demo from SeaGtGruff - it's great code and I've used it in several of my games.

Steve
0

User is offline Cliff Friedel Icon
Posted Wed Mar 17, 2010 10:43 PM


  • Icon
  • Space Invader
  • PM this member
  • Posts: 41
  • Joined: 18-February 10
Anyone happen to have an example of a sound system subroutine that can be called from a main loop? The only way I can think of doing this would be to have the sound registers, a duration, the voice it belongs to (0 or 1)and then having it do something like

subroutine
if a = 1 then read data : load sound registers for voice
if a=duration variable then turn off audv0 or audv1 : a = 0 : return
a = a + 1
return

This seems like it would work, but I figured I would ask before trying it and wasting time (and bytes). Any other ideas?

Cliff
0

User is offline Random Terrain Icon
Posted Yesterday, 4:52 PM

    • Randomness - Nonlinear - Replay Value


  • Icon
  • Visual batari Basic User
  • PM this member
  • View blog
  • View gallery
  • Posts: 16,537
  • Joined: 23-April 01
  • Location: North Carolina (USA)

View PostCliff Friedel, on Thu Mar 18, 2010 12:43 AM, said:

Anyone happen to have an example of a sound system subroutine that can be called from a main loop? The only way I can think of doing this would be to have the sound registers, a duration, the voice it belongs to (0 or 1)and then having it do something like

subroutine
if a = 1 then read data : load sound registers for voice
if a=duration variable then turn off audv0 or audv1 : a = 0 : return
a = a + 1
return

This seems like it would work, but I figured I would ask before trying it and wasting time (and bytes). Any other ideas?

Cliff

You mean like the kind of thing that the Music and Sound Editor can create? Right now it creates code using sdata, based on the Music Starter using sdata, but after the next update it will also create code that uses regular data if you want that will look like this:

   rem  *****************************************************
   rem  *
   rem  *  Music Starter using data
   rem  *
   rem  *  Based on code posted in the Ballblazer thread at AtariAge:
   rem  *  http://www.atariage.com/forums/index.php?s=&showtopic=130990&view=findpost&p=1615280
   rem  *
   rem  *  Code adapted by Duane Alan Hahn (Random Terrain)
   rem  *
   rem  *  Explanation:
   rem  *  This has a 256-byte limitation.
   rem  *
   rem  *****************************************************


   set smartbranching on


   rem  *****************************************************
   rem  *  Create aliases for variables
   rem  *****************************************************
   dim duration=a
   dim rand16=z


   rem  *****************************************************
   rem  *  Variable descriptions
   rem  *****************************************************
   rem  *  duration - how long each note plays
   rem  *  x - data counter
   rem  *  rand16 - makes better random numbers


   rem  *  Volume off
   AUDV0=0
   AUDV1=0


   rem  *  Initialize duration and data counter
   duration = 1 : x = 0




   rem  *****************************************************
   rem  *
   rem  *  Main game loop starts here.
   rem  *
   rem  *****************************************************
MainLoop

   goto GetMusic
GotMusic

   drawscreen

   goto MainLoop




   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 = musicData[x] : x = x + 1
   temp5 = musicData[x] : x = x + 1
   temp6 = musicData[x] : x = x + 1


   rem  *  Check for end of data
   if temp4=255 then duration = 1 : x = 0 : goto GotMusic


   rem  *  Play channel 0
   AUDV0 = temp4
   AUDC0 = temp5
   AUDF0 = temp6


   rem  *  Retrieve channel 1 data
   temp4 = musicData[x] : x = x + 1
   temp5 = musicData[x] : x = x + 1
   temp6 = musicData[x] : x = x + 1


   rem  *  Play channel 1
   AUDV1 = temp4
   AUDC1 = temp5
   AUDF1 = temp6


   rem  *  Set duration
   duration = musicData[x] : x = x + 1
   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


   data musicData
   8,12,29
   0,0,0
   15
   2,12,29
   0,0,0
   8
   8,12,19
   0,0,0
   15
   2,12,19
   0,0,0
   8
   8,12,17
   0,0,0
   15
   2,12,17
   0,0,0
   8

   255
end
   goto GotMusic

0

User is offline Cliff Friedel Icon
Posted Yesterday, 10:34 PM


  • Icon
  • Space Invader
  • PM this member
  • Posts: 41
  • Joined: 18-February 10

View PostRandom Terrain, on Thu Mar 18, 2010 6:52 PM, said:

View PostCliff Friedel, on Thu Mar 18, 2010 12:43 AM, said:

Anyone happen to have an example of a sound system subroutine that can be called from a main loop? The only way I can think of doing this would be to have the sound registers, a duration, the voice it belongs to (0 or 1)and then having it do something like

subroutine
if a = 1 then read data : load sound registers for voice
if a=duration variable then turn off audv0 or audv1 : a = 0 : return
a = a + 1
return

This seems like it would work, but I figured I would ask before trying it and wasting time (and bytes). Any other ideas?

Cliff

You mean like the kind of thing that the Music and Sound Editor can create? Right now it creates code using sdata, based on the Music Starter using sdata, but after the next update it will also create code that uses regular data if you want that will look like this:

   rem  *****************************************************
   rem  *
   rem  *  Music Starter using data
   rem  *
   rem  *  Based on code posted in the Ballblazer thread at AtariAge:
   rem  *  http://www.atariage.com/forums/index.php?s=&showtopic=130990&view=findpost&p=1615280
   rem  *
   rem  *  Code adapted by Duane Alan Hahn (Random Terrain)
   rem  *
   rem  *  Explanation:
   rem  *  This has a 256-byte limitation.
   rem  *
   rem  *****************************************************


   set smartbranching on


   rem  *****************************************************
   rem  *  Create aliases for variables
   rem  *****************************************************
   dim duration=a
   dim rand16=z


   rem  *****************************************************
   rem  *  Variable descriptions
   rem  *****************************************************
   rem  *  duration - how long each note plays
   rem  *  x - data counter
   rem  *  rand16 - makes better random numbers


   rem  *  Volume off
   AUDV0=0
   AUDV1=0


   rem  *  Initialize duration and data counter
   duration = 1 : x = 0




   rem  *****************************************************
   rem  *
   rem  *  Main game loop starts here.
   rem  *
   rem  *****************************************************
MainLoop

   goto GetMusic
GotMusic

   drawscreen

   goto MainLoop




   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 = musicData[x] : x = x + 1
   temp5 = musicData[x] : x = x + 1
   temp6 = musicData[x] : x = x + 1


   rem  *  Check for end of data
   if temp4=255 then duration = 1 : x = 0 : goto GotMusic


   rem  *  Play channel 0
   AUDV0 = temp4
   AUDC0 = temp5
   AUDF0 = temp6


   rem  *  Retrieve channel 1 data
   temp4 = musicData[x] : x = x + 1
   temp5 = musicData[x] : x = x + 1
   temp6 = musicData[x] : x = x + 1


   rem  *  Play channel 1
   AUDV1 = temp4
   AUDC1 = temp5
   AUDF1 = temp6


   rem  *  Set duration
   duration = musicData[x] : x = x + 1
   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


   data musicData
   8,12,29
   0,0,0
   15
   2,12,29
   0,0,0
   8
   8,12,19
   0,0,0
   15
   2,12,19
   0,0,0
   8
   8,12,17
   0,0,0
   15
   2,12,17
   0,0,0
   8

   255
end
   goto GotMusic


Thanks. This will definitely do what I want. I was hoping to maybe reduce the data size per note to 5 being v,c,f,voice,d, but I can see potential issues with syncing the voices if I do that. Better to do it the way you have.

Have you thought about posting this to the front of the thread? This is definitely something people could use. Thanks again.

Cliff
0

  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic


1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users