# HG changeset patch # User Matti Hamalainen # Date 1349524709 -10800 # Node ID a65f0c3deaa77208f0eac4209b270ba04191cbc5 # Parent 9024d249e47a31d9a4cf2c74ed920f78119cdd73 Some more player logic cleanups and variable renames. diff -r 9024d249e47a -r a65f0c3deaa7 jloadxm.c --- a/jloadxm.c Sat Oct 06 13:25:37 2012 +0300 +++ b/jloadxm.c Sat Oct 06 14:58:29 2012 +0300 @@ -219,19 +219,17 @@ (void) e; (void) instr; // Convert envelope points - d->points[0].frame = s->points[0].frame; - d->points[0].value = s->points[0].value; for (i = 0; i < XM_MaxEnvPoints; i++) { - d->points[i + 1].frame = s->points[i].frame + 1; - d->points[i + 1].value = s->points[i].value; + d->points[i].frame = s->points[i].frame; + d->points[i].value = s->points[i].value; } // Convert other values - d->npoints = s->npoints + 1; - d->sustain = s->sustain + 1; - d->loopS = s->loopS + 1; - d->loopE = s->loopE + 1; + d->npoints = s->npoints; + d->sustain = s->sustain; + d->loopS = s->loopS; + d->loopE = s->loopE; // Check if the envelope is used if (s->flags & 0x01) diff -r 9024d249e47a -r a65f0c3deaa7 jssplr.c --- a/jssplr.c Sat Oct 06 13:25:37 2012 +0300 +++ b/jssplr.c Sat Oct 06 14:58:29 2012 +0300 @@ -71,11 +71,11 @@ res = ((period1 + period2) * 2) >> moctave; - //fprintf(stderr, "jmpGetAmigaPeriod(%d, %d) = %d\n", note, finetune, res); +//fprintf(stderr, "jmpGetAmigaPeriod(%d, %d) = %d\n", note, finetune, res); } else { - //fprintf(stderr, "jmpGetLinearPeriod(%d, %d) = %d\n", note, finetune, res); +//fprintf(stderr, "jmpGetLinearPeriod(%d, %d) = %d\n", note, finetune, res); //res = ((120 - note) << 6) - (finetune / 2); res = 7680 - (note * 64) - (finetune / 2); if (res < 1) res = 1; @@ -116,12 +116,12 @@ volume = dmClamp(volume, mpMinVol, mpMaxVol); -//fprintf(stderr, "chn %d: vol=%d, fad=%d, env=%d\n", channel, volume, chn->iCFadeOutVol, chn->iCVolEnv); +//fprintf(stderr, "chn %d: vol=%d, fad=%d, env=%d\n", channel, volume, chn->fadeOutVol, chn->volumeEnv.value); if (mp->future == NULL) { jvmSetVolume(mp->device, channel, - (chn->iCFadeOutVol * chn->iCVolEnv * volume) / (16 * 65536)); + (chn->fadeOutVol * chn->volumeEnv.value * volume) / (16 * 65536)); } else if (init) @@ -133,7 +133,7 @@ else { jvmSetVolumeRamp(mp->device, channel, - (chn->iCFadeOutVol * chn->iCVolEnv * volume) / (16 * 65536), + (chn->fadeOutVol * chn->volumeEnv.value * volume) / (16 * 65536), jvmGetVolume(mp->future->device, channel), 0); } } @@ -147,80 +147,79 @@ if (mp->future == NULL) { jvmSetPan(mp->device, channel, - panning + (((chn->iCPanEnv - 32) * (128 - abs(panning - 128))) / 32)); + panning + (((chn->panningEnv.value - 32) * (128 - abs(panning - 128))) / 32)); } else { jvmSetPanRamp(mp->device, channel, - panning + (((chn->iCPanEnv - 32) * (128 - abs(panning - 128))) / 32), + panning + (((chn->panningEnv.value - 32) * (128 - abs(panning - 128))) / 32), jvmGetPan(mp->future->device, channel), 0); } } -static int jmpFindEnvPoint(JSSEnvelope * env, const int pos) +static BOOL jmpExecEnvelope(JSSEnvelope *env, JSSPlayerEnvelope *pe, BOOL keyOff) { - int i; + int point = 0; + + if (!pe->exec) + return FALSE; - for (i = 0; i < env->npoints - 1; i++) + while (point < env->npoints - 1) + { + if (pe->frame >= env->points[point + 1].frame) + point++; + else + break; + } + if (pe->frame >= env->points[env->npoints - 1].frame) { - if (env->points[i].frame <= pos && - env->points[i + 1].frame >= pos) - return i; + if (env->flags & jenvfLooped) + { + point = env->loopS; + pe->frame = env->points[env->loopS].frame; + } + else + { + point = env->npoints - 1; + pe->exec = FALSE; + } + + pe->value = env->points[point].value; + } + else + { + // Linearly interpolate the value for given frame + JSSEnvelopePoint + *ep1 = &env->points[point], + *ep2 = &env->points[point + 1]; + + int delta = ep2->frame - ep1->frame; + if (delta > 0) + pe->value = ep1->value + ((ep2->value - ep1->value) * (pe->frame - ep1->frame)) / delta; + else + pe->value = ep1->value; } - return -1; -} - - -static void jmpExecEnvelope(JSSEnvelope * env, BOOL keyOff, int * frames, BOOL * doExec, int * result) -{ - int currPoint, delta; - JSSEnvelopePoint *ipf1, *ipf2; - - // OK, find the current point based on frame - currPoint = jmpFindEnvPoint(env, *frames); - - // Check if the envelope has ended - if (currPoint < 0 && (env->flags & jenvfLooped) == 0) - { - *doExec = FALSE; - return; - } - - // Do the envelope looping here, if needed - if ((env->flags & jenvfLooped) && *frames >= env->points[env->loopE].frame) + if (pe->exec) { - currPoint = env->loopS; - *frames = env->points[currPoint].frame; + // The frame counter IS processed even if the envelope is not! + if ((env->flags & jenvfSustain) && point == env->sustain && + env->points[point].frame == env->points[env->sustain].frame) + { + if (keyOff) + pe->frame++; + } else + pe->frame++; } - - // If the current point is OK, then process the envelope - if (currPoint >= 0) - { - // Linearly interpolate the value for given frame - ipf1 = &env->points[currPoint]; - ipf2 = &env->points[currPoint + 1]; - - delta = (ipf2->frame - ipf1->frame); - if (delta > 0) - *result = ipf1->value + ((ipf2->value - ipf1->value) * (*frames - ipf1->frame)) / delta; - else - *result = ipf1->value; - } - - // The frame counter IS processed even if the envelope is not! - if ((env->flags & jenvfSustain) && currPoint == env->sustain && - env->points[currPoint].frame == env->points[env->sustain].frame) { - if (keyOff) (*frames)++; - } else - (*frames)++; + + return TRUE; } static void jmpProcessExtInstrument(JSSPlayerChannel *chn, int channel) { - JSSExtInstrument *inst = chn->iCExtInstrument; + JSSExtInstrument *inst = chn->extInstrument; (void) channel; // Get the instrument for envelope data @@ -231,57 +230,42 @@ FIXME fix me FIX me!!! todo. */ - // Process the volume envelope if (inst->volumeEnv.flags & jenvfUsed) { // Process the instrument volume fadeout - if (chn->iCKeyOff && chn->iCFadeOutVol > 0 && inst->fadeOut > 0) + if (chn->keyOff && chn->fadeOutVol > 0 && inst->fadeOut > 0) { - int tmp = chn->iCFadeOutVol - inst->fadeOut; + int tmp = chn->fadeOutVol - inst->fadeOut; if (tmp < 0) tmp = 0; - chn->iCFadeOutVol = tmp; + chn->fadeOutVol = tmp; JMPSETNDFLAGS(cdfNewVolume); } - if (chn->iCVolEnv_Exec) - { - // Execute the volume envelope - jmpExecEnvelope(&(inst->volumeEnv), - chn->iCKeyOff, - &(chn->iCVolEnv_Frames), &(chn->iCVolEnv_Exec), - &(chn->iCVolEnv)); - + // Execute the volume envelope + if (jmpExecEnvelope(&inst->volumeEnv, &chn->volumeEnv, chn->keyOff)) JMPSETNDFLAGS(cdfNewVolume); - } } else { // If the envelope is not used, set max volume - chn->iCVolEnv = mpMaxVol; - chn->iCFadeOutVol = chn->iCKeyOff ? 0 : mpMaxFadeoutVol; + chn->volumeEnv.value = mpMaxVol; + chn->fadeOutVol = chn->keyOff ? 0 : mpMaxFadeoutVol; JMPSETNDFLAGS(cdfNewVolume); } - // Process the panning envelope if (inst->panningEnv.flags & jenvfUsed) { - if (chn->iCPanEnv_Exec) - { - // Execute the panning envelope - jmpExecEnvelope(&(inst->panningEnv), chn->iCKeyOff, - &(chn->iCPanEnv_Frames), &(chn->iCPanEnv_Exec), - &(chn->iCPanEnv)); - + // Process the panning envelope + if (jmpExecEnvelope(&inst->panningEnv, &chn->panningEnv, chn->keyOff)) JMPSETNDFLAGS(cdfNewPanPos); - } } else { // If the envelope is not used, set center panning - if (chn->iCPanEnv != mpPanCenter) + if (chn->panningEnv.value != mpPanCenter) { - chn->iCPanEnv = mpPanCenter; + chn->panningEnv.value = mpPanCenter; JMPSETNDFLAGS(cdfNewPanPos); } } @@ -365,10 +349,10 @@ /* Reset the envelopes for given channel. */ -static void jmpResetEnvelopes(JSSPlayerChannel *chn) +static void jmpResetEnvelope(JSSPlayerEnvelope *env) { - chn->iCPanEnv_Frames = chn->iCVolEnv_Frames = 0; - chn->iCPanEnv_Exec = chn->iCVolEnv_Exec = TRUE; + env->frame = env->value = 0; + env->exec = TRUE; } @@ -378,11 +362,11 @@ { memset(chn, 0, sizeof(JSSPlayerChannel)); - chn->iCNote = jsetNotSet; - chn->iCInstrumentN = jsetNotSet; - chn->iCExtInstrumentN = jsetNotSet; - chn->iCPanning = mpPanCenter; - chn->iCPanEnv = mpPanCenter; + chn->note = jsetNotSet; + chn->ninstrument = jsetNotSet; + chn->nextInstrument = jsetNotSet; + chn->panning = mpPanCenter; + chn->panningEnv.value = mpPanCenter; } @@ -671,11 +655,11 @@ { (void) channel; - chn->iCVolume = dmClamp(volume, mpMinVol, mpMaxVol); + chn->volume = dmClamp(volume, mpMinVol, mpMaxVol); JMPSETNDFLAGS(cdfNewVolume); } -#define jmpChangeVolume(Q, Z, X) jmpSetVolume(Q, Z, chn->iCVolume + (X)) +#define jmpChangeVolume(Q, Z, X) jmpSetVolume(Q, Z, chn->volume + (X)) /* Change the pitch of given channel by ADelta. @@ -686,11 +670,11 @@ (void) channel; // Calculate new pitch and check it - value = chn->iCPitch + delta; + value = chn->pitch + delta; if (value < 0) value = 0; - chn->iCPitch = value; + chn->pitch = value; JMPSETNDFLAGS(cdfNewPitch); } @@ -711,20 +695,20 @@ /* Slide the pitch of channel to the destination value * with speed of iLastPortaToNoteParam[] * 4 and stop when it equals. */ - if (chn->iCPitch < chn->iLastPortaToNotePitch) + if (chn->pitch < chn->iLastPortaToNotePitch) { // Increase pitch UP jmpChangePitch(chn, channel, chn->iLastPortaToNoteParam * 4); - if (chn->iCPitch > chn->iLastPortaToNotePitch) - chn->iCPitch = chn->iLastPortaToNotePitch; + if (chn->pitch > chn->iLastPortaToNotePitch) + chn->pitch = chn->iLastPortaToNotePitch; } else - if (chn->iCPitch > chn->iLastPortaToNotePitch) + if (chn->pitch > chn->iLastPortaToNotePitch) { // Decrease pitch DOWN jmpChangePitch(chn, channel, -(chn->iLastPortaToNoteParam * 4)); - if (chn->iCPitch < chn->iLastPortaToNotePitch) - chn->iCPitch = chn->iLastPortaToNotePitch; + if (chn->pitch < chn->iLastPortaToNotePitch) + chn->pitch = chn->iLastPortaToNotePitch; } } @@ -736,14 +720,14 @@ int delta, pos, depth; // Check settings - if (chn->iTremoloDepth == 0 || chn->iTremoloSpeed == 0) + if (chn->tremolo.depth == 0 || chn->tremolo.speed == 0) return; // Get position of tremolo waveform - pos = chn->iTremoloPos & 255; - depth = chn->iTremoloDepth; + pos = chn->tremolo.pos & 255; + depth = chn->tremolo.depth; - switch (chn->iTremoloWC & 3) + switch (chn->tremolo.wc & 3) { case 0: // Sine-wave delta = (jmpSineTable[pos] * depth) / 2048; @@ -762,12 +746,12 @@ } // Set the new volume - jmpCSetVolume(mp, chn, channel, chn->iCVolume + delta, FALSE); + jmpCSetVolume(mp, chn, channel, chn->volume + delta, FALSE); // Advance tremolo waveform position - chn->iTremoloPos += chn->iTremoloSpeed; - if (chn->iTremoloPos > 255) - chn->iTremoloPos = 0; + chn->tremolo.pos += chn->tremolo.speed; + if (chn->tremolo.pos > 255) + chn->tremolo.pos = 0; } @@ -778,14 +762,14 @@ int delta, pos, depth; // Check settings - if (chn->iVibratoDepth == 0 || chn->iVibratoSpeed == 0) + if (chn->vibrato.depth == 0 || chn->vibrato.speed == 0) return; // Get position of vibrato waveform - pos = chn->iVibratoPos & 255; - depth = chn->iVibratoDepth; + pos = chn->vibrato.pos & 255; + depth = chn->vibrato.depth; - switch (chn->iVibratoWC & 3) + switch (chn->vibrato.wc & 3) { case 0: // Sine-wave delta = (jmpSineTable[pos] * depth) / 2048; @@ -804,12 +788,12 @@ } // Set the new frequency - jmpCSetPitch(mp, channel, chn->iCPitch + delta); + jmpCSetPitch(mp, channel, chn->pitch + delta); // Advance vibrato waveform position - chn->iVibratoPos += chn->iVibratoSpeed; - if (chn->iVibratoPos > 255) - chn->iVibratoPos = 0; + chn->vibrato.pos += chn->vibrato.speed; + if (chn->vibrato.pos > 255) + chn->vibrato.pos = 0; } @@ -872,11 +856,11 @@ */ static void jmpDoArpeggio(JSSPlayer * mp, JSSPlayerChannel *chn, int channel, int paramY, int paramX) { - JSSInstrument *tempInst = chn->iCInstrument; + JSSInstrument *tempInst = chn->instrument; if (tempInst) { - int tmp = chn->iCNote; + int tmp = chn->note; if (tmp == jsetNotSet || tmp == jsetNoteOff) return; switch (mp->tick & 3) { @@ -928,21 +912,21 @@ if (currNote->note != jsetNotSet && currNote->note != jsetNoteOff) { - chn->iLastPortaToNotePitch = chn->iCPitch; - chn->iCPitch = chn->iCOldPitch; + chn->iLastPortaToNotePitch = chn->pitch; + chn->pitch = chn->oldPitch; JMPUNSETNDFLAGS(cdfNewPitch | cdfPlay); } break; case '4': // 4xy = Vibrato : IMPL.VERIFIED if (paramX) - chn->iVibratoSpeed = paramX; + chn->vibrato.speed = paramX; if (paramY) - chn->iVibratoDepth = paramY; + chn->vibrato.depth = paramY; - if ((chn->iVibratoWC & 4) == 0) - chn->iVibratoPos = 0; + if ((chn->vibrato.wc & 4) == 0) + chn->vibrato.pos = 0; break; case '5': // 5xy = Portamento + Volume Slide @@ -953,23 +937,24 @@ case '7': // 7xy = Tremolo if (paramX) - chn->iTremoloSpeed = paramX; + chn->tremolo.speed = paramX; if (paramY) - chn->iTremoloDepth = paramY; + chn->tremolo.depth = paramY; - if ((chn->iTremoloWC & 4) == 0) - chn->iTremoloPos = 0; + if ((chn->tremolo.wc & 4) == 0) + chn->tremolo.pos = 0; break; case '8': // 8xx = Set Panning - JMPDEBUG("Set Panning used, UNIMPLEMENTED"); + chn->panning = param; + JMPSETNDFLAGS(cdfNewPanPos); break; case '9': // 9xx = Set Sample Offset : IMPL.VERIFIED - if (chn->iCNewDataFlags & cdfNewPitch) + if (chn->newDataFlags & cdfNewPitch) { - chn->iCPosition = param * 0x100; + chn->position = param * 0x100; JMPSETNDFLAGS(cdfNewPos); } break; @@ -1031,7 +1016,7 @@ break; case 0x04: // E4x - Set Vibrato waveform - chn->iVibratoWC = paramY; + chn->vibrato.wc = paramY; break; case 0x05: // E5x - Set Finetune @@ -1043,11 +1028,11 @@ break; case 0x07: // E7x - Set Tremolo waveform - chn->iTremoloWC = paramY; + chn->tremolo.wc = paramY; break; case 0x08: // E8x - Set Pan Position - chn->iCPanning = (paramY * 16); + chn->panning = (paramY * 16); JMPSETNDFLAGS(cdfNewPanPos); break; @@ -1075,8 +1060,8 @@ if (paramY > 0) { // Save the ND-flags, then clear - chn->iSaveNDFlags = chn->iCNewDataFlags; - chn->iCNewDataFlags = 0; + chn->iSaveNDFlags = chn->newDataFlags; + chn->newDataFlags = 0; // TODO .. does this only affect NOTE or also instrument? } break; @@ -1115,15 +1100,15 @@ break; case 'K': // Kxx = Key-off (Same as key-off note) - chn->iCKeyOff = TRUE; + chn->keyOff = TRUE; break; case 'L': // Lxx = Set Envelope Position JMPDEBUG("Set Envelope Position used, NOT verified with FT2"); - chn->iCPanEnv_Frames = param; - chn->iCVolEnv_Frames = param; - chn->iCPanEnv_Exec = TRUE; - chn->iCVolEnv_Exec = TRUE; + chn->panningEnv.frame = param; + chn->volumeEnv.frame = param; + chn->panningEnv.exec = TRUE; + chn->volumeEnv.exec = TRUE; break; case 'R': // Rxy = Multi Retrig note @@ -1176,13 +1161,13 @@ // Check for a new note/keyoff here if (currNote->note == jsetNoteOff) - chn->iCKeyOff = TRUE; + chn->keyOff = TRUE; else if (currNote->note >= 0 && currNote->note <= 96) { // New note was set newNote = TRUE; - chn->iCNote = currNote->note; + chn->note = currNote->note; } // Check for new instrument @@ -1191,45 +1176,46 @@ /* Envelopes and ext.instrument fadeout are initialized always if * new instrument is set, even if the instrument does not exist. */ - jmpResetEnvelopes(chn); - chn->iCKeyOff = FALSE; - chn->iCFadeOutVol = mpMaxFadeoutVol; + jmpResetEnvelope(&chn->volumeEnv); + jmpResetEnvelope(&chn->panningEnv); + chn->keyOff = FALSE; + chn->fadeOutVol = mpMaxFadeoutVol; // We save the instrument number here for later use if (currNote->instrument >= 0 && currNote->instrument < mp->module->nextInstruments) { - chn->iCExtInstrumentN = currNote->instrument; - chn->iCExtInstrument = mp->module->extInstruments[currNote->instrument]; + chn->nextInstrument = currNote->instrument; + chn->extInstrument = mp->module->extInstruments[currNote->instrument]; // Get instrument number - tmp = chn->iCExtInstrument->sNumForNotes[chn->iCNote]; + tmp = chn->extInstrument->sNumForNotes[chn->note]; if (tmp >= 0 && tmp < mp->module->ninstruments) { JSSInstrument *inst = mp->module->instruments[tmp]; - chn->iCInstrumentN = tmp; - chn->iCInstrument = inst; - chn->iCVolume = inst->volume; - chn->iCPanning = inst->EPanning; - chn->iCPosition = 0; + chn->ninstrument = tmp; + chn->instrument = inst; + chn->volume = inst->volume; + chn->panning = inst->EPanning; + chn->position = 0; JMPSETNDFLAGS(cdfPlay | cdfNewPos | cdfNewInstr | cdfNewVolume | cdfNewPanPos); } } } - if (newNote && chn->iCInstrument != NULL) + if (newNote && chn->instrument != NULL) { - JSSInstrument *inst = chn->iCInstrument; + JSSInstrument *inst = chn->instrument; // Save old pitch for later use - chn->iCOldPitch = chn->iCPitch; + chn->oldPitch = chn->pitch; - chn->iCPosition = 0; + chn->position = 0; // Compute new pitch - tmp = dmClamp(chn->iCNote + inst->ERelNote, 0, 119); - chn->iCPitch = jmpGetPeriodFromNote(mp, tmp, inst->EFineTune); + tmp = dmClamp(chn->note + inst->ERelNote, 0, 119); + chn->pitch = jmpGetPeriodFromNote(mp, tmp, inst->EFineTune); JMPSETNDFLAGS(cdfNewPitch | cdfPlay | cdfNewPos); } @@ -1255,12 +1241,12 @@ break; case 0x09: // Sx = Set vibrato speed : IMPL.VERIFIED - chn->iVibratoSpeed = paramY; + chn->vibrato.speed = paramY; break; case 0x0a: // Vx = Vibrato : IMPL.VERIFIED if (paramY) - chn->iVibratoDepth = paramY; + chn->vibrato.depth = paramY; break; case 0x0e: // Mx = Porta To Note : IMPL.VERIFIED @@ -1269,8 +1255,8 @@ if (currNote->note != jsetNotSet && currNote->note != jsetNoteOff) { - chn->iLastPortaToNotePitch = chn->iCPitch; - chn->iCPitch = chn->iCOldPitch; + chn->iLastPortaToNotePitch = chn->pitch; + chn->pitch = chn->oldPitch; JMPUNSETNDFLAGS(cdfNewPitch | cdfPlay); } break; @@ -1372,7 +1358,7 @@ case 0x0d: // EDx - Set Note Delay if (mp->tick == paramY) - chn->iCNewDataFlags = chn->iSaveNDFlags; + chn->newDataFlags = chn->iSaveNDFlags; break; } break; @@ -1383,7 +1369,7 @@ paramY++; tmp = (chn->iTremorCount % (paramX + paramY)); if (tmp < paramX) - jmpCSetVolume(mp, chn, channel, chn->iCVolume, FALSE); + jmpCSetVolume(mp, chn, channel, chn->volume, FALSE); else jmpCSetVolume(mp, chn, channel, jsetMinVol, FALSE); @@ -1424,7 +1410,7 @@ mp->breakFlag = FALSE; for (channel = 0; channel < jsetNChannels; channel++) - mp->channels[channel].iCNewDataFlags = 0; + mp->channels[channel].newDataFlags = 0; //fprintf(stderr, "1: tick=%d, order=%d, iPattern=%d, row=%d\n", mp->tick, mp->order, mp->npattern, mp->row); @@ -1530,7 +1516,7 @@ jmpProcessExtInstrument(chn, channel); // Check NDFlags and update channel data - flags = chn->iCNewDataFlags; + flags = chn->newDataFlags; if (!flags) continue; @@ -1544,7 +1530,7 @@ // No, handle other flags if (flags & cdfNewInstr) { - JSSInstrument *instr = chn->iCInstrument; + JSSInstrument *instr = chn->instrument; if (instr != NULL) { jvmSetSample(mp->device, channel, @@ -1558,16 +1544,16 @@ jvmPlay(mp->device, channel); if (flags & cdfNewPitch) - jmpCSetPitch(mp, channel, chn->iCPitch); + jmpCSetPitch(mp, channel, chn->pitch); if (flags & cdfNewPos) - jvmSetPos(mp->device, channel, chn->iCPosition); + jvmSetPos(mp->device, channel, chn->position); if (flags & cdfNewVolume) - jmpCSetVolume(mp, chn, channel, chn->iCVolume, flags & cdfNewInstr); + jmpCSetVolume(mp, chn, channel, chn->volume, flags & cdfNewInstr); if (flags & cdfNewPanPos) - jmpCSetPanning(mp, chn, channel, chn->iCPanning); + jmpCSetPanning(mp, chn, channel, chn->panning); if (flags & cdfNewGlobalVol) jvmSetGlobalVol(mp->device, mp->globalVol); diff -r 9024d249e47a -r a65f0c3deaa7 jssplr.h --- a/jssplr.h Sat Oct 06 13:25:37 2012 +0300 +++ b/jssplr.h Sat Oct 06 14:58:29 2012 +0300 @@ -31,27 +31,60 @@ #define cdfStop (0x80) // Stop channel playing +// Player envelope data +typedef struct +{ + int frame, value; + BOOL exec; +} JSSPlayerEnvelope; + + +typedef struct +{ + int pos, speed, depth, wc; +} JSSPlayerVData; + + // Player channel structure typedef struct { - int iPatLoopRow, // Pattern loop start row + JSSPlayerEnvelope volumeEnv, panningEnv; + + JSSPlayerVData vibrato, tremolo; + + BOOL keyOff; + + JSSInstrument *instrument; // Instrument + JSSExtInstrument *extInstrument; // ExtInstrument + int ninstrument, + nextInstrument, + note, // Current note + pitch, // Pitch (NOT actual frequency!) + oldPitch, + position, // Sample position + volume, // Volume + panning, // Panning position + + newDataFlags, // New data flags + + fadeOutVol, + + iCAutoVib_Frame, + + iCLastFineVolumeslideUpParam, + iCLastFineVolumeslideDownParam, + iCLastExtraFinePortamentoUpParam, + iCLastExtraFinePortamentoDownParam, + iCLastFinePortamentoUpParam, + iCLastFinePortamentoDownParam, + + iPatLoopRow, // Pattern loop start row iPatLoopCount, // Pattern loop count iLastPortaParam, // Last portamento effect parameter iLastPortaToNoteParam, // Last porta-to-note parameter iLastPortaToNotePitch, // Last porta-to-note pitch - iVibratoPos, // Vibrato waveform position - iVibratoSpeed, // Vibrato speed - iVibratoDepth, // Vibrato depth - iVibratoWC, // Vibrato wave control - - iTremoloPos, // Tremolo waveform position - iTremoloSpeed, // Tremolo speed - iTremoloDepth, // Tremolo depth - - iTremoloWC, // Tremolo wave control - iLastTremorParam, iTremorCount, iLastSampleOffset, @@ -60,40 +93,6 @@ iRetrigNDFlags, // For retrig-effect iSaveNDFlags; // For notedelay-effect - - // Current channel data - JSSInstrument *iCInstrument; // Instrument - JSSExtInstrument *iCExtInstrument; // ExtInstrument - int iCInstrumentN, - iCExtInstrumentN, - iCNote, // Current note - iCPitch, // Pitch (NOT actual frequency!) - iCOldPitch, - iCPosition, // Sample position - iCVolume, // Volume - iCPanning, // Panning position - - iCNewDataFlags, // New data flags - - iCFadeOutVol, - - iCPanEnv, - iCVolEnv, - - iCAutoVib_Frames, - iCPanEnv_Frames, - iCVolEnv_Frames, - - iCLastFineVolumeslideUpParam, - iCLastFineVolumeslideDownParam, - iCLastExtraFinePortamentoUpParam, - iCLastExtraFinePortamentoDownParam, - iCLastFinePortamentoUpParam, - iCLastFinePortamentoDownParam; - - BOOL iCPanEnv_Exec, - iCVolEnv_Exec, - iCKeyOff; } JSSPlayerChannel; @@ -119,14 +118,13 @@ int patternDelay, // Pattern delay tick-counter lastPatLoopRow; // Latest set pattern loop row (any channel) + BOOL jumpFlag, // Pattern jump flag + breakFlag; // Pattern break flag // All channels for this player // int nchannels; JSSPlayerChannel channels[jsetNChannels]; - // Parameters for effects, etc - BOOL jumpFlag, // Pattern jump flag - breakFlag; // Pattern break flag // Module and sounddevice specific JSSModule *module; // Current module in this player @@ -158,8 +156,8 @@ /* Helper macros */ #define JMPMAKEPARAM(AIVAL, AVALX, AVALY) { AVALX = (((AIVAL) >> 4) & 0x0f); AVALY = ((AIVAL) & 0x0f); } -#define JMPSETNDFLAGS(IVAL) chn->iCNewDataFlags |= IVAL -#define JMPUNSETNDFLAGS(IVAL) chn->iCNewDataFlags &= (~(IVAL)) +#define JMPSETNDFLAGS(IVAL) chn->newDataFlags |= IVAL +#define JMPUNSETNDFLAGS(IVAL) chn->newDataFlags &= (~(IVAL)) #define JMPGETNOTE(MNOTE, MROW, MCHAN) assert(mp); assert(mp->pattern); assert((MROW) >= 0); assert((MROW) < mp->pattern->nrows); MNOTE = &mp->pattern->data[(mp->pattern->nchannels * MROW) + (MCHAN)] #define JMPGETEFFECT(MEFF, MIEFF) if ((MIEFF >= 0) && (MIEFF < jmpNMODEffectTable)) MEFF = jmpMODEffectTable[MIEFF]; else MEFF = 0 #define JMPGETMODFLAGS(Q, Z) ((Q->module->defFlags & (Z)) == (Z))