resonance 1.0.1
Loading...
Searching...
No Matches
midi_main.h File Reference
#include <stdint.h>
#include <vector>
#include <libsdr.h>
#include <sifrpc.h>
#include "os/hxstr.h"
#include "synth/callbackxferbdtoiop.h"
Include dependency graph for midi_main.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  SoundDriverCommand
 Command block the sound driver reads a bank transfer out of. More...
struct  BankSlot
 One loaded bank's claim on a region of sound memory. More...

Functions

void SynthCommand (int nCommand)
 Voice and sound-bank driver that Ps2HardSynth is a thin class over.
int ezMidiInit ()
 Bind gCd to the sound driver's RPC server.
int SubmitSoundDriverRequest (int nSelector, uintptr_t nArgument)
 Submit one command to the sound driver.
int ezTransToIOP (int nIopAddress, const void *pSource, int nLength)
 Move a buffer from main memory into the sound driver's memory on the IOP.
void RegisterBankSlot (int nTag, int nDest, int nIopAddress)
 Record that a bank claims a region of sound memory, releasing whatever claimed it before.
void ReleaseBankSlotAt (int nDest)
 Release the bank claiming a region of sound memory.
void ReleaseAllBankSlots ()
 Release every bank and empty g_bankSlots.
int IsBankXferBusy ()
 Report whether a bank transfer is still moving.
void LoadSoundBank (const char *pszBdPath, const char *pszHdPath, int nTag, int nPlacement)
 Load a BD and HD bank pair and record the claim.
char * FourCcToString (const void *pFourCc)
 Copy a four-character code into a buffer it can be printed from.
int XferBankFromMemory (const void *pData, int nLength)
 Move a bank that is already in memory to the IOP and report it complete.
int StartBdBankXfer (const char *pszPath)
 Start a chunked BD bank transfer and report the bank's size.
int StartHdBankXfer (const char *pszPath, int nPlacement)
 Start an HD bank transfer.
void SetBankLoadProgressHook (void(*pfnProgress)())
 Install the bank-load progress hook.
void DumpSynthVoices (int bActiveOnly)
 Report the state of both SPU2 cores and all 48 voices to the log.
void InitSpu2Cores ()
 Bind libsdr and bring both SPU2 cores up.
void ConfigureSpu2Effects (int bEnable)
 Apply the configured reverb to both SPU2 cores.
void InitSynthDriver ()
 Bring the voice and bank driver up.
void PollSynthStream ()
 Advance the streaming voice buffers.
void SetSynthStreamBar (int nBar)
 Move the streamed audio to the start of a bar.
void PollSynthEvents ()
 Advance the driver's pending events.
void WaitForBankTransfers ()
 Wait until no bank transfer is outstanding.
void ReleaseSoundBanks ()
 Release every loaded bank.
void SendMidiToDriver (unsigned char nStatus, unsigned char nData1, unsigned char nData2)
 Move one MIDI message to the sound driver.
void SubmitDriverSetMono (int bMono)
 Switch the sound driver between mono and stereo output.
void SubmitDriverSetRemix (int bRemix)
 Switch the remix mode of the sound driver.
void SubmitDriverSetPaused (int bPaused)
 Pause or resume the sound driver.
void SubmitDriverAllNotesOff ()
 Silence every channel of the sound driver.
void ps2_InitMSin ()
 Bind the MIDI stream input of Sony's component sound library.
void StartSoundBankMovie (const char *pszPath)
 Open the sound-bank movie and start feeding its chunks to the driver.
void StopSoundBankMovie ()
 Destroy the sound-bank movie, if one is open, and clear the pointer.
void ShutdownSynthDriver ()
 Take the voice and bank driver down.

Variables

sceSifClientData gCd
 Client of the game's sound driver on the IOP, bound by ezMidiInit().
constexpr int kSoundDriverCommandPayloadSize = 0x6c
 Bytes of payload a command block has above its five-word header.
SoundDriverCommand g_chunkCommand
 Block that describes one chunk of a sound bank, submitted under selector 0x1070.
constexpr int kIopStagingBufferCount = 2
 Staging buffers on the IOP that chunk transfers alternate between.
int g_anIopStagingAddress [kIopStagingBufferCount]
 Addresses of the staging buffers on the IOP.
int g_nIopStagingIndex
 Staging buffer the next chunk transfer will use.
int g_nBankIopAddress
 Address on the IOP a sound bank is moved to.
std::vector< BankSlot > g_bankSlots
 Every bank currently claiming sound memory.
constexpr int kBankBufferAlignment = 0x40
 Boundary both bank read buffers are rounded up to.
CallbackXferBdToIop * g_pBdXfer
 Transfer currently streaming a BD bank, or null.
HxStr g_bdBankName
 Path of the BD bank currently loaded.
HxStr g_hdBankName
 Path of the HD bank currently loaded.
constexpr int kBankFixedDestAddress = 0x5010
 Destination in sound memory a placement of 0 or 1 selects.
constexpr int kBankPlacementFirstBuffer = 2
 Placement that selects the first destination buffer.
constexpr int kBankPlacementRotate = 3
 Placement that rotates through the destination buffers and the IOP addresses.
constexpr int kHdBankPathSize = 0x80
 Bytes of g_szHdBankPath.
constexpr int kBankDestBufferCount = 2
 Destination buffers the rotating placement alternates between.
int g_anBankDestAddress [kBankDestBufferCount]
 Destinations in sound memory a bank pair may go to.
int g_nBankDestIndex
 Destination buffer the next rotating placement will use.
constexpr int kBankIopAddressCount = 3
 Addresses on the IOP a bank may go to.
int g_anBankIopAddress [kBankIopAddressCount]
 Addresses on the IOP a bank may go to.
int g_nBankIopIndex
 Entry of g_anBankIopAddress the next rotating placement will use.
char g_szHdBankPath []
 Path of the HD bank, copied in by StartHdBankXfer().
int g_nBankDestAddress
 Address in sound memory a bank is written to.
int g_nSynthXferTag
 Word every command block is stamped with at +0x10.
void(* g_pfnBankLoadProgress )()
 Called once after every chunk is submitted and once when a bank transfer finishes.
int g_nHdXferInFlight
 Non-zero while an HD bank transfer occupies the shared command block.
SoundDriverCommand g_bankCommand
 Block that describes a whole bank, submitted under selector 0x1050 when the last chunk lands.
void * g_pHdXferBuffer
 Buffer the HD bank transfer read into, released once the transfer reports.
void * g_pBdXferBuffer
 Buffer the BD bank transfer reads into, released once the last chunk has been moved.

Function Documentation

◆ SynthCommand()

void SynthCommand ( int nCommand)

Voice and sound-bank driver that Ps2HardSynth is a thin class over.

Named after midi_main.cpp, the string at 0x0081cc98 that the module bills its heap releases to. The module spans 0x00461a88 through 0x00465200, the zone allocator ending just below it, and has the attested behaviour of the sound subsystem: the SPU2 voices, the sound banks, and the script-facing command dispatcher. Neither Synth nor Ps2HardSynth has any of it.

There is no voice table. Every routine here that reports or configures a voice queries the SPU2 itself through libsdr's remote-call trampoline, sceSdRemote(), with the rSd* function code and the SD_* entry encoding inline at the call site. The image has no sceSd* wrapper function, so the SDK release of this era supplied the whole API as macros over that one entry point. Correspondence is exact at both levels: the function codes are rSdInit, rSdSetParam, rSdGetParam, rSdGetSwitch, rSdSetAddr, rSdGetAddr, rSdSetCoreAttr, rSdGetCoreAttr and rSdSetEffectAttr, and the entries carry libsd's 0x80 core-level flag on exactly the core-level registers.

The two bank transfers are classes rather than routines. CallbackXferBdToIop streams a BD bank in 0x2000-byte chunks and CallbackXferHdToIop moves an HD bank in one go, and both derive from AsyncCallback. The globals below are what the two share with the rest of the module. Run one script-facing synth command.

Three command numbers are recognised. Command 0 does nothing. Command 1 reports the voices through DumpSynthVoices(). Command 2 submits driver selector 0xd0 with no command block. Anything else reports Unrecognized synth cmd d, and the command number is retained in its second argument register from entry so that the report can print it.

The script layer exposes this as synth_cmd, which is the one attested title in the module.

Parameters
nCommandThe command to run.
Ghidra address:
NTSC-U/C: 0x00464ad0
Ghidra address:
PAL: 0x004a2490

◆ ezMidiInit()

int ezMidiInit ( )

Bind gCd to the sound driver's RPC server.

Initialises the SIF RPC layer, then binds server 0x12346 until the server reports ready, spinning 9999 iterations between attempts. A failed bind reports error: sceSifBindRpc and hangs. The server is the game's own IOP driver rather than libsdr's. InitSynthDriver() is the one caller.

Returns
Always 1. The caller discards it.
Ghidra address:
NTSC-U/C: 0x005f9638
Ghidra address:
PAL: 0x0063a348

◆ SubmitSoundDriverRequest()

int SubmitSoundDriverRequest ( int nSelector,
uintptr_t nArgument )

Submit one command to the sound driver.

Every routine in the module funnels through this, twenty call sites in all, each passing a selector word and either a command block or nothing. Observed selectors are 0xd0 from SynthCommand() and from the tail of DumpSynthVoices(), 0x1070 and 0x1050 from a bank transfer, 0x10e0 from ConfigureSpu2Effects(), 0x8010 from InitSynthDriver(), and 0x8130 from 0x004642c8.

Two bits of the selector steer the send. Bit 0x1000 ships a whole 0x80-byte SoundDriverCommand from the caller's argument, read as an address; without it the argument travels as the single word of a 0x10-byte request, read as a value. Bit 0x8000 skips the busy flag and sends a different mode. On entry the routine spins until the previous request has been collected.

The title comes from what the twenty call sites have in common rather than from any one of them.

Parameters
nSelectorThe command selector.
nArgumentOne machine word whose meaning the selector decides. A selector with bit 0x1000 set takes the address of a SoundDriverCommand, 0x8130 takes a bank's tag, and 0xd0 takes nothing and is passed zero. The parameter is a word rather than a pointer because only half its callers pass one.
Returns
The first word of the reply buffer at 0x008e5b80. InitSynthDriver() retains the reply to 0x8010 as the event-buffer address, and the other callers discard it.
Ghidra address:
NTSC-U/C: 0x005f96c8
Ghidra address:
PAL: 0x0063a3d8

◆ ezTransToIOP()

int ezTransToIOP ( int nIopAddress,
const void * pSource,
int nLength )

Move a buffer from main memory into the sound driver's memory on the IOP.

Fills the descriptor at 0x008e5be8 with the three arguments and a zero fourth word, then issues the transfer and spins until it reports completion.

Parameters
nIopAddressThe destination on the IOP.
pSourceThe source in main memory.
nLengthThe number of bytes to move.
Returns
Zero once the transfer has completed, or -1 when it could not be started.
Ghidra address:
NTSC-U/C: 0x005f97d0
Ghidra address:
PAL: 0x0063a4e0

◆ RegisterBankSlot()

void RegisterBankSlot ( int nTag,
int nDest,
int nIopAddress )

Record that a bank claims a region of sound memory, releasing whatever claimed it before.

A slot whose mDest matches takes the new tag, and its previous tag is submitted under selector 0x8130 first when it claimed anything. A slot already using the new tag under a different destination is released. A destination with no slot is appended.

Parameters
nTagThe bank's tag.
nDestThe region in sound memory.
nIopAddressWhere the bank lives on the IOP.
Ghidra address:
NTSC-U/C: 0x00461a88
Ghidra address:
PAL: 0x0049f148

◆ ReleaseBankSlotAt()

void ReleaseBankSlotAt ( int nDest)

Release the bank claiming a region of sound memory.

The walk stops at the first slot whose mDest matches, whether or not that slot claimed anything.

The image has no reference to this routine. LoadSoundBank() reaches the same body inline, so the out-of-line copy exists and nothing calls it.

Parameters
nDestThe region in sound memory.
Ghidra address:
NTSC-U/C: 0x004642c8
Ghidra address:
PAL: 0x004a1da8

◆ ReleaseAllBankSlots()

void ReleaseAllBankSlots ( )

Release every bank and empty g_bankSlots.

Each slot that claims sound memory has its tag submitted under selector 0x8130. The slots are not reset one by one, because the vector is emptied straight afterwards. ReleaseSoundBanks() is the one caller.

Ghidra address:
NTSC-U/C: 0x00461bb8
Ghidra address:
PAL: 0x0049f278

◆ IsBankXferBusy()

int IsBankXferBusy ( )

Report whether a bank transfer is still moving.

An HD transfer counts whenever g_nHdXferInFlight is set. A BD transfer counts while g_pBdXfer exists and has bytes left to move. MetRenderer's front-end poll is the one caller.

Returns
1 while either transfer is moving, otherwise 0.
Ghidra address:
NTSC-U/C: 0x00464628
Ghidra address:
PAL: 0x004a2108

◆ LoadSoundBank()

void LoadSoundBank ( const char * pszBdPath,
const char * pszHdPath,
int nTag,
int nPlacement )

Load a BD and HD bank pair and record the claim.

Performs no work when both paths already match what is loaded. The placement argument selects where the pair goes: a negative value leaves both destinations as they are, 0 or 1 selects kBankFixedDestAddress and the first IOP address, 2 selects the first destination buffer, and 3 rotates through both destination buffers and through the IOP addresses. Anything above 3 behaves like a negative value and leaves both the destination and the IOP address as they are.

A placement other than 3 restores the destination the call found, so only the rotating placement leaves the choice behind for the next caller.

Parameters
pszBdPathThe BD bank.
pszHdPathThe HD bank.
nTagThe tag both banks are recorded and stamped with.
nPlacementWhere the pair goes.
Ghidra address:
NTSC-U/C: 0x004620b0
Ghidra address:
PAL: 0x0049f770

◆ FourCcToString()

char * FourCcToString ( const void * pFourCc)

Copy a four-character code into a buffer it can be printed from.

The scratch buffer is eight bytes and only the first four are ever written, so the second word terminates the string. Nothing writes that word, which is what makes the result printable.

Parameters
pFourCcThe code to copy.
Returns
The scratch buffer at 0x00894740, valid until the next call.
Ghidra address:
NTSC-U/C: 0x00464b50
Ghidra address:
PAL: 0x004a2510

◆ XferBankFromMemory()

int XferBankFromMemory ( const void * pData,
int nLength )

Move a bank that is already in memory to the IOP and report it complete.

There is no file, no asynchronous read, and no chunking: the whole buffer goes across in one transfer. The claim on the current destination is released, the IOP address rotates, and the bank block is filled with a zero length and an empty payload, because an in-memory bank has no path.

Parameters
pDataThe bank.
nLengthThe bank's length.
Returns
Zero. There is no failure path.
Ghidra address:
NTSC-U/C: 0x00461db8
Ghidra address:
PAL: 0x0049f478

◆ StartBdBankXfer()

int StartBdBankXfer ( const char * pszPath)

Start a chunked BD bank transfer and report the bank's size.

Fills the bank block, measures the file, then opens it and queues the first chunk against a new CallbackXferBdToIop. The measured length reaches the block whether or not the measurement succeeded.

Parameters
pszPathThe bank to read.
Returns
The bank's size, or -1 when the file could not be measured.
Ghidra address:
NTSC-U/C: 0x00461f28
Ghidra address:
PAL: 0x0049f5e8

◆ StartHdBankXfer()

int StartHdBankXfer ( const char * pszPath,
int nPlacement )

Start an HD bank transfer.

Unlike the BD transfer this queues the whole file as one read against g_hdXfer. It selects the IOP address the same way LoadSoundBank() selects a destination, and reports Can't alloc heap when the selected address is negative, which is what a failed allocation on the IOP side leaves there. The read buffer is the bank's size plus 0x40, rounded up to a 64-byte boundary.

Parameters
pszPathThe bank to read.
nPlacementWhere the bank goes on the IOP.
Returns
Zero once the read is queued, or -1 on either failure.
Ghidra address:
NTSC-U/C: 0x00461c68
Ghidra address:
PAL: 0x0049f328

◆ SetBankLoadProgressHook()

void SetBankLoadProgressHook ( void(* pfnProgress )())

Install the bank-load progress hook.

Parameters
pfnProgressThe hook, which may be null.
Ghidra address:
NTSC-U/C: 0x00464378
Ghidra address:
PAL: 0x004a1e58

◆ DumpSynthVoices()

void DumpSynthVoices ( int bActiveOnly)

Report the state of both SPU2 cores and all 48 voices to the log.

Writes one Core %2.2d: MMix x eff d vmix L x x R x x end x line per core, one Voice %2.2d at x env x - end d mix d d d d line per voice, and finally Using d voices total. Every value is read back from the hardware, so the report is the live mixer state rather than anything the driver retains. A voice counts towards the total when its ENDX bit is clear, which is the sample not having run out.

Parameters
bActiveOnlyNon-zero to report only the voices whose ENDX bit is clear. SynthCommand() passes 1, and zero reports all 24 voices of each core.
Ghidra address:
NTSC-U/C: 0x00462558
Ghidra address:
PAL: 0x0049ffa0

◆ InitSpu2Cores()

void InitSpu2Cores ( )

Bind libsdr and bring both SPU2 cores up.

Sets the two mixer routings, silences the effect send, opens both master volumes fully, and gives each core a 128 KB effect work area at the top of sound RAM, core 0 taking the highest block. Core 1's mixer routing takes the external input that core 0's does not, which is what chains the two cores.

InitSynthDriver() is the only caller.

Ghidra address:
NTSC-U/C: 0x004649f8
Ghidra address:
PAL: 0x004a23b8

◆ ConfigureSpu2Effects()

void ConfigureSpu2Effects ( int bEnable)

Apply the configured reverb to both SPU2 cores.

Per core, the routine enables the effect only when the argument is non-zero and the configuration also enables it for that core; otherwise it clears both effect volumes and turns the core attribute off. Either way it then reopens both master volumes fully. When effects are enabled it fills a sceSdEffectAttr from five configuration values, ORs SD_EFFECT_MODE_CLEAR into the mode, and both depths are the configured value shifted left by eight.

Enabling also submits a further command block to the sound driver under selector 0x10e0, built from eleven more configuration values. Every value is read through QueryConfigFlag() and QueryConfigValue() from the templates RegisterHardEffectCommands() registers.

In the PAL build the block also includes the driver's two error logs when the level specifies an error file through current_level.ps2_hsyn_error_file(). A file with a new path is opened for writing and receives a heading, and the open file is flushed when the path is unchanged. Without a path the log fields are cleared.

Parameters
bEnableZero to force the effect off on both cores.
Ghidra address:
NTSC-U/C: 0x00462340
Ghidra address:
PAL: 0x0049fbd8

◆ InitSynthDriver()

void InitSynthDriver ( )

Bring the voice and bank driver up.

CreatePs2HardSynth() calls this immediately after construction, which is the seam between the Synth class and this module.

In the PAL build the routine also takes the two IOP buffers of the driver's error logs from the IOP heap.

Ghidra address:
NTSC-U/C: 0x004647a8
Ghidra address:
PAL: 0x0049f950

◆ PollSynthStream()

void PollSynthStream ( )

Advance the streaming voice buffers.

Performs no work while the stream at 0x006e9c58 is absent. MainLoop::Poll() drives this once per frame.

Ghidra address:
NTSC-U/C: 0x00464bc8
Ghidra address:
PAL: 0x004a2588

◆ SetSynthStreamBar()

void SetSynthStreamBar ( int nBar)

Move the streamed audio to the start of a bar.

Stores the bar scaled by 19200 as the frame PollSynthStream() passes to the stream, and does nothing while the stream at 0x006e9c58 is absent. Gamer's per-bar update is one caller and the routine at 0x00157578 the other. The title is inferred.

Parameters
nBarThe bar.
Ghidra address:
NTSC-U/C: 0x00464ba0
Ghidra address:
PAL: 0x004a2560

◆ PollSynthEvents()

void PollSynthEvents ( )

Advance the driver's pending events.

One of MainLoop's two periodic timers drives this.

In the PAL build every sixteenth call also writes each non-empty error log to the open error file and empties the log.

Ghidra address:
NTSC-U/C: 0x004648c8
Ghidra address:
PAL: 0x0049fa38

◆ WaitForBankTransfers()

void WaitForBankTransfers ( )

Wait until no bank transfer is outstanding.

Pumps the async completion queue for as long as IsBankXferBusy() reports a transfer, which it expands inline.

Ghidra address:
NTSC-U/C: 0x004645c8
Ghidra address:
PAL: 0x004a20a8

◆ ReleaseSoundBanks()

void ReleaseSoundBanks ( )

Release every loaded bank.

Submits selector 0xc0, releases every bank slot, deletes the BD transfer, clears both references to it, and assigns the empty string to both stored bank paths so that the next LoadSoundBank() cannot match what was resident. It does not wait for the transfers in flight.

Ghidra address:
NTSC-U/C: 0x00464660
Ghidra address:
PAL: 0x004a2140

◆ SendMidiToDriver()

void SendMidiToDriver ( unsigned char nStatus,
unsigned char nData1,
unsigned char nData2 )

Move one MIDI message to the sound driver.

Retains the program each channel holds in the table at 0x006e9bd8 and the bank each channel holds in the table at 0x006e9c18, and returns without submitting anything when a program change or a bank select (controller 0x20) repeats what the channel already holds. Otherwise it packs the status into the low byte, the first data byte into the second, and the second data byte into the third, and puts that word on port 0 of the MIDI stream input through sceMSIn_PutMsg().

Parameters
nStatusThe status byte.
nData1The first data byte.
nData2The second data byte.
Ghidra address:
NTSC-U/C: 0x00464928
Ghidra address:
PAL: 0x004a22e8

◆ SubmitDriverSetMono()

void SubmitDriverSetMono ( int bMono)

Switch the sound driver between mono and stereo output.

Submits selector 0x110, the driver's mono command. Ps2HardSynth::SetStereo() is the one caller and passes its argument inverted.

The body is one call to SubmitSoundDriverRequest().

Parameters
bMonoNonzero for mono output, zero for stereo.
Ghidra address:
NTSC-U/C: 0x00464868
Ghidra address:
PAL: 0x004a2288

◆ SubmitDriverSetRemix()

void SubmitDriverSetRemix ( int bRemix)

Switch the remix mode of the sound driver.

Submits selector 0x100, the driver's remix command. Ps2HardSynth::SetRemixMode() is the one caller.

The body is one call to SubmitSoundDriverRequest().

Parameters
bRemixNonzero to enter remix mode, zero to exit it.
Ghidra address:
NTSC-U/C: 0x00464888
Ghidra address:
PAL: 0x004a22a8

◆ SubmitDriverSetPaused()

void SubmitDriverSetPaused ( int bPaused)

Pause or resume the sound driver.

Submits selector 0xf0, the driver's pause command. Ps2HardSynth::SetPaused() is the one caller.

The body is one call to SubmitSoundDriverRequest().

Parameters
bPausedNonzero to pause, zero to resume.
Ghidra address:
NTSC-U/C: 0x004648a8
Ghidra address:
PAL: 0x004a22c8

◆ SubmitDriverAllNotesOff()

void SubmitDriverAllNotesOff ( )

Silence every channel of the sound driver.

Submits selector 0xc0, the driver's all-notes-off command, with no command block. ReleaseSoundBanks() is the one caller.

Ghidra address:
NTSC-U/C: 0x004649d8
Ghidra address:
PAL: 0x004a2398

◆ ps2_InitMSin()

void ps2_InitMSin ( )

Bind the MIDI stream input of Sony's component sound library.

Builds the library context at 0x00894760 with two buffer groups, the second holding one 0x400-byte MIDI stream buffer, and passes it to sceMSIn_Init(). A failure logs sceMSIn_Init Error. Otherwise the routine puts the message 0xc0 on port 0 through sceMSIn_PutMsg(). InitSynthDriver() is the one caller.

Ghidra address:
NTSC-U/C: 0x00462290
Ghidra address:
PAL: 0x0049fb28

◆ StartSoundBankMovie()

void StartSoundBankMovie ( const char * pszPath)

Open the sound-bank movie and start feeding its chunks to the driver.

A movie already open is destroyed first, and the stream frame returns to zero. The new movie is streamed, and a failure to open it logs Problem starting sndbank movie with the error code and continues with the movie as constructed. Track 15 receives the bank chunks. The movie's loop offset, and the word at 0x006e9dc4, both take the current song tick.

The title is inferred from the failure message.

Parameters
pszPathThe movie file.
Ghidra address:
NTSC-U/C: 0x00462908
Ghidra address:
PAL: 0x004a0350

◆ StopSoundBankMovie()

void StopSoundBankMovie ( )

Destroy the sound-bank movie, if one is open, and clear the pointer.

The title is inferred as the counterpart of StartSoundBankMovie().

Ghidra address:
NTSC-U/C: 0x00464b68
Ghidra address:
PAL: 0x004a2528

◆ ShutdownSynthDriver()

void ShutdownSynthDriver ( )

Take the voice and bank driver down.

The body is a two-instruction bare return. Ps2HardSynth's destructor is the one caller, which is what identifies the routine as the counterpart of InitSynthDriver() rather than a stub of some other member.

Ghidra address:
NTSC-U/C: 0x00464b48
Ghidra address:
PAL: 0x004a2508

Variable Documentation

◆ gCd

sceSifClientData gCd
extern

Client of the game's sound driver on the IOP, bound by ezMidiInit().

SubmitSoundDriverRequest() calls through it.

Ghidra address:
NTSC-U/C: 0x008e5bc0
Ghidra address:
PAL: 0x0092abc0

◆ kSoundDriverCommandPayloadSize

int kSoundDriverCommandPayloadSize = 0x6c
constexpr

Bytes of payload a command block has above its five-word header.

◆ g_chunkCommand

SoundDriverCommand g_chunkCommand
extern

Block that describes one chunk of a sound bank, submitted under selector 0x1070.

Ghidra address:
NTSC-U/C: 0x00894cc0
Ghidra address:
PAL: 0x008d9cc0

◆ kIopStagingBufferCount

int kIopStagingBufferCount = 2
constexpr

Staging buffers on the IOP that chunk transfers alternate between.

◆ g_anIopStagingAddress

int g_anIopStagingAddress[kIopStagingBufferCount]
extern

Addresses of the staging buffers on the IOP.

The table itself may be longer. Only the first two entries are reachable, because the index below is masked to one bit.

Ghidra address:
NTSC-U/C: 0x00894748
Ghidra address:
PAL: 0x008d8e48

◆ g_nIopStagingIndex

int g_nIopStagingIndex
extern

Staging buffer the next chunk transfer will use.

Ghidra address:
NTSC-U/C: 0x006e9b80
Ghidra address:
PAL: 0x0072d540

◆ g_nBankIopAddress

int g_nBankIopAddress
extern

Address on the IOP a sound bank is moved to.

CallbackXferHdToIop::Done() moves the whole bank there, and the routine that starts a BD transfer copies it into the first word of the bank-complete block.

Ghidra address:
NTSC-U/C: 0x006e9b84
Ghidra address:
PAL: 0x0072d548

◆ g_bankSlots

std::vector<BankSlot> g_bankSlots
extern

Every bank currently claiming sound memory.

Ghidra address:
NTSC-U/C: 0x006e9bb8
Ghidra address:
PAL: 0x0072d578

◆ kBankBufferAlignment

int kBankBufferAlignment = 0x40
constexpr

Boundary both bank read buffers are rounded up to.

◆ g_pBdXfer

CallbackXferBdToIop* g_pBdXfer
extern

Transfer currently streaming a BD bank, or null.

StartBdBankXfer() stores the object here and then reads it back to register it with g_hdXfer, which is why the same pointer is written twice.

Ghidra address:
NTSC-U/C: 0x006e9dd4
Ghidra address:
PAL: 0x0072d794

◆ g_bdBankName

HxStr g_bdBankName
extern

Path of the BD bank currently loaded.

Ghidra address:
NTSC-U/C: 0x006e9b90
Ghidra address:
PAL: 0x0072d550

◆ g_hdBankName

HxStr g_hdBankName
extern

Path of the HD bank currently loaded.

Ghidra address:
NTSC-U/C: 0x006e9b98
Ghidra address:
PAL: 0x0072d558

◆ kBankFixedDestAddress

int kBankFixedDestAddress = 0x5010
constexpr

Destination in sound memory a placement of 0 or 1 selects.

◆ kBankPlacementFirstBuffer

int kBankPlacementFirstBuffer = 2
constexpr

Placement that selects the first destination buffer.

◆ kBankPlacementRotate

int kBankPlacementRotate = 3
constexpr

Placement that rotates through the destination buffers and the IOP addresses.

◆ kHdBankPathSize

int kHdBankPathSize = 0x80
constexpr

Bytes of g_szHdBankPath.

Bounded by the next known object at 0x00894cc0 rather than measured.

◆ kBankDestBufferCount

int kBankDestBufferCount = 2
constexpr

Destination buffers the rotating placement alternates between.

◆ g_anBankDestAddress

int g_anBankDestAddress[kBankDestBufferCount]
extern

Destinations in sound memory a bank pair may go to.

Ghidra address:
NTSC-U/C: 0x006e9ba8
Ghidra address:
PAL: 0x0072d568

◆ g_nBankDestIndex

int g_nBankDestIndex
extern

Destination buffer the next rotating placement will use.

Ghidra address:
NTSC-U/C: 0x006e9bb0
Ghidra address:
PAL: 0x0072d570

◆ kBankIopAddressCount

int kBankIopAddressCount = 3
constexpr

Addresses on the IOP a bank may go to.

Three rather than two. The first is what a placement of 0 or 1 selects, and the rotation runs through all three once and then cycles between the second and the third.

◆ g_anBankIopAddress

int g_anBankIopAddress[kBankIopAddressCount]
extern

Addresses on the IOP a bank may go to.

Ghidra address:
NTSC-U/C: 0x00894750
Ghidra address:
PAL: 0x008d8e50

◆ g_nBankIopIndex

int g_nBankIopIndex
extern

Entry of g_anBankIopAddress the next rotating placement will use.

Ghidra address:
NTSC-U/C: 0x0089475c
Ghidra address:
PAL: 0x008d8e5c

◆ g_szHdBankPath

char g_szHdBankPath[]
extern

Path of the HD bank, copied in by StartHdBankXfer().

Nothing recovered reads it. The size is bounded by the next known object at 0x00894cc0 rather than measured.

Ghidra address:
NTSC-U/C: 0x00894c40
Ghidra address:
PAL: 0x008d9c40

◆ g_nBankDestAddress

int g_nBankDestAddress
extern

Address in sound memory a bank is written to.

The routine that starts a transfer copies it into the bank block's mDest, and a BD transfer takes its own starting destination from there and advances one chunk at a time.

Ghidra address:
NTSC-U/C: 0x006e9ba4
Ghidra address:
PAL: 0x0072d564

◆ g_nSynthXferTag

int g_nSynthXferTag
extern

Word every command block is stamped with at +0x10.

What the driver does with it is unrecovered, and the writer has not been identified.

Ghidra address:
NTSC-U/C: 0x006e9bb4
Ghidra address:
PAL: 0x0072d574

◆ g_pfnBankLoadProgress

void(* g_pfnBankLoadProgress) () ( )
extern

Called once after every chunk is submitted and once when a bank transfer finishes.

Both call sites test the hook against null first. It takes no arguments.

Ghidra address:
NTSC-U/C: 0x006e9bc4
Ghidra address:
PAL: 0x0072d584

◆ g_nHdXferInFlight

int g_nHdXferInFlight
extern

Non-zero while an HD bank transfer occupies the shared command block.

CallbackXferBdToIop defers to it, and CallbackXferHdToIop::Done() clears it. The routine that sets it is unrecovered.

Ghidra address:
NTSC-U/C: 0x006e9dc8
Ghidra address:
PAL: 0x0072d788

◆ g_bankCommand

SoundDriverCommand g_bankCommand
extern

Block that describes a whole bank, submitted under selector 0x1050 when the last chunk lands.

The routine that starts a transfer fills it once, at the start, and the completion path submits it unchanged. Its payload is the bank's path, copied in with strcpy(), and the cache is flushed straight afterwards because the driver reads the block from the IOP side.

Ghidra address:
NTSC-U/C: 0x00894bc0
Ghidra address:
PAL: 0x008d9bc0

◆ g_pHdXferBuffer

void* g_pHdXferBuffer
extern

Buffer the HD bank transfer read into, released once the transfer reports.

Ghidra address:
NTSC-U/C: 0x006e9dcc
Ghidra address:
PAL: 0x0072d78c

◆ g_pBdXferBuffer

void* g_pBdXferBuffer
extern

Buffer the BD bank transfer reads into, released once the last chunk has been moved.

This is the allocation as it came back from the heap. The read itself uses the pointer rounded up to a 64-byte boundary, which CallbackXferBdToIop stores separately.

Ghidra address:
NTSC-U/C: 0x006e9dd0
Ghidra address:
PAL: 0x0072d790