History

Pushed v1.08 code

- The mouse system has been rewritten so that we don't need to do mouse capturing while interacting with GUI widgets, which could be buggy sometimes. - Fixed a bug when exiting from Edit Op. screen #4 ("Sample chord editor") and reopening it. It could mess up the UI in worst case scenarios. - Some other small miscellaneous changes not worth of a mention - Small code cleanup (and also the opposite :-)

Olav Sørensen committed 6 years ago

Commit 6f0d2c31 parent 0d1a2cf28 files · +2095 −1871Browse files

Unified · Split

28 files
  1. src/pt2_audio.c +325 −179
  2. src/pt2_audio.h +0 −1
  3. src/pt2_config.c +71 −71
  4. src/pt2_config.h +2 −2
  5. src/pt2_diskop.c +25 −25
  6. src/pt2_diskop.h +1 −1
  7. src/pt2_edit.c +17 −17
  8. src/pt2_header.h +45 −37
  9. src/pt2_helpers.c +6 −8
  10. src/pt2_keyboard.c +323 −325
  11. src/pt2_main.c +48 −44
  12. src/pt2_modloader.c +5 −6
  13. src/pt2_modplayer.c +16 −16
  14. src/pt2_mouse.c +353 −344
  15. src/pt2_palette.c +17 −24
  16. src/pt2_palette.h +2 −3
  17. src/pt2_patternviewer.c +74 −74
  18. src/pt2_patternviewer.h +1 −3
  19. src/pt2_sampleloader.c +10 −10
  20. src/pt2_sampler.c +149 −151
  21. src/pt2_scopes.c +34 −33
  22. src/pt2_scopes.h +5 −4
  23. src/pt2_tables.h +0 −3
  24. src/pt2_textout.c +132 −132
  25. src/pt2_textout.h +35 −35
  26. src/pt2_visuals.c +395 −322
  27. src/pt2_visuals.h +1 −1
  28. vs2019_project/pt2-clone/pt2-clone.vcxproj +3 −0
src/pt2_audio.c+325−179
@@ -53,11 +53,10 @@ typedef struct voice_t · 52 unmodified lines
5353 } paulaVoice_t;
5454
5555 static volatile int8_t filterFlags;
56−static volatile bool audioLocked;
5756 static int8_t defStereoSep;
5857 static bool amigaPanFlag, wavRenderingDone;
59−static uint16_t ch1Pan, ch2Pan, ch3Pan, ch4Pan, oldPeriod;
60−static int32_t sampleCounter, maxSamplesToMix, randSeed = INITIAL_DITHER_SEED;
58+static uint16_t ch1Pan, ch2Pan, ch3Pan, ch4Pan;
59+static int32_t oldPeriod, sampleCounter, maxSamplesToMix, randSeed = INITIAL_DITHER_SEED;
6160 static uint32_t oldScopeDelta;
6261 static double *dMixBufferL, *dMixBufferR, *dMixBufferLUnaligned, *dMixBufferRUnaligned, dOldVoiceDelta, dOldVoiceDeltaMul;
6362 static double dPrngStateL, dPrngStateR;
@@ -69,7 +68,6 @@ static paulaVoice_t paula[AMIGA_VOICES]; · 5 unmodified lines
6968 static SDL_AudioDeviceID dev;
7069
7170 // globalized
72−bool forceMixerOff = false;
7371 int32_t samplesPerTick;
7472
7573 bool intMusic(void); // defined in pt_modplayer.c
@@ -128,7 +126,8 @@ static void calcCoeffLED(double dSr, double dHz, ledFilterCoeff_t *filter) · 52 unmodified lines
128126
129127 #ifndef NO_FILTER_FINETUNING
130128 /* 8bitbubsy: makes the filter curve sound (and look) much closer to the real deal.
131− ** This has been tested against both an A500 and A1200 (real units). */
129+ ** This has been tested against both an A500 and A1200 (real units).
130+ */
132131 dFb *= 0.62;
133132 #endif
134133
@@ -184,7 +183,8 @@ void lossyIntegrator(lossyIntegrator_t *filter, double *dIn, double *dOut) · 49 unmodified lines
184183 ** This implementation has a less smooth cutoff curve compared to the old one, so it's
185184 ** maybe not the best. However, I stick to this one because it has a higher gain
186185 ** at the end of the curve (closer to real tested Amiga 500). It also sounds much closer when
187− ** comparing whitenoise on an A500. */
186+ ** comparing whitenoise on an A500.
187+ */
188188
189189 // left channel low-pass
190190 filter->dBuffer[0] = (filter->b0 * dIn[0]) + (filter->b1 * filter->dBuffer[0]) + DENORMAL_OFFSET;
@@ -224,7 +224,8 @@ void lossyIntegratorHighPassMono(lossyIntegrator_t *filter, double dIn, double * · 33 unmodified lines
224224 ** parameter range and have 'normalized' (1/2 = 0db) coeffs
225225 **
226226 ** the coeffs are for LERP(x, x * x, 0.224) * sqrt(2)
227−** max_error is minimized with 0.224 = 0.0013012886 */
227+** max_error is minimized with 0.224 = 0.0013012886
228+*/
228229 static double sinApx(double fX)
229230 {
230231 fX = fX * (2.0 - fX);
@@ -242,7 +243,7 @@ void lockAudio(void) · 11 unmodified lines
242243 if (dev != 0)
243244 SDL_LockAudioDevice(dev);
244245
245− audioLocked = true;
246+ audio.locked = true;
246247 }
247248
248249 void unlockAudio(void)
@@ -250,33 +251,7 @@ void unlockAudio(void) · 1 unmodified line
250251 if (dev != 0)
251252 SDL_UnlockAudioDevice(dev);
252253
253− audioLocked = false;
254−}
255−
256−void clearPaulaAndScopes(void)
257−{
258− uint8_t i;
259− double dOldPanL[4], dOldPanR[4];
260−
261− // copy old pans
262− for (i = 0; i < AMIGA_VOICES; i++)
263− {
264− dOldPanL[i] = paula[i].dPanL;
265− dOldPanR[i] = paula[i].dPanR;
266− }
267−
268− lockAudio();
269− memset(paula, 0, sizeof (paula));
270− unlockAudio();
271−
272− // store old pans
273− for (i = 0; i < AMIGA_VOICES; i++)
274− {
275− paula[i].dPanL = dOldPanL[i];
276− paula[i].dPanR = dOldPanR[i];
277− }
278−
279− clearScopes();
254+ audio.locked = false;
280255 }
281256
282257 void mixerUpdateLoops(void) // updates Paula loop (+ scopes)
@@ -284,14 +259,14 @@ void mixerUpdateLoops(void) // updates Paula loop (+ scopes) · 1 unmodified line
284259 moduleChannel_t *ch;
285260 moduleSample_t *s;
286261
287− for (uint8_t i = 0; i < AMIGA_VOICES; i++)
262+ for (int32_t i = 0; i < AMIGA_VOICES; i++)
288263 {
289264 ch = &modEntry->channels[i];
290265 if (ch->n_samplenum == editor.currSample)
291266 {
292267 s = &modEntry->samples[editor.currSample];
293268 paulaSetData(i, ch->n_start + s->loopStart);
294− paulaSetLength(i, s->loopLength / 2);
269+ paulaSetLength(i, s->loopLength >> 1);
295270 }
296271 }
297272 }
@@ -302,7 +277,8 @@ static void mixerSetVoicePan(uint8_t ch, uint16_t pan) // pan = 0..256 · 4 unmodified lines
302277
303278 /* proper 'normalized' equal-power panning is (assuming pan left to right):
304279 ** L = cos(p * pi * 1/2) * sqrt(2);
305− ** R = sin(p * pi * 1/2) * sqrt(2); */
280+ ** R = sin(p * pi * 1/2) * sqrt(2);
281+ */
306282 dPan = pan * (1.0 / 256.0); // 0.0..1.0
307283
308284 paula[ch].dPanL = cosApx(dPan);
@@ -311,24 +287,34 @@ static void mixerSetVoicePan(uint8_t ch, uint16_t pan) // pan = 0..256 · 2 unmodified lines
311287
312288 void mixerKillVoice(uint8_t ch)
313289 {
314− paulaVoice_t *v;
315− scopeChannelExt_t *s;
290+ const bool wasLocked = audio.locked;
291+ if (!wasLocked)
292+ lockAudio();
316293
317− v = &paula[ch];
318− s = &scopeExt[ch];
294+ // copy old pans
295+ const double dOldPanL = paula[ch].dPanL;
296+ const double dOldPanR = paula[ch].dPanR;
319297
320− v->active = false;
321− v->dVolume = 0.0;
298+ memset(&paula[ch], 0, sizeof (paulaVoice_t));
299+ stopScope(ch);
322300
323− s->active = false;
324− s->didSwapData = false;
301+ // store old pans
302+ paula[ch].dPanL = dOldPanL;
303+ paula[ch].dPanR = dOldPanR;
325304
326305 memset(&blep[ch], 0, sizeof (blep_t));
327306 memset(&blepVol[ch], 0, sizeof (blep_t));
307+
308+ if (!wasLocked)
309+ unlockAudio();
328310 }
329311
330312 void turnOffVoices(void)
331313 {
314+ const bool wasLocked = audio.locked;
315+ if (!wasLocked)
316+ lockAudio();
317+
332318 for (uint8_t i = 0; i < AMIGA_VOICES; i++)
333319 mixerKillVoice(i);
334320
@@ -339,121 +325,59 @@ void turnOffVoices(void) · 4 unmodified lines
339325 resetAudioDithering();
340326
341327 editor.tuningFlag = false;
342−}
343328
344−void paulaStopDMA(uint8_t ch)
345−{
346− scopeExt[ch].active = paula[ch].active = false;
347−}
348−
349−void paulaStartDMA(uint8_t ch)
350−{
351− const int8_t *dat;
352− int32_t length;
353− paulaVoice_t *v;
354− scopeChannel_t s, *sc;
355− scopeChannelExt_t *se;
356−
357− // trigger voice
358−
359− v = &paula[ch];
360−
361− dat = v->newData;
362− if (dat == NULL)
363− dat = &modEntry->sampleData[RESERVED_SAMPLE_OFFSET]; // dummy sample
364−
365− length = v->newLength;
366− if (length < 2)
367− length = 2; // for safety
368−
369− v->dPhase = 0.0;
370− v->pos = 0;
371− v->data = dat;
372− v->length = length;
373− v->active = true;
374−
375− // trigger scope
376−
377− sc = &scope[ch];
378− se = &scopeExt[ch];
379− s = *sc; // cache it
380−
381− dat = se->newData;
382− if (dat == NULL)
383− dat = &modEntry->sampleData[RESERVED_SAMPLE_OFFSET]; // dummy sample
384−
385− s.length = length;
386− s.data = dat;
387−
388− s.pos = 0;
389− s.posFrac = 0;
390−
391− // data/length is already set from replayer thread (important)
392− s.loopFlag = se->newLoopFlag;
393− s.loopStart = se->newLoopStart;
394−
395− se->didSwapData = false;
396− se->active = true;
397−
398− *sc = s; // update it
329+ if (!wasLocked)
330+ unlockAudio();
399331 }
400332
401333 void resetCachedMixerPeriod(void)
402334 {
403− oldPeriod = 0;
335+ oldPeriod = 0xFFFFFFFF;
404336 }
405337
338+// the following routines are only called from the mixer thread.
339+
406340 void paulaSetPeriod(uint8_t ch, uint16_t period)
407341 {
342+ int32_t realPeriod;
408343 double dPeriodToDeltaDiv;
409344 paulaVoice_t *v;
410345
411346 v = &paula[ch];
412347
413348 if (period == 0)
414− {
415− v->dDelta = 0.0; // confirmed behavior on real Amiga
416− v->dDeltaMul = 1.0; // for BLEP synthesis
417− setScopeDelta(ch, 0);
418− return;
419− }
420−
421− if (period < 113)
422− period = 113; // confirmed behavior on real Amiga
349+ realPeriod = 65536; // confirmed behavior on real Amiga
350+ else if (period < 113)
351+ realPeriod = 113; // confirmed behavior on real Amiga
352+ else
353+ realPeriod = period;
423354
424355 // if the new period was the same as the previous period, use cached deltas
425− if (period == oldPeriod)
426− {
427− v->dDelta = dOldVoiceDelta;
428− v->dDeltaMul = dOldVoiceDeltaMul; // for BLEP synthesis
429− setScopeDelta(ch, oldScopeDelta);
430− }
431− else
356+ if (realPeriod != oldPeriod)
432357 {
358+ oldPeriod = realPeriod;
359+
433360 // this period is not cached, calculate mixer/scope deltas
434361
435362 #if SCOPE_HZ != 64
436363 #error Scope Hz is not 64 (2^n), change rate calc. to use doubles+round in pt2_scope.c
437364 #endif
438− oldPeriod = period;
439−
440365 // if we are rendering pattern to sample (PAT2SMP), use different frequencies
441366 if (editor.isSMPRendering)
442367 dPeriodToDeltaDiv = editor.pat2SmpHQ ? (PAULA_PAL_CLK / 28836.0) : (PAULA_PAL_CLK / 22168.0);
443368 else
444369 dPeriodToDeltaDiv = audio.dPeriodToDeltaDiv;
445370
446− v->dDelta = dPeriodToDeltaDiv / period;
447− v->dDeltaMul = 1.0 / v->dDelta; // for BLEP synthesis
448−
449371 // cache these
450− dOldVoiceDelta = v->dDelta;
451− dOldVoiceDeltaMul = v->dDeltaMul; // for BLEP synthesis
452− oldScopeDelta = (PAULA_PAL_CLK * (65536UL / SCOPE_HZ)) / period;
453−
454− setScopeDelta(ch, oldScopeDelta);
372+ dOldVoiceDelta = dPeriodToDeltaDiv / realPeriod;
373+ dOldVoiceDeltaMul = 1.0 / dOldVoiceDelta; // for BLEP synthesis
374+ oldScopeDelta = (PAULA_PAL_CLK * (65536UL / SCOPE_HZ)) / realPeriod;
455375 }
456376
377+ v->dDelta = dOldVoiceDelta;
378+ v->dDeltaMul = dOldVoiceDeltaMul; // for BLEP synthesis
379+ setScopeDelta(ch, oldScopeDelta);
380+
457381 // for BLEP synthesis
458382
459383 if (v->dLastDelta == 0.0)
@@ -478,13 +402,13 @@ void paulaSetLength(uint8_t ch, uint16_t len) · 18 unmodified lines
478402 if (len == 0)
479403 {
480404 len = 65535;
481− /* confirmed behavior on real Amiga (also needed for safety)
405+ /* Confirmed behavior on real Amiga (also needed for safety).
482406 ** And yes, we have room for this, it will never overflow!
483407 */
484408 }
485409
486410 // our mixer works with bytes, not words. Multiply by two
487− scopeExt[ch].newLength = paula[ch].newLength = len * 2;
411+ scopeExt[ch].newLength = paula[ch].newLength = len << 1;
488412 }
489413
490414 void paulaSetData(uint8_t ch, const int8_t *src)
@@ -514,25 +438,86 @@ void paulaSetData(uint8_t ch, const int8_t *src) · 23 unmodified lines
514438 *se = tmp; // update it
515439 }
516440
441+void paulaStopDMA(uint8_t ch)
442+{
443+ scopeExt[ch].active = paula[ch].active = false;
444+}
445+
446+void paulaStartDMA(uint8_t ch)
447+{
448+ const int8_t *dat;
449+ int32_t length;
450+ paulaVoice_t *v;
451+ scopeChannel_t s, *sc;
452+ scopeChannelExt_t *se;
453+
454+ // trigger voice
455+
456+ v = &paula[ch];
457+
458+ dat = v->newData;
459+ if (dat == NULL)
460+ dat = &modEntry->sampleData[RESERVED_SAMPLE_OFFSET]; // dummy sample
461+
462+ length = v->newLength;
463+ if (length < 2)
464+ length = 2; // for safety
465+
466+ v->dPhase = 0.0;
467+ v->pos = 0;
468+ v->data = dat;
469+ v->length = length;
470+ v->active = true;
471+
472+ // trigger scope
473+
474+ sc = &scope[ch];
475+ se = &scopeExt[ch];
476+ s = *sc; // cache it
477+
478+ dat = se->newData;
479+ if (dat == NULL)
480+ dat = &modEntry->sampleData[RESERVED_SAMPLE_OFFSET]; // dummy sample
481+
482+ s.length = length;
483+ s.data = dat;
484+
485+ s.pos = 0;
486+ s.posFrac = 0;
487+
488+ // data/length is already set from replayer thread (important)
489+ s.loopFlag = se->newLoopFlag;
490+ s.loopStart = se->newLoopStart;
491+
492+ se->didSwapData = false;
493+ se->active = true;
494+
495+ *sc = s; // update it
496+}
497+
517498 void toggleA500Filters(void)
518499 {
500+ lockAudio();
501+ clearLossyIntegrator(&filterLo);
502+ clearLossyIntegrator(&filterHi);
503+ clearLEDFilter(&filterLED);
504+ unlockAudio();
505+
519506 if (filterFlags & FILTER_A500)
520507 {
521508 filterFlags &= ~FILTER_A500;
522− displayMsg("FILTER MOD: A1200");
509+ displayMsg("LP FILTER: A1200");
523510 }
524511 else
525512 {
526513 filterFlags |= FILTER_A500;
527− clearLossyIntegrator(&filterLo);
528− displayMsg("FILTER MOD: A500");
514+ displayMsg("LP FILTER: A500");
529515 }
530516 }
531517
532518 void mixChannels(int32_t numSamples)
533519 {
534− const int8_t *dataPtr;
535− double dTempSample, dTempVolume;
520+ double dSmp, dVol;
536521 blep_t *bSmp, *bVol;
537522 paulaVoice_t *v;
538523
@@ -542,7 +527,7 @@ void mixChannels(int32_t numSamples) · 3 unmodified lines
542527 for (int32_t i = 0; i < AMIGA_VOICES; i++)
543528 {
544529 v = &paula[i];
545− if (!v->active)
530+ if (!v->active || v->data == NULL)
546531 continue;
547532
548533 bSmp = &blep[i];
@@ -550,47 +535,108 @@ void mixChannels(int32_t numSamples) · 1 unmodified line
550535
551536 for (int32_t j = 0; j < numSamples; j++)
552537 {
553− dataPtr = v->data;
554− if (dataPtr == NULL)
538+ assert(v->data != NULL);
539+ dSmp = v->data[v->pos] * (1.0 / 128.0);
540+ dVol = v->dVolume;
541+
542+ if (dSmp != bSmp->dLastValue)
555543 {
556− dTempSample = 0.0;
557− dTempVolume = 0.0;
544+ if (v->dLastDelta > v->dLastPhase)
545+ {
546+ // div->mul trick: v->dLastDeltaMul is 1.0 / v->dLastDelta
547+ blepAdd(bSmp, v->dLastPhase * v->dLastDeltaMul, bSmp->dLastValue - dSmp);
548+ }
549+
550+ bSmp->dLastValue = dSmp;
558551 }
559− else
552+
553+ if (dVol != bVol->dLastValue)
560554 {
561− dTempSample = dataPtr[v->pos] * (1.0 / 128.0);
562− dTempVolume = v->dVolume;
555+ blepVolAdd(bVol, bVol->dLastValue - dVol);
556+ bVol->dLastValue = dVol;
563557 }
564558
565− if (dTempSample != bSmp->dLastValue)
559+ if (bSmp->samplesLeft > 0) dSmp += blepRun(bSmp);
560+ if (bVol->samplesLeft > 0) dVol += blepRun(bVol);
561+
562+ dSmp *= dVol;
563+
564+ dMixBufferL[j] += dSmp * v->dPanL;
565+ dMixBufferR[j] += dSmp * v->dPanR;
566+
567+ v->dPhase += v->dDelta;
568+ if (v->dPhase >= 1.0)
569+ {
570+ v->dPhase -= 1.0;
571+
572+ v->dLastPhase = v->dPhase;
573+ v->dLastDelta = v->dDelta;
574+ v->dLastDeltaMul = v->dDeltaMul;
575+
576+ if (++v->pos >= v->length)
577+ {
578+ v->pos = 0;
579+
580+ // re-fetch new Paula register values now
581+ v->length = v->newLength;
582+ v->data = v->newData;
583+ }
584+ }
585+ }
586+ }
587+}
588+
589+void mixChannelsMultiStep(int32_t numSamples) // for PAT2SMP
590+{
591+ double dSmp, dVol;
592+ blep_t *bSmp, *bVol;
593+ paulaVoice_t *v;
594+
595+ memset(dMixBufferL, 0, numSamples * sizeof (double));
596+ memset(dMixBufferR, 0, numSamples * sizeof (double));
597+
598+ for (int32_t i = 0; i < AMIGA_VOICES; i++)
599+ {
600+ v = &paula[i];
601+ if (!v->active || v->data == NULL)
602+ continue;
603+
604+ bSmp = &blep[i];
605+ bVol = &blepVol[i];
606+
607+ for (int32_t j = 0; j < numSamples; j++)
608+ {
609+ assert(v->data != NULL);
610+ dSmp = v->data[v->pos] * (1.0 / 128.0);
611+ dVol = v->dVolume;
612+
613+ if (dSmp != bSmp->dLastValue)
566614 {
567615 if (v->dLastDelta > v->dLastPhase)
568616 {
569617 // div->mul trick: v->dLastDeltaMul is 1.0 / v->dLastDelta
570− blepAdd(bSmp, v->dLastPhase * v->dLastDeltaMul, bSmp->dLastValue - dTempSample);
618+ blepAdd(bSmp, v->dLastPhase * v->dLastDeltaMul, bSmp->dLastValue - dSmp);
571619 }
572620
573− bSmp->dLastValue = dTempSample;
621+ bSmp->dLastValue = dSmp;
574622 }
575623
576− if (dTempVolume != bVol->dLastValue)
624+ if (dVol != bVol->dLastValue)
577625 {
578− blepVolAdd(bVol, bVol->dLastValue - dTempVolume);
579− bVol->dLastValue = dTempVolume;
626+ blepVolAdd(bVol, bVol->dLastValue - dVol);
627+ bVol->dLastValue = dVol;
580628 }
581629
582− if (bSmp->samplesLeft > 0) dTempSample += blepRun(bSmp);
583− if (bVol->samplesLeft > 0) dTempVolume += blepRun(bVol);
630+ if (bSmp->samplesLeft > 0) dSmp += blepRun(bSmp);
631+ if (bVol->samplesLeft > 0) dVol += blepRun(bVol);
584632
585− dTempSample *= dTempVolume;
633+ dSmp *= dVol;
586634
587− dMixBufferL[j] += dTempSample * v->dPanL;
588− dMixBufferR[j] += dTempSample * v->dPanR;
635+ dMixBufferL[j] += dSmp * v->dPanL;
636+ dMixBufferR[j] += dSmp * v->dPanR;
589637
590638 v->dPhase += v->dDelta;
591−
592− // PAT2SMP needs multi-step, so use while() here (will be only one iteration in normal mixing mode)
593− while (v->dPhase >= 1.0)
639+ while (v->dPhase >= 1.0) // multi-step
594640 {
595641 v->dPhase -= 1.0;
596642
@@ -636,9 +682,42 @@ static inline void processMixedSamplesA1200(int32_t i, int16_t *out) · 39 unmodified lines
636682
637683 // don't process any low-pass filter since the cut-off is around 28-31kHz on A1200
638684
685+ // process high-pass filter
686+ lossyIntegratorHighPass(&filterHi, dOut, dOut);
687+
688+ // normalize and flip phase (A500/A1200 has an inverted audio signal)
689+ dOut[0] *= -(INT16_MAX / AMIGA_VOICES);
690+ dOut[1] *= -(INT16_MAX / AMIGA_VOICES);
691+
692+ // left channel - 1-bit triangular dithering (high-pass filtered)
693+ dPrng = random32() * (0.5 / INT32_MAX); // -0.5..0.5
694+ dOut[0] = (dOut[0] + dPrng) - dPrngStateL;
695+ dPrngStateL = dPrng;
696+ smp32 = (int32_t)dOut[0];
697+ CLAMP16(smp32);
698+ out[0] = (int16_t)smp32;
699+
700+ // right channel - 1-bit triangular dithering (high-pass filtered)
701+ dPrng = random32() * (0.5 / INT32_MAX); // -0.5..0.5
702+ dOut[1] = (dOut[1] + dPrng) - dPrngStateR;
703+ dPrngStateR = dPrng;
704+ smp32 = (int32_t)dOut[1];
705+ CLAMP16(smp32);
706+ out[1] = (int16_t)smp32;
707+}
708+
709+static inline void processMixedSamplesA1200LED(int32_t i, int16_t *out)
710+{
711+ int32_t smp32;
712+ double dOut[2], dPrng;
713+
714+ dOut[0] = dMixBufferL[i];
715+ dOut[1] = dMixBufferR[i];
716+
717+ // don't process any low-pass filter since the cut-off is around 28-31kHz on A1200
718+
639719 // process "LED" filter
640− if (filterFlags & FILTER_LED_ENABLED)
641− lossyIntegratorLED(filterLEDC, &filterLED, dOut, dOut);
720+ lossyIntegratorLED(filterLEDC, &filterLED, dOut, dOut);
642721
643722 // process high-pass filter
644723 lossyIntegratorHighPass(&filterHi, dOut, dOut);
@@ -702,17 +781,54 @@ static inline void processMixedSamplesA500(int32_t i, int16_t *out) · 57 unmodified lines
702781 out[1] = (int16_t)smp32;
703782 }
704783
784+static inline void processMixedSamplesA500LED(int32_t i, int16_t *out)
785+{
786+ int32_t smp32;
787+ double dOut[2], dPrng;
788+
789+ dOut[0] = dMixBufferL[i];
790+ dOut[1] = dMixBufferR[i];
791+
792+ // process low-pass filter
793+ lossyIntegrator(&filterLo, dOut, dOut);
794+
795+ // process "LED" filter
796+ lossyIntegratorLED(filterLEDC, &filterLED, dOut, dOut);
797+
798+ // process high-pass filter
799+ lossyIntegratorHighPass(&filterHi, dOut, dOut);
800+
801+ dOut[0] *= -(INT16_MAX / AMIGA_VOICES);
802+ dOut[1] *= -(INT16_MAX / AMIGA_VOICES);
803+
804+ // left channel - 1-bit triangular dithering (high-pass filtered)
805+ dPrng = random32() * (0.5 / INT32_MAX); // -0.5..0.5
806+ dOut[0] = (dOut[0] + dPrng) - dPrngStateL;
807+ dPrngStateL = dPrng;
808+ smp32 = (int32_t)dOut[0];
809+ CLAMP16(smp32);
810+ out[0] = (int16_t)smp32;
811+
812+ // right channel - 1-bit triangular dithering (high-pass filtered)
813+ dPrng = random32() * (0.5 / INT32_MAX); // -0.5..0.5
814+ dOut[1] = (dOut[1] + dPrng) - dPrngStateR;
815+ dPrngStateR = dPrng;
816+ smp32 = (int32_t)dOut[1];
817+ CLAMP16(smp32);
818+ out[1] = (int16_t)smp32;
819+}
820+
705821 void outputAudio(int16_t *target, int32_t numSamples)
706822 {
707823 int16_t *outStream, out[2];
708824 int32_t j;
709825
710− mixChannels(numSamples);
711−
712826 if (editor.isSMPRendering)
713827 {
714828 // render to sample (PAT2SMP)
715829
830+ mixChannelsMultiStep(numSamples);
831+
716832 for (j = 0; j < numSamples; j++)
717833 {
718834 processMixedSamplesA1200(j, out);
@@ -730,23 +846,53 @@ void outputAudio(int16_t *target, int32_t numSamples) · 11 unmodified lines
730846 {
731847 // render to stream
732848
849+ mixChannels(numSamples);
850+
733851 outStream = target;
734852 if (filterFlags & FILTER_A500)
735853 {
736− for (j = 0; j < numSamples; j++)
854+ // Amiga 500 filter model
855+
856+ if (filterFlags & FILTER_LED_ENABLED)
737857 {
738− processMixedSamplesA500(j, out);
739− *outStream++ = out[0];
740− *outStream++ = out[1];
858+ for (j = 0; j < numSamples; j++)
859+ {
860+ processMixedSamplesA500LED(j, out);
861+ *outStream++ = out[0];
862+ *outStream++ = out[1];
863+ }
864+ }
865+ else
866+ {
867+ for (j = 0; j < numSamples; j++)
868+ {
869+ processMixedSamplesA500(j, out);
870+ *outStream++ = out[0];
871+ *outStream++ = out[1];
872+ }
741873 }
742874 }
743875 else
744876 {
745− for (j = 0; j < numSamples; j++)
877+ // Amiga 1200 filter model
878+
879+ if (filterFlags & FILTER_LED_ENABLED)
746880 {
747− processMixedSamplesA1200(j, out);
748− *outStream++ = out[0];
749− *outStream++ = out[1];
881+ for (j = 0; j < numSamples; j++)
882+ {
883+ processMixedSamplesA1200LED(j, out);
884+ *outStream++ = out[0];
885+ *outStream++ = out[1];
886+ }
887+ }
888+ else
889+ {
890+ for (j = 0; j < numSamples; j++)
891+ {
892+ processMixedSamplesA1200(j, out);
893+ *outStream++ = out[0];
894+ *outStream++ = out[1];
895+ }
750896 }
751897 }
752898 }
@@ -759,7 +905,7 @@ static void SDLCALL audioCallback(void *userdata, Uint8 *stream, int len) · 6 unmodified lines
759905
760906 (void)userdata;
761907
762− if (forceMixerOff) // during MOD2WAV
908+ if (audio.forceMixerOff) // during MOD2WAV
763909 {
764910 memset(stream, 0, len);
765911 return;
@@ -878,12 +1024,12 @@ bool setupAudio(void) · 112 unmodified lines
8781024 {
8791025 SDL_AudioSpec want, have;
8801026
881− want.freq = ptConfig.soundFrequency;
1027+ want.freq = config.soundFrequency;
8821028 want.format = AUDIO_S16;
8831029 want.channels = 2;
8841030 want.callback = audioCallback;
8851031 want.userdata = NULL;
886− want.samples = ptConfig.soundBufferSize;
1032+ want.samples = config.soundBufferSize;
8871033
8881034 dev = SDL_OpenAudioDevice(NULL, 0, &want, &have, 0);
8891035 if (dev == 0)
@@ -921,15 +1067,15 @@ bool setupAudio(void) · 31 unmodified lines
9211067 dMixBufferR = (double *)ALIGN_PTR(dMixBufferRUnaligned, 256);
9221068
9231069 audio.audioBufferSize = have.samples;
924− ptConfig.soundFrequency = have.freq;
925− audio.audioFreq = ptConfig.soundFrequency;
926− audio.dAudioFreq = (double)ptConfig.soundFrequency;
1070+ config.soundFrequency = have.freq;
1071+ audio.audioFreq = config.soundFrequency;
1072+ audio.dAudioFreq = (double)config.soundFrequency;
9271073 audio.dPeriodToDeltaDiv = PAULA_PAL_CLK / audio.dAudioFreq;
9281074
929− mixerCalcVoicePans(ptConfig.stereoSeparation);
930− defStereoSep = ptConfig.stereoSeparation;
1075+ mixerCalcVoicePans(config.stereoSeparation);
1076+ defStereoSep = config.stereoSeparation;
9311077
932− filterFlags = ptConfig.a500LowPassFilter ? FILTER_A500 : 0;
1078+ filterFlags = config.a500LowPassFilter ? FILTER_A500 : 0;
9331079
9341080 calculateFilterCoeffs();
9351081 generateBpmTables();
src/pt2_audio.h+0−1
@@ -37,7 +37,6 @@ void paulaSetLength(uint8_t ch, uint16_t len); · 36 unmodified lines
3737 void paulaSetData(uint8_t ch, const int8_t *src);
3838 void lockAudio(void);
3939 void unlockAudio(void);
40−void clearPaulaAndScopes(void);
4140 void mixerUpdateLoops(void);
4241 void mixerKillVoice(uint8_t ch);
4342 void turnOffVoices(void);
src/pt2_config.c+71−71
@@ -41,26 +41,26 @@ void loadConfig(void) · 40 unmodified lines
4141 FILE *f;
4242
4343 // set default config values first
44− ptConfig.fullScreenStretch = false;
45− ptConfig.pattDots = false;
46− ptConfig.dottedCenterFlag = true;
47− ptConfig.a500LowPassFilter = false;
48− ptConfig.soundFrequency = 48000;
49− ptConfig.rememberPlayMode = false;
50− ptConfig.stereoSeparation = 20;
51− ptConfig.videoScaleFactor = 2;
52− ptConfig.realVuMeters = false;
53− ptConfig.modDot = false;
54− ptConfig.accidental = 0; // sharp
55− ptConfig.quantizeValue = 1;
56− ptConfig.transDel = false;
57− ptConfig.blankZeroFlag = false;
58− ptConfig.compoMode = false;
59− ptConfig.soundBufferSize = 1024;
60− ptConfig.autoCloseDiskOp = true;
61− ptConfig.vsyncOff = false;
62− ptConfig.hwMouse = false;
63− ptConfig.sampleLowpass = true;
44+ config.fullScreenStretch = false;
45+ config.pattDots = false;
46+ config.dottedCenterFlag = true;
47+ config.a500LowPassFilter = false;
48+ config.soundFrequency = 48000;
49+ config.rememberPlayMode = false;
50+ config.stereoSeparation = 20;
51+ config.videoScaleFactor = 2;
52+ config.realVuMeters = false;
53+ config.modDot = false;
54+ config.accidental = 0; // sharp
55+ config.quantizeValue = 1;
56+ config.transDel = false;
57+ config.blankZeroFlag = false;
58+ config.compoMode = false;
59+ config.soundBufferSize = 1024;
60+ config.autoCloseDiskOp = true;
61+ config.vsyncOff = false;
62+ config.hwMouse = false;
63+ config.sampleLowpass = true;
6464
6565 #ifndef _WIN32
6666 getcwd(oldCwd, PATH_MAX);
@@ -191,127 +191,127 @@ static bool loadProTrackerDotIni(FILE *f) · 124 unmodified lines
191191 // HWMOUSE
192192 else if (!_strnicmp(configLine, "HWMOUSE=", 8))
193193 {
194− if (!_strnicmp(&configLine[8], "TRUE", 4)) ptConfig.hwMouse = true;
195− else if (!_strnicmp(&configLine[8], "FALSE", 5)) ptConfig.hwMouse = false;
194+ if (!_strnicmp(&configLine[8], "TRUE", 4)) config.hwMouse = true;
195+ else if (!_strnicmp(&configLine[8], "FALSE", 5)) config.hwMouse = false;
196196 }
197197
198198 // SAMPLELOWPASS
199199 else if (!_strnicmp(configLine, "SAMPLELOWPASS=", 14))
200200 {
201− if (!_strnicmp(&configLine[14], "TRUE", 4)) ptConfig.sampleLowpass = true;
202− else if (!_strnicmp(&configLine[14], "FALSE", 5)) ptConfig.sampleLowpass = false;
201+ if (!_strnicmp(&configLine[14], "TRUE", 4)) config.sampleLowpass = true;
202+ else if (!_strnicmp(&configLine[14], "FALSE", 5)) config.sampleLowpass = false;
203203 }
204204
205205 // VSYNCOFF
206206 else if (!_strnicmp(configLine, "VSYNCOFF=", 9))
207207 {
208− if (!_strnicmp(&configLine[9], "TRUE", 4)) ptConfig.vsyncOff = true;
209− else if (!_strnicmp(&configLine[9], "FALSE", 5)) ptConfig.vsyncOff = false;
208+ if (!_strnicmp(&configLine[9], "TRUE", 4)) config.vsyncOff = true;
209+ else if (!_strnicmp(&configLine[9], "FALSE", 5)) config.vsyncOff = false;
210210 }
211211
212212 // FULLSCREENSTRETCH
213213 else if (!_strnicmp(configLine, "FULLSCREENSTRETCH=", 18))
214214 {
215− if (!_strnicmp(&configLine[18], "TRUE", 4)) ptConfig.fullScreenStretch = true;
216− else if (!_strnicmp(&configLine[18], "FALSE", 5)) ptConfig.fullScreenStretch = false;
215+ if (!_strnicmp(&configLine[18], "TRUE", 4)) config.fullScreenStretch = true;
216+ else if (!_strnicmp(&configLine[18], "FALSE", 5)) config.fullScreenStretch = false;
217217 }
218218
219219 // HIDEDISKOPDATES
220220 else if (!_strnicmp(configLine, "HIDEDISKOPDATES=", 16))
221221 {
222− if (!_strnicmp(&configLine[16], "TRUE", 4)) ptConfig.hideDiskOpDates = true;
223− else if (!_strnicmp(&configLine[16], "FALSE", 5)) ptConfig.hideDiskOpDates = false;
222+ if (!_strnicmp(&configLine[16], "TRUE", 4)) config.hideDiskOpDates = true;
223+ else if (!_strnicmp(&configLine[16], "FALSE", 5)) config.hideDiskOpDates = false;
224224 }
225225
226226 // AUTOCLOSEDISKOP
227227 else if (!_strnicmp(configLine, "AUTOCLOSEDISKOP=", 16))
228228 {
229− if (!_strnicmp(&configLine[16], "TRUE", 4)) ptConfig.autoCloseDiskOp = true;
230− else if (!_strnicmp(&configLine[16], "FALSE", 5)) ptConfig.autoCloseDiskOp = false;
229+ if (!_strnicmp(&configLine[16], "TRUE", 4)) config.autoCloseDiskOp = true;
230+ else if (!_strnicmp(&configLine[16], "FALSE", 5)) config.autoCloseDiskOp = false;
231231 }
232232
233233 // COMPOMODE
234234 else if (!_strnicmp(configLine, "COMPOMODE=", 10))
235235 {
236− if (!_strnicmp(&configLine[10], "TRUE", 4)) ptConfig.compoMode = true;
237− else if (!_strnicmp(&configLine[10], "FALSE", 5)) ptConfig.compoMode = false;
236+ if (!_strnicmp(&configLine[10], "TRUE", 4)) config.compoMode = true;
237+ else if (!_strnicmp(&configLine[10], "FALSE", 5)) config.compoMode = false;
238238 }
239239
240240 // PATTDOTS
241241 else if (!_strnicmp(configLine, "PATTDOTS=", 9))
242242 {
243− if (!_strnicmp(&configLine[9], "TRUE", 4)) ptConfig.pattDots = true;
244− else if (!_strnicmp(&configLine[9], "FALSE", 5)) ptConfig.pattDots = false;
243+ if (!_strnicmp(&configLine[9], "TRUE", 4)) config.pattDots = true;
244+ else if (!_strnicmp(&configLine[9], "FALSE", 5)) config.pattDots = false;
245245 }
246246
247247 // BLANKZERO
248248 else if (!_strnicmp(configLine, "BLANKZERO=", 10))
249249 {
250− if (!_strnicmp(&configLine[10], "TRUE", 4)) ptConfig.blankZeroFlag = true;
251− else if (!_strnicmp(&configLine[10], "FALSE", 5)) ptConfig.blankZeroFlag = false;
250+ if (!_strnicmp(&configLine[10], "TRUE", 4)) config.blankZeroFlag = true;
251+ else if (!_strnicmp(&configLine[10], "FALSE", 5)) config.blankZeroFlag = false;
252252 }
253253
254254 // REALVUMETERS
255255 else if (!_strnicmp(configLine, "REALVUMETERS=", 13))
256256 {
257− if (!_strnicmp(&configLine[13], "TRUE", 4)) ptConfig.realVuMeters = true;
258− else if (!_strnicmp(&configLine[13], "FALSE", 5)) ptConfig.realVuMeters = false;
257+ if (!_strnicmp(&configLine[13], "TRUE", 4)) config.realVuMeters = true;
258+ else if (!_strnicmp(&configLine[13], "FALSE", 5)) config.realVuMeters = false;
259259 }
260260
261261 // ACCIDENTAL
262262 else if (!_strnicmp(configLine, "ACCIDENTAL=", 11))
263263 {
264− if (!_strnicmp(&configLine[11], "SHARP", 4)) ptConfig.accidental = 0;
265− else if (!_strnicmp(&configLine[11], "FLAT", 5)) ptConfig.accidental = 1;
264+ if (!_strnicmp(&configLine[11], "SHARP", 4)) config.accidental = 0;
265+ else if (!_strnicmp(&configLine[11], "FLAT", 5)) config.accidental = 1;
266266 }
267267
268268 // QUANTIZE
269269 else if (!_strnicmp(configLine, "QUANTIZE=", 9))
270270 {
271271 if (configLine[9] != '\0')
272− ptConfig.quantizeValue = (int16_t)(CLAMP(atoi(&configLine[9]), 0, 63));
272+ config.quantizeValue = (int16_t)(CLAMP(atoi(&configLine[9]), 0, 63));
273273 }
274274
275275 // TRANSDEL
276276 else if (!_strnicmp(configLine, "TRANSDEL=", 9))
277277 {
278− if (!_strnicmp(&configLine[9], "TRUE", 4)) ptConfig.transDel = true;
279− else if (!_strnicmp(&configLine[9], "FALSE", 5)) ptConfig.transDel = false;
278+ if (!_strnicmp(&configLine[9], "TRUE", 4)) config.transDel = true;
279+ else if (!_strnicmp(&configLine[9], "FALSE", 5)) config.transDel = false;
280280 }
281281
282282 // DOTTEDCENTER
283283 else if (!_strnicmp(configLine, "DOTTEDCENTER=", 13))
284284 {
285− if (!_strnicmp(&configLine[13], "TRUE", 4)) ptConfig.dottedCenterFlag = true;
286− else if (!_strnicmp(&configLine[13], "FALSE", 5)) ptConfig.dottedCenterFlag = false;
285+ if (!_strnicmp(&configLine[13], "TRUE", 4)) config.dottedCenterFlag = true;
286+ else if (!_strnicmp(&configLine[13], "FALSE", 5)) config.dottedCenterFlag = false;
287287 }
288288
289289 // MODDOT
290290 else if (!_strnicmp(configLine, "MODDOT=", 7))
291291 {
292− if (!_strnicmp(&configLine[7], "TRUE", 4)) ptConfig.modDot = true;
293− else if (!_strnicmp(&configLine[7], "FALSE", 5)) ptConfig.modDot = false;
292+ if (!_strnicmp(&configLine[7], "TRUE", 4)) config.modDot = true;
293+ else if (!_strnicmp(&configLine[7], "FALSE", 5)) config.modDot = false;
294294 }
295295
296296 // SCALE3X (deprecated)
297297 else if (!_strnicmp(configLine, "SCALE3X=", 8))
298298 {
299− if (!_strnicmp(&configLine[8], "TRUE", 4)) ptConfig.videoScaleFactor = 3;
300− else if (!_strnicmp(&configLine[8], "FALSE", 5)) ptConfig.videoScaleFactor = 2;
299+ if (!_strnicmp(&configLine[8], "TRUE", 4)) config.videoScaleFactor = 3;
300+ else if (!_strnicmp(&configLine[8], "FALSE", 5)) config.videoScaleFactor = 2;
301301 }
302302
303303 // VIDEOSCALE
304304 else if (!_strnicmp(configLine, "VIDEOSCALE=", 11))
305305 {
306306 if (lineLen >= 13 && configLine[12] == 'X' && isdigit(configLine[11]))
307− ptConfig.videoScaleFactor = configLine[11] - '0';
307+ config.videoScaleFactor = configLine[11] - '0';
308308 }
309309
310310 // REMEMBERPLAYMODE
311311 else if (!_strnicmp(configLine, "REMEMBERPLAYMODE=", 17))
312312 {
313− if (!_strnicmp(&configLine[17], "TRUE", 4)) ptConfig.rememberPlayMode = true;
314− else if (!_strnicmp(&configLine[17], "FALSE", 5)) ptConfig.rememberPlayMode = false;
313+ if (!_strnicmp(&configLine[17], "TRUE", 4)) config.rememberPlayMode = true;
314+ else if (!_strnicmp(&configLine[17], "FALSE", 5)) config.rememberPlayMode = false;
315315 }
316316
317317 // DEFAULTDIR
@@ -325,7 +325,7 @@ static bool loadProTrackerDotIni(FILE *f) · 7 unmodified lines
325325
326326 lineLen -= i;
327327 if (lineLen > 0)
328− strncpy(ptConfig.defModulesDir, &configLine[i], (lineLen > PATH_MAX) ? PATH_MAX : lineLen);
328+ strncpy(config.defModulesDir, &configLine[i], (lineLen > PATH_MAX) ? PATH_MAX : lineLen);
329329 }
330330 }
331331
@@ -340,43 +340,43 @@ static bool loadProTrackerDotIni(FILE *f) · 8 unmodified lines
340340
341341 lineLen -= i;
342342 if (lineLen > 0)
343− strncpy(ptConfig.defSamplesDir, &configLine[i], (lineLen > PATH_MAX) ? PATH_MAX : lineLen);
343+ strncpy(config.defSamplesDir, &configLine[i], (lineLen > PATH_MAX) ? PATH_MAX : lineLen);
344344 }
345345 }
346346
347347 // A500LOWPASSFILTER
348348 else if (!_strnicmp(configLine, "A500LOWPASSFILTER=", 18))
349349 {
350− if (!_strnicmp(&configLine[18], "TRUE", 4)) ptConfig.a500LowPassFilter = true;
351− else if (!_strnicmp(&configLine[18], "FALSE", 5)) ptConfig.a500LowPassFilter = false;
350+ if (!_strnicmp(&configLine[18], "TRUE", 4)) config.a500LowPassFilter = true;
351+ else if (!_strnicmp(&configLine[18], "FALSE", 5)) config.a500LowPassFilter = false;
352352 }
353353
354354 // A4000LOWPASSFILTER (deprecated, same as A500LOWPASSFILTER)
355355 else if (!_strnicmp(configLine, "A4000LOWPASSFILTER=", 19))
356356 {
357− if (!_strnicmp(&configLine[19], "TRUE", 4)) ptConfig.a500LowPassFilter = true;
358− else if (!_strnicmp(&configLine[19], "FALSE", 5)) ptConfig.a500LowPassFilter = false;
357+ if (!_strnicmp(&configLine[19], "TRUE", 4)) config.a500LowPassFilter = true;
358+ else if (!_strnicmp(&configLine[19], "FALSE", 5)) config.a500LowPassFilter = false;
359359 }
360360
361361 // FREQUENCY
362362 else if (!_strnicmp(configLine, "FREQUENCY=", 10))
363363 {
364364 if (configLine[10] != '\0')
365− ptConfig.soundFrequency = (uint32_t)(CLAMP(atoi(&configLine[10]), 32000, 96000));
365+ config.soundFrequency = (uint32_t)(CLAMP(atoi(&configLine[10]), 32000, 96000));
366366 }
367367
368368 // BUFFERSIZE
369369 else if (!_strnicmp(configLine, "BUFFERSIZE=", 11))
370370 {
371371 if (configLine[11] != '\0')
372− ptConfig.soundBufferSize = (uint32_t)(CLAMP(atoi(&configLine[11]), 128, 8192));
372+ config.soundBufferSize = (uint32_t)(CLAMP(atoi(&configLine[11]), 128, 8192));
373373 }
374374
375375 // STEREOSEPARATION
376376 else if (!_strnicmp(configLine, "STEREOSEPARATION=", 17))
377377 {
378378 if (configLine[17] != '\0')
379− ptConfig.stereoSeparation = (int8_t)(CLAMP(atoi(&configLine[17]), 0, 100));
379+ config.stereoSeparation = (int8_t)(CLAMP(atoi(&configLine[17]), 0, 100));
380380 }
381381
382382 configLine = strtok(NULL, "\n");
@@ -450,20 +450,20 @@ static bool loadPTDotConfig(FILE *f) · 67 unmodified lines
450450 {
451451 fread(&tmp16, 2, 1, f); // stored as Big-Endian
452452 tmp16 = SWAP16(tmp16);
453− palette[i] = RGB12_to_RGB24(tmp16);
453+ video.palette[i] = RGB12_to_RGB24(tmp16);
454454 }
455455
456456 // Transpose Delete (delete out of range notes on transposing)
457457 fseek(f, 174, SEEK_SET);
458458 fread(&tmp8, 1, 1, f);
459− ptConfig.transDel = tmp8 ? true : false;
460− ptConfig.transDel = ptConfig.transDel;
459+ config.transDel = tmp8 ? true : false;
460+ config.transDel = config.transDel;
461461
462462 // Note style (sharps/flats)
463463 fseek(f, 200, SEEK_SET);
464464 fread(&tmp8, 1, 1, f);
465− ptConfig.accidental = tmp8 ? 1 : 0;
466− ptConfig.accidental = ptConfig.accidental;
465+ config.accidental = tmp8 ? 1 : 0;
466+ config.accidental = config.accidental;
467467
468468 // Multi Mode Next
469469 fseek(f, 462, SEEK_SET);
@@ -489,8 +489,8 @@ static bool loadPTDotConfig(FILE *f) · 19 unmodified lines
489489 // Blank Zeroes
490490 fseek(f, 490, SEEK_SET);
491491 fread(&tmp8, 1, 1, f);
492− ptConfig.blankZeroFlag = tmp8 ? true : false;
493− ptConfig.blankZeroFlag = ptConfig.blankZeroFlag;
492+ config.blankZeroFlag = tmp8 ? true : false;
493+ config.blankZeroFlag = config.blankZeroFlag;
494494
495495 // Initial Tempo (don't load if timing is set to VBLANK)
496496 if (editor.timingMode == TEMPO_MODE_CIA)
@@ -603,7 +603,7 @@ static bool loadColorsDotIni(void) · 106 unmodified lines
603603 {
604604 color = (hex2int(configLine[0]) << 8) | (hex2int(configLine[1]) << 4) | hex2int(configLine[2]);
605605 color &= 0xFFF;
606− palette[line] = RGB12_to_RGB24(color);
606+ video.palette[line] = RGB12_to_RGB24(color);
607607
608608 configLine = strtok(NULL, "\n");
609609 line++;
src/pt2_config.h+2−2
@@ -3,7 +3,7 @@ · 2 unmodified lines
33 #include <stdint.h>
44 #include <stdbool.h>
55
6−struct ptConfig_t
6+struct config_t
77 {
88 char *defModulesDir, *defSamplesDir;
99 bool dottedCenterFlag, pattDots, a500LowPassFilter, compoMode, autoCloseDiskOp, hideDiskOpDates, hwMouse;
@@ -12,6 +12,6 @@ struct ptConfig_t · 2 unmodified lines
1212 int8_t stereoSeparation, videoScaleFactor, accidental;
1313 uint16_t quantizeValue;
1414 uint32_t soundFrequency, soundBufferSize;
15−} ptConfig;
15+} config;
1616
1717 void loadConfig(void);
src/pt2_diskop.c+25−25
@@ -450,12 +450,12 @@ bool diskOpSetPath(UNICHAR *path, bool cache) · 449 unmodified lines
450450 void diskOpSetInitPath(void)
451451 {
452452 // default module path
453− if (ptConfig.defModulesDir[0] != '\0')
453+ if (config.defModulesDir[0] != '\0')
454454 {
455455 #ifdef _WIN32
456− MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, ptConfig.defModulesDir, -1, pathTmp, PATH_MAX);
456+ MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, config.defModulesDir, -1, pathTmp, PATH_MAX);
457457 #else
458− strcpy(pathTmp, ptConfig.defModulesDir);
458+ strcpy(pathTmp, config.defModulesDir);
459459 #endif
460460 UNICHAR_STRCPY(editor.modulesPathU, pathTmp);
461461 }
@@ -466,12 +466,12 @@ void diskOpSetInitPath(void) · 4 unmodified lines
466466 }
467467
468468 // default sample path
469− if (ptConfig.defSamplesDir[0] != '\0')
469+ if (config.defSamplesDir[0] != '\0')
470470 {
471471 #ifdef _WIN32
472− MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, ptConfig.defSamplesDir, -1, pathTmp, PATH_MAX);
472+ MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, config.defSamplesDir, -1, pathTmp, PATH_MAX);
473473 #else
474− strcpy(pathTmp, ptConfig.defSamplesDir);
474+ strcpy(pathTmp, config.defSamplesDir);
475475 #endif
476476 UNICHAR_STRCPY(editor.samplesPathU, pathTmp);
477477 }
@@ -715,14 +715,14 @@ static int32_t SDLCALL diskOpFillThreadFunc(void *ptr) · 237 unmodified lines
715715 return true;
716716 }
717717
718−static void printFileSize(uint32_t *frameBuffer, fileEntry_t *entry, uint16_t x, uint16_t y)
718+static void printFileSize(fileEntry_t *entry, uint16_t x, uint16_t y)
719719 {
720720 char tmpStr[7];
721721 uint32_t fileSize, j;
722722
723723 if (entry->filesize == -1) // -1 means that the original filesize is above 2GB in our directory reader
724724 {
725− textOut(frameBuffer, x, y, " >2GB", palette[PAL_QADSCP]);
725+ textOut(x, y, " >2GB", video.palette[PAL_QADSCP]);
726726 return;
727727 }
728728
@@ -754,27 +754,27 @@ static void printFileSize(uint32_t *frameBuffer, fileEntry_t *entry, uint16_t x, · 25 unmodified lines
754754 tmpStr[j] = ' ';
755755 }
756756
757− textOut(frameBuffer, x, y, tmpStr, palette[PAL_QADSCP]);
757+ textOut(x, y, tmpStr, video.palette[PAL_QADSCP]);
758758 }
759759
760−static void printEntryName(uint32_t *frameBuffer, char *entryName, int32_t entryLength, int32_t maxLength, uint16_t x, uint16_t y)
760+static void printEntryName(char *entryName, int32_t entryLength, int32_t maxLength, uint16_t x, uint16_t y)
761761 {
762762 if (entryLength > maxLength)
763763 {
764764 // shorten name and add ".." to end
765765 for (int32_t j = 0; j < maxLength-2; j++)
766− charOut(frameBuffer, x + (j * FONT_CHAR_W), y, entryName[j], palette[PAL_QADSCP]);
766+ charOut(x + (j * FONT_CHAR_W), y, entryName[j], video.palette[PAL_QADSCP]);
767767
768− textOut(frameBuffer, x + ((maxLength - 2) * FONT_CHAR_W), y, "..", palette[PAL_QADSCP]);
768+ textOut(x + ((maxLength - 2) * FONT_CHAR_W), y, "..", video.palette[PAL_QADSCP]);
769769 }
770770 else
771771 {
772772 // print whole name
773− textOut(frameBuffer, x, y, entryName, palette[PAL_QADSCP]);
773+ textOut(x, y, entryName, video.palette[PAL_QADSCP]);
774774 }
775775 }
776776
777−void diskOpRenderFileList(uint32_t *frameBuffer)
777+void diskOpRenderFileList(void)
778778 {
779779 char *entryName;
780780 uint8_t maxFilenameChars, maxDirNameChars;
@@ -783,7 +783,7 @@ void diskOpRenderFileList(uint32_t *frameBuffer) · 2 unmodified lines
783783 uint32_t *dstPtr;
784784 fileEntry_t *entry;
785785
786− if (ptConfig.hideDiskOpDates)
786+ if (config.hideDiskOpDates)
787787 {
788788 textXStart = 8;
789789 maxFilenameChars = 30;
@@ -813,11 +813,11 @@ void diskOpRenderFileList(uint32_t *frameBuffer) · 23 unmodified lines
813813 }
814814
815815 // clear list
816− dstPtr = &frameBuffer[(35 * SCREEN_W) + 8];
816+ dstPtr = &video.frameBuffer[(35 * SCREEN_W) + 8];
817817 for (y = 0; y < 59; y++)
818818 {
819819 for (x = 0; x < 295; x++)
820− dstPtr[x] = palette[PAL_BACKGRD];
820+ dstPtr[x] = video.palette[PAL_BACKGRD];
821821
822822 dstPtr += SCREEN_W;
823823 }
@@ -840,19 +840,19 @@ void diskOpRenderFileList(uint32_t *frameBuffer) · 16 unmodified lines
840840
841841 if (!entry->isDir)
842842 {
843− printEntryName(frameBuffer, entryName, entryLength, maxFilenameChars, x, y);
843+ printEntryName(entryName, entryLength, maxFilenameChars, x, y);
844844
845845 // print modification date
846− if (!ptConfig.hideDiskOpDates)
847− textOut(frameBuffer, 8, y, entry->dateChanged, palette[PAL_QADSCP]);
846+ if (!config.hideDiskOpDates)
847+ textOut(8, y, entry->dateChanged, video.palette[PAL_QADSCP]);
848848
849849 // print file size
850− printFileSize(frameBuffer, entry, 256, y);
850+ printFileSize(entry, 256, y);
851851 }
852852 else
853853 {
854− printEntryName(frameBuffer, entryName, entryLength, maxDirNameChars, x, y);
855− textOut(frameBuffer, 264, y, "(DIR)", palette[PAL_QADSCP]);
854+ printEntryName(entryName, entryLength, maxDirNameChars, x, y);
855+ textOut(264, y, "(DIR)", video.palette[PAL_QADSCP]);
856856 }
857857 }
858858 }
@@ -900,10 +900,10 @@ void diskOpLoadFile(uint32_t fileEntryRow, bool songModifiedCheck) · 41 unmodified lines
900900
901901 statusAllRight();
902902
903− if (ptConfig.autoCloseDiskOp)
903+ if (config.autoCloseDiskOp)
904904 editor.ui.diskOpScreenShown = false;
905905
906− if (ptConfig.rememberPlayMode)
906+ if (config.rememberPlayMode)
907907 {
908908 if (oldMode == MODE_PLAY || oldMode == MODE_RECORD)
909909 {
src/pt2_diskop.h+1−1
@@ -22,7 +22,7 @@ char *diskOpGetAnsiEntry(int32_t fileIndex); · 21 unmodified lines
2222 UNICHAR *diskOpGetUnicodeEntry(int32_t fileIndex);
2323 bool diskOpSetPath(UNICHAR *path, bool cache);
2424 void diskOpSetInitPath(void);
25−void diskOpRenderFileList(uint32_t *frameBuffer);
25+void diskOpRenderFileList(void);
2626 bool allocDiskOpVars(void);
2727 void freeDiskOpMem(void);
2828 void freeDiskOpEntryMem(void);
src/pt2_edit.c+17−17
@@ -256,14 +256,14 @@ void exitGetTextLine(bool updateValue) · 255 unmodified lines
256256
257257 case PTB_EO_QUANTIZE:
258258 {
259− editor.quantizeValueDisp = &ptConfig.quantizeValue;
259+ editor.quantizeValueDisp = &config.quantizeValue;
260260
261261 if (updateValue)
262262 {
263263 if (editor.ui.tmpDisp16 > 63)
264264 editor.ui.tmpDisp16 = 63;
265265
266− ptConfig.quantizeValue = editor.ui.tmpDisp16;
266+ config.quantizeValue = editor.ui.tmpDisp16;
267267 editor.ui.updateQuantizeText = true;
268268 }
269269 }
@@ -679,7 +679,7 @@ void handleEditKeys(SDL_Scancode scancode, bool normalMode) · 409 unmodified lines
679679 if (editor.ui.samplerScreenShown || (editor.currMode == MODE_IDLE || editor.currMode == MODE_PLAY))
680680 {
681681 // at this point it will only jam, not place it
682− if (!input.keyb.leftAltPressed && !input.keyb.leftAmigaPressed && !input.keyb.leftCtrlPressed && !input.keyb.shiftPressed)
682+ if (!keyb.leftAltPressed && !keyb.leftAmigaPressed && !keyb.leftCtrlPressed && !keyb.shiftPressed)
683683 jamAndPlaceSample(scancode, normalMode);
684684
685685 return;
@@ -701,7 +701,7 @@ void handleEditKeys(SDL_Scancode scancode, bool normalMode) · 15 unmodified lines
701701 if (editor.cursor.mode != CURSOR_NOTE)
702702 {
703703 // if we held down any key modifier at this point, then do nothing
704− if (input.keyb.leftAltPressed || input.keyb.leftAmigaPressed || input.keyb.leftCtrlPressed || input.keyb.shiftPressed)
704+ if (keyb.leftAltPressed || keyb.leftAmigaPressed || keyb.leftCtrlPressed || keyb.shiftPressed)
705705 return;
706706
707707 if (editor.currMode == MODE_EDIT || editor.currMode == MODE_RECORD)
@@ -821,13 +821,13 @@ void handleEditKeys(SDL_Scancode scancode, bool normalMode) · 113 unmodified lines
821821 {
822822 note = &modEntry->patterns[modEntry->currPattern][(modEntry->currRow * AMIGA_VOICES) + editor.cursor.channel];
823823
824− if (!input.keyb.leftAltPressed)
824+ if (!keyb.leftAltPressed)
825825 {
826826 note->sample = 0;
827827 note->period = 0;
828828 }
829829
830− if (input.keyb.shiftPressed || input.keyb.leftAltPressed)
830+ if (keyb.shiftPressed || keyb.leftAltPressed)
831831 {
832832 note->command = 0;
833833 note->param = 0;
@@ -842,7 +842,7 @@ void handleEditKeys(SDL_Scancode scancode, bool normalMode) · 8 unmodified lines
842842 else
843843 {
844844 // if we held down any key modifier at this point, then do nothing
845− if (input.keyb.leftAltPressed || input.keyb.leftAmigaPressed || input.keyb.leftCtrlPressed || input.keyb.shiftPressed)
845+ if (keyb.leftAltPressed || keyb.leftAmigaPressed || keyb.leftCtrlPressed || keyb.shiftPressed)
846846 return;
847847
848848 jamAndPlaceSample(scancode, normalMode);
@@ -854,7 +854,7 @@ bool handleSpecialKeys(SDL_Scancode scancode) · 5 unmodified lines
854854 {
855855 note_t *patt, *note, *prevNote;
856856
857− if (!input.keyb.leftAltPressed)
857+ if (!keyb.leftAltPressed)
858858 return false;
859859
860860 patt = modEntry->patterns[modEntry->currPattern];
@@ -1015,7 +1015,7 @@ uint8_t quantizeCheck(uint8_t row) · 154 unmodified lines
10151015 {
10161016 uint8_t tempRow, quantize;
10171017
1018− quantize = (uint8_t)ptConfig.quantizeValue;
1018+ quantize = (uint8_t)config.quantizeValue;
10191019
10201020 editor.didQuantize = false;
10211021 if (editor.currMode == MODE_RECORD)
@@ -1307,7 +1307,7 @@ void trackNoteUp(bool sampleAllFlag, uint8_t from, uint8_t to) · 285 unmodified lines
13071307 {
13081308 j = 35;
13091309
1310− if (ptConfig.transDel)
1310+ if (config.transDel)
13111311 {
13121312 noteSrc->period = 0;
13131313 noteSrc->sample = 0;
@@ -1360,7 +1360,7 @@ void trackNoteDown(bool sampleAllFlag, uint8_t from, uint8_t to) · 46 unmodified lines
13601360 {
13611361 j = 0;
13621362
1363− if (ptConfig.transDel)
1363+ if (config.transDel)
13641364 {
13651365 noteSrc->period = 0;
13661366 noteSrc->sample = 0;
@@ -1409,7 +1409,7 @@ void trackOctaUp(bool sampleAllFlag, uint8_t from, uint8_t to) · 42 unmodified lines
14091409 }
14101410
14111411 noteDeleted = false;
1412− if (j+12 > 35 && ptConfig.transDel)
1412+ if (j+12 > 35 && config.transDel)
14131413 {
14141414 noteSrc->period = 0;
14151415 noteSrc->sample = 0;
@@ -1460,7 +1460,7 @@ void trackOctaDown(bool sampleAllFlag, uint8_t from, uint8_t to) · 44 unmodified lines
14601460 }
14611461
14621462 noteDeleted = false;
1463− if (j-12 < 0 && ptConfig.transDel)
1463+ if (j-12 < 0 && config.transDel)
14641464 {
14651465 noteSrc->period = 0;
14661466 noteSrc->sample = 0;
@@ -1510,7 +1510,7 @@ void pattNoteUp(bool sampleAllFlag) · 43 unmodified lines
15101510 {
15111511 k = 35;
15121512
1513− if (ptConfig.transDel)
1513+ if (config.transDel)
15141514 {
15151515 noteSrc->period = 0;
15161516 noteSrc->sample = 0;
@@ -1559,7 +1559,7 @@ void pattNoteDown(bool sampleAllFlag) · 42 unmodified lines
15591559 {
15601560 k = 0;
15611561
1562− if (ptConfig.transDel)
1562+ if (config.transDel)
15631563 {
15641564 noteSrc->period = 0;
15651565 noteSrc->sample = 0;
@@ -1604,7 +1604,7 @@ void pattOctaUp(bool sampleAllFlag) · 38 unmodified lines
16041604 }
16051605
16061606 noteDeleted = false;
1607− if (k+12 > 35 && ptConfig.transDel)
1607+ if (k+12 > 35 && config.transDel)
16081608 {
16091609 noteSrc->period = 0;
16101610 noteSrc->sample = 0;
@@ -1651,7 +1651,7 @@ void pattOctaDown(bool sampleAllFlag) · 40 unmodified lines
16511651 }
16521652
16531653 noteDeleted = false;
1654− if (k-12 < 0 && ptConfig.transDel)
1654+ if (k-12 < 0 && config.transDel)
16551655 {
16561656 noteSrc->period = 0;
16571657 noteSrc->sample = 0;
src/pt2_header.h+45−37
@@ -12,8 +12,9 @@ · 11 unmodified lines
1212 #endif
1313 #include <stdint.h>
1414 #include "pt2_unicode.h"
15+#include "pt2_palette.h"
1516
16−#define PROG_VER_STR "1.07"
17+#define PROG_VER_STR "1.08"
1718
1819 #ifdef _WIN32
1920 #define DIR_DELIMITER '\\'
@@ -285,39 +286,53 @@ typedef struct module_t · 265 unmodified lines
285286 note_t *patterns[MAX_PATTERNS];
286287 } module_t;
287288
288−struct cpu_t
289−{
290− bool hasSSE, hasSSE2;
291−} cpu;
292−
293289 struct audio_t
294290 {
291+ volatile bool locked;
292+ bool forceMixerOff;
295293 uint16_t bpmTab[256-32], bpmTab28kHz[256-32], bpmTab22kHz[256-32];
296294 uint32_t audioFreq, audioBufferSize;
297295 double dAudioFreq, dPeriodToDeltaDiv;
298296 } audio;
299297
300−struct input_t
298+struct keyb_t
301299 {
302− struct keyb_t
303− {
304− bool repeatKey, delayKey;
305− bool shiftPressed, leftCtrlPressed, leftAltPressed;
306− bool leftCommandPressed, leftAmigaPressed, keypadEnterPressed;
307− uint8_t repeatCounter, delayCounter;
308− uint64_t repeatFrac;
309− SDL_Scancode lastRepKey, lastKey;
310− } keyb;
311−
312− struct mouse_t
313− {
314− volatile bool setPosFlag;
315− bool buttonWaiting, leftButtonPressed, rightButtonPressed;
316− uint8_t repeatCounter, buttonWaitCounter;
317− int32_t setPosX, setPosY, lastGUIButton, lastSmpFilterButton, prevX, prevY;
318− int16_t x, y, lastMouseX;
319− } mouse;
320−} input;
300+ bool repeatKey, delayKey;
301+ bool shiftPressed, leftCtrlPressed, leftAltPressed;
302+ bool leftCommandPressed, leftAmigaPressed, keypadEnterPressed;
303+ uint8_t repeatCounter, delayCounter;
304+ uint64_t repeatFrac;
305+ SDL_Scancode lastRepKey, lastKey;
306+} keyb;
307+
308+struct mouse_t
309+{
310+ volatile bool setPosFlag;
311+ bool buttonWaiting, leftButtonPressed, rightButtonPressed;
312+ uint8_t repeatCounter, buttonWaitCounter;
313+ int32_t x, y, lastMouseX, setPosX, setPosY, lastGUIButton, lastSmpFilterButton, prevX, prevY;
314+ uint32_t buttonState;
315+} mouse;
316+
317+struct video_t
318+{
319+ bool fullscreen, vsync60HzPresent, windowHidden;
320+ int32_t renderX, renderY, renderW, renderH, displayW, displayH;
321+ int32_t xScale, yScale;
322+ double dMouseXMul, dMouseYMul;
323+ SDL_PixelFormat *pixelFormat;
324+ uint32_t *frameBuffer, *frameBufferUnaligned;
325+
326+ SDL_Window *window;
327+ SDL_Renderer *renderer;
328+ SDL_Texture *texture;
329+
330+ uint32_t palette[PALETTE_NUM];
331+
332+#ifdef _WIN32
333+ HWND hWnd;
334+#endif
335+} video;
321336
322337 // this is massive...
323338 struct editor_t
@@ -337,7 +352,7 @@ struct editor_t · 13 unmodified lines
337352
338353 bool errorMsgActive, errorMsgBlock, multiFlag, metroFlag, keypadToggle8CFlag, normalizeFiltersFlag;
339354 bool sampleAllFlag, halfClipFlag, newOldFlag, pat2SmpHQ, mixFlag, useLEDFilter;
340− bool modLoaded, fullscreen, autoInsFlag, repeatKeyFlag, sampleZero, tuningFlag;
355+ bool modLoaded, autoInsFlag, repeatKeyFlag, sampleZero, tuningFlag;
341356 bool stepPlayEnabled, stepPlayBackwards, blockBufferFlag, blockMarkFlag, didQuantize;
342357 bool swapChannelFlag, configFound, abortMod2Wav, chordLengthMin, rowVisitTable[MOD_ORDERS * MOD_ROWS];
343358 bool muted[AMIGA_VOICES];
@@ -430,17 +445,10 @@ struct editor_t · 86 unmodified lines
430445 // these are used when things are drawn on top, for example clear/ask dialogs
431446 bool disablePosEd, disableVisualizer;
432447
433− bool vsync60HzPresent;
434448 int16_t lineCurX, lineCurY, editObject, sampleMarkingPos;
435449 uint16_t *numPtr16, tmpDisp16, *dstOffset, dstPos, textLength, editTextPos;
436450 uint16_t dstOffsetEnd, lastSampleOffset;
437− int32_t askTempData, renderX, renderY, renderW, renderH, displayW, displayH;
438− int32_t xScale, yScale;
439− double dMouseXMul, dMouseYMul;
440− SDL_PixelFormat *pixelFormat;
441−#ifdef _WIN32
442− HWND hWnd;
443−#endif
451+ int32_t askTempData;
444452 } ui;
445453
446454 struct sampler_t
@@ -448,8 +456,8 @@ struct editor_t · 1 unmodified line
448456 const int8_t *samStart;
449457 int8_t *blankSample, *copyBuf;
450458 int16_t loopStartPos, loopEndPos;
451− uint16_t dragStart, dragEnd, saveMouseX, lastSamPos;
452− int32_t samPointWidth, samOffset, samDisplay, samLength;
459+ uint16_t dragStart, dragEnd;
460+ int32_t samPointWidth, samOffset, samDisplay, samLength, saveMouseX, lastSamPos;
453461 int32_t lastMouseX, lastMouseY, tmpLoopStart, tmpLoopLength;
454462 uint32_t copyBufSize, samDrawStart, samDrawEnd;
455463 } sampler;
src/pt2_helpers.c+6−8
@@ -20,8 +20,6 @@ · 19 unmodified lines
2020 #include "pt2_tables.h"
2121 #include "pt2_palette.h"
2222
23−extern SDL_Window *window; // pt_main.c
24−
2523 // used for Windows usleep() implementation
2624 #ifdef _WIN32
2725 static NTSTATUS (__stdcall *NtDelayExecution)(BOOL Alertable, PLARGE_INTEGER DelayInterval);
@@ -71,7 +69,7 @@ void showErrorMsgBox(const char *fmt, ...) · 43 unmodified lines
7169 va_end(args);
7270
7371 // window can be NULL here, no problem...
74− SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Critical Error", strBuf, window);
72+ SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Critical Error", strBuf, video.window);
7573 }
7674
7775 void sanitizeFilenameChar(char *chr)
@@ -129,14 +127,14 @@ void updateWindowTitle(bool modified) · 51 unmodified lines
129127 {
130128 if (modified)
131129 {
132− if (ptConfig.modDot)
130+ if (config.modDot)
133131 sprintf(titleTemp, "ProTracker 2 clone v%s - \"mod.%s\" (unsaved)", PROG_VER_STR, modEntry->head.moduleTitle);
134132 else
135133 sprintf(titleTemp, "ProTracker 2 clone v%s - \"%s.mod\" (unsaved)", PROG_VER_STR, modEntry->head.moduleTitle);
136134 }
137135 else
138136 {
139− if (ptConfig.modDot)
137+ if (config.modDot)
140138 sprintf(titleTemp, "ProTracker 2 clone v%s - \"mod.%s\"", PROG_VER_STR, modEntry->head.moduleTitle);
141139 else
142140 sprintf(titleTemp, "ProTracker 2 clone v%s - \"%s.mod\"", PROG_VER_STR, modEntry->head.moduleTitle);
@@ -146,21 +144,21 @@ void updateWindowTitle(bool modified) · 3 unmodified lines
146144 {
147145 if (modified)
148146 {
149− if (ptConfig.modDot)
147+ if (config.modDot)
150148 sprintf(titleTemp, "ProTracker 2 clone v%s - \"mod.untitled\" (unsaved)", PROG_VER_STR);
151149 else
152150 sprintf(titleTemp, "ProTracker 2 clone v%s - \"untitled.mod\" (unsaved)", PROG_VER_STR);
153151 }
154152 else
155153 {
156− if (ptConfig.modDot)
154+ if (config.modDot)
157155 sprintf(titleTemp, "ProTracker 2 clone v%s - \"mod.untitled\"", PROG_VER_STR);
158156 else
159157 sprintf(titleTemp, "ProTracker 2 clone v%s - \"untitled.mod\"", PROG_VER_STR);
160158 }
161159 }
162160
163− SDL_SetWindowTitle(window, titleTemp);
161+ SDL_SetWindowTitle(video.window, titleTemp);
164162 }
165163
166164 void recalcChordLength(void)
src/pt2_keyboard.c+323−325
@@ -32,8 +32,6 @@ extern bool windowsKeyIsDown; · 31 unmodified lines
3232 extern HHOOK g_hKeyboardHook;
3333 #endif
3434
35−extern SDL_Window *window;
36−
3735 void movePatCurPrevCh(void);
3836 void movePatCurNextCh(void);
3937 void movePatCurRight(void);
@@ -58,14 +56,14 @@ void readKeyModifiers(void) · 18 unmodified lines
5856
5957 modState = SDL_GetModState();
6058
61− input.keyb.leftCtrlPressed = (modState & KMOD_LCTRL) ? true : false;
62− input.keyb.leftAltPressed = (modState & KMOD_LALT) ? true : false;
63− input.keyb.shiftPressed = (modState & (KMOD_LSHIFT + KMOD_RSHIFT)) ? true : false;
59+ keyb.leftCtrlPressed = (modState & KMOD_LCTRL) ? true : false;
60+ keyb.leftAltPressed = (modState & KMOD_LALT) ? true : false;
61+ keyb.shiftPressed = (modState & (KMOD_LSHIFT + KMOD_RSHIFT)) ? true : false;
6462 #ifdef __APPLE__
65− input.keyb.leftCommandPressed = (modState & KMOD_LGUI) ? true : false;
63+ keyb.leftCommandPressed = (modState & KMOD_LGUI) ? true : false;
6664 #endif
6765 #ifndef _WIN32 // MS Windows: handled in lowLevelKeyboardProc
68− input.keyb.leftAmigaPressed = (modState & KMOD_LGUI) ? true : false;
66+ keyb.leftAmigaPressed = (modState & KMOD_LGUI) ? true : false;
6967 #endif
7068 }
7169
@@ -88,7 +86,7 @@ LRESULT CALLBACK lowLevelKeyboardProc(int32_t nCode, WPARAM wParam, LPARAM lPara · 16 unmodified lines
8886 case WM_KEYUP:
8987 case WM_KEYDOWN:
9088 {
91− bEatKeystroke = (SDL_GetWindowFlags(window) & SDL_WINDOW_INPUT_FOCUS) && (p->vkCode == VK_LWIN || p->vkCode == VK_NUMLOCK);
89+ bEatKeystroke = (SDL_GetWindowFlags(video.window) & SDL_WINDOW_INPUT_FOCUS) && (p->vkCode == VK_LWIN || p->vkCode == VK_NUMLOCK);
9290
9391 if (bEatKeystroke)
9492 {
@@ -109,7 +107,7 @@ LRESULT CALLBACK lowLevelKeyboardProc(int32_t nCode, WPARAM wParam, LPARAM lPara · 14 unmodified lines
109107 else if (!windowsKeyIsDown)
110108 {
111109 windowsKeyIsDown = true;
112− input.keyb.leftAmigaPressed = true;
110+ keyb.leftAmigaPressed = true;
113111
114112 memset(&inputEvent, 0, sizeof (SDL_Event));
115113 inputEvent.type = SDL_KEYDOWN;
@@ -136,7 +134,7 @@ LRESULT CALLBACK lowLevelKeyboardProc(int32_t nCode, WPARAM wParam, LPARAM lPara · 20 unmodified lines
136134 else
137135 {
138136 windowsKeyIsDown = false;
139− input.keyb.leftAmigaPressed = false;
137+ keyb.leftAmigaPressed = false;
140138
141139 memset(&inputEvent, 0, sizeof (SDL_Event));
142140 inputEvent.type = SDL_KEYUP;
@@ -329,11 +327,11 @@ void keyUpHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 186 unmodified lines
329327
330328 if (scancode == SDL_SCANCODE_KP_PLUS)
331329 {
332− input.keyb.keypadEnterPressed = false;
330+ keyb.keypadEnterPressed = false;
333331 }
334332
335− if (scancode == input.keyb.lastRepKey)
336− input.keyb.lastRepKey = SDL_SCANCODE_UNKNOWN;
333+ if (scancode == keyb.lastRepKey)
334+ keyb.lastRepKey = SDL_SCANCODE_UNKNOWN;
337335
338336 switch (scancode)
339337 {
@@ -353,10 +351,10 @@ void keyUpHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 13 unmodified lines
353351
354352 default:
355353 {
356− input.keyb.repeatKey = false;
357− input.keyb.delayKey = false;
358− input.keyb.repeatFrac = 0;
359− input.keyb.delayCounter = 0;
354+ keyb.repeatKey = false;
355+ keyb.delayKey = false;
356+ keyb.repeatFrac = 0;
357+ keyb.delayCounter = 0;
360358 }
361359 break;
362360 }
@@ -392,17 +390,17 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 29 unmodified lines
392390 }
393391
394392 // kludge to allow certain repeat-keys to use custom repeat/delay values
395− if (editor.repeatKeyFlag && input.keyb.repeatKey && scancode == input.keyb.lastRepKey &&
396− (input.keyb.leftAltPressed || input.keyb.leftAmigaPressed || input.keyb.leftCtrlPressed))
393+ if (editor.repeatKeyFlag && keyb.repeatKey && scancode == keyb.lastRepKey &&
394+ (keyb.leftAltPressed || keyb.leftAmigaPressed || keyb.leftCtrlPressed))
397395 {
398396 return;
399397 }
400398
401399 if (scancode == SDL_SCANCODE_KP_PLUS)
402− input.keyb.keypadEnterPressed = true;
400+ keyb.keypadEnterPressed = true;
403401
404402 // TOGGLE FULLSCREEN (should always react)
405− if (scancode == SDL_SCANCODE_F11 && !input.keyb.leftAltPressed)
403+ if (scancode == SDL_SCANCODE_F11 && !keyb.leftAltPressed)
406404 {
407405 toggleFullScreen();
408406
@@ -428,23 +426,23 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 19 unmodified lines
428426 if (editor.repeatKeyFlag)
429427 {
430428 // if Repeat Flag, repeat all keys
431− if (!input.keyb.repeatKey)
429+ if (!keyb.repeatKey)
432430 {
433− input.keyb.repeatCounter = 0;
434− input.keyb.repeatFrac = 0;
431+ keyb.repeatCounter = 0;
432+ keyb.repeatFrac = 0;
435433 }
436434
437− input.keyb.repeatKey = true;
438− input.keyb.delayKey = true;
435+ keyb.repeatKey = true;
436+ keyb.delayKey = true;
439437 }
440438
441− input.keyb.repeatCounter = 0;
442− input.keyb.repeatFrac = 0;
443− input.keyb.lastRepKey = scancode;
439+ keyb.repeatCounter = 0;
440+ keyb.repeatFrac = 0;
441+ keyb.lastRepKey = scancode;
444442 }
445443
446444 // ENTRY JUMPING IN DISK OP. FILELIST
447− if (editor.ui.diskOpScreenShown && input.keyb.shiftPressed && !editor.ui.editTextFlag)
445+ if (editor.ui.diskOpScreenShown && keyb.shiftPressed && !editor.ui.editTextFlag)
448446 {
449447 if (keycode >= 32 && keycode <= 126)
450448 {
@@ -472,7 +470,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 21 unmodified lines
472470 {
473471 if (editor.autoInsFlag)
474472 {
475− if (input.keyb.shiftPressed)
473+ if (keyb.shiftPressed)
476474 editor.autoInsSlot -= 4;
477475 else
478476 editor.autoInsSlot--;
@@ -487,7 +485,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 8 unmodified lines
487485
488486 case SDL_SCANCODE_BACKSLASH:
489487 {
490− if (input.keyb.leftAltPressed)
488+ if (keyb.leftAltPressed)
491489 {
492490 if (handleSpecialKeys(scancode) && editor.currMode != MODE_RECORD)
493491 modSetPos(DONT_SET_ORDER, (modEntry->currRow + editor.editMoveAdd) & 0x3F);
@@ -496,7 +494,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 2 unmodified lines
496494 {
497495 if (editor.autoInsFlag)
498496 {
499− if (input.keyb.shiftPressed)
497+ if (keyb.shiftPressed)
500498 editor.autoInsSlot += 4;
501499 else
502500 editor.autoInsSlot++;
@@ -644,11 +642,11 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 141 unmodified lines
644642 }
645643 }
646644
647− if (!input.keyb.repeatKey)
648− input.keyb.delayCounter = 0;
645+ if (!keyb.repeatKey)
646+ keyb.delayCounter = 0;
649647
650− input.keyb.repeatKey = true;
651− input.keyb.delayKey = true;
648+ keyb.repeatKey = true;
649+ keyb.delayKey = true;
652650 }
653651 break;
654652
@@ -681,11 +679,11 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 26 unmodified lines
681679 modSetPos(DONT_SET_ORDER, modEntry->currRow + 16);
682680 }
683681
684− if (!input.keyb.repeatKey)
685− input.keyb.delayCounter = 0;
682+ if (!keyb.repeatKey)
683+ keyb.delayCounter = 0;
686684
687− input.keyb.repeatKey = true;
688− input.keyb.delayKey = true;
685+ keyb.repeatKey = true;
686+ keyb.delayKey = true;
689687 }
690688 break;
691689
@@ -745,7 +743,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 53 unmodified lines
745743
746744 case SDL_SCANCODE_F12:
747745 {
748− if (input.keyb.leftCtrlPressed)
746+ if (keyb.leftCtrlPressed)
749747 {
750748 editor.timingMode ^= 1;
751749 if (editor.timingMode == TEMPO_MODE_VBLANK)
@@ -760,7 +758,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 8 unmodified lines
760758
761759 editor.ui.updateSongTiming = true;
762760 }
763− else if (input.keyb.shiftPressed)
761+ else if (keyb.shiftPressed)
764762 {
765763 toggleAmigaPanMode();
766764 }
@@ -783,10 +781,10 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 16 unmodified lines
783781 }
784782 else
785783 {
786− if (input.keyb.shiftPressed || input.keyb.leftAltPressed || input.keyb.leftCtrlPressed)
784+ if (keyb.shiftPressed || keyb.leftAltPressed || keyb.leftCtrlPressed)
787785 {
788786 saveUndo();
789− if (input.keyb.leftAltPressed && !input.keyb.leftCtrlPressed)
787+ if (keyb.leftAltPressed && !keyb.leftCtrlPressed)
790788 {
791789 if (modEntry->currRow < 63)
792790 {
@@ -821,7 +819,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 28 unmodified lines
821819 noteSrc = &modEntry->patterns[modEntry->currPattern][((i + 0) * AMIGA_VOICES) + editor.cursor.channel];
822820 noteDst = &modEntry->patterns[modEntry->currPattern][((i + 1) * AMIGA_VOICES) + editor.cursor.channel];
823821
824− if (input.keyb.leftCtrlPressed)
822+ if (keyb.leftCtrlPressed)
825823 {
826824 noteDst->command = noteSrc->command;
827825 noteDst->param = noteSrc->param;
@@ -834,7 +832,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 6 unmodified lines
834832
835833 noteDst = &modEntry->patterns[modEntry->currPattern][((i + 1) * AMIGA_VOICES) + editor.cursor.channel];
836834
837− if (!input.keyb.leftCtrlPressed)
835+ if (!keyb.leftCtrlPressed)
838836 {
839837 noteDst->period = 0;
840838 noteDst->sample = 0;
@@ -903,7 +901,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 62 unmodified lines
903901 }
904902 else
905903 {
906− if (input.keyb.shiftPressed)
904+ if (keyb.shiftPressed)
907905 {
908906 // cut channel and put in buffer
909907 saveUndo();
@@ -923,7 +921,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 13 unmodified lines
923921 updateWindowTitle(MOD_IS_MODIFIED);
924922 editor.ui.updatePatternData = true;
925923 }
926− else if (input.keyb.leftAltPressed)
924+ else if (keyb.leftAltPressed)
927925 {
928926 // cut pattern and put in buffer
929927 saveUndo();
@@ -937,7 +935,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 7 unmodified lines
937935 updateWindowTitle(MOD_IS_MODIFIED);
938936 editor.ui.updatePatternData = true;
939937 }
940− else if (input.keyb.leftCtrlPressed)
938+ else if (keyb.leftCtrlPressed)
941939 {
942940 // cut channel commands and put in buffer
943941 saveUndo();
@@ -967,7 +965,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 23 unmodified lines
967965 }
968966 else
969967 {
970− if (input.keyb.shiftPressed)
968+ if (keyb.shiftPressed)
971969 {
972970 // copy channel to buffer
973971
@@ -975,14 +973,14 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 1 unmodified line
975973 for (i = 0; i < MOD_ROWS; i++)
976974 *noteDst++ = modEntry->patterns[modEntry->currPattern][(i * AMIGA_VOICES) + editor.cursor.channel];
977975 }
978− else if (input.keyb.leftAltPressed)
976+ else if (keyb.leftAltPressed)
979977 {
980978 // copy pattern to buffer
981979
982980 memcpy(editor.patternBuffer, modEntry->patterns[modEntry->currPattern],
983981 sizeof (note_t) * (AMIGA_VOICES * MOD_ROWS));
984982 }
985− else if (input.keyb.leftCtrlPressed)
983+ else if (keyb.leftCtrlPressed)
986984 {
987985 // copy channel commands to buffer
988986
@@ -1008,7 +1006,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 19 unmodified lines
10081006 }
10091007 else
10101008 {
1011− if (input.keyb.shiftPressed)
1009+ if (keyb.shiftPressed)
10121010 {
10131011 // paste channel buffer to channel
10141012 saveUndo();
@@ -1020,7 +1018,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 5 unmodified lines
10201018 updateWindowTitle(MOD_IS_MODIFIED);
10211019 editor.ui.updatePatternData = true;
10221020 }
1023− else if (input.keyb.leftAltPressed)
1021+ else if (keyb.leftAltPressed)
10241022 {
10251023 // paste pattern buffer to pattern
10261024 saveUndo();
@@ -1031,7 +1029,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 4 unmodified lines
10311029 updateWindowTitle(MOD_IS_MODIFIED);
10321030 editor.ui.updatePatternData = true;
10331031 }
1034− else if (input.keyb.leftCtrlPressed)
1032+ else if (keyb.leftCtrlPressed)
10351033 {
10361034 // paste channel commands buffer to channel
10371035 saveUndo();
@@ -1055,14 +1053,14 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 17 unmodified lines
10551053
10561054 case SDL_SCANCODE_F6:
10571055 {
1058− if (input.keyb.shiftPressed)
1056+ if (keyb.shiftPressed)
10591057 {
10601058 editor.f6Pos = modEntry->currRow;
10611059 displayMsg("POSITION SET");
10621060 }
10631061 else
10641062 {
1065− if (input.keyb.leftAltPressed)
1063+ if (keyb.leftAltPressed)
10661064 {
10671065 editor.playMode = PLAY_MODE_PATTERN;
10681066 modPlay(modEntry->currPattern, DONT_SET_ORDER, editor.f6Pos);
@@ -1071,7 +1069,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 2 unmodified lines
10711069 pointerSetMode(POINTER_MODE_PLAY, DO_CARRY);
10721070 statusAllRight();
10731071 }
1074− else if (input.keyb.leftCtrlPressed)
1072+ else if (keyb.leftCtrlPressed)
10751073 {
10761074 if (!editor.ui.samplerScreenShown)
10771075 {
@@ -1083,7 +1081,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 5 unmodified lines
10831081 statusAllRight();
10841082 }
10851083 }
1086− else if (input.keyb.leftAmigaPressed)
1084+ else if (keyb.leftAmigaPressed)
10871085 {
10881086 editor.playMode = PLAY_MODE_NORMAL;
10891087 modPlay(DONT_SET_PATTERN, modEntry->currOrder, editor.f6Pos);
@@ -1102,14 +1100,14 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 12 unmodified lines
11021100
11031101 case SDL_SCANCODE_F7:
11041102 {
1105− if (input.keyb.shiftPressed)
1103+ if (keyb.shiftPressed)
11061104 {
11071105 editor.f7Pos = modEntry->currRow;
11081106 displayMsg("POSITION SET");
11091107 }
11101108 else
11111109 {
1112− if (input.keyb.leftAltPressed)
1110+ if (keyb.leftAltPressed)
11131111 {
11141112 editor.playMode = PLAY_MODE_PATTERN;
11151113 modPlay(modEntry->currPattern, DONT_SET_ORDER, editor.f7Pos);
@@ -1118,7 +1116,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 2 unmodified lines
11181116 pointerSetMode(POINTER_MODE_PLAY, DO_CARRY);
11191117 statusAllRight();
11201118 }
1121− else if (input.keyb.leftCtrlPressed)
1119+ else if (keyb.leftCtrlPressed)
11221120 {
11231121 if (!editor.ui.samplerScreenShown)
11241122 {
@@ -1130,7 +1128,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 5 unmodified lines
11301128 statusAllRight();
11311129 }
11321130 }
1133− else if (input.keyb.leftAmigaPressed)
1131+ else if (keyb.leftAmigaPressed)
11341132 {
11351133 editor.playMode = PLAY_MODE_NORMAL;
11361134 modPlay(DONT_SET_PATTERN, modEntry->currOrder, editor.f7Pos);
@@ -1149,14 +1147,14 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 12 unmodified lines
11491147
11501148 case SDL_SCANCODE_F8:
11511149 {
1152− if (input.keyb.shiftPressed)
1150+ if (keyb.shiftPressed)
11531151 {
11541152 editor.f8Pos = modEntry->currRow;
11551153 displayMsg("POSITION SET");
11561154 }
11571155 else
11581156 {
1159− if (input.keyb.leftAltPressed)
1157+ if (keyb.leftAltPressed)
11601158 {
11611159 editor.playMode = PLAY_MODE_PATTERN;
11621160 modPlay(modEntry->currPattern, DONT_SET_ORDER, editor.f8Pos);
@@ -1165,7 +1163,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 2 unmodified lines
11651163 pointerSetMode(POINTER_MODE_PLAY, DO_CARRY);
11661164 statusAllRight();
11671165 }
1168− else if (input.keyb.leftCtrlPressed)
1166+ else if (keyb.leftCtrlPressed)
11691167 {
11701168 if (!editor.ui.samplerScreenShown)
11711169 {
@@ -1177,7 +1175,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 5 unmodified lines
11771175 statusAllRight();
11781176 }
11791177 }
1180− else if (input.keyb.leftAmigaPressed)
1178+ else if (keyb.leftAmigaPressed)
11811179 {
11821180 editor.playMode = PLAY_MODE_NORMAL;
11831181 modPlay(DONT_SET_PATTERN, modEntry->currOrder, editor.f8Pos);
@@ -1196,14 +1194,14 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 12 unmodified lines
11961194
11971195 case SDL_SCANCODE_F9:
11981196 {
1199− if (input.keyb.shiftPressed)
1197+ if (keyb.shiftPressed)
12001198 {
12011199 editor.f9Pos = modEntry->currRow;
12021200 displayMsg("POSITION SET");
12031201 }
12041202 else
12051203 {
1206− if (input.keyb.leftAltPressed)
1204+ if (keyb.leftAltPressed)
12071205 {
12081206 editor.playMode = PLAY_MODE_PATTERN;
12091207 modPlay(modEntry->currPattern, DONT_SET_ORDER, editor.f9Pos);
@@ -1212,7 +1210,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 2 unmodified lines
12121210 pointerSetMode(POINTER_MODE_PLAY, DO_CARRY);
12131211 statusAllRight();
12141212 }
1215− else if (input.keyb.leftCtrlPressed)
1213+ else if (keyb.leftCtrlPressed)
12161214 {
12171215 if (!editor.ui.samplerScreenShown)
12181216 {
@@ -1224,7 +1222,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 5 unmodified lines
12241222 statusAllRight();
12251223 }
12261224 }
1227− else if (input.keyb.leftAmigaPressed)
1225+ else if (keyb.leftAmigaPressed)
12281226 {
12291227 editor.playMode = PLAY_MODE_NORMAL;
12301228 modPlay(DONT_SET_PATTERN, modEntry->currOrder, editor.f9Pos);
@@ -1243,14 +1241,14 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 12 unmodified lines
12431241
12441242 case SDL_SCANCODE_F10:
12451243 {
1246− if (input.keyb.shiftPressed)
1244+ if (keyb.shiftPressed)
12471245 {
12481246 editor.f10Pos = modEntry->currRow;
12491247 displayMsg("POSITION SET");
12501248 }
12511249 else
12521250 {
1253− if (input.keyb.leftAltPressed)
1251+ if (keyb.leftAltPressed)
12541252 {
12551253 editor.playMode = PLAY_MODE_PATTERN;
12561254 modPlay(modEntry->currPattern, DONT_SET_ORDER, editor.f10Pos);
@@ -1259,7 +1257,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 2 unmodified lines
12591257 pointerSetMode(POINTER_MODE_PLAY, DO_CARRY);
12601258 statusAllRight();
12611259 }
1262− else if (input.keyb.leftCtrlPressed)
1260+ else if (keyb.leftCtrlPressed)
12631261 {
12641262 if (!editor.ui.samplerScreenShown)
12651263 {
@@ -1271,7 +1269,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 5 unmodified lines
12711269 statusAllRight();
12721270 }
12731271 }
1274− else if (input.keyb.leftAmigaPressed)
1272+ else if (keyb.leftAmigaPressed)
12751273 {
12761274 editor.playMode = PLAY_MODE_NORMAL;
12771275 modPlay(DONT_SET_PATTERN, modEntry->currOrder, editor.f10Pos);
@@ -1290,17 +1288,17 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 12 unmodified lines
12901288
12911289 case SDL_SCANCODE_F11:
12921290 {
1293− if (input.keyb.leftAltPressed)
1291+ if (keyb.leftAltPressed)
12941292 {
1295− ptConfig.realVuMeters ^= 1;
1296− displayMsg(ptConfig.realVuMeters ? "VU-METERS: REAL" : "VU-METERS: FAKE");
1293+ config.realVuMeters ^= 1;
1294+ displayMsg(config.realVuMeters ? "VU-METERS: REAL" : "VU-METERS: FAKE");
12971295 }
12981296 }
12991297 break;
13001298
13011299 case SDL_SCANCODE_TAB:
13021300 {
1303− if (input.keyb.shiftPressed)
1301+ if (keyb.shiftPressed)
13041302 movePatCurPrevCh();
13051303 else
13061304 movePatCurNextCh();
@@ -1309,13 +1307,13 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 2 unmodified lines
13091307
13101308 case SDL_SCANCODE_0:
13111309 {
1312− if (input.keyb.leftCtrlPressed)
1310+ if (keyb.leftCtrlPressed)
13131311 {
13141312 editor.editMoveAdd = 0;
13151313 displayMsg("EDITSKIP = 0");
13161314 editor.ui.updateTrackerFlags = true;
13171315 }
1318− else if (input.keyb.shiftPressed)
1316+ else if (keyb.shiftPressed)
13191317 {
13201318 noteSrc = &modEntry->patterns[modEntry->currPattern][(modEntry->currRow * AMIGA_VOICES) + editor.cursor.channel];
13211319 editor.effectMacros[9] = (noteSrc->command << 8) | noteSrc->param;
@@ -1330,23 +1328,23 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 8 unmodified lines
13301328
13311329 case SDL_SCANCODE_1:
13321330 {
1333− if (input.keyb.leftAmigaPressed)
1331+ if (keyb.leftAmigaPressed)
13341332 {
13351333 trackNoteUp(TRANSPOSE_ALL, 0, MOD_ROWS - 1);
13361334 }
1337− else if (input.keyb.leftCtrlPressed)
1335+ else if (keyb.leftCtrlPressed)
13381336 {
13391337 editor.editMoveAdd = 1;
13401338 displayMsg("EDITSKIP = 1");
13411339 editor.ui.updateTrackerFlags = true;
13421340 }
1343− else if (input.keyb.shiftPressed)
1341+ else if (keyb.shiftPressed)
13441342 {
13451343 noteSrc = &modEntry->patterns[modEntry->currPattern][(modEntry->currRow * AMIGA_VOICES) + editor.cursor.channel];
13461344 editor.effectMacros[0] = (noteSrc->command << 8) | noteSrc->param;
13471345 displayMsg("COMMAND STORED!");
13481346 }
1349− else if (editor.currMode == MODE_IDLE && input.keyb.leftAltPressed)
1347+ else if (editor.currMode == MODE_IDLE && keyb.leftAltPressed)
13501348 {
13511349 incMulti(0);
13521350 }
@@ -1359,23 +1357,23 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 6 unmodified lines
13591357
13601358 case SDL_SCANCODE_2:
13611359 {
1362− if (input.keyb.leftAmigaPressed)
1360+ if (keyb.leftAmigaPressed)
13631361 {
13641362 pattNoteUp(TRANSPOSE_ALL);
13651363 }
1366− else if (input.keyb.leftCtrlPressed)
1364+ else if (keyb.leftCtrlPressed)
13671365 {
13681366 editor.editMoveAdd = 2;
13691367 displayMsg("EDITSKIP = 2");
13701368 editor.ui.updateTrackerFlags = true;
13711369 }
1372− else if (input.keyb.shiftPressed)
1370+ else if (keyb.shiftPressed)
13731371 {
13741372 noteSrc = &modEntry->patterns[modEntry->currPattern][(modEntry->currRow * AMIGA_VOICES) + editor.cursor.channel];
13751373 editor.effectMacros[1] = (noteSrc->command << 8) | noteSrc->param;
13761374 displayMsg("COMMAND STORED!");
13771375 }
1378− else if (editor.currMode == MODE_IDLE && input.keyb.leftAltPressed)
1376+ else if (editor.currMode == MODE_IDLE && keyb.leftAltPressed)
13791377 {
13801378 incMulti(1);
13811379 }
@@ -1388,23 +1386,23 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 6 unmodified lines
13881386
13891387 case SDL_SCANCODE_3:
13901388 {
1391− if (input.keyb.leftAmigaPressed)
1389+ if (keyb.leftAmigaPressed)
13921390 {
13931391 trackNoteUp(TRANSPOSE_ALL, 0, MOD_ROWS - 1);
13941392 }
1395− else if (input.keyb.leftCtrlPressed)
1393+ else if (keyb.leftCtrlPressed)
13961394 {
13971395 editor.editMoveAdd = 3;
13981396 displayMsg("EDITSKIP = 3");
13991397 editor.ui.updateTrackerFlags = true;
14001398 }
1401− else if (input.keyb.shiftPressed)
1399+ else if (keyb.shiftPressed)
14021400 {
14031401 noteSrc = &modEntry->patterns[modEntry->currPattern][(modEntry->currRow * AMIGA_VOICES) + editor.cursor.channel];
14041402 editor.effectMacros[2] = (noteSrc->command << 8) | noteSrc->param;
14051403 displayMsg("COMMAND STORED!");
14061404 }
1407− else if (editor.currMode == MODE_IDLE && input.keyb.leftAltPressed)
1405+ else if (editor.currMode == MODE_IDLE && keyb.leftAltPressed)
14081406 {
14091407 incMulti(2);
14101408 }
@@ -1417,23 +1415,23 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 6 unmodified lines
14171415
14181416 case SDL_SCANCODE_4:
14191417 {
1420− if (input.keyb.leftAmigaPressed)
1418+ if (keyb.leftAmigaPressed)
14211419 {
14221420 pattNoteUp(TRANSPOSE_ALL);
14231421 }
1424− else if (input.keyb.leftCtrlPressed)
1422+ else if (keyb.leftCtrlPressed)
14251423 {
14261424 editor.editMoveAdd = 4;
14271425 displayMsg("EDITSKIP = 4");
14281426 editor.ui.updateTrackerFlags = true;
14291427 }
1430− else if (input.keyb.shiftPressed)
1428+ else if (keyb.shiftPressed)
14311429 {
14321430 noteSrc = &modEntry->patterns[modEntry->currPattern][(modEntry->currRow * AMIGA_VOICES) + editor.cursor.channel];
14331431 editor.effectMacros[3] = (noteSrc->command << 8) | noteSrc->param;
14341432 displayMsg("COMMAND STORED!");
14351433 }
1436− else if (editor.currMode == MODE_IDLE && input.keyb.leftAltPressed)
1434+ else if (editor.currMode == MODE_IDLE && keyb.leftAltPressed)
14371435 {
14381436 incMulti(3);
14391437 }
@@ -1446,13 +1444,13 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 6 unmodified lines
14461444
14471445 case SDL_SCANCODE_5:
14481446 {
1449− if (input.keyb.leftCtrlPressed)
1447+ if (keyb.leftCtrlPressed)
14501448 {
14511449 editor.editMoveAdd = 5;
14521450 displayMsg("EDITSKIP = 5");
14531451 editor.ui.updateTrackerFlags = true;
14541452 }
1455− else if (input.keyb.shiftPressed)
1453+ else if (keyb.shiftPressed)
14561454 {
14571455 noteSrc = &modEntry->patterns[modEntry->currPattern][(modEntry->currRow * AMIGA_VOICES) + editor.cursor.channel];
14581456 editor.effectMacros[4] = (noteSrc->command << 8) | noteSrc->param;
@@ -1467,13 +1465,13 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 8 unmodified lines
14671465
14681466 case SDL_SCANCODE_6:
14691467 {
1470− if (input.keyb.leftCtrlPressed)
1468+ if (keyb.leftCtrlPressed)
14711469 {
14721470 editor.editMoveAdd = 6;
14731471 displayMsg("EDITSKIP = 6");
14741472 editor.ui.updateTrackerFlags = true;
14751473 }
1476− else if (input.keyb.shiftPressed)
1474+ else if (keyb.shiftPressed)
14771475 {
14781476 noteSrc = &modEntry->patterns[modEntry->currPattern][(modEntry->currRow * AMIGA_VOICES) + editor.cursor.channel];
14791477 editor.effectMacros[5] = (noteSrc->command << 8) | noteSrc->param;
@@ -1488,13 +1486,13 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 8 unmodified lines
14881486
14891487 case SDL_SCANCODE_7:
14901488 {
1491− if (input.keyb.leftCtrlPressed)
1489+ if (keyb.leftCtrlPressed)
14921490 {
14931491 editor.editMoveAdd = 7;
14941492 displayMsg("EDITSKIP = 7");
14951493 editor.ui.updateTrackerFlags = true;
14961494 }
1497− else if (input.keyb.shiftPressed)
1495+ else if (keyb.shiftPressed)
14981496 {
14991497 noteSrc = &modEntry->patterns[modEntry->currPattern][(modEntry->currRow * AMIGA_VOICES) + editor.cursor.channel];
15001498 editor.effectMacros[6] = (noteSrc->command << 8) | noteSrc->param;
@@ -1509,13 +1507,13 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 8 unmodified lines
15091507
15101508 case SDL_SCANCODE_8:
15111509 {
1512− if (input.keyb.leftCtrlPressed)
1510+ if (keyb.leftCtrlPressed)
15131511 {
15141512 editor.editMoveAdd = 8;
15151513 displayMsg("EDITSKIP = 8");
15161514 editor.ui.updateTrackerFlags = true;
15171515 }
1518− else if (input.keyb.shiftPressed)
1516+ else if (keyb.shiftPressed)
15191517 {
15201518 noteSrc = &modEntry->patterns[modEntry->currPattern][(modEntry->currRow * AMIGA_VOICES) + editor.cursor.channel];
15211519 editor.effectMacros[7] = (noteSrc->command << 8) | noteSrc->param;
@@ -1530,13 +1528,13 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 8 unmodified lines
15301528
15311529 case SDL_SCANCODE_9:
15321530 {
1533− if (input.keyb.leftCtrlPressed)
1531+ if (keyb.leftCtrlPressed)
15341532 {
15351533 editor.editMoveAdd = 9;
15361534 displayMsg("EDITSKIP = 9");
15371535 editor.ui.updateTrackerFlags = true;
15381536 }
1539− else if (input.keyb.shiftPressed)
1537+ else if (keyb.shiftPressed)
15401538 {
15411539 noteSrc = &modEntry->patterns[modEntry->currPattern][(modEntry->currRow * AMIGA_VOICES) + editor.cursor.channel];
15421540 editor.effectMacros[8] = (noteSrc->command << 8) | noteSrc->param;
@@ -1562,7 +1560,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 19 unmodified lines
15621560 editor.currSample = editor.keypadSampleOffset + 12;
15631561
15641562 updateCurrSample();
1565− if (input.keyb.leftAltPressed && editor.pNoteFlag > 0)
1563+ if (keyb.leftAltPressed && editor.pNoteFlag > 0)
15661564 {
15671565 editor.ui.changingDrumPadNote = true;
15681566 setStatusMessage("SELECT NOTE", NO_CARRY);
@@ -1581,7 +1579,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 12 unmodified lines
15811579 editor.currSample = editor.keypadSampleOffset + 13;
15821580
15831581 updateCurrSample();
1584− if (input.keyb.leftAltPressed && editor.pNoteFlag > 0)
1582+ if (keyb.leftAltPressed && editor.pNoteFlag > 0)
15851583 {
15861584 editor.ui.changingDrumPadNote = true;
15871585 setStatusMessage("SELECT NOTE", NO_CARRY);
@@ -1600,7 +1598,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 12 unmodified lines
16001598 editor.currSample = editor.keypadSampleOffset + 14;
16011599
16021600 updateCurrSample();
1603− if (input.keyb.leftAltPressed && editor.pNoteFlag > 0)
1601+ if (keyb.leftAltPressed && editor.pNoteFlag > 0)
16041602 {
16051603 editor.ui.changingDrumPadNote = true;
16061604 setStatusMessage("SELECT NOTE", NO_CARRY);
@@ -1619,7 +1617,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 12 unmodified lines
16191617 editor.currSample = editor.keypadSampleOffset + 8;
16201618
16211619 updateCurrSample();
1622− if (input.keyb.leftAltPressed && editor.pNoteFlag > 0)
1620+ if (keyb.leftAltPressed && editor.pNoteFlag > 0)
16231621 {
16241622 editor.ui.changingDrumPadNote = true;
16251623 setStatusMessage("SELECT NOTE", NO_CARRY);
@@ -1638,7 +1636,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 12 unmodified lines
16381636 editor.currSample = editor.keypadSampleOffset + 9;
16391637
16401638 updateCurrSample();
1641− if (input.keyb.leftAltPressed && editor.pNoteFlag > 0)
1639+ if (keyb.leftAltPressed && editor.pNoteFlag > 0)
16421640 {
16431641 editor.ui.changingDrumPadNote = true;
16441642 setStatusMessage("SELECT NOTE", NO_CARRY);
@@ -1657,7 +1655,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 12 unmodified lines
16571655 editor.currSample = editor.keypadSampleOffset + 10;
16581656
16591657 updateCurrSample();
1660− if (input.keyb.leftAltPressed && editor.pNoteFlag > 0)
1658+ if (keyb.leftAltPressed && editor.pNoteFlag > 0)
16611659 {
16621660 editor.ui.changingDrumPadNote = true;
16631661 setStatusMessage("SELECT NOTE", NO_CARRY);
@@ -1676,7 +1674,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 12 unmodified lines
16761674 editor.currSample = editor.keypadSampleOffset + 4;
16771675
16781676 updateCurrSample();
1679− if (input.keyb.leftAltPressed && editor.pNoteFlag > 0)
1677+ if (keyb.leftAltPressed && editor.pNoteFlag > 0)
16801678 {
16811679 editor.ui.changingDrumPadNote = true;
16821680 setStatusMessage("SELECT NOTE", NO_CARRY);
@@ -1695,7 +1693,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 12 unmodified lines
16951693 editor.currSample = editor.keypadSampleOffset + 5;
16961694
16971695 updateCurrSample();
1698− if (input.keyb.leftAltPressed && editor.pNoteFlag > 0)
1696+ if (keyb.leftAltPressed && editor.pNoteFlag > 0)
16991697 {
17001698 editor.ui.changingDrumPadNote = true;
17011699 setStatusMessage("SELECT NOTE", NO_CARRY);
@@ -1714,7 +1712,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 12 unmodified lines
17141712 editor.currSample = editor.keypadSampleOffset + 6;
17151713
17161714 updateCurrSample();
1717− if (input.keyb.leftAltPressed && editor.pNoteFlag > 0)
1715+ if (keyb.leftAltPressed && editor.pNoteFlag > 0)
17181716 {
17191717 editor.ui.changingDrumPadNote = true;
17201718 setStatusMessage("SELECT NOTE", NO_CARRY);
@@ -1757,7 +1755,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 36 unmodified lines
17571755 editor.currSample--;
17581756
17591757 updateCurrSample();
1760− if (input.keyb.leftAltPressed && editor.pNoteFlag > 0)
1758+ if (keyb.leftAltPressed && editor.pNoteFlag > 0)
17611759 {
17621760 editor.ui.changingDrumPadNote = true;
17631761 setStatusMessage("SELECT NOTE", NO_CARRY);
@@ -1782,7 +1780,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 18 unmodified lines
17821780 editor.currSample = editor.keypadSampleOffset + (0x08 - 1);
17831781
17841782 updateCurrSample();
1785− if (input.keyb.leftAltPressed && editor.pNoteFlag > 0)
1783+ if (keyb.leftAltPressed && editor.pNoteFlag > 0)
17861784 displayErrorMsg("INVALID PAD KEY !");
17871785
17881786 editor.keypadToggle8CFlag ^= 1;
@@ -1795,7 +1793,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 6 unmodified lines
17951793 editor.currSample = editor.keypadSampleOffset + 3;
17961794
17971795 updateCurrSample();
1798− if (input.keyb.leftAltPressed && editor.pNoteFlag > 0)
1796+ if (keyb.leftAltPressed && editor.pNoteFlag > 0)
17991797 {
18001798 editor.ui.changingDrumPadNote = true;
18011799 setStatusMessage("SELECT NOTE", NO_CARRY);
@@ -1814,7 +1812,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 12 unmodified lines
18141812 editor.currSample = editor.keypadSampleOffset + 2;
18151813
18161814 updateCurrSample();
1817− if (input.keyb.leftAltPressed && editor.pNoteFlag > 0)
1815+ if (keyb.leftAltPressed && editor.pNoteFlag > 0)
18181816 {
18191817 editor.ui.changingDrumPadNote = true;
18201818 setStatusMessage("SELECT NOTE", NO_CARRY);
@@ -1833,7 +1831,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 12 unmodified lines
18331831 editor.currSample = editor.keypadSampleOffset + 1;
18341832
18351833 updateCurrSample();
1836− if (input.keyb.leftAltPressed && editor.pNoteFlag > 0)
1834+ if (keyb.leftAltPressed && editor.pNoteFlag > 0)
18371835 {
18381836 editor.ui.changingDrumPadNote = true;
18391837 setStatusMessage("SELECT NOTE", NO_CARRY);
@@ -1852,7 +1850,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 12 unmodified lines
18521850 editor.currSample = editor.keypadSampleOffset + 0;
18531851
18541852 updateCurrSample();
1855− if (input.keyb.leftAltPressed && editor.pNoteFlag > 0)
1853+ if (keyb.leftAltPressed && editor.pNoteFlag > 0)
18561854 {
18571855 editor.ui.changingDrumPadNote = true;
18581856
@@ -1879,15 +1877,15 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 20 unmodified lines
18791877
18801878 case SDL_SCANCODE_DOWN:
18811879 {
1882− input.keyb.delayKey = false;
1883− input.keyb.repeatKey = false;
1880+ keyb.delayKey = false;
1881+ keyb.repeatKey = false;
18841882
18851883 if (editor.ui.diskOpScreenShown)
18861884 {
18871885 if (editor.diskop.numEntries > DISKOP_LINES)
18881886 {
18891887 editor.diskop.scrollOffset++;
1890− if (input.mouse.rightButtonPressed) // PT quirk: right mouse button speeds up scrolling even on keyb UP/DOWN
1888+ if (mouse.rightButtonPressed) // PT quirk: right mouse button speeds up scrolling even on keyb UP/DOWN
18911889 editor.diskop.scrollOffset += 3;
18921890
18931891 if (editor.diskop.scrollOffset > editor.diskop.numEntries-DISKOP_LINES)
@@ -1896,11 +1894,11 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 2 unmodified lines
18961894 editor.ui.updateDiskOpFileList = true;
18971895 }
18981896
1899− if (!input.keyb.repeatKey)
1900− input.keyb.delayCounter = 0;
1897+ if (!keyb.repeatKey)
1898+ keyb.delayCounter = 0;
19011899
1902− input.keyb.repeatKey = true;
1903− input.keyb.delayKey = false;
1900+ keyb.repeatKey = true;
1901+ keyb.delayKey = false;
19041902 }
19051903 else if (editor.ui.posEdScreenShown)
19061904 {
@@ -1913,31 +1911,31 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 6 unmodified lines
19131911 editor.ui.updatePosEd = true;
19141912 }
19151913
1916− if (!input.keyb.repeatKey)
1917− input.keyb.delayCounter = 0;
1914+ if (!keyb.repeatKey)
1915+ keyb.delayCounter = 0;
19181916
1919− input.keyb.repeatKey = true;
1920− input.keyb.delayKey = true;
1917+ keyb.repeatKey = true;
1918+ keyb.delayKey = true;
19211919 }
19221920 else if (!editor.ui.samplerScreenShown)
19231921 {
19241922 if (editor.currMode != MODE_PLAY && editor.currMode != MODE_RECORD)
19251923 modSetPos(DONT_SET_ORDER, (modEntry->currRow + 1) & 0x3F);
19261924
1927− input.keyb.repeatKey = true;
1925+ keyb.repeatKey = true;
19281926 }
19291927 }
19301928 break;
19311929
19321930 case SDL_SCANCODE_UP:
19331931 {
1934− input.keyb.delayKey = false;
1935− input.keyb.repeatKey = false;
1932+ keyb.delayKey = false;
1933+ keyb.repeatKey = false;
19361934
19371935 if (editor.ui.diskOpScreenShown)
19381936 {
19391937 editor.diskop.scrollOffset--;
1940− if (input.mouse.rightButtonPressed) // PT quirk: right mouse button speeds up scrolling even on keyb UP/DOWN
1938+ if (mouse.rightButtonPressed) // PT quirk: right mouse button speeds up scrolling even on keyb UP/DOWN
19411939 editor.diskop.scrollOffset -= 3;
19421940
19431941 if (editor.diskop.scrollOffset < 0)
@@ -1945,11 +1943,11 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 1 unmodified line
19451943
19461944 editor.ui.updateDiskOpFileList = true;
19471945
1948− if (!input.keyb.repeatKey)
1949− input.keyb.delayCounter = 0;
1946+ if (!keyb.repeatKey)
1947+ keyb.delayCounter = 0;
19501948
1951− input.keyb.repeatKey = true;
1952− input.keyb.delayKey = false;
1949+ keyb.repeatKey = true;
1950+ keyb.delayKey = false;
19531951 }
19541952 else if (editor.ui.posEdScreenShown)
19551953 {
@@ -1959,115 +1957,115 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 3 unmodified lines
19591957 editor.ui.updatePosEd = true;
19601958 }
19611959
1962− if (!input.keyb.repeatKey)
1963− input.keyb.delayCounter = 0;
1960+ if (!keyb.repeatKey)
1961+ keyb.delayCounter = 0;
19641962
1965− input.keyb.repeatKey = true;
1966− input.keyb.delayKey = true;
1963+ keyb.repeatKey = true;
1964+ keyb.delayKey = true;
19671965 }
19681966 else if (!editor.ui.samplerScreenShown)
19691967 {
19701968 if ((editor.currMode != MODE_PLAY) && (editor.currMode != MODE_RECORD))
19711969 modSetPos(DONT_SET_ORDER, (modEntry->currRow - 1) & 0x3F);
19721970
1973− input.keyb.repeatKey = true;
1971+ keyb.repeatKey = true;
19741972 }
19751973 }
19761974 break;
19771975
19781976 case SDL_SCANCODE_LEFT:
19791977 {
1980− input.keyb.delayKey = false;
1981− input.keyb.repeatKey = false;
1978+ keyb.delayKey = false;
1979+ keyb.repeatKey = false;
19821980
1983− if (input.keyb.leftCtrlPressed)
1981+ if (keyb.leftCtrlPressed)
19841982 {
19851983 sampleDownButton();
19861984 if (editor.repeatKeyFlag)
19871985 {
1988− input.keyb.delayKey = true;
1989− input.keyb.repeatKey = true;
1986+ keyb.delayKey = true;
1987+ keyb.repeatKey = true;
19901988 }
19911989 }
1992− else if (input.keyb.shiftPressed)
1990+ else if (keyb.shiftPressed)
19931991 {
19941992 if (modEntry->currOrder > 0)
19951993 {
19961994 modSetPos(modEntry->currOrder - 1, DONT_SET_ROW);
19971995 if (editor.repeatKeyFlag)
19981996 {
1999− input.keyb.delayKey = true;
2000− input.keyb.repeatKey = true;
1997+ keyb.delayKey = true;
1998+ keyb.repeatKey = true;
20011999 }
20022000 }
20032001 }
2004− else if (input.keyb.leftAltPressed)
2002+ else if (keyb.leftAltPressed)
20052003 {
20062004 decPatt();
20072005 if (editor.repeatKeyFlag)
20082006 {
2009− input.keyb.delayKey = true;
2010− input.keyb.repeatKey = true;
2007+ keyb.delayKey = true;
2008+ keyb.repeatKey = true;
20112009 }
20122010 }
20132011 else
20142012 {
20152013 movePatCurLeft();
2016− input.keyb.repeatKey = true;
2014+ keyb.repeatKey = true;
20172015 }
20182016 }
20192017 break;
20202018
20212019 case SDL_SCANCODE_RIGHT:
20222020 {
2023− input.keyb.delayKey = false;
2024− input.keyb.repeatKey = false;
2021+ keyb.delayKey = false;
2022+ keyb.repeatKey = false;
20252023
2026− if (input.keyb.leftCtrlPressed)
2024+ if (keyb.leftCtrlPressed)
20272025 {
20282026 sampleUpButton();
20292027 if (editor.repeatKeyFlag)
20302028 {
2031− input.keyb.delayKey = true;
2032− input.keyb.repeatKey = true;
2029+ keyb.delayKey = true;
2030+ keyb.repeatKey = true;
20332031 }
20342032 }
2035− else if (input.keyb.shiftPressed)
2033+ else if (keyb.shiftPressed)
20362034 {
20372035 if (modEntry->currOrder < 126)
20382036 {
20392037 modSetPos(modEntry->currOrder + 1, DONT_SET_ROW);
20402038 if (editor.repeatKeyFlag)
20412039 {
2042− input.keyb.delayKey = true;
2043− input.keyb.repeatKey = true;
2040+ keyb.delayKey = true;
2041+ keyb.repeatKey = true;
20442042 }
20452043 }
20462044 }
2047− else if (input.keyb.leftAltPressed)
2045+ else if (keyb.leftAltPressed)
20482046 {
20492047 incPatt();
20502048 if (editor.repeatKeyFlag)
20512049 {
2052− input.keyb.delayKey = true;
2053− input.keyb.repeatKey = true;
2050+ keyb.delayKey = true;
2051+ keyb.repeatKey = true;
20542052 }
20552053 }
20562054 else
20572055 {
20582056 movePatCurRight();
2059− input.keyb.repeatKey = true;
2057+ keyb.repeatKey = true;
20602058 }
20612059 }
20622060 break;
20632061
20642062 case SDL_SCANCODE_A:
20652063 {
2066− if (input.keyb.leftAmigaPressed)
2064+ if (keyb.leftAmigaPressed)
20672065 {
20682066 trackOctaUp(TRANSPOSE_ALL, 0, MOD_ROWS - 1);
20692067 }
2070− else if (input.keyb.leftCtrlPressed)
2068+ else if (keyb.leftCtrlPressed)
20712069 {
20722070 if (editor.ui.samplerScreenShown)
20732071 {
@@ -2075,7 +2073,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 1 unmodified line
20752073 }
20762074 else
20772075 {
2078− if (input.keyb.shiftPressed)
2076+ if (keyb.shiftPressed)
20792077 {
20802078 editor.muted[0] = true;
20812079 editor.muted[1] = true;
@@ -2100,7 +2098,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 18 unmodified lines
21002098
21012099 case SDL_SCANCODE_B:
21022100 {
2103− if (input.keyb.leftCtrlPressed)
2101+ if (keyb.leftCtrlPressed)
21042102 {
21052103 // CTRL+B doesn't change the status message back, so do this:
21062104 if (editor.ui.introScreenShown)
@@ -2122,7 +2120,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 15 unmodified lines
21222120
21232121 editor.ui.updateStatusText = true;
21242122 }
2125− else if (input.keyb.leftAltPressed)
2123+ else if (keyb.leftAltPressed)
21262124 {
21272125 s = &modEntry->samples[editor.currSample];
21282126 if (s->length == 0)
@@ -2145,11 +2143,11 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 16 unmodified lines
21452143
21462144 case SDL_SCANCODE_C:
21472145 {
2148− if (input.keyb.leftAmigaPressed)
2146+ if (keyb.leftAmigaPressed)
21492147 {
21502148 trackOctaDown(TRANSPOSE_ALL, 0, MOD_ROWS - 1);
21512149 }
2152− else if (input.keyb.leftCtrlPressed)
2150+ else if (keyb.leftCtrlPressed)
21532151 {
21542152 if (editor.ui.samplerScreenShown)
21552153 {
@@ -2184,7 +2182,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 28 unmodified lines
21842182 }
21852183 else
21862184 {
2187− if (input.keyb.leftAltPressed)
2185+ if (keyb.leftAltPressed)
21882186 {
21892187 editor.muted[2] ^= 1; // toggle channel 3
21902188 renderMuteButtons();
@@ -2199,17 +2197,17 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 8 unmodified lines
21992197
22002198 case SDL_SCANCODE_D:
22012199 {
2202− if (input.keyb.leftAmigaPressed)
2200+ if (keyb.leftAmigaPressed)
22032201 {
22042202 trackOctaUp(TRANSPOSE_ALL, 0, MOD_ROWS - 1);
22052203 }
2206− else if (input.keyb.leftCtrlPressed)
2204+ else if (keyb.leftCtrlPressed)
22072205 {
22082206 saveUndo();
22092207 }
22102208 else
22112209 {
2212− if (input.keyb.leftAltPressed)
2210+ if (keyb.leftAltPressed)
22132211 {
22142212 if (!editor.ui.posEdScreenShown)
22152213 {
@@ -2239,11 +2237,11 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 23 unmodified lines
22392237
22402238 case SDL_SCANCODE_E:
22412239 {
2242− if (input.keyb.leftAmigaPressed)
2240+ if (keyb.leftAmigaPressed)
22432241 {
22442242 trackNoteDown(TRANSPOSE_ALL, 0, MOD_ROWS - 1);
22452243 }
2246− else if (input.keyb.leftAltPressed)
2244+ else if (keyb.leftAltPressed)
22472245 {
22482246 if (!editor.ui.diskOpScreenShown && !editor.ui.posEdScreenShown)
22492247 {
@@ -2255,7 +2253,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 5 unmodified lines
22552253 renderEditOpScreen();
22562254 }
22572255 }
2258− else if (input.keyb.leftCtrlPressed)
2256+ else if (keyb.leftCtrlPressed)
22592257 {
22602258 saveUndo();
22612259
@@ -2290,17 +2288,17 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 28 unmodified lines
22902288 case SDL_SCANCODE_F:
22912289 {
22922290 #ifdef __APPLE__
2293− if (input.keyb.leftCommandPressed && input.keyb.leftCtrlPressed)
2291+ if (keyb.leftCommandPressed && keyb.leftCtrlPressed)
22942292 {
22952293 toggleFullScreen();
22962294 }
22972295 else
22982296 #endif
2299− if (input.keyb.leftAmigaPressed)
2297+ if (keyb.leftAmigaPressed)
23002298 {
23012299 pattOctaUp(TRANSPOSE_ALL);
23022300 }
2303− else if (input.keyb.leftCtrlPressed)
2301+ else if (keyb.leftCtrlPressed)
23042302 {
23052303 toggleLEDFilter();
23062304
@@ -2309,7 +2307,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 2 unmodified lines
23092307 else
23102308 displayMsg("LED FILTER OFF");
23112309 }
2312− else if (input.keyb.leftAltPressed)
2310+ else if (keyb.leftAltPressed)
23132311 {
23142312 s = &modEntry->samples[editor.currSample];
23152313 if (s->length == 0)
@@ -2331,7 +2329,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 15 unmodified lines
23312329
23322330 case SDL_SCANCODE_G:
23332331 {
2334− if (input.keyb.leftCtrlPressed)
2332+ if (keyb.leftCtrlPressed)
23352333 {
23362334 editor.ui.askScreenShown = true;
23372335 editor.ui.askScreenType = ASK_BOOST_ALL_SAMPLES;
@@ -2339,7 +2337,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 1 unmodified line
23392337 setStatusMessage("BOOST ALL SAMPLES", NO_CARRY);
23402338 renderAskDialog();
23412339 }
2342− else if (input.keyb.leftAltPressed) // toggle record mode (PT clone and PT2.3E only)
2340+ else if (keyb.leftAltPressed) // toggle record mode (PT clone and PT2.3E only)
23432341 {
23442342 editor.recordMode ^= 1;
23452343 if (editor.recordMode == 0)
@@ -2359,7 +2357,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 13 unmodified lines
23592357
23602358 case SDL_SCANCODE_H:
23612359 {
2362− if (input.keyb.leftCtrlPressed)
2360+ if (keyb.leftCtrlPressed)
23632361 {
23642362 if (!editor.blockMarkFlag)
23652363 {
@@ -2378,7 +2376,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 12 unmodified lines
23782376
23792377 case SDL_SCANCODE_I:
23802378 {
2381− if (input.keyb.leftCtrlPressed)
2379+ if (keyb.leftCtrlPressed)
23822380 {
23832381 if (!editor.blockBufferFlag)
23842382 {
@@ -2408,7 +2406,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 23 unmodified lines
24082406 = editor.blockBuffer[editor.buffFromPos + i];
24092407 }
24102408
2411− if (!input.keyb.shiftPressed)
2409+ if (!keyb.shiftPressed)
24122410 {
24132411 modEntry->currRow += i & 0xFF;
24142412 if (modEntry->currRow > 63)
@@ -2418,7 +2416,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 3 unmodified lines
24182416 updateWindowTitle(MOD_IS_MODIFIED);
24192417 editor.ui.updatePatternData = true;
24202418 }
2421− else if (input.keyb.leftAltPressed)
2419+ else if (keyb.leftAltPressed)
24222420 {
24232421 editor.autoInsFlag ^= 1;
24242422 editor.ui.updateTrackerFlags = true;
@@ -2432,7 +2430,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 7 unmodified lines
24322430
24332431 case SDL_SCANCODE_J:
24342432 {
2435− if (input.keyb.leftCtrlPressed)
2433+ if (keyb.leftCtrlPressed)
24362434 {
24372435 if (!editor.blockBufferFlag)
24382436 {
@@ -2466,7 +2464,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 27 unmodified lines
24662464 j++;
24672465 }
24682466
2469− if (!input.keyb.shiftPressed)
2467+ if (!keyb.shiftPressed)
24702468 {
24712469 modEntry->currRow += (editor.buffToPos-editor.buffFromPos) + 1;
24722470 if (modEntry->currRow > 63)
@@ -2485,7 +2483,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 12 unmodified lines
24852483
24862484 case SDL_SCANCODE_K:
24872485 {
2488− if (input.keyb.leftAltPressed)
2486+ if (keyb.leftAltPressed)
24892487 {
24902488 for (i = 0; i < MOD_ROWS; i++)
24912489 {
@@ -2502,12 +2500,12 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 10 unmodified lines
25022500 updateWindowTitle(MOD_IS_MODIFIED);
25032501 editor.ui.updatePatternData = true;
25042502 }
2505− else if (input.keyb.leftCtrlPressed)
2503+ else if (keyb.leftCtrlPressed)
25062504 {
25072505 saveUndo();
25082506
25092507 i = modEntry->currRow;
2510− if (input.keyb.shiftPressed)
2508+ if (keyb.shiftPressed)
25112509 {
25122510 // kill to start
25132511 while (i >= 0)
@@ -2548,7 +2546,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 34 unmodified lines
25482546
25492547 case SDL_SCANCODE_L:
25502548 {
2551− if (input.keyb.leftCtrlPressed)
2549+ if (keyb.leftCtrlPressed)
25522550 {
25532551 if (!editor.blockMarkFlag)
25542552 {
@@ -2567,15 +2565,15 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 12 unmodified lines
25672565
25682566 case SDL_SCANCODE_M:
25692567 {
2570− if (input.keyb.leftCtrlPressed)
2568+ if (keyb.leftCtrlPressed)
25712569 {
25722570 editor.multiFlag ^= 1;
25732571 editor.ui.updateTrackerFlags = true;
25742572 editor.ui.updateKeysText = true;
25752573 }
2576− else if (input.keyb.leftAltPressed)
2574+ else if (keyb.leftAltPressed)
25772575 {
2578− if (input.keyb.shiftPressed)
2576+ if (keyb.shiftPressed)
25792577 editor.metroChannel = editor.cursor.channel + 1;
25802578 else
25812579 editor.metroFlag ^= 1;
@@ -2591,7 +2589,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 9 unmodified lines
25912589
25922590 case SDL_SCANCODE_N:
25932591 {
2594− if (input.keyb.leftCtrlPressed)
2592+ if (keyb.leftCtrlPressed)
25952593 {
25962594 editor.blockMarkFlag = true;
25972595 modEntry->currRow = editor.blockToPos;
@@ -2605,7 +2603,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 7 unmodified lines
26052603
26062604 case SDL_SCANCODE_O:
26072605 {
2608− if (input.keyb.leftCtrlPressed)
2606+ if (keyb.leftCtrlPressed)
26092607 {
26102608 // fun fact: this function is broken in PT but I fixed it in my clone
26112609
@@ -2642,7 +2640,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 30 unmodified lines
26422640
26432641 case SDL_SCANCODE_P:
26442642 {
2645− if (input.keyb.leftCtrlPressed)
2643+ if (keyb.leftCtrlPressed)
26462644 {
26472645 if (!editor.blockBufferFlag)
26482646 {
@@ -2667,7 +2665,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 18 unmodified lines
26672665 j++;
26682666 }
26692667
2670− if (!input.keyb.shiftPressed)
2668+ if (!keyb.shiftPressed)
26712669 {
26722670 modEntry->currRow += (editor.buffToPos-editor.buffFromPos) + 1;
26732671 if (modEntry->currRow > 63)
@@ -2677,7 +2675,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 3 unmodified lines
26772675 updateWindowTitle(MOD_IS_MODIFIED);
26782676 editor.ui.updatePatternData = true;
26792677 }
2680− else if (input.keyb.leftAltPressed)
2678+ else if (keyb.leftAltPressed)
26812679 {
26822680 if (!editor.ui.diskOpScreenShown)
26832681 {
@@ -2702,11 +2700,11 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 18 unmodified lines
27022700
27032701 case SDL_SCANCODE_Q:
27042702 {
2705− if (input.keyb.leftAmigaPressed)
2703+ if (keyb.leftAmigaPressed)
27062704 {
27072705 trackNoteDown(TRANSPOSE_ALL, 0, MOD_ROWS - 1);
27082706 }
2709− else if (input.keyb.leftCtrlPressed)
2707+ else if (keyb.leftCtrlPressed)
27102708 {
27112709 editor.muted[0] = false;
27122710 editor.muted[1] = false;
@@ -2714,7 +2712,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 1 unmodified line
27142712 editor.muted[3] = false;
27152713 renderMuteButtons();
27162714 }
2717− else if (input.keyb.leftAltPressed)
2715+ else if (keyb.leftAltPressed)
27182716 {
27192717 editor.ui.askScreenShown = true;
27202718 editor.ui.askScreenType = ASK_QUIT;
@@ -2732,11 +2730,11 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 11 unmodified lines
27322730
27332731 case SDL_SCANCODE_R:
27342732 {
2735− if (input.keyb.leftAmigaPressed)
2733+ if (keyb.leftAmigaPressed)
27362734 {
27372735 pattNoteDown(TRANSPOSE_ALL);
27382736 }
2739− else if (input.keyb.leftCtrlPressed)
2737+ else if (keyb.leftCtrlPressed)
27402738 {
27412739 editor.f6Pos = 0;
27422740 editor.f7Pos = 16;
@@ -2746,7 +2744,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 3 unmodified lines
27462744
27472745 displayMsg("POS RESTORED !");
27482746 }
2749− else if (input.keyb.leftAltPressed)
2747+ else if (keyb.leftAltPressed)
27502748 {
27512749 editor.ui.askScreenShown = true;
27522750 editor.ui.askScreenType = ASK_RESAMPLE;
@@ -2763,7 +2761,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 10 unmodified lines
27632761
27642762 case SDL_SCANCODE_S:
27652763 {
2766− if (input.keyb.leftCtrlPressed)
2764+ if (keyb.leftCtrlPressed)
27672765 {
27682766 // if we're in sample load/save mode, set current dir to modules path
27692767 if (editor.diskop.mode == DISKOP_MODE_SMP)
@@ -2775,11 +2773,11 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 5 unmodified lines
27752773 if (editor.diskop.mode == DISKOP_MODE_SMP)
27762774 UNICHAR_CHDIR(editor.samplesPathU);
27772775 }
2778− else if (input.keyb.leftAmigaPressed)
2776+ else if (keyb.leftAmigaPressed)
27792777 {
27802778 pattOctaUp(TRANSPOSE_ALL);
27812779 }
2782− else if (input.keyb.leftAltPressed)
2780+ else if (keyb.leftAltPressed)
27832781 {
27842782 samplerScreen();
27852783 }
@@ -2792,13 +2790,13 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 6 unmodified lines
27922790
27932791 case SDL_SCANCODE_T:
27942792 {
2795− if (input.keyb.leftCtrlPressed)
2793+ if (keyb.leftCtrlPressed)
27962794 {
27972795 editor.swapChannelFlag = true;
27982796 pointerSetMode(POINTER_MODE_MSG1, NO_CARRY);
27992797 setStatusMessage("SWAP (1/2/3/4) ?", NO_CARRY);
28002798 }
2801− else if (input.keyb.leftAltPressed)
2799+ else if (keyb.leftAltPressed)
28022800 {
28032801 toggleTuningTone();
28042802 }
@@ -2811,7 +2809,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 6 unmodified lines
28112809
28122810 case SDL_SCANCODE_U:
28132811 {
2814− if (input.keyb.leftCtrlPressed)
2812+ if (keyb.leftCtrlPressed)
28152813 undoLastChange();
28162814 else
28172815 handleEditKeys(scancode, EDIT_NORMAL);
@@ -2820,11 +2818,11 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 2 unmodified lines
28202818
28212819 case SDL_SCANCODE_V:
28222820 {
2823− if (input.keyb.leftAmigaPressed)
2821+ if (keyb.leftAmigaPressed)
28242822 {
28252823 pattOctaDown(TRANSPOSE_ALL);
28262824 }
2827− else if (input.keyb.leftCtrlPressed)
2825+ else if (keyb.leftCtrlPressed)
28282826 {
28292827 if (editor.ui.samplerScreenShown)
28302828 {
@@ -2840,7 +2838,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 9 unmodified lines
28402838 renderAskDialog();
28412839 }
28422840 }
2843− else if (input.keyb.leftAltPressed)
2841+ else if (keyb.leftAltPressed)
28442842 {
28452843 editor.muted[3] ^= 1; // toggle channel 4
28462844 renderMuteButtons();
@@ -2854,11 +2852,11 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 7 unmodified lines
28542852
28552853 case SDL_SCANCODE_W:
28562854 {
2857− if (input.keyb.leftAmigaPressed)
2855+ if (keyb.leftAmigaPressed)
28582856 {
28592857 pattNoteDown(TRANSPOSE_ALL);
28602858 }
2861− else if (input.keyb.leftCtrlPressed)
2859+ else if (keyb.leftCtrlPressed)
28622860 {
28632861 // Polyphonize Block
28642862 if (!editor.blockBufferFlag)
@@ -2893,7 +2891,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 28 unmodified lines
28932891 gotoNextMulti();
28942892 }
28952893
2896− if (!input.keyb.shiftPressed)
2894+ if (!keyb.shiftPressed)
28972895 {
28982896 modEntry->currRow += (editor.buffToPos-editor.buffFromPos) + 1;
28992897 if (modEntry->currRow > 63)
@@ -2912,11 +2910,11 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 12 unmodified lines
29122910
29132911 case SDL_SCANCODE_X:
29142912 {
2915− if (input.keyb.leftAmigaPressed)
2913+ if (keyb.leftAmigaPressed)
29162914 {
29172915 pattOctaDown(TRANSPOSE_ALL);
29182916 }
2919− else if (input.keyb.leftCtrlPressed)
2917+ else if (keyb.leftCtrlPressed)
29202918 {
29212919 if (editor.ui.samplerScreenShown)
29222920 {
@@ -2963,7 +2961,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 40 unmodified lines
29632961 }
29642962 else
29652963 {
2966− if (input.keyb.leftAltPressed)
2964+ if (keyb.leftAltPressed)
29672965 {
29682966 editor.muted[1] ^= 1; // toggle channel 2
29692967 renderMuteButtons();
@@ -2978,7 +2976,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 8 unmodified lines
29782976
29792977 case SDL_SCANCODE_Y:
29802978 {
2981− if (input.keyb.leftCtrlPressed)
2979+ if (keyb.leftCtrlPressed)
29822980 {
29832981 if (!editor.blockMarkFlag)
29842982 {
@@ -3018,7 +3016,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 33 unmodified lines
30183016 updateWindowTitle(MOD_IS_MODIFIED);
30193017 editor.ui.updatePatternData = true;
30203018 }
3021− else if (input.keyb.leftAltPressed)
3019+ else if (keyb.leftAltPressed)
30223020 {
30233021 editor.ui.askScreenShown = true;
30243022 editor.ui.askScreenType = ASK_SAVE_ALL_SAMPLES;
@@ -3035,11 +3033,11 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 10 unmodified lines
30353033
30363034 case SDL_SCANCODE_Z:
30373035 {
3038− if (input.keyb.leftAmigaPressed)
3036+ if (keyb.leftAmigaPressed)
30393037 {
30403038 trackOctaDown(TRANSPOSE_ALL, 0, MOD_ROWS - 1);
30413039 }
3042− else if (input.keyb.leftCtrlPressed)
3040+ else if (keyb.leftCtrlPressed)
30433041 {
30443042 if (editor.ui.samplerScreenShown)
30453043 {
@@ -3067,7 +3065,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 21 unmodified lines
30673065 displayMsg("EFX RESTORED !");
30683066 }
30693067 }
3070− else if (input.keyb.leftAltPressed)
3068+ else if (keyb.leftAltPressed)
30713069 {
30723070 editor.muted[0] ^= 1; // toggle channel 1
30733071 renderMuteButtons();
@@ -3145,16 +3143,16 @@ void handleKeyRepeat(SDL_Scancode scancode) · 71 unmodified lines
31453143 {
31463144 uint8_t repeatNum;
31473145
3148− if (!input.keyb.repeatKey || (editor.ui.clearScreenShown || editor.ui.askScreenShown))
3146+ if (!keyb.repeatKey || (editor.ui.clearScreenShown || editor.ui.askScreenShown))
31493147 {
3150− input.keyb.repeatFrac = 0;
3151− input.keyb.repeatCounter = 0;
3148+ keyb.repeatFrac = 0;
3149+ keyb.repeatCounter = 0;
31523150 return;
31533151 }
31543152
3155− if (input.keyb.delayKey && input.keyb.delayCounter < KEYB_REPEAT_DELAY)
3153+ if (keyb.delayKey && keyb.delayCounter < KEYB_REPEAT_DELAY)
31563154 {
3157− input.keyb.delayCounter++;
3155+ keyb.delayCounter++;
31583156 return;
31593157 }
31603158
@@ -3162,9 +3160,9 @@ void handleKeyRepeat(SDL_Scancode scancode) · 1 unmodified line
31623160 {
31633161 case SDL_SCANCODE_PAGEUP:
31643162 {
3165− if (input.keyb.repeatCounter >= 3)
3163+ if (keyb.repeatCounter >= 3)
31663164 {
3167− input.keyb.repeatCounter = 0;
3165+ keyb.repeatCounter = 0;
31683166
31693167 if (editor.ui.posEdScreenShown)
31703168 {
@@ -3199,9 +3197,9 @@ void handleKeyRepeat(SDL_Scancode scancode) · 28 unmodified lines
31993197
32003198 case SDL_SCANCODE_PAGEDOWN:
32013199 {
3202− if (input.keyb.repeatCounter >= 3)
3200+ if (keyb.repeatCounter >= 3)
32033201 {
3204− input.keyb.repeatCounter = 0;
3202+ keyb.repeatCounter = 0;
32053203
32063204 if (editor.ui.posEdScreenShown)
32073205 {
@@ -3233,45 +3231,45 @@ void handleKeyRepeat(SDL_Scancode scancode) · 25 unmodified lines
32333231 {
32343232 if (editor.ui.editTextFlag)
32353233 {
3236− if (input.keyb.repeatCounter >= 4)
3234+ if (keyb.repeatCounter >= 4)
32373235 {
3238− input.keyb.repeatCounter = 0;
3236+ keyb.repeatCounter = 0;
32393237 textCharPrevious();
32403238 }
32413239 }
32423240 else
32433241 {
3244− if (input.keyb.leftCtrlPressed)
3242+ if (keyb.leftCtrlPressed)
32453243 {
3246− if (input.keyb.repeatCounter >= 6)
3244+ if (keyb.repeatCounter >= 6)
32473245 {
3248− input.keyb.repeatCounter = 0;
3246+ keyb.repeatCounter = 0;
32493247 sampleDownButton();
32503248 }
32513249 }
3252− else if (input.keyb.shiftPressed)
3250+ else if (keyb.shiftPressed)
32533251 {
3254− if (input.keyb.repeatCounter >= 6)
3252+ if (keyb.repeatCounter >= 6)
32553253 {
3256− input.keyb.repeatCounter = 0;
3254+ keyb.repeatCounter = 0;
32573255 if (modEntry->currOrder > 0)
32583256 modSetPos(modEntry->currOrder - 1, DONT_SET_ROW);
32593257 }
32603258 }
3261− else if (input.keyb.leftAltPressed)
3259+ else if (keyb.leftAltPressed)
32623260 {
3263− if (input.keyb.repeatCounter >= 4)
3261+ if (keyb.repeatCounter >= 4)
32643262 {
3265− input.keyb.repeatCounter = 0;
3263+ keyb.repeatCounter = 0;
32663264 decPatt();
32673265 }
32683266 }
32693267 else
32703268 {
3271− if (input.keyb.repeatCounter >= 6)
3269+ if (keyb.repeatCounter >= 6)
32723270 {
3273− input.keyb.repeatCounter = 0;
3274− if (!input.keyb.shiftPressed && !input.keyb.leftAltPressed && !input.keyb.leftCtrlPressed)
3271+ keyb.repeatCounter = 0;
3272+ if (!keyb.shiftPressed && !keyb.leftAltPressed && !keyb.leftCtrlPressed)
32753273 movePatCurLeft();
32763274 }
32773275 }
@@ -3283,45 +3281,45 @@ void handleKeyRepeat(SDL_Scancode scancode) · 5 unmodified lines
32833281 {
32843282 if (editor.ui.editTextFlag)
32853283 {
3286− if (input.keyb.repeatCounter >= 4)
3284+ if (keyb.repeatCounter >= 4)
32873285 {
3288− input.keyb.repeatCounter = 0;
3286+ keyb.repeatCounter = 0;
32893287 textCharNext();
32903288 }
32913289 }
32923290 else
32933291 {
3294− if (input.keyb.leftCtrlPressed)
3292+ if (keyb.leftCtrlPressed)
32953293 {
3296− if (input.keyb.repeatCounter >= 6)
3294+ if (keyb.repeatCounter >= 6)
32973295 {
3298− input.keyb.repeatCounter = 0;
3296+ keyb.repeatCounter = 0;
32993297 sampleUpButton();
33003298 }
33013299 }
3302− else if (input.keyb.shiftPressed)
3300+ else if (keyb.shiftPressed)
33033301 {
3304− if (input.keyb.repeatCounter >= 6)
3302+ if (keyb.repeatCounter >= 6)
33053303 {
3306− input.keyb.repeatCounter = 0;
3304+ keyb.repeatCounter = 0;
33073305 if (modEntry->currOrder < 126)
33083306 modSetPos(modEntry->currOrder + 1, DONT_SET_ROW);
33093307 }
33103308 }
3311− else if (input.keyb.leftAltPressed)
3309+ else if (keyb.leftAltPressed)
33123310 {
3313− if (input.keyb.repeatCounter >= 4)
3311+ if (keyb.repeatCounter >= 4)
33143312 {
3315− input.keyb.repeatCounter = 0;
3313+ keyb.repeatCounter = 0;
33163314 incPatt();
33173315 }
33183316 }
33193317 else
33203318 {
3321− if (input.keyb.repeatCounter >= 6)
3319+ if (keyb.repeatCounter >= 6)
33223320 {
3323− input.keyb.repeatCounter = 0;
3324− if (!input.keyb.shiftPressed && !input.keyb.leftAltPressed && !input.keyb.leftCtrlPressed)
3321+ keyb.repeatCounter = 0;
3322+ if (!keyb.shiftPressed && !keyb.leftAltPressed && !keyb.leftCtrlPressed)
33253323 movePatCurRight();
33263324 }
33273325 }
@@ -3333,12 +3331,12 @@ void handleKeyRepeat(SDL_Scancode scancode) · 5 unmodified lines
33333331 {
33343332 if (editor.ui.diskOpScreenShown)
33353333 {
3336− if (input.keyb.repeatCounter >= 1)
3334+ if (keyb.repeatCounter >= 1)
33373335 {
3338− input.keyb.repeatCounter = 0;
3336+ keyb.repeatCounter = 0;
33393337
33403338 editor.diskop.scrollOffset--;
3341− if (input.mouse.rightButtonPressed) // PT quirk: right mouse button speeds up scrolling even on keyb UP/DOWN
3339+ if (mouse.rightButtonPressed) // PT quirk: right mouse button speeds up scrolling even on keyb UP/DOWN
33423340 editor.diskop.scrollOffset -= 3;
33433341
33443342 if (editor.diskop.scrollOffset < 0)
@@ -3349,9 +3347,9 @@ void handleKeyRepeat(SDL_Scancode scancode) · 4 unmodified lines
33493347 }
33503348 else if (editor.ui.posEdScreenShown)
33513349 {
3352− if (input.keyb.repeatCounter >= 3)
3350+ if (keyb.repeatCounter >= 3)
33533351 {
3354− input.keyb.repeatCounter = 0;
3352+ keyb.repeatCounter = 0;
33553353 if (modEntry->currOrder > 0)
33563354 {
33573355 modSetPos(modEntry->currOrder - 1, DONT_SET_ROW);
@@ -3364,14 +3362,14 @@ void handleKeyRepeat(SDL_Scancode scancode) · 6 unmodified lines
33643362 if (editor.currMode != MODE_PLAY && editor.currMode != MODE_RECORD)
33653363 {
33663364 repeatNum = 6;
3367− if (input.keyb.leftAltPressed)
3365+ if (keyb.leftAltPressed)
33683366 repeatNum = 1;
3369− else if (input.keyb.shiftPressed)
3367+ else if (keyb.shiftPressed)
33703368 repeatNum = 3;
33713369
3372− if (input.keyb.repeatCounter >= repeatNum)
3370+ if (keyb.repeatCounter >= repeatNum)
33733371 {
3374− input.keyb.repeatCounter = 0;
3372+ keyb.repeatCounter = 0;
33753373 modSetPos(DONT_SET_ORDER, (modEntry->currRow - 1) & 0x3F);
33763374 }
33773375 }
@@ -3383,14 +3381,14 @@ void handleKeyRepeat(SDL_Scancode scancode) · 5 unmodified lines
33833381 {
33843382 if (editor.ui.diskOpScreenShown)
33853383 {
3386− if (input.keyb.repeatCounter >= 1)
3384+ if (keyb.repeatCounter >= 1)
33873385 {
3388− input.keyb.repeatCounter = 0;
3386+ keyb.repeatCounter = 0;
33893387
33903388 if (editor.diskop.numEntries > DISKOP_LINES)
33913389 {
33923390 editor.diskop.scrollOffset++;
3393− if (input.mouse.rightButtonPressed) // PT quirk: right mouse button speeds up scrolling even on keyb UP/DOWN
3391+ if (mouse.rightButtonPressed) // PT quirk: right mouse button speeds up scrolling even on keyb UP/DOWN
33943392 editor.diskop.scrollOffset += 3;
33953393
33963394 if (editor.diskop.scrollOffset > editor.diskop.numEntries-DISKOP_LINES)
@@ -3402,9 +3400,9 @@ void handleKeyRepeat(SDL_Scancode scancode) · 5 unmodified lines
34023400 }
34033401 else if (editor.ui.posEdScreenShown)
34043402 {
3405− if (input.keyb.repeatCounter >= 3)
3403+ if (keyb.repeatCounter >= 3)
34063404 {
3407− input.keyb.repeatCounter = 0;
3405+ keyb.repeatCounter = 0;
34083406
34093407 if (modEntry->currOrder != modEntry->head.orderCount-1)
34103408 {
@@ -3421,14 +3419,14 @@ void handleKeyRepeat(SDL_Scancode scancode) · 10 unmodified lines
34213419 if (editor.currMode != MODE_PLAY && editor.currMode != MODE_RECORD)
34223420 {
34233421 repeatNum = 6;
3424− if (input.keyb.leftAltPressed)
3422+ if (keyb.leftAltPressed)
34253423 repeatNum = 1;
3426− else if (input.keyb.shiftPressed)
3424+ else if (keyb.shiftPressed)
34273425 repeatNum = 3;
34283426
3429− if (input.keyb.repeatCounter >= repeatNum)
3427+ if (keyb.repeatCounter >= repeatNum)
34303428 {
3431− input.keyb.repeatCounter = 0;
3429+ keyb.repeatCounter = 0;
34323430 modSetPos(DONT_SET_ORDER, (modEntry->currRow + 1) & 0x3F);
34333431 }
34343432 }
@@ -3441,9 +3439,9 @@ void handleKeyRepeat(SDL_Scancode scancode) · 6 unmodified lines
34413439 if (editor.ui.editTextFlag)
34423440 {
34433441 // only repeat backspace while editing texts
3444− if (input.keyb.repeatCounter >= 3)
3442+ if (keyb.repeatCounter >= 3)
34453443 {
3446− input.keyb.repeatCounter = 0;
3444+ keyb.repeatCounter = 0;
34473445 keyDownHandler(scancode, 0);
34483446 }
34493447 }
@@ -3456,9 +3454,9 @@ void handleKeyRepeat(SDL_Scancode scancode) · 6 unmodified lines
34563454
34573455 default:
34583456 {
3459− if (input.keyb.repeatCounter >= 3)
3457+ if (keyb.repeatCounter >= 3)
34603458 {
3461− input.keyb.repeatCounter = 0;
3459+ keyb.repeatCounter = 0;
34623460 keyDownHandler(scancode, 0);
34633461 }
34643462 }
@@ -3469,11 +3467,11 @@ void handleKeyRepeat(SDL_Scancode scancode) · 4 unmodified lines
34693467
34703468 const uint64_t keyRepeatDelta = ((uint64_t)AMIGA_PAL_VBLANK_HZ << 32) / VBLANK_HZ;
34713469
3472− input.keyb.repeatFrac += keyRepeatDelta; // 32.32 fixed-point counter
3473− if (input.keyb.repeatFrac > 0xFFFFFFFF)
3470+ keyb.repeatFrac += keyRepeatDelta; // 32.32 fixed-point counter
3471+ if (keyb.repeatFrac > 0xFFFFFFFF)
34743472 {
3475− input.keyb.repeatFrac &= 0xFFFFFFFF;
3476− input.keyb.repeatCounter++;
3473+ keyb.repeatFrac &= 0xFFFFFFFF;
3474+ keyb.repeatCounter++;
34773475 }
34783476 }
34793477
@@ -4064,11 +4062,11 @@ void handleTextEditInputChar(char textChar) · 584 unmodified lines
40644062
40654063 updateTextObject(editor.ui.editObject);
40664064
4067− if (!input.keyb.repeatKey)
4068− input.keyb.delayCounter = 0;
4065+ if (!keyb.repeatKey)
4066+ keyb.delayCounter = 0;
40694067
4070− input.keyb.repeatKey = true;
4071− input.keyb.delayKey = true;
4068+ keyb.repeatKey = true;
4069+ keyb.delayKey = true;
40724070 }
40734071
40744072 bool handleTextEditMode(SDL_Scancode scancode)
@@ -4119,16 +4117,16 @@ bool handleTextEditMode(SDL_Scancode scancode) · 44 unmodified lines
41194117 if (editor.ui.editTextFlag)
41204118 {
41214119 textCharPrevious();
4122− if (!input.keyb.repeatKey)
4123− input.keyb.delayCounter = 0;
4120+ if (!keyb.repeatKey)
4121+ keyb.delayCounter = 0;
41244122
4125− input.keyb.repeatKey = true;
4126− input.keyb.delayKey = false;
4123+ keyb.repeatKey = true;
4124+ keyb.delayKey = false;
41274125 }
41284126 else
41294127 {
4130− input.keyb.delayKey = false;
4131− input.keyb.repeatKey = true;
4128+ keyb.delayKey = false;
4129+ keyb.repeatKey = true;
41324130 }
41334131 }
41344132 break;
@@ -4138,16 +4136,16 @@ bool handleTextEditMode(SDL_Scancode scancode) · 3 unmodified lines
41384136 if (editor.ui.editTextFlag)
41394137 {
41404138 textCharNext();
4141− if (!input.keyb.repeatKey)
4142− input.keyb.delayCounter = 0;
4139+ if (!keyb.repeatKey)
4140+ keyb.delayCounter = 0;
41434141
4144− input.keyb.repeatKey = true;
4145− input.keyb.delayKey = false;
4142+ keyb.repeatKey = true;
4143+ keyb.delayKey = false;
41464144 }
41474145 else
41484146 {
4149− input.keyb.delayKey = false;
4150− input.keyb.repeatKey = true;
4147+ keyb.delayKey = false;
4148+ keyb.repeatKey = true;
41514149 }
41524150 }
41534151 break;
@@ -4170,11 +4168,11 @@ bool handleTextEditMode(SDL_Scancode scancode) · 16 unmodified lines
41704168 if (editor.ui.editObject == PTB_SONGNAME || editor.ui.editObject == PTB_SAMPLENAME)
41714169 *editor.ui.textEndPtr = '\0';
41724170
4173− if (!input.keyb.repeatKey)
4174− input.keyb.delayCounter = 0;
4171+ if (!keyb.repeatKey)
4172+ keyb.delayCounter = 0;
41754173
4176− input.keyb.repeatKey = true;
4177− input.keyb.delayKey = false;
4174+ keyb.repeatKey = true;
4175+ keyb.delayKey = false;
41784176
41794177 updateTextObject(editor.ui.editObject);
41804178 }
@@ -4207,11 +4205,11 @@ bool handleTextEditMode(SDL_Scancode scancode) · 26 unmodified lines
42074205 updateTextObject(editor.ui.editObject);
42084206 }
42094207
4210− if (!input.keyb.repeatKey)
4211− input.keyb.delayCounter = 0;
4208+ if (!keyb.repeatKey)
4209+ keyb.delayCounter = 0;
42124210
4213− input.keyb.repeatKey = true;
4214− input.keyb.delayKey = false;
4211+ keyb.repeatKey = true;
4212+ keyb.delayKey = false;
42154213 }
42164214 else
42174215 {
@@ -4223,10 +4221,10 @@ bool handleTextEditMode(SDL_Scancode scancode) · 5 unmodified lines
42234221 diskOpSetPath("..", DISKOP_CACHE);
42244222 #endif
42254223 }
4226− else if (input.keyb.shiftPressed || input.keyb.leftAltPressed || input.keyb.leftCtrlPressed)
4224+ else if (keyb.shiftPressed || keyb.leftAltPressed || keyb.leftCtrlPressed)
42274225 {
42284226 saveUndo();
4229− if (input.keyb.leftAltPressed && !input.keyb.leftCtrlPressed)
4227+ if (keyb.leftAltPressed && !keyb.leftCtrlPressed)
42304228 {
42314229 if (modEntry->currRow > 0)
42324230 {
@@ -4259,7 +4257,7 @@ bool handleTextEditMode(SDL_Scancode scancode) · 26 unmodified lines
42594257 noteSrc = &modEntry->patterns[modEntry->currPattern][((i + 1) * AMIGA_VOICES) + editor.cursor.channel];
42604258 noteDst = &modEntry->patterns[modEntry->currPattern][(i * AMIGA_VOICES) + editor.cursor.channel];
42614259
4262− if (input.keyb.leftCtrlPressed)
4260+ if (keyb.leftCtrlPressed)
42634261 {
42644262 noteDst->command = noteSrc->command;
42654263 noteDst->param = noteSrc->param;
src/pt2_main.c+48−44
@@ -40,13 +40,6 @@ · 39 unmodified lines
4040
4141 module_t *modEntry = NULL; // globalized
4242
43−// accessed by pt_visuals.c
44−uint32_t *pixelBuffer = NULL;
45−SDL_Window *window = NULL;
46−SDL_Renderer *renderer = NULL;
47−SDL_Texture *texture = NULL;
48−// -----------------------------
49−
5043 static bool backupMadeAfterCrash;
5144
5245 #ifdef _WIN32
@@ -73,9 +66,6 @@ static void exceptionHandler(int32_t signal); · 20 unmodified lines
7366 #endif
7467 #endif
7568
76−extern bool forceMixerOff; // pt_audio.c
77−extern uint32_t palette[PALETTE_NUM]; // pt_palette.c
78−
7969 #ifdef _WIN32
8070 static void makeSureDirIsProgramDir(void);
8171 static void disableWasapi(void);
@@ -110,9 +100,6 @@ int main(int argc, char *argv[]) · 28 unmodified lines
110100 #pragma message("WARNING: The SDL2 dev lib is older than ver 2.0.5. You'll get fullscreen mode issues.")
111101 #endif
112102
113− cpu.hasSSE = SDL_HasSSE();
114− cpu.hasSSE2 = SDL_HasSSE2();
115−
116103 // set up crash handler
117104 #ifndef _DEBUG
118105 #ifdef _WIN32
@@ -154,14 +141,14 @@ int main(int argc, char *argv[]) · 35 unmodified lines
154141 #endif
155142
156143 #ifdef _WIN32
157− if (!cpu.hasSSE)
144+ if (!SDL_HasSSE())
158145 {
159− showErrorMsgBox("Your computer's processor doesn't have the SSE instruction set\n" \
146+ showErrorMsgBox("Your computer's processor doesn't have the SSE+SSE2 instruction set\n" \
160147 "which is needed for this program to run. Sorry!");
161148 return 0;
162149 }
163150
164− if (!cpu.hasSSE2)
151+ if (!SDL_HasSSE2())
165152 {
166153 showErrorMsgBox("Your computer's processor doesn't have the SSE2 instruction set\n" \
167154 "which is needed for this program to run. Sorry!");
@@ -170,12 +157,14 @@ int main(int argc, char *argv[]) · 2 unmodified lines
170157
171158 setupWin32Usleep();
172159 disableWasapi(); // disable problematic WASAPI SDL2 audio driver on Windows (causes clicks/pops sometimes...)
160+ // 13.03.2020: This is still needed with SDL 2.0.12...
173161 #endif
174162
175163 /* SDL 2.0.9 for Windows has a serious bug where you need to initialize the joystick subsystem
176164 ** (even if you don't use it) or else weird things happen like random stutters, keyboard (rarely) being
177165 ** reinitialized in Windows and what not.
178− ** Ref.: https://bugzilla.libsdl.org/show_bug.cgi?id=4391 */
166+ ** Ref.: https://bugzilla.libsdl.org/show_bug.cgi?id=4391
167+ */
179168 #if defined _WIN32 && SDL_PATCHLEVEL == 9
180169 if (SDL_Init(SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) != 0)
181170 #else
@@ -190,7 +179,8 @@ int main(int argc, char *argv[]) · 8 unmodified lines
190179
191180 /* Text input is started by default in SDL2, turn it off to remove ~2ms spikes per key press.
192181 ** We manuallay start it again when someone clicks on a text edit box, and stop it when done.
193− ** Ref.: https://bugzilla.libsdl.org/show_bug.cgi?id=4166 */
182+ ** Ref.: https://bugzilla.libsdl.org/show_bug.cgi?id=4166
183+ */
194184 SDL_StopTextInput();
195185
196186 #ifdef __APPLE__
@@ -299,7 +289,7 @@ int main(int argc, char *argv[]) · 102 unmodified lines
299289 fillToVuMetersBgBuffer();
300290 updateCursorPos();
301291
302− SDL_ShowWindow(window);
292+ SDL_ShowWindow(video.window);
303293
304294 changePathToHome(); // set path to home/user-dir now
305295 diskOpSetInitPath(); // set path to custom path in config (if present)
@@ -313,9 +303,9 @@ int main(int argc, char *argv[]) · 7 unmodified lines
313303 readKeyModifiers(); // set/clear CTRL/ALT/SHIFT/AMIGA key states
314304 handleInput();
315305 updateMouseCounters();
316− handleKeyRepeat(input.keyb.lastRepKey);
306+ handleKeyRepeat(keyb.lastRepKey);
317307
318− if (!input.mouse.buttonWaiting && editor.ui.sampleMarkingPos == -1 &&
308+ if (!mouse.buttonWaiting && editor.ui.sampleMarkingPos == -1 &&
319309 !editor.ui.forceSampleDrag && !editor.ui.forceVolDrag && !editor.ui.forceSampleEdit)
320310 {
321311 handleGUIButtonRepeat();
@@ -339,17 +329,27 @@ static void handleInput(void) · 17 unmodified lines
339329
340330 while (SDL_PollEvent(&event))
341331 {
342− if (editor.ui.vsync60HzPresent)
332+ if (event.type == SDL_WINDOWEVENT)
343333 {
344− /* if we minimize the window and vsync is present, vsync is temporarily turned off.
345− ** recalc waitVBL() vars so that it can sleep properly in said mode. */
346− if (event.type == SDL_WINDOWEVENT &&
347− (event.window.event == SDL_WINDOWEVENT_MINIMIZED || event.window.event == SDL_WINDOWEVENT_FOCUS_LOST))
334+ if (event.window.event == SDL_WINDOWEVENT_HIDDEN)
335+ video.windowHidden = true;
336+ else if (event.window.event == SDL_WINDOWEVENT_SHOWN)
337+ video.windowHidden = false;
338+
339+ if (video.vsync60HzPresent)
348340 {
349− setupWaitVBL();
341+ /* if we minimize the window and vsync is present, vsync is temporarily turned off.
342+ ** recalc waitVBL() vars so that it can sleep properly in said mode.
343+ */
344+ if (event.window.event == SDL_WINDOWEVENT_MINIMIZED ||
345+ event.window.event == SDL_WINDOWEVENT_FOCUS_LOST)
346+ {
347+ setupWaitVBL();
348+ }
350349 }
351350 }
352351
352+
353353 #ifdef _WIN32
354354 handleSysMsg(event);
355355 #endif
@@ -373,7 +373,7 @@ static void handleInput(void) · 17 unmodified lines
373373 {
374374 loadDroppedFile(event.drop.file, (uint32_t)strlen(event.drop.file), false, true);
375375 SDL_free(event.drop.file);
376− SDL_RaiseWindow(window); // set window focus
376+ SDL_RaiseWindow(video.window); // set window focus
377377 }
378378 if (event.type == SDL_QUIT)
379379 {
@@ -385,7 +385,7 @@ static void handleInput(void) · 5 unmodified lines
385385 }
386386 else if (event.type == SDL_KEYDOWN)
387387 {
388− if (editor.repeatKeyFlag || input.keyb.lastRepKey != event.key.keysym.scancode)
388+ if (editor.repeatKeyFlag || keyb.lastRepKey != event.key.keysym.scancode)
389389 keyDownHandler(event.key.keysym.scancode, event.key.keysym.sym);
390390 }
391391 else if (event.type == SDL_MOUSEBUTTONUP)
@@ -435,9 +435,13 @@ static void handleInput(void) · 43 unmodified lines
435435 static bool initializeVars(void)
436436 {
437437 // clear common structs
438− memset(&input, 0, sizeof (input));
438+ memset(&keyb, 0, sizeof (keyb));
439+ memset(&mouse, 0, sizeof (mouse));
440+ memset(&video, 0, sizeof (video));
439441 memset(&editor, 0, sizeof (editor));
440− memset(&ptConfig, 0, sizeof (ptConfig));
442+ memset(&config, 0, sizeof (config));
443+
444+ setDefaultPalette();
441445
442446 editor.repeatKeyFlag = (SDL_GetModState() & KMOD_CAPS) ? true : false;
443447
@@ -450,17 +454,17 @@ static bool initializeVars(void) · 6 unmodified lines
450454 if (!allocSamplerVars() || !allocDiskOpVars())
451455 goto oom;
452456
453− ptConfig.defModulesDir = (char *)calloc(PATH_MAX + 1, sizeof (char));
454− ptConfig.defSamplesDir = (char *)calloc(PATH_MAX + 1, sizeof (char));
457+ config.defModulesDir = (char *)calloc(PATH_MAX + 1, sizeof (char));
458+ config.defSamplesDir = (char *)calloc(PATH_MAX + 1, sizeof (char));
455459 editor.tempSample = (int8_t *)calloc(MAX_SAMPLE_LEN, 1);
456460
457− if (ptConfig.defModulesDir == NULL || ptConfig.defSamplesDir == NULL ||
461+ if (config.defModulesDir == NULL || config.defSamplesDir == NULL ||
458462 editor.tempSample == NULL)
459463 {
460464 goto oom;
461465 }
462466
463− clearPaulaAndScopes();
467+ turnOffVoices();
464468
465469 // set various non-zero values
466470 editor.vol1 = 100;
@@ -519,7 +523,7 @@ static bool initializeVars(void) · 52 unmodified lines
519523 editor.sampleFromDisp = &editor.sampleFrom;
520524 editor.chordLengthDisp = &editor.chordLength;
521525 editor.metroChannelDisp = &editor.metroChannel;
522− editor.quantizeValueDisp = &ptConfig.quantizeValue;
526+ editor.quantizeValueDisp = &config.quantizeValue;
523527
524528 editor.programRunning = true;
525529 return true;
@@ -535,11 +539,11 @@ static void handleSigTerm(void) · 9 unmodified lines
535539 {
536540 resetAllScreens();
537541
538− if (!editor.fullscreen)
542+ if (!video.fullscreen)
539543 {
540544 // de-minimize window and set focus so that the user sees the message box
541− SDL_RestoreWindow(window);
542− SDL_RaiseWindow(window);
545+ SDL_RestoreWindow(video.window);
546+ SDL_RaiseWindow(video.window);
543547 }
544548
545549 editor.ui.askScreenShown = true;
@@ -725,7 +729,7 @@ static bool instanceAlreadyOpen(void) · 179 unmodified lines
725729 sharedMemBuf = (LPTSTR)MapViewOfFile(oneInstHandle, FILE_MAP_ALL_ACCESS, 0, 0, sizeof (HWND));
726730 if (sharedMemBuf != NULL)
727731 {
728− CopyMemory((PVOID)sharedMemBuf, &editor.ui.hWnd, sizeof (HWND));
732+ CopyMemory((PVOID)sharedMemBuf, &video.hWnd, sizeof (HWND));
729733 UnmapViewOfFile(sharedMemBuf);
730734 sharedMemBuf = NULL;
731735 }
@@ -739,10 +743,10 @@ static bool handleSingleInstancing(int32_t argc, char **argv) · 7 unmodified lines
739743 SDL_SysWMinfo wmInfo;
740744
741745 SDL_VERSION(&wmInfo.version);
742− if (!SDL_GetWindowWMInfo(window, &wmInfo))
746+ if (!SDL_GetWindowWMInfo(video.window, &wmInfo))
743747 return false;
744748
745− editor.ui.hWnd = wmInfo.info.win.window;
749+ video.hWnd = wmInfo.info.win.window;
746750 if (instanceAlreadyOpen() && argc >= 2 && argv[1][0] != '\0')
747751 {
748752 sharedMemBuf = (LPTSTR)MapViewOfFile(hMapFile, FILE_MAP_ALL_ACCESS, 0, 0, sizeof (HWND));
@@ -864,8 +868,8 @@ static void cleanUp(void) // never call this inside the main loop! · 115 unmodified lines
864868 videoClose();
865869 freeSprites();
866870
867− if (ptConfig.defModulesDir != NULL) free(ptConfig.defModulesDir);
868− if (ptConfig.defSamplesDir != NULL) free(ptConfig.defSamplesDir);
871+ if (config.defModulesDir != NULL) free(config.defModulesDir);
872+ if (config.defSamplesDir != NULL) free(config.defSamplesDir);
869873 if (editor.tempSample != NULL) free(editor.tempSample);
870874
871875 #ifdef _WIN32
src/pt2_modloader.c+5−6
@@ -39,8 +39,6 @@ static char oldFullPath[(PATH_MAX * 2) + 2]; · 38 unmodified lines
3939 static uint32_t oldFullPathLen;
4040 static module_t *tempMod;
4141
42−extern SDL_Window *window;
43−
4442 static MEMFILE *mopen(const uint8_t *src, uint32_t length);
4543 static void mclose(MEMFILE **buf);
4644 static int32_t mgetc(MEMFILE *buf);
@@ -656,6 +654,7 @@ module_t *modLoad(UNICHAR *fileName) · 609 unmodified lines
656654 {
657655 // "DFJ SoundTracker II" or later
658656
657+ // TODO: This needs more detection and is NOT correct!
659658 if (note->command == 0xD)
660659 {
661660 if (veryLateSTKVerFlag) // "DFJ SoundTracker III" or later
@@ -806,7 +805,7 @@ bool saveModule(bool checkIfFileExist, bool giveNewFreeFilename) · 144 unmodified lines
806805
807806 memset(fileName, 0, sizeof (fileName));
808807
809− if (ptConfig.modDot)
808+ if (config.modDot)
810809 {
811810 // extension.filename
812811 if (*modEntry->head.moduleTitle == '\0')
@@ -848,7 +847,7 @@ bool saveModule(bool checkIfFileExist, bool giveNewFreeFilename) · 35 unmodified lines
848847 for (uint16_t j = 1; j <= 9999; j++)
849848 {
850849 memset(fileName, 0, sizeof (fileName));
851− if (ptConfig.modDot)
850+ if (config.modDot)
852851 {
853852 // extension.filename
854853 if (*modEntry->head.moduleTitle == '\0')
@@ -1326,8 +1325,8 @@ void loadDroppedFile(char *fullPath, uint32_t fullPathLen, bool autoPlay, bool s · 471 unmodified lines
13261325 oldAutoPlay = autoPlay;
13271326
13281327 // de-minimize window and set focus so that the user sees the message box
1329− SDL_RestoreWindow(window);
1330− SDL_RaiseWindow(window);
1328+ SDL_RestoreWindow(video.window);
1329+ SDL_RaiseWindow(video.window);
13311330
13321331 showSongUnsavedAskBox(ASK_DISCARD_SONG_DRAGNDROP);
13331332 return;
src/pt2_modplayer.c+16−16
@@ -24,8 +24,6 @@ · 23 unmodified lines
2424 #include "pt2_textout.h"
2525 #include "pt2_scopes.h"
2626
27−extern bool forceMixerOff; // pt_audio.c
28−
2927 static bool posJumpAssert, pBreakFlag, updateUIPositions, modHasBeenPlayed;
3028 static int8_t pBreakPosition, oldRow, modPattern;
3129 static uint8_t pattDelTime, setBPMFlag, lowMask = 0xFF, pattDelTime2, oldSpeed;
@@ -63,13 +61,14 @@ void doStopIt(void) · 31 unmodified lines
6361 moduleChannel_t *c;
6462 uint8_t i;
6563
64+ editor.songPlaying = false;
65+
6666 resetCachedMixerPeriod();
6767
6868 pattDelTime = 0;
6969 pattDelTime2 = 0;
7070 editor.playMode = PLAY_MODE_NORMAL;
7171 editor.currMode = MODE_IDLE;
72− editor.songPlaying = false;
7372
7473 pointerSetMode(POINTER_MODE_IDLE, DO_CARRY);
7574
@@ -919,7 +918,7 @@ static void nextPosition(void) · 843 unmodified lines
919918 modOrder = 0;
920919 modHasBeenPlayed = true;
921920
922− if (ptConfig.compoMode) // stop song for music competitions playing
921+ if (config.compoMode) // stop song for music competitions playing
923922 {
924923 doStopIt();
925924 turnOffVoices();
@@ -1249,6 +1248,10 @@ void modPlay(int16_t patt, int16_t order, int8_t row) · 323 unmodified lines
12491248 {
12501249 uint8_t oldPlayMode, oldMode;
12511250
1251+ doStopIt();
1252+ turnOffVoices();
1253+ mixerClearSampleCounter();
1254+
12521255 if (row != -1)
12531256 {
12541257 if (row >= 0 && row <= 63)
@@ -1301,9 +1304,6 @@ void modPlay(int16_t patt, int16_t order, int8_t row) · 46 unmodified lines
13011304 oldPlayMode = editor.playMode;
13021305 oldMode = editor.currMode;
13031306
1304− doStopIt();
1305− turnOffVoices();
1306−
13071307 editor.playMode = oldPlayMode;
13081308 editor.currMode = oldMode;
13091309
@@ -1320,8 +1320,6 @@ void modPlay(int16_t patt, int16_t order, int8_t row) · 10 unmodified lines
13201320 editor.ui.updateSongPattern = true;
13211321 editor.ui.updateCurrPattText = true;
13221322 }
1323−
1324− mixerClearSampleCounter();
13251323 }
13261324
13271325 void clearSong(void)
@@ -1438,7 +1436,11 @@ void modFree(void) · 110 unmodified lines
14381436 if (modEntry == NULL)
14391437 return; // not allocated
14401438
1441− lockAudio();
1439+ const bool wasLocked = audio.locked;
1440+ if (!wasLocked)
1441+ lockAudio();
1442+
1443+ turnOffVoices();
14421444
14431445 for (i = 0; i < MAX_PATTERNS; i++)
14441446 {
@@ -1447,15 +1449,13 @@ void modFree(void) · 2 unmodified lines
14471449 }
14481450
14491451 if (modEntry->sampleData != NULL)
1450− {
1451− clearPaulaAndScopes();
14521452 free(modEntry->sampleData);
1453− }
14541453
14551454 free(modEntry);
14561455 modEntry = NULL;
14571456
1458− unlockAudio();
1457+ if (!wasLocked)
1458+ unlockAudio();
14591459 }
14601460
14611461 void restartSong(void) // for the beginning of MOD2WAV/PAT2SMP
@@ -1465,7 +1465,7 @@ void restartSong(void) // for the beginning of MOD2WAV/PAT2SMP · 3 unmodified lines
14651465
14661466 editor.playMode = PLAY_MODE_NORMAL;
14671467 editor.blockMarkFlag = false;
1468− forceMixerOff = true;
1468+ audio.forceMixerOff = true;
14691469
14701470 modEntry->row = 0;
14711471 modEntry->currRow = 0;
@@ -1528,5 +1528,5 @@ void resetSong(void) // only call this after storeTempVariables() has been calle · 56 unmodified lines
15281528
15291529 editor.modTick = 0;
15301530 modHasBeenPlayed = false;
1531− forceMixerOff = false;
1531+ audio.forceMixerOff = false;
15321532 }
src/pt2_mouse.c+353−344
@@ -25,13 +25,11 @@ · 24 unmodified lines
2525 #include "pt2_keyboard.h"
2626
2727 /* TODO: Move irrelevant routines outta here! Disgusting design!
28− * Keep in mind that this was programmed in my early programming days... */
28+** Keep in mind that this was programmed in my early programming days...
29+**/
2930
3031 SDL_Cursor *cursors[NUM_CURSORS];
3132
32−extern SDL_Renderer *renderer;
33−extern SDL_Window *window;
34−
3533 void edNote1UpButton(void);
3634 void edNote1DownButton(void);
3735 void edNote2UpButton(void);
@@ -80,11 +78,11 @@ static void pointerSetColor(uint8_t cursorColorIndex) · 42 unmodified lines
8078 {
8179 assert(cursorColorIndex <= 5);
8280
83− palette[PAL_MOUSE_1] = cursorColors[cursorColorIndex][0];
84− palette[PAL_MOUSE_2] = cursorColors[cursorColorIndex][1];
85− palette[PAL_MOUSE_3] = cursorColors[cursorColorIndex][2];
81+ video.palette[PAL_MOUSE_1] = cursorColors[cursorColorIndex][0];
82+ video.palette[PAL_MOUSE_2] = cursorColors[cursorColorIndex][1];
83+ video.palette[PAL_MOUSE_3] = cursorColors[cursorColorIndex][2];
8684
87− if (ptConfig.hwMouse)
85+ if (config.hwMouse)
8886 setSystemCursor(cursors[cursorColorIndex]);
8987 }
9088
@@ -155,14 +153,15 @@ bool createMouseCursors(void) // creates scaled SDL surfaces for current mouse p · 64 unmodified lines
155153 {
156154 freeMouseCursors();
157155
158− uint8_t scaling = editor.ui.yScale;
156+ uint8_t scaleFactor = video.yScale;
157+
159158 for (uint32_t i = 0; i < NUM_CURSORS; i++)
160159 {
161− SDL_Surface *surface = SDL_CreateRGBSurface(0, POINTER_W*scaling, POINTER_H*scaling, 32, 0, 0, 0, 0);
160+ SDL_Surface *surface = SDL_CreateRGBSurface(0, POINTER_W*scaleFactor, POINTER_H*scaleFactor, 32, 0, 0, 0, 0);
162161 if (surface == NULL)
163162 {
164163 freeMouseCursors();
165− ptConfig.hwMouse = false; // enable software mouse
164+ config.hwMouse = false; // enable software mouse
166165 return false;
167166 }
168167
@@ -171,9 +170,9 @@ bool createMouseCursors(void) // creates scaled SDL surfaces for current mouse p · 2 unmodified lines
171170 uint32_t color3 = cursorColors[i][2];
172171 uint32_t colorkey = 0x12345678;
173172
174− color1 = SDL_MapRGB(surface->format, R24(color1), G24(color1), B24(color1));
175− color2 = SDL_MapRGB(surface->format, R24(color2), G24(color2), B24(color2));
176− color3 = SDL_MapRGB(surface->format, R24(color3), G24(color3), B24(color3));
173+ color1 = SDL_MapRGB(surface->format, R24(color1), G24(color1), B24(color1));
174+ color2 = SDL_MapRGB(surface->format, R24(color2), G24(color2), B24(color2));
175+ color3 = SDL_MapRGB(surface->format, R24(color3), G24(color3), B24(color3));
177176 colorkey = SDL_MapRGB(surface->format, R24(colorkey), G24(colorkey), B24(colorkey));
178177
179178 SDL_SetSurfaceBlendMode(surface, SDL_BLENDMODE_NONE);
@@ -190,8 +189,8 @@ bool createMouseCursors(void) // creates scaled SDL surfaces for current mouse p · 10 unmodified lines
190189 // blit upscaled cursor to surface
191190 for (uint32_t y = 0; y < POINTER_H; y++)
192191 {
193− uint32_t *outX = &dstPixels32[(y * scaling) * surface->w];
194− for (uint32_t yScale = 0; yScale < scaling; yScale++)
192+ uint32_t *outX = &dstPixels32[(y * scaleFactor) * surface->w];
193+ for (uint32_t yScale = 0; yScale < scaleFactor; yScale++)
195194 {
196195 for (uint32_t x = 0; x < POINTER_W; x++)
197196 {
@@ -204,11 +203,11 @@ bool createMouseCursors(void) // creates scaled SDL surfaces for current mouse p · 6 unmodified lines
204203 else if (srcPix == PAL_MOUSE_2) pixel = color2;
205204 else if (srcPix == PAL_MOUSE_3) pixel = color3;
206205
207− for (uint32_t xScale = 0; xScale < scaling; xScale++)
206+ for (uint32_t xScale = 0; xScale < scaleFactor; xScale++)
208207 outX[xScale] = pixel;
209208 }
210209
211− outX += scaling;
210+ outX += scaleFactor;
212211 }
213212 }
214213 }
@@ -220,7 +219,7 @@ bool createMouseCursors(void) // creates scaled SDL surfaces for current mouse p · 5 unmodified lines
220219 {
221220 SDL_FreeSurface(surface);
222221 freeMouseCursors();
223− ptConfig.hwMouse = false; // enable software mouse
222+ config.hwMouse = false; // enable software mouse
224223 return false;
225224 }
226225
@@ -233,102 +232,112 @@ bool createMouseCursors(void) // creates scaled SDL surfaces for current mouse p · 6 unmodified lines
233232
234233 void updateMouseScaling(void)
235234 {
236− if (editor.ui.renderW > 0) editor.ui.dMouseXMul = (double)SCREEN_W / editor.ui.renderW;
237− if (editor.ui.renderH > 0) editor.ui.dMouseYMul = (double)SCREEN_H / editor.ui.renderH;
235+ if (video.renderW > 0) video.dMouseXMul = (double)SCREEN_W / video.renderW;
236+ if (video.renderH > 0) video.dMouseYMul = (double)SCREEN_H / video.renderH;
238237 }
239238
240239 void readMouseXY(void)
241240 {
242− int32_t mx, my;
241+ int32_t mx, my, windowX, windowY;
243242
244− if (input.mouse.setPosFlag)
243+ if (mouse.setPosFlag)
245244 {
246− input.mouse.setPosFlag = false;
247−
248− if (SDL_GetWindowFlags(window) & SDL_WINDOW_SHOWN)
249− SDL_WarpMouseInWindow(window, input.mouse.setPosX, input.mouse.setPosY);
245+ if (!video.windowHidden)
246+ SDL_WarpMouseInWindow(video.window, mouse.setPosX, mouse.setPosY);
250247
248+ mouse.setPosFlag = false;
251249 return;
252250 }
253251
254− SDL_PumpEvents(); // gathers all pending input from devices into the event queue (less mouse lag)
255− SDL_GetMouseState(&mx, &my);
252+ mouse.buttonState = SDL_GetGlobalMouseState(&mx, &my);
256253
257− /* in centered fullscreen mode, trap the mouse inside the framed image
258− * and subtract the coords to match the OS mouse position (fixes touch from touchscreens) */
259− if (editor.fullscreen && !ptConfig.fullScreenStretch)
254+ if (video.fullscreen)
260255 {
261− if (mx < editor.ui.renderX)
262− {
263− mx = editor.ui.renderX;
264− SDL_WarpMouseInWindow(window, mx, my);
265− }
266− else if (mx >= editor.ui.renderX+editor.ui.renderW)
267− {
268− mx = (editor.ui.renderX + editor.ui.renderW) - 1;
269− SDL_WarpMouseInWindow(window, mx, my);
270− }
256+ /* If fullscreen without filtering mode, translate coords and warp mouse
257+ ** inside the render space.
258+ ** Fullscreen + filtering mode takes up 100% of the screen area used, so no
259+ ** need to translate coords in that mode.
260+ */
271261
272− if (my < editor.ui.renderY)
262+ if (!config.fullScreenStretch)
273263 {
274− my = editor.ui.renderY;
275− SDL_WarpMouseInWindow(window, mx, my);
276− }
277− else if (my >= editor.ui.renderY+editor.ui.renderH)
278− {
279− my = (editor.ui.renderY + editor.ui.renderH) - 1;
280− SDL_WarpMouseInWindow(window, mx, my);
281− }
264+ if (!config.hwMouse)
265+ {
266+ bool warpMouse = false;
282267
283− mx -= editor.ui.renderX;
284− my -= editor.ui.renderY;
285− }
268+ if (mx < video.renderX)
269+ {
270+ mx = video.renderX;
271+ warpMouse = true;
272+ }
273+ else if (mx >= video.renderX+video.renderW)
274+ {
275+ mx = (video.renderX + video.renderW) - 1;
276+ warpMouse = true;
277+ }
286278
287− if (mx < 0) mx = 0;
288− if (my < 0) my = 0;
279+ if (my < video.renderY)
280+ {
281+ my = video.renderY;
282+ warpMouse = true;
283+ }
284+ else if (my >= video.renderY+video.renderH)
285+ {
286+ my = (video.renderY + video.renderH) - 1;
287+ warpMouse = true;
288+ }
289289
290− // multiply coords by video scaling factors (do not round)
291− mx = (int32_t)(mx * editor.ui.dMouseXMul);
292− my = (int32_t)(my * editor.ui.dMouseYMul);
290+ if (warpMouse)
291+ SDL_WarpMouseInWindow(video.window, mx, my);
292+ }
293293
294− if (mx >= SCREEN_W) mx = SCREEN_W - 1;
295− if (my >= SCREEN_H) my = SCREEN_H - 1;
294+ // convert fullscreen coords to window (centered image) coords
295+ mx -= video.renderX;
296+ my -= video.renderY;
297+ }
298+ }
299+ else
300+ {
301+ // convert desktop coords to window coords
302+
303+ // (a call to this function is really fast in windowed mode)
304+ SDL_GetWindowPosition(video.window, &windowX, &windowY);
305+
306+ mx -= windowX;
307+ my -= windowY;
308+ }
296309
297− input.mouse.x = (int16_t)mx;
298− input.mouse.y = (int16_t)my;
310+ // multiply coords by video upscaling factors (don't round)
311+ mouse.x = (int32_t)(mx * video.dMouseXMul);
312+ mouse.y = (int32_t)(my * video.dMouseYMul);
299313
300− if (ptConfig.hwMouse)
314+ if (config.hwMouse)
301315 {
302− // hardware mouse
316+ // hardware mouse mode (OS)
303317 hideSprite(SPRITE_MOUSE_POINTER);
304318 }
305319 else
306320 {
307− // software mouse
308− setSpritePos(SPRITE_MOUSE_POINTER, input.mouse.x, input.mouse.y);
321+ // software mouse mode (PT mouse)
322+ setSpritePos(SPRITE_MOUSE_POINTER, mouse.x, mouse.y);
309323 }
310324 }
311325
312326 void mouseButtonUpHandler(uint8_t mouseButton)
313327 {
314−#ifndef __APPLE__
315− if (!editor.fullscreen)
316− SDL_SetWindowGrab(window, SDL_FALSE);
317−#endif
318−
319− input.mouse.buttonWaitCounter = 0;
320− input.mouse.buttonWaiting = false;
328+ mouse.buttonWaitCounter = 0;
329+ mouse.buttonWaiting = false;
321330
322331 if (mouseButton == SDL_BUTTON_LEFT)
323332 {
324− input.mouse.leftButtonPressed = false;
333+ mouse.leftButtonPressed = false;
325334 editor.ui.forceSampleDrag = false;
326335 editor.ui.forceVolDrag = false;
327336 editor.ui.leftLoopPinMoving = false;
328337 editor.ui.rightLoopPinMoving = false;
329338 editor.ui.sampleMarkingPos = -1;
330339
331− switch (input.mouse.lastGUIButton)
340+ switch (mouse.lastGUIButton)
332341 {
333342 case PTB_SLENGTHU:
334343 case PTB_SLENGTHD:
@@ -358,32 +367,27 @@ void mouseButtonUpHandler(uint8_t mouseButton) · 23 unmodified lines
358367 break;
359368 }
360369
361− input.mouse.lastGUIButton = -1;
362− input.mouse.lastSmpFilterButton = -1;
370+ mouse.lastGUIButton = -1;
371+ mouse.lastSmpFilterButton = -1;
363372 }
364373
365374 if (mouseButton == SDL_BUTTON_RIGHT)
366375 {
367− input.mouse.rightButtonPressed = false;
376+ mouse.rightButtonPressed = false;
368377 editor.ui.forceSampleEdit = false;
369378 }
370379 }
371380
372381 void mouseButtonDownHandler(uint8_t mouseButton)
373382 {
374−#ifndef __APPLE__
375− if (!editor.fullscreen)
376− SDL_SetWindowGrab(window, SDL_TRUE);
377−#endif
378−
379383 if (mouseButton == SDL_BUTTON_LEFT)
380384 {
381− input.mouse.leftButtonPressed = true;
382− input.mouse.buttonWaiting = true;
385+ mouse.leftButtonPressed = true;
386+ mouse.buttonWaiting = true;
383387 }
384388
385389 if (mouseButton == SDL_BUTTON_RIGHT)
386− input.mouse.rightButtonPressed = true;
390+ mouse.rightButtonPressed = true;
387391
388392 // when red mouse pointer (error), block further input for a while
389393 if (editor.errorMsgActive && editor.errorMsgBlock)
@@ -397,10 +401,10 @@ void mouseButtonDownHandler(uint8_t mouseButton) · 7 unmodified lines
397401
398402 void handleGUIButtonRepeat(void)
399403 {
400− if (!input.mouse.leftButtonPressed)
404+ if (!mouse.leftButtonPressed)
401405 {
402406 // left mouse button released, stop repeating buttons
403− input.mouse.repeatCounter = 0;
407+ mouse.repeatCounter = 0;
404408 return;
405409 }
406410
@@ -410,20 +414,20 @@ void handleGUIButtonRepeat(void) · 3 unmodified lines
410414 return;
411415 }
412416
413− if (input.mouse.lastGUIButton != checkGUIButtons()) // FIXME: This can potentially do a ton of iterations, bad design!
417+ if (mouse.lastGUIButton != checkGUIButtons()) // FIXME: This can potentially do a ton of iterations, bad design!
414418 {
415419 // only repeat the button that was first clicked (e.g. if you hold and move mouse to another button)
416− input.mouse.repeatCounter = 0;
420+ mouse.repeatCounter = 0;
417421 return;
418422 }
419423
420424 handleRepeatedGUIButtons();
421− input.mouse.repeatCounter++;
425+ mouse.repeatCounter++;
422426 }
423427
424428 void edNote1UpButton(void)
425429 {
426− if (input.mouse.rightButtonPressed)
430+ if (mouse.rightButtonPressed)
427431 editor.note1 += 12;
428432 else
429433 editor.note1++;
@@ -437,7 +441,7 @@ void edNote1UpButton(void) · 7 unmodified lines
437441
438442 void edNote1DownButton(void)
439443 {
440− if (input.mouse.rightButtonPressed)
444+ if (mouse.rightButtonPressed)
441445 editor.note1 -= 12;
442446 else
443447 editor.note1--;
@@ -451,7 +455,7 @@ void edNote1DownButton(void) · 7 unmodified lines
451455
452456 void edNote2UpButton(void)
453457 {
454− if (input.mouse.rightButtonPressed)
458+ if (mouse.rightButtonPressed)
455459 editor.note2 += 12;
456460 else
457461 editor.note2++;
@@ -465,7 +469,7 @@ void edNote2UpButton(void) · 7 unmodified lines
465469
466470 void edNote2DownButton(void)
467471 {
468− if (input.mouse.rightButtonPressed)
472+ if (mouse.rightButtonPressed)
469473 editor.note2 -= 12;
470474 else
471475 editor.note2--;
@@ -479,7 +483,7 @@ void edNote2DownButton(void) · 7 unmodified lines
479483
480484 void edNote3UpButton(void)
481485 {
482− if (input.mouse.rightButtonPressed)
486+ if (mouse.rightButtonPressed)
483487 editor.note3 += 12;
484488 else
485489 editor.note3++;
@@ -493,7 +497,7 @@ void edNote3UpButton(void) · 7 unmodified lines
493497
494498 void edNote3DownButton(void)
495499 {
496− if (input.mouse.rightButtonPressed)
500+ if (mouse.rightButtonPressed)
497501 editor.note3 -= 12;
498502 else
499503 editor.note3--;
@@ -507,7 +511,7 @@ void edNote3DownButton(void) · 7 unmodified lines
507511
508512 void edNote4UpButton(void)
509513 {
510− if (input.mouse.rightButtonPressed)
514+ if (mouse.rightButtonPressed)
511515 editor.note4 += 12;
512516 else
513517 editor.note4++;
@@ -521,7 +525,7 @@ void edNote4UpButton(void) · 7 unmodified lines
521525
522526 void edNote4DownButton(void)
523527 {
524− if (input.mouse.rightButtonPressed)
528+ if (mouse.rightButtonPressed)
525529 editor.note4 -= 12;
526530 else
527531 editor.note4--;
@@ -535,7 +539,7 @@ void edNote4DownButton(void) · 7 unmodified lines
535539
536540 void edPosUpButton(bool fast)
537541 {
538− if (input.mouse.rightButtonPressed)
542+ if (mouse.rightButtonPressed)
539543 {
540544 if (fast)
541545 {
@@ -578,7 +582,7 @@ void edPosUpButton(bool fast) · 36 unmodified lines
578582
579583 void edPosDownButton(bool fast)
580584 {
581− if (input.mouse.rightButtonPressed)
585+ if (mouse.rightButtonPressed)
582586 {
583587 if (fast)
584588 {
@@ -618,7 +622,7 @@ void edPosDownButton(bool fast) · 33 unmodified lines
618622
619623 void edModUpButton(void)
620624 {
621− if (input.mouse.rightButtonPressed)
625+ if (mouse.rightButtonPressed)
622626 editor.modulateSpeed += 10;
623627 else
624628 editor.modulateSpeed++;
@@ -631,7 +635,7 @@ void edModUpButton(void) · 6 unmodified lines
631635
632636 void edModDownButton(void)
633637 {
634− if (input.mouse.rightButtonPressed)
638+ if (mouse.rightButtonPressed)
635639 {
636640 editor.modulateSpeed -= 10;
637641 }
@@ -648,7 +652,7 @@ void edModDownButton(void) · 10 unmodified lines
648652
649653 void edVolUpButton(void)
650654 {
651− if (input.mouse.rightButtonPressed)
655+ if (mouse.rightButtonPressed)
652656 {
653657 if (editor.sampleVol <= 999-10)
654658 editor.sampleVol += 10;
@@ -666,7 +670,7 @@ void edVolUpButton(void) · 11 unmodified lines
666670
667671 void edVolDownButton(void)
668672 {
669− if (input.mouse.rightButtonPressed)
673+ if (mouse.rightButtonPressed)
670674 {
671675 if (editor.sampleVol >= 10)
672676 editor.sampleVol -= 10;
@@ -712,7 +716,7 @@ void sampleFineTuneUpButton(void) · 39 unmodified lines
712716 if (finetune != 7)
713717 modEntry->samples[editor.currSample].fineTune = (finetune + 1) & 0xF;
714718
715− if (input.mouse.rightButtonPressed)
719+ if (mouse.rightButtonPressed)
716720 modEntry->samples[editor.currSample].fineTune = 0;
717721
718722 recalcChordLength();
@@ -725,7 +729,7 @@ void sampleFineTuneDownButton(void) · 6 unmodified lines
725729 if (finetune != 8)
726730 modEntry->samples[editor.currSample].fineTune = (finetune - 1) & 0xF;
727731
728− if (input.mouse.rightButtonPressed)
732+ if (mouse.rightButtonPressed)
729733 modEntry->samples[editor.currSample].fineTune = 0;
730734
731735 recalcChordLength();
@@ -736,7 +740,7 @@ void sampleVolumeUpButton(void) · 4 unmodified lines
736740 {
737741 int8_t val = modEntry->samples[editor.currSample].volume;
738742
739− if (input.mouse.rightButtonPressed)
743+ if (mouse.rightButtonPressed)
740744 val += 16;
741745 else
742746 val++;
@@ -752,7 +756,7 @@ void sampleVolumeDownButton(void) · 9 unmodified lines
752756 {
753757 int8_t val = modEntry->samples[editor.currSample].volume;
754758
755− if (input.mouse.rightButtonPressed)
759+ if (mouse.rightButtonPressed)
756760 val -= 16;
757761 else
758762 val--;
@@ -772,7 +776,7 @@ void sampleLengthUpButton(bool fast) · 13 unmodified lines
772776 return;
773777
774778 val = modEntry->samples[editor.currSample].length;
775− if (input.mouse.rightButtonPressed)
779+ if (mouse.rightButtonPressed)
776780 {
777781 if (fast)
778782 val += 64;
@@ -812,7 +816,7 @@ void sampleLengthDownButton(bool fast) · 33 unmodified lines
812816 }
813817
814818 val = modEntry->samples[editor.currSample].length;
815− if (input.mouse.rightButtonPressed)
819+ if (mouse.rightButtonPressed)
816820 {
817821 if (fast)
818822 val -= 64;
@@ -855,7 +859,7 @@ void sampleRepeatUpButton(bool fast) · 36 unmodified lines
855859 return;
856860 }
857861
858− if (input.mouse.rightButtonPressed)
862+ if (mouse.rightButtonPressed)
859863 {
860864 if (fast)
861865 val += 64;
@@ -898,7 +902,7 @@ void sampleRepeatDownButton(bool fast) · 36 unmodified lines
898902 return;
899903 }
900904
901− if (input.mouse.rightButtonPressed)
905+ if (mouse.rightButtonPressed)
902906 {
903907 if (fast)
904908 val -= 64;
@@ -942,7 +946,7 @@ void sampleRepeatLengthUpButton(bool fast) · 37 unmodified lines
942946 return;
943947 }
944948
945− if (input.mouse.rightButtonPressed)
949+ if (mouse.rightButtonPressed)
946950 {
947951 if (fast)
948952 val += 64;
@@ -985,7 +989,7 @@ void sampleRepeatLengthDownButton(bool fast) · 36 unmodified lines
985989 return;
986990 }
987991
988− if (input.mouse.rightButtonPressed)
992+ if (mouse.rightButtonPressed)
989993 {
990994 if (fast)
991995 val -= 64;
@@ -1023,7 +1027,7 @@ void tempoUpButton(void) · 31 unmodified lines
10231027 return;
10241028
10251029 val = modEntry->currBPM;
1026− if (input.mouse.rightButtonPressed)
1030+ if (mouse.rightButtonPressed)
10271031 val += 10;
10281032 else
10291033 val++;
@@ -1044,7 +1048,7 @@ void tempoDownButton(void) · 14 unmodified lines
10441048 return;
10451049
10461050 val = modEntry->currBPM;
1047− if (input.mouse.rightButtonPressed)
1051+ if (mouse.rightButtonPressed)
10481052 val -= 10;
10491053 else
10501054 val--;
@@ -1062,7 +1066,7 @@ void songLengthUpButton(void) · 11 unmodified lines
10621066 int16_t val;
10631067
10641068 val = modEntry->head.orderCount;
1065− if (input.mouse.rightButtonPressed)
1069+ if (mouse.rightButtonPressed)
10661070 val += 10;
10671071 else
10681072 val++;
@@ -1084,7 +1088,7 @@ void songLengthDownButton(void) · 15 unmodified lines
10841088 {
10851089 int16_t val = modEntry->head.orderCount;
10861090
1087− if (input.mouse.rightButtonPressed)
1091+ if (mouse.rightButtonPressed)
10881092 val -= 10;
10891093 else
10901094 val--;
@@ -1106,7 +1110,7 @@ void patternUpButton(void) · 15 unmodified lines
11061110 {
11071111 int16_t val = modEntry->head.order[modEntry->currOrder];
11081112
1109− if (input.mouse.rightButtonPressed)
1113+ if (mouse.rightButtonPressed)
11101114 val += 10;
11111115 else
11121116 val++;
@@ -1126,7 +1130,7 @@ void patternDownButton(void) · 13 unmodified lines
11261130 {
11271131 int16_t val = modEntry->head.order[modEntry->currOrder];
11281132
1129− if (input.mouse.rightButtonPressed)
1133+ if (mouse.rightButtonPressed)
11301134 val -= 10;
11311135 else
11321136 val--;
@@ -1146,7 +1150,7 @@ void positionUpButton(void) · 13 unmodified lines
11461150 {
11471151 int16_t val = modEntry->currOrder;
11481152
1149− if (input.mouse.rightButtonPressed)
1153+ if (mouse.rightButtonPressed)
11501154 val += 10;
11511155 else
11521156 val++;
@@ -1161,7 +1165,7 @@ void positionDownButton(void) · 8 unmodified lines
11611165 {
11621166 int16_t val = modEntry->currOrder;
11631167
1164− if (input.mouse.rightButtonPressed)
1168+ if (mouse.rightButtonPressed)
11651169 val -= 10;
11661170 else
11671171 val--;
@@ -1181,7 +1185,7 @@ void handleSamplerVolumeBox(void) · 13 unmodified lines
11811185 double dSmp;
11821186 moduleSample_t *s;
11831187
1184− if (input.mouse.rightButtonPressed)
1188+ if (mouse.rightButtonPressed)
11851189 {
11861190 if (editor.ui.editTextFlag)
11871191 {
@@ -1200,14 +1204,14 @@ void handleSamplerVolumeBox(void) · 12 unmodified lines
12001204 return;
12011205
12021206 // check buttons
1203− if (input.mouse.leftButtonPressed)
1207+ if (mouse.leftButtonPressed)
12041208 {
12051209 // restore sample ask dialog
12061210 if (editor.ui.askScreenShown && editor.ui.askScreenType == ASK_RESTORE_SAMPLE)
12071211 {
1208− if (input.mouse.y >= 71 && input.mouse.y <= 81)
1212+ if (mouse.y >= 71 && mouse.y <= 81)
12091213 {
1210− if (input.mouse.x >= 171 && input.mouse.x <= 196)
1214+ if (mouse.x >= 171 && mouse.x <= 196)
12111215 {
12121216 // YES button
12131217 editor.ui.askScreenShown = false;
@@ -1215,7 +1219,7 @@ void handleSamplerVolumeBox(void) · 1 unmodified line
12151219 editor.ui.answerYes = true;
12161220 handleAskYes();
12171221 }
1218− else if (input.mouse.x >= 234 && input.mouse.x <= 252)
1222+ else if (mouse.x >= 234 && mouse.x <= 252)
12191223 {
12201224 // NO button
12211225 editor.ui.askScreenShown = false;
@@ -1231,31 +1235,31 @@ void handleSamplerVolumeBox(void) · 9 unmodified lines
12311235 // MAIN SCREEN STOP
12321236 if (!editor.ui.diskOpScreenShown && !editor.ui.posEdScreenShown)
12331237 {
1234− if (input.mouse.x >= 182 && input.mouse.x <= 243 && input.mouse.y >= 0 && input.mouse.y <= 10)
1238+ if (mouse.x >= 182 && mouse.x <= 243 && mouse.y >= 0 && mouse.y <= 10)
12351239 {
12361240 modStop();
12371241 return;
12381242 }
12391243 }
12401244
1241− if (input.mouse.x >= 32 && input.mouse.x <= 95)
1245+ if (mouse.x >= 32 && mouse.x <= 95)
12421246 {
12431247 // SAMPLER SCREEN PLAY WAVEFORM
1244− if (input.mouse.y >= 211 && input.mouse.y <= 221)
1248+ if (mouse.y >= 211 && mouse.y <= 221)
12451249 {
12461250 samplerPlayWaveform();
12471251 return;
12481252 }
12491253
12501254 // SAMPLER SCREEN PLAY DISPLAY
1251− else if (input.mouse.y >= 222 && input.mouse.y <= 232)
1255+ else if (mouse.y >= 222 && mouse.y <= 232)
12521256 {
12531257 samplerPlayDisplay();
12541258 return;
12551259 }
12561260
12571261 // SAMPLER SCREEN PLAY RANGE
1258− else if (input.mouse.y >= 233 && input.mouse.y <= 243)
1262+ else if (mouse.y >= 233 && mouse.y <= 243)
12591263 {
12601264 samplerPlayRange();
12611265 return;
@@ -1263,7 +1267,7 @@ void handleSamplerVolumeBox(void) · 1 unmodified line
12631267 }
12641268
12651269 // SAMPLER SCREEN STOP
1266− if (input.mouse.x >= 0 && input.mouse.x <= 31 && input.mouse.y >= 222 && input.mouse.y <= 243)
1270+ if (mouse.x >= 0 && mouse.x <= 31 && mouse.y >= 222 && mouse.y <= 243)
12671271 {
12681272 for (i = 0; i < AMIGA_VOICES; i++)
12691273 mixerKillVoice(i);
@@ -1271,7 +1275,7 @@ void handleSamplerVolumeBox(void) · 1 unmodified line
12711275 }
12721276
12731277 // VOLUME button (toggle)
1274− if (input.mouse.x >= 96 && input.mouse.x <= 135 && input.mouse.y >= 244 && input.mouse.y <= 254)
1278+ if (mouse.x >= 96 && mouse.x <= 135 && mouse.y >= 244 && mouse.y <= 254)
12751279 {
12761280 editor.ui.samplerVolBoxShown = false;
12771281 removeSamplerVolBox();
@@ -1279,16 +1283,16 @@ void handleSamplerVolumeBox(void) · 1 unmodified line
12791283 }
12801284
12811285 // DRAG BOXES
1282− if (input.mouse.x >= 72 && input.mouse.x <= 173 && input.mouse.y >= 154 && input.mouse.y <= 175)
1286+ if (mouse.x >= 72 && mouse.x <= 173 && mouse.y >= 154 && mouse.y <= 175)
12831287 {
12841288 volBoxBarPressed(MOUSE_BUTTON_NOT_HELD);
12851289 return;
12861290 }
12871291
1288− if (input.mouse.x >= 174 && input.mouse.x <= 207)
1292+ if (mouse.x >= 174 && mouse.x <= 207)
12891293 {
12901294 // FROM NUM
1291− if (input.mouse.y >= 154 && input.mouse.y <= 164)
1295+ if (mouse.y >= 154 && mouse.y <= 164)
12921296 {
12931297 editor.ui.tmpDisp16 = editor.vol1;
12941298 editor.vol1Disp = &editor.ui.tmpDisp16;
@@ -1300,7 +1304,7 @@ void handleSamplerVolumeBox(void) · 5 unmodified lines
13001304 }
13011305
13021306 // TO NUM
1303− else if (input.mouse.y >= 165 && input.mouse.y <= 175)
1307+ else if (mouse.y >= 165 && mouse.y <= 175)
13041308 {
13051309 editor.ui.tmpDisp16 = editor.vol2;
13061310 editor.vol2Disp = &editor.ui.tmpDisp16;
@@ -1312,10 +1316,10 @@ void handleSamplerVolumeBox(void) · 5 unmodified lines
13121316 }
13131317 }
13141318
1315− if (input.mouse.y >= 176 && input.mouse.y <= 186)
1319+ if (mouse.y >= 176 && mouse.y <= 186)
13161320 {
13171321 // NORMALIZE
1318− if (input.mouse.x >= 101 && input.mouse.x <= 143)
1322+ if (mouse.x >= 101 && mouse.x <= 143)
13191323 {
13201324 s = &modEntry->samples[editor.currSample];
13211325 if (s->length == 0)
@@ -1374,7 +1378,7 @@ void handleSamplerVolumeBox(void) · 52 unmodified lines
13741378 }
13751379
13761380 // RAMP DOWN
1377− else if (input.mouse.x >= 144 && input.mouse.x <= 153)
1381+ else if (mouse.x >= 144 && mouse.x <= 153)
13781382 {
13791383 editor.vol1 = 100;
13801384 editor.vol2 = 0;
@@ -1386,7 +1390,7 @@ void handleSamplerVolumeBox(void) · 5 unmodified lines
13861390 }
13871391
13881392 // RAMP UP
1389− else if (input.mouse.x >= 154 && input.mouse.x <= 163)
1393+ else if (mouse.x >= 154 && mouse.x <= 163)
13901394 {
13911395 editor.vol1 = 0;
13921396 editor.vol2 = 100;
@@ -1398,7 +1402,7 @@ void handleSamplerVolumeBox(void) · 5 unmodified lines
13981402 }
13991403
14001404 // RAMP UNITY
1401− else if (input.mouse.x >= 164 && input.mouse.x <= 173)
1405+ else if (mouse.x >= 164 && mouse.x <= 173)
14021406 {
14031407 editor.vol1 = 100;
14041408 editor.vol2 = 100;
@@ -1410,7 +1414,7 @@ void handleSamplerVolumeBox(void) · 5 unmodified lines
14101414 }
14111415
14121416 // CANCEL
1413− else if (input.mouse.x >= 174 && input.mouse.x <= 207)
1417+ else if (mouse.x >= 174 && mouse.x <= 207)
14141418 {
14151419 editor.ui.samplerVolBoxShown = false;
14161420 removeSamplerVolBox();
@@ -1418,7 +1422,7 @@ void handleSamplerVolumeBox(void) · 1 unmodified line
14181422 }
14191423
14201424 // RAMP
1421− else if (input.mouse.x >= 72 && input.mouse.x <= 100)
1425+ else if (mouse.x >= 72 && mouse.x <= 100)
14221426 {
14231427 s = &modEntry->samples[editor.currSample];
14241428 if (s->length == 0)
@@ -1478,14 +1482,14 @@ void handleSamplerVolumeBox(void) · 53 unmodified lines
14781482
14791483 static void handleRepeatedSamplerFilterButtons(void)
14801484 {
1481− if (!input.mouse.leftButtonPressed || input.mouse.lastSmpFilterButton == -1)
1485+ if (!mouse.leftButtonPressed || mouse.lastSmpFilterButton == -1)
14821486 return;
14831487
1484− switch (input.mouse.lastSmpFilterButton)
1488+ switch (mouse.lastSmpFilterButton)
14851489 {
14861490 case 0: // low-pass cutoff up
14871491 {
1488− if (input.mouse.rightButtonPressed)
1492+ if (mouse.rightButtonPressed)
14891493 {
14901494 if (editor.lpCutOff <= 0xFFFF-50)
14911495 editor.lpCutOff += 50;
@@ -1509,7 +1513,7 @@ static void handleRepeatedSamplerFilterButtons(void) · 17 unmodified lines
15091513
15101514 case 1: // low-pass cutoff down
15111515 {
1512− if (input.mouse.rightButtonPressed)
1516+ if (mouse.rightButtonPressed)
15131517 {
15141518 if (editor.lpCutOff >= 50)
15151519 editor.lpCutOff -= 50;
@@ -1530,7 +1534,7 @@ static void handleRepeatedSamplerFilterButtons(void) · 14 unmodified lines
15301534
15311535 case 2: // high-pass cutoff up
15321536 {
1533− if (input.mouse.rightButtonPressed)
1537+ if (mouse.rightButtonPressed)
15341538 {
15351539 if (editor.hpCutOff <= 0xFFFF-50)
15361540 editor.hpCutOff += 50;
@@ -1554,7 +1558,7 @@ static void handleRepeatedSamplerFilterButtons(void) · 17 unmodified lines
15541558
15551559 case 3: // high-pass cutoff down
15561560 {
1557− if (input.mouse.rightButtonPressed)
1561+ if (mouse.rightButtonPressed)
15581562 {
15591563 if (editor.hpCutOff >= 50)
15601564 editor.hpCutOff -= 50;
@@ -1582,21 +1586,21 @@ void handleSamplerFiltersBox(void) · 21 unmodified lines
15821586 uint8_t i;
15831587 moduleSample_t *s;
15841588
1585− if (input.mouse.rightButtonPressed && editor.ui.editTextFlag)
1589+ if (mouse.rightButtonPressed && editor.ui.editTextFlag)
15861590 {
15871591 exitGetTextLine(EDIT_TEXT_NO_UPDATE);
15881592 return;
15891593 }
15901594
1591− if (editor.ui.editTextFlag || input.mouse.lastSmpFilterButton > -1 || !input.mouse.leftButtonPressed)
1595+ if (editor.ui.editTextFlag || mouse.lastSmpFilterButton > -1 || !mouse.leftButtonPressed)
15921596 return;
15931597
15941598 // restore sample ask dialog
15951599 if (editor.ui.askScreenShown && editor.ui.askScreenType == ASK_RESTORE_SAMPLE)
15961600 {
1597− if (input.mouse.y >= 71 && input.mouse.y <= 81)
1601+ if (mouse.y >= 71 && mouse.y <= 81)
15981602 {
1599− if (input.mouse.x >= 171 && input.mouse.x <= 196)
1603+ if (mouse.x >= 171 && mouse.x <= 196)
16001604 {
16011605 // YES button
16021606 editor.ui.askScreenShown = false;
@@ -1604,7 +1608,7 @@ void handleSamplerFiltersBox(void) · 1 unmodified line
16041608 editor.ui.answerYes = true;
16051609 handleAskYes();
16061610 }
1607− else if ((input.mouse.x >= 234) && (input.mouse.x <= 252))
1611+ else if ((mouse.x >= 234) && (mouse.x <= 252))
16081612 {
16091613 // NO button
16101614 editor.ui.askScreenShown = false;
@@ -1618,7 +1622,7 @@ void handleSamplerFiltersBox(void) · 7 unmodified lines
16181622 }
16191623
16201624 // FILTERS button (toggle)
1621− if (input.mouse.x >= 211 && input.mouse.x <= 245 && input.mouse.y >= 244 && input.mouse.y <= 254)
1625+ if (mouse.x >= 211 && mouse.x <= 245 && mouse.y >= 244 && mouse.y <= 254)
16221626 {
16231627 editor.ui.samplerFiltersBoxShown = false;
16241628 removeSamplerFiltersBox();
@@ -1628,31 +1632,31 @@ void handleSamplerFiltersBox(void) · 3 unmodified lines
16281632 // MAIN SCREEN STOP
16291633 if (!editor.ui.diskOpScreenShown && !editor.ui.posEdScreenShown)
16301634 {
1631− if (input.mouse.x >= 182 && input.mouse.x <= 243 && input.mouse.y >= 0 && input.mouse.y <= 10)
1635+ if (mouse.x >= 182 && mouse.x <= 243 && mouse.y >= 0 && mouse.y <= 10)
16321636 {
16331637 modStop();
16341638 return;
16351639 }
16361640 }
16371641
1638− if (input.mouse.x >= 32 && input.mouse.x <= 95)
1642+ if (mouse.x >= 32 && mouse.x <= 95)
16391643 {
16401644 // SAMPLER SCREEN PLAY WAVEFORM
1641− if (input.mouse.y >= 211 && input.mouse.y <= 221)
1645+ if (mouse.y >= 211 && mouse.y <= 221)
16421646 {
16431647 samplerPlayWaveform();
16441648 return;
16451649 }
16461650
16471651 // SAMPLER SCREEN PLAY DISPLAY
1648− else if (input.mouse.y >= 222 && input.mouse.y <= 232)
1652+ else if (mouse.y >= 222 && mouse.y <= 232)
16491653 {
16501654 samplerPlayDisplay();
16511655 return;
16521656 }
16531657
16541658 // SAMPLER SCREEN PLAY RANGE
1655− else if (input.mouse.y >= 233 && input.mouse.y <= 243)
1659+ else if (mouse.y >= 233 && mouse.y <= 243)
16561660 {
16571661 samplerPlayRange();
16581662 return;
@@ -1660,7 +1664,7 @@ void handleSamplerFiltersBox(void) · 1 unmodified line
16601664 }
16611665
16621666 // SAMPLER SCREEN STOP
1663− if (input.mouse.x >= 0 && input.mouse.x <= 31 && input.mouse.y >= 222 && input.mouse.y <= 243)
1667+ if (mouse.x >= 0 && mouse.x <= 31 && mouse.y >= 222 && mouse.y <= 243)
16641668 {
16651669 for (i = 0; i < AMIGA_VOICES; i++)
16661670 mixerKillVoice(i);
@@ -1668,7 +1672,7 @@ void handleSamplerFiltersBox(void) · 1 unmodified line
16681672 }
16691673
16701674 // UNDO
1671− if (input.mouse.x >= 65 && input.mouse.x <= 75 && input.mouse.y >= 154 && input.mouse.y <= 184)
1675+ if (mouse.x >= 65 && mouse.x <= 75 && mouse.y >= 154 && mouse.y <= 184)
16721676 {
16731677 s = &modEntry->samples[editor.currSample];
16741678 if (s->length == 0)
@@ -1686,10 +1690,10 @@ void handleSamplerFiltersBox(void) · 11 unmodified lines
16861690 return;
16871691 }
16881692
1689− if (input.mouse.y >= 154 && input.mouse.y <= 164)
1693+ if (mouse.y >= 154 && mouse.y <= 164)
16901694 {
16911695 // DO LOW-PASS FILTER
1692− if (input.mouse.x >= 76 && input.mouse.x <= 165)
1696+ if (mouse.x >= 76 && mouse.x <= 165)
16931697 {
16941698 lowPassSample(editor.lpCutOff);
16951699 renderSamplerFiltersBox();
@@ -1697,9 +1701,9 @@ void handleSamplerFiltersBox(void) · 1 unmodified line
16971701 }
16981702
16991703 // LOW-PASS CUTOFF
1700− else if (input.mouse.x >= 166 && input.mouse.x <= 217)
1704+ else if (mouse.x >= 166 && mouse.x <= 217)
17011705 {
1702− if (input.mouse.rightButtonPressed)
1706+ if (mouse.rightButtonPressed)
17031707 {
17041708 editor.lpCutOff = 0;
17051709 editor.ui.updateLPText = true;
@@ -1718,10 +1722,10 @@ void handleSamplerFiltersBox(void) · 12 unmodified lines
17181722 }
17191723
17201724 // LOW-PASS CUTOFF UP
1721− else if (input.mouse.x >= 218 && input.mouse.x <= 228)
1725+ else if (mouse.x >= 218 && mouse.x <= 228)
17221726 {
1723− input.mouse.lastSmpFilterButton = 0;
1724− if (input.mouse.rightButtonPressed)
1727+ mouse.lastSmpFilterButton = 0;
1728+ if (mouse.rightButtonPressed)
17251729 {
17261730 if (editor.lpCutOff <= 0xFFFF-100)
17271731 editor.lpCutOff += 100;
@@ -1744,10 +1748,10 @@ void handleSamplerFiltersBox(void) · 16 unmodified lines
17441748 }
17451749
17461750 // LOW-PASS CUTOFF DOWN
1747− else if (input.mouse.x >= 229 && input.mouse.x <= 239)
1751+ else if (mouse.x >= 229 && mouse.x <= 239)
17481752 {
1749− input.mouse.lastSmpFilterButton = 1;
1750− if (input.mouse.rightButtonPressed)
1753+ mouse.lastSmpFilterButton = 1;
1754+ if (mouse.rightButtonPressed)
17511755 {
17521756 if (editor.lpCutOff >= 100)
17531757 editor.lpCutOff -= 100;
@@ -1767,10 +1771,10 @@ void handleSamplerFiltersBox(void) · 13 unmodified lines
17671771 }
17681772 }
17691773
1770− if (input.mouse.y >= 164 && input.mouse.y <= 174)
1774+ if (mouse.y >= 164 && mouse.y <= 174)
17711775 {
17721776 // DO HIGH-PASS FILTER
1773− if (input.mouse.x >= 76 && input.mouse.x <= 165)
1777+ if (mouse.x >= 76 && mouse.x <= 165)
17741778 {
17751779 highPassSample(editor.hpCutOff);
17761780 renderSamplerFiltersBox();
@@ -1778,9 +1782,9 @@ void handleSamplerFiltersBox(void) · 1 unmodified line
17781782 }
17791783
17801784 // HIGH-PASS CUTOFF
1781− else if (input.mouse.x >= 166 && input.mouse.x <= 217)
1785+ else if (mouse.x >= 166 && mouse.x <= 217)
17821786 {
1783− if (input.mouse.rightButtonPressed)
1787+ if (mouse.rightButtonPressed)
17841788 {
17851789 editor.hpCutOff = 0;
17861790 editor.ui.updateHPText = true;
@@ -1799,10 +1803,10 @@ void handleSamplerFiltersBox(void) · 12 unmodified lines
17991803 }
18001804
18011805 // HIGH-PASS CUTOFF UP
1802− else if (input.mouse.x >= 218 && input.mouse.x <= 228)
1806+ else if (mouse.x >= 218 && mouse.x <= 228)
18031807 {
1804− input.mouse.lastSmpFilterButton = 2;
1805− if (input.mouse.rightButtonPressed)
1808+ mouse.lastSmpFilterButton = 2;
1809+ if (mouse.rightButtonPressed)
18061810 {
18071811 if (editor.hpCutOff <= 0xFFFF-100)
18081812 editor.hpCutOff += 100;
@@ -1825,10 +1829,10 @@ void handleSamplerFiltersBox(void) · 16 unmodified lines
18251829 }
18261830
18271831 // HIGH-PASS CUTOFF DOWN
1828− else if (input.mouse.x >= 229 && input.mouse.x <= 239)
1832+ else if (mouse.x >= 229 && mouse.x <= 239)
18291833 {
1830− input.mouse.lastSmpFilterButton = 3;
1831− if (input.mouse.rightButtonPressed)
1834+ mouse.lastSmpFilterButton = 3;
1835+ if (mouse.rightButtonPressed)
18321836 {
18331837 if (editor.hpCutOff >= 100)
18341838 editor.hpCutOff -= 100;
@@ -1849,7 +1853,7 @@ void handleSamplerFiltersBox(void) · 14 unmodified lines
18491853 }
18501854
18511855 // NORMALIZE SAMPLE FLAG
1852− if (input.mouse.x >= 76 && input.mouse.x <= 239 && input.mouse.y >= 174 && input.mouse.y <= 186)
1856+ if (mouse.x >= 76 && mouse.x <= 239 && mouse.y >= 174 && mouse.y <= 186)
18531857 {
18541858 editor.normalizeFiltersFlag ^= 1;
18551859 editor.ui.updateNormFlag = true;
@@ -1857,7 +1861,7 @@ void handleSamplerFiltersBox(void) · 1 unmodified line
18571861 }
18581862
18591863 // EXIT
1860− if (input.mouse.x >= 240 && input.mouse.x <= 250 && input.mouse.y >= 154 && input.mouse.y <= 186)
1864+ if (mouse.x >= 240 && mouse.x <= 250 && mouse.y >= 154 && mouse.y <= 186)
18611865 {
18621866 editor.ui.samplerFiltersBoxShown = false;
18631867 removeSamplerFiltersBox();
@@ -1866,7 +1870,7 @@ void handleSamplerFiltersBox(void) · 2 unmodified lines
18661870
18671871 static bool withinButtonRect(const guiButton_t *b)
18681872 {
1869− if (input.mouse.x >= b->x1 && input.mouse.x <= b->x2 && input.mouse.y >= b->y1 && input.mouse.y <= b->y2)
1873+ if (mouse.x >= b->x1 && mouse.x <= b->x2 && mouse.y >= b->y1 && mouse.y <= b->y2)
18701874 return true;
18711875
18721876 return false;
@@ -1900,7 +1904,7 @@ int32_t checkGUIButtons(void) · 27 unmodified lines
19001904 }
19011905
19021906 // QUIT (xy 0,0) works on all screens except for ask/clear screen
1903− if (input.mouse.x == 0 && input.mouse.y == 0)
1907+ if (mouse.x == 0 && mouse.y == 0)
19041908 return PTB_QUIT;
19051909
19061910 // top screen buttons
@@ -1960,10 +1964,10 @@ void handleTextEditing(uint8_t mouseButton) · 53 unmodified lines
19601964 }
19611965 else if (mouseButton == SDL_BUTTON_LEFT && !editor.mixFlag)
19621966 {
1963− tmp16 = input.mouse.y - editor.ui.lineCurY;
1967+ tmp16 = mouse.y - editor.ui.lineCurY;
19641968 if (tmp16 <= 2 && tmp16 >= -9)
19651969 {
1966− tmp16 = (uint16_t)((input.mouse.x - editor.ui.lineCurX) + 4) >> 3;
1970+ tmp16 = (uint16_t)((mouse.x - editor.ui.lineCurX) + 4) >> 3;
19671971 while (tmp16 != 0) // 0 = pos we want
19681972 {
19691973 if (tmp16 > 0)
@@ -2038,7 +2042,7 @@ void mouseWheelUpHandler(void) · 68 unmodified lines
20382042 if (editor.ui.editTextFlag || editor.ui.askScreenShown || editor.ui.clearScreenShown || editor.swapChannelFlag)
20392043 return;
20402044
2041− if (input.mouse.y < 121)
2045+ if (mouse.y < 121)
20422046 {
20432047 // upper part of screen
20442048 if (editor.ui.diskOpScreenShown)
@@ -2069,7 +2073,7 @@ void mouseWheelDownHandler(void) · 24 unmodified lines
20692073 if (editor.ui.editTextFlag || editor.ui.askScreenShown || editor.ui.clearScreenShown || editor.swapChannelFlag)
20702074 return;
20712075
2072− if (input.mouse.y < 121)
2076+ if (mouse.y < 121)
20732077 {
20742078 // upper part of screen
20752079 if (editor.ui.diskOpScreenShown)
@@ -2097,7 +2101,7 @@ void mouseWheelDownHandler(void) · 21 unmodified lines
20972101
20982102 bool handleRightMouseButton(void)
20992103 {
2100− if (!input.mouse.rightButtonPressed)
2104+ if (!mouse.rightButtonPressed)
21012105 return false;
21022106
21032107 // exit sample swap mode with right mouse button (if present)
@@ -2136,23 +2140,23 @@ bool handleRightMouseButton(void) · 32 unmodified lines
21362140 }
21372141
21382142 // toggle channel muting with right mouse button
2139− if (editor.ui.visualizerMode == VISUAL_QUADRASCOPE && input.mouse.y >= 55 && input.mouse.y <= 87)
2143+ if (editor.ui.visualizerMode == VISUAL_QUADRASCOPE && mouse.y >= 55 && mouse.y <= 87)
21402144 {
21412145 if (!editor.ui.posEdScreenShown && !editor.ui.editOpScreenShown && !editor.ui.diskOpScreenShown &&
21422146 !editor.ui.aboutScreenShown && !editor.ui.samplerVolBoxShown &&
21432147 !editor.ui.samplerFiltersBoxShown && !editor.isWAVRendering)
21442148 {
2145− if (input.mouse.x > 127 && input.mouse.x <= 167) editor.muted[0] ^= 1;
2146− else if (input.mouse.x > 175 && input.mouse.x <= 215) editor.muted[1] ^= 1;
2147− else if (input.mouse.x > 223 && input.mouse.x <= 263) editor.muted[2] ^= 1;
2148− else if (input.mouse.x > 271 && input.mouse.x <= 311) editor.muted[3] ^= 1;
2149+ if (mouse.x > 127 && mouse.x <= 167) editor.muted[0] ^= 1;
2150+ else if (mouse.x > 175 && mouse.x <= 215) editor.muted[1] ^= 1;
2151+ else if (mouse.x > 223 && mouse.x <= 263) editor.muted[2] ^= 1;
2152+ else if (mouse.x > 271 && mouse.x <= 311) editor.muted[3] ^= 1;
21492153
21502154 renderMuteButtons();
21512155 }
21522156 }
21532157
21542158 // sample hand drawing
2155− if (input.mouse.y >= 138 && input.mouse.y <= 201 && editor.ui.samplerScreenShown &&
2159+ if (mouse.y >= 138 && mouse.y <= 201 && editor.ui.samplerScreenShown &&
21562160 !editor.ui.samplerVolBoxShown && !editor.ui.samplerFiltersBoxShown)
21572161 {
21582162 samplerEditSample(false);
@@ -2185,9 +2189,9 @@ bool handleLeftMouseButton(void) · 26 unmodified lines
21852189 // "downsample before loading sample" ask dialog
21862190 if (editor.ui.askScreenShown && editor.ui.askScreenType == ASK_LOAD_DOWNSAMPLE)
21872191 {
2188− if (input.mouse.y >= 83 && input.mouse.y <= 93)
2192+ if (mouse.y >= 83 && mouse.y <= 93)
21892193 {
2190− if (input.mouse.x >= 179 && input.mouse.x <= 204)
2194+ if (mouse.x >= 179 && mouse.x <= 204)
21912195 {
21922196 // YES button
21932197 editor.ui.askScreenShown = false;
@@ -2196,7 +2200,7 @@ bool handleLeftMouseButton(void) · 2 unmodified lines
21962200 handleAskYes();
21972201 return true;
21982202 }
2199− else if (input.mouse.x >= 242 && input.mouse.x <= 260)
2203+ else if (mouse.x >= 242 && mouse.x <= 260)
22002204 {
22012205 // NO button
22022206 editor.ui.askScreenShown = false;
@@ -2213,7 +2217,7 @@ bool handleLeftMouseButton(void) · 10 unmodified lines
22132217 // cancel note input gadgets with left/right mouse button
22142218 if (editor.ui.changingSmpResample || editor.ui.changingChordNote || editor.ui.changingDrumPadNote)
22152219 {
2216− if (input.mouse.leftButtonPressed || input.mouse.rightButtonPressed)
2220+ if (mouse.leftButtonPressed || mouse.rightButtonPressed)
22172221 {
22182222 editor.ui.changingSmpResample = false;
22192223 editor.ui.changingChordNote = false;
@@ -2232,7 +2236,7 @@ bool handleLeftMouseButton(void) · 12 unmodified lines
22322236 return true;
22332237 }
22342238
2235− if (!input.mouse.leftButtonPressed)
2239+ if (!mouse.leftButtonPressed)
22362240 return false;
22372241
22382242 // handle QUIT ask dialog while Disk Op. filling is ongoing
@@ -2240,9 +2244,9 @@ bool handleLeftMouseButton(void) · 1 unmodified line
22402244 {
22412245 if (editor.ui.askScreenShown && editor.ui.askScreenType == ASK_QUIT)
22422246 {
2243− if (input.mouse.y >= 71 && input.mouse.y <= 81)
2247+ if (mouse.y >= 71 && mouse.y <= 81)
22442248 {
2245− if (input.mouse.x >= 171 && input.mouse.x <= 196)
2249+ if (mouse.x >= 171 && mouse.x <= 196)
22462250 {
22472251 // YES button
22482252 editor.ui.askScreenShown = false;
@@ -2250,7 +2254,7 @@ bool handleLeftMouseButton(void) · 1 unmodified line
22502254 editor.ui.answerYes = true;
22512255 handleAskYes();
22522256 }
2253− else if (input.mouse.x >= 234 && input.mouse.x <= 252)
2257+ else if (mouse.x >= 234 && mouse.x <= 252)
22542258 {
22552259 // NO button
22562260 editor.ui.askScreenShown = false;
@@ -2269,7 +2273,7 @@ bool handleLeftMouseButton(void) · 12 unmodified lines
22692273 {
22702274 if (editor.ui.askScreenShown && editor.ui.askScreenType == ASK_QUIT)
22712275 {
2272− if (input.mouse.x >= 171 && input.mouse.x <= 196)
2276+ if (mouse.x >= 171 && mouse.x <= 196)
22732277 {
22742278 // YES button
22752279 editor.isWAVRendering = false;
@@ -2280,7 +2284,7 @@ bool handleLeftMouseButton(void) · 4 unmodified lines
22802284 editor.ui.answerYes = true;
22812285 handleAskYes();
22822286 }
2283− else if (input.mouse.x >= 234 && input.mouse.x <= 252)
2287+ else if (mouse.x >= 234 && mouse.x <= 252)
22842288 {
22852289 // NO button
22862290 editor.ui.askScreenShown = false;
@@ -2292,7 +2296,7 @@ bool handleLeftMouseButton(void) · 5 unmodified lines
22922296 setStatusMessage("RENDERING MOD...", NO_CARRY);
22932297 }
22942298 }
2295− else if (input.mouse.y >= 58 && input.mouse.y <= 68 && input.mouse.x >= 133 && input.mouse.x <= 186)
2299+ else if (mouse.y >= 58 && mouse.y <= 68 && mouse.x >= 133 && mouse.x <= 186)
22962300 {
22972301 // CANCEL button
22982302 editor.abortMod2Wav = true;
@@ -2310,12 +2314,12 @@ bool handleLeftMouseButton(void) · 11 unmodified lines
23102314
23112315 void updateMouseCounters(void)
23122316 {
2313− if (input.mouse.buttonWaiting)
2317+ if (mouse.buttonWaiting)
23142318 {
2315− if (++input.mouse.buttonWaitCounter > VBLANK_HZ/4) // quarter of a second
2319+ if (++mouse.buttonWaitCounter > VBLANK_HZ/4) // quarter of a second
23162320 {
2317− input.mouse.buttonWaitCounter = 0;
2318− input.mouse.buttonWaiting = false;
2321+ mouse.buttonWaitCounter = 0;
2322+ mouse.buttonWaiting = false;
23192323 }
23202324 }
23212325
@@ -2465,7 +2469,7 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 143 unmodified lines
24652469
24662470 case PTB_EO_QUANTIZE:
24672471 {
2468− editor.ui.tmpDisp16 = ptConfig.quantizeValue;
2472+ editor.ui.tmpDisp16 = config.quantizeValue;
24692473 editor.quantizeValueDisp = &editor.ui.tmpDisp16;
24702474 editor.ui.numPtr16 = &editor.ui.tmpDisp16;
24712475 editor.ui.numLen = 2;
@@ -2573,7 +2577,7 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 101 unmodified lines
25732577
25742578 case PTB_EO_MIX:
25752579 {
2576− if (!input.mouse.rightButtonPressed)
2580+ if (!mouse.rightButtonPressed)
25772581 {
25782582 editor.mixFlag = true;
25792583 editor.ui.showTextPtr = editor.mixText;
@@ -2729,7 +2733,7 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 149 unmodified lines
27292733
27302734 case PTB_EO_POS_NUM:
27312735 {
2732− if (input.mouse.rightButtonPressed)
2736+ if (mouse.rightButtonPressed)
27332737 {
27342738 editor.samplePos = 0;
27352739 editor.ui.updatePosText = true;
@@ -2786,7 +2790,7 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 50 unmodified lines
27862790
27872791 case PTB_EO_MOD_NUM:
27882792 {
2789− if (input.mouse.rightButtonPressed)
2793+ if (mouse.rightButtonPressed)
27902794 {
27912795 editor.modulateSpeed = 0;
27922796 editor.ui.updateModText = true;
@@ -3089,7 +3093,7 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 296 unmodified lines
30893093
30903094 case PTB_EO_VOL_NUM:
30913095 {
3092− if (input.mouse.rightButtonPressed)
3096+ if (mouse.rightButtonPressed)
30933097 {
30943098 editor.sampleVol = 100;
30953099 editor.ui.updateVolText = true;
@@ -3212,7 +3216,7 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 116 unmodified lines
32123216
32133217 case PTB_EO_NOTE1:
32143218 {
3215− if (input.mouse.rightButtonPressed)
3219+ if (mouse.rightButtonPressed)
32163220 {
32173221 editor.note1 = 36;
32183222 }
@@ -3231,7 +3235,7 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 12 unmodified lines
32313235
32323236 case PTB_EO_NOTE2:
32333237 {
3234− if (input.mouse.rightButtonPressed)
3238+ if (mouse.rightButtonPressed)
32353239 {
32363240 editor.note2 = 36;
32373241 }
@@ -3250,7 +3254,7 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 12 unmodified lines
32503254
32513255 case PTB_EO_NOTE3:
32523256 {
3253− if (input.mouse.rightButtonPressed)
3257+ if (mouse.rightButtonPressed)
32543258 {
32553259 editor.note3 = 36;
32563260 }
@@ -3269,7 +3273,7 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 12 unmodified lines
32693273
32703274 case PTB_EO_NOTE4:
32713275 {
3272− if (input.mouse.rightButtonPressed)
3276+ if (mouse.rightButtonPressed)
32733277 {
32743278 editor.note4 = 36;
32753279 }
@@ -3440,7 +3444,7 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 164 unmodified lines
34403444 {
34413445 if (modEntry->samples[editor.currSample].loopLength == 2 && modEntry->samples[editor.currSample].loopStart == 0)
34423446 {
3443− editor.chordLengthMin = input.mouse.rightButtonPressed ? true : false;
3447+ editor.chordLengthMin = mouse.rightButtonPressed ? true : false;
34443448 recalcChordLength();
34453449 }
34463450 }
@@ -3563,7 +3567,7 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 116 unmodified lines
35633567 {
35643568 if (editor.currMode == MODE_IDLE || editor.currMode == MODE_EDIT)
35653569 {
3566− if (input.mouse.rightButtonPressed)
3570+ if (mouse.rightButtonPressed)
35673571 {
35683572 modEntry->currOrder = 0;
35693573 editor.currPatternDisp = &modEntry->head.order[modEntry->currOrder];
@@ -3588,7 +3592,7 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 18 unmodified lines
35883592 {
35893593 if (editor.currMode == MODE_IDLE || editor.currMode == MODE_EDIT)
35903594 {
3591− if (input.mouse.rightButtonPressed)
3595+ if (mouse.rightButtonPressed)
35923596 {
35933597 modEntry->head.order[modEntry->currOrder] = 0;
35943598
@@ -3615,7 +3619,7 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 20 unmodified lines
36153619 {
36163620 if (editor.currMode == MODE_IDLE || editor.currMode == MODE_EDIT)
36173621 {
3618− if (input.mouse.rightButtonPressed)
3622+ if (mouse.rightButtonPressed)
36193623 {
36203624 modEntry->head.orderCount = 1;
36213625
@@ -3674,7 +3678,7 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 52 unmodified lines
36743678
36753679 case PTB_SVOLUMES:
36763680 {
3677− if (input.mouse.rightButtonPressed)
3681+ if (mouse.rightButtonPressed)
36783682 {
36793683 modEntry->samples[editor.currSample].volume = 0;
36803684 }
@@ -3693,7 +3697,7 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 12 unmodified lines
36933697
36943698 case PTB_SLENGTHS:
36953699 {
3696− if (input.mouse.rightButtonPressed)
3700+ if (mouse.rightButtonPressed)
36973701 {
36983702 s = &modEntry->samples[editor.currSample];
36993703
@@ -3730,7 +3734,7 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 30 unmodified lines
37303734
37313735 case PTB_SREPEATS:
37323736 {
3733− if (input.mouse.rightButtonPressed)
3737+ if (mouse.rightButtonPressed)
37343738 {
37353739 s = &modEntry->samples[editor.currSample];
37363740
@@ -3770,7 +3774,7 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 33 unmodified lines
37703774
37713775 case PTB_SREPLENS:
37723776 {
3773− if (input.mouse.rightButtonPressed)
3777+ if (mouse.rightButtonPressed)
37743778 {
37753779 s = &modEntry->samples[editor.currSample];
37763780
@@ -3813,12 +3817,17 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 36 unmodified lines
38133817
38143818 case PTB_EDITOP:
38153819 {
3816− if (editor.ui.editOpScreen == 3) // chord screen
3817− editor.ui.editOpScreen = 0;
3818− else if (editor.ui.editOpScreenShown)
3819− editor.ui.editOpScreen = (editor.ui.editOpScreen + 1) % 3;
3820+ if (editor.ui.editOpScreenShown)
3821+ {
3822+ if (editor.ui.editOpScreen == 3)
3823+ editor.ui.editOpScreen = 0;
3824+ else
3825+ editor.ui.editOpScreen = (editor.ui.editOpScreen + 1) % 3;
3826+ }
38203827 else
3828+ {
38213829 editor.ui.editOpScreenShown = true;
3830+ }
38223831
38233832 renderEditOpScreen();
38243833 }
@@ -3927,7 +3936,7 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 102 unmodified lines
39273936
39283937 case PTB_SA_ZOOMBARAREA:
39293938 {
3930− input.mouse.lastGUIButton = button;
3939+ mouse.lastGUIButton = button;
39313940 if (!editor.ui.forceSampleDrag)
39323941 {
39333942 samplerBarPressed(MOUSE_BUTTON_NOT_HELD);
@@ -4083,7 +4092,7 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 149 unmodified lines
40834092
40844093 case PTB_DO_DATAPATH:
40854094 {
4086− if (input.mouse.rightButtonPressed)
4095+ if (mouse.rightButtonPressed)
40874096 {
40884097 memset(editor.currPath, 0, PATH_MAX + 1);
40894098 editor.ui.updateDiskOpPathText = true;
@@ -4101,7 +4110,7 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 11 unmodified lines
41014110
41024111 case PTB_SONGNAME:
41034112 {
4104− if (input.mouse.rightButtonPressed)
4113+ if (mouse.rightButtonPressed)
41054114 {
41064115 memset(modEntry->head.moduleTitle, 0, sizeof (modEntry->head.moduleTitle));
41074116 editor.ui.updateSongName = true;
@@ -4122,7 +4131,7 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 14 unmodified lines
41224131
41234132 case PTB_SAMPLENAME:
41244133 {
4125− if (input.mouse.rightButtonPressed)
4134+ if (mouse.rightButtonPressed)
41264135 {
41274136 memset(modEntry->samples[editor.currSample].text, 0, sizeof (modEntry->samples[editor.currSample].text));
41284137 editor.ui.updateCurrSampleName = true;
@@ -4186,7 +4195,7 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 57 unmodified lines
41864195 {
41874196 editor.ui.aboutScreenShown = false;
41884197 }
4189− else if (!input.mouse.rightButtonPressed)
4198+ else if (!mouse.rightButtonPressed)
41904199 {
41914200 editor.ui.visualizerMode = (editor.ui.visualizerMode + 1) % 2;
41924201 if (editor.ui.visualizerMode == VISUAL_SPECTRUM)
@@ -4212,7 +4221,7 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 19 unmodified lines
42124221
42134222 case PTB_CHAN1:
42144223 {
4215− if (input.mouse.rightButtonPressed)
4224+ if (mouse.rightButtonPressed)
42164225 {
42174226 editor.muted[0] = false;
42184227 editor.muted[1] = true;
@@ -4230,7 +4239,7 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 11 unmodified lines
42304239
42314240 case PTB_CHAN2:
42324241 {
4233− if (input.mouse.rightButtonPressed)
4242+ if (mouse.rightButtonPressed)
42344243 {
42354244 editor.muted[0] = true;
42364245 editor.muted[1] = false;
@@ -4248,7 +4257,7 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 11 unmodified lines
42484257
42494258 case PTB_CHAN3:
42504259 {
4251− if (input.mouse.rightButtonPressed)
4260+ if (mouse.rightButtonPressed)
42524261 {
42534262 editor.muted[0] = true;
42544263 editor.muted[1] = true;
@@ -4266,7 +4275,7 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 11 unmodified lines
42664275
42674276 case PTB_CHAN4:
42684277 {
4269− if (input.mouse.rightButtonPressed)
4278+ if (mouse.rightButtonPressed)
42704279 {
42714280 editor.muted[0] = true;
42724281 editor.muted[1] = true;
@@ -4285,7 +4294,7 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 12 unmodified lines
42854294 case PTB_SAMPLER: samplerScreen(); break;
42864295 case PTB_SA_EXIT: exitFromSam(); break;
42874296
4288− case PTB_DO_FILEAREA: diskOpLoadFile((input.mouse.y - 34) / 6, true); break;
4297+ case PTB_DO_FILEAREA: diskOpLoadFile((mouse.y - 34) / 6, true); break;
42894298 case PTB_DO_PARENT:
42904299 {
42914300 #ifdef _WIN32
@@ -4366,7 +4375,7 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 74 unmodified lines
43664375 {
43674376 editor.playMode = PLAY_MODE_NORMAL;
43684377
4369− if (input.mouse.rightButtonPressed)
4378+ if (mouse.rightButtonPressed)
43704379 modPlay(DONT_SET_PATTERN, modEntry->currOrder, modEntry->currRow);
43714380 else
43724381 modPlay(DONT_SET_PATTERN, modEntry->currOrder, DONT_SET_ROW);
@@ -4381,7 +4390,7 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 8 unmodified lines
43814390 {
43824391 editor.playMode = PLAY_MODE_PATTERN;
43834392
4384− if (input.mouse.rightButtonPressed)
4393+ if (mouse.rightButtonPressed)
43854394 modPlay(modEntry->currPattern, DONT_SET_ORDER, modEntry->currRow);
43864395 else
43874396 modPlay(modEntry->currPattern, DONT_SET_ORDER, DONT_SET_ROW);
@@ -4411,7 +4420,7 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 23 unmodified lines
44114420 {
44124421 editor.playMode = PLAY_MODE_PATTERN;
44134422
4414− if (input.mouse.rightButtonPressed)
4423+ if (mouse.rightButtonPressed)
44154424 modPlay(modEntry->currPattern, DONT_SET_ORDER, modEntry->currRow);
44164425 else
44174426 modPlay(modEntry->currPattern, DONT_SET_ORDER, DONT_SET_ROW);
@@ -4486,7 +4495,7 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 68 unmodified lines
44864495
44874496 case PTB_SAMPLEU:
44884497 {
4489− if (input.mouse.rightButtonPressed)
4498+ if (mouse.rightButtonPressed)
44904499 {
44914500 editor.sampleZero = true;
44924501 editor.ui.updateCurrSampleNum = true;
@@ -4500,7 +4509,7 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 7 unmodified lines
45004509
45014510 case PTB_SAMPLED:
45024511 {
4503− if (input.mouse.rightButtonPressed)
4512+ if (mouse.rightButtonPressed)
45044513 {
45054514 editor.sampleZero = true;
45064515 editor.ui.updateCurrSampleNum = true;
@@ -4658,20 +4667,20 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 151 unmodified lines
46584667 default: displayErrorMsg("NOT IMPLEMENTED"); return false; // button not mapped
46594668 }
46604669
4661− input.mouse.lastGUIButton = button;
4670+ mouse.lastGUIButton = button;
46624671 return false;
46634672 }
46644673
46654674 static void handleRepeatedGUIButtons(void)
46664675 {
46674676 // repeat button
4668− switch (input.mouse.lastGUIButton)
4677+ switch (mouse.lastGUIButton)
46694678 {
46704679 case PTB_EO_NOTE1_UP:
46714680 {
4672− if (input.mouse.repeatCounter >= 4)
4681+ if (mouse.repeatCounter >= 4)
46734682 {
4674− input.mouse.repeatCounter = 0;
4683+ mouse.repeatCounter = 0;
46754684 edNote1UpButton();
46764685 }
46774686 }
@@ -4679,9 +4688,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
46794688
46804689 case PTB_EO_NOTE1_DOWN:
46814690 {
4682− if (input.mouse.repeatCounter >= 4)
4691+ if (mouse.repeatCounter >= 4)
46834692 {
4684− input.mouse.repeatCounter = 0;
4693+ mouse.repeatCounter = 0;
46854694 edNote1DownButton();
46864695 }
46874696 }
@@ -4689,9 +4698,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
46894698
46904699 case PTB_EO_NOTE2_UP:
46914700 {
4692− if (input.mouse.repeatCounter >= 4)
4701+ if (mouse.repeatCounter >= 4)
46934702 {
4694− input.mouse.repeatCounter = 0;
4703+ mouse.repeatCounter = 0;
46954704 edNote2UpButton();
46964705 }
46974706 }
@@ -4699,9 +4708,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
46994708
47004709 case PTB_EO_NOTE2_DOWN:
47014710 {
4702− if (input.mouse.repeatCounter >= 4)
4711+ if (mouse.repeatCounter >= 4)
47034712 {
4704− input.mouse.repeatCounter = 0;
4713+ mouse.repeatCounter = 0;
47054714 edNote2DownButton();
47064715 }
47074716 }
@@ -4709,9 +4718,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
47094718
47104719 case PTB_EO_NOTE3_UP:
47114720 {
4712− if (input.mouse.repeatCounter >= 4)
4721+ if (mouse.repeatCounter >= 4)
47134722 {
4714− input.mouse.repeatCounter = 0;
4723+ mouse.repeatCounter = 0;
47154724 edNote3UpButton();
47164725 }
47174726 }
@@ -4719,9 +4728,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
47194728
47204729 case PTB_EO_NOTE3_DOWN:
47214730 {
4722− if (input.mouse.repeatCounter >= 4)
4731+ if (mouse.repeatCounter >= 4)
47234732 {
4724− input.mouse.repeatCounter = 0;
4733+ mouse.repeatCounter = 0;
47254734 edNote3DownButton();
47264735 }
47274736 }
@@ -4729,9 +4738,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
47294738
47304739 case PTB_EO_NOTE4_UP:
47314740 {
4732− if (input.mouse.repeatCounter >= 4)
4741+ if (mouse.repeatCounter >= 4)
47334742 {
4734− input.mouse.repeatCounter = 0;
4743+ mouse.repeatCounter = 0;
47354744 edNote4UpButton();
47364745 }
47374746 }
@@ -4739,9 +4748,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
47394748
47404749 case PTB_EO_NOTE4_DOWN:
47414750 {
4742− if (input.mouse.repeatCounter >= 4)
4751+ if (mouse.repeatCounter >= 4)
47434752 {
4744− input.mouse.repeatCounter = 0;
4753+ mouse.repeatCounter = 0;
47454754 edNote4DownButton();
47464755 }
47474756 }
@@ -4749,9 +4758,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
47494758
47504759 case PTB_EO_VOL_UP:
47514760 {
4752− if (input.mouse.repeatCounter >= 2)
4761+ if (mouse.repeatCounter >= 2)
47534762 {
4754− input.mouse.repeatCounter = 0;
4763+ mouse.repeatCounter = 0;
47554764 edVolUpButton();
47564765 }
47574766 }
@@ -4759,9 +4768,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
47594768
47604769 case PTB_EO_VOL_DOWN:
47614770 {
4762− if (input.mouse.repeatCounter >= 2)
4771+ if (mouse.repeatCounter >= 2)
47634772 {
4764− input.mouse.repeatCounter = 0;
4773+ mouse.repeatCounter = 0;
47654774 edVolDownButton();
47664775 }
47674776 }
@@ -4769,9 +4778,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
47694778
47704779 case PTB_EO_MOD_UP:
47714780 {
4772− if (input.mouse.repeatCounter >= 2)
4781+ if (mouse.repeatCounter >= 2)
47734782 {
4774− input.mouse.repeatCounter = 0;
4783+ mouse.repeatCounter = 0;
47754784 edModUpButton();
47764785 }
47774786 }
@@ -4779,9 +4788,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
47794788
47804789 case PTB_EO_MOD_DOWN:
47814790 {
4782− if (input.mouse.repeatCounter >= 2)
4791+ if (mouse.repeatCounter >= 2)
47834792 {
4784− input.mouse.repeatCounter = 0;
4793+ mouse.repeatCounter = 0;
47854794 edModDownButton();
47864795 }
47874796 }
@@ -4789,9 +4798,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
47894798
47904799 case PTB_EO_POS_UP:
47914800 {
4792− if (input.mouse.repeatCounter >= 1)
4801+ if (mouse.repeatCounter >= 1)
47934802 {
4794− input.mouse.repeatCounter = 0;
4803+ mouse.repeatCounter = 0;
47954804 edPosUpButton(INCREMENT_FAST);
47964805 }
47974806 }
@@ -4799,9 +4808,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
47994808
48004809 case PTB_EO_POS_DOWN:
48014810 {
4802− if (input.mouse.repeatCounter >= 1)
4811+ if (mouse.repeatCounter >= 1)
48034812 {
4804− input.mouse.repeatCounter = 0;
4813+ mouse.repeatCounter = 0;
48054814 edPosDownButton(INCREMENT_FAST);
48064815 }
48074816 }
@@ -4809,9 +4818,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
48094818
48104819 case PTB_EO_FROM_UP:
48114820 {
4812− if (input.mouse.repeatCounter >= 2)
4821+ if (mouse.repeatCounter >= 2)
48134822 {
4814− input.mouse.repeatCounter = 0;
4823+ mouse.repeatCounter = 0;
48154824 if (editor.sampleFrom < 0x1F)
48164825 {
48174826 editor.sampleFrom++;
@@ -4823,9 +4832,9 @@ static void handleRepeatedGUIButtons(void) · 5 unmodified lines
48234832
48244833 case PTB_EO_FROM_DOWN:
48254834 {
4826− if (input.mouse.repeatCounter >= 2)
4835+ if (mouse.repeatCounter >= 2)
48274836 {
4828− input.mouse.repeatCounter = 0;
4837+ mouse.repeatCounter = 0;
48294838 if (editor.sampleFrom > 0x00)
48304839 {
48314840 editor.sampleFrom--;
@@ -4837,9 +4846,9 @@ static void handleRepeatedGUIButtons(void) · 5 unmodified lines
48374846
48384847 case PTB_EO_TO_UP:
48394848 {
4840− if (input.mouse.repeatCounter >= 2)
4849+ if (mouse.repeatCounter >= 2)
48414850 {
4842− input.mouse.repeatCounter = 0;
4851+ mouse.repeatCounter = 0;
48434852 if (editor.sampleTo < 0x1F)
48444853 {
48454854 editor.sampleTo++;
@@ -4851,9 +4860,9 @@ static void handleRepeatedGUIButtons(void) · 5 unmodified lines
48514860
48524861 case PTB_EO_TO_DOWN:
48534862 {
4854− if (input.mouse.repeatCounter >= 2)
4863+ if (mouse.repeatCounter >= 2)
48554864 {
4856− input.mouse.repeatCounter = 0;
4865+ mouse.repeatCounter = 0;
48574866 if (editor.sampleTo > 0x00)
48584867 {
48594868 editor.sampleTo--;
@@ -4865,10 +4874,10 @@ static void handleRepeatedGUIButtons(void) · 5 unmodified lines
48654874
48664875 case PTB_SAMPLEU:
48674876 {
4868− if (input.mouse.repeatCounter >= 5)
4877+ if (mouse.repeatCounter >= 5)
48694878 {
4870− input.mouse.repeatCounter = 0;
4871− if (!input.mouse.rightButtonPressed)
4879+ mouse.repeatCounter = 0;
4880+ if (!mouse.rightButtonPressed)
48724881 sampleUpButton();
48734882 else
48744883 editor.ui.updateCurrSampleNum = true;
@@ -4878,10 +4887,10 @@ static void handleRepeatedGUIButtons(void) · 3 unmodified lines
48784887
48794888 case PTB_SAMPLED:
48804889 {
4881− if (input.mouse.repeatCounter >= 5)
4890+ if (mouse.repeatCounter >= 5)
48824891 {
4883− input.mouse.repeatCounter = 0;
4884− if (!input.mouse.rightButtonPressed)
4892+ mouse.repeatCounter = 0;
4893+ if (!mouse.rightButtonPressed)
48854894 sampleDownButton();
48864895 else
48874896 editor.ui.updateCurrSampleNum = true;
@@ -4891,9 +4900,9 @@ static void handleRepeatedGUIButtons(void) · 3 unmodified lines
48914900
48924901 case PTB_FTUNEU:
48934902 {
4894− if (input.mouse.repeatCounter >= 5)
4903+ if (mouse.repeatCounter >= 5)
48954904 {
4896− input.mouse.repeatCounter = 0;
4905+ mouse.repeatCounter = 0;
48974906 sampleFineTuneUpButton();
48984907 }
48994908 }
@@ -4901,9 +4910,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
49014910
49024911 case PTB_FTUNED:
49034912 {
4904− if (input.mouse.repeatCounter >= 5)
4913+ if (mouse.repeatCounter >= 5)
49054914 {
4906− input.mouse.repeatCounter = 0;
4915+ mouse.repeatCounter = 0;
49074916 sampleFineTuneDownButton();
49084917 }
49094918 }
@@ -4911,9 +4920,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
49114920
49124921 case PTB_SVOLUMEU:
49134922 {
4914− if (input.mouse.repeatCounter >= 5)
4923+ if (mouse.repeatCounter >= 5)
49154924 {
4916− input.mouse.repeatCounter = 0;
4925+ mouse.repeatCounter = 0;
49174926 sampleVolumeUpButton();
49184927 }
49194928 }
@@ -4921,9 +4930,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
49214930
49224931 case PTB_SVOLUMED:
49234932 {
4924− if (input.mouse.repeatCounter >= 5)
4933+ if (mouse.repeatCounter >= 5)
49254934 {
4926− input.mouse.repeatCounter = 0;
4935+ mouse.repeatCounter = 0;
49274936 sampleVolumeDownButton();
49284937 }
49294938 }
@@ -4931,9 +4940,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
49314940
49324941 case PTB_SLENGTHU:
49334942 {
4934− if (input.mouse.rightButtonPressed || input.mouse.repeatCounter >= 1)
4943+ if (mouse.rightButtonPressed || mouse.repeatCounter >= 1)
49354944 {
4936− input.mouse.repeatCounter = 0;
4945+ mouse.repeatCounter = 0;
49374946 sampleLengthUpButton(INCREMENT_FAST);
49384947 }
49394948 }
@@ -4941,9 +4950,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
49414950
49424951 case PTB_SLENGTHD:
49434952 {
4944− if (input.mouse.rightButtonPressed || input.mouse.repeatCounter >= 1)
4953+ if (mouse.rightButtonPressed || mouse.repeatCounter >= 1)
49454954 {
4946− input.mouse.repeatCounter = 0;
4955+ mouse.repeatCounter = 0;
49474956 sampleLengthDownButton(INCREMENT_FAST);
49484957 }
49494958 }
@@ -4951,9 +4960,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
49514960
49524961 case PTB_SREPEATU:
49534962 {
4954− if (input.mouse.rightButtonPressed || input.mouse.repeatCounter >= 1)
4963+ if (mouse.rightButtonPressed || mouse.repeatCounter >= 1)
49554964 {
4956− input.mouse.repeatCounter = 0;
4965+ mouse.repeatCounter = 0;
49574966 sampleRepeatUpButton(INCREMENT_FAST);
49584967 }
49594968 }
@@ -4961,9 +4970,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
49614970
49624971 case PTB_SREPEATD:
49634972 {
4964− if (input.mouse.rightButtonPressed || input.mouse.repeatCounter >= 1)
4973+ if (mouse.rightButtonPressed || mouse.repeatCounter >= 1)
49654974 {
4966− input.mouse.repeatCounter = 0;
4975+ mouse.repeatCounter = 0;
49674976 sampleRepeatDownButton(INCREMENT_FAST);
49684977 }
49694978 }
@@ -4971,9 +4980,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
49714980
49724981 case PTB_SREPLENU:
49734982 {
4974− if (input.mouse.rightButtonPressed || input.mouse.repeatCounter >= 1)
4983+ if (mouse.rightButtonPressed || mouse.repeatCounter >= 1)
49754984 {
4976− input.mouse.repeatCounter = 0;
4985+ mouse.repeatCounter = 0;
49774986 sampleRepeatLengthUpButton(INCREMENT_FAST);
49784987 }
49794988 }
@@ -4981,9 +4990,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
49814990
49824991 case PTB_SREPLEND:
49834992 {
4984− if (input.mouse.rightButtonPressed || input.mouse.repeatCounter >= 1)
4993+ if (mouse.rightButtonPressed || mouse.repeatCounter >= 1)
49854994 {
4986− input.mouse.repeatCounter = 0;
4995+ mouse.repeatCounter = 0;
49874996 sampleRepeatLengthDownButton(INCREMENT_FAST);
49884997 }
49894998 }
@@ -4991,9 +5000,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
49915000
49925001 case PTB_TEMPOU:
49935002 {
4994− if (input.mouse.repeatCounter >= 3)
5003+ if (mouse.repeatCounter >= 3)
49955004 {
4996− input.mouse.repeatCounter = 0;
5005+ mouse.repeatCounter = 0;
49975006 tempoUpButton();
49985007 }
49995008 }
@@ -5001,9 +5010,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
50015010
50025011 case PTB_TEMPOD:
50035012 {
5004− if (input.mouse.repeatCounter >= 3)
5013+ if (mouse.repeatCounter >= 3)
50055014 {
5006− input.mouse.repeatCounter = 0;
5015+ mouse.repeatCounter = 0;
50075016 tempoDownButton();
50085017 }
50095018 }
@@ -5011,9 +5020,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
50115020
50125021 case PTB_LENGTHU:
50135022 {
5014− if (input.mouse.repeatCounter >= 7)
5023+ if (mouse.repeatCounter >= 7)
50155024 {
5016− input.mouse.repeatCounter = 0;
5025+ mouse.repeatCounter = 0;
50175026 songLengthUpButton();
50185027 }
50195028 }
@@ -5021,9 +5030,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
50215030
50225031 case PTB_LENGTHD:
50235032 {
5024− if (input.mouse.repeatCounter >= 7)
5033+ if (mouse.repeatCounter >= 7)
50255034 {
5026− input.mouse.repeatCounter = 0;
5035+ mouse.repeatCounter = 0;
50275036 songLengthDownButton();
50285037 }
50295038 }
@@ -5031,9 +5040,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
50315040
50325041 case PTB_PATTERNU:
50335042 {
5034− if (input.mouse.repeatCounter >= 7)
5043+ if (mouse.repeatCounter >= 7)
50355044 {
5036− input.mouse.repeatCounter = 0;
5045+ mouse.repeatCounter = 0;
50375046 patternUpButton();
50385047 }
50395048 }
@@ -5041,9 +5050,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
50415050
50425051 case PTB_PATTERND:
50435052 {
5044− if (input.mouse.repeatCounter >= 7)
5053+ if (mouse.repeatCounter >= 7)
50455054 {
5046− input.mouse.repeatCounter = 0;
5055+ mouse.repeatCounter = 0;
50475056 patternDownButton();
50485057 }
50495058 }
@@ -5051,9 +5060,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
50515060
50525061 case PTB_POSU:
50535062 {
5054− if (input.mouse.repeatCounter >= 7)
5063+ if (mouse.repeatCounter >= 7)
50555064 {
5056− input.mouse.repeatCounter = 0;
5065+ mouse.repeatCounter = 0;
50575066 positionUpButton();
50585067 }
50595068 }
@@ -5061,9 +5070,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
50615070
50625071 case PTB_POSD:
50635072 {
5064− if (input.mouse.repeatCounter >= 7)
5073+ if (mouse.repeatCounter >= 7)
50655074 {
5066− input.mouse.repeatCounter = 0;
5075+ mouse.repeatCounter = 0;
50675076 positionDownButton();
50685077 }
50695078 }
@@ -5071,9 +5080,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
50715080
50725081 case PTB_PE_SCROLLUP:
50735082 {
5074− if (input.mouse.repeatCounter >= 2)
5083+ if (mouse.repeatCounter >= 2)
50755084 {
5076− input.mouse.repeatCounter = 0;
5085+ mouse.repeatCounter = 0;
50775086 if (modEntry->currOrder > 0)
50785087 modSetPos(modEntry->currOrder - 1, DONT_SET_ROW);
50795088 }
@@ -5082,9 +5091,9 @@ static void handleRepeatedGUIButtons(void) · 2 unmodified lines
50825091
50835092 case PTB_PE_SCROLLDOWN:
50845093 {
5085− if (input.mouse.repeatCounter >= 2)
5094+ if (mouse.repeatCounter >= 2)
50865095 {
5087− input.mouse.repeatCounter = 0;
5096+ mouse.repeatCounter = 0;
50885097 if (modEntry->currOrder < modEntry->head.orderCount-1)
50895098 modSetPos(modEntry->currOrder + 1, DONT_SET_ROW);
50905099 }
@@ -5093,12 +5102,12 @@ static void handleRepeatedGUIButtons(void) · 2 unmodified lines
50935102
50945103 case PTB_DO_SCROLLUP:
50955104 {
5096− if (input.mouse.repeatCounter >= 1)
5105+ if (mouse.repeatCounter >= 1)
50975106 {
5098− input.mouse.repeatCounter = 0;
5107+ mouse.repeatCounter = 0;
50995108
51005109 editor.diskop.scrollOffset--;
5101− if (input.mouse.rightButtonPressed)
5110+ if (mouse.rightButtonPressed)
51025111 editor.diskop.scrollOffset -= 3;
51035112
51045113 if (editor.diskop.scrollOffset < 0)
@@ -5111,14 +5120,14 @@ static void handleRepeatedGUIButtons(void) · 6 unmodified lines
51115120
51125121 case PTB_DO_SCROLLDOWN:
51135122 {
5114− if (input.mouse.repeatCounter >= 1)
5123+ if (mouse.repeatCounter >= 1)
51155124 {
5116− input.mouse.repeatCounter = 0;
5125+ mouse.repeatCounter = 0;
51175126
51185127 if (editor.diskop.numEntries > DISKOP_LINES)
51195128 {
51205129 editor.diskop.scrollOffset++;
5121− if (input.mouse.rightButtonPressed)
5130+ if (mouse.rightButtonPressed)
51225131 editor.diskop.scrollOffset += 3;
51235132
51245133 if (editor.diskop.scrollOffset > editor.diskop.numEntries-DISKOP_LINES)
@@ -5132,9 +5141,9 @@ static void handleRepeatedGUIButtons(void) · 7 unmodified lines
51325141
51335142 case PTB_SA_ZOOMBARAREA:
51345143 {
5135− if (input.mouse.repeatCounter >= 4)
5144+ if (mouse.repeatCounter >= 4)
51365145 {
5137− input.mouse.repeatCounter = 0;
5146+ mouse.repeatCounter = 0;
51385147 if (!editor.ui.forceSampleDrag)
51395148 samplerBarPressed(MOUSE_BUTTON_NOT_HELD);
51405149 }
src/pt2_palette.c+17−24
@@ -1,28 +1,21 @@
1−#include <stdint.h>
21 #include "pt2_palette.h"
32 #include "pt2_header.h"
4−#include "pt2_helpers.h"
5−#include "pt2_tables.h"
63
7−uint32_t palette[PALETTE_NUM] =
4+void setDefaultPalette(void)
85 {
9− // -----------------------------
10− 0x000000, // 00- PAL_BACKGRD
11− 0xBBBBBB, // 01- PAL_BORDER
12− 0x888888, // 02- PAL_GENBKG
13− 0x555555, // 03- PAL_GENBKG2
14− 0xFFDD00, // 04- PAL_QADSCP
15− 0xDD0044, // 05- PAL_PATCURSOR
16− 0x000000, // 06- PAL_GENTXT
17− 0x3344FF, // 07- PAL_PATTXT
18− // -----------------------------
19− 0x00FFFF, // 08- PAL_SAMPLLINE
20− 0x0000FF, // 09- PAL_LOOPPIN
21− 0x770077, // 10- PAL_TEXTMARK
22− 0x444444, // 11- PAL_MOUSE_1
23− 0x777777, // 12- PAL_MOUSE_2
24− 0xAAAAAA, // 13- PAL_MOUSE_3
25− // -----------------------------
26− 0xC0FFEE // 14- PAL_COLORKEY
27− // -----------------------------
28−};
6+ video.palette[PAL_BACKGRD] = 0x000000;
7+ video.palette[PAL_BORDER] = 0xBBBBBB;
8+ video.palette[PAL_GENBKG] = 0x888888;
9+ video.palette[PAL_GENBKG2] = 0x555555;
10+ video.palette[PAL_QADSCP] = 0xFFDD00;
11+ video.palette[PAL_PATCURSOR] = 0xDD0044;
12+ video.palette[PAL_GENTXT] = 0x000000;
13+ video.palette[PAL_PATTXT] = 0x3344FF;
14+ video.palette[PAL_SAMPLLINE] = 0x00FFFF;
15+ video.palette[PAL_LOOPPIN] = 0x0000FF;
16+ video.palette[PAL_TEXTMARK] = 0x770077;
17+ video.palette[PAL_MOUSE_1] = 0x444444;
18+ video.palette[PAL_MOUSE_2] = 0x777777;
19+ video.palette[PAL_MOUSE_3] = 0xAAAAAA;
20+ video.palette[PAL_COLORKEY] = 0xC0FFEE;
21+}
src/pt2_palette.h+2−3
@@ -1,8 +1,5 @@
11 #pragma once
22
3−#include <stdint.h>
4−#include <stdbool.h>
5−
63 enum
74 {
85 // -----------------------------
@@ -26,3 +23,5 @@ enum · 17 unmodified lines
2623 // -----------------------------
2724 PALETTE_NUM
2825 };
26+
27+void setDefaultPalette(void);
src/pt2_patternviewer.c+74−74
@@ -33,11 +33,11 @@ static uint8_t periodToNote(int16_t period) · 32 unmodified lines
3333 return 255; // illegal period
3434 }
3535
36−void drawPatternNormal(uint32_t *frameBuffer)
36+static void drawPatternNormal(void)
3737 {
3838 int8_t rowMiddlePos;
3939 uint8_t j, h, tempNote, rowDispCheck;
40− uint16_t putXOffset, putYOffset, rowData;
40+ uint16_t x, y, rowData;
4141 const uint32_t *srcPtr;
4242 uint32_t bufferOffset, *dstPtr;
4343 note_t note;
@@ -50,93 +50,93 @@ void drawPatternNormal(uint32_t *frameBuffer) · 6 unmodified lines
5050 if (rowDispCheck < MOD_ROWS)
5151 {
5252 rowData = rowDispCheck * 4;
53− putYOffset = 140 + (i * 7);
53+ y = 140 + (i * 7);
5454
5555 if (i == 7) // are we on the play row (middle)?
5656 {
57− putYOffset++; // align font to play row (middle)
57+ y++; // align font to play row (middle)
5858
5959 // put current row number
60− printTwoDecimalsBigBg(frameBuffer, 8, putYOffset, rowMiddlePos + modEntry->currRow, palette[PAL_GENTXT], palette[PAL_GENBKG]);
60+ printTwoDecimalsBigBg(8, y, rowMiddlePos + modEntry->currRow, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
6161
6262 // pattern data
6363 for (j = 0; j < AMIGA_VOICES; j++)
6464 {
6565 note = modEntry->patterns[modEntry->currPattern][rowData + j];
66− putXOffset = 26 + (j * 72);
66+ x = 26 + (j * 72);
6767
6868 if (note.period == 0)
6969 {
70− textOutBigBg(frameBuffer, putXOffset + 6, putYOffset, "---", palette[PAL_GENTXT], palette[PAL_GENBKG]);
70+ textOutBigBg(x + 6, y, "---", video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
7171 }
7272 else
7373 {
7474 tempNote = periodToNote(note.period);
7575 if (tempNote == 255)
76− textOutBigBg(frameBuffer, putXOffset + 6, putYOffset, "???", palette[PAL_GENTXT], palette[PAL_GENBKG]);
76+ textOutBigBg(x + 6, y, "???", video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
7777 else
78− textOutBigBg(frameBuffer, putXOffset + 6, putYOffset, ptConfig.accidental ? noteNames2[tempNote] : noteNames1[tempNote], palette[PAL_GENTXT], palette[PAL_GENBKG]);
78+ textOutBigBg(x + 6, y, config.accidental ? noteNames2[tempNote] : noteNames1[tempNote], video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
7979 }
8080
81− if (ptConfig.blankZeroFlag)
81+ if (config.blankZeroFlag)
8282 {
8383 if (note.sample & 0xF0)
84− printOneHexBigBg(frameBuffer, putXOffset + 30, putYOffset, note.sample >> 4, palette[PAL_GENTXT], palette[PAL_GENBKG]);
84+ printOneHexBigBg(x + 30, y, note.sample >> 4, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
8585 else
86− printOneHexBigBg(frameBuffer, putXOffset + 30, putYOffset, ' ', palette[PAL_GENBKG], palette[PAL_GENBKG]);
86+ printOneHexBigBg(x + 30, y, ' ', video.palette[PAL_GENBKG], video.palette[PAL_GENBKG]);
8787 }
8888 else
8989 {
90− printOneHexBigBg(frameBuffer, putXOffset + 30, putYOffset, note.sample >> 4, palette[PAL_GENTXT], palette[PAL_GENBKG]);
90+ printOneHexBigBg(x + 30, y, note.sample >> 4, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
9191 }
9292
93− printOneHexBigBg(frameBuffer, putXOffset + 38, putYOffset, note.sample & 0x0F, palette[PAL_GENTXT], palette[PAL_GENBKG]);
94− printOneHexBigBg(frameBuffer, putXOffset + 46, putYOffset, note.command, palette[PAL_GENTXT], palette[PAL_GENBKG]);
95− printTwoHexBigBg(frameBuffer, putXOffset + 54, putYOffset, note.param, palette[PAL_GENTXT], palette[PAL_GENBKG]);
93+ printOneHexBigBg(x + 38, y, note.sample & 0x0F, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
94+ printOneHexBigBg(x + 46, y, note.command, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
95+ printTwoHexBigBg(x + 54, y, note.param, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
9696 }
9797 }
9898 else
9999 {
100100 if (i > 7)
101− putYOffset += 7; // beyond play row, jump some pixels out of the row (middle)
101+ y += 7; // beyond play row, jump some pixels out of the row (middle)
102102
103103 // put current row number
104− printTwoDecimalsBg(frameBuffer, 8, putYOffset, rowMiddlePos + modEntry->currRow, palette[PAL_PATTXT], palette[PAL_BACKGRD]);
104+ printTwoDecimalsBg(8, y, rowMiddlePos + modEntry->currRow, video.palette[PAL_PATTXT], video.palette[PAL_BACKGRD]);
105105
106106 // pattern data
107107 for (j = 0; j < AMIGA_VOICES; j++)
108108 {
109109 note = modEntry->patterns[modEntry->currPattern][rowData + j];
110− putXOffset = 26 + (j * 72);
110+ x = 26 + (j * 72);
111111
112112 if (note.period == 0)
113113 {
114− textOutBg(frameBuffer, putXOffset + 6, putYOffset, "---", palette[PAL_PATTXT], palette[PAL_BACKGRD]);
114+ textOutBg(x + 6, y, "---", video.palette[PAL_PATTXT], video.palette[PAL_BACKGRD]);
115115 }
116116 else
117117 {
118118 tempNote = periodToNote(note.period);
119119 if (tempNote == 255)
120− textOutBg(frameBuffer, putXOffset + 6, putYOffset, "???", palette[PAL_PATTXT], palette[PAL_BACKGRD]);
120+ textOutBg(x + 6, y, "???", video.palette[PAL_PATTXT], video.palette[PAL_BACKGRD]);
121121 else
122− textOutBg(frameBuffer, putXOffset + 6, putYOffset, ptConfig.accidental ? noteNames2[tempNote] : noteNames1[tempNote], palette[PAL_PATTXT], palette[PAL_BACKGRD]);
122+ textOutBg(x + 6, y, config.accidental ? noteNames2[tempNote] : noteNames1[tempNote], video.palette[PAL_PATTXT], video.palette[PAL_BACKGRD]);
123123 }
124124
125− if (ptConfig.blankZeroFlag)
125+ if (config.blankZeroFlag)
126126 {
127127 if (note.sample & 0xF0)
128− printOneHexBg(frameBuffer, putXOffset + 30, putYOffset, note.sample >> 4, palette[PAL_PATTXT], palette[PAL_BACKGRD]);
128+ printOneHexBg(x + 30, y, note.sample >> 4, video.palette[PAL_PATTXT], video.palette[PAL_BACKGRD]);
129129 else
130− printOneHexBg(frameBuffer, putXOffset + 30, putYOffset, ' ', palette[PAL_BACKGRD], palette[PAL_BACKGRD]);
130+ printOneHexBg(x + 30, y, ' ', video.palette[PAL_BACKGRD], video.palette[PAL_BACKGRD]);
131131 }
132132 else
133133 {
134− printOneHexBg(frameBuffer, putXOffset + 30, putYOffset, note.sample >> 4, palette[PAL_PATTXT], palette[PAL_BACKGRD]);
134+ printOneHexBg(x + 30, y, note.sample >> 4, video.palette[PAL_PATTXT], video.palette[PAL_BACKGRD]);
135135 }
136136
137− printOneHexBg(frameBuffer, putXOffset + 38, putYOffset, note.sample & 0x0F, palette[PAL_PATTXT], palette[PAL_BACKGRD]);
138− printOneHexBg(frameBuffer, putXOffset + 46, putYOffset, note.command, palette[PAL_PATTXT], palette[PAL_BACKGRD]);
139− printTwoHexBg(frameBuffer, putXOffset + 54, putYOffset, note.param, palette[PAL_PATTXT], palette[PAL_BACKGRD]);
137+ printOneHexBg(x + 38, y, note.sample & 0x0F, video.palette[PAL_PATTXT], video.palette[PAL_BACKGRD]);
138+ printOneHexBg(x + 46, y, note.command, video.palette[PAL_PATTXT], video.palette[PAL_BACKGRD]);
139+ printTwoHexBg(x + 54, y, note.param, video.palette[PAL_PATTXT], video.palette[PAL_BACKGRD]);
140140 }
141141 }
142142 }
@@ -147,7 +147,7 @@ void drawPatternNormal(uint32_t *frameBuffer) · 4 unmodified lines
147147 if (modEntry->currRow <= 6)
148148 {
149149 srcPtr = &trackerFrameBMP[140 * SCREEN_W];
150− dstPtr = &frameBuffer[140 * SCREEN_W];
150+ dstPtr = &video.frameBuffer[140 * SCREEN_W];
151151 memcpy(dstPtr, srcPtr, (SCREEN_W * sizeof (int32_t)) * ((7 - modEntry->currRow) * 7));
152152 }
153153 else if (modEntry->currRow >= 57)
@@ -156,16 +156,16 @@ void drawPatternNormal(uint32_t *frameBuffer) · 2 unmodified lines
156156 bufferOffset = (250 - h) * SCREEN_W;
157157
158158 srcPtr = &trackerFrameBMP[bufferOffset];
159− dstPtr = &frameBuffer[bufferOffset];
159+ dstPtr = &video.frameBuffer[bufferOffset];
160160 memcpy(dstPtr, srcPtr, (SCREEN_W * sizeof (int32_t)) * h);
161161 }
162162 }
163163
164−void drawPatternDotted(uint32_t *frameBuffer)
164+static void drawPatternDotted(void)
165165 {
166166 int8_t rowMiddlePos;
167167 uint8_t j, h, tempNote, rowDispCheck;
168− uint16_t putXOffset, putYOffset, rowData;
168+ uint16_t x, y, rowData;
169169 const uint32_t *srcPtr;
170170 uint32_t bufferOffset, *dstPtr;
171171 note_t note;
@@ -178,110 +178,110 @@ void drawPatternDotted(uint32_t *frameBuffer) · 6 unmodified lines
178178 if (rowDispCheck < MOD_ROWS)
179179 {
180180 rowData = rowDispCheck * 4;
181− putYOffset = 140 + (i * 7);
181+ y = 140 + (i * 7);
182182
183183 if (i == 7) // are we on the play row (middle)?
184184 {
185− putYOffset++; // align font to play row (middle)
185+ y++; // align font to play row (middle)
186186
187187 // put current row number
188− printTwoDecimalsBigBg(frameBuffer, 8, putYOffset, rowMiddlePos + modEntry->currRow, palette[PAL_GENTXT], palette[PAL_GENBKG]);
188+ printTwoDecimalsBigBg(8, y, rowMiddlePos + modEntry->currRow, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
189189
190190 // pattern data
191191 for (j = 0; j < AMIGA_VOICES; j++)
192192 {
193193 note = modEntry->patterns[modEntry->currPattern][rowData + j];
194− putXOffset = 26 + (j * 72);
194+ x = 26 + (j * 72);
195195
196196 if (note.period == 0)
197197 {
198− charOutBigBg(frameBuffer, putXOffset + 6, putYOffset, -128, palette[PAL_GENTXT], palette[PAL_GENBKG]);
199− charOutBigBg(frameBuffer, putXOffset + 14, putYOffset, -128, palette[PAL_GENTXT], palette[PAL_GENBKG]);
200− charOutBigBg(frameBuffer, putXOffset + 22, putYOffset, -128, palette[PAL_GENTXT], palette[PAL_GENBKG]);
198+ charOutBigBg(x + 6, y, -128, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
199+ charOutBigBg(x + 14, y, -128, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
200+ charOutBigBg(x + 22, y, -128, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
201201 }
202202 else
203203 {
204204 tempNote = periodToNote(note.period);
205205 if (tempNote == 255)
206− textOutBigBg(frameBuffer, putXOffset + 6, putYOffset, "???", palette[PAL_GENTXT], palette[PAL_GENBKG]);
206+ textOutBigBg(x + 6, y, "???", video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
207207 else
208− textOutBigBg(frameBuffer, putXOffset + 6, putYOffset, ptConfig.accidental ? noteNames2[tempNote] : noteNames1[tempNote], palette[PAL_GENTXT], palette[PAL_GENBKG]);
208+ textOutBigBg(x + 6, y, config.accidental ? noteNames2[tempNote] : noteNames1[tempNote], video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
209209 }
210210
211211 if (note.sample)
212212 {
213− printOneHexBigBg(frameBuffer, putXOffset + 30, putYOffset, note.sample >> 4, palette[PAL_GENTXT], palette[PAL_GENBKG]);
214− printOneHexBigBg(frameBuffer, putXOffset + 38, putYOffset, note.sample & 0x0F, palette[PAL_GENTXT], palette[PAL_GENBKG]);
213+ printOneHexBigBg(x + 30, y, note.sample >> 4, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
214+ printOneHexBigBg(x + 38, y, note.sample & 0x0F, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
215215 }
216216 else
217217 {
218− charOutBigBg(frameBuffer, putXOffset + 30, putYOffset, -128, palette[PAL_GENTXT], palette[PAL_GENBKG]);
219− charOutBigBg(frameBuffer, putXOffset + 38, putYOffset, -128, palette[PAL_GENTXT], palette[PAL_GENBKG]);
218+ charOutBigBg(x + 30, y, -128, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
219+ charOutBigBg(x + 38, y, -128, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
220220 }
221221
222222 if ((note.command | note.param) == 0)
223223 {
224− charOutBigBg(frameBuffer, putXOffset + 46, putYOffset, -128, palette[PAL_GENTXT], palette[PAL_GENBKG]);
225− charOutBigBg(frameBuffer, putXOffset + 54, putYOffset, -128, palette[PAL_GENTXT], palette[PAL_GENBKG]);
226− charOutBigBg(frameBuffer, putXOffset + 62, putYOffset, -128, palette[PAL_GENTXT], palette[PAL_GENBKG]);
224+ charOutBigBg(x + 46, y, -128, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
225+ charOutBigBg(x + 54, y, -128, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
226+ charOutBigBg(x + 62, y, -128, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
227227 }
228228 else
229229 {
230− printOneHexBigBg(frameBuffer, putXOffset + 46, putYOffset, note.command, palette[PAL_GENTXT], palette[PAL_GENBKG]);
231− printTwoHexBigBg(frameBuffer, putXOffset + 54, putYOffset, note.param, palette[PAL_GENTXT], palette[PAL_GENBKG]);
230+ printOneHexBigBg(x + 46, y, note.command, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
231+ printTwoHexBigBg(x + 54, y, note.param, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
232232 }
233233 }
234234 }
235235 else
236236 {
237237 if (i > 7)
238− putYOffset += 7; // beyond play row, jump some pixels out of the row (middle)
238+ y += 7; // beyond play row, jump some pixels out of the row (middle)
239239
240240 // put current row number
241− printTwoDecimalsBg(frameBuffer, 8, putYOffset, rowMiddlePos + modEntry->currRow, palette[PAL_PATTXT], palette[PAL_BACKGRD]);
241+ printTwoDecimalsBg(8, y, rowMiddlePos + modEntry->currRow, video.palette[PAL_PATTXT], video.palette[PAL_BACKGRD]);
242242
243243 // pattern data
244244 for (j = 0; j < AMIGA_VOICES; j++)
245245 {
246246 note = modEntry->patterns[modEntry->currPattern][rowData + j];
247− putXOffset = 26 + (j * 72);
247+ x = 26 + (j * 72);
248248
249249 if (note.period == 0)
250250 {
251− charOutBg(frameBuffer, putXOffset + 6, putYOffset, -128, palette[PAL_PATTXT], palette[PAL_BACKGRD]);
252− charOutBg(frameBuffer, putXOffset + 14, putYOffset, -128, palette[PAL_PATTXT], palette[PAL_BACKGRD]);
253− charOutBg(frameBuffer, putXOffset + 22, putYOffset, -128, palette[PAL_PATTXT], palette[PAL_BACKGRD]);
251+ charOutBg(x + 6, y, -128, video.palette[PAL_PATTXT], video.palette[PAL_BACKGRD]);
252+ charOutBg(x + 14, y, -128, video.palette[PAL_PATTXT], video.palette[PAL_BACKGRD]);
253+ charOutBg(x + 22, y, -128, video.palette[PAL_PATTXT], video.palette[PAL_BACKGRD]);
254254 }
255255 else
256256 {
257257 tempNote = periodToNote(note.period);
258258 if (tempNote == 255)
259− textOutBg(frameBuffer, putXOffset + 6, putYOffset, "???", palette[PAL_PATTXT], palette[PAL_BACKGRD]);
259+ textOutBg(x + 6, y, "???", video.palette[PAL_PATTXT], video.palette[PAL_BACKGRD]);
260260 else
261− textOutBg(frameBuffer, putXOffset + 6, putYOffset, ptConfig.accidental ? noteNames2[tempNote] : noteNames1[tempNote], palette[PAL_PATTXT], palette[PAL_BACKGRD]);
261+ textOutBg(x + 6, y, config.accidental ? noteNames2[tempNote] : noteNames1[tempNote], video.palette[PAL_PATTXT], video.palette[PAL_BACKGRD]);
262262 }
263263
264264 if (note.sample)
265265 {
266− printOneHexBg(frameBuffer, putXOffset + 30, putYOffset, note.sample >> 4, palette[PAL_PATTXT], palette[PAL_BACKGRD]);
267− printOneHexBg(frameBuffer, putXOffset + 38, putYOffset, note.sample & 0x0F, palette[PAL_PATTXT], palette[PAL_BACKGRD]);
266+ printOneHexBg(x + 30, y, note.sample >> 4, video.palette[PAL_PATTXT], video.palette[PAL_BACKGRD]);
267+ printOneHexBg(x + 38, y, note.sample & 0x0F, video.palette[PAL_PATTXT], video.palette[PAL_BACKGRD]);
268268 }
269269 else
270270 {
271− charOutBg(frameBuffer, putXOffset + 30, putYOffset, -128, palette[PAL_PATTXT], palette[PAL_BACKGRD]);
272− charOutBg(frameBuffer, putXOffset + 38, putYOffset, -128, palette[PAL_PATTXT], palette[PAL_BACKGRD]);
271+ charOutBg(x + 30, y, -128, video.palette[PAL_PATTXT], video.palette[PAL_BACKGRD]);
272+ charOutBg(x + 38, y, -128, video.palette[PAL_PATTXT], video.palette[PAL_BACKGRD]);
273273 }
274274
275275 if ((note.command | note.param) == 0)
276276 {
277− charOutBg(frameBuffer, putXOffset + 46, putYOffset, -128, palette[PAL_PATTXT], palette[PAL_BACKGRD]);
278− charOutBg(frameBuffer, putXOffset + 54, putYOffset, -128, palette[PAL_PATTXT], palette[PAL_BACKGRD]);
279− charOutBg(frameBuffer, putXOffset + 62, putYOffset, -128, palette[PAL_PATTXT], palette[PAL_BACKGRD]);
277+ charOutBg(x + 46, y, -128, video.palette[PAL_PATTXT], video.palette[PAL_BACKGRD]);
278+ charOutBg(x + 54, y, -128, video.palette[PAL_PATTXT], video.palette[PAL_BACKGRD]);
279+ charOutBg(x + 62, y, -128, video.palette[PAL_PATTXT], video.palette[PAL_BACKGRD]);
280280 }
281281 else
282282 {
283− printOneHexBg(frameBuffer, putXOffset + 46, putYOffset, note.command, palette[PAL_PATTXT], palette[PAL_BACKGRD]);
284− printTwoHexBg(frameBuffer, putXOffset + 54, putYOffset, note.param, palette[PAL_PATTXT], palette[PAL_BACKGRD]);
283+ printOneHexBg(x + 46, y, note.command, video.palette[PAL_PATTXT], video.palette[PAL_BACKGRD]);
284+ printTwoHexBg(x + 54, y, note.param, video.palette[PAL_PATTXT], video.palette[PAL_BACKGRD]);
285285 }
286286 }
287287 }
@@ -293,7 +293,7 @@ void drawPatternDotted(uint32_t *frameBuffer) · 5 unmodified lines
293293 if (modEntry->currRow <= 6)
294294 {
295295 srcPtr = &trackerFrameBMP[140 * SCREEN_W];
296− dstPtr = &frameBuffer[140 * SCREEN_W];
296+ dstPtr = &video.frameBuffer[140 * SCREEN_W];
297297 memcpy(dstPtr, srcPtr, (SCREEN_W * sizeof (int32_t)) * ((7 - modEntry->currRow) * 7));
298298 }
299299 else if (modEntry->currRow >= 57)
@@ -302,15 +302,15 @@ void drawPatternDotted(uint32_t *frameBuffer) · 2 unmodified lines
302302 bufferOffset = (250 - h) * SCREEN_W;
303303
304304 srcPtr = &trackerFrameBMP[bufferOffset];
305− dstPtr = &frameBuffer[bufferOffset];
305+ dstPtr = &video.frameBuffer[bufferOffset];
306306 memcpy(dstPtr, srcPtr, (SCREEN_W * sizeof (int32_t)) * h);
307307 }
308308 }
309309
310−void redrawPattern(uint32_t *frameBuffer)
310+void redrawPattern(void)
311311 {
312− if (ptConfig.pattDots)
313− drawPatternDotted(frameBuffer);
312+ if (config.pattDots)
313+ drawPatternDotted();
314314 else
315− drawPatternNormal(frameBuffer);
315+ drawPatternNormal();
316316 }
src/pt2_patternviewer.h+1−3
@@ -1,5 +1,3 @@
11 #pragma once
22
3−#include <stdint.h>
4−
5−void redrawPattern(uint32_t *frameBuffer);
3+void redrawPattern(void);
src/pt2_sampleloader.c+10−10
@@ -289,7 +289,7 @@ bool loadWAVSample(UNICHAR *fileName, char *entryName, int8_t forceDownSampling) · 288 unmodified lines
289289 // 2x downsampling - remove every other sample (if needed)
290290 if (forceDownSampling)
291291 {
292− if (ptConfig.sampleLowpass)
292+ if (config.sampleLowpass)
293293 lowPassSample8BitUnsigned(audioDataU8, sampleLength, sampleRate, sampleRate / DOWNSAMPLE_CUTOFF_FACTOR);
294294
295295 sampleLength /= 2;
@@ -348,7 +348,7 @@ bool loadWAVSample(UNICHAR *fileName, char *entryName, int8_t forceDownSampling) · 52 unmodified lines
348348 // 2x downsampling - remove every other sample (if needed)
349349 if (forceDownSampling)
350350 {
351− if (ptConfig.sampleLowpass)
351+ if (config.sampleLowpass)
352352 lowPassSample16Bit(audioDataS16, sampleLength, sampleRate, sampleRate / DOWNSAMPLE_CUTOFF_FACTOR);
353353
354354 sampleLength /= 2;
@@ -410,7 +410,7 @@ bool loadWAVSample(UNICHAR *fileName, char *entryName, int8_t forceDownSampling) · 55 unmodified lines
410410 // 2x downsampling - remove every other sample (if needed)
411411 if (forceDownSampling)
412412 {
413− if (ptConfig.sampleLowpass)
413+ if (config.sampleLowpass)
414414 lowPassSample32Bit(audioDataS32, sampleLength, sampleRate, sampleRate / DOWNSAMPLE_CUTOFF_FACTOR);
415415
416416 sampleLength /= 2;
@@ -473,7 +473,7 @@ bool loadWAVSample(UNICHAR *fileName, char *entryName, int8_t forceDownSampling) · 56 unmodified lines
473473 // 2x downsampling - remove every other sample (if needed)
474474 if (forceDownSampling)
475475 {
476− if (ptConfig.sampleLowpass)
476+ if (config.sampleLowpass)
477477 lowPassSample32Bit(audioDataS32, sampleLength, sampleRate, sampleRate / DOWNSAMPLE_CUTOFF_FACTOR);
478478
479479 sampleLength /= 2;
@@ -536,7 +536,7 @@ bool loadWAVSample(UNICHAR *fileName, char *entryName, int8_t forceDownSampling) · 56 unmodified lines
536536 // 2x downsampling - remove every other sample (if needed)
537537 if (forceDownSampling)
538538 {
539− if (ptConfig.sampleLowpass)
539+ if (config.sampleLowpass)
540540 lowPassSampleFloat(fAudioDataFloat, sampleLength, sampleRate, sampleRate / DOWNSAMPLE_CUTOFF_FACTOR);
541541
542542 sampleLength /= 2;
@@ -605,7 +605,7 @@ bool loadWAVSample(UNICHAR *fileName, char *entryName, int8_t forceDownSampling) · 62 unmodified lines
605605 // 2x downsampling - remove every other sample (if needed)
606606 if (forceDownSampling)
607607 {
608− if (ptConfig.sampleLowpass)
608+ if (config.sampleLowpass)
609609 lowPassSampleDouble(dAudioDataDouble, sampleLength, sampleRate, sampleRate / DOWNSAMPLE_CUTOFF_FACTOR);
610610
611611 sampleLength /= 2;
@@ -1295,7 +1295,7 @@ bool loadAIFFSample(UNICHAR *fileName, char *entryName, int8_t forceDownSampling · 683 unmodified lines
12951295 // 2x downsampling - remove every other sample (if needed)
12961296 if (forceDownSampling)
12971297 {
1298− if (ptConfig.sampleLowpass)
1298+ if (config.sampleLowpass)
12991299 lowPassSample8Bit(audioDataS8, sampleLength, sampleRate, sampleRate / DOWNSAMPLE_CUTOFF_FACTOR);
13001300
13011301 sampleLength /= 2;
@@ -1358,7 +1358,7 @@ bool loadAIFFSample(UNICHAR *fileName, char *entryName, int8_t forceDownSampling · 56 unmodified lines
13581358 // 2x downsampling - remove every other sample (if needed)
13591359 if (forceDownSampling)
13601360 {
1361− if (ptConfig.sampleLowpass)
1361+ if (config.sampleLowpass)
13621362 lowPassSample16Bit(audioDataS16, sampleLength, sampleRate, sampleRate / DOWNSAMPLE_CUTOFF_FACTOR);
13631363
13641364 sampleLength /= 2;
@@ -1428,7 +1428,7 @@ bool loadAIFFSample(UNICHAR *fileName, char *entryName, int8_t forceDownSampling · 63 unmodified lines
14281428 // 2x downsampling - remove every other sample (if needed)
14291429 if (forceDownSampling)
14301430 {
1431− if (ptConfig.sampleLowpass)
1431+ if (config.sampleLowpass)
14321432 lowPassSample32Bit(audioDataS32, sampleLength, sampleRate, sampleRate / DOWNSAMPLE_CUTOFF_FACTOR);
14331433
14341434 sampleLength /= 2;
@@ -1495,7 +1495,7 @@ bool loadAIFFSample(UNICHAR *fileName, char *entryName, int8_t forceDownSampling · 60 unmodified lines
14951495 // 2x downsampling - remove every other sample (if needed)
14961496 if (forceDownSampling)
14971497 {
1498− if (ptConfig.sampleLowpass)
1498+ if (config.sampleLowpass)
14991499 lowPassSample32Bit(audioDataS32, sampleLength, sampleRate, sampleRate / DOWNSAMPLE_CUTOFF_FACTOR);
15001500
15011501 sampleLength /= 2;
src/pt2_sampler.c+149−151
@@ -32,7 +32,7 @@ typedef struct sampleMixer_t · 31 unmodified lines
3232 uint32_t posFrac, delta;
3333 } sampleMixer_t;
3434
35−static int32_t samOffsetScaled;
35+static int32_t samOffsetScaled, lastDrawX, lastDrawY;
3636 static uint32_t waveInvertTable[8];
3737
3838 static const int8_t tuneToneData[32] = // Tuning Tone (Sine Wave)
@@ -43,16 +43,14 @@ static const int8_t tuneToneData[32] = // Tuning Tone (Sine Wave) · 4 unmodified lines
4343 -127,-126,-118,-106, -91, -71, -49, -25
4444 };
4545
46−extern uint32_t *pixelBuffer; // pt_main.c
47−
4846 void setLoopSprites(void);
4947
5048 void createSampleMarkTable(void)
5149 {
5250 // used for invertRange() (sample data marking)
5351
54− waveInvertTable[0] = 0x00000000 | palette[PAL_BACKGRD];
55− waveInvertTable[1] = 0x01000000 | palette[PAL_QADSCP];
52+ waveInvertTable[0] = 0x00000000 | video.palette[PAL_BACKGRD];
53+ waveInvertTable[1] = 0x01000000 | video.palette[PAL_QADSCP];
5654 waveInvertTable[2] = 0x02000000 | CENTER_LINE_COLOR;
5755 waveInvertTable[3] = 0x03000000; // spacer, not used
5856 waveInvertTable[4] = 0x04000000 | MARK_COLOR_1;
@@ -106,10 +104,10 @@ void fillSampleFilterUndoBuffer(void) · 47 unmodified lines
106104 }
107105 }
108106
109−static void sampleLine(uint32_t *frameBuffer, int16_t line_x1, int16_t line_x2, int16_t line_y1, int16_t line_y2)
107+static void sampleLine(int16_t line_x1, int16_t line_x2, int16_t line_y1, int16_t line_y2)
110108 {
111109 int16_t d, x, y, ax, ay, sx, sy, dx, dy;
112− uint32_t color = 0x01000000 | palette[PAL_QADSCP];
110+ uint32_t color = 0x01000000 | video.palette[PAL_QADSCP];
113111
114112 assert(line_x1 >= 0 || line_x2 >= 0 || line_x1 < SCREEN_W || line_x2 < SCREEN_W);
115113 assert(line_y1 >= 0 || line_y2 >= 0 || line_y1 < SCREEN_H || line_y2 < SCREEN_H);
@@ -130,7 +128,7 @@ static void sampleLine(uint32_t *frameBuffer, int16_t line_x1, int16_t line_x2, · 14 unmodified lines
130128 {
131129 assert(y >= 0 || x >= 0 || y < SCREEN_H || x < SCREEN_W);
132130
133− frameBuffer[(y * SCREEN_W) + x] = color;
131+ video.frameBuffer[(y * SCREEN_W) + x] = color;
134132
135133 if (x == line_x2)
136134 break;
@@ -152,7 +150,7 @@ static void sampleLine(uint32_t *frameBuffer, int16_t line_x1, int16_t line_x2, · 15 unmodified lines
152150 {
153151 assert(y >= 0 || x >= 0 || y < SCREEN_H || x < SCREEN_W);
154152
155− frameBuffer[(y * SCREEN_W) + x] = color;
153+ video.frameBuffer[(y * SCREEN_W) + x] = color;
156154
157155 if (y == line_y2)
158156 break;
@@ -192,9 +190,9 @@ static void setDragBar(void) · 33 unmodified lines
192190
193191 // draw drag bar
194192
195− dstPtr = &pixelBuffer[206 * SCREEN_W];
196− pixel = palette[PAL_QADSCP];
197− bgPixel = palette[PAL_BACKGRD];
193+ dstPtr = &video.frameBuffer[206 * SCREEN_W];
194+ pixel = video.palette[PAL_QADSCP];
195+ bgPixel = video.palette[PAL_BACKGRD];
198196
199197 for (int32_t y = 0; y < 4; y++)
200198 {
@@ -213,8 +211,8 @@ static void setDragBar(void) · 12 unmodified lines
213211 {
214212 // clear drag bar background
215213
216− dstPtr = &pixelBuffer[(206 * SCREEN_W) + 4];
217− pixel = palette[PAL_BACKGRD];
214+ dstPtr = &video.frameBuffer[(206 * SCREEN_W) + 4];
215+ pixel = video.palette[PAL_BACKGRD];
218216
219217 for (int32_t y = 0; y < 4; y++)
220218 {
@@ -264,6 +262,9 @@ int32_t scr2SmpPos(int32_t x) // screen x pos -> sample pos · 43 unmodified lines
264262 x += samOffsetScaled;
265263 x = (uint32_t)(x * editor.sampler.samDisplay) / SAMPLE_AREA_WIDTH; // truncate here
266264
265+ if (x > editor.sampler.samLength)
266+ x = editor.sampler.samLength;
267+
267268 return x;
268269 }
269270
@@ -297,8 +298,8 @@ static void renderSampleData(void) · 27 unmodified lines
297298
298299 // clear sample data background
299300
300− dstPtr = &pixelBuffer[(138 * SCREEN_W) + 3];
301− pixel = palette[PAL_BACKGRD];
301+ dstPtr = &video.frameBuffer[(138 * SCREEN_W) + 3];
302+ pixel = video.palette[PAL_BACKGRD];
302303
303304 for (y = 0; y < SAMPLE_VIEW_HEIGHT; y++)
304305 {
@@ -309,9 +310,9 @@ static void renderSampleData(void) · 4 unmodified lines
309310 }
310311
311312 // display center line
312− if (ptConfig.dottedCenterFlag)
313+ if (config.dottedCenterFlag)
313314 {
314− dstPtr = &pixelBuffer[(SAMPLE_AREA_Y_CENTER * SCREEN_W) + 3];
315+ dstPtr = &video.frameBuffer[(SAMPLE_AREA_Y_CENTER * SCREEN_W) + 3];
315316 for (x = 0; x < SAMPLE_AREA_WIDTH; x++)
316317 dstPtr[x] = 0x02000000 | CENTER_LINE_COLOR;
317318 }
@@ -327,7 +328,7 @@ static void renderSampleData(void) · 9 unmodified lines
327328 for (x = 1; x < SAMPLE_AREA_WIDTH; x++)
328329 {
329330 y2 = SAMPLE_AREA_Y_CENTER - getScaledSample(scr2SmpPos(x));
330− sampleLine(pixelBuffer, x + 2, x + 3, y1, y2);
331+ sampleLine(x + 2, x + 3, y1, y2);
331332 y1 = y2;
332333 }
333334 }
@@ -355,11 +356,11 @@ static void renderSampleData(void) · 21 unmodified lines
355356
356357 if (x > 0)
357358 {
358− if (min > oldMax) sampleLine(pixelBuffer, x + 2, x + 3, oldMax, min);
359− if (max < oldMin) sampleLine(pixelBuffer, x + 2, x + 3, oldMin, max);
359+ if (min > oldMax) sampleLine(x + 2, x + 3, oldMax, min);
360+ if (max < oldMin) sampleLine(x + 2, x + 3, oldMin, max);
360361 }
361362
362− sampleLine(pixelBuffer, x + 3, x + 3, max, min);
363+ sampleLine(x + 3, x + 3, max, min);
363364
364365 oldMin = min;
365366 oldMax = max;
@@ -369,9 +370,9 @@ static void renderSampleData(void) · 3 unmodified lines
369370
370371 // render "sample display" text
371372 if (editor.sampler.samStart == editor.sampler.blankSample)
372− printFiveDecimalsBg(pixelBuffer, 272, 214, 0, palette[PAL_GENTXT], palette[PAL_GENBKG]);
373+ printFiveDecimalsBg(272, 214, 0, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
373374 else
374− printFiveDecimalsBg(pixelBuffer, 272, 214, editor.sampler.samDisplay, palette[PAL_GENTXT], palette[PAL_GENBKG]);
375+ printFiveDecimalsBg(272, 214, editor.sampler.samDisplay, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
375376
376377 setDragBar();
377378 setLoopSprites();
@@ -398,7 +399,7 @@ void invertRange(void) · 20 unmodified lines
398399 if (rangeLen < 1)
399400 rangeLen = 1;
400401
401− dstPtr = &pixelBuffer[(138 * SCREEN_W) + (start + 3)];
402+ dstPtr = &video.frameBuffer[(138 * SCREEN_W) + (start + 3)];
402403 for (y = 0; y < 64; y++)
403404 {
404405 for (x = 0; x < rangeLen; x++)
@@ -1435,7 +1436,7 @@ void sampleMarkerToBeg(void) · 1030 unmodified lines
14351436 else
14361437 {
14371438 invertRange();
1438− if (input.keyb.shiftPressed && editor.markStartOfs != -1)
1439+ if (keyb.shiftPressed && editor.markStartOfs != -1)
14391440 {
14401441 editor.markStartOfs = editor.sampler.samOffset;
14411442 }
@@ -1471,7 +1472,7 @@ void sampleMarkerToCenter(void) · 29 unmodified lines
14711472 middlePos = editor.sampler.samOffset + ((editor.sampler.samDisplay + 1) / 2);
14721473
14731474 invertRange();
1474− if (input.keyb.shiftPressed && editor.markStartOfs != -1)
1475+ if (keyb.shiftPressed && editor.markStartOfs != -1)
14751476 {
14761477 if (editor.markStartOfs < middlePos)
14771478 editor.markEndOfs = middlePos;
@@ -1507,7 +1508,7 @@ void sampleMarkerToEnd(void) · 29 unmodified lines
15071508 else
15081509 {
15091510 invertRange();
1510− if (input.keyb.shiftPressed && editor.markStartOfs != -1)
1511+ if (keyb.shiftPressed && editor.markStartOfs != -1)
15111512 {
15121513 editor.markEndOfs = s->length;
15131514 }
@@ -1995,7 +1996,7 @@ void setLoopSprites(void) · 481 unmodified lines
19951996 hideSprite(SPRITE_LOOP_PIN_RIGHT);
19961997 }
19971998
1998− textOutBg(pixelBuffer, 288, 225, (s->loopStart+s->loopLength > 2) ? "ON " : "OFF", palette[PAL_GENTXT], palette[PAL_GENBKG]);
1999+ textOutBg(288, 225, (s->loopStart+s->loopLength > 2) ? "ON " : "OFF", video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
19992000 }
20002001
20012002 void samplerShowAll(void)
@@ -2081,12 +2082,12 @@ static void samplerZoomOut(int32_t step, int16_t x) · 79 unmodified lines
20812082
20822083 void samplerZoomInMouseWheel(void)
20832084 {
2084− samplerZoomIn((editor.sampler.samDisplay + 5) / 10, input.mouse.x);
2085+ samplerZoomIn((editor.sampler.samDisplay + 5) / 10, mouse.x);
20852086 }
20862087
20872088 void samplerZoomOutMouseWheel(void)
20882089 {
2089− samplerZoomOut((editor.sampler.samDisplay + 5) / 10, input.mouse.x);
2090+ samplerZoomOut((editor.sampler.samDisplay + 5) / 10, mouse.x);
20902091 }
20912092
20922093 void samplerZoomOut2x(void)
@@ -2158,22 +2159,19 @@ void volBoxBarPressed(bool mouseButtonHeld) · 65 unmodified lines
21582159 {
21592160 int32_t mouseX;
21602161
2161− if (input.mouse.y < 0 || input.mouse.x < 0 || input.mouse.y >= SCREEN_H || input.mouse.x >= SCREEN_W)
2162− return;
2163−
21642162 if (!mouseButtonHeld)
21652163 {
2166− if (input.mouse.x >= 72 && input.mouse.x <= 173)
2164+ if (mouse.x >= 72 && mouse.x <= 173)
21672165 {
2168− if (input.mouse.y >= 154 && input.mouse.y <= 174) editor.ui.forceVolDrag = 1;
2169− if (input.mouse.y >= 165 && input.mouse.y <= 175) editor.ui.forceVolDrag = 2;
2166+ if (mouse.y >= 154 && mouse.y <= 174) editor.ui.forceVolDrag = 1;
2167+ if (mouse.y >= 165 && mouse.y <= 175) editor.ui.forceVolDrag = 2;
21702168 }
21712169 }
21722170 else
21732171 {
2174− if (editor.sampler.lastMouseX != input.mouse.x)
2172+ if (editor.sampler.lastMouseX != mouse.x)
21752173 {
2176− editor.sampler.lastMouseX = input.mouse.x;
2174+ editor.sampler.lastMouseX = mouse.x;
21772175 mouseX = CLAMP(editor.sampler.lastMouseX - 107, 0, 60);
21782176
21792177 if (editor.ui.forceVolDrag == 1)
@@ -2196,14 +2194,11 @@ void samplerBarPressed(bool mouseButtonHeld) · 16 unmodified lines
21962194 {
21972195 int32_t tmp32;
21982196
2199− if (input.mouse.y < 0 || input.mouse.x < 0 || input.mouse.y >= SCREEN_H || input.mouse.x >= SCREEN_W)
2200− return;
2201−
22022197 if (!mouseButtonHeld)
22032198 {
2204− if (input.mouse.x >= 4 && input.mouse.x <= 315)
2199+ if (mouse.x >= 4 && mouse.x <= 315)
22052200 {
2206− if (input.mouse.x < editor.sampler.dragStart)
2201+ if (mouse.x < editor.sampler.dragStart)
22072202 {
22082203 tmp32 = editor.sampler.samOffset - editor.sampler.samDisplay;
22092204 if (tmp32 < 0)
@@ -2219,7 +2214,7 @@ void samplerBarPressed(bool mouseButtonHeld) · 9 unmodified lines
22192214 return;
22202215 }
22212216
2222− if (input.mouse.x > editor.sampler.dragEnd)
2217+ if (mouse.x > editor.sampler.dragEnd)
22232218 {
22242219 tmp32 = editor.sampler.samOffset + editor.sampler.samDisplay;
22252220 if (tmp32+editor.sampler.samDisplay <= editor.sampler.samLength)
@@ -2243,22 +2238,21 @@ void samplerBarPressed(bool mouseButtonHeld) · 17 unmodified lines
22432238 return;
22442239 }
22452240
2246− editor.sampler.lastSamPos = (uint16_t)input.mouse.x;
2241+ editor.sampler.lastSamPos = mouse.x;
22472242 editor.sampler.saveMouseX = editor.sampler.lastSamPos - editor.sampler.dragStart;
22482243
22492244 editor.ui.forceSampleDrag = true;
22502245 }
22512246 }
22522247
2253− if (input.mouse.x != editor.sampler.lastSamPos)
2248+ if (mouse.x != editor.sampler.lastSamPos)
22542249 {
2255− editor.sampler.lastSamPos = (uint16_t)input.mouse.x;
2250+ editor.sampler.lastSamPos = mouse.x;
22562251
22572252 tmp32 = editor.sampler.lastSamPos - editor.sampler.saveMouseX - 4;
2258− if (tmp32 < 0)
2259− tmp32 = 0;
2253+ tmp32 = CLAMP(tmp32, 0, SAMPLE_AREA_WIDTH);
22602254
2261− tmp32 = (int32_t)(((tmp32 * editor.sampler.samLength) + (311/2)) / 311); // rounded
2255+ tmp32 = ((tmp32 * editor.sampler.samLength) + (311/2)) / 311; // rounded
22622256 if (tmp32+editor.sampler.samDisplay <= editor.sampler.samLength)
22632257 {
22642258 if (tmp32 == editor.sampler.samOffset)
@@ -2280,162 +2274,166 @@ void samplerBarPressed(bool mouseButtonHeld) · 15 unmodified lines
22802274 }
22812275 }
22822276
2283−static int32_t x2LoopX(int32_t mouseX)
2284−{
2285− moduleSample_t *s = &modEntry->samples[editor.currSample];
2286−
2287− mouseX -= 3;
2288− if (mouseX < 0)
2289− mouseX = 0;
2290−
2291− mouseX = scr2SmpPos(mouseX);
2292− mouseX = CLAMP(mouseX, 0, s->length);
2293−
2294− return mouseX;
2295−}
2296−
2297−static int32_t xToSmpX(int32_t x, int32_t smpLen)
2277+static int32_t mouseYToSampleY(int32_t my)
22982278 {
2299− x = scr2SmpPos(x);
2300− x = CLAMP(x, 0, smpLen - 1);
2301−
2302− return x;
2303−}
2279+ int32_t tmp32;
23042280
2305−static int8_t yToSmpY(int32_t mouseY)
2306−{
2307− mouseY = (SAMPLE_AREA_Y_CENTER - mouseY) * 4;
2308− CLAMP8(mouseY);
2281+ if (my == SAMPLE_AREA_Y_CENTER) // center
2282+ {
2283+ return 128;
2284+ }
2285+ else
2286+ {
2287+ tmp32 = my - 138;
2288+ tmp32 = ((tmp32 << 8) + (SAMPLE_AREA_HEIGHT/2)) / SAMPLE_AREA_HEIGHT;
2289+ tmp32 = CLAMP(tmp32, 0, 255);
2290+ tmp32 ^= 0xFF;
2291+ }
23092292
2310− return mouseY;
2293+ return tmp32;
23112294 }
23122295
23132296 void samplerEditSample(bool mouseButtonHeld)
23142297 {
2315− int8_t y;
2316− int32_t mouseY, x, smp_x0, smp_x1, xDistance, smp_y0, smp_y1, yDistance, smp;
2298+ int8_t *ptr8;
2299+ int32_t mx, my, tmp32, p, vl, tvl, r, rl, rvl, start, end;
23172300 moduleSample_t *s;
23182301
23192302 assert(editor.currSample >= 0 && editor.currSample <= 30);
2303+ s = &modEntry->samples[editor.currSample];
23202304
2321− if (input.mouse.y < 0 || input.mouse.x < 0 || input.mouse.y >= SCREEN_H || input.mouse.x >= SCREEN_W)
2305+ if (s->length == 0)
2306+ {
2307+ displayErrorMsg("SAMPLE LENGTH = 0");
23222308 return;
2309+ }
23232310
2324− s = &modEntry->samples[editor.currSample];
2311+ mx = mouse.x;
2312+ if (mx > 4+SAMPLE_AREA_WIDTH)
2313+ mx = 4+SAMPLE_AREA_WIDTH;
2314+
2315+ my = mouse.y;
23252316
23262317 if (!mouseButtonHeld)
23272318 {
2328− if (input.mouse.x >= 3 && input.mouse.x <= 316 && input.mouse.y >= 138 && input.mouse.y <= 201)
2329− {
2330− if (s->length == 0)
2331− {
2332− displayErrorMsg("SAMPLE LENGTH = 0");
2333− }
2334− else
2335− {
2336− editor.sampler.lastMouseX = input.mouse.x;
2337− editor.sampler.lastMouseY = input.mouse.y;
2338− editor.ui.forceSampleEdit = true;
2339− updateWindowTitle(MOD_IS_MODIFIED);
2340− }
2341− }
2319+ lastDrawX = scr2SmpPos(mx);
2320+ lastDrawY = mouseYToSampleY(my);
23422321
2343− return;
2322+ editor.ui.forceSampleEdit = true;
2323+ updateWindowTitle(MOD_IS_MODIFIED);
2324+ }
2325+ else if (mx == editor.sampler.lastMouseX && my == editor.sampler.lastMouseY)
2326+ {
2327+ return; // don't continue if we didn't move the mouse
23442328 }
23452329
2346− mouseY = input.keyb.shiftPressed ? editor.sampler.lastMouseY : input.mouse.y;
2330+ if (mx != editor.sampler.lastMouseX)
2331+ p = scr2SmpPos(mx);
2332+ else
2333+ p = lastDrawX;
2334+
2335+ if (!keyb.shiftPressed && my != editor.sampler.lastMouseY)
2336+ vl = mouseYToSampleY(my);
2337+ else
2338+ vl = lastDrawY;
23472339
2348− x = xToSmpX(input.mouse.x - 3, s->length);
2349− y = yToSmpY(mouseY);
2340+ editor.sampler.lastMouseX = mx;
2341+ editor.sampler.lastMouseY = my;
23502342
2351− modEntry->sampleData[s->offset+x] = y;
2343+ r = p;
2344+ rvl = vl;
23522345
2353− // interpolate x gaps
2354− if (input.mouse.x != editor.sampler.lastMouseX)
2346+ // swap x/y if needed
2347+ if (p > lastDrawX)
23552348 {
2356− smp_y0 = yToSmpY(editor.sampler.lastMouseY);
2349+ // swap x
2350+ tmp32 = p;
2351+ p = lastDrawX;
2352+ lastDrawX = tmp32;
23572353
2358− smp_y1 = y;
2359− yDistance = smp_y1 - smp_y0;
2354+ // swap y
2355+ tmp32 = lastDrawY;
2356+ lastDrawY = vl;
2357+ vl = tmp32;
2358+ }
23602359
2361− if (input.mouse.x > editor.sampler.lastMouseX)
2362− {
2363− smp_x1 = x;
2364− smp_x0 = xToSmpX(editor.sampler.lastMouseX - 3, s->length);
2360+ ptr8 = &modEntry->sampleData[s->offset];
23652361
2366− xDistance = smp_x1 - smp_x0;
2367− if (xDistance > 0)
2368− {
2369− for (x = smp_x0; x < smp_x1; x++)
2370− {
2371− assert(x < s->length);
2362+ start = p;
2363+ if (start < 0)
2364+ start = 0;
23722365
2373− smp = smp_y0 + (((x - smp_x0) * yDistance) / xDistance);
2374− CLAMP8(smp);
2375− modEntry->sampleData[s->offset + x] = (int8_t)smp;
2376− }
2377− }
2378− }
2379− else if (input.mouse.x < editor.sampler.lastMouseX)
2366+ end = lastDrawX+1;
2367+ if (end > s->length)
2368+ end = s->length;
2369+
2370+ if (p == lastDrawX)
2371+ {
2372+ const int8_t smpVal = (int8_t)(vl ^ 0x80);
2373+ for (rl = start; rl < end; rl++)
2374+ ptr8[rl] = smpVal;
2375+ }
2376+ else
2377+ {
2378+ int32_t y = lastDrawY - vl;
2379+ int32_t x = lastDrawX - p;
2380+
2381+ if (x != 0)
23802382 {
2381− smp_x0 = x;
2382− smp_x1 = xToSmpX(editor.sampler.lastMouseX - 3, s->length);
2383+ double dMul = 1.0 / x;
2384+ int32_t i = 0;
23832385
2384− xDistance = smp_x1 - smp_x0;
2385− if (xDistance > 0)
2386+ for (rl = start; rl < end; rl++)
23862387 {
2387− for (x = smp_x0; x < smp_x1; x++)
2388− {
2389− assert(x < s->length);
2388+ tvl = y * i;
2389+ tvl = (int32_t)(tvl * dMul); // tvl /= x
2390+ tvl += vl;
2391+ tvl ^= 0x80;
23902392
2391− smp = smp_y0 + (((smp_x1 - x) * yDistance) / xDistance);
2392− CLAMP8(smp);
2393− modEntry->sampleData[s->offset + x] = (int8_t)smp;
2394− }
2393+ ptr8[rl] = (int8_t)tvl;
2394+ i++;
23952395 }
23962396 }
2397−
2398− editor.sampler.lastMouseX = input.mouse.x;
2399−
2400− if (!input.keyb.shiftPressed)
2401− editor.sampler.lastMouseY = input.mouse.y;
24022397 }
24032398
2399+ lastDrawY = rvl;
2400+ lastDrawX = r;
2401+
24042402 displaySample();
24052403 }
24062404
24072405 void samplerSamplePressed(bool mouseButtonHeld)
24082406 {
2409− int16_t mouseX;
2410− int32_t tmpPos;
2407+ int32_t mouseX, tmpPos;
24112408 moduleSample_t *s;
24122409
24132410 assert(editor.currSample >= 0 && editor.currSample <= 30);
24142411
24152412 if (!mouseButtonHeld)
24162413 {
2417− if (input.mouse.y < 142)
2414+ if (mouse.y < 142)
24182415 {
2419− if (input.mouse.x >= editor.sampler.loopStartPos && input.mouse.x <= editor.sampler.loopStartPos+3)
2416+ if (mouse.x >= editor.sampler.loopStartPos && mouse.x <= editor.sampler.loopStartPos+3)
24202417 {
24212418 editor.ui.leftLoopPinMoving = true;
24222419 editor.ui.rightLoopPinMoving = false;
24232420 editor.ui.sampleMarkingPos = 1;
2424− editor.sampler.lastMouseX = input.mouse.x;
2421+ editor.sampler.lastMouseX = mouse.x;
24252422 return;
24262423 }
2427− else if (input.mouse.x >= editor.sampler.loopEndPos+3 && input.mouse.x <= editor.sampler.loopEndPos+6)
2424+ else if (mouse.x >= editor.sampler.loopEndPos+3 && mouse.x <= editor.sampler.loopEndPos+6)
24282425 {
24292426 editor.ui.rightLoopPinMoving = true;
24302427 editor.ui.leftLoopPinMoving = false;
24312428 editor.ui.sampleMarkingPos = 1;
2432− editor.sampler.lastMouseX = input.mouse.x;
2429+ editor.sampler.lastMouseX = mouse.x;
24332430 return;
24342431 }
24352432 }
24362433 }
24372434
2438− mouseX = (int16_t)input.mouse.x;
2435+ mouseX = CLAMP(mouse.x, 0, SCREEN_W+8); // allow some extra pixels outside of the screen
2436+
24392437 s = &modEntry->samples[editor.currSample];
24402438
24412439 if (editor.ui.leftLoopPinMoving)
@@ -2444,7 +2442,7 @@ void samplerSamplePressed(bool mouseButtonHeld) · 2 unmodified lines
24442442 {
24452443 editor.sampler.lastMouseX = mouseX;
24462444
2447− tmpPos = (x2LoopX(mouseX + 2) - s->loopStart) & 0xFFFFFFFE;
2445+ tmpPos = (scr2SmpPos(mouseX - 1) - s->loopStart) & 0xFFFFFFFE;
24482446 if (tmpPos > MAX_SAMPLE_LEN)
24492447 tmpPos = MAX_SAMPLE_LEN;
24502448
@@ -2482,7 +2480,7 @@ void samplerSamplePressed(bool mouseButtonHeld) · 31 unmodified lines
24822480
24832481 s = &modEntry->samples[editor.currSample];
24842482
2485− tmpPos = (x2LoopX(mouseX - 1) - s->loopStart) & 0xFFFFFFFE;
2483+ tmpPos = (scr2SmpPos(mouseX - 4) - s->loopStart) & 0xFFFFFFFE;
24862484 tmpPos = CLAMP(tmpPos, 2, MAX_SAMPLE_LEN);
24872485
24882486 s->loopLength = tmpPos;
@@ -2500,7 +2498,7 @@ void samplerSamplePressed(bool mouseButtonHeld) · 11 unmodified lines
25002498
25012499 if (!mouseButtonHeld)
25022500 {
2503− if (mouseX < 3 || mouseX > 319)
2501+ if (mouseX < 3 || mouseX >= SCREEN_W)
25042502 return;
25052503
25062504 editor.ui.sampleMarkingPos = (int16_t)mouseX;
@@ -2540,7 +2538,7 @@ void samplerSamplePressed(bool mouseButtonHeld) · 33 unmodified lines
25402538 return;
25412539 }
25422540
2543− mouseX = CLAMP(mouseX, 3, 319);
2541+ mouseX = CLAMP(mouseX, 3, SCREEN_W);
25442542
25452543 if (mouseX != editor.sampler.lastSamPos)
25462544 {
@@ -2643,7 +2641,7 @@ void samplerLoopToggle(void) · 96 unmodified lines
26432641 void exitFromSam(void)
26442642 {
26452643 editor.ui.samplerScreenShown = false;
2646− memcpy(&pixelBuffer[121 * SCREEN_W], &trackerFrameBMP[121 * SCREEN_W], 320 * 134 * sizeof (int32_t));
2644+ memcpy(&video.frameBuffer[121 * SCREEN_W], &trackerFrameBMP[121 * SCREEN_W], 320 * 134 * sizeof (int32_t));
26472645
26482646 updateCursorPos();
26492647 setLoopSprites();
@@ -2667,7 +2665,7 @@ void samplerScreen(void) · 17 unmodified lines
26672665 }
26682666
26692667 editor.ui.samplerScreenShown = true;
2670− memcpy(&pixelBuffer[(121 * SCREEN_W)], samplerScreenBMP, 320 * 134 * sizeof (int32_t));
2668+ memcpy(&video.frameBuffer[(121 * SCREEN_W)], samplerScreenBMP, 320 * 134 * sizeof (int32_t));
26712669 hideSprite(SPRITE_PATTERN_CURSOR);
26722670
26732671 editor.ui.updateStatusText = true;
src/pt2_scopes.c+34−33
@@ -24,11 +24,8 @@ static uint32_t scopeTimeLen, scopeTimeLenFrac; · 23 unmodified lines
2424 static uint64_t timeNext64, timeNext64Frac;
2525 static SDL_Thread *scopeThread;
2626
27−scopeChannel_t scope[4]; // global
28−scopeChannelExt_t scopeExt[4]; // global
29−
30−extern bool forceMixerOff; // pt_audio.c
31−extern uint32_t *pixelBuffer; // pt_main.c
27+scopeChannel_t scope[AMIGA_VOICES]; // global
28+scopeChannelExt_t scopeExt[AMIGA_VOICES]; // global
3229
3330 int32_t getSampleReadPos(uint8_t ch, uint8_t smpNum)
3431 {
@@ -47,9 +44,10 @@ int32_t getSampleReadPos(uint8_t ch, uint8_t smpNum) · 12 unmodified lines
4744 {
4845 s = &modEntry->samples[smpNum];
4946
50− /* get real sampling position regardless of where the scope data points to
47+ /* Get real sampling position regardless of where the scope data points to
5148 ** sc->data changes during loop, offset and so on, so this has to be done
52− ** (sadly, because it's really hackish) */
49+ ** (sadly, because it's really hackish).
50+ */
5351 pos = (int32_t)(&data[pos] - &modEntry->sampleData[s->offset]);
5452 if (pos >= s->length)
5553 return -1;
@@ -73,7 +71,7 @@ void updateScopes(void) · 17 unmodified lines
7371 if (editor.isWAVRendering)
7472 return;
7573
76− for (uint32_t i = 0; i < AMIGA_VOICES; i++)
74+ for (int32_t i = 0; i < AMIGA_VOICES; i++)
7775 {
7876 sc = &scope[i];
7977 se = &scopeExt[i];
@@ -93,8 +91,9 @@ void updateScopes(void) · 13 unmodified lines
9391 {
9492 // sample reached end, simulate Paula register update (sample swapping)
9593
96− /* wrap pos around one time with current length, then set new length
97− ** and wrap around it (handles one-shot loops and sample swapping) */
94+ /* Wrap pos around one time with current length, then set new length
95+ ** and wrap around it (handles one-shot loops and sample swapping).
96+ */
9897 tmp.pos -= tmp.length;
9998 tmp.length = tmpExt.newLength;
10099
@@ -114,7 +113,8 @@ void updateScopes(void) · 13 unmodified lines
114113
115114 /* This routine gets the average sample peak through the running scope voices.
116115 ** This gives a much more smooth and stable result than getting the peak from
117−** the mixer, and we don't care about including filters/BLEP in the peak calculation. */
116+** the mixer, and we don't care about including filters/BLEP in the peak calculation.
117+*/
118118 static void updateRealVuMeters(void)
119119 {
120120 bool didSwapData;
@@ -195,7 +195,7 @@ static void updateRealVuMeters(void) · 74 unmodified lines
195195 }
196196 }
197197
198− smpPeak = ((smpPeak * 48) + (1 << 12)) >> 13;
198+ smpPeak = ((smpPeak * 48) + (1 << 12)) >> 13; // rounded
199199 if (smpPeak > editor.realVuMeterVolumes[i])
200200 editor.realVuMeterVolumes[i] = smpPeak;
201201 }
@@ -216,7 +216,7 @@ void drawScopes(void) · 14 unmodified lines
216216 {
217217 // --- QUADRASCOPE ---
218218
219− scopePtr = &pixelBuffer[(71 * SCREEN_W) + 128];
219+ scopePtr = &video.frameBuffer[(71 * SCREEN_W) + 128];
220220 for (i = 0; i < AMIGA_VOICES; i++)
221221 {
222222 sc = &scope[i];
@@ -226,7 +226,7 @@ void drawScopes(void) · 3 unmodified lines
226226 tmpScope = *sc;
227227 didSwapData = se->didSwapData;
228228
229− volume = -modEntry->channels[i].n_volume; // 0..64 -> -64..0
229+ volume = -modEntry->channels[i].n_volume; // invert volume
230230
231231 // render scope
232232 if (se->active && tmpScope.data != NULL && volume != 0 && tmpScope.length > 0)
@@ -237,8 +237,8 @@ void drawScopes(void) · 4 unmodified lines
237237
238238 // draw scope background
239239
240− dstPtr = &pixelBuffer[(55 * SCREEN_W) + (128 + (i * (SCOPE_WIDTH + 8)))];
241− scopePixel = palette[PAL_BACKGRD]; // this palette can change
240+ dstPtr = &video.frameBuffer[(55 * SCREEN_W) + (128 + (i * (SCOPE_WIDTH + 8)))];
241+ scopePixel = video.palette[PAL_BACKGRD]; // this palette can change
242242
243243 for (y = 0; y < SCOPE_HEIGHT; y++)
244244 {
@@ -250,7 +250,7 @@ void drawScopes(void) · 5 unmodified lines
250250
251251 // render scope data
252252
253− scopePixel = palette[PAL_QADSCP];
253+ scopePixel = video.palette[PAL_QADSCP];
254254
255255 readPos = tmpScope.pos;
256256 if (tmpScope.loopFlag)
@@ -299,8 +299,8 @@ void drawScopes(void) · 42 unmodified lines
299299 {
300300 // draw scope background
301301
302− dstPtr = &pixelBuffer[(55 * SCREEN_W) + (128 + (i * (SCOPE_WIDTH + 8)))];
303− scopePixel = palette[PAL_BACKGRD];
302+ dstPtr = &video.frameBuffer[(55 * SCREEN_W) + (128 + (i * (SCOPE_WIDTH + 8)))];
303+ scopePixel = video.palette[PAL_BACKGRD];
304304
305305 for (y = 0; y < SCOPE_HEIGHT; y++)
306306 {
@@ -312,7 +312,7 @@ void drawScopes(void) · 5 unmodified lines
312312
313313 // draw line
314314
315− scopePixel = palette[PAL_QADSCP];
315+ scopePixel = video.palette[PAL_QADSCP];
316316 for (x = 0; x < SCOPE_WIDTH; x++)
317317 scopePtr[x] = scopePixel;
318318
@@ -332,8 +332,6 @@ static int32_t SDLCALL scopeThreadFunc(void *ptr) · 13 unmodified lines
332332 uint32_t diff32;
333333 uint64_t time64;
334334
335− (void)ptr;
336−
337335 // this is needed for scope stability (confirmed)
338336 SDL_SetThreadPriority(SDL_THREAD_PRIORITY_HIGH);
339337
@@ -343,7 +341,7 @@ static int32_t SDLCALL scopeThreadFunc(void *ptr) · 3 unmodified lines
343341
344342 while (editor.programRunning)
345343 {
346− if (ptConfig.realVuMeters)
344+ if (config.realVuMeters)
347345 updateRealVuMeters();
348346
349347 updateScopes();
@@ -372,6 +370,7 @@ static int32_t SDLCALL scopeThreadFunc(void *ptr) · 22 unmodified lines
372370 }
373371 }
374372
373+ (void)ptr;
375374 return true;
376375 }
377376
@@ -383,7 +382,7 @@ bool initScopes(void) · 5 unmodified lines
383382 dFrac = modf(editor.dPerfFreq / SCOPE_HZ, &dInt);
384383
385384 // integer part
386− scopeTimeLen = (uint32_t)dInt;
385+ scopeTimeLen = (int32_t)dInt;
387386
388387 // fractional part scaled to 0..2^32-1
389388 dFrac *= UINT32_MAX;
@@ -400,18 +399,20 @@ bool initScopes(void) · 10 unmodified lines
400399 return true;
401400 }
402401
403−void waitOnScopes(void)
402+void stopScope(uint8_t ch)
404403 {
405404 while (scopesReading);
406−}
405+ memset(&scopeExt[ch], 0, sizeof (scopeChannelExt_t));
407406
408−void clearScopes(void)
409−{
410− waitOnScopes();
407+ while (scopesReading);
408+ memset(&scope[ch], 0, sizeof (scopeChannel_t));
411409
412− memset(scope, 0, sizeof (scope));
413− memset(scopeExt, 0, sizeof (scopeExt));
410+ scope[ch].length = scopeExt[ch].newLength = 2;
411+ while (scopesReading); // final wait to make sure scopes are all inactive
412+}
414413
415− for (uint8_t i = 0; i < AMIGA_VOICES; i++)
416− scope[i].length = scopeExt[i].newLength = 2;
414+void stopAllScopes(void)
415+{
416+ for (int32_t i = 0; i < AMIGA_VOICES; i++)
417+ stopScope(i);
417418 }
src/pt2_scopes.h+5−4
@@ -2,6 +2,7 @@ · 1 unmodified line
22
33 #include <stdint.h>
44 #include <stdbool.h>
5+#include "pt2_header.h"
56
67 typedef struct scopeChannel_t // internal scope state
78 {
@@ -24,8 +25,8 @@ int32_t getSampleReadPos(uint8_t ch, uint8_t smpNum); · 16 unmodified lines
2425 void updateScopes(void);
2526 void drawScopes(void);
2627 bool initScopes(void);
27−void waitOnScopes(void);
28−void clearScopes(void);
28+void stopScope(uint8_t ch);
29+void stopAllScopes(void);
2930
30−extern scopeChannel_t scope[4];
31−extern scopeChannelExt_t scopeExt[4];
31+extern scopeChannel_t scope[AMIGA_VOICES];
32+extern scopeChannelExt_t scopeExt[AMIGA_VOICES];
src/pt2_tables.h+0−3
@@ -70,9 +70,6 @@ extern uint32_t *arrowBMP; · 69 unmodified lines
7070 extern uint32_t *editOpModeCharsBMP;
7171 extern uint32_t *pat2SmpDialogBMP;
7272
73−// PALETTE
74−extern uint32_t palette[PALETTE_NUM];
75−
7673 // button tables taken from the ptplay project + modified
7774
7875 // MODIFY THESE EVERY TIME YOU REMOVE/ADD A BUTTON!
src/pt2_textout.c+132−132
@@ -12,7 +12,7 @@ static const char hexTable[16] = · 11 unmodified lines
1212 '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
1313 };
1414
15−void charOut(uint32_t *frameBuffer, uint32_t xPos, uint32_t yPos, char ch, uint32_t color)
15+void charOut(uint32_t xPos, uint32_t yPos, char ch, uint32_t color)
1616 {
1717 const uint8_t *srcPtr;
1818 uint32_t *dstPtr;
@@ -21,7 +21,7 @@ void charOut(uint32_t *frameBuffer, uint32_t xPos, uint32_t yPos, char ch, uint3 · 2 unmodified lines
2121 return;
2222
2323 srcPtr = &fontBMP[(uint8_t)ch * (FONT_CHAR_W * FONT_CHAR_H)];
24− dstPtr = &frameBuffer[(yPos * SCREEN_W) + xPos];
24+ dstPtr = &video.frameBuffer[(yPos * SCREEN_W) + xPos];
2525
2626 for (uint32_t y = 0; y < FONT_CHAR_H; y++)
2727 {
@@ -36,7 +36,7 @@ void charOut(uint32_t *frameBuffer, uint32_t xPos, uint32_t yPos, char ch, uint3 · 8 unmodified lines
3636 }
3737 }
3838
39−void charOutBg(uint32_t *frameBuffer, uint32_t xPos, uint32_t yPos, char ch, uint32_t fgColor, uint32_t bgColor)
39+void charOutBg(uint32_t xPos, uint32_t yPos, char ch, uint32_t fgColor, uint32_t bgColor)
4040 {
4141 const uint8_t *srcPtr;
4242 uint32_t *dstPtr;
@@ -48,7 +48,7 @@ void charOutBg(uint32_t *frameBuffer, uint32_t xPos, uint32_t yPos, char ch, uin · 5 unmodified lines
4848 ch = ' ';
4949
5050 srcPtr = &fontBMP[(uint8_t)ch * (FONT_CHAR_W * FONT_CHAR_H)];
51− dstPtr = &frameBuffer[(yPos * SCREEN_W) + xPos];
51+ dstPtr = &video.frameBuffer[(yPos * SCREEN_W) + xPos];
5252
5353 for (uint32_t y = 0; y < FONT_CHAR_H; y++)
5454 {
@@ -60,7 +60,7 @@ void charOutBg(uint32_t *frameBuffer, uint32_t xPos, uint32_t yPos, char ch, uin · 5 unmodified lines
6060 }
6161 }
6262
63−void charOutBig(uint32_t *frameBuffer, uint32_t xPos, uint32_t yPos, char ch, uint32_t color)
63+void charOutBig(uint32_t xPos, uint32_t yPos, char ch, uint32_t color)
6464 {
6565 const uint8_t *srcPtr;
6666 uint32_t *dstPtr;
@@ -69,7 +69,7 @@ void charOutBig(uint32_t *frameBuffer, uint32_t xPos, uint32_t yPos, char ch, ui · 2 unmodified lines
6969 return;
7070
7171 srcPtr = &fontBMP[(uint8_t)ch * (FONT_CHAR_W * FONT_CHAR_H)];
72− dstPtr = &frameBuffer[(yPos * SCREEN_W) + xPos];
72+ dstPtr = &video.frameBuffer[(yPos * SCREEN_W) + xPos];
7373
7474 for (uint32_t y = 0; y < FONT_CHAR_H; y++)
7575 {
@@ -87,7 +87,7 @@ void charOutBig(uint32_t *frameBuffer, uint32_t xPos, uint32_t yPos, char ch, ui · 11 unmodified lines
8787 }
8888 }
8989
90−void charOutBigBg(uint32_t *frameBuffer, uint32_t xPos, uint32_t yPos, char ch, uint32_t fgColor, uint32_t bgColor)
90+void charOutBigBg(uint32_t xPos, uint32_t yPos, char ch, uint32_t fgColor, uint32_t bgColor)
9191 {
9292 const uint8_t *srcPtr;
9393 uint32_t *dstPtr;
@@ -99,7 +99,7 @@ void charOutBigBg(uint32_t *frameBuffer, uint32_t xPos, uint32_t yPos, char ch, · 5 unmodified lines
9999 ch = ' ';
100100
101101 srcPtr = &fontBMP[(uint8_t)ch * (FONT_CHAR_W * FONT_CHAR_H)];
102− dstPtr = &frameBuffer[(yPos * SCREEN_W) + xPos];
102+ dstPtr = &video.frameBuffer[(yPos * SCREEN_W) + xPos];
103103
104104 for (uint32_t y = 0; y < FONT_CHAR_H; y++)
105105 {
@@ -122,151 +122,151 @@ void charOutBigBg(uint32_t *frameBuffer, uint32_t xPos, uint32_t yPos, char ch, · 16 unmodified lines
122122 }
123123 }
124124
125−void textOut(uint32_t *frameBuffer, uint32_t xPos, uint32_t yPos, const char *text, uint32_t color)
125+void textOut(uint32_t xPos, uint32_t yPos, const char *text, uint32_t color)
126126 {
127127 uint32_t x = xPos;
128128 while (*text != '\0')
129129 {
130− charOut(frameBuffer, x, yPos, *text++, color);
130+ charOut(x, yPos, *text++, color);
131131 x += FONT_CHAR_W;
132132 }
133133 }
134134
135−void textOutTight(uint32_t *frameBuffer, uint32_t xPos, uint32_t yPos, const char *text, uint32_t color)
135+void textOutTight(uint32_t xPos, uint32_t yPos, const char *text, uint32_t color)
136136 {
137137 uint32_t x = xPos;
138138 while (*text != '\0')
139139 {
140− charOut(frameBuffer, x, yPos, *text++, color);
140+ charOut(x, yPos, *text++, color);
141141 x += (FONT_CHAR_W - 1);
142142 }
143143 }
144144
145−void textOutBg(uint32_t *frameBuffer, uint32_t xPos, uint32_t yPos, const char *text, uint32_t fgColor, uint32_t bgColor)
145+void textOutBg(uint32_t xPos, uint32_t yPos, const char *text, uint32_t fgColor, uint32_t bgColor)
146146 {
147147 uint32_t x = xPos;
148148 while (*text != '\0')
149149 {
150− charOutBg(frameBuffer, x, yPos, *text++, fgColor, bgColor);
150+ charOutBg(x, yPos, *text++, fgColor, bgColor);
151151 x += FONT_CHAR_W;
152152 }
153153 }
154154
155−void textOutBig(uint32_t *frameBuffer, uint32_t xPos, uint32_t yPos, const char *text, uint32_t color)
155+void textOutBig(uint32_t xPos, uint32_t yPos, const char *text, uint32_t color)
156156 {
157157 uint32_t x = xPos;
158158 while (*text != '\0')
159159 {
160− charOutBig(frameBuffer, x, yPos, *text++, color);
160+ charOutBig(x, yPos, *text++, color);
161161 x += FONT_CHAR_W;
162162 }
163163 }
164164
165−void textOutBigBg(uint32_t *frameBuffer, uint32_t xPos, uint32_t yPos, const char *text, uint32_t fgColor, uint32_t bgColor)
165+void textOutBigBg(uint32_t xPos, uint32_t yPos, const char *text, uint32_t fgColor, uint32_t bgColor)
166166 {
167167 uint32_t x = xPos;
168168 while (*text != '\0')
169169 {
170− charOutBigBg(frameBuffer, x, yPos, *text++, fgColor, bgColor);
170+ charOutBigBg(x, yPos, *text++, fgColor, bgColor);
171171 x += FONT_CHAR_W;
172172 }
173173 }
174174
175−void printTwoDecimals(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor)
175+void printTwoDecimals(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor)
176176 {
177177 if (value == 0)
178178 {
179− textOut(frameBuffer, x, y, "00", fontColor);
179+ textOut(x, y, "00", fontColor);
180180 }
181181 else
182182 {
183183 if (value > 99)
184184 value = 99;
185185
186− charOut(frameBuffer, x + (FONT_CHAR_W * 1), y, '0' + (value % 10), fontColor); value /= 10;
187− charOut(frameBuffer, x + (FONT_CHAR_W * 0), y, '0' + (value % 10), fontColor);
186+ charOut(x + (FONT_CHAR_W * 1), y, '0' + (value % 10), fontColor); value /= 10;
187+ charOut(x + (FONT_CHAR_W * 0), y, '0' + (value % 10), fontColor);
188188 }
189189 }
190190
191−void printTwoDecimalsBig(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor)
191+void printTwoDecimalsBig(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor)
192192 {
193193 if (value == 0)
194194 {
195− textOutBig(frameBuffer, x, y, "00", fontColor);
195+ textOutBig(x, y, "00", fontColor);
196196 }
197197 else
198198 {
199199 if (value > 99)
200200 value = 99;
201201
202− charOutBig(frameBuffer, x + (FONT_CHAR_W * 1), y, '0' + (value % 10), fontColor); value /= 10;
203− charOutBig(frameBuffer, x + (FONT_CHAR_W * 0), y, '0' + (value % 10), fontColor);
202+ charOutBig(x + (FONT_CHAR_W * 1), y, '0' + (value % 10), fontColor); value /= 10;
203+ charOutBig(x + (FONT_CHAR_W * 0), y, '0' + (value % 10), fontColor);
204204 }
205205 }
206206
207−void printThreeDecimals(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor)
207+void printThreeDecimals(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor)
208208 {
209209 if (value == 0)
210210 {
211− textOut(frameBuffer, x, y, "000", fontColor);
211+ textOut(x, y, "000", fontColor);
212212 }
213213 else
214214 {
215215 if (value > 999)
216216 value = 999;
217217
218− charOut(frameBuffer, x + (FONT_CHAR_W * 2), y, '0' + (value % 10), fontColor); value /= 10;
219− charOut(frameBuffer, x + (FONT_CHAR_W * 1), y, '0' + (value % 10), fontColor); value /= 10;
220− charOut(frameBuffer, x + (FONT_CHAR_W * 0), y, '0' + (value % 10), fontColor);
218+ charOut(x + (FONT_CHAR_W * 2), y, '0' + (value % 10), fontColor); value /= 10;
219+ charOut(x + (FONT_CHAR_W * 1), y, '0' + (value % 10), fontColor); value /= 10;
220+ charOut(x + (FONT_CHAR_W * 0), y, '0' + (value % 10), fontColor);
221221 }
222222 }
223223
224−void printFourDecimals(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor)
224+void printFourDecimals(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor)
225225 {
226226 if (value == 0)
227227 {
228− textOut(frameBuffer, x, y, "0000", fontColor);
228+ textOut(x, y, "0000", fontColor);
229229 }
230230 else
231231 {
232232 if (value > 9999)
233233 value = 9999;
234234
235− charOut(frameBuffer, x + (FONT_CHAR_W * 3), y, '0' + (value % 10), fontColor); value /= 10;
236− charOut(frameBuffer, x + (FONT_CHAR_W * 2), y, '0' + (value % 10), fontColor); value /= 10;
237− charOut(frameBuffer, x + (FONT_CHAR_W * 1), y, '0' + (value % 10), fontColor); value /= 10;
238− charOut(frameBuffer, x + (FONT_CHAR_W * 0), y, '0' + (value % 10), fontColor);
235+ charOut(x + (FONT_CHAR_W * 3), y, '0' + (value % 10), fontColor); value /= 10;
236+ charOut(x + (FONT_CHAR_W * 2), y, '0' + (value % 10), fontColor); value /= 10;
237+ charOut(x + (FONT_CHAR_W * 1), y, '0' + (value % 10), fontColor); value /= 10;
238+ charOut(x + (FONT_CHAR_W * 0), y, '0' + (value % 10), fontColor);
239239 }
240240 }
241241
242−void printFiveDecimals(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor)
242+void printFiveDecimals(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor)
243243 {
244244 if (value == 0)
245245 {
246− textOut(frameBuffer, x, y, "00000", fontColor);
246+ textOut(x, y, "00000", fontColor);
247247 }
248248 else
249249 {
250250 if (value > 99999)
251251 value = 99999;
252252
253− charOut(frameBuffer, x + (FONT_CHAR_W * 4), y, '0' + (value % 10), fontColor); value /= 10;
254− charOut(frameBuffer, x + (FONT_CHAR_W * 3), y, '0' + (value % 10), fontColor); value /= 10;
255− charOut(frameBuffer, x + (FONT_CHAR_W * 2), y, '0' + (value % 10), fontColor); value /= 10;
256− charOut(frameBuffer, x + (FONT_CHAR_W * 1), y, '0' + (value % 10), fontColor); value /= 10;
257− charOut(frameBuffer, x + (FONT_CHAR_W * 0), y, '0' + (value % 10), fontColor);
253+ charOut(x + (FONT_CHAR_W * 4), y, '0' + (value % 10), fontColor); value /= 10;
254+ charOut(x + (FONT_CHAR_W * 3), y, '0' + (value % 10), fontColor); value /= 10;
255+ charOut(x + (FONT_CHAR_W * 2), y, '0' + (value % 10), fontColor); value /= 10;
256+ charOut(x + (FONT_CHAR_W * 1), y, '0' + (value % 10), fontColor); value /= 10;
257+ charOut(x + (FONT_CHAR_W * 0), y, '0' + (value % 10), fontColor);
258258 }
259259 }
260260
261261 // this one is used for module size and sampler screen display length (zeroes are padded with space)
262−void printSixDecimals(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor)
262+void printSixDecimals(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor)
263263 {
264264 char numberText[7];
265265 uint8_t i;
266266
267267 if (value == 0)
268268 {
269− textOut(frameBuffer, x, y, " 0", fontColor);
269+ textOut(x, y, " 0", fontColor);
270270 }
271271 else
272272 {
@@ -285,177 +285,177 @@ void printSixDecimals(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t va · 12 unmodified lines
285285 while (numberText[i] == '0')
286286 numberText[i++] = ' ';
287287
288− textOut(frameBuffer, x, y, numberText, fontColor);
288+ textOut(x, y, numberText, fontColor);
289289 }
290290 }
291291
292−void printOneHex(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor)
292+void printOneHex(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor)
293293 {
294− charOut(frameBuffer, x, y, hexTable[value & 15], fontColor);
294+ charOut(x, y, hexTable[value & 15], fontColor);
295295 }
296296
297−void printOneHexBig(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor)
297+void printOneHexBig(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor)
298298 {
299− charOutBig(frameBuffer, x, y, hexTable[value & 15], fontColor);
299+ charOutBig(x, y, hexTable[value & 15], fontColor);
300300 }
301301
302−void printTwoHex(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor)
302+void printTwoHex(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor)
303303 {
304304 if (value == 0)
305305 {
306− textOut(frameBuffer, x, y, "00", fontColor);
306+ textOut(x, y, "00", fontColor);
307307 }
308308 else
309309 {
310310 value &= 0xFF;
311311
312− charOut(frameBuffer, x + (FONT_CHAR_W * 0), y, hexTable[value >> 4], fontColor);
313− charOut(frameBuffer, x + (FONT_CHAR_W * 1), y, hexTable[value & 15], fontColor);
312+ charOut(x + (FONT_CHAR_W * 0), y, hexTable[value >> 4], fontColor);
313+ charOut(x + (FONT_CHAR_W * 1), y, hexTable[value & 15], fontColor);
314314 }
315315 }
316316
317−void printTwoHexBig(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor)
317+void printTwoHexBig(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor)
318318 {
319319 if (value == 0)
320320 {
321− textOutBig(frameBuffer, x, y, "00", fontColor);
321+ textOutBig(x, y, "00", fontColor);
322322 }
323323 else
324324 {
325325 value &= 0xFF;
326326
327− charOutBig(frameBuffer, x + (FONT_CHAR_W * 0), y, hexTable[value >> 4], fontColor);
328− charOutBig(frameBuffer, x + (FONT_CHAR_W * 1), y, hexTable[value & 15], fontColor);
327+ charOutBig(x + (FONT_CHAR_W * 0), y, hexTable[value >> 4], fontColor);
328+ charOutBig(x + (FONT_CHAR_W * 1), y, hexTable[value & 15], fontColor);
329329 }
330330 }
331331
332−void printThreeHex(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor)
332+void printThreeHex(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor)
333333 {
334334 if (value == 0)
335335 {
336− textOut(frameBuffer, x, y, "000", fontColor);
336+ textOut(x, y, "000", fontColor);
337337 }
338338 else
339339 {
340340 value &= 0xFFF;
341341
342− charOut(frameBuffer, x + (FONT_CHAR_W * 0), y, hexTable[value >> 8], fontColor);
343− charOut(frameBuffer, x + (FONT_CHAR_W * 1), y, hexTable[(value & (15 << 4)) >> 4], fontColor);
344− charOut(frameBuffer, x + (FONT_CHAR_W * 2), y, hexTable[value & 15], fontColor);
342+ charOut(x + (FONT_CHAR_W * 0), y, hexTable[value >> 8], fontColor);
343+ charOut(x + (FONT_CHAR_W * 1), y, hexTable[(value & (15 << 4)) >> 4], fontColor);
344+ charOut(x + (FONT_CHAR_W * 2), y, hexTable[value & 15], fontColor);
345345 }
346346 }
347347
348−void printFourHex(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor)
348+void printFourHex(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor)
349349 {
350350 if (value == 0)
351351 {
352− textOut(frameBuffer, x, y, "0000", fontColor);
352+ textOut(x, y, "0000", fontColor);
353353 }
354354 else
355355 {
356356 value &= 0xFFFF;
357357
358− charOut(frameBuffer, x + (FONT_CHAR_W * 0), y, hexTable[value >> 12], fontColor);
359− charOut(frameBuffer, x + (FONT_CHAR_W * 1), y, hexTable[(value & (15 << 8)) >> 8], fontColor);
360− charOut(frameBuffer, x + (FONT_CHAR_W * 2), y, hexTable[(value & (15 << 4)) >> 4], fontColor);
361− charOut(frameBuffer, x + (FONT_CHAR_W * 3), y, hexTable[value & 15], fontColor);
358+ charOut(x + (FONT_CHAR_W * 0), y, hexTable[value >> 12], fontColor);
359+ charOut(x + (FONT_CHAR_W * 1), y, hexTable[(value & (15 << 8)) >> 8], fontColor);
360+ charOut(x + (FONT_CHAR_W * 2), y, hexTable[(value & (15 << 4)) >> 4], fontColor);
361+ charOut(x + (FONT_CHAR_W * 3), y, hexTable[value & 15], fontColor);
362362 }
363363 }
364364
365−void printFiveHex(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor)
365+void printFiveHex(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor)
366366 {
367367 if (value == 0)
368368 {
369− textOut(frameBuffer, x, y, "00000", fontColor);
369+ textOut(x, y, "00000", fontColor);
370370 }
371371 else
372372 {
373373 value &= 0xFFFFF;
374374
375− charOut(frameBuffer, x + (FONT_CHAR_W * 0), y, hexTable[value >> 16], fontColor);
376− charOut(frameBuffer, x + (FONT_CHAR_W * 1), y, hexTable[(value & (15 << 12)) >> 12], fontColor);
377− charOut(frameBuffer, x + (FONT_CHAR_W * 2), y, hexTable[(value & (15 << 8)) >> 8], fontColor);
378− charOut(frameBuffer, x + (FONT_CHAR_W * 3), y, hexTable[(value & (15 << 4)) >> 4], fontColor);
379− charOut(frameBuffer, x + (FONT_CHAR_W * 4), y, hexTable[value & 15], fontColor);
375+ charOut(x + (FONT_CHAR_W * 0), y, hexTable[value >> 16], fontColor);
376+ charOut(x + (FONT_CHAR_W * 1), y, hexTable[(value & (15 << 12)) >> 12], fontColor);
377+ charOut(x + (FONT_CHAR_W * 2), y, hexTable[(value & (15 << 8)) >> 8], fontColor);
378+ charOut(x + (FONT_CHAR_W * 3), y, hexTable[(value & (15 << 4)) >> 4], fontColor);
379+ charOut(x + (FONT_CHAR_W * 4), y, hexTable[value & 15], fontColor);
380380 }
381381 }
382382
383−void printTwoDecimalsBg(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor)
383+void printTwoDecimalsBg(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor)
384384 {
385385 if (value == 0)
386386 {
387− textOutBg(frameBuffer, x, y, "00", fontColor, backColor);
387+ textOutBg(x, y, "00", fontColor, backColor);
388388 }
389389 else
390390 {
391391 if (value > 99)
392392 value = 99;
393393
394− charOutBg(frameBuffer, x + (FONT_CHAR_W * 1), y, '0' + (value % 10), fontColor, backColor); value /= 10;
395− charOutBg(frameBuffer, x + (FONT_CHAR_W * 0), y, '0' + (value % 10), fontColor, backColor);
394+ charOutBg(x + (FONT_CHAR_W * 1), y, '0' + (value % 10), fontColor, backColor); value /= 10;
395+ charOutBg(x + (FONT_CHAR_W * 0), y, '0' + (value % 10), fontColor, backColor);
396396 }
397397 }
398398
399−void printTwoDecimalsBigBg(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor)
399+void printTwoDecimalsBigBg(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor)
400400 {
401401 if (value == 0)
402402 {
403− textOutBigBg(frameBuffer, x, y, "00", fontColor, backColor);
403+ textOutBigBg(x, y, "00", fontColor, backColor);
404404 }
405405 else
406406 {
407407 if (value > 99)
408408 value = 99;
409409
410− charOutBigBg(frameBuffer, x + (FONT_CHAR_W * 1), y, '0' + (value % 10), fontColor, backColor); value /= 10;
411− charOutBigBg(frameBuffer, x + (FONT_CHAR_W * 0), y, '0' + (value % 10), fontColor, backColor);
410+ charOutBigBg(x + (FONT_CHAR_W * 1), y, '0' + (value % 10), fontColor, backColor); value /= 10;
411+ charOutBigBg(x + (FONT_CHAR_W * 0), y, '0' + (value % 10), fontColor, backColor);
412412 }
413413 }
414414
415−void printThreeDecimalsBg(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor)
415+void printThreeDecimalsBg(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor)
416416 {
417417 if (value == 0)
418418 {
419− textOutBg(frameBuffer, x, y, "000", fontColor, backColor);
419+ textOutBg(x, y, "000", fontColor, backColor);
420420 }
421421 else
422422 {
423423 if (value > 999)
424424 value = 999;
425425
426− charOutBg(frameBuffer, x + (FONT_CHAR_W * 2), y, '0' + (value % 10), fontColor, backColor); value /= 10;
427− charOutBg(frameBuffer, x + (FONT_CHAR_W * 1), y, '0' + (value % 10), fontColor, backColor); value /= 10;
428− charOutBg(frameBuffer, x + (FONT_CHAR_W * 0), y, '0' + (value % 10), fontColor, backColor);
426+ charOutBg(x + (FONT_CHAR_W * 2), y, '0' + (value % 10), fontColor, backColor); value /= 10;
427+ charOutBg(x + (FONT_CHAR_W * 1), y, '0' + (value % 10), fontColor, backColor); value /= 10;
428+ charOutBg(x + (FONT_CHAR_W * 0), y, '0' + (value % 10), fontColor, backColor);
429429 }
430430 }
431431
432−void printFourDecimalsBg(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor)
432+void printFourDecimalsBg(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor)
433433 {
434434 if (value == 0)
435435 {
436− textOutBg(frameBuffer, x, y, "0000", fontColor, backColor);
436+ textOutBg(x, y, "0000", fontColor, backColor);
437437 }
438438 else
439439 {
440440 if (value > 9999)
441441 value = 9999;
442442
443− charOutBg(frameBuffer, x + (FONT_CHAR_W * 3), y, '0' + (value % 10), fontColor, backColor); value /= 10;
444− charOutBg(frameBuffer, x + (FONT_CHAR_W * 2), y, '0' + (value % 10), fontColor, backColor); value /= 10;
445− charOutBg(frameBuffer, x + (FONT_CHAR_W * 1), y, '0' + (value % 10), fontColor, backColor); value /= 10;
446− charOutBg(frameBuffer, x + (FONT_CHAR_W * 0), y, '0' + (value % 10), fontColor, backColor);
443+ charOutBg(x + (FONT_CHAR_W * 3), y, '0' + (value % 10), fontColor, backColor); value /= 10;
444+ charOutBg(x + (FONT_CHAR_W * 2), y, '0' + (value % 10), fontColor, backColor); value /= 10;
445+ charOutBg(x + (FONT_CHAR_W * 1), y, '0' + (value % 10), fontColor, backColor); value /= 10;
446+ charOutBg(x + (FONT_CHAR_W * 0), y, '0' + (value % 10), fontColor, backColor);
447447 }
448448 }
449449
450450 // this one is used for "DISP:" in the sampler screen (zeroes are padded with space)
451−void printFiveDecimalsBg(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor)
451+void printFiveDecimalsBg(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor)
452452 {
453453 char numberText[6];
454454 uint8_t i;
455455
456456 if (value == 0)
457457 {
458− textOutBg(frameBuffer, x, y, " 0", fontColor, backColor);
458+ textOutBg(x, y, " 0", fontColor, backColor);
459459 }
460460 else
461461 {
@@ -473,19 +473,19 @@ void printFiveDecimalsBg(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t · 11 unmodified lines
473473 while (numberText[i] == '0')
474474 numberText[i++] = ' ';
475475
476− textOutBg(frameBuffer, x, y, numberText, fontColor, backColor);
476+ textOutBg(x, y, numberText, fontColor, backColor);
477477 }
478478 }
479479
480480 // this one is used for module size (zeroes are padded with space)
481−void printSixDecimalsBg(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor)
481+void printSixDecimalsBg(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor)
482482 {
483483 char numberText[7];
484484 uint8_t i;
485485
486486 if (value == 0)
487487 {
488− textOutBg(frameBuffer, x, y, " 0", fontColor, backColor);
488+ textOutBg(x, y, " 0", fontColor, backColor);
489489 }
490490 else
491491 {
@@ -504,98 +504,98 @@ void printSixDecimalsBg(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t · 12 unmodified lines
504504 while (numberText[i] == '0')
505505 numberText[i++] = ' ';
506506
507− textOutBg(frameBuffer, x, y, numberText, fontColor, backColor);
507+ textOutBg(x, y, numberText, fontColor, backColor);
508508 }
509509 }
510510
511−void printOneHexBg(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor)
511+void printOneHexBg(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor)
512512 {
513− charOutBg(frameBuffer, x, y, hexTable[value & 0xF], fontColor, backColor);
513+ charOutBg(x, y, hexTable[value & 0xF], fontColor, backColor);
514514 }
515515
516−void printOneHexBigBg(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor)
516+void printOneHexBigBg(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor)
517517 {
518− charOutBigBg(frameBuffer, x, y, hexTable[value & 0xF], fontColor, backColor);
518+ charOutBigBg(x, y, hexTable[value & 0xF], fontColor, backColor);
519519 }
520520
521−void printTwoHexBg(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor)
521+void printTwoHexBg(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor)
522522 {
523523 if (value == 0)
524524 {
525− textOutBg(frameBuffer, x, y, "00", fontColor, backColor);
525+ textOutBg(x, y, "00", fontColor, backColor);
526526 }
527527 else
528528 {
529529 value &= 0xFF;
530530
531− charOutBg(frameBuffer, x + (FONT_CHAR_W * 0), y, hexTable[value >> 4], fontColor, backColor);
532− charOutBg(frameBuffer, x + (FONT_CHAR_W * 1), y, hexTable[value & 15], fontColor, backColor);
531+ charOutBg(x + (FONT_CHAR_W * 0), y, hexTable[value >> 4], fontColor, backColor);
532+ charOutBg(x + (FONT_CHAR_W * 1), y, hexTable[value & 15], fontColor, backColor);
533533 }
534534 }
535535
536−void printTwoHexBigBg(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor)
536+void printTwoHexBigBg(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor)
537537 {
538538 if (value == 0)
539539 {
540− textOutBigBg(frameBuffer, x, y, "00", fontColor, backColor);
540+ textOutBigBg(x, y, "00", fontColor, backColor);
541541 }
542542 else
543543 {
544544 value &= 0xFF;
545545
546− charOutBigBg(frameBuffer, x + (FONT_CHAR_W * 0), y, hexTable[value >> 4], fontColor, backColor);
547− charOutBigBg(frameBuffer, x + (FONT_CHAR_W * 1), y, hexTable[value & 15], fontColor, backColor);
546+ charOutBigBg(x + (FONT_CHAR_W * 0), y, hexTable[value >> 4], fontColor, backColor);
547+ charOutBigBg(x + (FONT_CHAR_W * 1), y, hexTable[value & 15], fontColor, backColor);
548548 }
549549 }
550550
551−void printThreeHexBg(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor)
551+void printThreeHexBg(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor)
552552 {
553553 if (value == 0)
554554 {
555− textOutBg(frameBuffer, x, y, "000", fontColor, backColor);
555+ textOutBg(x, y, "000", fontColor, backColor);
556556 }
557557 else
558558 {
559559 value &= 0xFFF;
560560
561− charOutBg(frameBuffer, x + (FONT_CHAR_W * 0), y, hexTable[value >> 8], fontColor, backColor);
562− charOutBg(frameBuffer, x + (FONT_CHAR_W * 1), y, hexTable[(value & (15 << 4)) >> 4], fontColor, backColor);
563− charOutBg(frameBuffer, x + (FONT_CHAR_W * 2), y, hexTable[value & 15], fontColor, backColor);
561+ charOutBg(x + (FONT_CHAR_W * 0), y, hexTable[value >> 8], fontColor, backColor);
562+ charOutBg(x + (FONT_CHAR_W * 1), y, hexTable[(value & (15 << 4)) >> 4], fontColor, backColor);
563+ charOutBg(x + (FONT_CHAR_W * 2), y, hexTable[value & 15], fontColor, backColor);
564564 }
565565 }
566566
567−void printFourHexBg(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor)
567+void printFourHexBg(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor)
568568 {
569569 if (value == 0)
570570 {
571− textOutBg(frameBuffer, x, y, "0000", fontColor, backColor);
571+ textOutBg(x, y, "0000", fontColor, backColor);
572572 }
573573 else
574574 {
575575 value &= 0xFFFF;
576576
577− charOutBg(frameBuffer, x + (FONT_CHAR_W * 0), y, hexTable[value >> 12], fontColor, backColor);
578− charOutBg(frameBuffer, x + (FONT_CHAR_W * 1), y, hexTable[(value & (15 << 8)) >> 8], fontColor, backColor);
579− charOutBg(frameBuffer, x + (FONT_CHAR_W * 2), y, hexTable[(value & (15 << 4)) >> 4], fontColor, backColor);
580− charOutBg(frameBuffer, x + (FONT_CHAR_W * 3), y, hexTable[value & 15], fontColor, backColor);
577+ charOutBg(x + (FONT_CHAR_W * 0), y, hexTable[value >> 12], fontColor, backColor);
578+ charOutBg(x + (FONT_CHAR_W * 1), y, hexTable[(value & (15 << 8)) >> 8], fontColor, backColor);
579+ charOutBg(x + (FONT_CHAR_W * 2), y, hexTable[(value & (15 << 4)) >> 4], fontColor, backColor);
580+ charOutBg(x + (FONT_CHAR_W * 3), y, hexTable[value & 15], fontColor, backColor);
581581 }
582582 }
583583
584−void printFiveHexBg(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor)
584+void printFiveHexBg(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor)
585585 {
586586 if (value == 0)
587587 {
588− textOutBg(frameBuffer, x, y, "00000", fontColor, backColor);
588+ textOutBg(x, y, "00000", fontColor, backColor);
589589 }
590590 else
591591 {
592592 value &= 0xFFFFF;
593593
594− charOutBg(frameBuffer, x + (FONT_CHAR_W * 0), y, hexTable[value >> 16], fontColor, backColor);
595− charOutBg(frameBuffer, x + (FONT_CHAR_W * 1), y, hexTable[(value & (15 << 12)) >> 12], fontColor, backColor);
596− charOutBg(frameBuffer, x + (FONT_CHAR_W * 2), y, hexTable[(value & (15 << 8)) >> 8], fontColor, backColor);
597− charOutBg(frameBuffer, x + (FONT_CHAR_W * 3), y, hexTable[(value & (15 << 4)) >> 4], fontColor, backColor);
598− charOutBg(frameBuffer, x + (FONT_CHAR_W * 4), y, hexTable[value & 15], fontColor, backColor);
594+ charOutBg(x + (FONT_CHAR_W * 0), y, hexTable[value >> 16], fontColor, backColor);
595+ charOutBg(x + (FONT_CHAR_W * 1), y, hexTable[(value & (15 << 12)) >> 12], fontColor, backColor);
596+ charOutBg(x + (FONT_CHAR_W * 2), y, hexTable[(value & (15 << 8)) >> 8], fontColor, backColor);
597+ charOutBg(x + (FONT_CHAR_W * 3), y, hexTable[(value & (15 << 4)) >> 4], fontColor, backColor);
598+ charOutBg(x + (FONT_CHAR_W * 4), y, hexTable[value & 15], fontColor, backColor);
599599 }
600600 }
601601
src/pt2_textout.h+35−35
@@ -3,41 +3,41 @@ · 2 unmodified lines
33 #include <stdint.h>
44 #include <stdbool.h>
55
6−void charOut(uint32_t *frameBuffer, uint32_t xPos, uint32_t yPos, char ch, uint32_t color);
7−void charOutBg(uint32_t *frameBuffer, uint32_t xPos, uint32_t yPos, char ch, uint32_t fgColor, uint32_t bgColor);
8−void charOutBig(uint32_t *frameBuffer, uint32_t xPos, uint32_t yPos, char ch, uint32_t color);
9−void charOutBigBg(uint32_t *frameBuffer, uint32_t xPos, uint32_t yPos, char ch, uint32_t fgColor, uint32_t bgColor);
10−void textOut(uint32_t *frameBuffer, uint32_t xPos, uint32_t yPos, const char *text, uint32_t color);
11−void textOutTight(uint32_t *frameBuffer, uint32_t xPos, uint32_t yPos, const char *text, uint32_t color);
12−void textOutBg(uint32_t *frameBuffer, uint32_t xPos, uint32_t yPos, const char *text, uint32_t fgColor, uint32_t bgColor);
13−void textOutBig(uint32_t *frameBuffer, uint32_t xPos, uint32_t yPos, const char *text, uint32_t color);
14−void textOutBigBg(uint32_t *frameBuffer, uint32_t xPos, uint32_t yPos, const char *text, uint32_t fgColor, uint32_t bgColor);
15−void printOneHex(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor);
16−void printTwoHex(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor);
17−void printThreeHex(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor);
18−void printFourHex(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor);
19−void printFiveHex(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor);
20−void printOneHexBig(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor);
21−void printTwoHexBig(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor);
22−void printSixDecimals(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor);
23−void printTwoDecimals(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor);
24−void printFourDecimals(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor);
25−void printFiveDecimals(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor);
26−void printThreeDecimals(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor);
27−void printTwoDecimalsBig(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor);
28−void printOneHexBg(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor);
29−void printTwoHexBg(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor);
30−void printThreeHexBg(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor);
31−void printFourHexBg(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor);
32−void printFiveHexBg(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor);
33−void printOneHexBigBg(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor);
34−void printTwoHexBigBg(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor);
35−void printSixDecimalsBg(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor);
36−void printTwoDecimalsBg(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor);
37−void printFourDecimalsBg(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor);
38−void printFiveDecimalsBg(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor);
39−void printThreeDecimalsBg(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor);
40−void printTwoDecimalsBigBg(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor);
6+void charOut(uint32_t xPos, uint32_t yPos, char ch, uint32_t color);
7+void charOutBg(uint32_t xPos, uint32_t yPos, char ch, uint32_t fgColor, uint32_t bgColor);
8+void charOutBig(uint32_t xPos, uint32_t yPos, char ch, uint32_t color);
9+void charOutBigBg(uint32_t xPos, uint32_t yPos, char ch, uint32_t fgColor, uint32_t bgColor);
10+void textOut(uint32_t xPos, uint32_t yPos, const char *text, uint32_t color);
11+void textOutTight(uint32_t xPos, uint32_t yPos, const char *text, uint32_t color);
12+void textOutBg(uint32_t xPos, uint32_t yPos, const char *text, uint32_t fgColor, uint32_t bgColor);
13+void textOutBig(uint32_t xPos, uint32_t yPos, const char *text, uint32_t color);
14+void textOutBigBg(uint32_t xPos, uint32_t yPos, const char *text, uint32_t fgColor, uint32_t bgColor);
15+void printOneHex(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor);
16+void printTwoHex(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor);
17+void printThreeHex(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor);
18+void printFourHex(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor);
19+void printFiveHex(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor);
20+void printOneHexBig(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor);
21+void printTwoHexBig(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor);
22+void printSixDecimals(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor);
23+void printTwoDecimals(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor);
24+void printFourDecimals(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor);
25+void printFiveDecimals(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor);
26+void printThreeDecimals(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor);
27+void printTwoDecimalsBig(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor);
28+void printOneHexBg(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor);
29+void printTwoHexBg(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor);
30+void printThreeHexBg(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor);
31+void printFourHexBg(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor);
32+void printFiveHexBg(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor);
33+void printOneHexBigBg(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor);
34+void printTwoHexBigBg(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor);
35+void printSixDecimalsBg(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor);
36+void printTwoDecimalsBg(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor);
37+void printFourDecimalsBg(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor);
38+void printFiveDecimalsBg(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor);
39+void printThreeDecimalsBg(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor);
40+void printTwoDecimalsBigBg(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor);
4141 void setPrevStatusMessage(void);
4242 void setStatusMessage(const char *msg, bool carry);
4343 void displayMsg(const char *msg);
src/pt2_visuals.c+395−322
@@ -40,24 +40,16 @@ typedef struct sprite_t · 39 unmodified lines
4040 {
4141 bool visible;
4242 int8_t pixelType;
43− uint16_t newX, newY, x, y, w, h;
43+ int16_t newX, newY, x, y, w, h;
4444 uint32_t colorKey, *refreshBuffer;
4545 const void *data;
4646 } sprite_t;
4747
4848 static uint32_t vuMetersBg[4 * (10 * 48)];
49−static uint64_t timeNext64, timeNext64Frac, _50HzCounter;
49+static uint64_t timeNext64, timeNext64Frac;
5050
5151 sprite_t sprites[SPRITE_NUM]; // globalized
5252
53−extern bool forceMixerOff; // pt_audio.c
54−
55−// pt_main.c
56−extern uint32_t *pixelBuffer;
57−extern SDL_Window *window;
58−extern SDL_Renderer *renderer;
59−extern SDL_Texture *texture;
60−
6153 static const uint16_t cursorPosTable[24] =
6254 {
6355 30, 54, 62, 70, 78, 86,
@@ -98,7 +90,7 @@ void setupPerfFreq(void) · 34 unmodified lines
9890 dFrac = modf(editor.dPerfFreq / VBLANK_HZ, &dInt);
9991
10092 // integer part
101− editor.vblankTimeLen = (uint32_t)dInt;
93+ editor.vblankTimeLen = (int32_t)dInt;
10294
10395 // fractional part scaled to 0..2^32-1
10496 dFrac *= UINT32_MAX;
@@ -156,7 +148,7 @@ void renderFrame(void) · 51 unmodified lines
156148 updateSampler();
157149 updatePosEd();
158150 updateVisualizer();
159− updateDragBars();
151+ handleLastGUIObjectDown();
160152 drawSamplerLine();
161153 }
162154
@@ -203,7 +195,7 @@ void renderAskDialog(void) · 40 unmodified lines
203195 // render ask dialog
204196
205197 srcPtr = editor.ui.pat2SmpDialogShown ? pat2SmpDialogBMP : yesNoDialogBMP;
206− dstPtr = &pixelBuffer[(51 * SCREEN_W) + 160];
198+ dstPtr = &video.frameBuffer[(51 * SCREEN_W) + 160];
207199
208200 for (uint32_t y = 0; y < 39; y++)
209201 {
@@ -225,7 +217,7 @@ void renderBigAskDialog(void) · 15 unmodified lines
225217 // render custom big ask dialog
226218
227219 srcPtr = bigYesNoDialogBMP;
228− dstPtr = &pixelBuffer[(44 * SCREEN_W) + 120];
220+ dstPtr = &video.frameBuffer[(44 * SCREEN_W) + 120];
229221
230222 for (uint32_t y = 0; y < 55; y++)
231223 {
@@ -244,10 +236,10 @@ void showDownsampleAskDialog(void) · 12 unmodified lines
244236 setStatusMessage("PLEASE SELECT", NO_CARRY);
245237 renderBigAskDialog();
246238
247− textOutTight(pixelBuffer, 133, 49, "THE SAMPLE'S FREQUENCY IS", palette[PAL_BACKGRD]);
248− textOutTight(pixelBuffer, 178, 57, "ABOVE 22KHZ.", palette[PAL_BACKGRD]);
249− textOutTight(pixelBuffer, 133, 65, "DO YOU WANT TO DOWNSAMPLE", palette[PAL_BACKGRD]);
250− textOutTight(pixelBuffer, 156, 73, "BEFORE LOADING IT?", palette[PAL_BACKGRD]);
239+ textOutTight(133, 49, "THE SAMPLE'S FREQUENCY IS", video.palette[PAL_BACKGRD]);
240+ textOutTight(178, 57, "ABOVE 22KHZ.", video.palette[PAL_BACKGRD]);
241+ textOutTight(133, 65, "DO YOU WANT TO DOWNSAMPLE", video.palette[PAL_BACKGRD]);
242+ textOutTight(156, 73, "BEFORE LOADING IT?", video.palette[PAL_BACKGRD]);
251243 }
252244
253245 static void fillFromVuMetersBgBuffer(void)
@@ -259,7 +251,7 @@ static void fillFromVuMetersBgBuffer(void) · 5 unmodified lines
259251 return;
260252
261253 srcPtr = vuMetersBg;
262− dstPtr = &pixelBuffer[(187 * SCREEN_W) + 55];
254+ dstPtr = &video.frameBuffer[(187 * SCREEN_W) + 55];
263255
264256 for (uint32_t i = 0; i < AMIGA_VOICES; i++)
265257 {
@@ -284,7 +276,7 @@ void fillToVuMetersBgBuffer(void) · 18 unmodified lines
284276 if (editor.ui.samplerScreenShown || editor.isWAVRendering || editor.isSMPRendering)
285277 return;
286278
287− srcPtr = &pixelBuffer[(187 * SCREEN_W) + 55];
279+ srcPtr = &video.frameBuffer[(187 * SCREEN_W) + 55];
288280 dstPtr = vuMetersBg;
289281
290282 for (uint32_t i = 0; i < AMIGA_VOICES; i++)
@@ -312,10 +304,10 @@ void renderVuMeters(void) · 21 unmodified lines
312304
313305 fillToVuMetersBgBuffer();
314306
315− dstPtr = &pixelBuffer[(187 * SCREEN_W) + 55];
307+ dstPtr = &video.frameBuffer[(187 * SCREEN_W) + 55];
316308 for (uint32_t i = 0; i < AMIGA_VOICES; i++)
317309 {
318− if (ptConfig.realVuMeters)
310+ if (config.realVuMeters)
319311 h = editor.realVuMeterVolumes[i];
320312 else
321313 h = editor.vuMeterVolumes[i];
@@ -349,20 +341,20 @@ void updateSongInfo1(void) // left side of screen, when Disk Op. is hidden · 27 unmodified lines
349341 if (editor.ui.updateSongPos)
350342 {
351343 editor.ui.updateSongPos = false;
352− printThreeDecimalsBg(pixelBuffer, 72, 3, *editor.currPosDisp, palette[PAL_GENTXT], palette[PAL_GENBKG]);
344+ printThreeDecimalsBg(72, 3, *editor.currPosDisp, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
353345 }
354346
355347 if (editor.ui.updateSongPattern)
356348 {
357349 editor.ui.updateSongPattern = false;
358− printTwoDecimalsBg(pixelBuffer, 80, 14, *editor.currPatternDisp, palette[PAL_GENTXT], palette[PAL_GENBKG]);
350+ printTwoDecimalsBg(80, 14, *editor.currPatternDisp, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
359351 }
360352
361353 if (editor.ui.updateSongLength)
362354 {
363355 editor.ui.updateSongLength = false;
364356 if (!editor.isWAVRendering)
365− printThreeDecimalsBg(pixelBuffer, 72, 25, *editor.currLengthDisp,palette[PAL_GENTXT], palette[PAL_GENBKG]);
357+ printThreeDecimalsBg(72, 25, *editor.currLengthDisp, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
366358 }
367359
368360 if (editor.ui.updateCurrSampleFineTune)
@@ -373,18 +365,18 @@ void updateSongInfo1(void) // left side of screen, when Disk Op. is hidden · 4 unmodified lines
373365 {
374366 if (currSample->fineTune >= 8)
375367 {
376− charOutBg(pixelBuffer, 80, 36, '-', palette[PAL_GENTXT], palette[PAL_GENBKG]);
377− charOutBg(pixelBuffer, 88, 36, '0' + (0x10 - (currSample->fineTune & 0xF)), palette[PAL_GENTXT], palette[PAL_GENBKG]);
368+ charOutBg(80, 36, '-', video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
369+ charOutBg(88, 36, '0' + (0x10 - (currSample->fineTune & 0xF)), video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
378370 }
379371 else if (currSample->fineTune > 0)
380372 {
381− charOutBg(pixelBuffer, 80, 36, '+', palette[PAL_GENTXT], palette[PAL_GENBKG]);
382− charOutBg(pixelBuffer, 88, 36, '0' + (currSample->fineTune & 0xF), palette[PAL_GENTXT], palette[PAL_GENBKG]);
373+ charOutBg(80, 36, '+', video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
374+ charOutBg(88, 36, '0' + (currSample->fineTune & 0xF), video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
383375 }
384376 else
385377 {
386− charOutBg(pixelBuffer, 80, 36, ' ', palette[PAL_GENBKG], palette[PAL_GENBKG]);
387− charOutBg(pixelBuffer, 88, 36, '0', palette[PAL_GENTXT], palette[PAL_GENBKG]);
378+ charOutBg(80, 36, ' ', video.palette[PAL_GENBKG], video.palette[PAL_GENBKG]);
379+ charOutBg(88, 36, '0', video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
388380 }
389381 }
390382 }
@@ -394,8 +386,8 @@ void updateSongInfo1(void) // left side of screen, when Disk Op. is hidden · 3 unmodified lines
394386 editor.ui.updateCurrSampleNum = false;
395387 if (!editor.isWAVRendering)
396388 {
397− printTwoHexBg(pixelBuffer, 80, 47,
398− editor.sampleZero ? 0 : ((*editor.currSampleDisp) + 1), palette[PAL_GENTXT], palette[PAL_GENBKG]);
389+ printTwoHexBg(80, 47,
390+ editor.sampleZero ? 0 : ((*editor.currSampleDisp) + 1), video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
399391 }
400392 }
401393
@@ -403,26 +395,26 @@ void updateSongInfo1(void) // left side of screen, when Disk Op. is hidden · 1 unmodified line
403395 {
404396 editor.ui.updateCurrSampleVolume = false;
405397 if (!editor.isWAVRendering)
406− printTwoHexBg(pixelBuffer, 80, 58, *currSample->volumeDisp, palette[PAL_GENTXT], palette[PAL_GENBKG]);
398+ printTwoHexBg(80, 58, *currSample->volumeDisp, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
407399 }
408400
409401 if (editor.ui.updateCurrSampleLength)
410402 {
411403 editor.ui.updateCurrSampleLength = false;
412404 if (!editor.isWAVRendering)
413− printFourHexBg(pixelBuffer, 64, 69, *currSample->lengthDisp, palette[PAL_GENTXT], palette[PAL_GENBKG]);
405+ printFourHexBg(64, 69, *currSample->lengthDisp, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
414406 }
415407
416408 if (editor.ui.updateCurrSampleRepeat)
417409 {
418410 editor.ui.updateCurrSampleRepeat = false;
419− printFourHexBg(pixelBuffer, 64, 80, *currSample->loopStartDisp, palette[PAL_GENTXT], palette[PAL_GENBKG]);
411+ printFourHexBg(64, 80, *currSample->loopStartDisp, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
420412 }
421413
422414 if (editor.ui.updateCurrSampleReplen)
423415 {
424416 editor.ui.updateCurrSampleReplen = false;
425− printFourHexBg(pixelBuffer, 64, 91, *currSample->loopLengthDisp, palette[PAL_GENTXT], palette[PAL_GENBKG]);
417+ printFourHexBg(64, 91, *currSample->loopLengthDisp, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
426418 }
427419 }
428420
@@ -437,30 +429,30 @@ void updateSongInfo2(void) // two middle rows of screen, always present · 8 unmodified lines
437429 editor.ui.updateStatusText = false;
438430
439431 // clear background
440− textOutBg(pixelBuffer, 88, 127, " ", palette[PAL_GENBKG], palette[PAL_GENBKG]);
432+ textOutBg(88, 127, " ", video.palette[PAL_GENBKG], video.palette[PAL_GENBKG]);
441433
442434 // render status text
443435 if (!editor.errorMsgActive && editor.blockMarkFlag && !editor.ui.askScreenShown
444436 && !editor.ui.clearScreenShown && !editor.swapChannelFlag)
445437 {
446− textOut(pixelBuffer, 88, 127, "MARK BLOCK", palette[PAL_GENTXT]);
447− charOut(pixelBuffer, 192, 127, '-', palette[PAL_GENTXT]);
438+ textOut(88, 127, "MARK BLOCK", video.palette[PAL_GENTXT]);
439+ charOut(192, 127, '-', video.palette[PAL_GENTXT]);
448440
449441 editor.blockToPos = modEntry->currRow;
450442 if (editor.blockFromPos >= editor.blockToPos)
451443 {
452− printTwoDecimals(pixelBuffer, 176, 127, editor.blockToPos, palette[PAL_GENTXT]);
453− printTwoDecimals(pixelBuffer, 200, 127, editor.blockFromPos, palette[PAL_GENTXT]);
444+ printTwoDecimals(176, 127, editor.blockToPos, video.palette[PAL_GENTXT]);
445+ printTwoDecimals(200, 127, editor.blockFromPos, video.palette[PAL_GENTXT]);
454446 }
455447 else
456448 {
457− printTwoDecimals(pixelBuffer, 176, 127, editor.blockFromPos, palette[PAL_GENTXT]);
458− printTwoDecimals(pixelBuffer, 200, 127, editor.blockToPos, palette[PAL_GENTXT]);
449+ printTwoDecimals(176, 127, editor.blockFromPos, video.palette[PAL_GENTXT]);
450+ printTwoDecimals(200, 127, editor.blockToPos, video.palette[PAL_GENTXT]);
459451 }
460452 }
461453 else
462454 {
463− textOut(pixelBuffer, 88, 127, editor.ui.statusMessage, palette[PAL_GENTXT]);
455+ textOut(88, 127, editor.ui.statusMessage, video.palette[PAL_GENTXT]);
464456 }
465457 }
466458
@@ -468,62 +460,62 @@ void updateSongInfo2(void) // two middle rows of screen, always present · 1 unmodified line
468460 {
469461 editor.ui.updateSongBPM = false;
470462 if (!editor.ui.samplerScreenShown)
471− printThreeDecimalsBg(pixelBuffer, 32, 123, modEntry->currBPM, palette[PAL_GENTXT], palette[PAL_GENBKG]);
463+ printThreeDecimalsBg(32, 123, modEntry->currBPM, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
472464 }
473465
474466 if (editor.ui.updateCurrPattText)
475467 {
476468 editor.ui.updateCurrPattText = false;
477469 if (!editor.ui.samplerScreenShown)
478− printTwoDecimalsBg(pixelBuffer, 8, 127, *editor.currEditPatternDisp, palette[PAL_GENTXT], palette[PAL_GENBKG]);
470+ printTwoDecimalsBg(8, 127, *editor.currEditPatternDisp, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
479471 }
480472
481473 if (editor.ui.updateTrackerFlags)
482474 {
483475 editor.ui.updateTrackerFlags = false;
484476
485− charOutBg(pixelBuffer, 1, 113, ' ', palette[PAL_GENTXT], palette[PAL_GENBKG]);
486− charOutBg(pixelBuffer, 8, 113, ' ', palette[PAL_GENTXT], palette[PAL_GENBKG]);
477+ charOutBg(1, 113, ' ', video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
478+ charOutBg(8, 113, ' ', video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
487479
488480 if (editor.autoInsFlag)
489481 {
490− charOut(pixelBuffer, 0, 113, 'I', palette[PAL_GENTXT]);
482+ charOut(0, 113, 'I', video.palette[PAL_GENTXT]);
491483
492484 // in Amiga PT, "auto insert" 9 means 0
493485 if (editor.autoInsSlot == 9)
494− charOut(pixelBuffer, 8, 113, '0', palette[PAL_GENTXT]);
486+ charOut(8, 113, '0', video.palette[PAL_GENTXT]);
495487 else
496− charOut(pixelBuffer, 8, 113, '1' + editor.autoInsSlot, palette[PAL_GENTXT]);
488+ charOut(8, 113, '1' + editor.autoInsSlot, video.palette[PAL_GENTXT]);
497489 }
498490
499− charOutBg(pixelBuffer, 1, 102, ' ', palette[PAL_GENTXT], palette[PAL_GENBKG]);
491+ charOutBg(1, 102, ' ', video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
500492 if (editor.metroFlag)
501− charOut(pixelBuffer, 0, 102, 'M', palette[PAL_GENTXT]);
493+ charOut(0, 102, 'M', video.palette[PAL_GENTXT]);
502494
503− charOutBg(pixelBuffer, 16, 102, ' ', palette[PAL_GENTXT], palette[PAL_GENBKG]);
495+ charOutBg(16, 102, ' ', video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
504496 if (editor.multiFlag)
505− charOut(pixelBuffer, 16, 102, 'M', palette[PAL_GENTXT]);
497+ charOut(16, 102, 'M', video.palette[PAL_GENTXT]);
506498
507− charOutBg(pixelBuffer, 24, 102, '0' + editor.editMoveAdd,palette[PAL_GENTXT], palette[PAL_GENBKG]);
499+ charOutBg(24, 102, '0' + editor.editMoveAdd, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
508500
509− charOutBg(pixelBuffer, 311, 128, ' ', palette[PAL_GENBKG], palette[PAL_GENBKG]);
501+ charOutBg(311, 128, ' ', video.palette[PAL_GENBKG], video.palette[PAL_GENBKG]);
510502 if (editor.pNoteFlag == 1)
511503 {
512− pixelBuffer[(129 * SCREEN_W) + 314] = palette[PAL_GENTXT];
513− pixelBuffer[(129 * SCREEN_W) + 315] = palette[PAL_GENTXT];
504+ video.frameBuffer[(129 * SCREEN_W) + 314] = video.palette[PAL_GENTXT];
505+ video.frameBuffer[(129 * SCREEN_W) + 315] = video.palette[PAL_GENTXT];
514506 }
515507 else if (editor.pNoteFlag == 2)
516508 {
517− pixelBuffer[(128 * SCREEN_W) + 314] = palette[PAL_GENTXT];
518− pixelBuffer[(128 * SCREEN_W) + 315] = palette[PAL_GENTXT];
519− pixelBuffer[(130 * SCREEN_W) + 314] = palette[PAL_GENTXT];
520− pixelBuffer[(130 * SCREEN_W) + 315] = palette[PAL_GENTXT];
509+ video.frameBuffer[(128 * SCREEN_W) + 314] = video.palette[PAL_GENTXT];
510+ video.frameBuffer[(128 * SCREEN_W) + 315] = video.palette[PAL_GENTXT];
511+ video.frameBuffer[(130 * SCREEN_W) + 314] = video.palette[PAL_GENTXT];
512+ video.frameBuffer[(130 * SCREEN_W) + 315] = video.palette[PAL_GENTXT];
521513 }
522514 }
523515
524516 // playback timer
525517
526− secs = ((editor.musicTime / 256) * 5) / 512;
518+ secs = ((editor.musicTime >> 8) * 5) >> 9;
527519 secs -= ((secs / 3600) * 3600);
528520
529521 if (secs <= 5999) // below 99 minutes 59 seconds
@@ -532,14 +524,14 @@ void updateSongInfo2(void) // two middle rows of screen, always present · 2 unmodified lines
532524 MI_TimeS = secs - (MI_TimeM * 60);
533525
534526 // xx:xx
535− printTwoDecimalsBg(pixelBuffer, 272, 102, MI_TimeM, palette[PAL_GENTXT], palette[PAL_GENBKG]);
536− printTwoDecimalsBg(pixelBuffer, 296, 102, MI_TimeS, palette[PAL_GENTXT], palette[PAL_GENBKG]);
527+ printTwoDecimalsBg(272, 102, MI_TimeM, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
528+ printTwoDecimalsBg(296, 102, MI_TimeS, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
537529 }
538530 else
539531 {
540532 // 99:59
541− printTwoDecimalsBg(pixelBuffer, 272, 102, 99, palette[PAL_GENTXT], palette[PAL_GENBKG]);
542− printTwoDecimalsBg(pixelBuffer, 296, 102, 59, palette[PAL_GENTXT], palette[PAL_GENBKG]);
533+ printTwoDecimalsBg(272, 102, 99, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
534+ printTwoDecimalsBg(296, 102, 59, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
543535 }
544536
545537 if (editor.ui.updateSongName)
@@ -551,7 +543,7 @@ void updateSongInfo2(void) // two middle rows of screen, always present · 5 unmodified lines
551543 if (tempChar == '\0')
552544 tempChar = '_';
553545
554− charOutBg(pixelBuffer, 104 + (x * FONT_CHAR_W), 102, tempChar, palette[PAL_GENTXT], palette[PAL_GENBKG]);
546+ charOutBg(104 + (x * FONT_CHAR_W), 102, tempChar, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
555547 }
556548 }
557549
@@ -566,7 +558,7 @@ void updateSongInfo2(void) // two middle rows of screen, always present · 8 unmodified lines
566558 if (tempChar == '\0')
567559 tempChar = '_';
568560
569− charOutBg(pixelBuffer, 104 + (x * FONT_CHAR_W), 113, tempChar, palette[PAL_GENTXT], palette[PAL_GENBKG]);
561+ charOutBg(104 + (x * FONT_CHAR_W), 113, tempChar, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
570562 }
571563 }
572564
@@ -575,7 +567,7 @@ void updateSongInfo2(void) // two middle rows of screen, always present · 2 unmodified lines
575567 editor.ui.updateSongSize = false;
576568
577569 // clear background
578− textOutBg(pixelBuffer, 264, 123, " ", palette[PAL_GENBKG], palette[PAL_GENBKG]);
570+ textOutBg(264, 123, " ", video.palette[PAL_GENBKG], video.palette[PAL_GENBKG]);
579571
580572 // calculate module length
581573 uint32_t totalSampleDataSize = 0;
@@ -592,19 +584,19 @@ void updateSongInfo2(void) // two middle rows of screen, always present · 10 unmodified lines
592584 uint32_t moduleSize = 2108 + (totalPatterns * 1024) + totalSampleDataSize;
593585 if (moduleSize > 999999)
594586 {
595− charOut(pixelBuffer, 304, 123, 'K', palette[PAL_GENTXT]);
596− printFourDecimals(pixelBuffer, 272, 123, moduleSize / 1000, palette[PAL_GENTXT]);
587+ charOut(304, 123, 'K', video.palette[PAL_GENTXT]);
588+ printFourDecimals(272, 123, moduleSize / 1000, video.palette[PAL_GENTXT]);
597589 }
598590 else
599591 {
600− printSixDecimals(pixelBuffer, 264, 123, moduleSize, palette[PAL_GENTXT]);
592+ printSixDecimals(264, 123, moduleSize, video.palette[PAL_GENTXT]);
601593 }
602594 }
603595
604596 if (editor.ui.updateSongTiming)
605597 {
606598 editor.ui.updateSongTiming = false;
607− textOutBg(pixelBuffer, 288, 130, (editor.timingMode == TEMPO_MODE_CIA) ? "CIA" : "VBL", palette[PAL_GENTXT], palette[PAL_GENBKG]);
599+ textOutBg(288, 130, (editor.timingMode == TEMPO_MODE_CIA) ? "CIA" : "VBL", video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
608600 }
609601 }
610602
@@ -626,11 +618,11 @@ void updateSampler(void) · 15 unmodified lines
626618 s = &modEntry->samples[editor.currSample];
627619
628620 // update 9xx offset
629− if (input.mouse.y >= 138 && input.mouse.y <= 201 && input.mouse.x >= 3 && input.mouse.x <= 316)
621+ if (mouse.y >= 138 && mouse.y <= 201 && mouse.x >= 3 && mouse.x <= 316)
630622 {
631623 if (!editor.ui.samplerVolBoxShown && !editor.ui.samplerFiltersBoxShown && s->length > 0)
632624 {
633− tmpSampleOffset = (scr2SmpPos(input.mouse.x-3) + (1 << 7)) >> 8; // rounded
625+ tmpSampleOffset = (scr2SmpPos(mouse.x-3) + (1 << 7)) >> 8; // rounded
634626 tmpSampleOffset = 0x900 + CLAMP(tmpSampleOffset, 0x00, 0xFF);
635627
636628 if (tmpSampleOffset != editor.ui.lastSampleOffset)
@@ -645,7 +637,7 @@ void updateSampler(void) · 8 unmodified lines
645637 if (editor.ui.update9xxPos)
646638 {
647639 editor.ui.update9xxPos = false;
648− printThreeHexBg(pixelBuffer, 288, 247, editor.ui.lastSampleOffset, palette[PAL_GENTXT], palette[PAL_GENBKG]);
640+ printThreeHexBg(288, 247, editor.ui.lastSampleOffset, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
649641 }
650642
651643 if (editor.ui.updateResampleNote)
@@ -655,14 +647,14 @@ void updateSampler(void) · 3 unmodified lines
655647 // show resample note
656648 if (editor.ui.changingSmpResample)
657649 {
658− textOutBg(pixelBuffer, 288, 236, "---", palette[PAL_GENTXT], palette[PAL_GENBKG]);
650+ textOutBg(288, 236, "---", video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
659651 }
660652 else
661653 {
662654 assert(editor.resampleNote < 36);
663− textOutBg(pixelBuffer, 288, 236,
664− ptConfig.accidental ? noteNames2[editor.resampleNote] : noteNames1[editor.resampleNote],
665− palette[PAL_GENTXT], palette[PAL_GENBKG]);
655+ textOutBg(288, 236,
656+ config.accidental ? noteNames2[editor.resampleNote] : noteNames1[editor.resampleNote],
657+ video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
666658 }
667659 }
668660
@@ -671,13 +663,13 @@ void updateSampler(void) · 2 unmodified lines
671663 if (editor.ui.updateVolFromText)
672664 {
673665 editor.ui.updateVolFromText = false;
674− printThreeDecimalsBg(pixelBuffer, 176, 157, *editor.vol1Disp, palette[PAL_GENTXT], palette[PAL_GENBKG]);
666+ printThreeDecimalsBg(176, 157, *editor.vol1Disp, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
675667 }
676668
677669 if (editor.ui.updateVolToText)
678670 {
679671 editor.ui.updateVolToText = false;
680− printThreeDecimalsBg(pixelBuffer, 176, 168, *editor.vol2Disp, palette[PAL_GENTXT], palette[PAL_GENBKG]);
672+ printThreeDecimalsBg(176, 168, *editor.vol2Disp, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
681673 }
682674 }
683675 else if (editor.ui.samplerFiltersBoxShown)
@@ -685,13 +677,13 @@ void updateSampler(void) · 1 unmodified line
685677 if (editor.ui.updateLPText)
686678 {
687679 editor.ui.updateLPText = false;
688− printFourDecimalsBg(pixelBuffer, 168, 157, *editor.lpCutOffDisp, palette[PAL_GENTXT], palette[PAL_GENBKG]);
680+ printFourDecimalsBg(168, 157, *editor.lpCutOffDisp, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
689681 }
690682
691683 if (editor.ui.updateHPText)
692684 {
693685 editor.ui.updateHPText = false;
694− printFourDecimalsBg(pixelBuffer, 168, 168, *editor.hpCutOffDisp, palette[PAL_GENTXT], palette[PAL_GENBKG]);
686+ printFourDecimalsBg(168, 168, *editor.hpCutOffDisp, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
695687 }
696688
697689 if (editor.ui.updateNormFlag)
@@ -699,9 +691,9 @@ void updateSampler(void) · 1 unmodified line
699691 editor.ui.updateNormFlag = false;
700692
701693 if (editor.normalizeFiltersFlag)
702− textOutBg(pixelBuffer, 208, 179, "YES", palette[PAL_GENTXT], palette[PAL_GENBKG]);
694+ textOutBg(208, 179, "YES", video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
703695 else
704− textOutBg(pixelBuffer, 208, 179, "NO ", palette[PAL_GENTXT], palette[PAL_GENBKG]);
696+ textOutBg(208, 179, "NO ", video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
705697 }
706698 }
707699 }
@@ -712,9 +704,9 @@ void showVolFromSlider(void) · 4 unmodified lines
712704
713705 sliderStart = ((editor.vol1 * 3) + 5) / 10;
714706 sliderEnd = sliderStart + 4;
715− pixel = palette[PAL_QADSCP];
716− bgPixel = palette[PAL_BACKGRD];
717− dstPtr = &pixelBuffer[(158 * SCREEN_W) + 105];
707+ pixel = video.palette[PAL_QADSCP];
708+ bgPixel = video.palette[PAL_BACKGRD];
709+ dstPtr = &video.frameBuffer[(158 * SCREEN_W) + 105];
718710
719711 for (uint32_t y = 0; y < 3; y++)
720712 {
@@ -736,9 +728,9 @@ void showVolToSlider(void) · 15 unmodified lines
736728
737729 sliderStart = ((editor.vol2 * 3) + 5) / 10;
738730 sliderEnd = sliderStart + 4;
739− pixel = palette[PAL_QADSCP];
740− bgPixel = palette[PAL_BACKGRD];
741− dstPtr = &pixelBuffer[(169 * SCREEN_W) + 105];
731+ pixel = video.palette[PAL_QADSCP];
732+ bgPixel = video.palette[PAL_BACKGRD];
733+ dstPtr = &video.frameBuffer[(169 * SCREEN_W) + 105];
742734
743735 for (uint32_t y = 0; y < 3; y++)
744736 {
@@ -760,7 +752,7 @@ void renderSamplerVolBox(void) · 15 unmodified lines
760752 uint32_t *dstPtr;
761753
762754 srcPtr = samplerVolumeBMP;
763− dstPtr = &pixelBuffer[(154 * SCREEN_W) + 72];
755+ dstPtr = &video.frameBuffer[(154 * SCREEN_W) + 72];
764756
765757 for (uint32_t y = 0; y < 33; y++)
766758 {
@@ -791,7 +783,7 @@ void renderSamplerFiltersBox(void) · 24 unmodified lines
791783 uint32_t *dstPtr;
792784
793785 srcPtr = samplerFiltersBMP;
794− dstPtr = &pixelBuffer[(154 * SCREEN_W) + 65];
786+ dstPtr = &video.frameBuffer[(154 * SCREEN_W) + 65];
795787
796788 for (uint32_t y = 0; y < 33; y++)
797789 {
@@ -801,8 +793,8 @@ void renderSamplerFiltersBox(void) · 3 unmodified lines
801793 dstPtr += SCREEN_W;
802794 }
803795
804− textOut(pixelBuffer, 200, 157, "HZ", palette[PAL_GENTXT]);
805− textOut(pixelBuffer, 200, 168, "HZ", palette[PAL_GENTXT]);
796+ textOut(200, 157, "HZ", video.palette[PAL_GENTXT]);
797+ textOut(200, 168, "HZ", video.palette[PAL_GENTXT]);
806798
807799 editor.ui.updateLPText = true;
808800 editor.ui.updateHPText = true;
@@ -820,7 +812,7 @@ void removeSamplerFiltersBox(void) · 11 unmodified lines
820812
821813 void renderDiskOpScreen(void)
822814 {
823− memcpy(pixelBuffer, diskOpScreenBMP, (99 * 320) * sizeof (int32_t));
815+ memcpy(video.frameBuffer, diskOpScreenBMP, (99 * 320) * sizeof (int32_t));
824816
825817 editor.ui.updateDiskOpPathText = true;
826818 editor.ui.updatePackText = true;
@@ -841,7 +833,7 @@ void updateDiskOp(void) · 14 unmodified lines
841833 if (editor.ui.updateDiskOpFileList)
842834 {
843835 editor.ui.updateDiskOpFileList = false;
844− diskOpRenderFileList(pixelBuffer);
836+ diskOpRenderFileList();
845837 }
846838
847839 if (editor.ui.updateLoadMode)
@@ -849,13 +841,13 @@ void updateDiskOp(void) · 1 unmodified line
849841 editor.ui.updateLoadMode = false;
850842
851843 // clear backgrounds
852− charOutBg(pixelBuffer, 147, 3, ' ', palette[PAL_GENBKG], palette[PAL_GENBKG]);
853− charOutBg(pixelBuffer, 147, 14, ' ', palette[PAL_GENBKG], palette[PAL_GENBKG]);
844+ charOutBg(147, 3, ' ', video.palette[PAL_GENBKG], video.palette[PAL_GENBKG]);
845+ charOutBg(147, 14, ' ', video.palette[PAL_GENBKG], video.palette[PAL_GENBKG]);
854846
855847 // draw load mode arrow
856848
857849 srcPtr = arrowBMP;
858− dstPtr = &pixelBuffer[(((11 * editor.diskop.mode) + 3) * SCREEN_W) + 148];
850+ dstPtr = &video.frameBuffer[(((11 * editor.diskop.mode) + 3) * SCREEN_W) + 148];
859851
860852 for (uint32_t y = 0; y < 5; y++)
861853 {
@@ -870,15 +862,15 @@ void updateDiskOp(void) · 8 unmodified lines
870862 if (editor.ui.updatePackText)
871863 {
872864 editor.ui.updatePackText = false;
873− textOutBg(pixelBuffer, 120, 3, editor.diskop.modPackFlg ? "ON " : "OFF", palette[PAL_GENTXT], palette[PAL_GENBKG]);
865+ textOutBg(120, 3, editor.diskop.modPackFlg ? "ON " : "OFF", video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
874866 }
875867
876868 if (editor.ui.updateSaveFormatText)
877869 {
878870 editor.ui.updateSaveFormatText = false;
879− if (editor.diskop.smpSaveType == DISKOP_SMP_WAV) textOutBg(pixelBuffer, 120, 14, "WAV", palette[PAL_GENTXT], palette[PAL_GENBKG]);
880− else if (editor.diskop.smpSaveType == DISKOP_SMP_IFF) textOutBg(pixelBuffer, 120, 14, "IFF", palette[PAL_GENTXT], palette[PAL_GENBKG]);
881− else if (editor.diskop.smpSaveType == DISKOP_SMP_RAW) textOutBg(pixelBuffer, 120, 14, "RAW", palette[PAL_GENTXT], palette[PAL_GENBKG]);
871+ if (editor.diskop.smpSaveType == DISKOP_SMP_WAV) textOutBg(120, 14, "WAV", video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
872+ else if (editor.diskop.smpSaveType == DISKOP_SMP_IFF) textOutBg(120, 14, "IFF", video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
873+ else if (editor.diskop.smpSaveType == DISKOP_SMP_RAW) textOutBg(120, 14, "RAW", video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
882874 }
883875
884876 if (editor.ui.updateDiskOpPathText)
@@ -892,7 +884,7 @@ void updateDiskOp(void) · 7 unmodified lines
892884 if (tmpChar == '\0')
893885 tmpChar = '_';
894886
895− charOutBg(pixelBuffer, 24 + (i * FONT_CHAR_W), 25, tmpChar, palette[PAL_GENTXT], palette[PAL_GENBKG]);
887+ charOutBg(24 + (i * FONT_CHAR_W), 25, tmpChar, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
896888 }
897889 }
898890 }
@@ -910,7 +902,7 @@ void updatePosEd(void) · 11 unmodified lines
910902
911903 if (!editor.ui.disablePosEd)
912904 {
913− bgPixel = palette[PAL_BACKGRD];
905+ bgPixel = video.palette[PAL_BACKGRD];
914906
915907 posEdPosition = modEntry->currOrder;
916908 if (posEdPosition > modEntry->head.orderCount-1)
@@ -921,15 +913,12 @@ void updatePosEd(void) · 4 unmodified lines
921913 {
922914 if (posEdPosition-(5-y) >= 0)
923915 {
924− printThreeDecimalsBg(pixelBuffer, 128, 23+(y*6),
925− posEdPosition-(5-y), palette[PAL_QADSCP], palette[PAL_BACKGRD]);
926−
927− printTwoDecimalsBg(pixelBuffer, 160, 23+(y*6), modEntry->head.order[posEdPosition-(5-y)],
928− palette[PAL_QADSCP], palette[PAL_BACKGRD]);
916+ printThreeDecimalsBg(128, 23+(y*6), posEdPosition-(5-y), video.palette[PAL_QADSCP], video.palette[PAL_BACKGRD]);
917+ printTwoDecimalsBg(160, 23+(y*6), modEntry->head.order[posEdPosition-(5-y)], video.palette[PAL_QADSCP], video.palette[PAL_BACKGRD]);
929918 }
930919 else
931920 {
932− dstPtr = &pixelBuffer[((23+(y*6)) * SCREEN_W) + 128];
921+ dstPtr = &video.frameBuffer[((23+(y*6)) * SCREEN_W) + 128];
933922 for (y2 = 0; y2 < 5; y2++)
934923 {
935924 for (x = 0; x < FONT_CHAR_W*22; x++)
@@ -941,23 +930,20 @@ void updatePosEd(void) · 5 unmodified lines
941930 }
942931
943932 // middle
944− printThreeDecimalsBg(pixelBuffer, 128, 53, posEdPosition, palette[PAL_GENTXT], palette[PAL_GENBKG]);
945− printTwoDecimalsBg(pixelBuffer, 160, 53, *editor.currPosEdPattDisp, palette[PAL_GENTXT], palette[PAL_GENBKG]);
933+ printThreeDecimalsBg(128, 53, posEdPosition, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
934+ printTwoDecimalsBg(160, 53, *editor.currPosEdPattDisp, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
946935
947936 // bottom six
948937 for (y = 0; y < 6; y++)
949938 {
950939 if (posEdPosition+y < modEntry->head.orderCount-1)
951940 {
952− printThreeDecimalsBg(pixelBuffer, 128, 59+(y*6), posEdPosition+(y+1),
953− palette[PAL_QADSCP], palette[PAL_BACKGRD]);
954−
955− printTwoDecimalsBg(pixelBuffer, 160, 59+(y*6), modEntry->head.order[posEdPosition+(y+1)],
956− palette[PAL_QADSCP], palette[PAL_BACKGRD]);
941+ printThreeDecimalsBg(128, 59+(y*6), posEdPosition+(y+1), video.palette[PAL_QADSCP], video.palette[PAL_BACKGRD]);
942+ printTwoDecimalsBg(160, 59+(y*6), modEntry->head.order[posEdPosition+(y+1)], video.palette[PAL_QADSCP], video.palette[PAL_BACKGRD]);
957943 }
958944 else
959945 {
960− dstPtr = &pixelBuffer[((59+(y*6)) * SCREEN_W) + 128];
946+ dstPtr = &video.frameBuffer[((59+(y*6)) * SCREEN_W) + 128];
961947 for (y2 = 0; y2 < 5; y2++)
962948 {
963949 for (x = 0; x < FONT_CHAR_W*22; x++)
@@ -980,7 +966,7 @@ void renderPosEdScreen(void) · 16 unmodified lines
980966 uint32_t *dstPtr;
981967
982968 srcPtr = posEdBMP;
983− dstPtr = &pixelBuffer[120];
969+ dstPtr = &video.frameBuffer[120];
984970
985971 for (uint32_t y = 0; y < 99; y++)
986972 {
@@ -999,7 +985,7 @@ void renderMuteButtons(void) · 12 unmodified lines
999985 if (editor.ui.diskOpScreenShown || editor.ui.posEdScreenShown)
1000986 return;
1001987
1002− dstPtr = &pixelBuffer[(3 * SCREEN_W) + 310];
988+ dstPtr = &video.frameBuffer[(3 * SCREEN_W) + 310];
1003989 for (uint32_t i = 0; i < AMIGA_VOICES; i++)
1004990 {
1005991 if (editor.muted[i])
@@ -1035,7 +1021,7 @@ void renderClearScreen(void) · 29 unmodified lines
10351021 editor.ui.disableVisualizer = true;
10361022
10371023 srcPtr = clearDialogBMP;
1038− dstPtr = &pixelBuffer[(51 * SCREEN_W) + 160];
1024+ dstPtr = &video.frameBuffer[(51 * SCREEN_W) + 160];
10391025
10401026 for (uint32_t y = 0; y < 39; y++)
10411027 {
@@ -1085,7 +1071,7 @@ void updatePatternData(void) · 43 unmodified lines
10851071 {
10861072 editor.ui.updatePatternData = false;
10871073 if (!editor.ui.samplerScreenShown)
1088− redrawPattern(pixelBuffer);
1074+ redrawPattern();
10891075 }
10901076 }
10911077
@@ -1096,13 +1082,13 @@ void removeTextEditMarker(void) · 4 unmodified lines
10961082 if (!editor.ui.editTextFlag)
10971083 return;
10981084
1099− dstPtr = &pixelBuffer[((editor.ui.lineCurY - 1) * SCREEN_W) + (editor.ui.lineCurX - 4)];
1085+ dstPtr = &video.frameBuffer[((editor.ui.lineCurY - 1) * SCREEN_W) + (editor.ui.lineCurX - 4)];
11001086
11011087 if (editor.ui.editObject == PTB_PE_PATT)
11021088 {
11031089 // position editor text editing
11041090
1105− pixel = palette[PAL_GENBKG2];
1091+ pixel = video.palette[PAL_GENBKG2];
11061092 for (uint32_t x = 0; x < 7; x++)
11071093 dstPtr[x] = pixel;
11081094
@@ -1114,7 +1100,7 @@ void removeTextEditMarker(void) · 5 unmodified lines
11141100 {
11151101 // all others
11161102
1117− pixel = palette[PAL_GENBKG];
1103+ pixel = video.palette[PAL_GENBKG];
11181104 for (uint32_t y = 0; y < 2; y++)
11191105 {
11201106 for (uint32_t x = 0; x < 7; x++)
@@ -1132,8 +1118,8 @@ void renderTextEditMarker(void) · 11 unmodified lines
11321118 if (!editor.ui.editTextFlag)
11331119 return;
11341120
1135− dstPtr = &pixelBuffer[((editor.ui.lineCurY - 1) * SCREEN_W) + (editor.ui.lineCurX - 4)];
1136− pixel = palette[PAL_TEXTMARK];
1121+ dstPtr = &video.frameBuffer[((editor.ui.lineCurY - 1) * SCREEN_W) + (editor.ui.lineCurX - 4)];
1122+ pixel = video.palette[PAL_TEXTMARK];
11371123
11381124 for (uint32_t y = 0; y < 2; y++)
11391125 {
@@ -1144,12 +1130,60 @@ void renderTextEditMarker(void) · 4 unmodified lines
11441130 }
11451131 }
11461132
1147−void updateDragBars(void)
1133+static void sendMouseButtonUpEvent(uint8_t button)
11481134 {
1149− if (editor.ui.sampleMarkingPos >= 0) samplerSamplePressed(MOUSE_BUTTON_HELD);
1150− if (editor.ui.forceSampleDrag) samplerBarPressed(MOUSE_BUTTON_HELD);
1151− if (editor.ui.forceSampleEdit) samplerEditSample(MOUSE_BUTTON_HELD);
1152− if (editor.ui.forceVolDrag) volBoxBarPressed(MOUSE_BUTTON_HELD);
1135+ SDL_Event event;
1136+
1137+ memset(&event, 0, sizeof (event));
1138+
1139+ event.type = SDL_MOUSEBUTTONUP;
1140+ event.button.button = button;
1141+
1142+ SDL_PushEvent(&event);
1143+}
1144+
1145+void handleLastGUIObjectDown(void)
1146+{
1147+ bool testMouseButtonRelease = false;
1148+
1149+ if (editor.ui.sampleMarkingPos >= 0)
1150+ {
1151+ samplerSamplePressed(MOUSE_BUTTON_HELD);
1152+ testMouseButtonRelease = true;
1153+ }
1154+
1155+ if (editor.ui.forceSampleDrag)
1156+ {
1157+ samplerBarPressed(MOUSE_BUTTON_HELD);
1158+ testMouseButtonRelease = true;
1159+ }
1160+
1161+ if (editor.ui.forceSampleEdit)
1162+ {
1163+ samplerEditSample(MOUSE_BUTTON_HELD);
1164+ testMouseButtonRelease = true;
1165+ }
1166+
1167+ if (editor.ui.forceVolDrag)
1168+ {
1169+ volBoxBarPressed(MOUSE_BUTTON_HELD);
1170+ testMouseButtonRelease = true;
1171+ }
1172+
1173+ /* Hack to send "mouse button up" events if we released the mouse button(s)
1174+ ** outside of the window...
1175+ */
1176+ if (testMouseButtonRelease)
1177+ {
1178+ if (mouse.x < 0 || mouse.x >= SCREEN_W || mouse.y < 0 || mouse.y >= SCREEN_H)
1179+ {
1180+ if (mouse.leftButtonPressed && !(mouse.buttonState & SDL_BUTTON_LMASK))
1181+ sendMouseButtonUpEvent(SDL_BUTTON_LEFT);
1182+
1183+ if (mouse.rightButtonPressed && !(mouse.buttonState & SDL_BUTTON_RMASK))
1184+ sendMouseButtonUpEvent(SDL_BUTTON_RIGHT);
1185+ }
1186+ }
11531187 }
11541188
11551189 void updateVisualizer(void)
@@ -1170,11 +1204,11 @@ void updateVisualizer(void) · 14 unmodified lines
11701204 {
11711205 // spectrum analyzer
11721206
1173− dstPtr = &pixelBuffer[(59 * SCREEN_W) + 129];
1207+ dstPtr = &video.frameBuffer[(59 * SCREEN_W) + 129];
11741208 for (uint32_t i = 0; i < SPECTRUM_BAR_NUM; i++)
11751209 {
11761210 srcPtr = spectrumAnaBMP;
1177− pixel = palette[PAL_GENBKG];
1211+ pixel = video.palette[PAL_GENBKG];
11781212
11791213 tmpVol = editor.spectrumVolumes[i];
11801214 if (tmpVol > SPECTRUM_BAR_HEIGHT)
@@ -1206,7 +1240,7 @@ void renderQuadrascopeBg(void) · 25 unmodified lines
12061240 uint32_t *dstPtr;
12071241
12081242 srcPtr = &trackerFrameBMP[(44 * SCREEN_W) + 120];
1209− dstPtr = &pixelBuffer[(44 * SCREEN_W) + 120];
1243+ dstPtr = &video.frameBuffer[(44 * SCREEN_W) + 120];
12101244
12111245 for (uint32_t y = 0; y < 55; y++)
12121246 {
@@ -1226,7 +1260,7 @@ void renderSpectrumAnalyzerBg(void) · 13 unmodified lines
12261260 uint32_t *dstPtr;
12271261
12281262 srcPtr = spectrumVisualsBMP;
1229− dstPtr = &pixelBuffer[(44 * SCREEN_W) + 120];
1263+ dstPtr = &video.frameBuffer[(44 * SCREEN_W) + 120];
12301264
12311265 for (uint32_t y = 0; y < 55; y++)
12321266 {
@@ -1247,7 +1281,7 @@ void renderAboutScreen(void) · 14 unmodified lines
12471281 return;
12481282
12491283 srcPtr = aboutScreenBMP;
1250− dstPtr = &pixelBuffer[(44 * SCREEN_W) + 120];
1284+ dstPtr = &video.frameBuffer[(44 * SCREEN_W) + 120];
12511285
12521286 for (uint32_t y = 0; y < 55; y++)
12531287 {
@@ -1261,7 +1295,7 @@ void renderAboutScreen(void) · 7 unmodified lines
12611295
12621296 sprintf(verString, "v%s", PROG_VER_STR);
12631297 verStringX = 260 + (((63 - ((uint32_t)strlen(verString) * (FONT_CHAR_W - 1))) + 1) / 2);
1264− textOutTight(pixelBuffer, verStringX, 67, verString, palette[PAL_GENBKG2]);
1298+ textOutTight(verStringX, 67, verString, video.palette[PAL_GENBKG2]);
12651299 }
12661300
12671301 void renderEditOpMode(void)
@@ -1297,7 +1331,7 @@ void renderEditOpMode(void) · 29 unmodified lines
12971331
12981332 // render it...
12991333
1300− dstPtr = &pixelBuffer[(47 * SCREEN_W) + 310];
1334+ dstPtr = &video.frameBuffer[(47 * SCREEN_W) + 310];
13011335 for (uint32_t y = 0; y < 6; y++)
13021336 {
13031337 for (uint32_t x = 0; x < 7; x++)
@@ -1324,7 +1358,7 @@ void renderEditOpScreen(void) · 20 unmodified lines
13241358 }
13251359
13261360 // render background
1327− dstPtr = &pixelBuffer[(44 * SCREEN_W) + 120];
1361+ dstPtr = &video.frameBuffer[(44 * SCREEN_W) + 120];
13281362 for (uint32_t y = 0; y < 55; y++)
13291363 {
13301364 memcpy(dstPtr, srcPtr, 200 * sizeof (int32_t));
@@ -1338,11 +1372,11 @@ void renderEditOpScreen(void) · 7 unmodified lines
13381372 // render text and content
13391373 if (editor.ui.editOpScreen == 0)
13401374 {
1341− textOut(pixelBuffer, 128, 47, " TRACK PATTERN ", palette[PAL_GENTXT]);
1375+ textOut(128, 47, " TRACK PATTERN ", video.palette[PAL_GENTXT]);
13421376 }
13431377 else if (editor.ui.editOpScreen == 1)
13441378 {
1345− textOut(pixelBuffer, 128, 47, " RECORD SAMPLES ", palette[PAL_GENTXT]);
1379+ textOut(128, 47, " RECORD SAMPLES ", video.palette[PAL_GENTXT]);
13461380
13471381 editor.ui.updateRecordText = true;
13481382 editor.ui.updateQuantizeText = true;
@@ -1354,8 +1388,8 @@ void renderEditOpScreen(void) · 5 unmodified lines
13541388 }
13551389 else if (editor.ui.editOpScreen == 2)
13561390 {
1357− textOut(pixelBuffer, 128, 47, " SAMPLE EDITOR ", palette[PAL_GENTXT]);
1358− charOut(pixelBuffer, 272, 91, '%', palette[PAL_GENTXT]); // for Volume text
1391+ textOut(128, 47, " SAMPLE EDITOR ", video.palette[PAL_GENTXT]);
1392+ charOut(272, 91, '%', video.palette[PAL_GENTXT]); // for Volume text
13591393
13601394 editor.ui.updatePosText = true;
13611395 editor.ui.updateModText = true;
@@ -1363,7 +1397,7 @@ void renderEditOpScreen(void) · 1 unmodified line
13631397 }
13641398 else if (editor.ui.editOpScreen == 3)
13651399 {
1366− textOut(pixelBuffer, 128, 47, " SAMPLE CHORD EDITOR ", palette[PAL_GENTXT]);
1400+ textOut(128, 47, " SAMPLE CHORD EDITOR ", video.palette[PAL_GENTXT]);
13671401
13681402 editor.ui.updateLengthText = true;
13691403 editor.ui.updateNote1Text = true;
@@ -1379,7 +1413,7 @@ void renderMOD2WAVDialog(void) · 9 unmodified lines
13791413 uint32_t *dstPtr;
13801414
13811415 srcPtr = mod2wavBMP;
1382− dstPtr = &pixelBuffer[(27 * SCREEN_W) + 64];
1416+ dstPtr = &video.frameBuffer[(27 * SCREEN_W) + 64];
13831417
13841418 for (uint32_t y = 0; y < 48; y++)
13851419 {
@@ -1431,9 +1465,9 @@ void updateMOD2WAVDialog(void) · 45 unmodified lines
14311465 percent = 100;
14321466
14331467 barLength = ((percent * 180) + 50) / 100;
1434− dstPtr = &pixelBuffer[(42 * SCREEN_W) + 70];
1435− pixel = palette[PAL_GENBKG2];
1436− bgPixel = palette[PAL_BORDER];
1468+ dstPtr = &video.frameBuffer[(42 * SCREEN_W) + 70];
1469+ pixel = video.palette[PAL_GENBKG2];
1470+ bgPixel = video.palette[PAL_BORDER];
14371471
14381472 for (int32_t y = 0; y < 11; y++)
14391473 {
@@ -1450,13 +1484,13 @@ void updateMOD2WAVDialog(void) · 10 unmodified lines
14501484 }
14511485
14521486 // render percentage
1453− pixel = palette[PAL_GENTXT];
1487+ pixel = video.palette[PAL_GENTXT];
14541488 if (percent > 99)
1455− printThreeDecimals(pixelBuffer, 144, 45, percent, pixel);
1489+ printThreeDecimals(144, 45, percent, pixel);
14561490 else
1457− printTwoDecimals(pixelBuffer, 152, 45, percent, pixel);
1491+ printTwoDecimals(152, 45, percent, pixel);
14581492
1459− charOut(pixelBuffer, 168, 45, '%', pixel);
1493+ charOut(168, 45, '%', pixel);
14601494 }
14611495 }
14621496 }
@@ -1471,44 +1505,43 @@ void updateEditOp(void) · 8 unmodified lines
14711505 if (editor.ui.updateRecordText)
14721506 {
14731507 editor.ui.updateRecordText = false;
1474− textOutBg(pixelBuffer, 176, 58, (editor.recordMode == RECORD_PATT) ? "PATT" : "SONG",
1475− palette[PAL_GENTXT], palette[PAL_GENBKG]);
1508+ textOutBg(176, 58, (editor.recordMode == RECORD_PATT) ? "PATT" : "SONG", video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
14761509 }
14771510
14781511 if (editor.ui.updateQuantizeText)
14791512 {
14801513 editor.ui.updateQuantizeText = false;
1481− printTwoDecimalsBg(pixelBuffer, 192, 69, *editor.quantizeValueDisp, palette[PAL_GENTXT], palette[PAL_GENBKG]);
1514+ printTwoDecimalsBg(192, 69, *editor.quantizeValueDisp, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
14821515 }
14831516
14841517 if (editor.ui.updateMetro1Text)
14851518 {
14861519 editor.ui.updateMetro1Text = false;
1487− printTwoDecimalsBg(pixelBuffer, 168, 80, *editor.metroSpeedDisp, palette[PAL_GENTXT], palette[PAL_GENBKG]);
1520+ printTwoDecimalsBg(168, 80, *editor.metroSpeedDisp, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
14881521 }
14891522
14901523 if (editor.ui.updateMetro2Text)
14911524 {
14921525 editor.ui.updateMetro2Text = false;
1493− printTwoDecimalsBg(pixelBuffer, 192, 80, *editor.metroChannelDisp, palette[PAL_GENTXT], palette[PAL_GENBKG]);
1526+ printTwoDecimalsBg(192, 80, *editor.metroChannelDisp, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
14941527 }
14951528
14961529 if (editor.ui.updateFromText)
14971530 {
14981531 editor.ui.updateFromText = false;
1499− printTwoHexBg(pixelBuffer, 264, 80, *editor.sampleFromDisp, palette[PAL_GENTXT], palette[PAL_GENBKG]);
1532+ printTwoHexBg(264, 80, *editor.sampleFromDisp, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
15001533 }
15011534
15021535 if (editor.ui.updateKeysText)
15031536 {
15041537 editor.ui.updateKeysText = false;
1505− textOutBg(pixelBuffer, 160, 91, editor.multiFlag ? "MULTI " : "SINGLE", palette[PAL_GENTXT], palette[PAL_GENBKG]);
1538+ textOutBg(160, 91, editor.multiFlag ? "MULTI " : "SINGLE", video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
15061539 }
15071540
15081541 if (editor.ui.updateToText)
15091542 {
15101543 editor.ui.updateToText = false;
1511− printTwoHexBg(pixelBuffer, 264, 91, *editor.sampleToDisp, palette[PAL_GENTXT], palette[PAL_GENBKG]);
1544+ printTwoHexBg(264, 91, *editor.sampleToDisp, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
15121545 }
15131546 }
15141547 else if (editor.ui.editOpScreen == 2)
@@ -1518,38 +1551,38 @@ void updateEditOp(void) · 3 unmodified lines
15181551 editor.ui.updateMixText = false;
15191552 if (editor.mixFlag)
15201553 {
1521− textOutBg(pixelBuffer, 128, 47, editor.mixText, palette[PAL_GENTXT], palette[PAL_GENBKG]);
1522− textOutBg(pixelBuffer, 248, 47, " ", palette[PAL_GENTXT], palette[PAL_GENBKG]);
1554+ textOutBg(128, 47, editor.mixText, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
1555+ textOutBg(248, 47, " ", video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
15231556 }
15241557 else
15251558 {
1526− textOutBg(pixelBuffer, 128, 47, " SAMPLE EDITOR ", palette[PAL_GENTXT], palette[PAL_GENBKG]);
1559+ textOutBg(128, 47, " SAMPLE EDITOR ", video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
15271560 }
15281561 }
15291562
15301563 if (editor.ui.updatePosText)
15311564 {
15321565 editor.ui.updatePosText = false;
1533− printFourHexBg(pixelBuffer, 248, 58, *editor.samplePosDisp, palette[PAL_GENTXT], palette[PAL_GENBKG]);
1566+ printFourHexBg(248, 58, *editor.samplePosDisp, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
15341567 }
15351568
15361569 if (editor.ui.updateModText)
15371570 {
15381571 editor.ui.updateModText = false;
1539− printThreeDecimalsBg(pixelBuffer, 256, 69,
1572+ printThreeDecimalsBg(256, 69,
15401573 (editor.modulateSpeed < 0) ? (0 - editor.modulateSpeed) : editor.modulateSpeed,
1541− palette[PAL_GENTXT], palette[PAL_GENBKG]);
1574+ video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
15421575
15431576 if (editor.modulateSpeed < 0)
1544− charOutBg(pixelBuffer, 248, 69, '-', palette[PAL_GENTXT], palette[PAL_GENBKG]);
1577+ charOutBg(248, 69, '-', video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
15451578 else
1546− charOutBg(pixelBuffer, 248, 69, ' ', palette[PAL_GENTXT], palette[PAL_GENBKG]);
1579+ charOutBg(248, 69, ' ', video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
15471580 }
15481581
15491582 if (editor.ui.updateVolText)
15501583 {
15511584 editor.ui.updateVolText = false;
1552− printThreeDecimalsBg(pixelBuffer, 248, 91, *editor.sampleVolDisp, palette[PAL_GENTXT], palette[PAL_GENBKG]);
1585+ printThreeDecimalsBg(248, 91, *editor.sampleVolDisp, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
15531586 }
15541587 }
15551588 else if (editor.ui.editOpScreen == 3)
@@ -1559,17 +1592,17 @@ void updateEditOp(void) · 3 unmodified lines
15591592 editor.ui.updateLengthText = false;
15601593
15611594 // clear background
1562− textOutBg(pixelBuffer, 168, 91, " ", palette[PAL_GENTXT], palette[PAL_GENBKG]);
1563− charOut(pixelBuffer, 198, 91, ':', palette[PAL_GENBKG]);
1595+ textOutBg(168, 91, " ", video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
1596+ charOut(198, 91, ':', video.palette[PAL_GENBKG]);
15641597
15651598 if (modEntry->samples[editor.currSample].loopLength > 2 || modEntry->samples[editor.currSample].loopStart >= 2)
15661599 {
1567− textOut(pixelBuffer, 168, 91, "LOOP", palette[PAL_GENTXT]);
1600+ textOut(168, 91, "LOOP", video.palette[PAL_GENTXT]);
15681601 }
15691602 else
15701603 {
1571− printFourHex(pixelBuffer, 168, 91, *editor.chordLengthDisp, palette[PAL_GENTXT]); // CHORD MAX LENGTH
1572− charOut(pixelBuffer, 198, 91, (editor.chordLengthMin) ? '.' : ':', palette[PAL_GENTXT]); // MIN/MAX FLAG
1604+ printFourHex(168, 91, *editor.chordLengthDisp, video.palette[PAL_GENTXT]); // chord max length
1605+ charOut(198, 91, (editor.chordLengthMin) ? '.' : ':', video.palette[PAL_GENTXT]); // min/max flag
15731606 }
15741607 }
15751608
@@ -1577,40 +1610,40 @@ void updateEditOp(void) · 1 unmodified line
15771610 {
15781611 editor.ui.updateNote1Text = false;
15791612 if (editor.note1 > 35)
1580− textOutBg(pixelBuffer, 256, 58, "---", palette[PAL_GENTXT], palette[PAL_GENBKG]);
1613+ textOutBg(256, 58, "---", video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
15811614 else
1582− textOutBg(pixelBuffer, 256, 58, ptConfig.accidental ? noteNames2[editor.note1] : noteNames1[editor.note1],
1583− palette[PAL_GENTXT], palette[PAL_GENBKG]);
1615+ textOutBg(256, 58, config.accidental ? noteNames2[editor.note1] : noteNames1[editor.note1],
1616+ video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
15841617 }
15851618
15861619 if (editor.ui.updateNote2Text)
15871620 {
15881621 editor.ui.updateNote2Text = false;
15891622 if (editor.note2 > 35)
1590− textOutBg(pixelBuffer, 256, 69, "---", palette[PAL_GENTXT], palette[PAL_GENBKG]);
1623+ textOutBg(256, 69, "---", video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
15911624 else
1592− textOutBg(pixelBuffer, 256, 69, ptConfig.accidental ? noteNames2[editor.note2] : noteNames1[editor.note2],
1593− palette[PAL_GENTXT], palette[PAL_GENBKG]);
1625+ textOutBg(256, 69, config.accidental ? noteNames2[editor.note2] : noteNames1[editor.note2],
1626+ video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
15941627 }
15951628
15961629 if (editor.ui.updateNote3Text)
15971630 {
15981631 editor.ui.updateNote3Text = false;
15991632 if (editor.note3 > 35)
1600− textOutBg(pixelBuffer, 256, 80, "---", palette[PAL_GENTXT], palette[PAL_GENBKG]);
1633+ textOutBg(256, 80, "---", video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
16011634 else
1602− textOutBg(pixelBuffer, 256, 80, ptConfig.accidental ? noteNames2[editor.note3] : noteNames1[editor.note3],
1603− palette[PAL_GENTXT], palette[PAL_GENBKG]);
1635+ textOutBg(256, 80, config.accidental ? noteNames2[editor.note3] : noteNames1[editor.note3],
1636+ video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
16041637 }
16051638
16061639 if (editor.ui.updateNote4Text)
16071640 {
16081641 editor.ui.updateNote4Text = false;
16091642 if (editor.note4 > 35)
1610− textOutBg(pixelBuffer, 256, 91, "---", palette[PAL_GENTXT], palette[PAL_GENBKG]);
1643+ textOutBg(256, 91, "---", video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
16111644 else
1612− textOutBg(pixelBuffer, 256, 91, ptConfig.accidental ? noteNames2[editor.note4] : noteNames1[editor.note4],
1613− palette[PAL_GENTXT], palette[PAL_GENBKG]);
1645+ textOutBg(256, 91, config.accidental ? noteNames2[editor.note4] : noteNames1[editor.note4],
1646+ video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
16141647 }
16151648 }
16161649 }
@@ -1640,14 +1673,14 @@ void displayMainScreen(void) · 23 unmodified lines
16401673 if (editor.ui.samplerScreenShown)
16411674 {
16421675 if (!editor.ui.diskOpScreenShown)
1643− memcpy(pixelBuffer, trackerFrameBMP, 320 * 121 * sizeof (int32_t));
1676+ memcpy(video.frameBuffer, trackerFrameBMP, 320 * 121 * sizeof (int32_t));
16441677 }
16451678 else
16461679 {
16471680 if (!editor.ui.diskOpScreenShown)
1648− memcpy(pixelBuffer, trackerFrameBMP, 320 * 255 * sizeof (int32_t));
1681+ memcpy(video.frameBuffer, trackerFrameBMP, 320 * 255 * sizeof (int32_t));
16491682 else
1650− memcpy(&pixelBuffer[121 * SCREEN_W], &trackerFrameBMP[121 * SCREEN_W], 320 * 134 * sizeof (int32_t));
1683+ memcpy(&video.frameBuffer[121 * SCREEN_W], &trackerFrameBMP[121 * SCREEN_W], 320 * 134 * sizeof (int32_t));
16511684
16521685 editor.ui.updateSongBPM = true;
16531686 editor.ui.updateCurrPattText = true;
@@ -1665,14 +1698,14 @@ void displayMainScreen(void) · 11 unmodified lines
16651698 editor.ui.updateSongLength = true;
16661699
16671700 // zeroes (can't integrate zeroes in the graphics, the palette entry is above the 2-bit range)
1668− charOut(pixelBuffer, 64, 3, '0', palette[PAL_GENTXT]);
1669− textOut(pixelBuffer, 64, 14, "00", palette[PAL_GENTXT]);
1701+ charOut(64, 3, '0', video.palette[PAL_GENTXT]);
1702+ textOut(64, 14, "00", video.palette[PAL_GENTXT]);
16701703
16711704 if (!editor.isWAVRendering)
16721705 {
1673− charOut(pixelBuffer, 64, 25, '0', palette[PAL_GENTXT]);
1674− textOut(pixelBuffer, 64, 47, "00", palette[PAL_GENTXT]);
1675− textOut(pixelBuffer, 64, 58, "00", palette[PAL_GENTXT]);
1706+ charOut(64, 25, '0', video.palette[PAL_GENTXT]);
1707+ textOut(64, 47, "00", video.palette[PAL_GENTXT]);
1708+ textOut(64, 58, "00", video.palette[PAL_GENTXT]);
16761709 }
16771710
16781711 if (editor.ui.posEdScreenShown)
@@ -2167,7 +2200,7 @@ void createBitmaps(void) · 488 unmodified lines
21672200 uint16_t pixel12;
21682201 uint32_t i, j, x, y, pixel24;
21692202
2170− pixel24 = palette[PAL_PATCURSOR];
2203+ pixel24 = video.palette[PAL_PATCURSOR];
21712204 for (y = 0; y < 14; y++)
21722205 {
21732206 // top two rows have a lighter color
@@ -2202,7 +2235,7 @@ void createBitmaps(void) · 28 unmodified lines
22022235 patternCursorBMP[(y * 11) + 0] = pixel24;
22032236
22042237 for (x = 1; x < 10; x++)
2205− patternCursorBMP[(y * 11) + x] = palette[PAL_COLORKEY];
2238+ patternCursorBMP[(y * 11) + x] = video.palette[PAL_COLORKEY];
22062239
22072240 patternCursorBMP[(y * 11) + 10] = pixel24;
22082241 }
@@ -2299,7 +2332,7 @@ void createBitmaps(void) · 90 unmodified lines
22992332 vuMeterBMP[(i * 10) + 9] = pixel24;
23002333 }
23012334
2302− for (i = 0; i < 30; i++) arrowBMP[i] = palette[arrowPaletteBMP[i]];
2335+ for (i = 0; i < 30; i++) arrowBMP[i] = video.palette[arrowPaletteBMP[i]];
23032336 for (i = 0; i < 64; i++) samplingPosBMP[i] = samplingPosBMP[i];
23042337 for (i = 0; i < 512; i++) loopPinsBMP[i] = loopPinsBMP[i];
23052338 }
@@ -2379,19 +2412,19 @@ uint32_t *unpackBMP(const uint8_t *src, uint32_t packedLen) · 73 unmodified lines
23792412 {
23802413 byteIn = (tmpBuffer[i] & 0xC0) >> 6;
23812414 assert(byteIn < PALETTE_NUM);
2382− dst[(i * 4) + 0] = palette[byteIn];
2415+ dst[(i * 4) + 0] = video.palette[byteIn];
23832416
23842417 byteIn = (tmpBuffer[i] & 0x30) >> 4;
23852418 assert(byteIn < PALETTE_NUM);
2386− dst[(i * 4) + 1] = palette[byteIn];
2419+ dst[(i * 4) + 1] = video.palette[byteIn];
23872420
23882421 byteIn = (tmpBuffer[i] & 0x0C) >> 2;
23892422 assert(byteIn < PALETTE_NUM);
2390− dst[(i * 4) + 2] = palette[byteIn];
2423+ dst[(i * 4) + 2] = video.palette[byteIn];
23912424
23922425 byteIn = (tmpBuffer[i] & 0x03) >> 0;
23932426 assert(byteIn < PALETTE_NUM);
2394− dst[(i * 4) + 3] = palette[byteIn];
2427+ dst[(i * 4) + 3] = video.palette[byteIn];
23952428 }
23962429
23972430 free(tmpBuffer);
@@ -2440,10 +2473,10 @@ bool unpackBMPs(void) · 42 unmodified lines
24402473
24412474 void videoClose(void)
24422475 {
2443− SDL_DestroyTexture(texture);
2444− SDL_DestroyRenderer(renderer);
2445− SDL_DestroyWindow(window);
2446− free(pixelBuffer);
2476+ SDL_DestroyTexture(video.texture);
2477+ SDL_DestroyRenderer(video.renderer);
2478+ SDL_DestroyWindow(video.window);
2479+ free(video.frameBufferUnaligned);
24472480 }
24482481
24492482 void setupSprites(void)
@@ -2459,28 +2492,28 @@ void setupSprites(void) · 9 unmodified lines
24592492
24602493 sprites[SPRITE_PATTERN_CURSOR].data = patternCursorBMP;
24612494 sprites[SPRITE_PATTERN_CURSOR].pixelType = SPRITE_TYPE_RGB;
2462− sprites[SPRITE_PATTERN_CURSOR].colorKey = palette[PAL_COLORKEY];
2495+ sprites[SPRITE_PATTERN_CURSOR].colorKey = video.palette[PAL_COLORKEY];
24632496 sprites[SPRITE_PATTERN_CURSOR].w = 11;
24642497 sprites[SPRITE_PATTERN_CURSOR].h = 14;
24652498 hideSprite(SPRITE_PATTERN_CURSOR);
24662499
24672500 sprites[SPRITE_LOOP_PIN_LEFT].data = loopPinsBMP;
24682501 sprites[SPRITE_LOOP_PIN_LEFT].pixelType = SPRITE_TYPE_RGB;
2469− sprites[SPRITE_LOOP_PIN_LEFT].colorKey = palette[PAL_COLORKEY];
2502+ sprites[SPRITE_LOOP_PIN_LEFT].colorKey = video.palette[PAL_COLORKEY];
24702503 sprites[SPRITE_LOOP_PIN_LEFT].w = 4;
24712504 sprites[SPRITE_LOOP_PIN_LEFT].h = 64;
24722505 hideSprite(SPRITE_LOOP_PIN_LEFT);
24732506
24742507 sprites[SPRITE_LOOP_PIN_RIGHT].data = &loopPinsBMP[4 * 64];
24752508 sprites[SPRITE_LOOP_PIN_RIGHT].pixelType = SPRITE_TYPE_RGB;
2476− sprites[SPRITE_LOOP_PIN_RIGHT].colorKey = palette[PAL_COLORKEY];
2509+ sprites[SPRITE_LOOP_PIN_RIGHT].colorKey = video.palette[PAL_COLORKEY];
24772510 sprites[SPRITE_LOOP_PIN_RIGHT].w = 4;
24782511 sprites[SPRITE_LOOP_PIN_RIGHT].h = 64;
24792512 hideSprite(SPRITE_LOOP_PIN_RIGHT);
24802513
24812514 sprites[SPRITE_SAMPLING_POS_LINE].data = samplingPosBMP;
24822515 sprites[SPRITE_SAMPLING_POS_LINE].pixelType = SPRITE_TYPE_RGB;
2483− sprites[SPRITE_SAMPLING_POS_LINE].colorKey = palette[PAL_COLORKEY];
2516+ sprites[SPRITE_SAMPLING_POS_LINE].colorKey = video.palette[PAL_COLORKEY];
24842517 sprites[SPRITE_SAMPLING_POS_LINE].w = 1;
24852518 sprites[SPRITE_SAMPLING_POS_LINE].h = 64;
24862519 hideSprite(SPRITE_SAMPLING_POS_LINE);
@@ -2509,7 +2542,7 @@ void hideSprite(uint8_t sprite) · 22 unmodified lines
25092542
25102543 void eraseSprites(void)
25112544 {
2512− int32_t sw, sh, srcPitch, dstPitch;
2545+ int32_t sx, sy, x, y, sw, sh, srcPitch, dstPitch;
25132546 const uint32_t *src32;
25142547 uint32_t *dst32;
25152548 sprite_t *s;
@@ -2517,26 +2550,43 @@ void eraseSprites(void) · 1 unmodified line
25172550 for (int32_t i = SPRITE_NUM-1; i >= 0; i--) // erasing must be done in reverse order
25182551 {
25192552 s = &sprites[i];
2520− if (s->x >= SCREEN_W) // sprite is hidden, don't erase
2553+ if (s->x >= SCREEN_W || s->y >= SCREEN_H) // sprite is hidden, don't draw nor fill clear buffer
25212554 continue;
25222555
2523− assert(s->x >= 0 && s->y >= 0 && s->refreshBuffer != NULL);
2556+ assert(s->refreshBuffer != NULL);
25242557
25252558 sw = s->w;
25262559 sh = s->h;
2527− dst32 = &pixelBuffer[(s->y * SCREEN_W) + s->x];
2560+ sx = s->x;
2561+ sy = s->y;
2562+
2563+ // if x is negative, adjust variables
2564+ if (sx < 0)
2565+ {
2566+ sw += sx; // subtraction
2567+ sx = 0;
2568+ }
2569+
2570+ // if y is negative, adjust variables
2571+ if (sy < 0)
2572+ {
2573+ sh += sy; // subtraction
2574+ sy = 0;
2575+ }
2576+
2577+ dst32 = &video.frameBuffer[(sy * SCREEN_W) + sx];
25282578 src32 = s->refreshBuffer;
25292579
2530− // handle xy clipping
2531− if (s->y+sh >= SCREEN_H) sh = SCREEN_H - s->y;
2532− if (s->x+sw >= SCREEN_W) sw = SCREEN_W - s->x;
2580+ // handle x/y clipping
2581+ if (sx+sw >= SCREEN_W) sw = SCREEN_W - sx;
2582+ if (sy+sh >= SCREEN_H) sh = SCREEN_H - sy;
25332583
25342584 srcPitch = s->w - sw;
25352585 dstPitch = SCREEN_W - sw;
25362586
2537− for (int32_t y = 0; y < sh; y++)
2587+ for (y = 0; y < sh; y++)
25382588 {
2539− for (int32_t x = 0; x < sw; x++)
2589+ for (x = 0; x < sw; x++)
25402590 *dst32++ = *src32++;
25412591
25422592 src32 += srcPitch;
@@ -2550,10 +2600,9 @@ void eraseSprites(void) · 7 unmodified lines
25502600 void renderSprites(void)
25512601 {
25522602 const uint8_t *src8;
2553− int32_t x, y, sw, sh, srcPitch, dstPitch;
2603+ int32_t sx, sy, x, y, srcPtrBias, sw, sh, srcPitch, dstPitch;
25542604 const uint32_t *src32;
2555− uint32_t *dst32, *clr32;
2556− register uint32_t colorKey;
2605+ uint32_t *dst32, *clr32, colorKey;
25572606 sprite_t *s;
25582607
25592608 renderVuMeters(); // let's put it here even though it's not sprite-based
@@ -2566,19 +2615,39 @@ void renderSprites(void) · 6 unmodified lines
25662615 s->x = s->newX;
25672616 s->y = s->newY;
25682617
2569− if (s->x >= SCREEN_W) // sprite is hidden, don't draw nor fill clear buffer
2618+ if (s->x >= SCREEN_W || s->y >= SCREEN_H) // sprite is hidden, don't draw nor fill clear buffer
25702619 continue;
25712620
2572− assert(s->x >= 0 && s->y >= 0 && s->data != NULL && s->refreshBuffer != NULL);
2621+ assert(s->data != NULL && s->refreshBuffer != NULL);
25732622
25742623 sw = s->w;
25752624 sh = s->h;
2576− dst32 = &pixelBuffer[(s->y * SCREEN_W) + s->x];
2625+ sx = s->x;
2626+ sy = s->y;
2627+ srcPtrBias = 0;
2628+
2629+ // if x is negative, adjust variables
2630+ if (sx < 0)
2631+ {
2632+ sw += sx; // subtraction
2633+ srcPtrBias += -sx;
2634+ sx = 0;
2635+ }
2636+
2637+ // if y is negative, adjust variables
2638+ if (sy < 0)
2639+ {
2640+ sh += sy; // subtraction
2641+ srcPtrBias += (-sy * s->w);
2642+ sy = 0;
2643+ }
2644+
2645+ dst32 = &video.frameBuffer[(sy * SCREEN_W) + sx];
25772646 clr32 = s->refreshBuffer;
25782647
2579− // handle xy clipping
2580− if (s->y+sh >= SCREEN_H) sh = SCREEN_H - s->y;
2581− if (s->x+sw >= SCREEN_W) sw = SCREEN_W - s->x;
2648+ // handle x/y clipping
2649+ if (sx+sw >= SCREEN_W) sw = SCREEN_W - sx;
2650+ if (sy+sh >= SCREEN_H) sh = SCREEN_H - sy;
25822651
25832652 srcPitch = s->w - sw;
25842653 dstPitch = SCREEN_W - sw;
@@ -2587,7 +2656,7 @@ void renderSprites(void) · 2 unmodified lines
25872656 if (sprites[i].pixelType == SPRITE_TYPE_RGB)
25882657 {
25892658 // 24-bit RGB sprite
2590− src32 = (uint32_t *)sprites[i].data;
2659+ src32 = ((uint32_t *)sprites[i].data) + srcPtrBias;
25912660 for (y = 0; y < sh; y++)
25922661 {
25932662 for (x = 0; x < sw; x++)
@@ -2608,7 +2677,7 @@ void renderSprites(void) · 14 unmodified lines
26082677 else
26092678 {
26102679 // 8-bit paletted sprite
2611− src8 = (uint8_t *)sprites[i].data;
2680+ src8 = ((uint8_t *)sprites[i].data) + srcPtrBias;
26122681 for (y = 0; y < sh; y++)
26132682 {
26142683 for (x = 0; x < sw; x++)
@@ -2617,7 +2686,7 @@ void renderSprites(void) · 2 unmodified lines
26172686 if (*src8 != colorKey)
26182687 {
26192688 assert(*src8 < PALETTE_NUM);
2620− *dst32 = palette[*src8];
2689+ *dst32 = video.palette[*src8];
26212690 }
26222691
26232692 dst32++;
@@ -2634,21 +2703,21 @@ void renderSprites(void) · 10 unmodified lines
26342703
26352704 void flipFrame(void)
26362705 {
2637− uint32_t windowFlags = SDL_GetWindowFlags(window);
2638−
26392706 renderSprites();
2640− SDL_UpdateTexture(texture, NULL, pixelBuffer, SCREEN_W * sizeof (int32_t));
2641− SDL_RenderClear(renderer);
2642− SDL_RenderCopy(renderer, texture, NULL, NULL);
2643− SDL_RenderPresent(renderer);
2707+ SDL_UpdateTexture(video.texture, NULL, video.frameBuffer, SCREEN_W * sizeof (int32_t));
2708+ SDL_RenderClear(video.renderer);
2709+ SDL_RenderCopy(video.renderer, video.texture, NULL, NULL);
2710+ SDL_RenderPresent(video.renderer);
26442711 eraseSprites();
26452712
2646− if (!editor.ui.vsync60HzPresent)
2713+ if (!video.vsync60HzPresent)
26472714 {
26482715 waitVBL(); // we have no VSync, do crude thread sleeping to sync to ~60Hz
26492716 }
26502717 else
26512718 {
2719+ uint32_t windowFlags = SDL_GetWindowFlags(video.window);
2720+
26522721 /* We have VSync, but it can unexpectedly get inactive in certain scenarios.
26532722 ** We have to force thread sleeping (to ~60Hz) if so.
26542723 */
@@ -2658,7 +2727,7 @@ void flipFrame(void) · 3 unmodified lines
26582727 waitVBL();
26592728 #elif __unix__
26602729 // *NIX: VSync gets disabled in fullscreen mode (at least on some distros/systems). Let's add a fix:
2661− if ((windowFlags & SDL_WINDOW_MINIMIZED) || editor.fullscreen)
2730+ if ((windowFlags & SDL_WINDOW_MINIMIZED) || video.fullscreen)
26622731 waitVBL();
26632732 #else
26642733 if (windowFlags & SDL_WINDOW_MINIMIZED)
@@ -2670,20 +2739,18 @@ void flipFrame(void) · 5 unmodified lines
26702739 void updateSpectrumAnalyzer(int8_t vol, int16_t period)
26712740 {
26722741 const uint8_t maxHeight = SPECTRUM_BAR_HEIGHT + 1; // +1 because of audio latency - allows full height to be seen
2673− int16_t scaledVol;
2674− int32_t scaledNote;
2742+ int32_t scaledVol, scaledNote;
26752743
26762744 if (editor.ui.visualizerMode != VISUAL_SPECTRUM || vol <= 0)
26772745 return;
26782746
2679− scaledVol = (vol * 256) / ((64 * 256) / (SPECTRUM_BAR_NUM+1)); // 64 = max sample vol
2747+ scaledVol = (vol * 24600L) >> 16; // scaledVol = (vol << 8) / 682
26802748
26812749 period = CLAMP(period, 113, 856);
26822750
2683− // 856 = C-1 period, 113 = B-3 period
2684− scaledNote = (856-113) - (period - 113);
2751+ scaledNote = 856 - period;
26852752 scaledNote *= scaledNote;
2686− scaledNote /= ((856 - 113) * (856 - 113)) / (SPECTRUM_BAR_NUM-1);
2753+ scaledNote = ((int64_t)scaledNote * 171162) >> 32; // scaledNote /= 25093
26872754
26882755 // scaledNote now ranges 0..22, no need to clamp
26892756
@@ -2711,24 +2778,27 @@ void updateSpectrumAnalyzer(int8_t vol, int16_t period) · 21 unmodified lines
27112778
27122779 void sinkVisualizerBars(void)
27132780 {
2781+ int32_t i;
2782+
27142783 // sink stuff @ 50Hz rate
27152784
2716− const uint64_t _50HzCounterDelta = ((uint64_t)AMIGA_PAL_VBLANK_HZ << 32) / VBLANK_HZ;
2785+ static uint64_t counter50Hz;
2786+ const uint64_t counter50HzDelta = ((uint64_t)AMIGA_PAL_VBLANK_HZ << 32) / VBLANK_HZ;
27172787
2718− _50HzCounter += _50HzCounterDelta; // 32.32 fixed-point counter
2719− if (_50HzCounter > 0xFFFFFFFF)
2788+ counter50Hz += counter50HzDelta; // 32.32 fixed-point counter
2789+ if (counter50Hz > 0xFFFFFFFF)
27202790 {
2721− _50HzCounter &= 0xFFFFFFFF;
2791+ counter50Hz &= 0xFFFFFFFF;
27222792
27232793 // sink VU-meters
2724− for (uint32_t i = 0; i < AMIGA_VOICES; i++)
2794+ for (i = 0; i < AMIGA_VOICES; i++)
27252795 {
27262796 if (editor.vuMeterVolumes[i] > 0)
27272797 editor.vuMeterVolumes[i]--;
27282798 }
27292799
27302800 // sink "spectrum analyzer" bars
2731− for (uint32_t i = 0; i < SPECTRUM_BAR_NUM; i++)
2801+ for (i = 0; i < SPECTRUM_BAR_NUM; i++)
27322802 {
27332803 if (editor.spectrumVolumes[i] > 0)
27342804 editor.spectrumVolumes[i]--;
@@ -2746,57 +2816,57 @@ void updateRenderSizeVars(void) · 11 unmodified lines
27462816 float fXScale, fYScale;
27472817 SDL_DisplayMode dm;
27482818
2749− di = SDL_GetWindowDisplayIndex(window);
2819+ di = SDL_GetWindowDisplayIndex(video.window);
27502820 if (di < 0)
27512821 di = 0; /* return display index 0 (default) on error */
27522822
27532823 SDL_GetDesktopDisplayMode(di, &dm);
2754− editor.ui.displayW = dm.w;
2755− editor.ui.displayH = dm.h;
2824+ video.displayW = dm.w;
2825+ video.displayH = dm.h;
27562826
2757− if (editor.fullscreen)
2827+ if (video.fullscreen)
27582828 {
2759− if (ptConfig.fullScreenStretch)
2829+ if (config.fullScreenStretch)
27602830 {
2761− editor.ui.renderW = editor.ui.displayW;
2762− editor.ui.renderH = editor.ui.displayH;
2763− editor.ui.renderX = 0;
2764− editor.ui.renderY = 0;
2831+ video.renderW = video.displayW;
2832+ video.renderH = video.displayH;
2833+ video.renderX = 0;
2834+ video.renderY = 0;
27652835 }
27662836 else
27672837 {
2768− SDL_RenderGetScale(renderer, &fXScale, &fYScale);
2838+ SDL_RenderGetScale(video.renderer, &fXScale, &fYScale);
27692839
2770− editor.ui.renderW = (int32_t)(SCREEN_W * fXScale);
2771− editor.ui.renderH = (int32_t)(SCREEN_H * fYScale);
2840+ video.renderW = (int32_t)(SCREEN_W * fXScale);
2841+ video.renderH = (int32_t)(SCREEN_H * fYScale);
27722842
27732843 #ifdef __APPLE__
27742844 // retina high-DPI hackery (SDL2 is bad at reporting actual rendering sizes on macOS w/ high-DPI)
2775− SDL_GL_GetDrawableSize(window, &actualScreenW, &actualScreenH);
2845+ SDL_GL_GetDrawableSize(video.window, &actualScreenW, &actualScreenH);
27762846 SDL_GetDesktopDisplayMode(0, &dm);
27772847
2778− dXUpscale = ((double)actualScreenW / editor.ui.displayW);
2779− dYUpscale = ((double)actualScreenH / editor.ui.displayH);
2848+ dXUpscale = ((double)actualScreenW / video.displayW);
2849+ dYUpscale = ((double)actualScreenH / video.displayH);
27802850
27812851 // downscale back to correct sizes
2782− if (dXUpscale != 0.0) editor.ui.renderW = (int32_t)(editor.ui.renderW / dXUpscale);
2783− if (dYUpscale != 0.0) editor.ui.renderH = (int32_t)(editor.ui.renderH / dYUpscale);
2852+ if (dXUpscale != 0.0) video.renderW = (int32_t)(video.renderW / dXUpscale);
2853+ if (dYUpscale != 0.0) video.renderH = (int32_t)(video.renderH / dYUpscale);
27842854 #endif
2785− editor.ui.renderX = (editor.ui.displayW - editor.ui.renderW) / 2;
2786− editor.ui.renderY = (editor.ui.displayH - editor.ui.renderH) / 2;
2855+ video.renderX = (video.displayW - video.renderW) >> 1;
2856+ video.renderY = (video.displayH - video.renderH) >> 1;
27872857 }
27882858 }
27892859 else
27902860 {
2791− SDL_GetWindowSize(window, &editor.ui.renderW, &editor.ui.renderH);
2861+ SDL_GetWindowSize(video.window, &video.renderW, &video.renderH);
27922862
2793− editor.ui.renderX = 0;
2794− editor.ui.renderY = 0;
2863+ video.renderX = 0;
2864+ video.renderY = 0;
27952865 }
27962866
27972867 // for mouse cursor creation
2798− editor.ui.xScale = (int32_t)((editor.ui.renderW / (double)SCREEN_W) + 0.5);
2799− editor.ui.yScale = (int32_t)((editor.ui.renderH / (double)SCREEN_H) + 0.5);
2868+ video.xScale = (int32_t)((video.renderW * (1.0 / SCREEN_W)) + 0.5);
2869+ video.yScale = (int32_t)((video.renderH * (1.0 / SCREEN_H)) + 0.5);
28002870 createMouseCursors();
28012871 }
28022872
@@ -2804,47 +2874,47 @@ void toggleFullScreen(void) · 1 unmodified line
28042874 {
28052875 SDL_DisplayMode dm;
28062876
2807− editor.fullscreen ^= 1;
2808− if (editor.fullscreen)
2877+ video.fullscreen ^= 1;
2878+ if (video.fullscreen)
28092879 {
2810− if (ptConfig.fullScreenStretch)
2880+ if (config.fullScreenStretch)
28112881 {
28122882 SDL_GetDesktopDisplayMode(0, &dm);
2813− SDL_RenderSetLogicalSize(renderer, dm.w, dm.h);
2883+ SDL_RenderSetLogicalSize(video.renderer, dm.w, dm.h);
28142884 }
28152885 else
28162886 {
2817− SDL_RenderSetLogicalSize(renderer, SCREEN_W, SCREEN_H);
2887+ SDL_RenderSetLogicalSize(video.renderer, SCREEN_W, SCREEN_H);
28182888 }
28192889
2820− SDL_SetWindowSize(window, SCREEN_W, SCREEN_H);
2821− SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_DESKTOP);
2822− SDL_SetWindowGrab(window, SDL_TRUE);
2890+ SDL_SetWindowSize(video.window, SCREEN_W, SCREEN_H);
2891+ SDL_SetWindowFullscreen(video.window, SDL_WINDOW_FULLSCREEN_DESKTOP);
2892+ SDL_SetWindowGrab(video.window, SDL_TRUE);
28232893 }
28242894 else
28252895 {
2826− SDL_SetWindowFullscreen(window, 0);
2827− SDL_RenderSetLogicalSize(renderer, SCREEN_W, SCREEN_H);
2828− SDL_SetWindowSize(window, SCREEN_W * ptConfig.videoScaleFactor, SCREEN_H * ptConfig.videoScaleFactor);
2829− SDL_SetWindowPosition(window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
2830− SDL_SetWindowGrab(window, SDL_FALSE);
2896+ SDL_SetWindowFullscreen(video.window, 0);
2897+ SDL_RenderSetLogicalSize(video.renderer, SCREEN_W, SCREEN_H);
2898+ SDL_SetWindowSize(video.window, SCREEN_W * config.videoScaleFactor, SCREEN_H * config.videoScaleFactor);
2899+ SDL_SetWindowPosition(video.window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
2900+ SDL_SetWindowGrab(video.window, SDL_FALSE);
28312901 }
28322902
28332903 updateRenderSizeVars();
28342904 updateMouseScaling();
28352905
2836− if (editor.fullscreen)
2906+ if (video.fullscreen)
28372907 {
2838− input.mouse.setPosX = editor.ui.displayW / 2;
2839− input.mouse.setPosY = editor.ui.displayH / 2;
2908+ mouse.setPosX = video.displayW >> 1;
2909+ mouse.setPosY = video.displayH >> 1;
28402910 }
28412911 else
28422912 {
2843− input.mouse.setPosX = editor.ui.renderW / 2;
2844− input.mouse.setPosY = editor.ui.renderH / 2;
2913+ mouse.setPosX = video.renderW >> 1;
2914+ mouse.setPosY = video.renderH >> 1;
28452915 }
28462916
2847− input.mouse.setPosFlag = true;
2917+ mouse.setPosFlag = true;
28482918 }
28492919
28502920 bool setupVideo(void)
@@ -2853,8 +2923,8 @@ bool setupVideo(void) · 2 unmodified lines
28532923 uint32_t rendererFlags;
28542924 SDL_DisplayMode dm;
28552925
2856− screenW = SCREEN_W * ptConfig.videoScaleFactor;
2857− screenH = SCREEN_H * ptConfig.videoScaleFactor;
2926+ screenW = SCREEN_W * config.videoScaleFactor;
2927+ screenH = SCREEN_H * config.videoScaleFactor;
28582928
28592929 rendererFlags = 0;
28602930
@@ -2868,38 +2938,38 @@ bool setupVideo(void) · 7 unmodified lines
28682938 SDL_SetHint(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, "1");
28692939 #endif
28702940
2871− editor.ui.vsync60HzPresent = false;
2872− if (!ptConfig.vsyncOff)
2941+ video.vsync60HzPresent = false;
2942+ if (!config.vsyncOff)
28732943 {
28742944 SDL_GetDesktopDisplayMode(0, &dm);
28752945 if (dm.refresh_rate >= 59 && dm.refresh_rate <= 61)
28762946 {
2877− editor.ui.vsync60HzPresent = true;
2947+ video.vsync60HzPresent = true;
28782948 rendererFlags |= SDL_RENDERER_PRESENTVSYNC;
28792949 }
28802950 }
28812951
2882− window = SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED,
2952+ video.window = SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED,
28832953 SDL_WINDOWPOS_CENTERED, screenW, screenH,
28842954 SDL_WINDOW_HIDDEN | SDL_WINDOW_ALLOW_HIGHDPI);
28852955
2886− if (window == NULL)
2956+ if (video.window == NULL)
28872957 {
28882958 showErrorMsgBox("Couldn't create SDL window:\n%s", SDL_GetError());
28892959 return false;
28902960 }
28912961
2892− renderer = SDL_CreateRenderer(window, -1, rendererFlags);
2893− if (renderer == NULL)
2962+ video.renderer = SDL_CreateRenderer(video.window, -1, rendererFlags);
2963+ if (video.renderer == NULL)
28942964 {
2895− if (editor.ui.vsync60HzPresent) // try again without vsync flag
2965+ if (video.vsync60HzPresent) // try again without vsync flag
28962966 {
2897− editor.ui.vsync60HzPresent = false;
2967+ video.vsync60HzPresent = false;
28982968 rendererFlags &= ~SDL_RENDERER_PRESENTVSYNC;
2899− renderer = SDL_CreateRenderer(window, -1, rendererFlags);
2969+ video.renderer = SDL_CreateRenderer(video.window, -1, rendererFlags);
29002970 }
29012971
2902− if (renderer == NULL)
2972+ if (video.renderer == NULL)
29032973 {
29042974 showErrorMsgBox("Couldn't create SDL renderer:\n%s\n\n" \
29052975 "Is your GPU (+ driver) too old?", SDL_GetError());
@@ -2907,38 +2977,41 @@ bool setupVideo(void) · 1 unmodified line
29072977 }
29082978 }
29092979
2910− SDL_RenderSetLogicalSize(renderer, SCREEN_W, SCREEN_H);
2980+ SDL_RenderSetLogicalSize(video.renderer, SCREEN_W, SCREEN_H);
29112981
29122982 #if SDL_PATCHLEVEL >= 5
2913− SDL_RenderSetIntegerScale(renderer, SDL_TRUE);
2983+ SDL_RenderSetIntegerScale(video.renderer, SDL_TRUE);
29142984 #endif
29152985
2916− SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE);
2986+ SDL_SetRenderDrawBlendMode(video.renderer, SDL_BLENDMODE_NONE);
29172987
29182988 SDL_SetHint("SDL_RENDER_SCALE_QUALITY", "nearest");
29192989
2920− texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, SCREEN_W, SCREEN_H);
2921− if (texture == NULL)
2990+ video.texture = SDL_CreateTexture(video.renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, SCREEN_W, SCREEN_H);
2991+ if (video.texture == NULL)
29222992 {
29232993 showErrorMsgBox("Couldn't create %dx%d GPU texture:\n%s\n\n" \
29242994 "Is your GPU (+ driver) too old?", SCREEN_W, SCREEN_H, SDL_GetError());
29252995 return false;
29262996 }
29272997
2928− SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_NONE);
2998+ SDL_SetTextureBlendMode(video.texture, SDL_BLENDMODE_NONE);
29292999
29303000 // frame buffer used by SDL (for texture)
2931− pixelBuffer = (uint32_t *)malloc(SCREEN_W * SCREEN_H * sizeof (int32_t));
2932− if (pixelBuffer == NULL)
3001+ video.frameBufferUnaligned = (uint32_t *)MALLOC_PAD(SCREEN_W * SCREEN_H * sizeof (int32_t), 256);
3002+ if (video.frameBufferUnaligned == NULL)
29333003 {
29343004 showErrorMsgBox("Out of memory!");
29353005 return false;
29363006 }
29373007
3008+ // we want an aligned pointer
3009+ video.frameBuffer = (uint32_t *)ALIGN_PTR(video.frameBufferUnaligned, 256);
3010+
29383011 updateRenderSizeVars();
29393012 updateMouseScaling();
29403013
2941− if (ptConfig.hwMouse)
3014+ if (config.hwMouse)
29423015 SDL_ShowCursor(SDL_TRUE);
29433016 else
29443017 SDL_ShowCursor(SDL_FALSE);
src/pt2_visuals.h+1−1
@@ -68,7 +68,7 @@ void showVolToSlider(void); · 67 unmodified lines
6868 void updateCurrSample(void);
6969 void eraseSprites(void);
7070 void renderSprites(void);
71−void updateDragBars(void);
71+void handleLastGUIObjectDown(void);
7272 void invertRange(void);
7373 void updateCursorPos(void);
7474 void renderVuMeters(void);
vs2019_project/pt2-clone/pt2-clone.vcxproj+3−0
@@ -206,6 +206,7 @@ · 205 unmodified lines
206206 <OpenMPSupport>false</OpenMPSupport>
207207 <LanguageStandard>stdcpplatest</LanguageStandard>
208208 <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
209+ <Optimization>Disabled</Optimization>
209210 </ClCompile>
210211 <Link>
211212 <SubSystem>Windows</SubSystem>
@@ -247,6 +248,8 @@ · 35 unmodified lines
247248 <OpenMPSupport>false</OpenMPSupport>
248249 <LanguageStandard>stdcpplatest</LanguageStandard>
249250 <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
251+ <Optimization>Disabled</Optimization>
252+ <OmitFramePointers>false</OmitFramePointers>
250253 </ClCompile>
251254 <Link>
252255 <SubSystem>Windows</SubSystem>

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t