SOUND ManualSound Driver Programmer's Guide
BackForward
Sound Driver Programmer's Guide

4. Specific method of sound request


To start the sound driver, basically just transfer the sound driver to the sound memory and release the reset signal. However, the contents of the memory when the power is turned on are not guaranteed, so initialization such as zero clear is required.
Follow steps 1 to 6 below to start the sound driver. This will launch the sound driver and start running from the beginning of the program. For details on hardware such as SCSP and reset, refer to the SCSP and SMPC user's manuals.

Startup procedure

order Processing content explanation
1 Stop 68000
(Reset the sound CPU)
Execute "Sound OFF" of the software library "SMPC Interface Library".
2 Initialize SCSP registers Write 02h as a byte at address 25B00400 of the SH address.
(DAC18B = 0, MEM4MB = 1 is set)
3 Clear the system area to zero Clear all zeros from address 25A00000 to address 25A0AFFF of the SH address.
Four Transfer the sound program to sound memory Transfer the sound program (SDDRVS.TSK) from address 25A00000 of the SH address.
Five Transfer the sound area map to sound memory Transfer the sound area map from address 25A0A000 of the SH address.
6 Start 68000
(Release the sound CPU reset)
Execute "Sound ON" of the software library "SMPC Interface Library".

remarks)
The maximum size of the sound area map is 0x1000 bytes, so if the size is larger than this, please divide it into multiple sound area maps. However, in that case, replace the sound area map before changing the map (explained in the section on how to play sound) if necessary.

Even if you know the details of the request command, you often do not know how to actually issue the command. The general request procedure is shown here, but it is recommended that you decide on the request command buffer allocation before doing so. The command buffer allocations recommended by SEGA are as follows (regardless of the order, the roles are divided).

0x25A00700 Dedicated to important commands such as sound initials and map changes
0x25A00710 Pose on / off only
0x25A00720 Dedicated to on / off PCM stream playback
0x25A00730 For CD-DA control only
0x25A00740 Normal sound effect volume request only
0x25A00750 Normal sound effect performance on / off request only
0x25A00760 BGM volume request only
0x25A00770 BGM performance on / off request only

This isn't always a good idea, but at least it's highly recommended that sound effects and other requests be buffer-distinguished. This is because most of the troubles related to sound requests are sound effects. This is due to the fact that the number of sound effect requests is extremely large compared to others, and that there are many cases where it is unpredictable because it is a real-time request by the control pad. Distinguishing this also saves you time in debugging, as well as not to affect other requests.

Now, I will explain the request procedure from the start of the game.

  1. After loading the sound program, set bit 7 of 0x25A004E1 to enable the timing flag.

  2. Start 68000.

  3. Perform sound initialization.

    +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 + A + B
    0x0700 Ten - 01 01 01 01 01 01 01 01 01 01 - - - - -

    Write the above and set the timing flag.

  4. Load map data and sound data from address 0x25A0A000 and after, and set the transferred flag.

  5. Make a map change.

    +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 + A + B
    0x0700 08 08 - nn - - - - - - - - -

    Write the above and set the timing flag.

  6. Change the effect (if you don't use DSP, you don't need to).

    +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 + A + B
    0x0700 83 - nn - - - - - - - - -

    Write the above and set the timing flag.

  7. Make a mixer change.

    +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 + A + B
    0x0700 87 - nn nn - - - - - - - -

    Write the above and set the timing flag.

    Once you have completed the above, you will be able to request songs and sound effects. Next, let's request the song with song number 2 in bank 1 with pronunciation control number 3. In this example, it is assumed that the sound creator does not specify the volume.

    +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 + A + B
    0x0760 05 05 - 03 03 80 00 - - - - - - -
    0x0770 01 01 - 03 03 01 01 02 02 00 - - - - - -

    Write the above and set the timing flag.

    In this way, there is no mistake in issuing to the same INT as a set with the sequence volume command. Now, let's request the sound effect of song number 3 in bank 2 with pronunciation control number 7. Since the song produces sound effects without stopping, the song and sound effect pronunciation control numbers must be different.

    +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 + A + B
    0x0740 05 05 - 04 80 00 - - - - - - -
    0x0750 01 01 - 04 02 02 03 03 00 - - - - - -

    Write the above and set the timing flag.

    Next, stop the song currently being played with pronunciation control number 3. Specify 0 for the end mode.

    +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 + A + B
    0x0770 02 02 - 03 03 00 - - - - - - - -

    Write the above and set the timing flag.

    You can stop playing with this one shot. Looking at the command reference, there are other commands that seem to stop the sound, but this is the only command that stops playing. Now let's fade out and finish the song. Let's set the speed of fading out to 0x0A. Most games are about this.

    +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 + A + B
    0x0760 05 05 - 03 03 00 0A - - - - - - -

    Write the above and set the timing flag. Usually, you can't wait until the song fades out completely, so issue a performance end command at an appropriate place.

    +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 + A + B
    0x0770 02 02 - 03 03 00 - - - - - - - -

    Write the above and set the timing flag.

    I've just finished the song, but after that, I'd like to replace the sound data by overlay processing. In this case, just in case (because a sequence such as a sound effect may be playing at another pronunciation control number), stop all sequences.

    +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 + A + B
    0x0700 06 06 - - - - - - - - - - -

    Write the above, set the timing flag, wait for the timing flag to turn off, return to the beginning, issue sound initials, load data, issue map change, issue effect change, issue mixer change.

In rare cases, it seems that there is a case where SH2 builds a program that temporarily absorbs the request issued by the main side, regards the request command buffer as a ring buffer every 0x10 bytes, and writes it in the order in which it was issued. This is very dangerous in some games and should never be done. Please divide the roles of the command buffer!


BackForward
SOUND ManualSound Driver Programmer's Guide
Copyright SEGA ENTERPRISES, LTD., 1997