Skip to content

Commit

Permalink
MusyX: Initial PC Port rework
Browse files Browse the repository at this point in the history
  • Loading branch information
Antidote committed Nov 30, 2023
1 parent 87c251b commit 6f49822
Show file tree
Hide file tree
Showing 41 changed files with 691 additions and 2,836 deletions.
10 changes: 5 additions & 5 deletions config/GM8E01_00/splits.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4248,7 +4248,7 @@ musyx/runtime/s_data.c:
.bss start:0x8055EC60 end:0x8055F260
.sbss start:0x805A9AD8 end:0x805A9AE0

musyx/runtime/hw_dspctrl.c:
musyx/runtime/dolphin/hw_dspctrl.c:
.text start:0x803AACFC end:0x803AE110
.rodata start:0x803D8A68 end:0x803D8AC0
.data start:0x803F3FA8 end:0x803F3FC0
Expand Down Expand Up @@ -4284,23 +4284,23 @@ musyx/runtime/snd_service.c:
.data start:0x803F4278 end:0x803F4A80
.sdata start:0x805A8BD0 end:0x805A8BD8

musyx/runtime/hardware.c:
musyx/runtime/dolphin/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/dsp_import.c:
musyx/runtime/dolphin/dsp_import.c:
.data start:0x803F4A80 end:0x803F6460
.sdata start:0x805A8BE8 end:0x805A8BF0

musyx/runtime/hw_aramdma.c:
musyx/runtime/dolphin/hw_aramdma.c:
.text start:0x803B3F70 end:0x803B4C3C
.bss start:0x80566F90 end:0x805678A0
.sbss start:0x805A9B50 end:0x805A9B70

musyx/runtime/hw_dolphin.c:
musyx/runtime/dolphin/hw_dolphin.c:
.text start:0x803B4C3C end:0x803B5134
.bss start:0x805678A0 end:0x80569900
.sbss start:0x805A9B70 end:0x805A9B98
Expand Down
12 changes: 7 additions & 5 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@
"-Cpp_exceptions off",
"-str reuse,pool,readonly",
"-fp_contract off",
"-DMUSY_TARGET=MUSY_TARGET_DOLPHIN"
]

cflags_musyx_debug = [
Expand All @@ -216,6 +217,7 @@
"-D_DEBUG=1",
"-enum int",
"-Cpp_exceptions off",
"-DMUSY_TARGET=MUSY_TARGET_DOLPHIN"
]

# REL flags
Expand Down Expand Up @@ -1199,10 +1201,10 @@ def Rel(lib_name, objects):
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/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/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/hw_memory.c"),
Object(Matching, "musyx/runtime/hw_lib_dummy.c"),
Object(Matching, "musyx/runtime/CheapReverb/creverb_fx.c"),
Expand All @@ -1211,7 +1213,7 @@ def Rel(lib_name, objects):
Object(Matching, "musyx/runtime/StdReverb/reverb.c"),
Object(Matching, "musyx/runtime/Delay/delay_fx.c"),
Object(Matching, "musyx/runtime/Chorus/chorus_fx.c"),
Object(Matching, "musyx/runtime/profile.c"),
Object(Matching, "musyx/runtime/dolphin/profile.c"),
],
),
{
Expand Down
38 changes: 29 additions & 9 deletions include/musyx/assert.h
Original file line number Diff line number Diff line change
@@ -1,22 +1,42 @@
#ifndef _MUSYX_ASSERT
#define _MUSYX_ASSERT
#ifndef _ASSERT
#define _ASSERT
#include "musyx/version.h"
#include "musyx/platform.h"

#if MUSY_TARGET == MUSY_TARGET_DOLPHIN
extern void OSPanic(const char* file, int line, const char* msg, ...);
extern void OSReport(const char* msg, ...);

#ifndef MUSY_PANIC
#define MUSY_PANIC OSPanic
#endif
#ifndef MUSY_REPORT
#define MUSY_REPORT OSReport
#endif
#elif MUSY_TARGET == MUSY_TARGET_PC
#include <assert.h>

#ifndef MUSY_PANIC
#define MUSY_PANIC assert
#endif
#ifndef MUSY_REPORT
#define MUSY_REPORT printf
#endif
#endif

// TODO: Cleanup
static inline unsigned __SOME_ASSERT_DERP1() { return 0; }

static inline unsigned __SOME_ASSERT_DERP2() { return __SOME_ASSERT_DERP1(); }

static inline void __SOME_ASSERT_DERP() { __SOME_ASSERT_DERP2() != 0; }

#ifndef ASSERT
#ifndef MUSY_ASSERT
#ifdef _DEBUG
#define MUSY_ASSERT(cond) \
do { \
if (!(cond)) { \
OSPanic(__FILE__, __LINE__, "Failed assertion " #cond); \
MUSY_PANIC(__FILE__, __LINE__, "Failed assertion " #cond); \
} \
__SOME_ASSERT_DERP(); \
} while (0)
Expand All @@ -33,7 +53,7 @@ static inline void __SOME_ASSERT_DERP() { __SOME_ASSERT_DERP2() != 0; }
s32 tmp = 1; \
s32 tmp2; \
if (!(cond)) { \
OSPanic(__FILE__, __LINE__, msg); \
MUSY_PANIC(__FILE__, __LINE__, msg); \
tmp2 = 0; \
if (tmp2 == 0) { \
tmp = 0; \
Expand All @@ -44,7 +64,7 @@ static inline void __SOME_ASSERT_DERP() { __SOME_ASSERT_DERP2() != 0; }
#define MUSY_ASSERT_MSG(cond, msg) \
do { \
if (!(cond)) { \
OSPanic(__FILE__, __LINE__, msg); \
MUSY_PANIC(__FILE__, __LINE__, msg); \
} \
} while (0)
#endif
Expand All @@ -55,18 +75,18 @@ static inline void __SOME_ASSERT_DERP() { __SOME_ASSERT_DERP2() != 0; }

#ifndef MUSY_DEBUG
#ifdef _DEBUG
#define MUSY_DEBUG OSReport
#define MUSY_DEBUG MUSY_REPORT
#else
#define MUSY_DEBUG
#endif
#endif

#ifndef MUSY_FATAL
#ifdef _DEBUG
#define MUSY_FATAL(msg) OSPanic(__FILE__, __LINE__, msg)
#define MUSY_FATAL(msg) MUSY_PANIC(__FILE__, __LINE__, msg)
#else
#define MUSY_FATAL
#endif
#endif

#endif // _MUSYX_ASSERT
#endif // _ASSERT
4 changes: 2 additions & 2 deletions include/musyx/dsp_import.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#ifndef _MUSYX_DSP_IMPORT
#define _MUSYX_DSP_IMPORT

#include "types.h"
#include "musyx/musyx.h"

#ifdef __cplusplus
extern "C" {
#endif

extern char dspSlave[];
extern ushort dspSlaveLength;
extern u16 dspSlaveLength;

#ifdef __cplusplus
}
Expand Down
56 changes: 53 additions & 3 deletions include/musyx/hardware.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,30 @@
#ifndef _MUSYX_HARDWARE
#define _MUSYX_HARDWARE

#include "musyx/musyx_priv.h"
#include "musyx/musyx.h"

#ifdef __cplusplus
extern "C" {
#endif
typedef void* (*ARAMUploadCallback)(u32, u32);
typedef u32 (*SND_MESSAGE_CALLBACK)(u32, u32);

extern SND_MESSAGE_CALLBACK salMessageCallback;
extern SND_HOOKS salHooks;

extern u32 dspHRTFOn;

extern u16* dspCmdList;
extern u16 dspCmdFirstSize;
extern u8 dspScale2IndexTab[1024];


u32 hwFrq2Pitch(u32 frq);
void hwOff(s32 vid);
bool hwIsStudioActive(u8 studio);
void* hwGetStreamPlayBuffer(u8 hwStreamHandle);
s32 hwInit(u32* frq, u16 numVoices, u16 numStudios, u32 flags); /* extern */
void hwExit();
void hwInitSamplePlayback(u32 v, u16 smpID, void* newsmp, u32 set_defadsr, u32 prio,
u32 callbackUserValue, u32 setSRC, u8 itdMode);
void hwSetVolume(u32 v, u8 table, float vol, u32 pan, u32 span, float auxa, float auxb);
Expand All @@ -31,15 +46,50 @@ 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, unsigned char hwStreamHandle,
void (*callback)(u32), u32 user);
void hwSetSaveSampleCallback(ARAMUploadCallback callback, unsigned long chunckSize);
void hwSyncSampleMem();
void hwSetAUXProcessingCallbacks(u8 studio, SND_AUX_CALLBACK auxA, void* userA,
SND_AUX_CALLBACK auxB, void* userB);
void hwSetMesgCallback(SND_MESSAGE_CALLBACK callback);
#if MUSY_VERSION >= MUSY_VERSION_CHECK(2, 0, 3)
void hwSetFilter(u32 v, unsigned char mode, unsigned short coefA, unsigned short coefB);
void hwLowPassFrqToCoef(u32 frq, unsigned short* _a0, unsigned short* _b1);
#endif
void hwSetSRCType(u32 v, u8 salSRCType);
void hwSetITDMode(u32 v, u8 mode);
void hwSetPolyPhaseFilter(u32 v, u8 salCoefSel);
bool hwAddInput(u8 studio, SND_STUDIO_INPUT* in_desc);
bool hwRemoveInput(u8 studio, SND_STUDIO_INPUT* in_desc);
void hwChangeStudio(u32 v, u8 studio);
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 hwDeactivateStudio(u8);
void hwSetPriority(u32 v, u32 prio);
u32 hwIsActive(u32);
u32 hwGlobalActivity();
void hwSetAUXProcessingCallbacks(u8 studio, SND_AUX_CALLBACK auxA, void* userA,
SND_AUX_CALLBACK auxB, void* userB);
u8 hwInitStream(u32 len);
u8 hwGetTimeOffset();
u32 hwGetVirtualSampleID(u32 v);
void hwIRQEnterCritical();
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 aramFreeStreamBuffer(u8 id);
void* aramStoreData(void* src, u32 len);
void aramRemoveData(void* aram, u32 len);
u8 aramAllocateStreamBuffer(u32 len);

#ifdef __cplusplus
}
#endif
Expand Down
1 change: 1 addition & 0 deletions include/musyx/musyx.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define _MUSYX_MUSYX

#include "musyx/version.h"
#include "musyx/platform.h"

#include <math.h>

Expand Down
Loading

0 comments on commit 6f49822

Please sign in to comment.