comparison jssplr.c @ 177:eb293aa7a671

Cleanup the player logic a bit.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 06 Oct 2012 11:22:38 +0300
parents 4192aa6d5af6
children bc8019c38ba5
comparison
equal deleted inserted replaced
176:dfe7e392ea7e 177:eb293aa7a671
1147 1147
1148 1148
1149 static void jmpProcessNewRow(JSSPlayer * mp, int channel) 1149 static void jmpProcessNewRow(JSSPlayer * mp, int channel)
1150 { 1150 {
1151 JSSNote *currNote; 1151 JSSNote *currNote;
1152 JSSExtInstrument *extInst = NULL;
1153 JSSInstrument *inst = NULL;
1154 BOOL newNote = FALSE; 1152 BOOL newNote = FALSE;
1155 int tmp, paramX, paramY; 1153 int tmp, paramX, paramY;
1156 JSSPlayerChannel *chn = &(mp->channels[channel]); 1154 JSSPlayerChannel *chn = &(mp->channels[channel]);
1157 1155
1158 JMPGETNOTE(currNote, mp->row, channel); 1156 JMPGETNOTE(currNote, mp->row, channel);
1179 chn->iCFadeOutVol = mpMaxFadeoutVol; 1177 chn->iCFadeOutVol = mpMaxFadeoutVol;
1180 1178
1181 // We save the instrument number here for later use 1179 // We save the instrument number here for later use
1182 if (currNote->instrument >= 0 && 1180 if (currNote->instrument >= 0 &&
1183 currNote->instrument < mp->module->nextInstruments) 1181 currNote->instrument < mp->module->nextInstruments)
1182 {
1184 chn->iCExtInstrumentN = currNote->instrument; 1183 chn->iCExtInstrumentN = currNote->instrument;
1184 chn->iCExtInstrument = mp->module->extInstruments[currNote->instrument];
1185 }
1185 } 1186 }
1186 1187
1187 /* ONLY if newNote was SET NOW and ExtInstrument HAS BEEN set, we can 1188 /* ONLY if newNote was SET NOW and ExtInstrument HAS BEEN set, we can
1188 * set new pitches, and other things... 1189 * set new pitches, and other things...
1189 */ 1190 */
1190 if (newNote) 1191 if (newNote && chn->iCExtInstrument != NULL)
1191 { 1192 {
1192 if (chn->iCExtInstrumentN != jsetNotSet) 1193 JSSExtInstrument *extInst = chn->iCExtInstrument;
1193 extInst = mp->module->extInstruments[chn->iCExtInstrumentN]; 1194
1194 else 1195 // Get instrument number
1195 extInst = NULL; 1196 tmp = extInst->sNumForNotes[chn->iCNote];
1196 1197
1197 if (extInst) 1198 if (tmp >= 0 && tmp < mp->module->ninstruments)
1198 { 1199 {
1199 // Set instrument 1200 // Set the new instrument
1200 int note = chn->iCNote; 1201 JSSInstrument *inst = mp->module->instruments[tmp];
1201 chn->iCExtInstrument = extInst; 1202 chn->iCInstrumentN = tmp;
1202 1203 chn->iCInstrument = inst;
1203 // We set new Instrument ONLY if NEW NOTE has been set 1204 chn->iCVolume = inst->volume;
1204 if (note != jsetNotSet) 1205 chn->iCPanning = inst->EPanning;
1205 { 1206 chn->iCPosition = 0;
1206 // Get instrument number 1207
1207 tmp = extInst->sNumForNotes[note]; 1208 // Set NDFlags
1208 1209 JMPSETNDFLAGS(cdfNewInstr | cdfNewPos | cdfNewPanPos | cdfNewVolume);
1209 if (tmp >= 0 && tmp < mp->module->ninstruments)
1210 {
1211 // Set the new instrument
1212 inst = mp->module->instruments[tmp];
1213 chn->iCInstrumentN = tmp;
1214 chn->iCInstrument = inst;
1215 chn->iCVolume = inst->volume;
1216 chn->iCPanning = inst->EPanning;
1217 chn->iCPosition = 0;
1218
1219 // Set NDFlags
1220 JMPSETNDFLAGS(cdfNewInstr | cdfNewPos | cdfNewPanPos | cdfNewVolume);
1221 }
1222 }
1223 } 1210 }
1224 } 1211 }
1225 1212
1226 if (inst) 1213 if (newNote && chn->iCInstrument != NULL)
1227 { 1214 {
1215 JSSInstrument *inst = chn->iCInstrument;
1216
1228 // Save old pitch for later use 1217 // Save old pitch for later use
1229 chn->iCOldPitch = chn->iCPitch; 1218 chn->iCOldPitch = chn->iCPitch;
1230 1219
1231 // Compute new pitch 1220 // Compute new pitch
1232 tmp = dmClamp(chn->iCNote + inst->ERelNote, 0, 119); 1221 tmp = dmClamp(chn->iCNote + inst->ERelNote, 0, 119);