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

3. Sound control command


Control commands are issued to the command block area below. Write the command code and required parameters (P1--P14) in the 16-byte command block. There are 8 command blocks, so up to 8 commands can be issued at the same time.

System interface area

Sound control follows an operating procedure in which the sound program responds by writing "commands" that instruct operations and "parameters" as necessary information accompanying them to the host interface (RAM areas 0x25a00700 to 0x25a0077f). Masu. In addition, eight virtual drivers called pronunciation management numbers are used as playback formats, allowing each to be played and played in a different dimension.
The important thing here is the concept of pronunciation management number. The pronunciation control numbers (0 to 7) are designed to make it appear as if a program that performs eight pieces is playing each piece independently. However, in reality, there are not eight separate programs, and operations that exceed the limits of SCSP are not possible.
For example, play BGM with pronunciation control number 0. If you want to stop this BGM or fade it out, all you have to do is issue a command to this management number 0.
The program for each pronunciation control number can only execute one operation. Sound requests always trigger new actions. In other words, if you want to emit a sound effect while playing, you must specify a program with a management number other than 0 that is currently being played. Even with number 0, the sound effect will be emitted, but the BGM will immediately stop playing and switch to the next request, which is to emit the sound effect.
In this way, since the processing is independent, it is possible to play multiple BGMs at the same time or to emit sound effects while playing a PCM stream.

The host interface roughly looks like the image below. Write the command number in the CMD part. This will be explained in detail on the next page. P1,P2…set parameters. The number of parameters varies depending on the command. There are also commands that do not require parameters.

address CMD P1 P2 P3 P4 P5 P6 P7 P8 P9 P10 P11
0X0700
0X0710
0X0720
0X0730
0X0740
0X0750
0X0760
0X0770
*The second byte is not used.

There are two methods for issuing commands: "timing flag handshake" and "command code handshake." Timing flag handshake is a method of issuing commands that ensures that the order of commands written by the main system is reproduced. However, the command code handshake is for compatibility with sound drivers Ver1.00 to Ver1.29, so normally use the timing flag handshake. This is because if the command code handshake is used, 68000 may not be able to keep up with continuous requests, which may cause trouble. More on this later.
Set the timing flag handshake as follows:

Write 0x80 as a byte to 0x25A004E1 and start 68000

Issuing a command using timing flags is as follows.

Main system processing (issuing commands)

  1. If the timing flag (7th bit of 0x25A004E0) is "0", write as many commands as you want to issue into the command block (up to 8 commands, command blocks may be used at intervals).
  2. Set the timing flag to "1".
Sound driver processing (picking up and executing commands)
  1. If the timing flag is "1", commands will start executing in order from command block 1. (Command blocks are executed in order from 1 to 8, and blocks with command code "00h" do nothing and proceed to the next block)
  2. The command block that completes command execution returns the command code to "00h".
  3. When all processing up to command block 8 is completed, return the timing flag to "0".

Bit 76543210 
*・・・・・・・・・ 
↑ 
| 
Timing flag 0:Id1e 
1: Command set completed
Once the timing flag mode is set, it cannot be undone. Please note that if you want to restore this, the only way is to reload the sound driver. Also note that Cinepac specifically does not support timing flag mode. If you leave it in timing flag mode, it will definitely stop at the cine pack part. For games that use a combination of Cinepack + built-in sound source during the game, the only way to do this is to forcibly lower the timing flag bit or not use the timing flag mode.
If you are using a software library, there is no function provided to set timing flags because the library functions handle this automatically internally. In the case of SGL, it automatically enters timing flag mode, but in the case of SBL it does nothing.

Next, I will also touch on the command code handshake.
This method checks whether the command code (first byte of the command block) is "00h" and issues the command. The main system checks that the command code is "00h" and issues commands in the order from block 1 to block 8. Similarly, the sound driver simply repeats the process of checking blocks 1 to 8 in order, and if a command code is written, processing that command.
The command code is cleared by the sound driver when processing is completed, so if the command code is not cleared to "00h" yet, it means that the command is still being processed or is waiting for processing to start. means. Conversely, if the issued command code is cleared to "00h", it means that the sound driver's command processing has completed completely. However, due to a mistake on the command issuing side, if the next request is written before the sound driver that received the request clears the command code to 0, there is a possibility that the newer command code will be set to 0 ( Ver-2.04 has taken some measures to prevent this phenomenon, but since there is a considerable speed difference between SH2 and 68000, it cannot be completely prevented.)
Due to the nature of the game being a real-time game using a control pad, most of the problems caused by command code handshakes are due to sound effects. A typical phenomenon that often occurs is ``Sometimes the sound effects don't come out.'' Please be careful.
When issuing a command, write all command parameters and then write the command code last. The sound driver takes command parameters as soon as it detects a command code, so if you write a command code for the first time, processing may be performed with unexpected command parameters.
The sound driver checks blocks 1 to 8 in order, so if you simply search for an empty block and set a command, the commands may be executed in a different order than the order in which they were written by the main system. If the execution order is swapped, the system may malfunction, so if you are executing a process that has a fixed execution order, set the commands so that the order will not be swapped.
In this procedure, the main system and sound driver process asynchronously, so even if you follow the above precautions, the order of commands may be swapped. If you need to preserve the order of execution, you can avoid this by using only one command block and making sure that the previous command has been processed before issuing the next command.


Command list

01H SEQUENCE START Start playing music and sound effects
02H SEQUENCE STOP Stop playing songs and sound effects
03H PAUSE Pausing songs and sound effects
04H PAUSE OFF Unpause songs and sound effects
05H SEQUENCE VOLUME Adjust volume or fade in/out
06H STOP ALL Stop all playing
07H TEMPO CHANGE Changing the tempo of songs and sound effects
08H MAP CHANGE Perform a map change
09H DIRECT MIDI CONTROL Send MIDI events as commands
0AH START VOLUME ANALYZER Start input level analysis of Digital Audio In
0BH STOP VOLUME ANALYZER Digital Audio In input level analysis completed
0CH DSP STOP Stopping and initializing DSP
0DH ALL NOTE OFF All pronunciation stopped
0EH SEQUENCE PAN Control PANPOT from the game
10H SOUND INITIALIZE Initialize the sound driver
11H YAMAHA 3D CONTROL YAMAHA 3D sound controls
12H QSOUND CONTROL Qsound control
13H YAMAHA 3D INITIALIZE YAMAHA 3D,Qsound localization initialization
14H TEMPO MODE Setting the tempo mode
15H TEMPO RATIO Setting relative tempo values
80H CD-DA LEVEL Adjust CD-DA level
81H CD-DA PAN CD-DA output Panpot settings
82H TOTAL VOLUME Setting the total volume
83H EFFECT CHANGE Switching effects
85H START PCM STREAM PCM stream playback starts
86H STOP PCM STREAM PCM stream playback stop
87H MIXER CHANGE Mixer switching
88H MIXER PARAMETER CHANGE Switching mixer parameters
89H HARDWARE CHECK Check the hardware
8AH PCM PARAMETER CHANGE Parameter switching for the PCM stream being played
8BH PCM SLOT ALLOCATION Reserve a slot for PCM stream
8CH PCM SLOT RELEASE Free up slots for PCM streams

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