mirror of
https://github.com/blawar/ooot.git
synced 2024-07-04 18:13:37 +00:00
parent
3ad159855d
commit
aaeb80f0cb
|
@ -1,87 +0,0 @@
|
|||
|
||||
class Section:
|
||||
def __init__(self, name, offset, sz, elementSize = 8):
|
||||
self.name = name
|
||||
self.offset = offset
|
||||
self.sz = sz
|
||||
self.elementSize = elementSize
|
||||
|
||||
def serialize(self, f, z64):
|
||||
z64.seek(self.offset)
|
||||
|
||||
if self.getSize() == self.getElementSize():
|
||||
f.write('u%d %s = ' % (self.getElementSize() * 8, self.name))
|
||||
buffer = z64.read(self.getElementSize())
|
||||
n = int.from_bytes(buffer, "big")
|
||||
f.write(('0x%%%d.%dX' % (self.getElementSize() * 2, self.getElementSize() * 2)) % (n))
|
||||
f.write(';\n\n')
|
||||
return
|
||||
|
||||
f.write('u%d %s[0x%X] = {' % (self.getElementSize() * 8, self.name, self.getSize()))
|
||||
|
||||
lst = []
|
||||
while z64.tell() < self.offset + self.sz:
|
||||
buffer = z64.read(self.getElementSize())
|
||||
n = int.from_bytes(buffer, "big")
|
||||
lst.append(('0x%%%d.%dX' % (self.getElementSize() * 2, self.getElementSize() * 2)) % (n))
|
||||
#f.write(('0x%%%d.%dX, ' % (self.getElementSize() * 2, self.getElementSize() * 2)) % (n))
|
||||
|
||||
f.write(', '.join(lst))
|
||||
|
||||
f.write('};\n\n')
|
||||
|
||||
def getSize(self):
|
||||
return int(self.sz / self.getElementSize())
|
||||
|
||||
def getElementSize(self):
|
||||
return self.elementSize
|
||||
|
||||
sections = {'src/port/rsp.c': [
|
||||
Section('gSoundFontTable', 0xBCC270, 0x270, 1),
|
||||
Section('gSequenceFontTable', 0xBCC4E0, 0x1C0, 1),
|
||||
Section('gSequenceTable', 0xBCC6A0, 0x6F0, 1),
|
||||
Section('gSampleBankTable', 0xBCCD90, 0x80, 1),
|
||||
Section('rspAspMainDataStart', 0xBCCE10, 0x2E0),
|
||||
Section('D_80155F50', 0xBCD0F0, 0x1630, 1),
|
||||
Section('D_80157580', 0xBCE720, 0x420, 1),
|
||||
Section('D_801579A0', 0xBCEB40, 0x390, 1),
|
||||
Section('gJpegUCodeData', 0xBCEED0, 0x60),
|
||||
Section('D_801120C0', 0xB89260, 0xFB0, 8),
|
||||
Section('D_80113070', 0xB8A210, 0x18C0, 1),
|
||||
Section('gJpegUCode', 0xB8BAD0, 0xAF0, 8)
|
||||
],
|
||||
'src/port/rsp_boot.c': [
|
||||
Section('D_80009320', 0x9F20, 0xD0, 1),
|
||||
Section('D_800093F0', 0x9FF0, 0x20, 1)
|
||||
],
|
||||
'src/port/code_800F9280.c': [
|
||||
Section('sSeqCmdWrPos', 0xBAA5A0, 0x4, 1),
|
||||
Section('sSeqCmdRdPos', 0xBAA5A4, 0x4, 1),
|
||||
Section('D_80133408', 0xBAA5A8, 0x1, 1),
|
||||
Section('D_8013340C', 0xBAA5AC, 0x1, 1),
|
||||
Section('D_80133410', 0xBAA5B0, 0x4, 1),
|
||||
Section('gAudioSpecId', 0xBAA5B4, 0x1, 1),
|
||||
Section('D_80133418', 0xBAA5B8, 0x1, 1),
|
||||
'''
|
||||
Section('D_80133420', 0xBAA5C0, 0x48),
|
||||
Section('D_80133468', 0xBAA608, 0x48),
|
||||
Section('D_801334B0', 0xBAA650, 0x90),
|
||||
Section('D_80133540', 0xBAA6E0, 0x48),
|
||||
Section('D_80133588', 0xBAA728, 0x48),
|
||||
Section('D_801335D0', 0xBAA770, 0x48),
|
||||
Section('D_80133618', 0xBAA7B8, 0x48),
|
||||
Section('D_80133660', 0xBAA800, 0x48),
|
||||
Section('D_801336A8', 0xBAA848, 0x48),
|
||||
Section('D_801336F0', 0xBAA890, 0x48),
|
||||
Section('D_80133738', 0xBAA8D8, 0x90)
|
||||
'''
|
||||
]
|
||||
}
|
||||
|
||||
with open('baserom.z64', 'rb') as z64:
|
||||
for filename, s in sections.items():
|
||||
with open(filename, 'w') as f:
|
||||
f.write('#include "global.h"\n\n')
|
||||
|
||||
for section in s:
|
||||
section.serialize(f, z64)
|
75
include/redef_msgqueue.h
Normal file
75
include/redef_msgqueue.h
Normal file
|
@ -0,0 +1,75 @@
|
|||
#undef osCreateMesgQueue
|
||||
|
||||
static void osCreateMesgQueue(OSMesgQueue* mq, OSMesg* msg, s32 count)
|
||||
{
|
||||
mq->mtqueue = NULL;
|
||||
mq->fullqueue = NULL;
|
||||
mq->validCount = 0;
|
||||
mq->first = 0;
|
||||
mq->msgCount = count;
|
||||
mq->msg = msg;
|
||||
}
|
||||
|
||||
#undef osSendMesg
|
||||
|
||||
static s32 osSendMesg(OSMesgQueue* mq, OSMesg mesg, s32 flag)
|
||||
{
|
||||
register u32 index;
|
||||
|
||||
while(mq->validCount >= mq->msgCount)
|
||||
{
|
||||
if(flag == OS_MESG_BLOCK)
|
||||
{
|
||||
int zyz = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
index = (mq->first + mq->validCount) % mq->msgCount;
|
||||
mq->msg[index] = mesg;
|
||||
mq->validCount++;
|
||||
|
||||
if(mq->mtqueue->next != NULL)
|
||||
{
|
||||
//osStartThread(__osPopThread(&mq->mtqueue));
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#undef osRecvMesg
|
||||
|
||||
static s32 osRecvMesg(OSMesgQueue* mq, OSMesg* msg, s32 flag)
|
||||
{
|
||||
while(mq->validCount == 0)
|
||||
{
|
||||
if(flag == OS_MESG_NOBLOCK)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1; // TODO FIX HACK
|
||||
}
|
||||
}
|
||||
|
||||
if(msg != NULL)
|
||||
{
|
||||
*msg = mq->msg[mq->first];
|
||||
}
|
||||
|
||||
mq->first = (mq->first + 1) % mq->msgCount;
|
||||
mq->validCount--;
|
||||
|
||||
if(mq->fullqueue->next != NULL)
|
||||
{
|
||||
//osStartThread(__osPopThread(&mq->fullqueue));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -123,11 +123,19 @@ typedef struct {
|
|||
} AdpcmBook; // size >= 0x8
|
||||
|
||||
typedef struct {
|
||||
/* 0x00 */ u32 codec : 4;
|
||||
/* 0x00 */ u32 medium : 2;
|
||||
/* 0x00 */ u32 unk_bit26 : 1;
|
||||
/* 0x00 */ u32 unk_bit25 : 1;
|
||||
/* 0x01 */ u32 size : 24;
|
||||
#ifdef LITTLE_ENDIAN
|
||||
u32 size : 24;
|
||||
u32 unk_bit25 : 1;
|
||||
u32 unk_bit26 : 1;
|
||||
u32 medium : 2;
|
||||
u32 codec : 4;
|
||||
#else
|
||||
u32 codec : 4;
|
||||
u32 medium : 2;
|
||||
u32 unk_bit26 : 1;
|
||||
u32 unk_bit25 : 1;
|
||||
u32 size : 24;
|
||||
#endif
|
||||
/* 0x04 */ u8* sampleAddr;
|
||||
/* 0x08 */ AdpcmLoop* loop;
|
||||
/* 0x0C */ AdpcmBook* book;
|
||||
|
@ -138,6 +146,15 @@ typedef struct {
|
|||
/* 0x04 */ f32 tuning; // frequency scale factor
|
||||
} SoundFontSound; // size = 0x8
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CACHE_LOAD_PERMANENT = 0,
|
||||
CACHE_LOAD_PERSISTENT,
|
||||
CACHE_LOAD_TEMPORARY,
|
||||
CACHE_LOAD_EITHER,
|
||||
CACHE_LOAD_EITHER_NOSYNC
|
||||
} AudioCacheLoadType;
|
||||
|
||||
typedef struct {
|
||||
/* 0x00 */ s16 numSamplesAfterDownsampling; // never read
|
||||
/* 0x02 */ s16 chunkLen; // never read
|
||||
|
@ -231,14 +248,25 @@ typedef struct {
|
|||
|
||||
// Also known as a Group, according to debug strings.
|
||||
typedef struct {
|
||||
/* 0x000 */ u8 enabled : 1;
|
||||
/* 0x000 */ u8 finished : 1;
|
||||
/* 0x000 */ u8 muted : 1;
|
||||
/* 0x000 */ u8 seqDmaInProgress : 1;
|
||||
/* 0x000 */ u8 fontDmaInProgress : 1;
|
||||
/* 0x000 */ u8 recalculateVolume : 1;
|
||||
/* 0x000 */ u8 stopScript : 1;
|
||||
/* 0x000 */ u8 unk_0b1 : 1;
|
||||
#ifdef LITTLE_ENDIAN
|
||||
u8 unk_0b1 : 1;
|
||||
u8 stopScript : 1;
|
||||
u8 recalculateVolume : 1;
|
||||
u8 fontDmaInProgress : 1;
|
||||
u8 seqDmaInProgress : 1;
|
||||
u8 muted : 1;
|
||||
u8 finished : 1;
|
||||
u8 enabled : 1;
|
||||
#else
|
||||
u8 enabled : 1;
|
||||
u8 finished : 1;
|
||||
u8 muted : 1;
|
||||
u8 seqDmaInProgress : 1;
|
||||
u8 fontDmaInProgress : 1;
|
||||
u8 recalculateVolume : 1;
|
||||
u8 stopScript : 1;
|
||||
u8 unk_0b1 : 1;
|
||||
#endif
|
||||
/* 0x001 */ u8 state;
|
||||
/* 0x002 */ u8 noteAllocPolicy;
|
||||
/* 0x003 */ u8 muteBehavior;
|
||||
|
@ -281,11 +309,19 @@ typedef struct {
|
|||
typedef struct {
|
||||
/* 0x00 */ union {
|
||||
struct A {
|
||||
/* 0x00 */ u8 unk_0b80 : 1;
|
||||
/* 0x00 */ u8 hang : 1;
|
||||
/* 0x00 */ u8 decay : 1;
|
||||
/* 0x00 */ u8 release : 1;
|
||||
/* 0x00 */ u8 state : 4;
|
||||
#ifdef LITTLE_ENDIAN
|
||||
u8 state : 4;
|
||||
u8 release : 1;
|
||||
u8 decay : 1;
|
||||
u8 hang : 1;
|
||||
u8 unk_0b80 : 1;
|
||||
#else
|
||||
u8 unk_0b80 : 1;
|
||||
u8 hang : 1;
|
||||
u8 decay : 1;
|
||||
u8 release : 1;
|
||||
u8 state : 4;
|
||||
#endif
|
||||
} s;
|
||||
/* 0x00 */ u8 asByte;
|
||||
} action;
|
||||
|
@ -301,12 +337,21 @@ typedef struct {
|
|||
} AdsrState;
|
||||
|
||||
typedef struct {
|
||||
/* 0x00 */ u8 unused : 2;
|
||||
/* 0x00 */ u8 bit2 : 2;
|
||||
/* 0x00 */ u8 strongRight : 1;
|
||||
/* 0x00 */ u8 strongLeft : 1;
|
||||
/* 0x00 */ u8 stereoHeadsetEffects : 1;
|
||||
/* 0x00 */ u8 usesHeadsetPanEffects : 1;
|
||||
#ifdef LITTLE_ENDIAN
|
||||
u8 usesHeadsetPanEffects : 1;
|
||||
u8 stereoHeadsetEffects : 1;
|
||||
u8 strongLeft : 1;
|
||||
u8 strongRight : 1;
|
||||
u8 bit2 : 2;
|
||||
u8 unused : 2;
|
||||
#else
|
||||
u8 unused : 2;
|
||||
u8 bit2 : 2;
|
||||
u8 strongRight : 1;
|
||||
u8 strongLeft : 1;
|
||||
u8 stereoHeadsetEffects : 1;
|
||||
u8 usesHeadsetPanEffects : 1;
|
||||
#endif
|
||||
} StereoData;
|
||||
|
||||
typedef union {
|
||||
|
@ -329,19 +374,36 @@ typedef struct {
|
|||
|
||||
// Also known as a SubTrack, according to sm64 debug strings.
|
||||
typedef struct SequenceChannel {
|
||||
/* 0x00 */ u8 enabled : 1;
|
||||
/* 0x00 */ u8 finished : 1;
|
||||
/* 0x00 */ u8 stopScript : 1;
|
||||
/* 0x00 */ u8 stopSomething2 : 1; // sets SequenceLayer.stopSomething
|
||||
/* 0x00 */ u8 hasInstrument : 1;
|
||||
/* 0x00 */ u8 stereoHeadsetEffects : 1;
|
||||
/* 0x00 */ u8 largeNotes : 1; // notes specify duration and velocity
|
||||
/* 0x00 */ u8 unused : 1;
|
||||
#ifdef LITTLE_ENDIAN
|
||||
u8 unused : 1;
|
||||
u8 largeNotes : 1; // notes specify duration and velocity
|
||||
u8 stereoHeadsetEffects : 1;
|
||||
u8 hasInstrument : 1;
|
||||
u8 stopSomething2 : 1; // sets SequenceLayer.stopSomething
|
||||
u8 stopScript : 1;
|
||||
u8 finished : 1;
|
||||
u8 enabled : 1;
|
||||
#else
|
||||
u8 enabled : 1;
|
||||
u8 finished : 1;
|
||||
u8 stopScript : 1;
|
||||
u8 stopSomething2 : 1; // sets SequenceLayer.stopSomething
|
||||
u8 hasInstrument : 1;
|
||||
u8 stereoHeadsetEffects : 1;
|
||||
u8 largeNotes : 1; // notes specify duration and velocity
|
||||
u8 unused : 1;
|
||||
#endif
|
||||
union {
|
||||
struct {
|
||||
/* 0x01 */ u8 freqScale : 1;
|
||||
/* 0x01 */ u8 volume : 1;
|
||||
/* 0x01 */ u8 pan : 1;
|
||||
#ifdef LITTLE_ENDIAN
|
||||
u8 pan : 1;
|
||||
u8 volume : 1;
|
||||
u8 freqScale : 1;
|
||||
#else
|
||||
u8 freqScale : 1;
|
||||
u8 volume : 1;
|
||||
u8 pan : 1;
|
||||
#endif
|
||||
} s;
|
||||
/* 0x01 */ u8 asByte;
|
||||
} changes;
|
||||
|
@ -393,14 +455,25 @@ typedef struct SequenceChannel {
|
|||
|
||||
// Might also be known as a Track, according to sm64 debug strings (?).
|
||||
typedef struct SequenceLayer {
|
||||
/* 0x00 */ u8 enabled : 1;
|
||||
/* 0x00 */ u8 finished : 1;
|
||||
/* 0x00 */ u8 stopSomething : 1;
|
||||
/* 0x00 */ u8 continuousNotes : 1; // keep the same note for consecutive notes with the same sound
|
||||
/* 0x00 */ u8 bit3 : 1; // "loaded"?
|
||||
/* 0x00 */ u8 ignoreDrumPan : 1;
|
||||
/* 0x00 */ u8 bit1 : 1; // "has initialized continuous notes"?
|
||||
/* 0x00 */ u8 notePropertiesNeedInit : 1;
|
||||
#ifdef LITTLE_ENDIAN
|
||||
u8 notePropertiesNeedInit : 1;
|
||||
u8 bit1 : 1; // "has initialized continuous notes"?
|
||||
u8 ignoreDrumPan : 1;
|
||||
u8 bit3 : 1; // "loaded"?
|
||||
u8 continuousNotes : 1; // keep the same note for consecutive notes with the same sound
|
||||
u8 stopSomething : 1;
|
||||
u8 finished : 1;
|
||||
u8 enabled : 1;
|
||||
#else
|
||||
u8 enabled : 1;
|
||||
u8 finished : 1;
|
||||
u8 stopSomething : 1;
|
||||
u8 continuousNotes : 1; // keep the same note for consecutive notes with the same sound
|
||||
u8 bit3 : 1; // "loaded"?
|
||||
u8 ignoreDrumPan : 1;
|
||||
u8 bit1 : 1; // "has initialized continuous notes"?
|
||||
u8 notePropertiesNeedInit : 1;
|
||||
#endif
|
||||
/* 0x01 */ Stereo stereo;
|
||||
/* 0x02 */ u8 instOrWave;
|
||||
/* 0x03 */ u8 gateTime;
|
||||
|
@ -494,21 +567,40 @@ typedef struct {
|
|||
|
||||
typedef struct {
|
||||
struct {
|
||||
/* 0x00 */ volatile u8 enabled : 1;
|
||||
/* 0x00 */ u8 needsInit : 1;
|
||||
/* 0x00 */ u8 finished : 1; // ?
|
||||
/* 0x00 */ u8 unused : 1;
|
||||
/* 0x00 */ u8 stereoStrongRight : 1;
|
||||
/* 0x00 */ u8 stereoStrongLeft : 1;
|
||||
/* 0x00 */ u8 stereoHeadsetEffects : 1;
|
||||
/* 0x00 */ u8 usesHeadsetPanEffects : 1; // ?
|
||||
#ifdef LITTLE_ENDIAN
|
||||
u8 usesHeadsetPanEffects : 1; // ?
|
||||
u8 stereoHeadsetEffects : 1;
|
||||
u8 stereoStrongLeft : 1;
|
||||
u8 stereoStrongRight : 1;
|
||||
u8 unused : 1;
|
||||
u8 finished : 1; // ?
|
||||
u8 needsInit : 1;
|
||||
volatile u8 enabled : 1;
|
||||
#else
|
||||
volatile u8 enabled : 1;
|
||||
u8 needsInit : 1;
|
||||
u8 finished : 1; // ?
|
||||
u8 unused : 1;
|
||||
u8 stereoStrongRight : 1;
|
||||
u8 stereoStrongLeft : 1;
|
||||
u8 stereoHeadsetEffects : 1;
|
||||
u8 usesHeadsetPanEffects : 1; // ?
|
||||
#endif
|
||||
} bitField0;
|
||||
struct {
|
||||
/* 0x01 */ u8 reverbIndex : 3;
|
||||
/* 0x01 */ u8 bookOffset : 2;
|
||||
/* 0x01 */ u8 isSyntheticWave : 1;
|
||||
/* 0x01 */ u8 hasTwoParts : 1;
|
||||
/* 0x01 */ u8 usesHeadsetPanEffects2 : 1;
|
||||
#ifdef LITTLE_ENDIAN
|
||||
u8 usesHeadsetPanEffects2 : 1;
|
||||
u8 hasTwoParts : 1;
|
||||
u8 isSyntheticWave : 1;
|
||||
u8 bookOffset : 2;
|
||||
u8 reverbIndex : 3;
|
||||
#else
|
||||
u8 reverbIndex : 3;
|
||||
u8 bookOffset : 2;
|
||||
u8 isSyntheticWave : 1;
|
||||
u8 hasTwoParts : 1;
|
||||
u8 usesHeadsetPanEffects2 : 1;
|
||||
#endif
|
||||
} bitField1;
|
||||
/* 0x02 */ u8 unk_2;
|
||||
/* 0x03 */ u8 headsetPanRight;
|
||||
|
@ -671,12 +763,22 @@ typedef struct {
|
|||
typedef struct {
|
||||
union{
|
||||
u32 opArgs;
|
||||
#ifdef LITTLE_ENDIAN
|
||||
struct
|
||||
{
|
||||
u8 arg2;
|
||||
u8 arg1;
|
||||
u8 arg0;
|
||||
u8 op;
|
||||
};
|
||||
#else
|
||||
struct {
|
||||
u8 op;
|
||||
u8 arg0;
|
||||
u8 arg1;
|
||||
u8 arg2;
|
||||
};
|
||||
#endif
|
||||
};
|
||||
union {
|
||||
void* data;
|
||||
|
@ -723,7 +825,7 @@ typedef struct {
|
|||
/* 0x4C */ OSIoMesg ioMesg;
|
||||
} AudioSlowLoad; // size = 0x64
|
||||
|
||||
typedef struct {
|
||||
typedef struct AudioTableEntry {
|
||||
/* 0x00 */ uintptr_t romAddr;
|
||||
/* 0x04 */ u32 size;
|
||||
/* 0x08 */ s8 medium;
|
||||
|
@ -733,7 +835,7 @@ typedef struct {
|
|||
/* 0x0E */ s16 shortData3;
|
||||
} AudioTableEntry; // size = 0x10
|
||||
|
||||
typedef struct {
|
||||
typedef struct AudioTable {
|
||||
/* 0x00 */ s16 numEntries;
|
||||
/* 0x02 */ s16 unkMediumParam;
|
||||
/* 0x04 */ uintptr_t romAddr;
|
||||
|
@ -741,6 +843,15 @@ typedef struct {
|
|||
/* 0x10 */ AudioTableEntry entries[1]; // (dynamic size)
|
||||
} AudioTable; // size >= 0x20
|
||||
|
||||
typedef struct AudioTableDef
|
||||
{
|
||||
/* 0x00 */ s16 numEntries;
|
||||
/* 0x02 */ s16 unkMediumParam;
|
||||
/* 0x04 */ uintptr_t romAddr;
|
||||
/* 0x08 */ char pad[0x8];
|
||||
/* 0x10 */ AudioTableEntry entries[]; // (dynamic size)
|
||||
} AudioTableDef; // size >= 0x20
|
||||
|
||||
typedef struct {
|
||||
/* 0x00 */ OSTask task;
|
||||
/* 0x40 */ OSMesgQueue* taskQueue;
|
||||
|
@ -1335,10 +1446,10 @@ extern u8 D_80133418;
|
|||
|
||||
extern const AudioContextInitSizes D_8014A6C4;
|
||||
extern s16 gOcarinaSongItemMap[];
|
||||
extern u8 gSoundFontTable[];
|
||||
extern u8 gSequenceFontTable[];
|
||||
extern u8 gSequenceTable[];
|
||||
extern u8 gSampleBankTable[];
|
||||
extern AudioTableDef gSoundFontTable;
|
||||
extern u16 gSequenceFontTable[];
|
||||
extern AudioTableDef gSequenceTable;
|
||||
extern AudioTableDef gSampleBankTable;
|
||||
extern u8 gAudioHeap[0x38000];
|
||||
|
||||
extern ActiveSound gActiveSounds[7][MAX_CHANNELS_PER_BANK]; // total size = 0xA8
|
||||
|
|
3
setup.py
3
setup.py
|
@ -54,8 +54,7 @@ def build():
|
|||
subprocess.check_call([sys.executable, str('tools/msgenc.py'), str('assets/text/charmap.txt'), str('assets/text/message_data_staff.h'), str('build/assets/text/message_data_staff.enc.h')])
|
||||
subprocess.check_call([sys.executable, str('tools/extract_missing_assets.py')])
|
||||
subprocess.check_call([sys.executable, str('tools/create_luts.py')])
|
||||
#subprocess.check_call([sys.executable, str('tools/mark_segments.py')])
|
||||
#subprocess.check_call([sys.executable, str('tools/extract_z64_variables.py')])
|
||||
subprocess.check_call([sys.executable, str('tools/extract_z64_variables.py')])
|
||||
|
||||
print("Finished asset extraction and parsing")
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#define INTERNAL_SRC_CODE_AUDIOMGR_C
|
||||
#define INTERNAL_SRC_CODE_AUDIOMGR_C
|
||||
#include "global.h"
|
||||
#include "z64audio.h"
|
||||
#include "audiomgr.h"
|
||||
|
@ -8,13 +8,36 @@
|
|||
#include "regs.h"
|
||||
#include "z64game.h"
|
||||
#include "def/audioMgr.h"
|
||||
#include "def/code_800EC960.h"
|
||||
#include "def/code_800E4FE0.h"
|
||||
#include "def/audio_playback.h"
|
||||
|
||||
static AudioMgr* g_audioMgr = NULL;
|
||||
|
||||
void AudioMgr_HandleRetrace(AudioMgr* audioMgr);
|
||||
|
||||
void func_800C3C80(AudioMgr* audioMgr) {
|
||||
return;
|
||||
}
|
||||
|
||||
void AudioMgr_HandleRetraceNULL() {
|
||||
AudioMgr_HandleRetrace(NULL);
|
||||
}
|
||||
|
||||
void AudioMgr_HandleRetrace(AudioMgr* audioMgr) {
|
||||
if(!audioMgr)
|
||||
{
|
||||
audioMgr = g_audioMgr;
|
||||
}
|
||||
|
||||
if(!audioMgr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
AudioTask* task = func_800E4FE0();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void AudioMgr_HandlePRENMI(AudioMgr* audioMgr) {
|
||||
|
@ -27,4 +50,13 @@ void AudioMgr_Unlock(AudioMgr* audioMgr) {
|
|||
}
|
||||
|
||||
void AudioMgr_Init(AudioMgr* audioMgr, void* stack, OSPri pri, OSId id, SchedContext* sched, IrqMgr* irqMgr) {
|
||||
bzero(audioMgr, sizeof(AudioMgr));
|
||||
g_audioMgr = audioMgr;
|
||||
|
||||
IrqMgrClient irqClient;
|
||||
s16* msg = NULL;
|
||||
|
||||
Audio_Init();
|
||||
//AudioLoad_SetDmaHandler(DmaMgr_DmaHandler);
|
||||
Audio_InitSound();
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "def/audio_seqplayer.h"
|
||||
#include "def/code_800E6840.h"
|
||||
#include "def/code_800F7260.h"
|
||||
#include "def/initialize.h"
|
||||
|
||||
void AudioHeap_InitSampleCaches(u32 persistentSize, u32 temporarySize);
|
||||
SampleCacheEntry* AudioHeap_AllocTemporarySampleCacheEntry(u32 size);
|
||||
|
@ -20,6 +21,7 @@ void AudioHeap_DiscardSampleCaches(void);
|
|||
void AudioHeap_DiscardSampleBank(s32 sampleBankId);
|
||||
void AudioHeap_DiscardSampleBanks(void);
|
||||
|
||||
|
||||
f32 func_800DDE20(f32 arg0) {
|
||||
return 256.0f * gAudioContext.audioBufferParameters.unkUpdatesPerFrameScaled / arg0;
|
||||
}
|
||||
|
@ -241,6 +243,11 @@ void AudioHeap_PopCache(s32 tableType) {
|
|||
persistent = &loadedPool->persistent;
|
||||
persistentPool = &persistent->pool;
|
||||
|
||||
if(persistent == NULL) // TODO FIX HACK
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (persistent->numEntries == 0) {
|
||||
return;
|
||||
}
|
||||
|
@ -821,7 +828,7 @@ void AudioHeap_Init(void) {
|
|||
spec = &gAudioSpecs[gAudioContext.audioResetSpecIdToLoad];
|
||||
gAudioContext.sampleDmaCount = 0;
|
||||
gAudioContext.audioBufferParameters.frequency = spec->frequency;
|
||||
gAudioContext.audioBufferParameters.aiFrequency = 0; // TODO FIX osAiSetFrequency(gAudioContext.audioBufferParameters.frequency);
|
||||
gAudioContext.audioBufferParameters.aiFrequency = osAiSetFrequency(gAudioContext.audioBufferParameters.frequency);
|
||||
gAudioContext.audioBufferParameters.samplesPerFrameTarget =
|
||||
((gAudioContext.audioBufferParameters.frequency / gAudioContext.refreshRate) + 0xF) & 0xFFF0;
|
||||
gAudioContext.audioBufferParameters.minAiBufferLength =
|
||||
|
|
|
@ -3,8 +3,89 @@
|
|||
#include "z64audio.h"
|
||||
#include "def/audio_init_params.h"
|
||||
|
||||
u8 D_8016F0E0[0xA0]; // unused
|
||||
AudioContext gAudioContext;
|
||||
void (*D_801755D0)(void);
|
||||
s32 D_801755D8[3]; // unused
|
||||
|
||||
const s16 D_8014A6C0[] = {
|
||||
0x1C00, // unused
|
||||
0x0030, // gTatumsPerBeat
|
||||
};
|
||||
|
||||
const AudioContextInitSizes D_8014A6C4 = { 0x37F00, 0xE0E0, 0xBCE0 };
|
||||
|
||||
ReverbSettings D_80133420[][3] = {
|
||||
{
|
||||
{ 1, 0x30, 0x3000, 0, 0, 0x7FFF, 0x0000, 0x0000, 0xFF, 0x3000, 0x0, 0x0 },
|
||||
{ 1, 0x20, 0x0800, 0, 0, 0x7FFF, 0x0000, 0x0000, 0xFF, 0x0000, 0x0, 0x0 },
|
||||
},
|
||||
{
|
||||
{ 1, 0x30, 0x3000, 0, 0, 0x7FFF, 0x0000, 0x0000, 0xFF, 0x3000, 0x0, 0x0 },
|
||||
{ 1, 0x30, 0x1800, 0, 0, 0x7FFF, 0x0000, 0x0000, 0xFF, 0x0000, 0xB, 0xB },
|
||||
},
|
||||
{
|
||||
{ 1, 0x30, 0x3000, 0, 0, 0x7FFF, 0x0000, 0x0000, 0xFF, 0x3000, 0x0, 0x0 },
|
||||
{ 1, 0x38, 0x2800, 0, 0, 0x7FFF, 0x0000, 0x0000, 0xFF, 0x0000, 0x7, 0x7 },
|
||||
},
|
||||
{
|
||||
{ 1, 0x30, 0x3000, 0, 0, 0x7FFF, 0x0000, 0x0000, 0xFF, 0x3000, 0x0, 0x0 },
|
||||
{ 1, 0x50, 0x5000, 0, 0, 0x7FFF, 0x1000, 0x1000, 0xFF, 0x3000, 0x7, 0x7 },
|
||||
},
|
||||
{
|
||||
{ 1, 0x30, 0x3000, 0, 0, 0x7FFF, 0x0000, 0x0000, 0xFF, 0x3000, 0x0, 0x0 },
|
||||
{ 1, 0x40, 0x5000, 0, 0, 0x7FFF, 0x1800, 0x1800, 0xFF, 0x3000, 0x7, 0x7 },
|
||||
},
|
||||
{
|
||||
{ 1, 0x30, 0x3000, 0, 0, 0x7FFF, 0x0000, 0x0000, 0xFF, 0x3000, 0x0, 0x0 },
|
||||
{ 1, 0x40, 0x5C00, 0, 0, 0x7FFF, 0x2000, 0x2000, 0xFF, 0x3000, 0x4, 0x4 },
|
||||
},
|
||||
{
|
||||
{ 1, 0x30, 0x3000, 0, 0, 0x7FFF, 0x0000, 0x0000, 0xFF, 0x3000, 0x0, 0x0 },
|
||||
{ 1, 0x30, 0x6000, 0, 0, 0x7FFF, 0x1000, 0x1000, 0xFF, 0x3000, 0xA, 0xA },
|
||||
},
|
||||
{
|
||||
{ 1, 0x30, 0x3000, 0, 0, 0x7FFF, 0x0000, 0x0000, 0xFF, 0x3000, 0x0, 0x0 },
|
||||
{ 1, 0x30, 0x6800, 0, 0, 0x7FFF, 0x1400, 0x1400, 0xFF, 0x3000, 0x6, 0x6 },
|
||||
},
|
||||
{
|
||||
{ 1, 0x30, 0x3000, 0, 0, 0x7FFF, 0x0000, 0x0000, 0xFF, 0x3000, 0x0, 0x0 },
|
||||
{ 2, 0x50, 0x5000, 0, 0, 0x7FFF, 0xD000, 0x3000, 0xFF, 0x3000, 0x0, 0x0 },
|
||||
},
|
||||
{
|
||||
{ 1, 0x30, 0x3000, 0, 0, 0x7FFF, 0x0000, 0x0000, 0xFF, 0x3000, 0x0, 0x0 },
|
||||
{ 1, 0x20, 0x0000, 0, 0, 0x7FFF, 0x0000, 0x0000, 0xFF, 0x0000, 0x0, 0x0 },
|
||||
},
|
||||
{
|
||||
{ 1, 0x30, 0x3000, 0, 0, 0x7FFF, 0x0000, 0x0000, 0xFF, 0x3000, 0x0, 0x0 },
|
||||
{ 1, 0x30, 0x1800, 0, 0, 0x7FFF, 0x0000, 0x0000, 0xFF, 0x0000, 0xB, 0xB },
|
||||
},
|
||||
{
|
||||
{ 1, 0x30, 0x3000, 0, 0, 0x7FFF, 0x0000, 0x0000, 0xFF, 0x3000, 0x0, 0x0 },
|
||||
},
|
||||
{
|
||||
{ 1, 0x30, 0x3000, 0, 0, 0x7FFF, 0x0000, 0x0000, 0xFF, 0x3000, 0x0, 0x0 },
|
||||
{ 1, 0x40, 0x5000, 0, 0, 0x7FFF, 0x0000, 0x0000, 0xFF, 0x3000, 0x0, 0x0 },
|
||||
},
|
||||
};
|
||||
|
||||
AudioSpec gAudioSpecs[18] = {
|
||||
{ 32000, 1, 24, 4, 0, 0, 2, D_80133420[0], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x4000, 0x2880, 0, 0, 0 },
|
||||
{ 32000, 1, 24, 4, 0, 0, 2, D_80133420[1], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x3800, 0x2880, 0, 0, 0 },
|
||||
{ 32000, 1, 24, 4, 0, 0, 2, D_80133420[2], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x3800, 0x2880, 0, 0, 0 },
|
||||
{ 32000, 1, 23, 4, 0, 0, 2, D_80133420[4], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x3800, 0x2880, 0, 0, 0 },
|
||||
{ 32000, 1, 23, 4, 0, 0, 2, D_80133420[5], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x3800, 0x2880, 0, 0, 0 },
|
||||
{ 32000, 1, 24, 4, 0, 0, 2, D_80133420[6], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x3800, 0x2880, 0, 0, 0 },
|
||||
{ 32000, 1, 24, 4, 0, 0, 2, D_80133420[7], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x3800, 0x2880, 0, 0, 0 },
|
||||
{ 32000, 1, 23, 4, 0, 0, 2, D_80133420[8], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x3800, 0x2880, 0, 0, 0 },
|
||||
{ 32000, 1, 24, 4, 0, 0, 2, D_80133420[9], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x3800, 0x2880, 0, 0, 0 },
|
||||
{ 32000, 1, 23, 4, 0, 0, 2, D_80133420[8], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x3800, 0x2880, 0, 0, 0 },
|
||||
{ 32000, 1, 28, 3, 0, 0, 2, D_80133420[10], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x2800, 0x2880, 0, 0, 0 },
|
||||
{ 32000, 1, 28, 3, 0, 0, 1, D_80133420[11], 0x300, 0x200, 0x7FFF, 0, 0x4800, 0, 0x4000, 0, 0, 0, 0 },
|
||||
{ 32000, 1, 28, 3, 0, 0, 1, D_80133420[11], 0x300, 0x200, 0x7FFF, 0, 0, 0, 0x4000, 0x4800, 0, 0, 0 },
|
||||
{ 32000, 1, 22, 4, 0, 0, 2, D_80133420[0], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x3800, 0x2880, 0, 0, 0 },
|
||||
{ 32000, 1, 22, 4, 0, 0, 2, D_80133420[8], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x3800, 0x2880, 0, 0, 0 },
|
||||
{ 32000, 1, 16, 4, 0, 0, 2, D_80133420[0], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x3800, 0x2880, 0, 0, 0 },
|
||||
{ 22050, 1, 24, 4, 0, 0, 2, D_80133420[0], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x3800, 0x2880, 0, 0, 0 },
|
||||
{ 32000, 1, 24, 4, 0, 0, 2, D_80133420[2], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x3600, 0x2600, 0, 0, 0 },
|
||||
};
|
|
@ -2,6 +2,10 @@
|
|||
#include "ultra64.h"
|
||||
#include "global.h"
|
||||
#include "z64audio.h"
|
||||
#include "audio/bank.h"
|
||||
#include "audio/seq.h"
|
||||
#include "audio/table.h"
|
||||
#include <string.h>
|
||||
#include "segment_symbols.h"
|
||||
#include "def/audio_heap.h"
|
||||
#include "def/audio_init_params.h"
|
||||
|
@ -16,6 +20,10 @@
|
|||
#include "def/heaps.h"
|
||||
#include "def/recvmesg.h"
|
||||
|
||||
#include "redef_msgqueue.h"
|
||||
|
||||
#define BEE32(s) s
|
||||
|
||||
extern u32 osTvType;
|
||||
|
||||
#define MK_ASYNC_MSG(retData, tableType, id, status) (((retData) << 24) | ((tableType) << 16) | ((id) << 8) | (status))
|
||||
|
@ -356,9 +364,22 @@ void AudioLoad_SetSampleFontLoadStatus(s32 sampleBankId, s32 status) {
|
|||
}
|
||||
}
|
||||
|
||||
static AudioTable* LoadTable(AudioTable* table)
|
||||
{
|
||||
for(s16 i = 0; i < table->numEntries; i++)
|
||||
{
|
||||
AudioTableEntry* entry = &table->entries[i];
|
||||
continue;
|
||||
}
|
||||
|
||||
return table;
|
||||
}
|
||||
|
||||
void AudioLoad_InitTable(AudioTable* table, void* romAddr, u16 unkMediumParam) {
|
||||
s32 i;
|
||||
|
||||
LoadTable(table);
|
||||
|
||||
table->unkMediumParam = unkMediumParam;
|
||||
table->romAddr = romAddr;
|
||||
|
||||
|
@ -479,7 +500,7 @@ void AudioLoad_AsyncLoadFont(s32 fontId, s32 arg1, s32 retData, OSMesgQueue* ret
|
|||
|
||||
u8* AudioLoad_GetFontsForSequence(s32 seqId, u32* outNumFonts) {
|
||||
s32 index;
|
||||
return NULL; // TODO FIX
|
||||
|
||||
index = ((u16*)gAudioContext.sequenceFontTable)[seqId];
|
||||
|
||||
*outNumFonts = gAudioContext.sequenceFontTable[index++];
|
||||
|
@ -642,7 +663,7 @@ u32 AudioLoad_TrySyncLoadSampleBank(u32 sampleBankId, u32* outMedium, s32 noLoad
|
|||
}
|
||||
|
||||
SoundFontData* AudioLoad_SyncLoadFont(u32 fontId) {
|
||||
SoundFontData* ret;
|
||||
SoundFontData* mem;
|
||||
s32 sampleBankId1;
|
||||
s32 sampleBankId2;
|
||||
s32 didAllocate;
|
||||
|
@ -669,15 +690,15 @@ SoundFontData* AudioLoad_SyncLoadFont(u32 fontId) {
|
|||
relocInfo.baseAddr2 = 0;
|
||||
}
|
||||
|
||||
ret = AudioLoad_SyncLoad(FONT_TABLE, fontId, &didAllocate);
|
||||
if (ret == NULL) {
|
||||
mem = AudioLoad_SyncLoad(FONT_TABLE, fontId, &didAllocate);
|
||||
if (mem == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
if (didAllocate == true) {
|
||||
AudioLoad_RelocateFontAndPreloadSamples(realFontId, ret, &relocInfo, false);
|
||||
AudioLoad_RelocateFontAndPreloadSamples(realFontId, mem, &relocInfo, false);
|
||||
}
|
||||
|
||||
return ret;
|
||||
return mem;
|
||||
}
|
||||
|
||||
void* AudioLoad_SyncLoad(u32 tableType, u32 id, s32* didAllocate) {
|
||||
|
@ -687,13 +708,13 @@ void* AudioLoad_SyncLoad(u32 tableType, u32 id, s32* didAllocate) {
|
|||
u32 medium;
|
||||
s32 status;
|
||||
uintptr_t romAddr;
|
||||
s32 cachePolicy;
|
||||
void* ret;
|
||||
AudioCacheLoadType cachePolicy;
|
||||
void* mem;
|
||||
u32 realId;
|
||||
|
||||
realId = AudioLoad_GetRealTableIndex(tableType, id);
|
||||
ret = AudioLoad_SearchCaches(tableType, realId);
|
||||
if (ret != NULL) {
|
||||
mem = AudioLoad_SearchCaches(tableType, realId);
|
||||
if (mem != NULL) {
|
||||
*didAllocate = false;
|
||||
status = 2;
|
||||
} else {
|
||||
|
@ -704,38 +725,38 @@ void* AudioLoad_SyncLoad(u32 tableType, u32 id, s32* didAllocate) {
|
|||
cachePolicy = table->entries[id].cachePolicy;
|
||||
romAddr = table->entries[realId].romAddr;
|
||||
switch (cachePolicy) {
|
||||
case 0:
|
||||
ret = AudioHeap_AllocPermanent(tableType, realId, size);
|
||||
if (ret == NULL) {
|
||||
return ret;
|
||||
case CACHE_LOAD_PERMANENT:
|
||||
mem = AudioHeap_AllocPermanent(tableType, realId, size);
|
||||
if (mem == NULL) {
|
||||
return mem;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
ret = AudioHeap_AllocCached(tableType, size, CACHE_PERSISTENT, realId);
|
||||
if (ret == NULL) {
|
||||
return ret;
|
||||
case CACHE_LOAD_PERSISTENT:
|
||||
mem = AudioHeap_AllocCached(tableType, size, CACHE_PERSISTENT, realId);
|
||||
if (mem == NULL) {
|
||||
return mem;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
ret = AudioHeap_AllocCached(tableType, size, CACHE_TEMPORARY, realId);
|
||||
if (ret == NULL) {
|
||||
return ret;
|
||||
case CACHE_LOAD_TEMPORARY:
|
||||
mem = AudioHeap_AllocCached(tableType, size, CACHE_TEMPORARY, realId);
|
||||
if (mem == NULL) {
|
||||
return mem;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
case 4:
|
||||
ret = AudioHeap_AllocCached(tableType, size, CACHE_EITHER, realId);
|
||||
if (ret == NULL) {
|
||||
return ret;
|
||||
case CACHE_LOAD_EITHER:
|
||||
case CACHE_LOAD_EITHER_NOSYNC:
|
||||
mem = AudioHeap_AllocCached(tableType, size, CACHE_EITHER, realId);
|
||||
if (mem == NULL) {
|
||||
return mem;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
*didAllocate = true;
|
||||
if (medium == MEDIUM_UNK) {
|
||||
AudioLoad_SyncDmaUnkMedium(romAddr, ret, size, (s16)table->unkMediumParam);
|
||||
AudioLoad_SyncDmaUnkMedium(romAddr, mem, size, (s16)table->unkMediumParam);
|
||||
} else {
|
||||
AudioLoad_SyncDma(romAddr, ret, size, medium);
|
||||
AudioLoad_SyncDma(romAddr, mem, size, medium);
|
||||
}
|
||||
|
||||
status = cachePolicy == 0 ? 5 : 2;
|
||||
|
@ -755,7 +776,7 @@ void* AudioLoad_SyncLoad(u32 tableType, u32 id, s32* didAllocate) {
|
|||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return mem;
|
||||
}
|
||||
|
||||
u32 AudioLoad_GetRealTableIndex(s32 tableType, u32 id) {
|
||||
|
@ -804,6 +825,10 @@ AudioTable* AudioLoad_GetLoadTable(s32 tableType) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
static_assert(sizeof(Drum) == 0x10, "Drum is incorrect size");
|
||||
static_assert(sizeof(SoundFontSound) == 0x8, "SoundFontSound is incorrect size");
|
||||
static_assert(sizeof(SoundFont) == 0x14, "SoundFont is incorrect size");
|
||||
|
||||
void AudioLoad_RelocateFont(s32 fontId, SoundFontData* mem, RelocInfo* relocInfo) {
|
||||
u32 reloc;
|
||||
u32 reloc2;
|
||||
|
@ -816,16 +841,18 @@ void AudioLoad_RelocateFont(s32 fontId, SoundFontData* mem, RelocInfo* relocInfo
|
|||
s32 numSfx = gAudioContext.soundFonts[fontId].numSfx;
|
||||
void** ptrs = (void**)mem;
|
||||
|
||||
#define BASE_OFFSET(x) (void*)((u32)(x) + (u32)(mem))
|
||||
|
||||
#define BASE_OFFSET(x) (void*)((BEE32((uintptr_t)x)) + (u32)(mem))
|
||||
//#define BASE_OFFSET(x) (void*)(((uintptr_t)x) + (u32)(mem))
|
||||
reloc2 = ptrs[0];
|
||||
if (1) {}
|
||||
|
||||
if ((reloc2 != 0) && (numDrums != 0)) {
|
||||
ptrs[0] = BASE_OFFSET(reloc2);
|
||||
for (i = 0; i < numDrums; i++) {
|
||||
reloc = ((Drum**)ptrs[0])[i];
|
||||
//reloc = (Drum*)ptrs[0] + i;
|
||||
if (reloc != 0) {
|
||||
reloc = BASE_OFFSET(reloc);
|
||||
drum = reloc;
|
||||
((Drum**)ptrs[0])[i] = drum = reloc;
|
||||
if (!drum->loaded) {
|
||||
AudioLoad_RelocateSample(&drum->sound, mem, relocInfo);
|
||||
|
@ -838,7 +865,7 @@ void AudioLoad_RelocateFont(s32 fontId, SoundFontData* mem, RelocInfo* relocInfo
|
|||
}
|
||||
|
||||
reloc2 = ptrs[1];
|
||||
if (1) {}
|
||||
|
||||
if ((reloc2 != 0) && (numSfx != 0)) {
|
||||
ptrs[1] = BASE_OFFSET(reloc2);
|
||||
for (i = 0; i < numSfx; i++) {
|
||||
|
@ -858,6 +885,7 @@ void AudioLoad_RelocateFont(s32 fontId, SoundFontData* mem, RelocInfo* relocInfo
|
|||
|
||||
for (i = 2; i <= 2 + numInstruments - 1; i++) {
|
||||
if (ptrs[i] != NULL) {
|
||||
inst = ptrs[i];
|
||||
ptrs[i] = BASE_OFFSET(ptrs[i]);
|
||||
inst = ptrs[i];
|
||||
if (!inst->loaded) {
|
||||
|
@ -908,6 +936,7 @@ void AudioLoad_SyncDma(u32 devAddr, u8* addr, u32 size, s32 medium) {
|
|||
}
|
||||
|
||||
void AudioLoad_SyncDmaUnkMedium(u32 devAddr, u8* addr, u32 size, s32 unkMediumParam) {
|
||||
return;
|
||||
}
|
||||
|
||||
s32 AudioLoad_Dma(OSIoMesg* mesg, u32 priority, s32 direction, u32 devAddr, void* ramAddr, u32 size,
|
||||
|
@ -940,8 +969,9 @@ s32 AudioLoad_Dma(OSIoMesg* mesg, u32 priority, s32 direction, u32 devAddr, void
|
|||
mesg->dramAddr = ramAddr;
|
||||
mesg->devAddr = devAddr;
|
||||
mesg->size = size;
|
||||
handle->transferInfo.cmdType = 2;
|
||||
sDmaHandler(handle, mesg, direction);
|
||||
memcpy(ramAddr, devAddr, size);
|
||||
//handle->transferInfo.cmdType = 2;
|
||||
//sDmaHandler(handle, mesg, direction);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1154,9 +1184,9 @@ void AudioLoad_Init(void* heap, u32 heapSize) {
|
|||
gAudioContext.aiBuffers[i] = AudioHeap_AllocZeroed(&gAudioContext.audioInitPool, AIBUF_LEN * sizeof(s16));
|
||||
}
|
||||
|
||||
gAudioContext.sequenceTable = (AudioTable*)gSequenceTable;
|
||||
gAudioContext.soundFontTable = (AudioTable*)gSoundFontTable;
|
||||
gAudioContext.sampleBankTable = (AudioTable*)gSampleBankTable;
|
||||
gAudioContext.sequenceTable = (AudioTable*)&gSequenceTable;
|
||||
gAudioContext.soundFontTable = (AudioTable*)&gSoundFontTable;
|
||||
gAudioContext.sampleBankTable = (AudioTable*)&gSampleBankTable;
|
||||
gAudioContext.sequenceFontTable = gSequenceFontTable;
|
||||
gAudioContext.numSequences = gAudioContext.sequenceTable->numEntries;
|
||||
|
||||
|
@ -1164,9 +1194,9 @@ void AudioLoad_Init(void* heap, u32 heapSize) {
|
|||
gAudioContext.resetStatus = 1;
|
||||
|
||||
AudioHeap_ResetStep();
|
||||
AudioLoad_InitTable(gAudioContext.sequenceTable, _AudioseqSegmentRomStart, 0);
|
||||
AudioLoad_InitTable(gAudioContext.soundFontTable, _AudiobankSegmentRomStart, 0);
|
||||
AudioLoad_InitTable(gAudioContext.sampleBankTable, _AudiotableSegmentRomStart, 0);
|
||||
AudioLoad_InitTable(gAudioContext.sequenceTable, Audioseq, 0);
|
||||
AudioLoad_InitTable(gAudioContext.soundFontTable, Audiobank_le, 0);
|
||||
AudioLoad_InitTable(gAudioContext.sampleBankTable, Audiotable, 0);
|
||||
numFonts = gAudioContext.soundFontTable->numEntries;
|
||||
gAudioContext.soundFonts = AudioHeap_Alloc(&gAudioContext.audioInitPool, numFonts * sizeof(SoundFont));
|
||||
|
||||
|
@ -1575,22 +1605,24 @@ void AudioLoad_AsyncDma(AudioAsyncLoad* asyncLoad, u32 size) {
|
|||
}
|
||||
|
||||
void AudioLoad_AsyncDmaUnkMedium(u32 devAddr, void* ramAddr, u32 size, s16 arg3) {
|
||||
int xyz = 0;
|
||||
}
|
||||
|
||||
#define RELOC(v, base) (reloc = (void*)((u32)(v) + (u32)(base)))
|
||||
#define RELOC(v, base) (reloc = (void*)(BEE32((u32)(v)) + (u32)(base)))
|
||||
//#define RELOC(v, base) (reloc = (void*)((u32)(v) + (u32)(base)))
|
||||
|
||||
void AudioLoad_RelocateSample(SoundFontSound* sound, SoundFontData* mem, RelocInfo* relocInfo) {
|
||||
SoundFontSample* sample;
|
||||
void* reloc;
|
||||
|
||||
if ((u32)sound->sample <= 0x80000000) {
|
||||
if (BEE32((u32)sound->sample) <= 0x80000000) {
|
||||
sample = sound->sample = RELOC(sound->sample, mem);
|
||||
if (sample->size != 0 && sample->unk_bit25 != 1) {
|
||||
sample->loop = RELOC(sample->loop, mem);
|
||||
sample->book = RELOC(sample->book, mem);
|
||||
|
||||
// Resolve the sample medium 2-bit bitfield into a real value based on relocInfo.
|
||||
switch (sample->medium) {
|
||||
switch (BEE32(sample->medium)) {
|
||||
case 0:
|
||||
sample->sampleAddr = RELOC(sample->sampleAddr, relocInfo->baseAddr1);
|
||||
sample->medium = relocInfo->medium1;
|
||||
|
@ -1640,7 +1672,6 @@ void AudioLoad_RelocateFontAndPreloadSamples(s32 fontId, SoundFontData* mem, Rel
|
|||
for (i = 0; i < gAudioContext.numUsedSamples; i++) {
|
||||
size += ALIGN16(gAudioContext.usedSamples[i]->size);
|
||||
}
|
||||
if (size && size) {}
|
||||
|
||||
for (i = 0; i < gAudioContext.numUsedSamples; i++) {
|
||||
if (gAudioContext.preloadSampleStackTop == 120) {
|
||||
|
@ -2024,16 +2055,16 @@ void AudioLoad_ScriptLoad(s32 tableType, s32 id, s8* isDone) {
|
|||
|
||||
void AudioLoad_ProcessScriptLoads(void) {
|
||||
u32 temp = 0;
|
||||
u32 sp20;
|
||||
u32 sp20 = 0; // TODO FIX
|
||||
s8* isDone;
|
||||
|
||||
if (osRecvMesg(&sScriptLoadQueue, (OSMesg*)&sp20, OS_MESG_NOBLOCK) != -1) {
|
||||
//if (osRecvMesg(&sScriptLoadQueue, (OSMesg*)&sp20, OS_MESG_NOBLOCK) != -1) { TODO FIX HACK
|
||||
temp = sp20 >> 24;
|
||||
isDone = sScriptLoadDonePointers[temp];
|
||||
if (isDone != NULL) {
|
||||
*isDone = 0;
|
||||
}
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
void AudioLoad_InitScriptLoads(void) {
|
||||
|
|
|
@ -685,7 +685,7 @@ Acmd* AudioSynth_ProcessNote(s32 noteIndex, NoteSubEu* noteSubEu, NoteSynthesisS
|
|||
s32 nTrailingSamplesToIgnore;
|
||||
s32 phi_a1_2;
|
||||
s32 frameIndex;
|
||||
s32 skipBytes;
|
||||
s32 skipBytes;// = 0; // TODO HACK not sure why this isnt being set
|
||||
s32 temp_v1_6;
|
||||
void* buf;
|
||||
s32 nSamplesToDecode;
|
||||
|
@ -698,10 +698,10 @@ Acmd* AudioSynth_ProcessNote(s32 noteIndex, NoteSubEu* noteSubEu, NoteSynthesisS
|
|||
s32 phi_s4;
|
||||
s32 nFirstFrameSamplesToIgnore;
|
||||
s32 pad2[7];
|
||||
s32 frameSize;
|
||||
s32 frameSize = 0; // TODO HACK not sure why this isnt being set
|
||||
s32 nFramesToDecode;
|
||||
s32 skipInitialSamples;
|
||||
s32 sampleDataStart;
|
||||
s32 skipInitialSamples = 16; // TODO HACK not sure why this isnt being set
|
||||
s32 sampleDataStart = 0; // TODO HACK not sure why this isnt being set
|
||||
u8* sampleData;
|
||||
s32 nParts;
|
||||
s32 curPart;
|
||||
|
@ -795,9 +795,7 @@ Acmd* AudioSynth_ProcessNote(s32 noteIndex, NoteSubEu* noteSubEu, NoteSynthesisS
|
|||
gAudioContext.curLoadedBook = audioFontSample->book->book;
|
||||
break;
|
||||
}
|
||||
if (1) {}
|
||||
if (1) {}
|
||||
if (1) {}
|
||||
|
||||
nEntries = 16 * audioFontSample->book->order * audioFontSample->book->npredictors;
|
||||
aLoadADPCM(cmd++, nEntries, gAudioContext.curLoadedBook);
|
||||
}
|
||||
|
@ -869,6 +867,8 @@ Acmd* AudioSynth_ProcessNote(s32 noteIndex, NoteSubEu* noteSubEu, NoteSynthesisS
|
|||
goto skip;
|
||||
case CODEC_REVERB:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (nFramesToDecode != 0) {
|
||||
|
|
|
@ -16,6 +16,10 @@
|
|||
#include "def/createmesgqueue.h"
|
||||
#include "def/recvmesg.h"
|
||||
|
||||
#include "redef_msgqueue.h"
|
||||
|
||||
u32 osGetCount(void);
|
||||
|
||||
#define SAMPLES_TO_OVERPRODUCE 0x10
|
||||
#define EXTRA_BUFFERED_AI_SAMPLES_TARGET 0x80
|
||||
|
||||
|
@ -91,7 +95,7 @@ AudioTask* func_800E5000(void) {
|
|||
|
||||
if (gAudioContext.resetTimer < 16) {
|
||||
if (gAudioContext.aiBufLengths[index] != 0) {
|
||||
// TODO FIX osAiSetNextBuffer(gAudioContext.aiBuffers[index], gAudioContext.aiBufLengths[index] * 4);
|
||||
osAiSetNextBuffer(gAudioContext.aiBuffers[index], gAudioContext.aiBufLengths[index] * 4);
|
||||
if (gAudioContext.aiBuffers[index]) {}
|
||||
if (gAudioContext.aiBufLengths[index]) {}
|
||||
}
|
||||
|
@ -167,9 +171,6 @@ AudioTask* func_800E5000(void) {
|
|||
if (gAudioContext.resetStatus == 0) {
|
||||
// msg = 0000RREE R = read pos, E = End Pos
|
||||
while (osRecvMesg(gAudioContext.cmdProcQueueP, (OSMesg*)&sp4C, OS_MESG_NOBLOCK) != -1) {
|
||||
if (1) {}
|
||||
if (1) {}
|
||||
if (1) {}
|
||||
Audio_ProcessCmds(sp4C);
|
||||
j++;
|
||||
}
|
||||
|
@ -180,7 +181,7 @@ AudioTask* func_800E5000(void) {
|
|||
|
||||
gAudioContext.curAbiCmdBuf =
|
||||
AudioSynth_Update(gAudioContext.curAbiCmdBuf, &abiCmdCnt, currAiBuffer, gAudioContext.aiBufLengths[index]);
|
||||
gAudioContext.audioRandom = (gAudioContext.audioRandom + gAudioContext.totalTaskCnt); // TODO FIX *osGetCount();
|
||||
gAudioContext.audioRandom = (gAudioContext.audioRandom + gAudioContext.totalTaskCnt) * osGetCount();
|
||||
gAudioContext.audioRandom =
|
||||
gAudioContext.aiBuffers[index][gAudioContext.totalTaskCnt & 0xFF] + gAudioContext.audioRandom;
|
||||
gWaveSamples[8] = (s16*)(((u8*)func_800E4FE0) + (gAudioContext.audioRandom & 0xFFF0));
|
||||
|
@ -373,8 +374,8 @@ void Audio_InitMesgQueuesInternal(void) {
|
|||
void Audio_QueueCmd(u32 opArgs, void** data) {
|
||||
AudioCmd* cmd = &gAudioContext.cmdBuf[gAudioContext.cmdWrPos & 0xFF];
|
||||
|
||||
cmd->opArgs = opArgs;
|
||||
cmd->data = *data;
|
||||
cmd->opArgs = opArgs; // BE32(opArgs);
|
||||
cmd->data = (u32)*data; // BE32((u32)*data); // TODO FIX broke in 64 bit
|
||||
|
||||
gAudioContext.cmdWrPos++;
|
||||
|
||||
|
@ -527,7 +528,7 @@ s32 func_800E5EDC(void) {
|
|||
}
|
||||
|
||||
void func_800E5F34(void) {
|
||||
return; // TODO FIX HACK
|
||||
return; // TODO FIX HACK IGNORE
|
||||
// macro?
|
||||
// clang-format off
|
||||
s32 chk = -1; s32 sp28; do {} while (osRecvMesg(gAudioContext.audioResetQueueP, (OSMesg*)&sp28, OS_MESG_NOBLOCK) != chk);
|
||||
|
@ -826,7 +827,7 @@ s32 func_800E66C0(s32 arg0) {
|
|||
u32 Audio_NextRandom(void) {
|
||||
static u32 audRand = 0x12345678;
|
||||
|
||||
// TODO FIX audRand = ((osGetCount() + 0x1234567) * (audRand + gAudioContext.totalTaskCnt));
|
||||
audRand = ((osGetCount() + 0x1234567) * (audRand + gAudioContext.totalTaskCnt));
|
||||
audRand += gAudioContext.audioRandom;
|
||||
return audRand;
|
||||
}
|
||||
|
|
|
@ -3043,7 +3043,6 @@ void Audio_ClearSariaBgmAtPos(Vec3f* pos) {
|
|||
* equally between the two bgm channels. Split based on note priority
|
||||
*/
|
||||
void Audio_SplitBgmChannels(s8 volSplit) {
|
||||
return; // TODO FIX
|
||||
u8 volume;
|
||||
u8 notePriority;
|
||||
u16 channelBits;
|
||||
|
@ -3293,7 +3292,6 @@ void func_800F5C2C(void) {
|
|||
}
|
||||
|
||||
void Audio_PlayFanfare(u16 seqId) {
|
||||
return; // TODO FIX
|
||||
u16 sp26;
|
||||
u32 sp20;
|
||||
u8* sp1C;
|
||||
|
|
|
@ -42,13 +42,13 @@ char D_80133398[] = " L";
|
|||
|
||||
// bss
|
||||
static SoundRequest sSoundRequests[0x100];
|
||||
static SoundBankEntry D_8016BAD0[9];
|
||||
static SoundBankEntry D_8016BC80[12];
|
||||
static SoundBankEntry D_8016BEC0[22];
|
||||
static SoundBankEntry D_8016C2E0[20];
|
||||
static SoundBankEntry D_8016C6A0[8];
|
||||
static SoundBankEntry D_8016C820[3];
|
||||
static SoundBankEntry D_8016C8B0[5];
|
||||
static SoundBankEntry gSoundBankPlayer[9];
|
||||
static SoundBankEntry gSoundBankItem[12];
|
||||
static SoundBankEntry gSoundBankEnvironment[22];
|
||||
static SoundBankEntry gSoundBankEnemy[20];
|
||||
static SoundBankEntry gSoundBankSystem[8];
|
||||
static SoundBankEntry gSoundBankOcarina[3];
|
||||
static SoundBankEntry gSoundBankVoice[5];
|
||||
static u8 sSoundBankListEnd[7];
|
||||
static u8 sSoundBankFreeListStart[7];
|
||||
static u8 sSoundBankUnused[7];
|
||||
|
@ -83,12 +83,12 @@ u8 sSoundRequestReadIndex = 0;
|
|||
* 6 : Voice Bank size 5
|
||||
*/
|
||||
SoundBankEntry* gSoundBanks[7] = {
|
||||
D_8016BAD0, D_8016BC80, D_8016BEC0, D_8016C2E0, D_8016C6A0, D_8016C820, D_8016C8B0,
|
||||
gSoundBankPlayer, gSoundBankItem, gSoundBankEnvironment, gSoundBankEnemy, gSoundBankSystem, gSoundBankOcarina, gSoundBankVoice,
|
||||
};
|
||||
|
||||
u8 sBankSizes[ARRAY_COUNT(gSoundBanks)] = {
|
||||
ARRAY_COUNT(D_8016BAD0), ARRAY_COUNT(D_8016BC80), ARRAY_COUNT(D_8016BEC0), ARRAY_COUNT(D_8016C2E0),
|
||||
ARRAY_COUNT(D_8016C6A0), ARRAY_COUNT(D_8016C820), ARRAY_COUNT(D_8016C8B0),
|
||||
ARRAY_COUNT(gSoundBankPlayer), ARRAY_COUNT(gSoundBankItem), ARRAY_COUNT(gSoundBankEnvironment), ARRAY_COUNT(gSoundBankEnemy),
|
||||
ARRAY_COUNT(gSoundBankSystem), ARRAY_COUNT(gSoundBankOcarina), ARRAY_COUNT(gSoundBankVoice),
|
||||
};
|
||||
|
||||
u8 gSfxChannelLayout = 0;
|
||||
|
@ -112,7 +112,6 @@ u8 gAudioSfxSwapOff = 0;
|
|||
u8 D_801333F8 = 0;
|
||||
|
||||
void Audio_SetSoundBanksMute(u16 muteMask) {
|
||||
return; // TODO FIX
|
||||
u8 bankId;
|
||||
|
||||
for (bankId = 0; bankId < ARRAY_COUNT(gSoundBanks); bankId++) {
|
||||
|
@ -126,14 +125,12 @@ void Audio_SetSoundBanksMute(u16 muteMask) {
|
|||
}
|
||||
|
||||
void Audio_QueueSeqCmdMute(u8 channelIdx) {
|
||||
return; // TODO FIX
|
||||
D_801333D0 |= (1 << channelIdx);
|
||||
Audio_SetVolScale(SEQ_PLAYER_BGM_MAIN, 2, 0x40, 0xF);
|
||||
Audio_SetVolScale(SEQ_PLAYER_BGM_SUB, 2, 0x40, 0xF);
|
||||
}
|
||||
|
||||
void Audio_ClearBGMMute(u8 channelIdx) {
|
||||
return; // TODO FIX
|
||||
D_801333D0 &= ((1 << channelIdx) ^ 0xFFFF);
|
||||
if (D_801333D0 == 0) {
|
||||
Audio_SetVolScale(SEQ_PLAYER_BGM_MAIN, 2, 0x7F, 0xF);
|
||||
|
@ -142,7 +139,6 @@ void Audio_ClearBGMMute(u8 channelIdx) {
|
|||
}
|
||||
|
||||
void Audio_PlaySoundGeneral(u16 sfxId, Vec3f* pos, u8 token, f32* freqScale, f32* vol, s8* reverbAdd) {
|
||||
return; // TODO FIX
|
||||
u8 i;
|
||||
SoundRequest* req;
|
||||
|
||||
|
@ -178,7 +174,6 @@ void Audio_PlaySoundGeneral(u16 sfxId, Vec3f* pos, u8 token, f32* freqScale, f32
|
|||
}
|
||||
|
||||
void Audio_RemoveMatchingSoundRequests(u8 aspect, SoundBankEntry* cmp) {
|
||||
return; // TODO FIX
|
||||
SoundRequest* req;
|
||||
s32 remove;
|
||||
u8 i = sSoundRequestReadIndex;
|
||||
|
@ -225,7 +220,6 @@ void Audio_RemoveMatchingSoundRequests(u8 aspect, SoundBankEntry* cmp) {
|
|||
}
|
||||
|
||||
void Audio_ProcessSoundRequest(void) {
|
||||
return; // TODO FIX
|
||||
u16 sfxId;
|
||||
u8 count;
|
||||
u8 index;
|
||||
|
@ -328,7 +322,6 @@ void Audio_ProcessSoundRequest(void) {
|
|||
}
|
||||
|
||||
void Audio_RemoveSoundBankEntry(u8 bankId, u8 entryIndex) {
|
||||
return; // TODO FIX
|
||||
SoundBankEntry* entry = &gSoundBanks[bankId][entryIndex];
|
||||
u8 i;
|
||||
|
||||
|
@ -356,7 +349,6 @@ void Audio_RemoveSoundBankEntry(u8 bankId, u8 entryIndex) {
|
|||
}
|
||||
|
||||
void Audio_ChooseActiveSounds(u8 bankId) {
|
||||
return; // TODO FIX
|
||||
u8 numChosenSounds;
|
||||
u8 numChannels;
|
||||
u8 entryIndex;
|
||||
|
@ -513,7 +505,6 @@ void Audio_ChooseActiveSounds(u8 bankId) {
|
|||
}
|
||||
|
||||
void Audio_PlayActiveSounds(u8 bankId) {
|
||||
return; // TODO FIX
|
||||
u8 entryIndex;
|
||||
SequenceChannel* channel;
|
||||
SoundBankEntry* entry;
|
||||
|
@ -574,7 +565,6 @@ void Audio_PlayActiveSounds(u8 bankId) {
|
|||
}
|
||||
|
||||
void Audio_StopSfxByBank(u8 bankId) {
|
||||
return; // TODO FIX
|
||||
SoundBankEntry* entry;
|
||||
s32 pad;
|
||||
SoundBankEntry cmp;
|
||||
|
@ -595,7 +585,6 @@ void Audio_StopSfxByBank(u8 bankId) {
|
|||
}
|
||||
|
||||
void func_800F8884(u8 bankId, Vec3f* pos) {
|
||||
return; // TODO FIX HACK
|
||||
SoundBankEntry* entry;
|
||||
u8 entryIndex = gSoundBanks[bankId][0].next;
|
||||
u8 prevEntryIndex = 0;
|
||||
|
@ -692,7 +681,6 @@ void Audio_StopSfxByTokenAndId(u8 token, u16 sfxId) {
|
|||
}
|
||||
|
||||
void Audio_StopSfxById(u32 sfxId) {
|
||||
return; // TODO FIX
|
||||
SoundBankEntry* entry;
|
||||
u8 entryIndex = gSoundBanks[SFX_BANK(sfxId)][0].next;
|
||||
u8 prevEntryIndex = 0;
|
||||
|
@ -717,7 +705,6 @@ void Audio_StopSfxById(u32 sfxId) {
|
|||
}
|
||||
|
||||
void Audio_ProcessSoundRequests(void) {
|
||||
return; // TODO FIX
|
||||
while (sSoundRequestWriteIndex != sSoundRequestReadIndex) {
|
||||
Audio_ProcessSoundRequest();
|
||||
sSoundRequestReadIndex++;
|
||||
|
@ -725,7 +712,6 @@ void Audio_ProcessSoundRequests(void) {
|
|||
}
|
||||
|
||||
void Audio_SetUnusedBankLerp(u8 bankId, u8 target, u16 delay) {
|
||||
return; // TODO FIX
|
||||
if (delay == 0) {
|
||||
delay++;
|
||||
}
|
||||
|
@ -735,7 +721,6 @@ void Audio_SetUnusedBankLerp(u8 bankId, u8 target, u16 delay) {
|
|||
}
|
||||
|
||||
void Audio_StepUnusedBankLerp(u8 bankId) {
|
||||
return; // TODO FIX
|
||||
if (sUnusedBankLerp[bankId].remainingFrames != 0) {
|
||||
sUnusedBankLerp[bankId].remainingFrames--;
|
||||
if (sUnusedBankLerp[bankId].remainingFrames != 0) {
|
||||
|
@ -747,7 +732,6 @@ void Audio_StepUnusedBankLerp(u8 bankId) {
|
|||
}
|
||||
|
||||
void func_800F8F88(void) {
|
||||
return; // TODO FIX
|
||||
u8 bankId;
|
||||
|
||||
if (IS_SEQUENCE_CHANNEL_VALID(gAudioContext.seqPlayers[SEQ_PLAYER_SFX].channels[0])) {
|
||||
|
@ -761,7 +745,6 @@ void func_800F8F88(void) {
|
|||
}
|
||||
|
||||
u8 Audio_IsSfxPlaying(u32 sfxId) {
|
||||
return false; // TODO FIX
|
||||
SoundBankEntry* entry;
|
||||
u8 entryIndex = gSoundBanks[SFX_BANK(sfxId)][0].next;
|
||||
|
||||
|
@ -776,7 +759,6 @@ u8 Audio_IsSfxPlaying(u32 sfxId) {
|
|||
}
|
||||
|
||||
void Audio_ResetSounds(void) {
|
||||
return; // TODO FIX
|
||||
u8 bankId;
|
||||
u8 i;
|
||||
u8 entryIndex;
|
||||
|
|
|
@ -2471,9 +2471,7 @@ void Message_DrawMain(GlobalContext* globalCtx, Gfx** p) {
|
|||
case MSGMODE_DISPLAY_SONG_PLAYED:
|
||||
case MSGMODE_SONG_DEMONSTRATION:
|
||||
msgCtx->ocarinaStaff = Audio_OcaGetDisplayingStaff();
|
||||
#ifndef ENABLE_AUDIO
|
||||
msgCtx->ocarinaStaff->state = 0; // TODO FIX HACK
|
||||
#endif
|
||||
|
||||
if (msgCtx->ocarinaStaff->state == 0) {
|
||||
if (msgCtx->msgMode == MSGMODE_DISPLAY_SONG_PLAYED) {
|
||||
msgCtx->msgMode = MSGMODE_DISPLAY_SONG_PLAYED_TEXT_BEGIN;
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#define ENABLE_SDL_AUDIO
|
||||
#if defined(ENABLE_SDL_AUDIO)
|
||||
|
||||
#ifdef __MINGW32__
|
||||
|
|
|
@ -1,16 +1 @@
|
|||
#include "global.h"
|
||||
|
||||
u8 sSeqCmdWrPos[0x4] = {0x00, 0x00, 0x00, 0x00};
|
||||
|
||||
u8 sSeqCmdRdPos[0x4] = {0x00, 0x00, 0x00, 0x00};
|
||||
|
||||
u8 D_80133408 = 0x00;
|
||||
|
||||
u8 D_8013340C = 0x01;
|
||||
|
||||
u8 D_80133410[0x4] = {0x00, 0x01, 0x02, 0x03};
|
||||
|
||||
u8 gAudioSpecId = 0x00;
|
||||
|
||||
u8 D_80133418 = 0x00;
|
||||
|
||||
#include "assets/code_800F9280.h"
|
||||
|
|
|
@ -2,12 +2,16 @@
|
|||
#include "ultra64/types.h"
|
||||
#include "ultra64/vi.h"
|
||||
#include "z64audio.h"
|
||||
#include "audiomgr.h"
|
||||
#include "z_prenmi_buff.h"
|
||||
#include "ultra64/rcp.h"
|
||||
#include "ultra64/exception.h"
|
||||
#include "def/sys_cfb.h"
|
||||
#include "def/code_800FC620.h"
|
||||
#include "def/z_debug.h"
|
||||
#include "audiomgr.h"
|
||||
#include "def/code_800EC960.h"
|
||||
#include "def/audioMgr.h"
|
||||
|
||||
//f32 qNaN0x3FFFFF;
|
||||
f32 qNaN0x10000;
|
||||
|
@ -24,6 +28,8 @@ s32 gScreenHeight = SCREEN_HEIGHT;
|
|||
u32 gSystemHeapSize = 0;
|
||||
#endif
|
||||
|
||||
AudioMgr gAudioMgr;
|
||||
|
||||
unk_D_8016E750 D_8016E750[4];
|
||||
u8 osAppNmiBuffer[0x40];
|
||||
UNK_TYPE D_06000000;
|
||||
|
@ -38,8 +44,6 @@ u32 osRomBase;
|
|||
|
||||
u32 osMemSize = 0x800000;
|
||||
|
||||
AudioSpec gAudioSpecs[18];
|
||||
|
||||
void (*D_801755D0)(void) = NULL;
|
||||
|
||||
void xxxDebugDisplay_Init(void)
|
||||
|
@ -170,6 +174,8 @@ int main() {
|
|||
|
||||
//Main_LogSystemHeap();
|
||||
|
||||
AudioMgr_Init(&gAudioMgr, NULL, NULL, 0xA, NULL, NULL);
|
||||
|
||||
|
||||
/*StackCheck_Init(&sGraphStackInfo, sGraphStack, sGraphStack + sizeof(sGraphStack), 0, 0x100, "graph");
|
||||
osCreateThread(&sGraphThread, 4, Graph_ThreadEntry, arg, sGraphStack + sizeof(sGraphStack), Z_PRIORITY_GRAPH);
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#define WIN32_LEAN_AND_MEAN
|
||||
#define ENABLE_OPENGL
|
||||
#define DISABLE_AUDIO
|
||||
#define USE_GLIDEN64
|
||||
#include "window.h"
|
||||
|
||||
|
@ -144,10 +143,12 @@ s8 D_8032C648;
|
|||
extern AudioAPI audio_sdl;
|
||||
AudioAPI* audio_api = nullptr;
|
||||
|
||||
/*
|
||||
#ifdef ENABLE_SDL_AUDIO
|
||||
#else
|
||||
AudioAPI audio_sdl;
|
||||
#endif
|
||||
*/
|
||||
#endif
|
||||
|
||||
#ifdef USE_CF3D
|
||||
|
@ -254,6 +255,32 @@ extern "C" {
|
|||
void hid_update();
|
||||
}
|
||||
|
||||
extern void* gAudioBuffer;
|
||||
extern u32 gAudioBufferSize;
|
||||
extern "C" {
|
||||
void AudioMgr_HandleRetraceNULL();
|
||||
}
|
||||
|
||||
void audio_thread()
|
||||
{
|
||||
int samples_left = audio_api->buffered();
|
||||
u32 num_audio_samples = samples_left < audio_api->get_desired_buffered() ? 544 : 528;
|
||||
|
||||
s16 audio_buffer[544 * 2 * 2];
|
||||
for(int i = 0; i < 2; i++)
|
||||
{
|
||||
create_next_audio_buffer(audio_buffer + i * (num_audio_samples * 2), num_audio_samples);
|
||||
}
|
||||
|
||||
AudioMgr_HandleRetraceNULL();
|
||||
|
||||
if(audio_api /* && !config().game().disableSound()*/)
|
||||
{
|
||||
//audio_api->play((const u8*)audio_buffer, 2 * num_audio_samples * 4);
|
||||
audio_api->play((const u8*)gAudioBuffer, gAudioBufferSize);
|
||||
}
|
||||
}
|
||||
|
||||
void main_func(void)
|
||||
{
|
||||
sm64::log("initializing app\n");
|
||||
|
@ -392,6 +419,7 @@ extern "C" {
|
|||
gWindow->setTargetFrameRate(60 / frameRateDivisor());
|
||||
gWindow->end_frame();
|
||||
}
|
||||
audio_thread();
|
||||
}
|
||||
|
||||
float gfx_ar_ratio()
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,6 +1 @@
|
|||
#include "global.h"
|
||||
|
||||
u8 D_80009320[0xD0] = {0x09, 0x00, 0x04, 0x19, 0x20, 0x01, 0x0F, 0xC0, 0x8C, 0x22, 0x00, 0x10, 0x20, 0x03, 0x0F, 0x7F, 0x20, 0x07, 0x10, 0x80, 0x40, 0x87, 0x00, 0x00, 0x40, 0x82, 0x08, 0x00, 0x40, 0x83, 0x10, 0x00, 0x40, 0x04, 0x30, 0x00, 0x14, 0x80, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x04, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x00, 0x08, 0x40, 0x80, 0x38, 0x00, 0x40, 0x08, 0x20, 0x00, 0x31, 0x08, 0x00, 0x80, 0x15, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x03, 0xE0, 0x00, 0x08, 0x40, 0x80, 0x38, 0x00, 0x34, 0x08, 0x52, 0x00, 0x40, 0x88, 0x20, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x8C, 0x22, 0x00, 0x04, 0x30, 0x42, 0x00, 0x02, 0x10, 0x40, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x04, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x40, 0x02, 0x58, 0x00, 0x30, 0x42, 0x01, 0x00, 0x1C, 0x40, 0xFF, 0xED, 0x00, 0x00, 0x00, 0x00, 0x8C, 0x22, 0x00, 0x18, 0x8C, 0x23, 0x00, 0x1C, 0x20, 0x63, 0xFF, 0xFF, 0x40, 0x1E, 0x28, 0x00, 0x17, 0xC0, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x40, 0x80, 0x00, 0x00, 0x40, 0x82, 0x08, 0x00, 0x40, 0x83, 0x10, 0x00, 0x40, 0x04, 0x30, 0x00, 0x14, 0x80, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x04, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x04, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
|
||||
u8 D_800093F0[0x20] = {0xE8, 0x0C, 0x20, 0x01, 0x34, 0x01, 0x40, 0x00, 0x40, 0x81, 0x20, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x04, 0x25, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
|
||||
#include "assets/rsp_boot.h"
|
||||
|
|
|
@ -47,6 +47,13 @@ typedef s32 OSPri;
|
|||
#define OS_CLOCK_RATE 62500000LL
|
||||
u64 osClockRate = OS_CLOCK_RATE;
|
||||
|
||||
extern "C"
|
||||
{
|
||||
u32 osGetCount(void);
|
||||
s32 osAiSetNextBuffer(void* buf, u32 size);
|
||||
s32 osAiSetFrequency(u32 frequency);
|
||||
}
|
||||
|
||||
s32 osPiStartDma(struct OSIoMesg* mb, UNUSED s32 priority, UNUSED s32 direction, uintptr_t devAddr, void* vAddr, size_t nbytes, struct OSMesgQueue* mq)
|
||||
{
|
||||
memcpy(vAddr, (const void*)devAddr, nbytes);
|
||||
|
@ -98,30 +105,6 @@ u32 osGetCount(void)
|
|||
return counter++;
|
||||
}
|
||||
|
||||
s32 osAiSetFrequency(u32 freq)
|
||||
{
|
||||
u32 a1;
|
||||
s32 a2;
|
||||
u32 D_8033491C;
|
||||
|
||||
D_8033491C = 0x02E6D354;
|
||||
|
||||
a1 = D_8033491C / (float)freq + .5f;
|
||||
|
||||
if(a1 < 0x84)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
a2 = (a1 / 66) & 0xff;
|
||||
if(a2 > 16)
|
||||
{
|
||||
a2 = 16;
|
||||
}
|
||||
|
||||
return D_8033491C / (s32)a1;
|
||||
}
|
||||
|
||||
s32 osEepromProbe(UNUSED OSMesgQueue* mq)
|
||||
{
|
||||
return 1;
|
||||
|
@ -427,3 +410,68 @@ extern "C" {
|
|||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#include "ultra64/rcp.h"
|
||||
|
||||
void* gAudioBuffer = nullptr;
|
||||
u32 gAudioBufferSize = 0;
|
||||
|
||||
s32 osAiSetNextBuffer(void* buf, u32 size)
|
||||
{
|
||||
static u8 D_80130500 = false;
|
||||
uintptr_t bufAdjusted = (uintptr_t)buf;
|
||||
s32 status;
|
||||
|
||||
if(D_80130500)
|
||||
{
|
||||
bufAdjusted = (uintptr_t)buf - 0x2000;
|
||||
}
|
||||
if((((uintptr_t)buf + size) & 0x1FFF) == 0)
|
||||
{
|
||||
D_80130500 = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
D_80130500 = false;
|
||||
}
|
||||
|
||||
// Originally a call to __osAiDeviceBusy
|
||||
/*status = HW_REG(AI_STATUS_REG, s32);
|
||||
if(status & AI_STATUS_AI_FULL)
|
||||
{
|
||||
return -1;
|
||||
}*/
|
||||
|
||||
// OS_K0_TO_PHYSICAL replaces osVirtualToPhysical, this replacement
|
||||
// assumes that only KSEG0 addresses are given
|
||||
//HW_REG(AI_DRAM_ADDR_REG, uintptr_t) = bufAdjusted;
|
||||
//HW_REG(AI_LEN_REG, u32) = size;
|
||||
gAudioBuffer = (void*)bufAdjusted;
|
||||
gAudioBufferSize = size;
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" s32 osViClock;
|
||||
|
||||
s32 osAiSetFrequency(u32 frequency)
|
||||
{
|
||||
u8 bitrate;
|
||||
f32 dacRateF = ((f32)osViClock / frequency) + 0.5f;
|
||||
u32 dacRate = dacRateF;
|
||||
|
||||
if(dacRate < 132)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
bitrate = (dacRate / 66);
|
||||
|
||||
if(bitrate > 16)
|
||||
{
|
||||
bitrate = 16;
|
||||
}
|
||||
|
||||
//HW_REG(AI_DACRATE_REG, u32) = dacRate - 1;
|
||||
//HW_REG(AI_BITRATE_REG, u32) = bitrate - 1;
|
||||
return osViClock / (s32)dacRate;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@ import os.path
|
|||
from pathlib import Path
|
||||
import sys
|
||||
|
||||
basedir = os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__.replace('\\', '/'))), '../'))
|
||||
|
||||
magic = '// GENERATED'
|
||||
includeHeader = '#include "asset_common.h"'
|
||||
removeHeaders = ['#include "z64animation.h"', '#include "z64bgcheck.h"', '#include "asset_common.h"']
|
||||
|
@ -71,6 +73,12 @@ for path in files:
|
|||
if '/text/' in x:
|
||||
continue
|
||||
|
||||
if '/audio/' in x:
|
||||
continue
|
||||
|
||||
if len(x.split('/')) <= 2: # skip root assets directory files
|
||||
continue
|
||||
|
||||
if '/overlays/' in x:
|
||||
skip = True
|
||||
|
||||
|
|
|
@ -5,7 +5,12 @@ from pathlib import Path
|
|||
|
||||
basedir = os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__.replace('\\', '/'))), '../'))
|
||||
|
||||
segments = {'src/code/z_vr_box_assets.h': [
|
||||
try:
|
||||
os.makedirs(os.path.join(basedir, 'assets/audio/'))
|
||||
except:
|
||||
pass
|
||||
|
||||
segments = {'assets/z_vr_box_assets.h': [
|
||||
'vr_SP1a_static',
|
||||
'vr_SP1a_pal_static',
|
||||
'vr_cloud2_static',
|
||||
|
@ -57,7 +62,7 @@ segments = {'src/code/z_vr_box_assets.h': [
|
|||
'vr_KR3VR_static',
|
||||
'vr_KR3VR_pal_static'
|
||||
],
|
||||
'src/code/z_scene_table_assets.h': [
|
||||
'assets/z_scene_table_assets.h': [
|
||||
'g_pn_01',
|
||||
'g_pn_02',
|
||||
'g_pn_03',
|
||||
|
@ -116,13 +121,13 @@ segments = {'src/code/z_vr_box_assets.h': [
|
|||
'g_pn_56',
|
||||
'g_pn_57'
|
||||
],
|
||||
'src/code/z_message_PAL_assets.h': [
|
||||
'assets/z_message_PAL_assets.h': [
|
||||
'nes_message_data_static',
|
||||
'ger_message_data_static',
|
||||
'fra_message_data_static',
|
||||
'staff_message_data_static'
|
||||
],
|
||||
'src/code/z_kankyo_assets.h': [
|
||||
'assets/z_kankyo_assets.h': [
|
||||
'vr_fine0_static',
|
||||
'vr_fine0_pal_static',
|
||||
'vr_fine1_static',
|
||||
|
@ -141,7 +146,7 @@ segments = {'src/code/z_vr_box_assets.h': [
|
|||
'vr_cloud3_pal_static',
|
||||
'vr_holy0_static',
|
||||
'vr_holy0_pal_static'],
|
||||
'src/code/z_scene_assets.h': [
|
||||
'assets/z_scene_assets.h': [
|
||||
'elf_message_field',
|
||||
'elf_message_ydan',
|
||||
'gameplay_keep',
|
||||
|
@ -523,7 +528,10 @@ segments = {'src/code/z_vr_box_assets.h': [
|
|||
'object_door_killer',
|
||||
'object_ouke_haka',
|
||||
'object_timeblock',
|
||||
'object_zl4']
|
||||
'object_zl4'],
|
||||
'assets/audio/bank.h': ['Audiobank_le'],
|
||||
'assets/audio/seq.h': ['Audioseq'],
|
||||
'assets/audio/table.h': ['Audiotable']
|
||||
}
|
||||
|
||||
def writeFile(path, buffer):
|
||||
|
@ -587,6 +595,30 @@ def serializeU16(name, doswap = True):
|
|||
|
||||
return 'static const u16 %s[0x%X] = { %s };\n' % (name, len(buffer) // n, ', '.join(lst))
|
||||
|
||||
def serializeU32(name, doswap = True):
|
||||
path = os.path.join('baserom', name)
|
||||
path = os.path.abspath(os.path.join(basedir, path))
|
||||
lst = []
|
||||
|
||||
with open(path, 'rb') as f:
|
||||
buffer = f.read()
|
||||
n = 4
|
||||
a = [buffer[i:i+n] for i in range(0, len(buffer), n)]
|
||||
|
||||
|
||||
if doswap:
|
||||
for i in range(0, len(a), 4):
|
||||
swap = a[i]
|
||||
a[i] = a[i+1]
|
||||
a[i+1] = swap
|
||||
|
||||
|
||||
for b in a:
|
||||
b = int.from_bytes(b, byteorder='big')
|
||||
lst.append(('0x%%%d.%dX' % (n * 2, n * 2)) % b)
|
||||
|
||||
return 'static const u32 %s[0x%X] = { %s };\n' % (name, len(buffer) // n, ', '.join(lst))
|
||||
|
||||
|
||||
for output, files in segments.items():
|
||||
print('processing %s' % output)
|
||||
|
|
453
tools/extract_z64_variables.py
Normal file
453
tools/extract_z64_variables.py
Normal file
|
@ -0,0 +1,453 @@
|
|||
import struct
|
||||
import json
|
||||
|
||||
def reverse(s):
|
||||
return s[::-1]
|
||||
return int.from_bytes(s, byteorder='big').to_bytes(len(s), 'little')
|
||||
|
||||
def readConvert(f, size, swap = True):
|
||||
pos = f.tell()
|
||||
r = f.read(size)
|
||||
|
||||
if len(r) != size:
|
||||
raise IOError('failed to read %d bytes, got %d' % (size, len(r)))
|
||||
|
||||
return r
|
||||
|
||||
def readS8(f, swap = True):
|
||||
return int.from_bytes(readConvert(f, 1, swap), byteorder='big', signed=True)
|
||||
|
||||
def readU8(f, swap = True):
|
||||
return int.from_bytes(readConvert(f, 1, swap), byteorder='big', signed=False)
|
||||
|
||||
def readS16(f, swap = True):
|
||||
return int.from_bytes(readConvert(f, 2, swap), byteorder='big', signed=True)
|
||||
|
||||
def readU32(f, swap = True):
|
||||
return int.from_bytes(readConvert(f, 4, swap), byteorder='big', signed=False)
|
||||
|
||||
def readS32(f, swap = True):
|
||||
return int.from_bytes(readConvert(f, 4, swap), byteorder='big', signed=True)
|
||||
|
||||
def readFloat(f, swap = True):
|
||||
b = readConvert(f, 4, swap)
|
||||
return float(struct.unpack('>f', b)[0])
|
||||
|
||||
|
||||
class ConvFile:
|
||||
def __init__(self, path, mode):
|
||||
self.path = path
|
||||
self.i = open(path, 'rb')
|
||||
self.o = open(path + '_le', 'wb')
|
||||
if True:
|
||||
self.seek(0)
|
||||
buffer = self.i.read()
|
||||
self.o.write(buffer)
|
||||
else:
|
||||
self.seek(0)
|
||||
buffer = self.i.read()
|
||||
self.o.write(b'\xFF' * len(buffer))
|
||||
self.seek(0)
|
||||
|
||||
self.writes = {}
|
||||
|
||||
def __enter__(self):
|
||||
return self
|
||||
|
||||
def __exit__(self, type, value, tb):
|
||||
self.close()
|
||||
|
||||
def seek(self, offset):
|
||||
self.i.seek(offset)
|
||||
self.o.seek(offset)
|
||||
self.pos = offset
|
||||
|
||||
def tell(self):
|
||||
return self.i.tell()
|
||||
|
||||
def close(self):
|
||||
f = self.o
|
||||
self.i.close()
|
||||
self.o.close()
|
||||
|
||||
def read(self, n, swap = True):
|
||||
if n == 0:
|
||||
raise IOError('null read')
|
||||
pos = self.i.tell()
|
||||
self.seek(pos)
|
||||
|
||||
r = self.i.read(n)
|
||||
|
||||
if len(r) != n:
|
||||
raise IOError('incomplete read: %d, expected %d' % (len(r), n))
|
||||
|
||||
if swap:
|
||||
self.write2(reverse(r), n)
|
||||
else:
|
||||
self.write2(r, n)
|
||||
self.o.flush()
|
||||
return r
|
||||
|
||||
def write2(self, data, n):
|
||||
f = self.o
|
||||
f.seek(self.pos)
|
||||
f.write(data)
|
||||
#self.writes[self.pos] = data
|
||||
self.pos += len(data)
|
||||
|
||||
#def write(self, data):
|
||||
# self.o.write(data)
|
||||
# self.i.seek(self.o.tell())
|
||||
# return len(data)
|
||||
|
||||
|
||||
class Section:
|
||||
def __init__(self, name, offset, sz, elementSize = 8):
|
||||
self.name = name
|
||||
self.offset = offset
|
||||
self.sz = sz
|
||||
self.elementSize = elementSize
|
||||
|
||||
def serialize(self, f, z64):
|
||||
z64.seek(self.offset)
|
||||
|
||||
if self.getSize() == self.getElementSize():
|
||||
f.write('u%d %s = ' % (self.getElementSize() * 8, self.name))
|
||||
buffer = z64.read(self.getElementSize())
|
||||
n = int.from_bytes(buffer, "big")
|
||||
f.write(('0x%%%d.%dX' % (self.getElementSize() * 2, self.getElementSize() * 2)) % (n))
|
||||
f.write(';\n\n')
|
||||
return
|
||||
|
||||
f.write('u%d %s[0x%X] = {' % (self.getElementSize() * 8, self.name, self.getSize()))
|
||||
|
||||
lst = []
|
||||
while z64.tell() < self.offset + self.sz:
|
||||
buffer = z64.read(self.getElementSize())
|
||||
n = int.from_bytes(buffer, "big")
|
||||
lst.append(('0x%%%d.%dX' % (self.getElementSize() * 2, self.getElementSize() * 2)) % (n))
|
||||
|
||||
f.write(', '.join(lst))
|
||||
|
||||
f.write('};\n\n')
|
||||
|
||||
def getSize(self):
|
||||
return int(self.sz / self.getElementSize())
|
||||
|
||||
def getElementSize(self):
|
||||
return self.elementSize
|
||||
|
||||
def includes(self):
|
||||
return []
|
||||
|
||||
class Reloc:
|
||||
def __init__(self, address, size, medium, cachePolicy, shortData1, shortData2, shortData3, dataFile, f):
|
||||
self.address = address
|
||||
self.size = size
|
||||
self.medium = medium
|
||||
self.cachePolicy = cachePolicy
|
||||
self.shortData1 = shortData1
|
||||
self.shortData2 = shortData2
|
||||
self.shortData3 = shortData3
|
||||
|
||||
self.dataFile = dataFile
|
||||
self.f = f
|
||||
|
||||
def getDef(self):
|
||||
return '';
|
||||
|
||||
def OFFSET(o):
|
||||
if o > 0x2BDC0:
|
||||
raise IOError('bad offset: %8.8X' % o)
|
||||
return o
|
||||
|
||||
class AdpcmLoop:
|
||||
def __init__(self, f, parent):
|
||||
self.start = readU32(f)
|
||||
self.end = readU32(f)
|
||||
self.count = readU32(f)
|
||||
self.unk_0C = f.read(4, swap = False)
|
||||
|
||||
self.states = []
|
||||
|
||||
if self.count > 0:
|
||||
for i in range(16):
|
||||
self.states.append(readS16(f))
|
||||
|
||||
class AdpcmBook:
|
||||
def __init__(self, f, parent):
|
||||
self.order = readS32(f)
|
||||
self.npredictors = readS32(f)
|
||||
print('order = %d, npred = %d, offset = %8.8X' % (self.order, self.npredictors, f.tell()))
|
||||
|
||||
self.books = [] # TODO LOOP THROUGH: size 8 * order * npredictors. 8-byte aligned
|
||||
for i in range(self.order * self.npredictors * 8):
|
||||
self.books.append(readS16(f))
|
||||
|
||||
def RSHIFT(n, offset, length):
|
||||
return (n >> offset) & ((0x01 << length) - 1)
|
||||
|
||||
class SoundFontSample:
|
||||
def __init__(self, f, parent):
|
||||
self.flags = readU32(f)
|
||||
self.sampleOffset = readU32(f)
|
||||
self.loopOffset = readU32(f)
|
||||
self.bookOffset = readU32(f)
|
||||
|
||||
pos = f.tell()
|
||||
|
||||
|
||||
|
||||
self.codec = RSHIFT(self.flags, 0, 4)
|
||||
self.medium = RSHIFT(self.flags, 4, 2)
|
||||
self.unk_bit26 = RSHIFT(self.flags, 6, 1)
|
||||
self.unk_bit25 = RSHIFT(self.flags, 7, 1)
|
||||
self.size = RSHIFT(self.flags, 8, 24)
|
||||
print('sample flags: %8.8X, size = %d, codec = %d, medium = %d, unk_bit26 = %d, unk_bit25 = %d, sampleOffset = %8.8X' % (self.flags, self.size, self.codec, self.medium, self.unk_bit26, self.unk_bit25, self.sampleOffset))
|
||||
|
||||
#print('sample flags: %8.8X, size = %d' % (self.flags, RSHIFT(self.flags, 8, 24)))
|
||||
#exit(0)
|
||||
#if OFFSET(self.sampleOffset) > 0:
|
||||
# pass
|
||||
#print('sample flags: %8.8X' % self.flags)
|
||||
#exit(0)
|
||||
#f.seek(self.sampleOffset + parent.address)
|
||||
|
||||
|
||||
if OFFSET(self.loopOffset) > 0:
|
||||
f.seek(self.loopOffset + parent.address)
|
||||
self.loop = AdpcmLoop(f, parent)
|
||||
|
||||
if OFFSET(self.bookOffset) > 0:
|
||||
f.seek(self.bookOffset + parent.address)
|
||||
self.book = AdpcmBook(f, parent)
|
||||
|
||||
f.seek(pos)
|
||||
|
||||
class SoundFontSound:
|
||||
def __init__(self, f, parent):
|
||||
|
||||
self.sampleOffset = readU32(f)
|
||||
self.tuning = readFloat(f)
|
||||
|
||||
pos = f.tell()
|
||||
|
||||
if OFFSET(self.sampleOffset) > 0:
|
||||
f.seek(self.sampleOffset + parent.address)
|
||||
self.sample = SoundFontSample(f, parent)
|
||||
|
||||
f.seek(pos)
|
||||
|
||||
print('SoundFontSound: %8.8X, tuning: %f' % (self.sampleOffset, self.tuning))
|
||||
|
||||
class Drum:
|
||||
def __init__(self, f, parent):
|
||||
self.releaseRate = readU8(f)
|
||||
self.pan = readU8(f)
|
||||
self.loaded = readU8(f)
|
||||
|
||||
readU8(f) # padding
|
||||
|
||||
self.soundFontSound = SoundFontSound(f, parent)
|
||||
|
||||
self.envelopeOffset = readU32(f)
|
||||
|
||||
pos = f.tell()
|
||||
|
||||
if OFFSET(self.envelopeOffset) > 0:
|
||||
f.seek(self.envelopeOffset + parent.address)
|
||||
self.adsrEnvelope = AdsrEnvelope(f)
|
||||
|
||||
f.seek(pos)
|
||||
|
||||
print('Drum: releaseRate: %d, pan: %d, envelopeOffset: %8.8X' % (self.releaseRate, self.pan, self.envelopeOffset))
|
||||
|
||||
class AdsrEnvelope:
|
||||
def __init__(self, f):
|
||||
self.delay = readS16(f)
|
||||
self.arg = readS16(f)
|
||||
|
||||
class Instrument:
|
||||
def __init__(self, f, parent):
|
||||
self.loaded = readU8(f)
|
||||
self.normalRangeLo = readU8(f)
|
||||
self.normalRangeHi = readU8(f)
|
||||
self.releaseRate = readU8(f)
|
||||
|
||||
self.envelopeOffset = readU32(f)
|
||||
self.lowNotesSound = SoundFontSound(f, parent)
|
||||
self.normalNotesSound = SoundFontSound(f, parent)
|
||||
self.highNotesSound = SoundFontSound(f, parent)
|
||||
|
||||
pos = f.tell()
|
||||
|
||||
if OFFSET(self.envelopeOffset) > 0:
|
||||
f.seek(self.envelopeOffset + parent.address)
|
||||
self.adsrEnvelope = AdsrEnvelope(f)
|
||||
|
||||
f.seek(pos)
|
||||
|
||||
print('Instrument: normalRangeLo: %d, normalRangeHi: %d, releaseRate: %d, envelopeOffset = %8.8X (%8.8X)' % (self.normalRangeLo, self.normalRangeHi, self.releaseRate, self.envelopeOffset, parent.address))
|
||||
|
||||
|
||||
|
||||
class FontReloc(Reloc):
|
||||
def __init__(self, address, size, medium, cachePolicy, shortData1, shortData2, shortData3, dataFile, f):
|
||||
super(FontReloc, self).__init__(address, size, medium, cachePolicy, shortData1, shortData2, shortData3, dataFile, f)
|
||||
|
||||
self.sampleBankId1 = (shortData1 >> 8) & 0xFF
|
||||
self.sampleBankId2 = (shortData1) & 0xFF
|
||||
self.numInstruments = (shortData2 >> 8) & 0xFF
|
||||
self.numDrums = shortData2 & 0xFF
|
||||
self.numSfx = shortData3
|
||||
|
||||
f.seek(address)
|
||||
self.offsets = []
|
||||
self.offsets.append(readU32(f)) # drums
|
||||
self.offsets.append(readU32(f)) # SoundFontSound
|
||||
|
||||
for i in range(2, self.numInstruments + 2): # instruments
|
||||
self.offsets.append(readU32(f))
|
||||
|
||||
print('bankId1 = %d, bankId2 = %d, numInstruments = %d, numDrums = %d, , numSfx = %d' % (self.sampleBankId1, self.sampleBankId2, self.numInstruments, self.numDrums, self.numSfx))
|
||||
|
||||
def getName(self):
|
||||
return 'font_%X' % self.address
|
||||
|
||||
def getDef(self):
|
||||
buf = 'FontReloc %s = {' % self.getName()
|
||||
r = []
|
||||
for offset in self.offsets:
|
||||
r.append('0x%8.8X' % offset)
|
||||
|
||||
buf += ', '.join(r) + ' }; // data starts at 0x%8.8X\n' % (len(self.offsets) * 4)
|
||||
|
||||
drums = []
|
||||
sfxs = []
|
||||
instruments = []
|
||||
|
||||
f = self.f
|
||||
|
||||
if self.offsets[0] > 0:
|
||||
for i in range(self.numDrums):
|
||||
f.seek(self.offsets[0] + self.address + (i * 4))
|
||||
p = readS32(f)
|
||||
|
||||
if p > 0:
|
||||
f.seek(p + self.address)
|
||||
drums.append(Drum(f, self))
|
||||
|
||||
if self.offsets[1] > 0:
|
||||
f.seek(self.offsets[1] + self.address)
|
||||
for i in range(self.numSfx):
|
||||
sfxs.append(SoundFontSound(f, self))
|
||||
|
||||
for i in range(2, self.numInstruments + 2):
|
||||
if self.offsets[i] > 0:
|
||||
f.seek(self.offsets[i] + self.address)
|
||||
instruments.append(Instrument(f, self))
|
||||
|
||||
return buf
|
||||
|
||||
|
||||
|
||||
class Table(Section):
|
||||
def __init__(self, name, offset, sz, dataFile):
|
||||
super(Table, self).__init__(name, offset, sz, 1)
|
||||
|
||||
self.dataFile = dataFile
|
||||
|
||||
|
||||
def serialize(self, f, z64):
|
||||
z64.seek(self.offset)
|
||||
|
||||
numEntries = readS16(z64, swap = False)
|
||||
unkMediumParam = readS16(z64, swap = False)
|
||||
address = readU32(z64, swap = False)
|
||||
|
||||
z64.read(8) # padding
|
||||
|
||||
|
||||
lst = []
|
||||
relocs = []
|
||||
|
||||
with ConvFile(self.dataFile, 'rb') as x:
|
||||
while z64.tell() < self.offset + self.sz:
|
||||
address = readU32(z64, swap = False)
|
||||
size = readU32(z64, swap = False)
|
||||
medium = readS8(z64, swap = False)
|
||||
cachePolicy = readS8(z64, swap = False)
|
||||
shortData1 = readS16(z64, swap = False)
|
||||
shortData2 = readS16(z64, swap = False)
|
||||
shortData3 = readS16(z64, swap = False)
|
||||
|
||||
reloc = self.getReloc(address, size, medium, cachePolicy, shortData1, shortData2, shortData3, f = x)
|
||||
reloc.getDef() # reverses endian
|
||||
relocs.append(reloc)
|
||||
lst.append('{ .romAddr = 0x%8.8X, .size = 0x%8.8X, .medium = 0x%2.2X, .cachePolicy = %d, .shortData1 = 0x%4.4X, .shortData2 = 0x%4.4X, .shortData3 = 0x%4.4X }' % (address, size, medium, cachePolicy, shortData1, shortData2, shortData3))
|
||||
|
||||
f.write('AudioTableDef %s = {\n.numEntries = 0x%4.4X, .unkMediumParam = 0x%4.4X, .romAddr = 0x%8.8X, {0}, {\n' % (self.name, numEntries, unkMediumParam, address))
|
||||
|
||||
f.write(',\n'.join(lst))
|
||||
|
||||
f.write('\n}};\n\n')
|
||||
|
||||
def getReloc(self, address, size, medium, cachePolicy, shortData1, shortData2, shortData3, f):
|
||||
return Reloc(address, size, medium, cachePolicy, shortData1, shortData2, shortData3, self.dataFile, f = f)
|
||||
|
||||
|
||||
def includes(self):
|
||||
return ['z64audio.h']
|
||||
|
||||
class FontTable(Table):
|
||||
def __init__(self, name, offset, sz, dataFile):
|
||||
super(FontTable, self).__init__(name, offset, sz, dataFile)
|
||||
|
||||
def getReloc(self, address, size, medium, cachePolicy, shortData1, shortData2, shortData3, f):
|
||||
return FontReloc(address, size, medium, cachePolicy, shortData1, shortData2, shortData3, self.dataFile, f = f)
|
||||
|
||||
sections = {'assets/rsp.h': [
|
||||
FontTable('gSoundFontTable', 0xBCC270, 0x270, 'baserom/Audiobank'),
|
||||
Section('gSequenceFontTable', 0xBCC4E0, 0x1C0, 2),
|
||||
Table('gSequenceTable', 0xBCC6A0, 0x6F0, 'baserom/Audioseq'),
|
||||
Table('gSampleBankTable', 0xBCCD90, 0x80, 'baserom/Audiotable'),
|
||||
Section('rspAspMainDataStart', 0xBCCE10, 0x2E0),
|
||||
Section('D_80155F50', 0xBCD0F0, 0x1630, 1),
|
||||
Section('D_80157580', 0xBCE720, 0x420, 1),
|
||||
Section('D_801579A0', 0xBCEB40, 0x390, 1),
|
||||
Section('gJpegUCodeData', 0xBCEED0, 0x60),
|
||||
Section('D_801120C0', 0xB89260, 0xFB0, 8),
|
||||
Section('D_80113070', 0xB8A210, 0x18C0, 1),
|
||||
Section('gJpegUCode', 0xB8BAD0, 0xAF0, 8)
|
||||
],
|
||||
'assets/rsp_boot.h': [
|
||||
Section('D_80009320', 0x9F20, 0xD0, 1),
|
||||
Section('D_800093F0', 0x9FF0, 0x20, 1)
|
||||
],
|
||||
'assets/code_800F9280.h': [
|
||||
Section('sSeqCmdWrPos', 0xBAA5A0, 0x4, 1),
|
||||
Section('sSeqCmdRdPos', 0xBAA5A4, 0x4, 1),
|
||||
Section('D_80133408', 0xBAA5A8, 0x1, 1),
|
||||
Section('D_8013340C', 0xBAA5AC, 0x1, 1),
|
||||
Section('D_80133410', 0xBAA5B0, 0x4, 1),
|
||||
Section('gAudioSpecId', 0xBAA5B4, 0x1, 1),
|
||||
Section('D_80133418', 0xBAA5B8, 0x1, 1),
|
||||
]
|
||||
}
|
||||
|
||||
with open('baserom.z64', 'rb') as z64:
|
||||
for filename, s in sections.items():
|
||||
with open(filename, 'w') as f:
|
||||
f.write('#include "global.h"\n')
|
||||
includes = {}
|
||||
for section in s:
|
||||
for i in section.includes():
|
||||
includes[i] = i
|
||||
|
||||
for i in includes.keys():
|
||||
f.write('#include "%s"\n' % i)
|
||||
|
||||
f.write('\n')
|
||||
|
||||
for section in s:
|
||||
section.serialize(f, z64)
|
Loading…
Reference in New Issue
Block a user