Mario Kart 64
Loading...
Searching...
No Matches
load.c File Reference
#include <ultra64.h>
#include <macros.h>
#include "audio/load.h"
#include "audio/data.h"
#include "audio/heap.h"
#include "audio/internal.h"
#include "audio/playback.h"
#include "audio/synthesis.h"
#include "audio/seqplayer.h"
#include "audio/port_eu.h"
#include "buffers/gfx_output_buffer.h"
Include dependency graph for load.c:

Macros

#define ALIGN16(val)   (((val) + 0xF) & ~0xF)
 
#define j   i
 
#define PATCH(SRC, BASE, TYPE)   SRC = (TYPE) ((uintptr_t) SRC + (uintptr_t) BASE)
 
#define PATCH(x, base)   (patched = (void*) ((uintptr_t) (x) + (uintptr_t) base))
 
#define BASE_OFFSET_REAL(x, base)   (void*) ((uintptr_t) (x) + (uintptr_t) base)
 
#define PATCH(x, base)   (patched = BASE_OFFSET_REAL(x, base))
 
#define PATCH_MEM(x)   x = PATCH(x, mem)
 
#define BASE_OFFSET(x, base)   BASE_OFFSET_REAL(base, x)
 

Functions

void audio_dma_copy_immediate (u8 *devAddr, void *vAddr, size_t nbytes)
 
void audio_dma_copy_async (uintptr_t devAddr, void *vAddr, size_t nbytes, OSMesgQueue *queue, OSIoMesg *mesg)
 
void audio_dma_partial_copy_async (uintptr_t *devAddr, u8 **vAddr, ssize_t *remaining, OSMesgQueue *queue, OSIoMesg *mesg)
 
void decrease_sample_dma_ttls ()
 
void * dma_sample_data (uintptr_t devAddr, u32 size, s32 arg2, u8 *dmaIndexRef)
 
void func_800BB030 (UNUSED s32 arg0)
 
s32 func_800BB304 (struct AudioBankSample *sample)
 
s32 func_800BB388 (s32 bankId, s32 instId, s32 arg2)
 
void func_800BB43C (ALSeqFile *f, u8 *base)
 
void patch_sound (struct AudioBankSound *sound, u8 *memBase, u8 *offsetBase)
 
void func_800BB584 (s32 bankId)
 
void patch_audio_bank (struct AudioBank *mem, u8 *offset, u32 numInstruments, u32 numDrums)
 
struct AudioBankbank_load_immediate (s32 bankId, s32 arg1)
 
struct AudioBankbank_load_async (s32 bankId, s32 arg1, struct SequencePlayer *seqPlayer)
 
void * sequence_dma_immediate (s32 seqId, s32 arg1)
 
void * sequence_dma_async (s32 seqId, s32 arg1, struct SequencePlayer *seqPlayer)
 
u8 get_missing_bank (u32 seqId, s32 *nonNullCount, s32 *nullCount)
 
struct AudioBankload_banks_immediate (s32 seqId, u8 *outDefaultBank)
 
void preload_sequence (u32 seqId, u8 preloadMask)
 
void load_sequence (u32 player, u32 seqId, s32 loadAsync)
 
void load_sequence_internal (u32 player, u32 seqId, s32 loadAsync)
 

Variables

struct SequencePlayer gSequencePlayers [SEQUENCE_PLAYERS]
 
struct SequenceChannel gSequenceChannels [SEQUENCE_CHANNELS]
 
struct SequenceChannelLayer gSequenceLayers [SEQUENCE_LAYERS]
 
struct SequenceChannel gSequenceChannelNone
 
struct AudioListItem gLayerFreeList
 
struct NotePool gNoteFreeLists
 
OSMesgQueue gCurrAudioFrameDmaQueue
 
OSMesg gCurrAudioFrameDmaMesgBufs [AUDIO_FRAME_DMA_QUEUE_SIZE]
 
OSIoMesg gCurrAudioFrameDmaIoMesgBufs [AUDIO_FRAME_DMA_QUEUE_SIZE]
 
OSMesgQueue D_803B6720
 
OSMesg D_803B6738
 
OSIoMesg D_803B6740
 
struct SharedDma sSampleDmas [0x70]
 
u32 gSampleDmaNumListItems
 
u32 sSampleDmaListSize1
 
s32 D_803B6E60
 
s32 load_bss_pad
 
u8 sSampleDmaReuseQueue1 [256]
 
u8 sSampleDmaReuseQueue2 [256]
 
u8 sSampleDmaReuseQueueTail1
 
u8 sSampleDmaReuseQueueTail2
 
u8 sSampleDmaReuseQueueHead1
 
u8 sSampleDmaReuseQueueHead2
 
ALSeqFilegSeqFileHeader
 
ALSeqFilegAlCtlHeader
 
ALSeqFilegAlTbl
 
u8gAlBankSets
 
u16 gSequenceCount
 
struct CtlEntrygCtlEntries
 
struct AudioBufferParametersEU gAudioBufferParameters
 
u32 D_803B70A8
 
s32 gMaxAudioCmds
 
s32 gMaxSimultaneousNotes
 
s16 gTempoInternalToExternal
 
s8 gAudioLibSoundMode
 
volatile s32 gAudioFrameCount
 
s32 gCurrAudioFrameDmaCount
 
char loadAudioString00 [] = "Romcopy %x -> %x ,size %x\n"
 
char loadAudioString01 [] = "Romcopyend\n"
 
char loadAudioString02 [] = "CAUTION:WAVE CACHE FULL %d"
 
char loadAudioString03 [] = "LOAD Rom :%x -> Ram :%x Len:%x\n"
 
char loadAudioString04 [] = "BASE %x %x\n"
 
char loadAudioString05 [] = "LOAD %x %x %x\n"
 
char loadAudioString06 [] = "INSTTOP %x\n"
 
char loadAudioString07 [] = "INSTMAP[0] %x\n"
 
char loadAudioString08 [] = "already flags %d\n"
 
char loadAudioString09 [] = "already flags %d\n"
 
char loadAudioString10 [] = "ERR:SLOW BANK DMA BUSY\n"
 
char loadAudioString11 [] = "ERR:SLOW DMA BUSY\n"
 
char loadAudioString12 [] = "Check %d bank %d\n"
 
char loadAudioString13 [] = "Cache Check\n"
 
char loadAudioString14 [] = "NO BANK ERROR\n"
 
char loadAudioString15 [] = "BANK %d LOADING START\n"
 
char loadAudioString16 [] = "BANK %d LOAD MISS (NO MEMORY)!\n"
 
char loadAudioString17 [] = "BANK %d ALREADY CACHED\n"
 
char loadAudioString18 [] = "BANK LOAD MISS! FOR %d\n"
 
char loadAudioString19 [] = "Seq %d Loading Start\n"
 
char loadAudioString20 [] = "Heap Overflow Error\n"
 
char loadAudioString21 [] = "SEQ %d ALREADY CACHED\n"
 
char loadAudioString22 [] = "Ok,one bank slow load Start \n"
 
char loadAudioString23 [] = "Sorry,too many %d bank is none.fast load Start \n"
 
char loadAudioString24 [] = "Seq %d:Default Load Id is %d\n"
 
char loadAudioString25 [] = "Seq Loading Start\n"
 
char loadAudioString26 [] = "Error:Before Sequence-SlowDma remain.\n"
 
char loadAudioString27 [] = " Cancel Seq Start.\n"
 
char loadAudioString28 [] = "SEQ %d ALREADY CACHED\n"
 
char loadAudioString29 [] = "Clear Workarea %x -%x size %x \n"
 
char loadAudioString30 [] = "AudioHeap is %x\n"
 
char loadAudioString31 [] = "Heap reset.Synth Change %x \n"
 
char loadAudioString32 [] = "Heap %x %x %x\n"
 
char loadAudioString33 [] = "Main Heap Initialize.\n"
 
char loadAudioString34 [] = "---------- Init Completed. ------------\n"
 
char loadAudioString35 [] = " Syndrv :[%6d]\n"
 
char loadAudioString36 [] = " Seqdrv :[%6d]\n"
 
char loadAudioString37 [] = " audiodata :[%6d]\n"
 
char loadAudioString38 [] = "---------------------------------------\n"
 

Macro Definition Documentation

◆ ALIGN16

#define ALIGN16 ( val)    (((val) + 0xF) & ~0xF)

◆ BASE_OFFSET

#define BASE_OFFSET ( x,
base )   BASE_OFFSET_REAL(base, x)

◆ BASE_OFFSET_REAL

#define BASE_OFFSET_REAL ( x,
base )   (void*) ((uintptr_t) (x) + (uintptr_t) base)

◆ j

#define j   i

◆ PATCH [1/3]

#define PATCH ( SRC,
BASE,
TYPE )   SRC = (TYPE) ((uintptr_t) SRC + (uintptr_t) BASE)

◆ PATCH [2/3]

#define PATCH ( x,
base )   (patched = (void*) ((uintptr_t) (x) + (uintptr_t) base))

◆ PATCH [3/3]

#define PATCH ( x,
base )   (patched = BASE_OFFSET_REAL(x, base))

◆ PATCH_MEM

#define PATCH_MEM ( x)    x = PATCH(x, mem)

Function Documentation

◆ audio_dma_copy_async()

void audio_dma_copy_async ( uintptr_t devAddr,
void * vAddr,
size_t nbytes,
OSMesgQueue * queue,
OSIoMesg * mesg )

Performs an asynchronus (normal priority) DMA copy

Here is the call graph for this function:
Here is the caller graph for this function:

◆ audio_dma_copy_immediate()

void audio_dma_copy_immediate ( u8 * devAddr,
void * vAddr,
size_t nbytes )

Performs an immediate DMA copy

Here is the call graph for this function:
Here is the caller graph for this function:

◆ audio_dma_partial_copy_async()

void audio_dma_partial_copy_async ( uintptr_t * devAddr,
u8 ** vAddr,
ssize_t * remaining,
OSMesgQueue * queue,
OSIoMesg * mesg )

Performs a partial asynchronous (normal priority) DMA copy. This is limited to 0x1000 bytes transfer at once.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bank_load_async()

struct AudioBank * bank_load_async ( s32 bankId,
s32 arg1,
struct SequencePlayer * seqPlayer )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ bank_load_immediate()

struct AudioBank * bank_load_immediate ( s32 bankId,
s32 arg1 )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ decrease_sample_dma_ttls()

void decrease_sample_dma_ttls ( void )
Here is the caller graph for this function:

◆ dma_sample_data()

void * dma_sample_data ( uintptr_t devAddr,
u32 size,
s32 arg2,
u8 * dmaIndexRef )
Here is the call graph for this function:

◆ func_800BB030()

void func_800BB030 ( UNUSED s32 arg0)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ func_800BB304()

s32 func_800BB304 ( struct AudioBankSample * sample)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ func_800BB388()

s32 func_800BB388 ( s32 bankId,
s32 instId,
s32 arg2 )
Bug
missing return
Here is the call graph for this function:
Here is the caller graph for this function:

◆ func_800BB43C()

void func_800BB43C ( ALSeqFile * f,
u8 * base )

◆ func_800BB584()

void func_800BB584 ( s32 bankId)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_missing_bank()

u8 get_missing_bank ( u32 seqId,
s32 * nonNullCount,
s32 * nullCount )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_banks_immediate()

struct AudioBank * load_banks_immediate ( s32 seqId,
u8 * outDefaultBank )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_sequence()

void load_sequence ( u32 player,
u32 seqId,
s32 loadAsync )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_sequence_internal()

void load_sequence_internal ( u32 player,
u32 seqId,
s32 loadAsync )
Bug
This should set the last bank (i.e. the first in the JSON) as default, not the missing one. This code path never gets taken, though – all sequence loading is synchronous.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ patch_audio_bank()

void patch_audio_bank ( struct AudioBank * mem,
u8 * offset,
u32 numInstruments,
u32 numDrums )

Doesn't affect EU, but required for US/JP

Doesn't affect EU, but required for US/JP

Here is the call graph for this function:
Here is the caller graph for this function:

◆ patch_sound()

void patch_sound ( struct AudioBankSound * sound,
u8 * memBase,
u8 * offsetBase )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ preload_sequence()

void preload_sequence ( u32 seqId,
u8 preloadMask )
Bug
should be IS_SEQ_LOAD_COMPLETE
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sequence_dma_async()

void * sequence_dma_async ( s32 seqId,
s32 arg1,
struct SequencePlayer * seqPlayer )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sequence_dma_immediate()

void * sequence_dma_immediate ( s32 seqId,
s32 arg1 )
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ D_803B6720

OSMesgQueue D_803B6720

◆ D_803B6738

OSMesg D_803B6738

◆ D_803B6740

OSIoMesg D_803B6740

◆ D_803B6E60

s32 D_803B6E60

◆ D_803B70A8

u32 D_803B70A8

◆ gAlBankSets

u8* gAlBankSets

◆ gAlCtlHeader

ALSeqFile* gAlCtlHeader

◆ gAlTbl

ALSeqFile* gAlTbl

◆ gAudioBufferParameters

struct AudioBufferParametersEU gAudioBufferParameters

◆ gAudioFrameCount

volatile s32 gAudioFrameCount

◆ gAudioLibSoundMode

s8 gAudioLibSoundMode

◆ gCtlEntries

struct CtlEntry* gCtlEntries

◆ gCurrAudioFrameDmaCount

s32 gCurrAudioFrameDmaCount

◆ gCurrAudioFrameDmaIoMesgBufs

OSIoMesg gCurrAudioFrameDmaIoMesgBufs[AUDIO_FRAME_DMA_QUEUE_SIZE]

◆ gCurrAudioFrameDmaMesgBufs

OSMesg gCurrAudioFrameDmaMesgBufs[AUDIO_FRAME_DMA_QUEUE_SIZE]

◆ gCurrAudioFrameDmaQueue

OSMesgQueue gCurrAudioFrameDmaQueue

◆ gLayerFreeList

struct AudioListItem gLayerFreeList

◆ gMaxAudioCmds

s32 gMaxAudioCmds

◆ gMaxSimultaneousNotes

s32 gMaxSimultaneousNotes

◆ gNoteFreeLists

struct NotePool gNoteFreeLists

◆ gSampleDmaNumListItems

u32 gSampleDmaNumListItems

◆ gSeqFileHeader

ALSeqFile* gSeqFileHeader

◆ gSequenceChannelNone

struct SequenceChannel gSequenceChannelNone

◆ gSequenceChannels

struct SequenceChannel gSequenceChannels[SEQUENCE_CHANNELS]

◆ gSequenceCount

u16 gSequenceCount

◆ gSequenceLayers

struct SequenceChannelLayer gSequenceLayers[SEQUENCE_LAYERS]

◆ gSequencePlayers

struct SequencePlayer gSequencePlayers[SEQUENCE_PLAYERS]

◆ gTempoInternalToExternal

s16 gTempoInternalToExternal

◆ load_bss_pad

s32 load_bss_pad

◆ loadAudioString00

char loadAudioString00[] = "Romcopy %x -> %x ,size %x\n"

Given that (almost) all of these are format strings, it is highly likely that they are meant to be used in some sort of printf variant. But I don't care to try and figure out which function gets which string(s) So I've place them all here instead.

◆ loadAudioString01

char loadAudioString01[] = "Romcopyend\n"

◆ loadAudioString02

char loadAudioString02[] = "CAUTION:WAVE CACHE FULL %d"

◆ loadAudioString03

char loadAudioString03[] = "LOAD Rom :%x -> Ram :%x Len:%x\n"

◆ loadAudioString04

char loadAudioString04[] = "BASE %x %x\n"

◆ loadAudioString05

char loadAudioString05[] = "LOAD %x %x %x\n"

◆ loadAudioString06

char loadAudioString06[] = "INSTTOP %x\n"

◆ loadAudioString07

char loadAudioString07[] = "INSTMAP[0] %x\n"

◆ loadAudioString08

char loadAudioString08[] = "already flags %d\n"

◆ loadAudioString09

char loadAudioString09[] = "already flags %d\n"

◆ loadAudioString10

char loadAudioString10[] = "ERR:SLOW BANK DMA BUSY\n"

◆ loadAudioString11

char loadAudioString11[] = "ERR:SLOW DMA BUSY\n"

◆ loadAudioString12

char loadAudioString12[] = "Check %d bank %d\n"

◆ loadAudioString13

char loadAudioString13[] = "Cache Check\n"

◆ loadAudioString14

char loadAudioString14[] = "NO BANK ERROR\n"

◆ loadAudioString15

char loadAudioString15[] = "BANK %d LOADING START\n"

◆ loadAudioString16

char loadAudioString16[] = "BANK %d LOAD MISS (NO MEMORY)!\n"

◆ loadAudioString17

char loadAudioString17[] = "BANK %d ALREADY CACHED\n"

◆ loadAudioString18

char loadAudioString18[] = "BANK LOAD MISS! FOR %d\n"

◆ loadAudioString19

char loadAudioString19[] = "Seq %d Loading Start\n"

◆ loadAudioString20

char loadAudioString20[] = "Heap Overflow Error\n"

◆ loadAudioString21

char loadAudioString21[] = "SEQ %d ALREADY CACHED\n"

◆ loadAudioString22

char loadAudioString22[] = "Ok,one bank slow load Start \n"

◆ loadAudioString23

char loadAudioString23[] = "Sorry,too many %d bank is none.fast load Start \n"

◆ loadAudioString24

char loadAudioString24[] = "Seq %d:Default Load Id is %d\n"

◆ loadAudioString25

char loadAudioString25[] = "Seq Loading Start\n"

◆ loadAudioString26

char loadAudioString26[] = "Error:Before Sequence-SlowDma remain.\n"

◆ loadAudioString27

char loadAudioString27[] = " Cancel Seq Start.\n"

◆ loadAudioString28

char loadAudioString28[] = "SEQ %d ALREADY CACHED\n"

◆ loadAudioString29

char loadAudioString29[] = "Clear Workarea %x -%x size %x \n"

◆ loadAudioString30

char loadAudioString30[] = "AudioHeap is %x\n"

◆ loadAudioString31

char loadAudioString31[] = "Heap reset.Synth Change %x \n"

◆ loadAudioString32

char loadAudioString32[] = "Heap %x %x %x\n"

◆ loadAudioString33

char loadAudioString33[] = "Main Heap Initialize.\n"

◆ loadAudioString34

char loadAudioString34[] = "---------- Init Completed. ------------\n"

◆ loadAudioString35

char loadAudioString35[] = " Syndrv :[%6d]\n"

◆ loadAudioString36

char loadAudioString36[] = " Seqdrv :[%6d]\n"

◆ loadAudioString37

char loadAudioString37[] = " audiodata :[%6d]\n"

◆ loadAudioString38

char loadAudioString38[] = "---------------------------------------\n"

◆ sSampleDmaListSize1

u32 sSampleDmaListSize1

◆ sSampleDmaReuseQueue1

u8 sSampleDmaReuseQueue1[256]

◆ sSampleDmaReuseQueue2

u8 sSampleDmaReuseQueue2[256]

◆ sSampleDmaReuseQueueHead1

u8 sSampleDmaReuseQueueHead1

◆ sSampleDmaReuseQueueHead2

u8 sSampleDmaReuseQueueHead2

◆ sSampleDmaReuseQueueTail1

u8 sSampleDmaReuseQueueTail1

◆ sSampleDmaReuseQueueTail2

u8 sSampleDmaReuseQueueTail2

◆ sSampleDmas

struct SharedDma sSampleDmas[0x70]