Add musyx/stream.c, match and link arith.c

This commit is contained in:
Phillip Stephens 2022-11-29 23:07:31 -08:00
parent d9f71836b5
commit 7bd0748d30
7 changed files with 106 additions and 15 deletions

View File

@ -38,7 +38,9 @@
"osexception.h": "c",
"oserror.h": "c",
"oscontext.h": "c",
"oscache.h": "c"
"oscache.h": "c",
"stdlib.h": "c",
"musyx_priv.h": "c"
},
"files.autoSave": "onFocusChange",
"files.insertFinalNewline": true,

View File

@ -2248,12 +2248,12 @@ lbl_8038CE14:
/* 8038CE14 00389D74 7C 83 23 78 */ mr r3, r4
/* 8038CE18 00389D78 4E 80 00 20 */ blr
.global abs
abs:
/* 8038CE1C 00389D7C 7C 64 FE 70 */ srawi r4, r3, 0x1f
/* 8038CE20 00389D80 7C 80 1A 78 */ xor r0, r4, r3
/* 8038CE24 00389D84 7C 64 00 50 */ subf r3, r4, r0
/* 8038CE28 00389D88 4E 80 00 20 */ blr
#.global abs
#abs:
#/* 8038CE1C 00389D7C 7C 64 FE 70 */ srawi r4, r3, 0x1f
#/* 8038CE20 00389D80 7C 80 1A 78 */ xor r0, r4, r3
#/* 8038CE24 00389D84 7C 64 00 50 */ subf r3, r4, r0
#/* 8038CE28 00389D88 4E 80 00 20 */ blr
.section .sdata2, "a"
.balign 8

View File

@ -2,9 +2,9 @@
.section .text, "ax"
# .global abs
# abs:
# /* 8038CE1C 00389D7C 7C 64 FE 70 */ srawi r4, r3, 0x1f
# /* 8038CE20 00389D80 7C 80 1A 78 */ xor r0, r4, r3
# /* 8038CE24 00389D84 7C 64 00 50 */ subf r3, r4, r0
# /* 8038CE28 00389D88 4E 80 00 20 */ blr
.global abs
abs:
/* 8038CE1C 00389D7C 7C 64 FE 70 */ srawi r4, r3, 0x1f
/* 8038CE20 00389D80 7C 80 1A 78 */ xor r0, r4, r3
/* 8038CE24 00389D84 7C 64 00 50 */ subf r3, r4, r0
/* 8038CE28 00389D88 4E 80 00 20 */ blr

View File

@ -860,7 +860,7 @@ LIBS = [
["Runtime/alloc", False],
["Runtime/ansi_files", True],
"Runtime/ansi_fp",
"Runtime/arith",
["Runtime/arith", True],
["Runtime/buffer_io", True],
["Runtime/ctype", True],
["Runtime/locale", True],
@ -923,7 +923,7 @@ LIBS = [
"musyx/synth",
["musyx/seq_api", True],
["musyx/snd_synthapi", False, False],
"musyx/stream",
["musyx/stream", False],
"musyx/synthdata",
"musyx/synthmacros",
"musyx/synthvoice",

View File

@ -79,6 +79,22 @@ u32 salInitDsp(u32);
u32 salInitDspCtrl(u32, u32, u16);
u32 salStartAi();
/* Stream */
typedef s32 (*SND_STREAM_UPDATE_CALLBACK)(void * buffer1, u32 len1, void * buffer2, u32 len2, void* user);
typedef struct SND_STREAM_INFO {
u32 x0_;
u32 x4_;
u32 x8_;
u8 xc_;
char data2[0x10 - 0xd];
SND_STREAM_UPDATE_CALLBACK updateCb;
char data3[0x4C - 0x14];
SND_VOICEID voiceId;
void* user;
char data4[0x64 - 0x54];
} SND_STREAM_INFO;
/* TODO: Figure out what `unk` is */
bool hwAddInput(u8 studio, void* unk);
bool hwRemoveInput(u8 studio, void* unk);

15
src/Runtime/arith.c Normal file
View File

@ -0,0 +1,15 @@
#include <stdlib.h>
int abs(int n) {
if (n < 0)
return (-n);
else
return (n);
}
long labs(long n) {
if (n < 0)
return (-n);
else
return (n);
}

58
src/musyx/stream.c Normal file
View File

@ -0,0 +1,58 @@
#include "musyx/musyx_priv.h"
SND_STREAM_INFO streamInfo[64];
u32 nextPublicID = 0;
u8 streamCallDelay = 0;
u8 streamCallCnt = 0;
void streamInit() {
s32 i;
streamCallCnt = 0;
streamCallDelay = 3;
for (i = 0; i < synthInfo.voices; ++i) {
streamInfo[i].xc_ = 0;
}
nextPublicID = 0;
}
void SetHWMix(SND_STREAM_INFO* info) {
// hwSetVolume()
}
void streamHandle() {}
void streamCorrectLoops() {}
void streamKill(SND_STREAMID streamId) {
SND_STREAM_INFO* stream = &streamInfo[streamId];
switch (stream->xc_) {
case 1:
case 2:
if (stream->xc_ == 2) {
voiceUnblock(stream->voiceId);
}
stream->xc_ = 3;
stream->updateCb(NULL, 0, NULL, 0, stream->user);
break;
}
}
s32 GetPrivateIndex(s32 something) {
s32 i;
for (i = 0; i < 64; ++i) {
if (streamInfo[i].xc_ != 0 && something == streamInfo[i].x4_) {
return i;
}
}
return -1;
}
void sndStreamARAMUpdate() {
}