Sync MusyX source

Former-commit-id: 081a2fe39f
This commit is contained in:
Phillip Stephens 2023-12-18 18:28:24 -08:00
parent c2d27e0beb
commit 2733104114
39 changed files with 1252 additions and 660 deletions

View File

@ -4248,7 +4248,7 @@ musyx/runtime/s_data.c:
.bss start:0x8055EC60 end:0x8055F260
.sbss start:0x805A9AD8 end:0x805A9AE0
musyx/runtime/dolphin/hw_dspctrl.c:
musyx/runtime/hw_dspctrl.c:
.text start:0x803AACFC end:0x803AE110
.rodata start:0x803D8A68 end:0x803D8AC0
.data start:0x803F3FA8 end:0x803F3FC0
@ -4284,23 +4284,23 @@ musyx/runtime/snd_service.c:
.data start:0x803F4278 end:0x803F4A80
.sdata start:0x805A8BD0 end:0x805A8BD8
musyx/runtime/dolphin/hardware.c:
musyx/runtime/hardware.c:
.text start:0x803B2F4C end:0x803B3F70
.rodata start:0x803D8BD0 end:0x803D8CD0
.sdata start:0x805A8BD8 end:0x805A8BE8
.sbss start:0x805A9B40 end:0x805A9B50
.sdata2 start:0x805AF398 end:0x805AF3B0
musyx/runtime/dolphin/dsp_import.c:
musyx/runtime/dsp_import.c:
.data start:0x803F4A80 end:0x803F6460
.sdata start:0x805A8BE8 end:0x805A8BF0
musyx/runtime/dolphin/hw_aramdma.c:
musyx/runtime/hw_aramdma.c:
.text start:0x803B3F70 end:0x803B4C3C
.bss start:0x80566F90 end:0x805678A0
.sbss start:0x805A9B50 end:0x805A9B70
musyx/runtime/dolphin/hw_dolphin.c:
musyx/runtime/hw_dolphin.c:
.text start:0x803B4C3C end:0x803B5134
.bss start:0x805678A0 end:0x80569900
.sbss start:0x805A9B70 end:0x805A9B98

View File

@ -187,6 +187,7 @@ cflags_retro = [
"-gccinc",
"-inline deferred,noauto",
"-common on",
"-DMUSY_TARGET=MUSY_TARGET_DOLPHIN"
]
cflags_musyx = [
@ -1194,17 +1195,17 @@ config.libs = [
Object(Matching, "musyx/runtime/synth_vsamples.c"),
Object(Matching, "musyx/runtime/synth_dbtab.c"),
Object(Matching, "musyx/runtime/s_data.c"),
Object(NonMatching, "musyx/runtime/dolphin/hw_dspctrl.c"),
Object(NonMatching, "musyx/runtime/hw_dspctrl.c"),
Object(Matching, "musyx/runtime/hw_volconv.c"),
Object(Matching, "musyx/runtime/snd3d.c"),
Object(Matching, "musyx/runtime/snd_init.c"),
Object(Matching, "musyx/runtime/snd_math.c"),
Object(NonMatching, "musyx/runtime/snd_midictrl.c"),
Object(Matching, "musyx/runtime/snd_service.c"),
Object(Matching, "musyx/runtime/dolphin/hardware.c"),
Object(Matching, "musyx/runtime/dolphin/hw_aramdma.c"),
Object(Matching, "musyx/runtime/dolphin/dsp_import.c"),
Object(Matching, "musyx/runtime/dolphin/hw_dolphin.c"),
Object(Matching, "musyx/runtime/hardware.c"),
Object(Matching, "musyx/runtime/hw_aramdma.c"),
Object(Matching, "musyx/runtime/dsp_import.c"),
Object(Matching, "musyx/runtime/hw_dolphin.c"),
Object(Matching, "musyx/runtime/hw_memory.c"),
Object(Matching, "musyx/runtime/hw_lib_dummy.c"),
Object(Matching, "musyx/runtime/CheapReverb/creverb_fx.c"),

View File

@ -56,7 +56,7 @@ extern "C" {
#endif
u32 adsrHandleLowPrecision(ADSR_VARS* adsr, u16* adsr_start, u16* adsr_delta);
bool adsrRelease(ADSR_VARS* adsr);
u32 adsrConvertTimeCents(s32 tc);
#ifdef __cplusplus
}
#endif

View File

@ -1,7 +1,8 @@
#ifndef _ASSERT
#define _ASSERT
#include "musyx/version.h"
#include "musyx/platform.h"
#include "musyx/version.h"
#if MUSY_TARGET == MUSY_TARGET_DOLPHIN
extern void OSPanic(const char* file, int line, const char* msg, ...);
@ -15,9 +16,21 @@ extern void OSReport(const char* msg, ...);
#endif
#elif MUSY_TARGET == MUSY_TARGET_PC
#include <assert.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
static inline void panic(const char* file, int line, const char* msg, ...) {
va_list list;
va_start(list);
vprintf(msg, list);
va_end(list);
printf(" in \"%s\" on line %d.\n", file, line);
abort();
}
#ifndef MUSY_PANIC
#define MUSY_PANIC assert
#define MUSY_PANIC panic
#endif
#ifndef MUSY_REPORT
#define MUSY_REPORT printf

View File

@ -1,6 +1,8 @@
#ifndef _MUSYX_DSP_IMPORT
#define _MUSYX_DSP_IMPORT
#include "musyx/platform.h"
#if MUSY_TARGET == MUSY_TARGET_DOLPHIN
#include "musyx/musyx.h"
#ifdef __cplusplus
@ -14,4 +16,6 @@ extern u16 dspSlaveLength;
}
#endif
#endif
#endif // _MUSYX_DSP_IMPORT

View File

@ -2,6 +2,7 @@
#define _MUSYX_HARDWARE
#include "musyx/musyx.h"
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
@ -14,11 +15,10 @@ extern SND_HOOKS salHooks;
extern u32 dspHRTFOn;
extern u16* dspCmdList;
extern s16* dspCmdList;
extern u16 dspCmdFirstSize;
extern u8 dspScale2IndexTab[1024];
u32 hwFrq2Pitch(u32 frq);
void hwOff(s32 vid);
bool hwIsStudioActive(u8 studio);
@ -29,6 +29,8 @@ void hwInitSamplePlayback(u32 v, u16 smpID, void* newsmp, u32 set_defadsr, u32 p
u32 callbackUserValue, u32 setSRC, u8 itdMode);
void hwSetVolume(u32 v, u8 table, float vol, u32 pan, u32 span, float auxa, float auxb);
void hwSetPitch(u32 v, u16 speed);
void hwInitIrq();
void hwExitIrq();
void hwEnableIrq();
void hwDisableIrq();
void* hwTransAddr(void* samples);
@ -46,8 +48,8 @@ u16 hwGetSampleID(u32 voice);
u8 hwGetSampleType(u32 voice);
void hwChangeStudioMix(u8 studio, u32 isMaster);
void hwSetStreamLoopPS(u32 voice, u8 ps);
void hwFlushStream(void* base, u32 offset, u32 bytes, unsigned char hwStreamHandle,
void (*callback)(u32), u32 user);
void hwFlushStream(void* base, u32 offset, u32 bytes, u8 hwStreamHandle, void (*callback)(size_t),
u32 user);
void hwSetSaveSampleCallback(ARAMUploadCallback callback, unsigned long chunckSize);
void hwSyncSampleMem();
void hwSetAUXProcessingCallbacks(u8 studio, SND_AUX_CALLBACK auxA, void* userA,
@ -67,7 +69,7 @@ void hwDisableHRTF();
void hwStart(u32 v, u8 studio);
void hwKeyOff(u32 v);
void hwFrameDone();
void hwActivateStudio(u8 studio, u32 isMaster, SND_STUDIO_TYPE type);
void hwActivateStudio(u8 studio, bool isMaster, SND_STUDIO_TYPE type);
void hwDeactivateStudio(u8);
void hwSetPriority(u32 v, u32 prio);
u32 hwIsActive(u32);
@ -82,13 +84,17 @@ void hwIRQLeaveCritical();
extern u32 aramSize;
extern u8* aramBase;
unsigned long aramGetStreamBufferAddress(unsigned char id, unsigned long* len);
u32 aramGetStreamBufferAddress(u8 id, u32* len);
void aramUploadData(void* mram, u32 aram, u32 len, u32 highPrio, void (*callback)(u32), u32 user);
void aramInit(u32 length);
void aramExit();
size_t aramGetStreamBufferAddress(u8 id, size_t* len);
void aramUploadData(void* mram, u32 aram, u32 len, u32 highPrio, void (*callback)(size_t), u32 user);
void aramFreeStreamBuffer(u8 id);
void* aramStoreData(void* src, u32 len);
void aramRemoveData(void* aram, u32 len);
u8 aramAllocateStreamBuffer(u32 len);
unsigned long aramGetZeroBuffer();
void aramSetUploadCallback(ARAMUploadCallback callback, u32 chunckSize);
void aramSyncTransferQueue();
#ifdef __cplusplus
}

File diff suppressed because it is too large Load Diff

View File

@ -19,4 +19,13 @@
#endif
#endif
#endif
#if MUSY_TARGET == MUSY_TARGET_PC
#ifndef MUSY_CACHED_TO_UNCACHED_ADDR
#define MUSY_CACHED_TO_UNCACHED_ADDR(addr) addr
#endif
#elif MUSY_TARGET == MUSY_TARGET_DOLPHIN
#ifndef MUSY_CACHED_TO_UNCACHED_ADDR
#define MUSY_CACHED_TO_UNCACHED_ADDR(addr) OSCachedToUncached(addr)
#endif
#endif
#endif

View File

@ -13,6 +13,7 @@ void s3dKillAllEmitter();
void s3dInit(u32); /* extern */
void s3dKillEmitterByFXID(FX_TAB* fxTab, u32 num);
void s3dExit();
void s3dHandle();
#ifdef __cplusplus
}

View File

@ -41,21 +41,32 @@ typedef struct SAL_PANINFO {
f32 rpan_fm; // offset 0x2C, size 0x4
} SAL_PANINFO;
u32 salInitAi(SND_SOME_CALLBACK, u32, u32*);
u32 salInitDsp(u32);
u32 salInitDspCtrl(u8 numVoices, u8 numStudios, u32 defaultStudioDPL2);
u32 salStartAi();
bool salInitAi(SND_SOME_CALLBACK, u32, u32*);
bool salInitDsp(u32);
bool salInitDspCtrl(u8 numVoices, u8 numStudios, u32 defaultStudioDPL2);
bool salExitDsp();
bool salExitDspCtrl();
bool salExitAi();
bool salStartAi();
void* salAiGetDest();
void salInitHRTFBuffer();
void salActivateVoice(DSPvoice* dsp_vptr, u8 studio);
void salDeactivateVoice(DSPvoice* dsp_vptr);
void salActivateStudio(u8 studio, u32 isMaster, SND_STUDIO_TYPE type);
void salDeactivateStudio(u8 studio);
bool salAddStudioInput(DSPstudioinfo* stp, SND_STUDIO_INPUT* desc);
bool salRemoveStudioInput(DSPstudioinfo* stp, SND_STUDIO_INPUT* desc);
void salActivateVoice(DSPvoice* dsp_vptr, u8 studio);
void salCalcVolume(u8 voltab_index, SAL_VOLINFO* vi, f32 vol, u32 pan, u32 span, f32 auxa, f32 auxb,
u32 itd, u32 dpl2);
void salReconnectVoice(DSPvoice* dsp_vptr, u8 studio);
void* salMalloc(u32 len);
void salFree(void* addr);
void salBuildCommandList(signed short* dest, unsigned long nsDelay);
void salStartDsp(s16* cmdList);
void salCtrlDsp(s16* dest);
void salHandleAuxProcessing();
#define SAL_MAX_STUDIONUM 8
extern u8 salMaxStudioNum;

View File

@ -213,12 +213,6 @@ u32 seqStartPlay(PAGE* norm, PAGE* drum, MIDISETUP* midiSetup, u32* song, SND_PL
u32 seqGetPrivateId(u32 seqId);
void seqSpeed(u32 seqId, u16 speed);
void seqVolume(u8 volume, u16 time, u32 seqId, u8 mode);
void sndSeqStop(s32 unk);
void sndSeqSpeed(u32 seqId, u16 speed);
void sndSeqContinue(s32 unk);
void sndSeqMute(s32 unk1, s32 unk2, s32 unk3);
void sndSeqVolume(u8 volume, u16 time, u32 seqId, u8 mode);
u32 sndSeqPlayEx(u16 sgid, u16 sid, void* arrfile, SND_PLAYPARA* para, u8 studio);
void seqStop(u32 seqId);
u16 seqGetMIDIPriority(u8 set, u8 channel);
void seqCrossFade(SND_CROSSFADE* ci, u32* new_seqId, bool8 irq_call);
@ -228,6 +222,7 @@ void seqContinue(SND_SEQID seqId);
void seqMute(SND_SEQID seqId, u32 mask1, u32 mask2);
void seqKillInstancesByGroupID(SND_GROUPID sgid);
void seqKillAllInstances();
void seqHandle(u32 deltaTime);
u8 inpTranslateExCtrl(u8 ctrl);
void inpSetGlobalMIDIDirtyFlag(u8 chan, u8 midiSet, s32 flag);

View File

@ -16,10 +16,6 @@ void* sndBSearch(void* key, void* base, s32 num, s32 len, SND_COMPARE cmp);
void sndConvertMs(u32* time);
void sndConvertTicks(u32* out, SYNTH_VOICE* svoice);
u32 sndConvert2Ms(u32 time);
u32 sndStreamAllocLength(u32 num, u32 flags);
void sndStreamFree(u32 stid);
u32 sndStreamActivate(u32 stid);
void sndStreamDeactivate(u32 stid);
u32 sndGetPitch(u8 key, u32 sInfo);
s32 sndPitchUpOne(u16 note);

View File

@ -7,7 +7,7 @@
extern "C" {
#endif
typedef s32 (*SND_STREAM_UPDATE_CALLBACK)(void* buffer1, u32 len1, void* buffer2, u32 len2,
typedef u32 (*SND_STREAM_UPDATE_CALLBACK)(void* buffer1, u32 len1, void* buffer2, u32 len2,
u32 user);
typedef struct SNDADPCMinfo {
// total size: 0x28
@ -68,6 +68,7 @@ void streamOutputModeChanged();
void streamInit(); /* extern */
void streamKill(SND_VOICEID voice);
void streamCorrectLoops();
void streamHandle();
#ifdef __cplusplus
}

View File

@ -304,6 +304,7 @@ void synthInitPortamento(SYNTH_VOICE* svoice);
void synthStartSynthJobHandling(SYNTH_VOICE* svoice);
void synthForceLowPrecisionUpdate(SYNTH_VOICE* svoice);
void synthKeyStateUpdate(SYNTH_VOICE* svoice);
void synthHandle(u32 deltaTime);
bool synthFXSetCtrl(SND_VOICEID vid, u8 ctrl, u8 value);
bool synthFXSetCtrl14(SND_VOICEID vid, u8 ctrl, u16 value);
bool synthSendKeyOff(SND_VOICEID vid);
@ -322,8 +323,8 @@ u8 synthFXGetMaxVoices(u16 fid);
void synthPauseVolume(u8 volume, u16 time, u8 vGroup);
void synthKillAllVoices(bool8 musiconly);
void synthKeyStateUpdate(SYNTH_VOICE* svoice);
u32 synthAddStudioInput(u8 studio, SND_STUDIO_INPUT* in_desc);
u32 synthRemoveStudioInput(u8 studio, SND_STUDIO_INPUT* in_desc);
bool synthAddStudioInput(u8 studio, SND_STUDIO_INPUT* in_desc);
bool synthRemoveStudioInput(u8 studio, SND_STUDIO_INPUT* in_desc);
u32 synthGetTicksPerSecond(SYNTH_VOICE* svoice);
#ifdef __cplusplus

View File

@ -60,6 +60,21 @@ typedef struct SDIR_DATA {
u32 extraData; // offset 0x1C, size 0x4
} SDIR_DATA;
/*! A direct copy of the above structure to allow us to load in legacy data
* this must be done via sndConvert32BitSDIRto64BitSDIR via client code,
* this is explicit on the part of the programmer.
* MusyX data built with the new tools will not require this step.
*/
typedef struct SDIR_DATA_INTER {
// total size: 0x20
u16 id; // offset 0x0, size 0x2
u16 ref_cnt; // offset 0x2, size 0x2
u32 offset; // offset 0x4, size 0x4
u32 addr; // offset 0x8, size 0x4
SAMPLE_HEADER header; // offset 0xC, size 0x10
u32 extraData; // offset 0x1C, size 0x4
} SDIR_DATA_INTER;
typedef struct SDIR_TAB {
// total size: 0xC
SDIR_DATA* data; // offset 0x0, size 0x4
@ -183,21 +198,21 @@ void dataInitStack(unsigned long aramBase, unsigned long aramSize);
#else
void dataInitStack(); /* extern */
#endif
u32 dataInsertSDir(SDIR_DATA* sdir, void* smp_data);
u32 dataRemoveSDir(SDIR_DATA* sdir);
u32 dataInsertMacro(u16 mid, void* macroaddr);
u32 dataRemoveMacro(u16 mid);
u32 dataInsertCurve(u16 cid, void* curvedata);
u32 dataRemoveCurve(u16 sid);
bool dataInsertSDir(SDIR_DATA* sdir, void* smp_data);
bool dataRemoveSDir(SDIR_DATA* sdir);
bool dataInsertMacro(u16 mid, void* macroaddr);
bool dataRemoveMacro(u16 mid);
bool dataInsertCurve(u16 cid, void* curvedata);
bool dataRemoveCurve(u16 sid);
s32 dataGetSample(u16 sid, SAMPLE_INFO* newsmp);
void* dataGetCurve(u16 cid);
u32 dataAddSampleReference(u16 sid);
u32 dataRemoveSampleReference(u16 sid);
u32 dataInsertKeymap(u16 cid, void* keymapdata);
u32 dataRemoveKeymap(u16 sid);
u32 dataInsertLayer(u16 cid, void* layerdata, u16 size);
u32 dataRemoveLayer(u16 sid);
u32 dataInsertFX(u16 gid, FX_TAB* fx, u16 fxNum);
bool dataAddSampleReference(u16 sid);
bool dataRemoveSampleReference(u16 sid);
bool dataInsertKeymap(u16 cid, void* keymapdata);
bool dataRemoveKeymap(u16 sid);
bool dataInsertLayer(u16 cid, void* layerdata, u16 size);
bool dataRemoveLayer(u16 sid);
bool dataInsertFX(u16 gid, FX_TAB* fx, u16 fxNum);
bool dataRemoveFX(u16 gid);
FX_TAB* dataGetFX(u16 fid);
void* dataGetLayer(u16 cid, u16* n);

View File

@ -141,21 +141,6 @@ typedef struct VSampleInfo {
u8 inLoopBuffer; // offset 0x8, size 0x1
} VSampleInfo;
typedef struct SND_VIRTUALSAMPLE_INFO {
// total size: 0x14
u16 smpID; // offset 0x0, size 0x2
u16 instID; // offset 0x2, size 0x2
union vsData {
struct vsUpdate {
// total size: 0x10
u32 off1; // offset 0x0, size 0x4
u32 len1; // offset 0x4, size 0x4
u32 off2; // offset 0x8, size 0x4
u32 len2; // offset 0xC, size 0x4
} update;
} data;
} SND_VIRTUALSAMPLE_INFO;
typedef struct VS_BUFFER {
// total size: 0x24
u8 state; // offset 0x0, size 0x1
@ -176,7 +161,7 @@ typedef struct _VS {
u8 voices[64]; // offset 0x908, size 0x40
u16 nextInstID; // offset 0x948, size 0x2
u32 (*callback)(u8,
SND_VIRTUALSAMPLE_INFO*); // offset 0x94C, size 0x4
const SND_VIRTUALSAMPLE_INFO*); // offset 0x94C, size 0x4
} VS;
extern VS vs;
@ -221,6 +206,7 @@ extern u8 voiceListRoot;
void vsInit(); /* extern */
u32 vsSampleStartNotify(u8 voice);
void vsSampleEndNotify(u32 pubID);
void vsSampleUpdates();
void voiceSetPriority(SYNTH_VOICE* svoice, u8 prio);
u32 voiceIsLastStarted(SYNTH_VOICE* svoice);

View File

@ -415,7 +415,7 @@ lbl_803B599C:
#endif
}
#else
static void HandleReverb(long* sptr, struct _SND_REVSTD_WORK* rv) {
static void HandleReverb(s32* sptr, struct _SND_REVSTD_WORK* rv) {
// TODO: Reimplement this in C
}
#endif

View File

@ -15,17 +15,17 @@
#include "musyx/sal.h"
void sndAuxCallbackDelay(u8 reason, SND_AUX_INFO* info, void* user) {
long l; // r30
long r; // r29
long s; // r28
long* lBuf; // r27
long* rBuf; // r26
long* sBuf; // r25
unsigned long i; // r24
s32 l; // r30
s32 r; // r29
s32 s; // r28
s32* lBuf; // r27
s32* rBuf; // r26
s32* sBuf; // r25
u32 i; // r24
SND_AUX_DELAY* c; // r31
long* left; // r23
long* right; // r22
long* sur; // r21
s32* left; // r23
s32* right; // r22
s32* sur; // r21
switch (reason) {
case SND_AUX_REASON_BUFFERUPDATE:

View File

@ -1,8 +1,5 @@
#include "musyx/dsp_import.h"
#ifdef __cplusplus
extern "C" {
#endif
#if MUSY_TARGET == MUSY_TARGET_DOLPHIN
char dspSlave[0x19E0] ATTRIBUTE_ALIGN(32) = {
0x00, 0x00, 0x00, 0x00, 0x02, 0x9F, 0x0C, 0x10, 0x02, 0x9F, 0x0C, 0x1F, 0x02, 0x9F, 0x0C, 0x3B,
@ -423,6 +420,4 @@ char dspSlave[0x19E0] ATTRIBUTE_ALIGN(32) = {
u16 dspSlaveLength = sizeof(dspSlave);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,19 +1,21 @@
#include "musyx/assert.h"
#include "musyx/hardware.h"
#include "musyx/assert.h"
#include "musyx/s3d.h"
#include "musyx/sal.h"
#include "musyx/seq.h"
#include "musyx/stream.h"
#include "musyx/synth.h"
#include "musyx/sal.h"
extern void DCStoreRange(void* addr, u32 nBytes);
static volatile const u16 itdOffTab[128] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4,
5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 15, 15, 15, 16,
16, 17, 17, 17, 18, 18, 19, 19, 19, 20, 20, 20, 21, 21, 22, 22, 22, 23, 23, 23, 24, 24, 24, 25, 25, 25, 26, 26, 26, 27, 27, 27,
28, 28, 28, 28, 29, 29, 29, 29, 29, 30, 30, 30, 30, 30, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2,
2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8,
9, 9, 9, 10, 10, 10, 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 15, 15, 15, 16, 16, 17,
17, 17, 18, 18, 19, 19, 19, 20, 20, 20, 21, 21, 22, 22, 22, 23, 23, 23, 24, 24, 24, 25,
25, 25, 26, 26, 26, 27, 27, 27, 28, 28, 28, 28, 29, 29, 29, 29, 29, 30, 30, 30, 30, 30,
31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
};
//SND_PROFILE_INFO prof;
// SND_PROFILE_INFO prof;
u8 salFrame;
u8 salAuxFrame;
@ -140,7 +142,8 @@ void hwSetMesgCallback(SND_MESSAGE_CALLBACK callback) { salMessageCallback = cal
void hwSetPriority(u32 v, u32 prio) { dspVoice[v].prio = prio; }
void hwInitSamplePlayback(u32 v, u16 smpID, void* newsmp, u32 set_defadsr, u32 prio, u32 callbackUserValue, u32 setSRC, u8 itdMode) {
void hwInitSamplePlayback(u32 v, u16 smpID, void* newsmp, u32 set_defadsr, u32 prio,
u32 callbackUserValue, u32 setSRC, u8 itdMode) {
unsigned char i; // r30
unsigned long bf; // r29
bf = 0;
@ -249,14 +252,15 @@ void hwStart(u32 v, u8 studio) {
void hwKeyOff(u32 v) { dspVoice[v].changed[salTimeOffset] |= 0x40; }
void hwSetPitch(unsigned long v, unsigned short speed) {
struct DSPvoice* dsp_vptr = &dspVoice[v];
void hwSetPitch(u32 v, u16 speed) {
DSPvoice* dsp_vptr = &dspVoice[v];
if (speed >= 0x4000) {
speed = 0x3fff;
}
if (dsp_vptr->lastUpdate.pitch != 0xff && dsp_vptr->pitch[dsp_vptr->lastUpdate.pitch] == speed * 16) {
if (dsp_vptr->lastUpdate.pitch != 0xff &&
dsp_vptr->pitch[dsp_vptr->lastUpdate.pitch] == speed * 16) {
return;
}
@ -272,9 +276,9 @@ void hwSetSRCType(u32 v, u8 salSRCType) {
dsp_vptr->changed[0] |= 0x100;
}
void hwSetPolyPhaseFilter(unsigned long v, unsigned char salCoefSel) {
void hwSetPolyPhaseFilter(u32 v, u8 salCoefSel) {
static u16 dspCoefSel[3] = {0, 1, 2};
struct DSPvoice* dsp_vptr = &dspVoice[v];
DSPvoice* dsp_vptr = &dspVoice[v];
dsp_vptr->srcCoefSelect = dspCoefSel[salCoefSel];
dsp_vptr->changed[0] |= 0x80;
}
@ -297,11 +301,11 @@ void hwSetITDMode(u32 v, u8 mode) {
#define hwGetITDMode(dsp_vptr) (dsp_vptr->flags & 0x80000000)
void hwSetVolume(unsigned long v, unsigned char table, float vol, unsigned long pan, unsigned long span, float auxa, float auxb) {
void hwSetVolume(u32 v, u8 table, float vol, u32 pan, u32 span, float auxa, float auxb) {
SAL_VOLINFO vi; // r1+0x24
unsigned short il; // r30
unsigned short ir; // r29
unsigned short is; // r28
u16 il; // r30
u16 ir; // r29
u16 is; // r28
DSPvoice* dsp_vptr = &dspVoice[v]; // r31
if (vol >= 1.f) {
vol = 1.f;
@ -316,13 +320,14 @@ void hwSetVolume(unsigned long v, unsigned char table, float vol, unsigned long
}
salCalcVolume(table, &vi, vol, pan, span, auxa, auxb, (dsp_vptr->flags & 0x80000000) != 0,
dspStudio[dsp_vptr->studio].type == SND_STUDIO_TYPE_RESERVED0);
dspStudio[dsp_vptr->studio].type == SND_STUDIO_TYPE_DPL2);
il = 32767.f * vi.volL;
ir = 32767.f * vi.volR;
is = 32767.f * vi.volS;
if (dsp_vptr->lastUpdate.vol == 0xff || dsp_vptr->volL != il || dsp_vptr->volR != ir || dsp_vptr->volS != is) {
if (dsp_vptr->lastUpdate.vol == 0xff || dsp_vptr->volL != il || dsp_vptr->volR != ir ||
dsp_vptr->volS != is) {
dsp_vptr->volL = il;
dsp_vptr->volR = ir;
dsp_vptr->volS = is;
@ -334,7 +339,8 @@ void hwSetVolume(unsigned long v, unsigned char table, float vol, unsigned long
ir = 32767.f * vi.volAuxAR;
is = 32767.f * vi.volAuxAS;
if (dsp_vptr->lastUpdate.volA == 0xff || dsp_vptr->volLa != il || dsp_vptr->volRa != ir || dsp_vptr->volSa != is) {
if (dsp_vptr->lastUpdate.volA == 0xff || dsp_vptr->volLa != il || dsp_vptr->volRa != ir ||
dsp_vptr->volSa != is) {
dsp_vptr->volLa = il;
dsp_vptr->volRa = ir;
dsp_vptr->volSa = is;
@ -346,7 +352,8 @@ void hwSetVolume(unsigned long v, unsigned char table, float vol, unsigned long
ir = 32767.f * vi.volAuxBR;
is = 32767.f * vi.volAuxBS;
if (dsp_vptr->lastUpdate.volB == 0xff || dsp_vptr->volLb != il || dsp_vptr->volRb != ir || dsp_vptr->volSb != is) {
if (dsp_vptr->lastUpdate.volB == 0xff || dsp_vptr->volLb != il || dsp_vptr->volRb != ir ||
dsp_vptr->volSb != is) {
dsp_vptr->volLb = il;
dsp_vptr->volRb = ir;
dsp_vptr->volSb = is;
@ -361,14 +368,17 @@ void hwSetVolume(unsigned long v, unsigned char table, float vol, unsigned long
void hwOff(s32 vid) { salDeactivateVoice(&dspVoice[vid]); }
void hwSetAUXProcessingCallbacks(u8 studio, SND_AUX_CALLBACK auxA, void* userA, SND_AUX_CALLBACK auxB, void* userB) {
void hwSetAUXProcessingCallbacks(u8 studio, SND_AUX_CALLBACK auxA, void* userA,
SND_AUX_CALLBACK auxB, void* userB) {
dspStudio[studio].auxAHandler = auxA;
dspStudio[studio].auxAUser = userA;
dspStudio[studio].auxBHandler = auxB;
dspStudio[studio].auxBUser = userB;
}
void hwActivateStudio(unsigned char studio, unsigned long isMaster, SND_STUDIO_TYPE type) { salActivateStudio(studio, isMaster, type); }
void hwActivateStudio(u8 studio, bool isMaster, SND_STUDIO_TYPE type) {
salActivateStudio(studio, isMaster, type);
}
void hwDeactivateStudio(u8 studio) { salDeactivateStudio(studio); }
@ -376,9 +386,13 @@ void hwChangeStudioMix(u8 studio, u32 isMaster) { dspStudio[studio].isMaster = i
bool hwIsStudioActive(u8 studio) { return dspStudio[studio].state == 1; }
bool hwAddInput(u8 studio, SND_STUDIO_INPUT* in_desc) { return salAddStudioInput(&dspStudio[studio], in_desc); }
bool hwAddInput(u8 studio, SND_STUDIO_INPUT* in_desc) {
return salAddStudioInput(&dspStudio[studio], in_desc);
}
bool hwRemoveInput(u8 studio, SND_STUDIO_INPUT* in_desc) { return salRemoveStudioInput(&dspStudio[studio], in_desc); }
bool hwRemoveInput(u8 studio, SND_STUDIO_INPUT* in_desc) {
return salRemoveStudioInput(&dspStudio[studio], in_desc);
}
void hwChangeStudio(u32 v, u8 studio) { salReconnectVoice(&dspVoice[v], studio); }
@ -411,17 +425,19 @@ u32 hwGetPos(u32 v) {
return pos;
}
void hwFlushStream(void* base, unsigned long offset, unsigned long bytes, unsigned char hwStreamHandle, void (*callback)(unsigned long),
unsigned long user) {
u32 aram; // r28
u32 mram; // r29
u32 len;
void hwFlushStream(void* base, u32 offset, u32 bytes, u8 hwStreamHandle, void (*callback)(size_t),
u32 user) {
size_t aram; // r28
size_t mram; // r29
size_t len;
aram = aramGetStreamBufferAddress(hwStreamHandle, &len);
bytes += (offset & 31);
offset &= ~31;
bytes = (bytes + 31) & ~31;
mram = (u32)base + offset;
#if MUSY_TARGET == MUSY_TARGET_DOLPHIN
DCStoreRange((void*)mram, bytes);
#endif
aramUploadData((void*)mram, aram + offset, bytes, 1, callback, user);
}
@ -430,7 +446,9 @@ u8 hwInitStream(u32 len) { return aramAllocateStreamBuffer(len); }
void hwExitStream(u8 id) { aramFreeStreamBuffer(id); }
void* hwGetStreamPlayBuffer(u8 hwStreamHandle) { return (void*)aramGetStreamBufferAddress(hwStreamHandle, NULL); }
void* hwGetStreamPlayBuffer(u8 hwStreamHandle) {
return (void*)aramGetStreamBufferAddress(hwStreamHandle, NULL);
}
void* hwTransAddr(void* samples) { return samples; }
@ -438,7 +456,7 @@ u32 hwFrq2Pitch(u32 frq) { return (frq * 4096.f) / synthInfo.mixFrq; }
void hwInitSampleMem(u32 baseAddr, u32 length) {
#line 940
MUSY_ASSERT(baseAddr==0x00000000);
MUSY_ASSERT(baseAddr == 0x00000000);
aramInit(length);
}
@ -458,13 +476,17 @@ static u32 convert_length(u32 len, u8 type) {
}
void hwSaveSample(void* header, void* data) {
#if MUSY_TARGET == MUSY_TARGET_DOLPHIN
u32 len = ((u32*)*((u32*)header))[1] & 0xFFFFFF;
u8 type = ((u32*)*((u32*)header))[1] >> 0x18;
len = convert_length(len, type);
*((u32*)data) = (u32)aramStoreData((void*)*((u32*)data), len);
#endif
}
void hwSetSaveSampleCallback(ARAMUploadCallback callback, unsigned long chunckSize) { aramSetUploadCallback(callback, chunckSize); }
void hwSetSaveSampleCallback(ARAMUploadCallback callback, unsigned long chunckSize) {
aramSetUploadCallback(callback, chunckSize);
}
void hwRemoveSample(void* header, void* data) {
#if MUSY_VERSION <= MUSY_VERSION_CHECK(1, 5, 3)

View File

@ -1,13 +1,24 @@
#include "musyx/assert.h"
#include "musyx/musyx.h"
#include "musyx/platform.h"
typedef struct STREAM_BUFFER {
// total size: 0x10
struct STREAM_BUFFER* next; // offset 0x0, size 0x4
unsigned long aram; // offset 0x4, size 0x4
unsigned long length; // offset 0x8, size 0x4
unsigned long allocLength; // offset 0xC, size 0x4
} STREAM_BUFFER;
#if MUSY_TARGET == MUSY_TARGET_DOLPHIN
#include <dolphin/ar.h>
#include <dolphin/arq.h>
#include <dolphin/os.h>
#include "musyx/assert.h"
typedef struct ARAMTransferJob {
// total size: 0x28
ARQRequest arq; // offset 0x0, size 0x20
void (*callback)(unsigned long); // offset 0x20, size 0x4
void (*callback)(u32); // offset 0x20, size 0x4
unsigned long user; // offset 0x24, size 0x4
} ARAMTransferJob;
@ -18,19 +29,11 @@ typedef struct ARAMTransferQueue {
vu8 valid; // offset 0x281, size 0x1
} ARAMTransferQueue;
typedef struct STREAM_BUFFER {
// total size: 0x10
struct STREAM_BUFFER* next; // offset 0x0, size 0x4
unsigned long aram; // offset 0x4, size 0x4
unsigned long length; // offset 0x8, size 0x4
unsigned long allocLength; // offset 0xC, size 0x4
} STREAM_BUFFER;
static unsigned long aramTop; // size: 0x4
static unsigned long aramWrite; // size: 0x4
static unsigned long aramStream; // size: 0x4
static void* (*aramUploadCallback)(unsigned long, unsigned long); // size: 0x4
static unsigned long aramUploadChunkSize; // size: 0x4
static u32 aramTop; // size: 0x4
static u32 aramWrite; // size: 0x4
static u32 aramStream; // size: 0x4
static void* (*aramUploadCallback)(u32, u32); // size: 0x4
static u32 aramUploadChunkSize; // size: 0x4
static ARAMTransferQueue aramQueueLo;
static ARAMTransferQueue aramQueueHi;
@ -337,3 +340,83 @@ void aramFreeStreamBuffer(unsigned char id) {
fSb->next = aramFreeStreamBuffers;
aramFreeStreamBuffers = fSb;
}
#elif MUSY_TARGET == MUSY_TARGET_PC
// typedef struct ARAMTransferJob {
// // total size: 0x28
// ARQRequest arq; // offset 0x0, size 0x20
// void (*callback)(unsigned long); // offset 0x20, size 0x4
// unsigned long user; // offset 0x24, size 0x4
// } ARAMTransferJob;
//
// typedef struct ARAMTransferQueue {
// // total size: 0x284
// ARAMTransferJob queue[16]; // offset 0x0, size 0x280
// vu8 write; // offset 0x280, size 0x1
// vu8 valid; // offset 0x281, size 0x1
// } ARAMTransferQueue;
//
// typedef struct STREAM_BUFFER {
// // total size: 0x10
// struct STREAM_BUFFER* next; // offset 0x0, size 0x4
// unsigned long aram; // offset 0x4, size 0x4
// unsigned long length; // offset 0x8, size 0x4
// unsigned long allocLength; // offset 0xC, size 0x4
// } STREAM_BUFFER;
//
// static unsigned long aramTop; // size: 0x4
// static unsigned long aramWrite; // size: 0x4
// static unsigned long aramStream; // size: 0x4
// static void* (*aramUploadCallback)(unsigned long, unsigned long); // size: 0x4
// static unsigned long aramUploadChunkSize; // size: 0x4
//
// static ARAMTransferQueue aramQueueLo;
// static ARAMTransferQueue aramQueueHi;
// static STREAM_BUFFER aramStreamBuffers[64];
// static STREAM_BUFFER* aramUsedStreamBuffers;
// static STREAM_BUFFER* aramFreeStreamBuffers;
// static STREAM_BUFFER* aramIdleStreamBuffers;
static void InitStreamBuffers();
static void aramQueueInit() {}
static void aramQueueCallback(unsigned long ptr) {}
void aramUploadData(void* mram, unsigned long aram, unsigned long len, unsigned long highPrio,
void (*callback)(unsigned long), unsigned long user) {}
void aramSyncTransferQueue() {}
void aramInit(unsigned long length) {}
void aramExit() {}
unsigned long aramGetZeroBuffer() { return 0; }
void aramSetUploadCallback(void* (*callback)(unsigned long, unsigned long),
unsigned long chunckSize) {}
void* aramStoreData(void* src, unsigned long len) {}
void aramRemoveData(void* aram, unsigned long len) {}
static void InitStreamBuffers() {}
unsigned char aramAllocateStreamBuffer(u32 len) { return 0; }
size_t aramGetStreamBufferAddress(u8 id, size_t* len) {
MUSY_ASSERT_MSG(id != 0xFF, "Stream buffer ID is invalid");
}
void aramFreeStreamBuffer(unsigned char id) {
STREAM_BUFFER* fSb; // r30
STREAM_BUFFER* sb; // r31
STREAM_BUFFER* lastSb; // r29
STREAM_BUFFER* nextSb; // r27
unsigned long minAddr; // r28
MUSY_ASSERT_MSG(id != 0xFF, "Stream buffer ID is invalid");
}
#endif

View File

@ -1,3 +1,6 @@
#include "musyx/platform.h"
#if MUSY_TARGET == MUSY_TARGET_DOLPHIN
#include "dolphin/dsp.h"
#include "musyx/assert.h"
#include "musyx/dsp_import.h"
@ -125,7 +128,7 @@ u32 salExitDsp() {
return TRUE;
}
void salStartDsp(u16* cmdList) {
void salStartDsp(s16* cmdList) {
salDspIsDone = FALSE;
PPCSync();
/* clang-format off */
@ -140,7 +143,7 @@ void salStartDsp(u16* cmdList) {
;
}
void salCtrlDsp(u16* dest) {
void salCtrlDsp(s16* dest) {
salBuildCommandList(dest, salGetStartDelay());
salStartDsp(dspCmdList);
}
@ -169,3 +172,4 @@ void hwDisableIrq() {
void hwIRQEnterCritical() { OSDisableInterrupts(); }
void hwIRQLeaveCritical() { OSEnableInterrupts(); }
#endif

View File

@ -20,6 +20,8 @@
#include "musyx/hardware.h"
#include "musyx/sal.h"
#include <string.h>
#ifdef _DEBUG
static u32 dbgActiveVoicesMax = 0;
#endif
@ -34,7 +36,7 @@ u16* dspCmdLastLoad = NULL;
u16* dspCmdLastBase = NULL;
u16* dspCmdList = NULL;
s16* dspCmdList = NULL;
u16 dspCmdLastSize = 0;
@ -50,7 +52,7 @@ u32 dspHRTFOn = FALSE;
s16* dspHrtfHistoryBuffer = NULL;
long* dspSurround = NULL;
s32* dspSurround = NULL;
s16* dspITDBuffer = NULL;
@ -58,10 +60,10 @@ DSPvoice* dspVoice = NULL;
SND_MESSAGE_CALLBACK salMessageCallback = NULL;
u32 salInitDspCtrl(u8 numVoices, u8 numStudios, u32 defaultStudioDPL2) {
u32 i; // r31
u32 j; // r27
u32 itdPtr; // r28
bool salInitDspCtrl(u8 numVoices, u8 numStudios, u32 defaultStudioDPL2) {
u32 i; // r31
u32 j; // r27
size_t itdPtr; // r28
salNumVoices = numVoices;
salMaxStudioNum = numStudios;
@ -70,15 +72,19 @@ u32 salInitDspCtrl(u8 numVoices, u8 numStudios, u32 defaultStudioDPL2) {
dspARAMZeroBuffer = aramGetZeroBuffer();
if ((dspCmdList = salMalloc(1024 * sizeof(u16))) != NULL) {
MUSY_DEBUG("Allocated dspCmdList.\n\n");
if ((dspSurround = salMalloc(160 * sizeof(long))) != NULL) {
if ((dspSurround = salMalloc(160 * sizeof(s32))) != NULL) {
MUSY_DEBUG("Allocated surround buffer.\n\n");
memset(dspSurround, 0, 160 * sizeof(long));
memset(dspSurround, 0, 160 * sizeof(s32));
#if MUSY_TARGET == MUSY_TARGET_DOLPHIN
DCFlushRange(dspSurround, 160 * sizeof(long));
#endif
if ((dspVoice = salMalloc(salNumVoices * sizeof(DSPvoice))) != NULL) {
MUSY_DEBUG("Allocated HW voice array.\n\n");
if ((dspITDBuffer = salMalloc(salNumVoices * 64)) != NULL) {
MUSY_DEBUG("Allocated ITD buffers for voice array.\n\n");
#if MUSY_TARGET == MUSY_TARGET_DOLPHIN
DCInvalidateRange(dspITDBuffer, salNumVoices * 64);
#endif
itdPtr = (u32)dspITDBuffer;
for (i = 0; i < salNumVoices; ++i) {
MUSY_DEBUG("Initializing voice %d...\n", i);
@ -101,8 +107,9 @@ u32 salInitDspCtrl(u8 numVoices, u8 numStudios, u32 defaultStudioDPL2) {
dspVoice[i].itdBuffer = (void*)itdPtr;
itdPtr += 0x40;
dspVoice[i].virtualSampleID = 0xFFFFFFFF;
#if MUSY_TARGET == MUSY_TARGET_DOLPHIN
DCStoreRangeNoSync(dspVoice[i].pb, sizeof(_PB));
#endif
for (j = 0; j < 5; ++j) {
dspVoice[i].changed[j] = 0;
}
@ -122,7 +129,9 @@ u32 salInitDspCtrl(u8 numVoices, u8 numStudios, u32 defaultStudioDPL2) {
}
memset(dspStudio[i].main[0], 0, 0x3c00);
#if MUSY_TARGET == MUSY_TARGET_DOLPHIN
DCFlushRangeNoSync(dspStudio[i].main[0], 0x3c00);
#endif
dspStudio[i].main[1] = dspStudio[i].main[0] + 0x1e0;
dspStudio[i].auxA[0] = dspStudio[i].main[1] + 0x1e0;
dspStudio[i].auxA[1] = dspStudio[i].auxA[0] + 0x1e0;
@ -137,11 +146,13 @@ u32 salInitDspCtrl(u8 numVoices, u8 numStudios, u32 defaultStudioDPL2) {
dspStudio[i].hostDPopSum.sA = 0;
dspStudio[i].hostDPopSum.lB = dspStudio[i].hostDPopSum.rB =
dspStudio[i].hostDPopSum.sB = 0;
#if MUSY_TARGET == MUSY_TARGET_DOLPHIN
DCFlushRangeNoSync(dspStudio[i].spb, sizeof(_SPB));
#endif
}
MUSY_DEBUG("All studios are initialized.\n\n");
salActivateStudio(
0, 1, defaultStudioDPL2 != FALSE ? SND_STUDIO_TYPE_RESERVED0 : SND_STUDIO_TYPE_STD);
0, 1, defaultStudioDPL2 != FALSE ? SND_STUDIO_TYPE_DPL2 : SND_STUDIO_TYPE_STD);
MUSY_DEBUG("Default studio is active.\n\n");
if ((dspHrtfHistoryBuffer = salMalloc(0x100)) == NULL) {
return FALSE;
@ -159,10 +170,12 @@ u32 salInitDspCtrl(u8 numVoices, u8 numStudios, u32 defaultStudioDPL2) {
void salInitHRTFBuffer() {
memset(dspHrtfHistoryBuffer, 0, 0x100);
#if MUSY_TARGET == MUSY_TARGET_DOLPHIN
DCFlushRangeNoSync(dspHrtfHistoryBuffer, 0x100);
#endif
}
u32 salExitDspCtrl() {
bool salExitDspCtrl() {
u8 i; // r31
salFree(dspHrtfHistoryBuffer);
@ -185,7 +198,9 @@ u32 salExitDspCtrl() {
void salActivateStudio(u8 studio, u32 isMaster, SND_STUDIO_TYPE type) {
memset(dspStudio[studio].main[0], 0, 0x3c00);
#if MUSY_TARGET == MUSY_TARGET_DOLPHIN
DCFlushRangeNoSync(dspStudio[studio].main[0], 0x3c00);
#endif
memset(dspStudio[studio].spb, 0, sizeof(_SPB));
dspStudio[studio].hostDPopSum.l = dspStudio[studio].hostDPopSum.r =
dspStudio[studio].hostDPopSum.s = 0;
@ -193,12 +208,17 @@ void salActivateStudio(u8 studio, u32 isMaster, SND_STUDIO_TYPE type) {
dspStudio[studio].hostDPopSum.sA = 0;
dspStudio[studio].hostDPopSum.lB = dspStudio[studio].hostDPopSum.rB =
dspStudio[studio].hostDPopSum.sB = 0;
#if MUSY_TARGET == MUSY_TARGET_DOLPHIN
DCFlushRangeNoSync(dspStudio[studio].spb, sizeof(_SPB));
#endif
memset(dspStudio[studio].auxA[0], 0, 0x780);
#if MUSY_TARGET == MUSY_TARGET_DOLPHIN
DCFlushRangeNoSync(dspStudio[studio].auxA[0], 0x780);
#endif
memset(dspStudio[studio].auxB[0], 0, 0x780);
#if MUSY_TARGET == MUSY_TARGET_DOLPHIN
DCFlushRangeNoSync(dspStudio[studio].auxB[0], 0x780);
#endif
dspStudio[studio].voiceRoot = NULL;
dspStudio[studio].alienVoiceRoot = NULL;
dspStudio[studio].state = 1;
@ -222,7 +242,7 @@ static const u16 dspMixerCycles[32] = {
void salDeactivateStudio(u8 studio) { dspStudio[studio].state = 0; }
static u32 salCheckVolErrorAndResetDelta(u16* dsp_vol, u16* dsp_delta, u16* last_vol, u16 targetVol,
u16* resetFlags, u16 resetMask) {
u16* resetFlags, u16 resetMask) {
s16 d; // r31
s16 x; // r30
@ -287,7 +307,7 @@ static void sal_update_hostplayinfo(DSPvoice* dsp_vptr) {
}
}
static void AddDpop(long* sum, s16 delta) {
static void AddDpop(s32* sum, s16 delta) {
*sum += (int)delta;
*sum = (*sum > 0x7fffff) ? 0x7fffff : (*sum < -0x7fffff ? -0x7fffff : *sum);
}
@ -369,7 +389,7 @@ static void SortVoices(DSPvoice** voices, long l, long r) {
void salBuildCommandList(signed short* dest, unsigned long nsDelay) {
static const u16 pbOffsets[9] = {10, 12, 24, 13, 16, 26, 18, 20, 22};
static DSPvoice * voices[64];
static DSPvoice* voices[64];
}
u32 salSynthSendMessage(DSPvoice* dsp_vptr, u32 mesg) {
@ -440,7 +460,7 @@ void salReconnectVoice(DSPvoice* dsp_vptr, u8 studio) {
dsp_vptr->studio = studio;
}
u32 salAddStudioInput(DSPstudioinfo* stp, SND_STUDIO_INPUT* desc) {
bool salAddStudioInput(DSPstudioinfo* stp, SND_STUDIO_INPUT* desc) {
if (stp->numInputs < 7) {
stp->in[stp->numInputs].studio = desc->srcStudio;
stp->in[stp->numInputs].vol = ((u16)desc->vol << 8) | ((u16)desc->vol << 1);
@ -454,7 +474,7 @@ u32 salAddStudioInput(DSPstudioinfo* stp, SND_STUDIO_INPUT* desc) {
return 0;
}
unsigned long salRemoveStudioInput(DSPstudioinfo* stp, SND_STUDIO_INPUT* desc) {
bool salRemoveStudioInput(DSPstudioinfo* stp, SND_STUDIO_INPUT* desc) {
long i; // r31
for (i = 0; i < stp->numInputs; ++i) {
@ -472,7 +492,7 @@ unsigned long salRemoveStudioInput(DSPstudioinfo* stp, SND_STUDIO_INPUT* desc) {
void salHandleAuxProcessing() {
u8 st; // r29
long* work; // r30
s32* work; // r30
DSPstudioinfo* sp; // r31
SND_AUX_INFO info; // r1+0x8
sp = &dspStudio[0];
@ -488,7 +508,9 @@ void salHandleAuxProcessing() {
info.data.bufferUpdate.right = work + 0xa0;
info.data.bufferUpdate.surround = work + 0x140;
sp->auxAHandler(0, &info, sp->auxAUser);
#if MUSY_TARGET == MUSY_TARGET_DOLPHIN
DCFlushRangeNoSync(work, 0x780);
#endif
}
if (sp->type == 0 && sp->auxBHandler != 0) {
@ -497,7 +519,9 @@ void salHandleAuxProcessing() {
info.data.bufferUpdate.right = work + 0xa0;
info.data.bufferUpdate.surround = work + 0x140;
sp->auxBHandler(0, &info, sp->auxBUser);
#if MUSY_TARGET == MUSY_TARGET_DOLPHIN
DCFlushRangeNoSync(work, 0x780);
#endif
}
}
}

138
src/musyx/runtime/hw_pc.c Normal file
View File

@ -0,0 +1,138 @@
#include "musyx/platform.h"
#if MUSY_TARGET == MUSY_TARGET_PC
#include <pthread.h>
#include "musyx/assert.h"
#include "musyx/hardware.h"
#include "musyx/sal.h"
#include <string.h>
static volatile u32 oldState = 0;
static volatile u16 hwIrqLevel = 0;
static volatile u32 salDspInitIsDone = 0;
static volatile u64 salLastTick = 0;
static volatile u32 salLogicActive = 0;
static volatile u32 salLogicIsWaiting = 0;
static volatile u32 salDspIsDone = 0;
void* salAIBufferBase = NULL;
static u8 salAIBufferIndex = 0;
static SND_SOME_CALLBACK userCallback = NULL;
#define DMA_BUFFER_LEN 0x280
pthread_mutex_t globalMutex;
pthread_mutex_t globalInterrupt;
u32 salGetStartDelay();
static void callUserCallback() {
if (salLogicActive) {
return;
}
salLogicActive = 1;
// OSEnableInterrupts();
userCallback();
// OSDisableInterrupts();
salLogicActive = 0;
}
void salCallback() {
salAIBufferIndex = (salAIBufferIndex + 1) % 4;
// AIInitDMA(OSCachedToPhysical(salAIBufferBase) + (salAIBufferIndex * DMA_BUFFER_LEN),
// DMA_BUFFER_LEN);
salLastTick = 0; // OSGetTick();
if (salDspIsDone) {
callUserCallback();
} else {
salLogicIsWaiting = 1;
}
}
void dspInitCallback() {
salDspIsDone = TRUE;
salDspInitIsDone = TRUE;
}
void dspResumeCallback() {
salDspIsDone = TRUE;
if (salLogicIsWaiting) {
salLogicIsWaiting = FALSE;
callUserCallback();
}
}
bool salInitAi(SND_SOME_CALLBACK callback, u32 unk, u32* outFreq) {
if ((salAIBufferBase = salMalloc(DMA_BUFFER_LEN * 4)) != NULL) {
memset(salAIBufferBase, 0, DMA_BUFFER_LEN * 4);
// DCFlushRange(salAIBufferBase, DMA_BUFFER_LEN * 4);
salAIBufferIndex = TRUE;
salLogicIsWaiting = FALSE;
salDspIsDone = TRUE;
salLogicActive = FALSE;
userCallback = callback;
// AIRegisterDMACallback(salCallback);
// AIInitDMA(OSCachedToPhysical(salAIBufferBase) + (salAIBufferIndex * 0x280), 0x280);
synthInfo.numSamples = 0x20;
*outFreq = 32000;
MUSY_DEBUG("MusyX AI interface initialized.\n");
return TRUE;
}
return FALSE;
}
bool salStartAi() { } //AIStartDMA(); }
bool salExitAi() {
salFree(salAIBufferBase);
return TRUE;
}
void* salAiGetDest() {
u8 index; // r31
index = (salAIBufferIndex + 2) % 4;
return NULL;
}
bool salInitDsp(u32) { return TRUE; }
bool salExitDsp() {}
void salStartDsp(s16* cmdList) {}
void salCtrlDsp(s16* dest) {
salBuildCommandList(dest, salGetStartDelay());
salStartDsp(dspCmdList);
}
u32 salGetStartDelay() { return 0; }
void hwInitIrq() {
// oldState = OSDisableInterrupts();
hwIrqLevel = 1;
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ROBUST);
pthread_mutex_init(&globalMutex, &attr);
}
void hwExitIrq() {}
void hwEnableIrq() {
if (--hwIrqLevel == 0) {
// OSRestoreInterrupts(oldState);
}
}
void hwDisableIrq() {
if ((hwIrqLevel++) == 0) {
// oldState = OSDisableInterrupts();
}
}
void hwIRQEnterCritical() {
pthread_mutex_lock(&globalMutex);
}
void hwIRQLeaveCritical() {
pthread_mutex_unlock(&globalMutex);
}
#endif

View File

@ -179,12 +179,12 @@ static void InsertFXTab(unsigned short gid, FX_DATA* fd) { dataInsertFX(gid, fd-
static void RemoveFXTab(unsigned short gid) { dataRemoveFX(gid); }
void sndSetSampleDataUploadCallback(void* (*callback)(unsigned long, unsigned long),
unsigned long chunckSize) {
void sndSetSampleDataUploadCallback(void* (*callback)(u32, u32),
u32 chunckSize) {
hwSetSaveSampleCallback(callback, chunckSize);
}
u32 sndPushGroup(void* prj_data, u16 gid, void* samples, void* sdir, void* pool) {
bool sndPushGroup(void* prj_data, u16 gid, void* samples, void* sdir, void* pool) {
GROUP_DATA* g; // r31
MUSY_ASSERT_MSG(prj_data != NULL, "Project data pointer is NULL");
MUSY_ASSERT_MSG(sdir != NULL, "Sample directory pointer is NULL");
@ -207,7 +207,7 @@ u32 sndPushGroup(void* prj_data, u16 gid, void* samples, void* sdir, void* pool)
}
hwSyncSampleMem();
++sp;
return 1;
return TRUE;
}
g = (GROUP_DATA*)((u8*)prj_data + g->nextOff);
@ -215,7 +215,7 @@ u32 sndPushGroup(void* prj_data, u16 gid, void* samples, void* sdir, void* pool)
}
MUSY_DEBUG("Group ID=%d could not be pushed.\n", gid);
return 0;
return FALSE;
}
/*
@ -230,11 +230,11 @@ u32 sndPushGroup(void* prj_data, u16 gid, void* samples, void* sdir, void* pool)
*/
unsigned long sndPopGroup() {
struct GROUP_DATA* g;
struct SDIR_DATA* sdir;
bool sndPopGroup() {
GROUP_DATA* g;
SDIR_DATA* sdir;
void* prj;
struct FX_DATA* fd;
FX_DATA* fd;
MUSY_ASSERT_MSG(sndActive != FALSE, "Sound system is not initialized.");
MUSY_ASSERT_MSG(sp != 0, "Soundstack is empty.");
@ -296,9 +296,9 @@ u32 seqPlaySong(u16 sgid, u16 sid, void* arrfile, SND_PLAYPARA* para, u8 irq_cal
if (gs[i].gAddr->type == 0) {
g = gs[i].gAddr;
prj = gs[i].prjAddr;
norm = (PAGE*)((u32)prj + g->data.song.normpageOff);
drum = (PAGE*)((u32)prj + g->data.song.drumpageOff);
midiSetup = (MIDISETUP*)((u32)prj + g->data.song.midiSetupOff);
norm = (PAGE*)((size_t)prj + g->data.song.normpageOff);
drum = (PAGE*)((size_t)prj + g->data.song.drumpageOff);
midiSetup = (MIDISETUP*)((size_t)prj + g->data.song.midiSetupOff);
while (midiSetup->songId != 0xFFFF) {
if (midiSetup->songId == sid) {
if (irq_call != 0) {

View File

@ -430,7 +430,7 @@ u32 seqStartPlay(PAGE* norm, PAGE* drum, MIDISETUP* midiSetup, u32* song, SND_PL
nseq->section[i].bpm = bpm;
synthSetBpm(bpm >> 10, seqId, i);
if (arr->mTrack != NULL) {
if (arr->mTrack != 0) {
nseq->section[i].mTrack.base = ARR_GET(arr, arr->mTrack);
nseq->section[i].mTrack.addr = nseq->section[i].mTrack.base;
} else {
@ -657,7 +657,6 @@ void seqSpeed(u32 seqId, u16 speed) {
u32 i; // r30
seqId = seqGetPrivateId(seqId);
#line 1018
MUSY_ASSERT_MSG(seqId != SND_SEQ_ERROR_ID, "Sequencer ID is not valid.");
if ((seqId & SND_SEQ_CROSSFADE_ID) == 0) {
@ -675,7 +674,6 @@ void seqContinue(u32 seqId) {
struct SEQ_INSTANCE* si; // r31
seqId = seqGetPrivateId(seqId);
#line 1043
MUSY_ASSERT_MSG(seqId != SND_SEQ_ERROR_ID, "Sequencer ID is not valid.");
if ((seqId & SND_SEQ_CROSSFADE_ID) == 0) {
@ -758,7 +756,6 @@ void seqVolume(u8 volume, u16 time, u32 seqId, u8 mode) {
seqInstance[seqId].syncCrossInfo.vol2 = volume;
break;
default:
#line 1153
MUSY_FATAL("Illegal sequencere fade mode detected.");
break;
}
@ -771,7 +768,6 @@ void seqCrossFade(SND_CROSSFADE* ci, u32* new_seqId, bool8 irq_call) {
u16 time; // r27
seqId = seqGetPrivateId(ci->seqId1);
#line 1170
MUSY_ASSERT_MSG(seqId != SND_SEQ_ERROR_ID, "Sequencer ID is not valid.");
if ((ci->flags & SND_CROSSFADE_SYNC) != 0) {
@ -1087,7 +1083,7 @@ static SEQ_EVENT* GetGlobalEvent(SEQ_SECTION* section) {
return ev;
}
static SEQ_EVENT* HandleEvent(SEQ_EVENT* event, u8 secIndex, u32* loopFlag) {
static SEQ_EVENT* HandleEvent(SEQ_EVENT* event, u8 secIndex, bool* loopFlag) {
CPAT* pa; // r26
NOTE_DATA* pe; // r24
s32 velocity; // r28

View File

@ -16,9 +16,9 @@
*/
#include "musyx/assert.h"
#include "musyx/hardware.h"
#include "musyx/seq.h"
#include "musyx/assert.h"
/*
@ -29,7 +29,7 @@
*/
void sndSeqCrossFade(struct SND_CROSSFADE* ci, unsigned long* new_seqId) {
void sndSeqCrossFade(struct SND_CROSSFADE* ci, u32* new_seqId) {
MUSY_ASSERT_MSG(sndActive, "Sound system is not initialized.");
MUSY_ASSERT_MSG(ci != NULL, "Crossfade information pointer is NULL.");
@ -49,7 +49,7 @@ void sndSeqCrossFade(struct SND_CROSSFADE* ci, unsigned long* new_seqId) {
*/
u32 sndSeqCrossFadeDone(u32* new_seqId) {
bool sndSeqCrossFadeDone(SND_SEQID* new_seqId) {
if (*new_seqId != -1) {
return (*new_seqId & 0x80000000) == 0;
}
@ -57,7 +57,7 @@ u32 sndSeqCrossFadeDone(u32* new_seqId) {
return TRUE;
}
u16 sndSeqGetLoopCnt(u32 seqId) {
u16 sndSeqGetLoopCnt(SND_SEQID seqId) {
MUSY_ASSERT_MSG(sndActive, "Sound system is not initialized.");
seqId = seqGetPrivateId(seqId);
@ -99,7 +99,7 @@ u16 sndSeqGetLoopCntEx(u32 seqId, u8 track) {
*/
unsigned long sndSeqGetValid(unsigned long seqId) {
bool sndSeqGetValid(SND_SEQID seqId) {
MUSY_ASSERT_MSG(sndActive, "Sound system is not initialized.");
return seqGetPrivateId(seqId) != -1;
@ -109,10 +109,10 @@ unsigned long sndSeqGetValid(unsigned long seqId) {
*/
void sndSeqPause(s32 unk) {
void sndSeqPause(SND_SEQID seqId) {
MUSY_ASSERT_MSG(sndActive, "Sound system is not initialized.");
hwDisableIrq();
seqPause(unk);
seqPause(seqId);
hwEnableIrq();
}
@ -121,10 +121,10 @@ void sndSeqPause(s32 unk) {
*/
void sndSeqStop(s32 unk) {
void sndSeqStop(SND_SEQID seqid) {
MUSY_ASSERT_MSG(sndActive, "Sound system is not initialized.");
hwDisableIrq();
seqStop(unk);
seqStop(seqid);
hwEnableIrq();
}
@ -133,7 +133,7 @@ void sndSeqStop(s32 unk) {
*/
unsigned long sndSeqLoop(unsigned long seqId, bool on) {
bool sndSeqLoop(SND_SEQID seqId, bool on) {
unsigned long i; // r30
MUSY_ASSERT_MSG(sndActive, "Sound system is not initialized.");
@ -162,8 +162,8 @@ unsigned long sndSeqLoop(unsigned long seqId, bool on) {
*/
unsigned long sndSeqLoopEx(unsigned long seqId, unsigned char track, bool on) {
unsigned long i; // r29
bool sndSeqLoopEx(SND_SEQID seqId, u8 track, bool on) {
u32 i; // r29
MUSY_ASSERT_MSG(sndActive, "Sound system is not initialized.");
if ((seqId = seqGetPrivateId(seqId)) != -1) {
@ -209,10 +209,10 @@ void sndSeqSpeed(u32 seqId, u16 speed) {
*/
void sndSeqContinue(s32 unk) {
void sndSeqContinue(SND_SEQID seqId) {
MUSY_ASSERT_MSG(sndActive, "Sound system is not initialized.");
hwDisableIrq();
seqContinue(unk);
seqContinue(seqId);
hwEnableIrq();
}
@ -221,10 +221,10 @@ void sndSeqContinue(s32 unk) {
*/
void sndSeqMute(s32 unk1, s32 unk2, s32 unk3) {
void sndSeqMute(SND_SEQID seqId, u32 mask1, u32 mask2) {
MUSY_ASSERT_MSG(sndActive, "Sound system is not initialized.");
hwDisableIrq();
seqMute(unk1, unk2, unk3);
seqMute(seqId, mask1, mask2);
hwEnableIrq();
}
@ -232,8 +232,7 @@ void sndSeqMute(s32 unk1, s32 unk2, s32 unk3) {
*/
void sndSeqVolume(unsigned char volume, unsigned short time, unsigned long seqId,
unsigned char mode) {
void sndSeqVolume(u8 volume, u16 time, u32 seqId, u8 mode) {
MUSY_ASSERT_MSG(sndActive, "Sound system is not initialized.");
hwDisableIrq();
seqVolume(volume, time, seqId, mode);
@ -245,7 +244,7 @@ void sndSeqVolume(unsigned char volume, unsigned short time, unsigned long seqId
*/
unsigned char sndSeqGetVolGroup(unsigned long seqId) {
u8 sndSeqGetVolGroup(SND_SEQID seqId) {
MUSY_ASSERT_MSG(sndActive, "Sound system is not initialized.");
if ((seqId = seqGetPrivateId(seqId)) != -1) {
return seqInstance[seqId].defVGroup;
@ -259,8 +258,7 @@ unsigned char sndSeqGetVolGroup(unsigned long seqId) {
*/
unsigned long sndSeqAssignVolGroup2Track(unsigned long seqId, unsigned char track,
unsigned char vGroup) {
bool sndSeqAssignVolGroup2Track(SND_SEQID seqId, u8 track, u8 vGroup) {
MUSY_ASSERT_MSG(sndActive, "Sound system is not initialized.");
if ((seqId = seqGetPrivateId(seqId)) != -1) {
@ -280,8 +278,8 @@ unsigned long sndSeqAssignVolGroup2Track(unsigned long seqId, unsigned char trac
*/
unsigned char sndSeqGetMidiCtrl(unsigned long seqId, unsigned char channel, unsigned char ctrl) {
unsigned char value; // r31
u8 sndSeqGetMidiCtrl(SND_SEQID seqId, u8 channel, u8 ctrl) {
u8 value; // r31
MUSY_ASSERT_MSG(sndActive, "Sound system is not initialized.");
value = 0;
@ -299,8 +297,8 @@ unsigned char sndSeqGetMidiCtrl(unsigned long seqId, unsigned char channel, unsi
*/
unsigned short sndSeqGetMidiCtrl14(unsigned long seqId, unsigned char channel, unsigned char ctrl) {
unsigned short value; // r31
u16 sndSeqGetMidiCtrl14(SND_SEQID seqId, u8 channel, u8 ctrl) {
u16 value; // r31
MUSY_ASSERT_MSG(sndActive, "Sound system is not initialized.");
value = 0;
@ -317,8 +315,7 @@ unsigned short sndSeqGetMidiCtrl14(unsigned long seqId, unsigned char channel, u
/*
*/
unsigned long sndSeqSetMidiCtrl(unsigned long seqId, unsigned char channel, unsigned char ctrl,
unsigned char value) {
bool sndSeqSetMidiCtrl(SND_SEQID seqId, u8 channel, u8 ctrl, u8 value) {
unsigned long ret = FALSE; // r30
MUSY_ASSERT_MSG(sndActive, "Sound system is not initialized.");
hwDisableIrq();
@ -339,9 +336,8 @@ unsigned long sndSeqSetMidiCtrl(unsigned long seqId, unsigned char channel, unsi
*/
unsigned long sndSeqSetMidiCtrl14(unsigned long seqId, unsigned char channel, unsigned char ctrl,
unsigned short value) {
unsigned long ret = FALSE; // r30
bool sndSeqSetMidiCtrl14(SND_SEQID seqId, u8 channel, u8 ctrl, u16 value) {
bool ret = FALSE; // r30
MUSY_ASSERT_MSG(sndActive, "Sound system is not initialized.");
hwDisableIrq();
if ((seqId = seqGetPrivateId(seqId)) != -1) {

View File

@ -601,9 +601,9 @@ static SND_VOICEID AddEmitter(SND_EMITTER* em_buffer, SND_FVECTOR* pos, SND_FVEC
return -1;
}
unsigned long sndAddEmitter(SND_EMITTER* em_buffer, SND_FVECTOR* pos, SND_FVECTOR* dir, f32 maxDis,
f32 comp, unsigned long flags, unsigned short fxid,
unsigned char maxVol, unsigned char minVol, SND_ROOM* room) {
SND_VOICEID sndAddEmitter(SND_EMITTER* em_buffer, SND_FVECTOR* pos, SND_FVECTOR* dir, f32 maxDis,
f32 comp, u32 flags, SND_FXID fxid, u8 maxVol, u8 minVol,
SND_ROOM* room) {
if (sndActive) {
return AddEmitter(em_buffer, pos, dir, maxDis, comp, flags, fxid, fxid | 0x80000000, maxVol,
minVol, room, NULL, 0);
@ -612,10 +612,9 @@ unsigned long sndAddEmitter(SND_EMITTER* em_buffer, SND_FVECTOR* pos, SND_FVECTO
return -1;
}
unsigned long sndAddEmitterEx(struct SND_EMITTER* em_buffer, struct SND_FVECTOR* pos,
struct SND_FVECTOR* dir, f32 maxDis, f32 comp, unsigned long flags,
unsigned short fxid, unsigned short groupid, unsigned char maxVol,
unsigned char minVol, struct SND_ROOM* room) {
SND_VOICEID sndAddEmitterEx(SND_EMITTER* em_buffer, SND_FVECTOR* pos, SND_FVECTOR* dir, f32 maxDis,
f32 comp, u32 flags, SND_FXID fxid, unsigned short groupid, u8 maxVol,
u8 minVol, SND_ROOM* room) {
if (sndActive) {
return AddEmitter(em_buffer, pos, dir, maxDis, comp, flags, fxid, groupid, maxVol, minVol, room,
NULL, 0);
@ -624,10 +623,9 @@ unsigned long sndAddEmitterEx(struct SND_EMITTER* em_buffer, struct SND_FVECTOR*
return -1;
}
unsigned long sndAddEmitterPara(struct SND_EMITTER* em_buffer, struct SND_FVECTOR* pos,
struct SND_FVECTOR* dir, f32 maxDis, f32 comp, unsigned long flags,
unsigned short fxid, unsigned char maxVol, unsigned char minVol,
struct SND_ROOM* room, struct SND_PARAMETER_INFO* para) {
SND_VOICEID sndAddEmitterPara(SND_EMITTER* em_buffer, struct SND_FVECTOR* pos, SND_FVECTOR* dir,
f32 maxDis, f32 comp, u32 flags, SND_FXID fxid, u8 maxVol, u8 minVol,
SND_ROOM* room, struct SND_PARAMETER_INFO* para) {
if (sndActive) {
return AddEmitter(em_buffer, pos, dir, maxDis, comp, flags, fxid, fxid | 0x80000000, maxVol,
minVol, room, para, 0);
@ -635,11 +633,9 @@ unsigned long sndAddEmitterPara(struct SND_EMITTER* em_buffer, struct SND_FVECTO
return -1;
}
unsigned long sndAddEmitterParaEx(struct SND_EMITTER* em_buffer, struct SND_FVECTOR* pos,
struct SND_FVECTOR* dir, f32 maxDis, f32 comp,
unsigned long flags, unsigned short fxid, unsigned short groupid,
unsigned char maxVol, unsigned char minVol, struct SND_ROOM* room,
struct SND_PARAMETER_INFO* para) {
SND_VOICEID sndAddEmitterParaEx(SND_EMITTER* em_buffer, SND_FVECTOR* pos, SND_FVECTOR* dir,
f32 maxDis, f32 comp, u32 flags, SND_FXID fxid, SND_GROUPID groupid,
u8 maxVol, u8 minVol, SND_ROOM* room, SND_PARAMETER_INFO* para) {
if (sndActive) {
return AddEmitter(em_buffer, pos, dir, maxDis, comp, flags, fxid, groupid, maxVol, minVol, room,
para, 0);
@ -648,10 +644,9 @@ unsigned long sndAddEmitterParaEx(struct SND_EMITTER* em_buffer, struct SND_FVEC
return -1;
}
unsigned long sndAddEmitter2Studio(struct SND_EMITTER* em_buffer, struct SND_FVECTOR* pos,
struct SND_FVECTOR* dir, f32 maxDis, f32 comp,
unsigned long flags, unsigned short fxid, unsigned char maxVol,
unsigned char minVol, unsigned char studio) {
SND_VOICEID sndAddEmitter2Studio(SND_EMITTER* em_buffer, SND_FVECTOR* pos, SND_FVECTOR* dir,
f32 maxDis, f32 comp, u32 flags, SND_FXID fxid, u8 maxVol,
u8 minVol, u8 studio) {
if (sndActive) {
return AddEmitter(em_buffer, pos, dir, maxDis, comp, flags, fxid, fxid | 0x80000000, maxVol,
minVol, NULL, NULL, studio);
@ -659,11 +654,9 @@ unsigned long sndAddEmitter2Studio(struct SND_EMITTER* em_buffer, struct SND_FVE
return -1;
}
unsigned long sndAddEmitter2StudioEx(struct SND_EMITTER* em_buffer, struct SND_FVECTOR* pos,
struct SND_FVECTOR* dir, f32 maxDis, f32 comp,
unsigned long flags, unsigned short fxid,
unsigned short groupid, unsigned char maxVol,
unsigned char minVol, unsigned char studio) {
SND_VOICEID sndAddEmitter2StudioEx(SND_EMITTER* em_buffer, SND_FVECTOR* pos, SND_FVECTOR* dir,
f32 maxDis, f32 comp, u32 flags, SND_FXID fxid, u16 groupid,
u8 maxVol, u8 minVol, u8 studio) {
if (sndActive) {
return AddEmitter(em_buffer, pos, dir, maxDis, comp, flags, fxid, groupid, maxVol, minVol, NULL,
NULL, studio);
@ -671,11 +664,9 @@ unsigned long sndAddEmitter2StudioEx(struct SND_EMITTER* em_buffer, struct SND_F
return -1;
}
unsigned long sndAddEmitter2StudioPara(struct SND_EMITTER* em_buffer, struct SND_FVECTOR* pos,
struct SND_FVECTOR* dir, f32 maxDis, f32 comp,
unsigned long flags, unsigned short fxid,
unsigned char maxVol, unsigned char minVol,
unsigned char studio, struct SND_PARAMETER_INFO* para) {
SND_VOICEID sndAddEmitter2StudioPara(SND_EMITTER* em_buffer, SND_FVECTOR* pos, SND_FVECTOR* dir,
f32 maxDis, f32 comp, u32 flags, SND_FXID fxid, u8 maxVol,
u8 minVol, u8 studio, SND_PARAMETER_INFO* para) {
if (sndActive) {
return AddEmitter(em_buffer, pos, dir, maxDis, comp, flags, fxid, fxid | 0x80000000, maxVol,
minVol, NULL, para, studio);
@ -683,12 +674,9 @@ unsigned long sndAddEmitter2StudioPara(struct SND_EMITTER* em_buffer, struct SND
return -1;
}
unsigned long sndAddEmitter2StudioParaEx(struct SND_EMITTER* em_buffer, struct SND_FVECTOR* pos,
struct SND_FVECTOR* dir, f32 maxDis, f32 comp,
unsigned long flags, unsigned short fxid,
unsigned short groupid, unsigned char maxVol,
unsigned char minVol, unsigned char studio,
struct SND_PARAMETER_INFO* para) {
SND_VOICEID sndAddEmitter2StudioParaEx(SND_EMITTER* em_buffer, SND_FVECTOR* pos, SND_FVECTOR* dir,
f32 maxDis, f32 comp, u32 flags, SND_FXID fxid, u16 groupid,
u8 maxVol, u8 minVol, u8 studio, SND_PARAMETER_INFO* para) {
if (sndActive) {
return AddEmitter(em_buffer, pos, dir, maxDis, comp, flags, fxid, groupid, maxVol, minVol, NULL,
para, studio);
@ -696,7 +684,7 @@ unsigned long sndAddEmitter2StudioParaEx(struct SND_EMITTER* em_buffer, struct S
return -1;
}
unsigned long sndRemoveEmitter(SND_EMITTER* em) {
bool sndRemoveEmitter(SND_EMITTER* em) {
if (sndActive) {
hwDisableIrq();
if (em->flags & 0x10000) {
@ -711,7 +699,7 @@ unsigned long sndRemoveEmitter(SND_EMITTER* em) {
}
SND_VOICEID sndEmitterVoiceID(SND_EMITTER* em) {
unsigned long ret; // r31
SND_VOICEID ret; // r31
ret = 0xffffffff;
if (sndActive != FALSE) {
@ -770,8 +758,8 @@ static void MakeListenerMatrix(SND_LISTENER* li) {
salInvertMatrix(&li->mat, &mat);
}
unsigned long sndUpdateListener(SND_LISTENER* li, SND_FVECTOR* pos, SND_FVECTOR* dir,
SND_FVECTOR* heading, SND_FVECTOR* up, u8 vol, SND_ROOM* room) {
bool sndUpdateListener(SND_LISTENER* li, SND_FVECTOR* pos, SND_FVECTOR* dir, SND_FVECTOR* heading,
SND_FVECTOR* up, u8 vol, SND_ROOM* room) {
if (sndActive) {
hwDisableIrq();
li->pos = *pos;
@ -800,10 +788,9 @@ unsigned long sndUpdateListener(SND_LISTENER* li, SND_FVECTOR* pos, SND_FVECTOR*
return FALSE;
}
unsigned long sndAddListenerEx(SND_LISTENER* li, SND_FVECTOR* pos, SND_FVECTOR* dir,
SND_FVECTOR* heading, SND_FVECTOR* up, f32 front_sur, f32 back_sur,
f32 soundSpeed, f32 volPosOffset, unsigned long flags,
unsigned char vol, SND_ROOM* room) {
bool sndAddListenerEx(SND_LISTENER* li, SND_FVECTOR* pos, SND_FVECTOR* dir, SND_FVECTOR* heading,
SND_FVECTOR* up, f32 front_sur, f32 back_sur, f32 soundSpeed,
f32 volPosOffset, u32 flags, u8 vol, SND_ROOM* room) {
if (sndActive) {
hwDisableIrq();
@ -835,15 +822,14 @@ unsigned long sndAddListenerEx(SND_LISTENER* li, SND_FVECTOR* pos, SND_FVECTOR*
return FALSE;
}
unsigned long sndAddListener(SND_LISTENER* li, SND_FVECTOR* pos, SND_FVECTOR* dir,
SND_FVECTOR* heading, SND_FVECTOR* up, f32 front_sur, f32 back_sur,
f32 soundSpeed, unsigned long flags, unsigned char vol,
SND_ROOM* room) {
bool sndAddListener(SND_LISTENER* li, SND_FVECTOR* pos, SND_FVECTOR* dir, SND_FVECTOR* heading,
SND_FVECTOR* up, f32 front_sur, f32 back_sur, f32 soundSpeed, u32 flags, u8 vol,
SND_ROOM* room) {
return sndAddListenerEx(li, pos, dir, heading, up, front_sur, back_sur, soundSpeed, 0.f, flags,
vol, room);
}
unsigned long sndRemoveListener(SND_LISTENER* li) {
bool sndRemoveListener(SND_LISTENER* li) {
if (sndActive) {
hwDisableIrq();

View File

@ -18,11 +18,11 @@
*/
#include "musyx/assert.h"
#include "musyx/hardware.h"
#include "musyx/s3d.h"
#include "musyx/seq.h"
#include "musyx/stream.h"
#include "musyx/synth.h"
#include "musyx/hardware.h"
#include "musyx/synthdata.h"
// #define _DEBUG
@ -41,8 +41,7 @@ static s32 DoInit(u32 mixFrq, u32 aramSize, u32 numVoices, u32 flags)
{
bool ret;
MUSY_DEBUG("\nMusyX software initialization...\nBuild Date: %s %s\n\n", "Dec 17 2003",
"20:32:41");
MUSY_DEBUG("\nMusyX software initialization...\nBuild Date: %s %s\n\n", __DATE__, __TIME__);
ret = FALSE;
#if MUSY_VERSION >= MUSY_VERSION_CHECK(2, 0, 3)

View File

@ -109,7 +109,7 @@ void* sndBSearch(void* key, void* base, s32 num, s32 len, SND_COMPARE cmp) {
r = num;
do {
// This is kind of gross....
if ((c = cmp(key, (ptr = (void*)((u32)base + len * ((m = (l + r) >> 1) - 1))))) == 0) {
if ((c = cmp(key, (ptr = (void*)((size_t)base + len * ((m = (l + r) >> 1) - 1))))) == 0) {
return ptr;
}

View File

@ -202,7 +202,7 @@ SND_VOICEID sndFXStartParaInfo(SND_FXID fid, u8 vol, u8 pan, u8 studio,
*/
SND_VOICEID sndFXCheck(SND_VOICEID vid) {
MUSY_ASSERT_MSG(sndActive != NULL, "Sound system is not initialized.");
MUSY_ASSERT_MSG(sndActive != FALSE, "Sound system is not initialized.");
return vidGetInternalId(vid) != -1 ? vid : -1;
}
@ -213,9 +213,9 @@ SND_VOICEID sndFXCheck(SND_VOICEID vid) {
*/
bool sndReadFlag(unsigned char num) {
s32 sndReadFlag(unsigned char num) {
MUSY_ASSERT_MSG(sndActive != NULL, "Sound system is not initialized.");
MUSY_ASSERT_MSG(sndActive != FALSE, "Sound system is not initialized.");
return synthGlobalVariable[num & 0xf];
}
@ -225,9 +225,9 @@ bool sndReadFlag(unsigned char num) {
*/
long sndWriteFlag(unsigned char num, long value) {
long old; // r30
MUSY_ASSERT_MSG(sndActive != NULL, "Sound system is not initialized.");
s32 sndWriteFlag(u8 num, s32 value) {
s32 old; // r30
MUSY_ASSERT_MSG(sndActive != FALSE, "Sound system is not initialized.");
num &= 0xf;
@ -244,9 +244,9 @@ long sndWriteFlag(unsigned char num, long value) {
*/
u32 sndSendMessage(u32 vid, s32 mesg) {
u32 ret; // r31
MUSY_ASSERT_MSG(sndActive != NULL, "Sound system is not initialized.");
bool sndSendMessage(SND_VOICEID vid, s32 mesg) {
bool ret; // r31
MUSY_ASSERT_MSG(sndActive != FALSE, "Sound system is not initialized.");
hwDisableIrq();
ret = macPostMessage(vid, mesg);
@ -258,8 +258,8 @@ u32 sndSendMessage(u32 vid, s32 mesg) {
*/
void sndSetReceiveMessageCallback(void (*callback)(unsigned long, long)) {
MUSY_ASSERT_MSG(sndActive != NULL, "Sound system is not initialized.");
void sndSetReceiveMessageCallback(void (*callback)(u32, s32)) {
MUSY_ASSERT_MSG(sndActive != FALSE, "Sound system is not initialized.");
synthMessageCallback = callback;
}
@ -269,7 +269,7 @@ void sndSetReceiveMessageCallback(void (*callback)(unsigned long, long)) {
*/
void sndSilence() {
MUSY_ASSERT_MSG(sndActive != NULL, "Sound system is not initialized.");
MUSY_ASSERT_MSG(sndActive != FALSE, "Sound system is not initialized.");
hwDisableIrq();
seqKillAllInstances();
@ -283,11 +283,11 @@ void sndSilence() {
*/
u32 sndIsIdle() {
bool sndIsIdle() {
u32 i; // r31
u8 flag; // r30
MUSY_ASSERT_MSG(sndActive != NULL, "Sound system is not initialized.");
MUSY_ASSERT_MSG(sndActive != FALSE, "Sound system is not initialized.");
flag = 0;
@ -308,11 +308,11 @@ u32 sndIsIdle() {
*/
u32 sndFXAssignVolGroup2FXId(SND_FXID fid, u8 vGroup) {
bool sndFXAssignVolGroup2FXId(SND_FXID fid, u8 vGroup) {
FX_TAB* fx; // r30
u32 ret; // r29
MUSY_ASSERT_MSG(sndActive != NULL, "Sound system is not initialized.");
MUSY_ASSERT_MSG(sndActive != FALSE, "Sound system is not initialized.");
ret = 0;
@ -350,7 +350,7 @@ u32 sndFXAssignVolGroup2FXId(SND_FXID fid, u8 vGroup) {
*/
void sndPauseVolume(u8 volume, u16 time, u8 vGroup) {
MUSY_ASSERT_MSG(sndActive != NULL, "Sound system is not initialized.");
MUSY_ASSERT_MSG(sndActive != FALSE, "Sound system is not initialized.");
hwDisableIrq();
synthPauseVolume(volume, time, vGroup);
@ -363,7 +363,7 @@ void sndPauseVolume(u8 volume, u16 time, u8 vGroup) {
*/
void sndVolume(u8 volume, u16 time, u8 volgroup) {
MUSY_ASSERT_MSG(sndActive != NULL, "Sound system is not initialized.");
MUSY_ASSERT_MSG(sndActive != FALSE, "Sound system is not initialized.");
hwDisableIrq();
synthVolume(volume, time, volgroup, 0, -1);
@ -375,7 +375,7 @@ void sndVolume(u8 volume, u16 time, u8 volgroup) {
*/
void sndMasterVolume(u8 volume, u16 time, u8 music, u8 fx) {
MUSY_ASSERT_MSG(sndActive != NULL, "Sound system is not initialized.");
MUSY_ASSERT_MSG(sndActive != FALSE, "Sound system is not initialized.");
hwDisableIrq();
if (music != 0)
synthVolume(volume, time, 0x15, 0, -1);
@ -392,7 +392,7 @@ void sndMasterVolume(u8 volume, u16 time, u8 music, u8 fx) {
void sndOutputMode(SND_OUTPUTMODE output) {
u32 i;
u32 oldFlags;
MUSY_ASSERT_MSG(sndActive != NULL, "Sound system is not initialized.");
MUSY_ASSERT_MSG(sndActive != FALSE, "Sound system is not initialized.");
oldFlags = synthFlags;
switch (output) {
@ -418,9 +418,7 @@ void sndOutputMode(SND_OUTPUTMODE output) {
break;
default:
#line 426
MUSY_ASSERT_MSG(FALSE, "Unsupported outputmode selected.");
#line 418
break;
}
@ -449,7 +447,7 @@ void sndSetAuxProcessingCallbacks(u8 studio,
SND_AUX_CALLBACK auxA, void* userA, u8 midiA, SND_SEQID seqIDA,
SND_AUX_CALLBACK auxB, void* userB, u8 midiB, SND_SEQID seqIDB) {
// clang-format on
MUSY_ASSERT_MSG(sndActive != NULL, "Sound system is not initialized.");
MUSY_ASSERT_MSG(sndActive != FALSE, "Sound system is not initialized.");
hwDisableIrq();
if (auxA != NULL) {
@ -503,7 +501,7 @@ void sndUpdateAuxParameter(unsigned char studio, unsigned short* para, unsigned
struct SND_AUX_INFO info; // r1+0x14
unsigned long i; // r30
MUSY_ASSERT_MSG(sndActive != NULL, "Sound system is not initialized.");
MUSY_ASSERT_MSG(sndActive != FALSE, "Sound system is not initialized.");
for (i = 0; i < 4; ++i) {
info.data.parameterUpdate.para[i] = para[i];
@ -524,7 +522,7 @@ void sndUpdateAuxParameter(unsigned char studio, unsigned short* para, unsigned
*/
void sndSetITDDefault(unsigned char studio, unsigned long musicITD, unsigned long sfxITD) {
void sndSetITDDefault(u8 studio, bool musicITD, bool sfxITD) {
synthITDDefault[studio].music = musicITD;
synthITDDefault[studio].sfx = sfxITD;
}
@ -534,7 +532,7 @@ void sndSetITDDefault(unsigned char studio, unsigned long musicITD, unsigned lon
*/
void synthActivateStudio(u8 studio, u32 isMaster, SND_STUDIO_TYPE type) {
MUSY_ASSERT_MSG(sndActive != NULL, "Sound system is not initialized.");
MUSY_ASSERT_MSG(sndActive != FALSE, "Sound system is not initialized.");
hwDisableIrq();
synthAuxACallback[studio] = NULL;
synthAuxBCallback[studio] = NULL;
@ -551,8 +549,8 @@ void synthActivateStudio(u8 studio, u32 isMaster, SND_STUDIO_TYPE type) {
*/
void sndActivateStudioEx(u8 studio, u32 isMaster, SND_STUDIO_TYPE type) {
MUSY_ASSERT_MSG(sndActive != NULL, "Sound system is not initialized.");
void sndActivateStudioEx(u8 studio, bool isMaster, SND_STUDIO_TYPE type) {
MUSY_ASSERT_MSG(sndActive != FALSE, "Sound system is not initialized.");
MUSY_ASSERT_MSG(studio < synthInfo.studioNum, "Illegal studio index.");
if (studio != 0) {
hwDisableIrq();
@ -573,7 +571,7 @@ void sndActivateStudioEx(u8 studio, u32 isMaster, SND_STUDIO_TYPE type) {
*/
void synthDeactivateStudio(u8 studio) {
u32 i;
MUSY_ASSERT_MSG(sndActive != NULL, "Sound system is not initialized.");
MUSY_ASSERT_MSG(sndActive != FALSE, "Sound system is not initialized.");
for (i = 0; i < synthInfo.voiceNum; ++i) {
@ -605,7 +603,7 @@ void synthDeactivateStudio(u8 studio) {
*/
void sndDeactivateStudio(u8 studio) {
MUSY_ASSERT_MSG(sndActive != NULL, "Sound system is not initialized.");
MUSY_ASSERT_MSG(sndActive != FALSE, "Sound system is not initialized.");
MUSY_ASSERT_MSG(studio < synthInfo.studioNum, "Illegal studio index.");
if (studio != 0) {
hwDisableIrq();
@ -624,14 +622,14 @@ void sndDeactivateStudio(u8 studio) {
*/
void synthChangeStudioMasterMix(u8 studio, u32 isMaster) {
MUSY_ASSERT_MSG(sndActive != NULL, "Sound system is not initialized.");
MUSY_ASSERT_MSG(sndActive != FALSE, "Sound system is not initialized.");
hwChangeStudioMix(studio, isMaster);
}
//
void sndChangeStudioMasterMix(unsigned char studio, unsigned long isMaster) {
MUSY_ASSERT_MSG(sndActive != NULL, "Sound system is not initialized.");
void sndChangeStudioMasterMix(u8 studio, bool isMaster) {
MUSY_ASSERT_MSG(sndActive != FALSE, "Sound system is not initialized.");
if (studio != 0) {
hwDisableIrq();
synthChangeStudioMasterMix(studio, isMaster);
@ -648,18 +646,18 @@ void sndChangeStudioMasterMix(unsigned char studio, unsigned long isMaster) {
*/
u32 synthAddStudioInput(u8 studio, SND_STUDIO_INPUT* in_desc) {
bool synthAddStudioInput(u8 studio, SND_STUDIO_INPUT* in_desc) {
MUSY_ASSERT_MSG(sndActive != NULL, "Sound system is not initialized.");
MUSY_ASSERT_MSG(sndActive != FALSE, "Sound system is not initialized.");
return hwAddInput(studio, in_desc);
}
//
u32 sndAddStudioInput(u8 studio, struct SND_STUDIO_INPUT* in_desc) {
bool sndAddStudioInput(u8 studio, SND_STUDIO_INPUT* in_desc) {
u32 ret;
MUSY_ASSERT_MSG(sndActive != NULL, "Sound system is not initialized.");
MUSY_ASSERT_MSG(sndActive != FALSE, "Sound system is not initialized.");
hwDisableIrq();
ret = synthAddStudioInput(studio, in_desc);
hwEnableIrq();
@ -669,17 +667,17 @@ u32 sndAddStudioInput(u8 studio, struct SND_STUDIO_INPUT* in_desc) {
/*
*/
u32 synthRemoveStudioInput(u8 studio, SND_STUDIO_INPUT* in_desc) {
MUSY_ASSERT_MSG(sndActive != NULL, "Sound system is not initialized.");
bool synthRemoveStudioInput(u8 studio, SND_STUDIO_INPUT* in_desc) {
MUSY_ASSERT_MSG(sndActive != FALSE, "Sound system is not initialized.");
return hwRemoveInput(studio, in_desc);
}
/*
*/
u32 sndRemoveStudioInput(u8 studio, SND_STUDIO_INPUT* in_desc) {
u32 ret;
MUSY_ASSERT_MSG(sndActive != NULL, "Sound system is not initialized.");
bool sndRemoveStudioInput(u8 studio, SND_STUDIO_INPUT* in_desc) {
bool ret;
MUSY_ASSERT_MSG(sndActive != FALSE, "Sound system is not initialized.");
hwDisableIrq();
ret = synthRemoveStudioInput(studio, in_desc);
hwEnableIrq();

View File

@ -2,11 +2,11 @@
#include "musyx/assert.h"
#include "musyx/hardware.h"
#include "musyx/snd.h"
#include "musyx/stream.h"
#include "musyx/synth.h"
#include "musyx/synthdata.h"
#include "musyx/voice.h"
#include "musyx/snd.h"
#if !defined(_DEBUG) && MUSY_TARGET == MUSY_TARGET_DOLPHIN
#include "dolphin/os.h"
@ -129,8 +129,8 @@ void streamHandle() {
} break;
case 1: {
cpos = (si->last / 14) * 8;
if ((len = si->updateFunction((void*)((u32)si->buffer + cpos), off - si->last, NULL, 0,
si->user)) != 0 &&
if ((len = si->updateFunction((void*)((size_t)si->buffer + cpos), off - si->last, NULL,
0, si->user)) != 0 &&
si->state == 2) {
off = (si->last + len) % si->size;
@ -167,7 +167,7 @@ void streamHandle() {
break;
case 1:
cpos = ((si->last / 14) * 8);
if ((len = si->updateFunction((void*)((u32)si->buffer + cpos), si->size - si->last,
if ((len = si->updateFunction((void*)((size_t)si->buffer + cpos), si->size - si->last,
NULL, 0, si->user)) &&
si->state == 2) {
off = (si->last + len) % si->size;
@ -211,7 +211,7 @@ void streamHandle() {
break;
case 1: {
cpos = (si->last / 14) * 8;
if ((len = si->updateFunction((void*)((u32)si->buffer + cpos), si->size - si->last,
if ((len = si->updateFunction((void*)((size_t)si->buffer + cpos), si->size - si->last,
si->buffer, off, si->user)) &&
si->state == 2) {
off = (si->last + len) % si->size;
@ -334,20 +334,16 @@ void sndStreamARAMUpdate(u32 stid, u32 off1, u32 len1, u32 off2, u32 len2) {
#if MUSY_VERSION >= MUSY_VERSION_CHECK(1, 5, 4)
if (streamInfo[i].type == 1) {
#if MUSY_TARGET == MUSY_TARGET_DOLPHIN
streamInfo[i].lastPSFromBuffer = (*(u32*)OSCachedToUncached(streamInfo[i].buffer)) >> 24;
#elif MUSY_TARGET == MUSY_TARGET_PC
streamInfo[i].lastPSFromBuffer = (*(u32*)streamInfo[i].buffer) >> 24;
#endif
streamInfo[i].lastPSFromBuffer =
(*(u32*)MUSY_CACHED_TO_UNCACHED_ADDR(streamInfo[i].buffer)) >> 24;
if (streamInfo[i].voice != -1) {
hwSetStreamLoopPS(streamInfo[i].voice, streamInfo[i].lastPSFromBuffer);
}
}
#else
if (streamInfo[i].type == 1) {
hwSetStreamLoopPS(streamInfo[i].voice, *(u32*)OSCachedToUncached(streamInfo[i].buffer) >> 24);
hwSetStreamLoopPS(streamInfo[i].voice,
*(u32*)MUSY_CACHED_TO_UNCACHED_ADDR(streamInfo[i].buffer) >> 24);
}
#endif
} else {
@ -398,9 +394,11 @@ void streamOutputModeChanged() {
}
#endif
u32 sndStreamAllocEx(u8 prio, void* buffer, u32 samples, u32 frq, u8 vol, u8 pan, u8 span, u8 auxa,
u8 auxb, u8 studio, u32 flags, SND_STREAM_UPDATE_CALLBACK updateFunction,
u32 user, SND_ADPCMSTREAM_INFO* adpcmInfo) {
SND_STREAMID sndStreamAllocEx(u8 prio, void* buffer, u32 samples, u32 frq, u8 vol, u8 pan, u8 span,
u8 auxa, u8 auxb, u8 studio, u32 flags,
u32 (*updateFunction)(void* buffer1, u32 len1, void* buffer2,
u32 len2, u32 user),
u32 user, SND_ADPCMSTREAM_INFO* adpcmInfo) {
u32 stid; // r29
u32 i; // r31
u32 bytes; // r25
@ -643,7 +641,7 @@ void sndStreamFree(u32 stid) {
hwEnableIrq();
}
u32 sndStreamActivate(u32 stid) {
bool sndStreamActivate(SND_STREAMID stid) {
u32 i; // r31
u32 ret; // r28
ret = 0;

View File

@ -1091,9 +1091,9 @@ static bool synthFXVolume(u32 vid, u8 vol) {
return ret;
}
u32 synthSendKeyOff(u32 voiceid) {
bool synthSendKeyOff(u32 voiceid) {
u32 i; // r30
u32 ret; // r29
bool ret; // r29
ret = FALSE;
@ -1206,7 +1206,7 @@ void synthVolume(u8 volume, u16 time, u8 vGroup, u8 seqMode, u32 seqId) {
}
}
u32 synthIsFadeOutActive(u8 vGroup) {
bool synthIsFadeOutActive(u8 vGroup) {
if (synthMasterFader[vGroup].type != 4 && (synthMasterFaderActiveFlags & (1 << vGroup)) != 0 &&
synthMasterFader[vGroup].start > synthMasterFader[vGroup].target) {
return TRUE;

View File

@ -11,7 +11,7 @@ static u32 adsrGetIndex(ADSR_VARS* adsr) {
return i < 0 ? 0 : i;
}
u32 adsrConvertTimeCents(long tc) { return 1000.f * powf(2.f, 1.2715658e-08f * tc); }
u32 adsrConvertTimeCents(s32 tc) { return 1000.f * powf(2.f, 1.2715658e-08f * tc); }
u32 salChangeADSRState(ADSR_VARS* adsr) {
u32 VoiceDone; // r30
@ -140,7 +140,7 @@ u32 adsrStartRelease(ADSR_VARS* adsr, u32 rtime) {
return 0;
}
u32 adsrRelease(ADSR_VARS* adsr) {
bool adsrRelease(ADSR_VARS* adsr) {
switch (adsr->mode) {
case 0:
case 1:

View File

@ -56,9 +56,9 @@ void vsFreeBuffer(u8 bufferIndex) {
}
u32 vsSampleStartNotify(unsigned char voice) {
u8 sb; // r29
u8 i; // r28
u32 addr; // r27
u8 sb; // r29
u8 i; // r28
size_t addr; // r27
for (i = 0; i < vs.numBuffers; ++i) {
if (vs.streamBuffer[i].state != 0 && vs.streamBuffer[i].voice == voice) {
@ -87,7 +87,7 @@ u32 vsSampleStartNotify(unsigned char voice) {
return 0xFFFFFFFF;
}
void vsSampleEndNotify(unsigned long pubID) {
void vsSampleEndNotify(u32 pubID) {
u8 sb;
u8 voice;
@ -221,10 +221,9 @@ void vsSampleUpdates() {
}
}
unsigned long sndVirtualSampleAllocateBuffers(unsigned char numInstances,
unsigned long numSamples) {
long i; // r31
unsigned long len; // r28
bool sndVirtualSampleAllocateBuffers(u8 numInstances, u32 numSamples, u32 flags) {
s32 i; // r31
u32 len; // r28
MUSY_ASSERT_MSG(sndActive, "Sound system is not initialized.");
MUSY_ASSERT_MSG(numInstances <= 64, "Parameter exceeded maximum number of instances allowable");
@ -255,7 +254,7 @@ unsigned long sndVirtualSampleAllocateBuffers(unsigned char numInstances,
return 0;
}
s32 sndVirtualSampleFreeBuffers() {
void sndVirtualSampleFreeBuffers() {
u8 i; // r31
MUSY_ASSERT_MSG(sndActive, "Sound system is not initialized.");
@ -266,13 +265,12 @@ s32 sndVirtualSampleFreeBuffers() {
vs.numBuffers = 0;
}
void sndVirtualSampleSetCallback(unsigned long (*callback)(unsigned char,
struct SND_VIRTUALSAMPLE_INFO*)) {
void sndVirtualSampleSetCallback(u32 (*callback)(u8 reason, const SND_VIRTUALSAMPLE_INFO* info)) {
MUSY_ASSERT_MSG(sndActive, "Sound system is not initialized.");
vs.callback = callback;
}
void vsARAMDMACallback(unsigned long user) {
void vsARAMDMACallback(size_t user) {
if (vs.callback == NULL) {
return;
}
@ -280,8 +278,8 @@ void vsARAMDMACallback(unsigned long user) {
vs.callback(3, &((VS_BUFFER*)user)->info);
}
void sndVirtualSampleARAMUpdate(unsigned short instID, void* base, unsigned long off1,
unsigned long len1, unsigned long off2, unsigned long len2) {
void sndVirtualSampleARAMUpdate(SND_INSTID instID, void* base, u32 off1, u32 len1, u32 off2,
u32 len2) {
u8 i;
MUSY_ASSERT_MSG(sndActive, "Sound system is not initialized.");
@ -322,7 +320,7 @@ void sndVirtualSampleARAMUpdate(unsigned short instID, void* base, unsigned long
hwEnableIrq();
}
void sndVirtualSampleEndPlayback(unsigned short instID) {
void sndVirtualSampleEndPlayback(SND_INSTID instID, bool sampleEndedNormally) {
u8 i; // r30
VS_BUFFER* stream; // r31
u32 cpos; // r28

View File

@ -1,6 +1,6 @@
#include "musyx/synthdata.h"
#include "musyx/assert.h"
#include "musyx/hardware.h"
#include "musyx/synthdata.h"
#include "musyx/snd.h"
static SDIR_TAB dataSmpSDirs[128];
@ -347,7 +347,7 @@ done:
"Sample ID to be inserted could not be found in any sample directory.\n");
if (sdir->ref_cnt == 0) {
sdir->addr = (void*)(sdir->offset + (s32)dataSmpSDirs[i].base);
sdir->addr = (void*)((size_t)sdir->offset + (s32)dataSmpSDirs[i].base);
header = &sdir->header;
hwSaveSample(&header, &sdir->addr);
}
@ -532,7 +532,7 @@ MSTEP* dataGetMacro(u16 mid) {
static s32 smpcmp(void* p1, void* p2) { return ((SDIR_DATA*)p1)->id - ((SDIR_DATA*)p2)->id; }
long dataGetSample(u16 sid, SAMPLE_INFO* newsmp) {
s32 dataGetSample(u16 sid, SAMPLE_INFO* newsmp) {
static SDIR_DATA key;
static SDIR_DATA* result;
static SAMPLE_HEADER* sheader;
@ -554,7 +554,7 @@ long dataGetSample(u16 sid, SAMPLE_INFO* newsmp) {
newsmp->compType = sheader->length >> 24;
if (result->extraData) {
newsmp->extraData = (void*)((u32) & (dataSmpSDirs[i].data)->id + result->extraData);
newsmp->extraData = (void*)((size_t) & (dataSmpSDirs[i].data)->id + result->extraData);
}
return 0;
}
@ -605,7 +605,9 @@ void* dataGetLayer(u16 cid, u16* n) {
return NULL;
}
static s32 fxcmp(void* p1, void* p2) { return ((FX_TAB*)p1)->id - ((FX_TAB*)p2)->id; }
static s32 fxcmp(void* p1, void* p2) {
return ((FX_TAB*)p1)->id - ((FX_TAB*)p2)->id;
}
struct FX_TAB* dataGetFX(u16 fid) {
static FX_TAB key;
@ -640,3 +642,35 @@ void dataInit(u32 smpBase, u32 smpLength) {
}
void dataExit() { hwExitSampleMem(); }
#if MUSY_TARGET == MUSY_PLATFORM_PC
void* sndConvert32BitSDIRTo64BitSDIR(void* sdir_int) {
SDIR_DATA_INTER* sdir_inter = sdir_int;
SDIR_DATA* sdir = NULL;
s32 i = 0;
SDIR_DATA* s;
SDIR_DATA_INTER* s2 = NULL;
u16 n = 0;
for (s2 = sdir_inter; s2->id != 0xffff; ++s2) {
++n;
}
++n;
sdir = malloc(n * sizeof(SDIR_DATA));
for (i = 0; i < n; ++i) {
sdir[i].id = sdir_inter[i].id;
sdir[i].ref_cnt = sdir_inter[i].ref_cnt;
sdir[i].offset = sdir_inter[i].offset;
sdir[i].addr = (void*)(size_t)sdir_inter[i].addr;
sdir[i].header = sdir_inter[i].header;
sdir[i].extraData = sdir_inter[i].extraData;
}
free(sdir_int);
return sdir;
}
#endif

View File

@ -1064,7 +1064,7 @@ static void mcmdIfVarCompare(SYNTH_VOICE* svoice, MSTEP* cstep, u8 cmp) {
svoice->curAddr = svoice->addr + (u16)(cstep->para[1] >> 0x10);
}
}
u32 macPostMessage(u32 vid, s32 mesg) {
bool macPostMessage(u32 vid, s32 mesg) {
SYNTH_VOICE* sv; // r31
if ((vid = vidGetInternalId(vid)) != -1 && (sv = &synthVoice[vid & 0xFF])->mesgNum < 4) {
++sv->mesgNum;

View File

@ -117,7 +117,7 @@ void vidRemoveVoiceReferences(SYNTH_VOICE* svoice) {
}
}
unsigned long vidMakeRoot(struct SYNTH_VOICE* svoice) {
u32 vidMakeRoot(SYNTH_VOICE* svoice) {
svoice->vidMasterList = svoice->vidList;
return svoice->vidList->vid;
}
@ -551,7 +551,7 @@ void voiceKill(u32 vi) {
hwBreak(vi);
}
long voiceKillSound(u32 voiceid) {
s32 voiceKillSound(u32 voiceid) {
s32 ret = -1; // r29
u32 next_voiceid; // r28
u32 i; // r30