Jump to content
IGNORED

Nibble Based Sound Engine Demo


Gemintronic

Recommended Posts

So, I've resorted to using nibbles in my upcoming 4 player game.  The sound engine uses a nibble for sound type and another nibble for duration.  That means 16 sounds at various lengths for only one 8-bit variable!  No gosubs or functions as I'm unsure how much more overhead nibbles take.

 

Use FIRE to play back current sound.  LEFT or RIGHT to change sound and play it.

 

Usual disclaimer:  My code sucks.  Very much open to feedback.  I hope it gives people a feel for what a nibble based sound effect engine can look like.

 

 

sounds6.bas sounds6.bin

  • Like 4
Link to comment
Share on other sites

8 hours ago, Karl G said:

That does sound like a potential KevKelley title! :D

You got me listening to my dishwasher and loading it thinking how I can make a game out of it! I have to show some constraint and work on my other projects first! But this nibble thing might be what I was looking for. One thing I keep putting off is sound and I hate the idea of wasting full variables for sounds. That is why many of my games end up tying the AUDF0, C0, V0 to things like coordinates or pixel heights or whatever.

  • Like 2
Link to comment
Share on other sites

My biggest regret is not finding a good Atari Adventure Dragon roar.  I even tried perusing the Adventure source and couldn't figure out how to implement it.

 

If anyone has a clue what settings to use I'd greatly appreciate the help.  Here is the current "roar" code:
 

sound13
 rem Roar I Guess
 AUDV0 = 3 : AUDC0 = 8 : AUDF0 =  temp2
 goto after_sound_event 

 

Link to comment
Share on other sites

3 hours ago, Gemintronic said:

My biggest regret is not finding a good Atari Adventure Dragon roar.  I even tried perusing the Adventure source and couldn't figure out how to implement it.

 

If anyone has a clue what settings to use I'd greatly appreciate the help.  Here is the current "roar" code:
 


sound13
 rem Roar I Guess
 AUDV0 = 3 : AUDC0 = 8 : AUDF0 =  temp2
 goto after_sound_event 

 

Are you trying to copy the sound from adventure or just make a good road based on that?

Link to comment
Share on other sites

1 hour ago, KevKelley said:

Are you trying to copy the sound from adventure or just make a good roar based on that?

I'm not ashamed to admit I wanted it as close as possible.  But, now it's on my bucket list to understand the Adventure sound engine.  I'll keep studying 6502 assembly until it makes sense :)

 

I found something more akin to a roar like this:

sound13
 rem Roar
 AUDV0 = temp2&7 : AUDC0 = counter&2 : AUDF0 =  temp2&27
 goto after_sound_event

 

Link to comment
Share on other sites

12 minutes ago, Gemintronic said:

I'm not ashamed to admit I wanted it as close as possible.  But, now it's on my bucket list to understand the Adventure sound engine.  I'll keep studying 6502 assembly until it makes sense :)

 

I found something more akin to a roar like this:


sound13
 rem Roar
 AUDV0 = temp2&7 : AUDC0 = counter&2 : AUDF0 =  temp2&27
 goto after_sound_event

 

Just curious.  What is "temp2&7" ?  What does the "&7" part do? 

Link to comment
Share on other sites

8 minutes ago, KevKelley said:

Just curious.  What is "temp2&7" ?  What does the "&7" part do? 

 

My uninformed impression is that it's functionally the same as modulus.  So, if you want to limit the results to 0-7 then you'd go variable&7

 

temp2 is storing the duration nibble when inside the sound engine code.  It's also being slowed down by a quarter.  So, I'm using it as a less rapidly changing factor in producing sounds (compared to the counter variable)

  • Like 1
Link to comment
Share on other sites

2 hours ago, KevKelley said:

Just curious.  What is "temp2&7" ?  What does the "&7" part do? 

 

bitwise operation

 

  • & = AND
  • | = OR
  • ^ = EXCLUSE OR

These are operations that occur at the bit level.
 

AND

    0 1
  + - -
0 | 0 0
1 | 0 1


OR

    0 1
  + - -
0 | 0 1
1 | 1 1


EXCLUSIVE OR

    0 1
  + - -
0 | 0 1
1 | 1 0

 

For AND both bits must be 1 to return a 1, else return 0.

 

For OR at least 1 bit must be 1 to return a 1, else return 0.


For EXCLUSIVE OR only 1 bit must be 1 to return a 1, else return 0.

 

The operation is done at the bit level, so it's easiest to understand if you look at the values in binary.

 

7 in binary is %00000111

 

if temp2 where 158 then in binary it would be %10011110

 

AND
 76543210 bit location
%00000111
%10011110
---------
%00000110

 

So basically temp2&7 will return the value of the last 3 bits in temp2. In the example only bits 1 and bits 2 are both 1, so they're the only ones that are still on when doing a bitwise and operation.

 

temp2|7 would be OR:

OR
 76543210 bit location
%00000111
%10011110
---------
%10011111

 

temp2^7 would be EXCLUSIVE OR:

EXCLUSIVE OR
 76543210 bit location
%00000111
%10011110
---------
%10011001

 

  • Thanks 2
Link to comment
Share on other sites

Thanks @SpiceWare

 

I have had limited use in some bitwise operations so I wasn't familiar with seeing it like that with the temp variables. In Crossdock I used an ^ to turn the bay doors on or off but I think that might have been the extent of my use of these operations. 

  • Like 1
Link to comment
Share on other sites

Adventure generates sounds procedurally rather than using sound data. I used many of the Adventure sound effects in "Space Peril" for the 7800, but generated from sound data instead. Some of these I got from @RevEng's TIA SFX collection, and some I converted into sound data myself. Here's the dragon roar/bite sound:

 

  $1F,$03,$0F
  $1F,$08,$0E 
  $1F,$03,$0D 
  $1F,$08,$0C 
  $1F,$03,$0B 
  $1F,$08,$0A 
  $1F,$03,$09 
  $1F,$08,$08 
  $1F,$03,$07 
  $1F,$08,$06 
  $1F,$03,$05 
  $1F,$08,$04 
  $1F,$03,$03 
  $1F,$08,$02 
  $1F,$03,$01 

The data here is in the format: Frequency, Channel, Volume

 

Also, each chunk of data is held for 3 frames, so if the sound code doesn't support that, then you will need to triple all of the lines.

  • Thanks 1
Link to comment
Share on other sites

That. was. AMAZING!  Thank you for explaining the & operand SpiceWare and Karl G for showing the roar data.

 

I was able to get a pretty good approximation by doing this:

 

sound13
 rem Roar Karl G version
 if counter{0} then AUDV0 = temp2 : AUDC0 = 3 : AUDF0 =  31 else AUDV0 = temp2 : AUDC0 = 8 : AUDF0 =  31
 goto after_sound_event

 

  • Like 3
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...