MusyX progress

Former-commit-id: 1ba085dc20e7edb45bc52f4949c7efec33d750d3
This commit is contained in:
Phillip Stephens 2023-10-12 19:47:50 -07:00
parent bc5d1ac55f
commit 45681935ec
3 changed files with 181 additions and 28 deletions

View File

@ -187,21 +187,22 @@ cflags_retro = [
"-common on", "-common on",
] ]
### MusyX 1.5.3 (debug)
# "mw_version": "1.2.5",
# "cflags": "-proc gecko -fp hard -nodefaults -nosyspath -i include -i libc -g -sym on -D_DEBUG=1 -enum int -DMUSY_VERSION_MAJOR=1 -DMUSY_VERSION_MINOR=5 -DMUSY_VERSION_PATCH=3",
### MusyX 2.0.3 (debug)
# "mw_version": "1.3.2",
# "cflags": "-proc gecko -fp hard -nodefaults -nosyspath -i include -i libc -g -sym on -D_DEBUG=1 -enum int -DMUSY_VERSION_MAJOR=2 -DMUSY_VERSION_MINOR=0 -DMUSY_VERSION_PATCH=3",
cflags_musyx = [ cflags_musyx = [
*cflags_base, *cflags_base,
"-str reuse,pool,readonly", "-str reuse,pool,readonly",
"-fp_contract off", "-fp_contract off",
"-DMUSY_VERSION_MAJOR=1", ]
"-DMUSY_VERSION_MINOR=5",
"-DMUSY_VERSION_PATCH=4", cflags_musyx_debug = [
"-proc gecko",
"-fp hard",
"-nodefaults",
"-nosyspath",
"-i include",
"-i libc",
"-g -sym on -D_DEBUG=1",
"-enum int",
"-D_MATH_INLINE=static",
] ]
# REL flags # REL flags
@ -235,6 +236,22 @@ def RetroLib(lib_name, objects):
} }
def MusyX(objects, mw_version="GC/1.3.2", debug=False, major=1, minor=5, patch=4):
cflags = cflags_musyx if not debug else cflags_musyx_debug
return {
"lib": "MusyX",
"mw_version": mw_version,
"host": False,
"cflags": [
*cflags,
f"-DMUSY_VERSION_MAJOR={major}",
f"-DMUSY_VERSION_MINOR={minor}",
f"-DMUSY_VERSION_PATCH={patch}",
],
"objects": objects,
}
# Helper function for REL script objects # Helper function for REL script objects
def Rel(lib_name, objects): def Rel(lib_name, objects):
return { return {
@ -1138,12 +1155,13 @@ config.libs = [
Object(Matching, "Runtime/math_ppc.c"), Object(Matching, "Runtime/math_ppc.c"),
], ],
}, },
{ MusyX(
"lib": "musyx", # debug=True,
"mw_version": "GC/1.3.2", # mw_version="GC/1.2.5",
"cflags": cflags_musyx, # major=1,
"host": False, # minor=5,
"objects": [ # patch=3,
objects=[
Object(Matching, "musyx/runtime/seq.c"), Object(Matching, "musyx/runtime/seq.c"),
Object(Matching, "musyx/runtime/synth.c"), Object(Matching, "musyx/runtime/synth.c"),
Object(Matching, "musyx/runtime/seq_api.c"), Object(Matching, "musyx/runtime/seq_api.c"),
@ -1177,7 +1195,7 @@ config.libs = [
Object(Matching, "musyx/runtime/Chorus/chorus_fx.c"), Object(Matching, "musyx/runtime/Chorus/chorus_fx.c"),
Object(Matching, "musyx/runtime/profile.c"), Object(Matching, "musyx/runtime/profile.c"),
], ],
}, ),
{ {
"lib": "txwin", "lib": "txwin",
"mw_version": "GC/1.2.5n", "mw_version": "GC/1.2.5n",

View File

@ -7,7 +7,7 @@
extern float powf(float, float); extern float powf(float, float);
static u32 adsrGetIndex(ADSR_VARS* adsr) { static u32 adsrGetIndex(ADSR_VARS* adsr) {
long i = 193 - ((adsr->currentIndex + 0x8000) >> 16); s32 i = 193 - ((adsr->currentIndex + 0x8000) >> 16);
return i < 0 ? 0 : i; return i < 0 ? 0 : i;
} }
@ -55,7 +55,7 @@ u32 adsrStartRelease(ADSR_VARS* adsr, u32 rtime) {
} }
u32 adsrRelease(ADSR_VARS* adsr) { u32 adsrRelease(ADSR_VARS* adsr) {
switch(adsr->mode) { switch (adsr->mode) {
case 0: case 0:
case 1: case 1:
return adsrStartRelease(adsr, adsr->data.dls.rTime); return adsrStartRelease(adsr, adsr->data.dls.rTime);
@ -63,3 +63,20 @@ u32 adsrRelease(ADSR_VARS* adsr) {
return FALSE; return FALSE;
} }
u32 adsrHandle(ADSR_VARS* adsr, u16* adsr_start, u16* adsr_delta) {
s32 old_volume; // r29
bool VoiceDone; // r28
s32 vDelta; // r27
}
u32 adsrHandleLowPrecision(ADSR_VARS* adsr, u16* adsr_start, u16* adsr_delta) {
u8 i; // r31
for (i = 0; i < 15; ++i) {
if (adsrHandle(adsr, adsr_start, adsr_delta)) {
return 1;
}
}
return 0;
}

View File

@ -15,40 +15,46 @@ static MAC_SUBTAB dataMacSubTabmem[2048];
static u16 dataFXGroupNum = 0; static u16 dataFXGroupNum = 0;
static FX_GROUP dataFXGroups[128]; static FX_GROUP dataFXGroups[128];
// #line 94
u32 dataInsertKeymap(u16 cid, void* keymapdata) { u32 dataInsertKeymap(u16 cid, void* keymapdata) {
long i; // r31 long i; // r31
long j; // r29 long j; // r29
hwDisableIrq(); hwDisableIrq();
for (i = 0; i < dataKeymapNum && dataKeymapTab[i].id < cid; ++i) for (i = 0; i < dataKeymapNum && dataKeymapTab[i].id < cid; ++i)
; ;
if (i < dataKeymapNum) { if (i < dataKeymapNum) {
if (cid != dataKeymapTab[i].id) { if (cid != dataKeymapTab[i].id) {
if (dataKeymapNum < 256) { if (dataKeymapNum < 256) {
for (j = dataKeymapNum - 1; j >= i; --j) {
for (j = dataKeymapNum - 1; j >= i; --j)
dataKeymapTab[j + 1] = dataKeymapTab[j]; dataKeymapTab[j + 1] = dataKeymapTab[j];
}
++dataKeymapNum; ++dataKeymapNum;
} else { } else {
hwEnableIrq(); hwEnableIrq();
return 0; return 0;
} }
} else { } else {
dataKeymapTab[i].refCount++; dataKeymapTab[i].refCount++;
hwEnableIrq(); hwEnableIrq();
return 0; return 0;
} }
} else if (dataKeymapNum < 256) { } else if (dataKeymapNum < 256) {
++dataKeymapNum;
} else {
hwEnableIrq(); hwEnableIrq();
return 0; return 0;
} }
++dataKeymapNum;
MUSY_ASSERT_MSG(keymapdata != NULL, "Keymap data pointer is NULL"); MUSY_ASSERT_MSG(keymapdata != NULL, "Keymap data pointer is NULL");
dataKeymapTab[i].id = cid; dataKeymapTab[i].id = cid;
dataKeymapTab[i].data = keymapdata; dataKeymapTab[i].data = keymapdata;
dataKeymapTab[i].refCount = 1; dataKeymapTab[i].refCount = 1;
@ -59,23 +65,126 @@ u32 dataInsertKeymap(u16 cid, void* keymapdata) {
unsigned long dataRemoveKeymap(unsigned short sid) { unsigned long dataRemoveKeymap(unsigned short sid) {
long i; // r31 long i; // r31
long j; // r30 long j; // r30
hwDisableIrq();
for (i = 0; i < dataKeymapNum && dataKeymapTab[i].id != sid; ++i)
;
if (i != dataKeymapNum) {
for (j = i + 1; j < dataKeymapNum; j++, i++) {
dataKeymapTab[i] = dataKeymapTab[j];
}
}
hwEnableIrq();
return 1;
} }
unsigned long dataInsertLayer(unsigned short cid, void* layerdata, unsigned short size) { unsigned long dataInsertLayer(unsigned short cid, void* layerdata, unsigned short size) {
long i; // r31 long i; // r31
long j; // r29 long j; // r29
hwDisableIrq();
for (i = 0; i < dataLayerNum && dataLayerTab[i].id < cid; ++i)
;
if (i < dataLayerNum) {
if (cid != dataLayerTab[i].id) {
if (dataLayerNum < 256) {
for (j = dataLayerNum - 1; j >= i; --j)
dataLayerTab[j + 1] = dataLayerTab[j];
++dataLayerNum;
} else {
hwEnableIrq();
return 0;
}
} else {
dataLayerTab[i].refCount++;
hwEnableIrq();
return 0;
}
} else if (dataLayerNum < 256) {
++dataLayerNum;
} else {
hwEnableIrq();
return 0;
}
MUSY_ASSERT_MSG(layerdata != NULL, "Layer data pointer is NULL");
dataLayerTab[i].id = cid;
dataLayerTab[i].data = layerdata;
dataLayerTab[i].num = size;
dataLayerTab[i].refCount = 1;
hwEnableIrq();
return 1;
} }
unsigned long dataRemoveLayer(unsigned short sid) { unsigned long dataRemoveLayer(unsigned short sid) {
long i; // r31 long i; // r31
long j; // r30 long j; // r30
} }
unsigned long dataInsertCurve(unsigned short cid, void* curvedata) { unsigned long dataInsertCurve(unsigned short cid, void* curvedata) {
long i; // r31 long i; // r31
long j; // r29 long j; // r29
hwDisableIrq();
for (i = 0; i < dataCurveNum && dataCurveTab[i].id < cid; ++i)
;
if (i < dataCurveNum) {
if (cid != dataCurveTab[i].id) {
if (dataCurveNum < 2048) {
for (j = dataCurveNum - 1; j >= i; --j)
dataCurveTab[j + 1] = dataCurveTab[j];
++dataCurveNum;
} else {
hwEnableIrq();
return 0;
}
} else {
hwEnableIrq();
dataCurveTab[i].refCount++;
return 0;
}
} else if (dataCurveNum < 2048) {
++dataCurveNum;
} else {
hwEnableIrq();
return 0;
}
MUSY_ASSERT_MSG(curvedata != NULL, "Curve data pointer is NULL");
dataCurveTab[i].id = cid;
dataCurveTab[i].data = curvedata;
dataCurveTab[i].refCount = 1;
hwEnableIrq();
return 1;
} }
unsigned long dataRemoveCurve(unsigned short sid) { unsigned long dataRemoveCurve(unsigned short sid) {
long i; // r31 long i; // r31
long j; // r30 long j; // r30
} }
unsigned long dataInsertSDir(struct SDIR_DATA* sdir, void* smp_data) { unsigned long dataInsertSDir(struct SDIR_DATA* sdir, void* smp_data) {
long i; // r31 long i; // r31
struct SDIR_DATA* s; // r25 struct SDIR_DATA* s; // r25
@ -83,40 +192,49 @@ unsigned long dataInsertSDir(struct SDIR_DATA* sdir, void* smp_data) {
unsigned short j; // r29 unsigned short j; // r29
unsigned short k; // r26 unsigned short k; // r26
} }
unsigned long dataRemoveSDir(struct SDIR_DATA* sdir) { unsigned long dataRemoveSDir(struct SDIR_DATA* sdir) {
long i; // r28 long i; // r28
long j; // r30 long j; // r30
long index; // r27 long index; // r27
struct SDIR_DATA* data; // r31 struct SDIR_DATA* data; // r31
} }
unsigned long dataAddSampleReference(unsigned short sid) { unsigned long dataAddSampleReference(unsigned short sid) {
unsigned long i; // r29 unsigned long i; // r29
struct SAMPLE_HEADER* header; // r1+0xC struct SAMPLE_HEADER* header; // r1+0xC
struct SDIR_DATA* data; // r30 struct SDIR_DATA* data; // r30
struct SDIR_DATA* sdir; // r31 struct SDIR_DATA* sdir; // r31
} }
unsigned long dataRemoveSampleReference(unsigned short sid) { unsigned long dataRemoveSampleReference(unsigned short sid) {
unsigned long i; // r30 unsigned long i; // r30
struct SDIR_DATA* sdir; // r31 struct SDIR_DATA* sdir; // r31
} }
unsigned long dataInsertFX(unsigned short gid, struct FX_TAB* fx, unsigned short fxNum) { unsigned long dataInsertFX(unsigned short gid, struct FX_TAB* fx, unsigned short fxNum) {
long i; // r31 long i; // r31
} }
unsigned long dataRemoveFX(unsigned short gid) { unsigned long dataRemoveFX(unsigned short gid) {
long i; // r31 long i; // r31
long j; // r30 long j; // r30
return 1;
} }
unsigned long dataInsertMacro(unsigned short mid, void* macroaddr) { unsigned long dataInsertMacro(unsigned short mid, void* macroaddr) {
long main; // r28 long main; // r28
long pos; // r29 long pos; // r29
long base; // r27 long base; // r27
long i; // r31 long i; // r31
} }
unsigned long dataRemoveMacro(unsigned short mid) { unsigned long dataRemoveMacro(unsigned short mid) {
long main; // r29 long main; // r29
long base; // r28 long base; // r28
long i; // r31 long i; // r31
} }
long maccmp(void* p1, void* p2) { return ((MAC_SUBTAB*)p1)->id - ((MAC_SUBTAB*)p2)->id; } long maccmp(void* p1, void* p2) { return ((MAC_SUBTAB*)p1)->id - ((MAC_SUBTAB*)p2)->id; }
struct MSTEP* dataGetMacro(unsigned short mid) { struct MSTEP* dataGetMacro(unsigned short mid) {