Debian Codegraph @

src/pt2_replayer.c

raw symbols SCIP
1 // C port of ProTracker 2.3D's replayer (with some modifications, but still accurate)cxx . . $ `<file>/src/pt2_replayer.c`/
2
3 // for finding memory leaks in debug mode with Visual Studio
4 #if defined _DEBUG && defined _MSC_VER
5 #include <crtdbg.h>
6 #endif
7
8 #include <stdint.h>
9 #include <stdbool.h>
10 #include <string.h>
11 #include "pt2_audio.h"cxx . . $ `<file>/src/pt2_audio.h`/
12 #include "pt2_helpers.h"cxx . . $ `<file>/src/pt2_helpers.h`/
13 #include "pt2_tables.h"cxx . . $ `<file>/src/pt2_tables.h`/
14 #include "pt2_config.h"cxx . . $ `<file>/src/pt2_config.h`/
15 #include "pt2_visuals.h"cxx . . $ `<file>/src/pt2_visuals.h`/
16 #include "pt2_scopes.h"cxx . . $ `<file>/src/pt2_scopes.h`/
17 #include "pt2_paula.h"cxx . . $ `<file>/src/pt2_paula.h`/
18 #include "pt2_visuals_sync.h"cxx . . $ `<file>/src/pt2_visuals_sync.h`/
19 #include "pt2_posed.h"cxx . . $ `<file>/src/pt2_posed.h`/
20
21 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! posJumpAssertcxx . . $ posJumpAssert., pBreakFlagcxx . . $ pBreakFlag., modRenderDonecxx . . $ modRenderDone.;
22 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! doStopSongcxx . . $ doStopSong.; // from F00 (Set Speed)
23 static int8_tcxx . . $ int8_t# pBreakPositioncxx . . $ pBreakPosition., oldRowcxx . . $ oldRow., modPatterncxx . . $ modPattern.;
24 static uint8_tcxx . . $ uint8_t# pattDelTimecxx . . $ pattDelTime., lowMaskcxx . . $ lowMask. = 0xFF, pattDelTime2cxx . . $ pattDelTime2.;
25 static int16_tcxx . . $ int16_t# modPoscxx . . $ modPos., oldPatterncxx . . $ oldPattern., oldPoscxx . . $ oldPos.;
26 static uint16_tcxx . . $ uint16_t# DMACONtempcxx . . $ DMACONtemp.;
27 static int32_tcxx . . $ int32_t# modBPMcxx . . $ modBPM., oldBPMcxx . . $ oldBPM., oldSpeedcxx . . $ oldSpeed., ciaSetBPMcxx . . $ ciaSetBPM.;
28
29 static const uint8_tcxx . . $ uint8_t# funkTablecxx . . $ funkTable.[16] = // EFx (FunkRepeat/InvertLoop)
30 {
31 0x00, 0x05, 0x06, 0x07, 0x08, 0x0A, 0x0B, 0x0D,
32 0x10, 0x13, 0x16, 0x1A, 0x20, 0x2B, 0x40, 0x80
33 };
34
35 void gotoNextMulticxx . . $ gotoNextMulti(49f6e7a06ebc5aa8).(void)
36 {
37 cursorcxx . . $ cursor..channelcxx . . $ cursor_t#channel. = (editorcxx . . $ editor..multiModeNextcxx . . $ editor_t#multiModeNext.[cursorcxx . . $ cursor..channelcxx . . $ cursor_t#channel.] - 1) & 3;
38 cursorcxx . . $ cursor..poscxx . . $ cursor_t#pos. = cursorcxx . . $ cursor..channelcxx . . $ cursor_t#channel. * 6;
39 updateCursorPoscxx . . $ updateCursorPos(49f6e7a06ebc5aa8).();
40 }
41
42 double ciaBpm2Hzcxx . . $ ciaBpm2Hz(4badf5dbac1308a7).(int32_tcxx . . $ int32_t# bpm)
43 {
44 if (bpm == 0)
45 return 0.0;
46
47 const uint32_tcxx . . $ uint32_t# ciaPeriod = 1773447 / bpm; // yes, PT truncates here
48 return (double)CIA_PAL_CLKcxx . . $ `src/pt2_header.h:50:9`! / (ciaPeriod+1); // +1, CIA triggers on underflow
49 }
50
51 void updatePaulaLoopscxx . . $ updatePaulaLoops(49f6e7a06ebc5aa8).(void) // used after manipulating sample loop points while Paula is live
52 {
53 moduleSample_tcxx . . $ moduleSample_t# *s = &songcxx . . $ song.->samplescxx . . $ module_t#samples.[editorcxx . . $ editor..currSamplecxx . . $ editor_t#currSample.];
54
55 const boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! audioWasntLocked = !audiocxx . . $ audio..lockedcxx . . $ audio_t#locked.;
56 if (audioWasntLocked)
57 lockAudiocxx . . $ lockAudio(49f6e7a06ebc5aa8).();
58
59 moduleChannel_tcxx . . $ moduleChannel_t# *ch = songcxx . . $ song.->channelscxx . . $ module_t#channels.;
60 for (uint32_tcxx . . $ uint32_t# i = 0; i < PAULA_VOICEScxx . . $ `src/pt2_paula.h:13:9`!; i++, ch++)
61 {
62 if (ch->n_samplenumcxx . . $ moduleChannel_t#n_samplenum. == editorcxx . . $ editor..currSamplecxx . . $ editor_t#currSample. && ch->n_startcxx . . $ moduleChannel_t#n_start. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
63 {
64 const uint32_tcxx . . $ uint32_t# voiceAddr = 0xDFF0A0 + (i * 16);
65
66 // update replayer vars
67 ch->n_loopstartcxx . . $ moduleChannel_t#n_loopstart. = ch->n_startcxx . . $ moduleChannel_t#n_start. + s->loopStartcxx . . $ moduleSample_t#loopStart.;
68 ch->n_replencxx . . $ moduleChannel_t#n_replen. = (uint16_tcxx . . $ uint16_t#)(s->loopLengthcxx . . $ moduleSample_t#loopLength. >> 1);
69 ch->n_wavestartcxx . . $ moduleChannel_t#n_wavestart. = ch->n_loopstartcxx . . $ moduleChannel_t#n_loopstart.;
70
71 // set Paula DAT and LEN (for next cycle)
72 paulaWritePtrcxx . . $ paulaWritePtr(8ed931be62ea155e).(voiceAddr + 0, ch->n_loopstartcxx . . $ moduleChannel_t#n_loopstart.);
73 paulaWriteWordcxx . . $ paulaWriteWord(272d193675e92631).(voiceAddr + 4, ch->n_replencxx . . $ moduleChannel_t#n_replen.);
74
75 // ... and update quadrascope as well
76 setVisualsDataPtrcxx . . $ setVisualsDataPtr(70eb3de2aab3469c).(i, ch->n_loopstartcxx . . $ moduleChannel_t#n_loopstart.);
77 setVisualsLengthcxx . . $ setVisualsLength(a7050f1a4cb56049).(i, ch->n_replencxx . . $ moduleChannel_t#n_replen.);
78 }
79 }
80
81 if (audioWasntLocked)
82 unlockAudiocxx . . $ unlockAudio(49f6e7a06ebc5aa8).();
83 }
84
85 void turnOffVoicescxx . . $ turnOffVoices(49f6e7a06ebc5aa8).(void)
86 {
87 const boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! audioWasntLocked = !audiocxx . . $ audio..lockedcxx . . $ audio_t#locked.;
88 if (audioWasntLocked)
89 lockAudiocxx . . $ lockAudio(49f6e7a06ebc5aa8).();
90
91 paulaWriteWordcxx . . $ paulaWriteWord(272d193675e92631).(0xDFF096, 0x000F); // turn off all voice DMAs
92 setVisualsDMACONcxx . . $ setVisualsDMACON(ed53e3bbd3fa2f69).(0x000F);
93
94 // clear all volumes
95 for (int32_tcxx . . $ int32_t# i = 0; i < PAULA_VOICEScxx . . $ `src/pt2_paula.h:13:9`!; i++)
96 {
97 const uint32_tcxx . . $ uint32_t# voiceAddr = 0xDFF0A0 + (i * 16);
98 paulaWriteWordcxx . . $ paulaWriteWord(272d193675e92631).(voiceAddr + 8, 0);
99
100 setVisualsVolumecxx . . $ setVisualsVolume(a7050f1a4cb56049).(i, 0);
101 }
102
103 resetAudioDithercxx . . $ resetAudioDither(49f6e7a06ebc5aa8).();
104
105 editorcxx . . $ editor..tuningToneFlagcxx . . $ editor_t#tuningToneFlag. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
106
107 if (audioWasntLocked)
108 unlockAudiocxx . . $ unlockAudio(49f6e7a06ebc5aa8).();
109 }
110
111 void initializeModuleChannelscxx . . $ initializeModuleChannels(c4f6a69956ee5af3).(module_tcxx . . $ module_t# *m)
112 {
113 ASSERTcxx . . $ `src/pt2_header.h:25:9`!(m != NULL);
114
115 memsetcxx . . $ memset(d1de1e4fb215f1c6).(m->channelscxx . . $ module_t#channels., 0, sizeof (m->channelscxx . . $ module_t#channels.));
116
117 moduleChannel_tcxx . . $ moduleChannel_t# *ch = m->channelscxx . . $ module_t#channels.;
118 for (uint8_tcxx . . $ uint8_t# i = 0; i < PAULA_VOICEScxx . . $ `src/pt2_paula.h:13:9`!; i++, ch++)
119 {
120 ch->n_chanindexcxx . . $ moduleChannel_t#n_chanindex. = i;
121 ch->n_dmabitcxx . . $ moduleChannel_t#n_dmabit. = 1 << i;
122 }
123 }
124
125 void setReplayerPosToTrackerPoscxx . . $ setReplayerPosToTrackerPos(49f6e7a06ebc5aa8).(void)
126 {
127 if (songcxx . . $ song. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
128 return;
129
130 modPatterncxx . . $ modPattern. = (int8_tcxx . . $ int8_t#)songcxx . . $ song.->currPatterncxx . . $ module_t#currPattern.;
131 modPoscxx . . $ modPos. = songcxx . . $ song.->currPoscxx . . $ module_t#currPos.;
132 songcxx . . $ song.->rowcxx . . $ module_t#row. = songcxx . . $ song.->currRowcxx . . $ module_t#currRow.;
133 songcxx . . $ song.->tickcxx . . $ module_t#tick. = 0;
134 }
135
136 module_tcxx . . $ module_t# *createEmptyModcxx . . $ createEmptyMod(51965c0e12ed79c4).(void)
137 {
138 module_tcxx . . $ module_t# *m = (module_tcxx . . $ module_t# *)calloccxx . . $ calloc(63a7bf2941bfcd7a).(1, sizeof (module_tcxx . . $ module_t#));
139 if (m == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
140 goto error;
141
142 // allocate memory for all sample data blocks (+ 2 extra, for quirk + safety)
143 const size_t allocLen = (MOD_SAMPLEScxx . . $ `src/pt2_header.h:74:9`! + 2) * configcxx . . $ config..maxSampleLengthcxx . . $ config_t#maxSampleLength.;
144
145 m->sampleDatacxx . . $ module_t#sampleData. = (int8_tcxx . . $ int8_t# *)calloccxx . . $ calloc(63a7bf2941bfcd7a).(allocLen, 1);
146 if (m->sampleDatacxx . . $ module_t#sampleData. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
147 goto error;
148
149 for (int32_tcxx . . $ int32_t# i = 0; i < MAX_PATTERNScxx . . $ `src/pt2_header.h:75:9`!; i++)
150 {
151 m->patternscxx . . $ module_t#patterns.[i] = (note_tcxx . . $ note_t# *)calloccxx . . $ calloc(63a7bf2941bfcd7a).(1, MOD_ROWScxx . . $ `src/pt2_header.h:73:9`! * sizeof (note_tcxx . . $ note_t#) * PAULA_VOICEScxx . . $ `src/pt2_paula.h:13:9`!);
152 if (m->patternscxx . . $ module_t#patterns.[i] == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
153 goto error;
154 }
155
156 m->headercxx . . $ module_t#header..songLengthcxx . . $ moduleHeader_t#songLength. = 1;
157
158 moduleSample_tcxx . . $ moduleSample_t# *s = m->samplescxx . . $ module_t#samples.;
159 for (int32_tcxx . . $ int32_t# i = 0; i < MOD_SAMPLEScxx . . $ `src/pt2_header.h:74:9`!; i++, s++)
160 {
161 // setup GUI text pointers
162 s->volumeDispcxx . . $ moduleSample_t#volumeDisp. = &s->volumecxx . . $ moduleSample_t#volume.;
163 s->lengthDispcxx . . $ moduleSample_t#lengthDisp. = &s->lengthcxx . . $ moduleSample_t#length.;
164 s->loopStartDispcxx . . $ moduleSample_t#loopStartDisp. = &s->loopStartcxx . . $ moduleSample_t#loopStart.;
165 s->loopLengthDispcxx . . $ moduleSample_t#loopLengthDisp. = &s->loopLengthcxx . . $ moduleSample_t#loopLength.;
166
167 s->loopLengthcxx . . $ moduleSample_t#loopLength. = 2;
168
169 // sample data offsets (sample data = one huge buffer to rule them all)
170 s->offsetcxx . . $ moduleSample_t#offset. = configcxx . . $ config..maxSampleLengthcxx . . $ config_t#maxSampleLength. * i;
171 }
172
173 initializeModuleChannelscxx . . $ initializeModuleChannels(c4f6a69956ee5af3).(m);
174
175 return m;
176
177 error:
178 if (m != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
179 {
180 for (int32_tcxx . . $ int32_t# i = 0; i < MAX_PATTERNScxx . . $ `src/pt2_header.h:75:9`!; i++)
181 {
182 if (m->patternscxx . . $ module_t#patterns.[i] != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
183 freecxx . . $ free(5d22bdacc48458e8).(m->patternscxx . . $ module_t#patterns.[i]);
184 }
185
186 if (m->sampleDatacxx . . $ module_t#sampleData. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
187 freecxx . . $ free(5d22bdacc48458e8).(m->sampleDatacxx . . $ module_t#sampleData.);
188
189 freecxx . . $ free(5d22bdacc48458e8).(m);
190 }
191
192 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
193 }
194
195 void modSetSpeedcxx . . $ modSetSpeed(d4f767463ce0a6b3).(int32_tcxx . . $ int32_t# speed)
196 {
197 songcxx . . $ song.->currSpeedcxx . . $ module_t#currSpeed. = songcxx . . $ song.->speedcxx . . $ module_t#speed. = speed;
198 songcxx . . $ song.->tickcxx . . $ module_t#tick. = 0;
199 }
200
201 void doStopItcxx . . $ doStopIt(b45ddcbc8423892c).(boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! resetPlayMode)
202 {
203 const boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! audioWasntLocked = !audiocxx . . $ audio..lockedcxx . . $ audio_t#locked.;
204 if (audioWasntLocked)
205 lockAudiocxx . . $ lockAudio(49f6e7a06ebc5aa8).();
206
207 editorcxx . . $ editor..songPlayingcxx . . $ editor_t#songPlaying. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
208
209 pattDelTimecxx . . $ pattDelTime. = pattDelTime2cxx . . $ pattDelTime2. = 0;
210
211 if (resetPlayMode)
212 {
213 editorcxx . . $ editor..playModecxx . . $ editor_t#playMode. = PLAY_MODE_NORMALcxx . . $ PLAY_MODE_NORMAL.;
214 editorcxx . . $ editor..currModecxx . . $ editor_t#currMode. = MODE_IDLEcxx . . $ MODE_IDLE.;
215
216 if (editorcxx . . $ editor..stepPlayLastModecxx . . $ editor_t#stepPlayLastMode. != MODE_IDLEcxx . . $ MODE_IDLE.)
217 pointerSetModeThreadSafecxx . . $ pointerSetModeThreadSafe(f2ac3508b56cd10).(POINTER_MODE_IDLEcxx . . $ POINTER_MODE_IDLE., truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!);
218 }
219
220 if (songcxx . . $ song. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
221 {
222 moduleChannel_tcxx . . $ moduleChannel_t# *ch = songcxx . . $ song.->channelscxx . . $ module_t#channels.;
223 for (int32_tcxx . . $ int32_t# i = 0; i < PAULA_VOICEScxx . . $ `src/pt2_paula.h:13:9`!; i++, ch++)
224 {
225 ch->n_wavecontrolcxx . . $ moduleChannel_t#n_wavecontrol. = 0;
226 ch->n_glissfunkcxx . . $ moduleChannel_t#n_glissfunk. = 0;
227 ch->n_finetunecxx . . $ moduleChannel_t#n_finetune. = 0;
228 ch->n_loopcountcxx . . $ moduleChannel_t#n_loopcount. = 0;
229 }
230 }
231
232 doStopSongcxx . . $ doStopSong. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; // just in case this flag was stuck from command F00 (stop song)
233
234 if (audioWasntLocked)
235 unlockAudiocxx . . $ unlockAudio(49f6e7a06ebc5aa8).();
236 }
237
238 void setPatterncxx . . $ setPattern(68e3ae50fe6578a9).(int16_tcxx . . $ int16_t# pattern)
239 {
240 if (pattern > MAX_PATTERNScxx . . $ `src/pt2_header.h:75:9`!-1)
241 pattern = MAX_PATTERNScxx . . $ `src/pt2_header.h:75:9`!-1;
242
243 songcxx . . $ song.->currPatterncxx . . $ module_t#currPattern. = modPatterncxx . . $ modPattern. = (int8_tcxx . . $ int8_t#)pattern;
244 }
245
246 void storeTempVariablescxx . . $ storeTempVariables(49f6e7a06ebc5aa8).(void) // this one is accessed in other files, so non-static
247 {
248 oldBPMcxx . . $ oldBPM. = songcxx . . $ song.->currBPMcxx . . $ module_t#currBPM.;
249 oldRowcxx . . $ oldRow. = songcxx . . $ song.->currRowcxx . . $ module_t#currRow.;
250 oldPoscxx . . $ oldPos. = songcxx . . $ song.->currPoscxx . . $ module_t#currPos.;
251 oldSpeedcxx . . $ oldSpeed. = songcxx . . $ song.->currSpeedcxx . . $ module_t#currSpeed.;
252 oldPatterncxx . . $ oldPattern. = songcxx . . $ song.->currPatterncxx . . $ module_t#currPattern.;
253 }
254
255 static void setVUMeterHeightcxx . . $ setVUMeterHeight(252f18867a0e9dee).(moduleChannel_tcxx . . $ moduleChannel_t# *ch)
256 {
257 if (editorcxx . . $ editor..mutedcxx . . $ editor_t#muted.[ch->n_chanindexcxx . . $ moduleChannel_t#n_chanindex.])
258 return;
259
260 uint8_tcxx . . $ uint8_t# vol = ch->n_volumecxx . . $ moduleChannel_t#n_volume.;
261 if ((ch->n_cmdcxx . . $ moduleChannel_t#n_cmd. & 0xF00) == 0xC00) // handle Cxx effect
262 vol = ch->n_cmdcxx . . $ moduleChannel_t#n_cmd. & 0xFF;
263
264 if (vol > 64)
265 vol = 64;
266
267 if (!editorcxx . . $ editor..songPlayingcxx . . $ editor_t#songPlaying.)
268 {
269 editorcxx . . $ editor..vuMeterVolumescxx . . $ editor_t#vuMeterVolumes.[ch->n_chanindexcxx . . $ moduleChannel_t#n_chanindex.] = vuMeterHeightscxx . . $ vuMeterHeights.[vol];
270 }
271 else
272 {
273 ch->syncVuVolumecxx . . $ moduleChannel_t#syncVuVolume. = vol;
274 ch->syncFlagscxx . . $ moduleChannel_t#syncFlags. |= UPDATE_VUMETERcxx . . $ UPDATE_VUMETER.;
275 }
276 }
277
278 static void updateFunkcxx . . $ updateFunk(252f18867a0e9dee).(moduleChannel_tcxx . . $ moduleChannel_t# *ch)
279 {
280 const int8_tcxx . . $ int8_t# funkSpeed = ch->n_glissfunkcxx . . $ moduleChannel_t#n_glissfunk. >> 4;
281 if (funkSpeed == 0)
282 return;
283
284 ch->n_funkoffsetcxx . . $ moduleChannel_t#n_funkoffset. += funkTablecxx . . $ funkTable.[funkSpeed];
285 if (ch->n_funkoffsetcxx . . $ moduleChannel_t#n_funkoffset. >= 128)
286 {
287 ch->n_funkoffsetcxx . . $ moduleChannel_t#n_funkoffset. = 0;
288
289 if (ch->n_loopstartcxx . . $ moduleChannel_t#n_loopstart. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! && ch->n_wavestartcxx . . $ moduleChannel_t#n_wavestart. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) // ProTracker bugfix
290 {
291 if (++ch->n_wavestartcxx . . $ moduleChannel_t#n_wavestart. >= ch->n_loopstartcxx . . $ moduleChannel_t#n_loopstart. + (ch->n_replencxx . . $ moduleChannel_t#n_replen. << 1))
292 ch->n_wavestartcxx . . $ moduleChannel_t#n_wavestart. = ch->n_loopstartcxx . . $ moduleChannel_t#n_loopstart.;
293
294 *ch->n_wavestartcxx . . $ moduleChannel_t#n_wavestart. = -1 - *ch->n_wavestartcxx . . $ moduleChannel_t#n_wavestart.;
295 }
296 }
297 }
298
299 static void setGlissControlcxx . . $ setGlissControl(252f18867a0e9dee).(moduleChannel_tcxx . . $ moduleChannel_t# *ch)
300 {
301 ch->n_glissfunkcxx . . $ moduleChannel_t#n_glissfunk. = (ch->n_glissfunkcxx . . $ moduleChannel_t#n_glissfunk. & 0xF0) | (ch->n_cmdcxx . . $ moduleChannel_t#n_cmd. & 0x0F);
302 }
303
304 static void setVibratoControlcxx . . $ setVibratoControl(252f18867a0e9dee).(moduleChannel_tcxx . . $ moduleChannel_t# *ch)
305 {
306 ch->n_wavecontrolcxx . . $ moduleChannel_t#n_wavecontrol. = (ch->n_wavecontrolcxx . . $ moduleChannel_t#n_wavecontrol. & 0xF0) | (ch->n_cmdcxx . . $ moduleChannel_t#n_cmd. & 0x0F);
307 }
308
309 static void setFineTunecxx . . $ setFineTune(252f18867a0e9dee).(moduleChannel_tcxx . . $ moduleChannel_t# *ch)
310 {
311 ch->n_finetunecxx . . $ moduleChannel_t#n_finetune. = ch->n_cmdcxx . . $ moduleChannel_t#n_cmd. & 0xF;
312 }
313
314 static void jumpLoopcxx . . $ jumpLoop(252f18867a0e9dee).(moduleChannel_tcxx . . $ moduleChannel_t# *ch)
315 {
316 if (songcxx . . $ song.->tickcxx . . $ module_t#tick. != 0)
317 return;
318
319 if ((ch->n_cmdcxx . . $ moduleChannel_t#n_cmd. & 0xF) == 0)
320 {
321 ch->n_pattposcxx . . $ moduleChannel_t#n_pattpos. = songcxx . . $ song.->rowcxx . . $ module_t#row.;
322 }
323 else
324 {
325 if (ch->n_loopcountcxx . . $ moduleChannel_t#n_loopcount. == 0)
326 ch->n_loopcountcxx . . $ moduleChannel_t#n_loopcount. = ch->n_cmdcxx . . $ moduleChannel_t#n_cmd. & 0xF;
327 else if (--ch->n_loopcountcxx . . $ moduleChannel_t#n_loopcount. == 0)
328 return;
329
330 pBreakPositioncxx . . $ pBreakPosition. = ch->n_pattposcxx . . $ moduleChannel_t#n_pattpos.;
331 pBreakFlagcxx . . $ pBreakFlag. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
332
333 // stuff used for MOD2WAV to determine if the song has reached its end
334 if (editorcxx . . $ editor..mod2WavOngoingcxx . . $ editor_t#mod2WavOngoing.)
335 {
336 for (int32_tcxx . . $ int32_t# tempParam = pBreakPositioncxx . . $ pBreakPosition.; tempParam <= songcxx . . $ song.->rowcxx . . $ module_t#row.; tempParam++)
337 editorcxx . . $ editor..rowVisitTablecxx . . $ editor_t#rowVisitTable.[(modPoscxx . . $ modPos. * MOD_ROWScxx . . $ `src/pt2_header.h:73:9`!) + tempParam] = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
338 }
339 }
340 }
341
342 static void setTremoloControlcxx . . $ setTremoloControl(252f18867a0e9dee).(moduleChannel_tcxx . . $ moduleChannel_t# *ch)
343 {
344 ch->n_wavecontrolcxx . . $ moduleChannel_t#n_wavecontrol. = ((ch->n_cmdcxx . . $ moduleChannel_t#n_cmd. & 0xF) << 4) | (ch->n_wavecontrolcxx . . $ moduleChannel_t#n_wavecontrol. & 0xF);
345 }
346
347 /* This is the least used (and least known) ProTracker effect there is. It's not even
348 ** documented in the official ProTracker help text...
349 **
350 ** When E8x is seen in a .mod, it is in >95% of cases used for demo effect syncing for
351 ** demo .mod players, so it is disabled by default (as this effect trashes sample data
352 * and is almost NEVER used as Karplus-Strong intentionally).
353 ** It can be turned on through ENABLE_E8X in protracker.ini if you so desire.
354 */
355 static void karplusStrongcxx . . $ karplusStrong(252f18867a0e9dee).(moduleChannel_tcxx . . $ moduleChannel_t# *ch) // E8x
356 {
357 if (!configcxx . . $ config..enableE8xEffectcxx . . $ config_t#enableE8xEffect.)
358 return;
359
360 if (ch->n_loopstartcxx . . $ moduleChannel_t#n_loopstart. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
361 return; // ProTracker bugfix
362
363 // yes, this means that it's buggy for >64kB loops!
364 uint16_tcxx . . $ uint16_t# end = (uint16_tcxx . . $ uint16_t#)((ch->n_replencxx . . $ moduleChannel_t#n_replen. * 2) - 2);
365
366 int8_tcxx . . $ int8_t# *loopStartPtr = ch->n_loopstartcxx . . $ moduleChannel_t#n_loopstart.;
367 for (int32_tcxx . . $ int32_t# i = 0; i <= end; i++)
368 loopStartPtr[i] = (loopStartPtr[i+0] + loopStartPtr[i+1]) >> 1;
369
370 loopStartPtr[end+1] = (loopStartPtr[end+1] + loopStartPtr[0]) >> 1;
371 }
372
373 static void doRetrgcxx . . $ doRetrg(252f18867a0e9dee).(moduleChannel_tcxx . . $ moduleChannel_t# *ch)
374 {
375 const uint32_tcxx . . $ uint32_t# voiceAddr = 0xDFF0A0 + (ch->n_chanindexcxx . . $ moduleChannel_t#n_chanindex. * 16);
376
377 // voice DMA off
378 paulaWriteWordcxx . . $ paulaWriteWord(272d193675e92631).(0xDFF096, ch->n_dmabitcxx . . $ moduleChannel_t#n_dmabit.);
379
380 // set voice data ptr, data length and period
381 paulaWritePtrcxx . . $ paulaWritePtr(8ed931be62ea155e).(voiceAddr + 0, ch->n_startcxx . . $ moduleChannel_t#n_start.); // n_start is increased on 9xx
382 paulaWriteWordcxx . . $ paulaWriteWord(272d193675e92631).(voiceAddr + 4, ch->n_lengthcxx . . $ moduleChannel_t#n_length.);
383 paulaWriteWordcxx . . $ paulaWriteWord(272d193675e92631).(voiceAddr + 6, ch->n_periodcxx . . $ moduleChannel_t#n_period.);
384
385 // voice DMA on
386 paulaWriteWordcxx . . $ paulaWriteWord(272d193675e92631).(0xDFF096, 0x8000 | ch->n_dmabitcxx . . $ moduleChannel_t#n_dmabit.);
387
388 // set new data ptr and data length (these take effect after the current DMA cycle is done)
389 paulaWritePtrcxx . . $ paulaWritePtr(8ed931be62ea155e).(voiceAddr + 0, ch->n_loopstartcxx . . $ moduleChannel_t#n_loopstart.);
390 paulaWriteWordcxx . . $ paulaWriteWord(272d193675e92631).(voiceAddr + 4, ch->n_replencxx . . $ moduleChannel_t#n_replen.);
391
392 // update tracker visuals
393 setVisualsDMACONcxx . . $ setVisualsDMACON(ed53e3bbd3fa2f69).(ch->n_dmabitcxx . . $ moduleChannel_t#n_dmabit.);
394 setVisualsDataPtrcxx . . $ setVisualsDataPtr(70eb3de2aab3469c).(ch->n_chanindexcxx . . $ moduleChannel_t#n_chanindex., ch->n_startcxx . . $ moduleChannel_t#n_start.);
395 setVisualsLengthcxx . . $ setVisualsLength(a7050f1a4cb56049).(ch->n_chanindexcxx . . $ moduleChannel_t#n_chanindex., ch->n_lengthcxx . . $ moduleChannel_t#n_length.);
396 setVisualsPeriodcxx . . $ setVisualsPeriod(a7050f1a4cb56049).(ch->n_chanindexcxx . . $ moduleChannel_t#n_chanindex., ch->n_periodcxx . . $ moduleChannel_t#n_period.);
397 setVisualsDMACONcxx . . $ setVisualsDMACON(ed53e3bbd3fa2f69).(0x8000 | ch->n_dmabitcxx . . $ moduleChannel_t#n_dmabit.);
398 setVisualsDataPtrcxx . . $ setVisualsDataPtr(70eb3de2aab3469c).(ch->n_chanindexcxx . . $ moduleChannel_t#n_chanindex., ch->n_loopstartcxx . . $ moduleChannel_t#n_loopstart.);
399 setVisualsLengthcxx . . $ setVisualsLength(a7050f1a4cb56049).(ch->n_chanindexcxx . . $ moduleChannel_t#n_chanindex., ch->n_replencxx . . $ moduleChannel_t#n_replen.);
400
401 // set spectrum analyzer state for this channel
402 ch->syncAnalyzerVolumecxx . . $ moduleChannel_t#syncAnalyzerVolume. = ch->n_volumecxx . . $ moduleChannel_t#n_volume.;
403 ch->syncAnalyzerPeriodcxx . . $ moduleChannel_t#syncAnalyzerPeriod. = ch->n_periodcxx . . $ moduleChannel_t#n_period.;
404 ch->syncFlagscxx . . $ moduleChannel_t#syncFlags. |= UPDATE_SPECTRUM_ANALYZERcxx . . $ UPDATE_SPECTRUM_ANALYZER.;
405
406 setVUMeterHeightcxx . . $ setVUMeterHeight(252f18867a0e9dee).(ch);
407 }
408
409 static void retrigNotecxx . . $ retrigNote(252f18867a0e9dee).(moduleChannel_tcxx . . $ moduleChannel_t# *ch)
410 {
411 if ((ch->n_cmdcxx . . $ moduleChannel_t#n_cmd. & 0xF) > 0)
412 {
413 if (songcxx . . $ song.->tickcxx . . $ module_t#tick. == 0 && (ch->n_notecxx . . $ moduleChannel_t#n_note. & 0xFFF) > 0)
414 return;
415
416 if (songcxx . . $ song.->tickcxx . . $ module_t#tick. % (ch->n_cmdcxx . . $ moduleChannel_t#n_cmd. & 0xF) == 0)
417 doRetrgcxx . . $ doRetrg(252f18867a0e9dee).(ch);
418 }
419 }
420
421 static void volumeSlidecxx . . $ volumeSlide(252f18867a0e9dee).(moduleChannel_tcxx . . $ moduleChannel_t# *ch)
422 {
423 uint8_tcxx . . $ uint8_t# param = ch->n_cmdcxx . . $ moduleChannel_t#n_cmd. & 0xFF;
424 if ((param & 0xF0) == 0)
425 {
426 ch->n_volumecxx . . $ moduleChannel_t#n_volume. -= param & 0x0F;
427 if (ch->n_volumecxx . . $ moduleChannel_t#n_volume. < 0)
428 ch->n_volumecxx . . $ moduleChannel_t#n_volume. = 0;
429 }
430 else
431 {
432 ch->n_volumecxx . . $ moduleChannel_t#n_volume. += param >> 4;
433 if (ch->n_volumecxx . . $ moduleChannel_t#n_volume. > 64)
434 ch->n_volumecxx . . $ moduleChannel_t#n_volume. = 64;
435 }
436 }
437
438 static void volumeFineUpcxx . . $ volumeFineUp(252f18867a0e9dee).(moduleChannel_tcxx . . $ moduleChannel_t# *ch)
439 {
440 if (songcxx . . $ song.->tickcxx . . $ module_t#tick. == 0)
441 {
442 ch->n_volumecxx . . $ moduleChannel_t#n_volume. += ch->n_cmdcxx . . $ moduleChannel_t#n_cmd. & 0xF;
443 if (ch->n_volumecxx . . $ moduleChannel_t#n_volume. > 64)
444 ch->n_volumecxx . . $ moduleChannel_t#n_volume. = 64;
445 }
446 }
447
448 static void volumeFineDowncxx . . $ volumeFineDown(252f18867a0e9dee).(moduleChannel_tcxx . . $ moduleChannel_t# *ch)
449 {
450 if (songcxx . . $ song.->tickcxx . . $ module_t#tick. == 0)
451 {
452 ch->n_volumecxx . . $ moduleChannel_t#n_volume. -= ch->n_cmdcxx . . $ moduleChannel_t#n_cmd. & 0xF;
453 if (ch->n_volumecxx . . $ moduleChannel_t#n_volume. < 0)
454 ch->n_volumecxx . . $ moduleChannel_t#n_volume. = 0;
455 }
456 }
457
458 static void noteCutcxx . . $ noteCut(252f18867a0e9dee).(moduleChannel_tcxx . . $ moduleChannel_t# *ch)
459 {
460 if (songcxx . . $ song.->tickcxx . . $ module_t#tick. == (ch->n_cmdcxx . . $ moduleChannel_t#n_cmd. & 0xF))
461 ch->n_volumecxx . . $ moduleChannel_t#n_volume. = 0;
462 }
463
464 static void noteDelaycxx . . $ noteDelay(252f18867a0e9dee).(moduleChannel_tcxx . . $ moduleChannel_t# *ch)
465 {
466 if (songcxx . . $ song.->tickcxx . . $ module_t#tick. == (ch->n_cmdcxx . . $ moduleChannel_t#n_cmd. & 0xF) && (ch->n_notecxx . . $ moduleChannel_t#n_note. & 0xFFF) > 0)
467 doRetrgcxx . . $ doRetrg(252f18867a0e9dee).(ch);
468 }
469
470 static void patternDelaycxx . . $ patternDelay(252f18867a0e9dee).(moduleChannel_tcxx . . $ moduleChannel_t# *ch)
471 {
472 if (songcxx . . $ song.->tickcxx . . $ module_t#tick. == 0 && pattDelTime2cxx . . $ pattDelTime2. == 0)
473 pattDelTimecxx . . $ pattDelTime. = (ch->n_cmdcxx . . $ moduleChannel_t#n_cmd. & 0xF) + 1;
474 }
475
476 static void funkItcxx . . $ funkIt(252f18867a0e9dee).(moduleChannel_tcxx . . $ moduleChannel_t# *ch)
477 {
478 if (songcxx . . $ song.->tickcxx . . $ module_t#tick. == 0)
479 {
480 ch->n_glissfunkcxx . . $ moduleChannel_t#n_glissfunk. = ((ch->n_cmdcxx . . $ moduleChannel_t#n_cmd. & 0xF) << 4) | (ch->n_glissfunkcxx . . $ moduleChannel_t#n_glissfunk. & 0xF);
481
482 if ((ch->n_glissfunkcxx . . $ moduleChannel_t#n_glissfunk. & 0xF0) > 0)
483 updateFunkcxx . . $ updateFunk(252f18867a0e9dee).(ch);
484 }
485 }
486
487 static void positionJumpcxx . . $ positionJump(252f18867a0e9dee).(moduleChannel_tcxx . . $ moduleChannel_t# *ch)
488 {
489 // original PT doesn't do this check, but we have to
490 if (editorcxx . . $ editor..playModecxx . . $ editor_t#playMode. != PLAY_MODE_PATTERNcxx . . $ PLAY_MODE_PATTERN. || (editorcxx . . $ editor..currModecxx . . $ editor_t#currMode. == MODE_RECORDcxx . . $ MODE_RECORD. && editorcxx . . $ editor..recordModecxx . . $ editor_t#recordMode. != RECORD_PATTcxx . . $ RECORD_PATT.))
491 modPoscxx . . $ modPos. = (ch->n_cmdcxx . . $ moduleChannel_t#n_cmd. & 0xFF) - 1; // B00 results in -1, but it safely jumps to order 0
492
493 pBreakPositioncxx . . $ pBreakPosition. = 0;
494 posJumpAssertcxx . . $ posJumpAssert. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
495 }
496
497 static void volumeChangecxx . . $ volumeChange(252f18867a0e9dee).(moduleChannel_tcxx . . $ moduleChannel_t# *ch)
498 {
499 ch->n_volumecxx . . $ moduleChannel_t#n_volume. = ch->n_cmdcxx . . $ moduleChannel_t#n_cmd. & 0xFF;
500 if ((uint8_tcxx . . $ uint8_t#)ch->n_volumecxx . . $ moduleChannel_t#n_volume. > 64)
501 ch->n_volumecxx . . $ moduleChannel_t#n_volume. = 64;
502 }
503
504 static void patternBreakcxx . . $ patternBreak(252f18867a0e9dee).(moduleChannel_tcxx . . $ moduleChannel_t# *ch)
505 {
506 pBreakPositioncxx . . $ pBreakPosition. = (((ch->n_cmdcxx . . $ moduleChannel_t#n_cmd. & 0xF0) >> 4) * 10) + (ch->n_cmdcxx . . $ moduleChannel_t#n_cmd. & 0x0F);
507 if ((uint8_tcxx . . $ uint8_t#)pBreakPositioncxx . . $ pBreakPosition. > 63)
508 pBreakPositioncxx . . $ pBreakPosition. = 0;
509
510 posJumpAssertcxx . . $ posJumpAssert. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
511 }
512
513 static void setSpeedcxx . . $ setSpeed(252f18867a0e9dee).(moduleChannel_tcxx . . $ moduleChannel_t# *ch)
514 {
515 if ((ch->n_cmdcxx . . $ moduleChannel_t#n_cmd. & 0xFF) > 0)
516 {
517 if (editorcxx . . $ editor..timingModecxx . . $ editor_t#timingMode. == TEMPO_MODE_VBLANKcxx . . $ TEMPO_MODE_VBLANK. || (ch->n_cmdcxx . . $ moduleChannel_t#n_cmd. & 0xFF) < 32)
518 modSetSpeedcxx . . $ modSetSpeed(d4f767463ce0a6b3).(ch->n_cmdcxx . . $ moduleChannel_t#n_cmd. & 0xFF);
519 else
520 ciaSetBPMcxx . . $ ciaSetBPM. = ch->n_cmdcxx . . $ moduleChannel_t#n_cmd. & 0xFF; // the CIA chip doesn't use its new timer value until the next interrupt, so change it later
521 }
522 else
523 {
524 // F00 - stop song
525 doStopSongcxx . . $ doStopSong. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
526 }
527 }
528
529 static void arpeggiocxx . . $ arpeggio(252f18867a0e9dee).(moduleChannel_tcxx . . $ moduleChannel_t# *ch)
530 {
531 int32_tcxx . . $ int32_t# arpNote;
532
533 const uint32_tcxx . . $ uint32_t# voiceAddr = 0xDFF0A0 + (ch->n_chanindexcxx . . $ moduleChannel_t#n_chanindex. * 16);
534
535 int32_tcxx . . $ int32_t# arpTick = songcxx . . $ song.->tickcxx . . $ module_t#tick. % 3; // 0, 1, 2
536 if (arpTick == 1)
537 {
538 arpNote = ch->n_cmdcxx . . $ moduleChannel_t#n_cmd. >> 4;
539 }
540 else if (arpTick == 2)
541 {
542 arpNote = ch->n_cmdcxx . . $ moduleChannel_t#n_cmd. & 0xF;
543 }
544 else // arpTick 0
545 {
546 // set voice period
547 paulaWriteWordcxx . . $ paulaWriteWord(272d193675e92631).(voiceAddr + 6, ch->n_periodcxx . . $ moduleChannel_t#n_period.);
548
549 setVisualsPeriodcxx . . $ setVisualsPeriod(a7050f1a4cb56049).(ch->n_chanindexcxx . . $ moduleChannel_t#n_chanindex., ch->n_periodcxx . . $ moduleChannel_t#n_period.);
550
551 return;
552 }
553
554 /* 8bitbubsy: If the finetune is -1, this can overflow up to
555 ** 15 words outside of the table. The table is padded with
556 ** the correct overflow values to allow this to safely happen
557 ** and sound correct at the same time.
558 */
559 const int16_tcxx . . $ int16_t# *periods = &periodTablecxx . . $ periodTable.[ch->n_finetunecxx . . $ moduleChannel_t#n_finetune. * 37];
560 for (int32_tcxx . . $ int32_t# baseNote = 0; baseNote < 37; baseNote++)
561 {
562 if (ch->n_periodcxx . . $ moduleChannel_t#n_period. >= periods[baseNote])
563 {
564 // set voice period
565 paulaWriteWordcxx . . $ paulaWriteWord(272d193675e92631).(voiceAddr + 6, periods[baseNote+arpNote]);
566
567 setVisualsPeriodcxx . . $ setVisualsPeriod(a7050f1a4cb56049).(ch->n_chanindexcxx . . $ moduleChannel_t#n_chanindex., periods[baseNote+arpNote]);
568
569 break;
570 }
571 }
572 }
573
574 static void portaUpcxx . . $ portaUp(252f18867a0e9dee).(moduleChannel_tcxx . . $ moduleChannel_t# *ch)
575 {
576 ch->n_periodcxx . . $ moduleChannel_t#n_period. -= (ch->n_cmdcxx . . $ moduleChannel_t#n_cmd. & 0xFF) & lowMaskcxx . . $ lowMask.;
577 lowMaskcxx . . $ lowMask. = 0xFF;
578
579 if ((ch->n_periodcxx . . $ moduleChannel_t#n_period. & 0xFFF) < 113) // PT BUG: sign removed before comparison, underflow not clamped!
580 ch->n_periodcxx . . $ moduleChannel_t#n_period. = (ch->n_periodcxx . . $ moduleChannel_t#n_period. & 0xF000) | 113;
581
582 // set voice period
583 const uint32_tcxx . . $ uint32_t# voiceAddr = 0xDFF0A0 + (ch->n_chanindexcxx . . $ moduleChannel_t#n_chanindex. * 16);
584 paulaWriteWordcxx . . $ paulaWriteWord(272d193675e92631).(voiceAddr + 6, ch->n_periodcxx . . $ moduleChannel_t#n_period. & 0xFFF);
585
586 setVisualsPeriodcxx . . $ setVisualsPeriod(a7050f1a4cb56049).(ch->n_chanindexcxx . . $ moduleChannel_t#n_chanindex., ch->n_periodcxx . . $ moduleChannel_t#n_period. & 0xFFF);
587 }
588
589 static void portaDowncxx . . $ portaDown(252f18867a0e9dee).(moduleChannel_tcxx . . $ moduleChannel_t# *ch)
590 {
591 ch->n_periodcxx . . $ moduleChannel_t#n_period. += (ch->n_cmdcxx . . $ moduleChannel_t#n_cmd. & 0xFF) & lowMaskcxx . . $ lowMask.;
592 lowMaskcxx . . $ lowMask. = 0xFF;
593
594 if ((ch->n_periodcxx . . $ moduleChannel_t#n_period. & 0xFFF) > 856)
595 ch->n_periodcxx . . $ moduleChannel_t#n_period. = (ch->n_periodcxx . . $ moduleChannel_t#n_period. & 0xF000) | 856;
596
597 // set voice period
598 const uint32_tcxx . . $ uint32_t# voiceAddr = 0xDFF0A0 + (ch->n_chanindexcxx . . $ moduleChannel_t#n_chanindex. * 16);
599 paulaWriteWordcxx . . $ paulaWriteWord(272d193675e92631).(voiceAddr + 6, ch->n_periodcxx . . $ moduleChannel_t#n_period. & 0xFFF);
600
601 setVisualsPeriodcxx . . $ setVisualsPeriod(a7050f1a4cb56049).(ch->n_chanindexcxx . . $ moduleChannel_t#n_chanindex., ch->n_periodcxx . . $ moduleChannel_t#n_period. & 0xFFF);
602 }
603
604 static void filterOnOffcxx . . $ filterOnOff(252f18867a0e9dee).(moduleChannel_tcxx . . $ moduleChannel_t# *ch)
605 {
606 if (songcxx . . $ song.->tickcxx . . $ module_t#tick. == 0) // added this (just pointless to call this during all ticks!)
607 {
608 const boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! filterOn = (ch->n_cmdcxx . . $ moduleChannel_t#n_cmd. & 1) ^ 1;
609
610 // set "LED" filter
611 paulaWriteBytecxx . . $ paulaWriteByte(cc289a6b3dfc48da).(0xBFE001, filterOn << 1);
612 audiocxx . . $ audio..ledFilterEnabledcxx . . $ audio_t#ledFilterEnabled. = filterOn;
613 }
614 }
615
616 static void finePortaUpcxx . . $ finePortaUp(252f18867a0e9dee).(moduleChannel_tcxx . . $ moduleChannel_t# *ch)
617 {
618 if (songcxx . . $ song.->tickcxx . . $ module_t#tick. == 0)
619 {
620 lowMaskcxx . . $ lowMask. = 0xF;
621 portaUpcxx . . $ portaUp(252f18867a0e9dee).(ch);
622 }
623 }
624
625 static void finePortaDowncxx . . $ finePortaDown(252f18867a0e9dee).(moduleChannel_tcxx . . $ moduleChannel_t# *ch)
626 {
627 if (songcxx . . $ song.->tickcxx . . $ module_t#tick. == 0)
628 {
629 lowMaskcxx . . $ lowMask. = 0xF;
630 portaDowncxx . . $ portaDown(252f18867a0e9dee).(ch);
631 }
632 }
633
634 static void setTonePortacxx . . $ setTonePorta(252f18867a0e9dee).(moduleChannel_tcxx . . $ moduleChannel_t# *ch)
635 {
636 uint16_tcxx . . $ uint16_t# note = ch->n_notecxx . . $ moduleChannel_t#n_note. & 0xFFF;
637 const int16_tcxx . . $ int16_t# *portaPointer = &periodTablecxx . . $ periodTable.[ch->n_finetunecxx . . $ moduleChannel_t#n_finetune. * 37];
638
639 int32_tcxx . . $ int32_t# i = 0;
640 while (truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!)
641 {
642 // portaPointer[36] = 0, so i=36 is safe
643 if (note >= portaPointer[i])
644 break;
645
646 if (++i >= 37)
647 {
648 i = 35;
649 break;
650 }
651 }
652
653 if ((ch->n_finetunecxx . . $ moduleChannel_t#n_finetune. & 8) && i > 0)
654 i--;
655
656 ch->n_wantedperiodcxx . . $ moduleChannel_t#n_wantedperiod. = portaPointer[i];
657 ch->n_toneportdireccxx . . $ moduleChannel_t#n_toneportdirec. = 0;
658
659 if (ch->n_periodcxx . . $ moduleChannel_t#n_period. == ch->n_wantedperiodcxx . . $ moduleChannel_t#n_wantedperiod.) ch->n_wantedperiodcxx . . $ moduleChannel_t#n_wantedperiod. = 0;
660 else if (ch->n_periodcxx . . $ moduleChannel_t#n_period. > ch->n_wantedperiodcxx . . $ moduleChannel_t#n_wantedperiod.) ch->n_toneportdireccxx . . $ moduleChannel_t#n_toneportdirec. = 1;
661 }
662
663 static void tonePortNoChangecxx . . $ tonePortNoChange(252f18867a0e9dee).(moduleChannel_tcxx . . $ moduleChannel_t# *ch)
664 {
665 if (ch->n_wantedperiodcxx . . $ moduleChannel_t#n_wantedperiod. <= 0)
666 return;
667
668 if (ch->n_toneportdireccxx . . $ moduleChannel_t#n_toneportdirec. > 0)
669 {
670 ch->n_periodcxx . . $ moduleChannel_t#n_period. -= ch->n_toneportspeedcxx . . $ moduleChannel_t#n_toneportspeed.;
671 if (ch->n_periodcxx . . $ moduleChannel_t#n_period. <= ch->n_wantedperiodcxx . . $ moduleChannel_t#n_wantedperiod.)
672 {
673 ch->n_periodcxx . . $ moduleChannel_t#n_period. = ch->n_wantedperiodcxx . . $ moduleChannel_t#n_wantedperiod.;
674 ch->n_wantedperiodcxx . . $ moduleChannel_t#n_wantedperiod. = 0;
675 }
676 }
677 else
678 {
679 ch->n_periodcxx . . $ moduleChannel_t#n_period. += ch->n_toneportspeedcxx . . $ moduleChannel_t#n_toneportspeed.;
680 if (ch->n_periodcxx . . $ moduleChannel_t#n_period. >= ch->n_wantedperiodcxx . . $ moduleChannel_t#n_wantedperiod.)
681 {
682 ch->n_periodcxx . . $ moduleChannel_t#n_period. = ch->n_wantedperiodcxx . . $ moduleChannel_t#n_wantedperiod.;
683 ch->n_wantedperiodcxx . . $ moduleChannel_t#n_wantedperiod. = 0;
684 }
685 }
686
687 const uint32_tcxx . . $ uint32_t# voiceAddr = 0xDFF0A0 + (ch->n_chanindexcxx . . $ moduleChannel_t#n_chanindex. * 16);
688
689 if ((ch->n_glissfunkcxx . . $ moduleChannel_t#n_glissfunk. & 0xF) == 0)
690 {
691 // set voice period
692 paulaWriteWordcxx . . $ paulaWriteWord(272d193675e92631).(voiceAddr + 6, ch->n_periodcxx . . $ moduleChannel_t#n_period.);
693
694 setVisualsPeriodcxx . . $ setVisualsPeriod(a7050f1a4cb56049).(ch->n_chanindexcxx . . $ moduleChannel_t#n_chanindex., ch->n_periodcxx . . $ moduleChannel_t#n_period.);
695 }
696 else
697 {
698 const int16_tcxx . . $ int16_t# *portaPointer = &periodTablecxx . . $ periodTable.[ch->n_finetunecxx . . $ moduleChannel_t#n_finetune. * 37];
699
700 int32_tcxx . . $ int32_t# i = 0;
701 while (truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!)
702 {
703 // portaPointer[36] = 0, so i=36 is safe
704 if (ch->n_periodcxx . . $ moduleChannel_t#n_period. >= portaPointer[i])
705 break;
706
707 if (++i >= 37)
708 {
709 i = 35;
710 break;
711 }
712 }
713
714 // set voice period
715 paulaWriteWordcxx . . $ paulaWriteWord(272d193675e92631).(voiceAddr + 6, portaPointer[i]);
716
717 setVisualsPeriodcxx . . $ setVisualsPeriod(a7050f1a4cb56049).(ch->n_chanindexcxx . . $ moduleChannel_t#n_chanindex., portaPointer[i]);
718 }
719 }
720
721 static void tonePortamentocxx . . $ tonePortamento(252f18867a0e9dee).(moduleChannel_tcxx . . $ moduleChannel_t# *ch)
722 {
723 if ((ch->n_cmdcxx . . $ moduleChannel_t#n_cmd. & 0xFF) > 0)
724 {
725 ch->n_toneportspeedcxx . . $ moduleChannel_t#n_toneportspeed. = ch->n_cmdcxx . . $ moduleChannel_t#n_cmd. & 0xFF;
726 ch->n_cmdcxx . . $ moduleChannel_t#n_cmd. &= 0xFF00;
727 }
728
729 tonePortNoChangecxx . . $ tonePortNoChange(252f18867a0e9dee).(ch);
730 }
731
732 static void vibrato2cxx . . $ vibrato2(252f18867a0e9dee).(moduleChannel_tcxx . . $ moduleChannel_t# *ch)
733 {
734 uint16_tcxx . . $ uint16_t# vibratoData;
735
736 const uint8_tcxx . . $ uint8_t# vibratoPos = (ch->n_vibratoposcxx . . $ moduleChannel_t#n_vibratopos. >> 2) & 0x1F;
737 const uint8_tcxx . . $ uint8_t# vibratoType = ch->n_wavecontrolcxx . . $ moduleChannel_t#n_wavecontrol. & 3;
738
739 if (vibratoType == 0) // sine
740 {
741 vibratoData = vibratoTablecxx . . $ vibratoTable.[vibratoPos];
742 }
743 else if (vibratoType == 1) // ramp
744 {
745 if (ch->n_vibratoposcxx . . $ moduleChannel_t#n_vibratopos. < 128)
746 vibratoData = vibratoPos << 3;
747 else
748 vibratoData = 255 - (vibratoPos << 3);
749 }
750 else // square
751 {
752 vibratoData = 255;
753 }
754
755 vibratoData = (vibratoData * (ch->n_vibratocmdcxx . . $ moduleChannel_t#n_vibratocmd. & 0xF)) >> 7;
756
757 if (ch->n_vibratoposcxx . . $ moduleChannel_t#n_vibratopos. < 128)
758 vibratoData = ch->n_periodcxx . . $ moduleChannel_t#n_period. + vibratoData;
759 else
760 vibratoData = ch->n_periodcxx . . $ moduleChannel_t#n_period. - vibratoData;
761
762 // set voice period
763 const uint32_tcxx . . $ uint32_t# voiceAddr = 0xDFF0A0 + (ch->n_chanindexcxx . . $ moduleChannel_t#n_chanindex. * 16);
764 paulaWriteWordcxx . . $ paulaWriteWord(272d193675e92631).(voiceAddr + 6, vibratoData);
765
766 setVisualsPeriodcxx . . $ setVisualsPeriod(a7050f1a4cb56049).(ch->n_chanindexcxx . . $ moduleChannel_t#n_chanindex., vibratoData);
767
768 ch->n_vibratoposcxx . . $ moduleChannel_t#n_vibratopos. += (ch->n_vibratocmdcxx . . $ moduleChannel_t#n_vibratocmd. >> 2) & 0x3C;
769 }
770
771 static void vibratocxx . . $ vibrato(252f18867a0e9dee).(moduleChannel_tcxx . . $ moduleChannel_t# *ch)
772 {
773 if ((ch->n_cmdcxx . . $ moduleChannel_t#n_cmd. & 0x0F) > 0)
774 ch->n_vibratocmdcxx . . $ moduleChannel_t#n_vibratocmd. = (ch->n_vibratocmdcxx . . $ moduleChannel_t#n_vibratocmd. & 0xF0) | (ch->n_cmdcxx . . $ moduleChannel_t#n_cmd. & 0x0F);
775
776 if ((ch->n_cmdcxx . . $ moduleChannel_t#n_cmd. & 0xF0) > 0)
777 ch->n_vibratocmdcxx . . $ moduleChannel_t#n_vibratocmd. = (ch->n_cmdcxx . . $ moduleChannel_t#n_cmd. & 0xF0) | (ch->n_vibratocmdcxx . . $ moduleChannel_t#n_vibratocmd. & 0x0F);
778
779 vibrato2cxx . . $ vibrato2(252f18867a0e9dee).(ch);
780 }
781
782 static void tonePlusVolSlidecxx . . $ tonePlusVolSlide(252f18867a0e9dee).(moduleChannel_tcxx . . $ moduleChannel_t# *ch)
783 {
784 tonePortNoChangecxx . . $ tonePortNoChange(252f18867a0e9dee).(ch);
785 volumeSlidecxx . . $ volumeSlide(252f18867a0e9dee).(ch);
786 }
787
788 static void vibratoPlusVolSlidecxx . . $ vibratoPlusVolSlide(252f18867a0e9dee).(moduleChannel_tcxx . . $ moduleChannel_t# *ch)
789 {
790 vibrato2cxx . . $ vibrato2(252f18867a0e9dee).(ch);
791 volumeSlidecxx . . $ volumeSlide(252f18867a0e9dee).(ch);
792 }
793
794 static void tremolocxx . . $ tremolo(252f18867a0e9dee).(moduleChannel_tcxx . . $ moduleChannel_t# *ch)
795 {
796 int16_tcxx . . $ int16_t# tremoloData;
797
798 if ((ch->n_cmdcxx . . $ moduleChannel_t#n_cmd. & 0x0F) > 0)
799 ch->n_tremolocmdcxx . . $ moduleChannel_t#n_tremolocmd. = (ch->n_tremolocmdcxx . . $ moduleChannel_t#n_tremolocmd. & 0xF0) | (ch->n_cmdcxx . . $ moduleChannel_t#n_cmd. & 0x0F);
800
801 if ((ch->n_cmdcxx . . $ moduleChannel_t#n_cmd. & 0xF0) > 0)
802 ch->n_tremolocmdcxx . . $ moduleChannel_t#n_tremolocmd. = (ch->n_cmdcxx . . $ moduleChannel_t#n_cmd. & 0xF0) | (ch->n_tremolocmdcxx . . $ moduleChannel_t#n_tremolocmd. & 0x0F);
803
804 const uint8_tcxx . . $ uint8_t# tremoloPos = (ch->n_tremoloposcxx . . $ moduleChannel_t#n_tremolopos. >> 2) & 0x1F;
805 const uint8_tcxx . . $ uint8_t# tremoloType = (ch->n_wavecontrolcxx . . $ moduleChannel_t#n_wavecontrol. >> 4) & 3;
806
807 if (tremoloType == 0) // sine
808 {
809 tremoloData = vibratoTablecxx . . $ vibratoTable.[tremoloPos];
810 }
811 else if (tremoloType == 1) // ramp
812 {
813 if (ch->n_vibratoposcxx . . $ moduleChannel_t#n_vibratopos. < 128) // PT bug, should've been ch->n_tremolopos
814 tremoloData = tremoloPos << 3;
815 else
816 tremoloData = 255 - (tremoloPos << 3);
817 }
818 else // square
819 {
820 tremoloData = 255;
821 }
822
823 tremoloData = ((uint16_tcxx . . $ uint16_t#)tremoloData * (ch->n_tremolocmdcxx . . $ moduleChannel_t#n_tremolocmd. & 0xF)) >> 6;
824
825 if (ch->n_tremoloposcxx . . $ moduleChannel_t#n_tremolopos. < 128)
826 {
827 tremoloData = ch->n_volumecxx . . $ moduleChannel_t#n_volume. + tremoloData;
828 if (tremoloData > 64)
829 tremoloData = 64;
830 }
831 else
832 {
833 tremoloData = ch->n_volumecxx . . $ moduleChannel_t#n_volume. - tremoloData;
834 if (tremoloData < 0)
835 tremoloData = 0;
836 }
837
838 // set voice volume
839 const uint32_tcxx . . $ uint32_t# voiceAddr = 0xDFF0A0 + (ch->n_chanindexcxx . . $ moduleChannel_t#n_chanindex. * 16);
840 paulaWriteWordcxx . . $ paulaWriteWord(272d193675e92631).(voiceAddr + 8, tremoloData);
841
842 setVisualsVolumecxx . . $ setVisualsVolume(a7050f1a4cb56049).(ch->n_chanindexcxx . . $ moduleChannel_t#n_chanindex., tremoloData);
843
844 ch->n_tremoloposcxx . . $ moduleChannel_t#n_tremolopos. += (ch->n_tremolocmdcxx . . $ moduleChannel_t#n_tremolocmd. >> 2) & 0x3C;
845 }
846
847 static void sampleOffsetcxx . . $ sampleOffset(252f18867a0e9dee).(moduleChannel_tcxx . . $ moduleChannel_t# *ch)
848 {
849 if ((ch->n_cmdcxx . . $ moduleChannel_t#n_cmd. & 0xFF) > 0)
850 ch->n_sampleoffsetcxx . . $ moduleChannel_t#n_sampleoffset. = ch->n_cmdcxx . . $ moduleChannel_t#n_cmd. & 0xFF;
851
852 const uint16_tcxx . . $ uint16_t# newOffset = ch->n_sampleoffsetcxx . . $ moduleChannel_t#n_sampleoffset. << 7;
853 if (newOffset < ch->n_lengthcxx . . $ moduleChannel_t#n_length.)
854 {
855 ch->n_lengthcxx . . $ moduleChannel_t#n_length. -= newOffset;
856 ch->n_startcxx . . $ moduleChannel_t#n_start. += newOffset << 1;
857 }
858 else
859 {
860 ch->n_lengthcxx . . $ moduleChannel_t#n_length. = 1;
861 }
862 }
863
864 static void E_Commandscxx . . $ E_Commands(252f18867a0e9dee).(moduleChannel_tcxx . . $ moduleChannel_t# *ch)
865 {
866 const uint8_tcxx . . $ uint8_t# ecmd = (ch->n_cmdcxx . . $ moduleChannel_t#n_cmd. & 0x00F0) >> 4;
867 switch (ecmd)
868 {
869 case 0x0: filterOnOffcxx . . $ filterOnOff(252f18867a0e9dee).(ch); return;
870 case 0x1: finePortaUpcxx . . $ finePortaUp(252f18867a0e9dee).(ch); return;
871 case 0x2: finePortaDowncxx . . $ finePortaDown(252f18867a0e9dee).(ch); return;
872 case 0x3: setGlissControlcxx . . $ setGlissControl(252f18867a0e9dee).(ch); return;
873 case 0x4: setVibratoControlcxx . . $ setVibratoControl(252f18867a0e9dee).(ch); return;
874 case 0x5: setFineTunecxx . . $ setFineTune(252f18867a0e9dee).(ch); return;
875 case 0x6: jumpLoopcxx . . $ jumpLoop(252f18867a0e9dee).(ch); return;
876 case 0x7: setTremoloControlcxx . . $ setTremoloControl(252f18867a0e9dee).(ch); return;
877 case 0x8: karplusStrongcxx . . $ karplusStrong(252f18867a0e9dee).(ch); return;
878 case 0xE: patternDelaycxx . . $ patternDelay(252f18867a0e9dee).(ch); return;
879 default: break;
880 }
881
882 if (editorcxx . . $ editor..mutedcxx . . $ editor_t#muted.[ch->n_chanindexcxx . . $ moduleChannel_t#n_chanindex.])
883 return;
884
885 switch (ecmd)
886 {
887 case 0x9: retrigNotecxx . . $ retrigNote(252f18867a0e9dee).(ch); return;
888 case 0xA: volumeFineUpcxx . . $ volumeFineUp(252f18867a0e9dee).(ch); return;
889 case 0xB: volumeFineDowncxx . . $ volumeFineDown(252f18867a0e9dee).(ch); return;
890 case 0xC: noteCutcxx . . $ noteCut(252f18867a0e9dee).(ch); return;
891 case 0xD: noteDelaycxx . . $ noteDelay(252f18867a0e9dee).(ch); return;
892 case 0xF: funkItcxx . . $ funkIt(252f18867a0e9dee).(ch); return;
893 default: break;
894 }
895 }
896
897 static void checkMoreEffectscxx . . $ checkMoreEffects(252f18867a0e9dee).(moduleChannel_tcxx . . $ moduleChannel_t# *ch)
898 {
899 const uint8_tcxx . . $ uint8_t# cmd = (ch->n_cmdcxx . . $ moduleChannel_t#n_cmd. & 0x0F00) >> 8;
900 switch (cmd)
901 {
902 case 0x9: sampleOffsetcxx . . $ sampleOffset(252f18867a0e9dee).(ch); return; // note the returns here, not breaks!
903 case 0xB: positionJumpcxx . . $ positionJump(252f18867a0e9dee).(ch); return;
904 case 0xD: patternBreakcxx . . $ patternBreak(252f18867a0e9dee).(ch); return;
905 case 0xE: E_Commandscxx . . $ E_Commands(252f18867a0e9dee).(ch); return;
906 case 0xF: setSpeedcxx . . $ setSpeed(252f18867a0e9dee).(ch); return;
907 default: break;
908 }
909
910 if (editorcxx . . $ editor..mutedcxx . . $ editor_t#muted.[ch->n_chanindexcxx . . $ moduleChannel_t#n_chanindex.])
911 return;
912
913 if (cmd == 0xC)
914 {
915 volumeChangecxx . . $ volumeChange(252f18867a0e9dee).(ch);
916 return;
917 }
918
919 // set voice period
920 const uint32_tcxx . . $ uint32_t# voiceAddr = 0xDFF0A0 + (ch->n_chanindexcxx . . $ moduleChannel_t#n_chanindex. * 16);
921 paulaWriteWordcxx . . $ paulaWriteWord(272d193675e92631).(voiceAddr + 6, ch->n_periodcxx . . $ moduleChannel_t#n_period.);
922
923 setVisualsPeriodcxx . . $ setVisualsPeriod(a7050f1a4cb56049).(ch->n_chanindexcxx . . $ moduleChannel_t#n_chanindex., ch->n_periodcxx . . $ moduleChannel_t#n_period.);
924 }
925
926 static void chkefx2cxx . . $ chkefx2(252f18867a0e9dee).(moduleChannel_tcxx . . $ moduleChannel_t# *ch)
927 {
928 updateFunkcxx . . $ updateFunk(252f18867a0e9dee).(ch);
929
930 if ((ch->n_cmdcxx . . $ moduleChannel_t#n_cmd. & 0xFFF) == 0)
931 return;
932
933 const uint8_tcxx . . $ uint8_t# cmd = (ch->n_cmdcxx . . $ moduleChannel_t#n_cmd. & 0x0F00) >> 8;
934 switch (cmd)
935 {
936 case 0x0: arpeggiocxx . . $ arpeggio(252f18867a0e9dee).(ch); return; // note the returns here, not breaks!
937 case 0x1: portaUpcxx . . $ portaUp(252f18867a0e9dee).(ch); return;
938 case 0x2: portaDowncxx . . $ portaDown(252f18867a0e9dee).(ch); return;
939 case 0x3: tonePortamentocxx . . $ tonePortamento(252f18867a0e9dee).(ch); return;
940 case 0x4: vibratocxx . . $ vibrato(252f18867a0e9dee).(ch); return;
941 case 0x5: tonePlusVolSlidecxx . . $ tonePlusVolSlide(252f18867a0e9dee).(ch); return;
942 case 0x6: vibratoPlusVolSlidecxx . . $ vibratoPlusVolSlide(252f18867a0e9dee).(ch); return;
943 case 0xE: E_Commandscxx . . $ E_Commands(252f18867a0e9dee).(ch); return;
944 default: break;
945 }
946
947 // set voice period
948 const uint32_tcxx . . $ uint32_t# voiceAddr = 0xDFF0A0 + (ch->n_chanindexcxx . . $ moduleChannel_t#n_chanindex. * 16);
949 paulaWriteWordcxx . . $ paulaWriteWord(272d193675e92631).(voiceAddr + 6, ch->n_periodcxx . . $ moduleChannel_t#n_period.);
950
951 setVisualsPeriodcxx . . $ setVisualsPeriod(a7050f1a4cb56049).(ch->n_chanindexcxx . . $ moduleChannel_t#n_chanindex., ch->n_periodcxx . . $ moduleChannel_t#n_period.);
952
953 if (cmd == 0x7)
954 tremolocxx . . $ tremolo(252f18867a0e9dee).(ch);
955 else if (cmd == 0xA)
956 volumeSlidecxx . . $ volumeSlide(252f18867a0e9dee).(ch);
957 }
958
959 static void checkEffectscxx . . $ checkEffects(252f18867a0e9dee).(moduleChannel_tcxx . . $ moduleChannel_t# *ch)
960 {
961 if (editorcxx . . $ editor..mutedcxx . . $ editor_t#muted.[ch->n_chanindexcxx . . $ moduleChannel_t#n_chanindex.])
962 return;
963
964 chkefx2cxx . . $ chkefx2(252f18867a0e9dee).(ch);
965
966 /* This is not very clear in the original PT replayer code,
967 ** but the tremolo effect skips chkefx2()'s return address
968 ** in the stack so that it jumps to checkEffects()'s return
969 ** address instead of ending up here. In other words, volume
970 ** is not updated here after tremolo (it's done inside the
971 ** tremolo routine itself).
972 */
973 const uint8_tcxx . . $ uint8_t# cmd = (ch->n_cmdcxx . . $ moduleChannel_t#n_cmd. & 0x0F00) >> 8;
974 if (cmd != 0x7)
975 {
976 // set voice volume
977 const uint32_tcxx . . $ uint32_t# voiceAddr = 0xDFF0A0 + (ch->n_chanindexcxx . . $ moduleChannel_t#n_chanindex. * 16);
978 paulaWriteWordcxx . . $ paulaWriteWord(272d193675e92631).(voiceAddr + 8, ch->n_volumecxx . . $ moduleChannel_t#n_volume.);
979
980 setVisualsVolumecxx . . $ setVisualsVolume(a7050f1a4cb56049).(ch->n_chanindexcxx . . $ moduleChannel_t#n_chanindex., ch->n_volumecxx . . $ moduleChannel_t#n_volume.);
981 }
982 }
983
984 static void setPeriodcxx . . $ setPeriod(252f18867a0e9dee).(moduleChannel_tcxx . . $ moduleChannel_t# *ch)
985 {
986 int32_tcxx . . $ int32_t# i;
987
988 uint16_tcxx . . $ uint16_t# note = ch->n_notecxx . . $ moduleChannel_t#n_note. & 0xFFF;
989 for (i = 0; i < 37; i++)
990 {
991 // periodTable[36] = 0, so i=36 is safe
992 if (note >= periodTablecxx . . $ periodTable.[i])
993 break;
994 }
995
996 // yes it's safe if i=37 because of zero-padding
997 ch->n_periodcxx . . $ moduleChannel_t#n_period. = periodTablecxx . . $ periodTable.[(ch->n_finetunecxx . . $ moduleChannel_t#n_finetune. * 37) + i];
998
999 if ((ch->n_cmdcxx . . $ moduleChannel_t#n_cmd. & 0xFF0) != 0xED0) // no note delay
1000 {
1001 // voice DMA off (turned on in setDMA() later)
1002 paulaWriteWordcxx . . $ paulaWriteWord(272d193675e92631).(0xDFF096, ch->n_dmabitcxx . . $ moduleChannel_t#n_dmabit.);
1003
1004 if ((ch->n_wavecontrolcxx . . $ moduleChannel_t#n_wavecontrol. & 0x04) == 0) ch->n_vibratoposcxx . . $ moduleChannel_t#n_vibratopos. = 0;
1005 if ((ch->n_wavecontrolcxx . . $ moduleChannel_t#n_wavecontrol. & 0x40) == 0) ch->n_tremoloposcxx . . $ moduleChannel_t#n_tremolopos. = 0;
1006
1007 const uint32_tcxx . . $ uint32_t# voiceAddr = 0xDFF0A0 + (ch->n_chanindexcxx . . $ moduleChannel_t#n_chanindex. * 16);
1008
1009 // set voice data length and data ptr
1010 paulaWriteWordcxx . . $ paulaWriteWord(272d193675e92631).(voiceAddr + 4, ch->n_lengthcxx . . $ moduleChannel_t#n_length.);
1011 paulaWritePtrcxx . . $ paulaWritePtr(8ed931be62ea155e).(voiceAddr + 0, ch->n_startcxx . . $ moduleChannel_t#n_start.);
1012
1013 if (ch->n_startcxx . . $ moduleChannel_t#n_start. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
1014 {
1015 ch->n_loopstartcxx . . $ moduleChannel_t#n_loopstart. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
1016 paulaWriteWordcxx . . $ paulaWriteWord(272d193675e92631).(voiceAddr + 4, 1); // length
1017 ch->n_replencxx . . $ moduleChannel_t#n_replen. = 1;
1018 }
1019
1020 // set voice period
1021 paulaWriteWordcxx . . $ paulaWriteWord(272d193675e92631).(voiceAddr + 6, ch->n_periodcxx . . $ moduleChannel_t#n_period.);
1022
1023 DMACONtempcxx . . $ DMACONtemp. |= ch->n_dmabitcxx . . $ moduleChannel_t#n_dmabit.;
1024
1025 // update tracker visuals
1026
1027 setVisualsDMACONcxx . . $ setVisualsDMACON(ed53e3bbd3fa2f69).(ch->n_dmabitcxx . . $ moduleChannel_t#n_dmabit.);
1028
1029 setVisualsLengthcxx . . $ setVisualsLength(a7050f1a4cb56049).(ch->n_chanindexcxx . . $ moduleChannel_t#n_chanindex., ch->n_lengthcxx . . $ moduleChannel_t#n_length.);
1030 setVisualsDataPtrcxx . . $ setVisualsDataPtr(70eb3de2aab3469c).(ch->n_chanindexcxx . . $ moduleChannel_t#n_chanindex., ch->n_startcxx . . $ moduleChannel_t#n_start.);
1031
1032 if (ch->n_startcxx . . $ moduleChannel_t#n_start. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
1033 setVisualsLengthcxx . . $ setVisualsLength(a7050f1a4cb56049).(ch->n_chanindexcxx . . $ moduleChannel_t#n_chanindex., 1);
1034
1035 setVisualsPeriodcxx . . $ setVisualsPeriod(a7050f1a4cb56049).(ch->n_chanindexcxx . . $ moduleChannel_t#n_chanindex., ch->n_periodcxx . . $ moduleChannel_t#n_period.);
1036
1037 // set spectrum analyzer state for this channel
1038 if (!editorcxx . . $ editor..mutedcxx . . $ editor_t#muted.[ch->n_chanindexcxx . . $ moduleChannel_t#n_chanindex.])
1039 {
1040 ch->syncAnalyzerVolumecxx . . $ moduleChannel_t#syncAnalyzerVolume. = ch->n_volumecxx . . $ moduleChannel_t#n_volume.;
1041 ch->syncAnalyzerPeriodcxx . . $ moduleChannel_t#syncAnalyzerPeriod. = ch->n_periodcxx . . $ moduleChannel_t#n_period.;
1042 ch->syncFlagscxx . . $ moduleChannel_t#syncFlags. |= UPDATE_SPECTRUM_ANALYZERcxx . . $ UPDATE_SPECTRUM_ANALYZER.;
1043 }
1044 }
1045
1046 checkMoreEffectscxx . . $ checkMoreEffects(252f18867a0e9dee).(ch);
1047 }
1048
1049 static void checkMetronomecxx . . $ checkMetronome(e32629acb5a4f44f).(moduleChannel_tcxx . . $ moduleChannel_t# *ch, note_tcxx . . $ note_t# *note)
1050 {
1051 if (editorcxx . . $ editor..metroFlagcxx . . $ editor_t#metroFlag. && editorcxx . . $ editor..metroChannelcxx . . $ editor_t#metroChannel. > 0)
1052 {
1053 if (ch->n_chanindexcxx . . $ moduleChannel_t#n_chanindex. == (uint32_tcxx . . $ uint32_t#)editorcxx . . $ editor..metroChannelcxx . . $ editor_t#metroChannel.-1 && (songcxx . . $ song.->rowcxx . . $ module_t#row. % editorcxx . . $ editor..metroSpeedcxx . . $ editor_t#metroSpeed.) == 0)
1054 {
1055 note->samplecxx . . $ note_t#sample. = 31;
1056 note->periodcxx . . $ note_t#period. = (((songcxx . . $ song.->rowcxx . . $ module_t#row. / editorcxx . . $ editor..metroSpeedcxx . . $ editor_t#metroSpeed.) % editorcxx . . $ editor..metroSpeedcxx . . $ editor_t#metroSpeed.) == 0) ? 160 : 214;
1057 }
1058 }
1059 }
1060
1061 static void playVoicecxx . . $ playVoice(252f18867a0e9dee).(moduleChannel_tcxx . . $ moduleChannel_t# *ch)
1062 {
1063 if (ch->n_notecxx . . $ moduleChannel_t#n_note. == 0 && ch->n_cmdcxx . . $ moduleChannel_t#n_cmd. == 0) // test period, command and command parameter
1064 {
1065 // set voice period
1066 const uint32_tcxx . . $ uint32_t# voiceAddr = 0xDFF0A0 + (ch->n_chanindexcxx . . $ moduleChannel_t#n_chanindex. * 16);
1067 paulaWriteWordcxx . . $ paulaWriteWord(272d193675e92631).(voiceAddr + 6, ch->n_periodcxx . . $ moduleChannel_t#n_period.);
1068
1069 setVisualsPeriodcxx . . $ setVisualsPeriod(a7050f1a4cb56049).(ch->n_chanindexcxx . . $ moduleChannel_t#n_chanindex., ch->n_periodcxx . . $ moduleChannel_t#n_period.);
1070 }
1071
1072 note_tcxx . . $ note_t# note = songcxx . . $ song.->patternscxx . . $ module_t#patterns.[modPatterncxx . . $ modPattern.][(songcxx . . $ song.->rowcxx . . $ module_t#row. * PAULA_VOICEScxx . . $ `src/pt2_paula.h:13:9`!) + ch->n_chanindexcxx . . $ moduleChannel_t#n_chanindex.];
1073
1074 checkMetronomecxx . . $ checkMetronome(e32629acb5a4f44f).(ch, &note);
1075
1076 ch->n_notecxx . . $ moduleChannel_t#n_note. = note.periodcxx . . $ note_t#period.;
1077 ch->n_cmdcxx . . $ moduleChannel_t#n_cmd. = (note.commandcxx . . $ note_t#command. << 8) | note.paramcxx . . $ note_t#param.;
1078
1079 if (note.samplecxx . . $ note_t#sample. >= 1 && note.samplecxx . . $ note_t#sample. <= 31) // SAFETY BUG FIX: don't handle sample-numbers >31
1080 {
1081 ch->n_samplenumcxx . . $ moduleChannel_t#n_samplenum. = note.samplecxx . . $ note_t#sample. - 1;
1082 moduleSample_tcxx . . $ moduleSample_t# *s = &songcxx . . $ song.->samplescxx . . $ module_t#samples.[ch->n_samplenumcxx . . $ moduleChannel_t#n_samplenum.];
1083
1084 ch->n_startcxx . . $ moduleChannel_t#n_start. = &songcxx . . $ song.->sampleDatacxx . . $ module_t#sampleData.[s->offsetcxx . . $ moduleSample_t#offset.];
1085 ch->n_finetunecxx . . $ moduleChannel_t#n_finetune. = s->fineTunecxx . . $ moduleSample_t#fineTune. & 0xF;
1086 ch->n_volumecxx . . $ moduleChannel_t#n_volume. = s->volumecxx . . $ moduleSample_t#volume.;
1087 ch->n_lengthcxx . . $ moduleChannel_t#n_length. = (uint16_tcxx . . $ uint16_t#)(s->lengthcxx . . $ moduleSample_t#length. >> 1);
1088 ch->n_replencxx . . $ moduleChannel_t#n_replen. = (uint16_tcxx . . $ uint16_t#)(s->loopLengthcxx . . $ moduleSample_t#loopLength. >> 1);
1089
1090 const uint16_tcxx . . $ uint16_t# repeat = (uint16_tcxx . . $ uint16_t#)(s->loopStartcxx . . $ moduleSample_t#loopStart. >> 1);
1091 if (repeat > 0)
1092 {
1093 ch->n_loopstartcxx . . $ moduleChannel_t#n_loopstart. = ch->n_startcxx . . $ moduleChannel_t#n_start. + (repeat << 1);
1094 ch->n_wavestartcxx . . $ moduleChannel_t#n_wavestart. = ch->n_loopstartcxx . . $ moduleChannel_t#n_loopstart.;
1095 ch->n_lengthcxx . . $ moduleChannel_t#n_length. = repeat + ch->n_replencxx . . $ moduleChannel_t#n_replen.;
1096 }
1097 else
1098 {
1099 ch->n_loopstartcxx . . $ moduleChannel_t#n_loopstart. = ch->n_startcxx . . $ moduleChannel_t#n_start.;
1100 ch->n_wavestartcxx . . $ moduleChannel_t#n_wavestart. = ch->n_startcxx . . $ moduleChannel_t#n_start.;
1101 }
1102
1103 // non-PT2 requirement (set safe sample space for uninitialized voices - f.ex. "the ultimate beeper.mod")
1104 if (ch->n_lengthcxx . . $ moduleChannel_t#n_length. == 0)
1105 ch->n_loopstartcxx . . $ moduleChannel_t#n_loopstart. = ch->n_wavestartcxx . . $ moduleChannel_t#n_wavestart. = paulaGetNullSamplePtrcxx . . $ paulaGetNullSamplePtr(d09b239063734497).();
1106 }
1107
1108 if ((ch->n_notecxx . . $ moduleChannel_t#n_note. & 0xFFF) > 0)
1109 {
1110 if ((ch->n_cmdcxx . . $ moduleChannel_t#n_cmd. & 0xFF0) == 0xE50) // set finetune
1111 {
1112 setFineTunecxx . . $ setFineTune(252f18867a0e9dee).(ch);
1113 setPeriodcxx . . $ setPeriod(252f18867a0e9dee).(ch);
1114 }
1115 else
1116 {
1117 uint8_tcxx . . $ uint8_t# cmd = (ch->n_cmdcxx . . $ moduleChannel_t#n_cmd. & 0x0F00) >> 8;
1118 if (cmd == 3 || cmd == 5)
1119 {
1120 setVUMeterHeightcxx . . $ setVUMeterHeight(252f18867a0e9dee).(ch);
1121 setTonePortacxx . . $ setTonePorta(252f18867a0e9dee).(ch);
1122 checkMoreEffectscxx . . $ checkMoreEffects(252f18867a0e9dee).(ch);
1123 }
1124 else if (cmd == 9)
1125 {
1126 checkMoreEffectscxx . . $ checkMoreEffects(252f18867a0e9dee).(ch);
1127 setPeriodcxx . . $ setPeriod(252f18867a0e9dee).(ch);
1128 }
1129 else
1130 {
1131 setPeriodcxx . . $ setPeriod(252f18867a0e9dee).(ch);
1132 }
1133 }
1134 }
1135 else
1136 {
1137 checkMoreEffectscxx . . $ checkMoreEffects(252f18867a0e9dee).(ch);
1138 }
1139 }
1140
1141 static void updateUIPositionscxx . . $ updateUIPositions(49f6e7a06ebc5aa8).(void)
1142 {
1143 if (editorcxx . . $ editor..mod2WavOngoingcxx . . $ editor_t#mod2WavOngoing. || editorcxx . . $ editor..pat2SmpOngoingcxx . . $ editor_t#pat2SmpOngoing.)
1144 return; // don't update UI under MOD2WAV/PAT2SMP rendering
1145
1146 songcxx . . $ song.->currRowcxx . . $ module_t#currRow. = songcxx . . $ song.->rowcxx . . $ module_t#row.;
1147 songcxx . . $ song.->currPoscxx . . $ module_t#currPos. = modPoscxx . . $ modPos.;
1148 songcxx . . $ song.->currPatterncxx . . $ module_t#currPattern. = modPatterncxx . . $ modPattern.;
1149
1150 uint16_tcxx . . $ uint16_t# *currPatPtr = &songcxx . . $ song.->headercxx . . $ module_t#header..patternTablecxx . . $ moduleHeader_t#patternTable.[modPoscxx . . $ modPos.];
1151 editorcxx . . $ editor..currPatternDispcxx . . $ editor_t#currPatternDisp. = currPatPtr;
1152 editorcxx . . $ editor..currPosEdPattDispcxx . . $ editor_t#currPosEdPattDisp. = currPatPtr;
1153 editorcxx . . $ editor..currPatternDispcxx . . $ editor_t#currPatternDisp. = currPatPtr;
1154 editorcxx . . $ editor..currPosEdPattDispcxx . . $ editor_t#currPosEdPattDisp. = currPatPtr;
1155
1156 uicxx . . $ ui..updateSongPoscxx . . $ ui_t#updateSongPos. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
1157 uicxx . . $ ui..updateSongPatterncxx . . $ ui_t#updateSongPattern. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
1158 uicxx . . $ ui..updateCurrPattTextcxx . . $ ui_t#updateCurrPattText. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
1159 uicxx . . $ ui..updatePatternDatacxx . . $ ui_t#updatePatternData. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
1160
1161 if (uicxx . . $ ui..posEdScreenShowncxx . . $ ui_t#posEdScreenShown.)
1162 uicxx . . $ ui..updatePosEdcxx . . $ ui_t#updatePosEd. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
1163 }
1164
1165 static void nextPositioncxx . . $ nextPosition(49f6e7a06ebc5aa8).(void)
1166 {
1167 if (editorcxx . . $ editor..pat2SmpOngoingcxx . . $ editor_t#pat2SmpOngoing.)
1168 modRenderDonecxx . . $ modRenderDone. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
1169
1170 songcxx . . $ song.->rowcxx . . $ module_t#row. = pBreakPositioncxx . . $ pBreakPosition.;
1171 pBreakPositioncxx . . $ pBreakPosition. = 0;
1172 posJumpAssertcxx . . $ posJumpAssert. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
1173
1174 if (editorcxx . . $ editor..playModecxx . . $ editor_t#playMode. != PLAY_MODE_PATTERNcxx . . $ PLAY_MODE_PATTERN. ||
1175 (editorcxx . . $ editor..currModecxx . . $ editor_t#currMode. == MODE_RECORDcxx . . $ MODE_RECORD. && editorcxx . . $ editor..recordModecxx . . $ editor_t#recordMode. != RECORD_PATTcxx . . $ RECORD_PATT.))
1176 {
1177 if (editorcxx . . $ editor..stepPlayEnabledcxx . . $ editor_t#stepPlayEnabled.)
1178 {
1179 if (configcxx . . $ config..keepEditModeAfterStepPlaycxx . . $ config_t#keepEditModeAfterStepPlay. && editorcxx . . $ editor..stepPlayLastModecxx . . $ editor_t#stepPlayLastMode. == MODE_EDITcxx . . $ MODE_EDIT.)
1180 {
1181 doStopItcxx . . $ doStopIt(b45ddcbc8423892c).(falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!);
1182
1183 editorcxx . . $ editor..playModecxx . . $ editor_t#playMode. = PLAY_MODE_NORMALcxx . . $ PLAY_MODE_NORMAL.;
1184 editorcxx . . $ editor..currModecxx . . $ editor_t#currMode. = MODE_EDITcxx . . $ MODE_EDIT.;
1185 pointerSetModeThreadSafecxx . . $ pointerSetModeThreadSafe(f2ac3508b56cd10).(POINTER_MODE_EDITcxx . . $ POINTER_MODE_EDIT., truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!);
1186 }
1187 else
1188 {
1189 doStopItcxx . . $ doStopIt(b45ddcbc8423892c).(truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!);
1190 }
1191
1192 editorcxx . . $ editor..stepPlayEnabledcxx . . $ editor_t#stepPlayEnabled. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
1193 editorcxx . . $ editor..stepPlayBackwardscxx . . $ editor_t#stepPlayBackwards. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
1194
1195 if (editorcxx . . $ editor..stepPlayLastModecxx . . $ editor_t#stepPlayLastMode. == MODE_EDITcxx . . $ MODE_EDIT. || editorcxx . . $ editor..stepPlayLastModecxx . . $ editor_t#stepPlayLastMode. == MODE_IDLEcxx . . $ MODE_IDLE.)
1196 {
1197 songcxx . . $ song.->rowcxx . . $ module_t#row. &= 63;
1198 songcxx . . $ song.->currRowcxx . . $ module_t#currRow. = songcxx . . $ song.->rowcxx . . $ module_t#row.;
1199 }
1200 else
1201 {
1202 // if we were playing, set replayer row to tracker row (stay in sync)
1203 songcxx . . $ song.->currRowcxx . . $ module_t#currRow. &= 63;
1204 songcxx . . $ song.->rowcxx . . $ module_t#row. = songcxx . . $ song.->currRowcxx . . $ module_t#currRow.;
1205 }
1206
1207 return;
1208 }
1209
1210 modPoscxx . . $ modPos. = (modPoscxx . . $ modPos. + 1) & 127;
1211 if (modPoscxx . . $ modPos. >= songcxx . . $ song.->headercxx . . $ module_t#header..songLengthcxx . . $ moduleHeader_t#songLength.)
1212 {
1213 modPoscxx . . $ modPos. = 0;
1214
1215 if (configcxx . . $ config..compoModecxx . . $ config_t#compoMode.) // stop song for music competitions playing
1216 {
1217 doStopItcxx . . $ doStopIt(b45ddcbc8423892c).(truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!);
1218 turnOffVoicescxx . . $ turnOffVoices(49f6e7a06ebc5aa8).();
1219
1220 modPoscxx . . $ modPos. = 0;
1221 modPatterncxx . . $ modPattern. = (int8_tcxx . . $ int8_t#)songcxx . . $ song.->headercxx . . $ module_t#header..patternTablecxx . . $ moduleHeader_t#patternTable.[modPoscxx . . $ modPos.];
1222 songcxx . . $ song.->rowcxx . . $ module_t#row. = 0;
1223
1224 updateUIPositionscxx . . $ updateUIPositions(49f6e7a06ebc5aa8).();
1225 }
1226
1227 if (editorcxx . . $ editor..mod2WavOngoingcxx . . $ editor_t#mod2WavOngoing.)
1228 modRenderDonecxx . . $ modRenderDone. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
1229 }
1230
1231 modPatterncxx . . $ modPattern. = (int8_tcxx . . $ int8_t#)songcxx . . $ song.->headercxx . . $ module_t#header..patternTablecxx . . $ moduleHeader_t#patternTable.[modPoscxx . . $ modPos.];
1232 if (modPatterncxx . . $ modPattern. > MAX_PATTERNScxx . . $ `src/pt2_header.h:75:9`!-1)
1233 modPatterncxx . . $ modPattern. = MAX_PATTERNScxx . . $ `src/pt2_header.h:75:9`!-1;
1234 }
1235 }
1236
1237 static void increasePlaybackTimercxx . . $ increasePlaybackTimer(49f6e7a06ebc5aa8).(void)
1238 {
1239 // (the timer is not counting in "play pattern" mode)
1240 if (editorcxx . . $ editor..playModecxx . . $ editor_t#playMode. != PLAY_MODE_PATTERNcxx . . $ PLAY_MODE_PATTERN. && modBPMcxx . . $ modBPM. >= MIN_BPMcxx . . $ `src/pt2_replayer.h:7:9`! && modBPMcxx . . $ modBPM. <= MAX_BPMcxx . . $ `src/pt2_replayer.h:8:9`!)
1241 {
1242 if (editorcxx . . $ editor..timingModecxx . . $ editor_t#timingMode. == TEMPO_MODE_CIAcxx . . $ TEMPO_MODE_CIA.)
1243 editorcxx . . $ editor..playbackSecondsFraccxx . . $ editor_t#playbackSecondsFrac. += tickDuration31fpcxx . . $ tickDuration31fp.[modBPMcxx . . $ modBPM.-MIN_BPMcxx . . $ `src/pt2_replayer.h:7:9`!];
1244 else
1245 editorcxx . . $ editor..playbackSecondsFraccxx . . $ editor_t#playbackSecondsFrac. += tickDuration31fpcxx . . $ tickDuration31fp.[(MAX_BPMcxx . . $ `src/pt2_replayer.h:8:9`!-MIN_BPMcxx . . $ `src/pt2_replayer.h:7:9`!)+1]; // vblank tempo mode
1246
1247 if (editorcxx . . $ editor..playbackSecondsFraccxx . . $ editor_t#playbackSecondsFrac. > INT32_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:112:10`!)
1248 {
1249 editorcxx . . $ editor..playbackSecondsFraccxx . . $ editor_t#playbackSecondsFrac. &= INT32_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:112:10`!;
1250
1251 if (editorcxx . . $ editor..playbackSecondscxx . . $ editor_t#playbackSeconds. >= (99*60)+59) // wrap around 99:59 -> 00:00
1252 editorcxx . . $ editor..playbackSecondscxx . . $ editor_t#playbackSeconds. = 0;
1253 else
1254 editorcxx . . $ editor..playbackSecondscxx . . $ editor_t#playbackSeconds.++;
1255 }
1256 }
1257 }
1258
1259 static void setCurrRowToVisitedcxx . . $ setCurrRowToVisited(49f6e7a06ebc5aa8).(void) // for MOD2WAV
1260 {
1261 if (editorcxx . . $ editor..mod2WavOngoingcxx . . $ editor_t#mod2WavOngoing.)
1262 editorcxx . . $ editor..rowVisitTablecxx . . $ editor_t#rowVisitTable.[(modPoscxx . . $ modPos. * MOD_ROWScxx . . $ `src/pt2_header.h:73:9`!) + songcxx . . $ song.->rowcxx . . $ module_t#row.] = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
1263 }
1264
1265 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! renderEndCheckcxx . . $ renderEndCheck(c9857a73d68e59ba).(void) // for MOD2WAV/PAT2SMP
1266 {
1267 if (!editorcxx . . $ editor..mod2WavOngoingcxx . . $ editor_t#mod2WavOngoing. && !editorcxx . . $ editor..pat2SmpOngoingcxx . . $ editor_t#pat2SmpOngoing.)
1268 return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; // we're not doing MOD2WAV/PAT2SMP
1269
1270 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! noPatternDelay = (pattDelTime2cxx . . $ pattDelTime2. == 0);
1271 if (noPatternDelay)
1272 {
1273 if (editorcxx . . $ editor..pat2SmpOngoingcxx . . $ editor_t#pat2SmpOngoing.)
1274 {
1275 if (modRenderDonecxx . . $ modRenderDone.)
1276 return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; // we're done rendering
1277 }
1278
1279 if (editorcxx . . $ editor..mod2WavOngoingcxx . . $ editor_t#mod2WavOngoing. && songcxx . . $ song.->tickcxx . . $ module_t#tick. == songcxx . . $ song.->speedcxx . . $ module_t#speed.-1)
1280 {
1281 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! rowVisited = editorcxx . . $ editor..rowVisitTablecxx . . $ editor_t#rowVisitTable.[(modPoscxx . . $ modPos. * MOD_ROWScxx . . $ `src/pt2_header.h:73:9`!) + songcxx . . $ song.->rowcxx . . $ module_t#row.];
1282 if (rowVisited || modRenderDonecxx . . $ modRenderDone.)
1283 {
1284 modRenderDonecxx . . $ modRenderDone. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
1285 return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; // we're done rendering
1286 }
1287 }
1288 }
1289
1290 return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
1291 }
1292
1293 static void setDMAcxx . . $ setDMA(49f6e7a06ebc5aa8).(void)
1294 {
1295 if (editorcxx . . $ editor..mutedcxx . . $ editor_t#muted.[0]) DMACONtempcxx . . $ DMACONtemp. &= ~1;
1296 if (editorcxx . . $ editor..mutedcxx . . $ editor_t#muted.[1]) DMACONtempcxx . . $ DMACONtemp. &= ~2;
1297 if (editorcxx . . $ editor..mutedcxx . . $ editor_t#muted.[2]) DMACONtempcxx . . $ DMACONtemp. &= ~4;
1298 if (editorcxx . . $ editor..mutedcxx . . $ editor_t#muted.[3]) DMACONtempcxx . . $ DMACONtemp. &= ~8;
1299
1300 // start DMAs for selected voices
1301 paulaWriteWordcxx . . $ paulaWriteWord(272d193675e92631).(0xDFF096, 0x8000 | DMACONtempcxx . . $ DMACONtemp.);
1302
1303 setVisualsDMACONcxx . . $ setVisualsDMACON(ed53e3bbd3fa2f69).(0x8000 | DMACONtempcxx . . $ DMACONtemp.);
1304
1305 moduleChannel_tcxx . . $ moduleChannel_t# *ch = songcxx . . $ song.->channelscxx . . $ module_t#channels.;
1306 for (int32_tcxx . . $ int32_t# i = 0; i < PAULA_VOICEScxx . . $ `src/pt2_paula.h:13:9`!; i++, ch++)
1307 {
1308 if (DMACONtempcxx . . $ DMACONtemp. & ch->n_dmabitcxx . . $ moduleChannel_t#n_dmabit.) // handle visuals on sample trigger
1309 setVUMeterHeightcxx . . $ setVUMeterHeight(252f18867a0e9dee).(ch);
1310
1311 // set new voice data ptr and length (these take effect after the current DMA cycle is done)
1312 const uint32_tcxx . . $ uint32_t# voiceAddr = 0xDFF0A0 + (i * 16);
1313 paulaWritePtrcxx . . $ paulaWritePtr(8ed931be62ea155e).(voiceAddr + 0, ch->n_loopstartcxx . . $ moduleChannel_t#n_loopstart.);
1314 paulaWriteWordcxx . . $ paulaWriteWord(272d193675e92631).(voiceAddr + 4, ch->n_replencxx . . $ moduleChannel_t#n_replen.);
1315
1316 setVisualsDataPtrcxx . . $ setVisualsDataPtr(70eb3de2aab3469c).(i, ch->n_loopstartcxx . . $ moduleChannel_t#n_loopstart.);
1317 setVisualsLengthcxx . . $ setVisualsLength(a7050f1a4cb56049).(i, ch->n_replencxx . . $ moduleChannel_t#n_replen.);
1318 }
1319 }
1320
1321 void modSetTempocxx . . $ modSetTempo(918ebd27a9ddbad3).(int32_tcxx . . $ int32_t# bpm, boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! doLockAudio)
1322 {
1323 if (bpm < MIN_BPMcxx . . $ `src/pt2_replayer.h:7:9`! || bpm > MAX_BPMcxx . . $ `src/pt2_replayer.h:8:9`!)
1324 return;
1325
1326 const boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! audioWasntLocked = !audiocxx . . $ audio..lockedcxx . . $ audio_t#locked.;
1327 if (doLockAudio && audioWasntLocked)
1328 lockAudiocxx . . $ lockAudio(49f6e7a06ebc5aa8).();
1329
1330 modBPMcxx . . $ modBPM. = bpm;
1331 if (!editorcxx . . $ editor..pat2SmpOngoingcxx . . $ editor_t#pat2SmpOngoing. && !editorcxx . . $ editor..mod2WavOngoingcxx . . $ editor_t#mod2WavOngoing.)
1332 {
1333 songcxx . . $ song.->currBPMcxx . . $ module_t#currBPM. = bpm;
1334 uicxx . . $ ui..updateSongBPMcxx . . $ ui_t#updateSongBPM. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
1335 }
1336
1337 const int32_tcxx . . $ int32_t# i = bpm - MIN_BPMcxx . . $ `src/pt2_replayer.h:7:9`!; // 32..255 -> 0..223
1338
1339 audiocxx . . $ audio..samplesPerTickIntcxx . . $ audio_t#samplesPerTickInt. = audiocxx . . $ audio..samplesPerTickIntTabcxx . . $ audio_t#samplesPerTickIntTab.[i];
1340 audiocxx . . $ audio..samplesPerTickFraccxx . . $ audio_t#samplesPerTickFrac. = audiocxx . . $ audio..samplesPerTickFracTabcxx . . $ audio_t#samplesPerTickFracTab.[i];
1341
1342 // calculate tick time length for audio/video sync timestamp (visualizers)
1343 if (!editorcxx . . $ editor..pat2SmpOngoingcxx . . $ editor_t#pat2SmpOngoing. && !editorcxx . . $ editor..mod2WavOngoingcxx . . $ editor_t#mod2WavOngoing.)
1344 setSyncTickTimeLencxx . . $ setSyncTickTimeLen(588cb903c6b0e163).(audiocxx . . $ audio..tickTimeIntTabcxx . . $ audio_t#tickTimeIntTab.[i], audiocxx . . $ audio..tickTimeFracTabcxx . . $ audio_t#tickTimeFracTab.[i]);
1345
1346 if (doLockAudio && audioWasntLocked)
1347 unlockAudiocxx . . $ unlockAudio(49f6e7a06ebc5aa8).();
1348 }
1349
1350 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! tickReplayercxx . . $ tickReplayer(c9857a73d68e59ba).(void)
1351 {
1352 // quirk: CIA BPM changes are delayed by one tick in PT, so handle previous tick's BPM change now
1353 if (ciaSetBPMcxx . . $ ciaSetBPM. != -1)
1354 {
1355 const int32_tcxx . . $ int32_t# newBPM = ciaSetBPMcxx . . $ ciaSetBPM.;
1356 modSetTempocxx . . $ modSetTempo(918ebd27a9ddbad3).(newBPM, falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!);
1357 ciaSetBPMcxx . . $ ciaSetBPM. = -1;
1358 }
1359
1360 increasePlaybackTimercxx . . $ increasePlaybackTimer(49f6e7a06ebc5aa8).();
1361
1362 if (!editorcxx . . $ editor..stepPlayEnabledcxx . . $ editor_t#stepPlayEnabled.)
1363 songcxx . . $ song.->tickcxx . . $ module_t#tick.++;
1364
1365 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! readNewNote = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
1366 if ((uint32_tcxx . . $ uint32_t#)songcxx . . $ song.->tickcxx . . $ module_t#tick. >= (uint32_tcxx . . $ uint32_t#)songcxx . . $ song.->speedcxx . . $ module_t#speed.)
1367 {
1368 songcxx . . $ song.->tickcxx . . $ module_t#tick. = 0;
1369 readNewNote = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
1370 }
1371
1372 if (readNewNote || editorcxx . . $ editor..stepPlayEnabledcxx . . $ editor_t#stepPlayEnabled.) // tick 0
1373 {
1374 if (pattDelTime2cxx . . $ pattDelTime2. == 0) // no pattern delay, time to read note data
1375 {
1376 DMACONtempcxx . . $ DMACONtemp. = 0; // reset Paula DMA trigger states
1377
1378 setCurrRowToVisitedcxx . . $ setCurrRowToVisited(49f6e7a06ebc5aa8).(); // for MOD2WAV
1379 updateUIPositionscxx . . $ updateUIPositions(49f6e7a06ebc5aa8).(); // update current song positions in UI
1380
1381 // read note data and trigger voices
1382 moduleChannel_tcxx . . $ moduleChannel_t# *ch = songcxx . . $ song.->channelscxx . . $ module_t#channels.;
1383 for (int32_tcxx . . $ int32_t# i = 0; i < PAULA_VOICEScxx . . $ `src/pt2_paula.h:13:9`!; i++, ch++)
1384 {
1385 playVoicecxx . . $ playVoice(252f18867a0e9dee).(ch);
1386
1387 // set voice volume
1388 const uint32_tcxx . . $ uint32_t# voiceAddr = 0xDFF0A0 + (i * 16);
1389 paulaWriteWordcxx . . $ paulaWriteWord(272d193675e92631).(voiceAddr + 8, ch->n_volumecxx . . $ moduleChannel_t#n_volume.);
1390
1391 setVisualsVolumecxx . . $ setVisualsVolume(a7050f1a4cb56049).(i, ch->n_volumecxx . . $ moduleChannel_t#n_volume.);
1392 }
1393
1394 setDMAcxx . . $ setDMA(49f6e7a06ebc5aa8).();
1395 }
1396 else // pattern delay is on-going
1397 {
1398 moduleChannel_tcxx . . $ moduleChannel_t# *ch = songcxx . . $ song.->channelscxx . . $ module_t#channels.;
1399 for (int32_tcxx . . $ int32_t# i = 0; i < PAULA_VOICEScxx . . $ `src/pt2_paula.h:13:9`!; i++, ch++)
1400 checkEffectscxx . . $ checkEffects(252f18867a0e9dee).(ch);
1401 }
1402
1403 // increase row
1404 if (!editorcxx . . $ editor..stepPlayBackwardscxx . . $ editor_t#stepPlayBackwards.)
1405 {
1406 songcxx . . $ song.->rowcxx . . $ module_t#row.++;
1407 songcxx . . $ song.->rowsCountercxx . . $ module_t#rowsCounter.++; // for MOD2WAV's progress bar
1408 }
1409
1410 if (pattDelTimecxx . . $ pattDelTime. > 0)
1411 {
1412 pattDelTime2cxx . . $ pattDelTime2. = pattDelTimecxx . . $ pattDelTime.;
1413 pattDelTimecxx . . $ pattDelTime. = 0;
1414 }
1415
1416 // undo row increase if pattern delay is on-going
1417 if (pattDelTime2cxx . . $ pattDelTime2. > 0)
1418 {
1419 pattDelTime2cxx . . $ pattDelTime2.--;
1420 if (pattDelTime2cxx . . $ pattDelTime2. > 0)
1421 {
1422 songcxx . . $ song.->rowcxx . . $ module_t#row.--;
1423 songcxx . . $ song.->rowsCountercxx . . $ module_t#rowsCounter.--; // for MOD2WAV's progress bar
1424 }
1425 }
1426
1427 if (pBreakFlagcxx . . $ pBreakFlag.)
1428 {
1429 songcxx . . $ song.->rowcxx . . $ module_t#row. = pBreakPositioncxx . . $ pBreakPosition.;
1430 pBreakPositioncxx . . $ pBreakPosition. = 0;
1431 pBreakFlagcxx . . $ pBreakFlag. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
1432 }
1433
1434 // step-play handling
1435 if (editorcxx . . $ editor..stepPlayEnabledcxx . . $ editor_t#stepPlayEnabled.)
1436 {
1437 if (configcxx . . $ config..keepEditModeAfterStepPlaycxx . . $ config_t#keepEditModeAfterStepPlay. && editorcxx . . $ editor..stepPlayLastModecxx . . $ editor_t#stepPlayLastMode. == MODE_EDITcxx . . $ MODE_EDIT.)
1438 {
1439 doStopItcxx . . $ doStopIt(b45ddcbc8423892c).(falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!);
1440
1441 editorcxx . . $ editor..playModecxx . . $ editor_t#playMode. = PLAY_MODE_NORMALcxx . . $ PLAY_MODE_NORMAL.;
1442 editorcxx . . $ editor..currModecxx . . $ editor_t#currMode. = MODE_EDITcxx . . $ MODE_EDIT.;
1443 pointerSetModeThreadSafecxx . . $ pointerSetModeThreadSafe(f2ac3508b56cd10).(POINTER_MODE_EDITcxx . . $ POINTER_MODE_EDIT., truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!);
1444 }
1445 else
1446 {
1447 doStopItcxx . . $ doStopIt(b45ddcbc8423892c).(truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!);
1448 }
1449
1450 if (editorcxx . . $ editor..stepPlayLastModecxx . . $ editor_t#stepPlayLastMode. == MODE_EDITcxx . . $ MODE_EDIT. || editorcxx . . $ editor..stepPlayLastModecxx . . $ editor_t#stepPlayLastMode. == MODE_IDLEcxx . . $ MODE_IDLE.)
1451 {
1452 songcxx . . $ song.->rowcxx . . $ module_t#row. &= 63;
1453 songcxx . . $ song.->currRowcxx . . $ module_t#currRow. = songcxx . . $ song.->rowcxx . . $ module_t#row.;
1454 }
1455 else
1456 {
1457 // if we were playing, set replayer row to tracker row (stay in sync)
1458 songcxx . . $ song.->currRowcxx . . $ module_t#currRow. &= 63;
1459 songcxx . . $ song.->rowcxx . . $ module_t#row. = songcxx . . $ song.->currRowcxx . . $ module_t#currRow.;
1460 }
1461
1462 editorcxx . . $ editor..stepPlayEnabledcxx . . $ editor_t#stepPlayEnabled. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
1463 editorcxx . . $ editor..stepPlayBackwardscxx . . $ editor_t#stepPlayBackwards. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
1464
1465 uicxx . . $ ui..updatePatternDatacxx . . $ ui_t#updatePatternData. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
1466 return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
1467 }
1468
1469 if (songcxx . . $ song.->rowcxx . . $ module_t#row. >= MOD_ROWScxx . . $ `src/pt2_header.h:73:9`! || posJumpAssertcxx . . $ posJumpAssert.)
1470 nextPositioncxx . . $ nextPosition(49f6e7a06ebc5aa8).();
1471
1472 // for pattern block mark feature
1473 if (editorcxx . . $ editor..blockMarkFlagcxx . . $ editor_t#blockMarkFlag.)
1474 uicxx . . $ ui..updateStatusTextcxx . . $ ui_t#updateStatusText. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
1475 }
1476 else // tick > 0 (handle effects)
1477 {
1478 moduleChannel_tcxx . . $ moduleChannel_t# *ch = songcxx . . $ song.->channelscxx . . $ module_t#channels.;
1479 for (int32_tcxx . . $ int32_t# i = 0; i < PAULA_VOICEScxx . . $ `src/pt2_paula.h:13:9`!; i++, ch++)
1480 checkEffectscxx . . $ checkEffects(252f18867a0e9dee).(ch);
1481
1482 if (posJumpAssertcxx . . $ posJumpAssert.)
1483 nextPositioncxx . . $ nextPosition(49f6e7a06ebc5aa8).();
1484 }
1485
1486 // command F00 = stop song, do it here (so that the scopes are updated properly)
1487 if (doStopSongcxx . . $ doStopSong.)
1488 {
1489 doStopSongcxx . . $ doStopSong. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
1490
1491 editorcxx . . $ editor..songPlayingcxx . . $ editor_t#songPlaying. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
1492
1493 editorcxx . . $ editor..playModecxx . . $ editor_t#playMode. = PLAY_MODE_NORMALcxx . . $ PLAY_MODE_NORMAL.;
1494 editorcxx . . $ editor..currModecxx . . $ editor_t#currMode. = MODE_IDLEcxx . . $ MODE_IDLE.;
1495 pointerSetModeThreadSafecxx . . $ pointerSetModeThreadSafe(f2ac3508b56cd10).(POINTER_MODE_IDLEcxx . . $ POINTER_MODE_IDLE., truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!);
1496 }
1497
1498 return renderEndCheckcxx . . $ renderEndCheck(c9857a73d68e59ba).(); // MOD2WAV/PAT2SMP listens to the return value (true = not done yet)
1499 }
1500
1501 void modSetPatterncxx . . $ modSetPattern(ac50b47256ae7414).(uint8_tcxx . . $ uint8_t# pattern)
1502 {
1503 modPatterncxx . . $ modPattern. = pattern;
1504 songcxx . . $ song.->currPatterncxx . . $ module_t#currPattern. = modPatterncxx . . $ modPattern.;
1505 uicxx . . $ ui..updateCurrPattTextcxx . . $ ui_t#updateCurrPattText. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
1506 }
1507
1508 void updateNewPoscxx . . $ updateNewPos(49f6e7a06ebc5aa8).(void) // for after having edited the "POS" digits only
1509 {
1510 modPoscxx . . $ modPos. = songcxx . . $ song.->currPoscxx . . $ module_t#currPos.;
1511 editorcxx . . $ editor..currPatternDispcxx . . $ editor_t#currPatternDisp. = &songcxx . . $ song.->headercxx . . $ module_t#header..patternTablecxx . . $ moduleHeader_t#patternTable.[songcxx . . $ song.->currPoscxx . . $ module_t#currPos.];
1512 uicxx . . $ ui..updateSongPoscxx . . $ ui_t#updateSongPos. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
1513 uicxx . . $ ui..updateSongPatterncxx . . $ ui_t#updateSongPattern. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
1514 }
1515
1516 void modSetPoscxx . . $ modSetPos(af780a7c10c7990f).(int16_tcxx . . $ int16_t# pos, int16_tcxx . . $ int16_t# row)
1517 {
1518 /*
1519 const bool audioWasntLocked = !audio.locked;
1520 if (audioWasntLocked)
1521 lockAudio();
1522 */
1523
1524 if (row != -1)
1525 {
1526 row = CLAMPcxx . . $ `src/pt2_helpers.h:36:9`!(row, 0, 63);
1527
1528 songcxx . . $ song.->tickcxx . . $ module_t#tick. = 0;
1529 songcxx . . $ song.->rowcxx . . $ module_t#row. = (int8_tcxx . . $ int8_t#)row;
1530 songcxx . . $ song.->currRowcxx . . $ module_t#currRow. = (int8_tcxx . . $ int8_t#)row;
1531 }
1532
1533 if (pos != -1)
1534 {
1535 if (pos >= 0)
1536 {
1537 songcxx . . $ song.->currPoscxx . . $ module_t#currPos. = modPoscxx . . $ modPos. = pos;
1538 uicxx . . $ ui..updateSongPoscxx . . $ ui_t#updateSongPos. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
1539
1540 if (editorcxx . . $ editor..currModecxx . . $ editor_t#currMode. == MODE_PLAYcxx . . $ MODE_PLAY. && editorcxx . . $ editor..playModecxx . . $ editor_t#playMode. == PLAY_MODE_NORMALcxx . . $ PLAY_MODE_NORMAL.)
1541 {
1542 modPatterncxx . . $ modPattern. = (int8_tcxx . . $ int8_t#)songcxx . . $ song.->headercxx . . $ module_t#header..patternTablecxx . . $ moduleHeader_t#patternTable.[pos];
1543 if (modPatterncxx . . $ modPattern. > MAX_PATTERNScxx . . $ `src/pt2_header.h:75:9`!-1)
1544 modPatterncxx . . $ modPattern. = MAX_PATTERNScxx . . $ `src/pt2_header.h:75:9`!-1;
1545
1546 songcxx . . $ song.->currPatterncxx . . $ module_t#currPattern. = modPatterncxx . . $ modPattern.;
1547 uicxx . . $ ui..updateCurrPattTextcxx . . $ ui_t#updateCurrPattText. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
1548 }
1549
1550 uicxx . . $ ui..updateSongPatterncxx . . $ ui_t#updateSongPattern. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
1551 editorcxx . . $ editor..currPatternDispcxx . . $ editor_t#currPatternDisp. = &songcxx . . $ song.->headercxx . . $ module_t#header..patternTablecxx . . $ moduleHeader_t#patternTable.[modPoscxx . . $ modPos.];
1552
1553 int16_tcxx . . $ int16_t# posEdPos = songcxx . . $ song.->currPoscxx . . $ module_t#currPos.;
1554 if (posEdPos > songcxx . . $ song.->headercxx . . $ module_t#header..songLengthcxx . . $ moduleHeader_t#songLength.-1)
1555 posEdPos = songcxx . . $ song.->headercxx . . $ module_t#header..songLengthcxx . . $ moduleHeader_t#songLength.-1;
1556
1557 editorcxx . . $ editor..currPosEdPattDispcxx . . $ editor_t#currPosEdPattDisp. = &songcxx . . $ song.->headercxx . . $ module_t#header..patternTablecxx . . $ moduleHeader_t#patternTable.[posEdPos];
1558
1559 if (uicxx . . $ ui..posEdScreenShowncxx . . $ ui_t#posEdScreenShown.)
1560 uicxx . . $ ui..updatePosEdcxx . . $ ui_t#updatePosEd. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
1561 }
1562 }
1563
1564 /*
1565 if (audioWasntLocked)
1566 unlockAudio();
1567 */
1568
1569 uicxx . . $ ui..updatePatternDatacxx . . $ ui_t#updatePatternData. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
1570
1571 if (editorcxx . . $ editor..blockMarkFlagcxx . . $ editor_t#blockMarkFlag.)
1572 uicxx . . $ ui..updateStatusTextcxx . . $ ui_t#updateStatusText. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
1573 }
1574
1575 void modStopcxx . . $ modStop(49f6e7a06ebc5aa8).(void)
1576 {
1577 editorcxx . . $ editor..songPlayingcxx . . $ editor_t#songPlaying. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
1578 turnOffVoicescxx . . $ turnOffVoices(49f6e7a06ebc5aa8).();
1579
1580 if (songcxx . . $ song. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
1581 {
1582 moduleChannel_tcxx . . $ moduleChannel_t# *ch = songcxx . . $ song.->channelscxx . . $ module_t#channels.;
1583 for (int32_tcxx . . $ int32_t# i = 0; i < PAULA_VOICEScxx . . $ `src/pt2_paula.h:13:9`!; i++, ch++)
1584 {
1585 ch->n_wavecontrolcxx . . $ moduleChannel_t#n_wavecontrol. = 0;
1586 ch->n_glissfunkcxx . . $ moduleChannel_t#n_glissfunk. = 0;
1587 ch->n_finetunecxx . . $ moduleChannel_t#n_finetune. = 0;
1588 ch->n_loopcountcxx . . $ moduleChannel_t#n_loopcount. = 0;
1589 }
1590 }
1591
1592 pBreakFlagcxx . . $ pBreakFlag. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
1593 pattDelTimecxx . . $ pattDelTime. = 0;
1594 pattDelTime2cxx . . $ pattDelTime2. = 0;
1595 pBreakPositioncxx . . $ pBreakPosition. = 0;
1596 posJumpAssertcxx . . $ posJumpAssert. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
1597 modRenderDonecxx . . $ modRenderDone. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
1598
1599 /* The replayer is one tick ahead (unfortunately), so if the user was to stop the mod at the previous tick
1600 ** before a position jump (pattern loop, pattern break, position jump, row 63->0 transition, etc),
1601 ** it would be possible for the replayer to be at another order/pattern than the tracker.
1602 ** Let's set the replayer state to the tracker state on mod stop, to fix possible confusion.
1603 */
1604 setReplayerPosToTrackerPoscxx . . $ setReplayerPosToTrackerPos(49f6e7a06ebc5aa8).();
1605
1606 doStopSongcxx . . $ doStopSong. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; // just in case this flag was stuck from command F00 (stop song)
1607 }
1608
1609 void playPatterncxx . . $ playPattern(4af4fd0e2b26c4ac).(int8_tcxx . . $ int8_t# startRow)
1610 {
1611 if (!editorcxx . . $ editor..stepPlayEnabledcxx . . $ editor_t#stepPlayEnabled.)
1612 pointerSetModecxx . . $ pointerSetMode(f2ac3508b56cd10).(POINTER_MODE_PLAYcxx . . $ POINTER_MODE_PLAY., DO_CARRYcxx . . $ DO_CARRY.);
1613
1614 const boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! audioWasntLocked = !audiocxx . . $ audio..lockedcxx . . $ audio_t#locked.;
1615 if (audioWasntLocked)
1616 lockAudiocxx . . $ lockAudio(49f6e7a06ebc5aa8).();
1617
1618 audiocxx . . $ audio..tickSampleCountercxx . . $ audio_t#tickSampleCounter. = 0; // zero tick sample counter so that it will instantly initiate a tick
1619 audiocxx . . $ audio..tickSampleCounterFraccxx . . $ audio_t#tickSampleCounterFrac. = 0;
1620
1621 songcxx . . $ song.->currRowcxx . . $ module_t#currRow. = songcxx . . $ song.->rowcxx . . $ module_t#row. = startRow & 63;
1622
1623 if (!editorcxx . . $ editor..stepPlayEnabledcxx . . $ editor_t#stepPlayEnabled.)
1624 songcxx . . $ song.->tickcxx . . $ module_t#tick. = songcxx . . $ song.->speedcxx . . $ module_t#speed.-1;
1625 else
1626 songcxx . . $ song.->tickcxx . . $ module_t#tick. = 0;
1627
1628 ciaSetBPMcxx . . $ ciaSetBPM. = -1; // fix possibly stuck "set BPM" flag
1629
1630 if (!editorcxx . . $ editor..stepPlayEnabledcxx . . $ editor_t#stepPlayEnabled.)
1631 {
1632 editorcxx . . $ editor..playModecxx . . $ editor_t#playMode. = PLAY_MODE_PATTERNcxx . . $ PLAY_MODE_PATTERN.;
1633 editorcxx . . $ editor..currModecxx . . $ editor_t#currMode. = MODE_PLAYcxx . . $ MODE_PLAY.;
1634 }
1635
1636 editorcxx . . $ editor..didQuantizecxx . . $ editor_t#didQuantize. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
1637 editorcxx . . $ editor..songPlayingcxx . . $ editor_t#songPlaying. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
1638
1639 if (audioWasntLocked)
1640 unlockAudiocxx . . $ unlockAudio(49f6e7a06ebc5aa8).();
1641 }
1642
1643 void incPattcxx . . $ incPatt(49f6e7a06ebc5aa8).(void)
1644 {
1645 modPatterncxx . . $ modPattern.++;
1646 if (modPatterncxx . . $ modPattern. > MAX_PATTERNScxx . . $ `src/pt2_header.h:75:9`!-1)
1647 modPatterncxx . . $ modPattern. = 0;
1648
1649 songcxx . . $ song.->currPatterncxx . . $ module_t#currPattern. = modPatterncxx . . $ modPattern.;
1650
1651 uicxx . . $ ui..updatePatternDatacxx . . $ ui_t#updatePatternData. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
1652 uicxx . . $ ui..updateCurrPattTextcxx . . $ ui_t#updateCurrPattText. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
1653 }
1654
1655 void decPattcxx . . $ decPatt(49f6e7a06ebc5aa8).(void)
1656 {
1657 modPatterncxx . . $ modPattern.--;
1658 if (modPatterncxx . . $ modPattern. < 0)
1659 modPatterncxx . . $ modPattern. = MAX_PATTERNScxx . . $ `src/pt2_header.h:75:9`! - 1;
1660
1661 songcxx . . $ song.->currPatterncxx . . $ module_t#currPattern. = modPatterncxx . . $ modPattern.;
1662
1663 uicxx . . $ ui..updatePatternDatacxx . . $ ui_t#updatePatternData. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
1664 uicxx . . $ ui..updateCurrPattTextcxx . . $ ui_t#updateCurrPattText. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
1665 }
1666
1667 void modPlaycxx . . $ modPlay(7b7bc4ff97a2e5fe).(int16_tcxx . . $ int16_t# patt, int16_tcxx . . $ int16_t# pos, int8_tcxx . . $ int8_t# row)
1668 {
1669 const boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! audioWasntLocked = !audiocxx . . $ audio..lockedcxx . . $ audio_t#locked.;
1670 if (audioWasntLocked)
1671 lockAudiocxx . . $ lockAudio(49f6e7a06ebc5aa8).();
1672
1673 doStopItcxx . . $ doStopIt(b45ddcbc8423892c).(falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!);
1674 turnOffVoicescxx . . $ turnOffVoices(49f6e7a06ebc5aa8).();
1675
1676 if (row != -1)
1677 {
1678 if (row >= 0 && row <= 63)
1679 {
1680 songcxx . . $ song.->rowcxx . . $ module_t#row. = row;
1681 songcxx . . $ song.->currRowcxx . . $ module_t#currRow. = row;
1682 }
1683 }
1684 else
1685 {
1686 songcxx . . $ song.->rowcxx . . $ module_t#row. = 0;
1687 songcxx . . $ song.->currRowcxx . . $ module_t#currRow. = 0;
1688 }
1689
1690 if (editorcxx . . $ editor..playModecxx . . $ editor_t#playMode. != PLAY_MODE_PATTERNcxx . . $ PLAY_MODE_PATTERN.)
1691 {
1692 if (modPoscxx . . $ modPos. >= songcxx . . $ song.->headercxx . . $ module_t#header..songLengthcxx . . $ moduleHeader_t#songLength.)
1693 songcxx . . $ song.->currPoscxx . . $ module_t#currPos. = modPoscxx . . $ modPos. = 0;
1694
1695 if (pos >= 0 && pos < songcxx . . $ song.->headercxx . . $ module_t#header..songLengthcxx . . $ moduleHeader_t#songLength.)
1696 songcxx . . $ song.->currPoscxx . . $ module_t#currPos. = modPoscxx . . $ modPos. = pos;
1697
1698 if (pos >= songcxx . . $ song.->headercxx . . $ module_t#header..songLengthcxx . . $ moduleHeader_t#songLength.)
1699 songcxx . . $ song.->currPoscxx . . $ module_t#currPos. = modPoscxx . . $ modPos. = 0;
1700 }
1701
1702 if (patt >= 0 && patt <= MAX_PATTERNScxx . . $ `src/pt2_header.h:75:9`!-1)
1703 songcxx . . $ song.->currPatterncxx . . $ module_t#currPattern. = modPatterncxx . . $ modPattern. = (int8_tcxx . . $ int8_t#)patt;
1704 else
1705 songcxx . . $ song.->currPatterncxx . . $ module_t#currPattern. = modPatterncxx . . $ modPattern. = (int8_tcxx . . $ int8_t#)songcxx . . $ song.->headercxx . . $ module_t#header..patternTablecxx . . $ moduleHeader_t#patternTable.[modPoscxx . . $ modPos.];
1706
1707 editorcxx . . $ editor..currPatternDispcxx . . $ editor_t#currPatternDisp. = &songcxx . . $ song.->headercxx . . $ module_t#header..patternTablecxx . . $ moduleHeader_t#patternTable.[modPoscxx . . $ modPos.];
1708 editorcxx . . $ editor..currPosEdPattDispcxx . . $ editor_t#currPosEdPattDisp. = &songcxx . . $ song.->headercxx . . $ module_t#header..patternTablecxx . . $ moduleHeader_t#patternTable.[modPoscxx . . $ modPos.];
1709
1710 songcxx . . $ song.->tickcxx . . $ module_t#tick. = songcxx . . $ song.->speedcxx . . $ module_t#speed.-1;
1711 ciaSetBPMcxx . . $ ciaSetBPM. = -1; // fix possibly stuck "set BPM" flag
1712
1713 modRenderDonecxx . . $ modRenderDone. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
1714 editorcxx . . $ editor..songPlayingcxx . . $ editor_t#songPlaying. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
1715 editorcxx . . $ editor..didQuantizecxx . . $ editor_t#didQuantize. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
1716
1717 // don't reset playback counter in "play/rec pattern" mode
1718 if (editorcxx . . $ editor..playModecxx . . $ editor_t#playMode. != PLAY_MODE_PATTERNcxx . . $ PLAY_MODE_PATTERN.)
1719 editorcxx . . $ editor..playbackSecondscxx . . $ editor_t#playbackSeconds. = editorcxx . . $ editor..playbackSecondsFraccxx . . $ editor_t#playbackSecondsFrac. = 0;
1720
1721 audiocxx . . $ audio..tickSampleCountercxx . . $ audio_t#tickSampleCounter. = 0; // zero tick sample counter so that it will instantly initiate a tick
1722 audiocxx . . $ audio..tickSampleCounterFraccxx . . $ audio_t#tickSampleCounterFrac. = 0;
1723
1724 if (audioWasntLocked)
1725 unlockAudiocxx . . $ unlockAudio(49f6e7a06ebc5aa8).();
1726
1727 if (!editorcxx . . $ editor..pat2SmpOngoingcxx . . $ editor_t#pat2SmpOngoing. && !editorcxx . . $ editor..mod2WavOngoingcxx . . $ editor_t#mod2WavOngoing.)
1728 {
1729 uicxx . . $ ui..updateSongPoscxx . . $ ui_t#updateSongPos. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
1730 uicxx . . $ ui..updatePatternDatacxx . . $ ui_t#updatePatternData. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
1731 uicxx . . $ ui..updateSongPatterncxx . . $ ui_t#updateSongPattern. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
1732 uicxx . . $ ui..updateCurrPattTextcxx . . $ ui_t#updateCurrPattText. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
1733 }
1734 }
1735
1736 void clearSongcxx . . $ clearSong(49f6e7a06ebc5aa8).(void)
1737 {
1738 ASSERTcxx . . $ `src/pt2_header.h:25:9`!(song != NULL);
1739 if (songcxx . . $ song. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
1740 return;
1741
1742 memsetcxx . . $ memset(d1de1e4fb215f1c6).(songcxx . . $ song.->headercxx . . $ module_t#header..patternTablecxx . . $ moduleHeader_t#patternTable., 0, sizeof (songcxx . . $ song.->headercxx . . $ module_t#header..patternTablecxx . . $ moduleHeader_t#patternTable.));
1743 memsetcxx . . $ memset(d1de1e4fb215f1c6).(songcxx . . $ song.->headercxx . . $ module_t#header..namecxx . . $ moduleHeader_t#name., 0, sizeof (songcxx . . $ song.->headercxx . . $ module_t#header..namecxx . . $ moduleHeader_t#name.));
1744
1745 posEdClearNamescxx . . $ posEdClearNames(49f6e7a06ebc5aa8).();
1746
1747 editorcxx . . $ editor..mutedcxx . . $ editor_t#muted.[0] = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
1748 editorcxx . . $ editor..mutedcxx . . $ editor_t#muted.[1] = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
1749 editorcxx . . $ editor..mutedcxx . . $ editor_t#muted.[2] = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
1750 editorcxx . . $ editor..mutedcxx . . $ editor_t#muted.[3] = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
1751
1752 editorcxx . . $ editor..f6Poscxx . . $ editor_t#f6Pos. = 0;
1753 editorcxx . . $ editor..f7Poscxx . . $ editor_t#f7Pos. = 16;
1754 editorcxx . . $ editor..f8Poscxx . . $ editor_t#f8Pos. = 32;
1755 editorcxx . . $ editor..f9Poscxx . . $ editor_t#f9Pos. = 48;
1756 editorcxx . . $ editor..f10Poscxx . . $ editor_t#f10Pos. = 63;
1757
1758 editorcxx . . $ editor..playbackSecondscxx . . $ editor_t#playbackSeconds. = editorcxx . . $ editor..playbackSecondsFraccxx . . $ editor_t#playbackSecondsFrac. = 0;
1759 editorcxx . . $ editor..metroFlagcxx . . $ editor_t#metroFlag. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
1760 editorcxx . . $ editor..currSamplecxx . . $ editor_t#currSample. = 0;
1761 editorcxx . . $ editor..editMoveAddcxx . . $ editor_t#editMoveAdd. = 1;
1762 editorcxx . . $ editor..blockMarkFlagcxx . . $ editor_t#blockMarkFlag. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
1763 editorcxx . . $ editor..swapChannelFlagcxx . . $ editor_t#swapChannelFlag. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
1764
1765 songcxx . . $ song.->headercxx . . $ module_t#header..songLengthcxx . . $ moduleHeader_t#songLength. = 1;
1766
1767 for (int32_tcxx . . $ int32_t# i = 0; i < MAX_PATTERNScxx . . $ `src/pt2_header.h:75:9`!; i++)
1768 memsetcxx . . $ memset(d1de1e4fb215f1c6).(songcxx . . $ song.->patternscxx . . $ module_t#patterns.[i], 0, (MOD_ROWScxx . . $ `src/pt2_header.h:73:9`! * PAULA_VOICEScxx . . $ `src/pt2_paula.h:13:9`!) * sizeof (note_tcxx . . $ note_t#));
1769
1770 moduleChannel_tcxx . . $ moduleChannel_t# *ch = songcxx . . $ song.->channelscxx . . $ module_t#channels.;
1771 for (int32_tcxx . . $ int32_t# i = 0; i < PAULA_VOICEScxx . . $ `src/pt2_paula.h:13:9`!; i++, ch++)
1772 {
1773 ch->n_wavecontrolcxx . . $ moduleChannel_t#n_wavecontrol. = 0;
1774 ch->n_glissfunkcxx . . $ moduleChannel_t#n_glissfunk. = 0;
1775 ch->n_finetunecxx . . $ moduleChannel_t#n_finetune. = 0;
1776 ch->n_loopcountcxx . . $ moduleChannel_t#n_loopcount. = 0;
1777 }
1778
1779 modSetPoscxx . . $ modSetPos(af780a7c10c7990f).(0, 0); // this also refreshes pattern data
1780
1781 songcxx . . $ song.->currPoscxx . . $ module_t#currPos. = 0;
1782 songcxx . . $ song.->currPatterncxx . . $ module_t#currPattern. = 0;
1783 editorcxx . . $ editor..currPatternDispcxx . . $ editor_t#currPatternDisp. = &songcxx . . $ song.->headercxx . . $ module_t#header..patternTablecxx . . $ moduleHeader_t#patternTable.[0];
1784 editorcxx . . $ editor..currPosEdPattDispcxx . . $ editor_t#currPosEdPattDisp. = &songcxx . . $ song.->headercxx . . $ module_t#header..patternTablecxx . . $ moduleHeader_t#patternTable.[0];
1785
1786 modSetTempocxx . . $ modSetTempo(918ebd27a9ddbad3).(editorcxx . . $ editor..initialTempocxx . . $ editor_t#initialTempo., truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!);
1787 modSetSpeedcxx . . $ modSetSpeed(d4f767463ce0a6b3).(editorcxx . . $ editor..initialSpeedcxx . . $ editor_t#initialSpeed.);
1788
1789 // disable the LED filter after clearing the song (real PT2 doesn't do this)
1790 setLEDFiltercxx . . $ setLEDFilter(b45ddcbc8423892c).(falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!);
1791
1792 updateCurrSamplecxx . . $ updateCurrSample(49f6e7a06ebc5aa8).();
1793
1794 uicxx . . $ ui..updateSongSizecxx . . $ ui_t#updateSongSize. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
1795 uicxx . . $ ui..updateSongLengthcxx . . $ ui_t#updateSongLength. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
1796 uicxx . . $ ui..updateSongNamecxx . . $ ui_t#updateSongName. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
1797 renderMuteButtonscxx . . $ renderMuteButtons(49f6e7a06ebc5aa8).();
1798 }
1799
1800 void clearSamplescxx . . $ clearSamples(49f6e7a06ebc5aa8).(void)
1801 {
1802 ASSERTcxx . . $ `src/pt2_header.h:25:9`!(song != NULL);
1803 if (songcxx . . $ song. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
1804 return;
1805
1806 moduleSample_tcxx . . $ moduleSample_t# *s = songcxx . . $ song.->samplescxx . . $ module_t#samples.;
1807 for (int32_tcxx . . $ int32_t# i = 0; i < MOD_SAMPLEScxx . . $ `src/pt2_header.h:74:9`!; i++, s++)
1808 {
1809 s->fineTunecxx . . $ moduleSample_t#fineTune. = 0;
1810 s->lengthcxx . . $ moduleSample_t#length. = 0;
1811 s->loopLengthcxx . . $ moduleSample_t#loopLength. = 2;
1812 s->loopStartcxx . . $ moduleSample_t#loopStart. = 0;
1813 s->volumecxx . . $ moduleSample_t#volume. = 0;
1814
1815 memsetcxx . . $ memset(d1de1e4fb215f1c6).(s->textcxx . . $ moduleSample_t#text., 0, sizeof (s->textcxx . . $ moduleSample_t#text.));
1816 }
1817
1818 memsetcxx . . $ memset(d1de1e4fb215f1c6).(songcxx . . $ song.->sampleDatacxx . . $ module_t#sampleData., 0, (MOD_SAMPLEScxx . . $ `src/pt2_header.h:74:9`! + 1) * configcxx . . $ config..maxSampleLengthcxx . . $ config_t#maxSampleLength.);
1819
1820 editorcxx . . $ editor..currSamplecxx . . $ editor_t#currSample. = 0;
1821 editorcxx . . $ editor..hiLowInstrcxx . . $ editor_t#hiLowInstr. = 0;
1822 editorcxx . . $ editor..sampleZerocxx . . $ editor_t#sampleZero. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
1823 editorcxx . . $ editor..blockMarkFlagcxx . . $ editor_t#blockMarkFlag. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
1824 editorcxx . . $ editor..samplePoscxx . . $ editor_t#samplePos. = 0;
1825
1826 updateCurrSamplecxx . . $ updateCurrSample(49f6e7a06ebc5aa8).();
1827 }
1828
1829 void modFreecxx . . $ modFree(49f6e7a06ebc5aa8).(void)
1830 {
1831 if (songcxx . . $ song. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
1832 return; // not allocated
1833
1834 const boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! audioWasntLocked = !audiocxx . . $ audio..lockedcxx . . $ audio_t#locked.;
1835 if (audioWasntLocked)
1836 lockAudiocxx . . $ lockAudio(49f6e7a06ebc5aa8).();
1837
1838 turnOffVoicescxx . . $ turnOffVoices(49f6e7a06ebc5aa8).();
1839
1840 for (int32_tcxx . . $ int32_t# i = 0; i < MAX_PATTERNScxx . . $ `src/pt2_header.h:75:9`!; i++)
1841 {
1842 if (songcxx . . $ song.->patternscxx . . $ module_t#patterns.[i] != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
1843 freecxx . . $ free(5d22bdacc48458e8).(songcxx . . $ song.->patternscxx . . $ module_t#patterns.[i]);
1844 }
1845
1846 if (songcxx . . $ song.->sampleDatacxx . . $ module_t#sampleData. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
1847 freecxx . . $ free(5d22bdacc48458e8).(songcxx . . $ song.->sampleDatacxx . . $ module_t#sampleData.);
1848
1849 freecxx . . $ free(5d22bdacc48458e8).(songcxx . . $ song.);
1850 songcxx . . $ song. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
1851
1852 if (audioWasntLocked)
1853 unlockAudiocxx . . $ unlockAudio(49f6e7a06ebc5aa8).();
1854 }
1855
1856 void restartSongcxx . . $ restartSong(49f6e7a06ebc5aa8).(void) // for the beginning of MOD2WAV/PAT2SMP
1857 {
1858 if (editorcxx . . $ editor..songPlayingcxx . . $ editor_t#songPlaying.)
1859 modStopcxx . . $ modStop(49f6e7a06ebc5aa8).();
1860
1861 editorcxx . . $ editor..playModecxx . . $ editor_t#playMode. = PLAY_MODE_NORMALcxx . . $ PLAY_MODE_NORMAL.;
1862 editorcxx . . $ editor..blockMarkFlagcxx . . $ editor_t#blockMarkFlag. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
1863
1864 songcxx . . $ song.->rowcxx . . $ module_t#row. = 0;
1865 songcxx . . $ song.->currRowcxx . . $ module_t#currRow. = 0;
1866 songcxx . . $ song.->rowsCountercxx . . $ module_t#rowsCounter. = 0;
1867
1868 memsetcxx . . $ memset(d1de1e4fb215f1c6).(editorcxx . . $ editor..rowVisitTablecxx . . $ editor_t#rowVisitTable., 0, 128 * MOD_ROWScxx . . $ `src/pt2_header.h:73:9`!); // for MOD2WAV
1869
1870 if (editorcxx . . $ editor..pat2SmpOngoingcxx . . $ editor_t#pat2SmpOngoing.)
1871 {
1872 modSetSpeedcxx . . $ modSetSpeed(d4f767463ce0a6b3).(songcxx . . $ song.->currSpeedcxx . . $ module_t#currSpeed.);
1873 modSetTempocxx . . $ modSetTempo(918ebd27a9ddbad3).(songcxx . . $ song.->currBPMcxx . . $ module_t#currBPM., truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!);
1874 modPlaycxx . . $ modPlay(7b7bc4ff97a2e5fe).(DONT_SET_PATTERNcxx . . $ DONT_SET_PATTERN., DONT_SET_ORDERcxx . . $ DONT_SET_ORDER., 0);
1875 }
1876 else
1877 {
1878 songcxx . . $ song.->currSpeedcxx . . $ module_t#currSpeed. = 6;
1879 songcxx . . $ song.->currBPMcxx . . $ module_t#currBPM. = 125;
1880 modSetSpeedcxx . . $ modSetSpeed(d4f767463ce0a6b3).(songcxx . . $ song.->currSpeedcxx . . $ module_t#currSpeed.);
1881 modSetTempocxx . . $ modSetTempo(918ebd27a9ddbad3).(songcxx . . $ song.->currBPMcxx . . $ module_t#currBPM., truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!);
1882
1883 modPlaycxx . . $ modPlay(7b7bc4ff97a2e5fe).(DONT_SET_PATTERNcxx . . $ DONT_SET_PATTERN., 0, 0);
1884 }
1885 }
1886
1887 // this function is meant for the end of MOD2WAV/PAT2SMP
1888 void resetSongcxx . . $ resetSong(49f6e7a06ebc5aa8).(void) // only call this after storeTempVariables() has been called!
1889 {
1890 modStopcxx . . $ modStop(49f6e7a06ebc5aa8).();
1891
1892 editorcxx . . $ editor..songPlayingcxx . . $ editor_t#songPlaying. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
1893 editorcxx . . $ editor..playModecxx . . $ editor_t#playMode. = PLAY_MODE_NORMALcxx . . $ PLAY_MODE_NORMAL.;
1894 editorcxx . . $ editor..currModecxx . . $ editor_t#currMode. = MODE_IDLEcxx . . $ MODE_IDLE.;
1895
1896 turnOffVoicescxx . . $ turnOffVoices(49f6e7a06ebc5aa8).();
1897
1898 memsetcxx . . $ memset(d1de1e4fb215f1c6).((int8_tcxx . . $ int8_t# *)editorcxx . . $ editor..vuMeterVolumescxx . . $ editor_t#vuMeterVolumes., 0, sizeof (editorcxx . . $ editor..vuMeterVolumescxx . . $ editor_t#vuMeterVolumes.));
1899 memsetcxx . . $ memset(d1de1e4fb215f1c6).((int8_tcxx . . $ int8_t# *)editorcxx . . $ editor..realVuMeterVolumescxx . . $ editor_t#realVuMeterVolumes., 0, sizeof (editorcxx . . $ editor..realVuMeterVolumescxx . . $ editor_t#realVuMeterVolumes.));
1900 memsetcxx . . $ memset(d1de1e4fb215f1c6).((int8_tcxx . . $ int8_t# *)editorcxx . . $ editor..spectrumVolumescxx . . $ editor_t#spectrumVolumes., 0, sizeof (editorcxx . . $ editor..spectrumVolumescxx . . $ editor_t#spectrumVolumes.));
1901
1902 initializeModuleChannelscxx . . $ initializeModuleChannels(c4f6a69956ee5af3).(songcxx . . $ song.);
1903
1904 modPoscxx . . $ modPos. = oldPoscxx . . $ oldPos.;
1905 modPatterncxx . . $ modPattern. = (int8_tcxx . . $ int8_t#)oldPatterncxx . . $ oldPattern.;
1906
1907 songcxx . . $ song.->rowcxx . . $ module_t#row. = oldRowcxx . . $ oldRow.;
1908 songcxx . . $ song.->currRowcxx . . $ module_t#currRow. = oldRowcxx . . $ oldRow.;
1909 songcxx . . $ song.->currBPMcxx . . $ module_t#currBPM. = oldBPMcxx . . $ oldBPM.;
1910 songcxx . . $ song.->currPoscxx . . $ module_t#currPos. = oldPoscxx . . $ oldPos.;
1911 songcxx . . $ song.->currPatterncxx . . $ module_t#currPattern. = oldPatterncxx . . $ oldPattern.;
1912
1913 editorcxx . . $ editor..currPosDispcxx . . $ editor_t#currPosDisp. = &songcxx . . $ song.->currPoscxx . . $ module_t#currPos.;
1914 editorcxx . . $ editor..currEditPatternDispcxx . . $ editor_t#currEditPatternDisp. = &songcxx . . $ song.->currPatterncxx . . $ module_t#currPattern.;
1915 editorcxx . . $ editor..currPatternDispcxx . . $ editor_t#currPatternDisp. = &songcxx . . $ song.->headercxx . . $ module_t#header..patternTablecxx . . $ moduleHeader_t#patternTable.[songcxx . . $ song.->currPoscxx . . $ module_t#currPos.];
1916 editorcxx . . $ editor..currPosEdPattDispcxx . . $ editor_t#currPosEdPattDisp. = &songcxx . . $ song.->headercxx . . $ module_t#header..patternTablecxx . . $ moduleHeader_t#patternTable.[songcxx . . $ song.->currPoscxx . . $ module_t#currPos.];
1917
1918 modSetSpeedcxx . . $ modSetSpeed(d4f767463ce0a6b3).(oldSpeedcxx . . $ oldSpeed.);
1919 modSetTempocxx . . $ modSetTempo(918ebd27a9ddbad3).(oldBPMcxx . . $ oldBPM., truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!);
1920
1921 doStopItcxx . . $ doStopIt(b45ddcbc8423892c).(truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!);
1922
1923 songcxx . . $ song.->tickcxx . . $ module_t#tick. = 0;
1924 modRenderDonecxx . . $ modRenderDone. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
1925 }