[NCSF] Documented what FSS functions were originally used.
* Changed default of modDelay to 0.
* Also minor cleanup.
--- a/src/in_ncsf/SSEQPlayer/Channel.cpp
+++ b/src/in_ncsf/SSEQPlayer/Channel.cpp
@@ -71,6 +71,7 @@
}
}
+// Original FSS Function: Chn_UpdateVol
void Channel::UpdateVol(const Track &trk)
{
int finalVol = trk.ply->masterVol;
@@ -82,11 +83,13 @@
this->extAmpl = finalVol;
}
+// Original FSS Function: Chn_UpdatePan
void Channel::UpdatePan(const Track &trk)
{
this->extPan = trk.pan;
}
+// Original FSS Function: Chn_UpdateTune
void Channel::UpdateTune(const Track &trk)
{
int tune = (static_cast<int>(this->key) - static_cast<int>(this->orgKey)) * 64;
@@ -94,6 +97,7 @@
this->extTune = tune;
}
+// Original FSS Function: Chn_UpdateMod
void Channel::UpdateMod(const Track &trk)
{
this->modType = trk.modType;
@@ -103,6 +107,7 @@
this->modDelay = trk.modDelay;
}
+// Original FSS Function: Chn_UpdatePorta
void Channel::UpdatePorta(const Track &trk)
{
this->manualSweep = false;
@@ -130,6 +135,7 @@
}
}
+// Original FSS Function: Chn_Release
void Channel::Release()
{
this->noteLength = -1;
@@ -137,6 +143,7 @@
this->state = CS_RELEASE;
}
+// Original FSS Function: Chn_Kill
void Channel::Kill()
{
this->state = CS_NONE;
@@ -162,6 +169,7 @@
}
}
+// Original FSS Function: Chn_UpdateTracks
void Channel::UpdateTrack()
{
if (!this->ply)
@@ -171,11 +179,11 @@
if (trkn == -1)
return;
- auto &trackFlags = this->ply->tracks[trkn].updateFlags;
+ auto &trk = this->ply->tracks[trkn];
+ auto &trackFlags = trk.updateFlags;
if (trackFlags.none())
return;
- auto &trk = this->ply->tracks[trkn];
if (trackFlags[TUF_LEN])
{
int st = this->state;
@@ -414,6 +422,7 @@
return 4;
}
+// Original FSS Function: Snd_UpdChannel
void Channel::Update()
{
// Kill active channels that aren't physically active
@@ -470,10 +479,11 @@
}
case CS_RELEASE:
this->ampl -= static_cast<int>(this->releaseRate);
- if (this->ampl > AMPL_THRESHOLD)
- break;
- this->Kill();
- return;
+ if (this->ampl <= AMPL_THRESHOLD)
+ {
+ this->Kill();
+ return;
+ }
}
if (bModulation && this->modDelayCnt < this->modDelay)
@@ -575,10 +585,7 @@
if (bModulation && this->modType == 2)
realPan += modParam;
realPan += 64;
- if (realPan < 0)
- realPan = 0;
- else if (realPan > 127)
- realPan = 127;
+ clamp(realPan, 0, 127);
cr &= ~SOUND_PAN(0x7F);
cr |= SOUND_PAN(realPan);
--- a/src/in_ncsf/SSEQPlayer/Player.cpp
+++ b/src/in_ncsf/SSEQPlayer/Player.cpp
@@ -15,10 +15,14 @@
{
memset(this->trackIds, 0, sizeof(this->trackIds));
for (size_t i = 0; i < 16; ++i)
+ {
this->channels[i].chnId = i;
+ this->channels[i].ply = this;
+ }
memset(this->variables, -1, sizeof(this->variables));
}
+// Original FSS Function: Player_Setup
bool Player::Setup(const SSEQ *sseqToPlay)
{
this->sseq = sseqToPlay;
@@ -38,6 +42,7 @@
return true;
}
+// Original FSS Function: Player_ClearState
void Player::ClearState()
{
this->tempo = 120;
@@ -47,6 +52,7 @@
memset(this->variables, -1, sizeof(this->variables));
}
+// Original FSS Function: Player_FreeTracks
void Player::FreeTracks()
{
for (uint8_t i = 0; i < this->nTracks; ++i)
@@ -54,6 +60,7 @@
this->nTracks = 0;
}
+// Original FSS Function: Player_Stop
void Player::Stop(bool bKillSound)
{
this->ClearState();
@@ -76,6 +83,7 @@
this->FreeTracks();
}
+// Original FSS Function: Chn_Alloc
int Player::ChannelAlloc(int type, int priority)
{
static const uint8_t pcmChnArray[] = { 4, 5, 6, 7, 2, 0, 3, 1, 8, 9, 10, 11, 14, 12, 15, 13 };
@@ -105,12 +113,12 @@
if (curChnNo == -1 || priority < this->channels[curChnNo].prio)
return -1;
- this->channels[curChnNo].ply = this;
this->channels[curChnNo].noteLength = -1;
this->channels[curChnNo].vol = 0x7FF;
return curChnNo;
}
+// Original FSS Function: Track_Alloc
int Player::TrackAlloc()
{
for (int i = 0; i < FSS_MAXTRACKS; ++i)
@@ -127,6 +135,7 @@
return -1;
}
+// Original FSS Function: Player_Run
void Player::Run()
{
while (this->tempoCount > 240)
@@ -146,6 +155,7 @@
this->tracks[i].updateFlags.reset();
}
+// Original FSS Function: Snd_Timer
void Player::Timer()
{
this->UpdateTracks();
--- a/src/in_ncsf/SSEQPlayer/Track.cpp
+++ b/src/in_ncsf/SSEQPlayer/Track.cpp
@@ -18,6 +18,7 @@
this->Zero();
}
+// Original FSS Function: Player_InitTrack
void Track::Init(uint8_t handle, Player *player, const uint8_t *dataPos, int n)
{
this->trackId = handle;
@@ -59,6 +60,7 @@
this->updateFlags.reset();
}
+// Original FSS Function: Track_ClearState
void Track::ClearState()
{
this->state.reset();
@@ -84,16 +86,18 @@
this->modType = 0;
this->modRange = 1;
this->modSpeed = 16;
- this->modDelay = 10;
+ this->modDelay = 0;
this->modDepth = 0;
}
+// Original FSS Function: Track_Free
void Track::Free()
{
this->state.reset();
this->updateFlags.reset();
}
+// Original FSS Function: Note_On
int Track::NoteOn(int key, int vel, int len)
{
auto sbnk = this->ply->sseq->bank;
@@ -212,6 +216,7 @@
return nCh;
}
+// Original FSS Function: Note_On_Tie
int Track::NoteOnTie(int key, int vel)
{
// Find an existing note
@@ -247,6 +252,7 @@
return i;
}
+// Original FSS Function: Track_ReleaseAllNotes
void Track::ReleaseAllNotes()
{
for (int i = 0; i < 16; ++i)
@@ -469,6 +475,7 @@
}
}
+// Original FSS Function: Track_Run
void Track::Run()
{
// Indicate "heartbeat" for this track