Timing is correct now! Forgot to update samples_per_tick when parsing the 0xf effect.
[pineappletracker.git] / hively / hvl_replay.h
blob674df9d70620959878a73047a8e8f4bb0b854d0c
2 typedef char int8;
3 typedef unsigned char uint8;
4 typedef short int16;
5 typedef unsigned short uint16;
6 typedef int int32;
7 typedef unsigned int uint32;
8 typedef double float64;
9 typedef char TEXT;
10 typedef int BOOL;
12 #define TRUE 1
13 #define FALSE 0
15 // Woohoo!
16 #define MAX_CHANNELS 16
18 #define Period2Freq(period) ((3546897.f * 65536.f) / (period))
20 struct hvl_envelope
22 int16 aFrames, aVolume;
23 int16 dFrames, dVolume;
24 int16 sFrames;
25 int16 rFrames, rVolume;
26 int16 pad;
29 struct hvl_plsentry
31 uint8 ple_Note;
32 uint8 ple_Waveform;
33 int16 ple_Fixed;
34 int8 ple_FX[2];
35 int8 ple_FXParam[2];
38 struct hvl_plist
40 int16 pls_Speed;
41 int16 pls_Length;
42 struct hvl_plsentry *pls_Entries;
45 struct hvl_instrument
47 TEXT ins_Name[128];
48 uint8 ins_Volume;
49 uint8 ins_WaveLength;
50 uint8 ins_FilterLowerLimit;
51 uint8 ins_FilterUpperLimit;
52 uint8 ins_FilterSpeed;
53 uint8 ins_SquareLowerLimit;
54 uint8 ins_SquareUpperLimit;
55 uint8 ins_SquareSpeed;
56 uint8 ins_VibratoDelay;
57 uint8 ins_VibratoSpeed;
58 uint8 ins_VibratoDepth;
59 uint8 ins_HardCutRelease;
60 uint8 ins_HardCutReleaseFrames;
61 struct hvl_envelope ins_Envelope;
62 struct hvl_plist ins_PList;
65 struct hvl_position
67 uint8 pos_Track[MAX_CHANNELS];
68 int8 pos_Transpose[MAX_CHANNELS];
71 struct hvl_step
73 uint8 stp_Note;
74 uint8 stp_Instrument;
75 uint8 stp_FX;
76 uint8 stp_FXParam;
77 uint8 stp_FXb;
78 uint8 stp_FXbParam;
81 struct hvl_voice
83 int16 vc_Track;
84 int16 vc_NextTrack;
85 int16 vc_Transpose;
86 int16 vc_NextTranspose;
87 int16 vc_OverrideTranspose; // 1.5
88 int32 vc_ADSRVolume;
89 struct hvl_envelope vc_ADSR;
90 struct hvl_instrument *vc_Instrument;
91 uint32 vc_SamplePos;
92 uint32 vc_Delta;
93 uint16 vc_InstrPeriod;
94 uint16 vc_TrackPeriod;
95 uint16 vc_VibratoPeriod;
96 uint16 vc_WaveLength;
97 int16 vc_NoteMaxVolume;
98 uint16 vc_PerfSubVolume;
99 uint8 vc_NewWaveform;
100 uint8 vc_Waveform;
101 uint8 vc_PlantPeriod;
102 uint8 vc_VoiceVolume;
103 uint8 vc_PlantSquare;
104 uint8 vc_IgnoreSquare;
105 uint8 vc_FixedNote;
106 int16 vc_VolumeSlideUp;
107 int16 vc_VolumeSlideDown;
108 int16 vc_HardCut;
109 uint8 vc_HardCutRelease;
110 int16 vc_HardCutReleaseF;
111 uint8 vc_PeriodSlideOn;
112 int16 vc_PeriodSlideSpeed;
113 int16 vc_PeriodSlidePeriod;
114 int16 vc_PeriodSlideLimit;
115 int16 vc_PeriodSlideWithLimit;
116 int16 vc_PeriodPerfSlideSpeed;
117 int16 vc_PeriodPerfSlidePeriod;
118 uint8 vc_PeriodPerfSlideOn;
119 int16 vc_VibratoDelay;
120 int16 vc_VibratoSpeed;
121 int16 vc_VibratoCurrent;
122 int16 vc_VibratoDepth;
123 int16 vc_SquareOn;
124 int16 vc_SquareInit;
125 int16 vc_SquareWait;
126 int16 vc_SquareLowerLimit;
127 int16 vc_SquareUpperLimit;
128 int16 vc_SquarePos;
129 int16 vc_SquareSign;
130 int16 vc_SquareSlidingIn;
131 int16 vc_SquareReverse;
132 uint8 vc_FilterOn;
133 uint8 vc_FilterInit;
134 int16 vc_FilterWait;
135 int16 vc_FilterSpeed;
136 int16 vc_FilterUpperLimit;
137 int16 vc_FilterLowerLimit;
138 int16 vc_FilterPos;
139 int16 vc_FilterSign;
140 int16 vc_FilterSlidingIn;
141 int16 vc_IgnoreFilter;
142 int16 vc_PerfCurrent;
143 int16 vc_PerfSpeed;
144 int16 vc_PerfWait;
145 struct hvl_plist *vc_PerfList;
146 int8 *vc_AudioPointer;
147 int8 *vc_AudioSource;
148 uint8 vc_NoteDelayOn;
149 uint8 vc_NoteCutOn;
150 int16 vc_NoteDelayWait;
151 int16 vc_NoteCutWait;
152 int16 vc_AudioPeriod;
153 int16 vc_AudioVolume;
154 int32 vc_WNRandom;
155 int8 *vc_MixSource;
156 int8 vc_SquareTempBuffer[0x80];
157 int8 vc_VoiceBuffer[0x282*4];
158 uint8 vc_VoiceNum;
159 uint8 vc_TrackMasterVolume;
160 uint8 vc_TrackOn;
161 int16 vc_VoicePeriod;
162 uint32 vc_Pan;
163 uint32 vc_SetPan; // New for 1.4
164 uint32 vc_PanMultLeft;
165 uint32 vc_PanMultRight;
166 uint32 vc_RingSamplePos;
167 uint32 vc_RingDelta;
168 int8 *vc_RingMixSource;
169 uint8 vc_RingPlantPeriod;
170 int16 vc_RingInstrPeriod;
171 int16 vc_RingBasePeriod;
172 int16 vc_RingAudioPeriod;
173 int8 *vc_RingAudioSource;
174 uint8 vc_RingNewWaveform;
175 uint8 vc_RingWaveform;
176 uint8 vc_RingFixedPeriod;
177 int8 vc_RingVoiceBuffer[0x282*4];
180 struct hvl_tune
182 TEXT ht_Name[128];
183 uint16 ht_SongNum;
184 uint32 ht_Frequency;
185 float64 ht_FreqF;
186 int8 *ht_WaveformTab[MAX_CHANNELS];
187 uint16 ht_Restart;
188 uint16 ht_PositionNr;
189 uint8 ht_SpeedMultiplier;
190 uint8 ht_TrackLength;
191 uint8 ht_TrackNr;
192 uint8 ht_InstrumentNr;
193 uint8 ht_SubsongNr;
194 uint16 ht_PosJump;
195 uint32 ht_PlayingTime;
196 int16 ht_Tempo;
197 int16 ht_PosNr;
198 int16 ht_StepWaitFrames;
199 int16 ht_NoteNr;
200 uint16 ht_PosJumpNote;
201 uint8 ht_GetNewPosition;
202 uint8 ht_PatternBreak;
203 uint8 ht_SongEndReached;
204 uint8 ht_Stereo;
205 uint16 *ht_Subsongs;
206 uint16 ht_Channels;
207 struct hvl_position *ht_Positions;
208 struct hvl_step ht_Tracks[256][64];
209 struct hvl_instrument *ht_Instruments;
210 struct hvl_voice ht_Voices[MAX_CHANNELS];
211 int32 ht_defstereo;
212 int32 ht_defpanleft;
213 int32 ht_defpanright;
214 int32 ht_mixgain;
215 uint8 ht_Version;
216 //added for pineappletracker
217 uint8 curNote;
218 uint8 curInstr;
221 void hvl_DecodeFrame( struct hvl_tune *ht, int8 *buf1, int8 *buf2, int32 bufmod );
222 void hvl_InitReplayer( void );
223 BOOL hvl_InitSubsong( struct hvl_tune *ht, uint32 nr );
224 struct hvl_tune *hvl_LoadTune( TEXT *name, uint32 freq, uint32 defstereo );
225 void hvl_FreeTune( struct hvl_tune *ht );
227 void hvl_process_step( struct hvl_tune *ht, struct hvl_voice *voice );
228 void hvl_process_frame( struct hvl_tune *ht, struct hvl_voice *voice );
229 void hvl_set_audio( struct hvl_voice *voice, float64 freqf );
230 void hvl_playNote(struct hvl_tune *ht, int8 *buf1, int8 *buf2, int32 bufmod, struct hvl_voice *voice);
232 struct hvl_tune *tune;
234 int play;
235 int plonked;