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

3. Sound control command


The control command is issued to the following command block area. Write the command code and required parameters (P1--P14) in the 16-byte command block. Since there are 8 command blocks, up to 8 commands can be issued at the same time.

System interface area

Sound control follows the operation procedure that the sound program responds to the "command" that instructs the operation and the "parameter" that accompanies it by writing it to the host interface (RAM area 0x25a00700 to 0x25a0077f). increase. In addition, eight virtual drivers called pronunciation control numbers can be used as playback modes to play and play each in a different dimension.
What is important here is the concept of pronunciation control numbers. Pronunciation control numbers (0 to 7) are designed to make it appear as if each of the eight playing programs is playing independently. However, in reality, there are not eight separate programs, and operations that exceed the limits of SCSP are not possible.
For example, let's play BGM with pronunciation control number 0. If you want to stop this BGM or fade it out, you can issue a command to this control number 0.
The program for each pronunciation control number can only perform one action. Sound requests always work on new ones. In other words, if you want to produce a sound effect during a performance, you must specify a program other than the control number 0 that is currently being played. Even if the number is 0, the sound effect will be uttered, but the BGM will end the performance immediately and will switch to the process of uttering the sound effect, which is the next request.
In this way, since the processing is independent, it is possible to play multiple BGMs at the same time and to utter sound effects during PCM stream playback.

The image of the host interface is as follows. Write the command number in the CMD part. This will be explained in detail from the next page. P1, P2… set the parameters. The number of parameters depends 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 ways to issue commands: "timing flag handshake" and "command code handshake". Timing flag handshake is a command issuance method that takes into consideration the order of commands written by the main system. However, the command code handshake is compatible with sound drivers Ver1.00 to Ver1.29, so normally use the timing flag handshake. This is because the command code handshake may cause trouble because 68000 may not be in time for continuous requests. This will be discussed later.
The timing flag handshake is set as follows.

Write 0x80 to 0x25A004E1 in bytes and start 68000

Issue a command using the timing flag as follows.

Main system processing (command issuance)

  1. If the timing flag (7th bit of 0x25A004E0) is "0", write as many commands as you want in the command block (up to 8 commands, and the command blocks may be used at intervals).
  2. Set the timing flag to "1".
Sound driver processing (command acquisition and execution)
  1. If the timing flag is "1", command execution is started in order from command block 1. (The command blocks are executed in order from 1 to 8, and the block whose command code is "00h" does nothing and proceeds to the next block.)
  2. The command block that has finished executing the command returns the command code to "00h".
  3. When all the processing up to command block 8 is completed, the timing flag is returned to "0".

Bit 76543210 
* ・ ・ ・ ・ ・ ・ ・ 
↑ 
| 
Timing flag 0: Id1e 
1: Command set completed
The timing flag mode cannot be restored once it has been set. Please note that the only way to get this back is to reload the sound driver. Also, especially note that Cinepak does not support timing flag mode. If you leave it in the timing flag mode, it will definitely stop at the Cinepak part. In games that use the combination of Cinepak + built-in sound source during the game, there is only a way 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 to set the timing flag, because the library function handles it automatically. In the case of SGL, it automatically enters the timing flag mode, but in the case of SBL, it does nothing.

Next, I will touch on the command code handshake.
This is a method of issuing a command by checking whether the command code (the first byte at the beginning of the command block) is "00h". The main system confirms 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 operation of checking blocks 1 to 8 in order and processing the command code if it is written.
The command code is cleared by the sound driver when the processing is completed, so if the command code is not cleared to "00h", it means that the command is still being processed or waiting to start processing. Means On the contrary, the fact that the issued command code is cleared to "00h" means that the command processing of the sound driver is completely completed. However, if the sound driver that received the request writes the next request before clearing the command code to 0 due to a mistake on the command issuing side, the newer command code may be set to 0 (). In ver-2.04, some measures are taken against 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 real-time using a control pad, most of the trouble caused by command code handshakes is sound effects. As a typical example, it seems that phenomena such as "sometimes there is no sound effect" occur. Please be careful.
When issuing a command, write all the command parameters, and then write the command code at the end. The sound driver takes over the command parameters as soon as it detects the command code, so if you write the command code first, it may be processed 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 the command, the commands may be executed in an order different from the order written by the main system. If the execution order is changed, the system may malfunction. Therefore, when executing a process that has a fixed execution order, set the command so that the order is not changed.
In this procedure, the main system and the sound driver perform processing asynchronously, so even if you follow the above precautions, the command order may change. If you need to keep the execution order, use only one command block to make sure that the previous command has been processed before issuing the next command.


Command list

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

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