Jump to content
  • entry
    1
  • comments
    0
  • views
    2,147

Let there be sound


TheHoboInYourRoom

529 views

It's fair to say I've neglected this blog. But now I'm using it, so that's cool. You probably shouldn't expect updates to be regular.

I'm finally taking the first steps in writing an actual game for the VCS, and I'm doing it from the inside out, more or less. Making sure the individual effects and modules work, and that I thoroughly understand them, before integrating them.
This first module is rather generic and could be used in any number of games: a sound driver and its associated data format. It's pretty simple, with only three message types: sound updates, sustain times, and end-of-sound. Sound updates are 3 bytes that map directly to the AUDx registers. The sustain and end-of-sound messages are control messages, and I set the high bit to mark them. End-of-sound is $FF, so that leaves the other 127 values for sustain times of 0-126 frames. A zero-frame sustain sounds a little weird, but only one message per channel is processed per frame, which means every message has an inherent length of one frame, so a zero-sustain just leads to a sound fragment that lasts for two frames. I'll also write a macro for making the sustain messages more readable. End-of-sound sets everything to zero. But really I'm just repeating the comments I wrote in the source code. The driver will be elaborated on eventually; I plan to reserve a special sound effect ID that will cause the driver to bypass normal processing, in order to allow for randomly generated music and effects. By the way, if you read the source code, I apologize for the cycle-count spaghetti. I just had to make utterly sure the code would run within the VSYNC period in all cases. It so happens I have plenty of time left over, and the code so far is only about half a page long, so there's room to expand in both dimensions.

For the actual numbering of sound effects, I already have a format worked out:

[7][6][5][4][3][2][1][0]\____/\_/\_____________/  |    |        |  |    |        \-> In-page sound ID  |    |  |    \-> Sound-already-playing flag  |  \-> Page number


I don't seriously expect to need a full kilobyte of sound data. I may not even need more than a couple pages, but it's better to have too many possible addresses than to run out. And I'm fairly certain almost every sound effect will be longer than four or five bytes (including end-of-sound), so the limit of 32 sounds per page is a reasonable tradeoff. The already-playing flag will only exist in RAM, after a sound ID has already been loaded, to avoid needlessly setting the sound data pointers on every frame. Regardless, I haven't used it yet, so this format is subject to change as I figure out the logistics of interpreting it. Actual sound design should come first.

In the meantime, have a noise burst and a bwoop sound, in the attached binary. :P Press fire on the left joystick for the noise and push the stick to the right for the bwoop.
Comments and critique welcome. Cheers!

0 Comments


Recommended Comments

There are no comments to display.

Guest
Add a comment...

×   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...