-
Notifications
You must be signed in to change notification settings - Fork 44
iSnd work #769
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
iSnd work #769
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -613,16 +613,20 @@ bool iSndIsPlaying(U32 assetID) | |
| { | ||
| if (gSnd.voice[i].assetID == assetID) | ||
| { | ||
| if(streams[i].vinf.flags & 0xC000 && (streams[i].vinf.flags & 0x82) == 0) { | ||
| if (streams[i].vinf.flags & 0xC000 && (streams[i].vinf.flags & 0x82) == 0) | ||
| { | ||
| return true; | ||
| } | ||
| return false; | ||
| } | ||
| } | ||
|
|
||
| for(S32 i = 0; i < 0x3a; i++) { | ||
| if(gSnd.voice[i+6].assetID == assetID) { | ||
| if(voices[i].flags & 0x4 && (voices[i].flags & 0x8) == 0) { | ||
| for (S32 i = 0; i < 0x3a; i++) | ||
| { | ||
| if (gSnd.voice[i + 6].assetID == assetID) | ||
| { | ||
| if (voices[i].flags & 0x4 && (voices[i].flags & 0x8) == 0) | ||
| { | ||
| return true; | ||
| } | ||
| return false; | ||
|
|
@@ -633,10 +637,12 @@ bool iSndIsPlaying(U32 assetID) | |
|
|
||
| bool iSndIsPlaying(U32 assetID, U32 parid) | ||
| { | ||
| for(U32 i = 0; i < 0x40; i++) { | ||
| if((assetID == 0 || gSnd.voice[i].assetID == assetID) && gSnd.voice[i].parentID == parid) | ||
| for (U32 i = 0; i < 0x40; i++) | ||
| { | ||
| if ((assetID == 0 || gSnd.voice[i].assetID == assetID) && gSnd.voice[i].parentID == parid) | ||
| { | ||
| if(iSndIsPlaying(gSnd.voice[i].assetID)) { | ||
| if (iSndIsPlaying(gSnd.voice[i].assetID)) | ||
| { | ||
| return true; | ||
| }; | ||
| } | ||
|
|
@@ -646,7 +652,6 @@ bool iSndIsPlaying(U32 assetID, U32 parid) | |
|
|
||
| bool iSndIsPlayingByHandle(U32 handle) | ||
| { | ||
|
|
||
| if (handle == 0) | ||
| { | ||
| return false; | ||
|
|
@@ -656,17 +661,18 @@ bool iSndIsPlayingByHandle(U32 handle) | |
| { | ||
| if (gSnd.voice[i].sndID == handle) | ||
| { | ||
| return (streams[i].vinf.flags & 0xC000 && (streams[i].vinf.flags & 0x82) == 0); | ||
| return (streams[i].vinf.flags & 0xC000 && (streams[i].vinf.flags & 0x82) == 0); | ||
| } | ||
| } | ||
|
|
||
| for(S32 i = 0; i < 0x3a; i++) { | ||
| if(gSnd.voice[i+6].sndID == handle) { | ||
| for (S32 i = 0; i < 0x3a; i++) | ||
| { | ||
| if (gSnd.voice[i + 6].sndID == handle) | ||
| { | ||
| return (voices[i].flags & 0x4 && (voices[i].flags & 0x8) == 0); | ||
| } | ||
| } | ||
| return false; | ||
|
|
||
| } | ||
|
|
||
| U32 iVolFromX(F32 param1) | ||
|
|
@@ -686,6 +692,18 @@ U32 iVolFromX(F32 param1) | |
| } | ||
| } | ||
|
|
||
| void iSndCalcVol(xSndVoiceInfo* vp, vinfo* info) | ||
| { | ||
| S32 vol = iVolFromX(vp->vol * gSnd.categoryVolFader[vp->category]); | ||
|
|
||
| info->x10 = vol; | ||
| info->x14 = vol; | ||
| info->x18 = 0x40; | ||
| info->x1c = 0x40; | ||
| MIXAdjustFader(info->voice, vol - MIXGetFader(info->voice)); | ||
| MIXAdjustPan(info->voice, 0x40 - MIXGetPan(info->voice)); | ||
| } | ||
|
|
||
| void iSndVolUpdate(xSndVoiceInfo* info, vinfo* vinfo) | ||
| { | ||
| MIXUnMute(vinfo->voice); | ||
|
|
@@ -716,6 +734,77 @@ void iSndUpdateSounds() | |
| } | ||
| } | ||
|
|
||
| S32 iSndPlay(xSndVoiceInfo* vp) | ||
| { | ||
| S32 offset = (S32)vp - (S32)gSnd.voice; | ||
| S32 div = offset / 100; | ||
|
|
||
| xSTAssetName(vp->assetID); | ||
|
|
||
| if ((div < 0) || (div >= 64)) | ||
| { | ||
| return 0; | ||
| } | ||
| else if (div < 6) | ||
| { | ||
| U32 ret = iSndPrepStream(vp); | ||
| if (ret < 0x3a) | ||
| { | ||
| if (vp->flags & 0x200) | ||
| { | ||
| return iSndPlayMemStream(vp); | ||
| } | ||
| else | ||
| { | ||
| return iSndPlayStream(vp); | ||
| } | ||
| } | ||
| return ret; | ||
| } | ||
| else | ||
| { | ||
| return iSndPlaySound(vp); | ||
| } | ||
| } | ||
|
|
||
| void iSndSetVol(U32 snd, F32 vol) | ||
| { | ||
| xSndVoiceInfo* vp = &gSnd.voice[0]; | ||
|
|
||
| S32 i = 0; | ||
| for (; i < 64;) | ||
| { | ||
| if (vp->sndID == snd) | ||
| break; | ||
| i++; | ||
| vp++; | ||
| } | ||
|
|
||
| if (i != 64) | ||
| { | ||
| vp->vol = vol; | ||
| S32 adj = iVolFromX(vol * gSnd.categoryVolFader[vp->category]); | ||
| vinfo* info; | ||
| if (i < 6) | ||
| { | ||
| info = &streams[i].vinf; | ||
| } | ||
| else | ||
| { | ||
| info = &voices[i - 6]; | ||
| } | ||
| if (info->voice != 0) | ||
| { | ||
| info->x10 = adj; | ||
| info->x14 = adj; | ||
| info->x18 = 0x40; | ||
| info->x1c = 0x40; | ||
| MIXAdjustFader(info->voice, adj - MIXGetFader(info->voice)); | ||
| MIXAdjustPan(info->voice, 0x40 - MIXGetPan(info->voice)); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| void iSndStartStereo(U32 id1, U32 id2, F32 pitch) | ||
| { | ||
| } | ||
|
|
@@ -778,7 +867,45 @@ void sndloadcb(tag_xFile* tag) | |
| { | ||
| SoundFlags = 0; | ||
| } | ||
| /* Matching | ||
| void iSndDIEDIEDIE() | ||
|
Comment on lines
+868
to
+869
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this commented?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Gonna be real I just want the 69.67% bot message in the discord 😭 |
||
| { | ||
| if (!soundInited) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| OSDisableInterrupts(); | ||
| soundInited = 0; | ||
|
|
||
| for (S32 i = 0; i < (S32)(sizeof(streams) / (sizeof(UNK_STREAM))); i++) | ||
| { | ||
| UNK_STREAM* pv = &streams[i]; | ||
|
|
||
| if (pv->vinf.voice != NULL) | ||
| { | ||
| MIXReleaseChannel(pv->vinf.voice); | ||
| AXSetVoiceState(pv->vinf.voice, 0); | ||
| iSndMyAXFree(&pv->vinf.voice); | ||
| } | ||
| pv++; | ||
| } | ||
|
|
||
| for (S32 i = 0; i < (S32)(sizeof(voices) / (sizeof(vinfo))); i++) | ||
| { | ||
| vinfo* v = &voices[i]; | ||
|
|
||
| if ((v->voice != NULL)) | ||
| { | ||
| MIXReleaseChannel(v->voice); | ||
| AXSetVoiceState(v->voice, 0); | ||
| iSndMyAXFree(&v->voice); | ||
| } | ||
| } | ||
|
|
||
| AXQuit(); | ||
| } | ||
| */ | ||
| void iSndSetExternalCallback(iSndExternalCallback callback) | ||
| { | ||
| } | ||
|
|
@@ -791,3 +918,78 @@ void iSndMyAXFree(_AXVPB** param1) | |
| *param1 = NULL; | ||
| } | ||
| } | ||
|
|
||
| void iSndSuspend() | ||
| { | ||
| AXRegisterCallback(0); | ||
|
|
||
| for (S32 i = 0; i < (S32)(sizeof(streams) / (sizeof(UNK_STREAM))); i++) | ||
| { | ||
| UNK_STREAM* pv = &streams[i]; | ||
|
|
||
| if (pv->vinf.voice != NULL) | ||
| { | ||
| AXSetVoiceState(pv->vinf.voice, 0); | ||
| } | ||
| pv++; | ||
| } | ||
|
|
||
| for (S32 i = 0; i < (S32)(sizeof(voices) / (sizeof(vinfo))); i++) | ||
| { | ||
| vinfo* v = &voices[i]; | ||
|
|
||
| if ((v->voice != NULL)) | ||
| { | ||
| AXSetVoiceState(v->voice, 0); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| void iSndResume() | ||
| { | ||
| for (S32 i = 0; i < (S32)(sizeof(streams) / (sizeof(UNK_STREAM))); i++) | ||
| { | ||
| UNK_STREAM* pv = &streams[i]; | ||
|
|
||
| if ((pv->vinf.voice != NULL) && !(pv->vinf.flags & 2)) | ||
| { | ||
| AXSetVoiceState(pv->vinf.voice, 1); | ||
| } | ||
| pv++; | ||
| } | ||
|
|
||
| for (S32 i = 0; i < (S32)(sizeof(voices) / (sizeof(vinfo))); i++) | ||
| { | ||
| vinfo* v = &voices[i]; | ||
|
|
||
| if ((v->voice != NULL) && !(v->flags & 8)) | ||
| { | ||
| AXSetVoiceState(v->voice, 1); | ||
| } | ||
| } | ||
|
|
||
| AXRegisterCallback(fcb); | ||
| } | ||
|
|
||
| F32 iSndGetVol(U32 snd) | ||
| { | ||
| xSndVoiceInfo* vp = &gSnd.voice[0]; | ||
|
|
||
| for (int i = 0; i < 0x40; i++) | ||
| { | ||
| if (vp->flags & 1) | ||
| { | ||
| if (vp->sndID == snd) | ||
| { | ||
| if (gSnd.categoryVolFader[vp->category] <= 0.0f) | ||
| { | ||
| return 0.0f; | ||
| } | ||
| return (vp->vol / gSnd.categoryVolFader[vp->category]); | ||
| } | ||
| } | ||
| vp++; | ||
| } | ||
|
|
||
| return 0.0f; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.