9 #include "hvl_replay.h"
11 int32 stereopan_left[] = { 128, 96, 64, 32, 0 };
12 int32 stereopan_right[] = { 128, 160, 193, 225, 255 };
17 #define WHITENOISELEN (0x280*3)
19 #define WO_LOWPASSES 0
20 #define WO_TRIANGLE_04 (WO_LOWPASSES+((0xfc+0xfc+0x80*0x1f+0x80+3*0x280)*31))
21 //#define WO_TRIANGLE_04 (WO_LOWPASSES+((0x01+0x01+0x01*0x01+0x01+3*0x010)*31))
22 #define WO_TRIANGLE_08 (WO_TRIANGLE_04+0x04)
23 #define WO_TRIANGLE_10 (WO_TRIANGLE_08+0x08)
24 #define WO_TRIANGLE_20 (WO_TRIANGLE_10+0x10)
25 #define WO_TRIANGLE_40 (WO_TRIANGLE_20+0x20)
26 #define WO_TRIANGLE_80 (WO_TRIANGLE_40+0x40)
27 #define WO_SAWTOOTH_04 (WO_TRIANGLE_80+0x80)
28 #define WO_SAWTOOTH_08 (WO_SAWTOOTH_04+0x04)
29 #define WO_SAWTOOTH_10 (WO_SAWTOOTH_08+0x08)
30 #define WO_SAWTOOTH_20 (WO_SAWTOOTH_10+0x10)
31 #define WO_SAWTOOTH_40 (WO_SAWTOOTH_20+0x20)
32 #define WO_SAWTOOTH_80 (WO_SAWTOOTH_40+0x40)
33 #define WO_SQUARES (WO_SAWTOOTH_80+0x80)
34 #define WO_WHITENOISE (WO_SQUARES+(0x80*0x20))
35 #define WO_HIGHPASSES (WO_WHITENOISE+WHITENOISELEN)
36 #define WAVES_SIZE (WO_HIGHPASSES+((0xfc+0xfc+0x80*0x1f+0x80+3*0x280)*31))
38 int8 waves[WAVES_SIZE];
40 CONST int16 vib_tab[] =
42 0,24,49,74,97,120,141,161,180,197,212,224,235,244,250,253,255,
43 253,250,244,235,224,212,197,180,161,141,120,97,74,49,24,
44 0,-24,-49,-74,-97,-120,-141,-161,-180,-197,-212,-224,-235,-244,-250,-253,-255,
45 -253,-250,-244,-235,-224,-212,-197,-180,-161,-141,-120,-97,-74,-49,-24
48 CONST uint16 period_tab[] =
50 0x0000, 0x0D60, 0x0CA0, 0x0BE8, 0x0B40, 0x0A98, 0x0A00, 0x0970,
51 0x08E8, 0x0868, 0x07F0, 0x0780, 0x0714, 0x06B0, 0x0650, 0x05F4,
52 0x05A0, 0x054C, 0x0500, 0x04B8, 0x0474, 0x0434, 0x03F8, 0x03C0,
53 0x038A, 0x0358, 0x0328, 0x02FA, 0x02D0, 0x02A6, 0x0280, 0x025C,
54 0x023A, 0x021A, 0x01FC, 0x01E0, 0x01C5, 0x01AC, 0x0194, 0x017D,
55 0x0168, 0x0153, 0x0140, 0x012E, 0x011D, 0x010D, 0x00FE, 0x00F0,
56 0x00E2, 0x00D6, 0x00CA, 0x00BE, 0x00B4, 0x00AA, 0x00A0, 0x0097,
57 0x008F, 0x0087, 0x007F, 0x0078, 0x0071
60 uint32 panning_left[256], panning_right[256];
62 static inline void clr_l( ULONG *src, uint32 longs)
70 void hvl_GenPanningTables( void )
75 // Sine based panning table
76 aa = (3.14159265f*2.0f)/4.0f; // Quarter of the way through the sinewave == top peak
77 ab = 0.0f; // Start of the climb from zero
79 for( i=0; i<256; i++ )
81 panning_left[i] = (uint32)(sin(aa)*255.0f);
82 panning_right[i] = (uint32)(sin(ab)*255.0f);
84 aa += (3.14159265*2.0f/4.0f)/256.0f;
85 ab += (3.14159265*2.0f/4.0f)/256.0f;
87 panning_left[255] = 0;
91 void hvl_GenSawtooth( int8 *buf, uint32 len )
99 for( i=0; i<len; i++, val += add )
103 void hvl_GenTriangle( int8 *buf, uint32 len )
106 int32 d2, d5, d1, d4;
116 for( i=0; i<d5; i++ )
126 for( i=0; i<d5-1; i++ )
134 for( i=0; i<d5*2; i++ )
148 void hvl_GenSquare( int8 *buf )
152 for( i=1; i<=0x20; i++ )
154 for( j=0; j<(0x40-i)*2; j++ )
156 for( j=0; j<i*2; j++ )
161 static inline float64 clip( float64 x )
165 else if( x < -128.f )
170 void hvl_GenFilterWaves( int8 *buf, int8 *lowbuf, int8 *highbuf )
172 static const uint16 LengthTable[45] = { 3, 7, 0xf, 0x1f, 0x3f, 0x7f, 3, 7, 0xf, 0x1f, 0x3f, 0x7f,
173 0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,
174 0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,
180 for( temp=0, freq=8.f; temp<31; temp++, freq += 3.f )
185 for( waves=0; waves<6+6+0x20+1; waves++ )
187 float64 fre, high, mid, low;
192 fre = freq * 1.25f / 100.f;
194 for( i=0; i<=LengthTable[waves]; i++ )
196 high = a0[i] - mid - low;
204 for( i=0; i<=LengthTable[waves]; i++ )
206 high = a0[i] - mid - low;
212 *lowbuf++ = (int8)low;
213 *highbuf++ = (int8)high;
216 a0 += LengthTable[waves] + 1;
221 void hvl_GenWhiteNoise( int8 *buf, uint32 len )
237 if( (LONG)(ays & 0xffff) >= 0 )
244 ays = (ays >> 5) | (ays << 27);
245 ays = (ays & 0xffffff00) | ((ays & 0xff) ^ 0x9a);
247 ays = (ays << 2) | (ays >> 30);
251 ays = (ays & 0xffff0000) | ax;
252 ays = (ays >> 3) | (ays << 29);
256 void hvl_reset_some_stuff( struct hvl_tune *ht )
260 for( i=0; i<MAX_CHANNELS; i++ )
262 ht->ht_Voices[i].vc_Delta=1;
263 ht->ht_Voices[i].vc_SamplePos=ht->ht_Voices[i].vc_Track=ht->ht_Voices[i].vc_Transpose=ht->ht_Voices[i].vc_NextTrack = ht->ht_Voices[i].vc_NextTranspose = 0;
264 ht->ht_Voices[i].vc_ADSRVolume=ht->ht_Voices[i].vc_InstrPeriod=ht->ht_Voices[i].vc_TrackPeriod=ht->ht_Voices[i].vc_VibratoPeriod=ht->ht_Voices[i].vc_NoteMaxVolume=ht->ht_Voices[i].vc_PerfSubVolume=ht->ht_Voices[i].vc_TrackMasterVolume=0;
265 ht->ht_Voices[i].vc_NewWaveform=ht->ht_Voices[i].vc_Waveform=ht->ht_Voices[i].vc_PlantSquare=ht->ht_Voices[i].vc_PlantPeriod=ht->ht_Voices[i].vc_IgnoreSquare=0;
266 ht->ht_Voices[i].vc_TrackOn=ht->ht_Voices[i].vc_FixedNote=ht->ht_Voices[i].vc_VolumeSlideUp=ht->ht_Voices[i].vc_VolumeSlideDown=ht->ht_Voices[i].vc_HardCut=ht->ht_Voices[i].vc_HardCutRelease=ht->ht_Voices[i].vc_HardCutReleaseF=0;
267 ht->ht_Voices[i].vc_PeriodSlideSpeed=ht->ht_Voices[i].vc_PeriodSlidePeriod=ht->ht_Voices[i].vc_PeriodSlideLimit=ht->ht_Voices[i].vc_PeriodSlideOn=ht->ht_Voices[i].vc_PeriodSlideWithLimit=0;
268 ht->ht_Voices[i].vc_PeriodPerfSlideSpeed=ht->ht_Voices[i].vc_PeriodPerfSlidePeriod=ht->ht_Voices[i].vc_PeriodPerfSlideOn=ht->ht_Voices[i].vc_VibratoDelay=ht->ht_Voices[i].vc_VibratoCurrent=ht->ht_Voices[i].vc_VibratoDepth=ht->ht_Voices[i].vc_VibratoSpeed=0;
269 ht->ht_Voices[i].vc_SquareOn=ht->ht_Voices[i].vc_SquareInit=ht->ht_Voices[i].vc_SquareLowerLimit=ht->ht_Voices[i].vc_SquareUpperLimit=ht->ht_Voices[i].vc_SquarePos=ht->ht_Voices[i].vc_SquareSign=ht->ht_Voices[i].vc_SquareSlidingIn=ht->ht_Voices[i].vc_SquareReverse=0;
270 ht->ht_Voices[i].vc_FilterOn=ht->ht_Voices[i].vc_FilterInit=ht->ht_Voices[i].vc_FilterLowerLimit=ht->ht_Voices[i].vc_FilterUpperLimit=ht->ht_Voices[i].vc_FilterPos=ht->ht_Voices[i].vc_FilterSign=ht->ht_Voices[i].vc_FilterSpeed=ht->ht_Voices[i].vc_FilterSlidingIn=ht->ht_Voices[i].vc_IgnoreFilter=0;
271 ht->ht_Voices[i].vc_PerfCurrent=ht->ht_Voices[i].vc_PerfSpeed=ht->ht_Voices[i].vc_WaveLength=ht->ht_Voices[i].vc_NoteDelayOn=ht->ht_Voices[i].vc_NoteCutOn=0;
272 ht->ht_Voices[i].vc_AudioPeriod=ht->ht_Voices[i].vc_AudioVolume=ht->ht_Voices[i].vc_VoiceVolume=ht->ht_Voices[i].vc_VoicePeriod=ht->ht_Voices[i].vc_VoiceNum=ht->ht_Voices[i].vc_WNRandom=0;
273 ht->ht_Voices[i].vc_SquareWait=ht->ht_Voices[i].vc_FilterWait=ht->ht_Voices[i].vc_PerfWait=ht->ht_Voices[i].vc_NoteDelayWait=ht->ht_Voices[i].vc_NoteCutWait=0;
274 ht->ht_Voices[i].vc_PerfList=0;
275 ht->ht_Voices[i].vc_RingSamplePos=ht->ht_Voices[i].vc_RingDelta=ht->ht_Voices[i].vc_RingPlantPeriod=ht->ht_Voices[i].vc_RingAudioPeriod=ht->ht_Voices[i].vc_RingNewWaveform=ht->ht_Voices[i].vc_RingWaveform=ht->ht_Voices[i].vc_RingFixedPeriod=ht->ht_Voices[i].vc_RingBasePeriod=0;
277 ht->ht_Voices[i].vc_RingMixSource = NULL;
278 ht->ht_Voices[i].vc_RingAudioSource = NULL;
280 clr_l((ULONG *)&ht->ht_Voices[i].vc_SquareTempBuffer,0x80/4);
281 clr_l((ULONG *)&ht->ht_Voices[i].vc_ADSR,sizeof(struct hvl_envelope)/4);
282 clr_l((ULONG *)&ht->ht_Voices[i].vc_VoiceBuffer,0x281/4);
283 clr_l((ULONG *)&ht->ht_Voices[i].vc_RingVoiceBuffer,0x281/4);
286 for( i=0; i<MAX_CHANNELS; i++ )
288 ht->ht_Voices[i].vc_WNRandom = 0x280;
289 ht->ht_Voices[i].vc_VoiceNum = i;
290 ht->ht_Voices[i].vc_TrackMasterVolume = 0x40;
291 ht->ht_Voices[i].vc_TrackOn = 1;
292 ht->ht_Voices[i].vc_MixSource = ht->ht_Voices[i].vc_VoiceBuffer;
296 BOOL hvl_InitSubsong( struct hvl_tune *ht, uint32 nr )
300 if( nr > ht->ht_SubsongNr )
306 if( nr ) PosNr = ht->ht_Subsongs[nr-1];
308 ht->ht_PosNr = PosNr;
310 ht->ht_PatternBreak = 0;
312 ht->ht_PosJumpNote = 0;
314 ht->ht_StepWaitFrames = 0;
315 ht->ht_GetNewPosition = 1;
316 ht->ht_SongEndReached = 0;
317 ht->ht_PlayingTime = 0;
319 for( i=0; i<MAX_CHANNELS; i+=4 )
321 ht->ht_Voices[i+0].vc_Pan = ht->ht_defpanleft;
322 ht->ht_Voices[i+0].vc_SetPan = ht->ht_defpanleft; // 1.4
323 ht->ht_Voices[i+0].vc_PanMultLeft = panning_left[ht->ht_defpanleft];
324 ht->ht_Voices[i+0].vc_PanMultRight = panning_right[ht->ht_defpanleft];
325 ht->ht_Voices[i+1].vc_Pan = ht->ht_defpanright;
326 ht->ht_Voices[i+1].vc_SetPan = ht->ht_defpanright; // 1.4
327 ht->ht_Voices[i+1].vc_PanMultLeft = panning_left[ht->ht_defpanright];
328 ht->ht_Voices[i+1].vc_PanMultRight = panning_right[ht->ht_defpanright];
329 ht->ht_Voices[i+2].vc_Pan = ht->ht_defpanright;
330 ht->ht_Voices[i+2].vc_SetPan = ht->ht_defpanright; // 1.4
331 ht->ht_Voices[i+2].vc_PanMultLeft = panning_left[ht->ht_defpanright];
332 ht->ht_Voices[i+2].vc_PanMultRight = panning_right[ht->ht_defpanright];
333 ht->ht_Voices[i+3].vc_Pan = ht->ht_defpanleft;
334 ht->ht_Voices[i+3].vc_SetPan = ht->ht_defpanleft; // 1.4
335 ht->ht_Voices[i+3].vc_PanMultLeft = panning_left[ht->ht_defpanleft];
336 ht->ht_Voices[i+3].vc_PanMultRight = panning_right[ht->ht_defpanleft];
339 hvl_reset_some_stuff( ht );
344 void hvl_InitReplayer( void )
346 hvl_GenPanningTables();
347 hvl_GenSawtooth( &waves[WO_SAWTOOTH_04], 0x04 );
348 hvl_GenSawtooth( &waves[WO_SAWTOOTH_08], 0x08 );
349 hvl_GenSawtooth( &waves[WO_SAWTOOTH_10], 0x10 );
350 hvl_GenSawtooth( &waves[WO_SAWTOOTH_20], 0x20 );
351 hvl_GenSawtooth( &waves[WO_SAWTOOTH_40], 0x40 );
352 hvl_GenSawtooth( &waves[WO_SAWTOOTH_80], 0x80 );
353 hvl_GenTriangle( &waves[WO_TRIANGLE_04], 0x04 );
354 hvl_GenTriangle( &waves[WO_TRIANGLE_08], 0x08 );
355 hvl_GenTriangle( &waves[WO_TRIANGLE_10], 0x10 );
356 hvl_GenTriangle( &waves[WO_TRIANGLE_20], 0x20 );
357 hvl_GenTriangle( &waves[WO_TRIANGLE_40], 0x40 );
358 hvl_GenTriangle( &waves[WO_TRIANGLE_80], 0x80 );
359 hvl_GenSquare( &waves[WO_SQUARES] );
360 hvl_GenWhiteNoise( &waves[WO_WHITENOISE], WHITENOISELEN );
361 hvl_GenFilterWaves( &waves[WO_TRIANGLE_04], &waves[WO_LOWPASSES], &waves[WO_HIGHPASSES] );
364 struct hvl_tune *hvl_load_ahx( uint8 *buf, uint32 buflen, uint32 defstereo, uint32 freq )
368 uint32 i, j, k, l, posn, insn, ssn, hs, trkn, trkl;
370 struct hvl_plsentry *ple;
371 int32 defgain[] = { 71, 72, 76, 85, 100 };
373 posn = ((buf[6]&0x0f)<<8)|buf[7];
379 hs = sizeof( struct hvl_tune );
380 hs += sizeof( struct hvl_position ) * posn;
381 hs += sizeof( struct hvl_instrument ) * (insn+1);
382 hs += sizeof( uint16 ) * ssn;
384 // Calculate the size of all instrument PList buffers
386 bptr += ssn*2; // Skip past the subsong list
387 bptr += posn*4*2; // Skip past the positions
389 if((buf[6]&0x80)==0) bptr += trkl*3;
391 // *NOW* we can finally calculate PList space
392 for( i=1; i<=insn; i++ )
394 hs += bptr[21] * sizeof( struct hvl_plsentry );
395 bptr += 22 + bptr[21]*4;
398 ht = malloc(hs); //AllocVec( hs, MEMF_ANY );
402 printf( "Out of memory!\n" );
406 ht->ht_Frequency = freq;
407 ht->ht_FreqF = (float64)freq;
409 ht->ht_Positions = (struct hvl_position *)(&ht[1]);
410 ht->ht_Instruments = (struct hvl_instrument *)(&ht->ht_Positions[posn]);
411 ht->ht_Subsongs = (uint16 *)(&ht->ht_Instruments[(insn+1)]);
412 ple = (struct hvl_plsentry *)(&ht->ht_Subsongs[ssn]);
414 ht->ht_WaveformTab[0] = &waves[WO_TRIANGLE_04];
415 ht->ht_WaveformTab[1] = &waves[WO_SAWTOOTH_04];
416 ht->ht_WaveformTab[3] = &waves[WO_WHITENOISE];
419 ht->ht_PositionNr = posn;
420 ht->ht_Restart = (buf[8]<<8)|buf[9];
421 ht->ht_SpeedMultiplier = ((buf[6]>>5)&3)+1;
422 ht->ht_TrackLength = trkl;
423 ht->ht_TrackNr = trkn;
424 ht->ht_InstrumentNr = insn;
425 ht->ht_SubsongNr = ssn;
426 ht->ht_defstereo = defstereo;
427 ht->ht_defpanleft = stereopan_left[ht->ht_defstereo];
428 ht->ht_defpanright = stereopan_right[ht->ht_defstereo];
429 ht->ht_mixgain = (defgain[ht->ht_defstereo]*256)/100;
431 if( ht->ht_Restart >= ht->ht_PositionNr )
432 ht->ht_Restart = ht->ht_PositionNr-1;
434 // Do some validation
435 if( ( ht->ht_PositionNr > 1000 ) ||
436 ( ht->ht_TrackLength > 64 ) ||
437 ( ht->ht_InstrumentNr > 64 ) )
439 printf( "%d,%d,%d\n", ht->ht_PositionNr,
441 ht->ht_InstrumentNr );
444 printf( "Invalid file.\n" );
448 strncpy( ht->ht_Name, (TEXT *)&buf[(buf[4]<<8)|buf[5]], 128 );
449 nptr = (TEXT *)&buf[((buf[4]<<8)|buf[5])+strlen( ht->ht_Name )+1];
454 for( i=0; i<ht->ht_SubsongNr; i++ )
456 ht->ht_Subsongs[i] = (bptr[0]<<8)|bptr[1];
457 if( ht->ht_Subsongs[i] >= ht->ht_PositionNr )
458 ht->ht_Subsongs[i] = 0;
463 for( i=0; i<ht->ht_PositionNr; i++ )
467 ht->ht_Positions[i].pos_Track[j] = *bptr++;
468 ht->ht_Positions[i].pos_Transpose[j] = *(int8 *)bptr++;
473 for( i=0; i<=ht->ht_TrackNr; i++ )
475 if( ( ( buf[6]&0x80 ) == 0x80 ) && ( i == 0 ) )
477 for( j=0; j<ht->ht_TrackLength; j++ )
479 ht->ht_Tracks[i][j].stp_Note = 0;
480 ht->ht_Tracks[i][j].stp_Instrument = 0;
481 ht->ht_Tracks[i][j].stp_FX = 0;
482 ht->ht_Tracks[i][j].stp_FXParam = 0;
483 ht->ht_Tracks[i][j].stp_FXb = 0;
484 ht->ht_Tracks[i][j].stp_FXbParam = 0;
489 for( j=0; j<ht->ht_TrackLength; j++ )
491 ht->ht_Tracks[i][j].stp_Note = (bptr[0]>>2)&0x3f;
492 ht->ht_Tracks[i][j].stp_Instrument = ((bptr[0]&0x3)<<4) | (bptr[1]>>4);
493 ht->ht_Tracks[i][j].stp_FX = bptr[1]&0xf;
494 ht->ht_Tracks[i][j].stp_FXParam = bptr[2];
495 ht->ht_Tracks[i][j].stp_FXb = 0;
496 ht->ht_Tracks[i][j].stp_FXbParam = 0;
502 for( i=1; i<=ht->ht_InstrumentNr; i++ )
504 if( nptr < (TEXT *)(buf+buflen) )
506 strncpy( ht->ht_Instruments[i].ins_Name, nptr, 128 );
507 nptr += strlen( nptr )+1;
509 ht->ht_Instruments[i].ins_Name[0] = 0;
512 ht->ht_Instruments[i].ins_Volume = bptr[0];
513 ht->ht_Instruments[i].ins_FilterSpeed = ((bptr[1]>>3)&0x1f)|((bptr[12]>>2)&0x20);
514 ht->ht_Instruments[i].ins_WaveLength = bptr[1]&0x07;
516 ht->ht_Instruments[i].ins_Envelope.aFrames = bptr[2];
517 ht->ht_Instruments[i].ins_Envelope.aVolume = bptr[3];
518 ht->ht_Instruments[i].ins_Envelope.dFrames = bptr[4];
519 ht->ht_Instruments[i].ins_Envelope.dVolume = bptr[5];
520 ht->ht_Instruments[i].ins_Envelope.sFrames = bptr[6];
521 ht->ht_Instruments[i].ins_Envelope.rFrames = bptr[7];
522 ht->ht_Instruments[i].ins_Envelope.rVolume = bptr[8];
524 ht->ht_Instruments[i].ins_FilterLowerLimit = bptr[12]&0x7f;
525 ht->ht_Instruments[i].ins_VibratoDelay = bptr[13];
526 ht->ht_Instruments[i].ins_HardCutReleaseFrames = (bptr[14]>>4)&0x07;
527 ht->ht_Instruments[i].ins_HardCutRelease = bptr[14]&0x80?1:0;
528 ht->ht_Instruments[i].ins_VibratoDepth = bptr[14]&0x0f;
529 ht->ht_Instruments[i].ins_VibratoSpeed = bptr[15];
530 ht->ht_Instruments[i].ins_SquareLowerLimit = bptr[16];
531 ht->ht_Instruments[i].ins_SquareUpperLimit = bptr[17];
532 ht->ht_Instruments[i].ins_SquareSpeed = bptr[18];
533 ht->ht_Instruments[i].ins_FilterUpperLimit = bptr[19]&0x3f;
534 ht->ht_Instruments[i].ins_PList.pls_Speed = bptr[20];
535 ht->ht_Instruments[i].ins_PList.pls_Length = bptr[21];
537 ht->ht_Instruments[i].ins_PList.pls_Entries = ple;
541 for( j=0; j<ht->ht_Instruments[i].ins_PList.pls_Length; j++ )
549 ht->ht_Instruments[i].ins_PList.pls_Entries[j].ple_FX[1] = k;
550 ht->ht_Instruments[i].ins_PList.pls_Entries[j].ple_FX[0] = l;
551 ht->ht_Instruments[i].ins_PList.pls_Entries[j].ple_Waveform = ((bptr[0]<<1)&6) | (bptr[1]>>7);
552 ht->ht_Instruments[i].ins_PList.pls_Entries[j].ple_Fixed = (bptr[1]>>6)&1;
553 ht->ht_Instruments[i].ins_PList.pls_Entries[j].ple_Note = bptr[1]&0x3f;
554 ht->ht_Instruments[i].ins_PList.pls_Entries[j].ple_FXParam[0] = bptr[2];
555 ht->ht_Instruments[i].ins_PList.pls_Entries[j].ple_FXParam[1] = bptr[3];
560 hvl_InitSubsong( ht, 0 );
565 struct hvl_tune *hvl_LoadTune( TEXT *name, uint32 freq, uint32 defstereo )
570 uint32 buflen, i, j, posn, insn, ssn, chnn, hs, trkl, trkn;
572 //struct FileInfoBlock *fib;
573 struct hvl_plsentry *ple;
576 //fib = AllocDosObjectTags( DOS_FIB, TAG_DONE );
577 f = fopen( name, "rb" );
580 printf( "Cannot open file\n" );
583 fseek( f, 0, SEEK_END );
586 buf = malloc( buflen );
590 printf( "Out of memory!\n" );
594 if( fread( buf, 1, buflen, f ) != buflen )
598 printf( "Unable to read from file!\n" );
605 if( ( buf[0] == 'T' ) &&
609 return hvl_load_ahx( buf, buflen, defstereo, freq );
611 if( ( buf[0] != 'H' ) ||
617 printf( "Invalid file.\n" );
621 posn = ((buf[6]&0x0f)<<8)|buf[7];
624 chnn = (buf[8]>>2)+4;
628 hs = sizeof( struct hvl_tune );
629 hs += sizeof( struct hvl_position ) * posn;
630 hs += sizeof( struct hvl_instrument ) * (insn+1);
631 hs += sizeof( uint16 ) * ssn;
633 // Calculate the size of all instrument PList buffers
635 bptr += ssn*2; // Skip past the subsong list
636 bptr += posn*chnn*2; // Skip past the positions
638 // Skip past the tracks
639 // 1.4: Fixed two really stupid bugs that cancelled each other
640 // out if the module had a blank first track (which is how
641 // come they were missed.
642 for( i=((buf[6]&0x80)==0x80)?1:0; i<=trkn; i++ )
643 for( j=0; j<trkl; j++ )
645 if( bptr[0] == 0x3f )
653 // *NOW* we can finally calculate PList space
654 for( i=1; i<=insn; i++ )
656 hs += bptr[21] * sizeof( struct hvl_plsentry );
657 bptr += 22 + bptr[21]*5;
660 ht = malloc(hs); // AllocVec( hs, MEMF_ANY );
664 printf( "Out of memory!\n" );
668 ht->ht_Frequency = freq;
669 ht->ht_FreqF = (float64)freq;
671 ht->ht_Positions = (struct hvl_position *)(&ht[1]);
672 ht->ht_Instruments = (struct hvl_instrument *)(&ht->ht_Positions[posn]);
673 ht->ht_Subsongs = (uint16 *)(&ht->ht_Instruments[(insn+1)]);
674 ple = (struct hvl_plsentry *)(&ht->ht_Subsongs[ssn]);
676 ht->ht_WaveformTab[0] = &waves[WO_TRIANGLE_04];
677 ht->ht_WaveformTab[1] = &waves[WO_SAWTOOTH_04];
678 ht->ht_WaveformTab[3] = &waves[WO_WHITENOISE];
680 ht->ht_PositionNr = posn;
681 ht->ht_Channels = (buf[8]>>2)+4;
682 ht->ht_Restart = ((buf[8]&3)<<8)|buf[9];
683 ht->ht_SpeedMultiplier = ((buf[6]>>5)&3)+1;
684 ht->ht_TrackLength = buf[10];
685 ht->ht_TrackNr = buf[11];
686 ht->ht_InstrumentNr = insn;
687 ht->ht_SubsongNr = ssn;
688 ht->ht_mixgain = (buf[14]<<8)/100;
689 ht->ht_defstereo = buf[15];
690 ht->ht_defpanleft = stereopan_left[ht->ht_defstereo];
691 ht->ht_defpanright = stereopan_right[ht->ht_defstereo];
693 if( ht->ht_Restart >= ht->ht_PositionNr )
694 ht->ht_Restart = ht->ht_PositionNr-1;
696 // Do some validation
697 if( ( ht->ht_PositionNr > 1000 ) ||
698 ( ht->ht_TrackLength > 64 ) ||
699 ( ht->ht_InstrumentNr > 64 ) )
701 printf( "%d,%d,%d\n", ht->ht_PositionNr,
703 ht->ht_InstrumentNr );
706 printf( "Invalid file.\n" );
710 strncpy( ht->ht_Name, (TEXT *)&buf[(buf[4]<<8)|buf[5]], 128 );
711 nptr = (TEXT *)&buf[((buf[4]<<8)|buf[5])+strlen( ht->ht_Name )+1];
716 for( i=0; i<ht->ht_SubsongNr; i++ )
718 ht->ht_Subsongs[i] = (bptr[0]<<8)|bptr[1];
723 for( i=0; i<ht->ht_PositionNr; i++ )
725 for( j=0; j<ht->ht_Channels; j++ )
727 ht->ht_Positions[i].pos_Track[j] = *bptr++;
728 ht->ht_Positions[i].pos_Transpose[j] = *(int8 *)bptr++;
733 for( i=0; i<=ht->ht_TrackNr; i++ )
735 if( ( ( buf[6]&0x80 ) == 0x80 ) && ( i == 0 ) )
737 for( j=0; j<ht->ht_TrackLength; j++ )
739 ht->ht_Tracks[i][j].stp_Note = 0;
740 ht->ht_Tracks[i][j].stp_Instrument = 0;
741 ht->ht_Tracks[i][j].stp_FX = 0;
742 ht->ht_Tracks[i][j].stp_FXParam = 0;
743 ht->ht_Tracks[i][j].stp_FXb = 0;
744 ht->ht_Tracks[i][j].stp_FXbParam = 0;
749 for( j=0; j<ht->ht_TrackLength; j++ )
751 if( bptr[0] == 0x3f )
753 ht->ht_Tracks[i][j].stp_Note = 0;
754 ht->ht_Tracks[i][j].stp_Instrument = 0;
755 ht->ht_Tracks[i][j].stp_FX = 0;
756 ht->ht_Tracks[i][j].stp_FXParam = 0;
757 ht->ht_Tracks[i][j].stp_FXb = 0;
758 ht->ht_Tracks[i][j].stp_FXbParam = 0;
763 ht->ht_Tracks[i][j].stp_Note = bptr[0];
764 ht->ht_Tracks[i][j].stp_Instrument = bptr[1];
765 ht->ht_Tracks[i][j].stp_FX = bptr[2]>>4;
766 ht->ht_Tracks[i][j].stp_FXParam = bptr[3];
767 ht->ht_Tracks[i][j].stp_FXb = bptr[2]&0xf;
768 ht->ht_Tracks[i][j].stp_FXbParam = bptr[4];
775 for( i=1; i<=ht->ht_InstrumentNr; i++ )
777 if( nptr < (TEXT *)(buf+buflen) )
779 strncpy( ht->ht_Instruments[i].ins_Name, nptr, 128 );
780 nptr += strlen( nptr )+1;
782 ht->ht_Instruments[i].ins_Name[0] = 0;
784 ht->ht_Instruments[i].ins_Volume = bptr[0];
785 ht->ht_Instruments[i].ins_FilterSpeed = ((bptr[1]>>3)&0x1f)|((bptr[12]>>2)&0x20);
786 ht->ht_Instruments[i].ins_WaveLength = bptr[1]&0x07;
788 ht->ht_Instruments[i].ins_Envelope.aFrames = bptr[2];
789 ht->ht_Instruments[i].ins_Envelope.aVolume = bptr[3];
790 ht->ht_Instruments[i].ins_Envelope.dFrames = bptr[4];
791 ht->ht_Instruments[i].ins_Envelope.dVolume = bptr[5];
792 ht->ht_Instruments[i].ins_Envelope.sFrames = bptr[6];
793 ht->ht_Instruments[i].ins_Envelope.rFrames = bptr[7];
794 ht->ht_Instruments[i].ins_Envelope.rVolume = bptr[8];
796 ht->ht_Instruments[i].ins_FilterLowerLimit = bptr[12]&0x7f;
797 ht->ht_Instruments[i].ins_VibratoDelay = bptr[13];
798 ht->ht_Instruments[i].ins_HardCutReleaseFrames = (bptr[14]>>4)&0x07;
799 ht->ht_Instruments[i].ins_HardCutRelease = bptr[14]&0x80?1:0;
800 ht->ht_Instruments[i].ins_VibratoDepth = bptr[14]&0x0f;
801 ht->ht_Instruments[i].ins_VibratoSpeed = bptr[15];
802 ht->ht_Instruments[i].ins_SquareLowerLimit = bptr[16];
803 ht->ht_Instruments[i].ins_SquareUpperLimit = bptr[17];
804 ht->ht_Instruments[i].ins_SquareSpeed = bptr[18];
805 ht->ht_Instruments[i].ins_FilterUpperLimit = bptr[19]&0x3f;
806 ht->ht_Instruments[i].ins_PList.pls_Speed = bptr[20];
807 ht->ht_Instruments[i].ins_PList.pls_Length = bptr[21];
809 ht->ht_Instruments[i].ins_PList.pls_Entries = ple;
813 for( j=0; j<ht->ht_Instruments[i].ins_PList.pls_Length; j++ )
815 ht->ht_Instruments[i].ins_PList.pls_Entries[j].ple_FX[0] = bptr[0]&0xf;
816 ht->ht_Instruments[i].ins_PList.pls_Entries[j].ple_FX[1] = (bptr[1]>>3)&0xf;
817 ht->ht_Instruments[i].ins_PList.pls_Entries[j].ple_Waveform = bptr[1]&7;
818 ht->ht_Instruments[i].ins_PList.pls_Entries[j].ple_Fixed = (bptr[2]>>6)&1;
819 ht->ht_Instruments[i].ins_PList.pls_Entries[j].ple_Note = bptr[2]&0x3f;
820 ht->ht_Instruments[i].ins_PList.pls_Entries[j].ple_FXParam[0] = bptr[3];
821 ht->ht_Instruments[i].ins_PList.pls_Entries[j].ple_FXParam[1] = bptr[4];
826 hvl_InitSubsong( ht, 0 );
831 void hvl_FreeTune( struct hvl_tune *ht )
837 void hvl_process_stepfx_1( struct hvl_tune *ht, struct hvl_voice *voice, int32 FX, int32 FXParam )
841 case 0x0: // Position Jump HI
842 if( ((FXParam&0x0f) > 0) && ((FXParam&0x0f) <= 9) )
843 ht->ht_PosJump = FXParam & 0xf;
846 case 0x5: // Volume Slide + Tone Portamento
847 case 0xa: // Volume Slide
848 voice->vc_VolumeSlideDown = FXParam & 0x0f;
849 voice->vc_VolumeSlideUp = FXParam >> 4;
855 voice->vc_Pan = (FXParam+128);
856 voice->vc_SetPan = (FXParam+128); // 1.4
857 voice->vc_PanMultLeft = panning_left[voice->vc_Pan];
858 voice->vc_PanMultRight = panning_right[voice->vc_Pan];
861 case 0xb: // Position jump
862 ht->ht_PosJump = ht->ht_PosJump*100 + (FXParam & 0x0f) + (FXParam >> 4)*10;
863 ht->ht_PatternBreak = 1;
864 if( ht->ht_PosJump <= ht->ht_PosNr )
865 ht->ht_SongEndReached = 1;
868 case 0xd: // Pattern break
869 ht->ht_PosJump = ht->ht_PosNr+1;
870 ht->ht_PosJumpNote = (FXParam & 0x0f) + (FXParam>>4)*10;
871 ht->ht_PatternBreak = 1;
872 if( ht->ht_PosJumpNote > ht->ht_TrackLength )
873 ht->ht_PosJumpNote = 0;
876 case 0xe: // Extended commands
877 switch( FXParam >> 4 )
879 case 0xc: // Note cut
880 if( (FXParam & 0x0f) < ht->ht_Tempo )
882 voice->vc_NoteCutWait = FXParam & 0x0f;
883 if( voice->vc_NoteCutWait )
885 voice->vc_NoteCutOn = 1;
886 voice->vc_HardCutRelease = 0;
890 case 0xd: // Note delay
891 if( voice->vc_NoteDelayOn )
893 voice->vc_NoteDelayOn = 0;
895 if( (FXParam & 0x0f) < ht->ht_Tempo )
897 voice->vc_NoteDelayWait = FXParam & 0x0f;
898 if( voice->vc_NoteDelayWait )
900 voice->vc_NoteDelayOn = 1;
910 ht->ht_Tempo = FXParam;
912 ht->ht_SongEndReached = 1;
917 void hvl_process_stepfx_2( struct hvl_tune *ht, struct hvl_voice *voice, int32 FX, int32 FXParam, int32 *Note )
921 case 0x9: // Set squarewave offset
922 voice->vc_SquarePos = FXParam >> (5 - voice->vc_WaveLength);
923 voice->vc_PlantSquare = 1;
924 voice->vc_IgnoreSquare = 1;
927 case 0x5: // Tone portamento + volume slide
928 case 0x3: // Tone portamento
929 if( FXParam != 0 ) voice->vc_PeriodSlideSpeed = FXParam;
935 new = period_tab[*Note];
936 diff = period_tab[voice->vc_TrackPeriod];
938 new = diff + voice->vc_PeriodSlidePeriod;
941 voice->vc_PeriodSlideLimit = -diff;
943 voice->vc_PeriodSlideOn = 1;
944 voice->vc_PeriodSlideWithLimit = 1;
950 void hvl_process_stepfx_3( struct hvl_tune *ht, struct hvl_voice *voice, int32 FX, int32 FXParam )
956 case 0x01: // Portamento up (period slide down)
957 voice->vc_PeriodSlideSpeed = -FXParam;
958 voice->vc_PeriodSlideOn = 1;
959 voice->vc_PeriodSlideWithLimit = 0;
961 case 0x02: // Portamento down
962 voice->vc_PeriodSlideSpeed = FXParam;
963 voice->vc_PeriodSlideOn = 1;
964 voice->vc_PeriodSlideWithLimit = 0;
966 case 0x04: // Filter override
967 if( ( FXParam == 0 ) || ( FXParam == 0x40 ) ) break;
970 voice->vc_IgnoreFilter = FXParam;
973 if( FXParam > 0x7f ) break;
974 voice->vc_FilterPos = FXParam - 0x40;
978 if( FXParam <= 0x40 )
980 voice->vc_NoteMaxVolume = FXParam;
985 if( FXParam <= 0x40 )
987 for( i=0; i<ht->ht_Channels; i++ )
988 ht->ht_Voices[i].vc_TrackMasterVolume = FXParam;
992 FXParam -= 0xa0-0x50;
993 if( FXParam <= 0x40 )
994 voice->vc_TrackMasterVolume = FXParam;
997 case 0xe: // Extended commands;
998 switch( FXParam >> 4 )
1000 case 0x1: // Fineslide up
1001 voice->vc_PeriodSlidePeriod = -(FXParam & 0x0f);
1002 voice->vc_PlantPeriod = 1;
1005 case 0x2: // Fineslide down
1006 voice->vc_PeriodSlidePeriod = (FXParam & 0x0f);
1007 voice->vc_PlantPeriod = 1;
1010 case 0x4: // Vibrato control
1011 voice->vc_VibratoDepth = FXParam & 0x0f;
1014 case 0x0a: // Fine volume up
1015 voice->vc_NoteMaxVolume += FXParam & 0x0f;
1017 if( voice->vc_NoteMaxVolume > 0x40 )
1018 voice->vc_NoteMaxVolume = 0x40;
1021 case 0x0b: // Fine volume down
1022 voice->vc_NoteMaxVolume -= FXParam & 0x0f;
1024 if( voice->vc_NoteMaxVolume < 0 )
1025 voice->vc_NoteMaxVolume = 0;
1032 void hvl_process_step( struct hvl_tune *ht, struct hvl_voice *voice )
1035 struct hvl_step *Step;
1037 if( voice->vc_TrackOn == 0 )
1040 voice->vc_VolumeSlideUp = voice->vc_VolumeSlideDown = 0;
1042 Step = &ht->ht_Tracks[ht->ht_Positions[ht->ht_PosNr].pos_Track[voice->vc_VoiceNum]][ht->ht_NoteNr];
1044 //Note = Step->stp_Note;
1046 //Instr = Step->stp_Instrument;
1048 //hvl_process_stepfx_1( ht, voice, Step->stp_FX&0xf, Step->stp_FXParam );
1049 //hvl_process_stepfx_1( ht, voice, Step->stp_FXb&0xf, Step->stp_FXbParam );
1051 if( ( Instr ) && ( Instr <= ht->ht_InstrumentNr ) )
1053 struct hvl_instrument *Ins;
1054 int16 SquareLower, SquareUpper, d6, d3, d4;
1056 /* 1.4: Reset panning to last set position */
1057 voice->vc_Pan = voice->vc_SetPan;
1058 voice->vc_PanMultLeft = panning_left[voice->vc_Pan];
1059 voice->vc_PanMultRight = panning_right[voice->vc_Pan];
1061 voice->vc_PeriodSlideSpeed = voice->vc_PeriodSlidePeriod = voice->vc_PeriodSlideLimit = 0;
1063 voice->vc_PerfSubVolume = 0x40;
1064 voice->vc_ADSRVolume = 0;
1065 voice->vc_Instrument = Ins = &ht->ht_Instruments[Instr];
1066 voice->vc_SamplePos = 0;
1068 voice->vc_ADSR.aFrames = Ins->ins_Envelope.aFrames;
1069 voice->vc_ADSR.aVolume = Ins->ins_Envelope.aVolume*256/voice->vc_ADSR.aFrames;
1070 voice->vc_ADSR.dFrames = Ins->ins_Envelope.dFrames;
1071 voice->vc_ADSR.dVolume = (Ins->ins_Envelope.dVolume-Ins->ins_Envelope.aVolume)*256/voice->vc_ADSR.dFrames;
1072 voice->vc_ADSR.sFrames = Ins->ins_Envelope.sFrames;
1073 voice->vc_ADSR.rFrames = Ins->ins_Envelope.rFrames;
1074 voice->vc_ADSR.rVolume = (Ins->ins_Envelope.rVolume-Ins->ins_Envelope.dVolume)*256/voice->vc_ADSR.rFrames;
1076 voice->vc_WaveLength = Ins->ins_WaveLength;
1077 voice->vc_NoteMaxVolume = Ins->ins_Volume;
1079 voice->vc_VibratoCurrent = 0;
1080 voice->vc_VibratoDelay = Ins->ins_VibratoDelay;
1081 voice->vc_VibratoDepth = Ins->ins_VibratoDepth;
1082 voice->vc_VibratoSpeed = Ins->ins_VibratoSpeed;
1083 voice->vc_VibratoPeriod = 0;
1085 voice->vc_HardCutRelease = Ins->ins_HardCutRelease;
1086 voice->vc_HardCut = Ins->ins_HardCutReleaseFrames;
1088 voice->vc_IgnoreSquare = voice->vc_SquareSlidingIn = 0;
1089 voice->vc_SquareWait = voice->vc_SquareOn = 0;
1091 SquareLower = Ins->ins_SquareLowerLimit >> (5 - voice->vc_WaveLength);
1092 SquareUpper = Ins->ins_SquareUpperLimit >> (5 - voice->vc_WaveLength);
1094 if( SquareUpper < SquareLower )
1096 int16 t = SquareUpper;
1097 SquareUpper = SquareLower;
1101 voice->vc_SquareUpperLimit = SquareUpper;
1102 voice->vc_SquareLowerLimit = SquareLower;
1104 //voice->vc_IgnoreFilter = voice->vc_FilterWait = voice->vc_FilterOn = 0;
1105 //voice->vc_FilterSlidingIn = 0;
1107 d6 = Ins->ins_FilterSpeed;
1108 d3 = Ins->ins_FilterLowerLimit;
1109 d4 = Ins->ins_FilterUpperLimit;
1111 if( d3 & 0x80 ) d6 |= 0x20;
1112 if( d4 & 0x80 ) d6 |= 0x40;
1114 voice->vc_FilterSpeed = d6;
1125 voice->vc_FilterUpperLimit = d4;
1126 voice->vc_FilterLowerLimit = d3;
1127 voice->vc_FilterPos = 32;
1129 voice->vc_PerfWait = voice->vc_PerfCurrent = 0;
1130 voice->vc_PerfSpeed = Ins->ins_PList.pls_Speed;
1131 voice->vc_PerfList = &voice->vc_Instrument->ins_PList;
1133 voice->vc_RingMixSource = NULL; // No ring modulation
1134 voice->vc_RingSamplePos = 0;
1135 voice->vc_RingPlantPeriod = 0;
1136 voice->vc_RingNewWaveform = 0;
1139 //voice->vc_PeriodSlideOn = 0;
1141 //hvl_process_stepfx_2( ht, voice, Step->stp_FX&0xf, Step->stp_FXParam, &Note );
1142 //hvl_process_stepfx_2( ht, voice, Step->stp_FXb&0xf, Step->stp_FXbParam, &Note );
1146 voice->vc_TrackPeriod = Note;
1147 voice->vc_PlantPeriod = 1;
1150 //hvl_process_stepfx_3( ht, voice, Step->stp_FX&0xf, Step->stp_FXParam );
1151 //hvl_process_stepfx_3( ht, voice, Step->stp_FXb&0xf, Step->stp_FXbParam );
1154 void hvl_plist_command_parse( struct hvl_tune *ht, struct hvl_voice *voice, int32 FX, int32 FXParam )
1159 if( ( FXParam > 0 ) && ( FXParam < 0x40 ) )
1161 if( voice->vc_IgnoreFilter )
1163 voice->vc_FilterPos = voice->vc_IgnoreFilter;
1164 voice->vc_IgnoreFilter = 0;
1166 voice->vc_FilterPos = FXParam;
1168 voice->vc_NewWaveform = 1;
1173 voice->vc_PeriodPerfSlideSpeed = FXParam;
1174 voice->vc_PeriodPerfSlideOn = 1;
1178 voice->vc_PeriodPerfSlideSpeed = -FXParam;
1179 voice->vc_PeriodPerfSlideOn = 1;
1183 if( voice->vc_IgnoreSquare == 0 )
1184 voice->vc_SquarePos = FXParam >> (5-voice->vc_WaveLength);
1186 voice->vc_IgnoreSquare = 0;
1192 voice->vc_SquareInit = (voice->vc_SquareOn ^= 1);
1193 voice->vc_SquareSign = 1;
1196 if( FXParam & 0x0f )
1198 voice->vc_SquareInit = (voice->vc_SquareOn ^= 1);
1199 voice->vc_SquareSign = 1;
1200 if(( FXParam & 0x0f ) == 0x0f )
1201 voice->vc_SquareSign = -1;
1204 if( FXParam & 0xf0 )
1206 voice->vc_FilterInit = (voice->vc_FilterOn ^= 1);
1207 voice->vc_FilterSign = 1;
1208 if(( FXParam & 0xf0 ) == 0xf0 )
1209 voice->vc_FilterSign = -1;
1215 voice->vc_PerfCurrent = FXParam;
1219 // Ring modulate with triangle
1220 if(( FXParam >= 1 ) && ( FXParam <= 0x3C ))
1222 voice->vc_RingBasePeriod = FXParam;
1223 voice->vc_RingFixedPeriod = 1;
1224 } else if(( FXParam >= 0x81 ) && ( FXParam <= 0xBC )) {
1225 voice->vc_RingBasePeriod = FXParam-0x80;
1226 voice->vc_RingFixedPeriod = 0;
1228 voice->vc_RingBasePeriod = 0;
1229 voice->vc_RingFixedPeriod = 0;
1230 voice->vc_RingNewWaveform = 0;
1231 voice->vc_RingAudioSource = NULL; // turn it off
1232 voice->vc_RingMixSource = NULL;
1235 voice->vc_RingWaveform = 0;
1236 voice->vc_RingNewWaveform = 1;
1237 voice->vc_RingPlantPeriod = 1;
1240 case 8: // Ring modulate with sawtooth
1241 if(( FXParam >= 1 ) && ( FXParam <= 0x3C ))
1243 voice->vc_RingBasePeriod = FXParam;
1244 voice->vc_RingFixedPeriod = 1;
1245 } else if(( FXParam >= 0x81 ) && ( FXParam <= 0xBC )) {
1246 voice->vc_RingBasePeriod = FXParam-0x80;
1247 voice->vc_RingFixedPeriod = 0;
1249 voice->vc_RingBasePeriod = 0;
1250 voice->vc_RingFixedPeriod = 0;
1251 voice->vc_RingNewWaveform = 0;
1252 voice->vc_RingAudioSource = NULL;
1253 voice->vc_RingMixSource = NULL;
1257 voice->vc_RingWaveform = 1;
1258 voice->vc_RingNewWaveform = 1;
1259 voice->vc_RingPlantPeriod = 1;
1262 /* New in HivelyTracker 1.4 */
1266 voice->vc_Pan = (FXParam+128);
1267 voice->vc_PanMultLeft = panning_left[voice->vc_Pan];
1268 voice->vc_PanMultRight = panning_right[voice->vc_Pan];
1272 if( FXParam <= 0x40 )
1274 voice->vc_NoteMaxVolume = FXParam;
1278 if( (FXParam -= 0x50) < 0 ) break;
1280 if( FXParam <= 0x40 )
1282 voice->vc_PerfSubVolume = FXParam;
1286 if( (FXParam -= 0xa0-0x50) < 0 ) break;
1288 if( FXParam <= 0x40 )
1289 voice->vc_TrackMasterVolume = FXParam;
1293 voice->vc_PerfSpeed = voice->vc_PerfWait = FXParam;
1298 void hvl_process_frame( struct hvl_tune *ht, struct hvl_voice *voice )
1300 static CONST uint8 Offsets[] = {0x00,0x04,0x04+0x08,0x04+0x08+0x10,0x04+0x08+0x10+0x20,0x04+0x08+0x10+0x20+0x40};
1302 if( voice->vc_TrackOn == 0 )
1305 if( voice->vc_NoteDelayOn )
1307 if( voice->vc_NoteDelayWait <= 0 )
1308 hvl_process_step( ht, voice );
1310 voice->vc_NoteDelayWait--;
1313 if( voice->vc_HardCut )
1317 if( ht->ht_NoteNr+1 < ht->ht_TrackLength )
1318 nextinst = ht->ht_Tracks[voice->vc_Track][ht->ht_NoteNr+1].stp_Instrument;
1320 nextinst = ht->ht_Tracks[voice->vc_NextTrack][0].stp_Instrument;
1326 d1 = ht->ht_Tempo - voice->vc_HardCut;
1328 if( d1 < 0 ) d1 = 0;
1330 if( !voice->vc_NoteCutOn )
1332 voice->vc_NoteCutOn = 1;
1333 voice->vc_NoteCutWait = d1;
1334 voice->vc_HardCutReleaseF = -(d1-ht->ht_Tempo);
1336 voice->vc_HardCut = 0;
1341 if( voice->vc_NoteCutOn )
1343 if( voice->vc_NoteCutWait <= 0 )
1345 voice->vc_NoteCutOn = 0;
1347 if( voice->vc_HardCutRelease )
1349 voice->vc_ADSR.rVolume = -(voice->vc_ADSRVolume - (voice->vc_Instrument->ins_Envelope.rVolume << 8)) / voice->vc_HardCutReleaseF;
1350 voice->vc_ADSR.rFrames = voice->vc_HardCutReleaseF;
1351 voice->vc_ADSR.aFrames = voice->vc_ADSR.dFrames = voice->vc_ADSR.sFrames = 0;
1353 voice->vc_NoteMaxVolume = 0;
1356 voice->vc_NoteCutWait--;
1361 if( voice->vc_ADSR.aFrames )
1363 voice->vc_ADSRVolume += voice->vc_ADSR.aVolume;
1365 if( --voice->vc_ADSR.aFrames <= 0 )
1366 voice->vc_ADSRVolume = voice->vc_Instrument->ins_Envelope.aVolume << 8;
1368 } else if( voice->vc_ADSR.dFrames ) {
1370 voice->vc_ADSRVolume += voice->vc_ADSR.dVolume;
1372 if( --voice->vc_ADSR.dFrames <= 0 )
1373 voice->vc_ADSRVolume = voice->vc_Instrument->ins_Envelope.dVolume << 8;
1375 } else if( voice->vc_ADSR.sFrames ) {
1377 voice->vc_ADSR.sFrames--;
1379 } else if( voice->vc_ADSR.rFrames ) {
1381 voice->vc_ADSRVolume += voice->vc_ADSR.rVolume;
1383 if( --voice->vc_ADSR.rFrames <= 0 )
1384 voice->vc_ADSRVolume = voice->vc_Instrument->ins_Envelope.rVolume << 8;
1388 voice->vc_NoteMaxVolume = voice->vc_NoteMaxVolume + voice->vc_VolumeSlideUp - voice->vc_VolumeSlideDown;
1390 if( voice->vc_NoteMaxVolume < 0 )
1391 voice->vc_NoteMaxVolume = 0;
1392 else if( voice->vc_NoteMaxVolume > 0x40 )
1393 voice->vc_NoteMaxVolume = 0x40;
1396 if( voice->vc_PeriodSlideOn )
1398 if( voice->vc_PeriodSlideWithLimit )
1402 d0 = voice->vc_PeriodSlidePeriod - voice->vc_PeriodSlideLimit;
1403 d2 = voice->vc_PeriodSlideSpeed;
1412 d3 = (d0 + d2) ^ d0;
1415 d0 = voice->vc_PeriodSlidePeriod + d2;
1417 d0 = voice->vc_PeriodSlideLimit;
1419 voice->vc_PeriodSlidePeriod = d0;
1420 voice->vc_PlantPeriod = 1;
1423 voice->vc_PeriodSlidePeriod += voice->vc_PeriodSlideSpeed;
1424 voice->vc_PlantPeriod = 1;
1429 if( voice->vc_VibratoDepth )
1431 if( voice->vc_VibratoDelay <= 0 )
1433 voice->vc_VibratoPeriod = (vib_tab[voice->vc_VibratoCurrent] * voice->vc_VibratoDepth) >> 7;
1434 voice->vc_PlantPeriod = 1;
1435 voice->vc_VibratoCurrent = (voice->vc_VibratoCurrent + voice->vc_VibratoSpeed) & 0x3f;
1437 voice->vc_VibratoDelay--;
1442 if( voice->vc_PerfList != 0 )
1444 if( voice->vc_Instrument && voice->vc_PerfCurrent < voice->vc_Instrument->ins_PList.pls_Length )
1446 if( --voice->vc_PerfWait <= 0 )
1451 cur = voice->vc_PerfCurrent++;
1452 voice->vc_PerfWait = voice->vc_PerfSpeed;
1454 if( voice->vc_PerfList->pls_Entries[cur].ple_Waveform )
1456 voice->vc_Waveform = voice->vc_PerfList->pls_Entries[cur].ple_Waveform-1;
1457 voice->vc_NewWaveform = 1;
1458 voice->vc_PeriodPerfSlideSpeed = voice->vc_PeriodPerfSlidePeriod = 0;
1462 voice->vc_PeriodPerfSlideOn = 0;
1464 for( i=0; i<2; i++ )
1465 hvl_plist_command_parse( ht, voice, voice->vc_PerfList->pls_Entries[cur].ple_FX[i]&0xff, voice->vc_PerfList->pls_Entries[cur].ple_FXParam[i]&0xff );
1468 if( voice->vc_PerfList->pls_Entries[cur].ple_Note )
1470 voice->vc_InstrPeriod = voice->vc_PerfList->pls_Entries[cur].ple_Note;
1471 voice->vc_PlantPeriod = 1;
1472 voice->vc_FixedNote = voice->vc_PerfList->pls_Entries[cur].ple_Fixed;
1476 if( voice->vc_PerfWait )
1477 voice->vc_PerfWait--;
1479 voice->vc_PeriodPerfSlideSpeed = 0;
1484 if( voice->vc_PeriodPerfSlideOn )
1486 voice->vc_PeriodPerfSlidePeriod -= voice->vc_PeriodPerfSlideSpeed;
1488 if( voice->vc_PeriodPerfSlidePeriod )
1489 voice->vc_PlantPeriod = 1;
1492 if( voice->vc_Waveform == 3-1 && voice->vc_SquareOn )
1494 if( --voice->vc_SquareWait <= 0 )
1498 d1 = voice->vc_SquareLowerLimit;
1499 d2 = voice->vc_SquareUpperLimit;
1500 d3 = voice->vc_SquarePos;
1502 if( voice->vc_SquareInit )
1504 voice->vc_SquareInit = 0;
1508 voice->vc_SquareSlidingIn = 1;
1509 voice->vc_SquareSign = 1;
1510 } else if( d3 >= d2 ) {
1511 voice->vc_SquareSlidingIn = 1;
1512 voice->vc_SquareSign = -1;
1517 if( d1 == d3 || d2 == d3 )
1519 if( voice->vc_SquareSlidingIn )
1520 voice->vc_SquareSlidingIn = 0;
1522 voice->vc_SquareSign = -voice->vc_SquareSign;
1525 d3 += voice->vc_SquareSign;
1526 voice->vc_SquarePos = d3;
1527 voice->vc_PlantSquare = 1;
1528 voice->vc_SquareWait = voice->vc_Instrument->ins_SquareSpeed;
1532 if( voice->vc_FilterOn && --voice->vc_FilterWait <= 0 )
1537 d1 = voice->vc_FilterLowerLimit;
1538 d2 = voice->vc_FilterUpperLimit;
1539 d3 = voice->vc_FilterPos;
1541 if( voice->vc_FilterInit )
1543 voice->vc_FilterInit = 0;
1546 voice->vc_FilterSlidingIn = 1;
1547 voice->vc_FilterSign = 1;
1548 } else if( d3 >= d2 ) {
1549 voice->vc_FilterSlidingIn = 1;
1550 voice->vc_FilterSign = -1;
1555 FMax = (voice->vc_FilterSpeed < 3) ? (5-voice->vc_FilterSpeed) : 1;
1557 for( i=0; i<FMax; i++ )
1559 if( ( d1 == d3 ) || ( d2 == d3 ) )
1561 if( voice->vc_FilterSlidingIn )
1562 voice->vc_FilterSlidingIn = 0;
1564 voice->vc_FilterSign = -voice->vc_FilterSign;
1566 d3 += voice->vc_FilterSign;
1569 if( d3 < 1 ) d3 = 1;
1570 if( d3 > 63 ) d3 = 63;
1571 voice->vc_FilterPos = d3;
1572 voice->vc_NewWaveform = 1;
1573 voice->vc_FilterWait = voice->vc_FilterSpeed - 3;
1575 if( voice->vc_FilterWait < 1 )
1576 voice->vc_FilterWait = 1;
1579 if( voice->vc_Waveform == 3-1 || voice->vc_PlantSquare )
1587 SquarePtr = &waves[WO_SQUARES+(voice->vc_FilterPos-0x20)*(0xfc+0xfc+0x80*0x1f+0x80+0x280*3)];
1588 X = voice->vc_SquarePos << (5 - voice->vc_WaveLength);
1593 voice->vc_SquareReverse = 1;
1598 SquarePtr += (X-1) << 7;
1600 Delta = 32 >> voice->vc_WaveLength;
1601 ht->ht_WaveformTab[2] = voice->vc_SquareTempBuffer;
1603 for( i=0; i<(1<<voice->vc_WaveLength)*4; i++ )
1605 voice->vc_SquareTempBuffer[i] = *SquarePtr;
1609 voice->vc_NewWaveform = 1;
1610 voice->vc_Waveform = 3-1;
1611 voice->vc_PlantSquare = 0;
1614 if( voice->vc_Waveform == 4-1 )
1615 voice->vc_NewWaveform = 1;
1617 if( voice->vc_RingNewWaveform )
1621 if( voice->vc_RingWaveform > 1 ) voice->vc_RingWaveform = 1;
1623 rasrc = ht->ht_WaveformTab[voice->vc_RingWaveform];
1624 rasrc += Offsets[voice->vc_WaveLength];
1626 voice->vc_RingAudioSource = rasrc;
1629 if( voice->vc_NewWaveform )
1633 AudioSource = ht->ht_WaveformTab[voice->vc_Waveform];
1635 if( voice->vc_Waveform != 3-1 )
1636 AudioSource += (voice->vc_FilterPos-0x20)*(0xfc+0xfc+0x80*0x1f+0x80+0x280*3);
1638 if( voice->vc_Waveform < 3-1)
1640 // GetWLWaveformlor2
1641 AudioSource += Offsets[voice->vc_WaveLength];
1644 if( voice->vc_Waveform == 4-1 )
1647 AudioSource += ( voice->vc_WNRandom & (2*0x280-1) ) & ~1;
1649 voice->vc_WNRandom += 2239384;
1650 voice->vc_WNRandom = ((((voice->vc_WNRandom >> 8) | (voice->vc_WNRandom << 24)) + 782323) ^ 75) - 6735;
1653 voice->vc_AudioSource = AudioSource;
1656 // Ring modulation period calculation
1657 if( voice->vc_RingAudioSource )
1659 voice->vc_RingAudioPeriod = voice->vc_RingBasePeriod;
1661 if( !(voice->vc_RingFixedPeriod) )
1662 voice->vc_RingAudioPeriod += voice->vc_Transpose + voice->vc_TrackPeriod - 1;
1664 if( voice->vc_RingAudioPeriod > 5*12 )
1665 voice->vc_RingAudioPeriod = 5*12;
1667 if( voice->vc_RingAudioPeriod < 0 )
1668 voice->vc_RingAudioPeriod = 0;
1670 voice->vc_RingAudioPeriod = period_tab[voice->vc_RingAudioPeriod];
1672 if( !(voice->vc_RingFixedPeriod) )
1673 voice->vc_RingAudioPeriod += voice->vc_PeriodSlidePeriod;
1675 voice->vc_RingAudioPeriod += voice->vc_PeriodPerfSlidePeriod + voice->vc_VibratoPeriod;
1677 if( voice->vc_RingAudioPeriod > 0x0d60 )
1678 voice->vc_RingAudioPeriod = 0x0d60;
1680 if( voice->vc_RingAudioPeriod < 0x0071 )
1681 voice->vc_RingAudioPeriod = 0x0071;
1684 // Normal period calculation
1685 voice->vc_AudioPeriod = voice->vc_InstrPeriod;
1687 if( !(voice->vc_FixedNote) )
1688 voice->vc_AudioPeriod += voice->vc_Transpose + voice->vc_TrackPeriod - 1;
1690 if( voice->vc_AudioPeriod > 5*12 )
1691 voice->vc_AudioPeriod = 5*12;
1693 if( voice->vc_AudioPeriod < 0 )
1694 voice->vc_AudioPeriod = 0;
1696 voice->vc_AudioPeriod = period_tab[voice->vc_AudioPeriod];
1698 if( !(voice->vc_FixedNote) )
1699 voice->vc_AudioPeriod += voice->vc_PeriodSlidePeriod;
1701 voice->vc_AudioPeriod += voice->vc_PeriodPerfSlidePeriod + voice->vc_VibratoPeriod;
1703 if( voice->vc_AudioPeriod > 0x0d60 )
1704 voice->vc_AudioPeriod = 0x0d60;
1706 if( voice->vc_AudioPeriod < 0x0071 )
1707 voice->vc_AudioPeriod = 0x0071;
1709 voice->vc_AudioVolume = (((((((voice->vc_ADSRVolume >> 8) * voice->vc_NoteMaxVolume) >> 6) * voice->vc_PerfSubVolume) >> 6) * voice->vc_TrackMasterVolume) >> 6);
1712 void hvl_set_audio( struct hvl_voice *voice, float64 freqf )
1715 if( voice->vc_TrackOn == 0 )
1717 voice->vc_VoiceVolume = 0;
1721 voice->vc_VoiceVolume = voice->vc_AudioVolume;
1723 if( voice->vc_PlantPeriod )
1728 voice->vc_PlantPeriod = 0;
1729 voice->vc_VoicePeriod = voice->vc_AudioPeriod;
1731 freq2 = Period2Freq( voice->vc_AudioPeriod );
1732 delta = (uint32)(freq2 / freqf);
1734 if( delta > (0x280<<16) ) delta -= (0x280<<16);
1735 if( delta == 0 ) delta = 1;
1736 voice->vc_Delta = delta;
1739 if( voice->vc_NewWaveform )
1743 src = voice->vc_AudioSource;
1745 if( voice->vc_Waveform == 4-1 )
1747 //CopyMem((void *)src, &voice->vc_VoiceBuffer[0], 0x280);
1748 memcpy( &voice->vc_VoiceBuffer[0], (void *)src, 0x280);
1750 uint32 i, WaveLoops;
1752 WaveLoops = (1 << (5 - voice->vc_WaveLength)) * 5;
1754 for( i=0; i<WaveLoops; i++ )
1755 //CopyMem((void *)src, &voice->vc_VoiceBuffer[i*4*(1<<voice->vc_WaveLength)], 4*(1<<voice->vc_WaveLength));
1756 memcpy( &voice->vc_VoiceBuffer[i*4*(1<<voice->vc_WaveLength)],
1758 4*(1<<voice->vc_WaveLength));
1761 voice->vc_VoiceBuffer[0x280] = voice->vc_VoiceBuffer[0];
1762 voice->vc_MixSource = voice->vc_VoiceBuffer;
1765 /* Ring Modulation */
1766 if( voice->vc_RingPlantPeriod )
1771 voice->vc_RingPlantPeriod = 0;
1772 freq2 = Period2Freq( voice->vc_RingAudioPeriod );
1773 delta = (uint32)(freq2 / freqf);
1775 if( delta > (0x280<<16) ) delta -= (0x280<<16);
1776 if( delta == 0 ) delta = 1;
1777 voice->vc_RingDelta = delta;
1780 if( voice->vc_RingNewWaveform )
1783 uint32 i, WaveLoops;
1785 src = voice->vc_RingAudioSource;
1787 WaveLoops = (1 << (5 - voice->vc_WaveLength)) * 5;
1789 for( i=0; i<WaveLoops; i++ )
1790 //CopyMem((void *)src, &voice->vc_RingVoiceBuffer[i*4*(1<<voice->vc_WaveLength)], 4*(1<<voice->vc_WaveLength));
1791 memcpy( &voice->vc_RingVoiceBuffer[i*4*(1<<voice->vc_WaveLength)],
1793 4*(1<<voice->vc_WaveLength));
1795 voice->vc_RingVoiceBuffer[0x280] = voice->vc_RingVoiceBuffer[0];
1796 voice->vc_RingMixSource = voice->vc_RingVoiceBuffer;
1800 void hvl_play_irq( struct hvl_tune *ht )
1804 if( ht->ht_StepWaitFrames <= 0 )
1806 if( ht->ht_GetNewPosition )
1808 int32 nextpos = (ht->ht_PosNr+1==ht->ht_PositionNr)?0:(ht->ht_PosNr+1);
1810 for( i=0; i<ht->ht_Channels; i++ )
1812 ht->ht_Voices[i].vc_Track = ht->ht_Positions[ht->ht_PosNr].pos_Track[i];
1813 ht->ht_Voices[i].vc_Transpose = ht->ht_Positions[ht->ht_PosNr].pos_Transpose[i];
1814 ht->ht_Voices[i].vc_NextTrack = ht->ht_Positions[nextpos].pos_Track[i];
1815 ht->ht_Voices[i].vc_NextTranspose = ht->ht_Positions[nextpos].pos_Transpose[i];
1817 ht->ht_GetNewPosition = 0;
1820 for( i=0; i<ht->ht_Channels; i++ )
1821 hvl_process_step( ht, &ht->ht_Voices[i] );
1823 ht->ht_StepWaitFrames = ht->ht_Tempo;
1826 for( i=0; i<ht->ht_Channels; i++ )
1827 hvl_process_frame( ht, &ht->ht_Voices[i] );
1829 ht->ht_PlayingTime++;
1830 if( ht->ht_Tempo > 0 && --ht->ht_StepWaitFrames <= 0 )
1832 if( !ht->ht_PatternBreak )
1835 if( ht->ht_NoteNr >= ht->ht_TrackLength )
1837 ht->ht_PosJump = ht->ht_PosNr+1;
1838 ht->ht_PosJumpNote = 0;
1839 ht->ht_PatternBreak = 1;
1843 if( ht->ht_PatternBreak )
1845 ht->ht_PatternBreak = 0;
1846 ht->ht_PosNr = ht->ht_PosJump;
1847 ht->ht_NoteNr = ht->ht_PosJumpNote;
1848 if( ht->ht_PosNr == ht->ht_PositionNr )
1850 ht->ht_SongEndReached = 1;
1851 ht->ht_PosNr = ht->ht_Restart;
1853 ht->ht_PosJumpNote = 0;
1856 ht->ht_GetNewPosition = 1;
1860 for( i=0; i<ht->ht_Channels; i++ )
1861 hvl_set_audio( &ht->ht_Voices[i], ht->ht_Frequency );
1864 void hvl_mixchunk( struct hvl_tune *ht, uint32 samples, int8 *buf1, int8 *buf2, int32 bufmod )
1866 int8 *src[MAX_CHANNELS];
1867 int8 *rsrc[MAX_CHANNELS];
1868 uint32 delta[MAX_CHANNELS];
1869 uint32 rdelta[MAX_CHANNELS];
1870 int32 vol[MAX_CHANNELS];
1871 uint32 pos[MAX_CHANNELS];
1872 uint32 rpos[MAX_CHANNELS];
1874 int32 panl[MAX_CHANNELS];
1875 int32 panr[MAX_CHANNELS];
1876 // uint32 vu[MAX_CHANNELS];
1878 uint32 i, chans, loops;
1880 chans = ht->ht_Channels;
1881 for( i=0; i<chans; i++ )
1883 delta[i] = ht->ht_Voices[i].vc_Delta;
1884 vol[i] = ht->ht_Voices[i].vc_VoiceVolume;
1885 pos[i] = ht->ht_Voices[i].vc_SamplePos;
1886 src[i] = ht->ht_Voices[i].vc_MixSource;
1887 panl[i] = ht->ht_Voices[i].vc_PanMultLeft;
1888 panr[i] = ht->ht_Voices[i].vc_PanMultRight;
1890 /* Ring Modulation */
1891 rdelta[i]= ht->ht_Voices[i].vc_RingDelta;
1892 rpos[i] = ht->ht_Voices[i].vc_RingSamplePos;
1893 rsrc[i] = ht->ht_Voices[i].vc_RingMixSource;
1901 for( i=0; i<chans; i++ )
1903 if( pos[i] >= (0x280 << 16)) pos[i] -= 0x280<<16;
1904 cnt = ((0x280<<16) - pos[i] - 1) / delta[i] + 1;
1905 if( cnt < loops ) loops = cnt;
1909 if( rpos[i] >= (0x280<<16)) rpos[i] -= 0x280<<16;
1910 cnt = ((0x280<<16) - rpos[i] - 1) / rdelta[i] + 1;
1911 if( cnt < loops ) loops = cnt;
1923 for( i=0; i<chans; i++ )
1927 /* Ring Modulation */
1928 j = ((src[i][pos[i]>>16]*rsrc[i][rpos[i]>>16])>>7)*vol[i];
1929 rpos[i] += rdelta[i];
1931 j = src[i][pos[i]>>16]*vol[i];
1934 // if( abs( j ) > vu[i] ) vu[i] = abs( j );
1936 a += (j * panl[i]) >> 7;
1937 b += (j * panr[i]) >> 7;
1941 a = (a*ht->ht_mixgain)>>8;
1942 b = (b*ht->ht_mixgain)>>8;
1951 } while( loops > 0 );
1952 } while( samples > 0 );
1954 for( i=0; i<chans; i++ )
1956 ht->ht_Voices[i].vc_SamplePos = pos[i];
1957 ht->ht_Voices[i].vc_RingSamplePos = rpos[i];
1958 // ht->ht_Voices[i].vc_VUMeter = vu[i];
1962 /*void hvl_DecodeFrame( struct hvl_tune *ht, int8 *buf1, int8 *buf2, int32 bufmod )
1964 uint32 samples, loops;
1966 samples = ht->ht_Frequency/50/ht->ht_SpeedMultiplier;
1967 loops = ht->ht_SpeedMultiplier;
1972 hvl_mixchunk( ht, samples, buf1, buf2, bufmod );
1973 buf1 += samples * 4;
1974 buf2 += samples * 4;
1979 void hvl_DecodeFrame( struct hvl_tune *ht, int8 *buf1, int8 *buf2, int32 bufmod )
1981 uint32 samples, loops;
1983 samples = ht->ht_Frequency/50/ht->ht_SpeedMultiplier;
1984 loops = ht->ht_SpeedMultiplier;
1990 //if( ht->ht_StepWaitFrames <= 0 )
1992 //if( ht->ht_GetNewPosition )
1994 //int32 nextpos = (ht->ht_PosNr+1==ht->ht_PositionNr)?0:(ht->ht_PosNr+1);
1996 /*for( i=0; i<ht->ht_Channels; i++ )
1998 ht->ht_Voices[i].vc_Track = ht->ht_Positions[ht->ht_PosNr].pos_Track[i];
1999 ht->ht_Voices[i].vc_Transpose = ht->ht_Positions[ht->ht_PosNr].pos_Transpose[i];
2000 ht->ht_Voices[i].vc_NextTrack = ht->ht_Positions[nextpos].pos_Track[i];
2001 ht->ht_Voices[i].vc_NextTranspose = ht->ht_Positions[nextpos].pos_Transpose[i];
2004 // ht->ht_GetNewPosition = 0;
2006 hvl_process_step( ht, &ht->ht_Voices[0] );
2007 //ht->ht_StepWaitFrames = ht->ht_Tempo;
2009 hvl_process_frame( ht, &ht->ht_Voices[0] );
2010 //if( ht->ht_Tempo > 0 && --ht->ht_StepWaitFrames <= 0 )
2012 //if( !ht->ht_PatternBreak )
2016 /*if( ht->ht_NoteNr >= ht->ht_TrackLength )
2018 ht->ht_PosJump = ht->ht_PosNr+1;
2019 ht->ht_PosJumpNote = 0;
2020 ht->ht_PatternBreak = 1;
2025 /*if( ht->ht_PatternBreak )
2027 ht->ht_PatternBreak = 0;
2028 ht->ht_PosNr = ht->ht_PosJump;
2029 ht->ht_NoteNr = ht->ht_PosJumpNote;
2030 if( ht->ht_PosNr == ht->ht_PositionNr )
2032 ht->ht_SongEndReached = 1;
2033 ht->ht_PosNr = ht->ht_Restart;
2035 ht->ht_PosJumpNote = 0;
2038 ht->ht_GetNewPosition = 1;
2042 //hvl_process_step( ht, &ht->ht_Voices[0] );
2043 //hvl_process_frame( ht, &ht->ht_Voices[0] );
2044 hvl_set_audio( &ht->ht_Voices[0], ht->ht_Frequency );
2045 hvl_mixchunk( ht, samples, buf1, buf2, bufmod );
2046 buf1 += samples * 4;
2047 buf2 += samples * 4;
2053 hvl_mixchunk( ht, samples, buf1, buf2, bufmod );
2054 buf1 += samples * 4;
2055 buf2 += samples * 4;